mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 08:03:46 +00:00
100 lines
2.4 KiB
Text
100 lines
2.4 KiB
Text
---
|
|
title: "TypeScript SDK"
|
|
description: "Generated types and a thin fetch-based client."
|
|
---
|
|
|
|
The TypeScript SDK is generated from the OpenAPI spec produced by the Rust server.
|
|
|
|
## Generate types
|
|
|
|
```bash
|
|
pnpm --filter sandbox-agent generate
|
|
```
|
|
|
|
This runs:
|
|
|
|
- `cargo run -p sandbox-agent-openapi-gen` to emit OpenAPI JSON
|
|
- `openapi-typescript` to generate types
|
|
|
|
## Usage
|
|
|
|
```ts
|
|
import { SandboxDaemonClient } from "sandbox-agent";
|
|
|
|
const client = new SandboxDaemonClient({
|
|
baseUrl: "http://127.0.0.1:2468",
|
|
token: process.env.SANDBOX_TOKEN,
|
|
});
|
|
|
|
await client.createSession("my-session", { agent: "claude" });
|
|
await client.postMessage("my-session", { message: "Hello" });
|
|
const events = await client.getEvents("my-session", { offset: 0, limit: 50 });
|
|
```
|
|
|
|
## Endpoint mapping
|
|
|
|
<details>
|
|
<summary><strong>client.listAgents()</strong></summary>
|
|
|
|
Maps to `GET /v1/agents`.
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>client.installAgent(agentId, body)</strong></summary>
|
|
|
|
Maps to `POST /v1/agents/{agentId}/install`.
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>client.getAgentModes(agentId)</strong></summary>
|
|
|
|
Maps to `GET /v1/agents/{agentId}/modes`.
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>client.createSession(sessionId, body)</strong></summary>
|
|
|
|
Maps to `POST /v1/sessions/{sessionId}`.
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>client.postMessage(sessionId, body)</strong></summary>
|
|
|
|
Maps to `POST /v1/sessions/{sessionId}/messages`.
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>client.getEvents(sessionId, params)</strong></summary>
|
|
|
|
Maps to `GET /v1/sessions/{sessionId}/events`.
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>client.getEventsSse(sessionId, params)</strong></summary>
|
|
|
|
Maps to `GET /v1/sessions/{sessionId}/events/sse` (raw SSE response).
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>client.streamEvents(sessionId, params)</strong></summary>
|
|
|
|
Helper that parses SSE into `UniversalEvent` objects.
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>client.replyQuestion(sessionId, questionId, body)</strong></summary>
|
|
|
|
Maps to `POST /v1/sessions/{sessionId}/questions/{questionId}/reply`.
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>client.rejectQuestion(sessionId, questionId)</strong></summary>
|
|
|
|
Maps to `POST /v1/sessions/{sessionId}/questions/{questionId}/reject`.
|
|
</details>
|
|
|
|
<details>
|
|
<summary><strong>client.replyPermission(sessionId, permissionId, body)</strong></summary>
|
|
|
|
Maps to `POST /v1/sessions/{sessionId}/permissions/{permissionId}/reply`.
|
|
</details>
|