@cortex-agent/server 2026.7.30 → 2026.8.3-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. package/README.md +1 -1
  2. package/defaults/CORTEX.md +1 -0
  3. package/defaults/config/CORTEX.md +2 -1
  4. package/defaults/config/hooks/13-status-md-guard.json +11 -0
  5. package/defaults/config/hooks/CORTEX.md +1 -0
  6. package/defaults/config/mcp-config-empty.json +3 -0
  7. package/defaults/config/thread-templates/agents/benchmark-coder.json +22 -0
  8. package/defaults/config/thread-templates/agents/benchmark-reviewer.json +22 -0
  9. package/defaults/config/thread-templates/agents/coder-reviewer.json +4 -9
  10. package/defaults/config/thread-templates/agents/coder.json +4 -14
  11. package/defaults/config/thread-templates/templates/benchmark-coder-review.json +37 -0
  12. package/defaults/config/thread-templates/templates/coder-review.json +3 -27
  13. package/defaults/context/projects/CORTEX.md +1 -1
  14. package/defaults/data/schedules.json +12 -0
  15. package/defaults/hooks/CORTEX.md +1 -0
  16. package/defaults/hooks/new-session-hook.mjs +2 -2
  17. package/defaults/hooks/status-md-guard.mjs +193 -0
  18. package/defaults/plugins/cortex-coder/.claude-plugin/plugin.json +1 -1
  19. package/defaults/plugins/cortex-coder/skills/develop/SKILL.md +28 -2
  20. package/defaults/plugins/cortex-common/.claude-plugin/plugin.json +1 -1
  21. package/defaults/plugins/cortex-common/skills/compound/SKILL.md +1 -1
  22. package/defaults/plugins/cortex-common/skills/compound-simple/SKILL.md +4 -2
  23. package/defaults/plugins/cortex-common/skills/postmortem/SKILL.md +1 -1
  24. package/defaults/plugins/cortex-stage-gate/.claude-plugin/plugin.json +1 -1
  25. package/defaults/plugins/cortex-stage-gate/skills/director-method/SKILL.md +1 -1
  26. package/defaults/plugins/cortex-stage-gate/skills/need-approval/SKILL.md +1 -0
  27. package/defaults/plugins/cortex-stage-gate/skills/reorient/SKILL.md +2 -2
  28. package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +11 -8
  29. package/defaults/plugins/cortex-system/skills/feedback/SKILL.md +1 -1
  30. package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +13 -16
  31. package/defaults/prompts/directives/coder-reviewer.md +24 -20
  32. package/defaults/prompts/directives/coder.md +4 -5
  33. package/defaults/prompts/directives/director.md +4 -10
  34. package/defaults/prompts/directives/manager.md +9 -10
  35. package/defaults/prompts/systemPrompts/worker.md +2 -2
  36. package/defaults/rules/cortex-md.md +31 -0
  37. package/defaults/rules/experiment-format.md +8 -1
  38. package/defaults/rules/issues-md.md +10 -9
  39. package/defaults/rules/meta-conventions.md +5 -4
  40. package/defaults/rules/mission-md.md +2 -1
  41. package/defaults/rules/status-md.md +39 -21
  42. package/dist/agent-adapter/bg-wait.d.ts +10 -12
  43. package/dist/agent-adapter/bg-wait.js +209 -129
  44. package/dist/agent-adapter/claude/adapter-tui.d.ts +3 -1
  45. package/dist/agent-adapter/claude/adapter-tui.js +8 -5
  46. package/dist/agent-adapter/claude/adapter.d.ts +43 -14
  47. package/dist/agent-adapter/claude/adapter.js +276 -161
  48. package/dist/agent-adapter/claude/defaults.d.ts +2 -0
  49. package/dist/agent-adapter/claude/defaults.js +5 -5
  50. package/dist/agent-adapter/claude/event-parser.d.ts +3 -8
  51. package/dist/agent-adapter/claude/event-parser.js +28 -31
  52. package/dist/agent-adapter/claude/hooks-builder.js +4 -3
  53. package/dist/agent-adapter/claude/jsonl-tail.js +54 -35
  54. package/dist/agent-adapter/claude/spawn-args.d.ts +15 -12
  55. package/dist/agent-adapter/claude/spawn-args.js +44 -38
  56. package/dist/agent-adapter/claude/tmux-control.d.ts +4 -17
  57. package/dist/agent-adapter/claude/tmux-control.js +39 -32
  58. package/dist/agent-adapter/event-tee.d.ts +19 -0
  59. package/dist/agent-adapter/event-tee.js +145 -0
  60. package/dist/agent-adapter/index.d.ts +1 -0
  61. package/dist/agent-adapter/index.js +7 -3
  62. package/dist/agent-adapter/normalize/event-types.d.ts +17 -9
  63. package/dist/agent-adapter/normalize/event-types.js +4 -4
  64. package/dist/agent-adapter/pi/adapter.d.ts +16 -4
  65. package/dist/agent-adapter/pi/adapter.js +69 -36
  66. package/dist/agent-adapter/pi/discovery.d.ts +19 -3
  67. package/dist/agent-adapter/pi/discovery.js +81 -43
  68. package/dist/agent-adapter/pi/event-parser.js +4 -2
  69. package/dist/agent-adapter/pi/spawn-args.d.ts +2 -4
  70. package/dist/agent-adapter/pi/spawn-args.js +6 -5
  71. package/dist/agent-adapter/types.d.ts +43 -2
  72. package/dist/agent-adapter/types.js +8 -4
  73. package/dist/core/atomic-write.d.ts +6 -1
  74. package/dist/core/atomic-write.js +183 -7
  75. package/dist/core/cli-utils.d.ts +15 -2
  76. package/dist/core/cli-utils.js +46 -41
  77. package/dist/core/config-generator.d.ts +4 -0
  78. package/dist/core/config-generator.js +34 -21
  79. package/dist/core/json-repository.d.ts +4 -0
  80. package/dist/core/json-repository.js +6 -3
  81. package/dist/core/locales/en.d.ts +94 -0
  82. package/dist/core/locales/slices/commands.d.ts +76 -0
  83. package/dist/core/locales/slices/commands.js +155 -1
  84. package/dist/core/locales/slices/status.d.ts +18 -0
  85. package/dist/core/locales/slices/status.js +43 -2
  86. package/dist/core/log.d.ts +5 -0
  87. package/dist/core/log.js +25 -23
  88. package/dist/core/pi-session-filename.d.ts +2 -0
  89. package/dist/core/pi-session-filename.js +18 -0
  90. package/dist/core/resume-reminder.d.ts +5 -0
  91. package/dist/core/resume-reminder.js +18 -0
  92. package/dist/core/runtime-env.d.ts +1 -0
  93. package/dist/core/runtime-env.js +15 -0
  94. package/dist/core/settings-migration.d.ts +5 -0
  95. package/dist/core/settings-migration.js +128 -0
  96. package/dist/core/settings-spec.d.ts +174 -0
  97. package/dist/core/settings-spec.js +150 -0
  98. package/dist/core/settings.d.ts +10 -0
  99. package/dist/core/settings.js +235 -0
  100. package/dist/core/task-parser.d.ts +11 -1
  101. package/dist/core/task-parser.js +34 -3
  102. package/dist/core/types/agent-types.d.ts +19 -0
  103. package/dist/core/types/agent-types.js +1 -1
  104. package/dist/core/types/thread-types.d.ts +48 -3
  105. package/dist/core/types/thread-types.js +2 -2
  106. package/dist/core/utils.d.ts +21 -1
  107. package/dist/core/utils.js +37 -1
  108. package/dist/domain/agent-run/access-probe-cli.d.ts +7 -0
  109. package/dist/domain/agent-run/access-probe-cli.js +139 -0
  110. package/dist/domain/agent-run/access-probe-policy.d.ts +61 -0
  111. package/dist/domain/agent-run/access-probe-policy.js +614 -0
  112. package/dist/domain/agent-run/access-probe.d.ts +21 -0
  113. package/dist/domain/agent-run/access-probe.js +194 -0
  114. package/dist/domain/agent-run/agent-run-cli.d.ts +19 -0
  115. package/dist/domain/agent-run/agent-run-cli.js +171 -0
  116. package/dist/domain/agent-run/atif.d.ts +54 -0
  117. package/dist/domain/agent-run/atif.js +211 -0
  118. package/dist/domain/agent-run/benchmark-local-thread-orchestrator.d.ts +32 -0
  119. package/dist/domain/agent-run/benchmark-local-thread-orchestrator.js +616 -0
  120. package/dist/domain/agent-run/benchmark-thread-identity.d.ts +34 -0
  121. package/dist/domain/agent-run/benchmark-thread-identity.js +106 -0
  122. package/dist/domain/agent-run/identity.d.ts +62 -0
  123. package/dist/domain/agent-run/identity.js +118 -0
  124. package/dist/domain/agent-run/journal.d.ts +51 -0
  125. package/dist/domain/agent-run/journal.js +259 -0
  126. package/dist/domain/agent-run/manifest-contract.d.ts +44 -0
  127. package/dist/domain/agent-run/manifest-contract.js +134 -0
  128. package/dist/domain/agent-run/manifest.d.ts +51 -0
  129. package/dist/domain/agent-run/manifest.js +801 -0
  130. package/dist/domain/agent-run/pinned-node-process.d.ts +35 -0
  131. package/dist/domain/agent-run/pinned-node-process.js +206 -0
  132. package/dist/domain/agent-run/role-surface.d.ts +4 -0
  133. package/dist/domain/agent-run/role-surface.js +99 -0
  134. package/dist/domain/agent-run/run-config.d.ts +22 -0
  135. package/dist/domain/agent-run/run-config.js +135 -0
  136. package/dist/domain/agent-run/runner.d.ts +7 -0
  137. package/dist/domain/agent-run/runner.js +518 -0
  138. package/dist/domain/agent-run/supervisor.d.ts +78 -0
  139. package/dist/domain/agent-run/supervisor.js +425 -0
  140. package/dist/domain/agent-run/trajectory-merge-cli.d.ts +11 -0
  141. package/dist/domain/agent-run/trajectory-merge-cli.js +111 -0
  142. package/dist/domain/agent-run/trajectory-merge.d.ts +39 -0
  143. package/dist/domain/agent-run/trajectory-merge.js +505 -0
  144. package/dist/domain/agents/config.d.ts +10 -0
  145. package/dist/domain/agents/config.js +149 -44
  146. package/dist/domain/agents/facade.d.ts +42 -7
  147. package/dist/domain/agents/facade.js +174 -170
  148. package/dist/domain/agents/provider-run-lifecycle.d.ts +18 -0
  149. package/dist/domain/agents/provider-run-lifecycle.js +60 -0
  150. package/dist/domain/auth/auth-events.d.ts +18 -0
  151. package/dist/domain/auth/auth-events.js +38 -0
  152. package/dist/domain/auth/auth-format.d.ts +2 -0
  153. package/dist/domain/auth/auth-format.js +58 -0
  154. package/dist/domain/auth/auth-status.d.ts +61 -0
  155. package/dist/domain/auth/auth-status.js +304 -0
  156. package/dist/domain/auth/auth-watch.d.ts +16 -0
  157. package/dist/domain/auth/auth-watch.js +125 -0
  158. package/dist/domain/auth/cc-login.d.ts +7 -0
  159. package/dist/domain/auth/cc-login.js +16 -0
  160. package/dist/domain/auth/cc-subscription.d.ts +38 -0
  161. package/dist/domain/auth/cc-subscription.js +204 -0
  162. package/dist/domain/auth/index.d.ts +12 -0
  163. package/dist/domain/auth/index.js +16 -0
  164. package/dist/domain/auth/login-flow.d.ts +120 -0
  165. package/dist/domain/auth/login-flow.js +253 -0
  166. package/dist/domain/auth/login-service.d.ts +32 -0
  167. package/dist/domain/auth/login-service.js +97 -0
  168. package/dist/domain/auth/logout.d.ts +32 -0
  169. package/dist/domain/auth/logout.js +123 -0
  170. package/dist/domain/auth/pi-login.d.ts +36 -0
  171. package/dist/domain/auth/pi-login.js +72 -0
  172. package/dist/domain/auth/pi-oauth.d.ts +36 -0
  173. package/dist/domain/auth/pi-oauth.js +84 -0
  174. package/dist/domain/auth/pi-runtime.d.ts +72 -0
  175. package/dist/domain/auth/pi-runtime.js +86 -0
  176. package/dist/domain/mcp/benchmark-thread-server.d.ts +1 -0
  177. package/dist/domain/mcp/benchmark-thread-server.js +26 -0
  178. package/dist/domain/mcp/tools/benchmark-thread-run.d.ts +23 -0
  179. package/dist/domain/mcp/tools/benchmark-thread-run.js +146 -0
  180. package/dist/domain/memory/user-context.js +6 -8
  181. package/dist/domain/monitor/disk-monitor.js +47 -16
  182. package/dist/domain/projects/project-store.js +23 -6
  183. package/dist/domain/remote/client-hot-reload.d.ts +9 -1
  184. package/dist/domain/remote/client-hot-reload.js +60 -12
  185. package/dist/domain/remote/client-manager.js +12 -6
  186. package/dist/domain/scheduling/jobs/auth-expiry-scan.d.ts +14 -0
  187. package/dist/domain/scheduling/jobs/auth-expiry-scan.js +86 -0
  188. package/dist/domain/scheduling/jobs/task-dispatch.js +36 -40
  189. package/dist/domain/scheduling/runner.d.ts +2 -0
  190. package/dist/domain/scheduling/runner.js +7 -4
  191. package/dist/domain/sessions/session-backup.d.ts +14 -20
  192. package/dist/domain/sessions/session-backup.js +57 -68
  193. package/dist/domain/system/doctor.d.ts +4 -0
  194. package/dist/domain/system/doctor.js +113 -28
  195. package/dist/domain/system/install-cli.js +8 -3
  196. package/dist/domain/system/server-update-check.js +7 -5
  197. package/dist/domain/system/system-notice.d.ts +3 -1
  198. package/dist/domain/system/system-notice.js +6 -11
  199. package/dist/domain/tasks/archiver.d.ts +1 -0
  200. package/dist/domain/tasks/archiver.js +13 -7
  201. package/dist/domain/tasks/claim-recovery.d.ts +3 -3
  202. package/dist/domain/tasks/claim-recovery.js +12 -8
  203. package/dist/domain/tasks/dispatch-utils.d.ts +15 -14
  204. package/dist/domain/tasks/dispatch-utils.js +22 -18
  205. package/dist/domain/tasks/dispatcher.d.ts +1 -0
  206. package/dist/domain/tasks/dispatcher.js +9 -5
  207. package/dist/domain/tasks/mutator.d.ts +21 -11
  208. package/dist/domain/tasks/mutator.js +30 -24
  209. package/dist/domain/tasks/pending-tracker.d.ts +5 -2
  210. package/dist/domain/tasks/pending-tracker.js +11 -5
  211. package/dist/domain/tasks/system/cortex-run.d.ts +2 -1
  212. package/dist/domain/tasks/system/cortex-run.js +24 -4
  213. package/dist/domain/tasks/system/task-cli.d.ts +1 -0
  214. package/dist/domain/tasks/system/task-cli.js +72 -22
  215. package/dist/domain/tasks/system/task-completion.d.ts +19 -2
  216. package/dist/domain/tasks/system/task-completion.js +31 -17
  217. package/dist/domain/tasks/system/task-file-input.d.ts +10 -0
  218. package/dist/domain/tasks/system/task-file-input.js +57 -0
  219. package/dist/domain/tasks/system/task-id-utils.d.ts +9 -9
  220. package/dist/domain/tasks/system/task-id-utils.js +13 -4
  221. package/dist/domain/tasks/system/task-lifecycle-edit.d.ts +6 -2
  222. package/dist/domain/tasks/system/task-lifecycle-edit.js +200 -6
  223. package/dist/domain/tasks/system/task-lock.js +19 -5
  224. package/dist/domain/tasks/system/task-mutations.d.ts +22 -12
  225. package/dist/domain/tasks/system/task-mutations.js +28 -4
  226. package/dist/domain/tasks/system/task-process.js +10 -8
  227. package/dist/domain/tasks/system/task-state.d.ts +65 -11
  228. package/dist/domain/tasks/system/task-state.js +86 -13
  229. package/dist/domain/threads/local-runtime-deps.d.ts +32 -0
  230. package/dist/domain/threads/local-runtime-deps.js +91 -0
  231. package/dist/domain/threads/local-runtime-scope.d.ts +6 -0
  232. package/dist/domain/threads/local-runtime-scope.js +12 -0
  233. package/dist/domain/threads/pending-user-inputs.d.ts +3 -0
  234. package/dist/domain/threads/pending-user-inputs.js +37 -0
  235. package/dist/domain/threads/prompt-builder.d.ts +12 -1
  236. package/dist/domain/threads/prompt-builder.js +73 -26
  237. package/dist/domain/threads/runner.d.ts +15 -3
  238. package/dist/domain/threads/runner.js +261 -105
  239. package/dist/domain/threads/state-machine.d.ts +1 -1
  240. package/dist/domain/threads/state-machine.js +17 -8
  241. package/dist/domain/ui-service/app-router.d.ts +86 -6
  242. package/dist/domain/ui-service/app-router.js +171 -133
  243. package/dist/domain/ui-service/input-schemas.d.ts +132 -10
  244. package/dist/domain/ui-service/input-schemas.js +59 -5
  245. package/dist/domain/ui-service/mutate/approvals.d.ts +2 -1
  246. package/dist/domain/ui-service/mutate/approvals.js +2 -1
  247. package/dist/domain/ui-service/mutate/auth.d.ts +6 -0
  248. package/dist/domain/ui-service/mutate/auth.js +83 -0
  249. package/dist/domain/ui-service/mutate/config.js +11 -10
  250. package/dist/domain/ui-service/query/approvals.js +3 -0
  251. package/dist/domain/ui-service/query/auth.d.ts +6 -0
  252. package/dist/domain/ui-service/query/auth.js +12 -0
  253. package/dist/domain/ui-service/query/config.d.ts +5 -5
  254. package/dist/domain/ui-service/query/config.js +27 -17
  255. package/dist/domain/ui-service/query/tasks.d.ts +1 -1
  256. package/dist/domain/ui-service/query/tasks.js +69 -30
  257. package/dist/domain/ui-service/query/threads.js +3 -3
  258. package/dist/domain/ui-service/types.d.ts +67 -8
  259. package/dist/domain/ui-service/types.js +2 -2
  260. package/dist/domain/ui-service/ui-service.js +16 -2
  261. package/dist/entry/admin-channel-hot-reload.d.ts +4 -0
  262. package/dist/entry/admin-channel-hot-reload.js +22 -0
  263. package/dist/entry/app.js +38 -38
  264. package/dist/entry/auth-cli.d.ts +10 -0
  265. package/dist/entry/auth-cli.js +52 -0
  266. package/dist/entry/cli-help.d.ts +5 -0
  267. package/dist/entry/cli-help.js +130 -0
  268. package/dist/entry/cli.d.ts +5 -5
  269. package/dist/entry/cli.js +174 -248
  270. package/dist/entry/daemon.d.ts +11 -0
  271. package/dist/entry/daemon.js +204 -103
  272. package/dist/entry/draft-attachments.d.ts +8 -0
  273. package/dist/entry/draft-attachments.js +83 -0
  274. package/dist/entry/feishu-login.d.ts +2 -6
  275. package/dist/entry/feishu-login.js +16 -21
  276. package/dist/entry/init.js +6 -4
  277. package/dist/entry/start-ui-http.d.ts +2 -8
  278. package/dist/entry/start-ui-http.js +7 -34
  279. package/dist/events/event-logger.js +11 -13
  280. package/dist/events/event-types.d.ts +19 -1
  281. package/dist/events/event-types.js +3 -3
  282. package/dist/events/index.d.ts +1 -1
  283. package/dist/events/index.js +3 -3
  284. package/dist/hooks/new-session-hook.mjs +2 -2
  285. package/dist/hooks/status-md-guard.mjs +193 -0
  286. package/dist/orchestration/agent-file-send.js +44 -14
  287. package/dist/orchestration/agent-runner.d.ts +7 -3
  288. package/dist/orchestration/agent-runner.js +65 -41
  289. package/dist/orchestration/conversation-runner.d.ts +5 -1
  290. package/dist/orchestration/conversation-runner.js +16 -7
  291. package/dist/orchestration/lifecycle.d.ts +23 -1
  292. package/dist/orchestration/lifecycle.js +103 -40
  293. package/dist/orchestration/mid-turn-inject.d.ts +2 -0
  294. package/dist/orchestration/mid-turn-inject.js +29 -13
  295. package/dist/orchestration/resume-dispatcher.d.ts +3 -5
  296. package/dist/orchestration/resume-dispatcher.js +9 -17
  297. package/dist/orchestration/routing/commands/index.d.ts +4 -1
  298. package/dist/orchestration/routing/commands/index.js +83 -61
  299. package/dist/orchestration/routing/commands/login-notice.d.ts +21 -0
  300. package/dist/orchestration/routing/commands/login-notice.js +97 -0
  301. package/dist/orchestration/routing/commands/login.d.ts +12 -0
  302. package/dist/orchestration/routing/commands/login.js +555 -0
  303. package/dist/orchestration/routing/commands/status.js +45 -59
  304. package/dist/orchestration/routing/edit-handler.d.ts +5 -0
  305. package/dist/orchestration/routing/edit-handler.js +127 -73
  306. package/dist/orchestration/routing/webhook.js +5 -4
  307. package/dist/orchestration/session-rewind.d.ts +5 -1
  308. package/dist/orchestration/session-rewind.js +106 -62
  309. package/dist/orchestration/session-send.d.ts +2 -0
  310. package/dist/orchestration/session-send.js +5 -6
  311. package/dist/orchestration/status-helpers.d.ts +1 -2
  312. package/dist/orchestration/status-helpers.js +7 -10
  313. package/dist/orchestration/thread-callback.d.ts +19 -11
  314. package/dist/orchestration/thread-callback.js +132 -61
  315. package/dist/orchestration/thread-executor.js +37 -27
  316. package/dist/orchestration/turn-mutation-lock.d.ts +3 -0
  317. package/dist/orchestration/turn-mutation-lock.js +36 -0
  318. package/dist/orchestration/turn-notify.d.ts +2 -5
  319. package/dist/orchestration/turn-notify.js +9 -21
  320. package/dist/platform/adapter.d.ts +1 -0
  321. package/dist/platform/adapter.js +2 -2
  322. package/dist/platform/adapters/composite-adapter.d.ts +2 -0
  323. package/dist/platform/adapters/composite-adapter.js +13 -3
  324. package/dist/platform/adapters/feishu.d.ts +2 -4
  325. package/dist/platform/adapters/feishu.js +38 -59
  326. package/dist/platform/adapters/index.d.ts +1 -1
  327. package/dist/platform/adapters/index.js +13 -12
  328. package/dist/platform/adapters/slack.d.ts +1 -1
  329. package/dist/platform/adapters/slack.js +12 -35
  330. package/dist/platform/index.d.ts +2 -1
  331. package/dist/platform/index.js +3 -3
  332. package/dist/platform/testing.d.ts +1 -0
  333. package/dist/platform/testing.js +13 -4
  334. package/dist/platform/tool-trace.js +6 -11
  335. package/dist/platform/ui-http/ui-http-server.d.ts +1 -1
  336. package/dist/platform/ui-http/ui-http-server.js +6 -18
  337. package/dist/store/execution-repo.d.ts +17 -1
  338. package/dist/store/execution-repo.js +55 -4
  339. package/dist/store/prompt-migration-replacements.d.ts +4 -0
  340. package/dist/store/prompt-migration-replacements.js +149 -0
  341. package/dist/store/thread-repo.d.ts +15 -4
  342. package/dist/store/thread-repo.js +61 -24
  343. package/dist/store/version-migrations.js +36 -1
  344. package/native/cortex-supervisor/dist/build-manifest.json +22 -0
  345. package/native/cortex-supervisor/dist/cortex-supervisor +0 -0
  346. package/package.json +5 -2
  347. package/web/dist/assets/index-XqBCYtkw.js +139 -0
  348. package/web/dist/assets/index-zpf3OSKC.css +1 -0
  349. package/web/dist/index.html +2 -2
  350. package/dist/domain/scheduling/jobs/failed-dispatch-reconciliation.d.ts +0 -1
  351. package/dist/domain/scheduling/jobs/failed-dispatch-reconciliation.js +0 -78
  352. package/web/dist/assets/index-B19jLgji.js +0 -138
  353. package/web/dist/assets/index-BuFyPyRW.css +0 -1
@@ -1,10 +1,11 @@
1
- // input: config root, mounted-hook registry, UI query types
2
- // output: redacted ConfigSnapshot with live backend profiles
3
- // pos: Hermetic config.get snapshot reader
4
- // >>> If I am updated, update my header comment and CORTEX.md <<<
1
+ // input: config root, settings registry, mounted-hook registry
2
+ // output: redacted config plus plaintext settings provenance
3
+ // pos: Config.get snapshot reader
4
+ // >>> 一旦我被更新,务必更新我的开头注释与所属文件夹 CORTEX.md <<<
5
5
  import fs from 'node:fs/promises';
6
6
  import path from 'node:path';
7
7
  import { CONFIG_DIR } from '../../../core/paths.js';
8
+ import { getSettingsSnapshot, resolveSettingsSnapshot } from '../../../core/settings.js';
8
9
  import { loadMountedHookSummaries } from '../../../store/hook-registry.js';
9
10
  const MASK = '••••••••';
10
11
  async function readJson(file) {
@@ -104,15 +105,27 @@ async function readEnv(file) {
104
105
  return [];
105
106
  }
106
107
  }
108
+ async function readSettings(configDir) {
109
+ const raw = await readJson(path.join(configDir, 'settings.json'));
110
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
111
+ return resolveSettingsSnapshot({});
112
+ }
113
+ try {
114
+ return resolveSettingsSnapshot(raw);
115
+ }
116
+ catch {
117
+ return resolveSettingsSnapshot({});
118
+ }
119
+ }
107
120
  /**
108
- * Read a redacted snapshot of the config directory for the settings panel. Pure over its dir
109
- * arguments (no global paths) so it is hermetically testable against a fixture directory. Every
110
- * source file is independent: a missing / malformed file yields null (or []) for that field only.
121
+ * Read a config snapshot from the supplied directory. Files remain hermetically scoped to that
122
+ * directory; settings use the process env fallback unless the caller supplies the live cached
123
+ * snapshot. A missing or malformed source affects only its own field.
111
124
  */
112
- export async function readConfigSnapshot(configDir) {
125
+ export async function readConfigSnapshot(configDir, liveSettings) {
113
126
  const tt = path.join(configDir, 'thread-templates');
114
127
  const hooks = loadMountedHookSummaries(path.join(configDir, 'hooks'), path.join(tt, 'templates'));
115
- const [budgetRaw, profilesRaw, machinesRaw, mcpRaw, agents, templates, shells, env] = await Promise.all([
128
+ const parts = await Promise.all([
116
129
  readJson(path.join(configDir, 'budget.json')),
117
130
  readJson(path.join(configDir, 'profiles.json')),
118
131
  readJson(path.join(configDir, 'machines.json')),
@@ -121,18 +134,15 @@ export async function readConfigSnapshot(configDir) {
121
134
  listJsonBasenames(path.join(tt, 'templates')),
122
135
  listJsonBasenames(path.join(tt, 'shells')),
123
136
  readEnv(path.join(configDir, '.env')),
137
+ liveSettings ?? readSettings(configDir),
124
138
  ]);
139
+ const [budget, profiles, machines, mcp, agents, templates, shells, env, settings] = parts;
125
140
  const threadTemplates = { agents, templates, shells };
126
141
  return {
127
- budget: parseBudget(budgetRaw),
128
- profiles: parseProfiles(profilesRaw),
129
- machines: parseMachines(machinesRaw),
130
- mcp: parseMcp(mcpRaw),
131
- threadTemplates,
132
- hooks,
133
- env,
142
+ budget: parseBudget(budget), profiles: parseProfiles(profiles), machines: parseMachines(machines),
143
+ mcp: parseMcp(mcp), threadTemplates, hooks, env, settings,
134
144
  };
135
145
  }
136
146
  export async function handleConfigGet(_deps, _params) {
137
- return readConfigSnapshot(CONFIG_DIR);
147
+ return readConfigSnapshot(CONFIG_DIR, getSettingsSnapshot());
138
148
  }
@@ -1,3 +1,3 @@
1
1
  import type { UiServiceDeps, TaskInfo, TasksListParams } from '../types.js';
2
- export declare function toTaskInfo(t: any): TaskInfo;
2
+ export declare function toTaskInfo(task: any): TaskInfo;
3
3
  export declare function handleTasksList(deps: UiServiceDeps, params: TasksListParams): Promise<TaskInfo[]>;
@@ -1,38 +1,77 @@
1
- // input: UiServiceDeps, TasksListParams, task records
2
- // output: Task DTOs with lifecycle and approval state
1
+ // input: UiServiceDeps, TasksListParams, task and thread records
2
+ // output: Task DTOs with lifecycle, dependencies and claim thread
3
3
  // pos: Task DTO mapper and tasks.list query handler
4
4
  // >>> If I am updated, update my header comment and CORTEX.md <<<
5
- export function toTaskInfo(t) {
5
+ const ACTIVE_THREAD_STATUSES = new Set(['running', 'waiting', 'rate_limited']);
6
+ function taskThreadKey(project, taskId) {
7
+ return `${project}\0${taskId}`;
8
+ }
9
+ function claimThreadMap(deps) {
10
+ const result = new Map();
11
+ for (const thread of deps.threadStore.getAll()) {
12
+ const taskId = thread.metadata?.taskId;
13
+ const project = thread.metadata?.taskProject ?? thread.projectId;
14
+ const key = taskId && project ? taskThreadKey(project, taskId) : null;
15
+ if (!key || !ACTIVE_THREAD_STATUSES.has(thread.status) || result.has(key))
16
+ continue;
17
+ result.set(key, thread.id);
18
+ }
19
+ return result;
20
+ }
21
+ function unresolvedDependencies(task, completedIds) {
22
+ return (task.depends_on ?? []).filter((dependency) => !completedIds.has(dependency));
23
+ }
24
+ function isTaskActionable(task, unmetDependencyIds, today) {
25
+ return task.status === 'open'
26
+ && !task.paused
27
+ && !task.claimed_by
28
+ && !task.blocked_by
29
+ && !(task.approval_needed && !task.approved_at)
30
+ && unmetDependencyIds.length === 0
31
+ && !(task.not_before && task.not_before > today);
32
+ }
33
+ function mapTaskInfo(task, claimThreadId, unmetDependencyIds, actionable) {
6
34
  return {
7
- id: t.id,
8
- text: t.text,
9
- project: t.project,
10
- status: t.status === 'done' ? 'done' : 'open',
11
- priority: t.priority || 'medium',
12
- actionable: !!(t.status === 'open' && !t.claimed_by && !t.blocked_by && !t.paused),
13
- claimedBy: t.claimed_by ?? null,
14
- blockedBy: t.blocked_by ?? null,
15
- approvalNeeded: t.approval_needed === true,
16
- approvedAt: t.approved_at ?? null,
17
- dependsOn: t.depends_on || [],
18
- plan: t.plan ?? null,
19
- template: t.template || 'coder-review',
20
- why: t.why || null,
21
- doneWhen: t.done_when || null,
35
+ id: task.id,
36
+ text: task.text,
37
+ project: task.project,
38
+ status: task.status === 'done' ? 'done' : 'open',
39
+ priority: task.priority || 'medium',
40
+ actionable: actionable ?? !!(task.status === 'open' && !task.claimed_by && !task.blocked_by && !task.paused),
41
+ claimedBy: task.claimed_by ?? null,
42
+ claimThreadId,
43
+ blockedBy: task.blocked_by ?? null,
44
+ approvalNeeded: task.approval_needed === true,
45
+ approvedAt: task.approved_at ?? null,
46
+ dependsOn: task.depends_on || [],
47
+ unmetDependencyIds,
48
+ plan: task.plan ?? null,
49
+ template: task.template || 'coder-review',
50
+ why: task.why || null,
51
+ doneWhen: task.done_when || null,
52
+ completedAt: task.completed_at ?? null,
22
53
  };
23
54
  }
55
+ export function toTaskInfo(task) {
56
+ return mapTaskInfo(task, null);
57
+ }
24
58
  export async function handleTasksList(deps, params) {
25
- const { projectId, status, actionable } = params;
26
59
  deps.taskStore.refresh();
27
- let tasks = deps.taskStore.getAll(projectId || undefined);
28
- if (status) {
29
- tasks = tasks.filter((t) => t.status === status);
30
- }
31
- if (actionable !== undefined) {
32
- tasks = tasks.filter((t) => {
33
- const isActionable = t.status === 'open' && !t.claimed_by && !t.blocked_by && !t.paused;
34
- return actionable ? isActionable : !isActionable;
35
- });
36
- }
37
- return tasks.map(toTaskInfo);
60
+ const allTasks = deps.taskStore.getAll();
61
+ const completedIds = new Set(allTasks.filter((task) => task.status === 'done' && task.id).map((task) => task.id));
62
+ const today = new Date().toISOString().slice(0, 10);
63
+ const projected = allTasks.map((task) => {
64
+ const unmetDependencyIds = unresolvedDependencies(task, completedIds);
65
+ return { task, unmetDependencyIds, actionable: isTaskActionable(task, unmetDependencyIds, today) };
66
+ });
67
+ const threadByTask = claimThreadMap(deps);
68
+ return projected
69
+ .filter(({ task }) => !params.projectId || task.project === params.projectId)
70
+ .filter(({ task }) => !params.status || task.status === params.status)
71
+ .filter((item) => params.actionable === undefined || item.actionable === params.actionable)
72
+ .map(({ task, unmetDependencyIds, actionable }) => {
73
+ const key = taskThreadKey(task.project, task.id);
74
+ const threadId = task.claimed_by ? threadByTask.get(key) ?? null : null;
75
+ return mapTaskInfo(task, threadId, unmetDependencyIds, actionable);
76
+ });
38
77
  }
@@ -1,5 +1,5 @@
1
1
  // input: UiServiceDeps, thread query params, task DTO mapper
2
- // output: task-linked thread detail with optional artifact text
2
+ // output: normalized thread lists and task-linked detail
3
3
  // pos: Thread list/detail query handlers
4
4
  // >>> If I am updated, update my header comment and CORTEX.md <<<
5
5
  import { readFile } from 'node:fs/promises';
@@ -23,7 +23,7 @@ export async function handleThreadsList(deps, params) {
23
23
  }
24
24
  if (status && status.length > 0) {
25
25
  const statusSet = new Set(status);
26
- threads = threads.filter((t) => statusSet.has(t.status));
26
+ threads = threads.filter((t) => statusSet.has(mapStatus(t.status)));
27
27
  }
28
28
  // Session scoping: a thread spawned from a chat runs on that session's channel, so resolve the
29
29
  // session → channel and keep only threads on it. An unknown session (or one with no channel)
@@ -39,7 +39,7 @@ export async function handleThreadsList(deps, params) {
39
39
  currentStep: t.currentStepIndex != null
40
40
  ? { index: t.currentStepIndex, name: t.currentStepName || `step-${t.currentStepIndex}` }
41
41
  : null,
42
- status: t.status,
42
+ status: mapStatus(t.status),
43
43
  projectId: t.projectId,
44
44
  createdAt: t.createdAt,
45
45
  updatedAt: t.updatedAt,
@@ -2,8 +2,9 @@ import type { Project, CreateProjectResult } from '../projects/index.js';
2
2
  import type { CostSummary } from '../costs/cost-tracker.js';
3
3
  import type { EventBus } from '../../events/index.js';
4
4
  import type { RunningExecutions } from '../../core/running-executions.js';
5
- import type { ChatNoticeLevel, SessionContextUsage } from '../../core/types/agent-types.js';
6
- export type { ChatNoticeLevel, SessionContextUsage } from '../../core/types/agent-types.js';
5
+ import type { Settings, SettingSnapshotEntry } from '../../core/settings-spec.js';
6
+ import type { AuthNoticeAction, ChatNoticeLevel, SessionContextUsage } from '../../core/types/agent-types.js';
7
+ export type { AuthNoticeAction, ChatNoticeLevel, SessionContextUsage, } from '../../core/types/agent-types.js';
7
8
  import type { PlatformAdapter } from '../../platform/adapter.js';
8
9
  import type { HookBackend, HookEvent, HookFilterValue, HookPhase, HookResultMode, HookSource } from '../../store/hook-registry.js';
9
10
  import type { HookApplyTime, HookMountTarget } from '../hooks/hook-view.js';
@@ -14,6 +15,8 @@ import type { LogLocation } from '../executions/log-tailer.js';
14
15
  import type { SessionHistory } from '../../store/conversation-history-repo.js';
15
16
  import type { Backend } from '../../agent-adapter/types.js';
16
17
  import type { ProjectNote } from '../../store/project-notes-repo.js';
18
+ import type { AuthLoginService, AuthLogoutResult, AuthLogoutSuccess, AuthStatusSnapshot, AuthType, LoginFlowState, LogoutAccountInput } from '../auth/index.js';
19
+ export type { AuthAccountState, AuthAccountStatus, AuthCredentialStatus, AuthStatusSnapshot, AuthType, LoginFlowNotice, LoginFlowState, LoginFlowStep, LoginOutcome, LoginPendingPrompt, LoginPromptOption, } from '../auth/index.js';
17
20
  export type Ok<T> = {
18
21
  ok: true;
19
22
  data: T;
@@ -24,8 +27,8 @@ export type Err = {
24
27
  message: string;
25
28
  };
26
29
  export type Result<T> = Ok<T> | Err;
27
- export type QueryScope = 'projects.list' | 'sessions.list' | 'sessions.transcript' | 'sessions.pendingInteraction' | 'threads.list' | 'threads.get' | 'tasks.list' | 'tasks.verification' | 'schedules.list' | 'executions.list' | 'executions.get' | 'memory.tree' | 'memory.file' | 'approvals.list' | 'issues.list' | 'notes.list' | 'cost.summary' | 'config.get' | 'hooks.list' | 'machines.list' | 'skills.list' | 'threadTemplates.get' | 'system.daemonStatus' | 'system.rateLimitStatus';
28
- export type MutateOp = 'projects.create' | 'sessions.create' | 'sessions.send' | 'sessions.cancel' | 'sessions.compact' | 'sessions.setProfile' | 'sessions.createAndSend' | 'sessions.markRead' | 'sessions.answerQuestion' | 'sessions.respondPlan' | 'sessions.rewind' | 'threads.cancel' | 'executions.cancel' | 'schedules.pause' | 'schedules.resume' | 'schedules.remove' | 'schedules.add' | 'tasks.claim' | 'tasks.unclaim' | 'tasks.complete' | 'tasks.block' | 'tasks.unblock' | 'approvals.approve' | 'approvals.reject' | 'approvals.request' | 'issues.handle' | 'issues.delete' | 'notes.add' | 'notes.update' | 'notes.setCompleted' | 'notes.delete' | 'notes.clearCompleted' | 'config.set' | 'hooks.create' | 'hooks.update' | 'hooks.setEnabled' | 'hooks.remove' | 'hooks.test' | 'system.restart';
30
+ export type QueryScope = 'projects.list' | 'sessions.list' | 'sessions.transcript' | 'sessions.pendingInteraction' | 'threads.list' | 'threads.get' | 'tasks.list' | 'tasks.verification' | 'schedules.list' | 'executions.list' | 'executions.get' | 'memory.tree' | 'memory.file' | 'approvals.list' | 'issues.list' | 'notes.list' | 'cost.summary' | 'config.get' | 'auth.status' | 'auth.flowState' | 'hooks.list' | 'machines.list' | 'skills.list' | 'threadTemplates.get' | 'system.daemonStatus' | 'system.rateLimitStatus';
31
+ export type MutateOp = 'projects.create' | 'sessions.create' | 'sessions.send' | 'sessions.cancel' | 'sessions.compact' | 'sessions.setProfile' | 'sessions.createAndSend' | 'sessions.markRead' | 'sessions.answerQuestion' | 'sessions.respondPlan' | 'sessions.rewind' | 'threads.cancel' | 'executions.cancel' | 'schedules.pause' | 'schedules.resume' | 'schedules.remove' | 'schedules.add' | 'tasks.claim' | 'tasks.unclaim' | 'tasks.complete' | 'tasks.block' | 'tasks.unblock' | 'approvals.approve' | 'approvals.reject' | 'approvals.request' | 'issues.handle' | 'issues.delete' | 'notes.add' | 'notes.update' | 'notes.setCompleted' | 'notes.delete' | 'notes.clearCompleted' | 'config.set' | 'auth.startLogin' | 'auth.respondPrompt' | 'auth.cancelFlow' | 'auth.logout' | 'hooks.create' | 'hooks.update' | 'hooks.setEnabled' | 'hooks.remove' | 'hooks.test' | 'system.restart';
29
32
  export interface SubscribeFilter {
30
33
  events: string[];
31
34
  projectId?: string | null;
@@ -134,6 +137,10 @@ export interface CostSummaryParams {
134
137
  projectId?: string | null;
135
138
  }
136
139
  export type ConfigGetParams = Record<string, never>;
140
+ export type AuthStatusParams = Record<string, never>;
141
+ export interface AuthFlowStateParams {
142
+ flowId: string;
143
+ }
137
144
  export type MachinesListParams = Record<string, never>;
138
145
  export type SkillsListParams = Record<string, never>;
139
146
  export type ThreadTemplatesGetParams = Record<string, never>;
@@ -142,6 +149,21 @@ export type SystemRateLimitStatusParams = Record<string, never>;
142
149
  export interface ProjectCreateArgs {
143
150
  name: string;
144
151
  }
152
+ export interface AuthStartLoginArgs {
153
+ backend: 'claude' | 'pi';
154
+ provider: string;
155
+ authType: AuthType;
156
+ noticeId?: string;
157
+ }
158
+ export interface AuthRespondPromptArgs {
159
+ flowId: string;
160
+ value: string;
161
+ }
162
+ export interface AuthCancelFlowArgs {
163
+ flowId: string;
164
+ }
165
+ export type AuthLogoutArgs = LogoutAccountInput;
166
+ export type AuthLogoutReturn = AuthLogoutSuccess;
145
167
  export interface SessionsCreateArgs {
146
168
  /** Project the new session belongs to. Omitted → the default project (handler fallback). */
147
169
  projectId?: string;
@@ -254,12 +276,16 @@ export interface BudgetValue {
254
276
  export interface ProfilesValue {
255
277
  defaultProfile: string;
256
278
  }
279
+ export type SettingsValue = Partial<Settings>;
257
280
  export type ConfigSetArgs = {
258
281
  section: 'budget';
259
282
  value: BudgetValue;
260
283
  } | {
261
284
  section: 'profiles';
262
285
  value: ProfilesValue;
286
+ } | {
287
+ section: 'settings';
288
+ value: SettingsValue;
263
289
  };
264
290
  export interface ApprovalsApproveArgs {
265
291
  id: string;
@@ -423,6 +449,8 @@ export interface TranscriptMessage {
423
449
  debug?: TranscriptDebugDetails;
424
450
  /** Semantic chat-notice styling for system-authored assistant messages. */
425
451
  noticeLevel?: ChatNoticeLevel;
452
+ /** Secret-free one-click target carried only by authentication notices. */
453
+ authAction?: AuthNoticeAction;
426
454
  /** interaction subtype: 'ask-user-answered' | 'plan-approved' | 'plan-rejected' (legacy rows)
427
455
  * or derived from kind+status for entity rows (display compat). */
428
456
  subtype?: string;
@@ -580,18 +608,24 @@ export interface TaskInfo {
580
608
  priority: 'high' | 'medium' | 'low';
581
609
  actionable: boolean;
582
610
  claimedBy: string | null;
611
+ /** Owning task-dispatch thread; optional while app and server versions roll independently. */
612
+ claimThreadId?: string | null;
583
613
  blockedBy: string | null;
584
614
  /** Approval gate from task-store `approval-needed`; absent only with an older server contract. */
585
615
  approvalNeeded?: boolean;
586
616
  /** Recorded approval date; absent only with an older server contract. */
587
617
  approvedAt?: string | null;
588
618
  dependsOn: string[];
619
+ /** Unresolved dependencies across all projects; optional with an older server contract. */
620
+ unmetDependencyIds?: string[];
589
621
  plan: string | null;
590
622
  template: string;
591
623
  /** The task's rationale (task store `why`). Null when absent/empty (null-safe). */
592
624
  why: string | null;
593
625
  /** The task's completion criteria (task store `done-when`). Null when absent/empty (null-safe). */
594
626
  doneWhen: string | null;
627
+ /** Completion timestamp; optional while app and server versions roll independently. */
628
+ completedAt?: string | null;
595
629
  }
596
630
  /** Done-when achievement evidence drawn from real completion sources (task store + completing execution). */
597
631
  export interface TaskDoneWhenEvidence {
@@ -727,6 +761,7 @@ export interface ConfigEnvEntry {
727
761
  present: boolean;
728
762
  masked: string;
729
763
  }
764
+ export type ConfigSettingEntry = SettingSnapshotEntry;
730
765
  export interface ConfigHook {
731
766
  id: string;
732
767
  event: HookEvent;
@@ -848,6 +883,8 @@ export interface ConfigSnapshot {
848
883
  threadTemplates: ConfigThreadTemplates;
849
884
  hooks: ConfigHook[];
850
885
  env: ConfigEnvEntry[];
886
+ /** Always emitted by current servers; optional while clients and servers roll independently. */
887
+ settings?: ConfigSettingEntry[];
851
888
  }
852
889
  export interface MachineInfo {
853
890
  /** Machine name (key from machines.json). */
@@ -950,6 +987,12 @@ export interface ApprovalInfo {
950
987
  /** Stable id derived from the heading line (no explicit id exists in the markdown). */
951
988
  id: string;
952
989
  title: string;
990
+ /**
991
+ * Owning project from the `- **Project**:` bullet (need-approval skill template). `null` (honest
992
+ * placeholder, never fabricated) for legacy entries and system-level operations — the UI renders
993
+ * those as "global".
994
+ */
995
+ projectId: string | null;
953
996
  operation: string | null;
954
997
  reason: string | null;
955
998
  impact: string | null;
@@ -964,9 +1007,9 @@ export interface ApprovalInfo {
964
1007
  feedback: string | null;
965
1008
  /**
966
1009
  * Verbatim `Provenance` bullet — the only real "who raised this / origin" carrier in the queue
967
- * (§12 C item 13). Neither the need-approval skill nor the approval-gate builder emit a structured
968
- * origin/from field; a subset of entries add this freeform bullet. `null` (honest placeholder,
969
- * never fabricated) when absent. Backs the approval-center origin/from slots.
1010
+ * (§12 C item 13). Project attribution now has its own structured `Project` bullet (projectId),
1011
+ * but origin/from remains this freeform bullet only a subset of entries add. `null` (honest
1012
+ * placeholder, never fabricated) when absent. Backs the approval-center origin/from slots.
970
1013
  */
971
1014
  provenance: string | null;
972
1015
  /**
@@ -1069,7 +1112,7 @@ export interface ExecutionsCancelReturn {
1069
1112
  }
1070
1113
  export interface ConfigSetReturn {
1071
1114
  written: true;
1072
- section: 'budget' | 'profiles';
1115
+ section: 'budget' | 'profiles' | 'settings';
1073
1116
  }
1074
1117
  export interface ApprovalMutateReturn {
1075
1118
  id: string;
@@ -1114,6 +1157,8 @@ export interface QueryParamMap {
1114
1157
  'notes.list': NotesListParams;
1115
1158
  'cost.summary': CostSummaryParams;
1116
1159
  'config.get': ConfigGetParams;
1160
+ 'auth.status': AuthStatusParams;
1161
+ 'auth.flowState': AuthFlowStateParams;
1117
1162
  'hooks.list': HooksListParams;
1118
1163
  'machines.list': MachinesListParams;
1119
1164
  'skills.list': SkillsListParams;
@@ -1140,6 +1185,8 @@ export interface QueryReturnMap {
1140
1185
  'notes.list': NoteInfo[];
1141
1186
  'cost.summary': CostSummary;
1142
1187
  'config.get': ConfigSnapshot;
1188
+ 'auth.status': AuthStatusSnapshot;
1189
+ 'auth.flowState': LoginFlowState | null;
1143
1190
  'hooks.list': HooksOverview;
1144
1191
  'machines.list': MachineInfo[];
1145
1192
  'skills.list': SkillGroup[];
@@ -1181,6 +1228,10 @@ export interface MutateArgsMap {
1181
1228
  'notes.delete': NoteActionArgs;
1182
1229
  'notes.clearCompleted': NotesClearCompletedArgs;
1183
1230
  'config.set': ConfigSetArgs;
1231
+ 'auth.startLogin': AuthStartLoginArgs;
1232
+ 'auth.respondPrompt': AuthRespondPromptArgs;
1233
+ 'auth.cancelFlow': AuthCancelFlowArgs;
1234
+ 'auth.logout': AuthLogoutArgs;
1184
1235
  'hooks.create': HooksCreateArgs;
1185
1236
  'hooks.update': HooksUpdateArgs;
1186
1237
  'hooks.setEnabled': HooksSetEnabledArgs;
@@ -1222,6 +1273,10 @@ export interface MutateReturnMap {
1222
1273
  'notes.delete': NotesDeleteReturn;
1223
1274
  'notes.clearCompleted': NotesClearCompletedReturn;
1224
1275
  'config.set': ConfigSetReturn;
1276
+ 'auth.startLogin': LoginFlowState;
1277
+ 'auth.respondPrompt': LoginFlowState;
1278
+ 'auth.cancelFlow': LoginFlowState;
1279
+ 'auth.logout': AuthLogoutReturn;
1225
1280
  'hooks.create': HooksCreateReturn;
1226
1281
  'hooks.update': HooksUpdateReturn;
1227
1282
  'hooks.setEnabled': HooksSetEnabledReturn;
@@ -1249,6 +1304,10 @@ export interface UiService {
1249
1304
  };
1250
1305
  }
1251
1306
  export interface UiServiceDeps {
1307
+ /** Optional seams for deterministic authentication dispatch tests. */
1308
+ getAuthStatus?: () => Promise<AuthStatusSnapshot>;
1309
+ authLogin?: AuthLoginService;
1310
+ logoutAccount?: (input: LogoutAccountInput) => Promise<AuthLogoutResult>;
1252
1311
  projectStore: {
1253
1312
  list(): Project[];
1254
1313
  get(id: string): Project | undefined;
@@ -1,5 +1,5 @@
1
- // input: domain types, context/notices, stores, pending data
2
- // output: UI DTOs and operation maps including task approvals
1
+ // input: domain types, auth flows/logout, runtime settings, stores
2
+ // output: UI DTOs/maps including auth account mutations
3
3
  // pos: Canonical transport-neutral UI contract
4
4
  // >>> 一旦我被更新,务必更新我的开头注释与所属文件夹 CORTEX.md <<<
5
5
  export {};
@@ -1,5 +1,5 @@
1
1
  // input: UiServiceDeps and query/mutation handlers
2
- // output: createUiService with notes routing and private audit redaction
2
+ // output: createUiService with authentication mutation routing
3
3
  // pos: Transport-neutral UI-service dispatcher
4
4
  // >>> 一旦我被更新,务必更新我的开头注释与所属文件夹 CORTEX.md <<<
5
5
  import { handleProjectsList } from './query/projects.js';
@@ -15,6 +15,7 @@ import { handleIssuesList } from './query/issues.js';
15
15
  import { handleNotesList } from './query/notes.js';
16
16
  import { handleCostSummary } from './query/cost.js';
17
17
  import { handleConfigGet } from './query/config.js';
18
+ import { handleAuthFlowState, handleAuthStatus } from './query/auth.js';
18
19
  import { handleHooksList } from './query/hooks.js';
19
20
  import { handleMachinesList } from './query/machines.js';
20
21
  import { handleSkillsList } from './query/skills.js';
@@ -32,6 +33,7 @@ import { handleApproveApproval, handleRejectApproval, handleRequestApproval } fr
32
33
  import { handleIssuesDelete, handleIssuesHandle } from './mutate/issues.js';
33
34
  import { handleNotesAdd, handleNotesClearCompleted, handleNotesDelete, handleNotesSetCompleted, handleNotesUpdate, } from './mutate/notes.js';
34
35
  import { handleSystemRestart } from './mutate/system.js';
36
+ import { handleAuthCancelFlow, handleAuthLogout, handleAuthRespondPrompt, handleAuthStartLogin, } from './mutate/auth.js';
35
37
  import { createSubscription } from './subscribe.js';
36
38
  import { resolveExecutionLogLocation } from '../executions/log-tailer.js';
37
39
  const queryHandlers = {
@@ -53,6 +55,8 @@ const queryHandlers = {
53
55
  'notes.list': (deps, params) => handleNotesList(deps, params),
54
56
  'cost.summary': (deps, params) => handleCostSummary(deps, params),
55
57
  'config.get': (deps, params) => handleConfigGet(deps, params),
58
+ 'auth.status': (deps, params) => handleAuthStatus(params, deps.getAuthStatus),
59
+ 'auth.flowState': (deps, params) => handleAuthFlowState(params, deps.authLogin?.getState),
56
60
  'hooks.list': (deps, params) => handleHooksList(deps, params),
57
61
  'machines.list': (deps, params) => handleMachinesList(deps, params),
58
62
  'skills.list': (deps, params) => handleSkillsList(deps, params),
@@ -94,6 +98,10 @@ const mutateHandlers = {
94
98
  'notes.delete': (deps, args) => handleNotesDelete(deps, args),
95
99
  'notes.clearCompleted': (deps, args) => handleNotesClearCompleted(deps, args),
96
100
  'config.set': (deps, args) => handleConfigSet(deps, args),
101
+ 'auth.startLogin': (deps, args) => handleAuthStartLogin(deps, args),
102
+ 'auth.respondPrompt': (deps, args) => handleAuthRespondPrompt(deps, args),
103
+ 'auth.cancelFlow': (deps, args) => handleAuthCancelFlow(deps, args),
104
+ 'auth.logout': (deps, args) => handleAuthLogout(deps, args),
97
105
  'hooks.create': (deps, args) => handleHooksCreate(deps, args),
98
106
  'hooks.update': (deps, args) => handleHooksUpdate(deps, args),
99
107
  'hooks.setEnabled': (deps, args) => handleHooksSetEnabled(deps, args),
@@ -102,7 +110,13 @@ const mutateHandlers = {
102
110
  'system.restart': (_deps, args) => handleSystemRestart(args),
103
111
  };
104
112
  export function redactMutationAuditArgs(op, args) {
105
- if (!op.startsWith('notes.') || !args || typeof args !== 'object')
113
+ if (!args || typeof args !== 'object')
114
+ return args;
115
+ if (op === 'auth.respondPrompt') {
116
+ const { flowId } = args;
117
+ return { flowId };
118
+ }
119
+ if (!op.startsWith('notes.'))
106
120
  return args;
107
121
  const { text: _privateText, ...safe } = args;
108
122
  return safe;
@@ -0,0 +1,4 @@
1
+ import type { PlatformAdapter } from '../platform/index.js';
2
+ type AdapterFactory = () => PlatformAdapter;
3
+ export declare function createHotReloadingAdapter(factory?: AdapterFactory): PlatformAdapter;
4
+ export {};
@@ -0,0 +1,22 @@
1
+ // input: adapter factory, settings callbacks, platform routing
2
+ // output: runtime adapter with registered admin hot-reload
3
+ // pos: Composition seam for live admin settings
4
+ // >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
5
+ import { getSettings, onSettingsChange } from '../core/settings.js';
6
+ import { createAdapterFromEnv, setPlatformAdminChannel } from '../platform/index.js';
7
+ function registerAdminChannelHotReload(adapter) {
8
+ onSettingsChange((changedKeys) => {
9
+ const settings = getSettings();
10
+ if (changedKeys.includes('adminChannel')) {
11
+ setPlatformAdminChannel(adapter, 'slack', settings.adminChannel);
12
+ }
13
+ if (changedKeys.includes('feishuAdminChannel')) {
14
+ setPlatformAdminChannel(adapter, 'feishu', settings.feishuAdminChannel);
15
+ }
16
+ });
17
+ }
18
+ export function createHotReloadingAdapter(factory = createAdapterFromEnv) {
19
+ const adapter = factory();
20
+ registerAdminChannelHotReload(adapter);
21
+ return adapter;
22
+ }