@blazingagents/sdk 0.2.1 → 0.2.2
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 +95 -346
- package/dist/contracts/api.d.ts +1 -1
- package/dist/contracts/api.js +1 -1
- package/dist/contracts/entities/agents.d.ts +14 -7
- package/dist/contracts/entities/agents.js +7 -3
- package/dist/contracts/entities/artifacts.d.ts +9 -9
- package/dist/contracts/entities/artifacts.js +5 -5
- package/dist/contracts/entities/chat.d.ts +7 -7
- package/dist/contracts/entities/chat.js +5 -5
- package/dist/contracts/entities/mcp-connections.d.ts +18 -18
- package/dist/contracts/entities/mcp-connections.js +13 -13
- package/dist/contracts/entities/memories.d.ts +5 -5
- package/dist/contracts/entities/memories.js +2 -2
- package/dist/contracts/entities/prompts.d.ts +4 -4
- package/dist/contracts/entities/prompts.js +2 -2
- package/dist/contracts/entities/providers.d.ts +12 -7
- package/dist/contracts/entities/providers.js +12 -6
- package/dist/contracts/entities/sessions.d.ts +10 -10
- package/dist/contracts/entities/sessions.js +6 -6
- package/dist/contracts/entities/skills.d.ts +18 -18
- package/dist/contracts/entities/skills.js +6 -6
- package/dist/contracts/entities/tasks.d.ts +56 -46
- package/dist/contracts/entities/tasks.js +25 -16
- package/dist/contracts/entities/tenants.d.ts +6 -6
- package/dist/contracts/entities/tenants.js +4 -4
- package/dist/contracts/entities/usage.d.ts +5 -5
- package/dist/contracts/entities/usage.js +3 -3
- package/dist/contracts/entities/workspaces.d.ts +9 -9
- package/dist/contracts/entities/workspaces.js +7 -2
- package/dist/contracts/index.d.ts +1 -1
- package/dist/contracts/index.js +1 -1
- package/dist/direct-chat-transport.d.ts +16 -0
- package/dist/direct-chat-transport.js +49 -0
- package/dist/generation.js +1 -0
- package/dist/http.d.ts +2 -0
- package/dist/http.js +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -0
- package/dist/resources/agents.js +11 -6
- package/dist/resources/artifacts.js +3 -2
- package/dist/resources/mcp-connections.js +4 -4
- package/dist/resources/memories.js +3 -2
- package/dist/resources/prompts.js +4 -3
- package/dist/resources/providers.js +10 -7
- package/dist/resources/sessions.js +4 -2
- package/dist/resources/skills.js +18 -10
- package/dist/resources/tasks.js +10 -5
- package/dist/resources/tenant.js +2 -2
- package/dist/resources/usage.js +4 -3
- package/dist/resources/workspaces.js +3 -2
- package/dist/types.d.ts +39 -33
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,389 +1,138 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://docs.blazingagents.com">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/blazingagents/docs/main/public/brand/icon.svg" alt="Blazing Agents logo" width="96">
|
|
4
|
+
</a>
|
|
5
|
+
<h1>Blazing Agents TypeScript SDK</h1>
|
|
6
|
+
<p>Build production agents with a typed TypeScript client for the Blazing Agents API.</p>
|
|
7
|
+
<p>
|
|
8
|
+
<a href="https://docs.blazingagents.com/sdk/typescript">Documentation</a> ·
|
|
9
|
+
<a href="https://www.npmjs.com/package/@blazingagents/sdk">npm</a>
|
|
10
|
+
</p>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
The official resource-style client SDK for the Blazing Agents `/v1` API. It
|
|
14
|
+
requires Node.js 24 or newer.
|
|
15
|
+
|
|
16
|
+
## Features
|
|
17
|
+
|
|
18
|
+
- Typed clients for Agents, Workspaces, Skills, Providers, Prompts, Tasks,
|
|
19
|
+
Sessions, Artifacts, usage, and Tenant settings.
|
|
20
|
+
- Stateful chat and stateless text or structured-object generation.
|
|
21
|
+
- Public Zod contracts for validating API requests and responses.
|
|
22
|
+
- Cursor pagination and binary transfers.
|
|
23
|
+
- Request correlation and a typed, forward-compatible error model.
|
|
4
24
|
|
|
5
25
|
## Installation
|
|
6
26
|
|
|
7
|
-
```
|
|
27
|
+
```console
|
|
8
28
|
npm install @blazingagents/sdk ai@7.0.84
|
|
9
29
|
```
|
|
10
30
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
The SDK wraps the Blazing Agents REST API with a thin, typed client in the
|
|
14
|
-
stripe/openai-node shape. It provides:
|
|
15
|
-
|
|
16
|
-
- **Resource namespaces** for management CRUD (`agents`, `workspaces`,
|
|
17
|
-
`prompts`, `providers`, `tasks`, `sessions`, `artifacts`, `tenant`, `usage`),
|
|
18
|
-
plus Agent-scoped Skills through `client.agent(agentId).skills`.
|
|
19
|
-
- **Generation methods** with a raw `useChat` SSE relay and AI SDK–shaped
|
|
20
|
-
completion/object results.
|
|
21
|
-
- **A single error class** (`BlazingAgentsError`) with known-code completion
|
|
22
|
-
and forward-compatible server codes.
|
|
23
|
-
|
|
24
|
-
`ai` is a peer dependency (`^7`). The SDK re-exports `UIMessage` from `ai` —
|
|
25
|
-
it never redeclares it.
|
|
26
|
-
|
|
27
|
-
## Runtime contracts
|
|
28
|
-
|
|
29
|
-
Import the public Zod schemas from the explicit contracts entry point:
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
import {
|
|
33
|
-
agentIdSchema,
|
|
34
|
-
createAgentBodySchema,
|
|
35
|
-
} from "@blazingagents/sdk/contracts";
|
|
36
|
-
|
|
37
|
-
const agentId = agentIdSchema.parse("ag_0123456789abcdef");
|
|
38
|
-
const input = createAgentBodySchema.parse({ name: "Support agent" });
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
The contracts entry point contains public HTTP request and response schemas.
|
|
42
|
-
Platform-only persistence and service contracts are not part of the SDK.
|
|
31
|
+
`ai` is a peer dependency. The SDK re-exports its `UIMessage` type.
|
|
43
32
|
|
|
44
33
|
## Quick start
|
|
45
34
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const client = new BlazingAgents({
|
|
50
|
-
apiKey: "ba_your_api_key",
|
|
51
|
-
// baseUrl defaults to https://api.blazingagents.com.
|
|
52
|
-
onResponse(response) {
|
|
53
|
-
// Store response.requestId with your logs for support correlation.
|
|
54
|
-
console.log(response.requestId, response.status);
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// --- Management ---
|
|
59
|
-
|
|
60
|
-
// Agents
|
|
61
|
-
const agent = await client.agents.create({
|
|
62
|
-
name: "My Agent",
|
|
63
|
-
model: "openrouter/auto",
|
|
64
|
-
instructions: "Be helpful.",
|
|
65
|
-
tools: ["write_todos"],
|
|
66
|
-
});
|
|
67
|
-
// Every Agent receives a Workspace. Its runtime stays lazy until first use.
|
|
68
|
-
const defaultWorkspace = await client.workspaces.get({
|
|
69
|
-
workspaceId: agent.workspaceId,
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const list = await client.agents.list();
|
|
73
|
-
const fetched = await client.agents.get(agent.id);
|
|
74
|
-
const updated = await client.agents.update(agent.id, { name: "Renamed" });
|
|
75
|
-
|
|
76
|
-
// Pass an existing Workspace to share it, or switch to one later.
|
|
77
|
-
const sharedWorkspace = await client.workspaces.create({ name: "Team files" });
|
|
78
|
-
const teammate = await client.agents.create({
|
|
79
|
-
name: "Teammate",
|
|
80
|
-
model: "openrouter/auto",
|
|
81
|
-
workspaceId: sharedWorkspace.id,
|
|
82
|
-
});
|
|
83
|
-
await client.agents.update(agent.id, { workspaceId: sharedWorkspace.id });
|
|
84
|
-
|
|
85
|
-
// Agent-owned Skills
|
|
86
|
-
const skills = client.agent(teammate.id).skills;
|
|
87
|
-
const skill = await skills.create({
|
|
88
|
-
path: "SKILL.md",
|
|
89
|
-
content: "---\nname: release-notes\ndescription: Draft release notes.\n---\n",
|
|
90
|
-
});
|
|
91
|
-
await skills.putFile({
|
|
92
|
-
skillId: skill.id,
|
|
93
|
-
path: "references/style.md",
|
|
94
|
-
content: "Use sentence case.",
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// Deleting an Agent preserves its Workspace for explicit cleanup or reuse.
|
|
98
|
-
await client.agents.delete(agent.id, false);
|
|
99
|
-
await client.workspaces.get({ workspaceId: sharedWorkspace.id });
|
|
100
|
-
|
|
101
|
-
// Prompts
|
|
102
|
-
const prompt = await client.prompts.create({
|
|
103
|
-
name: "Greeting",
|
|
104
|
-
template: "Hello {{name}}!",
|
|
105
|
-
});
|
|
106
|
-
const promptList = await client.prompts.list();
|
|
107
|
-
|
|
108
|
-
// Providers
|
|
109
|
-
const provider = await client.providers.create({
|
|
110
|
-
name: "My OpenRouter",
|
|
111
|
-
providerType: "openrouter",
|
|
112
|
-
apiKey: "sk-or-...",
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
// Tenant settings
|
|
116
|
-
const settings = await client.tenant.get();
|
|
117
|
-
await client.tenant.patch({
|
|
118
|
-
quota: { monthlyTokenLimit: 100_000, monthlyRequestLimit: null, resetDay: 1 },
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// Usage
|
|
122
|
-
const usage = await client.usage.get({ groupBy: "agent" });
|
|
123
|
-
const agentUsage = await client.usage.getForAgent(agent.id);
|
|
124
|
-
|
|
125
|
-
// Tasks
|
|
126
|
-
const task = await client.tasks.create({
|
|
127
|
-
agentId: agent.id,
|
|
128
|
-
name: "Daily Report",
|
|
129
|
-
prompt: "Generate the daily report",
|
|
130
|
-
});
|
|
131
|
-
const run = await client.tasks.createRun(task.task.id);
|
|
132
|
-
|
|
133
|
-
// Persist task.task.id and run.runId, then return to the caller.
|
|
134
|
-
|
|
135
|
-
// In a later request, scheduled job, or worker invocation:
|
|
136
|
-
const outcome = await client.tasks.getRun(task.task.id, run.runId);
|
|
137
|
-
if (outcome.status !== "queued" && outcome.status !== "running") {
|
|
138
|
-
const transcript = await client.tasks.runMessages(task.task.id, run.runId);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Sessions
|
|
142
|
-
const sessions = await client.sessions.list(agent.id);
|
|
143
|
-
const messages = await client.sessions.messages(agent.id, sessionId);
|
|
144
|
-
|
|
145
|
-
// Artifacts
|
|
146
|
-
const artifacts = await client.artifacts.list({ agentId: agent.id });
|
|
147
|
-
const artifact = artifacts.data[0];
|
|
148
|
-
if (artifact) {
|
|
149
|
-
const { url } = await client.artifacts.createDownloadUrl(artifact.artifactId);
|
|
150
|
-
const bytes = await (await fetch(url)).arrayBuffer();
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
Generation request inputs accept `clientRequestId` for caller-owned
|
|
155
|
-
correlation without raw headers. For any resource or generation request, use
|
|
156
|
-
`client.withOptions({ clientRequestId })` to create a scoped client view. The
|
|
157
|
-
callback receives the method, path
|
|
158
|
-
without query, status, duration, server `requestId`, and the same optional
|
|
159
|
-
`clientRequestId` once for every received response, including errors and
|
|
160
|
-
streaming handshakes. Callback failures are ignored and transport failures
|
|
161
|
-
with no response do not invoke it. The server-owned `requestId` identifies one
|
|
162
|
-
HTTP attempt and should be retained when contacting support.
|
|
163
|
-
Successful generated message metadata separately exposes `usage.turnId` for
|
|
164
|
-
the admitted, metered Turn. It is not the HTTP `requestId` or message ID.
|
|
165
|
-
|
|
166
|
-
## Generation methods
|
|
167
|
-
|
|
168
|
-
### `client.chat(input)` — stateful UI message stream
|
|
169
|
-
|
|
170
|
-
The server mints the `ss_` session id. Start a new chat with a single
|
|
171
|
-
`client.chat({ agentId, message })` call — no `sessionId`, no `mode` —
|
|
172
|
-
and read the minted id from `await result.sessionId` (resolved from the
|
|
173
|
-
create response's `Location` header):
|
|
35
|
+
Create a Tenant API key in the Blazing Agents dashboard, then pass it to the
|
|
36
|
+
client or read it from your server environment.
|
|
174
37
|
|
|
175
38
|
```ts
|
|
176
|
-
|
|
177
|
-
const created = await client.chat({
|
|
178
|
-
agentId: agent.id,
|
|
179
|
-
message: {
|
|
180
|
-
id: "msg_user_1",
|
|
181
|
-
role: "user",
|
|
182
|
-
parts: [{ type: "text", text: "Hello!" }],
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
const sessionId = await created.sessionId;
|
|
186
|
-
return created.toResponse();
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
`toResponse()` exposes the server's AI SDK UI-message SSE response unchanged
|
|
190
|
-
for relay to the browser. It is one-shot; a repeated call throws a
|
|
191
|
-
`BlazingAgentsError` with `code: "stream_error"`. `result.sessionId` remains
|
|
192
|
-
independently awaitable before or after selecting the response.
|
|
193
|
-
|
|
194
|
-
After `useChat` successfully consumes that response, pass the same `sessionId`
|
|
195
|
-
on a later request to continue the chat:
|
|
196
|
-
|
|
197
|
-
```ts
|
|
198
|
-
const result = await client.chat({
|
|
199
|
-
agentId: agent.id,
|
|
200
|
-
sessionId,
|
|
201
|
-
message: {
|
|
202
|
-
id: "msg_user_2",
|
|
203
|
-
role: "user",
|
|
204
|
-
parts: [{ type: "text", text: "Follow up" }],
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
return result.toResponse();
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
`trigger: "regenerate-message"` is valid only when `sessionId` is present.
|
|
212
|
-
`messageId` remains optional when regenerating an existing Session.
|
|
213
|
-
|
|
214
|
-
Prompt-invocation variant (server resolves + renders the template):
|
|
215
|
-
|
|
216
|
-
```ts
|
|
217
|
-
const result = await client.chat({
|
|
218
|
-
agentId: agent.id,
|
|
219
|
-
promptId: "prompt_...",
|
|
220
|
-
variables: { name: "Alice" },
|
|
221
|
-
});
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### `client.completion(input)` — stateless text stream
|
|
39
|
+
import { BlazingAgents } from "@blazingagents/sdk";
|
|
225
40
|
|
|
226
|
-
|
|
41
|
+
const client = new BlazingAgents({ apiKey: "ba_..." });
|
|
227
42
|
|
|
228
|
-
```ts
|
|
229
43
|
const result = await client.completion({
|
|
230
|
-
agentId:
|
|
231
|
-
prompt: "Write a
|
|
44
|
+
agentId: "ag_...",
|
|
45
|
+
prompt: "Write a friendly welcome message.",
|
|
232
46
|
});
|
|
233
47
|
|
|
234
|
-
|
|
235
|
-
process.stdout.write(delta);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const fullText = await result.text;
|
|
48
|
+
console.log(await result.text);
|
|
239
49
|
```
|
|
240
50
|
|
|
241
|
-
|
|
51
|
+
Keep API keys on the server. For browser chat applications, relay `chat()`
|
|
52
|
+
through your backend and use `BlazingAgentsChatTransport` with AI SDK
|
|
53
|
+
`useChat`.
|
|
242
54
|
|
|
243
|
-
|
|
55
|
+
## Documentation
|
|
244
56
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
schema: {
|
|
250
|
-
type: "object",
|
|
251
|
-
properties: {
|
|
252
|
-
name: { type: "string" },
|
|
253
|
-
age: { type: "number" },
|
|
254
|
-
},
|
|
255
|
-
required: ["name"],
|
|
256
|
-
},
|
|
257
|
-
});
|
|
57
|
+
Read the
|
|
58
|
+
[TypeScript SDK documentation](https://docs.blazingagents.com/sdk/typescript)
|
|
59
|
+
for authentication, resource guides, generation and streaming, React
|
|
60
|
+
integration, error handling, and the complete API reference.
|
|
258
61
|
|
|
259
|
-
|
|
260
|
-
console.log(partial);
|
|
261
|
-
}
|
|
62
|
+
## Development
|
|
262
63
|
|
|
263
|
-
|
|
64
|
+
```console
|
|
65
|
+
npm ci
|
|
66
|
+
npm run check
|
|
67
|
+
npm run test:consumer
|
|
264
68
|
```
|
|
265
69
|
|
|
266
|
-
##
|
|
267
|
-
|
|
268
|
-
Keep `BlazingAgents` and its API key on your backend. The browser-safe
|
|
269
|
-
`BlazingAgentsChatTransport` sends the latest user message, forwards
|
|
270
|
-
regeneration metadata, captures the Session ID from the first response's
|
|
271
|
-
`Location` header, and includes that ID on later sends.
|
|
272
|
-
|
|
273
|
-
### Tenant backend
|
|
70
|
+
## License
|
|
274
71
|
|
|
275
|
-
|
|
276
|
-
import {
|
|
277
|
-
BlazingAgents,
|
|
278
|
-
createChatRelay,
|
|
279
|
-
createCompletionRelay,
|
|
280
|
-
} from "@blazingagents/sdk";
|
|
281
|
-
|
|
282
|
-
const client = new BlazingAgents({ apiKey: process.env.BLAZING_AGENTS_API_KEY });
|
|
72
|
+
[MIT](LICENSE)
|
|
283
73
|
|
|
284
|
-
|
|
285
|
-
const user = await authenticateApplicationRequest(request);
|
|
286
|
-
return user ? { agentId: "ag_...", userId: user.id } : null;
|
|
287
|
-
};
|
|
74
|
+
### Thinking level
|
|
288
75
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
});
|
|
76
|
+
Agent create/update accepts `thinkingLevel: "high"`, `"off"`, `"max"`, or
|
|
77
|
+
another nonempty string supported by the selected Model. Omission on creation
|
|
78
|
+
means Provider default; omission on update preserves the saved value, while
|
|
79
|
+
`thinkingLevel: null` clears it. Agent and Version responses include the
|
|
80
|
+
selection, and `restoreVersion` restores it through ordinary validation.
|
|
81
|
+
Use `client.providers.getThinkingLevels(providerId, model)` to read
|
|
82
|
+
`{ known, levels }`. Unknown capabilities permit custom values that can still
|
|
83
|
+
be rejected during execution. Levels control reasoning, not a token/cost cap.
|
|
298
84
|
|
|
299
|
-
|
|
300
|
-
|
|
85
|
+
For native clients whose `Response` constructor does not support streaming bodies,
|
|
86
|
+
use `result.toStream()` on chat or terminal continuation results to read the
|
|
87
|
+
original SSE bytes. It shares one-shot ownership with `toResponse()`; choose one
|
|
88
|
+
accessor per result. Stream errors and cancellation retain the same behavior.
|
|
301
89
|
|
|
302
|
-
|
|
303
|
-
`Response` objects. They validate AI SDK input, ignore browser attempts to set
|
|
304
|
-
reserved agent/attribution fields, authorize Session resumes, record ownership
|
|
305
|
-
before returning a created stream, preserve safe status and correlation
|
|
306
|
-
headers, and propagate request cancellation. Framework adapters only need to
|
|
307
|
-
pass their request to the returned function.
|
|
90
|
+
### Direct native chat
|
|
308
91
|
|
|
309
|
-
|
|
92
|
+
For a direct SDK integration, use `BlazingAgentsDirectChatTransport` with AI SDK
|
|
93
|
+
`useChat`. It sends through `client.chat()` and uses AI SDK's stream decoder
|
|
94
|
+
without constructing a streaming `Response`. Inject your native streaming fetch
|
|
95
|
+
implementation into `BlazingAgents` when the runtime requires one.
|
|
310
96
|
|
|
311
97
|
```tsx
|
|
98
|
+
import { useMemo } from "react";
|
|
312
99
|
import { useChat } from "@ai-sdk/react";
|
|
313
|
-
import {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
})
|
|
323
|
-
|
|
324
|
-
() =>
|
|
325
|
-
new BlazingAgentsChatTransport({
|
|
326
|
-
api: "/api/chat",
|
|
327
|
-
onSessionId: rememberSessionId,
|
|
328
|
-
sessionId: initialSessionId,
|
|
329
|
-
}),
|
|
100
|
+
import { BlazingAgentsDirectChatTransport } from "@blazingagents/sdk";
|
|
101
|
+
|
|
102
|
+
function Chat({ client, agentId, initialSessionId, saveSessionId }) {
|
|
103
|
+
const transport = useMemo(
|
|
104
|
+
() => new BlazingAgentsDirectChatTransport({
|
|
105
|
+
client,
|
|
106
|
+
agentId,
|
|
107
|
+
sessionId: initialSessionId,
|
|
108
|
+
onSessionId: saveSessionId,
|
|
109
|
+
}),
|
|
110
|
+
[client, agentId, initialSessionId, saveSessionId],
|
|
330
111
|
);
|
|
331
|
-
|
|
112
|
+
const chat = useChat({ transport });
|
|
113
|
+
// Render chat.messages and submit using chat.sendMessage({ text }).
|
|
332
114
|
}
|
|
333
115
|
```
|
|
334
116
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
## Error model
|
|
117
|
+
Install `@ai-sdk/react` for the React hook. Keep the transport stable for one chat;
|
|
118
|
+
remount the chat with a new transport when switching credentials, Agents, or
|
|
119
|
+
Sessions. `onSessionId` runs once for a newly created Session before stream
|
|
120
|
+
consumption, so it can be saved even if streaming later fails. The adapter
|
|
121
|
+
preserves user message IDs, regeneration targets, and `useChat` cancellation.
|
|
122
|
+
Regeneration requires an existing Session. Reconnection returns `null`; the
|
|
123
|
+
adapter does not retry interrupted Turns or resume their streams.
|
|
343
124
|
|
|
344
|
-
|
|
345
|
-
is preserved exactly, including a future code unknown to the installed SDK.
|
|
346
|
-
`KnownBlazingAgentsErrorCode` provides editor completion for the current API
|
|
347
|
-
catalog and four SDK-local codes:
|
|
125
|
+
### Cancel resource reads
|
|
348
126
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
| `invalid_response` | A response is not a valid API envelope or successful JSON result. |
|
|
352
|
-
| `network_error` | Fetch failed before an HTTP exchange for a reason other than caller abort. |
|
|
353
|
-
| `request_aborted` | The caller's `AbortSignal` aborted the request. |
|
|
354
|
-
| `stream_error` | A stream failed after its response started or violated its stream contract. |
|
|
355
|
-
|
|
356
|
-
`BlazingAgentsError` exposes `code`, `message`, and optional `status`,
|
|
357
|
-
`details`, `param`, `headers`, `requestId`, `responseBody`,
|
|
358
|
-
`responseBodyTruncated`, and `cause`. A malformed response uses the stable
|
|
359
|
-
`invalid_response` message and retains a size-bounded body separately.
|
|
360
|
-
Response-backed failures copy `X-Request-Id` into `requestId`.
|
|
127
|
+
Pass an optional `signal` to resource reads when leaving a screen or switching
|
|
128
|
+
credentials:
|
|
361
129
|
|
|
362
130
|
```ts
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
} catch (error) {
|
|
368
|
-
if (BlazingAgentsError.isInstance(error)) {
|
|
369
|
-
console.log(error.code);
|
|
370
|
-
console.log(error.status);
|
|
371
|
-
console.log(error.requestId);
|
|
372
|
-
console.log(error.message);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
131
|
+
const controller = new AbortController();
|
|
132
|
+
const agents = client.agents.list({ signal: controller.signal });
|
|
133
|
+
controller.abort();
|
|
134
|
+
await agents; // Rejects with the SDK's typed cancellation error.
|
|
375
135
|
```
|
|
376
136
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
[error catalog and stream boundary](https://docs.blazingagents.com/api-reference/protocols/errors).
|
|
380
|
-
|
|
381
|
-
## Development
|
|
382
|
-
|
|
383
|
-
Install dependencies and run the complete standalone check:
|
|
384
|
-
|
|
385
|
-
```bash
|
|
386
|
-
npm ci
|
|
387
|
-
npm run check
|
|
388
|
-
npm run test:consumer
|
|
389
|
-
```
|
|
137
|
+
SDK response parsing strips unknown object fields while validating required
|
|
138
|
+
fields and known field types. Request validation remains strict.
|
package/dist/contracts/api.d.ts
CHANGED
|
@@ -238,7 +238,7 @@ export declare const cursorSchema: z.ZodString;
|
|
|
238
238
|
export declare function paginatedResponseSchema<T extends z.ZodTypeAny>(itemSchema: T): z.ZodObject<{
|
|
239
239
|
data: z.ZodArray<T>;
|
|
240
240
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
241
|
-
}, z.core.$
|
|
241
|
+
}, z.core.$strip>;
|
|
242
242
|
/**
|
|
243
243
|
* Opaque keyset cursor helpers. Cursors are base64url-encoded JSON of the
|
|
244
244
|
* keyset tuple the endpoint paginates by — never a raw value, never a row
|
package/dist/contracts/api.js
CHANGED
|
@@ -18,6 +18,7 @@ export declare const agentSchema: z.ZodObject<{
|
|
|
18
18
|
tenantId: z.ZodString;
|
|
19
19
|
name: z.ZodString;
|
|
20
20
|
model: z.ZodNullable<z.ZodString>;
|
|
21
|
+
thinkingLevel: z.ZodNullable<z.ZodString>;
|
|
21
22
|
providerId: z.ZodNullable<z.ZodString>;
|
|
22
23
|
workspaceId: z.ZodString;
|
|
23
24
|
memoryInjectionEnabled: z.ZodBoolean;
|
|
@@ -38,13 +39,14 @@ export declare const agentSchema: z.ZodObject<{
|
|
|
38
39
|
active: "active";
|
|
39
40
|
disabled: "disabled";
|
|
40
41
|
}>;
|
|
41
|
-
}, z.core.$
|
|
42
|
+
}, z.core.$strip>;
|
|
42
43
|
export declare const agentsResponseSchema: z.ZodObject<{
|
|
43
44
|
agents: z.ZodArray<z.ZodObject<{
|
|
44
45
|
id: z.ZodString;
|
|
45
46
|
tenantId: z.ZodString;
|
|
46
47
|
name: z.ZodString;
|
|
47
48
|
model: z.ZodNullable<z.ZodString>;
|
|
49
|
+
thinkingLevel: z.ZodNullable<z.ZodString>;
|
|
48
50
|
providerId: z.ZodNullable<z.ZodString>;
|
|
49
51
|
workspaceId: z.ZodString;
|
|
50
52
|
memoryInjectionEnabled: z.ZodBoolean;
|
|
@@ -65,13 +67,14 @@ export declare const agentsResponseSchema: z.ZodObject<{
|
|
|
65
67
|
active: "active";
|
|
66
68
|
disabled: "disabled";
|
|
67
69
|
}>;
|
|
68
|
-
}, z.core.$
|
|
69
|
-
}, z.core.$
|
|
70
|
+
}, z.core.$strip>>;
|
|
71
|
+
}, z.core.$strip>;
|
|
70
72
|
export declare const agentResponseSchema: z.ZodObject<{
|
|
71
73
|
id: z.ZodString;
|
|
72
74
|
tenantId: z.ZodString;
|
|
73
75
|
name: z.ZodString;
|
|
74
76
|
model: z.ZodNullable<z.ZodString>;
|
|
77
|
+
thinkingLevel: z.ZodNullable<z.ZodString>;
|
|
75
78
|
providerId: z.ZodNullable<z.ZodString>;
|
|
76
79
|
workspaceId: z.ZodString;
|
|
77
80
|
memoryInjectionEnabled: z.ZodBoolean;
|
|
@@ -92,7 +95,7 @@ export declare const agentResponseSchema: z.ZodObject<{
|
|
|
92
95
|
active: "active";
|
|
93
96
|
disabled: "disabled";
|
|
94
97
|
}>;
|
|
95
|
-
}, z.core.$
|
|
98
|
+
}, z.core.$strip>;
|
|
96
99
|
export declare const agentsListQuerySchema: z.ZodObject<{
|
|
97
100
|
userId: z.ZodOptional<z.ZodString>;
|
|
98
101
|
workspaceId: z.ZodOptional<z.ZodString>;
|
|
@@ -103,6 +106,7 @@ export declare const agentVersionSchema: z.ZodObject<{
|
|
|
103
106
|
version: z.ZodNumber;
|
|
104
107
|
name: z.ZodString;
|
|
105
108
|
model: z.ZodNullable<z.ZodString>;
|
|
109
|
+
thinkingLevel: z.ZodNullable<z.ZodString>;
|
|
106
110
|
providerId: z.ZodNullable<z.ZodString>;
|
|
107
111
|
memoryInjectionEnabled: z.ZodBoolean;
|
|
108
112
|
tools: z.ZodArray<z.ZodEnum<{
|
|
@@ -114,7 +118,7 @@ export declare const agentVersionSchema: z.ZodObject<{
|
|
|
114
118
|
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
115
119
|
mcpConnectionIds: z.ZodArray<z.ZodString>;
|
|
116
120
|
createdAt: z.ZodISODateTime;
|
|
117
|
-
}, z.core.$
|
|
121
|
+
}, z.core.$strip>;
|
|
118
122
|
export declare const agentVersionsListQuerySchema: z.ZodObject<{
|
|
119
123
|
cursor: z.ZodOptional<z.ZodString>;
|
|
120
124
|
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
@@ -126,6 +130,7 @@ export declare const agentVersionsResponseSchema: z.ZodObject<{
|
|
|
126
130
|
version: z.ZodNumber;
|
|
127
131
|
name: z.ZodString;
|
|
128
132
|
model: z.ZodNullable<z.ZodString>;
|
|
133
|
+
thinkingLevel: z.ZodNullable<z.ZodString>;
|
|
129
134
|
providerId: z.ZodNullable<z.ZodString>;
|
|
130
135
|
memoryInjectionEnabled: z.ZodBoolean;
|
|
131
136
|
tools: z.ZodArray<z.ZodEnum<{
|
|
@@ -137,12 +142,13 @@ export declare const agentVersionsResponseSchema: z.ZodObject<{
|
|
|
137
142
|
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
138
143
|
mcpConnectionIds: z.ZodArray<z.ZodString>;
|
|
139
144
|
createdAt: z.ZodISODateTime;
|
|
140
|
-
}, z.core.$
|
|
145
|
+
}, z.core.$strip>>;
|
|
141
146
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
142
|
-
}, z.core.$
|
|
147
|
+
}, z.core.$strip>;
|
|
143
148
|
export declare const createAgentBodySchema: z.ZodObject<{
|
|
144
149
|
name: z.ZodString;
|
|
145
150
|
model: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
151
|
+
thinkingLevel: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
146
152
|
providerId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
147
153
|
workspaceId: z.ZodOptional<z.ZodString>;
|
|
148
154
|
memoryInjectionEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -159,6 +165,7 @@ export declare const createAgentBodySchema: z.ZodObject<{
|
|
|
159
165
|
export declare const updateAgentBodySchema: z.ZodObject<{
|
|
160
166
|
name: z.ZodOptional<z.ZodString>;
|
|
161
167
|
model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
168
|
+
thinkingLevel: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
162
169
|
providerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
163
170
|
workspaceId: z.ZodOptional<z.ZodString>;
|
|
164
171
|
memoryInjectionEnabled: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -38,6 +38,7 @@ export const agentSchema = z
|
|
|
38
38
|
tenantId: tenantIdSchema,
|
|
39
39
|
name: agentNameSchema,
|
|
40
40
|
model: agentModelIdSchema.nullable(),
|
|
41
|
+
thinkingLevel: z.string().min(1).nullable(),
|
|
41
42
|
providerId: providerIdSchema.nullable(),
|
|
42
43
|
workspaceId: workspaceIdSchema,
|
|
43
44
|
memoryInjectionEnabled: z.boolean(),
|
|
@@ -53,7 +54,7 @@ export const agentSchema = z
|
|
|
53
54
|
version: agentVersionNumberSchema,
|
|
54
55
|
status: agentStatusSchema,
|
|
55
56
|
})
|
|
56
|
-
.
|
|
57
|
+
.strip()
|
|
57
58
|
.refine(hasProviderModelPair, {
|
|
58
59
|
message: providerModelPairMessage,
|
|
59
60
|
path: ["providerId"],
|
|
@@ -62,7 +63,7 @@ export const agentsResponseSchema = z
|
|
|
62
63
|
.object({
|
|
63
64
|
agents: z.array(agentSchema),
|
|
64
65
|
})
|
|
65
|
-
.
|
|
66
|
+
.strip();
|
|
66
67
|
export const agentResponseSchema = agentSchema;
|
|
67
68
|
export const agentsListQuerySchema = z
|
|
68
69
|
.object({
|
|
@@ -77,6 +78,7 @@ export const agentVersionSchema = z
|
|
|
77
78
|
version: agentVersionNumberSchema,
|
|
78
79
|
name: agentSchema.shape.name,
|
|
79
80
|
model: agentSchema.shape.model,
|
|
81
|
+
thinkingLevel: agentSchema.shape.thinkingLevel,
|
|
80
82
|
providerId: agentSchema.shape.providerId,
|
|
81
83
|
memoryInjectionEnabled: agentSchema.shape.memoryInjectionEnabled,
|
|
82
84
|
tools: agentSchema.shape.tools,
|
|
@@ -85,7 +87,7 @@ export const agentVersionSchema = z
|
|
|
85
87
|
mcpConnectionIds: agentSchema.shape.mcpConnectionIds,
|
|
86
88
|
createdAt: agentSchema.shape.createdAt,
|
|
87
89
|
})
|
|
88
|
-
.
|
|
90
|
+
.strip()
|
|
89
91
|
.refine(hasProviderModelPair, {
|
|
90
92
|
message: providerModelPairMessage,
|
|
91
93
|
path: ["providerId"],
|
|
@@ -106,6 +108,7 @@ export const createAgentBodySchema = z
|
|
|
106
108
|
.object({
|
|
107
109
|
name: agentNameSchema,
|
|
108
110
|
model: agentModelIdSchema.nullable().default(null),
|
|
111
|
+
thinkingLevel: z.string().min(1).nullable().default(null),
|
|
109
112
|
providerId: providerIdSchema.nullable().default(null),
|
|
110
113
|
workspaceId: workspaceIdSchema.optional(),
|
|
111
114
|
memoryInjectionEnabled: z.boolean().default(false),
|
|
@@ -124,6 +127,7 @@ export const updateAgentBodySchema = z
|
|
|
124
127
|
.object({
|
|
125
128
|
name: agentNameSchema.optional(),
|
|
126
129
|
model: agentModelIdSchema.nullable().optional(),
|
|
130
|
+
thinkingLevel: z.string().min(1).nullable().optional(),
|
|
127
131
|
providerId: providerIdSchema.nullable().optional(),
|
|
128
132
|
workspaceId: workspaceIdSchema.optional(),
|
|
129
133
|
memoryInjectionEnabled: z.boolean().optional(),
|