@songsid/agend 2.4.0-beta.23 → 2.4.0-beta.25

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 (499) hide show
  1. package/README.md +1 -1
  2. package/README.zh-TW.md +1 -1
  3. package/dist/agend-home.js +5 -5
  4. package/dist/agend-home.js.map +1 -1
  5. package/dist/agent-cli-instructions.md +4 -3
  6. package/dist/agent-cli.js +32 -2
  7. package/dist/agent-cli.js.map +1 -1
  8. package/dist/agent-endpoint.js +10 -0
  9. package/dist/agent-endpoint.js.map +1 -1
  10. package/dist/agent-file-read.js +2 -2
  11. package/dist/agent-file-read.js.map +1 -1
  12. package/dist/agent-whats-new.js +11 -1
  13. package/dist/agent-whats-new.js.map +1 -1
  14. package/dist/agent-workspace.d.ts +18 -2
  15. package/dist/agent-workspace.js +15 -4
  16. package/dist/agent-workspace.js.map +1 -1
  17. package/dist/backend/antigravity.js +8 -6
  18. package/dist/backend/antigravity.js.map +1 -1
  19. package/dist/backend/claude-code.d.ts +15 -0
  20. package/dist/backend/claude-code.js +25 -3
  21. package/dist/backend/claude-code.js.map +1 -1
  22. package/dist/backend/claude-mcp-carry.d.ts +63 -0
  23. package/dist/backend/claude-mcp-carry.js +242 -0
  24. package/dist/backend/claude-mcp-carry.js.map +1 -0
  25. package/dist/backend/claude-usage-credits.d.ts +8 -0
  26. package/dist/backend/claude-usage-credits.js +121 -0
  27. package/dist/backend/claude-usage-credits.js.map +1 -0
  28. package/dist/backend/types.d.ts +30 -0
  29. package/dist/backend/types.js.map +1 -1
  30. package/dist/build-provenance.json +1 -1
  31. package/dist/channel/adapters/discord.js +7 -1
  32. package/dist/channel/adapters/discord.js.map +1 -1
  33. package/dist/channel/mcp-tools.js +7 -6
  34. package/dist/channel/mcp-tools.js.map +1 -1
  35. package/dist/channel/tool-router.js +1 -0
  36. package/dist/channel/tool-router.js.map +1 -1
  37. package/dist/cli-audited.js +9 -4
  38. package/dist/cli-audited.js.map +1 -1
  39. package/dist/cli.js +184 -21
  40. package/dist/cli.js.map +1 -1
  41. package/dist/config-validator.js +17 -1
  42. package/dist/config-validator.js.map +1 -1
  43. package/dist/config.js +2 -0
  44. package/dist/config.js.map +1 -1
  45. package/dist/contact-auth-store.d.ts +18 -0
  46. package/dist/contact-auth-store.js +55 -8
  47. package/dist/contact-auth-store.js.map +1 -1
  48. package/dist/contact-auth-types.d.ts +3 -0
  49. package/dist/contact-auth-types.js.map +1 -1
  50. package/dist/contact-change-proposals.d.ts +34 -0
  51. package/dist/contact-change-proposals.js +1 -1
  52. package/dist/contact-change-proposals.js.map +1 -1
  53. package/dist/cross-instance-notice.d.ts +1 -0
  54. package/dist/cross-instance-notice.js +9 -8
  55. package/dist/cross-instance-notice.js.map +1 -1
  56. package/dist/daemon.d.ts +46 -0
  57. package/dist/daemon.js +299 -33
  58. package/dist/daemon.js.map +1 -1
  59. package/dist/dashboard-permissions.d.ts +8 -0
  60. package/dist/dashboard-permissions.js +8 -0
  61. package/dist/dashboard-permissions.js.map +1 -1
  62. package/dist/delivery-outbox.d.ts +56 -1
  63. package/dist/delivery-outbox.js +254 -22
  64. package/dist/delivery-outbox.js.map +1 -1
  65. package/dist/fleet-context.d.ts +8 -0
  66. package/dist/fleet-lock.d.ts +67 -2
  67. package/dist/fleet-lock.js +236 -2
  68. package/dist/fleet-lock.js.map +1 -1
  69. package/dist/fleet-manager.d.ts +177 -6
  70. package/dist/fleet-manager.js +1203 -75
  71. package/dist/fleet-manager.js.map +1 -1
  72. package/dist/fleet-windows-runtime.d.ts +20 -1
  73. package/dist/fleet-windows-runtime.js +98 -18
  74. package/dist/fleet-windows-runtime.js.map +1 -1
  75. package/dist/general-knowledge/skills/concepts/SKILL.md +22 -9
  76. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +6 -0
  77. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +7 -0
  78. package/dist/general-knowledge/skills/fleet-config/SKILL.md +3 -3
  79. package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +1 -1
  80. package/dist/general-knowledge/skills/task-board/SKILL.md +17 -0
  81. package/dist/general-knowledge/skills/web-appearance/SKILL.md +4 -0
  82. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +35 -7
  83. package/dist/home-update-lock.d.ts +35 -0
  84. package/dist/home-update-lock.js +81 -0
  85. package/dist/home-update-lock.js.map +1 -0
  86. package/dist/hub/compose/member.d.ts +5 -1
  87. package/dist/hub/compose/member.js +9 -5
  88. package/dist/hub/compose/member.js.map +1 -1
  89. package/dist/hub/group-policy/resources.d.ts +1 -1
  90. package/dist/hub/member/room-ask.d.ts +5 -0
  91. package/dist/hub/member/room-ask.js +43 -16
  92. package/dist/hub/member/room-ask.js.map +1 -1
  93. package/dist/hub/member/room-mention-feedback.d.ts +2 -0
  94. package/dist/hub/member/room-mention-feedback.js +1 -1
  95. package/dist/hub/member/room-mention-feedback.js.map +1 -1
  96. package/dist/hub/member/room-post-answers.d.ts +2 -0
  97. package/dist/hub/member/room-post-answers.js +1 -1
  98. package/dist/hub/member/room-post-answers.js.map +1 -1
  99. package/dist/hub/member/room-post.d.ts +5 -0
  100. package/dist/hub/member/room-post.js +4 -1
  101. package/dist/hub/member/room-post.js.map +1 -1
  102. package/dist/hub/member/updates.d.ts +7 -1
  103. package/dist/hub/member/updates.js +7 -1
  104. package/dist/hub/member/updates.js.map +1 -1
  105. package/dist/hub/representative.d.ts +7 -0
  106. package/dist/hub/representative.js +38 -5
  107. package/dist/hub/representative.js.map +1 -1
  108. package/dist/install-lock.d.ts +15 -1
  109. package/dist/install-lock.js +16 -8
  110. package/dist/install-lock.js.map +1 -1
  111. package/dist/install-ownership.d.ts +165 -0
  112. package/dist/install-ownership.js +404 -0
  113. package/dist/install-ownership.js.map +1 -0
  114. package/dist/instance-config-impact.js +2 -0
  115. package/dist/instance-config-impact.js.map +1 -1
  116. package/dist/instance-lifecycle.d.ts +2 -0
  117. package/dist/instance-lifecycle.js +29 -1
  118. package/dist/instance-lifecycle.js.map +1 -1
  119. package/dist/instructions.d.ts +4 -0
  120. package/dist/instructions.js +4 -0
  121. package/dist/instructions.js.map +1 -1
  122. package/dist/local-pane-endpoint.d.ts +4 -1
  123. package/dist/local-pane-endpoint.js +12 -2
  124. package/dist/local-pane-endpoint.js.map +1 -1
  125. package/dist/locale.js +170 -4
  126. package/dist/locale.js.map +1 -1
  127. package/dist/native-agent-admission.d.ts +7 -0
  128. package/dist/native-agent-admission.js +46 -3
  129. package/dist/native-agent-admission.js.map +1 -1
  130. package/dist/native-mcp.d.ts +16 -1
  131. package/dist/native-mcp.js +38 -5
  132. package/dist/native-mcp.js.map +1 -1
  133. package/dist/native-pane-lifecycle.d.ts +9 -0
  134. package/dist/native-pane-lifecycle.js +23 -0
  135. package/dist/native-pane-lifecycle.js.map +1 -1
  136. package/dist/native-pane-manager.d.ts +19 -6
  137. package/dist/native-pane-manager.js +79 -4
  138. package/dist/native-pane-manager.js.map +1 -1
  139. package/dist/needs-you-hub.d.ts +3 -0
  140. package/dist/needs-you-hub.js +31 -5
  141. package/dist/needs-you-hub.js.map +1 -1
  142. package/dist/needs-you.d.ts +22 -1
  143. package/dist/needs-you.js +6 -0
  144. package/dist/needs-you.js.map +1 -1
  145. package/dist/office-share-page.js +1 -1
  146. package/dist/office-share-page.js.map +1 -1
  147. package/dist/office-share.js +2 -1
  148. package/dist/office-share.js.map +1 -1
  149. package/dist/outbound-handlers.d.ts +12 -0
  150. package/dist/outbound-handlers.js +59 -8
  151. package/dist/outbound-handlers.js.map +1 -1
  152. package/dist/outbound-schemas.d.ts +3 -0
  153. package/dist/outbound-schemas.js +7 -5
  154. package/dist/outbound-schemas.js.map +1 -1
  155. package/dist/package-preimage.js +4 -0
  156. package/dist/package-preimage.js.map +1 -1
  157. package/dist/pane-port.d.ts +1 -0
  158. package/dist/plist-args.d.ts +9 -0
  159. package/dist/plist-args.js +22 -0
  160. package/dist/plist-args.js.map +1 -0
  161. package/dist/public-preview.d.ts +4 -6
  162. package/dist/public-preview.js +5 -2
  163. package/dist/public-preview.js.map +1 -1
  164. package/dist/public-web-gateway.js +11 -3
  165. package/dist/public-web-gateway.js.map +1 -1
  166. package/dist/public-web-link.d.ts +13 -1
  167. package/dist/public-web-link.js +28 -1
  168. package/dist/public-web-link.js.map +1 -1
  169. package/dist/recover.cjs +2452 -0
  170. package/dist/remote-card-prompt.d.ts +6 -2
  171. package/dist/remote-card-prompt.js +12 -3
  172. package/dist/remote-card-prompt.js.map +1 -1
  173. package/dist/reply-draft.d.ts +12 -0
  174. package/dist/reply-draft.js +81 -0
  175. package/dist/reply-draft.js.map +1 -0
  176. package/dist/request-contact-api.d.ts +15 -0
  177. package/dist/request-contact-api.js +120 -0
  178. package/dist/request-contact-api.js.map +1 -0
  179. package/dist/request-contact-card.d.ts +36 -0
  180. package/dist/request-contact-card.js +206 -0
  181. package/dist/request-contact-card.js.map +1 -0
  182. package/dist/request-contact-gate.d.ts +79 -0
  183. package/dist/request-contact-gate.js +262 -0
  184. package/dist/request-contact-gate.js.map +1 -0
  185. package/dist/request-contact-native.d.ts +52 -0
  186. package/dist/request-contact-native.js +83 -0
  187. package/dist/request-contact-native.js.map +1 -0
  188. package/dist/request-contact-types.d.ts +86 -0
  189. package/dist/request-contact-types.js +7 -0
  190. package/dist/request-contact-types.js.map +1 -0
  191. package/dist/request-context-call-protocol.d.ts +12 -0
  192. package/dist/request-context-call-protocol.js +14 -0
  193. package/dist/request-context-call-protocol.js.map +1 -0
  194. package/dist/request-context-call.d.ts +22 -0
  195. package/dist/request-context-call.js +35 -0
  196. package/dist/request-context-call.js.map +1 -0
  197. package/dist/request-context-compatibility.d.ts +20 -0
  198. package/dist/request-context-compatibility.js +74 -0
  199. package/dist/request-context-compatibility.js.map +1 -0
  200. package/dist/request-context-drain.d.ts +39 -0
  201. package/dist/request-context-drain.js +159 -0
  202. package/dist/request-context-drain.js.map +1 -0
  203. package/dist/request-context-fence.d.ts +28 -0
  204. package/dist/request-context-fence.js +58 -0
  205. package/dist/request-context-fence.js.map +1 -0
  206. package/dist/request-context-migration.d.ts +64 -0
  207. package/dist/request-context-migration.js +158 -0
  208. package/dist/request-context-migration.js.map +1 -0
  209. package/dist/request-context-pane.d.ts +25 -0
  210. package/dist/request-context-pane.js +48 -0
  211. package/dist/request-context-pane.js.map +1 -0
  212. package/dist/request-context-policy.d.ts +74 -0
  213. package/dist/request-context-policy.js +116 -0
  214. package/dist/request-context-policy.js.map +1 -0
  215. package/dist/request-context-protocol.d.ts +137 -0
  216. package/dist/request-context-protocol.js +38 -0
  217. package/dist/request-context-protocol.js.map +1 -0
  218. package/dist/request-context-recovery.d.ts +14 -0
  219. package/dist/request-context-recovery.js +56 -0
  220. package/dist/request-context-recovery.js.map +1 -0
  221. package/dist/request-context-relay.d.ts +19 -0
  222. package/dist/request-context-relay.js +63 -0
  223. package/dist/request-context-relay.js.map +1 -0
  224. package/dist/request-context-returns.d.ts +67 -0
  225. package/dist/request-context-returns.js +211 -0
  226. package/dist/request-context-returns.js.map +1 -0
  227. package/dist/request-context-store.d.ts +26 -0
  228. package/dist/request-context-store.js +144 -0
  229. package/dist/request-context-store.js.map +1 -0
  230. package/dist/request-context-turns.d.ts +99 -0
  231. package/dist/request-context-turns.js +215 -0
  232. package/dist/request-context-turns.js.map +1 -0
  233. package/dist/request-context-view.d.ts +33 -0
  234. package/dist/request-context-view.js +36 -0
  235. package/dist/request-context-view.js.map +1 -0
  236. package/dist/request-hub-context.d.ts +130 -0
  237. package/dist/request-hub-context.js +89 -0
  238. package/dist/request-hub-context.js.map +1 -0
  239. package/dist/request-hub-output.d.ts +11 -0
  240. package/dist/request-hub-output.js +21 -0
  241. package/dist/request-hub-output.js.map +1 -0
  242. package/dist/runtime-cli-install.js +13 -11
  243. package/dist/runtime-cli-install.js.map +1 -1
  244. package/dist/runtime-client.d.ts +2 -0
  245. package/dist/runtime-client.js +17 -4
  246. package/dist/runtime-client.js.map +1 -1
  247. package/dist/runtime-coordinator.d.ts +4 -1
  248. package/dist/runtime-coordinator.js +10 -3
  249. package/dist/runtime-coordinator.js.map +1 -1
  250. package/dist/runtime-pane-assets.d.ts +1 -1
  251. package/dist/runtime-pane-assets.js +1 -1
  252. package/dist/runtime-pane-assets.js.map +1 -1
  253. package/dist/runtime-pane-host.d.ts +3 -0
  254. package/dist/runtime-pane-host.js +39 -21
  255. package/dist/runtime-pane-host.js.map +1 -1
  256. package/dist/runtime-pane-link.d.ts +6 -2
  257. package/dist/runtime-pane-link.js +17 -4
  258. package/dist/runtime-pane-link.js.map +1 -1
  259. package/dist/runtime-pane-mcp-relay.d.ts +11 -1
  260. package/dist/runtime-pane-mcp-relay.js +69 -3
  261. package/dist/runtime-pane-mcp-relay.js.map +1 -1
  262. package/dist/runtime-pane-mcp.d.ts +28 -1
  263. package/dist/runtime-pane-mcp.js +92 -15
  264. package/dist/runtime-pane-mcp.js.map +1 -1
  265. package/dist/runtime-pane-port.d.ts +6 -0
  266. package/dist/runtime-pane-port.js +23 -4
  267. package/dist/runtime-pane-port.js.map +1 -1
  268. package/dist/runtime-pane-protocol.d.ts +4 -0
  269. package/dist/runtime-pane-protocol.js +11 -4
  270. package/dist/runtime-pane-protocol.js.map +1 -1
  271. package/dist/runtime-pane-service.d.ts +1 -0
  272. package/dist/runtime-pane-service.js +25 -9
  273. package/dist/runtime-pane-service.js.map +1 -1
  274. package/dist/runtime-pane-stdio-protocol.d.ts +4 -0
  275. package/dist/runtime-pane-stdio-protocol.js +12 -5
  276. package/dist/runtime-pane-stdio-protocol.js.map +1 -1
  277. package/dist/runtime-pane-stdio.js +5 -5
  278. package/dist/runtime-pane-stdio.js.map +1 -1
  279. package/dist/runtime-protocol.d.ts +3 -0
  280. package/dist/runtime-protocol.js.map +1 -1
  281. package/dist/scheduler/db.js +26 -0
  282. package/dist/scheduler/db.js.map +1 -1
  283. package/dist/scheduler/scheduler.d.ts +6 -0
  284. package/dist/scheduler/scheduler.js +19 -1
  285. package/dist/scheduler/scheduler.js.map +1 -1
  286. package/dist/scheduler/task-board-text.d.ts +2 -0
  287. package/dist/scheduler/task-board-text.js +12 -0
  288. package/dist/scheduler/task-board-text.js.map +1 -1
  289. package/dist/scheduler/task-board.d.ts +106 -2
  290. package/dist/scheduler/task-board.js +248 -24
  291. package/dist/scheduler/task-board.js.map +1 -1
  292. package/dist/scheduler/task-files.d.ts +80 -0
  293. package/dist/scheduler/task-files.js +357 -0
  294. package/dist/scheduler/task-files.js.map +1 -0
  295. package/dist/scheduler/types.d.ts +1 -1
  296. package/dist/service-activation.js +3 -13
  297. package/dist/service-activation.js.map +1 -1
  298. package/dist/service-lock.d.ts +28 -0
  299. package/dist/service-lock.js +85 -0
  300. package/dist/service-lock.js.map +1 -0
  301. package/dist/settings-api.d.ts +8 -0
  302. package/dist/settings-api.js +41 -1
  303. package/dist/settings-api.js.map +1 -1
  304. package/dist/settings-baseline.d.ts +1 -0
  305. package/dist/settings-baseline.js +1 -1
  306. package/dist/settings-baseline.js.map +1 -1
  307. package/dist/settings-change.js +1 -1
  308. package/dist/settings-change.js.map +1 -1
  309. package/dist/settings-effect.d.ts +2 -0
  310. package/dist/settings-effect.js +5 -1
  311. package/dist/settings-effect.js.map +1 -1
  312. package/dist/state-lease.d.ts +24 -0
  313. package/dist/state-lease.js +103 -0
  314. package/dist/state-lease.js.map +1 -0
  315. package/dist/task-attach-client.d.ts +43 -0
  316. package/dist/task-attach-client.js +125 -0
  317. package/dist/task-attach-client.js.map +1 -0
  318. package/dist/task-board-tool.d.ts +12 -0
  319. package/dist/task-board-tool.js +107 -6
  320. package/dist/task-board-tool.js.map +1 -1
  321. package/dist/task-file-limits.d.ts +15 -0
  322. package/dist/task-file-limits.js +21 -0
  323. package/dist/task-file-limits.js.map +1 -0
  324. package/dist/tmux-binary.js +1 -1
  325. package/dist/tmux-binary.js.map +1 -1
  326. package/dist/tool-permissions.d.ts +32 -0
  327. package/dist/tool-permissions.js +63 -0
  328. package/dist/tool-permissions.js.map +1 -1
  329. package/dist/tool-receipt-output.d.ts +2 -0
  330. package/dist/topic-commands.js +21 -1
  331. package/dist/topic-commands.js.map +1 -1
  332. package/dist/transcript-monitor.js +3 -0
  333. package/dist/transcript-monitor.js.map +1 -1
  334. package/dist/tunnel/named-link-test.d.ts +27 -0
  335. package/dist/tunnel/named-link-test.js +41 -0
  336. package/dist/tunnel/named-link-test.js.map +1 -1
  337. package/dist/types.d.ts +13 -0
  338. package/dist/ui/agent-details-settings.js +7 -5
  339. package/dist/ui/agent-who-can-use-strings.js +125 -0
  340. package/dist/ui/agent-who-can-use.js +238 -0
  341. package/dist/ui/chat-store.js +5 -4
  342. package/dist/ui/fleet-office-card.js +37 -6
  343. package/dist/ui/fleet-office-editor.js +5 -5
  344. package/dist/ui/fleet-office-pack.d.ts +10 -0
  345. package/dist/ui/fleet-office-pack.js +65 -2
  346. package/dist/ui/fleet-office-skin.js +75 -17
  347. package/dist/ui/fleet-office-store.js +33 -2
  348. package/dist/ui/fleet-office-vehicles.js +130 -0
  349. package/dist/ui/fleet-office-zones.js +13 -4
  350. package/dist/ui/fleet-office.js +245 -46
  351. package/dist/ui/fleet-task-activity.js +9 -82
  352. package/dist/ui/fleet-task-archive.js +111 -0
  353. package/dist/ui/fleet-task-card.js +6 -4
  354. package/dist/ui/fleet-task-common.js +2 -2
  355. package/dist/ui/fleet-task-edit.js +8 -1
  356. package/dist/ui/fleet-task-files.js +196 -0
  357. package/dist/ui/fleet-task-md.js +98 -0
  358. package/dist/ui/fleet-task-menu.js +1 -1
  359. package/dist/ui/fleet-task-stats.js +2 -2
  360. package/dist/ui/fleet-task-view.js +12 -8
  361. package/dist/ui/fleet-tasks.js +42 -18
  362. package/dist/ui/panel-chat.js +15 -2
  363. package/dist/ui/panel-details.js +3 -1
  364. package/dist/ui/panel-needs.js +25 -5
  365. package/dist/ui/panel-settings.js +37 -9
  366. package/dist/ui/settings-preview-address.js +156 -0
  367. package/dist/ui/settings-registry.js +3 -0
  368. package/dist/ui/settings-shared-strings.js +9 -0
  369. package/dist/ui/settings-shared.js +6 -1
  370. package/dist/ui/settings-strings.js +6 -6
  371. package/dist/ui/shared/app-i18n.js +2 -2
  372. package/dist/ui/shared/app-needs.js +8 -1
  373. package/dist/ui/shared/app.css +131 -5
  374. package/dist/ui/shared/chat-strings.js +10 -6
  375. package/dist/ui/shared/chat-thread.js +7 -1
  376. package/dist/ui/shared/preview-panel.js +1 -1
  377. package/dist/ui/shared/preview.js +11 -2
  378. package/dist/ui/shared/task-board.css +64 -0
  379. package/dist/ui/shared/tokens.css +18 -3
  380. package/dist/ui/shared/ui-confirm.js +5 -4
  381. package/dist/ui/shared/workspace.css +7 -0
  382. package/dist/ui/usage-credits-card.js +84 -0
  383. package/dist/ui/workspace-ignored-strings.js +16 -0
  384. package/dist/ui/workspace-panel.js +15 -6
  385. package/dist/update-card.d.ts +193 -0
  386. package/dist/update-card.js +620 -0
  387. package/dist/update-card.js.map +1 -0
  388. package/dist/update-dispatch.d.ts +16 -1
  389. package/dist/update-dispatch.js +12 -4
  390. package/dist/update-dispatch.js.map +1 -1
  391. package/dist/update-forward.d.ts +73 -0
  392. package/dist/update-forward.js +283 -0
  393. package/dist/update-forward.js.map +1 -0
  394. package/dist/update-idle.d.ts +1 -0
  395. package/dist/update-idle.js +12 -3
  396. package/dist/update-idle.js.map +1 -1
  397. package/dist/update-install.d.ts +2 -1
  398. package/dist/update-install.js +18 -10
  399. package/dist/update-install.js.map +1 -1
  400. package/dist/update-journal.d.ts +351 -0
  401. package/dist/update-journal.js +717 -0
  402. package/dist/update-journal.js.map +1 -0
  403. package/dist/update-launch.js +1 -1
  404. package/dist/update-launch.js.map +1 -1
  405. package/dist/update-npm-env.d.ts +45 -12
  406. package/dist/update-npm-env.js +48 -0
  407. package/dist/update-npm-env.js.map +1 -1
  408. package/dist/update-package-restore.d.ts +75 -0
  409. package/dist/update-package-restore.js +318 -0
  410. package/dist/update-package-restore.js.map +1 -0
  411. package/dist/update-quiescence.d.ts +192 -0
  412. package/dist/update-quiescence.js +330 -0
  413. package/dist/update-quiescence.js.map +1 -0
  414. package/dist/update-readiness-host.d.ts +61 -0
  415. package/dist/update-readiness-host.js +297 -0
  416. package/dist/update-readiness-host.js.map +1 -0
  417. package/dist/update-readiness.d.ts +83 -0
  418. package/dist/update-readiness.js +459 -0
  419. package/dist/update-readiness.js.map +1 -0
  420. package/dist/update-recovery/kit.d.ts +35 -0
  421. package/dist/update-recovery/kit.js +99 -0
  422. package/dist/update-recovery/kit.js.map +1 -0
  423. package/dist/update-recovery/pre-start.d.ts +34 -0
  424. package/dist/update-recovery/pre-start.js +103 -0
  425. package/dist/update-recovery/pre-start.js.map +1 -0
  426. package/dist/update-recovery/recover-main.d.ts +1 -0
  427. package/dist/update-recovery/recover-main.js +4 -0
  428. package/dist/update-recovery/recover-main.js.map +1 -0
  429. package/dist/update-recovery/recover.d.ts +22 -0
  430. package/dist/update-recovery/recover.js +124 -0
  431. package/dist/update-recovery/recover.js.map +1 -0
  432. package/dist/update-recovery/route.d.ts +53 -0
  433. package/dist/update-recovery/route.js +262 -0
  434. package/dist/update-recovery/route.js.map +1 -0
  435. package/dist/update-recovery/runner.d.ts +58 -0
  436. package/dist/update-recovery/runner.js +196 -0
  437. package/dist/update-recovery/runner.js.map +1 -0
  438. package/dist/update-recovery/service-manager.d.ts +39 -0
  439. package/dist/update-recovery/service-manager.js +57 -0
  440. package/dist/update-recovery/service-manager.js.map +1 -0
  441. package/dist/update-restore.d.ts +44 -0
  442. package/dist/update-restore.js +355 -0
  443. package/dist/update-restore.js.map +1 -0
  444. package/dist/update-retained.d.ts +38 -0
  445. package/dist/update-retained.js +91 -0
  446. package/dist/update-retained.js.map +1 -0
  447. package/dist/update-rollback.d.ts +74 -0
  448. package/dist/update-rollback.js +221 -0
  449. package/dist/update-rollback.js.map +1 -0
  450. package/dist/update-settings.d.ts +36 -0
  451. package/dist/update-settings.js +122 -0
  452. package/dist/update-settings.js.map +1 -0
  453. package/dist/update-snapshot-manifest.d.ts +32 -0
  454. package/dist/update-snapshot-manifest.js +65 -0
  455. package/dist/update-snapshot-manifest.js.map +1 -0
  456. package/dist/update-snapshot-scope.d.ts +67 -0
  457. package/dist/update-snapshot-scope.js +172 -0
  458. package/dist/update-snapshot-scope.js.map +1 -0
  459. package/dist/update-snapshot.d.ts +34 -0
  460. package/dist/update-snapshot.js +246 -0
  461. package/dist/update-snapshot.js.map +1 -0
  462. package/dist/update-writers.d.ts +71 -0
  463. package/dist/update-writers.js +235 -0
  464. package/dist/update-writers.js.map +1 -0
  465. package/dist/web-api.d.ts +6 -0
  466. package/dist/web-api.js +140 -22
  467. package/dist/web-api.js.map +1 -1
  468. package/dist/web-chat-history.d.ts +7 -0
  469. package/dist/web-chat-history.js +15 -0
  470. package/dist/web-chat-history.js.map +1 -1
  471. package/dist/web-office-acts.d.ts +16 -0
  472. package/dist/web-office-acts.js +27 -9
  473. package/dist/web-office-acts.js.map +1 -1
  474. package/dist/web-office-pack-read.js +1 -1
  475. package/dist/web-office-pack-read.js.map +1 -1
  476. package/dist/web-office-skins.d.ts +5 -3
  477. package/dist/web-office-skins.js +20 -16
  478. package/dist/web-office-skins.js.map +1 -1
  479. package/dist/web-preview.d.ts +5 -0
  480. package/dist/web-preview.js +1 -1
  481. package/dist/web-preview.js.map +1 -1
  482. package/dist/web-settings-patch.d.ts +27 -0
  483. package/dist/web-settings-patch.js +67 -0
  484. package/dist/web-settings-patch.js.map +1 -1
  485. package/dist/web-update.d.ts +6 -0
  486. package/dist/windows-agents.d.ts +12 -0
  487. package/dist/windows-agents.js +5 -0
  488. package/dist/windows-agents.js.map +1 -1
  489. package/dist/workflow-templates/default.md +1 -0
  490. package/launcher/agend +4 -1
  491. package/launcher/agend-agent +4 -1
  492. package/launcher/agend-install.cjs +16 -8
  493. package/launcher/install-admission.d.cts +8 -0
  494. package/launcher/npm-allow-scripts.cjs +72 -0
  495. package/launcher/npm-global-prefix.cjs +81 -0
  496. package/launcher/postinstall.cjs +9 -8
  497. package/launcher/runtime-select.cjs +8 -2
  498. package/package.json +3 -2
  499. package/scripts/preinstall-guard.cjs +1 -1
@@ -1,5 +1,6 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { parseMentions } from "./task-board-mentions.js";
3
+ import { TASK_FILE_LIMITS, TaskFileError } from "./task-files.js";
3
4
  export const CARD_STATUSES = ["open", "claimed", "blocked", "review", "done", "cancelled"];
4
5
  /** Statuses still on the board (not finished). */
5
6
  export const LIVE_CARD_STATUSES = ["open", "claimed", "blocked", "review"];
@@ -27,6 +28,18 @@ export const CARD_LIMITS = {
27
28
  };
28
29
  /** How far back finished sub tasks and cancelled main tasks stay on the board. */
29
30
  const BOARD_DAYS = 14;
31
+ /**
32
+ * M-3668 (the user, 11-24): a finished main task — done or cancelled — leaves the dashboard's board this many days after it
33
+ * finished (defaults.task_board.archive_after_days; 0 = never). A view rule only: nothing in the database changes, search
34
+ * and its number still find it, and moving it to To do reopens it (its status, not its age, makes it archived).
35
+ */
36
+ export const ARCHIVE_AFTER_DAYS = 3;
37
+ /** The archive age as fleet.yaml gives it: a whole number of days, 0–3650; anything else is the default. */
38
+ export function archiveAfterDays(v) {
39
+ return typeof v === "number" && Number.isInteger(v) && v >= 0 && v <= 3650 ? v : ARCHIVE_AFTER_DAYS;
40
+ }
41
+ /** M-3668: how many finished main tasks a project's Done column counts as "this week". */
42
+ const WEEK_MS = 7 * 86_400_000;
30
43
  const BATCH_MAX = 30;
31
44
  /**
32
45
  * The loop guard for comments that wake (docs/design/task-board.md, "Comments and mentions"): instances (and scripts,
@@ -286,10 +299,20 @@ export class TaskBoard {
286
299
  /** The notes of the last write, until a caller of the `task` tool's old actions takes them (takeNotes). */
287
300
  lastNotes = [];
288
301
  codes = new Map();
302
+ /** Where files on cards live (task-files.ts); none: this process cannot take attachments (a bare board in a test, the CLI). */
303
+ fileStore = null;
304
+ /** What undoes this write's file moves, when the write fails after them. */
305
+ undo = [];
306
+ /** S-244: while the barrier flag is up, an open card is not claimed. Unset: today's claim. */
307
+ quiescence = null;
308
+ setQuiescence(gate) { this.quiescence = gate; }
289
309
  constructor(db, now = () => new Date()) {
290
310
  this.db = db;
291
311
  this.now = now;
292
312
  }
313
+ /** The store for files on cards (the fleet's scheduler sets it); null takes attachments away. */
314
+ setFiles(store) { this.fileStore = store; }
315
+ files() { return this.fileStore; }
293
316
  /** Called with what each committed write changed. Returns an unsubscribe function. */
294
317
  onChange(listener) {
295
318
  this.listeners.push(listener);
@@ -375,6 +398,20 @@ export class TaskBoard {
375
398
  at TEXT NOT NULL,
376
399
  PRIMARY KEY (task_id, instance)
377
400
  );
401
+ CREATE TABLE IF NOT EXISTS task_attachments (
402
+ id TEXT PRIMARY KEY,
403
+ task_id TEXT NOT NULL,
404
+ entry_id INTEGER,
405
+ name TEXT NOT NULL,
406
+ mime TEXT NOT NULL,
407
+ kind TEXT NOT NULL,
408
+ size INTEGER NOT NULL,
409
+ sha256 TEXT NOT NULL,
410
+ author TEXT NOT NULL,
411
+ author_kind TEXT NOT NULL,
412
+ at TEXT NOT NULL
413
+ );
414
+ CREATE INDEX IF NOT EXISTS idx_task_attachments_task ON task_attachments(task_id, at);
378
415
  `);
379
416
  // #2352: a project's lead instance, added in place (null: its waiting cards' buttons stay in General).
380
417
  const projectCols = new Set(this.db.prepare("PRAGMA table_info(task_projects)").all().map((c) => c.name));
@@ -575,25 +612,76 @@ export class TaskBoard {
575
612
  * tasks — or every done main task with `allDone` (the Done column's "All"). Older finished work stays in the
576
613
  * database and in the projects' numbers (projectStats), not in every board read.
577
614
  */
578
- boardCards(days = BOARD_DAYS, allDone = false) {
615
+ boardCards(days = BOARD_DAYS, allDone = false, archiveDays = 0) {
579
616
  const since = new Date(this.now().getTime() - days * 86_400_000).toISOString();
617
+ if (archiveDays > 0) {
618
+ // M-3668: finished main tasks until they are archived (`allDone` no longer reads past it: the Archive list does).
619
+ // #4428 review: an archived main task's sub tasks go with it (isArchived), even one done more recently.
620
+ const kept = new Date(this.now().getTime() - archiveDays * 86_400_000).toISOString();
621
+ return this.db.prepare(`SELECT * FROM tasks WHERE
622
+ (kind = 'main' AND (status NOT IN ('done', 'cancelled') OR COALESCE(done_at, updated_at) >= ?))
623
+ OR (kind = 'sub' AND status != 'cancelled' AND (status != 'done' OR COALESCE(done_at, updated_at) >= ?)
624
+ AND NOT EXISTS (SELECT 1 FROM tasks m WHERE m.id = tasks.parent_id AND m.status IN ('done', 'cancelled') AND COALESCE(m.done_at, m.updated_at) < ?))
625
+ ORDER BY sort`).all(kept, since, kept).map(toCard);
626
+ }
580
627
  const rows = this.db.prepare(`SELECT * FROM tasks WHERE
581
628
  (kind = 'main' AND (status NOT IN ('done', 'cancelled') OR (status = 'done' AND (? OR COALESCE(done_at, updated_at) >= ?)) OR (status = 'cancelled' AND updated_at >= ?)))
582
629
  OR (kind = 'sub' AND status != 'cancelled' AND (status != 'done' OR COALESCE(done_at, updated_at) >= ?))
583
630
  ORDER BY sort`).all(allDone ? 1 : 0, since, since, since);
584
631
  return rows.map(toCard);
585
632
  }
633
+ /**
634
+ * #4428 review: ` AND …` leaving out the cards that name one of `names` (assigned to, created by or handed out by one:
635
+ * the public link's hiding, web-api boardHiding), with its values; empty when none.
636
+ */
637
+ unseen(names = []) {
638
+ const out = [...new Set(names)];
639
+ if (!out.length)
640
+ return { sql: "", args: [] };
641
+ const marks = out.map(() => "?").join(", ");
642
+ return { sql: ` AND (assignee IS NULL OR assignee NOT IN (${marks})) AND created_by NOT IN (${marks}) AND (dispatcher IS NULL OR dispatcher NOT IN (${marks}))`,
643
+ args: [...out, ...out, ...out] };
644
+ }
645
+ /**
646
+ * #4428 review: what time alone changes in a board read and its numbers — how many finished cards have passed each
647
+ * of its lines (archived, out of this week's count, out of the recent window) — with the archive age. A card passes a
648
+ * line without a write (the revision stays), so a page's "same revision" read is answered `unchanged` only when this
649
+ * matches too. One counting pass, no rows. `leaveOut`: as projectStats (the public link's hidden instances' cards never
650
+ * move it).
651
+ */
652
+ boardEpoch(archiveDays = 0, days = BOARD_DAYS, leaveOut = []) {
653
+ const nowMs = this.now().getTime();
654
+ const at = (ms) => new Date(nowMs - ms).toISOString();
655
+ const kept = archiveDays > 0 ? at(archiveDays * 86_400_000) : "", week = at(WEEK_MS), since = at(days * 86_400_000), hide = this.unseen(leaveOut);
656
+ const r = this.db.prepare(`SELECT
657
+ COALESCE(SUM(kind = 'main' AND status IN ('done', 'cancelled') AND COALESCE(done_at, updated_at) < ?), 0) AS archived,
658
+ COALESCE(SUM(kind = 'main' AND status = 'done' AND COALESCE(done_at, updated_at) < ?), 0) AS week,
659
+ COALESCE(SUM(status IN ('done', 'cancelled') AND (CASE WHEN kind = 'main' AND status = 'cancelled' THEN updated_at ELSE COALESCE(done_at, updated_at) END) < ?), 0) AS old
660
+ FROM tasks WHERE 1${hide.sql}`).get(kept, week, since, ...hide.args);
661
+ return `${archiveDays}:${r.archived}:${r.week}:${r.old}`;
662
+ }
586
663
  /**
587
664
  * Each project's numbers (by id; "none" for No project) over all its cards, finished ones included: main tasks,
588
665
  * work units (a main task's sub tasks, or one unit for a main task without them; a done main task counts all its
589
666
  * units done), cards waiting for the person and blocked, and the last change. One pass over the table. #2080: waiting
590
667
  * counts only the cards in review the person confirms (waitsForPerson, `gone` as for Needs you), never an agent's.
668
+ * #4428 review: `leaveOut` names (the public link's hidden instances) — their cards, and a hidden main task's sub tasks,
669
+ * count nowhere, as the board read leaves them out.
591
670
  */
592
- projectStats(gone) {
593
- const rows = this.db.prepare("SELECT id, kind, status, project_id, parent_id, updated_at, needs_review, dispatcher, dispatcher_kind FROM tasks").all();
671
+ projectStats(gone, archiveDays = 0, leaveOut = []) {
672
+ const all = this.db.prepare("SELECT id, kind, status, project_id, parent_id, updated_at, done_at, needs_review, dispatcher, dispatcher_kind, assignee, created_by FROM tasks").all();
673
+ const unseenNames = new Set(leaveOut);
674
+ const names = (r) => [r.assignee, r.created_by, r.dispatcher].some((n) => typeof n === "string" && unseenNames.has(n));
675
+ const hiddenMains = unseenNames.size ? new Set(all.filter((r) => r.kind === "main" && names(r)).map((r) => r.id)) : new Set();
676
+ const rows = unseenNames.size ? all.filter((r) => !names(r) && !(r.kind === "sub" && hiddenMains.has(r.parent_id))) : all;
677
+ const nowMs = this.now().getTime(), kept = archiveDays > 0 ? new Date(nowMs - archiveDays * 86_400_000).toISOString() : null;
678
+ const week = new Date(nowMs - WEEK_MS).toISOString();
679
+ const finished = (r) => (r.done_at ?? r.updated_at);
680
+ // M-3668: an archived main task (and its sub tasks) is left out of every number but `archived`.
681
+ const archivedMains = new Set(kept ? rows.filter((r) => r.kind === "main" && (r.status === "done" || r.status === "cancelled") && finished(r) < kept).map((r) => r.id) : []);
594
682
  const subs = new Map();
595
683
  for (const r of rows) {
596
- if (r.kind !== "sub" || !r.parent_id || r.status === "cancelled")
684
+ if (r.kind !== "sub" || !r.parent_id || r.status === "cancelled" || archivedMains.has(r.parent_id))
597
685
  continue;
598
686
  const p = subs.get(r.parent_id) ?? { total: 0, open: 0, claimed: 0, blocked: 0, review: 0, done: 0 };
599
687
  p.total++;
@@ -603,10 +691,21 @@ export class TaskBoard {
603
691
  const out = {};
604
692
  for (const r of rows) {
605
693
  const key = r.project_id === null || r.project_id === undefined ? "none" : String(r.project_id);
606
- const st = out[key] ??= { mains: 0, units: { total: 0, open: 0, claimed: 0, blocked: 0, review: 0, done: 0 }, percent: 0, waiting: 0, blocked: 0, lastActivity: null };
694
+ const st = out[key] ??= { mains: 0, units: { total: 0, open: 0, claimed: 0, blocked: 0, review: 0, done: 0 }, percent: 0, waiting: 0, blocked: 0, lastActivity: null, archived: 0, doneWeek: 0, archivedWeek: 0 };
607
695
  if (!st.lastActivity || r.updated_at > st.lastActivity)
608
696
  st.lastActivity = r.updated_at;
609
697
  const status = r.status;
698
+ if (r.kind === "main" && status === "done" && finished(r) >= week) {
699
+ st.doneWeek++;
700
+ if (archivedMains.has(r.id))
701
+ st.archivedWeek++;
702
+ }
703
+ if (archivedMains.has(r.id)) {
704
+ st.archived++;
705
+ continue;
706
+ }
707
+ if (r.kind === "sub" && archivedMains.has(r.parent_id))
708
+ continue;
610
709
  if (status === "cancelled")
611
710
  continue;
612
711
  if (status === "review" && waitsForPerson({ status, needsReview: Number(r.needs_review) === 1,
@@ -635,6 +734,40 @@ export class TaskBoard {
635
734
  st.percent = st.units.total ? Math.round((st.units.done / st.units.total) * 100) : 0;
636
735
  return out;
637
736
  }
737
+ /** M-3668: whether the dashboard has archived this card (a sub task goes with its main task). */
738
+ isArchived(card, archiveDays) {
739
+ if (archiveDays <= 0)
740
+ return false;
741
+ const main = card.kind === "sub" && card.parent ? this.byUuid(card.parent) : card;
742
+ if (!main || main.kind !== "main" || (main.status !== "done" && main.status !== "cancelled"))
743
+ return false;
744
+ return (main.doneAt ?? main.updatedAt) < new Date(this.now().getTime() - archiveDays * 86_400_000).toISOString();
745
+ }
746
+ /**
747
+ * M-3668: a project's archived main tasks (`project` null: No project), the most recently finished first, a page at a
748
+ * time (`before`: the last one's cursor), and who they were assigned to (the list's filter, `assignee`).
749
+ * `leaveOut`: names whose cards the reader may not see (assigned to, created by or handed out by one) — left out
750
+ * before the page, its cursor, the total and the assignees are worked out, so none of them tells of such a card.
751
+ */
752
+ archiveList(project, archiveDays, opts = {}) {
753
+ if (archiveDays <= 0)
754
+ return { cards: [], next: null, total: 0, assignees: [] };
755
+ const kept = new Date(this.now().getTime() - archiveDays * 86_400_000).toISOString();
756
+ const hide = this.unseen(opts.leaveOut);
757
+ const where = `kind = 'main' AND status IN ('done', 'cancelled') AND COALESCE(done_at, updated_at) < ? AND ${project === null ? "project_id IS NULL" : "project_id = ?"}${hide.sql}`;
758
+ const base = [kept, ...(project === null ? [] : [project]), ...hide.args];
759
+ const assignees = this.db.prepare(`SELECT DISTINCT assignee FROM tasks WHERE ${where} AND assignee IS NOT NULL ORDER BY assignee`).all(...base).map((r) => r.assignee);
760
+ const who = opts.assignee ? " AND assignee = ?" : "", whoArgs = opts.assignee ? [opts.assignee] : [];
761
+ const total = this.db.prepare(`SELECT COUNT(*) AS n FROM tasks WHERE ${where}${who}`).get(...base, ...whoArgs).n;
762
+ const cursor = typeof opts.before === "string" ? /^(.+)\|([^|]+)$/.exec(opts.before) : null;
763
+ const after = cursor ? " AND (COALESCE(done_at, updated_at) < ? OR (COALESCE(done_at, updated_at) = ? AND id < ?))" : "";
764
+ const limit = Math.min(Math.max(opts.limit ?? 50, 1), 100);
765
+ const rows = this.db.prepare(`SELECT * FROM tasks WHERE ${where}${who}${after} ORDER BY COALESCE(done_at, updated_at) DESC, id DESC LIMIT ?`)
766
+ .all(...base, ...whoArgs, ...(cursor ? [cursor[1], cursor[1], cursor[2]] : []), limit + 1);
767
+ const cards = rows.slice(0, limit).map(toCard);
768
+ const last = cards[cards.length - 1];
769
+ return { cards, next: rows.length > limit && last ? `${last.doneAt ?? last.updatedAt}|${last.uuid}` : null, total, assignees };
770
+ }
638
771
  view(card, scope = {}, gone) {
639
772
  return this.views([card], scope, gone)[0];
640
773
  }
@@ -667,6 +800,8 @@ export class TaskBoard {
667
800
  const by = this.notBy(scope, "author"), eBy = this.notBy(scope, "e.author");
668
801
  const comments = new Map(this.db.prepare(`SELECT e.task_id AS task_id, n.n AS n, e.author AS author, e.author_kind AS author_kind, e.at AS at FROM task_entries e
669
802
  JOIN (SELECT task_id, COUNT(*) AS n, MAX(id) AS last FROM task_entries WHERE kind IN ('comment', 'reject', 'approve')${by.sql} GROUP BY task_id) n ON e.id = n.last`).all(...by.args).map((r) => [r.task_id, r]));
803
+ const files = new Map(this.db.prepare(`SELECT task_id, COUNT(*) AS n FROM task_attachments WHERE 1 = 1${by.sql} GROUP BY task_id`)
804
+ .all(...by.args).map((r) => [r.task_id, r.n]));
670
805
  const unseen = new Map(this.db.prepare(`SELECT t.id AS id, COUNT(e.id) AS n FROM tasks t JOIN task_entries e
671
806
  ON e.task_id = t.id AND e.id > t.seen_entry_id AND e.kind IN ('comment', 'reject') AND e.author IS NOT t.assignee${eBy.sql}
672
807
  GROUP BY t.id`).all(...eBy.args).map((r) => [r.id, r.n]));
@@ -720,6 +855,7 @@ export class TaskBoard {
720
855
  progress: card.kind === "main" ? progress.get(card.uuid) ?? { total: 0, open: 0, claimed: 0, blocked: 0, review: 0, done: 0 } : null,
721
856
  unmetDeps: unmet(card.deps, card.parent),
722
857
  commentCount: c?.n ?? 0,
858
+ attachmentCount: files.get(card.uuid) ?? 0,
723
859
  newCommentCount: unseen.get(card.uuid) ?? 0,
724
860
  lastComment: c ? { author: c.author, authorKind: c.author_kind, at: c.at } : null,
725
861
  };
@@ -735,6 +871,7 @@ export class TaskBoard {
735
871
  comments: this.entries(card.uuid, ["comment", "reject", "approve"], 200),
736
872
  logs: this.entries(card.uuid, ["log"], 200),
737
873
  history: this.events(card.uuid, 200).filter((e) => e.type !== "reordered"),
874
+ attachments: this.attachments(card.uuid, scope),
738
875
  watchers: this.watchersOf(card.uuid),
739
876
  inheritedWatchers: card.parent ? this.watchersOf(card.parent) : [],
740
877
  leader: this.leaderOf(card),
@@ -1299,13 +1436,9 @@ export class TaskBoard {
1299
1436
  touched = true;
1300
1437
  }
1301
1438
  }
1302
- if (patch.comment !== undefined) {
1303
- const text = checkText("the comment", patch.comment, CARD_LIMITS.comment);
1304
- if (text) {
1305
- this.entry(card, "comment", actor, text);
1306
- this.commented(actor, card, text);
1439
+ if (patch.comment !== undefined || patch.attach?.length) {
1440
+ if (this.writeComment(card, actor, patch.comment ?? "", patch.attach))
1307
1441
  touched = true;
1308
- }
1309
1442
  }
1310
1443
  if (!touched)
1311
1444
  return { card, notes: ["no change"], said: [] };
@@ -1348,10 +1481,8 @@ export class TaskBoard {
1348
1481
  this.checkAnswer(card, comment);
1349
1482
  const busy = this.busyWith(card, card.assignee);
1350
1483
  if (busy.length) {
1351
- const text = checkText("the comment", comment, CARD_LIMITS.comment);
1352
- this.entry(card, "comment", actor, text);
1353
1484
  // #2801 review: the one comment that is news — the answer its assignee waits for (`kept`).
1354
- this.commented(actor, card, text, true);
1485
+ this.writeComment(card, actor, comment, options.attach, true);
1355
1486
  card.version++;
1356
1487
  card.updatedAt = this.nowIso();
1357
1488
  this.save(card);
@@ -1364,7 +1495,7 @@ export class TaskBoard {
1364
1495
  this.checkDerivedMove(card, actor, to, reason, { comment });
1365
1496
  else
1366
1497
  this.checkManualMove(card, actor, to, reason, { comment });
1367
- this.applyMove(card, actor, this.ownReview(card, actor, to, reason), reason, comment);
1498
+ this.applyMove(card, actor, this.ownReview(card, actor, to, reason), reason, comment, options.attach);
1368
1499
  return { card, from, ...this.spoken() };
1369
1500
  });
1370
1501
  }
@@ -1913,8 +2044,11 @@ export class TaskBoard {
1913
2044
  }
1914
2045
  // ── Derived state ───────────────────────────────────────
1915
2046
  /** Status bookkeeping shared by every move, then what the move sets off. */
1916
- applyMove(card, actor, to, reason, comment) {
2047
+ applyMove(card, actor, to, reason, comment, attach) {
1917
2048
  const from = card.status;
2049
+ if (from === "open" && to === "claimed" && this.quiescence?.holdTaskClaim()) {
2050
+ throw new TaskBoardError("conflict", "an update is in progress; this claim waits until it finishes");
2051
+ }
1918
2052
  const now = this.nowIso();
1919
2053
  card.status = to;
1920
2054
  if (to === "claimed" && !card.startedAt)
@@ -1923,11 +2057,8 @@ export class TaskBoard {
1923
2057
  card.submittedAt = now;
1924
2058
  card.doneAt = to === "done" ? now : null;
1925
2059
  card.blockedReason = to === "blocked" ? reason : "";
1926
- if (comment?.trim()) {
1927
- const text = checkText("the comment", comment, CARD_LIMITS.comment);
1928
- this.entry(card, "comment", actor, text);
1929
- this.commented(actor, card, text);
1930
- }
2060
+ if (comment?.trim() || attach?.length)
2061
+ this.writeComment(card, actor, comment ?? "", attach);
1931
2062
  card.version++;
1932
2063
  card.updatedAt = now;
1933
2064
  this.surfaceComments(card, actor);
@@ -2452,6 +2583,7 @@ export class TaskBoard {
2452
2583
  this.pending = [];
2453
2584
  this.projectsChanged = false;
2454
2585
  this.notes = [];
2586
+ this.undo = [];
2455
2587
  try {
2456
2588
  let wakes = [];
2457
2589
  const result = this.db.transaction(() => {
@@ -2471,6 +2603,9 @@ export class TaskBoard {
2471
2603
  }
2472
2604
  return r;
2473
2605
  }).immediate();
2606
+ // Committed: the rows are there for good, so what undoes the file moves is forgotten — a failure from here on (a listener's
2607
+ // work, reading the revision) must not move files back from under rows that stay.
2608
+ this.undo = [];
2474
2609
  this.lastNotes = this.notes.map((n) => n.text);
2475
2610
  const touched = this.pending;
2476
2611
  const projects = this.projectsChanged;
@@ -2486,9 +2621,20 @@ export class TaskBoard {
2486
2621
  }
2487
2622
  return result;
2488
2623
  }
2624
+ catch (err) {
2625
+ // The write failed BEFORE it committed, after it moved files under a card: the rows are rolled back, so the files go back to staging.
2626
+ for (const back of this.undo.reverse()) {
2627
+ try {
2628
+ back();
2629
+ }
2630
+ catch { /* the sweep removes it */ }
2631
+ }
2632
+ throw err;
2633
+ }
2489
2634
  finally {
2490
2635
  this.pending = [];
2491
2636
  this.projectsChanged = false;
2637
+ this.undo = [];
2492
2638
  }
2493
2639
  }
2494
2640
  nowIso() {
@@ -2581,6 +2727,83 @@ export class TaskBoard {
2581
2727
  card.seenEntryId = 0;
2582
2728
  this.event(actor, card, "assigned", { from, to: assignee });
2583
2729
  }
2730
+ /**
2731
+ * A comment written, with the files that came with it: its entry, the files linked to it, and the
2732
+ * "commented" event. A write that brings files and no words leaves a line naming them (`📎 name, name`), which an
2733
+ * older release shows as the comment it is. False when there is nothing to write (no words, no files).
2734
+ */
2735
+ writeComment(card, actor, raw, attach, kept = false) {
2736
+ const files = attach?.length ? this.stagedFiles(card, actor, attach) : [];
2737
+ const words = checkText("the comment", raw, CARD_LIMITS.comment);
2738
+ const text = words || (files.length ? checkText("the comment", `📎 ${files.map((f) => f.name).join(", ")}`, CARD_LIMITS.comment) : "");
2739
+ if (!text)
2740
+ return false;
2741
+ const entryId = this.entry(card, "comment", actor, text);
2742
+ this.linkFiles(card, actor, entryId, files);
2743
+ this.commented(actor, card, text, kept, files.length);
2744
+ return true;
2745
+ }
2746
+ /** The files `actor` staged, checked against this card's limits (nothing is moved yet). */
2747
+ stagedFiles(card, actor, ids) {
2748
+ const store = this.fileStore;
2749
+ if (!store)
2750
+ throw new TaskBoardError("invalid", "attachments are not available here (the fleet's scheduler holds the card files)");
2751
+ let files;
2752
+ try {
2753
+ files = store.adopt(actor.name, ids);
2754
+ }
2755
+ catch (err) {
2756
+ if (err instanceof TaskFileError)
2757
+ throw new TaskBoardError("invalid", err.message);
2758
+ throw err;
2759
+ }
2760
+ const held = this.db.prepare("SELECT COUNT(*) AS n, COALESCE(SUM(size), 0) AS bytes FROM task_attachments WHERE task_id = ?").get(card.uuid);
2761
+ const bytes = files.reduce((n, f) => n + f.size, 0);
2762
+ if (held.n + files.length > TASK_FILE_LIMITS.files) {
2763
+ throw new TaskBoardError("too_long", `${card.code} holds ${held.n} files; at most ${TASK_FILE_LIMITS.files} on a card`);
2764
+ }
2765
+ if (held.bytes + bytes > TASK_FILE_LIMITS.cardBytes) {
2766
+ throw new TaskBoardError("too_long", `the files on ${card.code} would be ${Math.ceil((held.bytes + bytes) / (1024 * 1024))} MiB; at most ${Math.floor(TASK_FILE_LIMITS.cardBytes / (1024 * 1024))} MiB on a card`);
2767
+ }
2768
+ return files;
2769
+ }
2770
+ /** The staged files, now the card's: a row each, hung under `entryId`, and the file moved under the card. */
2771
+ linkFiles(card, actor, entryId, files) {
2772
+ if (!files.length)
2773
+ return;
2774
+ const store = this.fileStore;
2775
+ const insert = this.db.prepare("INSERT INTO task_attachments (id, task_id, entry_id, name, mime, kind, size, sha256, author, author_kind, at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
2776
+ for (const f of files) {
2777
+ insert.run(f.id, card.uuid, entryId, f.name, f.mime, f.kind, f.size, f.sha256, actor.name, actor.kind, this.nowIso());
2778
+ try {
2779
+ this.undo.push(store.commit(card.uuid, f));
2780
+ }
2781
+ catch (err) {
2782
+ if (err instanceof TaskFileError)
2783
+ throw new TaskBoardError("invalid", err.message);
2784
+ throw new TaskBoardError("invalid", `the file ${f.name} could not be stored on ${card.code}`);
2785
+ }
2786
+ }
2787
+ }
2788
+ /** The files on a card, oldest first; a scope leaves out the ones its left-out authors wrote. */
2789
+ attachments(uuid, scope = {}) {
2790
+ const by = this.notBy(scope, "author");
2791
+ const rows = this.db.prepare(`SELECT * FROM task_attachments WHERE task_id = ?${by.sql} ORDER BY at, rowid`).all(uuid, ...by.args);
2792
+ return rows.map((r) => this.toAttachment(r));
2793
+ }
2794
+ /** One file by its id, with the card it is on; undefined when there is none. */
2795
+ attachment(id) {
2796
+ const r = this.db.prepare("SELECT * FROM task_attachments WHERE id = ?").get(id);
2797
+ const card = r ? this.byUuid(r.task_id) : undefined;
2798
+ return r && card ? { file: this.toAttachment(r), card } : undefined;
2799
+ }
2800
+ toAttachment(r) {
2801
+ return {
2802
+ id: r.id, cardId: this.codeOf(r.task_id), entryId: r.entry_id === null ? null : Number(r.entry_id), name: r.name,
2803
+ mime: r.mime, kind: r.kind === "photo" ? "photo" : "document", size: Number(r.size), author: r.author,
2804
+ authorKind: r.author_kind, at: r.at,
2805
+ };
2806
+ }
2584
2807
  /**
2585
2808
  * Any write by the assignee counts as having seen the comments so far, so the unseen ones go in its reply first;
2586
2809
  * otherwise a comment posted mid-task would be acknowledged without being read.
@@ -2600,15 +2823,16 @@ export class TaskBoard {
2600
2823
  card.seenEntryId = this.db.prepare("SELECT COALESCE(MAX(id), 0) AS m FROM task_entries WHERE task_id = ?").get(card.uuid).m;
2601
2824
  }
2602
2825
  entry(card, kind, actor, text) {
2603
- this.db.prepare("INSERT INTO task_entries (task_id, kind, author, author_kind, text, at) VALUES (?, ?, ?, ?, ?, ?)")
2826
+ const r = this.db.prepare("INSERT INTO task_entries (task_id, kind, author, author_kind, text, at) VALUES (?, ?, ?, ?, ?, ?)")
2604
2827
  .run(card.uuid, kind, actor.name, actor.kind, text, this.nowIso());
2828
+ return Number(r.lastInsertRowid);
2605
2829
  }
2606
2830
  /**
2607
2831
  * A comment written (its entry is already on the card): the "commented" event, and whom the comment concerns, which
2608
2832
  * settleWakes reads when the write ends. `kept` is a dispatcher's answer a busy assignee finds on the card (#2303).
2609
2833
  */
2610
- commented(actor, card, text, kept = false) {
2611
- this.event(actor, card, "commented", kept ? { text, kept: true } : { text });
2834
+ commented(actor, card, text, kept = false, files = 0) {
2835
+ this.event(actor, card, "commented", { text, ...(kept ? { kept: true } : {}), ...(files ? { files } : {}) });
2612
2836
  this.pending[this.pending.length - 1].audience = this.routeComment(actor, card, text, kept);
2613
2837
  }
2614
2838
  /**