experimental-agent 0.0.4 → 0.1.1
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/agent-workflow.d.mts +2 -3
- package/dist/agent-workflow.d.ts +2 -3
- package/dist/agent-workflow.js +947 -436
- package/dist/agent-workflow.mjs +3 -2
- package/dist/chunk-2IIWVPZB.mjs +334 -0
- package/dist/chunk-A63YU65A.mjs +20 -0
- package/dist/{chunk-3ODWQVIA.mjs → chunk-BJTO5JO5.mjs} +1 -2
- package/dist/chunk-GJETDXOU.mjs +361 -0
- package/dist/chunk-RDKDLHXM.mjs +2031 -0
- package/dist/{chunk-T7PMZLOX.mjs → chunk-T2UUL6VC.mjs} +4 -4
- package/dist/{chunk-TQRCSTCF.mjs → chunk-VGJISV6O.mjs} +9 -4
- package/dist/chunk-VS7U6SXN.mjs +1261 -0
- package/dist/{client-SREKHM6I.mjs → client-66JIQLSA.mjs} +2 -2
- package/dist/client-DjcE0ATp.d.mts +710 -0
- package/dist/client-DwrDzn4_.d.ts +710 -0
- package/dist/client.mjs +1 -1
- package/dist/{handler-36FM5H35.mjs → handler-BQY5SOI2.mjs} +2 -2
- package/dist/index.d.mts +18 -4
- package/dist/index.d.ts +18 -4
- package/dist/index.js +1178 -509
- package/dist/index.mjs +152 -49
- package/dist/lifecycle-workflow.d.mts +3 -2
- package/dist/lifecycle-workflow.d.ts +3 -2
- package/dist/lifecycle-workflow.js +111 -5
- package/dist/lifecycle-workflow.mjs +3 -2
- package/dist/local-fs-handlers-Q5W52DKV.mjs +290 -0
- package/dist/next/loader.js +7 -7
- package/dist/next/loader.mjs +3 -3
- package/dist/next.js +9 -4
- package/dist/next.mjs +11 -6
- package/dist/{process-manager-JAKAXROL.mjs → process-manager-ZCET3VD2.mjs} +1 -1
- package/dist/{sandbox-QAPGBVYM.mjs → sandbox-27X2DSE3.mjs} +4 -3
- package/dist/{storage-Q376OZH3.mjs → storage-KQYV42J4.mjs} +3 -3
- package/dist/{client-6g79J0s3.d.mts → types-DuTc4UQW.d.mts} +229 -590
- package/dist/{client-6g79J0s3.d.ts → types-DuTc4UQW.d.ts} +229 -590
- package/dist/vercel-SD3JTECG.mjs +20 -0
- package/dist/{vercel-sdk-VHKEX2GQ.mjs → vercel-sdk-I6A4MVAN.mjs} +3 -3
- package/package.json +3 -3
- package/dist/chunk-GSRJYPWF.mjs +0 -284
- package/dist/chunk-JCPQQWIK.mjs +0 -2057
- package/dist/chunk-JEE2FQ4O.mjs +0 -844
- package/dist/chunk-VBLZWXVE.mjs +0 -318
- package/dist/local-fs-handlers-P4WGW3QY.mjs +0 -235
- package/dist/vercel-LLXAHKVJ.mjs +0 -20
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as ai from 'ai';
|
|
3
|
-
import { UIMessage, JSONSchema7, ToolSet, InferToolInput, ModelMessage, GatewayModelId, UIDataTypes, InferUITools, UIMessageChunk } from 'ai';
|
|
1
|
+
import { UIMessage } from 'ai';
|
|
4
2
|
import { z } from 'zod';
|
|
3
|
+
import * as errore from 'errore';
|
|
5
4
|
|
|
6
5
|
declare const SessionNotFoundError_base: errore.FactoryTaggedErrorClass<"SessionNotFoundError", "Session $id not found", Error>;
|
|
7
6
|
declare class SessionNotFoundError extends SessionNotFoundError_base {
|
|
@@ -22,6 +21,14 @@ declare const MessageNotFoundError_base: errore.FactoryTaggedErrorClass<"Message
|
|
|
22
21
|
declare class MessageNotFoundError extends MessageNotFoundError_base {
|
|
23
22
|
}
|
|
24
23
|
|
|
24
|
+
declare const NetworkPolicySchema: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
|
|
25
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
26
|
+
subnets: z.ZodOptional<z.ZodObject<{
|
|
27
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
29
|
+
}, z.core.$strip>>;
|
|
30
|
+
}, z.core.$strip>]>>;
|
|
31
|
+
type NetworkPolicy = z.infer<typeof NetworkPolicySchema>;
|
|
25
32
|
declare const SandboxConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
26
33
|
type: z.ZodLiteral<"vercel">;
|
|
27
34
|
resources: z.ZodOptional<z.ZodObject<{
|
|
@@ -35,6 +42,13 @@ declare const SandboxConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
35
42
|
snapshotId: z.ZodOptional<z.ZodString>;
|
|
36
43
|
autoStart: z.ZodOptional<z.ZodBoolean>;
|
|
37
44
|
}, z.core.$strip>>;
|
|
45
|
+
networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
|
|
46
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
47
|
+
subnets: z.ZodOptional<z.ZodObject<{
|
|
48
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
49
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
50
|
+
}, z.core.$strip>>;
|
|
51
|
+
}, z.core.$strip>]>>;
|
|
38
52
|
}, z.core.$strip>, z.ZodObject<{
|
|
39
53
|
type: z.ZodLiteral<"local">;
|
|
40
54
|
path: z.ZodOptional<z.ZodString>;
|
|
@@ -175,6 +189,13 @@ declare const SandboxRecordSchema: z.ZodObject<{
|
|
|
175
189
|
snapshotId: z.ZodOptional<z.ZodString>;
|
|
176
190
|
autoStart: z.ZodOptional<z.ZodBoolean>;
|
|
177
191
|
}, z.core.$strip>>;
|
|
192
|
+
networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
|
|
193
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
194
|
+
subnets: z.ZodOptional<z.ZodObject<{
|
|
195
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
196
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
197
|
+
}, z.core.$strip>>;
|
|
198
|
+
}, z.core.$strip>]>>;
|
|
178
199
|
}, z.core.$strip>, z.ZodObject<{
|
|
179
200
|
type: z.ZodLiteral<"local">;
|
|
180
201
|
path: z.ZodOptional<z.ZodString>;
|
|
@@ -241,6 +262,14 @@ declare const CommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
241
262
|
completedAt: z.ZodNumber;
|
|
242
263
|
}, z.core.$strip>;
|
|
243
264
|
}, z.core.$strip>], "status">;
|
|
265
|
+
declare const SetupSnapshotSchema: z.ZodObject<{
|
|
266
|
+
key: z.ZodString;
|
|
267
|
+
snapshotId: z.ZodNullable<z.ZodString>;
|
|
268
|
+
createdAt: z.ZodNumber;
|
|
269
|
+
lastUsedAt: z.ZodNullable<z.ZodNumber>;
|
|
270
|
+
acquiringLockId: z.ZodNullable<z.ZodString>;
|
|
271
|
+
acquiringLockAt: z.ZodNullable<z.ZodNumber>;
|
|
272
|
+
}, z.core.$strip>;
|
|
244
273
|
declare const methods: {
|
|
245
274
|
readonly "session.get": {
|
|
246
275
|
readonly params: z.ZodObject<{
|
|
@@ -664,6 +693,13 @@ declare const methods: {
|
|
|
664
693
|
snapshotId: z.ZodOptional<z.ZodString>;
|
|
665
694
|
autoStart: z.ZodOptional<z.ZodBoolean>;
|
|
666
695
|
}, z.core.$strip>>;
|
|
696
|
+
networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
|
|
697
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
698
|
+
subnets: z.ZodOptional<z.ZodObject<{
|
|
699
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
700
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
701
|
+
}, z.core.$strip>>;
|
|
702
|
+
}, z.core.$strip>]>>;
|
|
667
703
|
}, z.core.$strip>, z.ZodObject<{
|
|
668
704
|
type: z.ZodLiteral<"local">;
|
|
669
705
|
path: z.ZodOptional<z.ZodString>;
|
|
@@ -703,6 +739,13 @@ declare const methods: {
|
|
|
703
739
|
snapshotId: z.ZodOptional<z.ZodString>;
|
|
704
740
|
autoStart: z.ZodOptional<z.ZodBoolean>;
|
|
705
741
|
}, z.core.$strip>>;
|
|
742
|
+
networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
|
|
743
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
744
|
+
subnets: z.ZodOptional<z.ZodObject<{
|
|
745
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
746
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
747
|
+
}, z.core.$strip>>;
|
|
748
|
+
}, z.core.$strip>]>>;
|
|
706
749
|
}, z.core.$strip>, z.ZodObject<{
|
|
707
750
|
type: z.ZodLiteral<"local">;
|
|
708
751
|
path: z.ZodOptional<z.ZodString>;
|
|
@@ -739,6 +782,13 @@ declare const methods: {
|
|
|
739
782
|
snapshotId: z.ZodOptional<z.ZodString>;
|
|
740
783
|
autoStart: z.ZodOptional<z.ZodBoolean>;
|
|
741
784
|
}, z.core.$strip>>;
|
|
785
|
+
networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
|
|
786
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
787
|
+
subnets: z.ZodOptional<z.ZodObject<{
|
|
788
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
789
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
790
|
+
}, z.core.$strip>>;
|
|
791
|
+
}, z.core.$strip>]>>;
|
|
742
792
|
}, z.core.$strip>, z.ZodObject<{
|
|
743
793
|
type: z.ZodLiteral<"local">;
|
|
744
794
|
path: z.ZodOptional<z.ZodString>;
|
|
@@ -788,6 +838,13 @@ declare const methods: {
|
|
|
788
838
|
snapshotId: z.ZodOptional<z.ZodString>;
|
|
789
839
|
autoStart: z.ZodOptional<z.ZodBoolean>;
|
|
790
840
|
}, z.core.$strip>>;
|
|
841
|
+
networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
|
|
842
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
843
|
+
subnets: z.ZodOptional<z.ZodObject<{
|
|
844
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
845
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
846
|
+
}, z.core.$strip>>;
|
|
847
|
+
}, z.core.$strip>]>>;
|
|
791
848
|
}, z.core.$strip>, z.ZodObject<{
|
|
792
849
|
type: z.ZodLiteral<"local">;
|
|
793
850
|
path: z.ZodOptional<z.ZodString>;
|
|
@@ -830,6 +887,13 @@ declare const methods: {
|
|
|
830
887
|
snapshotId: z.ZodOptional<z.ZodString>;
|
|
831
888
|
autoStart: z.ZodOptional<z.ZodBoolean>;
|
|
832
889
|
}, z.core.$strip>>;
|
|
890
|
+
networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
|
|
891
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
892
|
+
subnets: z.ZodOptional<z.ZodObject<{
|
|
893
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
894
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
895
|
+
}, z.core.$strip>>;
|
|
896
|
+
}, z.core.$strip>]>>;
|
|
833
897
|
}, z.core.$strip>, z.ZodObject<{
|
|
834
898
|
type: z.ZodLiteral<"local">;
|
|
835
899
|
path: z.ZodOptional<z.ZodString>;
|
|
@@ -1056,6 +1120,132 @@ declare const methods: {
|
|
|
1056
1120
|
nextCursor: z.ZodNullable<z.ZodString>;
|
|
1057
1121
|
}, z.core.$strip>;
|
|
1058
1122
|
};
|
|
1123
|
+
readonly "setup.get": {
|
|
1124
|
+
readonly params: z.ZodObject<{
|
|
1125
|
+
key: z.ZodString;
|
|
1126
|
+
}, z.core.$strip>;
|
|
1127
|
+
readonly result: z.ZodNullable<z.ZodObject<{
|
|
1128
|
+
key: z.ZodString;
|
|
1129
|
+
snapshotId: z.ZodNullable<z.ZodString>;
|
|
1130
|
+
createdAt: z.ZodNumber;
|
|
1131
|
+
lastUsedAt: z.ZodNullable<z.ZodNumber>;
|
|
1132
|
+
acquiringLockId: z.ZodNullable<z.ZodString>;
|
|
1133
|
+
acquiringLockAt: z.ZodNullable<z.ZodNumber>;
|
|
1134
|
+
}, z.core.$strip>>;
|
|
1135
|
+
};
|
|
1136
|
+
readonly "setup.set": {
|
|
1137
|
+
readonly params: z.ZodObject<{
|
|
1138
|
+
key: z.ZodString;
|
|
1139
|
+
snapshotId: z.ZodNullable<z.ZodString>;
|
|
1140
|
+
createdAt: z.ZodNumber;
|
|
1141
|
+
lastUsedAt: z.ZodNullable<z.ZodNumber>;
|
|
1142
|
+
acquiringLockId: z.ZodNullable<z.ZodString>;
|
|
1143
|
+
acquiringLockAt: z.ZodNullable<z.ZodNumber>;
|
|
1144
|
+
}, z.core.$strip>;
|
|
1145
|
+
readonly result: z.ZodVoid;
|
|
1146
|
+
};
|
|
1147
|
+
readonly "setup.acquireLock": {
|
|
1148
|
+
readonly params: z.ZodObject<{
|
|
1149
|
+
key: z.ZodString;
|
|
1150
|
+
lockId: z.ZodString;
|
|
1151
|
+
lockTimeoutMs: z.ZodNumber;
|
|
1152
|
+
}, z.core.$strip>;
|
|
1153
|
+
readonly result: z.ZodNullable<z.ZodObject<{
|
|
1154
|
+
key: z.ZodString;
|
|
1155
|
+
snapshotId: z.ZodNullable<z.ZodString>;
|
|
1156
|
+
createdAt: z.ZodNumber;
|
|
1157
|
+
lastUsedAt: z.ZodNullable<z.ZodNumber>;
|
|
1158
|
+
acquiringLockId: z.ZodNullable<z.ZodString>;
|
|
1159
|
+
acquiringLockAt: z.ZodNullable<z.ZodNumber>;
|
|
1160
|
+
}, z.core.$strip>>;
|
|
1161
|
+
};
|
|
1162
|
+
readonly "sandbox.acquireLock": {
|
|
1163
|
+
readonly params: z.ZodObject<{
|
|
1164
|
+
record: z.ZodObject<{
|
|
1165
|
+
id: z.ZodString;
|
|
1166
|
+
config: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1167
|
+
type: z.ZodLiteral<"vercel">;
|
|
1168
|
+
resources: z.ZodOptional<z.ZodObject<{
|
|
1169
|
+
vcpus: z.ZodNumber;
|
|
1170
|
+
}, z.core.$strip>>;
|
|
1171
|
+
ports: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
1172
|
+
lifecycle: z.ZodOptional<z.ZodObject<{
|
|
1173
|
+
pollIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
1174
|
+
stopAfterInactiveMs: z.ZodOptional<z.ZodNumber>;
|
|
1175
|
+
snapshotBeforeTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
1176
|
+
snapshotId: z.ZodOptional<z.ZodString>;
|
|
1177
|
+
autoStart: z.ZodOptional<z.ZodBoolean>;
|
|
1178
|
+
}, z.core.$strip>>;
|
|
1179
|
+
networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
|
|
1180
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1181
|
+
subnets: z.ZodOptional<z.ZodObject<{
|
|
1182
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1183
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1184
|
+
}, z.core.$strip>>;
|
|
1185
|
+
}, z.core.$strip>]>>;
|
|
1186
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1187
|
+
type: z.ZodLiteral<"local">;
|
|
1188
|
+
path: z.ZodOptional<z.ZodString>;
|
|
1189
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1190
|
+
type: z.ZodLiteral<"custom">;
|
|
1191
|
+
url: z.ZodString;
|
|
1192
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1193
|
+
}, z.core.$strip>], "type">;
|
|
1194
|
+
tags: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1195
|
+
createdAt: z.ZodNullable<z.ZodNumber>;
|
|
1196
|
+
lastActivityAt: z.ZodNullable<z.ZodNumber>;
|
|
1197
|
+
acquiringLockId: z.ZodNullable<z.ZodString>;
|
|
1198
|
+
acquiringLockAt: z.ZodNullable<z.ZodNumber>;
|
|
1199
|
+
providerMetadata: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1200
|
+
provider: z.ZodLiteral<"vercel">;
|
|
1201
|
+
sandboxId: z.ZodNullable<z.ZodString>;
|
|
1202
|
+
snapshotId: z.ZodNullable<z.ZodString>;
|
|
1203
|
+
}, z.core.$strip>], "provider">>;
|
|
1204
|
+
}, z.core.$strip>;
|
|
1205
|
+
lockTimeoutMs: z.ZodNumber;
|
|
1206
|
+
}, z.core.$strip>;
|
|
1207
|
+
readonly result: z.ZodNullable<z.ZodObject<{
|
|
1208
|
+
id: z.ZodString;
|
|
1209
|
+
config: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1210
|
+
type: z.ZodLiteral<"vercel">;
|
|
1211
|
+
resources: z.ZodOptional<z.ZodObject<{
|
|
1212
|
+
vcpus: z.ZodNumber;
|
|
1213
|
+
}, z.core.$strip>>;
|
|
1214
|
+
ports: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
1215
|
+
lifecycle: z.ZodOptional<z.ZodObject<{
|
|
1216
|
+
pollIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
1217
|
+
stopAfterInactiveMs: z.ZodOptional<z.ZodNumber>;
|
|
1218
|
+
snapshotBeforeTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
1219
|
+
snapshotId: z.ZodOptional<z.ZodString>;
|
|
1220
|
+
autoStart: z.ZodOptional<z.ZodBoolean>;
|
|
1221
|
+
}, z.core.$strip>>;
|
|
1222
|
+
networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
|
|
1223
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1224
|
+
subnets: z.ZodOptional<z.ZodObject<{
|
|
1225
|
+
allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1226
|
+
deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1227
|
+
}, z.core.$strip>>;
|
|
1228
|
+
}, z.core.$strip>]>>;
|
|
1229
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1230
|
+
type: z.ZodLiteral<"local">;
|
|
1231
|
+
path: z.ZodOptional<z.ZodString>;
|
|
1232
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1233
|
+
type: z.ZodLiteral<"custom">;
|
|
1234
|
+
url: z.ZodString;
|
|
1235
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1236
|
+
}, z.core.$strip>], "type">;
|
|
1237
|
+
tags: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1238
|
+
createdAt: z.ZodNullable<z.ZodNumber>;
|
|
1239
|
+
lastActivityAt: z.ZodNullable<z.ZodNumber>;
|
|
1240
|
+
acquiringLockId: z.ZodNullable<z.ZodString>;
|
|
1241
|
+
acquiringLockAt: z.ZodNullable<z.ZodNumber>;
|
|
1242
|
+
providerMetadata: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1243
|
+
provider: z.ZodLiteral<"vercel">;
|
|
1244
|
+
sandboxId: z.ZodNullable<z.ZodString>;
|
|
1245
|
+
snapshotId: z.ZodNullable<z.ZodString>;
|
|
1246
|
+
}, z.core.$strip>], "provider">>;
|
|
1247
|
+
}, z.core.$strip>>;
|
|
1248
|
+
};
|
|
1059
1249
|
};
|
|
1060
1250
|
|
|
1061
1251
|
type StorageMethods = typeof methods;
|
|
@@ -1065,6 +1255,7 @@ type Session = z.infer<typeof SessionSchema>;
|
|
|
1065
1255
|
type Message = z.infer<typeof MessageSchema>;
|
|
1066
1256
|
type Command = z.infer<typeof CommandSchema>;
|
|
1067
1257
|
type SandboxRecord = z.infer<typeof SandboxRecordSchema>;
|
|
1258
|
+
type SetupSnapshot = z.infer<typeof SetupSnapshotSchema>;
|
|
1068
1259
|
type PartBase = z.infer<typeof PartSchema>;
|
|
1069
1260
|
type Part = Omit<PartBase, "part"> & {
|
|
1070
1261
|
part: UIMessage["parts"][number];
|
|
@@ -1073,6 +1264,34 @@ type ListResult<T> = {
|
|
|
1073
1264
|
items: T[];
|
|
1074
1265
|
nextCursor: string | null;
|
|
1075
1266
|
};
|
|
1267
|
+
/**
|
|
1268
|
+
* Session with tags narrowed to a specific schema.
|
|
1269
|
+
*/
|
|
1270
|
+
type TypedSession<TTags extends Record<string, unknown>> = Omit<Session, "tags"> & {
|
|
1271
|
+
tags: Partial<TTags> | null;
|
|
1272
|
+
};
|
|
1273
|
+
/**
|
|
1274
|
+
* Storage interface with session tags narrowed to the agent's tagsSchema.
|
|
1275
|
+
* Used by the agent's `storage` getter so callers get typed tags on sessions.
|
|
1276
|
+
*/
|
|
1277
|
+
type TypedStorage<TTags extends Record<string, unknown>> = Omit<Storage, "session"> & {
|
|
1278
|
+
session: Omit<Storage["session"], "get" | "set" | "list" | "tag"> & {
|
|
1279
|
+
get: (id: string) => Promise<SessionNotFoundError | StorageError | TypedSession<TTags>>;
|
|
1280
|
+
set: (session: TypedSession<TTags>) => Promise<StorageError | TypedSession<TTags>>;
|
|
1281
|
+
list: (opts?: {
|
|
1282
|
+
tags?: Partial<TTags>;
|
|
1283
|
+
order?: "createdAt_asc" | "createdAt_desc" | "updatedAt_asc" | "updatedAt_desc";
|
|
1284
|
+
cursor?: string;
|
|
1285
|
+
limit?: number;
|
|
1286
|
+
}) => Promise<StorageError | ListResult<TypedSession<TTags>>>;
|
|
1287
|
+
tag: {
|
|
1288
|
+
set: (opts: {
|
|
1289
|
+
sessionId: string;
|
|
1290
|
+
tags: Partial<TTags>;
|
|
1291
|
+
}) => Promise<StorageError | TypedSession<TTags>>;
|
|
1292
|
+
};
|
|
1293
|
+
};
|
|
1294
|
+
};
|
|
1076
1295
|
interface Storage {
|
|
1077
1296
|
session: {
|
|
1078
1297
|
get: (id: string) => Promise<SessionNotFoundError | StorageError | Session>;
|
|
@@ -1126,6 +1345,7 @@ interface Storage {
|
|
|
1126
1345
|
tags: Record<string, unknown>;
|
|
1127
1346
|
}) => Promise<StorageError | SandboxRecord>;
|
|
1128
1347
|
};
|
|
1348
|
+
acquireLock: (record: SandboxRecord, lockTimeoutMs: number) => Promise<StorageError | SandboxRecord | null>;
|
|
1129
1349
|
};
|
|
1130
1350
|
command: {
|
|
1131
1351
|
get: (id: string) => Promise<StorageError | Command | null>;
|
|
@@ -1136,6 +1356,11 @@ interface Storage {
|
|
|
1136
1356
|
limit?: number;
|
|
1137
1357
|
}) => Promise<StorageError | ListResult<Command>>;
|
|
1138
1358
|
};
|
|
1359
|
+
setup: {
|
|
1360
|
+
get: (key: string) => Promise<StorageError | SetupSnapshot | null>;
|
|
1361
|
+
set: (snapshot: SetupSnapshot) => Promise<StorageError | SetupSnapshot>;
|
|
1362
|
+
acquireLock: (key: string, lockId: string, lockTimeoutMs: number) => Promise<StorageError | SetupSnapshot | null>;
|
|
1363
|
+
};
|
|
1139
1364
|
}
|
|
1140
1365
|
type BaseStorageConfig = {
|
|
1141
1366
|
name?: string;
|
|
@@ -1160,590 +1385,4 @@ type ResolvedStorage = {
|
|
|
1160
1385
|
headers?: Record<string, string>;
|
|
1161
1386
|
};
|
|
1162
1387
|
|
|
1163
|
-
type
|
|
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 };
|
|
1388
|
+
export { type ListResult as L, type MethodName as M, type NetworkPolicy as N, type Part as P, type ResolvedStorage as R, type StorageMethods as S, type TypedStorage as T, type UsageSummary as U, type Message as a, MessageNotFoundError as b, type MessageUsage as c, type SandboxConfig as d, SandboxError as e, SandboxNotFoundError as f, type SandboxRecord as g, type Session as h, SessionNotFoundError as i, type StepUsage as j, type StorageConfig as k, StorageError as l, type Storage as m, SessionError as n };
|