@blazingagents/sdk 0.43.0 → 0.43.1

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 CHANGED
@@ -10,19 +10,24 @@
10
10
  </p>
11
11
  </div>
12
12
 
13
- The official resource-style client SDK for the Blazing Agents `/v1` API. It
14
- requires Node.js 24 or newer.
13
+ The official TypeScript SDK is a client for the Blazing Agents `/v1` API that
14
+ your backend uses to manage Agents and run them for your users. It requires
15
+ Node.js 24 or newer.
15
16
 
16
17
  ## Features
17
18
 
18
- - Typed clients for Agents, Workspaces, Skills, Providers, Prompts, Tasks,
19
- Sessions, Artifacts, Slack and Telegram Chat Connections, usage, Tenant settings, and merchant monetization.
20
- - Stateful chat with explicit message batches, steer receipts, and one-call Tool approvals.
21
- - Stateless text or structured-object generation.
22
- - Public Zod contracts for validating API requests and responses.
23
- - Cursor pagination and binary transfers.
24
- - Request correlation and a typed, forward-compatible error model.
25
- - End-user scoped clients for user-owned resources and generation.
19
+ - A typed method for every `/v1` operation an API key can call: Agents,
20
+ Skills, Sessions, Memories, Prompts, Tasks, Workspaces, Artifacts,
21
+ Providers, MCP Connections, Chat Connections, usage, spending limits, Tenant
22
+ settings, and merchant monetization.
23
+ - Chat streams in the AI SDK UI message stream format, with steering, Tool
24
+ approvals, and backend functions that run in your process.
25
+ - Text and structured-object generation.
26
+ - End-user scoped clients through `forUser`.
27
+ - Cursor pagination, uploads, and downloads.
28
+ - Request IDs and typed errors.
29
+ - `BlazingAgentsChatTransport` and `createChatRelay` connect AI SDK `useChat`
30
+ to your backend.
26
31
 
27
32
  ## Installation
28
33
 
@@ -30,19 +35,21 @@ requires Node.js 24 or newer.
30
35
  npm install @blazingagents/sdk ai@^7.0.84 zod@^4.5.4
31
36
  ```
32
37
 
33
- `ai` (`^7.0.84`) and `zod` (`^4.5.4`) are peer dependencies. The SDK
34
- re-exports AI SDK message types and Zod schemas, so consumers share these
35
- dependencies with the SDK.
38
+ `ai` and `zod` are required peer dependencies. The SDK re-exports AI SDK
39
+ message types and Zod schemas, so your app and the SDK share one copy of each.
36
40
 
37
41
  ## Quick start
38
42
 
39
- Create a Tenant API key in the Blazing Agents dashboard, then pass it to the
40
- client or read it from your server environment.
43
+ Create a Full API key in the Blazing Agents dashboard and set
44
+ `BLAZING_AGENTS_API_KEY` in your server environment. The key acts for your
45
+ whole Tenant, so keep it on your backend and never send it to a browser.
41
46
 
42
47
  ```ts
43
48
  import { BlazingAgents } from "@blazingagents/sdk";
44
49
 
45
- const client = new BlazingAgents({ apiKey: "ba_..." });
50
+ const client = new BlazingAgents({
51
+ apiKey: process.env.BLAZING_AGENTS_API_KEY!,
52
+ });
46
53
 
47
54
  const result = await client.completion({
48
55
  agentId: "ag_...",
@@ -52,32 +59,59 @@ const result = await client.completion({
52
59
  console.log(await result.text);
53
60
  ```
54
61
 
55
- For stateful chat, pass one user message or an ordered batch.
62
+ Replace `ag_...` with an Agent ID from the dashboard.
56
63
 
57
- ```ts
58
- const chat = await client.chat({
59
- agentId: "ag_...",
60
- messages: [
61
- { id: "first", role: "user", parts: [{ type: "text", text: "Compare the plans." }] },
62
- { id: "second", role: "user", parts: [{ type: "text", text: "Include annual pricing." }] },
63
- ],
64
- });
64
+ For requests from your users, scope the client to the user ID that your
65
+ backend verified at sign-in, never to an ID from the request body. A scoped
66
+ client reaches only that End-user's Agents, Sessions, and Workspace. An
67
+ unscoped Agent shares one Workspace across all your users, so give each user
68
+ an Agent of their own:
65
69
 
66
- const sessionId = await chat.sessionId;
67
- return chat.toResponse();
70
+ ```ts
71
+ export async function createAgentForUser(userId: string): Promise<string> {
72
+ const agent = await client.forUser(userId).agents.create({
73
+ name: "Assistant",
74
+ providerId: "prv_...",
75
+ model: "openai/gpt-6-luna",
76
+ });
77
+ return agent.id;
78
+ }
79
+
80
+ export async function chatAsUser(
81
+ userId: string,
82
+ agentId: string,
83
+ text: string
84
+ ): Promise<Response> {
85
+ const chat = await client.forUser(userId).chat({
86
+ agentId,
87
+ message: {
88
+ id: crypto.randomUUID(),
89
+ role: "user",
90
+ parts: [{ type: "text", text }],
91
+ },
92
+ });
93
+ return chat.toResponse();
94
+ }
68
95
  ```
69
96
 
70
- Keep API keys on the server. For browser chat applications, serve
71
- `createChatRelay` from your backend and use `BlazingAgentsChatTransport` with
72
- AI SDK `useChat`. The relay runs each request as the signed-in End-user with
73
- `client.forUser(userId)`.
97
+ Call `createAgentForUser` once per user and store the Agent ID with the user.
98
+ A scoped chat with an Agent created without the scope fails with `404`.
99
+ `chatAsUser` returns the chat as a streaming `Response`. To chat from the
100
+ browser with `useChat`, serve `createChatRelay` from your backend and use
101
+ `BlazingAgentsChatTransport`. The relay scopes each request to the user that
102
+ your `resolveContext` returns.
103
+
104
+ ## Examples
105
+
106
+ The [examples repository](https://github.com/blazingagents/examples) has
107
+ complete TypeScript and Python apps built on the Blazing Agents SDKs.
74
108
 
75
109
  ## Documentation
76
110
 
77
111
  Read the
78
112
  [TypeScript SDK documentation](https://docs.blazingagents.com/sdk/typescript)
79
- for authentication, resource guides, generation and streaming, React
80
- integration, error handling, and the complete API reference.
113
+ for client setup, End-user scoping, chat and generation, a guide to each
114
+ resource, and error handling.
81
115
 
82
116
  ## Development
83
117
 
@@ -41,7 +41,7 @@ export const createMemoryBodySchema = z
41
41
  text: memoryTextSchema.describe("The note to remember, up to 10 KiB."),
42
42
  userId: userIdSchema
43
43
  .default("")
44
- .describe("The end user this memory belongs to. Only turns that pass the same `userId` see it. Leave it out or send an empty string for a general memory that every turn of the agent sees. It cannot change after creation."),
44
+ .describe("The end user this memory belongs to. Turns for that end user see it. Leave it out or send an empty string for a general memory, which unscoped turns see; a turn made through `forUser` sees only its end user's memories. It cannot change after creation."),
45
45
  })
46
46
  .strict();
47
47
  export const updateMemoryBodySchema = z
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazingagents/sdk",
3
- "version": "0.43.0",
3
+ "version": "0.43.1",
4
4
  "description": "TypeScript SDK for the Blazing Agents API",
5
5
  "homepage": "https://docs.blazingagents.com",
6
6
  "bugs": {