@blazingagents/sdk 0.18.0 → 0.20.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 +2 -14
- package/dist/approvals.js +10 -15
- package/dist/client.d.ts +4 -4
- package/dist/client.js +6 -6
- package/dist/contracts/api.d.ts +6 -6
- package/dist/contracts/api.js +2 -2
- package/dist/contracts/entities/chat.d.ts +8 -10
- package/dist/contracts/entities/chat.js +5 -7
- package/dist/contracts/entities/session-inputs.d.ts +29 -87
- package/dist/contracts/entities/session-inputs.js +18 -18
- package/dist/contracts/entities/sessions.d.ts +16 -17
- package/dist/contracts/entities/sessions.js +12 -7
- package/dist/contracts/index.d.ts +5 -5
- package/dist/contracts/index.js +3 -3
- package/dist/direct-chat-transport.d.ts +3 -6
- package/dist/direct-chat-transport.js +14 -48
- package/dist/generation.d.ts +2 -2
- package/dist/generation.js +14 -19
- package/dist/index.d.ts +3 -3
- package/dist/relay.d.ts +3 -3
- package/dist/relay.js +9 -10
- package/dist/resources/sessions.js +3 -46
- package/dist/types.d.ts +15 -48
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,8 @@ requires Node.js 24 or newer.
|
|
|
17
17
|
|
|
18
18
|
- Typed clients for Agents, Workspaces, Skills, Providers, Prompts, Tasks,
|
|
19
19
|
Sessions, Artifacts, Slack and Telegram Chat Connections, usage, Tenant settings, and merchant monetization.
|
|
20
|
-
- Stateful chat
|
|
20
|
+
- Stateful chat with explicit message batches, steer receipts, and one-call Tool approvals.
|
|
21
|
+
- Stateless text or structured-object generation.
|
|
21
22
|
- Public Zod contracts for validating API requests and responses.
|
|
22
23
|
- Cursor pagination and binary transfers.
|
|
23
24
|
- Request correlation and a typed, forward-compatible error model.
|
|
@@ -51,6 +52,21 @@ const result = await client.completion({
|
|
|
51
52
|
console.log(await result.text);
|
|
52
53
|
```
|
|
53
54
|
|
|
55
|
+
For stateful chat, pass one user message or an ordered batch.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
const chat = await client.chat({
|
|
59
|
+
agentId: "ag_...",
|
|
60
|
+
messages: [
|
|
61
|
+
{ id: "first", role: "user", parts: [{ type: "text", text: "Compare the plans." }] },
|
|
62
|
+
{ id: "second", role: "user", parts: [{ type: "text", text: "Include annual pricing." }] },
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const sessionId = await chat.sessionId;
|
|
67
|
+
return chat.toResponse();
|
|
68
|
+
```
|
|
69
|
+
|
|
54
70
|
Keep API keys on the server. For browser chat applications, relay `chat()`
|
|
55
71
|
through your backend and use `BlazingAgentsChatTransport` with AI SDK
|
|
56
72
|
`useChat`.
|
package/dist/approvals.d.ts
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
1
|
import { type UIMessage } from "ai";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
abortSignal?: AbortSignal;
|
|
5
|
-
agentId: string;
|
|
6
|
-
sessionId: string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Records each approval response in the assistant message's last step and
|
|
10
|
-
* returns the continuation they decide, or `undefined` when there are none.
|
|
11
|
-
*/
|
|
12
|
-
export declare function decideApprovalResponses(client: Pick<BlazingAgents, "sessions">, { message, ...target }: ApprovalTarget & {
|
|
13
|
-
message: UIMessage;
|
|
14
|
-
}): Promise<string | undefined>;
|
|
15
|
-
export {};
|
|
2
|
+
import type { ToolApprovalDecision } from "./contracts/entities/sessions.ts";
|
|
3
|
+
export declare function extractApprovalDecisions(message: UIMessage): ToolApprovalDecision[];
|
package/dist/approvals.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import { isToolUIPart } from "ai";
|
|
2
|
-
|
|
3
|
-
* Records each approval response in the assistant message's last step and
|
|
4
|
-
* returns the continuation they decide, or `undefined` when there are none.
|
|
5
|
-
*/
|
|
6
|
-
export async function decideApprovalResponses(client, { message, ...target }) {
|
|
2
|
+
export function extractApprovalDecisions(message) {
|
|
7
3
|
const lastStep = message.parts.findLastIndex((part) => part.type === "step-start");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
({ continuationId } = await client.sessions.decideToolApproval({
|
|
12
|
-
...target,
|
|
4
|
+
return message.parts.slice(lastStep + 1).flatMap((part) => isToolUIPart(part) && part.state === "approval-responded"
|
|
5
|
+
? [
|
|
6
|
+
{
|
|
13
7
|
approvalId: part.approval.id,
|
|
14
8
|
approved: part.approval.approved,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
...(part.approval.reason === undefined
|
|
10
|
+
? {}
|
|
11
|
+
: { reason: part.approval.reason }),
|
|
12
|
+
},
|
|
13
|
+
]
|
|
14
|
+
: []);
|
|
20
15
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentClient, AgentsResource, ArtifactsResource, BlazingAgentsOptions, BlazingAgentsRequestOptions, ChatConnectionsResource, ChatDeliveriesResource, ChatInput, ChatResult, CompletionInput, CompletionResult, McpConnectionsResource, MemoriesResource, MerchantBindingsResource, MerchantConnectionResource, MerchantUsageEventsResource, ObjectInput, ObjectResult, PromptsResource, ProvidersResource,
|
|
1
|
+
import type { AgentClient, AgentsResource, ArtifactsResource, BlazingAgentsOptions, BlazingAgentsRequestOptions, ChatConnectionsResource, ChatDeliveriesResource, ChatInput, ChatResult, CompletionInput, CompletionResult, ContinueChatInput, McpConnectionsResource, MemoriesResource, MerchantBindingsResource, MerchantConnectionResource, MerchantUsageEventsResource, ObjectInput, ObjectResult, PromptsResource, ProvidersResource, SessionsResource, TasksResource, TenantResource, UsageResource, UserClient, WorkspacesResource } from "./types.ts";
|
|
2
2
|
export declare class BlazingAgents {
|
|
3
3
|
private readonly config;
|
|
4
4
|
readonly chatConnections: ChatConnectionsResource;
|
|
@@ -30,10 +30,10 @@ export declare class BlazingAgents {
|
|
|
30
30
|
*/
|
|
31
31
|
chat(input: ChatInput): Promise<ChatResult>;
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
33
|
+
* Records a complete Tool approval round and streams its continuation.
|
|
34
|
+
* Caller-local function handlers apply only to this invocation.
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
continueChat(input: ContinueChatInput): Promise<ChatResult>;
|
|
37
37
|
/**
|
|
38
38
|
* `POST /v1/agents/:agentId/generation` — stateless one-shot text
|
|
39
39
|
* stream. Returns `textStream` + `await result.text` + `toResponse()`.
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { chat, completion,
|
|
2
|
+
import { chat, completion, continueChat, objectGeneration, } from "./generation.js";
|
|
3
3
|
import { createAgentsResource } from "./resources/agents.js";
|
|
4
4
|
import { createArtifactsResource } from "./resources/artifacts.js";
|
|
5
5
|
import { createChatConnectionsResource } from "./resources/chat-connections.js";
|
|
@@ -40,7 +40,7 @@ function createUserClient(config) {
|
|
|
40
40
|
chat: (input) => chat(config, input),
|
|
41
41
|
completion: (input) => completion(config, input),
|
|
42
42
|
object: (input) => objectGeneration(config, input),
|
|
43
|
-
|
|
43
|
+
continueChat: (input) => continueChat(config, input),
|
|
44
44
|
withOptions: (options) => createUserClient({ ...config, clientRequestId: options.clientRequestId }),
|
|
45
45
|
};
|
|
46
46
|
}
|
|
@@ -108,11 +108,11 @@ export class BlazingAgents {
|
|
|
108
108
|
return chat(this.config, input);
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
111
|
+
* Records a complete Tool approval round and streams its continuation.
|
|
112
|
+
* Caller-local function handlers apply only to this invocation.
|
|
113
113
|
*/
|
|
114
|
-
|
|
115
|
-
return
|
|
114
|
+
continueChat(input) {
|
|
115
|
+
return continueChat(this.config, input);
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* `POST /v1/agents/:agentId/generation` — stateless one-shot text
|
package/dist/contracts/api.d.ts
CHANGED
|
@@ -32,7 +32,6 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
|
|
|
32
32
|
function_call_conflict: "function_call_conflict";
|
|
33
33
|
idempotency_conflict: "idempotency_conflict";
|
|
34
34
|
input_idempotency_conflict: "input_idempotency_conflict";
|
|
35
|
-
input_not_pending: "input_not_pending";
|
|
36
35
|
internal: "internal";
|
|
37
36
|
invalid_cursor: "invalid_cursor";
|
|
38
37
|
invalid_request: "invalid_request";
|
|
@@ -82,13 +81,14 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
|
|
|
82
81
|
skill_not_found: "skill_not_found";
|
|
83
82
|
skill_too_many_files: "skill_too_many_files";
|
|
84
83
|
skill_uncompressed_too_large: "skill_uncompressed_too_large";
|
|
84
|
+
steer_not_available: "steer_not_available";
|
|
85
85
|
subscription_required: "subscription_required";
|
|
86
86
|
task_active_run_exists: "task_active_run_exists";
|
|
87
87
|
tenant_deleting: "tenant_deleting";
|
|
88
88
|
tenant_deletion_in_progress: "tenant_deletion_in_progress";
|
|
89
89
|
tenant_deletion_not_ready: "tenant_deletion_not_ready";
|
|
90
90
|
tenant_not_deleting: "tenant_not_deleting";
|
|
91
|
-
|
|
91
|
+
tool_approval_continuation_settled: "tool_approval_continuation_settled";
|
|
92
92
|
tool_approval_decision_conflict: "tool_approval_decision_conflict";
|
|
93
93
|
unauthorized: "unauthorized";
|
|
94
94
|
usage_credit_required: "usage_credit_required";
|
|
@@ -112,7 +112,6 @@ export declare const apiErrorSchema: z.ZodObject<{
|
|
|
112
112
|
function_call_conflict: "function_call_conflict";
|
|
113
113
|
idempotency_conflict: "idempotency_conflict";
|
|
114
114
|
input_idempotency_conflict: "input_idempotency_conflict";
|
|
115
|
-
input_not_pending: "input_not_pending";
|
|
116
115
|
internal: "internal";
|
|
117
116
|
invalid_cursor: "invalid_cursor";
|
|
118
117
|
invalid_request: "invalid_request";
|
|
@@ -162,13 +161,14 @@ export declare const apiErrorSchema: z.ZodObject<{
|
|
|
162
161
|
skill_not_found: "skill_not_found";
|
|
163
162
|
skill_too_many_files: "skill_too_many_files";
|
|
164
163
|
skill_uncompressed_too_large: "skill_uncompressed_too_large";
|
|
164
|
+
steer_not_available: "steer_not_available";
|
|
165
165
|
subscription_required: "subscription_required";
|
|
166
166
|
task_active_run_exists: "task_active_run_exists";
|
|
167
167
|
tenant_deleting: "tenant_deleting";
|
|
168
168
|
tenant_deletion_in_progress: "tenant_deletion_in_progress";
|
|
169
169
|
tenant_deletion_not_ready: "tenant_deletion_not_ready";
|
|
170
170
|
tenant_not_deleting: "tenant_not_deleting";
|
|
171
|
-
|
|
171
|
+
tool_approval_continuation_settled: "tool_approval_continuation_settled";
|
|
172
172
|
tool_approval_decision_conflict: "tool_approval_decision_conflict";
|
|
173
173
|
unauthorized: "unauthorized";
|
|
174
174
|
usage_credit_required: "usage_credit_required";
|
|
@@ -197,7 +197,6 @@ export declare const apiErrorResponseSchema: z.ZodObject<{
|
|
|
197
197
|
function_call_conflict: "function_call_conflict";
|
|
198
198
|
idempotency_conflict: "idempotency_conflict";
|
|
199
199
|
input_idempotency_conflict: "input_idempotency_conflict";
|
|
200
|
-
input_not_pending: "input_not_pending";
|
|
201
200
|
internal: "internal";
|
|
202
201
|
invalid_cursor: "invalid_cursor";
|
|
203
202
|
invalid_request: "invalid_request";
|
|
@@ -247,13 +246,14 @@ export declare const apiErrorResponseSchema: z.ZodObject<{
|
|
|
247
246
|
skill_not_found: "skill_not_found";
|
|
248
247
|
skill_too_many_files: "skill_too_many_files";
|
|
249
248
|
skill_uncompressed_too_large: "skill_uncompressed_too_large";
|
|
249
|
+
steer_not_available: "steer_not_available";
|
|
250
250
|
subscription_required: "subscription_required";
|
|
251
251
|
task_active_run_exists: "task_active_run_exists";
|
|
252
252
|
tenant_deleting: "tenant_deleting";
|
|
253
253
|
tenant_deletion_in_progress: "tenant_deletion_in_progress";
|
|
254
254
|
tenant_deletion_not_ready: "tenant_deletion_not_ready";
|
|
255
255
|
tenant_not_deleting: "tenant_not_deleting";
|
|
256
|
-
|
|
256
|
+
tool_approval_continuation_settled: "tool_approval_continuation_settled";
|
|
257
257
|
tool_approval_decision_conflict: "tool_approval_decision_conflict";
|
|
258
258
|
unauthorized: "unauthorized";
|
|
259
259
|
usage_credit_required: "usage_credit_required";
|
package/dist/contracts/api.js
CHANGED
|
@@ -20,7 +20,7 @@ export const apiErrorCodeSchema = z.enum([
|
|
|
20
20
|
"invalid_request",
|
|
21
21
|
"idempotency_conflict",
|
|
22
22
|
"input_idempotency_conflict",
|
|
23
|
-
"
|
|
23
|
+
"steer_not_available",
|
|
24
24
|
"validation_failed",
|
|
25
25
|
"unauthorized",
|
|
26
26
|
"forbidden",
|
|
@@ -64,7 +64,7 @@ export const apiErrorCodeSchema = z.enum([
|
|
|
64
64
|
"workspace_busy",
|
|
65
65
|
"session_busy",
|
|
66
66
|
"session_version_mismatch",
|
|
67
|
-
"
|
|
67
|
+
"tool_approval_continuation_settled",
|
|
68
68
|
"tool_approval_decision_conflict",
|
|
69
69
|
"function_call_conflict",
|
|
70
70
|
"skill_invalid_archive",
|
|
@@ -162,18 +162,16 @@ export declare const resolveChatFunctionBodySchema: z.ZodObject<{
|
|
|
162
162
|
export declare const resolveChatFunctionResponseSchema: z.ZodObject<{
|
|
163
163
|
accepted: z.ZodLiteral<true>;
|
|
164
164
|
}, z.core.$strip>;
|
|
165
|
-
/** `POST .../tool-approval-continuations/{continuationId}/resume` body. */
|
|
166
|
-
export declare const resumeToolApprovalContinuationBodySchema: z.ZodObject<{}, z.core.$strict>;
|
|
167
165
|
/**
|
|
168
166
|
* `POST /v1/agents/{agentId}/sessions` (create) and
|
|
169
167
|
* `POST /v1/agents/{agentId}/sessions/{sessionId}` (resume) request body.
|
|
170
168
|
* The URL selects the mode; on create the platform mints the `ss_` id and
|
|
171
|
-
* returns it in `Location`. Exactly one of `
|
|
169
|
+
* returns it in `Location`. Exactly one of `messages` or `promptId` is
|
|
172
170
|
* required, and `variables` requires `promptId`. Regenerate is resume-only,
|
|
173
171
|
* enforced by the route layer rather than this schema.
|
|
174
172
|
*/
|
|
175
173
|
export declare const chatRequestBodySchema: z.ZodObject<{
|
|
176
|
-
|
|
174
|
+
messages: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
177
175
|
promptId: z.ZodOptional<z.ZodString>;
|
|
178
176
|
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
179
177
|
trigger: z.ZodDefault<z.ZodEnum<{
|
|
@@ -188,7 +186,7 @@ export declare const chatRequestBodySchema: z.ZodObject<{
|
|
|
188
186
|
inputSchema: z.ZodCustom<z.core.JSONSchema.JSONSchema, z.core.JSONSchema.JSONSchema>;
|
|
189
187
|
}, z.core.$strict>>>;
|
|
190
188
|
}, z.core.$strict> & z.ZodType<{
|
|
191
|
-
|
|
189
|
+
messages?: unknown[] | undefined;
|
|
192
190
|
promptId?: string | undefined;
|
|
193
191
|
variables?: Record<string, string> | undefined;
|
|
194
192
|
trigger: "regenerate-message" | "submit-message";
|
|
@@ -200,9 +198,9 @@ export declare const chatRequestBodySchema: z.ZodObject<{
|
|
|
200
198
|
inputSchema: z.core.JSONSchema.JSONSchema;
|
|
201
199
|
}> | undefined;
|
|
202
200
|
} & ExclusivePromptInput<{
|
|
203
|
-
|
|
201
|
+
messages: unknown[];
|
|
204
202
|
}>, {
|
|
205
|
-
|
|
203
|
+
messages?: unknown[] | undefined;
|
|
206
204
|
promptId?: string | undefined;
|
|
207
205
|
variables?: Record<string, string> | undefined;
|
|
208
206
|
trigger?: "regenerate-message" | "submit-message" | undefined;
|
|
@@ -214,7 +212,7 @@ export declare const chatRequestBodySchema: z.ZodObject<{
|
|
|
214
212
|
inputSchema: z.core.JSONSchema.JSONSchema;
|
|
215
213
|
}> | undefined;
|
|
216
214
|
}, z.core.$ZodTypeInternals<{
|
|
217
|
-
|
|
215
|
+
messages?: unknown[] | undefined;
|
|
218
216
|
promptId?: string | undefined;
|
|
219
217
|
variables?: Record<string, string> | undefined;
|
|
220
218
|
trigger: "regenerate-message" | "submit-message";
|
|
@@ -226,9 +224,9 @@ export declare const chatRequestBodySchema: z.ZodObject<{
|
|
|
226
224
|
inputSchema: z.core.JSONSchema.JSONSchema;
|
|
227
225
|
}> | undefined;
|
|
228
226
|
} & ExclusivePromptInput<{
|
|
229
|
-
|
|
227
|
+
messages: unknown[];
|
|
230
228
|
}>, {
|
|
231
|
-
|
|
229
|
+
messages?: unknown[] | undefined;
|
|
232
230
|
promptId?: string | undefined;
|
|
233
231
|
variables?: Record<string, string> | undefined;
|
|
234
232
|
trigger?: "regenerate-message" | "submit-message" | undefined;
|
|
@@ -181,13 +181,11 @@ export const resolveChatFunctionBodySchema = z
|
|
|
181
181
|
export const resolveChatFunctionResponseSchema = z
|
|
182
182
|
.object({ accepted: z.literal(true) })
|
|
183
183
|
.strip();
|
|
184
|
-
/** `POST .../tool-approval-continuations/{continuationId}/resume` body. */
|
|
185
|
-
export const resumeToolApprovalContinuationBodySchema = z.object({}).strict();
|
|
186
184
|
/**
|
|
187
185
|
* `POST /v1/agents/{agentId}/sessions` (create) and
|
|
188
186
|
* `POST /v1/agents/{agentId}/sessions/{sessionId}` (resume) request body.
|
|
189
187
|
* The URL selects the mode; on create the platform mints the `ss_` id and
|
|
190
|
-
* returns it in `Location`. Exactly one of `
|
|
188
|
+
* returns it in `Location`. Exactly one of `messages` or `promptId` is
|
|
191
189
|
* required, and `variables` requires `promptId`. Regenerate is resume-only,
|
|
192
190
|
* enforced by the route layer rather than this schema.
|
|
193
191
|
*/
|
|
@@ -198,7 +196,7 @@ export const chatRequestBodySchema = z
|
|
|
198
196
|
* unknown; the HTTP boundary validates it with `safeValidateUIMessages`
|
|
199
197
|
* before treating it as a UIMessage.
|
|
200
198
|
*/
|
|
201
|
-
|
|
199
|
+
messages: z.array(z.unknown()).min(1).optional(),
|
|
202
200
|
promptId: promptIdSchema.optional(),
|
|
203
201
|
variables: promptVariablesSchema.optional(),
|
|
204
202
|
trigger: chatTriggerSchema.default("submit-message"),
|
|
@@ -213,11 +211,11 @@ export const chatRequestBodySchema = z
|
|
|
213
211
|
functions: chatFunctionDefinitionsSchema.optional(),
|
|
214
212
|
})
|
|
215
213
|
.strict()
|
|
216
|
-
.refine((body) => body.
|
|
214
|
+
.refine((body) => body.messages === undefined
|
|
217
215
|
? body.promptId !== undefined
|
|
218
216
|
: body.promptId === undefined && body.variables === undefined, {
|
|
219
|
-
message: "Provide either `
|
|
220
|
-
path: ["
|
|
217
|
+
message: "Provide either `messages` or `promptId` (+`variables`); they are mutually exclusive, and `variables` is only allowed with `promptId`.",
|
|
218
|
+
path: ["messages"],
|
|
221
219
|
});
|
|
222
220
|
/**
|
|
223
221
|
* `POST /v1/agents/{agentId}/generation` — the single stateless generation
|
|
@@ -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)
|
|
@@ -23,22 +20,19 @@ export const sessionInputSchema = z
|
|
|
23
20
|
requestId: sessionInputRequestIdSchema,
|
|
24
21
|
sequence: z.number().int().positive(),
|
|
25
22
|
message: sessionMessageSchema.extend({ role: z.literal("user") }),
|
|
26
|
-
mode: sessionInputModeSchema,
|
|
27
23
|
state: sessionInputStateSchema,
|
|
28
|
-
turnId: turnIdSchema
|
|
24
|
+
turnId: turnIdSchema,
|
|
29
25
|
createdAt: z.iso.datetime({ offset: true }),
|
|
30
26
|
updatedAt: z.iso.datetime({ offset: true }),
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
reason: z
|
|
28
|
+
.enum(["stopped", "failed", "owner_lost", "turn_finished"])
|
|
29
|
+
.nullable(),
|
|
33
30
|
})
|
|
34
31
|
.strip();
|
|
35
32
|
export const sessionActivitySchema = z
|
|
36
33
|
.object({
|
|
37
|
-
state: z.enum(["idle", "running", "stopping", "approval"
|
|
34
|
+
state: z.enum(["idle", "running", "stopping", "approval"]),
|
|
38
35
|
turnId: turnIdSchema.nullable(),
|
|
39
|
-
reason: z
|
|
40
|
-
.enum(["failed", "owner_lost", "function_executor_required"])
|
|
41
|
-
.nullable(),
|
|
42
36
|
})
|
|
43
37
|
.strip();
|
|
44
38
|
export const sessionInputResponseSchema = z
|
|
@@ -56,7 +50,6 @@ export const submitSessionInputBodySchema = z
|
|
|
56
50
|
requestId: sessionInputRequestIdSchema,
|
|
57
51
|
/** The HTTP boundary validates the user message with AI SDK. */
|
|
58
52
|
message: z.unknown().refine((message) => message !== undefined),
|
|
59
|
-
whenBusy: sessionInputModeSchema.default("queue"),
|
|
60
53
|
})
|
|
61
54
|
.strict();
|
|
62
55
|
export const sessionInputsQuerySchema = z
|
|
@@ -72,9 +65,16 @@ export const stopSessionBodySchema = z
|
|
|
72
65
|
export const stopSessionResponseSchema = z
|
|
73
66
|
.object({ stoppedTurnId: turnIdSchema, activity: sessionActivitySchema })
|
|
74
67
|
.strip();
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
/** Provisional placement observation emitted on the owning Turn stream. */
|
|
69
|
+
export const chatSteerConsumedEventSchema = z
|
|
70
|
+
.object({
|
|
71
|
+
type: z.literal("data-ba-steer-consumed"),
|
|
72
|
+
transient: z.literal(true),
|
|
73
|
+
data: sessionInputSchema.pick({
|
|
74
|
+
requestId: true,
|
|
75
|
+
turnId: true,
|
|
76
|
+
sequence: true,
|
|
77
|
+
message: true,
|
|
78
|
+
}),
|
|
79
|
+
})
|
|
77
80
|
.strip();
|
|
78
|
-
export const runSessionInputsBodySchema = z
|
|
79
|
-
.object({ functions: chatFunctionDefinitionsSchema.optional() })
|
|
80
|
-
.strict();
|