@blazingagents/sdk 0.17.0 → 0.18.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/contracts/api.d.ts +6 -0
- package/dist/contracts/api.js +2 -0
- package/dist/contracts/entities/session-inputs.d.ts +235 -0
- package/dist/contracts/entities/session-inputs.js +80 -0
- package/dist/contracts/index.d.ts +2 -0
- package/dist/contracts/index.js +1 -0
- package/dist/direct-chat-transport.d.ts +7 -0
- package/dist/direct-chat-transport.js +26 -0
- package/dist/generation.d.ts +1 -1
- package/dist/generation.js +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/resources/sessions.js +45 -1
- package/dist/types.d.ts +45 -0
- package/package.json +1 -1
package/dist/contracts/api.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ export declare const apiErrorCodeSchema: z.ZodEnum<{
|
|
|
31
31
|
forbidden: "forbidden";
|
|
32
32
|
function_call_conflict: "function_call_conflict";
|
|
33
33
|
idempotency_conflict: "idempotency_conflict";
|
|
34
|
+
input_idempotency_conflict: "input_idempotency_conflict";
|
|
35
|
+
input_not_pending: "input_not_pending";
|
|
34
36
|
internal: "internal";
|
|
35
37
|
invalid_cursor: "invalid_cursor";
|
|
36
38
|
invalid_request: "invalid_request";
|
|
@@ -109,6 +111,8 @@ export declare const apiErrorSchema: z.ZodObject<{
|
|
|
109
111
|
forbidden: "forbidden";
|
|
110
112
|
function_call_conflict: "function_call_conflict";
|
|
111
113
|
idempotency_conflict: "idempotency_conflict";
|
|
114
|
+
input_idempotency_conflict: "input_idempotency_conflict";
|
|
115
|
+
input_not_pending: "input_not_pending";
|
|
112
116
|
internal: "internal";
|
|
113
117
|
invalid_cursor: "invalid_cursor";
|
|
114
118
|
invalid_request: "invalid_request";
|
|
@@ -192,6 +196,8 @@ export declare const apiErrorResponseSchema: z.ZodObject<{
|
|
|
192
196
|
forbidden: "forbidden";
|
|
193
197
|
function_call_conflict: "function_call_conflict";
|
|
194
198
|
idempotency_conflict: "idempotency_conflict";
|
|
199
|
+
input_idempotency_conflict: "input_idempotency_conflict";
|
|
200
|
+
input_not_pending: "input_not_pending";
|
|
195
201
|
internal: "internal";
|
|
196
202
|
invalid_cursor: "invalid_cursor";
|
|
197
203
|
invalid_request: "invalid_request";
|
package/dist/contracts/api.js
CHANGED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const sessionInputStateSchema: z.ZodEnum<{
|
|
3
|
+
accepted: "accepted";
|
|
4
|
+
cancelled: "cancelled";
|
|
5
|
+
committed: "committed";
|
|
6
|
+
consumed: "consumed";
|
|
7
|
+
delivered: "delivered";
|
|
8
|
+
uncertain: "uncertain";
|
|
9
|
+
}>;
|
|
10
|
+
export declare const sessionInputModeSchema: z.ZodEnum<{
|
|
11
|
+
queue: "queue";
|
|
12
|
+
steer: "steer";
|
|
13
|
+
}>;
|
|
14
|
+
export declare const sessionInputRequestIdSchema: z.ZodString;
|
|
15
|
+
export declare const sessionInputSchema: z.ZodObject<{
|
|
16
|
+
requestId: z.ZodString;
|
|
17
|
+
sequence: z.ZodNumber;
|
|
18
|
+
message: z.ZodObject<{
|
|
19
|
+
id: z.ZodString;
|
|
20
|
+
parts: z.ZodArray<z.ZodObject<{
|
|
21
|
+
type: z.ZodString;
|
|
22
|
+
}, z.core.$loose>>;
|
|
23
|
+
metadata: z.ZodOptional<z.ZodUnknown>;
|
|
24
|
+
role: z.ZodLiteral<"user">;
|
|
25
|
+
}, z.core.$loose>;
|
|
26
|
+
mode: z.ZodEnum<{
|
|
27
|
+
queue: "queue";
|
|
28
|
+
steer: "steer";
|
|
29
|
+
}>;
|
|
30
|
+
state: z.ZodEnum<{
|
|
31
|
+
accepted: "accepted";
|
|
32
|
+
cancelled: "cancelled";
|
|
33
|
+
committed: "committed";
|
|
34
|
+
consumed: "consumed";
|
|
35
|
+
delivered: "delivered";
|
|
36
|
+
uncertain: "uncertain";
|
|
37
|
+
}>;
|
|
38
|
+
turnId: z.ZodNullable<z.ZodString>;
|
|
39
|
+
createdAt: z.ZodISODateTime;
|
|
40
|
+
updatedAt: z.ZodISODateTime;
|
|
41
|
+
consumedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
42
|
+
reason: z.ZodNullable<z.ZodEnum<{
|
|
43
|
+
deleted: "deleted";
|
|
44
|
+
failed: "failed";
|
|
45
|
+
owner_lost: "owner_lost";
|
|
46
|
+
stopped: "stopped";
|
|
47
|
+
}>>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
export declare const sessionActivitySchema: z.ZodObject<{
|
|
50
|
+
state: z.ZodEnum<{
|
|
51
|
+
approval: "approval";
|
|
52
|
+
idle: "idle";
|
|
53
|
+
paused: "paused";
|
|
54
|
+
running: "running";
|
|
55
|
+
stopping: "stopping";
|
|
56
|
+
}>;
|
|
57
|
+
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
|
+
}, z.core.$strip>;
|
|
64
|
+
export declare const sessionInputResponseSchema: z.ZodObject<{
|
|
65
|
+
data: z.ZodObject<{
|
|
66
|
+
requestId: z.ZodString;
|
|
67
|
+
sequence: z.ZodNumber;
|
|
68
|
+
message: z.ZodObject<{
|
|
69
|
+
id: z.ZodString;
|
|
70
|
+
parts: z.ZodArray<z.ZodObject<{
|
|
71
|
+
type: z.ZodString;
|
|
72
|
+
}, z.core.$loose>>;
|
|
73
|
+
metadata: z.ZodOptional<z.ZodUnknown>;
|
|
74
|
+
role: z.ZodLiteral<"user">;
|
|
75
|
+
}, z.core.$loose>;
|
|
76
|
+
mode: z.ZodEnum<{
|
|
77
|
+
queue: "queue";
|
|
78
|
+
steer: "steer";
|
|
79
|
+
}>;
|
|
80
|
+
state: z.ZodEnum<{
|
|
81
|
+
accepted: "accepted";
|
|
82
|
+
cancelled: "cancelled";
|
|
83
|
+
committed: "committed";
|
|
84
|
+
consumed: "consumed";
|
|
85
|
+
delivered: "delivered";
|
|
86
|
+
uncertain: "uncertain";
|
|
87
|
+
}>;
|
|
88
|
+
turnId: z.ZodNullable<z.ZodString>;
|
|
89
|
+
createdAt: z.ZodISODateTime;
|
|
90
|
+
updatedAt: z.ZodISODateTime;
|
|
91
|
+
consumedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
92
|
+
reason: z.ZodNullable<z.ZodEnum<{
|
|
93
|
+
deleted: "deleted";
|
|
94
|
+
failed: "failed";
|
|
95
|
+
owner_lost: "owner_lost";
|
|
96
|
+
stopped: "stopped";
|
|
97
|
+
}>>;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
activity: z.ZodObject<{
|
|
100
|
+
state: z.ZodEnum<{
|
|
101
|
+
approval: "approval";
|
|
102
|
+
idle: "idle";
|
|
103
|
+
paused: "paused";
|
|
104
|
+
running: "running";
|
|
105
|
+
stopping: "stopping";
|
|
106
|
+
}>;
|
|
107
|
+
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
|
+
}, z.core.$strip>;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
export declare const sessionInputsResponseSchema: z.ZodObject<{
|
|
116
|
+
data: z.ZodArray<z.ZodObject<{
|
|
117
|
+
requestId: z.ZodString;
|
|
118
|
+
sequence: z.ZodNumber;
|
|
119
|
+
message: z.ZodObject<{
|
|
120
|
+
id: z.ZodString;
|
|
121
|
+
parts: z.ZodArray<z.ZodObject<{
|
|
122
|
+
type: z.ZodString;
|
|
123
|
+
}, z.core.$loose>>;
|
|
124
|
+
metadata: z.ZodOptional<z.ZodUnknown>;
|
|
125
|
+
role: z.ZodLiteral<"user">;
|
|
126
|
+
}, z.core.$loose>;
|
|
127
|
+
mode: z.ZodEnum<{
|
|
128
|
+
queue: "queue";
|
|
129
|
+
steer: "steer";
|
|
130
|
+
}>;
|
|
131
|
+
state: z.ZodEnum<{
|
|
132
|
+
accepted: "accepted";
|
|
133
|
+
cancelled: "cancelled";
|
|
134
|
+
committed: "committed";
|
|
135
|
+
consumed: "consumed";
|
|
136
|
+
delivered: "delivered";
|
|
137
|
+
uncertain: "uncertain";
|
|
138
|
+
}>;
|
|
139
|
+
turnId: z.ZodNullable<z.ZodString>;
|
|
140
|
+
createdAt: z.ZodISODateTime;
|
|
141
|
+
updatedAt: z.ZodISODateTime;
|
|
142
|
+
consumedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
143
|
+
reason: z.ZodNullable<z.ZodEnum<{
|
|
144
|
+
deleted: "deleted";
|
|
145
|
+
failed: "failed";
|
|
146
|
+
owner_lost: "owner_lost";
|
|
147
|
+
stopped: "stopped";
|
|
148
|
+
}>>;
|
|
149
|
+
}, z.core.$strip>>;
|
|
150
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
151
|
+
activity: z.ZodObject<{
|
|
152
|
+
state: z.ZodEnum<{
|
|
153
|
+
approval: "approval";
|
|
154
|
+
idle: "idle";
|
|
155
|
+
paused: "paused";
|
|
156
|
+
running: "running";
|
|
157
|
+
stopping: "stopping";
|
|
158
|
+
}>;
|
|
159
|
+
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
|
+
}, z.core.$strip>;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
export declare const submitSessionInputBodySchema: z.ZodObject<{
|
|
168
|
+
requestId: z.ZodString;
|
|
169
|
+
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
|
+
}, z.core.$strict>;
|
|
175
|
+
export declare const sessionInputsQuerySchema: z.ZodObject<{
|
|
176
|
+
includeCompleted: z.ZodDefault<z.ZodBoolean>;
|
|
177
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
178
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
179
|
+
}, z.core.$strict>;
|
|
180
|
+
export declare const stopSessionBodySchema: z.ZodObject<{
|
|
181
|
+
turnId: z.ZodString;
|
|
182
|
+
}, z.core.$strict>;
|
|
183
|
+
export declare const stopSessionResponseSchema: z.ZodObject<{
|
|
184
|
+
stoppedTurnId: z.ZodString;
|
|
185
|
+
activity: z.ZodObject<{
|
|
186
|
+
state: z.ZodEnum<{
|
|
187
|
+
approval: "approval";
|
|
188
|
+
idle: "idle";
|
|
189
|
+
paused: "paused";
|
|
190
|
+
running: "running";
|
|
191
|
+
stopping: "stopping";
|
|
192
|
+
}>;
|
|
193
|
+
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
|
+
}, z.core.$strip>;
|
|
217
|
+
}, z.core.$strip>;
|
|
218
|
+
export type SessionInputState = z.infer<typeof sessionInputStateSchema>;
|
|
219
|
+
export type SessionInputMode = z.infer<typeof sessionInputModeSchema>;
|
|
220
|
+
export type SessionInput = z.infer<typeof sessionInputSchema>;
|
|
221
|
+
export type SessionActivity = z.infer<typeof sessionActivitySchema>;
|
|
222
|
+
export type SessionInputResponse = z.infer<typeof sessionInputResponseSchema>;
|
|
223
|
+
export type SessionInputsResponse = z.infer<typeof sessionInputsResponseSchema>;
|
|
224
|
+
export type SubmitSessionInputBody = z.input<typeof submitSessionInputBodySchema>;
|
|
225
|
+
export type SessionInputsQuery = z.input<typeof sessionInputsQuerySchema>;
|
|
226
|
+
export type StopSessionBody = z.infer<typeof stopSessionBodySchema>;
|
|
227
|
+
export type StopSessionResponse = z.infer<typeof stopSessionResponseSchema>;
|
|
228
|
+
export type ResumeSessionInputsResponse = z.infer<typeof resumeSessionInputsResponseSchema>;
|
|
229
|
+
export declare const runSessionInputsBodySchema: z.ZodObject<{
|
|
230
|
+
functions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
231
|
+
description: z.ZodString;
|
|
232
|
+
inputSchema: z.ZodCustom<z.core.JSONSchema.JSONSchema, z.core.JSONSchema.JSONSchema>;
|
|
233
|
+
}, z.core.$strict>>>;
|
|
234
|
+
}, z.core.$strict>;
|
|
235
|
+
export type RunSessionInputsBody = z.infer<typeof runSessionInputsBodySchema>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { turnIdSchema } from "../ids.js";
|
|
3
|
+
import { chatFunctionDefinitionsSchema } from "./chat.js";
|
|
4
|
+
import { sessionMessageSchema } from "./sessions.js";
|
|
5
|
+
export const sessionInputStateSchema = z.enum([
|
|
6
|
+
"accepted",
|
|
7
|
+
"delivered",
|
|
8
|
+
"consumed",
|
|
9
|
+
"committed",
|
|
10
|
+
"cancelled",
|
|
11
|
+
"uncertain",
|
|
12
|
+
]);
|
|
13
|
+
export const sessionInputModeSchema = z.enum(["queue", "steer"]);
|
|
14
|
+
export const sessionInputRequestIdSchema = z
|
|
15
|
+
.string()
|
|
16
|
+
.min(1)
|
|
17
|
+
.max(128)
|
|
18
|
+
.refine((requestId) => requestId !== "." && requestId !== "..", {
|
|
19
|
+
message: "requestId must not be a URL dot segment.",
|
|
20
|
+
});
|
|
21
|
+
export const sessionInputSchema = z
|
|
22
|
+
.object({
|
|
23
|
+
requestId: sessionInputRequestIdSchema,
|
|
24
|
+
sequence: z.number().int().positive(),
|
|
25
|
+
message: sessionMessageSchema.extend({ role: z.literal("user") }),
|
|
26
|
+
mode: sessionInputModeSchema,
|
|
27
|
+
state: sessionInputStateSchema,
|
|
28
|
+
turnId: turnIdSchema.nullable(),
|
|
29
|
+
createdAt: z.iso.datetime({ offset: true }),
|
|
30
|
+
updatedAt: z.iso.datetime({ offset: true }),
|
|
31
|
+
consumedAt: z.iso.datetime({ offset: true }).nullable(),
|
|
32
|
+
reason: z.enum(["stopped", "failed", "owner_lost", "deleted"]).nullable(),
|
|
33
|
+
})
|
|
34
|
+
.strip();
|
|
35
|
+
export const sessionActivitySchema = z
|
|
36
|
+
.object({
|
|
37
|
+
state: z.enum(["idle", "running", "stopping", "approval", "paused"]),
|
|
38
|
+
turnId: turnIdSchema.nullable(),
|
|
39
|
+
reason: z
|
|
40
|
+
.enum(["failed", "owner_lost", "function_executor_required"])
|
|
41
|
+
.nullable(),
|
|
42
|
+
})
|
|
43
|
+
.strip();
|
|
44
|
+
export const sessionInputResponseSchema = z
|
|
45
|
+
.object({ data: sessionInputSchema, activity: sessionActivitySchema })
|
|
46
|
+
.strip();
|
|
47
|
+
export const sessionInputsResponseSchema = z
|
|
48
|
+
.object({
|
|
49
|
+
data: z.array(sessionInputSchema),
|
|
50
|
+
nextCursor: z.string().nullable(),
|
|
51
|
+
activity: sessionActivitySchema,
|
|
52
|
+
})
|
|
53
|
+
.strip();
|
|
54
|
+
export const submitSessionInputBodySchema = z
|
|
55
|
+
.object({
|
|
56
|
+
requestId: sessionInputRequestIdSchema,
|
|
57
|
+
/** The HTTP boundary validates the user message with AI SDK. */
|
|
58
|
+
message: z.unknown().refine((message) => message !== undefined),
|
|
59
|
+
whenBusy: sessionInputModeSchema.default("queue"),
|
|
60
|
+
})
|
|
61
|
+
.strict();
|
|
62
|
+
export const sessionInputsQuerySchema = z
|
|
63
|
+
.object({
|
|
64
|
+
includeCompleted: z.boolean().default(false),
|
|
65
|
+
limit: z.number().int().min(1).max(200).default(100),
|
|
66
|
+
cursor: z.string().min(1).optional(),
|
|
67
|
+
})
|
|
68
|
+
.strict();
|
|
69
|
+
export const stopSessionBodySchema = z
|
|
70
|
+
.object({ turnId: turnIdSchema })
|
|
71
|
+
.strict();
|
|
72
|
+
export const stopSessionResponseSchema = z
|
|
73
|
+
.object({ stoppedTurnId: turnIdSchema, activity: sessionActivitySchema })
|
|
74
|
+
.strip();
|
|
75
|
+
export const resumeSessionInputsResponseSchema = z
|
|
76
|
+
.object({ activity: sessionActivitySchema })
|
|
77
|
+
.strip();
|
|
78
|
+
export const runSessionInputsBodySchema = z
|
|
79
|
+
.object({ functions: chatFunctionDefinitionsSchema.optional() })
|
|
80
|
+
.strict();
|
|
@@ -14,6 +14,8 @@ export { createMemoryBodySchema, memoriesListResponseSchema, memoryResponseSchem
|
|
|
14
14
|
export { createMerchantConnectionBodySchema, merchantBindingResponseSchema, merchantBindingsResponseSchema, merchantConnectionResponseSchema, merchantConnectionSchema, merchantConnectionStatusSchema, merchantCustomerBindingSchema, merchantEnvironmentSchema, merchantGuardSchema, merchantProviderSchema, merchantUsageEventNextAction, merchantUsageEventNextActionSchema, merchantUsageEventSchema, merchantUsageEventStatusSchema, merchantUsageEventsResponseSchema, merchantUsageSummaryQuerySchema, merchantUsageSummaryResponseSchema, merchantUsageSummarySchema, merchantWorkflowIssueSchema, updateMerchantConnectionBodySchema, upsertMerchantBindingBodySchema, } from "./entities/merchant.ts";
|
|
15
15
|
export { createPromptBodySchema, parsePromptVariables, promptResponseSchema, promptSchema, promptsListQuerySchema, promptsResponseSchema, promptTemplateSchema, renderPromptTemplate, updatePromptBodySchema, } from "./entities/prompts.ts";
|
|
16
16
|
export { createProviderBodySchema, providerListItemSchema, providerModelsResponseSchema, providerResponseSchema, providersResponseSchema, providerTypeSchema, thinkingLevelsResponseSchema, updateProviderBodySchema, } from "./entities/providers.ts";
|
|
17
|
+
export type { ResumeSessionInputsResponse, RunSessionInputsBody, SessionActivity, SessionInput, SessionInputMode, SessionInputResponse, SessionInputState, SessionInputsQuery, SessionInputsResponse, StopSessionBody, StopSessionResponse, SubmitSessionInputBody, } from "./entities/session-inputs.ts";
|
|
18
|
+
export { resumeSessionInputsResponseSchema, runSessionInputsBodySchema, sessionActivitySchema, sessionInputModeSchema, sessionInputRequestIdSchema, sessionInputResponseSchema, sessionInputSchema, sessionInputStateSchema, sessionInputsQuerySchema, sessionInputsResponseSchema, stopSessionBodySchema, stopSessionResponseSchema, submitSessionInputBodySchema, } from "./entities/session-inputs.ts";
|
|
17
19
|
export type { ToolApprovalDecisionResponse, ToolApprovalsResponse, } from "./entities/sessions.ts";
|
|
18
20
|
export { decideToolApprovalBodySchema, latestSessionListItemSchema, latestSessionsListResponseSchema, sessionListItemSchema, sessionMessageSchema, sessionMessagesResponseSchema, sessionResponseSchema, sessionsListResponseSchema, toolApprovalContinuationStateSchema, toolApprovalDecisionResponseSchema, toolApprovalStateSchema, toolApprovalsResponseSchema, } from "./entities/sessions.ts";
|
|
19
21
|
export { copySkillBodySchema, createSkillBodySchema, skillCopyResultsSchema, skillDetailSchema, skillsListResponseSchema, } from "./entities/skills.ts";
|
package/dist/contracts/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export { createMemoryBodySchema, memoriesListResponseSchema, memoryResponseSchem
|
|
|
13
13
|
export { createMerchantConnectionBodySchema, merchantBindingResponseSchema, merchantBindingsResponseSchema, merchantConnectionResponseSchema, merchantConnectionSchema, merchantConnectionStatusSchema, merchantCustomerBindingSchema, merchantEnvironmentSchema, merchantGuardSchema, merchantProviderSchema, merchantUsageEventNextAction, merchantUsageEventNextActionSchema, merchantUsageEventSchema, merchantUsageEventStatusSchema, merchantUsageEventsResponseSchema, merchantUsageSummaryQuerySchema, merchantUsageSummaryResponseSchema, merchantUsageSummarySchema, merchantWorkflowIssueSchema, updateMerchantConnectionBodySchema, upsertMerchantBindingBodySchema, } from "./entities/merchant.js";
|
|
14
14
|
export { createPromptBodySchema, parsePromptVariables, promptResponseSchema, promptSchema, promptsListQuerySchema, promptsResponseSchema, promptTemplateSchema, renderPromptTemplate, updatePromptBodySchema, } from "./entities/prompts.js";
|
|
15
15
|
export { createProviderBodySchema, providerListItemSchema, providerModelsResponseSchema, providerResponseSchema, providersResponseSchema, providerTypeSchema, thinkingLevelsResponseSchema, updateProviderBodySchema, } from "./entities/providers.js";
|
|
16
|
+
export { resumeSessionInputsResponseSchema, runSessionInputsBodySchema, sessionActivitySchema, sessionInputModeSchema, sessionInputRequestIdSchema, sessionInputResponseSchema, sessionInputSchema, sessionInputStateSchema, sessionInputsQuerySchema, sessionInputsResponseSchema, stopSessionBodySchema, stopSessionResponseSchema, submitSessionInputBodySchema, } from "./entities/session-inputs.js";
|
|
16
17
|
export { decideToolApprovalBodySchema, latestSessionListItemSchema, latestSessionsListResponseSchema, sessionListItemSchema, sessionMessageSchema, sessionMessagesResponseSchema, sessionResponseSchema, sessionsListResponseSchema, toolApprovalContinuationStateSchema, toolApprovalDecisionResponseSchema, toolApprovalStateSchema, toolApprovalsResponseSchema, } from "./entities/sessions.js";
|
|
17
18
|
export { copySkillBodySchema, createSkillBodySchema, skillCopyResultsSchema, skillDetailSchema, skillsListResponseSchema, } from "./entities/skills.js";
|
|
18
19
|
export { createTaskBodySchema, createTaskResponseSchema, createTaskRunBodySchema, createTaskRunResponseSchema, taskCronConfigSchema, taskIntervalConfigSchema, taskListItemSchema, taskOnceConfigSchema, taskResponseSchema, taskRunMessagesResponseSchema, taskRunResponseSchema, taskRunSchema, taskRunStatusSchema, taskRunsListResponseSchema, taskScheduleInputSchema, taskScheduleKindSchema, taskSchema, tasksListResponseSchema, updateTaskBodySchema, } from "./entities/tasks.js";
|
|
@@ -22,6 +22,13 @@ export type BlazingAgentsDirectChatTransportOptions = {
|
|
|
22
22
|
export declare class BlazingAgentsDirectChatTransport<UI_MESSAGE extends UIMessage = UIMessage> extends DefaultChatTransport<UI_MESSAGE> {
|
|
23
23
|
#private;
|
|
24
24
|
constructor(options: BlazingAgentsDirectChatTransportOptions);
|
|
25
|
+
joinInputTurn(input: {
|
|
26
|
+
turnId: string;
|
|
27
|
+
abortSignal?: AbortSignal;
|
|
28
|
+
}): Promise<ReadableStream<import("ai").UIMessageChunk<unknown, import("ai").UIDataTypes>>>;
|
|
29
|
+
runInputs(input?: {
|
|
30
|
+
abortSignal?: AbortSignal;
|
|
31
|
+
}): Promise<ReadableStream<import("ai").UIMessageChunk<unknown, import("ai").UIDataTypes>>>;
|
|
25
32
|
sendMessages(input: Parameters<ChatTransport<UI_MESSAGE>["sendMessages"]>[0]): Promise<ReadableStream<import("ai").UIMessageChunk<unknown, import("ai").UIDataTypes>>>;
|
|
26
33
|
reconnectToStream(_input: Parameters<ChatTransport<UI_MESSAGE>["reconnectToStream"]>[0]): Promise<ReadableStream<import("ai").UIMessageChunk<unknown, import("ai").UIDataTypes>> | null>;
|
|
27
34
|
}
|
|
@@ -13,6 +13,32 @@ export class BlazingAgentsDirectChatTransport extends DefaultChatTransport {
|
|
|
13
13
|
? undefined
|
|
14
14
|
: sessionIdSchema.parse(options.sessionId);
|
|
15
15
|
}
|
|
16
|
+
async joinInputTurn(input) {
|
|
17
|
+
if (this.#sessionId === undefined) {
|
|
18
|
+
throw new Error("Input Turn attachment requires an existing Session.");
|
|
19
|
+
}
|
|
20
|
+
const client = await this.#options.getClient();
|
|
21
|
+
const result = await client.sessions.joinInputTurn({
|
|
22
|
+
...input,
|
|
23
|
+
agentId: this.#options.agentId,
|
|
24
|
+
sessionId: this.#sessionId,
|
|
25
|
+
functions: this.#options.functions,
|
|
26
|
+
});
|
|
27
|
+
return this.processResponseStream(result.toStream());
|
|
28
|
+
}
|
|
29
|
+
async runInputs(input = {}) {
|
|
30
|
+
if (this.#sessionId === undefined) {
|
|
31
|
+
throw new Error("Input batch admission requires an existing Session.");
|
|
32
|
+
}
|
|
33
|
+
const client = await this.#options.getClient();
|
|
34
|
+
const result = await client.sessions.runInputs({
|
|
35
|
+
...input,
|
|
36
|
+
agentId: this.#options.agentId,
|
|
37
|
+
sessionId: this.#sessionId,
|
|
38
|
+
functions: this.#options.functions,
|
|
39
|
+
});
|
|
40
|
+
return this.processResponseStream(result.toStream());
|
|
41
|
+
}
|
|
16
42
|
async sendMessages(input) {
|
|
17
43
|
if (input.trigger === "regenerate-message" && !this.#sessionId) {
|
|
18
44
|
throw new Error("Regeneration requires an existing Session.");
|
package/dist/generation.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ export declare function resumeChat(config: HttpConfig, input: ResumeChatInput):
|
|
|
6
6
|
* bodies pass through so the stream result reports them as `stream_error`.
|
|
7
7
|
*/
|
|
8
8
|
export declare function withFilteredBody(response: Response, filter: (body: ReadableStream<Uint8Array>) => ReadableStream<Uint8Array>): Response;
|
|
9
|
-
export declare function buildTerminalStreamResult(response: Response, resourceName: string): TerminalStreamResult;
|
|
9
|
+
export declare function buildTerminalStreamResult(response: Response, resourceName: string, filter?: (body: ReadableStream<Uint8Array>) => ReadableStream<Uint8Array>): TerminalStreamResult;
|
|
10
10
|
export declare function completion(config: HttpConfig, input: CompletionInput): Promise<CompletionResult>;
|
|
11
11
|
export declare function objectGeneration(config: HttpConfig, input: ObjectInput): Promise<ObjectResult>;
|
package/dist/generation.js
CHANGED
|
@@ -159,7 +159,7 @@ function buildChatResult(config, response, resumeSessionId, dispatch) {
|
|
|
159
159
|
...buildTerminalStreamResult(streamResponse, "chat"),
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
|
-
export function buildTerminalStreamResult(response, resourceName) {
|
|
162
|
+
export function buildTerminalStreamResult(response, resourceName, filter) {
|
|
163
163
|
const requestId = response.headers.get("x-request-id") ?? undefined;
|
|
164
164
|
const location = response.headers.get("location");
|
|
165
165
|
let bodyClaimed = false;
|
|
@@ -174,7 +174,8 @@ export function buildTerminalStreamResult(response, resourceName) {
|
|
|
174
174
|
}, { cause });
|
|
175
175
|
}
|
|
176
176
|
bodyClaimed = true;
|
|
177
|
-
|
|
177
|
+
const body = responseBodyStream(response, requestId, resourceName);
|
|
178
|
+
return normalizeStreamErrors(filter ? filter(body) : body, requestId, `The ${resourceName} response stream failed.`);
|
|
178
179
|
};
|
|
179
180
|
return {
|
|
180
181
|
requestId,
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type { CreateMcpConnectionBody, McpAttachmentResponse, McpAttachmentsResp
|
|
|
15
15
|
export type { CreateMerchantConnectionBody, MerchantBindingResponse, MerchantBindingsResponse, MerchantConnection, MerchantConnectionResponse, MerchantCustomerBinding, MerchantGuard, MerchantProviderKind, MerchantUsageEvent, MerchantUsageEventResponse, MerchantUsageEventStatus, MerchantUsageEventsResponse, MerchantUsageSummary, MerchantUsageSummaryResponse, UpdateMerchantConnectionBody, UpsertMerchantBindingBody, } from "./contracts/entities/merchant.ts";
|
|
16
16
|
export type { CreatePromptBody, PromptResponse, PromptsListQuery, PromptsResponse, UpdatePromptBody, } from "./contracts/entities/prompts.ts";
|
|
17
17
|
export type { CreateProviderBody, ProviderListItem, ProviderModel, ProviderModelsResponse, ProviderResponse, ProvidersResponse, ProviderType, ThinkingLevelsResponse, UpdateProviderBody, } from "./contracts/entities/providers.ts";
|
|
18
|
+
export type { ResumeSessionInputsResponse, RunSessionInputsBody, SessionActivity, SessionInput, SessionInputMode, SessionInputResponse, SessionInputState, SessionInputsQuery, SessionInputsResponse, StopSessionBody, StopSessionResponse, SubmitSessionInputBody, } from "./contracts/entities/session-inputs.ts";
|
|
18
19
|
export type { SessionResponse, ToolApprovalDecisionResponse, ToolApprovalState, ToolApprovalsResponse, } from "./contracts/entities/sessions.ts";
|
|
19
20
|
export { sessionResponseSchema } from "./contracts/entities/sessions.ts";
|
|
20
21
|
export type { CreateSkillBody, Skill, SkillArchiveType, SkillCopyResult, SkillCopyResults, SkillDetail, SkillFile, SkillsListResponse, } from "./contracts/entities/skills.ts";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { resumeSessionInputsResponseSchema, sessionInputRequestIdSchema, sessionInputResponseSchema, sessionInputsResponseSchema, stopSessionResponseSchema, } from "../contracts/entities/session-inputs.js";
|
|
1
2
|
import { latestSessionsListResponseSchema, sessionMessagesResponseSchema, sessionResponseSchema, sessionsListResponseSchema, toolApprovalDecisionResponseSchema, toolApprovalsResponseSchema, } from "../contracts/entities/sessions.js";
|
|
2
|
-
import {
|
|
3
|
+
import { agentIdSchema, sessionIdSchema, turnIdSchema, } from "../contracts/ids.js";
|
|
4
|
+
import { dispatchChatFunctions, stripFunctionEvents, toChatFunctionDefinitions, } from "../functions.js";
|
|
3
5
|
import { buildTerminalStreamResult, withFilteredBody } from "../generation.js";
|
|
4
6
|
import { requestJson, requestStream } from "../http.js";
|
|
5
7
|
/**
|
|
@@ -10,6 +12,48 @@ import { requestJson, requestStream } from "../http.js";
|
|
|
10
12
|
*/
|
|
11
13
|
export function createSessionsResource(config) {
|
|
12
14
|
return {
|
|
15
|
+
async joinInputTurn({ agentId, sessionId, turnId, functions, abortSignal, }) {
|
|
16
|
+
const response = await requestStream(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/input-turns/${turnIdSchema.parse(turnId)}`, { signal: abortSignal });
|
|
17
|
+
return buildTerminalStreamResult(response, "input Turn", (body) => functions
|
|
18
|
+
? dispatchChatFunctions(config, { agentId, sessionId, functions, abortSignal }, body)
|
|
19
|
+
: stripFunctionEvents(body));
|
|
20
|
+
},
|
|
21
|
+
async runInputs({ agentId, sessionId, functions, abortSignal }) {
|
|
22
|
+
const response = await requestStream(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/inputs/run`, {
|
|
23
|
+
method: "POST",
|
|
24
|
+
json: functions === undefined
|
|
25
|
+
? {}
|
|
26
|
+
: { functions: toChatFunctionDefinitions(functions) },
|
|
27
|
+
signal: abortSignal,
|
|
28
|
+
});
|
|
29
|
+
return buildTerminalStreamResult(response, "input Turn", (body) => functions
|
|
30
|
+
? dispatchChatFunctions(config, { agentId, sessionId, functions, abortSignal }, body)
|
|
31
|
+
: stripFunctionEvents(body));
|
|
32
|
+
},
|
|
33
|
+
async submitInput({ agentId, sessionId, abortSignal, ...body }) {
|
|
34
|
+
return await requestJson(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/inputs`, { method: "POST", json: body, signal: abortSignal }, sessionInputResponseSchema);
|
|
35
|
+
},
|
|
36
|
+
async inputs({ agentId, sessionId, abortSignal, ...query }) {
|
|
37
|
+
return await requestJson(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/inputs`, { query, signal: abortSignal }, sessionInputsResponseSchema);
|
|
38
|
+
},
|
|
39
|
+
async promoteInput({ agentId, sessionId, requestId, abortSignal }) {
|
|
40
|
+
const inputId = sessionInputRequestIdSchema.parse(requestId);
|
|
41
|
+
return await requestJson(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/inputs/${encodeURIComponent(inputId)}/promote`, { method: "POST", signal: abortSignal }, sessionInputResponseSchema);
|
|
42
|
+
},
|
|
43
|
+
async deleteInput({ agentId, sessionId, requestId, abortSignal }) {
|
|
44
|
+
const inputId = sessionInputRequestIdSchema.parse(requestId);
|
|
45
|
+
return await requestJson(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/inputs/${encodeURIComponent(inputId)}`, { method: "DELETE", signal: abortSignal }, sessionInputResponseSchema);
|
|
46
|
+
},
|
|
47
|
+
async stop({ agentId, sessionId, turnId, abortSignal }) {
|
|
48
|
+
return await requestJson(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/stop`, {
|
|
49
|
+
method: "POST",
|
|
50
|
+
json: { turnId: turnIdSchema.parse(turnId) },
|
|
51
|
+
signal: abortSignal,
|
|
52
|
+
}, stopSessionResponseSchema);
|
|
53
|
+
},
|
|
54
|
+
async resumeInputs({ agentId, sessionId, abortSignal }) {
|
|
55
|
+
return await requestJson(config, `/v1/agents/${agentIdSchema.parse(agentId)}/sessions/${sessionIdSchema.parse(sessionId)}/inputs/resume`, { method: "POST", signal: abortSignal }, resumeSessionInputsResponseSchema);
|
|
56
|
+
},
|
|
13
57
|
async get({ agentId, sessionId, abortSignal }) {
|
|
14
58
|
return await requestJson(config, `/v1/agents/${agentId}/sessions/${sessionId}`, { signal: abortSignal }, sessionResponseSchema);
|
|
15
59
|
},
|
package/dist/types.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { CreateMemoryBody, MemoriesListResponse, MemoryResponse, UpdateMemo
|
|
|
9
9
|
import type { CreateMerchantConnectionBody, MerchantBindingResponse, MerchantBindingsResponse, MerchantConnectionResponse, MerchantUsageEventResponse, MerchantUsageEventStatus, MerchantUsageEventsResponse, MerchantUsageSummaryResponse, UpdateMerchantConnectionBody, UpsertMerchantBindingBody } from "./contracts/entities/merchant.ts";
|
|
10
10
|
import type { CreatePromptBody, PromptResponse, PromptsResponse, UpdatePromptBody } from "./contracts/entities/prompts.ts";
|
|
11
11
|
import type { CreateProviderBody, DeleteProviderOptions, ProviderModelsResponse, ProviderResponse, ProvidersResponse, ThinkingLevelsResponse, UpdateProviderBody } from "./contracts/entities/providers.ts";
|
|
12
|
+
import type { ResumeSessionInputsResponse, SessionInputResponse, SessionInputsQuery, SessionInputsResponse, StopSessionBody, StopSessionResponse, SubmitSessionInputBody } from "./contracts/entities/session-inputs.ts";
|
|
12
13
|
import type { DecideToolApprovalBody, LatestSessionsListResponse, SessionMessagesResponse, SessionResponse, SessionsListResponse, ToolApprovalDecisionResponse, ToolApprovalsResponse } from "./contracts/entities/sessions.ts";
|
|
13
14
|
import type { CreateSkillBody, SkillArchiveType, SkillCopyResults, SkillDetail, SkillsListResponse } from "./contracts/entities/skills.ts";
|
|
14
15
|
import type { CreateTaskBody, CreateTaskResponse, CreateTaskRunBody, CreateTaskRunResponse, TaskResponse, TaskRunMessagesResponse, TaskRunResponse, TaskRunsListResponse, TasksListResponse, UpdateTaskBody } from "./contracts/entities/tasks.ts";
|
|
@@ -404,10 +405,27 @@ export interface SessionsResource {
|
|
|
404
405
|
sessionId: string;
|
|
405
406
|
deleteArtifacts: boolean;
|
|
406
407
|
} & ResourceRequestOptions): Promise<void>;
|
|
408
|
+
deleteInput(input: {
|
|
409
|
+
agentId: string;
|
|
410
|
+
sessionId: string;
|
|
411
|
+
requestId: string;
|
|
412
|
+
} & ResourceRequestOptions): Promise<SessionInputResponse>;
|
|
407
413
|
get(input: {
|
|
408
414
|
agentId: string;
|
|
409
415
|
sessionId: string;
|
|
410
416
|
} & ResourceRequestOptions): Promise<SessionResponse>;
|
|
417
|
+
/** Poll from the first page for state changes; cursor only paginates receipts. */
|
|
418
|
+
inputs(input: {
|
|
419
|
+
agentId: string;
|
|
420
|
+
sessionId: string;
|
|
421
|
+
} & SessionInputsQuery & ResourceRequestOptions): Promise<SessionInputsResponse>;
|
|
422
|
+
/** Replays an admitted input Turn. Supplying functions opts into executor claims. */
|
|
423
|
+
joinInputTurn(input: {
|
|
424
|
+
agentId: string;
|
|
425
|
+
sessionId: string;
|
|
426
|
+
turnId: string;
|
|
427
|
+
functions?: ChatFunctions;
|
|
428
|
+
} & ResourceRequestOptions): Promise<TerminalStreamResult>;
|
|
411
429
|
joinToolApprovalContinuation(input: {
|
|
412
430
|
agentId: string;
|
|
413
431
|
sessionId: string;
|
|
@@ -426,6 +444,33 @@ export interface SessionsResource {
|
|
|
426
444
|
agentId: string;
|
|
427
445
|
sessionId: string;
|
|
428
446
|
} & SessionMessagesOptions): Promise<SessionMessagesResponse>;
|
|
447
|
+
promoteInput(input: {
|
|
448
|
+
agentId: string;
|
|
449
|
+
sessionId: string;
|
|
450
|
+
requestId: string;
|
|
451
|
+
} & ResourceRequestOptions): Promise<SessionInputResponse>;
|
|
452
|
+
/** Resume accepted inputs after a pause. Uncertain inputs are never replayed. */
|
|
453
|
+
resumeInputs(input: {
|
|
454
|
+
agentId: string;
|
|
455
|
+
sessionId: string;
|
|
456
|
+
} & ResourceRequestOptions): Promise<ResumeSessionInputsResponse>;
|
|
457
|
+
/** Admits the pending batch without resubmitting its messages. */
|
|
458
|
+
runInputs(input: {
|
|
459
|
+
agentId: string;
|
|
460
|
+
sessionId: string;
|
|
461
|
+
functions?: ChatFunctions;
|
|
462
|
+
} & ResourceRequestOptions): Promise<TerminalStreamResult>;
|
|
463
|
+
/** Wait for settlement of the named Turn. A queued Turn may already be running. */
|
|
464
|
+
stop(input: {
|
|
465
|
+
agentId: string;
|
|
466
|
+
sessionId: string;
|
|
467
|
+
} & StopSessionBody & ResourceRequestOptions): Promise<StopSessionResponse>;
|
|
468
|
+
/** Retry an uncertain acknowledgement with the same requestId and payload. */
|
|
469
|
+
submitInput(input: Omit<SubmitSessionInputBody, "message"> & {
|
|
470
|
+
agentId: string;
|
|
471
|
+
sessionId: string;
|
|
472
|
+
message: UIMessage;
|
|
473
|
+
} & ResourceRequestOptions): Promise<SessionInputResponse>;
|
|
429
474
|
toolApprovals(input: {
|
|
430
475
|
agentId: string;
|
|
431
476
|
sessionId: string;
|