@blazingagents/sdk 0.19.0 → 0.21.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/README.md +17 -1
- package/dist/approvals.d.ts +4 -12
- package/dist/approvals.js +12 -13
- package/dist/chat-transport.d.ts +18 -1
- package/dist/chat-transport.js +16 -0
- package/dist/client.d.ts +28 -5
- package/dist/client.js +39 -7
- package/dist/contracts/api.d.ts +40 -6
- package/dist/contracts/api.js +30 -2
- package/dist/contracts/entities/agent-tools.d.ts +5 -2
- package/dist/contracts/entities/agent-tools.js +5 -2
- package/dist/contracts/entities/agents.d.ts +4 -0
- package/dist/contracts/entities/agents.js +9 -0
- package/dist/contracts/entities/chat.d.ts +11 -10
- package/dist/contracts/entities/chat.js +11 -7
- package/dist/contracts/entities/mcp-connections.d.ts +3 -1
- package/dist/contracts/entities/mcp-connections.js +3 -1
- package/dist/contracts/entities/prompts.d.ts +13 -0
- package/dist/contracts/entities/prompts.js +13 -0
- package/dist/contracts/entities/session-inputs.d.ts +29 -87
- package/dist/contracts/entities/session-inputs.js +21 -19
- package/dist/contracts/entities/sessions.d.ts +27 -17
- package/dist/contracts/entities/sessions.js +23 -8
- package/dist/contracts/entities/skills.d.ts +3 -0
- package/dist/contracts/entities/skills.js +3 -0
- package/dist/contracts/entities/tasks.d.ts +1 -0
- package/dist/contracts/entities/usage.d.ts +4 -1
- package/dist/contracts/entities/usage.js +7 -1
- package/dist/contracts/entities/workspaces.d.ts +17 -6
- package/dist/contracts/entities/workspaces.js +3 -7
- package/dist/contracts/ids.d.ts +31 -0
- package/dist/contracts/ids.js +34 -0
- package/dist/contracts/index.d.ts +7 -6
- package/dist/contracts/index.js +4 -4
- package/dist/contracts/utils.d.ts +10 -0
- package/dist/contracts/utils.js +10 -0
- package/dist/direct-chat-transport.d.ts +30 -3
- package/dist/direct-chat-transport.js +40 -35
- package/dist/errors.d.ts +9 -0
- package/dist/errors.js +9 -0
- package/dist/functions.d.ts +35 -2
- package/dist/functions.js +60 -4
- package/dist/generation.d.ts +34 -2
- package/dist/generation.js +97 -19
- package/dist/http.d.ts +26 -0
- package/dist/http.js +43 -0
- package/dist/index.d.ts +4 -4
- package/dist/relay.d.ts +26 -3
- package/dist/relay.js +25 -10
- package/dist/resources/agents.d.ts +5 -0
- package/dist/resources/agents.js +38 -0
- package/dist/resources/artifacts.d.ts +2 -0
- package/dist/resources/artifacts.js +14 -0
- package/dist/resources/chat-connections.d.ts +5 -0
- package/dist/resources/chat-connections.js +32 -0
- package/dist/resources/chat-deliveries.d.ts +2 -0
- package/dist/resources/chat-deliveries.js +5 -0
- package/dist/resources/mcp-connections.d.ts +5 -0
- package/dist/resources/mcp-connections.js +26 -0
- package/dist/resources/memories.d.ts +2 -0
- package/dist/resources/memories.js +17 -0
- package/dist/resources/merchant-bindings.d.ts +2 -0
- package/dist/resources/merchant-bindings.js +11 -0
- package/dist/resources/merchant-connection.d.ts +2 -0
- package/dist/resources/merchant-connection.js +14 -0
- package/dist/resources/merchant-usage-events.d.ts +2 -0
- package/dist/resources/merchant-usage-events.js +20 -0
- package/dist/resources/prompts.d.ts +5 -0
- package/dist/resources/prompts.js +20 -0
- package/dist/resources/providers.d.ts +2 -0
- package/dist/resources/providers.js +23 -0
- package/dist/resources/sessions.d.ts +2 -0
- package/dist/resources/sessions.js +42 -39
- package/dist/resources/skills.d.ts +5 -0
- package/dist/resources/skills.js +35 -0
- package/dist/resources/tasks.d.ts +2 -0
- package/dist/resources/tasks.js +32 -0
- package/dist/resources/tenant.d.ts +2 -0
- package/dist/resources/tenant.js +8 -0
- package/dist/resources/usage.d.ts +2 -0
- package/dist/resources/usage.js +14 -0
- package/dist/resources/workspaces.d.ts +5 -0
- package/dist/resources/workspaces.js +20 -0
- package/dist/types.d.ts +691 -48
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
/** Tool groups an Agent can attach. File operations use its
|
|
2
|
+
/** Tool groups an Agent can attach. File operations use its Workspace. */
|
|
3
3
|
export const agentToolGroupIds = [
|
|
4
4
|
"workspace",
|
|
5
5
|
"write_todos",
|
|
@@ -9,7 +9,7 @@ export const AGENT_TOOL_CATALOG = [
|
|
|
9
9
|
{
|
|
10
10
|
id: "workspace",
|
|
11
11
|
name: "File operations",
|
|
12
|
-
description: "Read, write, edit, search, and run shell commands in the attached
|
|
12
|
+
description: "Read, write, edit, search, and run shell commands in the attached Workspace.",
|
|
13
13
|
tools: [
|
|
14
14
|
"read",
|
|
15
15
|
"write",
|
|
@@ -39,6 +39,9 @@ export const AGENT_TOOL_CATALOG = [
|
|
|
39
39
|
],
|
|
40
40
|
},
|
|
41
41
|
];
|
|
42
|
+
/**
|
|
43
|
+
* Expands tool group names into their individual tool names.
|
|
44
|
+
*/
|
|
42
45
|
export function expandToolGroups(ids) {
|
|
43
46
|
const result = new Set();
|
|
44
47
|
for (const id of ids) {
|
|
@@ -518,6 +518,10 @@ export declare const createAgentBodySchema: z.ZodObject<{
|
|
|
518
518
|
thinkingLevel: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
519
519
|
providerId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
520
520
|
workspaceId: z.ZodOptional<z.ZodString>;
|
|
521
|
+
workspaceTier: z.ZodOptional<z.ZodEnum<{
|
|
522
|
+
core: "core";
|
|
523
|
+
plus: "plus";
|
|
524
|
+
}>>;
|
|
521
525
|
autoCompaction: z.ZodDefault<z.ZodBoolean>;
|
|
522
526
|
compactionReserveTokens: z.ZodDefault<z.ZodNumber>;
|
|
523
527
|
memoryInjectionEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -6,6 +6,7 @@ import { atLeastOneFieldMessage, hasObjectKeys, hasUniqueValues, } from "../util
|
|
|
6
6
|
import { approvalPolicySchema } from "./agent-approval.js";
|
|
7
7
|
import { agentToolGroupIds } from "./agent-tools.js";
|
|
8
8
|
import { metadataSchema, userIdSchema } from "./attribution.js";
|
|
9
|
+
import { workspaceTierSchema } from "./workspaces.js";
|
|
9
10
|
const approvalFields = {
|
|
10
11
|
approvalInChat: approvalPolicySchema.default({
|
|
11
12
|
default: "full",
|
|
@@ -35,6 +36,9 @@ export const agentMcpConnectionIdsSchema = z
|
|
|
35
36
|
});
|
|
36
37
|
export const agentStatusSchema = z.enum(["active", "disabled"]);
|
|
37
38
|
const providerModelPairMessage = "Provider and model must either both be set or both be null.";
|
|
39
|
+
/**
|
|
40
|
+
* Checks that provider and model selections are both present or both absent.
|
|
41
|
+
*/
|
|
38
42
|
function hasProviderModelPair(input) {
|
|
39
43
|
return (input.model === null) === (input.providerId === null);
|
|
40
44
|
}
|
|
@@ -114,6 +118,7 @@ export const createAgentBodySchema = z
|
|
|
114
118
|
thinkingLevel: z.string().min(1).nullable().default(null),
|
|
115
119
|
providerId: providerIdSchema.nullable().default(null),
|
|
116
120
|
workspaceId: workspaceIdSchema.optional(),
|
|
121
|
+
workspaceTier: workspaceTierSchema.optional(),
|
|
117
122
|
autoCompaction: z.boolean().default(true),
|
|
118
123
|
compactionReserveTokens: agentSchema.shape.compactionReserveTokens.default(16_384),
|
|
119
124
|
memoryInjectionEnabled: z.boolean().default(false),
|
|
@@ -124,6 +129,10 @@ export const createAgentBodySchema = z
|
|
|
124
129
|
mcpConnectionIds: agentMcpConnectionIdsSchema.default([]),
|
|
125
130
|
})
|
|
126
131
|
.strict()
|
|
132
|
+
.refine((input) => input.workspaceId === undefined || input.workspaceTier === undefined, {
|
|
133
|
+
message: "workspaceId and workspaceTier are mutually exclusive.",
|
|
134
|
+
path: ["workspaceTier"],
|
|
135
|
+
})
|
|
127
136
|
.refine(hasProviderModelPair, {
|
|
128
137
|
message: providerModelPairMessage,
|
|
129
138
|
path: ["providerId"],
|
|
@@ -110,6 +110,9 @@ export declare const jsonSchemaShapeSchema: z.ZodCustom<z.core.JSONSchema.JSONSc
|
|
|
110
110
|
export declare const MAX_CHAT_FUNCTIONS = 32;
|
|
111
111
|
export declare const MAX_CHAT_FUNCTION_DEFINITIONS_BYTES: number;
|
|
112
112
|
export declare const MAX_CHAT_FUNCTION_PAYLOAD_BYTES: number;
|
|
113
|
+
/**
|
|
114
|
+
* Measures the UTF-8 byte length of a JSON-serialized value.
|
|
115
|
+
*/
|
|
113
116
|
export declare const jsonByteLength: (value: unknown) => number;
|
|
114
117
|
/** One caller-local function as sent to Blazing Agents: description and JSON Schema only. */
|
|
115
118
|
export declare const chatFunctionDefinitionSchema: z.ZodObject<{
|
|
@@ -162,18 +165,16 @@ export declare const resolveChatFunctionBodySchema: z.ZodObject<{
|
|
|
162
165
|
export declare const resolveChatFunctionResponseSchema: z.ZodObject<{
|
|
163
166
|
accepted: z.ZodLiteral<true>;
|
|
164
167
|
}, z.core.$strip>;
|
|
165
|
-
/** `POST .../tool-approval-continuations/{continuationId}/resume` body. */
|
|
166
|
-
export declare const resumeToolApprovalContinuationBodySchema: z.ZodObject<{}, z.core.$strict>;
|
|
167
168
|
/**
|
|
168
169
|
* `POST /v1/agents/{agentId}/sessions` (create) and
|
|
169
170
|
* `POST /v1/agents/{agentId}/sessions/{sessionId}` (resume) request body.
|
|
170
171
|
* The URL selects the mode; on create the platform mints the `ss_` id and
|
|
171
|
-
* returns it in `Location`. Exactly one of `
|
|
172
|
+
* returns it in `Location`. Exactly one of `messages` or `promptId` is
|
|
172
173
|
* required, and `variables` requires `promptId`. Regenerate is resume-only,
|
|
173
174
|
* enforced by the route layer rather than this schema.
|
|
174
175
|
*/
|
|
175
176
|
export declare const chatRequestBodySchema: z.ZodObject<{
|
|
176
|
-
|
|
177
|
+
messages: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
177
178
|
promptId: z.ZodOptional<z.ZodString>;
|
|
178
179
|
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
179
180
|
trigger: z.ZodDefault<z.ZodEnum<{
|
|
@@ -188,7 +189,7 @@ export declare const chatRequestBodySchema: z.ZodObject<{
|
|
|
188
189
|
inputSchema: z.ZodCustom<z.core.JSONSchema.JSONSchema, z.core.JSONSchema.JSONSchema>;
|
|
189
190
|
}, z.core.$strict>>>;
|
|
190
191
|
}, z.core.$strict> & z.ZodType<{
|
|
191
|
-
|
|
192
|
+
messages?: unknown[] | undefined;
|
|
192
193
|
promptId?: string | undefined;
|
|
193
194
|
variables?: Record<string, string> | undefined;
|
|
194
195
|
trigger: "regenerate-message" | "submit-message";
|
|
@@ -200,9 +201,9 @@ export declare const chatRequestBodySchema: z.ZodObject<{
|
|
|
200
201
|
inputSchema: z.core.JSONSchema.JSONSchema;
|
|
201
202
|
}> | undefined;
|
|
202
203
|
} & ExclusivePromptInput<{
|
|
203
|
-
|
|
204
|
+
messages: unknown[];
|
|
204
205
|
}>, {
|
|
205
|
-
|
|
206
|
+
messages?: unknown[] | undefined;
|
|
206
207
|
promptId?: string | undefined;
|
|
207
208
|
variables?: Record<string, string> | undefined;
|
|
208
209
|
trigger?: "regenerate-message" | "submit-message" | undefined;
|
|
@@ -214,7 +215,7 @@ export declare const chatRequestBodySchema: z.ZodObject<{
|
|
|
214
215
|
inputSchema: z.core.JSONSchema.JSONSchema;
|
|
215
216
|
}> | undefined;
|
|
216
217
|
}, z.core.$ZodTypeInternals<{
|
|
217
|
-
|
|
218
|
+
messages?: unknown[] | undefined;
|
|
218
219
|
promptId?: string | undefined;
|
|
219
220
|
variables?: Record<string, string> | undefined;
|
|
220
221
|
trigger: "regenerate-message" | "submit-message";
|
|
@@ -226,9 +227,9 @@ export declare const chatRequestBodySchema: z.ZodObject<{
|
|
|
226
227
|
inputSchema: z.core.JSONSchema.JSONSchema;
|
|
227
228
|
}> | undefined;
|
|
228
229
|
} & ExclusivePromptInput<{
|
|
229
|
-
|
|
230
|
+
messages: unknown[];
|
|
230
231
|
}>, {
|
|
231
|
-
|
|
232
|
+
messages?: unknown[] | undefined;
|
|
232
233
|
promptId?: string | undefined;
|
|
233
234
|
variables?: Record<string, string> | undefined;
|
|
234
235
|
trigger?: "regenerate-message" | "submit-message" | undefined;
|
|
@@ -61,6 +61,9 @@ export const blazingAgentsChatMessageMetadataSchema = z
|
|
|
61
61
|
*/
|
|
62
62
|
export const promptVariablesSchema = z.record(z.string(), z.string());
|
|
63
63
|
const JSON_SCHEMA_COMPOSITION_KEYS = ["allOf", "anyOf", "oneOf"];
|
|
64
|
+
/**
|
|
65
|
+
* Checks whether the JSON Schema root contains a meaningful schema keyword.
|
|
66
|
+
*/
|
|
64
67
|
function hasMeaningfulSchemaRoot(value, definitions, seenReferences) {
|
|
65
68
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
66
69
|
return false;
|
|
@@ -120,6 +123,9 @@ export const jsonSchemaShapeSchema = z.custom((value) => {
|
|
|
120
123
|
export const MAX_CHAT_FUNCTIONS = 32;
|
|
121
124
|
export const MAX_CHAT_FUNCTION_DEFINITIONS_BYTES = 64 * 1024;
|
|
122
125
|
export const MAX_CHAT_FUNCTION_PAYLOAD_BYTES = 256 * 1024;
|
|
126
|
+
/**
|
|
127
|
+
* Measures the UTF-8 byte length of a JSON-serialized value.
|
|
128
|
+
*/
|
|
123
129
|
export const jsonByteLength = (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
124
130
|
/** One caller-local function as sent to Blazing Agents: description and JSON Schema only. */
|
|
125
131
|
export const chatFunctionDefinitionSchema = z
|
|
@@ -181,13 +187,11 @@ export const resolveChatFunctionBodySchema = z
|
|
|
181
187
|
export const resolveChatFunctionResponseSchema = z
|
|
182
188
|
.object({ accepted: z.literal(true) })
|
|
183
189
|
.strip();
|
|
184
|
-
/** `POST .../tool-approval-continuations/{continuationId}/resume` body. */
|
|
185
|
-
export const resumeToolApprovalContinuationBodySchema = z.object({}).strict();
|
|
186
190
|
/**
|
|
187
191
|
* `POST /v1/agents/{agentId}/sessions` (create) and
|
|
188
192
|
* `POST /v1/agents/{agentId}/sessions/{sessionId}` (resume) request body.
|
|
189
193
|
* The URL selects the mode; on create the platform mints the `ss_` id and
|
|
190
|
-
* returns it in `Location`. Exactly one of `
|
|
194
|
+
* returns it in `Location`. Exactly one of `messages` or `promptId` is
|
|
191
195
|
* required, and `variables` requires `promptId`. Regenerate is resume-only,
|
|
192
196
|
* enforced by the route layer rather than this schema.
|
|
193
197
|
*/
|
|
@@ -198,7 +202,7 @@ export const chatRequestBodySchema = z
|
|
|
198
202
|
* unknown; the HTTP boundary validates it with `safeValidateUIMessages`
|
|
199
203
|
* before treating it as a UIMessage.
|
|
200
204
|
*/
|
|
201
|
-
|
|
205
|
+
messages: z.array(z.unknown()).min(1).optional(),
|
|
202
206
|
promptId: promptIdSchema.optional(),
|
|
203
207
|
variables: promptVariablesSchema.optional(),
|
|
204
208
|
trigger: chatTriggerSchema.default("submit-message"),
|
|
@@ -213,11 +217,11 @@ export const chatRequestBodySchema = z
|
|
|
213
217
|
functions: chatFunctionDefinitionsSchema.optional(),
|
|
214
218
|
})
|
|
215
219
|
.strict()
|
|
216
|
-
.refine((body) => body.
|
|
220
|
+
.refine((body) => body.messages === undefined
|
|
217
221
|
? body.promptId !== undefined
|
|
218
222
|
: body.promptId === undefined && body.variables === undefined, {
|
|
219
|
-
message: "Provide either `
|
|
220
|
-
path: ["
|
|
223
|
+
message: "Provide either `messages` or `promptId` (+`variables`); they are mutually exclusive, and `variables` is only allowed with `promptId`.",
|
|
224
|
+
path: ["messages"],
|
|
221
225
|
});
|
|
222
226
|
/**
|
|
223
227
|
* `POST /v1/agents/{agentId}/generation` — the single stateless generation
|
|
@@ -16,7 +16,9 @@ export declare const mcpConnectionTestErrorCodeSchema: z.ZodEnum<{
|
|
|
16
16
|
MCP_CONNECTION_INVALID: "MCP_CONNECTION_INVALID";
|
|
17
17
|
MCP_CONNECTION_UNREACHABLE: "MCP_CONNECTION_UNREACHABLE";
|
|
18
18
|
}>;
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Mirrors the MCP SDK's SEP-2352 issuer-identity comparison.
|
|
21
|
+
*/
|
|
20
22
|
export declare function mcpOauthIssuersMatch(a: string, b: string): boolean;
|
|
21
23
|
export declare const mcpOauthClientCredentialsBundleSchema: z.ZodObject<{
|
|
22
24
|
clientInformation: z.ZodObject<{
|
|
@@ -75,7 +75,9 @@ const oauthIssuerSchema = z
|
|
|
75
75
|
})
|
|
76
76
|
.transform((value) => new URL(value).toString());
|
|
77
77
|
const credentialFragmentSchema = z.string().min(1).max(4).nullable();
|
|
78
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* Mirrors the MCP SDK's SEP-2352 issuer-identity comparison.
|
|
80
|
+
*/
|
|
79
81
|
export function mcpOauthIssuersMatch(a, b) {
|
|
80
82
|
return (a === b ||
|
|
81
83
|
(a.endsWith("/") && a.slice(0, -1) === b) ||
|
|
@@ -5,6 +5,11 @@ export interface PromptVariableParseResult {
|
|
|
5
5
|
}
|
|
6
6
|
export declare const promptVariableTokenPattern: RegExp;
|
|
7
7
|
export declare const promptVariableNamePattern: RegExp;
|
|
8
|
+
/**
|
|
9
|
+
* Lists unique valid Prompt variables in appearance order and reports invalid names.
|
|
10
|
+
* @param template - Prompt template containing double-brace variable tokens.
|
|
11
|
+
* @returns Unique valid variables and all invalid variable names.
|
|
12
|
+
*/
|
|
8
13
|
export declare function parsePromptVariables(template: string): PromptVariableParseResult;
|
|
9
14
|
export declare const promptTemplateSchema: z.ZodString;
|
|
10
15
|
export declare const promptSchema: z.ZodObject<{
|
|
@@ -65,6 +70,14 @@ export declare const updatePromptBodySchema: z.ZodObject<{
|
|
|
65
70
|
template: z.ZodOptional<z.ZodString>;
|
|
66
71
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
67
72
|
}, z.core.$strict>;
|
|
73
|
+
/**
|
|
74
|
+
* Validates the Prompt template and replaces variables with their supplied string values.
|
|
75
|
+
* @param template - Prompt template containing double-brace variable tokens.
|
|
76
|
+
* @param values - Values to inspect or substitute.
|
|
77
|
+
* @returns The validated template with every variable replaced.
|
|
78
|
+
* @throws ZodError - If the template is invalid.
|
|
79
|
+
* @throws Error - If a variable has no string value.
|
|
80
|
+
*/
|
|
68
81
|
export declare function renderPromptTemplate(template: string, values: Record<string, string>): string;
|
|
69
82
|
export type Prompt = z.infer<typeof promptSchema>;
|
|
70
83
|
export type PromptsResponse = z.infer<typeof promptsResponseSchema>;
|
|
@@ -7,6 +7,11 @@ import { metadataSchema, userIdSchema } from "./attribution.js";
|
|
|
7
7
|
export const promptVariableTokenPattern = /{{([\s\S]*?)}}/g;
|
|
8
8
|
export const promptVariableNamePattern = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
9
9
|
const promptNameSchema = z.string().trim().min(1).max(MAX_PROMPT_NAME_LENGTH);
|
|
10
|
+
/**
|
|
11
|
+
* Lists unique valid Prompt variables in appearance order and reports invalid names.
|
|
12
|
+
* @param template - Prompt template containing double-brace variable tokens.
|
|
13
|
+
* @returns Unique valid variables and all invalid variable names.
|
|
14
|
+
*/
|
|
10
15
|
export function parsePromptVariables(template) {
|
|
11
16
|
const invalidVariableNames = [];
|
|
12
17
|
const seenVariables = new Set();
|
|
@@ -95,6 +100,14 @@ export const updatePromptBodySchema = z
|
|
|
95
100
|
.refine(hasObjectKeys, {
|
|
96
101
|
message: atLeastOneFieldMessage,
|
|
97
102
|
});
|
|
103
|
+
/**
|
|
104
|
+
* Validates the Prompt template and replaces variables with their supplied string values.
|
|
105
|
+
* @param template - Prompt template containing double-brace variable tokens.
|
|
106
|
+
* @param values - Values to inspect or substitute.
|
|
107
|
+
* @returns The validated template with every variable replaced.
|
|
108
|
+
* @throws ZodError - If the template is invalid.
|
|
109
|
+
* @throws Error - If a variable has no string value.
|
|
110
|
+
*/
|
|
98
111
|
export function renderPromptTemplate(template, values) {
|
|
99
112
|
return promptTemplateSchema
|
|
100
113
|
.parse(template)
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const sessionInputStateSchema: z.ZodEnum<{
|
|
3
3
|
accepted: "accepted";
|
|
4
|
-
cancelled: "cancelled";
|
|
5
4
|
committed: "committed";
|
|
6
|
-
consumed: "consumed";
|
|
7
5
|
delivered: "delivered";
|
|
6
|
+
not_placed: "not_placed";
|
|
8
7
|
uncertain: "uncertain";
|
|
9
8
|
}>;
|
|
10
|
-
export declare const sessionInputModeSchema: z.ZodEnum<{
|
|
11
|
-
queue: "queue";
|
|
12
|
-
steer: "steer";
|
|
13
|
-
}>;
|
|
14
9
|
export declare const sessionInputRequestIdSchema: z.ZodString;
|
|
15
10
|
export declare const sessionInputSchema: z.ZodObject<{
|
|
16
11
|
requestId: z.ZodString;
|
|
@@ -23,43 +18,31 @@ export declare const sessionInputSchema: z.ZodObject<{
|
|
|
23
18
|
metadata: z.ZodOptional<z.ZodUnknown>;
|
|
24
19
|
role: z.ZodLiteral<"user">;
|
|
25
20
|
}, z.core.$loose>;
|
|
26
|
-
mode: z.ZodEnum<{
|
|
27
|
-
queue: "queue";
|
|
28
|
-
steer: "steer";
|
|
29
|
-
}>;
|
|
30
21
|
state: z.ZodEnum<{
|
|
31
22
|
accepted: "accepted";
|
|
32
|
-
cancelled: "cancelled";
|
|
33
23
|
committed: "committed";
|
|
34
|
-
consumed: "consumed";
|
|
35
24
|
delivered: "delivered";
|
|
25
|
+
not_placed: "not_placed";
|
|
36
26
|
uncertain: "uncertain";
|
|
37
27
|
}>;
|
|
38
|
-
turnId: z.
|
|
28
|
+
turnId: z.ZodString;
|
|
39
29
|
createdAt: z.ZodISODateTime;
|
|
40
30
|
updatedAt: z.ZodISODateTime;
|
|
41
|
-
consumedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
42
31
|
reason: z.ZodNullable<z.ZodEnum<{
|
|
43
|
-
deleted: "deleted";
|
|
44
32
|
failed: "failed";
|
|
45
33
|
owner_lost: "owner_lost";
|
|
46
34
|
stopped: "stopped";
|
|
35
|
+
turn_finished: "turn_finished";
|
|
47
36
|
}>>;
|
|
48
37
|
}, z.core.$strip>;
|
|
49
38
|
export declare const sessionActivitySchema: z.ZodObject<{
|
|
50
39
|
state: z.ZodEnum<{
|
|
51
40
|
approval: "approval";
|
|
52
41
|
idle: "idle";
|
|
53
|
-
paused: "paused";
|
|
54
42
|
running: "running";
|
|
55
43
|
stopping: "stopping";
|
|
56
44
|
}>;
|
|
57
45
|
turnId: z.ZodNullable<z.ZodString>;
|
|
58
|
-
reason: z.ZodNullable<z.ZodEnum<{
|
|
59
|
-
failed: "failed";
|
|
60
|
-
function_executor_required: "function_executor_required";
|
|
61
|
-
owner_lost: "owner_lost";
|
|
62
|
-
}>>;
|
|
63
46
|
}, z.core.$strip>;
|
|
64
47
|
export declare const sessionInputResponseSchema: z.ZodObject<{
|
|
65
48
|
data: z.ZodObject<{
|
|
@@ -73,43 +56,31 @@ export declare const sessionInputResponseSchema: z.ZodObject<{
|
|
|
73
56
|
metadata: z.ZodOptional<z.ZodUnknown>;
|
|
74
57
|
role: z.ZodLiteral<"user">;
|
|
75
58
|
}, z.core.$loose>;
|
|
76
|
-
mode: z.ZodEnum<{
|
|
77
|
-
queue: "queue";
|
|
78
|
-
steer: "steer";
|
|
79
|
-
}>;
|
|
80
59
|
state: z.ZodEnum<{
|
|
81
60
|
accepted: "accepted";
|
|
82
|
-
cancelled: "cancelled";
|
|
83
61
|
committed: "committed";
|
|
84
|
-
consumed: "consumed";
|
|
85
62
|
delivered: "delivered";
|
|
63
|
+
not_placed: "not_placed";
|
|
86
64
|
uncertain: "uncertain";
|
|
87
65
|
}>;
|
|
88
|
-
turnId: z.
|
|
66
|
+
turnId: z.ZodString;
|
|
89
67
|
createdAt: z.ZodISODateTime;
|
|
90
68
|
updatedAt: z.ZodISODateTime;
|
|
91
|
-
consumedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
92
69
|
reason: z.ZodNullable<z.ZodEnum<{
|
|
93
|
-
deleted: "deleted";
|
|
94
70
|
failed: "failed";
|
|
95
71
|
owner_lost: "owner_lost";
|
|
96
72
|
stopped: "stopped";
|
|
73
|
+
turn_finished: "turn_finished";
|
|
97
74
|
}>>;
|
|
98
75
|
}, z.core.$strip>;
|
|
99
76
|
activity: z.ZodObject<{
|
|
100
77
|
state: z.ZodEnum<{
|
|
101
78
|
approval: "approval";
|
|
102
79
|
idle: "idle";
|
|
103
|
-
paused: "paused";
|
|
104
80
|
running: "running";
|
|
105
81
|
stopping: "stopping";
|
|
106
82
|
}>;
|
|
107
83
|
turnId: z.ZodNullable<z.ZodString>;
|
|
108
|
-
reason: z.ZodNullable<z.ZodEnum<{
|
|
109
|
-
failed: "failed";
|
|
110
|
-
function_executor_required: "function_executor_required";
|
|
111
|
-
owner_lost: "owner_lost";
|
|
112
|
-
}>>;
|
|
113
84
|
}, z.core.$strip>;
|
|
114
85
|
}, z.core.$strip>;
|
|
115
86
|
export declare const sessionInputsResponseSchema: z.ZodObject<{
|
|
@@ -124,27 +95,21 @@ export declare const sessionInputsResponseSchema: z.ZodObject<{
|
|
|
124
95
|
metadata: z.ZodOptional<z.ZodUnknown>;
|
|
125
96
|
role: z.ZodLiteral<"user">;
|
|
126
97
|
}, z.core.$loose>;
|
|
127
|
-
mode: z.ZodEnum<{
|
|
128
|
-
queue: "queue";
|
|
129
|
-
steer: "steer";
|
|
130
|
-
}>;
|
|
131
98
|
state: z.ZodEnum<{
|
|
132
99
|
accepted: "accepted";
|
|
133
|
-
cancelled: "cancelled";
|
|
134
100
|
committed: "committed";
|
|
135
|
-
consumed: "consumed";
|
|
136
101
|
delivered: "delivered";
|
|
102
|
+
not_placed: "not_placed";
|
|
137
103
|
uncertain: "uncertain";
|
|
138
104
|
}>;
|
|
139
|
-
turnId: z.
|
|
105
|
+
turnId: z.ZodString;
|
|
140
106
|
createdAt: z.ZodISODateTime;
|
|
141
107
|
updatedAt: z.ZodISODateTime;
|
|
142
|
-
consumedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
143
108
|
reason: z.ZodNullable<z.ZodEnum<{
|
|
144
|
-
deleted: "deleted";
|
|
145
109
|
failed: "failed";
|
|
146
110
|
owner_lost: "owner_lost";
|
|
147
111
|
stopped: "stopped";
|
|
112
|
+
turn_finished: "turn_finished";
|
|
148
113
|
}>>;
|
|
149
114
|
}, z.core.$strip>>;
|
|
150
115
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
@@ -152,25 +117,15 @@ export declare const sessionInputsResponseSchema: z.ZodObject<{
|
|
|
152
117
|
state: z.ZodEnum<{
|
|
153
118
|
approval: "approval";
|
|
154
119
|
idle: "idle";
|
|
155
|
-
paused: "paused";
|
|
156
120
|
running: "running";
|
|
157
121
|
stopping: "stopping";
|
|
158
122
|
}>;
|
|
159
123
|
turnId: z.ZodNullable<z.ZodString>;
|
|
160
|
-
reason: z.ZodNullable<z.ZodEnum<{
|
|
161
|
-
failed: "failed";
|
|
162
|
-
function_executor_required: "function_executor_required";
|
|
163
|
-
owner_lost: "owner_lost";
|
|
164
|
-
}>>;
|
|
165
124
|
}, z.core.$strip>;
|
|
166
125
|
}, z.core.$strip>;
|
|
167
126
|
export declare const submitSessionInputBodySchema: z.ZodObject<{
|
|
168
127
|
requestId: z.ZodString;
|
|
169
128
|
message: z.ZodUnknown & z.ZodType<{} | null, unknown, z.core.$ZodTypeInternals<{} | null, unknown>>;
|
|
170
|
-
whenBusy: z.ZodDefault<z.ZodEnum<{
|
|
171
|
-
queue: "queue";
|
|
172
|
-
steer: "steer";
|
|
173
|
-
}>>;
|
|
174
129
|
}, z.core.$strict>;
|
|
175
130
|
export declare const sessionInputsQuerySchema: z.ZodObject<{
|
|
176
131
|
includeCompleted: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -186,37 +141,13 @@ export declare const stopSessionResponseSchema: z.ZodObject<{
|
|
|
186
141
|
state: z.ZodEnum<{
|
|
187
142
|
approval: "approval";
|
|
188
143
|
idle: "idle";
|
|
189
|
-
paused: "paused";
|
|
190
144
|
running: "running";
|
|
191
145
|
stopping: "stopping";
|
|
192
146
|
}>;
|
|
193
147
|
turnId: z.ZodNullable<z.ZodString>;
|
|
194
|
-
reason: z.ZodNullable<z.ZodEnum<{
|
|
195
|
-
failed: "failed";
|
|
196
|
-
function_executor_required: "function_executor_required";
|
|
197
|
-
owner_lost: "owner_lost";
|
|
198
|
-
}>>;
|
|
199
|
-
}, z.core.$strip>;
|
|
200
|
-
}, z.core.$strip>;
|
|
201
|
-
export declare const resumeSessionInputsResponseSchema: z.ZodObject<{
|
|
202
|
-
activity: z.ZodObject<{
|
|
203
|
-
state: z.ZodEnum<{
|
|
204
|
-
approval: "approval";
|
|
205
|
-
idle: "idle";
|
|
206
|
-
paused: "paused";
|
|
207
|
-
running: "running";
|
|
208
|
-
stopping: "stopping";
|
|
209
|
-
}>;
|
|
210
|
-
turnId: z.ZodNullable<z.ZodString>;
|
|
211
|
-
reason: z.ZodNullable<z.ZodEnum<{
|
|
212
|
-
failed: "failed";
|
|
213
|
-
function_executor_required: "function_executor_required";
|
|
214
|
-
owner_lost: "owner_lost";
|
|
215
|
-
}>>;
|
|
216
148
|
}, z.core.$strip>;
|
|
217
149
|
}, z.core.$strip>;
|
|
218
150
|
export type SessionInputState = z.infer<typeof sessionInputStateSchema>;
|
|
219
|
-
export type SessionInputMode = z.infer<typeof sessionInputModeSchema>;
|
|
220
151
|
export type SessionInput = z.infer<typeof sessionInputSchema>;
|
|
221
152
|
export type SessionActivity = z.infer<typeof sessionActivitySchema>;
|
|
222
153
|
export type SessionInputResponse = z.infer<typeof sessionInputResponseSchema>;
|
|
@@ -225,11 +156,22 @@ export type SubmitSessionInputBody = z.input<typeof submitSessionInputBodySchema
|
|
|
225
156
|
export type SessionInputsQuery = z.input<typeof sessionInputsQuerySchema>;
|
|
226
157
|
export type StopSessionBody = z.infer<typeof stopSessionBodySchema>;
|
|
227
158
|
export type StopSessionResponse = z.infer<typeof stopSessionResponseSchema>;
|
|
228
|
-
|
|
229
|
-
export declare const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
159
|
+
/** Provisional placement observation emitted on the owning Turn stream. */
|
|
160
|
+
export declare const chatSteerConsumedEventSchema: z.ZodObject<{
|
|
161
|
+
type: z.ZodLiteral<"data-ba-steer-consumed">;
|
|
162
|
+
transient: z.ZodLiteral<true>;
|
|
163
|
+
data: z.ZodObject<{
|
|
164
|
+
requestId: z.ZodString;
|
|
165
|
+
sequence: z.ZodNumber;
|
|
166
|
+
message: z.ZodObject<{
|
|
167
|
+
id: z.ZodString;
|
|
168
|
+
parts: z.ZodArray<z.ZodObject<{
|
|
169
|
+
type: z.ZodString;
|
|
170
|
+
}, z.core.$loose>>;
|
|
171
|
+
metadata: z.ZodOptional<z.ZodUnknown>;
|
|
172
|
+
role: z.ZodLiteral<"user">;
|
|
173
|
+
}, z.core.$loose>;
|
|
174
|
+
turnId: z.ZodString;
|
|
175
|
+
}, z.core.$strip>;
|
|
176
|
+
}, z.core.$strip>;
|
|
177
|
+
export type ChatSteerConsumedEvent = z.infer<typeof chatSteerConsumedEventSchema>;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { turnIdSchema } from "../ids.js";
|
|
3
|
-
import { chatFunctionDefinitionsSchema } from "./chat.js";
|
|
4
3
|
import { sessionMessageSchema } from "./sessions.js";
|
|
5
4
|
export const sessionInputStateSchema = z.enum([
|
|
6
5
|
"accepted",
|
|
7
6
|
"delivered",
|
|
8
|
-
"consumed",
|
|
9
7
|
"committed",
|
|
10
|
-
"
|
|
8
|
+
"not_placed",
|
|
11
9
|
"uncertain",
|
|
12
10
|
]);
|
|
13
|
-
export const sessionInputModeSchema = z.enum(["queue", "steer"]);
|
|
14
11
|
export const sessionInputRequestIdSchema = z
|
|
15
12
|
.string()
|
|
16
13
|
.min(1)
|
|
@@ -22,23 +19,22 @@ export const sessionInputSchema = z
|
|
|
22
19
|
.object({
|
|
23
20
|
requestId: sessionInputRequestIdSchema,
|
|
24
21
|
sequence: z.number().int().positive(),
|
|
25
|
-
message: sessionMessageSchema
|
|
26
|
-
|
|
22
|
+
message: sessionMessageSchema
|
|
23
|
+
.omit({ branchable: true })
|
|
24
|
+
.extend({ role: z.literal("user") }),
|
|
27
25
|
state: sessionInputStateSchema,
|
|
28
|
-
turnId: turnIdSchema
|
|
26
|
+
turnId: turnIdSchema,
|
|
29
27
|
createdAt: z.iso.datetime({ offset: true }),
|
|
30
28
|
updatedAt: z.iso.datetime({ offset: true }),
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
reason: z
|
|
30
|
+
.enum(["stopped", "failed", "owner_lost", "turn_finished"])
|
|
31
|
+
.nullable(),
|
|
33
32
|
})
|
|
34
33
|
.strip();
|
|
35
34
|
export const sessionActivitySchema = z
|
|
36
35
|
.object({
|
|
37
|
-
state: z.enum(["idle", "running", "stopping", "approval"
|
|
36
|
+
state: z.enum(["idle", "running", "stopping", "approval"]),
|
|
38
37
|
turnId: turnIdSchema.nullable(),
|
|
39
|
-
reason: z
|
|
40
|
-
.enum(["failed", "owner_lost", "function_executor_required"])
|
|
41
|
-
.nullable(),
|
|
42
38
|
})
|
|
43
39
|
.strip();
|
|
44
40
|
export const sessionInputResponseSchema = z
|
|
@@ -56,7 +52,6 @@ export const submitSessionInputBodySchema = z
|
|
|
56
52
|
requestId: sessionInputRequestIdSchema,
|
|
57
53
|
/** The HTTP boundary validates the user message with AI SDK. */
|
|
58
54
|
message: z.unknown().refine((message) => message !== undefined),
|
|
59
|
-
whenBusy: sessionInputModeSchema.default("queue"),
|
|
60
55
|
})
|
|
61
56
|
.strict();
|
|
62
57
|
export const sessionInputsQuerySchema = z
|
|
@@ -72,9 +67,16 @@ export const stopSessionBodySchema = z
|
|
|
72
67
|
export const stopSessionResponseSchema = z
|
|
73
68
|
.object({ stoppedTurnId: turnIdSchema, activity: sessionActivitySchema })
|
|
74
69
|
.strip();
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
/** Provisional placement observation emitted on the owning Turn stream. */
|
|
71
|
+
export const chatSteerConsumedEventSchema = z
|
|
72
|
+
.object({
|
|
73
|
+
type: z.literal("data-ba-steer-consumed"),
|
|
74
|
+
transient: z.literal(true),
|
|
75
|
+
data: sessionInputSchema.pick({
|
|
76
|
+
requestId: true,
|
|
77
|
+
turnId: true,
|
|
78
|
+
sequence: true,
|
|
79
|
+
message: true,
|
|
80
|
+
}),
|
|
81
|
+
})
|
|
77
82
|
.strip();
|
|
78
|
-
export const runSessionInputsBodySchema = z
|
|
79
|
-
.object({ functions: chatFunctionDefinitionsSchema.optional() })
|
|
80
|
-
.strict();
|