@geminixiang/mikan 1.0.0-beta.2 → 1.0.0-beta.21

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 (497) hide show
  1. package/CHANGELOG.md +388 -0
  2. package/README.md +49 -16
  3. package/dist/adapter.d.ts +1 -1
  4. package/dist/adapter.d.ts.map +1 -1
  5. package/dist/adapter.js.map +1 -1
  6. package/dist/adapters/buffered-responder.d.ts +60 -0
  7. package/dist/adapters/buffered-responder.d.ts.map +1 -0
  8. package/dist/adapters/buffered-responder.js +201 -0
  9. package/dist/adapters/buffered-responder.js.map +1 -0
  10. package/dist/adapters/discord/bot.d.ts +1 -0
  11. package/dist/adapters/discord/bot.d.ts.map +1 -1
  12. package/dist/adapters/discord/bot.js +36 -67
  13. package/dist/adapters/discord/bot.js.map +1 -1
  14. package/dist/adapters/discord/context.d.ts.map +1 -1
  15. package/dist/adapters/discord/context.js +44 -204
  16. package/dist/adapters/discord/context.js.map +1 -1
  17. package/dist/adapters/github/bot.d.ts +86 -0
  18. package/dist/adapters/github/bot.d.ts.map +1 -0
  19. package/dist/adapters/github/bot.js +640 -0
  20. package/dist/adapters/github/bot.js.map +1 -0
  21. package/dist/adapters/github/client.d.ts +122 -0
  22. package/dist/adapters/github/client.d.ts.map +1 -0
  23. package/dist/adapters/github/client.js +314 -0
  24. package/dist/adapters/github/client.js.map +1 -0
  25. package/dist/adapters/github/cloudbuild.d.ts +24 -0
  26. package/dist/adapters/github/cloudbuild.d.ts.map +1 -0
  27. package/dist/adapters/github/cloudbuild.js +71 -0
  28. package/dist/adapters/github/cloudbuild.js.map +1 -0
  29. package/dist/adapters/github/context.d.ts +9 -0
  30. package/dist/adapters/github/context.d.ts.map +1 -0
  31. package/dist/adapters/github/context.js +103 -0
  32. package/dist/adapters/github/context.js.map +1 -0
  33. package/dist/adapters/github/gcp-auth.d.ts +31 -0
  34. package/dist/adapters/github/gcp-auth.d.ts.map +1 -0
  35. package/dist/adapters/github/gcp-auth.js +196 -0
  36. package/dist/adapters/github/gcp-auth.js.map +1 -0
  37. package/dist/adapters/github/github-ops.d.ts +90 -0
  38. package/dist/adapters/github/github-ops.d.ts.map +1 -0
  39. package/dist/adapters/github/github-ops.js +405 -0
  40. package/dist/adapters/github/github-ops.js.map +1 -0
  41. package/dist/adapters/github/ids.d.ts +34 -0
  42. package/dist/adapters/github/ids.d.ts.map +1 -0
  43. package/dist/adapters/github/ids.js +53 -0
  44. package/dist/adapters/github/ids.js.map +1 -0
  45. package/dist/adapters/github/repo.d.ts +32 -0
  46. package/dist/adapters/github/repo.d.ts.map +1 -0
  47. package/dist/adapters/github/repo.js +141 -0
  48. package/dist/adapters/github/repo.js.map +1 -0
  49. package/dist/adapters/github/tool-pack.d.ts +14 -0
  50. package/dist/adapters/github/tool-pack.d.ts.map +1 -0
  51. package/dist/adapters/github/tool-pack.js +56 -0
  52. package/dist/adapters/github/tool-pack.js.map +1 -0
  53. package/dist/adapters/github/tools/checks.d.ts +24 -0
  54. package/dist/adapters/github/tools/checks.d.ts.map +1 -0
  55. package/dist/adapters/github/tools/checks.js +105 -0
  56. package/dist/adapters/github/tools/checks.js.map +1 -0
  57. package/dist/adapters/github/tools/issue.d.ts +22 -0
  58. package/dist/adapters/github/tools/issue.d.ts.map +1 -0
  59. package/dist/adapters/github/tools/issue.js +48 -0
  60. package/dist/adapters/github/tools/issue.js.map +1 -0
  61. package/dist/adapters/github/tools/pr.d.ts +22 -0
  62. package/dist/adapters/github/tools/pr.d.ts.map +1 -0
  63. package/dist/adapters/github/tools/pr.js +48 -0
  64. package/dist/adapters/github/tools/pr.js.map +1 -0
  65. package/dist/adapters/github/tools/read.d.ts +22 -0
  66. package/dist/adapters/github/tools/read.d.ts.map +1 -0
  67. package/dist/adapters/github/tools/read.js +141 -0
  68. package/dist/adapters/github/tools/read.js.map +1 -0
  69. package/dist/adapters/github/tools/review-reply.d.ts +19 -0
  70. package/dist/adapters/github/tools/review-reply.d.ts.map +1 -0
  71. package/dist/adapters/github/tools/review-reply.js +38 -0
  72. package/dist/adapters/github/tools/review-reply.js.map +1 -0
  73. package/dist/adapters/github/tools/sync.d.ts +17 -0
  74. package/dist/adapters/github/tools/sync.d.ts.map +1 -0
  75. package/dist/adapters/github/tools/sync.js +34 -0
  76. package/dist/adapters/github/tools/sync.js.map +1 -0
  77. package/dist/adapters/github/types.d.ts +350 -0
  78. package/dist/adapters/github/types.d.ts.map +1 -0
  79. package/dist/adapters/github/types.js +2 -0
  80. package/dist/adapters/github/types.js.map +1 -0
  81. package/dist/adapters/intake.d.ts +16 -5
  82. package/dist/adapters/intake.d.ts.map +1 -1
  83. package/dist/adapters/intake.js +79 -22
  84. package/dist/adapters/intake.js.map +1 -1
  85. package/dist/adapters/slack/bot.d.ts +8 -6
  86. package/dist/adapters/slack/bot.d.ts.map +1 -1
  87. package/dist/adapters/slack/bot.js +82 -134
  88. package/dist/adapters/slack/bot.js.map +1 -1
  89. package/dist/adapters/slack/context.d.ts.map +1 -1
  90. package/dist/adapters/slack/context.js +3 -14
  91. package/dist/adapters/slack/context.js.map +1 -1
  92. package/dist/adapters/slack/response-lifecycle.d.ts.map +1 -1
  93. package/dist/adapters/slack/response-lifecycle.js +14 -17
  94. package/dist/adapters/slack/response-lifecycle.js.map +1 -1
  95. package/dist/adapters/slack/session.d.ts.map +1 -1
  96. package/dist/adapters/slack/session.js +5 -8
  97. package/dist/adapters/slack/session.js.map +1 -1
  98. package/dist/adapters/streaming.d.ts +4 -0
  99. package/dist/adapters/streaming.d.ts.map +1 -1
  100. package/dist/adapters/streaming.js +11 -0
  101. package/dist/adapters/streaming.js.map +1 -1
  102. package/dist/adapters/telegram/bot.d.ts +1 -2
  103. package/dist/adapters/telegram/bot.d.ts.map +1 -1
  104. package/dist/adapters/telegram/bot.js +27 -62
  105. package/dist/adapters/telegram/bot.js.map +1 -1
  106. package/dist/adapters/telegram/context.d.ts.map +1 -1
  107. package/dist/adapters/telegram/context.js +37 -174
  108. package/dist/adapters/telegram/context.js.map +1 -1
  109. package/dist/adapters/types.d.ts +28 -2
  110. package/dist/adapters/types.d.ts.map +1 -1
  111. package/dist/adapters/types.js.map +1 -1
  112. package/dist/agent.d.ts +37 -14
  113. package/dist/agent.d.ts.map +1 -1
  114. package/dist/agent.js +359 -229
  115. package/dist/agent.js.map +1 -1
  116. package/dist/cli/arg-grammar.d.ts +25 -0
  117. package/dist/cli/arg-grammar.d.ts.map +1 -0
  118. package/dist/cli/arg-grammar.js +59 -0
  119. package/dist/cli/arg-grammar.js.map +1 -0
  120. package/dist/cli/boot.d.ts +16 -0
  121. package/dist/cli/boot.d.ts.map +1 -0
  122. package/dist/cli/boot.js +119 -0
  123. package/dist/cli/boot.js.map +1 -0
  124. package/dist/cli/download.d.ts.map +1 -0
  125. package/dist/cli/download.js.map +1 -0
  126. package/dist/cli/ext-git.d.ts +22 -0
  127. package/dist/cli/ext-git.d.ts.map +1 -0
  128. package/dist/cli/ext-git.js +76 -0
  129. package/dist/cli/ext-git.js.map +1 -0
  130. package/dist/cli/ext.d.ts +2 -0
  131. package/dist/cli/ext.d.ts.map +1 -0
  132. package/dist/cli/ext.js +215 -0
  133. package/dist/cli/ext.js.map +1 -0
  134. package/dist/commands/admin.d.ts.map +1 -1
  135. package/dist/commands/admin.js +2 -1
  136. package/dist/commands/admin.js.map +1 -1
  137. package/dist/commands/auto-reply.d.ts.map +1 -1
  138. package/dist/commands/auto-reply.js +2 -6
  139. package/dist/commands/auto-reply.js.map +1 -1
  140. package/dist/commands/extensions.d.ts.map +1 -1
  141. package/dist/commands/extensions.js +18 -8
  142. package/dist/commands/extensions.js.map +1 -1
  143. package/dist/commands/login.d.ts +2 -1
  144. package/dist/commands/login.d.ts.map +1 -1
  145. package/dist/commands/login.js +35 -3
  146. package/dist/commands/login.js.map +1 -1
  147. package/dist/commands/manifest.d.ts +72 -0
  148. package/dist/commands/manifest.d.ts.map +1 -0
  149. package/dist/commands/manifest.js +121 -0
  150. package/dist/commands/manifest.js.map +1 -0
  151. package/dist/commands/model.d.ts.map +1 -1
  152. package/dist/commands/model.js +11 -9
  153. package/dist/commands/model.js.map +1 -1
  154. package/dist/commands/new.d.ts.map +1 -1
  155. package/dist/commands/new.js +2 -1
  156. package/dist/commands/new.js.map +1 -1
  157. package/dist/commands/sandbox.d.ts.map +1 -1
  158. package/dist/commands/sandbox.js +23 -17
  159. package/dist/commands/sandbox.js.map +1 -1
  160. package/dist/commands/text.d.ts +2 -0
  161. package/dist/commands/text.d.ts.map +1 -0
  162. package/dist/commands/text.js +16 -0
  163. package/dist/commands/text.js.map +1 -0
  164. package/dist/commands/types.d.ts +14 -1
  165. package/dist/commands/types.d.ts.map +1 -1
  166. package/dist/commands/types.js.map +1 -1
  167. package/dist/config.d.ts +1 -3
  168. package/dist/config.d.ts.map +1 -1
  169. package/dist/config.js +98 -95
  170. package/dist/config.js.map +1 -1
  171. package/dist/env-manifest.d.ts +35 -0
  172. package/dist/env-manifest.d.ts.map +1 -0
  173. package/dist/env-manifest.js +225 -0
  174. package/dist/env-manifest.js.map +1 -0
  175. package/dist/events.d.ts.map +1 -1
  176. package/dist/events.js +9 -73
  177. package/dist/events.js.map +1 -1
  178. package/dist/execution-resolver.d.ts +4 -2
  179. package/dist/execution-resolver.d.ts.map +1 -1
  180. package/dist/execution-resolver.js +54 -41
  181. package/dist/execution-resolver.js.map +1 -1
  182. package/dist/harness/event-format.d.ts +66 -0
  183. package/dist/harness/event-format.d.ts.map +1 -0
  184. package/dist/harness/event-format.js +112 -0
  185. package/dist/harness/event-format.js.map +1 -0
  186. package/dist/harness/extensions/loader.d.ts +44 -11
  187. package/dist/harness/extensions/loader.d.ts.map +1 -1
  188. package/dist/harness/extensions/loader.js +273 -84
  189. package/dist/harness/extensions/loader.js.map +1 -1
  190. package/dist/harness/extensions/registry.d.ts +48 -1
  191. package/dist/harness/extensions/registry.d.ts.map +1 -1
  192. package/dist/harness/extensions/registry.js +146 -0
  193. package/dist/harness/extensions/registry.js.map +1 -1
  194. package/dist/harness/extensions/types.d.ts +165 -22
  195. package/dist/harness/extensions/types.d.ts.map +1 -1
  196. package/dist/harness/extensions/types.js.map +1 -1
  197. package/dist/harness/index.d.ts +6 -5
  198. package/dist/harness/index.d.ts.map +1 -1
  199. package/dist/harness/index.js +3 -2
  200. package/dist/harness/index.js.map +1 -1
  201. package/dist/harness/models.d.ts +5 -0
  202. package/dist/harness/models.d.ts.map +1 -1
  203. package/dist/harness/models.js +10 -0
  204. package/dist/harness/models.js.map +1 -1
  205. package/dist/harness/runner.d.ts +37 -2
  206. package/dist/harness/runner.d.ts.map +1 -1
  207. package/dist/harness/runner.js +107 -23
  208. package/dist/harness/runner.js.map +1 -1
  209. package/dist/harness/session-store.d.ts +4 -1
  210. package/dist/harness/session-store.d.ts.map +1 -1
  211. package/dist/harness/session-store.js +11 -2
  212. package/dist/harness/session-store.js.map +1 -1
  213. package/dist/harness/subagent-runner.d.ts +34 -0
  214. package/dist/harness/subagent-runner.d.ts.map +1 -0
  215. package/dist/harness/subagent-runner.js +339 -0
  216. package/dist/harness/subagent-runner.js.map +1 -0
  217. package/dist/harness/types.d.ts +53 -0
  218. package/dist/harness/types.d.ts.map +1 -1
  219. package/dist/harness/types.js.map +1 -1
  220. package/dist/index.d.ts +3 -3
  221. package/dist/index.d.ts.map +1 -1
  222. package/dist/index.js +2 -2
  223. package/dist/index.js.map +1 -1
  224. package/dist/main.js +260 -109
  225. package/dist/main.js.map +1 -1
  226. package/dist/observability/instrument.js +6 -4
  227. package/dist/observability/instrument.js.map +1 -1
  228. package/dist/observability/sentry.d.ts.map +1 -1
  229. package/dist/observability/sentry.js +3 -2
  230. package/dist/observability/sentry.js.map +1 -1
  231. package/dist/provisioner.d.ts.map +1 -1
  232. package/dist/provisioner.js +2 -5
  233. package/dist/provisioner.js.map +1 -1
  234. package/dist/runtime/conversation-runtime.d.ts +1 -1
  235. package/dist/runtime/conversation-runtime.d.ts.map +1 -1
  236. package/dist/runtime/conversation-runtime.js +276 -43
  237. package/dist/runtime/conversation-runtime.js.map +1 -1
  238. package/dist/runtime/types.d.ts +36 -5
  239. package/dist/runtime/types.d.ts.map +1 -1
  240. package/dist/runtime/types.js.map +1 -1
  241. package/dist/sandbox/cloudflare.d.ts +3 -0
  242. package/dist/sandbox/cloudflare.d.ts.map +1 -1
  243. package/dist/sandbox/cloudflare.js +10 -0
  244. package/dist/sandbox/cloudflare.js.map +1 -1
  245. package/dist/sandbox/container.d.ts +4 -0
  246. package/dist/sandbox/container.d.ts.map +1 -1
  247. package/dist/sandbox/container.js +11 -2
  248. package/dist/sandbox/container.js.map +1 -1
  249. package/dist/sandbox/firecracker.d.ts +3 -0
  250. package/dist/sandbox/firecracker.d.ts.map +1 -1
  251. package/dist/sandbox/firecracker.js +10 -1
  252. package/dist/sandbox/firecracker.js.map +1 -1
  253. package/dist/sandbox/gondolin-bootstrap.d.ts +26 -0
  254. package/dist/sandbox/gondolin-bootstrap.d.ts.map +1 -0
  255. package/dist/sandbox/gondolin-bootstrap.js +27 -0
  256. package/dist/sandbox/gondolin-bootstrap.js.map +1 -0
  257. package/dist/sandbox/gondolin-contract.d.ts +125 -0
  258. package/dist/sandbox/gondolin-contract.d.ts.map +1 -0
  259. package/dist/sandbox/gondolin-contract.js +155 -0
  260. package/dist/sandbox/gondolin-contract.js.map +1 -0
  261. package/dist/sandbox/gondolin-fleet.d.ts +104 -0
  262. package/dist/sandbox/gondolin-fleet.d.ts.map +1 -0
  263. package/dist/sandbox/gondolin-fleet.js +330 -0
  264. package/dist/sandbox/gondolin-fleet.js.map +1 -0
  265. package/dist/sandbox/gondolin-gateway.d.ts +86 -0
  266. package/dist/sandbox/gondolin-gateway.d.ts.map +1 -0
  267. package/dist/sandbox/gondolin-gateway.js +407 -0
  268. package/dist/sandbox/gondolin-gateway.js.map +1 -0
  269. package/dist/sandbox/gondolin-inventory.d.ts +75 -0
  270. package/dist/sandbox/gondolin-inventory.d.ts.map +1 -0
  271. package/dist/sandbox/gondolin-inventory.js +257 -0
  272. package/dist/sandbox/gondolin-inventory.js.map +1 -0
  273. package/dist/sandbox/gondolin-join.d.ts +62 -0
  274. package/dist/sandbox/gondolin-join.d.ts.map +1 -0
  275. package/dist/sandbox/gondolin-join.js +261 -0
  276. package/dist/sandbox/gondolin-join.js.map +1 -0
  277. package/dist/sandbox/gondolin-nfs-advisory.d.ts +15 -0
  278. package/dist/sandbox/gondolin-nfs-advisory.d.ts.map +1 -0
  279. package/dist/sandbox/gondolin-nfs-advisory.js +60 -0
  280. package/dist/sandbox/gondolin-nfs-advisory.js.map +1 -0
  281. package/dist/sandbox/gondolin-placement.d.ts +30 -0
  282. package/dist/sandbox/gondolin-placement.d.ts.map +1 -0
  283. package/dist/sandbox/gondolin-placement.js +77 -0
  284. package/dist/sandbox/gondolin-placement.js.map +1 -0
  285. package/dist/sandbox/gondolin-recovery.d.ts +33 -0
  286. package/dist/sandbox/gondolin-recovery.d.ts.map +1 -0
  287. package/dist/sandbox/gondolin-recovery.js +39 -0
  288. package/dist/sandbox/gondolin-recovery.js.map +1 -0
  289. package/dist/sandbox/gondolin-remote.d.ts +70 -0
  290. package/dist/sandbox/gondolin-remote.d.ts.map +1 -0
  291. package/dist/sandbox/gondolin-remote.js +325 -0
  292. package/dist/sandbox/gondolin-remote.js.map +1 -0
  293. package/dist/sandbox/gondolin-worker-client.d.ts +135 -0
  294. package/dist/sandbox/gondolin-worker-client.d.ts.map +1 -0
  295. package/dist/sandbox/gondolin-worker-client.js +323 -0
  296. package/dist/sandbox/gondolin-worker-client.js.map +1 -0
  297. package/dist/sandbox/gondolin-worker-main.d.ts +2 -0
  298. package/dist/sandbox/gondolin-worker-main.d.ts.map +1 -0
  299. package/dist/sandbox/gondolin-worker-main.js +22 -0
  300. package/dist/sandbox/gondolin-worker-main.js.map +1 -0
  301. package/dist/sandbox/gondolin-worker.d.ts +17 -0
  302. package/dist/sandbox/gondolin-worker.d.ts.map +1 -0
  303. package/dist/sandbox/gondolin-worker.js +201 -0
  304. package/dist/sandbox/gondolin-worker.js.map +1 -0
  305. package/dist/sandbox/gondolin.d.ts +53 -0
  306. package/dist/sandbox/gondolin.d.ts.map +1 -0
  307. package/dist/sandbox/gondolin.js +429 -0
  308. package/dist/sandbox/gondolin.js.map +1 -0
  309. package/dist/sandbox/host.d.ts +3 -0
  310. package/dist/sandbox/host.d.ts.map +1 -1
  311. package/dist/sandbox/host.js +14 -0
  312. package/dist/sandbox/host.js.map +1 -1
  313. package/dist/sandbox/identity.d.ts +21 -0
  314. package/dist/sandbox/identity.d.ts.map +1 -0
  315. package/dist/sandbox/identity.js +36 -0
  316. package/dist/sandbox/identity.js.map +1 -0
  317. package/dist/sandbox/index.d.ts +13 -4
  318. package/dist/sandbox/index.d.ts.map +1 -1
  319. package/dist/sandbox/index.js +19 -3
  320. package/dist/sandbox/index.js.map +1 -1
  321. package/dist/sandbox/types.d.ts +31 -1
  322. package/dist/sandbox/types.d.ts.map +1 -1
  323. package/dist/sandbox/types.js.map +1 -1
  324. package/dist/sandbox/utils.d.ts +12 -0
  325. package/dist/sandbox/utils.d.ts.map +1 -1
  326. package/dist/sandbox/utils.js +38 -0
  327. package/dist/sandbox/utils.js.map +1 -1
  328. package/dist/sessions/chat-history-sync.d.ts +32 -0
  329. package/dist/sessions/chat-history-sync.d.ts.map +1 -0
  330. package/dist/sessions/{agent-memory-file-manager.js → chat-history-sync.js} +40 -113
  331. package/dist/sessions/chat-history-sync.js.map +1 -0
  332. package/dist/sessions/conversation-log.d.ts +13 -0
  333. package/dist/sessions/conversation-log.d.ts.map +1 -0
  334. package/dist/sessions/conversation-log.js +47 -0
  335. package/dist/sessions/conversation-log.js.map +1 -0
  336. package/dist/sessions/history-line.d.ts +20 -0
  337. package/dist/sessions/history-line.d.ts.map +1 -0
  338. package/dist/sessions/history-line.js +24 -0
  339. package/dist/sessions/history-line.js.map +1 -0
  340. package/dist/sessions/policy.d.ts.map +1 -1
  341. package/dist/sessions/policy.js +5 -3
  342. package/dist/sessions/policy.js.map +1 -1
  343. package/dist/sessions/rotation.d.ts +2 -0
  344. package/dist/sessions/rotation.d.ts.map +1 -0
  345. package/dist/sessions/rotation.js +39 -0
  346. package/dist/sessions/rotation.js.map +1 -0
  347. package/dist/sessions/session-key.d.ts +31 -0
  348. package/dist/sessions/session-key.d.ts.map +1 -0
  349. package/dist/sessions/session-key.js +44 -0
  350. package/dist/sessions/session-key.js.map +1 -0
  351. package/dist/sessions/store.d.ts.map +1 -1
  352. package/dist/sessions/store.js +6 -12
  353. package/dist/sessions/store.js.map +1 -1
  354. package/dist/sessions/types.d.ts +2 -2
  355. package/dist/sessions/types.d.ts.map +1 -1
  356. package/dist/sessions/types.js.map +1 -1
  357. package/dist/settings-mutation.d.ts +23 -0
  358. package/dist/settings-mutation.d.ts.map +1 -0
  359. package/dist/settings-mutation.js +42 -0
  360. package/dist/settings-mutation.js.map +1 -0
  361. package/dist/tools/bash.d.ts +3 -1
  362. package/dist/tools/bash.d.ts.map +1 -1
  363. package/dist/tools/bash.js +24 -17
  364. package/dist/tools/bash.js.map +1 -1
  365. package/dist/tools/edit.d.ts.map +1 -1
  366. package/dist/tools/edit.js +9 -12
  367. package/dist/tools/edit.js.map +1 -1
  368. package/dist/tools/event.d.ts +1 -1
  369. package/dist/tools/event.d.ts.map +1 -1
  370. package/dist/tools/event.js +53 -43
  371. package/dist/tools/event.js.map +1 -1
  372. package/dist/tools/generate-image.d.ts +17 -0
  373. package/dist/tools/generate-image.d.ts.map +1 -0
  374. package/dist/tools/generate-image.js +63 -0
  375. package/dist/tools/generate-image.js.map +1 -0
  376. package/dist/tools/host-fn-tool.d.ts +21 -0
  377. package/dist/tools/host-fn-tool.d.ts.map +1 -0
  378. package/dist/tools/host-fn-tool.js +32 -0
  379. package/dist/tools/host-fn-tool.js.map +1 -0
  380. package/dist/tools/index.d.ts +17 -2
  381. package/dist/tools/index.d.ts.map +1 -1
  382. package/dist/tools/index.js +28 -3
  383. package/dist/tools/index.js.map +1 -1
  384. package/dist/tools/react.d.ts +15 -0
  385. package/dist/tools/react.d.ts.map +1 -0
  386. package/dist/tools/react.js +29 -0
  387. package/dist/tools/react.js.map +1 -0
  388. package/dist/tools/read.d.ts.map +1 -1
  389. package/dist/tools/read.js +7 -26
  390. package/dist/tools/read.js.map +1 -1
  391. package/dist/tools/sandbox.d.ts +2 -2
  392. package/dist/tools/sandbox.d.ts.map +1 -1
  393. package/dist/tools/sandbox.js +13 -9
  394. package/dist/tools/sandbox.js.map +1 -1
  395. package/dist/tools/subagent-slots.d.ts +28 -0
  396. package/dist/tools/subagent-slots.d.ts.map +1 -0
  397. package/dist/tools/subagent-slots.js +57 -0
  398. package/dist/tools/subagent-slots.js.map +1 -0
  399. package/dist/tools/subagent.d.ts +74 -0
  400. package/dist/tools/subagent.d.ts.map +1 -0
  401. package/dist/tools/subagent.js +335 -0
  402. package/dist/tools/subagent.js.map +1 -0
  403. package/dist/tools/types.d.ts +40 -6
  404. package/dist/tools/types.d.ts.map +1 -1
  405. package/dist/tools/types.js.map +1 -1
  406. package/dist/tools/write.d.ts.map +1 -1
  407. package/dist/tools/write.js +1 -8
  408. package/dist/tools/write.js.map +1 -1
  409. package/dist/trigger.d.ts.map +1 -1
  410. package/dist/trigger.js +1 -2
  411. package/dist/trigger.js.map +1 -1
  412. package/dist/types.d.ts +144 -31
  413. package/dist/types.d.ts.map +1 -1
  414. package/dist/types.js.map +1 -1
  415. package/dist/utils/date.d.ts +1 -1
  416. package/dist/utils/date.js +1 -1
  417. package/dist/utils/date.js.map +1 -1
  418. package/dist/vault/disabled.d.ts +9 -0
  419. package/dist/vault/disabled.d.ts.map +1 -0
  420. package/dist/vault/disabled.js +22 -0
  421. package/dist/vault/disabled.js.map +1 -0
  422. package/dist/vault/index.d.ts +0 -2
  423. package/dist/vault/index.d.ts.map +1 -1
  424. package/dist/vault/index.js +1 -32
  425. package/dist/vault/index.js.map +1 -1
  426. package/dist/vault/injection.d.ts +20 -0
  427. package/dist/vault/injection.d.ts.map +1 -0
  428. package/dist/vault/injection.js +27 -0
  429. package/dist/vault/injection.js.map +1 -0
  430. package/dist/vault/policy.d.ts +20 -0
  431. package/dist/vault/policy.d.ts.map +1 -0
  432. package/dist/vault/policy.js +20 -0
  433. package/dist/vault/policy.js.map +1 -0
  434. package/dist/vault/types.d.ts +0 -2
  435. package/dist/vault/types.d.ts.map +1 -1
  436. package/dist/vault/types.js.map +1 -1
  437. package/dist/web/admin/portal.d.ts +27 -0
  438. package/dist/web/admin/portal.d.ts.map +1 -1
  439. package/dist/web/admin/portal.js +117 -154
  440. package/dist/web/admin/portal.js.map +1 -1
  441. package/dist/web/admin/types.d.ts +6 -0
  442. package/dist/web/admin/types.d.ts.map +1 -1
  443. package/dist/web/admin/types.js.map +1 -1
  444. package/dist/web/agent-events/portal.d.ts.map +1 -1
  445. package/dist/web/agent-events/portal.js +2 -1
  446. package/dist/web/agent-events/portal.js.map +1 -1
  447. package/dist/web/login/oauth.d.ts +2 -3
  448. package/dist/web/login/oauth.d.ts.map +1 -1
  449. package/dist/web/login/oauth.js +0 -31
  450. package/dist/web/login/oauth.js.map +1 -1
  451. package/dist/web/login/portal.js +1 -1
  452. package/dist/web/login/portal.js.map +1 -1
  453. package/dist/web/login/types.d.ts +0 -11
  454. package/dist/web/login/types.d.ts.map +1 -1
  455. package/dist/web/login/types.js.map +1 -1
  456. package/dist/web/portal-shell.d.ts +4 -0
  457. package/dist/web/portal-shell.d.ts.map +1 -0
  458. package/dist/{portal-shell.js → web/portal-shell.js} +2 -2
  459. package/dist/web/portal-shell.js.map +1 -0
  460. package/dist/web/server.d.ts.map +1 -1
  461. package/dist/web/server.js +7 -0
  462. package/dist/web/server.js.map +1 -1
  463. package/dist/web/session-view/command.d.ts.map +1 -1
  464. package/dist/web/session-view/command.js +4 -1
  465. package/dist/web/session-view/command.js.map +1 -1
  466. package/dist/web/session-view/portal.d.ts.map +1 -1
  467. package/dist/web/session-view/portal.js +4 -3
  468. package/dist/web/session-view/portal.js.map +1 -1
  469. package/dist/web/session-view/service.d.ts.map +1 -1
  470. package/dist/web/session-view/service.js +2 -1
  471. package/dist/web/session-view/service.js.map +1 -1
  472. package/dist/web/session-view/types.d.ts +2 -1
  473. package/dist/web/session-view/types.d.ts.map +1 -1
  474. package/dist/web/session-view/types.js.map +1 -1
  475. package/package.json +7 -4
  476. package/dist/download.d.ts.map +0 -1
  477. package/dist/download.js.map +0 -1
  478. package/dist/model-registry.d.ts +0 -4
  479. package/dist/model-registry.d.ts.map +0 -1
  480. package/dist/model-registry.js +0 -7
  481. package/dist/model-registry.js.map +0 -1
  482. package/dist/portal-shell.d.ts +0 -4
  483. package/dist/portal-shell.d.ts.map +0 -1
  484. package/dist/portal-shell.js.map +0 -1
  485. package/dist/runtime/agent-run-controller.d.ts +0 -31
  486. package/dist/runtime/agent-run-controller.d.ts.map +0 -1
  487. package/dist/runtime/agent-run-controller.js +0 -195
  488. package/dist/runtime/agent-run-controller.js.map +0 -1
  489. package/dist/sessions/agent-memory-file-manager.d.ts +0 -19
  490. package/dist/sessions/agent-memory-file-manager.d.ts.map +0 -1
  491. package/dist/sessions/agent-memory-file-manager.js.map +0 -1
  492. package/dist/vault/routing.d.ts +0 -3
  493. package/dist/vault/routing.d.ts.map +0 -1
  494. package/dist/vault/routing.js +0 -13
  495. package/dist/vault/routing.js.map +0 -1
  496. /package/dist/{download.d.ts → cli/download.d.ts} +0 -0
  497. /package/dist/{download.js → cli/download.js} +0 -0
@@ -0,0 +1,330 @@
1
+ import * as log from "../log.js";
2
+ import { SandboxError } from "./errors.js";
3
+ import { gondolinPlacements } from "./gondolin-placement.js";
4
+ import { GondolinRemoteConnection, GondolinWorkerUnreachableError, } from "./gondolin-remote.js";
5
+ import { GondolinRuntimeGoneError } from "./gondolin-recovery.js";
6
+ const LEASE_TTL_SECONDS = 300;
7
+ const QUEUE_WAIT_SECONDS = 60;
8
+ const QUEUE_POLL_MS = 2000;
9
+ function normalizeWorkers(settings) {
10
+ const inline = settings.workers ?? [{ url: settings.url }];
11
+ return inline.map((worker) => ({
12
+ ...worker,
13
+ name: worker.name ?? worker.url,
14
+ caFile: worker.caFile ?? settings.caFile,
15
+ certFile: worker.certFile ?? settings.certFile,
16
+ keyFile: worker.keyFile ?? settings.keyFile,
17
+ workspaceRoot: worker.workspaceRoot ?? settings.workspaceRoot,
18
+ maxRuntimes: worker.maxRuntimes ?? settings.maxRuntimes,
19
+ }));
20
+ }
21
+ /**
22
+ * Places each conversation's runtime on one worker of the fleet and keeps it
23
+ * there (sticky placement). Failover to another worker happens only when the
24
+ * placed worker is unreachable AND its lease fencing watermark has passed —
25
+ * the point after which the old worker's janitor has provably stopped the
26
+ * runtime, so shared storage never sees two writers.
27
+ */
28
+ class GondolinFleetClient {
29
+ constructor() {
30
+ this.workers = new Map();
31
+ this.connectionOverrides = {};
32
+ this.placements = gondolinPlacements;
33
+ this.leaseTtlMs = LEASE_TTL_SECONDS * 1000;
34
+ this.queueWaitMs = QUEUE_WAIT_SECONDS * 1000;
35
+ this.queuePollMs = QUEUE_POLL_MS;
36
+ this.now = Date.now;
37
+ this.sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
38
+ }
39
+ configure(settings, overrides) {
40
+ for (const worker of this.workers.values())
41
+ worker.connection.dispose();
42
+ this.workers.clear();
43
+ this.settings = settings;
44
+ this.placements = overrides?.placements ?? gondolinPlacements;
45
+ this.now = overrides?.now ?? Date.now;
46
+ this.sleep = overrides?.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
47
+ this.queuePollMs = overrides?.queuePollMs ?? QUEUE_POLL_MS;
48
+ this.connectionOverrides = overrides?.connectionOverrides ?? {};
49
+ this.leaseTtlMs = (overrides?.connectionOverrides?.leaseTtlSeconds ?? LEASE_TTL_SECONDS) * 1000;
50
+ this.queueWaitMs = (settings?.queueWaitSeconds ?? QUEUE_WAIT_SECONDS) * 1000;
51
+ if (!settings)
52
+ return;
53
+ if (!settings.workers?.length && !settings.url) {
54
+ return; // not configured; validate() reports the actionable error
55
+ }
56
+ const createConnection = overrides?.createConnection ??
57
+ ((worker, connectionOverrides) => new GondolinRemoteConnection(worker, connectionOverrides));
58
+ for (const worker of normalizeWorkers(settings)) {
59
+ const name = worker.name;
60
+ const connection = createConnection(worker, {
61
+ ...overrides?.connectionOverrides,
62
+ onLeaseActivity: (instanceId, expiresAtMs) => {
63
+ if (this.placements.get(instanceId)?.worker === name) {
64
+ this.placements.touch(instanceId, expiresAtMs);
65
+ }
66
+ },
67
+ });
68
+ this.workers.set(name, { name, settings: worker, connection });
69
+ }
70
+ }
71
+ isConfigured() {
72
+ return this.workers.size > 0;
73
+ }
74
+ /** Names of statically-configured workers with no workspaceRoot (startup guard). */
75
+ workersMissingWorkspaceRoot() {
76
+ return Array.from(this.workers.values())
77
+ .filter((worker) => !worker.settings.workspaceRoot)
78
+ .map((worker) => worker.name);
79
+ }
80
+ /**
81
+ * Attach a dial-home worker at runtime (the gateway calls this when a
82
+ * worker registers). The factory receives the fleet's connection overrides
83
+ * plus the lease-watermark callback, mirroring configure()'s wiring.
84
+ */
85
+ attachWorker(settings, createConnection) {
86
+ const name = settings.name ?? settings.url;
87
+ this.workers.get(name)?.connection.dispose();
88
+ const connection = createConnection({
89
+ ...this.connectionOverrides,
90
+ onLeaseActivity: (instanceId, expiresAtMs) => {
91
+ if (this.placements.get(instanceId)?.worker === name) {
92
+ this.placements.touch(instanceId, expiresAtMs);
93
+ }
94
+ },
95
+ });
96
+ this.workers.set(name, { name, settings: { ...settings, name }, connection });
97
+ }
98
+ /**
99
+ * Record a worker's shared-workspace health (the gateway pushes this from
100
+ * register and ping frames). A degraded worker keeps its runtimes and its
101
+ * connection, but new placements skip it and runtime operations fail fast
102
+ * with the probe's diagnosis instead of hanging on a dead mount.
103
+ */
104
+ setWorkspaceHealth(name, error) {
105
+ const worker = this.workers.get(name);
106
+ if (!worker)
107
+ return;
108
+ worker.workspaceError = error || undefined;
109
+ }
110
+ /**
111
+ * Detach a dial-home worker (disconnect). Placements survive: their lease
112
+ * watermarks keep fencing failover until expiry, exactly as for an
113
+ * unreachable static worker.
114
+ */
115
+ detachWorker(name) {
116
+ const worker = this.workers.get(name);
117
+ if (!worker)
118
+ return;
119
+ worker.connection.dispose();
120
+ this.workers.delete(name);
121
+ }
122
+ imageSelector() {
123
+ return this.settings?.imageSelector;
124
+ }
125
+ /** At least one worker must answer for the sandbox mode to come up. */
126
+ async health() {
127
+ const report = await Promise.all(Array.from(this.workers.values()).map(async (worker) => {
128
+ try {
129
+ return { worker: worker.name, health: await worker.connection.health() };
130
+ }
131
+ catch {
132
+ return { worker: worker.name };
133
+ }
134
+ }));
135
+ if (report.length > 0 && !report.some((entry) => entry.health)) {
136
+ throw new SandboxError("Error: no gondolin remote worker is reachable");
137
+ }
138
+ return report;
139
+ }
140
+ async ensure(instanceId, spec) {
141
+ const placed = this.placements.get(instanceId);
142
+ if (placed) {
143
+ const worker = this.workers.get(placed.worker);
144
+ if (worker) {
145
+ try {
146
+ return await this.ensureOn(worker, instanceId, spec);
147
+ }
148
+ catch (err) {
149
+ if (!(err instanceof GondolinWorkerUnreachableError))
150
+ throw err;
151
+ this.assertFailoverAllowed(instanceId, placed.worker, placed.leaseExpiresAt, err);
152
+ }
153
+ }
154
+ else {
155
+ this.assertFailoverAllowed(instanceId, placed.worker, placed.leaseExpiresAt, new GondolinWorkerUnreachableError("worker is no longer configured"));
156
+ }
157
+ log.logWarning(`Gondolin worker '${placed.worker}' lost runtime for '${instanceId}'; failing over`);
158
+ }
159
+ const worker = await this.selectWorker();
160
+ return this.ensureOn(worker, instanceId, spec);
161
+ }
162
+ async stop(handle) {
163
+ const worker = this.workerFor(handle.workerName);
164
+ if (!worker) {
165
+ // the worker left the fleet config; its janitor stops the runtime when
166
+ // the lease expires, and the record keeps fencing until then
167
+ return;
168
+ }
169
+ try {
170
+ await worker.connection.stop(handle);
171
+ this.placements.delete(handle.instanceId);
172
+ }
173
+ catch (err) {
174
+ if (err instanceof GondolinWorkerUnreachableError) {
175
+ // cannot confirm the stop; keep the placement so its watermark still
176
+ // fences any failover, and let the daemon's expiry janitor finish it
177
+ log.logWarning(`Gondolin worker '${worker.name}' unreachable while stopping '${handle.instanceId}'; leaving it to lease expiry`);
178
+ return;
179
+ }
180
+ throw err;
181
+ }
182
+ }
183
+ async exec(handle, command, options = {}) {
184
+ const worker = this.workerFor(handle.workerName);
185
+ if (!worker)
186
+ throw new GondolinRuntimeGoneError("worker is no longer configured");
187
+ this.assertWorkspaceUsable(worker);
188
+ log.logInfo(`Gondolin execution '${handle.instanceId}' routed to worker '${worker.name}'`);
189
+ return worker.connection.exec(handle, command, options);
190
+ }
191
+ async isRuntimeAlive(handle) {
192
+ const worker = this.workerFor(handle.workerName);
193
+ if (!worker)
194
+ return false;
195
+ return worker.connection.isRuntimeAlive(handle);
196
+ }
197
+ /**
198
+ * Fleet reconciliation: a runtime whose conversation is placed on a
199
+ * different worker is a stray from a superseded placement — stop it. A
200
+ * runtime with no placement at all (crash between daemon ensure and the
201
+ * placement write) is adopted instead of killed.
202
+ */
203
+ async reconcile() {
204
+ for (const worker of this.workers.values()) {
205
+ let runtimes;
206
+ try {
207
+ runtimes = await worker.connection.listRuntimes();
208
+ }
209
+ catch {
210
+ continue; // unreachable workers reconcile on a later sweep
211
+ }
212
+ for (const runtime of runtimes) {
213
+ const record = this.placements.get(runtime.instanceId);
214
+ if (!record) {
215
+ log.logInfo(`Adopting unplaced Gondolin runtime '${runtime.instanceId}' on worker '${worker.name}'`);
216
+ this.placements.set(runtime.instanceId, worker.name, this.now() + this.leaseTtlMs);
217
+ continue;
218
+ }
219
+ if (record.worker === worker.name)
220
+ continue;
221
+ log.logInfo(`Stopping stray Gondolin runtime '${runtime.instanceId}' on worker '${worker.name}' (placed on '${record.worker}')`);
222
+ try {
223
+ await worker.connection.stop({
224
+ sessionId: runtime.sessionId,
225
+ instanceId: runtime.instanceId,
226
+ workerPid: 0,
227
+ });
228
+ }
229
+ catch (err) {
230
+ log.logWarning(`Failed to stop stray runtime '${runtime.instanceId}' on '${worker.name}'`, err instanceof Error ? err.message : String(err));
231
+ }
232
+ }
233
+ }
234
+ }
235
+ async ensureOn(worker, instanceId, spec) {
236
+ this.assertWorkspaceUsable(worker);
237
+ const handle = await worker.connection.ensure(instanceId, spec);
238
+ this.placements.set(instanceId, worker.name, this.now() + this.leaseTtlMs);
239
+ return { ...handle, workerName: worker.name };
240
+ }
241
+ /**
242
+ * Fail fast — with the probe's diagnosis — instead of dispatching work that
243
+ * would hang on a dead shared-workspace mount. Deliberately NOT a
244
+ * GondolinWorkerUnreachableError: a broken mount must not trigger failover,
245
+ * because the workspace is shared and likely broken for every worker.
246
+ */
247
+ assertWorkspaceUsable(worker) {
248
+ if (!worker.workspaceError)
249
+ return;
250
+ throw new SandboxError(`Error: Gondolin worker '${worker.name}' has an unusable shared workspace: ` +
251
+ `${worker.workspaceError} (fix the mount on the worker; health refreshes with its next heartbeat)`);
252
+ }
253
+ assertFailoverAllowed(instanceId, workerName, leaseExpiresAt, cause) {
254
+ const remainingMs = leaseExpiresAt - this.now();
255
+ if (remainingMs <= 0)
256
+ return;
257
+ // Failing over earlier could put a second writable VM on the same shared
258
+ // workspace: the old worker may be alive behind a partition, and its
259
+ // daemon only stops the runtime once the lease expires.
260
+ throw new SandboxError(`Error: Gondolin worker '${workerName}' is unreachable (${cause.message}); ` +
261
+ `retrying '${instanceId}' elsewhere in ${Math.ceil(remainingMs / 1000)}s once its lease has expired`);
262
+ }
263
+ async selectWorker() {
264
+ const deadline = this.now() + this.queueWaitMs;
265
+ for (;;) {
266
+ let best;
267
+ let reachable = 0;
268
+ let draining = 0;
269
+ let full = 0;
270
+ const degraded = [];
271
+ for (const worker of this.workers.values()) {
272
+ if (worker.settings.draining) {
273
+ draining += 1;
274
+ continue;
275
+ }
276
+ if (worker.workspaceError) {
277
+ degraded.push(`'${worker.name}': ${worker.workspaceError}`);
278
+ continue;
279
+ }
280
+ let active;
281
+ let workspaceError;
282
+ try {
283
+ const health = await worker.connection.health();
284
+ active = typeof health.activeRuntimes === "number" ? health.activeRuntimes : 0;
285
+ workspaceError =
286
+ typeof health.workspaceError === "string" && health.workspaceError
287
+ ? health.workspaceError
288
+ : undefined;
289
+ }
290
+ catch {
291
+ continue;
292
+ }
293
+ reachable += 1;
294
+ if (workspaceError) {
295
+ // static workers report probe results via /v1/health only
296
+ degraded.push(`'${worker.name}': ${workspaceError}`);
297
+ continue;
298
+ }
299
+ const cap = worker.settings.maxRuntimes;
300
+ if (cap !== undefined && active >= cap) {
301
+ full += 1;
302
+ continue;
303
+ }
304
+ const load = cap !== undefined ? active / cap : active / Number.MAX_SAFE_INTEGER;
305
+ if (!best || load < best.load)
306
+ best = { worker, load };
307
+ }
308
+ if (best)
309
+ return best.worker;
310
+ if (reachable === 0 && draining === 0 && degraded.length === 0) {
311
+ throw new SandboxError("Error: no gondolin remote worker is reachable");
312
+ }
313
+ if (full === 0) {
314
+ const detail = degraded.length > 0 ? ` — degraded: ${degraded.join("; ")}` : "";
315
+ throw new SandboxError(`Error: every gondolin remote worker is draining, degraded, or unreachable${detail}`);
316
+ }
317
+ if (this.now() >= deadline) {
318
+ throw new SandboxError(`Error: all gondolin remote workers are at capacity (waited ${Math.round(this.queueWaitMs / 1000)}s)`);
319
+ }
320
+ await this.sleep(this.queuePollMs);
321
+ }
322
+ }
323
+ workerFor(workerName) {
324
+ if (!workerName)
325
+ return undefined;
326
+ return this.workers.get(workerName);
327
+ }
328
+ }
329
+ export const gondolinFleet = new GondolinFleetClient();
330
+ //# sourceMappingURL=gondolin-fleet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gondolin-fleet.js","sourceRoot":"","sources":["../../src/sandbox/gondolin-fleet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAA+B,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EACL,wBAAwB,EACxB,8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gBAAE,OAAO,IAAI,CAAC,MAAM,CAAC;YAC7B,IAAI,SAAS,KAAK,CAAC,IAAI,QAAQ,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC/D,MAAM,IAAI,YAAY,CAAC,+CAA+C,CAAC,CAAC;YAC1E,CAAC;YACD,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAChF,MAAM,IAAI,YAAY,CACpB,4EAA4E,MAAM,EAAE,CACrF,CAAC;YACJ,CAAC;YACD,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC;gBAC3B,MAAM,IAAI,YAAY,CACpB,8DAA8D,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CACtG,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAEO,SAAS,CAAC,UAA8B;QAC9C,IAAI,CAAC,UAAU;YAAE,OAAO,SAAS,CAAC;QAClC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,mBAAmB,EAAE,CAAC","sourcesContent":["import * as log from \"../log.js\";\nimport type { GondolinRemoteSettings, GondolinRemoteWorkerSettings } from \"../types.js\";\nimport { SandboxError } from \"./errors.js\";\nimport { gondolinPlacements, type GondolinPlacementStore } from \"./gondolin-placement.js\";\nimport {\n GondolinRemoteConnection,\n GondolinWorkerUnreachableError,\n type GondolinRemoteOverrides,\n} from \"./gondolin-remote.js\";\nimport { GondolinRuntimeGoneError } from \"./gondolin-recovery.js\";\nimport type {\n GondolinRuntimeHandle,\n GondolinRuntimeSpec,\n GondolinRuntimeTransport,\n} from \"./gondolin-worker-client.js\";\nimport type { ExecResult } from \"./types.js\";\n\nconst LEASE_TTL_SECONDS = 300;\nconst QUEUE_WAIT_SECONDS = 60;\nconst QUEUE_POLL_MS = 2000;\n\n/** The connection surface the fleet needs from each worker. */\nexport interface GondolinWorkerConnection {\n health(): Promise<Record<string, unknown>>;\n ensure(instanceId: string, spec: GondolinRuntimeSpec): Promise<GondolinRuntimeHandle>;\n stop(\n handle: Pick<GondolinRuntimeHandle, \"workerPid\" | \"sessionId\" | \"instanceId\">,\n ): Promise<void>;\n exec(\n handle: GondolinRuntimeHandle,\n command: string,\n options?: { env?: Record<string, string>; signal?: AbortSignal },\n ): Promise<ExecResult>;\n isRuntimeAlive(handle: GondolinRuntimeHandle): Promise<boolean>;\n listRuntimes(): Promise<Array<{ sessionId: string; instanceId: string }>>;\n dispose(): void;\n}\n\ninterface FleetWorker {\n name: string;\n settings: GondolinRemoteWorkerSettings;\n connection: GondolinWorkerConnection;\n /** Non-empty when the worker's shared workspace failed its usability probe. */\n workspaceError?: string;\n}\n\ninterface GondolinFleetOverrides {\n createConnection?: (\n worker: GondolinRemoteWorkerSettings,\n connectionOverrides: GondolinRemoteOverrides,\n ) => GondolinWorkerConnection;\n placements?: GondolinPlacementStore;\n connectionOverrides?: GondolinRemoteOverrides;\n now?: () => number;\n queuePollMs?: number;\n sleep?: (ms: number) => Promise<void>;\n}\n\nfunction normalizeWorkers(settings: GondolinRemoteSettings): GondolinRemoteWorkerSettings[] {\n const inline = settings.workers ?? [{ url: settings.url as string }];\n return inline.map((worker) => ({\n ...worker,\n name: worker.name ?? worker.url,\n caFile: worker.caFile ?? settings.caFile,\n certFile: worker.certFile ?? settings.certFile,\n keyFile: worker.keyFile ?? settings.keyFile,\n workspaceRoot: worker.workspaceRoot ?? settings.workspaceRoot,\n maxRuntimes: worker.maxRuntimes ?? settings.maxRuntimes,\n }));\n}\n\n/**\n * Places each conversation's runtime on one worker of the fleet and keeps it\n * there (sticky placement). Failover to another worker happens only when the\n * placed worker is unreachable AND its lease fencing watermark has passed —\n * the point after which the old worker's janitor has provably stopped the\n * runtime, so shared storage never sees two writers.\n */\nclass GondolinFleetClient implements GondolinRuntimeTransport {\n private settings?: GondolinRemoteSettings;\n private workers = new Map<string, FleetWorker>();\n private connectionOverrides: GondolinRemoteOverrides = {};\n private placements: GondolinPlacementStore = gondolinPlacements;\n private leaseTtlMs = LEASE_TTL_SECONDS * 1000;\n private queueWaitMs = QUEUE_WAIT_SECONDS * 1000;\n private queuePollMs = QUEUE_POLL_MS;\n private now: () => number = Date.now;\n private sleep: (ms: number) => Promise<void> = (ms) =>\n new Promise((resolve) => setTimeout(resolve, ms));\n\n configure(settings?: GondolinRemoteSettings, overrides?: GondolinFleetOverrides): void {\n for (const worker of this.workers.values()) worker.connection.dispose();\n this.workers.clear();\n this.settings = settings;\n this.placements = overrides?.placements ?? gondolinPlacements;\n this.now = overrides?.now ?? Date.now;\n this.sleep = overrides?.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));\n this.queuePollMs = overrides?.queuePollMs ?? QUEUE_POLL_MS;\n this.connectionOverrides = overrides?.connectionOverrides ?? {};\n this.leaseTtlMs = (overrides?.connectionOverrides?.leaseTtlSeconds ?? LEASE_TTL_SECONDS) * 1000;\n this.queueWaitMs = (settings?.queueWaitSeconds ?? QUEUE_WAIT_SECONDS) * 1000;\n if (!settings) return;\n if (!settings.workers?.length && !settings.url) {\n return; // not configured; validate() reports the actionable error\n }\n const createConnection =\n overrides?.createConnection ??\n ((worker: GondolinRemoteWorkerSettings, connectionOverrides: GondolinRemoteOverrides) =>\n new GondolinRemoteConnection(worker, connectionOverrides));\n for (const worker of normalizeWorkers(settings)) {\n const name = worker.name as string;\n const connection = createConnection(worker, {\n ...overrides?.connectionOverrides,\n onLeaseActivity: (instanceId, expiresAtMs) => {\n if (this.placements.get(instanceId)?.worker === name) {\n this.placements.touch(instanceId, expiresAtMs);\n }\n },\n });\n this.workers.set(name, { name, settings: worker, connection });\n }\n }\n\n isConfigured(): boolean {\n return this.workers.size > 0;\n }\n\n /** Names of statically-configured workers with no workspaceRoot (startup guard). */\n workersMissingWorkspaceRoot(): string[] {\n return Array.from(this.workers.values())\n .filter((worker) => !worker.settings.workspaceRoot)\n .map((worker) => worker.name);\n }\n\n /**\n * Attach a dial-home worker at runtime (the gateway calls this when a\n * worker registers). The factory receives the fleet's connection overrides\n * plus the lease-watermark callback, mirroring configure()'s wiring.\n */\n attachWorker(\n settings: GondolinRemoteWorkerSettings,\n createConnection: (overrides: GondolinRemoteOverrides) => GondolinWorkerConnection,\n ): void {\n const name = settings.name ?? settings.url;\n this.workers.get(name)?.connection.dispose();\n const connection = createConnection({\n ...this.connectionOverrides,\n onLeaseActivity: (instanceId, expiresAtMs) => {\n if (this.placements.get(instanceId)?.worker === name) {\n this.placements.touch(instanceId, expiresAtMs);\n }\n },\n });\n this.workers.set(name, { name, settings: { ...settings, name }, connection });\n }\n\n /**\n * Record a worker's shared-workspace health (the gateway pushes this from\n * register and ping frames). A degraded worker keeps its runtimes and its\n * connection, but new placements skip it and runtime operations fail fast\n * with the probe's diagnosis instead of hanging on a dead mount.\n */\n setWorkspaceHealth(name: string, error?: string): void {\n const worker = this.workers.get(name);\n if (!worker) return;\n worker.workspaceError = error || undefined;\n }\n\n /**\n * Detach a dial-home worker (disconnect). Placements survive: their lease\n * watermarks keep fencing failover until expiry, exactly as for an\n * unreachable static worker.\n */\n detachWorker(name: string): void {\n const worker = this.workers.get(name);\n if (!worker) return;\n worker.connection.dispose();\n this.workers.delete(name);\n }\n\n imageSelector(): string | undefined {\n return this.settings?.imageSelector;\n }\n\n /** At least one worker must answer for the sandbox mode to come up. */\n async health(): Promise<Array<{ worker: string; health?: Record<string, unknown> }>> {\n const report = await Promise.all(\n Array.from(this.workers.values()).map(async (worker) => {\n try {\n return { worker: worker.name, health: await worker.connection.health() };\n } catch {\n return { worker: worker.name };\n }\n }),\n );\n if (report.length > 0 && !report.some((entry) => entry.health)) {\n throw new SandboxError(\"Error: no gondolin remote worker is reachable\");\n }\n return report;\n }\n\n async ensure(instanceId: string, spec: GondolinRuntimeSpec): Promise<GondolinRuntimeHandle> {\n const placed = this.placements.get(instanceId);\n if (placed) {\n const worker = this.workers.get(placed.worker);\n if (worker) {\n try {\n return await this.ensureOn(worker, instanceId, spec);\n } catch (err) {\n if (!(err instanceof GondolinWorkerUnreachableError)) throw err;\n this.assertFailoverAllowed(instanceId, placed.worker, placed.leaseExpiresAt, err);\n }\n } else {\n this.assertFailoverAllowed(\n instanceId,\n placed.worker,\n placed.leaseExpiresAt,\n new GondolinWorkerUnreachableError(\"worker is no longer configured\"),\n );\n }\n log.logWarning(\n `Gondolin worker '${placed.worker}' lost runtime for '${instanceId}'; failing over`,\n );\n }\n const worker = await this.selectWorker();\n return this.ensureOn(worker, instanceId, spec);\n }\n\n async stop(\n handle: Pick<GondolinRuntimeHandle, \"workerPid\" | \"sessionId\" | \"instanceId\" | \"workerName\">,\n ): Promise<void> {\n const worker = this.workerFor(handle.workerName);\n if (!worker) {\n // the worker left the fleet config; its janitor stops the runtime when\n // the lease expires, and the record keeps fencing until then\n return;\n }\n try {\n await worker.connection.stop(handle);\n this.placements.delete(handle.instanceId);\n } catch (err) {\n if (err instanceof GondolinWorkerUnreachableError) {\n // cannot confirm the stop; keep the placement so its watermark still\n // fences any failover, and let the daemon's expiry janitor finish it\n log.logWarning(\n `Gondolin worker '${worker.name}' unreachable while stopping '${handle.instanceId}'; leaving it to lease expiry`,\n );\n return;\n }\n throw err;\n }\n }\n\n async exec(\n handle: GondolinRuntimeHandle,\n command: string,\n options: { env?: Record<string, string>; signal?: AbortSignal } = {},\n ): Promise<ExecResult> {\n const worker = this.workerFor(handle.workerName);\n if (!worker) throw new GondolinRuntimeGoneError(\"worker is no longer configured\");\n this.assertWorkspaceUsable(worker);\n log.logInfo(`Gondolin execution '${handle.instanceId}' routed to worker '${worker.name}'`);\n return worker.connection.exec(handle, command, options);\n }\n\n async isRuntimeAlive(handle: GondolinRuntimeHandle): Promise<boolean> {\n const worker = this.workerFor(handle.workerName);\n if (!worker) return false;\n return worker.connection.isRuntimeAlive(handle);\n }\n\n /**\n * Fleet reconciliation: a runtime whose conversation is placed on a\n * different worker is a stray from a superseded placement — stop it. A\n * runtime with no placement at all (crash between daemon ensure and the\n * placement write) is adopted instead of killed.\n */\n async reconcile(): Promise<void> {\n for (const worker of this.workers.values()) {\n let runtimes: Array<{ sessionId: string; instanceId: string }>;\n try {\n runtimes = await worker.connection.listRuntimes();\n } catch {\n continue; // unreachable workers reconcile on a later sweep\n }\n for (const runtime of runtimes) {\n const record = this.placements.get(runtime.instanceId);\n if (!record) {\n log.logInfo(\n `Adopting unplaced Gondolin runtime '${runtime.instanceId}' on worker '${worker.name}'`,\n );\n this.placements.set(runtime.instanceId, worker.name, this.now() + this.leaseTtlMs);\n continue;\n }\n if (record.worker === worker.name) continue;\n log.logInfo(\n `Stopping stray Gondolin runtime '${runtime.instanceId}' on worker '${worker.name}' (placed on '${record.worker}')`,\n );\n try {\n await worker.connection.stop({\n sessionId: runtime.sessionId,\n instanceId: runtime.instanceId,\n workerPid: 0,\n });\n } catch (err) {\n log.logWarning(\n `Failed to stop stray runtime '${runtime.instanceId}' on '${worker.name}'`,\n err instanceof Error ? err.message : String(err),\n );\n }\n }\n }\n }\n\n private async ensureOn(\n worker: FleetWorker,\n instanceId: string,\n spec: GondolinRuntimeSpec,\n ): Promise<GondolinRuntimeHandle> {\n this.assertWorkspaceUsable(worker);\n const handle = await worker.connection.ensure(instanceId, spec);\n this.placements.set(instanceId, worker.name, this.now() + this.leaseTtlMs);\n return { ...handle, workerName: worker.name };\n }\n\n /**\n * Fail fast — with the probe's diagnosis — instead of dispatching work that\n * would hang on a dead shared-workspace mount. Deliberately NOT a\n * GondolinWorkerUnreachableError: a broken mount must not trigger failover,\n * because the workspace is shared and likely broken for every worker.\n */\n private assertWorkspaceUsable(worker: FleetWorker): void {\n if (!worker.workspaceError) return;\n throw new SandboxError(\n `Error: Gondolin worker '${worker.name}' has an unusable shared workspace: ` +\n `${worker.workspaceError} (fix the mount on the worker; health refreshes with its next heartbeat)`,\n );\n }\n\n private assertFailoverAllowed(\n instanceId: string,\n workerName: string,\n leaseExpiresAt: number,\n cause: Error,\n ): void {\n const remainingMs = leaseExpiresAt - this.now();\n if (remainingMs <= 0) return;\n // Failing over earlier could put a second writable VM on the same shared\n // workspace: the old worker may be alive behind a partition, and its\n // daemon only stops the runtime once the lease expires.\n throw new SandboxError(\n `Error: Gondolin worker '${workerName}' is unreachable (${cause.message}); ` +\n `retrying '${instanceId}' elsewhere in ${Math.ceil(remainingMs / 1000)}s once its lease has expired`,\n );\n }\n\n private async selectWorker(): Promise<FleetWorker> {\n const deadline = this.now() + this.queueWaitMs;\n for (;;) {\n let best: { worker: FleetWorker; load: number } | undefined;\n let reachable = 0;\n let draining = 0;\n let full = 0;\n const degraded: string[] = [];\n for (const worker of this.workers.values()) {\n if (worker.settings.draining) {\n draining += 1;\n continue;\n }\n if (worker.workspaceError) {\n degraded.push(`'${worker.name}': ${worker.workspaceError}`);\n continue;\n }\n let active: number;\n let workspaceError: string | undefined;\n try {\n const health = await worker.connection.health();\n active = typeof health.activeRuntimes === \"number\" ? health.activeRuntimes : 0;\n workspaceError =\n typeof health.workspaceError === \"string\" && health.workspaceError\n ? health.workspaceError\n : undefined;\n } catch {\n continue;\n }\n reachable += 1;\n if (workspaceError) {\n // static workers report probe results via /v1/health only\n degraded.push(`'${worker.name}': ${workspaceError}`);\n continue;\n }\n const cap = worker.settings.maxRuntimes;\n if (cap !== undefined && active >= cap) {\n full += 1;\n continue;\n }\n const load = cap !== undefined ? active / cap : active / Number.MAX_SAFE_INTEGER;\n if (!best || load < best.load) best = { worker, load };\n }\n if (best) return best.worker;\n if (reachable === 0 && draining === 0 && degraded.length === 0) {\n throw new SandboxError(\"Error: no gondolin remote worker is reachable\");\n }\n if (full === 0) {\n const detail = degraded.length > 0 ? ` — degraded: ${degraded.join(\"; \")}` : \"\";\n throw new SandboxError(\n `Error: every gondolin remote worker is draining, degraded, or unreachable${detail}`,\n );\n }\n if (this.now() >= deadline) {\n throw new SandboxError(\n `Error: all gondolin remote workers are at capacity (waited ${Math.round(this.queueWaitMs / 1000)}s)`,\n );\n }\n await this.sleep(this.queuePollMs);\n }\n }\n\n private workerFor(workerName: string | undefined): FleetWorker | undefined {\n if (!workerName) return undefined;\n return this.workers.get(workerName);\n }\n}\n\nexport const gondolinFleet = new GondolinFleetClient();\n"]}
@@ -0,0 +1,86 @@
1
+ import type { Server, Socket } from "node:net";
2
+ import type { GondolinGatewaySettings } from "../types.js";
3
+ /** What a worker announces when it dials home (mirrors the Go register frame). */
4
+ interface GondolinWorkerRegistration {
5
+ name: string;
6
+ os?: string;
7
+ arch?: string;
8
+ accelerator?: string;
9
+ cpus?: number;
10
+ memoryBytes?: number;
11
+ maxRuntimes?: number;
12
+ protocolVersion?: number;
13
+ runtimes?: Array<{
14
+ sessionId: string;
15
+ instanceId: string;
16
+ }>;
17
+ /** Non-empty when the worker's shared workspace failed its usability probe. */
18
+ workspaceError?: string;
19
+ }
20
+ interface GatewayOverrides {
21
+ /** Server factory (tests substitute a plain net.Server). */
22
+ createServer?: (onConnection: (socket: Socket) => void) => Server;
23
+ /** mTLS verification result for a socket (tests substitute outcomes). */
24
+ isAuthorized?: (socket: Socket) => boolean;
25
+ leaseTtlSeconds?: number;
26
+ rpcTimeoutMs?: number;
27
+ tunnelTimeoutMs?: number;
28
+ }
29
+ /**
30
+ * The host side of dial-home workers: one mTLS listener that accepts worker
31
+ * control channels (register/ping/RPC responses) and per-command dial-back
32
+ * tunnels, keeps the registry of connected workers, and attaches each one to
33
+ * the fleet as a regular worker connection. Placement, leases, fencing, and
34
+ * failover are unchanged — this only reverses who dials whom.
35
+ */
36
+ declare class GondolinWorkerGateway {
37
+ private settings?;
38
+ private overrides;
39
+ private server?;
40
+ private readonly workers;
41
+ private readonly pendingTunnels;
42
+ configure(settings?: GondolinGatewaySettings, overrides?: GatewayOverrides): void;
43
+ isConfigured(): boolean;
44
+ /** Registered workers and their liveness (admin/observability surface). */
45
+ list(): Array<{
46
+ name: string;
47
+ connected: boolean;
48
+ activeRuntimes: number;
49
+ workspaceError?: string;
50
+ info: GondolinWorkerRegistration;
51
+ }>;
52
+ /**
53
+ * Start the listener. Without explicit certificate settings the gateway
54
+ * provisions its own: a private worker CA plus a server certificate signed
55
+ * by it (required for join's CA pinning to also authenticate the host).
56
+ */
57
+ start(): Promise<void>;
58
+ stop(): void;
59
+ /** Routes one inbound connection by its first frame: control or tunnel. */
60
+ private handleConnection;
61
+ private acceptControlChannel;
62
+ private handleControlFrame;
63
+ /**
64
+ * Track shared-workspace health from register/ping frames and push it into
65
+ * the fleet, logging only the transitions. A worker whose NFS mount died
66
+ * keeps its control channel alive — this is what turns that silent state
67
+ * into refused placements and fail-fast execs.
68
+ */
69
+ private applyWorkspaceHealth;
70
+ /** RPC to a worker over its control channel (the reverse of HTTPS requests). */
71
+ private rpc;
72
+ private rejectPendingRpc;
73
+ /** Ask the worker to dial back a data connection for one session tunnel. */
74
+ private openTunnel;
75
+ /**
76
+ * One-time token → CA-signed client certificate. The only operation an
77
+ * unauthenticated connection may perform; the connection closes after the
78
+ * response either way.
79
+ */
80
+ private handleJoin;
81
+ private acceptTunnel;
82
+ private workerBySocket;
83
+ }
84
+ export declare const gondolinGateway: GondolinWorkerGateway;
85
+ export {};
86
+ //# sourceMappingURL=gondolin-gateway.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gondolin-gateway.d.ts","sourceRoot":"","sources":["../../src/sandbox/gondolin-gateway.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAI/C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,aAAa,CA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