experimental-agent 0.2.3 → 0.4.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 (69) hide show
  1. package/README.md +103 -241
  2. package/dist/adapter-zgOel4wW.d.mts +256 -0
  3. package/dist/adapter-zgOel4wW.d.ts +256 -0
  4. package/dist/chunk-BFFNCESS.mjs +302 -0
  5. package/dist/chunk-C4VSUEY2.mjs +72 -0
  6. package/dist/chunk-GKASMIBR.mjs +50 -0
  7. package/dist/chunk-IV75IMEW.mjs +328 -0
  8. package/dist/chunk-JO3JDCH5.mjs +107 -0
  9. package/dist/chunk-MSTM6W3Y.mjs +99 -0
  10. package/dist/chunk-MSWINCCM.mjs +128 -0
  11. package/dist/chunk-RT72C52I.mjs +324 -0
  12. package/dist/chunk-ZUFJJYC4.mjs +150 -0
  13. package/dist/{handler-FRUPZ4LX.mjs → docker-QPCLWLYR.mjs} +3 -4
  14. package/dist/entry-6HYg5qqg.d.mts +36 -0
  15. package/dist/entry-BrWOmEK2.d.ts +36 -0
  16. package/dist/index.d.mts +401 -18
  17. package/dist/index.d.ts +401 -18
  18. package/dist/index.js +3396 -5500
  19. package/dist/index.mjs +3511 -1166
  20. package/dist/lifecycle-workflow-steps.d.mts +5 -0
  21. package/dist/lifecycle-workflow-steps.d.ts +5 -0
  22. package/dist/lifecycle-workflow-steps.js +263 -0
  23. package/dist/lifecycle-workflow-steps.mjs +9 -0
  24. package/dist/lifecycle-workflow.d.mts +6 -6
  25. package/dist/lifecycle-workflow.d.ts +6 -6
  26. package/dist/lifecycle-workflow.js +192 -905
  27. package/dist/lifecycle-workflow.mjs +3 -1
  28. package/dist/local-KJ3BSIFJ.mjs +8 -0
  29. package/dist/next/loader.js +31 -7
  30. package/dist/next/loader.mjs +1 -1
  31. package/dist/next.js +35 -8
  32. package/dist/next.mjs +6 -3
  33. package/dist/{process-manager-JDUJDYGU.mjs → process-manager-WQHAIVRB.mjs} +1 -1
  34. package/dist/sandbox.d.mts +6 -0
  35. package/dist/sandbox.d.ts +6 -0
  36. package/dist/sandbox.js +1070 -0
  37. package/dist/sandbox.mjs +19 -0
  38. package/dist/steps-BIsP57pm.d.mts +173 -0
  39. package/dist/steps-DShnXBLf.d.ts +173 -0
  40. package/dist/storage.d.mts +17 -0
  41. package/dist/storage.d.ts +17 -0
  42. package/dist/storage.js +368 -0
  43. package/dist/storage.mjs +16 -0
  44. package/dist/vercel-QZ6INPMV.mjs +11 -0
  45. package/package.json +29 -5
  46. package/dist/agent-workflow.d.mts +0 -30
  47. package/dist/agent-workflow.d.ts +0 -30
  48. package/dist/agent-workflow.js +0 -5433
  49. package/dist/agent-workflow.mjs +0 -14
  50. package/dist/chunk-7M6UPURS.mjs +0 -75
  51. package/dist/chunk-AML2VCQS.mjs +0 -1287
  52. package/dist/chunk-FQ67QZOI.mjs +0 -75
  53. package/dist/chunk-NO7RHGTH.mjs +0 -2367
  54. package/dist/chunk-NXDVNJRS.mjs +0 -106
  55. package/dist/chunk-OZZVS6L5.mjs +0 -139
  56. package/dist/chunk-SJVFFE5D.mjs +0 -402
  57. package/dist/chunk-TAXLUVIC.mjs +0 -1
  58. package/dist/chunk-TGNVXSMX.mjs +0 -399
  59. package/dist/chunk-YRYXN7W4.mjs +0 -48
  60. package/dist/chunk-ZIAHPXOJ.mjs +0 -595
  61. package/dist/client-BKA7XBGW.mjs +0 -15
  62. package/dist/client-CEeSFGva.d.mts +0 -2376
  63. package/dist/client-CEeSFGva.d.ts +0 -2376
  64. package/dist/docker-FB2MJTHJ.mjs +0 -12
  65. package/dist/local-fs-handlers-SYOCKTPN.mjs +0 -447
  66. package/dist/sandbox-UENKQV3T.mjs +0 -21
  67. package/dist/storage-LSDMRW73.mjs +0 -20
  68. package/dist/vercel-SD3JTECG.mjs +0 -20
  69. package/dist/vercel-sdk-I6A4MVAN.mjs +0 -8
@@ -0,0 +1,19 @@
1
+ import {
2
+ vercelSandbox
3
+ } from "./chunk-RT72C52I.mjs";
4
+ import {
5
+ dockerSandbox
6
+ } from "./chunk-BFFNCESS.mjs";
7
+ import {
8
+ localSandbox
9
+ } from "./chunk-ZUFJJYC4.mjs";
10
+ import "./chunk-GKASMIBR.mjs";
11
+ import "./chunk-JO3JDCH5.mjs";
12
+ import "./chunk-MSWINCCM.mjs";
13
+ import "./chunk-BJTO5JO5.mjs";
14
+ export {
15
+ dockerSandbox,
16
+ localSandbox,
17
+ vercelSandbox
18
+ };
19
+ //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFtdLAogICJzb3VyY2VzQ29udGVudCI6IFtdLAogICJtYXBwaW5ncyI6ICIiLAogICJuYW1lcyI6IFtdCn0K
@@ -0,0 +1,173 @@
1
+ import * as _vercel_sandbox from '@vercel/sandbox';
2
+ import { f as Storage, b as Sandbox } from './adapter-zgOel4wW.mjs';
3
+
4
+ type LogLevel = "info" | "warn" | "error" | "silent";
5
+ type LogContext = {
6
+ sessionId?: string;
7
+ messageId?: string;
8
+ sandboxId?: string;
9
+ [key: string]: unknown;
10
+ };
11
+ type LoggingConfig = {
12
+ level?: LogLevel;
13
+ /**
14
+ * Top-level label for all log lines.
15
+ * @default "agent"
16
+ * @example "my-app" → [my-app:default:workflow]
17
+ */
18
+ prefix?: string;
19
+ name?: string;
20
+ };
21
+ declare class Logger {
22
+ readonly subsystem: string;
23
+ private readonly config;
24
+ private readonly context;
25
+ constructor({ subsystem, config, context, }: {
26
+ subsystem: string;
27
+ config: LoggingConfig;
28
+ context?: LogContext;
29
+ });
30
+ child({ subsystem, context, }: {
31
+ subsystem?: string;
32
+ context?: LogContext;
33
+ }): Logger;
34
+ withContext(context: LogContext): Logger;
35
+ info(message: string, data?: Record<string, unknown>): void;
36
+ warn(message: string, data?: Record<string, unknown>): void;
37
+ error(message: string, data?: Record<string, unknown>): void;
38
+ /**
39
+ * Returns a function that, when called, logs the elapsed time at info level.
40
+ * Pass `logOnStart: true` to also log when the timer begins.
41
+ *
42
+ * @example
43
+ * const done = log.time("sandbox setup", { sandboxId }, { logOnStart: true });
44
+ * await setup();
45
+ * done(); // start: [agent:default:sandbox] sandbox setup { sandboxId: '...' }
46
+ * // end: [agent:default:sandbox] sandbox setup { sandboxId: '...', durationMs: 123 }
47
+ */
48
+ time(message: string, data?: Record<string, unknown>, opts?: {
49
+ logOnStart?: boolean;
50
+ }): (endData?: Record<string, unknown>) => void;
51
+ }
52
+
53
+ type ExecResult = {
54
+ commandId: string;
55
+ logs: () => AsyncIterable<{
56
+ stream: "stdout" | "stderr";
57
+ data: string;
58
+ }>;
59
+ result: Promise<{
60
+ stdout: string;
61
+ stderr: string;
62
+ exitCode: number;
63
+ }>;
64
+ };
65
+ type UploadableFile = {
66
+ path: string;
67
+ content: string | Buffer;
68
+ };
69
+ interface SandboxInstance {
70
+ readonly cwd: string;
71
+ exec(opts: {
72
+ command: string;
73
+ args?: string[];
74
+ cwd?: string;
75
+ env?: Record<string, string>;
76
+ sudo?: boolean;
77
+ signal?: AbortSignal;
78
+ }): Promise<ExecResult>;
79
+ readFile(opts: {
80
+ path: string;
81
+ signal?: AbortSignal;
82
+ }): Promise<Buffer | null>;
83
+ writeFiles(opts: {
84
+ files: UploadableFile[];
85
+ destPath: string;
86
+ signal?: AbortSignal;
87
+ }): Promise<void>;
88
+ getDomain(opts: {
89
+ port: number;
90
+ signal?: AbortSignal;
91
+ }): Promise<string>;
92
+ updateNetworkPolicy(opts: {
93
+ policy: _vercel_sandbox.NetworkPolicy;
94
+ signal?: AbortSignal;
95
+ }): Promise<_vercel_sandbox.NetworkPolicy>;
96
+ start(opts?: {
97
+ signal?: AbortSignal;
98
+ }): Promise<void>;
99
+ stop(opts?: {
100
+ signal?: AbortSignal;
101
+ }): Promise<void>;
102
+ snapshot(opts?: {
103
+ signal?: AbortSignal;
104
+ }): Promise<{
105
+ snapshotId: string;
106
+ }>;
107
+ kill(opts: {
108
+ commandId: string;
109
+ signal?: AbortSignal;
110
+ }): Promise<void>;
111
+ getStatus(opts?: {
112
+ signal?: AbortSignal;
113
+ }): Promise<"pending" | "running" | "stopping" | "stopped" | "failed">;
114
+ }
115
+ type SandboxAgentRef = {
116
+ name: string;
117
+ storage: Storage;
118
+ options: {
119
+ logging?: Omit<LoggingConfig, "name">;
120
+ };
121
+ };
122
+ type WithConfig<TConfig> = unknown extends TConfig ? {
123
+ config?: Record<string, unknown>;
124
+ } : Partial<TConfig> extends TConfig ? {
125
+ config?: TConfig;
126
+ } : {
127
+ config: TConfig;
128
+ };
129
+ type SandboxSetupFields = Omit<Sandbox["setup"], "binding" | "completedAt">;
130
+ type SandboxBinding<TType extends string = string, TConfig = any, TMetadata = any> = {
131
+ type: TType;
132
+ create(opts: {
133
+ cwd: string;
134
+ agent: SandboxAgentRef;
135
+ setup: SandboxSetupFields & {
136
+ run?: (sandbox: SandboxInstance) => Promise<void>;
137
+ } & WithConfig<TConfig>;
138
+ record?: Sandbox;
139
+ signal?: AbortSignal;
140
+ log: Logger;
141
+ }): Promise<{
142
+ instance: SandboxInstance;
143
+ metadata: TMetadata;
144
+ }>;
145
+ connect(opts: {
146
+ agent: SandboxAgentRef;
147
+ metadata: TMetadata;
148
+ signal?: AbortSignal;
149
+ log: Logger;
150
+ }): Promise<SandboxInstance>;
151
+ };
152
+
153
+ type LifecycleStepResult = {
154
+ action: "continue";
155
+ nextPollMs: number;
156
+ } | {
157
+ action: "exit";
158
+ reason: "sandboxId_changed" | "idle" | "timeout" | "not_found";
159
+ };
160
+ type LifecycleConfig = {
161
+ pollIntervalMs?: number;
162
+ stopAfterInactiveMs?: number;
163
+ snapshotBeforeTimeoutMs?: number;
164
+ };
165
+ type LifecycleInput = {
166
+ agent: SandboxAgentRef;
167
+ sandboxId: string;
168
+ vercelSandboxId: string;
169
+ config?: LifecycleConfig;
170
+ };
171
+ declare function checkAndSnapshotStep(input: LifecycleInput): Promise<Error | LifecycleStepResult>;
172
+
173
+ export { type ExecResult as E, type LifecycleInput as L, type SandboxBinding as S, type UploadableFile as U, type WithConfig as W, type SandboxSetupFields as a, type SandboxInstance as b, type LoggingConfig as c, type SandboxAgentRef as d, type LifecycleConfig as e, type LifecycleStepResult as f, checkAndSnapshotStep as g };
@@ -0,0 +1,173 @@
1
+ import * as _vercel_sandbox from '@vercel/sandbox';
2
+ import { f as Storage, b as Sandbox } from './adapter-zgOel4wW.js';
3
+
4
+ type LogLevel = "info" | "warn" | "error" | "silent";
5
+ type LogContext = {
6
+ sessionId?: string;
7
+ messageId?: string;
8
+ sandboxId?: string;
9
+ [key: string]: unknown;
10
+ };
11
+ type LoggingConfig = {
12
+ level?: LogLevel;
13
+ /**
14
+ * Top-level label for all log lines.
15
+ * @default "agent"
16
+ * @example "my-app" → [my-app:default:workflow]
17
+ */
18
+ prefix?: string;
19
+ name?: string;
20
+ };
21
+ declare class Logger {
22
+ readonly subsystem: string;
23
+ private readonly config;
24
+ private readonly context;
25
+ constructor({ subsystem, config, context, }: {
26
+ subsystem: string;
27
+ config: LoggingConfig;
28
+ context?: LogContext;
29
+ });
30
+ child({ subsystem, context, }: {
31
+ subsystem?: string;
32
+ context?: LogContext;
33
+ }): Logger;
34
+ withContext(context: LogContext): Logger;
35
+ info(message: string, data?: Record<string, unknown>): void;
36
+ warn(message: string, data?: Record<string, unknown>): void;
37
+ error(message: string, data?: Record<string, unknown>): void;
38
+ /**
39
+ * Returns a function that, when called, logs the elapsed time at info level.
40
+ * Pass `logOnStart: true` to also log when the timer begins.
41
+ *
42
+ * @example
43
+ * const done = log.time("sandbox setup", { sandboxId }, { logOnStart: true });
44
+ * await setup();
45
+ * done(); // start: [agent:default:sandbox] sandbox setup { sandboxId: '...' }
46
+ * // end: [agent:default:sandbox] sandbox setup { sandboxId: '...', durationMs: 123 }
47
+ */
48
+ time(message: string, data?: Record<string, unknown>, opts?: {
49
+ logOnStart?: boolean;
50
+ }): (endData?: Record<string, unknown>) => void;
51
+ }
52
+
53
+ type ExecResult = {
54
+ commandId: string;
55
+ logs: () => AsyncIterable<{
56
+ stream: "stdout" | "stderr";
57
+ data: string;
58
+ }>;
59
+ result: Promise<{
60
+ stdout: string;
61
+ stderr: string;
62
+ exitCode: number;
63
+ }>;
64
+ };
65
+ type UploadableFile = {
66
+ path: string;
67
+ content: string | Buffer;
68
+ };
69
+ interface SandboxInstance {
70
+ readonly cwd: string;
71
+ exec(opts: {
72
+ command: string;
73
+ args?: string[];
74
+ cwd?: string;
75
+ env?: Record<string, string>;
76
+ sudo?: boolean;
77
+ signal?: AbortSignal;
78
+ }): Promise<ExecResult>;
79
+ readFile(opts: {
80
+ path: string;
81
+ signal?: AbortSignal;
82
+ }): Promise<Buffer | null>;
83
+ writeFiles(opts: {
84
+ files: UploadableFile[];
85
+ destPath: string;
86
+ signal?: AbortSignal;
87
+ }): Promise<void>;
88
+ getDomain(opts: {
89
+ port: number;
90
+ signal?: AbortSignal;
91
+ }): Promise<string>;
92
+ updateNetworkPolicy(opts: {
93
+ policy: _vercel_sandbox.NetworkPolicy;
94
+ signal?: AbortSignal;
95
+ }): Promise<_vercel_sandbox.NetworkPolicy>;
96
+ start(opts?: {
97
+ signal?: AbortSignal;
98
+ }): Promise<void>;
99
+ stop(opts?: {
100
+ signal?: AbortSignal;
101
+ }): Promise<void>;
102
+ snapshot(opts?: {
103
+ signal?: AbortSignal;
104
+ }): Promise<{
105
+ snapshotId: string;
106
+ }>;
107
+ kill(opts: {
108
+ commandId: string;
109
+ signal?: AbortSignal;
110
+ }): Promise<void>;
111
+ getStatus(opts?: {
112
+ signal?: AbortSignal;
113
+ }): Promise<"pending" | "running" | "stopping" | "stopped" | "failed">;
114
+ }
115
+ type SandboxAgentRef = {
116
+ name: string;
117
+ storage: Storage;
118
+ options: {
119
+ logging?: Omit<LoggingConfig, "name">;
120
+ };
121
+ };
122
+ type WithConfig<TConfig> = unknown extends TConfig ? {
123
+ config?: Record<string, unknown>;
124
+ } : Partial<TConfig> extends TConfig ? {
125
+ config?: TConfig;
126
+ } : {
127
+ config: TConfig;
128
+ };
129
+ type SandboxSetupFields = Omit<Sandbox["setup"], "binding" | "completedAt">;
130
+ type SandboxBinding<TType extends string = string, TConfig = any, TMetadata = any> = {
131
+ type: TType;
132
+ create(opts: {
133
+ cwd: string;
134
+ agent: SandboxAgentRef;
135
+ setup: SandboxSetupFields & {
136
+ run?: (sandbox: SandboxInstance) => Promise<void>;
137
+ } & WithConfig<TConfig>;
138
+ record?: Sandbox;
139
+ signal?: AbortSignal;
140
+ log: Logger;
141
+ }): Promise<{
142
+ instance: SandboxInstance;
143
+ metadata: TMetadata;
144
+ }>;
145
+ connect(opts: {
146
+ agent: SandboxAgentRef;
147
+ metadata: TMetadata;
148
+ signal?: AbortSignal;
149
+ log: Logger;
150
+ }): Promise<SandboxInstance>;
151
+ };
152
+
153
+ type LifecycleStepResult = {
154
+ action: "continue";
155
+ nextPollMs: number;
156
+ } | {
157
+ action: "exit";
158
+ reason: "sandboxId_changed" | "idle" | "timeout" | "not_found";
159
+ };
160
+ type LifecycleConfig = {
161
+ pollIntervalMs?: number;
162
+ stopAfterInactiveMs?: number;
163
+ snapshotBeforeTimeoutMs?: number;
164
+ };
165
+ type LifecycleInput = {
166
+ agent: SandboxAgentRef;
167
+ sandboxId: string;
168
+ vercelSandboxId: string;
169
+ config?: LifecycleConfig;
170
+ };
171
+ declare function checkAndSnapshotStep(input: LifecycleInput): Promise<Error | LifecycleStepResult>;
172
+
173
+ export { type ExecResult as E, type LifecycleInput as L, type SandboxBinding as S, type UploadableFile as U, type WithConfig as W, type SandboxSetupFields as a, type SandboxInstance as b, type LoggingConfig as c, type SandboxAgentRef as d, type LifecycleConfig as e, type LifecycleStepResult as f, checkAndSnapshotStep as g };
@@ -0,0 +1,17 @@
1
+ import { S as StorageHandlers } from './adapter-zgOel4wW.mjs';
2
+ export { G as GenerationOptions, M as Message, a as MessageUsage, P as Part, b as Sandbox, c as Session, d as Setup, e as SetupSnapshot, f as Storage, g as StorageCall, h as StorageStep, i as StorageStepFunction, t as toStorage } from './adapter-zgOel4wW.mjs';
3
+ import '@workflow/serde';
4
+ import '@vercel/sandbox';
5
+ import 'ai';
6
+
7
+ declare function kvStorageFallback(opts: {
8
+ prefix: string;
9
+ }): StorageHandlers;
10
+
11
+ declare function localStorage(opts?: {
12
+ dir?: string;
13
+ }): StorageHandlers;
14
+
15
+ declare function shouldFallbackToKV2(): boolean;
16
+
17
+ export { StorageHandlers, kvStorageFallback, localStorage, shouldFallbackToKV2 };
@@ -0,0 +1,17 @@
1
+ import { S as StorageHandlers } from './adapter-zgOel4wW.js';
2
+ export { G as GenerationOptions, M as Message, a as MessageUsage, P as Part, b as Sandbox, c as Session, d as Setup, e as SetupSnapshot, f as Storage, g as StorageCall, h as StorageStep, i as StorageStepFunction, t as toStorage } from './adapter-zgOel4wW.js';
3
+ import '@workflow/serde';
4
+ import '@vercel/sandbox';
5
+ import 'ai';
6
+
7
+ declare function kvStorageFallback(opts: {
8
+ prefix: string;
9
+ }): StorageHandlers;
10
+
11
+ declare function localStorage(opts?: {
12
+ dir?: string;
13
+ }): StorageHandlers;
14
+
15
+ declare function shouldFallbackToKV2(): boolean;
16
+
17
+ export { StorageHandlers, kvStorageFallback, localStorage, shouldFallbackToKV2 };