@skillcdn/console 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (415) hide show
  1. package/README.md +7 -7
  2. package/dist/agent-page.d.ts.map +1 -1
  3. package/dist/agent-page.js +58 -35
  4. package/dist/agent-page.js.map +1 -1
  5. package/dist/agent-usage.d.ts +51 -0
  6. package/dist/agent-usage.d.ts.map +1 -0
  7. package/dist/agent-usage.js +77 -0
  8. package/dist/agent-usage.js.map +1 -0
  9. package/dist/api.d.ts +4 -2
  10. package/dist/api.d.ts.map +1 -1
  11. package/dist/api.js +4 -2
  12. package/dist/api.js.map +1 -1
  13. package/dist/cli/cli.d.ts +9 -2
  14. package/dist/cli/cli.d.ts.map +1 -1
  15. package/dist/cli/cli.js +491 -125
  16. package/dist/cli/cli.js.map +1 -1
  17. package/dist/cli/format.d.ts +46 -4
  18. package/dist/cli/format.d.ts.map +1 -1
  19. package/dist/cli/format.js +163 -45
  20. package/dist/cli/format.js.map +1 -1
  21. package/dist/cli/help.d.ts.map +1 -1
  22. package/dist/cli/help.js +62 -13
  23. package/dist/cli/help.js.map +1 -1
  24. package/dist/cli/machine-check.d.ts +24 -5
  25. package/dist/cli/machine-check.d.ts.map +1 -1
  26. package/dist/cli/machine-check.js +128 -16
  27. package/dist/cli/machine-check.js.map +1 -1
  28. package/dist/cli/pack.d.ts +11 -8
  29. package/dist/cli/pack.d.ts.map +1 -1
  30. package/dist/cli/pack.js +63 -28
  31. package/dist/cli/pack.js.map +1 -1
  32. package/dist/cli/runner-host.d.ts +2 -0
  33. package/dist/cli/runner-host.d.ts.map +1 -1
  34. package/dist/cli/runner-host.js +1 -0
  35. package/dist/cli/runner-host.js.map +1 -1
  36. package/dist/cli/secret-notes.d.ts.map +1 -1
  37. package/dist/cli/secret-notes.js +9 -1
  38. package/dist/cli/secret-notes.js.map +1 -1
  39. package/dist/cli/terminal.d.ts +10 -2
  40. package/dist/cli/terminal.d.ts.map +1 -1
  41. package/dist/cli/terminal.js +16 -4
  42. package/dist/cli/terminal.js.map +1 -1
  43. package/dist/client.d.ts +30 -7
  44. package/dist/client.d.ts.map +1 -1
  45. package/dist/client.js +13 -1
  46. package/dist/client.js.map +1 -1
  47. package/dist/components/agent-page.d.ts +76 -18
  48. package/dist/components/agent-page.d.ts.map +1 -1
  49. package/dist/components/agent-page.js +183 -53
  50. package/dist/components/agent-page.js.map +1 -1
  51. package/dist/components/agents.d.ts +2 -0
  52. package/dist/components/agents.d.ts.map +1 -1
  53. package/dist/components/agents.js +6 -5
  54. package/dist/components/agents.js.map +1 -1
  55. package/dist/components/calendar.d.ts +24 -4
  56. package/dist/components/calendar.d.ts.map +1 -1
  57. package/dist/components/calendar.js +79 -36
  58. package/dist/components/calendar.js.map +1 -1
  59. package/dist/components/categories.js +2 -2
  60. package/dist/components/categories.js.map +1 -1
  61. package/dist/components/comments.js +2 -2
  62. package/dist/components/comments.js.map +1 -1
  63. package/dist/components/decision-list.d.ts.map +1 -1
  64. package/dist/components/decision-list.js +5 -5
  65. package/dist/components/decision-list.js.map +1 -1
  66. package/dist/components/documents.d.ts.map +1 -1
  67. package/dist/components/documents.js +4 -4
  68. package/dist/components/documents.js.map +1 -1
  69. package/dist/components/event-feed.d.ts +2 -3
  70. package/dist/components/event-feed.d.ts.map +1 -1
  71. package/dist/components/event-feed.js +4 -184
  72. package/dist/components/event-feed.js.map +1 -1
  73. package/dist/components/goals.d.ts.map +1 -1
  74. package/dist/components/goals.js +3 -3
  75. package/dist/components/goals.js.map +1 -1
  76. package/dist/components/home.js +9 -9
  77. package/dist/components/home.js.map +1 -1
  78. package/dist/components/icon.d.ts.map +1 -1
  79. package/dist/components/icon.js +11 -2
  80. package/dist/components/icon.js.map +1 -1
  81. package/dist/components/notifications.d.ts +65 -0
  82. package/dist/components/notifications.d.ts.map +1 -0
  83. package/dist/components/notifications.js +162 -0
  84. package/dist/components/notifications.js.map +1 -0
  85. package/dist/components/pack-connect.js +1 -1
  86. package/dist/components/pack-connect.js.map +1 -1
  87. package/dist/components/pack-token.js +1 -1
  88. package/dist/components/pack-token.js.map +1 -1
  89. package/dist/components/people.js +2 -2
  90. package/dist/components/people.js.map +1 -1
  91. package/dist/components/pictures.js +1 -1
  92. package/dist/components/pictures.js.map +1 -1
  93. package/dist/components/plugin-settings.d.ts +22 -1
  94. package/dist/components/plugin-settings.d.ts.map +1 -1
  95. package/dist/components/plugin-settings.js +63 -11
  96. package/dist/components/plugin-settings.js.map +1 -1
  97. package/dist/components/projects.js +1 -1
  98. package/dist/components/projects.js.map +1 -1
  99. package/dist/components/roadmap.js +2 -2
  100. package/dist/components/roadmap.js.map +1 -1
  101. package/dist/components/rules.js +2 -2
  102. package/dist/components/rules.js.map +1 -1
  103. package/dist/components/runs.d.ts.map +1 -1
  104. package/dist/components/runs.js +1 -1
  105. package/dist/components/runs.js.map +1 -1
  106. package/dist/components/sessions.js +1 -1
  107. package/dist/components/sessions.js.map +1 -1
  108. package/dist/components/shell.d.ts +2 -0
  109. package/dist/components/shell.d.ts.map +1 -1
  110. package/dist/components/shell.js +1 -1
  111. package/dist/components/shell.js.map +1 -1
  112. package/dist/components/sign-in.js +2 -2
  113. package/dist/components/sign-in.js.map +1 -1
  114. package/dist/components/skills.d.ts.map +1 -1
  115. package/dist/components/skills.js +1 -1
  116. package/dist/components/skills.js.map +1 -1
  117. package/dist/components/task-view.d.ts +6 -0
  118. package/dist/components/task-view.d.ts.map +1 -1
  119. package/dist/components/task-view.js +3 -2
  120. package/dist/components/task-view.js.map +1 -1
  121. package/dist/components/tokens.js +1 -1
  122. package/dist/components/tokens.js.map +1 -1
  123. package/dist/components/ui.d.ts +21 -2
  124. package/dist/components/ui.d.ts.map +1 -1
  125. package/dist/components/ui.js +24 -3
  126. package/dist/components/ui.js.map +1 -1
  127. package/dist/components/work.js +1 -1
  128. package/dist/components/work.js.map +1 -1
  129. package/dist/console.css +506 -289
  130. package/dist/console.d.ts.map +1 -1
  131. package/dist/console.js +193 -16
  132. package/dist/console.js.map +1 -1
  133. package/dist/data.d.ts +17 -1
  134. package/dist/data.d.ts.map +1 -1
  135. package/dist/data.js +31 -0
  136. package/dist/data.js.map +1 -1
  137. package/dist/desk-page.js +5 -5
  138. package/dist/desk-page.js.map +1 -1
  139. package/dist/feed-words.d.ts +5 -0
  140. package/dist/feed-words.d.ts.map +1 -0
  141. package/dist/feed-words.js +193 -0
  142. package/dist/feed-words.js.map +1 -0
  143. package/dist/i18n/en.d.ts +93 -1
  144. package/dist/i18n/en.d.ts.map +1 -1
  145. package/dist/i18n/en.js +103 -15
  146. package/dist/i18n/en.js.map +1 -1
  147. package/dist/i18n/ko.d.ts.map +1 -1
  148. package/dist/i18n/ko.js +105 -22
  149. package/dist/i18n/ko.js.map +1 -1
  150. package/dist/icons/glyphs.d.ts +370 -104
  151. package/dist/icons/glyphs.d.ts.map +1 -1
  152. package/dist/icons/glyphs.js +72 -66
  153. package/dist/icons/glyphs.js.map +1 -1
  154. package/dist/icons/index.d.ts.map +1 -1
  155. package/dist/icons/index.js +9 -1
  156. package/dist/icons/index.js.map +1 -1
  157. package/dist/index.d.ts +3 -2
  158. package/dist/index.d.ts.map +1 -1
  159. package/dist/index.js +3 -2
  160. package/dist/index.js.map +1 -1
  161. package/dist/limits.d.ts +7 -0
  162. package/dist/limits.d.ts.map +1 -1
  163. package/dist/limits.js +7 -0
  164. package/dist/limits.js.map +1 -1
  165. package/dist/notifications.d.ts +124 -0
  166. package/dist/notifications.d.ts.map +1 -0
  167. package/dist/notifications.js +147 -0
  168. package/dist/notifications.js.map +1 -0
  169. package/dist/onboarding.d.ts.map +1 -1
  170. package/dist/onboarding.js +7 -12
  171. package/dist/onboarding.js.map +1 -1
  172. package/dist/plugin/capabilities.d.ts +1 -1
  173. package/dist/plugin/capabilities.d.ts.map +1 -1
  174. package/dist/plugin/capabilities.js +10 -0
  175. package/dist/plugin/capabilities.js.map +1 -1
  176. package/dist/plugin/context.d.ts +85 -1
  177. package/dist/plugin/context.d.ts.map +1 -1
  178. package/dist/plugin/limits.d.ts +7 -0
  179. package/dist/plugin/limits.d.ts.map +1 -1
  180. package/dist/plugin/limits.js +7 -0
  181. package/dist/plugin/limits.js.map +1 -1
  182. package/dist/plugin/manifest.d.ts +8 -0
  183. package/dist/plugin/manifest.d.ts.map +1 -1
  184. package/dist/plugin/manifest.js +13 -0
  185. package/dist/plugin/manifest.js.map +1 -1
  186. package/dist/plugin/rest-schemas.d.ts +22 -0
  187. package/dist/plugin/rest-schemas.d.ts.map +1 -1
  188. package/dist/plugin/rest-schemas.js +19 -3
  189. package/dist/plugin/rest-schemas.js.map +1 -1
  190. package/dist/plugin/testing.d.ts +2 -0
  191. package/dist/plugin/testing.d.ts.map +1 -1
  192. package/dist/plugin/testing.js +2 -0
  193. package/dist/plugin/testing.js.map +1 -1
  194. package/dist/plugin.d.ts +1 -1
  195. package/dist/plugin.d.ts.map +1 -1
  196. package/dist/plugin.js +1 -1
  197. package/dist/plugin.js.map +1 -1
  198. package/dist/router.d.ts +6 -0
  199. package/dist/router.d.ts.map +1 -1
  200. package/dist/router.js +5 -0
  201. package/dist/router.js.map +1 -1
  202. package/dist/routes.d.ts +2 -0
  203. package/dist/routes.d.ts.map +1 -1
  204. package/dist/routes.js +2 -0
  205. package/dist/routes.js.map +1 -1
  206. package/dist/rules.js +1 -1
  207. package/dist/rules.js.map +1 -1
  208. package/dist/runner/acp.d.ts.map +1 -1
  209. package/dist/runner/acp.js +12 -97
  210. package/dist/runner/acp.js.map +1 -1
  211. package/dist/runner/browser.d.ts +50 -0
  212. package/dist/runner/browser.d.ts.map +1 -0
  213. package/dist/runner/browser.js +104 -0
  214. package/dist/runner/browser.js.map +1 -0
  215. package/dist/runner/claude.d.ts +1 -2
  216. package/dist/runner/claude.d.ts.map +1 -1
  217. package/dist/runner/claude.js +352 -13
  218. package/dist/runner/claude.js.map +1 -1
  219. package/dist/runner/codex.d.ts +9 -10
  220. package/dist/runner/codex.d.ts.map +1 -1
  221. package/dist/runner/codex.js +809 -346
  222. package/dist/runner/codex.js.map +1 -1
  223. package/dist/runner/config.d.ts +14 -3
  224. package/dist/runner/config.d.ts.map +1 -1
  225. package/dist/runner/config.js +27 -7
  226. package/dist/runner/config.js.map +1 -1
  227. package/dist/runner/desk.d.ts +3 -1
  228. package/dist/runner/desk.d.ts.map +1 -1
  229. package/dist/runner/desk.js +17 -5
  230. package/dist/runner/desk.js.map +1 -1
  231. package/dist/runner/message.d.ts +53 -3
  232. package/dist/runner/message.d.ts.map +1 -1
  233. package/dist/runner/message.js +201 -20
  234. package/dist/runner/message.js.map +1 -1
  235. package/dist/runner/registry.d.ts +6 -0
  236. package/dist/runner/registry.d.ts.map +1 -1
  237. package/dist/runner/registry.js.map +1 -1
  238. package/dist/runner/rpc.d.ts +31 -0
  239. package/dist/runner/rpc.d.ts.map +1 -0
  240. package/dist/runner/rpc.js +102 -0
  241. package/dist/runner/rpc.js.map +1 -0
  242. package/dist/runner/runner.d.ts +41 -1
  243. package/dist/runner/runner.d.ts.map +1 -1
  244. package/dist/runner/runner.js +695 -52
  245. package/dist/runner/runner.js.map +1 -1
  246. package/dist/runner/slack.d.ts +17 -8
  247. package/dist/runner/slack.d.ts.map +1 -1
  248. package/dist/runner/slack.js +1250 -78
  249. package/dist/runner/slack.js.map +1 -1
  250. package/dist/runner/types.d.ts +160 -8
  251. package/dist/runner/types.d.ts.map +1 -1
  252. package/dist/runner/types.js.map +1 -1
  253. package/dist/runner/usage.d.ts +105 -0
  254. package/dist/runner/usage.d.ts.map +1 -0
  255. package/dist/runner/usage.js +218 -0
  256. package/dist/runner/usage.js.map +1 -0
  257. package/dist/runner.d.ts +4 -4
  258. package/dist/runner.d.ts.map +1 -1
  259. package/dist/runner.js +3 -3
  260. package/dist/runner.js.map +1 -1
  261. package/dist/schemas.d.ts +673 -0
  262. package/dist/schemas.d.ts.map +1 -1
  263. package/dist/schemas.js +205 -1
  264. package/dist/schemas.js.map +1 -1
  265. package/dist/services.js +3 -3
  266. package/dist/services.js.map +1 -1
  267. package/dist/setup-guide.d.ts +4 -3
  268. package/dist/setup-guide.d.ts.map +1 -1
  269. package/dist/setup-guide.js +11 -13
  270. package/dist/setup-guide.js.map +1 -1
  271. package/dist/text.d.ts +7 -0
  272. package/dist/text.d.ts.map +1 -1
  273. package/dist/text.js +18 -0
  274. package/dist/text.js.map +1 -1
  275. package/dist/vocabulary.d.ts +4 -2
  276. package/dist/vocabulary.d.ts.map +1 -1
  277. package/dist/vocabulary.js +4 -1
  278. package/dist/vocabulary.js.map +1 -1
  279. package/docs/specs/cli.md +26 -19
  280. package/docs/specs/plugins.md +16 -10
  281. package/docs/specs/rest.md +28 -10
  282. package/docs/specs/runner.md +132 -44
  283. package/package.json +4 -4
  284. package/skills/building-a-console/SKILL.md +2 -2
  285. package/skills/building-a-console/references/configuring.md +1 -1
  286. package/skills/building-a-plugin/SKILL.md +4 -4
  287. package/skills/planning-the-board/SKILL.md +1 -1
  288. package/skills/planning-the-board/references/setting-up.md +2 -2
  289. package/skills/running-an-agent/SKILL.md +15 -64
  290. package/skills/running-an-agent/references/preparing-the-machine.md +17 -0
  291. package/skills/running-an-agent/references/several-tasks.md +37 -0
  292. package/skills/running-an-agent/references/slack-app.md +70 -13
  293. package/skills/running-an-agent/references/the-account-and-the-invitation.md +5 -0
  294. package/skills/running-an-agent/references/what-was-not-seen-run-yet.md +3 -0
  295. package/skills/running-an-agent/references/when-the-agent-could-not-go-on.md +16 -0
  296. package/skills/running-an-agent/references/your-first-task.md +14 -0
  297. package/skills/working-the-board/SKILL.md +9 -12
  298. package/skills/working-the-board/references/a-pack-skills-questions.md +3 -0
  299. package/skills/working-the-board/references/a-plugins-commands.md +3 -0
  300. package/skills/working-the-board/references/a-review.md +3 -0
  301. package/skills/working-the-board/references/an-open-run.md +3 -0
  302. package/skills/working-the-board/references/requirements.md +7 -0
  303. package/skills/working-the-board/references/the-pack.md +2 -2
  304. package/skills/working-the-board/references/what-they-were-told.md +3 -0
  305. package/skills/working-the-board/references/work-given-in-chat.md +5 -0
  306. package/src/agent-page.tsx +76 -47
  307. package/src/agent-usage.ts +113 -0
  308. package/src/api.ts +62 -0
  309. package/src/cli/cli.ts +634 -162
  310. package/src/cli/format.ts +190 -47
  311. package/src/cli/help.ts +77 -12
  312. package/src/cli/machine-check.ts +182 -29
  313. package/src/cli/pack.ts +81 -40
  314. package/src/cli/runner-host.ts +3 -0
  315. package/src/cli/secret-notes.ts +9 -1
  316. package/src/cli/terminal.ts +20 -4
  317. package/src/client.ts +94 -6
  318. package/src/components/agent-page.tsx +280 -63
  319. package/src/components/agents.tsx +23 -3
  320. package/src/components/calendar.tsx +93 -37
  321. package/src/components/categories.tsx +2 -2
  322. package/src/components/comments.tsx +5 -5
  323. package/src/components/decision-list.tsx +13 -10
  324. package/src/components/documents.tsx +13 -8
  325. package/src/components/event-feed.tsx +4 -203
  326. package/src/components/goals.tsx +6 -4
  327. package/src/components/home.tsx +12 -12
  328. package/src/components/icon.tsx +16 -3
  329. package/src/components/notifications.tsx +419 -0
  330. package/src/components/pack-connect.tsx +1 -1
  331. package/src/components/pack-token.tsx +5 -5
  332. package/src/components/people.tsx +3 -3
  333. package/src/components/pictures.tsx +1 -1
  334. package/src/components/plugin-settings.tsx +128 -23
  335. package/src/components/projects.tsx +1 -1
  336. package/src/components/roadmap.tsx +2 -2
  337. package/src/components/rules.tsx +2 -2
  338. package/src/components/runs.tsx +6 -3
  339. package/src/components/sessions.tsx +2 -2
  340. package/src/components/shell.tsx +3 -0
  341. package/src/components/sign-in.tsx +3 -3
  342. package/src/components/skills.tsx +5 -3
  343. package/src/components/task-view.tsx +18 -7
  344. package/src/components/tokens.tsx +2 -2
  345. package/src/components/ui.tsx +70 -5
  346. package/src/components/work.tsx +2 -2
  347. package/src/console.tsx +269 -12
  348. package/src/data.ts +54 -0
  349. package/src/desk-page.tsx +5 -5
  350. package/src/feed-words.ts +214 -0
  351. package/src/i18n/en.ts +114 -15
  352. package/src/i18n/ko.ts +115 -22
  353. package/src/icons/glyphs.ts +74 -68
  354. package/src/icons/index.ts +9 -1
  355. package/src/index.ts +11 -0
  356. package/src/limits.ts +7 -0
  357. package/src/notifications.ts +205 -0
  358. package/src/onboarding.ts +10 -14
  359. package/src/plugin/capabilities.ts +13 -0
  360. package/src/plugin/context.ts +87 -0
  361. package/src/plugin/limits.ts +7 -0
  362. package/src/plugin/manifest.ts +14 -0
  363. package/src/plugin/rest-schemas.ts +27 -3
  364. package/src/plugin/testing.ts +4 -0
  365. package/src/plugin.ts +2 -0
  366. package/src/router.ts +7 -0
  367. package/src/routes.ts +2 -0
  368. package/src/rules.ts +1 -1
  369. package/src/runner/acp.ts +12 -118
  370. package/src/runner/browser.ts +128 -0
  371. package/src/runner/claude.ts +399 -12
  372. package/src/runner/codex.ts +904 -400
  373. package/src/runner/config.ts +30 -7
  374. package/src/runner/desk.ts +22 -6
  375. package/src/runner/message.ts +251 -21
  376. package/src/runner/registry.ts +6 -0
  377. package/src/runner/rpc.ts +140 -0
  378. package/src/runner/runner.ts +863 -53
  379. package/src/runner/slack.ts +1535 -85
  380. package/src/runner/types.ts +150 -5
  381. package/src/runner/usage.ts +299 -0
  382. package/src/runner.ts +16 -1
  383. package/src/schemas.ts +249 -0
  384. package/src/services.ts +3 -3
  385. package/src/setup-guide.ts +12 -14
  386. package/src/styles/README.md +11 -7
  387. package/src/styles/console.css +2 -0
  388. package/src/styles/drawn-by-pages.json +7 -82
  389. package/src/styles/pages/agents.css +46 -35
  390. package/src/styles/pages/calendar.css +0 -1
  391. package/src/styles/pages/connect.css +0 -14
  392. package/src/styles/pages/decisions.css +2 -43
  393. package/src/styles/pages/documents.css +0 -29
  394. package/src/styles/pages/home.css +4 -16
  395. package/src/styles/pages/people.css +2 -17
  396. package/src/styles/pages/plugins.css +9 -12
  397. package/src/styles/pages/roadmap.css +0 -16
  398. package/src/styles/pages/settings.css +0 -28
  399. package/src/styles/pages/sign-in.css +2 -17
  400. package/src/styles/pages/thread.css +4 -50
  401. package/src/styles/pages/work.css +0 -5
  402. package/src/styles/parts/button.css +31 -0
  403. package/src/styles/parts/count.css +10 -0
  404. package/src/styles/parts/divider.css +17 -0
  405. package/src/styles/parts/frame.css +12 -0
  406. package/src/styles/parts/icon.css +39 -0
  407. package/src/styles/parts/menu.css +184 -0
  408. package/src/styles/parts/panel.css +7 -0
  409. package/src/styles/parts/progress.css +63 -0
  410. package/src/styles/parts/settings.css +2 -0
  411. package/src/styles/parts/sheet.css +28 -0
  412. package/src/styles/parts/text.css +34 -0
  413. package/src/text.ts +19 -0
  414. package/src/vocabulary.ts +4 -1
  415. package/template/plugin/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { MAX_FILE_BYTES } from "../limits.js";
3
3
  import { TRANSCRIPT_PICTURE_TYPES } from "../vocabulary.js";
4
+ import { HEADLESS_TOOL, headlessServers } from "./browser.js";
4
5
  import type { DriverHost } from "./registry.js";
5
6
  import {
6
7
  type Child,
@@ -16,7 +17,9 @@ import {
16
17
  plainCut,
17
18
  plainCutEnd,
18
19
  type StartOptions,
20
+ type UsageWindow,
19
21
  } from "./types.js";
22
+ import { saysUsageLimit } from "./usage.js";
20
23
 
21
24
  // The `claude` driver (docs/specs/runner.md): the Claude Code binary, unmodified, over its
22
25
  // streaming JSON input and output. One message a line on its standard input, one event a line
@@ -55,6 +58,119 @@ const isObject = (value: unknown): value is Json =>
55
58
  typeof value === "object" && value !== null && !Array.isArray(value);
56
59
  const textOf = (value: unknown): string | undefined =>
57
60
  typeof value === "string" ? value : undefined;
61
+ const listOf = (value: unknown): readonly unknown[] => (Array.isArray(value) ? value : []);
62
+
63
+ /** How many windows of the product's allowance a line is read for: more than it has. */
64
+ const MAX_WINDOWS = 8;
65
+ /** The product's word for a window, as it spells one. */
66
+ const WINDOW = /^[a-z][a-z0-9_]{0,39}$/;
67
+ /**
68
+ * The week's window of one model, the bucket the product keeps for a model beside the week of
69
+ * all of them: `seven_day_overage_included`, which its own description of the line calls the
70
+ * "overage-included weekly (per-model bucket)" window, and which its usage screen shows as the
71
+ * week of a model by name, "Current week (Fable)". Seen beside the week's own at twice its
72
+ * share (2.1.322). It is a window of a part of the allowance (`UsageWindow.part`): the agent
73
+ * is told of it at the shares it is told of any window at, in words of its own.
74
+ */
75
+ const MODEL_WEEK = "seven_day_overage_included";
76
+ /**
77
+ * The model `MODEL_WEEK` is the week of. WRITTEN BY HAND: the line names no model with the
78
+ * bucket (2.1.322, 2.1.330), neither beside the window nor anywhere else in it, and the product
79
+ * keeps the one bucket for the one model its usage screen names, Fable as of 2026-11, whatever
80
+ * model the session runs. To change when the product does:
81
+ * - where a line comes to name the model of the bucket, read it there in place of this word;
82
+ * - where the usage screen names another model for it, write that one here;
83
+ * - where the product keeps such a bucket for a second model, under a word of its own
84
+ * (`seven_day_opus`, as it once spelled one), nothing is to do: `windowName` says it by
85
+ * that word already, "weekly opus".
86
+ */
87
+ const MODEL_WEEK_OF = "fable";
88
+ /** A window of what the product allows beyond the subscription, which is no share of the subscription's. */
89
+ const BEYOND = /overage/;
90
+
91
+ /** A window's name in plain words: the product's `five_hour` and `seven_day` as a person calls them, the rest as it comes. */
92
+ const windowName = (word: string): string =>
93
+ word
94
+ .replace(/^five_hour/, "5-hour")
95
+ .replace(/^seven_day/, "weekly")
96
+ .replaceAll("_", " ");
97
+
98
+ /**
99
+ * A moment the product gives in seconds since the epoch, in milliseconds; nothing for anything
100
+ * that is no such number. One past the year 5000 as seconds was given in milliseconds already.
101
+ */
102
+ function momentOf(value: unknown): number | undefined {
103
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
104
+ return undefined;
105
+ }
106
+ const ms = value < 1e11 ? value * 1000 : value;
107
+ return ms < 1e14 ? Math.floor(ms) : undefined;
108
+ }
109
+
110
+ /** A share used, from 0 to 1, or nothing for anything that is no such number. */
111
+ const shareOf = (value: unknown): number | undefined =>
112
+ typeof value === "number" && Number.isFinite(value) && value >= 0
113
+ ? Math.min(1, value)
114
+ : undefined;
115
+
116
+ /**
117
+ * The windows of the allowance as the product says them of a request (`rate_limit_info`): each
118
+ * of `unifiedWindows` with how much of it is used and when it resets, or the one window the
119
+ * line itself is of where it names no others. The product marks these fields as its own and no
120
+ * contract (seen with 2.1.330): read by shape, bounded, and nothing where they are not there.
121
+ */
122
+ function windowsOf(info: Json): UsageWindow[] {
123
+ const windows: UsageWindow[] = [];
124
+ const add = (word: unknown, one: Json): void => {
125
+ if (typeof word !== "string" || !WINDOW.test(word) || windows.length >= MAX_WINDOWS) {
126
+ return;
127
+ }
128
+ const part = word === MODEL_WEEK;
129
+ const name = part
130
+ ? `weekly ${MODEL_WEEK_OF}`
131
+ : BEYOND.test(word)
132
+ ? undefined
133
+ : windowName(word);
134
+ if (name === undefined) {
135
+ return;
136
+ }
137
+ const used = shareOf(one.utilization);
138
+ const resetsAt = momentOf(one.resetsAt);
139
+ const near = one.status === "allowed_warning";
140
+ if (used !== undefined || near) {
141
+ windows.push({ name, used, resetsAt, ...(near ? { near } : {}), ...(part ? { part } : {}) });
142
+ }
143
+ };
144
+ if (isObject(info.unifiedWindows)) {
145
+ for (const [word, one] of Object.entries(info.unifiedWindows)) {
146
+ if (isObject(one)) {
147
+ add(word, one);
148
+ }
149
+ }
150
+ }
151
+ if (windows.length === 0) {
152
+ add(info.rateLimitType, info);
153
+ }
154
+ return windows;
155
+ }
156
+
157
+ /**
158
+ * Whether a line of the product's says that what the subscription allows is used up, and until
159
+ * when where it says: its typed word for it (`api_error`, with what the refused request said of
160
+ * the limit beside it), which the product marks as its own and no contract, or its words, which
161
+ * it says stay the fallback. `said` is the text of a line that is an error of the product's
162
+ * own. Written down from the product's record of a limit reached (2.1.330): no stream of one
163
+ * was recorded, since that takes using an allowance up.
164
+ */
165
+ function limitOf(line: Json, said: string): { readonly until: number | undefined } | undefined {
166
+ const typed = line.api_error === "usage_limit_reached";
167
+ if (!typed && !saysUsageLimit(said)) {
168
+ return undefined;
169
+ }
170
+ const params = isObject(line.api_error_params) ? line.api_error_params : undefined;
171
+ const info = isObject(params?.rate_limit_info) ? params.rate_limit_info : undefined;
172
+ return { until: momentOf(info?.resetsAt) };
173
+ }
58
174
 
59
175
  /** One line of the product's output as an object with a type, or nothing for anything else. */
60
176
  function lineOf(line: string): Json | undefined {
@@ -93,6 +209,20 @@ const MAX_SUBAGENTS = 500;
93
209
  /** The product's tools that start a sub-agent, as it has called them: one whose input names a kind of sub-agent is one too. */
94
210
  const SUBAGENT_TOOLS: ReadonlySet<string> = new Set(["Agent", "Task"]);
95
211
 
212
+ /** How much of what the product says of a sub-agent that failed an event shows. */
213
+ const MAX_SUMMARY_LENGTH = 1000;
214
+
215
+ /** Keeps a word under a key among at most `MAX_SUBAGENTS`: the oldest is let go past it. */
216
+ function remember(kept: Map<string, string>, key: string, word: string): void {
217
+ if (!kept.has(key) && kept.size >= MAX_SUBAGENTS) {
218
+ const oldest = kept.keys().next().value;
219
+ if (oldest !== undefined) {
220
+ kept.delete(oldest);
221
+ }
222
+ }
223
+ kept.set(key, word);
224
+ }
225
+
96
226
  /** A word of a call's input, trimmed, or nothing where it holds none. */
97
227
  const wordOf = (input: unknown, name: string): string | undefined => {
98
228
  const word = isObject(input) ? textOf(input[name])?.trim() : undefined;
@@ -186,9 +316,13 @@ interface Read {
186
316
  results: number;
187
317
  /** What it last said it runs with, and the conversation it last named: said on when they change. */
188
318
  runs: string | undefined;
319
+ /** The model it last said it runs, which a window of one model's own is named by. */
320
+ model: string | undefined;
189
321
  conversation: string | undefined;
190
322
  /** The permission mode the driver asked for. */
191
323
  readonly asked: string;
324
+ /** Whether the product was started with the server that drives the agent's browser. */
325
+ readonly drivesBrowser: boolean;
192
326
  /** The messages written to it that it has not said it took, by the id each was written under. */
193
327
  readonly waiting: Set<string>;
194
328
  /** Whether it said of any message that it took it: a build that says none back is read without. */
@@ -197,6 +331,23 @@ interface Read {
197
331
  readonly denied: Set<string>;
198
332
  /** The calls that started a sub-agent, by their ids, with what each calls it. */
199
333
  readonly subagents: Map<string, string>;
334
+ /**
335
+ * The sub-agents the product spoke of, by the id it knows each by as a task of its own, with
336
+ * the id of the call that started each: what it says of a task later, that it ended, names
337
+ * the task.
338
+ */
339
+ readonly tasks: Map<string, string>;
340
+ /** The calls the product started a sub-agent of in the background, until each is answered. */
341
+ readonly launched: Set<string>;
342
+ /** How many sub-agents it last said are at work in the background; nothing until one is. */
343
+ background: number | undefined;
344
+ /**
345
+ * The usage limit the turn under way ran into, where it did: until when, where the product
346
+ * said, and the words it was said in, which the turn's result says again.
347
+ */
348
+ limit: { until: number | undefined; said: string | undefined } | undefined;
349
+ /** When the limit resets that a request of the turn under way was refused by, where the product said so of the request. */
350
+ resets: number | undefined;
200
351
  /** What cuts a text to what is shown of it. */
201
352
  readonly cut: Cut;
202
353
  }
@@ -212,10 +363,90 @@ function whoseOf(line: Json, state: Read): Record<string, Fact> {
212
363
  if (parent === undefined || parent.length === 0) {
213
364
  return {};
214
365
  }
366
+ // A sub-agent's line names the sub-agent too, by the id the product's word on its tasks
367
+ // names it by (`agent_id`; seen with 2.1.330): what the line says of the two holds over what
368
+ // a task's start said, which names another call where a sub-agent was started again.
369
+ const task = textOf(line.agent_id);
370
+ if (task !== undefined && task.length > 0) {
371
+ remember(state.tasks, task, parent);
372
+ }
373
+ return factsOf(parent, state);
374
+ }
375
+
376
+ /** The facts of an event of the sub-agent a call started: the call, and what it called the sub-agent where it was read. */
377
+ function factsOf(parent: string, state: Read): Record<string, Fact> {
215
378
  const subagent = state.subagents.get(parent);
216
379
  return subagent === undefined ? { parent } : { parent, subagent };
217
380
  }
218
381
 
382
+ /** How the product says a task ended, as its documentation has the three. */
383
+ const TASK_ENDS: ReadonlySet<string> = new Set(["completed", "failed", "stopped"]);
384
+
385
+ /**
386
+ * What the product says when a sub-agent ended (`task_notification`, as its documentation has
387
+ * the line; seen with 2.1.322 of the three) as an event of that sub-agent's: how it ended,
388
+ * `completed`, `failed` or `stopped`, under `over`. A sub-agent that goes on in the background is answered for when it starts, so this
389
+ * is the one word the record has of its end. Nothing for a task that is no sub-agent the
390
+ * driver knows the call of: a command, a watch, or one a process before this one started.
391
+ */
392
+ function overOf(line: Json, state: Read): DriverEvent | undefined {
393
+ const how = textOf(line.status);
394
+ if (how === undefined || !TASK_ENDS.has(how)) {
395
+ return undefined;
396
+ }
397
+ const said = textOf(line.tool_use_id);
398
+ const parent =
399
+ state.tasks.get(textOf(line.task_id) ?? "") ??
400
+ (said !== undefined && state.subagents.has(said) ? said : undefined);
401
+ if (parent === undefined) {
402
+ return undefined;
403
+ }
404
+ // Why it failed is the product's to say, in words of its own: shown within a bound, cut
405
+ // after the secrets are out.
406
+ const why = how === "failed" ? (textOf(line.summary)?.trim() ?? "") : "";
407
+ const text =
408
+ how === "completed"
409
+ ? "The sub-agent is done."
410
+ : how === "stopped"
411
+ ? "The sub-agent was stopped."
412
+ : `The sub-agent failed.${why.length === 0 ? "" : `\n${state.cut(why, MAX_SUMMARY_LENGTH)}`}`;
413
+ return { type: "event", kind: "status", text, data: { ...factsOf(parent, state), over: how } };
414
+ }
415
+
416
+ /**
417
+ * Whether what a tool answered is the product's word that the sub-agent the call started goes
418
+ * on in the background, and not what that sub-agent answered, as the structured output the
419
+ * product writes beside the result says it (`tool_use_result`, whose `status` is
420
+ * `async_launched` there, as its own declaration of the tool's output has it): the output of
421
+ * the one result a line carries, for a call that was moved to the background after it was made.
422
+ * A call made so says it as its sub-agent starts (`task_started`), the one word there is of a
423
+ * call a sub-agent made, whose answer carries no such output (seen with 2.1.322).
424
+ */
425
+ const launchedOf = (line: Json, results: number): boolean =>
426
+ results === 1 &&
427
+ isObject(line.tool_use_result) &&
428
+ line.tool_use_result.status === "async_launched";
429
+
430
+ /**
431
+ * The sub-agents at work in the background, by the product's list of its tasks there, which it
432
+ * writes whole as it changes (`background_tasks_changed`; seen with 2.1.322). A command a
433
+ * sub-agent left running there (`parent_task_id`) is that sub-agent at work, though it ended
434
+ * its turn: the product starts it again when the command ends. A command of the session's own
435
+ * is none.
436
+ */
437
+ function agentsOf(tasks: unknown): number {
438
+ const agents = new Set<string>();
439
+ for (const task of listOf(tasks)) {
440
+ if (isObject(task)) {
441
+ const id = textOf(task.task_type === "local_agent" ? task.task_id : task.parent_task_id);
442
+ if (id !== undefined) {
443
+ agents.add(id);
444
+ }
445
+ }
446
+ }
447
+ return agents.size;
448
+ }
449
+
219
450
  /** The product's permission modes, as its documentation and its own help name them. */
220
451
  const MODES = [
221
452
  "default",
@@ -271,7 +502,11 @@ function eventsOf(line: Json, state: Read): DriverEvent[] {
271
502
  const version = textOf(line.claude_code_version) ?? null;
272
503
  const mode = textOf(line.permissionMode) ?? null;
273
504
  const runs = JSON.stringify([model, effort, version, mode]);
505
+ state.model = model ?? undefined;
274
506
  const conversation = textOf(line.session_id);
507
+ if (state.background !== undefined) {
508
+ events.push({ type: "turn_started" });
509
+ }
275
510
  if (runs !== state.runs) {
276
511
  events.push({ type: "running", model, effort, version });
277
512
  }
@@ -290,6 +525,24 @@ function eventsOf(line: Json, state: Read): DriverEvent[] {
290
525
  : "The product started.",
291
526
  data: { model, effort, version, mode },
292
527
  });
528
+ // The product goes on where a server it was started with did not start, and says so
529
+ // only here: without this line an agent that was told it has a browser has none,
530
+ // and nobody reads why.
531
+ const failed =
532
+ state.drivesBrowser &&
533
+ listOf(line.mcp_servers).some(
534
+ (server) =>
535
+ isObject(server) &&
536
+ server.name === HEADLESS_TOOL.server &&
537
+ server.status === "failed",
538
+ );
539
+ if (failed) {
540
+ events.push({
541
+ type: "event",
542
+ kind: "status",
543
+ text: `The agent's browser did not start: the product could not start ${HEADLESS_TOOL.command}, so this session has no browser. On this machine: ${HEADLESS_TOOL.install}, which runs on ${HEADLESS_TOOL.needs}; or name "browser": "none" in runner.json.`,
544
+ });
545
+ }
293
546
  } else if (runs !== state.runs) {
294
547
  events.push({
295
548
  type: "event",
@@ -315,6 +568,41 @@ function eventsOf(line: Json, state: Read): DriverEvent[] {
315
568
  text: "The product is asking the model again after a request that failed.",
316
569
  data: { attempt },
317
570
  });
571
+ } else if (line.subtype === "task_started") {
572
+ // A sub-agent is a task of the product's own, which names the call that started it
573
+ // (`task_type`, `tool_use_id`, as its documentation has them).
574
+ const task = textOf(line.task_id);
575
+ const call = textOf(line.tool_use_id);
576
+ if (line.task_type === "local_agent" && task !== undefined && call !== undefined) {
577
+ const known = state.tasks.get(task);
578
+ if (known === undefined) {
579
+ remember(state.tasks, task, call);
580
+ if (line.is_backgrounded === true) {
581
+ state.launched.add(call);
582
+ }
583
+ } else {
584
+ // One known already is started again, by a message the agent sent it or by the
585
+ // product once a command of its own ended (seen with 2.1.322): an event of the
586
+ // sub-agent's, under the call its events name, whatever call this line names.
587
+ events.push({
588
+ type: "event",
589
+ kind: "status",
590
+ text: "The sub-agent was started again.",
591
+ data: factsOf(known, state),
592
+ });
593
+ }
594
+ }
595
+ } else if (line.subtype === "background_tasks_changed") {
596
+ const agents = agentsOf(line.tasks);
597
+ if (agents !== (state.background ?? 0)) {
598
+ state.background = agents;
599
+ events.push({ type: "background", agents });
600
+ }
601
+ } else if (line.subtype === "task_notification") {
602
+ const over = overOf(line, state);
603
+ if (over !== undefined) {
604
+ events.push(over);
605
+ }
318
606
  } else if (line.subtype === "permission_denied") {
319
607
  // Said when it happens, and again in the turn's result, which is then not said twice.
320
608
  const denied = denialOf(line, state.cut);
@@ -332,6 +620,32 @@ function eventsOf(line: Json, state: Read): DriverEvent[] {
332
620
  const whose = whoseOf(line, state);
333
621
  // A fact is said only where there is one: a line of the session's own carries none.
334
622
  const said = Object.keys(whose).length === 0 ? {} : { data: whose };
623
+ // An error of the product's own, which it writes in the model's place: where it says the
624
+ // usage limit is reached, in the session's own turn, it is the product's word and no
625
+ // answer of the agent's, and the turn's result is read by it.
626
+ if (
627
+ (typeof line.error === "string" || line.is_api_error_message === true) &&
628
+ Object.keys(whose).length === 0
629
+ ) {
630
+ const words = blocks
631
+ .flatMap((block) =>
632
+ isObject(block) && block.type === "text" && typeof block.text === "string"
633
+ ? [block.text]
634
+ : [],
635
+ )
636
+ .join("\n");
637
+ const limit = limitOf(line, words);
638
+ if (limit !== undefined) {
639
+ state.limit = { until: limit.until, said: words };
640
+ events.push({
641
+ type: "event",
642
+ kind: "error",
643
+ text: words.length === 0 ? "The product's usage limit is reached." : words,
644
+ data: { limit: "reached" },
645
+ });
646
+ return events;
647
+ }
648
+ }
335
649
  for (const block of blocks) {
336
650
  if (!isObject(block)) {
337
651
  continue;
@@ -350,13 +664,7 @@ function eventsOf(line: Json, state: Read): DriverEvent[] {
350
664
  const subagent = subagentOf(tool, block.input, state.cut);
351
665
  if (id !== undefined && subagent !== undefined) {
352
666
  // What the sub-agent this call starts does names the call: remembered by its id.
353
- if (state.subagents.size >= MAX_SUBAGENTS) {
354
- const oldest = state.subagents.keys().next().value;
355
- if (oldest !== undefined) {
356
- state.subagents.delete(oldest);
357
- }
358
- }
359
- state.subagents.set(id, subagent);
667
+ remember(state.subagents, id, subagent);
360
668
  }
361
669
  events.push({
362
670
  type: "event",
@@ -388,10 +696,15 @@ function eventsOf(line: Json, state: Read): DriverEvent[] {
388
696
  }
389
697
  // What came back from a tool is recorded here, a sub-agent's tool as the session's own.
390
698
  const whose = whoseOf(line, state);
391
- for (const block of blocks) {
392
- if (!isObject(block) || block.type !== "tool_result") {
699
+ const results = blocks.filter((block) => isObject(block) && block.type === "tool_result");
700
+ // An answer that says the sub-agent goes on in the background is not that sub-agent's
701
+ // answer: said, so that whoever reads the session takes it for at work from there on.
702
+ const moved = launchedOf(line, results.length);
703
+ for (const block of results) {
704
+ if (!isObject(block)) {
393
705
  continue;
394
706
  }
707
+ const launched = state.launched.delete(textOf(block.tool_use_id) ?? "") || moved;
395
708
  state.results += 1;
396
709
  const result = resultOf(block.content, `tool-${state.results}`);
397
710
  events.push({
@@ -401,6 +714,7 @@ function eventsOf(line: Json, state: Read): DriverEvent[] {
401
714
  data: {
402
715
  id: textOf(block.tool_use_id) ?? null,
403
716
  error: block.is_error === true,
717
+ ...(launched ? { background: true } : {}),
404
718
  ...whose,
405
719
  },
406
720
  pictures: result.pictures,
@@ -431,6 +745,36 @@ function eventsOf(line: Json, state: Read): DriverEvent[] {
431
745
  // A turn that was stopped says so in the product's word for how it ended, and is no
432
746
  // error, whatever else its result says: it is what was asked for.
433
747
  const stopped = textOf(line.terminal_reason)?.startsWith("aborted") === true;
748
+ // A turn that ended on the usage limit: the agent cannot go on until a window resets, and
749
+ // whatever it was handed and had not answered is the runner's to hand over again. Said
750
+ // once, though the product writes it twice, in the model's place and as the result.
751
+ const met = state.limit;
752
+ const resets = state.resets;
753
+ state.limit = undefined;
754
+ state.resets = undefined;
755
+ const limit = line.is_error === true && !stopped ? (limitOf(line, said) ?? met) : undefined;
756
+ if (limit !== undefined) {
757
+ // A build that says no message back: what it was written is not waited for here, and
758
+ // is the runner's to hand over again.
759
+ if (!state.acknowledges) {
760
+ state.waiting.clear();
761
+ }
762
+ if (met?.said === undefined || (said.length > 0 && said !== met.said)) {
763
+ events.push({
764
+ type: "event",
765
+ kind: "error",
766
+ text: said.length === 0 ? "The product's usage limit is reached." : said,
767
+ data: { limit: "reached" },
768
+ });
769
+ }
770
+ events.push({
771
+ type: "cannot_go_on",
772
+ state: "failed",
773
+ reason: "usage_limit",
774
+ until: limit.until ?? met?.until ?? resets,
775
+ });
776
+ return events;
777
+ }
434
778
  if (line.is_error === true && !stopped) {
435
779
  events.push({
436
780
  type: "event",
@@ -469,6 +813,22 @@ function eventsOf(line: Json, state: Read): DriverEvent[] {
469
813
  events.push({ type: "turn_completed" });
470
814
  return events;
471
815
  }
816
+ case "rate_limit_event": {
817
+ // What the product says of the allowance after a request: said on as it is, for the
818
+ // runner to tell its agent by. A request the limit refused says when the limit resets.
819
+ const info = isObject(line.rate_limit_info) ? line.rate_limit_info : undefined;
820
+ if (info === undefined) {
821
+ return events;
822
+ }
823
+ const windows = windowsOf(info);
824
+ if (windows.length > 0) {
825
+ events.push({ type: "usage", windows });
826
+ }
827
+ if (info.status === "rejected") {
828
+ state.resets = momentOf(info.resetsAt) ?? state.resets;
829
+ }
830
+ return events;
831
+ }
472
832
  case "command_lifecycle": {
473
833
  // What the product says became of a message: one it is done with, or will not take, is
474
834
  // not waited for, whether or not it was said back.
@@ -538,6 +898,7 @@ function sessionOf(
538
898
  child: Child,
539
899
  command: string,
540
900
  asked: string,
901
+ drivesBrowser: boolean,
541
902
  uuid: () => string,
542
903
  cut: Cut,
543
904
  cutEnd: Cut,
@@ -547,12 +908,19 @@ function sessionOf(
547
908
  began: false,
548
909
  results: 0,
549
910
  runs: undefined,
911
+ model: undefined,
550
912
  conversation: undefined,
551
913
  asked,
914
+ drivesBrowser,
552
915
  waiting: new Set(),
553
916
  denied: new Set(),
554
917
  acknowledges: false,
555
918
  subagents: new Map(),
919
+ tasks: new Map(),
920
+ launched: new Set(),
921
+ background: undefined,
922
+ limit: undefined,
923
+ resets: undefined,
556
924
  cut,
557
925
  };
558
926
 
@@ -632,8 +1000,15 @@ const WORD = /^[A-Za-z0-9][A-Za-z0-9._:[\]-]{0,199}$/;
632
1000
  const word = (value: string | null | undefined): string | undefined =>
633
1001
  typeof value === "string" && WORD.test(value) ? value : undefined;
634
1002
 
635
- /** The arguments the product is started with. */
636
- export function claudeArguments(options: StartOptions): readonly string[] {
1003
+ /**
1004
+ * The arguments the product is started with. `platform` is the system the runner is on, as the
1005
+ * runtime names it: what a program named beside the product's own is started as.
1006
+ */
1007
+ /** Whether a browser a desk names is the one the driver has the product start a server for. */
1008
+ const drivesBrowser = (browser: string | undefined): boolean =>
1009
+ browser === "headless" || browser === "window";
1010
+
1011
+ export function claudeArguments(options: StartOptions, platform?: string): readonly string[] {
637
1012
  const model = word(options.model);
638
1013
  const effort = word(options.effort);
639
1014
  const resume = word(options.resume);
@@ -656,6 +1031,14 @@ export function claudeArguments(options: StartOptions): readonly string[] {
656
1031
  // The product's browser tool is off in a run nobody attends unless it is asked for when the
657
1032
  // product starts: seen with 2.1.329, where its own setting for it did nothing in this mode.
658
1033
  ...(options.browser === "chrome" ? ["--chrome"] : []),
1034
+ // A headless browser is no tool of the product's own (ADR-0151): the product starts the
1035
+ // program that drives one as a server of its own, named here for this run alone, and its
1036
+ // settings are left as they are. The server's tools are leave for nothing by themselves:
1037
+ // the mode decides of them as of every tool. The option takes every word after it up to
1038
+ // the next option, so an option follows it, and never a word of its own.
1039
+ ...(drivesBrowser(options.browser)
1040
+ ? ["--mcp-config", JSON.stringify(headlessServers(platform, options.browser === "window"))]
1041
+ : []),
659
1042
  ...(model === undefined ? [] : ["--model", model]),
660
1043
  ...(effort === undefined ? [] : ["--effort", effort]),
661
1044
  ...(resume === undefined ? [] : ["--resume", resume]),
@@ -698,9 +1081,13 @@ export function createClaudeDriver(host: DriverHost): Driver {
698
1081
  },
699
1082
  start(options) {
700
1083
  return sessionOf(
701
- host.spawn(command, claudeArguments(options), { cwd: options.cwd, env: options.env }),
1084
+ host.spawn(command, claudeArguments(options, host.platform), {
1085
+ cwd: options.cwd,
1086
+ env: options.env,
1087
+ }),
702
1088
  command,
703
1089
  claudeMode(options.permissions),
1090
+ drivesBrowser(options.browser),
704
1091
  uuid,
705
1092
  options.cut ?? plainCut,
706
1093
  options.cutEnd ?? plainCutEnd,