@blazingagents/sdk 0.23.0 → 0.25.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.
- package/dist/chat-transport.d.ts +6 -0
- package/dist/chat-transport.js +15 -8
- package/dist/contracts/api.d.ts +0 -245
- package/dist/contracts/api.js +0 -121
- package/dist/contracts/entities/agent-tools.d.ts +0 -4
- package/dist/contracts/entities/agent-tools.js +0 -15
- package/dist/contracts/entities/agents.d.ts +2 -109
- package/dist/contracts/entities/agents.js +15 -16
- package/dist/contracts/entities/artifacts.d.ts +0 -30
- package/dist/contracts/entities/artifacts.js +1 -36
- package/dist/contracts/entities/attribution.d.ts +0 -2
- package/dist/contracts/entities/chat-connections.d.ts +0 -3
- package/dist/contracts/entities/chat-connections.js +0 -3
- package/dist/contracts/entities/chat.d.ts +1 -17
- package/dist/contracts/entities/chat.js +4 -13
- package/dist/contracts/entities/mcp-connections.d.ts +0 -168
- package/dist/contracts/entities/mcp-connections.js +1 -171
- package/dist/contracts/entities/memories.d.ts +0 -8
- package/dist/contracts/entities/memories.js +2 -15
- package/dist/contracts/entities/merchant.d.ts +0 -19
- package/dist/contracts/entities/merchant.js +1 -26
- package/dist/contracts/entities/prompts.d.ts +1 -14
- package/dist/contracts/entities/prompts.js +2 -3
- package/dist/contracts/entities/providers.d.ts +0 -28
- package/dist/contracts/entities/providers.js +1 -24
- package/dist/contracts/entities/sessions.d.ts +0 -9
- package/dist/contracts/entities/sessions.js +4 -21
- package/dist/contracts/entities/skills.d.ts +0 -52
- package/dist/contracts/entities/skills.js +2 -60
- package/dist/contracts/entities/tasks.d.ts +1 -168
- package/dist/contracts/entities/tasks.js +5 -14
- package/dist/contracts/entities/tenants.d.ts +0 -6
- package/dist/contracts/entities/usage.d.ts +0 -1
- package/dist/contracts/entities/workspaces.d.ts +0 -6
- package/dist/contracts/entities/workspaces.js +2 -14
- package/dist/contracts/ids.d.ts +1 -68
- package/dist/contracts/ids.js +2 -91
- package/dist/contracts/index.d.ts +3 -3
- package/dist/contracts/index.js +3 -3
- package/dist/contracts/limitations.d.ts +8 -81
- package/dist/contracts/limitations.js +8 -82
- package/dist/direct-chat-transport.d.ts +6 -0
- package/dist/direct-chat-transport.js +19 -2
- package/dist/generation.js +20 -4
- package/dist/types.d.ts +6 -0
- package/package.json +6 -6
package/dist/chat-transport.d.ts
CHANGED
|
@@ -5,6 +5,12 @@ export type BlazingAgentsChatTransportOptions<UI_MESSAGE extends UIMessage = UIM
|
|
|
5
5
|
* @param sessionId - Session to look up or record.
|
|
6
6
|
*/
|
|
7
7
|
onSessionId?: (sessionId: string) => Promise<void> | void;
|
|
8
|
+
/**
|
|
9
|
+
* Receives the running Turn ID from each response that names one, before
|
|
10
|
+
* its stream is consumed. Pass it to Stop.
|
|
11
|
+
* @param turnId - Turn the response runs.
|
|
12
|
+
*/
|
|
13
|
+
onTurnId?: (turnId: string) => Promise<void> | void;
|
|
8
14
|
/** An authorized Session ID used to resume after a remount or reload. */
|
|
9
15
|
sessionId?: string;
|
|
10
16
|
};
|
package/dist/chat-transport.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { lastAssistantMessageIsCompleteWithApprovalResponses, } from "ai";
|
|
2
2
|
import { ChatStreamTransport } from "./chat-stream-transport.js";
|
|
3
|
-
import { sessionIdSchema } from "./contracts/ids.js";
|
|
3
|
+
import { sessionIdSchema, turnIdSchema } from "./contracts/ids.js";
|
|
4
4
|
/**
|
|
5
5
|
* Adapts AI SDK chat requests to the Blazing Agents backend-relay shape and
|
|
6
6
|
* resumes with the server-minted Session ID returned in `Location`.
|
|
@@ -13,27 +13,34 @@ export class BlazingAgentsChatTransport {
|
|
|
13
13
|
* @param options - Configuration for this operation.
|
|
14
14
|
*/
|
|
15
15
|
constructor(options = {}) {
|
|
16
|
-
const { onSessionId, sessionId, ...transportOptions } = options;
|
|
16
|
+
const { onSessionId, onTurnId, sessionId, ...transportOptions } = options;
|
|
17
17
|
const transportFetch = transportOptions.fetch ?? globalThis.fetch;
|
|
18
18
|
this.#sessionId =
|
|
19
19
|
sessionId === undefined ? undefined : sessionIdSchema.parse(sessionId);
|
|
20
20
|
this.#transport = new ChatStreamTransport({
|
|
21
21
|
...transportOptions,
|
|
22
|
-
/** Reads the first Session ID
|
|
22
|
+
/** Reads the first Session ID and each Turn ID before returning the response. */
|
|
23
23
|
fetch: async (input, init) => {
|
|
24
24
|
const response = await transportFetch(input, init);
|
|
25
|
-
if (response.ok
|
|
26
|
-
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
return response;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
if (this.#sessionId === undefined) {
|
|
27
30
|
const location = response.headers.get("location");
|
|
28
31
|
const candidate = location?.split("/").pop();
|
|
29
32
|
this.#sessionId = sessionIdSchema.parse(candidate);
|
|
30
33
|
await onSessionId?.(this.#sessionId);
|
|
31
34
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
const turnId = turnIdSchema.safeParse(response.headers.get("x-ba-turn-id"));
|
|
36
|
+
if (turnId.success) {
|
|
37
|
+
await onTurnId?.(turnId.data);
|
|
35
38
|
}
|
|
36
39
|
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
await response.body?.cancel(error).catch(() => undefined);
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
37
44
|
return response;
|
|
38
45
|
},
|
|
39
46
|
/** Selects the user message or complete approval round for the relay request. */
|
package/dist/contracts/api.d.ts
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const clientRequestCorrelationSchema: z.ZodString;
|
|
3
|
-
export declare const apiErrorIssueSchema: z.ZodObject<{
|
|
4
|
-
code: z.ZodString;
|
|
5
|
-
location: z.ZodEnum<{
|
|
6
|
-
body: "body";
|
|
7
|
-
header: "header";
|
|
8
|
-
path: "path";
|
|
9
|
-
query: "query";
|
|
10
|
-
}>;
|
|
11
|
-
message: z.ZodString;
|
|
12
|
-
path: z.ZodString;
|
|
13
|
-
}, z.core.$strict>;
|
|
14
|
-
export type ApiErrorIssue = z.infer<typeof apiErrorIssueSchema>;
|
|
15
2
|
/**
|
|
16
3
|
* `/v1` error envelope — see docs/adr/0003-ai-sdk-native-wire-protocol.md.
|
|
17
4
|
* Closed producer code set; `code` is what SDKs switch on and `message` is
|
|
@@ -101,185 +88,6 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
|
|
|
101
88
|
workspace_in_use: "workspace_in_use";
|
|
102
89
|
workspace_not_found: "workspace_not_found";
|
|
103
90
|
}>;
|
|
104
|
-
export declare const apiErrorSchema: z.ZodObject<{
|
|
105
|
-
code: z.ZodEnum<{
|
|
106
|
-
admin_agent_managed: "admin_agent_managed";
|
|
107
|
-
agent_disabled: "agent_disabled";
|
|
108
|
-
agent_mcp_connection_not_found: "agent_mcp_connection_not_found";
|
|
109
|
-
agent_mcp_connections_invalid: "agent_mcp_connections_invalid";
|
|
110
|
-
api_key_limit_reached: "api_key_limit_reached";
|
|
111
|
-
artifact_session_cap_reached: "artifact_session_cap_reached";
|
|
112
|
-
chat_webhook_conflict: "chat_webhook_conflict";
|
|
113
|
-
chat_webhook_registration_failed: "chat_webhook_registration_failed";
|
|
114
|
-
checkout_evidence_mismatch: "checkout_evidence_mismatch";
|
|
115
|
-
forbidden: "forbidden";
|
|
116
|
-
function_call_conflict: "function_call_conflict";
|
|
117
|
-
idempotency_conflict: "idempotency_conflict";
|
|
118
|
-
input_idempotency_conflict: "input_idempotency_conflict";
|
|
119
|
-
internal: "internal";
|
|
120
|
-
invalid_cursor: "invalid_cursor";
|
|
121
|
-
invalid_request: "invalid_request";
|
|
122
|
-
mcp_connection_authentication_failed: "mcp_connection_authentication_failed";
|
|
123
|
-
mcp_connection_discovery_failed: "mcp_connection_discovery_failed";
|
|
124
|
-
mcp_connection_in_use: "mcp_connection_in_use";
|
|
125
|
-
mcp_connection_invalid: "mcp_connection_invalid";
|
|
126
|
-
mcp_connection_limit_reached: "mcp_connection_limit_reached";
|
|
127
|
-
mcp_connection_name_conflict: "mcp_connection_name_conflict";
|
|
128
|
-
mcp_connection_stale_credential_version: "mcp_connection_stale_credential_version";
|
|
129
|
-
mcp_connection_unreachable: "mcp_connection_unreachable";
|
|
130
|
-
merchant_account_mismatch: "merchant_account_mismatch";
|
|
131
|
-
merchant_balance_required: "merchant_balance_required";
|
|
132
|
-
merchant_binding_not_found: "merchant_binding_not_found";
|
|
133
|
-
merchant_binding_required: "merchant_binding_required";
|
|
134
|
-
merchant_connection_not_found: "merchant_connection_not_found";
|
|
135
|
-
merchant_credential_invalid: "merchant_credential_invalid";
|
|
136
|
-
merchant_customer_not_found: "merchant_customer_not_found";
|
|
137
|
-
merchant_customer_unmapped: "merchant_customer_unmapped";
|
|
138
|
-
merchant_eligibility_unavailable: "merchant_eligibility_unavailable";
|
|
139
|
-
merchant_event_not_found: "merchant_event_not_found";
|
|
140
|
-
merchant_event_state_conflict: "merchant_event_state_conflict";
|
|
141
|
-
merchant_provider_unavailable: "merchant_provider_unavailable";
|
|
142
|
-
merchant_subscription_required: "merchant_subscription_required";
|
|
143
|
-
message_id_conflict: "message_id_conflict";
|
|
144
|
-
message_not_found: "message_not_found";
|
|
145
|
-
model_discovery_unsupported: "model_discovery_unsupported";
|
|
146
|
-
model_not_found: "model_not_found";
|
|
147
|
-
model_spending_limit_exceeded: "model_spending_limit_exceeded";
|
|
148
|
-
model_validation_unavailable: "model_validation_unavailable";
|
|
149
|
-
not_found: "not_found";
|
|
150
|
-
prompt_variable_missing: "prompt_variable_missing";
|
|
151
|
-
prompt_variable_unknown: "prompt_variable_unknown";
|
|
152
|
-
provider_historical_use: "provider_historical_use";
|
|
153
|
-
provider_in_use: "provider_in_use";
|
|
154
|
-
provider_limit_reached: "provider_limit_reached";
|
|
155
|
-
provider_name_conflict: "provider_name_conflict";
|
|
156
|
-
provider_not_found: "provider_not_found";
|
|
157
|
-
provider_required: "provider_required";
|
|
158
|
-
quota_exceeded: "quota_exceeded";
|
|
159
|
-
rate_limited: "rate_limited";
|
|
160
|
-
service_unavailable: "service_unavailable";
|
|
161
|
-
session_busy: "session_busy";
|
|
162
|
-
session_fork_deleted: "session_fork_deleted";
|
|
163
|
-
session_fork_unavailable: "session_fork_unavailable";
|
|
164
|
-
session_version_mismatch: "session_version_mismatch";
|
|
165
|
-
skill_invalid_archive: "skill_invalid_archive";
|
|
166
|
-
skill_invalid_markdown: "skill_invalid_markdown";
|
|
167
|
-
skill_limit_reached: "skill_limit_reached";
|
|
168
|
-
skill_name_conflict: "skill_name_conflict";
|
|
169
|
-
skill_not_found: "skill_not_found";
|
|
170
|
-
skill_too_many_files: "skill_too_many_files";
|
|
171
|
-
skill_uncompressed_too_large: "skill_uncompressed_too_large";
|
|
172
|
-
steer_not_available: "steer_not_available";
|
|
173
|
-
subscription_required: "subscription_required";
|
|
174
|
-
task_active_run_exists: "task_active_run_exists";
|
|
175
|
-
tenant_deleting: "tenant_deleting";
|
|
176
|
-
tenant_deletion_in_progress: "tenant_deletion_in_progress";
|
|
177
|
-
tenant_deletion_not_ready: "tenant_deletion_not_ready";
|
|
178
|
-
tenant_not_deleting: "tenant_not_deleting";
|
|
179
|
-
tool_approval_continuation_settled: "tool_approval_continuation_settled";
|
|
180
|
-
tool_approval_decision_conflict: "tool_approval_decision_conflict";
|
|
181
|
-
unauthorized: "unauthorized";
|
|
182
|
-
usage_credit_required: "usage_credit_required";
|
|
183
|
-
validation_failed: "validation_failed";
|
|
184
|
-
workspace_busy: "workspace_busy";
|
|
185
|
-
workspace_in_use: "workspace_in_use";
|
|
186
|
-
workspace_not_found: "workspace_not_found";
|
|
187
|
-
}>;
|
|
188
|
-
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
189
|
-
message: z.ZodString;
|
|
190
|
-
param: z.ZodOptional<z.ZodString>;
|
|
191
|
-
}, z.core.$strict>;
|
|
192
|
-
export declare const apiErrorResponseSchema: z.ZodObject<{
|
|
193
|
-
error: z.ZodObject<{
|
|
194
|
-
code: z.ZodEnum<{
|
|
195
|
-
admin_agent_managed: "admin_agent_managed";
|
|
196
|
-
agent_disabled: "agent_disabled";
|
|
197
|
-
agent_mcp_connection_not_found: "agent_mcp_connection_not_found";
|
|
198
|
-
agent_mcp_connections_invalid: "agent_mcp_connections_invalid";
|
|
199
|
-
api_key_limit_reached: "api_key_limit_reached";
|
|
200
|
-
artifact_session_cap_reached: "artifact_session_cap_reached";
|
|
201
|
-
chat_webhook_conflict: "chat_webhook_conflict";
|
|
202
|
-
chat_webhook_registration_failed: "chat_webhook_registration_failed";
|
|
203
|
-
checkout_evidence_mismatch: "checkout_evidence_mismatch";
|
|
204
|
-
forbidden: "forbidden";
|
|
205
|
-
function_call_conflict: "function_call_conflict";
|
|
206
|
-
idempotency_conflict: "idempotency_conflict";
|
|
207
|
-
input_idempotency_conflict: "input_idempotency_conflict";
|
|
208
|
-
internal: "internal";
|
|
209
|
-
invalid_cursor: "invalid_cursor";
|
|
210
|
-
invalid_request: "invalid_request";
|
|
211
|
-
mcp_connection_authentication_failed: "mcp_connection_authentication_failed";
|
|
212
|
-
mcp_connection_discovery_failed: "mcp_connection_discovery_failed";
|
|
213
|
-
mcp_connection_in_use: "mcp_connection_in_use";
|
|
214
|
-
mcp_connection_invalid: "mcp_connection_invalid";
|
|
215
|
-
mcp_connection_limit_reached: "mcp_connection_limit_reached";
|
|
216
|
-
mcp_connection_name_conflict: "mcp_connection_name_conflict";
|
|
217
|
-
mcp_connection_stale_credential_version: "mcp_connection_stale_credential_version";
|
|
218
|
-
mcp_connection_unreachable: "mcp_connection_unreachable";
|
|
219
|
-
merchant_account_mismatch: "merchant_account_mismatch";
|
|
220
|
-
merchant_balance_required: "merchant_balance_required";
|
|
221
|
-
merchant_binding_not_found: "merchant_binding_not_found";
|
|
222
|
-
merchant_binding_required: "merchant_binding_required";
|
|
223
|
-
merchant_connection_not_found: "merchant_connection_not_found";
|
|
224
|
-
merchant_credential_invalid: "merchant_credential_invalid";
|
|
225
|
-
merchant_customer_not_found: "merchant_customer_not_found";
|
|
226
|
-
merchant_customer_unmapped: "merchant_customer_unmapped";
|
|
227
|
-
merchant_eligibility_unavailable: "merchant_eligibility_unavailable";
|
|
228
|
-
merchant_event_not_found: "merchant_event_not_found";
|
|
229
|
-
merchant_event_state_conflict: "merchant_event_state_conflict";
|
|
230
|
-
merchant_provider_unavailable: "merchant_provider_unavailable";
|
|
231
|
-
merchant_subscription_required: "merchant_subscription_required";
|
|
232
|
-
message_id_conflict: "message_id_conflict";
|
|
233
|
-
message_not_found: "message_not_found";
|
|
234
|
-
model_discovery_unsupported: "model_discovery_unsupported";
|
|
235
|
-
model_not_found: "model_not_found";
|
|
236
|
-
model_spending_limit_exceeded: "model_spending_limit_exceeded";
|
|
237
|
-
model_validation_unavailable: "model_validation_unavailable";
|
|
238
|
-
not_found: "not_found";
|
|
239
|
-
prompt_variable_missing: "prompt_variable_missing";
|
|
240
|
-
prompt_variable_unknown: "prompt_variable_unknown";
|
|
241
|
-
provider_historical_use: "provider_historical_use";
|
|
242
|
-
provider_in_use: "provider_in_use";
|
|
243
|
-
provider_limit_reached: "provider_limit_reached";
|
|
244
|
-
provider_name_conflict: "provider_name_conflict";
|
|
245
|
-
provider_not_found: "provider_not_found";
|
|
246
|
-
provider_required: "provider_required";
|
|
247
|
-
quota_exceeded: "quota_exceeded";
|
|
248
|
-
rate_limited: "rate_limited";
|
|
249
|
-
service_unavailable: "service_unavailable";
|
|
250
|
-
session_busy: "session_busy";
|
|
251
|
-
session_fork_deleted: "session_fork_deleted";
|
|
252
|
-
session_fork_unavailable: "session_fork_unavailable";
|
|
253
|
-
session_version_mismatch: "session_version_mismatch";
|
|
254
|
-
skill_invalid_archive: "skill_invalid_archive";
|
|
255
|
-
skill_invalid_markdown: "skill_invalid_markdown";
|
|
256
|
-
skill_limit_reached: "skill_limit_reached";
|
|
257
|
-
skill_name_conflict: "skill_name_conflict";
|
|
258
|
-
skill_not_found: "skill_not_found";
|
|
259
|
-
skill_too_many_files: "skill_too_many_files";
|
|
260
|
-
skill_uncompressed_too_large: "skill_uncompressed_too_large";
|
|
261
|
-
steer_not_available: "steer_not_available";
|
|
262
|
-
subscription_required: "subscription_required";
|
|
263
|
-
task_active_run_exists: "task_active_run_exists";
|
|
264
|
-
tenant_deleting: "tenant_deleting";
|
|
265
|
-
tenant_deletion_in_progress: "tenant_deletion_in_progress";
|
|
266
|
-
tenant_deletion_not_ready: "tenant_deletion_not_ready";
|
|
267
|
-
tenant_not_deleting: "tenant_not_deleting";
|
|
268
|
-
tool_approval_continuation_settled: "tool_approval_continuation_settled";
|
|
269
|
-
tool_approval_decision_conflict: "tool_approval_decision_conflict";
|
|
270
|
-
unauthorized: "unauthorized";
|
|
271
|
-
usage_credit_required: "usage_credit_required";
|
|
272
|
-
validation_failed: "validation_failed";
|
|
273
|
-
workspace_busy: "workspace_busy";
|
|
274
|
-
workspace_in_use: "workspace_in_use";
|
|
275
|
-
workspace_not_found: "workspace_not_found";
|
|
276
|
-
}>;
|
|
277
|
-
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
278
|
-
message: z.ZodString;
|
|
279
|
-
param: z.ZodOptional<z.ZodString>;
|
|
280
|
-
}, z.core.$strict>;
|
|
281
|
-
}, z.core.$strict>;
|
|
282
|
-
declare const receivedApiErrorCodeSchema: z.ZodString;
|
|
283
91
|
export declare const receivedApiErrorResponseSchema: z.ZodObject<{
|
|
284
92
|
error: z.ZodObject<{
|
|
285
93
|
code: z.ZodString;
|
|
@@ -289,31 +97,6 @@ export declare const receivedApiErrorResponseSchema: z.ZodObject<{
|
|
|
289
97
|
}, z.core.$loose>;
|
|
290
98
|
}, z.core.$loose>;
|
|
291
99
|
export type ApiErrorCode = z.infer<typeof apiErrorCodeSchema>;
|
|
292
|
-
export type ApiError = z.infer<typeof apiErrorSchema>;
|
|
293
|
-
export type ApiErrorResponse = z.infer<typeof apiErrorResponseSchema>;
|
|
294
|
-
export type ReceivedApiErrorCode = z.infer<typeof receivedApiErrorCodeSchema>;
|
|
295
|
-
export interface ApiErrorOptions {
|
|
296
|
-
details?: Record<string, unknown>;
|
|
297
|
-
param?: string;
|
|
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
|
-
*/
|
|
305
|
-
export declare function apiError(code: ApiErrorCode, message: string, options?: ApiErrorOptions): ApiErrorResponse;
|
|
306
|
-
/**
|
|
307
|
-
* Cursor pagination — `{ data, nextCursor }` on unbounded list surfaces,
|
|
308
|
-
* including sessions, transcripts, artifacts, and memories.
|
|
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.
|
|
312
|
-
*/
|
|
313
|
-
export declare function paginatedResponse<T>(data: T[], nextCursor: string | null): {
|
|
314
|
-
data: T[];
|
|
315
|
-
nextCursor: string | null;
|
|
316
|
-
};
|
|
317
100
|
export declare const cursorSchema: z.ZodString;
|
|
318
101
|
/**
|
|
319
102
|
* Creates a schema for a data page and nullable next cursor.
|
|
@@ -323,31 +106,3 @@ export declare function paginatedResponseSchema<T extends z.ZodTypeAny>(itemSche
|
|
|
323
106
|
data: z.ZodArray<T>;
|
|
324
107
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
325
108
|
}, z.core.$strip>;
|
|
326
|
-
/**
|
|
327
|
-
* Opaque keyset cursor helpers. Cursors are base64url-encoded JSON of the
|
|
328
|
-
* keyset tuple the endpoint paginates by — never a raw value, never a row
|
|
329
|
-
* id alone. The repo-wide pattern: keyset-backed `{ data, nextCursor }`,
|
|
330
|
-
* mapping 1:1 onto `useInfiniteQuery`. Decode failures surface as
|
|
331
|
-
* `INVALID_CURSOR` (the caller wraps the throw).
|
|
332
|
-
*/
|
|
333
|
-
export declare class CursorDecodeError extends Error {
|
|
334
|
-
readonly errorCode = "INVALID_CURSOR";
|
|
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
|
-
*/
|
|
341
|
-
constructor(message: string, options?: ErrorOptions);
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
352
|
-
export declare function decodeCursor(cursor: string): Record<string, unknown>;
|
|
353
|
-
export {};
|
package/dist/contracts/api.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export const clientRequestCorrelationSchema = z
|
|
3
|
-
.string()
|
|
4
|
-
.regex(/^[A-Za-z0-9._:-]{1,128}$/);
|
|
5
|
-
export const apiErrorIssueSchema = z
|
|
6
|
-
.object({
|
|
7
|
-
code: z.string().min(1),
|
|
8
|
-
location: z.enum(["body", "path", "query", "header"]),
|
|
9
|
-
message: z.string().min(1),
|
|
10
|
-
path: z.string(),
|
|
11
|
-
})
|
|
12
|
-
.strict();
|
|
13
2
|
/**
|
|
14
3
|
* `/v1` error envelope — see docs/adr/0003-ai-sdk-native-wire-protocol.md.
|
|
15
4
|
* Closed producer code set; `code` is what SDKs switch on and `message` is
|
|
@@ -99,22 +88,6 @@ export const apiErrorCodeSchema = z.enum([
|
|
|
99
88
|
"tenant_deletion_not_ready",
|
|
100
89
|
"tenant_not_deleting",
|
|
101
90
|
]);
|
|
102
|
-
export const apiErrorSchema = z
|
|
103
|
-
.object({
|
|
104
|
-
code: apiErrorCodeSchema,
|
|
105
|
-
details: z
|
|
106
|
-
.record(z.string(), z.unknown())
|
|
107
|
-
.refine((value) => Object.keys(value).length > 0)
|
|
108
|
-
.optional(),
|
|
109
|
-
message: z.string().min(1),
|
|
110
|
-
param: z.string().optional(),
|
|
111
|
-
})
|
|
112
|
-
.strict();
|
|
113
|
-
export const apiErrorResponseSchema = z
|
|
114
|
-
.object({
|
|
115
|
-
error: apiErrorSchema,
|
|
116
|
-
})
|
|
117
|
-
.strict();
|
|
118
91
|
const receivedApiErrorCodeSchema = z.string().min(1);
|
|
119
92
|
const receivedApiErrorSchema = z
|
|
120
93
|
.object({
|
|
@@ -129,34 +102,6 @@ export const receivedApiErrorResponseSchema = z
|
|
|
129
102
|
error: receivedApiErrorSchema,
|
|
130
103
|
})
|
|
131
104
|
.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
|
-
*/
|
|
138
|
-
export function apiError(code, message, options = {}) {
|
|
139
|
-
return {
|
|
140
|
-
error: {
|
|
141
|
-
code,
|
|
142
|
-
...(options.details && Object.keys(options.details).length > 0
|
|
143
|
-
? { details: options.details }
|
|
144
|
-
: {}),
|
|
145
|
-
message,
|
|
146
|
-
...(options.param === undefined ? {} : { param: options.param }),
|
|
147
|
-
},
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Cursor pagination — `{ data, nextCursor }` on unbounded list surfaces,
|
|
152
|
-
* including sessions, transcripts, artifacts, and memories.
|
|
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.
|
|
156
|
-
*/
|
|
157
|
-
export function paginatedResponse(data, nextCursor) {
|
|
158
|
-
return { data, nextCursor };
|
|
159
|
-
}
|
|
160
105
|
export const cursorSchema = z.string().trim().min(1);
|
|
161
106
|
/**
|
|
162
107
|
* Creates a schema for a data page and nullable next cursor.
|
|
@@ -170,69 +115,3 @@ export function paginatedResponseSchema(itemSchema) {
|
|
|
170
115
|
})
|
|
171
116
|
.strip();
|
|
172
117
|
}
|
|
173
|
-
/**
|
|
174
|
-
* Opaque keyset cursor helpers. Cursors are base64url-encoded JSON of the
|
|
175
|
-
* keyset tuple the endpoint paginates by — never a raw value, never a row
|
|
176
|
-
* id alone. The repo-wide pattern: keyset-backed `{ data, nextCursor }`,
|
|
177
|
-
* mapping 1:1 onto `useInfiniteQuery`. Decode failures surface as
|
|
178
|
-
* `INVALID_CURSOR` (the caller wraps the throw).
|
|
179
|
-
*/
|
|
180
|
-
export class CursorDecodeError extends Error {
|
|
181
|
-
errorCode = "INVALID_CURSOR";
|
|
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
|
-
*/
|
|
188
|
-
constructor(message, options) {
|
|
189
|
-
super(message, options);
|
|
190
|
-
this.name = "CursorDecodeError";
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
const BASE64_PLUS = /\+/g;
|
|
194
|
-
const BASE64_SLASH = /\//g;
|
|
195
|
-
const BASE64_PADDING = /[=]+$/;
|
|
196
|
-
const BASE64_DASH = /-/g;
|
|
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
|
-
*/
|
|
202
|
-
export function encodeCursor(payload) {
|
|
203
|
-
const json = JSON.stringify(payload);
|
|
204
|
-
const bytes = new TextEncoder().encode(json);
|
|
205
|
-
let binary = "";
|
|
206
|
-
for (const byte of bytes) {
|
|
207
|
-
binary += String.fromCharCode(byte);
|
|
208
|
-
}
|
|
209
|
-
return btoa(binary)
|
|
210
|
-
.replace(BASE64_PLUS, "-")
|
|
211
|
-
.replace(BASE64_SLASH, "_")
|
|
212
|
-
.replace(BASE64_PADDING, "");
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Decodes and validates a URL-safe base64 JSON cursor.
|
|
216
|
-
* @param cursor - URL-safe base64 JSON cursor to decode.
|
|
217
|
-
*/
|
|
218
|
-
export function decodeCursor(cursor) {
|
|
219
|
-
let json;
|
|
220
|
-
try {
|
|
221
|
-
const binary = atob(cursor.replace(BASE64_DASH, "+").replace(BASE64_UNDERSCORE, "/"));
|
|
222
|
-
const bytes = new Uint8Array(binary.length);
|
|
223
|
-
for (let i = 0; i < binary.length; i += 1) {
|
|
224
|
-
bytes[i] = binary.charCodeAt(i);
|
|
225
|
-
}
|
|
226
|
-
json = new TextDecoder().decode(bytes);
|
|
227
|
-
const parsed = JSON.parse(json);
|
|
228
|
-
if (parsed === null ||
|
|
229
|
-
typeof parsed !== "object" ||
|
|
230
|
-
Array.isArray(parsed)) {
|
|
231
|
-
throw new Error("cursor payload is not an object");
|
|
232
|
-
}
|
|
233
|
-
return parsed;
|
|
234
|
-
}
|
|
235
|
-
catch (cause) {
|
|
236
|
-
throw new CursorDecodeError("Invalid cursor", { cause });
|
|
237
|
-
}
|
|
238
|
-
}
|
|
@@ -24,10 +24,6 @@ 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
|
-
*/
|
|
30
|
-
export declare function expandToolGroups(ids: Iterable<string>): Set<string>;
|
|
31
27
|
/**
|
|
32
28
|
* A model-facing tool name. Built-in tool names and the `mcp__` prefix used
|
|
33
29
|
* for MCP tools are reserved so a caller function never shadows them.
|
|
@@ -39,21 +39,6 @@ export const AGENT_TOOL_CATALOG = [
|
|
|
39
39
|
],
|
|
40
40
|
},
|
|
41
41
|
];
|
|
42
|
-
/**
|
|
43
|
-
* Expands tool group names into their individual tool names.
|
|
44
|
-
*/
|
|
45
|
-
export function expandToolGroups(ids) {
|
|
46
|
-
const result = new Set();
|
|
47
|
-
for (const id of ids) {
|
|
48
|
-
const group = AGENT_TOOL_CATALOG.find((candidate) => candidate.id === id);
|
|
49
|
-
if (group) {
|
|
50
|
-
for (const tool of group.tools) {
|
|
51
|
-
result.add(tool);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return result;
|
|
56
|
-
}
|
|
57
42
|
const RESERVED_CHAT_FUNCTION_NAMES = new Set([
|
|
58
43
|
...AGENT_TOOL_CATALOG.flatMap((group) => group.tools),
|
|
59
44
|
"activate_skill",
|
|
@@ -12,7 +12,7 @@ export declare const agentStatusSchema: z.ZodEnum<{
|
|
|
12
12
|
active: "active";
|
|
13
13
|
disabled: "disabled";
|
|
14
14
|
}>;
|
|
15
|
-
export declare const
|
|
15
|
+
export declare const agentResponseSchema: z.ZodObject<{
|
|
16
16
|
approvalInChat: z.ZodDefault<z.ZodObject<{
|
|
17
17
|
default: z.ZodEnum<{
|
|
18
18
|
auto: "auto";
|
|
@@ -227,112 +227,6 @@ export declare const agentsResponseSchema: z.ZodObject<{
|
|
|
227
227
|
}, z.core.$strip>>;
|
|
228
228
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
229
229
|
}, z.core.$strip>;
|
|
230
|
-
export declare const agentResponseSchema: z.ZodObject<{
|
|
231
|
-
approvalInChat: z.ZodDefault<z.ZodObject<{
|
|
232
|
-
default: z.ZodEnum<{
|
|
233
|
-
auto: "auto";
|
|
234
|
-
deny: "deny";
|
|
235
|
-
full: "full";
|
|
236
|
-
manual: "manual";
|
|
237
|
-
}>;
|
|
238
|
-
overrides: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
239
|
-
tool: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
240
|
-
type: z.ZodLiteral<"builtin">;
|
|
241
|
-
name: z.ZodEnum<{
|
|
242
|
-
activate_skill: "activate_skill";
|
|
243
|
-
bash: "bash";
|
|
244
|
-
delete_memory: "delete_memory";
|
|
245
|
-
edit: "edit";
|
|
246
|
-
get_memory: "get_memory";
|
|
247
|
-
glob: "glob";
|
|
248
|
-
grep: "grep";
|
|
249
|
-
publish_artifacts: "publish_artifacts";
|
|
250
|
-
read: "read";
|
|
251
|
-
save_memory: "save_memory";
|
|
252
|
-
search_memories: "search_memories";
|
|
253
|
-
update_memory: "update_memory";
|
|
254
|
-
write: "write";
|
|
255
|
-
write_todos: "write_todos";
|
|
256
|
-
}>;
|
|
257
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
258
|
-
type: z.ZodLiteral<"mcp">;
|
|
259
|
-
connectionId: z.ZodString;
|
|
260
|
-
name: z.ZodString;
|
|
261
|
-
}, z.core.$strict>], "type">;
|
|
262
|
-
decision: z.ZodEnum<{
|
|
263
|
-
auto: "auto";
|
|
264
|
-
deny: "deny";
|
|
265
|
-
full: "full";
|
|
266
|
-
manual: "manual";
|
|
267
|
-
}>;
|
|
268
|
-
}, z.core.$strict>>>;
|
|
269
|
-
}, z.core.$strict>>;
|
|
270
|
-
approvalInTasks: z.ZodDefault<z.ZodObject<{
|
|
271
|
-
default: z.ZodEnum<{
|
|
272
|
-
auto: "auto";
|
|
273
|
-
deny: "deny";
|
|
274
|
-
full: "full";
|
|
275
|
-
manual: "manual";
|
|
276
|
-
}>;
|
|
277
|
-
overrides: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
278
|
-
tool: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
279
|
-
type: z.ZodLiteral<"builtin">;
|
|
280
|
-
name: z.ZodEnum<{
|
|
281
|
-
activate_skill: "activate_skill";
|
|
282
|
-
bash: "bash";
|
|
283
|
-
delete_memory: "delete_memory";
|
|
284
|
-
edit: "edit";
|
|
285
|
-
get_memory: "get_memory";
|
|
286
|
-
glob: "glob";
|
|
287
|
-
grep: "grep";
|
|
288
|
-
publish_artifacts: "publish_artifacts";
|
|
289
|
-
read: "read";
|
|
290
|
-
save_memory: "save_memory";
|
|
291
|
-
search_memories: "search_memories";
|
|
292
|
-
update_memory: "update_memory";
|
|
293
|
-
write: "write";
|
|
294
|
-
write_todos: "write_todos";
|
|
295
|
-
}>;
|
|
296
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
297
|
-
type: z.ZodLiteral<"mcp">;
|
|
298
|
-
connectionId: z.ZodString;
|
|
299
|
-
name: z.ZodString;
|
|
300
|
-
}, z.core.$strict>], "type">;
|
|
301
|
-
decision: z.ZodEnum<{
|
|
302
|
-
auto: "auto";
|
|
303
|
-
deny: "deny";
|
|
304
|
-
full: "full";
|
|
305
|
-
manual: "manual";
|
|
306
|
-
}>;
|
|
307
|
-
}, z.core.$strict>>>;
|
|
308
|
-
}, z.core.$strict>>;
|
|
309
|
-
id: z.ZodString;
|
|
310
|
-
tenantId: z.ZodString;
|
|
311
|
-
name: z.ZodString;
|
|
312
|
-
model: z.ZodNullable<z.ZodString>;
|
|
313
|
-
thinkingLevel: z.ZodNullable<z.ZodString>;
|
|
314
|
-
providerId: z.ZodNullable<z.ZodString>;
|
|
315
|
-
workspaceId: z.ZodString;
|
|
316
|
-
autoCompaction: z.ZodBoolean;
|
|
317
|
-
compactionReserveTokens: z.ZodNumber;
|
|
318
|
-
memoryInjectionEnabled: z.ZodBoolean;
|
|
319
|
-
tools: z.ZodArray<z.ZodEnum<{
|
|
320
|
-
memory: "memory";
|
|
321
|
-
workspace: "workspace";
|
|
322
|
-
write_todos: "write_todos";
|
|
323
|
-
}>>;
|
|
324
|
-
instructions: z.ZodString;
|
|
325
|
-
userId: z.ZodString;
|
|
326
|
-
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
327
|
-
mcpConnectionIds: z.ZodArray<z.ZodString>;
|
|
328
|
-
avatarUrl: z.ZodNullable<z.ZodURL>;
|
|
329
|
-
createdAt: z.ZodISODateTime;
|
|
330
|
-
updatedAt: z.ZodISODateTime;
|
|
331
|
-
status: z.ZodEnum<{
|
|
332
|
-
active: "active";
|
|
333
|
-
disabled: "disabled";
|
|
334
|
-
}>;
|
|
335
|
-
}, z.core.$strip>;
|
|
336
230
|
export declare const agentsListQuerySchema: z.ZodObject<{
|
|
337
231
|
cursor: z.ZodOptional<z.ZodString>;
|
|
338
232
|
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
@@ -631,11 +525,10 @@ export declare const updateAgentBodySchema: z.ZodObject<{
|
|
|
631
525
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
632
526
|
mcpConnectionIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
633
527
|
}, z.core.$strict>;
|
|
634
|
-
export type Agent = z.infer<typeof
|
|
528
|
+
export type Agent = z.infer<typeof agentResponseSchema>;
|
|
635
529
|
export type AgentsResponse = z.infer<typeof agentsResponseSchema>;
|
|
636
530
|
export type AgentResponse = z.infer<typeof agentResponseSchema>;
|
|
637
531
|
export type AgentsListQuery = z.infer<typeof agentsListQuerySchema>;
|
|
638
532
|
export type AgentConfig = z.infer<typeof agentConfigSchema>;
|
|
639
|
-
export type AgentStatus = z.infer<typeof agentStatusSchema>;
|
|
640
533
|
export type CreateAgentBody = z.input<typeof createAgentBodySchema>;
|
|
641
534
|
export type UpdateAgentBody = z.input<typeof updateAgentBodySchema>;
|