experimental-agent 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/{adapter-zgOel4wW.d.mts → adapter-Cl735Kp4.d.mts} +3 -60
  2. package/dist/{adapter-zgOel4wW.d.ts → adapter-Cl735Kp4.d.ts} +3 -60
  3. package/dist/{chunk-ZUFJJYC4.mjs → chunk-2Y7EZPIP.mjs} +3 -2
  4. package/dist/{chunk-RT72C52I.mjs → chunk-6MS4CGEZ.mjs} +3 -2
  5. package/dist/{chunk-MSTM6W3Y.mjs → chunk-AB2JYY6A.mjs} +3 -3
  6. package/dist/{chunk-IV75IMEW.mjs → chunk-I5DCB7RU.mjs} +27 -9
  7. package/dist/chunk-NOW6XL5E.mjs +310 -0
  8. package/dist/{docker-QPCLWLYR.mjs → docker-OBUQX5ZI.mjs} +1 -1
  9. package/dist/entry-Bs17QEiq.d.mts +45 -0
  10. package/dist/entry-QNyd4S1s.d.ts +45 -0
  11. package/dist/index.d.mts +128 -37
  12. package/dist/index.d.ts +128 -37
  13. package/dist/index.js +251 -130
  14. package/dist/index.mjs +216 -123
  15. package/dist/lifecycle-workflow-steps.d.mts +2 -2
  16. package/dist/lifecycle-workflow-steps.d.ts +2 -2
  17. package/dist/lifecycle-workflow.d.mts +2 -2
  18. package/dist/lifecycle-workflow.d.ts +2 -2
  19. package/dist/{local-KJ3BSIFJ.mjs → local-4C3V4EFS.mjs} +1 -1
  20. package/dist/next/loader.js +3 -3
  21. package/dist/next/loader.mjs +1 -1
  22. package/dist/next.js +3 -3
  23. package/dist/next.mjs +1 -1
  24. package/dist/sandbox.d.mts +3 -3
  25. package/dist/sandbox.d.ts +3 -3
  26. package/dist/sandbox.js +15 -5
  27. package/dist/sandbox.mjs +3 -3
  28. package/dist/{steps-DShnXBLf.d.ts → steps-XA4wG8W3.d.ts} +4 -1
  29. package/dist/{steps-BIsP57pm.d.mts → steps-eTytqxQb.d.mts} +4 -1
  30. package/dist/storage.d.mts +2 -2
  31. package/dist/storage.d.ts +2 -2
  32. package/dist/storage.js +27 -9
  33. package/dist/storage.mjs +1 -1
  34. package/dist/{vercel-QZ6INPMV.mjs → vercel-6ORAC625.mjs} +1 -1
  35. package/package.json +2 -2
  36. package/dist/chunk-BFFNCESS.mjs +0 -302
  37. package/dist/entry-6HYg5qqg.d.mts +0 -36
  38. package/dist/entry-BrWOmEK2.d.ts +0 -36
@@ -0,0 +1,45 @@
1
+ import { a as SandboxSetupFields, b as SandboxInstance, S as SandboxBinding, e as LifecycleConfig } from './steps-XA4wG8W3.js';
2
+ import * as _vercel_sandbox from '@vercel/sandbox';
3
+
4
+ type DockerBindingConfig = {
5
+ cwd?: string;
6
+ };
7
+ type DockerBindingMetadata = {
8
+ sandboxName: string;
9
+ };
10
+ declare function dockerSandbox(defaults?: Partial<SandboxSetupFields> & {
11
+ run?: (sandbox: SandboxInstance) => Promise<void>;
12
+ config?: DockerBindingConfig;
13
+ }): SandboxBinding<"docker", DockerBindingConfig, DockerBindingMetadata>;
14
+
15
+ type LocalBindingConfig = {
16
+ cwd?: string;
17
+ };
18
+ type LocalBindingMetadata = {
19
+ basePath: string;
20
+ pid: number;
21
+ };
22
+ declare function localSandbox(defaults?: Partial<SandboxSetupFields> & {
23
+ run?: (sandbox: SandboxInstance) => Promise<void>;
24
+ config?: LocalBindingConfig;
25
+ }): SandboxBinding<"local", LocalBindingConfig, LocalBindingMetadata>;
26
+
27
+ type VercelBindingConfig = {
28
+ cwd?: string;
29
+ resources?: {
30
+ vcpus: number;
31
+ };
32
+ ports?: number[];
33
+ networkPolicy?: _vercel_sandbox.NetworkPolicy;
34
+ snapshotId?: string;
35
+ lifecycle?: LifecycleConfig;
36
+ };
37
+ type VercelBindingMetadata = {
38
+ sandboxId: string;
39
+ };
40
+ declare function vercelSandbox(defaults?: Partial<SandboxSetupFields> & {
41
+ run?: (sandbox: SandboxInstance) => Promise<void>;
42
+ config?: VercelBindingConfig;
43
+ }): SandboxBinding<"vercel", VercelBindingConfig, VercelBindingMetadata>;
44
+
45
+ export { type DockerBindingConfig as D, type LocalBindingConfig as L, type VercelBindingConfig as V, type LocalBindingMetadata as a, type VercelBindingMetadata as b, type DockerBindingMetadata as c, dockerSandbox as d, localSandbox as l, vercelSandbox as v };
package/dist/index.d.mts CHANGED
@@ -1,21 +1,16 @@
1
1
  import * as _vercel_sandbox from '@vercel/sandbox';
2
- import { S as SandboxBinding, a as SandboxSetupFields, b as SandboxInstance, W as WithConfig, c as LoggingConfig, E as ExecResult, U as UploadableFile } from './steps-BIsP57pm.mjs';
3
- export { d as SandboxAgentRef } from './steps-BIsP57pm.mjs';
4
- import { L as LocalBindingConfig, a as LocalBindingMetadata, V as VercelBindingConfig, b as VercelBindingMetadata, D as DockerBindingConfig, c as DockerBindingMetadata } from './entry-6HYg5qqg.mjs';
2
+ import { S as SandboxBinding, a as SandboxSetupFields, b as SandboxInstance, W as WithConfig, c as LoggingConfig, E as ExecResult, U as UploadableFile } from './steps-eTytqxQb.mjs';
3
+ export { d as SandboxAgentRef } from './steps-eTytqxQb.mjs';
4
+ import { L as LocalBindingConfig, a as LocalBindingMetadata, V as VercelBindingConfig, b as VercelBindingMetadata, D as DockerBindingConfig, c as DockerBindingMetadata } from './entry-Bs17QEiq.mjs';
5
+ import { G as GenerationOptions, j as StorageInput, f as Storage, c as Session } from './adapter-Cl735Kp4.mjs';
5
6
  import * as ai from 'ai';
6
- import { InferToolInput, ModelMessage, ToolSet, UIMessage, InferUITools, GatewayModelId } from 'ai';
7
+ import { ToolSet, InferToolInput, ModelMessage, UIMessage, InferUITools, GatewayModelId } from 'ai';
7
8
  import { z } from 'zod';
8
- import { c as Session, f as Storage, j as SkillInput, k as StorageInput } from './adapter-zgOel4wW.mjs';
9
- export { l as GitSkillEntry, m as GitSkillInput, H as HostSkillEntry, n as HostSkillInput, I as InlineSkillEntry, o as InlineSkillInput, p as SandboxSkillEntry, q as SandboxSkillInput, r as SkillEntry, s as SkillSourceType } from './adapter-zgOel4wW.mjs';
10
9
  import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
11
10
  import * as errore from 'errore';
12
11
 
13
12
  type BuiltInBindings = SandboxBinding<"local", LocalBindingConfig, LocalBindingMetadata> | SandboxBinding<"vercel", VercelBindingConfig, VercelBindingMetadata> | SandboxBinding<"docker", DockerBindingConfig, DockerBindingMetadata>;
14
13
 
15
- type SandboxOptions = {
16
- id?: string;
17
- };
18
-
19
14
  type SetupCommonFields = Partial<SandboxSetupFields> & {
20
15
  cwd?: string;
21
16
  run?: (sandbox: SandboxInstance) => Promise<void>;
@@ -33,6 +28,10 @@ type SetupResult = {
33
28
  done: Promise<SandboxInstance>;
34
29
  };
35
30
 
31
+ type SandboxOptions = {
32
+ id?: string;
33
+ };
34
+
36
35
  type StepUsage = {
37
36
  stepIndex: number;
38
37
  model: string;
@@ -60,12 +59,59 @@ type SessionUsage = {
60
59
  byMessageId: Record<string, UsageSummary | null>;
61
60
  };
62
61
 
63
- type ToolContext<TContext = Record<string, unknown>> = {
64
- session: Session;
65
- sandbox: SandboxInstance;
66
- storage: Storage;
67
- context: TContext;
62
+ type SkillSourceType = "sandbox" | "host" | "git" | "inline";
63
+ type SandboxSkillInput = {
64
+ type: "sandbox";
65
+ path: string;
66
+ };
67
+ type HostSkillInput = {
68
+ type: "host";
69
+ path: string;
70
+ };
71
+ type GitSkillInput = {
72
+ type: "git";
73
+ repo: string;
74
+ ref?: string;
75
+ path?: string;
76
+ /**
77
+ * Skill directory name under `path`.
78
+ */
79
+ name?: string;
68
80
  };
81
+ type InlineSkillInput = {
82
+ type: "inline";
83
+ name: string;
84
+ description: string;
85
+ instructions: string;
86
+ };
87
+ type SkillInput = SandboxSkillInput | HostSkillInput | GitSkillInput | InlineSkillInput;
88
+ type SandboxSkillEntry = {
89
+ type: "sandbox";
90
+ path: string;
91
+ };
92
+ type HostSkillEntry = {
93
+ type: "host";
94
+ path: string;
95
+ };
96
+ type GitSkillEntry = {
97
+ type: "git";
98
+ repo: string;
99
+ ref?: string;
100
+ path?: string;
101
+ /**
102
+ * Skill directory name under `path`.
103
+ */
104
+ name?: string;
105
+ };
106
+ type InlineSkillEntry = {
107
+ type: "inline";
108
+ name: string;
109
+ description: string;
110
+ instructions: string;
111
+ };
112
+ type SkillEntry = SandboxSkillEntry | HostSkillEntry | GitSkillEntry | InlineSkillEntry;
113
+
114
+ type ToolContext<TContext = Record<string, unknown>, Tools extends ToolSet = ToolSet> = ResolvableArgs<TContext, Tools>;
69
115
  declare const builtInTools: {
70
116
  Read: ai.Tool<{
71
117
  label: string;
@@ -238,11 +284,6 @@ type WorkflowRunLike = {
238
284
  }): ReadableStream;
239
285
  };
240
286
 
241
- type UpdateOptions<Tools extends ToolSet> = Partial<Omit<Session, "id" | "activeTools" | "model"> & {
242
- model?: GatewayModelId;
243
- activeTools?: (Extract<keyof Tools, string> | BuiltInToolName)[];
244
- }>;
245
-
246
287
  type ApprovalData = {
247
288
  approvalId: string;
248
289
  approved: boolean;
@@ -261,7 +302,7 @@ type SendInput<Tools extends ToolSet> = string | MessageData<Tools> | {
261
302
  type: "approval";
262
303
  approval: ApprovalData;
263
304
  };
264
- type SendOptions<Tools extends ToolSet, TContext> = {
305
+ type SendOptions<TContext> = {
265
306
  interruptIfStreaming?: boolean | {
266
307
  lastPart: {
267
308
  index: number;
@@ -270,7 +311,8 @@ type SendOptions<Tools extends ToolSet, TContext> = {
270
311
  };
271
312
  context?: TContext;
272
313
  abortSignal?: AbortSignal;
273
- } & UpdateOptions<Tools>;
314
+ sandboxId?: string;
315
+ };
274
316
  type SendResult = {
275
317
  assistantMessageId: string;
276
318
  done: true | Promise<true>;
@@ -283,14 +325,21 @@ type InterruptOptions = {
283
325
  };
284
326
  };
285
327
 
286
- type SessionDefaults<Tools extends ToolSet = ToolSet> = {
287
- model?: GatewayModelId;
288
- system?: string;
289
- generation?: Session["generation"];
290
- activeTools?: (Extract<keyof Tools, string> | BuiltInToolName)[];
291
- skills?: SkillInput[];
328
+ type ResolvableArgs<TContext = Record<string, unknown>, Tools extends ToolSet = ToolSet> = {
329
+ context: TContext;
330
+ sessionId: string;
331
+ sandbox: SandboxInstance;
332
+ messages: UIMessage<unknown, AgentDataTypes, InferUITools<Tools>>[];
333
+ };
334
+ type Resolvable<T, TContext = Record<string, unknown>, Tools extends ToolSet = ToolSet> = T | ((args: ResolvableArgs<TContext, Tools>) => T | Promise<T>);
335
+ type SessionDefaults<Tools extends ToolSet = ToolSet, TContext extends Record<string, unknown> = Record<string, unknown>> = {
336
+ model?: Resolvable<GatewayModelId | undefined, TContext, Tools>;
337
+ system?: Resolvable<string | string[] | undefined, TContext, Tools>;
338
+ generation?: Resolvable<GenerationOptions | undefined, TContext, Tools>;
339
+ activeTools?: Resolvable<readonly (Extract<keyof Tools, string> | BuiltInToolName)[] | undefined, TContext, Tools>;
340
+ skills?: Resolvable<SkillInput[] | undefined, TContext, Tools>;
292
341
  };
293
- type AgentOptions<Tools extends ToolSet = any, TSandboxBindings extends SandboxBinding | SandboxBinding[] = SandboxBinding, TContext extends Record<string, unknown> = Record<string, never>> = SessionDefaults<Tools> & {
342
+ type AgentOptions<Tools extends ToolSet = any, TSandboxBindings extends SandboxBinding | SandboxBinding[] = SandboxBinding, TContext extends Record<string, unknown> = Record<string, never>> = SessionDefaults<Tools, TContext> & {
294
343
  storage?: StorageInput;
295
344
  sandbox?: TSandboxBindings;
296
345
  tools?: Tools;
@@ -315,14 +364,13 @@ declare class Agent<TMessageMetadata = unknown, Tools extends ToolSet = ToolSet,
315
364
  private _resolvedStorage;
316
365
  get storage(): Storage;
317
366
  get tools(): typeof builtInTools & Tools;
318
- get sessionDefaults(): SessionDefaults;
319
367
  get hooks(): AgentHooks;
320
368
  readonly session: (id?: string | {
321
369
  id?: string;
322
370
  } | undefined) => {
323
371
  id: string;
324
- send: (input: SendInput<Tools> | SendInput<Tools>[], opts?: SendOptions<Tools, TContext> | undefined) => Promise<SendResult>;
325
- stream: (runOrOpts?: WorkflowRunLike | StreamOptions | undefined) => Promise<ReadableStream<ai.UIMessageChunk>>;
372
+ send: (input: SendInput<Tools> | SendInput<Tools>[], opts?: SendOptions<TContext> | undefined) => Promise<SendResult>;
373
+ stream: (runOrOpts?: StreamOptions | WorkflowRunLike | undefined) => Promise<ReadableStream<ai.UIMessageChunk>>;
326
374
  history: () => Promise<{
327
375
  messages: UIMessage<unknown, AgentDataTypes, InferUITools<Tools>>[];
328
376
  streamingMessageId: string | null;
@@ -330,10 +378,53 @@ declare class Agent<TMessageMetadata = unknown, Tools extends ToolSet = ToolSet,
330
378
  }>;
331
379
  interrupt: (opts?: InterruptOptions | undefined) => Promise<void>;
332
380
  usage: () => Promise<SessionUsage>;
333
- update: (opts: Partial<Omit<Session, "id" | "model" | "activeTools"> & {
334
- model?: GatewayModelId;
335
- activeTools?: ("Read" | "Grep" | "List" | "Write" | "Edit" | "Bash" | "Skill" | "JavaScript" | Extract<keyof Tools, string>)[] | undefined;
336
- }>) => Promise<void>;
381
+ update: (opts: Partial<Omit<Session, "id" | "createdAt" | "updatedAt">>) => Promise<void>;
382
+ sandbox: {
383
+ setup: (opts?: SetupOpts<TSandboxBindings> | undefined) => Promise<SetupResult>;
384
+ exec: (opts: {
385
+ command: string;
386
+ args?: string[];
387
+ cwd?: string;
388
+ env?: Record<string, string>;
389
+ sudo?: boolean;
390
+ signal?: AbortSignal;
391
+ }) => Promise<ExecResult>;
392
+ stop: (opts?: {
393
+ signal?: AbortSignal;
394
+ } | undefined) => Promise<void>;
395
+ snapshot: (opts?: {
396
+ signal?: AbortSignal;
397
+ } | undefined) => Promise<{
398
+ snapshotId: string;
399
+ }>;
400
+ getDomain: (opts: {
401
+ port: number;
402
+ signal?: AbortSignal;
403
+ }) => Promise<string>;
404
+ getStatus: (opts?: {
405
+ signal?: AbortSignal;
406
+ } | undefined) => Promise<"pending" | "running" | "stopping" | "stopped" | "failed">;
407
+ kill: (opts: {
408
+ commandId: string;
409
+ signal?: AbortSignal;
410
+ }) => Promise<void>;
411
+ readFile: (opts: {
412
+ path: string;
413
+ signal?: AbortSignal;
414
+ }) => Promise<Buffer | null>;
415
+ start: (opts?: {
416
+ signal?: AbortSignal;
417
+ } | undefined) => Promise<void>;
418
+ updateNetworkPolicy: (opts: {
419
+ policy: _vercel_sandbox.NetworkPolicy;
420
+ signal?: AbortSignal;
421
+ }) => Promise<_vercel_sandbox.NetworkPolicy>;
422
+ writeFiles: (opts: {
423
+ files: UploadableFile[];
424
+ destPath: string;
425
+ signal?: AbortSignal;
426
+ }) => Promise<void>;
427
+ };
337
428
  };
338
429
  readonly sandbox: (id?: string | SandboxOptions | undefined) => {
339
430
  id: string;
@@ -407,4 +498,4 @@ declare const MessageNotFoundError_base: errore.FactoryTaggedErrorClass<"Message
407
498
  declare class MessageNotFoundError extends MessageNotFoundError_base {
408
499
  }
409
500
 
410
- export { type AgentDataTypes, type AgentHooks, type AgentOptions, AgentStatus, type AnyAgent, type ApprovalData, type BuiltInToolName, ExecResult, type InferSession, type InferUIMessage, MessageNotFoundError, type NeedsApprovalMap, SandboxBinding, SandboxError, SandboxInstance, SandboxNotFoundError, SandboxSetupFields, type SendInput, type SessionDefaults, SessionNotFoundError, type SessionSendArgs, SkillInput, type StepUsage, StorageConflictError, StorageError, type ToolContext, UploadableFile, type UsageSummary, type WorkflowRunLike, agent, builtinToolNames };
501
+ export { type AgentDataTypes, type AgentHooks, type AgentOptions, AgentStatus, type AnyAgent, type ApprovalData, type BuiltInToolName, ExecResult, type GitSkillEntry, type GitSkillInput, type HostSkillEntry, type HostSkillInput, type InferSession, type InferUIMessage, type InlineSkillEntry, type InlineSkillInput, MessageNotFoundError, type NeedsApprovalMap, type Resolvable, type ResolvableArgs, SandboxBinding, SandboxError, SandboxInstance, SandboxNotFoundError, SandboxSetupFields, type SandboxSkillEntry, type SandboxSkillInput, type SendInput, type SessionDefaults, SessionNotFoundError, type SessionSendArgs, type SkillEntry, type SkillInput, type SkillSourceType, type StepUsage, StorageConflictError, StorageError, type ToolContext, UploadableFile, type UsageSummary, type WorkflowRunLike, agent, builtinToolNames };
package/dist/index.d.ts CHANGED
@@ -1,21 +1,16 @@
1
1
  import * as _vercel_sandbox from '@vercel/sandbox';
2
- import { S as SandboxBinding, a as SandboxSetupFields, b as SandboxInstance, W as WithConfig, c as LoggingConfig, E as ExecResult, U as UploadableFile } from './steps-DShnXBLf.js';
3
- export { d as SandboxAgentRef } from './steps-DShnXBLf.js';
4
- import { L as LocalBindingConfig, a as LocalBindingMetadata, V as VercelBindingConfig, b as VercelBindingMetadata, D as DockerBindingConfig, c as DockerBindingMetadata } from './entry-BrWOmEK2.js';
2
+ import { S as SandboxBinding, a as SandboxSetupFields, b as SandboxInstance, W as WithConfig, c as LoggingConfig, E as ExecResult, U as UploadableFile } from './steps-XA4wG8W3.js';
3
+ export { d as SandboxAgentRef } from './steps-XA4wG8W3.js';
4
+ import { L as LocalBindingConfig, a as LocalBindingMetadata, V as VercelBindingConfig, b as VercelBindingMetadata, D as DockerBindingConfig, c as DockerBindingMetadata } from './entry-QNyd4S1s.js';
5
+ import { G as GenerationOptions, j as StorageInput, f as Storage, c as Session } from './adapter-Cl735Kp4.js';
5
6
  import * as ai from 'ai';
6
- import { InferToolInput, ModelMessage, ToolSet, UIMessage, InferUITools, GatewayModelId } from 'ai';
7
+ import { ToolSet, InferToolInput, ModelMessage, UIMessage, InferUITools, GatewayModelId } from 'ai';
7
8
  import { z } from 'zod';
8
- import { c as Session, f as Storage, j as SkillInput, k as StorageInput } from './adapter-zgOel4wW.js';
9
- export { l as GitSkillEntry, m as GitSkillInput, H as HostSkillEntry, n as HostSkillInput, I as InlineSkillEntry, o as InlineSkillInput, p as SandboxSkillEntry, q as SandboxSkillInput, r as SkillEntry, s as SkillSourceType } from './adapter-zgOel4wW.js';
10
9
  import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
11
10
  import * as errore from 'errore';
12
11
 
13
12
  type BuiltInBindings = SandboxBinding<"local", LocalBindingConfig, LocalBindingMetadata> | SandboxBinding<"vercel", VercelBindingConfig, VercelBindingMetadata> | SandboxBinding<"docker", DockerBindingConfig, DockerBindingMetadata>;
14
13
 
15
- type SandboxOptions = {
16
- id?: string;
17
- };
18
-
19
14
  type SetupCommonFields = Partial<SandboxSetupFields> & {
20
15
  cwd?: string;
21
16
  run?: (sandbox: SandboxInstance) => Promise<void>;
@@ -33,6 +28,10 @@ type SetupResult = {
33
28
  done: Promise<SandboxInstance>;
34
29
  };
35
30
 
31
+ type SandboxOptions = {
32
+ id?: string;
33
+ };
34
+
36
35
  type StepUsage = {
37
36
  stepIndex: number;
38
37
  model: string;
@@ -60,12 +59,59 @@ type SessionUsage = {
60
59
  byMessageId: Record<string, UsageSummary | null>;
61
60
  };
62
61
 
63
- type ToolContext<TContext = Record<string, unknown>> = {
64
- session: Session;
65
- sandbox: SandboxInstance;
66
- storage: Storage;
67
- context: TContext;
62
+ type SkillSourceType = "sandbox" | "host" | "git" | "inline";
63
+ type SandboxSkillInput = {
64
+ type: "sandbox";
65
+ path: string;
66
+ };
67
+ type HostSkillInput = {
68
+ type: "host";
69
+ path: string;
70
+ };
71
+ type GitSkillInput = {
72
+ type: "git";
73
+ repo: string;
74
+ ref?: string;
75
+ path?: string;
76
+ /**
77
+ * Skill directory name under `path`.
78
+ */
79
+ name?: string;
68
80
  };
81
+ type InlineSkillInput = {
82
+ type: "inline";
83
+ name: string;
84
+ description: string;
85
+ instructions: string;
86
+ };
87
+ type SkillInput = SandboxSkillInput | HostSkillInput | GitSkillInput | InlineSkillInput;
88
+ type SandboxSkillEntry = {
89
+ type: "sandbox";
90
+ path: string;
91
+ };
92
+ type HostSkillEntry = {
93
+ type: "host";
94
+ path: string;
95
+ };
96
+ type GitSkillEntry = {
97
+ type: "git";
98
+ repo: string;
99
+ ref?: string;
100
+ path?: string;
101
+ /**
102
+ * Skill directory name under `path`.
103
+ */
104
+ name?: string;
105
+ };
106
+ type InlineSkillEntry = {
107
+ type: "inline";
108
+ name: string;
109
+ description: string;
110
+ instructions: string;
111
+ };
112
+ type SkillEntry = SandboxSkillEntry | HostSkillEntry | GitSkillEntry | InlineSkillEntry;
113
+
114
+ type ToolContext<TContext = Record<string, unknown>, Tools extends ToolSet = ToolSet> = ResolvableArgs<TContext, Tools>;
69
115
  declare const builtInTools: {
70
116
  Read: ai.Tool<{
71
117
  label: string;
@@ -238,11 +284,6 @@ type WorkflowRunLike = {
238
284
  }): ReadableStream;
239
285
  };
240
286
 
241
- type UpdateOptions<Tools extends ToolSet> = Partial<Omit<Session, "id" | "activeTools" | "model"> & {
242
- model?: GatewayModelId;
243
- activeTools?: (Extract<keyof Tools, string> | BuiltInToolName)[];
244
- }>;
245
-
246
287
  type ApprovalData = {
247
288
  approvalId: string;
248
289
  approved: boolean;
@@ -261,7 +302,7 @@ type SendInput<Tools extends ToolSet> = string | MessageData<Tools> | {
261
302
  type: "approval";
262
303
  approval: ApprovalData;
263
304
  };
264
- type SendOptions<Tools extends ToolSet, TContext> = {
305
+ type SendOptions<TContext> = {
265
306
  interruptIfStreaming?: boolean | {
266
307
  lastPart: {
267
308
  index: number;
@@ -270,7 +311,8 @@ type SendOptions<Tools extends ToolSet, TContext> = {
270
311
  };
271
312
  context?: TContext;
272
313
  abortSignal?: AbortSignal;
273
- } & UpdateOptions<Tools>;
314
+ sandboxId?: string;
315
+ };
274
316
  type SendResult = {
275
317
  assistantMessageId: string;
276
318
  done: true | Promise<true>;
@@ -283,14 +325,21 @@ type InterruptOptions = {
283
325
  };
284
326
  };
285
327
 
286
- type SessionDefaults<Tools extends ToolSet = ToolSet> = {
287
- model?: GatewayModelId;
288
- system?: string;
289
- generation?: Session["generation"];
290
- activeTools?: (Extract<keyof Tools, string> | BuiltInToolName)[];
291
- skills?: SkillInput[];
328
+ type ResolvableArgs<TContext = Record<string, unknown>, Tools extends ToolSet = ToolSet> = {
329
+ context: TContext;
330
+ sessionId: string;
331
+ sandbox: SandboxInstance;
332
+ messages: UIMessage<unknown, AgentDataTypes, InferUITools<Tools>>[];
333
+ };
334
+ type Resolvable<T, TContext = Record<string, unknown>, Tools extends ToolSet = ToolSet> = T | ((args: ResolvableArgs<TContext, Tools>) => T | Promise<T>);
335
+ type SessionDefaults<Tools extends ToolSet = ToolSet, TContext extends Record<string, unknown> = Record<string, unknown>> = {
336
+ model?: Resolvable<GatewayModelId | undefined, TContext, Tools>;
337
+ system?: Resolvable<string | string[] | undefined, TContext, Tools>;
338
+ generation?: Resolvable<GenerationOptions | undefined, TContext, Tools>;
339
+ activeTools?: Resolvable<readonly (Extract<keyof Tools, string> | BuiltInToolName)[] | undefined, TContext, Tools>;
340
+ skills?: Resolvable<SkillInput[] | undefined, TContext, Tools>;
292
341
  };
293
- type AgentOptions<Tools extends ToolSet = any, TSandboxBindings extends SandboxBinding | SandboxBinding[] = SandboxBinding, TContext extends Record<string, unknown> = Record<string, never>> = SessionDefaults<Tools> & {
342
+ type AgentOptions<Tools extends ToolSet = any, TSandboxBindings extends SandboxBinding | SandboxBinding[] = SandboxBinding, TContext extends Record<string, unknown> = Record<string, never>> = SessionDefaults<Tools, TContext> & {
294
343
  storage?: StorageInput;
295
344
  sandbox?: TSandboxBindings;
296
345
  tools?: Tools;
@@ -315,14 +364,13 @@ declare class Agent<TMessageMetadata = unknown, Tools extends ToolSet = ToolSet,
315
364
  private _resolvedStorage;
316
365
  get storage(): Storage;
317
366
  get tools(): typeof builtInTools & Tools;
318
- get sessionDefaults(): SessionDefaults;
319
367
  get hooks(): AgentHooks;
320
368
  readonly session: (id?: string | {
321
369
  id?: string;
322
370
  } | undefined) => {
323
371
  id: string;
324
- send: (input: SendInput<Tools> | SendInput<Tools>[], opts?: SendOptions<Tools, TContext> | undefined) => Promise<SendResult>;
325
- stream: (runOrOpts?: WorkflowRunLike | StreamOptions | undefined) => Promise<ReadableStream<ai.UIMessageChunk>>;
372
+ send: (input: SendInput<Tools> | SendInput<Tools>[], opts?: SendOptions<TContext> | undefined) => Promise<SendResult>;
373
+ stream: (runOrOpts?: StreamOptions | WorkflowRunLike | undefined) => Promise<ReadableStream<ai.UIMessageChunk>>;
326
374
  history: () => Promise<{
327
375
  messages: UIMessage<unknown, AgentDataTypes, InferUITools<Tools>>[];
328
376
  streamingMessageId: string | null;
@@ -330,10 +378,53 @@ declare class Agent<TMessageMetadata = unknown, Tools extends ToolSet = ToolSet,
330
378
  }>;
331
379
  interrupt: (opts?: InterruptOptions | undefined) => Promise<void>;
332
380
  usage: () => Promise<SessionUsage>;
333
- update: (opts: Partial<Omit<Session, "id" | "model" | "activeTools"> & {
334
- model?: GatewayModelId;
335
- activeTools?: ("Read" | "Grep" | "List" | "Write" | "Edit" | "Bash" | "Skill" | "JavaScript" | Extract<keyof Tools, string>)[] | undefined;
336
- }>) => Promise<void>;
381
+ update: (opts: Partial<Omit<Session, "id" | "createdAt" | "updatedAt">>) => Promise<void>;
382
+ sandbox: {
383
+ setup: (opts?: SetupOpts<TSandboxBindings> | undefined) => Promise<SetupResult>;
384
+ exec: (opts: {
385
+ command: string;
386
+ args?: string[];
387
+ cwd?: string;
388
+ env?: Record<string, string>;
389
+ sudo?: boolean;
390
+ signal?: AbortSignal;
391
+ }) => Promise<ExecResult>;
392
+ stop: (opts?: {
393
+ signal?: AbortSignal;
394
+ } | undefined) => Promise<void>;
395
+ snapshot: (opts?: {
396
+ signal?: AbortSignal;
397
+ } | undefined) => Promise<{
398
+ snapshotId: string;
399
+ }>;
400
+ getDomain: (opts: {
401
+ port: number;
402
+ signal?: AbortSignal;
403
+ }) => Promise<string>;
404
+ getStatus: (opts?: {
405
+ signal?: AbortSignal;
406
+ } | undefined) => Promise<"pending" | "running" | "stopping" | "stopped" | "failed">;
407
+ kill: (opts: {
408
+ commandId: string;
409
+ signal?: AbortSignal;
410
+ }) => Promise<void>;
411
+ readFile: (opts: {
412
+ path: string;
413
+ signal?: AbortSignal;
414
+ }) => Promise<Buffer | null>;
415
+ start: (opts?: {
416
+ signal?: AbortSignal;
417
+ } | undefined) => Promise<void>;
418
+ updateNetworkPolicy: (opts: {
419
+ policy: _vercel_sandbox.NetworkPolicy;
420
+ signal?: AbortSignal;
421
+ }) => Promise<_vercel_sandbox.NetworkPolicy>;
422
+ writeFiles: (opts: {
423
+ files: UploadableFile[];
424
+ destPath: string;
425
+ signal?: AbortSignal;
426
+ }) => Promise<void>;
427
+ };
337
428
  };
338
429
  readonly sandbox: (id?: string | SandboxOptions | undefined) => {
339
430
  id: string;
@@ -407,4 +498,4 @@ declare const MessageNotFoundError_base: errore.FactoryTaggedErrorClass<"Message
407
498
  declare class MessageNotFoundError extends MessageNotFoundError_base {
408
499
  }
409
500
 
410
- export { type AgentDataTypes, type AgentHooks, type AgentOptions, AgentStatus, type AnyAgent, type ApprovalData, type BuiltInToolName, ExecResult, type InferSession, type InferUIMessage, MessageNotFoundError, type NeedsApprovalMap, SandboxBinding, SandboxError, SandboxInstance, SandboxNotFoundError, SandboxSetupFields, type SendInput, type SessionDefaults, SessionNotFoundError, type SessionSendArgs, SkillInput, type StepUsage, StorageConflictError, StorageError, type ToolContext, UploadableFile, type UsageSummary, type WorkflowRunLike, agent, builtinToolNames };
501
+ export { type AgentDataTypes, type AgentHooks, type AgentOptions, AgentStatus, type AnyAgent, type ApprovalData, type BuiltInToolName, ExecResult, type GitSkillEntry, type GitSkillInput, type HostSkillEntry, type HostSkillInput, type InferSession, type InferUIMessage, type InlineSkillEntry, type InlineSkillInput, MessageNotFoundError, type NeedsApprovalMap, type Resolvable, type ResolvableArgs, SandboxBinding, SandboxError, SandboxInstance, SandboxNotFoundError, SandboxSetupFields, type SandboxSkillEntry, type SandboxSkillInput, type SendInput, type SessionDefaults, SessionNotFoundError, type SessionSendArgs, type SkillEntry, type SkillInput, type SkillSourceType, type StepUsage, StorageConflictError, StorageError, type ToolContext, UploadableFile, type UsageSummary, type WorkflowRunLike, agent, builtinToolNames };