@blazingagents/sdk 0.24.0 → 0.26.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/contracts/api.d.ts +1 -245
- package/dist/contracts/api.js +1 -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 +5 -92
- 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/package.json +6 -6
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
|
|
@@ -32,6 +19,7 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
|
|
|
32
19
|
function_call_conflict: "function_call_conflict";
|
|
33
20
|
idempotency_conflict: "idempotency_conflict";
|
|
34
21
|
input_idempotency_conflict: "input_idempotency_conflict";
|
|
22
|
+
insufficient_scope: "insufficient_scope";
|
|
35
23
|
internal: "internal";
|
|
36
24
|
invalid_cursor: "invalid_cursor";
|
|
37
25
|
invalid_request: "invalid_request";
|
|
@@ -101,185 +89,6 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
|
|
|
101
89
|
workspace_in_use: "workspace_in_use";
|
|
102
90
|
workspace_not_found: "workspace_not_found";
|
|
103
91
|
}>;
|
|
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
92
|
export declare const receivedApiErrorResponseSchema: z.ZodObject<{
|
|
284
93
|
error: z.ZodObject<{
|
|
285
94
|
code: z.ZodString;
|
|
@@ -289,31 +98,6 @@ export declare const receivedApiErrorResponseSchema: z.ZodObject<{
|
|
|
289
98
|
}, z.core.$loose>;
|
|
290
99
|
}, z.core.$loose>;
|
|
291
100
|
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
101
|
export declare const cursorSchema: z.ZodString;
|
|
318
102
|
/**
|
|
319
103
|
* Creates a schema for a data page and nullable next cursor.
|
|
@@ -323,31 +107,3 @@ export declare function paginatedResponseSchema<T extends z.ZodTypeAny>(itemSche
|
|
|
323
107
|
data: z.ZodArray<T>;
|
|
324
108
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
325
109
|
}, 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
|
|
@@ -26,6 +15,7 @@ export const apiErrorCodeSchema = z.enum([
|
|
|
26
15
|
"validation_failed",
|
|
27
16
|
"unauthorized",
|
|
28
17
|
"forbidden",
|
|
18
|
+
"insufficient_scope",
|
|
29
19
|
"not_found",
|
|
30
20
|
"quota_exceeded",
|
|
31
21
|
"model_spending_limit_exceeded",
|
|
@@ -99,22 +89,6 @@ export const apiErrorCodeSchema = z.enum([
|
|
|
99
89
|
"tenant_deletion_not_ready",
|
|
100
90
|
"tenant_not_deleting",
|
|
101
91
|
]);
|
|
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
92
|
const receivedApiErrorCodeSchema = z.string().min(1);
|
|
119
93
|
const receivedApiErrorSchema = z
|
|
120
94
|
.object({
|
|
@@ -129,34 +103,6 @@ export const receivedApiErrorResponseSchema = z
|
|
|
129
103
|
error: receivedApiErrorSchema,
|
|
130
104
|
})
|
|
131
105
|
.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
106
|
export const cursorSchema = z.string().trim().min(1);
|
|
161
107
|
/**
|
|
162
108
|
* Creates a schema for a data page and nullable next cursor.
|
|
@@ -170,69 +116,3 @@ export function paginatedResponseSchema(itemSchema) {
|
|
|
170
116
|
})
|
|
171
117
|
.strip();
|
|
172
118
|
}
|
|
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>;
|
|
@@ -42,7 +42,7 @@ const providerModelPairMessage = "Provider and model must either both be set or
|
|
|
42
42
|
function hasProviderModelPair(input) {
|
|
43
43
|
return (input.model === null) === (input.providerId === null);
|
|
44
44
|
}
|
|
45
|
-
export const
|
|
45
|
+
export const agentResponseSchema = z
|
|
46
46
|
.object({
|
|
47
47
|
...approvalFields,
|
|
48
48
|
id: agentIdSchema,
|
|
@@ -75,8 +75,7 @@ export const agentSchema = z
|
|
|
75
75
|
message: providerModelPairMessage,
|
|
76
76
|
path: ["providerId"],
|
|
77
77
|
});
|
|
78
|
-
export const agentsResponseSchema = paginatedResponseSchema(
|
|
79
|
-
export const agentResponseSchema = agentSchema;
|
|
78
|
+
export const agentsResponseSchema = paginatedResponseSchema(agentResponseSchema);
|
|
80
79
|
export const agentsListQuerySchema = z
|
|
81
80
|
.object({
|
|
82
81
|
cursor: cursorSchema.optional(),
|
|
@@ -93,17 +92,17 @@ export const agentsListQuerySchema = z
|
|
|
93
92
|
export const agentConfigSchema = z
|
|
94
93
|
.object({
|
|
95
94
|
...approvalFields,
|
|
96
|
-
name:
|
|
97
|
-
model:
|
|
98
|
-
thinkingLevel:
|
|
99
|
-
providerId:
|
|
100
|
-
autoCompaction:
|
|
101
|
-
compactionReserveTokens:
|
|
102
|
-
memoryInjectionEnabled:
|
|
103
|
-
tools:
|
|
104
|
-
instructions:
|
|
105
|
-
metadata:
|
|
106
|
-
mcpConnectionIds:
|
|
95
|
+
name: agentResponseSchema.shape.name,
|
|
96
|
+
model: agentResponseSchema.shape.model,
|
|
97
|
+
thinkingLevel: agentResponseSchema.shape.thinkingLevel,
|
|
98
|
+
providerId: agentResponseSchema.shape.providerId,
|
|
99
|
+
autoCompaction: agentResponseSchema.shape.autoCompaction,
|
|
100
|
+
compactionReserveTokens: agentResponseSchema.shape.compactionReserveTokens,
|
|
101
|
+
memoryInjectionEnabled: agentResponseSchema.shape.memoryInjectionEnabled,
|
|
102
|
+
tools: agentResponseSchema.shape.tools,
|
|
103
|
+
instructions: agentResponseSchema.shape.instructions,
|
|
104
|
+
metadata: agentResponseSchema.shape.metadata,
|
|
105
|
+
mcpConnectionIds: agentResponseSchema.shape.mcpConnectionIds,
|
|
107
106
|
})
|
|
108
107
|
.strip()
|
|
109
108
|
.refine(hasProviderModelPair, {
|
|
@@ -120,7 +119,7 @@ export const createAgentBodySchema = z
|
|
|
120
119
|
workspaceId: workspaceIdSchema.optional(),
|
|
121
120
|
workspaceTier: workspaceTierSchema.optional(),
|
|
122
121
|
autoCompaction: z.boolean().default(true),
|
|
123
|
-
compactionReserveTokens:
|
|
122
|
+
compactionReserveTokens: agentResponseSchema.shape.compactionReserveTokens.default(16_384),
|
|
124
123
|
memoryInjectionEnabled: z.boolean().default(false),
|
|
125
124
|
tools: agentToolsSchema.default([]),
|
|
126
125
|
instructions: agentInstructionsSchema.default(""),
|
|
@@ -147,7 +146,7 @@ export const updateAgentBodySchema = z
|
|
|
147
146
|
providerId: providerIdSchema.nullable().optional(),
|
|
148
147
|
workspaceId: workspaceIdSchema.optional(),
|
|
149
148
|
autoCompaction: z.boolean().optional(),
|
|
150
|
-
compactionReserveTokens:
|
|
149
|
+
compactionReserveTokens: agentResponseSchema.shape.compactionReserveTokens.optional(),
|
|
151
150
|
memoryInjectionEnabled: z.boolean().optional(),
|
|
152
151
|
tools: agentToolsSchema.optional(),
|
|
153
152
|
instructions: agentInstructionsSchema.optional(),
|