@tensorlakeai/tensorlake 0.0.0-bootstrap.0 → 0.5.145
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/README.md +166 -2
- package/bin/function-executor.js +8 -0
- package/bin/tensorlake-create-sandbox-image.js +9 -0
- package/bin/tensorlake-deploy.cjs +8 -0
- package/bin/tensorlake-import-sandbox-image.js +9 -0
- package/bin/tensorlake-typescript-function-runner.js +8 -0
- package/dist/applications/index.cjs +4821 -0
- package/dist/applications/index.cjs.map +1 -0
- package/dist/applications/index.d.cts +130 -0
- package/dist/applications/index.d.ts +130 -0
- package/dist/applications/index.js +4782 -0
- package/dist/applications/index.js.map +1 -0
- package/dist/function-agent/main.cjs +1838 -0
- package/dist/function-agent/main.cjs.map +1 -0
- package/dist/function-agent/main.d.cts +3 -0
- package/dist/function-agent/main.d.ts +3 -0
- package/dist/function-agent/main.js +1825 -0
- package/dist/function-agent/main.js.map +1 -0
- package/dist/function-executor/main.cjs +4944 -0
- package/dist/function-executor/main.cjs.map +1 -0
- package/dist/function-executor/main.d.cts +4 -0
- package/dist/function-executor/main.d.ts +4 -0
- package/dist/function-executor/main.js +4902 -0
- package/dist/function-executor/main.js.map +1 -0
- package/dist/index.cjs +10184 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2431 -0
- package/dist/index.d.ts +2431 -0
- package/dist/index.js +10108 -0
- package/dist/index.js.map +1 -0
- package/dist/native-worker.cjs +278 -0
- package/dist/native-worker.cjs.map +1 -0
- package/dist/native-worker.d.cts +2 -0
- package/dist/native-worker.d.ts +2 -0
- package/dist/native-worker.js +276 -0
- package/dist/native-worker.js.map +1 -0
- package/dist/remote-CNJ9TmcQ.d.cts +283 -0
- package/dist/remote-dblFxKug.d.ts +283 -0
- package/dist/sandbox-image-ChzWDeZy.d.cts +357 -0
- package/dist/sandbox-image-ChzWDeZy.d.ts +357 -0
- package/dist/sandbox-image.cjs +1992 -0
- package/dist/sandbox-image.cjs.map +1 -0
- package/dist/sandbox-image.d.cts +1 -0
- package/dist/sandbox-image.d.ts +1 -0
- package/dist/sandbox-image.js +1987 -0
- package/dist/sandbox-image.js.map +1 -0
- package/lib/libc.cjs +61 -0
- package/lib/libc.d.cts +1 -0
- package/lib/runtime.cjs +155 -0
- package/package.json +104 -4
- package/runtime/function-executor/manifest.json +59 -0
- package/runtime/function-executor/package/bin/function-executor.js +8 -0
- package/runtime/function-executor/package/dist/function-executor/main.js +4902 -0
- package/runtime/function-executor/package/dist/function-executor/main.js.map +1 -0
- package/runtime/function-executor/package/dist/native-worker.cjs +278 -0
- package/runtime/function-executor/package/dist/native-worker.cjs.map +1 -0
- package/runtime/function-executor/package/npm-shrinkwrap.json +475 -0
- package/runtime/function-executor/package/package.json +22 -0
- package/runtime/function-executor/package/proto/README.md +18 -0
- package/runtime/function-executor/package/proto/tensorlake/function_executor/proto/function_executor.proto +613 -0
- package/runtime/function-executor/package/proto/tensorlake/function_executor/proto/status.proto +42 -0
- package/runtime/typescript-function-runner/manifest.json +44 -0
- package/runtime/typescript-function-runner/package/bin/tensorlake-typescript-function-runner.js +8 -0
- package/runtime/typescript-function-runner/package/dist/function-agent/main.js +1825 -0
- package/runtime/typescript-function-runner/package/dist/function-agent/main.js.map +1 -0
- package/runtime/typescript-function-runner/package/dist/native-worker.cjs +278 -0
- package/runtime/typescript-function-runner/package/dist/native-worker.cjs.map +1 -0
- package/runtime/typescript-function-runner/package/npm-shrinkwrap.json +586 -0
- package/runtime/typescript-function-runner/package/package.json +25 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2431 @@
|
|
|
1
|
+
import { C as CloudClientOptions, A as ApplicationManifest, B as BinaryPayload, S as SandboxTemplate, a as ApplicationSummary, R as RequestInput, c as RequestMetadata, b as RequestOutput, d as SecretsList, e as Secret, N as NewSecret, U as UpsertSecretResponse, f as StartImageBuildRequest, g as BuildInfo, h as CreateApplicationBuildRequest, i as ApplicationBuildContext, j as ApplicationBuildResponse, k as BuildLogEntry, F as FileSystem } from './sandbox-image-ChzWDeZy.js';
|
|
2
|
+
export { l as ApplicationBuildImageResult, m as CreateApplicationBuildImageRequest, n as CreateSandboxImageOptions, I as Image, o as ImageBuildOperation, p as ImageBuildOperationType, p as ImageBuildOperationTypeValue, q as ImageOptions, r as ImportSandboxImageOptions, s as RequestErrorInfo, t as SandboxImageSource, u as SecretsPagination, v as createSandboxImage, w as deleteSandboxImage, x as dockerfileContent, y as findSandboxImageByName, z as importSandboxImage, D as listSandboxImages } from './sandbox-image-ChzWDeZy.js';
|
|
3
|
+
export { v as APIClient, A as ApplicationCapability, a as ApplicationOptions, F as File, b as FunctionOptions, c as Future, H as Headers, d as HeadersInit, e as HttpBody, P as Parameter, g as RegisteredFunction, h as RemoteOptions, j as RequestContext, S as Schema, l as SimpleApplicationOptions, m as SimpleFunctionOptions, T as TailCall, r as registerApplication, o as registerFunction, p as remoteOptions, q as retries, s as runLocal, t as runRemote, u as schema } from './remote-dblFxKug.js';
|
|
4
|
+
|
|
5
|
+
/** An SDK result paired with its server-side W3C trace ID. */
|
|
6
|
+
type Traced<T> = T & {
|
|
7
|
+
readonly traceId: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Bridge to the Rust core's sandbox lifecycle + proxy clients (`napi-rs`).
|
|
12
|
+
*
|
|
13
|
+
* The proxy data path (process/file/stream ops) is served by the Rust core so
|
|
14
|
+
* it shares `reqwest`'s connection pool — replacing the previous undici path,
|
|
15
|
+
* which multiplexed every parallel request onto a single, untuned HTTP/2
|
|
16
|
+
* connection. The native binding is required: there is no JS fallback.
|
|
17
|
+
*
|
|
18
|
+
* Convention (mirrors the Python binding): structured payloads cross as JSON
|
|
19
|
+
* strings, bytes as `Buffer`, and every call surfaces the W3C `traceId`.
|
|
20
|
+
* Errors arrive as a JSON `{category, status, message}` string in the native
|
|
21
|
+
* error message; {@link translateNativeError} rethrows them as the SDK's typed
|
|
22
|
+
* errors.
|
|
23
|
+
*/
|
|
24
|
+
interface TracedJson {
|
|
25
|
+
traceId: string;
|
|
26
|
+
json: string;
|
|
27
|
+
}
|
|
28
|
+
interface TracedBytes {
|
|
29
|
+
traceId: string;
|
|
30
|
+
data: Uint8Array;
|
|
31
|
+
contentId?: string;
|
|
32
|
+
fullSize?: number;
|
|
33
|
+
}
|
|
34
|
+
interface TracedEvents {
|
|
35
|
+
traceId: string;
|
|
36
|
+
events: string[];
|
|
37
|
+
}
|
|
38
|
+
/** Per-event callback used by the streaming proxy methods. */
|
|
39
|
+
type NativeEmit = (eventJson: string) => void | Promise<void>;
|
|
40
|
+
interface NativeSandboxProxyClient {
|
|
41
|
+
baseUrl(): string;
|
|
42
|
+
startProcess(payloadJson: string): Promise<TracedJson>;
|
|
43
|
+
listProcesses(): Promise<TracedJson>;
|
|
44
|
+
getProcess(process: string): Promise<TracedJson>;
|
|
45
|
+
killProcess(process: string): Promise<string>;
|
|
46
|
+
restartProcess(process: string): Promise<TracedJson>;
|
|
47
|
+
sendSignal(process: string, signal: number): Promise<TracedJson>;
|
|
48
|
+
writeStdin(process: string, data: Buffer): Promise<string>;
|
|
49
|
+
closeStdin(process: string): Promise<string>;
|
|
50
|
+
getStdout(process: string): Promise<TracedJson>;
|
|
51
|
+
getStderr(process: string): Promise<TracedJson>;
|
|
52
|
+
getOutput(process: string): Promise<TracedJson>;
|
|
53
|
+
followStdout(process: string, emit: NativeEmit): Promise<string>;
|
|
54
|
+
followStderr(process: string, emit: NativeEmit): Promise<string>;
|
|
55
|
+
followOutput(process: string, emit: NativeEmit): Promise<string>;
|
|
56
|
+
runProcess(payloadJson: string): Promise<TracedEvents>;
|
|
57
|
+
runProcessStreaming(payloadJson: string, emit: NativeEmit): Promise<string>;
|
|
58
|
+
readFile(path: string): Promise<TracedBytes>;
|
|
59
|
+
writeFile(path: string, content: Buffer): Promise<string>;
|
|
60
|
+
uploadFile(path: string, localPath: string): Promise<string>;
|
|
61
|
+
deleteFile(path: string): Promise<string>;
|
|
62
|
+
listDirectory(path: string): Promise<TracedJson>;
|
|
63
|
+
createPtySession(payloadJson: string): Promise<TracedJson>;
|
|
64
|
+
deletePtySession(sessionId: string): Promise<string>;
|
|
65
|
+
health(): Promise<TracedJson>;
|
|
66
|
+
info(): Promise<TracedJson>;
|
|
67
|
+
}
|
|
68
|
+
interface NativeSandboxClient {
|
|
69
|
+
createSandbox(requestJson: string): Promise<TracedJson>;
|
|
70
|
+
/** Wait-free create (`wait: false`, ADR 0086). */
|
|
71
|
+
createSandboxNoWait(requestJson: string): Promise<TracedJson>;
|
|
72
|
+
/** Poll the sandbox until it leaves `pending` or the budget runs out; resolves with the last `SandboxInfo`. */
|
|
73
|
+
waitForSandbox(sandboxId: string, timeoutSec: number, pollIntervalSec?: number | null): Promise<TracedJson>;
|
|
74
|
+
claimSandbox(poolId: string, requestJson?: string): Promise<TracedJson>;
|
|
75
|
+
copySandbox(sandboxId: string, times: number): Promise<TracedJson>;
|
|
76
|
+
getSandbox(sandboxId: string): Promise<TracedJson>;
|
|
77
|
+
listSandboxes(): Promise<TracedJson>;
|
|
78
|
+
listArchivedSandboxes(limit?: number | null, cursor?: string | null, direction?: string | null): Promise<TracedJson>;
|
|
79
|
+
getArchivedSandbox(sandboxId: string): Promise<TracedJson>;
|
|
80
|
+
getSandboxLogs(requestJson: string): Promise<TracedJson>;
|
|
81
|
+
listSandboxLogProcesses(sandboxId: string): Promise<TracedJson>;
|
|
82
|
+
updateSandbox(sandboxId: string, requestJson: string, wait?: boolean, timeoutSec?: number, pollIntervalSec?: number): Promise<TracedJson>;
|
|
83
|
+
waitForResourceResize(sandboxId: string, generation: number, timeoutSec?: number, pollIntervalSec?: number): Promise<TracedJson>;
|
|
84
|
+
deleteSandbox(sandboxId: string): Promise<string>;
|
|
85
|
+
suspendSandbox(sandboxId: string): Promise<string>;
|
|
86
|
+
resumeSandbox(sandboxId: string): Promise<string>;
|
|
87
|
+
attachFileSystem(sandboxId: string, fileSystemId: string, mountPath: string, readOnly?: boolean | null, prefetch?: boolean | null, snapshotId?: string | null, owner?: string | null): Promise<TracedJson>;
|
|
88
|
+
detachFileSystem(sandboxId: string, mountPath: string): Promise<TracedJson>;
|
|
89
|
+
createSnapshot(sandboxId: string, snapshotType?: string | null): Promise<TracedJson>;
|
|
90
|
+
getSnapshot(snapshotId: string): Promise<TracedJson>;
|
|
91
|
+
listSnapshots(): Promise<TracedJson>;
|
|
92
|
+
deleteSnapshot(snapshotId: string): Promise<string>;
|
|
93
|
+
createPool(requestJson: string): Promise<TracedJson>;
|
|
94
|
+
getPool(poolId: string): Promise<TracedJson>;
|
|
95
|
+
listPools(): Promise<TracedJson>;
|
|
96
|
+
updatePool(poolId: string, requestJson: string): Promise<TracedJson>;
|
|
97
|
+
deletePool(poolId: string): Promise<string>;
|
|
98
|
+
connectProxy(proxyUrl: string, sandboxId: string, routingHint?: string | null, requestTimeoutSec?: number | null): NativeSandboxProxyClient;
|
|
99
|
+
selectSandboxProxyUrl(sandboxId: string, sandboxUrl?: string | null, ingressEndpoint?: string | null, explicitProxyUrl?: string | null): string | Promise<string>;
|
|
100
|
+
}
|
|
101
|
+
interface NativeRepositoryClient {
|
|
102
|
+
gitRepoUrl(repo: string): Promise<string>;
|
|
103
|
+
createRepo(repo: string, defaultBranch?: string | null): Promise<TracedJson>;
|
|
104
|
+
listRepos(): Promise<TracedJson>;
|
|
105
|
+
deleteRepo(repo: string): Promise<string>;
|
|
106
|
+
forkRepo(repo: string, baseRepo: string): Promise<TracedJson>;
|
|
107
|
+
archiveRepo(repo: string): Promise<string>;
|
|
108
|
+
restoreRepo(repo: string): Promise<string>;
|
|
109
|
+
repoInfo(repo: string): Promise<TracedJson>;
|
|
110
|
+
listBranches(repo: string): Promise<TracedJson>;
|
|
111
|
+
listRefs(repo: string): Promise<TracedJson>;
|
|
112
|
+
deleteBranch(repo: string, branch: string): Promise<string>;
|
|
113
|
+
listOperations(repo: string): Promise<TracedJson>;
|
|
114
|
+
gitCredential(repo?: string | null): Promise<string>;
|
|
115
|
+
commitStatus(repo: string, jobId: string): Promise<TracedJson>;
|
|
116
|
+
pushWorktree(repo: string, root: string, branch: string, message: string, expectOid?: string | null): Promise<TracedJson>;
|
|
117
|
+
mergeRepo(repo: string, ours: string, theirs: string, preflight: boolean, deep: boolean, materialize: boolean, message?: string | null, base?: string | null): Promise<TracedJson>;
|
|
118
|
+
commitConflicts(repo: string, commit: string): Promise<TracedJson>;
|
|
119
|
+
createFilesystem(name: string, region?: string): Promise<string>;
|
|
120
|
+
forkFilesystem(name: string, base: string, snapshot?: string | null): Promise<TracedJson>;
|
|
121
|
+
listFilesystems(): Promise<TracedJson>;
|
|
122
|
+
filesystemMeta(name: string): Promise<TracedJson>;
|
|
123
|
+
deleteFilesystem(name: string): Promise<string>;
|
|
124
|
+
filesystemRefStatus(name: string, refspec: string): Promise<TracedJson>;
|
|
125
|
+
retainFilesystemSnapshot(name: string, message: string, requestId: string): Promise<TracedJson>;
|
|
126
|
+
listFilesystemSnapshots(name: string): Promise<TracedJson>;
|
|
127
|
+
deleteFilesystemSnapshot(name: string, snapshot: string): Promise<string>;
|
|
128
|
+
readFilesystemFile(name: string, path: string, version: string, offset?: number, length?: number): Promise<TracedBytes>;
|
|
129
|
+
listFilesystemTree(name: string, dirPath: string, version: string): Promise<TracedJson>;
|
|
130
|
+
pushFilesystemFiles(name: string, files: Array<{
|
|
131
|
+
path: string;
|
|
132
|
+
content: Buffer;
|
|
133
|
+
}>, deletes: string[], moves: Array<{
|
|
134
|
+
from: string;
|
|
135
|
+
to: string;
|
|
136
|
+
}>, copies: Array<{
|
|
137
|
+
from: string;
|
|
138
|
+
to: string;
|
|
139
|
+
}>, message: string, branch: string, idempotencyKey?: string | null): Promise<TracedJson>;
|
|
140
|
+
pushFilesystemPaths(name: string, files: Array<{
|
|
141
|
+
path: string;
|
|
142
|
+
localPath: string;
|
|
143
|
+
}>, message: string, branch: string, idempotencyKey?: string | null): Promise<TracedJson>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare enum SandboxStatus {
|
|
147
|
+
PENDING = "pending",
|
|
148
|
+
RUNNING = "running",
|
|
149
|
+
SNAPSHOTTING = "snapshotting",
|
|
150
|
+
SUSPENDING = "suspending",
|
|
151
|
+
SUSPENDED = "suspended",
|
|
152
|
+
TERMINATED = "terminated",
|
|
153
|
+
TIMEOUT = "timeout",
|
|
154
|
+
/** Terminal status used by blocking create/claim responses. */
|
|
155
|
+
FAILED = "failed"
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Why a pending sandbox is waiting (`pendingReason`). The wire value is a
|
|
159
|
+
* snake_case string; unknown future reasons arrive as plain strings.
|
|
160
|
+
*/
|
|
161
|
+
declare enum SandboxPendingReason {
|
|
162
|
+
SCHEDULING = "scheduling",
|
|
163
|
+
WAITING_FOR_CONTAINER = "waiting_for_container",
|
|
164
|
+
NO_EXECUTORS_AVAILABLE = "no_executors_available",
|
|
165
|
+
NO_RESOURCES_AVAILABLE = "no_resources_available",
|
|
166
|
+
POOL_AT_CAPACITY = "pool_at_capacity",
|
|
167
|
+
MAX_CAPACITY_REACHED = "max_capacity_reached",
|
|
168
|
+
NO_EXECUTOR_FOR_SNAPSHOT_LOCATION = "no_executor_for_snapshot_location",
|
|
169
|
+
/** The autoscaler reported that no fleet can ever place this shape. */
|
|
170
|
+
UNPLACEABLE = "unplaceable"
|
|
171
|
+
}
|
|
172
|
+
/** `terminationReason` when a `maxPendingSecs` bound expired, or the shape is unplaceable. */
|
|
173
|
+
declare const TERMINATION_REASON_NO_CAPACITY = "no_capacity";
|
|
174
|
+
/** `terminationReason` when a pending sandbox was deleted before it ran. */
|
|
175
|
+
declare const TERMINATION_REASON_CANCELLED = "cancelled";
|
|
176
|
+
/** Whether a sandbox status is one a readiness wait keeps polling through. */
|
|
177
|
+
declare function isSandboxPending(status: SandboxStatus | string): boolean;
|
|
178
|
+
declare enum SnapshotStatus {
|
|
179
|
+
IN_PROGRESS = "in_progress",
|
|
180
|
+
LOCAL_READY = "local_ready",
|
|
181
|
+
COMPLETED = "completed",
|
|
182
|
+
FAILED = "failed"
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Snapshot type for sandbox snapshot creation.
|
|
186
|
+
*
|
|
187
|
+
* - `"memory"`: Capture VM memory + filesystem state. Sandboxes restored
|
|
188
|
+
* from this snapshot warm-restore VM memory.
|
|
189
|
+
* - `"filesystem"`: Capture filesystem state only. Sandboxes restored from
|
|
190
|
+
* this snapshot cold-boot from the snapshot tarball instead of warm-
|
|
191
|
+
* restoring VM state. Use this for sandbox image builds so that the
|
|
192
|
+
* restored sandbox bypasses Firecracker's overlay-path constraints.
|
|
193
|
+
*/
|
|
194
|
+
type SnapshotType = "memory" | "filesystem";
|
|
195
|
+
/**
|
|
196
|
+
* Checkpoint type for {@link Sandbox.checkpoint}.
|
|
197
|
+
*
|
|
198
|
+
* - `"memory"`: Capture VM memory + filesystem state. Sandboxes restored
|
|
199
|
+
* from this checkpoint warm-restore VM memory and running processes.
|
|
200
|
+
* - `"filesystem"`: Capture filesystem state only. Sandboxes restored from
|
|
201
|
+
* this checkpoint cold-boot from the snapshot tarball.
|
|
202
|
+
*/
|
|
203
|
+
type CheckpointType = "memory" | "filesystem";
|
|
204
|
+
type SnapshotWaitCondition = "local_ready" | "completed";
|
|
205
|
+
declare enum ProcessStatus {
|
|
206
|
+
RUNNING = "running",
|
|
207
|
+
EXITED = "exited",
|
|
208
|
+
SIGNALED = "signaled",
|
|
209
|
+
OOM_KILLED = "oom_killed"
|
|
210
|
+
}
|
|
211
|
+
declare enum StdinMode {
|
|
212
|
+
CLOSED = "closed",
|
|
213
|
+
PIPE = "pipe"
|
|
214
|
+
}
|
|
215
|
+
declare enum OutputMode {
|
|
216
|
+
CAPTURE = "capture",
|
|
217
|
+
DISCARD = "discard"
|
|
218
|
+
}
|
|
219
|
+
declare enum ContainerState {
|
|
220
|
+
IDLE = "Idle",
|
|
221
|
+
RUNNING = "Running"
|
|
222
|
+
}
|
|
223
|
+
interface ContainerResourcesInfo {
|
|
224
|
+
cpus: number;
|
|
225
|
+
memoryMb: number;
|
|
226
|
+
diskMb: number;
|
|
227
|
+
}
|
|
228
|
+
/** GPU models supported by the sandbox scheduler. */
|
|
229
|
+
type GpuModel = "A100-40GB" | "A100-80GB" | "H100" | "T4" | "A6000" | "RTX-PRO-6000" | "L40" | "A10";
|
|
230
|
+
/** A homogeneous GPU allocation for a sandbox. */
|
|
231
|
+
interface GpuRequest {
|
|
232
|
+
count: number;
|
|
233
|
+
model: GpuModel;
|
|
234
|
+
}
|
|
235
|
+
interface GPUResources {
|
|
236
|
+
count: number;
|
|
237
|
+
model: string;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Egress network access control policy for a sandbox.
|
|
241
|
+
*
|
|
242
|
+
* `denyOut` takes precedence over `allowOut`: a destination matched by both is
|
|
243
|
+
* blocked. Entries may be IPv4 addresses, CIDR ranges, or DNS hostnames;
|
|
244
|
+
* hostname rules are followed across DNS changes. The policy can be changed on
|
|
245
|
+
* a running sandbox via `Sandbox.update({ network })` (pass `null` to clear).
|
|
246
|
+
*/
|
|
247
|
+
interface NetworkConfig {
|
|
248
|
+
allowInternetAccess: boolean;
|
|
249
|
+
allowOut: string[];
|
|
250
|
+
denyOut: string[];
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* One file system mounted into a sandbox at an absolute guest path.
|
|
254
|
+
*
|
|
255
|
+
* `fileSystemId` is the Artifact Storage file-system name created with
|
|
256
|
+
* `tl fs create <name>` and `mountPath` is an absolute, unique guest path
|
|
257
|
+
* (e.g. `/mnt/skills`).
|
|
258
|
+
*
|
|
259
|
+
* `readOnly` and `prefetch` are optional mount modes; they are sent on the
|
|
260
|
+
* wire only when `true` (older servers reject unknown mount fields, so
|
|
261
|
+
* `false` is expressed by omission).
|
|
262
|
+
*
|
|
263
|
+
* `snapshotId` pins the mount to a specific filesystem snapshot. A pinned
|
|
264
|
+
* mount must also set `readOnly: true` (the server rejects a writable pin
|
|
265
|
+
* with HTTP 400). It is sent only when set, for the same compatibility
|
|
266
|
+
* reason as the mount modes.
|
|
267
|
+
*
|
|
268
|
+
* `owner` presents the mounted files as owned by a guest user: `NAME`,
|
|
269
|
+
* `UID`, `NAME:GROUP`, or `UID:GID` (e.g. `"agent"` or `"1001:1001"`),
|
|
270
|
+
* resolved against the sandbox image's own user database when the mount
|
|
271
|
+
* attaches. Unset keeps the image default (the baked `tl-user` account when
|
|
272
|
+
* the image has one, otherwise root). It is sent only when set, for the
|
|
273
|
+
* same compatibility reason as the mount modes.
|
|
274
|
+
*/
|
|
275
|
+
interface FileSystemMount {
|
|
276
|
+
fileSystemId: string;
|
|
277
|
+
mountPath: string;
|
|
278
|
+
/** Mount the file system read-only. */
|
|
279
|
+
readOnly?: boolean;
|
|
280
|
+
/** Eagerly download the file system's contents. */
|
|
281
|
+
prefetch?: boolean;
|
|
282
|
+
/** Pin the mount to a specific filesystem snapshot (requires `readOnly`). */
|
|
283
|
+
snapshotId?: string;
|
|
284
|
+
/** Present the mounted files as owned by this guest user spec. */
|
|
285
|
+
owner?: string;
|
|
286
|
+
}
|
|
287
|
+
/** Optional mount modes for attaching a file system to a running sandbox. */
|
|
288
|
+
interface AttachFileSystemOptions {
|
|
289
|
+
/** Mount the file system read-only. */
|
|
290
|
+
readOnly?: boolean;
|
|
291
|
+
/** Eagerly download the file system's contents. */
|
|
292
|
+
prefetch?: boolean;
|
|
293
|
+
/** Pin the mount to a specific filesystem snapshot (requires `readOnly`). */
|
|
294
|
+
snapshotId?: string;
|
|
295
|
+
/** Present the mounted files as owned by this guest user spec. */
|
|
296
|
+
owner?: string;
|
|
297
|
+
}
|
|
298
|
+
interface ClaimSandboxOptions {
|
|
299
|
+
/** File systems to mount before the claimed sandbox is reported as running. */
|
|
300
|
+
fileSystems?: FileSystemMount[];
|
|
301
|
+
}
|
|
302
|
+
interface CreateSandboxOptions {
|
|
303
|
+
/** Optional sandbox image name. GPU sandboxes require a CAS image; when omitted with a GPU request, Tensorlake uses the server's configured GPU default. */
|
|
304
|
+
image?: string;
|
|
305
|
+
/** CPU count. Defaults to 1 for fresh creates; snapshot restores inherit it when omitted. */
|
|
306
|
+
cpus?: number;
|
|
307
|
+
/** Memory in MiB. Defaults to 1024 for fresh creates; snapshot restores inherit it when omitted. */
|
|
308
|
+
memoryMb?: number;
|
|
309
|
+
/** Root disk size in MiB. When omitted, the server uses its default disk size. */
|
|
310
|
+
diskMb?: number;
|
|
311
|
+
/** Number of GPUs to allocate. Defaults to A10 unless gpuModel is set. GPU sandboxes require a CAS image. */
|
|
312
|
+
gpus?: number;
|
|
313
|
+
/** GPU model to allocate. The string arm preserves compatibility with existing callers; values are validated at runtime. */
|
|
314
|
+
gpuModel?: GpuModel | (string & {});
|
|
315
|
+
/** Typed GPU model and count request. Cannot be combined with gpus or gpuModel. */
|
|
316
|
+
gpu?: GpuRequest;
|
|
317
|
+
timeoutSecs?: number;
|
|
318
|
+
entrypoint?: string[];
|
|
319
|
+
allowInternetAccess?: boolean;
|
|
320
|
+
allowOut?: string[];
|
|
321
|
+
denyOut?: string[];
|
|
322
|
+
snapshotId?: string;
|
|
323
|
+
/** Optional name for the sandbox. Named sandboxes support suspend/resume. When absent the sandbox is ephemeral. */
|
|
324
|
+
name?: string;
|
|
325
|
+
/** File systems to mount on fresh creation or warm-pool claim, each at its own absolute, unique guest mount path. */
|
|
326
|
+
fileSystems?: FileSystemMount[];
|
|
327
|
+
/**
|
|
328
|
+
* `false` returns a `PendingSandbox` handle as soon as the sandbox is
|
|
329
|
+
* durable, without waiting for it to run: `pending.ready()` waits,
|
|
330
|
+
* `pending.status()` looks, and `Sandbox.connect(pending.sandboxId)`
|
|
331
|
+
* collects it from any other process. `true` / unset waits as before.
|
|
332
|
+
*/
|
|
333
|
+
wait?: boolean;
|
|
334
|
+
/**
|
|
335
|
+
* Longest the sandbox may wait for capacity before the server fails it with
|
|
336
|
+
* reason `no_capacity`. `0` fails at once when it cannot be placed; unset
|
|
337
|
+
* (the default) waits indefinitely. Applies to capacity waits only, not to
|
|
338
|
+
* image pull or boot. A bound shorter than the fleet's boot time (up to 20
|
|
339
|
+
* minutes on metal hosts) expires the very demand that made the autoscaler
|
|
340
|
+
* launch a host; 30 minutes or more is recommended for capacity waits.
|
|
341
|
+
*/
|
|
342
|
+
maxPendingSecs?: number;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Bounded generation wait. Timeout never cancels a resize. Times are seconds.
|
|
346
|
+
* A zero timeout checks once without polling again.
|
|
347
|
+
*/
|
|
348
|
+
interface ResourceResizeWaitOptions {
|
|
349
|
+
timeout?: number;
|
|
350
|
+
pollInterval?: number;
|
|
351
|
+
}
|
|
352
|
+
declare enum ResizeStatus {
|
|
353
|
+
PENDING = "pending",
|
|
354
|
+
SUCCEEDED = "succeeded",
|
|
355
|
+
FAILED = "failed"
|
|
356
|
+
}
|
|
357
|
+
declare enum ResizeErrorReason {
|
|
358
|
+
FAILED = "failed",
|
|
359
|
+
TIMEOUT = "timeout",
|
|
360
|
+
SUPERSEDED = "superseded",
|
|
361
|
+
INTERRUPTED = "interrupted",
|
|
362
|
+
INCOMPATIBLE_RESPONSE = "incompatible_response"
|
|
363
|
+
}
|
|
364
|
+
interface SandboxResourceResizeInfo {
|
|
365
|
+
generation: number;
|
|
366
|
+
requested: ContainerResourcesInfo;
|
|
367
|
+
status: ResizeStatus | (string & {});
|
|
368
|
+
errorMessage?: string | null;
|
|
369
|
+
}
|
|
370
|
+
/** Wait options apply only to resource updates and are ignored for other properties. */
|
|
371
|
+
interface UpdateSandboxOptions extends ResourceResizeWaitOptions {
|
|
372
|
+
/** Whole live vCPU target; omitted retains the current allocation. */
|
|
373
|
+
cpus?: number;
|
|
374
|
+
/** Memory target in MiB, with the same units as create; never rounded by the SDK. */
|
|
375
|
+
memoryMb?: number;
|
|
376
|
+
/** Root disk target in MiB; can only grow. */
|
|
377
|
+
diskMb?: number;
|
|
378
|
+
/** Wait for resize completion (default true). False returns admission. */
|
|
379
|
+
wait?: boolean;
|
|
380
|
+
/** New name for the sandbox. Naming an ephemeral sandbox enables suspend/resume. */
|
|
381
|
+
name?: string;
|
|
382
|
+
/** Whether exposed user ports should be reachable without TensorLake auth. */
|
|
383
|
+
allowUnauthenticatedAccess?: boolean;
|
|
384
|
+
/** User ports that should be routable through the sandbox proxy. Port 9501 is reserved. */
|
|
385
|
+
exposedPorts?: number[];
|
|
386
|
+
/**
|
|
387
|
+
* Egress network policy for the running sandbox, applied to the live VM's
|
|
388
|
+
* firewall in one atomic swap. Omit to keep the current policy, set to
|
|
389
|
+
* replace it, or pass `null` to clear it to unrestricted egress.
|
|
390
|
+
*/
|
|
391
|
+
network?: NetworkConfig | null;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Response from a blocking create or a pool claim.
|
|
395
|
+
*
|
|
396
|
+
* The server waits for readiness for at most the request timeout and can
|
|
397
|
+
* already report `running`; a `pending` answer carries a `pendingReason`.
|
|
398
|
+
* Use `connect(sandboxId)` to wait for a pending sandbox, or
|
|
399
|
+
* `create({ wait: false })` for a `PendingSandbox` handle.
|
|
400
|
+
*/
|
|
401
|
+
interface CreateSandboxResponse {
|
|
402
|
+
sandboxId: string;
|
|
403
|
+
status: SandboxStatus;
|
|
404
|
+
reason?: string;
|
|
405
|
+
routingHint?: string;
|
|
406
|
+
ingressEndpoint?: string;
|
|
407
|
+
sandboxUrl?: string;
|
|
408
|
+
name?: string | null;
|
|
409
|
+
terminationReason?: string;
|
|
410
|
+
errorDetails?: unknown;
|
|
411
|
+
pendingReason?: string;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* The acknowledgement of a `create({ wait: false })`: the wire record of a
|
|
415
|
+
* sandbox that is durable and starts whenever capacity allows. The
|
|
416
|
+
* `PendingSandbox` class in `pending-sandbox.ts` wraps it with `ready()` /
|
|
417
|
+
* `status()`. A server that predates `wait: false` answers the blocking
|
|
418
|
+
* create's shape instead, so `state` may already be `running`.
|
|
419
|
+
*/
|
|
420
|
+
interface PendingSandboxRecord {
|
|
421
|
+
sandboxId: string;
|
|
422
|
+
name?: string;
|
|
423
|
+
state: SandboxStatus;
|
|
424
|
+
pendingReason?: string;
|
|
425
|
+
routingHint?: string;
|
|
426
|
+
ingressEndpoint?: string;
|
|
427
|
+
sandboxUrl?: string;
|
|
428
|
+
reason?: string;
|
|
429
|
+
terminationReason?: string;
|
|
430
|
+
errorDetails?: unknown;
|
|
431
|
+
}
|
|
432
|
+
interface ReadyOptions {
|
|
433
|
+
/** Seconds to wait; defaults to the client requestTimeout. `0` observes the current state once. */
|
|
434
|
+
timeout?: number;
|
|
435
|
+
/** Seconds between `GET /sandboxes/{id}` polls. Default: 2. */
|
|
436
|
+
pollInterval?: number;
|
|
437
|
+
/**
|
|
438
|
+
* Delete the sandbox when `timeout` runs out while it is still pending,
|
|
439
|
+
* then throw `SandboxError` (the pre-ADR-0086 behaviour). Default false:
|
|
440
|
+
* throw `SandboxPending` and leave the sandbox queued.
|
|
441
|
+
*/
|
|
442
|
+
cancelOnTimeout?: boolean;
|
|
443
|
+
}
|
|
444
|
+
interface CopySandboxOptions {
|
|
445
|
+
/** Number of running copies to create. Defaults to 1. */
|
|
446
|
+
times?: number;
|
|
447
|
+
/** Per-request timeout in seconds for the blocking live-copy request. */
|
|
448
|
+
requestTimeout?: number;
|
|
449
|
+
}
|
|
450
|
+
interface CopiedSandboxResponse {
|
|
451
|
+
sandboxId: string;
|
|
452
|
+
/** Raw server status. Partial copy responses can include statuses such as `"failed"`. */
|
|
453
|
+
status: string;
|
|
454
|
+
reason?: string;
|
|
455
|
+
routingHint?: string;
|
|
456
|
+
ingressEndpoint?: string;
|
|
457
|
+
sandboxUrl?: string;
|
|
458
|
+
name?: string | null;
|
|
459
|
+
terminationReason?: string;
|
|
460
|
+
errorDetails?: unknown;
|
|
461
|
+
}
|
|
462
|
+
interface CopySandboxResponse {
|
|
463
|
+
sourceSandboxId: string;
|
|
464
|
+
sandboxes: CopiedSandboxResponse[];
|
|
465
|
+
}
|
|
466
|
+
interface SandboxInfo {
|
|
467
|
+
runtime?: string;
|
|
468
|
+
resourceResize?: SandboxResourceResizeInfo | null;
|
|
469
|
+
sandboxId: string;
|
|
470
|
+
namespace: string;
|
|
471
|
+
status: SandboxStatus;
|
|
472
|
+
/** Resolved sandbox image name. */
|
|
473
|
+
image?: string;
|
|
474
|
+
resources: ContainerResourcesInfo;
|
|
475
|
+
timeoutSecs?: number;
|
|
476
|
+
entrypoint?: string[];
|
|
477
|
+
/** Egress network policy currently applied to the sandbox. */
|
|
478
|
+
networkPolicy?: NetworkConfig;
|
|
479
|
+
poolId?: string;
|
|
480
|
+
outcome?: string;
|
|
481
|
+
terminationReason?: string;
|
|
482
|
+
errorDetails?: unknown;
|
|
483
|
+
/** Why a pending sandbox is waiting, in snake_case. */
|
|
484
|
+
pendingReason?: string;
|
|
485
|
+
createdAt?: Date;
|
|
486
|
+
terminatedAt?: Date;
|
|
487
|
+
name?: string;
|
|
488
|
+
allowUnauthenticatedAccess?: boolean;
|
|
489
|
+
exposedPorts?: number[];
|
|
490
|
+
ingressEndpoint?: string;
|
|
491
|
+
sandboxUrl?: string;
|
|
492
|
+
routingHint?: string;
|
|
493
|
+
/** File systems currently mounted into the sandbox, each at its own guest mount path. Empty when none are mounted. */
|
|
494
|
+
fileSystems?: FileSystemMount[];
|
|
495
|
+
}
|
|
496
|
+
interface SandboxPortAccess {
|
|
497
|
+
allowUnauthenticatedAccess: boolean;
|
|
498
|
+
exposedPorts: number[];
|
|
499
|
+
ingressEndpoint?: string;
|
|
500
|
+
sandboxUrl?: string;
|
|
501
|
+
}
|
|
502
|
+
/** Sandbox information plus the archival timestamp. */
|
|
503
|
+
interface ArchivedSandboxInfo extends SandboxInfo {
|
|
504
|
+
archivedAt: Date;
|
|
505
|
+
}
|
|
506
|
+
/** Pagination params for `listArchivedSandboxes`. */
|
|
507
|
+
interface ListArchivedSandboxesOptions {
|
|
508
|
+
limit?: number;
|
|
509
|
+
/** Base64-encoded pagination cursor returned by a prior call. */
|
|
510
|
+
cursor?: string;
|
|
511
|
+
/** Pagination direction. */
|
|
512
|
+
direction?: "forward" | "backward";
|
|
513
|
+
}
|
|
514
|
+
interface ListArchivedSandboxesResponse {
|
|
515
|
+
sandboxes: ArchivedSandboxInfo[];
|
|
516
|
+
prevCursor?: string;
|
|
517
|
+
nextCursor?: string;
|
|
518
|
+
}
|
|
519
|
+
interface CreateSnapshotResponse {
|
|
520
|
+
snapshotId: string;
|
|
521
|
+
status: SnapshotStatus;
|
|
522
|
+
}
|
|
523
|
+
interface SnapshotInfo {
|
|
524
|
+
snapshotId: string;
|
|
525
|
+
namespace: string;
|
|
526
|
+
sandboxId: string;
|
|
527
|
+
baseImage: string;
|
|
528
|
+
status: SnapshotStatus;
|
|
529
|
+
snapshotType?: SnapshotType;
|
|
530
|
+
error?: string;
|
|
531
|
+
snapshotUri?: string;
|
|
532
|
+
snapshotFormatVersion?: string;
|
|
533
|
+
sizeBytes?: number;
|
|
534
|
+
rootfsDiskBytes?: number;
|
|
535
|
+
createdAt?: Date;
|
|
536
|
+
}
|
|
537
|
+
interface SnapshotOptions {
|
|
538
|
+
/**
|
|
539
|
+
* Optional snapshot type. When omitted the server picks its default. Use
|
|
540
|
+
* `"filesystem"` for snapshots intended for sandbox image builds so that
|
|
541
|
+
* restored sandboxes cold-boot.
|
|
542
|
+
*/
|
|
543
|
+
snapshotType?: SnapshotType;
|
|
544
|
+
}
|
|
545
|
+
interface SnapshotAndWaitOptions extends SnapshotOptions {
|
|
546
|
+
timeout?: number;
|
|
547
|
+
pollInterval?: number;
|
|
548
|
+
/** Defaults to `"local_ready"`, which is enough to resume from a snapshot. */
|
|
549
|
+
waitUntil?: SnapshotWaitCondition;
|
|
550
|
+
}
|
|
551
|
+
type SandboxLogLevel = "trace" | "debug" | "info" | "warn" | "error" | "fatal";
|
|
552
|
+
interface GetSandboxLogsOptions {
|
|
553
|
+
levels?: SandboxLogLevel[];
|
|
554
|
+
processIds?: string[];
|
|
555
|
+
nextToken?: string;
|
|
556
|
+
head?: number;
|
|
557
|
+
tail?: number;
|
|
558
|
+
body?: string;
|
|
559
|
+
}
|
|
560
|
+
interface SandboxLogSignal {
|
|
561
|
+
timestamp: number;
|
|
562
|
+
uuid: string;
|
|
563
|
+
namespace: string;
|
|
564
|
+
application: string;
|
|
565
|
+
sandboxId?: string;
|
|
566
|
+
resourceAttributes: Array<[string, string]>;
|
|
567
|
+
body: string;
|
|
568
|
+
logAttributes: string;
|
|
569
|
+
allocations?: string[];
|
|
570
|
+
functionRuns?: string[];
|
|
571
|
+
level?: number;
|
|
572
|
+
retention?: number;
|
|
573
|
+
}
|
|
574
|
+
interface SandboxLogsResponse {
|
|
575
|
+
logs: SandboxLogSignal[];
|
|
576
|
+
nextToken?: string;
|
|
577
|
+
}
|
|
578
|
+
interface SandboxProcessLogFilter {
|
|
579
|
+
processId: string;
|
|
580
|
+
processPid: string;
|
|
581
|
+
processCommand: string;
|
|
582
|
+
processManagedId: string;
|
|
583
|
+
processManagedName: string;
|
|
584
|
+
firstSeen: number;
|
|
585
|
+
lastSeen: number;
|
|
586
|
+
logCount: number;
|
|
587
|
+
}
|
|
588
|
+
interface SandboxProcessLogFiltersResponse {
|
|
589
|
+
processes: SandboxProcessLogFilter[];
|
|
590
|
+
}
|
|
591
|
+
interface CreatePoolOptions {
|
|
592
|
+
/** Sandbox image name, such as `tensorlake/ubuntu-minimal` or a registered Sandbox Image. */
|
|
593
|
+
image: string;
|
|
594
|
+
cpus?: number;
|
|
595
|
+
memoryMb?: number;
|
|
596
|
+
/** Root disk size in MiB. Omit to use the registered image's size. */
|
|
597
|
+
diskMb?: number;
|
|
598
|
+
timeoutSecs?: number;
|
|
599
|
+
entrypoint?: string[];
|
|
600
|
+
maxContainers?: number;
|
|
601
|
+
warmContainers?: number;
|
|
602
|
+
/** Network policy for each container. Can be replaced later via updatePool. */
|
|
603
|
+
network?: NetworkConfig;
|
|
604
|
+
}
|
|
605
|
+
interface UpdatePoolOptions {
|
|
606
|
+
/**
|
|
607
|
+
* Network policy for each container. Omit to keep the pool's current policy,
|
|
608
|
+
* set to replace it, or pass `null` to remove it (unclaimed warm containers
|
|
609
|
+
* are recycled onto the new policy).
|
|
610
|
+
*/
|
|
611
|
+
network?: NetworkConfig | null;
|
|
612
|
+
/** Sandbox image name, such as `tensorlake/ubuntu-minimal` or a registered Sandbox Image. */
|
|
613
|
+
image: string;
|
|
614
|
+
cpus?: number;
|
|
615
|
+
memoryMb?: number;
|
|
616
|
+
/** Root disk size in MiB. Omit to use the registered image's size. */
|
|
617
|
+
diskMb?: number;
|
|
618
|
+
timeoutSecs?: number;
|
|
619
|
+
entrypoint?: string[];
|
|
620
|
+
maxContainers?: number;
|
|
621
|
+
warmContainers?: number;
|
|
622
|
+
}
|
|
623
|
+
interface CreateSandboxPoolResponse {
|
|
624
|
+
poolId: string;
|
|
625
|
+
namespace: string;
|
|
626
|
+
}
|
|
627
|
+
interface PoolContainerInfo {
|
|
628
|
+
id: string;
|
|
629
|
+
state: string;
|
|
630
|
+
sandboxId?: string;
|
|
631
|
+
executorId: string;
|
|
632
|
+
}
|
|
633
|
+
interface SandboxPoolInfo {
|
|
634
|
+
poolId: string;
|
|
635
|
+
namespace: string;
|
|
636
|
+
/** Sandbox image name backing the pool. */
|
|
637
|
+
image: string;
|
|
638
|
+
resources: ContainerResourcesInfo;
|
|
639
|
+
timeoutSecs: number;
|
|
640
|
+
entrypoint?: string[];
|
|
641
|
+
maxContainers?: number;
|
|
642
|
+
warmContainers?: number;
|
|
643
|
+
/** The network policy that applies to each container in the pool. */
|
|
644
|
+
networkPolicy?: NetworkConfig;
|
|
645
|
+
containers?: PoolContainerInfo[];
|
|
646
|
+
createdAt?: Date;
|
|
647
|
+
updatedAt?: Date;
|
|
648
|
+
}
|
|
649
|
+
interface ProcessUserSpec {
|
|
650
|
+
name?: string;
|
|
651
|
+
uid?: number;
|
|
652
|
+
gid?: number;
|
|
653
|
+
}
|
|
654
|
+
type ProcessUser = string | ProcessUserSpec;
|
|
655
|
+
type RestartPolicy = "never" | "on_failure" | "always";
|
|
656
|
+
interface RestartPolicyConfig {
|
|
657
|
+
policy?: RestartPolicy;
|
|
658
|
+
maxRestarts?: number;
|
|
659
|
+
initialBackoffMs?: number;
|
|
660
|
+
maxBackoffMs?: number;
|
|
661
|
+
}
|
|
662
|
+
type ProcessHealthCheckType = "http" | "tcp";
|
|
663
|
+
interface ProcessHealthCheck {
|
|
664
|
+
type: ProcessHealthCheckType;
|
|
665
|
+
port: number;
|
|
666
|
+
path?: string;
|
|
667
|
+
initialDelayMs?: number;
|
|
668
|
+
intervalMs?: number;
|
|
669
|
+
timeoutMs?: number;
|
|
670
|
+
failureThreshold?: number;
|
|
671
|
+
}
|
|
672
|
+
type ManagedProcessStatus = "starting" | "running" | "backing_off" | "stopped";
|
|
673
|
+
type ManagedProcessHealthStatus = "disabled" | "starting" | "healthy" | "unhealthy";
|
|
674
|
+
interface ManagedProcessExit {
|
|
675
|
+
exitCode?: number;
|
|
676
|
+
signal?: number;
|
|
677
|
+
oomKilled: boolean;
|
|
678
|
+
endedAt: Date;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Managed-process metadata embedded into {@link ProcessInfo}.
|
|
682
|
+
*
|
|
683
|
+
* A managed process is addressable by either its current PID or, if a `name` was given at
|
|
684
|
+
* creation, that name (process APIs accept a PID or process name). `id` is a stable
|
|
685
|
+
* daemon-local identifier: it equals `name` when one was set, otherwise a daemon-assigned
|
|
686
|
+
* opaque id (the process is then addressable only by PID, not by `id`).
|
|
687
|
+
*/
|
|
688
|
+
interface ManagedProcessInfo {
|
|
689
|
+
id: string;
|
|
690
|
+
name?: string;
|
|
691
|
+
status: ManagedProcessStatus;
|
|
692
|
+
restartCount: number;
|
|
693
|
+
restart: RestartPolicyConfig;
|
|
694
|
+
healthCheck?: ProcessHealthCheck;
|
|
695
|
+
healthStatus: ManagedProcessHealthStatus;
|
|
696
|
+
consecutiveHealthFailures: number;
|
|
697
|
+
lastExit?: ManagedProcessExit;
|
|
698
|
+
lastError?: string;
|
|
699
|
+
nextRestartAt?: Date;
|
|
700
|
+
}
|
|
701
|
+
interface StartProcessOptions {
|
|
702
|
+
args?: string[];
|
|
703
|
+
env?: Record<string, string>;
|
|
704
|
+
workingDir?: string;
|
|
705
|
+
stdinMode?: StdinMode;
|
|
706
|
+
stdoutMode?: OutputMode;
|
|
707
|
+
stderrMode?: OutputMode;
|
|
708
|
+
user?: ProcessUser;
|
|
709
|
+
/**
|
|
710
|
+
* Optional managed-process name. Supplying this opts into managed process behavior, and
|
|
711
|
+
* lets the process be addressed by this name (in addition to its PID) in
|
|
712
|
+
* `getProcess`/`killProcess`/`sendSignal`/etc. — useful because a managed process's PID
|
|
713
|
+
* changes when it restarts. May contain any characters except `/` and must not be all
|
|
714
|
+
* digits (numeric strings are reserved for PID addressing). If omitted, the daemon assigns
|
|
715
|
+
* an opaque id (`ManagedProcessInfo.id`) and the process is addressable only by its current PID.
|
|
716
|
+
*/
|
|
717
|
+
name?: string;
|
|
718
|
+
/** Optional restart behavior. Supplying this opts into managed process behavior. */
|
|
719
|
+
restart?: RestartPolicyConfig;
|
|
720
|
+
/** Optional HTTP/TCP health check. Supplying this opts into managed process behavior. */
|
|
721
|
+
healthCheck?: ProcessHealthCheck;
|
|
722
|
+
}
|
|
723
|
+
interface ProcessInfo {
|
|
724
|
+
handle?: number;
|
|
725
|
+
pid: number;
|
|
726
|
+
status: ProcessStatus;
|
|
727
|
+
exitCode?: number;
|
|
728
|
+
signal?: number;
|
|
729
|
+
stdinWritable: boolean;
|
|
730
|
+
command: string;
|
|
731
|
+
args: string[];
|
|
732
|
+
startedAt: Date;
|
|
733
|
+
endedAt?: Date;
|
|
734
|
+
managed?: ManagedProcessInfo;
|
|
735
|
+
}
|
|
736
|
+
interface SendSignalResponse {
|
|
737
|
+
success: boolean;
|
|
738
|
+
}
|
|
739
|
+
interface OutputResponse {
|
|
740
|
+
pid: number;
|
|
741
|
+
lines: string[];
|
|
742
|
+
lineCount: number;
|
|
743
|
+
}
|
|
744
|
+
interface OutputEvent {
|
|
745
|
+
line: string;
|
|
746
|
+
timestamp: Date;
|
|
747
|
+
stream?: string;
|
|
748
|
+
}
|
|
749
|
+
interface RunOptions {
|
|
750
|
+
args?: string[];
|
|
751
|
+
env?: Record<string, string>;
|
|
752
|
+
workingDir?: string;
|
|
753
|
+
timeout?: number;
|
|
754
|
+
user?: ProcessUser;
|
|
755
|
+
}
|
|
756
|
+
interface CommandResult {
|
|
757
|
+
exitCode: number;
|
|
758
|
+
stdout: string;
|
|
759
|
+
stderr: string;
|
|
760
|
+
}
|
|
761
|
+
interface DirectoryEntry {
|
|
762
|
+
name: string;
|
|
763
|
+
isDir: boolean;
|
|
764
|
+
size?: number;
|
|
765
|
+
modifiedAt?: Date;
|
|
766
|
+
}
|
|
767
|
+
interface ListDirectoryResponse {
|
|
768
|
+
path: string;
|
|
769
|
+
entries: DirectoryEntry[];
|
|
770
|
+
}
|
|
771
|
+
interface CreatePtySessionOptions {
|
|
772
|
+
command: string;
|
|
773
|
+
args?: string[];
|
|
774
|
+
env?: Record<string, string>;
|
|
775
|
+
workingDir?: string;
|
|
776
|
+
rows?: number;
|
|
777
|
+
cols?: number;
|
|
778
|
+
}
|
|
779
|
+
interface PtySessionInfo {
|
|
780
|
+
sessionId: string;
|
|
781
|
+
token: string;
|
|
782
|
+
}
|
|
783
|
+
interface HealthResponse {
|
|
784
|
+
healthy: boolean;
|
|
785
|
+
}
|
|
786
|
+
interface DaemonInfo {
|
|
787
|
+
version: string;
|
|
788
|
+
uptimeSecs: number;
|
|
789
|
+
runningProcesses: number;
|
|
790
|
+
totalProcesses: number;
|
|
791
|
+
}
|
|
792
|
+
interface SandboxClientOptions {
|
|
793
|
+
apiUrl?: string;
|
|
794
|
+
apiKey?: string;
|
|
795
|
+
organizationId?: string;
|
|
796
|
+
projectId?: string;
|
|
797
|
+
namespace?: string;
|
|
798
|
+
maxRetries?: number;
|
|
799
|
+
retryBackoffMs?: number;
|
|
800
|
+
/**
|
|
801
|
+
* HTTP request timeout in seconds. For a streamed response it bounds the
|
|
802
|
+
* wait for the stream to start and each wait for more data. Default: 300.
|
|
803
|
+
*/
|
|
804
|
+
requestTimeout?: number;
|
|
805
|
+
/** @deprecated Use requestTimeout. HTTP request timeout in milliseconds. */
|
|
806
|
+
timeoutMs?: number;
|
|
807
|
+
}
|
|
808
|
+
interface SandboxOptions {
|
|
809
|
+
sandboxId: string;
|
|
810
|
+
/**
|
|
811
|
+
* Explicit sandbox proxy base URL. Direct `new Sandbox(...)` construction
|
|
812
|
+
* requires this; `Sandbox.connect()` and `SandboxClient.connect()` normally
|
|
813
|
+
* resolve the server-returned `sandboxUrl`.
|
|
814
|
+
*/
|
|
815
|
+
proxyUrl?: string;
|
|
816
|
+
/** @internal Real caller/env proxy override, distinct from an internally selected proxyUrl. */
|
|
817
|
+
explicitProxyUrl?: string;
|
|
818
|
+
apiKey?: string;
|
|
819
|
+
organizationId?: string;
|
|
820
|
+
projectId?: string;
|
|
821
|
+
routingHint?: string;
|
|
822
|
+
resolveProxyInfo?: (identifier: string) => Promise<SandboxInfo & {
|
|
823
|
+
readonly traceId: string;
|
|
824
|
+
}>;
|
|
825
|
+
/**
|
|
826
|
+
* Optional HTTP request timeout in seconds for sandbox proxy operations. For
|
|
827
|
+
* streamed responses, such as `run()` and output follows, it bounds the wait
|
|
828
|
+
* for the stream to start and each wait for more data. Omit for no proxy
|
|
829
|
+
* timeout.
|
|
830
|
+
*/
|
|
831
|
+
requestTimeout?: number;
|
|
832
|
+
/** @deprecated Use requestTimeout. Optional HTTP request timeout in milliseconds for sandbox proxy operations. */
|
|
833
|
+
timeoutMs?: number;
|
|
834
|
+
/**
|
|
835
|
+
* @internal Shared Rust-backed lifecycle client. When provided, the proxy
|
|
836
|
+
* client is minted via `connectProxy` so it reuses this client's connection
|
|
837
|
+
* pool (HTTP/2 coalescing across sandboxes).
|
|
838
|
+
*/
|
|
839
|
+
nativeClient?: NativeSandboxClient;
|
|
840
|
+
}
|
|
841
|
+
interface CreateAndConnectOptions extends CreateSandboxOptions {
|
|
842
|
+
poolId?: string;
|
|
843
|
+
proxyUrl?: string;
|
|
844
|
+
/** Total HTTP request timeout in seconds for sandbox startup. Default: client requestTimeout. */
|
|
845
|
+
requestTimeout?: number;
|
|
846
|
+
/** @deprecated Use requestTimeout. */
|
|
847
|
+
startupTimeout?: number;
|
|
848
|
+
/**
|
|
849
|
+
* Delete the sandbox when `requestTimeout` runs out while it is still
|
|
850
|
+
* pending, then throw `SandboxError` (the pre-ADR-0086 behaviour). Default
|
|
851
|
+
* false: throw `SandboxPending` and leave the sandbox queued.
|
|
852
|
+
*/
|
|
853
|
+
cancelOnTimeout?: boolean;
|
|
854
|
+
/** Seconds between readiness polls. Default: 2. */
|
|
855
|
+
pollInterval?: number;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Options for `Sandbox.getOrCreate`: everything `create` accepts (used only
|
|
859
|
+
* when a new sandbox must be created; `name` comes from the first argument),
|
|
860
|
+
* plus `resume`. `poolId` is excluded: a pool claim cannot carry a name, so
|
|
861
|
+
* a claimed sandbox could never be found again by a later call.
|
|
862
|
+
*/
|
|
863
|
+
interface GetOrCreateOptions extends Omit<CreateAndConnectOptions, "name" | "poolId"> {
|
|
864
|
+
/** Resume a suspended sandbox before returning. Default: true. */
|
|
865
|
+
resume?: boolean;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* What `Sandbox.getOrCreate` did to bind the name, exposed as
|
|
869
|
+
* `sandbox.bindOutcome`:
|
|
870
|
+
*
|
|
871
|
+
* - `"created"`: nothing held the name; the call created a new sandbox.
|
|
872
|
+
* - `"attached"`: a sandbox already held the name and needed no resume.
|
|
873
|
+
* Includes a sandbox that was still starting (the call waited for it)
|
|
874
|
+
* and a suspended sandbox when `resume: false`.
|
|
875
|
+
* - `"resumed"`: the sandbox was suspended when the call found it and is
|
|
876
|
+
* running now.
|
|
877
|
+
*/
|
|
878
|
+
type GetOrCreateOutcome = "created" | "attached" | "resumed";
|
|
879
|
+
interface SuspendResumeOptions {
|
|
880
|
+
/** If false, fire-and-return without waiting for completion. Default: true. */
|
|
881
|
+
wait?: boolean;
|
|
882
|
+
/** Max seconds to wait when wait=true. Default: 300. */
|
|
883
|
+
timeout?: number;
|
|
884
|
+
/** Seconds between status polls when wait=true. Default: 1. */
|
|
885
|
+
pollInterval?: number;
|
|
886
|
+
}
|
|
887
|
+
interface CheckpointOptions extends SuspendResumeOptions {
|
|
888
|
+
checkpointType?: CheckpointType;
|
|
889
|
+
/** Defaults to `"local_ready"`, which is enough to resume from a checkpoint. */
|
|
890
|
+
waitUntil?: SnapshotWaitCondition;
|
|
891
|
+
}
|
|
892
|
+
interface ConnectOptions {
|
|
893
|
+
sandboxId: string;
|
|
894
|
+
proxyUrl?: string;
|
|
895
|
+
routingHint?: string;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
type MouseButton = "left" | "middle" | "right";
|
|
899
|
+
interface ConnectDesktopOptions {
|
|
900
|
+
/** Remote VNC port. Defaults to `5901`. */
|
|
901
|
+
port?: number;
|
|
902
|
+
/** Optional VNC password for classic VNC authentication. */
|
|
903
|
+
password?: string;
|
|
904
|
+
/** Whether to request a shared VNC session. Defaults to `true`. */
|
|
905
|
+
shared?: boolean;
|
|
906
|
+
/** Seconds to wait while opening the desktop session. Defaults to `10`. */
|
|
907
|
+
connectTimeout?: number;
|
|
908
|
+
}
|
|
909
|
+
interface DesktopPointerOptions {
|
|
910
|
+
button?: MouseButton;
|
|
911
|
+
x?: number;
|
|
912
|
+
y?: number;
|
|
913
|
+
}
|
|
914
|
+
interface DesktopDoubleClickOptions extends DesktopPointerOptions {
|
|
915
|
+
delayMs?: number;
|
|
916
|
+
}
|
|
917
|
+
interface DesktopConnectRequest extends ConnectDesktopOptions {
|
|
918
|
+
baseUrl: string;
|
|
919
|
+
wsHeaders: Record<string, string>;
|
|
920
|
+
}
|
|
921
|
+
declare class Desktop {
|
|
922
|
+
private session;
|
|
923
|
+
private readonly connectRequest;
|
|
924
|
+
private operationChain;
|
|
925
|
+
private reconnectPromise;
|
|
926
|
+
private closed;
|
|
927
|
+
private constructor();
|
|
928
|
+
static connect(options: DesktopConnectRequest): Promise<Desktop>;
|
|
929
|
+
get width(): number;
|
|
930
|
+
get height(): number;
|
|
931
|
+
close(): Promise<void>;
|
|
932
|
+
screenshot(timeout?: number): Promise<Uint8Array>;
|
|
933
|
+
getFrameVersion(): number;
|
|
934
|
+
screenshotAfter(frameVersion: number, timeout?: number): Promise<Uint8Array>;
|
|
935
|
+
moveMouse(x: number, y: number): Promise<void>;
|
|
936
|
+
mousePress(options?: DesktopPointerOptions): Promise<void>;
|
|
937
|
+
mouseRelease(options?: DesktopPointerOptions): Promise<void>;
|
|
938
|
+
click(options?: DesktopPointerOptions): Promise<void>;
|
|
939
|
+
doubleClick(options?: DesktopDoubleClickOptions): Promise<void>;
|
|
940
|
+
leftClick(x?: number, y?: number): Promise<void>;
|
|
941
|
+
middleClick(x?: number, y?: number): Promise<void>;
|
|
942
|
+
rightClick(x?: number, y?: number): Promise<void>;
|
|
943
|
+
scroll(steps: number, x?: number, y?: number): Promise<void>;
|
|
944
|
+
scrollUp(steps?: number, x?: number, y?: number): Promise<void>;
|
|
945
|
+
scrollDown(steps?: number, x?: number, y?: number): Promise<void>;
|
|
946
|
+
keyDown(key: string): Promise<void>;
|
|
947
|
+
keyUp(key: string): Promise<void>;
|
|
948
|
+
press(keys: string | string[]): Promise<void>;
|
|
949
|
+
typeText(text: string): Promise<void>;
|
|
950
|
+
private enqueue;
|
|
951
|
+
private captureScreenshot;
|
|
952
|
+
private captureScreenshotAfter;
|
|
953
|
+
private reconnect;
|
|
954
|
+
private performReconnect;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
interface CreateTunnelOptions {
|
|
958
|
+
/** Local host/interface to bind. Defaults to `127.0.0.1`. */
|
|
959
|
+
localHost?: string;
|
|
960
|
+
/** Local port to bind. Defaults to the remote port. Use `0` for an ephemeral port. */
|
|
961
|
+
localPort?: number;
|
|
962
|
+
/** Seconds to wait for each websocket tunnel connection. Defaults to `10`. */
|
|
963
|
+
connectTimeout?: number;
|
|
964
|
+
}
|
|
965
|
+
interface TunnelAddress {
|
|
966
|
+
host: string;
|
|
967
|
+
port: number;
|
|
968
|
+
}
|
|
969
|
+
declare class TcpTunnel {
|
|
970
|
+
readonly remotePort: number;
|
|
971
|
+
readonly localHost: string;
|
|
972
|
+
readonly localPort: number;
|
|
973
|
+
private readonly baseUrl;
|
|
974
|
+
private readonly wsHeaders;
|
|
975
|
+
private readonly server;
|
|
976
|
+
private readonly connectTimeoutMs;
|
|
977
|
+
private readonly activeRelays;
|
|
978
|
+
private closePromise;
|
|
979
|
+
private constructor();
|
|
980
|
+
static listen(options: {
|
|
981
|
+
baseUrl: string;
|
|
982
|
+
wsHeaders: Record<string, string>;
|
|
983
|
+
remotePort: number;
|
|
984
|
+
localHost?: string;
|
|
985
|
+
localPort?: number;
|
|
986
|
+
connectTimeout?: number;
|
|
987
|
+
}): Promise<TcpTunnel>;
|
|
988
|
+
address(): TunnelAddress;
|
|
989
|
+
close(): Promise<void>;
|
|
990
|
+
private handleConnection;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
type PtyDataHandler = (data: Uint8Array) => void;
|
|
994
|
+
type PtyExitHandler = (exitCode: number) => void;
|
|
995
|
+
interface PtyConnectionOptions {
|
|
996
|
+
onData?: PtyDataHandler;
|
|
997
|
+
onExit?: PtyExitHandler;
|
|
998
|
+
}
|
|
999
|
+
interface CreatePtyOptions extends CreatePtySessionOptions, PtyConnectionOptions {
|
|
1000
|
+
}
|
|
1001
|
+
declare class Pty {
|
|
1002
|
+
readonly sessionId: string;
|
|
1003
|
+
readonly token: string;
|
|
1004
|
+
private readonly wsUrl;
|
|
1005
|
+
private readonly wsHeaders;
|
|
1006
|
+
private readonly killSession;
|
|
1007
|
+
private socket;
|
|
1008
|
+
private connectPromise;
|
|
1009
|
+
private intentionalDisconnect;
|
|
1010
|
+
private exitCode;
|
|
1011
|
+
private waitSettled;
|
|
1012
|
+
private readonly dataHandlers;
|
|
1013
|
+
private readonly exitHandlers;
|
|
1014
|
+
private readonly waitPromise;
|
|
1015
|
+
private resolveWait;
|
|
1016
|
+
private rejectWait;
|
|
1017
|
+
constructor(options: {
|
|
1018
|
+
sessionId: string;
|
|
1019
|
+
token: string;
|
|
1020
|
+
wsUrl: string;
|
|
1021
|
+
wsHeaders: Record<string, string>;
|
|
1022
|
+
killSession: () => Promise<void>;
|
|
1023
|
+
});
|
|
1024
|
+
onData(handler: PtyDataHandler): () => void;
|
|
1025
|
+
onExit(handler: PtyExitHandler): () => void;
|
|
1026
|
+
connect(): Promise<this>;
|
|
1027
|
+
sendInput(input: string | Uint8Array): Promise<void>;
|
|
1028
|
+
resize(cols: number, rows: number): Promise<void>;
|
|
1029
|
+
disconnect(code?: number, reason?: string): void;
|
|
1030
|
+
wait(): Promise<number>;
|
|
1031
|
+
kill(): Promise<void>;
|
|
1032
|
+
private requireOpenSocket;
|
|
1033
|
+
private finishWait;
|
|
1034
|
+
private failWait;
|
|
1035
|
+
}
|
|
1036
|
+
declare class Sandbox {
|
|
1037
|
+
traceId: string | null;
|
|
1038
|
+
/**
|
|
1039
|
+
* What {@link Sandbox.getOrCreate} did to bind the name: `"created"`,
|
|
1040
|
+
* `"attached"`, or `"resumed"`. `null` for handles from `create` or
|
|
1041
|
+
* `connect`.
|
|
1042
|
+
*/
|
|
1043
|
+
readonly bindOutcome: GetOrCreateOutcome | null;
|
|
1044
|
+
private readonly proxy;
|
|
1045
|
+
private ownsSandbox;
|
|
1046
|
+
private lifecycleClient;
|
|
1047
|
+
private lifecycleIdentifier;
|
|
1048
|
+
private sandboxName;
|
|
1049
|
+
constructor(options: SandboxOptions);
|
|
1050
|
+
/**
|
|
1051
|
+
* The server-assigned sandbox ID.
|
|
1052
|
+
*
|
|
1053
|
+
* A handle opened by name (`connect({ sandboxId: name })`) reports the
|
|
1054
|
+
* name until its first server response, then the canonical ID. Handles
|
|
1055
|
+
* from `create` and `getOrCreate` carry the canonical ID from the start.
|
|
1056
|
+
*/
|
|
1057
|
+
get sandboxId(): string;
|
|
1058
|
+
private get baseUrl();
|
|
1059
|
+
private get wsHeaders();
|
|
1060
|
+
get name(): string | null;
|
|
1061
|
+
/** @internal Used by client wiring to keep locally cached name in sync. */
|
|
1062
|
+
_setName(name: string | null): void;
|
|
1063
|
+
/** @internal Used by lifecycle operations to pin to canonical sandbox ID. */
|
|
1064
|
+
_setLifecycleIdentifier(identifier: string): void;
|
|
1065
|
+
/** @internal Used by the lazy proxy resolver. */
|
|
1066
|
+
_getLifecycleIdentifier(): string;
|
|
1067
|
+
/** @internal Used by SandboxClient.createAndConnect to set ownership. */
|
|
1068
|
+
_setOwner(client: SandboxClient): void;
|
|
1069
|
+
/** @internal Used by PendingSandbox.ready for a non-owning handle. */
|
|
1070
|
+
_setLifecycleClient(client: SandboxClient): void;
|
|
1071
|
+
/**
|
|
1072
|
+
* Create a new sandbox and return a connected, running handle.
|
|
1073
|
+
*
|
|
1074
|
+
* Covers both fresh sandbox creation and restore-from-snapshot (set
|
|
1075
|
+
* `snapshotId`). With `wait` unset or `true` it blocks until the sandbox
|
|
1076
|
+
* is `Running`: the create is sent with `wait: false` and the sandbox is
|
|
1077
|
+
* polled every two seconds, with `requestTimeout` as the wait budget.
|
|
1078
|
+
*
|
|
1079
|
+
* With `wait: false` it returns a {@link PendingSandbox} at once:
|
|
1080
|
+
* `pending.ready()` waits for it, `pending.status()` looks at it, and
|
|
1081
|
+
* `Sandbox.connect({ sandboxId: pending.sandboxId })` collects it from any
|
|
1082
|
+
* other process. This is the call for requesting many sandboxes ahead of
|
|
1083
|
+
* capacity. `wait: false` cannot be combined with `poolId`.
|
|
1084
|
+
*
|
|
1085
|
+
* **When the wait runs out the sandbox is not deleted.** A
|
|
1086
|
+
* `SandboxPending` is thrown carrying the sandbox id; the sandbox keeps
|
|
1087
|
+
* its place in the queue and starts whenever capacity arrives. Collect it
|
|
1088
|
+
* later with `Sandbox.connect` or delete it to give up. Pass
|
|
1089
|
+
* `cancelOnTimeout: true` for the previous delete-then-throw behaviour,
|
|
1090
|
+
* or `maxPendingSecs` to let the server fail it after a bound.
|
|
1091
|
+
*
|
|
1092
|
+
* When `name` is already claimed, the server rejects the create with
|
|
1093
|
+
* HTTP 409 (`RemoteAPIError`). To attach to the existing sandbox
|
|
1094
|
+
* instead, use {@link Sandbox.getOrCreate}.
|
|
1095
|
+
*/
|
|
1096
|
+
static create<O extends CreateAndConnectOptions & Partial<SandboxClientOptions> = CreateAndConnectOptions & Partial<SandboxClientOptions>>(options?: O): Promise<O extends {
|
|
1097
|
+
wait: false;
|
|
1098
|
+
} ? PendingSandbox : Sandbox>;
|
|
1099
|
+
/**
|
|
1100
|
+
* Attach to an existing sandbox and return a connected handle.
|
|
1101
|
+
*
|
|
1102
|
+
* The handle is lazy: when `proxyUrl` is omitted, the sandbox is resolved
|
|
1103
|
+
* on the first request so the handle uses the correct cloud/region ingress
|
|
1104
|
+
* endpoint. Connecting does not verify that the sandbox exists. Does
|
|
1105
|
+
* **not** auto-resume a suspended sandbox — call `sandbox.resume()`
|
|
1106
|
+
* explicitly.
|
|
1107
|
+
*/
|
|
1108
|
+
static connect(options: ConnectOptions & Partial<SandboxClientOptions>): Promise<Sandbox>;
|
|
1109
|
+
/**
|
|
1110
|
+
* Return the one sandbox bound to `name`. Create it on first use.
|
|
1111
|
+
*
|
|
1112
|
+
* This is the recommended call for an agent session that derives its
|
|
1113
|
+
* sandbox name from its session ID. It declares the intent "this name is
|
|
1114
|
+
* my session's sandbox": when a sandbox already holds the name, the call
|
|
1115
|
+
* attaches to it instead of failing with HTTP 409 the way `create` does.
|
|
1116
|
+
*
|
|
1117
|
+
* The steps, all handled internally:
|
|
1118
|
+
*
|
|
1119
|
+
* 1. `connect` by name — finds the sandbox, running or suspended.
|
|
1120
|
+
* 2. When nothing holds the name, `create` with the given configuration.
|
|
1121
|
+
* 3. When that create loses a race against another caller (HTTP 409),
|
|
1122
|
+
* connect to the winner.
|
|
1123
|
+
* 4. When the sandbox is still starting (another caller's create is in
|
|
1124
|
+
* flight), wait until it is `Running`, the same way `create` blocks
|
|
1125
|
+
* for its own caller.
|
|
1126
|
+
* 5. When the sandbox is suspended, `resume()` it. Disable with
|
|
1127
|
+
* `resume: false`.
|
|
1128
|
+
*
|
|
1129
|
+
* Concurrent callers that use the same name all converge on the same
|
|
1130
|
+
* sandbox. The configuration options (`image`, `cpus`, ...) apply only
|
|
1131
|
+
* when the call creates a new sandbox; an existing sandbox is returned
|
|
1132
|
+
* as-is, with whatever configuration it already has.
|
|
1133
|
+
*
|
|
1134
|
+
* The returned handle carries the canonical `sandboxId` (not the name)
|
|
1135
|
+
* and records what the call did in `bindOutcome`: `"created"`,
|
|
1136
|
+
* `"attached"`, or `"resumed"`. See {@link GetOrCreateOutcome}.
|
|
1137
|
+
*
|
|
1138
|
+
* For about a second after `terminate()`, the name still resolves and
|
|
1139
|
+
* the sandbox still reports `running`. A `getOrCreate` in that window
|
|
1140
|
+
* attaches to the dying sandbox. When you recreate right after a
|
|
1141
|
+
* terminate, check `status()` after the call, or wait for the old
|
|
1142
|
+
* sandbox to report `terminated` first.
|
|
1143
|
+
*
|
|
1144
|
+
* `poolId` is not accepted: a pool claim cannot carry a name, so a
|
|
1145
|
+
* claimed sandbox could never be found again by a later call. To use a
|
|
1146
|
+
* warm pool, `create` with `poolId` and name the sandbox afterwards
|
|
1147
|
+
* with `client.update(sandboxId, { name })`.
|
|
1148
|
+
*
|
|
1149
|
+
* @param name Sandbox name; unique within the namespace. Derive it
|
|
1150
|
+
* deterministically from your session ID, for example
|
|
1151
|
+
* `agent-${sessionId}`.
|
|
1152
|
+
* @param options Create options plus `resume` (default true: resume a
|
|
1153
|
+
* suspended sandbox before returning). Used only when a new sandbox
|
|
1154
|
+
* must be created, except connection-level options.
|
|
1155
|
+
* @throws {SandboxError} If the name stays claimed but its sandbox cannot
|
|
1156
|
+
* be attached to after several attempts (for example, the previous
|
|
1157
|
+
* holder is stuck terminating), or if a sandbox that is still starting
|
|
1158
|
+
* does not reach `Running` within `requestTimeout`.
|
|
1159
|
+
* @throws {RemoteAPIError} If the create step fails with a non-409 error.
|
|
1160
|
+
*/
|
|
1161
|
+
static getOrCreate(name: string, options?: GetOrCreateOptions & Partial<SandboxClientOptions>): Promise<Sandbox>;
|
|
1162
|
+
/** Get information about a snapshot by ID. No sandbox handle needed. */
|
|
1163
|
+
static getSnapshot(snapshotId: string, options?: Partial<SandboxClientOptions>): Promise<SnapshotInfo>;
|
|
1164
|
+
/** Delete a snapshot by ID. No sandbox handle needed. */
|
|
1165
|
+
static deleteSnapshot(snapshotId: string, options?: Partial<SandboxClientOptions>): Promise<void>;
|
|
1166
|
+
/** List all sandboxes. No sandbox handle needed. */
|
|
1167
|
+
static list(options?: Partial<SandboxClientOptions>): Promise<SandboxInfo[]>;
|
|
1168
|
+
/** List all snapshots in the project. No sandbox handle needed. */
|
|
1169
|
+
static listSnapshots(options?: Partial<SandboxClientOptions>): Promise<SnapshotInfo[]>;
|
|
1170
|
+
private requireLifecycleClient;
|
|
1171
|
+
/** Fetch the current sandbox information from the server on demand. */
|
|
1172
|
+
info(): Promise<Traced<SandboxInfo>>;
|
|
1173
|
+
/**
|
|
1174
|
+
* Fetch the current sandbox status from the server.
|
|
1175
|
+
*
|
|
1176
|
+
* Always hits the network — the value is not cached locally because the
|
|
1177
|
+
* status changes over the sandbox's lifecycle.
|
|
1178
|
+
*/
|
|
1179
|
+
status(): Promise<SandboxStatus>;
|
|
1180
|
+
/**
|
|
1181
|
+
* Update this sandbox's properties or resize its resources.
|
|
1182
|
+
*
|
|
1183
|
+
* Resource targets use create's cpus, memoryMb, and diskMb names. Resize
|
|
1184
|
+
* waits by default; wait=false returns admission. Timeout does not cancel it.
|
|
1185
|
+
* Wait, timeout, and pollInterval are ignored on non-resource updates.
|
|
1186
|
+
* A no-op returns current resources with absent or earlier resize metadata.
|
|
1187
|
+
*
|
|
1188
|
+
* Naming an ephemeral sandbox makes it non-ephemeral and enables
|
|
1189
|
+
* suspend/resume. For `network`, omit to keep the current policy, pass an
|
|
1190
|
+
* object to replace it, or pass `null` to clear it to unrestricted egress.
|
|
1191
|
+
*/
|
|
1192
|
+
update(options: UpdateSandboxOptions): Promise<Traced<SandboxInfo>>;
|
|
1193
|
+
/** Wait for this exact resize generation without submitting another update. */
|
|
1194
|
+
waitForResourceResize(generation: number, options?: ResourceResizeWaitOptions): Promise<Traced<SandboxInfo>>;
|
|
1195
|
+
/**
|
|
1196
|
+
* Suspend this sandbox.
|
|
1197
|
+
*
|
|
1198
|
+
* By default blocks until the sandbox is fully `Suspended`. Pass
|
|
1199
|
+
* `{ wait: false }` for fire-and-return.
|
|
1200
|
+
*/
|
|
1201
|
+
suspend(options?: SuspendResumeOptions): Promise<void>;
|
|
1202
|
+
/**
|
|
1203
|
+
* Resume this sandbox.
|
|
1204
|
+
*
|
|
1205
|
+
* By default blocks until the sandbox is `Running` and refreshes this
|
|
1206
|
+
* handle's cached proxy routing. Rare transient proxy errors may still occur
|
|
1207
|
+
* immediately after resume.
|
|
1208
|
+
*
|
|
1209
|
+
* Pass `{ wait: false }` for fire-and-return. That mode does not refresh
|
|
1210
|
+
* cached proxy routing on this handle; use the default wait behavior for
|
|
1211
|
+
* immediate follow-up operations, or wait until the sandbox is running and
|
|
1212
|
+
* reconnect before issuing process/file/PTY operations.
|
|
1213
|
+
*/
|
|
1214
|
+
resume(options?: SuspendResumeOptions): Promise<void>;
|
|
1215
|
+
/**
|
|
1216
|
+
* Poll until the sandbox leaves `Suspending`.
|
|
1217
|
+
*
|
|
1218
|
+
* The lifecycle API rejects resume while a suspend is still in progress,
|
|
1219
|
+
* so `getOrCreate` must wait for the suspend to settle before it can
|
|
1220
|
+
* resume the sandbox.
|
|
1221
|
+
*/
|
|
1222
|
+
private waitOutSuspending;
|
|
1223
|
+
/**
|
|
1224
|
+
* Poll until the sandbox is `Running` with routing info, then rebind this
|
|
1225
|
+
* handle's cached proxy routing. Shared by `resume()` and the
|
|
1226
|
+
* `getOrCreate` path that attaches to a still-starting sandbox.
|
|
1227
|
+
*/
|
|
1228
|
+
private refreshRoutingWhenRunning;
|
|
1229
|
+
/** Live-copy this running sandbox. */
|
|
1230
|
+
copy(options?: CopySandboxOptions): Promise<Traced<CopySandboxResponse>>;
|
|
1231
|
+
/**
|
|
1232
|
+
* Attach a registered file system to this running sandbox at `mountPath`.
|
|
1233
|
+
*
|
|
1234
|
+
* Returns the updated sandbox info; the new mount appears in
|
|
1235
|
+
* `fileSystems`. `options.snapshotId` pins the mount to a specific
|
|
1236
|
+
* filesystem snapshot and requires `options.readOnly: true`.
|
|
1237
|
+
*/
|
|
1238
|
+
attachFileSystem(fileSystemId: string, mountPath: string, options?: AttachFileSystemOptions): Promise<Traced<SandboxInfo>>;
|
|
1239
|
+
/**
|
|
1240
|
+
* Detach the file system mounted at `mountPath` from this running
|
|
1241
|
+
* sandbox.
|
|
1242
|
+
*
|
|
1243
|
+
* Returns the updated sandbox info with the mount removed from
|
|
1244
|
+
* `fileSystems`.
|
|
1245
|
+
*/
|
|
1246
|
+
detachFileSystem(mountPath: string): Promise<Traced<SandboxInfo>>;
|
|
1247
|
+
/** List the file systems currently mounted into this sandbox. */
|
|
1248
|
+
listFileSystems(): Promise<Traced<FileSystemMount[]>>;
|
|
1249
|
+
/**
|
|
1250
|
+
* Create a checkpoint of this sandbox and wait for it to be locally ready.
|
|
1251
|
+
*
|
|
1252
|
+
* By default blocks until the checkpoint is resumable and returns
|
|
1253
|
+
* `SnapshotInfo`. Pass `{ wait: false }` to fire-and-return
|
|
1254
|
+
* (returns `undefined`).
|
|
1255
|
+
*/
|
|
1256
|
+
checkpoint(options?: CheckpointOptions): Promise<Traced<SnapshotInfo> | undefined>;
|
|
1257
|
+
/**
|
|
1258
|
+
* List snapshots taken from this sandbox.
|
|
1259
|
+
*/
|
|
1260
|
+
listSnapshots(): Promise<Traced<SnapshotInfo[]>>;
|
|
1261
|
+
/** Close the proxy connection. The sandbox keeps running. */
|
|
1262
|
+
close(): void;
|
|
1263
|
+
/** Terminate the sandbox and release all resources. */
|
|
1264
|
+
terminate(): Promise<void>;
|
|
1265
|
+
/**
|
|
1266
|
+
* Run a command to completion and return its output.
|
|
1267
|
+
*
|
|
1268
|
+
* Uses a single streaming `POST /api/v1/processes/run` request that starts
|
|
1269
|
+
* the process, streams output, and delivers the exit code over one connection.
|
|
1270
|
+
*/
|
|
1271
|
+
run(command: string, options?: RunOptions): Promise<Traced<CommandResult>>;
|
|
1272
|
+
/**
|
|
1273
|
+
* Start a process in the sandbox without waiting for it to exit.
|
|
1274
|
+
*
|
|
1275
|
+
* Returns a `ProcessInfo` with the assigned `pid`. Use `getProcess()` to
|
|
1276
|
+
* poll status, or `followStdout()` / `followOutput()` to stream output
|
|
1277
|
+
* until the process exits. Use `run()` instead to block until completion
|
|
1278
|
+
* and get combined output in one call.
|
|
1279
|
+
*/
|
|
1280
|
+
startProcess(command: string, options?: StartProcessOptions): Promise<Traced<ProcessInfo>>;
|
|
1281
|
+
/** List all processes (running and exited) tracked by the sandbox daemon. */
|
|
1282
|
+
listProcesses(): Promise<Traced<ProcessInfo[]>>;
|
|
1283
|
+
/** Read persisted logs for this sandbox from the log service. */
|
|
1284
|
+
getLogs(options?: GetSandboxLogsOptions): Promise<Traced<SandboxLogsResponse>>;
|
|
1285
|
+
/** List processes available as persisted-log filters for this sandbox. */
|
|
1286
|
+
listLogProcesses(): Promise<Traced<SandboxProcessLogFiltersResponse>>;
|
|
1287
|
+
/** Get current status and metadata for a process. `process` is a PID or process name given on creation. */
|
|
1288
|
+
getProcess(process: number | string): Promise<Traced<ProcessInfo>>;
|
|
1289
|
+
/** Send SIGKILL to a process (or stop a managed process). `process` is a PID or process name given on creation. */
|
|
1290
|
+
killProcess(process: number | string): Promise<void>;
|
|
1291
|
+
/** Restart a managed process. `process` is a PID or process name given on creation. */
|
|
1292
|
+
restartProcess(process: number | string): Promise<Traced<ProcessInfo>>;
|
|
1293
|
+
/** Send an arbitrary signal (e.g. `15` for SIGTERM, `9` for SIGKILL). `process` is a PID or process name given on creation. */
|
|
1294
|
+
sendSignal(process: number | string, signal: number): Promise<Traced<SendSignalResponse>>;
|
|
1295
|
+
/** Write bytes to a process's stdin (must be started with `stdinMode: StdinMode.PIPE`). `process` is a PID or process name given on creation. */
|
|
1296
|
+
writeStdin(process: number | string, data: Uint8Array): Promise<void>;
|
|
1297
|
+
/** Close a process's stdin pipe, signalling EOF. `process` is a PID or process name given on creation. */
|
|
1298
|
+
closeStdin(process: number | string): Promise<void>;
|
|
1299
|
+
/** Return all captured stdout lines produced so far. `process` is a PID or process name given on creation. */
|
|
1300
|
+
getStdout(process: number | string): Promise<Traced<OutputResponse>>;
|
|
1301
|
+
/** Return all captured stderr lines produced so far. `process` is a PID or process name given on creation. */
|
|
1302
|
+
getStderr(process: number | string): Promise<Traced<OutputResponse>>;
|
|
1303
|
+
/** Return all captured stdout+stderr lines produced so far. `process` is a PID or process name given on creation. */
|
|
1304
|
+
getOutput(process: number | string): Promise<Traced<OutputResponse>>;
|
|
1305
|
+
/** Stream stdout events until the process exits. `process` is a PID or process name given on creation. */
|
|
1306
|
+
followStdout(process: number | string, options?: {
|
|
1307
|
+
signal?: AbortSignal;
|
|
1308
|
+
}): AsyncIterable<OutputEvent>;
|
|
1309
|
+
/** Stream stderr events until the process exits. `process` is a PID or process name given on creation. */
|
|
1310
|
+
followStderr(process: number | string, options?: {
|
|
1311
|
+
signal?: AbortSignal;
|
|
1312
|
+
}): AsyncIterable<OutputEvent>;
|
|
1313
|
+
/** Stream combined stdout+stderr events until the process exits. `process` is a PID or process name given on creation. */
|
|
1314
|
+
followOutput(process: number | string, options?: {
|
|
1315
|
+
signal?: AbortSignal;
|
|
1316
|
+
}): AsyncIterable<OutputEvent>;
|
|
1317
|
+
/** Read a file from the sandbox and return its raw bytes. */
|
|
1318
|
+
readFile(path: string): Promise<Traced<Uint8Array>>;
|
|
1319
|
+
/** Write raw bytes to a file in the sandbox, creating it if it does not exist. */
|
|
1320
|
+
writeFile(path: string, content: Uint8Array): Promise<void>;
|
|
1321
|
+
/** Delete a file from the sandbox. */
|
|
1322
|
+
deleteFile(path: string): Promise<void>;
|
|
1323
|
+
/** List the contents of a directory in the sandbox. */
|
|
1324
|
+
listDirectory(path: string): Promise<Traced<ListDirectoryResponse>>;
|
|
1325
|
+
/** Create an interactive PTY session. Returns a `sessionId` and `token` for WebSocket connection via `connectPty()`. */
|
|
1326
|
+
createPtySession(options: CreatePtySessionOptions): Promise<Traced<PtySessionInfo>>;
|
|
1327
|
+
/** Create a PTY session and connect to it immediately. Cleans up the session if the WebSocket connection fails. */
|
|
1328
|
+
createPty(options: CreatePtyOptions): Promise<Pty>;
|
|
1329
|
+
/** Attach to an existing PTY session by ID and token and return a connected `Pty` handle. */
|
|
1330
|
+
connectPty(sessionId: string, token: string, options?: PtyConnectionOptions): Promise<Pty>;
|
|
1331
|
+
/** Open a TCP tunnel to a port inside the sandbox and return the local listener. */
|
|
1332
|
+
createTunnel(remotePort: number, options?: CreateTunnelOptions): Promise<TcpTunnel>;
|
|
1333
|
+
/** Connect to a sandbox VNC session for programmatic desktop control. */
|
|
1334
|
+
connectDesktop(options?: ConnectDesktopOptions): Promise<Desktop>;
|
|
1335
|
+
/**
|
|
1336
|
+
* Poll the in-sandbox daemon until `127.0.0.1:port` accepts a TCP connection.
|
|
1337
|
+
* Uses `bash`'s `/dev/tcp` builtin via `processes/run` — no extra deps in
|
|
1338
|
+
* the sandbox image. `bash` is present on every image we ship.
|
|
1339
|
+
*/
|
|
1340
|
+
private waitForPortReady;
|
|
1341
|
+
ptyWsUrl(sessionId: string, token: string): string;
|
|
1342
|
+
/** Check the sandbox daemon health. */
|
|
1343
|
+
health(): Promise<Traced<HealthResponse>>;
|
|
1344
|
+
/** Get sandbox daemon info (version, uptime, process counts). */
|
|
1345
|
+
daemonInfo(): Promise<Traced<DaemonInfo>>;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
/** @internal How a client binds a handle it issued. */
|
|
1349
|
+
interface PendingSandboxBinding {
|
|
1350
|
+
client: SandboxClient;
|
|
1351
|
+
proxyUrl?: string;
|
|
1352
|
+
requestTimeout?: number;
|
|
1353
|
+
requestedName?: string | null;
|
|
1354
|
+
ownsSandbox: boolean;
|
|
1355
|
+
traceId: string;
|
|
1356
|
+
}
|
|
1357
|
+
/**
|
|
1358
|
+
* A sandbox requested with `wait: false`: the handle returned by
|
|
1359
|
+
* `Sandbox.create({ wait: false })` / `SandboxClient.create({ wait: false })`.
|
|
1360
|
+
*
|
|
1361
|
+
* The sandbox is durable and starts whenever capacity allows. Collect it
|
|
1362
|
+
* with {@link PendingSandbox.ready}, look at it with
|
|
1363
|
+
* {@link PendingSandbox.status}, or from any other process with
|
|
1364
|
+
* `Sandbox.connect({ sandboxId })` (which waits while it is pending) or
|
|
1365
|
+
* `client.list()`. `pendingReason` is `scheduling` at create time; the
|
|
1366
|
+
* capacity reasons appear after the first scheduler pass.
|
|
1367
|
+
*/
|
|
1368
|
+
declare class PendingSandbox implements PendingSandboxRecord {
|
|
1369
|
+
private readonly binding;
|
|
1370
|
+
readonly sandboxId: string;
|
|
1371
|
+
readonly name?: string;
|
|
1372
|
+
readonly state: SandboxStatus;
|
|
1373
|
+
readonly pendingReason?: string;
|
|
1374
|
+
readonly routingHint?: string;
|
|
1375
|
+
readonly ingressEndpoint?: string;
|
|
1376
|
+
readonly sandboxUrl?: string;
|
|
1377
|
+
readonly reason?: string;
|
|
1378
|
+
readonly terminationReason?: string;
|
|
1379
|
+
readonly errorDetails?: unknown;
|
|
1380
|
+
/** W3C trace id of the create request. */
|
|
1381
|
+
readonly traceId: string;
|
|
1382
|
+
/** @internal */
|
|
1383
|
+
constructor(record: PendingSandboxRecord, binding: PendingSandboxBinding);
|
|
1384
|
+
/** Fetch the sandbox's current state with one `GET`. */
|
|
1385
|
+
status(): Promise<Traced<SandboxInfo>>;
|
|
1386
|
+
/**
|
|
1387
|
+
* Wait for the sandbox to be running and return a connected `Sandbox`.
|
|
1388
|
+
*
|
|
1389
|
+
* Polls `GET /sandboxes/{id}` every `pollInterval` seconds (default 2).
|
|
1390
|
+
* Call it again after a `SandboxPending` to keep waiting.
|
|
1391
|
+
*
|
|
1392
|
+
* @throws {SandboxPending} `timeout` elapsed while the sandbox was still
|
|
1393
|
+
* pending. It keeps its place in the queue; the error carries
|
|
1394
|
+
* `sandboxId` and `pendingReason`.
|
|
1395
|
+
* @throws {SandboxError} The sandbox settled somewhere else: `terminated`
|
|
1396
|
+
* or `failed` (`reason` is the server's, such as `no_capacity` or
|
|
1397
|
+
* `cancelled`), or `suspended`.
|
|
1398
|
+
*/
|
|
1399
|
+
ready(options?: ReadyOptions): Promise<Sandbox>;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* Client for managing TensorLake sandboxes, pools, and snapshots.
|
|
1404
|
+
*
|
|
1405
|
+
* This is a thin shim over the Rust core ({@link NativeSandboxClient}): every
|
|
1406
|
+
* call marshals a request to JSON, delegates the RPC (URL resolution,
|
|
1407
|
+
* namespacing, retries, connection pooling) to Rust, and reshapes the JSON
|
|
1408
|
+
* response. There is no TypeScript-side HTTP transport.
|
|
1409
|
+
*/
|
|
1410
|
+
declare class SandboxClient {
|
|
1411
|
+
private readonly native;
|
|
1412
|
+
private readonly apiUrl;
|
|
1413
|
+
private readonly apiKey;
|
|
1414
|
+
private readonly organizationId;
|
|
1415
|
+
private readonly projectId;
|
|
1416
|
+
private readonly namespace;
|
|
1417
|
+
private readonly requestTimeoutMs;
|
|
1418
|
+
/** @internal Pass `true` to suppress the deprecation warning when used by `Sandbox.create()` / `Sandbox.connect()`. */
|
|
1419
|
+
constructor(options?: SandboxClientOptions, _internal?: boolean);
|
|
1420
|
+
/**
|
|
1421
|
+
* Create an API-key client for TensorLake Cloud. Ingress selects the authorized
|
|
1422
|
+
* organization/project; explicit scope options are forwarded only as compatibility headers.
|
|
1423
|
+
*/
|
|
1424
|
+
static forCloud(options?: {
|
|
1425
|
+
apiKey?: string;
|
|
1426
|
+
organizationId?: string;
|
|
1427
|
+
projectId?: string;
|
|
1428
|
+
apiUrl?: string;
|
|
1429
|
+
requestTimeout?: number;
|
|
1430
|
+
timeoutMs?: number;
|
|
1431
|
+
}): SandboxClient;
|
|
1432
|
+
/** Create a client for a local Indexify server. */
|
|
1433
|
+
static forLocalhost(options?: {
|
|
1434
|
+
apiUrl?: string;
|
|
1435
|
+
namespace?: string;
|
|
1436
|
+
requestTimeout?: number;
|
|
1437
|
+
timeoutMs?: number;
|
|
1438
|
+
}): SandboxClient;
|
|
1439
|
+
close(): void;
|
|
1440
|
+
private withRequestTimeout;
|
|
1441
|
+
/** Run a native JSON call and reshape it into a `Traced<T>`. */
|
|
1442
|
+
private tracedJson;
|
|
1443
|
+
/** Run a native JSON call and reshape it into a plain `T` (no trace id). */
|
|
1444
|
+
private plainJson;
|
|
1445
|
+
/**
|
|
1446
|
+
* Create a new sandbox.
|
|
1447
|
+
*
|
|
1448
|
+
* With `wait` unset or `true` the server waits for readiness for at most
|
|
1449
|
+
* the request timeout and answers the blocking create's record (`status`
|
|
1450
|
+
* may already be `running`); this is the wire behaviour unchanged. With
|
|
1451
|
+
* `wait: false` the server answers as soon as the sandbox is durable and
|
|
1452
|
+
* this returns a {@link PendingSandbox} at once: `pending.ready()` waits
|
|
1453
|
+
* for it, `pending.status()` looks at it, and `connect(sandboxId)`
|
|
1454
|
+
* collects it from any other process. Give the sandbox a `name` when a
|
|
1455
|
+
* retry of this call must not create a second one: a repeated name is an
|
|
1456
|
+
* HTTP 409, and `Sandbox.getOrCreate` resolves it. Use
|
|
1457
|
+
* `createAndConnect()` for a blocking, ready-to-use handle.
|
|
1458
|
+
*/
|
|
1459
|
+
create<O extends CreateSandboxOptions = CreateSandboxOptions>(options?: O): Promise<O extends {
|
|
1460
|
+
wait: false;
|
|
1461
|
+
} ? PendingSandbox : Traced<CreateSandboxResponse>>;
|
|
1462
|
+
/**
|
|
1463
|
+
* @internal Send the create with `wait: false` and return the pending
|
|
1464
|
+
* handle, bound to this client so `ready()` / `status()` work.
|
|
1465
|
+
*/
|
|
1466
|
+
requestPending(options: CreateSandboxOptions | undefined, binding: {
|
|
1467
|
+
proxyUrl?: string;
|
|
1468
|
+
requestTimeout?: number;
|
|
1469
|
+
ownsSandbox: boolean;
|
|
1470
|
+
}): Promise<PendingSandbox>;
|
|
1471
|
+
/** @internal Implementation of `PendingSandbox.ready`. */
|
|
1472
|
+
_ready(sandboxId: string, binding: PendingSandboxBinding, options?: ReadyOptions): Promise<Sandbox>;
|
|
1473
|
+
/**
|
|
1474
|
+
* Poll `get` every `pollInterval` seconds until the sandbox leaves
|
|
1475
|
+
* `pending` or `timeout` elapses, resolving with the last observation.
|
|
1476
|
+
* Never rejects for a timeout and never deletes.
|
|
1477
|
+
*/
|
|
1478
|
+
private waitForSandbox;
|
|
1479
|
+
/** Turn the last observed sandbox state into a handle or an error. */
|
|
1480
|
+
private settleWait;
|
|
1481
|
+
/**
|
|
1482
|
+
* Routing for a lazy `connect` handle. A sandbox that is still pending is
|
|
1483
|
+
* waited on here rather than failing: readiness is a property of the
|
|
1484
|
+
* sandbox, not of the create call that requested it.
|
|
1485
|
+
*/
|
|
1486
|
+
private resolveRoutingInfo;
|
|
1487
|
+
/** @internal Build the create wire body; shared by `create` and `createAndConnect`. */
|
|
1488
|
+
static buildCreateRequestBody(options?: CreateSandboxOptions): Record<string, unknown>;
|
|
1489
|
+
/** Get current state and metadata for a sandbox by ID. */
|
|
1490
|
+
get(sandboxId: string): Promise<Traced<SandboxInfo>>;
|
|
1491
|
+
/** List all sandboxes in the namespace. */
|
|
1492
|
+
list(): Promise<Traced<SandboxInfo[]>>;
|
|
1493
|
+
/**
|
|
1494
|
+
* List archived (terminated) sandboxes in the namespace.
|
|
1495
|
+
*
|
|
1496
|
+
* Archived sandboxes are terminated sandboxes parked in the server's
|
|
1497
|
+
* archived sandboxes store until the server-configured TTL expires.
|
|
1498
|
+
*/
|
|
1499
|
+
listArchived(options?: ListArchivedSandboxesOptions): Promise<Traced<ListArchivedSandboxesResponse>>;
|
|
1500
|
+
/** Get a single archived sandbox by id. */
|
|
1501
|
+
getArchived(sandboxId: string): Promise<Traced<ArchivedSandboxInfo>>;
|
|
1502
|
+
/** Read persisted logs for a sandbox. */
|
|
1503
|
+
getLogs(sandboxId: string, options?: GetSandboxLogsOptions): Promise<Traced<SandboxLogsResponse>>;
|
|
1504
|
+
/** List sandbox processes available as persisted-log filters. */
|
|
1505
|
+
listLogProcesses(sandboxId: string): Promise<Traced<SandboxProcessLogFiltersResponse>>;
|
|
1506
|
+
/**
|
|
1507
|
+
* Update properties or resize a Running Cloud Hypervisor sandbox.
|
|
1508
|
+
* Resource names match create. Resize waits by default; wait=false returns
|
|
1509
|
+
* admission. Timeout leaves the resize running and reports its generation.
|
|
1510
|
+
* Wait, timeout, and pollInterval are ignored on non-resource updates.
|
|
1511
|
+
* A no-op returns current resources with absent or earlier resize metadata.
|
|
1512
|
+
*/
|
|
1513
|
+
update(sandboxId: string, options: UpdateSandboxOptions): Promise<Traced<SandboxInfo>>;
|
|
1514
|
+
/** Wait for this exact generation. Timeout leaves the resize running. */
|
|
1515
|
+
waitForResourceResize(sandboxId: string, generation: number, options?: ResourceResizeWaitOptions): Promise<Traced<SandboxInfo>>;
|
|
1516
|
+
/** Get the current proxy port settings for a sandbox. */
|
|
1517
|
+
getPortAccess(sandboxId: string): Promise<SandboxPortAccess>;
|
|
1518
|
+
/** Add one or more user ports to the sandbox proxy allowlist. */
|
|
1519
|
+
exposePorts(sandboxId: string, ports: number[], options?: {
|
|
1520
|
+
allowUnauthenticatedAccess?: boolean;
|
|
1521
|
+
}): Promise<SandboxInfo>;
|
|
1522
|
+
/** Remove one or more user ports from the sandbox proxy allowlist. */
|
|
1523
|
+
unexposePorts(sandboxId: string, ports: number[]): Promise<SandboxInfo>;
|
|
1524
|
+
/** Terminate and delete a sandbox. */
|
|
1525
|
+
delete(sandboxId: string): Promise<void>;
|
|
1526
|
+
/**
|
|
1527
|
+
* Suspend a named sandbox, preserving its state for later resume.
|
|
1528
|
+
*
|
|
1529
|
+
* Only sandboxes created with a `name` can be suspended; ephemeral sandboxes
|
|
1530
|
+
* cannot. By default blocks until the sandbox is fully `Suspended`. Pass
|
|
1531
|
+
* `{ wait: false }` to return immediately after the request is sent
|
|
1532
|
+
* (fire-and-return); the server processes the suspend asynchronously.
|
|
1533
|
+
*/
|
|
1534
|
+
suspend(sandboxId: string, options?: SuspendResumeOptions): Promise<void>;
|
|
1535
|
+
/**
|
|
1536
|
+
* Resume a suspended sandbox and bring it back to `Running`.
|
|
1537
|
+
*
|
|
1538
|
+
* By default blocks until the sandbox is `Running` and routable. Pass
|
|
1539
|
+
* `{ wait: false }` to return immediately after the request is sent
|
|
1540
|
+
* (fire-and-return); the server processes the resume asynchronously.
|
|
1541
|
+
*/
|
|
1542
|
+
resume(sandboxId: string, options?: SuspendResumeOptions): Promise<void>;
|
|
1543
|
+
/**
|
|
1544
|
+
* Attach a registered file system to a running sandbox at `mountPath`.
|
|
1545
|
+
*
|
|
1546
|
+
* The mount completes asynchronously on the dataplane; the returned
|
|
1547
|
+
* `SandboxInfo` already reflects the new entry in `fileSystems`.
|
|
1548
|
+
*
|
|
1549
|
+
* `options.snapshotId` pins the mount to a specific filesystem snapshot
|
|
1550
|
+
* and requires `options.readOnly: true`.
|
|
1551
|
+
*/
|
|
1552
|
+
attachFileSystem(sandboxId: string, fileSystemId: string, mountPath: string, options?: AttachFileSystemOptions): Promise<Traced<SandboxInfo>>;
|
|
1553
|
+
/**
|
|
1554
|
+
* Detach the file system mounted at `mountPath` from a running sandbox.
|
|
1555
|
+
*
|
|
1556
|
+
* The unmount completes asynchronously on the dataplane; the returned
|
|
1557
|
+
* `SandboxInfo` already reflects the removed `fileSystems` entry.
|
|
1558
|
+
*/
|
|
1559
|
+
detachFileSystem(sandboxId: string, mountPath: string): Promise<Traced<SandboxInfo>>;
|
|
1560
|
+
/**
|
|
1561
|
+
* Claim a warm sandbox from a pool, creating one if no warm containers are
|
|
1562
|
+
* available. Claim-specific file systems are ready before the sandbox is
|
|
1563
|
+
* reported as running.
|
|
1564
|
+
*/
|
|
1565
|
+
claim(poolId: string, options?: ClaimSandboxOptions): Promise<Traced<CreateSandboxResponse>>;
|
|
1566
|
+
/**
|
|
1567
|
+
* Live-copy a running sandbox.
|
|
1568
|
+
*
|
|
1569
|
+
* The server creates `times` running copies from the source sandbox. Partial
|
|
1570
|
+
* responses can include failed copies; inspect each returned sandbox's
|
|
1571
|
+
* `status` and `reason`.
|
|
1572
|
+
*/
|
|
1573
|
+
copy(sandboxId: string, options?: CopySandboxOptions): Promise<Traced<CopySandboxResponse>>;
|
|
1574
|
+
/**
|
|
1575
|
+
* Request a snapshot of a running sandbox's filesystem.
|
|
1576
|
+
*
|
|
1577
|
+
* This call **returns immediately** with a `snapshotId` and `in_progress`
|
|
1578
|
+
* status — the snapshot is created asynchronously. Poll `getSnapshot()` until
|
|
1579
|
+
* `local_ready`, `completed`, or `failed`, or use `snapshotAndWait()` to
|
|
1580
|
+
* block automatically.
|
|
1581
|
+
*/
|
|
1582
|
+
snapshot(sandboxId: string, options?: SnapshotOptions): Promise<CreateSnapshotResponse>;
|
|
1583
|
+
/** Get current status and metadata for a snapshot by ID. */
|
|
1584
|
+
getSnapshot(snapshotId: string): Promise<Traced<SnapshotInfo>>;
|
|
1585
|
+
/** List all snapshots in the namespace. */
|
|
1586
|
+
listSnapshots(): Promise<Traced<SnapshotInfo[]>>;
|
|
1587
|
+
/** Delete a snapshot by ID. */
|
|
1588
|
+
deleteSnapshot(snapshotId: string): Promise<void>;
|
|
1589
|
+
/**
|
|
1590
|
+
* Create a snapshot and block until it is locally ready.
|
|
1591
|
+
*
|
|
1592
|
+
* Combines `snapshot()` with polling `getSnapshot()` until `local_ready`
|
|
1593
|
+
* or `completed`. Pass `{ waitUntil: "completed" }` when durable
|
|
1594
|
+
* `snapshotUri` metadata is required.
|
|
1595
|
+
*/
|
|
1596
|
+
snapshotAndWait(sandboxId: string, options?: SnapshotAndWaitOptions): Promise<Traced<SnapshotInfo>>;
|
|
1597
|
+
/** Create a new sandbox pool with warm pre-booted containers. */
|
|
1598
|
+
createPool(options: CreatePoolOptions): Promise<CreateSandboxPoolResponse>;
|
|
1599
|
+
/** Get current state and metadata for a sandbox pool by ID. */
|
|
1600
|
+
getPool(poolId: string): Promise<SandboxPoolInfo>;
|
|
1601
|
+
/** List all sandbox pools in the namespace. */
|
|
1602
|
+
listPools(): Promise<Traced<SandboxPoolInfo[]>>;
|
|
1603
|
+
/**
|
|
1604
|
+
* Replace a pool configuration. Omit `network` to keep the pool's current
|
|
1605
|
+
* network policy, set it to replace the policy, or pass `null` to remove the
|
|
1606
|
+
* policy entirely. On a change the service recycles the pool's unclaimed
|
|
1607
|
+
* warm containers onto the new policy, while containers already claimed by
|
|
1608
|
+
* sandboxes keep the policy they booted with. CPU, memory, disk, image, and
|
|
1609
|
+
* entrypoint changes likewise recycle unclaimed warm containers
|
|
1610
|
+
* asynchronously. If suitable capacity is unavailable, stale warm
|
|
1611
|
+
* containers are not used as a fallback.
|
|
1612
|
+
*/
|
|
1613
|
+
updatePool(poolId: string, options: UpdatePoolOptions): Promise<SandboxPoolInfo>;
|
|
1614
|
+
/** Delete a sandbox pool. Fails if the pool has active containers. */
|
|
1615
|
+
deletePool(poolId: string): Promise<void>;
|
|
1616
|
+
/** Return a `Sandbox` handle for an existing running sandbox without verifying it exists. */
|
|
1617
|
+
connect(identifier: string, proxyUrl?: string, routingHint?: string, requestTimeout?: number, explicitProxyUrl?: string): Sandbox;
|
|
1618
|
+
/**
|
|
1619
|
+
* Create a sandbox, wait for it to reach `Running`, and return a connected handle.
|
|
1620
|
+
*
|
|
1621
|
+
* This is `create({ wait: false })` followed by `PendingSandbox.ready()`
|
|
1622
|
+
* polling every `pollInterval` seconds, with `requestTimeout` as the wait
|
|
1623
|
+
* budget, in one call. The returned `Sandbox` auto-terminates when
|
|
1624
|
+
* `terminate()` is called.
|
|
1625
|
+
*
|
|
1626
|
+
* **When the wait runs out the sandbox is not deleted.** A `SandboxPending`
|
|
1627
|
+
* is thrown with the sandbox id, and the sandbox keeps its place in the
|
|
1628
|
+
* queue and starts whenever capacity arrives; `connect` with that id to
|
|
1629
|
+
* collect it, or `delete` it to give up. Pass
|
|
1630
|
+
* `cancelOnTimeout: true` for the previous behaviour (delete, then throw
|
|
1631
|
+
* `SandboxError`), or set `maxPendingSecs` to let the server fail it after
|
|
1632
|
+
* a bound. A pool claim (`poolId`) answers from the server-side wait; a
|
|
1633
|
+
* claim that is still starting is then waited on the same way.
|
|
1634
|
+
*/
|
|
1635
|
+
createAndConnect(options?: CreateAndConnectOptions): Promise<Sandbox>;
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
declare class CloudClient {
|
|
1639
|
+
private readonly transport;
|
|
1640
|
+
private readonly organizationId?;
|
|
1641
|
+
private readonly projectId?;
|
|
1642
|
+
private readonly namespace;
|
|
1643
|
+
constructor(options?: CloudClientOptions);
|
|
1644
|
+
static forCloud(options?: CloudClientOptions): CloudClient;
|
|
1645
|
+
close(): void;
|
|
1646
|
+
upsertApplication(manifest: ApplicationManifest, codeZip: BinaryPayload, upgradeRunningRequests?: boolean): Promise<void>;
|
|
1647
|
+
deleteApplication(applicationName: string): Promise<void>;
|
|
1648
|
+
deleteSandboxImage(imageName: string): Promise<void>;
|
|
1649
|
+
/**
|
|
1650
|
+
* Look up a registered sandbox image (template) by its registered name.
|
|
1651
|
+
*
|
|
1652
|
+
* Returns the template, or `null` when no image with that name exists.
|
|
1653
|
+
* API-key clients may omit organization/project IDs and use the
|
|
1654
|
+
* token-scoped Platform API route directly. Explicit scope remains
|
|
1655
|
+
* available for PAT callers.
|
|
1656
|
+
*/
|
|
1657
|
+
findSandboxImageByName(imageName: string, options?: {
|
|
1658
|
+
organizationId?: string;
|
|
1659
|
+
projectId?: string;
|
|
1660
|
+
}): Promise<SandboxTemplate | null>;
|
|
1661
|
+
/**
|
|
1662
|
+
* List all registered sandbox images (templates), following pagination to
|
|
1663
|
+
* the end. API-key clients may omit organization/project IDs and use the
|
|
1664
|
+
* token-scoped Platform API route directly.
|
|
1665
|
+
*/
|
|
1666
|
+
listSandboxImages(options?: {
|
|
1667
|
+
organizationId?: string;
|
|
1668
|
+
projectId?: string;
|
|
1669
|
+
}): Promise<SandboxTemplate[]>;
|
|
1670
|
+
applications(): Promise<ApplicationSummary[]>;
|
|
1671
|
+
applicationManifest(applicationName: string): Promise<ApplicationManifest>;
|
|
1672
|
+
runRequest(applicationName: string, inputs?: RequestInput[]): Promise<string>;
|
|
1673
|
+
waitOnRequestCompletion(applicationName: string, requestId: string): Promise<void>;
|
|
1674
|
+
requestMetadata(applicationName: string, requestId: string): Promise<RequestMetadata>;
|
|
1675
|
+
requestOutput(applicationName: string, requestId: string): Promise<RequestOutput>;
|
|
1676
|
+
listSecrets(options?: {
|
|
1677
|
+
organizationId?: string;
|
|
1678
|
+
projectId?: string;
|
|
1679
|
+
pageSize?: number;
|
|
1680
|
+
}): Promise<SecretsList>;
|
|
1681
|
+
getSecret(secretId: string, options?: {
|
|
1682
|
+
organizationId?: string;
|
|
1683
|
+
projectId?: string;
|
|
1684
|
+
}): Promise<Secret>;
|
|
1685
|
+
upsertSecrets(secrets: NewSecret | NewSecret[], options?: {
|
|
1686
|
+
organizationId?: string;
|
|
1687
|
+
projectId?: string;
|
|
1688
|
+
}): Promise<UpsertSecretResponse>;
|
|
1689
|
+
deleteSecret(secretId: string, options?: {
|
|
1690
|
+
organizationId?: string;
|
|
1691
|
+
projectId?: string;
|
|
1692
|
+
}): Promise<void>;
|
|
1693
|
+
private upsertSecret;
|
|
1694
|
+
startImageBuild(buildServicePath: string, request: StartImageBuildRequest): Promise<BuildInfo>;
|
|
1695
|
+
createApplicationBuild(buildServicePath: string, request: CreateApplicationBuildRequest, imageContexts: ApplicationBuildContext[]): Promise<ApplicationBuildResponse>;
|
|
1696
|
+
applicationBuildInfo(buildServicePath: string, applicationBuildId: string): Promise<ApplicationBuildResponse>;
|
|
1697
|
+
cancelApplicationBuild(buildServicePath: string, applicationBuildId: string): Promise<ApplicationBuildResponse>;
|
|
1698
|
+
buildInfo(buildServicePath: string, buildId: string): Promise<BuildInfo>;
|
|
1699
|
+
cancelBuild(buildServicePath: string, buildId: string): Promise<void>;
|
|
1700
|
+
streamBuildLogs(buildServicePath: string, buildId: string, signal?: AbortSignal): AsyncIterable<BuildLogEntry>;
|
|
1701
|
+
private runMultipartRequest;
|
|
1702
|
+
private namespacePath;
|
|
1703
|
+
private existingApplicationPublicEndpointId;
|
|
1704
|
+
private platformProjectPath;
|
|
1705
|
+
private secretCollectionPath;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
/** Shared command runner for the separately installed local mount daemon. */
|
|
1709
|
+
declare class MountCli {
|
|
1710
|
+
private readonly command;
|
|
1711
|
+
private readonly envOverrides;
|
|
1712
|
+
private binary;
|
|
1713
|
+
constructor(command: "fs" | "git", envOverrides: Record<string, string>);
|
|
1714
|
+
private findCli;
|
|
1715
|
+
protected run(args: string[], timeoutMs?: number): Promise<string>;
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
interface RepositoryMountOptions {
|
|
1719
|
+
/** Stateless read-only view; cannot be combined with publish or workspace. */
|
|
1720
|
+
readOnly?: boolean;
|
|
1721
|
+
/** Publish each explicit snapshot onto the mounted branch. */
|
|
1722
|
+
publish?: boolean;
|
|
1723
|
+
/** Resume a private workspace; cannot be combined with publish or readOnly. */
|
|
1724
|
+
workspace?: string;
|
|
1725
|
+
}
|
|
1726
|
+
interface RepositoryUnmountOptions {
|
|
1727
|
+
/** Delete the private server workspace after detaching. Defaults to false. */
|
|
1728
|
+
deleteWorkspace?: boolean;
|
|
1729
|
+
/** Drop unpublished local state. Defaults to false. */
|
|
1730
|
+
discard?: boolean;
|
|
1731
|
+
}
|
|
1732
|
+
/** Stable fields from `tl git status --json`, with the full payload in raw. */
|
|
1733
|
+
interface RepositoryMountStatus {
|
|
1734
|
+
path: string;
|
|
1735
|
+
repository: string | null;
|
|
1736
|
+
reference: string | null;
|
|
1737
|
+
workspaceId: string | null;
|
|
1738
|
+
state: string | null;
|
|
1739
|
+
localChanges: boolean | null;
|
|
1740
|
+
raw: Record<string, unknown>;
|
|
1741
|
+
}
|
|
1742
|
+
/** @internal CLI implementation; obtain mounts through RepositoryClient. */
|
|
1743
|
+
declare class GitCli extends MountCli {
|
|
1744
|
+
constructor(envOverrides: Record<string, string>);
|
|
1745
|
+
mount(target: string, localPath: string, options?: RepositoryMountOptions): Promise<RepositoryMount>;
|
|
1746
|
+
unmount(localPath: string, options?: RepositoryUnmountOptions): Promise<void>;
|
|
1747
|
+
status(localPath?: string): Promise<RepositoryMountStatus>;
|
|
1748
|
+
snapshot(path: string, message?: string): Promise<void>;
|
|
1749
|
+
sync(path: string, target?: string): Promise<void>;
|
|
1750
|
+
rebase(path: string, target: string, failOnConflict: boolean): Promise<void>;
|
|
1751
|
+
promote(path: string, branch: string, merge: boolean): Promise<void>;
|
|
1752
|
+
prefetch(path: string): Promise<void>;
|
|
1753
|
+
}
|
|
1754
|
+
/** A repository mounted on the machine running Node.js via the `tl` CLI daemon. */
|
|
1755
|
+
declare class RepositoryMount {
|
|
1756
|
+
private readonly cli;
|
|
1757
|
+
/** Initial source (`repo[:ref][//subtree]`); sync/rebase can change the base. */
|
|
1758
|
+
readonly target: string;
|
|
1759
|
+
readonly path: string;
|
|
1760
|
+
readonly readOnly: boolean;
|
|
1761
|
+
/** @internal Obtain instances via RepositoryClient.mount(). */
|
|
1762
|
+
constructor(cli: GitCli,
|
|
1763
|
+
/** Initial source (`repo[:ref][//subtree]`); sync/rebase can change the base. */
|
|
1764
|
+
target: string, path: string, readOnly: boolean);
|
|
1765
|
+
/** Inspect workspace state, pending changes, and daemon diagnostics. */
|
|
1766
|
+
status(): Promise<RepositoryMountStatus>;
|
|
1767
|
+
/** Materialize autosaved edits as a commit; publish mounts also update their branch. */
|
|
1768
|
+
snapshot(message?: string): Promise<void>;
|
|
1769
|
+
/** Refresh the current source, or switch an unsnapshotted workspace to a new base. */
|
|
1770
|
+
sync(target?: string): Promise<void>;
|
|
1771
|
+
/** Replay snapshots and pending edits onto another base. Conflicts become diff3 markers by default. */
|
|
1772
|
+
rebase(target: string, options?: {
|
|
1773
|
+
failOnConflict?: boolean;
|
|
1774
|
+
}): Promise<void>;
|
|
1775
|
+
/** Publish the workspace to a branch; merge allows landing when the branch moved. */
|
|
1776
|
+
promote(branch: string, options?: {
|
|
1777
|
+
merge?: boolean;
|
|
1778
|
+
}): Promise<void>;
|
|
1779
|
+
/** Download and verify the mounted working set for network-free reads. */
|
|
1780
|
+
prefetch(): Promise<void>;
|
|
1781
|
+
/** Detach, retaining the private workspace and unpublished state unless explicitly requested. */
|
|
1782
|
+
unmount(options?: RepositoryUnmountOptions): Promise<void>;
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
interface RepositoryClientOptions {
|
|
1786
|
+
apiUrl?: string;
|
|
1787
|
+
apiKey?: string;
|
|
1788
|
+
/** @deprecated Scope is selected by ingress for SDK API keys; used only by local `tl` mounts. */
|
|
1789
|
+
organizationId?: string;
|
|
1790
|
+
/** @deprecated Scope is selected by ingress for SDK API keys; used only by local `tl` mounts. */
|
|
1791
|
+
projectId?: string;
|
|
1792
|
+
requestTimeout?: number;
|
|
1793
|
+
timeoutMs?: number;
|
|
1794
|
+
}
|
|
1795
|
+
interface GitRepository {
|
|
1796
|
+
name: string;
|
|
1797
|
+
fullName: string;
|
|
1798
|
+
defaultBranch: string;
|
|
1799
|
+
status: string;
|
|
1800
|
+
}
|
|
1801
|
+
interface RepositoryHandle {
|
|
1802
|
+
repo: string;
|
|
1803
|
+
url: string;
|
|
1804
|
+
baseRepo?: string;
|
|
1805
|
+
}
|
|
1806
|
+
interface GitRef {
|
|
1807
|
+
name: string;
|
|
1808
|
+
oid: string;
|
|
1809
|
+
}
|
|
1810
|
+
interface Branch {
|
|
1811
|
+
name: string;
|
|
1812
|
+
refName: string;
|
|
1813
|
+
oid: string;
|
|
1814
|
+
}
|
|
1815
|
+
interface RepositoryInfo {
|
|
1816
|
+
repo: string;
|
|
1817
|
+
url: string;
|
|
1818
|
+
branches: Branch[];
|
|
1819
|
+
refs: GitRef[];
|
|
1820
|
+
}
|
|
1821
|
+
interface GitCredential {
|
|
1822
|
+
token: string;
|
|
1823
|
+
tokenType: string;
|
|
1824
|
+
expiresAt: string;
|
|
1825
|
+
gitUsername: string;
|
|
1826
|
+
repoPattern: string;
|
|
1827
|
+
scopes: string[];
|
|
1828
|
+
}
|
|
1829
|
+
interface CommitJobReadBack {
|
|
1830
|
+
done: number;
|
|
1831
|
+
total: number;
|
|
1832
|
+
}
|
|
1833
|
+
interface CommitJobError {
|
|
1834
|
+
kind: string;
|
|
1835
|
+
message: string;
|
|
1836
|
+
retryable: boolean;
|
|
1837
|
+
}
|
|
1838
|
+
interface CommitJobStatus {
|
|
1839
|
+
jobId: string;
|
|
1840
|
+
state: string;
|
|
1841
|
+
phase?: string;
|
|
1842
|
+
readBack?: CommitJobReadBack;
|
|
1843
|
+
commit?: string;
|
|
1844
|
+
tree?: string;
|
|
1845
|
+
refName?: string;
|
|
1846
|
+
parent?: string;
|
|
1847
|
+
created?: boolean;
|
|
1848
|
+
error?: CommitJobError;
|
|
1849
|
+
}
|
|
1850
|
+
interface PushReport {
|
|
1851
|
+
commit: string;
|
|
1852
|
+
tree: string;
|
|
1853
|
+
refName: string;
|
|
1854
|
+
created: boolean;
|
|
1855
|
+
files: number;
|
|
1856
|
+
bytesTotal: number;
|
|
1857
|
+
chunksTotal: number;
|
|
1858
|
+
chunksUploaded: number;
|
|
1859
|
+
bytesUploaded: number;
|
|
1860
|
+
fileBlobOids: Array<[string, string]>;
|
|
1861
|
+
}
|
|
1862
|
+
interface PushWorktreeOptions {
|
|
1863
|
+
path?: string;
|
|
1864
|
+
branch?: string;
|
|
1865
|
+
message?: string;
|
|
1866
|
+
expectOid?: string;
|
|
1867
|
+
}
|
|
1868
|
+
interface MergeEntry {
|
|
1869
|
+
mode: number;
|
|
1870
|
+
oid: string;
|
|
1871
|
+
}
|
|
1872
|
+
interface MergeConflict {
|
|
1873
|
+
path: string;
|
|
1874
|
+
kind: string;
|
|
1875
|
+
potential: boolean;
|
|
1876
|
+
ours?: MergeEntry;
|
|
1877
|
+
base?: MergeEntry;
|
|
1878
|
+
theirs?: MergeEntry;
|
|
1879
|
+
}
|
|
1880
|
+
interface MergeStats {
|
|
1881
|
+
treesRead: number;
|
|
1882
|
+
entriesCompared: number;
|
|
1883
|
+
blobsMerged: number;
|
|
1884
|
+
wallMs: number;
|
|
1885
|
+
}
|
|
1886
|
+
interface MergeReport {
|
|
1887
|
+
ours: string;
|
|
1888
|
+
theirs: string;
|
|
1889
|
+
mergeBase?: string;
|
|
1890
|
+
clean: boolean;
|
|
1891
|
+
fastForward: boolean;
|
|
1892
|
+
alreadyMerged: boolean;
|
|
1893
|
+
changedPaths: number;
|
|
1894
|
+
conflicts: MergeConflict[];
|
|
1895
|
+
stats: MergeStats;
|
|
1896
|
+
commit?: string;
|
|
1897
|
+
fastForwarded: boolean;
|
|
1898
|
+
}
|
|
1899
|
+
interface MergeOptions {
|
|
1900
|
+
preflight?: boolean;
|
|
1901
|
+
deep?: boolean;
|
|
1902
|
+
materialize?: boolean;
|
|
1903
|
+
message?: string;
|
|
1904
|
+
base?: string;
|
|
1905
|
+
}
|
|
1906
|
+
interface ConflictTerm {
|
|
1907
|
+
mode: number;
|
|
1908
|
+
oid: string;
|
|
1909
|
+
}
|
|
1910
|
+
interface ConflictPath {
|
|
1911
|
+
path: string;
|
|
1912
|
+
kind: string;
|
|
1913
|
+
terms: Array<ConflictTerm | null>;
|
|
1914
|
+
}
|
|
1915
|
+
interface MergeConflictRecord {
|
|
1916
|
+
version: number;
|
|
1917
|
+
oursCommit: string;
|
|
1918
|
+
theirsCommit: string;
|
|
1919
|
+
baseCommit?: string;
|
|
1920
|
+
paths: ConflictPath[];
|
|
1921
|
+
truncatedPaths: number;
|
|
1922
|
+
}
|
|
1923
|
+
interface OperationRef {
|
|
1924
|
+
name: string;
|
|
1925
|
+
old?: string;
|
|
1926
|
+
new?: string;
|
|
1927
|
+
}
|
|
1928
|
+
interface Operation {
|
|
1929
|
+
opId: string;
|
|
1930
|
+
repo: string;
|
|
1931
|
+
network?: string;
|
|
1932
|
+
parentOpId?: string;
|
|
1933
|
+
actor: string;
|
|
1934
|
+
atSecs: number;
|
|
1935
|
+
kind: string;
|
|
1936
|
+
result: string;
|
|
1937
|
+
refs: OperationRef[];
|
|
1938
|
+
packIds: string[];
|
|
1939
|
+
oldPackIds: string[];
|
|
1940
|
+
relatedRepo?: string;
|
|
1941
|
+
status?: string;
|
|
1942
|
+
oldPackCount: number;
|
|
1943
|
+
objectCount: number;
|
|
1944
|
+
packBytes: number;
|
|
1945
|
+
}
|
|
1946
|
+
declare class RepositoryClient {
|
|
1947
|
+
private readonly native;
|
|
1948
|
+
private readonly requestTimeoutMs;
|
|
1949
|
+
private readonly cli;
|
|
1950
|
+
constructor(options?: RepositoryClientOptions);
|
|
1951
|
+
static forCloud(options?: RepositoryClientOptions): RepositoryClient;
|
|
1952
|
+
static fromEnv(): Promise<RepositoryClient>;
|
|
1953
|
+
close(): void;
|
|
1954
|
+
/**
|
|
1955
|
+
* Mount `repo[:branch|tag|full-commit][//subtree]` to a local directory.
|
|
1956
|
+
* Requires the separately installed `tl` CLI with mount support. Mounts
|
|
1957
|
+
* live on the machine running Node.js and must be explicitly unmounted.
|
|
1958
|
+
*/
|
|
1959
|
+
mount(target: string, localPath: string, options?: RepositoryMountOptions): Promise<RepositoryMount>;
|
|
1960
|
+
/** Detach a local repository mount, optionally deleting its private workspace. */
|
|
1961
|
+
unmount(localPath: string, options?: RepositoryUnmountOptions): Promise<void>;
|
|
1962
|
+
/** Inspect a local mount; defaults to the mount containing the current directory. */
|
|
1963
|
+
mountStatus(localPath?: string): Promise<RepositoryMountStatus>;
|
|
1964
|
+
url(repo: string): Promise<string>;
|
|
1965
|
+
create(repo: string, options?: {
|
|
1966
|
+
defaultBranch?: string;
|
|
1967
|
+
}): Promise<Traced<RepositoryHandle>>;
|
|
1968
|
+
list(): Promise<Traced<GitRepository[]>>;
|
|
1969
|
+
delete(repo: string): Promise<void>;
|
|
1970
|
+
fork(repo: string, baseRepo: string): Promise<Traced<RepositoryHandle>>;
|
|
1971
|
+
archive(repo: string): Promise<void>;
|
|
1972
|
+
restore(repo: string): Promise<void>;
|
|
1973
|
+
info(repo: string): Promise<Traced<RepositoryInfo>>;
|
|
1974
|
+
branches(repo: string): Promise<Traced<Branch[]>>;
|
|
1975
|
+
refs(repo: string): Promise<Traced<GitRef[]>>;
|
|
1976
|
+
deleteBranch(repo: string, branch: string): Promise<void>;
|
|
1977
|
+
operations(repo: string): Promise<Traced<Operation[]>>;
|
|
1978
|
+
credential(repo?: string): Promise<GitCredential>;
|
|
1979
|
+
commitStatus(repo: string, jobId: string): Promise<Traced<CommitJobStatus>>;
|
|
1980
|
+
pushWorktree(repo: string, options?: PushWorktreeOptions): Promise<Traced<PushReport>>;
|
|
1981
|
+
merge(repo: string, ours: string, theirs: string, options?: MergeOptions): Promise<Traced<MergeReport>>;
|
|
1982
|
+
commitConflicts(repo: string, commit: string): Promise<Traced<MergeConflictRecord> | null>;
|
|
1983
|
+
private tracedJson;
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
/**
|
|
1987
|
+
* Compatibility helpers for Artifact Storage filesystems.
|
|
1988
|
+
*
|
|
1989
|
+
* New code should use {@link FilesystemClient} directly. These helpers retain
|
|
1990
|
+
* the original create/list/delete API and authenticate with
|
|
1991
|
+
* `TENSORLAKE_API_KEY`; ingress selects the project scope.
|
|
1992
|
+
*
|
|
1993
|
+
* To mount a registered file system into a sandbox, pass
|
|
1994
|
+
* `fileSystems` to `Sandbox.create()` (including warm-pool claims) or call
|
|
1995
|
+
* `sandbox.attachFileSystem()` / `sandbox.detachFileSystem()` on a
|
|
1996
|
+
* running sandbox.
|
|
1997
|
+
*/
|
|
1998
|
+
/** Register a new file system for the current project. */
|
|
1999
|
+
declare function createFileSystem(name: string, description?: string, options?: {
|
|
2000
|
+
region?: string;
|
|
2001
|
+
}): Promise<FileSystem>;
|
|
2002
|
+
/** List all registered file systems for the current project. */
|
|
2003
|
+
declare function listFileSystems(): Promise<FileSystem[]>;
|
|
2004
|
+
/** Delete a registered file system by its id (e.g. `file_system_...`). */
|
|
2005
|
+
declare function deleteFileSystem(fileSystemId: string): Promise<void>;
|
|
2006
|
+
|
|
2007
|
+
/** One filesystem as returned by listing/point-read endpoints. */
|
|
2008
|
+
interface FilesystemInfo {
|
|
2009
|
+
name: string;
|
|
2010
|
+
fullName: string;
|
|
2011
|
+
status: string;
|
|
2012
|
+
kind: string;
|
|
2013
|
+
}
|
|
2014
|
+
/** Remote status of a filesystem: identity plus current head. */
|
|
2015
|
+
interface FilesystemStatus {
|
|
2016
|
+
name: string;
|
|
2017
|
+
status: string;
|
|
2018
|
+
/**
|
|
2019
|
+
* Current native version id; null for an empty filesystem that has never
|
|
2020
|
+
* been written to.
|
|
2021
|
+
*/
|
|
2022
|
+
versionId: string | null;
|
|
2023
|
+
/** Server-side movement counter for the live version, when reported. */
|
|
2024
|
+
generation: number | null;
|
|
2025
|
+
}
|
|
2026
|
+
/** One directory entry from a filesystem listing. */
|
|
2027
|
+
interface FileEntry {
|
|
2028
|
+
name: string;
|
|
2029
|
+
/** Path of the entry relative to the filesystem root. */
|
|
2030
|
+
path: string;
|
|
2031
|
+
/** Stable native content identity for the file or directory. */
|
|
2032
|
+
contentId: string;
|
|
2033
|
+
/** Native entry kind. */
|
|
2034
|
+
kind: "file" | "directory" | "symlink";
|
|
2035
|
+
/** Whether a regular file is executable. */
|
|
2036
|
+
executable: boolean;
|
|
2037
|
+
/** Blob size in bytes when cheaply known server-side. */
|
|
2038
|
+
size: number | null;
|
|
2039
|
+
isDir: boolean;
|
|
2040
|
+
isSymlink: boolean;
|
|
2041
|
+
}
|
|
2042
|
+
/** Bytes plus immutable identity/size returned by one file request. */
|
|
2043
|
+
interface FilesystemFileRead {
|
|
2044
|
+
data: Uint8Array;
|
|
2045
|
+
/** Stable native identity for the complete file content. */
|
|
2046
|
+
contentId: string;
|
|
2047
|
+
/** Size of the complete file, even when `data` is a requested range. */
|
|
2048
|
+
size: number;
|
|
2049
|
+
}
|
|
2050
|
+
interface FilesystemReadOptions {
|
|
2051
|
+
/** Current `main` head when omitted; otherwise one retained snapshot id. */
|
|
2052
|
+
version?: string;
|
|
2053
|
+
/** Half-open byte selection expressed as offset + length. */
|
|
2054
|
+
range?: {
|
|
2055
|
+
offset: number;
|
|
2056
|
+
length: number;
|
|
2057
|
+
};
|
|
2058
|
+
}
|
|
2059
|
+
/** The durable live version produced by one atomic filesystem publication. */
|
|
2060
|
+
interface FilesystemVersion {
|
|
2061
|
+
/** Native version id — pass as `version` to read the filesystem at this point. */
|
|
2062
|
+
versionId: string;
|
|
2063
|
+
/** Version replaced by this publication, or null for the first publication. */
|
|
2064
|
+
previousVersionId: string | null;
|
|
2065
|
+
/** False when the write was a no-op (content identical to the parent). */
|
|
2066
|
+
created: boolean;
|
|
2067
|
+
message: string;
|
|
2068
|
+
}
|
|
2069
|
+
/** One newly retained native filesystem snapshot. */
|
|
2070
|
+
interface FilesystemSnapshot {
|
|
2071
|
+
id: string;
|
|
2072
|
+
message: string;
|
|
2073
|
+
}
|
|
2074
|
+
/** One explicitly retained native filesystem snapshot. */
|
|
2075
|
+
interface FilesystemSnapshotInfo {
|
|
2076
|
+
id: string;
|
|
2077
|
+
createdAt: Date;
|
|
2078
|
+
message: string;
|
|
2079
|
+
}
|
|
2080
|
+
/**
|
|
2081
|
+
* Status of a local mount as reported by `tl fs status --json`.
|
|
2082
|
+
*
|
|
2083
|
+
* The mount daemon's JSON is versioned independently of this SDK, so only
|
|
2084
|
+
* stable fields are typed; the full payload is preserved in `raw`.
|
|
2085
|
+
*/
|
|
2086
|
+
interface MountStatus {
|
|
2087
|
+
/** Local mount path. */
|
|
2088
|
+
path: string;
|
|
2089
|
+
/** Filesystem name this mount serves, when reported. */
|
|
2090
|
+
filesystem: string | null;
|
|
2091
|
+
/** Whether the daemon reports the mount as healthy/active. */
|
|
2092
|
+
mounted: boolean;
|
|
2093
|
+
/** Complete parsed JSON payload from the CLI. */
|
|
2094
|
+
raw: Record<string, unknown>;
|
|
2095
|
+
}
|
|
2096
|
+
declare class FilesystemError extends Error {
|
|
2097
|
+
constructor(message: string);
|
|
2098
|
+
}
|
|
2099
|
+
declare class FilesystemNotFoundError extends FilesystemError {
|
|
2100
|
+
readonly filesystemName: string;
|
|
2101
|
+
constructor(name: string);
|
|
2102
|
+
}
|
|
2103
|
+
declare class FileNotFoundInFilesystemError extends FilesystemError {
|
|
2104
|
+
readonly filesystem: string;
|
|
2105
|
+
readonly path: string;
|
|
2106
|
+
constructor(filesystem: string, path: string);
|
|
2107
|
+
}
|
|
2108
|
+
declare class FilesystemAPIError extends FilesystemError {
|
|
2109
|
+
readonly statusCode: number;
|
|
2110
|
+
constructor(statusCode: number, message: string);
|
|
2111
|
+
}
|
|
2112
|
+
declare class MountError extends FilesystemError {
|
|
2113
|
+
constructor(message: string);
|
|
2114
|
+
}
|
|
2115
|
+
declare class ReadOnlyMountNotSupportedError extends MountError {
|
|
2116
|
+
constructor();
|
|
2117
|
+
}
|
|
2118
|
+
declare class CliNotFoundError extends MountError {
|
|
2119
|
+
constructor(detail: string, command?: "fs" | "git mount");
|
|
2120
|
+
}
|
|
2121
|
+
|
|
2122
|
+
/**
|
|
2123
|
+
* Client for Tensorlake filesystems.
|
|
2124
|
+
*
|
|
2125
|
+
* A filesystem is a durable, versioned file tree that lives in Tensorlake
|
|
2126
|
+
* Cloud. Every write publishes a durable live version; {@link Filesystem.snapshot}
|
|
2127
|
+
* retains the current version permanently. Files can be read at any retained
|
|
2128
|
+
* version, and a filesystem can be mounted to a local path through the `tl`
|
|
2129
|
+
* CLI's FUSE/FSKit daemon.
|
|
2130
|
+
*
|
|
2131
|
+
* Server-side SDK writes hash complete files locally, upload missing bytes
|
|
2132
|
+
* directly to checksum-bound object-store targets, and atomically publish
|
|
2133
|
+
* one durable snapshot. Payload bytes never transit the API service.
|
|
2134
|
+
*
|
|
2135
|
+
* @example
|
|
2136
|
+
* const client = new FilesystemClient(); // env-based auth
|
|
2137
|
+
* const fs = await client.create("my-data");
|
|
2138
|
+
* await fs.writeFile("docs/hello.txt", "hi");
|
|
2139
|
+
* console.log(await fs.readText("docs/hello.txt"));
|
|
2140
|
+
* const snapshot = await fs.snapshot("after first write");
|
|
2141
|
+
*
|
|
2142
|
+
* const mount = await fs.mount("/mnt/my-data"); // requires the `tl` CLI
|
|
2143
|
+
* // ... use it as a normal directory
|
|
2144
|
+
* await mount.unmount();
|
|
2145
|
+
*/
|
|
2146
|
+
|
|
2147
|
+
interface FilesystemClientOptions {
|
|
2148
|
+
apiKey?: string;
|
|
2149
|
+
apiUrl?: string;
|
|
2150
|
+
/** @deprecated Scope is selected by ingress for SDK API keys; used only by local `tl` mounts. */
|
|
2151
|
+
organizationId?: string;
|
|
2152
|
+
/** @deprecated Scope is selected by ingress for SDK API keys; used only by local `tl` mounts. */
|
|
2153
|
+
projectId?: string;
|
|
2154
|
+
/** @internal Test seam: bypass the native binding loader. */
|
|
2155
|
+
nativeClient?: NativeRepositoryClient;
|
|
2156
|
+
}
|
|
2157
|
+
/**
|
|
2158
|
+
* Runs `tl fs ...` commands for local mount operations.
|
|
2159
|
+
*
|
|
2160
|
+
* Mounting a filesystem to a local path is served by a FUSE (Linux) / FSKit
|
|
2161
|
+
* (macOS) daemon that ships only inside the Tensorlake CLI, so the SDK drives
|
|
2162
|
+
* mounts by invoking `tl fs mount/unmount/snapshot/status`. Everything else
|
|
2163
|
+
* goes through the Rust core and does not need the CLI.
|
|
2164
|
+
*/
|
|
2165
|
+
declare class FsCli extends MountCli {
|
|
2166
|
+
constructor(envOverrides: Record<string, string>);
|
|
2167
|
+
mount(filesystem: string, localPath: string, readonly: boolean): Promise<void>;
|
|
2168
|
+
unmount(localPath: string, discard: boolean): Promise<void>;
|
|
2169
|
+
snapshot(localPath: string, message?: string): Promise<void>;
|
|
2170
|
+
status(localPath?: string): Promise<Record<string, unknown>>;
|
|
2171
|
+
}
|
|
2172
|
+
/** Manages the filesystems of one Tensorlake project. */
|
|
2173
|
+
declare class FilesystemClient {
|
|
2174
|
+
private readonly native;
|
|
2175
|
+
private readonly cli;
|
|
2176
|
+
/**
|
|
2177
|
+
* The SDK authenticates with `apiKey` or `TENSORLAKE_API_KEY`. Project scope is selected by
|
|
2178
|
+
* ingress from the API key; no organization/project lookup is performed. Organization/project
|
|
2179
|
+
* options are retained only for the separately installed `tl` CLI used by local mounts.
|
|
2180
|
+
*/
|
|
2181
|
+
constructor(options?: FilesystemClientOptions);
|
|
2182
|
+
/** Create a filesystem; region fixes its storage placement. Forks inherit placement. */
|
|
2183
|
+
create(name: string, options?: {
|
|
2184
|
+
region?: string;
|
|
2185
|
+
}): Promise<Filesystem>;
|
|
2186
|
+
/**
|
|
2187
|
+
* Fork a filesystem at its live head or an explicit retained snapshot.
|
|
2188
|
+
* The server shares immutable content and publishes only metadata.
|
|
2189
|
+
*/
|
|
2190
|
+
fork(name: string, baseFilesystem: string, snapshot?: string): Promise<Filesystem>;
|
|
2191
|
+
/** Return a handle to an existing filesystem (verifies it exists). */
|
|
2192
|
+
get(name: string): Promise<Filesystem>;
|
|
2193
|
+
/** List all filesystems in the project. */
|
|
2194
|
+
list(): Promise<FilesystemInfo[]>;
|
|
2195
|
+
/** Permanently delete a filesystem and all its snapshots. */
|
|
2196
|
+
delete(name: string): Promise<void>;
|
|
2197
|
+
/**
|
|
2198
|
+
* Mount a filesystem to a local path (requires the `tl` CLI).
|
|
2199
|
+
*
|
|
2200
|
+
* `readonly: true` is not supported for local mounts and throws
|
|
2201
|
+
* {@link ReadOnlyMountNotSupportedError}; use a sandbox read-only mount
|
|
2202
|
+
* (`readOnly: true`) or `tl git mount --ro` instead.
|
|
2203
|
+
*/
|
|
2204
|
+
mount(name: string, localPath: string, readonly?: boolean): Promise<FilesystemMount>;
|
|
2205
|
+
/**
|
|
2206
|
+
* Unmount a locally mounted filesystem.
|
|
2207
|
+
*
|
|
2208
|
+
* `discard: true` drops local changes that were not yet uploaded.
|
|
2209
|
+
*/
|
|
2210
|
+
unmount(localPath: string, discard?: boolean): Promise<void>;
|
|
2211
|
+
/** Status of a local mount (defaults to the mount containing CWD). */
|
|
2212
|
+
mountStatus(localPath?: string): Promise<MountStatus>;
|
|
2213
|
+
}
|
|
2214
|
+
type FileData = Uint8Array | string;
|
|
2215
|
+
/** Handle to one filesystem; reads/writes go through the Rust core. */
|
|
2216
|
+
declare class Filesystem {
|
|
2217
|
+
private readonly client;
|
|
2218
|
+
private readonly native;
|
|
2219
|
+
private readonly cli;
|
|
2220
|
+
readonly name: string;
|
|
2221
|
+
private defaultBranch;
|
|
2222
|
+
/** @internal — obtain instances via `FilesystemClient.create()` / `.get()`. */
|
|
2223
|
+
constructor(client: FilesystemClient, native: NativeRepositoryClient, cli: FsCli, name: string, defaultBranch?: string | null);
|
|
2224
|
+
/**
|
|
2225
|
+
* The filesystem's default branch — the target of every write and the
|
|
2226
|
+
* default version of every read, so writes and `status()` can never
|
|
2227
|
+
* silently disagree on a non-"main" filesystem.
|
|
2228
|
+
*/
|
|
2229
|
+
private branch;
|
|
2230
|
+
/** Write one file. Returns the snapshot (version) the write produced. */
|
|
2231
|
+
writeFile(path: string, data: FileData, message?: string): Promise<FilesystemVersion>;
|
|
2232
|
+
/** Write several files (and/or delete paths) in one atomic snapshot. */
|
|
2233
|
+
writeFiles(files: Map<string, FileData> | Record<string, FileData>, message?: string, deletes?: string[]): Promise<FilesystemVersion>;
|
|
2234
|
+
/**
|
|
2235
|
+
* Stream one local file directly to object storage in bounded parts.
|
|
2236
|
+
* This is the memory-bounded API for multi-GiB files.
|
|
2237
|
+
*/
|
|
2238
|
+
writeFileFromPath(path: string, localPath: string, message?: string): Promise<FilesystemVersion>;
|
|
2239
|
+
/**
|
|
2240
|
+
* Atomically publish local files without loading their complete payloads
|
|
2241
|
+
* into JavaScript or Rust memory.
|
|
2242
|
+
*/
|
|
2243
|
+
writeFilesFromPaths(files: Map<string, string> | Record<string, string>, message?: string): Promise<FilesystemVersion>;
|
|
2244
|
+
/**
|
|
2245
|
+
* Move a file or directory without downloading or re-uploading its bytes.
|
|
2246
|
+
* The source removal and destination creation publish as one atomic snapshot.
|
|
2247
|
+
*/
|
|
2248
|
+
moveFile(from: string, to: string, message?: string): Promise<FilesystemVersion>;
|
|
2249
|
+
/**
|
|
2250
|
+
* Copy a file or directory by reusing immutable content references. No
|
|
2251
|
+
* payload bytes traverse the client, API server, or object store.
|
|
2252
|
+
*/
|
|
2253
|
+
copyFile(from: string, to: string, message?: string): Promise<FilesystemVersion>;
|
|
2254
|
+
private publishChanges;
|
|
2255
|
+
/** Delete one file. Returns the durable version the deletion produced. */
|
|
2256
|
+
deleteFile(path: string, message?: string): Promise<FilesystemVersion>;
|
|
2257
|
+
/**
|
|
2258
|
+
* Return the filesystem's current version as a snapshot.
|
|
2259
|
+
*
|
|
2260
|
+
* Writes publish durable live versions. This retains the current head
|
|
2261
|
+
* permanently in one metadata-only server operation without changing or
|
|
2262
|
+
* copying any content.
|
|
2263
|
+
*/
|
|
2264
|
+
snapshot(message?: string): Promise<FilesystemSnapshot>;
|
|
2265
|
+
/** List explicitly retained snapshots without reading filesystem contents. */
|
|
2266
|
+
listSnapshots(): Promise<FilesystemSnapshotInfo[]>;
|
|
2267
|
+
/** Delete one permanent retention point; shared/head-reachable bytes remain. */
|
|
2268
|
+
deleteSnapshot(snapshot: string): Promise<void>;
|
|
2269
|
+
/**
|
|
2270
|
+
* Read a file's bytes at `version` (the current `main` head or a retained
|
|
2271
|
+
* snapshot id; defaults to the filesystem's current head).
|
|
2272
|
+
*/
|
|
2273
|
+
readFile(path: string, version?: string): Promise<Uint8Array>;
|
|
2274
|
+
/**
|
|
2275
|
+
* Read bytes and immutable metadata in one request. A range is executed by
|
|
2276
|
+
* Artifact Storage, so callers never download the unrequested remainder.
|
|
2277
|
+
*/
|
|
2278
|
+
readFileWithMetadata(path: string, options?: FilesystemReadOptions): Promise<FilesystemFileRead>;
|
|
2279
|
+
/** Read a file as UTF-8 text at `version`. Throws on non-UTF-8 content. */
|
|
2280
|
+
readText(path: string, version?: string): Promise<string>;
|
|
2281
|
+
/** List one directory (non-recursive) at `version`. */
|
|
2282
|
+
listFiles(dirPath?: string, version?: string): Promise<FileEntry[]>;
|
|
2283
|
+
/** Remote status: identity plus the current native version. */
|
|
2284
|
+
status(): Promise<FilesystemStatus>;
|
|
2285
|
+
/**
|
|
2286
|
+
* Mount this filesystem to a local path (requires the `tl` CLI).
|
|
2287
|
+
*
|
|
2288
|
+
* `readonly: true` is not supported for local mounts and throws
|
|
2289
|
+
* {@link ReadOnlyMountNotSupportedError}; use a sandbox read-only mount
|
|
2290
|
+
* (`readOnly: true`) or `tl git mount --ro` instead.
|
|
2291
|
+
*/
|
|
2292
|
+
mount(localPath: string, readonly?: boolean): Promise<FilesystemMount>;
|
|
2293
|
+
}
|
|
2294
|
+
/** A filesystem mounted to a local path via the `tl` CLI daemon. */
|
|
2295
|
+
declare class FilesystemMount {
|
|
2296
|
+
private readonly client;
|
|
2297
|
+
private readonly cli;
|
|
2298
|
+
readonly filesystem: string;
|
|
2299
|
+
readonly path: string;
|
|
2300
|
+
readonly readonly: boolean;
|
|
2301
|
+
/** @internal — obtain instances via `FilesystemClient.mount()`. */
|
|
2302
|
+
constructor(client: FilesystemClient, cli: FsCli, filesystem: string, path: string, readonly: boolean);
|
|
2303
|
+
/** Flush pending local changes into a durable snapshot. */
|
|
2304
|
+
snapshot(message?: string): Promise<void>;
|
|
2305
|
+
/** Local mount status as reported by the mount daemon. */
|
|
2306
|
+
status(): Promise<MountStatus>;
|
|
2307
|
+
/** Unmount; `discard: true` drops changes not yet uploaded. */
|
|
2308
|
+
unmount(discard?: boolean): Promise<void>;
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
/**
|
|
2312
|
+
* Build a public sandbox URL from a server-provided ingress endpoint.
|
|
2313
|
+
*
|
|
2314
|
+
* `port` omitted or `9501` returns the management URL:
|
|
2315
|
+
* `https://<sandbox-id>.<ingress-host>`. User ports use the public
|
|
2316
|
+
* `<port>-<sandbox-id>.<ingress-host>` form.
|
|
2317
|
+
*/
|
|
2318
|
+
declare function sandboxUrlFromIngressEndpoint(ingressEndpoint: string, sandboxId: string, port?: number): string;
|
|
2319
|
+
|
|
2320
|
+
/** Base exception for all sandbox-related errors. */
|
|
2321
|
+
declare class SandboxException extends Error {
|
|
2322
|
+
constructor(message: string);
|
|
2323
|
+
}
|
|
2324
|
+
/**
|
|
2325
|
+
* General sandbox operation error.
|
|
2326
|
+
*
|
|
2327
|
+
* `reason` carries the server's reason when the error describes a sandbox
|
|
2328
|
+
* that failed or terminated: `no_capacity` when a `maxPendingSecs` bound
|
|
2329
|
+
* expired, `cancelled` when a pending sandbox was deleted, or a startup
|
|
2330
|
+
* reason such as `ConfigurationError`. It is undefined for errors that are
|
|
2331
|
+
* not about a sandbox's fate.
|
|
2332
|
+
*/
|
|
2333
|
+
declare class SandboxError extends SandboxException {
|
|
2334
|
+
readonly reason?: string;
|
|
2335
|
+
readonly sandboxId?: string;
|
|
2336
|
+
constructor(message: string, options?: {
|
|
2337
|
+
reason?: string;
|
|
2338
|
+
sandboxId?: string;
|
|
2339
|
+
});
|
|
2340
|
+
}
|
|
2341
|
+
/** A failed, timed-out, interrupted, or superseded resize, with confirmed allocation. */
|
|
2342
|
+
declare class SandboxResizeError extends SandboxError {
|
|
2343
|
+
readonly reason: ResizeErrorReason;
|
|
2344
|
+
readonly generation: number;
|
|
2345
|
+
readonly info?: SandboxInfo;
|
|
2346
|
+
constructor(payload: {
|
|
2347
|
+
sandboxId: string;
|
|
2348
|
+
generation: number;
|
|
2349
|
+
reason: ResizeErrorReason;
|
|
2350
|
+
message: string;
|
|
2351
|
+
info?: SandboxInfo | null;
|
|
2352
|
+
});
|
|
2353
|
+
/** Last confirmed allocation, if an observation was available. */
|
|
2354
|
+
get confirmedResources(): ContainerResourcesInfo | undefined;
|
|
2355
|
+
}
|
|
2356
|
+
/**
|
|
2357
|
+
* The wait budget ran out while the sandbox was still queued.
|
|
2358
|
+
*
|
|
2359
|
+
* Thrown by `Sandbox.create`, `createAndConnect`, `PendingSandbox.ready` and
|
|
2360
|
+
* a lazy `connect` when their timeout elapses before the sandbox is running.
|
|
2361
|
+
* **The sandbox is not deleted**: it keeps its place in the queue and starts
|
|
2362
|
+
* whenever capacity arrives. Call `ready()` again to keep waiting,
|
|
2363
|
+
* `Sandbox.connect` from any other process, or `delete` it to give up.
|
|
2364
|
+
* `pendingReason` is the last reason the scheduler recorded (`scheduling`,
|
|
2365
|
+
* `no_resources_available`, `pool_at_capacity`, ...).
|
|
2366
|
+
*/
|
|
2367
|
+
declare class SandboxPending extends SandboxError {
|
|
2368
|
+
readonly sandboxId: string;
|
|
2369
|
+
readonly pendingReason?: string;
|
|
2370
|
+
readonly timeout?: number;
|
|
2371
|
+
constructor(sandboxId: string, options?: {
|
|
2372
|
+
pendingReason?: string;
|
|
2373
|
+
timeout?: number;
|
|
2374
|
+
});
|
|
2375
|
+
}
|
|
2376
|
+
/**
|
|
2377
|
+
* Raised when the client cannot complete a request against the API server.
|
|
2378
|
+
*
|
|
2379
|
+
* The original transport error is preserved on this error's {@link cause} for programmatic
|
|
2380
|
+
* inspection, and its full chain is folded into the message so it survives
|
|
2381
|
+
* wrappers that only forward `error.message`. No interpretation of the failure
|
|
2382
|
+
* (client vs server) is applied — the raw inner error is surfaced as-is so the
|
|
2383
|
+
* reader can judge.
|
|
2384
|
+
*/
|
|
2385
|
+
declare class SandboxConnectionError extends SandboxError {
|
|
2386
|
+
constructor(message: string, options?: {
|
|
2387
|
+
cause?: unknown;
|
|
2388
|
+
});
|
|
2389
|
+
}
|
|
2390
|
+
/** Raised when a sandbox is not found. */
|
|
2391
|
+
declare class SandboxNotFoundError extends SandboxError {
|
|
2392
|
+
readonly sandboxId: string;
|
|
2393
|
+
constructor(sandboxId: string);
|
|
2394
|
+
}
|
|
2395
|
+
/** Raised when a sandbox pool is not found. */
|
|
2396
|
+
declare class PoolNotFoundError extends SandboxError {
|
|
2397
|
+
readonly poolId: string;
|
|
2398
|
+
constructor(poolId: string);
|
|
2399
|
+
}
|
|
2400
|
+
/** Raised when attempting to delete a pool that is in use. */
|
|
2401
|
+
declare class PoolInUseError extends SandboxError {
|
|
2402
|
+
readonly poolId: string;
|
|
2403
|
+
constructor(poolId: string, message?: string);
|
|
2404
|
+
}
|
|
2405
|
+
/** Raised when the remote API returns an error. */
|
|
2406
|
+
declare class RemoteAPIError extends SandboxError {
|
|
2407
|
+
readonly statusCode: number;
|
|
2408
|
+
/** Original response body, retained for compatibility and diagnostics. */
|
|
2409
|
+
readonly responseMessage: string;
|
|
2410
|
+
readonly sandboxId?: string;
|
|
2411
|
+
/** Server reason, including unknown future reasons. */
|
|
2412
|
+
readonly reason?: string;
|
|
2413
|
+
readonly errorDetails?: unknown;
|
|
2414
|
+
constructor(statusCode: number, message: string);
|
|
2415
|
+
}
|
|
2416
|
+
/** Raised when request output is fetched before the request has completed. */
|
|
2417
|
+
declare class RequestNotFinishedError extends Error {
|
|
2418
|
+
constructor();
|
|
2419
|
+
}
|
|
2420
|
+
/** Raised when a request completed unsuccessfully. */
|
|
2421
|
+
declare class RequestFailedError extends Error {
|
|
2422
|
+
readonly failure: string;
|
|
2423
|
+
constructor(failure: string);
|
|
2424
|
+
}
|
|
2425
|
+
/** Raised when a request surfaced an application-level error. */
|
|
2426
|
+
declare class RequestExecutionError extends Error {
|
|
2427
|
+
readonly functionName?: string;
|
|
2428
|
+
constructor(message: string, functionName?: string);
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
export { ApplicationBuildContext, ApplicationBuildResponse, ApplicationManifest, ApplicationSummary, type ArchivedSandboxInfo, type AttachFileSystemOptions, BinaryPayload, type Branch, BuildInfo, BuildLogEntry, type CheckpointOptions, type CheckpointType, type ClaimSandboxOptions, CliNotFoundError, CloudClient, CloudClientOptions, type CommandResult, type CommitJobError, type CommitJobReadBack, type CommitJobStatus, type ConflictPath, type ConflictTerm, type ConnectDesktopOptions, type ConnectOptions, type ContainerResourcesInfo, ContainerState, type CopiedSandboxResponse, type CopySandboxOptions, type CopySandboxResponse, type CreateAndConnectOptions, CreateApplicationBuildRequest, type CreatePoolOptions, type CreatePtyOptions, type CreatePtySessionOptions, type CreateSandboxOptions, type CreateSandboxPoolResponse, type CreateSandboxResponse, type CreateSnapshotResponse, type CreateTunnelOptions, type DaemonInfo, Desktop, type DesktopDoubleClickOptions, type DesktopPointerOptions, type DirectoryEntry, type FileEntry, FileNotFoundInFilesystemError, FileSystem, type FileSystemMount, Filesystem, FilesystemAPIError, FilesystemClient, type FilesystemClientOptions, FilesystemError, type FilesystemFileRead, type FilesystemInfo, FilesystemMount, FilesystemNotFoundError, type FilesystemReadOptions, type FilesystemSnapshot, type FilesystemSnapshotInfo, type FilesystemStatus, type FilesystemVersion, type GPUResources, type GetOrCreateOptions, type GetOrCreateOutcome, type GetSandboxLogsOptions, type GitCredential, type GitRef, type GitRepository, type GpuModel, type GpuRequest, type HealthResponse, type ListArchivedSandboxesOptions, type ListArchivedSandboxesResponse, type ListDirectoryResponse, type ManagedProcessExit, type ManagedProcessHealthStatus, type ManagedProcessInfo, type ManagedProcessStatus, type MergeConflict, type MergeConflictRecord, type MergeEntry, type MergeOptions, type MergeReport, type MergeStats, MountError, type MountStatus, type MouseButton, type NetworkConfig, NewSecret, type Operation, type OperationRef, type OutputEvent, OutputMode, type OutputResponse, PendingSandbox, type PendingSandboxRecord, type PoolContainerInfo, PoolInUseError, PoolNotFoundError, type ProcessHealthCheck, type ProcessHealthCheckType, type ProcessInfo, ProcessStatus, type ProcessUser, type ProcessUserSpec, Pty, type PtyConnectionOptions, type PtyDataHandler, type PtyExitHandler, type PtySessionInfo, type PushReport, type PushWorktreeOptions, ReadOnlyMountNotSupportedError, type ReadyOptions, RemoteAPIError, RepositoryClient, type RepositoryClientOptions, type RepositoryHandle, type RepositoryInfo, RepositoryMount, type RepositoryMountOptions, type RepositoryMountStatus, type RepositoryUnmountOptions, RequestExecutionError, RequestFailedError, RequestInput, RequestMetadata, RequestNotFinishedError, RequestOutput, ResizeErrorReason, ResizeStatus, type ResourceResizeWaitOptions, type RestartPolicy, type RestartPolicyConfig, type RunOptions, Sandbox, SandboxClient, type SandboxClientOptions, SandboxConnectionError, SandboxError, SandboxException, type SandboxInfo, type SandboxLogLevel, type SandboxLogSignal, type SandboxLogsResponse, SandboxNotFoundError, type SandboxOptions, SandboxPending, SandboxPendingReason, type SandboxPoolInfo, type SandboxPortAccess, type SandboxProcessLogFilter, type SandboxProcessLogFiltersResponse, SandboxResizeError, type SandboxResourceResizeInfo, SandboxStatus, SandboxTemplate, Secret, SecretsList, type SendSignalResponse, type SnapshotAndWaitOptions, type SnapshotInfo, type SnapshotOptions, SnapshotStatus, type SnapshotType, type SnapshotWaitCondition, StartImageBuildRequest, type StartProcessOptions, StdinMode, type SuspendResumeOptions, TERMINATION_REASON_CANCELLED, TERMINATION_REASON_NO_CAPACITY, TcpTunnel, type TunnelAddress, type UpdatePoolOptions, type UpdateSandboxOptions, UpsertSecretResponse, createFileSystem, deleteFileSystem, isSandboxPending, listFileSystems, sandboxUrlFromIngressEndpoint };
|