@blazingagents/sdk 0.19.0 → 0.21.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 (85) hide show
  1. package/README.md +17 -1
  2. package/dist/approvals.d.ts +4 -12
  3. package/dist/approvals.js +12 -13
  4. package/dist/chat-transport.d.ts +18 -1
  5. package/dist/chat-transport.js +16 -0
  6. package/dist/client.d.ts +28 -5
  7. package/dist/client.js +39 -7
  8. package/dist/contracts/api.d.ts +40 -6
  9. package/dist/contracts/api.js +30 -2
  10. package/dist/contracts/entities/agent-tools.d.ts +5 -2
  11. package/dist/contracts/entities/agent-tools.js +5 -2
  12. package/dist/contracts/entities/agents.d.ts +4 -0
  13. package/dist/contracts/entities/agents.js +9 -0
  14. package/dist/contracts/entities/chat.d.ts +11 -10
  15. package/dist/contracts/entities/chat.js +11 -7
  16. package/dist/contracts/entities/mcp-connections.d.ts +3 -1
  17. package/dist/contracts/entities/mcp-connections.js +3 -1
  18. package/dist/contracts/entities/prompts.d.ts +13 -0
  19. package/dist/contracts/entities/prompts.js +13 -0
  20. package/dist/contracts/entities/session-inputs.d.ts +29 -87
  21. package/dist/contracts/entities/session-inputs.js +21 -19
  22. package/dist/contracts/entities/sessions.d.ts +27 -17
  23. package/dist/contracts/entities/sessions.js +23 -8
  24. package/dist/contracts/entities/skills.d.ts +3 -0
  25. package/dist/contracts/entities/skills.js +3 -0
  26. package/dist/contracts/entities/tasks.d.ts +1 -0
  27. package/dist/contracts/entities/usage.d.ts +4 -1
  28. package/dist/contracts/entities/usage.js +7 -1
  29. package/dist/contracts/entities/workspaces.d.ts +17 -6
  30. package/dist/contracts/entities/workspaces.js +3 -7
  31. package/dist/contracts/ids.d.ts +31 -0
  32. package/dist/contracts/ids.js +34 -0
  33. package/dist/contracts/index.d.ts +7 -6
  34. package/dist/contracts/index.js +4 -4
  35. package/dist/contracts/utils.d.ts +10 -0
  36. package/dist/contracts/utils.js +10 -0
  37. package/dist/direct-chat-transport.d.ts +30 -3
  38. package/dist/direct-chat-transport.js +40 -35
  39. package/dist/errors.d.ts +9 -0
  40. package/dist/errors.js +9 -0
  41. package/dist/functions.d.ts +35 -2
  42. package/dist/functions.js +60 -4
  43. package/dist/generation.d.ts +34 -2
  44. package/dist/generation.js +97 -19
  45. package/dist/http.d.ts +26 -0
  46. package/dist/http.js +43 -0
  47. package/dist/index.d.ts +4 -4
  48. package/dist/relay.d.ts +26 -3
  49. package/dist/relay.js +25 -10
  50. package/dist/resources/agents.d.ts +5 -0
  51. package/dist/resources/agents.js +38 -0
  52. package/dist/resources/artifacts.d.ts +2 -0
  53. package/dist/resources/artifacts.js +14 -0
  54. package/dist/resources/chat-connections.d.ts +5 -0
  55. package/dist/resources/chat-connections.js +32 -0
  56. package/dist/resources/chat-deliveries.d.ts +2 -0
  57. package/dist/resources/chat-deliveries.js +5 -0
  58. package/dist/resources/mcp-connections.d.ts +5 -0
  59. package/dist/resources/mcp-connections.js +26 -0
  60. package/dist/resources/memories.d.ts +2 -0
  61. package/dist/resources/memories.js +17 -0
  62. package/dist/resources/merchant-bindings.d.ts +2 -0
  63. package/dist/resources/merchant-bindings.js +11 -0
  64. package/dist/resources/merchant-connection.d.ts +2 -0
  65. package/dist/resources/merchant-connection.js +14 -0
  66. package/dist/resources/merchant-usage-events.d.ts +2 -0
  67. package/dist/resources/merchant-usage-events.js +20 -0
  68. package/dist/resources/prompts.d.ts +5 -0
  69. package/dist/resources/prompts.js +20 -0
  70. package/dist/resources/providers.d.ts +2 -0
  71. package/dist/resources/providers.js +23 -0
  72. package/dist/resources/sessions.d.ts +2 -0
  73. package/dist/resources/sessions.js +42 -39
  74. package/dist/resources/skills.d.ts +5 -0
  75. package/dist/resources/skills.js +35 -0
  76. package/dist/resources/tasks.d.ts +2 -0
  77. package/dist/resources/tasks.js +32 -0
  78. package/dist/resources/tenant.d.ts +2 -0
  79. package/dist/resources/tenant.js +8 -0
  80. package/dist/resources/usage.d.ts +2 -0
  81. package/dist/resources/usage.js +14 -0
  82. package/dist/resources/workspaces.d.ts +5 -0
  83. package/dist/resources/workspaces.js +20 -0
  84. package/dist/types.d.ts +691 -48
  85. package/package.json +1 -1
package/README.md CHANGED
@@ -17,7 +17,8 @@ requires Node.js 24 or newer.
17
17
 
18
18
  - Typed clients for Agents, Workspaces, Skills, Providers, Prompts, Tasks,
19
19
  Sessions, Artifacts, Slack and Telegram Chat Connections, usage, Tenant settings, and merchant monetization.
20
- - Stateful chat and stateless text or structured-object generation.
20
+ - Stateful chat with explicit message batches, steer receipts, and one-call Tool approvals.
21
+ - Stateless text or structured-object generation.
21
22
  - Public Zod contracts for validating API requests and responses.
22
23
  - Cursor pagination and binary transfers.
23
24
  - Request correlation and a typed, forward-compatible error model.
@@ -51,6 +52,21 @@ const result = await client.completion({
51
52
  console.log(await result.text);
52
53
  ```
53
54
 
55
+ For stateful chat, pass one user message or an ordered batch.
56
+
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
+ });
65
+
66
+ const sessionId = await chat.sessionId;
67
+ return chat.toResponse();
68
+ ```
69
+
54
70
  Keep API keys on the server. For browser chat applications, relay `chat()`
55
71
  through your backend and use `BlazingAgentsChatTransport` with AI SDK
56
72
  `useChat`.
@@ -1,15 +1,7 @@
1
1
  import { type UIMessage } from "ai";
2
- import type { BlazingAgents } from "./client.ts";
3
- interface ApprovalTarget {
4
- abortSignal?: AbortSignal;
5
- agentId: string;
6
- sessionId: string;
7
- }
2
+ import type { ToolApprovalDecision } from "./contracts/entities/sessions.ts";
8
3
  /**
9
- * Records each approval response in the assistant message's last step and
10
- * returns the continuation they decide, or `undefined` when there are none.
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.
11
6
  */
12
- export declare function decideApprovalResponses(client: Pick<BlazingAgents, "sessions">, { message, ...target }: ApprovalTarget & {
13
- message: UIMessage;
14
- }): Promise<string | undefined>;
15
- export {};
7
+ export declare function extractApprovalDecisions(message: UIMessage): ToolApprovalDecision[];
package/dist/approvals.js CHANGED
@@ -1,20 +1,19 @@
1
1
  import { isToolUIPart } from "ai";
2
2
  /**
3
- * Records each approval response in the assistant message's last step and
4
- * returns the continuation they decide, or `undefined` when there are none.
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
5
  */
6
- export async function decideApprovalResponses(client, { message, ...target }) {
6
+ export function extractApprovalDecisions(message) {
7
7
  const lastStep = message.parts.findLastIndex((part) => part.type === "step-start");
8
- let continuationId;
9
- for (const part of message.parts.slice(lastStep + 1)) {
10
- if (isToolUIPart(part) && part.state === "approval-responded") {
11
- ({ continuationId } = await client.sessions.decideToolApproval({
12
- ...target,
8
+ return message.parts.slice(lastStep + 1).flatMap((part) => isToolUIPart(part) && part.state === "approval-responded"
9
+ ? [
10
+ {
13
11
  approvalId: part.approval.id,
14
12
  approved: part.approval.approved,
15
- reason: part.approval.reason,
16
- }));
17
- }
18
- }
19
- return continuationId;
13
+ ...(part.approval.reason === undefined
14
+ ? {}
15
+ : { reason: part.approval.reason }),
16
+ },
17
+ ]
18
+ : []);
20
19
  }
@@ -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
  }
@@ -7,6 +7,10 @@ import { sessionIdSchema } from "./contracts/ids.js";
7
7
  export class BlazingAgentsChatTransport {
8
8
  #transport;
9
9
  #sessionId;
10
+ /**
11
+ * Creates a chat transport and validates any supplied Session ID.
12
+ * @param options - Configuration for this operation.
13
+ */
10
14
  constructor(options = {}) {
11
15
  const { onSessionId, sessionId, ...transportOptions } = options;
12
16
  const transportFetch = transportOptions.fetch ?? globalThis.fetch;
@@ -14,6 +18,7 @@ export class BlazingAgentsChatTransport {
14
18
  sessionId === undefined ? undefined : sessionIdSchema.parse(sessionId);
15
19
  this.#transport = new DefaultChatTransport({
16
20
  ...transportOptions,
21
+ /** Reads the first Session ID from Location before returning the response. */
17
22
  fetch: async (input, init) => {
18
23
  const response = await transportFetch(input, init);
19
24
  if (response.ok && this.#sessionId === undefined) {
@@ -30,6 +35,7 @@ export class BlazingAgentsChatTransport {
30
35
  }
31
36
  return response;
32
37
  },
38
+ /** Selects the user message or complete approval round for the relay request. */
33
39
  prepareSendMessagesRequest: ({ body, messageId, messages, trigger }) => {
34
40
  const approvals = messages.at(-1)?.role === "assistant" &&
35
41
  lastAssistantMessageIsCompleteWithApprovalResponses({ messages });
@@ -56,9 +62,19 @@ export class BlazingAgentsChatTransport {
56
62
  },
57
63
  });
58
64
  }
65
+ /**
66
+ * Submits the latest user message or complete assistant approval round to the chat.
67
+ * @param input - Operation input and optional cancellation signal.
68
+ * @returns The decoded AI SDK message-chunk stream.
69
+ */
59
70
  sendMessages(input) {
60
71
  return this.#transport.sendMessages(input);
61
72
  }
73
+ /**
74
+ * Returns null because reconnecting to an existing stream is unsupported.
75
+ * @param _input - Unused reconnect request.
76
+ * @returns A promise resolving to null.
77
+ */
62
78
  reconnectToStream(_input) {
63
79
  return Promise.resolve(null);
64
80
  }
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AgentClient, AgentsResource, ArtifactsResource, BlazingAgentsOptions, BlazingAgentsRequestOptions, ChatConnectionsResource, ChatDeliveriesResource, ChatInput, ChatResult, CompletionInput, CompletionResult, McpConnectionsResource, MemoriesResource, MerchantBindingsResource, MerchantConnectionResource, MerchantUsageEventsResource, ObjectInput, ObjectResult, PromptsResource, ProvidersResource, ResumeChatInput, SessionsResource, TasksResource, TenantResource, UsageResource, UserClient, WorkspacesResource } from "./types.ts";
1
+ import type { AgentClient, AgentsResource, ArtifactsResource, BlazingAgentsOptions, BlazingAgentsRequestOptions, ChatConnectionsResource, ChatDeliveriesResource, ChatInput, ChatResult, CompletionInput, CompletionResult, ContinueChatInput, McpConnectionsResource, MemoriesResource, MerchantBindingsResource, MerchantConnectionResource, MerchantUsageEventsResource, ObjectInput, ObjectResult, PromptsResource, ProvidersResource, SessionsResource, TasksResource, TenantResource, UsageResource, UserClient, WorkspacesResource } from "./types.ts";
2
2
  export declare class BlazingAgents {
3
3
  private readonly config;
4
4
  readonly chatConnections: ChatConnectionsResource;
@@ -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
- * Reattaches function handlers after human tool approval and starts or
34
- * joins the Session's continuation. Returns the continuation SSE relay.
48
+ * Records a complete Tool approval round and streams its continuation.
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
- resumeChat(input: ResumeChatInput): Promise<ChatResult>;
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
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { chat, completion, objectGeneration, resumeChat, } from "./generation.js";
2
+ import { chat, completion, continueChat, objectGeneration, } from "./generation.js";
3
3
  import { createAgentsResource } from "./resources/agents.js";
4
4
  import { createArtifactsResource } from "./resources/artifacts.js";
5
5
  import { createChatConnectionsResource } from "./resources/chat-connections.js";
@@ -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),
43
- resumeChat: (input) => resumeChat(config, input),
50
+ /** Continues an approval round using the scoped client configuration. */
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,20 +125,26 @@ 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);
109
133
  }
110
134
  /**
111
- * Reattaches function handlers after human tool approval and starts or
112
- * joins the Session's continuation. Returns the continuation SSE relay.
135
+ * Records a complete Tool approval round and streams its continuation.
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
- resumeChat(input) {
115
- return resumeChat(this.config, input);
140
+ continueChat(input) {
141
+ return continueChat(this.config, input);
116
142
  }
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({
@@ -32,7 +32,6 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
32
32
  function_call_conflict: "function_call_conflict";
33
33
  idempotency_conflict: "idempotency_conflict";
34
34
  input_idempotency_conflict: "input_idempotency_conflict";
35
- input_not_pending: "input_not_pending";
36
35
  internal: "internal";
37
36
  invalid_cursor: "invalid_cursor";
38
37
  invalid_request: "invalid_request";
@@ -57,6 +56,7 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
57
56
  merchant_event_state_conflict: "merchant_event_state_conflict";
58
57
  merchant_provider_unavailable: "merchant_provider_unavailable";
59
58
  merchant_subscription_required: "merchant_subscription_required";
59
+ message_id_conflict: "message_id_conflict";
60
60
  message_not_found: "message_not_found";
61
61
  model_discovery_unsupported: "model_discovery_unsupported";
62
62
  model_not_found: "model_not_found";
@@ -74,6 +74,8 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
74
74
  rate_limited: "rate_limited";
75
75
  service_unavailable: "service_unavailable";
76
76
  session_busy: "session_busy";
77
+ session_fork_deleted: "session_fork_deleted";
78
+ session_fork_unavailable: "session_fork_unavailable";
77
79
  session_version_mismatch: "session_version_mismatch";
78
80
  skill_invalid_archive: "skill_invalid_archive";
79
81
  skill_invalid_markdown: "skill_invalid_markdown";
@@ -82,13 +84,14 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
82
84
  skill_not_found: "skill_not_found";
83
85
  skill_too_many_files: "skill_too_many_files";
84
86
  skill_uncompressed_too_large: "skill_uncompressed_too_large";
87
+ steer_not_available: "steer_not_available";
85
88
  subscription_required: "subscription_required";
86
89
  task_active_run_exists: "task_active_run_exists";
87
90
  tenant_deleting: "tenant_deleting";
88
91
  tenant_deletion_in_progress: "tenant_deletion_in_progress";
89
92
  tenant_deletion_not_ready: "tenant_deletion_not_ready";
90
93
  tenant_not_deleting: "tenant_not_deleting";
91
- tool_approval_continuation_not_found: "tool_approval_continuation_not_found";
94
+ tool_approval_continuation_settled: "tool_approval_continuation_settled";
92
95
  tool_approval_decision_conflict: "tool_approval_decision_conflict";
93
96
  unauthorized: "unauthorized";
94
97
  usage_credit_required: "usage_credit_required";
@@ -112,7 +115,6 @@ export declare const apiErrorSchema: z.ZodObject<{
112
115
  function_call_conflict: "function_call_conflict";
113
116
  idempotency_conflict: "idempotency_conflict";
114
117
  input_idempotency_conflict: "input_idempotency_conflict";
115
- input_not_pending: "input_not_pending";
116
118
  internal: "internal";
117
119
  invalid_cursor: "invalid_cursor";
118
120
  invalid_request: "invalid_request";
@@ -137,6 +139,7 @@ export declare const apiErrorSchema: z.ZodObject<{
137
139
  merchant_event_state_conflict: "merchant_event_state_conflict";
138
140
  merchant_provider_unavailable: "merchant_provider_unavailable";
139
141
  merchant_subscription_required: "merchant_subscription_required";
142
+ message_id_conflict: "message_id_conflict";
140
143
  message_not_found: "message_not_found";
141
144
  model_discovery_unsupported: "model_discovery_unsupported";
142
145
  model_not_found: "model_not_found";
@@ -154,6 +157,8 @@ export declare const apiErrorSchema: z.ZodObject<{
154
157
  rate_limited: "rate_limited";
155
158
  service_unavailable: "service_unavailable";
156
159
  session_busy: "session_busy";
160
+ session_fork_deleted: "session_fork_deleted";
161
+ session_fork_unavailable: "session_fork_unavailable";
157
162
  session_version_mismatch: "session_version_mismatch";
158
163
  skill_invalid_archive: "skill_invalid_archive";
159
164
  skill_invalid_markdown: "skill_invalid_markdown";
@@ -162,13 +167,14 @@ export declare const apiErrorSchema: z.ZodObject<{
162
167
  skill_not_found: "skill_not_found";
163
168
  skill_too_many_files: "skill_too_many_files";
164
169
  skill_uncompressed_too_large: "skill_uncompressed_too_large";
170
+ steer_not_available: "steer_not_available";
165
171
  subscription_required: "subscription_required";
166
172
  task_active_run_exists: "task_active_run_exists";
167
173
  tenant_deleting: "tenant_deleting";
168
174
  tenant_deletion_in_progress: "tenant_deletion_in_progress";
169
175
  tenant_deletion_not_ready: "tenant_deletion_not_ready";
170
176
  tenant_not_deleting: "tenant_not_deleting";
171
- tool_approval_continuation_not_found: "tool_approval_continuation_not_found";
177
+ tool_approval_continuation_settled: "tool_approval_continuation_settled";
172
178
  tool_approval_decision_conflict: "tool_approval_decision_conflict";
173
179
  unauthorized: "unauthorized";
174
180
  usage_credit_required: "usage_credit_required";
@@ -197,7 +203,6 @@ export declare const apiErrorResponseSchema: z.ZodObject<{
197
203
  function_call_conflict: "function_call_conflict";
198
204
  idempotency_conflict: "idempotency_conflict";
199
205
  input_idempotency_conflict: "input_idempotency_conflict";
200
- input_not_pending: "input_not_pending";
201
206
  internal: "internal";
202
207
  invalid_cursor: "invalid_cursor";
203
208
  invalid_request: "invalid_request";
@@ -222,6 +227,7 @@ export declare const apiErrorResponseSchema: z.ZodObject<{
222
227
  merchant_event_state_conflict: "merchant_event_state_conflict";
223
228
  merchant_provider_unavailable: "merchant_provider_unavailable";
224
229
  merchant_subscription_required: "merchant_subscription_required";
230
+ message_id_conflict: "message_id_conflict";
225
231
  message_not_found: "message_not_found";
226
232
  model_discovery_unsupported: "model_discovery_unsupported";
227
233
  model_not_found: "model_not_found";
@@ -239,6 +245,8 @@ export declare const apiErrorResponseSchema: z.ZodObject<{
239
245
  rate_limited: "rate_limited";
240
246
  service_unavailable: "service_unavailable";
241
247
  session_busy: "session_busy";
248
+ session_fork_deleted: "session_fork_deleted";
249
+ session_fork_unavailable: "session_fork_unavailable";
242
250
  session_version_mismatch: "session_version_mismatch";
243
251
  skill_invalid_archive: "skill_invalid_archive";
244
252
  skill_invalid_markdown: "skill_invalid_markdown";
@@ -247,13 +255,14 @@ export declare const apiErrorResponseSchema: z.ZodObject<{
247
255
  skill_not_found: "skill_not_found";
248
256
  skill_too_many_files: "skill_too_many_files";
249
257
  skill_uncompressed_too_large: "skill_uncompressed_too_large";
258
+ steer_not_available: "steer_not_available";
250
259
  subscription_required: "subscription_required";
251
260
  task_active_run_exists: "task_active_run_exists";
252
261
  tenant_deleting: "tenant_deleting";
253
262
  tenant_deletion_in_progress: "tenant_deletion_in_progress";
254
263
  tenant_deletion_not_ready: "tenant_deletion_not_ready";
255
264
  tenant_not_deleting: "tenant_not_deleting";
256
- tool_approval_continuation_not_found: "tool_approval_continuation_not_found";
265
+ tool_approval_continuation_settled: "tool_approval_continuation_settled";
257
266
  tool_approval_decision_conflict: "tool_approval_decision_conflict";
258
267
  unauthorized: "unauthorized";
259
268
  usage_credit_required: "usage_credit_required";
@@ -284,17 +293,29 @@ export interface ApiErrorOptions {
284
293
  details?: Record<string, unknown>;
285
294
  param?: string;
286
295
  }
296
+ /**
297
+ * Builds an API error envelope with optional parameter and detail fields.
298
+ * @param code - API error code for programmatic handling.
299
+ * @param message - Human-readable error description.
300
+ * @param options - Configuration for this operation.
301
+ */
287
302
  export declare function apiError(code: ApiErrorCode, message: string, options?: ApiErrorOptions): ApiErrorResponse;
288
303
  /**
289
304
  * Cursor pagination — `{ data, nextCursor }` on unbounded list surfaces,
290
305
  * including sessions, transcripts, artifacts, and memories.
291
306
  * `nextCursor` is opaque (base64 of the keyset); `null` means no more pages.
307
+ * @param data - Response data to wrap in the success envelope.
308
+ * @param nextCursor - Next Cursor.
292
309
  */
293
310
  export declare function paginatedResponse<T>(data: T[], nextCursor: string | null): {
294
311
  data: T[];
295
312
  nextCursor: string | null;
296
313
  };
297
314
  export declare const cursorSchema: z.ZodString;
315
+ /**
316
+ * Creates a schema for a data page and nullable next cursor.
317
+ * @param itemSchema - Item Schema.
318
+ */
298
319
  export declare function paginatedResponseSchema<T extends z.ZodTypeAny>(itemSchema: T): z.ZodObject<{
299
320
  data: z.ZodArray<T>;
300
321
  nextCursor: z.ZodNullable<z.ZodString>;
@@ -309,8 +330,21 @@ export declare function paginatedResponseSchema<T extends z.ZodTypeAny>(itemSche
309
330
  export declare class CursorDecodeError extends Error {
310
331
  readonly errorCode = "INVALID_CURSOR";
311
332
  readonly statusCode = 400;
333
+ /**
334
+ * Creates the error with the supplied message.
335
+ * @param message - Human-readable error description.
336
+ * @param options - Configuration for this operation.
337
+ */
312
338
  constructor(message: string, options?: ErrorOptions);
313
339
  }
340
+ /**
341
+ * Encodes a cursor payload as URL-safe base64 JSON.
342
+ * @param payload - JSON-serializable cursor fields. This function does not validate them.
343
+ */
314
344
  export declare function encodeCursor(payload: Record<string, unknown>): string;
345
+ /**
346
+ * Decodes and validates a URL-safe base64 JSON cursor.
347
+ * @param cursor - URL-safe base64 JSON cursor to decode.
348
+ */
315
349
  export declare function decodeCursor(cursor: string): Record<string, unknown>;
316
350
  export {};
@@ -19,8 +19,10 @@ 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
- "input_not_pending",
25
+ "steer_not_available",
24
26
  "validation_failed",
25
27
  "unauthorized",
26
28
  "forbidden",
@@ -41,6 +43,7 @@ export const apiErrorCodeSchema = z.enum([
41
43
  "artifact_session_cap_reached",
42
44
  "invalid_cursor",
43
45
  "message_not_found",
46
+ "message_id_conflict",
44
47
  "prompt_variable_missing",
45
48
  "prompt_variable_unknown",
46
49
  "provider_in_use",
@@ -64,7 +67,7 @@ export const apiErrorCodeSchema = z.enum([
64
67
  "workspace_busy",
65
68
  "session_busy",
66
69
  "session_version_mismatch",
67
- "tool_approval_continuation_not_found",
70
+ "tool_approval_continuation_settled",
68
71
  "tool_approval_decision_conflict",
69
72
  "function_call_conflict",
70
73
  "skill_invalid_archive",
@@ -125,6 +128,12 @@ export const receivedApiErrorResponseSchema = z
125
128
  error: receivedApiErrorSchema,
126
129
  })
127
130
  .passthrough();
131
+ /**
132
+ * Builds an API error envelope with optional parameter and detail fields.
133
+ * @param code - API error code for programmatic handling.
134
+ * @param message - Human-readable error description.
135
+ * @param options - Configuration for this operation.
136
+ */
128
137
  export function apiError(code, message, options = {}) {
129
138
  return {
130
139
  error: {
@@ -141,11 +150,17 @@ export function apiError(code, message, options = {}) {
141
150
  * Cursor pagination — `{ data, nextCursor }` on unbounded list surfaces,
142
151
  * including sessions, transcripts, artifacts, and memories.
143
152
  * `nextCursor` is opaque (base64 of the keyset); `null` means no more pages.
153
+ * @param data - Response data to wrap in the success envelope.
154
+ * @param nextCursor - Next Cursor.
144
155
  */
145
156
  export function paginatedResponse(data, nextCursor) {
146
157
  return { data, nextCursor };
147
158
  }
148
159
  export const cursorSchema = z.string().trim().min(1);
160
+ /**
161
+ * Creates a schema for a data page and nullable next cursor.
162
+ * @param itemSchema - Item Schema.
163
+ */
149
164
  export function paginatedResponseSchema(itemSchema) {
150
165
  return z
151
166
  .object({
@@ -164,6 +179,11 @@ export function paginatedResponseSchema(itemSchema) {
164
179
  export class CursorDecodeError extends Error {
165
180
  errorCode = "INVALID_CURSOR";
166
181
  statusCode = 400;
182
+ /**
183
+ * Creates the error with the supplied message.
184
+ * @param message - Human-readable error description.
185
+ * @param options - Configuration for this operation.
186
+ */
167
187
  constructor(message, options) {
168
188
  super(message, options);
169
189
  this.name = "CursorDecodeError";
@@ -174,6 +194,10 @@ const BASE64_SLASH = /\//g;
174
194
  const BASE64_PADDING = /[=]+$/;
175
195
  const BASE64_DASH = /-/g;
176
196
  const BASE64_UNDERSCORE = /_/g;
197
+ /**
198
+ * Encodes a cursor payload as URL-safe base64 JSON.
199
+ * @param payload - JSON-serializable cursor fields. This function does not validate them.
200
+ */
177
201
  export function encodeCursor(payload) {
178
202
  const json = JSON.stringify(payload);
179
203
  const bytes = new TextEncoder().encode(json);
@@ -186,6 +210,10 @@ export function encodeCursor(payload) {
186
210
  .replace(BASE64_SLASH, "_")
187
211
  .replace(BASE64_PADDING, "");
188
212
  }
213
+ /**
214
+ * Decodes and validates a URL-safe base64 JSON cursor.
215
+ * @param cursor - URL-safe base64 JSON cursor to decode.
216
+ */
189
217
  export function decodeCursor(cursor) {
190
218
  let json;
191
219
  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