void 0.21.8 → 0.22.0

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 (132) hide show
  1. package/dist/{account-cmd-CQ2wi4Th.mjs → account-cmd-CjyxcGkM.mjs} +4 -4
  2. package/dist/{auth-link-B_lceSHK.mjs → auth-link-BLO4ptzo.mjs} +4 -4
  3. package/dist/{auth-router-cZq0HuWe.mjs → auth-router-ZUg9MF_U.mjs} +5 -5
  4. package/dist/{build-cmd-Dpt0jd-x.mjs → build-cmd-BxR5FROK.mjs} +3 -3
  5. package/dist/{cache-7_UeZdTk.mjs → cache-D0sWhgKI.mjs} +3 -3
  6. package/dist/{cancel-deploy-D23R1RXT.mjs → cancel-deploy-D4NUqFbi.mjs} +3 -3
  7. package/dist/{cf-build-output-CGT03qCD.mjs → cf-build-output-BJ6yGEIS.mjs} +139 -62
  8. package/dist/cli/cf-compat.mjs +164 -42
  9. package/dist/cli/cli.mjs +73 -44
  10. package/dist/cli/env-schema-probe.d.mts +1 -1
  11. package/dist/{client-QTl6ko_D.mjs → client-BTZ3XkrB.mjs} +25 -0
  12. package/dist/client-Czz8o5jP.mjs +2 -0
  13. package/dist/{cloudflare-auth-C4_GPZr0.mjs → cloudflare-auth-DQkqoMYa.mjs} +1 -6
  14. package/dist/{cloudflare-cmd-bSmZ1d5L.mjs → cloudflare-cmd-BKlfGHAy.mjs} +6 -7
  15. package/dist/{cloudflare-connect-jAwacxxP.mjs → cloudflare-connect-Ctmrw579.mjs} +3 -3
  16. package/dist/{cloudflare-operations-sMZXpk_S.mjs → cloudflare-operations-B9tzgjmf.mjs} +10 -39
  17. package/dist/{cloudflare-operations-BipGMJ5O.mjs → cloudflare-operations-BT6OWFBk.mjs} +1 -1
  18. package/dist/{config-CafTW6Cz.mjs → config-Br_JZD6u.mjs} +2 -7
  19. package/dist/{config-s7Xj7tPb.mjs → config-CyQ-wVd7.mjs} +1 -1
  20. package/dist/{config-CF69HgXc.d.mts → config-VavjpDnp.d.mts} +1 -2
  21. package/dist/config-entry.d.mts +1 -1
  22. package/dist/{config-write-BSduPMY8.mjs → config-write-B1f88wJA.mjs} +1 -1
  23. package/dist/{connect-BY38i-9E.mjs → connect-Dg-WkW-C.mjs} +5 -5
  24. package/dist/{create-project-BniEV0OW.mjs → create-project-DdoqwFLF.mjs} +1 -1
  25. package/dist/{create-project-DBfFSZKY.mjs → create-project-l9J7pbtm.mjs} +8 -4
  26. package/dist/{db-BIo37Y7H.mjs → db-gp2sCXyN.mjs} +14 -14
  27. package/dist/{delete-D6dZ9B6B.mjs → delete-TTedbH6B.mjs} +3 -3
  28. package/dist/{deploy-BM_LoBXC.mjs → deploy-B19L2Bra.mjs} +1 -1
  29. package/dist/{deploy-C0JaQSWS.mjs → deploy-CH-o2CaZ.mjs} +47 -36
  30. package/dist/{dist-BR1quN_w.mjs → dist-AoCzRTJE.mjs} +226 -60
  31. package/dist/{dist-C5fND3R0.mjs → dist-BuDuKZJv.mjs} +1 -1
  32. package/dist/{dist-Dn6nn2IU.mjs → dist-CTBk70IR.mjs} +42 -42
  33. package/dist/{domain-Dmhvb2oU.mjs → domain-JRF59P_r.mjs} +4 -4
  34. package/dist/{email-dMnE_Lat.mjs → email-Bo6G9LOZ.mjs} +6 -6
  35. package/dist/{env-Csi-tMbT.mjs → env-BYOrWQnv.mjs} +4 -4
  36. package/dist/{env-public-D_6u46fX.d.mts → env-public-BxU_0yTL.d.mts} +2 -1
  37. package/dist/gen-CNJ62MM7.mjs +2 -0
  38. package/dist/{gen-Dz3X1Qab.mjs → gen-sCtlCOdA.mjs} +3 -3
  39. package/dist/{github-cmd-BED3_9JD.mjs → github-cmd-0-7PexDq.mjs} +5 -7
  40. package/dist/{handler-BXJTXd02.d.mts → handler-HEcZsaij.d.mts} +2 -1
  41. package/dist/{headers-BOg_velo.mjs → headers-DWi2IXWx.mjs} +1 -1
  42. package/dist/help-CmZzxUba.mjs +2 -0
  43. package/dist/{help-DC7gdz7L.mjs → help-GKtwl07I.mjs} +124 -4
  44. package/dist/index.d.mts +1 -1
  45. package/dist/index.mjs +53 -24
  46. package/dist/{init-CJSnEcuj.mjs → init-FZx3Elvz.mjs} +13 -13
  47. package/dist/{link-CsHOinF7.mjs → link-BrQfb_CU.mjs} +4 -4
  48. package/dist/{list-CDb-4bZ1.mjs → list-D44jmIAM.mjs} +4 -4
  49. package/dist/{live-CKiJilLr.d.mts → live-CKJlvlNp.d.mts} +1 -1
  50. package/dist/{local-d1-CC8sKFGu.mjs → local-d1-Bg9OzEEO.mjs} +1 -1
  51. package/dist/{login-DZldyb8c.mjs → login-CAsAsQ-_.mjs} +4 -4
  52. package/dist/login-CGcRKEoi.mjs +2 -0
  53. package/dist/{logs-BdfiOezj.mjs → logs-BjKvFnVM.mjs} +4 -4
  54. package/dist/{migrate-B8KuoYsO.mjs → migrate-BPITvDJN.mjs} +4 -4
  55. package/dist/migrate-CYfbKkXh.mjs +2 -0
  56. package/dist/{node-BM43oz4G.mjs → node-Dt7z256D.mjs} +1 -1
  57. package/dist/{operator-cmd-B9dbG3Od.mjs → operator-cmd-BK5CCiT9.mjs} +4 -4
  58. package/dist/output-Dm_A4Tbv.mjs +81 -0
  59. package/dist/pages/client.d.mts +1 -1
  60. package/dist/pages/index.d.mts +1 -1
  61. package/dist/pages/index.mjs +2 -2
  62. package/dist/pages/islands-plugin.d.mts +16 -6
  63. package/dist/pages/islands-plugin.mjs +1 -1
  64. package/dist/pages/protocol.d.mts +2 -2
  65. package/dist/{output-CCH48AMM.mjs → picocolors-BTps1_gs.mjs} +2 -76
  66. package/dist/{platform-auth-config-Bex45lQt.mjs → platform-auth-config-BlN8xTdD.mjs} +3 -3
  67. package/dist/{platform-auth-protection-Dma02l6-.mjs → platform-auth-protection-7d5aV2Jg.mjs} +3 -3
  68. package/dist/{platform-auth-recovery-COOhMCvx.mjs → platform-auth-recovery-Dxij8ZbR.mjs} +3 -3
  69. package/dist/{platform-cmd-BtxZrT6w.mjs → platform-cmd-B3hwKrFK.mjs} +5 -5
  70. package/dist/{platform-cmd-CjNB09OF.mjs → platform-cmd-E0FuL212.mjs} +1 -1
  71. package/dist/{platform-domain-DppaTARe.mjs → platform-domain-D6Xcy9ZX.mjs} +36 -9
  72. package/dist/{platform-lifecycle-CYll-oKE.mjs → platform-lifecycle-DMh_qrry.mjs} +1 -1
  73. package/dist/{platform-lifecycle-BpDlxT3t.mjs → platform-lifecycle-k0E0xoxx.mjs} +769 -59
  74. package/dist/{platform-management-BKYenDlE.mjs → platform-management-Brz_BDiT.mjs} +72 -10
  75. package/dist/{platform-management-BS5r6Ao8.mjs → platform-management-DOtss0BN.mjs} +1 -1
  76. package/dist/{platform-recovery-dJ5Me-I0.mjs → platform-recovery-BvtcXON5.mjs} +2 -2
  77. package/dist/prepare-Bm3iq-u4.mjs +2 -0
  78. package/dist/{prepare-DyZ-Yok5.mjs → prepare-C-6YZyyg.mjs} +3 -3
  79. package/dist/{prepare-C3kt3Rst.mjs → prepare-CRhJbVrG.mjs} +1 -1
  80. package/dist/{project-cmd-B44I8J_W.mjs → project-cmd-BZLCqOqw.mjs} +29 -15
  81. package/dist/{project-team-BkbYIsXN.mjs → project-team-BvgM0WoX.mjs} +3 -3
  82. package/dist/{project-token-C8xEEQnB.mjs → project-token-l5DqK6Az.mjs} +3 -3
  83. package/dist/project-zero-trust-v6Mvpp8y.mjs +63 -0
  84. package/dist/{protocol-ZH3jP4a7.d.mts → protocol-BBa6cstI.d.mts} +1 -1
  85. package/dist/{provision-BhreDAOS.mjs → provision-C4IGqkBf.mjs} +24 -19
  86. package/dist/{provision-DNtrtaVD.mjs → provision-Fr9pRqce.mjs} +1 -1
  87. package/dist/{requests-DFyhBMaf.mjs → requests-DN-BbNiM.mjs} +3 -3
  88. package/dist/{rollback-DHHxXZiS.mjs → rollback-D7rzSaZM.mjs} +4 -4
  89. package/dist/runtime/env-public.d.mts +1 -1
  90. package/dist/runtime/handler.d.mts +1 -1
  91. package/dist/runtime/live-client.d.mts +1 -1
  92. package/dist/runtime/live.d.mts +1 -1
  93. package/dist/runtime/sandbox-container.d.mts +3 -0
  94. package/dist/runtime/sandbox-container.mjs +2 -0
  95. package/dist/runtime/sandbox.d.mts +4 -32
  96. package/dist/runtime/sandbox.mjs +118 -72
  97. package/dist/runtime/validator.d.mts +1 -1
  98. package/dist/runtime/ws-server.d.mts +1 -1
  99. package/dist/runtime/ws.d.mts +1 -1
  100. package/dist/sandbox-container-4fdqLnyb.mjs +279 -0
  101. package/dist/sandbox-container-DdNEBfCc.d.mts +72 -0
  102. package/dist/sandbox-qpNBT8a3.d.mts +49 -0
  103. package/dist/{secret-DN9sSNiV.mjs → secret-BOtOl_cb.mjs} +4 -4
  104. package/dist/{skills-O6FUaizK.mjs → skills-D1II1Juz.mjs} +1 -1
  105. package/dist/{subcommand-prompt-BuGYkAkC.mjs → subcommand-prompt-CY1C4fvl.mjs} +2 -2
  106. package/dist/{wrangler-BymcxrRa.mjs → wrangler-DQF1vKyf.mjs} +37 -27
  107. package/dist/{ws-BwcqizuH.d.mts → ws-BoY7vQML.d.mts} +1 -1
  108. package/package.json +40 -32
  109. package/sandbox.Dockerfile +4 -0
  110. package/schema.json +10 -22
  111. package/skills/void/SKILL.md +2 -0
  112. package/skills/void/docs/guide/deployment.md +1 -1
  113. package/skills/void/docs/guide/edge/revalidation.md +1 -1
  114. package/skills/void/docs/guide/edge/static-assets.md +1 -0
  115. package/skills/void/docs/guide/platform/administration/zero-trust.md +318 -0
  116. package/skills/void/docs/guide/platform/development/local.md +2 -2
  117. package/skills/void/docs/guide/platform/installation/domains.md +1 -1
  118. package/skills/void/docs/guide/platform/installation/first-deployment.md +4 -0
  119. package/skills/void/docs/guide/platform/installation/prerequisites.md +1 -1
  120. package/skills/void/docs/guide/platform/installation/uninstall.md +17 -2
  121. package/skills/void/docs/guide/platform-administration.md +1 -0
  122. package/skills/void/docs/guide/sandboxes.md +70 -41
  123. package/skills/void/docs/integrations/cloudflare.md +1 -1
  124. package/skills/void/docs/reference/api.md +35 -35
  125. package/skills/void/docs/reference/cli.md +68 -6
  126. package/skills/void/docs/reference/config.md +16 -16
  127. package/dist/client-4cDVv7BO.mjs +0 -2
  128. package/dist/gen-Vnv2f65C.mjs +0 -2
  129. package/dist/help-DQMfeKMz.mjs +0 -2
  130. package/dist/login-t6rndSRW.mjs +0 -2
  131. package/dist/migrate-TsHGBnDA.mjs +0 -2
  132. package/dist/prepare-BZXkjdNe.mjs +0 -2
@@ -1,4 +1,4 @@
1
- import { t as LiveClientEvent } from "../live-CKiJilLr.mjs";
1
+ import { t as LiveClientEvent } from "../live-CKJlvlNp.mjs";
2
2
  //#region src/runtime/live-client.d.ts
3
3
  export type LiveSubscribeOptions<Data = unknown> = {
4
4
  id: string;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="@cloudflare/workers-types" />
2
- import { _ as __getLiveBindingName, a as LiveControlErrorCode, c as LiveControlOptions, d as LiveHookContext, f as LiveLimits, g as LiveSubscribeHookContext, h as LiveStreamOptions, i as LiveControlError, l as LiveControlRequest, m as LiveStream, n as LiveConnectHookContext, o as LiveControlOperation, p as LivePublishOptions, r as LiveConnectOptions, s as LiveControlOperationResult, t as LiveClientEvent, u as LiveControlResponse, v as __setLiveBindingName, y as defineLiveStream } from "../live-CKiJilLr.mjs";
2
+ import { _ as __getLiveBindingName, a as LiveControlErrorCode, c as LiveControlOptions, d as LiveHookContext, f as LiveLimits, g as LiveSubscribeHookContext, h as LiveStreamOptions, i as LiveControlError, l as LiveControlRequest, m as LiveStream, n as LiveConnectHookContext, o as LiveControlOperation, p as LivePublishOptions, r as LiveConnectOptions, s as LiveControlOperationResult, t as LiveClientEvent, u as LiveControlResponse, v as __setLiveBindingName, y as defineLiveStream } from "../live-CKJlvlNp.mjs";
3
3
  export { LiveClientEvent, LiveConnectHookContext, LiveConnectOptions, LiveControlError, LiveControlErrorCode, LiveControlOperation, LiveControlOperationResult, LiveControlOptions, LiveControlRequest, LiveControlResponse, LiveHookContext, LiveLimits, LivePublishOptions, LiveStream, LiveStreamOptions, LiveSubscribeHookContext, __getLiveBindingName, __setLiveBindingName, defineLiveStream };
@@ -0,0 +1,3 @@
1
+ /// <reference types="@cloudflare/workers-types" />
2
+ import { a as SandboxInstance, c as SandboxProcessWire, i as SandboxExecOptions, l as validateSandboxOptions, n as SandboxCapability, o as SandboxNativeContainer, r as SandboxContainer, s as SandboxOptions, t as DEFAULT_SANDBOX_INACTIVITY_TIMEOUT_MS } from "../sandbox-container-DdNEBfCc.mjs";
3
+ export { DEFAULT_SANDBOX_INACTIVITY_TIMEOUT_MS, SandboxCapability, SandboxContainer, SandboxExecOptions, SandboxInstance, SandboxNativeContainer, SandboxOptions, SandboxProcessWire, validateSandboxOptions };
@@ -0,0 +1,2 @@
1
+ import { n as SandboxContainer, r as validateSandboxOptions, t as DEFAULT_SANDBOX_INACTIVITY_TIMEOUT_MS } from "../sandbox-container-4fdqLnyb.mjs";
2
+ export { DEFAULT_SANDBOX_INACTIVITY_TIMEOUT_MS, SandboxContainer, validateSandboxOptions };
@@ -1,33 +1,5 @@
1
1
  /// <reference types="@cloudflare/workers-types" />
2
- import { Sandbox, SandboxOptions } from "@cloudflare/sandbox";
3
- //#region src/runtime/sandbox.d.ts
4
- export declare const DEFAULT_SANDBOX_ID = "default";
5
- export declare const DEFAULT_SANDBOX_BINDING = "SANDBOX";
6
- export declare const SANDBOX_SERVICE_BINDING = "__VOID_SANDBOX";
7
- export type VoidSandboxOptions = SandboxOptions & {
8
- binding?: string;
9
- };
10
- export declare class SandboxLimitError extends Error {
11
- override readonly name = "SandboxLimitError";
12
- readonly reason: "concurrency" | "runtime_budget";
13
- constructor(reason: "concurrency" | "runtime_budget", message?: string);
14
- }
15
- export declare class SandboxUnavailableError extends Error {
16
- override readonly name = "SandboxUnavailableError";
17
- constructor(message?: string);
18
- }
19
- export declare function __setSandboxBindingName(bindingName: string): void;
20
- /**
21
- * Retained for generated native/local Worker entries. Managed deployments host
22
- * the platform-owned Sandbox class in a separate Worker and never use this DO.
23
- */
24
- export declare class VoidPlatformSandbox<Env = unknown> extends Sandbox<Env> {
25
- override onStart(): Promise<void>;
26
- }
27
- /** Resolve an isolated Sandbox on the current deployment. Starts on first use. */
28
- export declare function getSandbox<T extends Sandbox = Sandbox>(id?: string, options?: VoidSandboxOptions): Promise<T>;
29
- export declare const sandbox: {
30
- get: typeof getSandbox;
31
- };
32
- //#endregion
33
- export { Sandbox, type SandboxOptions };
2
+ import { i as SandboxExecOptions, s as SandboxOptions } from "../sandbox-container-DdNEBfCc.mjs";
3
+ import { a as SandboxLimitError, c as VoidPlatformSandbox, d as getSandbox, f as sandbox, i as SandboxClient, l as VoidSandboxOptions, n as DEFAULT_SANDBOX_ID, o as SandboxProcess, r as SANDBOX_SERVICE_BINDING, s as SandboxUnavailableError, t as DEFAULT_SANDBOX_BINDING, u as __setSandboxBindingName } from "../sandbox-qpNBT8a3.mjs";
4
+ export * from "@cloudflare/sandbox";
5
+ export { DEFAULT_SANDBOX_BINDING, DEFAULT_SANDBOX_ID, SANDBOX_SERVICE_BINDING, SandboxClient, type SandboxExecOptions, SandboxLimitError, type SandboxOptions, SandboxProcess, SandboxUnavailableError, VoidPlatformSandbox, VoidSandboxOptions, __setSandboxBindingName, getSandbox, sandbox };
@@ -1,6 +1,7 @@
1
1
  import { a as getRawRuntimeEnv } from "../env-raw-Cx8ElDdj.mjs";
2
2
  import { a as requireRuntimeBinding } from "../env-D5liuQYR.mjs";
3
- import { Sandbox, getSandbox as getSandbox$1 } from "@cloudflare/sandbox";
3
+ import { n as SandboxContainer, r as validateSandboxOptions } from "../sandbox-container-4fdqLnyb.mjs";
4
+ export * from "@cloudflare/sandbox";
4
5
  //#region src/runtime/sandbox.ts
5
6
  const DEFAULT_SANDBOX_ID = "default";
6
7
  const DEFAULT_SANDBOX_BINDING = "SANDBOX";
@@ -29,96 +30,141 @@ function rethrowSandboxError(error) {
29
30
  if (message.includes("VOID_SANDBOX_unavailable")) throw new SandboxUnavailableError();
30
31
  throw error;
31
32
  }
32
- function managedClient(capability) {
33
- const call = async (target, operation, args) => {
33
+ function encodeOptions(value) {
34
+ if (!value || typeof value !== "object") return {
35
+ options: value,
36
+ finish() {}
37
+ };
38
+ const { signal, ...options } = value;
39
+ if (!signal) return {
40
+ options,
41
+ finish() {}
42
+ };
43
+ signal.throwIfAborted();
44
+ let closed = false;
45
+ let remove;
46
+ let finish;
47
+ const abort = new ReadableStream({
48
+ start(controller) {
49
+ const listener = () => finish();
50
+ remove = () => signal.removeEventListener("abort", listener);
51
+ finish = () => {
52
+ remove();
53
+ if (!closed) {
54
+ closed = true;
55
+ controller.close();
56
+ }
57
+ };
58
+ signal.addEventListener("abort", listener, { once: true });
59
+ },
60
+ cancel() {
61
+ closed = true;
62
+ remove();
63
+ }
64
+ });
65
+ return {
66
+ options: {
67
+ ...options,
68
+ abort
69
+ },
70
+ finish
71
+ };
72
+ }
73
+ function client(capability) {
74
+ const call = async (operation, args) => {
34
75
  try {
35
- return decodeManagedResult(await target.invoke(operation, prepareManagedArgs(operation, args)));
76
+ return await capability.invoke(operation, args);
36
77
  } catch (error) {
37
78
  rethrowSandboxError(error);
38
79
  }
39
80
  };
40
- return new Proxy(Object.create(null), { get(_target, property) {
41
- if (typeof property !== "string" || property === "then") return;
42
- if (property === "tunnels") return new Proxy(Object.create(null), { get(_tunnels, method) {
43
- if (typeof method !== "string" || method === "then") return;
44
- return (...args) => call(capability, "tunnels", [method, ...args]);
45
- } });
46
- return (...args) => call(capability, property, args);
47
- } });
48
- function decodeManagedResult(value) {
49
- if (Array.isArray(value)) return value.map(decodeManagedResult);
50
- if (!value || typeof value !== "object") return value;
51
- const record = value;
52
- if (record.__voidSandboxType === "process") {
53
- const { capability: processCapability, __voidSandboxType: _type, ...snapshot } = value;
54
- return Object.assign(snapshot, {
55
- kill: (...args) => call(processCapability, "kill", args),
56
- getStatus: (...args) => call(processCapability, "getStatus", args),
57
- getLogs: (...args) => call(processCapability, "getLogs", args),
58
- waitForLog: (...args) => call(processCapability, "waitForLog", args),
59
- waitForPort: (...args) => call(processCapability, "waitForPort", args),
60
- waitForExit: (...args) => call(processCapability, "waitForExit", args)
61
- });
81
+ const callWithOptions = async (operation, args, index) => {
82
+ const encoded = encodeOptions(args[index]);
83
+ args[index] = encoded.options;
84
+ try {
85
+ return await call(operation, args);
86
+ } catch (error) {
87
+ encoded.finish();
88
+ throw error;
62
89
  }
63
- if (record.__voidSandboxType === "session") {
64
- const session = value;
65
- return new Proxy({ id: session.id }, { get(target, property) {
66
- if (property === "id") return target.id;
67
- if (typeof property !== "string" || property === "then") return;
68
- return (...args) => call(session.capability, property, args);
69
- } });
90
+ };
91
+ return {
92
+ files: new Proxy(Object.create(null), { get(_target, method) {
93
+ if (typeof method !== "string" || method === "then") return;
94
+ return (...args) => {
95
+ const index = method === "writeFile" || method === "rename" ? 3 : 2;
96
+ return callWithOptions("files", [method, ...args], index);
97
+ };
98
+ } }),
99
+ async exec(argv, options) {
100
+ const wire = await callWithOptions("exec", [argv, options], 1);
101
+ let exitCode;
102
+ let output;
103
+ const process = {
104
+ pid: wire.pid,
105
+ isPty: wire.isPty,
106
+ stdin: wire.stdin,
107
+ stdout: wire.stdout,
108
+ stderr: wire.stderr,
109
+ get exitCode() {
110
+ return exitCode ??= wire.capability.invoke("exitCode", []);
111
+ },
112
+ output() {
113
+ return output ??= Promise.all([
114
+ wire.stdout ? new Response(wire.stdout).arrayBuffer() : /* @__PURE__ */ new ArrayBuffer(0),
115
+ wire.stderr ? new Response(wire.stderr).arrayBuffer() : /* @__PURE__ */ new ArrayBuffer(0),
116
+ process.exitCode
117
+ ]).then(([stdout, stderr, exitCode]) => ({
118
+ stdout,
119
+ stderr,
120
+ exitCode
121
+ }));
122
+ },
123
+ kill: async (signal) => {
124
+ await wire.capability.invoke("kill", [signal]);
125
+ },
126
+ resize: async (cols, rows) => {
127
+ await wire.capability.invoke("resize", [cols, rows]);
128
+ }
129
+ };
130
+ return process;
131
+ },
132
+ fetch: async (port, request) => await call("fetch", [port, request]),
133
+ running: async () => await call("running", []),
134
+ destroy: async () => {
135
+ await call("destroy", []);
70
136
  }
71
- return value;
72
- }
73
- function prepareManagedArgs(operation, args) {
74
- if (operation !== "startProcess") return args;
75
- const [command, options, ...rest] = args;
76
- if (!options || typeof options !== "object" || Array.isArray(options)) return args;
77
- const onStart = options.onStart;
78
- if (typeof onStart !== "function") return args;
79
- return [
80
- command,
81
- {
82
- ...options,
83
- onStart: (process) => onStart(decodeManagedResult(process))
84
- },
85
- ...rest
86
- ];
87
- }
137
+ };
88
138
  }
89
- /**
90
- * Retained for generated native/local Worker entries. Managed deployments host
91
- * the platform-owned Sandbox class in a separate Worker and never use this DO.
92
- */
93
- var VoidPlatformSandbox = class extends Sandbox {
94
- async onStart() {
139
+ /** Generated local/native DO. Managed execution uses the trusted controller. */
140
+ var VoidPlatformSandbox = class extends SandboxContainer {
141
+ async beforeStart() {
95
142
  const env = this.env;
96
143
  if (env.__PROJECT_ID !== void 0 || env.__VOID_PROXY !== void 0) throw new SandboxUnavailableError("Managed Sandboxes require the platform Sandbox controller. Redeploy this application.");
97
- await super.onStart();
98
144
  }
99
145
  };
100
- /** Resolve an isolated Sandbox on the current deployment. Starts on first use. */
101
- async function getSandbox(id = DEFAULT_SANDBOX_ID, options) {
102
- const { binding = sandboxBindingName, ...sandboxOptions } = options ?? {};
103
- const runtimeEnv = getRawRuntimeEnv();
104
- const service = runtimeEnv[SANDBOX_SERVICE_BINDING];
146
+ /** Resolve a container by name. Starts on the first command, file or port operation. */
147
+ async function getSandbox(id = DEFAULT_SANDBOX_ID, options = {}) {
148
+ const { binding = sandboxBindingName, normalizeId = true, ...sandboxOptions } = options;
149
+ if (typeof normalizeId !== "boolean") throw new TypeError("Sandbox normalizeId must be a boolean.");
150
+ validateSandboxOptions(sandboxOptions);
151
+ if (typeof id !== "string" || id.length === 0 || id.length > 63) throw new TypeError("Sandbox id must contain between 1 and 63 characters.");
152
+ if (normalizeId) id = id.toLowerCase();
153
+ const env = getRawRuntimeEnv();
154
+ const service = env[SANDBOX_SERVICE_BINDING];
105
155
  if (service) {
106
156
  if (binding !== sandboxBindingName) throw new SandboxUnavailableError(`Managed Sandbox binding ${binding} is unavailable.`);
107
157
  try {
108
- return managedClient(await service.getSandbox(id, {
109
- normalizeId: true,
110
- ...sandboxOptions
111
- }));
158
+ return client(await service.getSandbox(id, sandboxOptions));
112
159
  } catch (error) {
113
160
  rethrowSandboxError(error);
114
161
  }
115
162
  }
116
- if (runtimeEnv.__PROJECT_ID !== void 0 || runtimeEnv.__VOID_PROXY !== void 0) throw new SandboxUnavailableError("This deployment has no managed Sandbox controller. Redeploy this application.");
117
- return getSandbox$1(requireRuntimeBinding(binding), id, {
118
- normalizeId: true,
119
- ...sandboxOptions
120
- });
163
+ if (env.__PROJECT_ID !== void 0 || env.__VOID_PROXY !== void 0) throw new SandboxUnavailableError("This deployment has no managed Sandbox controller. Redeploy this application.");
164
+ const stub = requireRuntimeBinding(binding).getByName(id);
165
+ await stub.configure(sandboxOptions);
166
+ return client(stub);
121
167
  }
122
168
  const sandbox = { get: getSandbox };
123
169
  //#endregion
124
- export { DEFAULT_SANDBOX_BINDING, DEFAULT_SANDBOX_ID, SANDBOX_SERVICE_BINDING, Sandbox, SandboxLimitError, SandboxUnavailableError, VoidPlatformSandbox, __setSandboxBindingName, getSandbox, sandbox };
170
+ export { DEFAULT_SANDBOX_BINDING, DEFAULT_SANDBOX_ID, SANDBOX_SERVICE_BINDING, SandboxLimitError, SandboxUnavailableError, VoidPlatformSandbox, __setSandboxBindingName, getSandbox, sandbox };
@@ -1,2 +1,2 @@
1
- import { D as runValidation, E as ValidatorSlots, T as HandlerInput } from "../handler-BXJTXd02.mjs";
1
+ import { D as runValidation, E as ValidatorSlots, T as HandlerInput } from "../handler-HEcZsaij.mjs";
2
2
  export { HandlerInput, ValidatorSlots, runValidation };
@@ -1,6 +1,6 @@
1
1
  import { n as AuthState } from "../auth-DkcFflXV.mjs";
2
2
  import { i as VoidAuthRuntimeOptions, n as VoidAuthEnv } from "../better-auth-shared-BVkjZ3vM.mjs";
3
- import { t as AnyWebSocketDefinition } from "../ws-BwcqizuH.mjs";
3
+ import { t as AnyWebSocketDefinition } from "../ws-BoY7vQML.mjs";
4
4
  //#region src/runtime/ws-server.d.ts
5
5
  export type WebSocketRouteMeta = {
6
6
  pattern: string;
@@ -1,2 +1,2 @@
1
- import { a as RoomDefinition, c as VoidSocket, d as WebSocketConnection, f as connect, i as RoomController, l as VoidSocketCloseEvent, m as defineWebSocket, n as ConnectCommonOptions, o as SocketContext, p as defineRoom, r as RoomContext, s as SocketDefinition, t as AnyWebSocketDefinition, u as WebSocketBaseContext } from "../ws-BwcqizuH.mjs";
1
+ import { a as RoomDefinition, c as VoidSocket, d as WebSocketConnection, f as connect, i as RoomController, l as VoidSocketCloseEvent, m as defineWebSocket, n as ConnectCommonOptions, o as SocketContext, p as defineRoom, r as RoomContext, s as SocketDefinition, t as AnyWebSocketDefinition, u as WebSocketBaseContext } from "../ws-BoY7vQML.mjs";
2
2
  export { AnyWebSocketDefinition, ConnectCommonOptions, RoomContext, RoomController, RoomDefinition, SocketContext, SocketDefinition, VoidSocket, VoidSocketCloseEvent, WebSocketBaseContext, WebSocketConnection, connect, defineRoom, defineWebSocket };
@@ -0,0 +1,279 @@
1
+ import { DurableObject, RpcTarget } from "cloudflare:workers";
2
+ import { Files } from "@cloudflare/sandbox";
3
+ //#region src/runtime/sandbox-container.ts
4
+ const OPTIONS = /* @__PURE__ */ new Set([
5
+ "inactivityTimeoutMs",
6
+ "enableInternet",
7
+ "labels"
8
+ ]);
9
+ const FILE_OPERATIONS = /* @__PURE__ */ new Set([
10
+ "readFile",
11
+ "writeFile",
12
+ "stat",
13
+ "lstat",
14
+ "readDirectory",
15
+ "mkdir",
16
+ "rename",
17
+ "remove"
18
+ ]);
19
+ const DEFAULT_SANDBOX_INACTIVITY_TIMEOUT_MS = 6e5;
20
+ function validateSandboxOptions(options) {
21
+ if (!options || typeof options !== "object" || Array.isArray(options)) throw new TypeError("Sandbox options must be an object.");
22
+ for (const key of Object.keys(options)) if (!OPTIONS.has(key)) throw new TypeError(`Unsupported Sandbox option: ${key}`);
23
+ if (options.inactivityTimeoutMs !== void 0 && (!Number.isInteger(options.inactivityTimeoutMs) || options.inactivityTimeoutMs < 1 || options.inactivityTimeoutMs > 216e5)) throw new TypeError("Sandbox inactivityTimeoutMs must be an integer between 1 and 21600000.");
24
+ if (options.enableInternet !== void 0 && typeof options.enableInternet !== "boolean") throw new TypeError("Sandbox enableInternet must be a boolean.");
25
+ if (options.labels !== void 0 && (!options.labels || typeof options.labels !== "object" || Array.isArray(options.labels) || Object.values(options.labels).some((value) => typeof value !== "string"))) throw new TypeError("Sandbox labels must be strings.");
26
+ }
27
+ var ProcessCapability = class extends RpcTarget {
28
+ #process;
29
+ #exited = false;
30
+ #waitForExit;
31
+ constructor(process, waitForExit) {
32
+ super();
33
+ this.#process = process;
34
+ this.#waitForExit = waitForExit;
35
+ process.exitCode.then(() => {
36
+ this.#exited = true;
37
+ }, () => {
38
+ this.#exited = true;
39
+ });
40
+ }
41
+ async invoke(operation, args) {
42
+ if (!Array.isArray(args)) throw new TypeError("Sandbox arguments must be an array.");
43
+ if (operation === "exitCode") return this.#waitForExit();
44
+ if (operation === "kill") {
45
+ if (this.#exited) return;
46
+ return this.#process.kill(args[0]);
47
+ }
48
+ if (operation === "resize") return this.#process.resize(args[0], args[1]);
49
+ throw new TypeError(`Unsupported Sandbox process operation: ${operation}`);
50
+ }
51
+ };
52
+ /** Decode cancellation without trying to serialize an AbortSignal over Workers RPC. */
53
+ function operationOptions(value) {
54
+ const { abort, ...options } = value ?? {};
55
+ if (abort === void 0) return {
56
+ options,
57
+ finish() {}
58
+ };
59
+ if (!(abort instanceof ReadableStream)) throw new TypeError("Invalid Sandbox cancellation stream.");
60
+ const controller = new AbortController();
61
+ const reader = abort.getReader();
62
+ let finished = false;
63
+ reader.read().then(() => {
64
+ if (!finished) controller.abort();
65
+ }, () => {
66
+ if (!finished) controller.abort();
67
+ });
68
+ return {
69
+ options: {
70
+ ...options,
71
+ signal: controller.signal
72
+ },
73
+ finish() {
74
+ finished = true;
75
+ reader.cancel().catch(() => {});
76
+ }
77
+ };
78
+ }
79
+ /** Shared native execution, used by local Workers and the trusted platform controller. */
80
+ var SandboxContainer = class extends DurableObject {
81
+ instanceType = "lite";
82
+ #setup;
83
+ #options = {};
84
+ #ready;
85
+ starting = false;
86
+ #epoch = 0;
87
+ constructor(ctx, env) {
88
+ super(ctx, env);
89
+ this.#ready = ctx.blockConcurrencyWhile(async () => {
90
+ this.#options = await ctx.storage.get("__voidSandboxOptions") ?? {};
91
+ if (this.container.running) await this.container.setInactivityTimeout(this.inactivityTimeoutMs);
92
+ });
93
+ }
94
+ get container() {
95
+ if (!this.ctx.container) throw new Error("Sandbox container binding is missing.");
96
+ return this.ctx.container;
97
+ }
98
+ async configure(options) {
99
+ validateSandboxOptions(options);
100
+ await this.#ready;
101
+ this.#options = { ...options };
102
+ await this.ctx.storage.put("__voidSandboxOptions", this.#options);
103
+ if (this.container.running) await this.container.setInactivityTimeout(this.inactivityTimeoutMs);
104
+ }
105
+ get inactivityTimeoutMs() {
106
+ return this.#options.inactivityTimeoutMs ?? 6e5;
107
+ }
108
+ async beforeStart() {}
109
+ async afterStart() {}
110
+ async beforeUse() {}
111
+ async stopped() {}
112
+ async waitForProcessExit(exitCode) {
113
+ return exitCode;
114
+ }
115
+ /** Native abort listeners must be detached as soon as a process exits. */
116
+ async execProcess(argv, options = {}) {
117
+ const { signal, ...nativeOptions } = options;
118
+ if (!signal) return this.container.exec(argv, nativeOptions);
119
+ const controller = new AbortController();
120
+ const abort = () => controller.abort();
121
+ if (signal.aborted) abort();
122
+ else signal.addEventListener("abort", abort, { once: true });
123
+ const finish = () => signal.removeEventListener("abort", abort);
124
+ try {
125
+ const process = await this.container.exec(argv, {
126
+ ...nativeOptions,
127
+ signal: controller.signal
128
+ });
129
+ process.exitCode.then(finish, finish);
130
+ return process;
131
+ } catch (error) {
132
+ finish();
133
+ throw error;
134
+ }
135
+ }
136
+ async initializationOutput(argv, options, timeoutMs) {
137
+ const controller = new AbortController();
138
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
139
+ const finish = () => clearTimeout(timer);
140
+ try {
141
+ const process = await this.execProcess(argv, {
142
+ ...options,
143
+ signal: controller.signal
144
+ });
145
+ process.exitCode.then(finish, finish);
146
+ return await process.output();
147
+ } finally {
148
+ finish();
149
+ }
150
+ }
151
+ async initialize() {
152
+ if ((await this.initializationOutput([
153
+ "sh",
154
+ "-c",
155
+ "mkdir -p /workspace"
156
+ ], {}, 6e4)).exitCode !== 0) throw new Error("Sandbox workspace initialization failed.");
157
+ }
158
+ get entrypoint() {}
159
+ get image() {
160
+ return this.container.images.default;
161
+ }
162
+ async ensureRunning() {
163
+ if (!this.#setup || !this.container.running && !this.starting) {
164
+ this.starting = true;
165
+ this.#setup = this.setup(this.#epoch).catch((error) => {
166
+ this.#setup = void 0;
167
+ throw error;
168
+ }).finally(() => {
169
+ this.starting = false;
170
+ });
171
+ }
172
+ await this.#setup;
173
+ await this.beforeUse();
174
+ }
175
+ async setup(epoch) {
176
+ await this.#ready;
177
+ try {
178
+ await this.beforeStart();
179
+ if (epoch !== this.#epoch) throw new Error("Sandbox startup was cancelled.");
180
+ if (!this.container.running) this.container.start({
181
+ image: this.image,
182
+ instance: this.instanceType,
183
+ enableInternet: this.#options.enableInternet ?? false,
184
+ labels: this.#options.labels,
185
+ ...this.entrypoint ? { entrypoint: this.entrypoint } : {}
186
+ });
187
+ await this.initialize();
188
+ if (epoch !== this.#epoch) throw new Error("Sandbox startup was cancelled.");
189
+ await this.container.setInactivityTimeout(this.inactivityTimeoutMs);
190
+ await this.afterStart();
191
+ } catch (error) {
192
+ await this.destroy().catch(() => {});
193
+ throw error;
194
+ }
195
+ }
196
+ async destroy() {
197
+ this.#epoch++;
198
+ if (this.container.running) await this.container.destroy();
199
+ if (this.container.running) throw new Error("VOID_SANDBOX_unavailable");
200
+ if (!this.starting) this.#setup = void 0;
201
+ await this.stopped();
202
+ }
203
+ async invoke(operation, args) {
204
+ if (!Array.isArray(args)) throw new TypeError("Sandbox arguments must be an array.");
205
+ if (operation === "destroy") return this.destroy();
206
+ if (operation === "running") return this.container.running;
207
+ if (operation === "files") {
208
+ const [method, ...parameters] = args;
209
+ if (!FILE_OPERATIONS.has(method)) throw new TypeError(`Unsupported Sandbox file operation: ${String(method)}`);
210
+ await this.ensureRunning();
211
+ const index = method === "writeFile" || method === "rename" ? 2 : 1;
212
+ const { options, finish } = operationOptions(parameters[index]);
213
+ parameters[index] = options;
214
+ try {
215
+ const files = new Files({ exec: (argv, options) => this.execProcess(argv, options) });
216
+ const result = await files[method].apply(files, parameters);
217
+ if (result instanceof Response && result.body) {
218
+ const reader = result.body.getReader();
219
+ return new Response(new ReadableStream({
220
+ async pull(controller) {
221
+ try {
222
+ const chunk = await reader.read();
223
+ if (chunk.done) {
224
+ finish();
225
+ controller.close();
226
+ } else controller.enqueue(chunk.value);
227
+ } catch (error) {
228
+ finish();
229
+ controller.error(error);
230
+ }
231
+ },
232
+ async cancel(reason) {
233
+ finish();
234
+ await reader.cancel(reason);
235
+ }
236
+ }), result);
237
+ }
238
+ finish();
239
+ return result;
240
+ } catch (error) {
241
+ finish();
242
+ throw error;
243
+ }
244
+ }
245
+ if (operation === "exec") {
246
+ const [argv, value] = args;
247
+ if (!Array.isArray(argv) || argv.length === 0 || argv.some((arg) => typeof arg !== "string")) throw new TypeError("Sandbox exec requires an executable and arguments as an array of strings.");
248
+ const { options, finish } = operationOptions(value);
249
+ try {
250
+ await this.ensureRunning();
251
+ const process = await this.execProcess(argv, {
252
+ cwd: "/workspace",
253
+ ...options
254
+ });
255
+ process.exitCode.then(finish, finish);
256
+ return {
257
+ capability: new ProcessCapability(process, () => this.waitForProcessExit(process.exitCode)),
258
+ pid: process.pid,
259
+ isPty: process.isPty ?? false,
260
+ stdin: process.stdin ?? null,
261
+ stdout: process.stdout ?? null,
262
+ stderr: process.stderr ?? null
263
+ };
264
+ } catch (error) {
265
+ finish();
266
+ throw error;
267
+ }
268
+ }
269
+ if (operation === "fetch") {
270
+ const [port, request] = args;
271
+ if (!Number.isInteger(port) || port < 1 || port > 65535) throw new TypeError("Invalid Sandbox TCP port.");
272
+ await this.ensureRunning();
273
+ return this.container.getTcpPort(port).fetch(request);
274
+ }
275
+ throw new TypeError(`Unsupported Sandbox operation: ${operation}`);
276
+ }
277
+ };
278
+ //#endregion
279
+ export { SandboxContainer as n, validateSandboxOptions as r, DEFAULT_SANDBOX_INACTIVITY_TIMEOUT_MS as t };
@@ -0,0 +1,72 @@
1
+ import { DurableObject } from "cloudflare:workers";
2
+ //#region src/runtime/sandbox-container.d.ts
3
+ type SandboxInstance = "lite" | "standard-1" | "standard-2" | "standard-3" | "standard-4";
4
+ type SandboxOptions = {
5
+ inactivityTimeoutMs?: number;
6
+ enableInternet?: boolean;
7
+ labels?: Record<string, string>;
8
+ };
9
+ type SandboxExecOptions = ContainerExecOptions & {
10
+ signal?: AbortSignal;
11
+ pty?: boolean | {
12
+ cols?: number;
13
+ rows?: number;
14
+ };
15
+ };
16
+ type SandboxCapability = {
17
+ invoke(operation: string, args: Array<unknown>): Promise<unknown>;
18
+ };
19
+ type SandboxProcessWire = {
20
+ capability: SandboxCapability;
21
+ pid: number;
22
+ isPty: boolean;
23
+ stdin: WritableStream | null;
24
+ stdout: ReadableStream | null;
25
+ stderr: ReadableStream | null;
26
+ };
27
+ type SandboxNativeContainer = Omit<Container, "start" | "exec"> & {
28
+ readonly images: Record<string, string>;
29
+ start(options: {
30
+ image: string;
31
+ instance: SandboxInstance;
32
+ enableInternet: boolean;
33
+ labels?: Record<string, string>;
34
+ entrypoint?: Array<string>;
35
+ }): void;
36
+ exec(argv: Array<string>, options?: SandboxExecOptions): Promise<ExecProcess & {
37
+ isPty?: boolean;
38
+ resize(cols: number, rows: number): void;
39
+ }>;
40
+ };
41
+ declare const DEFAULT_SANDBOX_INACTIVITY_TIMEOUT_MS: number;
42
+ declare function validateSandboxOptions(options: SandboxOptions): void;
43
+ /** Shared native execution, used by local Workers and the trusted platform controller. */
44
+ declare class SandboxContainer<Env = unknown> extends DurableObject<Env> {
45
+ #private;
46
+ protected instanceType: SandboxInstance;
47
+ protected starting: boolean;
48
+ constructor(ctx: DurableObjectState, env: Env);
49
+ protected get container(): SandboxNativeContainer;
50
+ configure(options: SandboxOptions): Promise<void>;
51
+ protected get inactivityTimeoutMs(): number;
52
+ protected beforeStart(): Promise<void>;
53
+ protected afterStart(): Promise<void>;
54
+ protected beforeUse(): Promise<void>;
55
+ protected stopped(): Promise<void>;
56
+ protected waitForProcessExit(exitCode: Promise<number>): Promise<number>;
57
+ /** Native abort listeners must be detached as soon as a process exits. */
58
+ protected execProcess(argv: Array<string>, options?: SandboxExecOptions): Promise<ExecProcess & {
59
+ isPty?: boolean;
60
+ resize(cols: number, rows: number): void;
61
+ }>;
62
+ protected initializationOutput(argv: Array<string>, options: SandboxExecOptions, timeoutMs: number): Promise<ExecOutput>;
63
+ protected initialize(): Promise<void>;
64
+ protected get entrypoint(): Array<string> | undefined;
65
+ protected get image(): string;
66
+ protected ensureRunning(): Promise<void>;
67
+ private setup;
68
+ destroy(): Promise<void>;
69
+ invoke(operation: string, args: Array<unknown>): Promise<unknown>;
70
+ }
71
+ //#endregion
72
+ export { SandboxInstance as a, SandboxProcessWire as c, SandboxExecOptions as i, validateSandboxOptions as l, SandboxCapability as n, SandboxNativeContainer as o, SandboxContainer as r, SandboxOptions as s, DEFAULT_SANDBOX_INACTIVITY_TIMEOUT_MS as t };