bma-sdk
GitHub ↗适合: 调用平台 API 的应用。
- Agent、会话、SSE 事件流
- 文件、产物、电脑、桌面、终端
- 可续传 SSE · 幂等键 · 类型化错误
$
npm install @beeos-ai/bma-sdkimport { BmaClient } from "@beeos-ai/bma-sdk";
const client = new BmaClient({ apiKey: process.env.BMA_API_KEY!, baseURL: process.env.BMA_BASE_URL! });
const session = await client.beta.sessions.create({ agent: agentId, environment_id: environmentId });
// Open the stream first, then send: an interrupted stream resumes with Last-Event-ID.
const stream = await client.beta.sessions.events.stream(session.id);
await client.beta.sessions.events.send(session.id, {
events: [{ type: "user.message", content: [{ type: "text", text: "Plan my week." }] }],
});
for await (const ev of stream) {
if (ev.type === "agent.message") console.log(ev.content);
if (ev.type === "session.status_idle") break;
}