experimental-agent 0.0.2 → 0.0.4
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 +13 -2
- package/dist/agent-workflow.d.mts +11 -3
- package/dist/agent-workflow.d.ts +11 -3
- package/dist/agent-workflow.js +1921 -1144
- package/dist/agent-workflow.mjs +7 -3
- package/dist/chunk-3ODWQVIA.mjs +12 -0
- package/dist/chunk-64THY7Y7.mjs +155 -0
- package/dist/chunk-GSRJYPWF.mjs +284 -0
- package/dist/chunk-HJGPUEFC.mjs +42 -0
- package/dist/chunk-JCPQQWIK.mjs +2057 -0
- package/dist/chunk-JEE2FQ4O.mjs +844 -0
- package/dist/chunk-T7PMZLOX.mjs +79 -0
- package/dist/chunk-TQRCSTCF.mjs +103 -0
- package/dist/chunk-VBLZWXVE.mjs +318 -0
- package/dist/{types-DPXFq_r6.d.ts → client-6g79J0s3.d.mts} +866 -31
- package/dist/{types-DPXFq_r6.d.mts → client-6g79J0s3.d.ts} +866 -31
- package/dist/client-SREKHM6I.mjs +15 -0
- package/dist/client.d.mts +37 -0
- package/dist/client.d.ts +37 -0
- package/dist/client.js +58 -0
- package/dist/client.mjs +30 -0
- package/dist/{client-HUG4HT5L.mjs → handler-36FM5H35.mjs} +4 -5
- package/dist/index.d.mts +3 -4
- package/dist/index.d.ts +3 -4
- package/dist/index.js +3102 -1438
- package/dist/index.mjs +720 -147
- package/dist/lifecycle-workflow.d.mts +3 -10
- package/dist/lifecycle-workflow.d.ts +3 -10
- package/dist/lifecycle-workflow.js +170 -1246
- package/dist/lifecycle-workflow.mjs +5 -41
- package/dist/local-fs-handlers-P4WGW3QY.mjs +235 -0
- package/dist/next/loader.d.mts +14 -0
- package/dist/next/loader.d.ts +14 -0
- package/dist/next/loader.js +206 -0
- package/dist/next/loader.mjs +103 -0
- package/dist/next.d.mts +34 -0
- package/dist/next.d.ts +34 -0
- package/dist/next.js +329 -0
- package/dist/next.mjs +224 -0
- package/dist/process-manager-JAKAXROL.mjs +10 -0
- package/dist/{client-4Y3UPWFR.mjs → sandbox-QAPGBVYM.mjs} +4 -3
- package/dist/storage-Q376OZH3.mjs +20 -0
- package/dist/{vercel-2CFDMEHB.mjs → vercel-LLXAHKVJ.mjs} +3 -1
- package/dist/vercel-sdk-VHKEX2GQ.mjs +8 -0
- package/package.json +32 -19
- package/dist/chunk-24DJSI7C.mjs +0 -374
- package/dist/chunk-4RGMKC2M.mjs +0 -755
- package/dist/chunk-6ICYKNCC.mjs +0 -284
- package/dist/chunk-PGYYQ3WZ.mjs +0 -1088
- package/dist/client-BBpD9kKL.d.ts +0 -193
- package/dist/client-BGJViybU.d.mts +0 -193
- package/dist/lifecycle-workflow-steps-HHN46ZAD.mjs +0 -20
- package/dist/local-BYPFRMLZ.mjs +0 -282
- package/dist/process-manager-H2HF6G4G.mjs +0 -153
- package/dist/sandbox-BFA4ECEQ.mjs +0 -10
- package/dist/storage-2U2QFNWI.mjs +0 -27
- /package/dist/{chunk-36X6L7SK.mjs → chunk-TAXLUVIC.mjs} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { UIMessage } from 'ai';
|
|
2
|
-
import { z } from 'zod';
|
|
3
1
|
import * as errore from 'errore';
|
|
2
|
+
import * as ai from 'ai';
|
|
3
|
+
import { UIMessage, JSONSchema7, ToolSet, InferToolInput, ModelMessage, GatewayModelId, UIDataTypes, InferUITools, UIMessageChunk } from 'ai';
|
|
4
|
+
import { z } from 'zod';
|
|
4
5
|
|
|
5
6
|
declare const SessionNotFoundError_base: errore.FactoryTaggedErrorClass<"SessionNotFoundError", "Session $id not found", Error>;
|
|
6
7
|
declare class SessionNotFoundError extends SessionNotFoundError_base {
|
|
@@ -28,6 +29,7 @@ declare const SandboxConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
28
29
|
}, z.core.$strip>>;
|
|
29
30
|
ports: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
30
31
|
lifecycle: z.ZodOptional<z.ZodObject<{
|
|
32
|
+
pollIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
31
33
|
stopAfterInactiveMs: z.ZodOptional<z.ZodNumber>;
|
|
32
34
|
snapshotBeforeTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
33
35
|
snapshotId: z.ZodOptional<z.ZodString>;
|
|
@@ -49,25 +51,102 @@ declare const SessionSchema: z.ZodObject<{
|
|
|
49
51
|
runId: z.ZodNullable<z.ZodString>;
|
|
50
52
|
lastMessageId: z.ZodNullable<z.ZodString>;
|
|
51
53
|
tags: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
52
|
-
|
|
54
|
+
system: z.ZodNullable<z.ZodString>;
|
|
53
55
|
model: z.ZodNullable<z.ZodString>;
|
|
54
|
-
mcp: z.ZodNullable<z.ZodUnknown>;
|
|
55
56
|
sandboxId: z.ZodNullable<z.ZodString>;
|
|
56
57
|
skillsDir: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
57
58
|
hookToken: z.ZodNullable<z.ZodString>;
|
|
59
|
+
activeTools: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
60
|
+
generation: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
61
|
+
maxSteps: z.ZodOptional<z.ZodNumber>;
|
|
62
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
63
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
frequencyPenalty: z.ZodOptional<z.ZodNumber>;
|
|
66
|
+
presencePenalty: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
69
|
+
}, z.core.$strip>>>;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
declare const StepUsageSchema: z.ZodObject<{
|
|
72
|
+
stepIndex: z.ZodNumber;
|
|
73
|
+
model: z.ZodString;
|
|
74
|
+
inputTokens: z.ZodNumber;
|
|
75
|
+
outputTokens: z.ZodNumber;
|
|
76
|
+
totalTokens: z.ZodNumber;
|
|
77
|
+
cacheReadTokens: z.ZodNumber;
|
|
78
|
+
cacheWriteTokens: z.ZodNumber;
|
|
79
|
+
reasoningTokens: z.ZodNumber;
|
|
80
|
+
}, z.core.$strip>;
|
|
81
|
+
declare const UsageSummarySchema: z.ZodObject<{
|
|
82
|
+
model: z.ZodString;
|
|
83
|
+
inputTokens: z.ZodNumber;
|
|
84
|
+
outputTokens: z.ZodNumber;
|
|
85
|
+
totalTokens: z.ZodNumber;
|
|
86
|
+
cacheReadTokens: z.ZodNumber;
|
|
87
|
+
cacheWriteTokens: z.ZodNumber;
|
|
88
|
+
reasoningTokens: z.ZodNumber;
|
|
89
|
+
stepCount: z.ZodNumber;
|
|
58
90
|
}, z.core.$strip>;
|
|
91
|
+
declare const MessageUsageSchema: z.ZodObject<{
|
|
92
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
93
|
+
stepIndex: z.ZodNumber;
|
|
94
|
+
model: z.ZodString;
|
|
95
|
+
inputTokens: z.ZodNumber;
|
|
96
|
+
outputTokens: z.ZodNumber;
|
|
97
|
+
totalTokens: z.ZodNumber;
|
|
98
|
+
cacheReadTokens: z.ZodNumber;
|
|
99
|
+
cacheWriteTokens: z.ZodNumber;
|
|
100
|
+
reasoningTokens: z.ZodNumber;
|
|
101
|
+
}, z.core.$strip>>;
|
|
102
|
+
summary: z.ZodObject<{
|
|
103
|
+
model: z.ZodString;
|
|
104
|
+
inputTokens: z.ZodNumber;
|
|
105
|
+
outputTokens: z.ZodNumber;
|
|
106
|
+
totalTokens: z.ZodNumber;
|
|
107
|
+
cacheReadTokens: z.ZodNumber;
|
|
108
|
+
cacheWriteTokens: z.ZodNumber;
|
|
109
|
+
reasoningTokens: z.ZodNumber;
|
|
110
|
+
stepCount: z.ZodNumber;
|
|
111
|
+
}, z.core.$strip>;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
type MessageUsage = z.infer<typeof MessageUsageSchema>;
|
|
114
|
+
type UsageSummary = z.infer<typeof UsageSummarySchema>;
|
|
115
|
+
type StepUsage = z.infer<typeof StepUsageSchema>;
|
|
59
116
|
declare const MessageSchema: z.ZodObject<{
|
|
60
117
|
id: z.ZodString;
|
|
61
118
|
sessionId: z.ZodString;
|
|
62
119
|
role: z.ZodEnum<{
|
|
120
|
+
system: "system";
|
|
63
121
|
user: "user";
|
|
64
122
|
assistant: "assistant";
|
|
65
|
-
system: "system";
|
|
66
123
|
}>;
|
|
67
124
|
createdAt: z.ZodNumber;
|
|
125
|
+
startedAt: z.ZodNullable<z.ZodNumber>;
|
|
68
126
|
completedAt: z.ZodNullable<z.ZodNumber>;
|
|
69
127
|
interruptedAt: z.ZodNullable<z.ZodNumber>;
|
|
70
|
-
|
|
128
|
+
usage: z.ZodNullable<z.ZodObject<{
|
|
129
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
130
|
+
stepIndex: z.ZodNumber;
|
|
131
|
+
model: z.ZodString;
|
|
132
|
+
inputTokens: z.ZodNumber;
|
|
133
|
+
outputTokens: z.ZodNumber;
|
|
134
|
+
totalTokens: z.ZodNumber;
|
|
135
|
+
cacheReadTokens: z.ZodNumber;
|
|
136
|
+
cacheWriteTokens: z.ZodNumber;
|
|
137
|
+
reasoningTokens: z.ZodNumber;
|
|
138
|
+
}, z.core.$strip>>;
|
|
139
|
+
summary: z.ZodObject<{
|
|
140
|
+
model: z.ZodString;
|
|
141
|
+
inputTokens: z.ZodNumber;
|
|
142
|
+
outputTokens: z.ZodNumber;
|
|
143
|
+
totalTokens: z.ZodNumber;
|
|
144
|
+
cacheReadTokens: z.ZodNumber;
|
|
145
|
+
cacheWriteTokens: z.ZodNumber;
|
|
146
|
+
reasoningTokens: z.ZodNumber;
|
|
147
|
+
stepCount: z.ZodNumber;
|
|
148
|
+
}, z.core.$strip>;
|
|
149
|
+
}, z.core.$strip>>;
|
|
71
150
|
}, z.core.$strip>;
|
|
72
151
|
/**
|
|
73
152
|
* The `part` field corresponds to `UIMessage["parts"][number]` from the `ai` package.
|
|
@@ -90,6 +169,7 @@ declare const SandboxRecordSchema: z.ZodObject<{
|
|
|
90
169
|
}, z.core.$strip>>;
|
|
91
170
|
ports: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
92
171
|
lifecycle: z.ZodOptional<z.ZodObject<{
|
|
172
|
+
pollIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
93
173
|
stopAfterInactiveMs: z.ZodOptional<z.ZodNumber>;
|
|
94
174
|
snapshotBeforeTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
95
175
|
snapshotId: z.ZodOptional<z.ZodString>;
|
|
@@ -173,12 +253,22 @@ declare const methods: {
|
|
|
173
253
|
runId: z.ZodNullable<z.ZodString>;
|
|
174
254
|
lastMessageId: z.ZodNullable<z.ZodString>;
|
|
175
255
|
tags: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
176
|
-
|
|
256
|
+
system: z.ZodNullable<z.ZodString>;
|
|
177
257
|
model: z.ZodNullable<z.ZodString>;
|
|
178
|
-
mcp: z.ZodNullable<z.ZodUnknown>;
|
|
179
258
|
sandboxId: z.ZodNullable<z.ZodString>;
|
|
180
259
|
skillsDir: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
181
260
|
hookToken: z.ZodNullable<z.ZodString>;
|
|
261
|
+
activeTools: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
262
|
+
generation: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
263
|
+
maxSteps: z.ZodOptional<z.ZodNumber>;
|
|
264
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
265
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
266
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
267
|
+
frequencyPenalty: z.ZodOptional<z.ZodNumber>;
|
|
268
|
+
presencePenalty: z.ZodOptional<z.ZodNumber>;
|
|
269
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
270
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
271
|
+
}, z.core.$strip>>>;
|
|
182
272
|
}, z.core.$strip>>;
|
|
183
273
|
};
|
|
184
274
|
readonly "session.set": {
|
|
@@ -189,12 +279,22 @@ declare const methods: {
|
|
|
189
279
|
runId: z.ZodNullable<z.ZodString>;
|
|
190
280
|
lastMessageId: z.ZodNullable<z.ZodString>;
|
|
191
281
|
tags: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
192
|
-
|
|
282
|
+
system: z.ZodNullable<z.ZodString>;
|
|
193
283
|
model: z.ZodNullable<z.ZodString>;
|
|
194
|
-
mcp: z.ZodNullable<z.ZodUnknown>;
|
|
195
284
|
sandboxId: z.ZodNullable<z.ZodString>;
|
|
196
285
|
skillsDir: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
197
286
|
hookToken: z.ZodNullable<z.ZodString>;
|
|
287
|
+
activeTools: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
288
|
+
generation: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
289
|
+
maxSteps: z.ZodOptional<z.ZodNumber>;
|
|
290
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
291
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
292
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
293
|
+
frequencyPenalty: z.ZodOptional<z.ZodNumber>;
|
|
294
|
+
presencePenalty: z.ZodOptional<z.ZodNumber>;
|
|
295
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
296
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
297
|
+
}, z.core.$strip>>>;
|
|
198
298
|
}, z.core.$strip>;
|
|
199
299
|
readonly result: z.ZodObject<{
|
|
200
300
|
id: z.ZodString;
|
|
@@ -203,12 +303,22 @@ declare const methods: {
|
|
|
203
303
|
runId: z.ZodNullable<z.ZodString>;
|
|
204
304
|
lastMessageId: z.ZodNullable<z.ZodString>;
|
|
205
305
|
tags: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
206
|
-
|
|
306
|
+
system: z.ZodNullable<z.ZodString>;
|
|
207
307
|
model: z.ZodNullable<z.ZodString>;
|
|
208
|
-
mcp: z.ZodNullable<z.ZodUnknown>;
|
|
209
308
|
sandboxId: z.ZodNullable<z.ZodString>;
|
|
210
309
|
skillsDir: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
211
310
|
hookToken: z.ZodNullable<z.ZodString>;
|
|
311
|
+
activeTools: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
312
|
+
generation: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
313
|
+
maxSteps: z.ZodOptional<z.ZodNumber>;
|
|
314
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
315
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
316
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
317
|
+
frequencyPenalty: z.ZodOptional<z.ZodNumber>;
|
|
318
|
+
presencePenalty: z.ZodOptional<z.ZodNumber>;
|
|
319
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
320
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
321
|
+
}, z.core.$strip>>>;
|
|
212
322
|
}, z.core.$strip>;
|
|
213
323
|
};
|
|
214
324
|
readonly "session.list": {
|
|
@@ -231,12 +341,22 @@ declare const methods: {
|
|
|
231
341
|
runId: z.ZodNullable<z.ZodString>;
|
|
232
342
|
lastMessageId: z.ZodNullable<z.ZodString>;
|
|
233
343
|
tags: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
234
|
-
|
|
344
|
+
system: z.ZodNullable<z.ZodString>;
|
|
235
345
|
model: z.ZodNullable<z.ZodString>;
|
|
236
|
-
mcp: z.ZodNullable<z.ZodUnknown>;
|
|
237
346
|
sandboxId: z.ZodNullable<z.ZodString>;
|
|
238
347
|
skillsDir: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
239
348
|
hookToken: z.ZodNullable<z.ZodString>;
|
|
349
|
+
activeTools: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
350
|
+
generation: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
351
|
+
maxSteps: z.ZodOptional<z.ZodNumber>;
|
|
352
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
353
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
354
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
355
|
+
frequencyPenalty: z.ZodOptional<z.ZodNumber>;
|
|
356
|
+
presencePenalty: z.ZodOptional<z.ZodNumber>;
|
|
357
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
358
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
359
|
+
}, z.core.$strip>>>;
|
|
240
360
|
}, z.core.$strip>>;
|
|
241
361
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
242
362
|
}, z.core.$strip>;
|
|
@@ -262,12 +382,22 @@ declare const methods: {
|
|
|
262
382
|
runId: z.ZodNullable<z.ZodString>;
|
|
263
383
|
lastMessageId: z.ZodNullable<z.ZodString>;
|
|
264
384
|
tags: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
265
|
-
|
|
385
|
+
system: z.ZodNullable<z.ZodString>;
|
|
266
386
|
model: z.ZodNullable<z.ZodString>;
|
|
267
|
-
mcp: z.ZodNullable<z.ZodUnknown>;
|
|
268
387
|
sandboxId: z.ZodNullable<z.ZodString>;
|
|
269
388
|
skillsDir: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
270
389
|
hookToken: z.ZodNullable<z.ZodString>;
|
|
390
|
+
activeTools: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
391
|
+
generation: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
392
|
+
maxSteps: z.ZodOptional<z.ZodNumber>;
|
|
393
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
394
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
395
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
396
|
+
frequencyPenalty: z.ZodOptional<z.ZodNumber>;
|
|
397
|
+
presencePenalty: z.ZodOptional<z.ZodNumber>;
|
|
398
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
399
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
400
|
+
}, z.core.$strip>>>;
|
|
271
401
|
}, z.core.$strip>>;
|
|
272
402
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
273
403
|
}, z.core.$strip>;
|
|
@@ -284,12 +414,22 @@ declare const methods: {
|
|
|
284
414
|
runId: z.ZodNullable<z.ZodString>;
|
|
285
415
|
lastMessageId: z.ZodNullable<z.ZodString>;
|
|
286
416
|
tags: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
287
|
-
|
|
417
|
+
system: z.ZodNullable<z.ZodString>;
|
|
288
418
|
model: z.ZodNullable<z.ZodString>;
|
|
289
|
-
mcp: z.ZodNullable<z.ZodUnknown>;
|
|
290
419
|
sandboxId: z.ZodNullable<z.ZodString>;
|
|
291
420
|
skillsDir: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
292
421
|
hookToken: z.ZodNullable<z.ZodString>;
|
|
422
|
+
activeTools: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
423
|
+
generation: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
424
|
+
maxSteps: z.ZodOptional<z.ZodNumber>;
|
|
425
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
426
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
427
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
428
|
+
frequencyPenalty: z.ZodOptional<z.ZodNumber>;
|
|
429
|
+
presencePenalty: z.ZodOptional<z.ZodNumber>;
|
|
430
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
431
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
432
|
+
}, z.core.$strip>>>;
|
|
293
433
|
}, z.core.$strip>;
|
|
294
434
|
};
|
|
295
435
|
readonly "message.get": {
|
|
@@ -300,14 +440,36 @@ declare const methods: {
|
|
|
300
440
|
id: z.ZodString;
|
|
301
441
|
sessionId: z.ZodString;
|
|
302
442
|
role: z.ZodEnum<{
|
|
443
|
+
system: "system";
|
|
303
444
|
user: "user";
|
|
304
445
|
assistant: "assistant";
|
|
305
|
-
system: "system";
|
|
306
446
|
}>;
|
|
307
447
|
createdAt: z.ZodNumber;
|
|
448
|
+
startedAt: z.ZodNullable<z.ZodNumber>;
|
|
308
449
|
completedAt: z.ZodNullable<z.ZodNumber>;
|
|
309
450
|
interruptedAt: z.ZodNullable<z.ZodNumber>;
|
|
310
|
-
|
|
451
|
+
usage: z.ZodNullable<z.ZodObject<{
|
|
452
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
453
|
+
stepIndex: z.ZodNumber;
|
|
454
|
+
model: z.ZodString;
|
|
455
|
+
inputTokens: z.ZodNumber;
|
|
456
|
+
outputTokens: z.ZodNumber;
|
|
457
|
+
totalTokens: z.ZodNumber;
|
|
458
|
+
cacheReadTokens: z.ZodNumber;
|
|
459
|
+
cacheWriteTokens: z.ZodNumber;
|
|
460
|
+
reasoningTokens: z.ZodNumber;
|
|
461
|
+
}, z.core.$strip>>;
|
|
462
|
+
summary: z.ZodObject<{
|
|
463
|
+
model: z.ZodString;
|
|
464
|
+
inputTokens: z.ZodNumber;
|
|
465
|
+
outputTokens: z.ZodNumber;
|
|
466
|
+
totalTokens: z.ZodNumber;
|
|
467
|
+
cacheReadTokens: z.ZodNumber;
|
|
468
|
+
cacheWriteTokens: z.ZodNumber;
|
|
469
|
+
reasoningTokens: z.ZodNumber;
|
|
470
|
+
stepCount: z.ZodNumber;
|
|
471
|
+
}, z.core.$strip>;
|
|
472
|
+
}, z.core.$strip>>;
|
|
311
473
|
}, z.core.$strip>>;
|
|
312
474
|
};
|
|
313
475
|
readonly "message.set": {
|
|
@@ -315,27 +477,71 @@ declare const methods: {
|
|
|
315
477
|
id: z.ZodString;
|
|
316
478
|
sessionId: z.ZodString;
|
|
317
479
|
role: z.ZodEnum<{
|
|
480
|
+
system: "system";
|
|
318
481
|
user: "user";
|
|
319
482
|
assistant: "assistant";
|
|
320
|
-
system: "system";
|
|
321
483
|
}>;
|
|
322
484
|
createdAt: z.ZodNumber;
|
|
485
|
+
startedAt: z.ZodNullable<z.ZodNumber>;
|
|
323
486
|
completedAt: z.ZodNullable<z.ZodNumber>;
|
|
324
487
|
interruptedAt: z.ZodNullable<z.ZodNumber>;
|
|
325
|
-
|
|
488
|
+
usage: z.ZodNullable<z.ZodObject<{
|
|
489
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
490
|
+
stepIndex: z.ZodNumber;
|
|
491
|
+
model: z.ZodString;
|
|
492
|
+
inputTokens: z.ZodNumber;
|
|
493
|
+
outputTokens: z.ZodNumber;
|
|
494
|
+
totalTokens: z.ZodNumber;
|
|
495
|
+
cacheReadTokens: z.ZodNumber;
|
|
496
|
+
cacheWriteTokens: z.ZodNumber;
|
|
497
|
+
reasoningTokens: z.ZodNumber;
|
|
498
|
+
}, z.core.$strip>>;
|
|
499
|
+
summary: z.ZodObject<{
|
|
500
|
+
model: z.ZodString;
|
|
501
|
+
inputTokens: z.ZodNumber;
|
|
502
|
+
outputTokens: z.ZodNumber;
|
|
503
|
+
totalTokens: z.ZodNumber;
|
|
504
|
+
cacheReadTokens: z.ZodNumber;
|
|
505
|
+
cacheWriteTokens: z.ZodNumber;
|
|
506
|
+
reasoningTokens: z.ZodNumber;
|
|
507
|
+
stepCount: z.ZodNumber;
|
|
508
|
+
}, z.core.$strip>;
|
|
509
|
+
}, z.core.$strip>>;
|
|
326
510
|
}, z.core.$strip>;
|
|
327
511
|
readonly result: z.ZodObject<{
|
|
328
512
|
id: z.ZodString;
|
|
329
513
|
sessionId: z.ZodString;
|
|
330
514
|
role: z.ZodEnum<{
|
|
515
|
+
system: "system";
|
|
331
516
|
user: "user";
|
|
332
517
|
assistant: "assistant";
|
|
333
|
-
system: "system";
|
|
334
518
|
}>;
|
|
335
519
|
createdAt: z.ZodNumber;
|
|
520
|
+
startedAt: z.ZodNullable<z.ZodNumber>;
|
|
336
521
|
completedAt: z.ZodNullable<z.ZodNumber>;
|
|
337
522
|
interruptedAt: z.ZodNullable<z.ZodNumber>;
|
|
338
|
-
|
|
523
|
+
usage: z.ZodNullable<z.ZodObject<{
|
|
524
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
525
|
+
stepIndex: z.ZodNumber;
|
|
526
|
+
model: z.ZodString;
|
|
527
|
+
inputTokens: z.ZodNumber;
|
|
528
|
+
outputTokens: z.ZodNumber;
|
|
529
|
+
totalTokens: z.ZodNumber;
|
|
530
|
+
cacheReadTokens: z.ZodNumber;
|
|
531
|
+
cacheWriteTokens: z.ZodNumber;
|
|
532
|
+
reasoningTokens: z.ZodNumber;
|
|
533
|
+
}, z.core.$strip>>;
|
|
534
|
+
summary: z.ZodObject<{
|
|
535
|
+
model: z.ZodString;
|
|
536
|
+
inputTokens: z.ZodNumber;
|
|
537
|
+
outputTokens: z.ZodNumber;
|
|
538
|
+
totalTokens: z.ZodNumber;
|
|
539
|
+
cacheReadTokens: z.ZodNumber;
|
|
540
|
+
cacheWriteTokens: z.ZodNumber;
|
|
541
|
+
reasoningTokens: z.ZodNumber;
|
|
542
|
+
stepCount: z.ZodNumber;
|
|
543
|
+
}, z.core.$strip>;
|
|
544
|
+
}, z.core.$strip>>;
|
|
339
545
|
}, z.core.$strip>;
|
|
340
546
|
};
|
|
341
547
|
readonly "message.list": {
|
|
@@ -349,14 +555,36 @@ declare const methods: {
|
|
|
349
555
|
id: z.ZodString;
|
|
350
556
|
sessionId: z.ZodString;
|
|
351
557
|
role: z.ZodEnum<{
|
|
558
|
+
system: "system";
|
|
352
559
|
user: "user";
|
|
353
560
|
assistant: "assistant";
|
|
354
|
-
system: "system";
|
|
355
561
|
}>;
|
|
356
562
|
createdAt: z.ZodNumber;
|
|
563
|
+
startedAt: z.ZodNullable<z.ZodNumber>;
|
|
357
564
|
completedAt: z.ZodNullable<z.ZodNumber>;
|
|
358
565
|
interruptedAt: z.ZodNullable<z.ZodNumber>;
|
|
359
|
-
|
|
566
|
+
usage: z.ZodNullable<z.ZodObject<{
|
|
567
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
568
|
+
stepIndex: z.ZodNumber;
|
|
569
|
+
model: z.ZodString;
|
|
570
|
+
inputTokens: z.ZodNumber;
|
|
571
|
+
outputTokens: z.ZodNumber;
|
|
572
|
+
totalTokens: z.ZodNumber;
|
|
573
|
+
cacheReadTokens: z.ZodNumber;
|
|
574
|
+
cacheWriteTokens: z.ZodNumber;
|
|
575
|
+
reasoningTokens: z.ZodNumber;
|
|
576
|
+
}, z.core.$strip>>;
|
|
577
|
+
summary: z.ZodObject<{
|
|
578
|
+
model: z.ZodString;
|
|
579
|
+
inputTokens: z.ZodNumber;
|
|
580
|
+
outputTokens: z.ZodNumber;
|
|
581
|
+
totalTokens: z.ZodNumber;
|
|
582
|
+
cacheReadTokens: z.ZodNumber;
|
|
583
|
+
cacheWriteTokens: z.ZodNumber;
|
|
584
|
+
reasoningTokens: z.ZodNumber;
|
|
585
|
+
stepCount: z.ZodNumber;
|
|
586
|
+
}, z.core.$strip>;
|
|
587
|
+
}, z.core.$strip>>;
|
|
360
588
|
}, z.core.$strip>>;
|
|
361
589
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
362
590
|
}, z.core.$strip>;
|
|
@@ -411,6 +639,12 @@ declare const methods: {
|
|
|
411
639
|
part: z.ZodUnknown;
|
|
412
640
|
}, z.core.$strip>;
|
|
413
641
|
};
|
|
642
|
+
readonly "part.delete": {
|
|
643
|
+
readonly params: z.ZodObject<{
|
|
644
|
+
id: z.ZodString;
|
|
645
|
+
}, z.core.$strip>;
|
|
646
|
+
readonly result: z.ZodVoid;
|
|
647
|
+
};
|
|
414
648
|
readonly "sandbox.get": {
|
|
415
649
|
readonly params: z.ZodObject<{
|
|
416
650
|
key: z.ZodString;
|
|
@@ -424,6 +658,7 @@ declare const methods: {
|
|
|
424
658
|
}, z.core.$strip>>;
|
|
425
659
|
ports: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
426
660
|
lifecycle: z.ZodOptional<z.ZodObject<{
|
|
661
|
+
pollIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
427
662
|
stopAfterInactiveMs: z.ZodOptional<z.ZodNumber>;
|
|
428
663
|
snapshotBeforeTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
429
664
|
snapshotId: z.ZodOptional<z.ZodString>;
|
|
@@ -462,6 +697,7 @@ declare const methods: {
|
|
|
462
697
|
}, z.core.$strip>>;
|
|
463
698
|
ports: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
464
699
|
lifecycle: z.ZodOptional<z.ZodObject<{
|
|
700
|
+
pollIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
465
701
|
stopAfterInactiveMs: z.ZodOptional<z.ZodNumber>;
|
|
466
702
|
snapshotBeforeTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
467
703
|
snapshotId: z.ZodOptional<z.ZodString>;
|
|
@@ -497,6 +733,7 @@ declare const methods: {
|
|
|
497
733
|
}, z.core.$strip>>;
|
|
498
734
|
ports: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
499
735
|
lifecycle: z.ZodOptional<z.ZodObject<{
|
|
736
|
+
pollIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
500
737
|
stopAfterInactiveMs: z.ZodOptional<z.ZodNumber>;
|
|
501
738
|
snapshotBeforeTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
502
739
|
snapshotId: z.ZodOptional<z.ZodString>;
|
|
@@ -545,6 +782,7 @@ declare const methods: {
|
|
|
545
782
|
}, z.core.$strip>>;
|
|
546
783
|
ports: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
547
784
|
lifecycle: z.ZodOptional<z.ZodObject<{
|
|
785
|
+
pollIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
548
786
|
stopAfterInactiveMs: z.ZodOptional<z.ZodNumber>;
|
|
549
787
|
snapshotBeforeTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
550
788
|
snapshotId: z.ZodOptional<z.ZodString>;
|
|
@@ -586,6 +824,7 @@ declare const methods: {
|
|
|
586
824
|
}, z.core.$strip>>;
|
|
587
825
|
ports: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
588
826
|
lifecycle: z.ZodOptional<z.ZodObject<{
|
|
827
|
+
pollIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
589
828
|
stopAfterInactiveMs: z.ZodOptional<z.ZodNumber>;
|
|
590
829
|
snapshotBeforeTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
591
830
|
snapshotId: z.ZodOptional<z.ZodString>;
|
|
@@ -818,6 +1057,7 @@ declare const methods: {
|
|
|
818
1057
|
}, z.core.$strip>;
|
|
819
1058
|
};
|
|
820
1059
|
};
|
|
1060
|
+
|
|
821
1061
|
type StorageMethods = typeof methods;
|
|
822
1062
|
type MethodName = keyof StorageMethods;
|
|
823
1063
|
|
|
@@ -868,6 +1108,7 @@ interface Storage {
|
|
|
868
1108
|
limit?: number;
|
|
869
1109
|
}) => Promise<StorageError | ListResult<Part>>;
|
|
870
1110
|
set: (part: Part) => Promise<StorageError | Part>;
|
|
1111
|
+
delete: (id: string) => Promise<StorageError | undefined>;
|
|
871
1112
|
};
|
|
872
1113
|
sandbox: {
|
|
873
1114
|
get: (key: string) => Promise<StorageError | SandboxRecord | SandboxNotFoundError>;
|
|
@@ -896,19 +1137,613 @@ interface Storage {
|
|
|
896
1137
|
}) => Promise<StorageError | ListResult<Command>>;
|
|
897
1138
|
};
|
|
898
1139
|
}
|
|
899
|
-
type
|
|
1140
|
+
type BaseStorageConfig = {
|
|
1141
|
+
name?: string;
|
|
1142
|
+
/**
|
|
1143
|
+
* Agent API endpoint URL. Storage RPC calls flow through this handler.
|
|
1144
|
+
* If not provided, resolved from environment (VERCEL_URL, PORT, etc).
|
|
1145
|
+
*/
|
|
1146
|
+
api?: string;
|
|
1147
|
+
};
|
|
1148
|
+
type StorageConfig = (BaseStorageConfig & {
|
|
900
1149
|
type: "local";
|
|
901
1150
|
path?: string;
|
|
902
|
-
} | {
|
|
1151
|
+
}) | (BaseStorageConfig & {
|
|
903
1152
|
type: "vercel";
|
|
904
|
-
} | {
|
|
1153
|
+
}) | (BaseStorageConfig & {
|
|
905
1154
|
type: "custom";
|
|
906
1155
|
url: string;
|
|
907
1156
|
headers?: Record<string, string>;
|
|
908
|
-
};
|
|
1157
|
+
});
|
|
909
1158
|
type ResolvedStorage = {
|
|
910
1159
|
url: string;
|
|
911
1160
|
headers?: Record<string, string>;
|
|
912
1161
|
};
|
|
913
1162
|
|
|
914
|
-
|
|
1163
|
+
type RpcResponse<T> = {
|
|
1164
|
+
result: T;
|
|
1165
|
+
} | {
|
|
1166
|
+
error: {
|
|
1167
|
+
code: string;
|
|
1168
|
+
message: string;
|
|
1169
|
+
};
|
|
1170
|
+
};
|
|
1171
|
+
type RpcFn = (params: {
|
|
1172
|
+
name?: string;
|
|
1173
|
+
method: string;
|
|
1174
|
+
params: unknown;
|
|
1175
|
+
}) => Promise<RpcResponse<unknown>>;
|
|
1176
|
+
|
|
1177
|
+
/**
|
|
1178
|
+
* Summary of a discovered skill, used in the system prompt
|
|
1179
|
+
* to inform the LLM about available skills.
|
|
1180
|
+
*/
|
|
1181
|
+
type SkillSummary = {
|
|
1182
|
+
name: string;
|
|
1183
|
+
description: string;
|
|
1184
|
+
/** Full path to the SKILL.md file inside the sandbox */
|
|
1185
|
+
skillMdPath: string;
|
|
1186
|
+
};
|
|
1187
|
+
/**
|
|
1188
|
+
* A file ready to be uploaded to the sandbox.
|
|
1189
|
+
* Content can be text (string) or binary (Buffer).
|
|
1190
|
+
*/
|
|
1191
|
+
type UploadableFile = {
|
|
1192
|
+
/** Relative path within the upload destination */
|
|
1193
|
+
path: string;
|
|
1194
|
+
content: string | Buffer;
|
|
1195
|
+
};
|
|
1196
|
+
/**
|
|
1197
|
+
* Path or paths to skills directories inside the sandbox.
|
|
1198
|
+
*/
|
|
1199
|
+
type SkillsDir = string | string[];
|
|
1200
|
+
|
|
1201
|
+
type SandboxLifecycleInput = {
|
|
1202
|
+
id: string;
|
|
1203
|
+
vercelSandboxId: string;
|
|
1204
|
+
storageConfig: StorageConfig;
|
|
1205
|
+
rpc: RpcFn;
|
|
1206
|
+
};
|
|
1207
|
+
type LogEntry = {
|
|
1208
|
+
stream: "stdout" | "stderr";
|
|
1209
|
+
data: string;
|
|
1210
|
+
};
|
|
1211
|
+
type ExecResult = {
|
|
1212
|
+
commandId: string;
|
|
1213
|
+
logs: () => AsyncIterable<LogEntry>;
|
|
1214
|
+
result: Promise<{
|
|
1215
|
+
stdout: string;
|
|
1216
|
+
stderr: string;
|
|
1217
|
+
exitCode: number;
|
|
1218
|
+
}>;
|
|
1219
|
+
};
|
|
1220
|
+
type SandboxStatus = "pending" | "running" | "stopping" | "stopped" | "failed";
|
|
1221
|
+
interface SandboxLifecycle {
|
|
1222
|
+
start: () => Promise<SandboxError | SandboxStatus>;
|
|
1223
|
+
snapshot: () => Promise<SandboxError | {
|
|
1224
|
+
snapshotId: string;
|
|
1225
|
+
}>;
|
|
1226
|
+
stop: () => Promise<SandboxError | undefined>;
|
|
1227
|
+
getStatus: () => Promise<SandboxError | SandboxStatus>;
|
|
1228
|
+
getCreatedAt: () => Promise<SandboxError | Date>;
|
|
1229
|
+
getRemainingTimeout: () => Promise<SandboxError | number>;
|
|
1230
|
+
}
|
|
1231
|
+
interface Sandbox<TTags extends TagsSchema = TagsSchema> {
|
|
1232
|
+
id: SandboxRecord["id"];
|
|
1233
|
+
config: SandboxRecord["config"];
|
|
1234
|
+
exec: (opts: {
|
|
1235
|
+
command: string;
|
|
1236
|
+
args?: string[];
|
|
1237
|
+
signal?: AbortSignal;
|
|
1238
|
+
}) => Promise<SandboxError | ExecResult>;
|
|
1239
|
+
/**
|
|
1240
|
+
* Get the public domain URL for an exposed port.
|
|
1241
|
+
* Only available for Vercel sandboxes with exposed ports.
|
|
1242
|
+
*/
|
|
1243
|
+
getDomain: (port: number) => Promise<SandboxError | string>;
|
|
1244
|
+
kill: (opts: {
|
|
1245
|
+
commandId: string;
|
|
1246
|
+
storage: Storage;
|
|
1247
|
+
}) => Promise<SandboxError | undefined>;
|
|
1248
|
+
writeFiles: (opts: {
|
|
1249
|
+
files: UploadableFile[];
|
|
1250
|
+
destPath: string;
|
|
1251
|
+
}) => Promise<void>;
|
|
1252
|
+
lifecycle?: SandboxLifecycle;
|
|
1253
|
+
tag: {
|
|
1254
|
+
list: () => Promise<SandboxNotFoundError | StorageError | TTags>;
|
|
1255
|
+
get: (key: string) => Promise<SandboxNotFoundError | StorageError | TTags[typeof key] | undefined>;
|
|
1256
|
+
set: (key: string, value: unknown) => Promise<StorageError | undefined>;
|
|
1257
|
+
setMany: (tags: Record<string, unknown>) => Promise<StorageError | undefined>;
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
type GenerationOptions = {
|
|
1262
|
+
/** Max tool-use steps per assistant response. Default: unlimited. */
|
|
1263
|
+
maxSteps?: number;
|
|
1264
|
+
temperature?: number;
|
|
1265
|
+
topK?: number;
|
|
1266
|
+
topP?: number;
|
|
1267
|
+
frequencyPenalty?: number;
|
|
1268
|
+
presencePenalty?: number;
|
|
1269
|
+
maxOutputTokens?: number;
|
|
1270
|
+
/** Provider-specific HTTP headers. */
|
|
1271
|
+
headers?: Record<string, string>;
|
|
1272
|
+
};
|
|
1273
|
+
|
|
1274
|
+
type ToolContext<TContext = Record<string, unknown>> = {
|
|
1275
|
+
session: Session;
|
|
1276
|
+
sandbox: Sandbox;
|
|
1277
|
+
storage: Storage;
|
|
1278
|
+
context: TContext;
|
|
1279
|
+
};
|
|
1280
|
+
declare const builtInTools: {
|
|
1281
|
+
Read: ai.Tool<{
|
|
1282
|
+
path: string;
|
|
1283
|
+
startLine?: number | undefined;
|
|
1284
|
+
endLine?: number | undefined;
|
|
1285
|
+
}, {
|
|
1286
|
+
content: string;
|
|
1287
|
+
metadata: {
|
|
1288
|
+
totalLines: number;
|
|
1289
|
+
linesShown: number;
|
|
1290
|
+
startLine: number;
|
|
1291
|
+
endLine: number;
|
|
1292
|
+
isPaginated: boolean;
|
|
1293
|
+
fileSize: string;
|
|
1294
|
+
path: string;
|
|
1295
|
+
};
|
|
1296
|
+
}>;
|
|
1297
|
+
Grep: ai.Tool<{
|
|
1298
|
+
pattern: string;
|
|
1299
|
+
caseSensitive: boolean;
|
|
1300
|
+
filesWithMatches: boolean;
|
|
1301
|
+
path?: string | undefined;
|
|
1302
|
+
fileType?: string | undefined;
|
|
1303
|
+
glob?: string | undefined;
|
|
1304
|
+
contextLines?: number | undefined;
|
|
1305
|
+
maxCount?: number | undefined;
|
|
1306
|
+
}, {
|
|
1307
|
+
matches: string;
|
|
1308
|
+
summary: {
|
|
1309
|
+
matchCount: number;
|
|
1310
|
+
fileCount: number;
|
|
1311
|
+
searchPath: string;
|
|
1312
|
+
pattern: string;
|
|
1313
|
+
};
|
|
1314
|
+
}>;
|
|
1315
|
+
List: ai.Tool<{
|
|
1316
|
+
includeHidden: boolean;
|
|
1317
|
+
filesOnly: boolean;
|
|
1318
|
+
path?: string | undefined;
|
|
1319
|
+
depth?: number | undefined;
|
|
1320
|
+
pattern?: string | undefined;
|
|
1321
|
+
}, {
|
|
1322
|
+
listing: string;
|
|
1323
|
+
summary: {
|
|
1324
|
+
totalItems: number;
|
|
1325
|
+
totalFiles: number;
|
|
1326
|
+
totalDirs: number;
|
|
1327
|
+
searchPath: string;
|
|
1328
|
+
depth?: number | undefined;
|
|
1329
|
+
};
|
|
1330
|
+
}>;
|
|
1331
|
+
Write: ai.Tool<{
|
|
1332
|
+
path: string;
|
|
1333
|
+
content: string;
|
|
1334
|
+
}, {
|
|
1335
|
+
success: boolean;
|
|
1336
|
+
path: string;
|
|
1337
|
+
bytesWritten: number;
|
|
1338
|
+
error?: string | undefined;
|
|
1339
|
+
}>;
|
|
1340
|
+
Edit: ai.Tool<{
|
|
1341
|
+
path: string;
|
|
1342
|
+
old_string: string;
|
|
1343
|
+
new_string: string;
|
|
1344
|
+
}, {
|
|
1345
|
+
success: boolean;
|
|
1346
|
+
path: string;
|
|
1347
|
+
error?: string | undefined;
|
|
1348
|
+
}>;
|
|
1349
|
+
Bash: ai.Tool<{
|
|
1350
|
+
command: string;
|
|
1351
|
+
waitUntil?: number | undefined;
|
|
1352
|
+
}, {
|
|
1353
|
+
pid: number;
|
|
1354
|
+
output: string;
|
|
1355
|
+
exitCode: number;
|
|
1356
|
+
status: "running" | "completed" | "failed";
|
|
1357
|
+
cwd: string;
|
|
1358
|
+
outputFile: string;
|
|
1359
|
+
}>;
|
|
1360
|
+
JavaScript: ai.Tool<{
|
|
1361
|
+
code: string;
|
|
1362
|
+
}, any>;
|
|
1363
|
+
};
|
|
1364
|
+
type BuiltInToolName = keyof typeof builtInTools;
|
|
1365
|
+
declare const builtinToolNames: { [K in BuiltInToolName]: K; };
|
|
1366
|
+
|
|
1367
|
+
type ToolMetadata = {
|
|
1368
|
+
name: string;
|
|
1369
|
+
description?: string;
|
|
1370
|
+
inputSchema?: JSONSchema7;
|
|
1371
|
+
};
|
|
1372
|
+
type ToolsExecuteParams = {
|
|
1373
|
+
name: string;
|
|
1374
|
+
input: unknown;
|
|
1375
|
+
session: Session;
|
|
1376
|
+
sandboxRecord: SandboxRecord;
|
|
1377
|
+
context: Record<string, unknown>;
|
|
1378
|
+
};
|
|
1379
|
+
type HookToolBeforeParams = {
|
|
1380
|
+
name: string;
|
|
1381
|
+
input: unknown;
|
|
1382
|
+
context: ToolContext;
|
|
1383
|
+
};
|
|
1384
|
+
type HookToolBeforeResult = {
|
|
1385
|
+
input?: unknown;
|
|
1386
|
+
stop?: boolean;
|
|
1387
|
+
};
|
|
1388
|
+
type HookToolAfterParams = {
|
|
1389
|
+
name: string;
|
|
1390
|
+
input: unknown;
|
|
1391
|
+
result: unknown;
|
|
1392
|
+
context: ToolContext;
|
|
1393
|
+
};
|
|
1394
|
+
type HookToolAfterResult = {
|
|
1395
|
+
result?: unknown;
|
|
1396
|
+
stop?: boolean;
|
|
1397
|
+
};
|
|
1398
|
+
type ToolsNeedsApprovalParams = {
|
|
1399
|
+
toolName: string;
|
|
1400
|
+
input: unknown;
|
|
1401
|
+
toolCallId: string;
|
|
1402
|
+
messages: unknown[];
|
|
1403
|
+
};
|
|
1404
|
+
type ToolsNeedsApprovalResult = boolean;
|
|
1405
|
+
|
|
1406
|
+
type SessionUsage = {
|
|
1407
|
+
total: UsageSummary & {
|
|
1408
|
+
messageCount: number;
|
|
1409
|
+
};
|
|
1410
|
+
byMessageId: Record<string, UsageSummary | null>;
|
|
1411
|
+
};
|
|
1412
|
+
|
|
1413
|
+
type SendInput = string | {
|
|
1414
|
+
role?: UIMessage["role"];
|
|
1415
|
+
parts: UIMessage["parts"];
|
|
1416
|
+
id?: string;
|
|
1417
|
+
};
|
|
1418
|
+
/**
|
|
1419
|
+
* Infer a typed UIMessage from an agent instance.
|
|
1420
|
+
* Tool parts are discriminated by `type: "tool-${name}"` with typed input/output.
|
|
1421
|
+
*
|
|
1422
|
+
* @example
|
|
1423
|
+
* ```ts
|
|
1424
|
+
* const myAgent = agent({ tools: { myTool: tool({...}) } });
|
|
1425
|
+
* type MyMessage = InferUIMessage<typeof myAgent>;
|
|
1426
|
+
* // MyMessage.parts includes { type: "tool-myTool"; input: MyInput; output: MyOutput; ... }
|
|
1427
|
+
* ```
|
|
1428
|
+
*/
|
|
1429
|
+
type InferUIMessage<A> = A extends {
|
|
1430
|
+
tools: infer T extends ToolSet;
|
|
1431
|
+
} ? UIMessage<unknown, UIDataTypes, InferUITools<T>> : UIMessage;
|
|
1432
|
+
type ToolName<Tools> = Extract<keyof Tools, string> | BuiltInToolName;
|
|
1433
|
+
type ToolInput<Tools, K> = K extends BuiltInToolName ? InferToolInput<(typeof builtInTools)[K]> : K extends keyof Tools ? Tools[K] extends ai.Tool ? InferToolInput<Tools[K]> : unknown : unknown;
|
|
1434
|
+
type NeedsApprovalMap<Tools> = {
|
|
1435
|
+
[K in ToolName<Tools>]?: boolean | ((input: ToolInput<Tools, K>, options: {
|
|
1436
|
+
toolCallId: string;
|
|
1437
|
+
messages: ModelMessage[];
|
|
1438
|
+
experimental_context: unknown;
|
|
1439
|
+
}) => boolean | Promise<boolean>);
|
|
1440
|
+
};
|
|
1441
|
+
/**
|
|
1442
|
+
* Options that can be set per-session, overriding agent-level defaults.
|
|
1443
|
+
*/
|
|
1444
|
+
type SessionOptions<Tools extends ToolSet, TTags extends Record<string, unknown> = Record<string, never>> = {
|
|
1445
|
+
/** The AI model to use. */
|
|
1446
|
+
model?: GatewayModelId;
|
|
1447
|
+
/** System prompt for the AI model. */
|
|
1448
|
+
system?: string;
|
|
1449
|
+
/** Sandbox configuration or ID. If string, uses as sandbox ID with its config. */
|
|
1450
|
+
sandbox?: SandboxConfig | string;
|
|
1451
|
+
/** Key-value metadata tags for the session. */
|
|
1452
|
+
tags?: TTags;
|
|
1453
|
+
/** Directory containing skill definitions for the agent. */
|
|
1454
|
+
skillsDir?: SkillsDir;
|
|
1455
|
+
/**
|
|
1456
|
+
* Names of tools to activate for this session.
|
|
1457
|
+
* If not specified, all agent-level tools are active.
|
|
1458
|
+
* Use this to restrict which tools are available per-session.
|
|
1459
|
+
*/
|
|
1460
|
+
activeTools?: (Extract<keyof Tools, string> | BuiltInToolName)[];
|
|
1461
|
+
/** Generation options (temperature, maxSteps, etc.). Overrides agent-level defaults. */
|
|
1462
|
+
generation?: GenerationOptions;
|
|
1463
|
+
};
|
|
1464
|
+
/**
|
|
1465
|
+
* Configuration options for creating an agent instance.
|
|
1466
|
+
*
|
|
1467
|
+
* @example
|
|
1468
|
+
* ```ts
|
|
1469
|
+
* const myAgent = agent({
|
|
1470
|
+
* model: "anthropic/claude-opus-4.5",
|
|
1471
|
+
* system: "You are a helpful assistant...",
|
|
1472
|
+
* tagsSchema: z.object({ userId: z.string() }),
|
|
1473
|
+
* contextSchema: z.object({ authToken: z.string() }),
|
|
1474
|
+
* });
|
|
1475
|
+
* ```
|
|
1476
|
+
*/
|
|
1477
|
+
type AgentOptions<Tools extends ToolSet, TTags extends Record<string, unknown> = Record<string, never>, TContext extends Record<string, unknown> = Record<string, never>> = {
|
|
1478
|
+
/**
|
|
1479
|
+
* Agent name. Used to isolate storage data - different names have separate data.
|
|
1480
|
+
* @default "default"
|
|
1481
|
+
*/
|
|
1482
|
+
name?: string;
|
|
1483
|
+
/**
|
|
1484
|
+
* Storage backend configuration.
|
|
1485
|
+
* - `{ type: "local" }` - filesystem storage (dev)
|
|
1486
|
+
* - `{ type: "vercel" }` - Vercel managed storage (prod)
|
|
1487
|
+
* - `{ type: "custom", url: "..." }` - custom HTTP backend
|
|
1488
|
+
* @default { type: "vercel" }
|
|
1489
|
+
*/
|
|
1490
|
+
storage?: StorageConfig;
|
|
1491
|
+
/**
|
|
1492
|
+
* Custom tools available to the agent.
|
|
1493
|
+
* These are exposed via the RPC handler and called over HTTP.
|
|
1494
|
+
*/
|
|
1495
|
+
tools?: Tools;
|
|
1496
|
+
/**
|
|
1497
|
+
* Hooks for intercepting agent operations.
|
|
1498
|
+
*/
|
|
1499
|
+
hooks?: AgentHooks;
|
|
1500
|
+
/**
|
|
1501
|
+
* Schema for session tags. All sessions share this schema.
|
|
1502
|
+
* Tags are persisted in storage and survive across requests.
|
|
1503
|
+
*/
|
|
1504
|
+
tagsSchema?: z.ZodType<TTags>;
|
|
1505
|
+
/**
|
|
1506
|
+
* Schema for transient tool context. Passed per-request via send().
|
|
1507
|
+
* NOT persisted - use for secrets like auth tokens.
|
|
1508
|
+
*/
|
|
1509
|
+
contextSchema?: z.ZodType<TContext>;
|
|
1510
|
+
/**
|
|
1511
|
+
* Approval rules for tools you don't own (built-in or third-party).
|
|
1512
|
+
* Maps tool names to a boolean or a function that decides whether to ask.
|
|
1513
|
+
*
|
|
1514
|
+
* @example
|
|
1515
|
+
* ```ts
|
|
1516
|
+
* needsApproval: {
|
|
1517
|
+
* Bash: (input) => input.command.startsWith("rm"),
|
|
1518
|
+
* Write: true,
|
|
1519
|
+
* }
|
|
1520
|
+
* ```
|
|
1521
|
+
*/
|
|
1522
|
+
needsApproval?: NeedsApprovalMap<Tools>;
|
|
1523
|
+
} & Omit<SessionOptions<Tools, TTags>, "tags">;
|
|
1524
|
+
/**
|
|
1525
|
+
* Base type for session/sandbox tags. Used for generic constraints.
|
|
1526
|
+
* For agent-level tag validation, use `tagsSchema` option with a zod schema.
|
|
1527
|
+
*/
|
|
1528
|
+
type TagsSchema = Record<string, unknown>;
|
|
1529
|
+
/**
|
|
1530
|
+
* Hooks for intercepting agent operations.
|
|
1531
|
+
*/
|
|
1532
|
+
type AgentHooks = {
|
|
1533
|
+
/** Called before a tool is executed. Can modify input or throw to block. */
|
|
1534
|
+
"tool.before"?: (opts: {
|
|
1535
|
+
name: string;
|
|
1536
|
+
input: unknown;
|
|
1537
|
+
context: ToolContext;
|
|
1538
|
+
}) => Promise<undefined | {
|
|
1539
|
+
input: unknown;
|
|
1540
|
+
}>;
|
|
1541
|
+
/** Called after a tool is executed. Can modify result. */
|
|
1542
|
+
"tool.after"?: (opts: {
|
|
1543
|
+
name: string;
|
|
1544
|
+
input: unknown;
|
|
1545
|
+
result: unknown;
|
|
1546
|
+
context: ToolContext;
|
|
1547
|
+
}) => Promise<undefined | {
|
|
1548
|
+
result: unknown;
|
|
1549
|
+
}>;
|
|
1550
|
+
};
|
|
1551
|
+
/**
|
|
1552
|
+
* RPC response type for dispatch.
|
|
1553
|
+
*/
|
|
1554
|
+
type RpcResult<T = unknown> = {
|
|
1555
|
+
result: T;
|
|
1556
|
+
} | {
|
|
1557
|
+
error: {
|
|
1558
|
+
code: string;
|
|
1559
|
+
message: string;
|
|
1560
|
+
};
|
|
1561
|
+
status?: number;
|
|
1562
|
+
};
|
|
1563
|
+
/**
|
|
1564
|
+
* Direct RPC payload for step function calls (no HTTP).
|
|
1565
|
+
*/
|
|
1566
|
+
type RpcPayload = {
|
|
1567
|
+
name?: string;
|
|
1568
|
+
method: string;
|
|
1569
|
+
params: unknown;
|
|
1570
|
+
};
|
|
1571
|
+
/**
|
|
1572
|
+
* All RPC methods available on the agent handler.
|
|
1573
|
+
* Combines tools methods, hooks, and storage methods.
|
|
1574
|
+
*/
|
|
1575
|
+
type AgentRpcMethods = {
|
|
1576
|
+
"tools.list": {
|
|
1577
|
+
params: Record<string, never>;
|
|
1578
|
+
result: ToolMetadata[];
|
|
1579
|
+
};
|
|
1580
|
+
"tools.execute": {
|
|
1581
|
+
params: ToolsExecuteParams;
|
|
1582
|
+
result: unknown;
|
|
1583
|
+
};
|
|
1584
|
+
"tools.needsApproval": {
|
|
1585
|
+
params: ToolsNeedsApprovalParams;
|
|
1586
|
+
result: ToolsNeedsApprovalResult;
|
|
1587
|
+
};
|
|
1588
|
+
"hook.tool.before": {
|
|
1589
|
+
params: HookToolBeforeParams;
|
|
1590
|
+
result: HookToolBeforeResult;
|
|
1591
|
+
};
|
|
1592
|
+
"hook.tool.after": {
|
|
1593
|
+
params: HookToolAfterParams;
|
|
1594
|
+
result: HookToolAfterResult;
|
|
1595
|
+
};
|
|
1596
|
+
} & StorageMethods;
|
|
1597
|
+
type AgentRpcMethodName = keyof AgentRpcMethods;
|
|
1598
|
+
/**
|
|
1599
|
+
* Result type for RPC override handlers.
|
|
1600
|
+
* - `{ ok: true; result: T }` - return this result
|
|
1601
|
+
* - `{ ok: false; error: string }` - return this error
|
|
1602
|
+
* - `null` - use default handler
|
|
1603
|
+
*/
|
|
1604
|
+
type AgentRpcResult<T> = {
|
|
1605
|
+
ok: true;
|
|
1606
|
+
result: T;
|
|
1607
|
+
} | {
|
|
1608
|
+
ok: false;
|
|
1609
|
+
error: string;
|
|
1610
|
+
} | null;
|
|
1611
|
+
/**
|
|
1612
|
+
* Override handlers for agent RPC methods.
|
|
1613
|
+
* Each method can be individually overridden.
|
|
1614
|
+
* Return `null` to fall back to the default handler.
|
|
1615
|
+
*/
|
|
1616
|
+
type AgentRpcOverrides = {
|
|
1617
|
+
[K in AgentRpcMethodName]?: (params: AgentRpcMethods[K]["params"]) => Promise<AgentRpcResult<AgentRpcMethods[K]["result"]>>;
|
|
1618
|
+
};
|
|
1619
|
+
declare const agent: <Tools extends {}, TTags extends Record<string, unknown> = Record<string, never>, TContext extends Record<string, unknown> = Record<string, never>>(options: AgentOptions<Tools, TTags, TContext>) => {
|
|
1620
|
+
session: (sessionId: string, sessionOptions?: SessionOptions<Tools, TTags>) => Promise<{
|
|
1621
|
+
send: ({ input, interruptIfStreaming, context, }: {
|
|
1622
|
+
input: SendInput | SendInput[];
|
|
1623
|
+
interruptIfStreaming?: boolean;
|
|
1624
|
+
context?: TContext;
|
|
1625
|
+
}) => Promise<void | SessionError | StorageError>;
|
|
1626
|
+
stream: (opts?: {
|
|
1627
|
+
messageId?: string;
|
|
1628
|
+
}) => Promise<SessionNotFoundError | SessionError | StorageError | ReadableStream<UIMessageChunk>>;
|
|
1629
|
+
ui: () => Promise<StorageError | {
|
|
1630
|
+
messages: UIMessage<unknown, UIDataTypes, InferUITools<{
|
|
1631
|
+
Read: ai.Tool<{
|
|
1632
|
+
path: string;
|
|
1633
|
+
startLine?: number | undefined;
|
|
1634
|
+
endLine?: number | undefined;
|
|
1635
|
+
}, {
|
|
1636
|
+
content: string;
|
|
1637
|
+
metadata: {
|
|
1638
|
+
totalLines: number;
|
|
1639
|
+
linesShown: number;
|
|
1640
|
+
startLine: number;
|
|
1641
|
+
endLine: number;
|
|
1642
|
+
isPaginated: boolean;
|
|
1643
|
+
fileSize: string;
|
|
1644
|
+
path: string;
|
|
1645
|
+
};
|
|
1646
|
+
}>;
|
|
1647
|
+
Grep: ai.Tool<{
|
|
1648
|
+
pattern: string;
|
|
1649
|
+
caseSensitive: boolean;
|
|
1650
|
+
filesWithMatches: boolean;
|
|
1651
|
+
path?: string | undefined;
|
|
1652
|
+
fileType?: string | undefined;
|
|
1653
|
+
glob?: string | undefined;
|
|
1654
|
+
contextLines?: number | undefined;
|
|
1655
|
+
maxCount?: number | undefined;
|
|
1656
|
+
}, {
|
|
1657
|
+
matches: string;
|
|
1658
|
+
summary: {
|
|
1659
|
+
matchCount: number;
|
|
1660
|
+
fileCount: number;
|
|
1661
|
+
searchPath: string;
|
|
1662
|
+
pattern: string;
|
|
1663
|
+
};
|
|
1664
|
+
}>;
|
|
1665
|
+
List: ai.Tool<{
|
|
1666
|
+
includeHidden: boolean;
|
|
1667
|
+
filesOnly: boolean;
|
|
1668
|
+
path?: string | undefined;
|
|
1669
|
+
depth?: number | undefined;
|
|
1670
|
+
pattern?: string | undefined;
|
|
1671
|
+
}, {
|
|
1672
|
+
listing: string;
|
|
1673
|
+
summary: {
|
|
1674
|
+
totalItems: number;
|
|
1675
|
+
totalFiles: number;
|
|
1676
|
+
totalDirs: number;
|
|
1677
|
+
searchPath: string;
|
|
1678
|
+
depth?: number | undefined;
|
|
1679
|
+
};
|
|
1680
|
+
}>;
|
|
1681
|
+
Write: ai.Tool<{
|
|
1682
|
+
path: string;
|
|
1683
|
+
content: string;
|
|
1684
|
+
}, {
|
|
1685
|
+
success: boolean;
|
|
1686
|
+
path: string;
|
|
1687
|
+
bytesWritten: number;
|
|
1688
|
+
error?: string | undefined;
|
|
1689
|
+
}>;
|
|
1690
|
+
Edit: ai.Tool<{
|
|
1691
|
+
path: string;
|
|
1692
|
+
old_string: string;
|
|
1693
|
+
new_string: string;
|
|
1694
|
+
}, {
|
|
1695
|
+
success: boolean;
|
|
1696
|
+
path: string;
|
|
1697
|
+
error?: string | undefined;
|
|
1698
|
+
}>;
|
|
1699
|
+
Bash: ai.Tool<{
|
|
1700
|
+
command: string;
|
|
1701
|
+
waitUntil?: number | undefined;
|
|
1702
|
+
}, {
|
|
1703
|
+
pid: number;
|
|
1704
|
+
output: string;
|
|
1705
|
+
exitCode: number;
|
|
1706
|
+
status: "running" | "completed" | "failed";
|
|
1707
|
+
cwd: string;
|
|
1708
|
+
outputFile: string;
|
|
1709
|
+
}>;
|
|
1710
|
+
JavaScript: ai.Tool<{
|
|
1711
|
+
code: string;
|
|
1712
|
+
}, any>;
|
|
1713
|
+
} & Tools>>[];
|
|
1714
|
+
streamingMessageId: string | null;
|
|
1715
|
+
usage: SessionUsage;
|
|
1716
|
+
}>;
|
|
1717
|
+
tag: {
|
|
1718
|
+
list: () => Promise<SessionNotFoundError | StorageError | TTags>;
|
|
1719
|
+
get: <K extends keyof TTags & string>(key: K) => Promise<TTags[K] | undefined | Error>;
|
|
1720
|
+
set: <K extends keyof TTags & string>(key: K, value: TTags[K]) => Promise<undefined | Error>;
|
|
1721
|
+
setMany: (tags: Partial<TTags>) => Promise<undefined | Error>;
|
|
1722
|
+
};
|
|
1723
|
+
sandbox: Sandbox<TTags>;
|
|
1724
|
+
interrupt: () => Promise<StorageError | undefined>;
|
|
1725
|
+
resolveApproval: ({ approvalId, approved, reason, }: {
|
|
1726
|
+
approvalId: string;
|
|
1727
|
+
approved: boolean;
|
|
1728
|
+
reason?: string;
|
|
1729
|
+
}) => Promise<undefined | Error>;
|
|
1730
|
+
usage: () => Promise<SessionUsage | Error>;
|
|
1731
|
+
}>;
|
|
1732
|
+
sandbox: (sandboxId: string, opts?: {
|
|
1733
|
+
config?: SandboxConfig;
|
|
1734
|
+
tags?: TTags;
|
|
1735
|
+
}) => Promise<Sandbox<TTags>>;
|
|
1736
|
+
readonly storage: Storage;
|
|
1737
|
+
/**
|
|
1738
|
+
* RPC handler for agent operations.
|
|
1739
|
+
* Handles tools.list, tools.execute, storage RPC, and hooks.
|
|
1740
|
+
*
|
|
1741
|
+
* Called internally by the `rpc` step function during workflow execution.
|
|
1742
|
+
* Can also be exposed via HTTP for external access if needed.
|
|
1743
|
+
*/
|
|
1744
|
+
handler: (input: Request | RpcPayload, overrides?: AgentRpcOverrides) => Promise<Response | RpcResult>;
|
|
1745
|
+
tools: typeof builtInTools & Tools;
|
|
1746
|
+
rpc: (params: RpcPayload) => Promise<RpcResult>;
|
|
1747
|
+
};
|
|
1748
|
+
|
|
1749
|
+
export { type AgentOptions as A, type BuiltInToolName as B, type ExecResult as E, type GenerationOptions as G, type InferUIMessage as I, type ListResult as L, type MethodName as M, type Part as P, type ResolvedStorage as R, type StorageMethods as S, type TagsSchema as T, type UploadableFile as U, type Message as a, MessageNotFoundError as b, type MessageUsage as c, type RpcPayload as d, type RpcResult as e, type Sandbox as f, type SandboxConfig as g, SandboxError as h, SandboxNotFoundError as i, type SandboxRecord as j, type SendInput as k, type Session as l, SessionNotFoundError as m, type SessionOptions as n, type SkillSummary as o, type StepUsage as p, type StorageConfig as q, StorageError as r, type ToolContext as s, type UsageSummary as t, agent as u, builtinToolNames as v, type SandboxLifecycleInput as w };
|