@0xmaxma/claude-gateway 2.0.6 → 2.0.7

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 (364) hide show
  1. package/README.md +14 -1
  2. package/dist/agent/builtin-commands.js +5 -5
  3. package/dist/agent/builtin-commands.js.map +1 -1
  4. package/dist/agent/command-help.d.ts +9 -0
  5. package/dist/agent/command-help.d.ts.map +1 -0
  6. package/dist/agent/command-help.js +50 -0
  7. package/dist/agent/command-help.js.map +1 -0
  8. package/dist/agent/dreaming/index.d.ts +6 -3
  9. package/dist/agent/dreaming/index.d.ts.map +1 -1
  10. package/dist/agent/dreaming/index.js +21 -1
  11. package/dist/agent/dreaming/index.js.map +1 -1
  12. package/dist/agent/knowledge/reflection.d.ts +7 -4
  13. package/dist/agent/knowledge/reflection.d.ts.map +1 -1
  14. package/dist/agent/knowledge/reflection.js +19 -1
  15. package/dist/agent/knowledge/reflection.js.map +1 -1
  16. package/dist/agent/runner.d.ts +37 -3
  17. package/dist/agent/runner.d.ts.map +1 -1
  18. package/dist/agent/runner.js +164 -47
  19. package/dist/agent/runner.js.map +1 -1
  20. package/dist/agent/session-confirmations.d.ts +12 -0
  21. package/dist/agent/session-confirmations.d.ts.map +1 -0
  22. package/dist/agent/session-confirmations.js +43 -0
  23. package/dist/agent/session-confirmations.js.map +1 -0
  24. package/dist/agent/session-status.d.ts +7 -0
  25. package/dist/agent/session-status.d.ts.map +1 -0
  26. package/dist/agent/session-status.js +16 -0
  27. package/dist/agent/session-status.js.map +1 -0
  28. package/dist/agent/skill-learning/index.d.ts +5 -1
  29. package/dist/agent/skill-learning/index.d.ts.map +1 -1
  30. package/dist/agent/skill-learning/index.js +23 -1
  31. package/dist/agent/skill-learning/index.js.map +1 -1
  32. package/dist/agent/skill-learning/notifier.d.ts +2 -1
  33. package/dist/agent/skill-learning/notifier.d.ts.map +1 -1
  34. package/dist/agent/skill-learning/notifier.js +1 -0
  35. package/dist/agent/skill-learning/notifier.js.map +1 -1
  36. package/dist/api/apps-router.d.ts.map +1 -1
  37. package/dist/api/apps-router.js +1 -3
  38. package/dist/api/apps-router.js.map +1 -1
  39. package/dist/api/cron-router.d.ts +1 -1
  40. package/dist/api/cron-router.d.ts.map +1 -1
  41. package/dist/api/cron-router.js +4 -4
  42. package/dist/api/cron-router.js.map +1 -1
  43. package/dist/api/dashboard-processes.d.ts +86 -0
  44. package/dist/api/dashboard-processes.d.ts.map +1 -0
  45. package/dist/api/dashboard-processes.js +155 -0
  46. package/dist/api/dashboard-processes.js.map +1 -0
  47. package/dist/api/dashboard-sessions.d.ts +15 -0
  48. package/dist/api/dashboard-sessions.d.ts.map +1 -0
  49. package/dist/api/dashboard-sessions.js +66 -0
  50. package/dist/api/dashboard-sessions.js.map +1 -0
  51. package/dist/api/gateway-router.d.ts +3 -4
  52. package/dist/api/gateway-router.d.ts.map +1 -1
  53. package/dist/api/gateway-router.js +77 -56
  54. package/dist/api/gateway-router.js.map +1 -1
  55. package/dist/api/oauth-connectors-router.d.ts +1 -1
  56. package/dist/api/oauth-connectors-router.d.ts.map +1 -1
  57. package/dist/api/oauth-connectors-router.js +11 -21
  58. package/dist/api/oauth-connectors-router.js.map +1 -1
  59. package/dist/api/router.d.ts +1 -1
  60. package/dist/api/router.d.ts.map +1 -1
  61. package/dist/api/router.js +3 -9
  62. package/dist/api/router.js.map +1 -1
  63. package/dist/api/share-router.d.ts +1 -1
  64. package/dist/api/share-router.d.ts.map +1 -1
  65. package/dist/api/share-router.js +1 -1
  66. package/dist/api/share-router.js.map +1 -1
  67. package/dist/api/slack-webhook-router.js +1 -1
  68. package/dist/api/slack-webhook-router.js.map +1 -1
  69. package/dist/api/voice-router.d.ts +1 -0
  70. package/dist/api/voice-router.d.ts.map +1 -1
  71. package/dist/api/voice-router.js +7 -0
  72. package/dist/api/voice-router.js.map +1 -1
  73. package/dist/apps/agent-container-migration.d.ts +2 -0
  74. package/dist/apps/agent-container-migration.d.ts.map +1 -1
  75. package/dist/apps/agent-container-migration.js +59 -2
  76. package/dist/apps/agent-container-migration.js.map +1 -1
  77. package/dist/apps/agent-manager.d.ts +4 -2
  78. package/dist/apps/agent-manager.d.ts.map +1 -1
  79. package/dist/apps/agent-manager.js +39 -3
  80. package/dist/apps/agent-manager.js.map +1 -1
  81. package/dist/apps/installer.d.ts +4 -3
  82. package/dist/apps/installer.d.ts.map +1 -1
  83. package/dist/apps/installer.js +8 -4
  84. package/dist/apps/installer.js.map +1 -1
  85. package/dist/build-provenance.json +8 -0
  86. package/dist/cli/args.js +1 -1
  87. package/dist/cli/args.js.map +1 -1
  88. package/dist/cli/commands/app.d.ts.map +1 -1
  89. package/dist/cli/commands/app.js +39 -3
  90. package/dist/cli/commands/app.js.map +1 -1
  91. package/dist/cli/commands/doctor.d.ts.map +1 -1
  92. package/dist/cli/commands/doctor.js +6 -2
  93. package/dist/cli/commands/doctor.js.map +1 -1
  94. package/dist/cli/commands/safemode.d.ts +2 -0
  95. package/dist/cli/commands/safemode.d.ts.map +1 -0
  96. package/dist/cli/commands/safemode.js +279 -0
  97. package/dist/cli/commands/safemode.js.map +1 -0
  98. package/dist/cli/dependencies.d.ts +2 -0
  99. package/dist/cli/dependencies.d.ts.map +1 -1
  100. package/dist/cli/dependencies.js +81 -0
  101. package/dist/cli/dependencies.js.map +1 -1
  102. package/dist/cli/index.d.ts.map +1 -1
  103. package/dist/cli/index.js +11 -1
  104. package/dist/cli/index.js.map +1 -1
  105. package/dist/cli/manager.d.ts.map +1 -1
  106. package/dist/cli/manager.js +4 -1
  107. package/dist/cli/manager.js.map +1 -1
  108. package/dist/config/agent-lifecycle.d.ts +26 -0
  109. package/dist/config/agent-lifecycle.d.ts.map +1 -0
  110. package/dist/config/agent-lifecycle.js +63 -0
  111. package/dist/config/agent-lifecycle.js.map +1 -0
  112. package/dist/config/loader.d.ts.map +1 -1
  113. package/dist/config/loader.js +11 -0
  114. package/dist/config/loader.js.map +1 -1
  115. package/dist/config/reload-policy.d.ts +9 -0
  116. package/dist/config/reload-policy.d.ts.map +1 -0
  117. package/dist/config/reload-policy.js +62 -0
  118. package/dist/config/reload-policy.js.map +1 -0
  119. package/dist/config/watcher.d.ts +3 -2
  120. package/dist/config/watcher.d.ts.map +1 -1
  121. package/dist/config/watcher.js +34 -51
  122. package/dist/config/watcher.js.map +1 -1
  123. package/dist/cron/tool-schemas.d.ts +296 -0
  124. package/dist/cron/tool-schemas.d.ts.map +1 -0
  125. package/dist/cron/tool-schemas.js +122 -0
  126. package/dist/cron/tool-schemas.js.map +1 -0
  127. package/dist/index.js +141 -158
  128. package/dist/index.js.map +1 -1
  129. package/dist/orchestration/agent-tool-schemas.js +4 -4
  130. package/dist/orchestration/agent-tool-schemas.js.map +1 -1
  131. package/dist/orchestration/background-work.d.ts +9 -0
  132. package/dist/orchestration/background-work.d.ts.map +1 -0
  133. package/dist/orchestration/background-work.js +49 -0
  134. package/dist/orchestration/background-work.js.map +1 -0
  135. package/dist/orchestration/bridge.d.ts +6 -15
  136. package/dist/orchestration/bridge.d.ts.map +1 -1
  137. package/dist/orchestration/bridge.js +67 -32
  138. package/dist/orchestration/bridge.js.map +1 -1
  139. package/dist/orchestration/capabilities.d.ts.map +1 -1
  140. package/dist/orchestration/capabilities.js +18 -10
  141. package/dist/orchestration/capabilities.js.map +1 -1
  142. package/dist/orchestration/capacity.d.ts +3 -2
  143. package/dist/orchestration/capacity.d.ts.map +1 -1
  144. package/dist/orchestration/capacity.js +7 -0
  145. package/dist/orchestration/capacity.js.map +1 -1
  146. package/dist/orchestration/channel-controls.d.ts.map +1 -1
  147. package/dist/orchestration/channel-controls.js +3 -2
  148. package/dist/orchestration/channel-controls.js.map +1 -1
  149. package/dist/orchestration/cli-skills.d.ts +5 -0
  150. package/dist/orchestration/cli-skills.d.ts.map +1 -1
  151. package/dist/orchestration/container-tool-schemas.d.ts +37 -0
  152. package/dist/orchestration/container-tool-schemas.d.ts.map +1 -0
  153. package/dist/orchestration/container-tool-schemas.js +27 -0
  154. package/dist/orchestration/container-tool-schemas.js.map +1 -0
  155. package/dist/orchestration/container.d.ts.map +1 -1
  156. package/dist/orchestration/container.js +7 -0
  157. package/dist/orchestration/container.js.map +1 -1
  158. package/dist/orchestration/dashboard-reader-worker.js +7 -7
  159. package/dist/orchestration/dashboard-reader-worker.js.map +1 -1
  160. package/dist/orchestration/decision-context.js +1 -1
  161. package/dist/orchestration/decision-context.js.map +1 -1
  162. package/dist/orchestration/gateway-tasks/controller.d.ts +29 -0
  163. package/dist/orchestration/gateway-tasks/controller.d.ts.map +1 -0
  164. package/dist/orchestration/gateway-tasks/controller.js +139 -0
  165. package/dist/orchestration/gateway-tasks/controller.js.map +1 -0
  166. package/dist/orchestration/gateway-tasks/safemode.d.ts +19 -0
  167. package/dist/orchestration/gateway-tasks/safemode.d.ts.map +1 -0
  168. package/dist/orchestration/gateway-tasks/safemode.js +128 -0
  169. package/dist/orchestration/gateway-tasks/safemode.js.map +1 -0
  170. package/dist/orchestration/process-turn.d.ts +11 -2
  171. package/dist/orchestration/process-turn.d.ts.map +1 -1
  172. package/dist/orchestration/process-turn.js +47 -7
  173. package/dist/orchestration/process-turn.js.map +1 -1
  174. package/dist/orchestration/recovery.d.ts.map +1 -1
  175. package/dist/orchestration/recovery.js +4 -2
  176. package/dist/orchestration/recovery.js.map +1 -1
  177. package/dist/orchestration/runtime.d.ts +10 -0
  178. package/dist/orchestration/runtime.d.ts.map +1 -1
  179. package/dist/orchestration/runtime.js +31 -4
  180. package/dist/orchestration/runtime.js.map +1 -1
  181. package/dist/orchestration/skills.d.ts +2 -0
  182. package/dist/orchestration/skills.d.ts.map +1 -1
  183. package/dist/orchestration/skills.js +4 -3
  184. package/dist/orchestration/skills.js.map +1 -1
  185. package/dist/orchestration/task-controls.d.ts +12 -0
  186. package/dist/orchestration/task-controls.d.ts.map +1 -1
  187. package/dist/orchestration/task-controls.js +3 -1
  188. package/dist/orchestration/task-controls.js.map +1 -1
  189. package/dist/orchestration/tasks/driver.d.ts.map +1 -1
  190. package/dist/orchestration/tasks/driver.js +99 -12
  191. package/dist/orchestration/tasks/driver.js.map +1 -1
  192. package/dist/orchestration/tasks/pool.d.ts +2 -0
  193. package/dist/orchestration/tasks/pool.d.ts.map +1 -1
  194. package/dist/orchestration/tasks/pool.js +4 -0
  195. package/dist/orchestration/tasks/pool.js.map +1 -1
  196. package/dist/orchestration/tasks/scheduler.d.ts.map +1 -1
  197. package/dist/orchestration/tasks/scheduler.js +4 -0
  198. package/dist/orchestration/tasks/scheduler.js.map +1 -1
  199. package/dist/orchestration/tasks/service.d.ts +4 -0
  200. package/dist/orchestration/tasks/service.d.ts.map +1 -1
  201. package/dist/orchestration/tasks/service.js +38 -8
  202. package/dist/orchestration/tasks/service.js.map +1 -1
  203. package/dist/orchestration/token-ledger.d.ts +1 -0
  204. package/dist/orchestration/token-ledger.d.ts.map +1 -1
  205. package/dist/orchestration/token-ledger.js +6 -2
  206. package/dist/orchestration/token-ledger.js.map +1 -1
  207. package/dist/orchestration/token-usage.d.ts +3 -0
  208. package/dist/orchestration/token-usage.d.ts.map +1 -1
  209. package/dist/orchestration/token-usage.js +12 -3
  210. package/dist/orchestration/token-usage.js.map +1 -1
  211. package/dist/orchestration/types.d.ts +19 -1
  212. package/dist/orchestration/types.d.ts.map +1 -1
  213. package/dist/orchestration/types.js.map +1 -1
  214. package/dist/orchestration/worker-crons.d.ts +5 -0
  215. package/dist/orchestration/worker-crons.d.ts.map +1 -0
  216. package/dist/orchestration/worker-crons.js +84 -0
  217. package/dist/orchestration/worker-crons.js.map +1 -0
  218. package/dist/orchestration/worker-harness.d.ts +15 -0
  219. package/dist/orchestration/worker-harness.d.ts.map +1 -0
  220. package/dist/orchestration/worker-harness.js +72 -0
  221. package/dist/orchestration/worker-harness.js.map +1 -0
  222. package/dist/safemode/config.d.ts +7 -0
  223. package/dist/safemode/config.d.ts.map +1 -0
  224. package/dist/safemode/config.js +67 -0
  225. package/dist/safemode/config.js.map +1 -0
  226. package/dist/safemode/context.d.ts +7 -0
  227. package/dist/safemode/context.d.ts.map +1 -0
  228. package/dist/safemode/context.js +397 -0
  229. package/dist/safemode/context.js.map +1 -0
  230. package/dist/safemode/external-owners.d.ts +19 -0
  231. package/dist/safemode/external-owners.d.ts.map +1 -0
  232. package/dist/safemode/external-owners.js +229 -0
  233. package/dist/safemode/external-owners.js.map +1 -0
  234. package/dist/safemode/native.d.ts +38 -0
  235. package/dist/safemode/native.d.ts.map +1 -0
  236. package/dist/safemode/native.js +220 -0
  237. package/dist/safemode/native.js.map +1 -0
  238. package/dist/safemode/params.d.ts +10 -0
  239. package/dist/safemode/params.d.ts.map +1 -0
  240. package/dist/safemode/params.js +86 -0
  241. package/dist/safemode/params.js.map +1 -0
  242. package/dist/safemode/provenance.d.ts +45 -0
  243. package/dist/safemode/provenance.d.ts.map +1 -0
  244. package/dist/safemode/provenance.js +153 -0
  245. package/dist/safemode/provenance.js.map +1 -0
  246. package/dist/safemode/runner.d.ts +17 -0
  247. package/dist/safemode/runner.d.ts.map +1 -0
  248. package/dist/safemode/runner.js +398 -0
  249. package/dist/safemode/runner.js.map +1 -0
  250. package/dist/safemode/store.d.ts +56 -0
  251. package/dist/safemode/store.d.ts.map +1 -0
  252. package/dist/safemode/store.js +451 -0
  253. package/dist/safemode/store.js.map +1 -0
  254. package/dist/session/codex-auth.d.ts +37 -0
  255. package/dist/session/codex-auth.d.ts.map +1 -0
  256. package/dist/session/codex-auth.js +266 -0
  257. package/dist/session/codex-auth.js.map +1 -0
  258. package/dist/session/codex-container-runtime.d.ts +15 -0
  259. package/dist/session/codex-container-runtime.d.ts.map +1 -0
  260. package/dist/session/codex-container-runtime.js +85 -0
  261. package/dist/session/codex-container-runtime.js.map +1 -0
  262. package/dist/session/codex-context-defaults.json +5 -0
  263. package/dist/session/codex-context.d.ts +13 -0
  264. package/dist/session/codex-context.d.ts.map +1 -0
  265. package/dist/session/codex-context.js +27 -0
  266. package/dist/session/codex-context.js.map +1 -0
  267. package/dist/session/codex-extension-discovery.d.ts +21 -0
  268. package/dist/session/codex-extension-discovery.d.ts.map +1 -0
  269. package/dist/session/codex-extension-discovery.js +132 -0
  270. package/dist/session/codex-extension-discovery.js.map +1 -0
  271. package/dist/session/codex-native-mcp-client.d.ts +37 -0
  272. package/dist/session/codex-native-mcp-client.d.ts.map +1 -0
  273. package/dist/session/codex-native-mcp-client.js +164 -0
  274. package/dist/session/codex-native-mcp-client.js.map +1 -0
  275. package/dist/session/codex-policy.d.ts +6 -0
  276. package/dist/session/codex-policy.d.ts.map +1 -0
  277. package/dist/session/codex-policy.js +17 -0
  278. package/dist/session/codex-policy.js.map +1 -0
  279. package/dist/session/codex-process.d.ts +114 -0
  280. package/dist/session/codex-process.d.ts.map +1 -0
  281. package/dist/session/codex-process.js +759 -0
  282. package/dist/session/codex-process.js.map +1 -0
  283. package/dist/session/codex-runtime.d.ts +20 -0
  284. package/dist/session/codex-runtime.d.ts.map +1 -0
  285. package/dist/session/codex-runtime.js +182 -0
  286. package/dist/session/codex-runtime.js.map +1 -0
  287. package/dist/session/codex-tool-capture.d.ts +35 -0
  288. package/dist/session/codex-tool-capture.d.ts.map +1 -0
  289. package/dist/session/codex-tool-capture.js +178 -0
  290. package/dist/session/codex-tool-capture.js.map +1 -0
  291. package/dist/session/container-connectors.d.ts +10 -0
  292. package/dist/session/container-connectors.d.ts.map +1 -0
  293. package/dist/session/container-connectors.js +41 -0
  294. package/dist/session/container-connectors.js.map +1 -0
  295. package/dist/session/container-extensions.d.ts +4 -0
  296. package/dist/session/container-extensions.d.ts.map +1 -0
  297. package/dist/session/container-extensions.js +45 -0
  298. package/dist/session/container-extensions.js.map +1 -0
  299. package/dist/session/managed-connectors.d.ts +16 -0
  300. package/dist/session/managed-connectors.d.ts.map +1 -0
  301. package/dist/session/managed-connectors.js +25 -0
  302. package/dist/session/managed-connectors.js.map +1 -0
  303. package/dist/session/process-diagnostics.d.ts +14 -0
  304. package/dist/session/process-diagnostics.d.ts.map +1 -0
  305. package/dist/session/process-diagnostics.js +39 -0
  306. package/dist/session/process-diagnostics.js.map +1 -0
  307. package/dist/session/process.d.ts +4 -0
  308. package/dist/session/process.d.ts.map +1 -1
  309. package/dist/session/process.js +21 -16
  310. package/dist/session/process.js.map +1 -1
  311. package/dist/session/request-tool-capture.d.ts +1 -1
  312. package/dist/session/request-tool-capture.d.ts.map +1 -1
  313. package/dist/session/runtime-profile.d.ts +8 -0
  314. package/dist/session/runtime-profile.d.ts.map +1 -1
  315. package/dist/session/runtime-profile.js +3 -2
  316. package/dist/session/runtime-profile.js.map +1 -1
  317. package/dist/session/worker-environment.d.ts +5 -0
  318. package/dist/session/worker-environment.d.ts.map +1 -0
  319. package/dist/session/worker-environment.js +27 -0
  320. package/dist/session/worker-environment.js.map +1 -0
  321. package/dist/session/worker-extensions.d.ts +20 -0
  322. package/dist/session/worker-extensions.d.ts.map +1 -0
  323. package/dist/session/worker-extensions.js +322 -0
  324. package/dist/session/worker-extensions.js.map +1 -0
  325. package/dist/skills/loader.d.ts +2 -0
  326. package/dist/skills/loader.d.ts.map +1 -1
  327. package/dist/skills/loader.js.map +1 -1
  328. package/dist/types.d.ts +30 -0
  329. package/dist/types.d.ts.map +1 -1
  330. package/dist/ui/codex-context.d.ts +4 -0
  331. package/dist/ui/codex-context.d.ts.map +1 -0
  332. package/dist/ui/codex-context.js +15 -0
  333. package/dist/ui/codex-context.js.map +1 -0
  334. package/dist/ui/dashboard-client.d.ts.map +1 -1
  335. package/dist/ui/dashboard-client.js +14 -11
  336. package/dist/ui/dashboard-client.js.map +1 -1
  337. package/dist/ui/dashboard-presentation.d.ts +1 -1
  338. package/dist/ui/dashboard-presentation.d.ts.map +1 -1
  339. package/dist/ui/dashboard-presentation.js +2 -2
  340. package/dist/ui/dashboard-presentation.js.map +1 -1
  341. package/dist/ui/token-report.d.ts +3 -0
  342. package/dist/ui/token-report.d.ts.map +1 -1
  343. package/dist/ui/token-report.js +22 -10
  344. package/dist/ui/token-report.js.map +1 -1
  345. package/dist/ui/web-ui.d.ts.map +1 -1
  346. package/dist/ui/web-ui.js +53 -132
  347. package/dist/ui/web-ui.js.map +1 -1
  348. package/mcp/capability-catalog.ts +2 -0
  349. package/mcp/extension-catalog.ts +18 -0
  350. package/mcp/lazy-connector.ts +4 -2
  351. package/mcp/lazy-tools.test.ts +29 -0
  352. package/mcp/modules.ts +1 -0
  353. package/mcp/server.ts +2 -2
  354. package/mcp/tools/cron/module.ts +8 -114
  355. package/mcp/tools/discord/commands.ts +4 -1
  356. package/mcp/tools/safemode/module.test.ts +29 -0
  357. package/mcp/tools/telegram/receiver-server.ts +2 -22
  358. package/mcp/tools/telegram/task-detail.ts +2 -1
  359. package/package.json +3 -2
  360. package/scripts/orchestration/audit-codex-context.cjs +83 -0
  361. package/scripts/orchestration/benchmark-worker-harnesses.cjs +112 -0
  362. package/scripts/orchestration/smoke-codex-extensions.ts +29 -0
  363. package/scripts/orchestration/smoke-codex-worker.cjs +166 -0
  364. package/scripts/orchestration/smoke-safemode-codex.cjs +66 -0
@@ -11,12 +11,14 @@ function recoverOrchestration(store) {
11
11
  store.run("UPDATE assistant_responses SET state='interrupted',completed_at=? WHERE state='generating'", now);
12
12
  const inputs = Number(store.run("UPDATE conversation_inputs SET status='accepted' WHERE status='assigned'").changes);
13
13
  store.run("UPDATE notifications SET status='pending',decision_id=NULL WHERE status='assigned'");
14
+ let uncertainTasks = 0;
14
15
  const rows = store.all('SELECT snapshot_json FROM tasks WHERE active_attempt_id IS NOT NULL');
15
16
  for (const row of rows) {
16
17
  const task = JSON.parse(String(row.snapshot_json));
17
- if (task.state === 'needs_reconciliation')
18
+ if (task.state === 'needs_reconciliation' || task.gatewayTarget)
18
19
  continue;
19
20
  const attempt = store.attempt(task.activeAttemptId);
21
+ uncertainTasks++;
20
22
  attempt.state = 'unknown';
21
23
  task.state = 'needs_reconciliation';
22
24
  task.latestProgress = { source: 'runtime', observedAt: now, text: 'Gateway restarted; process liveness and side effects require reconciliation.' };
@@ -29,7 +31,7 @@ function recoverOrchestration(store) {
29
31
  store.run("UPDATE deliveries SET state='unknown',updated_at=? WHERE state='sending'", now);
30
32
  store.run("UPDATE task_resources SET lifecycle_state='cleanup_unknown' WHERE lifecycle_state='archiving'");
31
33
  store.run("UPDATE outbox SET state='pending',lease_owner=NULL,lease_expires_at=NULL WHERE state='processing' AND kind!='delivery'");
32
- return { inputs, uncertainTasks: rows.length };
34
+ return { inputs, uncertainTasks };
33
35
  });
34
36
  }
35
37
  //# sourceMappingURL=recovery.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"recovery.js","sourceRoot":"","sources":["../../src/orchestration/recovery.ts"],"names":[],"mappings":";;AAKA,oDAyBC;AA3BD;iFACiF;AACjF,SAAgB,oBAAoB,CAAC,KAAyB;IAC5D,OAAO,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,KAAK,CAAC,GAAG,CAAC,mJAAmJ,CAAC,CAAC;QAC/J,KAAK,CAAC,GAAG,CAAC,4GAA4G,EAAE,GAAG,CAAC,CAAC;QAC7H,KAAK,CAAC,GAAG,CAAC,4FAA4F,EAAE,GAAG,CAAC,CAAC;QAC7G,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,0EAA0E,CAAC,CAAC,OAAO,CAAC,CAAC;QACrH,KAAK,CAAC,GAAG,CAAC,oFAAoF,CAAC,CAAC;QAChG,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,qEAAqE,CAAC,CAAC;QAC9F,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAiB,CAAC;YACnE,IAAI,IAAI,CAAC,KAAK,KAAK,sBAAsB;gBAAE,SAAS;YACpD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,eA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ery;
55
55
  private readonly scheduler;
56
+ private gatewayTasks?;
56
57
  private nextQuestionCheck;
57
58
  private readonly scheduledReports;
58
59
  private readonly seenSessions;
@@ -136,6 +137,8 @@ export declare class AgentOrchestrationRuntime {
136
137
  compactSession(sessionId: string, model?: string): Promise<CompactMeasurements | null>;
137
138
  private compactionMaintenance;
138
139
  runSessionCompaction(config: ResolvedSessionCompaction, window: (model: string) => Promise<number>): Promise<import("./session-compaction").CompactionRun>;
140
+ /** Lightweight live ownership only: no transcript or token-ledger scans. */
141
+ processOwners(): import('../api/dashboard-processes').ProcessOwner[];
139
142
  sessionContextWindow(sessionId: string): {
140
143
  used: number;
141
144
  total: number | null;
@@ -209,6 +212,8 @@ export declare class AgentOrchestrationRuntime {
209
212
  sessionId: string | number | null;
210
213
  state: string | number | null;
211
214
  title: any;
215
+ executionType: string;
216
+ gatewayTarget: any;
212
217
  execution: any;
213
218
  workerId: string | undefined;
214
219
  workstreamId: any;
@@ -216,6 +221,7 @@ export declare class AgentOrchestrationRuntime {
216
221
  resumed: boolean | undefined;
217
222
  attemptId: string | undefined;
218
223
  workerSessionId: string | undefined;
224
+ targetSessionId: any;
219
225
  hostProcessId: number | undefined;
220
226
  container: string | undefined;
221
227
  lastTool: {
@@ -250,6 +256,8 @@ export declare class AgentOrchestrationRuntime {
250
256
  sessionId: string | number | null;
251
257
  state: string | number | null;
252
258
  title: any;
259
+ executionType: string;
260
+ gatewayTarget: any;
253
261
  execution: any;
254
262
  workerId: string | undefined;
255
263
  workstreamId: any;
@@ -257,6 +265,7 @@ export declare class AgentOrchestrationRuntime {
257
265
  resumed: boolean | undefined;
258
266
  attemptId: string | undefined;
259
267
  workerSessionId: string | undefined;
268
+ targetSessionId: any;
260
269
  hostProcessId: number | undefined;
261
270
  container: string | undefined;
262
271
  lastTool: {
@@ -311,6 +320,7 @@ export declare class AgentOrchestrationRuntime {
311
320
  private run;
312
321
  stopResponse(sessionId: string, reason?: 'user' | 'barge-in'): boolean;
313
322
  flushHistory(): Promise<void>;
323
+ hasPendingWork(): boolean;
314
324
  drain(): void;
315
325
  canReturnToLegacy(): boolean;
316
326
  close(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/orchestration/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC3F,OAAO,EAA+C,KAAK,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACnH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAMrD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAejD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAE,kBAAkB,EAAgC,MAAM,uBAAuB,CAAC;AAOzF,OAAO,EAAgB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAA2B,MAAM,gBAAgB,CAAC;AAK9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAO/C,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAgC,MAAM,SAAS,CAAC;AAExF,OAAO,EAAE,WAAW,EAAkB,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EA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controller_1 = require("./gateway-tasks/controller");
5
+ const safemode_1 = require("./gateway-tasks/safemode");
6
+ const worker_crons_1 = require("./worker-crons");
4
7
  const compact_measurements_1 = require("./compact-measurements");
5
8
  const session_compaction_1 = require("./session-compaction");
6
9
  const context_delivery_1 = require("./context-delivery");
@@ -72,6 +75,7 @@ const task_files_1 = require("./task-files");
72
75
  const worker_shares_1 = require("./worker-shares");
73
76
  /** Stable instructions are carried in the system prefix, not appended to every
74
77
  * resumed user turn. Per-turn authorization flags remain explicit below it. */
78
+ const GATEWAY_TASK_INSTRUCTIONS = 'For safemode discovery use capabilities_list(scope=safemode); this creates no task. For authorized work on a discovered session use task_spawn(target_profile=gateway-managed, gateway_target={adapter:safemode,session_id:...}). Gateway-managed tasks are followed by the gateway and report results automatically; never spawn a polling worker.';
75
79
  const CONTEXT_DELIVERY_INSTRUCTIONS = 'Worker profiles: default-worker is the general-purpose worker for research, files, browser/API operations, services, calculations and code. In host mode it uses the Agent working environment; no Git or projectRoot is required. In container mode it stays inside the app container. Only explicitly configured isolated-worktree mode requires Git for default-worker; media-worker remains available for standalone scratch work in isolated modes. State the authorized working directory in task instructions; workers may change directories only within their execution boundary. Serialize conflicting edits to the same shared files; continue related work with continue_task_id. Task context is incremental within a resumed CLI conversation. Omission means unchanged, not deleted. On a fresh context only active/waiting tasks and current reports are bootstrapped; use task_status for other past work or full results. Receipt recovery is evidence, not authorization to replay a command. Previously supplied materials remain in the resumed context; preserve their references when assigning workers. Never infer that missing image bytes mean a missing attachment if its ref was already supplied.';
76
80
  class AgentOrchestrationRuntime {
77
81
  setBrowserVoice(sessionId, principalId, enabled) {
@@ -184,7 +188,9 @@ class AgentOrchestrationRuntime {
184
188
  }
185
189
  const tasks = new service_1.TaskService(store, agent.orchestration, agent.workspace);
186
190
  const files = new task_files_1.TaskFiles(store, (0, path_1.join)(agent.workspace, '../..'), agent.type === 'app-agent' ? (0, path_1.join)(root, 'container-files') : undefined, agent.workspace);
187
- const bridge = new bridge_1.TaskBridge(tasks, files, (0, worker_shares_1.workerShares)(files, agent, gateway), host.skills ? () => host.skills() : undefined, agent.type === 'app-agent' ? { agent, spool: (0, path_1.join)(root, 'container-files') } : undefined);
191
+ const safemodeAllowed = () => agent.type !== 'app-agent' && Boolean(gateway.safemode?.allowedAgentIds?.includes(agent.id));
192
+ const gatewayAdapters = new Map(agent.type === 'app-agent' ? [] : [['safemode', new safemode_1.SafemodeTaskAdapter(agent.id, safemodeAllowed)]]);
193
+ const bridge = new bridge_1.TaskBridge(tasks, files, (0, worker_shares_1.workerShares)(files, agent, gateway), host.skills ? () => host.skills() : undefined, agent.type === 'app-agent' ? { agent, spool: (0, path_1.join)(root, 'container-files') } : undefined, (0, worker_crons_1.workerCrons)(files, agent, gateway), gatewayAdapters);
188
194
  const personalRetention = (0, config_1.resolveDreamingConfig)(agent.dreaming, gateway.gateway.dreaming, gateway.gateway.timezone).staleness;
189
195
  const sharedRetention = (0, knowledge_1.resolveSharedConfig)(agent.knowledge?.shared, gateway.gateway.knowledge?.shared).staleness;
190
196
  bridge.recordRetrievals = (personalRetention.enabled && personalRetention.recordRetrievals) || (sharedRetention.enabled && sharedRetention.recordRetrievals);
@@ -195,6 +201,8 @@ class AgentOrchestrationRuntime {
195
201
  // their global capacity conservatively as well as the per-agent slots.
196
202
  const recoveredReservations = new Map();
197
203
  for (const row of store.all("SELECT id FROM tasks WHERE state='needs_reconciliation' AND active_attempt_id IS NOT NULL")) {
204
+ if (store.task(String(row.id))?.gatewayTarget)
205
+ continue;
198
206
  recoveredReservations.set(String(row.id), (0, capacity_1.gatewayCapacity)(gateway).acquireWorker(agent.id, String(row.id), false));
199
207
  }
200
208
  if (agent.orchestration?.enabled)
@@ -222,6 +230,8 @@ class AgentOrchestrationRuntime {
222
230
  runtime.drain();
223
231
  await runtime.flushHistory();
224
232
  scheduler.start();
233
+ runtime.gatewayTasks = new controller_1.GatewayTaskController(tasks, gatewayAdapters);
234
+ runtime.gatewayTasks.start();
225
235
  runtime.mailboxTimer = setInterval(() => {
226
236
  try {
227
237
  runtime.pumpMailbox();
@@ -423,6 +433,18 @@ class AgentOrchestrationRuntime {
423
433
  void operation.finally(() => this.pending.delete(operation)).catch(() => { });
424
434
  return operation;
425
435
  }
436
+ /** Lightweight live ownership only: no transcript or token-ledger scans. */
437
+ processOwners() {
438
+ return this.store.all(`SELECT t.snapshot_json,a.payload_json FROM tasks t JOIN task_attempts a
439
+ ON a.id=t.active_attempt_id WHERE t.active_attempt_id IS NOT NULL`).flatMap(row => {
440
+ const task = JSON.parse(String(row.snapshot_json)), attempt = JSON.parse(String(row.payload_json));
441
+ const pid = attempt.processIdentity?.pid;
442
+ return Number.isInteger(pid) ? [{ pid, startTicks: attempt.processIdentity?.startTicks, group: 'worker', agentId: this.agent.id,
443
+ sessionId: task.agentSessionId, taskId: task.taskId, title: task.title,
444
+ harness: attempt.harness ?? 'claude', model: attempt.harnessModel ?? task.model,
445
+ container: this.agent.type === 'app-agent' ? this.agent.container : undefined }] : [];
446
+ });
447
+ }
426
448
  sessionContextWindow(sessionId) {
427
449
  if (!this.store.get("SELECT name FROM sqlite_master WHERE name='token_turns'"))
428
450
  return null;
@@ -447,8 +469,8 @@ class AgentOrchestrationRuntime {
447
469
  const tool = event ? JSON.parse(String(event.payload_json)).payload : undefined;
448
470
  const measured = (0, token_ledger_1.summarizeTokenTurns)((0, token_ledger_1.measuredTurns)(this.store, String(row.agent_session_id)).filter(turn => turn.id === attempt?.attemptId));
449
471
  return { tokenSummary: { totalTokens: measured.totalTokens }, contextTools: measured.contextTools, loadedTools: measured.loadedTools, usedTools: measured.usedTools, taskId: row.id, sessionId: row.agent_session_id, state: row.state, title: snapshot.title,
450
- execution: snapshot.execution, workerId: attempt?.workerId, workstreamId: snapshot.workstreamId, continueTaskId: snapshot.continueTaskId, resumed: attempt?.resumeSession,
451
- attemptId: attempt?.attemptId, workerSessionId: attempt?.sessionId, hostProcessId: row.active_attempt_id ? attempt?.processIdentity?.pid : undefined,
472
+ executionType: snapshot.gatewayTarget ? 'gateway-managed' : 'worker', gatewayTarget: snapshot.gatewayTarget, execution: snapshot.execution, workerId: attempt?.workerId, workstreamId: snapshot.workstreamId, continueTaskId: snapshot.continueTaskId, resumed: attempt?.resumeSession,
473
+ attemptId: attempt?.attemptId, workerSessionId: snapshot.gatewayTarget ? undefined : attempt?.sessionId, targetSessionId: snapshot.gatewayTarget?.sessionId, hostProcessId: row.active_attempt_id ? attempt?.processIdentity?.pid : undefined,
452
474
  container: this.agent.type === 'app-agent' ? this.agent.container : undefined,
453
475
  lastTool: tool ? { name: tool.name, type: tool.type, is_error: tool.is_error } : undefined };
454
476
  });
@@ -1106,7 +1128,7 @@ class AgentOrchestrationRuntime {
1106
1128
  // produced, while speech and review turns fill the optional fields their per-turn overlay
1107
1129
  // asks for. This restores the structured-output guarantee without a per-turn tools diff.
1108
1130
  ticket.profile.responseSchema = response_schema_1.ORCHESTRATION_RESPONSE_SCHEMA;
1109
- ticket.profile.overlay += `\n\n${CONTEXT_DELIVERY_INSTRUCTIONS}\n\nOnly when the current turn explicitly enables semantic intake, apply these rules:\n${conversation_intake_1.INTAKE_OVERLAY}`;
1131
+ ticket.profile.overlay += `\n\n${CONTEXT_DELIVERY_INSTRUCTIONS}${this.agent.type !== 'app-agent' && this.gateway.safemode?.allowedAgentIds?.includes(this.agent.id) ? '\n' + GATEWAY_TASK_INSTRUCTIONS : ''}\n\nOnly when the current turn explicitly enables semantic intake, apply these rules:\n${conversation_intake_1.INTAKE_OVERLAY}`;
1110
1132
  // Continue the CLI session this agent session already has a transcript for. Each decision
1111
1133
  // turn is still its own process; resuming is what lets the next one reuse the previous
1112
1134
  // turn's cached prefix instead of paying a full cache write, and it replaces the flattened
@@ -1129,6 +1151,7 @@ class AgentOrchestrationRuntime {
1129
1151
  ticket.profile.excludedHistoryOperationIds = this.store.all(`SELECT r.id FROM assistant_responses r
1130
1152
  JOIN conversation_decisions d ON d.id=r.decision_id WHERE d.session_id=? AND r.state='failed'`, sessionId)
1131
1153
  .map(row => `response:${row.id}`);
1154
+ ticket.profile.responseId = decision.responseId;
1132
1155
  agentSession = await this.host.createAgentSession(sessionId, ticket.profile, options.model, input.scope);
1133
1156
  const reportingTasks = new Set(this.store.all("SELECT task_id FROM notifications WHERE decision_id=? AND status='assigned'", decision.decisionId).map(row => String(row.task_id)));
1134
1157
  const taskCandidates = this.tasks.context(receipt.conversationId, input.scope.principalId, decision.decisionId)
@@ -1410,6 +1433,9 @@ class AgentOrchestrationRuntime {
1410
1433
  for (const row of this.store.all("SELECT operation_id FROM history_operations WHERE state='pending' ORDER BY updated_at LIMIT 200"))
1411
1434
  await this.history.write(String(row.operation_id));
1412
1435
  }
1436
+ hasPendingWork() {
1437
+ return !!(this.active.size || this.pending.size || this.store.get("SELECT id FROM conversation_inputs WHERE status IN ('accepted','assigned') LIMIT 1") || this.store.get("SELECT id FROM tasks WHERE state NOT IN ('completed','failed','cancelled') LIMIT 1"));
1438
+ }
1413
1439
  drain() {
1414
1440
  this.draining = true;
1415
1441
  this.store.run("UPDATE conversations SET status='draining' WHERE status='active'");
@@ -1437,6 +1463,7 @@ class AgentOrchestrationRuntime {
1437
1463
  this.drain();
1438
1464
  for (const sessionId of this.active.keys())
1439
1465
  this.stopResponse(sessionId);
1466
+ await this.gatewayTasks?.close();
1440
1467
  await this.scheduler.close();
1441
1468
  await this.settleResources();
1442
1469
  await Promise.allSettled([...this.pending]);