@cloudflare/sandbox 0.13.0-next.797.1 → 0.13.0-next.808.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.
Files changed (43) hide show
  1. package/README.md +7 -0
  2. package/dist/bridge/index.js +23 -14
  3. package/dist/bridge/index.js.map +1 -1
  4. package/dist/{contexts-1EsLHByO.d.ts → contexts-DNFVmC9N.d.ts} +4 -1
  5. package/dist/contexts-DNFVmC9N.d.ts.map +1 -0
  6. package/dist/errors/index.d.ts +2 -2
  7. package/dist/errors/index.js +2 -2
  8. package/dist/{errors-QYlSkVGz.js → errors--yR3zLC_.js} +2 -2
  9. package/dist/{errors-QYlSkVGz.js.map → errors--yR3zLC_.js.map} +1 -1
  10. package/dist/{errors-CXR0xBpw.js → errors-Bb3s6nBS.js} +7 -1
  11. package/dist/errors-Bb3s6nBS.js.map +1 -0
  12. package/dist/extensions/index.d.ts +2 -2
  13. package/dist/extensions/index.js +3 -3
  14. package/dist/{extensions-Be5HnDGt.js → extensions-038QzSIg.js} +7 -3
  15. package/dist/extensions-038QzSIg.js.map +1 -0
  16. package/dist/{filesystem-Y5aF3nmJ.d.ts → filesystem-Cd6xd_Pe.d.ts} +5 -1
  17. package/dist/filesystem-Cd6xd_Pe.d.ts.map +1 -0
  18. package/dist/git/index.d.ts +2 -2
  19. package/dist/git/index.js +3 -3
  20. package/dist/{index-HNYBk-az.d.ts → index-CfpTXmNv.d.ts} +2 -2
  21. package/dist/{index-HNYBk-az.d.ts.map → index-CfpTXmNv.d.ts.map} +1 -1
  22. package/dist/{index-DfXx3uZL.d.ts → index-Fbdwkfft.d.ts} +9 -3
  23. package/dist/index-Fbdwkfft.d.ts.map +1 -0
  24. package/dist/index.d.ts +6 -5
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +4 -4
  27. package/dist/interpreter/index.d.ts +2 -2
  28. package/dist/interpreter/index.js +3 -3
  29. package/dist/openai/index.d.ts +2 -2
  30. package/dist/openai/index.js +1 -1
  31. package/dist/opencode/index.d.ts +3 -3
  32. package/dist/opencode/index.js +3 -3
  33. package/dist/{sandbox-BEhPgFZx.js → sandbox-CpelK4pU.js} +227 -68
  34. package/dist/sandbox-CpelK4pU.js.map +1 -0
  35. package/dist/{sandbox-CBkS3tGv.d.ts → sandbox-D1BoB5f7.d.ts} +2 -2
  36. package/dist/{sandbox-CBkS3tGv.d.ts.map → sandbox-D1BoB5f7.d.ts.map} +1 -1
  37. package/package.json +1 -1
  38. package/dist/contexts-1EsLHByO.d.ts.map +0 -1
  39. package/dist/errors-CXR0xBpw.js.map +0 -1
  40. package/dist/extensions-Be5HnDGt.js.map +0 -1
  41. package/dist/filesystem-Y5aF3nmJ.d.ts.map +0 -1
  42. package/dist/index-DfXx3uZL.d.ts.map +0 -1
  43. package/dist/sandbox-BEhPgFZx.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.
@@ -1,8 +1,8 @@
1
- import "../errors-CXR0xBpw.js";
2
- import "../errors-QYlSkVGz.js";
1
+ import "../errors-Bb3s6nBS.js";
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-BEhPgFZx.js";
5
- import "../extensions-Be5HnDGt.js";
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
- const logs = await process.logs({
2250
- since: c.req.query("since"),
2251
- replay,
2252
- follow
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
- return await terminal.connect(c.req.raw, {
2490
- cursor: c.req.query("cursor"),
2491
- cols,
2492
- rows
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
  }