@watasu/sdk 0.1.6 → 0.1.24
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 +104 -8
- package/dist/commands.d.ts +26 -4
- package/dist/commands.js +54 -15
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +8 -0
- package/dist/filesystem.d.ts +53 -13
- package/dist/filesystem.js +128 -12
- package/dist/git.d.ts +27 -0
- package/dist/git.js +43 -2
- package/dist/index.d.ts +12 -6
- package/dist/index.js +6 -3
- package/dist/process.d.ts +56 -0
- package/dist/process.js +137 -0
- package/dist/processSocket.d.ts +1 -0
- package/dist/processSocket.js +3 -0
- package/dist/pty.d.ts +5 -1
- package/dist/pty.js +9 -7
- package/dist/sandbox.d.ts +118 -19
- package/dist/sandbox.js +246 -42
- package/dist/template.d.ts +232 -0
- package/dist/template.js +624 -0
- package/dist/terminal.d.ts +41 -0
- package/dist/terminal.js +74 -0
- package/dist/transport.d.ts +1 -0
- package/dist/transport.js +3 -0
- package/package.json +1 -1
package/dist/sandbox.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { ControlClient } from './transport.js';
|
|
|
4
4
|
import { Filesystem } from './filesystem.js';
|
|
5
5
|
import { Git } from './git.js';
|
|
6
6
|
import { Pty } from './pty.js';
|
|
7
|
+
import { ProcessManager } from './process.js';
|
|
8
|
+
import { TerminalManager } from './terminal.js';
|
|
7
9
|
export interface SandboxCreateOpts extends ConnectionOpts {
|
|
8
10
|
/** Template slug to create. Defaults to "base". */
|
|
9
11
|
template?: string;
|
|
@@ -13,14 +15,44 @@ export interface SandboxCreateOpts extends ConnectionOpts {
|
|
|
13
15
|
envs?: Record<string, string>;
|
|
14
16
|
secure?: boolean;
|
|
15
17
|
allowInternetAccess?: boolean;
|
|
18
|
+
network?: SandboxNetworkUpdate;
|
|
16
19
|
team?: string;
|
|
17
|
-
mcp
|
|
20
|
+
/** MCP gateway configuration to launch inside an `mcp-gateway` sandbox. */
|
|
21
|
+
mcp?: McpServer;
|
|
18
22
|
volumeMounts?: unknown;
|
|
19
23
|
}
|
|
24
|
+
export type SandboxNetworkSelector = string | string[];
|
|
25
|
+
export interface SandboxNetworkUpdate {
|
|
26
|
+
allowOut?: SandboxNetworkSelector;
|
|
27
|
+
denyOut?: SandboxNetworkSelector;
|
|
28
|
+
allowInternetAccess?: boolean;
|
|
29
|
+
allowPackageRegistryAccess?: boolean;
|
|
30
|
+
allowPublicTraffic?: boolean;
|
|
31
|
+
egressProfile?: string;
|
|
32
|
+
egressProfiles?: string[];
|
|
33
|
+
networkClass?: string;
|
|
34
|
+
rules?: unknown;
|
|
35
|
+
maskRequestHost?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface SandboxNetworkUpdateOpts extends ConnectionOpts {
|
|
38
|
+
}
|
|
20
39
|
export interface SandboxConnectOpts extends ConnectionOpts {
|
|
21
40
|
/** Optional new sandbox lifetime in milliseconds. */
|
|
22
41
|
timeoutMs?: number;
|
|
23
42
|
}
|
|
43
|
+
export interface SandboxListOpts extends ConnectionOpts {
|
|
44
|
+
/** Filters applied by the Watasu API. */
|
|
45
|
+
query?: {
|
|
46
|
+
metadata?: Record<string, string>;
|
|
47
|
+
state?: Array<'running' | 'paused' | string>;
|
|
48
|
+
};
|
|
49
|
+
/** Maximum number of sandboxes to return per page. */
|
|
50
|
+
limit?: number;
|
|
51
|
+
/** Pagination cursor returned by a previous page. */
|
|
52
|
+
nextToken?: string;
|
|
53
|
+
/** Team slug to list within. */
|
|
54
|
+
team?: string;
|
|
55
|
+
}
|
|
24
56
|
export interface SandboxInfo {
|
|
25
57
|
sandboxId: string;
|
|
26
58
|
templateId?: string;
|
|
@@ -56,6 +88,10 @@ export interface FileUrlInfo {
|
|
|
56
88
|
expiresAt?: string;
|
|
57
89
|
raw: Record<string, unknown>;
|
|
58
90
|
}
|
|
91
|
+
/** MCP gateway configuration accepted by `Sandbox.create({ mcp })`. */
|
|
92
|
+
export type McpServer = Record<string, unknown>;
|
|
93
|
+
/** Name accepted by `Template.addMcpServer`. Watasu keeps this open-ended. */
|
|
94
|
+
export type McpServerName = string;
|
|
59
95
|
export interface SandboxUrlOpts extends ConnectionOpts {
|
|
60
96
|
user?: string;
|
|
61
97
|
useSignatureExpiration?: number;
|
|
@@ -67,29 +103,62 @@ export interface CreateSnapshotOpts extends ConnectionOpts {
|
|
|
67
103
|
expiresAt?: string;
|
|
68
104
|
quiesceMode?: string;
|
|
69
105
|
}
|
|
106
|
+
export interface SnapshotListOpts extends ConnectionOpts {
|
|
107
|
+
/** Filter snapshots by source sandbox id. */
|
|
108
|
+
sandboxId?: string;
|
|
109
|
+
/** Maximum number of snapshots to return per page. */
|
|
110
|
+
limit?: number;
|
|
111
|
+
/** Pagination cursor returned by a previous page. */
|
|
112
|
+
nextToken?: string;
|
|
113
|
+
}
|
|
70
114
|
export interface RestoreSnapshotOpts extends ConnectionOpts {
|
|
71
115
|
checkpointId?: string | number;
|
|
72
116
|
snapshotId?: string | number;
|
|
73
117
|
timeout?: number;
|
|
74
118
|
timeoutMs?: number;
|
|
75
119
|
}
|
|
120
|
+
/** Paginator for listing sandbox snapshots. */
|
|
76
121
|
export declare class SnapshotPaginator {
|
|
77
|
-
private readonly
|
|
78
|
-
|
|
122
|
+
private readonly opts;
|
|
123
|
+
hasNext: boolean;
|
|
124
|
+
nextToken: string | undefined;
|
|
125
|
+
constructor(opts?: SnapshotListOpts);
|
|
126
|
+
/** Fetch the next page of snapshot metadata. */
|
|
127
|
+
nextItems(opts?: ConnectionOpts): Promise<SnapshotInfo[]>;
|
|
128
|
+
/** Drain all remaining pages into one list. */
|
|
129
|
+
listItems(opts?: ConnectionOpts): Promise<SnapshotInfo[]>;
|
|
130
|
+
}
|
|
131
|
+
/** Paginator for listing sandboxes. */
|
|
132
|
+
export declare class SandboxPaginator {
|
|
133
|
+
private readonly opts;
|
|
79
134
|
hasNext: boolean;
|
|
80
135
|
nextToken: string | undefined;
|
|
81
|
-
constructor(
|
|
82
|
-
|
|
136
|
+
constructor(opts?: SandboxListOpts);
|
|
137
|
+
/** Fetch the next page of sandbox metadata. */
|
|
138
|
+
nextItems(opts?: ConnectionOpts): Promise<SandboxInfo[]>;
|
|
139
|
+
/** Drain all remaining pages into one list. */
|
|
140
|
+
listItems(opts?: ConnectionOpts): Promise<SandboxInfo[]>;
|
|
83
141
|
}
|
|
84
142
|
/** Running Watasu sandbox with ready `files` and `commands` helpers. */
|
|
85
143
|
export declare class Sandbox {
|
|
86
144
|
/** Default template slug used when create is called without a template. */
|
|
87
145
|
static readonly defaultTemplate = "base";
|
|
146
|
+
/** Default template slug used by MCP creation once Watasu supports it. */
|
|
147
|
+
static readonly defaultMcpTemplate = "mcp-gateway";
|
|
148
|
+
/** Default sandbox lifetime in milliseconds. */
|
|
149
|
+
static readonly defaultSandboxTimeoutMs = 300000;
|
|
88
150
|
files: Filesystem;
|
|
151
|
+
filesystem: Filesystem;
|
|
89
152
|
commands: Commands;
|
|
153
|
+
process: ProcessManager;
|
|
90
154
|
pty: Pty;
|
|
155
|
+
terminal: TerminalManager;
|
|
91
156
|
git: Git;
|
|
157
|
+
cwd: string | undefined;
|
|
158
|
+
envVars: Record<string, string>;
|
|
92
159
|
readonly sandboxId: string;
|
|
160
|
+
private readonly mcpPort;
|
|
161
|
+
private mcpToken;
|
|
93
162
|
private readonly config;
|
|
94
163
|
private readonly control;
|
|
95
164
|
private readonly envs;
|
|
@@ -103,22 +172,38 @@ export declare class Sandbox {
|
|
|
103
172
|
sandbox?: Record<string, unknown>;
|
|
104
173
|
envs?: Record<string, string>;
|
|
105
174
|
});
|
|
175
|
+
/** Sandbox id alias used by SDK-compatible code. */
|
|
176
|
+
get id(): string;
|
|
106
177
|
static create(opts?: SandboxCreateOpts): Promise<Sandbox>;
|
|
107
178
|
static create(template: string, opts?: SandboxCreateOpts): Promise<Sandbox>;
|
|
108
179
|
/** Connect to an existing sandbox and return it with a fresh data-plane session. */
|
|
109
180
|
static connect(sandboxId: string, opts?: SandboxConnectOpts): Promise<Sandbox>;
|
|
181
|
+
/** Alias for `connect`. */
|
|
182
|
+
static reconnect(sandboxId: string, opts?: SandboxConnectOpts): Promise<Sandbox>;
|
|
183
|
+
static reconnect(opts: SandboxConnectOpts & {
|
|
184
|
+
sandboxID: string;
|
|
185
|
+
}): Promise<Sandbox>;
|
|
110
186
|
/** Refresh this sandbox's data-plane session in place. */
|
|
111
187
|
connect(opts?: SandboxConnectOpts): Promise<this>;
|
|
188
|
+
/** Resume a paused sandbox by id. */
|
|
189
|
+
static resume(sandboxId: string, opts?: SandboxConnectOpts): Promise<boolean>;
|
|
190
|
+
/** Pause a sandbox by id. Returns false when it was already paused. */
|
|
191
|
+
static betaPause(sandboxId: string, opts?: ConnectionOpts): Promise<boolean>;
|
|
192
|
+
/** Alias for `betaPause`. */
|
|
193
|
+
static pause(sandboxId: string, opts?: ConnectionOpts): Promise<boolean>;
|
|
112
194
|
/** Destroy a sandbox by id. */
|
|
113
|
-
static kill(sandboxId: string, opts?: ConnectionOpts): Promise<boolean>;
|
|
195
|
+
static kill(sandboxId: string, opts?: ConnectionOpts | string): Promise<boolean>;
|
|
114
196
|
/** Fetch sandbox metrics by id. */
|
|
115
197
|
static getMetrics(sandboxId: string, opts?: ConnectionOpts): Promise<SandboxMetrics[]>;
|
|
198
|
+
/** Atomically replace a sandbox's network egress policy by id. */
|
|
199
|
+
static updateNetwork(sandboxId: string, network: SandboxNetworkUpdate, opts?: SandboxNetworkUpdateOpts): Promise<void>;
|
|
200
|
+
private static putNetwork;
|
|
116
201
|
/** Deprecated alias for `getInfo`. */
|
|
117
202
|
static getFullInfo(sandboxId: string, opts?: ConnectionOpts): Promise<SandboxInfo>;
|
|
118
203
|
/** Create a Watasu checkpoint using snapshot naming. */
|
|
119
204
|
static createSnapshot(sandboxId: string, opts?: CreateSnapshotOpts): Promise<SnapshotInfo>;
|
|
120
|
-
/** List
|
|
121
|
-
static listSnapshots(
|
|
205
|
+
/** List snapshots visible to the configured API key. */
|
|
206
|
+
static listSnapshots(opts?: SnapshotListOpts): SnapshotPaginator;
|
|
122
207
|
/** Delete a snapshot by id. Returns `false` when the snapshot does not exist. */
|
|
123
208
|
static deleteSnapshot(snapshotId: string, opts?: ConnectionOpts): Promise<boolean>;
|
|
124
209
|
/** Destroy this sandbox. */
|
|
@@ -129,6 +214,8 @@ export declare class Sandbox {
|
|
|
129
214
|
static setTimeout(sandboxId: string, timeoutMs: number, opts?: ConnectionOpts): Promise<void>;
|
|
130
215
|
/** Set this sandbox's lifetime. */
|
|
131
216
|
setTimeout(timeoutMs: number): Promise<void>;
|
|
217
|
+
/** Keep the sandbox alive for `duration` milliseconds. */
|
|
218
|
+
keepAlive(duration: number): Promise<void>;
|
|
132
219
|
/** Fetch control-plane metadata for a sandbox by id. */
|
|
133
220
|
static getInfo(sandboxId: string, opts?: ConnectionOpts): Promise<SandboxInfo>;
|
|
134
221
|
/** Fetch the latest control-plane metadata for this sandbox. */
|
|
@@ -142,27 +229,39 @@ export declare class Sandbox {
|
|
|
142
229
|
/** Watasu-native alias for `createSnapshot`. */
|
|
143
230
|
checkpoint(opts?: CreateSnapshotOpts): Promise<SnapshotInfo>;
|
|
144
231
|
/** List checkpoints for this sandbox using snapshot naming. */
|
|
145
|
-
listSnapshots(opts?:
|
|
232
|
+
listSnapshots(opts?: Omit<SnapshotListOpts, 'sandboxId'>): SnapshotPaginator;
|
|
146
233
|
/** Restore a checkpoint into a new sandbox and return its control-plane info. */
|
|
147
234
|
restore(opts?: RestoreSnapshotOpts | string | number): Promise<SandboxInfo>;
|
|
148
|
-
/**
|
|
149
|
-
static list(opts?:
|
|
150
|
-
team?: string;
|
|
151
|
-
}): Promise<SandboxInfo[]>;
|
|
235
|
+
/** Return a paginator for sandboxes visible to the configured API key. */
|
|
236
|
+
static list(opts?: SandboxListOpts | string): SandboxPaginator;
|
|
152
237
|
/** Return the public hostname for an exposed sandbox port. */
|
|
153
238
|
getHost(port: number): string;
|
|
239
|
+
/** Return the public hostname for the sandbox or an exposed sandbox port. */
|
|
240
|
+
getHostname(port?: number): string;
|
|
241
|
+
/** Return the conventional MCP URL for this sandbox. */
|
|
242
|
+
getMcpUrl(): string;
|
|
243
|
+
/** Return the MCP gateway token when the sandbox contains one. */
|
|
244
|
+
getMcpToken(): Promise<string | undefined>;
|
|
245
|
+
/** Return a protocol string for a secure or insecure sandbox URL. */
|
|
246
|
+
getProtocol(baseProtocol?: string, secure?: boolean): string;
|
|
247
|
+
/** Close the local SDK attachment. This does not destroy the sandbox. */
|
|
248
|
+
close(): Promise<void>;
|
|
154
249
|
/** Get a signed URL that accepts a POST upload for a sandbox file path. */
|
|
155
|
-
uploadUrl(path
|
|
250
|
+
uploadUrl(path?: string, opts?: SandboxUrlOpts): Promise<string>;
|
|
156
251
|
/** Get a signed URL that accepts a GET download for a sandbox file path. */
|
|
157
252
|
downloadUrl(path: string, opts?: SandboxUrlOpts): Promise<string>;
|
|
158
253
|
/** Get signed upload URL metadata for a sandbox file path. */
|
|
159
|
-
uploadUrlInfo(path
|
|
254
|
+
uploadUrlInfo(path?: string, opts?: SandboxUrlOpts): Promise<FileUrlInfo>;
|
|
160
255
|
/** Get signed download URL metadata for a sandbox file path. */
|
|
161
256
|
downloadUrlInfo(path: string, opts?: SandboxUrlOpts): Promise<FileUrlInfo>;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
257
|
+
/** Atomically replace this sandbox's network egress policy. */
|
|
258
|
+
updateNetwork(network: SandboxNetworkUpdate, opts?: SandboxNetworkUpdateOpts): Promise<void>;
|
|
259
|
+
/** Pause this sandbox. Returns false when it was already paused. */
|
|
260
|
+
betaPause(opts?: ConnectionOpts): Promise<boolean>;
|
|
261
|
+
/** Alias for `betaPause`. */
|
|
262
|
+
pause(opts?: ConnectionOpts): Promise<boolean>;
|
|
263
|
+
/** Resume this sandbox and refresh its data-plane session. */
|
|
264
|
+
resume(opts?: SandboxConnectOpts): Promise<boolean>;
|
|
166
265
|
private fileUrl;
|
|
167
266
|
private configOptions;
|
|
168
267
|
}
|