@cortex-agent/server 2026.5.25 → 2026.6.15

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 (395) hide show
  1. package/defaults/config/thread-templates.json +28 -1
  2. package/defaults/hooks/cortex-md-injector.mjs +47 -31
  3. package/defaults/hooks/post-task-hook.mjs +6 -0
  4. package/defaults/hooks/task-status-check.mjs +8 -0
  5. package/defaults/mcp-config-slack.json +11 -0
  6. package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +18 -0
  7. package/defaults/plugins/cortex-system/skills/schedule/SKILL.md +5 -6
  8. package/defaults/prompts/directives/manager.md +67 -0
  9. package/dist/agent-adapter/claude/adapter-tui.d.ts +35 -3
  10. package/dist/agent-adapter/claude/adapter-tui.js +91 -12
  11. package/dist/agent-adapter/claude/adapter.js +11 -0
  12. package/dist/agent-adapter/claude/defaults.d.ts +30 -0
  13. package/dist/agent-adapter/claude/defaults.js +30 -0
  14. package/dist/agent-adapter/claude/jsonl-tail.d.ts +2 -2
  15. package/dist/agent-adapter/claude/jsonl-tail.js +25 -20
  16. package/dist/agent-adapter/claude/spawn-args.d.ts +11 -0
  17. package/dist/agent-adapter/claude/spawn-args.js +49 -7
  18. package/dist/agent-adapter/claude/tmux-control.d.ts +20 -0
  19. package/dist/agent-adapter/claude/tmux-control.js +54 -8
  20. package/dist/agent-adapter/codex/adapter.js +1 -1
  21. package/dist/agent-adapter/normalize/event-types.d.ts +1 -0
  22. package/dist/agent-adapter/pi/adapter.js +46 -19
  23. package/dist/agent-adapter/pi/agent-dir.d.ts +21 -0
  24. package/dist/agent-adapter/pi/agent-dir.js +53 -2
  25. package/dist/agent-adapter/pi/event-parser.js +13 -1
  26. package/dist/agent-adapter/pi/mcp-bridge.d.ts +12 -0
  27. package/dist/agent-adapter/pi/mcp-bridge.js +47 -9
  28. package/dist/agent-adapter/pi/tool-shims.d.ts +14 -0
  29. package/dist/agent-adapter/pi/tool-shims.js +167 -140
  30. package/dist/agent-adapter/types.d.ts +7 -2
  31. package/dist/core/atomic-write.js +21 -0
  32. package/dist/core/config-generator.d.ts +10 -0
  33. package/dist/core/config-generator.js +28 -0
  34. package/dist/core/gateway-generator.d.ts +77 -7
  35. package/dist/core/gateway-generator.js +323 -30
  36. package/dist/core/i18n.d.ts +19 -0
  37. package/dist/core/i18n.js +46 -0
  38. package/dist/core/icons.d.ts +68 -0
  39. package/dist/core/icons.js +67 -0
  40. package/dist/core/locales/en.d.ts +438 -0
  41. package/dist/core/locales/en.js +24 -0
  42. package/dist/core/locales/slices/commands.d.ts +214 -0
  43. package/dist/core/locales/slices/commands.js +462 -0
  44. package/dist/core/locales/slices/init.d.ts +121 -0
  45. package/dist/core/locales/slices/init.js +380 -0
  46. package/dist/core/locales/slices/interactions.d.ts +47 -0
  47. package/dist/core/locales/slices/interactions.js +102 -0
  48. package/dist/core/locales/slices/lang.d.ts +8 -0
  49. package/dist/core/locales/slices/lang.js +18 -0
  50. package/dist/core/locales/slices/scheduling.d.ts +36 -0
  51. package/dist/core/locales/slices/scheduling.js +74 -0
  52. package/dist/core/locales/slices/startup.d.ts +6 -0
  53. package/dist/core/locales/slices/startup.js +14 -0
  54. package/dist/core/locales/slices/status.d.ts +20 -0
  55. package/dist/core/locales/slices/status.js +48 -0
  56. package/dist/core/locales/zh.d.ts +5 -0
  57. package/dist/core/locales/zh.js +23 -0
  58. package/dist/core/profile-generator.d.ts +6 -0
  59. package/dist/core/profile-generator.js +35 -7
  60. package/dist/core/running-executions.d.ts +51 -41
  61. package/dist/core/running-executions.js +120 -73
  62. package/dist/core/singleton-lock.d.ts +23 -0
  63. package/dist/core/singleton-lock.js +53 -0
  64. package/dist/core/status-format.js +4 -2
  65. package/dist/core/task-parser.d.ts +3 -0
  66. package/dist/core/task-parser.js +3 -1
  67. package/dist/core/types/thread-types.d.ts +54 -8
  68. package/dist/core/utils.d.ts +9 -1
  69. package/dist/core/utils.js +9 -1
  70. package/dist/domain/agents/config.d.ts +2 -1
  71. package/dist/domain/agents/config.js +25 -6
  72. package/dist/domain/agents/facade.d.ts +18 -0
  73. package/dist/domain/agents/facade.js +26 -3
  74. package/dist/domain/agents/profile-manager.d.ts +11 -0
  75. package/dist/domain/agents/profile-manager.js +21 -2
  76. package/dist/domain/costs/codex-usage-monitor.js +2 -1
  77. package/dist/domain/costs/rate-limit-throttle.js +14 -2
  78. package/dist/domain/executions/registry.d.ts +24 -0
  79. package/dist/domain/executions/registry.js +38 -0
  80. package/dist/domain/mcp/core-server.js +15 -3
  81. package/dist/domain/mcp/feishu/bitable.d.ts +3 -0
  82. package/dist/domain/mcp/feishu/bitable.js +168 -0
  83. package/dist/domain/mcp/feishu/block-types.d.ts +44 -0
  84. package/dist/domain/mcp/feishu/block-types.js +127 -0
  85. package/dist/domain/mcp/feishu/blocks-to-text.d.ts +19 -0
  86. package/dist/domain/mcp/feishu/blocks-to-text.js +43 -0
  87. package/dist/domain/mcp/feishu/client.d.ts +46 -0
  88. package/dist/domain/mcp/feishu/client.js +87 -0
  89. package/dist/domain/mcp/feishu/docx.d.ts +3 -0
  90. package/dist/domain/mcp/feishu/docx.js +163 -0
  91. package/dist/domain/mcp/feishu/drive.d.ts +23 -0
  92. package/dist/domain/mcp/feishu/drive.js +66 -0
  93. package/dist/domain/mcp/feishu/file.d.ts +14 -0
  94. package/dist/domain/mcp/feishu/file.js +107 -0
  95. package/dist/domain/mcp/feishu/index.d.ts +6 -0
  96. package/dist/domain/mcp/feishu/index.js +61 -0
  97. package/dist/domain/mcp/feishu/markdown-to-blocks.d.ts +40 -0
  98. package/dist/domain/mcp/feishu/markdown-to-blocks.js +191 -0
  99. package/dist/domain/mcp/feishu/sheets.d.ts +3 -0
  100. package/dist/domain/mcp/feishu/sheets.js +119 -0
  101. package/dist/domain/mcp/feishu/types.d.ts +26 -0
  102. package/dist/domain/mcp/feishu/types.js +38 -0
  103. package/dist/domain/mcp/feishu/user-auth.d.ts +140 -0
  104. package/dist/domain/mcp/feishu/user-auth.js +286 -0
  105. package/dist/domain/mcp/feishu/wiki.d.ts +3 -0
  106. package/dist/domain/mcp/feishu/wiki.js +77 -0
  107. package/dist/domain/mcp/feishu-server.d.ts +2 -0
  108. package/dist/domain/mcp/feishu-server.js +33 -0
  109. package/dist/domain/mcp/server.d.ts +0 -1
  110. package/dist/domain/mcp/server.js +6 -25
  111. package/dist/domain/mcp/slack-server.d.ts +3 -0
  112. package/dist/domain/mcp/slack-server.js +46 -0
  113. package/dist/domain/mcp/tools/context.js +1 -1
  114. package/dist/domain/mcp/tools/schedule.d.ts +1 -1
  115. package/dist/domain/mcp/tools/schedule.js +6 -20
  116. package/dist/domain/mcp/tools/slack.js +20 -7
  117. package/dist/domain/mcp/tools/thread-ops.d.ts +2 -0
  118. package/dist/domain/mcp/tools/thread-ops.js +121 -0
  119. package/dist/domain/mcp/tools/time.d.ts +2 -0
  120. package/dist/domain/mcp/tools/time.js +66 -0
  121. package/dist/domain/mcp/tools/tui-ask.js +1 -1
  122. package/dist/domain/mcp/tools/tui-plan.js +2 -2
  123. package/dist/domain/mcp/tui-server.js +1 -0
  124. package/dist/domain/monitor/disk-monitor.js +2 -1
  125. package/dist/domain/monitor/gpu-monitor.js +2 -1
  126. package/dist/domain/remote/client-hot-reload.js +3 -2
  127. package/dist/domain/remote/client-manager.js +8 -6
  128. package/dist/domain/scheduling/job-registry.d.ts +4 -0
  129. package/dist/domain/scheduling/job-registry.js +1 -0
  130. package/dist/domain/scheduling/jobs/_shared.js +2 -1
  131. package/dist/domain/scheduling/jobs/memory-index-regen.js +3 -2
  132. package/dist/domain/scheduling/jobs/scheduled-task.js +9 -23
  133. package/dist/domain/scheduling/jobs/sync-public.js +4 -3
  134. package/dist/domain/scheduling/jobs/target-dispatch.d.ts +1 -8
  135. package/dist/domain/scheduling/jobs/target-dispatch.js +0 -7
  136. package/dist/domain/scheduling/jobs/task-archive.js +3 -2
  137. package/dist/domain/scheduling/jobs/task-dispatch.js +126 -20
  138. package/dist/domain/scheduling/schedule-command.js +45 -43
  139. package/dist/domain/scheduling/scheduler.d.ts +1 -1
  140. package/dist/domain/scheduling/scheduler.js +2 -1
  141. package/dist/domain/sessions/session-hooks.d.ts +2 -2
  142. package/dist/domain/sessions/session-hooks.js +19 -18
  143. package/dist/domain/sessions/session-lifecycle.d.ts +38 -0
  144. package/dist/domain/sessions/session-lifecycle.js +44 -0
  145. package/dist/domain/system/github-release.d.ts +18 -0
  146. package/dist/domain/system/github-release.js +106 -0
  147. package/dist/domain/system/install-cli.d.ts +7 -0
  148. package/dist/domain/system/install-cli.js +106 -0
  149. package/dist/domain/system/preferences.d.ts +12 -0
  150. package/dist/domain/system/preferences.js +36 -0
  151. package/dist/domain/system/server-update-check.js +2 -2
  152. package/dist/domain/tasks/dispatch-utils.d.ts +58 -1
  153. package/dist/domain/tasks/dispatch-utils.js +53 -4
  154. package/dist/domain/tasks/dispatcher.d.ts +11 -2
  155. package/dist/domain/tasks/dispatcher.js +63 -7
  156. package/dist/domain/tasks/lint.js +28 -0
  157. package/dist/domain/tasks/mutator.d.ts +16 -3
  158. package/dist/domain/tasks/mutator.js +41 -12
  159. package/dist/domain/tasks/pending-tracker.js +6 -5
  160. package/dist/domain/tasks/system/task-cli.d.ts +2 -0
  161. package/dist/domain/tasks/system/task-cli.js +37 -6
  162. package/dist/domain/tasks/system/task-lifecycle-edit.js +6 -1
  163. package/dist/domain/tasks/system/task-mutations.d.ts +41 -3
  164. package/dist/domain/tasks/system/task-mutations.js +166 -8
  165. package/dist/domain/threads/contract.d.ts +17 -0
  166. package/dist/domain/threads/contract.js +59 -0
  167. package/dist/domain/threads/hook-runner.js +7 -6
  168. package/dist/domain/threads/index.d.ts +2 -0
  169. package/dist/domain/threads/index.js +3 -1
  170. package/dist/domain/threads/prompt-builder.d.ts +21 -1
  171. package/dist/domain/threads/prompt-builder.js +60 -4
  172. package/dist/domain/threads/runner.d.ts +6 -5
  173. package/dist/domain/threads/runner.js +128 -79
  174. package/dist/domain/threads/state-machine.d.ts +23 -21
  175. package/dist/domain/threads/state-machine.js +113 -54
  176. package/dist/domain/threads/template-loader.js +3 -2
  177. package/dist/domain/threads/tree.d.ts +45 -0
  178. package/dist/domain/threads/tree.js +171 -0
  179. package/dist/domain/tui-session/index.d.ts +2 -0
  180. package/dist/domain/tui-session/index.js +3 -0
  181. package/dist/domain/tui-session/tui-session-service.d.ts +2 -0
  182. package/dist/domain/tui-session/tui-session-service.js +103 -0
  183. package/dist/domain/tui-session/types.d.ts +67 -0
  184. package/dist/domain/tui-session/types.js +4 -0
  185. package/dist/domain/ui-service/index.d.ts +5 -0
  186. package/dist/domain/ui-service/index.js +3 -0
  187. package/dist/domain/ui-service/mutate/executions.d.ts +4 -0
  188. package/dist/domain/ui-service/mutate/executions.js +15 -0
  189. package/dist/domain/ui-service/mutate/schedules.d.ts +10 -0
  190. package/dist/domain/ui-service/mutate/schedules.js +39 -0
  191. package/dist/domain/ui-service/mutate/tasks.d.ts +23 -0
  192. package/dist/domain/ui-service/mutate/tasks.js +59 -0
  193. package/dist/domain/ui-service/mutate/threads.d.ts +4 -0
  194. package/dist/domain/ui-service/mutate/threads.js +21 -0
  195. package/dist/domain/ui-service/query/cost.d.ts +3 -0
  196. package/dist/domain/ui-service/query/cost.js +6 -0
  197. package/dist/domain/ui-service/query/executions.d.ts +2 -0
  198. package/dist/domain/ui-service/query/executions.js +35 -0
  199. package/dist/domain/ui-service/query/projects.d.ts +2 -0
  200. package/dist/domain/ui-service/query/projects.js +30 -0
  201. package/dist/domain/ui-service/query/schedules.d.ts +2 -0
  202. package/dist/domain/ui-service/query/schedules.js +23 -0
  203. package/dist/domain/ui-service/query/sessions.d.ts +2 -0
  204. package/dist/domain/ui-service/query/sessions.js +35 -0
  205. package/dist/domain/ui-service/query/tasks.d.ts +2 -0
  206. package/dist/domain/ui-service/query/tasks.js +30 -0
  207. package/dist/domain/ui-service/query/threads.d.ts +2 -0
  208. package/dist/domain/ui-service/query/threads.js +27 -0
  209. package/dist/domain/ui-service/subscribe.d.ts +5 -0
  210. package/dist/domain/ui-service/subscribe.js +118 -0
  211. package/dist/domain/ui-service/types.d.ts +237 -0
  212. package/dist/domain/ui-service/types.js +5 -0
  213. package/dist/domain/ui-service/ui-service.d.ts +2 -0
  214. package/dist/domain/ui-service/ui-service.js +83 -0
  215. package/dist/entry/app.js +130 -8
  216. package/dist/entry/cli.d.ts +12 -0
  217. package/dist/entry/cli.js +122 -12
  218. package/dist/entry/daemon.js +12 -30
  219. package/dist/entry/feishu-login.d.ts +28 -0
  220. package/dist/entry/feishu-login.js +218 -0
  221. package/dist/entry/init.d.ts +29 -5
  222. package/dist/entry/init.js +323 -233
  223. package/dist/entry/startup-notify.js +6 -3
  224. package/dist/events/event-types.d.ts +14 -0
  225. package/dist/hooks/cortex-md-injector.mjs +47 -31
  226. package/dist/hooks/post-task-hook.mjs +6 -0
  227. package/dist/hooks/task-status-check.mjs +8 -0
  228. package/dist/orchestration/agent-runner.d.ts +2 -1
  229. package/dist/orchestration/agent-runner.js +55 -55
  230. package/dist/orchestration/conduit-queue.d.ts +18 -0
  231. package/dist/orchestration/conduit-queue.js +32 -0
  232. package/dist/orchestration/conversation-runner.d.ts +48 -0
  233. package/dist/orchestration/conversation-runner.js +109 -0
  234. package/dist/orchestration/dispatch-reconciler.js +8 -1
  235. package/dist/orchestration/interactions/ask-user-question.d.ts +1 -1
  236. package/dist/orchestration/interactions/ask-user-question.js +3 -3
  237. package/dist/orchestration/interactions/interaction-handlers.js +55 -23
  238. package/dist/orchestration/interactions/plan-handler.d.ts +2 -2
  239. package/dist/orchestration/interactions/plan-handler.js +4 -3
  240. package/dist/orchestration/interactions/update-prompt-slack.js +11 -10
  241. package/dist/orchestration/interactions/update-prompt.d.ts +6 -0
  242. package/dist/orchestration/interactions/update-prompt.js +155 -0
  243. package/dist/orchestration/lifecycle.d.ts +4 -4
  244. package/dist/orchestration/lifecycle.js +25 -22
  245. package/dist/orchestration/orchestrator.d.ts +1 -1
  246. package/dist/orchestration/routing/commands/cancel.js +45 -52
  247. package/dist/orchestration/routing/commands/channel.js +41 -27
  248. package/dist/orchestration/routing/commands/cost.js +11 -2
  249. package/dist/orchestration/routing/commands/device.js +12 -9
  250. package/dist/orchestration/routing/commands/dispatch.js +11 -10
  251. package/dist/orchestration/routing/commands/index.d.ts +1 -1
  252. package/dist/orchestration/routing/commands/index.js +15 -10
  253. package/dist/orchestration/routing/commands/lang.d.ts +3 -0
  254. package/dist/orchestration/routing/commands/lang.js +31 -0
  255. package/dist/orchestration/routing/commands/mode.js +32 -30
  256. package/dist/orchestration/routing/commands/nvtop.js +15 -13
  257. package/dist/orchestration/routing/commands/orient.js +2 -1
  258. package/dist/orchestration/routing/commands/schedule.js +23 -22
  259. package/dist/orchestration/routing/commands/sendfile.js +9 -7
  260. package/dist/orchestration/routing/commands/session.d.ts +1 -1
  261. package/dist/orchestration/routing/commands/session.js +24 -39
  262. package/dist/orchestration/routing/commands/status.js +78 -71
  263. package/dist/orchestration/routing/commands/tail.js +7 -5
  264. package/dist/orchestration/routing/commands/task.js +25 -23
  265. package/dist/orchestration/routing/commands/thread-handlers.js +55 -44
  266. package/dist/orchestration/routing/edit-handler.js +8 -7
  267. package/dist/orchestration/routing/hook-bridge-subscribers.js +17 -1
  268. package/dist/orchestration/routing/message-router.d.ts +1 -1
  269. package/dist/orchestration/routing/message-router.js +9 -9
  270. package/dist/orchestration/routing/webhook.js +233 -2
  271. package/dist/orchestration/status-helpers.d.ts +5 -1
  272. package/dist/orchestration/status-helpers.js +13 -11
  273. package/dist/orchestration/thread-callback.d.ts +67 -0
  274. package/dist/orchestration/thread-callback.js +465 -0
  275. package/dist/orchestration/thread-executor.d.ts +22 -1
  276. package/dist/orchestration/thread-executor.js +85 -36
  277. package/dist/platform/adapter.d.ts +6 -2
  278. package/dist/platform/adapters/composite-adapter.d.ts +89 -0
  279. package/dist/platform/adapters/composite-adapter.js +318 -0
  280. package/dist/platform/adapters/feishu-output-stream.d.ts +26 -4
  281. package/dist/platform/adapters/feishu-output-stream.js +274 -36
  282. package/dist/platform/adapters/feishu.d.ts +50 -5
  283. package/dist/platform/adapters/feishu.js +370 -116
  284. package/dist/platform/adapters/index.d.ts +24 -3
  285. package/dist/platform/adapters/index.js +89 -11
  286. package/dist/platform/adapters/project-conduits.d.ts +9 -0
  287. package/dist/platform/adapters/project-conduits.js +42 -0
  288. package/dist/platform/adapters/slack-project-conduits.d.ts +1 -9
  289. package/dist/platform/adapters/slack-project-conduits.js +6 -40
  290. package/dist/platform/adapters/slack.d.ts +9 -2
  291. package/dist/platform/adapters/slack.js +83 -39
  292. package/dist/platform/adapters/tui/index.d.ts +9 -0
  293. package/dist/platform/adapters/tui/index.js +10 -0
  294. package/dist/platform/adapters/tui/ports.d.ts +20 -0
  295. package/dist/platform/adapters/tui/ports.js +4 -0
  296. package/dist/platform/adapters/tui/tui-conduit-state.d.ts +10 -0
  297. package/dist/platform/adapters/tui/tui-conduit-state.js +17 -0
  298. package/dist/platform/adapters/tui/tui-connection.d.ts +30 -0
  299. package/dist/platform/adapters/tui/tui-connection.js +53 -0
  300. package/dist/platform/adapters/tui/tui-gateway.d.ts +120 -0
  301. package/dist/platform/adapters/tui/tui-gateway.js +919 -0
  302. package/dist/platform/adapters/tui/tui-notifications.d.ts +12 -0
  303. package/dist/platform/adapters/tui/tui-notifications.js +60 -0
  304. package/dist/platform/adapters/tui/tui-output-stream.d.ts +36 -0
  305. package/dist/platform/adapters/tui/tui-output-stream.js +99 -0
  306. package/dist/platform/adapters/tui/tui-transcript.d.ts +8 -0
  307. package/dist/platform/adapters/tui/tui-transcript.js +56 -0
  308. package/dist/platform/index.d.ts +1 -0
  309. package/dist/platform/index.js +2 -1
  310. package/dist/platform/interactive-builder.js +21 -19
  311. package/dist/platform/output-stream.d.ts +5 -0
  312. package/dist/platform/testing.d.ts +7 -11
  313. package/dist/platform/testing.js +18 -15
  314. package/dist/platform/tool-trace.js +15 -5
  315. package/dist/platform/tui/protocol.d.ts +355 -0
  316. package/dist/platform/tui/protocol.js +199 -0
  317. package/dist/platform/types.d.ts +12 -3
  318. package/dist/store/execution-repo.d.ts +6 -1
  319. package/dist/store/execution-repo.js +13 -3
  320. package/dist/store/hook-sync.d.ts +18 -0
  321. package/dist/store/hook-sync.js +92 -0
  322. package/dist/store/outbound-queue.js +2 -2
  323. package/dist/store/profile-repo.js +3 -2
  324. package/dist/store/schedule-repo.d.ts +1 -8
  325. package/dist/store/session-registry-repo.d.ts +9 -1
  326. package/dist/store/session-registry-repo.js +19 -3
  327. package/dist/store/session-repo.d.ts +14 -0
  328. package/dist/store/session-repo.js +23 -0
  329. package/dist/store/thread-repo.d.ts +3 -0
  330. package/dist/store/thread-repo.js +49 -2
  331. package/dist/store/version-migrations.d.ts +7 -0
  332. package/dist/store/version-migrations.js +183 -0
  333. package/dist/tui/App.d.ts +27 -0
  334. package/dist/tui/App.js +219 -0
  335. package/dist/tui/components/AskUserModal.d.ts +11 -0
  336. package/dist/tui/components/AskUserModal.js +364 -0
  337. package/dist/tui/components/ConfirmModal.d.ts +12 -0
  338. package/dist/tui/components/ConfirmModal.js +31 -0
  339. package/dist/tui/components/Dashboard.d.ts +23 -0
  340. package/dist/tui/components/Dashboard.js +80 -0
  341. package/dist/tui/components/DashboardCostTab.d.ts +7 -0
  342. package/dist/tui/components/DashboardCostTab.js +16 -0
  343. package/dist/tui/components/DashboardExecutionsTab.d.ts +11 -0
  344. package/dist/tui/components/DashboardExecutionsTab.js +94 -0
  345. package/dist/tui/components/DashboardSchedulesTab.d.ts +11 -0
  346. package/dist/tui/components/DashboardSchedulesTab.js +124 -0
  347. package/dist/tui/components/DashboardTasksTab.d.ts +12 -0
  348. package/dist/tui/components/DashboardTasksTab.js +200 -0
  349. package/dist/tui/components/DashboardThreadsTab.d.ts +11 -0
  350. package/dist/tui/components/DashboardThreadsTab.js +81 -0
  351. package/dist/tui/components/Header.d.ts +11 -0
  352. package/dist/tui/components/Header.js +5 -0
  353. package/dist/tui/components/InputBox.d.ts +10 -0
  354. package/dist/tui/components/InputBox.js +19 -0
  355. package/dist/tui/components/MessageRow.d.ts +7 -0
  356. package/dist/tui/components/MessageRow.js +10 -0
  357. package/dist/tui/components/Notifications.d.ts +19 -0
  358. package/dist/tui/components/Notifications.js +72 -0
  359. package/dist/tui/components/PlanFeedbackModal.d.ts +11 -0
  360. package/dist/tui/components/PlanFeedbackModal.js +161 -0
  361. package/dist/tui/components/ProjectSwitcher.d.ts +18 -0
  362. package/dist/tui/components/ProjectSwitcher.js +43 -0
  363. package/dist/tui/components/SessionPicker.d.ts +14 -0
  364. package/dist/tui/components/SessionPicker.js +34 -0
  365. package/dist/tui/components/SidePanel.d.ts +19 -0
  366. package/dist/tui/components/SidePanel.js +8 -0
  367. package/dist/tui/components/StatusLine.d.ts +10 -0
  368. package/dist/tui/components/StatusLine.js +29 -0
  369. package/dist/tui/components/Transcript.d.ts +13 -0
  370. package/dist/tui/components/Transcript.js +56 -0
  371. package/dist/tui/hooks/useDashboardData.d.ts +32 -0
  372. package/dist/tui/hooks/useDashboardData.js +104 -0
  373. package/dist/tui/hooks/useKeybindings.d.ts +19 -0
  374. package/dist/tui/hooks/useKeybindings.js +87 -0
  375. package/dist/tui/hooks/useMutate.d.ts +22 -0
  376. package/dist/tui/hooks/useMutate.js +56 -0
  377. package/dist/tui/hooks/useNotifications.d.ts +28 -0
  378. package/dist/tui/hooks/useNotifications.js +70 -0
  379. package/dist/tui/hooks/useTranscript.d.ts +39 -0
  380. package/dist/tui/hooks/useTranscript.js +265 -0
  381. package/dist/tui/hooks/useWsClient.d.ts +29 -0
  382. package/dist/tui/hooks/useWsClient.js +69 -0
  383. package/dist/tui/index.d.ts +2 -0
  384. package/dist/tui/index.js +210 -0
  385. package/dist/tui/logic.d.ts +16 -0
  386. package/dist/tui/logic.js +49 -0
  387. package/dist/tui/render/markdown.d.ts +10 -0
  388. package/dist/tui/render/markdown.js +38 -0
  389. package/dist/tui/render/rich-blocks.d.ts +11 -0
  390. package/dist/tui/render/rich-blocks.js +24 -0
  391. package/dist/tui/ws-client.d.ts +44 -0
  392. package/dist/tui/ws-client.js +157 -0
  393. package/package.json +11 -3
  394. package/dist/orchestration/channel-queue.d.ts +0 -18
  395. package/dist/orchestration/channel-queue.js +0 -32
@@ -0,0 +1,74 @@
1
+ // input: nothing (leaf data slice)
2
+ // output: schedulingEn / schedulingZh — message slice (filled by i18n extraction)
3
+ // pos: one locale slice; aggregated by core/locales/en.ts & zh.ts barrels
4
+ // >>> Keep en and zh keys in lockstep (zh typed against keyof typeof schedulingEn) <<<
5
+ export const schedulingEn = {
6
+ 'schedule.help.title': '*Schedule commands:*',
7
+ 'schedule.help.addInterval': '`!schedule add interval <duration> [--profile <name>] <message>` — repeat every duration (e.g. `30m`, `2h`, `1d`)',
8
+ 'schedule.help.addDaily': '`!schedule add daily <HH:MM> [--profile <name>] <message>` — run every day at a fixed time (24-hour)',
9
+ 'schedule.help.addWeekly': '`!schedule add weekly <day> <HH:MM> [--profile <name>] <message>` — run every week (day: mon,tue,wed,thu,fri,sat,sun)',
10
+ 'schedule.help.addOnce': '`!schedule add once <duration> [--profile <name>] <message>` — run once after a delay',
11
+ 'schedule.help.list': '`!schedule list` — show all scheduled tasks',
12
+ 'schedule.help.pause': '`!schedule pause <id>` — pause a recurring task',
13
+ 'schedule.help.resume': '`!schedule resume <id>` — resume a paused recurring task',
14
+ 'schedule.help.remove': '`!schedule remove <id>` — remove a task by id',
15
+ 'schedule.help.availableProfiles': 'Available profiles: ${profileNames}',
16
+ 'schedule.list.empty': 'No scheduled tasks.',
17
+ 'schedule.list.header': '*Scheduled tasks (${count}):*\n${lines}',
18
+ 'schedule.remove.usage': 'Usage: `!schedule remove <id>`',
19
+ 'schedule.remove.ok': 'Removed task `${id}`.',
20
+ 'schedule.taskNotFound': 'Task not found: `${id}`',
21
+ 'schedule.pause.usage': 'Usage: `!schedule pause <id>`',
22
+ 'schedule.pause.ok': 'Paused task `${id}`.',
23
+ 'schedule.resume.usage': 'Usage: `!schedule resume <id>`',
24
+ 'schedule.resume.ok': 'Resumed task `${id}`.${nextAt}',
25
+ 'schedule.resume.nextRun': ' Next run: ${time}.',
26
+ 'schedule.invalidDuration': 'Invalid duration: `${duration}`. Use e.g. `30s`, `5m`, `2h`, `1d`',
27
+ 'schedule.invalidTime': 'Invalid time: `${time}`. Use 24-hour HH:MM, e.g. `${example}`',
28
+ 'schedule.invalidDay': 'Invalid day: `${day}`. Use: mon, tue, wed, thu, fri, sat, sun',
29
+ 'schedule.add.intervalUsage': 'Usage: `!schedule add interval <duration> [--profile <name>] <message>`',
30
+ 'schedule.add.dailyUsage': 'Usage: `!schedule add daily <HH:MM> [--profile <name>] <message>`',
31
+ 'schedule.add.weeklyUsage': 'Usage: `!schedule add weekly <day> <HH:MM> [--profile <name>] <message>`',
32
+ 'schedule.add.onceUsage': 'Usage: `!schedule add once <duration> [--profile <name>] <message>`',
33
+ 'schedule.add.scheduledInterval': 'Scheduled every *${duration}*: "${message}"',
34
+ 'schedule.add.scheduledDaily': 'Scheduled daily at *${time}*: "${message}"',
35
+ 'schedule.add.scheduledWeekly': 'Scheduled weekly *${day} ${time}*: "${message}"',
36
+ 'schedule.add.scheduledOnce': 'Scheduled once in *${duration}*: "${message}"',
37
+ 'schedule.add.unknownType': 'Unknown type: `${type}`. Use `interval`, `daily`, `weekly`, or `once`',
38
+ 'schedule.profileUsage': 'Usage: ${usage}',
39
+ };
40
+ export const schedulingZh = {
41
+ 'schedule.help.title': '*定时任务命令:*',
42
+ 'schedule.help.addInterval': '`!schedule add interval <duration> [--profile <name>] <message>` — 每隔指定时长重复(例如 `30m`、`2h`、`1d`)',
43
+ 'schedule.help.addDaily': '`!schedule add daily <HH:MM> [--profile <name>] <message>` — 每天在固定时间运行(24 小时制)',
44
+ 'schedule.help.addWeekly': '`!schedule add weekly <day> <HH:MM> [--profile <name>] <message>` — 每周运行(day:mon,tue,wed,thu,fri,sat,sun)',
45
+ 'schedule.help.addOnce': '`!schedule add once <duration> [--profile <name>] <message>` — 延迟一段时间后运行一次',
46
+ 'schedule.help.list': '`!schedule list` — 显示所有定时任务',
47
+ 'schedule.help.pause': '`!schedule pause <id>` — 暂停一个周期任务',
48
+ 'schedule.help.resume': '`!schedule resume <id>` — 恢复一个已暂停的周期任务',
49
+ 'schedule.help.remove': '`!schedule remove <id>` — 按 id 删除任务',
50
+ 'schedule.help.availableProfiles': '可用的 profile:${profileNames}',
51
+ 'schedule.list.empty': '没有定时任务。',
52
+ 'schedule.list.header': '*定时任务(${count}):*\n${lines}',
53
+ 'schedule.remove.usage': '用法:`!schedule remove <id>`',
54
+ 'schedule.remove.ok': '已删除任务 `${id}`。',
55
+ 'schedule.taskNotFound': '未找到任务:`${id}`',
56
+ 'schedule.pause.usage': '用法:`!schedule pause <id>`',
57
+ 'schedule.pause.ok': '已暂停任务 `${id}`。',
58
+ 'schedule.resume.usage': '用法:`!schedule resume <id>`',
59
+ 'schedule.resume.ok': '已恢复任务 `${id}`。${nextAt}',
60
+ 'schedule.resume.nextRun': ' 下次运行:${time}。',
61
+ 'schedule.invalidDuration': '无效的时长:`${duration}`。请使用例如 `30s`、`5m`、`2h`、`1d`',
62
+ 'schedule.invalidTime': '无效的时间:`${time}`。请使用 24 小时制 HH:MM,例如 `${example}`',
63
+ 'schedule.invalidDay': '无效的星期:`${day}`。请使用:mon, tue, wed, thu, fri, sat, sun',
64
+ 'schedule.add.intervalUsage': '用法:`!schedule add interval <duration> [--profile <name>] <message>`',
65
+ 'schedule.add.dailyUsage': '用法:`!schedule add daily <HH:MM> [--profile <name>] <message>`',
66
+ 'schedule.add.weeklyUsage': '用法:`!schedule add weekly <day> <HH:MM> [--profile <name>] <message>`',
67
+ 'schedule.add.onceUsage': '用法:`!schedule add once <duration> [--profile <name>] <message>`',
68
+ 'schedule.add.scheduledInterval': '已设定每 *${duration}* 运行一次:"${message}"',
69
+ 'schedule.add.scheduledDaily': '已设定每天 *${time}* 运行:"${message}"',
70
+ 'schedule.add.scheduledWeekly': '已设定每周 *${day} ${time}* 运行:"${message}"',
71
+ 'schedule.add.scheduledOnce': '已设定 *${duration}* 后运行一次:"${message}"',
72
+ 'schedule.add.unknownType': '未知的类型:`${type}`。请使用 `interval`、`daily`、`weekly` 或 `once`',
73
+ 'schedule.profileUsage': '用法:${usage}',
74
+ };
@@ -0,0 +1,6 @@
1
+ export declare const startupEn: {
2
+ readonly 'startup.started': "Cortex agent v${version} started on ${machine}.";
3
+ readonly 'startup.restarted': "Cortex agent v${version} restarted on ${machine}.";
4
+ readonly 'startup.reason': " Reason: ${reason}.";
5
+ };
6
+ export declare const startupZh: Record<keyof typeof startupEn, string>;
@@ -0,0 +1,14 @@
1
+ // input: nothing (leaf data slice)
2
+ // output: startupEn / startupZh — message slice (filled by i18n extraction)
3
+ // pos: one locale slice; aggregated by core/locales/en.ts & zh.ts barrels
4
+ // >>> Keep en and zh keys in lockstep (zh typed against keyof typeof startupEn) <<<
5
+ export const startupEn = {
6
+ 'startup.started': 'Cortex agent v${version} started on ${machine}.',
7
+ 'startup.restarted': 'Cortex agent v${version} restarted on ${machine}.',
8
+ 'startup.reason': ' Reason: ${reason}.',
9
+ };
10
+ export const startupZh = {
11
+ 'startup.started': 'Cortex 代理 v${version} 已在 ${machine} 上启动。',
12
+ 'startup.restarted': 'Cortex 代理 v${version} 已在 ${machine} 上重启。',
13
+ 'startup.reason': ' 原因:${reason}。',
14
+ };
@@ -0,0 +1,20 @@
1
+ export declare const statusEn: {
2
+ readonly 'status.processing': "Processing";
3
+ readonly 'status.done': "Done";
4
+ readonly 'status.waitingForUserInput': "Waiting for user input";
5
+ readonly 'status.cancelled': "Cancelled";
6
+ readonly 'status.error': "Error";
7
+ readonly 'status.supersededByEdit': "Superseded by edit";
8
+ readonly 'status.retryEdited': "edited";
9
+ readonly 'status.retry': "Retry";
10
+ readonly 'status.rateLimitedExhausted': "Rate limited — all fallbacks exhausted";
11
+ readonly 'status.supersededSeeNewReply': "see new reply";
12
+ readonly 'status.processingAskResponse': "Processing AskUserQuestion response...";
13
+ readonly 'status.errorBody': "Error: ${message}";
14
+ readonly 'status.noRunningExecutions': "No running executions.";
15
+ readonly 'status.runningExecutions': "Running executions: ${count}";
16
+ readonly 'btn.cancel': "Cancel";
17
+ readonly 'btn.resume': "Resume";
18
+ readonly 'btn.new': "New";
19
+ };
20
+ export declare const statusZh: Record<keyof typeof statusEn, string>;
@@ -0,0 +1,48 @@
1
+ // input: nothing (leaf data slice)
2
+ // output: statusEn / statusZh — message slice (filled by i18n extraction)
3
+ // pos: one locale slice; aggregated by core/locales/en.ts & zh.ts barrels
4
+ // >>> Keep en and zh keys in lockstep (zh typed against keyof typeof statusEn) <<<
5
+ export const statusEn = {
6
+ // --- Status / lifecycle phrases ---
7
+ 'status.processing': 'Processing',
8
+ 'status.done': 'Done',
9
+ 'status.waitingForUserInput': 'Waiting for user input',
10
+ 'status.cancelled': 'Cancelled',
11
+ 'status.error': 'Error',
12
+ 'status.supersededByEdit': 'Superseded by edit',
13
+ 'status.retryEdited': 'edited',
14
+ 'status.retry': 'Retry',
15
+ 'status.rateLimitedExhausted': 'Rate limited — all fallbacks exhausted',
16
+ 'status.supersededSeeNewReply': 'see new reply',
17
+ 'status.processingAskResponse': 'Processing AskUserQuestion response...',
18
+ 'status.errorBody': 'Error: ${message}',
19
+ // --- Execution report ---
20
+ 'status.noRunningExecutions': 'No running executions.',
21
+ 'status.runningExecutions': 'Running executions: ${count}',
22
+ // --- Button labels ---
23
+ 'btn.cancel': 'Cancel',
24
+ 'btn.resume': 'Resume',
25
+ 'btn.new': 'New',
26
+ };
27
+ export const statusZh = {
28
+ // --- Status / lifecycle phrases ---
29
+ 'status.processing': '处理中',
30
+ 'status.done': '完成',
31
+ 'status.waitingForUserInput': '等待用户输入',
32
+ 'status.cancelled': '已取消',
33
+ 'status.error': '错误',
34
+ 'status.supersededByEdit': '已被编辑取代',
35
+ 'status.retryEdited': '已编辑',
36
+ 'status.retry': '重试',
37
+ 'status.rateLimitedExhausted': '触发限流 — 所有回退已用尽',
38
+ 'status.supersededSeeNewReply': '查看新回复',
39
+ 'status.processingAskResponse': '正在处理 AskUserQuestion 回复……',
40
+ 'status.errorBody': '错误:${message}',
41
+ // --- Execution report ---
42
+ 'status.noRunningExecutions': '没有正在运行的执行。',
43
+ 'status.runningExecutions': '正在运行的执行:${count}',
44
+ // --- Button labels ---
45
+ 'btn.cancel': '取消',
46
+ 'btn.resume': '恢复',
47
+ 'btn.new': '新建',
48
+ };
@@ -0,0 +1,5 @@
1
+ import type { MessageKey } from './en.js';
2
+ /** Simplified-Chinese translations, aggregated from per-cluster slices. Must provide every
3
+ * MessageKey (compiler-enforced via Record<MessageKey,string>) and add none. ${param}
4
+ * placeholders and `code`/*bold* markdown are preserved verbatim from the en slices. */
5
+ export declare const zh: Record<MessageKey, string>;
@@ -0,0 +1,23 @@
1
+ // input: per-cluster Simplified-Chinese slices (./slices/*) + MessageKey from en.ts
2
+ // output: `zh` — aggregated zh table, typed Record<MessageKey, string>
3
+ // pos: L0 locale barrel; the Record<MessageKey,...> type forces parity with en.ts at compile time
4
+ // >>> Keep slice keys in lockstep with their en counterparts <<<
5
+ import { langZh } from './slices/lang.js';
6
+ import { statusZh } from './slices/status.js';
7
+ import { commandsZh } from './slices/commands.js';
8
+ import { schedulingZh } from './slices/scheduling.js';
9
+ import { interactionsZh } from './slices/interactions.js';
10
+ import { startupZh } from './slices/startup.js';
11
+ import { initZh } from './slices/init.js';
12
+ /** Simplified-Chinese translations, aggregated from per-cluster slices. Must provide every
13
+ * MessageKey (compiler-enforced via Record<MessageKey,string>) and add none. ${param}
14
+ * placeholders and `code`/*bold* markdown are preserved verbatim from the en slices. */
15
+ export const zh = {
16
+ ...langZh,
17
+ ...statusZh,
18
+ ...commandsZh,
19
+ ...schedulingZh,
20
+ ...interactionsZh,
21
+ ...startupZh,
22
+ ...initZh,
23
+ };
@@ -3,6 +3,8 @@ interface ProfileEntry {
3
3
  model: string;
4
4
  backend: string;
5
5
  mode: string;
6
+ /** PI `--provider` (= gateway endpoint group). Required for backend='pi'; omitted for claude/codex. */
7
+ provider?: string;
6
8
  fallback?: ProfileEntry[];
7
9
  extraEnv?: Record<string, string>;
8
10
  extraOption?: Record<string, string>;
@@ -25,6 +27,8 @@ export interface GenerateOpts {
25
27
  planFallback?: ModelChoice[];
26
28
  /** Ordered fallback chain for the `execute` profile. */
27
29
  executeFallback?: ModelChoice[];
30
+ /** Additional models to register as standalone named profiles (profile name = model name). */
31
+ extraProfiles?: ModelChoice[];
28
32
  }
29
33
  /**
30
34
  * Flatten endpoints to a list of (mode, model) choices the user can pick from.
@@ -55,6 +59,8 @@ export interface WriteProfilesOpts extends GenerateOpts {
55
59
  outputDir?: string;
56
60
  /** Force overwrite of existing `plan` / `execute` profiles. Default false. */
57
61
  overwrite?: boolean;
62
+ /** Additional models to register as standalone named profiles. */
63
+ extraProfiles?: ModelChoice[];
58
64
  }
59
65
  /**
60
66
  * Write profiles.json to ~/.cortex/config/profiles.json (or outputDir/profiles.json).
@@ -48,11 +48,19 @@ function findModelEntry(models, choice, label) {
48
48
  }
49
49
  /** Build a ProfileEntry from a ModelEntry (no fallback chain attached yet). */
50
50
  function makeProfileEntry(m) {
51
- return {
51
+ const entry = {
52
52
  model: m.model,
53
53
  backend: m.backend,
54
54
  mode: m.mode,
55
55
  };
56
+ // PI backends require an explicit `provider` (the PI `--provider` / gateway endpoint group).
57
+ // For discovered PI providers, endpoint === provider name (discoverEndpoints sets mode = endpoint
58
+ // = provider), so the gateway URL `/m/<mode>/<provider>` lands on the generated `<endpoint>:
59
+ // { <mode>: ... }` route. claude/codex backends carry no provider.
60
+ if (m.backend === 'pi') {
61
+ entry.provider = m.endpoint;
62
+ }
63
+ return entry;
56
64
  }
57
65
  /** Build fallback entries from explicit user choices. Throws if any choice can't be resolved. */
58
66
  function resolveFallbackChain(models, fallback, label) {
@@ -111,13 +119,32 @@ export function generateProfiles(endpoints, opts = {}) {
111
119
  const executeProfile = makeProfileEntry(executeEntry);
112
120
  if (executeFallback)
113
121
  executeProfile.fallback = executeFallback;
114
- return {
115
- defaultProfile: 'plan',
116
- profiles: {
117
- plan: planProfile,
118
- execute: executeProfile,
119
- },
122
+ const profiles = {
123
+ plan: planProfile,
124
+ execute: executeProfile,
120
125
  };
126
+ // Extra profiles: user-picked additional models to register as standalone named profiles.
127
+ // Profile name = model name (e.g., selecting deepseek-v4-pro → profile "deepseek-v4-pro").
128
+ if (opts.extraProfiles && opts.extraProfiles.length > 0) {
129
+ for (const choice of opts.extraProfiles) {
130
+ // Profile names must match /^[a-zA-Z0-9_-]+$/. Model ids may contain dots (e.g. "gpt-5.4"),
131
+ // which are invalid in a profile name — sanitize dots → dashes. The model id stored in the
132
+ // entry stays verbatim (makeProfileEntry uses choice.model) so the API call is unaffected.
133
+ const name = choice.model.replace(/\./g, '-');
134
+ if (name === 'plan' || name === 'execute') {
135
+ log.warn(`Skipping extra profile "${name}": name conflicts with managed profile`);
136
+ continue;
137
+ }
138
+ if (profiles[name]) {
139
+ log.warn(`Skipping extra profile "${name}": already exists`);
140
+ continue;
141
+ }
142
+ const entry = findModelEntry(models, choice, `extraProfiles[${name}]`);
143
+ profiles[name] = makeProfileEntry(entry);
144
+ log.info(`Added extra profile: ${name} (mode=${entry.mode}, backend=${entry.backend})`);
145
+ }
146
+ }
147
+ return { defaultProfile: 'plan', profiles };
121
148
  }
122
149
  // ─── File I/O ─────────────────────────────────────────────────────
123
150
  /**
@@ -177,6 +204,7 @@ export function writeProfilesJson(endpoints, optsOrOutputDir) {
177
204
  executeChoice: opts.executeChoice,
178
205
  planFallback: opts.planFallback,
179
206
  executeFallback: opts.executeFallback,
207
+ extraProfiles: opts.extraProfiles,
180
208
  });
181
209
  const merged = mergeProfilesJson(generated, opts.outputDir, opts.overwrite ?? false);
182
210
  const configDir = opts.outputDir || path.join(os.homedir(), '.cortex', 'config');
@@ -2,9 +2,12 @@ import type { EventBus } from '../events/index.js';
2
2
  export interface RunningExecution {
3
3
  threadId: string | null;
4
4
  channel: string | null;
5
+ /** Primary key — the executionId when present, otherwise the ad-hoc registryKey. */
5
6
  registryKey: string;
6
7
  agentSlotId: string | null;
7
8
  executionId: string | null;
9
+ /** Execution kind ('local' | 'dispatch' | 'scheduled' | null) — used for dispatch concurrency accounting. */
10
+ kind: string | null;
8
11
  kill: () => boolean;
9
12
  startTime: number;
10
13
  backend: string;
@@ -13,74 +16,81 @@ export interface RunningExecution {
13
16
  /** Claude session ID — saved on cancel so the next message can resume the same session. */
14
17
  sessionId?: string | null;
15
18
  }
16
- export type RunningExecutionInput = Omit<RunningExecution, 'registryKey' | 'startTime'>;
19
+ /** Input accepted by register(). registryKey/startTime are assigned internally; kind defaults to null. */
20
+ export type RunningExecutionInput = Omit<RunningExecution, 'registryKey' | 'startTime' | 'kind'> & {
21
+ registryKey?: string;
22
+ kind?: string | null;
23
+ };
17
24
  export declare class RunningExecutions {
18
- /** Primary index: key is channel or hookHandleKey (arbitrary string). */
25
+ /** Primary index: key is executionId (or ad-hoc registryKey when executionId is null). */
19
26
  private byKey;
20
27
  /** Secondary index: threadId → RunningExecution, only if threadId is non-null. */
21
28
  private byThreadId;
22
- /** Secondary index: executionId → RunningExecution, only if executionId is non-null. */
23
- private byExecutionId;
29
+ /** Secondary index: channel → set of RunningExecutions on that channel. */
30
+ private byChannel;
24
31
  /** EventBus for publishing agent.* lifecycle events. May be set after construction. */
25
32
  private _bus;
26
33
  constructor(bus?: EventBus);
27
34
  setBus(bus: EventBus): void;
28
35
  /**
29
- * Register a new execution under an arbitrary key.
30
- * Silently replaces any existing entry at the same key.
31
- * Secondary indices (byThreadId / byExecutionId) are kept in sync.
32
- * Publishes agent.started if executionId is non-null and bus is wired.
36
+ * Register a live execution, keyed by its executionId (or an ad-hoc registryKey).
37
+ * Returns the primary key. Secondary indices (byThreadId / byChannel) are kept in sync.
38
+ * Publishes agent.started if executionId is non-null and a bus is wired.
33
39
  */
34
- register(key: string, exec: RunningExecutionInput): void;
35
- /** Look up an execution by its primary registry key. Returns null if not found. */
36
- getByKey(key: string): RunningExecution | null;
37
- /** Look up an execution by threadId. Returns null if not found or threadId was null at registration. */
40
+ register(exec: RunningExecutionInput): string;
41
+ /** Look up an execution by its primary key (executionId or ad-hoc registryKey). */
42
+ getById(id: string): RunningExecution | null;
43
+ /** Returns true if an execution is registered under the given id/key. */
44
+ hasId(id: string): boolean;
45
+ /** Look up an execution by threadId. Returns null if not found. */
38
46
  getByThreadId(threadId: string): RunningExecution | null;
39
- /** Look up an execution by executionId. Returns null if not found. */
40
- getByExecutionId(executionId: string): RunningExecution | null;
41
- /** Returns true if an execution is registered under the given key. */
42
- has(key: string): boolean;
47
+ /** Return all live executions registered on a channel (empty array if none). */
48
+ getByChannel(channel: string): RunningExecution[];
49
+ /** Returns true if at least one live execution is registered on the channel. */
50
+ hasChannel(channel: string): boolean;
51
+ /** Return all registered executions (snapshot of the primary index). */
52
+ getAll(): RunningExecution[];
43
53
  /**
44
- * Kill the execution for a key, remove it from all indices, and return the result of kill().
45
- * Returns false if no entry is registered for the key.
54
+ * Kill the execution for an id, remove it from all indices, and return the result of kill().
55
+ * Returns false if no entry is registered for the id.
46
56
  */
47
- killByKey(key: string): boolean;
57
+ killById(id: string): boolean;
48
58
  /**
49
59
  * Kill the execution for a threadId, remove it from all indices, and return true.
50
- * Resolves through byThreadId secondary index.
51
60
  * Returns false if no entry has that threadId.
52
61
  */
53
62
  killByThreadId(threadId: string): boolean;
63
+ /** Kill every execution on a channel; returns the number killed. */
64
+ killByChannel(channel: string): number;
54
65
  /**
55
- * Remove an execution by key without calling kill() or publishing events.
56
- * No-op if the key is not registered.
66
+ * Remove an execution by id without calling kill() or publishing events.
67
+ * No-op if the id is not registered.
57
68
  */
58
- remove(key: string): void;
59
- /** Return all registered executions (snapshot of the primary index). */
60
- getAll(): RunningExecution[];
69
+ remove(id: string): void;
61
70
  /**
62
- * Mark the execution for a key as completed and publish agent.completed.
63
- * Returns false if no entry is registered for the key (e.g., already removed).
64
- * Publishes agent.completed only if executionId is non-null and bus is wired.
71
+ * Mark the execution for an id as completed and publish agent.completed.
72
+ * Returns false if no entry is registered (e.g., already removed).
65
73
  */
66
- complete(key: string, costUsd?: number): boolean;
74
+ complete(id: string, costUsd?: number): boolean;
67
75
  /**
68
- * Mark the execution for a key as failed and publish agent.failed.
69
- * Returns false if no entry is registered for the key (e.g., already removed by supersede).
70
- * Publishes agent.failed only if executionId is non-null and bus is wired.
76
+ * Mark the execution for an id as failed and publish agent.failed.
77
+ * Returns false if no entry is registered (e.g., already removed).
71
78
  */
72
- fail(key: string, error: string): boolean;
79
+ fail(id: string, error: string): boolean;
73
80
  /**
74
- * Kill the execution for a key, remove it, and publish agent.superseded.
75
- * Returns false if no entry is registered for the key.
76
- * Publishes agent.superseded only if executionId is non-null and bus is wired.
81
+ * Kill the execution for an id, remove it, and publish agent.superseded.
82
+ * Returns false if no entry is registered for the id.
77
83
  */
78
- supersede(key: string, reason: string): boolean;
84
+ supersede(id: string, reason: string): boolean;
85
+ /** Supersede (kill + event) every execution on a channel; returns the number superseded. */
86
+ supersedeByChannel(channel: string, reason: string): number;
87
+ /** Delete an entry from the primary map and all secondary indices. */
88
+ private _delete;
79
89
  /**
80
- * Remove an entry from secondary indices (byThreadId / byExecutionId).
81
- * Guards each delete with identity check: only clears the index if it still points
82
- * to this entry. This prevents corruption when a stale entry (whose threadId/executionId
83
- * has been claimed by a newer entry) is removed.
90
+ * Remove an entry from secondary indices (byThreadId / byChannel).
91
+ * Guards each delete with an identity check: only clears the index if it still points
92
+ * to this entry, preventing corruption when a stale entry (whose threadId has been
93
+ * claimed by a newer entry) is removed.
84
94
  */
85
95
  private _removeFromIndices;
86
96
  }