@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,39 +1,19 @@
1
1
  import { type DiscoveredEndpoint } from '../../core/gateway-generator.js';
2
+ import type { ModelRef } from '../agents/engine-selection.js';
2
3
  export interface GatewaySyncResult {
3
- /** True when gateway.yaml and profiles.json were regenerated. */
4
4
  configured: boolean;
5
- /** How many endpoints discovery reported. */
6
5
  endpoints: number;
7
- /** Profile names present after the sync (empty when nothing was written). */
8
- profiles: string[];
9
- /** Why nothing was written — 'no-endpoints' or an error message. */
6
+ /** Whether this sync supplied a previously missing default. */
7
+ defaultSet: boolean;
8
+ /** Favorites actually present after the sync. */
9
+ favorites: ModelRef[];
10
10
  reason?: string;
11
11
  }
12
12
  export interface GatewaySyncOptions {
13
- /** Limit discovery to these backends. Omitted → discover everything available. */
14
13
  backends?: string[];
15
- /** Where profiles.json lives. Defaults to the running install's config dir. */
16
14
  configDir?: string;
17
- /** Where gateway.yaml lives. Defaults to ~/.aistatus. */
18
15
  gatewayConfigDir?: string;
19
- /** Injectable discovery seam (tests supply fixed endpoints instead of scanning the machine). */
20
16
  discover?: (backends?: string[]) => DiscoveredEndpoint[] | Promise<DiscoveredEndpoint[]>;
21
17
  }
22
- /**
23
- * Regenerate gateway.yaml and profiles.json from the backends that are reachable right now.
24
- *
25
- * Logging in is only half of becoming usable: the models a provider exposes are discovered by
26
- * scanning local backend state (PI's auth and model catalog, Claude config), and that scan previously ran
27
- * only inside `cortex init` and `cortex setup-gateway`. A user who logged in from the workbench
28
- * therefore had working credentials but no profile pointing at the newly reachable models, with no
29
- * in-product way to fix it. Running this after a successful login closes that loop.
30
- *
31
- * Both writes are merge-aware on purpose: `writeMergedGatewayYaml` keeps hand-maintained modes, and
32
- * profiles are written with `overwrite: false` so an operator's edited `plan` / `execute` survives —
33
- * a login must never silently re-point which model the agents run on. Only missing profiles are
34
- * filled in.
35
- *
36
- * Never throws. It runs on the tail of a login flow and inside a UI mutation; a discovery hiccup
37
- * must not fail the login that just succeeded, so problems come back as `configured: false`.
38
- */
18
+ /** Add newly connected backend/provider groups without changing an existing default. Never fails login. */
39
19
  export declare function syncGatewayFromBackends(options?: GatewaySyncOptions): Promise<GatewaySyncResult>;
@@ -1,90 +1,46 @@
1
- import { existsSync, readFileSync } from 'node:fs';
2
1
  import * as path from 'node:path';
3
2
  import { createLogger } from '../../core/log.js';
3
+ import { atomicWriteSync } from '../../core/atomic-write.js';
4
4
  import { discoverEndpoints, writeMergedGatewayYaml } from '../../core/gateway-generator.js';
5
- import { generateProfiles, recommendedChoice, writeProfilesJson } from '../../core/profile-generator.js';
5
+ import { generateModels, mergeModelsJson, readExistingModels, recommendedChoice } from '../../core/models-generator.js';
6
6
  import { CONFIG_DIR } from '../../core/paths.js';
7
+ import { modelsRepo, modelsWriteLock } from '../../store/models-repo.js';
7
8
  const log = createLogger('gateway-sync');
8
- /**
9
- * Regenerate gateway.yaml and profiles.json from the backends that are reachable right now.
10
- *
11
- * Logging in is only half of becoming usable: the models a provider exposes are discovered by
12
- * scanning local backend state (PI's auth and model catalog, Claude config), and that scan previously ran
13
- * only inside `cortex init` and `cortex setup-gateway`. A user who logged in from the workbench
14
- * therefore had working credentials but no profile pointing at the newly reachable models, with no
15
- * in-product way to fix it. Running this after a successful login closes that loop.
16
- *
17
- * Both writes are merge-aware on purpose: `writeMergedGatewayYaml` keeps hand-maintained modes, and
18
- * profiles are written with `overwrite: false` so an operator's edited `plan` / `execute` survives —
19
- * a login must never silently re-point which model the agents run on. Only missing profiles are
20
- * filled in.
21
- *
22
- * Never throws. It runs on the tail of a login flow and inside a UI mutation; a discovery hiccup
23
- * must not fail the login that just succeeded, so problems come back as `configured: false`.
24
- */
9
+ function syncModels(endpoints, configDir) {
10
+ const saved = readExistingModels(configDir);
11
+ const groups = new Set((saved?.favorites ?? []).map(ref => JSON.stringify([ref.backend, ref.provider])));
12
+ const generated = generateModels(endpoints);
13
+ generated.favorites = [];
14
+ for (const endpoint of endpoints) {
15
+ if (!recommendedChoice([endpoint]))
16
+ continue;
17
+ const ref = generateModels([endpoint]).favorites[0];
18
+ const group = JSON.stringify([ref.backend, ref.provider]);
19
+ if (groups.has(group))
20
+ continue;
21
+ generated.favorites.push(ref);
22
+ groups.add(group);
23
+ }
24
+ const merged = mergeModelsJson(generated, configDir);
25
+ atomicWriteSync(path.join(configDir, 'models.json'), JSON.stringify(merged, null, 2) + '\n');
26
+ modelsRepo.invalidate();
27
+ return { defaultSet: !saved?.default, favorites: merged.favorites };
28
+ }
29
+ /** Add newly connected backend/provider groups without changing an existing default. Never fails login. */
25
30
  export async function syncGatewayFromBackends(options = {}) {
26
- const discover = options.discover ?? discoverEndpoints;
27
- const configDir = options.configDir ?? CONFIG_DIR;
28
31
  try {
29
- const endpoints = await discover(options.backends);
30
- if (endpoints.length === 0) {
31
- log.info('No backend endpoints discovered — leaving gateway and profiles untouched');
32
- return { configured: false, endpoints: 0, profiles: [], reason: 'no-endpoints' };
32
+ const endpoints = await (options.discover ?? discoverEndpoints)(options.backends);
33
+ if (!endpoints.some(endpoint => endpoint.models.length > 0)) {
34
+ return { configured: false, endpoints: 0, defaultSet: false, favorites: [], reason: 'no-endpoints' };
33
35
  }
34
36
  writeMergedGatewayYaml(endpoints, options.gatewayConfigDir);
35
- writeProfilesJson(endpoints, {
36
- outputDir: configDir, overwrite: false, extraProfiles: missingBackendChoices(endpoints, configDir),
37
- });
38
- const profiles = readProfileNames(configDir);
39
- log.info(`Synced ${endpoints.length} endpoint(s) → profiles: ${profiles.join(', ')}`);
40
- return { configured: true, endpoints: endpoints.length, profiles };
37
+ const result = await modelsWriteLock.run(() => syncModels(endpoints, options.configDir ?? CONFIG_DIR));
38
+ log.info(`Synced ${endpoints.length} endpoint(s) → ${result.favorites.length} favorite model(s)`);
39
+ return { configured: true, endpoints: endpoints.length, ...result };
41
40
  }
42
41
  catch (error) {
43
42
  const reason = error instanceof Error ? error.message : String(error);
44
43
  log.warn(`Gateway sync skipped: ${reason}`);
45
- return { configured: false, endpoints: 0, profiles: [], reason };
46
- }
47
- }
48
- /** Read back the profile names actually on disk, so the caller reports facts rather than intent. */
49
- function readProfileNames(configDir) {
50
- const file = path.join(configDir, 'profiles.json');
51
- if (!existsSync(file))
52
- return [];
53
- try {
54
- const parsed = JSON.parse(readFileSync(file, 'utf-8'));
55
- return Object.keys(parsed.profiles ?? {});
44
+ return { configured: false, endpoints: 0, defaultSet: false, favorites: [], reason };
56
45
  }
57
- catch {
58
- return [];
59
- }
60
- }
61
- function missingBackendChoices(endpoints, configDir) {
62
- const file = path.join(configDir, 'profiles.json');
63
- if (!existsSync(file))
64
- return [];
65
- const saved = JSON.parse(readFileSync(file, 'utf8'));
66
- const backends = new Set(Object.values(saved.profiles ?? {}).map(p => p.backend));
67
- const extras = [];
68
- const names = new Set(Object.keys(saved.profiles ?? {}));
69
- for (const endpoint of endpoints) {
70
- const choice = recommendedChoice([endpoint]);
71
- if (!choice)
72
- continue;
73
- const backend = generateProfiles([endpoint]).profiles.plan.backend;
74
- if (backends.has(backend))
75
- continue;
76
- const name = availableProfileName(choice.model, backend, names);
77
- extras.push({ ...choice, name });
78
- names.add(name);
79
- backends.add(backend);
80
- }
81
- return extras;
82
- }
83
- function availableProfileName(model, backend, names) {
84
- const base = model.replace(/[^a-zA-Z0-9_-]/g, '-') || backend;
85
- let name = base;
86
- let suffix = 1;
87
- while (name === 'plan' || name === 'execute' || names.has(name))
88
- name = `${backend}-${base}-${suffix++}`;
89
- return name;
90
46
  }
@@ -1,10 +1,9 @@
1
- import type { McpComposition } from '../../agent-adapter/types.js';
2
- import type { ResolvedProfileConfig } from '../agents/profile-manager.js';
1
+ import type { Backend, McpComposition } from '../../agent-adapter/types.js';
3
2
  export type IdentityJsonValue = null | boolean | number | string | IdentityJsonValue[] | {
4
3
  [key: string]: IdentityJsonValue;
5
4
  };
6
5
  export interface ModelExecutionIdentityInput {
7
- backend: ResolvedProfileConfig['backend'];
6
+ backend: Backend;
8
7
  requestedModel: string;
9
8
  modelAliasPolicy: IdentityJsonValue;
10
9
  providerProtocol: string | null;
@@ -12,11 +11,10 @@ export interface ModelExecutionIdentityInput {
12
11
  claudeCliVersion: string | null;
13
12
  /** Backend-neutral CLI identity; `claudeCliVersion` keeps its Claude-only meaning so every
14
13
  * hash frozen before the neutral pair existed stays reproducible from its own inputs. */
15
- cliName: ResolvedProfileConfig['backend'] | null;
14
+ cliName: Backend | null;
16
15
  cliVersion: string | null;
17
16
  reasoningEffort: string | null;
18
17
  maxOutputTokens?: number | null;
19
- fallbackEmpty: true;
20
18
  }
21
19
  export interface PluginDirIdentityInput {
22
20
  path: string;
@@ -46,7 +46,6 @@ export function computeModelExecutionIdentityHash(input) {
46
46
  cli_version: input.cliVersion,
47
47
  reasoning_effort: input.reasoningEffort,
48
48
  max_output_tokens: input.maxOutputTokens ?? null,
49
- fallback_empty: input.fallbackEmpty,
50
49
  });
51
50
  }
52
51
  function compareText(left, right) {
@@ -1,7 +1,7 @@
1
1
  import type { Backend, EngineSpec } from '../../agent-adapter/types.js';
2
2
  import type { RunRequest } from '../runs/request.js';
3
- import type { ResolvedProfileConfig } from '../agents/profile-manager.js';
4
- declare const RECORD_SCHEMA = "cortex-production-attempt-identity/4";
3
+ import type { EngineSelection } from '../agents/engine-selection.js';
4
+ declare const RECORD_SCHEMA = "cortex-production-attempt-identity/5";
5
5
  export type ProductionAttemptIdentityRecord = Readonly<{
6
6
  schema_version: typeof RECORD_SCHEMA;
7
7
  trial_id: string;
@@ -11,7 +11,8 @@ export type ProductionAttemptIdentityRecord = Readonly<{
11
11
  spawn_parent_attempt_id: string | null;
12
12
  execution_id: string;
13
13
  session_id: string;
14
- profile_name: string;
14
+ thinking: string | null;
15
+ mode: string;
15
16
  backend: Backend;
16
17
  provider: string | null;
17
18
  requested_model: string;
@@ -21,7 +22,7 @@ export type ProductionAttemptIdentityRecord = Readonly<{
21
22
  frozen_at: string;
22
23
  }>;
23
24
  interface ConfigurationRevision {
24
- profiles: number;
25
+ models: number;
25
26
  environments: number;
26
27
  }
27
28
  export interface ProductionAttemptIdentityInit {
@@ -34,7 +35,7 @@ interface FreezeAttemptInput {
34
35
  request: RunRequest;
35
36
  /** The execution record this attempt belongs to — the attested attempt id is derived from it. */
36
37
  executionId: string | null;
37
- resolvedProfile: ResolvedProfileConfig | undefined;
38
+ selection: EngineSelection | undefined;
38
39
  }
39
40
  type AttemptScope = Pick<ProductionAttemptIdentityRecord, 'trial_id' | 'root_run_id' | 'session_id'>;
40
41
  export interface ProductionAttemptIdentityScope {
@@ -5,12 +5,12 @@ import { parseProductionBenchmarkEvidenceContext } from './production-benchmark-
5
5
  import { computeModelExecutionIdentityHash, computeRoleToolSurfaceHash, } from './identity.js';
6
6
  import { roleSurfaceFromSpec } from './role-surface.js';
7
7
  import { initializeProductionAttemptJournals, resetProductionAttemptJournals, } from './production-attempt-journal.js';
8
- const RECORD_SCHEMA = 'cortex-production-attempt-identity/4';
8
+ const RECORD_SCHEMA = 'cortex-production-attempt-identity/5';
9
9
  const SHA256_PATTERN = /^[a-f0-9]{64}$/;
10
10
  const DEFAULT_STORE_PATH = path.join(STORE_DIR, 'benchmark-attempt-identities.jsonl');
11
11
  const RECORD_KEYS = [
12
12
  'schema_version', 'trial_id', 'root_run_id', 'attempt_id', 'root_attempt_id',
13
- 'spawn_parent_attempt_id', 'execution_id', 'session_id', 'profile_name',
13
+ 'spawn_parent_attempt_id', 'execution_id', 'session_id', 'thinking', 'mode',
14
14
  'backend', 'provider', 'requested_model', 'model_execution_identity_hash',
15
15
  'role_tool_surface_hash', 'bundle_manifest_hash', 'frozen_at',
16
16
  ];
@@ -37,10 +37,10 @@ function isNullableString(value) {
37
37
  function storedRecordValid(value) {
38
38
  const strings = [
39
39
  'trial_id', 'root_run_id', 'attempt_id', 'root_attempt_id', 'execution_id',
40
- 'session_id', 'profile_name', 'requested_model', 'model_execution_identity_hash',
40
+ 'session_id', 'mode', 'requested_model', 'model_execution_identity_hash',
41
41
  'role_tool_surface_hash', 'bundle_manifest_hash', 'frozen_at',
42
42
  ];
43
- const nullable = ['spawn_parent_attempt_id', 'provider'];
43
+ const nullable = ['spawn_parent_attempt_id', 'provider', 'thinking'];
44
44
  const hashes = [
45
45
  value.model_execution_identity_hash, value.role_tool_surface_hash, value.bundle_manifest_hash,
46
46
  ];
@@ -240,34 +240,31 @@ function configuredRouteHost(spec, backend) {
240
240
  throw new Error(`Production benchmark resolved route is invalid: ${route}`);
241
241
  }
242
242
  }
243
- function assertSpawnMatchesProfile(spec, profile) {
244
- if (spec.model.id !== profile.model) {
243
+ function assertSpawnMatchesSelection(spec, selection) {
244
+ if (spec.model.id !== selection.model) {
245
245
  throw new Error('Production benchmark resolved model drifted before adapter spawn');
246
246
  }
247
- if ((spec.model.thinking ?? null) !== profile.thinking) {
247
+ if ((spec.model.thinking ?? null) !== selection.thinking) {
248
248
  throw new Error('Production benchmark resolved thinking drifted before adapter spawn');
249
249
  }
250
- if (profile.backend === 'pi' && (spec.model.provider ?? null) !== profile.provider) {
250
+ if (selection.backend === 'pi' && (spec.model.provider ?? null) !== selection.provider) {
251
251
  throw new Error('Production benchmark resolved provider drifted before adapter spawn');
252
252
  }
253
253
  }
254
- function assertProfile(input, context) {
255
- const profile = input.resolvedProfile;
256
- if (!profile)
257
- throw new Error('Production benchmark attempt is missing resolved profile');
258
- if (profile.fallback.length > 0) {
259
- throw new Error('Production benchmark identity refuses profiles with fallbacks');
260
- }
261
- if (profile.backend !== context.model_execution.cli_name
262
- || profile.backend !== input.adapterBackend) {
254
+ function assertSelection(input, context) {
255
+ const selection = input.selection;
256
+ if (!selection)
257
+ throw new Error('Production benchmark attempt is missing selection');
258
+ if (selection.backend !== context.model_execution.cli_name
259
+ || selection.backend !== input.adapterBackend) {
263
260
  throw new Error('Production benchmark backend differs from injected CLI identity');
264
261
  }
265
- assertSpawnMatchesProfile(input.spec, profile);
266
- return profile;
262
+ assertSpawnMatchesSelection(input.spec, selection);
263
+ return selection;
267
264
  }
268
265
  function maxOutputTokens(spec, context) {
269
266
  const injected = context.model_execution.max_output_tokens;
270
- const resolved = spec.model.maxOutputTokens ?? null;
267
+ const resolved = spec.model.benchmarkMaxOutputTokens ?? null;
271
268
  if (resolved !== injected) {
272
269
  throw new Error('Production benchmark max output token identity drifted');
273
270
  }
@@ -289,33 +286,33 @@ function attemptLinkage(state, request, executionIdInput, context, existing) {
289
286
  execution_id: executionId, session_id: scope.session_id,
290
287
  };
291
288
  }
292
- function modelExecutionHash(context, spec, profile) {
289
+ function modelExecutionHash(context, spec, selection) {
293
290
  const cli = context.model_execution;
294
291
  return computeModelExecutionIdentityHash({
295
- backend: profile.backend,
296
- requestedModel: profile.model,
292
+ backend: selection.backend,
293
+ requestedModel: selection.model,
297
294
  modelAliasPolicy: cli.model_alias_policy,
298
- providerProtocol: profile.provider,
299
- configuredRouteBaseHost: configuredRouteHost(spec, profile.backend),
300
- claudeCliVersion: profile.backend === 'claude' ? cli.cli_version : null,
295
+ providerProtocol: selection.provider,
296
+ configuredRouteBaseHost: configuredRouteHost(spec, selection.backend),
297
+ claudeCliVersion: selection.backend === 'claude' ? cli.cli_version : null,
301
298
  cliName: cli.cli_name,
302
299
  cliVersion: cli.cli_version,
303
- reasoningEffort: profile.thinking,
300
+ reasoningEffort: selection.thinking,
304
301
  maxOutputTokens: maxOutputTokens(spec, context),
305
- fallbackEmpty: true,
306
302
  });
307
303
  }
308
304
  function attemptModel(context, input) {
309
- const profile = assertProfile(input, context);
305
+ const selection = assertSelection(input, context);
310
306
  const directive = typeof input.request.benchmark?.identityDirective === 'string'
311
307
  ? input.request.benchmark.identityDirective : '';
312
308
  const roleSurface = roleSurfaceFromSpec(input.spec, directive);
313
309
  return {
314
- profile_name: profile.name,
315
- backend: profile.backend,
316
- provider: profile.provider,
317
- requested_model: profile.model,
318
- model_execution_identity_hash: modelExecutionHash(context, input.spec, profile),
310
+ thinking: selection.thinking,
311
+ mode: selection.mode,
312
+ backend: selection.backend,
313
+ provider: selection.provider,
314
+ requested_model: selection.model,
315
+ model_execution_identity_hash: modelExecutionHash(context, input.spec, selection),
319
316
  role_tool_surface_hash: computeRoleToolSurfaceHash(roleSurface),
320
317
  };
321
318
  }
@@ -335,7 +332,7 @@ function assertRootBaseline(repo, record) {
335
332
  if (!root)
336
333
  return;
337
334
  const rootFields = [
338
- 'trial_id', 'root_run_id', 'bundle_manifest_hash', 'profile_name', 'backend', 'provider',
335
+ 'trial_id', 'root_run_id', 'bundle_manifest_hash', 'thinking', 'mode', 'backend', 'provider',
339
336
  'requested_model', 'model_execution_identity_hash',
340
337
  ];
341
338
  if (rootFields.some(field => root[field] !== record[field])) {
@@ -1,6 +1,7 @@
1
1
  import type { ProductionBenchmarkEvidenceContext } from './benchmark-types.js';
2
2
  /** Bind `context` to `sessionId`. A trial run (trial id + root run id) owns exactly one session. */
3
- export declare function bindSessionEvidenceContext(sessionId: string, context: ProductionBenchmarkEvidenceContext): void;
3
+ export declare function bindSessionEvidenceContext(sessionId: string, context: ProductionBenchmarkEvidenceContext, benchmarkMaxOutputTokens?: number): void;
4
4
  export declare function sessionEvidenceContext(sessionId: string): ProductionBenchmarkEvidenceContext | null;
5
+ export declare function sessionBenchmarkMaxOutputTokens(sessionId: string): number | undefined;
5
6
  export declare function sessionForRun(trialId: string, rootRunId: string): string | null;
6
7
  export declare function _resetSessionEvidence(): void;
@@ -4,17 +4,23 @@
4
4
  // of that session then opens its runs with the context, so each attempt is frozen and journaled.
5
5
  // In memory only: a trial's server lives exactly as long as its one session.
6
6
  const bound = new Map();
7
+ const outputCaps = new Map();
7
8
  /** Bind `context` to `sessionId`. A trial run (trial id + root run id) owns exactly one session. */
8
- export function bindSessionEvidenceContext(sessionId, context) {
9
+ export function bindSessionEvidenceContext(sessionId, context, benchmarkMaxOutputTokens) {
9
10
  const owner = sessionForRun(context.trial_id, context.root_run_id);
10
11
  if (owner && owner !== sessionId) {
11
12
  throw new Error(`trial run ${context.trial_id}/${context.root_run_id} already has a session`);
12
13
  }
13
14
  bound.set(sessionId, context);
15
+ if (benchmarkMaxOutputTokens !== undefined)
16
+ outputCaps.set(sessionId, benchmarkMaxOutputTokens);
14
17
  }
15
18
  export function sessionEvidenceContext(sessionId) {
16
19
  return bound.get(sessionId) ?? null;
17
20
  }
21
+ export function sessionBenchmarkMaxOutputTokens(sessionId) {
22
+ return outputCaps.get(sessionId);
23
+ }
18
24
  export function sessionForRun(trialId, rootRunId) {
19
25
  for (const [sessionId, context] of bound) {
20
26
  if (context.trial_id === trialId && context.root_run_id === rootRunId)
@@ -24,4 +30,5 @@ export function sessionForRun(trialId, rootRunId) {
24
30
  }
25
31
  export function _resetSessionEvidence() {
26
32
  bound.clear();
33
+ outputCaps.clear();
27
34
  }
@@ -0,0 +1,99 @@
1
+ import { type AgentBrowserRun } from '../../platform/browser/agent-browser.js';
2
+ /**
3
+ * Browser leases for `cortex-browser`, held per Cortex session rather than per turn.
4
+ *
5
+ * A lease ties one session to one device's shared Chrome (server-local, or a device's through the
6
+ * reverse channel) and to one agent-browser session pinned to its own tab there. It holds one
7
+ * reference on that Chrome, is renewed by every call, and is released, closing its tab, after
8
+ * {@link LEASE_IDLE_MS} without one. Page state survives between turns because nothing here is torn
9
+ * down per turn.
10
+ */
11
+ export declare const LEASE_IDLE_MS: number;
12
+ export type BrowserSessionState = 'starting' | 'ready' | 'error';
13
+ export interface BrowserSessionInfo {
14
+ sessionId: string;
15
+ device: string;
16
+ abSession: string;
17
+ state: BrowserSessionState;
18
+ error?: string;
19
+ url?: string;
20
+ title?: string;
21
+ takenOver: boolean;
22
+ lastUsedAt: number;
23
+ }
24
+ export interface BrowserLease {
25
+ device: string;
26
+ cdpEndpoint: string;
27
+ abSession: string;
28
+ }
29
+ export type BrowserLeaseErrorCode = 'bad-request' | 'unknown-device' | 'device-offline' | 'taken-over' | 'chrome-failed' | 'engine-missing' | 'no-lease';
30
+ /** A lease failure meant for a human: what went wrong, and what to do about it. */
31
+ export declare class BrowserLeaseError extends Error {
32
+ readonly code: BrowserLeaseErrorCode;
33
+ readonly hint?: string;
34
+ constructor(code: BrowserLeaseErrorCode, message: string, hint?: string);
35
+ }
36
+ /** Device states the broker distinguishes when asked for one. */
37
+ export type DeviceAvailability = 'online' | 'offline' | 'unknown';
38
+ export interface BrokerDeps {
39
+ /** Take one reference on the device's Chrome, starting it if needed. */
40
+ acquire(device: string): Promise<string>;
41
+ /** Drop one reference taken by {@link acquire}. */
42
+ release(device: string): void;
43
+ /**
44
+ * The device's live endpoint for a lease that already holds a reference, relaunching Chrome if
45
+ * it died. Must leave the reference count as it found it.
46
+ */
47
+ refresh(device: string, cdpEndpoint: string): Promise<string>;
48
+ availability(device: string): {
49
+ state: DeviceAvailability;
50
+ online: string[];
51
+ };
52
+ resolveBin(): string;
53
+ baseEnv(): Record<string, string>;
54
+ run(bin: string, args: string[], env: Record<string, string>): Promise<AgentBrowserRun>;
55
+ now(): number;
56
+ idleMs: number;
57
+ }
58
+ export interface BrowserBroker {
59
+ leaseBrowser(input: {
60
+ sessionId: string;
61
+ device?: string | null;
62
+ }): Promise<BrowserLease>;
63
+ listBrowserSessions(): BrowserSessionInfo[];
64
+ runAgentBrowser(sessionId: string, args: string[]): Promise<AgentBrowserRun>;
65
+ streamPort(sessionId: string): Promise<number | null>;
66
+ setTakeover(sessionId: string, on: boolean): void;
67
+ isTakenOver(sessionId: string): boolean;
68
+ insertText(sessionId: string, text: string): Promise<void>;
69
+ /** A CLI call finished: refresh the URL and title shown for the session. */
70
+ noteBrowserCommand(sessionId: string): void;
71
+ /** The binary and environment a CLI call must use to reach this broker's daemons. */
72
+ agentBrowserRuntime(): {
73
+ bin: string;
74
+ env: Record<string, string>;
75
+ };
76
+ onBrowserSessionsChanged(listener: () => void): () => void;
77
+ /** Forget every lease (daemon shutdown). Chrome itself is stopped by its own owner. */
78
+ shutdown(): void;
79
+ }
80
+ /** Turn a device launch failure (often a bare marker from the launch script) into a sentence. */
81
+ export declare function describeDeviceFailure(device: string, raw: string): {
82
+ message: string;
83
+ hint?: string;
84
+ };
85
+ export declare function createBrowserBroker(deps: BrokerDeps): BrowserBroker;
86
+ export declare function defaultBrokerDeps(): BrokerDeps;
87
+ /** Test seam: swap the process-wide broker (pass null to rebuild it from the real deps). */
88
+ export declare function _setBrowserBroker(next: BrowserBroker | null): void;
89
+ export declare const leaseBrowser: BrowserBroker['leaseBrowser'];
90
+ export declare const listBrowserSessions: BrowserBroker['listBrowserSessions'];
91
+ export declare const runAgentBrowser: BrowserBroker['runAgentBrowser'];
92
+ export declare const streamPort: BrowserBroker['streamPort'];
93
+ export declare const setTakeover: BrowserBroker['setTakeover'];
94
+ export declare const isTakenOver: BrowserBroker['isTakenOver'];
95
+ export declare const insertText: BrowserBroker['insertText'];
96
+ export declare const noteBrowserCommand: BrowserBroker['noteBrowserCommand'];
97
+ export declare const agentBrowserRuntime: BrowserBroker['agentBrowserRuntime'];
98
+ export declare const onBrowserSessionsChanged: BrowserBroker['onBrowserSessionsChanged'];
99
+ export declare function shutdownBrowserBroker(): void;