@blazingagents/sdk 0.14.0 → 0.16.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 (49) hide show
  1. package/README.md +5 -231
  2. package/dist/approvals.d.ts +15 -0
  3. package/dist/approvals.js +20 -0
  4. package/dist/chat-transport.js +9 -2
  5. package/dist/client.d.ts +8 -1
  6. package/dist/client.js +41 -1
  7. package/dist/contracts/api.d.ts +9 -9
  8. package/dist/contracts/api.js +3 -3
  9. package/dist/contracts/entities/agent-approval.d.ts +32 -0
  10. package/dist/contracts/entities/agent-approval.js +12 -1
  11. package/dist/contracts/entities/agent-tools.d.ts +6 -0
  12. package/dist/contracts/entities/agent-tools.js +13 -0
  13. package/dist/contracts/entities/agents.d.ts +4 -1
  14. package/dist/contracts/entities/agents.js +9 -6
  15. package/dist/contracts/entities/chat.d.ts +95 -12
  16. package/dist/contracts/entities/chat.js +105 -36
  17. package/dist/contracts/entities/prompts.d.ts +9 -1
  18. package/dist/contracts/entities/prompts.js +14 -4
  19. package/dist/contracts/entities/sessions.d.ts +6 -0
  20. package/dist/contracts/entities/sessions.js +2 -2
  21. package/dist/contracts/entities/tasks.d.ts +4 -6
  22. package/dist/contracts/entities/tasks.js +4 -6
  23. package/dist/contracts/entities/usage.d.ts +18 -0
  24. package/dist/contracts/entities/usage.js +28 -0
  25. package/dist/contracts/ids.d.ts +1 -0
  26. package/dist/contracts/ids.js +1 -0
  27. package/dist/contracts/index.d.ts +11 -10
  28. package/dist/contracts/index.js +8 -7
  29. package/dist/contracts/limitations.d.ts +4 -4
  30. package/dist/contracts/limitations.js +4 -4
  31. package/dist/direct-chat-transport.d.ts +3 -0
  32. package/dist/direct-chat-transport.js +20 -22
  33. package/dist/functions.d.ts +38 -0
  34. package/dist/functions.js +299 -0
  35. package/dist/generation.d.ts +7 -1
  36. package/dist/generation.js +64 -12
  37. package/dist/http.js +3 -0
  38. package/dist/index.d.ts +6 -4
  39. package/dist/index.js +1 -0
  40. package/dist/relay.d.ts +11 -4
  41. package/dist/relay.js +41 -1
  42. package/dist/resources/agents.d.ts +0 -6
  43. package/dist/resources/agents.js +2 -6
  44. package/dist/resources/prompts.d.ts +0 -4
  45. package/dist/resources/prompts.js +2 -6
  46. package/dist/resources/sessions.js +4 -2
  47. package/dist/resources/usage.js +9 -1
  48. package/dist/types.d.ts +39 -1
  49. package/package.json +8 -6
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { cursorSchema, paginatedResponseSchema } from "../api.js";
3
3
  import { agentIdSchema, mcpConnectionIdSchema, providerIdSchema, tenantIdSchema, workspaceIdSchema, } from "../ids.js";
4
- import { DEFAULT_AGENT_VERSIONS_LIST_LIMIT, MAX_AGENT_INSTRUCTIONS_LENGTH, MAX_AGENT_NAME_LENGTH, MAX_AGENT_VERSIONS_LIST_LIMIT, MAX_MCP_CONNECTIONS_PER_AGENT, } from "../limitations.js";
4
+ import { DEFAULT_AGENT_VERSIONS_LIST_LIMIT, DEFAULT_AGENTS_LIST_LIMIT, MAX_AGENT_INSTRUCTIONS_LENGTH, MAX_AGENT_NAME_LENGTH, MAX_AGENT_VERSIONS_LIST_LIMIT, MAX_AGENTS_LIST_LIMIT, MAX_MCP_CONNECTIONS_PER_AGENT, } from "../limitations.js";
5
5
  import { atLeastOneFieldMessage, hasObjectKeys, hasUniqueValues, } from "../utils.js";
6
6
  import { approvalPolicySchema } from "./agent-approval.js";
7
7
  import { agentToolGroupIds } from "./agent-tools.js";
@@ -77,14 +77,17 @@ export const agentSchema = z
77
77
  message: providerModelPairMessage,
78
78
  path: ["providerId"],
79
79
  });
80
- export const agentsResponseSchema = z
81
- .object({
82
- agents: z.array(agentSchema),
83
- })
84
- .strip();
80
+ export const agentsResponseSchema = paginatedResponseSchema(agentSchema);
85
81
  export const agentResponseSchema = agentSchema;
86
82
  export const agentsListQuerySchema = z
87
83
  .object({
84
+ cursor: cursorSchema.optional(),
85
+ limit: z.coerce
86
+ .number()
87
+ .int()
88
+ .min(1)
89
+ .max(MAX_AGENTS_LIST_LIMIT)
90
+ .default(DEFAULT_AGENTS_LIST_LIMIT),
88
91
  userId: userIdSchema.optional(),
89
92
  workspaceId: workspaceIdSchema.optional(),
90
93
  })
@@ -97,6 +97,75 @@ type ExclusivePromptInput<Literal extends object> = (Literal & {
97
97
  promptId: string;
98
98
  variables?: z.infer<typeof promptVariablesSchema>;
99
99
  });
100
+ /**
101
+ * The JSON Schema accepted by structured generation. Zod's JSON Schema
102
+ * compiler (`z.fromJSONSchema`) is the single authority for the supported
103
+ * feature set: anything it can convert is accepted, anything it cannot
104
+ * (unresolvable references, unsupported keywords, …) is rejected at this
105
+ * untrusted boundary. The only product restriction on top is the documented
106
+ * "at least a schema root" rule, which keeps the empty match-anything schema
107
+ * out of object mode. Composition roots are needed for schemas derived from
108
+ * unions (for example, Pydantic's `int | None` TypeAdapter schema), and local
109
+ * `$ref` roots are needed for recursive Pydantic models.
110
+ */
111
+ export declare const jsonSchemaShapeSchema: z.ZodCustom<z.core.JSONSchema.JSONSchema, z.core.JSONSchema.JSONSchema>;
112
+ export declare const MAX_CHAT_FUNCTIONS = 32;
113
+ export declare const MAX_CHAT_FUNCTION_DEFINITIONS_BYTES: number;
114
+ export declare const MAX_CHAT_FUNCTION_PAYLOAD_BYTES: number;
115
+ export declare const jsonByteLength: (value: unknown) => number;
116
+ /** One caller-local function as sent to Blazing Agents: description and JSON Schema only. */
117
+ export declare const chatFunctionDefinitionSchema: z.ZodObject<{
118
+ description: z.ZodString;
119
+ inputSchema: z.ZodCustom<z.core.JSONSchema.JSONSchema, z.core.JSONSchema.JSONSchema>;
120
+ }, z.core.$strict>;
121
+ export declare const chatFunctionDefinitionsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
122
+ description: z.ZodString;
123
+ inputSchema: z.ZodCustom<z.core.JSONSchema.JSONSchema, z.core.JSONSchema.JSONSchema>;
124
+ }, z.core.$strict>>;
125
+ /**
126
+ * Transient UI data part that authorizes one claim attempt for a function
127
+ * call. The SDK consumes it and never forwards it to the browser.
128
+ */
129
+ export declare const chatFunctionCallEventSchema: z.ZodObject<{
130
+ type: z.ZodLiteral<"data-ba-function-call">;
131
+ data: z.ZodObject<{
132
+ id: z.ZodString;
133
+ name: z.ZodString;
134
+ input: z.ZodJSONSchema;
135
+ deadlineAt: z.ZodISODateTime;
136
+ }, z.core.$strip>;
137
+ transient: z.ZodLiteral<true>;
138
+ }, z.core.$strip>;
139
+ export declare const chatFunctionOutcomeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
140
+ kind: z.ZodLiteral<"output">;
141
+ value: z.ZodJSONSchema;
142
+ }, z.core.$strict>, z.ZodObject<{
143
+ kind: z.ZodLiteral<"error">;
144
+ message: z.ZodString;
145
+ }, z.core.$strict>], "kind">;
146
+ /** `POST .../function-calls/{functionCallId}/claim` body. */
147
+ export declare const claimChatFunctionBodySchema: z.ZodObject<{
148
+ claimRequestId: z.ZodUUID;
149
+ }, z.core.$strict>;
150
+ export declare const claimChatFunctionResponseSchema: z.ZodObject<{
151
+ claimed: z.ZodLiteral<true>;
152
+ }, z.core.$strip>;
153
+ /** `POST .../function-calls/{functionCallId}/result` body. */
154
+ export declare const resolveChatFunctionBodySchema: z.ZodObject<{
155
+ claimRequestId: z.ZodUUID;
156
+ outcome: z.ZodDiscriminatedUnion<[z.ZodObject<{
157
+ kind: z.ZodLiteral<"output">;
158
+ value: z.ZodJSONSchema;
159
+ }, z.core.$strict>, z.ZodObject<{
160
+ kind: z.ZodLiteral<"error">;
161
+ message: z.ZodString;
162
+ }, z.core.$strict>], "kind">;
163
+ }, z.core.$strict>;
164
+ export declare const resolveChatFunctionResponseSchema: z.ZodObject<{
165
+ accepted: z.ZodLiteral<true>;
166
+ }, z.core.$strip>;
167
+ /** `POST .../tool-approval-continuations/{continuationId}/resume` body. */
168
+ export declare const resumeToolApprovalContinuationBodySchema: z.ZodObject<{}, z.core.$strict>;
100
169
  /**
101
170
  * `POST /v1/agents/{agentId}/sessions` (create) and
102
171
  * `POST /v1/agents/{agentId}/sessions/{sessionId}` (resume) request body.
@@ -117,6 +186,10 @@ export declare const chatRequestBodySchema: z.ZodObject<{
117
186
  version: z.ZodOptional<z.ZodNumber>;
118
187
  userId: z.ZodDefault<z.ZodString>;
119
188
  metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
189
+ functions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
190
+ description: z.ZodString;
191
+ inputSchema: z.ZodCustom<z.core.JSONSchema.JSONSchema, z.core.JSONSchema.JSONSchema>;
192
+ }, z.core.$strict>>>;
120
193
  }, z.core.$strict> & z.ZodType<{
121
194
  message?: unknown;
122
195
  promptId?: string | undefined;
@@ -126,6 +199,10 @@ export declare const chatRequestBodySchema: z.ZodObject<{
126
199
  version?: number | undefined;
127
200
  userId: string;
128
201
  metadata: Record<string, unknown>;
202
+ functions?: Record<string, {
203
+ description: string;
204
+ inputSchema: z.core.JSONSchema.JSONSchema;
205
+ }> | undefined;
129
206
  } & ExclusivePromptInput<{
130
207
  message: null | NonNullable<unknown>;
131
208
  }>, {
@@ -137,6 +214,10 @@ export declare const chatRequestBodySchema: z.ZodObject<{
137
214
  version?: number | undefined;
138
215
  userId?: string | undefined;
139
216
  metadata?: Record<string, unknown> | undefined;
217
+ functions?: Record<string, {
218
+ description: string;
219
+ inputSchema: z.core.JSONSchema.JSONSchema;
220
+ }> | undefined;
140
221
  }, z.core.$ZodTypeInternals<{
141
222
  message?: unknown;
142
223
  promptId?: string | undefined;
@@ -146,6 +227,10 @@ export declare const chatRequestBodySchema: z.ZodObject<{
146
227
  version?: number | undefined;
147
228
  userId: string;
148
229
  metadata: Record<string, unknown>;
230
+ functions?: Record<string, {
231
+ description: string;
232
+ inputSchema: z.core.JSONSchema.JSONSchema;
233
+ }> | undefined;
149
234
  } & ExclusivePromptInput<{
150
235
  message: null | NonNullable<unknown>;
151
236
  }>, {
@@ -157,19 +242,11 @@ export declare const chatRequestBodySchema: z.ZodObject<{
157
242
  version?: number | undefined;
158
243
  userId?: string | undefined;
159
244
  metadata?: Record<string, unknown> | undefined;
245
+ functions?: Record<string, {
246
+ description: string;
247
+ inputSchema: z.core.JSONSchema.JSONSchema;
248
+ }> | undefined;
160
249
  }>>;
161
- /**
162
- * The JSON Schema accepted by structured generation. Zod's JSON Schema
163
- * compiler (`z.fromJSONSchema`) is the single authority for the supported
164
- * feature set: anything it can convert is accepted, anything it cannot
165
- * (unresolvable references, unsupported keywords, …) is rejected at this
166
- * untrusted boundary. The only product restriction on top is the documented
167
- * "at least a schema root" rule, which keeps the empty match-anything schema
168
- * out of object mode. Composition roots are needed for schemas derived from
169
- * unions (for example, Pydantic's `int | None` TypeAdapter schema), and local
170
- * `$ref` roots are needed for recursive Pydantic models.
171
- */
172
- export declare const jsonSchemaShapeSchema: z.ZodCustom<z.core.JSONSchema.JSONSchema, z.core.JSONSchema.JSONSchema>;
173
250
  /**
174
251
  * `POST /v1/agents/{agentId}/generation` — the single stateless generation
175
252
  * boundary. Output selection is explicit on the wire while prompt selection
@@ -264,3 +341,9 @@ export type ChatRequestBody = z.infer<typeof chatRequestBodySchema>;
264
341
  export type GenerationRequestBody = z.infer<typeof generationRequestBodySchema>;
265
342
  export type ChatStreamErrorChunk = z.infer<typeof chatStreamErrorChunkSchema>;
266
343
  export type PromptVariables = z.infer<typeof promptVariablesSchema>;
344
+ export type ChatFunctionDefinition = z.infer<typeof chatFunctionDefinitionSchema>;
345
+ export type ChatFunctionDefinitions = z.infer<typeof chatFunctionDefinitionsSchema>;
346
+ export type ChatFunctionCallEvent = z.infer<typeof chatFunctionCallEventSchema>;
347
+ export type ChatFunctionOutcome = z.infer<typeof chatFunctionOutcomeSchema>;
348
+ export type ClaimChatFunctionBody = z.infer<typeof claimChatFunctionBodySchema>;
349
+ export type ResolveChatFunctionBody = z.infer<typeof resolveChatFunctionBodySchema>;
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
- import { agentIdSchema, promptIdSchema, sessionIdSchema, tenantIdSchema, turnIdSchema, } from "../ids.js";
2
+ import { agentIdSchema, functionCallIdSchema, promptIdSchema, sessionIdSchema, tenantIdSchema, turnIdSchema, } from "../ids.js";
3
+ import { chatFunctionNameSchema } from "./agent-tools.js";
3
4
  import { agentModelIdSchema, agentVersionNumberSchema } from "./agents.js";
4
5
  import { metadataSchema, userIdSchema } from "./attribution.js";
5
6
  export const chatModeSchema = z.enum(["create", "resume"]);
@@ -60,41 +61,6 @@ export const blazingAgentsChatMessageMetadataSchema = z
60
61
  * against the template (missing or unknown variable → 400 invalid_request).
61
62
  */
62
63
  export const promptVariablesSchema = z.record(z.string(), z.string());
63
- /**
64
- * `POST /v1/agents/{agentId}/sessions` (create) and
65
- * `POST /v1/agents/{agentId}/sessions/{sessionId}` (resume) request body.
66
- * The URL selects the mode; on create the platform mints the `ss_` id and
67
- * returns it in `Location`. Exactly one of `message` or `promptId` is
68
- * required, and `variables` requires `promptId`. Regenerate is resume-only,
69
- * enforced by the route layer rather than this schema.
70
- */
71
- export const chatRequestBodySchema = z
72
- .object({
73
- /**
74
- * AI SDK owns the runtime UIMessage schema. Core keeps this wire field
75
- * unknown; the HTTP boundary validates it with `safeValidateUIMessages`
76
- * before treating it as a UIMessage.
77
- */
78
- message: z.unknown().optional(),
79
- promptId: promptIdSchema.optional(),
80
- variables: promptVariablesSchema.optional(),
81
- trigger: chatTriggerSchema.default("submit-message"),
82
- messageId: z.string().min(1).optional(),
83
- version: agentVersionNumberSchema.optional(),
84
- /**
85
- * End-user attribution (ADR-0001), stamped on the Session at lazy
86
- * materialization and on every usage row this Turn records.
87
- */
88
- userId: userIdSchema.default(""),
89
- metadata: metadataSchema.default({}),
90
- })
91
- .strict()
92
- .refine((body) => body.message === undefined
93
- ? body.promptId !== undefined
94
- : body.promptId === undefined && body.variables === undefined, {
95
- message: "Provide either `message` or `promptId` (+`variables`); they are mutually exclusive, and `variables` is only allowed with `promptId`.",
96
- path: ["message"],
97
- });
98
64
  const JSON_SCHEMA_COMPOSITION_KEYS = ["allOf", "anyOf", "oneOf"];
99
65
  function hasMeaningfulSchemaRoot(value, definitions, seenReferences) {
100
66
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
@@ -152,6 +118,109 @@ export const jsonSchemaShapeSchema = z.custom((value) => {
152
118
  return false;
153
119
  }
154
120
  }, { message: "schema contains an unsupported or invalid JSON Schema feature" });
121
+ export const MAX_CHAT_FUNCTIONS = 32;
122
+ export const MAX_CHAT_FUNCTION_DEFINITIONS_BYTES = 64 * 1024;
123
+ export const MAX_CHAT_FUNCTION_PAYLOAD_BYTES = 256 * 1024;
124
+ export const jsonByteLength = (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength;
125
+ /** One caller-local function as sent to Blazing Agents: description and JSON Schema only. */
126
+ export const chatFunctionDefinitionSchema = z
127
+ .object({
128
+ description: z.string().trim().min(1),
129
+ inputSchema: jsonSchemaShapeSchema.refine((schema) => typeof schema === "object" && schema.type === "object", { message: "Function input schema must describe a JSON object." }),
130
+ })
131
+ .strict();
132
+ export const chatFunctionDefinitionsSchema = z
133
+ .record(chatFunctionNameSchema, chatFunctionDefinitionSchema)
134
+ .refine((functions) => Object.keys(functions).length <= MAX_CHAT_FUNCTIONS, {
135
+ message: `At most ${MAX_CHAT_FUNCTIONS} functions are allowed.`,
136
+ })
137
+ .refine((functions) => jsonByteLength(functions) <= MAX_CHAT_FUNCTION_DEFINITIONS_BYTES, {
138
+ message: `Function definitions must not exceed ${MAX_CHAT_FUNCTION_DEFINITIONS_BYTES} bytes.`,
139
+ });
140
+ /**
141
+ * Transient UI data part that authorizes one claim attempt for a function
142
+ * call. The SDK consumes it and never forwards it to the browser.
143
+ */
144
+ export const chatFunctionCallEventSchema = z
145
+ .object({
146
+ type: z.literal("data-ba-function-call"),
147
+ data: z
148
+ .object({
149
+ id: functionCallIdSchema,
150
+ name: chatFunctionNameSchema,
151
+ input: z.json(),
152
+ deadlineAt: z.iso.datetime({ offset: true }),
153
+ })
154
+ .strip(),
155
+ transient: z.literal(true),
156
+ })
157
+ .strip();
158
+ export const chatFunctionOutcomeSchema = z
159
+ .discriminatedUnion("kind", [
160
+ z.object({ kind: z.literal("output"), value: z.json() }).strict(),
161
+ z
162
+ .object({
163
+ kind: z.literal("error"),
164
+ message: z.string().min(1).max(4096),
165
+ })
166
+ .strict(),
167
+ ])
168
+ .refine((outcome) => jsonByteLength(outcome) <= MAX_CHAT_FUNCTION_PAYLOAD_BYTES, {
169
+ message: `Function outcome must not exceed ${MAX_CHAT_FUNCTION_PAYLOAD_BYTES} bytes.`,
170
+ });
171
+ /** `POST .../function-calls/{functionCallId}/claim` body. */
172
+ export const claimChatFunctionBodySchema = z
173
+ .object({ claimRequestId: z.uuid() })
174
+ .strict();
175
+ export const claimChatFunctionResponseSchema = z
176
+ .object({ claimed: z.literal(true) })
177
+ .strip();
178
+ /** `POST .../function-calls/{functionCallId}/result` body. */
179
+ export const resolveChatFunctionBodySchema = z
180
+ .object({ claimRequestId: z.uuid(), outcome: chatFunctionOutcomeSchema })
181
+ .strict();
182
+ export const resolveChatFunctionResponseSchema = z
183
+ .object({ accepted: z.literal(true) })
184
+ .strip();
185
+ /** `POST .../tool-approval-continuations/{continuationId}/resume` body. */
186
+ export const resumeToolApprovalContinuationBodySchema = z.object({}).strict();
187
+ /**
188
+ * `POST /v1/agents/{agentId}/sessions` (create) and
189
+ * `POST /v1/agents/{agentId}/sessions/{sessionId}` (resume) request body.
190
+ * The URL selects the mode; on create the platform mints the `ss_` id and
191
+ * returns it in `Location`. Exactly one of `message` or `promptId` is
192
+ * required, and `variables` requires `promptId`. Regenerate is resume-only,
193
+ * enforced by the route layer rather than this schema.
194
+ */
195
+ export const chatRequestBodySchema = z
196
+ .object({
197
+ /**
198
+ * AI SDK owns the runtime UIMessage schema. Core keeps this wire field
199
+ * unknown; the HTTP boundary validates it with `safeValidateUIMessages`
200
+ * before treating it as a UIMessage.
201
+ */
202
+ message: z.unknown().optional(),
203
+ promptId: promptIdSchema.optional(),
204
+ variables: promptVariablesSchema.optional(),
205
+ trigger: chatTriggerSchema.default("submit-message"),
206
+ messageId: z.string().min(1).optional(),
207
+ version: agentVersionNumberSchema.optional(),
208
+ /**
209
+ * End-user attribution (ADR-0001), stamped on the Session at lazy
210
+ * materialization and on every usage row this Turn records.
211
+ */
212
+ userId: userIdSchema.default(""),
213
+ metadata: metadataSchema.default({}),
214
+ /** Caller-local functions for this invocation; handlers stay in the caller's backend. */
215
+ functions: chatFunctionDefinitionsSchema.optional(),
216
+ })
217
+ .strict()
218
+ .refine((body) => body.message === undefined
219
+ ? body.promptId !== undefined
220
+ : body.promptId === undefined && body.variables === undefined, {
221
+ message: "Provide either `message` or `promptId` (+`variables`); they are mutually exclusive, and `variables` is only allowed with `promptId`.",
222
+ path: ["message"],
223
+ });
155
224
  /**
156
225
  * `POST /v1/agents/{agentId}/generation` — the single stateless generation
157
226
  * boundary. Output selection is explicit on the wire while prompt selection
@@ -20,7 +20,7 @@ export declare const promptSchema: z.ZodObject<{
20
20
  updatedAt: z.ZodISODateTime;
21
21
  }, z.core.$strip>;
22
22
  export declare const promptsResponseSchema: z.ZodObject<{
23
- prompts: z.ZodArray<z.ZodObject<{
23
+ data: z.ZodArray<z.ZodObject<{
24
24
  id: z.ZodString;
25
25
  tenantId: z.ZodString;
26
26
  agentId: z.ZodNullable<z.ZodString>;
@@ -32,7 +32,14 @@ export declare const promptsResponseSchema: z.ZodObject<{
32
32
  createdAt: z.ZodISODateTime;
33
33
  updatedAt: z.ZodISODateTime;
34
34
  }, z.core.$strip>>;
35
+ nextCursor: z.ZodNullable<z.ZodString>;
35
36
  }, z.core.$strip>;
37
+ export declare const promptsListQuerySchema: z.ZodObject<{
38
+ cursor: z.ZodOptional<z.ZodString>;
39
+ limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
40
+ userId: z.ZodOptional<z.ZodString>;
41
+ agentId: z.ZodOptional<z.ZodString>;
42
+ }, z.core.$strict>;
36
43
  export declare const promptResponseSchema: z.ZodObject<{
37
44
  id: z.ZodString;
38
45
  tenantId: z.ZodString;
@@ -61,6 +68,7 @@ export declare const updatePromptBodySchema: z.ZodObject<{
61
68
  export declare function renderPromptTemplate(template: string, values: Record<string, string>): string;
62
69
  export type Prompt = z.infer<typeof promptSchema>;
63
70
  export type PromptsResponse = z.infer<typeof promptsResponseSchema>;
71
+ export type PromptsListQuery = z.infer<typeof promptsListQuerySchema>;
64
72
  export type PromptResponse = z.infer<typeof promptResponseSchema>;
65
73
  export type CreatePromptBody = z.input<typeof createPromptBodySchema>;
66
74
  export type UpdatePromptBody = z.infer<typeof updatePromptBodySchema>;
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
+ import { cursorSchema, paginatedResponseSchema } from "../api.js";
2
3
  import { agentIdSchema, promptIdSchema, tenantIdSchema } from "../ids.js";
3
- import { MAX_PROMPT_NAME_LENGTH, MAX_PROMPT_TEMPLATE_BYTES, MAX_PROMPT_VARIABLES, } from "../limitations.js";
4
+ import { DEFAULT_PROMPTS_LIST_LIMIT, MAX_PROMPT_NAME_LENGTH, MAX_PROMPT_TEMPLATE_BYTES, MAX_PROMPT_VARIABLES, MAX_PROMPTS_LIST_LIMIT, } from "../limitations.js";
4
5
  import { atLeastOneFieldMessage, hasObjectKeys } from "../utils.js";
5
6
  import { metadataSchema, userIdSchema } from "./attribution.js";
6
7
  export const promptVariableTokenPattern = /{{([\s\S]*?)}}/g;
@@ -59,11 +60,20 @@ export const promptSchema = z
59
60
  updatedAt: z.iso.datetime({ offset: true }),
60
61
  })
61
62
  .strip();
62
- export const promptsResponseSchema = z
63
+ export const promptsResponseSchema = paginatedResponseSchema(promptSchema);
64
+ export const promptsListQuerySchema = z
63
65
  .object({
64
- prompts: z.array(promptSchema),
66
+ cursor: cursorSchema.optional(),
67
+ limit: z.coerce
68
+ .number()
69
+ .int()
70
+ .min(1)
71
+ .max(MAX_PROMPTS_LIST_LIMIT)
72
+ .default(DEFAULT_PROMPTS_LIST_LIMIT),
73
+ userId: userIdSchema.optional(),
74
+ agentId: agentIdSchema.optional(),
65
75
  })
66
- .strip();
76
+ .strict();
67
77
  export const promptResponseSchema = promptSchema;
68
78
  export const createPromptBodySchema = z
69
79
  .object({
@@ -151,6 +151,9 @@ export declare const toolApprovalStateSchema: z.ZodObject<{
151
151
  type: z.ZodLiteral<"mcp">;
152
152
  connectionId: z.ZodString;
153
153
  name: z.ZodString;
154
+ }, z.core.$strict>, z.ZodObject<{
155
+ type: z.ZodLiteral<"function">;
156
+ name: z.ZodString;
154
157
  }, z.core.$strict>], "type">>>;
155
158
  assistantMessageId: z.ZodOptional<z.ZodString>;
156
159
  createdAt: z.ZodOptional<z.ZodISODateTime>;
@@ -200,6 +203,9 @@ export declare const toolApprovalsResponseSchema: z.ZodObject<{
200
203
  type: z.ZodLiteral<"mcp">;
201
204
  connectionId: z.ZodString;
202
205
  name: z.ZodString;
206
+ }, z.core.$strict>, z.ZodObject<{
207
+ type: z.ZodLiteral<"function">;
208
+ name: z.ZodString;
203
209
  }, z.core.$strict>], "type">>>;
204
210
  assistantMessageId: z.ZodOptional<z.ZodString>;
205
211
  createdAt: z.ZodOptional<z.ZodISODateTime>;
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import { paginatedResponseSchema } from "../api.js";
3
3
  import { agentIdSchema, sessionIdSchema } from "../ids.js";
4
4
  import { DEFAULT_SESSION_MESSAGES_LIMIT, MAX_SESSION_MESSAGES_LIMIT, } from "../limitations.js";
5
- import { toolReferenceSchema } from "./agent-approval.js";
5
+ import { toolExecutionReferenceSchema } from "./agent-approval.js";
6
6
  import { agentSchema, agentVersionNumberSchema } from "./agents.js";
7
7
  import { metadataSchema, userIdSchema } from "./attribution.js";
8
8
  /**
@@ -104,7 +104,7 @@ export const toolApprovalContinuationStateSchema = z.enum([
104
104
  ]);
105
105
  export const toolApprovalStateSchema = z
106
106
  .object({
107
- tool: toolReferenceSchema.nullable().optional(),
107
+ tool: toolExecutionReferenceSchema.nullable().optional(),
108
108
  assistantMessageId: z.string().min(1).optional(),
109
109
  createdAt: z.iso.datetime({ offset: true }).optional(),
110
110
  decidedAt: z.iso.datetime({ offset: true }).nullable().optional(),
@@ -44,12 +44,9 @@ export declare const taskScheduleInputSchema: z.ZodDiscriminatedUnion<[z.ZodObje
44
44
  export type TaskScheduleInput = z.infer<typeof taskScheduleInputSchema>;
45
45
  /**
46
46
  * `POST /v1/tasks` — schedule present = scheduled task; absent = on-demand.
47
- * `submit: true` enqueues a run immediately (on-demand's only trigger
48
- * alongside creation) with a server-minted random run id. This path is
49
- * NOT idempotent — each call creates a new task + new run. For run-level
50
- * idempotency, use `POST /v1/tasks/{taskId}/runs` with an idempotency key
51
- * (the task must already exist so the deterministic run id is stable
52
- * across replays).
47
+ * `submit: true` enqueues a run immediately. An optional `idempotencyKey`
48
+ * makes retries return the original Task and initial run id. Without a key,
49
+ * each call creates a new Task. Run creation has its own idempotency key.
53
50
  */
54
51
  export declare const createTaskBodySchema: z.ZodObject<{
55
52
  agentId: z.ZodString;
@@ -76,6 +73,7 @@ export declare const createTaskBodySchema: z.ZodObject<{
76
73
  }, z.core.$strict>], "kind">>>;
77
74
  enabled: z.ZodDefault<z.ZodBoolean>;
78
75
  submit: z.ZodDefault<z.ZodBoolean>;
76
+ idempotencyKey: z.ZodOptional<z.ZodString>;
79
77
  userId: z.ZodDefault<z.ZodString>;
80
78
  metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
81
79
  }, z.core.$strict>;
@@ -106,12 +106,9 @@ const taskNameSchema = z.string().trim().min(1).max(MAX_TASK_NAME_LENGTH);
106
106
  const taskPromptSchema = z.string().trim().min(1).max(MAX_TASK_PROMPT_LENGTH);
107
107
  /**
108
108
  * `POST /v1/tasks` — schedule present = scheduled task; absent = on-demand.
109
- * `submit: true` enqueues a run immediately (on-demand's only trigger
110
- * alongside creation) with a server-minted random run id. This path is
111
- * NOT idempotent — each call creates a new task + new run. For run-level
112
- * idempotency, use `POST /v1/tasks/{taskId}/runs` with an idempotency key
113
- * (the task must already exist so the deterministic run id is stable
114
- * across replays).
109
+ * `submit: true` enqueues a run immediately. An optional `idempotencyKey`
110
+ * makes retries return the original Task and initial run id. Without a key,
111
+ * each call creates a new Task. Run creation has its own idempotency key.
115
112
  */
116
113
  export const createTaskBodySchema = z
117
114
  .object({
@@ -122,6 +119,7 @@ export const createTaskBodySchema = z
122
119
  schedule: taskScheduleInputSchema.nullable().default(null),
123
120
  enabled: z.boolean().default(true),
124
121
  submit: z.boolean().default(false),
122
+ idempotencyKey: z.string().trim().min(1).optional(),
125
123
  userId: userIdSchema.default(""),
126
124
  metadata: metadataSchema.default({}),
127
125
  })
@@ -77,6 +77,22 @@ export declare const usageTotalsSchema: z.ZodObject<{
77
77
  requestCount: z.ZodNumber;
78
78
  durationMs: z.ZodNumber;
79
79
  }, z.core.$strip>;
80
+ export declare const sessionUsageQuerySchema: z.ZodObject<{
81
+ sessionIds: z.ZodArray<z.ZodString>;
82
+ from: z.ZodOptional<z.ZodISODate>;
83
+ to: z.ZodOptional<z.ZodISODate>;
84
+ }, z.core.$strict>;
85
+ export declare const sessionUsageResponseSchema: z.ZodObject<{
86
+ data: z.ZodArray<z.ZodObject<{
87
+ sessionId: z.ZodString;
88
+ totals: z.ZodObject<{
89
+ inputTokens: z.ZodNumber;
90
+ outputTokens: z.ZodNumber;
91
+ requestCount: z.ZodNumber;
92
+ durationMs: z.ZodNumber;
93
+ }, z.core.$strip>;
94
+ }, z.core.$strip>>;
95
+ }, z.core.$strip>;
80
96
  export declare const usageResponseSchema: z.ZodObject<{
81
97
  buckets: z.ZodArray<z.ZodObject<{
82
98
  day: z.ZodNullable<z.ZodString>;
@@ -224,3 +240,5 @@ export type UsageTotals = z.infer<typeof usageTotalsSchema>;
224
240
  export type UsageResponse = z.infer<typeof usageResponseSchema>;
225
241
  export type UsageOverviewQuery = z.infer<typeof usageOverviewQuerySchema>;
226
242
  export type UsageOverviewResponse = z.infer<typeof usageOverviewResponseSchema>;
243
+ export type SessionUsageQuery = z.infer<typeof sessionUsageQuerySchema>;
244
+ export type SessionUsageResponse = z.infer<typeof sessionUsageResponseSchema>;
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { agentIdSchema, sessionIdSchema } from "../ids.js";
3
3
  import { DEFAULT_USAGE_OVERVIEW_TOP_N, DEFAULT_USAGE_RANGE_DAYS, DEFAULT_USAGE_SESSION_TOP_N, MAX_USAGE_OVERVIEW_TOP_N, MAX_USAGE_RANGE_DAYS, MAX_USAGE_SESSION_TOP_N, } from "../limitations.js";
4
+ import { hasUniqueValues } from "../utils.js";
4
5
  import { userIdSchema } from "./attribution.js";
5
6
  function validateUsageRange(value, ctx) {
6
7
  if ((value.from === undefined) !== (value.to === undefined)) {
@@ -122,6 +123,33 @@ export const usageTotalsSchema = z
122
123
  durationMs: z.number().int().nonnegative(),
123
124
  })
124
125
  .strip();
126
+ export const sessionUsageQuerySchema = z
127
+ .object({
128
+ sessionIds: z
129
+ .array(sessionIdSchema)
130
+ .min(1)
131
+ .max(100)
132
+ .refine(hasUniqueValues, {
133
+ message: "Session ids must be unique.",
134
+ }),
135
+ from: z.iso.date().optional(),
136
+ to: z.iso.date().optional(),
137
+ })
138
+ .strict()
139
+ .superRefine(validateUsageRange);
140
+ export const sessionUsageResponseSchema = z
141
+ .object({
142
+ data: z
143
+ .array(z
144
+ .object({
145
+ sessionId: sessionIdSchema,
146
+ totals: usageTotalsSchema,
147
+ })
148
+ .strip())
149
+ .min(1)
150
+ .max(100),
151
+ })
152
+ .strip();
125
153
  export const usageResponseSchema = z
126
154
  .object({
127
155
  buckets: z.array(usageBucketSchema),
@@ -46,6 +46,7 @@ export declare const promptIdSchema: z.ZodString;
46
46
  export declare const requestIdSchema: z.ZodString;
47
47
  export declare const checkoutAttemptIdSchema: z.ZodString;
48
48
  export declare const turnIdSchema: z.ZodString;
49
+ export declare const functionCallIdSchema: z.ZodString;
49
50
  export declare const skillIdSchema: z.ZodString;
50
51
  /**
51
52
  * API key token + digest helpers. The digest is sha256 hex (64 chars); the
@@ -72,6 +72,7 @@ export const promptIdSchema = z.string().regex(/^prompt_[0-9A-Za-z]{16}$/);
72
72
  export const requestIdSchema = z.string().regex(/^req_[0-9A-Za-z]{16}$/);
73
73
  export const checkoutAttemptIdSchema = z.string().regex(/^ca_[0-9A-Za-z]{16}$/);
74
74
  export const turnIdSchema = z.string().regex(/^turn_[0-9A-Za-z]{16}$/);
75
+ export const functionCallIdSchema = z.string().regex(/^fc_[0-9A-Za-z]{16}$/);
75
76
  export const skillIdSchema = z.string().regex(/^skill_[0-9A-Za-z]{16}$/);
76
77
  /**
77
78
  * API key token + digest helpers. The digest is sha256 hex (64 chars); the
@@ -1,24 +1,25 @@
1
1
  /** Public runtime schemas for the Blazing Agents HTTP API. */
2
2
  export { receivedApiErrorResponseSchema } from "./api.ts";
3
- export type { ApprovalDecision, ApprovalPolicy, ToolReference, } from "./entities/agent-approval.ts";
4
- export { approvalDecisionSchema, approvalPolicySchema, toolReferenceSchema, } from "./entities/agent-approval.ts";
5
- export { agentResponseSchema, agentSchema, agentStatusSchema, agentsResponseSchema, agentVersionSchema, agentVersionsResponseSchema, createAgentBodySchema, updateAgentBodySchema, } from "./entities/agents.ts";
3
+ export type { ApprovalDecision, ApprovalPolicy, ToolExecutionReference, ToolReference, } from "./entities/agent-approval.ts";
4
+ export { approvalDecisionSchema, approvalPolicySchema, toolExecutionReferenceSchema, toolReferenceSchema, } from "./entities/agent-approval.ts";
5
+ export { chatFunctionNameSchema } from "./entities/agent-tools.ts";
6
+ export { agentResponseSchema, agentSchema, agentStatusSchema, agentsListQuerySchema, agentsResponseSchema, agentVersionSchema, agentVersionsResponseSchema, createAgentBodySchema, updateAgentBodySchema, } from "./entities/agents.ts";
6
7
  export { artifactDownloadUrlResponseSchema, artifactListItemSchema, artifactsListResponseSchema, } from "./entities/artifacts.ts";
7
8
  export { attributionCreateInputSchema, metadataSchema, } from "./entities/attribution.ts";
8
- export type { PromptVariables, UsageSummary } from "./entities/chat.ts";
9
- export { blazingAgentsChatMessageMetadataSchema, chatModeSchema, chatRequestBodySchema, chatTriggerSchema, generationRequestBodySchema, jsonSchemaShapeSchema, promptVariablesSchema, usageSummarySchema, } from "./entities/chat.ts";
9
+ export type { ChatFunctionCallEvent, ChatFunctionDefinition, ChatFunctionDefinitions, ChatFunctionOutcome, ClaimChatFunctionBody, PromptVariables, ResolveChatFunctionBody, UsageSummary, } from "./entities/chat.ts";
10
+ 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, resumeToolApprovalContinuationBodySchema, usageSummarySchema, } from "./entities/chat.ts";
10
11
  export { chatConfigurationSchema, chatConnectionSchema, chatConnectionsResponseSchema, chatCredentialsSchema, chatDeliveriesResponseSchema, chatDeliveryListStatusSchema, chatDeliverySchema, chatDeliveryStatusSchema, chatHealthCheckSchema, chatHealthSchema, chatIdentitySchema, createChatConnectionBodySchema, rotateChatConnectionBodySchema, tenantChatDeliverySchema, updateChatConnectionBodySchema, } from "./entities/chat-connections.ts";
11
12
  export { approveMcpOauthAuthorizationBodySchema, createMcpConnectionBodySchema, mcpAttachmentResponseSchema, mcpAttachmentsResponseSchema, mcpConnectionAuthTypeSchema, mcpConnectionOauthConnectResponseSchema, mcpConnectionReconnectResultSchema, mcpConnectionResponseSchema, mcpConnectionStatusSchema, mcpConnectionsResponseSchema, mcpConnectionTestErrorCodeSchema, mcpConnectionTestResponseSchema, mcpOauthAuthorizationLaunchResponseSchema, reconnectMcpConnectionBodySchema, updateMcpAttachmentBodySchema, updateMcpConnectionBodySchema, } from "./entities/mcp-connections.ts";
12
13
  export { createMemoryBodySchema, memoriesListResponseSchema, memoryResponseSchema, memorySchema, updateMemoryBodySchema, } from "./entities/memories.ts";
13
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";
14
- export { createPromptBodySchema, parsePromptVariables, promptResponseSchema, promptSchema, promptsResponseSchema, promptTemplateSchema, renderPromptTemplate, updatePromptBodySchema, } from "./entities/prompts.ts";
15
+ export { createPromptBodySchema, parsePromptVariables, promptResponseSchema, promptSchema, promptsListQuerySchema, promptsResponseSchema, promptTemplateSchema, renderPromptTemplate, updatePromptBodySchema, } from "./entities/prompts.ts";
15
16
  export { createProviderBodySchema, providerListItemSchema, providerModelsResponseSchema, providerResponseSchema, providersResponseSchema, providerTypeSchema, thinkingLevelsResponseSchema, updateProviderBodySchema, } from "./entities/providers.ts";
16
17
  export type { ToolApprovalDecisionResponse, ToolApprovalsResponse, } from "./entities/sessions.ts";
17
18
  export { decideToolApprovalBodySchema, latestSessionListItemSchema, latestSessionsListResponseSchema, sessionListItemSchema, sessionMessageSchema, sessionMessagesResponseSchema, sessionsListResponseSchema, toolApprovalContinuationStateSchema, toolApprovalDecisionResponseSchema, toolApprovalStateSchema, toolApprovalsResponseSchema, } from "./entities/sessions.ts";
18
19
  export { copySkillBodySchema, createSkillBodySchema, skillCopyResultsSchema, skillDetailSchema, skillsListResponseSchema, } from "./entities/skills.ts";
19
- export { createTaskBodySchema, createTaskResponseSchema, createTaskRunBodySchema, createTaskRunResponseSchema, taskListItemSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunSchema, taskRunStatusSchema, taskRunsListResponseSchema, taskScheduleKindSchema, taskSchema, tasksListResponseSchema, updateTaskBodySchema, } from "./entities/tasks.ts";
20
+ export { createTaskBodySchema, createTaskResponseSchema, createTaskRunBodySchema, createTaskRunResponseSchema, taskCronConfigSchema, taskIntervalConfigSchema, taskListItemSchema, taskOnceConfigSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunSchema, taskRunStatusSchema, taskRunsListResponseSchema, taskScheduleInputSchema, taskScheduleKindSchema, taskSchema, tasksListResponseSchema, updateTaskBodySchema, } from "./entities/tasks.ts";
20
21
  export { quotaSchema, subscriptionStatusSchema, tenantDeletionSchema, tenantResponseSchema, tenantSchema, tenantSettingsResponseSchema, updateTenantSettingsBodySchema, } from "./entities/tenants.ts";
21
- export type { UsageBucket, UsageOverviewQuery, UsageOverviewResponse, UsageResponse, UsageTotals, } from "./entities/usage.ts";
22
- export { usageOverviewQuerySchema, usageOverviewResponseSchema, usageResponseSchema, } from "./entities/usage.ts";
22
+ export type { SessionUsageQuery, SessionUsageResponse, UsageBucket, UsageOverviewQuery, UsageOverviewResponse, UsageResponse, UsageTotals, } from "./entities/usage.ts";
23
+ export { sessionUsageQuerySchema, sessionUsageResponseSchema, usageOverviewQuerySchema, usageOverviewResponseSchema, usageResponseSchema, } from "./entities/usage.ts";
23
24
  export { createWorkspaceBodySchema, updateWorkspaceBodySchema, workspaceSchema, workspacesListResponseSchema, } from "./entities/workspaces.ts";
24
- export { agentIdSchema, apiKeyTokenSchema, isAdminAgentId, promptIdSchema, sessionIdSchema, } from "./ids.ts";
25
+ export { agentIdSchema, apiKeyTokenSchema, functionCallIdSchema, isAdminAgentId, promptIdSchema, sessionIdSchema, } from "./ids.ts";