@blazingagents/sdk 0.20.0 → 0.22.0

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.
Files changed (88) hide show
  1. package/dist/approvals.d.ts +4 -0
  2. package/dist/approvals.js +4 -0
  3. package/dist/chat-stream-transport.d.ts +5 -0
  4. package/dist/chat-stream-transport.js +15 -0
  5. package/dist/chat-transport.d.ts +18 -1
  6. package/dist/chat-transport.js +19 -2
  7. package/dist/client.d.ts +24 -1
  8. package/dist/client.js +33 -1
  9. package/dist/contracts/api.d.ts +37 -0
  10. package/dist/contracts/api.js +29 -0
  11. package/dist/contracts/entities/agent-tools.d.ts +5 -2
  12. package/dist/contracts/entities/agent-tools.js +5 -2
  13. package/dist/contracts/entities/agents.d.ts +4 -0
  14. package/dist/contracts/entities/agents.js +9 -0
  15. package/dist/contracts/entities/chat.d.ts +3 -0
  16. package/dist/contracts/entities/chat.js +6 -0
  17. package/dist/contracts/entities/mcp-connections.d.ts +3 -1
  18. package/dist/contracts/entities/mcp-connections.js +3 -1
  19. package/dist/contracts/entities/prompts.d.ts +13 -0
  20. package/dist/contracts/entities/prompts.js +13 -0
  21. package/dist/contracts/entities/session-inputs.js +3 -1
  22. package/dist/contracts/entities/sessions.d.ts +11 -0
  23. package/dist/contracts/entities/sessions.js +11 -1
  24. package/dist/contracts/entities/skills.d.ts +3 -0
  25. package/dist/contracts/entities/skills.js +3 -0
  26. package/dist/contracts/entities/spending-limits.d.ts +103 -0
  27. package/dist/contracts/entities/spending-limits.js +81 -0
  28. package/dist/contracts/entities/tasks.d.ts +1 -0
  29. package/dist/contracts/entities/usage.d.ts +4 -1
  30. package/dist/contracts/entities/usage.js +7 -1
  31. package/dist/contracts/entities/workspaces.d.ts +17 -6
  32. package/dist/contracts/entities/workspaces.js +3 -7
  33. package/dist/contracts/ids.d.ts +31 -0
  34. package/dist/contracts/ids.js +34 -0
  35. package/dist/contracts/index.d.ts +6 -3
  36. package/dist/contracts/index.js +3 -2
  37. package/dist/contracts/utils.d.ts +10 -0
  38. package/dist/contracts/utils.js +10 -0
  39. package/dist/direct-chat-transport.d.ts +32 -5
  40. package/dist/direct-chat-transport.js +29 -2
  41. package/dist/errors.d.ts +9 -0
  42. package/dist/errors.js +9 -0
  43. package/dist/functions.d.ts +35 -2
  44. package/dist/functions.js +60 -4
  45. package/dist/generation.d.ts +32 -0
  46. package/dist/generation.js +83 -0
  47. package/dist/http.d.ts +26 -0
  48. package/dist/http.js +43 -0
  49. package/dist/index.d.ts +5 -3
  50. package/dist/index.js +1 -0
  51. package/dist/relay.d.ts +23 -0
  52. package/dist/relay.js +16 -0
  53. package/dist/resources/agents.d.ts +5 -0
  54. package/dist/resources/agents.js +47 -0
  55. package/dist/resources/artifacts.d.ts +2 -0
  56. package/dist/resources/artifacts.js +14 -0
  57. package/dist/resources/chat-connections.d.ts +5 -0
  58. package/dist/resources/chat-connections.js +32 -0
  59. package/dist/resources/chat-deliveries.d.ts +2 -0
  60. package/dist/resources/chat-deliveries.js +5 -0
  61. package/dist/resources/mcp-connections.d.ts +5 -0
  62. package/dist/resources/mcp-connections.js +26 -0
  63. package/dist/resources/memories.d.ts +2 -0
  64. package/dist/resources/memories.js +17 -0
  65. package/dist/resources/merchant-bindings.d.ts +2 -0
  66. package/dist/resources/merchant-bindings.js +11 -0
  67. package/dist/resources/merchant-connection.d.ts +2 -0
  68. package/dist/resources/merchant-connection.js +14 -0
  69. package/dist/resources/merchant-usage-events.d.ts +2 -0
  70. package/dist/resources/merchant-usage-events.js +20 -0
  71. package/dist/resources/prompts.d.ts +5 -0
  72. package/dist/resources/prompts.js +20 -0
  73. package/dist/resources/providers.d.ts +2 -0
  74. package/dist/resources/providers.js +23 -0
  75. package/dist/resources/sessions.d.ts +2 -0
  76. package/dist/resources/sessions.js +40 -0
  77. package/dist/resources/skills.d.ts +5 -0
  78. package/dist/resources/skills.js +35 -0
  79. package/dist/resources/tasks.d.ts +2 -0
  80. package/dist/resources/tasks.js +32 -0
  81. package/dist/resources/tenant.d.ts +2 -0
  82. package/dist/resources/tenant.js +17 -0
  83. package/dist/resources/usage.d.ts +2 -0
  84. package/dist/resources/usage.js +14 -0
  85. package/dist/resources/workspaces.d.ts +5 -0
  86. package/dist/resources/workspaces.js +20 -0
  87. package/dist/types.d.ts +696 -13
  88. package/package.json +1 -1
@@ -1,3 +1,7 @@
1
1
  import { type UIMessage } from "ai";
2
2
  import type { ToolApprovalDecision } from "./contracts/entities/sessions.ts";
3
+ /**
4
+ * Extracts approval decisions from the last assistant step without changing the message.
5
+ * @returns Decisions after the last step-start part, or an empty array.
6
+ */
3
7
  export declare function extractApprovalDecisions(message: UIMessage): ToolApprovalDecision[];
package/dist/approvals.js CHANGED
@@ -1,4 +1,8 @@
1
1
  import { isToolUIPart } from "ai";
2
+ /**
3
+ * Extracts approval decisions from the last assistant step without changing the message.
4
+ * @returns Decisions after the last step-start part, or an empty array.
5
+ */
2
6
  export function extractApprovalDecisions(message) {
3
7
  const lastStep = message.parts.findLastIndex((part) => part.type === "step-start");
4
8
  return message.parts.slice(lastStep + 1).flatMap((part) => isToolUIPart(part) && part.state === "approval-responded"
@@ -0,0 +1,5 @@
1
+ import { DefaultChatTransport, type UIMessage } from "ai";
2
+ export declare class ChatStreamTransport<UI_MESSAGE extends UIMessage = UIMessage> extends DefaultChatTransport<UI_MESSAGE> {
3
+ /** Native Chat rejects an update job for error chunks, so fail the stream before that job runs. */
4
+ protected processResponseStream(stream: ReadableStream<Uint8Array>): ReadableStream<any>;
5
+ }
@@ -0,0 +1,15 @@
1
+ import { DefaultChatTransport } from "ai";
2
+ export class ChatStreamTransport extends DefaultChatTransport {
3
+ /** Native Chat rejects an update job for error chunks, so fail the stream before that job runs. */
4
+ processResponseStream(stream) {
5
+ return super.processResponseStream(stream).pipeThrough(new TransformStream({
6
+ transform(chunk, controller) {
7
+ if (chunk.type === "error") {
8
+ controller.error(new Error(chunk.errorText));
9
+ return;
10
+ }
11
+ controller.enqueue(chunk);
12
+ },
13
+ }));
14
+ }
15
+ }
@@ -1,6 +1,9 @@
1
1
  import { type ChatTransport, type HttpChatTransportInitOptions, type UIMessage } from "ai";
2
2
  export type BlazingAgentsChatTransportOptions<UI_MESSAGE extends UIMessage = UIMessage> = Omit<HttpChatTransportInitOptions<UI_MESSAGE>, "prepareReconnectToStreamRequest" | "prepareSendMessagesRequest"> & {
3
- /** Receives the Session ID minted by the first successful response. */
3
+ /**
4
+ * Receives the Session ID minted by the first successful response.
5
+ * @param sessionId - Session to look up or record.
6
+ */
4
7
  onSessionId?: (sessionId: string) => Promise<void> | void;
5
8
  /** An authorized Session ID used to resume after a remount or reload. */
6
9
  sessionId?: string;
@@ -11,7 +14,21 @@ export type BlazingAgentsChatTransportOptions<UI_MESSAGE extends UIMessage = UIM
11
14
  */
12
15
  export declare class BlazingAgentsChatTransport<UI_MESSAGE extends UIMessage = UIMessage> implements ChatTransport<UI_MESSAGE> {
13
16
  #private;
17
+ /**
18
+ * Creates a chat transport and validates any supplied Session ID.
19
+ * @param options - Configuration for this operation.
20
+ */
14
21
  constructor(options?: BlazingAgentsChatTransportOptions<UI_MESSAGE>);
22
+ /**
23
+ * Submits the latest user message or complete assistant approval round to the chat.
24
+ * @param input - Operation input and optional cancellation signal.
25
+ * @returns The decoded AI SDK message-chunk stream.
26
+ */
15
27
  sendMessages(input: Parameters<ChatTransport<UI_MESSAGE>["sendMessages"]>[0]): Promise<ReadableStream<import("ai").UIMessageChunk>>;
28
+ /**
29
+ * Returns null because reconnecting to an existing stream is unsupported.
30
+ * @param _input - Unused reconnect request.
31
+ * @returns A promise resolving to null.
32
+ */
16
33
  reconnectToStream(_input: Parameters<ChatTransport<UI_MESSAGE>["reconnectToStream"]>[0]): Promise<null>;
17
34
  }
@@ -1,4 +1,5 @@
1
- import { DefaultChatTransport, lastAssistantMessageIsCompleteWithApprovalResponses, } from "ai";
1
+ import { lastAssistantMessageIsCompleteWithApprovalResponses, } from "ai";
2
+ import { ChatStreamTransport } from "./chat-stream-transport.js";
2
3
  import { sessionIdSchema } from "./contracts/ids.js";
3
4
  /**
4
5
  * Adapts AI SDK chat requests to the Blazing Agents backend-relay shape and
@@ -7,13 +8,18 @@ import { sessionIdSchema } from "./contracts/ids.js";
7
8
  export class BlazingAgentsChatTransport {
8
9
  #transport;
9
10
  #sessionId;
11
+ /**
12
+ * Creates a chat transport and validates any supplied Session ID.
13
+ * @param options - Configuration for this operation.
14
+ */
10
15
  constructor(options = {}) {
11
16
  const { onSessionId, sessionId, ...transportOptions } = options;
12
17
  const transportFetch = transportOptions.fetch ?? globalThis.fetch;
13
18
  this.#sessionId =
14
19
  sessionId === undefined ? undefined : sessionIdSchema.parse(sessionId);
15
- this.#transport = new DefaultChatTransport({
20
+ this.#transport = new ChatStreamTransport({
16
21
  ...transportOptions,
22
+ /** Reads the first Session ID from Location before returning the response. */
17
23
  fetch: async (input, init) => {
18
24
  const response = await transportFetch(input, init);
19
25
  if (response.ok && this.#sessionId === undefined) {
@@ -30,6 +36,7 @@ export class BlazingAgentsChatTransport {
30
36
  }
31
37
  return response;
32
38
  },
39
+ /** Selects the user message or complete approval round for the relay request. */
33
40
  prepareSendMessagesRequest: ({ body, messageId, messages, trigger }) => {
34
41
  const approvals = messages.at(-1)?.role === "assistant" &&
35
42
  lastAssistantMessageIsCompleteWithApprovalResponses({ messages });
@@ -56,9 +63,19 @@ export class BlazingAgentsChatTransport {
56
63
  },
57
64
  });
58
65
  }
66
+ /**
67
+ * Submits the latest user message or complete assistant approval round to the chat.
68
+ * @param input - Operation input and optional cancellation signal.
69
+ * @returns The decoded AI SDK message-chunk stream.
70
+ */
59
71
  sendMessages(input) {
60
72
  return this.#transport.sendMessages(input);
61
73
  }
74
+ /**
75
+ * Returns null because reconnecting to an existing stream is unsupported.
76
+ * @param _input - Unused reconnect request.
77
+ * @returns A promise resolving to null.
78
+ */
62
79
  reconnectToStream(_input) {
63
80
  return Promise.resolve(null);
64
81
  }
package/dist/client.d.ts CHANGED
@@ -17,36 +17,59 @@ export declare class BlazingAgents {
17
17
  readonly merchantConnection: MerchantConnectionResource;
18
18
  readonly merchantBindings: MerchantBindingsResource;
19
19
  readonly merchantUsageEvents: MerchantUsageEventsResource;
20
+ /**
21
+ * Creates a client. Defaults to the hosted API and removes trailing base URL slashes.
22
+ * @param options - Configuration for this operation.
23
+ */
20
24
  constructor(options: BlazingAgentsOptions);
25
+ /**
26
+ * Returns the Skill operations for the selected Agent.
27
+ * @returns The selected Agent Skill client.
28
+ */
21
29
  agent({ agentId }: {
22
30
  agentId: string;
23
31
  }): AgentClient;
24
- /** Scope requests to one end user. IDs use printable ASCII, at most 256 characters, without leading or trailing spaces. */
32
+ /**
33
+ * Scope requests to one end user. IDs use printable ASCII, at most 256 characters, without leading or trailing spaces.
34
+ * @param userId - Printable ASCII end-user ID, at most 256 characters with no surrounding spaces.
35
+ * @returns A client scoped to the validated end-user ID.
36
+ * @throws ZodError - If the user ID is invalid.
37
+ */
25
38
  forUser(userId: string): UserClient;
26
39
  /**
27
40
  * `POST /v1/agents/:agentId/sessions` (create, no `sessionId`) or
28
41
  * `POST /v1/agents/:agentId/sessions/:sessionId` (resume). Returns the
29
42
  * session id and a byte-compatible SSE relay for `useChat`.
43
+ * @param input - Agent, message or stored Prompt, and optional existing Session.
44
+ * @returns The Session ID promise and single-owner SSE accessors.
30
45
  */
31
46
  chat(input: ChatInput): Promise<ChatResult>;
32
47
  /**
33
48
  * Records a complete Tool approval round and streams its continuation.
34
49
  * Caller-local function handlers apply only to this invocation.
50
+ * @param input - Agent, Session, and decisions for the complete approval round.
51
+ * @returns The Session ID promise and continuation SSE accessors.
35
52
  */
36
53
  continueChat(input: ContinueChatInput): Promise<ChatResult>;
37
54
  /**
38
55
  * `POST /v1/agents/:agentId/generation` — stateless one-shot text
39
56
  * stream. Returns `textStream` + `await result.text` + `toResponse()`.
57
+ * @param input - Agent and literal prompt or stored Prompt reference.
58
+ * @returns Independent text stream, final text promise, and response relay.
40
59
  */
41
60
  completion(input: CompletionInput): Promise<CompletionResult>;
42
61
  /**
43
62
  * `POST /v1/agents/:agentId/generation` — stateless structured output.
44
63
  * Returns `partialObjectStream` + `await result.object` + `toResponse()`.
64
+ * @param input - Agent, prompt source, and JSON output schema.
65
+ * @returns Partial JSON objects, a final JSON promise, and a text response relay.
45
66
  */
46
67
  object(input: ObjectInput): Promise<ObjectResult>;
47
68
  /**
48
69
  * Returns a lightweight client view whose resource and generation calls
49
70
  * carry caller-owned correlation without raw header manipulation.
71
+ * @param options - Caller-owned request correlation ID for subsequent calls.
72
+ * @returns A new client carrying the supplied correlation ID.
50
73
  */
51
74
  withOptions(options: BlazingAgentsRequestOptions): BlazingAgents;
52
75
  }
package/dist/client.js CHANGED
@@ -23,6 +23,9 @@ const scopedUserIdSchema = z
23
23
  .string()
24
24
  .max(256)
25
25
  .regex(/^[\x21-\x7E](?:[\x20-\x7E]*[\x21-\x7E])?$/);
26
+ /**
27
+ * Builds a client whose requests share the configured user scope.
28
+ */
26
29
  function createUserClient(config) {
27
30
  const usage = createUsageResource(config);
28
31
  return {
@@ -34,13 +37,19 @@ function createUserClient(config) {
34
37
  workspaces: createWorkspacesResource(config),
35
38
  memories: createMemoriesResource(config),
36
39
  usage: { get: usage.get, sessions: usage.sessions },
40
+ /** Returns Skill operations for the selected Agent. */
37
41
  agent: ({ agentId }) => ({
38
42
  skills: createAgentSkillsResource(config, agentId),
39
43
  }),
44
+ /** Starts a chat using the scoped client configuration. */
40
45
  chat: (input) => chat(config, input),
46
+ /** Starts text generation using the scoped client configuration. */
41
47
  completion: (input) => completion(config, input),
48
+ /** Starts JSON generation using the scoped client configuration. */
42
49
  object: (input) => objectGeneration(config, input),
50
+ /** Continues an approval round using the scoped client configuration. */
43
51
  continueChat: (input) => continueChat(config, input),
52
+ /** Creates a scoped client view with the supplied correlation ID. */
44
53
  withOptions: (options) => createUserClient({ ...config, clientRequestId: options.clientRequestId }),
45
54
  };
46
55
  }
@@ -62,6 +71,10 @@ export class BlazingAgents {
62
71
  merchantConnection;
63
72
  merchantBindings;
64
73
  merchantUsageEvents;
74
+ /**
75
+ * Creates a client. Defaults to the hosted API and removes trailing base URL slashes.
76
+ * @param options - Configuration for this operation.
77
+ */
65
78
  constructor(options) {
66
79
  this.config = {
67
80
  apiKey: options.apiKey,
@@ -89,10 +102,19 @@ export class BlazingAgents {
89
102
  this.merchantBindings = createMerchantBindingsResource(this.config);
90
103
  this.merchantUsageEvents = createMerchantUsageEventsResource(this.config);
91
104
  }
105
+ /**
106
+ * Returns the Skill operations for the selected Agent.
107
+ * @returns The selected Agent Skill client.
108
+ */
92
109
  agent({ agentId }) {
93
110
  return { skills: createAgentSkillsResource(this.config, agentId) };
94
111
  }
95
- /** Scope requests to one end user. IDs use printable ASCII, at most 256 characters, without leading or trailing spaces. */
112
+ /**
113
+ * Scope requests to one end user. IDs use printable ASCII, at most 256 characters, without leading or trailing spaces.
114
+ * @param userId - Printable ASCII end-user ID, at most 256 characters with no surrounding spaces.
115
+ * @returns A client scoped to the validated end-user ID.
116
+ * @throws ZodError - If the user ID is invalid.
117
+ */
96
118
  forUser(userId) {
97
119
  return createUserClient({
98
120
  ...this.config,
@@ -103,6 +125,8 @@ export class BlazingAgents {
103
125
  * `POST /v1/agents/:agentId/sessions` (create, no `sessionId`) or
104
126
  * `POST /v1/agents/:agentId/sessions/:sessionId` (resume). Returns the
105
127
  * session id and a byte-compatible SSE relay for `useChat`.
128
+ * @param input - Agent, message or stored Prompt, and optional existing Session.
129
+ * @returns The Session ID promise and single-owner SSE accessors.
106
130
  */
107
131
  chat(input) {
108
132
  return chat(this.config, input);
@@ -110,6 +134,8 @@ export class BlazingAgents {
110
134
  /**
111
135
  * Records a complete Tool approval round and streams its continuation.
112
136
  * Caller-local function handlers apply only to this invocation.
137
+ * @param input - Agent, Session, and decisions for the complete approval round.
138
+ * @returns The Session ID promise and continuation SSE accessors.
113
139
  */
114
140
  continueChat(input) {
115
141
  return continueChat(this.config, input);
@@ -117,6 +143,8 @@ export class BlazingAgents {
117
143
  /**
118
144
  * `POST /v1/agents/:agentId/generation` — stateless one-shot text
119
145
  * stream. Returns `textStream` + `await result.text` + `toResponse()`.
146
+ * @param input - Agent and literal prompt or stored Prompt reference.
147
+ * @returns Independent text stream, final text promise, and response relay.
120
148
  */
121
149
  completion(input) {
122
150
  return completion(this.config, input);
@@ -124,6 +152,8 @@ export class BlazingAgents {
124
152
  /**
125
153
  * `POST /v1/agents/:agentId/generation` — stateless structured output.
126
154
  * Returns `partialObjectStream` + `await result.object` + `toResponse()`.
155
+ * @param input - Agent, prompt source, and JSON output schema.
156
+ * @returns Partial JSON objects, a final JSON promise, and a text response relay.
127
157
  */
128
158
  object(input) {
129
159
  return objectGeneration(this.config, input);
@@ -131,6 +161,8 @@ export class BlazingAgents {
131
161
  /**
132
162
  * Returns a lightweight client view whose resource and generation calls
133
163
  * carry caller-owned correlation without raw header manipulation.
164
+ * @param options - Caller-owned request correlation ID for subsequent calls.
165
+ * @returns A new client carrying the supplied correlation ID.
134
166
  */
135
167
  withOptions(options) {
136
168
  return new BlazingAgents({
@@ -56,9 +56,11 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
56
56
  merchant_event_state_conflict: "merchant_event_state_conflict";
57
57
  merchant_provider_unavailable: "merchant_provider_unavailable";
58
58
  merchant_subscription_required: "merchant_subscription_required";
59
+ message_id_conflict: "message_id_conflict";
59
60
  message_not_found: "message_not_found";
60
61
  model_discovery_unsupported: "model_discovery_unsupported";
61
62
  model_not_found: "model_not_found";
63
+ model_spending_limit_exceeded: "model_spending_limit_exceeded";
62
64
  model_validation_unavailable: "model_validation_unavailable";
63
65
  not_found: "not_found";
64
66
  prompt_variable_missing: "prompt_variable_missing";
@@ -73,6 +75,8 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
73
75
  rate_limited: "rate_limited";
74
76
  service_unavailable: "service_unavailable";
75
77
  session_busy: "session_busy";
78
+ session_fork_deleted: "session_fork_deleted";
79
+ session_fork_unavailable: "session_fork_unavailable";
76
80
  session_version_mismatch: "session_version_mismatch";
77
81
  skill_invalid_archive: "skill_invalid_archive";
78
82
  skill_invalid_markdown: "skill_invalid_markdown";
@@ -136,9 +140,11 @@ export declare const apiErrorSchema: z.ZodObject<{
136
140
  merchant_event_state_conflict: "merchant_event_state_conflict";
137
141
  merchant_provider_unavailable: "merchant_provider_unavailable";
138
142
  merchant_subscription_required: "merchant_subscription_required";
143
+ message_id_conflict: "message_id_conflict";
139
144
  message_not_found: "message_not_found";
140
145
  model_discovery_unsupported: "model_discovery_unsupported";
141
146
  model_not_found: "model_not_found";
147
+ model_spending_limit_exceeded: "model_spending_limit_exceeded";
142
148
  model_validation_unavailable: "model_validation_unavailable";
143
149
  not_found: "not_found";
144
150
  prompt_variable_missing: "prompt_variable_missing";
@@ -153,6 +159,8 @@ export declare const apiErrorSchema: z.ZodObject<{
153
159
  rate_limited: "rate_limited";
154
160
  service_unavailable: "service_unavailable";
155
161
  session_busy: "session_busy";
162
+ session_fork_deleted: "session_fork_deleted";
163
+ session_fork_unavailable: "session_fork_unavailable";
156
164
  session_version_mismatch: "session_version_mismatch";
157
165
  skill_invalid_archive: "skill_invalid_archive";
158
166
  skill_invalid_markdown: "skill_invalid_markdown";
@@ -221,9 +229,11 @@ export declare const apiErrorResponseSchema: z.ZodObject<{
221
229
  merchant_event_state_conflict: "merchant_event_state_conflict";
222
230
  merchant_provider_unavailable: "merchant_provider_unavailable";
223
231
  merchant_subscription_required: "merchant_subscription_required";
232
+ message_id_conflict: "message_id_conflict";
224
233
  message_not_found: "message_not_found";
225
234
  model_discovery_unsupported: "model_discovery_unsupported";
226
235
  model_not_found: "model_not_found";
236
+ model_spending_limit_exceeded: "model_spending_limit_exceeded";
227
237
  model_validation_unavailable: "model_validation_unavailable";
228
238
  not_found: "not_found";
229
239
  prompt_variable_missing: "prompt_variable_missing";
@@ -238,6 +248,8 @@ export declare const apiErrorResponseSchema: z.ZodObject<{
238
248
  rate_limited: "rate_limited";
239
249
  service_unavailable: "service_unavailable";
240
250
  session_busy: "session_busy";
251
+ session_fork_deleted: "session_fork_deleted";
252
+ session_fork_unavailable: "session_fork_unavailable";
241
253
  session_version_mismatch: "session_version_mismatch";
242
254
  skill_invalid_archive: "skill_invalid_archive";
243
255
  skill_invalid_markdown: "skill_invalid_markdown";
@@ -284,17 +296,29 @@ export interface ApiErrorOptions {
284
296
  details?: Record<string, unknown>;
285
297
  param?: string;
286
298
  }
299
+ /**
300
+ * Builds an API error envelope with optional parameter and detail fields.
301
+ * @param code - API error code for programmatic handling.
302
+ * @param message - Human-readable error description.
303
+ * @param options - Configuration for this operation.
304
+ */
287
305
  export declare function apiError(code: ApiErrorCode, message: string, options?: ApiErrorOptions): ApiErrorResponse;
288
306
  /**
289
307
  * Cursor pagination — `{ data, nextCursor }` on unbounded list surfaces,
290
308
  * including sessions, transcripts, artifacts, and memories.
291
309
  * `nextCursor` is opaque (base64 of the keyset); `null` means no more pages.
310
+ * @param data - Response data to wrap in the success envelope.
311
+ * @param nextCursor - Next Cursor.
292
312
  */
293
313
  export declare function paginatedResponse<T>(data: T[], nextCursor: string | null): {
294
314
  data: T[];
295
315
  nextCursor: string | null;
296
316
  };
297
317
  export declare const cursorSchema: z.ZodString;
318
+ /**
319
+ * Creates a schema for a data page and nullable next cursor.
320
+ * @param itemSchema - Item Schema.
321
+ */
298
322
  export declare function paginatedResponseSchema<T extends z.ZodTypeAny>(itemSchema: T): z.ZodObject<{
299
323
  data: z.ZodArray<T>;
300
324
  nextCursor: z.ZodNullable<z.ZodString>;
@@ -309,8 +333,21 @@ export declare function paginatedResponseSchema<T extends z.ZodTypeAny>(itemSche
309
333
  export declare class CursorDecodeError extends Error {
310
334
  readonly errorCode = "INVALID_CURSOR";
311
335
  readonly statusCode = 400;
336
+ /**
337
+ * Creates the error with the supplied message.
338
+ * @param message - Human-readable error description.
339
+ * @param options - Configuration for this operation.
340
+ */
312
341
  constructor(message: string, options?: ErrorOptions);
313
342
  }
343
+ /**
344
+ * Encodes a cursor payload as URL-safe base64 JSON.
345
+ * @param payload - JSON-serializable cursor fields. This function does not validate them.
346
+ */
314
347
  export declare function encodeCursor(payload: Record<string, unknown>): string;
348
+ /**
349
+ * Decodes and validates a URL-safe base64 JSON cursor.
350
+ * @param cursor - URL-safe base64 JSON cursor to decode.
351
+ */
315
352
  export declare function decodeCursor(cursor: string): Record<string, unknown>;
316
353
  export {};
@@ -19,6 +19,8 @@ export const apiErrorIssueSchema = z
19
19
  export const apiErrorCodeSchema = z.enum([
20
20
  "invalid_request",
21
21
  "idempotency_conflict",
22
+ "session_fork_deleted",
23
+ "session_fork_unavailable",
22
24
  "input_idempotency_conflict",
23
25
  "steer_not_available",
24
26
  "validation_failed",
@@ -26,6 +28,7 @@ export const apiErrorCodeSchema = z.enum([
26
28
  "forbidden",
27
29
  "not_found",
28
30
  "quota_exceeded",
31
+ "model_spending_limit_exceeded",
29
32
  "subscription_required",
30
33
  "usage_credit_required",
31
34
  "rate_limited",
@@ -41,6 +44,7 @@ export const apiErrorCodeSchema = z.enum([
41
44
  "artifact_session_cap_reached",
42
45
  "invalid_cursor",
43
46
  "message_not_found",
47
+ "message_id_conflict",
44
48
  "prompt_variable_missing",
45
49
  "prompt_variable_unknown",
46
50
  "provider_in_use",
@@ -125,6 +129,12 @@ export const receivedApiErrorResponseSchema = z
125
129
  error: receivedApiErrorSchema,
126
130
  })
127
131
  .passthrough();
132
+ /**
133
+ * Builds an API error envelope with optional parameter and detail fields.
134
+ * @param code - API error code for programmatic handling.
135
+ * @param message - Human-readable error description.
136
+ * @param options - Configuration for this operation.
137
+ */
128
138
  export function apiError(code, message, options = {}) {
129
139
  return {
130
140
  error: {
@@ -141,11 +151,17 @@ export function apiError(code, message, options = {}) {
141
151
  * Cursor pagination — `{ data, nextCursor }` on unbounded list surfaces,
142
152
  * including sessions, transcripts, artifacts, and memories.
143
153
  * `nextCursor` is opaque (base64 of the keyset); `null` means no more pages.
154
+ * @param data - Response data to wrap in the success envelope.
155
+ * @param nextCursor - Next Cursor.
144
156
  */
145
157
  export function paginatedResponse(data, nextCursor) {
146
158
  return { data, nextCursor };
147
159
  }
148
160
  export const cursorSchema = z.string().trim().min(1);
161
+ /**
162
+ * Creates a schema for a data page and nullable next cursor.
163
+ * @param itemSchema - Item Schema.
164
+ */
149
165
  export function paginatedResponseSchema(itemSchema) {
150
166
  return z
151
167
  .object({
@@ -164,6 +180,11 @@ export function paginatedResponseSchema(itemSchema) {
164
180
  export class CursorDecodeError extends Error {
165
181
  errorCode = "INVALID_CURSOR";
166
182
  statusCode = 400;
183
+ /**
184
+ * Creates the error with the supplied message.
185
+ * @param message - Human-readable error description.
186
+ * @param options - Configuration for this operation.
187
+ */
167
188
  constructor(message, options) {
168
189
  super(message, options);
169
190
  this.name = "CursorDecodeError";
@@ -174,6 +195,10 @@ const BASE64_SLASH = /\//g;
174
195
  const BASE64_PADDING = /[=]+$/;
175
196
  const BASE64_DASH = /-/g;
176
197
  const BASE64_UNDERSCORE = /_/g;
198
+ /**
199
+ * Encodes a cursor payload as URL-safe base64 JSON.
200
+ * @param payload - JSON-serializable cursor fields. This function does not validate them.
201
+ */
177
202
  export function encodeCursor(payload) {
178
203
  const json = JSON.stringify(payload);
179
204
  const bytes = new TextEncoder().encode(json);
@@ -186,6 +211,10 @@ export function encodeCursor(payload) {
186
211
  .replace(BASE64_SLASH, "_")
187
212
  .replace(BASE64_PADDING, "");
188
213
  }
214
+ /**
215
+ * Decodes and validates a URL-safe base64 JSON cursor.
216
+ * @param cursor - URL-safe base64 JSON cursor to decode.
217
+ */
189
218
  export function decodeCursor(cursor) {
190
219
  let json;
191
220
  try {
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- /** Tool groups an Agent can attach. File operations use its durable Workspace. */
2
+ /** Tool groups an Agent can attach. File operations use its Workspace. */
3
3
  export declare const agentToolGroupIds: readonly ["workspace", "write_todos", "memory"];
4
4
  export type AgentToolGroupId = (typeof agentToolGroupIds)[number];
5
5
  export interface AgentToolGroup {
@@ -11,7 +11,7 @@ export interface AgentToolGroup {
11
11
  export declare const AGENT_TOOL_CATALOG: readonly [{
12
12
  readonly id: "workspace";
13
13
  readonly name: "File operations";
14
- readonly description: "Read, write, edit, search, and run shell commands in the attached durable Workspace.";
14
+ readonly description: "Read, write, edit, search, and run shell commands in the attached Workspace.";
15
15
  readonly tools: readonly ["read", "write", "edit", "grep", "glob", "bash", "publish_artifacts"];
16
16
  }, {
17
17
  readonly id: "write_todos";
@@ -24,6 +24,9 @@ export declare const AGENT_TOOL_CATALOG: readonly [{
24
24
  readonly description: "Save, recall, search, update, and delete durable notes owned by this Agent.";
25
25
  readonly tools: readonly ["save_memory", "get_memory", "search_memories", "update_memory", "delete_memory"];
26
26
  }];
27
+ /**
28
+ * Expands tool group names into their individual tool names.
29
+ */
27
30
  export declare function expandToolGroups(ids: Iterable<string>): Set<string>;
28
31
  /**
29
32
  * A model-facing tool name. Built-in tool names and the `mcp__` prefix used
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- /** Tool groups an Agent can attach. File operations use its durable Workspace. */
2
+ /** Tool groups an Agent can attach. File operations use its Workspace. */
3
3
  export const agentToolGroupIds = [
4
4
  "workspace",
5
5
  "write_todos",
@@ -9,7 +9,7 @@ export const AGENT_TOOL_CATALOG = [
9
9
  {
10
10
  id: "workspace",
11
11
  name: "File operations",
12
- description: "Read, write, edit, search, and run shell commands in the attached durable Workspace.",
12
+ description: "Read, write, edit, search, and run shell commands in the attached Workspace.",
13
13
  tools: [
14
14
  "read",
15
15
  "write",
@@ -39,6 +39,9 @@ export const AGENT_TOOL_CATALOG = [
39
39
  ],
40
40
  },
41
41
  ];
42
+ /**
43
+ * Expands tool group names into their individual tool names.
44
+ */
42
45
  export function expandToolGroups(ids) {
43
46
  const result = new Set();
44
47
  for (const id of ids) {
@@ -518,6 +518,10 @@ export declare const createAgentBodySchema: z.ZodObject<{
518
518
  thinkingLevel: z.ZodDefault<z.ZodNullable<z.ZodString>>;
519
519
  providerId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
520
520
  workspaceId: z.ZodOptional<z.ZodString>;
521
+ workspaceTier: z.ZodOptional<z.ZodEnum<{
522
+ core: "core";
523
+ plus: "plus";
524
+ }>>;
521
525
  autoCompaction: z.ZodDefault<z.ZodBoolean>;
522
526
  compactionReserveTokens: z.ZodDefault<z.ZodNumber>;
523
527
  memoryInjectionEnabled: z.ZodDefault<z.ZodBoolean>;
@@ -6,6 +6,7 @@ import { atLeastOneFieldMessage, hasObjectKeys, hasUniqueValues, } from "../util
6
6
  import { approvalPolicySchema } from "./agent-approval.js";
7
7
  import { agentToolGroupIds } from "./agent-tools.js";
8
8
  import { metadataSchema, userIdSchema } from "./attribution.js";
9
+ import { workspaceTierSchema } from "./workspaces.js";
9
10
  const approvalFields = {
10
11
  approvalInChat: approvalPolicySchema.default({
11
12
  default: "full",
@@ -35,6 +36,9 @@ export const agentMcpConnectionIdsSchema = z
35
36
  });
36
37
  export const agentStatusSchema = z.enum(["active", "disabled"]);
37
38
  const providerModelPairMessage = "Provider and model must either both be set or both be null.";
39
+ /**
40
+ * Checks that provider and model selections are both present or both absent.
41
+ */
38
42
  function hasProviderModelPair(input) {
39
43
  return (input.model === null) === (input.providerId === null);
40
44
  }
@@ -114,6 +118,7 @@ export const createAgentBodySchema = z
114
118
  thinkingLevel: z.string().min(1).nullable().default(null),
115
119
  providerId: providerIdSchema.nullable().default(null),
116
120
  workspaceId: workspaceIdSchema.optional(),
121
+ workspaceTier: workspaceTierSchema.optional(),
117
122
  autoCompaction: z.boolean().default(true),
118
123
  compactionReserveTokens: agentSchema.shape.compactionReserveTokens.default(16_384),
119
124
  memoryInjectionEnabled: z.boolean().default(false),
@@ -124,6 +129,10 @@ export const createAgentBodySchema = z
124
129
  mcpConnectionIds: agentMcpConnectionIdsSchema.default([]),
125
130
  })
126
131
  .strict()
132
+ .refine((input) => input.workspaceId === undefined || input.workspaceTier === undefined, {
133
+ message: "workspaceId and workspaceTier are mutually exclusive.",
134
+ path: ["workspaceTier"],
135
+ })
127
136
  .refine(hasProviderModelPair, {
128
137
  message: providerModelPairMessage,
129
138
  path: ["providerId"],
@@ -110,6 +110,9 @@ export declare const jsonSchemaShapeSchema: z.ZodCustom<z.core.JSONSchema.JSONSc
110
110
  export declare const MAX_CHAT_FUNCTIONS = 32;
111
111
  export declare const MAX_CHAT_FUNCTION_DEFINITIONS_BYTES: number;
112
112
  export declare const MAX_CHAT_FUNCTION_PAYLOAD_BYTES: number;
113
+ /**
114
+ * Measures the UTF-8 byte length of a JSON-serialized value.
115
+ */
113
116
  export declare const jsonByteLength: (value: unknown) => number;
114
117
  /** One caller-local function as sent to Blazing Agents: description and JSON Schema only. */
115
118
  export declare const chatFunctionDefinitionSchema: z.ZodObject<{
@@ -61,6 +61,9 @@ export const blazingAgentsChatMessageMetadataSchema = z
61
61
  */
62
62
  export const promptVariablesSchema = z.record(z.string(), z.string());
63
63
  const JSON_SCHEMA_COMPOSITION_KEYS = ["allOf", "anyOf", "oneOf"];
64
+ /**
65
+ * Checks whether the JSON Schema root contains a meaningful schema keyword.
66
+ */
64
67
  function hasMeaningfulSchemaRoot(value, definitions, seenReferences) {
65
68
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
66
69
  return false;
@@ -120,6 +123,9 @@ export const jsonSchemaShapeSchema = z.custom((value) => {
120
123
  export const MAX_CHAT_FUNCTIONS = 32;
121
124
  export const MAX_CHAT_FUNCTION_DEFINITIONS_BYTES = 64 * 1024;
122
125
  export const MAX_CHAT_FUNCTION_PAYLOAD_BYTES = 256 * 1024;
126
+ /**
127
+ * Measures the UTF-8 byte length of a JSON-serialized value.
128
+ */
123
129
  export const jsonByteLength = (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength;
124
130
  /** One caller-local function as sent to Blazing Agents: description and JSON Schema only. */
125
131
  export const chatFunctionDefinitionSchema = z
@@ -16,7 +16,9 @@ export declare const mcpConnectionTestErrorCodeSchema: z.ZodEnum<{
16
16
  MCP_CONNECTION_INVALID: "MCP_CONNECTION_INVALID";
17
17
  MCP_CONNECTION_UNREACHABLE: "MCP_CONNECTION_UNREACHABLE";
18
18
  }>;
19
- /** Mirrors the MCP SDK's SEP-2352 issuer-identity comparison. */
19
+ /**
20
+ * Mirrors the MCP SDK's SEP-2352 issuer-identity comparison.
21
+ */
20
22
  export declare function mcpOauthIssuersMatch(a: string, b: string): boolean;
21
23
  export declare const mcpOauthClientCredentialsBundleSchema: z.ZodObject<{
22
24
  clientInformation: z.ZodObject<{
@@ -75,7 +75,9 @@ const oauthIssuerSchema = z
75
75
  })
76
76
  .transform((value) => new URL(value).toString());
77
77
  const credentialFragmentSchema = z.string().min(1).max(4).nullable();
78
- /** Mirrors the MCP SDK's SEP-2352 issuer-identity comparison. */
78
+ /**
79
+ * Mirrors the MCP SDK's SEP-2352 issuer-identity comparison.
80
+ */
79
81
  export function mcpOauthIssuersMatch(a, b) {
80
82
  return (a === b ||
81
83
  (a.endsWith("/") && a.slice(0, -1) === b) ||