@blazingagents/sdk 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat-transport.js +4 -1
- package/dist/client.d.ts +18 -2
- package/dist/client.js +16 -15
- package/dist/contracts/entities/agents.d.ts +7 -6
- package/dist/contracts/entities/agents.js +129 -36
- package/dist/contracts/entities/chat-connections.d.ts +9 -8
- package/dist/contracts/entities/chat-connections.js +70 -40
- package/dist/contracts/entities/chat.d.ts +8 -4
- package/dist/contracts/entities/chat.js +102 -28
- package/dist/contracts/entities/mcp-connections.d.ts +2 -0
- package/dist/contracts/entities/mcp-connections.js +36 -23
- package/dist/contracts/entities/memories.d.ts +1 -0
- package/dist/contracts/entities/memories.js +5 -3
- package/dist/contracts/entities/merchant.js +28 -9
- package/dist/contracts/entities/prompts.d.ts +2 -2
- package/dist/contracts/entities/prompts.js +42 -15
- package/dist/contracts/entities/providers.js +14 -6
- package/dist/contracts/entities/sessions.d.ts +17 -15
- package/dist/contracts/entities/sessions.js +23 -10
- package/dist/contracts/entities/skills.js +6 -3
- package/dist/contracts/entities/spending-limits.d.ts +0 -23
- package/dist/contracts/entities/spending-limits.js +0 -9
- package/dist/contracts/entities/tasks.d.ts +4 -7
- package/dist/contracts/entities/tasks.js +45 -15
- package/dist/contracts/entities/tenants.d.ts +2 -28
- package/dist/contracts/entities/tenants.js +15 -22
- package/dist/contracts/entities/usage.d.ts +1 -1
- package/dist/contracts/entities/usage.js +16 -6
- package/dist/contracts/entities/workspaces.d.ts +1 -1
- package/dist/contracts/entities/workspaces.js +26 -10
- package/dist/contracts/index.d.ts +20 -15
- package/dist/contracts/index.js +13 -13
- package/dist/contracts/limitations.d.ts +2 -4
- package/dist/contracts/limitations.js +2 -4
- package/dist/direct-chat-transport.js +2 -1
- package/dist/errors.d.ts +11 -0
- package/dist/errors.js +21 -0
- package/dist/http.d.ts +3 -1
- package/dist/http.js +12 -1
- package/dist/index.d.ts +20 -3
- package/dist/resources/agents.d.ts +120 -1
- package/dist/resources/agents.js +1 -33
- package/dist/resources/artifacts.d.ts +42 -1
- package/dist/resources/artifacts.js +0 -12
- package/dist/resources/chat-connections.d.ts +110 -1
- package/dist/resources/chat-connections.js +0 -33
- package/dist/resources/chat-deliveries.d.ts +23 -1
- package/dist/resources/chat-deliveries.js +1 -4
- package/dist/resources/mcp-connections.d.ts +63 -1
- package/dist/resources/mcp-connections.js +3 -21
- package/dist/resources/memories.d.ts +58 -1
- package/dist/resources/memories.js +0 -15
- package/dist/resources/merchant-bindings.d.ts +39 -1
- package/dist/resources/merchant-bindings.js +0 -9
- package/dist/resources/merchant-connection.d.ts +37 -1
- package/dist/resources/merchant-connection.js +1 -13
- package/dist/resources/merchant-usage-events.d.ts +66 -1
- package/dist/resources/merchant-usage-events.js +0 -18
- package/dist/resources/prompts.d.ts +50 -1
- package/dist/resources/prompts.js +0 -15
- package/dist/resources/providers.d.ts +64 -1
- package/dist/resources/providers.js +0 -21
- package/dist/resources/sessions.d.ts +124 -1
- package/dist/resources/sessions.js +5 -36
- package/dist/resources/skills.d.ts +95 -1
- package/dist/resources/skills.js +0 -27
- package/dist/resources/tasks.d.ts +107 -1
- package/dist/resources/tasks.js +0 -30
- package/dist/resources/tenant.d.ts +23 -1
- package/dist/resources/tenant.js +2 -10
- package/dist/resources/usage.d.ts +34 -1
- package/dist/resources/usage.js +2 -15
- package/dist/resources/workspaces.d.ts +50 -1
- package/dist/resources/workspaces.js +0 -15
- package/dist/types.d.ts +12 -1083
- package/package.json +1 -1
|
@@ -78,6 +78,7 @@ export declare const blazingAgentsChatMessageMetadataSchema: z.ZodObject<{
|
|
|
78
78
|
tenantId: z.ZodString;
|
|
79
79
|
userId: z.ZodString;
|
|
80
80
|
}, z.core.$strip>;
|
|
81
|
+
compactedContext: z.ZodOptional<z.ZodArray<z.ZodType<import("ai").ModelMessage, unknown, z.core.$ZodTypeInternals<import("ai").ModelMessage, unknown>>>>;
|
|
81
82
|
}, z.core.$strip>;
|
|
82
83
|
}, z.core.$strip>;
|
|
83
84
|
/**
|
|
@@ -183,10 +184,13 @@ export declare const chatRequestBodySchema: z.ZodObject<{
|
|
|
183
184
|
messageId: z.ZodOptional<z.ZodString>;
|
|
184
185
|
userId: z.ZodDefault<z.ZodString>;
|
|
185
186
|
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
186
|
-
functions: z.ZodOptional<z.
|
|
187
|
-
description:
|
|
188
|
-
inputSchema: z.
|
|
189
|
-
},
|
|
187
|
+
functions: z.ZodOptional<z.ZodCustom<Record<string, {
|
|
188
|
+
description: string;
|
|
189
|
+
inputSchema: z.core.JSONSchema.JSONSchema;
|
|
190
|
+
}>, Record<string, {
|
|
191
|
+
description: string;
|
|
192
|
+
inputSchema: z.core.JSONSchema.JSONSchema;
|
|
193
|
+
}>>>;
|
|
190
194
|
}, z.core.$strict> & z.ZodType<{
|
|
191
195
|
messages?: unknown[] | undefined;
|
|
192
196
|
promptId?: string | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { modelMessageSchema } from "ai";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { agentIdSchema, functionCallIdSchema, promptIdSchema, sessionIdSchema, tenantIdSchema, turnIdSchema, } from "../ids.js";
|
|
3
4
|
import { chatFunctionNameSchema } from "./agent-tools.js";
|
|
@@ -26,9 +27,8 @@ export const usageSummarySchema = z
|
|
|
26
27
|
errorMessage: z.string().nullable(),
|
|
27
28
|
inputTokens: z.number().int().min(0),
|
|
28
29
|
/**
|
|
29
|
-
* True only when every
|
|
30
|
-
*
|
|
31
|
-
* substituted for a missing measurement (ADR-0048).
|
|
30
|
+
* True only when every inference reported input/output totals; a zero is
|
|
31
|
+
* never substituted for a missing measurement (ADR-0048).
|
|
32
32
|
*/
|
|
33
33
|
measurementComplete: z.boolean(),
|
|
34
34
|
modelDurationMs: z.number().int().min(0),
|
|
@@ -54,7 +54,12 @@ export const usageSummarySchema = z
|
|
|
54
54
|
.strip();
|
|
55
55
|
export const blazingAgentsChatMessageMetadataSchema = z
|
|
56
56
|
.object({
|
|
57
|
-
blazingAgents: z
|
|
57
|
+
blazingAgents: z
|
|
58
|
+
.object({
|
|
59
|
+
usage: usageSummarySchema,
|
|
60
|
+
compactedContext: z.array(modelMessageSchema).optional(),
|
|
61
|
+
})
|
|
62
|
+
.strip(),
|
|
58
63
|
})
|
|
59
64
|
.strip();
|
|
60
65
|
/**
|
|
@@ -78,7 +83,10 @@ function hasMeaningfulSchemaRoot(value, definitions, seenReferences) {
|
|
|
78
83
|
}
|
|
79
84
|
const reference = schema.$ref;
|
|
80
85
|
if (typeof reference === "string" && reference.startsWith("#/$defs/")) {
|
|
81
|
-
const name = reference
|
|
86
|
+
const name = reference
|
|
87
|
+
.slice("#/$defs/".length)
|
|
88
|
+
.replaceAll("~1", "/")
|
|
89
|
+
.replaceAll("~0", "~");
|
|
82
90
|
if (!name || seenReferences.has(name) || !(name in definitions)) {
|
|
83
91
|
return false;
|
|
84
92
|
}
|
|
@@ -102,7 +110,8 @@ function hasMeaningfulSchemaRoot(value, definitions, seenReferences) {
|
|
|
102
110
|
* unions (for example, Pydantic's `int | None` TypeAdapter schema), and local
|
|
103
111
|
* `$ref` roots are needed for recursive Pydantic models.
|
|
104
112
|
*/
|
|
105
|
-
export const jsonSchemaShapeSchema = z
|
|
113
|
+
export const jsonSchemaShapeSchema = z
|
|
114
|
+
.custom((value) => {
|
|
106
115
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
107
116
|
return false;
|
|
108
117
|
}
|
|
@@ -123,7 +132,12 @@ export const jsonSchemaShapeSchema = z.custom((value) => {
|
|
|
123
132
|
catch {
|
|
124
133
|
return false;
|
|
125
134
|
}
|
|
126
|
-
}, { message: "schema contains an unsupported or invalid JSON Schema feature" })
|
|
135
|
+
}, { message: "schema contains an unsupported or invalid JSON Schema feature" })
|
|
136
|
+
/**
|
|
137
|
+
* `z.custom` is opaque to the OpenAPI generator; declare the honest wire
|
|
138
|
+
* shape (any JSON object) for the generated document.
|
|
139
|
+
*/
|
|
140
|
+
.meta({ type: "object" });
|
|
127
141
|
export const MAX_CHAT_FUNCTIONS = 32;
|
|
128
142
|
export const MAX_CHAT_FUNCTION_DEFINITIONS_BYTES = 64 * 1024;
|
|
129
143
|
export const MAX_CHAT_FUNCTION_PAYLOAD_BYTES = 256 * 1024;
|
|
@@ -202,23 +216,68 @@ export const resolveChatFunctionResponseSchema = z
|
|
|
202
216
|
export const chatRequestBodySchema = z
|
|
203
217
|
.object({
|
|
204
218
|
/**
|
|
205
|
-
* AI SDK owns the
|
|
206
|
-
*
|
|
207
|
-
* before treating it as a UIMessage.
|
|
219
|
+
* AI SDK owns the UIMessage schema; the HTTP boundary validates this with
|
|
220
|
+
* `safeValidateUIMessages`.
|
|
208
221
|
*/
|
|
209
|
-
messages: z
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
222
|
+
messages: z
|
|
223
|
+
.array(z.unknown())
|
|
224
|
+
.min(1)
|
|
225
|
+
.optional()
|
|
226
|
+
.describe('Ordered messages for one Turn, each an AI SDK `UIMessage` with `role: "user"`, an `id`, and non-empty `parts`. Parts can be text, or `file` parts with an `image/*` media type and a base64 `data:` URL. Send either `messages` or `promptId`.'),
|
|
227
|
+
promptId: promptIdSchema
|
|
228
|
+
.optional()
|
|
229
|
+
.describe("ID of a saved prompt to send instead of `messages`."),
|
|
230
|
+
variables: promptVariablesSchema
|
|
231
|
+
.optional()
|
|
232
|
+
.describe("Values for the saved prompt's variables. Allowed only with `promptId`, and must name exactly the prompt's variables."),
|
|
233
|
+
trigger: chatTriggerSchema
|
|
234
|
+
.default("submit-message")
|
|
235
|
+
.describe("`submit-message` (the default) sends a new message. `regenerate-message` generates the answer again and is allowed only when continuing a session."),
|
|
236
|
+
messageId: z
|
|
237
|
+
.string()
|
|
238
|
+
.min(1)
|
|
239
|
+
.optional()
|
|
240
|
+
.describe("With `regenerate-message`, the message to cut the conversation back to before the answer is generated again."),
|
|
214
241
|
/**
|
|
215
|
-
*
|
|
216
|
-
*
|
|
242
|
+
* Stamps the session row at lazy materialization and every
|
|
243
|
+
* `token_usage_*` row this turn records (ADR-0001).
|
|
217
244
|
*/
|
|
218
|
-
userId: userIdSchema
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
245
|
+
userId: userIdSchema
|
|
246
|
+
.default("")
|
|
247
|
+
.describe("Your end user's ID. Starting a session records it on the session, and every turn in that session keeps the session's end user."),
|
|
248
|
+
metadata: metadataSchema
|
|
249
|
+
.default({})
|
|
250
|
+
.describe("Your own key-value data. Recorded on a new session and on the turn's usage."),
|
|
251
|
+
/**
|
|
252
|
+
* `chatFunctionDefinitionsSchema` validates the value; `z.custom` is opaque
|
|
253
|
+
* to the OpenAPI generator, so `meta` declares the wire shape.
|
|
254
|
+
*/
|
|
255
|
+
functions: z
|
|
256
|
+
.custom((value) => typeof value === "object" && value !== null)
|
|
257
|
+
.check((context) => {
|
|
258
|
+
const result = chatFunctionDefinitionsSchema.safeParse(context.value);
|
|
259
|
+
if (!result.success) {
|
|
260
|
+
context.issues.push({
|
|
261
|
+
code: "custom",
|
|
262
|
+
input: context.value,
|
|
263
|
+
message: z.prettifyError(result.error),
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
})
|
|
267
|
+
.optional()
|
|
268
|
+
.meta({
|
|
269
|
+
additionalProperties: {
|
|
270
|
+
additionalProperties: false,
|
|
271
|
+
properties: {
|
|
272
|
+
description: { type: "string" },
|
|
273
|
+
inputSchema: { type: "object" },
|
|
274
|
+
},
|
|
275
|
+
required: ["description", "inputSchema"],
|
|
276
|
+
type: "object",
|
|
277
|
+
},
|
|
278
|
+
type: "object",
|
|
279
|
+
})
|
|
280
|
+
.describe("Caller-local functions the model may call during this turn, keyed by name; each entry has a `description` and a JSON Schema `inputSchema`. Your backend claims and answers each call through the function-call endpoints."),
|
|
222
281
|
})
|
|
223
282
|
.strict()
|
|
224
283
|
.refine((body) => body.messages === undefined
|
|
@@ -234,17 +293,32 @@ export const chatRequestBodySchema = z
|
|
|
234
293
|
*/
|
|
235
294
|
export const generationRequestBodySchema = z
|
|
236
295
|
.object({
|
|
237
|
-
prompt: z
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
296
|
+
prompt: z
|
|
297
|
+
.string()
|
|
298
|
+
.trim()
|
|
299
|
+
.min(1)
|
|
300
|
+
.optional()
|
|
301
|
+
.describe("The prompt to answer. Send either `prompt` or `promptId`."),
|
|
302
|
+
promptId: promptIdSchema
|
|
303
|
+
.optional()
|
|
304
|
+
.describe("ID of a saved prompt to use instead of `prompt`."),
|
|
305
|
+
variables: promptVariablesSchema
|
|
306
|
+
.optional()
|
|
307
|
+
.describe("Values for the saved prompt's variables. Allowed only with `promptId`, and must name exactly the prompt's variables."),
|
|
308
|
+
output: z
|
|
309
|
+
.discriminatedUnion("type", [
|
|
241
310
|
z.object({ type: z.literal("text") }).strict(),
|
|
242
311
|
z
|
|
243
312
|
.object({ type: z.literal("object"), schema: jsonSchemaShapeSchema })
|
|
244
313
|
.strict(),
|
|
245
|
-
])
|
|
246
|
-
|
|
247
|
-
|
|
314
|
+
])
|
|
315
|
+
.describe('What to stream back: `{"type":"text"}` for text, or `{"type":"object","schema":{…}}` for JSON that matches a JSON Schema.'),
|
|
316
|
+
userId: userIdSchema
|
|
317
|
+
.default("")
|
|
318
|
+
.describe("Your end user's ID, used for usage attribution."),
|
|
319
|
+
metadata: metadataSchema
|
|
320
|
+
.default({})
|
|
321
|
+
.describe("Your own key-value data, recorded with the usage."),
|
|
248
322
|
})
|
|
249
323
|
.strict()
|
|
250
324
|
.refine((body) => body.prompt === undefined
|
|
@@ -239,6 +239,8 @@ export declare const mcpConnectionReconnectResultSchema: z.ZodDiscriminatedUnion
|
|
|
239
239
|
}, z.core.$strip>], "status">;
|
|
240
240
|
export type McpConnectionAuthType = z.infer<typeof mcpConnectionAuthTypeSchema>;
|
|
241
241
|
export type McpConnectionStatus = z.infer<typeof mcpConnectionStatusSchema>;
|
|
242
|
+
export type McpConnectionTestErrorCode = z.infer<typeof mcpConnectionTestErrorCodeSchema>;
|
|
243
|
+
export type McpConnectionLiveDetails = z.infer<typeof mcpConnectionLiveDetailsSchema>;
|
|
242
244
|
export type McpConnectionResponse = z.infer<typeof mcpConnectionResponseSchema>;
|
|
243
245
|
export type McpConnectionsResponse = z.infer<typeof mcpConnectionsResponseSchema>;
|
|
244
246
|
export type CreateMcpConnectionBody = z.infer<typeof createMcpConnectionBodySchema>;
|
|
@@ -25,27 +25,33 @@ const mcpConnectionNameSchema = z
|
|
|
25
25
|
.trim()
|
|
26
26
|
.min(1)
|
|
27
27
|
.max(MAX_MCP_CONNECTION_NAME_LENGTH);
|
|
28
|
+
/** Request bodies describe the field; responses carry the bare value. */
|
|
29
|
+
const mcpConnectionNameInputSchema = mcpConnectionNameSchema.describe("Display name of the connection, unique within your tenant.");
|
|
28
30
|
const bearerTokenSchema = z
|
|
29
31
|
.string()
|
|
30
32
|
.min(1)
|
|
31
33
|
.max(MAX_MCP_BEARER_TOKEN_LENGTH)
|
|
32
|
-
.regex(/^[!-~]+$/, "Bearer token must contain visible ASCII characters only")
|
|
34
|
+
.regex(/^[!-~]+$/, "Bearer token must contain visible ASCII characters only")
|
|
35
|
+
.describe("Token sent as `Authorization: Bearer <token>` to the MCP server. Required when `authType` is `bearer`. Never returned.");
|
|
33
36
|
const oauthClientIdSchema = z
|
|
34
37
|
.string()
|
|
35
38
|
.min(1)
|
|
36
39
|
.max(MAX_MCP_OAUTH_CLIENT_ID_LENGTH)
|
|
37
|
-
.regex(/^[!-~]+$/, "Client ID must contain visible ASCII characters only")
|
|
40
|
+
.regex(/^[!-~]+$/, "Client ID must contain visible ASCII characters only")
|
|
41
|
+
.describe("OAuth client ID. Required with `clientSecret` for `oauth_client_credentials`. Optional for `oauth_authorization_code`, but send it together with `clientSecret`.");
|
|
38
42
|
const oauthClientSecretSchema = z
|
|
39
43
|
.string()
|
|
40
44
|
.min(1)
|
|
41
45
|
.max(MAX_MCP_OAUTH_CLIENT_SECRET_LENGTH)
|
|
42
|
-
.regex(/^[!-~]+$/, "Client secret must contain visible ASCII characters only")
|
|
46
|
+
.regex(/^[!-~]+$/, "Client secret must contain visible ASCII characters only")
|
|
47
|
+
.describe("OAuth client secret. Required with `clientId` for `oauth_client_credentials`. Optional for `oauth_authorization_code`, but send it together with `clientId`. Never returned.");
|
|
43
48
|
const oauthScopeSchema = z
|
|
44
49
|
.string()
|
|
45
50
|
.trim()
|
|
46
51
|
.min(1)
|
|
47
52
|
.max(MAX_MCP_OAUTH_SCOPE_LENGTH)
|
|
48
|
-
.regex(/^[\x20-\x7e]+$/, "Scope must contain printable ASCII characters only")
|
|
53
|
+
.regex(/^[\x20-\x7e]+$/, "Scope must contain printable ASCII characters only")
|
|
54
|
+
.describe("OAuth scope to request. Optional for either OAuth type.");
|
|
49
55
|
const credentialFragmentSchema = z.string().min(1).max(4).nullable();
|
|
50
56
|
const mcpConnectionUrlSchema = z
|
|
51
57
|
.string()
|
|
@@ -68,6 +74,8 @@ const mcpConnectionUrlSchema = z
|
|
|
68
74
|
message: "URL must use http(s) without credentials, query, or fragment",
|
|
69
75
|
})
|
|
70
76
|
.transform((value) => new URL(value).toString());
|
|
77
|
+
const mcpConnectionUrlInputSchema = mcpConnectionUrlSchema.describe("Streamable HTTP URL of the MCP server. Use `http` or `https`, with no credentials, query, or fragment.");
|
|
78
|
+
const authTypeDescription = "How Blazing Agents authenticates to the MCP server: `none`, `bearer`, `oauth_client_credentials`, or `oauth_authorization_code`. The other fields you send depend on it.";
|
|
71
79
|
export const mcpConnectionResponseSchema = z
|
|
72
80
|
.object({
|
|
73
81
|
id: mcpConnectionIdSchema,
|
|
@@ -111,8 +119,13 @@ export const mcpAttachmentsResponseSchema = z
|
|
|
111
119
|
.strip();
|
|
112
120
|
export const updateMcpAttachmentBodySchema = z
|
|
113
121
|
.object({
|
|
114
|
-
forwardUserId: z
|
|
115
|
-
|
|
122
|
+
forwardUserId: z
|
|
123
|
+
.boolean()
|
|
124
|
+
.optional()
|
|
125
|
+
.describe("Send the session's `userId` to the MCP server with every tool call."),
|
|
126
|
+
forwardedMetadataKeys: forwardedMetadataKeysSchema
|
|
127
|
+
.optional()
|
|
128
|
+
.describe("Session metadata keys whose values are sent to the MCP server with every tool call. Replaces the current list."),
|
|
116
129
|
})
|
|
117
130
|
.strict()
|
|
118
131
|
.refine(hasObjectKeys, {
|
|
@@ -120,43 +133,43 @@ export const updateMcpAttachmentBodySchema = z
|
|
|
120
133
|
});
|
|
121
134
|
const createNoneMcpConnectionBodySchema = z
|
|
122
135
|
.object({
|
|
123
|
-
name:
|
|
124
|
-
url:
|
|
125
|
-
authType: z.literal("none"),
|
|
136
|
+
name: mcpConnectionNameInputSchema,
|
|
137
|
+
url: mcpConnectionUrlInputSchema,
|
|
138
|
+
authType: z.literal("none").describe(authTypeDescription),
|
|
126
139
|
})
|
|
127
140
|
.strict();
|
|
128
141
|
const createBearerMcpConnectionBodySchema = z
|
|
129
142
|
.object({
|
|
130
|
-
name:
|
|
131
|
-
url:
|
|
132
|
-
authType: z.literal("bearer"),
|
|
143
|
+
name: mcpConnectionNameInputSchema,
|
|
144
|
+
url: mcpConnectionUrlInputSchema,
|
|
145
|
+
authType: z.literal("bearer").describe(authTypeDescription),
|
|
133
146
|
bearerToken: bearerTokenSchema,
|
|
134
147
|
})
|
|
135
148
|
.strict();
|
|
136
149
|
const oauthClientCredentialsFields = {
|
|
137
|
-
authType: z.literal("oauth_client_credentials"),
|
|
150
|
+
authType: z.literal("oauth_client_credentials").describe(authTypeDescription),
|
|
138
151
|
clientId: oauthClientIdSchema,
|
|
139
152
|
clientSecret: oauthClientSecretSchema,
|
|
140
153
|
scope: oauthScopeSchema.optional(),
|
|
141
|
-
url:
|
|
154
|
+
url: mcpConnectionUrlInputSchema,
|
|
142
155
|
};
|
|
143
156
|
const oauthAuthorizationCodeFields = {
|
|
144
|
-
authType: z.literal("oauth_authorization_code"),
|
|
157
|
+
authType: z.literal("oauth_authorization_code").describe(authTypeDescription),
|
|
145
158
|
clientId: oauthClientIdSchema.optional(),
|
|
146
159
|
clientSecret: oauthClientSecretSchema.optional(),
|
|
147
160
|
scope: oauthScopeSchema.optional(),
|
|
148
|
-
url:
|
|
161
|
+
url: mcpConnectionUrlInputSchema,
|
|
149
162
|
};
|
|
150
163
|
const createOauthAuthorizationCodeMcpConnectionBodySchema = z
|
|
151
164
|
.object({
|
|
152
165
|
...oauthAuthorizationCodeFields,
|
|
153
|
-
name:
|
|
166
|
+
name: mcpConnectionNameInputSchema,
|
|
154
167
|
})
|
|
155
168
|
.strict();
|
|
156
169
|
const createOauthClientCredentialsMcpConnectionBodySchema = z
|
|
157
170
|
.object({
|
|
158
171
|
...oauthClientCredentialsFields,
|
|
159
|
-
name:
|
|
172
|
+
name: mcpConnectionNameInputSchema,
|
|
160
173
|
})
|
|
161
174
|
.strict();
|
|
162
175
|
export const createMcpConnectionBodySchema = z
|
|
@@ -178,7 +191,7 @@ export const createMcpConnectionBodySchema = z
|
|
|
178
191
|
});
|
|
179
192
|
export const updateMcpConnectionBodySchema = z
|
|
180
193
|
.object({
|
|
181
|
-
name:
|
|
194
|
+
name: mcpConnectionNameInputSchema.optional(),
|
|
182
195
|
})
|
|
183
196
|
.strict()
|
|
184
197
|
.refine(hasObjectKeys, {
|
|
@@ -188,15 +201,15 @@ export const reconnectMcpConnectionBodySchema = z
|
|
|
188
201
|
.discriminatedUnion("authType", [
|
|
189
202
|
z
|
|
190
203
|
.object({
|
|
191
|
-
authType: z.literal("none"),
|
|
192
|
-
url:
|
|
204
|
+
authType: z.literal("none").describe(authTypeDescription),
|
|
205
|
+
url: mcpConnectionUrlInputSchema,
|
|
193
206
|
})
|
|
194
207
|
.strict(),
|
|
195
208
|
z
|
|
196
209
|
.object({
|
|
197
|
-
authType: z.literal("bearer"),
|
|
210
|
+
authType: z.literal("bearer").describe(authTypeDescription),
|
|
198
211
|
bearerToken: bearerTokenSchema,
|
|
199
|
-
url:
|
|
212
|
+
url: mcpConnectionUrlInputSchema,
|
|
200
213
|
})
|
|
201
214
|
.strict(),
|
|
202
215
|
z.object(oauthAuthorizationCodeFields).strict(),
|
|
@@ -42,6 +42,7 @@ export declare const createMemoryBodySchema: z.ZodObject<{
|
|
|
42
42
|
export declare const updateMemoryBodySchema: z.ZodObject<{
|
|
43
43
|
text: z.ZodString;
|
|
44
44
|
}, z.core.$strict>;
|
|
45
|
+
export type Memory = z.infer<typeof memorySchema>;
|
|
45
46
|
export type MemoryResponse = z.infer<typeof memoryResponseSchema>;
|
|
46
47
|
export type MemoriesListResponse = z.infer<typeof memoriesListResponseSchema>;
|
|
47
48
|
export type CreateMemoryBody = z.input<typeof createMemoryBodySchema>;
|
|
@@ -38,12 +38,14 @@ export const memoryResponseSchema = z
|
|
|
38
38
|
export const memoriesListResponseSchema = paginatedResponseSchema(memorySchema);
|
|
39
39
|
export const createMemoryBodySchema = z
|
|
40
40
|
.object({
|
|
41
|
-
text: memoryTextSchema,
|
|
42
|
-
userId: userIdSchema
|
|
41
|
+
text: memoryTextSchema.describe("The note to remember, up to 10 KiB."),
|
|
42
|
+
userId: userIdSchema
|
|
43
|
+
.default("")
|
|
44
|
+
.describe("The end user this memory belongs to. Only turns that pass the same `userId` see it. Leave it out or send an empty string for a general memory that every turn of the agent sees. It cannot change after creation."),
|
|
43
45
|
})
|
|
44
46
|
.strict();
|
|
45
47
|
export const updateMemoryBodySchema = z
|
|
46
48
|
.object({
|
|
47
|
-
text: memoryTextSchema,
|
|
49
|
+
text: memoryTextSchema.describe("Replacement text for the memory, up to 10 KiB."),
|
|
48
50
|
})
|
|
49
51
|
.strict();
|
|
@@ -48,17 +48,30 @@ export const merchantConnectionResponseSchema = z
|
|
|
48
48
|
.strip();
|
|
49
49
|
export const createMerchantConnectionBodySchema = z
|
|
50
50
|
.object({
|
|
51
|
-
provider: merchantProviderSchema,
|
|
52
|
-
environment: merchantEnvironmentSchema,
|
|
53
|
-
credential: z
|
|
54
|
-
|
|
51
|
+
provider: merchantProviderSchema.describe("Your billing provider: `polar` or `dodo`."),
|
|
52
|
+
environment: merchantEnvironmentSchema.describe("The provider environment to send usage to: `sandbox` or `live`."),
|
|
53
|
+
credential: z
|
|
54
|
+
.string()
|
|
55
|
+
.min(1)
|
|
56
|
+
.describe("A credential for your provider account: a Polar Organization Access Token, or a Dodo API key in the mode that matches `environment`. It is never returned."),
|
|
57
|
+
guard: merchantGuardSchema
|
|
58
|
+
.optional()
|
|
59
|
+
.describe("Check each end user's plan or balance with your provider before every turn starts. Off when left out."),
|
|
55
60
|
})
|
|
56
61
|
.strict();
|
|
57
62
|
export const updateMerchantConnectionBodySchema = z
|
|
58
63
|
.object({
|
|
59
|
-
credential: z
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
credential: z
|
|
65
|
+
.string()
|
|
66
|
+
.min(1)
|
|
67
|
+
.optional()
|
|
68
|
+
.describe("A replacement credential. It must belong to the same merchant account as the current one."),
|
|
69
|
+
status: merchantConnectionStatusSchema
|
|
70
|
+
.optional()
|
|
71
|
+
.describe("`active` sends usage events to your provider. While `disconnected`, deliveries fail and can be retried after you set it back to `active`, and turns are refused if the guard is on."),
|
|
72
|
+
guard: merchantGuardSchema
|
|
73
|
+
.optional()
|
|
74
|
+
.describe("The complete guard configuration, replacing the current one."),
|
|
62
75
|
})
|
|
63
76
|
.strict();
|
|
64
77
|
export const merchantCustomerBindingSchema = z
|
|
@@ -76,7 +89,12 @@ export const merchantBindingsResponseSchema = z
|
|
|
76
89
|
})
|
|
77
90
|
.strip();
|
|
78
91
|
export const upsertMerchantBindingBodySchema = z
|
|
79
|
-
.object({
|
|
92
|
+
.object({
|
|
93
|
+
customerId: z
|
|
94
|
+
.string()
|
|
95
|
+
.min(1)
|
|
96
|
+
.describe("The ID of the customer in your billing provider."),
|
|
97
|
+
})
|
|
80
98
|
.strict();
|
|
81
99
|
export const merchantBindingResponseSchema = z
|
|
82
100
|
.object({ binding: merchantCustomerBindingSchema })
|
|
@@ -182,7 +200,8 @@ export const merchantUsageSummaryQuerySchema = z
|
|
|
182
200
|
.int()
|
|
183
201
|
.min(1)
|
|
184
202
|
.max(MAX_MERCHANT_USAGE_SUMMARY_DAYS)
|
|
185
|
-
.default(DEFAULT_MERCHANT_USAGE_SUMMARY_DAYS)
|
|
203
|
+
.default(DEFAULT_MERCHANT_USAGE_SUMMARY_DAYS)
|
|
204
|
+
.describe(`UTC days in the \`daily\` series, ending today, from 1 to ${MAX_MERCHANT_USAGE_SUMMARY_DAYS}.`),
|
|
186
205
|
})
|
|
187
206
|
.strict();
|
|
188
207
|
export const merchantUsageSummaryResponseSchema = z
|
|
@@ -40,10 +40,10 @@ export declare const promptsResponseSchema: z.ZodObject<{
|
|
|
40
40
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
41
41
|
}, z.core.$strip>;
|
|
42
42
|
export declare const promptsListQuerySchema: z.ZodObject<{
|
|
43
|
-
cursor: z.ZodOptional<z.ZodString>;
|
|
44
|
-
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
45
43
|
userId: z.ZodOptional<z.ZodString>;
|
|
46
44
|
agentId: z.ZodOptional<z.ZodString>;
|
|
45
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
46
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
47
47
|
}, z.core.$strict>;
|
|
48
48
|
export declare const createPromptBodySchema: z.ZodObject<{
|
|
49
49
|
name: z.ZodString;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { cursorSchema, paginatedResponseSchema } from "../api.js";
|
|
3
3
|
import { agentIdSchema, promptIdSchema, tenantIdSchema } from "../ids.js";
|
|
4
|
-
import {
|
|
4
|
+
import { DEFAULT_RESOURCES_LIST_LIMIT, MAX_PROMPT_NAME_LENGTH, MAX_PROMPT_TEMPLATE_BYTES, MAX_PROMPT_VARIABLES, MAX_RESOURCES_LIST_LIMIT, } from "../limitations.js";
|
|
5
5
|
import { atLeastOneFieldMessage, hasObjectKeys } from "../utils.js";
|
|
6
6
|
import { metadataSchema, userIdSchema } from "./attribution.js";
|
|
7
7
|
export const promptVariableTokenPattern = /{{([\s\S]*?)}}/g;
|
|
@@ -66,34 +66,61 @@ export const promptResponseSchema = z
|
|
|
66
66
|
})
|
|
67
67
|
.strip();
|
|
68
68
|
export const promptsResponseSchema = paginatedResponseSchema(promptResponseSchema);
|
|
69
|
+
const promptFieldDescriptions = {
|
|
70
|
+
name: "Display name, 1 to 80 characters.",
|
|
71
|
+
template: "Message template, up to 10,240 characters. Mark each variable as `{{name}}`; names match `[A-Za-z_][A-Za-z0-9_]*`, and a template can use up to 10 of them.",
|
|
72
|
+
agentId: "ID of an agent in your tenant to link the prompt to, or `null` for no link. Deleting the agent also deletes its linked prompts.",
|
|
73
|
+
metadata: "Your own key-value data, returned unchanged.",
|
|
74
|
+
};
|
|
69
75
|
export const promptsListQuerySchema = z
|
|
70
76
|
.object({
|
|
71
|
-
|
|
77
|
+
userId: userIdSchema
|
|
78
|
+
.optional()
|
|
79
|
+
.describe("Return only prompts for this end user. Send an empty string for tenant-level prompts, or leave it out for all prompts."),
|
|
80
|
+
agentId: agentIdSchema
|
|
81
|
+
.optional()
|
|
82
|
+
.describe("Return only prompts linked to this agent."),
|
|
83
|
+
cursor: cursorSchema
|
|
84
|
+
.optional()
|
|
85
|
+
.describe("`nextCursor` from the previous page."),
|
|
72
86
|
limit: z.coerce
|
|
73
87
|
.number()
|
|
74
88
|
.int()
|
|
75
89
|
.min(1)
|
|
76
|
-
.max(
|
|
77
|
-
.default(
|
|
78
|
-
|
|
79
|
-
agentId: agentIdSchema.optional(),
|
|
90
|
+
.max(MAX_RESOURCES_LIST_LIMIT)
|
|
91
|
+
.default(DEFAULT_RESOURCES_LIST_LIMIT)
|
|
92
|
+
.describe("Maximum number of prompts to return."),
|
|
80
93
|
})
|
|
81
94
|
.strict();
|
|
82
95
|
export const createPromptBodySchema = z
|
|
83
96
|
.object({
|
|
84
|
-
name: promptNameSchema,
|
|
85
|
-
template: promptTemplateSchema,
|
|
86
|
-
agentId: agentIdSchema
|
|
87
|
-
|
|
88
|
-
|
|
97
|
+
name: promptNameSchema.describe(promptFieldDescriptions.name),
|
|
98
|
+
template: promptTemplateSchema.describe(promptFieldDescriptions.template),
|
|
99
|
+
agentId: agentIdSchema
|
|
100
|
+
.nullable()
|
|
101
|
+
.optional()
|
|
102
|
+
.describe(promptFieldDescriptions.agentId),
|
|
103
|
+
userId: userIdSchema
|
|
104
|
+
.default("")
|
|
105
|
+
.describe("Your end user's ID, used for attribution. An empty string means a tenant-level prompt. It cannot change after creation."),
|
|
106
|
+
metadata: metadataSchema
|
|
107
|
+
.default({})
|
|
108
|
+
.describe(promptFieldDescriptions.metadata),
|
|
89
109
|
})
|
|
90
110
|
.strict();
|
|
91
111
|
export const updatePromptBodySchema = z
|
|
92
112
|
.object({
|
|
93
|
-
agentId: agentIdSchema
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
113
|
+
agentId: agentIdSchema
|
|
114
|
+
.nullable()
|
|
115
|
+
.optional()
|
|
116
|
+
.describe(promptFieldDescriptions.agentId),
|
|
117
|
+
name: promptNameSchema.optional().describe(promptFieldDescriptions.name),
|
|
118
|
+
template: promptTemplateSchema
|
|
119
|
+
.optional()
|
|
120
|
+
.describe(promptFieldDescriptions.template),
|
|
121
|
+
metadata: metadataSchema
|
|
122
|
+
.optional()
|
|
123
|
+
.describe(`${promptFieldDescriptions.metadata} Replaces the current value.`),
|
|
97
124
|
})
|
|
98
125
|
.strict()
|
|
99
126
|
.refine(hasObjectKeys, {
|
|
@@ -52,7 +52,8 @@ export const providerModelsResponseSchema = z
|
|
|
52
52
|
})
|
|
53
53
|
.strip()),
|
|
54
54
|
})
|
|
55
|
-
.strip()
|
|
55
|
+
.strip()
|
|
56
|
+
.meta({ id: "ProviderModelList" });
|
|
56
57
|
/**
|
|
57
58
|
* `POST /v1/providers` — name, type, optional base URL, and the API key
|
|
58
59
|
* (plaintext, never stored — goes to Vault). `custom` providers require a
|
|
@@ -61,10 +62,17 @@ export const providerModelsResponseSchema = z
|
|
|
61
62
|
*/
|
|
62
63
|
export const createProviderBodySchema = z
|
|
63
64
|
.object({
|
|
64
|
-
name: providerNameSchema,
|
|
65
|
-
providerType: providerTypeSchema,
|
|
66
|
-
baseUrl: providerBaseUrlSchema
|
|
67
|
-
|
|
65
|
+
name: providerNameSchema.describe("Display name, unique within your tenant."),
|
|
66
|
+
providerType: providerTypeSchema.describe("The model vendor. Cannot be changed later."),
|
|
67
|
+
baseUrl: providerBaseUrlSchema
|
|
68
|
+
.nullable()
|
|
69
|
+
.default(null)
|
|
70
|
+
.describe("Endpoint override. Required for `custom`, not accepted for `vercel_ai_gateway`, and optional otherwise. Cannot be changed later."),
|
|
71
|
+
apiKey: z
|
|
72
|
+
.string()
|
|
73
|
+
.trim()
|
|
74
|
+
.min(1)
|
|
75
|
+
.describe("The vendor API key. It is stored encrypted, never returned, and cannot be changed later."),
|
|
68
76
|
})
|
|
69
77
|
.strict()
|
|
70
78
|
.refine((body) => body.providerType !== "custom" ||
|
|
@@ -79,7 +87,7 @@ export const createProviderBodySchema = z
|
|
|
79
87
|
/** `PATCH /v1/providers/{id}` — only the display name is mutable. */
|
|
80
88
|
export const updateProviderBodySchema = z
|
|
81
89
|
.object({
|
|
82
|
-
name: providerNameSchema,
|
|
90
|
+
name: providerNameSchema.describe("New display name, unique within your tenant."),
|
|
83
91
|
})
|
|
84
92
|
.strict();
|
|
85
93
|
export const thinkingLevelsResponseSchema = z
|