@sandagent/sdk 0.2.4 → 0.2.5

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.
Files changed (2) hide show
  1. package/README.md +142 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # @sandagent/sdk
2
+
3
+ SandAgent SDK - AI Provider and React hooks for building AI agents with sandboxed execution.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm install @sandagent/sdk ai
9
+ ```
10
+
11
+ For React applications:
12
+
13
+ ```bash
14
+ npm install @sandagent/sdk ai react react-dom
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ### Backend
20
+
21
+ ```typescript
22
+ import { createSandAgent, LocalSandbox } from "@sandagent/sdk";
23
+ import { streamText, createUIMessageStream, createUIMessageStreamResponse } from "ai";
24
+
25
+ const sandbox = new LocalSandbox({
26
+ workdir: process.cwd(),
27
+ env: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY },
28
+ });
29
+
30
+ const sandagent = createSandAgent({ sandbox });
31
+
32
+ // Use with AI SDK
33
+ const result = streamText({
34
+ model: sandagent("sonnet"),
35
+ messages: [{ role: "user", content: "Hello!" }],
36
+ });
37
+ ```
38
+
39
+ ### Frontend
40
+
41
+ ```tsx
42
+ import { useSandAgentChat } from "@sandagent/sdk/react";
43
+
44
+ export default function ChatPage() {
45
+ const { messages, sendMessage, isLoading } = useSandAgentChat({
46
+ apiEndpoint: "/api/ai",
47
+ });
48
+
49
+ return (
50
+ <div>
51
+ {messages.map((msg) => (
52
+ <div key={msg.id}>{/* render message */}</div>
53
+ ))}
54
+ <button onClick={() => sendMessage("Hello!")}>Send</button>
55
+ </div>
56
+ );
57
+ }
58
+ ```
59
+
60
+ ## Environment Variables
61
+
62
+ Set up your API key:
63
+
64
+ **Anthropic API (Recommended):**
65
+ ```bash
66
+ ANTHROPIC_API_KEY=sk-ant-xxx
67
+ ```
68
+
69
+ **AWS Bedrock:**
70
+ ```bash
71
+ AWS_BEARER_TOKEN_BEDROCK=xxx
72
+ ```
73
+
74
+ ## Features
75
+
76
+ - **AI Provider**: Use SandAgent as an AI SDK provider
77
+ - **React Hooks**: `useSandAgentChat` for chat interfaces
78
+ - **Artifacts**: Automatically extract and display AI-generated files
79
+ - **Custom Sandboxes**: Works with E2B, Sandock, Daytona, and Local sandboxes
80
+
81
+ ## API Reference
82
+
83
+ ### Backend Exports
84
+
85
+ ```typescript
86
+ import {
87
+ createSandAgent, // Create SandAgent provider
88
+ LocalSandbox, // Local sandbox adapter
89
+ SandAgentLanguageModel, // Language model class
90
+ resolveModelId, // Resolve model ID alias
91
+ } from "@sandagent/sdk";
92
+ ```
93
+
94
+ ### Frontend Exports
95
+
96
+ ```typescript
97
+ import {
98
+ useSandAgentChat, // Main chat hook
99
+ useArtifacts, // Artifacts management hook
100
+ useAskUserQuestion, // User question UI hook
101
+ useWriteTool, // Write tool UI hook
102
+ } from "@sandagent/sdk/react";
103
+ ```
104
+
105
+ ## Usage
106
+
107
+ ### Artifacts
108
+
109
+ ```tsx
110
+ const { artifacts, selectedArtifact, setSelectedArtifact } = useSandAgentChat({
111
+ apiEndpoint: "/api/ai",
112
+ });
113
+ ```
114
+
115
+ ### Custom Agent Templates
116
+
117
+ Create a template directory with `CLAUDE.md` and skills:
118
+
119
+ ```
120
+ my-agent-template/
121
+ ├── CLAUDE.md
122
+ └── .claude/
123
+ └── skills/
124
+ └── my-skill/
125
+ └── SKILL.md
126
+ ```
127
+
128
+ Pass the template path to `LocalSandbox`:
129
+
130
+ ```typescript
131
+ const sandbox = new LocalSandbox({
132
+ workdir: process.cwd(),
133
+ templatesPath: "./my-agent-template",
134
+ env: { ANTHROPIC_API_KEY },
135
+ });
136
+ ```
137
+
138
+ All files (including `CLAUDE.md` and `.claude/skills/`) will be automatically copied to the workspace.
139
+
140
+ ## License
141
+
142
+ Apache-2.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sandagent/sdk",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "SandAgent SDK - AI Provider and React hooks for building AI agents",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -49,7 +49,7 @@
49
49
  "dependencies": {
50
50
  "@ai-sdk/provider": "^3.0.5",
51
51
  "@ai-sdk/react": "^3.0.52",
52
- "@sandagent/manager": "0.2.4"
52
+ "@sandagent/manager": "0.2.5"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/node": "^20.10.0",