@skillcdn/console 0.4.7 → 0.5.1

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 (599) hide show
  1. package/README.md +74 -14
  2. package/SKILLCDN.md +5 -3
  3. package/dist/agent-page.d.ts +44 -0
  4. package/dist/agent-page.d.ts.map +1 -0
  5. package/dist/agent-page.js +415 -0
  6. package/dist/agent-page.js.map +1 -0
  7. package/dist/agent-stream.d.ts +52 -0
  8. package/dist/agent-stream.d.ts.map +1 -0
  9. package/dist/agent-stream.js +155 -0
  10. package/dist/agent-stream.js.map +1 -0
  11. package/dist/api.d.ts +12 -6
  12. package/dist/api.d.ts.map +1 -1
  13. package/dist/api.js +11 -5
  14. package/dist/api.js.map +1 -1
  15. package/dist/avatar.d.ts +137 -0
  16. package/dist/avatar.d.ts.map +1 -0
  17. package/dist/avatar.js +1216 -0
  18. package/dist/avatar.js.map +1 -0
  19. package/dist/charts.d.ts +103 -0
  20. package/dist/charts.d.ts.map +1 -0
  21. package/dist/charts.js +182 -0
  22. package/dist/charts.js.map +1 -0
  23. package/dist/cli/cli.d.ts +39 -1
  24. package/dist/cli/cli.d.ts.map +1 -1
  25. package/dist/cli/cli.js +2424 -296
  26. package/dist/cli/cli.js.map +1 -1
  27. package/dist/cli/command-words.d.ts +20 -0
  28. package/dist/cli/command-words.d.ts.map +1 -0
  29. package/dist/cli/command-words.js +51 -0
  30. package/dist/cli/command-words.js.map +1 -0
  31. package/dist/cli/credentials.d.ts +59 -5
  32. package/dist/cli/credentials.d.ts.map +1 -1
  33. package/dist/cli/credentials.js +128 -16
  34. package/dist/cli/credentials.js.map +1 -1
  35. package/dist/cli/directory.d.ts +19 -4
  36. package/dist/cli/directory.d.ts.map +1 -1
  37. package/dist/cli/directory.js +16 -8
  38. package/dist/cli/directory.js.map +1 -1
  39. package/dist/cli/format.d.ts +91 -8
  40. package/dist/cli/format.d.ts.map +1 -1
  41. package/dist/cli/format.js +386 -57
  42. package/dist/cli/format.js.map +1 -1
  43. package/dist/cli/help.d.ts +13 -4
  44. package/dist/cli/help.d.ts.map +1 -1
  45. package/dist/cli/help.js +202 -62
  46. package/dist/cli/help.js.map +1 -1
  47. package/dist/cli/main.js +94 -0
  48. package/dist/cli/main.js.map +1 -1
  49. package/dist/cli/pack.d.ts +69 -36
  50. package/dist/cli/pack.d.ts.map +1 -1
  51. package/dist/cli/pack.js +241 -188
  52. package/dist/cli/pack.js.map +1 -1
  53. package/dist/cli/plugin-check.d.ts +42 -0
  54. package/dist/cli/plugin-check.d.ts.map +1 -1
  55. package/dist/cli/plugin-check.js +221 -36
  56. package/dist/cli/plugin-check.js.map +1 -1
  57. package/dist/cli/plugin-cli.d.ts +6 -1
  58. package/dist/cli/plugin-cli.d.ts.map +1 -1
  59. package/dist/cli/plugin-cli.js +21 -4
  60. package/dist/cli/plugin-cli.js.map +1 -1
  61. package/dist/cli/plugin-main.js +1 -0
  62. package/dist/cli/plugin-main.js.map +1 -1
  63. package/dist/cli/runner-host.d.ts +36 -0
  64. package/dist/cli/runner-host.d.ts.map +1 -0
  65. package/dist/cli/runner-host.js +154 -0
  66. package/dist/cli/runner-host.js.map +1 -0
  67. package/dist/cli/serve.d.ts +33 -1
  68. package/dist/cli/serve.d.ts.map +1 -1
  69. package/dist/cli/serve.js +275 -6
  70. package/dist/cli/serve.js.map +1 -1
  71. package/dist/cli/setup-machine.d.ts +36 -0
  72. package/dist/cli/setup-machine.d.ts.map +1 -0
  73. package/dist/cli/setup-machine.js +109 -0
  74. package/dist/cli/setup-machine.js.map +1 -0
  75. package/dist/client.d.ts +189 -10
  76. package/dist/client.d.ts.map +1 -1
  77. package/dist/client.js +192 -57
  78. package/dist/client.js.map +1 -1
  79. package/dist/compat.d.ts +1 -1
  80. package/dist/compat.js +2 -2
  81. package/dist/components/agent-page.d.ts +384 -0
  82. package/dist/components/agent-page.d.ts.map +1 -0
  83. package/dist/components/agent-page.js +985 -0
  84. package/dist/components/agent-page.js.map +1 -0
  85. package/dist/components/agents.d.ts +102 -0
  86. package/dist/components/agents.d.ts.map +1 -0
  87. package/dist/components/agents.js +246 -0
  88. package/dist/components/agents.js.map +1 -0
  89. package/dist/components/calendar.d.ts +17 -17
  90. package/dist/components/calendar.d.ts.map +1 -1
  91. package/dist/components/calendar.js +7 -2
  92. package/dist/components/calendar.js.map +1 -1
  93. package/dist/components/charts.d.ts +157 -0
  94. package/dist/components/charts.d.ts.map +1 -0
  95. package/dist/components/charts.js +182 -0
  96. package/dist/components/charts.js.map +1 -0
  97. package/dist/components/comments.d.ts +2 -0
  98. package/dist/components/comments.d.ts.map +1 -1
  99. package/dist/components/comments.js +1 -1
  100. package/dist/components/comments.js.map +1 -1
  101. package/dist/components/connect.d.ts.map +1 -1
  102. package/dist/components/connect.js +7 -2
  103. package/dist/components/connect.js.map +1 -1
  104. package/dist/components/decision-form.d.ts +21 -0
  105. package/dist/components/decision-form.d.ts.map +1 -1
  106. package/dist/components/decision-form.js +20 -6
  107. package/dist/components/decision-form.js.map +1 -1
  108. package/dist/components/decision-list.d.ts +24 -0
  109. package/dist/components/decision-list.d.ts.map +1 -1
  110. package/dist/components/decision-list.js +54 -5
  111. package/dist/components/decision-list.js.map +1 -1
  112. package/dist/components/desk-records.d.ts +102 -0
  113. package/dist/components/desk-records.d.ts.map +1 -0
  114. package/dist/components/desk-records.js +221 -0
  115. package/dist/components/desk-records.js.map +1 -0
  116. package/dist/components/desk.d.ts +85 -0
  117. package/dist/components/desk.d.ts.map +1 -0
  118. package/dist/components/desk.js +135 -0
  119. package/dist/components/desk.js.map +1 -0
  120. package/dist/components/event-feed.d.ts.map +1 -1
  121. package/dist/components/event-feed.js +26 -1
  122. package/dist/components/event-feed.js.map +1 -1
  123. package/dist/components/home.d.ts +12 -1
  124. package/dist/components/home.d.ts.map +1 -1
  125. package/dist/components/home.js +175 -16
  126. package/dist/components/home.js.map +1 -1
  127. package/dist/components/my-decisions.d.ts +5 -0
  128. package/dist/components/my-decisions.d.ts.map +1 -1
  129. package/dist/components/my-decisions.js +3 -3
  130. package/dist/components/my-decisions.js.map +1 -1
  131. package/dist/components/people.d.ts +17 -0
  132. package/dist/components/people.d.ts.map +1 -1
  133. package/dist/components/people.js +55 -19
  134. package/dist/components/people.js.map +1 -1
  135. package/dist/components/picker.d.ts +2 -0
  136. package/dist/components/picker.d.ts.map +1 -1
  137. package/dist/components/picker.js +1 -1
  138. package/dist/components/picker.js.map +1 -1
  139. package/dist/components/pictures.d.ts +38 -10
  140. package/dist/components/pictures.d.ts.map +1 -1
  141. package/dist/components/pictures.js +195 -40
  142. package/dist/components/pictures.js.map +1 -1
  143. package/dist/components/plugin-events.d.ts +29 -0
  144. package/dist/components/plugin-events.d.ts.map +1 -0
  145. package/dist/components/plugin-events.js +139 -0
  146. package/dist/components/plugin-events.js.map +1 -0
  147. package/dist/components/plugin-frame.d.ts.map +1 -1
  148. package/dist/components/plugin-frame.js +14 -37
  149. package/dist/components/plugin-frame.js.map +1 -1
  150. package/dist/components/plugin-settings.d.ts.map +1 -1
  151. package/dist/components/plugin-settings.js +58 -7
  152. package/dist/components/plugin-settings.js.map +1 -1
  153. package/dist/components/projects.d.ts.map +1 -1
  154. package/dist/components/projects.js +30 -10
  155. package/dist/components/projects.js.map +1 -1
  156. package/dist/components/rules.d.ts +8 -10
  157. package/dist/components/rules.d.ts.map +1 -1
  158. package/dist/components/rules.js +36 -14
  159. package/dist/components/rules.js.map +1 -1
  160. package/dist/components/sessions.d.ts.map +1 -1
  161. package/dist/components/sessions.js +8 -4
  162. package/dist/components/sessions.js.map +1 -1
  163. package/dist/components/setup.d.ts +59 -0
  164. package/dist/components/setup.d.ts.map +1 -0
  165. package/dist/components/setup.js +93 -0
  166. package/dist/components/setup.js.map +1 -0
  167. package/dist/components/sign-in.js +1 -1
  168. package/dist/components/sign-in.js.map +1 -1
  169. package/dist/components/task-form.d.ts.map +1 -1
  170. package/dist/components/task-form.js +2 -2
  171. package/dist/components/task-form.js.map +1 -1
  172. package/dist/components/task-list.d.ts +7 -6
  173. package/dist/components/task-list.d.ts.map +1 -1
  174. package/dist/components/task-list.js.map +1 -1
  175. package/dist/components/task-view.d.ts +3 -0
  176. package/dist/components/task-view.d.ts.map +1 -1
  177. package/dist/components/task-view.js +1 -1
  178. package/dist/components/task-view.js.map +1 -1
  179. package/dist/components/ui.d.ts +78 -8
  180. package/dist/components/ui.d.ts.map +1 -1
  181. package/dist/components/ui.js +88 -9
  182. package/dist/components/ui.js.map +1 -1
  183. package/dist/components/work.d.ts +5 -5
  184. package/dist/components/work.d.ts.map +1 -1
  185. package/dist/components/work.js.map +1 -1
  186. package/dist/components/workspace.d.ts +17 -0
  187. package/dist/components/workspace.d.ts.map +1 -1
  188. package/dist/components/workspace.js +129 -2
  189. package/dist/components/workspace.js.map +1 -1
  190. package/dist/connect-page.d.ts.map +1 -1
  191. package/dist/connect-page.js +5 -2
  192. package/dist/connect-page.js.map +1 -1
  193. package/dist/console.css +7551 -4580
  194. package/dist/console.d.ts +20 -0
  195. package/dist/console.d.ts.map +1 -1
  196. package/dist/console.js +331 -57
  197. package/dist/console.js.map +1 -1
  198. package/dist/data.d.ts +22 -1
  199. package/dist/data.d.ts.map +1 -1
  200. package/dist/data.js +62 -34
  201. package/dist/data.js.map +1 -1
  202. package/dist/desk-page.d.ts +38 -0
  203. package/dist/desk-page.d.ts.map +1 -0
  204. package/dist/desk-page.js +184 -0
  205. package/dist/desk-page.js.map +1 -0
  206. package/dist/desk-records-page.d.ts +18 -0
  207. package/dist/desk-records-page.d.ts.map +1 -0
  208. package/dist/desk-records-page.js +130 -0
  209. package/dist/desk-records-page.js.map +1 -0
  210. package/dist/desk-records.d.ts +247 -0
  211. package/dist/desk-records.d.ts.map +1 -0
  212. package/dist/desk-records.js +543 -0
  213. package/dist/desk-records.js.map +1 -0
  214. package/dist/desk.d.ts +122 -0
  215. package/dist/desk.d.ts.map +1 -0
  216. package/dist/desk.js +211 -0
  217. package/dist/desk.js.map +1 -0
  218. package/dist/feed-stream.d.ts +39 -0
  219. package/dist/feed-stream.d.ts.map +1 -0
  220. package/dist/feed-stream.js +117 -0
  221. package/dist/feed-stream.js.map +1 -0
  222. package/dist/glances.d.ts +39 -0
  223. package/dist/glances.d.ts.map +1 -0
  224. package/dist/glances.js +94 -0
  225. package/dist/glances.js.map +1 -0
  226. package/dist/home-tiles.d.ts +69 -5
  227. package/dist/home-tiles.d.ts.map +1 -1
  228. package/dist/home-tiles.js +347 -9
  229. package/dist/home-tiles.js.map +1 -1
  230. package/dist/i18n/en.d.ts +773 -3
  231. package/dist/i18n/en.d.ts.map +1 -1
  232. package/dist/i18n/en.js +770 -9
  233. package/dist/i18n/en.js.map +1 -1
  234. package/dist/i18n/ko.d.ts.map +1 -1
  235. package/dist/i18n/ko.js +736 -9
  236. package/dist/i18n/ko.js.map +1 -1
  237. package/dist/index.d.ts +19 -7
  238. package/dist/index.d.ts.map +1 -1
  239. package/dist/index.js +17 -5
  240. package/dist/index.js.map +1 -1
  241. package/dist/limits.d.ts +67 -0
  242. package/dist/limits.d.ts.map +1 -1
  243. package/dist/limits.js +67 -0
  244. package/dist/limits.js.map +1 -1
  245. package/dist/onboarding.d.ts +21 -0
  246. package/dist/onboarding.d.ts.map +1 -0
  247. package/dist/onboarding.js +43 -0
  248. package/dist/onboarding.js.map +1 -0
  249. package/dist/persona.d.ts +34 -0
  250. package/dist/persona.d.ts.map +1 -0
  251. package/dist/persona.js +71 -0
  252. package/dist/persona.js.map +1 -0
  253. package/dist/plugin/context.d.ts +42 -11
  254. package/dist/plugin/context.d.ts.map +1 -1
  255. package/dist/plugin/limits.d.ts +2 -0
  256. package/dist/plugin/limits.d.ts.map +1 -1
  257. package/dist/plugin/limits.js +2 -0
  258. package/dist/plugin/limits.js.map +1 -1
  259. package/dist/plugin/manifest.d.ts +13 -0
  260. package/dist/plugin/manifest.d.ts.map +1 -1
  261. package/dist/plugin/manifest.js +34 -4
  262. package/dist/plugin/manifest.js.map +1 -1
  263. package/dist/plugin/rest-schemas.d.ts +56 -0
  264. package/dist/plugin/rest-schemas.d.ts.map +1 -1
  265. package/dist/plugin/rest-schemas.js +42 -0
  266. package/dist/plugin/rest-schemas.js.map +1 -1
  267. package/dist/plugin/sandbox.d.ts.map +1 -1
  268. package/dist/plugin/sandbox.js +4 -1
  269. package/dist/plugin/sandbox.js.map +1 -1
  270. package/dist/plugin/testing.d.ts +6 -2
  271. package/dist/plugin/testing.d.ts.map +1 -1
  272. package/dist/plugin/testing.js +52 -10
  273. package/dist/plugin/testing.js.map +1 -1
  274. package/dist/plugin.d.ts +1 -1
  275. package/dist/plugin.d.ts.map +1 -1
  276. package/dist/plugin.js +1 -1
  277. package/dist/plugin.js.map +1 -1
  278. package/dist/records.d.ts +283 -0
  279. package/dist/records.d.ts.map +1 -0
  280. package/dist/records.js +543 -0
  281. package/dist/records.js.map +1 -0
  282. package/dist/router.d.ts +50 -3
  283. package/dist/router.d.ts.map +1 -1
  284. package/dist/router.js +78 -7
  285. package/dist/router.js.map +1 -1
  286. package/dist/routes.d.ts +12 -2
  287. package/dist/routes.d.ts.map +1 -1
  288. package/dist/routes.js +14 -1
  289. package/dist/routes.js.map +1 -1
  290. package/dist/rules.d.ts +30 -11
  291. package/dist/rules.d.ts.map +1 -1
  292. package/dist/rules.js +99 -42
  293. package/dist/rules.js.map +1 -1
  294. package/dist/runner/acp.d.ts +20 -0
  295. package/dist/runner/acp.d.ts.map +1 -0
  296. package/dist/runner/acp.js +1132 -0
  297. package/dist/runner/acp.js.map +1 -0
  298. package/dist/runner/claude.d.ts +13 -0
  299. package/dist/runner/claude.d.ts.map +1 -0
  300. package/dist/runner/claude.js +615 -0
  301. package/dist/runner/claude.js.map +1 -0
  302. package/dist/runner/codex.d.ts +19 -0
  303. package/dist/runner/codex.d.ts.map +1 -0
  304. package/dist/runner/codex.js +597 -0
  305. package/dist/runner/codex.js.map +1 -0
  306. package/dist/runner/config.d.ts +35 -0
  307. package/dist/runner/config.d.ts.map +1 -0
  308. package/dist/runner/config.js +74 -0
  309. package/dist/runner/config.js.map +1 -0
  310. package/dist/runner/desk.d.ts +81 -0
  311. package/dist/runner/desk.d.ts.map +1 -0
  312. package/dist/runner/desk.js +303 -0
  313. package/dist/runner/desk.js.map +1 -0
  314. package/dist/runner/launchd.d.ts +7 -0
  315. package/dist/runner/launchd.d.ts.map +1 -0
  316. package/dist/runner/launchd.js +78 -0
  317. package/dist/runner/launchd.js.map +1 -0
  318. package/dist/runner/message.d.ts +66 -0
  319. package/dist/runner/message.d.ts.map +1 -0
  320. package/dist/runner/message.js +181 -0
  321. package/dist/runner/message.js.map +1 -0
  322. package/dist/runner/modules.d.ts +13 -0
  323. package/dist/runner/modules.d.ts.map +1 -0
  324. package/dist/runner/modules.js +30 -0
  325. package/dist/runner/modules.js.map +1 -0
  326. package/dist/runner/process.d.ts +7 -0
  327. package/dist/runner/process.d.ts.map +1 -0
  328. package/dist/runner/process.js +65 -0
  329. package/dist/runner/process.js.map +1 -0
  330. package/dist/runner/redact.d.ts +48 -0
  331. package/dist/runner/redact.d.ts.map +1 -0
  332. package/dist/runner/redact.js +214 -0
  333. package/dist/runner/redact.js.map +1 -0
  334. package/dist/runner/registry.d.ts +37 -0
  335. package/dist/runner/registry.d.ts.map +1 -0
  336. package/dist/runner/registry.js +26 -0
  337. package/dist/runner/registry.js.map +1 -0
  338. package/dist/runner/runner.d.ts +130 -0
  339. package/dist/runner/runner.d.ts.map +1 -0
  340. package/dist/runner/runner.js +1551 -0
  341. package/dist/runner/runner.js.map +1 -0
  342. package/dist/runner/slack.d.ts +16 -0
  343. package/dist/runner/slack.d.ts.map +1 -0
  344. package/dist/runner/slack.js +157 -0
  345. package/dist/runner/slack.js.map +1 -0
  346. package/dist/runner/systemd-user.d.ts +7 -0
  347. package/dist/runner/systemd-user.d.ts.map +1 -0
  348. package/dist/runner/systemd-user.js +93 -0
  349. package/dist/runner/systemd-user.js.map +1 -0
  350. package/dist/runner/task-scheduler.d.ts +38 -0
  351. package/dist/runner/task-scheduler.d.ts.map +1 -0
  352. package/dist/runner/task-scheduler.js +216 -0
  353. package/dist/runner/task-scheduler.js.map +1 -0
  354. package/dist/runner/types.d.ts +315 -0
  355. package/dist/runner/types.d.ts.map +1 -0
  356. package/dist/runner/types.js +24 -0
  357. package/dist/runner/types.js.map +1 -0
  358. package/dist/runner.d.ts +18 -0
  359. package/dist/runner.d.ts.map +1 -0
  360. package/dist/runner.js +20 -0
  361. package/dist/runner.js.map +1 -0
  362. package/dist/schemas.d.ts +6082 -1295
  363. package/dist/schemas.d.ts.map +1 -1
  364. package/dist/schemas.js +930 -31
  365. package/dist/schemas.js.map +1 -1
  366. package/dist/services.d.ts +110 -0
  367. package/dist/services.d.ts.map +1 -0
  368. package/dist/services.js +305 -0
  369. package/dist/services.js.map +1 -0
  370. package/dist/setup-guide.d.ts +64 -0
  371. package/dist/setup-guide.d.ts.map +1 -0
  372. package/dist/setup-guide.js +256 -0
  373. package/dist/setup-guide.js.map +1 -0
  374. package/dist/setup-page.d.ts +6 -0
  375. package/dist/setup-page.d.ts.map +1 -0
  376. package/dist/setup-page.js +29 -0
  377. package/dist/setup-page.js.map +1 -0
  378. package/dist/sse.d.ts +15 -0
  379. package/dist/sse.d.ts.map +1 -0
  380. package/dist/sse.js +73 -0
  381. package/dist/sse.js.map +1 -0
  382. package/dist/tab-title.d.ts +6 -0
  383. package/dist/tab-title.d.ts.map +1 -0
  384. package/dist/tab-title.js +22 -0
  385. package/dist/tab-title.js.map +1 -0
  386. package/dist/tokens.d.ts.map +1 -1
  387. package/dist/tokens.js +3 -0
  388. package/dist/tokens.js.map +1 -1
  389. package/dist/use-action.d.ts +5 -2
  390. package/dist/use-action.d.ts.map +1 -1
  391. package/dist/use-action.js +6 -1
  392. package/dist/use-action.js.map +1 -1
  393. package/dist/vocabulary.d.ts +84 -4
  394. package/dist/vocabulary.d.ts.map +1 -1
  395. package/dist/vocabulary.js +115 -3
  396. package/dist/vocabulary.js.map +1 -1
  397. package/docs/specs/cli.md +147 -41
  398. package/docs/specs/plugins.md +37 -27
  399. package/docs/specs/records.md +113 -0
  400. package/docs/specs/rest.md +155 -20
  401. package/docs/specs/runner.md +347 -0
  402. package/package.json +12 -3
  403. package/skills/building-a-console/SKILL.md +4 -4
  404. package/skills/building-a-console/references/configuring.md +1 -0
  405. package/skills/building-a-plugin/SKILL.md +7 -7
  406. package/skills/deploying-a-console/SKILL.md +4 -4
  407. package/skills/deploying-a-console/references/resources.md +48 -8
  408. package/skills/deploying-a-console/references/running-it-again.md +3 -2
  409. package/skills/keeping-a-desk/SKILL.md +133 -0
  410. package/skills/keeping-a-desk/collections.md +96 -0
  411. package/skills/planning-the-board/SKILL.md +14 -18
  412. package/skills/planning-the-board/references/a-task.md +2 -2
  413. package/skills/planning-the-board/references/project-rules.md +13 -14
  414. package/skills/planning-the-board/references/setting-up.md +22 -9
  415. package/skills/running-an-agent/SKILL.md +107 -0
  416. package/skills/running-an-agent/references/slack-app.md +61 -0
  417. package/skills/working-the-board/SKILL.md +66 -39
  418. package/skills/working-the-board/references/terms.md +9 -5
  419. package/skills/working-the-board/references/the-pack.md +14 -9
  420. package/skills/working-the-board/references/the-sentence.md +2 -2
  421. package/src/agent-page.tsx +1039 -0
  422. package/src/agent-stream.ts +199 -0
  423. package/src/api.ts +317 -2
  424. package/src/avatar.ts +1506 -0
  425. package/src/charts.ts +250 -0
  426. package/src/cli/cli.ts +3210 -503
  427. package/src/cli/command-words.ts +56 -0
  428. package/src/cli/credentials.ts +188 -16
  429. package/src/cli/directory.ts +28 -10
  430. package/src/cli/format.ts +470 -67
  431. package/src/cli/help.ts +233 -61
  432. package/src/cli/main.ts +89 -0
  433. package/src/cli/pack.ts +332 -263
  434. package/src/cli/plugin-check.ts +275 -34
  435. package/src/cli/plugin-cli.ts +28 -4
  436. package/src/cli/plugin-main.ts +1 -0
  437. package/src/cli/runner-host.ts +188 -0
  438. package/src/cli/serve.ts +320 -5
  439. package/src/cli/setup-machine.ts +153 -0
  440. package/src/client.ts +711 -126
  441. package/src/compat.ts +2 -2
  442. package/src/components/agent-page.tsx +1946 -0
  443. package/src/components/agents.tsx +638 -0
  444. package/src/components/calendar.tsx +74 -53
  445. package/src/components/charts.tsx +680 -0
  446. package/src/components/comments.tsx +3 -0
  447. package/src/components/connect.tsx +37 -2
  448. package/src/components/decision-form.tsx +89 -51
  449. package/src/components/decision-list.tsx +140 -4
  450. package/src/components/desk-records.tsx +724 -0
  451. package/src/components/desk.tsx +471 -0
  452. package/src/components/event-feed.tsx +30 -1
  453. package/src/components/home.tsx +353 -12
  454. package/src/components/my-decisions.tsx +8 -2
  455. package/src/components/people.tsx +300 -203
  456. package/src/components/picker.tsx +3 -1
  457. package/src/components/pictures.tsx +256 -44
  458. package/src/components/plugin-events.ts +159 -0
  459. package/src/components/plugin-frame.tsx +14 -38
  460. package/src/components/plugin-settings.tsx +178 -22
  461. package/src/components/projects.tsx +33 -15
  462. package/src/components/rules.tsx +96 -36
  463. package/src/components/sessions.tsx +7 -4
  464. package/src/components/setup.tsx +252 -0
  465. package/src/components/sign-in.tsx +1 -1
  466. package/src/components/task-form.tsx +11 -2
  467. package/src/components/task-list.tsx +7 -6
  468. package/src/components/task-view.tsx +4 -0
  469. package/src/components/ui.tsx +169 -25
  470. package/src/components/work.tsx +9 -9
  471. package/src/components/workspace.tsx +345 -4
  472. package/src/connect-page.tsx +15 -2
  473. package/src/console.tsx +657 -83
  474. package/src/data.ts +109 -43
  475. package/src/desk-page.tsx +332 -0
  476. package/src/desk-records-page.tsx +256 -0
  477. package/src/desk-records.ts +808 -0
  478. package/src/desk.ts +329 -0
  479. package/src/feed-stream.ts +144 -0
  480. package/src/glances.ts +132 -0
  481. package/src/home-tiles.ts +411 -9
  482. package/src/i18n/en.ts +828 -10
  483. package/src/i18n/ko.ts +792 -10
  484. package/src/index.ts +172 -3
  485. package/src/limits.ts +67 -0
  486. package/src/onboarding.ts +84 -0
  487. package/src/persona.ts +100 -0
  488. package/src/plugin/context.ts +55 -12
  489. package/src/plugin/limits.ts +2 -0
  490. package/src/plugin/manifest.ts +42 -3
  491. package/src/plugin/rest-schemas.ts +46 -0
  492. package/src/plugin/sandbox.ts +4 -1
  493. package/src/plugin/testing.ts +63 -12
  494. package/src/plugin.ts +2 -0
  495. package/src/records.ts +702 -0
  496. package/src/router.ts +120 -10
  497. package/src/routes.ts +17 -1
  498. package/src/rules.ts +109 -44
  499. package/src/runner/acp.ts +1267 -0
  500. package/src/runner/claude.ts +695 -0
  501. package/src/runner/codex.ts +691 -0
  502. package/src/runner/config.ts +97 -0
  503. package/src/runner/desk.ts +377 -0
  504. package/src/runner/launchd.ts +86 -0
  505. package/src/runner/message.ts +232 -0
  506. package/src/runner/modules.ts +30 -0
  507. package/src/runner/process.ts +72 -0
  508. package/src/runner/redact.ts +242 -0
  509. package/src/runner/registry.ts +67 -0
  510. package/src/runner/runner.ts +1879 -0
  511. package/src/runner/slack.ts +180 -0
  512. package/src/runner/systemd-user.ts +103 -0
  513. package/src/runner/task-scheduler.ts +236 -0
  514. package/src/runner/types.ts +334 -0
  515. package/src/runner.ts +110 -0
  516. package/src/schemas.ts +1183 -30
  517. package/src/services.ts +424 -0
  518. package/src/setup-guide.ts +336 -0
  519. package/src/setup-page.tsx +46 -0
  520. package/src/sse.ts +84 -0
  521. package/src/styles/README.md +111 -0
  522. package/src/styles/base.css +130 -0
  523. package/src/styles/console.css +85 -7095
  524. package/src/styles/drawn-by-pages.json +256 -0
  525. package/src/styles/pages/agents.css +1195 -0
  526. package/src/styles/pages/board.css +380 -0
  527. package/src/styles/pages/calendar.css +214 -0
  528. package/src/styles/pages/connect.css +182 -0
  529. package/src/styles/pages/decisions.css +370 -0
  530. package/src/styles/pages/desk.css +126 -0
  531. package/src/styles/pages/documents.css +273 -0
  532. package/src/styles/pages/feed.css +118 -0
  533. package/src/styles/pages/home.css +718 -0
  534. package/src/styles/pages/people.css +90 -0
  535. package/src/styles/pages/plugins.css +212 -0
  536. package/src/styles/pages/roadmap.css +377 -0
  537. package/src/styles/pages/settings.css +171 -0
  538. package/src/styles/pages/shell.css +208 -0
  539. package/src/styles/pages/sign-in.css +178 -0
  540. package/src/styles/pages/task.css +108 -0
  541. package/src/styles/pages/thread.css +331 -0
  542. package/src/styles/pages/work.css +68 -0
  543. package/src/styles/parts/avatar.css +82 -0
  544. package/src/styles/parts/badge.css +227 -0
  545. package/src/styles/parts/bars.css +80 -0
  546. package/src/styles/parts/button.css +99 -0
  547. package/src/styles/parts/calendar.css +547 -0
  548. package/src/styles/parts/callout.css +41 -0
  549. package/src/styles/parts/category.css +8 -0
  550. package/src/styles/parts/chart.css +173 -0
  551. package/src/styles/parts/chip.css +90 -0
  552. package/src/styles/parts/code.css +48 -0
  553. package/src/styles/parts/count.css +27 -0
  554. package/src/styles/parts/crumbs.css +61 -0
  555. package/src/styles/parts/detail.css +110 -0
  556. package/src/styles/parts/empty.css +21 -0
  557. package/src/styles/parts/eyebrow.css +9 -0
  558. package/src/styles/parts/facts.css +147 -0
  559. package/src/styles/parts/figures.css +65 -0
  560. package/src/styles/parts/files.css +38 -0
  561. package/src/styles/parts/filters.css +42 -0
  562. package/src/styles/parts/form.css +109 -0
  563. package/src/styles/parts/frame.css +45 -0
  564. package/src/styles/parts/input.css +243 -0
  565. package/src/styles/parts/legend.css +48 -0
  566. package/src/styles/parts/links.css +37 -0
  567. package/src/styles/parts/mark.css +79 -0
  568. package/src/styles/parts/menu.css +147 -0
  569. package/src/styles/parts/page.css +174 -0
  570. package/src/styles/parts/pager.css +19 -0
  571. package/src/styles/parts/panel.css +33 -0
  572. package/src/styles/parts/person.css +257 -0
  573. package/src/styles/parts/picker.css +185 -0
  574. package/src/styles/parts/progress.css +25 -0
  575. package/src/styles/parts/prose.css +128 -0
  576. package/src/styles/parts/rows.css +63 -0
  577. package/src/styles/parts/series.css +32 -0
  578. package/src/styles/parts/settings.css +101 -0
  579. package/src/styles/parts/share.css +25 -0
  580. package/src/styles/parts/spark.css +23 -0
  581. package/src/styles/parts/spinner.css +29 -0
  582. package/src/styles/parts/stat.css +69 -0
  583. package/src/styles/parts/steps.css +68 -0
  584. package/src/styles/parts/tabs.css +175 -0
  585. package/src/styles/parts/text.css +61 -0
  586. package/src/styles/parts/toggle.css +71 -0
  587. package/src/styles/parts/workers.css +37 -0
  588. package/src/styles/tokens.css +295 -0
  589. package/src/tab-title.ts +25 -0
  590. package/src/tokens.ts +3 -0
  591. package/src/use-action.ts +7 -2
  592. package/src/vocabulary.ts +151 -3
  593. package/template/desk-web/README.md +8 -0
  594. package/template/desk-web/index.html +13 -0
  595. package/template/desk-web/package.json +25 -0
  596. package/template/desk-web/src/main.tsx +24 -0
  597. package/template/desk-web/src/page.tsx +51 -0
  598. package/template/desk-web/tsconfig.json +16 -0
  599. package/template/desk-web/vite.config.ts +15 -0
package/src/schemas.ts CHANGED
@@ -4,22 +4,29 @@
4
4
  // Absent values are `null` on the wire, never missing keys. Changes within a version are additive.
5
5
  import {
6
6
  restBrowseSchema as packBrowseSchema,
7
+ restCodeSchema as packCodeSchema,
7
8
  restFileSchema as packFileSchema,
8
9
  restFindSchema as packFindSchema,
9
10
  restMountSchema as packMountSchema,
11
+ restRowsSchema as packRowsSchema,
10
12
  restSkillSchema as packSkillSchema,
11
13
  } from "@skillcdn/core";
12
14
  import * as z from "zod/mini";
13
15
  import { isDocumentPath } from "./documents.js";
14
16
  import {
17
+ MAX_AGENT_ELSEWHERE,
15
18
  MAX_AGENT_LENGTH,
19
+ MAX_AGENT_SECRET_BYTES,
20
+ MAX_AGENT_SECRET_NAME_LENGTH,
16
21
  MAX_BODY_LENGTH,
17
22
  MAX_CATEGORY_KEY_LENGTH,
18
23
  MAX_CATEGORY_NAME_LENGTH,
19
24
  MAX_DECIDERS,
20
25
  MAX_DOCUMENT_LENGTH,
21
26
  MAX_DOCUMENT_PATH_LENGTH,
27
+ MAX_ELSEWHERE_NAME_LENGTH,
22
28
  MAX_FILE_NAME_LENGTH,
29
+ MAX_HANDLE_LENGTH,
23
30
  MAX_HOME_ROW,
24
31
  MAX_HOME_TILES,
25
32
  MAX_LANGUAGE_TAG_LENGTH,
@@ -29,13 +36,22 @@ import {
29
36
  MAX_NOTE_LENGTH,
30
37
  MAX_OPTION_LABEL_LENGTH,
31
38
  MAX_OPTIONS,
39
+ MAX_PERSON_NAME_LENGTH,
40
+ MAX_PERSON_TITLE_LENGTH,
32
41
  MAX_PROJECT_DESCRIPTION_LENGTH,
33
42
  MAX_PROJECT_KEY_LENGTH,
34
43
  MAX_PROJECT_NAME_LENGTH,
35
44
  MAX_PROJECT_SYMBOL_LENGTH,
36
45
  MAX_QUESTION_LENGTH,
37
46
  MAX_RULES_LENGTH,
47
+ MAX_RUNNER_LINE_LENGTH,
48
+ MAX_RUNNER_OFFERS,
49
+ MAX_SEAL_REASON_LENGTH,
38
50
  MAX_SECRET_LENGTH,
51
+ MAX_SERVICE_PARAMETERS,
52
+ MAX_SERVICE_VALUE_LENGTH,
53
+ MAX_SIGNAL_KEY_LENGTH,
54
+ MAX_SIGNAL_LENGTH,
39
55
  MAX_SKILLS_ADDRESS_LENGTH,
40
56
  MAX_SUMMARY_LENGTH,
41
57
  MAX_TEAM_KEY_LENGTH,
@@ -43,23 +59,34 @@ import {
43
59
  MAX_TITLE_LENGTH,
44
60
  MAX_TOKEN_DAYS,
45
61
  MAX_TOKEN_NAME_LENGTH,
62
+ MAX_TRANSCRIPT_ATTACHMENTS,
63
+ MAX_TRANSCRIPT_BATCH,
64
+ MAX_TRANSCRIPT_FACT_LENGTH,
65
+ MAX_TRANSCRIPT_FACT_NAME_LENGTH,
66
+ MAX_TRANSCRIPT_FACTS,
67
+ MAX_TRANSCRIPT_TEXT_BYTES,
46
68
  MAX_URL_LENGTH,
47
69
  MAX_WORKERS,
70
+ MIN_HANDLE_LENGTH,
48
71
  MIN_OPTIONS,
49
72
  } from "./limits.js";
50
73
  import { PLUGIN_WIDGET_SIZE_NAMES } from "./plugin/manifest.js";
51
74
  import { hasForbiddenCodePoint } from "./text.js";
52
75
  import {
76
+ AGENT_STATE_REASONS,
77
+ AGENT_STATES,
53
78
  ARTIFACT_KINDS,
54
79
  CATEGORY_COLORS,
55
80
  COLOR_NAMES,
56
81
  CONSOLE_LANGUAGES,
57
82
  EVENT_KINDS,
83
+ FIRST_SIGN_INS,
58
84
  GOAL_STATES,
59
85
  LINK_SOURCES,
60
86
  MEMBERSHIP_SOURCES,
61
87
  PACK_CONNECT_ENDINGS,
62
88
  PEOPLE_VISIBILITIES,
89
+ PERSON_KINDS,
63
90
  PERSON_ROLES,
64
91
  PERSON_STATUSES,
65
92
  PLUGIN_COMMAND_OUTCOMES,
@@ -71,9 +98,17 @@ import {
71
98
  RULES_SOURCES,
72
99
  RUN_ENDINGS,
73
100
  RUN_STATUSES,
101
+ SECRET_ACCESSES,
102
+ SERVICE_ROLES,
103
+ SESSION_ENDS,
104
+ SESSION_KINDS,
105
+ type ServiceRole,
106
+ SIGNAL_KINDS,
107
+ SIGNAL_SOURCES,
74
108
  SKILLS_STATUSES,
75
109
  TASK_PRIORITIES,
76
110
  TASK_STATES,
111
+ TRANSCRIPT_KINDS,
77
112
  WEEK_STARTS,
78
113
  } from "./vocabulary.js";
79
114
 
@@ -115,6 +150,36 @@ const languageTag = z
115
150
  z.regex(/^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$/, "must be a language tag"),
116
151
  );
117
152
 
153
+ /** One part of an avatar: which of the set's choices of that part, by its place in the set. */
154
+ const avatarPart = z.int().check(z.gte(0), z.lte(255));
155
+
156
+ /**
157
+ * What an agent account's avatar is made of (ADR-0084, ADR-0097): a small planet, its body, what
158
+ * lies on its surface, the ramp of colours both are drawn in, and one thing beside it or
159
+ * nothing, on a ground; each a place in the set the package ships, with that set's version, and
160
+ * the seed the squares on the ground are strewn by. The names of the parts are older than the
161
+ * planets and say which list of a set each is a place in. Nothing drawn is kept or sent: whoever
162
+ * shows the picture draws it from these, with the package's own function. A released set never
163
+ * changes, so an avatar keeps the look it was made with.
164
+ */
165
+ export const restAvatarPartsSchema = z.object({
166
+ /** The version of the set the places are in. */
167
+ set: z.int().check(z.gte(1), z.lte(9999)),
168
+ /** The ramp of colours: a place among the set's `ramps`. */
169
+ palette: avatarPart,
170
+ /** The colour behind everything: a place among the set's `grounds`. */
171
+ ground: avatarPart,
172
+ /** The body: a place among the set's `bodies`. */
173
+ form: avatarPart,
174
+ /** What lies on the body: a place among the set's `surfaces`. */
175
+ material: avatarPart,
176
+ /** What stands beside the body, a place among the set's `accents`: `0` for nothing. */
177
+ accent: avatarPart,
178
+ /** The seed of the squares strewn over the ground: two avatars alike in every other part differ in them. */
179
+ vein: avatarPart,
180
+ });
181
+ export type RestAvatarParts = z.infer<typeof restAvatarPartsSchema>;
182
+
118
183
  export const restPersonSchema = z.object({
119
184
  id: uuid,
120
185
  /** What the account is called at its provider: a login at the git host, an address at Google. */
@@ -153,6 +218,33 @@ export const restPersonSchema = z.object({
153
218
  * carries none. Answered from 0.4.5 and read as optional.
154
219
  */
155
220
  email: z.optional(z.nullable(z.string())),
221
+ /**
222
+ * What the member is (ADR-0084): a person, or an agent account, a member of its own under the
223
+ * same rules. Answered from 0.5.0 and read as optional: a person, where a console says nothing.
224
+ */
225
+ kind: z.optional(z.enum(PERSON_KINDS)),
226
+ /**
227
+ * An agent account's handle, what the pages and the command call it by (`mira`, addressed as
228
+ * `@mira`); it never changes. `null` for a person. Answered from 0.5.0 and read as optional.
229
+ */
230
+ handle: z.optional(z.nullable(z.string())),
231
+ /**
232
+ * What the member does, in a line (`Release engineer`): every member's, a person's as an agent
233
+ * account's, kept by an administrator; `null` for none. It is not `role`. Answered from 0.5.0
234
+ * and read as optional.
235
+ */
236
+ title: z.optional(z.nullable(z.string())),
237
+ /**
238
+ * What an agent account's avatar is drawn from, where the picture of a person is `avatar`,
239
+ * the provider's; `null` for a person. Answered from 0.5.0 and read as optional.
240
+ */
241
+ avatarParts: z.optional(z.nullable(restAvatarPartsSchema)),
242
+ /**
243
+ * `true` for an agent account nobody has signed in with yet: made by an administrator, so that
244
+ * work can be assigned to it, and "invited" on the pages until its first sign-in. Not a status
245
+ * of the directory. Left out otherwise.
246
+ */
247
+ invited: z.optional(z.boolean()),
156
248
  });
157
249
  export type RestPerson = z.infer<typeof restPersonSchema>;
158
250
 
@@ -333,8 +425,154 @@ export type RestMePatch = z.infer<typeof restMePatchSchema>;
333
425
  * the board is called, what the deployment's configuration says of it, and the settings an
334
426
  * administrator keeps on the Settings page (ADR-0035).
335
427
  */
428
+ const DOMAIN =
429
+ /^(?=.{4,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
430
+
431
+ /** Whether `value` is spelled as a mail and web domain is, in small letters (`acme.example`). */
432
+ export function isDomain(value: string): boolean {
433
+ return DOMAIN.test(value);
434
+ }
435
+
436
+ const SERVICE_KIND = /^[a-z][a-z0-9-]{0,39}$/;
437
+ const SERVICE_PARAMETER = /^[a-z][A-Za-z0-9]{0,39}$/;
438
+ /** A name's template: what a name is made of, and the three places. */
439
+ const SERVICE_TEMPLATE = /^(?:[A-Za-z0-9._@-]|\{(?:workspace|agent|domain)\})+$/;
440
+ /** An organization or an account as a git host spells one. */
441
+ const HOST_ACCOUNT = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
442
+ /** A group as a git host that nests them spells one: `acme`, or `acme/platform`. */
443
+ const HOST_GROUP =
444
+ /^(?=.{1,200}$)[A-Za-z0-9_][A-Za-z0-9_.-]*(?:\/[A-Za-z0-9_][A-Za-z0-9_.-]*){0,7}$/;
445
+ /** The forms of account a git host has: a person's, and the one it has for a machine. */
446
+ const ACCOUNT_FORM = /^(?:user|service)$/;
447
+
448
+ /**
449
+ * The parameters the kinds the package knows take, and the roles each may be named for
450
+ * (ADR-0089). A kind that is not here is kept with whatever short parameters it came with.
451
+ */
452
+ const SERVICE_SHAPES: Readonly<
453
+ Record<
454
+ string,
455
+ {
456
+ readonly roles: readonly ServiceRole[];
457
+ readonly parameters: Readonly<Record<string, RegExp>>;
458
+ }
459
+ >
460
+ > = {
461
+ github: {
462
+ roles: ["identity", "git"],
463
+ parameters: { organization: HOST_ACCOUNT, account: SERVICE_TEMPLATE },
464
+ },
465
+ gitlab: {
466
+ roles: ["git"],
467
+ parameters: {
468
+ group: HOST_GROUP,
469
+ host: DOMAIN,
470
+ form: ACCOUNT_FORM,
471
+ account: SERVICE_TEMPLATE,
472
+ },
473
+ },
474
+ "google-workspace": { roles: ["identity"], parameters: { account: SERVICE_TEMPLATE } },
475
+ slack: { roles: ["messenger"], parameters: { workspace: DOMAIN } },
476
+ };
477
+
478
+ /**
479
+ * What is wrong with a service named for a role, as a fact a page puts into its own words: its
480
+ * kind is no kind, it has more parameters than one may or one that is no word, it is named for
481
+ * a role it may not have, or a parameter is one the kind does not take or is not spelled as one.
482
+ */
483
+ export type ServiceProblem =
484
+ | { readonly what: "kind" | "parameters" | "role" }
485
+ | { readonly what: "unknown" | "spelling"; readonly parameter: string };
486
+
487
+ /**
488
+ * What is wrong with a service named for a role, or nothing: a kind the package knows takes its
489
+ * own parameters, spelled as they are, and is named for a role it may have.
490
+ */
491
+ export function serviceProblemOf(
492
+ role: ServiceRole,
493
+ service: Readonly<Record<string, string>>,
494
+ ): ServiceProblem | undefined {
495
+ const kind = service.kind;
496
+ if (kind === undefined || !SERVICE_KIND.test(kind)) {
497
+ return { what: "kind" };
498
+ }
499
+ const names = Object.keys(service).filter((name) => name !== "kind");
500
+ if (
501
+ names.length > MAX_SERVICE_PARAMETERS ||
502
+ names.some((name) => !SERVICE_PARAMETER.test(name))
503
+ ) {
504
+ return { what: "parameters" };
505
+ }
506
+ const shape = SERVICE_SHAPES[kind];
507
+ if (shape === undefined) {
508
+ return undefined;
509
+ }
510
+ if (!shape.roles.includes(role)) {
511
+ return { what: "role" };
512
+ }
513
+ for (const name of names) {
514
+ const spelled = shape.parameters[name];
515
+ if (spelled === undefined) {
516
+ return { what: "unknown", parameter: name };
517
+ }
518
+ if (!spelled.test(service[name] ?? "")) {
519
+ return { what: "spelling", parameter: name };
520
+ }
521
+ }
522
+ return undefined;
523
+ }
524
+
525
+ /** What is wrong with a service named for a role, in a few English words for a program, or nothing. */
526
+ export function serviceProblem(
527
+ role: ServiceRole,
528
+ service: Readonly<Record<string, string>>,
529
+ ): string | undefined {
530
+ const problem = serviceProblemOf(role, service);
531
+ if (problem === undefined) {
532
+ return undefined;
533
+ }
534
+ switch (problem.what) {
535
+ case "kind":
536
+ return "names no kind";
537
+ case "parameters":
538
+ return "has more parameters than one may, or one that is no word";
539
+ case "role":
540
+ return `is no ${role} service`;
541
+ case "unknown":
542
+ return `takes no ${problem.parameter}`;
543
+ case "spelling":
544
+ return `${problem.parameter} is not spelled as one is`;
545
+ }
546
+ }
547
+
548
+ /**
549
+ * A service a workspace's agents work with (ADR-0089), as it is answered: its `kind`, and its
550
+ * parameters as short strings. No secret is among them.
551
+ */
552
+ export const restWorkspaceServiceSchema = z.record(z.string(), z.string());
553
+ export type RestWorkspaceService = z.infer<typeof restWorkspaceServiceSchema>;
554
+
555
+ /** The services of a workspace, by what each is to its agents; a role with none is left out. */
556
+ export const restWorkspaceServicesSchema = z.object({
557
+ identity: z.optional(restWorkspaceServiceSchema),
558
+ git: z.optional(restWorkspaceServiceSchema),
559
+ messenger: z.optional(restWorkspaceServiceSchema),
560
+ });
561
+ export type RestWorkspaceServices = z.infer<typeof restWorkspaceServicesSchema>;
562
+
563
+ /** A service as an administrator names one: a kind and a few parameters, each a short line. */
564
+ const serviceInput = z.record(z.string(), line(MAX_SERVICE_VALUE_LENGTH));
565
+
336
566
  export const restWorkspaceSchema = z.object({
337
567
  name: z.string(),
568
+ /**
569
+ * The organization's short name (`acme`) and its mail and web domain (ADR-0089), from which
570
+ * with an agent account's handle a name at a service is put together; `null` each for none.
571
+ * And the services its agents work with. Answered from 0.5.0 and read as optional.
572
+ */
573
+ handle: z.optional(z.nullable(z.string())),
574
+ domain: z.optional(z.nullable(z.string())),
575
+ services: z.optional(restWorkspaceServicesSchema),
338
576
  /** The most days a token may be good for here, or `null` when a person chooses. */
339
577
  tokenDaysAtMost: z.nullable(z.int().check(z.positive())),
340
578
  /**
@@ -383,18 +621,42 @@ export const restWorkspacePatchSchema = z
383
621
  timeZone: z.optional(z.nullable(timeZoneName)),
384
622
  /** One of the languages the console speaks, or `null` for none. */
385
623
  language: z.optional(z.nullable(z.enum(CONSOLE_LANGUAGES))),
624
+ /** The organization's short name, spelled as an agent account's handle is; `null` for none. */
625
+ handle: z.optional(z.nullable(z.string().check(z.refine(isHandle, "is a short name")))),
626
+ /** Its mail and web domain, in small letters; `null` for none. */
627
+ domain: z.optional(z.nullable(z.string().check(z.refine(isDomain, "is a domain")))),
628
+ /** The services named anew, by role: one left out stays as it is, `null` takes one away. */
629
+ services: z.optional(
630
+ z.object({
631
+ identity: z.optional(z.nullable(serviceInput)),
632
+ git: z.optional(z.nullable(serviceInput)),
633
+ messenger: z.optional(z.nullable(serviceInput)),
634
+ }),
635
+ ),
386
636
  })
387
637
  .check(
388
638
  z.refine((patch) => Object.values(patch).some((value) => value !== undefined), {
389
639
  message: "names nothing to change",
390
640
  }),
641
+ z.refine(
642
+ (patch) =>
643
+ SERVICE_ROLES.every((role) => {
644
+ const service = patch.services?.[role];
645
+ return (
646
+ service === undefined || service === null || serviceProblem(role, service) === undefined
647
+ );
648
+ }),
649
+ { message: "names a service that does not read" },
650
+ ),
391
651
  );
392
652
  export type RestWorkspacePatch = z.infer<typeof restWorkspacePatchSchema>;
393
653
 
394
654
  /**
395
655
  * `GET /api/v1/me`: the workspace, who the session cookie says is signed in (or `null`), the
396
656
  * language they chose (or `null`), and the identity providers people sign in through, none
397
- * where nobody can.
657
+ * where nobody can. Nobody signed in is told the workspace's name and its language alone: the
658
+ * most days of a token is `null` then, the skills' source is empty and their address `null`,
659
+ * and everything read as optional is left out.
398
660
  */
399
661
  export const restMeSchema = z.object({
400
662
  workspace: restWorkspaceSchema,
@@ -404,6 +666,15 @@ export const restMeSchema = z.object({
404
666
  * person's own knows it holds one. `null` on a session, and for nobody.
405
667
  */
406
668
  agent: z.nullable(z.string()),
669
+ /**
670
+ * The session asking, when a session asks (ADR-0084): a browser's, or the command's, signed in
671
+ * as the account itself, with what it called itself. A console served through the command is
672
+ * told a command's session by it, as it is told a token by `agent`, and offers nothing either
673
+ * cannot do. `null` on a token, and for nobody. Answered from 0.5.0 and read as optional.
674
+ */
675
+ session: z.optional(
676
+ z.nullable(z.object({ kind: z.enum(SESSION_KINDS), name: z.nullable(z.string()) })),
677
+ ),
407
678
  /** The language the person reads in (ADR-0065): the one they chose, else the one the pages first saw them in; `null` until then. */
408
679
  language: z.nullable(languageTag),
409
680
  /**
@@ -452,6 +723,11 @@ export const restPersonPatchSchema = z
452
723
  managerId: z.optional(z.nullable(uuid)),
453
724
  /** The person's work email, one per workspace, or `null` for none; an administrator's to write. */
454
725
  email: z.optional(z.nullable(z.email().check(z.maxLength(254)))),
726
+ /**
727
+ * What the member does, in a line, or `null` for none (ADR-0084): an administrator's to write
728
+ * of anyone, and of an agent account its supervisors' too.
729
+ */
730
+ title: z.optional(z.nullable(line(MAX_PERSON_TITLE_LENGTH))),
455
731
  })
456
732
  .check(
457
733
  z.refine(
@@ -459,12 +735,689 @@ export const restPersonPatchSchema = z
459
735
  patch.role !== undefined ||
460
736
  patch.status !== undefined ||
461
737
  patch.managerId !== undefined ||
462
- patch.email !== undefined,
463
- "must name a role, a status, a manager or an email",
738
+ patch.email !== undefined ||
739
+ patch.title !== undefined,
740
+ "must name a role, a status, a manager, an email or a title",
464
741
  ),
465
742
  );
466
743
  export type RestPersonPatch = z.infer<typeof restPersonPatchSchema>;
467
744
 
745
+ /**
746
+ * The words that are the console's own, which no agent account may be called: what stands under
747
+ * `/agents/` and `/api/v1/agents/` in an address, and what follows `console agent` in the
748
+ * command, where a handle stands too.
749
+ */
750
+ export const RESERVED_HANDLES: readonly string[] = [
751
+ "new",
752
+ "me",
753
+ "proposals",
754
+ "setup",
755
+ "invite",
756
+ "secret",
757
+ "secrets",
758
+ "signals",
759
+ "tell",
760
+ "interrupt",
761
+ "stop",
762
+ "restart",
763
+ "reset",
764
+ "set",
765
+ "wake",
766
+ ];
767
+
768
+ /** Whether `value` is spelled as a handle is: lowercase letters, digits and hyphens, a letter or a digit first and last, of the length one may be. */
769
+ export function isHandle(value: string): boolean {
770
+ return (
771
+ value.length >= MIN_HANDLE_LENGTH &&
772
+ value.length <= MAX_HANDLE_LENGTH &&
773
+ /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(value)
774
+ );
775
+ }
776
+
777
+ /**
778
+ * An agent account's handle (ADR-0084): what the pages and the command call it by, `@mira`. One
779
+ * among the workspace's agent accounts, and immutable once the account is made.
780
+ */
781
+ const handle = z.string().check(
782
+ z.refine(isHandle, "must be 2 to 39 lowercase letters, digits and hyphens"),
783
+ z.refine((value) => !RESERVED_HANDLES.includes(value), "is a word the addresses use"),
784
+ );
785
+
786
+ /** A line a runner says: bounded, without characters that hide. */
787
+ const runnerLine = line(MAX_RUNNER_LINE_LENGTH);
788
+ /**
789
+ * How a model or a level of effort is spelled for the console to take it: letters, digits and a
790
+ * few marks, beginning with a letter or a digit. The runner holds what a product says of itself
791
+ * to the same rule before it says it on, so that one name the console would refuse does not
792
+ * cost the account its heartbeat.
793
+ */
794
+ export const RUNNER_CHOICE = /^[A-Za-z0-9][A-Za-z0-9._:[\]-]*$/;
795
+ /** A model or a level of effort, as the product spells one. */
796
+ const runnerChoice = z
797
+ .string()
798
+ .check(z.minLength(1), z.maxLength(MAX_RUNNER_LINE_LENGTH), z.regex(RUNNER_CHOICE));
799
+
800
+ /** The model and the level of effort an agent runs with, or is to; `null` each for "as the product has it". */
801
+ export const restAgentChoiceSchema = z.object({
802
+ model: z.nullable(z.string()),
803
+ effort: z.nullable(z.string()),
804
+ });
805
+ export type RestAgentChoice = z.infer<typeof restAgentChoiceSchema>;
806
+
807
+ /** Where a runner runs: the machine as it calls itself, its operating system, and the OS account. */
808
+ const runnerMachine = z.object({ name: runnerLine, os: runnerLine, user: runnerLine });
809
+ /** The product a runner starts: the driver, what the product is called, its version, and whether the driver was tried with it. */
810
+ const runnerProduct = z.object({
811
+ driver: runnerLine,
812
+ name: runnerLine,
813
+ version: z.nullable(runnerLine),
814
+ tried: z.boolean(),
815
+ });
816
+ /** What the product offers to choose from, and what the driver can do. */
817
+ const runnerOffers = z.object({
818
+ models: z.array(runnerChoice).check(z.maxLength(MAX_RUNNER_OFFERS)),
819
+ efforts: z.array(runnerChoice).check(z.maxLength(MAX_RUNNER_OFFERS)),
820
+ steer: z.boolean(),
821
+ images: z.boolean(),
822
+ resume: z.boolean(),
823
+ });
824
+
825
+ /**
826
+ * What `PUT /api/v1/agents/me/runner` is sent (ADR-0085, docs/specs/runner.md): the runner's
827
+ * heartbeat, every thirty seconds and when the agent's state changes.
828
+ */
829
+ export const restRunnerHeartbeatInputSchema = z.object({
830
+ /** How the runner says its agent stands; `unheard` is the console's word, never the runner's. */
831
+ state: z.enum(["running", "stopped", "refused", "failed"]),
832
+ reason: z.enum(AGENT_STATE_REASONS),
833
+ /** The number of the last signal delivered, every one before it too: the product took it, or the record says what became of it; `0` for none. */
834
+ delivered: z.int().check(z.gte(0)),
835
+ /** The open session, or `null`. */
836
+ session: z.nullable(uuid),
837
+ machine: runnerMachine,
838
+ /** The package's version the runner runs from. */
839
+ runner: runnerLine,
840
+ product: runnerProduct,
841
+ offers: runnerOffers,
842
+ /** What the open session runs with; `null` each where the product's own choice stands. */
843
+ running: z.object({ model: z.nullable(runnerChoice), effort: z.nullable(runnerChoice) }),
844
+ });
845
+ export type RestRunnerHeartbeatInput = z.infer<typeof restRunnerHeartbeatInputSchema>;
846
+
847
+ /** What the heartbeat is answered: where the account's record of signals stands, what its supervisors chose, and how the console has the agent. */
848
+ export const restRunnerHeartbeatSchema = z.object({
849
+ latest: z.int().check(z.gte(0)),
850
+ /** The number of the last signal the console has as delivered: where a runner that lost its own count goes on from. */
851
+ delivered: z.int().check(z.gte(0)),
852
+ settings: restAgentChoiceSchema,
853
+ state: z.enum(AGENT_STATES),
854
+ });
855
+ export type RestRunnerHeartbeat = z.infer<typeof restRunnerHeartbeatSchema>;
856
+
857
+ /** How an agent account stands (ADR-0085), for whoever sees it: the state, why, since when, and when its runner was last heard from. */
858
+ export const restAgentStateSchema = z.object({
859
+ state: z.enum(AGENT_STATES),
860
+ reason: z.nullable(z.string()),
861
+ since: instant,
862
+ heardAt: z.nullable(instant),
863
+ });
864
+ export type RestAgentState = z.infer<typeof restAgentStateSchema>;
865
+
866
+ /** What a runner last said of itself, for the account's supervisors and for the account: where it runs, with what, what it offers and runs with, and what was chosen for it. */
867
+ export const restAgentRunnerSchema = z.object({
868
+ delivered: z.int(),
869
+ latest: z.int(),
870
+ session: z.nullable(uuid),
871
+ machine: z.nullable(z.object({ name: z.string(), os: z.string(), user: z.string() })),
872
+ runner: z.nullable(z.string()),
873
+ product: z.nullable(
874
+ z.object({
875
+ driver: z.string(),
876
+ name: z.string(),
877
+ version: z.nullable(z.string()),
878
+ tried: z.boolean(),
879
+ }),
880
+ ),
881
+ offers: z.nullable(
882
+ z.object({
883
+ models: z.array(z.string()),
884
+ efforts: z.array(z.string()),
885
+ steer: z.boolean(),
886
+ images: z.boolean(),
887
+ resume: z.boolean(),
888
+ }),
889
+ ),
890
+ running: z.nullable(restAgentChoiceSchema),
891
+ settings: restAgentChoiceSchema,
892
+ });
893
+ export type RestAgentRunner = z.infer<typeof restAgentRunnerSchema>;
894
+
895
+ /**
896
+ * A signal (ADR-0085): what the console sends an agent account's runner, a record numbered per
897
+ * account, with who sent it and where it came from.
898
+ */
899
+ export const restSignalSchema = z.object({
900
+ number: z.int().check(z.positive()),
901
+ kind: z.enum(SIGNAL_KINDS),
902
+ /** Who sent it, with the agent and the plugin they acted through; `null` for the console itself. */
903
+ by: z.nullable(restPersonSchema),
904
+ agent: z.nullable(z.string()),
905
+ plugin: z.nullable(z.string()),
906
+ source: z.enum(SIGNAL_SOURCES),
907
+ /** What it refers to: a task (`#412`), a briefing (`day`), a thread; `null` for a supervisor's own. */
908
+ key: z.nullable(z.string()),
909
+ text: z.string(),
910
+ /** For `set`: the model and the effort to run with from then on, the whole choice, `null` each for the product's own. */
911
+ set: z.nullable(restAgentChoiceSchema),
912
+ attachments: z.array(
913
+ z.object({ id: uuid, name: z.string(), size: count, contentType: z.string() }),
914
+ ),
915
+ at: instant,
916
+ });
917
+ export type RestSignal = z.infer<typeof restSignalSchema>;
918
+
919
+ /** `GET /api/v1/agents/<handle>/signals?before=&limit=`: the record, the newest first, and whether there is more before. */
920
+ export const restSignalsSchema = z.object({ items: z.array(restSignalSchema), more: z.boolean() });
921
+ export type RestSignals = z.infer<typeof restSignalsSchema>;
922
+
923
+ /**
924
+ * What `POST /api/v1/agents/<handle>/signals` is sent, by a supervisor: the kind, the words for
925
+ * the agent, and for `set` the model or the effort. A `tell` needs words; an `interrupt` takes
926
+ * them, and without any stops the turn under way so that what the agent was sent and has not
927
+ * taken is read now; `set` needs one of its two, a field left out staying as it is and `null`
928
+ * meaning the product's own.
929
+ */
930
+ export const restSignalInputSchema = z
931
+ .object({
932
+ kind: z.enum(SIGNAL_KINDS),
933
+ text: z.optional(paragraphs(MAX_SIGNAL_LENGTH)),
934
+ set: z.optional(
935
+ z.object({
936
+ model: z.optional(z.nullable(runnerChoice)),
937
+ effort: z.optional(z.nullable(runnerChoice)),
938
+ }),
939
+ ),
940
+ })
941
+ .check(
942
+ z.refine(
943
+ (input) => input.kind !== "tell" || (input.text ?? "").trim().length > 0,
944
+ "a tell needs words",
945
+ ),
946
+ z.refine(
947
+ (input) =>
948
+ input.kind !== "set" ||
949
+ (input.set !== undefined &&
950
+ (input.set.model !== undefined || input.set.effort !== undefined)),
951
+ "a set names a model or an effort",
952
+ ),
953
+ );
954
+ export type RestSignalInput = z.infer<typeof restSignalInputSchema>;
955
+
956
+ /**
957
+ * What `POST /api/v1/agents/me/signals` is sent, by an account's own runner (ADR-0085): a wake
958
+ * one of its wake sources raised on the machine, from the messenger, with what it is about as
959
+ * its `key`, a thread say, and someone else's words as its `text`. Nothing else is raised this
960
+ * way: a runner tells its own agent nothing in anyone's name.
961
+ */
962
+ export const restRunnerWakeSchema = z.object({
963
+ kind: z.literal("wake"),
964
+ source: z.literal("messenger"),
965
+ key: line(MAX_SIGNAL_KEY_LENGTH),
966
+ text: z.optional(paragraphs(MAX_SIGNAL_LENGTH)),
967
+ });
968
+ export type RestRunnerWake = z.infer<typeof restRunnerWakeSchema>;
969
+
970
+ /**
971
+ * The invitation that leads a machine to an agent account (ADR-0088), as it stands: when it was
972
+ * made, by whom, and when it ends. Never its code, which is shown once, when it is made.
973
+ */
974
+ export const restAgentInvitationSchema = z.object({
975
+ createdAt: instant,
976
+ expiresAt: instant,
977
+ by: z.nullable(restPersonSchema),
978
+ });
979
+ export type RestAgentInvitation = z.infer<typeof restAgentInvitationSchema>;
980
+
981
+ /** `GET /api/v1/agents/<handle>/invitation`: the invitation, or `null` where none stands. */
982
+ export const restAgentInvitationStateSchema = z.object({
983
+ invitation: z.nullable(restAgentInvitationSchema),
984
+ });
985
+ export type RestAgentInvitationState = z.infer<typeof restAgentInvitationStateSchema>;
986
+
987
+ /**
988
+ * What making an invitation answers, this once: the code, and the command that sets a machine
989
+ * up with it. The code is no credential: it says which account a setup is for.
990
+ */
991
+ export const restAgentInvitationMadeSchema = z.object({
992
+ invitation: restAgentInvitationSchema,
993
+ code: z.string(),
994
+ command: z.string(),
995
+ });
996
+ export type RestAgentInvitationMade = z.infer<typeof restAgentInvitationMadeSchema>;
997
+
998
+ /**
999
+ * `GET /api/v1/setup/<code>`: what an invitation's code opens, for whoever holds it, signed in or
1000
+ * not: the account a setup is for, with the login it signs in with; its workspace, with the
1001
+ * services its agents work with; and the console to come back to. Nothing secret.
1002
+ */
1003
+ export const restAgentSetupSchema = z.object({
1004
+ account: z.object({
1005
+ handle: z.string(),
1006
+ name: z.nullable(z.string()),
1007
+ title: z.nullable(z.string()),
1008
+ login: z.string(),
1009
+ host: z.enum(PROVIDER_KEYS),
1010
+ avatarParts: z.optional(z.nullable(restAvatarPartsSchema)),
1011
+ }),
1012
+ workspace: z.object({
1013
+ name: z.string(),
1014
+ handle: z.nullable(z.string()),
1015
+ domain: z.nullable(z.string()),
1016
+ services: restWorkspaceServicesSchema,
1017
+ }),
1018
+ console: z.object({ url: z.string() }),
1019
+ expiresAt: instant,
1020
+ });
1021
+ export type RestAgentSetup = z.infer<typeof restAgentSetupSchema>;
1022
+
1023
+ /** How many bytes of UTF-8 a text is, without encoding one that cannot be over or under the bound anyway. */
1024
+ function utf8Within(value: string, bytes: number): boolean {
1025
+ if (value.length > bytes) {
1026
+ return false;
1027
+ }
1028
+ return value.length * 3 <= bytes || new TextEncoder().encode(value).byteLength <= bytes;
1029
+ }
1030
+
1031
+ /**
1032
+ * What `POST /api/v1/agents/me/sessions` is sent (ADR-0085, docs/specs/runner.md): what the
1033
+ * session the runner begins runs, and where.
1034
+ */
1035
+ export const restAgentSessionInputSchema = z.object({
1036
+ product: runnerProduct,
1037
+ model: z.nullable(runnerChoice),
1038
+ effort: z.nullable(runnerChoice),
1039
+ /** Whether the conversation of the session before is gone on with. */
1040
+ resumed: z.boolean(),
1041
+ machine: runnerMachine,
1042
+ });
1043
+ export type RestAgentSessionInput = z.infer<typeof restAgentSessionInputSchema>;
1044
+
1045
+ /**
1046
+ * A session of an agent account's runner (ADR-0086): the lifetime of one process of its product,
1047
+ * which leaves a transcript. The row stays, and says what the session held, whatever becomes of
1048
+ * the month its events are kept under.
1049
+ */
1050
+ export const restAgentSessionSchema = z.object({
1051
+ id: uuid,
1052
+ /** The month it began in, as `2026-11`: what its events and its pictures are kept under. */
1053
+ month: z.string(),
1054
+ startedAt: instant,
1055
+ /** When it ended, and how; `null` each while it is open. */
1056
+ endedAt: z.nullable(instant),
1057
+ ended: z.nullable(z.enum(SESSION_ENDS)),
1058
+ product: z.object({
1059
+ driver: z.string(),
1060
+ name: z.string(),
1061
+ version: z.nullable(z.string()),
1062
+ tried: z.boolean(),
1063
+ }),
1064
+ model: z.nullable(z.string()),
1065
+ effort: z.nullable(z.string()),
1066
+ resumed: z.boolean(),
1067
+ machine: z.object({ name: z.string(), os: z.string(), user: z.string() }),
1068
+ /** The number of its last event; `0` for none. */
1069
+ events: count,
1070
+ lastEventAt: z.nullable(instant),
1071
+ /** Whether its events are put away: the month they are kept under is not with the database now. */
1072
+ away: z.boolean(),
1073
+ });
1074
+ export type RestAgentSession = z.infer<typeof restAgentSessionSchema>;
1075
+
1076
+ /** `GET /api/v1/agents/<handle>/sessions?before=&limit=`: the sessions, the newest first, and whether there are more before. */
1077
+ export const restAgentSessionsSchema = z.object({
1078
+ items: z.array(restAgentSessionSchema),
1079
+ more: z.boolean(),
1080
+ });
1081
+ export type RestAgentSessions = z.infer<typeof restAgentSessionsSchema>;
1082
+
1083
+ /** What `POST /api/v1/agents/me/sessions/<id>/end` is sent: how the session ended, as the runner saw it. */
1084
+ export const restAgentSessionEndInputSchema = z.object({
1085
+ how: z.enum(["stopped", "restarted", "reset", "crashed", "exited"]),
1086
+ });
1087
+ export type RestAgentSessionEndInput = z.infer<typeof restAgentSessionEndInputSchema>;
1088
+
1089
+ /** A fact about a block of a transcript: a word, a number, a yes or a no. Shown as text, never run. */
1090
+ const transcriptFact = z.union([
1091
+ z.string().check(z.maxLength(MAX_TRANSCRIPT_FACT_LENGTH)),
1092
+ z.number(),
1093
+ z.boolean(),
1094
+ z.null(),
1095
+ ]);
1096
+
1097
+ /**
1098
+ * One event of a session's transcript as its runner reports it (ADR-0086): a whole block,
1099
+ * numbered per session from 1, with what a person reads of it as text and a few facts about it.
1100
+ * The text is whatever the product said, control characters and all: it is kept as data and
1101
+ * shown as text, so nothing of it is refused but its length.
1102
+ */
1103
+ export const restTranscriptEventInputSchema = z.object({
1104
+ n: z.int().check(z.positive()),
1105
+ kind: z.enum(TRANSCRIPT_KINDS),
1106
+ /** When it happened, as the runner's clock had it. */
1107
+ at: instant,
1108
+ text: z
1109
+ .string()
1110
+ .check(z.refine((value) => utf8Within(value, MAX_TRANSCRIPT_TEXT_BYTES), "is too long")),
1111
+ data: z.optional(
1112
+ z
1113
+ .record(
1114
+ z.string().check(z.minLength(1), z.maxLength(MAX_TRANSCRIPT_FACT_NAME_LENGTH)),
1115
+ transcriptFact,
1116
+ )
1117
+ .check(
1118
+ z.refine((data) => Object.keys(data).length <= MAX_TRANSCRIPT_FACTS, "has too many facts"),
1119
+ ),
1120
+ ),
1121
+ /** The pictures of the block, by the ids their upload answered, of this session. */
1122
+ files: z.optional(z.array(uuid).check(z.maxLength(MAX_TRANSCRIPT_ATTACHMENTS))),
1123
+ });
1124
+ export type RestTranscriptEventInput = z.infer<typeof restTranscriptEventInputSchema>;
1125
+
1126
+ /** What `POST /api/v1/agents/me/sessions/<id>/events` is sent: a batch, in order. The same number sent again changes nothing. */
1127
+ export const restTranscriptBatchInputSchema = z.object({
1128
+ events: z
1129
+ .array(restTranscriptEventInputSchema)
1130
+ .check(z.minLength(1), z.maxLength(MAX_TRANSCRIPT_BATCH)),
1131
+ });
1132
+ export type RestTranscriptBatchInput = z.infer<typeof restTranscriptBatchInputSchema>;
1133
+
1134
+ /** What a batch is answered: the number of the session's last event now, which the next batch goes on from. */
1135
+ export const restTranscriptBatchSchema = z.object({ last: count });
1136
+ export type RestTranscriptBatch = z.infer<typeof restTranscriptBatchSchema>;
1137
+
1138
+ /** A picture of a transcript, as its upload answers it and as an event names it. */
1139
+ export const restTranscriptFileSchema = z.object({
1140
+ id: uuid,
1141
+ name: z.string(),
1142
+ size: count,
1143
+ contentType: z.string(),
1144
+ });
1145
+ export type RestTranscriptFile = z.infer<typeof restTranscriptFileSchema>;
1146
+
1147
+ /**
1148
+ * One event of a session's transcript as it is read (ADR-0086). `text` is the whole text, or its
1149
+ * beginning where `whole` says how many bytes the whole is, which is read apart. A sealed event
1150
+ * keeps its number, its kind and its time, and says who sealed it, when and why in place of what
1151
+ * it held.
1152
+ */
1153
+ export const restTranscriptEventSchema = z.object({
1154
+ n: z.int().check(z.positive()),
1155
+ kind: z.enum(TRANSCRIPT_KINDS),
1156
+ at: instant,
1157
+ text: z.string(),
1158
+ whole: z.nullable(count),
1159
+ data: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])),
1160
+ files: z.array(restTranscriptFileSchema),
1161
+ sealed: z.nullable(
1162
+ z.object({ by: z.nullable(restPersonSchema), at: instant, reason: z.string() }),
1163
+ ),
1164
+ });
1165
+ export type RestTranscriptEvent = z.infer<typeof restTranscriptEventSchema>;
1166
+
1167
+ /** `GET /api/v1/agents/<handle>/sessions/<id>/events?after=&limit=`: the events after a number, in order, and whether there are more. */
1168
+ export const restTranscriptEventsSchema = z.object({
1169
+ items: z.array(restTranscriptEventSchema),
1170
+ more: z.boolean(),
1171
+ });
1172
+ export type RestTranscriptEvents = z.infer<typeof restTranscriptEventsSchema>;
1173
+
1174
+ /** `GET /api/v1/agents/<handle>/sessions/<id>/events/<n>/text`: the whole text of one event, where its row keeps the beginning alone. */
1175
+ export const restTranscriptTextSchema = z.object({
1176
+ n: z.int().check(z.positive()),
1177
+ text: z.string(),
1178
+ });
1179
+ export type RestTranscriptText = z.infer<typeof restTranscriptTextSchema>;
1180
+
1181
+ /** What sealing an event is sent: why, in a line, which stays on the record in place of what the event held. */
1182
+ export const restTranscriptSealInputSchema = z.object({ reason: line(MAX_SEAL_REASON_LENGTH) });
1183
+ export type RestTranscriptSealInput = z.infer<typeof restTranscriptSealInputSchema>;
1184
+
1185
+ /** Whether `value` is spelled as a secret's name is: lowercase letters, digits, dots, hyphens and underscores, a letter or a digit first and last. */
1186
+ export function isSecretName(value: string): boolean {
1187
+ return (
1188
+ value.length <= MAX_AGENT_SECRET_NAME_LENGTH &&
1189
+ /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/.test(value)
1190
+ );
1191
+ }
1192
+
1193
+ /**
1194
+ * A secret of an agent account's store as a listing says it (ADR-0087): its name, when it was
1195
+ * set, whether a supervisor seeded it, and the day its value ends on where one is known. Never
1196
+ * its value.
1197
+ */
1198
+ export const restAgentSecretSchema = z.object({
1199
+ name: z.string(),
1200
+ setAt: instant,
1201
+ seeded: z.boolean(),
1202
+ expiresOn: z.nullable(day),
1203
+ });
1204
+ export type RestAgentSecret = z.infer<typeof restAgentSecretSchema>;
1205
+
1206
+ /** `GET /api/v1/agents/me/secrets` and `GET /api/v1/agents/<handle>/secrets`: the names, by name. */
1207
+ export const restAgentSecretsSchema = z.object({ items: z.array(restAgentSecretSchema) });
1208
+ export type RestAgentSecrets = z.infer<typeof restAgentSecretsSchema>;
1209
+
1210
+ /** `GET /api/v1/agents/me/secrets/<name>`: the secret with its value, for the account itself alone. */
1211
+ export const restAgentSecretValueSchema = z.object({
1212
+ name: z.string(),
1213
+ setAt: instant,
1214
+ seeded: z.boolean(),
1215
+ expiresOn: z.nullable(day),
1216
+ value: z.string(),
1217
+ });
1218
+ export type RestAgentSecretValue = z.infer<typeof restAgentSecretValueSchema>;
1219
+
1220
+ /**
1221
+ * What `PUT .../secrets/<name>` is sent: the value, up to `MAX_AGENT_SECRET_BYTES` of UTF-8,
1222
+ * and optionally the day it ends on, a product's long-lived token say, `null` for none.
1223
+ */
1224
+ export const restAgentSecretInputSchema = z.object({
1225
+ value: z.string().check(z.minLength(1), z.maxLength(MAX_AGENT_SECRET_BYTES)),
1226
+ expiresOn: z.optional(z.nullable(day)),
1227
+ });
1228
+ export type RestAgentSecretInput = z.infer<typeof restAgentSecretInputSchema>;
1229
+
1230
+ /** One line of the account's record of its store (ADR-0087): what was done to which secret, by whom and through which agent; never a value. */
1231
+ export const restAgentSecretAccessSchema = z.object({
1232
+ id: z.int().check(z.positive()),
1233
+ name: z.string(),
1234
+ action: z.enum(SECRET_ACCESSES),
1235
+ /** Who did it: the account itself, or a supervisor; `null` for someone who is no longer there. */
1236
+ by: z.nullable(restPersonSchema),
1237
+ /** The agent they did it through, when they acted with a token; `null` when they did it themselves. */
1238
+ agent: z.nullable(z.string()),
1239
+ /** Whether a supervisor's doing, where the account's own otherwise. */
1240
+ seeded: z.boolean(),
1241
+ at: instant,
1242
+ });
1243
+ export type RestAgentSecretAccess = z.infer<typeof restAgentSecretAccessSchema>;
1244
+
1245
+ /** `GET /api/v1/agents/<handle>/secret-accesses?before=&limit=`: the record, the newest first, and whether there is more before. */
1246
+ export const restAgentSecretAccessesSchema = z.object({
1247
+ items: z.array(restAgentSecretAccessSchema),
1248
+ more: z.boolean(),
1249
+ });
1250
+ export type RestAgentSecretAccesses = z.infer<typeof restAgentSecretAccessesSchema>;
1251
+
1252
+ /**
1253
+ * `GET /api/v1/me/manager`: whom whoever asks reports to, a person or an agent account, `null`
1254
+ * for nobody; and the administrators of the workspace, who stand in where there is nobody, or
1255
+ * the manager is out (ADR-0084). A manager is whom a member turns to first, not a rule of the
1256
+ * board: a decision is addressed to whomever the asker names.
1257
+ */
1258
+ export const restManagerSchema = z.object({
1259
+ manager: z.nullable(restPersonSchema),
1260
+ administrators: z.array(restPersonSchema),
1261
+ });
1262
+ export type RestManager = z.infer<typeof restManagerSchema>;
1263
+
1264
+ /** What an avatar's parts were rolled from: a short text of letters, digits, hyphens and underscores. */
1265
+ const avatarSeed = z.string().check(z.minLength(1), z.maxLength(64), z.regex(/^[A-Za-z0-9_-]+$/));
1266
+
1267
+ /**
1268
+ * A persona proposed for an agent account (ADR-0084): the seed it was rolled from, a name in the
1269
+ * language asked for, the handle the name gives where nobody has it, and the parts of an avatar.
1270
+ * A suggestion, edited freely by whoever makes the account.
1271
+ */
1272
+ export const restAgentProposalSchema = z.object({
1273
+ seed: z.string(),
1274
+ name: z.string(),
1275
+ handle: z.string(),
1276
+ avatarParts: restAvatarPartsSchema,
1277
+ });
1278
+ export type RestAgentProposal = z.infer<typeof restAgentProposalSchema>;
1279
+
1280
+ /** `GET /api/v1/agents/proposals?count=&lang=`: a few personas to choose from, rolled again at each asking. */
1281
+ export const restAgentProposalsSchema = z.object({ items: z.array(restAgentProposalSchema) });
1282
+ export type RestAgentProposals = z.infer<typeof restAgentProposalsSchema>;
1283
+
1284
+ /** The short name of a service an account is held at, spelled as a kind is: `github`, `slack`. */
1285
+ const elsewhereService = z.string().check(z.regex(/^[a-z][a-z0-9-]{0,39}$/));
1286
+ /** What the agent is called at a service: a line, and no secret. */
1287
+ const elsewhereName = line(MAX_ELSEWHERE_NAME_LENGTH);
1288
+ /** An hour and a minute of the day, as `09:00`. */
1289
+ const clockTime = z.string().check(z.regex(/^(?:[01][0-9]|2[0-3]):[0-5][0-9]$/));
1290
+ /**
1291
+ * The hours an agent account keeps (ADR-0085, point 11), in the workspace's time zone: when its
1292
+ * day starts, which is when its day's briefing is sent, and when it ends, with a wrap then, or
1293
+ * `null` for a day with no end.
1294
+ */
1295
+ export const restAgentHoursSchema = z.object({
1296
+ dayStart: clockTime,
1297
+ dayEnd: z.nullable(clockTime),
1298
+ });
1299
+ export type RestAgentHours = z.infer<typeof restAgentHoursSchema>;
1300
+
1301
+ /** The accounts an agent account holds elsewhere (ADR-0089): what it is called at each, by service. */
1302
+ export const restAgentElsewhereSchema = z.record(elsewhereService, elsewhereName);
1303
+ export type RestAgentElsewhere = z.infer<typeof restAgentElsewhereSchema>;
1304
+
1305
+ /**
1306
+ * What `PATCH /api/v1/agents/<handle>` is sent: by a supervisor, the persona to keep, one or
1307
+ * more of its name, its title (`null` for none) and its avatar; by a supervisor or the account
1308
+ * itself, the accounts it holds elsewhere and the hours of its day. The handle never changes.
1309
+ */
1310
+ export const restAgentPatchSchema = z
1311
+ .object({
1312
+ /** When its day starts, `null` for the hour an account starts at where it says none; and when it ends, `null` for no end. */
1313
+ dayStart: z.optional(z.nullable(clockTime)),
1314
+ dayEnd: z.optional(z.nullable(clockTime)),
1315
+ /** The accounts it holds elsewhere, by service: one left out stays as it is, `null` takes one away. */
1316
+ accounts: z.optional(
1317
+ z
1318
+ .record(elsewhereService, z.nullable(elsewhereName))
1319
+ .check(
1320
+ z.refine(
1321
+ (accounts) => Object.keys(accounts).length <= MAX_AGENT_ELSEWHERE,
1322
+ "names more accounts than one may hold",
1323
+ ),
1324
+ ),
1325
+ ),
1326
+ name: z.optional(line(MAX_PERSON_NAME_LENGTH)),
1327
+ title: z.optional(z.nullable(line(MAX_PERSON_TITLE_LENGTH))),
1328
+ /** The parts of the avatar, and optionally the seed they were rolled from, `null` for parts chosen by hand. */
1329
+ avatarParts: z.optional(restAvatarPartsSchema),
1330
+ avatarSeed: z.optional(z.nullable(avatarSeed)),
1331
+ })
1332
+ .check(
1333
+ z.refine(
1334
+ (patch) =>
1335
+ patch.name !== undefined ||
1336
+ patch.title !== undefined ||
1337
+ patch.avatarParts !== undefined ||
1338
+ patch.dayStart !== undefined ||
1339
+ patch.dayEnd !== undefined ||
1340
+ (patch.accounts !== undefined && Object.keys(patch.accounts).length > 0),
1341
+ "must name a name, a title, the parts of an avatar, an hour of its day or an account held elsewhere",
1342
+ ),
1343
+ );
1344
+ export type RestAgentPatch = z.infer<typeof restAgentPatchSchema>;
1345
+
1346
+ /**
1347
+ * An agent account as its own listing answers it (ADR-0084): the member it is, and whom it
1348
+ * reports to.
1349
+ */
1350
+ export const restAgentSchema = z.object({
1351
+ /** The account as a member: `kind: "agent"`, with its handle, its title and what its avatar is drawn from. */
1352
+ person: restPersonSchema,
1353
+ /** Whom it reports to, as the asker may see them; `null` where they may not. */
1354
+ manager: z.nullable(restPersonSchema),
1355
+ /**
1356
+ * Whether the asker supervises it (ADR-0084): an administrator, or above it in the reporting
1357
+ * line. What a supervisor may do of it, nobody else may.
1358
+ */
1359
+ supervised: z.boolean(),
1360
+ /** How it stands, as its runner last said or the console noted (ADR-0085); `null` while no runner has ever said. */
1361
+ state: z.optional(z.nullable(restAgentStateSchema)),
1362
+ /** What its runner last said of itself and what was chosen for it: answered to its supervisors and to the account, `null` to anyone else and while there is none. */
1363
+ runner: z.optional(z.nullable(restAgentRunnerSchema)),
1364
+ /**
1365
+ * The accounts it holds elsewhere (ADR-0089), what it is called at each by the service's short
1366
+ * name, and no secret: answered where one account is read, so that taking it out knows what
1367
+ * to close.
1368
+ */
1369
+ accounts: z.optional(restAgentElsewhereSchema),
1370
+ /** The hours it keeps: answered where one account is read, to its supervisors and to the account. */
1371
+ hours: z.optional(restAgentHoursSchema),
1372
+ /** Its onboarding task (ADR-0088), where the console made one with the account: answered when the account is made. */
1373
+ onboarding: z.optional(
1374
+ z.nullable(z.object({ project: z.string(), number: z.number().check(z.int()) })),
1375
+ ),
1376
+ /**
1377
+ * What its first sign-in is held to (ADR-0126), while nobody has signed in with it under a
1378
+ * sign-in at a git host: `account` where the host said which account its login is, so that
1379
+ * only that account is let in; `member` and `login` where the host did not, which the pages
1380
+ * and the command say as not confirmed. Left out once it has signed in, and under a provider
1381
+ * that makes its own addresses. Answered from 0.5.1 and read as optional.
1382
+ */
1383
+ firstSignIn: z.optional(z.enum(FIRST_SIGN_INS)),
1384
+ });
1385
+ export type RestAgent = z.infer<typeof restAgentSchema>;
1386
+
1387
+ /** `GET /api/v1/agents`: the agent accounts the asker may see, by handle. */
1388
+ export const restAgentsSchema = z.object({ items: z.array(restAgentSchema) });
1389
+ export type RestAgents = z.infer<typeof restAgentsSchema>;
1390
+
1391
+ /**
1392
+ * What `POST /api/v1/agents` is sent, by an administrator: the account the agent will sign in
1393
+ * with, at one of the providers the deployment has, as a listing names one; its persona; its
1394
+ * manager, whoever makes it where none is named; and the project it starts in. A login a member
1395
+ * already carries is made an agent account only where `convert` asks for it, once (ADR-0104).
1396
+ */
1397
+ export const restAgentInputSchema = z
1398
+ .object({
1399
+ host: z.enum(PROVIDER_KEYS),
1400
+ login: z.string().check(z.trim(), z.minLength(1), z.maxLength(MAX_LOGIN_LENGTH)),
1401
+ handle,
1402
+ name: line(MAX_PERSON_NAME_LENGTH),
1403
+ title: z.optional(z.nullable(line(MAX_PERSON_TITLE_LENGTH))),
1404
+ /** What the proposals rolled the parts from, kept beside them; left out where they were chosen by hand. */
1405
+ avatarSeed: z.optional(avatarSeed),
1406
+ /** Left out, the console rolls them: from the seed where one is given, from one of its own otherwise. */
1407
+ avatarParts: z.optional(restAvatarPartsSchema),
1408
+ managerId: z.optional(uuid),
1409
+ /** The key of the project it starts in. */
1410
+ project: z.string().check(z.minLength(1), z.maxLength(MAX_PROJECT_KEY_LENGTH)),
1411
+ /**
1412
+ * `true` says that the member who carries the login already is to become the account, for
1413
+ * good (ADR-0104); left out, such a login is refused (`agent.login_is_member`). It asks
1414
+ * nothing of a login nobody carries.
1415
+ */
1416
+ convert: z.optional(z.boolean()),
1417
+ })
1418
+ .check(z.refine((input) => isLoginAt(input.host, input.login), "must be a login at the host"));
1419
+ export type RestAgentInput = z.infer<typeof restAgentInputSchema>;
1420
+
468
1421
  /** The words under `/projects/` that are the pages' own, which no project may be called. */
469
1422
  export const RESERVED_PROJECT_KEYS: readonly string[] = ["new"];
470
1423
 
@@ -495,6 +1448,17 @@ export const restProjectIconSchema = z.object({
495
1448
  });
496
1449
  export type RestProjectIcon = z.infer<typeof restProjectIconSchema>;
497
1450
 
1451
+ /** How many tasks a goal, or a project's board, has in each state: what its progress is read from, live. */
1452
+ export const restTaskCountsSchema = z.object({
1453
+ idea: count,
1454
+ ready: count,
1455
+ in_progress: count,
1456
+ in_review: count,
1457
+ done: count,
1458
+ dropped: count,
1459
+ });
1460
+ export type RestTaskCounts = z.infer<typeof restTaskCountsSchema>;
1461
+
498
1462
  export const restProjectSchema = z.object({
499
1463
  id: uuid,
500
1464
  key: projectKey,
@@ -730,17 +1694,6 @@ export const restTaskPatchSchema = z.object({
730
1694
  });
731
1695
  export type RestTaskPatch = z.infer<typeof restTaskPatchSchema>;
732
1696
 
733
- /** How many tasks a goal has in each state: what its progress is read from, live. */
734
- export const restTaskCountsSchema = z.object({
735
- idea: count,
736
- ready: count,
737
- in_progress: count,
738
- in_review: count,
739
- done: count,
740
- dropped: count,
741
- });
742
- export type RestTaskCounts = z.infer<typeof restTaskCountsSchema>;
743
-
744
1697
  /**
745
1698
  * A goal of a project's roadmap (ADR-0019): what the project works towards, with the day it is
746
1699
  * meant to be reached by, and how far the tasks under it are.
@@ -773,6 +1726,46 @@ export type RestGoal = z.infer<typeof restGoalSchema>;
773
1726
  export const restGoalsSchema = z.object({ items: z.array(restGoalSchema), more: z.boolean() });
774
1727
  export type RestGoals = z.infer<typeof restGoalsSchema>;
775
1728
 
1729
+ /** A task as a project's glance shows it (ADR-0107): its title, its day and who is at work on it. */
1730
+ export const restGlanceTaskSchema = z.pick(restTaskSchema, {
1731
+ id: true,
1732
+ number: true,
1733
+ title: true,
1734
+ state: true,
1735
+ dueOn: true,
1736
+ workers: true,
1737
+ });
1738
+ export type RestGlanceTask = z.infer<typeof restGlanceTaskSchema>;
1739
+
1740
+ /** A goal as a project's glance shows it: its title, its day and its tasks counted by state. */
1741
+ export const restGlanceGoalSchema = z.pick(restGoalSchema, {
1742
+ id: true,
1743
+ title: true,
1744
+ state: true,
1745
+ dueOn: true,
1746
+ taskCounts: true,
1747
+ });
1748
+ export type RestGlanceGoal = z.infer<typeof restGlanceGoalSchema>;
1749
+
1750
+ /**
1751
+ * `GET /api/v1/projects/<key>/glance`: what a project's tile at a glance shows (ADR-0105), read
1752
+ * at one moment so that its figures and its rows agree (ADR-0107). Each list is ordered and cut
1753
+ * by the console, `GLANCE_ROWS` at most, and says how many it has in all.
1754
+ */
1755
+ export const restProjectGlanceSchema = z.object({
1756
+ /** The tasks on its board, those put away left out, counted by state. */
1757
+ taskCounts: restTaskCountsSchema,
1758
+ /** How many decisions in it wait for a person. */
1759
+ openDecisions: count,
1760
+ /** Its tasks in progress, the sooner due first and those due on no day after. */
1761
+ inProgress: z.object({ items: z.array(restGlanceTaskSchema), total: count }),
1762
+ /** Its tasks waiting for review, in the same order. */
1763
+ inReview: z.object({ items: z.array(restGlanceTaskSchema), total: count }),
1764
+ /** Its goals ahead, the active and the planned, as the roadmap orders them. */
1765
+ goals: z.object({ items: z.array(restGlanceGoalSchema), total: count }),
1766
+ });
1767
+ export type RestProjectGlance = z.infer<typeof restProjectGlanceSchema>;
1768
+
776
1769
  /** What `POST /api/v1/projects/<key>/goals` is sent: the title, and the rest with defaults. */
777
1770
  export const restGoalInputSchema = z.object({
778
1771
  title: line(MAX_TITLE_LENGTH),
@@ -976,6 +1969,45 @@ export const restPersonWorkSchema = z.object({
976
1969
  });
977
1970
  export type RestPersonWork = z.infer<typeof restPersonWorkSchema>;
978
1971
 
1972
+ /** A task as the plate's page asks for it: everything but its body, which the page does not show. */
1973
+ export const restTaskBriefSchema = z.omit(restTaskSchema, { body: true });
1974
+ export type RestTaskBrief = z.infer<typeof restTaskBriefSchema>;
1975
+
1976
+ /**
1977
+ * `GET /api/v1/projects/<key>/tasks?brief=true`: a page of the board as `.../tasks` answers it,
1978
+ * the tasks without their bodies, for whatever lists tasks and shows no body: a listing of
1979
+ * the command, a desk's pages. A console from before the brief form answers the tasks whole,
1980
+ * which reads the same.
1981
+ */
1982
+ export const restTaskBriefsSchema = z.object({
1983
+ items: z.array(restTaskBriefSchema),
1984
+ more: z.boolean(),
1985
+ });
1986
+ export type RestTaskBriefs = z.infer<typeof restTaskBriefsSchema>;
1987
+
1988
+ /** A decision as the plate's page asks for it: everything but its body. */
1989
+ export const restDecisionBriefSchema = z.omit(restDecisionSchema, { body: true });
1990
+ export type RestDecisionBrief = z.infer<typeof restDecisionBriefSchema>;
1991
+
1992
+ /**
1993
+ * `GET /api/v1/work?brief=true`: the plate as `GET /api/v1/work` answers it, the tasks and the
1994
+ * decisions without their bodies, which the plate's page does not show and which weigh more
1995
+ * than the rest of the plate together. What the pages read; the command reads the plate whole.
1996
+ */
1997
+ export const restWorkBriefSchema = z.object({
1998
+ tasks: z.array(z.object({ project: projectRef, task: restTaskBriefSchema })),
1999
+ closed: z.optional(z.array(z.object({ project: projectRef, task: restTaskBriefSchema }))),
2000
+ decisions: z.array(z.object({ project: projectRef, decision: restDecisionBriefSchema })),
2001
+ });
2002
+ export type RestWorkBrief = z.infer<typeof restWorkBriefSchema>;
2003
+
2004
+ /** `GET /api/v1/people/<id>/work?brief=true`: another person's plate without the tasks' bodies. */
2005
+ export const restPersonWorkBriefSchema = z.object({
2006
+ tasks: restWorkBriefSchema.shape.tasks,
2007
+ closed: restWorkBriefSchema.shape.closed,
2008
+ });
2009
+ export type RestPersonWorkBrief = z.infer<typeof restPersonWorkBriefSchema>;
2010
+
979
2011
  /**
980
2012
  * What `POST /api/v1/projects/<key>/decisions` is sent: the question, its context, and the
981
2013
  * options. As JSON; or, with files put on the decision (ADR-0055), as the part `decision` of a
@@ -1016,6 +2048,15 @@ export const restDecisionPatchSchema = z.object({
1016
2048
  });
1017
2049
  export type RestDecisionPatch = z.infer<typeof restDecisionPatchSchema>;
1018
2050
 
2051
+ /**
2052
+ * What `PUT .../decisions/<id>/deciders` is sent (ADR-0096): everyone a decision that waits is
2053
+ * for from now on, each once in the order named, in place of those it was for.
2054
+ */
2055
+ export const restDecisionDecidersSchema = z.object({
2056
+ deciderIds: z.array(uuid).check(z.minLength(1), z.maxLength(MAX_DECIDERS)),
2057
+ });
2058
+ export type RestDecisionDeciders = z.infer<typeof restDecisionDecidersSchema>;
2059
+
1019
2060
  /**
1020
2061
  * What `POST .../decisions/<id>/answer` is sent: one of the options by its id, or the person's
1021
2062
  * own answer in a line, one of the two; and a word about either.
@@ -1043,8 +2084,13 @@ export type RestAnswerInput = z.infer<typeof restAnswerInputSchema>;
1043
2084
  export const restEventDataSchema = z.object({
1044
2085
  number: z.optional(z.int()),
1045
2086
  title: z.optional(z.string()),
1046
- /** For `task.updated`, `project.updated`, `goal.updated` and `decision.updated`: which fields changed. */
2087
+ /** For `task.updated`, `project.updated`, `goal.updated`, `decision.updated` and `person.updated`: which fields changed. */
1047
2088
  fields: z.optional(z.array(z.string())),
2089
+ /** For a `task.updated` that put anyone to work on the task: their ids. */
2090
+ workersAdded: z.optional(z.array(uuid)),
2091
+ /** For `decision.addressed` (ADR-0096): the logins of everyone the decision is for now, and the ids of those named anew. */
2092
+ deciders: z.optional(z.array(z.string())),
2093
+ decidersAdded: z.optional(z.array(uuid)),
1048
2094
  /** For the events about a document: its path, and the version written. */
1049
2095
  path: z.optional(z.string()),
1050
2096
  version: z.optional(z.int()),
@@ -1064,6 +2110,16 @@ export const restEventDataSchema = z.object({
1064
2110
  team: z.optional(z.string()),
1065
2111
  /** For `person.email_changed`: whether the person has an address now; never the address itself. */
1066
2112
  set: z.optional(z.boolean()),
2113
+ /** For `person.updated` of an agent account and for `agent.state_changed`: the account's handle. */
2114
+ handle: z.optional(z.string()),
2115
+ /**
2116
+ * For `agent.state_changed` (ADR-0085): how the agent account stands now; how it stood before,
2117
+ * `null` where nothing had been said of it; and why, in a few words, where the runner or the
2118
+ * console said.
2119
+ */
2120
+ state: z.optional(z.enum(AGENT_STATES)),
2121
+ was: z.optional(z.nullable(z.enum(AGENT_STATES))),
2122
+ detail: z.optional(z.string()),
1067
2123
  /** For the events about a project: its key and its name. */
1068
2124
  key: z.optional(z.string()),
1069
2125
  name: z.optional(z.string()),
@@ -1088,6 +2144,8 @@ export const restEventDataSchema = z.object({
1088
2144
  capabilities: z.optional(z.array(z.string())),
1089
2145
  /** For `plugin.configured` of a secret: `administrator`, or the host of the answer it was sealed from (ADR-0070). */
1090
2146
  source: z.optional(z.string()),
2147
+ /** For `plugin.configured` of a keyed secret: the key its value was set, removed or moved under (ADR-0111). */
2148
+ under: z.optional(z.string()),
1091
2149
  /** For `plugin.granted` and `plugin.revoked`: the plugin the role went to, by key, where one did (ADR-0072). */
1092
2150
  grantee: z.optional(z.string()),
1093
2151
  /** For `plugin.granted` and `plugin.revoked`: whether the role went to everyone. */
@@ -1169,6 +2227,8 @@ export const restRunSchema = z.object({
1169
2227
  artifacts: z.array(restArtifactSchema),
1170
2228
  /** The id of the decision the run waits for, or `null`. */
1171
2229
  waitingFor: z.nullable(uuid),
2230
+ /** The session of an agent account's runner the run was begun in (ADR-0086), or `null`; read as optional. */
2231
+ sessionId: z.optional(z.nullable(uuid)),
1172
2232
  });
1173
2233
  export type RestRun = z.infer<typeof restRunSchema>;
1174
2234
 
@@ -1176,6 +2236,32 @@ export type RestRun = z.infer<typeof restRunSchema>;
1176
2236
  export const restRunsSchema = z.object({ items: z.array(restRunSchema), more: z.boolean() });
1177
2237
  export type RestRuns = z.infer<typeof restRunsSchema>;
1178
2238
 
2239
+ /**
2240
+ * A run as a listing asks for it: everything but its reports, of which it says how many. The
2241
+ * reports are what a run says as it goes, and weigh more than the rest of a listing together.
2242
+ * A console from before the brief form (0.5.0) ignores the word and answers the run whole, so
2243
+ * what is read is either: the count where the console counted, the reports where it sent them.
2244
+ */
2245
+ export const restRunBriefSchema = z.extend(z.omit(restRunSchema, { reports: true }), {
2246
+ /** How many reports the run has, as the brief form says it. */
2247
+ reportCount: z.optional(count),
2248
+ /** The reports themselves, from a console from before the brief form; a console that knows it leaves them out. */
2249
+ reports: z.optional(z.array(restReportSchema)),
2250
+ });
2251
+ export type RestRunBrief = z.infer<typeof restRunBriefSchema>;
2252
+
2253
+ /** How many reports a run has, as a listing says it: as the console counted them, else as many as it sent. */
2254
+ export function reportCountOf(run: RestRunBrief): number {
2255
+ return run.reportCount ?? run.reports?.length ?? 0;
2256
+ }
2257
+
2258
+ /** `GET /api/v1/projects/<key>/runs?brief=true`: a page of the runs as `.../runs` answers it, without their reports. */
2259
+ export const restRunBriefsSchema = z.object({
2260
+ items: z.array(restRunBriefSchema),
2261
+ more: z.boolean(),
2262
+ });
2263
+ export type RestRunBriefs = z.infer<typeof restRunBriefsSchema>;
2264
+
1179
2265
  /** A file put in a comment, kept as a run's file is; its bytes are at `projectPath(key, "files", <id>)`. */
1180
2266
  export const restCommentFileSchema = z.object({
1181
2267
  id: uuid,
@@ -1254,6 +2340,13 @@ export const restSessionSchema = z.object({
1254
2340
  platform: z.nullable(z.string()),
1255
2341
  /** Where the browser last came from, as the server saw it, or `null` until seen. */
1256
2342
  address: z.nullable(z.string()),
2343
+ /**
2344
+ * What holds the session (ADR-0084): a browser, or the command signed in as the account
2345
+ * itself. Answered from 0.5.0 and read as optional; a browser's then.
2346
+ */
2347
+ kind: z.optional(z.enum(SESSION_KINDS)),
2348
+ /** For the command's: what it called itself when it signed in, and where it runs; `null` for a browser's. Optional as above. */
2349
+ name: z.optional(z.nullable(z.string())),
1257
2350
  });
1258
2351
  export type RestSession = z.infer<typeof restSessionSchema>;
1259
2352
 
@@ -1281,21 +2374,39 @@ export const restTokenCreatedSchema = z.object({
1281
2374
  });
1282
2375
  export type RestTokenCreated = z.infer<typeof restTokenCreatedSchema>;
1283
2376
 
1284
- /** What `POST /api/v1/connect` is sent by the command: what the agent calls itself, and where it runs. */
1285
- export const restConnectInputSchema = z.object({ agent: line(MAX_TOKEN_NAME_LENGTH) });
2377
+ /**
2378
+ * What a connection asks to be (ADR-0011, ADR-0084): an agent of whoever approves it, which holds
2379
+ * a token of theirs, or the approver themselves, where the command is signed in as the account
2380
+ * and holds a session of its own.
2381
+ */
2382
+ export const CONNECT_AS = ["agent", "self"] as const;
2383
+ export type ConnectAs = (typeof CONNECT_AS)[number];
2384
+
2385
+ /**
2386
+ * What `POST /api/v1/connect` is sent by the command: what the agent calls itself, and where it
2387
+ * runs; and what it asks to be, an agent where nothing is said.
2388
+ */
2389
+ export const restConnectInputSchema = z.object({
2390
+ agent: line(MAX_TOKEN_NAME_LENGTH),
2391
+ as: z.optional(z.enum(CONNECT_AS)),
2392
+ });
1286
2393
  export type RestConnectInput = z.infer<typeof restConnectInputSchema>;
1287
2394
 
1288
2395
  /**
1289
2396
  * What `POST /api/v1/connect` answers (ADR-0011): the code a person approves, the address of the
1290
2397
  * console's own page for it, and the secret the command claims the token with, shown nowhere.
2398
+ * Bounded, each no wider than the command's credentials file reads back (`cli/credentials.ts`),
2399
+ * since the route answers nobody and the command keeps the answer while it waits (ADR-0129):
2400
+ * a console answers a code of nine characters and a wait of a few seconds.
1291
2401
  */
1292
2402
  export const restConnectionSchema = z.object({
1293
- code: z.string(),
1294
- url: z.string(),
1295
- secret: z.string(),
1296
- expiresAt: instant,
1297
- /** How many seconds the command waits between claims. */
1298
- interval: z.int().check(z.positive()),
2403
+ code: z.string().check(z.minLength(1), z.maxLength(64)),
2404
+ url: z.string().check(z.minLength(1), z.maxLength(MAX_URL_LENGTH)),
2405
+ /** As long as the claim takes one. */
2406
+ secret: z.string().check(z.minLength(1), z.maxLength(MAX_SECRET_LENGTH)),
2407
+ expiresAt: z.iso.datetime().check(z.maxLength(40)),
2408
+ /** How many seconds the command waits between claims: ten minutes at most. */
2409
+ interval: z.int().check(z.positive(), z.lte(600)),
1299
2410
  });
1300
2411
  export type RestConnection = z.infer<typeof restConnectionSchema>;
1301
2412
 
@@ -1307,6 +2418,8 @@ export const restConnectRequestSchema = z.object({
1307
2418
  createdAt: instant,
1308
2419
  expiresAt: instant,
1309
2420
  approved: z.boolean(),
2421
+ /** What it asks to be: an agent of the approver's, or the approver themselves. Answered from 0.5.0 and read as optional; an agent then. */
2422
+ as: z.optional(z.enum(CONNECT_AS)),
1310
2423
  });
1311
2424
  export type RestConnectRequest = z.infer<typeof restConnectRequestSchema>;
1312
2425
 
@@ -1316,10 +2429,15 @@ export const restClaimInputSchema = z.object({
1316
2429
  });
1317
2430
  export type RestClaimInput = z.infer<typeof restClaimInputSchema>;
1318
2431
 
1319
- /** What the claim answers: wait, or the token this once, with its secret. */
2432
+ /**
2433
+ * What the claim answers: wait; or the token this once, with its secret; or, for a connection
2434
+ * that asked to be the account itself, the command's session this once, with its secret, which is
2435
+ * presented as a token's is (ADR-0084).
2436
+ */
1320
2437
  export const restClaimSchema = z.union([
1321
2438
  z.object({ status: z.literal("pending"), expiresAt: instant }),
1322
2439
  z.object({ status: z.literal("connected"), token: restTokenSchema, secret: z.string() }),
2440
+ z.object({ status: z.literal("signed_in"), session: restSessionSchema, secret: z.string() }),
1323
2441
  ]);
1324
2442
  export type RestClaim = z.infer<typeof restClaimSchema>;
1325
2443
 
@@ -1470,6 +2588,28 @@ export const restSkillFindSchema = z.object({
1470
2588
  });
1471
2589
  export type RestSkillFind = z.infer<typeof restSkillFindSchema>;
1472
2590
 
2591
+ /**
2592
+ * `GET .../skills/rows?path=&heading=&cursor=&limit=`: the tables of a document, or of every
2593
+ * document under a folder, as data, a page of them by whole files, as the pack answers its
2594
+ * `rows` read (`RestRows` of `@skillcdn/core`); `read` is `null` unless `ready` (ADR-0100).
2595
+ */
2596
+ export const restSkillRowsSchema = z.object({
2597
+ ...packEnvelope,
2598
+ read: z.nullable(packRowsSchema),
2599
+ });
2600
+ export type RestSkillRows = z.infer<typeof restSkillRowsSchema>;
2601
+
2602
+ /**
2603
+ * `GET .../skills/code?path=&heading=&cursor=&limit=`: the fenced code blocks of a document, or
2604
+ * of every document under a folder, as data, a page of them, as the pack answers its `code`
2605
+ * read (`RestCode` of `@skillcdn/core`); `read` is `null` unless `ready` (ADR-0100).
2606
+ */
2607
+ export const restSkillCodeSchema = z.object({
2608
+ ...packEnvelope,
2609
+ read: z.nullable(packCodeSchema),
2610
+ });
2611
+ export type RestSkillCode = z.infer<typeof restSkillCodeSchema>;
2612
+
1473
2613
  /**
1474
2614
  * A document's path (ADR-0009): segments of lowercase letters, digits and hyphens, separated
1475
2615
  * by slashes, as a repository keeps files; the document's address, which does not change.
@@ -1584,16 +2724,25 @@ export const restRulesPluginSchema = z.object({
1584
2724
  export type RestRulesPlugin = z.infer<typeof restRulesPluginSchema>;
1585
2725
 
1586
2726
  /**
1587
- * `GET /api/v1/rules`, and each half of a project's (ADR-0023): the rules that hold, and where
1588
- * they come from. `reference`: the console's own, since the organization wrote none;
1589
- * `written`: the page written, with its facts; `none`: a project that adds none.
2727
+ * `GET /api/v1/rules`, and each half of a project's (ADR-0023, ADR-0120): the rules that hold,
2728
+ * and what stands beside the console's. At the workspace, `reference`: the console's rules
2729
+ * alone, since the organization adds nothing; `written`: something is added, on its page. In
2730
+ * a project's own half, `written`: the page the project wrote; `none`: it adds none.
1590
2731
  */
1591
2732
  export const restRulesSchema = z.object({
1592
2733
  source: z.enum(RULES_SOURCES),
1593
- /** The rules as they hold, Markdown; `null` for a project that adds none. */
2734
+ /**
2735
+ * The rules as they hold, Markdown. At the workspace, whole: the console's, then what the
2736
+ * organization adds under a heading of its own, which is what a command of before prints.
2737
+ * `null` for a project that adds none.
2738
+ */
1594
2739
  body: z.nullable(z.string()),
1595
- /** The page they are written on, or `null` for the console's own and for none. */
2740
+ /** The page what is added is written on, or `null` where nothing is added. */
1596
2741
  page: z.nullable(restDocumentSummarySchema),
2742
+ /** At the workspace, from 0.5.1: the console's rules by themselves, as they always hold. */
2743
+ own: z.optional(z.string()),
2744
+ /** At the workspace, from 0.5.1: what the organization adds, with its page; `null` where it adds nothing. */
2745
+ added: z.optional(z.nullable(z.object({ body: z.string(), page: restDocumentSummarySchema }))),
1597
2746
  /** At the workspace: every plugin the asker may use, by key; left out in the halves of a project's answer. */
1598
2747
  plugins: z.optional(z.array(restRulesPluginSchema)),
1599
2748
  });
@@ -1608,7 +2757,11 @@ export const restProjectRulesSchema = z.object({
1608
2757
  });
1609
2758
  export type RestProjectRules = z.infer<typeof restProjectRulesSchema>;
1610
2759
 
1611
- /** What `PUT /api/v1/rules` is sent: the rules as they are to be. */
2760
+ /**
2761
+ * What `PUT /api/v1/rules` is sent: what the organization adds, as it is to be. A body that
2762
+ * carries the console's rules whole, as a client of before read them, is taken for what stands
2763
+ * before and after them.
2764
+ */
1612
2765
  export const restRulesInputSchema = z.object({
1613
2766
  body: paragraphs(MAX_RULES_LENGTH),
1614
2767
  /** The version the writer started from; the write is refused when the rules have moved on. */