@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.
Files changed (46) hide show
  1. package/dist/chat-transport.d.ts +6 -0
  2. package/dist/chat-transport.js +15 -8
  3. package/dist/contracts/api.d.ts +0 -245
  4. package/dist/contracts/api.js +0 -121
  5. package/dist/contracts/entities/agent-tools.d.ts +0 -4
  6. package/dist/contracts/entities/agent-tools.js +0 -15
  7. package/dist/contracts/entities/agents.d.ts +2 -109
  8. package/dist/contracts/entities/agents.js +15 -16
  9. package/dist/contracts/entities/artifacts.d.ts +0 -30
  10. package/dist/contracts/entities/artifacts.js +1 -36
  11. package/dist/contracts/entities/attribution.d.ts +0 -2
  12. package/dist/contracts/entities/chat-connections.d.ts +0 -3
  13. package/dist/contracts/entities/chat-connections.js +0 -3
  14. package/dist/contracts/entities/chat.d.ts +1 -17
  15. package/dist/contracts/entities/chat.js +4 -13
  16. package/dist/contracts/entities/mcp-connections.d.ts +0 -168
  17. package/dist/contracts/entities/mcp-connections.js +1 -171
  18. package/dist/contracts/entities/memories.d.ts +0 -8
  19. package/dist/contracts/entities/memories.js +2 -15
  20. package/dist/contracts/entities/merchant.d.ts +0 -19
  21. package/dist/contracts/entities/merchant.js +1 -26
  22. package/dist/contracts/entities/prompts.d.ts +1 -14
  23. package/dist/contracts/entities/prompts.js +2 -3
  24. package/dist/contracts/entities/providers.d.ts +0 -28
  25. package/dist/contracts/entities/providers.js +1 -24
  26. package/dist/contracts/entities/sessions.d.ts +0 -9
  27. package/dist/contracts/entities/sessions.js +4 -21
  28. package/dist/contracts/entities/skills.d.ts +0 -52
  29. package/dist/contracts/entities/skills.js +2 -60
  30. package/dist/contracts/entities/tasks.d.ts +1 -168
  31. package/dist/contracts/entities/tasks.js +5 -14
  32. package/dist/contracts/entities/tenants.d.ts +0 -6
  33. package/dist/contracts/entities/usage.d.ts +0 -1
  34. package/dist/contracts/entities/workspaces.d.ts +0 -6
  35. package/dist/contracts/entities/workspaces.js +2 -14
  36. package/dist/contracts/ids.d.ts +1 -68
  37. package/dist/contracts/ids.js +2 -91
  38. package/dist/contracts/index.d.ts +3 -3
  39. package/dist/contracts/index.js +3 -3
  40. package/dist/contracts/limitations.d.ts +8 -81
  41. package/dist/contracts/limitations.js +8 -82
  42. package/dist/direct-chat-transport.d.ts +6 -0
  43. package/dist/direct-chat-transport.js +19 -2
  44. package/dist/generation.js +20 -4
  45. package/dist/types.d.ts +6 -0
  46. package/package.json +6 -6
@@ -41,7 +41,6 @@ export declare const taskScheduleInputSchema: z.ZodDiscriminatedUnion<[z.ZodObje
41
41
  timezone: z.ZodDefault<z.ZodString>;
42
42
  }, z.core.$strict>;
43
43
  }, z.core.$strict>], "kind">;
44
- export type TaskScheduleInput = z.infer<typeof taskScheduleInputSchema>;
45
44
  /**
46
45
  * `POST /v1/tasks` — schedule present = scheduled task; absent = on-demand.
47
46
  * `submit: true` enqueues a run immediately. An optional `idempotencyKey`
@@ -117,7 +116,7 @@ export declare const taskRunStatusSchema: z.ZodEnum<{
117
116
  running: "running";
118
117
  succeeded: "succeeded";
119
118
  }>;
120
- export declare const taskSchema: z.ZodObject<{
119
+ export declare const taskResponseSchema: z.ZodObject<{
121
120
  id: z.ZodString;
122
121
  tenantId: z.ZodString;
123
122
  agentId: z.ZodString;
@@ -258,169 +257,10 @@ export declare const tasksListResponseSchema: z.ZodObject<{
258
257
  }, z.core.$strip>>;
259
258
  nextCursor: z.ZodNullable<z.ZodString>;
260
259
  }, z.core.$strip>;
261
- export declare const tasksListQuerySchema: z.ZodObject<{
262
- agentId: z.ZodOptional<z.ZodString>;
263
- userId: z.ZodOptional<z.ZodString>;
264
- cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
265
- }, z.core.$strict>;
266
- export declare const taskResponseSchema: z.ZodObject<{
267
- id: z.ZodString;
268
- tenantId: z.ZodString;
269
- agentId: z.ZodString;
270
- name: z.ZodString;
271
- prompt: z.ZodString;
272
- schedule: z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
273
- kind: z.ZodLiteral<"once">;
274
- config: z.ZodObject<{
275
- at: z.ZodISODateTime;
276
- }, z.core.$strip>;
277
- }, z.core.$strip>, z.ZodObject<{
278
- kind: z.ZodLiteral<"interval">;
279
- config: z.ZodObject<{
280
- everyMs: z.ZodNumber;
281
- }, z.core.$strip>;
282
- }, z.core.$strip>, z.ZodObject<{
283
- kind: z.ZodLiteral<"cron">;
284
- config: z.ZodObject<{
285
- expression: z.ZodString;
286
- staggerMs: z.ZodOptional<z.ZodNumber>;
287
- timezone: z.ZodDefault<z.ZodString>;
288
- }, z.core.$strip>;
289
- }, z.core.$strip>], "kind">>;
290
- enabled: z.ZodBoolean;
291
- activeRunId: z.ZodNullable<z.ZodString>;
292
- latestRunId: z.ZodNullable<z.ZodString>;
293
- userId: z.ZodString;
294
- metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
295
- deletedAt: z.ZodNullable<z.ZodISODateTime>;
296
- createdAt: z.ZodISODateTime;
297
- updatedAt: z.ZodISODateTime;
298
- nextFireAt: z.ZodNullable<z.ZodISODateTime>;
299
- }, z.core.$strip>;
300
260
  /**
301
261
  * Task run record. `userId`/`metadata` are copied from the task at enqueue
302
262
  * and carried onto the run's Session and usage facts.
303
263
  */
304
- export declare const taskRunSchema: z.ZodObject<{
305
- id: z.ZodString;
306
- taskId: z.ZodString;
307
- tenantId: z.ZodString;
308
- agentId: z.ZodString;
309
- agentConfig: z.ZodObject<{
310
- approvalInChat: z.ZodDefault<z.ZodObject<{
311
- default: z.ZodEnum<{
312
- auto: "auto";
313
- deny: "deny";
314
- full: "full";
315
- manual: "manual";
316
- }>;
317
- overrides: z.ZodDefault<z.ZodArray<z.ZodObject<{
318
- tool: z.ZodDiscriminatedUnion<[z.ZodObject<{
319
- type: z.ZodLiteral<"builtin">;
320
- name: z.ZodEnum<{
321
- activate_skill: "activate_skill";
322
- bash: "bash";
323
- delete_memory: "delete_memory";
324
- edit: "edit";
325
- get_memory: "get_memory";
326
- glob: "glob";
327
- grep: "grep";
328
- publish_artifacts: "publish_artifacts";
329
- read: "read";
330
- save_memory: "save_memory";
331
- search_memories: "search_memories";
332
- update_memory: "update_memory";
333
- write: "write";
334
- write_todos: "write_todos";
335
- }>;
336
- }, z.core.$strict>, z.ZodObject<{
337
- type: z.ZodLiteral<"mcp">;
338
- connectionId: z.ZodString;
339
- name: z.ZodString;
340
- }, z.core.$strict>], "type">;
341
- decision: z.ZodEnum<{
342
- auto: "auto";
343
- deny: "deny";
344
- full: "full";
345
- manual: "manual";
346
- }>;
347
- }, z.core.$strict>>>;
348
- }, z.core.$strict>>;
349
- approvalInTasks: z.ZodDefault<z.ZodObject<{
350
- default: z.ZodEnum<{
351
- auto: "auto";
352
- deny: "deny";
353
- full: "full";
354
- manual: "manual";
355
- }>;
356
- overrides: z.ZodDefault<z.ZodArray<z.ZodObject<{
357
- tool: z.ZodDiscriminatedUnion<[z.ZodObject<{
358
- type: z.ZodLiteral<"builtin">;
359
- name: z.ZodEnum<{
360
- activate_skill: "activate_skill";
361
- bash: "bash";
362
- delete_memory: "delete_memory";
363
- edit: "edit";
364
- get_memory: "get_memory";
365
- glob: "glob";
366
- grep: "grep";
367
- publish_artifacts: "publish_artifacts";
368
- read: "read";
369
- save_memory: "save_memory";
370
- search_memories: "search_memories";
371
- update_memory: "update_memory";
372
- write: "write";
373
- write_todos: "write_todos";
374
- }>;
375
- }, z.core.$strict>, z.ZodObject<{
376
- type: z.ZodLiteral<"mcp">;
377
- connectionId: z.ZodString;
378
- name: z.ZodString;
379
- }, z.core.$strict>], "type">;
380
- decision: z.ZodEnum<{
381
- auto: "auto";
382
- deny: "deny";
383
- full: "full";
384
- manual: "manual";
385
- }>;
386
- }, z.core.$strict>>>;
387
- }, z.core.$strict>>;
388
- name: z.ZodString;
389
- model: z.ZodNullable<z.ZodString>;
390
- thinkingLevel: z.ZodNullable<z.ZodString>;
391
- providerId: z.ZodNullable<z.ZodString>;
392
- autoCompaction: z.ZodBoolean;
393
- compactionReserveTokens: z.ZodNumber;
394
- memoryInjectionEnabled: z.ZodBoolean;
395
- tools: z.ZodArray<z.ZodEnum<{
396
- memory: "memory";
397
- workspace: "workspace";
398
- write_todos: "write_todos";
399
- }>>;
400
- instructions: z.ZodString;
401
- metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
402
- mcpConnectionIds: z.ZodArray<z.ZodString>;
403
- }, z.core.$strip>;
404
- sessionId: z.ZodNullable<z.ZodString>;
405
- turnId: z.ZodNullable<z.ZodString>;
406
- status: z.ZodEnum<{
407
- blocked: "blocked";
408
- canceled: "canceled";
409
- failed: "failed";
410
- queued: "queued";
411
- running: "running";
412
- succeeded: "succeeded";
413
- }>;
414
- error: z.ZodNullable<z.ZodString>;
415
- userId: z.ZodString;
416
- metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
417
- startedAt: z.ZodNullable<z.ZodISODateTime>;
418
- finishedAt: z.ZodNullable<z.ZodISODateTime>;
419
- cancelRequestedAt: z.ZodNullable<z.ZodISODateTime>;
420
- canceledAt: z.ZodNullable<z.ZodISODateTime>;
421
- createdAt: z.ZodISODateTime;
422
- updatedAt: z.ZodISODateTime;
423
- }, z.core.$strip>;
424
264
  export declare const taskRunResponseSchema: z.ZodObject<{
425
265
  id: z.ZodString;
426
266
  taskId: z.ZodString;
@@ -735,15 +575,9 @@ export declare const taskRunMessagesResponseSchema: z.ZodObject<{
735
575
  succeeded: "succeeded";
736
576
  }>;
737
577
  }, z.core.$strip>;
738
- export type Task = z.infer<typeof taskSchema>;
739
- export type TaskListItem = z.infer<typeof taskListItemSchema>;
740
- export type TaskLatestRun = z.infer<typeof taskLatestRunSchema>;
741
578
  export type TasksListResponse = z.infer<typeof tasksListResponseSchema>;
742
- export type TasksListQuery = z.infer<typeof tasksListQuerySchema>;
743
579
  export type TaskResponse = z.infer<typeof taskResponseSchema>;
744
- export type TaskRun = z.infer<typeof taskRunSchema>;
745
580
  export type TaskRunResponse = z.infer<typeof taskRunResponseSchema>;
746
- export type TaskRunStatus = z.infer<typeof taskRunStatusSchema>;
747
581
  export type TaskRunsListResponse = z.infer<typeof taskRunsListResponseSchema>;
748
582
  export type CreateTaskBody = z.input<typeof createTaskBodySchema>;
749
583
  export type UpdateTaskBody = z.infer<typeof updateTaskBodySchema>;
@@ -751,4 +585,3 @@ export type CreateTaskRunBody = z.infer<typeof createTaskRunBodySchema>;
751
585
  export type CreateTaskResponse = z.infer<typeof createTaskResponseSchema>;
752
586
  export type CreateTaskRunResponse = z.infer<typeof createTaskRunResponseSchema>;
753
587
  export type TaskRunMessagesResponse = z.infer<typeof taskRunMessagesResponseSchema>;
754
- export type TaskScheduleKind = z.infer<typeof taskScheduleKindSchema>;
@@ -166,7 +166,7 @@ const taskScheduleResponseSchema = z.discriminatedUnion("kind", [
166
166
  z.object({ kind: z.literal("cron"), config: taskCronConfigSchema.strip() }),
167
167
  ]);
168
168
  // The task record — pure definition; state lives in its runs.
169
- export const taskSchema = z
169
+ export const taskResponseSchema = z
170
170
  .object({
171
171
  id: taskIdSchema,
172
172
  tenantId: tenantIdSchema,
@@ -193,23 +193,15 @@ export const taskLatestRunSchema = z
193
193
  finishedAt: z.iso.datetime({ offset: true }).nullable(),
194
194
  })
195
195
  .strip();
196
- export const taskListItemSchema = taskSchema.extend({
196
+ export const taskListItemSchema = taskResponseSchema.extend({
197
197
  latestRun: taskLatestRunSchema.nullable(),
198
198
  });
199
199
  export const tasksListResponseSchema = paginatedResponseSchema(taskListItemSchema);
200
- export const tasksListQuerySchema = z
201
- .object({
202
- agentId: agentIdSchema.optional(),
203
- userId: z.string().optional(),
204
- cursor: z.string().nullable().optional(),
205
- })
206
- .strict();
207
- export const taskResponseSchema = taskSchema;
208
200
  /**
209
201
  * Task run record. `userId`/`metadata` are copied from the task at enqueue
210
202
  * and carried onto the run's Session and usage facts.
211
203
  */
212
- export const taskRunSchema = z
204
+ export const taskRunResponseSchema = z
213
205
  .object({
214
206
  id: taskRunIdSchema,
215
207
  taskId: taskIdSchema,
@@ -230,12 +222,11 @@ export const taskRunSchema = z
230
222
  updatedAt: z.iso.datetime({ offset: true }),
231
223
  })
232
224
  .strip();
233
- export const taskRunResponseSchema = taskRunSchema;
234
- export const taskRunsListResponseSchema = paginatedResponseSchema(taskRunSchema);
225
+ export const taskRunsListResponseSchema = paginatedResponseSchema(taskRunResponseSchema);
235
226
  // `POST /v1/tasks` response — the created task + optional queued run id.
236
227
  export const createTaskResponseSchema = z
237
228
  .object({
238
- task: taskSchema,
229
+ task: taskResponseSchema,
239
230
  runId: taskRunIdSchema.nullable(),
240
231
  })
241
232
  .strip();
@@ -37,7 +37,6 @@ export declare const tenantDeletionSchema: z.ZodObject<{
37
37
  deletesAt: z.ZodISODateTime;
38
38
  requestedAt: z.ZodISODateTime;
39
39
  }, z.core.$strict>;
40
- export type TenantDeletion = z.infer<typeof tenantDeletionSchema>;
41
40
  /**
42
41
  * Quota — `GET/PATCH /v1/tenant` carries the tenant's self-set quota.
43
42
  * `null` means unlimited (no quota row).
@@ -77,10 +76,5 @@ export declare const updateTenantSettingsBodySchema: z.ZodObject<{
77
76
  resetDay: z.ZodNumber;
78
77
  }, z.core.$strict>>>;
79
78
  }, z.core.$strict>;
80
- export type Tenant = z.infer<typeof tenantSchema>;
81
- export type SubscriptionStatus = z.infer<typeof subscriptionStatusSchema>;
82
- export type TenantResponse = z.infer<typeof tenantResponseSchema>;
83
- export type Quota = z.infer<typeof quotaSchema>;
84
- export type TenantSettings = z.infer<typeof tenantSettingsSchema>;
85
79
  export type TenantSettingsResponse = z.infer<typeof tenantSettingsResponseSchema>;
86
80
  export type UpdateTenantSettingsBody = z.infer<typeof updateTenantSettingsBodySchema>;
@@ -236,7 +236,6 @@ export declare function usageOverviewResponseSchemaForQuery(query?: Partial<Usag
236
236
  }, z.core.$strip>>;
237
237
  activeAgentCount: z.ZodNumber;
238
238
  }, z.core.$strip>;
239
- export type UsageGroupBy = z.infer<typeof usageGroupBySchema>;
240
239
  export type UsageQuery = z.infer<typeof usageQuerySchema>;
241
240
  export type UsageBucket = z.infer<typeof usageBucketSchema>;
242
241
  export type UsageTotals = z.infer<typeof usageTotalsSchema>;
@@ -62,11 +62,6 @@ export declare const updateWorkspaceBodySchema: z.ZodObject<{
62
62
  mode: z.ZodLiteral<"offline">;
63
63
  }, z.core.$strict>], "mode">>;
64
64
  }, z.core.$strict>;
65
- export declare const workspaceListQuerySchema: z.ZodObject<{
66
- cursor: z.ZodOptional<z.ZodString>;
67
- limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
68
- userId: z.ZodOptional<z.ZodString>;
69
- }, z.core.$strict>;
70
65
  export declare const workspacesListResponseSchema: z.ZodObject<{
71
66
  data: z.ZodArray<z.ZodObject<{
72
67
  id: z.ZodString;
@@ -96,5 +91,4 @@ export type WorkspaceTier = z.infer<typeof workspaceTierSchema>;
96
91
  export type WorkspaceNetworkPolicy = z.infer<typeof workspaceNetworkPolicySchema>;
97
92
  export type CreateWorkspaceBody = z.input<typeof createWorkspaceBodySchema>;
98
93
  export type UpdateWorkspaceBody = z.infer<typeof updateWorkspaceBodySchema>;
99
- export type WorkspaceListQuery = z.infer<typeof workspaceListQuerySchema>;
100
94
  export type WorkspacesListResponse = z.infer<typeof workspacesListResponseSchema>;
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
- import { cursorSchema, paginatedResponseSchema } from "../api.js";
2
+ import { paginatedResponseSchema } from "../api.js";
3
3
  import { tenantIdSchema, workspaceIdSchema } from "../ids.js";
4
- import { DEFAULT_WORKSPACES_LIST_LIMIT, MAX_WORKSPACE_NAME_LENGTH, MAX_WORKSPACES_LIST_LIMIT, } from "../limitations.js";
4
+ import { MAX_WORKSPACE_NAME_LENGTH } from "../limitations.js";
5
5
  import { hasObjectKeys } from "../utils.js";
6
6
  import { metadataSchema, userIdSchema } from "./attribution.js";
7
7
  export const workspaceNameSchema = z
@@ -57,16 +57,4 @@ export const updateWorkspaceBodySchema = z
57
57
  })
58
58
  .strict()
59
59
  .refine(hasObjectKeys, { message: "At least one field is required." });
60
- export const workspaceListQuerySchema = z
61
- .object({
62
- cursor: cursorSchema.optional(),
63
- limit: z.coerce
64
- .number()
65
- .int()
66
- .min(1)
67
- .max(MAX_WORKSPACES_LIST_LIMIT)
68
- .default(DEFAULT_WORKSPACES_LIST_LIMIT),
69
- userId: userIdSchema.optional(),
70
- })
71
- .strict();
72
60
  export const workspacesListResponseSchema = paginatedResponseSchema(workspaceSchema);
@@ -1,61 +1,4 @@
1
1
  import { z } from "zod";
2
- export declare const ADMIN_AGENT_ID_PREFIX = "ag_adm";
3
- /** Creates a Tenant ID with a 16-character base62 body. */
4
- export declare const createTenantId: () => string;
5
- /**
6
- * Creates an Agent ID outside the reserved administrator prefix.
7
- */
8
- export declare const createAgentId: () => string;
9
- /**
10
- * Creates an Agent ID with the reserved administrator prefix.
11
- */
12
- export declare const mintAdminAgentId: () => string;
13
- /** Creates a Session ID with a 16-character base62 body. */
14
- export declare const createSessionId: () => string;
15
- /** Creates a Api Key ID with a 16-character base62 body. */
16
- export declare const createApiKeyId: () => string;
17
- /** Creates a Provider ID with a 16-character base62 body. */
18
- export declare const createProviderId: () => string;
19
- /** Creates a Mcp Connection ID with a 16-character base62 body. */
20
- export declare const createMcpConnectionId: () => string;
21
- /** Creates a Workspace ID with a 16-character base62 body. */
22
- export declare const createWorkspaceId: () => string;
23
- /** Creates a Artifact ID with a 16-character base62 body. */
24
- export declare const createArtifactId: () => string;
25
- /** Creates a Task ID with a 16-character base62 body. */
26
- export declare const createTaskId: () => string;
27
- /** Creates a Task Run ID with a 16-character base62 body. */
28
- export declare const createTaskRunId: () => string;
29
- /** Creates a Memory ID with a 16-character base62 body. */
30
- export declare const createMemoryId: () => string;
31
- /** Creates a Prompt ID with a 16-character base62 body. */
32
- export declare const createPromptId: () => string;
33
- /** Creates a Request ID with a 16-character base62 body. */
34
- export declare const createRequestId: () => string;
35
- /** Creates a Checkout Attempt ID with a 16-character base62 body. */
36
- export declare const createCheckoutAttemptId: () => string;
37
- /**
38
- * Creates a Skill ID with a 16-character base62 body.
39
- */
40
- export declare const createSkillId: () => string;
41
- /**
42
- * API keys — `ba_` + 40 base62 chars (~230 bits entropy). The full token is
43
- * shown once at creation; only the sha256 hash and a 2-char display fragment
44
- * are stored. (docs/adr/0004-unified-v1-dual-credential-auth.md)
45
- */
46
- export declare const API_KEY_TOKEN_PREFIX = "ba_";
47
- /**
48
- * Creates an API key token with a 40-character random base62 body.
49
- * @returns A ba_ token with 40 random base62 characters.
50
- */
51
- export declare function createApiKeyToken(): string;
52
- /**
53
- * The display fragment is `ba_` + the first 2 chars of the random body —
54
- * safe to store (~12 of ~230 bits revealed).
55
- * @param token - API key token with the ba_ prefix.
56
- * @returns The prefix and first two characters of the token body.
57
- */
58
- export declare function apiKeyFragmentFromToken(token: string): string;
59
2
  export declare const tenantIdSchema: z.ZodString;
60
3
  export declare const agentIdSchema: z.ZodString;
61
4
  /**
@@ -63,7 +6,6 @@ export declare const agentIdSchema: z.ZodString;
63
6
  */
64
7
  export declare const isAdminAgentId: (id: string) => boolean;
65
8
  export declare const sessionIdSchema: z.ZodString;
66
- export declare const apiKeyIdSchema: z.ZodString;
67
9
  export declare const providerIdSchema: z.ZodString;
68
10
  export declare const mcpConnectionIdSchema: z.ZodString;
69
11
  export declare const merchantConnectionIdSchema: z.ZodString;
@@ -74,20 +16,11 @@ export declare const taskIdSchema: z.ZodString;
74
16
  export declare const taskRunIdSchema: z.ZodString;
75
17
  export declare const memoryIdSchema: z.ZodString;
76
18
  export declare const promptIdSchema: z.ZodString;
77
- export declare const requestIdSchema: z.ZodString;
78
- export declare const checkoutAttemptIdSchema: z.ZodString;
79
19
  export declare const turnIdSchema: z.ZodString;
80
20
  export declare const functionCallIdSchema: z.ZodString;
81
21
  export declare const skillIdSchema: z.ZodString;
82
- /**
83
- * API key token + digest helpers. The digest is sha256 hex (64 chars); the
84
- * fragment is `ba_` + 2 base62 chars. Both stored columns are format-checked
85
- * in the migration.
86
- */
22
+ /** API keys are `ba_` + 40 base62 characters. */
87
23
  export declare const apiKeyTokenSchema: z.ZodString;
88
- export declare const apiKeyDigestSchema: z.ZodString;
89
- export declare const apiKeyFragmentSchema: z.ZodString;
90
24
  export declare const providerKeyFragmentSchema: z.ZodString;
91
- export type TurnId = z.infer<typeof turnIdSchema>;
92
25
  export declare const chatConnectionIdSchema: z.ZodString;
93
26
  export declare const chatDeliveryIdSchema: z.ZodString;
@@ -1,85 +1,5 @@
1
- import { customAlphabet } from "nanoid";
2
1
  import { z } from "zod";
3
- /**
4
- * Base62 — the alphabet every platform id body uses (16 chars for ids,
5
- * 40 chars for API key bodies). Matches the regex check constraints in every
6
- * migration: `^<prefix>_[0-9A-Za-z]{16}$`.
7
- */
8
- const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
9
- export const ADMIN_AGENT_ID_PREFIX = "ag_adm";
10
- const createNanoId16 = customAlphabet(BASE62, 16);
11
- const createNanoId13 = customAlphabet(BASE62, 13);
12
- const createAgentIdFirstChar = customAlphabet(BASE62.replace("a", ""), 1);
13
- const createNanoId15 = customAlphabet(BASE62, 15);
14
- const createNanoId40 = customAlphabet(BASE62, 40);
15
- /**
16
- * Creates a generator for prefixed IDs with a 16-character base62 body.
17
- */
18
- const platformId = (prefix) => () => `${prefix}_${createNanoId16()}`;
19
- /** Creates a Tenant ID with a 16-character base62 body. */
20
- export const createTenantId = platformId("ten");
21
- /**
22
- * Creates an Agent ID outside the reserved administrator prefix.
23
- */
24
- export const createAgentId = () => `ag_${createAgentIdFirstChar()}${createNanoId15()}`;
25
- /**
26
- * Creates an Agent ID with the reserved administrator prefix.
27
- */
28
- export const mintAdminAgentId = () => `${ADMIN_AGENT_ID_PREFIX}${createNanoId13()}`;
29
- /** Creates a Session ID with a 16-character base62 body. */
30
- export const createSessionId = platformId("ss");
31
- /** Creates a Api Key ID with a 16-character base62 body. */
32
- export const createApiKeyId = platformId("ak");
33
- /** Creates a Provider ID with a 16-character base62 body. */
34
- export const createProviderId = platformId("prv");
35
- /** Creates a Mcp Connection ID with a 16-character base62 body. */
36
- export const createMcpConnectionId = platformId("mcp");
37
- /** Creates a Workspace ID with a 16-character base62 body. */
38
- export const createWorkspaceId = platformId("ws");
39
- /** Creates a Artifact ID with a 16-character base62 body. */
40
- export const createArtifactId = platformId("at");
41
- /** Creates a Task ID with a 16-character base62 body. */
42
- export const createTaskId = platformId("tk");
43
- /** Creates a Task Run ID with a 16-character base62 body. */
44
- export const createTaskRunId = platformId("tr");
45
- /** Creates a Memory ID with a 16-character base62 body. */
46
- export const createMemoryId = platformId("mem");
47
- /** Creates a Prompt ID with a 16-character base62 body. */
48
- export const createPromptId = platformId("prompt");
49
- /** Creates a Request ID with a 16-character base62 body. */
50
- export const createRequestId = platformId("req");
51
- /** Creates a Checkout Attempt ID with a 16-character base62 body. */
52
- export const createCheckoutAttemptId = platformId("ca");
53
- /**
54
- * Creates a Skill ID with a 16-character base62 body.
55
- */
56
- export const createSkillId = () => `skill_${createNanoId16()}`;
57
- /**
58
- * API keys — `ba_` + 40 base62 chars (~230 bits entropy). The full token is
59
- * shown once at creation; only the sha256 hash and a 2-char display fragment
60
- * are stored. (docs/adr/0004-unified-v1-dual-credential-auth.md)
61
- */
62
- export const API_KEY_TOKEN_PREFIX = "ba_";
63
- /**
64
- * Creates an API key token with a 40-character random base62 body.
65
- * @returns A ba_ token with 40 random base62 characters.
66
- */
67
- export function createApiKeyToken() {
68
- return `${API_KEY_TOKEN_PREFIX}${createNanoId40()}`;
69
- }
70
- /**
71
- * The display fragment is `ba_` + the first 2 chars of the random body —
72
- * safe to store (~12 of ~230 bits revealed).
73
- * @param token - API key token with the ba_ prefix.
74
- * @returns The prefix and first two characters of the token body.
75
- */
76
- export function apiKeyFragmentFromToken(token) {
77
- if (!token.startsWith(API_KEY_TOKEN_PREFIX)) {
78
- throw new Error(`API key token must start with ${API_KEY_TOKEN_PREFIX}.`);
79
- }
80
- const body = token.slice(API_KEY_TOKEN_PREFIX.length);
81
- return `${API_KEY_TOKEN_PREFIX}${body.slice(0, 2)}`;
82
- }
2
+ const ADMIN_AGENT_ID_PREFIX = "ag_adm";
83
3
  // Schemas — one per id prefix, mirroring the migration check constraints.
84
4
  export const tenantIdSchema = z.string().regex(/^ten_[0-9A-Za-z]{16}$/);
85
5
  export const agentIdSchema = z.string().regex(/^ag_[0-9A-Za-z]{16}$/);
@@ -88,7 +8,6 @@ export const agentIdSchema = z.string().regex(/^ag_[0-9A-Za-z]{16}$/);
88
8
  */
89
9
  export const isAdminAgentId = (id) => id.startsWith(ADMIN_AGENT_ID_PREFIX) && z.validate(agentIdSchema, id);
90
10
  export const sessionIdSchema = z.string().regex(/^ss_[0-9A-Za-z]{16}$/);
91
- export const apiKeyIdSchema = z.string().regex(/^ak_[0-9A-Za-z]{16}$/);
92
11
  export const providerIdSchema = z.string().regex(/^prv_[0-9A-Za-z]{16}$/);
93
12
  export const mcpConnectionIdSchema = z.string().regex(/^mcp_[0-9A-Za-z]{16}$/);
94
13
  export const merchantConnectionIdSchema = z
@@ -103,19 +22,11 @@ export const taskIdSchema = z.string().regex(/^tk_[0-9A-Za-z]{16}$/);
103
22
  export const taskRunIdSchema = z.string().regex(/^tr_[0-9A-Za-z]{16}$/);
104
23
  export const memoryIdSchema = z.string().regex(/^mem_[0-9A-Za-z]{16}$/);
105
24
  export const promptIdSchema = z.string().regex(/^prompt_[0-9A-Za-z]{16}$/);
106
- export const requestIdSchema = z.string().regex(/^req_[0-9A-Za-z]{16}$/);
107
- export const checkoutAttemptIdSchema = z.string().regex(/^ca_[0-9A-Za-z]{16}$/);
108
25
  export const turnIdSchema = z.string().regex(/^turn_[0-9A-Za-z]{16}$/);
109
26
  export const functionCallIdSchema = z.string().regex(/^fc_[0-9A-Za-z]{16}$/);
110
27
  export const skillIdSchema = z.string().regex(/^skill_[0-9A-Za-z]{16}$/);
111
- /**
112
- * API key token + digest helpers. The digest is sha256 hex (64 chars); the
113
- * fragment is `ba_` + 2 base62 chars. Both stored columns are format-checked
114
- * in the migration.
115
- */
28
+ /** API keys are `ba_` + 40 base62 characters. */
116
29
  export const apiKeyTokenSchema = z.string().regex(/^ba_[0-9A-Za-z]{40}$/);
117
- export const apiKeyDigestSchema = z.string().regex(/^[0-9a-f]{64}$/);
118
- export const apiKeyFragmentSchema = z.string().regex(/^ba_[0-9A-Za-z]{2}$/);
119
30
  // Provider key fragment — last 4 chars of the secret, display-only.
120
31
  export const providerKeyFragmentSchema = z.string().min(1).max(4);
121
32
  export const chatConnectionIdSchema = z.string().regex(/^cc_[0-9A-Za-z]{16}$/);
@@ -3,7 +3,7 @@ export { receivedApiErrorResponseSchema } from "./api.ts";
3
3
  export type { ApprovalDecision, ApprovalPolicy, ToolExecutionReference, ToolReference, } from "./entities/agent-approval.ts";
4
4
  export { approvalDecisionSchema, approvalPolicySchema, toolExecutionReferenceSchema, toolReferenceSchema, } from "./entities/agent-approval.ts";
5
5
  export { chatFunctionNameSchema } from "./entities/agent-tools.ts";
6
- export { agentConfigSchema, agentResponseSchema, agentSchema, agentStatusSchema, agentsListQuerySchema, agentsResponseSchema, createAgentBodySchema, updateAgentBodySchema, } from "./entities/agents.ts";
6
+ export { agentConfigSchema, agentResponseSchema, agentStatusSchema, agentsListQuerySchema, agentsResponseSchema, createAgentBodySchema, updateAgentBodySchema, } from "./entities/agents.ts";
7
7
  export { artifactDownloadUrlResponseSchema, artifactListItemSchema, artifactsListResponseSchema, } from "./entities/artifacts.ts";
8
8
  export { attributionCreateInputSchema, metadataSchema, } from "./entities/attribution.ts";
9
9
  export type { ChatFunctionCallEvent, ChatFunctionDefinition, ChatFunctionDefinitions, ChatFunctionOutcome, ClaimChatFunctionBody, PromptVariables, ResolveChatFunctionBody, UsageSummary, } from "./entities/chat.ts";
@@ -12,7 +12,7 @@ export { chatConfigurationSchema, chatConnectionSchema, chatConnectionsResponseS
12
12
  export { approveMcpOauthAuthorizationBodySchema, createMcpConnectionBodySchema, mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, mcpConnectionAuthTypeSchema, mcpConnectionOauthConnectResponseSchema, mcpConnectionReconnectResultSchema, mcpConnectionResponseSchema, mcpConnectionStatusSchema, mcpConnectionsResponseSchema, mcpConnectionTestErrorCodeSchema, mcpConnectionTestResponseSchema, mcpOauthAuthorizationLaunchResponseSchema, reconnectMcpConnectionBodySchema, updateMcpAttachmentBodySchema, updateMcpConnectionBodySchema, } from "./entities/mcp-connections.ts";
13
13
  export { createMemoryBodySchema, memoriesListResponseSchema, memoryResponseSchema, memorySchema, updateMemoryBodySchema, } from "./entities/memories.ts";
14
14
  export { createMerchantConnectionBodySchema, merchantBindingResponseSchema, merchantBindingsResponseSchema, merchantConnectionResponseSchema, merchantConnectionSchema, merchantConnectionStatusSchema, merchantCustomerBindingSchema, merchantEnvironmentSchema, merchantGuardSchema, merchantProviderSchema, merchantUsageEventNextAction, merchantUsageEventNextActionSchema, merchantUsageEventSchema, merchantUsageEventStatusSchema, merchantUsageEventsResponseSchema, merchantUsageSummaryQuerySchema, merchantUsageSummaryResponseSchema, merchantUsageSummarySchema, merchantWorkflowIssueSchema, updateMerchantConnectionBodySchema, upsertMerchantBindingBodySchema, } from "./entities/merchant.ts";
15
- export { createPromptBodySchema, parsePromptVariables, promptResponseSchema, promptSchema, promptsListQuerySchema, promptsResponseSchema, promptTemplateSchema, renderPromptTemplate, updatePromptBodySchema, } from "./entities/prompts.ts";
15
+ export { createPromptBodySchema, parsePromptVariables, promptResponseSchema, promptsListQuerySchema, promptsResponseSchema, promptTemplateSchema, renderPromptTemplate, updatePromptBodySchema, } from "./entities/prompts.ts";
16
16
  export { createProviderBodySchema, providerListItemSchema, providerModelsResponseSchema, providerResponseSchema, providersResponseSchema, providerTypeSchema, thinkingLevelsResponseSchema, updateProviderBodySchema, } from "./entities/providers.ts";
17
17
  export type { ChatSteerConsumedEvent, SessionActivity, SessionInput, SessionInputResponse, SessionInputState, SessionInputsQuery, SessionInputsResponse, StopSessionBody, StopSessionResponse, SubmitSessionInputBody, } from "./entities/session-inputs.ts";
18
18
  export { chatSteerConsumedEventSchema, sessionActivitySchema, sessionInputRequestIdSchema, sessionInputResponseSchema, sessionInputSchema, sessionInputStateSchema, sessionInputsQuerySchema, sessionInputsResponseSchema, stopSessionBodySchema, stopSessionResponseSchema, submitSessionInputBodySchema, } from "./entities/session-inputs.ts";
@@ -21,7 +21,7 @@ export { continueToolApprovalsBodySchema, latestSessionListItemSchema, latestSes
21
21
  export { copySkillBodySchema, createSkillBodySchema, skillCopyResultsSchema, skillDetailSchema, skillsListResponseSchema, } from "./entities/skills.ts";
22
22
  export type { SpendingLimit, SpendingLimitResponse, SpendingLimitStopDetails, SpendingLimitStopEvent, UpdateSpendingLimitBody, } from "./entities/spending-limits.ts";
23
23
  export { nextSpendingLimitReset, spendingLimitPeriodSchema, spendingLimitResetIntervalSchema, spendingLimitResponseSchema, spendingLimitSchema, spendingLimitStopDetailsSchema, spendingLimitStopEventSchema, updateSpendingLimitBodySchema, } from "./entities/spending-limits.ts";
24
- export { createTaskBodySchema, createTaskResponseSchema, createTaskRunBodySchema, createTaskRunResponseSchema, taskCronConfigSchema, taskIntervalConfigSchema, taskListItemSchema, taskOnceConfigSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunSchema, taskRunStatusSchema, taskRunsListResponseSchema, taskScheduleInputSchema, taskScheduleKindSchema, taskSchema, tasksListResponseSchema, updateTaskBodySchema, } from "./entities/tasks.ts";
24
+ export { createTaskBodySchema, createTaskResponseSchema, createTaskRunBodySchema, createTaskRunResponseSchema, taskCronConfigSchema, taskIntervalConfigSchema, taskListItemSchema, taskOnceConfigSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunStatusSchema, taskRunsListResponseSchema, taskScheduleInputSchema, taskScheduleKindSchema, tasksListResponseSchema, updateTaskBodySchema, } from "./entities/tasks.ts";
25
25
  export { quotaSchema, subscriptionStatusSchema, tenantDeletionSchema, tenantResponseSchema, tenantSchema, tenantSettingsResponseSchema, updateTenantSettingsBodySchema, } from "./entities/tenants.ts";
26
26
  export type { SessionUsageQuery, SessionUsageResponse, UsageBucket, UsageOverviewQuery, UsageOverviewResponse, UsageResponse, UsageTotals, } from "./entities/usage.ts";
27
27
  export { sessionUsageQuerySchema, sessionUsageResponseSchema, usageOverviewQuerySchema, usageOverviewResponseSchema, usageResponseSchema, } from "./entities/usage.ts";
@@ -3,7 +3,7 @@
3
3
  export { receivedApiErrorResponseSchema } from "./api.js";
4
4
  export { approvalDecisionSchema, approvalPolicySchema, toolExecutionReferenceSchema, toolReferenceSchema, } from "./entities/agent-approval.js";
5
5
  export { chatFunctionNameSchema } from "./entities/agent-tools.js";
6
- export { agentConfigSchema, agentResponseSchema, agentSchema, agentStatusSchema, agentsListQuerySchema, agentsResponseSchema, createAgentBodySchema, updateAgentBodySchema, } from "./entities/agents.js";
6
+ export { agentConfigSchema, agentResponseSchema, agentStatusSchema, agentsListQuerySchema, agentsResponseSchema, createAgentBodySchema, updateAgentBodySchema, } from "./entities/agents.js";
7
7
  export { artifactDownloadUrlResponseSchema, artifactListItemSchema, artifactsListResponseSchema, } from "./entities/artifacts.js";
8
8
  export { attributionCreateInputSchema, metadataSchema, } from "./entities/attribution.js";
9
9
  export { blazingAgentsChatMessageMetadataSchema, chatFunctionCallEventSchema, chatFunctionDefinitionSchema, chatFunctionDefinitionsSchema, chatFunctionOutcomeSchema, chatModeSchema, chatRequestBodySchema, chatTriggerSchema, claimChatFunctionBodySchema, claimChatFunctionResponseSchema, generationRequestBodySchema, jsonSchemaShapeSchema, MAX_CHAT_FUNCTION_DEFINITIONS_BYTES, MAX_CHAT_FUNCTION_PAYLOAD_BYTES, MAX_CHAT_FUNCTIONS, promptVariablesSchema, resolveChatFunctionBodySchema, resolveChatFunctionResponseSchema, usageSummarySchema, } from "./entities/chat.js";
@@ -11,13 +11,13 @@ export { chatConfigurationSchema, chatConnectionSchema, chatConnectionsResponseS
11
11
  export { approveMcpOauthAuthorizationBodySchema, createMcpConnectionBodySchema, mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, mcpConnectionAuthTypeSchema, mcpConnectionOauthConnectResponseSchema, mcpConnectionReconnectResultSchema, mcpConnectionResponseSchema, mcpConnectionStatusSchema, mcpConnectionsResponseSchema, mcpConnectionTestErrorCodeSchema, mcpConnectionTestResponseSchema, mcpOauthAuthorizationLaunchResponseSchema, reconnectMcpConnectionBodySchema, updateMcpAttachmentBodySchema, updateMcpConnectionBodySchema, } from "./entities/mcp-connections.js";
12
12
  export { createMemoryBodySchema, memoriesListResponseSchema, memoryResponseSchema, memorySchema, updateMemoryBodySchema, } from "./entities/memories.js";
13
13
  export { createMerchantConnectionBodySchema, merchantBindingResponseSchema, merchantBindingsResponseSchema, merchantConnectionResponseSchema, merchantConnectionSchema, merchantConnectionStatusSchema, merchantCustomerBindingSchema, merchantEnvironmentSchema, merchantGuardSchema, merchantProviderSchema, merchantUsageEventNextAction, merchantUsageEventNextActionSchema, merchantUsageEventSchema, merchantUsageEventStatusSchema, merchantUsageEventsResponseSchema, merchantUsageSummaryQuerySchema, merchantUsageSummaryResponseSchema, merchantUsageSummarySchema, merchantWorkflowIssueSchema, updateMerchantConnectionBodySchema, upsertMerchantBindingBodySchema, } from "./entities/merchant.js";
14
- export { createPromptBodySchema, parsePromptVariables, promptResponseSchema, promptSchema, promptsListQuerySchema, promptsResponseSchema, promptTemplateSchema, renderPromptTemplate, updatePromptBodySchema, } from "./entities/prompts.js";
14
+ export { createPromptBodySchema, parsePromptVariables, promptResponseSchema, promptsListQuerySchema, promptsResponseSchema, promptTemplateSchema, renderPromptTemplate, updatePromptBodySchema, } from "./entities/prompts.js";
15
15
  export { createProviderBodySchema, providerListItemSchema, providerModelsResponseSchema, providerResponseSchema, providersResponseSchema, providerTypeSchema, thinkingLevelsResponseSchema, updateProviderBodySchema, } from "./entities/providers.js";
16
16
  export { chatSteerConsumedEventSchema, sessionActivitySchema, sessionInputRequestIdSchema, sessionInputResponseSchema, sessionInputSchema, sessionInputStateSchema, sessionInputsQuerySchema, sessionInputsResponseSchema, stopSessionBodySchema, stopSessionResponseSchema, submitSessionInputBodySchema, } from "./entities/session-inputs.js";
17
17
  export { continueToolApprovalsBodySchema, latestSessionListItemSchema, latestSessionsListResponseSchema, sessionForkedFromSchema, sessionListItemSchema, sessionMessageSchema, sessionMessagesResponseSchema, sessionResponseSchema, sessionsListResponseSchema, toolApprovalContinuationStateSchema, toolApprovalDecisionSchema, toolApprovalStateSchema, toolApprovalsResponseSchema, } from "./entities/sessions.js";
18
18
  export { copySkillBodySchema, createSkillBodySchema, skillCopyResultsSchema, skillDetailSchema, skillsListResponseSchema, } from "./entities/skills.js";
19
19
  export { nextSpendingLimitReset, spendingLimitPeriodSchema, spendingLimitResetIntervalSchema, spendingLimitResponseSchema, spendingLimitSchema, spendingLimitStopDetailsSchema, spendingLimitStopEventSchema, updateSpendingLimitBodySchema, } from "./entities/spending-limits.js";
20
- export { createTaskBodySchema, createTaskResponseSchema, createTaskRunBodySchema, createTaskRunResponseSchema, taskCronConfigSchema, taskIntervalConfigSchema, taskListItemSchema, taskOnceConfigSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunSchema, taskRunStatusSchema, taskRunsListResponseSchema, taskScheduleInputSchema, taskScheduleKindSchema, taskSchema, tasksListResponseSchema, updateTaskBodySchema, } from "./entities/tasks.js";
20
+ export { createTaskBodySchema, createTaskResponseSchema, createTaskRunBodySchema, createTaskRunResponseSchema, taskCronConfigSchema, taskIntervalConfigSchema, taskListItemSchema, taskOnceConfigSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunStatusSchema, taskRunsListResponseSchema, taskScheduleInputSchema, taskScheduleKindSchema, tasksListResponseSchema, updateTaskBodySchema, } from "./entities/tasks.js";
21
21
  export { quotaSchema, subscriptionStatusSchema, tenantDeletionSchema, tenantResponseSchema, tenantSchema, tenantSettingsResponseSchema, updateTenantSettingsBodySchema, } from "./entities/tenants.js";
22
22
  export { sessionUsageQuerySchema, sessionUsageResponseSchema, usageOverviewQuerySchema, usageOverviewResponseSchema, usageResponseSchema, } from "./entities/usage.js";
23
23
  export { createWorkspaceBodySchema, updateWorkspaceBodySchema, workspaceSchema, workspacesListResponseSchema, workspaceTierSchema, } from "./entities/workspaces.js";