@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/dist/cli/cli.js CHANGED
@@ -2,7 +2,7 @@ import { basename, extname, isAbsolute } from "node:path";
2
2
  import { parseArgs } from "node:util";
3
3
  import { deflateSync } from "node:zlib";
4
4
  import { PackError, ReadMisuse, readNumber, readPack, wroteLine, } from "@skillcdn/cli";
5
- import { BROWSE_MAX_LIMIT, FIND_MAX_LIMIT, READ_FILE_MAX_LIMIT, } from "@skillcdn/core";
5
+ import { BROWSE_MAX_LIMIT, FIND_MAX_LIMIT, READ_FILE_MAX_LIMIT, utf8Length, } from "@skillcdn/core";
6
6
  import { avatarScanlines, MAX_AVATAR_PIXELS, pngFile } from "../avatar.js";
7
7
  import { ApiError, createClient, } from "../client.js";
8
8
  import { CLIENT_RANGE_HEADER, CONSOLE_AT_LEAST, consoleRange, formatRange, judgeClient, judgeConsole, parseVersion, VERSION_HEADER, formatVersion as versionText, } from "../compat.js";
@@ -10,14 +10,17 @@ import { normalizeConnectCode } from "../connect.js";
10
10
  import { addDays, dayOf as dayOfDate, firstDayOfWeek, isDay, weekOf } from "../dates.js";
11
11
  import { ICON_NAMES, isIconName } from "../icons/index.js";
12
12
  import { DEFAULT_PAGE_LIMIT, EVENTS_PAGE_LIMIT, LIST_LIMIT, MAX_DECIDERS, MAX_OPTIONS, MAX_OWN_WAKE_DAYS, MAX_RUNNER_LINE_LENGTH, MAX_SIGNALS_PAGE_LIMIT, MIN_OPTIONS, OWN_WAKE_KEY, } from "../limits.js";
13
+ import { MAX_NOTIFICATIONS_PAGE, NOTIFICATION_KINDS, NOTIFICATIONS_PAGE, } from "../notifications.js";
13
14
  import { onboardingTitle } from "../onboarding.js";
14
15
  import { capabilityWords } from "../plugin/capabilities.js";
15
16
  import { PLUGIN_LIST_LIMIT } from "../plugin/limits.js";
16
17
  import { checkRecords, RECORDS_DIR, RECORDS_INDEX_FILE } from "../records.js";
17
18
  import { agentHref, decisionHref, docHref, myDecisionHref, taskHref } from "../router.js";
18
19
  import { fillRules, RULES_PATH, RULES_TITLE } from "../rules.js";
20
+ import { HEADLESS_TOOL } from "../runner/browser.js";
19
21
  import { DEFAULT_RUNNER_CONFIG, parseRunnerConfig } from "../runner/config.js";
20
22
  import { DESK_FOLDER, deskFiles, deskServicesOf, deskWebTitleOf, personDeskFiles, } from "../runner/desk.js";
23
+ import { quotedLines } from "../runner/message.js";
21
24
  import { ownRunnerModules } from "../runner/modules.js";
22
25
  import { createRunner, GIT_TOKEN_SECRET, } from "../runner/runner.js";
23
26
  import { hostOfLogin, } from "../schemas.js";
@@ -28,11 +31,11 @@ import { loadWebRoot, WebRootError } from "../web.js";
28
31
  import { commandLine, commandWord, NO_LINE_TO_RUN } from "./command-words.js";
29
32
  import { CredentialsError, EMPTY_CREDENTIALS, fitsFile, keepsNothing, lasts, loginsAt, pendingAt, resolveLogin, withLogin, withoutLogin, withoutPending, withPending, } from "./credentials.js";
30
33
  import { DIRECTORY_FILE, THE_SENTENCE, } from "./directory.js";
31
- import { calledOf, deciderLogins, formatAgent, formatAgentLine, formatAnswer, formatCategoryLine, formatComment, formatDecision, formatDecisionLine, formatDocument, formatDocuments, formatGoal, formatGoalLine, formatInvocation, formatListingLine, formatMemberLine, formatMore, formatOptions, formatOwnWakeLine, formatPersonLine, formatPersonWork, formatPlugin, formatPluginAsks, formatPluginEvents, formatPluginGrantLine, formatPluginHelp, formatPluginRecord, formatPluginRecords, formatPluginRecordVersions, formatPluginSettingLine, formatPlugins, formatProject, formatProjectLine, formatRules, formatRulesChanged, formatRulesLeftOut, formatRun, formatRunLine, formatSecretLine, formatSignalLine, formatTask, formatTaskLine, formatTeamLine, formatVersion, formatVersionLine, formatWork, formatWorkspace, localized, moment, pageLine, rulesMark, setMomentZone, } from "./format.js";
34
+ import { calledOf, deciderLogins, formatAgent, formatAgentLine, formatAnswer, formatCategoryLine, formatComment, formatDecision, formatDecisionLine, formatDocument, formatDocuments, formatGoal, formatGoalLine, formatInvocation, formatListingLine, formatMemberLine, formatMore, formatNotificationSettings, formatNotifications, formatOptions, formatOwnWakeLine, formatPersonLine, formatPersonWork, formatPlugin, formatPluginAsks, formatPluginEvents, formatPluginGrantLine, formatPluginHelp, formatPluginRecord, formatPluginRecords, formatPluginRecordVersions, formatPluginSettingLine, formatPlugins, formatProject, formatProjectLine, formatRules, formatRulesChanged, formatRulesLeftOut, formatRun, formatRunLine, formatSecretLine, formatSignalLine, formatTask, formatTaskFollow, formatTaskLine, formatTeamLine, formatVersion, formatVersionLine, formatWork, formatWorkspace, localized, moment, pageLine, rulesMark, setMomentZone, } from "./format.js";
32
35
  import { COMMAND_HELP, helpFor, ownSkillPath, usage } from "./help.js";
33
36
  import { describeInstall, updateCommandFor } from "./install.js";
34
- import { awakeWords, heldAwake, lookAtMachine } from "./machine-check.js";
35
- import { consolePack, formatSkills, holdsNothing, ORGANIZATION_PACK_LINE, PackRefusal, packWords, refusalWords, skillPathIn, } from "./pack.js";
37
+ import { awakeWords, heldAwake, lookAtMachine, standsInTheWay, } from "./machine-check.js";
38
+ import { consolePack, formatSkills, holdsNothing, ORGANIZATION_PACK_LINE, PackRefusal, packWords, refusalWords, skillPathIn, skillsAround, } from "./pack.js";
36
39
  import { workPath } from "./runner-host.js";
37
40
  import { secretNotes } from "./secret-notes.js";
38
41
  import { createServeHandler, DEFAULT_SERVE_PORT, loadRecordsRoot, RecordsRootError, } from "./serve.js";
@@ -1276,7 +1279,9 @@ function whereGiven(values) {
1276
1279
  * with. What the pack refused ends the command as refused (ADR-0118): of one read, in the
1277
1280
  * pack's own code and words, as that command prints them; of the pack as a whole, in the
1278
1281
  * console's. A read not asked right is a command not understood. With `data`, nothing is
1279
- * printed for a refusal even with `--json`: what a program takes is never one.
1282
+ * printed for a refusal even with `--json`: what a program takes is never one. `beside` is the
1283
+ * lines the command prints of its own around the text, which the read keeps room for, so that
1284
+ * the whole output is one a host shows whole.
1280
1285
  */
1281
1286
  async function readThrough(io, session, owner, pack, read, options) {
1282
1287
  try {
@@ -1284,6 +1289,7 @@ async function readThrough(io, session, owner, pack, read, options) {
1284
1289
  words: options.words,
1285
1290
  json: session.json,
1286
1291
  nextPart: options.nextPart,
1292
+ room: roomFor(owner, options.beside ?? []),
1287
1293
  });
1288
1294
  }
1289
1295
  catch (error) {
@@ -1303,6 +1309,15 @@ async function readThrough(io, session, owner, pack, read, options) {
1303
1309
  : refusedRead(io, session, owner, refusal.answer, refusal.words);
1304
1310
  }
1305
1311
  }
1312
+ /**
1313
+ * The bytes the command prints beside what a read of the pack prints (ADR-0124): each line of
1314
+ * its own with the break that sets it apart, and the line that says the pack is the
1315
+ * organization's where it is.
1316
+ */
1317
+ function roomFor(owner, beside) {
1318
+ const lines = [owner === "organization" ? ORGANIZATION_PACK_LINE : undefined, ...beside];
1319
+ return lines.reduce((bytes, line) => (line === undefined ? bytes : bytes + utf8Length(line) + 1), 0);
1320
+ }
1306
1321
  /**
1307
1322
  * What `--json` prints for a read: the console's answer, with the pack's own in it as the
1308
1323
  * skillcdn command's `--json` prints it, the pages of a skill or of a read of data joined.
@@ -1410,8 +1425,9 @@ async function readSkills(io, session, reader, values, positionals, extras) {
1410
1425
  }
1411
1426
  const named = given ?? within;
1412
1427
  const folder = named === undefined || named === "/" || named === "." ? undefined : named;
1413
- if (words === undefined && given === undefined && (limit !== undefined || cursor !== undefined)) {
1414
- throw misuse(`--limit and --cursor go with a folder or with --search: ${extras.command} <folder> [--limit <n>] [--cursor <cursor>]`);
1428
+ // The listing is as long as one read prints, and goes on from the cursor its page ended with.
1429
+ if (words === undefined && given === undefined && limit !== undefined) {
1430
+ throw misuse(`--limit goes with a folder or with --search: ${extras.command} <folder> [--limit <n>] [--cursor <cursor>]`);
1415
1431
  }
1416
1432
  // A page of what words find, or of what a folder holds: the bounds of each, as the pack has them.
1417
1433
  checkedNumber(limit, "limit", words === undefined ? BROWSE_MAX_LIMIT : FIND_MAX_LIMIT);
@@ -1443,18 +1459,49 @@ async function readSkills(io, session, reader, values, positionals, extras) {
1443
1459
  .join("\n"));
1444
1460
  }
1445
1461
  if (words === undefined && given === undefined) {
1446
- // --json is the console's listing as it answered it; the words are the pack's own, read once more from that answer.
1447
- const told = session.json
1448
- ? undefined
1449
- : await readThrough(io, session, owner, pack, { read: "skills" }, { words: toolWords });
1450
- say(listing, () => [formatSkills(listing, told?.text, extras.own, owner, toolWords), loading, extras.afterwards]
1451
- .filter((part) => part !== undefined)
1452
- .join("\n"));
1462
+ // --json is the console's listing as it answered it, whole; the words are the pack's own,
1463
+ // read once more from that answer, a listing longer than one read prints in pages.
1464
+ if (session.json) {
1465
+ say(listing, () => "");
1466
+ return EXIT.ok;
1467
+ }
1468
+ // The console's own lines stand around the first page, and the read keeps room for them
1469
+ // and for the empty lines that set them apart.
1470
+ const around = skillsAround(listing, extras.own, toolWords);
1471
+ const own = [
1472
+ ...around.host,
1473
+ ...around.own,
1474
+ loading,
1475
+ ...(extras.afterwards === undefined ? [] : [extras.afterwards]),
1476
+ ];
1477
+ const told = await readThrough(io, session, owner, pack, { read: "skills", cursor }, {
1478
+ words: toolWords,
1479
+ beside: cursor === undefined ? [around.head, ...own, "", "", ""] : [],
1480
+ nextPart: (next) => commandLine(extras.command, ["--cursor", next, ...(extras.again ?? [])]) ??
1481
+ `${extras.command} with --cursor ${commandWord(next) ?? JSON.stringify(next)}, each word quoted for your shell. ${NO_LINE_TO_RUN}`,
1482
+ });
1483
+ say(listing, () => {
1484
+ // A page read from a cursor is the pack's own words alone: what stands around the
1485
+ // listing was said with its first page.
1486
+ if (cursor !== undefined) {
1487
+ return told.text;
1488
+ }
1489
+ // Where the listing goes on, the command that lists the rest is the last line printed,
1490
+ // as a part of a skill ends with the command that reads the next: the console's own
1491
+ // lines stand above the listing then, and after it where it is whole.
1492
+ return told.next === undefined
1493
+ ? [
1494
+ formatSkills(listing, told.text, extras.own, owner, toolWords),
1495
+ loading,
1496
+ ...(extras.afterwards === undefined ? [] : [extras.afterwards]),
1497
+ ].join("\n")
1498
+ : [around.head, ...own, "", told.text].join("\n");
1499
+ });
1453
1500
  return EXIT.ok;
1454
1501
  }
1455
1502
  if (words !== undefined) {
1456
1503
  // One page of what the words find; more is said, and asked for with --cursor.
1457
- const found = await readThrough(io, session, owner, pack, { read: "find", words, path: folder, cursor, limit }, { words: toolWords });
1504
+ const found = await readThrough(io, session, owner, pack, { read: "find", words, path: folder, cursor, limit }, { words: toolWords, beside: [loading] });
1458
1505
  say(jsonOfRead(session, pack, found), () => `${found.text}\n${loading}`);
1459
1506
  return EXIT.ok;
1460
1507
  }
@@ -1474,22 +1521,6 @@ async function packNamed(session) {
1474
1521
  ? { reader: session.client.organizationPack(), owner: "organization" }
1475
1522
  : { reader: await session.project(), owner: "project" };
1476
1523
  }
1477
- /**
1478
- * A read of the organization's pack at a console from before ADR-0113, which has no such
1479
- * routes and answers that nothing is at the path: said as what it is, with what still reads a
1480
- * pack there, where the console's own words would read as a missing skill.
1481
- */
1482
- async function readingPack(owner, read) {
1483
- try {
1484
- return await read();
1485
- }
1486
- catch (error) {
1487
- if (owner === "organization" && error instanceof ApiError && error.code === "not_found") {
1488
- throw failed(`This console does not read the organization's pack where no project is named: it is older than the command. ${NO_PROJECT}`);
1489
- }
1490
- throw error;
1491
- }
1492
- }
1493
1524
  /**
1494
1525
  * Prints a read of a pack: as `answer` does, and, where the pack is the organization's, under
1495
1526
  * the line that says so. `--json` stays what the console answered.
@@ -1501,12 +1532,13 @@ const skills = async (args, io) => {
1501
1532
  const { values, positionals } = parse(args, SKILLS_OPTIONS);
1502
1533
  const session = await open(io, values);
1503
1534
  const { reader, owner } = await packNamed(session);
1504
- return readingPack(owner, () => readSkills(io, session, reader, values, positionals, {
1535
+ return readSkills(io, session, reader, values, positionals, {
1505
1536
  command: "console skills",
1506
1537
  own: io.skillsDir,
1507
1538
  afterwards: PLUGIN_SKILLS_LINE,
1508
1539
  owner,
1509
- }));
1540
+ again: whereGiven(values),
1541
+ });
1510
1542
  };
1511
1543
  /**
1512
1544
  * One skill of the pack, or a page of a file of it; for the project's pack as `console skill`,
@@ -1555,57 +1587,24 @@ async function readSkill(io, session, reader, values, positionals, command, owne
1555
1587
  throw misuse(wanted.error);
1556
1588
  }
1557
1589
  // The skill, its rules first, as load_skill lays them out: whole, or the part that begins at
1558
- // the cursor, ending with the command that reads the next, asked as this one was.
1559
- // The library asks for that line of every run of pages it tries, the runs it goes on from
1560
- // among them, so a line was asked for of a skill that is then printed to its end: the part
1561
- // goes on only where what is printed ends with the line.
1562
- const offered = [];
1590
+ // the cursor. A part says how many pages of the skill follow it and ends with the command
1591
+ // that reads the next, asked as this one was, and the last says that it is the last: the
1592
+ // words are the skillcdn command's own (SkillCDN 0.6.2), and only the line is made here.
1563
1593
  const loaded = await readThrough(io, session, owner, pack, { read: "skill", path: wanted.path, cursor }, {
1564
1594
  words: toolWords,
1565
1595
  // Spelled so that bash and PowerShell run it as it is; where a word has no such spelling,
1566
1596
  // the command that was run is run again, with the cursor, and the line says why.
1567
- nextPart: (next) => {
1568
- const line = commandLine(command, [given, "--cursor", next, ...again]) ??
1569
- `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}`;
1570
- offered.push({ cursor: next, line });
1571
- return line;
1572
- },
1597
+ nextPart: (next) => commandLine(command, [given, "--cursor", next, ...again]) ??
1598
+ `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}`,
1573
1599
  });
1574
- const goesOn = offered.findLast((one) => loaded.text.endsWith(one.line));
1575
- // A part that is not the last ends with the console's own words after the library's line: a
1576
- // fresh agent read one part of four, saw that the skill continued, and planned from that part,
1577
- // since "before using it" did not read as now to a session that meant only to plan. The last
1578
- // part of a skill read in parts says that it is the last, so that the end is said and not
1579
- // only missed.
1580
- const closing = goesOn !== undefined
1581
- ? partEndsHere(pack.pagesAfter(goesOn.cursor))
1582
- : cursor !== undefined && pack.skillEnded()
1583
- ? SKILL_ENDS_HERE
1584
- : undefined;
1585
- say(jsonOfRead(session, pack, loaded), () => closing === undefined ? loaded.text : `${loaded.text}\n${closing}`);
1600
+ say(jsonOfRead(session, pack, loaded), () => loaded.text);
1586
1601
  return EXIT.ok;
1587
1602
  }
1588
- /**
1589
- * What a part of a skill ends with where another follows: that the instructions stop here,
1590
- * what the rest holds, and that the command above is run now.
1591
- */
1592
- const PART_ENDS_HERE = "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.";
1593
- /**
1594
- * The same with how far the skill goes on before it, where the pack counts the pages left
1595
- * (SkillCDN 0.6.1): a reader told how many pages follow reads a skill to its end far more often
1596
- * than one told only that it continues. A part is a run of pages, so the count is the pack's
1597
- * own, of pages, and falls from part to part.
1598
- */
1599
- const partEndsHere = (left) => left === undefined || left < 1
1600
- ? PART_ENDS_HERE
1601
- : `${left} more ${left === 1 ? "page" : "pages"} of the skill ${left === 1 ? "follows" : "follow"} this part. ${PART_ENDS_HERE}`;
1602
- /** What the last part of a skill read in parts ends with. */
1603
- const SKILL_ENDS_HERE = "The skill is complete: this was its last part.";
1604
1603
  const skill = async (args, io) => {
1605
1604
  const { values, positionals } = parse(args, SKILL_OPTIONS);
1606
1605
  const session = await open(io, values);
1607
1606
  const { reader, owner } = await packNamed(session);
1608
- return readingPack(owner, () => readSkill(io, session, reader, values, positionals, "console skill", owner, whereGiven(values)));
1607
+ return readSkill(io, session, reader, values, positionals, "console skill", owner, whereGiven(values));
1609
1608
  };
1610
1609
  // ---- The plugins (docs/specs/plugins.md, "The command") ----
1611
1610
  // `console plugins` and `console plugin <key> ...` are the two entries: the command sends the
@@ -1709,6 +1708,7 @@ const plugin = async (args, io) => {
1709
1708
  const parsed = parse(rest, SKILLS_OPTIONS);
1710
1709
  return readSkills(io, session, client, parsed.values, parsed.positionals, {
1711
1710
  command: `console plugin ${key} skills`,
1711
+ again: whereGiven(values),
1712
1712
  });
1713
1713
  }
1714
1714
  case "skill": {
@@ -1852,9 +1852,7 @@ function whereValueOf(word) {
1852
1852
  * the caller may read it, which the console decides (every event for an administrator; for
1853
1853
  * anyone else those of the projects they may see, their own commands and the console's word of
1854
1854
  * the plugin); the failures alone with `--kind plugin.failed`, whether or not it has a board
1855
- * project. A console before 0.5.1 takes no kind and answers every one: the page is narrowed
1856
- * here, and that is said, since a page narrowed after it was read may hold fewer than were
1857
- * asked for.
1855
+ * project.
1858
1856
  */
1859
1857
  async function pluginEvents(io, session, client, rest) {
1860
1858
  const usage = `console plugin ${client.key} events [--kind <kind>] [--limit <n>] [--offset <n>]`;
@@ -1869,13 +1867,8 @@ async function pluginEvents(io, session, client, rest) {
1869
1867
  const limit = countOf(text(values, "limit"), "limit", { least: 1, most: EVENTS_PAGE_LIMIT });
1870
1868
  const offset = countOf(text(values, "offset"), "offset", { least: 0, most: 1_000_000 });
1871
1869
  const asked = { kind, limit: limit ?? DEFAULT_PAGE_LIMIT, offset: offset ?? 0 };
1872
- const read = await client.events(asked);
1873
- const items = kind === undefined ? read.items : read.items.filter((one) => one.kind === kind);
1874
- const narrowedHere = items.length !== read.items.length;
1875
- const page = { items, more: read.more };
1876
- answer(io, session, page, () => `${formatPluginEvents(client.key, page, asked)}${narrowedHere
1877
- ? `\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.`
1878
- : ""}`);
1870
+ const page = await client.events(asked);
1871
+ answer(io, session, page, () => formatPluginEvents(client.key, page, asked));
1879
1872
  return EXIT.ok;
1880
1873
  }
1881
1874
  async function pluginRecords(io, session, client, rest, project) {
@@ -2064,6 +2057,10 @@ async function pluginEnable(io, session, client, rest) {
2064
2057
  key: detail.boardDefaults.key,
2065
2058
  name: localized(detail.boardDefaults.name, readingLanguage(me)),
2066
2059
  description: localized(detail.boardDefaults.description, readingLanguage(me)),
2060
+ // The mark the plugin names for its project (ADR-0155); an icon of a pack this command
2061
+ // does not have is left to the console, which is whose pack it is.
2062
+ ...(detail.boardDefaults.color == null ? {} : { color: detail.boardDefaults.color }),
2063
+ ...(detail.boardDefaults.glyph == null ? {} : { glyph: detail.boardDefaults.glyph }),
2067
2064
  },
2068
2065
  };
2069
2066
  }
@@ -2239,14 +2236,6 @@ const rules = async (args, io) => {
2239
2236
  answer(io, session, put, () => "What this organization adds to the rules is put away: the console's stand alone.");
2240
2237
  return EXIT.ok;
2241
2238
  }
2242
- // A console of before 0.5.1 keeps what is written here as the organization's whole rules,
2243
- // in the place of its own (ADR-0120): what is added would be all that holds there. Its
2244
- // answer tells, since it says the workspace's rules whole and no parts, and it is asked
2245
- // before anything is written.
2246
- const held = await session.client.rules();
2247
- if (held.own === undefined) {
2248
- throw failed("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.");
2249
- }
2250
2239
  const written = await session.client.writeRules({
2251
2240
  body: body ?? "",
2252
2241
  ...(baseVersion === undefined ? {} : { baseVersion }),
@@ -2513,15 +2502,161 @@ const task = async (args, io) => {
2513
2502
  const session = await open(io, values);
2514
2503
  const project = await session.project();
2515
2504
  const found = await project.task(ref);
2516
- const [decisions, runs, comments] = await Promise.all([
2505
+ const [decisions, runs, comments, follow] = await Promise.all([
2517
2506
  project.decisions({ task: found.id }),
2518
2507
  // The runs are a line each, with their reports counted: the brief form, unless --json asks
2519
2508
  // for the console's own answer.
2520
2509
  session.json ? project.runs({ task: found.id }) : project.runBriefs({ task: found.id }),
2521
2510
  project.comments(found.id),
2511
+ // Whether the task tells the member anything (ADR-0157). A console of before has no such
2512
+ // route, and nothing is said of it then.
2513
+ project.taskFollow(found.id).then((kept) => kept, (error) => {
2514
+ if (noSuchRoute(error)) {
2515
+ return null;
2516
+ }
2517
+ throw error;
2518
+ }),
2522
2519
  ]);
2523
2520
  const page = await taskPage(session, found.number);
2524
- answer(io, session, { task: found, decisions: decisions.items, runs: runs.items, comments: comments.items }, () => formatTask(found, decisions.items, runs.items, comments.items, page));
2521
+ answer(io, session, { task: found, decisions: decisions.items, runs: runs.items, comments: comments.items, follow }, () => formatTask(found, decisions.items, runs.items, comments.items, page, follow));
2522
+ return EXIT.ok;
2523
+ };
2524
+ /** Whether a console answered that it has nothing at a path: what one of before a route does. */
2525
+ const noSuchRoute = (error) => error instanceof ApiError && error.status === 404 && error.code === "not_found";
2526
+ /**
2527
+ * What the console answers of the notifications (ADR-0157), where it has them: one of before
2528
+ * answers their paths as nothing, which is said as what it is, since "nothing at this path"
2529
+ * says nothing of why.
2530
+ */
2531
+ async function ofNotifications(io, asked) {
2532
+ try {
2533
+ return await asked;
2534
+ }
2535
+ catch (error) {
2536
+ if (noSuchRoute(error)) {
2537
+ const version = io.consoleVersion?.();
2538
+ throw failed(`This console${version === undefined ? "" : `, ${version},`} has no notifications yet: it is older than the command.`);
2539
+ }
2540
+ throw error;
2541
+ }
2542
+ }
2543
+ const NOTIFICATIONS_USAGE = "console notifications [--unread] [--limit <n>] [--offset <n>] | notifications --read <id> [<id>...] | notifications --read-all";
2544
+ // What the board told the member (ADR-0157), the newest first, and which of it they have read:
2545
+ // their own, a person's as an agent account's, across the projects, so that no project is named.
2546
+ const notifications = async (args, io) => {
2547
+ const { values, positionals } = parse(args, {
2548
+ unread: { type: "boolean" },
2549
+ read: { type: "boolean" },
2550
+ "read-all": { type: "boolean" },
2551
+ ...PAGE_OPTIONS,
2552
+ });
2553
+ const some = on(values, "read");
2554
+ const all = on(values, "read-all");
2555
+ const unread = on(values, "unread");
2556
+ const limit = countOf(text(values, "limit"), "limit", { least: 1, most: MAX_NOTIFICATIONS_PAGE });
2557
+ const offset = countOf(text(values, "offset"), "offset", { least: 0 });
2558
+ if (some || all) {
2559
+ if (unread || limit !== undefined || offset !== undefined) {
2560
+ throw misuse(`--unread, --limit and --offset are a listing's, and go with neither --read nor --read-all: ${NOTIFICATIONS_USAGE}`);
2561
+ }
2562
+ if (some === all || (all && positionals.length > 0)) {
2563
+ throw misuse(`Say one: --read <id> [<id>...] for the notifications named, or --read-all alone for every one: ${NOTIFICATIONS_USAGE}`);
2564
+ }
2565
+ if (some && positionals.length === 0) {
2566
+ throw misuse("Say which, by the ids the listing prints: console notifications --read <id> [<id>...]; or --read-all for every one");
2567
+ }
2568
+ const session = await open(io, values);
2569
+ const marked = await ofNotifications(io, session.client.readNotifications(all ? { all: true } : { ids: [...new Set(positionals)] }));
2570
+ answer(io, session, marked, () => `Marked ${marked.read} read; ${marked.unread} still unread.`);
2571
+ return EXIT.ok;
2572
+ }
2573
+ if (positionals.length > 0) {
2574
+ throw misuse(`A listing takes no word but its flags, and an id goes with --read: ${NOTIFICATIONS_USAGE}`);
2575
+ }
2576
+ const asked = { unread, limit: limit ?? NOTIFICATIONS_PAGE, offset: offset ?? 0 };
2577
+ const session = await open(io, values);
2578
+ const found = await ofNotifications(io, session.client.notifications(asked));
2579
+ answer(io, session, found, () => formatNotifications(found, asked));
2580
+ return EXIT.ok;
2581
+ };
2582
+ const NOTIFY_USAGE = "console notify [--on <kind>]... [--off <kind>]... [--project-off <key>]... [--project-on <key>]... [--own-agents on|off] | notify --reset";
2583
+ // What the member is told of (ADR-0157): each kind on or off, the projects they are told
2584
+ // nothing of, and whether what an agent of their own did as them counts; read, or changed in
2585
+ // what the flags say, or put back to what a member who chose nothing has.
2586
+ const notify = async (args, io) => {
2587
+ const { values } = parse(args, {
2588
+ on: { type: "string", multiple: true },
2589
+ off: { type: "string", multiple: true },
2590
+ "project-off": { type: "string", multiple: true },
2591
+ "project-on": { type: "string", multiple: true },
2592
+ "own-agents": { type: "string" },
2593
+ reset: { type: "boolean" },
2594
+ }, false);
2595
+ // A kind the vocabulary does not have is refused here, with the kinds there are, before the
2596
+ // console is asked anything: it would refuse the whole change for it.
2597
+ const kindOf = (value) => wordOf(value, NOTIFICATION_KINDS, "a kind of notification");
2598
+ const turnedOn = texts(values, "on").map(kindOf);
2599
+ const turnedOff = texts(values, "off").map(kindOf);
2600
+ const projectsOff = texts(values, "project-off");
2601
+ const projectsOn = texts(values, "project-on");
2602
+ const twice = turnedOn.find((kind) => turnedOff.includes(kind)) ??
2603
+ projectsOn.find((key) => projectsOff.includes(key));
2604
+ if (twice !== undefined) {
2605
+ throw misuse(`${twice} is said both on and off: say one. ${NOTIFY_USAGE}`);
2606
+ }
2607
+ const own = text(values, "own-agents");
2608
+ const ownAgents = own === undefined ? undefined : wordOf(own, ["on", "off"], "what --own-agents takes") === "on";
2609
+ const kinds = [
2610
+ ...turnedOn.map((kind) => [kind, true]),
2611
+ ...turnedOff.map((kind) => [kind, false]),
2612
+ ];
2613
+ const projects = projectsOff.length > 0 || projectsOn.length > 0;
2614
+ const changes = kinds.length > 0 || projects || ownAgents !== undefined;
2615
+ if (on(values, "reset") && changes) {
2616
+ throw misuse(`--reset stands alone: it puts everything back to what a member who chose nothing is told of. ${NOTIFY_USAGE}`);
2617
+ }
2618
+ const session = await open(io, values);
2619
+ const { client } = session;
2620
+ // The settings as they are now, whatever was asked: read, changed or put back.
2621
+ const say = (settings) => {
2622
+ answer(io, session, settings, () => formatNotificationSettings(settings));
2623
+ return EXIT.ok;
2624
+ };
2625
+ if (on(values, "reset")) {
2626
+ return say(await ofNotifications(io, client.updateNotificationSettings({ reset: true })));
2627
+ }
2628
+ if (!changes) {
2629
+ return say(await ofNotifications(io, client.notificationSettings()));
2630
+ }
2631
+ // The projects turned off are sent whole: those that were, read as they stand, less the ones
2632
+ // turned on again, and the ones turned off now.
2633
+ const off = projects
2634
+ ? [
2635
+ ...new Set([
2636
+ ...(await ofNotifications(io, client.notificationSettings())).projectsOff
2637
+ .map((project) => project.key)
2638
+ .filter((key) => !projectsOn.includes(key)),
2639
+ ...projectsOff,
2640
+ ]),
2641
+ ]
2642
+ : undefined;
2643
+ return say(await ofNotifications(io, client.updateNotificationSettings({
2644
+ ...(kinds.length === 0 ? {} : { kinds: Object.fromEntries(kinds) }),
2645
+ ...(off === undefined ? {} : { projectsOff: off }),
2646
+ ...(ownAgents === undefined ? {} : { ownAgents }),
2647
+ })));
2648
+ };
2649
+ // Whether one task tells a member anything (ADR-0157): `follow` turns its notifications on,
2650
+ // `mute` off. A task turned on that their settings would be silent of tells them of
2651
+ // everything on it; one turned to what their settings say already is told by their kinds.
2652
+ const following = (turned) => async (args, io) => {
2653
+ const { values, positionals } = parse(args, {});
2654
+ const ref = theOne(positionals, `Say which task: console ${turned ? "follow" : "mute"} <number|id>`);
2655
+ const session = await open(io, values);
2656
+ const project = await session.project();
2657
+ const found = await project.task(ref);
2658
+ const kept = await ofNotifications(io, project.followTask(found.id, turned));
2659
+ answer(io, session, kept, () => formatTaskFollow(found, kept));
2525
2660
  return EXIT.ok;
2526
2661
  };
2527
2662
  /**
@@ -2875,7 +3010,7 @@ const notInProject = (error) => error instanceof ApiError &&
2875
3010
  * before; else wherever it is, addressed to the person, raised by them, or a plugin's addressed
2876
3011
  * to someone they manage, through the console's own route for one decision. A plugin's decision
2877
3012
  * waits in the plugin's board project, which a checkout bound to another project does not name,
2878
- * and which the person may not be in at all. A console from before that route answers as before.
3013
+ * and which the person may not be in at all.
2879
3014
  */
2880
3015
  async function reachDecision(session, id) {
2881
3016
  if ((await session.projectKey()) !== undefined) {
@@ -3292,8 +3427,8 @@ const decisions = async (args, io) => {
3292
3427
  /**
3293
3428
  * Says how a run ended, and where that left its task (ADR-0114). The console places the task,
3294
3429
  * and where is not the command's to know: a finished run leaves it at work where another run is
3295
- * open on it, and a run that failed or was given up does that too, and on a console of before
3296
- * 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
3430
+ * open on it, and a run that failed or was given up does that too, or where a person moved it
3431
+ * meanwhile. So the task is read once the run is over, and its state said as it stands. On
3297
3432
  * `--json` the answer is the run as the console gave it, and nothing more is asked.
3298
3433
  */
3299
3434
  async function sayEnded(io, session, project, run, status) {
@@ -3510,9 +3645,21 @@ function runnerStateOf(text) {
3510
3645
  const delivered = "delivered" in json ? json.delivered : undefined;
3511
3646
  const conversation = "conversation" in json ? json.conversation : undefined;
3512
3647
  const driver = "driver" in json ? json.driver : undefined;
3648
+ const limited = "limited" in json ? json.limited : undefined;
3649
+ const kept = "kept" in json ? json.kept : undefined;
3513
3650
  if (typeof delivered !== "number" || !Number.isSafeInteger(delivered) || delivered < 0) {
3514
3651
  return undefined;
3515
3652
  }
3653
+ /**
3654
+ * A moment in milliseconds since the epoch, or nothing for anything else: a number past what
3655
+ * a date holds would fail the runner at every start, where it says the moment in words.
3656
+ */
3657
+ const momentOf = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0 && value < 1e14
3658
+ ? value
3659
+ : undefined;
3660
+ const since = typeof limited === "object" && limited !== null && "since" in limited
3661
+ ? momentOf(limited.since)
3662
+ : undefined;
3516
3663
  return {
3517
3664
  delivered,
3518
3665
  conversation: typeof conversation === "string" && conversation.length > 0 && conversation.length <= 200
@@ -3520,6 +3667,23 @@ function runnerStateOf(text) {
3520
3667
  : undefined,
3521
3668
  // The driver the conversation was begun under, as a registry spells one.
3522
3669
  driver: typeof driver === "string" && /^[a-z][a-z0-9-]{0,39}$/.test(driver) ? driver : undefined,
3670
+ // The usage limit the agent is not back from (ADR-0150): since when, and until when where the product said.
3671
+ ...(since === undefined || typeof limited !== "object" || limited === null
3672
+ ? {}
3673
+ : {
3674
+ limited: {
3675
+ since,
3676
+ until: "until" in limited ? momentOf(limited.until) : undefined,
3677
+ },
3678
+ }),
3679
+ // The signals the record has as delivered that the agent never read: taken from the stream once more.
3680
+ ...(Array.isArray(kept)
3681
+ ? {
3682
+ kept: kept
3683
+ .filter((number) => momentOf(number) !== undefined)
3684
+ .slice(0, 50),
3685
+ }
3686
+ : {}),
3523
3687
  };
3524
3688
  }
3525
3689
  /** A line a runner says of its machine, within what the console takes one in. */
@@ -3649,8 +3813,10 @@ const runner = async (args, io) => {
3649
3813
  command: read.config.product?.command,
3650
3814
  args: read.config.product?.args,
3651
3815
  version: io.version,
3816
+ platform: host.platform,
3652
3817
  }),
3653
3818
  config: read.config,
3819
+ account: person.id,
3654
3820
  reconfigured: async () => {
3655
3821
  const now = await readConfig();
3656
3822
  return !now.ok ? { problem: now.problem } : now.text === read.text ? "same" : "changed";
@@ -3669,6 +3835,10 @@ const runner = async (args, io) => {
3669
3835
  now: io.now,
3670
3836
  random: host.random,
3671
3837
  time: (iso) => clock.format(new Date(iso)),
3838
+ // A moment that may be on another day, a stretch the runner did not run in or when a
3839
+ // usage limit resets, is said as the command prints any moment: with its day, in the
3840
+ // workspace's zone where the login kept one.
3841
+ moment,
3672
3842
  files: {
3673
3843
  write: (path, text) => host.writePrivate(workPath(path), text),
3674
3844
  remove: (path) => host.remove(workPath(path)),
@@ -3846,12 +4016,12 @@ const agentNew = async (args, io) => {
3846
4016
  made.person.invited === true
3847
4017
  ? host === "gh"
3848
4018
  ? // A login at a git host goes to whoever registers it: what the first sign-in is held
3849
- // to is said (ADR-0126), and by a console older than the answer, the login alone.
4019
+ // to is said (ADR-0126).
3850
4020
  made.firstSignIn === "account"
3851
4021
  ? `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.`
3852
4022
  : made.firstSignIn === "member"
3853
4023
  ? `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.`
3854
- : `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.`
4024
+ : `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.`
3855
4025
  : `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.`
3856
4026
  : `${made.person.login} is an agent account from now on, with everything it did.`,
3857
4027
  ...(made.onboarding === null || made.onboarding === undefined
@@ -4062,37 +4232,54 @@ const ownWake = async (args, io) => {
4062
4232
  throw misuse(`Not a name for a wake, which is up to 40 lowercase letters, digits and hyphens: ${key}`);
4063
4233
  }
4064
4234
  const session = await open(io, values);
4065
- /** A console of before knows no such route: said as what it is. */
4066
- const asked = async (ask) => {
4067
- try {
4068
- return await ask();
4069
- }
4070
- catch (error) {
4071
- if (error instanceof ApiError && error.status === 404 && error.code === "not_found") {
4072
- throw failed("This console does not take an account's own wake yet: it does from 0.5.2 on.");
4073
- }
4074
- throw error;
4075
- }
4076
- };
4077
4235
  if (on(values, "cancel")) {
4078
4236
  const named = key ?? OWN_WAKE_KEY;
4079
- await asked(() => session.client.cancelOwnWake(named));
4237
+ await session.client.cancelOwnWake(named);
4080
4238
  answer(io, session, { cancelled: named }, () => `The wake ${named} is taken away.`);
4081
4239
  return EXIT.ok;
4082
4240
  }
4083
4241
  const said = ((await bodyOf(io, values, words)) ?? "").trim();
4084
4242
  const me = await session.client.me();
4085
4243
  const at = ownWakeMoment({ in: text(values, "in"), at: text(values, "at") }, me.workspace.timeZone ?? undefined, new Date(io.now()));
4086
- const raised = await asked(() => session.client.raiseOwnWake({
4244
+ const raised = await session.client.raiseOwnWake({
4087
4245
  ...(said.length === 0 ? {} : { text: said }),
4088
4246
  ...(at === undefined ? {} : { at: at.toISOString() }),
4089
4247
  ...(key === undefined ? {} : { key }),
4090
- }));
4248
+ });
4091
4249
  answer(io, session, raised, () => raised.kept === null
4092
4250
  ? `Raised, as signal #${raised.signal?.number ?? "?"} of your record: your runner takes it as it takes any wake.`
4093
4251
  : `Kept: ${formatOwnWakeLine(raised.kept)}\nTake it away: console agent wake me --cancel${raised.kept.key === OWN_WAKE_KEY ? "" : ` --key ${raised.kept.key}`}. A second under the same name takes its place.`);
4094
4252
  return EXIT.ok;
4095
4253
  };
4254
+ const OWN_RESET_USAGE = 'Say why, which the new conversation reads first: console agent reset me "<why>" [--file <path>]';
4255
+ // A new conversation an agent account begins for itself (ADR-0154), by its own command, where
4256
+ // its work has a break: its runner takes it when the turn it is asked in is over. The words
4257
+ // say why, on the account's record, and are what the new conversation reads first.
4258
+ const ownReset = async (args, io) => {
4259
+ const { values, positionals } = parse(args, { file: { type: "string" } });
4260
+ const [, words, ...rest] = positionals;
4261
+ if (rest.length > 0) {
4262
+ throw misuse(OWN_RESET_USAGE);
4263
+ }
4264
+ const said = ((await bodyOf(io, values, words)) ?? "").trim();
4265
+ if (said.length === 0) {
4266
+ throw misuse(OWN_RESET_USAGE);
4267
+ }
4268
+ const session = await open(io, values);
4269
+ let sent;
4270
+ try {
4271
+ sent = await session.client.sendOwnReset({ text: said });
4272
+ }
4273
+ catch (error) {
4274
+ // A console of before knows no such route: said as what it is.
4275
+ if (error instanceof ApiError && error.status === 404 && error.code === "not_found") {
4276
+ throw failed("This console does not take an account's own reset yet: it is older than the command.");
4277
+ }
4278
+ throw error;
4279
+ }
4280
+ answer(io, session, sent, () => `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.`);
4281
+ return EXIT.ok;
4282
+ };
4096
4283
  /** The kinds of signal a supervisor sends with words: which need them, and which take them. */
4097
4284
  const WORDED_SIGNALS = {
4098
4285
  tell: { needs: true },
@@ -4121,6 +4308,19 @@ const agentSignal = async (kind, args, io) => {
4121
4308
  return ownWake(args, io);
4122
4309
  }
4123
4310
  }
4311
+ // And so is its own reset: console agent reset me.
4312
+ if (kind === "reset") {
4313
+ let whom;
4314
+ try {
4315
+ whom = parse(args, { file: { type: "string" } }).positionals[0];
4316
+ }
4317
+ catch {
4318
+ whom = undefined;
4319
+ }
4320
+ if (whom === "me") {
4321
+ return ownReset(args, io);
4322
+ }
4323
+ }
4124
4324
  const { values, positionals } = parse(args, { file: { type: "string" } });
4125
4325
  const [given, words, ...rest] = positionals;
4126
4326
  const needs = WORDED_SIGNALS[kind]?.needs === true;
@@ -4191,7 +4391,7 @@ const agentSignals = async (args, io) => {
4191
4391
  ...(before === undefined ? {} : { before: Number(before) }),
4192
4392
  });
4193
4393
  // What the account keeps for later (ADR-0145) stands over the record's first page: it is no
4194
- // signal yet. A console of before keeps none, and says nothing of it.
4394
+ // signal yet. Where it cannot be read, the record is printed without it.
4195
4395
  const kept = before === undefined
4196
4396
  ? await session.client
4197
4397
  .ownWakes(handle)
@@ -4211,24 +4411,144 @@ const agentSignals = async (args, io) => {
4211
4411
  ].join("\n"));
4212
4412
  return EXIT.ok;
4213
4413
  };
4414
+ const AGENT_MESSAGES_USAGE = "Say where, as a wake's header names it after messenger: console agent messages <source>:<conversation>[:<thread>] [--limit <n>] [--after <moment>]";
4415
+ // What was said where a wake from the messenger was raised (ADR-0163): the latest messages of the
4416
+ // conversation, or of the thread, that the wake's key names, read by the wake source the key
4417
+ // begins with, with a secret of the account's own store, which nobody else reads. For the
4418
+ // account itself, where a wake carried less than the agent needs, and before it answers where
4419
+ // others may have answered meanwhile. What a source's line says is printed as it is, and what
4420
+ // someone wrote behind `>`, a line each, so that no word of a message reads as a line.
4421
+ const agentMessages = async (args, io) => {
4422
+ const { values, positionals } = parse(args, {
4423
+ limit: { type: "string" },
4424
+ after: { type: "string" },
4425
+ });
4426
+ const key = theOne(positionals, AGENT_MESSAGES_USAGE);
4427
+ const named = /^([a-z][a-z0-9-]{0,39}):(.+)$/.exec(key);
4428
+ const source = named?.[1] === undefined ? undefined : ownRunnerModules({ user: "" }).wakeSources.get(named[1]);
4429
+ if (named?.[2] === undefined || source?.read === undefined) {
4430
+ throw misuse(`No wake source of this command reads ${key.includes(":") ? `what ${key.slice(0, key.indexOf(":"))} names` : "that"}. ${AGENT_MESSAGES_USAGE}`);
4431
+ }
4432
+ const limit = text(values, "limit");
4433
+ if (limit !== undefined && !(Number.isSafeInteger(Number(limit)) && Number(limit) >= 1)) {
4434
+ throw misuse(`Not a number of messages: ${limit}`);
4435
+ }
4436
+ const after = text(values, "after");
4437
+ const session = await open(io, values);
4438
+ const read = await source.read({
4439
+ // A secret the account does not keep is none, and the source says what it lacks.
4440
+ secret: async (name) => {
4441
+ try {
4442
+ return (await session.client.secret(name)).value;
4443
+ }
4444
+ catch (error) {
4445
+ if (error instanceof ApiError && error.code === "secret.not_found") {
4446
+ return undefined;
4447
+ }
4448
+ throw error;
4449
+ }
4450
+ },
4451
+ fetch: (url, init) => io.fetch(url, { ...init, headers: { ...init.headers } }),
4452
+ // Who wrote each message, as the console says it (ADR-0164): where it says nothing, a
4453
+ // console older than the question say, the lines are as the messenger alone has them.
4454
+ writers: async (accounts, signal) => (await session.client.writers({ messenger: named[1] ?? "", accounts: [...accounts] }, signal)).items,
4455
+ }, named[2], {
4456
+ ...(limit === undefined ? {} : { limit: Number(limit) }),
4457
+ ...(after === undefined ? {} : { after }),
4458
+ now: io.now(),
4459
+ signal: AbortSignal.timeout(30_000),
4460
+ });
4461
+ if (!read.ok) {
4462
+ throw failed(read.why === "no_token"
4463
+ ? `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.`
4464
+ : read.why === "not_a_conversation"
4465
+ ? `Nothing was read: ${named[2]} names no conversation as a wake of the ${named[1]} wake source does (not_a_conversation). ${AGENT_MESSAGES_USAGE}`
4466
+ : read.why === "not_a_moment"
4467
+ ? `Nothing was read: ${after} is the moment of no message, as a wake of the ${named[1]} wake source says one (not_a_moment).`
4468
+ : `Nothing was read: the messenger did not answer the ${named[1]} wake source with the conversation (${read.why}).`);
4469
+ }
4470
+ answer(io, session, { key, parts: read.parts }, () => read.parts
4471
+ .map((part) => ("says" in part ? part.says : quotedLines(part.words).join("\n")))
4472
+ .join("\n"));
4473
+ return EXIT.ok;
4474
+ };
4214
4475
  // The invitation that leads a machine to an agent account (ADR-0088): made, made again in place
4215
4476
  // of the one before, or taken away, by a supervisor. Its code is no credential: it says which
4216
4477
  // account a setup is for and opens the guide, and the account is entered through its own sign-in.
4478
+ // What the command prints under an agent is in that agent's record from then on, and an agent
4479
+ // account that supervises another has nobody reading along: with --out the line goes to a file,
4480
+ // which a decision's body or a comment's attachment carries to a person, and the output names no
4481
+ // code. Never the words of a comment (`comment --file`): the command prints those back.
4217
4482
  const agentInvite = async (args, io) => {
4218
- const { values, positionals } = parse(args, { revoke: { type: "boolean" } });
4219
- const handle = handleOf(theOne(positionals, "Say whose: console agent invite <handle> [--revoke]"));
4483
+ const { values, positionals } = parse(args, {
4484
+ revoke: { type: "boolean" },
4485
+ out: { type: "string" },
4486
+ });
4487
+ const handle = handleOf(theOne(positionals, "Say whose: console agent invite <handle> [--out <path>] | --revoke"));
4488
+ const out = text(values, "out");
4489
+ if (on(values, "revoke") && out !== undefined) {
4490
+ throw misuse("Say one of --out <path>, which writes the line of a new invitation to a file, and --revoke, which takes the invitation away.");
4491
+ }
4220
4492
  const session = await open(io, values);
4221
4493
  if (on(values, "revoke")) {
4222
4494
  await session.client.revokeAgentInvitation(handle);
4223
4495
  answer(io, session, { handle, revoked: true }, () => `The invitation of @${handle} is taken away: its code opens nothing now.`);
4224
4496
  return EXIT.ok;
4225
4497
  }
4498
+ // The path is tried before the invitation is made: a new invitation takes the place of the
4499
+ // one before and its code comes once, so one made for a path that cannot be written would
4500
+ // leave the account with an invitation nobody holds. The file is the account's alone to read.
4501
+ // What is at the path stays until the new line is there to take its place: the line of the
4502
+ // invitation before, say, which still stands where this one cannot be made.
4503
+ const name = `${handle}-invitation.md`;
4504
+ let file;
4505
+ if (out !== undefined) {
4506
+ try {
4507
+ file = await io.writeBytes(out, new Uint8Array(), name, { private: true, after: true });
4508
+ }
4509
+ catch {
4510
+ throw failed(`Nothing can be written at ${out}, so no invitation was made and the one before stands. Say a path that can be written.`);
4511
+ }
4512
+ }
4226
4513
  const made = await session.client.inviteAgent(handle);
4227
- answer(io, session, made, () => [
4228
- `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.`,
4514
+ const until = `good until ${moment(made.invitation.expiresAt)} or until its command has signed in`;
4515
+ const guide = `${session.url}/setup/${made.code}`;
4516
+ if (file === undefined) {
4517
+ answer(io, session, made, () => [
4518
+ `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.`,
4519
+ "On the agent's machine, in its own OS account, say to its product:",
4520
+ ` ${setupSentenceOf(made.command)}`,
4521
+ `or run the command there yourself. A person reads the same guide at ${guide}`,
4522
+ ].join("\n"));
4523
+ return EXIT.ok;
4524
+ }
4525
+ // Markdown, since the file is read where it is handed on: a decision's body, a comment, a
4526
+ // messenger. The line stands in a block of its own, to be copied as written.
4527
+ const words = [
4528
+ `An invitation for @${handle}, ${until}. Its code is no credential: it says which account a setup is for, and gives nobody the account.`,
4529
+ "",
4229
4530
  "On the agent's machine, in its own OS account, say to its product:",
4230
- ` ${setupSentenceOf(made.command)}`,
4231
- `or run the command there yourself. A person reads the same guide at ${session.url}/setup/${made.code}`,
4531
+ "",
4532
+ "```",
4533
+ setupSentenceOf(made.command),
4534
+ "```",
4535
+ "",
4536
+ `or run the command there yourself. A person reads the same guide at ${guide}`,
4537
+ "",
4538
+ ].join("\n");
4539
+ let written;
4540
+ try {
4541
+ written = await io.writeBytes(file, new TextEncoder().encode(words), name, { private: true });
4542
+ }
4543
+ catch {
4544
+ // The code came this once and went nowhere: the invitation stands and nobody holds its line.
4545
+ throw failed(`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.`);
4546
+ }
4547
+ // The path as both shells take it whole; where it has no such spelling, it is named in words.
4548
+ const path = commandWord(written) ?? "<the file's path, quoted for your shell>";
4549
+ answer(io, session, { handle, invitation: made.invitation, file: written }, () => [
4550
+ `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.`,
4551
+ `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.`,
4232
4552
  ].join("\n"));
4233
4553
  return EXIT.ok;
4234
4554
  };
@@ -4249,8 +4569,26 @@ const SETUP_FLAGS = {
4249
4569
  "new-desk": { type: "boolean" },
4250
4570
  "no-service": { type: "boolean" },
4251
4571
  driver: { type: "string" },
4572
+ browser: { type: "string" },
4252
4573
  "no-browser": { type: "boolean" },
4253
4574
  };
4575
+ /**
4576
+ * The browsers a setup looks for where it is asked for one: the one with no window and the
4577
+ * product's own. A window for the first is a name the agent writes itself when someone is to
4578
+ * see its browser, and no setup's.
4579
+ */
4580
+ const SETUP_BROWSERS = ["headless", "chrome"];
4581
+ /** What a setup says it found of the agent's browser, by the name a new desk gives it; nothing of none. */
4582
+ const BROWSER_FOUND = {
4583
+ headless: `, Google Chrome and ${HEADLESS_TOOL.command}, which drives it with no window`,
4584
+ chrome: ", Google Chrome",
4585
+ none: "",
4586
+ };
4587
+ /** A runner's config with no browser named, for a desk whose product is started with none. */
4588
+ function withoutBrowser(config) {
4589
+ const { browser: _none, ...rest } = config;
4590
+ return rest;
4591
+ }
4254
4592
  /** The end of what a program said, for a refusal to carry: one line, bounded. */
4255
4593
  function lastWords(ran) {
4256
4594
  const line = ran.err.trim().split(/\r?\n/).at(-1) ?? "";
@@ -4369,8 +4707,10 @@ look) {
4369
4707
  runner: look === undefined
4370
4708
  ? undefined
4371
4709
  : {
4372
- ...DEFAULT_RUNNER_CONFIG,
4710
+ ...withoutBrowser(DEFAULT_RUNNER_CONFIG),
4373
4711
  ...(look.driver === undefined ? {} : { driver: look.driver }),
4712
+ // A browser is named where the product is started with one: under a driver that
4713
+ // takes nothing of the name, a desk that named one would read as having it.
4374
4714
  ...(look.browser === undefined ? {} : { browser: look.browser }),
4375
4715
  },
4376
4716
  })) {
@@ -4599,6 +4939,7 @@ log) {
4599
4939
  }
4600
4940
  const plate = await client.work().catch(() => undefined);
4601
4941
  const first = plate?.tasks.find((one) => one.task.title === onboardingTitle(handle));
4942
+ const inTheWay = await standsInTheWay(machine);
4602
4943
  const lines = [
4603
4944
  began
4604
4945
  ? `@${handle}'s session has begun: the agent is at work.`
@@ -4612,6 +4953,12 @@ log) {
4612
4953
  `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.`,
4613
4954
  `What you change on this machine afterwards, say to it: console agent wake me "<what changed>"`,
4614
4955
  awakeWords(machine.platform, await heldAwake(machine), log),
4956
+ ...(inTheWay.length === 0
4957
+ ? []
4958
+ : [
4959
+ `What on this machine still leaves @${handle} unheard with nobody there, for whoever keeps the machine to change or to accept:`,
4960
+ ...inTheWay.map((line) => `- ${line}`),
4961
+ ]),
4615
4962
  ];
4616
4963
  io.stdout(`${lines.join("\n")}\n`);
4617
4964
  }
@@ -4693,11 +5040,23 @@ const agentSetup = async (args, io) => {
4693
5040
  ownRunnerModules({ user: machine.user }).drivers.get(driver) === undefined) {
4694
5041
  throw misuse(`Not a driver this command has: ${driver}. It has: ${ownRunnerModules({ user: machine.user }).drivers.names().join(", ")}.`);
4695
5042
  }
4696
- const look = await lookAtMachine(machine, { driver, browser: !on(values, "no-browser") });
5043
+ // The agent's browser (ADR-0151): a Chrome with no window where nobody says another.
5044
+ const named = text(values, "browser");
5045
+ const browser = SETUP_BROWSERS.find((one) => one === named);
5046
+ if (named !== undefined && browser === undefined) {
5047
+ throw misuse(`Not a browser this command sets up: ${named}. It has: ${SETUP_BROWSERS.join(", ")}; --no-browser is for none.`);
5048
+ }
5049
+ if (named !== undefined && on(values, "no-browser")) {
5050
+ throw misuse("Say one of --browser <name> and --no-browser.");
5051
+ }
5052
+ const look = await lookAtMachine(machine, {
5053
+ driver,
5054
+ browser: on(values, "no-browser") ? "none" : (browser ?? "headless"),
5055
+ });
4697
5056
  if (look.missing.length > 0) {
4698
5057
  throw failed(`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")}`);
4699
5058
  }
4700
- io.stdout(`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("")}`);
5059
+ io.stdout(`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("")}`);
4701
5060
  const client = await signInAsAccount(io, machine, url, setup);
4702
5061
  const me = await client.me();
4703
5062
  if (me.person === null) {
@@ -4914,6 +5273,9 @@ const agent = async (args, io) => {
4914
5273
  if (args[0] === "signals") {
4915
5274
  return agentSignals(args.slice(1), io);
4916
5275
  }
5276
+ if (args[0] === "messages") {
5277
+ return agentMessages(args.slice(1), io);
5278
+ }
4917
5279
  if (args[0] === "invite") {
4918
5280
  return agentInvite(args.slice(1), io);
4919
5281
  }
@@ -4969,13 +5331,13 @@ const agent = async (args, io) => {
4969
5331
  ...(dayStart === undefined ? {} : { dayStart }),
4970
5332
  ...(dayEnd === undefined ? {} : { dayEnd }),
4971
5333
  });
4972
- answer(io, session, kept, () => formatAgent(kept));
5334
+ answer(io, session, kept, () => formatAgent(kept, io.now()));
4973
5335
  return EXIT.ok;
4974
5336
  }
4975
5337
  const found = await session.client.agent(handle);
4976
5338
  const file = text(values, "avatar");
4977
5339
  if (file === undefined) {
4978
- answer(io, session, found, () => formatAgent(found));
5340
+ answer(io, session, found, () => formatAgent(found, io.now()));
4979
5341
  return EXIT.ok;
4980
5342
  }
4981
5343
  const parts = found.person.avatarParts;
@@ -5553,6 +5915,10 @@ const COMMANDS = {
5553
5915
  projects,
5554
5916
  use,
5555
5917
  work,
5918
+ notifications,
5919
+ notify,
5920
+ follow: following(true),
5921
+ mute: following(false),
5556
5922
  tasks,
5557
5923
  task,
5558
5924
  goals,