# `@sylphx/sdk` — TypeScript Platform SDK

First-class **external** TypeScript client for Sylphx Platform.

| Language | App (runtime) | Management (operators) |
| --- | --- | --- |
| **TypeScript** | `@sylphx/sdk` → `Client` | `@sylphx/sdk` → `ManagementClient` |
| **Rust** | `sylphx-sdk` | `sylphx-sdk-management` |

**Wire authority:** Protobuf under `api/proto/sylphx/platform/v1/` (sole).  
Not Effect Schema / `@sylphx/contract`.

## Install

```bash
npm install @sylphx/sdk
# or: bun add @sylphx/sdk
```

## App client (runtime / BaaS)

```ts
import { Client } from '@sylphx/sdk'

const client = Client.create(process.env.SYLPHX_SECRET_KEY!, 'my-tenant')
await client.kvSet('user:1', { name: 'Ada' }, 60)
const value = await client.kvGet('user:1')
await client.kvDelete('user:1')
// Typed beyond foundation (Protobuf KvIncr):
await client.kvIncr('visits', 1)
await client.kvExists('visits')
await client.kvExpire('visits', 3600)
```

## Management client

```ts
import { ManagementClient } from '@sylphx/sdk'

const mgmt = ManagementClient.create(process.env.SYLPHX_TOKEN!)
await mgmt.health()
const me = await mgmt.whoami()
const projects = await mgmt.listProjects()
const project = await mgmt.getProject('prj_…')
// Typed beyond foundation (Protobuf ListEnvironments):
const envs = await mgmt.listEnvironments('prj_…')
const env = await mgmt.getEnvironment('prj_…', 'env_…')
const deps = await mgmt.listDeployments('prj_…')
// Escape hatch for any Management REST route:
await mgmt.api('GET', '/projects')
```

## Contract identity

```ts
import { WIRE_CONTRACT_PACKAGE, WIRE_CONTRACT_REVISION } from '@sylphx/sdk'
// sylphx.platform.v1 @ 0.3.0 — same as Rust sylphx-wire
```

## CLI

Operator CLI is the **Rust** binary `sylphx` (crate `sylphx-cli`). Install via
either channel — same binary product:

```bash
npm install -g @sylphx/cli    # npm channel (native binary optionalDeps)
cargo install sylphx-cli      # crates.io channel
```

## Install (commercial)

```bash
# TypeScript library
npm install @sylphx/sdk

# Rust libraries
# Cargo.toml: sylphx-sdk = "0.1", sylphx-sdk-management = "0.1"

# Operator CLI (Rust binary — npm or cargo)
npm install -g @sylphx/cli
# or: cargo install sylphx-cli
```
