@sandagent/sdk — Vercel AI SDK Streams와 함께 샌드박스에서 Claude 실행
Source: Dev.to
Overview
sandagent/sdk는 샌드박스 환경(로컬 또는 클라우드)에서 Claude 에이전트를 실행하기 위한 TypeScript/JavaScript SDK입니다. Vercel AI SDK와 호환되는 스트리밍을 제공하여 다음을 할 수 있습니다:
- API 키를 노출하지 않고 제어된 샌드박스에서 AI 에이전트를 실행
- Vercel AI SDK 프로토콜을 사용해 메시지를 스트리밍
- UI 구축을 위한 선택적 React 채팅 훅 사용
- 샌드박스된 에이전트를 SDK 호환 모델로 노출
npm:
Example: Create a Sandboxed Session & Stream Messages
The following example demonstrates how to create a sandboxed session and stream messages in a way compatible with the Vercel AI SDK. The React chat hooks can be used to integrate real‑time UI components seamlessly.
import { SandAgentClient } from "@sandagent/sdk";
const client = new SandAgentClient({ apiKey: process.env.SANDAGENT_API_KEY });
// Create a sandboxed agent session
const session = await client.createSession("example-session", {
model: "claude-2",
});
// Stream messages
const stream = client.streamMessages(session.id, { prompt: "Hello!" });
for await (const chunk of stream) {
console.log(chunk);
}