@lightningai/sdk 2026.5.6-post2 → 2026.5.15-post0
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 +90 -0
- package/dist/command.d.ts +63 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +85 -0
- package/dist/command.js.map +1 -0
- package/dist/filesystem.d.ts.map +1 -1
- package/dist/filesystem.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/lightning_cloud/openapi/data-contracts.d.ts +35 -0
- package/dist/lightning_cloud/openapi/data-contracts.d.ts.map +1 -1
- package/dist/process.d.ts +115 -0
- package/dist/process.d.ts.map +1 -0
- package/dist/process.js +254 -0
- package/dist/process.js.map +1 -0
- package/dist/pty.d.ts +121 -0
- package/dist/pty.d.ts.map +1 -0
- package/dist/pty.js +264 -0
- package/dist/pty.js.map +1 -0
- package/dist/sandbox.d.ts +53 -3
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +73 -4
- package/dist/sandbox.js.map +1 -1
- package/dist/types.d.ts +82 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -50,6 +50,96 @@ Environment variables read by the SDK:
|
|
|
50
50
|
| ------------------- | --------------------------------------------------------- |
|
|
51
51
|
| `LIGHTNING_API_KEY` | API key if not passed via `configure()` / request options |
|
|
52
52
|
|
|
53
|
+
## PTY sessions
|
|
54
|
+
|
|
55
|
+
For interactive shells (REPLs, build watchers, anything that needs `stdin`/window-resize/ANSI), use the `sandbox.process` namespace instead of `runCommand`. PTY sessions are bridged over a WebSocket from the controlplane down to the in-sandbox SSH server, with the same xterm wire protocol the Lightning UI's web terminal uses.
|
|
56
|
+
|
|
57
|
+
PTY support requires Node 22+ (for the built-in `WebSocket` global).
|
|
58
|
+
|
|
59
|
+
### Create a session
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
const pty = await sandbox.process.createPty({
|
|
63
|
+
sessionName: "build",
|
|
64
|
+
clusterId: sandbox.clusterId,
|
|
65
|
+
cwd: "/app",
|
|
66
|
+
cols: 120,
|
|
67
|
+
rows: 30,
|
|
68
|
+
envs: { TERM: "xterm-256color" },
|
|
69
|
+
onData: (chunk) => process.stdout.write(chunk),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
await pty.waitForConnection();
|
|
73
|
+
await pty.sendInput("npm test\n");
|
|
74
|
+
await pty.sendInput("exit\n");
|
|
75
|
+
|
|
76
|
+
const result = await pty.wait();
|
|
77
|
+
console.log(`exit code: ${result.exitCode}`);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
| Option | Type | Description |
|
|
81
|
+
| ------------- | --------------------------- | ---------------------------------------------------------------------- |
|
|
82
|
+
| `sessionName` | `string` | Session identifier (used by `connectPty`) |
|
|
83
|
+
| `clusterId` | `string` | Cluster the sandbox runs on (`sandbox.clusterId`) |
|
|
84
|
+
| `cwd` | `string` | Initial working directory |
|
|
85
|
+
| `envs` | `Record<string, string>` | Environment variables exported into the session |
|
|
86
|
+
| `cols` | `number` | Initial terminal columns (default 80) |
|
|
87
|
+
| `rows` | `number` | Initial terminal rows (default 24) |
|
|
88
|
+
| `onData` | `(chunk: Uint8Array)=>void` | Callback for every chunk of shell output (defaults to `writeToStdout`) |
|
|
89
|
+
|
|
90
|
+
If `onData` is omitted, the SDK uses the exported `writeToStdout` helper, which forwards raw shell bytes to `process.stdout`. Pass `onData: () => {}` to suppress.
|
|
91
|
+
|
|
92
|
+
### Reconnect to a session
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const pty = await sandbox.process.connectPty("build", sandbox.clusterId, {
|
|
96
|
+
onData: (chunk) => process.stdout.write(chunk),
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### List, inspect, and kill sessions
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
const sessions = await sandbox.process.listPtySessions();
|
|
104
|
+
for (const s of sessions) {
|
|
105
|
+
console.log(s.id, s.active, s.cols, s.rows);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const info = await sandbox.process.getPtySessionInfo("build");
|
|
109
|
+
await sandbox.process.killPtySession("build");
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Resize
|
|
113
|
+
|
|
114
|
+
Resize from a handle (preferred — works without a server round-trip):
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
await pty.resize(150, 40);
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Or via the namespace, which finds the live handle in this process:
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
await sandbox.process.resizePtySession("build", 150, 40);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### `PtyHandle` reference
|
|
127
|
+
|
|
128
|
+
| Member | Description |
|
|
129
|
+
| --------------------------------- | -------------------------------------------------------- |
|
|
130
|
+
| `sendInput(string \| Uint8Array)` | Send raw bytes to the shell (e.g. `"\u0003"` for Ctrl+C) |
|
|
131
|
+
| `resize(cols, rows)` | Send a resize control frame |
|
|
132
|
+
| `wait()` | Resolve when the WebSocket closes; returns `PtyResult` |
|
|
133
|
+
| `waitForConnection(timeoutMs?)` | Resolve when the WebSocket opens |
|
|
134
|
+
| `kill()` | Send Ctrl+C and disconnect |
|
|
135
|
+
| `disconnect()` | Close the WebSocket without killing the shell |
|
|
136
|
+
| `isConnected()` | Whether the WebSocket is OPEN |
|
|
137
|
+
| `exitCode` | `0` on clean close, `-1` on abnormal, `null` while alive |
|
|
138
|
+
| `error` | Termination reason on abnormal close, otherwise `null` |
|
|
139
|
+
| `size` | Most recent `{ cols, rows }` |
|
|
140
|
+
|
|
141
|
+
> **Note on cross-process persistence.** Within a single SDK process, every PTY method works against an in-process registry. Reattaching from a *different* process to a session that's still running on the sandbox requires the runtime image to ship `screen` (or similar) and the in-sandbox SSH login shell to honor `LAI_TERM_SESSION_NAME` / `LAI_TERM_RESTORE` — both of which are tracked as a follow-up to this initial parity work. The API surface above does not change either way.
|
|
142
|
+
|
|
53
143
|
## License
|
|
54
144
|
|
|
55
145
|
Apache-2.0
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Sandbox } from "./sandbox.js";
|
|
2
|
+
import type { CommandStatus, WaitForCommandOptions } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Handle for a command running (or finished) inside a sandbox.
|
|
5
|
+
*
|
|
6
|
+
* - When {@link Sandbox.runCommand} is awaited *without* `detached: true`, the
|
|
7
|
+
* server has already waited for the process to exit, so `exitCode` is a
|
|
8
|
+
* number and `running` is `false` immediately.
|
|
9
|
+
* - When `detached: true` is passed, the call returns immediately with
|
|
10
|
+
* `exitCode === null` and `running === true`. Call {@link wait} to block
|
|
11
|
+
* until the process exits, or {@link kill} to terminate it.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const detachedCmd = await sandbox.runCommand({
|
|
15
|
+
* cmd: "sleep",
|
|
16
|
+
* args: ["5"],
|
|
17
|
+
* detached: true,
|
|
18
|
+
* });
|
|
19
|
+
* const result = await detachedCmd.wait();
|
|
20
|
+
* if (result.exitCode !== 0) {
|
|
21
|
+
* console.error("Something went wrong...");
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class Command {
|
|
26
|
+
readonly cmdId: string;
|
|
27
|
+
/** Captured combined stdout/stderr seen so far. Updated by {@link wait} and {@link getStatus}. */
|
|
28
|
+
output: string;
|
|
29
|
+
/** Exit code; `null` while the command is still running. */
|
|
30
|
+
exitCode: number | null;
|
|
31
|
+
protected readonly sandbox: Sandbox;
|
|
32
|
+
constructor(sandbox: Sandbox, data: {
|
|
33
|
+
cmdId: string;
|
|
34
|
+
output: string;
|
|
35
|
+
exitCode: number | null;
|
|
36
|
+
});
|
|
37
|
+
/** `true` while the command is still executing (i.e. {@link exitCode} is `null`). */
|
|
38
|
+
get running(): boolean;
|
|
39
|
+
/** Returns the captured combined stdout/stderr buffered on the handle. */
|
|
40
|
+
stdout(): string;
|
|
41
|
+
/** Alias for {@link stdout}; the API exposes a single combined output stream. */
|
|
42
|
+
stderr(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Refresh status from the server, updating {@link output} and {@link exitCode}.
|
|
45
|
+
*
|
|
46
|
+
* The returned {@link CommandStatus} is the raw server response and is also
|
|
47
|
+
* useful for inspecting `running` directly.
|
|
48
|
+
*/
|
|
49
|
+
getStatus(): Promise<CommandStatus>;
|
|
50
|
+
/**
|
|
51
|
+
* Block until the command exits, then return this handle with `exitCode`
|
|
52
|
+
* populated. Essential for detached commands where you need to know when
|
|
53
|
+
* execution completes; for non-detached commands, {@link Sandbox.runCommand}
|
|
54
|
+
* already waits automatically and `wait()` returns immediately.
|
|
55
|
+
*
|
|
56
|
+
* Resolves immediately if the command has already exited. Otherwise polls
|
|
57
|
+
* {@link Sandbox.getCommand} until `running` becomes `false`.
|
|
58
|
+
*/
|
|
59
|
+
wait(opts?: WaitForCommandOptions): Promise<Command>;
|
|
60
|
+
/** Terminate the command (best effort) via {@link Sandbox.killCommand}. */
|
|
61
|
+
kill(): Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,OAAO;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,kGAAkG;IAClG,MAAM,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAExB,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;gBAGlC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;IAQlE,qFAAqF;IACrF,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,0EAA0E;IAC1E,MAAM,IAAI,MAAM;IAIhB,iFAAiF;IACjF,MAAM,IAAI,MAAM;IAIhB;;;;;OAKG;IACG,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC;IASzC;;;;;;;;OAQG;IACG,IAAI,CAAC,IAAI,GAAE,qBAA0B,GAAG,OAAO,CAAC,OAAO,CAAC;IAU9D,2EAA2E;IACrE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
|
package/dist/command.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handle for a command running (or finished) inside a sandbox.
|
|
3
|
+
*
|
|
4
|
+
* - When {@link Sandbox.runCommand} is awaited *without* `detached: true`, the
|
|
5
|
+
* server has already waited for the process to exit, so `exitCode` is a
|
|
6
|
+
* number and `running` is `false` immediately.
|
|
7
|
+
* - When `detached: true` is passed, the call returns immediately with
|
|
8
|
+
* `exitCode === null` and `running === true`. Call {@link wait} to block
|
|
9
|
+
* until the process exits, or {@link kill} to terminate it.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const detachedCmd = await sandbox.runCommand({
|
|
13
|
+
* cmd: "sleep",
|
|
14
|
+
* args: ["5"],
|
|
15
|
+
* detached: true,
|
|
16
|
+
* });
|
|
17
|
+
* const result = await detachedCmd.wait();
|
|
18
|
+
* if (result.exitCode !== 0) {
|
|
19
|
+
* console.error("Something went wrong...");
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export class Command {
|
|
24
|
+
cmdId;
|
|
25
|
+
/** Captured combined stdout/stderr seen so far. Updated by {@link wait} and {@link getStatus}. */
|
|
26
|
+
output;
|
|
27
|
+
/** Exit code; `null` while the command is still running. */
|
|
28
|
+
exitCode;
|
|
29
|
+
sandbox;
|
|
30
|
+
constructor(sandbox, data) {
|
|
31
|
+
this.sandbox = sandbox;
|
|
32
|
+
this.cmdId = data.cmdId;
|
|
33
|
+
this.output = data.output;
|
|
34
|
+
this.exitCode = data.exitCode;
|
|
35
|
+
}
|
|
36
|
+
/** `true` while the command is still executing (i.e. {@link exitCode} is `null`). */
|
|
37
|
+
get running() {
|
|
38
|
+
return this.exitCode === null;
|
|
39
|
+
}
|
|
40
|
+
/** Returns the captured combined stdout/stderr buffered on the handle. */
|
|
41
|
+
stdout() {
|
|
42
|
+
return this.output;
|
|
43
|
+
}
|
|
44
|
+
/** Alias for {@link stdout}; the API exposes a single combined output stream. */
|
|
45
|
+
stderr() {
|
|
46
|
+
return this.output;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Refresh status from the server, updating {@link output} and {@link exitCode}.
|
|
50
|
+
*
|
|
51
|
+
* The returned {@link CommandStatus} is the raw server response and is also
|
|
52
|
+
* useful for inspecting `running` directly.
|
|
53
|
+
*/
|
|
54
|
+
async getStatus() {
|
|
55
|
+
const status = await this.sandbox.getCommand(this.cmdId);
|
|
56
|
+
this.output = status.output;
|
|
57
|
+
if (!status.running) {
|
|
58
|
+
this.exitCode = status.exitCode;
|
|
59
|
+
}
|
|
60
|
+
return status;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Block until the command exits, then return this handle with `exitCode`
|
|
64
|
+
* populated. Essential for detached commands where you need to know when
|
|
65
|
+
* execution completes; for non-detached commands, {@link Sandbox.runCommand}
|
|
66
|
+
* already waits automatically and `wait()` returns immediately.
|
|
67
|
+
*
|
|
68
|
+
* Resolves immediately if the command has already exited. Otherwise polls
|
|
69
|
+
* {@link Sandbox.getCommand} until `running` becomes `false`.
|
|
70
|
+
*/
|
|
71
|
+
async wait(opts = {}) {
|
|
72
|
+
if (this.exitCode !== null) {
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
const final = await this.sandbox.waitForCommand(this.cmdId, opts);
|
|
76
|
+
this.output = final.output;
|
|
77
|
+
this.exitCode = final.exitCode;
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
/** Terminate the command (best effort) via {@link Sandbox.killCommand}. */
|
|
81
|
+
async kill() {
|
|
82
|
+
await this.sandbox.killCommand(this.cmdId);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,OAAO;IACT,KAAK,CAAS;IACvB,kGAAkG;IAClG,MAAM,CAAS;IACf,4DAA4D;IAC5D,QAAQ,CAAgB;IAEL,OAAO,CAAU;IAEpC,YACE,OAAgB,EAChB,IAAgE;QAEhE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAChC,CAAC;IAED,qFAAqF;IACrF,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC;IAChC,CAAC;IAED,0EAA0E;IAC1E,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,iFAAiF;IACjF,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS;QACb,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAClC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,IAAI,CAAC,OAA8B,EAAE;QACzC,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAClE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,2EAA2E;IAC3E,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;CACF"}
|
package/dist/filesystem.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../src/filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../src/filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAQ5D,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,OAAO;IAEvC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IACvD,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IASjD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKtC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiBrC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAMxC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAM/D,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvD,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKlD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMzD,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAI3D"}
|
package/dist/filesystem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesystem.js","sourceRoot":"","sources":["../src/filesystem.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filesystem.js","sourceRoot":"","sources":["../src/filesystem.ts"],"names":[],"mappings":"AAIA,SAAS,eAAe,CAAC,CAAU,EAAE,IAAY;IAC/C,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC;QAAE,OAAO;IAC7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AC,EAAE,UAAU,OAAO,OAAO,OAAO,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,GAAW,EAAE,IAAY;QACtC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;QAC3D,eAAe,CAAC,CAAC,EAAE,YAAY,GAAG,OAAO,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,IAAY,EAAE,IAAqB;QAC7C,MAAM,CAAC,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC7D,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QAC5D,eAAe,CAAC,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,IAAY;QACxC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;QACpE,eAAe,CAAC,CAAC,EAAE,WAAW,IAAI,EAAE,CAAC,CAAC;IACxC,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { Sandbox } from "./sandbox.js";
|
|
2
2
|
export { FileSystem } from "./filesystem.js";
|
|
3
|
-
export
|
|
3
|
+
export { Command } from "./command.js";
|
|
4
|
+
export { SandboxProcess } from "./process.js";
|
|
5
|
+
export { PtyHandle, writeToStdout } from "./pty.js";
|
|
6
|
+
export type { SandboxConfig, SandboxData, CreateSandboxParams, GetSandboxParams, ListSandboxesParams, ListSandboxesResponse, RunCommandOpts, CommandStatus, CommandLog, WaitForCommandOptions, WriteFileParams, ReadFileParams, CreateDirectoryParams, FileStat, PtySize, PtyCreateOpts, PtyConnectOpts, PtyResult, PtySessionInfo, } from "./types.js";
|
|
4
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EACV,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACpD,YAAY,EACV,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,UAAU,EACV,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,QAAQ,EACR,OAAO,EACP,aAAa,EACb,cAAc,EACd,SAAS,EACT,cAAc,GACf,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -191,6 +191,12 @@ export interface V1CreateSandboxRequest {
|
|
|
191
191
|
* @format uint64
|
|
192
192
|
*/
|
|
193
193
|
timeout?: string;
|
|
194
|
+
/**
|
|
195
|
+
* Network access policy for the sandbox. Controls which external hosts the
|
|
196
|
+
* sandbox can communicate with. When unset, the sandbox inherits the default
|
|
197
|
+
* network policy.
|
|
198
|
+
*/
|
|
199
|
+
networkPolicy?: V1NetworkPolicy;
|
|
194
200
|
}
|
|
195
201
|
export type V1DeleteSandboxResponse = object;
|
|
196
202
|
export type V1ExtendSandboxTimeoutResponse = object;
|
|
@@ -202,6 +208,7 @@ export interface V1GetSandboxCommandResponse {
|
|
|
202
208
|
output?: string;
|
|
203
209
|
/** @format int32 */
|
|
204
210
|
exitCode?: number;
|
|
211
|
+
running?: boolean;
|
|
205
212
|
}
|
|
206
213
|
export interface V1GetSandboxFileResponse {
|
|
207
214
|
content?: string;
|
|
@@ -218,6 +225,34 @@ export interface V1LogMessage {
|
|
|
218
225
|
timestamp?: string;
|
|
219
226
|
message?: string;
|
|
220
227
|
}
|
|
228
|
+
/** NetworkPolicy controls outbound network access for a sandbox. */
|
|
229
|
+
export interface V1NetworkPolicy {
|
|
230
|
+
/**
|
|
231
|
+
* The network access policy mode.
|
|
232
|
+
* - "allow-all": permit all outbound traffic.
|
|
233
|
+
* - "deny-all": block all outbound traffic.
|
|
234
|
+
* - "custom": specify explicit allow/deny rules via the fields below.
|
|
235
|
+
* - "default-allow": allow all traffic except for explicit deny rules.
|
|
236
|
+
* - "default-deny": deny all traffic except for explicit allow rules.
|
|
237
|
+
*/
|
|
238
|
+
mode?: string;
|
|
239
|
+
/**
|
|
240
|
+
* List of domain names the sandbox is allowed to connect to. Only applies
|
|
241
|
+
* when mode is "custom". Supports wildcard patterns (e.g., "*.example.com"
|
|
242
|
+
* matches all subdomains).
|
|
243
|
+
*/
|
|
244
|
+
allowedDomains?: string[];
|
|
245
|
+
/**
|
|
246
|
+
* List of IP address ranges (in CIDR notation) the sandbox is allowed to
|
|
247
|
+
* connect to. Traffic to these addresses bypasses domain-based restrictions.
|
|
248
|
+
*/
|
|
249
|
+
allowedCidrs?: string[];
|
|
250
|
+
/**
|
|
251
|
+
* List of IP address ranges (in CIDR notation) the sandbox is blocked from
|
|
252
|
+
* connecting to. These rules take precedence over all allowed rules.
|
|
253
|
+
*/
|
|
254
|
+
deniedCidrs?: string[];
|
|
255
|
+
}
|
|
221
256
|
export interface V1RunSandboxCommandResponse {
|
|
222
257
|
cmdId?: string;
|
|
223
258
|
output?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-contracts.d.ts","sourceRoot":"","sources":["../../../src/lightning_cloud/openapi/data-contracts.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,0CAA0C;IACzD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,wCAAwC;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qCAAqC;IACpD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,E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IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"data-contracts.d.ts","sourceRoot":"","sources":["../../../src/lightning_cloud/openapi/data-contracts.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,0CAA0C;IACzD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,wCAAwC;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qCAAqC;IACpD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,oCAAoC;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;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PtyConnectOpts, PtyCreateOpts, PtySessionInfo, RunCommandOpts } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Runtime context the `Sandbox` passes into a `SandboxProcess` so that
|
|
6
|
+
* the PTY namespace can build URLs, authenticate, and shell out to
|
|
7
|
+
* `runCommand` for session bookkeeping without importing the `Sandbox`
|
|
8
|
+
* class directly (avoids a circular dependency).
|
|
9
|
+
*
|
|
10
|
+
* Internal — not part of the public API surface.
|
|
11
|
+
*/
|
|
12
|
+
export interface SandboxProcessContext {
|
|
13
|
+
sandboxId: string;
|
|
14
|
+
organizationId: string;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the resolved API key. Mirrors the lazy lookup used by the
|
|
17
|
+
* REST request helpers so that `Sandbox.configure` calls made after
|
|
18
|
+
* the sandbox object was created are still honored.
|
|
19
|
+
*/
|
|
20
|
+
getApiKey(): string;
|
|
21
|
+
/** Returns the resolved base URL (with no trailing slash). */
|
|
22
|
+
getBaseUrl(): string;
|
|
23
|
+
/** Forwards to `Sandbox.runCommand`. */
|
|
24
|
+
runCommand(opts: RunCommandOpts): Promise<Command>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* `sandbox.process` — interactive shell sessions on a sandbox.
|
|
28
|
+
*
|
|
29
|
+
* Mirrors the Daytona PTY surface so existing code shaped around it
|
|
30
|
+
* ports over with mechanical changes only. Under the hood, every method
|
|
31
|
+
* either opens a WebSocket against the controlplane's
|
|
32
|
+
* `/v1/clusters/{clusterId}/machines/{sandboxId}/attach` endpoint (which
|
|
33
|
+
* is bridged to the in-sandbox SSH server at port 2222) or shells out to
|
|
34
|
+
* `screen` via the existing `runCommand` REST API for session
|
|
35
|
+
* bookkeeping.
|
|
36
|
+
*
|
|
37
|
+
* Within a single SDK process every method works against a local
|
|
38
|
+
* registry. Cross-process session persistence (i.e. `connectPty` from
|
|
39
|
+
* a fresh process to a session created elsewhere) requires the sandbox
|
|
40
|
+
* runtime image to ship `screen` and the gliderlabs SSH login shell to
|
|
41
|
+
* honor `LAI_TERM_SESSION_NAME` / `LAI_TERM_RESTORE` — both of which
|
|
42
|
+
* are tracked as a follow-up to this initial parity work.
|
|
43
|
+
*/
|
|
44
|
+
export declare class SandboxProcess {
|
|
45
|
+
private readonly ctx;
|
|
46
|
+
/**
|
|
47
|
+
* Live handles bound to this `SandboxProcess`, keyed by their
|
|
48
|
+
* caller-chosen session name. Used by `connectPty` /
|
|
49
|
+
* `getPtySessionInfo` / `killPtySession` / `resizePtySession` to find
|
|
50
|
+
* an existing session before falling back to `screen -ls` over
|
|
51
|
+
* `runCommand`.
|
|
52
|
+
*/
|
|
53
|
+
private readonly handles;
|
|
54
|
+
constructor(ctx: SandboxProcessContext);
|
|
55
|
+
/**
|
|
56
|
+
* Create a new PTY session on the sandbox.
|
|
57
|
+
*
|
|
58
|
+
* ```ts
|
|
59
|
+
* const pty = await sandbox.process.createPty({
|
|
60
|
+
* sessionName: "build",
|
|
61
|
+
* clusterId: sandbox.clusterId,
|
|
62
|
+
* cols: 120,
|
|
63
|
+
* rows: 30,
|
|
64
|
+
* onData: (chunk) => process.stdout.write(chunk),
|
|
65
|
+
* });
|
|
66
|
+
* await pty.waitForConnection();
|
|
67
|
+
* await pty.sendInput("npm test\n");
|
|
68
|
+
* const result = await pty.wait();
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
createPty(opts: PtyCreateOpts): Promise<PtyHandle>;
|
|
72
|
+
/**
|
|
73
|
+
* Reattach to a PTY session that was previously created by `createPty`.
|
|
74
|
+
*
|
|
75
|
+
* ```ts
|
|
76
|
+
* const pty = await sandbox.process.connectPty("build", sandbox.clusterId, {
|
|
77
|
+
* onData: (chunk) => process.stdout.write(chunk),
|
|
78
|
+
* });
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
connectPty(sessionName: string, clusterId: string, opts?: PtyConnectOpts): Promise<PtyHandle>;
|
|
82
|
+
/**
|
|
83
|
+
* List PTY sessions on the sandbox. Implemented as a `screen -ls`
|
|
84
|
+
* call via {@link runCommand} so no new server endpoint is required.
|
|
85
|
+
* Returns the union of locally-tracked handles and remote `screen`
|
|
86
|
+
* sessions; locally-tracked handles include live `cols`/`rows`.
|
|
87
|
+
*/
|
|
88
|
+
listPtySessions(): Promise<PtySessionInfo[]>;
|
|
89
|
+
/**
|
|
90
|
+
* Look up a single PTY session.
|
|
91
|
+
*
|
|
92
|
+
* ```ts
|
|
93
|
+
* const info = await sandbox.process.getPtySessionInfo("build");
|
|
94
|
+
* console.log(info.active);
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
getPtySessionInfo(id: string): Promise<PtySessionInfo>;
|
|
98
|
+
/**
|
|
99
|
+
* Forcefully terminate a PTY session. Closes any live `PtyHandle` for
|
|
100
|
+
* the session within this SDK process and runs
|
|
101
|
+
* `screen -X -S {id} quit` on the sandbox so the remote screen
|
|
102
|
+
* session (when present) is also torn down.
|
|
103
|
+
*/
|
|
104
|
+
killPtySession(id: string): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Resize the terminal of an active PTY session. Requires the session
|
|
107
|
+
* to be currently attached in this SDK process; the existing wire
|
|
108
|
+
* protocol carries resize as a JSON control frame on the open
|
|
109
|
+
* WebSocket and offers no out-of-band REST equivalent.
|
|
110
|
+
*/
|
|
111
|
+
resizePtySession(id: string, cols: number, rows: number): Promise<PtySessionInfo>;
|
|
112
|
+
/** Internal: builds the WebSocket URL and opens the connection. */
|
|
113
|
+
private openPty;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=process.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,cAAc,E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