eve 0.12.0 → 0.12.2
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/CHANGELOG.md +15 -0
- package/dist/src/chunks/{use-eve-agent-D9ZhQhyV.js → use-eve-agent-DEm_Jg4k.js} +18 -4
- package/dist/src/chunks/{use-eve-agent-DFI0POM9.js → use-eve-agent-DsXOQMFZ.js} +18 -4
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/dev/tui/command-typeahead.d.ts +1 -1
- package/dist/src/cli/dev/tui/command-typeahead.js +1 -1
- package/dist/src/cli/dev/tui/prompt-command-handler.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +6 -2
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/setup-commands.d.ts +6 -2
- package/dist/src/cli/dev/tui/setup-commands.js +2 -2
- package/dist/src/cli/dev/tui/setup-issues.d.ts +16 -2
- package/dist/src/cli/dev/tui/setup-issues.js +1 -1
- package/dist/src/cli/dev/tui/setup-panel.js +2 -2
- package/dist/src/cli/dev/tui/target.d.ts +21 -0
- package/dist/src/cli/dev/tui/target.js +1 -0
- package/dist/src/cli/dev/tui/terminal-renderer.js +3 -3
- package/dist/src/cli/dev/tui/test/fake-setup-flow-renderer.d.ts +2 -0
- package/dist/src/cli/dev/tui/test/fake-setup-flow-renderer.js +1 -0
- package/dist/src/cli/dev/tui/theme.d.ts +3 -1
- package/dist/src/cli/dev/tui/theme.js +1 -1
- package/dist/src/cli/dev/tui/tui.d.ts +4 -14
- package/dist/src/cli/dev/tui/tui.js +1 -1
- package/dist/src/cli/dev/url.js +1 -1
- package/dist/src/cli/run.d.ts +0 -12
- package/dist/src/cli/run.js +2 -2
- package/dist/src/client/client.js +1 -1
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/client/open-stream.d.ts +2 -0
- package/dist/src/client/open-stream.js +1 -1
- package/dist/src/client/session.d.ts +2 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/client/types.d.ts +9 -0
- package/dist/src/compiled/.vendor-stamp.json +1 -1
- package/dist/src/compiled/@vercel/sandbox/_async-retry.d.ts +8 -0
- package/dist/src/compiled/@vercel/sandbox/_workflow-serde.d.ts +5 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/api-client.d.ts +1442 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/api-error.d.ts +29 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/base-client.d.ts +39 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/file-writer.d.ts +66 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/index.d.ts +2 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/validators.d.ts +878 -0
- package/dist/src/compiled/@vercel/sandbox/api-client/with-retry.d.ts +10 -0
- package/dist/src/compiled/@vercel/sandbox/auth/error.d.ts +15 -0
- package/dist/src/compiled/@vercel/sandbox/auth/file.d.ts +18 -0
- package/dist/src/compiled/@vercel/sandbox/auth/index.d.ts +6 -0
- package/dist/src/compiled/@vercel/sandbox/auth/oauth.d.ts +111 -0
- package/dist/src/compiled/@vercel/sandbox/auth/poll-for-token.d.ts +28 -0
- package/dist/src/compiled/@vercel/sandbox/auth/project.d.ts +40 -0
- package/dist/src/compiled/@vercel/sandbox/command.d.ts +290 -0
- package/dist/src/compiled/@vercel/sandbox/constants.d.ts +5 -0
- package/dist/src/compiled/@vercel/sandbox/filesystem.d.ts +258 -0
- package/dist/src/compiled/@vercel/sandbox/index.d.ts +10 -129
- package/dist/src/compiled/@vercel/sandbox/proxy.d.ts +55 -0
- package/dist/src/compiled/@vercel/sandbox/sandbox.d.ts +1058 -0
- package/dist/src/compiled/@vercel/sandbox/session.d.ts +432 -0
- package/dist/src/compiled/@vercel/sandbox/snapshot.d.ts +229 -0
- package/dist/src/compiled/@vercel/sandbox/utils/get-credentials.d.ts +21 -0
- package/dist/src/compiled/@vercel/sandbox/utils/paginator.d.ts +16 -0
- package/dist/src/compiled/@vercel/sandbox/utils/resolveSignal.d.ts +15 -0
- package/dist/src/compiled/@vercel/sandbox/utils/sandbox-snapshot.d.ts +11 -0
- package/dist/src/compiled/@vercel/sandbox/utils/types.d.ts +11 -0
- package/dist/src/compiled/chat/_workflow-serde.d.ts +3 -0
- package/dist/src/compiled/chat/index.d.ts +1 -1
- package/dist/src/evals/cli/eval-client.d.ts +12 -16
- package/dist/src/evals/cli/eval-client.js +1 -1
- package/dist/src/evals/cli/eval.js +1 -1
- package/dist/src/execution/sandbox/bindings/vercel-base-runtime.d.ts +3 -3
- package/dist/src/execution/sandbox/bindings/vercel-create-sdk.d.ts +8 -13
- package/dist/src/execution/sandbox/bindings/vercel-credentials.d.ts +3 -3
- package/dist/src/execution/sandbox/bindings/vercel-lookup.d.ts +4 -5
- package/dist/src/execution/sandbox/bindings/vercel-read-stream.d.ts +5 -0
- package/dist/src/execution/sandbox/bindings/vercel-read-stream.js +1 -0
- package/dist/src/execution/sandbox/bindings/vercel-sdk-types.d.ts +6 -0
- package/dist/src/execution/sandbox/bindings/vercel-sdk-types.js +1 -0
- package/dist/src/execution/sandbox/bindings/vercel.d.ts +4 -4
- package/dist/src/execution/sandbox/bindings/vercel.js +1 -1
- package/dist/src/harness/compaction.d.ts +2 -3
- package/dist/src/harness/compaction.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/start-development-server.js +2 -2
- package/dist/src/public/sandbox/vercel-sandbox.d.ts +12 -9
- package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
- package/dist/src/services/dev-client/client-options.d.ts +9 -4
- package/dist/src/services/dev-client/client-options.js +1 -1
- package/dist/src/services/dev-client/credential-gate.d.ts +19 -0
- package/dist/src/services/dev-client/credential-gate.js +1 -0
- package/dist/src/services/dev-client/local-host.d.ts +4 -0
- package/dist/src/services/dev-client/local-host.js +1 -0
- package/dist/src/services/dev-client/request-headers.d.ts +38 -56
- package/dist/src/services/dev-client/request-headers.js +1 -1
- package/dist/src/services/dev-client/runtime-artifacts.js +1 -1
- package/dist/src/services/dev-client/vercel-auth-error.d.ts +2 -0
- package/dist/src/services/dev-client/vercel-auth-error.js +2 -2
- package/dist/src/services/dev-client.js +1 -1
- package/dist/src/setup/cli/option-row.d.ts +11 -5
- package/dist/src/setup/cli/option-row.js +1 -1
- package/dist/src/setup/cli/prompt-ui.d.ts +6 -6
- package/dist/src/setup/cli/prompt-ui.js +2 -2
- package/dist/src/setup/flows/model.d.ts +2 -0
- package/dist/src/setup/flows/model.js +1 -1
- package/dist/src/setup/project-resolution.d.ts +13 -0
- package/dist/src/setup/project-resolution.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/index.d.ts +1 -1
- package/dist/src/setup/scaffold/index.js +1 -1
- package/dist/src/setup/scaffold/update/channels.d.ts +8 -1
- package/dist/src/setup/scaffold/update/channels.js +2 -2
- package/dist/src/setup/vercel-deployment.d.ts +53 -0
- package/dist/src/setup/vercel-deployment.js +1 -0
- package/dist/src/setup/vercel-project.js +1 -1
- package/dist/src/setup/verified-remote-client.d.ts +23 -0
- package/dist/src/setup/verified-remote-client.js +1 -0
- package/dist/src/shared/sandbox-network-policy.d.ts +2 -2
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/evals/targets.mdx +7 -5
- package/docs/guides/client/overview.mdx +3 -0
- package/docs/guides/dev-tui.md +5 -5
- package/package.json +1 -1
- package/dist/src/harness/tool-result-pruning.d.ts +0 -8
- package/dist/src/harness/tool-result-pruning.js +0 -1
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { Dirent, Stats } from "fs";
|
|
2
|
+
|
|
3
|
+
//#region src/filesystem.d.ts
|
|
4
|
+
type WriteFileData = string | Buffer | Uint8Array;
|
|
5
|
+
interface MkdirOptions {
|
|
6
|
+
recursive?: boolean;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
interface RmOptions {
|
|
10
|
+
recursive?: boolean;
|
|
11
|
+
force?: boolean;
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
}
|
|
14
|
+
interface SandboxHandle {
|
|
15
|
+
readFileToBuffer(file: {
|
|
16
|
+
path: string;
|
|
17
|
+
}, opts?: {
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
}): Promise<Buffer | null>;
|
|
20
|
+
writeFiles(files: {
|
|
21
|
+
path: string;
|
|
22
|
+
content: Buffer;
|
|
23
|
+
}[], opts?: {
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
mkDir(path: string, opts?: {
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
runCommand(cmd: string, args?: string[], opts?: {
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
exitCode: number;
|
|
33
|
+
stdout(opts?: {
|
|
34
|
+
signal?: AbortSignal;
|
|
35
|
+
}): Promise<string>;
|
|
36
|
+
stderr(opts?: {
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
}): Promise<string>;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
declare class FileSystem {
|
|
42
|
+
/** @internal */
|
|
43
|
+
private sandbox;
|
|
44
|
+
/** @internal */
|
|
45
|
+
constructor(sandbox: SandboxHandle);
|
|
46
|
+
/**
|
|
47
|
+
* Read the entire contents of a file.
|
|
48
|
+
*
|
|
49
|
+
* @param path - Path to the file
|
|
50
|
+
* @param options - Encoding or options object. If encoding is specified, returns a string; otherwise returns a Buffer.
|
|
51
|
+
*/
|
|
52
|
+
readFile(path: string, options?: {
|
|
53
|
+
encoding?: null;
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
} | null): Promise<Buffer>;
|
|
56
|
+
readFile(path: string, options: {
|
|
57
|
+
encoding: BufferEncoding;
|
|
58
|
+
signal?: AbortSignal;
|
|
59
|
+
} | BufferEncoding): Promise<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Write data to a file, replacing the file if it already exists.
|
|
62
|
+
*
|
|
63
|
+
* @param path - Path to the file
|
|
64
|
+
* @param data - The data to write
|
|
65
|
+
* @param options - Write options
|
|
66
|
+
*/
|
|
67
|
+
writeFile(path: string, data: WriteFileData, options?: {
|
|
68
|
+
encoding?: BufferEncoding;
|
|
69
|
+
signal?: AbortSignal;
|
|
70
|
+
} | BufferEncoding): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Append data to a file, creating the file if it does not yet exist.
|
|
73
|
+
*
|
|
74
|
+
* @param path - Path to the file
|
|
75
|
+
* @param data - The data to append
|
|
76
|
+
* @param options - Write options
|
|
77
|
+
*/
|
|
78
|
+
appendFile(path: string, data: WriteFileData, options?: {
|
|
79
|
+
encoding?: BufferEncoding;
|
|
80
|
+
signal?: AbortSignal;
|
|
81
|
+
} | BufferEncoding): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Create a directory.
|
|
84
|
+
*
|
|
85
|
+
* @param path - Path of the directory to create
|
|
86
|
+
* @param options - Options for directory creation
|
|
87
|
+
*/
|
|
88
|
+
mkdir(path: string, options?: MkdirOptions | number): Promise<string | undefined>;
|
|
89
|
+
/**
|
|
90
|
+
* Read the contents of a directory.
|
|
91
|
+
*
|
|
92
|
+
* @param path - Path to the directory
|
|
93
|
+
* @param options - Options. When `withFileTypes` is true, returns `Dirent` objects.
|
|
94
|
+
*/
|
|
95
|
+
readdir(path: string, options?: {
|
|
96
|
+
signal?: AbortSignal;
|
|
97
|
+
withFileTypes?: false;
|
|
98
|
+
}): Promise<string[]>;
|
|
99
|
+
readdir(path: string, options: {
|
|
100
|
+
signal?: AbortSignal;
|
|
101
|
+
withFileTypes: true;
|
|
102
|
+
}): Promise<Dirent[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Get file status. Follows symbolic links.
|
|
105
|
+
*
|
|
106
|
+
* @param path - Path to the file
|
|
107
|
+
* @param options - Options
|
|
108
|
+
*/
|
|
109
|
+
stat(path: string, options?: {
|
|
110
|
+
signal?: AbortSignal;
|
|
111
|
+
}): Promise<Stats>;
|
|
112
|
+
/**
|
|
113
|
+
* Get file status. Does not follow symbolic links.
|
|
114
|
+
*
|
|
115
|
+
* @param path - Path to the file
|
|
116
|
+
* @param options - Options
|
|
117
|
+
*/
|
|
118
|
+
lstat(path: string, options?: {
|
|
119
|
+
signal?: AbortSignal;
|
|
120
|
+
}): Promise<Stats>;
|
|
121
|
+
/**
|
|
122
|
+
* Remove a file or symbolic link.
|
|
123
|
+
*
|
|
124
|
+
* @param path - Path to the file
|
|
125
|
+
* @param options - Options
|
|
126
|
+
*/
|
|
127
|
+
unlink(path: string, options?: {
|
|
128
|
+
signal?: AbortSignal;
|
|
129
|
+
}): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Remove files and directories.
|
|
132
|
+
*
|
|
133
|
+
* @param path - Path to remove
|
|
134
|
+
* @param options - Options
|
|
135
|
+
*/
|
|
136
|
+
rm(path: string, options?: RmOptions): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Remove a directory.
|
|
139
|
+
*
|
|
140
|
+
* @param path - Path to the directory
|
|
141
|
+
* @param options - Options
|
|
142
|
+
*/
|
|
143
|
+
rmdir(path: string, options?: {
|
|
144
|
+
signal?: AbortSignal;
|
|
145
|
+
}): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Rename a file or directory.
|
|
148
|
+
*
|
|
149
|
+
* @param oldPath - Current path
|
|
150
|
+
* @param newPath - New path
|
|
151
|
+
* @param options - Options
|
|
152
|
+
*/
|
|
153
|
+
rename(oldPath: string, newPath: string, options?: {
|
|
154
|
+
signal?: AbortSignal;
|
|
155
|
+
}): Promise<void>;
|
|
156
|
+
/**
|
|
157
|
+
* Copy a file.
|
|
158
|
+
*
|
|
159
|
+
* @param src - Source path
|
|
160
|
+
* @param dest - Destination path
|
|
161
|
+
* @param options - Options
|
|
162
|
+
*/
|
|
163
|
+
copyFile(src: string, dest: string, options?: {
|
|
164
|
+
signal?: AbortSignal;
|
|
165
|
+
}): Promise<void>;
|
|
166
|
+
/**
|
|
167
|
+
* Test whether a file exists and the user has the specified permissions.
|
|
168
|
+
*
|
|
169
|
+
* @param path - Path to the file
|
|
170
|
+
* @param options - Options
|
|
171
|
+
*/
|
|
172
|
+
access(path: string, options?: {
|
|
173
|
+
signal?: AbortSignal;
|
|
174
|
+
}): Promise<void>;
|
|
175
|
+
/**
|
|
176
|
+
* Check if a path exists.
|
|
177
|
+
*
|
|
178
|
+
* This is a convenience method not in `node:fs/promises` but commonly needed.
|
|
179
|
+
*
|
|
180
|
+
* @param path - Path to check
|
|
181
|
+
* @param options - Options
|
|
182
|
+
*/
|
|
183
|
+
exists(path: string, options?: {
|
|
184
|
+
signal?: AbortSignal;
|
|
185
|
+
}): Promise<boolean>;
|
|
186
|
+
/**
|
|
187
|
+
* Change file mode (permissions).
|
|
188
|
+
*
|
|
189
|
+
* @param path - Path to the file
|
|
190
|
+
* @param mode - File mode (e.g., 0o755 or "755")
|
|
191
|
+
* @param options - Options
|
|
192
|
+
*/
|
|
193
|
+
chmod(path: string, mode: number | string, options?: {
|
|
194
|
+
signal?: AbortSignal;
|
|
195
|
+
}): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Change file owner and group.
|
|
198
|
+
*
|
|
199
|
+
* @param path - Path to the file
|
|
200
|
+
* @param uid - User ID
|
|
201
|
+
* @param gid - Group ID
|
|
202
|
+
* @param options - Options
|
|
203
|
+
*/
|
|
204
|
+
chown(path: string, uid: number, gid: number, options?: {
|
|
205
|
+
signal?: AbortSignal;
|
|
206
|
+
}): Promise<void>;
|
|
207
|
+
/**
|
|
208
|
+
* Create a symbolic link.
|
|
209
|
+
*
|
|
210
|
+
* @param target - The target of the symbolic link
|
|
211
|
+
* @param path - The path of the symbolic link to create
|
|
212
|
+
* @param options - Options
|
|
213
|
+
*/
|
|
214
|
+
symlink(target: string, path: string, options?: {
|
|
215
|
+
signal?: AbortSignal;
|
|
216
|
+
}): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* Read the value of a symbolic link.
|
|
219
|
+
*
|
|
220
|
+
* @param path - Path to the symbolic link
|
|
221
|
+
* @param options - Options
|
|
222
|
+
*/
|
|
223
|
+
readlink(path: string, options?: {
|
|
224
|
+
signal?: AbortSignal;
|
|
225
|
+
}): Promise<string>;
|
|
226
|
+
/**
|
|
227
|
+
* Resolve the real path of a file (resolving symlinks).
|
|
228
|
+
*
|
|
229
|
+
* @param path - Path to resolve
|
|
230
|
+
* @param options - Options
|
|
231
|
+
*/
|
|
232
|
+
realpath(path: string, options?: {
|
|
233
|
+
signal?: AbortSignal;
|
|
234
|
+
}): Promise<string>;
|
|
235
|
+
/**
|
|
236
|
+
* Truncate a file to a specified length.
|
|
237
|
+
*
|
|
238
|
+
* @param path - Path to the file
|
|
239
|
+
* @param len - Length to truncate to (default: 0)
|
|
240
|
+
* @param options - Options
|
|
241
|
+
*/
|
|
242
|
+
truncate(path: string, len?: number, options?: {
|
|
243
|
+
signal?: AbortSignal;
|
|
244
|
+
}): Promise<void>;
|
|
245
|
+
/**
|
|
246
|
+
* Create a unique temporary directory.
|
|
247
|
+
*
|
|
248
|
+
* @param prefix - The prefix for the temporary directory name
|
|
249
|
+
* @param options - Options
|
|
250
|
+
* @returns The path of the created temporary directory
|
|
251
|
+
*/
|
|
252
|
+
mkdtemp(prefix: string, options?: {
|
|
253
|
+
signal?: AbortSignal;
|
|
254
|
+
}): Promise<string>;
|
|
255
|
+
}
|
|
256
|
+
//#endregion
|
|
257
|
+
export { FileSystem };
|
|
258
|
+
//# sourceMappingURL=filesystem.d.ts.map
|
|
@@ -1,129 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
NetworkPolicyRule,
|
|
12
|
-
NetworkTransformer,
|
|
13
|
-
} from "./network-policy.js";
|
|
14
|
-
|
|
15
|
-
export interface SandboxKeepLastSnapshotsConfig {
|
|
16
|
-
count: number;
|
|
17
|
-
expiration?: number | undefined;
|
|
18
|
-
deleteEvicted?: boolean | undefined;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface SandboxUpdateParams {
|
|
22
|
-
currentSnapshotId?: string | undefined;
|
|
23
|
-
keepLastSnapshots?: SandboxKeepLastSnapshotsConfig | null | undefined;
|
|
24
|
-
networkPolicy?: NetworkPolicy | undefined;
|
|
25
|
-
persistent?: boolean | undefined;
|
|
26
|
-
ports?: number[] | undefined;
|
|
27
|
-
resources?: { vcpus?: number | undefined } | undefined;
|
|
28
|
-
snapshotExpiration?: number | undefined;
|
|
29
|
-
tags?: Record<string, string> | undefined;
|
|
30
|
-
timeout?: number | undefined;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface SandboxCreateOptions {
|
|
34
|
-
[key: `__${string}`]: unknown;
|
|
35
|
-
env?: Record<string, string> | undefined;
|
|
36
|
-
name?: string | undefined;
|
|
37
|
-
networkPolicy?: NetworkPolicy | undefined;
|
|
38
|
-
onResume?: ((sandbox: Sandbox) => Promise<void>) | undefined;
|
|
39
|
-
persistent?: boolean | undefined;
|
|
40
|
-
ports?: number[] | undefined;
|
|
41
|
-
resources?: { vcpus?: number | undefined } | undefined;
|
|
42
|
-
runtime?: string | undefined;
|
|
43
|
-
signal?: AbortSignal | undefined;
|
|
44
|
-
snapshotExpiration?: number | undefined;
|
|
45
|
-
source?: unknown;
|
|
46
|
-
tags?: Record<string, string> | undefined;
|
|
47
|
-
timeout?: number | undefined;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface SandboxGetOptions {
|
|
51
|
-
name: string;
|
|
52
|
-
onResume?: ((sandbox: Sandbox) => Promise<void>) | undefined;
|
|
53
|
-
resume?: boolean | undefined;
|
|
54
|
-
signal?: AbortSignal | undefined;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface SandboxRunCommandParams {
|
|
58
|
-
args?: readonly string[] | undefined;
|
|
59
|
-
cmd: string;
|
|
60
|
-
cwd?: string | undefined;
|
|
61
|
-
detached?: boolean | undefined;
|
|
62
|
-
env?: Record<string, string> | undefined;
|
|
63
|
-
signal?: AbortSignal | undefined;
|
|
64
|
-
sudo?: boolean | undefined;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface SandboxRmOptions {
|
|
68
|
-
force?: boolean | undefined;
|
|
69
|
-
recursive?: boolean | undefined;
|
|
70
|
-
signal?: AbortSignal | undefined;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export declare class FileSystem {
|
|
74
|
-
rm(path: string, options?: SandboxRmOptions): Promise<void>;
|
|
75
|
-
unlink(path: string, options?: { signal?: AbortSignal | undefined }): Promise<void>;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface SandboxCommandLogMessage {
|
|
79
|
-
data: string;
|
|
80
|
-
stream: "stdout" | "stderr";
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export declare class SandboxCommand {
|
|
84
|
-
readonly cmdId: string;
|
|
85
|
-
readonly cwd: string;
|
|
86
|
-
exitCode: number | null;
|
|
87
|
-
logs(opts?: {
|
|
88
|
-
signal?: AbortSignal | undefined;
|
|
89
|
-
}): AsyncGenerator<SandboxCommandLogMessage, void, void>;
|
|
90
|
-
wait(opts?: { signal?: AbortSignal | undefined }): Promise<SandboxCommandFinished>;
|
|
91
|
-
stdout(opts?: { signal?: AbortSignal | undefined }): Promise<string>;
|
|
92
|
-
stderr(opts?: { signal?: AbortSignal | undefined }): Promise<string>;
|
|
93
|
-
kill(signal?: string, opts?: { abortSignal?: AbortSignal | undefined }): Promise<void>;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface SandboxCommandFinished extends SandboxCommand {
|
|
97
|
-
exitCode: number;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export type SandboxCommandResult = SandboxCommandFinished;
|
|
101
|
-
|
|
102
|
-
export declare class Sandbox {
|
|
103
|
-
currentSnapshotId?: string | undefined;
|
|
104
|
-
readonly fs: FileSystem;
|
|
105
|
-
id: string;
|
|
106
|
-
name: string;
|
|
107
|
-
networkPolicy?: NetworkPolicy | undefined;
|
|
108
|
-
persistent: boolean;
|
|
109
|
-
status: string;
|
|
110
|
-
tags?: Record<string, string> | undefined;
|
|
111
|
-
static create(options?: SandboxCreateOptions): Promise<Sandbox>;
|
|
112
|
-
static get(options: SandboxGetOptions): Promise<Sandbox>;
|
|
113
|
-
domain(port: number): string;
|
|
114
|
-
readFile(file: { path: string }): Promise<ReadableStream<Uint8Array> | null>;
|
|
115
|
-
readFileToBuffer(file: { path: string }): Promise<Buffer | null>;
|
|
116
|
-
runCommand(input: SandboxRunCommandParams & { detached: true }): Promise<SandboxCommand>;
|
|
117
|
-
runCommand(input: SandboxRunCommandParams): Promise<SandboxCommandFinished>;
|
|
118
|
-
snapshot(options?: unknown): Promise<{ snapshotId: string }>;
|
|
119
|
-
stop(options?: unknown): Promise<void>;
|
|
120
|
-
update(
|
|
121
|
-
params: SandboxUpdateParams,
|
|
122
|
-
opts?: { signal?: AbortSignal | undefined } | undefined,
|
|
123
|
-
): Promise<void>;
|
|
124
|
-
writeFiles(
|
|
125
|
-
files: readonly { content: string | Uint8Array; path: string }[],
|
|
126
|
-
options?: unknown,
|
|
127
|
-
): Promise<void>;
|
|
128
|
-
[key: string]: any;
|
|
129
|
-
}
|
|
1
|
+
import { APIError, StreamError } from "./api-client/api-error.js";
|
|
2
|
+
import { SnapshotTreeNodeData } from "./api-client/validators.js";
|
|
3
|
+
import { NetworkPolicy, NetworkPolicyKeyValueMatcher, NetworkPolicyMatch, NetworkPolicyMatcher, NetworkPolicyRule, NetworkTransformer } from "./network-policy.js";
|
|
4
|
+
import { Command, CommandFinished, CommandOutput, SerializedCommand, SerializedCommandFinished } from "./command.js";
|
|
5
|
+
import { SerializedSnapshot, Snapshot } from "./snapshot.js";
|
|
6
|
+
import { Session } from "./session.js";
|
|
7
|
+
import { FileSystem } from "./filesystem.js";
|
|
8
|
+
import { Sandbox, SerializedSandbox } from "./sandbox.js";
|
|
9
|
+
import { InvalidRequestProxyHandler, ProxyHandler, ProxyMeta, defineSandboxProxy } from "./proxy.js";
|
|
10
|
+
export { APIError, Command, CommandFinished, type CommandOutput, FileSystem, type InvalidRequestProxyHandler, type NetworkPolicy, type NetworkPolicyKeyValueMatcher, type NetworkPolicyMatch, type NetworkPolicyMatcher, type NetworkPolicyRule, type NetworkTransformer, type ProxyHandler, type ProxyMeta, Sandbox, type SerializedCommand, type SerializedCommandFinished, type SerializedSandbox, type SerializedSnapshot, Session, Snapshot, type SnapshotTreeNodeData, StreamError, defineSandboxProxy };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//#region src/proxy.d.ts
|
|
2
|
+
interface ProxyMeta {
|
|
3
|
+
/**
|
|
4
|
+
* The host of the request as received by this proxy.
|
|
5
|
+
*/
|
|
6
|
+
host: string;
|
|
7
|
+
/**
|
|
8
|
+
* The ID of the team that owns the sandbox that proxied the request.
|
|
9
|
+
*/
|
|
10
|
+
teamId: string;
|
|
11
|
+
/**
|
|
12
|
+
* The ID of the project that owns the sandbox that proxied the request.
|
|
13
|
+
*/
|
|
14
|
+
projectId: string;
|
|
15
|
+
/**
|
|
16
|
+
* The ID of the sandbox that proxied the request.
|
|
17
|
+
*/
|
|
18
|
+
sandboxId: string;
|
|
19
|
+
/**
|
|
20
|
+
* The name of the sandbox that proxied the request, when using persistent sandboxes.
|
|
21
|
+
*/
|
|
22
|
+
sandboxName: string;
|
|
23
|
+
}
|
|
24
|
+
type ProxyHandler = (request: Request, meta: ProxyMeta) => Response | Promise<Response>;
|
|
25
|
+
type InvalidRequestProxyHandler = (request: Request, error: Error) => Response | Promise<Response>;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a Web Handler for proxied requests from Vercel Sandboxes using the network policy `forwardURL`
|
|
28
|
+
* option. The provided `handler` is called for each valid proxied request, with the original request
|
|
29
|
+
* alongside extracted metadata used to identify the source sandbox and request details.
|
|
30
|
+
*
|
|
31
|
+
* This function automatically verifies the OIDC token included in proxied requests to ensure the request
|
|
32
|
+
* is legitimate: if invalid, the `invalidRequestHandler` is called (by default, a 403 response is returned).
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* export default {
|
|
37
|
+
* fetch: defineSandboxProxy(async (request, meta) => {
|
|
38
|
+
* // meta contains the original host & source team/project/sandbox ids
|
|
39
|
+
* console.log(meta)
|
|
40
|
+
*
|
|
41
|
+
* // return a custom response, or proxy upstream:
|
|
42
|
+
* return await fetch(request)
|
|
43
|
+
* }, (request, error) => {
|
|
44
|
+
* // optional, handle any authorization error
|
|
45
|
+
* return new Response("Forbidden", { status: 403 })
|
|
46
|
+
* })
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @see https://vercel.com/docs/vercel-sandbox/concepts/firewall#requests-proxying
|
|
51
|
+
*/
|
|
52
|
+
declare function defineSandboxProxy(handler: ProxyHandler, invalidRequestHandler?: InvalidRequestProxyHandler): (request: Request) => Promise<Response>;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { InvalidRequestProxyHandler, ProxyHandler, ProxyMeta, defineSandboxProxy };
|
|
55
|
+
//# sourceMappingURL=proxy.d.ts.map
|