@cloudflare/sandbox 0.13.0-next.802.1 → 0.13.0-next.816.1
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 +7 -0
- package/dist/bridge/index.js +21 -12
- package/dist/bridge/index.js.map +1 -1
- package/dist/extensions/index.d.ts +2 -2
- package/dist/extensions/index.js +1 -1
- package/dist/{extensions-BKL2zqL4.js → extensions-038QzSIg.js} +5 -1
- package/dist/extensions-038QzSIg.js.map +1 -0
- package/dist/{filesystem-Y5aF3nmJ.d.ts → filesystem-Cd6xd_Pe.d.ts} +5 -1
- package/dist/filesystem-Cd6xd_Pe.d.ts.map +1 -0
- package/dist/git/index.d.ts +2 -2
- package/dist/git/index.js +1 -1
- package/dist/{index-DfXx3uZL.d.ts → index-Fbdwkfft.d.ts} +9 -3
- package/dist/index-Fbdwkfft.d.ts.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/interpreter/index.d.ts +2 -2
- package/dist/interpreter/index.js +1 -1
- package/dist/openai/index.d.ts +2 -2
- package/dist/opencode/index.d.ts +2 -2
- package/dist/opencode/index.js +1 -1
- package/dist/{sandbox-CaesWCLh.js → sandbox-CpelK4pU.js} +140 -51
- package/dist/sandbox-CpelK4pU.js.map +1 -0
- package/dist/{sandbox-CBkS3tGv.d.ts → sandbox-D1BoB5f7.d.ts} +2 -2
- package/dist/{sandbox-CBkS3tGv.d.ts.map → sandbox-D1BoB5f7.d.ts.map} +1 -1
- package/package.json +1 -1
- package/dist/extensions-BKL2zqL4.js.map +0 -1
- package/dist/filesystem-Y5aF3nmJ.d.ts.map +0 -1
- package/dist/index-DfXx3uZL.d.ts.map +0 -1
- package/dist/sandbox-CaesWCLh.js.map +0 -1
package/README.md
CHANGED
|
@@ -140,6 +140,13 @@ const recovered = await sandbox.getProcess(server.id);
|
|
|
140
140
|
const running = await sandbox.listProcesses();
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
+
Process and terminal handles hold a Workers RPC reference to the Sandbox. Declare them with `using` to release that reference when the handle goes out of scope; the process keeps running:
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
using build = await sandbox.exec(['npm', 'run', 'build']);
|
|
147
|
+
const { exitCode } = await build.output({ encoding: 'utf8' });
|
|
148
|
+
```
|
|
149
|
+
|
|
143
150
|
`getProcess()` and `listProcesses()` are non-waking discovery calls: with no active runtime they return `null` and `[]` instead of starting a replacement. Handles, IDs, PIDs, statuses, retained logs, and cursors belong to the runtime that launched the process. After sleep, restart, or replacement, discovery cannot recover them and operations on an old handle fail with `STALE_PROCESS_HANDLE` rather than targeting a replacement runtime.
|
|
144
151
|
|
|
145
152
|
Use `createTerminal()` for a persistent interactive PTY shell with input, resize, interrupt, terminate, and reconnect semantics. Terminals remain separate from supervised processes and are also runtime-local.
|
package/dist/bridge/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "../errors-Bb3s6nBS.js";
|
|
2
2
|
import "../errors--yR3zLC_.js";
|
|
3
3
|
import "../dist-n_eniPAR.js";
|
|
4
|
-
import { g as validateTunnelName, h as validatePort, m as SandboxSecurityError, n as getSandbox$1, x as streamFile } from "../sandbox-
|
|
5
|
-
import "../extensions-
|
|
4
|
+
import { g as validateTunnelName, h as validatePort, m as SandboxSecurityError, n as getSandbox$1, x as streamFile } from "../sandbox-CpelK4pU.js";
|
|
5
|
+
import "../extensions-038QzSIg.js";
|
|
6
6
|
import { DurableObject, env } from "cloudflare:workers";
|
|
7
7
|
import { Hono } from "hono";
|
|
8
8
|
|
|
@@ -2246,11 +2246,16 @@ function registerProcessRoutes(app, apiPrefix, sandboxBinding) {
|
|
|
2246
2246
|
if (!process) return errorJson("Process not found", "not_found", 404);
|
|
2247
2247
|
const replay = parseBoolean(c.req.query("replay"));
|
|
2248
2248
|
const follow = parseBoolean(c.req.query("follow"));
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2249
|
+
let logs;
|
|
2250
|
+
try {
|
|
2251
|
+
logs = await process.logs({
|
|
2252
|
+
since: c.req.query("since"),
|
|
2253
|
+
replay,
|
|
2254
|
+
follow
|
|
2255
|
+
});
|
|
2256
|
+
} finally {
|
|
2257
|
+
process[Symbol.dispose]();
|
|
2258
|
+
}
|
|
2254
2259
|
return new Response(processLogsToSSE(logs), { headers: {
|
|
2255
2260
|
"Content-Type": "text/event-stream",
|
|
2256
2261
|
"Cache-Control": "no-cache"
|
|
@@ -2486,11 +2491,15 @@ function registerTerminalRoutes(app, apiPrefix, sandboxBinding) {
|
|
|
2486
2491
|
try {
|
|
2487
2492
|
const terminal = await sandbox.getTerminal(terminalId);
|
|
2488
2493
|
if (!terminal) return errorJson("Terminal not found", "not_found", 404);
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
+
try {
|
|
2495
|
+
return await terminal.connect(c.req.raw, {
|
|
2496
|
+
cursor: c.req.query("cursor"),
|
|
2497
|
+
cols,
|
|
2498
|
+
rows
|
|
2499
|
+
});
|
|
2500
|
+
} finally {
|
|
2501
|
+
terminal[Symbol.dispose]();
|
|
2502
|
+
}
|
|
2494
2503
|
} catch (error) {
|
|
2495
2504
|
return terminalError(error);
|
|
2496
2505
|
}
|