@cortex-agent/server 2026.10.15 → 2026.10.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. package/README.md +76 -50
  2. package/defaults/board/board.css +140 -62
  3. package/defaults/board/scaffold.html +36 -13
  4. package/defaults/config/environments/creative.json +0 -1
  5. package/defaults/config/environments/main.json +1 -2
  6. package/defaults/plugins/cortex-board/skills/board/SKILL.md +30 -22
  7. package/defaults/plugins/cortex-system/plugin.json +2 -2
  8. package/defaults/plugins/cortex-system/skills/browser/SKILL.md +56 -0
  9. package/dist/agent-adapter/claude/adapter.d.ts +2 -5
  10. package/dist/agent-adapter/claude/adapter.js +6 -5
  11. package/dist/agent-adapter/claude/assistant-blocks.d.ts +5 -0
  12. package/dist/agent-adapter/claude/assistant-blocks.js +61 -0
  13. package/dist/agent-adapter/claude/cache-refresh.d.ts +58 -0
  14. package/dist/agent-adapter/claude/cache-refresh.js +145 -0
  15. package/dist/agent-adapter/claude/cache-touch.d.ts +12 -0
  16. package/dist/agent-adapter/claude/cache-touch.js +75 -0
  17. package/dist/agent-adapter/claude/event-parser.d.ts +8 -3
  18. package/dist/agent-adapter/claude/event-parser.js +33 -17
  19. package/dist/agent-adapter/claude/event-translator.d.ts +2 -0
  20. package/dist/agent-adapter/claude/event-translator.js +2 -0
  21. package/dist/agent-adapter/claude/session-options.d.ts +6 -13
  22. package/dist/agent-adapter/claude/session-options.js +2 -13
  23. package/dist/agent-adapter/claude/spawn-args.d.ts +4 -21
  24. package/dist/agent-adapter/claude/spawn-args.js +17 -24
  25. package/dist/agent-adapter/claude/transcript-clear.d.ts +42 -0
  26. package/dist/agent-adapter/claude/transcript-clear.js +217 -0
  27. package/dist/agent-adapter/claude/turn-machine.d.ts +3 -2
  28. package/dist/agent-adapter/claude/turn-machine.js +21 -68
  29. package/dist/agent-adapter/claude/window-warmup.d.ts +13 -0
  30. package/dist/agent-adapter/claude/window-warmup.js +38 -0
  31. package/dist/agent-adapter/continuation-phase.js +3 -0
  32. package/dist/agent-adapter/normalize/event-types.d.ts +8 -0
  33. package/dist/agent-adapter/pi/adapter.d.ts +0 -1
  34. package/dist/agent-adapter/pi/adapter.js +5 -13
  35. package/dist/agent-adapter/pi/event-parser.d.ts +1 -1
  36. package/dist/agent-adapter/pi/event-parser.js +43 -27
  37. package/dist/agent-adapter/pi/mcp-bridge.d.ts +1 -1
  38. package/dist/agent-adapter/pi/pi-session.d.ts +2 -0
  39. package/dist/agent-adapter/pi/pi-session.js +15 -0
  40. package/dist/agent-adapter/pi/providers-config.d.ts +2 -2
  41. package/dist/agent-adapter/pi/providers-config.js +1 -1
  42. package/dist/agent-adapter/pi/quota-sink.d.ts +3 -3
  43. package/dist/agent-adapter/pi/quota-sink.js +3 -3
  44. package/dist/agent-adapter/pi/runtime.js +6 -1
  45. package/dist/agent-adapter/pi/session-options.d.ts +9 -13
  46. package/dist/agent-adapter/pi/session-options.js +12 -25
  47. package/dist/agent-adapter/run-events.d.ts +11 -10
  48. package/dist/agent-adapter/run-events.js +2 -0
  49. package/dist/agent-adapter/types.d.ts +5 -4
  50. package/dist/client-bundle/manifest.json +2 -2
  51. package/dist/core/codex-quota.d.ts +1 -1
  52. package/dist/core/codex-quota.js +1 -1
  53. package/dist/core/gateway-generator.d.ts +9 -11
  54. package/dist/core/gateway-generator.js +31 -58
  55. package/dist/core/locales/en.d.ts +51 -77
  56. package/dist/core/locales/slices/commands.d.ts +26 -31
  57. package/dist/core/locales/slices/commands.js +54 -64
  58. package/dist/core/locales/slices/init.d.ts +8 -19
  59. package/dist/core/locales/slices/init.js +17 -53
  60. package/dist/core/locales/slices/interactions.d.ts +3 -3
  61. package/dist/core/locales/slices/interactions.js +6 -6
  62. package/dist/core/locales/slices/notices.d.ts +1 -3
  63. package/dist/core/locales/slices/notices.js +2 -6
  64. package/dist/core/locales/slices/scheduling.d.ts +9 -9
  65. package/dist/core/locales/slices/scheduling.js +18 -18
  66. package/dist/core/locales/slices/status.d.ts +0 -4
  67. package/dist/core/locales/slices/status.js +0 -8
  68. package/dist/core/locales/slices/tui.d.ts +0 -1
  69. package/dist/core/locales/slices/tui.js +0 -2
  70. package/dist/core/locales/slices/uimsg.d.ts +4 -7
  71. package/dist/core/locales/slices/uimsg.js +9 -15
  72. package/dist/core/models-generator.d.ts +29 -0
  73. package/dist/core/models-generator.js +82 -0
  74. package/dist/core/paths.d.ts +1 -1
  75. package/dist/core/paths.js +1 -1
  76. package/dist/core/settings-spec.d.ts +25 -0
  77. package/dist/core/settings-spec.js +34 -0
  78. package/dist/core/status-format.d.ts +3 -2
  79. package/dist/core/status-format.js +2 -2
  80. package/dist/core/types/environment-types.d.ts +0 -2
  81. package/dist/domain/agents/agent-state.d.ts +11 -56
  82. package/dist/domain/agents/agent-state.js +48 -115
  83. package/dist/domain/agents/agent-switch.d.ts +2 -24
  84. package/dist/domain/agents/agent-switch.js +9 -72
  85. package/dist/domain/agents/config.d.ts +11 -61
  86. package/dist/domain/agents/config.js +47 -154
  87. package/dist/domain/agents/engine-selection.d.ts +21 -0
  88. package/dist/domain/agents/engine-selection.js +37 -0
  89. package/dist/domain/agents/environments/registry.js +2 -1
  90. package/dist/domain/agents/environments/resolve.js +0 -1
  91. package/dist/domain/agents/environments/schema.d.ts +0 -1
  92. package/dist/domain/agents/environments/schema.js +0 -1
  93. package/dist/domain/agents/index.d.ts +2 -1
  94. package/dist/domain/agents/index.js +3 -7
  95. package/dist/domain/agents/model-selection.d.ts +18 -70
  96. package/dist/domain/agents/model-selection.js +100 -150
  97. package/dist/domain/agents/models.d.ts +12 -0
  98. package/dist/domain/agents/models.js +94 -0
  99. package/dist/domain/agents/subagent/registry.d.ts +2 -0
  100. package/dist/domain/agents/subagent/registry.js +8 -0
  101. package/dist/domain/agents/subagent/runner.d.ts +5 -5
  102. package/dist/domain/agents/subagent/runner.js +12 -35
  103. package/dist/domain/auth/auth-status.d.ts +4 -4
  104. package/dist/domain/auth/auth-status.js +17 -28
  105. package/dist/domain/auth/gateway-sync.d.ts +6 -26
  106. package/dist/domain/auth/gateway-sync.js +31 -75
  107. package/dist/domain/benchmark/identity.d.ts +3 -5
  108. package/dist/domain/benchmark/identity.js +0 -1
  109. package/dist/domain/benchmark/production-attempt-identity.d.ts +6 -5
  110. package/dist/domain/benchmark/production-attempt-identity.js +32 -35
  111. package/dist/domain/benchmark/session-evidence.d.ts +2 -1
  112. package/dist/domain/benchmark/session-evidence.js +8 -1
  113. package/dist/domain/browser/broker.d.ts +99 -0
  114. package/dist/domain/browser/broker.js +487 -0
  115. package/dist/domain/costs/claude-account.js +21 -0
  116. package/dist/domain/costs/rate-limit-throttle.js +3 -1
  117. package/dist/domain/costs/reset-account.d.ts +2 -0
  118. package/dist/domain/costs/usage-service.d.ts +1 -1
  119. package/dist/domain/costs/usage-service.js +20 -7
  120. package/dist/domain/mcp/tools/context.d.ts +5 -6
  121. package/dist/domain/mcp/tools/context.js +17 -3
  122. package/dist/domain/mcp/tools/subagent.js +1 -1
  123. package/dist/domain/mcp/tools/ui-file.js +1 -1
  124. package/dist/domain/pi-providers/custom-provider-model.d.ts +1 -1
  125. package/dist/domain/pi-providers/custom-provider-model.js +1 -1
  126. package/dist/domain/remote/device-browser.js +1 -1
  127. package/dist/domain/remote/device-chrome-commands.js +2 -0
  128. package/dist/domain/remote/device-port.js +2 -2
  129. package/dist/domain/runs/attempt.d.ts +3 -3
  130. package/dist/domain/runs/attempt.js +2 -3
  131. package/dist/domain/runs/builders.d.ts +4 -4
  132. package/dist/domain/runs/builders.js +4 -5
  133. package/dist/domain/runs/compact.d.ts +4 -17
  134. package/dist/domain/runs/compact.js +14 -56
  135. package/dist/domain/runs/config-resolver.d.ts +15 -83
  136. package/dist/domain/runs/config-resolver.js +24 -150
  137. package/dist/domain/runs/engine-spec.d.ts +8 -8
  138. package/dist/domain/runs/engine-spec.js +15 -31
  139. package/dist/domain/runs/events.d.ts +1 -1
  140. package/dist/domain/runs/fallback.d.ts +6 -38
  141. package/dist/domain/runs/fallback.js +10 -72
  142. package/dist/domain/runs/notices.d.ts +1 -11
  143. package/dist/domain/runs/notices.js +3 -30
  144. package/dist/domain/runs/request.d.ts +4 -3
  145. package/dist/domain/runs/retryable-errors.d.ts +0 -13
  146. package/dist/domain/runs/retryable-errors.js +0 -17
  147. package/dist/domain/runs/run.d.ts +12 -42
  148. package/dist/domain/runs/run.js +40 -147
  149. package/dist/domain/runs/service.d.ts +1 -1
  150. package/dist/domain/runs/service.js +8 -3
  151. package/dist/domain/runs/spec-loader.d.ts +1 -1
  152. package/dist/domain/runs/spend.d.ts +1 -1
  153. package/dist/domain/runs/spend.js +1 -1
  154. package/dist/domain/scheduling/jobs/scheduled-task.d.ts +3 -2
  155. package/dist/domain/scheduling/jobs/scheduled-task.js +25 -19
  156. package/dist/domain/scheduling/schedule-ops.d.ts +0 -1
  157. package/dist/domain/scheduling/schedule-ops.js +2 -5
  158. package/dist/domain/scheduling/schedule-selection.d.ts +3 -0
  159. package/dist/domain/scheduling/schedule-selection.js +16 -0
  160. package/dist/domain/scheduling/schedule-spec.d.ts +6 -5
  161. package/dist/domain/scheduling/schedule-spec.js +6 -6
  162. package/dist/domain/scheduling/scheduler.d.ts +3 -1
  163. package/dist/domain/scheduling/scheduler.js +22 -21
  164. package/dist/domain/sessions/session-hooks.d.ts +5 -4
  165. package/dist/domain/sessions/session-hooks.js +15 -33
  166. package/dist/domain/sessions/session-lifecycle.d.ts +19 -51
  167. package/dist/domain/sessions/session-lifecycle.js +34 -96
  168. package/dist/domain/system/doctor.d.ts +3 -3
  169. package/dist/domain/system/doctor.js +22 -26
  170. package/dist/domain/system/own-bin-path.d.ts +13 -0
  171. package/dist/domain/system/own-bin-path.js +36 -0
  172. package/dist/domain/system/terminal-cli/index.d.ts +58 -0
  173. package/dist/domain/system/terminal-cli/index.js +100 -0
  174. package/dist/domain/system/terminal-cli/posix-profiles.d.ts +23 -0
  175. package/dist/domain/system/terminal-cli/posix-profiles.js +74 -0
  176. package/dist/domain/system/terminal-cli/registrar.d.ts +12 -0
  177. package/dist/domain/system/terminal-cli/registrar.js +1 -0
  178. package/dist/domain/system/terminal-cli/shims.d.ts +27 -0
  179. package/dist/domain/system/terminal-cli/shims.js +108 -0
  180. package/dist/domain/system/terminal-cli/state.d.ts +7 -0
  181. package/dist/domain/system/terminal-cli/state.js +36 -0
  182. package/dist/domain/system/terminal-cli/windows-user-path.d.ts +13 -0
  183. package/dist/domain/system/terminal-cli/windows-user-path.js +67 -0
  184. package/dist/domain/tui-session/tui-session-service.js +1 -1
  185. package/dist/domain/tui-session/types.d.ts +2 -2
  186. package/dist/domain/ui-service/app-router.d.ts +49 -71
  187. package/dist/domain/ui-service/app-router.js +9 -13
  188. package/dist/domain/ui-service/assistant-snapshots.js +2 -0
  189. package/dist/domain/ui-service/contract.parity.d.ts +19 -0
  190. package/dist/domain/ui-service/contract.parity.js +1 -0
  191. package/dist/domain/ui-service/inline-media-types.d.ts +18 -0
  192. package/dist/domain/ui-service/inline-media-types.js +1 -0
  193. package/dist/domain/ui-service/input-schemas.d.ts +52 -115
  194. package/dist/domain/ui-service/input-schemas.js +38 -84
  195. package/dist/domain/ui-service/mutate/auth.d.ts +1 -1
  196. package/dist/domain/ui-service/mutate/auth.js +3 -2
  197. package/dist/domain/ui-service/mutate/config.d.ts +0 -8
  198. package/dist/domain/ui-service/mutate/config.js +0 -22
  199. package/dist/domain/ui-service/mutate/models.d.ts +13 -0
  200. package/dist/domain/ui-service/mutate/models.js +137 -0
  201. package/dist/domain/ui-service/mutate/resolve-media.d.ts +4 -0
  202. package/dist/domain/ui-service/mutate/resolve-media.js +17 -0
  203. package/dist/domain/ui-service/mutate/sessions.d.ts +2 -2
  204. package/dist/domain/ui-service/mutate/sessions.js +29 -126
  205. package/dist/domain/ui-service/query/config.js +22 -42
  206. package/dist/domain/ui-service/query/models.js +2 -2
  207. package/dist/domain/ui-service/query/schedules.js +1 -1
  208. package/dist/domain/ui-service/query/sessions.js +7 -13
  209. package/dist/domain/ui-service/types.d.ts +51 -177
  210. package/dist/domain/ui-service/ui-service.d.ts +23 -49
  211. package/dist/domain/ui-service/ui-service.js +8 -6
  212. package/dist/entry/app.js +42 -19
  213. package/dist/entry/browser-cli.d.ts +39 -0
  214. package/dist/entry/browser-cli.js +317 -0
  215. package/dist/entry/cli-help.d.ts +1 -0
  216. package/dist/entry/cli-help.js +37 -6
  217. package/dist/entry/cli.js +16 -14
  218. package/dist/entry/daemon.js +2 -0
  219. package/dist/entry/init-auth.js +1 -1
  220. package/dist/entry/init.d.ts +7 -8
  221. package/dist/entry/init.js +89 -249
  222. package/dist/entry/path-cli.d.ts +4 -0
  223. package/dist/entry/path-cli.js +65 -0
  224. package/dist/entry/schedule-cli.js +13 -6
  225. package/dist/entry/shutdown.d.ts +1 -1
  226. package/dist/entry/shutdown.js +8 -1
  227. package/dist/entry/start-ui-http.js +8 -0
  228. package/dist/entry/ui-service-wiring.js +8 -10
  229. package/dist/events/event-types.d.ts +3 -2
  230. package/dist/orchestration/agent-runner.d.ts +2 -2
  231. package/dist/orchestration/agent-runner.js +10 -9
  232. package/dist/orchestration/benchmark-session-webhook.js +13 -1
  233. package/dist/orchestration/browser-webhook.d.ts +11 -0
  234. package/dist/orchestration/browser-webhook.js +28 -0
  235. package/dist/orchestration/cache-keep-warm.d.ts +77 -0
  236. package/dist/orchestration/cache-keep-warm.js +213 -0
  237. package/dist/orchestration/claude-window-warmup.d.ts +40 -0
  238. package/dist/orchestration/claude-window-warmup.js +126 -0
  239. package/dist/orchestration/conversation-request.d.ts +6 -10
  240. package/dist/orchestration/conversation-request.js +5 -23
  241. package/dist/orchestration/delta-coalescer.d.ts +4 -2
  242. package/dist/orchestration/delta-coalescer.js +5 -5
  243. package/dist/orchestration/edit-retry.js +9 -11
  244. package/dist/orchestration/inline-media-eager.d.ts +13 -0
  245. package/dist/orchestration/inline-media-eager.js +58 -0
  246. package/dist/orchestration/inline-media.d.ts +22 -0
  247. package/dist/orchestration/inline-media.js +151 -0
  248. package/dist/orchestration/interactions/ask-user-resume.js +3 -7
  249. package/dist/orchestration/interactions/interaction-handlers.js +6 -6
  250. package/dist/orchestration/mid-turn-inject.d.ts +2 -1
  251. package/dist/orchestration/mid-turn-inject.js +1 -1
  252. package/dist/orchestration/pending-injection-recovery.d.ts +2 -1
  253. package/dist/orchestration/pending-injection-recovery.js +1 -1
  254. package/dist/orchestration/routing/commands/index.js +4 -4
  255. package/dist/orchestration/routing/commands/mode.d.ts +5 -44
  256. package/dist/orchestration/routing/commands/mode.js +98 -272
  257. package/dist/orchestration/routing/commands/schedule.js +29 -18
  258. package/dist/orchestration/routing/commands/session.js +9 -9
  259. package/dist/orchestration/routing/commands/status.js +1 -1
  260. package/dist/orchestration/routing/commands/usage-format.js +3 -0
  261. package/dist/orchestration/routing/webhook.js +4 -0
  262. package/dist/orchestration/session-compact.d.ts +0 -1
  263. package/dist/orchestration/session-compact.js +5 -7
  264. package/dist/orchestration/session-events.d.ts +2 -1
  265. package/dist/orchestration/session-events.js +1 -0
  266. package/dist/orchestration/status-helpers.d.ts +0 -4
  267. package/dist/orchestration/status-helpers.js +0 -18
  268. package/dist/orchestration/subagent-webhook.js +9 -34
  269. package/dist/orchestration/team-webhook.d.ts +8 -9
  270. package/dist/orchestration/team-webhook.js +16 -42
  271. package/dist/orchestration/transcript-sink.d.ts +6 -0
  272. package/dist/orchestration/transcript-sink.js +21 -2
  273. package/dist/orchestration/turn/terminal.js +7 -7
  274. package/dist/orchestration/turn/turn-prep.d.ts +0 -8
  275. package/dist/orchestration/turn/turn-prep.js +0 -51
  276. package/dist/orchestration/turn/turn-tracking.d.ts +2 -2
  277. package/dist/orchestration/turn/turn-tracking.js +8 -5
  278. package/dist/orchestration/turn/turn.d.ts +0 -2
  279. package/dist/orchestration/turn/turn.js +13 -15
  280. package/dist/platform/adapters/tui/ports.d.ts +1 -1
  281. package/dist/platform/adapters/tui/tui-transcript.js +2 -0
  282. package/dist/platform/browser/agent-browser.d.ts +50 -0
  283. package/dist/platform/browser/agent-browser.js +165 -0
  284. package/dist/platform/browser/managed-browser.d.ts +1 -11
  285. package/dist/platform/browser/managed-browser.js +4 -12
  286. package/dist/platform/ui-http/browser-stream.d.ts +110 -0
  287. package/dist/platform/ui-http/browser-stream.js +447 -0
  288. package/dist/platform/ui-http/ui-http-server.d.ts +12 -0
  289. package/dist/platform/ui-http/ui-http-server.js +23 -6
  290. package/dist/store/conversation-history-reader.js +8 -0
  291. package/dist/store/conversation-history-repo.d.ts +8 -1
  292. package/dist/store/conversation-history-repo.js +5 -0
  293. package/dist/store/conversation-ledger-repo.d.ts +6 -6
  294. package/dist/store/conversation-ledger-repo.js +4 -4
  295. package/dist/store/models-repo.d.ts +18 -0
  296. package/dist/store/models-repo.js +74 -0
  297. package/dist/store/pending-injection-repo.d.ts +2 -1
  298. package/dist/store/pending-injection-repo.js +3 -1
  299. package/dist/store/retire-profiles-migration.d.ts +28 -0
  300. package/dist/store/retire-profiles-migration.js +335 -0
  301. package/dist/store/schedule-repo.d.ts +2 -1
  302. package/dist/store/session-registry-import.js +3 -2
  303. package/dist/store/session-registry-journal.d.ts +10 -13
  304. package/dist/store/session-registry-journal.js +48 -25
  305. package/dist/store/session-registry-repo.d.ts +4 -4
  306. package/dist/store/session-registry-repo.js +4 -5
  307. package/dist/store/version-migrations.d.ts +2 -3
  308. package/dist/store/version-migrations.js +19 -3
  309. package/dist/tui/slash-commands.js +2 -2
  310. package/dist/tui/turn-status.js +1 -1
  311. package/package.json +6 -4
  312. package/web/dist/assets/board-math-css-CB4GJ6qO.js +2 -0
  313. package/web/dist/assets/index-CaSZPg_H.css +1 -0
  314. package/web/dist/assets/index-CzOR7Edh.js +522 -0
  315. package/web/dist/assets/{index-CndZZ1IQ.js → index-cIGFv27z.js} +1 -1
  316. package/web/dist/index.html +3 -2
  317. package/web/dist/theme.css +6 -0
  318. package/dist/agent-adapter/browser-mcp-server.d.ts +0 -13
  319. package/dist/agent-adapter/browser-mcp-server.js +0 -28
  320. package/dist/agent-adapter/claude/browser-mcp.d.ts +0 -9
  321. package/dist/agent-adapter/claude/browser-mcp.js +0 -10
  322. package/dist/core/profile-generator.d.ts +0 -79
  323. package/dist/core/profile-generator.js +0 -215
  324. package/dist/domain/agents/profile-manager.d.ts +0 -103
  325. package/dist/domain/agents/profile-manager.js +0 -286
  326. package/dist/domain/agents/profile-switch.d.ts +0 -49
  327. package/dist/domain/agents/profile-switch.js +0 -62
  328. package/dist/domain/ui-service/mutate/profiles.d.ts +0 -36
  329. package/dist/domain/ui-service/mutate/profiles.js +0 -151
  330. package/dist/store/profile-repo.d.ts +0 -20
  331. package/dist/store/profile-repo.js +0 -97
  332. package/web/dist/assets/index-B76ueW3q.js +0 -494
  333. package/web/dist/assets/index-C8O0yxg8.css +0 -1
@@ -1,3 +1,4 @@
1
+ import type { EngineSelection } from '../agents/engine-selection.js';
1
2
  import type { ScheduleTask } from '../../store/schedule-repo.js';
2
3
  export declare const SCHEDULE_TYPES: readonly ['interval', 'daily', 'weekly', 'once'];
3
4
  export type ScheduleType = typeof SCHEDULE_TYPES[number];
@@ -21,7 +22,7 @@ export type ScheduleTiming = {
21
22
  export type ScheduleSpec = ScheduleTiming & {
22
23
  message: string;
23
24
  projectId: string;
24
- profile: string | null;
25
+ selection?: EngineSelection;
25
26
  preCheck?: string;
26
27
  };
27
28
  /** Schedule fields as an entry point parsed them from its own syntax. Durations are a unit string
@@ -30,7 +31,7 @@ export interface ScheduleSpecInput {
30
31
  type: string | undefined;
31
32
  message: string | null | undefined;
32
33
  projectId?: string | null;
33
- profile?: string | null;
34
+ selection?: EngineSelection | null;
34
35
  preCheck?: string | null;
35
36
  interval?: string | number;
36
37
  time?: string;
@@ -41,7 +42,7 @@ export interface ScheduleSpecInput {
41
42
  export interface SchedulePatch {
42
43
  message?: string;
43
44
  projectId?: string;
44
- profile?: string | null;
45
+ selection?: EngineSelection;
45
46
  preCheck?: string;
46
47
  dispatchType?: string;
47
48
  intervalMs?: number;
@@ -74,5 +75,5 @@ export declare function nextFireDelayMs(task: Pick<ScheduleTask, 'type' | 'inter
74
75
  /** Recompute nextRun after a recurring task's timing or pause state changed. A once task keeps
75
76
  * its runAt. */
76
77
  export declare function retimeTask(task: ScheduleTask, now?: number): void;
77
- /** The persisted record for a new schedule. `profile` is already resolved by the caller. */
78
- export declare function buildScheduleTask(spec: ScheduleSpec, id: string, now: number, profile: string): ScheduleTask;
78
+ /** The persisted record for a new schedule. The caller has materialized its selection. */
79
+ export declare function buildScheduleTask(spec: ScheduleSpec, id: string, now: number, selection: EngineSelection): ScheduleTask;
@@ -80,12 +80,12 @@ export function normalizeScheduleSpec(input) {
80
80
  ...timing,
81
81
  message: normalizeMessage(input.message),
82
82
  projectId: input.projectId?.trim() || 'general',
83
- profile: input.profile?.trim() || null,
83
+ selection: input.selection ? { ...input.selection } : undefined,
84
84
  ...(preCheck ? { preCheck } : {}),
85
85
  };
86
86
  }
87
87
  const BUILTIN_JOB_DISPATCH_TYPES = new Set(['memory-index-regen']);
88
- const COMMON_PATCH_FIELDS = ['message', 'projectId', 'profile', 'dispatchType', 'preCheck'];
88
+ const COMMON_PATCH_FIELDS = ['message', 'projectId', 'selection', 'dispatchType', 'preCheck'];
89
89
  export const TIMING_PATCH_FIELDS = {
90
90
  interval: ['intervalMs'],
91
91
  daily: ['time'],
@@ -157,10 +157,10 @@ export function retimeTask(task, now = Date.now()) {
157
157
  return;
158
158
  task.nextRun = task.isPaused ? null : now + nextFireDelayMs(task, now);
159
159
  }
160
- /** The persisted record for a new schedule. `profile` is already resolved by the caller. */
161
- export function buildScheduleTask(spec, id, now, profile) {
162
- const { message, projectId, preCheck, profile: _profile, ...timing } = spec;
163
- const base = { id, message, projectId, profile, preCheck, createdAt: now };
160
+ /** The persisted record for a new schedule. The caller has materialized its selection. */
161
+ export function buildScheduleTask(spec, id, now, selection) {
162
+ const { message, projectId, preCheck, selection: _selection, ...timing } = spec;
163
+ const base = { id, message, projectId, selection: { ...selection }, preCheck, createdAt: now };
164
164
  if (timing.type === 'once')
165
165
  return { ...base, type: 'once', runAt: now + timing.delayMs };
166
166
  const task = { ...base, ...timing, lastRun: null, nextRun: null };
@@ -1,12 +1,13 @@
1
1
  import { FSWatcher } from 'fs';
2
2
  import { ScheduleRepo, type ScheduleTask } from '../../store/schedule-repo.js';
3
3
  import { type ScheduleSpec, type SchedulePatch } from './schedule-spec.js';
4
+ import type { EngineSelection } from '../agents/engine-selection.js';
4
5
  export type { ScheduleTask } from '../../store/schedule-repo.js';
5
6
  interface RunnerParams {
6
7
  message: string;
7
8
  projectId: string;
8
9
  scheduleTaskId: string;
9
- profileName: string;
10
+ selection: EngineSelection;
10
11
  }
11
12
  interface ProgrammaticHandlerParams {
12
13
  channel: string;
@@ -69,5 +70,6 @@ declare class Scheduler {
69
70
  /** Run the task's preCheck shell gate. A failing check records the skip and returns false. */
70
71
  _passesPreCheck(task: ScheduleTask): Promise<boolean>;
71
72
  _runTask(task: ScheduleTask): Promise<void>;
73
+ _dispatchTask(task: ScheduleTask): Promise<void>;
72
74
  }
73
75
  export { Scheduler };
@@ -7,14 +7,15 @@ import { createLogger } from '../../core/log.js';
7
7
  import { emitCortexEvent } from '../../core/hook-bus.js';
8
8
  import { ScheduleRepo, scheduleRepo, SCHEDULES_FILE } from '../../store/schedule-repo.js';
9
9
  import { nextFireDelayMs } from './schedule-spec.js';
10
- import { addSchedule, pauseSchedule, resolveTaskProfile, resumeSchedule, updateSchedule } from './schedule-ops.js';
10
+ import { addSchedule, pauseSchedule, resumeSchedule, updateSchedule } from './schedule-ops.js';
11
+ import { getDefaultSelection } from '../agents/models.js';
11
12
  const log = createLogger('scheduler');
12
13
  // Hash the task fields that affect when and how it fires (not run timestamps)
13
14
  function taskConfigHash(task) {
14
15
  const keys = { interval: 'intervalMs', daily: 'time', once: 'runAt', weekly: 'dayOfWeek' };
15
16
  const key = keys[task.type];
16
17
  const extra = task.type === 'weekly' ? `${task.dayOfWeek}:${task.time}` : (String(task[key] || ''));
17
- return `${task.type}:${extra}:${task.message}:${task.projectId}:${task.profile || ''}:${task.dispatchType || ''}:${task.preCheck || ''}:${task.isPaused ? 'paused' : ''}`;
18
+ return `${task.type}:${extra}:${task.message}:${task.projectId}:${JSON.stringify(task.selection ?? null)}:${task.dispatchType || ''}:${task.preCheck || ''}:${task.isPaused ? 'paused' : ''}`;
18
19
  }
19
20
  // The daemon's live view of schedules.json. `cortex schedule` writes the file
20
21
  // directly through schedule-ops; the file watcher re-reads it
@@ -268,35 +269,35 @@ class Scheduler {
268
269
  }
269
270
  // Internal: invoke the runner for a task
270
271
  async _runTask(task) {
271
- const profileName = resolveTaskProfile(task.profile);
272
- const resolvedChannel = task.projectId;
273
- log.info(`Firing task ${task.id} (${task.type}, dispatch=${task.dispatchType || 'llm'}, profile=${profileName}, project=${task.projectId}): "${task.message}"`);
272
+ log.info(`Firing task ${task.id} (${task.type}, dispatch=${task.dispatchType || 'llm'}, model=${task.selection?.model || 'default'}, project=${task.projectId}): "${task.message}"`);
274
273
  void emitCortexEvent('cortex:schedule.fired', {
275
274
  scheduleId: task.id,
276
275
  name: task.message,
277
276
  project: task.projectId,
278
277
  }).catch(() => { });
279
278
  try {
280
- if (task.dispatchType) {
281
- const handler = this.programmaticHandlers[task.dispatchType];
282
- if (!handler) {
283
- log.warn(`Skipping task ${task.id}: unregistered dispatch type "${task.dispatchType}"`);
284
- return;
285
- }
286
- await handler({ channel: resolvedChannel, scheduleTaskId: task.id });
287
- }
288
- else {
289
- await this.runner({
290
- message: `[Scheduled Task] ${task.message}`,
291
- projectId: task.projectId,
292
- scheduleTaskId: task.id,
293
- profileName,
294
- });
295
- }
279
+ await this._dispatchTask(task);
296
280
  }
297
281
  catch (e) {
298
282
  log.error(`Task ${task.id} runner error:`, e.message);
299
283
  }
300
284
  }
285
+ async _dispatchTask(task) {
286
+ if (!task.dispatchType) {
287
+ await this.runner({
288
+ message: `[Scheduled Task] ${task.message}`,
289
+ projectId: task.projectId,
290
+ scheduleTaskId: task.id,
291
+ selection: task.selection ?? getDefaultSelection(),
292
+ });
293
+ return;
294
+ }
295
+ const handler = this.programmaticHandlers[task.dispatchType];
296
+ if (!handler) {
297
+ log.warn(`Skipping task ${task.id}: unregistered dispatch type "${task.dispatchType}"`);
298
+ return;
299
+ }
300
+ await handler({ channel: task.projectId, scheduleTaskId: task.id });
301
+ }
301
302
  }
302
303
  export { Scheduler };
@@ -1,4 +1,5 @@
1
1
  import type { PlatformAdapter, OutputStream } from '../../platform/index.js';
2
+ import type { EngineSelection } from '../agents/engine-selection.js';
2
3
  import { startRun } from '../runs/service.js';
3
4
  import type { RunRequest } from '../runs/request.js';
4
5
  declare const SESSION_EVENTS: {
@@ -16,7 +17,7 @@ export interface SessionHookContext {
16
17
  /** The backend's own id for the session's conversation (its transcript), when it has one. */
17
18
  backendSessionId?: string | null;
18
19
  executionId?: string | null;
19
- profile?: string | null;
20
+ selection?: EngineSelection | null;
20
21
  }
21
22
  /** Caller-supplied formatters — keep wording per-hook so existing UX text doesn't change.
22
23
  * All formatters return short single-line strings; runSessionHook appends them via OutputStream,
@@ -40,7 +41,7 @@ export interface SessionHookInject {
40
41
  /** The backend conversation it resumes. Differs from `sessionId` once the backend has assigned
41
42
  * its own id (Slack, Feishu, the Web after a first turn) or a rewind has moved it. */
42
43
  backendSessionId: string;
43
- profileName: string | null;
44
+ selection: EngineSelection | null;
44
45
  /** Session-pool key for the injected turn.
45
46
  * - onNew: an ISOLATED key (onNewInjectSessionKey(channel)) so resuming the old session for
46
47
  * the pre-close turn never collides with the channel's live pool slot — see the race below.
@@ -102,7 +103,7 @@ export interface OnMessageEndArgs {
102
103
  /** The backend conversation the turn ran on; a follow-up turn resumes it. */
103
104
  backendSessionId: string | null;
104
105
  executionId: string;
105
- profile?: string | null;
106
+ selection?: EngineSelection | null;
106
107
  /** The finished turn's request; see {@link SessionHookInject.follows}. */
107
108
  request?: RunRequest | null;
108
109
  /** OutputStream to extend — pass the assistant turn's stream so the hook lines
@@ -115,7 +116,7 @@ export declare function runMessageEndSessionHook(args: OnMessageEndArgs): Promis
115
116
  /** Run the onMessageEnd hook for a turn that just finished. The hook's lines extend the assistant
116
117
  * turn's OutputStream, so hook output (status / preview / error) and any injected agent turn share
117
118
  * one continuous thread with the reply we just finished — no top-level leak, no detached stream.
118
- * The profile comes from the turn's conversation record, never from a global. */
119
+ * The selection comes from the turn's conversation record, never from a global. */
119
120
  export declare function runMessageEndForTurn(args: {
120
121
  channel: string;
121
122
  /** The Cortex session id (the registry key), not the backend's. */
@@ -2,8 +2,7 @@ import { randomUUID } from 'node:crypto';
2
2
  import { emitCortexEvent } from '../../core/hook-bus.js';
3
3
  import { createLogger } from '../../core/log.js';
4
4
  import { Icons } from '../../core/icons.js';
5
- import { resolveBackendForChannel } from '../agents/index.js';
6
- import { resolveProfileConfig } from '../agents/profile-manager.js';
5
+ import { resolveRunSelection } from '../runs/config-resolver.js';
7
6
  import { startRun } from '../runs/service.js';
8
7
  import { continuationRunRequest } from '../runs/builders.js';
9
8
  import { engines } from '../runs/engines.js';
@@ -42,20 +41,6 @@ export function isOnMessageEndHookConfigured() {
42
41
  export function onNewInjectSessionKey(channel) {
43
42
  return `${channel}::onnew-hook`;
44
43
  }
45
- /** Synthetic profile for an unknown/missing configured name: keeps the requested name so the
46
- * run still rejects it, while its backend mirrors the channel's live session. */
47
- function hookInjectionProfile(profileName, channel) {
48
- try {
49
- return resolveProfileConfig(profileName);
50
- }
51
- catch {
52
- return {
53
- name: profileName ?? '', model: '', backend: resolveBackendForChannel(channel), mode: null,
54
- provider: null, extraEnv: {}, extraOption: {}, thinking: null,
55
- maxOutputTokens: null, fallback: [],
56
- };
57
- }
58
- }
59
44
  const defaultInjectDeps = {
60
45
  startRun,
61
46
  closeInjectedSession: async (channel, sessionKey) => {
@@ -67,7 +52,7 @@ const defaultInjectDeps = {
67
52
  }
68
53
  },
69
54
  };
70
- /** The next turn on the engine `after` ran on: same session, agent, profile, policy and route —
55
+ /** The next turn on the engine `after` ran on: same session, agent, selection, policy and route —
71
56
  * the route keeps `after`'s trigger, since the gateway URL names it and the process was spawned on
72
57
  * it; the follow-up's own trigger is what its execution and cost are recorded under. */
73
58
  function followUpRequest(after, next) {
@@ -105,7 +90,7 @@ export async function runHookInjection(output, spec, stream, deps = defaultInjec
105
90
  // session id.
106
91
  engineKey: inject.sessionKey,
107
92
  },
108
- profile: hookInjectionProfile(inject.profileName, spec.ctx.channel),
93
+ selection: resolveRunSelection({ selection: inject.selection, channel: spec.ctx.channel }),
109
94
  prompt: output,
110
95
  channel: spec.ctx.channel,
111
96
  project: 'general',
@@ -151,7 +136,8 @@ function buildHookPayload(name, ctx) {
151
136
  sessionId: ctx.sessionId,
152
137
  backendSessionId: ctx.backendSessionId ?? null,
153
138
  executionId: ctx.executionId ?? null,
154
- profile: ctx.profile ?? null,
139
+ backend: ctx.selection?.backend ?? null,
140
+ model: ctx.selection?.model ?? null,
155
141
  trigger: name === 'onNew' ? 'new' : 'messageEnd',
156
142
  timestampIso: new Date().toISOString(),
157
143
  };
@@ -252,29 +238,25 @@ export async function resolveOnNewThreadAnchor(channel, threadAnchorId) {
252
238
  }
253
239
  return null;
254
240
  }
255
- /** What a session hook reads about its session, from the registry, keyed by the Cortex session id.
256
- * The registry is the SINGLE source of truth for the profile (B.T2): the per-session record is
257
- * right for every kind of session, where the old channel-level ledger fallback could name another
258
- * session on the same channel and resume with the wrong profile (wrong gateway mode → Anthropic
259
- * 400 on thinking blocks). */
241
+ /** Read the engine choice from the session record, never another session's channel state. */
260
242
  async function sessionHookTarget(sessionId) {
261
243
  const record = await sessionStore.getById(sessionId);
262
244
  return {
263
- profile: record?.profileName ?? null,
245
+ selection: record?.selection ?? null,
264
246
  backendSessionId: record ? effectiveBackendSessionId(record) : null,
265
247
  };
266
248
  }
267
249
  function onNewHookSpec(channel, sessionId, target) {
268
- const { profile, backendSessionId } = target;
250
+ const { selection, backendSessionId } = target;
269
251
  return {
270
252
  name: 'onNew',
271
- ctx: { channel, sessionId, profile, backendSessionId },
253
+ ctx: { channel, sessionId, selection, backendSessionId },
272
254
  format: ONNEW_FORMAT,
273
255
  // A session with no backend conversation yet has nothing for a pre-close turn to continue.
274
256
  inject: backendSessionId ? {
275
257
  sessionId,
276
258
  backendSessionId,
277
- profileName: profile,
259
+ selection,
278
260
  sessionKey: onNewInjectSessionKey(channel),
279
261
  trigger: 'hook:onNew',
280
262
  } : null,
@@ -319,13 +301,13 @@ export async function runMessageEndSessionHook(args) {
319
301
  sessionId: args.sessionId,
320
302
  backendSessionId: args.backendSessionId,
321
303
  executionId: args.executionId,
322
- profile: args.profile ?? null,
304
+ selection: args.selection ?? null,
323
305
  },
324
306
  format: ONMESSAGEEND_FORMAT,
325
307
  inject: args.backendSessionId ? {
326
308
  sessionId: args.sessionId,
327
309
  backendSessionId: args.backendSessionId,
328
- profileName: args.profile ?? null,
310
+ selection: args.selection ?? null,
329
311
  // onMessageEnd continues the live conversation — keep it on the channel pool slot.
330
312
  sessionKey: args.channel,
331
313
  trigger: 'hook:onMessageEnd',
@@ -337,7 +319,7 @@ export async function runMessageEndSessionHook(args) {
337
319
  /** Run the onMessageEnd hook for a turn that just finished. The hook's lines extend the assistant
338
320
  * turn's OutputStream, so hook output (status / preview / error) and any injected agent turn share
339
321
  * one continuous thread with the reply we just finished — no top-level leak, no detached stream.
340
- * The profile comes from the turn's conversation record, never from a global. */
322
+ * The selection comes from the turn's conversation record, never from a global. */
341
323
  export async function runMessageEndForTurn(args) {
342
324
  if (!isOnMessageEndHookConfigured() || !args.sessionId)
343
325
  return;
@@ -346,7 +328,7 @@ export async function runMessageEndForTurn(args) {
346
328
  return;
347
329
  }
348
330
  try {
349
- // Profile comes from the session registry (the single source of truth), keyed by the turn's
331
+ // Selection comes from the session registry (the single source of truth), keyed by the turn's
350
332
  // sessionId — never from the channel-level ledger, which could name a different session.
351
333
  const target = await sessionHookTarget(args.sessionId);
352
334
  await runMessageEndSessionHook({
@@ -354,7 +336,7 @@ export async function runMessageEndForTurn(args) {
354
336
  sessionId: args.sessionId,
355
337
  backendSessionId: args.backendSessionId ?? target.backendSessionId,
356
338
  executionId: args.executionId ?? '',
357
- profile: target.profile,
339
+ selection: target.selection,
358
340
  stream: args.stream,
359
341
  request: args.request,
360
342
  });
@@ -1,5 +1,5 @@
1
+ import type { EngineSelection } from '../agents/engine-selection.js';
1
2
  import type { SessionOrigin } from '../../store/session-registry-repo.js';
2
- import type { SessionBrowserOption } from '../../store/session-registry-journal.js';
3
3
  export interface SessionRegistryWriter {
4
4
  registerSession(opts: {
5
5
  sessionId: string;
@@ -9,9 +9,8 @@ export interface SessionRegistryWriter {
9
9
  origin?: SessionOrigin;
10
10
  projectId: string;
11
11
  label?: string | null;
12
- profileName?: string | null;
12
+ selection?: EngineSelection | null;
13
13
  agentName?: string | null;
14
- browser?: SessionBrowserOption | null;
15
14
  boardId?: string | null;
16
15
  teamLeadId?: string | null;
17
16
  workerName?: string | null;
@@ -25,99 +24,68 @@ export interface RegisterSessionRecordOpts {
25
24
  backend: string;
26
25
  projectId: string;
27
26
  label?: string | null;
28
- profileName?: string | null;
29
- /** The agent template the session runs as; null/absent means it follows the channel's selection
30
- * and, beneath that, the global default. */
27
+ selection?: EngineSelection | null;
28
+ /** The agent template; absent means the channel/global default. */
31
29
  agentName?: string | null;
32
- /** Opt-in browser access for this session; null/absent means no browser tools at all. */
33
- browser?: SessionBrowserOption | null;
34
- /** The board a new session starts bound to (a worker inherits its lead's). */
35
30
  boardId?: string | null;
36
- /** Team mode: the owning lead's sessionId, this worker's name and its brief. Absent for ordinary
37
- * sessions. */
38
31
  teamLeadId?: string | null;
39
32
  workerName?: string | null;
40
33
  workerBrief?: string | null;
41
- /** The schedule whose fire opened this session. Present, the session is that schedule's run
42
- * (kind and origin 'scheduled') until a reply adopts it as an ordinary direct session. */
34
+ /** Provenance retained when the user adopts a scheduled session. */
43
35
  scheduleId?: string | null;
44
36
  }
45
- /** Register a session by its stable ID. */
37
+ /** Register a session by its stable ID, freezing the engine choice for future resumes. */
46
38
  export declare function registerSessionRecord(store: SessionRegistryWriter, opts: RegisterSessionRecordOpts): Promise<void>;
47
39
  export interface CreateDirectSessionDeps {
48
40
  sessionStore: SessionRegistryWriter;
49
- /** Bind the channel to the new session in the registry (so a later send resumes it). */
50
41
  setChannelSession(channel: string, sessionId: string): Promise<void>;
51
- /** Initialize the conversation ledger for the new channel/session. */
52
42
  initConversation(channel: string, opts: {
53
43
  sessionId: string;
54
44
  backend: string;
45
+ selection: EngineSelection;
55
46
  }): Promise<void>;
56
- /** Resolve the backend the send path will use for the channel (agent-runner reads the same). */
57
47
  resolveBackend(channel: string): string;
58
48
  }
59
- /** Create a fresh, live session for a web/UI conversation: mint a sessionId, derive its own
60
- * `web:<sessionId>` conduit channel, register by ID, bind the channel→session mapping
61
- * and conversation ledger. Returns the sessionId + channel. The session is
62
- * user-initiated (origin='direct') unless `scheduleId` names the schedule whose fire opened it.
63
- *
64
- * When `profileName` is provided, the backend is resolved directly from the profile config (not
65
- * from the channel's profile state) so the session is bound to the correct backend even before any
66
- * channel profile is set. The channel profile is then set so subsequent sends resolve correctly.
67
- *
68
- * Because the channel is bound with the same backend the send path resolves, a subsequent send
69
- * resumes THIS session rather than spawning a new one. */
70
- export declare function createDirectSession(deps: CreateDirectSessionDeps, opts: {
49
+ interface CreateDirectSessionOpts {
71
50
  projectId: string;
72
51
  sessionId?: string;
73
- profileName?: string | null;
74
52
  agentName?: string | null;
75
- selection?: {
76
- model?: string;
77
- provider?: string;
78
- thinking?: string;
79
- mode?: string;
80
- } | null;
81
- browser?: SessionBrowserOption | null;
53
+ selection?: EngineSelection | null;
54
+ seedDefault?: boolean;
82
55
  boardId?: string | null;
83
56
  teamLeadId?: string | null;
84
57
  workerName?: string | null;
85
58
  workerBrief?: string | null;
86
59
  label?: string | null;
87
60
  scheduleId?: string | null;
88
- }): Promise<{
61
+ }
62
+ /** Mint a session and bind its conduit, registry and ledger to one materialized engine choice. */
63
+ export declare function createDirectSession(deps: CreateDirectSessionDeps, opts: CreateDirectSessionOpts): Promise<{
89
64
  sessionId: string;
90
65
  channel: string;
91
66
  }>;
92
67
  export interface AttachExistingSessionOpts {
93
68
  sessionId: string;
94
69
  backend: string;
95
- profileName?: string | null;
70
+ selection?: EngineSelection | null;
96
71
  }
97
- /** Attach a channel to an existing session: restore its profile (if any), bind the channel to it in
98
- * the registry, and switch the conversation ledger. Mirrors the !resume switch sequence. */
72
+ /** Resume restores the record verbatim, not the last choice of the channel it replaces. */
99
73
  export declare function attachExistingSession(channel: string, opts: AttachExistingSessionOpts): Promise<void>;
100
74
  export interface AdoptScheduledSessionStore {
101
75
  getById(sessionId: string): Promise<{
102
76
  channel: string;
103
77
  backend: string;
104
78
  origin: SessionOrigin;
105
- profileName: string | null;
79
+ selection: EngineSelection | null;
106
80
  } | null>;
107
- /** Re-point the registry record: channel → the adopted channel, kind → local, origin → direct. */
108
81
  convertToDirect(sessionId: string, opts: {
109
82
  channel: string;
110
83
  }): Promise<unknown | null>;
111
84
  }
112
- /** Convert a scheduled run's session into a normal direct web session (replying adopts the run).
113
- * A run opened on its own `web:<sessionId>` conduit is already bound there and only needs its record
114
- * re-pointed; an older run that lived on the shared project channel first gets that conduit attached
115
- * — the same switch sequence as !resume, so a later send resumes the run's transcript. `scheduleId`
116
- * is intentionally KEPT on the record (provenance for the trigger card / schedule grouping).
117
- * Idempotent: a non-scheduled record just returns its current channel; an unknown id returns null. */
85
+ /** Re-home older shared-channel scheduled runs; preserve provenance and engine selection. */
118
86
  export declare function adoptScheduledSession(store: AdoptScheduledSessionStore, sessionId: string): Promise<{
119
87
  channel: string;
120
88
  } | null>;
121
- /** Clear a channel's session state: unbind the channel in the registry, clean session
122
- * backups, and clear the conversation ledger. Mirrors the store-level half of !new. */
89
+ /** Clear the channel's binding, backups and conversation ledger. */
123
90
  export declare function resetChannelSession(channel: string): Promise<void>;
91
+ export {};