@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
package/src/cli/cli.ts CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  FIND_MAX_LIMIT,
16
16
  READ_FILE_MAX_LIMIT,
17
17
  type ToolWords,
18
+ utf8Length,
18
19
  } from "@skillcdn/core";
19
20
  import { avatarScanlines, MAX_AVATAR_PIXELS, pngFile } from "../avatar.js";
20
21
  import {
@@ -53,13 +54,19 @@ import {
53
54
  MIN_OPTIONS,
54
55
  OWN_WAKE_KEY,
55
56
  } from "../limits.js";
57
+ import {
58
+ MAX_NOTIFICATIONS_PAGE,
59
+ NOTIFICATION_KINDS,
60
+ NOTIFICATIONS_PAGE,
61
+ } from "../notifications.js";
56
62
  import { onboardingTitle } from "../onboarding.js";
57
63
  import { capabilityWords } from "../plugin/capabilities.js";
58
64
  import { PLUGIN_LIST_LIMIT } from "../plugin/limits.js";
59
65
  import { checkRecords, RECORDS_DIR, RECORDS_INDEX_FILE, type RecordsFiles } from "../records.js";
60
66
  import { agentHref, decisionHref, docHref, myDecisionHref, taskHref } from "../router.js";
61
67
  import { fillRules, RULES_PATH, RULES_TITLE } from "../rules.js";
62
- import { DEFAULT_RUNNER_CONFIG, parseRunnerConfig } from "../runner/config.js";
68
+ import { HEADLESS_TOOL } from "../runner/browser.js";
69
+ import { DEFAULT_RUNNER_CONFIG, parseRunnerConfig, type RunnerBrowser } from "../runner/config.js";
63
70
  import {
64
71
  DESK_FOLDER,
65
72
  deskFiles,
@@ -67,6 +74,7 @@ import {
67
74
  deskWebTitleOf,
68
75
  personDeskFiles,
69
76
  } from "../runner/desk.js";
77
+ import { quotedLines } from "../runner/message.js";
70
78
  import { ownRunnerModules } from "../runner/modules.js";
71
79
  import {
72
80
  createRunner,
@@ -83,6 +91,7 @@ import {
83
91
  type RestClaim,
84
92
  type RestDecision,
85
93
  type RestMember,
94
+ type RestNotificationSettings,
86
95
  type RestPackConnectStarted,
87
96
  type RestPerson,
88
97
  type RestPluginDetail,
@@ -92,6 +101,7 @@ import {
92
101
  type RestRules,
93
102
  type RestRun,
94
103
  type RestRunBrief,
104
+ type RestSignal,
95
105
  type RestTask,
96
106
  type RestTaskPatch,
97
107
  } from "../schemas.js";
@@ -165,6 +175,8 @@ import {
165
175
  formatListingLine,
166
176
  formatMemberLine,
167
177
  formatMore,
178
+ formatNotificationSettings,
179
+ formatNotifications,
168
180
  formatOptions,
169
181
  formatOwnWakeLine,
170
182
  formatPersonLine,
@@ -189,6 +201,7 @@ import {
189
201
  formatSecretLine,
190
202
  formatSignalLine,
191
203
  formatTask,
204
+ formatTaskFollow,
192
205
  formatTaskLine,
193
206
  formatTeamLine,
194
207
  formatVersion,
@@ -203,7 +216,14 @@ import {
203
216
  } from "./format.js";
204
217
  import { COMMAND_HELP, helpFor, ownSkillPath, usage } from "./help.js";
205
218
  import { describeInstall, type Install, updateCommandFor } from "./install.js";
206
- import { awakeWords, heldAwake, lookAtMachine, type MachineLook } from "./machine-check.js";
219
+ import {
220
+ awakeWords,
221
+ heldAwake,
222
+ lookAtMachine,
223
+ type MachineLook,
224
+ type SetupBrowser,
225
+ standsInTheWay,
226
+ } from "./machine-check.js";
207
227
  import type { NoticeStore } from "./notices.js";
208
228
  import {
209
229
  type ConsolePack,
@@ -216,6 +236,7 @@ import {
216
236
  packWords,
217
237
  refusalWords,
218
238
  skillPathIn,
239
+ skillsAround,
219
240
  } from "./pack.js";
220
241
  import { type RunnerHost, workPath } from "./runner-host.js";
221
242
  import { secretNotes } from "./secret-notes.js";
@@ -293,8 +314,17 @@ export interface CliIo {
293
314
  readonly readFile: (path: string) => Promise<string>;
294
315
  /** A file handed in, as bytes. */
295
316
  readonly readBytes: (path: string) => Promise<Uint8Array>;
296
- /** A file read from the console, written at a path, or into a directory under its name; says where. */
297
- readonly writeBytes: (path: string, bytes: Uint8Array, name: string) => Promise<string>;
317
+ /**
318
+ * A file read from the console, written at a path, or into a directory under its name; says
319
+ * where. With `private`, the file is the OS account's alone to read, whatever was there;
320
+ * with `after`, the bytes go after what the file holds, which stays.
321
+ */
322
+ readonly writeBytes: (
323
+ path: string,
324
+ bytes: Uint8Array,
325
+ name: string,
326
+ options?: { readonly private?: boolean; readonly after?: boolean },
327
+ ) => Promise<string>;
298
328
  readonly store: CredentialStore;
299
329
  /** What the working directory says of the project, and the way to write it. */
300
330
  readonly directory: DirectoryStore;
@@ -1853,7 +1883,9 @@ function whereGiven(values: Readonly<Record<string, unknown>>): readonly string[
1853
1883
  * with. What the pack refused ends the command as refused (ADR-0118): of one read, in the
1854
1884
  * pack's own code and words, as that command prints them; of the pack as a whole, in the
1855
1885
  * console's. A read not asked right is a command not understood. With `data`, nothing is
1856
- * printed for a refusal even with `--json`: what a program takes is never one.
1886
+ * printed for a refusal even with `--json`: what a program takes is never one. `beside` is the
1887
+ * lines the command prints of its own around the text, which the read keeps room for, so that
1888
+ * the whole output is one a host shows whole.
1857
1889
  */
1858
1890
  async function readThrough(
1859
1891
  io: CliIo,
@@ -1865,6 +1897,7 @@ async function readThrough(
1865
1897
  readonly words: ToolWords;
1866
1898
  readonly nextPart?: ((cursor: string) => string) | undefined;
1867
1899
  readonly data?: boolean | undefined;
1900
+ readonly beside?: readonly (string | undefined)[] | undefined;
1868
1901
  },
1869
1902
  ): Promise<ReadOutput> {
1870
1903
  try {
@@ -1872,6 +1905,7 @@ async function readThrough(
1872
1905
  words: options.words,
1873
1906
  json: session.json,
1874
1907
  nextPart: options.nextPart,
1908
+ room: roomFor(owner, options.beside ?? []),
1875
1909
  });
1876
1910
  } catch (error) {
1877
1911
  if (error instanceof ReadMisuse) {
@@ -1892,6 +1926,19 @@ async function readThrough(
1892
1926
  }
1893
1927
  }
1894
1928
 
1929
+ /**
1930
+ * The bytes the command prints beside what a read of the pack prints (ADR-0124): each line of
1931
+ * its own with the break that sets it apart, and the line that says the pack is the
1932
+ * organization's where it is.
1933
+ */
1934
+ function roomFor(owner: PackOwner, beside: readonly (string | undefined)[]): number {
1935
+ const lines = [owner === "organization" ? ORGANIZATION_PACK_LINE : undefined, ...beside];
1936
+ return lines.reduce(
1937
+ (bytes, line) => (line === undefined ? bytes : bytes + utf8Length(line) + 1),
1938
+ 0,
1939
+ );
1940
+ }
1941
+
1895
1942
  /**
1896
1943
  * What `--json` prints for a read: the console's answer, with the pack's own in it as the
1897
1944
  * skillcdn command's `--json` prints it, the pages of a skill or of a read of data joined.
@@ -1980,6 +2027,8 @@ async function readSkills(
1980
2027
  readonly afterwards?: string | undefined;
1981
2028
  /** Whose pack it is: the organization's where no project is named (ADR-0113), else a project's. */
1982
2029
  readonly owner?: PackOwner | undefined;
2030
+ /** What the command that lists the next page says after the cursor: where the pack is read, as it was said for this page. */
2031
+ readonly again?: readonly string[] | undefined;
1983
2032
  },
1984
2033
  ): Promise<number> {
1985
2034
  const owner = extras.owner ?? "project";
@@ -2045,9 +2094,10 @@ async function readSkills(
2045
2094
  }
2046
2095
  const named = given ?? within;
2047
2096
  const folder = named === undefined || named === "/" || named === "." ? undefined : named;
2048
- if (words === undefined && given === undefined && (limit !== undefined || cursor !== undefined)) {
2097
+ // The listing is as long as one read prints, and goes on from the cursor its page ended with.
2098
+ if (words === undefined && given === undefined && limit !== undefined) {
2049
2099
  throw misuse(
2050
- `--limit and --cursor go with a folder or with --search: ${extras.command} <folder> [--limit <n>] [--cursor <cursor>]`,
2100
+ `--limit goes with a folder or with --search: ${extras.command} <folder> [--limit <n>] [--cursor <cursor>]`,
2051
2101
  );
2052
2102
  }
2053
2103
  // A page of what words find, or of what a folder holds: the bounds of each, as the pack has them.
@@ -2086,15 +2136,52 @@ async function readSkills(
2086
2136
  );
2087
2137
  }
2088
2138
  if (words === undefined && given === undefined) {
2089
- // --json is the console's listing as it answered it; the words are the pack's own, read once more from that answer.
2090
- const told = session.json
2091
- ? undefined
2092
- : await readThrough(io, session, owner, pack, { read: "skills" }, { words: toolWords });
2093
- say(listing, () =>
2094
- [formatSkills(listing, told?.text, extras.own, owner, toolWords), loading, extras.afterwards]
2095
- .filter((part): part is string => part !== undefined)
2096
- .join("\n"),
2139
+ // --json is the console's listing as it answered it, whole; the words are the pack's own,
2140
+ // read once more from that answer, a listing longer than one read prints in pages.
2141
+ if (session.json) {
2142
+ say(listing, () => "");
2143
+ return EXIT.ok;
2144
+ }
2145
+ // The console's own lines stand around the first page, and the read keeps room for them
2146
+ // and for the empty lines that set them apart.
2147
+ const around = skillsAround(listing, extras.own, toolWords);
2148
+ const own = [
2149
+ ...around.host,
2150
+ ...around.own,
2151
+ loading,
2152
+ ...(extras.afterwards === undefined ? [] : [extras.afterwards]),
2153
+ ];
2154
+ const told = await readThrough(
2155
+ io,
2156
+ session,
2157
+ owner,
2158
+ pack,
2159
+ { read: "skills", cursor },
2160
+ {
2161
+ words: toolWords,
2162
+ beside: cursor === undefined ? [around.head, ...own, "", "", ""] : [],
2163
+ nextPart: (next) =>
2164
+ commandLine(extras.command, ["--cursor", next, ...(extras.again ?? [])]) ??
2165
+ `${extras.command} with --cursor ${commandWord(next) ?? JSON.stringify(next)}, each word quoted for your shell. ${NO_LINE_TO_RUN}`,
2166
+ },
2097
2167
  );
2168
+ say(listing, () => {
2169
+ // A page read from a cursor is the pack's own words alone: what stands around the
2170
+ // listing was said with its first page.
2171
+ if (cursor !== undefined) {
2172
+ return told.text;
2173
+ }
2174
+ // Where the listing goes on, the command that lists the rest is the last line printed,
2175
+ // as a part of a skill ends with the command that reads the next: the console's own
2176
+ // lines stand above the listing then, and after it where it is whole.
2177
+ return told.next === undefined
2178
+ ? [
2179
+ formatSkills(listing, told.text, extras.own, owner, toolWords),
2180
+ loading,
2181
+ ...(extras.afterwards === undefined ? [] : [extras.afterwards]),
2182
+ ].join("\n")
2183
+ : [around.head, ...own, "", told.text].join("\n");
2184
+ });
2098
2185
  return EXIT.ok;
2099
2186
  }
2100
2187
  if (words !== undefined) {
@@ -2105,7 +2192,7 @@ async function readSkills(
2105
2192
  owner,
2106
2193
  pack,
2107
2194
  { read: "find", words, path: folder, cursor, limit },
2108
- { words: toolWords },
2195
+ { words: toolWords, beside: [loading] },
2109
2196
  );
2110
2197
  say(jsonOfRead(session, pack, found), () => `${found.text}\n${loading}`);
2111
2198
  return EXIT.ok;
@@ -2137,24 +2224,6 @@ async function packNamed(
2137
2224
  : { reader: await session.project(), owner: "project" };
2138
2225
  }
2139
2226
 
2140
- /**
2141
- * A read of the organization's pack at a console from before ADR-0113, which has no such
2142
- * routes and answers that nothing is at the path: said as what it is, with what still reads a
2143
- * pack there, where the console's own words would read as a missing skill.
2144
- */
2145
- async function readingPack(owner: PackOwner, read: () => Promise<number>): Promise<number> {
2146
- try {
2147
- return await read();
2148
- } catch (error) {
2149
- if (owner === "organization" && error instanceof ApiError && error.code === "not_found") {
2150
- throw failed(
2151
- `This console does not read the organization's pack where no project is named: it is older than the command. ${NO_PROJECT}`,
2152
- );
2153
- }
2154
- throw error;
2155
- }
2156
- }
2157
-
2158
2227
  /**
2159
2228
  * Prints a read of a pack: as `answer` does, and, where the pack is the organization's, under
2160
2229
  * the line that says so. `--json` stays what the console answered.
@@ -2175,14 +2244,13 @@ const skills: Command = async (args, io) => {
2175
2244
  const { values, positionals } = parse(args, SKILLS_OPTIONS);
2176
2245
  const session = await open(io, values);
2177
2246
  const { reader, owner } = await packNamed(session);
2178
- return readingPack(owner, () =>
2179
- readSkills(io, session, reader, values, positionals, {
2180
- command: "console skills",
2181
- own: io.skillsDir,
2182
- afterwards: PLUGIN_SKILLS_LINE,
2183
- owner,
2184
- }),
2185
- );
2247
+ return readSkills(io, session, reader, values, positionals, {
2248
+ command: "console skills",
2249
+ own: io.skillsDir,
2250
+ afterwards: PLUGIN_SKILLS_LINE,
2251
+ owner,
2252
+ again: whereGiven(values),
2253
+ });
2186
2254
  };
2187
2255
 
2188
2256
  /**
@@ -2266,11 +2334,9 @@ async function readSkill(
2266
2334
  throw misuse(wanted.error);
2267
2335
  }
2268
2336
  // The skill, its rules first, as load_skill lays them out: whole, or the part that begins at
2269
- // the cursor, ending with the command that reads the next, asked as this one was.
2270
- // The library asks for that line of every run of pages it tries, the runs it goes on from
2271
- // among them, so a line was asked for of a skill that is then printed to its end: the part
2272
- // goes on only where what is printed ends with the line.
2273
- const offered: { readonly cursor: string; readonly line: string }[] = [];
2337
+ // the cursor. A part says how many pages of the skill follow it and ends with the command
2338
+ // that reads the next, asked as this one was, and the last says that it is the last: the
2339
+ // words are the skillcdn command's own (SkillCDN 0.6.2), and only the line is made here.
2274
2340
  const loaded = await readThrough(
2275
2341
  io,
2276
2342
  session,
@@ -2281,60 +2347,28 @@ async function readSkill(
2281
2347
  words: toolWords,
2282
2348
  // Spelled so that bash and PowerShell run it as it is; where a word has no such spelling,
2283
2349
  // the command that was run is run again, with the cursor, and the line says why.
2284
- nextPart: (next) => {
2285
- const line =
2286
- commandLine(command, [given, "--cursor", next, ...again]) ??
2287
- `the command you ran, with --cursor ${commandWord(next) ?? JSON.stringify(next)} in place of any it had, each word quoted for your shell. ${NO_LINE_TO_RUN}`;
2288
- offered.push({ cursor: next, line });
2289
- return line;
2290
- },
2350
+ nextPart: (next) =>
2351
+ commandLine(command, [given, "--cursor", next, ...again]) ??
2352
+ `the command you ran, with --cursor ${commandWord(next) ?? JSON.stringify(next)} in place of any it had, each word quoted for your shell. ${NO_LINE_TO_RUN}`,
2291
2353
  },
2292
2354
  );
2293
- const goesOn = offered.findLast((one) => loaded.text.endsWith(one.line));
2294
- // A part that is not the last ends with the console's own words after the library's line: a
2295
- // fresh agent read one part of four, saw that the skill continued, and planned from that part,
2296
- // since "before using it" did not read as now to a session that meant only to plan. The last
2297
- // part of a skill read in parts says that it is the last, so that the end is said and not
2298
- // only missed.
2299
- const closing =
2300
- goesOn !== undefined
2301
- ? partEndsHere(pack.pagesAfter(goesOn.cursor))
2302
- : cursor !== undefined && pack.skillEnded()
2303
- ? SKILL_ENDS_HERE
2304
- : undefined;
2305
- say(jsonOfRead(session, pack, loaded), () =>
2306
- closing === undefined ? loaded.text : `${loaded.text}\n${closing}`,
2307
- );
2355
+ say(jsonOfRead(session, pack, loaded), () => loaded.text);
2308
2356
  return EXIT.ok;
2309
2357
  }
2310
2358
 
2311
- /**
2312
- * What a part of a skill ends with where another follows: that the instructions stop here,
2313
- * what the rest holds, and that the command above is run now.
2314
- */
2315
- const PART_ENDS_HERE =
2316
- "This part stops in the middle of the skill: its later steps, its checkpoints and its rules are in the parts that follow, and nothing above is complete without them. Run that command now, before a plan, an answer or any other step, and each next one, until a part ends without these lines.";
2317
-
2318
- /**
2319
- * The same with how far the skill goes on before it, where the pack counts the pages left
2320
- * (SkillCDN 0.6.1): a reader told how many pages follow reads a skill to its end far more often
2321
- * than one told only that it continues. A part is a run of pages, so the count is the pack's
2322
- * own, of pages, and falls from part to part.
2323
- */
2324
- const partEndsHere = (left: number | undefined): string =>
2325
- left === undefined || left < 1
2326
- ? PART_ENDS_HERE
2327
- : `${left} more ${left === 1 ? "page" : "pages"} of the skill ${left === 1 ? "follows" : "follow"} this part. ${PART_ENDS_HERE}`;
2328
-
2329
- /** What the last part of a skill read in parts ends with. */
2330
- const SKILL_ENDS_HERE = "The skill is complete: this was its last part.";
2331
-
2332
2359
  const skill: Command = async (args, io) => {
2333
2360
  const { values, positionals } = parse(args, SKILL_OPTIONS);
2334
2361
  const session = await open(io, values);
2335
2362
  const { reader, owner } = await packNamed(session);
2336
- return readingPack(owner, () =>
2337
- readSkill(io, session, reader, values, positionals, "console skill", owner, whereGiven(values)),
2363
+ return readSkill(
2364
+ io,
2365
+ session,
2366
+ reader,
2367
+ values,
2368
+ positionals,
2369
+ "console skill",
2370
+ owner,
2371
+ whereGiven(values),
2338
2372
  );
2339
2373
  };
2340
2374
 
@@ -2453,6 +2487,7 @@ const plugin: Command = async (args, io) => {
2453
2487
  const parsed = parse(rest, SKILLS_OPTIONS);
2454
2488
  return readSkills(io, session, client, parsed.values, parsed.positionals, {
2455
2489
  command: `console plugin ${key} skills`,
2490
+ again: whereGiven(values),
2456
2491
  });
2457
2492
  }
2458
2493
  case "skill": {
@@ -2623,9 +2658,7 @@ function whereValueOf(word: string): unknown {
2623
2658
  * the caller may read it, which the console decides (every event for an administrator; for
2624
2659
  * anyone else those of the projects they may see, their own commands and the console's word of
2625
2660
  * the plugin); the failures alone with `--kind plugin.failed`, whether or not it has a board
2626
- * project. A console before 0.5.1 takes no kind and answers every one: the page is narrowed
2627
- * here, and that is said, since a page narrowed after it was read may hold fewer than were
2628
- * asked for.
2661
+ * project.
2629
2662
  */
2630
2663
  async function pluginEvents(
2631
2664
  io: CliIo,
@@ -2647,21 +2680,8 @@ async function pluginEvents(
2647
2680
  const limit = countOf(text(values, "limit"), "limit", { least: 1, most: EVENTS_PAGE_LIMIT });
2648
2681
  const offset = countOf(text(values, "offset"), "offset", { least: 0, most: 1_000_000 });
2649
2682
  const asked = { kind, limit: limit ?? DEFAULT_PAGE_LIMIT, offset: offset ?? 0 };
2650
- const read = await client.events(asked);
2651
- const items = kind === undefined ? read.items : read.items.filter((one) => one.kind === kind);
2652
- const narrowedHere = items.length !== read.items.length;
2653
- const page = { items, more: read.more };
2654
- answer(
2655
- io,
2656
- session,
2657
- page,
2658
- () =>
2659
- `${formatPluginEvents(client.key, page, asked)}${
2660
- narrowedHere
2661
- ? `\nThis console is older than 0.5.1 and does not narrow events by kind: of the ${read.items.length} newest read, the ${kind} ones are shown. Read further back with --offset.`
2662
- : ""
2663
- }`,
2664
- );
2683
+ const page = await client.events(asked);
2684
+ answer(io, session, page, () => formatPluginEvents(client.key, page, asked));
2665
2685
  return EXIT.ok;
2666
2686
  }
2667
2687
 
@@ -2896,6 +2916,10 @@ async function pluginEnable(
2896
2916
  key: detail.boardDefaults.key,
2897
2917
  name: localized(detail.boardDefaults.name, readingLanguage(me)),
2898
2918
  description: localized(detail.boardDefaults.description, readingLanguage(me)),
2919
+ // The mark the plugin names for its project (ADR-0155); an icon of a pack this command
2920
+ // does not have is left to the console, which is whose pack it is.
2921
+ ...(detail.boardDefaults.color == null ? {} : { color: detail.boardDefaults.color }),
2922
+ ...(detail.boardDefaults.glyph == null ? {} : { glyph: detail.boardDefaults.glyph }),
2899
2923
  },
2900
2924
  };
2901
2925
  } else if (boardFlag !== undefined) {
@@ -3121,16 +3145,6 @@ const rules: Command = async (args, io) => {
3121
3145
  );
3122
3146
  return EXIT.ok;
3123
3147
  }
3124
- // A console of before 0.5.1 keeps what is written here as the organization's whole rules,
3125
- // in the place of its own (ADR-0120): what is added would be all that holds there. Its
3126
- // answer tells, since it says the workspace's rules whole and no parts, and it is asked
3127
- // before anything is written.
3128
- const held = await session.client.rules();
3129
- if (held.own === undefined) {
3130
- throw failed(
3131
- "This console is older than 0.5.1 and keeps the organization's rules whole: what is written here would replace the console's rules, not add to them. Update the console first.",
3132
- );
3133
- }
3134
3148
  const written = await session.client.writeRules({
3135
3149
  body: body ?? "",
3136
3150
  ...(baseVersion === undefined ? {} : { baseVersion }),
@@ -3455,23 +3469,212 @@ const task: Command = async (args, io) => {
3455
3469
  const session = await open(io, values);
3456
3470
  const project = await session.project();
3457
3471
  const found = await project.task(ref);
3458
- const [decisions, runs, comments] = await Promise.all([
3472
+ const [decisions, runs, comments, follow] = await Promise.all([
3459
3473
  project.decisions({ task: found.id }),
3460
3474
  // The runs are a line each, with their reports counted: the brief form, unless --json asks
3461
3475
  // for the console's own answer.
3462
3476
  session.json ? project.runs({ task: found.id }) : project.runBriefs({ task: found.id }),
3463
3477
  project.comments(found.id),
3478
+ // Whether the task tells the member anything (ADR-0157). A console of before has no such
3479
+ // route, and nothing is said of it then.
3480
+ project.taskFollow(found.id).then(
3481
+ (kept) => kept,
3482
+ (error: unknown) => {
3483
+ if (noSuchRoute(error)) {
3484
+ return null;
3485
+ }
3486
+ throw error;
3487
+ },
3488
+ ),
3464
3489
  ]);
3465
3490
  const page = await taskPage(session, found.number);
3466
3491
  answer(
3467
3492
  io,
3468
3493
  session,
3469
- { task: found, decisions: decisions.items, runs: runs.items, comments: comments.items },
3470
- () => formatTask(found, decisions.items, runs.items, comments.items, page),
3494
+ { task: found, decisions: decisions.items, runs: runs.items, comments: comments.items, follow },
3495
+ () => formatTask(found, decisions.items, runs.items, comments.items, page, follow),
3471
3496
  );
3472
3497
  return EXIT.ok;
3473
3498
  };
3474
3499
 
3500
+ /** Whether a console answered that it has nothing at a path: what one of before a route does. */
3501
+ const noSuchRoute = (error: unknown): boolean =>
3502
+ error instanceof ApiError && error.status === 404 && error.code === "not_found";
3503
+
3504
+ /**
3505
+ * What the console answers of the notifications (ADR-0157), where it has them: one of before
3506
+ * answers their paths as nothing, which is said as what it is, since "nothing at this path"
3507
+ * says nothing of why.
3508
+ */
3509
+ async function ofNotifications<T>(io: CliIo, asked: Promise<T>): Promise<T> {
3510
+ try {
3511
+ return await asked;
3512
+ } catch (error) {
3513
+ if (noSuchRoute(error)) {
3514
+ const version = io.consoleVersion?.();
3515
+ throw failed(
3516
+ `This console${version === undefined ? "" : `, ${version},`} has no notifications yet: it is older than the command.`,
3517
+ );
3518
+ }
3519
+ throw error;
3520
+ }
3521
+ }
3522
+
3523
+ const NOTIFICATIONS_USAGE =
3524
+ "console notifications [--unread] [--limit <n>] [--offset <n>] | notifications --read <id> [<id>...] | notifications --read-all";
3525
+
3526
+ // What the board told the member (ADR-0157), the newest first, and which of it they have read:
3527
+ // their own, a person's as an agent account's, across the projects, so that no project is named.
3528
+ const notifications: Command = async (args, io) => {
3529
+ const { values, positionals } = parse(args, {
3530
+ unread: { type: "boolean" },
3531
+ read: { type: "boolean" },
3532
+ "read-all": { type: "boolean" },
3533
+ ...PAGE_OPTIONS,
3534
+ });
3535
+ const some = on(values, "read");
3536
+ const all = on(values, "read-all");
3537
+ const unread = on(values, "unread");
3538
+ const limit = countOf(text(values, "limit"), "limit", { least: 1, most: MAX_NOTIFICATIONS_PAGE });
3539
+ const offset = countOf(text(values, "offset"), "offset", { least: 0 });
3540
+ if (some || all) {
3541
+ if (unread || limit !== undefined || offset !== undefined) {
3542
+ throw misuse(
3543
+ `--unread, --limit and --offset are a listing's, and go with neither --read nor --read-all: ${NOTIFICATIONS_USAGE}`,
3544
+ );
3545
+ }
3546
+ if (some === all || (all && positionals.length > 0)) {
3547
+ throw misuse(
3548
+ `Say one: --read <id> [<id>...] for the notifications named, or --read-all alone for every one: ${NOTIFICATIONS_USAGE}`,
3549
+ );
3550
+ }
3551
+ if (some && positionals.length === 0) {
3552
+ throw misuse(
3553
+ "Say which, by the ids the listing prints: console notifications --read <id> [<id>...]; or --read-all for every one",
3554
+ );
3555
+ }
3556
+ const session = await open(io, values);
3557
+ const marked = await ofNotifications(
3558
+ io,
3559
+ session.client.readNotifications(all ? { all: true } : { ids: [...new Set(positionals)] }),
3560
+ );
3561
+ answer(io, session, marked, () => `Marked ${marked.read} read; ${marked.unread} still unread.`);
3562
+ return EXIT.ok;
3563
+ }
3564
+ if (positionals.length > 0) {
3565
+ throw misuse(
3566
+ `A listing takes no word but its flags, and an id goes with --read: ${NOTIFICATIONS_USAGE}`,
3567
+ );
3568
+ }
3569
+ const asked = { unread, limit: limit ?? NOTIFICATIONS_PAGE, offset: offset ?? 0 };
3570
+ const session = await open(io, values);
3571
+ const found = await ofNotifications(io, session.client.notifications(asked));
3572
+ answer(io, session, found, () => formatNotifications(found, asked));
3573
+ return EXIT.ok;
3574
+ };
3575
+
3576
+ const NOTIFY_USAGE =
3577
+ "console notify [--on <kind>]... [--off <kind>]... [--project-off <key>]... [--project-on <key>]... [--own-agents on|off] | notify --reset";
3578
+
3579
+ // What the member is told of (ADR-0157): each kind on or off, the projects they are told
3580
+ // nothing of, and whether what an agent of their own did as them counts; read, or changed in
3581
+ // what the flags say, or put back to what a member who chose nothing has.
3582
+ const notify: Command = async (args, io) => {
3583
+ const { values } = parse(
3584
+ args,
3585
+ {
3586
+ on: { type: "string", multiple: true },
3587
+ off: { type: "string", multiple: true },
3588
+ "project-off": { type: "string", multiple: true },
3589
+ "project-on": { type: "string", multiple: true },
3590
+ "own-agents": { type: "string" },
3591
+ reset: { type: "boolean" },
3592
+ },
3593
+ false,
3594
+ );
3595
+ // A kind the vocabulary does not have is refused here, with the kinds there are, before the
3596
+ // console is asked anything: it would refuse the whole change for it.
3597
+ const kindOf = (value: string) => wordOf(value, NOTIFICATION_KINDS, "a kind of notification");
3598
+ const turnedOn = texts(values, "on").map(kindOf);
3599
+ const turnedOff = texts(values, "off").map(kindOf);
3600
+ const projectsOff = texts(values, "project-off");
3601
+ const projectsOn = texts(values, "project-on");
3602
+ const twice =
3603
+ turnedOn.find((kind) => turnedOff.includes(kind)) ??
3604
+ projectsOn.find((key) => projectsOff.includes(key));
3605
+ if (twice !== undefined) {
3606
+ throw misuse(`${twice} is said both on and off: say one. ${NOTIFY_USAGE}`);
3607
+ }
3608
+ const own = text(values, "own-agents");
3609
+ const ownAgents =
3610
+ own === undefined ? undefined : wordOf(own, ["on", "off"], "what --own-agents takes") === "on";
3611
+ const kinds = [
3612
+ ...turnedOn.map((kind) => [kind, true] as const),
3613
+ ...turnedOff.map((kind) => [kind, false] as const),
3614
+ ];
3615
+ const projects = projectsOff.length > 0 || projectsOn.length > 0;
3616
+ const changes = kinds.length > 0 || projects || ownAgents !== undefined;
3617
+ if (on(values, "reset") && changes) {
3618
+ throw misuse(
3619
+ `--reset stands alone: it puts everything back to what a member who chose nothing is told of. ${NOTIFY_USAGE}`,
3620
+ );
3621
+ }
3622
+ const session = await open(io, values);
3623
+ const { client } = session;
3624
+ // The settings as they are now, whatever was asked: read, changed or put back.
3625
+ const say = (settings: RestNotificationSettings): number => {
3626
+ answer(io, session, settings, () => formatNotificationSettings(settings));
3627
+ return EXIT.ok;
3628
+ };
3629
+ if (on(values, "reset")) {
3630
+ return say(await ofNotifications(io, client.updateNotificationSettings({ reset: true })));
3631
+ }
3632
+ if (!changes) {
3633
+ return say(await ofNotifications(io, client.notificationSettings()));
3634
+ }
3635
+ // The projects turned off are sent whole: those that were, read as they stand, less the ones
3636
+ // turned on again, and the ones turned off now.
3637
+ const off = projects
3638
+ ? [
3639
+ ...new Set([
3640
+ ...(await ofNotifications(io, client.notificationSettings())).projectsOff
3641
+ .map((project) => project.key)
3642
+ .filter((key) => !projectsOn.includes(key)),
3643
+ ...projectsOff,
3644
+ ]),
3645
+ ]
3646
+ : undefined;
3647
+ return say(
3648
+ await ofNotifications(
3649
+ io,
3650
+ client.updateNotificationSettings({
3651
+ ...(kinds.length === 0 ? {} : { kinds: Object.fromEntries(kinds) }),
3652
+ ...(off === undefined ? {} : { projectsOff: off }),
3653
+ ...(ownAgents === undefined ? {} : { ownAgents }),
3654
+ }),
3655
+ ),
3656
+ );
3657
+ };
3658
+
3659
+ // Whether one task tells a member anything (ADR-0157): `follow` turns its notifications on,
3660
+ // `mute` off. A task turned on that their settings would be silent of tells them of
3661
+ // everything on it; one turned to what their settings say already is told by their kinds.
3662
+ const following =
3663
+ (turned: boolean): Command =>
3664
+ async (args, io) => {
3665
+ const { values, positionals } = parse(args, {});
3666
+ const ref = theOne(
3667
+ positionals,
3668
+ `Say which task: console ${turned ? "follow" : "mute"} <number|id>`,
3669
+ );
3670
+ const session = await open(io, values);
3671
+ const project = await session.project();
3672
+ const found = await project.task(ref);
3673
+ const kept = await ofNotifications(io, project.followTask(found.id, turned));
3674
+ answer(io, session, kept, () => formatTaskFollow(found, kept));
3675
+ return EXIT.ok;
3676
+ };
3677
+
3475
3678
  /**
3476
3679
  * A word in the discussion on a task (ADR-0024): what is said, as given, from a file or from
3477
3680
  * standard input, with the files named by --attach put in it; one request, one comment.
@@ -3905,7 +4108,7 @@ const notInProject = (error: unknown): boolean =>
3905
4108
  * before; else wherever it is, addressed to the person, raised by them, or a plugin's addressed
3906
4109
  * to someone they manage, through the console's own route for one decision. A plugin's decision
3907
4110
  * waits in the plugin's board project, which a checkout bound to another project does not name,
3908
- * and which the person may not be in at all. A console from before that route answers as before.
4111
+ * and which the person may not be in at all.
3909
4112
  */
3910
4113
  async function reachDecision(
3911
4114
  session: Session,
@@ -4392,8 +4595,8 @@ const decisions: Command = async (args, io) => {
4392
4595
  /**
4393
4596
  * Says how a run ended, and where that left its task (ADR-0114). The console places the task,
4394
4597
  * and where is not the command's to know: a finished run leaves it at work where another run is
4395
- * open on it, and a run that failed or was given up does that too, and on a console of before
4396
- * 0.5.1 always, or where a person moved it meanwhile. So the task is read once the run is over, and its state said as it stands. On
4598
+ * open on it, and a run that failed or was given up does that too, or where a person moved it
4599
+ * meanwhile. So the task is read once the run is over, and its state said as it stands. On
4397
4600
  * `--json` the answer is the run as the console gave it, and nothing more is asked.
4398
4601
  */
4399
4602
  async function sayEnded(
@@ -4644,9 +4847,23 @@ function runnerStateOf(text: string | undefined): RunnerState | undefined {
4644
4847
  const delivered = "delivered" in json ? json.delivered : undefined;
4645
4848
  const conversation = "conversation" in json ? json.conversation : undefined;
4646
4849
  const driver = "driver" in json ? json.driver : undefined;
4850
+ const limited = "limited" in json ? json.limited : undefined;
4851
+ const kept: unknown = "kept" in json ? json.kept : undefined;
4647
4852
  if (typeof delivered !== "number" || !Number.isSafeInteger(delivered) || delivered < 0) {
4648
4853
  return undefined;
4649
4854
  }
4855
+ /**
4856
+ * A moment in milliseconds since the epoch, or nothing for anything else: a number past what
4857
+ * a date holds would fail the runner at every start, where it says the moment in words.
4858
+ */
4859
+ const momentOf = (value: unknown): number | undefined =>
4860
+ typeof value === "number" && Number.isSafeInteger(value) && value > 0 && value < 1e14
4861
+ ? value
4862
+ : undefined;
4863
+ const since =
4864
+ typeof limited === "object" && limited !== null && "since" in limited
4865
+ ? momentOf(limited.since)
4866
+ : undefined;
4650
4867
  return {
4651
4868
  delivered,
4652
4869
  conversation:
@@ -4656,6 +4873,23 @@ function runnerStateOf(text: string | undefined): RunnerState | undefined {
4656
4873
  // The driver the conversation was begun under, as a registry spells one.
4657
4874
  driver:
4658
4875
  typeof driver === "string" && /^[a-z][a-z0-9-]{0,39}$/.test(driver) ? driver : undefined,
4876
+ // The usage limit the agent is not back from (ADR-0150): since when, and until when where the product said.
4877
+ ...(since === undefined || typeof limited !== "object" || limited === null
4878
+ ? {}
4879
+ : {
4880
+ limited: {
4881
+ since,
4882
+ until: "until" in limited ? momentOf(limited.until) : undefined,
4883
+ },
4884
+ }),
4885
+ // The signals the record has as delivered that the agent never read: taken from the stream once more.
4886
+ ...(Array.isArray(kept)
4887
+ ? {
4888
+ kept: kept
4889
+ .filter((number): number is number => momentOf(number) !== undefined)
4890
+ .slice(0, 50),
4891
+ }
4892
+ : {}),
4659
4893
  };
4660
4894
  }
4661
4895
 
@@ -4800,8 +5034,10 @@ const runner: Command = async (args, io) => {
4800
5034
  command: read.config.product?.command,
4801
5035
  args: read.config.product?.args,
4802
5036
  version: io.version,
5037
+ platform: host.platform,
4803
5038
  }),
4804
5039
  config: read.config,
5040
+ account: person.id,
4805
5041
  reconfigured: async () => {
4806
5042
  const now = await readConfig();
4807
5043
  return !now.ok ? { problem: now.problem } : now.text === read.text ? "same" : "changed";
@@ -4820,6 +5056,10 @@ const runner: Command = async (args, io) => {
4820
5056
  now: io.now,
4821
5057
  random: host.random,
4822
5058
  time: (iso) => clock.format(new Date(iso)),
5059
+ // A moment that may be on another day, a stretch the runner did not run in or when a
5060
+ // usage limit resets, is said as the command prints any moment: with its day, in the
5061
+ // workspace's zone where the login kept one.
5062
+ moment,
4823
5063
  files: {
4824
5064
  write: (path, text) => host.writePrivate(workPath(path), text),
4825
5065
  remove: (path) => host.remove(workPath(path)),
@@ -5033,12 +5273,12 @@ const agentNew = async (args: readonly string[], io: CliIo): Promise<number> =>
5033
5273
  made.person.invited === true
5034
5274
  ? host === "gh"
5035
5275
  ? // A login at a git host goes to whoever registers it: what the first sign-in is held
5036
- // to is said (ADR-0126), and by a console older than the answer, the login alone.
5276
+ // to is said (ADR-0126).
5037
5277
  made.firstSignIn === "account"
5038
5278
  ? `It is a member now, and work can be assigned to it. It signs in as ${made.person.login}: confirmed at the git host, so that account alone is let in as it, whatever it is called by then.`
5039
5279
  : made.firstSignIn === "member"
5040
5280
  ? `It is a member now, and work can be assigned to it. It signs in as ${made.person.login}: not confirmed, since the organization at the git host has no member called so, or could not be asked. It is let in once it is a member there, and nobody else is under that login.`
5041
- : `It is a member now, and work can be assigned to it. It signs in as ${made.person.login}: ${made.firstSignIn === "login" ? "not confirmed, since this console reads no organization at the git host. That" : "that"} account has to be the organization's own at the git host already, since until its first sign-in binds it here the console lets in whoever holds that login.`
5281
+ : `It is a member now, and work can be assigned to it. It signs in as ${made.person.login}: not confirmed, since this console reads no organization at the git host. That account has to be the organization's own at the git host already, since until its first sign-in binds it here the console lets in whoever holds that login.`
5042
5282
  : `It is a member now, and work can be assigned to it. It signs in as ${made.person.login}: that account is made at the provider before its machine is set up, and its first sign-in with it binds it here.`
5043
5283
  : `${made.person.login} is an agent account from now on, with everything it did.`,
5044
5284
  ...(made.onboarding === null || made.onboarding === undefined
@@ -5297,22 +5537,9 @@ const ownWake = async (args: readonly string[], io: CliIo): Promise<number> => {
5297
5537
  );
5298
5538
  }
5299
5539
  const session = await open(io, values);
5300
- /** A console of before knows no such route: said as what it is. */
5301
- const asked = async <T>(ask: () => Promise<T>): Promise<T> => {
5302
- try {
5303
- return await ask();
5304
- } catch (error) {
5305
- if (error instanceof ApiError && error.status === 404 && error.code === "not_found") {
5306
- throw failed(
5307
- "This console does not take an account's own wake yet: it does from 0.5.2 on.",
5308
- );
5309
- }
5310
- throw error;
5311
- }
5312
- };
5313
5540
  if (on(values, "cancel")) {
5314
5541
  const named = key ?? OWN_WAKE_KEY;
5315
- await asked(() => session.client.cancelOwnWake(named));
5542
+ await session.client.cancelOwnWake(named);
5316
5543
  answer(io, session, { cancelled: named }, () => `The wake ${named} is taken away.`);
5317
5544
  return EXIT.ok;
5318
5545
  }
@@ -5323,13 +5550,11 @@ const ownWake = async (args: readonly string[], io: CliIo): Promise<number> => {
5323
5550
  me.workspace.timeZone ?? undefined,
5324
5551
  new Date(io.now()),
5325
5552
  );
5326
- const raised = await asked(() =>
5327
- session.client.raiseOwnWake({
5328
- ...(said.length === 0 ? {} : { text: said }),
5329
- ...(at === undefined ? {} : { at: at.toISOString() }),
5330
- ...(key === undefined ? {} : { key }),
5331
- }),
5332
- );
5553
+ const raised = await session.client.raiseOwnWake({
5554
+ ...(said.length === 0 ? {} : { text: said }),
5555
+ ...(at === undefined ? {} : { at: at.toISOString() }),
5556
+ ...(key === undefined ? {} : { key }),
5557
+ });
5333
5558
  answer(io, session, raised, () =>
5334
5559
  raised.kept === null
5335
5560
  ? `Raised, as signal #${raised.signal?.number ?? "?"} of your record: your runner takes it as it takes any wake.`
@@ -5338,6 +5563,45 @@ const ownWake = async (args: readonly string[], io: CliIo): Promise<number> => {
5338
5563
  return EXIT.ok;
5339
5564
  };
5340
5565
 
5566
+ const OWN_RESET_USAGE =
5567
+ 'Say why, which the new conversation reads first: console agent reset me "<why>" [--file <path>]';
5568
+
5569
+ // A new conversation an agent account begins for itself (ADR-0154), by its own command, where
5570
+ // its work has a break: its runner takes it when the turn it is asked in is over. The words
5571
+ // say why, on the account's record, and are what the new conversation reads first.
5572
+ const ownReset = async (args: readonly string[], io: CliIo): Promise<number> => {
5573
+ const { values, positionals } = parse(args, { file: { type: "string" } });
5574
+ const [, words, ...rest] = positionals;
5575
+ if (rest.length > 0) {
5576
+ throw misuse(OWN_RESET_USAGE);
5577
+ }
5578
+ const said = ((await bodyOf(io, values, words)) ?? "").trim();
5579
+ if (said.length === 0) {
5580
+ throw misuse(OWN_RESET_USAGE);
5581
+ }
5582
+ const session = await open(io, values);
5583
+ let sent: RestSignal;
5584
+ try {
5585
+ sent = await session.client.sendOwnReset({ text: said });
5586
+ } catch (error) {
5587
+ // A console of before knows no such route: said as what it is.
5588
+ if (error instanceof ApiError && error.status === 404 && error.code === "not_found") {
5589
+ throw failed(
5590
+ "This console does not take an account's own reset yet: it is older than the command.",
5591
+ );
5592
+ }
5593
+ throw error;
5594
+ }
5595
+ answer(
5596
+ io,
5597
+ session,
5598
+ sent,
5599
+ () =>
5600
+ `Asked, as signal #${sent.number} of your record: when this turn is over, your session ends and a new conversation begins with these words. Nothing else of this one goes with it: put what must be kept on the board, in your desk or in your product's memory before the turn ends.`,
5601
+ );
5602
+ return EXIT.ok;
5603
+ };
5604
+
5341
5605
  /** The kinds of signal a supervisor sends with words: which need them, and which take them. */
5342
5606
  const WORDED_SIGNALS: Readonly<Record<string, { readonly needs: boolean }>> = {
5343
5607
  tell: { needs: true },
@@ -5370,6 +5634,18 @@ const agentSignal = async (
5370
5634
  return ownWake(args, io);
5371
5635
  }
5372
5636
  }
5637
+ // And so is its own reset: console agent reset me.
5638
+ if (kind === "reset") {
5639
+ let whom: string | undefined;
5640
+ try {
5641
+ whom = parse(args, { file: { type: "string" } }).positionals[0];
5642
+ } catch {
5643
+ whom = undefined;
5644
+ }
5645
+ if (whom === "me") {
5646
+ return ownReset(args, io);
5647
+ }
5648
+ }
5373
5649
  const { values, positionals } = parse(args, { file: { type: "string" } });
5374
5650
  const [given, words, ...rest] = positionals;
5375
5651
  const needs = WORDED_SIGNALS[kind]?.needs === true;
@@ -5452,7 +5728,7 @@ const agentSignals = async (args: readonly string[], io: CliIo): Promise<number>
5452
5728
  ...(before === undefined ? {} : { before: Number(before) }),
5453
5729
  });
5454
5730
  // What the account keeps for later (ADR-0145) stands over the record's first page: it is no
5455
- // signal yet. A console of before keeps none, and says nothing of it.
5731
+ // signal yet. Where it cannot be read, the record is printed without it.
5456
5732
  const kept =
5457
5733
  before === undefined
5458
5734
  ? await session.client
@@ -5476,14 +5752,107 @@ const agentSignals = async (args: readonly string[], io: CliIo): Promise<number>
5476
5752
  return EXIT.ok;
5477
5753
  };
5478
5754
 
5755
+ const AGENT_MESSAGES_USAGE =
5756
+ "Say where, as a wake's header names it after messenger: console agent messages <source>:<conversation>[:<thread>] [--limit <n>] [--after <moment>]";
5757
+
5758
+ // What was said where a wake from the messenger was raised (ADR-0163): the latest messages of the
5759
+ // conversation, or of the thread, that the wake's key names, read by the wake source the key
5760
+ // begins with, with a secret of the account's own store, which nobody else reads. For the
5761
+ // account itself, where a wake carried less than the agent needs, and before it answers where
5762
+ // others may have answered meanwhile. What a source's line says is printed as it is, and what
5763
+ // someone wrote behind `>`, a line each, so that no word of a message reads as a line.
5764
+ const agentMessages = async (args: readonly string[], io: CliIo): Promise<number> => {
5765
+ const { values, positionals } = parse(args, {
5766
+ limit: { type: "string" },
5767
+ after: { type: "string" },
5768
+ });
5769
+ const key = theOne(positionals, AGENT_MESSAGES_USAGE);
5770
+ const named = /^([a-z][a-z0-9-]{0,39}):(.+)$/.exec(key);
5771
+ const source =
5772
+ named?.[1] === undefined ? undefined : ownRunnerModules({ user: "" }).wakeSources.get(named[1]);
5773
+ if (named?.[2] === undefined || source?.read === undefined) {
5774
+ throw misuse(
5775
+ `No wake source of this command reads ${key.includes(":") ? `what ${key.slice(0, key.indexOf(":"))} names` : "that"}. ${AGENT_MESSAGES_USAGE}`,
5776
+ );
5777
+ }
5778
+ const limit = text(values, "limit");
5779
+ if (limit !== undefined && !(Number.isSafeInteger(Number(limit)) && Number(limit) >= 1)) {
5780
+ throw misuse(`Not a number of messages: ${limit}`);
5781
+ }
5782
+ const after = text(values, "after");
5783
+ const session = await open(io, values);
5784
+ const read = await source.read(
5785
+ {
5786
+ // A secret the account does not keep is none, and the source says what it lacks.
5787
+ secret: async (name) => {
5788
+ try {
5789
+ return (await session.client.secret(name)).value;
5790
+ } catch (error) {
5791
+ if (error instanceof ApiError && error.code === "secret.not_found") {
5792
+ return undefined;
5793
+ }
5794
+ throw error;
5795
+ }
5796
+ },
5797
+ fetch: (url, init) => io.fetch(url, { ...init, headers: { ...init.headers } }),
5798
+ // Who wrote each message, as the console says it (ADR-0164): where it says nothing, a
5799
+ // console older than the question say, the lines are as the messenger alone has them.
5800
+ writers: async (accounts, signal) =>
5801
+ (
5802
+ await session.client.writers(
5803
+ { messenger: named[1] ?? "", accounts: [...accounts] },
5804
+ signal,
5805
+ )
5806
+ ).items,
5807
+ },
5808
+ named[2],
5809
+ {
5810
+ ...(limit === undefined ? {} : { limit: Number(limit) }),
5811
+ ...(after === undefined ? {} : { after }),
5812
+ now: io.now(),
5813
+ signal: AbortSignal.timeout(30_000),
5814
+ },
5815
+ );
5816
+ if (!read.ok) {
5817
+ throw failed(
5818
+ read.why === "no_token"
5819
+ ? `Nothing was read: this account keeps no secret the ${named[1]} wake source reads a conversation with (no_token). The skill running-an-agent says which to keep.`
5820
+ : read.why === "not_a_conversation"
5821
+ ? `Nothing was read: ${named[2]} names no conversation as a wake of the ${named[1]} wake source does (not_a_conversation). ${AGENT_MESSAGES_USAGE}`
5822
+ : read.why === "not_a_moment"
5823
+ ? `Nothing was read: ${after} is the moment of no message, as a wake of the ${named[1]} wake source says one (not_a_moment).`
5824
+ : `Nothing was read: the messenger did not answer the ${named[1]} wake source with the conversation (${read.why}).`,
5825
+ );
5826
+ }
5827
+ answer(io, session, { key, parts: read.parts }, () =>
5828
+ read.parts
5829
+ .map((part) => ("says" in part ? part.says : quotedLines(part.words).join("\n")))
5830
+ .join("\n"),
5831
+ );
5832
+ return EXIT.ok;
5833
+ };
5834
+
5479
5835
  // The invitation that leads a machine to an agent account (ADR-0088): made, made again in place
5480
5836
  // of the one before, or taken away, by a supervisor. Its code is no credential: it says which
5481
5837
  // account a setup is for and opens the guide, and the account is entered through its own sign-in.
5838
+ // What the command prints under an agent is in that agent's record from then on, and an agent
5839
+ // account that supervises another has nobody reading along: with --out the line goes to a file,
5840
+ // which a decision's body or a comment's attachment carries to a person, and the output names no
5841
+ // code. Never the words of a comment (`comment --file`): the command prints those back.
5482
5842
  const agentInvite = async (args: readonly string[], io: CliIo): Promise<number> => {
5483
- const { values, positionals } = parse(args, { revoke: { type: "boolean" } });
5843
+ const { values, positionals } = parse(args, {
5844
+ revoke: { type: "boolean" },
5845
+ out: { type: "string" },
5846
+ });
5484
5847
  const handle = handleOf(
5485
- theOne(positionals, "Say whose: console agent invite <handle> [--revoke]"),
5848
+ theOne(positionals, "Say whose: console agent invite <handle> [--out <path>] | --revoke"),
5486
5849
  );
5850
+ const out = text(values, "out");
5851
+ if (on(values, "revoke") && out !== undefined) {
5852
+ throw misuse(
5853
+ "Say one of --out <path>, which writes the line of a new invitation to a file, and --revoke, which takes the invitation away.",
5854
+ );
5855
+ }
5487
5856
  const session = await open(io, values);
5488
5857
  if (on(values, "revoke")) {
5489
5858
  await session.client.revokeAgentInvitation(handle);
@@ -5495,13 +5864,65 @@ const agentInvite = async (args: readonly string[], io: CliIo): Promise<number>
5495
5864
  );
5496
5865
  return EXIT.ok;
5497
5866
  }
5867
+ // The path is tried before the invitation is made: a new invitation takes the place of the
5868
+ // one before and its code comes once, so one made for a path that cannot be written would
5869
+ // leave the account with an invitation nobody holds. The file is the account's alone to read.
5870
+ // What is at the path stays until the new line is there to take its place: the line of the
5871
+ // invitation before, say, which still stands where this one cannot be made.
5872
+ const name = `${handle}-invitation.md`;
5873
+ let file: string | undefined;
5874
+ if (out !== undefined) {
5875
+ try {
5876
+ file = await io.writeBytes(out, new Uint8Array(), name, { private: true, after: true });
5877
+ } catch {
5878
+ throw failed(
5879
+ `Nothing can be written at ${out}, so no invitation was made and the one before stands. Say a path that can be written.`,
5880
+ );
5881
+ }
5882
+ }
5498
5883
  const made = await session.client.inviteAgent(handle);
5499
- answer(io, session, made, () =>
5884
+ const until = `good until ${moment(made.invitation.expiresAt)} or until its command has signed in`;
5885
+ const guide = `${session.url}/setup/${made.code}`;
5886
+ if (file === undefined) {
5887
+ answer(io, session, made, () =>
5888
+ [
5889
+ `An invitation for @${handle}, ${until}. The code is shown this once. It is no credential: it says which account a setup is for, and gives nobody the account.`,
5890
+ "On the agent's machine, in its own OS account, say to its product:",
5891
+ ` ${setupSentenceOf(made.command)}`,
5892
+ `or run the command there yourself. A person reads the same guide at ${guide}`,
5893
+ ].join("\n"),
5894
+ );
5895
+ return EXIT.ok;
5896
+ }
5897
+ // Markdown, since the file is read where it is handed on: a decision's body, a comment, a
5898
+ // messenger. The line stands in a block of its own, to be copied as written.
5899
+ const words = [
5900
+ `An invitation for @${handle}, ${until}. Its code is no credential: it says which account a setup is for, and gives nobody the account.`,
5901
+ "",
5902
+ "On the agent's machine, in its own OS account, say to its product:",
5903
+ "",
5904
+ "```",
5905
+ setupSentenceOf(made.command),
5906
+ "```",
5907
+ "",
5908
+ `or run the command there yourself. A person reads the same guide at ${guide}`,
5909
+ "",
5910
+ ].join("\n");
5911
+ let written: string;
5912
+ try {
5913
+ written = await io.writeBytes(file, new TextEncoder().encode(words), name, { private: true });
5914
+ } catch {
5915
+ // The code came this once and went nowhere: the invitation stands and nobody holds its line.
5916
+ throw failed(
5917
+ `The invitation of @${handle} is made, and its line could not be written at ${file}, so nobody has it. Make the invitation again with a path that can be written: it takes the place of this one.`,
5918
+ );
5919
+ }
5920
+ // The path as both shells take it whole; where it has no such spelling, it is named in words.
5921
+ const path = commandWord(written) ?? "<the file's path, quoted for your shell>";
5922
+ answer(io, session, { handle, invitation: made.invitation, file: written }, () =>
5500
5923
  [
5501
- `An invitation for @${handle}, good until ${moment(made.invitation.expiresAt)} or until its command has signed in. The code is shown this once. It is no credential: it says which account a setup is for, and gives nobody the account.`,
5502
- "On the agent's machine, in its own OS account, say to its product:",
5503
- ` ${setupSentenceOf(made.command)}`,
5504
- `or run the command there yourself. A person reads the same guide at ${session.url}/setup/${made.code}`,
5924
+ `An invitation for @${handle}, ${until}. Its line is written to ${written} and is not shown here: it carries the code, which is shown nowhere else.`,
5925
+ `Hand the file on unread to whoever prepares the machine: as the body of a decision for them (console ask "<question>" --option "<one>" --option "<another>" --file ${path} --to <login>), attached to a comment on a task (console comment <number> "<a line for them>" --attach ${path}), or as a file at the messenger. Never as a comment's own words (--file there): the command prints them back. A decision read with the command afterwards shows the line. Remove the file once it is handed on: one left in a desk outside work/ is committed and pushed with it.`,
5505
5926
  ].join("\n"),
5506
5927
  );
5507
5928
  return EXIT.ok;
@@ -5527,11 +5948,32 @@ const SETUP_FLAGS: OptionSpec = {
5527
5948
  "new-desk": { type: "boolean" },
5528
5949
  "no-service": { type: "boolean" },
5529
5950
  driver: { type: "string" },
5951
+ browser: { type: "string" },
5530
5952
  "no-browser": { type: "boolean" },
5531
5953
  };
5532
5954
 
5533
5955
  type Me = Awaited<ReturnType<ConsoleClient["me"]>>;
5534
5956
 
5957
+ /**
5958
+ * The browsers a setup looks for where it is asked for one: the one with no window and the
5959
+ * product's own. A window for the first is a name the agent writes itself when someone is to
5960
+ * see its browser, and no setup's.
5961
+ */
5962
+ const SETUP_BROWSERS = ["headless", "chrome"] as const satisfies readonly RunnerBrowser[];
5963
+
5964
+ /** What a setup says it found of the agent's browser, by the name a new desk gives it; nothing of none. */
5965
+ const BROWSER_FOUND: Readonly<Record<SetupBrowser, string>> = {
5966
+ headless: `, Google Chrome and ${HEADLESS_TOOL.command}, which drives it with no window`,
5967
+ chrome: ", Google Chrome",
5968
+ none: "",
5969
+ };
5970
+
5971
+ /** A runner's config with no browser named, for a desk whose product is started with none. */
5972
+ function withoutBrowser<T extends { readonly browser?: unknown }>(config: T): Omit<T, "browser"> {
5973
+ const { browser: _none, ...rest } = config;
5974
+ return rest;
5975
+ }
5976
+
5535
5977
  /** The end of what a program said, for a refusal to carry: one line, bounded. */
5536
5978
  function lastWords(ran: Ran): string {
5537
5979
  const line = ran.err.trim().split(/\r?\n/).at(-1) ?? "";
@@ -5673,8 +6115,10 @@ async function settleDesk(
5673
6115
  look === undefined
5674
6116
  ? undefined
5675
6117
  : {
5676
- ...DEFAULT_RUNNER_CONFIG,
6118
+ ...withoutBrowser(DEFAULT_RUNNER_CONFIG),
5677
6119
  ...(look.driver === undefined ? {} : { driver: look.driver }),
6120
+ // A browser is named where the product is started with one: under a driver that
6121
+ // takes nothing of the name, a desk that named one would read as having it.
5678
6122
  ...(look.browser === undefined ? {} : { browser: look.browser }),
5679
6123
  },
5680
6124
  })) {
@@ -5968,6 +6412,7 @@ async function handOver(
5968
6412
  }
5969
6413
  const plate = await client.work().catch(() => undefined);
5970
6414
  const first = plate?.tasks.find((one) => one.task.title === onboardingTitle(handle));
6415
+ const inTheWay = await standsInTheWay(machine);
5971
6416
  const lines = [
5972
6417
  began
5973
6418
  ? `@${handle}'s session has begun: the agent is at work.`
@@ -5981,6 +6426,12 @@ async function handOver(
5981
6426
  `That is the machine prepared: stop here. What comes next, its sign-ins, its tokens, its desk's repository, its profile and its messenger, is @${handle}'s own, done in its own session: do none of it for it.`,
5982
6427
  `What you change on this machine afterwards, say to it: console agent wake me "<what changed>"`,
5983
6428
  awakeWords(machine.platform, await heldAwake(machine), log),
6429
+ ...(inTheWay.length === 0
6430
+ ? []
6431
+ : [
6432
+ `What on this machine still leaves @${handle} unheard with nobody there, for whoever keeps the machine to change or to accept:`,
6433
+ ...inTheWay.map((line) => `- ${line}`),
6434
+ ]),
5984
6435
  ];
5985
6436
  io.stdout(`${lines.join("\n")}\n`);
5986
6437
  }
@@ -6088,14 +6539,28 @@ const agentSetup = async (args: readonly string[], io: CliIo): Promise<number> =
6088
6539
  `Not a driver this command has: ${driver}. It has: ${ownRunnerModules({ user: machine.user }).drivers.names().join(", ")}.`,
6089
6540
  );
6090
6541
  }
6091
- const look = await lookAtMachine(machine, { driver, browser: !on(values, "no-browser") });
6542
+ // The agent's browser (ADR-0151): a Chrome with no window where nobody says another.
6543
+ const named = text(values, "browser");
6544
+ const browser = SETUP_BROWSERS.find((one) => one === named);
6545
+ if (named !== undefined && browser === undefined) {
6546
+ throw misuse(
6547
+ `Not a browser this command sets up: ${named}. It has: ${SETUP_BROWSERS.join(", ")}; --no-browser is for none.`,
6548
+ );
6549
+ }
6550
+ if (named !== undefined && on(values, "no-browser")) {
6551
+ throw misuse("Say one of --browser <name> and --no-browser.");
6552
+ }
6553
+ const look = await lookAtMachine(machine, {
6554
+ driver,
6555
+ browser: on(values, "no-browser") ? "none" : (browser ?? "headless"),
6556
+ });
6092
6557
  if (look.missing.length > 0) {
6093
6558
  throw failed(
6094
6559
  `This machine lacks what the setup needs. Install each yourself, without asking, and run the line again:\n${look.missing.map((line) => `- ${line}`).join("\n")}`,
6095
6560
  );
6096
6561
  }
6097
6562
  io.stdout(
6098
- `The machine has what the setup needs: git${look.product === undefined ? "" : `, ${look.product}`}${look.browser === undefined ? "" : ", Google Chrome"}.\n${look.notes.map((line) => `${line}\n`).join("")}`,
6563
+ `The machine has what the setup needs: git${look.product === undefined ? "" : `, ${look.product}`}${look.browser === undefined ? "" : BROWSER_FOUND[look.browser]}.\n${look.notes.map((line) => `${line}\n`).join("")}`,
6099
6564
  );
6100
6565
  const client = await signInAsAccount(io, machine, url, setup);
6101
6566
  const me = await client.me();
@@ -6349,6 +6814,9 @@ const agent: Command = async (args, io) => {
6349
6814
  if (args[0] === "signals") {
6350
6815
  return agentSignals(args.slice(1), io);
6351
6816
  }
6817
+ if (args[0] === "messages") {
6818
+ return agentMessages(args.slice(1), io);
6819
+ }
6352
6820
  if (args[0] === "invite") {
6353
6821
  return agentInvite(args.slice(1), io);
6354
6822
  }
@@ -6406,13 +6874,13 @@ const agent: Command = async (args, io) => {
6406
6874
  ...(dayStart === undefined ? {} : { dayStart }),
6407
6875
  ...(dayEnd === undefined ? {} : { dayEnd }),
6408
6876
  });
6409
- answer(io, session, kept, () => formatAgent(kept));
6877
+ answer(io, session, kept, () => formatAgent(kept, io.now()));
6410
6878
  return EXIT.ok;
6411
6879
  }
6412
6880
  const found = await session.client.agent(handle);
6413
6881
  const file = text(values, "avatar");
6414
6882
  if (file === undefined) {
6415
- answer(io, session, found, () => formatAgent(found));
6883
+ answer(io, session, found, () => formatAgent(found, io.now()));
6416
6884
  return EXIT.ok;
6417
6885
  }
6418
6886
  const parts = found.person.avatarParts;
@@ -7159,6 +7627,10 @@ const COMMANDS: Readonly<Record<string, Command>> = {
7159
7627
  projects,
7160
7628
  use,
7161
7629
  work,
7630
+ notifications,
7631
+ notify,
7632
+ follow: following(true),
7633
+ mute: following(false),
7162
7634
  tasks,
7163
7635
  task,
7164
7636
  goals,