@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
@@ -0,0 +1,94 @@
1
+ // The boards a front page shows at a glance (ADR-0105), each read in one request (ADR-0107):
2
+ // which are read, when they are read again, and what becomes of an answer that comes late or
3
+ // not at all. Pure: it is given the way to read one and the way to wait, so that the
4
+ // composition's hook is a few lines and a test needs no page.
5
+ /** How long after a read that failed the next is tried, doubling from the first to the longest. */
6
+ export const GLANCE_RETRY_MS = 3_000;
7
+ export const GLANCE_RETRY_MAX_MS = 60_000;
8
+ const soon = (run, ms) => {
9
+ const timer = setTimeout(run, ms);
10
+ return () => clearTimeout(timer);
11
+ };
12
+ /**
13
+ * Reads the glances a front page shows. A project is read once for each reading; an answer is
14
+ * kept only if it is still the reading it was asked for, so that a slow one never writes over a
15
+ * newer one; and a read that failed is tried again, a little later each time, for as long as the
16
+ * project is shown at a glance, so that one bad moment does not leave a tile empty for good.
17
+ */
18
+ export function createGlanceReader(options) {
19
+ const later = options.later ?? soon;
20
+ const again = options.again ?? (() => true);
21
+ let reading = 0;
22
+ let stopped = false;
23
+ let wanted = new Map();
24
+ /** Each project by the reading it was last asked for. */
25
+ const asked = new Map();
26
+ /** The tries that wait, by project, each with the way to call it off. */
27
+ const waiting = new Map();
28
+ const ask = (project, attempt) => {
29
+ const mine = reading;
30
+ asked.set(project.id, mine);
31
+ const current = () => !stopped && asked.get(project.id) === mine;
32
+ options.read(project).then((glance) => {
33
+ if (current()) {
34
+ options.store(project.id, glance);
35
+ }
36
+ }, (failure) => {
37
+ if (!current()) {
38
+ return;
39
+ }
40
+ if (!wanted.has(project.id) || !again(failure)) {
41
+ // Asked again when it is shown at a glance anew, or at the next reading.
42
+ asked.delete(project.id);
43
+ return;
44
+ }
45
+ const wait = Math.min(GLANCE_RETRY_MS * 2 ** attempt, GLANCE_RETRY_MAX_MS);
46
+ waiting.set(project.id, later(() => {
47
+ waiting.delete(project.id);
48
+ if (!current()) {
49
+ return;
50
+ }
51
+ const shown = wanted.get(project.id);
52
+ if (shown === undefined) {
53
+ asked.delete(project.id);
54
+ return;
55
+ }
56
+ ask(shown, attempt + 1);
57
+ }, wait));
58
+ });
59
+ };
60
+ return {
61
+ want(projects) {
62
+ wanted = new Map(projects.map((project) => [project.id, project]));
63
+ if (stopped) {
64
+ return;
65
+ }
66
+ for (const project of projects) {
67
+ if (asked.get(project.id) !== reading) {
68
+ ask(project, 0);
69
+ }
70
+ }
71
+ },
72
+ renew() {
73
+ if (stopped) {
74
+ return;
75
+ }
76
+ reading += 1;
77
+ for (const cancel of waiting.values()) {
78
+ cancel();
79
+ }
80
+ waiting.clear();
81
+ for (const project of wanted.values()) {
82
+ ask(project, 0);
83
+ }
84
+ },
85
+ stop() {
86
+ stopped = true;
87
+ for (const cancel of waiting.values()) {
88
+ cancel();
89
+ }
90
+ waiting.clear();
91
+ },
92
+ };
93
+ }
94
+ //# sourceMappingURL=glances.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glances.js","sourceRoot":"","sources":["../src/glances.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,6FAA6F;AAC7F,qFAAqF;AACrF,8DAA8D;AAE9D,mGAAmG;AACnG,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AACrC,MAAM,CAAC,MAAM,mBAAmB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IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,OAAO,EAAE,CAAC;oBACtC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;QACH,CAAC;QACD,KAAK;YACH,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO;YACT,CAAC;YACD,OAAO,IAAI,CAAC,CAAC;YACb,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;gBACtC,MAAM,EAAE,CAAC;YACX,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAC;YAChB,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;gBACtC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;QACD,IAAI;YACF,OAAO,GAAG,IAAI,CAAC;YACf,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;gBACtC,MAAM,EAAE,CAAC;YACX,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -36,6 +36,40 @@ export interface PlacedTile {
36
36
  readonly y: number;
37
37
  readonly size: HomeTileSize;
38
38
  }
39
+ /** Whether a project at a size shows a glance of its board: what is at work in it, and its roadmap (ADR-0105). */
40
+ export declare function isGlanceSize(size: HomeTileSize): boolean;
41
+ /** The projects a page shows at a glance, in its order: the ones whose boards are read for it. */
42
+ export declare function glanceProjects(shown: readonly {
43
+ readonly tile: HomeTile;
44
+ readonly size: HomeTileSize;
45
+ }[]): RestProject[];
46
+ /**
47
+ * The heights a glance is laid out with, in rem, which its stylesheet gives the same parts: a
48
+ * list's heading, a task's row, a goal's row of two lines, the line that says how many more, and
49
+ * the room between two lists, a hairline in it.
50
+ */
51
+ export declare const GLANCE_REM: {
52
+ readonly heading: 1.5;
53
+ readonly task: 2.25;
54
+ readonly goal: 3;
55
+ readonly more: 1.5;
56
+ readonly between: 1.5;
57
+ };
58
+ /** The room a glance's lists are taken to have before it is laid out, in rem, by the size of the tile. */
59
+ export declare const GLANCE_ROOM_GUESS: Partial<Record<HomeTileSize, number>>;
60
+ /** A list of a glance: the rows it could show, how many there are in all, and the height of a row, in rem. */
61
+ export interface GlanceList {
62
+ readonly rows: number;
63
+ readonly total: number;
64
+ readonly row: number;
65
+ }
66
+ /**
67
+ * The rows of a glance's lists, one under the other, that a room holds, each row whole (ADR-0105):
68
+ * the steps give rows in turn, each step a list and the rows it may have by then, so that the
69
+ * lists that matter most are seen first and the others as the room allows. A list with no rows to
70
+ * show takes no room.
71
+ */
72
+ export declare function glanceFit(room: number, lists: readonly GlanceList[], steps: readonly (readonly [number, number])[]): number[];
39
73
  /**
40
74
  * Every tile the person may see: the widgets of the plugins that are on, which they hold a role
41
75
  * for, and the projects, those a manifest places at the top first and those at the bottom last.
@@ -61,15 +95,45 @@ export declare function startingSizeAt(tile: HomeTile, columns: number): HomeTil
61
95
  /** The cells a size takes on a grid of so many columns: never wider than the grid. */
62
96
  export declare function footprintOf(size: HomeTileSize, columns: number): Footprint;
63
97
  /**
64
- * The page as it stands: what the person kept for this width where they stand, or, kept for
65
- * another width, the same order packed from the top; a tile they may no longer see stays out, a
66
- * size it no longer comes in, or that is too wide for this grid, becomes the one it starts at
67
- * here, and a tile on another's cells moves to the nearest room. What they have not seen yet takes the first room, a plugin's widgets as soon
68
- * as it is on; what they took off stays off.
98
+ * The page as it stands on the grid: what the person kept for this width where they stand; for
99
+ * someone who has arranged nothing, the composed page on the cells nearest it; for a width nobody
100
+ * arranged when another was, the order kept there, closed up so that no cell stands empty where
101
+ * the sizes the tiles come in allow it (ADR-0082). A tile they may no longer
102
+ * see stays out, a size it no longer comes in, or that is too wide for this grid, becomes the one
103
+ * it starts at here, and a tile on another's cells moves to the nearest room. What they have not
104
+ * seen yet takes the first room of a width they arranged, a plugin's widgets as soon as it is on;
105
+ * what they took off stays off.
69
106
  */
70
107
  export declare function arranged(tiles: readonly HomeTile[], home: RestHome | null | undefined, columns: HomeColumns): PlacedTile[];
71
108
  /** How many rows the page takes. */
72
109
  export declare function rowsOf(placed: readonly PlacedTile[], columns: number): number;
110
+ /** Whether the person has arranged no width of the page, whatever they took off it. */
111
+ export declare function nobodyArranged(home: RestHome | null | undefined): boolean;
112
+ /** The page put back as composed: no width arranged, nothing taken off (ADR-0109). */
113
+ export declare const COMPOSED_HOME: RestHome;
114
+ /** Whether the page stands as composed, nothing taken off: nothing for putting it back to undo. */
115
+ export declare function standsComposed(home: RestHome | null | undefined): boolean;
116
+ /**
117
+ * A tile of the composed page: where it stands and how far it reaches, in cells, which need not
118
+ * be whole, and the size its frame is told, the one of its own nearest that shape.
119
+ */
120
+ export interface ComposedTile extends PlacedTile {
121
+ readonly w: number;
122
+ readonly h: number;
123
+ }
124
+ /**
125
+ * The page of someone who has arranged nothing, composed (ADR-0082): the first widget leads,
126
+ * half the page wide, and beside it stand the next two widgets and the projects, the column as
127
+ * high as the lead; on a grid of six columns or fewer they stand one under the other. With nothing
128
+ * beside it, the lead stands at a size it comes in, and the projects follow it in the columns it
129
+ * leaves (ADR-0110). The projects are icons, one to a cell, in rows as long as their column has
130
+ * cells, so that a project is never drawn in a shape it does not come in and the page is the one
131
+ * arranging starts from (ADR-0108); the last row may end short. The other widgets stand below, two
132
+ * to a row.
133
+ */
134
+ export declare function composed(tiles: readonly HomeTile[], home: RestHome | null | undefined, columns: HomeColumns): ComposedTile[];
135
+ /** How many rows the composed page takes, which need not be whole. */
136
+ export declare function composedRows(boxes: readonly ComposedTile[]): number;
73
137
  /**
74
138
  * The page with a tile moved to a place, as a phone's home screen does it. Where the place is
75
139
  * free it stands there. On a tile of its own shape, the tiles of that shape between the two
@@ -1 +1 @@
1
- {"version":3,"file":"home-tiles.d.ts","sourceRoot":"","sources":["../src/home-tiles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,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AED,sEAAsE;AACtE,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,CAEnE;AA8BD;;;;;GAKG;AACH,wBAAgB,KAAK,CACnB,MAAM,EAAE,SAAS,UAAU,EAAE,EAC7B,EAAE,EAAE,MAAM,EACV,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,OAAO,EAAE,MAAM,GACd,SAAS,UAAU,EAAE,CAuCvB;AAMD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,GAAG,MAAM,CAG9D;AAED,mGAAmG;AACnG,wBAAgB,OAAO,CACrB,MAAM,EAAE,SAAS,UAAU,EAAE,EAC7B,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,MAAM,GACd,SAAS,UAAU,EAAE,CAWvB;AAED,oFAAoF;AACpF,wBAAgB,KAAK,CACnB,MAAM,EAAE,SAAS,UAAU,EAAE,EAC7B,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,MAAM,GACd,SAAS,UAAU,EAAE,CAIvB;AAED,mFAAmF;AACnF,wBAAgB,QAAQ,CACtB,IAAI,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,EACjC,MAAM,EAAE,SAAS,UAAU,EAAE,EAC7B,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,OAAO,EAAE,WAAW,GACnB,QAAQ,CAgBV"}
@@ -3,8 +3,10 @@ import { PLUGIN_WIDGET_SIZE_CELLS, widgetSizesOf } from "./plugin/manifest.js";
3
3
  // The front page as a person arranges it (ADR-0061): one grid of square cells, on which the
4
4
  // projects and the plugins' widgets are tiles alike, each at a place of its own. What there is
5
5
  // comes from what the person may see; where each stands comes from what they kept, one layout
6
- // for each width of the grid. What is new takes the first room, what they took off stays off,
7
- // and what they may no longer see waits out of sight for its place. Pure functions, so that the
6
+ // for each width of the grid. Someone who has arranged nothing sees the page composed edge to
7
+ // edge, and a width nobody arranged when another was is closed up from the sizes the tiles come
8
+ // in (ADR-0082); on one they arranged, what is new takes the first room. What they took off stays
9
+ // off, and what they may no longer see waits out of sight for its place. Pure functions, so that the
8
10
  // page and the tests read the same arrangement.
9
11
  /** The grid's columns at each width: wide, a laptop's, a tablet's, a phone's. */
10
12
  export const HOME_COLUMNS = [12, 8, 6, 4];
@@ -20,7 +22,72 @@ export function columnsFor(width) {
20
22
  }
21
23
  /** The cells a tile takes at each size: an icon one, the widgets' family as the phones have it. */
22
24
  export const HOME_TILE_CELLS = { icon: { columns: 1, rows: 1 }, ...PLUGIN_WIDGET_SIZE_CELLS };
23
- const PROJECT_SIZES = ["icon", "small"];
25
+ /**
26
+ * A project comes as an icon, a card, and at a glance of its board in three shapes (ADR-0105):
27
+ * `medium` 4×2, `large` 4×4 and `wide` 8×2. Not `full`: at 8×4 a glance had more room than it
28
+ * has things to say.
29
+ */
30
+ const PROJECT_SIZES = ["icon", "small", "medium", "large", "wide"];
31
+ /** The sizes the projects take together where a width is closed up: the small ones a person kept them at before a glance existed. */
32
+ const PROJECT_ALIKE_SIZES = ["icon", "small"];
33
+ /** Whether a project at a size shows a glance of its board: what is at work in it, and its roadmap (ADR-0105). */
34
+ export function isGlanceSize(size) {
35
+ return size === "medium" || size === "large" || size === "wide";
36
+ }
37
+ /** The projects a page shows at a glance, in its order: the ones whose boards are read for it. */
38
+ export function glanceProjects(shown) {
39
+ return shown.flatMap(({ tile, size }) => tile.kind === "project" && isGlanceSize(size) ? [tile.project] : []);
40
+ }
41
+ /**
42
+ * The heights a glance is laid out with, in rem, which its stylesheet gives the same parts: a
43
+ * list's heading, a task's row, a goal's row of two lines, the line that says how many more, and
44
+ * the room between two lists, a hairline in it.
45
+ */
46
+ export const GLANCE_REM = { heading: 1.5, task: 2.25, goal: 3, more: 1.5, between: 1.5 };
47
+ /** The room a glance's lists are taken to have before it is laid out, in rem, by the size of the tile. */
48
+ export const GLANCE_ROOM_GUESS = {
49
+ medium: 6,
50
+ large: 20,
51
+ wide: 12,
52
+ };
53
+ /** The height a list takes with so many rows shown: nothing with none, the line of how many more while some are left out. */
54
+ function listHeight(shown, list) {
55
+ return shown === 0
56
+ ? 0
57
+ : GLANCE_REM.heading + shown * list.row + (shown < list.total ? GLANCE_REM.more : 0);
58
+ }
59
+ /**
60
+ * The rows of a glance's lists, one under the other, that a room holds, each row whole (ADR-0105):
61
+ * the steps give rows in turn, each step a list and the rows it may have by then, so that the
62
+ * lists that matter most are seen first and the others as the room allows. A list with no rows to
63
+ * show takes no room.
64
+ */
65
+ export function glanceFit(room, lists, steps) {
66
+ const shown = lists.map(() => 0);
67
+ if (!Number.isFinite(room)) {
68
+ return shown;
69
+ }
70
+ const height = (counts) => {
71
+ const used = lists.map((list, at) => listHeight(counts[at] ?? 0, list));
72
+ const showing = used.filter((value) => value > 0).length;
73
+ return (used.reduce((sum, value) => sum + value, 0) + Math.max(0, showing - 1) * GLANCE_REM.between);
74
+ };
75
+ for (const [at, upTo] of steps) {
76
+ const list = lists[at];
77
+ if (list === undefined) {
78
+ continue;
79
+ }
80
+ const limit = Math.min(upTo, list.rows);
81
+ while ((shown[at] ?? 0) < limit) {
82
+ const next = shown.map((count, index) => (index === at ? count + 1 : count));
83
+ if (height(next) > room) {
84
+ break;
85
+ }
86
+ shown[at] = (shown[at] ?? 0) + 1;
87
+ }
88
+ }
89
+ return shown;
90
+ }
24
91
  /**
25
92
  * Every tile the person may see: the widgets of the plugins that are on, which they hold a role
26
93
  * for, and the projects, those a manifest places at the top first and those at the bottom last.
@@ -144,17 +211,131 @@ function keptAt(home, columns) {
144
211
  }
145
212
  return { entries: [], placed: false };
146
213
  }
214
+ /** The size combinations tried at most, so that a page of many widgets is still laid out at once. */
215
+ const MOST_COMBINATIONS = 4096;
216
+ /** Whether one score comes before another, read from its first number. */
217
+ function lessThan(score, than) {
218
+ const at = score.findIndex((value, index) => value !== than[index]);
219
+ return at >= 0 && (score[at] ?? 0) < (than[at] ?? 0);
220
+ }
221
+ /** The tiles in order, each at its size, at the first room reading from the top. */
222
+ function packed(wanted, sizes, columns) {
223
+ const taken = new Set();
224
+ return wanted.map(({ tile }, at) => {
225
+ const size = sizes[at] ?? startingSizeAt(tile, columns);
226
+ const shape = footprintOf(size, columns);
227
+ const place = firstRoom(taken, shape, columns);
228
+ occupy(taken, place, shape, columns);
229
+ return { tile, size, ...place };
230
+ });
231
+ }
147
232
  /**
148
- * The page as it stands: what the person kept for this width where they stand, or, kept for
149
- * another width, the same order packed from the top; a tile they may no longer see stays out, a
150
- * size it no longer comes in, or that is too wide for this grid, becomes the one it starts at
151
- * here, and a tile on another's cells moves to the nearest room. What they have not seen yet takes the first room, a plugin's widgets as soon
152
- * as it is on; what they took off stays off.
233
+ * A width nobody arranged, closed up (ADR-0082): the same order, each tile at one of the sizes it
234
+ * comes in here, chosen so that the fewest cells stand empty within the page, then so that the
235
+ * fewest tiles leave the size they would rather have, then so that the page is the shortest. The
236
+ * projects take one size together, so that they line up as a row of the same tiles; a widget
237
+ * takes any of its own. A page that cannot close leaves the fewest cells empty it can.
238
+ */
239
+ function closedUp(wanted, columns) {
240
+ const projects = wanted.flatMap((entry, at) => (entry.tile.kind === "project" ? [at] : []));
241
+ // The choices: for each widget its sizes, the one it would rather have first; for the projects
242
+ // together, each its own, then each of the sizes a project comes in, all alike.
243
+ const choices = [];
244
+ if (projects.length > 0) {
245
+ const own = projects.map((at) => wanted[at]?.size ?? "icon");
246
+ const alike = PROJECT_ALIKE_SIZES.filter((size) => HOME_TILE_CELLS[size].columns <= columns).map((size) => projects.map(() => size));
247
+ const options = [own, ...alike].filter((option, index, all) => all.findIndex((other) => other.join() === option.join()) === index);
248
+ choices.push({ at: projects, options });
249
+ }
250
+ let combinations = choices[0]?.options.length ?? 1;
251
+ wanted.forEach((entry, at) => {
252
+ if (entry.tile.kind !== "widget") {
253
+ return;
254
+ }
255
+ const others = sizesAt(entry.tile, columns).filter((size) => size !== entry.size);
256
+ const all = [entry.size, ...others];
257
+ // Past what can be tried at once, a widget keeps the size it would rather have.
258
+ const options = combinations * all.length <= MOST_COMBINATIONS ? all : [entry.size];
259
+ combinations *= options.length;
260
+ choices.push({ at: [at], options: options.map((size) => [size]) });
261
+ });
262
+ const preferred = wanted.map((entry) => entry.size);
263
+ let best;
264
+ const trying = (index, sizes, changed) => {
265
+ const choice = choices[index];
266
+ if (choice === undefined) {
267
+ const placed = packed(wanted, sizes, columns);
268
+ const rows = rowsOf(placed, columns);
269
+ const filled = placed.reduce((cells, { size }) => {
270
+ const { w, h } = footprintOf(size, columns);
271
+ return cells + w * h;
272
+ }, 0);
273
+ const score = [rows * columns - filled, changed, rows];
274
+ if (best === undefined || lessThan(score, best.score)) {
275
+ best = { placed, score };
276
+ }
277
+ return;
278
+ }
279
+ choice.options.forEach((option) => {
280
+ const next = [...sizes];
281
+ choice.at.forEach((at, nth) => {
282
+ next[at] = option[nth] ?? preferred[at];
283
+ });
284
+ const differs = choice.at.some((at) => next[at] !== preferred[at]) ? 1 : 0;
285
+ trying(index + 1, next, changed + differs);
286
+ });
287
+ };
288
+ trying(0, [...preferred], 0);
289
+ return best?.placed ?? packed(wanted, preferred, columns);
290
+ }
291
+ /**
292
+ * The page as it stands on the grid: what the person kept for this width where they stand; for
293
+ * someone who has arranged nothing, the composed page on the cells nearest it; for a width nobody
294
+ * arranged when another was, the order kept there, closed up so that no cell stands empty where
295
+ * the sizes the tiles come in allow it (ADR-0082). A tile they may no longer
296
+ * see stays out, a size it no longer comes in, or that is too wide for this grid, becomes the one
297
+ * it starts at here, and a tile on another's cells moves to the nearest room. What they have not
298
+ * seen yet takes the first room of a width they arranged, a plugin's widgets as soon as it is on;
299
+ * what they took off stays off.
153
300
  */
154
301
  export function arranged(tiles, home, columns) {
155
302
  const byId = new Map(tiles.map((tile) => [tile.id, tile]));
156
303
  const hidden = new Set(home?.hidden ?? []);
157
304
  const { entries, placed: keepsPlaces } = keptAt(home, columns);
305
+ if (nobodyArranged(home)) {
306
+ // Arranging starts from the page as it was composed, each tile on the cells nearest it: a
307
+ // project on the very cell it stood on (ADR-0108), a lead alone on its own (ADR-0110).
308
+ const taken = new Set();
309
+ return composed(tiles, home, columns).map(({ tile, size, x, y }) => {
310
+ const shape = footprintOf(size, columns);
311
+ const near = { x: Math.round(x), y: Math.round(y) };
312
+ const place = fits(taken, near, shape, columns)
313
+ ? near
314
+ : nearestRoom(taken, shape, near, columns);
315
+ occupy(taken, place, shape, columns);
316
+ return { tile, size, ...place };
317
+ });
318
+ }
319
+ if (!keepsPlaces) {
320
+ const wanted = [];
321
+ const seen = new Set();
322
+ for (const entry of entries) {
323
+ const tile = byId.get(entry.tile);
324
+ if (tile !== undefined && !hidden.has(tile.id) && !seen.has(tile.id)) {
325
+ const size = sizesAt(tile, columns).includes(entry.size)
326
+ ? entry.size
327
+ : startingSizeAt(tile, columns);
328
+ wanted.push({ tile, size });
329
+ seen.add(tile.id);
330
+ }
331
+ }
332
+ for (const tile of tiles) {
333
+ if (!hidden.has(tile.id) && !seen.has(tile.id)) {
334
+ wanted.push({ tile, size: startingSizeAt(tile, columns) });
335
+ }
336
+ }
337
+ return closedUp(wanted, columns);
338
+ }
158
339
  const taken = new Set();
159
340
  const placed = [];
160
341
  const seen = new Set();
@@ -175,7 +356,7 @@ export function arranged(tiles, home, columns) {
175
356
  const size = sizesAt(tile, columns).includes(entry.size)
176
357
  ? entry.size
177
358
  : startingSizeAt(tile, columns);
178
- put(tile, size, keepsPlaces ? { x: entry.x, y: entry.y } : undefined);
359
+ put(tile, size, { x: entry.x, y: entry.y });
179
360
  }
180
361
  }
181
362
  for (const tile of tiles) {
@@ -189,6 +370,163 @@ export function arranged(tiles, home, columns) {
189
370
  export function rowsOf(placed, columns) {
190
371
  return Math.max(0, ...placed.map((tile) => tile.y + footprintOf(tile.size, columns).h));
191
372
  }
373
+ /** Whether the person has arranged no width of the page, whatever they took off it. */
374
+ export function nobodyArranged(home) {
375
+ return home === null || home === undefined || Object.keys(home.layouts).length === 0;
376
+ }
377
+ /** The page put back as composed: no width arranged, nothing taken off (ADR-0109). */
378
+ export const COMPOSED_HOME = { hidden: [], layouts: {} };
379
+ /** Whether the page stands as composed, nothing taken off: nothing for putting it back to undo. */
380
+ export function standsComposed(home) {
381
+ return nobodyArranged(home) && (home?.hidden.length ?? 0) === 0;
382
+ }
383
+ /** The rows a widget beside the lead takes, and those the lead takes at least. */
384
+ const SIDE_ROWS = 2;
385
+ const LEAD_ROWS = 4;
386
+ /** The widgets that stand beside the lead at most; the others stand below, two to a row. */
387
+ const MOST_BESIDE = 2;
388
+ /** The rows of projects the column beside the lead holds at most; more go below, across the page. */
389
+ const MOST_PROJECT_ROWS_BESIDE = 2;
390
+ /**
391
+ * Of the sizes a tile comes in on this grid, the one nearest a shape; on a tie the one that fits
392
+ * within it, so that a frame is never told of more room than it has, then its own, then the smaller.
393
+ */
394
+ function nearestSize(tile, w, h, columns) {
395
+ if (tile.kind === "project") {
396
+ return "icon";
397
+ }
398
+ const away = (size) => {
399
+ const cells = footprintOf(size, columns);
400
+ return Math.abs(cells.w - w) + Math.abs(cells.h - h);
401
+ };
402
+ const within = (size) => {
403
+ const cells = footprintOf(size, columns);
404
+ return cells.w <= w && cells.h <= h;
405
+ };
406
+ const area = (size) => HOME_TILE_CELLS[size].columns * HOME_TILE_CELLS[size].rows;
407
+ return [...sizesAt(tile, columns)].sort((a, b) => away(a) - away(b) ||
408
+ Number(within(b)) - Number(within(a)) ||
409
+ Number(b === tile.defaultSize) - Number(a === tile.defaultSize) ||
410
+ area(a) - area(b))[0];
411
+ }
412
+ /**
413
+ * The page of someone who has arranged nothing, composed (ADR-0082): the first widget leads,
414
+ * half the page wide, and beside it stand the next two widgets and the projects, the column as
415
+ * high as the lead; on a grid of six columns or fewer they stand one under the other. With nothing
416
+ * beside it, the lead stands at a size it comes in, and the projects follow it in the columns it
417
+ * leaves (ADR-0110). The projects are icons, one to a cell, in rows as long as their column has
418
+ * cells, so that a project is never drawn in a shape it does not come in and the page is the one
419
+ * arranging starts from (ADR-0108); the last row may end short. The other widgets stand below, two
420
+ * to a row.
421
+ */
422
+ export function composed(tiles, home, columns) {
423
+ const hidden = new Set(home?.hidden ?? []);
424
+ const shown = tiles.filter((tile) => !hidden.has(tile.id));
425
+ const widgets = shown.filter((tile) => tile.kind === "widget");
426
+ const top = widgets.filter((tile) => tile.widget.place === "home:top");
427
+ const bottom = widgets.filter((tile) => tile.widget.place !== "home:top");
428
+ const projects = shown.filter((tile) => tile.kind === "project");
429
+ const boxes = [];
430
+ const put = (tile, x, y, w, h) => {
431
+ boxes.push({ tile, size: nearestSize(tile, w, h, columns), x, y, w, h });
432
+ };
433
+ /** The rows the projects take in a column so wide: as many to a row as a cell each allows. */
434
+ const projectRows = (width) => projects.length === 0 ? 0 : Math.ceil(projects.length / Math.max(1, Math.floor(width)));
435
+ /** The projects in rows from a place, one to a cell, each row as long as the width has cells. */
436
+ const putProjects = (x, y, width) => {
437
+ const across = Math.max(1, Math.floor(width));
438
+ projects.forEach((tile, nth) => {
439
+ put(tile, x + (nth % across), y + Math.floor(nth / across), 1, 1);
440
+ });
441
+ return projectRows(width);
442
+ };
443
+ /**
444
+ * The projects beside a tile in the page's corner, so wide and so high: one to a cell in the
445
+ * columns it leaves, no lower than it reaches, then across the page below it. The row after them.
446
+ */
447
+ const putProjectsBeside = (w, h) => {
448
+ const across = columns - w;
449
+ const beside = Math.min(projects.length, across * h);
450
+ projects.forEach((tile, nth) => {
451
+ const below = nth - beside;
452
+ if (below < 0) {
453
+ put(tile, w + (nth % across), Math.floor(nth / across), 1, 1);
454
+ }
455
+ else {
456
+ put(tile, below % columns, h + Math.floor(below / columns), 1, 1);
457
+ }
458
+ });
459
+ const left = projects.length - beside;
460
+ return h + Math.ceil(left / columns);
461
+ };
462
+ /** Widgets two to a row across the page, one alone as wide as the page. */
463
+ const putInPairs = (list, from) => {
464
+ let y = from;
465
+ for (let at = 0; at < list.length; at += 2) {
466
+ const first = list[at];
467
+ const second = list[at + 1];
468
+ if (first !== undefined && second !== undefined) {
469
+ put(first, 0, y, columns / 2, SIDE_ROWS);
470
+ put(second, columns / 2, y, columns / 2, SIDE_ROWS);
471
+ }
472
+ else if (first !== undefined) {
473
+ put(first, 0, y, columns, SIDE_ROWS);
474
+ }
475
+ y += SIDE_ROWS;
476
+ }
477
+ return y;
478
+ };
479
+ const [lead, ...others] = top;
480
+ const beside = others.slice(0, MOST_BESIDE);
481
+ let y = 0;
482
+ if (lead !== undefined && beside.length > 0 && columns >= 8) {
483
+ const half = columns / 2;
484
+ const projectsBeside = projectRows(half) <= MOST_PROJECT_ROWS_BESIDE;
485
+ const besideRows = beside.length * SIDE_ROWS + (projectsBeside ? projectRows(half) : 0);
486
+ const height = Math.max(besideRows, LEAD_ROWS);
487
+ // A column shorter than the lead gives its widgets the rows left over, alike.
488
+ const widgetRows = SIDE_ROWS + (height - besideRows) / beside.length;
489
+ put(lead, 0, 0, half, height);
490
+ let at = 0;
491
+ for (const tile of beside) {
492
+ put(tile, half, at, half, widgetRows);
493
+ at += widgetRows;
494
+ }
495
+ if (projectsBeside) {
496
+ putProjects(half, at, half);
497
+ }
498
+ y = height;
499
+ if (!projectsBeside) {
500
+ y += putProjects(0, y, columns);
501
+ }
502
+ y = putInPairs([...others.slice(MOST_BESIDE), ...bottom], y);
503
+ }
504
+ else {
505
+ let projectsPut = false;
506
+ if (lead !== undefined) {
507
+ // Nothing beside it, the lead is drawn at the size it is told, on that size's cells, and
508
+ // never stretched to the page's width and four rows (ADR-0110).
509
+ const size = nearestSize(lead, columns, LEAD_ROWS, columns);
510
+ const shape = footprintOf(size, columns);
511
+ boxes.push({ tile: lead, size, x: 0, y: 0, ...shape });
512
+ y = shape.h;
513
+ if (shape.w < columns && projects.length > 0) {
514
+ y = putProjectsBeside(shape.w, shape.h);
515
+ projectsPut = true;
516
+ }
517
+ }
518
+ y = putInPairs(others, y);
519
+ if (!projectsPut) {
520
+ y += putProjects(0, y, columns);
521
+ }
522
+ putInPairs(bottom, y);
523
+ }
524
+ return boxes;
525
+ }
526
+ /** How many rows the composed page takes, which need not be whole. */
527
+ export function composedRows(boxes) {
528
+ return Math.max(0, ...boxes.map((box) => box.y + box.h));
529
+ }
192
530
  const sameTile = (a, b) => a.tile.id === b.tile.id;
193
531
  const overlapping = (a, b, columns) => {
194
532
  const shapeA = footprintOf(a.size, columns);