@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 +67 -33
- package/dist/contracts/entities/memories.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,19 +10,24 @@
|
|
|
10
10
|
</p>
|
|
11
11
|
</div>
|
|
12
12
|
|
|
13
|
-
The official
|
|
14
|
-
|
|
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
|
-
-
|
|
19
|
-
Sessions,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
- End-user scoped clients
|
|
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`
|
|
34
|
-
|
|
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
|
|
40
|
-
|
|
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({
|
|
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
|
-
|
|
62
|
+
Replace `ag_...` with an Agent ID from the dashboard.
|
|
56
63
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
67
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
`
|
|
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
|
|
80
|
-
|
|
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.
|
|
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
|