@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
@@ -3,8 +3,10 @@
3
3
  // pos: Agent runtime lifecycle handling (success/failure/approval/resume)
4
4
  // >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
5
5
  import { createLogger } from '../core/log.js';
6
+ import { Icons } from '../core/icons.js';
7
+ import { t } from '../core/i18n.js';
6
8
  import { trackPendingTask } from './busy-tracker.js';
7
- import { enqueue } from './channel-queue.js';
9
+ import { enqueue } from './conduit-queue.js';
8
10
  import { supersededEdits } from './superseded-edits.js';
9
11
  import { runningExecutions } from '../core/running-executions.js';
10
12
  import { finalizeLocalExecution, buildSessionTag, buildUserProcessingMessage, makeFallbackNotifier, makeStreamingMessageCallback, computeElapsed, formatMetricsSuffix, writeStatus, sealStatus, buildStatusActionBlocks, buildSealedStatusActionBlocks, initStatusBlocks } from './status-helpers.js';
@@ -24,7 +26,7 @@ import { getOutboundQueue } from '../store/outbound-queue.js';
24
26
  import { buildDurableHooks, durablePost } from './durable-helpers.js';
25
27
  const log = createLogger('lifecycle');
26
28
  // --- Agent success handler ---
27
- export async function handleAgentSuccess({ result, channel, adapter, statusMsg, startTime, userMessage, executionId, trigger = 'user', sessionName = null, threadTs = null, userMessageTs = null, onAssistantMessage = null }) {
29
+ export async function handleAgentSuccess({ result, channel, adapter, statusMsg, startTime, userMessage, executionId, trigger = 'user', sessionName = null, threadAnchorId = null, userMessageTs = null, onAssistantMessage = null }) {
28
30
  if (result?.sessionId)
29
31
  await setSessionAsync(channel, result.sessionId, resolveBackendForChannel(channel));
30
32
  await registerOrUpdateSession(result, sessionName, channel, trigger, projectStore.resolveFromMessage(userMessage)?.id ?? 'general');
@@ -34,10 +36,10 @@ export async function handleAgentSuccess({ result, channel, adapter, statusMsg,
34
36
  const metrics = formatMetricsSuffix({ costUsd: result?.total_cost_usd ?? null, numTurns: result?.num_turns ?? null });
35
37
  const sessionTag = buildSessionTag(sessionName, result?.sessionId);
36
38
  const stream = onAssistantMessage?.stream ?? null;
37
- const askCount = await askUserQuestion.sendMessages(result, channel, adapter, statusMsg.messageId, threadTs, stream);
39
+ const askCount = await askUserQuestion.sendMessages(result, channel, adapter, statusMsg.messageId, threadAnchorId, stream);
38
40
  const statusText = askCount > 0
39
- ? `:speech_balloon: ${sessionTag}Waiting for user input (${elapsedStr}${metrics})`
40
- : `:white_check_mark: Done | ${sessionTag}(${elapsedStr}${metrics})`;
41
+ ? `${Icons.waiting} ${sessionTag}${t('status.waitingForUserInput')} (${elapsedStr}${metrics})`
42
+ : `${Icons.ok} ${t('status.done')} | ${sessionTag}(${elapsedStr}${metrics})`;
41
43
  await sealStatus(adapter, statusMsg, statusText, buildSealedStatusActionBlocks(statusText, { channel, sessionName, isDm: true }));
42
44
  if (userMessageTs) {
43
45
  await conversationLedger.completeTurn(channel, userMessageTs, { executionId });
@@ -100,15 +102,16 @@ async function backfillLedgerSessionId(result, channel) {
100
102
  }
101
103
  }
102
104
  // --- Agent error handler ---
103
- export async function handleAgentError({ error, channel, adapter, statusMsg, startTime, executionId, sessionName = null, sessionId = null, effectiveSessionId = null, threadTs = null, userMessageTs = null }) {
104
- runningExecutions.fail(channel, error.message);
105
+ export async function handleAgentError({ error, channel, adapter, statusMsg, startTime, executionId, sessionName = null, sessionId = null, effectiveSessionId = null, threadAnchorId = null, userMessageTs = null }) {
106
+ if (executionId)
107
+ runningExecutions.fail(executionId, error.message);
105
108
  const resolvedSessionId = effectiveSessionId || sessionId;
106
109
  const sessionTag = buildSessionTag(sessionName, resolvedSessionId);
107
110
  const { elapsedStr, elapsedS } = computeElapsed(startTime);
108
111
  if (error?.cancelled && supersededEdits.check(channel)) {
109
112
  supersededEdits.clear(channel);
110
113
  finalizeLocalExecution({ executionId, status: 'cancelled', error, durationS: elapsedS });
111
- const supersededText = `:fast_forward: ${sessionTag}Superseded by edit (${elapsedStr})`;
114
+ const supersededText = `${Icons.superseded} ${sessionTag}${t('status.supersededByEdit')} (${elapsedStr})`;
112
115
  await sealStatus(adapter, statusMsg, supersededText, buildSealedStatusActionBlocks(supersededText, { channel, sessionName, isDm: true }));
113
116
  return;
114
117
  }
@@ -117,21 +120,21 @@ export async function handleAgentError({ error, channel, adapter, statusMsg, sta
117
120
  await conversationLedger.completeTurn(channel, userMessageTs, { executionId });
118
121
  if (error?.cancelled) {
119
122
  finalizeLocalExecution({ executionId, status: 'failed', error, durationS: elapsedS });
120
- const cancelledText = `:octagonal_sign: ${sessionTag}Cancelled (${elapsedStr})`;
123
+ const cancelledText = `${Icons.stopped} ${sessionTag}${t('status.cancelled')} (${elapsedStr})`;
121
124
  await sealStatus(adapter, statusMsg, cancelledText, buildSealedStatusActionBlocks(cancelledText, { channel, sessionName, isDm: true }));
122
125
  return;
123
126
  }
124
127
  log.error('Agent error:', error.message);
125
128
  finalizeLocalExecution({ executionId, status: 'failed', error, durationS: elapsedS });
126
- const errorText = `:x: ${sessionTag}Error (${elapsedStr})`;
129
+ const errorText = `${Icons.error} ${sessionTag}${t('status.error')} (${elapsedStr})`;
127
130
  await sealStatus(adapter, statusMsg, errorText, buildSealedStatusActionBlocks(errorText, { channel, sessionName, isDm: true }));
128
131
  const errorDest = { type: 'interactive-reply', conduit: channel, sessionId: resolvedSessionId ?? '' };
129
132
  const queue = getOutboundQueue();
130
133
  if (queue) {
131
- await durablePost(queue, adapter, errorDest, { text: `Error: ${error.message}` }, threadTs ? { threadId: threadTs } : undefined);
134
+ await durablePost(queue, adapter, errorDest, { text: t('status.errorBody', { message: error.message }) }, threadAnchorId ? { threadId: threadAnchorId } : undefined);
132
135
  }
133
136
  else {
134
- await adapter.postMessage(errorDest, { text: `Error: ${error.message}` }, threadTs ? { threadId: threadTs } : undefined);
137
+ await adapter.postMessage(errorDest, { text: t('status.errorBody', { message: error.message }) }, threadAnchorId ? { threadId: threadAnchorId } : undefined);
135
138
  }
136
139
  }
137
140
  async function persistErrorSession(resolvedSessionId, sessionName, channel, adapter) {
@@ -150,7 +153,7 @@ async function persistErrorSession(resolvedSessionId, sessionName, channel, adap
150
153
  // --- AskUserQuestion resume ---
151
154
  export async function resumeAskUserQuestionGroup({ adapter, group, responseText }) {
152
155
  const askDest = { type: 'interactive-reply', conduit: group.channel, sessionId: group.sessionId };
153
- const statusMsg = await adapter.postMessage(askDest, { text: ':hourglass_flowing_sand: Processing AskUserQuestion response...' });
156
+ const statusMsg = await adapter.postMessage(askDest, { text: `${Icons.processing} ${t('status.processingAskResponse')}` });
154
157
  const startTime = Date.now();
155
158
  let executionId = null;
156
159
  let handle;
@@ -168,9 +171,9 @@ export async function resumeAskUserQuestionGroup({ adapter, group, responseText
168
171
  const askDurable = askQueue ? buildDurableHooks(askQueue) : null;
169
172
  const onAssistantMsg = makeStreamingMessageCallback(adapter, askDest, null, null, askDurable);
170
173
  handle = runAgent(responseText, { channel: group.channel, sessionId: group.sessionId, files: [], project: projectStore.resolveFromMessage(responseText)?.id ?? 'general', trigger: 'ask-user-question', onAssistantMessage: onAssistantMsg });
171
- runningExecutions.register(group.channel, { threadId: group.threadId ?? null, channel: group.channel, agentSlotId: null, executionId, kill: () => handle.kill(), backend: askBackend });
174
+ runningExecutions.register({ threadId: group.threadId ?? null, channel: group.channel, agentSlotId: null, executionId, kill: () => handle.kill(), backend: askBackend });
172
175
  const result = await handle.promise;
173
- runningExecutions.complete(group.channel, result?.total_cost_usd ?? 0);
176
+ runningExecutions.complete(executionId, result?.total_cost_usd ?? 0);
174
177
  await maybeNotifyCodexLowUsage({ adapter, result });
175
178
  await handleAgentSuccess({ result, channel: group.channel, adapter, statusMsg, startTime, userMessage: responseText, executionId, trigger: 'ask-user-question', onAssistantMessage: onAssistantMsg });
176
179
  }
@@ -199,7 +202,7 @@ async function executeRetry(channel, text, adapter, opts) {
199
202
  const sessionName = opts.sessionName || await sessionStore.generateSessionName();
200
203
  const userMessageTs = opts.originalTs;
201
204
  const retryDest = { type: 'interactive-reply', conduit: channel, sessionId: sessionId ?? '' };
202
- const retryPrefix = ':arrows_counterclockwise: Retry (edited) | ';
205
+ const retryPrefix = `${Icons.refresh} ${t('status.retry')} (${t('status.retryEdited')}) | `;
203
206
  const retryStatusText = retryPrefix + buildUserProcessingMessage({ startTime, profileName: getActiveProfile(channel), sessionName, sessionId });
204
207
  const retryBlocksTemplate = { channel, sessionName, isDm: true };
205
208
  const statusMsg = await adapter.postMessage(retryDest, {
@@ -233,14 +236,14 @@ async function runRetryAgent({ channel, text, adapter, statusMsg, startTime, ses
233
236
  isUserInitiated: true, onAssistantMessage: onAssistantMsg,
234
237
  onProgress: buildRetryProgressUpdater(adapter, channel, statusMsg, retryPrefix, startTime, sessionName, sessionId),
235
238
  });
236
- runningExecutions.register(channel, { threadId: null /* A5: edit-retry — threadId not yet wired; Cancel button will warn */, channel, agentSlotId: null, executionId, kill: () => handle.kill(), backend: retryBackend });
239
+ runningExecutions.register({ threadId: null /* A5: edit-retry — threadId not yet wired; Cancel button will warn */, channel, agentSlotId: null, executionId, kill: () => handle.kill(), backend: retryBackend });
237
240
  const result = await handle.promise;
238
- runningExecutions.complete(channel, result?.total_cost_usd ?? 0);
241
+ runningExecutions.complete(executionId, result?.total_cost_usd ?? 0);
239
242
  clearStreamingCallback(channel);
240
243
  await maybeNotifyCodexLowUsage({ adapter, result });
241
244
  if (result?.rateLimited) {
242
245
  const { elapsedStr } = computeElapsed(startTime);
243
- const rateLimitText = `:warning: ${buildSessionTag(sessionName, sessionId)}Rate limited \u2014 all fallbacks exhausted (${elapsedStr})`;
246
+ const rateLimitText = `${Icons.warning} ${buildSessionTag(sessionName, sessionId)}${t('status.rateLimitedExhausted')} (${elapsedStr})`;
244
247
  await sealStatus(adapter, statusMsg, rateLimitText, buildSealedStatusActionBlocks(rateLimitText, { channel, sessionName, isDm: true }));
245
248
  }
246
249
  else {
@@ -263,17 +266,17 @@ function buildRetryProgressUpdater(adapter, channel, statusMsg, retryPrefix, sta
263
266
  }
264
267
  // --- Internal helpers ---
265
268
  function updateRetryPermalinks(adapter, channel, userMessageTs, statusMsg, supersededTimestamps, retryPrefix, startTime, sessionName, sessionId) {
266
- const userPermalinkP = adapter.getPermalink({ channel, messageId: userMessageTs }).catch(() => null);
269
+ const userPermalinkP = adapter.getPermalink({ conduit: channel, messageId: userMessageTs }).catch(() => null);
267
270
  const statusPermalinkP = supersededTimestamps?.length
268
271
  ? adapter.getPermalink(statusMsg).catch(() => null)
269
272
  : Promise.resolve(null);
270
273
  Promise.all([userPermalinkP, statusPermalinkP]).then(([userPermalink, statusPermalink]) => {
271
274
  if (userPermalink) {
272
- writeStatus(adapter, statusMsg, `:arrows_counterclockwise: Retry (<${userPermalink}|edited>) | ` + buildUserProcessingMessage({ startTime, profileName: getActiveProfile(channel), sessionName, sessionId }));
275
+ writeStatus(adapter, statusMsg, `${Icons.refresh} ${t('status.retry')} (<${userPermalink}|${t('status.retryEdited')}>) | ` + buildUserProcessingMessage({ startTime, profileName: getActiveProfile(channel), sessionName, sessionId }));
273
276
  }
274
277
  if (statusPermalink && supersededTimestamps?.length) {
275
278
  for (const oldTs of supersededTimestamps) {
276
- adapter.updateMessage({ channel, messageId: oldTs }, { text: `:fast_forward: Superseded by edit \u2014 <${statusPermalink}|see new reply>` }).catch(() => { });
279
+ adapter.updateMessage({ conduit: channel, messageId: oldTs }, { text: `${Icons.superseded} ${t('status.supersededByEdit')} \u2014 <${statusPermalink}|${t('status.supersededSeeNewReply')}>` }).catch(() => { });
277
280
  }
278
281
  }
279
282
  }).catch(() => { });
@@ -3,7 +3,7 @@ export interface OrchMessageContext {
3
3
  message: IncomingMessage;
4
4
  channel: string;
5
5
  adapter: PlatformAdapter;
6
- threadTs: string | null;
6
+ threadAnchorId: string | null;
7
7
  hasFiles: boolean;
8
8
  userMessage: string;
9
9
  agentMessage: string;
@@ -1,9 +1,28 @@
1
1
  import { createLogger } from '../../../core/log.js';
2
+ import { Icons } from '../../../core/icons.js';
3
+ import { t } from '../../../core/i18n.js';
2
4
  import { runningExecutions } from '../../../core/running-executions.js';
3
- import { channelQueues } from '../../channel-queue.js';
5
+ import { conduitQueues } from '../../conduit-queue.js';
4
6
  import { cancelThread as cancelThreadById } from '../../../domain/threads/index.js';
5
7
  import { setSessionAsync } from '../../../domain/sessions/session.js';
6
8
  import { getActiveBackend } from '../../../domain/agents/index.js';
9
+ import * as executionRegistry from '../../../domain/executions/registry.js';
10
+ /** Cancel one live execution: preserve its session, cancel its thread record, then tear it down as
11
+ * 'cancelled'. teardownExecution sets the persistent record cancelled BEFORE killing the handle, so
12
+ * the kill-error path's failExecution is a terminal no-op — and it publishes a balanced terminal
13
+ * event so agent.started is not left dangling. */
14
+ async function cancelLive(exec, channel) {
15
+ if (exec.sessionId)
16
+ await setSessionAsync(channel, exec.sessionId, getActiveBackend()).catch(() => { });
17
+ if (exec.threadId)
18
+ await cancelThreadById(exec.threadId).catch(() => { });
19
+ if (exec.executionId) {
20
+ executionRegistry.teardownExecution({ executionId: exec.executionId, status: 'cancelled', durationS: 0 });
21
+ }
22
+ else {
23
+ runningExecutions.killById(exec.registryKey);
24
+ }
25
+ }
7
26
  /** Matches thread IDs like `thr_a1b2c3d4`. */
8
27
  const THREAD_ID_RE = /^thr_[0-9a-f]{8}$/;
9
28
  const log = createLogger('cancel');
@@ -11,29 +30,19 @@ const MAX_CANCEL_BUTTONS = 10;
11
30
  export function createCancelHandler(cancelDispatchedTask, router) {
12
31
  if (router) {
13
32
  const cancelHandler = async (ctx) => {
14
- const { threadId, registryKey } = JSON.parse(ctx.value);
33
+ const { threadId, executionId } = JSON.parse(ctx.value);
15
34
  const adapter = router.getAdapter();
16
35
  if (!adapter)
17
36
  return;
18
- if (threadId) {
19
- const exec = runningExecutions.getByThreadId(threadId);
20
- runningExecutions.killByThreadId(threadId);
21
- await cancelThreadById(threadId).catch(() => { });
22
- if (exec?.sessionId) {
23
- await setSessionAsync(ctx.channelId, exec.sessionId, getActiveBackend()).catch(() => { });
24
- }
25
- }
26
- else if (registryKey) {
27
- const exec = runningExecutions.getByKey(registryKey);
28
- if (exec?.sessionId) {
29
- await setSessionAsync(ctx.channelId, exec.sessionId, getActiveBackend()).catch(() => { });
30
- }
31
- runningExecutions.killByKey(registryKey);
32
- }
33
- channelQueues.delete(registryKey || threadId || ctx.channelId);
37
+ const exec = threadId
38
+ ? runningExecutions.getByThreadId(threadId)
39
+ : (executionId ? runningExecutions.getById(executionId) : null);
40
+ if (exec)
41
+ await cancelLive(exec, ctx.channelId);
42
+ conduitQueues.delete(ctx.channelId);
34
43
  if (ctx.messageRef) {
35
44
  await adapter.updateMessage(ctx.messageRef, {
36
- text: `:octagonal_sign: Cancelled (${threadId || registryKey})`,
45
+ text: `${Icons.stopped} ${t('cmd.cancel.cancelledShort', { id: threadId || executionId })}`,
37
46
  }).catch(() => { });
38
47
  }
39
48
  };
@@ -51,43 +60,34 @@ export function createCancelHandler(cancelDispatchedTask, router) {
51
60
  const firstArg = args[0];
52
61
  // --all: kill all running executions in the current channel
53
62
  if (firstArg === '--all') {
54
- const executions = runningExecutions.getAll().filter(e => e.channel === channel);
63
+ const executions = runningExecutions.getByChannel(channel);
55
64
  if (executions.length === 0) {
56
- await adapter.postMessage(dest, { text: 'Nothing running to cancel.' });
65
+ await adapter.postMessage(dest, { text: t('cmd.cancel.nothingRunning') });
57
66
  return;
58
67
  }
59
68
  for (const exec of executions) {
60
- if (exec.threadId) {
61
- await cancelThreadById(exec.threadId).catch(() => { });
62
- }
63
- if (exec.sessionId) {
64
- await setSessionAsync(channel, exec.sessionId, getActiveBackend()).catch(() => { });
65
- }
66
- runningExecutions.killByKey(exec.registryKey);
69
+ await cancelLive(exec, channel);
67
70
  }
68
- channelQueues.delete(channel);
69
- await adapter.postMessage(dest, { text: `:octagonal_sign: Cancelled ${executions.length} execution(s).` });
71
+ conduitQueues.delete(channel);
72
+ await adapter.postMessage(dest, { text: `${Icons.stopped} ${t('cmd.cancel.cancelledN', { n: executions.length })}` });
70
73
  return;
71
74
  }
72
75
  // Thread ID pattern: kill by threadId + cancel thread store record
73
76
  if (THREAD_ID_RE.test(firstArg)) {
74
77
  const exec = runningExecutions.getByThreadId(firstArg);
75
- if (runningExecutions.killByThreadId(firstArg)) {
76
- await cancelThreadById(firstArg).catch(() => { });
77
- if (exec?.sessionId) {
78
- await setSessionAsync(channel, exec.sessionId, getActiveBackend()).catch(() => { });
79
- }
78
+ if (exec) {
79
+ await cancelLive(exec, channel);
80
80
  log.info('Cancel requested for thread:', firstArg);
81
- await adapter.postMessage(dest, { text: `:octagonal_sign: Thread \`${firstArg}\` cancelled.` });
81
+ await adapter.postMessage(dest, { text: `${Icons.stopped} ${t('cmd.cancel.threadCancelled', { id: firstArg })}` });
82
82
  }
83
83
  else {
84
- await adapter.postMessage(dest, { text: `No running thread \`${firstArg}\` found to cancel.` });
84
+ await adapter.postMessage(dest, { text: t('cmd.cancel.threadNotFound', { id: firstArg }) });
85
85
  }
86
86
  return;
87
87
  }
88
88
  // Fallback: dispatched-task cancellation
89
89
  if (!cancelDispatchedTask) {
90
- await adapter.postMessage(dest, { text: 'Dispatched-task cancellation is not available in this process.' });
90
+ await adapter.postMessage(dest, { text: t('cmd.cancel.dispatchUnavailable') });
91
91
  return;
92
92
  }
93
93
  const result = await cancelDispatchedTask({ taskId: firstArg, channel });
@@ -95,7 +95,7 @@ export function createCancelHandler(cancelDispatchedTask, router) {
95
95
  return;
96
96
  }
97
97
  // No args: check how many executions are running on this channel
98
- const executions = runningExecutions.getAll().filter(e => e.channel === channel);
98
+ const executions = runningExecutions.getByChannel(channel);
99
99
  // 0 executions: nothing to cancel
100
100
  if (executions.length === 0) {
101
101
  await adapter.postMessage(dest, { text: 'Nothing running to cancel.' });
@@ -103,32 +103,25 @@ export function createCancelHandler(cancelDispatchedTask, router) {
103
103
  }
104
104
  // 1 execution: cancel directly (existing default behavior)
105
105
  if (executions.length === 1) {
106
- const exec = executions[0];
107
- if (exec.threadId) {
108
- await cancelThreadById(exec.threadId).catch(() => { });
109
- }
110
- runningExecutions.killByKey(exec.registryKey);
111
- if (exec.sessionId) {
112
- await setSessionAsync(channel, exec.sessionId, getActiveBackend()).catch(() => { });
113
- }
114
- channelQueues.delete(channel);
115
- await adapter.postMessage(dest, { text: ':octagonal_sign: Cancelled. Session preserved — next message will resume.' });
106
+ await cancelLive(executions[0], channel);
107
+ conduitQueues.delete(channel);
108
+ await adapter.postMessage(dest, { text: `${Icons.stopped} ${t('cmd.cancel.cancelledSessionPreserved')}` });
116
109
  return;
117
110
  }
118
111
  // 2+ executions: show interactive list with cancel buttons
119
112
  return {
120
- text: `Running tasks (${executions.length}):`,
113
+ text: t('cmd.cancel.runningTasks', { n: executions.length }),
121
114
  richBlocks: executions.map(exec => ({
122
115
  type: 'section',
123
116
  text: `\`${exec.threadId || exec.registryKey}\` · started ${new Date(exec.startTime).toLocaleTimeString()} · ${exec.backend}${exec.channel ? ` · ${exec.channel}` : ''}`,
124
117
  })),
125
118
  actions: executions.map((exec, i) => ({
126
119
  type: 'button',
127
- text: `Cancel ${exec.threadId || exec.registryKey}`,
120
+ text: t('cmd.cancel.cancelButton', { id: exec.threadId || exec.registryKey }),
128
121
  actionId: `cmd:cancel:exec-${i}`,
129
122
  value: JSON.stringify({
130
123
  threadId: exec.threadId,
131
- registryKey: exec.registryKey,
124
+ executionId: exec.executionId,
132
125
  }),
133
126
  style: 'danger',
134
127
  })),
@@ -1,20 +1,34 @@
1
1
  import { projectStore } from '../../../domain/projects/index.js';
2
2
  import { projectDirRepo } from '../../../store/project-dir-repo.js';
3
+ import { Icons } from '../../../core/icons.js';
4
+ import { t } from '../../../core/i18n.js';
3
5
  import { getMachineRegistry } from '../../../domain/tasks/dispatch-utils.js';
6
+ /**
7
+ * Render a (possibly platform-prefixed) conduit for display.
8
+ * Slack channels become a `<#id>` mention; other platforms (Feishu/TUI) show
9
+ * the bare id in code formatting since `<#…>` is Slack-only syntax.
10
+ */
11
+ function displayConduit(conduit) {
12
+ if (conduit.startsWith('slack:'))
13
+ return `<#${conduit.slice('slack:'.length)}>`;
14
+ const colon = conduit.indexOf(':');
15
+ const bare = colon === -1 ? conduit : conduit.slice(colon + 1);
16
+ return `\`${bare}\``;
17
+ }
4
18
  export async function handleProjectsCmd(channel, adapter) {
5
19
  const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
6
20
  const projects = projectStore.list().map(p => p.id);
7
21
  if (projects.length === 0) {
8
- await adapter.postMessage(dest, { text: 'No projects found.' });
22
+ await adapter.postMessage(dest, { text: t('cmd.channel.noProjects') });
9
23
  return;
10
24
  }
11
25
  const registrations = await adapter.getProjectConduits();
12
26
  const lines = projects.map(p => {
13
27
  const ch = registrations[p];
14
- const status = ch ? ` → <#${ch}>` : '';
28
+ const status = ch ? ` → ${displayConduit(ch)}` : '';
15
29
  return `• \`${p}\`${status}`;
16
30
  });
17
- await adapter.postMessage(dest, { text: `*Projects*\n${lines.join('\n')}` });
31
+ await adapter.postMessage(dest, { text: t('cmd.channel.projectsHeader', { list: lines.join('\n') }) });
18
32
  }
19
33
  const MAX_PROJECT_BUTTONS = 10;
20
34
  export function createRegisterHandler(router) {
@@ -28,7 +42,7 @@ export function createRegisterHandler(router) {
28
42
  await adapter.bindProjectConduit(project, ctx.channelId);
29
43
  if (ctx.messageRef) {
30
44
  await adapter.updateMessage(ctx.messageRef, {
31
- text: `:white_check_mark: Registered for \`${project}\` task notifications.`,
45
+ text: `${Icons.ok} ${t('cmd.channel.registeredNotification', { project })}`,
32
46
  }).catch(() => { });
33
47
  }
34
48
  }
@@ -48,11 +62,11 @@ export function createRegisterHandler(router) {
48
62
  const project = args[0];
49
63
  const projects = projectStore.list().map(p => p.id);
50
64
  if (!projects.includes(project)) {
51
- await adapter.postMessage(dest, { text: `:x: Unknown project: \`${project}\`\nAvailable: ${projects.map(p => `\`${p}\``).join(', ')}` });
65
+ await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.channel.unknownProject', { project, available: projects.map(p => `\`${p}\``).join(', ') })}` });
52
66
  return;
53
67
  }
54
68
  await adapter.bindProjectConduit(project, channel);
55
- await adapter.postMessage(dest, { text: `:white_check_mark: This channel is now registered for project \`${project}\` task notifications.` });
69
+ await adapter.postMessage(dest, { text: `${Icons.ok} ${t('cmd.channel.channelRegistered', { project })}` });
56
70
  return;
57
71
  }
58
72
  const registrations = await adapter.getProjectConduits();
@@ -61,13 +75,13 @@ export function createRegisterHandler(router) {
61
75
  const unbound = projects.filter(p => !bound.includes(p));
62
76
  const lines = [];
63
77
  if (bound.length > 0) {
64
- lines.push(`Registered: ${bound.map(p => `\`${p}\``).join(', ')}`);
78
+ lines.push(t('cmd.channel.registeredList', { list: bound.map(p => `\`${p}\``).join(', ') }));
65
79
  }
66
80
  else {
67
- lines.push('This channel is not registered to any project.');
81
+ lines.push(t('cmd.channel.notRegisteredAny'));
68
82
  }
69
83
  if (unbound.length > 0) {
70
- lines.push(`Available: ${unbound.map(p => `\`${p}\``).join(', ')}`);
84
+ lines.push(t('cmd.channel.availableList', { list: unbound.map(p => `\`${p}\``).join(', ') }));
71
85
  }
72
86
  const text = lines.join('\n');
73
87
  if (!router || unbound.length === 0) {
@@ -96,33 +110,33 @@ export async function handleUnregisterCmd(channel, adapter, trimmedMessage) {
96
110
  const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
97
111
  const args = trimmedMessage.split(/\s+/).slice(1);
98
112
  if (args.length === 0) {
99
- await adapter.postMessage(dest, { text: 'Usage: `!unregister <project>`' });
113
+ await adapter.postMessage(dest, { text: t('cmd.channel.unregisterUsage') });
100
114
  return;
101
115
  }
102
116
  const project = args[0];
103
117
  const registrations = await adapter.getProjectConduits();
104
118
  const current = registrations[project] ?? null;
105
119
  if (!current || current !== channel) {
106
- await adapter.postMessage(dest, { text: `:x: This channel is not registered for project \`${project}\`.` });
120
+ await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.channel.notRegistered', { project })}` });
107
121
  return;
108
122
  }
109
123
  await adapter.unbindProjectConduit(project);
110
- await adapter.postMessage(dest, { text: `:white_check_mark: Unregistered this channel from project \`${project}\`.` });
124
+ await adapter.postMessage(dest, { text: `${Icons.ok} ${t('cmd.channel.unregistered', { project })}` });
111
125
  }
112
126
  function buildProjectDirModal(channel) {
113
127
  const machines = Object.keys(getMachineRegistry());
114
128
  return {
115
129
  callbackId: 'cmd_project_dir_add',
116
- title: 'Add Project Directory',
117
- submitLabel: 'Save',
130
+ title: t('cmd.channel.modalTitle'),
131
+ submitLabel: t('cmd.channel.modalSubmit'),
118
132
  privateMetadata: JSON.stringify({ channel }),
119
133
  fields: [
120
- { type: 'text_input', blockId: 'pd_project', label: 'Project name', actionId: 'text', placeholder: 'e.g. example-project-dataset' },
134
+ { type: 'text_input', blockId: 'pd_project', label: t('cmd.channel.modalProjectLabel'), actionId: 'text', placeholder: t('cmd.channel.modalProjectPlaceholder') },
121
135
  {
122
- type: 'select', blockId: 'pd_machine', label: 'Machine', actionId: 'selection',
136
+ type: 'select', blockId: 'pd_machine', label: t('cmd.channel.modalMachineLabel'), actionId: 'selection',
123
137
  options: machines.map(m => ({ label: m, value: m })),
124
138
  },
125
- { type: 'text_input', blockId: 'pd_path', label: 'Directory path', actionId: 'text', placeholder: 'e.g. /home/user/project' },
139
+ { type: 'text_input', blockId: 'pd_path', label: t('cmd.channel.modalPathLabel'), actionId: 'text', placeholder: t('cmd.channel.modalPathPlaceholder') },
126
140
  ],
127
141
  };
128
142
  }
@@ -154,7 +168,7 @@ export function createProjectDirHandler(router) {
154
168
  return;
155
169
  await projectDirRepo.setProjectDir(project, machine, dirPath);
156
170
  await adapter.postMessage(modalDest, {
157
- text: `:white_check_mark: \`${project}\` on \`${machine}\` → \`${dirPath}\``,
171
+ text: `${Icons.ok} ${t('cmd.channel.dirSet', { project, machine, dir: dirPath })}`,
158
172
  });
159
173
  },
160
174
  }],
@@ -165,42 +179,42 @@ export function createProjectDirHandler(router) {
165
179
  const args = trimmedMessage.split(/\s+/).slice(1);
166
180
  if (args.length > 0) {
167
181
  if (args.length < 2) {
168
- await adapter.postMessage(dest, { text: ':x: Usage: `!project-dir <project> <machine> <path>` or `!project-dir <project> <machine> --remove`' });
182
+ await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.channel.projectDirUsage')}` });
169
183
  return;
170
184
  }
171
185
  const [project, machine] = args;
172
186
  const validMachines = Object.keys(getMachineRegistry());
173
187
  if (!validMachines.includes(machine)) {
174
- await adapter.postMessage(dest, { text: `:x: Unknown machine: \`${machine}\`\nValid: ${validMachines.map(m => `\`${m}\``).join(', ')}` });
188
+ await adapter.postMessage(dest, { text: `${Icons.error} ${t('cmd.channel.unknownMachine', { machine, valid: validMachines.map(m => `\`${m}\``).join(', ') })}` });
175
189
  return;
176
190
  }
177
191
  if (args.length === 2 || args[2] === '--remove') {
178
192
  if (args[2] === '--remove') {
179
193
  await projectDirRepo.removeProjectDir(project, machine);
180
- await adapter.postMessage(dest, { text: `:white_check_mark: Removed \`${project}\` directory on \`${machine}\`.` });
194
+ await adapter.postMessage(dest, { text: `${Icons.ok} ${t('cmd.channel.dirRemoved', { project, machine })}` });
181
195
  }
182
196
  else {
183
197
  const dir = await projectDirRepo.getProjectDir(project, machine);
184
198
  if (dir) {
185
- await adapter.postMessage(dest, { text: `\`${project}\` on \`${machine}\` → \`${dir}\`` });
199
+ await adapter.postMessage(dest, { text: t('cmd.channel.dirShow', { project, machine, dir }) });
186
200
  }
187
201
  else {
188
- await adapter.postMessage(dest, { text: `No directory registered for \`${project}\` on \`${machine}\`.` });
202
+ await adapter.postMessage(dest, { text: t('cmd.channel.dirNone', { project, machine }) });
189
203
  }
190
204
  }
191
205
  return;
192
206
  }
193
207
  const dirPath = args.slice(2).join(' ');
194
208
  await projectDirRepo.setProjectDir(project, machine, dirPath);
195
- await adapter.postMessage(dest, { text: `:white_check_mark: \`${project}\` on \`${machine}\` → \`${dirPath}\`` });
209
+ await adapter.postMessage(dest, { text: `${Icons.ok} ${t('cmd.channel.dirSet', { project, machine, dir: dirPath })}` });
196
210
  return;
197
211
  }
198
212
  const allDirs = await projectDirRepo.getAllProjectDirs();
199
213
  const entries = Object.entries(allDirs);
200
214
  const lines = entries.length > 0
201
215
  ? entries.flatMap(([project, machines]) => Object.entries(machines).map(([machine, dir]) => `• \`${project}\` on \`${machine}\` → \`${dir}\``))
202
- : ['No project directories registered.'];
203
- const text = `*Project Directories*\n${lines.join('\n')}`;
216
+ : [t('cmd.channel.noProjectDirs')];
217
+ const text = t('cmd.channel.projectDirsHeader', { list: lines.join('\n') });
204
218
  if (!router) {
205
219
  await adapter.postMessage(dest, { text });
206
220
  return;
@@ -210,7 +224,7 @@ export function createProjectDirHandler(router) {
210
224
  richBlocks: [{ type: 'section', text }],
211
225
  actions: [{
212
226
  type: 'button',
213
- text: 'Add',
227
+ text: t('cmd.channel.addButton'),
214
228
  actionId: 'cmd:project-dir:open-add',
215
229
  value: 'add',
216
230
  style: 'primary',
@@ -1,4 +1,6 @@
1
1
  import { formatCostReport, checkBudget, setBudget } from '../../../domain/costs/cost-tracker.js';
2
+ import { Icons } from '../../../core/icons.js';
3
+ import { t } from '../../../core/i18n.js';
2
4
  export async function handleCostCmd(channel, adapter, trimmedMessage) {
3
5
  const dest = { type: 'interactive-reply', conduit: channel, sessionId: '' };
4
6
  const project = trimmedMessage.split(/\s+/).slice(1).join(' ').trim() || null;
@@ -10,7 +12,14 @@ export async function handleBudgetCmd(channel, adapter, trimmedMessage) {
10
12
  if (args.length === 0) {
11
13
  const b = await checkBudget();
12
14
  await adapter.postMessage(dest, {
13
- text: `*Budget*\n• Daily: $${b.dailyBudget} (spent: $${b.dailySpent.toFixed(2)}, remaining: $${b.dailyRemaining.toFixed(2)})\n• Monthly: $${b.monthlyBudget} (spent: $${b.monthlySpent.toFixed(2)}, remaining: $${b.monthlyRemaining.toFixed(2)})`,
15
+ text: t('cmd.cost.budgetHeader', {
16
+ dailyBudget: b.dailyBudget,
17
+ dailySpent: b.dailySpent.toFixed(2),
18
+ dailyRemaining: b.dailyRemaining.toFixed(2),
19
+ monthlyBudget: b.monthlyBudget,
20
+ monthlySpent: b.monthlySpent.toFixed(2),
21
+ monthlyRemaining: b.monthlyRemaining.toFixed(2),
22
+ }),
14
23
  });
15
24
  return;
16
25
  }
@@ -20,5 +29,5 @@ export async function handleBudgetCmd(channel, adapter, trimmedMessage) {
20
29
  daily_usd: daily ? parseFloat(daily) : undefined,
21
30
  monthly_usd: monthly ? parseFloat(monthly) : undefined,
22
31
  });
23
- await adapter.postMessage(dest, { text: `:white_check_mark: Budget updated: $${result.daily_usd}/day, $${result.monthly_usd}/month` });
32
+ await adapter.postMessage(dest, { text: `${Icons.ok} ${t('cmd.cost.budgetUpdated', { daily: result.daily_usd, monthly: result.monthly_usd })}` });
24
33
  }
@@ -1,5 +1,7 @@
1
1
  import { getOnlineDevices } from '../../../domain/remote/client-manager.js';
2
2
  import { getMachineRegistry } from '../../../domain/tasks/dispatch-utils.js';
3
+ import { Icons } from '../../../core/icons.js';
4
+ import { t } from '../../../core/i18n.js';
3
5
  function formatTimeAgo(ms) {
4
6
  const seconds = Math.floor(ms / 1000);
5
7
  if (seconds < 60)
@@ -19,29 +21,30 @@ function buildDevicesText() {
19
21
  for (const d of onlineDevices)
20
22
  knownNames.add(d.device);
21
23
  const now = Date.now();
22
- const lines = ['*Devices*'];
24
+ const lines = [t('cmd.device.header')];
23
25
  for (const name of [...knownNames].sort()) {
24
26
  const online = onlineDevices.find(d => d.device === name);
25
27
  if (online) {
26
28
  const connAgo = formatTimeAgo(now - online.connectedAt.getTime());
27
29
  const hbAgo = formatTimeAgo(now - online.lastHeartbeat.getTime());
28
- lines.push(`:white_check_mark: \`${name}\` ${online.platform} connected ${connAgo} heartbeat ${hbAgo}`);
30
+ lines.push(`${Icons.ok} ${t('cmd.device.online', { name, platform: online.platform, connAgo, hbAgo })}`);
29
31
  }
30
32
  else {
31
- lines.push(`:x: \`${name}\` offline`);
33
+ lines.push(`${Icons.error} ${t('cmd.device.offline', { name })}`);
32
34
  }
33
35
  }
34
36
  if (knownNames.size === 0) {
35
- lines.push('No devices registered or online.');
37
+ lines.push(t('cmd.device.none'));
36
38
  }
37
39
  return lines.join('\n');
38
40
  }
39
- const REFRESH_BUTTON = {
41
+ // Built per call so the label is resolved in the active locale (not frozen at import time).
42
+ const refreshButton = () => ({
40
43
  type: 'button',
41
- text: 'Refresh',
44
+ text: t('cmd.device.refreshButton'),
42
45
  actionId: 'cmd:devices:refresh',
43
46
  value: 'refresh',
44
- };
47
+ });
45
48
  export function createDevicesHandler(router) {
46
49
  if (router) {
47
50
  router.registerCommand('devices', {
@@ -56,7 +59,7 @@ export function createDevicesHandler(router) {
56
59
  text,
57
60
  richBlocks: [
58
61
  { type: 'section', text },
59
- { type: 'actions', elements: [REFRESH_BUTTON] },
62
+ { type: 'actions', elements: [refreshButton()] },
60
63
  ],
61
64
  }).catch(() => { });
62
65
  },
@@ -73,7 +76,7 @@ export function createDevicesHandler(router) {
73
76
  return {
74
77
  text,
75
78
  richBlocks: [{ type: 'section', text }],
76
- actions: [REFRESH_BUTTON],
79
+ actions: [refreshButton()],
77
80
  };
78
81
  };
79
82
  }