experimental-agent 0.0.3 → 0.0.5

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.
Files changed (38) hide show
  1. package/dist/agent-workflow.d.mts +1 -1
  2. package/dist/agent-workflow.d.ts +1 -1
  3. package/dist/agent-workflow.js +739 -319
  4. package/dist/agent-workflow.mjs +1 -1
  5. package/dist/chunk-2IIWVPZB.mjs +334 -0
  6. package/dist/{chunk-TQRCSTCF.mjs → chunk-CQB6AOJ7.mjs} +2 -2
  7. package/dist/{chunk-UFVWOC5L.mjs → chunk-CRDAPJEY.mjs} +3 -3
  8. package/dist/chunk-GJETDXOU.mjs +361 -0
  9. package/dist/chunk-M2XPBOZD.mjs +1980 -0
  10. package/dist/chunk-ZWP7RQZT.mjs +1239 -0
  11. package/dist/{client-SREKHM6I.mjs → client-5C4CNU6H.mjs} +1 -1
  12. package/dist/{client-BlSrVoPI.d.mts → client-9A8NO6x9.d.mts} +268 -7
  13. package/dist/{client-BlSrVoPI.d.ts → client-9A8NO6x9.d.ts} +268 -7
  14. package/dist/{handler-36FM5H35.mjs → handler-SZDTM3MC.mjs} +1 -1
  15. package/dist/index.d.mts +2 -2
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.js +875 -341
  18. package/dist/index.mjs +96 -24
  19. package/dist/lifecycle-workflow.d.mts +1 -1
  20. package/dist/lifecycle-workflow.d.ts +1 -1
  21. package/dist/lifecycle-workflow.js +97 -4
  22. package/dist/lifecycle-workflow.mjs +1 -1
  23. package/dist/local-fs-handlers-BZVA3XAU.mjs +277 -0
  24. package/dist/next/loader.js +3 -3
  25. package/dist/next/loader.mjs +1 -1
  26. package/dist/next.js +6 -3
  27. package/dist/next.mjs +5 -2
  28. package/dist/{sandbox-QAPGBVYM.mjs → sandbox-M24R3JLM.mjs} +2 -2
  29. package/dist/{storage-Q376OZH3.mjs → storage-TMZQJ2OQ.mjs} +2 -2
  30. package/dist/vercel-WGN2NY3D.mjs +20 -0
  31. package/dist/{vercel-sdk-VHKEX2GQ.mjs → vercel-sdk-UKBD5JDI.mjs} +2 -2
  32. package/package.json +2 -2
  33. package/dist/chunk-GSRJYPWF.mjs +0 -284
  34. package/dist/chunk-JEE2FQ4O.mjs +0 -844
  35. package/dist/chunk-VBLZWXVE.mjs +0 -318
  36. package/dist/chunk-ZASQBPOI.mjs +0 -2057
  37. package/dist/local-fs-handlers-P4WGW3QY.mjs +0 -235
  38. package/dist/vercel-LLXAHKVJ.mjs +0 -20
@@ -22,6 +22,14 @@ declare const MessageNotFoundError_base: errore.FactoryTaggedErrorClass<"Message
22
22
  declare class MessageNotFoundError extends MessageNotFoundError_base {
23
23
  }
24
24
 
25
+ declare const NetworkPolicySchema: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
26
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
27
+ subnets: z.ZodOptional<z.ZodObject<{
28
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
29
+ deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
30
+ }, z.core.$strip>>;
31
+ }, z.core.$strip>]>>;
32
+ type NetworkPolicy = z.infer<typeof NetworkPolicySchema>;
25
33
  declare const SandboxConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
26
34
  type: z.ZodLiteral<"vercel">;
27
35
  resources: z.ZodOptional<z.ZodObject<{
@@ -35,6 +43,13 @@ declare const SandboxConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
35
43
  snapshotId: z.ZodOptional<z.ZodString>;
36
44
  autoStart: z.ZodOptional<z.ZodBoolean>;
37
45
  }, z.core.$strip>>;
46
+ networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
47
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
48
+ subnets: z.ZodOptional<z.ZodObject<{
49
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
50
+ deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
51
+ }, z.core.$strip>>;
52
+ }, z.core.$strip>]>>;
38
53
  }, z.core.$strip>, z.ZodObject<{
39
54
  type: z.ZodLiteral<"local">;
40
55
  path: z.ZodOptional<z.ZodString>;
@@ -175,6 +190,13 @@ declare const SandboxRecordSchema: z.ZodObject<{
175
190
  snapshotId: z.ZodOptional<z.ZodString>;
176
191
  autoStart: z.ZodOptional<z.ZodBoolean>;
177
192
  }, z.core.$strip>>;
193
+ networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
194
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
195
+ subnets: z.ZodOptional<z.ZodObject<{
196
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
197
+ deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
198
+ }, z.core.$strip>>;
199
+ }, z.core.$strip>]>>;
178
200
  }, z.core.$strip>, z.ZodObject<{
179
201
  type: z.ZodLiteral<"local">;
180
202
  path: z.ZodOptional<z.ZodString>;
@@ -241,6 +263,14 @@ declare const CommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
241
263
  completedAt: z.ZodNumber;
242
264
  }, z.core.$strip>;
243
265
  }, z.core.$strip>], "status">;
266
+ declare const SetupSnapshotSchema: z.ZodObject<{
267
+ key: z.ZodString;
268
+ snapshotId: z.ZodNullable<z.ZodString>;
269
+ createdAt: z.ZodNumber;
270
+ lastUsedAt: z.ZodNullable<z.ZodNumber>;
271
+ acquiringLockId: z.ZodNullable<z.ZodString>;
272
+ acquiringLockAt: z.ZodNullable<z.ZodNumber>;
273
+ }, z.core.$strip>;
244
274
  declare const methods: {
245
275
  readonly "session.get": {
246
276
  readonly params: z.ZodObject<{
@@ -664,6 +694,13 @@ declare const methods: {
664
694
  snapshotId: z.ZodOptional<z.ZodString>;
665
695
  autoStart: z.ZodOptional<z.ZodBoolean>;
666
696
  }, z.core.$strip>>;
697
+ networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
698
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
699
+ subnets: z.ZodOptional<z.ZodObject<{
700
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
701
+ deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
702
+ }, z.core.$strip>>;
703
+ }, z.core.$strip>]>>;
667
704
  }, z.core.$strip>, z.ZodObject<{
668
705
  type: z.ZodLiteral<"local">;
669
706
  path: z.ZodOptional<z.ZodString>;
@@ -703,6 +740,13 @@ declare const methods: {
703
740
  snapshotId: z.ZodOptional<z.ZodString>;
704
741
  autoStart: z.ZodOptional<z.ZodBoolean>;
705
742
  }, z.core.$strip>>;
743
+ networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
744
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
745
+ subnets: z.ZodOptional<z.ZodObject<{
746
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
747
+ deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
748
+ }, z.core.$strip>>;
749
+ }, z.core.$strip>]>>;
706
750
  }, z.core.$strip>, z.ZodObject<{
707
751
  type: z.ZodLiteral<"local">;
708
752
  path: z.ZodOptional<z.ZodString>;
@@ -739,6 +783,13 @@ declare const methods: {
739
783
  snapshotId: z.ZodOptional<z.ZodString>;
740
784
  autoStart: z.ZodOptional<z.ZodBoolean>;
741
785
  }, z.core.$strip>>;
786
+ networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
787
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
788
+ subnets: z.ZodOptional<z.ZodObject<{
789
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
790
+ deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
791
+ }, z.core.$strip>>;
792
+ }, z.core.$strip>]>>;
742
793
  }, z.core.$strip>, z.ZodObject<{
743
794
  type: z.ZodLiteral<"local">;
744
795
  path: z.ZodOptional<z.ZodString>;
@@ -788,6 +839,13 @@ declare const methods: {
788
839
  snapshotId: z.ZodOptional<z.ZodString>;
789
840
  autoStart: z.ZodOptional<z.ZodBoolean>;
790
841
  }, z.core.$strip>>;
842
+ networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
843
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
844
+ subnets: z.ZodOptional<z.ZodObject<{
845
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
846
+ deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
847
+ }, z.core.$strip>>;
848
+ }, z.core.$strip>]>>;
791
849
  }, z.core.$strip>, z.ZodObject<{
792
850
  type: z.ZodLiteral<"local">;
793
851
  path: z.ZodOptional<z.ZodString>;
@@ -830,6 +888,13 @@ declare const methods: {
830
888
  snapshotId: z.ZodOptional<z.ZodString>;
831
889
  autoStart: z.ZodOptional<z.ZodBoolean>;
832
890
  }, z.core.$strip>>;
891
+ networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
892
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
893
+ subnets: z.ZodOptional<z.ZodObject<{
894
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
895
+ deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
896
+ }, z.core.$strip>>;
897
+ }, z.core.$strip>]>>;
833
898
  }, z.core.$strip>, z.ZodObject<{
834
899
  type: z.ZodLiteral<"local">;
835
900
  path: z.ZodOptional<z.ZodString>;
@@ -1056,6 +1121,132 @@ declare const methods: {
1056
1121
  nextCursor: z.ZodNullable<z.ZodString>;
1057
1122
  }, z.core.$strip>;
1058
1123
  };
1124
+ readonly "setup.get": {
1125
+ readonly params: z.ZodObject<{
1126
+ key: z.ZodString;
1127
+ }, z.core.$strip>;
1128
+ readonly result: z.ZodNullable<z.ZodObject<{
1129
+ key: z.ZodString;
1130
+ snapshotId: z.ZodNullable<z.ZodString>;
1131
+ createdAt: z.ZodNumber;
1132
+ lastUsedAt: z.ZodNullable<z.ZodNumber>;
1133
+ acquiringLockId: z.ZodNullable<z.ZodString>;
1134
+ acquiringLockAt: z.ZodNullable<z.ZodNumber>;
1135
+ }, z.core.$strip>>;
1136
+ };
1137
+ readonly "setup.set": {
1138
+ readonly params: z.ZodObject<{
1139
+ key: z.ZodString;
1140
+ snapshotId: z.ZodNullable<z.ZodString>;
1141
+ createdAt: z.ZodNumber;
1142
+ lastUsedAt: z.ZodNullable<z.ZodNumber>;
1143
+ acquiringLockId: z.ZodNullable<z.ZodString>;
1144
+ acquiringLockAt: z.ZodNullable<z.ZodNumber>;
1145
+ }, z.core.$strip>;
1146
+ readonly result: z.ZodVoid;
1147
+ };
1148
+ readonly "setup.acquireLock": {
1149
+ readonly params: z.ZodObject<{
1150
+ key: z.ZodString;
1151
+ lockId: z.ZodString;
1152
+ lockTimeoutMs: z.ZodNumber;
1153
+ }, z.core.$strip>;
1154
+ readonly result: z.ZodNullable<z.ZodObject<{
1155
+ key: z.ZodString;
1156
+ snapshotId: z.ZodNullable<z.ZodString>;
1157
+ createdAt: z.ZodNumber;
1158
+ lastUsedAt: z.ZodNullable<z.ZodNumber>;
1159
+ acquiringLockId: z.ZodNullable<z.ZodString>;
1160
+ acquiringLockAt: z.ZodNullable<z.ZodNumber>;
1161
+ }, z.core.$strip>>;
1162
+ };
1163
+ readonly "sandbox.acquireLock": {
1164
+ readonly params: z.ZodObject<{
1165
+ record: z.ZodObject<{
1166
+ id: z.ZodString;
1167
+ config: z.ZodDiscriminatedUnion<[z.ZodObject<{
1168
+ type: z.ZodLiteral<"vercel">;
1169
+ resources: z.ZodOptional<z.ZodObject<{
1170
+ vcpus: z.ZodNumber;
1171
+ }, z.core.$strip>>;
1172
+ ports: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
1173
+ lifecycle: z.ZodOptional<z.ZodObject<{
1174
+ pollIntervalMs: z.ZodOptional<z.ZodNumber>;
1175
+ stopAfterInactiveMs: z.ZodOptional<z.ZodNumber>;
1176
+ snapshotBeforeTimeoutMs: z.ZodOptional<z.ZodNumber>;
1177
+ snapshotId: z.ZodOptional<z.ZodString>;
1178
+ autoStart: z.ZodOptional<z.ZodBoolean>;
1179
+ }, z.core.$strip>>;
1180
+ networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
1181
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
1182
+ subnets: z.ZodOptional<z.ZodObject<{
1183
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
1184
+ deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
1185
+ }, z.core.$strip>>;
1186
+ }, z.core.$strip>]>>;
1187
+ }, z.core.$strip>, z.ZodObject<{
1188
+ type: z.ZodLiteral<"local">;
1189
+ path: z.ZodOptional<z.ZodString>;
1190
+ }, z.core.$strip>, z.ZodObject<{
1191
+ type: z.ZodLiteral<"custom">;
1192
+ url: z.ZodString;
1193
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1194
+ }, z.core.$strip>], "type">;
1195
+ tags: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1196
+ createdAt: z.ZodNullable<z.ZodNumber>;
1197
+ lastActivityAt: z.ZodNullable<z.ZodNumber>;
1198
+ acquiringLockId: z.ZodNullable<z.ZodString>;
1199
+ acquiringLockAt: z.ZodNullable<z.ZodNumber>;
1200
+ providerMetadata: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
1201
+ provider: z.ZodLiteral<"vercel">;
1202
+ sandboxId: z.ZodNullable<z.ZodString>;
1203
+ snapshotId: z.ZodNullable<z.ZodString>;
1204
+ }, z.core.$strip>], "provider">>;
1205
+ }, z.core.$strip>;
1206
+ lockTimeoutMs: z.ZodNumber;
1207
+ }, z.core.$strip>;
1208
+ readonly result: z.ZodNullable<z.ZodObject<{
1209
+ id: z.ZodString;
1210
+ config: z.ZodDiscriminatedUnion<[z.ZodObject<{
1211
+ type: z.ZodLiteral<"vercel">;
1212
+ resources: z.ZodOptional<z.ZodObject<{
1213
+ vcpus: z.ZodNumber;
1214
+ }, z.core.$strip>>;
1215
+ ports: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
1216
+ lifecycle: z.ZodOptional<z.ZodObject<{
1217
+ pollIntervalMs: z.ZodOptional<z.ZodNumber>;
1218
+ stopAfterInactiveMs: z.ZodOptional<z.ZodNumber>;
1219
+ snapshotBeforeTimeoutMs: z.ZodOptional<z.ZodNumber>;
1220
+ snapshotId: z.ZodOptional<z.ZodString>;
1221
+ autoStart: z.ZodOptional<z.ZodBoolean>;
1222
+ }, z.core.$strip>>;
1223
+ networkPolicy: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"allow-all">, z.ZodLiteral<"deny-all">, z.ZodObject<{
1224
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
1225
+ subnets: z.ZodOptional<z.ZodObject<{
1226
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
1227
+ deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
1228
+ }, z.core.$strip>>;
1229
+ }, z.core.$strip>]>>;
1230
+ }, z.core.$strip>, z.ZodObject<{
1231
+ type: z.ZodLiteral<"local">;
1232
+ path: z.ZodOptional<z.ZodString>;
1233
+ }, z.core.$strip>, z.ZodObject<{
1234
+ type: z.ZodLiteral<"custom">;
1235
+ url: z.ZodString;
1236
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1237
+ }, z.core.$strip>], "type">;
1238
+ tags: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1239
+ createdAt: z.ZodNullable<z.ZodNumber>;
1240
+ lastActivityAt: z.ZodNullable<z.ZodNumber>;
1241
+ acquiringLockId: z.ZodNullable<z.ZodString>;
1242
+ acquiringLockAt: z.ZodNullable<z.ZodNumber>;
1243
+ providerMetadata: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
1244
+ provider: z.ZodLiteral<"vercel">;
1245
+ sandboxId: z.ZodNullable<z.ZodString>;
1246
+ snapshotId: z.ZodNullable<z.ZodString>;
1247
+ }, z.core.$strip>], "provider">>;
1248
+ }, z.core.$strip>>;
1249
+ };
1059
1250
  };
1060
1251
 
1061
1252
  type StorageMethods = typeof methods;
@@ -1065,6 +1256,7 @@ type Session = z.infer<typeof SessionSchema>;
1065
1256
  type Message = z.infer<typeof MessageSchema>;
1066
1257
  type Command = z.infer<typeof CommandSchema>;
1067
1258
  type SandboxRecord = z.infer<typeof SandboxRecordSchema>;
1259
+ type SetupSnapshot = z.infer<typeof SetupSnapshotSchema>;
1068
1260
  type PartBase = z.infer<typeof PartSchema>;
1069
1261
  type Part = Omit<PartBase, "part"> & {
1070
1262
  part: UIMessage["parts"][number];
@@ -1126,6 +1318,7 @@ interface Storage {
1126
1318
  tags: Record<string, unknown>;
1127
1319
  }) => Promise<StorageError | SandboxRecord>;
1128
1320
  };
1321
+ acquireLock: (record: SandboxRecord, lockTimeoutMs: number) => Promise<StorageError | SandboxRecord | null>;
1129
1322
  };
1130
1323
  command: {
1131
1324
  get: (id: string) => Promise<StorageError | Command | null>;
@@ -1136,6 +1329,11 @@ interface Storage {
1136
1329
  limit?: number;
1137
1330
  }) => Promise<StorageError | ListResult<Command>>;
1138
1331
  };
1332
+ setup: {
1333
+ get: (key: string) => Promise<StorageError | SetupSnapshot | null>;
1334
+ set: (snapshot: SetupSnapshot) => Promise<StorageError | SetupSnapshot>;
1335
+ acquireLock: (key: string, lockId: string, lockTimeoutMs: number) => Promise<StorageError | SetupSnapshot | null>;
1336
+ };
1139
1337
  }
1140
1338
  type BaseStorageConfig = {
1141
1339
  name?: string;
@@ -1198,6 +1396,13 @@ type UploadableFile = {
1198
1396
  */
1199
1397
  type SkillsDir = string | string[];
1200
1398
 
1399
+ type SandboxSetup = {
1400
+ /** Explicit key the developer controls. Bump to invalidate and re-run setup. */
1401
+ key: string;
1402
+ /** Async function that receives a bare Sandbox and does setup work. */
1403
+ run: (sandbox: Sandbox) => Promise<void>;
1404
+ };
1405
+ type OnRestart = (sandbox: Sandbox) => Promise<void>;
1201
1406
  type SandboxLifecycleInput = {
1202
1407
  id: string;
1203
1408
  vercelSandboxId: string;
@@ -1245,11 +1450,31 @@ interface Sandbox<TTags extends TagsSchema = TagsSchema> {
1245
1450
  commandId: string;
1246
1451
  storage: Storage;
1247
1452
  }) => Promise<SandboxError | undefined>;
1453
+ readFile: (opts: {
1454
+ path: string;
1455
+ }) => Promise<SandboxError | Buffer | null>;
1248
1456
  writeFiles: (opts: {
1249
1457
  files: UploadableFile[];
1250
1458
  destPath: string;
1251
1459
  }) => Promise<void>;
1252
1460
  lifecycle?: SandboxLifecycle;
1461
+ /**
1462
+ * Dynamically update the network policy on a running sandbox.
1463
+ * Only available for Vercel sandboxes.
1464
+ *
1465
+ * @example
1466
+ * ```ts
1467
+ * // Lock down to specific domains
1468
+ * await sandbox.updateNetworkPolicy({ allow: ["github.com", "*.github.com"] });
1469
+ *
1470
+ * // Deny all network access
1471
+ * await sandbox.updateNetworkPolicy("deny-all");
1472
+ *
1473
+ * // Restore full access
1474
+ * await sandbox.updateNetworkPolicy("allow-all");
1475
+ * ```
1476
+ */
1477
+ updateNetworkPolicy: (policy: NonNullable<NetworkPolicy>) => Promise<SandboxError | NonNullable<NetworkPolicy>>;
1253
1478
  tag: {
1254
1479
  list: () => Promise<SandboxNotFoundError | StorageError | TTags>;
1255
1480
  get: (key: string) => Promise<SandboxNotFoundError | StorageError | TTags[typeof key] | undefined>;
@@ -1362,9 +1587,7 @@ declare const builtInTools: {
1362
1587
  }, any>;
1363
1588
  };
1364
1589
  type BuiltInToolName = keyof typeof builtInTools;
1365
- declare const builtinToolNames: {
1366
- [k: string]: string;
1367
- };
1590
+ declare const builtinToolNames: { [K in BuiltInToolName]: K; };
1368
1591
 
1369
1592
  type ToolMetadata = {
1370
1593
  name: string;
@@ -1449,7 +1672,10 @@ type SessionOptions<Tools extends ToolSet, TTags extends Record<string, unknown>
1449
1672
  /** System prompt for the AI model. */
1450
1673
  system?: string;
1451
1674
  /** Sandbox configuration or ID. If string, uses as sandbox ID with its config. */
1452
- sandbox?: SandboxConfig | string;
1675
+ sandbox?: (SandboxConfig & {
1676
+ setup?: SandboxSetup;
1677
+ onRestart?: OnRestart;
1678
+ }) | string;
1453
1679
  /** Key-value metadata tags for the session. */
1454
1680
  tags?: TTags;
1455
1681
  /** Directory containing skill definitions for the agent. */
@@ -1463,6 +1689,11 @@ type SessionOptions<Tools extends ToolSet, TTags extends Record<string, unknown>
1463
1689
  /** Generation options (temperature, maxSteps, etc.). Overrides agent-level defaults. */
1464
1690
  generation?: GenerationOptions;
1465
1691
  };
1692
+ /**
1693
+ * Fields that can be updated on an existing session via `session.update()`.
1694
+ * Excludes sandbox (not changeable after creation) and tags (use `session.tag` methods).
1695
+ */
1696
+ type SessionUpdateOptions<Tools extends ToolSet> = Pick<SessionOptions<Tools>, "model" | "system" | "skillsDir" | "activeTools" | "generation">;
1466
1697
  /**
1467
1698
  * Configuration options for creating an agent instance.
1468
1699
  *
@@ -1487,7 +1718,7 @@ type AgentOptions<Tools extends ToolSet, TTags extends Record<string, unknown> =
1487
1718
  * - `{ type: "local" }` - filesystem storage (dev)
1488
1719
  * - `{ type: "vercel" }` - Vercel managed storage (prod)
1489
1720
  * - `{ type: "custom", url: "..." }` - custom HTTP backend
1490
- * @default { type: "vercel" }
1721
+ * @default Inferred from environment: `{ type: "vercel" }` when `VERCEL_OIDC_TOKEN` is set, `{ type: "local" }` otherwise.
1491
1722
  */
1492
1723
  storage?: StorageConfig;
1493
1724
  /**
@@ -1522,7 +1753,34 @@ type AgentOptions<Tools extends ToolSet, TTags extends Record<string, unknown> =
1522
1753
  * ```
1523
1754
  */
1524
1755
  needsApproval?: NeedsApprovalMap<Tools>;
1525
- } & Omit<SessionOptions<Tools, TTags>, "tags">;
1756
+ /**
1757
+ * Sandbox configuration with optional setup and restart hooks.
1758
+ *
1759
+ * - `setup.key`: explicit string to control snapshot invalidation (bump to re-run)
1760
+ * - `setup.run`: async function that runs once to initialize the sandbox, then gets snapshotted
1761
+ * - `onRestart`: async function that runs every time a sandbox resumes from a snapshot
1762
+ *
1763
+ * @example
1764
+ * ```ts
1765
+ * sandbox: {
1766
+ * type: "vercel",
1767
+ * setup: {
1768
+ * key: "dev-env-v3",
1769
+ * run: async (sandbox) => {
1770
+ * await sandbox.exec({ command: "npm", args: ["i", "-g", "vercel"] })
1771
+ * },
1772
+ * },
1773
+ * onRestart: async (sandbox) => {
1774
+ * await sandbox.exec({ command: "bash", args: ["-c", "npm run dev &"] })
1775
+ * },
1776
+ * }
1777
+ * ```
1778
+ */
1779
+ sandbox?: (SandboxConfig & {
1780
+ setup?: SandboxSetup;
1781
+ onRestart?: OnRestart;
1782
+ }) | string;
1783
+ } & Omit<SessionOptions<Tools, TTags>, "tags" | "sandbox">;
1526
1784
  /**
1527
1785
  * Base type for session/sandbox tags. Used for generic constraints.
1528
1786
  * For agent-level tag validation, use `tagsSchema` option with a zod schema.
@@ -1730,10 +1988,13 @@ declare const agent: <Tools extends {}, TTags extends Record<string, unknown> =
1730
1988
  reason?: string;
1731
1989
  }) => Promise<undefined | Error>;
1732
1990
  usage: () => Promise<SessionUsage | Error>;
1991
+ update: (updateOptions: SessionUpdateOptions<Tools>) => Promise<undefined | Error>;
1733
1992
  }>;
1734
1993
  sandbox: (sandboxId: string, opts?: {
1735
1994
  config?: SandboxConfig;
1736
1995
  tags?: TTags;
1996
+ setup?: SandboxSetup;
1997
+ onRestart?: OnRestart;
1737
1998
  }) => Promise<Sandbox<TTags>>;
1738
1999
  readonly storage: Storage;
1739
2000
  /**
@@ -1748,4 +2009,4 @@ declare const agent: <Tools extends {}, TTags extends Record<string, unknown> =
1748
2009
  rpc: (params: RpcPayload) => Promise<RpcResult>;
1749
2010
  };
1750
2011
 
1751
- 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 };
2012
+ 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 OnRestart as O, 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 SandboxSetup as k, type SendInput as l, type Session as m, SessionNotFoundError as n, type SessionOptions as o, type SkillSummary as p, type StepUsage as q, type StorageConfig as r, StorageError as s, type ToolContext as t, type UsageSummary as u, agent as v, builtinToolNames as w, type SandboxLifecycleInput as x };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  handleStorageRpc
3
- } from "./chunk-VBLZWXVE.mjs";
3
+ } from "./chunk-GJETDXOU.mjs";
4
4
  import "./chunk-3ODWQVIA.mjs";
5
5
  export {
6
6
  handleStorageRpc
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as MethodName, S as StorageMethods } from './client-BlSrVoPI.mjs';
2
- export { A as AgentOptions, B as BuiltInToolName, E as ExecResult, G as GenerationOptions, I as InferUIMessage, L as ListResult, a as Message, b as MessageNotFoundError, c as MessageUsage, P as Part, R as ResolvedStorage, d as RpcPayload, e as RpcResult, f as Sandbox, g as SandboxConfig, h as SandboxError, i as SandboxNotFoundError, j as SandboxRecord, k as SendInput, l as Session, m as SessionNotFoundError, n as SessionOptions, o as SkillSummary, p as StepUsage, q as StorageConfig, r as StorageError, T as TagsSchema, s as ToolContext, U as UploadableFile, t as UsageSummary, u as agent, v as builtinToolNames } from './client-BlSrVoPI.mjs';
1
+ import { M as MethodName, S as StorageMethods } from './client-9A8NO6x9.mjs';
2
+ export { A as AgentOptions, B as BuiltInToolName, E as ExecResult, G as GenerationOptions, I as InferUIMessage, L as ListResult, a as Message, b as MessageNotFoundError, c as MessageUsage, O as OnRestart, P as Part, R as ResolvedStorage, d as RpcPayload, e as RpcResult, f as Sandbox, g as SandboxConfig, h as SandboxError, i as SandboxNotFoundError, j as SandboxRecord, k as SandboxSetup, l as SendInput, m as Session, n as SessionNotFoundError, o as SessionOptions, p as SkillSummary, q as StepUsage, r as StorageConfig, s as StorageError, T as TagsSchema, t as ToolContext, U as UploadableFile, u as UsageSummary, v as agent, w as builtinToolNames } from './client-9A8NO6x9.mjs';
3
3
  import { z } from 'zod';
4
4
  import 'errore';
5
5
  import 'ai';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as MethodName, S as StorageMethods } from './client-BlSrVoPI.js';
2
- export { A as AgentOptions, B as BuiltInToolName, E as ExecResult, G as GenerationOptions, I as InferUIMessage, L as ListResult, a as Message, b as MessageNotFoundError, c as MessageUsage, P as Part, R as ResolvedStorage, d as RpcPayload, e as RpcResult, f as Sandbox, g as SandboxConfig, h as SandboxError, i as SandboxNotFoundError, j as SandboxRecord, k as SendInput, l as Session, m as SessionNotFoundError, n as SessionOptions, o as SkillSummary, p as StepUsage, q as StorageConfig, r as StorageError, T as TagsSchema, s as ToolContext, U as UploadableFile, t as UsageSummary, u as agent, v as builtinToolNames } from './client-BlSrVoPI.js';
1
+ import { M as MethodName, S as StorageMethods } from './client-9A8NO6x9.js';
2
+ export { A as AgentOptions, B as BuiltInToolName, E as ExecResult, G as GenerationOptions, I as InferUIMessage, L as ListResult, a as Message, b as MessageNotFoundError, c as MessageUsage, O as OnRestart, P as Part, R as ResolvedStorage, d as RpcPayload, e as RpcResult, f as Sandbox, g as SandboxConfig, h as SandboxError, i as SandboxNotFoundError, j as SandboxRecord, k as SandboxSetup, l as SendInput, m as Session, n as SessionNotFoundError, o as SessionOptions, p as SkillSummary, q as StepUsage, r as StorageConfig, s as StorageError, T as TagsSchema, t as ToolContext, U as UploadableFile, u as UsageSummary, v as agent, w as builtinToolNames } from './client-9A8NO6x9.js';
3
3
  import { z } from 'zod';
4
4
  import 'errore';
5
5
  import 'ai';