@sandagent/sdk 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -0
- package/package.json +4 -2
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# @sandagent/sdk
|
|
2
|
+
|
|
3
|
+
Run Claude in a sandbox. Stream from your API, chat from React.
|
|
4
|
+
|
|
5
|
+
`@sandagent/sdk` is the easiest way to run an agent in a sandbox (local or cloud) and expose it as an AI SDK-compatible model, with optional React chat hooks for your UI.
|
|
6
|
+
|
|
7
|
+
## What you get
|
|
8
|
+
|
|
9
|
+
- A provider (`createSandAgent`) that you can pass to AI SDK APIs (e.g. `streamText`, `generateText`)
|
|
10
|
+
- A built-in `LocalSandbox` for local development
|
|
11
|
+
- React hooks under `@sandagent/sdk/react` for building chat UIs
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @sandagent/sdk ai
|
|
17
|
+
npm install react react-dom
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quickstart
|
|
21
|
+
|
|
22
|
+
Typical setup:
|
|
23
|
+
1) **Server**: create a sandbox + provider and stream AI SDK UI messages.
|
|
24
|
+
2) **Client**: call your API route with the React hook.
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { createSandAgent, LocalSandbox } from "@sandagent/sdk";
|
|
28
|
+
import {
|
|
29
|
+
createUIMessageStream,
|
|
30
|
+
createUIMessageStreamResponse,
|
|
31
|
+
streamText,
|
|
32
|
+
} from "ai";
|
|
33
|
+
|
|
34
|
+
const sandbox = new LocalSandbox({
|
|
35
|
+
workdir: process.cwd(),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const sandagent = createSandAgent({
|
|
39
|
+
sandbox,
|
|
40
|
+
cwd: sandbox.getWorkdir(),
|
|
41
|
+
env: {
|
|
42
|
+
ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY!,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const stream = createUIMessageStream({
|
|
47
|
+
execute: async ({ writer }) => {
|
|
48
|
+
const result = streamText({
|
|
49
|
+
model: sandagent("sonnet"),
|
|
50
|
+
messages,
|
|
51
|
+
abortSignal: request.signal,
|
|
52
|
+
});
|
|
53
|
+
writer.merge(result.toUIMessageStream());
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
return createUIMessageStreamResponse({ stream });
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { useSandAgentChat } from "@sandagent/sdk/react";
|
|
61
|
+
|
|
62
|
+
const { messages, sendMessage } = useSandAgentChat({ apiEndpoint: "/api/ai" });
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Using cloud sandboxes
|
|
66
|
+
|
|
67
|
+
- `LocalSandbox` (bundled): run on your machine (good for quickstarts/dev)
|
|
68
|
+
- Cloud adapters (separate packages): `@sandagent/sandbox-e2b`, `@sandagent/sandbox-daytona`, `@sandagent/sandbox-sandock`
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sandagent/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "SandAgent SDK - AI Provider and React hooks for building AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -49,17 +49,19 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@ai-sdk/provider": "^3.0.5",
|
|
51
51
|
"@ai-sdk/react": "^3.0.52",
|
|
52
|
-
"@sandagent/manager": "0.2.
|
|
52
|
+
"@sandagent/manager": "0.2.8"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^20.10.0",
|
|
56
56
|
"@types/react": "^19.2.0",
|
|
57
57
|
"@types/react-dom": "^19.2.0",
|
|
58
|
+
"vitest": "^1.6.1",
|
|
58
59
|
"tsup": "^8.5.0",
|
|
59
60
|
"typescript": "^5.9.3"
|
|
60
61
|
},
|
|
61
62
|
"scripts": {
|
|
62
63
|
"build": "tsup",
|
|
64
|
+
"test": "vitest run --passWithNoTests",
|
|
63
65
|
"typecheck": "tsc --noEmit",
|
|
64
66
|
"lint": "biome format . --write && biome check . --write"
|
|
65
67
|
}
|