@watasu/sdk 0.1.30 → 0.1.50
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 +13 -7
- package/dist/codeInterpreter.d.ts +141 -16
- package/dist/codeInterpreter.js +74 -19
- package/dist/commands.d.ts +16 -8
- package/dist/commands.js +17 -16
- package/dist/connectionConfig.d.ts +25 -0
- package/dist/connectionConfig.js +49 -2
- package/dist/errors.d.ts +21 -0
- package/dist/errors.js +54 -4
- package/dist/filesystem.d.ts +20 -20
- package/dist/filesystem.js +51 -12
- package/dist/git.d.ts +6 -4
- package/dist/git.js +7 -3
- package/dist/index.d.ts +22 -10
- package/dist/index.js +7 -5
- package/dist/process.d.ts +1 -1
- package/dist/process.js +11 -7
- package/dist/processSocket.d.ts +17 -4
- package/dist/processSocket.js +112 -8
- package/dist/pty.d.ts +3 -3
- package/dist/pty.js +10 -8
- package/dist/sandbox.d.ts +44 -30
- package/dist/sandbox.js +103 -59
- package/dist/template.d.ts +39 -9
- package/dist/template.js +117 -31
- package/dist/terminal.d.ts +3 -3
- package/dist/terminal.js +7 -4
- package/dist/transport.d.ts +2 -0
- package/dist/transport.js +23 -6
- package/dist/volume.d.ts +15 -8
- package/dist/volume.js +28 -9
- package/package.json +2 -2
package/dist/processSocket.d.ts
CHANGED
|
@@ -5,22 +5,35 @@ export declare class ProcessSocket implements AsyncIterable<ProcessFrame> {
|
|
|
5
5
|
private readonly token;
|
|
6
6
|
private readonly path;
|
|
7
7
|
private readonly requestTimeoutMs;
|
|
8
|
+
private readonly headers;
|
|
8
9
|
private ws?;
|
|
9
10
|
private queue;
|
|
10
11
|
private waiters;
|
|
12
|
+
private ackWaiters;
|
|
11
13
|
private closed;
|
|
12
14
|
private keepalive?;
|
|
13
|
-
constructor(baseUrl: string, token: string, path: string, requestTimeoutMs?: number);
|
|
15
|
+
constructor(baseUrl: string, token: string, path: string, requestTimeoutMs?: number, headers?: Record<string, string>);
|
|
14
16
|
connect(): Promise<this>;
|
|
15
|
-
sendJson(payload: ProcessFrame): void
|
|
16
|
-
sendStdin(data: string | Uint8Array
|
|
17
|
-
|
|
17
|
+
sendJson(payload: ProcessFrame): Promise<void>;
|
|
18
|
+
sendStdin(data: string | Uint8Array, opts?: {
|
|
19
|
+
requestTimeoutMs?: number;
|
|
20
|
+
signal?: AbortSignal;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
closeStdin(opts?: {
|
|
23
|
+
requestTimeoutMs?: number;
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
}): Promise<void>;
|
|
18
26
|
close(): void;
|
|
19
27
|
[Symbol.asyncIterator](): AsyncIterator<ProcessFrame>;
|
|
20
28
|
private next;
|
|
21
29
|
private onMessage;
|
|
22
30
|
private finish;
|
|
23
31
|
private flushDone;
|
|
32
|
+
private waitForControlAck;
|
|
33
|
+
private resolveControlAck;
|
|
34
|
+
private rejectControlAcks;
|
|
35
|
+
private removeControlAck;
|
|
36
|
+
private removeSignalListener;
|
|
24
37
|
}
|
|
25
38
|
export declare function base64Encode(bytes: Uint8Array): string;
|
|
26
39
|
export declare function base64DecodeText(value: unknown): string;
|
package/dist/processSocket.js
CHANGED
|
@@ -8,20 +8,23 @@ export class ProcessSocket {
|
|
|
8
8
|
token;
|
|
9
9
|
path;
|
|
10
10
|
requestTimeoutMs;
|
|
11
|
+
headers;
|
|
11
12
|
ws;
|
|
12
13
|
queue = [];
|
|
13
14
|
waiters = [];
|
|
15
|
+
ackWaiters = new Map();
|
|
14
16
|
closed = false;
|
|
15
17
|
keepalive;
|
|
16
|
-
constructor(baseUrl, token, path, requestTimeoutMs = 60_000) {
|
|
18
|
+
constructor(baseUrl, token, path, requestTimeoutMs = 60_000, headers = {}) {
|
|
17
19
|
this.baseUrl = baseUrl;
|
|
18
20
|
this.token = token;
|
|
19
21
|
this.path = path;
|
|
20
22
|
this.requestTimeoutMs = requestTimeoutMs;
|
|
23
|
+
this.headers = headers;
|
|
21
24
|
}
|
|
22
25
|
async connect() {
|
|
23
26
|
const ws = new WebSocket(wsUrl(this.baseUrl, this.path), {
|
|
24
|
-
headers: { Authorization: `Bearer ${this.token}` },
|
|
27
|
+
headers: { ...this.headers, Authorization: `Bearer ${this.token}` },
|
|
25
28
|
});
|
|
26
29
|
this.ws = ws;
|
|
27
30
|
ws.on('message', (data) => this.onMessage(data));
|
|
@@ -45,18 +48,41 @@ export class ProcessSocket {
|
|
|
45
48
|
}, KEEPALIVE_PING_INTERVAL_SEC * 1000);
|
|
46
49
|
return this;
|
|
47
50
|
}
|
|
48
|
-
sendJson(payload) {
|
|
51
|
+
async sendJson(payload) {
|
|
49
52
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
50
53
|
throw new SandboxError('process websocket is not connected');
|
|
51
54
|
}
|
|
52
|
-
|
|
55
|
+
await new Promise((resolve, reject) => {
|
|
56
|
+
this.ws.send(JSON.stringify(payload), (error) => {
|
|
57
|
+
if (error)
|
|
58
|
+
reject(error);
|
|
59
|
+
else
|
|
60
|
+
resolve();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
53
63
|
}
|
|
54
|
-
sendStdin(data) {
|
|
64
|
+
async sendStdin(data, opts = {}) {
|
|
55
65
|
const raw = typeof data === 'string' ? new TextEncoder().encode(data) : data;
|
|
56
|
-
this.
|
|
66
|
+
const ack = this.waitForControlAck('stdin_ack', opts);
|
|
67
|
+
try {
|
|
68
|
+
await this.sendJson({ type: 'stdin', data: base64Encode(raw) });
|
|
69
|
+
await ack.promise;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
ack.cancel();
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
57
75
|
}
|
|
58
|
-
closeStdin() {
|
|
59
|
-
this.
|
|
76
|
+
async closeStdin(opts = {}) {
|
|
77
|
+
const ack = this.waitForControlAck('close_stdin_ack', opts);
|
|
78
|
+
try {
|
|
79
|
+
await this.sendJson({ type: 'close_stdin' });
|
|
80
|
+
await ack.promise;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
ack.cancel();
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
60
86
|
}
|
|
61
87
|
close() {
|
|
62
88
|
this.closed = true;
|
|
@@ -84,6 +110,10 @@ export class ProcessSocket {
|
|
|
84
110
|
const frame = JSON.parse(text);
|
|
85
111
|
if (frame.type === 'pong' || frame.type === 'ready')
|
|
86
112
|
return;
|
|
113
|
+
if (frame.type === 'stdin_ack' || frame.type === 'close_stdin_ack') {
|
|
114
|
+
this.resolveControlAck(String(frame.type));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
87
117
|
if (frame.type === 'error') {
|
|
88
118
|
this.finish(new SandboxError(String(frame.message ?? frame.code ?? 'process error')));
|
|
89
119
|
return;
|
|
@@ -110,6 +140,7 @@ export class ProcessSocket {
|
|
|
110
140
|
else
|
|
111
141
|
this.queue.push(frame);
|
|
112
142
|
}
|
|
143
|
+
this.rejectControlAcks(error ?? new SandboxError('process websocket closed before acknowledgement'));
|
|
113
144
|
this.flushDone();
|
|
114
145
|
}
|
|
115
146
|
flushDone() {
|
|
@@ -117,6 +148,79 @@ export class ProcessSocket {
|
|
|
117
148
|
waiter({ done: true, value: undefined });
|
|
118
149
|
}
|
|
119
150
|
}
|
|
151
|
+
waitForControlAck(type, opts = {}) {
|
|
152
|
+
if (opts.signal?.aborted) {
|
|
153
|
+
return {
|
|
154
|
+
promise: Promise.reject(new SandboxError('process control acknowledgement aborted')),
|
|
155
|
+
cancel: () => { },
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
let entry;
|
|
159
|
+
const promise = new Promise((resolve, reject) => {
|
|
160
|
+
const rejectWithAbort = () => {
|
|
161
|
+
this.removeControlAck(type, entry);
|
|
162
|
+
clearTimeout(entry.timer);
|
|
163
|
+
reject(new SandboxError('process control acknowledgement aborted'));
|
|
164
|
+
};
|
|
165
|
+
const timer = setTimeout(() => {
|
|
166
|
+
this.removeControlAck(type, entry);
|
|
167
|
+
this.removeSignalListener(entry);
|
|
168
|
+
reject(new TimeoutError());
|
|
169
|
+
}, opts.requestTimeoutMs ?? this.requestTimeoutMs);
|
|
170
|
+
entry = { resolve, reject, timer, signal: opts.signal };
|
|
171
|
+
if (opts.signal) {
|
|
172
|
+
entry.abort = rejectWithAbort;
|
|
173
|
+
opts.signal.addEventListener('abort', rejectWithAbort, { once: true });
|
|
174
|
+
}
|
|
175
|
+
const waiters = this.ackWaiters.get(type) ?? [];
|
|
176
|
+
waiters.push(entry);
|
|
177
|
+
this.ackWaiters.set(type, waiters);
|
|
178
|
+
});
|
|
179
|
+
return {
|
|
180
|
+
promise,
|
|
181
|
+
cancel: () => {
|
|
182
|
+
this.removeControlAck(type, entry);
|
|
183
|
+
clearTimeout(entry.timer);
|
|
184
|
+
if (entry.abort)
|
|
185
|
+
opts.signal?.removeEventListener('abort', entry.abort);
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
resolveControlAck(type) {
|
|
190
|
+
const entry = this.ackWaiters.get(type)?.shift();
|
|
191
|
+
if (!entry)
|
|
192
|
+
return;
|
|
193
|
+
clearTimeout(entry.timer);
|
|
194
|
+
if (entry.abort)
|
|
195
|
+
this.removeSignalListener(entry);
|
|
196
|
+
entry.resolve();
|
|
197
|
+
}
|
|
198
|
+
rejectControlAcks(error) {
|
|
199
|
+
for (const waiters of this.ackWaiters.values()) {
|
|
200
|
+
for (const entry of waiters.splice(0)) {
|
|
201
|
+
clearTimeout(entry.timer);
|
|
202
|
+
if (entry.abort)
|
|
203
|
+
this.removeSignalListener(entry);
|
|
204
|
+
entry.reject(error);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
this.ackWaiters.clear();
|
|
208
|
+
}
|
|
209
|
+
removeControlAck(type, entry) {
|
|
210
|
+
const waiters = this.ackWaiters.get(type);
|
|
211
|
+
if (!waiters)
|
|
212
|
+
return;
|
|
213
|
+
const index = waiters.indexOf(entry);
|
|
214
|
+
if (index !== -1)
|
|
215
|
+
waiters.splice(index, 1);
|
|
216
|
+
if (waiters.length === 0)
|
|
217
|
+
this.ackWaiters.delete(type);
|
|
218
|
+
}
|
|
219
|
+
removeSignalListener(entry) {
|
|
220
|
+
if (entry.abort)
|
|
221
|
+
entry.signal?.removeEventListener('abort', entry.abort);
|
|
222
|
+
entry.abort = undefined;
|
|
223
|
+
}
|
|
120
224
|
}
|
|
121
225
|
export function base64Encode(bytes) {
|
|
122
226
|
return Buffer.from(bytes).toString('base64');
|
package/dist/pty.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CommandHandle, CommandStartOpts } from './commands.js';
|
|
2
|
-
import { ConnectionConfig } from './connectionConfig.js';
|
|
2
|
+
import { ConnectionConfig, type ConnectionOpts } from './connectionConfig.js';
|
|
3
3
|
import { DataPlaneClient } from './transport.js';
|
|
4
4
|
export interface PtySize {
|
|
5
5
|
cols: number;
|
|
@@ -28,10 +28,10 @@ export declare class Pty {
|
|
|
28
28
|
connect(pid: number | string, opts?: PtyConnectOpts): Promise<CommandHandle>;
|
|
29
29
|
/** Send input bytes or text to a PTY. */
|
|
30
30
|
sendStdin(pid: number | string, data: string | Uint8Array, opts?: PtyConnectOpts): Promise<void>;
|
|
31
|
-
/**
|
|
31
|
+
/** Send input bytes or text to a PTY. */
|
|
32
32
|
sendInput(pid: number | string, data: string | Uint8Array, opts?: PtyConnectOpts): Promise<void>;
|
|
33
33
|
/** Resize a running PTY. */
|
|
34
34
|
resize(pid: number | string, size: PtySize, opts?: PtyConnectOpts): Promise<void>;
|
|
35
35
|
/** Kill a running PTY. */
|
|
36
|
-
kill(pid: number | string): Promise<boolean>;
|
|
36
|
+
kill(pid: number | string, opts?: Pick<ConnectionOpts, 'requestTimeoutMs' | 'signal'>): Promise<boolean>;
|
|
37
37
|
}
|
package/dist/pty.js
CHANGED
|
@@ -11,21 +11,21 @@ export class Pty {
|
|
|
11
11
|
}
|
|
12
12
|
/** Create an interactive shell PTY and return its live command handle. */
|
|
13
13
|
async create(opts) {
|
|
14
|
-
const socket = await new ProcessSocket(this.dataPlane.baseUrl, this.dataPlane.token, '/runtime/v1/process', opts.requestTimeoutMs ?? this.config.requestTimeoutMs).connect();
|
|
15
|
-
const envs = { TERM: 'xterm-256color', LANG: 'C.UTF-8', LC_ALL: 'C.UTF-8', ...(opts.
|
|
14
|
+
const socket = await new ProcessSocket(this.dataPlane.baseUrl, this.dataPlane.token, '/runtime/v1/process', opts.requestTimeoutMs ?? this.config.requestTimeoutMs, this.config.headers).connect();
|
|
15
|
+
const envs = { TERM: 'xterm-256color', LANG: 'C.UTF-8', LC_ALL: 'C.UTF-8', ...(opts.envs ?? {}) };
|
|
16
16
|
const size = opts.size ?? { cols: opts.cols ?? 80, rows: opts.rows ?? 24 };
|
|
17
17
|
const args = opts.cmd === undefined ? ['-i', '-l'] : ['-l', '-c', opts.cmd];
|
|
18
|
-
socket.sendJson({
|
|
18
|
+
await socket.sendJson({
|
|
19
19
|
type: 'start',
|
|
20
20
|
cmd: '/bin/bash',
|
|
21
21
|
args,
|
|
22
|
-
cwd: opts.cwd
|
|
22
|
+
cwd: opts.cwd,
|
|
23
23
|
user: opts.user,
|
|
24
24
|
environment: envs,
|
|
25
25
|
envs,
|
|
26
26
|
stdin: true,
|
|
27
27
|
pty: { cols: size.cols, rows: size.rows },
|
|
28
|
-
timeout_ms: opts.timeoutMs ??
|
|
28
|
+
timeout_ms: opts.timeoutMs ?? 60_000,
|
|
29
29
|
});
|
|
30
30
|
const first = await nextStarted(socket);
|
|
31
31
|
const pid = framePid(first);
|
|
@@ -35,7 +35,7 @@ export class Pty {
|
|
|
35
35
|
}
|
|
36
36
|
/** Connect to a running PTY by pid. */
|
|
37
37
|
async connect(pid, opts = {}) {
|
|
38
|
-
const socket = await new ProcessSocket(this.dataPlane.baseUrl, this.dataPlane.token, `/runtime/v1/process/${pid}/connect?since=0`, opts.requestTimeoutMs ?? this.config.requestTimeoutMs).connect();
|
|
38
|
+
const socket = await new ProcessSocket(this.dataPlane.baseUrl, this.dataPlane.token, `/runtime/v1/process/${pid}/connect?since=0`, opts.requestTimeoutMs ?? this.config.requestTimeoutMs, this.config.headers).connect();
|
|
39
39
|
const first = await nextStarted(socket);
|
|
40
40
|
const actualPid = framePid(first) ?? pid;
|
|
41
41
|
return new CommandHandle(actualPid, socket, () => this.kill(actualPid), withFirst(first, socket), undefined, undefined, opts.onData);
|
|
@@ -50,7 +50,7 @@ export class Pty {
|
|
|
50
50
|
await handle.disconnect();
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
/**
|
|
53
|
+
/** Send input bytes or text to a PTY. */
|
|
54
54
|
async sendInput(pid, data, opts = {}) {
|
|
55
55
|
return this.sendStdin(pid, data, opts);
|
|
56
56
|
}
|
|
@@ -65,9 +65,11 @@ export class Pty {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
/** Kill a running PTY. */
|
|
68
|
-
async kill(pid) {
|
|
68
|
+
async kill(pid, opts = {}) {
|
|
69
69
|
await this.dataPlane.postJson(`/runtime/v1/process/${pid}/signal`, {
|
|
70
70
|
json: { signal: 'SIGKILL' },
|
|
71
|
+
requestTimeoutMs: opts.requestTimeoutMs,
|
|
72
|
+
signal: opts.signal,
|
|
71
73
|
});
|
|
72
74
|
return true;
|
|
73
75
|
}
|
package/dist/sandbox.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { Git } from './git.js';
|
|
|
6
6
|
import { Pty } from './pty.js';
|
|
7
7
|
import { ProcessManager } from './process.js';
|
|
8
8
|
import { TerminalManager } from './terminal.js';
|
|
9
|
+
import type { Volume } from './volume.js';
|
|
10
|
+
export declare const ALL_TRAFFIC = "0.0.0.0/0";
|
|
9
11
|
export interface SandboxCreateOpts extends ConnectionOpts {
|
|
10
12
|
/** Template slug to create. Defaults to "base". */
|
|
11
13
|
template?: string;
|
|
@@ -22,7 +24,7 @@ export interface SandboxCreateOpts extends ConnectionOpts {
|
|
|
22
24
|
/** Timeout lifecycle policy. Defaults to killing the sandbox at timeout. */
|
|
23
25
|
lifecycle?: SandboxLifecycle;
|
|
24
26
|
/** Persistent volumes to mount, keyed by guest path. */
|
|
25
|
-
volumeMounts?: Record<string, string | {
|
|
27
|
+
volumeMounts?: Record<string, string | Volume | {
|
|
26
28
|
name: string;
|
|
27
29
|
}>;
|
|
28
30
|
}
|
|
@@ -30,7 +32,18 @@ export interface SandboxLifecycle {
|
|
|
30
32
|
onTimeout: 'kill' | 'pause';
|
|
31
33
|
autoResume?: boolean;
|
|
32
34
|
}
|
|
33
|
-
export type
|
|
35
|
+
export type SandboxNetworkTransform = {
|
|
36
|
+
headers?: Record<string, string>;
|
|
37
|
+
};
|
|
38
|
+
export type SandboxNetworkRule = {
|
|
39
|
+
transform?: SandboxNetworkTransform;
|
|
40
|
+
};
|
|
41
|
+
export type SandboxNetworkRules = Record<string, SandboxNetworkRule[]> | Map<string, SandboxNetworkRule[]>;
|
|
42
|
+
export interface SandboxNetworkSelectorContext {
|
|
43
|
+
allTraffic: string;
|
|
44
|
+
rules: Map<string, SandboxNetworkRule[]>;
|
|
45
|
+
}
|
|
46
|
+
export type SandboxNetworkSelector = string | string[] | ((ctx: SandboxNetworkSelectorContext) => string[]);
|
|
34
47
|
export interface SandboxNetworkUpdate {
|
|
35
48
|
allowOut?: SandboxNetworkSelector;
|
|
36
49
|
denyOut?: SandboxNetworkSelector;
|
|
@@ -40,9 +53,15 @@ export interface SandboxNetworkUpdate {
|
|
|
40
53
|
egressProfile?: string;
|
|
41
54
|
egressProfiles?: string[];
|
|
42
55
|
networkClass?: string;
|
|
43
|
-
rules?:
|
|
56
|
+
rules?: SandboxNetworkRules;
|
|
44
57
|
maskRequestHost?: string;
|
|
45
58
|
}
|
|
59
|
+
export type SandboxNetworkOpts = SandboxNetworkUpdate;
|
|
60
|
+
export type SandboxNetworkInfo = SandboxNetworkUpdate;
|
|
61
|
+
export type SandboxNetworkRuleInfo = Record<string, unknown>;
|
|
62
|
+
export type SandboxOpts = SandboxCreateOpts;
|
|
63
|
+
export type SandboxApiOpts = ConnectionOpts;
|
|
64
|
+
export type SandboxState = string;
|
|
46
65
|
export interface SandboxNetworkUpdateOpts extends ConnectionOpts {
|
|
47
66
|
}
|
|
48
67
|
export interface SandboxConnectOpts extends ConnectionOpts {
|
|
@@ -62,6 +81,7 @@ export interface SandboxListOpts extends ConnectionOpts {
|
|
|
62
81
|
/** Team slug to list within. */
|
|
63
82
|
team?: string;
|
|
64
83
|
}
|
|
84
|
+
type SandboxRequestOpts = Pick<ConnectionOpts, 'requestTimeoutMs' | 'signal'>;
|
|
65
85
|
export interface SandboxInfo {
|
|
66
86
|
sandboxId: string;
|
|
67
87
|
templateId?: string;
|
|
@@ -138,9 +158,19 @@ export interface SnapshotListOpts extends ConnectionOpts {
|
|
|
138
158
|
export interface RestoreSnapshotOpts extends ConnectionOpts {
|
|
139
159
|
checkpointId?: string | number;
|
|
140
160
|
snapshotId?: string | number;
|
|
141
|
-
timeout?: number;
|
|
142
161
|
timeoutMs?: number;
|
|
143
162
|
}
|
|
163
|
+
export interface SignatureOpts {
|
|
164
|
+
path: string;
|
|
165
|
+
operation: 'read' | 'write';
|
|
166
|
+
user?: string;
|
|
167
|
+
expirationInSeconds?: number;
|
|
168
|
+
envdAccessToken?: string;
|
|
169
|
+
}
|
|
170
|
+
export declare function getSignature({ path, operation, user, expirationInSeconds, envdAccessToken, }: SignatureOpts): Promise<{
|
|
171
|
+
signature: string;
|
|
172
|
+
expiration: number | null;
|
|
173
|
+
}>;
|
|
144
174
|
/** Paginator for listing sandbox snapshots. */
|
|
145
175
|
export declare class SnapshotPaginator {
|
|
146
176
|
private readonly opts;
|
|
@@ -172,14 +202,12 @@ export declare class Sandbox {
|
|
|
172
202
|
/** Default sandbox lifetime in milliseconds. */
|
|
173
203
|
static readonly defaultSandboxTimeoutMs = 300000;
|
|
174
204
|
files: Filesystem;
|
|
175
|
-
filesystem: Filesystem;
|
|
176
205
|
commands: Commands;
|
|
177
206
|
process: ProcessManager;
|
|
178
207
|
pty: Pty;
|
|
179
208
|
terminal: TerminalManager;
|
|
180
209
|
git: Git;
|
|
181
210
|
cwd: string | undefined;
|
|
182
|
-
envVars: Record<string, string>;
|
|
183
211
|
readonly sandboxId: string;
|
|
184
212
|
private readonly mcpPort;
|
|
185
213
|
private mcpToken;
|
|
@@ -196,24 +224,19 @@ export declare class Sandbox {
|
|
|
196
224
|
sandbox?: Record<string, unknown>;
|
|
197
225
|
envs?: Record<string, string>;
|
|
198
226
|
});
|
|
199
|
-
/**
|
|
227
|
+
/** Unique sandbox identifier. */
|
|
200
228
|
get id(): string;
|
|
201
229
|
static create(opts?: SandboxCreateOpts): Promise<Sandbox>;
|
|
202
230
|
static create(template: string, opts?: SandboxCreateOpts): Promise<Sandbox>;
|
|
203
231
|
/** Connect to an existing sandbox and return it with a fresh data-plane session. */
|
|
204
232
|
static connect(sandboxId: string, opts?: SandboxConnectOpts): Promise<Sandbox>;
|
|
205
|
-
/** Alias for `connect`. */
|
|
206
|
-
static reconnect(sandboxId: string, opts?: SandboxConnectOpts): Promise<Sandbox>;
|
|
207
|
-
static reconnect(opts: SandboxConnectOpts & {
|
|
208
|
-
sandboxID: string;
|
|
209
|
-
}): Promise<Sandbox>;
|
|
210
233
|
/** Refresh this sandbox's data-plane session in place. */
|
|
211
234
|
connect(opts?: SandboxConnectOpts): Promise<this>;
|
|
212
235
|
/** Resume a paused sandbox by id. */
|
|
213
236
|
static resume(sandboxId: string, opts?: SandboxConnectOpts): Promise<boolean>;
|
|
214
237
|
/** Pause a sandbox by id. Returns false when it was already paused. */
|
|
215
238
|
static betaPause(sandboxId: string, opts?: ConnectionOpts): Promise<boolean>;
|
|
216
|
-
/**
|
|
239
|
+
/** Pause a sandbox by id. */
|
|
217
240
|
static pause(sandboxId: string, opts?: ConnectionOpts): Promise<boolean>;
|
|
218
241
|
/** Destroy a sandbox by id. */
|
|
219
242
|
static kill(sandboxId: string, opts?: ConnectionOpts | string): Promise<boolean>;
|
|
@@ -222,8 +245,6 @@ export declare class Sandbox {
|
|
|
222
245
|
/** Atomically replace a sandbox's network egress policy by id. */
|
|
223
246
|
static updateNetwork(sandboxId: string, network: SandboxNetworkUpdate, opts?: SandboxNetworkUpdateOpts): Promise<void>;
|
|
224
247
|
private static putNetwork;
|
|
225
|
-
/** Deprecated alias for `getInfo`. */
|
|
226
|
-
static getFullInfo(sandboxId: string, opts?: ConnectionOpts): Promise<SandboxInfo>;
|
|
227
248
|
/** Create a Watasu checkpoint using snapshot naming. */
|
|
228
249
|
static createSnapshot(sandboxId: string, opts?: CreateSnapshotOpts): Promise<SnapshotInfo>;
|
|
229
250
|
/** List snapshots visible to the configured API key. */
|
|
@@ -231,27 +252,25 @@ export declare class Sandbox {
|
|
|
231
252
|
/** Delete a snapshot by id. Returns `false` when the snapshot does not exist. */
|
|
232
253
|
static deleteSnapshot(snapshotId: string, opts?: ConnectionOpts): Promise<boolean>;
|
|
233
254
|
/** Destroy this sandbox. */
|
|
234
|
-
kill(): Promise<boolean>;
|
|
255
|
+
kill(opts?: SandboxRequestOpts): Promise<boolean>;
|
|
235
256
|
/** Check if this sandbox is in a runtime-active lifecycle state. */
|
|
236
|
-
isRunning(opts?:
|
|
257
|
+
isRunning(opts?: SandboxRequestOpts): Promise<boolean>;
|
|
237
258
|
/** Set a sandbox's lifetime by id. */
|
|
238
259
|
static setTimeout(sandboxId: string, timeoutMs: number, opts?: ConnectionOpts): Promise<void>;
|
|
239
260
|
/** Set this sandbox's lifetime. */
|
|
240
|
-
setTimeout(timeoutMs: number): Promise<void>;
|
|
241
|
-
/** Keep the sandbox alive for `duration` milliseconds. */
|
|
242
|
-
keepAlive(duration: number): Promise<void>;
|
|
261
|
+
setTimeout(timeoutMs: number, opts?: SandboxRequestOpts): Promise<void>;
|
|
243
262
|
/** Fetch control-plane metadata for a sandbox by id. */
|
|
244
263
|
static getInfo(sandboxId: string, opts?: ConnectionOpts): Promise<SandboxInfo>;
|
|
264
|
+
/** Fetch full control-plane metadata for a sandbox by id. */
|
|
265
|
+
static getFullInfo(sandboxId: string, opts?: ConnectionOpts): Promise<SandboxInfo>;
|
|
245
266
|
/** Fetch the latest control-plane metadata for this sandbox. */
|
|
246
|
-
getInfo(): Promise<SandboxInfo>;
|
|
267
|
+
getInfo(opts?: SandboxRequestOpts): Promise<SandboxInfo>;
|
|
247
268
|
/** Fetch latest sandbox metrics. */
|
|
248
269
|
getMetrics(opts?: SandboxMetricsOpts): Promise<SandboxMetrics[]>;
|
|
249
270
|
/** Create a Watasu checkpoint using snapshot naming. */
|
|
250
271
|
createSnapshot(opts?: CreateSnapshotOpts): Promise<SnapshotInfo>;
|
|
251
272
|
/** Delete a snapshot by id. */
|
|
252
273
|
deleteSnapshot(snapshotId: string, opts?: ConnectionOpts): Promise<boolean>;
|
|
253
|
-
/** Watasu-native alias for `createSnapshot`. */
|
|
254
|
-
checkpoint(opts?: CreateSnapshotOpts): Promise<SnapshotInfo>;
|
|
255
274
|
/** List checkpoints for this sandbox using snapshot naming. */
|
|
256
275
|
listSnapshots(opts?: Omit<SnapshotListOpts, 'sandboxId'>): SnapshotPaginator;
|
|
257
276
|
/** Restore a checkpoint into a new sandbox and return its control-plane info. */
|
|
@@ -260,16 +279,10 @@ export declare class Sandbox {
|
|
|
260
279
|
static list(opts?: SandboxListOpts | string): SandboxPaginator;
|
|
261
280
|
/** Return the public hostname for an exposed sandbox port. */
|
|
262
281
|
getHost(port: number): string;
|
|
263
|
-
/** Return the public hostname for the sandbox or an exposed sandbox port. */
|
|
264
|
-
getHostname(port?: number): string;
|
|
265
282
|
/** Return the conventional MCP URL for this sandbox. */
|
|
266
283
|
getMcpUrl(): string;
|
|
267
284
|
/** Return the MCP gateway token when the sandbox contains one. */
|
|
268
285
|
getMcpToken(): Promise<string | undefined>;
|
|
269
|
-
/** Return a protocol string for a secure or insecure sandbox URL. */
|
|
270
|
-
getProtocol(baseProtocol?: string, secure?: boolean): string;
|
|
271
|
-
/** Close the local SDK attachment. This does not destroy the sandbox. */
|
|
272
|
-
close(): Promise<void>;
|
|
273
286
|
/** Get a signed URL that accepts a POST upload for a sandbox file path. */
|
|
274
287
|
uploadUrl(path?: string, opts?: SandboxUrlOpts): Promise<string>;
|
|
275
288
|
/** Get a signed URL that accepts a GET download for a sandbox file path. */
|
|
@@ -282,7 +295,7 @@ export declare class Sandbox {
|
|
|
282
295
|
updateNetwork(network: SandboxNetworkUpdate, opts?: SandboxNetworkUpdateOpts): Promise<void>;
|
|
283
296
|
/** Pause this sandbox. Returns false when it was already paused. */
|
|
284
297
|
betaPause(opts?: ConnectionOpts): Promise<boolean>;
|
|
285
|
-
/**
|
|
298
|
+
/** Pause this sandbox. Returns false when it was already paused. */
|
|
286
299
|
pause(opts?: ConnectionOpts): Promise<boolean>;
|
|
287
300
|
/** Resume this sandbox and refresh its data-plane session. */
|
|
288
301
|
resume(opts?: SandboxConnectOpts): Promise<boolean>;
|
|
@@ -295,3 +308,4 @@ export declare class Sandbox {
|
|
|
295
308
|
protected runtimeDeleteJson(path: string, opts?: ConnectionOpts): Promise<Record<string, unknown>>;
|
|
296
309
|
private configOptions;
|
|
297
310
|
}
|
|
311
|
+
export {};
|