@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,6 +1,5 @@
1
1
  import { resolveMcpComposition } from '../types.js';
2
2
  import { fromCanonical } from '../../core/tool-names.js';
3
- import { browserMcpServer } from '../browser-mcp-server.js';
4
3
  import { MCP_TOOL_ALLOWLIST_ENV } from '../../core/mcp-tool-gate.js';
5
4
  export const PI_MCP_COMPOSITION_ENV = 'CORTEX_PI_MCP_COMPOSITION';
6
5
  export const PI_INTERACTION_BRIDGE_ENV = 'CORTEX_PI_INTERACTION_BRIDGE';
@@ -8,7 +7,8 @@ export const PI_TEAM_LEAD_ENV = 'CORTEX_PI_TEAM_LEAD';
8
7
  export const PI_TEAM_WORKER_ENV = 'CORTEX_PI_TEAM_WORKER';
9
8
  const RESET_CONTEXT_KEYS = [
10
9
  'SLACK_CHANNEL', 'FEISHU_CHANNEL',
11
- 'CORTEX_SESSION_ID', 'CORTEX_PROFILE',
10
+ 'CORTEX_SESSION_ID', 'CORTEX_PROFILE', // Strip the retired context key from inherited env.
11
+ 'CORTEX_BACKEND', 'CORTEX_MODEL', 'CORTEX_PROVIDER', 'CORTEX_THINKING', 'CORTEX_MODE',
12
12
  'CORTEX_PROJECT', 'CORTEX_SESSION_NAME', 'CORTEX_EXECUTION_ID',
13
13
  'CORTEX_CALLBACK_SOURCE', 'CORTEX_SCHEDULE_TASK_ID',
14
14
  'CORTEX_CONFIG_IMMUTABLE', 'CORTEX_PRODUCTION_AUTH_FILE',
@@ -23,10 +23,13 @@ function setOptional(env, key, value) {
23
23
  }
24
24
  function applyContext(env, options) {
25
25
  const context = options.context;
26
+ setOptional(env, 'CORTEX_MODEL', context?.selection?.model);
27
+ setOptional(env, 'CORTEX_PROVIDER', context?.selection?.provider);
28
+ setOptional(env, 'CORTEX_THINKING', context?.selection?.thinking);
29
+ setOptional(env, 'CORTEX_MODE', context?.selection?.mode);
26
30
  setOptional(env, 'CORTEX_SESSION_ID', context?.trackSessionId ?? options.sessionId);
27
31
  setOptional(env, 'CORTEX_CALLBACK_SOURCE', options.callbackSource);
28
32
  setOptional(env, 'CORTEX_SCHEDULE_TASK_ID', options.scheduleTaskId);
29
- setOptional(env, 'CORTEX_PROFILE', context?.profile);
30
33
  setOptional(env, 'CORTEX_PROJECT', context?.project);
31
34
  setOptional(env, 'CORTEX_EXECUTION_ID', context?.executionId);
32
35
  }
@@ -36,7 +39,7 @@ function applyContext(env, options) {
36
39
  * read their scope from it, and it doubles as part of the pooled-session identity.
37
40
  */
38
41
  export function buildPiEnv(options, inheritedEnv = process.env) {
39
- const env = { ...inheritedEnv, ...(options.extraEnv ?? {}) };
42
+ const env = { ...inheritedEnv, ...(options.routeEnv ?? {}) };
40
43
  for (const key of RESET_CONTEXT_KEYS)
41
44
  delete env[key];
42
45
  // After the merge: deletion is the only way to express "absent", since '' is a legal value here.
@@ -83,28 +86,11 @@ function allowedToolLabels(spec) {
83
86
  function subagentMarker(spec) {
84
87
  return spec.env.sets?.CORTEX_PI_SUBAGENT === '1' ? '1' : undefined;
85
88
  }
86
- /**
87
- * Plugin MCP servers for this session. Browser control rides along like any other plugin server,
88
- * gated on `direct` for the same reason Claude gates it: an unattended worker sharing one browser
89
- * is a cross-run side channel, not a feature.
90
- */
89
+ /** Plugin MCP servers for this session; only the direct composition carries them. */
91
90
  export function pluginMcpServers(spec, composition) {
92
91
  if (composition !== 'direct')
93
92
  return [];
94
- const servers = [...(spec.mcp.servers ?? [])];
95
- if (spec.mcp.browserCdpEndpoint && composition === 'direct') {
96
- servers.push(browserMcpServer(spec.mcp.browserCdpEndpoint));
97
- }
98
- return servers;
99
- }
100
- /** Thinking level: the profile field wins unless `extraOption` carries an explicit `--thinking`. */
101
- function thinkingLevel(spec) {
102
- const explicit = spec.extraOption?.['--thinking'];
103
- return explicit || spec.model.thinking || null;
104
- }
105
- /** `extraOption` keys other than `--thinking` were PI CLI flags; there is no CLI to hand them to. */
106
- export function unsupportedExtraOptions(spec) {
107
- return Object.keys(spec.extraOption ?? {}).filter((key) => key !== '--thinking');
93
+ return [...(spec.mcp.servers ?? [])];
108
94
  }
109
95
  export function buildSessionRequest(spec, inputs) {
110
96
  const composition = resolveMcpComposition(spec.mcp.composition);
@@ -114,7 +100,7 @@ export function buildSessionRequest(spec, inputs) {
114
100
  channel: spec.context.channel,
115
101
  callbackSource: spec.context.callbackSource,
116
102
  scheduleTaskId: spec.context.scheduleTaskId,
117
- extraEnv: spec.env.sets,
103
+ routeEnv: spec.env.sets,
118
104
  unsetEnv: spec.env.unsets,
119
105
  context: spec.env.context,
120
106
  piAgentDir: inputs.agentDir,
@@ -140,7 +126,8 @@ export function buildSessionRequest(spec, inputs) {
140
126
  sessionPath: inputs.sessionPath,
141
127
  provider: spec.model.provider ?? null,
142
128
  model: spec.model.id ? stripModelSuffix(spec.model.id) : null,
143
- thinking: thinkingLevel(spec),
129
+ benchmarkMaxOutputTokens: spec.model.benchmarkMaxOutputTokens,
130
+ thinking: spec.model.thinking ?? null,
144
131
  systemPrompt: spec.prompt.system || null,
145
132
  appendSystemPrompt: promptValues(spec.prompt.append),
146
133
  // PI has no skill layer of its own to switch off: its skills are exactly the roots handed to
@@ -6,13 +6,9 @@ import type { NormalizedEvent, ToolUseSubagent } from './normalize/event-types.j
6
6
  * (Claude background tasks, PI deferred completion, post-result injected messages).
7
7
  * - `done` — terminal bookkeeping after every background task has settled. */
8
8
  export type RunPhase = 'foreground' | 'background' | 'done';
9
- /** Opaque label identifying one attempt of the fallback chain, e.g. `model/mode`.
10
- * The plan sketches `run_fallback` with this type but does not define it; declared here so the
11
- * event union is self-contained until `domain/runs/run.ts` owns the real shape. */
12
- export type AttemptLabel = string;
13
9
  /** The one event union every run produces. Passthrough kinds keep the exact field names of the
14
10
  * `NormalizedEvent` member they translate from and add a `phase` tag; the remaining kinds are the
15
- * run's own vocabulary (dialogs, injections, accounting, fallback, terminal results). */
11
+ * run's own vocabulary (dialogs, injections, accounting, terminal results). */
16
12
  export type RunEvent = {
17
13
  type: 'engine_started';
18
14
  backendSessionId: string;
@@ -36,6 +32,16 @@ export type RunEvent = {
36
32
  text: string;
37
33
  blockId: string;
38
34
  phase: RunPhase;
35
+ } | {
36
+ type: 'assistant_thinking';
37
+ text: string;
38
+ blockId?: string;
39
+ phase: RunPhase;
40
+ } | {
41
+ type: 'assistant_thinking_delta';
42
+ text: string;
43
+ blockId: string;
44
+ phase: RunPhase;
39
45
  } | {
40
46
  type: 'tool_use';
41
47
  toolUseId: string;
@@ -124,11 +130,6 @@ export type RunEvent = {
124
130
  } | {
125
131
  type: 'turn_progress';
126
132
  numTurns: number;
127
- } | {
128
- type: 'run_fallback';
129
- from: AttemptLabel;
130
- to: AttemptLabel;
131
- reason: 'rate-limited' | 'transport-error';
132
133
  } | {
133
134
  type: 'foreground_result';
134
135
  result: AgentResult;
@@ -34,6 +34,8 @@ export function toRunEvent(event, phase) {
34
34
  };
35
35
  case 'assistant_text':
36
36
  return { ...event, phase };
37
+ case 'assistant_thinking':
38
+ case 'assistant_thinking_delta':
37
39
  case 'assistant_delta':
38
40
  return { ...event, phase };
39
41
  case 'tool_use':
@@ -3,6 +3,7 @@ import type { NormalizedEvent, ToolUseSubagent } from './normalize/event-types.j
3
3
  import type { AwaitBackground } from './continuation-phase.js';
4
4
  import type { RunEvent } from './run-events.js';
5
5
  import type { AgentResult, ContextUsage, ToolResultImage } from '../core/types/agent-types.js';
6
+ import type { EngineSelection } from '../domain/agents/engine-selection.js';
6
7
  import type { Backend } from '../core/types/agent-types.js';
7
8
  export type { Backend };
8
9
  export type McpComposition = 'direct' | 'none';
@@ -29,7 +30,8 @@ export interface RateLimitOrigin {
29
30
  export type RateLimitReporter = (info: RateLimitObservation, origin: RateLimitOrigin) => Promise<void>;
30
31
  /** Cortex execution context surfaced to child processes as CORTEX_* env vars. */
31
32
  export interface CortexContextEnv {
32
- profile?: string | null;
33
+ /** The actual selected attempt, not the request's original selection. */
34
+ selection?: EngineSelection;
33
35
  project?: string | null;
34
36
  /** Stable Cortex tracking id (decoupled from the backend `sessionId`). Surfaced as
35
37
  * CORTEX_SESSION_ID so session-activity logs + MCP context tools key on the stable UI-facing
@@ -55,7 +57,7 @@ export interface EngineSpec {
55
57
  id?: string;
56
58
  provider?: string;
57
59
  thinking?: string;
58
- maxOutputTokens?: number;
60
+ benchmarkMaxOutputTokens?: number;
59
61
  };
60
62
  prompt: {
61
63
  system?: string;
@@ -77,7 +79,6 @@ export interface EngineSpec {
77
79
  servers?: McpServerConfig[];
78
80
  allowlist?: string[];
79
81
  configPaths?: string[];
80
- browserCdpEndpoint?: string;
81
82
  };
82
83
  env: {
83
84
  sets?: Record<string, string>;
@@ -110,7 +111,6 @@ export interface EngineSpec {
110
111
  callbackSource?: string;
111
112
  scheduleTaskId?: string;
112
113
  };
113
- extraOption?: Record<string, string>;
114
114
  backend: {
115
115
  kind: 'claude';
116
116
  claudeAgent?: string;
@@ -193,6 +193,7 @@ export interface BackgroundTurnSink {
193
193
  /** Assistant text from the continuation turn (append to the original reply). `subagent` is set
194
194
  * only when a native subagent produced it (see ToolUseSubagent). */
195
195
  onAssistantText: (text: string, model?: string | null, subagent?: ToolUseSubagent) => void;
196
+ onAssistantThinking?: (text: string, blockId?: string) => void;
196
197
  /** Optional tool_use trace from the continuation turn, preserving its correlation id and,
197
198
  * when a native subagent made the call, its attribution. */
198
199
  onToolUse?: (name: string, input: any, toolUseId?: string, subagent?: ToolUseSubagent) => void;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2026.9.21",
2
+ "version": "2026.10.15",
3
3
  "hash": "8427e6d35fd14a8701b97c5d80cca778f5fc0340d0c938a485e25b666757cfcd",
4
- "source": "5b8226cacadc7b0c4108ca42d6619d016d9c7053"
4
+ "source": "3d9dd5c4e1df1c572d6146f72b8dca90ee53e0f5"
5
5
  }
@@ -1,4 +1,4 @@
1
- /** Provider slug this reading is attributed to; matches the gateway route and profile provider. */
1
+ /** Provider slug this reading is attributed to; matches the gateway route and model provider. */
2
2
  export declare const CODEX_PROVIDER = "openai-codex";
3
3
  export interface QuotaWindow {
4
4
  /** Codex limit family, preserving the provider's primary/secondary distinction. */
@@ -1,4 +1,4 @@
1
- /** Provider slug this reading is attributed to; matches the gateway route and profile provider. */
1
+ /** Provider slug this reading is attributed to; matches the gateway route and model provider. */
2
2
  export const CODEX_PROVIDER = 'openai-codex';
3
3
  /** The two limit buckets Codex advertises per response. `secondary` is empty on plans without a
4
4
  * short window (pro, 2026-08), so a bucket is only real when its window length is positive. */
@@ -23,13 +23,13 @@ export interface MergeGatewayResult {
23
23
  }>;
24
24
  }
25
25
  export interface GatewayValidationIssue {
26
- profile: string;
26
+ model: string;
27
27
  mode: string;
28
28
  provider?: string;
29
29
  reason: string;
30
30
  }
31
31
  export interface DiscoveredEndpoint {
32
- /** Mode key in gateway.yaml + cortex profile (e.g. "plan", "deepseek", "openai-codex") */
32
+ /** Mode key in gateway.yaml (e.g. "plan", "deepseek", "openai-codex") */
33
33
  mode: string;
34
34
  /** Endpoint group name (e.g. "anthropic", "deepseek", "openai-codex") */
35
35
  endpoint: string;
@@ -40,7 +40,7 @@ export interface DiscoveredEndpoint {
40
40
  /** Model IDs known to be available for this endpoint */
41
41
  models: string[];
42
42
  /** Whether gateway.yaml should render an endpoint section for this entry. PI providers without a
43
- * known upstream URL are surfaced as profiles but skipped in gateway.yaml. */
43
+ * known upstream URL are surfaced as models but skipped in gateway.yaml. */
44
44
  gatewayManaged: boolean;
45
45
  /** The model this endpoint recommends when nothing is chosen — PI's per-provider default, or the
46
46
  * newest Claude flagship. Always one of `models`; absent when the endpoint has no preference. */
@@ -77,12 +77,12 @@ export interface DiscoverEndpointsOptions {
77
77
  * @param backends - Optional filter: when provided, only discover endpoints for the listed backends
78
78
  * (e.g. `['claude']`, `['pi']`, `['claude', 'pi']`). When omitted, all backends are discovered.
79
79
  *
80
- * Claude endpoints come first, then PI providers in PI's order; profile defaults follow that order.
80
+ * Claude endpoints come first, then PI providers in PI's order; model recommendations follow that order.
81
81
  * - Claude Code plan mode: only when Claude Code holds a subscription login.
82
82
  * - Claude Code api mode: only when a real ANTHROPIC_API_KEY is available.
83
83
  * - PI providers: those PI reports usable auth for. Each provider becomes one endpoint with
84
84
  * `mode = endpoint = provider name`. `gatewayManaged` is true only if the provider has a known
85
- * upstream URL in PI_PROVIDER_UPSTREAM (otherwise profile is generated but gateway.yaml entry is
85
+ * upstream URL in PI_PROVIDER_UPSTREAM (otherwise the model is discovered but gateway.yaml entry is
86
86
  * skipped).
87
87
  */
88
88
  export declare function discoverEndpoints(backends?: string[], options?: DiscoverEndpointsOptions): Promise<DiscoveredEndpoint[]>;
@@ -90,7 +90,7 @@ export declare function discoverEndpoints(backends?: string[], options?: Discove
90
90
  * Generate gateway.yaml content from discovered endpoints.
91
91
  * Outputs a formatted YAML string with comments explaining each mode.
92
92
  *
93
- * Endpoints with gatewayManaged=false are skipped (their profile still exists in profiles.json,
93
+ * Endpoints with gatewayManaged=false are skipped (their models still exist in models.json,
94
94
  * but gateway.yaml has no entry for them — PI traffic to those providers is currently direct).
95
95
  */
96
96
  export declare function generateGatewayYaml(endpoints: DiscoveredEndpoint[], defaultMode?: string): string;
@@ -104,7 +104,7 @@ export declare function discoveredToEndpointMap(endpoints: DiscoveredEndpoint[])
104
104
  /**
105
105
  * Merge freshly discovered endpoints over an existing gateway config.
106
106
  *
107
- * Add-only at the (endpoint, mode) PAIR level (mirrors mergeProfilesJson overwrite=false): a pair
107
+ * Add-only at the (endpoint, mode) PAIR level (preserving existing operator choices): a pair
108
108
  * absent from the existing file is added from discovery; any pair that already exists is preserved
109
109
  * verbatim — its base_url, auth_style and (critically) managed keys are never clobbered. This both
110
110
  * fixes the original bug (a missing mode gets added) and protects hand-customized routes, e.g. a
@@ -125,11 +125,9 @@ export declare function writeMergedGatewayYaml(discovered: DiscoveredEndpoint[],
125
125
  result: MergeGatewayResult;
126
126
  };
127
127
  /**
128
- * Validate that every profile (and its fallback chain) in profiles.json references a gateway mode
129
- * that actually exists in the merged endpoint map. Pure + non-fatal — returns the list of problems
130
- * so the caller can warn loudly. This is what catches the `400 Unknown mode: <x>` class of bug.
128
+ * Check the default's selected route and whether each favorite has an available endpoint route.
131
129
  */
132
- export declare function validateProfilesAgainstGateway(mergedEndpoints: EndpointMap, profilesConfigDir?: string): GatewayValidationIssue[];
130
+ export declare function validateModelsAgainstGateway(mergedEndpoints: EndpointMap, configDir?: string): GatewayValidationIssue[];
133
131
  /**
134
132
  * Run discovery and return the YAML string (without writing to disk).
135
133
  * Useful for dry-run / preview.
@@ -23,7 +23,7 @@ const FLAT_MODE = 'default';
23
23
  * Map a PI built-in provider name to its real upstream URL. Used by `generateGatewayYaml` so PI
24
24
  * traffic can be routed through the gateway. Entries are sourced from PI source / docs.
25
25
  *
26
- * Providers absent from this table are still surfaced as cortex profiles, but no gateway endpoint
26
+ * Providers absent from this table are still surfaced as models, but no gateway endpoint
27
27
  * is generated for them (gatewayManaged=false). PI will then either fail (if the cortex spawn path
28
28
  * forces gateway routing) or direct-call the upstream (if the spawn path leaves models.json
29
29
  * untouched for that provider). Full provider plumbing remains future work.
@@ -55,7 +55,7 @@ const PI_PROVIDER_UPSTREAM = {
55
55
  'google-antigravity': { url: 'https://daily-cloudcode-pa.sandbox.googleapis.com', auth_style: 'bearer' },
56
56
  // Other built-ins
57
57
  google: { url: 'https://generativelanguage.googleapis.com/v1beta', auth_style: 'bearer' },
58
- // amazon-bedrock / google-vertex / azure-openai-responses / cloudflare-workers-ai use
58
+ // amazon-bedrock / google-vertex / azure / cloudflare-workers-ai use
59
59
  // env-driven URLs (region / account ID / resource name) — not safely templated here.
60
60
  // Users wanting these through the gateway must edit gateway.yaml manually.
61
61
  };
@@ -126,12 +126,12 @@ async function scanPiForEndpoints() {
126
126
  * @param backends - Optional filter: when provided, only discover endpoints for the listed backends
127
127
  * (e.g. `['claude']`, `['pi']`, `['claude', 'pi']`). When omitted, all backends are discovered.
128
128
  *
129
- * Claude endpoints come first, then PI providers in PI's order; profile defaults follow that order.
129
+ * Claude endpoints come first, then PI providers in PI's order; model recommendations follow that order.
130
130
  * - Claude Code plan mode: only when Claude Code holds a subscription login.
131
131
  * - Claude Code api mode: only when a real ANTHROPIC_API_KEY is available.
132
132
  * - PI providers: those PI reports usable auth for. Each provider becomes one endpoint with
133
133
  * `mode = endpoint = provider name`. `gatewayManaged` is true only if the provider has a known
134
- * upstream URL in PI_PROVIDER_UPSTREAM (otherwise profile is generated but gateway.yaml entry is
134
+ * upstream URL in PI_PROVIDER_UPSTREAM (otherwise the model is discovered but gateway.yaml entry is
135
135
  * skipped).
136
136
  */
137
137
  export async function discoverEndpoints(backends, options = {}) {
@@ -156,7 +156,7 @@ function anthropicEndpoint(mode, models, defaultModel) {
156
156
  }
157
157
  /**
158
158
  * Claude Code's endpoints, each present only when its credential is: an endpoint nobody logged
159
- * into would otherwise become the default profile and lock the user out of the one they did log
159
+ * into would otherwise become the default selection and lock the user out of the one they did log
160
160
  * into (merges never overwrite an existing plan/execute).
161
161
  */
162
162
  async function discoverClaudeEndpoints(options) {
@@ -218,7 +218,7 @@ function capitalize(s) {
218
218
  * Generate gateway.yaml content from discovered endpoints.
219
219
  * Outputs a formatted YAML string with comments explaining each mode.
220
220
  *
221
- * Endpoints with gatewayManaged=false are skipped (their profile still exists in profiles.json,
221
+ * Endpoints with gatewayManaged=false are skipped (their models still exist in models.json,
222
222
  * but gateway.yaml has no entry for them — PI traffic to those providers is currently direct).
223
223
  */
224
224
  export function generateGatewayYaml(endpoints, defaultMode) {
@@ -280,7 +280,7 @@ export function generateGatewayYaml(endpoints, defaultMode) {
280
280
  for (const s of skipped) {
281
281
  lines.push(`# ${s.mode} (${s.models.length} model${s.models.length === 1 ? '' : 's'})`);
282
282
  }
283
- lines.push('# These providers appear in profiles.json but are not routed through this gateway.');
283
+ lines.push('# These providers appear in models.json but are not routed through this gateway.');
284
284
  }
285
285
  lines.push('');
286
286
  return lines.join('\n');
@@ -355,7 +355,7 @@ export function discoveredToEndpointMap(endpoints) {
355
355
  /**
356
356
  * Merge freshly discovered endpoints over an existing gateway config.
357
357
  *
358
- * Add-only at the (endpoint, mode) PAIR level (mirrors mergeProfilesJson overwrite=false): a pair
358
+ * Add-only at the (endpoint, mode) PAIR level (preserving existing operator choices): a pair
359
359
  * absent from the existing file is added from discovery; any pair that already exists is preserved
360
360
  * verbatim — its base_url, auth_style and (critically) managed keys are never clobbered. This both
361
361
  * fixes the original bug (a missing mode gets added) and protects hand-customized routes, e.g. a
@@ -476,64 +476,37 @@ export function writeMergedGatewayYaml(discovered, outputDir, defaultMode) {
476
476
  return { path: configPath, result };
477
477
  }
478
478
  /**
479
- * Validate that every profile (and its fallback chain) in profiles.json references a gateway mode
480
- * that actually exists in the merged endpoint map. Pure + non-fatal — returns the list of problems
481
- * so the caller can warn loudly. This is what catches the `400 Unknown mode: <x>` class of bug.
479
+ * Check the default's selected route and whether each favorite has an available endpoint route.
482
480
  */
483
- export function validateProfilesAgainstGateway(mergedEndpoints, profilesConfigDir = CONFIG_DIR) {
484
- const profilesPath = path.join(profilesConfigDir, 'profiles.json');
481
+ export function validateModelsAgainstGateway(mergedEndpoints, configDir = CONFIG_DIR) {
482
+ const file = path.join(configDir, 'models.json');
485
483
  let parsed;
486
484
  try {
487
- if (!existsSync(profilesPath))
485
+ if (!existsSync(file))
488
486
  return [];
489
- parsed = JSON.parse(readFileSync(profilesPath, 'utf-8'));
487
+ parsed = JSON.parse(readFileSync(file, 'utf8'));
490
488
  }
491
- catch (e) {
492
- log.warn(`Failed to read profiles.json for validation: ${e.message}`);
489
+ catch (error) {
490
+ log.warn(`Failed to read models.json for validation: ${error.message}`);
493
491
  return [];
494
492
  }
495
- if (!isPlainObject(parsed) || !isPlainObject(parsed.profiles))
493
+ if (!isPlainObject(parsed))
496
494
  return [];
497
- const modeExistsAnywhere = (mode) => Object.values(mergedEndpoints).some((modes) => mode in modes);
498
- const issues = [];
499
- const checkEntry = (entry, label) => {
500
- const backend = typeof entry.backend === 'string' ? entry.backend : undefined;
501
- const mode = typeof entry.mode === 'string' ? entry.mode : undefined;
502
- const provider = typeof entry.provider === 'string' ? entry.provider : undefined;
503
- // No mode → PI uses direct /<provider> routing (no gateway mode indirection); nothing to check.
504
- if (!mode)
505
- return;
506
- let endpoint;
507
- if (backend === 'claude')
508
- endpoint = 'anthropic';
509
- else if (backend === 'pi')
510
- endpoint = provider;
511
- else
512
- return; // Unknown backends do not route through gateway modes here.
513
- if (backend === 'pi' && !provider) {
514
- issues.push({ profile: label, mode, reason: `pi profile is missing a provider (cannot resolve gateway endpoint)` });
515
- return;
516
- }
517
- if (!endpoint || !mergedEndpoints[endpoint]?.[mode]) {
518
- const reason = !modeExistsAnywhere(mode)
519
- ? `mode "${mode}" is not configured in gateway.yaml`
520
- : `endpoint "${endpoint}" is not configured under mode "${mode}"`;
521
- issues.push({ profile: label, mode, provider, reason });
522
- }
523
- };
524
- for (const [name, profileVal] of Object.entries(parsed.profiles)) {
525
- if (!isPlainObject(profileVal))
526
- continue;
527
- checkEntry(profileVal, name);
528
- const fallback = profileVal.fallback;
529
- if (Array.isArray(fallback)) {
530
- fallback.forEach((fb, i) => {
531
- if (isPlainObject(fb))
532
- checkEntry(fb, `${name} (fallback #${i + 1})`);
533
- });
534
- }
535
- }
536
- return issues;
495
+ const entries = [parsed.default, ...(Array.isArray(parsed.favorites) ? parsed.favorites : [])];
496
+ return entries.filter(isPlainObject).flatMap(entry => validateModelRoute(entry, mergedEndpoints));
497
+ }
498
+ function validateModelRoute(entry, endpoints) {
499
+ const provider = typeof entry.provider === 'string' ? entry.provider : undefined;
500
+ const endpoint = entry.backend === 'claude' ? 'anthropic' : provider;
501
+ const mode = typeof entry.mode === 'string' ? entry.mode : '';
502
+ const model = String(entry.model ?? '(unknown)');
503
+ if (!endpoint)
504
+ return [{ model, mode, reason: 'PI model is missing a provider (cannot resolve gateway endpoint)' }];
505
+ const routes = endpoints[endpoint] ?? {};
506
+ const available = mode ? !!routes[mode] : Object.keys(routes).length > 0;
507
+ if (available)
508
+ return [];
509
+ return [{ model, mode, provider, reason: `endpoint "${endpoint}" has no configured ${mode ? `mode "${mode}"` : 'route'} in gateway.yaml` }];
537
510
  }
538
511
  /**
539
512
  * Run discovery and return the YAML string (without writing to disk).