@blazingagents/sdk 0.15.0 → 0.17.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/approvals.d.ts +15 -0
- package/dist/approvals.js +20 -0
- package/dist/chat-transport.js +9 -2
- package/dist/client.d.ts +6 -1
- package/dist/client.js +9 -1
- package/dist/contracts/api.d.ts +3 -3
- package/dist/contracts/api.js +1 -1
- package/dist/contracts/entities/agent-approval.d.ts +32 -0
- package/dist/contracts/entities/agent-approval.js +12 -1
- package/dist/contracts/entities/agent-tools.d.ts +6 -0
- package/dist/contracts/entities/agent-tools.js +13 -0
- package/dist/contracts/entities/agents.d.ts +2 -118
- package/dist/contracts/entities/agents.js +2 -24
- package/dist/contracts/entities/chat.d.ts +95 -24
- package/dist/contracts/entities/chat.js +105 -39
- package/dist/contracts/entities/providers.d.ts +2 -6
- package/dist/contracts/entities/providers.js +2 -9
- package/dist/contracts/entities/sessions.d.ts +112 -5
- package/dist/contracts/entities/sessions.js +7 -5
- package/dist/contracts/entities/tasks.d.ts +285 -10
- package/dist/contracts/entities/tasks.js +2 -5
- package/dist/contracts/ids.d.ts +1 -0
- package/dist/contracts/ids.js +1 -0
- package/dist/contracts/index.d.ts +8 -7
- package/dist/contracts/index.js +6 -5
- package/dist/contracts/limitations.d.ts +0 -2
- package/dist/contracts/limitations.js +0 -2
- package/dist/direct-chat-transport.d.ts +3 -1
- package/dist/direct-chat-transport.js +20 -23
- package/dist/functions.d.ts +38 -0
- package/dist/functions.js +299 -0
- package/dist/generation.d.ts +7 -1
- package/dist/generation.js +64 -20
- package/dist/index.d.ts +7 -4
- package/dist/index.js +3 -0
- package/dist/relay.d.ts +11 -5
- package/dist/relay.js +41 -3
- package/dist/resources/agents.js +1 -33
- package/dist/resources/providers.js +1 -1
- package/dist/resources/sessions.d.ts +1 -1
- package/dist/resources/sessions.js +9 -4
- package/dist/types.d.ts +22 -23
- package/package.json +1 -1
|
@@ -19,7 +19,6 @@ export declare const chatTriggerSchema: z.ZodEnum<{
|
|
|
19
19
|
*/
|
|
20
20
|
export declare const usageSummarySchema: z.ZodObject<{
|
|
21
21
|
agentId: z.ZodString;
|
|
22
|
-
agentVersion: z.ZodNumber;
|
|
23
22
|
commitId: z.ZodString;
|
|
24
23
|
completedAt: z.ZodISODateTime;
|
|
25
24
|
durationMs: z.ZodNumber;
|
|
@@ -52,7 +51,6 @@ export declare const blazingAgentsChatMessageMetadataSchema: z.ZodObject<{
|
|
|
52
51
|
blazingAgents: z.ZodObject<{
|
|
53
52
|
usage: z.ZodObject<{
|
|
54
53
|
agentId: z.ZodString;
|
|
55
|
-
agentVersion: z.ZodNumber;
|
|
56
54
|
commitId: z.ZodString;
|
|
57
55
|
completedAt: z.ZodISODateTime;
|
|
58
56
|
durationMs: z.ZodNumber;
|
|
@@ -97,6 +95,75 @@ type ExclusivePromptInput<Literal extends object> = (Literal & {
|
|
|
97
95
|
promptId: string;
|
|
98
96
|
variables?: z.infer<typeof promptVariablesSchema>;
|
|
99
97
|
});
|
|
98
|
+
/**
|
|
99
|
+
* The JSON Schema accepted by structured generation. Zod's JSON Schema
|
|
100
|
+
* compiler (`z.fromJSONSchema`) is the single authority for the supported
|
|
101
|
+
* feature set: anything it can convert is accepted, anything it cannot
|
|
102
|
+
* (unresolvable references, unsupported keywords, …) is rejected at this
|
|
103
|
+
* untrusted boundary. The only product restriction on top is the documented
|
|
104
|
+
* "at least a schema root" rule, which keeps the empty match-anything schema
|
|
105
|
+
* out of object mode. Composition roots are needed for schemas derived from
|
|
106
|
+
* unions (for example, Pydantic's `int | None` TypeAdapter schema), and local
|
|
107
|
+
* `$ref` roots are needed for recursive Pydantic models.
|
|
108
|
+
*/
|
|
109
|
+
export declare const jsonSchemaShapeSchema: z.ZodCustom<z.core.JSONSchema.JSONSchema, z.core.JSONSchema.JSONSchema>;
|
|
110
|
+
export declare const MAX_CHAT_FUNCTIONS = 32;
|
|
111
|
+
export declare const MAX_CHAT_FUNCTION_DEFINITIONS_BYTES: number;
|
|
112
|
+
export declare const MAX_CHAT_FUNCTION_PAYLOAD_BYTES: number;
|
|
113
|
+
export declare const jsonByteLength: (value: unknown) => number;
|
|
114
|
+
/** One caller-local function as sent to Blazing Agents: description and JSON Schema only. */
|
|
115
|
+
export declare const chatFunctionDefinitionSchema: z.ZodObject<{
|
|
116
|
+
description: z.ZodString;
|
|
117
|
+
inputSchema: z.ZodCustom<z.core.JSONSchema.JSONSchema, z.core.JSONSchema.JSONSchema>;
|
|
118
|
+
}, z.core.$strict>;
|
|
119
|
+
export declare const chatFunctionDefinitionsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
120
|
+
description: z.ZodString;
|
|
121
|
+
inputSchema: z.ZodCustom<z.core.JSONSchema.JSONSchema, z.core.JSONSchema.JSONSchema>;
|
|
122
|
+
}, z.core.$strict>>;
|
|
123
|
+
/**
|
|
124
|
+
* Transient UI data part that authorizes one claim attempt for a function
|
|
125
|
+
* call. The SDK consumes it and never forwards it to the browser.
|
|
126
|
+
*/
|
|
127
|
+
export declare const chatFunctionCallEventSchema: z.ZodObject<{
|
|
128
|
+
type: z.ZodLiteral<"data-ba-function-call">;
|
|
129
|
+
data: z.ZodObject<{
|
|
130
|
+
id: z.ZodString;
|
|
131
|
+
name: z.ZodString;
|
|
132
|
+
input: z.ZodJSONSchema;
|
|
133
|
+
deadlineAt: z.ZodISODateTime;
|
|
134
|
+
}, z.core.$strip>;
|
|
135
|
+
transient: z.ZodLiteral<true>;
|
|
136
|
+
}, z.core.$strip>;
|
|
137
|
+
export declare const chatFunctionOutcomeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
138
|
+
kind: z.ZodLiteral<"output">;
|
|
139
|
+
value: z.ZodJSONSchema;
|
|
140
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
141
|
+
kind: z.ZodLiteral<"error">;
|
|
142
|
+
message: z.ZodString;
|
|
143
|
+
}, z.core.$strict>], "kind">;
|
|
144
|
+
/** `POST .../function-calls/{functionCallId}/claim` body. */
|
|
145
|
+
export declare const claimChatFunctionBodySchema: z.ZodObject<{
|
|
146
|
+
claimRequestId: z.ZodUUID;
|
|
147
|
+
}, z.core.$strict>;
|
|
148
|
+
export declare const claimChatFunctionResponseSchema: z.ZodObject<{
|
|
149
|
+
claimed: z.ZodLiteral<true>;
|
|
150
|
+
}, z.core.$strip>;
|
|
151
|
+
/** `POST .../function-calls/{functionCallId}/result` body. */
|
|
152
|
+
export declare const resolveChatFunctionBodySchema: z.ZodObject<{
|
|
153
|
+
claimRequestId: z.ZodUUID;
|
|
154
|
+
outcome: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
155
|
+
kind: z.ZodLiteral<"output">;
|
|
156
|
+
value: z.ZodJSONSchema;
|
|
157
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
158
|
+
kind: z.ZodLiteral<"error">;
|
|
159
|
+
message: z.ZodString;
|
|
160
|
+
}, z.core.$strict>], "kind">;
|
|
161
|
+
}, z.core.$strict>;
|
|
162
|
+
export declare const resolveChatFunctionResponseSchema: z.ZodObject<{
|
|
163
|
+
accepted: z.ZodLiteral<true>;
|
|
164
|
+
}, z.core.$strip>;
|
|
165
|
+
/** `POST .../tool-approval-continuations/{continuationId}/resume` body. */
|
|
166
|
+
export declare const resumeToolApprovalContinuationBodySchema: z.ZodObject<{}, z.core.$strict>;
|
|
100
167
|
/**
|
|
101
168
|
* `POST /v1/agents/{agentId}/sessions` (create) and
|
|
102
169
|
* `POST /v1/agents/{agentId}/sessions/{sessionId}` (resume) request body.
|
|
@@ -114,18 +181,24 @@ export declare const chatRequestBodySchema: z.ZodObject<{
|
|
|
114
181
|
"submit-message": "submit-message";
|
|
115
182
|
}>>;
|
|
116
183
|
messageId: z.ZodOptional<z.ZodString>;
|
|
117
|
-
version: z.ZodOptional<z.ZodNumber>;
|
|
118
184
|
userId: z.ZodDefault<z.ZodString>;
|
|
119
185
|
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
186
|
+
functions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
187
|
+
description: z.ZodString;
|
|
188
|
+
inputSchema: z.ZodCustom<z.core.JSONSchema.JSONSchema, z.core.JSONSchema.JSONSchema>;
|
|
189
|
+
}, z.core.$strict>>>;
|
|
120
190
|
}, z.core.$strict> & z.ZodType<{
|
|
121
191
|
message?: unknown;
|
|
122
192
|
promptId?: string | undefined;
|
|
123
193
|
variables?: Record<string, string> | undefined;
|
|
124
194
|
trigger: "regenerate-message" | "submit-message";
|
|
125
195
|
messageId?: string | undefined;
|
|
126
|
-
version?: number | undefined;
|
|
127
196
|
userId: string;
|
|
128
197
|
metadata: Record<string, unknown>;
|
|
198
|
+
functions?: Record<string, {
|
|
199
|
+
description: string;
|
|
200
|
+
inputSchema: z.core.JSONSchema.JSONSchema;
|
|
201
|
+
}> | undefined;
|
|
129
202
|
} & ExclusivePromptInput<{
|
|
130
203
|
message: null | NonNullable<unknown>;
|
|
131
204
|
}>, {
|
|
@@ -134,18 +207,24 @@ export declare const chatRequestBodySchema: z.ZodObject<{
|
|
|
134
207
|
variables?: Record<string, string> | undefined;
|
|
135
208
|
trigger?: "regenerate-message" | "submit-message" | undefined;
|
|
136
209
|
messageId?: string | undefined;
|
|
137
|
-
version?: number | undefined;
|
|
138
210
|
userId?: string | undefined;
|
|
139
211
|
metadata?: Record<string, unknown> | undefined;
|
|
212
|
+
functions?: Record<string, {
|
|
213
|
+
description: string;
|
|
214
|
+
inputSchema: z.core.JSONSchema.JSONSchema;
|
|
215
|
+
}> | undefined;
|
|
140
216
|
}, z.core.$ZodTypeInternals<{
|
|
141
217
|
message?: unknown;
|
|
142
218
|
promptId?: string | undefined;
|
|
143
219
|
variables?: Record<string, string> | undefined;
|
|
144
220
|
trigger: "regenerate-message" | "submit-message";
|
|
145
221
|
messageId?: string | undefined;
|
|
146
|
-
version?: number | undefined;
|
|
147
222
|
userId: string;
|
|
148
223
|
metadata: Record<string, unknown>;
|
|
224
|
+
functions?: Record<string, {
|
|
225
|
+
description: string;
|
|
226
|
+
inputSchema: z.core.JSONSchema.JSONSchema;
|
|
227
|
+
}> | undefined;
|
|
149
228
|
} & ExclusivePromptInput<{
|
|
150
229
|
message: null | NonNullable<unknown>;
|
|
151
230
|
}>, {
|
|
@@ -154,22 +233,13 @@ export declare const chatRequestBodySchema: z.ZodObject<{
|
|
|
154
233
|
variables?: Record<string, string> | undefined;
|
|
155
234
|
trigger?: "regenerate-message" | "submit-message" | undefined;
|
|
156
235
|
messageId?: string | undefined;
|
|
157
|
-
version?: number | undefined;
|
|
158
236
|
userId?: string | undefined;
|
|
159
237
|
metadata?: Record<string, unknown> | undefined;
|
|
238
|
+
functions?: Record<string, {
|
|
239
|
+
description: string;
|
|
240
|
+
inputSchema: z.core.JSONSchema.JSONSchema;
|
|
241
|
+
}> | undefined;
|
|
160
242
|
}>>;
|
|
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
243
|
/**
|
|
174
244
|
* `POST /v1/agents/{agentId}/generation` — the single stateless generation
|
|
175
245
|
* boundary. Output selection is explicit on the wire while prompt selection
|
|
@@ -185,7 +255,6 @@ export declare const generationRequestBodySchema: z.ZodObject<{
|
|
|
185
255
|
type: z.ZodLiteral<"object">;
|
|
186
256
|
schema: z.ZodCustom<z.core.JSONSchema.JSONSchema, z.core.JSONSchema.JSONSchema>;
|
|
187
257
|
}, z.core.$strict>], "type">;
|
|
188
|
-
version: z.ZodOptional<z.ZodNumber>;
|
|
189
258
|
userId: z.ZodDefault<z.ZodString>;
|
|
190
259
|
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
191
260
|
}, z.core.$strict> & z.ZodType<{
|
|
@@ -198,7 +267,6 @@ export declare const generationRequestBodySchema: z.ZodObject<{
|
|
|
198
267
|
type: "object";
|
|
199
268
|
schema: z.core.JSONSchema.JSONSchema;
|
|
200
269
|
};
|
|
201
|
-
version?: number | undefined;
|
|
202
270
|
userId: string;
|
|
203
271
|
metadata: Record<string, unknown>;
|
|
204
272
|
} & ExclusivePromptInput<{
|
|
@@ -213,7 +281,6 @@ export declare const generationRequestBodySchema: z.ZodObject<{
|
|
|
213
281
|
type: "object";
|
|
214
282
|
schema: z.core.JSONSchema.JSONSchema;
|
|
215
283
|
};
|
|
216
|
-
version?: number | undefined;
|
|
217
284
|
userId?: string | undefined;
|
|
218
285
|
metadata?: Record<string, unknown> | undefined;
|
|
219
286
|
}, z.core.$ZodTypeInternals<{
|
|
@@ -226,7 +293,6 @@ export declare const generationRequestBodySchema: z.ZodObject<{
|
|
|
226
293
|
type: "object";
|
|
227
294
|
schema: z.core.JSONSchema.JSONSchema;
|
|
228
295
|
};
|
|
229
|
-
version?: number | undefined;
|
|
230
296
|
userId: string;
|
|
231
297
|
metadata: Record<string, unknown>;
|
|
232
298
|
} & ExclusivePromptInput<{
|
|
@@ -241,7 +307,6 @@ export declare const generationRequestBodySchema: z.ZodObject<{
|
|
|
241
307
|
type: "object";
|
|
242
308
|
schema: z.core.JSONSchema.JSONSchema;
|
|
243
309
|
};
|
|
244
|
-
version?: number | undefined;
|
|
245
310
|
userId?: string | undefined;
|
|
246
311
|
metadata?: Record<string, unknown> | undefined;
|
|
247
312
|
}>>;
|
|
@@ -264,3 +329,9 @@ export type ChatRequestBody = z.infer<typeof chatRequestBodySchema>;
|
|
|
264
329
|
export type GenerationRequestBody = z.infer<typeof generationRequestBodySchema>;
|
|
265
330
|
export type ChatStreamErrorChunk = z.infer<typeof chatStreamErrorChunkSchema>;
|
|
266
331
|
export type PromptVariables = z.infer<typeof promptVariablesSchema>;
|
|
332
|
+
export type ChatFunctionDefinition = z.infer<typeof chatFunctionDefinitionSchema>;
|
|
333
|
+
export type ChatFunctionDefinitions = z.infer<typeof chatFunctionDefinitionsSchema>;
|
|
334
|
+
export type ChatFunctionCallEvent = z.infer<typeof chatFunctionCallEventSchema>;
|
|
335
|
+
export type ChatFunctionOutcome = z.infer<typeof chatFunctionOutcomeSchema>;
|
|
336
|
+
export type ClaimChatFunctionBody = z.infer<typeof claimChatFunctionBodySchema>;
|
|
337
|
+
export type ResolveChatFunctionBody = z.infer<typeof resolveChatFunctionBodySchema>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { agentIdSchema, promptIdSchema, sessionIdSchema, tenantIdSchema, turnIdSchema, } from "../ids.js";
|
|
3
|
-
import {
|
|
2
|
+
import { agentIdSchema, functionCallIdSchema, promptIdSchema, sessionIdSchema, tenantIdSchema, turnIdSchema, } from "../ids.js";
|
|
3
|
+
import { chatFunctionNameSchema } from "./agent-tools.js";
|
|
4
|
+
import { agentModelIdSchema } from "./agents.js";
|
|
4
5
|
import { metadataSchema, userIdSchema } from "./attribution.js";
|
|
5
6
|
export const chatModeSchema = z.enum(["create", "resume"]);
|
|
6
7
|
export const chatTriggerSchema = z.enum([
|
|
@@ -15,7 +16,6 @@ export const chatTriggerSchema = z.enum([
|
|
|
15
16
|
export const usageSummarySchema = z
|
|
16
17
|
.object({
|
|
17
18
|
agentId: agentIdSchema,
|
|
18
|
-
agentVersion: agentVersionNumberSchema,
|
|
19
19
|
commitId: z.string().trim().min(1),
|
|
20
20
|
completedAt: z.iso.datetime({ offset: true }),
|
|
21
21
|
durationMs: z.number().int().min(0),
|
|
@@ -60,41 +60,6 @@ export const blazingAgentsChatMessageMetadataSchema = z
|
|
|
60
60
|
* against the template (missing or unknown variable → 400 invalid_request).
|
|
61
61
|
*/
|
|
62
62
|
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
63
|
const JSON_SCHEMA_COMPOSITION_KEYS = ["allOf", "anyOf", "oneOf"];
|
|
99
64
|
function hasMeaningfulSchemaRoot(value, definitions, seenReferences) {
|
|
100
65
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
@@ -152,6 +117,108 @@ export const jsonSchemaShapeSchema = z.custom((value) => {
|
|
|
152
117
|
return false;
|
|
153
118
|
}
|
|
154
119
|
}, { message: "schema contains an unsupported or invalid JSON Schema feature" });
|
|
120
|
+
export const MAX_CHAT_FUNCTIONS = 32;
|
|
121
|
+
export const MAX_CHAT_FUNCTION_DEFINITIONS_BYTES = 64 * 1024;
|
|
122
|
+
export const MAX_CHAT_FUNCTION_PAYLOAD_BYTES = 256 * 1024;
|
|
123
|
+
export const jsonByteLength = (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
124
|
+
/** One caller-local function as sent to Blazing Agents: description and JSON Schema only. */
|
|
125
|
+
export const chatFunctionDefinitionSchema = z
|
|
126
|
+
.object({
|
|
127
|
+
description: z.string().trim().min(1),
|
|
128
|
+
inputSchema: jsonSchemaShapeSchema.refine((schema) => typeof schema === "object" && schema.type === "object", { message: "Function input schema must describe a JSON object." }),
|
|
129
|
+
})
|
|
130
|
+
.strict();
|
|
131
|
+
export const chatFunctionDefinitionsSchema = z
|
|
132
|
+
.record(chatFunctionNameSchema, chatFunctionDefinitionSchema)
|
|
133
|
+
.refine((functions) => Object.keys(functions).length <= MAX_CHAT_FUNCTIONS, {
|
|
134
|
+
message: `At most ${MAX_CHAT_FUNCTIONS} functions are allowed.`,
|
|
135
|
+
})
|
|
136
|
+
.refine((functions) => jsonByteLength(functions) <= MAX_CHAT_FUNCTION_DEFINITIONS_BYTES, {
|
|
137
|
+
message: `Function definitions must not exceed ${MAX_CHAT_FUNCTION_DEFINITIONS_BYTES} bytes.`,
|
|
138
|
+
});
|
|
139
|
+
/**
|
|
140
|
+
* Transient UI data part that authorizes one claim attempt for a function
|
|
141
|
+
* call. The SDK consumes it and never forwards it to the browser.
|
|
142
|
+
*/
|
|
143
|
+
export const chatFunctionCallEventSchema = z
|
|
144
|
+
.object({
|
|
145
|
+
type: z.literal("data-ba-function-call"),
|
|
146
|
+
data: z
|
|
147
|
+
.object({
|
|
148
|
+
id: functionCallIdSchema,
|
|
149
|
+
name: chatFunctionNameSchema,
|
|
150
|
+
input: z.json(),
|
|
151
|
+
deadlineAt: z.iso.datetime({ offset: true }),
|
|
152
|
+
})
|
|
153
|
+
.strip(),
|
|
154
|
+
transient: z.literal(true),
|
|
155
|
+
})
|
|
156
|
+
.strip();
|
|
157
|
+
export const chatFunctionOutcomeSchema = z
|
|
158
|
+
.discriminatedUnion("kind", [
|
|
159
|
+
z.object({ kind: z.literal("output"), value: z.json() }).strict(),
|
|
160
|
+
z
|
|
161
|
+
.object({
|
|
162
|
+
kind: z.literal("error"),
|
|
163
|
+
message: z.string().min(1).max(4096),
|
|
164
|
+
})
|
|
165
|
+
.strict(),
|
|
166
|
+
])
|
|
167
|
+
.refine((outcome) => jsonByteLength(outcome) <= MAX_CHAT_FUNCTION_PAYLOAD_BYTES, {
|
|
168
|
+
message: `Function outcome must not exceed ${MAX_CHAT_FUNCTION_PAYLOAD_BYTES} bytes.`,
|
|
169
|
+
});
|
|
170
|
+
/** `POST .../function-calls/{functionCallId}/claim` body. */
|
|
171
|
+
export const claimChatFunctionBodySchema = z
|
|
172
|
+
.object({ claimRequestId: z.uuid() })
|
|
173
|
+
.strict();
|
|
174
|
+
export const claimChatFunctionResponseSchema = z
|
|
175
|
+
.object({ claimed: z.literal(true) })
|
|
176
|
+
.strip();
|
|
177
|
+
/** `POST .../function-calls/{functionCallId}/result` body. */
|
|
178
|
+
export const resolveChatFunctionBodySchema = z
|
|
179
|
+
.object({ claimRequestId: z.uuid(), outcome: chatFunctionOutcomeSchema })
|
|
180
|
+
.strict();
|
|
181
|
+
export const resolveChatFunctionResponseSchema = z
|
|
182
|
+
.object({ accepted: z.literal(true) })
|
|
183
|
+
.strip();
|
|
184
|
+
/** `POST .../tool-approval-continuations/{continuationId}/resume` body. */
|
|
185
|
+
export const resumeToolApprovalContinuationBodySchema = z.object({}).strict();
|
|
186
|
+
/**
|
|
187
|
+
* `POST /v1/agents/{agentId}/sessions` (create) and
|
|
188
|
+
* `POST /v1/agents/{agentId}/sessions/{sessionId}` (resume) request body.
|
|
189
|
+
* The URL selects the mode; on create the platform mints the `ss_` id and
|
|
190
|
+
* returns it in `Location`. Exactly one of `message` or `promptId` is
|
|
191
|
+
* required, and `variables` requires `promptId`. Regenerate is resume-only,
|
|
192
|
+
* enforced by the route layer rather than this schema.
|
|
193
|
+
*/
|
|
194
|
+
export const chatRequestBodySchema = z
|
|
195
|
+
.object({
|
|
196
|
+
/**
|
|
197
|
+
* AI SDK owns the runtime UIMessage schema. Core keeps this wire field
|
|
198
|
+
* unknown; the HTTP boundary validates it with `safeValidateUIMessages`
|
|
199
|
+
* before treating it as a UIMessage.
|
|
200
|
+
*/
|
|
201
|
+
message: z.unknown().optional(),
|
|
202
|
+
promptId: promptIdSchema.optional(),
|
|
203
|
+
variables: promptVariablesSchema.optional(),
|
|
204
|
+
trigger: chatTriggerSchema.default("submit-message"),
|
|
205
|
+
messageId: z.string().min(1).optional(),
|
|
206
|
+
/**
|
|
207
|
+
* End-user attribution (ADR-0001), stamped on the Session at lazy
|
|
208
|
+
* materialization and on every usage row this Turn records.
|
|
209
|
+
*/
|
|
210
|
+
userId: userIdSchema.default(""),
|
|
211
|
+
metadata: metadataSchema.default({}),
|
|
212
|
+
/** Caller-local functions for this invocation; handlers stay in the caller's backend. */
|
|
213
|
+
functions: chatFunctionDefinitionsSchema.optional(),
|
|
214
|
+
})
|
|
215
|
+
.strict()
|
|
216
|
+
.refine((body) => body.message === undefined
|
|
217
|
+
? body.promptId !== undefined
|
|
218
|
+
: body.promptId === undefined && body.variables === undefined, {
|
|
219
|
+
message: "Provide either `message` or `promptId` (+`variables`); they are mutually exclusive, and `variables` is only allowed with `promptId`.",
|
|
220
|
+
path: ["message"],
|
|
221
|
+
});
|
|
155
222
|
/**
|
|
156
223
|
* `POST /v1/agents/{agentId}/generation` — the single stateless generation
|
|
157
224
|
* boundary. Output selection is explicit on the wire while prompt selection
|
|
@@ -168,7 +235,6 @@ export const generationRequestBodySchema = z
|
|
|
168
235
|
.object({ type: z.literal("object"), schema: jsonSchemaShapeSchema })
|
|
169
236
|
.strict(),
|
|
170
237
|
]),
|
|
171
|
-
version: agentVersionNumberSchema.optional(),
|
|
172
238
|
userId: userIdSchema.default(""),
|
|
173
239
|
metadata: metadataSchema.default({}),
|
|
174
240
|
})
|
|
@@ -92,12 +92,8 @@ export declare const providerModelsResponseSchema: z.ZodObject<{
|
|
|
92
92
|
}, z.core.$strip>>;
|
|
93
93
|
}, z.core.$strip>;
|
|
94
94
|
export declare const providerHistoricalUseDetailsSchema: z.ZodObject<{
|
|
95
|
-
agentVersions: z.ZodArray<z.ZodObject<{
|
|
96
|
-
agentId: z.ZodString;
|
|
97
|
-
version: z.ZodNumber;
|
|
98
|
-
}, z.core.$strip>>;
|
|
99
95
|
sessionIds: z.ZodArray<z.ZodString>;
|
|
100
|
-
|
|
96
|
+
taskRunIds: z.ZodArray<z.ZodString>;
|
|
101
97
|
}, z.core.$strip>;
|
|
102
98
|
/**
|
|
103
99
|
* `POST /v1/providers` — name, type, optional base URL, and the API key
|
|
@@ -128,7 +124,7 @@ export type ProviderModelsResponse = z.infer<typeof providerModelsResponseSchema
|
|
|
128
124
|
export type ProviderModel = ProviderModelsResponse["models"][number];
|
|
129
125
|
export type ProviderHistoricalUseDetails = z.infer<typeof providerHistoricalUseDetailsSchema>;
|
|
130
126
|
export interface DeleteProviderOptions {
|
|
131
|
-
|
|
127
|
+
confirmSnapshotInvalidation?: boolean;
|
|
132
128
|
}
|
|
133
129
|
export type ProviderResponse = z.infer<typeof providerResponseSchema>;
|
|
134
130
|
export type CreateProviderBody = z.infer<typeof createProviderBodySchema>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
2
|
+
import { providerIdSchema, providerKeyFragmentSchema, sessionIdSchema, taskRunIdSchema, tenantIdSchema, } from "../ids.js";
|
|
3
3
|
import { MAX_PROVIDER_NAME_LENGTH } from "../limitations.js";
|
|
4
|
-
import { agentVersionNumberSchema } from "./agents.js";
|
|
5
4
|
/**
|
|
6
5
|
* Provider type — the enum of model providers we support. Selects catalog
|
|
7
6
|
* discovery and AI SDK model behavior.
|
|
@@ -73,14 +72,8 @@ export const providerModelsResponseSchema = z
|
|
|
73
72
|
.strip();
|
|
74
73
|
export const providerHistoricalUseDetailsSchema = z
|
|
75
74
|
.object({
|
|
76
|
-
agentVersions: z.array(z
|
|
77
|
-
.object({
|
|
78
|
-
agentId: agentIdSchema,
|
|
79
|
-
version: agentVersionNumberSchema,
|
|
80
|
-
})
|
|
81
|
-
.strip()),
|
|
82
75
|
sessionIds: z.array(sessionIdSchema),
|
|
83
|
-
|
|
76
|
+
taskRunIds: z.array(taskRunIdSchema),
|
|
84
77
|
})
|
|
85
78
|
.strip();
|
|
86
79
|
/**
|
|
@@ -4,7 +4,6 @@ import { z } from "zod";
|
|
|
4
4
|
* leak to the wire; `userId`/`metadata` come from the first successful Turn.
|
|
5
5
|
*/
|
|
6
6
|
export declare const sessionListItemSchema: z.ZodObject<{
|
|
7
|
-
agentVersion: z.ZodNullable<z.ZodNumber>;
|
|
8
7
|
id: z.ZodString;
|
|
9
8
|
messageCount: z.ZodNumber;
|
|
10
9
|
lastMessagePreview: z.ZodNullable<z.ZodString>;
|
|
@@ -15,7 +14,6 @@ export declare const sessionListItemSchema: z.ZodObject<{
|
|
|
15
14
|
}, z.core.$strip>;
|
|
16
15
|
export declare const sessionsListResponseSchema: z.ZodObject<{
|
|
17
16
|
data: z.ZodArray<z.ZodObject<{
|
|
18
|
-
agentVersion: z.ZodNullable<z.ZodNumber>;
|
|
19
17
|
id: z.ZodString;
|
|
20
18
|
messageCount: z.ZodNumber;
|
|
21
19
|
lastMessagePreview: z.ZodNullable<z.ZodString>;
|
|
@@ -26,14 +24,117 @@ export declare const sessionsListResponseSchema: z.ZodObject<{
|
|
|
26
24
|
}, z.core.$strip>>;
|
|
27
25
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
28
26
|
}, z.core.$strip>;
|
|
27
|
+
export declare const sessionResponseSchema: z.ZodObject<{
|
|
28
|
+
id: z.ZodString;
|
|
29
|
+
messageCount: z.ZodNumber;
|
|
30
|
+
lastMessagePreview: z.ZodNullable<z.ZodString>;
|
|
31
|
+
userId: z.ZodString;
|
|
32
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
33
|
+
createdAt: z.ZodISODateTime;
|
|
34
|
+
updatedAt: z.ZodISODateTime;
|
|
35
|
+
agentConfig: z.ZodObject<{
|
|
36
|
+
approvalInChat: z.ZodDefault<z.ZodObject<{
|
|
37
|
+
default: z.ZodEnum<{
|
|
38
|
+
auto: "auto";
|
|
39
|
+
deny: "deny";
|
|
40
|
+
full: "full";
|
|
41
|
+
manual: "manual";
|
|
42
|
+
}>;
|
|
43
|
+
overrides: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
44
|
+
tool: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
45
|
+
type: z.ZodLiteral<"builtin">;
|
|
46
|
+
name: z.ZodEnum<{
|
|
47
|
+
activate_skill: "activate_skill";
|
|
48
|
+
bash: "bash";
|
|
49
|
+
delete_memory: "delete_memory";
|
|
50
|
+
edit: "edit";
|
|
51
|
+
get_memory: "get_memory";
|
|
52
|
+
glob: "glob";
|
|
53
|
+
grep: "grep";
|
|
54
|
+
publish_artifacts: "publish_artifacts";
|
|
55
|
+
read: "read";
|
|
56
|
+
save_memory: "save_memory";
|
|
57
|
+
search_memories: "search_memories";
|
|
58
|
+
update_memory: "update_memory";
|
|
59
|
+
write: "write";
|
|
60
|
+
write_todos: "write_todos";
|
|
61
|
+
}>;
|
|
62
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
63
|
+
type: z.ZodLiteral<"mcp">;
|
|
64
|
+
connectionId: z.ZodString;
|
|
65
|
+
name: z.ZodString;
|
|
66
|
+
}, z.core.$strict>], "type">;
|
|
67
|
+
decision: z.ZodEnum<{
|
|
68
|
+
auto: "auto";
|
|
69
|
+
deny: "deny";
|
|
70
|
+
full: "full";
|
|
71
|
+
manual: "manual";
|
|
72
|
+
}>;
|
|
73
|
+
}, z.core.$strict>>>;
|
|
74
|
+
}, z.core.$strict>>;
|
|
75
|
+
approvalInTasks: z.ZodDefault<z.ZodObject<{
|
|
76
|
+
default: z.ZodEnum<{
|
|
77
|
+
auto: "auto";
|
|
78
|
+
deny: "deny";
|
|
79
|
+
full: "full";
|
|
80
|
+
manual: "manual";
|
|
81
|
+
}>;
|
|
82
|
+
overrides: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
83
|
+
tool: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
84
|
+
type: z.ZodLiteral<"builtin">;
|
|
85
|
+
name: z.ZodEnum<{
|
|
86
|
+
activate_skill: "activate_skill";
|
|
87
|
+
bash: "bash";
|
|
88
|
+
delete_memory: "delete_memory";
|
|
89
|
+
edit: "edit";
|
|
90
|
+
get_memory: "get_memory";
|
|
91
|
+
glob: "glob";
|
|
92
|
+
grep: "grep";
|
|
93
|
+
publish_artifacts: "publish_artifacts";
|
|
94
|
+
read: "read";
|
|
95
|
+
save_memory: "save_memory";
|
|
96
|
+
search_memories: "search_memories";
|
|
97
|
+
update_memory: "update_memory";
|
|
98
|
+
write: "write";
|
|
99
|
+
write_todos: "write_todos";
|
|
100
|
+
}>;
|
|
101
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
102
|
+
type: z.ZodLiteral<"mcp">;
|
|
103
|
+
connectionId: z.ZodString;
|
|
104
|
+
name: z.ZodString;
|
|
105
|
+
}, z.core.$strict>], "type">;
|
|
106
|
+
decision: z.ZodEnum<{
|
|
107
|
+
auto: "auto";
|
|
108
|
+
deny: "deny";
|
|
109
|
+
full: "full";
|
|
110
|
+
manual: "manual";
|
|
111
|
+
}>;
|
|
112
|
+
}, z.core.$strict>>>;
|
|
113
|
+
}, z.core.$strict>>;
|
|
114
|
+
name: z.ZodString;
|
|
115
|
+
model: z.ZodNullable<z.ZodString>;
|
|
116
|
+
thinkingLevel: z.ZodNullable<z.ZodString>;
|
|
117
|
+
providerId: z.ZodNullable<z.ZodString>;
|
|
118
|
+
autoCompaction: z.ZodBoolean;
|
|
119
|
+
compactionReserveTokens: z.ZodNumber;
|
|
120
|
+
memoryInjectionEnabled: z.ZodBoolean;
|
|
121
|
+
tools: z.ZodArray<z.ZodEnum<{
|
|
122
|
+
memory: "memory";
|
|
123
|
+
workspace: "workspace";
|
|
124
|
+
write_todos: "write_todos";
|
|
125
|
+
}>>;
|
|
126
|
+
instructions: z.ZodString;
|
|
127
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
128
|
+
mcpConnectionIds: z.ZodArray<z.ZodString>;
|
|
129
|
+
}, z.core.$strip>;
|
|
130
|
+
}, z.core.$strip>;
|
|
29
131
|
/**
|
|
30
132
|
* `GET /v1/sessions/latest` list item — one per Agent: the Agent's most
|
|
31
133
|
* recently updated Session (optionally among one end user's Sessions).
|
|
32
134
|
* Carries `agentId` and the Agent's current model, Thinking level, and status,
|
|
33
|
-
* independently of the Session's
|
|
135
|
+
* independently of the Session's saved configuration.
|
|
34
136
|
*/
|
|
35
137
|
export declare const latestSessionListItemSchema: z.ZodObject<{
|
|
36
|
-
agentVersion: z.ZodNullable<z.ZodNumber>;
|
|
37
138
|
id: z.ZodString;
|
|
38
139
|
messageCount: z.ZodNumber;
|
|
39
140
|
lastMessagePreview: z.ZodNullable<z.ZodString>;
|
|
@@ -51,7 +152,6 @@ export declare const latestSessionListItemSchema: z.ZodObject<{
|
|
|
51
152
|
}, z.core.$strip>;
|
|
52
153
|
export declare const latestSessionsListResponseSchema: z.ZodObject<{
|
|
53
154
|
data: z.ZodArray<z.ZodObject<{
|
|
54
|
-
agentVersion: z.ZodNullable<z.ZodNumber>;
|
|
55
155
|
id: z.ZodString;
|
|
56
156
|
messageCount: z.ZodNumber;
|
|
57
157
|
lastMessagePreview: z.ZodNullable<z.ZodString>;
|
|
@@ -151,6 +251,9 @@ export declare const toolApprovalStateSchema: z.ZodObject<{
|
|
|
151
251
|
type: z.ZodLiteral<"mcp">;
|
|
152
252
|
connectionId: z.ZodString;
|
|
153
253
|
name: z.ZodString;
|
|
254
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
255
|
+
type: z.ZodLiteral<"function">;
|
|
256
|
+
name: z.ZodString;
|
|
154
257
|
}, z.core.$strict>], "type">>>;
|
|
155
258
|
assistantMessageId: z.ZodOptional<z.ZodString>;
|
|
156
259
|
createdAt: z.ZodOptional<z.ZodISODateTime>;
|
|
@@ -200,6 +303,9 @@ export declare const toolApprovalsResponseSchema: z.ZodObject<{
|
|
|
200
303
|
type: z.ZodLiteral<"mcp">;
|
|
201
304
|
connectionId: z.ZodString;
|
|
202
305
|
name: z.ZodString;
|
|
306
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
307
|
+
type: z.ZodLiteral<"function">;
|
|
308
|
+
name: z.ZodString;
|
|
203
309
|
}, z.core.$strict>], "type">>>;
|
|
204
310
|
assistantMessageId: z.ZodOptional<z.ZodString>;
|
|
205
311
|
createdAt: z.ZodOptional<z.ZodISODateTime>;
|
|
@@ -237,6 +343,7 @@ export declare const toolApprovalDecisionResponseSchema: z.ZodObject<{
|
|
|
237
343
|
}>;
|
|
238
344
|
}, z.core.$strip>;
|
|
239
345
|
export type SessionListItem = z.infer<typeof sessionListItemSchema>;
|
|
346
|
+
export type SessionResponse = z.infer<typeof sessionResponseSchema>;
|
|
240
347
|
export type SessionsListResponse = z.infer<typeof sessionsListResponseSchema>;
|
|
241
348
|
export type LatestSessionListItem = z.infer<typeof latestSessionListItemSchema>;
|
|
242
349
|
export type LatestSessionsListResponse = z.infer<typeof latestSessionsListResponseSchema>;
|
|
@@ -2,8 +2,8 @@ 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 {
|
|
6
|
-
import {
|
|
5
|
+
import { toolExecutionReferenceSchema } from "./agent-approval.js";
|
|
6
|
+
import { agentConfigSchema, agentSchema } from "./agents.js";
|
|
7
7
|
import { metadataSchema, userIdSchema } from "./attribution.js";
|
|
8
8
|
/**
|
|
9
9
|
* `GET /v1/agents/{agentId}/sessions` list item. `agentId`/`tenantId` never
|
|
@@ -11,7 +11,6 @@ import { metadataSchema, userIdSchema } from "./attribution.js";
|
|
|
11
11
|
*/
|
|
12
12
|
export const sessionListItemSchema = z
|
|
13
13
|
.object({
|
|
14
|
-
agentVersion: agentVersionNumberSchema.nullable(),
|
|
15
14
|
id: sessionIdSchema,
|
|
16
15
|
messageCount: z.number().int().nonnegative(),
|
|
17
16
|
lastMessagePreview: z.string().nullable(),
|
|
@@ -22,11 +21,14 @@ export const sessionListItemSchema = z
|
|
|
22
21
|
})
|
|
23
22
|
.strip();
|
|
24
23
|
export const sessionsListResponseSchema = paginatedResponseSchema(sessionListItemSchema);
|
|
24
|
+
export const sessionResponseSchema = sessionListItemSchema
|
|
25
|
+
.extend({ agentConfig: agentConfigSchema })
|
|
26
|
+
.strip();
|
|
25
27
|
/**
|
|
26
28
|
* `GET /v1/sessions/latest` list item — one per Agent: the Agent's most
|
|
27
29
|
* recently updated Session (optionally among one end user's Sessions).
|
|
28
30
|
* Carries `agentId` and the Agent's current model, Thinking level, and status,
|
|
29
|
-
* independently of the Session's
|
|
31
|
+
* independently of the Session's saved configuration.
|
|
30
32
|
*/
|
|
31
33
|
export const latestSessionListItemSchema = sessionListItemSchema
|
|
32
34
|
.extend({
|
|
@@ -104,7 +106,7 @@ export const toolApprovalContinuationStateSchema = z.enum([
|
|
|
104
106
|
]);
|
|
105
107
|
export const toolApprovalStateSchema = z
|
|
106
108
|
.object({
|
|
107
|
-
tool:
|
|
109
|
+
tool: toolExecutionReferenceSchema.nullable().optional(),
|
|
108
110
|
assistantMessageId: z.string().min(1).optional(),
|
|
109
111
|
createdAt: z.iso.datetime({ offset: true }).optional(),
|
|
110
112
|
decidedAt: z.iso.datetime({ offset: true }).nullable().optional(),
|