@hatchet-dev/sandbox 0.1.0 → 0.1.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 +30 -1
- package/README.md +57 -37
- package/dist/index.cjs +365 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +188 -0
- package/dist/index.d.ts +188 -2
- package/dist/index.js +341 -8
- package/dist/index.js.map +1 -0
- package/package.json +47 -20
- package/dist/files.d.ts +0 -93
- package/dist/files.js +0 -170
- package/dist/otel.d.ts +0 -1
- package/dist/otel.js +0 -20
- package/dist/sandbox.d.ts +0 -83
- package/dist/sandbox.js +0 -94
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { JsonObject, HatchetClient } from '@hatchet-dev/typescript-sdk/v1';
|
|
2
|
+
|
|
3
|
+
type FileType = 'file' | 'dir';
|
|
4
|
+
interface EntryInfo {
|
|
5
|
+
name: string;
|
|
6
|
+
path: string;
|
|
7
|
+
type: FileType;
|
|
8
|
+
size: number;
|
|
9
|
+
mode: number;
|
|
10
|
+
permissions: string;
|
|
11
|
+
modifiedTime?: Date;
|
|
12
|
+
}
|
|
13
|
+
type FileData = string | ArrayBuffer | Uint8Array | Blob;
|
|
14
|
+
interface WriteEntry {
|
|
15
|
+
path: string;
|
|
16
|
+
data: FileData;
|
|
17
|
+
}
|
|
18
|
+
interface ReadOpts {
|
|
19
|
+
format?: 'text' | 'bytes' | 'blob';
|
|
20
|
+
}
|
|
21
|
+
interface TransferOpts {
|
|
22
|
+
/** Give up after this long. */
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
}
|
|
25
|
+
interface ListOpts {
|
|
26
|
+
depth?: number;
|
|
27
|
+
}
|
|
28
|
+
type FilesystemErrorCode = 'staging_failed' | 'not_found' | 'invalid_path' | 'invalid_url' | 'invalid_content' | 'invalid' | 'is_a_directory' | 'not_a_directory' | 'too_large' | 'transfer_failed';
|
|
29
|
+
/** Thrown for caller mistakes such as a missing file or a path outside the workspace. */
|
|
30
|
+
declare class FilesystemError extends Error {
|
|
31
|
+
readonly code: FilesystemErrorCode;
|
|
32
|
+
constructor(code: FilesystemErrorCode, message: string);
|
|
33
|
+
}
|
|
34
|
+
type RawEntry = Omit<EntryInfo, 'modifiedTime'> & {
|
|
35
|
+
modifiedTime?: string;
|
|
36
|
+
};
|
|
37
|
+
interface FsOutput extends JsonObject {
|
|
38
|
+
content?: string;
|
|
39
|
+
stagedKey?: string;
|
|
40
|
+
url?: string;
|
|
41
|
+
putUrl?: string;
|
|
42
|
+
getUrl?: string;
|
|
43
|
+
entry?: RawEntry | null;
|
|
44
|
+
entries?: RawEntry[];
|
|
45
|
+
created?: boolean;
|
|
46
|
+
error?: {
|
|
47
|
+
code: FilesystemErrorCode;
|
|
48
|
+
message: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** @internal */
|
|
52
|
+
type FsTurn = (fn: string, input: JsonObject, fresh?: boolean) => Promise<FsOutput>;
|
|
53
|
+
/** File operations on a sandbox workspace. Paths are relative to the workspace. Each call is one Hatchet task. */
|
|
54
|
+
declare class Files {
|
|
55
|
+
private readonly turn;
|
|
56
|
+
/** @internal */
|
|
57
|
+
constructor(turn: FsTurn);
|
|
58
|
+
private call;
|
|
59
|
+
/** Reads a file as text (default), bytes, or a Blob. Files over the provider's `--max-file-bytes` (2 MiB) come through the provider's `--store` instead of Hatchet. */
|
|
60
|
+
read(path: string, opts?: ReadOpts & {
|
|
61
|
+
format?: 'text';
|
|
62
|
+
}): Promise<string>;
|
|
63
|
+
read(path: string, opts: ReadOpts & {
|
|
64
|
+
format: 'bytes';
|
|
65
|
+
}): Promise<Uint8Array>;
|
|
66
|
+
read(path: string, opts: ReadOpts & {
|
|
67
|
+
format: 'blob';
|
|
68
|
+
}): Promise<Blob>;
|
|
69
|
+
/** A replayed durable read may hold a URL that has expired; the provider signs the same staged file again. The renewal is a plain run, not a durable child, so the replayed child sequence stays aligned. */
|
|
70
|
+
private readStaged;
|
|
71
|
+
/** Writes one file or several. Parent directories are created. Bytes are stored exactly. Files over 2 MiB go through the provider's `--store` instead of Hatchet. */
|
|
72
|
+
write(path: string, data: FileData): Promise<EntryInfo>;
|
|
73
|
+
write(files: WriteEntry[]): Promise<EntryInfo[]>;
|
|
74
|
+
/** Writes several files in one task. */
|
|
75
|
+
writeFiles(files: WriteEntry[]): Promise<EntryInfo[]>;
|
|
76
|
+
/** Lists a directory. `depth` 1 (default) is the directory itself; higher values recurse. No snapshot is made. */
|
|
77
|
+
list(path?: string, opts?: ListOpts): Promise<EntryInfo[]>;
|
|
78
|
+
/** True if the path exists. No snapshot is made. */
|
|
79
|
+
exists(path: string): Promise<boolean>;
|
|
80
|
+
/** Metadata of a file or directory. Throws `FilesystemError` with code `not_found` if absent. */
|
|
81
|
+
getInfo(path: string): Promise<EntryInfo>;
|
|
82
|
+
/** Creates a directory and its parents. Returns false if it already existed. */
|
|
83
|
+
makeDir(path: string): Promise<boolean>;
|
|
84
|
+
/** Renames or moves a file or directory. */
|
|
85
|
+
rename(oldPath: string, newPath: string): Promise<EntryInfo>;
|
|
86
|
+
/** Copies a file or directory tree. */
|
|
87
|
+
copy(srcPath: string, dstPath: string): Promise<EntryInfo>;
|
|
88
|
+
/** Deletes a file or directory tree. */
|
|
89
|
+
remove(path: string): Promise<void>;
|
|
90
|
+
/** The provider fetches an https URL into the workspace. The sandbox needs no network. Private and loopback addresses are refused. */
|
|
91
|
+
download(url: string, path: string, opts?: TransferOpts): Promise<EntryInfo>;
|
|
92
|
+
/** The provider sends a workspace file to an https URL with HTTP PUT, for example a presigned URL. */
|
|
93
|
+
upload(path: string, url: string, opts?: TransferOpts): Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface Timings {
|
|
97
|
+
/** Snapshot made after this turn. Absent for turns that do not change the workspace. */
|
|
98
|
+
snapshotId?: string;
|
|
99
|
+
/** Milliseconds per phase: `claim`, `restore`, `exec`, `checkpoint`. */
|
|
100
|
+
timings?: Record<string, number>;
|
|
101
|
+
}
|
|
102
|
+
interface CommandResult extends Timings {
|
|
103
|
+
stdout: string;
|
|
104
|
+
stderr: string;
|
|
105
|
+
/** A non-zero code is a normal result, not an error. */
|
|
106
|
+
exitCode: number;
|
|
107
|
+
}
|
|
108
|
+
interface SandboxOpts {
|
|
109
|
+
/** Sandbox ID to use instead of a generated one. Lowercase letters, digits, and hyphens; must be new on the provider. */
|
|
110
|
+
id?: string;
|
|
111
|
+
/** Container image. Defaults to the provider's image. */
|
|
112
|
+
template?: string;
|
|
113
|
+
/** Snapshot to start from. Two sandboxes with the same `from` are a fork. */
|
|
114
|
+
from?: string;
|
|
115
|
+
/** Key-value tags, used to find the sandbox again with {@link SandboxNamespace.list}. */
|
|
116
|
+
metadata?: Record<string, string>;
|
|
117
|
+
/** Milliseconds without a turn before the provider removes the sandbox. Capped by the provider. */
|
|
118
|
+
idleTimeoutMs?: number;
|
|
119
|
+
/** With `from`, start from the metadata of the sandbox that made that snapshot. Pairs given in `metadata` take precedence over inherited ones. */
|
|
120
|
+
inheritParentMetadata?: boolean;
|
|
121
|
+
/** Name of the sandbox provider to create on. Required when the tenant has more than one; with `from`, it must be the provider that holds the snapshot. */
|
|
122
|
+
provider?: string;
|
|
123
|
+
}
|
|
124
|
+
interface ExecOpts {
|
|
125
|
+
/** Kill the command after this long. The result then has `exitCode` 124. */
|
|
126
|
+
timeoutMs?: number;
|
|
127
|
+
}
|
|
128
|
+
interface ConnectOpts {
|
|
129
|
+
/** Image to use if the sandbox has to be started again. Defaults to the provider's image. */
|
|
130
|
+
template?: string;
|
|
131
|
+
}
|
|
132
|
+
interface SandboxListOpts {
|
|
133
|
+
/** Only the sandbox with this ID. */
|
|
134
|
+
sandboxId?: string;
|
|
135
|
+
/** Only sandboxes whose metadata contains every one of these pairs. */
|
|
136
|
+
metadata?: Record<string, string>;
|
|
137
|
+
}
|
|
138
|
+
interface SandboxInfo {
|
|
139
|
+
sandboxId: string;
|
|
140
|
+
metadata?: Record<string, string>;
|
|
141
|
+
/** True while the sandbox is running. A sandbox that is not live is started again by `connect`. */
|
|
142
|
+
live: boolean;
|
|
143
|
+
latestSnapshot?: string;
|
|
144
|
+
createdAt: Date;
|
|
145
|
+
lastUsed?: Date;
|
|
146
|
+
}
|
|
147
|
+
/** One sandbox. Every method is one Hatchet task on the tenant's sandbox provider. */
|
|
148
|
+
declare class Sandbox {
|
|
149
|
+
private readonly run;
|
|
150
|
+
readonly sandboxId: string;
|
|
151
|
+
private readonly template?;
|
|
152
|
+
/** File operations on the workspace. */
|
|
153
|
+
readonly files: Files;
|
|
154
|
+
private constructor();
|
|
155
|
+
/** Starts a new sandbox. Prefer `hatchet.sandbox.create`. */
|
|
156
|
+
static create(client: HatchetClient, opts?: SandboxOpts): Promise<Sandbox>;
|
|
157
|
+
/** Attaches to a sandbox by ID. Prefer `hatchet.sandbox.connect`. */
|
|
158
|
+
static connect(client: HatchetClient, sandboxId: string, opts?: ConnectOpts): Promise<Sandbox>;
|
|
159
|
+
/** Lists sandboxes on the provider. Prefer `hatchet.sandbox.list`. */
|
|
160
|
+
static list(client: HatchetClient, opts?: SandboxListOpts): Promise<SandboxInfo[]>;
|
|
161
|
+
/** Deletes every sandbox matching the filter, with all their snapshots and files. Prefer `hatchet.sandbox.delete`. */
|
|
162
|
+
static delete(client: HatchetClient, opts: SandboxListOpts): Promise<string[]>;
|
|
163
|
+
/** Runs a shell command with `sh -c` in the workspace and makes a snapshot. A timeout gives `exitCode` 124, not an error. */
|
|
164
|
+
exec(cmd: string, opts?: ExecOpts): Promise<CommandResult>;
|
|
165
|
+
/** Removes the sandbox. Its snapshots stay; `connect` can bring it back. */
|
|
166
|
+
kill(): Promise<void>;
|
|
167
|
+
/** Removes the sandbox and deletes every snapshot and file the provider stored for it. `connect` fails afterwards. */
|
|
168
|
+
delete(): Promise<void>;
|
|
169
|
+
private turn;
|
|
170
|
+
}
|
|
171
|
+
/** `hatchet.sandbox`, added to `HatchetClient` by importing `@hatchet-dev/sandbox`. */
|
|
172
|
+
interface SandboxNamespace {
|
|
173
|
+
/** Starts a new sandbox. Inside a durable task this is a durable step. */
|
|
174
|
+
create(opts?: SandboxOpts): Promise<Sandbox>;
|
|
175
|
+
/** Attaches to a sandbox by ID. If it is not running, the provider starts it from its latest snapshot. */
|
|
176
|
+
connect(sandboxId: string, opts?: ConnectOpts): Promise<Sandbox>;
|
|
177
|
+
/** Lists sandboxes the provider knows, filtered by ID or metadata. */
|
|
178
|
+
list(opts?: SandboxListOpts): Promise<SandboxInfo[]>;
|
|
179
|
+
/** Deletes the sandboxes matching the filter, with every snapshot and file stored for them. Returns their IDs. */
|
|
180
|
+
delete(opts: SandboxListOpts): Promise<string[]>;
|
|
181
|
+
}
|
|
182
|
+
declare module '@hatchet-dev/typescript-sdk/v1' {
|
|
183
|
+
interface HatchetClient {
|
|
184
|
+
readonly sandbox: SandboxNamespace;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export { type CommandResult, type ConnectOpts, type EntryInfo, type ExecOpts, type FileData, type FileType, Files, FilesystemError, type FilesystemErrorCode, type ListOpts, type ReadOpts, Sandbox, type SandboxInfo, type SandboxListOpts, type SandboxNamespace, type SandboxOpts, type Timings, type TransferOpts, type WriteEntry };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,188 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { JsonObject, HatchetClient } from '@hatchet-dev/typescript-sdk/v1';
|
|
2
|
+
|
|
3
|
+
type FileType = 'file' | 'dir';
|
|
4
|
+
interface EntryInfo {
|
|
5
|
+
name: string;
|
|
6
|
+
path: string;
|
|
7
|
+
type: FileType;
|
|
8
|
+
size: number;
|
|
9
|
+
mode: number;
|
|
10
|
+
permissions: string;
|
|
11
|
+
modifiedTime?: Date;
|
|
12
|
+
}
|
|
13
|
+
type FileData = string | ArrayBuffer | Uint8Array | Blob;
|
|
14
|
+
interface WriteEntry {
|
|
15
|
+
path: string;
|
|
16
|
+
data: FileData;
|
|
17
|
+
}
|
|
18
|
+
interface ReadOpts {
|
|
19
|
+
format?: 'text' | 'bytes' | 'blob';
|
|
20
|
+
}
|
|
21
|
+
interface TransferOpts {
|
|
22
|
+
/** Give up after this long. */
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
}
|
|
25
|
+
interface ListOpts {
|
|
26
|
+
depth?: number;
|
|
27
|
+
}
|
|
28
|
+
type FilesystemErrorCode = 'staging_failed' | 'not_found' | 'invalid_path' | 'invalid_url' | 'invalid_content' | 'invalid' | 'is_a_directory' | 'not_a_directory' | 'too_large' | 'transfer_failed';
|
|
29
|
+
/** Thrown for caller mistakes such as a missing file or a path outside the workspace. */
|
|
30
|
+
declare class FilesystemError extends Error {
|
|
31
|
+
readonly code: FilesystemErrorCode;
|
|
32
|
+
constructor(code: FilesystemErrorCode, message: string);
|
|
33
|
+
}
|
|
34
|
+
type RawEntry = Omit<EntryInfo, 'modifiedTime'> & {
|
|
35
|
+
modifiedTime?: string;
|
|
36
|
+
};
|
|
37
|
+
interface FsOutput extends JsonObject {
|
|
38
|
+
content?: string;
|
|
39
|
+
stagedKey?: string;
|
|
40
|
+
url?: string;
|
|
41
|
+
putUrl?: string;
|
|
42
|
+
getUrl?: string;
|
|
43
|
+
entry?: RawEntry | null;
|
|
44
|
+
entries?: RawEntry[];
|
|
45
|
+
created?: boolean;
|
|
46
|
+
error?: {
|
|
47
|
+
code: FilesystemErrorCode;
|
|
48
|
+
message: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** @internal */
|
|
52
|
+
type FsTurn = (fn: string, input: JsonObject, fresh?: boolean) => Promise<FsOutput>;
|
|
53
|
+
/** File operations on a sandbox workspace. Paths are relative to the workspace. Each call is one Hatchet task. */
|
|
54
|
+
declare class Files {
|
|
55
|
+
private readonly turn;
|
|
56
|
+
/** @internal */
|
|
57
|
+
constructor(turn: FsTurn);
|
|
58
|
+
private call;
|
|
59
|
+
/** Reads a file as text (default), bytes, or a Blob. Files over the provider's `--max-file-bytes` (2 MiB) come through the provider's `--store` instead of Hatchet. */
|
|
60
|
+
read(path: string, opts?: ReadOpts & {
|
|
61
|
+
format?: 'text';
|
|
62
|
+
}): Promise<string>;
|
|
63
|
+
read(path: string, opts: ReadOpts & {
|
|
64
|
+
format: 'bytes';
|
|
65
|
+
}): Promise<Uint8Array>;
|
|
66
|
+
read(path: string, opts: ReadOpts & {
|
|
67
|
+
format: 'blob';
|
|
68
|
+
}): Promise<Blob>;
|
|
69
|
+
/** A replayed durable read may hold a URL that has expired; the provider signs the same staged file again. The renewal is a plain run, not a durable child, so the replayed child sequence stays aligned. */
|
|
70
|
+
private readStaged;
|
|
71
|
+
/** Writes one file or several. Parent directories are created. Bytes are stored exactly. Files over 2 MiB go through the provider's `--store` instead of Hatchet. */
|
|
72
|
+
write(path: string, data: FileData): Promise<EntryInfo>;
|
|
73
|
+
write(files: WriteEntry[]): Promise<EntryInfo[]>;
|
|
74
|
+
/** Writes several files in one task. */
|
|
75
|
+
writeFiles(files: WriteEntry[]): Promise<EntryInfo[]>;
|
|
76
|
+
/** Lists a directory. `depth` 1 (default) is the directory itself; higher values recurse. No snapshot is made. */
|
|
77
|
+
list(path?: string, opts?: ListOpts): Promise<EntryInfo[]>;
|
|
78
|
+
/** True if the path exists. No snapshot is made. */
|
|
79
|
+
exists(path: string): Promise<boolean>;
|
|
80
|
+
/** Metadata of a file or directory. Throws `FilesystemError` with code `not_found` if absent. */
|
|
81
|
+
getInfo(path: string): Promise<EntryInfo>;
|
|
82
|
+
/** Creates a directory and its parents. Returns false if it already existed. */
|
|
83
|
+
makeDir(path: string): Promise<boolean>;
|
|
84
|
+
/** Renames or moves a file or directory. */
|
|
85
|
+
rename(oldPath: string, newPath: string): Promise<EntryInfo>;
|
|
86
|
+
/** Copies a file or directory tree. */
|
|
87
|
+
copy(srcPath: string, dstPath: string): Promise<EntryInfo>;
|
|
88
|
+
/** Deletes a file or directory tree. */
|
|
89
|
+
remove(path: string): Promise<void>;
|
|
90
|
+
/** The provider fetches an https URL into the workspace. The sandbox needs no network. Private and loopback addresses are refused. */
|
|
91
|
+
download(url: string, path: string, opts?: TransferOpts): Promise<EntryInfo>;
|
|
92
|
+
/** The provider sends a workspace file to an https URL with HTTP PUT, for example a presigned URL. */
|
|
93
|
+
upload(path: string, url: string, opts?: TransferOpts): Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface Timings {
|
|
97
|
+
/** Snapshot made after this turn. Absent for turns that do not change the workspace. */
|
|
98
|
+
snapshotId?: string;
|
|
99
|
+
/** Milliseconds per phase: `claim`, `restore`, `exec`, `checkpoint`. */
|
|
100
|
+
timings?: Record<string, number>;
|
|
101
|
+
}
|
|
102
|
+
interface CommandResult extends Timings {
|
|
103
|
+
stdout: string;
|
|
104
|
+
stderr: string;
|
|
105
|
+
/** A non-zero code is a normal result, not an error. */
|
|
106
|
+
exitCode: number;
|
|
107
|
+
}
|
|
108
|
+
interface SandboxOpts {
|
|
109
|
+
/** Sandbox ID to use instead of a generated one. Lowercase letters, digits, and hyphens; must be new on the provider. */
|
|
110
|
+
id?: string;
|
|
111
|
+
/** Container image. Defaults to the provider's image. */
|
|
112
|
+
template?: string;
|
|
113
|
+
/** Snapshot to start from. Two sandboxes with the same `from` are a fork. */
|
|
114
|
+
from?: string;
|
|
115
|
+
/** Key-value tags, used to find the sandbox again with {@link SandboxNamespace.list}. */
|
|
116
|
+
metadata?: Record<string, string>;
|
|
117
|
+
/** Milliseconds without a turn before the provider removes the sandbox. Capped by the provider. */
|
|
118
|
+
idleTimeoutMs?: number;
|
|
119
|
+
/** With `from`, start from the metadata of the sandbox that made that snapshot. Pairs given in `metadata` take precedence over inherited ones. */
|
|
120
|
+
inheritParentMetadata?: boolean;
|
|
121
|
+
/** Name of the sandbox provider to create on. Required when the tenant has more than one; with `from`, it must be the provider that holds the snapshot. */
|
|
122
|
+
provider?: string;
|
|
123
|
+
}
|
|
124
|
+
interface ExecOpts {
|
|
125
|
+
/** Kill the command after this long. The result then has `exitCode` 124. */
|
|
126
|
+
timeoutMs?: number;
|
|
127
|
+
}
|
|
128
|
+
interface ConnectOpts {
|
|
129
|
+
/** Image to use if the sandbox has to be started again. Defaults to the provider's image. */
|
|
130
|
+
template?: string;
|
|
131
|
+
}
|
|
132
|
+
interface SandboxListOpts {
|
|
133
|
+
/** Only the sandbox with this ID. */
|
|
134
|
+
sandboxId?: string;
|
|
135
|
+
/** Only sandboxes whose metadata contains every one of these pairs. */
|
|
136
|
+
metadata?: Record<string, string>;
|
|
137
|
+
}
|
|
138
|
+
interface SandboxInfo {
|
|
139
|
+
sandboxId: string;
|
|
140
|
+
metadata?: Record<string, string>;
|
|
141
|
+
/** True while the sandbox is running. A sandbox that is not live is started again by `connect`. */
|
|
142
|
+
live: boolean;
|
|
143
|
+
latestSnapshot?: string;
|
|
144
|
+
createdAt: Date;
|
|
145
|
+
lastUsed?: Date;
|
|
146
|
+
}
|
|
147
|
+
/** One sandbox. Every method is one Hatchet task on the tenant's sandbox provider. */
|
|
148
|
+
declare class Sandbox {
|
|
149
|
+
private readonly run;
|
|
150
|
+
readonly sandboxId: string;
|
|
151
|
+
private readonly template?;
|
|
152
|
+
/** File operations on the workspace. */
|
|
153
|
+
readonly files: Files;
|
|
154
|
+
private constructor();
|
|
155
|
+
/** Starts a new sandbox. Prefer `hatchet.sandbox.create`. */
|
|
156
|
+
static create(client: HatchetClient, opts?: SandboxOpts): Promise<Sandbox>;
|
|
157
|
+
/** Attaches to a sandbox by ID. Prefer `hatchet.sandbox.connect`. */
|
|
158
|
+
static connect(client: HatchetClient, sandboxId: string, opts?: ConnectOpts): Promise<Sandbox>;
|
|
159
|
+
/** Lists sandboxes on the provider. Prefer `hatchet.sandbox.list`. */
|
|
160
|
+
static list(client: HatchetClient, opts?: SandboxListOpts): Promise<SandboxInfo[]>;
|
|
161
|
+
/** Deletes every sandbox matching the filter, with all their snapshots and files. Prefer `hatchet.sandbox.delete`. */
|
|
162
|
+
static delete(client: HatchetClient, opts: SandboxListOpts): Promise<string[]>;
|
|
163
|
+
/** Runs a shell command with `sh -c` in the workspace and makes a snapshot. A timeout gives `exitCode` 124, not an error. */
|
|
164
|
+
exec(cmd: string, opts?: ExecOpts): Promise<CommandResult>;
|
|
165
|
+
/** Removes the sandbox. Its snapshots stay; `connect` can bring it back. */
|
|
166
|
+
kill(): Promise<void>;
|
|
167
|
+
/** Removes the sandbox and deletes every snapshot and file the provider stored for it. `connect` fails afterwards. */
|
|
168
|
+
delete(): Promise<void>;
|
|
169
|
+
private turn;
|
|
170
|
+
}
|
|
171
|
+
/** `hatchet.sandbox`, added to `HatchetClient` by importing `@hatchet-dev/sandbox`. */
|
|
172
|
+
interface SandboxNamespace {
|
|
173
|
+
/** Starts a new sandbox. Inside a durable task this is a durable step. */
|
|
174
|
+
create(opts?: SandboxOpts): Promise<Sandbox>;
|
|
175
|
+
/** Attaches to a sandbox by ID. If it is not running, the provider starts it from its latest snapshot. */
|
|
176
|
+
connect(sandboxId: string, opts?: ConnectOpts): Promise<Sandbox>;
|
|
177
|
+
/** Lists sandboxes the provider knows, filtered by ID or metadata. */
|
|
178
|
+
list(opts?: SandboxListOpts): Promise<SandboxInfo[]>;
|
|
179
|
+
/** Deletes the sandboxes matching the filter, with every snapshot and file stored for them. Returns their IDs. */
|
|
180
|
+
delete(opts: SandboxListOpts): Promise<string[]>;
|
|
181
|
+
}
|
|
182
|
+
declare module '@hatchet-dev/typescript-sdk/v1' {
|
|
183
|
+
interface HatchetClient {
|
|
184
|
+
readonly sandbox: SandboxNamespace;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export { type CommandResult, type ConnectOpts, type EntryInfo, type ExecOpts, type FileData, type FileType, Files, FilesystemError, type FilesystemErrorCode, type ListOpts, type ReadOpts, Sandbox, type SandboxInfo, type SandboxListOpts, type SandboxNamespace, type SandboxOpts, type Timings, type TransferOpts, type WriteEntry };
|