@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/dist/schemas.js CHANGED
@@ -2,13 +2,13 @@
2
2
  // most of what a page downloads. The server validates what it is sent with the input schemas
3
3
  // and builds the output shapes; the pages and a custom console parse answers with the rest.
4
4
  // Absent values are `null` on the wire, never missing keys. Changes within a version are additive.
5
- import { restBrowseSchema as packBrowseSchema, restFileSchema as packFileSchema, restFindSchema as packFindSchema, restMountSchema as packMountSchema, restSkillSchema as packSkillSchema, } from "@skillcdn/core";
5
+ import { restBrowseSchema as packBrowseSchema, restCodeSchema as packCodeSchema, restFileSchema as packFileSchema, restFindSchema as packFindSchema, restMountSchema as packMountSchema, restRowsSchema as packRowsSchema, restSkillSchema as packSkillSchema, } from "@skillcdn/core";
6
6
  import * as z from "zod/mini";
7
7
  import { isDocumentPath } from "./documents.js";
8
- import { MAX_AGENT_LENGTH, MAX_BODY_LENGTH, MAX_CATEGORY_KEY_LENGTH, MAX_CATEGORY_NAME_LENGTH, MAX_DECIDERS, MAX_DOCUMENT_LENGTH, MAX_DOCUMENT_PATH_LENGTH, MAX_FILE_NAME_LENGTH, MAX_HOME_ROW, MAX_HOME_TILES, MAX_LANGUAGE_TAG_LENGTH, MAX_LINK_LABEL_LENGTH, MAX_LINKS, MAX_LOGIN_LENGTH, MAX_NOTE_LENGTH, MAX_OPTION_LABEL_LENGTH, MAX_OPTIONS, MAX_PROJECT_DESCRIPTION_LENGTH, MAX_PROJECT_KEY_LENGTH, MAX_PROJECT_NAME_LENGTH, MAX_PROJECT_SYMBOL_LENGTH, MAX_QUESTION_LENGTH, MAX_RULES_LENGTH, MAX_SECRET_LENGTH, MAX_SKILLS_ADDRESS_LENGTH, MAX_SUMMARY_LENGTH, MAX_TEAM_KEY_LENGTH, MAX_TEAM_NAME_LENGTH, MAX_TITLE_LENGTH, MAX_TOKEN_DAYS, MAX_TOKEN_NAME_LENGTH, MAX_URL_LENGTH, MAX_WORKERS, MIN_OPTIONS, } from "./limits.js";
8
+ import { MAX_AGENT_ELSEWHERE, MAX_AGENT_LENGTH, MAX_AGENT_SECRET_BYTES, MAX_AGENT_SECRET_NAME_LENGTH, MAX_BODY_LENGTH, MAX_CATEGORY_KEY_LENGTH, MAX_CATEGORY_NAME_LENGTH, MAX_DECIDERS, MAX_DOCUMENT_LENGTH, MAX_DOCUMENT_PATH_LENGTH, MAX_ELSEWHERE_NAME_LENGTH, MAX_FILE_NAME_LENGTH, MAX_HANDLE_LENGTH, MAX_HOME_ROW, MAX_HOME_TILES, MAX_LANGUAGE_TAG_LENGTH, MAX_LINK_LABEL_LENGTH, MAX_LINKS, MAX_LOGIN_LENGTH, MAX_NOTE_LENGTH, MAX_OPTION_LABEL_LENGTH, MAX_OPTIONS, MAX_PERSON_NAME_LENGTH, MAX_PERSON_TITLE_LENGTH, MAX_PROJECT_DESCRIPTION_LENGTH, MAX_PROJECT_KEY_LENGTH, MAX_PROJECT_NAME_LENGTH, MAX_PROJECT_SYMBOL_LENGTH, MAX_QUESTION_LENGTH, MAX_RULES_LENGTH, MAX_RUNNER_LINE_LENGTH, MAX_RUNNER_OFFERS, MAX_SEAL_REASON_LENGTH, MAX_SECRET_LENGTH, MAX_SERVICE_PARAMETERS, MAX_SERVICE_VALUE_LENGTH, MAX_SIGNAL_KEY_LENGTH, MAX_SIGNAL_LENGTH, MAX_SKILLS_ADDRESS_LENGTH, MAX_SUMMARY_LENGTH, MAX_TEAM_KEY_LENGTH, MAX_TEAM_NAME_LENGTH, MAX_TITLE_LENGTH, MAX_TOKEN_DAYS, MAX_TOKEN_NAME_LENGTH, MAX_TRANSCRIPT_ATTACHMENTS, MAX_TRANSCRIPT_BATCH, MAX_TRANSCRIPT_FACT_LENGTH, MAX_TRANSCRIPT_FACT_NAME_LENGTH, MAX_TRANSCRIPT_FACTS, MAX_TRANSCRIPT_TEXT_BYTES, MAX_URL_LENGTH, MAX_WORKERS, MIN_HANDLE_LENGTH, MIN_OPTIONS, } from "./limits.js";
9
9
  import { PLUGIN_WIDGET_SIZE_NAMES } from "./plugin/manifest.js";
10
10
  import { hasForbiddenCodePoint } from "./text.js";
11
- import { ARTIFACT_KINDS, CATEGORY_COLORS, COLOR_NAMES, CONSOLE_LANGUAGES, EVENT_KINDS, GOAL_STATES, LINK_SOURCES, MEMBERSHIP_SOURCES, PACK_CONNECT_ENDINGS, PEOPLE_VISIBILITIES, PERSON_ROLES, PERSON_STATUSES, PLUGIN_COMMAND_OUTCOMES, PROJECT_ICON_TYPES, PROJECT_ROLES, PROJECT_VISIBILITIES, PROVIDER_KEYS, RULES_SOURCES, RUN_ENDINGS, RUN_STATUSES, SKILLS_STATUSES, TASK_PRIORITIES, TASK_STATES, WEEK_STARTS, } from "./vocabulary.js";
11
+ import { AGENT_STATE_REASONS, AGENT_STATES, ARTIFACT_KINDS, CATEGORY_COLORS, COLOR_NAMES, CONSOLE_LANGUAGES, EVENT_KINDS, FIRST_SIGN_INS, GOAL_STATES, LINK_SOURCES, MEMBERSHIP_SOURCES, PACK_CONNECT_ENDINGS, PEOPLE_VISIBILITIES, PERSON_KINDS, PERSON_ROLES, PERSON_STATUSES, PLUGIN_COMMAND_OUTCOMES, PROJECT_ICON_TYPES, PROJECT_ROLES, PROJECT_VISIBILITIES, PROVIDER_KEYS, RULES_SOURCES, RUN_ENDINGS, RUN_STATUSES, SECRET_ACCESSES, SERVICE_ROLES, SESSION_ENDS, SESSION_KINDS, SIGNAL_KINDS, SIGNAL_SOURCES, SKILLS_STATUSES, TASK_PRIORITIES, TASK_STATES, TRANSCRIPT_KINDS, WEEK_STARTS, } from "./vocabulary.js";
12
12
  /** A line of text a person wrote: trimmed, bounded, and free of characters that hide. */
13
13
  const line = (maxLength) => z.string().check(z.trim(), z.minLength(1), z.maxLength(maxLength), z.refine((value) => !hasForbiddenCodePoint(value), "must not contain control characters"));
14
14
  /** A text of a few lines: bounded, with its line breaks, and otherwise the same rule. */
@@ -28,6 +28,33 @@ const count = z.int().check(z.nonnegative());
28
28
  const languageTag = z
29
29
  .string()
30
30
  .check(z.maxLength(MAX_LANGUAGE_TAG_LENGTH), z.regex(/^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$/, "must be a language tag"));
31
+ /** One part of an avatar: which of the set's choices of that part, by its place in the set. */
32
+ const avatarPart = z.int().check(z.gte(0), z.lte(255));
33
+ /**
34
+ * What an agent account's avatar is made of (ADR-0084, ADR-0097): a small planet, its body, what
35
+ * lies on its surface, the ramp of colours both are drawn in, and one thing beside it or
36
+ * nothing, on a ground; each a place in the set the package ships, with that set's version, and
37
+ * the seed the squares on the ground are strewn by. The names of the parts are older than the
38
+ * planets and say which list of a set each is a place in. Nothing drawn is kept or sent: whoever
39
+ * shows the picture draws it from these, with the package's own function. A released set never
40
+ * changes, so an avatar keeps the look it was made with.
41
+ */
42
+ export const restAvatarPartsSchema = z.object({
43
+ /** The version of the set the places are in. */
44
+ set: z.int().check(z.gte(1), z.lte(9999)),
45
+ /** The ramp of colours: a place among the set's `ramps`. */
46
+ palette: avatarPart,
47
+ /** The colour behind everything: a place among the set's `grounds`. */
48
+ ground: avatarPart,
49
+ /** The body: a place among the set's `bodies`. */
50
+ form: avatarPart,
51
+ /** What lies on the body: a place among the set's `surfaces`. */
52
+ material: avatarPart,
53
+ /** What stands beside the body, a place among the set's `accents`: `0` for nothing. */
54
+ accent: avatarPart,
55
+ /** The seed of the squares strewn over the ground: two avatars alike in every other part differ in them. */
56
+ vein: avatarPart,
57
+ });
31
58
  export const restPersonSchema = z.object({
32
59
  id: uuid,
33
60
  /** What the account is called at its provider: a login at the git host, an address at Google. */
@@ -66,6 +93,33 @@ export const restPersonSchema = z.object({
66
93
  * carries none. Answered from 0.4.5 and read as optional.
67
94
  */
68
95
  email: z.optional(z.nullable(z.string())),
96
+ /**
97
+ * What the member is (ADR-0084): a person, or an agent account, a member of its own under the
98
+ * same rules. Answered from 0.5.0 and read as optional: a person, where a console says nothing.
99
+ */
100
+ kind: z.optional(z.enum(PERSON_KINDS)),
101
+ /**
102
+ * An agent account's handle, what the pages and the command call it by (`mira`, addressed as
103
+ * `@mira`); it never changes. `null` for a person. Answered from 0.5.0 and read as optional.
104
+ */
105
+ handle: z.optional(z.nullable(z.string())),
106
+ /**
107
+ * What the member does, in a line (`Release engineer`): every member's, a person's as an agent
108
+ * account's, kept by an administrator; `null` for none. It is not `role`. Answered from 0.5.0
109
+ * and read as optional.
110
+ */
111
+ title: z.optional(z.nullable(z.string())),
112
+ /**
113
+ * What an agent account's avatar is drawn from, where the picture of a person is `avatar`,
114
+ * the provider's; `null` for a person. Answered from 0.5.0 and read as optional.
115
+ */
116
+ avatarParts: z.optional(z.nullable(restAvatarPartsSchema)),
117
+ /**
118
+ * `true` for an agent account nobody has signed in with yet: made by an administrator, so that
119
+ * work can be assigned to it, and "invited" on the pages until its first sign-in. Not a status
120
+ * of the directory. Left out otherwise.
121
+ */
122
+ invited: z.optional(z.boolean()),
69
123
  });
70
124
  /** The provider a login belongs to, by its shape: an address is Google's, anything else the git host's. */
71
125
  export function hostOfLogin(login) {
@@ -193,8 +247,116 @@ export const restMePatchSchema = z
193
247
  * the board is called, what the deployment's configuration says of it, and the settings an
194
248
  * administrator keeps on the Settings page (ADR-0035).
195
249
  */
250
+ const DOMAIN = /^(?=.{4,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
251
+ /** Whether `value` is spelled as a mail and web domain is, in small letters (`acme.example`). */
252
+ export function isDomain(value) {
253
+ return DOMAIN.test(value);
254
+ }
255
+ const SERVICE_KIND = /^[a-z][a-z0-9-]{0,39}$/;
256
+ const SERVICE_PARAMETER = /^[a-z][A-Za-z0-9]{0,39}$/;
257
+ /** A name's template: what a name is made of, and the three places. */
258
+ const SERVICE_TEMPLATE = /^(?:[A-Za-z0-9._@-]|\{(?:workspace|agent|domain)\})+$/;
259
+ /** An organization or an account as a git host spells one. */
260
+ const HOST_ACCOUNT = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
261
+ /** A group as a git host that nests them spells one: `acme`, or `acme/platform`. */
262
+ const HOST_GROUP = /^(?=.{1,200}$)[A-Za-z0-9_][A-Za-z0-9_.-]*(?:\/[A-Za-z0-9_][A-Za-z0-9_.-]*){0,7}$/;
263
+ /** The forms of account a git host has: a person's, and the one it has for a machine. */
264
+ const ACCOUNT_FORM = /^(?:user|service)$/;
265
+ /**
266
+ * The parameters the kinds the package knows take, and the roles each may be named for
267
+ * (ADR-0089). A kind that is not here is kept with whatever short parameters it came with.
268
+ */
269
+ const SERVICE_SHAPES = {
270
+ github: {
271
+ roles: ["identity", "git"],
272
+ parameters: { organization: HOST_ACCOUNT, account: SERVICE_TEMPLATE },
273
+ },
274
+ gitlab: {
275
+ roles: ["git"],
276
+ parameters: {
277
+ group: HOST_GROUP,
278
+ host: DOMAIN,
279
+ form: ACCOUNT_FORM,
280
+ account: SERVICE_TEMPLATE,
281
+ },
282
+ },
283
+ "google-workspace": { roles: ["identity"], parameters: { account: SERVICE_TEMPLATE } },
284
+ slack: { roles: ["messenger"], parameters: { workspace: DOMAIN } },
285
+ };
286
+ /**
287
+ * What is wrong with a service named for a role, or nothing: a kind the package knows takes its
288
+ * own parameters, spelled as they are, and is named for a role it may have.
289
+ */
290
+ export function serviceProblemOf(role, service) {
291
+ const kind = service.kind;
292
+ if (kind === undefined || !SERVICE_KIND.test(kind)) {
293
+ return { what: "kind" };
294
+ }
295
+ const names = Object.keys(service).filter((name) => name !== "kind");
296
+ if (names.length > MAX_SERVICE_PARAMETERS ||
297
+ names.some((name) => !SERVICE_PARAMETER.test(name))) {
298
+ return { what: "parameters" };
299
+ }
300
+ const shape = SERVICE_SHAPES[kind];
301
+ if (shape === undefined) {
302
+ return undefined;
303
+ }
304
+ if (!shape.roles.includes(role)) {
305
+ return { what: "role" };
306
+ }
307
+ for (const name of names) {
308
+ const spelled = shape.parameters[name];
309
+ if (spelled === undefined) {
310
+ return { what: "unknown", parameter: name };
311
+ }
312
+ if (!spelled.test(service[name] ?? "")) {
313
+ return { what: "spelling", parameter: name };
314
+ }
315
+ }
316
+ return undefined;
317
+ }
318
+ /** What is wrong with a service named for a role, in a few English words for a program, or nothing. */
319
+ export function serviceProblem(role, service) {
320
+ const problem = serviceProblemOf(role, service);
321
+ if (problem === undefined) {
322
+ return undefined;
323
+ }
324
+ switch (problem.what) {
325
+ case "kind":
326
+ return "names no kind";
327
+ case "parameters":
328
+ return "has more parameters than one may, or one that is no word";
329
+ case "role":
330
+ return `is no ${role} service`;
331
+ case "unknown":
332
+ return `takes no ${problem.parameter}`;
333
+ case "spelling":
334
+ return `${problem.parameter} is not spelled as one is`;
335
+ }
336
+ }
337
+ /**
338
+ * A service a workspace's agents work with (ADR-0089), as it is answered: its `kind`, and its
339
+ * parameters as short strings. No secret is among them.
340
+ */
341
+ export const restWorkspaceServiceSchema = z.record(z.string(), z.string());
342
+ /** The services of a workspace, by what each is to its agents; a role with none is left out. */
343
+ export const restWorkspaceServicesSchema = z.object({
344
+ identity: z.optional(restWorkspaceServiceSchema),
345
+ git: z.optional(restWorkspaceServiceSchema),
346
+ messenger: z.optional(restWorkspaceServiceSchema),
347
+ });
348
+ /** A service as an administrator names one: a kind and a few parameters, each a short line. */
349
+ const serviceInput = z.record(z.string(), line(MAX_SERVICE_VALUE_LENGTH));
196
350
  export const restWorkspaceSchema = z.object({
197
351
  name: z.string(),
352
+ /**
353
+ * The organization's short name (`acme`) and its mail and web domain (ADR-0089), from which
354
+ * with an agent account's handle a name at a service is put together; `null` each for none.
355
+ * And the services its agents work with. Answered from 0.5.0 and read as optional.
356
+ */
357
+ handle: z.optional(z.nullable(z.string())),
358
+ domain: z.optional(z.nullable(z.string())),
359
+ services: z.optional(restWorkspaceServicesSchema),
198
360
  /** The most days a token may be good for here, or `null` when a person chooses. */
199
361
  tokenDaysAtMost: z.nullable(z.int().check(z.positive())),
200
362
  /**
@@ -241,14 +403,29 @@ export const restWorkspacePatchSchema = z
241
403
  timeZone: z.optional(z.nullable(timeZoneName)),
242
404
  /** One of the languages the console speaks, or `null` for none. */
243
405
  language: z.optional(z.nullable(z.enum(CONSOLE_LANGUAGES))),
406
+ /** The organization's short name, spelled as an agent account's handle is; `null` for none. */
407
+ handle: z.optional(z.nullable(z.string().check(z.refine(isHandle, "is a short name")))),
408
+ /** Its mail and web domain, in small letters; `null` for none. */
409
+ domain: z.optional(z.nullable(z.string().check(z.refine(isDomain, "is a domain")))),
410
+ /** The services named anew, by role: one left out stays as it is, `null` takes one away. */
411
+ services: z.optional(z.object({
412
+ identity: z.optional(z.nullable(serviceInput)),
413
+ git: z.optional(z.nullable(serviceInput)),
414
+ messenger: z.optional(z.nullable(serviceInput)),
415
+ })),
244
416
  })
245
417
  .check(z.refine((patch) => Object.values(patch).some((value) => value !== undefined), {
246
418
  message: "names nothing to change",
247
- }));
419
+ }), z.refine((patch) => SERVICE_ROLES.every((role) => {
420
+ const service = patch.services?.[role];
421
+ return (service === undefined || service === null || serviceProblem(role, service) === undefined);
422
+ }), { message: "names a service that does not read" }));
248
423
  /**
249
424
  * `GET /api/v1/me`: the workspace, who the session cookie says is signed in (or `null`), the
250
425
  * language they chose (or `null`), and the identity providers people sign in through, none
251
- * where nobody can.
426
+ * where nobody can. Nobody signed in is told the workspace's name and its language alone: the
427
+ * most days of a token is `null` then, the skills' source is empty and their address `null`,
428
+ * and everything read as optional is left out.
252
429
  */
253
430
  export const restMeSchema = z.object({
254
431
  workspace: restWorkspaceSchema,
@@ -258,6 +435,13 @@ export const restMeSchema = z.object({
258
435
  * person's own knows it holds one. `null` on a session, and for nobody.
259
436
  */
260
437
  agent: z.nullable(z.string()),
438
+ /**
439
+ * The session asking, when a session asks (ADR-0084): a browser's, or the command's, signed in
440
+ * as the account itself, with what it called itself. A console served through the command is
441
+ * told a command's session by it, as it is told a token by `agent`, and offers nothing either
442
+ * cannot do. `null` on a token, and for nobody. Answered from 0.5.0 and read as optional.
443
+ */
444
+ session: z.optional(z.nullable(z.object({ kind: z.enum(SESSION_KINDS), name: z.nullable(z.string()) }))),
261
445
  /** The language the person reads in (ADR-0065): the one they chose, else the one the pages first saw them in; `null` until then. */
262
446
  language: z.nullable(languageTag),
263
447
  /**
@@ -302,11 +486,555 @@ export const restPersonPatchSchema = z
302
486
  managerId: z.optional(z.nullable(uuid)),
303
487
  /** The person's work email, one per workspace, or `null` for none; an administrator's to write. */
304
488
  email: z.optional(z.nullable(z.email().check(z.maxLength(254)))),
489
+ /**
490
+ * What the member does, in a line, or `null` for none (ADR-0084): an administrator's to write
491
+ * of anyone, and of an agent account its supervisors' too.
492
+ */
493
+ title: z.optional(z.nullable(line(MAX_PERSON_TITLE_LENGTH))),
305
494
  })
306
495
  .check(z.refine((patch) => patch.role !== undefined ||
307
496
  patch.status !== undefined ||
308
497
  patch.managerId !== undefined ||
309
- patch.email !== undefined, "must name a role, a status, a manager or an email"));
498
+ patch.email !== undefined ||
499
+ patch.title !== undefined, "must name a role, a status, a manager, an email or a title"));
500
+ /**
501
+ * The words that are the console's own, which no agent account may be called: what stands under
502
+ * `/agents/` and `/api/v1/agents/` in an address, and what follows `console agent` in the
503
+ * command, where a handle stands too.
504
+ */
505
+ export const RESERVED_HANDLES = [
506
+ "new",
507
+ "me",
508
+ "proposals",
509
+ "setup",
510
+ "invite",
511
+ "secret",
512
+ "secrets",
513
+ "signals",
514
+ "tell",
515
+ "interrupt",
516
+ "stop",
517
+ "restart",
518
+ "reset",
519
+ "set",
520
+ "wake",
521
+ ];
522
+ /** 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. */
523
+ export function isHandle(value) {
524
+ return (value.length >= MIN_HANDLE_LENGTH &&
525
+ value.length <= MAX_HANDLE_LENGTH &&
526
+ /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(value));
527
+ }
528
+ /**
529
+ * An agent account's handle (ADR-0084): what the pages and the command call it by, `@mira`. One
530
+ * among the workspace's agent accounts, and immutable once the account is made.
531
+ */
532
+ const handle = z.string().check(z.refine(isHandle, "must be 2 to 39 lowercase letters, digits and hyphens"), z.refine((value) => !RESERVED_HANDLES.includes(value), "is a word the addresses use"));
533
+ /** A line a runner says: bounded, without characters that hide. */
534
+ const runnerLine = line(MAX_RUNNER_LINE_LENGTH);
535
+ /**
536
+ * How a model or a level of effort is spelled for the console to take it: letters, digits and a
537
+ * few marks, beginning with a letter or a digit. The runner holds what a product says of itself
538
+ * to the same rule before it says it on, so that one name the console would refuse does not
539
+ * cost the account its heartbeat.
540
+ */
541
+ export const RUNNER_CHOICE = /^[A-Za-z0-9][A-Za-z0-9._:[\]-]*$/;
542
+ /** A model or a level of effort, as the product spells one. */
543
+ const runnerChoice = z
544
+ .string()
545
+ .check(z.minLength(1), z.maxLength(MAX_RUNNER_LINE_LENGTH), z.regex(RUNNER_CHOICE));
546
+ /** The model and the level of effort an agent runs with, or is to; `null` each for "as the product has it". */
547
+ export const restAgentChoiceSchema = z.object({
548
+ model: z.nullable(z.string()),
549
+ effort: z.nullable(z.string()),
550
+ });
551
+ /** Where a runner runs: the machine as it calls itself, its operating system, and the OS account. */
552
+ const runnerMachine = z.object({ name: runnerLine, os: runnerLine, user: runnerLine });
553
+ /** The product a runner starts: the driver, what the product is called, its version, and whether the driver was tried with it. */
554
+ const runnerProduct = z.object({
555
+ driver: runnerLine,
556
+ name: runnerLine,
557
+ version: z.nullable(runnerLine),
558
+ tried: z.boolean(),
559
+ });
560
+ /** What the product offers to choose from, and what the driver can do. */
561
+ const runnerOffers = z.object({
562
+ models: z.array(runnerChoice).check(z.maxLength(MAX_RUNNER_OFFERS)),
563
+ efforts: z.array(runnerChoice).check(z.maxLength(MAX_RUNNER_OFFERS)),
564
+ steer: z.boolean(),
565
+ images: z.boolean(),
566
+ resume: z.boolean(),
567
+ });
568
+ /**
569
+ * What `PUT /api/v1/agents/me/runner` is sent (ADR-0085, docs/specs/runner.md): the runner's
570
+ * heartbeat, every thirty seconds and when the agent's state changes.
571
+ */
572
+ export const restRunnerHeartbeatInputSchema = z.object({
573
+ /** How the runner says its agent stands; `unheard` is the console's word, never the runner's. */
574
+ state: z.enum(["running", "stopped", "refused", "failed"]),
575
+ reason: z.enum(AGENT_STATE_REASONS),
576
+ /** 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. */
577
+ delivered: z.int().check(z.gte(0)),
578
+ /** The open session, or `null`. */
579
+ session: z.nullable(uuid),
580
+ machine: runnerMachine,
581
+ /** The package's version the runner runs from. */
582
+ runner: runnerLine,
583
+ product: runnerProduct,
584
+ offers: runnerOffers,
585
+ /** What the open session runs with; `null` each where the product's own choice stands. */
586
+ running: z.object({ model: z.nullable(runnerChoice), effort: z.nullable(runnerChoice) }),
587
+ });
588
+ /** What the heartbeat is answered: where the account's record of signals stands, what its supervisors chose, and how the console has the agent. */
589
+ export const restRunnerHeartbeatSchema = z.object({
590
+ latest: z.int().check(z.gte(0)),
591
+ /** The number of the last signal the console has as delivered: where a runner that lost its own count goes on from. */
592
+ delivered: z.int().check(z.gte(0)),
593
+ settings: restAgentChoiceSchema,
594
+ state: z.enum(AGENT_STATES),
595
+ });
596
+ /** How an agent account stands (ADR-0085), for whoever sees it: the state, why, since when, and when its runner was last heard from. */
597
+ export const restAgentStateSchema = z.object({
598
+ state: z.enum(AGENT_STATES),
599
+ reason: z.nullable(z.string()),
600
+ since: instant,
601
+ heardAt: z.nullable(instant),
602
+ });
603
+ /** 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. */
604
+ export const restAgentRunnerSchema = z.object({
605
+ delivered: z.int(),
606
+ latest: z.int(),
607
+ session: z.nullable(uuid),
608
+ machine: z.nullable(z.object({ name: z.string(), os: z.string(), user: z.string() })),
609
+ runner: z.nullable(z.string()),
610
+ product: z.nullable(z.object({
611
+ driver: z.string(),
612
+ name: z.string(),
613
+ version: z.nullable(z.string()),
614
+ tried: z.boolean(),
615
+ })),
616
+ offers: z.nullable(z.object({
617
+ models: z.array(z.string()),
618
+ efforts: z.array(z.string()),
619
+ steer: z.boolean(),
620
+ images: z.boolean(),
621
+ resume: z.boolean(),
622
+ })),
623
+ running: z.nullable(restAgentChoiceSchema),
624
+ settings: restAgentChoiceSchema,
625
+ });
626
+ /**
627
+ * A signal (ADR-0085): what the console sends an agent account's runner, a record numbered per
628
+ * account, with who sent it and where it came from.
629
+ */
630
+ export const restSignalSchema = z.object({
631
+ number: z.int().check(z.positive()),
632
+ kind: z.enum(SIGNAL_KINDS),
633
+ /** Who sent it, with the agent and the plugin they acted through; `null` for the console itself. */
634
+ by: z.nullable(restPersonSchema),
635
+ agent: z.nullable(z.string()),
636
+ plugin: z.nullable(z.string()),
637
+ source: z.enum(SIGNAL_SOURCES),
638
+ /** What it refers to: a task (`#412`), a briefing (`day`), a thread; `null` for a supervisor's own. */
639
+ key: z.nullable(z.string()),
640
+ text: z.string(),
641
+ /** For `set`: the model and the effort to run with from then on, the whole choice, `null` each for the product's own. */
642
+ set: z.nullable(restAgentChoiceSchema),
643
+ attachments: z.array(z.object({ id: uuid, name: z.string(), size: count, contentType: z.string() })),
644
+ at: instant,
645
+ });
646
+ /** `GET /api/v1/agents/<handle>/signals?before=&limit=`: the record, the newest first, and whether there is more before. */
647
+ export const restSignalsSchema = z.object({ items: z.array(restSignalSchema), more: z.boolean() });
648
+ /**
649
+ * What `POST /api/v1/agents/<handle>/signals` is sent, by a supervisor: the kind, the words for
650
+ * the agent, and for `set` the model or the effort. A `tell` needs words; an `interrupt` takes
651
+ * them, and without any stops the turn under way so that what the agent was sent and has not
652
+ * taken is read now; `set` needs one of its two, a field left out staying as it is and `null`
653
+ * meaning the product's own.
654
+ */
655
+ export const restSignalInputSchema = z
656
+ .object({
657
+ kind: z.enum(SIGNAL_KINDS),
658
+ text: z.optional(paragraphs(MAX_SIGNAL_LENGTH)),
659
+ set: z.optional(z.object({
660
+ model: z.optional(z.nullable(runnerChoice)),
661
+ effort: z.optional(z.nullable(runnerChoice)),
662
+ })),
663
+ })
664
+ .check(z.refine((input) => input.kind !== "tell" || (input.text ?? "").trim().length > 0, "a tell needs words"), z.refine((input) => input.kind !== "set" ||
665
+ (input.set !== undefined &&
666
+ (input.set.model !== undefined || input.set.effort !== undefined)), "a set names a model or an effort"));
667
+ /**
668
+ * What `POST /api/v1/agents/me/signals` is sent, by an account's own runner (ADR-0085): a wake
669
+ * one of its wake sources raised on the machine, from the messenger, with what it is about as
670
+ * its `key`, a thread say, and someone else's words as its `text`. Nothing else is raised this
671
+ * way: a runner tells its own agent nothing in anyone's name.
672
+ */
673
+ export const restRunnerWakeSchema = z.object({
674
+ kind: z.literal("wake"),
675
+ source: z.literal("messenger"),
676
+ key: line(MAX_SIGNAL_KEY_LENGTH),
677
+ text: z.optional(paragraphs(MAX_SIGNAL_LENGTH)),
678
+ });
679
+ /**
680
+ * The invitation that leads a machine to an agent account (ADR-0088), as it stands: when it was
681
+ * made, by whom, and when it ends. Never its code, which is shown once, when it is made.
682
+ */
683
+ export const restAgentInvitationSchema = z.object({
684
+ createdAt: instant,
685
+ expiresAt: instant,
686
+ by: z.nullable(restPersonSchema),
687
+ });
688
+ /** `GET /api/v1/agents/<handle>/invitation`: the invitation, or `null` where none stands. */
689
+ export const restAgentInvitationStateSchema = z.object({
690
+ invitation: z.nullable(restAgentInvitationSchema),
691
+ });
692
+ /**
693
+ * What making an invitation answers, this once: the code, and the command that sets a machine
694
+ * up with it. The code is no credential: it says which account a setup is for.
695
+ */
696
+ export const restAgentInvitationMadeSchema = z.object({
697
+ invitation: restAgentInvitationSchema,
698
+ code: z.string(),
699
+ command: z.string(),
700
+ });
701
+ /**
702
+ * `GET /api/v1/setup/<code>`: what an invitation's code opens, for whoever holds it, signed in or
703
+ * not: the account a setup is for, with the login it signs in with; its workspace, with the
704
+ * services its agents work with; and the console to come back to. Nothing secret.
705
+ */
706
+ export const restAgentSetupSchema = z.object({
707
+ account: z.object({
708
+ handle: z.string(),
709
+ name: z.nullable(z.string()),
710
+ title: z.nullable(z.string()),
711
+ login: z.string(),
712
+ host: z.enum(PROVIDER_KEYS),
713
+ avatarParts: z.optional(z.nullable(restAvatarPartsSchema)),
714
+ }),
715
+ workspace: z.object({
716
+ name: z.string(),
717
+ handle: z.nullable(z.string()),
718
+ domain: z.nullable(z.string()),
719
+ services: restWorkspaceServicesSchema,
720
+ }),
721
+ console: z.object({ url: z.string() }),
722
+ expiresAt: instant,
723
+ });
724
+ /** How many bytes of UTF-8 a text is, without encoding one that cannot be over or under the bound anyway. */
725
+ function utf8Within(value, bytes) {
726
+ if (value.length > bytes) {
727
+ return false;
728
+ }
729
+ return value.length * 3 <= bytes || new TextEncoder().encode(value).byteLength <= bytes;
730
+ }
731
+ /**
732
+ * What `POST /api/v1/agents/me/sessions` is sent (ADR-0085, docs/specs/runner.md): what the
733
+ * session the runner begins runs, and where.
734
+ */
735
+ export const restAgentSessionInputSchema = z.object({
736
+ product: runnerProduct,
737
+ model: z.nullable(runnerChoice),
738
+ effort: z.nullable(runnerChoice),
739
+ /** Whether the conversation of the session before is gone on with. */
740
+ resumed: z.boolean(),
741
+ machine: runnerMachine,
742
+ });
743
+ /**
744
+ * A session of an agent account's runner (ADR-0086): the lifetime of one process of its product,
745
+ * which leaves a transcript. The row stays, and says what the session held, whatever becomes of
746
+ * the month its events are kept under.
747
+ */
748
+ export const restAgentSessionSchema = z.object({
749
+ id: uuid,
750
+ /** The month it began in, as `2026-11`: what its events and its pictures are kept under. */
751
+ month: z.string(),
752
+ startedAt: instant,
753
+ /** When it ended, and how; `null` each while it is open. */
754
+ endedAt: z.nullable(instant),
755
+ ended: z.nullable(z.enum(SESSION_ENDS)),
756
+ product: z.object({
757
+ driver: z.string(),
758
+ name: z.string(),
759
+ version: z.nullable(z.string()),
760
+ tried: z.boolean(),
761
+ }),
762
+ model: z.nullable(z.string()),
763
+ effort: z.nullable(z.string()),
764
+ resumed: z.boolean(),
765
+ machine: z.object({ name: z.string(), os: z.string(), user: z.string() }),
766
+ /** The number of its last event; `0` for none. */
767
+ events: count,
768
+ lastEventAt: z.nullable(instant),
769
+ /** Whether its events are put away: the month they are kept under is not with the database now. */
770
+ away: z.boolean(),
771
+ });
772
+ /** `GET /api/v1/agents/<handle>/sessions?before=&limit=`: the sessions, the newest first, and whether there are more before. */
773
+ export const restAgentSessionsSchema = z.object({
774
+ items: z.array(restAgentSessionSchema),
775
+ more: z.boolean(),
776
+ });
777
+ /** What `POST /api/v1/agents/me/sessions/<id>/end` is sent: how the session ended, as the runner saw it. */
778
+ export const restAgentSessionEndInputSchema = z.object({
779
+ how: z.enum(["stopped", "restarted", "reset", "crashed", "exited"]),
780
+ });
781
+ /** A fact about a block of a transcript: a word, a number, a yes or a no. Shown as text, never run. */
782
+ const transcriptFact = z.union([
783
+ z.string().check(z.maxLength(MAX_TRANSCRIPT_FACT_LENGTH)),
784
+ z.number(),
785
+ z.boolean(),
786
+ z.null(),
787
+ ]);
788
+ /**
789
+ * One event of a session's transcript as its runner reports it (ADR-0086): a whole block,
790
+ * numbered per session from 1, with what a person reads of it as text and a few facts about it.
791
+ * The text is whatever the product said, control characters and all: it is kept as data and
792
+ * shown as text, so nothing of it is refused but its length.
793
+ */
794
+ export const restTranscriptEventInputSchema = z.object({
795
+ n: z.int().check(z.positive()),
796
+ kind: z.enum(TRANSCRIPT_KINDS),
797
+ /** When it happened, as the runner's clock had it. */
798
+ at: instant,
799
+ text: z
800
+ .string()
801
+ .check(z.refine((value) => utf8Within(value, MAX_TRANSCRIPT_TEXT_BYTES), "is too long")),
802
+ data: z.optional(z
803
+ .record(z.string().check(z.minLength(1), z.maxLength(MAX_TRANSCRIPT_FACT_NAME_LENGTH)), transcriptFact)
804
+ .check(z.refine((data) => Object.keys(data).length <= MAX_TRANSCRIPT_FACTS, "has too many facts"))),
805
+ /** The pictures of the block, by the ids their upload answered, of this session. */
806
+ files: z.optional(z.array(uuid).check(z.maxLength(MAX_TRANSCRIPT_ATTACHMENTS))),
807
+ });
808
+ /** What `POST /api/v1/agents/me/sessions/<id>/events` is sent: a batch, in order. The same number sent again changes nothing. */
809
+ export const restTranscriptBatchInputSchema = z.object({
810
+ events: z
811
+ .array(restTranscriptEventInputSchema)
812
+ .check(z.minLength(1), z.maxLength(MAX_TRANSCRIPT_BATCH)),
813
+ });
814
+ /** What a batch is answered: the number of the session's last event now, which the next batch goes on from. */
815
+ export const restTranscriptBatchSchema = z.object({ last: count });
816
+ /** A picture of a transcript, as its upload answers it and as an event names it. */
817
+ export const restTranscriptFileSchema = z.object({
818
+ id: uuid,
819
+ name: z.string(),
820
+ size: count,
821
+ contentType: z.string(),
822
+ });
823
+ /**
824
+ * One event of a session's transcript as it is read (ADR-0086). `text` is the whole text, or its
825
+ * beginning where `whole` says how many bytes the whole is, which is read apart. A sealed event
826
+ * keeps its number, its kind and its time, and says who sealed it, when and why in place of what
827
+ * it held.
828
+ */
829
+ export const restTranscriptEventSchema = z.object({
830
+ n: z.int().check(z.positive()),
831
+ kind: z.enum(TRANSCRIPT_KINDS),
832
+ at: instant,
833
+ text: z.string(),
834
+ whole: z.nullable(count),
835
+ data: z.record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()])),
836
+ files: z.array(restTranscriptFileSchema),
837
+ sealed: z.nullable(z.object({ by: z.nullable(restPersonSchema), at: instant, reason: z.string() })),
838
+ });
839
+ /** `GET /api/v1/agents/<handle>/sessions/<id>/events?after=&limit=`: the events after a number, in order, and whether there are more. */
840
+ export const restTranscriptEventsSchema = z.object({
841
+ items: z.array(restTranscriptEventSchema),
842
+ more: z.boolean(),
843
+ });
844
+ /** `GET /api/v1/agents/<handle>/sessions/<id>/events/<n>/text`: the whole text of one event, where its row keeps the beginning alone. */
845
+ export const restTranscriptTextSchema = z.object({
846
+ n: z.int().check(z.positive()),
847
+ text: z.string(),
848
+ });
849
+ /** What sealing an event is sent: why, in a line, which stays on the record in place of what the event held. */
850
+ export const restTranscriptSealInputSchema = z.object({ reason: line(MAX_SEAL_REASON_LENGTH) });
851
+ /** 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. */
852
+ export function isSecretName(value) {
853
+ return (value.length <= MAX_AGENT_SECRET_NAME_LENGTH &&
854
+ /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/.test(value));
855
+ }
856
+ /**
857
+ * A secret of an agent account's store as a listing says it (ADR-0087): its name, when it was
858
+ * set, whether a supervisor seeded it, and the day its value ends on where one is known. Never
859
+ * its value.
860
+ */
861
+ export const restAgentSecretSchema = z.object({
862
+ name: z.string(),
863
+ setAt: instant,
864
+ seeded: z.boolean(),
865
+ expiresOn: z.nullable(day),
866
+ });
867
+ /** `GET /api/v1/agents/me/secrets` and `GET /api/v1/agents/<handle>/secrets`: the names, by name. */
868
+ export const restAgentSecretsSchema = z.object({ items: z.array(restAgentSecretSchema) });
869
+ /** `GET /api/v1/agents/me/secrets/<name>`: the secret with its value, for the account itself alone. */
870
+ export const restAgentSecretValueSchema = z.object({
871
+ name: z.string(),
872
+ setAt: instant,
873
+ seeded: z.boolean(),
874
+ expiresOn: z.nullable(day),
875
+ value: z.string(),
876
+ });
877
+ /**
878
+ * What `PUT .../secrets/<name>` is sent: the value, up to `MAX_AGENT_SECRET_BYTES` of UTF-8,
879
+ * and optionally the day it ends on, a product's long-lived token say, `null` for none.
880
+ */
881
+ export const restAgentSecretInputSchema = z.object({
882
+ value: z.string().check(z.minLength(1), z.maxLength(MAX_AGENT_SECRET_BYTES)),
883
+ expiresOn: z.optional(z.nullable(day)),
884
+ });
885
+ /** 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. */
886
+ export const restAgentSecretAccessSchema = z.object({
887
+ id: z.int().check(z.positive()),
888
+ name: z.string(),
889
+ action: z.enum(SECRET_ACCESSES),
890
+ /** Who did it: the account itself, or a supervisor; `null` for someone who is no longer there. */
891
+ by: z.nullable(restPersonSchema),
892
+ /** The agent they did it through, when they acted with a token; `null` when they did it themselves. */
893
+ agent: z.nullable(z.string()),
894
+ /** Whether a supervisor's doing, where the account's own otherwise. */
895
+ seeded: z.boolean(),
896
+ at: instant,
897
+ });
898
+ /** `GET /api/v1/agents/<handle>/secret-accesses?before=&limit=`: the record, the newest first, and whether there is more before. */
899
+ export const restAgentSecretAccessesSchema = z.object({
900
+ items: z.array(restAgentSecretAccessSchema),
901
+ more: z.boolean(),
902
+ });
903
+ /**
904
+ * `GET /api/v1/me/manager`: whom whoever asks reports to, a person or an agent account, `null`
905
+ * for nobody; and the administrators of the workspace, who stand in where there is nobody, or
906
+ * the manager is out (ADR-0084). A manager is whom a member turns to first, not a rule of the
907
+ * board: a decision is addressed to whomever the asker names.
908
+ */
909
+ export const restManagerSchema = z.object({
910
+ manager: z.nullable(restPersonSchema),
911
+ administrators: z.array(restPersonSchema),
912
+ });
913
+ /** What an avatar's parts were rolled from: a short text of letters, digits, hyphens and underscores. */
914
+ const avatarSeed = z.string().check(z.minLength(1), z.maxLength(64), z.regex(/^[A-Za-z0-9_-]+$/));
915
+ /**
916
+ * A persona proposed for an agent account (ADR-0084): the seed it was rolled from, a name in the
917
+ * language asked for, the handle the name gives where nobody has it, and the parts of an avatar.
918
+ * A suggestion, edited freely by whoever makes the account.
919
+ */
920
+ export const restAgentProposalSchema = z.object({
921
+ seed: z.string(),
922
+ name: z.string(),
923
+ handle: z.string(),
924
+ avatarParts: restAvatarPartsSchema,
925
+ });
926
+ /** `GET /api/v1/agents/proposals?count=&lang=`: a few personas to choose from, rolled again at each asking. */
927
+ export const restAgentProposalsSchema = z.object({ items: z.array(restAgentProposalSchema) });
928
+ /** The short name of a service an account is held at, spelled as a kind is: `github`, `slack`. */
929
+ const elsewhereService = z.string().check(z.regex(/^[a-z][a-z0-9-]{0,39}$/));
930
+ /** What the agent is called at a service: a line, and no secret. */
931
+ const elsewhereName = line(MAX_ELSEWHERE_NAME_LENGTH);
932
+ /** An hour and a minute of the day, as `09:00`. */
933
+ const clockTime = z.string().check(z.regex(/^(?:[01][0-9]|2[0-3]):[0-5][0-9]$/));
934
+ /**
935
+ * The hours an agent account keeps (ADR-0085, point 11), in the workspace's time zone: when its
936
+ * day starts, which is when its day's briefing is sent, and when it ends, with a wrap then, or
937
+ * `null` for a day with no end.
938
+ */
939
+ export const restAgentHoursSchema = z.object({
940
+ dayStart: clockTime,
941
+ dayEnd: z.nullable(clockTime),
942
+ });
943
+ /** The accounts an agent account holds elsewhere (ADR-0089): what it is called at each, by service. */
944
+ export const restAgentElsewhereSchema = z.record(elsewhereService, elsewhereName);
945
+ /**
946
+ * What `PATCH /api/v1/agents/<handle>` is sent: by a supervisor, the persona to keep, one or
947
+ * more of its name, its title (`null` for none) and its avatar; by a supervisor or the account
948
+ * itself, the accounts it holds elsewhere and the hours of its day. The handle never changes.
949
+ */
950
+ export const restAgentPatchSchema = z
951
+ .object({
952
+ /** When its day starts, `null` for the hour an account starts at where it says none; and when it ends, `null` for no end. */
953
+ dayStart: z.optional(z.nullable(clockTime)),
954
+ dayEnd: z.optional(z.nullable(clockTime)),
955
+ /** The accounts it holds elsewhere, by service: one left out stays as it is, `null` takes one away. */
956
+ accounts: z.optional(z
957
+ .record(elsewhereService, z.nullable(elsewhereName))
958
+ .check(z.refine((accounts) => Object.keys(accounts).length <= MAX_AGENT_ELSEWHERE, "names more accounts than one may hold"))),
959
+ name: z.optional(line(MAX_PERSON_NAME_LENGTH)),
960
+ title: z.optional(z.nullable(line(MAX_PERSON_TITLE_LENGTH))),
961
+ /** The parts of the avatar, and optionally the seed they were rolled from, `null` for parts chosen by hand. */
962
+ avatarParts: z.optional(restAvatarPartsSchema),
963
+ avatarSeed: z.optional(z.nullable(avatarSeed)),
964
+ })
965
+ .check(z.refine((patch) => patch.name !== undefined ||
966
+ patch.title !== undefined ||
967
+ patch.avatarParts !== undefined ||
968
+ patch.dayStart !== undefined ||
969
+ patch.dayEnd !== undefined ||
970
+ (patch.accounts !== undefined && Object.keys(patch.accounts).length > 0), "must name a name, a title, the parts of an avatar, an hour of its day or an account held elsewhere"));
971
+ /**
972
+ * An agent account as its own listing answers it (ADR-0084): the member it is, and whom it
973
+ * reports to.
974
+ */
975
+ export const restAgentSchema = z.object({
976
+ /** The account as a member: `kind: "agent"`, with its handle, its title and what its avatar is drawn from. */
977
+ person: restPersonSchema,
978
+ /** Whom it reports to, as the asker may see them; `null` where they may not. */
979
+ manager: z.nullable(restPersonSchema),
980
+ /**
981
+ * Whether the asker supervises it (ADR-0084): an administrator, or above it in the reporting
982
+ * line. What a supervisor may do of it, nobody else may.
983
+ */
984
+ supervised: z.boolean(),
985
+ /** How it stands, as its runner last said or the console noted (ADR-0085); `null` while no runner has ever said. */
986
+ state: z.optional(z.nullable(restAgentStateSchema)),
987
+ /** 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. */
988
+ runner: z.optional(z.nullable(restAgentRunnerSchema)),
989
+ /**
990
+ * The accounts it holds elsewhere (ADR-0089), what it is called at each by the service's short
991
+ * name, and no secret: answered where one account is read, so that taking it out knows what
992
+ * to close.
993
+ */
994
+ accounts: z.optional(restAgentElsewhereSchema),
995
+ /** The hours it keeps: answered where one account is read, to its supervisors and to the account. */
996
+ hours: z.optional(restAgentHoursSchema),
997
+ /** Its onboarding task (ADR-0088), where the console made one with the account: answered when the account is made. */
998
+ onboarding: z.optional(z.nullable(z.object({ project: z.string(), number: z.number().check(z.int()) }))),
999
+ /**
1000
+ * What its first sign-in is held to (ADR-0126), while nobody has signed in with it under a
1001
+ * sign-in at a git host: `account` where the host said which account its login is, so that
1002
+ * only that account is let in; `member` and `login` where the host did not, which the pages
1003
+ * and the command say as not confirmed. Left out once it has signed in, and under a provider
1004
+ * that makes its own addresses. Answered from 0.5.1 and read as optional.
1005
+ */
1006
+ firstSignIn: z.optional(z.enum(FIRST_SIGN_INS)),
1007
+ });
1008
+ /** `GET /api/v1/agents`: the agent accounts the asker may see, by handle. */
1009
+ export const restAgentsSchema = z.object({ items: z.array(restAgentSchema) });
1010
+ /**
1011
+ * What `POST /api/v1/agents` is sent, by an administrator: the account the agent will sign in
1012
+ * with, at one of the providers the deployment has, as a listing names one; its persona; its
1013
+ * manager, whoever makes it where none is named; and the project it starts in. A login a member
1014
+ * already carries is made an agent account only where `convert` asks for it, once (ADR-0104).
1015
+ */
1016
+ export const restAgentInputSchema = z
1017
+ .object({
1018
+ host: z.enum(PROVIDER_KEYS),
1019
+ login: z.string().check(z.trim(), z.minLength(1), z.maxLength(MAX_LOGIN_LENGTH)),
1020
+ handle,
1021
+ name: line(MAX_PERSON_NAME_LENGTH),
1022
+ title: z.optional(z.nullable(line(MAX_PERSON_TITLE_LENGTH))),
1023
+ /** What the proposals rolled the parts from, kept beside them; left out where they were chosen by hand. */
1024
+ avatarSeed: z.optional(avatarSeed),
1025
+ /** Left out, the console rolls them: from the seed where one is given, from one of its own otherwise. */
1026
+ avatarParts: z.optional(restAvatarPartsSchema),
1027
+ managerId: z.optional(uuid),
1028
+ /** The key of the project it starts in. */
1029
+ project: z.string().check(z.minLength(1), z.maxLength(MAX_PROJECT_KEY_LENGTH)),
1030
+ /**
1031
+ * `true` says that the member who carries the login already is to become the account, for
1032
+ * good (ADR-0104); left out, such a login is refused (`agent.login_is_member`). It asks
1033
+ * nothing of a login nobody carries.
1034
+ */
1035
+ convert: z.optional(z.boolean()),
1036
+ })
1037
+ .check(z.refine((input) => isLoginAt(input.host, input.login), "must be a login at the host"));
310
1038
  /** The words under `/projects/` that are the pages' own, which no project may be called. */
311
1039
  export const RESERVED_PROJECT_KEYS = ["new"];
312
1040
  /**
@@ -325,6 +1053,15 @@ export const restProjectIconSchema = z.object({
325
1053
  sha256: z.string().check(z.regex(/^[0-9a-f]{64}$/)),
326
1054
  contentType: z.enum(PROJECT_ICON_TYPES),
327
1055
  });
1056
+ /** How many tasks a goal, or a project's board, has in each state: what its progress is read from, live. */
1057
+ export const restTaskCountsSchema = z.object({
1058
+ idea: count,
1059
+ ready: count,
1060
+ in_progress: count,
1061
+ in_review: count,
1062
+ done: count,
1063
+ dropped: count,
1064
+ });
328
1065
  export const restProjectSchema = z.object({
329
1066
  id: uuid,
330
1067
  key: projectKey,
@@ -516,15 +1253,6 @@ export const restTaskPatchSchema = z.object({
516
1253
  dueOn: z.optional(z.nullable(day)),
517
1254
  links: z.optional(z.array(taskLinkInput).check(z.maxLength(MAX_LINKS))),
518
1255
  });
519
- /** How many tasks a goal has in each state: what its progress is read from, live. */
520
- export const restTaskCountsSchema = z.object({
521
- idea: count,
522
- ready: count,
523
- in_progress: count,
524
- in_review: count,
525
- done: count,
526
- dropped: count,
527
- });
528
1256
  /**
529
1257
  * A goal of a project's roadmap (ADR-0019): what the project works towards, with the day it is
530
1258
  * meant to be reached by, and how far the tasks under it are.
@@ -551,6 +1279,40 @@ export const restGoalSchema = z.object({
551
1279
  });
552
1280
  /** `GET /api/v1/projects/<key>/goals`: a page of the roadmap, the active goals first, and whether there is more after it. */
553
1281
  export const restGoalsSchema = z.object({ items: z.array(restGoalSchema), more: z.boolean() });
1282
+ /** A task as a project's glance shows it (ADR-0107): its title, its day and who is at work on it. */
1283
+ export const restGlanceTaskSchema = z.pick(restTaskSchema, {
1284
+ id: true,
1285
+ number: true,
1286
+ title: true,
1287
+ state: true,
1288
+ dueOn: true,
1289
+ workers: true,
1290
+ });
1291
+ /** A goal as a project's glance shows it: its title, its day and its tasks counted by state. */
1292
+ export const restGlanceGoalSchema = z.pick(restGoalSchema, {
1293
+ id: true,
1294
+ title: true,
1295
+ state: true,
1296
+ dueOn: true,
1297
+ taskCounts: true,
1298
+ });
1299
+ /**
1300
+ * `GET /api/v1/projects/<key>/glance`: what a project's tile at a glance shows (ADR-0105), read
1301
+ * at one moment so that its figures and its rows agree (ADR-0107). Each list is ordered and cut
1302
+ * by the console, `GLANCE_ROWS` at most, and says how many it has in all.
1303
+ */
1304
+ export const restProjectGlanceSchema = z.object({
1305
+ /** The tasks on its board, those put away left out, counted by state. */
1306
+ taskCounts: restTaskCountsSchema,
1307
+ /** How many decisions in it wait for a person. */
1308
+ openDecisions: count,
1309
+ /** Its tasks in progress, the sooner due first and those due on no day after. */
1310
+ inProgress: z.object({ items: z.array(restGlanceTaskSchema), total: count }),
1311
+ /** Its tasks waiting for review, in the same order. */
1312
+ inReview: z.object({ items: z.array(restGlanceTaskSchema), total: count }),
1313
+ /** Its goals ahead, the active and the planned, as the roadmap orders them. */
1314
+ goals: z.object({ items: z.array(restGlanceGoalSchema), total: count }),
1315
+ });
554
1316
  /** What `POST /api/v1/projects/<key>/goals` is sent: the title, and the rest with defaults. */
555
1317
  export const restGoalInputSchema = z.object({
556
1318
  title: line(MAX_TITLE_LENGTH),
@@ -723,6 +1485,35 @@ export const restPersonWorkSchema = z.object({
723
1485
  tasks: restWorkSchema.shape.tasks,
724
1486
  closed: restWorkSchema.shape.closed,
725
1487
  });
1488
+ /** A task as the plate's page asks for it: everything but its body, which the page does not show. */
1489
+ export const restTaskBriefSchema = z.omit(restTaskSchema, { body: true });
1490
+ /**
1491
+ * `GET /api/v1/projects/<key>/tasks?brief=true`: a page of the board as `.../tasks` answers it,
1492
+ * the tasks without their bodies, for whatever lists tasks and shows no body: a listing of
1493
+ * the command, a desk's pages. A console from before the brief form answers the tasks whole,
1494
+ * which reads the same.
1495
+ */
1496
+ export const restTaskBriefsSchema = z.object({
1497
+ items: z.array(restTaskBriefSchema),
1498
+ more: z.boolean(),
1499
+ });
1500
+ /** A decision as the plate's page asks for it: everything but its body. */
1501
+ export const restDecisionBriefSchema = z.omit(restDecisionSchema, { body: true });
1502
+ /**
1503
+ * `GET /api/v1/work?brief=true`: the plate as `GET /api/v1/work` answers it, the tasks and the
1504
+ * decisions without their bodies, which the plate's page does not show and which weigh more
1505
+ * than the rest of the plate together. What the pages read; the command reads the plate whole.
1506
+ */
1507
+ export const restWorkBriefSchema = z.object({
1508
+ tasks: z.array(z.object({ project: projectRef, task: restTaskBriefSchema })),
1509
+ closed: z.optional(z.array(z.object({ project: projectRef, task: restTaskBriefSchema }))),
1510
+ decisions: z.array(z.object({ project: projectRef, decision: restDecisionBriefSchema })),
1511
+ });
1512
+ /** `GET /api/v1/people/<id>/work?brief=true`: another person's plate without the tasks' bodies. */
1513
+ export const restPersonWorkBriefSchema = z.object({
1514
+ tasks: restWorkBriefSchema.shape.tasks,
1515
+ closed: restWorkBriefSchema.shape.closed,
1516
+ });
726
1517
  /**
727
1518
  * What `POST /api/v1/projects/<key>/decisions` is sent: the question, its context, and the
728
1519
  * options. As JSON; or, with files put on the decision (ADR-0055), as the part `decision` of a
@@ -755,6 +1546,13 @@ export const restDecisionPatchSchema = z.object({
755
1546
  /** What followed the decision; empty clears it. */
756
1547
  outcome: z.optional(body),
757
1548
  });
1549
+ /**
1550
+ * What `PUT .../decisions/<id>/deciders` is sent (ADR-0096): everyone a decision that waits is
1551
+ * for from now on, each once in the order named, in place of those it was for.
1552
+ */
1553
+ export const restDecisionDecidersSchema = z.object({
1554
+ deciderIds: z.array(uuid).check(z.minLength(1), z.maxLength(MAX_DECIDERS)),
1555
+ });
758
1556
  /**
759
1557
  * What `POST .../decisions/<id>/answer` is sent: one of the options by its id, or the person's
760
1558
  * own answer in a line, one of the two; and a word about either.
@@ -775,8 +1573,13 @@ export const restAnswerInputSchema = z
775
1573
  export const restEventDataSchema = z.object({
776
1574
  number: z.optional(z.int()),
777
1575
  title: z.optional(z.string()),
778
- /** For `task.updated`, `project.updated`, `goal.updated` and `decision.updated`: which fields changed. */
1576
+ /** For `task.updated`, `project.updated`, `goal.updated`, `decision.updated` and `person.updated`: which fields changed. */
779
1577
  fields: z.optional(z.array(z.string())),
1578
+ /** For a `task.updated` that put anyone to work on the task: their ids. */
1579
+ workersAdded: z.optional(z.array(uuid)),
1580
+ /** For `decision.addressed` (ADR-0096): the logins of everyone the decision is for now, and the ids of those named anew. */
1581
+ deciders: z.optional(z.array(z.string())),
1582
+ decidersAdded: z.optional(z.array(uuid)),
780
1583
  /** For the events about a document: its path, and the version written. */
781
1584
  path: z.optional(z.string()),
782
1585
  version: z.optional(z.int()),
@@ -796,6 +1599,16 @@ export const restEventDataSchema = z.object({
796
1599
  team: z.optional(z.string()),
797
1600
  /** For `person.email_changed`: whether the person has an address now; never the address itself. */
798
1601
  set: z.optional(z.boolean()),
1602
+ /** For `person.updated` of an agent account and for `agent.state_changed`: the account's handle. */
1603
+ handle: z.optional(z.string()),
1604
+ /**
1605
+ * For `agent.state_changed` (ADR-0085): how the agent account stands now; how it stood before,
1606
+ * `null` where nothing had been said of it; and why, in a few words, where the runner or the
1607
+ * console said.
1608
+ */
1609
+ state: z.optional(z.enum(AGENT_STATES)),
1610
+ was: z.optional(z.nullable(z.enum(AGENT_STATES))),
1611
+ detail: z.optional(z.string()),
799
1612
  /** For the events about a project: its key and its name. */
800
1613
  key: z.optional(z.string()),
801
1614
  name: z.optional(z.string()),
@@ -820,6 +1633,8 @@ export const restEventDataSchema = z.object({
820
1633
  capabilities: z.optional(z.array(z.string())),
821
1634
  /** For `plugin.configured` of a secret: `administrator`, or the host of the answer it was sealed from (ADR-0070). */
822
1635
  source: z.optional(z.string()),
1636
+ /** For `plugin.configured` of a keyed secret: the key its value was set, removed or moved under (ADR-0111). */
1637
+ under: z.optional(z.string()),
823
1638
  /** For `plugin.granted` and `plugin.revoked`: the plugin the role went to, by key, where one did (ADR-0072). */
824
1639
  grantee: z.optional(z.string()),
825
1640
  /** For `plugin.granted` and `plugin.revoked`: whether the role went to everyone. */
@@ -893,9 +1708,32 @@ export const restRunSchema = z.object({
893
1708
  artifacts: z.array(restArtifactSchema),
894
1709
  /** The id of the decision the run waits for, or `null`. */
895
1710
  waitingFor: z.nullable(uuid),
1711
+ /** The session of an agent account's runner the run was begun in (ADR-0086), or `null`; read as optional. */
1712
+ sessionId: z.optional(z.nullable(uuid)),
896
1713
  });
897
1714
  /** `GET /api/v1/projects/<key>/runs`: a page of the runs, newest first, and whether there is more. */
898
1715
  export const restRunsSchema = z.object({ items: z.array(restRunSchema), more: z.boolean() });
1716
+ /**
1717
+ * A run as a listing asks for it: everything but its reports, of which it says how many. The
1718
+ * reports are what a run says as it goes, and weigh more than the rest of a listing together.
1719
+ * A console from before the brief form (0.5.0) ignores the word and answers the run whole, so
1720
+ * what is read is either: the count where the console counted, the reports where it sent them.
1721
+ */
1722
+ export const restRunBriefSchema = z.extend(z.omit(restRunSchema, { reports: true }), {
1723
+ /** How many reports the run has, as the brief form says it. */
1724
+ reportCount: z.optional(count),
1725
+ /** The reports themselves, from a console from before the brief form; a console that knows it leaves them out. */
1726
+ reports: z.optional(z.array(restReportSchema)),
1727
+ });
1728
+ /** How many reports a run has, as a listing says it: as the console counted them, else as many as it sent. */
1729
+ export function reportCountOf(run) {
1730
+ return run.reportCount ?? run.reports?.length ?? 0;
1731
+ }
1732
+ /** `GET /api/v1/projects/<key>/runs?brief=true`: a page of the runs as `.../runs` answers it, without their reports. */
1733
+ export const restRunBriefsSchema = z.object({
1734
+ items: z.array(restRunBriefSchema),
1735
+ more: z.boolean(),
1736
+ });
899
1737
  /** A file put in a comment, kept as a run's file is; its bytes are at `projectPath(key, "files", <id>)`. */
900
1738
  export const restCommentFileSchema = z.object({
901
1739
  id: uuid,
@@ -962,6 +1800,13 @@ export const restSessionSchema = z.object({
962
1800
  platform: z.nullable(z.string()),
963
1801
  /** Where the browser last came from, as the server saw it, or `null` until seen. */
964
1802
  address: z.nullable(z.string()),
1803
+ /**
1804
+ * What holds the session (ADR-0084): a browser, or the command signed in as the account
1805
+ * itself. Answered from 0.5.0 and read as optional; a browser's then.
1806
+ */
1807
+ kind: z.optional(z.enum(SESSION_KINDS)),
1808
+ /** For the command's: what it called itself when it signed in, and where it runs; `null` for a browser's. Optional as above. */
1809
+ name: z.optional(z.nullable(z.string())),
965
1810
  });
966
1811
  /** `GET /api/v1/sessions`: the sessions of whoever asks, the current first and then the last used first, and how long one lives unused. */
967
1812
  export const restSessionsSchema = z.object({
@@ -981,19 +1826,35 @@ export const restTokenCreatedSchema = z.object({
981
1826
  /** Presented as `Authorization: Bearer <secret>`. The server keeps its hash, and never shows it again. */
982
1827
  secret: z.string(),
983
1828
  });
984
- /** What `POST /api/v1/connect` is sent by the command: what the agent calls itself, and where it runs. */
985
- export const restConnectInputSchema = z.object({ agent: line(MAX_TOKEN_NAME_LENGTH) });
1829
+ /**
1830
+ * What a connection asks to be (ADR-0011, ADR-0084): an agent of whoever approves it, which holds
1831
+ * a token of theirs, or the approver themselves, where the command is signed in as the account
1832
+ * and holds a session of its own.
1833
+ */
1834
+ export const CONNECT_AS = ["agent", "self"];
1835
+ /**
1836
+ * What `POST /api/v1/connect` is sent by the command: what the agent calls itself, and where it
1837
+ * runs; and what it asks to be, an agent where nothing is said.
1838
+ */
1839
+ export const restConnectInputSchema = z.object({
1840
+ agent: line(MAX_TOKEN_NAME_LENGTH),
1841
+ as: z.optional(z.enum(CONNECT_AS)),
1842
+ });
986
1843
  /**
987
1844
  * What `POST /api/v1/connect` answers (ADR-0011): the code a person approves, the address of the
988
1845
  * console's own page for it, and the secret the command claims the token with, shown nowhere.
1846
+ * Bounded, each no wider than the command's credentials file reads back (`cli/credentials.ts`),
1847
+ * since the route answers nobody and the command keeps the answer while it waits (ADR-0129):
1848
+ * a console answers a code of nine characters and a wait of a few seconds.
989
1849
  */
990
1850
  export const restConnectionSchema = z.object({
991
- code: z.string(),
992
- url: z.string(),
993
- secret: z.string(),
994
- expiresAt: instant,
995
- /** How many seconds the command waits between claims. */
996
- interval: z.int().check(z.positive()),
1851
+ code: z.string().check(z.minLength(1), z.maxLength(64)),
1852
+ url: z.string().check(z.minLength(1), z.maxLength(MAX_URL_LENGTH)),
1853
+ /** As long as the claim takes one. */
1854
+ secret: z.string().check(z.minLength(1), z.maxLength(MAX_SECRET_LENGTH)),
1855
+ expiresAt: z.iso.datetime().check(z.maxLength(40)),
1856
+ /** How many seconds the command waits between claims: ten minutes at most. */
1857
+ interval: z.int().check(z.positive(), z.lte(600)),
997
1858
  });
998
1859
  /** `GET /api/v1/connect/<code>`: what asks to connect, for the person who approves it. */
999
1860
  export const restConnectRequestSchema = z.object({
@@ -1003,15 +1864,22 @@ export const restConnectRequestSchema = z.object({
1003
1864
  createdAt: instant,
1004
1865
  expiresAt: instant,
1005
1866
  approved: z.boolean(),
1867
+ /** 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. */
1868
+ as: z.optional(z.enum(CONNECT_AS)),
1006
1869
  });
1007
1870
  /** What `POST /api/v1/connect/claim` is sent: the secret the connection began with. */
1008
1871
  export const restClaimInputSchema = z.object({
1009
1872
  secret: z.string().check(z.minLength(1), z.maxLength(MAX_SECRET_LENGTH)),
1010
1873
  });
1011
- /** What the claim answers: wait, or the token this once, with its secret. */
1874
+ /**
1875
+ * What the claim answers: wait; or the token this once, with its secret; or, for a connection
1876
+ * that asked to be the account itself, the command's session this once, with its secret, which is
1877
+ * presented as a token's is (ADR-0084).
1878
+ */
1012
1879
  export const restClaimSchema = z.union([
1013
1880
  z.object({ status: z.literal("pending"), expiresAt: instant }),
1014
1881
  z.object({ status: z.literal("connected"), token: restTokenSchema, secret: z.string() }),
1882
+ z.object({ status: z.literal("signed_in"), session: restSessionSchema, secret: z.string() }),
1015
1883
  ]);
1016
1884
  /** Why a pack did not answer a read: the code and the words the deployment, or the console reading a directory, gave, as the main repository's API spells them. */
1017
1885
  export const restPackRefusalSchema = z.object({
@@ -1132,6 +2000,24 @@ export const restSkillFindSchema = z.object({
1132
2000
  ...packEnvelope,
1133
2001
  read: z.nullable(packFindSchema),
1134
2002
  });
2003
+ /**
2004
+ * `GET .../skills/rows?path=&heading=&cursor=&limit=`: the tables of a document, or of every
2005
+ * document under a folder, as data, a page of them by whole files, as the pack answers its
2006
+ * `rows` read (`RestRows` of `@skillcdn/core`); `read` is `null` unless `ready` (ADR-0100).
2007
+ */
2008
+ export const restSkillRowsSchema = z.object({
2009
+ ...packEnvelope,
2010
+ read: z.nullable(packRowsSchema),
2011
+ });
2012
+ /**
2013
+ * `GET .../skills/code?path=&heading=&cursor=&limit=`: the fenced code blocks of a document, or
2014
+ * of every document under a folder, as data, a page of them, as the pack answers its `code`
2015
+ * read (`RestCode` of `@skillcdn/core`); `read` is `null` unless `ready` (ADR-0100).
2016
+ */
2017
+ export const restSkillCodeSchema = z.object({
2018
+ ...packEnvelope,
2019
+ read: z.nullable(packCodeSchema),
2020
+ });
1135
2021
  /**
1136
2022
  * A document's path (ADR-0009): segments of lowercase letters, digits and hyphens, separated
1137
2023
  * by slashes, as a repository keeps files; the document's address, which does not change.
@@ -1223,16 +2109,25 @@ export const restRulesPluginSchema = z.object({
1223
2109
  roles: z.array(z.string()),
1224
2110
  });
1225
2111
  /**
1226
- * `GET /api/v1/rules`, and each half of a project's (ADR-0023): the rules that hold, and where
1227
- * they come from. `reference`: the console's own, since the organization wrote none;
1228
- * `written`: the page written, with its facts; `none`: a project that adds none.
2112
+ * `GET /api/v1/rules`, and each half of a project's (ADR-0023, ADR-0120): the rules that hold,
2113
+ * and what stands beside the console's. At the workspace, `reference`: the console's rules
2114
+ * alone, since the organization adds nothing; `written`: something is added, on its page. In
2115
+ * a project's own half, `written`: the page the project wrote; `none`: it adds none.
1229
2116
  */
1230
2117
  export const restRulesSchema = z.object({
1231
2118
  source: z.enum(RULES_SOURCES),
1232
- /** The rules as they hold, Markdown; `null` for a project that adds none. */
2119
+ /**
2120
+ * The rules as they hold, Markdown. At the workspace, whole: the console's, then what the
2121
+ * organization adds under a heading of its own, which is what a command of before prints.
2122
+ * `null` for a project that adds none.
2123
+ */
1233
2124
  body: z.nullable(z.string()),
1234
- /** The page they are written on, or `null` for the console's own and for none. */
2125
+ /** The page what is added is written on, or `null` where nothing is added. */
1235
2126
  page: z.nullable(restDocumentSummarySchema),
2127
+ /** At the workspace, from 0.5.1: the console's rules by themselves, as they always hold. */
2128
+ own: z.optional(z.string()),
2129
+ /** At the workspace, from 0.5.1: what the organization adds, with its page; `null` where it adds nothing. */
2130
+ added: z.optional(z.nullable(z.object({ body: z.string(), page: restDocumentSummarySchema }))),
1236
2131
  /** At the workspace: every plugin the asker may use, by key; left out in the halves of a project's answer. */
1237
2132
  plugins: z.optional(z.array(restRulesPluginSchema)),
1238
2133
  });
@@ -1243,7 +2138,11 @@ export const restProjectRulesSchema = z.object({
1243
2138
  /** The plugins bound to the project, as its board project or on it, that the asker holds a role in. */
1244
2139
  plugins: z.optional(z.array(restRulesPluginSchema)),
1245
2140
  });
1246
- /** What `PUT /api/v1/rules` is sent: the rules as they are to be. */
2141
+ /**
2142
+ * What `PUT /api/v1/rules` is sent: what the organization adds, as it is to be. A body that
2143
+ * carries the console's rules whole, as a client of before read them, is taken for what stands
2144
+ * before and after them.
2145
+ */
1247
2146
  export const restRulesInputSchema = z.object({
1248
2147
  body: paragraphs(MAX_RULES_LENGTH),
1249
2148
  /** The version the writer started from; the write is refused when the rules have moved on. */