@madarco/agentbox 0.27.1 → 0.27.2

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 (146) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/{_cloud-attach-WDGM6FL5.js → _cloud-attach-FVD5YJCE.js} +6 -4
  3. package/dist/{chunk-NEF6MDJO.js → chunk-2PCU4OF5.js} +4 -4
  4. package/dist/{chunk-JE6UI5YR.js → chunk-47BVC7FN.js} +7 -59
  5. package/dist/chunk-47BVC7FN.js.map +1 -0
  6. package/dist/chunk-5ZK5MQA2.js +64 -0
  7. package/dist/chunk-5ZK5MQA2.js.map +1 -0
  8. package/dist/{chunk-26IKZRTT.js → chunk-A4OVGMVL.js} +23 -16
  9. package/dist/chunk-A4OVGMVL.js.map +1 -0
  10. package/dist/{chunk-KWOEUFVA.js → chunk-EZWPCTUO.js} +2 -2
  11. package/dist/{chunk-IDH5A4RR.js → chunk-F6NQZ4DC.js} +2 -2
  12. package/dist/chunk-IMN62QY5.js +285 -0
  13. package/dist/chunk-IMN62QY5.js.map +1 -0
  14. package/dist/{chunk-V5XXJH63.js → chunk-JNFUWQ4N.js} +2 -2
  15. package/dist/{chunk-UJEH2NJT.js → chunk-JRXNVEV3.js} +2 -271
  16. package/dist/chunk-JRXNVEV3.js.map +1 -0
  17. package/dist/{chunk-LL7NCMUU.js → chunk-QAJQXZ3N.js} +3 -3
  18. package/dist/{chunk-SJ75AIA2.js → chunk-QJT2XOKH.js} +8 -6
  19. package/dist/{chunk-SJ75AIA2.js.map → chunk-QJT2XOKH.js.map} +1 -1
  20. package/dist/{chunk-HR7NHH5J.js → chunk-RK2CEABS.js} +205 -5
  21. package/dist/{chunk-HR7NHH5J.js.map → chunk-RK2CEABS.js.map} +1 -1
  22. package/dist/cloud-backends.js +28 -0
  23. package/dist/cloud-backends.js.map +1 -0
  24. package/dist/{dist-O3LKOIE7.js → dist-2SXD3ITR.js} +6 -5
  25. package/dist/{dist-O3LKOIE7.js.map → dist-2SXD3ITR.js.map} +1 -1
  26. package/dist/{dist-FTKS2GI4.js → dist-4KTWNGU6.js} +6 -5
  27. package/dist/{dist-WVYAURMF.js → dist-6ZOCQZIP.js} +6 -5
  28. package/dist/{dist-OO52HARR.js → dist-7VCYREHM.js} +22 -20
  29. package/dist/{dist-KQTMCVME.js → dist-TL4YW7KZ.js} +6 -5
  30. package/dist/{dist-KQTMCVME.js.map → dist-TL4YW7KZ.js.map} +1 -1
  31. package/dist/{dist-TSFVB7AI.js → dist-UUOX4DBX.js} +6 -5
  32. package/dist/{dist-TSFVB7AI.js.map → dist-UUOX4DBX.js.map} +1 -1
  33. package/dist/dist-XSEK7LX3.js +156 -0
  34. package/dist/{dist-Z6L5MM5D.js → dist-YGXQMN2K.js} +6 -5
  35. package/dist/index.js +58 -54
  36. package/dist/index.js.map +1 -1
  37. package/dist/{prepared-state-75DIZ55S-TNJXWMXV.js → prepared-state-75DIZ55S-B33TDOJZ.js} +3 -2
  38. package/dist/prepared-state-75DIZ55S-B33TDOJZ.js.map +1 -0
  39. package/package.json +1 -1
  40. package/runtime/_shared/ctl.cjs +186 -172
  41. package/runtime/digitalocean/ctl.cjs +186 -172
  42. package/runtime/docker/packages/ctl/dist/bin.cjs +186 -172
  43. package/runtime/e2b/ctl.cjs +186 -172
  44. package/runtime/hetzner/ctl.cjs +186 -172
  45. package/runtime/hub/apps/hub/.next/BUILD_ID +1 -1
  46. package/runtime/hub/apps/hub/.next/build-manifest.json +3 -3
  47. package/runtime/hub/apps/hub/.next/prerender-manifest.json +3 -3
  48. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page/server-reference-manifest.json +1 -1
  49. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/approvals/page_client-reference-manifest.js +1 -1
  50. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page/server-reference-manifest.json +12 -12
  51. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/boxes/[id]/page_client-reference-manifest.js +1 -1
  52. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page/server-reference-manifest.json +11 -11
  53. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
  54. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page/server-reference-manifest.json +8 -8
  55. package/runtime/hub/apps/hub/.next/server/app/(dashboard)/projects/[id]/page_client-reference-manifest.js +1 -1
  56. package/runtime/hub/apps/hub/.next/server/app/[...path]/route.js +1 -1
  57. package/runtime/hub/apps/hub/.next/server/app/[...path]/route.js.nft.json +1 -1
  58. package/runtime/hub/apps/hub/.next/server/app/_global-error.html +1 -1
  59. package/runtime/hub/apps/hub/.next/server/app/_global-error.rsc +1 -1
  60. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  61. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  62. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  63. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  64. package/runtime/hub/apps/hub/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  65. package/runtime/hub/apps/hub/.next/server/chunks/151__@better-auth_core_dist_0ecdp_3._.js +1 -1
  66. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__04h15ml._.js +1 -1
  67. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__04jgk9x._.js +1 -1
  68. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__07ednlo._.js +1 -1
  69. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0a7djvw._.js +1 -1
  70. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0ig1bot._.js +1 -1
  71. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0szd4sh._.js +1 -1
  72. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__0t7o5ed._.js +1 -1
  73. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-0flwc._.js +1 -1
  74. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1-9g0ae._.js +1 -1
  75. package/runtime/hub/apps/hub/.next/server/chunks/{[root-of-the-server]__1e4z_-v._.js → [root-of-the-server]__11izd5j._.js} +2 -2
  76. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__13ioh5z._.js +1 -1
  77. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__13jwk_k._.js +1 -1
  78. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__16_uteg._.js +1 -1
  79. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__16p2m-g._.js +1 -1
  80. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1_gu2yk._.js +1 -1
  81. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1ai-945._.js +1 -1
  82. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1bu2zio._.js +1 -1
  83. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1ctczev._.js +1 -1
  84. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1f2sueq._.js +1 -1
  85. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1f9zctr._.js +1 -1
  86. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1md9kdw._.js +1 -1
  87. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1mttufy._.js +1 -1
  88. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1pp5oib._.js +1 -1
  89. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1qwhzmi._.js +1 -1
  90. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1thipug._.js +1 -1
  91. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__1xeczo7._.js +1 -1
  92. package/runtime/hub/apps/hub/.next/server/chunks/[root-of-the-server]__20503l7._.js +1 -1
  93. package/runtime/hub/apps/hub/.next/server/chunks/_0760z6y._.js +2 -2
  94. package/runtime/hub/apps/hub/.next/server/chunks/packages_relay_dist_control-plane_03a-9aj.js +3 -3
  95. package/runtime/hub/apps/hub/.next/server/chunks/ssr/044u_hub__next-internal_server_app_(dashboard)_projects_[id]_page_actions_15f56np.js +1 -1
  96. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_03s-ah2._.js +1 -1
  97. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0kpdmm-._.js +1 -1
  98. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0ozyjt1._.js +1 -1
  99. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_0r4px38._.js +1 -1
  100. package/runtime/hub/apps/hub/.next/server/chunks/ssr/_18w2zeh._.js +1 -1
  101. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(dashboard)_approvals_page_actions_1mi0bpn.js +1 -1
  102. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(dashboard)_boxes_[id]_page_actions_0k7kgn2.js +1 -1
  103. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub__next-internal_server_app_(dashboard)_page_actions_1t3u0xy.js +1 -1
  104. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_app_(dashboard)_boxes_[id]_page_tsx_1-j_972._.js +1 -1
  105. package/runtime/hub/apps/hub/.next/server/chunks/ssr/apps_hub_app_(dashboard)_boxes_components_box-table_tsx_0a9pyn_._.js +1 -1
  106. package/runtime/hub/apps/hub/.next/server/chunks/ssr/packages_relay_dist_control-plane_0ve-wz4.js +1 -1
  107. package/runtime/hub/apps/hub/.next/server/middleware-build-manifest.js +3 -3
  108. package/runtime/hub/apps/hub/.next/server/pages/500.html +1 -1
  109. package/runtime/hub/apps/hub/.next/server/server-reference-manifest.js +1 -1
  110. package/runtime/hub/apps/hub/.next/server/server-reference-manifest.json +18 -18
  111. package/runtime/hub/apps/hub/.next/static/chunks/{30de2x24ntwkg.js → 1-maeq_pl3z29.js} +1 -1
  112. package/runtime/hub/apps/hub/.next/static/chunks/{2gfw8-qyx5xi_.js → 1f-pwhlfklk8h.js} +1 -1
  113. package/runtime/hub/apps/hub/.next/static/chunks/{3tqnniym2yvpb.js → 1g922r_mc5ciw.js} +1 -1
  114. package/runtime/hub/apps/hub/.next/static/chunks/{070w7h5rh5ja6.js → 2k1tvmngrtdgs.js} +1 -1
  115. package/runtime/hub/apps/hub/.next/static/chunks/{3e5n630psqst8.js → 2omimeqtc8qnp.js} +1 -1
  116. package/runtime/hub/apps/hub/.next/static/chunks/{2awpm9w8crker.js → 3urpddxa8b_je.js} +1 -1
  117. package/runtime/hub/apps/hub/{chunk-YJ5MJOXK.js → chunk-5ARPIPV4.js} +194 -171
  118. package/runtime/hub/apps/hub/{chunk-EHBJKZCL.js → chunk-AEIOQFZ4.js} +245 -2
  119. package/runtime/hub/apps/hub/dist-2EOAT3PC.js +155 -0
  120. package/runtime/hub/apps/hub/{dist-LYDHYTP2.js → dist-DQIL673Y.js} +2 -2
  121. package/runtime/hub/apps/hub/{dist-GTVVXCBP.js → dist-EURE7AUA.js} +2 -2
  122. package/runtime/hub/apps/hub/{dist-JG45OFT2.js → dist-EYHD64SR.js} +16 -16
  123. package/runtime/hub/apps/hub/{dist-G6TXUSPZ.js → dist-GFXXCXLS.js} +2 -2
  124. package/runtime/hub/apps/hub/{dist-DX6IYMAH.js → dist-IVA2PC7N.js} +2 -2
  125. package/runtime/hub/apps/hub/{dist-6FPPUSWZ.js → dist-MMTT7VYJ.js} +1 -1
  126. package/runtime/hub/apps/hub/{dist-3I7KUI6W.js → dist-TAWVTJGU.js} +2 -2
  127. package/runtime/hub/apps/hub/server.js +28 -15
  128. package/runtime/relay/bin.cjs +37 -3
  129. package/runtime/vercel/ctl.cjs +186 -172
  130. package/dist/chunk-26IKZRTT.js.map +0 -1
  131. package/dist/chunk-JE6UI5YR.js.map +0 -1
  132. package/dist/chunk-UJEH2NJT.js.map +0 -1
  133. /package/dist/{_cloud-attach-WDGM6FL5.js.map → _cloud-attach-FVD5YJCE.js.map} +0 -0
  134. /package/dist/{chunk-NEF6MDJO.js.map → chunk-2PCU4OF5.js.map} +0 -0
  135. /package/dist/{chunk-KWOEUFVA.js.map → chunk-EZWPCTUO.js.map} +0 -0
  136. /package/dist/{chunk-IDH5A4RR.js.map → chunk-F6NQZ4DC.js.map} +0 -0
  137. /package/dist/{chunk-V5XXJH63.js.map → chunk-JNFUWQ4N.js.map} +0 -0
  138. /package/dist/{chunk-LL7NCMUU.js.map → chunk-QAJQXZ3N.js.map} +0 -0
  139. /package/dist/{dist-FTKS2GI4.js.map → dist-4KTWNGU6.js.map} +0 -0
  140. /package/dist/{dist-OO52HARR.js.map → dist-6ZOCQZIP.js.map} +0 -0
  141. /package/dist/{dist-WVYAURMF.js.map → dist-7VCYREHM.js.map} +0 -0
  142. /package/dist/{dist-Z6L5MM5D.js.map → dist-XSEK7LX3.js.map} +0 -0
  143. /package/dist/{prepared-state-75DIZ55S-TNJXWMXV.js.map → dist-YGXQMN2K.js.map} +0 -0
  144. /package/runtime/hub/apps/hub/.next/static/{PWF2iHQOg9-rRyfqVDLrh → Wddru2A-5szSWhZWYoMwi}/_buildManifest.js +0 -0
  145. /package/runtime/hub/apps/hub/.next/static/{PWF2iHQOg9-rRyfqVDLrh → Wddru2A-5szSWhZWYoMwi}/_clientMiddlewareManifest.js +0 -0
  146. /package/runtime/hub/apps/hub/.next/static/{PWF2iHQOg9-rRyfqVDLrh → Wddru2A-5szSWhZWYoMwi}/_ssgManifest.js +0 -0
@@ -6,7 +6,8 @@ import {
6
6
  readPreparedDockerState,
7
7
  resolveContextFiles,
8
8
  writePreparedDockerState
9
- } from "./chunk-UJEH2NJT.js";
9
+ } from "./chunk-IMN62QY5.js";
10
+ import "./chunk-JRXNVEV3.js";
10
11
  import "./chunk-WJFZJZIM.js";
11
12
  export {
12
13
  DOCKERFILE_PATH,
@@ -16,4 +17,4 @@ export {
16
17
  resolveContextFiles,
17
18
  writePreparedDockerState
18
19
  };
19
- //# sourceMappingURL=prepared-state-75DIZ55S-TNJXWMXV.js.map
20
+ //# sourceMappingURL=prepared-state-75DIZ55S-B33TDOJZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@madarco/agentbox",
3
- "version": "0.27.1",
3
+ "version": "0.27.2",
4
4
  "description": "Launch Claude Code, Codex, and other coding agents in isolated sandboxes",
5
5
  "license": "MIT",
6
6
  "author": "Marco D'Alia",
@@ -12000,15 +12000,178 @@ var opencodeStateCommand = new Command("opencode-state").description("Report Ope
12000
12000
  process.exit(0);
12001
12001
  });
12002
12002
 
12003
- // ../relay/dist/chunk-KNZCE7J6.js
12003
+ // ../relay/dist/chunk-WDEY7V3V.js
12004
+ var import_crypto = require("crypto");
12004
12005
  var import_promises2 = require("fs/promises");
12005
12006
  var import_os = require("os");
12006
12007
  var import_path = require("path");
12007
- var import_crypto = require("crypto");
12008
12008
  var import_crypto2 = require("crypto");
12009
12009
  var import_crypto3 = require("crypto");
12010
12010
  var DEFAULT_BOX_RELAY_PORT = 8788;
12011
12011
  var RELAY_EVENT_RING_SIZE = 1e3;
12012
+ var PendingPrompts = class {
12013
+ entries = /* @__PURE__ */ new Map();
12014
+ autoApprove = null;
12015
+ onChange = null;
12016
+ /** Install the per-box auto-approve policy (relay server, once at startup). */
12017
+ setAutoApprovePolicy(policy) {
12018
+ this.autoApprove = policy;
12019
+ }
12020
+ /**
12021
+ * Install a change hook fired whenever the pending set is mutated (add /
12022
+ * resolve). Wired by the relay server to the hub notifier so the embedded UI
12023
+ * pushes an update to connected browsers.
12024
+ */
12025
+ setOnChange(fn) {
12026
+ this.onChange = fn;
12027
+ }
12028
+ /**
12029
+ * True when this box opted into `box.autoApproveHostActions`. Records the
12030
+ * bypass to the audit sink as a side effect so the caller short-circuits
12031
+ * with a trail. Returns false when no policy is installed.
12032
+ */
12033
+ consumeAutoApprove(boxId, params) {
12034
+ if (!this.autoApprove || !this.autoApprove.shouldAutoApprove(boxId)) return false;
12035
+ this.autoApprove.audit(boxId, params);
12036
+ return true;
12037
+ }
12038
+ /**
12039
+ * Record a *safe-subset* auto-approval (opening a PR, a contained file copy,
12040
+ * a sanctioned-branch push, …) to the audit sink WITHOUT the blanket
12041
+ * `autoApproveHostActions` opt-in. The handler already decided the action is
12042
+ * safe under `box.autoApproveSafeHostActions`; this just leaves the same
12043
+ * `host-action-auto-approved` trail a full opt-in would, tagged with `reason`.
12044
+ * No-op when no policy is installed (e.g. the stateless poll plane).
12045
+ */
12046
+ noteAutoApprove(boxId, params, reason) {
12047
+ this.autoApprove?.audit(boxId, params, reason);
12048
+ }
12049
+ add(boxId, ev) {
12050
+ return new Promise((resolve4) => {
12051
+ this.entries.set(ev.id, {
12052
+ ev,
12053
+ boxId,
12054
+ resolve: resolve4,
12055
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
12056
+ });
12057
+ this.onChange?.();
12058
+ });
12059
+ }
12060
+ /**
12061
+ * Idempotent: returns true if a pending entry was found + resolved, false
12062
+ * otherwise. The /admin/prompts/answer handler uses the bool to decide
12063
+ * 204 vs 404 — the wrapper treats both as "we're done."
12064
+ */
12065
+ resolve(id, answer, cancelled) {
12066
+ const entry = this.entries.get(id);
12067
+ if (!entry) return false;
12068
+ this.entries.delete(id);
12069
+ entry.resolve({ answer, cancelled });
12070
+ this.onChange?.();
12071
+ return true;
12072
+ }
12073
+ /**
12074
+ * Snapshot of all pending prompts for a given box; used to flush the
12075
+ * backlog to a newly-attached SSE subscriber.
12076
+ */
12077
+ forBox(boxId) {
12078
+ const out = [];
12079
+ for (const entry of this.entries.values()) {
12080
+ if (entry.boxId === boxId) out.push(entry.ev);
12081
+ }
12082
+ return out;
12083
+ }
12084
+ /**
12085
+ * Snapshot of every pending prompt across all boxes, with its boxId and
12086
+ * enqueue time — the hub's Approvals view lists these.
12087
+ */
12088
+ all() {
12089
+ const out = [];
12090
+ for (const entry of this.entries.values()) {
12091
+ out.push({ id: entry.ev.id, boxId: entry.boxId, ev: entry.ev, createdAt: entry.createdAt });
12092
+ }
12093
+ return out;
12094
+ }
12095
+ /** boxId that owns a pending prompt id, or null when unknown. */
12096
+ boxFor(id) {
12097
+ const entry = this.entries.get(id);
12098
+ return entry ? entry.boxId : null;
12099
+ }
12100
+ size() {
12101
+ return this.entries.size;
12102
+ }
12103
+ };
12104
+ var PromptSubscribers = class {
12105
+ byBox = /* @__PURE__ */ new Map();
12106
+ add(boxId, res) {
12107
+ let set = this.byBox.get(boxId);
12108
+ if (!set) {
12109
+ set = /* @__PURE__ */ new Set();
12110
+ this.byBox.set(boxId, set);
12111
+ }
12112
+ set.add(res);
12113
+ }
12114
+ remove(boxId, res) {
12115
+ const set = this.byBox.get(boxId);
12116
+ if (!set) return;
12117
+ set.delete(res);
12118
+ if (set.size === 0) this.byBox.delete(boxId);
12119
+ }
12120
+ forBox(boxId) {
12121
+ const set = this.byBox.get(boxId);
12122
+ return set ? Array.from(set) : [];
12123
+ }
12124
+ /**
12125
+ * Fire-and-forget broadcast. SSE writes that fail (closed socket) are
12126
+ * swallowed — the `res.on('close')` handler in the server route already
12127
+ * deregisters the dead subscriber.
12128
+ */
12129
+ broadcast(boxId, event, data) {
12130
+ const set = this.byBox.get(boxId);
12131
+ if (!set) return;
12132
+ const payload = `event: ${event}
12133
+ data: ${JSON.stringify(data)}
12134
+
12135
+ `;
12136
+ for (const res of set) {
12137
+ try {
12138
+ res.write(payload);
12139
+ } catch {
12140
+ }
12141
+ }
12142
+ }
12143
+ };
12144
+ async function askPrompt(prompts, subscribers, boxId, params, opts) {
12145
+ if (process.env.AGENTBOX_PROMPT === "off") {
12146
+ return { answer: "y" };
12147
+ }
12148
+ if (prompts.consumeAutoApprove(boxId, params)) {
12149
+ return { answer: "y" };
12150
+ }
12151
+ const ev = { id: (0, import_crypto.randomUUID)(), ...params };
12152
+ const promise = prompts.add(boxId, ev);
12153
+ subscribers.broadcast(boxId, "prompt-ask", ev);
12154
+ if (opts?.ttlMs !== void 0 && opts.ttlMs > 0) {
12155
+ const timer = setTimeout(() => {
12156
+ if (prompts.resolve(ev.id, params.defaultAnswer ?? "n", true)) {
12157
+ subscribers.broadcast(boxId, "prompt-resolved", { id: ev.id });
12158
+ }
12159
+ }, opts.ttlMs);
12160
+ if (typeof timer.unref === "function") timer.unref();
12161
+ void promise.then(() => {
12162
+ clearTimeout(timer);
12163
+ });
12164
+ }
12165
+ return promise;
12166
+ }
12167
+ function isPromptAnswerBody(v) {
12168
+ if (!v || typeof v !== "object") return false;
12169
+ const o2 = v;
12170
+ if (typeof o2.id !== "string" || o2.id.length === 0) return false;
12171
+ if (o2.answer !== "y" && o2.answer !== "n") return false;
12172
+ if (o2.cancelled !== void 0 && typeof o2.cancelled !== "boolean") return false;
12173
+ return true;
12174
+ }
12012
12175
  var BoxRegistry = class {
12013
12176
  map = /* @__PURE__ */ new Map();
12014
12177
  register(reg) {
@@ -12219,169 +12382,6 @@ var MemoryStore = class {
12219
12382
  return Promise.resolve();
12220
12383
  }
12221
12384
  };
12222
- var PendingPrompts = class {
12223
- entries = /* @__PURE__ */ new Map();
12224
- autoApprove = null;
12225
- onChange = null;
12226
- /** Install the per-box auto-approve policy (relay server, once at startup). */
12227
- setAutoApprovePolicy(policy) {
12228
- this.autoApprove = policy;
12229
- }
12230
- /**
12231
- * Install a change hook fired whenever the pending set is mutated (add /
12232
- * resolve). Wired by the relay server to the hub notifier so the embedded UI
12233
- * pushes an update to connected browsers.
12234
- */
12235
- setOnChange(fn) {
12236
- this.onChange = fn;
12237
- }
12238
- /**
12239
- * True when this box opted into `box.autoApproveHostActions`. Records the
12240
- * bypass to the audit sink as a side effect so the caller short-circuits
12241
- * with a trail. Returns false when no policy is installed.
12242
- */
12243
- consumeAutoApprove(boxId, params) {
12244
- if (!this.autoApprove || !this.autoApprove.shouldAutoApprove(boxId)) return false;
12245
- this.autoApprove.audit(boxId, params);
12246
- return true;
12247
- }
12248
- /**
12249
- * Record a *safe-subset* auto-approval (opening a PR, a contained file copy,
12250
- * a sanctioned-branch push, …) to the audit sink WITHOUT the blanket
12251
- * `autoApproveHostActions` opt-in. The handler already decided the action is
12252
- * safe under `box.autoApproveSafeHostActions`; this just leaves the same
12253
- * `host-action-auto-approved` trail a full opt-in would, tagged with `reason`.
12254
- * No-op when no policy is installed (e.g. the stateless poll plane).
12255
- */
12256
- noteAutoApprove(boxId, params, reason) {
12257
- this.autoApprove?.audit(boxId, params, reason);
12258
- }
12259
- add(boxId, ev) {
12260
- return new Promise((resolve4) => {
12261
- this.entries.set(ev.id, {
12262
- ev,
12263
- boxId,
12264
- resolve: resolve4,
12265
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
12266
- });
12267
- this.onChange?.();
12268
- });
12269
- }
12270
- /**
12271
- * Idempotent: returns true if a pending entry was found + resolved, false
12272
- * otherwise. The /admin/prompts/answer handler uses the bool to decide
12273
- * 204 vs 404 — the wrapper treats both as "we're done."
12274
- */
12275
- resolve(id, answer, cancelled) {
12276
- const entry = this.entries.get(id);
12277
- if (!entry) return false;
12278
- this.entries.delete(id);
12279
- entry.resolve({ answer, cancelled });
12280
- this.onChange?.();
12281
- return true;
12282
- }
12283
- /**
12284
- * Snapshot of all pending prompts for a given box; used to flush the
12285
- * backlog to a newly-attached SSE subscriber.
12286
- */
12287
- forBox(boxId) {
12288
- const out = [];
12289
- for (const entry of this.entries.values()) {
12290
- if (entry.boxId === boxId) out.push(entry.ev);
12291
- }
12292
- return out;
12293
- }
12294
- /**
12295
- * Snapshot of every pending prompt across all boxes, with its boxId and
12296
- * enqueue time — the hub's Approvals view lists these.
12297
- */
12298
- all() {
12299
- const out = [];
12300
- for (const entry of this.entries.values()) {
12301
- out.push({ id: entry.ev.id, boxId: entry.boxId, ev: entry.ev, createdAt: entry.createdAt });
12302
- }
12303
- return out;
12304
- }
12305
- /** boxId that owns a pending prompt id, or null when unknown. */
12306
- boxFor(id) {
12307
- const entry = this.entries.get(id);
12308
- return entry ? entry.boxId : null;
12309
- }
12310
- size() {
12311
- return this.entries.size;
12312
- }
12313
- };
12314
- var PromptSubscribers = class {
12315
- byBox = /* @__PURE__ */ new Map();
12316
- add(boxId, res) {
12317
- let set = this.byBox.get(boxId);
12318
- if (!set) {
12319
- set = /* @__PURE__ */ new Set();
12320
- this.byBox.set(boxId, set);
12321
- }
12322
- set.add(res);
12323
- }
12324
- remove(boxId, res) {
12325
- const set = this.byBox.get(boxId);
12326
- if (!set) return;
12327
- set.delete(res);
12328
- if (set.size === 0) this.byBox.delete(boxId);
12329
- }
12330
- forBox(boxId) {
12331
- const set = this.byBox.get(boxId);
12332
- return set ? Array.from(set) : [];
12333
- }
12334
- /**
12335
- * Fire-and-forget broadcast. SSE writes that fail (closed socket) are
12336
- * swallowed — the `res.on('close')` handler in the server route already
12337
- * deregisters the dead subscriber.
12338
- */
12339
- broadcast(boxId, event, data) {
12340
- const set = this.byBox.get(boxId);
12341
- if (!set) return;
12342
- const payload = `event: ${event}
12343
- data: ${JSON.stringify(data)}
12344
-
12345
- `;
12346
- for (const res of set) {
12347
- try {
12348
- res.write(payload);
12349
- } catch {
12350
- }
12351
- }
12352
- }
12353
- };
12354
- async function askPrompt(prompts, subscribers, boxId, params, opts) {
12355
- if (process.env.AGENTBOX_PROMPT === "off") {
12356
- return { answer: "y" };
12357
- }
12358
- if (prompts.consumeAutoApprove(boxId, params)) {
12359
- return { answer: "y" };
12360
- }
12361
- const ev = { id: (0, import_crypto.randomUUID)(), ...params };
12362
- const promise = prompts.add(boxId, ev);
12363
- subscribers.broadcast(boxId, "prompt-ask", ev);
12364
- if (opts?.ttlMs !== void 0 && opts.ttlMs > 0) {
12365
- const timer = setTimeout(() => {
12366
- if (prompts.resolve(ev.id, params.defaultAnswer ?? "n", true)) {
12367
- subscribers.broadcast(boxId, "prompt-resolved", { id: ev.id });
12368
- }
12369
- }, opts.ttlMs);
12370
- if (typeof timer.unref === "function") timer.unref();
12371
- void promise.then(() => {
12372
- clearTimeout(timer);
12373
- });
12374
- }
12375
- return promise;
12376
- }
12377
- function isPromptAnswerBody(v) {
12378
- if (!v || typeof v !== "object") return false;
12379
- const o2 = v;
12380
- if (typeof o2.id !== "string" || o2.id.length === 0) return false;
12381
- if (o2.answer !== "y" && o2.answer !== "n") return false;
12382
- if (o2.cancelled !== void 0 && typeof o2.cancelled !== "boolean") return false;
12383
- return true;
12384
- }
12385
12385
  async function gateApproval(deps, boxId, method, params, promptParams) {
12386
12386
  if (deps.mode === "block") {
12387
12387
  if (!deps.prompts || !deps.subscribers) return { kind: "deny" };
@@ -12871,7 +12871,7 @@ function sanitizeGitArgs(args) {
12871
12871
  return Array.isArray(args) ? args.filter((a2) => typeof a2 === "string") : [];
12872
12872
  }
12873
12873
 
12874
- // ../relay/dist/chunk-GEIE6TWJ.js
12874
+ // ../relay/dist/chunk-FYIOSAVW.js
12875
12875
  var import_child_process = require("child_process");
12876
12876
  var import_http2 = require("http");
12877
12877
 
@@ -19650,7 +19650,7 @@ var {
19650
19650
  getCancelSignal: getCancelSignal2
19651
19651
  } = getIpcExport();
19652
19652
 
19653
- // ../relay/dist/chunk-GEIE6TWJ.js
19653
+ // ../relay/dist/chunk-FYIOSAVW.js
19654
19654
  var import_promises20 = require("fs/promises");
19655
19655
  var import_os6 = require("os");
19656
19656
  var import_path10 = require("path");
@@ -20036,7 +20036,7 @@ var CODEX_STATIC_EXCLUDES = resolveAgentSpec("codex").staticPaths[0]?.exclude ??
20036
20036
  var CODEX_STATIC_INCLUDES = resolveAgentSpec("codex").staticPaths[0]?.include ?? [];
20037
20037
  var OPENCODE_DATA_EXCLUDES = resolveAgentSpec("opencode").staticPaths[0]?.exclude ?? [];
20038
20038
 
20039
- // ../relay/dist/chunk-GEIE6TWJ.js
20039
+ // ../relay/dist/chunk-FYIOSAVW.js
20040
20040
  var import_child_process2 = require("child_process");
20041
20041
  var import_crypto5 = require("crypto");
20042
20042
  var import_child_process3 = require("child_process");
@@ -21306,7 +21306,7 @@ function getConnector(service) {
21306
21306
  return null;
21307
21307
  }
21308
21308
 
21309
- // ../relay/dist/chunk-GEIE6TWJ.js
21309
+ // ../relay/dist/chunk-FYIOSAVW.js
21310
21310
  var import_crypto6 = require("crypto");
21311
21311
  var import_crypto7 = require("crypto");
21312
21312
  var import_path11 = require("path");
@@ -21848,7 +21848,12 @@ async function canAutoApproveTransfer(input) {
21848
21848
  }
21849
21849
  return true;
21850
21850
  }
21851
+ var cloudBackendLoader;
21851
21852
  async function resolveCloudBackend(name) {
21853
+ if (cloudBackendLoader) {
21854
+ const injected = await cloudBackendLoader.resolveBackend(name);
21855
+ if (injected) return injected;
21856
+ }
21852
21857
  if (name === "daytona") {
21853
21858
  const pkg = "@agentbox/sandbox-daytona";
21854
21859
  return loadCloudBackend(pkg, async () => (await import(pkg)).daytonaBackend);
@@ -21890,14 +21895,18 @@ async function resolveCloudBackend(name) {
21890
21895
  return pm.backend;
21891
21896
  });
21892
21897
  }
21893
- throw new Error(`no host executor for cloud backend '${name}'`);
21898
+ const via = cloudBackendLoader ? ` (loader '${cloudBackendLoader.id}' does not provide it)` : "";
21899
+ throw new Error(`no host executor for cloud backend '${name}'${via}`);
21900
+ }
21901
+ function isModuleNotFound(msg) {
21902
+ return /cannot find module|cannot find package|MODULE_NOT_FOUND|ERR_MODULE_NOT_FOUND/i.test(msg);
21894
21903
  }
21895
21904
  async function loadCloudBackend(pkg, load2) {
21896
21905
  try {
21897
21906
  return await load2();
21898
21907
  } catch (err) {
21899
21908
  const msg = err instanceof Error ? err.message : String(err);
21900
- if (/cannot find module|MODULE_NOT_FOUND/i.test(msg)) {
21909
+ if (isModuleNotFound(msg)) {
21901
21910
  throw new Error(
21902
21911
  `relay: cannot load '${pkg}' at runtime \u2014 install it alongside @agentbox/relay (the @madarco/agentbox CLI normally provides this dependency). Original: ${msg}`
21903
21912
  );
@@ -22294,6 +22303,11 @@ async function boxCarriedHostPaths(boxId) {
22294
22303
  var cloudCpModule;
22295
22304
  async function loadCloudCp() {
22296
22305
  if (cloudCpModule) return cloudCpModule;
22306
+ if (cloudBackendLoader) {
22307
+ const mod = await cloudBackendLoader.loadCloudCp();
22308
+ cloudCpModule = mod;
22309
+ return mod;
22310
+ }
22297
22311
  const pkg = "@agentbox/sandbox-cloud";
22298
22312
  try {
22299
22313
  const mod = await import(pkg);
@@ -22301,7 +22315,7 @@ async function loadCloudCp() {
22301
22315
  return mod;
22302
22316
  } catch (err) {
22303
22317
  const msg = err instanceof Error ? err.message : String(err);
22304
- if (/cannot find module|MODULE_NOT_FOUND/i.test(msg)) {
22318
+ if (isModuleNotFound(msg)) {
22305
22319
  throw new Error(
22306
22320
  `relay: cannot load '${pkg}' at runtime \u2014 install it alongside @agentbox/relay (the @madarco/agentbox CLI normally provides this dependency). Original: ${msg}`
22307
22321
  );