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;
}