@songsid/agend 2.4.0-beta.17 → 2.4.0-beta.19

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 (431) hide show
  1. package/dist/agent-cli-instructions.md +13 -7
  2. package/dist/agent-cli.js +149 -49
  3. package/dist/agent-cli.js.map +1 -1
  4. package/dist/agent-export.d.ts +3 -1
  5. package/dist/agent-export.js +18 -1
  6. package/dist/agent-export.js.map +1 -1
  7. package/dist/agent-whats-new.js +9 -0
  8. package/dist/agent-whats-new.js.map +1 -1
  9. package/dist/apply-job.d.ts +2 -2
  10. package/dist/auth-api.js +1 -1
  11. package/dist/auth-api.js.map +1 -1
  12. package/dist/backend/claude-code.d.ts +0 -6
  13. package/dist/backend/claude-code.js +29 -5
  14. package/dist/backend/claude-code.js.map +1 -1
  15. package/dist/backend/claude-transcript-errors.d.ts +4 -0
  16. package/dist/backend/claude-transcript-errors.js +5 -1
  17. package/dist/backend/claude-transcript-errors.js.map +1 -1
  18. package/dist/backend/codex-precaution.js +3 -2
  19. package/dist/backend/codex-precaution.js.map +1 -1
  20. package/dist/backend/codex.js +1 -1
  21. package/dist/backend/codex.js.map +1 -1
  22. package/dist/backend/types.d.ts +6 -0
  23. package/dist/backend/types.js.map +1 -1
  24. package/dist/build-provenance.json +1 -1
  25. package/dist/channel/mcp-server.js +8 -2
  26. package/dist/channel/mcp-server.js.map +1 -1
  27. package/dist/channel/mcp-tools.d.ts +27 -1
  28. package/dist/channel/mcp-tools.js +77 -7
  29. package/dist/channel/mcp-tools.js.map +1 -1
  30. package/dist/chat-task-refs.d.ts +61 -0
  31. package/dist/chat-task-refs.js +112 -0
  32. package/dist/chat-task-refs.js.map +1 -0
  33. package/dist/classic-channel-manager.d.ts +1 -1
  34. package/dist/classic-channel-manager.js +6 -2
  35. package/dist/classic-channel-manager.js.map +1 -1
  36. package/dist/claude-credential-launch.d.ts +6 -0
  37. package/dist/claude-credential-launch.js +16 -3
  38. package/dist/claude-credential-launch.js.map +1 -1
  39. package/dist/claude-credential-runner.js +3 -1
  40. package/dist/claude-credential-runner.js.map +1 -1
  41. package/dist/claude-setup-token-transport.js +25 -3
  42. package/dist/claude-setup-token-transport.js.map +1 -1
  43. package/dist/cli-audited.js +9 -8
  44. package/dist/cli-audited.js.map +1 -1
  45. package/dist/composite-tools.d.ts +11 -0
  46. package/dist/composite-tools.js +29 -0
  47. package/dist/composite-tools.js.map +1 -0
  48. package/dist/config-validator.js +22 -1
  49. package/dist/config-validator.js.map +1 -1
  50. package/dist/config.js +11 -0
  51. package/dist/config.js.map +1 -1
  52. package/dist/contact-auth-policy.d.ts +1 -0
  53. package/dist/contact-auth-policy.js +2 -1
  54. package/dist/contact-auth-policy.js.map +1 -1
  55. package/dist/contact-auth-service.js +2 -0
  56. package/dist/contact-auth-service.js.map +1 -1
  57. package/dist/contact-auth-store.js +21 -6
  58. package/dist/contact-auth-store.js.map +1 -1
  59. package/dist/contact-auth-types.d.ts +2 -0
  60. package/dist/contact-auth-types.js.map +1 -1
  61. package/dist/daemon.d.ts +8 -0
  62. package/dist/daemon.js +66 -13
  63. package/dist/daemon.js.map +1 -1
  64. package/dist/darwin-memory.js +2 -1
  65. package/dist/darwin-memory.js.map +1 -1
  66. package/dist/dashboard-permissions.d.ts +1 -8
  67. package/dist/dashboard-permissions.js +8 -9
  68. package/dist/dashboard-permissions.js.map +1 -1
  69. package/dist/delivery-outbox.d.ts +0 -6
  70. package/dist/delivery-outbox.js +0 -25
  71. package/dist/delivery-outbox.js.map +1 -1
  72. package/dist/delivery-outbox.test.js +132 -96
  73. package/dist/delivery-outbox.test.js.map +1 -1
  74. package/dist/fleet-context.d.ts +1 -0
  75. package/dist/fleet-manager.d.ts +60 -8
  76. package/dist/fleet-manager.js +404 -107
  77. package/dist/fleet-manager.js.map +1 -1
  78. package/dist/fleet-windows-runtime.d.ts +2 -2
  79. package/dist/fleet-windows-runtime.js +9 -2
  80. package/dist/fleet-windows-runtime.js.map +1 -1
  81. package/dist/fleet-yaml-stringify.d.ts +3 -0
  82. package/dist/fleet-yaml-stringify.js +132 -0
  83. package/dist/fleet-yaml-stringify.js.map +1 -0
  84. package/dist/general-knowledge/skills/concepts/SKILL.md +53 -4
  85. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +4 -0
  86. package/dist/general-knowledge/skills/fleet-config/SKILL.md +21 -1
  87. package/dist/general-knowledge/skills/hub/SKILL.md +2 -0
  88. package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +5 -1
  89. package/dist/general-knowledge/skills/model-discovery/SKILL.md +3 -2
  90. package/dist/general-knowledge/skills/persona-emoji/SKILL.md +3 -0
  91. package/dist/general-knowledge/skills/task-board/SKILL.md +63 -0
  92. package/dist/general-knowledge/skills/web-appearance/SKILL.md +25 -2
  93. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +48 -11
  94. package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +4 -0
  95. package/dist/general-knowledge/steering/core-rules.md +15 -78
  96. package/dist/general-role-block.d.ts +19 -0
  97. package/dist/general-role-block.js +56 -0
  98. package/dist/general-role-block.js.map +1 -0
  99. package/dist/general-role.d.ts +1 -1
  100. package/dist/general-role.js +1 -0
  101. package/dist/general-role.js.map +1 -1
  102. package/dist/host-memory.d.ts +3 -0
  103. package/dist/host-memory.js.map +1 -1
  104. package/dist/host-monitoring/darwin/collector.d.ts +18 -0
  105. package/dist/host-monitoring/darwin/collector.js +65 -0
  106. package/dist/host-monitoring/darwin/collector.js.map +1 -0
  107. package/dist/host-monitoring/darwin/defaults.d.ts +2 -0
  108. package/dist/host-monitoring/darwin/defaults.js +9 -0
  109. package/dist/host-monitoring/darwin/defaults.js.map +1 -0
  110. package/dist/host-monitoring/darwin/interpretation.d.ts +20 -0
  111. package/dist/host-monitoring/darwin/interpretation.js +73 -0
  112. package/dist/host-monitoring/darwin/interpretation.js.map +1 -0
  113. package/dist/host-monitoring/linux/collector.d.ts +17 -0
  114. package/dist/host-monitoring/linux/collector.js +55 -0
  115. package/dist/host-monitoring/linux/collector.js.map +1 -0
  116. package/dist/host-monitoring/linux/defaults.d.ts +2 -0
  117. package/dist/host-monitoring/linux/defaults.js +9 -0
  118. package/dist/host-monitoring/linux/defaults.js.map +1 -0
  119. package/dist/host-monitoring/linux/interpretation.d.ts +22 -0
  120. package/dist/host-monitoring/linux/interpretation.js +76 -0
  121. package/dist/host-monitoring/linux/interpretation.js.map +1 -0
  122. package/dist/host-monitoring/transport.d.ts +42 -0
  123. package/dist/host-monitoring/transport.js +101 -0
  124. package/dist/host-monitoring/transport.js.map +1 -0
  125. package/dist/host-monitoring/wsl/collector.d.ts +19 -0
  126. package/dist/host-monitoring/wsl/collector.js +72 -0
  127. package/dist/host-monitoring/wsl/collector.js.map +1 -0
  128. package/dist/host-monitoring/wsl/defaults.d.ts +2 -0
  129. package/dist/host-monitoring/wsl/defaults.js +9 -0
  130. package/dist/host-monitoring/wsl/defaults.js.map +1 -0
  131. package/dist/host-monitoring/wsl/interpretation.d.ts +22 -0
  132. package/dist/host-monitoring/wsl/interpretation.js +77 -0
  133. package/dist/host-monitoring/wsl/interpretation.js.map +1 -0
  134. package/dist/host-monitoring-alert-policy.d.ts +73 -0
  135. package/dist/host-monitoring-alert-policy.js +152 -0
  136. package/dist/host-monitoring-alert-policy.js.map +1 -0
  137. package/dist/host-monitoring-alert-resources.d.ts +11 -0
  138. package/dist/host-monitoring-alert-resources.js +16 -0
  139. package/dist/host-monitoring-alert-resources.js.map +1 -0
  140. package/dist/host-monitoring-alert-settings.d.ts +16 -0
  141. package/dist/host-monitoring-alert-settings.js +68 -0
  142. package/dist/host-monitoring-alert-settings.js.map +1 -0
  143. package/dist/host-monitoring-alert-store.d.ts +49 -0
  144. package/dist/host-monitoring-alert-store.js +228 -0
  145. package/dist/host-monitoring-alert-store.js.map +1 -0
  146. package/dist/host-monitoring-alert-text.d.ts +7 -0
  147. package/dist/host-monitoring-alert-text.js +10 -0
  148. package/dist/host-monitoring-alert-text.js.map +1 -0
  149. package/dist/host-monitoring-alerts.d.ts +79 -0
  150. package/dist/host-monitoring-alerts.js +276 -0
  151. package/dist/host-monitoring-alerts.js.map +1 -0
  152. package/dist/host-monitoring-defaults.d.ts +19 -0
  153. package/dist/host-monitoring-defaults.js +10 -0
  154. package/dist/host-monitoring-defaults.js.map +1 -0
  155. package/dist/host-monitoring-footprint-policy.d.ts +45 -0
  156. package/dist/host-monitoring-footprint-policy.js +150 -0
  157. package/dist/host-monitoring-footprint-policy.js.map +1 -0
  158. package/dist/host-monitoring-footprint.d.ts +42 -0
  159. package/dist/host-monitoring-footprint.js +169 -0
  160. package/dist/host-monitoring-footprint.js.map +1 -0
  161. package/dist/host-monitoring-history-policy.d.ts +2 -0
  162. package/dist/host-monitoring-history-policy.js +16 -2
  163. package/dist/host-monitoring-history-policy.js.map +1 -1
  164. package/dist/host-monitoring-history-store.js +8 -6
  165. package/dist/host-monitoring-history-store.js.map +1 -1
  166. package/dist/host-monitoring-history-worker.js +19 -3
  167. package/dist/host-monitoring-history-worker.js.map +1 -1
  168. package/dist/host-monitoring-history.d.ts +9 -0
  169. package/dist/host-monitoring-history.js +45 -9
  170. package/dist/host-monitoring-history.js.map +1 -1
  171. package/dist/host-monitoring-platform.d.ts +18 -70
  172. package/dist/host-monitoring-platform.js +14 -269
  173. package/dist/host-monitoring-platform.js.map +1 -1
  174. package/dist/host-monitoring-process-identity.d.ts +8 -0
  175. package/dist/host-monitoring-process-identity.js +81 -0
  176. package/dist/host-monitoring-process-identity.js.map +1 -0
  177. package/dist/host-monitoring-runtime.d.ts +8 -0
  178. package/dist/host-monitoring-runtime.js +18 -3
  179. package/dist/host-monitoring-runtime.js.map +1 -1
  180. package/dist/host-monitoring.d.ts +15 -0
  181. package/dist/host-monitoring.js.map +1 -1
  182. package/dist/hub/agent-catalog-model.d.ts +21 -0
  183. package/dist/hub/agent-catalog-model.js +9 -1
  184. package/dist/hub/agent-catalog-model.js.map +1 -1
  185. package/dist/hub/agent-catalog.d.ts +4 -1
  186. package/dist/hub/agent-catalog.js +11 -0
  187. package/dist/hub/agent-catalog.js.map +1 -1
  188. package/dist/hub/catalog.js +12 -0
  189. package/dist/hub/catalog.js.map +1 -1
  190. package/dist/hub/client.js +4 -1
  191. package/dist/hub/client.js.map +1 -1
  192. package/dist/hub/compose/member.d.ts +5 -0
  193. package/dist/hub/compose/member.js +25 -5
  194. package/dist/hub/compose/member.js.map +1 -1
  195. package/dist/hub/compose/server.d.ts +2 -0
  196. package/dist/hub/compose/server.js +4 -2
  197. package/dist/hub/compose/server.js.map +1 -1
  198. package/dist/hub/http/compose.d.ts +5 -0
  199. package/dist/hub/http/compose.js +25 -2
  200. package/dist/hub/http/compose.js.map +1 -1
  201. package/dist/hub/http/deps.d.ts +2 -0
  202. package/dist/hub/http/schema.js +4 -0
  203. package/dist/hub/http/schema.js.map +1 -1
  204. package/dist/hub/lapse-carry.d.ts +45 -0
  205. package/dist/hub/lapse-carry.js +62 -0
  206. package/dist/hub/lapse-carry.js.map +1 -0
  207. package/dist/hub/member/agent-catalog.d.ts +4 -1
  208. package/dist/hub/member/agent-catalog.js +15 -4
  209. package/dist/hub/member/agent-catalog.js.map +1 -1
  210. package/dist/hub/member/agent-intro.d.ts +4 -3
  211. package/dist/hub/member/agent-intro.js +7 -0
  212. package/dist/hub/member/agent-intro.js.map +1 -1
  213. package/dist/hub/member/exposure-api.d.ts +2 -0
  214. package/dist/hub/member/exposure-api.js +8 -1
  215. package/dist/hub/member/exposure-api.js.map +1 -1
  216. package/dist/hub/member/room-post.d.ts +34 -6
  217. package/dist/hub/member/room-post.js +30 -0
  218. package/dist/hub/member/room-post.js.map +1 -1
  219. package/dist/hub/member/sharing.d.ts +2 -0
  220. package/dist/hub/member/sharing.js +9 -2
  221. package/dist/hub/member/sharing.js.map +1 -1
  222. package/dist/hub/protocol.d.ts +2 -0
  223. package/dist/hub/room-brief-model.js +2 -1
  224. package/dist/hub/room-brief-model.js.map +1 -1
  225. package/dist/hub/rooms/agents.d.ts +2 -0
  226. package/dist/hub/rooms/agents.js +16 -2
  227. package/dist/hub/rooms/agents.js.map +1 -1
  228. package/dist/hub/rooms/office.d.ts +82 -0
  229. package/dist/hub/rooms/office.js +46 -0
  230. package/dist/hub/rooms/office.js.map +1 -0
  231. package/dist/hub/rooms/service.d.ts +66 -1
  232. package/dist/hub/rooms/service.js +67 -11
  233. package/dist/hub/rooms/service.js.map +1 -1
  234. package/dist/hub/rooms/types.d.ts +4 -0
  235. package/dist/hub/runtime.d.ts +1 -1
  236. package/dist/hub/server.js +9 -2
  237. package/dist/hub/server.js.map +1 -1
  238. package/dist/hub/sharing-requests.d.ts +5 -2
  239. package/dist/hub/sharing-requests.js +19 -4
  240. package/dist/hub/sharing-requests.js.map +1 -1
  241. package/dist/instance-config-impact.js +1 -1
  242. package/dist/instance-config-impact.js.map +1 -1
  243. package/dist/instance-lifecycle.js +8 -9
  244. package/dist/instance-lifecycle.js.map +1 -1
  245. package/dist/instruction-file-sizes.d.ts +46 -0
  246. package/dist/instruction-file-sizes.js +115 -0
  247. package/dist/instruction-file-sizes.js.map +1 -0
  248. package/dist/instructions.d.ts +35 -1
  249. package/dist/instructions.js +59 -33
  250. package/dist/instructions.js.map +1 -1
  251. package/dist/locale.js +16 -4
  252. package/dist/locale.js.map +1 -1
  253. package/dist/log-steps.d.ts +5 -0
  254. package/dist/log-steps.js +6 -2
  255. package/dist/log-steps.js.map +1 -1
  256. package/dist/memory-guidance.d.ts +5 -0
  257. package/dist/memory-guidance.js +14 -0
  258. package/dist/memory-guidance.js.map +1 -0
  259. package/dist/model-defaults.d.ts +5 -0
  260. package/dist/model-defaults.js +6 -0
  261. package/dist/model-defaults.js.map +1 -0
  262. package/dist/native-mcp.d.ts +2 -0
  263. package/dist/native-mcp.js +16 -6
  264. package/dist/native-mcp.js.map +1 -1
  265. package/dist/needs-you-hub.d.ts +3 -0
  266. package/dist/needs-you-hub.js +7 -1
  267. package/dist/needs-you-hub.js.map +1 -1
  268. package/dist/needs-you.d.ts +15 -2
  269. package/dist/needs-you.js +6 -0
  270. package/dist/needs-you.js.map +1 -1
  271. package/dist/outbound-handlers.d.ts +3 -3
  272. package/dist/outbound-schemas.d.ts +3 -0
  273. package/dist/outbound-schemas.js +27 -26
  274. package/dist/outbound-schemas.js.map +1 -1
  275. package/dist/public-web-gateway.js +7 -1
  276. package/dist/public-web-gateway.js.map +1 -1
  277. package/dist/quickstart.d.ts +1 -1
  278. package/dist/quickstart.js +2 -3
  279. package/dist/quickstart.js.map +1 -1
  280. package/dist/remote-card-prompt.d.ts +1 -0
  281. package/dist/remote-card-prompt.js +1 -1
  282. package/dist/remote-card-prompt.js.map +1 -1
  283. package/dist/runtime-build-info.js +1 -1
  284. package/dist/runtime-build-info.js.map +1 -1
  285. package/dist/runtime-cli-install.js +9 -9
  286. package/dist/runtime-cli-install.js.map +1 -1
  287. package/dist/runtime-pane-mcp.js +7 -3
  288. package/dist/runtime-pane-mcp.js.map +1 -1
  289. package/dist/runtime-pane-native.js +2 -1
  290. package/dist/runtime-pane-native.js.map +1 -1
  291. package/dist/scheduler/db.js +2 -0
  292. package/dist/scheduler/db.js.map +1 -1
  293. package/dist/scheduler/task-board-mentions.d.ts +32 -0
  294. package/dist/scheduler/task-board-mentions.js +97 -0
  295. package/dist/scheduler/task-board-mentions.js.map +1 -0
  296. package/dist/scheduler/task-board-text.js +3 -0
  297. package/dist/scheduler/task-board-text.js.map +1 -1
  298. package/dist/scheduler/task-board.d.ts +199 -3
  299. package/dist/scheduler/task-board.js +492 -7
  300. package/dist/scheduler/task-board.js.map +1 -1
  301. package/dist/settings-api.d.ts +5 -1
  302. package/dist/settings-api.js +77 -2
  303. package/dist/settings-api.js.map +1 -1
  304. package/dist/settings-baseline.js +5 -4
  305. package/dist/settings-baseline.js.map +1 -1
  306. package/dist/settings-change.js +4 -2
  307. package/dist/settings-change.js.map +1 -1
  308. package/dist/settings-effect.d.ts +2 -0
  309. package/dist/settings-effect.js +20 -1
  310. package/dist/settings-effect.js.map +1 -1
  311. package/dist/settings-instance-patch.js +3 -1
  312. package/dist/settings-instance-patch.js.map +1 -1
  313. package/dist/setup-host.d.ts +2 -3
  314. package/dist/setup-host.js +3 -5
  315. package/dist/setup-host.js.map +1 -1
  316. package/dist/setup-wizard.js +0 -2
  317. package/dist/setup-wizard.js.map +1 -1
  318. package/dist/shared-default-adoption.d.ts +24 -0
  319. package/dist/shared-default-adoption.js +73 -0
  320. package/dist/shared-default-adoption.js.map +1 -0
  321. package/dist/subagent-records.d.ts +2 -0
  322. package/dist/subagent-records.js +11 -1
  323. package/dist/subagent-records.js.map +1 -1
  324. package/dist/subagent-service.d.ts +3 -0
  325. package/dist/subagent-service.js +24 -4
  326. package/dist/subagent-service.js.map +1 -1
  327. package/dist/task-board-tool.d.ts +31 -0
  328. package/dist/task-board-tool.js +31 -0
  329. package/dist/task-board-tool.js.map +1 -1
  330. package/dist/task-board-waker.d.ts +23 -30
  331. package/dist/task-board-waker.js +136 -97
  332. package/dist/task-board-waker.js.map +1 -1
  333. package/dist/topic-commands.js +4 -0
  334. package/dist/topic-commands.js.map +1 -1
  335. package/dist/types.d.ts +23 -0
  336. package/dist/ui/agent-details-settings.js +2 -2
  337. package/dist/ui/agent-export-dialog.js +4 -3
  338. package/dist/ui/agent-export-strings.js +4 -4
  339. package/dist/ui/agent-page-strings.js +18 -0
  340. package/dist/ui/chat-activity-groups.js +1 -1
  341. package/dist/ui/chat-activity.js +17 -0
  342. package/dist/ui/chat-store.js +34 -8
  343. package/dist/ui/chat-task-ref-strings.js +24 -0
  344. package/dist/ui/chat-task-refs.js +129 -0
  345. package/dist/ui/claude-setup-token.js +3 -3
  346. package/dist/ui/contact-auth-strings.js +33 -3
  347. package/dist/ui/contact-authorizations.js +17 -24
  348. package/dist/ui/contact-grant-editor.js +50 -0
  349. package/dist/ui/contact-permissions.js +21 -8
  350. package/dist/ui/fleet-office-card.js +18 -14
  351. package/dist/ui/fleet-office.js +29 -17
  352. package/dist/ui/fleet-task-activity.js +362 -0
  353. package/dist/ui/fleet-task-card.js +317 -314
  354. package/dist/ui/fleet-task-common.js +99 -9
  355. package/dist/ui/fleet-task-create.js +67 -0
  356. package/dist/ui/fleet-task-edit.js +204 -0
  357. package/dist/ui/fleet-task-follow.js +123 -0
  358. package/dist/ui/fleet-task-menu.js +1 -1
  359. package/dist/ui/fleet-task-owner.js +252 -0
  360. package/dist/ui/fleet-task-run.js +257 -0
  361. package/dist/ui/fleet-task-view.js +178 -39
  362. package/dist/ui/fleet-task-work.js +2 -2
  363. package/dist/ui/fleet-tasks.js +258 -130
  364. package/dist/ui/host-alerts.js +23 -0
  365. package/dist/ui/host-footprint.js +17 -0
  366. package/dist/ui/host-health.js +24 -16
  367. package/dist/ui/host-monitoring-darwin.js +6 -0
  368. package/dist/ui/host-monitoring-help.js +7 -0
  369. package/dist/ui/host-monitoring-linux.js +6 -0
  370. package/dist/ui/host-monitoring-wsl.js +6 -0
  371. package/dist/ui/host-time.js +5 -0
  372. package/dist/ui/hub-agent-copy.js +2 -0
  373. package/dist/ui/hub-client.js +4 -0
  374. package/dist/ui/hub-my-agents-strings.js +2 -0
  375. package/dist/ui/hub-my-agents.js +17 -1
  376. package/dist/ui/hub-room-composer.js +108 -5
  377. package/dist/ui/hub-room-members-strings.js +9 -2
  378. package/dist/ui/hub-room-members.js +72 -15
  379. package/dist/ui/hub-room-office.js +191 -0
  380. package/dist/ui/hub-room-purpose.js +18 -2
  381. package/dist/ui/hub-room-settings.js +8 -1
  382. package/dist/ui/hub-room-strings.js +15 -0
  383. package/dist/ui/hub-room-thread.js +51 -15
  384. package/dist/ui/hub-strings.js +1 -1
  385. package/dist/ui/log-row.js +7 -5
  386. package/dist/ui/native-instance-settings.js +4 -2
  387. package/dist/ui/panel-chat.js +98 -17
  388. package/dist/ui/panel-details.js +17 -0
  389. package/dist/ui/panel-fleet.js +1 -1
  390. package/dist/ui/panel-hub.js +4 -1
  391. package/dist/ui/panel-needs.js +38 -18
  392. package/dist/ui/panel-settings.js +58 -13
  393. package/dist/ui/settings-apply.js +8 -3
  394. package/dist/ui/settings-default-model-scope.js +40 -0
  395. package/dist/ui/settings-default-model-strings.js +43 -0
  396. package/dist/ui/settings-dialogs.js +9 -5
  397. package/dist/ui/settings-host-alerts.js +23 -0
  398. package/dist/ui/settings-host-monitoring.js +10 -8
  399. package/dist/ui/settings-hub.js +1 -1
  400. package/dist/ui/settings-layout.js +7 -2
  401. package/dist/ui/settings-model.js +9 -5
  402. package/dist/ui/settings-quota-notice.js +3 -3
  403. package/dist/ui/settings-registry.js +3 -0
  404. package/dist/ui/settings-shared-strings.js +22 -0
  405. package/dist/ui/settings-shared.js +59 -12
  406. package/dist/ui/settings-strings.js +2 -4
  407. package/dist/ui/shared/app-i18n.js +2 -2
  408. package/dist/ui/shared/app.css +169 -50
  409. package/dist/ui/shared/chat-composer.js +7 -6
  410. package/dist/ui/shared/chat-render.js +63 -10
  411. package/dist/ui/shared/chat-strings.js +2 -2
  412. package/dist/ui/shared/chat-thread.js +10 -3
  413. package/dist/ui/shared/composer-focus.js +21 -0
  414. package/dist/ui/shared/hub-chat.css +30 -2
  415. package/dist/ui/shared/hub-rooms-u2.css +17 -0
  416. package/dist/ui/shared/task-board.css +406 -8
  417. package/dist/ui/trigger-complete.js +71 -0
  418. package/dist/web-api.d.ts +11 -1
  419. package/dist/web-api.js +324 -18
  420. package/dist/web-api.js.map +1 -1
  421. package/dist/web-chat-history.d.ts +40 -1
  422. package/dist/web-chat-history.js +131 -9
  423. package/dist/web-chat-history.js.map +1 -1
  424. package/dist/web-guest-access.js +4 -4
  425. package/dist/web-guest-access.js.map +1 -1
  426. package/dist/web-upload.d.ts +1 -1
  427. package/dist/web-upload.js.map +1 -1
  428. package/dist/windows-native-mcp.js +5 -2
  429. package/dist/windows-native-mcp.js.map +1 -1
  430. package/dist/workflow-templates/default.md +4 -6
  431. package/package.json +1 -1
@@ -28,13 +28,13 @@ import { nineSlice } from "./fleet-office-dialogue.js";
28
28
  register("ocard", {
29
29
  en: {
30
30
  card: "{0}'s card", level: "Lv {0}", work: "{0} work tokens", estimated: "estimated", toNext: "{0} to Lv {1}", office: "Office", model: "Model", backend: "Backend",
31
- today: "Today", todayN: "{0} work tokens · {1} requests", firstSeen: "First seen", day: "Day {0}", now: "Now", find: "Find in office", chat: "Chat", pat: "Pat", feed: "Feed", tell: "Tell {0} (with their next message)", tellNote: "Off: only you see it. On: a line like “[Office] <your name> patted your head ×3” rides the next message they get anyway — it never wakes them.",
31
+ today: "Today", todayN: "{0} work tokens · {1} requests", firstSeen: "First seen", day: "Day {0}", now: "Now", nowLabel: "Now:", find: "Find in office", chat: "Chat", pat: "Pat", feed: "Feed", tell: "Tell {0} (with their next message)", tellNote: "Off: only you see it. On: a line like “[Office] <your name> patted your head ×3” rides the next message they get anyway — it never wakes them.",
32
32
  chatWindow: "Open {0}’s chat in a new window",
33
33
  close: "Close", xp: "Progress to Lv {0}",
34
34
  },
35
35
  "zh-TW": {
36
36
  card: "{0} 的名片", level: "Lv {0}", work: "{0} 工作 token", estimated: "估算", toNext: "再 {0} 到 Lv {1}", office: "辦公室", model: "模型", backend: "後端",
37
- today: "今天", todayN: "{0} 工作 token · {1} 次請求", firstSeen: "首次出現", day: "第 {0} 天", now: "現在", find: "在辦公室找他", chat: "聊天", pat: "摸頭", feed: "餵點心", tell: "讓 {0} 知道(隨下一則訊息)", tellNote: "關閉:只有你看得到。開啟:下一則本來就會送給它的訊息會附上一行,例如「[Office] <你的名字> patted your head ×3」,不會叫醒它。",
37
+ today: "今天", todayN: "{0} 工作 token · {1} 次請求", firstSeen: "首次出現", day: "第 {0} 天", now: "現在", nowLabel: "現在:", find: "在辦公室找它", chat: "聊天", pat: "摸頭", feed: "餵點心", tell: "讓 {0} 知道(隨下一則訊息)", tellNote: "關閉:只有你看得到。開啟:下一則本來就會送給它的訊息會附上一行,例如「[Office] <你的名字> patted your head ×3」,不會叫醒它。",
38
38
  chatWindow: "在新視窗開啟 {0} 的聊天",
39
39
  close: "關閉", xp: "升到 Lv {0} 的進度",
40
40
  },
@@ -52,9 +52,10 @@ export function dayOf(first, nowMs = Date.now()) {
52
52
  /**
53
53
  * What the card says (pure, for the component and the tests): `node` the org chart's node; `lv` levelsOk's answer (or
54
54
  * null); `levels` the style's pack `levels` (or null); `share` a share link's page; `state` the state's words; `now`
55
- * the tooltip's activity line; `where` the office (and area) in words.
55
+ * the tooltip's activity line; `where` the office (and area) in words. M-3533: `rows` ({ key, label, value }[]) the
56
+ * card's rows instead of the office's own (a Hub room's office: the agent's owner and introduction).
56
57
  */
57
- export function cardModel({ node, lv, levels, share = false, state, now, where }) {
58
+ export function cardModel({ node, lv, levels, share = false, state, now, where, rows: given = null }) {
58
59
  const it = node.i || {};
59
60
  const names = node.i ? namesOf(node.i) : { primary: node.name, secondary: "" };
60
61
  const fx = fixedOf(node.name, levels);
@@ -64,18 +65,18 @@ export function cardModel({ node, lv, levels, share = false, state, now, where }
64
65
  const title = on && fx ? fx.title : e ? titleOf(e.level, levels && levels.titles) : null;
65
66
  const detail = !share && !!e && e.workTokens !== undefined;
66
67
  const xp = showLevel && detail ? xpOf(e.level, e.workTokens, lv.unit) : null;
67
- const rowItems = [{ key: "office", label: tc("office"), value: where }];
68
- if (!share && it.model) rowItems.push({
68
+ const rowItems = Array.isArray(given) ? given.filter((r) => r && r.value) : [{ key: "office", label: tc("office"), value: where }];
69
+ if (!given && !share && it.model) rowItems.push({
69
70
  key: "model",
70
71
  label: it.model_observation ? observationLabel("selection") : tc("model"),
71
72
  value: it.model_observation ? (modelName(it.model_observation.session) || observationLabel("unresolved")) : modelText(it),
72
73
  });
73
- if (!share && it.backend) rowItems.push({ key: "backend", label: tc("backend"), value: backendLabel(it.backend) });
74
+ if (!given && !share && it.backend) rowItems.push({ key: "backend", label: tc("backend"), value: backendLabel(it.backend) });
74
75
  if (detail) rowItems.push({ key: "today", label: tc("today"), value: tc("todayN", tokens(e.today.workTokens), e.today.requests) });
75
76
  if (detail && e.firstSeen) rowItems.push({ key: "firstSeen", label: tc("firstSeen"), value: tc("day", dayOf(e.firstSeen)) });
76
77
  const rows = rowItems.map((r) => [r.label, r.value]);
77
78
  return {
78
- name: names.primary, instance: node.name, state, title,
79
+ name: names.primary, instance: given ? "" : node.name, state, title,
79
80
  stateLine: title ? `${state} · ${title}` : state,
80
81
  badge: on && fx && fx.hideLevel ? { mark: true, tier: 0 } : e ? { text: badgeText(e.level), tier: tierOf(e.level) } : null,
81
82
  level: showLevel ? { line1: detail ? `${tc("level", e.level)} · ${tc("work", tokens(e.workTokens))}` : tc("level", e.level), estimated: detail && e.estimated,
@@ -325,9 +326,10 @@ function drawPortraitAvatar(cv, im, W) {
325
326
  * The card. `model`: cardModel's; `avatar(canvas, sizePx)`: draws the person's idle frame on it; `sheet`: a bottom
326
327
  * sheet (a phone); `place(el)`: the page positions the popover (beside the person, following them); `onChat` (none on
327
328
  * a share link), `onFind`, `onClose`; M-3293: `onReact(kind)` — Pat and Feed (only where play is on; none on a share
328
- * link); M-3433: optional `packCard`, `picture` (lazy image loader), `portrait` (src), `packScale`.
329
+ * link); M-3433: optional `packCard`, `picture` (lazy image loader), `portrait` (src), `packScale`; M-3533: `action`
330
+ * ({ label, title, run }) the card's own main action, from the page (a Hub room's office: "@ it", to ask it in the chat).
329
331
  */
330
- export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onClose, onReact = null, tell = null, packCard = null, picture = null, portrait = null, packScale = 2 }) {
332
+ export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onClose, onReact = null, tell = null, packCard = null, picture = null, portrait = null, packScale = 2, action = null }) {
331
333
  const box = useRef(null), canvas = useRef(null), bgCanvas = useRef(null), swipe = useRef(null);
332
334
  const [picRev, setPicRev] = useState(0);
333
335
  const spec = useMemo(() => resolveCardSpec(packCard), [packCard]);
@@ -400,7 +402,7 @@ export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onC
400
402
  ${m.badge ? html`<span class=${`oo-badge tier-${m.badge.tier}${m.badge.mark ? " mark" : ""}`} aria-hidden="true">${m.badge.mark ? "" : m.badge.text}</span>` : null}</div>
401
403
  <div class="oo-card-names">
402
404
  <strong class="oo-card-name">${m.name}</strong>
403
- <div class="oo-card-instance mono" title=${m.instance}>${m.instance}</div>
405
+ ${m.instance ? html`<div class="oo-card-instance mono" title=${m.instance}>${m.instance}</div>` : null}
404
406
  <div class="oo-card-state">${m.stateLine}</div>
405
407
  </div>
406
408
  <button type="button" class="icon-btn oo-card-close" aria-label=${tc("close")} title=${tc("close")} onClick=${onClose}>×</button>
@@ -411,7 +413,7 @@ export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onC
411
413
  ${m.level.pct !== null ? html`<progress class="oo-card-bar" max="100" value=${Math.round(m.level.pct * 100)} aria-label=${tc("xp", m.level.next)}></progress>` : null}
412
414
  </div>` : null}
413
415
  <dl class="oo-card-rows">${(m.rowItems || m.rows.map(([label, value]) => ({ key: "", label, value }))).map((r) => html`<div data-row=${r.key || undefined}><dt>${r.label}</dt><dd>${r.value}</dd></div>`)}</dl>
414
- ${m.now ? html`<div class="oo-card-now"><span class="muted">${tc("now")}:</span> ${m.now}</div>` : null}
416
+ ${m.now ? html`<div class="oo-card-now"><span class="muted">${tc("nowLabel")}</span> ${m.now}</div>` : null}
415
417
  ${tell ? html`<label class="check oo-card-tell" title=${tc("tellNote")}><input type="checkbox" checked=${tell.on} onChange=${(e) => tell.set(e.target.checked)} />
416
418
  <span>${tc("tell", m.name)}</span></label>` : null}
417
419
  <div class="oo-card-actions">
@@ -419,6 +421,7 @@ export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onC
419
421
  <button type="button" class="btn btn-sm btn-ghost oo-card-feed" onClick=${() => onReact("feed")}>${tc("feed")}</button>` : null}
420
422
  ${onFind ? html`<button type="button" class="btn btn-sm btn-ghost oo-card-find" onClick=${onFind}>${tc("find")}</button>` : null}
421
423
  ${onChat ? html`<button type="button" class="btn btn-sm btn-primary oo-card-chat" title=${tc("chatWindow", m.name)} aria-label=${tc("chatWindow", m.name)} onClick=${onChat}>${tc("chat")}</button>` : null}
424
+ ${action ? html`<button type="button" class="btn btn-sm btn-primary oo-card-action" title=${action.title || undefined} aria-label=${action.title || undefined} onClick=${action.run}>${action.label}</button>` : null}
422
425
  </div>
423
426
  </div>`;
424
427
  }
@@ -443,7 +446,7 @@ export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onC
443
446
  ${m.badge && !hide.has("badge") ? html`<span class=${`oo-badge tier-${m.badge.tier}${m.badge.mark ? " mark" : ""}`} aria-hidden="true">${m.badge.mark ? "" : m.badge.text}</span>` : null}</div>
444
447
  <div class="oo-card-names">
445
448
  <strong class="oo-card-name">${m.name}</strong>
446
- ${!hide.has("instance") ? html`<div class="oo-card-instance mono" title=${m.instance}>${m.instance}</div>` : null}
449
+ ${!hide.has("instance") && m.instance ? html`<div class="oo-card-instance mono" title=${m.instance}>${m.instance}</div>` : null}
447
450
  <div class="oo-card-state">${stateLine}</div>
448
451
  </div>
449
452
  <button type="button" class="icon-btn oo-card-close" aria-label=${tc("close")} title=${tc("close")} onClick=${onClose}>×</button>
@@ -463,7 +466,7 @@ export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onC
463
466
  }
464
467
  if (sec === "now") {
465
468
  if (!m.now || hide.has("now")) return null;
466
- return html`<div key="now" class="oo-card-now"><span class="muted">${tc("now")}:</span> ${m.now}</div>`;
469
+ return html`<div key="now" class="oo-card-now"><span class="muted">${tc("nowLabel")}</span> ${m.now}</div>`;
467
470
  }
468
471
  if (sec === "tell") {
469
472
  if (!tell) return null;
@@ -476,6 +479,7 @@ export function OfficeCard({ model: m, avatar, sheet, place, onChat, onFind, onC
476
479
  <button type="button" class="btn btn-sm btn-ghost oo-card-feed" onClick=${() => onReact("feed")}>${tc("feed")}</button>` : null}
477
480
  ${onFind ? html`<button type="button" class="btn btn-sm btn-ghost oo-card-find" onClick=${onFind}>${tc("find")}</button>` : null}
478
481
  ${onChat ? html`<button type="button" class="btn btn-sm btn-primary oo-card-chat" title=${tc("chatWindow", m.name)} aria-label=${tc("chatWindow", m.name)} onClick=${onChat}>${tc("chat")}</button>` : null}
482
+ ${action ? html`<button type="button" class="btn btn-sm btn-primary oo-card-action" title=${action.title || undefined} aria-label=${action.title || undefined} onClick=${action.run}>${action.label}</button>` : null}
479
483
  </div>`;
480
484
  }
481
485
  return null;
@@ -837,6 +837,13 @@ export function OfficeKey({ pal }) {
837
837
  * `assetImage(url)` how (the share's, which waits out a 429, #2662; none: the loader's own);
838
838
  * `opening` the office it opens on (the share's), instead of the one this browser chose last; #2861: `talk` the share's
839
839
  * conversations (its /state's: who heard or answered a person, when — never what was said), instead of the stream's.
840
+ * M-3533 R1, a Hub room's office (hub-room-office.js), on the Fleet dashboard's own origin too: `oneOffice` its one office
841
+ * (no office picker or carousel); `readOnly` no editing or sharing whatever the session; `stream` false: never this
842
+ * page's own stream (the fleet's offices, acts and skins); `storage` where this browser's choices are kept (not the
843
+ * Fleet office's); `cardRows(name)` a card's rows instead of the office's (the room's: owner, introduction); `words(node)`
844
+ * a person's state and activity in the page's own words ({ state, now }: the room's member list's), instead of the Fleet's;
845
+ * `cardAction(name)` a card's main action ({ label, title, run }: the room's "@ it"), or null; `officesKey` read the offices
846
+ * again when it changes (a page with no stream: the room's office when an agent joins, leaves or is renamed).
840
847
  */
841
848
  function ensureDialogueStyle() {
842
849
  const doc = globalThis.document;
@@ -845,12 +852,16 @@ function ensureDialogueStyle() {
845
852
  link.href = assetUrl("/assets/office-dialogue.css");
846
853
  link.setAttribute("data-office-dialogue-css", "1"); doc.head.appendChild(link);
847
854
  }
848
- export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetImage, opening, talk, more = false, onMore = null, live = null, onLive = null }) {
855
+ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetImage, opening, talk, more = false, onMore = null, live = null, onLive = null,
856
+ oneOffice = false, readOnly = false, stream = true, storage = undefined, cardRows = null, words = null, cardAction = null, officesKey = undefined }) {
849
857
  // M-3253: on a phone the page above (fleet-canvas.js) puts a ⋯ in its bar: `more` is that sheet open, `onMore(open)`;
850
858
  // `live` / `onLive` its Live toggle, which moves into the sheet. Without one (a share link's page) the bar stays.
851
859
  useLayoutEffect(ensureDialogueStyle, []);
852
860
  const phone = useOfficePhone(), compact = phone && typeof onMore === "function";
853
- const store = useMemo(() => createOfficeStore(lease ? { fetch: (path, o) => lease.fetch(path, o) } : {}), [lease]);
861
+ const store = useMemo(() => createOfficeStore({ ...(lease ? { fetch: (path, o) => lease.fetch(path, o) } : {}), ...(storage ? { storage } : {}) }), [lease, storage]);
862
+ const streamOn = () => (stream === false ? null : appStore.get().streamOn);
863
+ const stateOf = (node) => (words ? words(node).state : stateWords(node));
864
+ const nowOf = (node) => (words ? words(node).now : caption(officePose(node.state), node.state));
854
865
  const [stored, setStored] = useState([]);
855
866
  const [storedRev, setStoredRev] = useState(null); // the rev the list was read at (a save sends it)
856
867
  const [canEdit, setCanEdit] = useState(false); // an admin session (never a guest or the public link)
@@ -978,10 +989,10 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
978
989
  if (!lease) return undefined;
979
990
  const read = async () => { const at = ask(); const d = await store.offices(); if (lease.current()) adopt(d, at); };
980
991
  void read();
981
- const sub = appStore.get().streamOn;
992
+ const sub = streamOn();
982
993
  const off = sub ? lease.hold(sub("offices", () => { void read(); })) : null;
983
994
  return () => { if (off) off(); };
984
- }, [lease, store]);
995
+ }, [lease, store, officesKey]);
985
996
  // #2578: what agents do here by their own hand (office_set) — on opening, then as the stream brings it.
986
997
  // A read a newer one or the stream overtook is dropped (it is older: review — an opening read answered after the one
987
998
  // the stream's return began brought a cleared act back); read again when the stream comes back, and — with no live
@@ -1014,7 +1025,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
1014
1025
  let heard = 0; // reads begun and events heard: the newest wins
1015
1026
  const read = async () => { const at = ++heard, d = await store.acts(); if (lease.current() && d && at === heard) setActs(d); };
1016
1027
  void read();
1017
- const sub = appStore.get().streamOn;
1028
+ const sub = streamOn();
1018
1029
  const polled = () => globalThis.document?.body?.dataset?.webTransport === "poll" || appStore.get().connection === "polling";
1019
1030
  const offs = sub ? [lease.hold(sub("office_acts", (d) => { heard++; if (d && Array.isArray(d.acts)) setActs(actsOk(d.acts, d.now)); else void read(); })),
1020
1031
  lease.hold(sub("connection", (c) => { if (c === "live") void read(); }))] : [];
@@ -1036,7 +1047,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
1036
1047
  };
1037
1048
  useEffect(() => {
1038
1049
  if (!dialogueOn || talk !== undefined) return undefined;
1039
- const sub = appStore.get().streamOn;
1050
+ const sub = streamOn();
1040
1051
  if (!sub) return undefined;
1041
1052
  let skew = 0;
1042
1053
  const seen = new Set();
@@ -1088,7 +1099,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
1088
1099
  if (!lease) return undefined;
1089
1100
  const read = async () => { const d = await store.skins(); if (lease.current() && d) setPacks(d.packs); };
1090
1101
  void read();
1091
- const sub = appStore.get().streamOn;
1102
+ const sub = streamOn();
1092
1103
  const off = sub ? lease.hold(sub("office_skins", () => { void read(); })) : null;
1093
1104
  return () => { if (off) off(); };
1094
1105
  }, [lease, store]);
@@ -1097,7 +1108,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
1097
1108
  // session's here or over the public link (the host asks again too); never a guest's or a read-only one's.
1098
1109
  useEffect(() => {
1099
1110
  const body = globalThis.document?.body;
1100
- if (!body || body.dataset.tier === "guest") return undefined;
1111
+ if (readOnly || !body || body.dataset.tier === "guest") return undefined;
1101
1112
  let live = true;
1102
1113
  const auth = globalThis.AgendAuth;
1103
1114
  if (auth && typeof auth.canWrite === "function") Promise.resolve(auth.canWrite()).then((v) => { if (live) { setCanEdit(v === true); setCanShare(v === true); } }, () => {});
@@ -2283,7 +2294,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
2283
2294
  const tile = (icon, label, fn, cls, pressed) => html`<button type="button" class=${`oo-sheet-tile ${cls}`} aria-pressed=${pressed === undefined ? undefined : pressed ? "true" : "false"}
2284
2295
  onClick=${fn}><${Icon} name=${icon} size=${20} /><span>${label}</span></button>`;
2285
2296
  const barItems = html`
2286
- <label class="oo-pick"><span class="oo-pick-label">${to("office")}</span>${officeSelect("oo-office")}</label>
2297
+ ${oneOffice ? null : html`<label class="oo-pick"><span class="oo-pick-label">${to("office")}</span>${officeSelect("oo-office")}</label>`}
2287
2298
  ${auto ? html`<label class="oo-pick"><span class="oo-pick-label">${to("styleLabel")}</span>
2288
2299
  <select class="tb-select" value=${STYLES.includes(style) || packs.some((pk) => pk.id === style) ? style : skin.id} title=${to(canEdit ? "styleForAll" : "styleHere")} onChange=${(e) => pickStyle(e.target.value)}>
2289
2300
  ${styles.map((id) => html`<option key=${id} value=${id}>${to(`style_${id}`)}</option>`)}
@@ -2352,12 +2363,12 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
2352
2363
  stale=${layoutStale ? t("orgl.stale") : ""} onChange=${onDraft} onSave=${saveLayout} onClose=${closeLayout} />` : null}
2353
2364
  ${tipText && tip !== card ? html`<div ref=${tipRef} class="oo-tip" role="tooltip">
2354
2365
  <strong>${tipText.primary}</strong>${tipText.secondary ? html` <span class="muted mono">${tipText.secondary}</span>` : null}
2355
- <div>${tipText.sub}</div><div class="muted">${caption(officePose(tipDesk.node.state), tipDesk.node.state)}</div>
2366
+ <div>${words ? stateOf(tipDesk.node) : tipText.sub}</div>${nowOf(tipDesk.node) ? html`<div class="muted">${nowOf(tipDesk.node)}</div>` : null}
2356
2367
  ${tipDesk.office ? html`<div class="muted oo-tip-office">${tipDesk.office}</div>` : null}
2357
2368
  </div>` : null}
2358
2369
  ${cardOf ? html`<${OfficeCard} key=${cardOf.key}
2359
- model=${cardModel({ node: cardOf.node, lv, levels: wordsOf(cardOf.skin), share: !onOpen,
2360
- state: stateWords(cardOf.node), now: caption(officePose(cardOf.node.state), cardOf.node.state),
2370
+ model=${cardModel({ node: cardOf.node, lv, levels: wordsOf(cardOf.skin), share: !onOpen, rows: cardRows ? cardRows(cardOf.node.name) : null,
2371
+ state: stateOf(cardOf.node), now: nowOf(cardOf.node),
2361
2372
  where: [cardOf.office || (custom ? custom.name : to("allOffice")), cardOf.area].filter(Boolean).join(" · ") })}
2362
2373
  avatar=${drawAvatar} sheet=${phone || size.w < SHEET_W} place=${(el) => { cardEl.current = el; placeCard(); }}
2363
2374
  onChat=${onOpen ? () => { const n = cardOf.node.name; setCard(null); open(n); } : null} onFind=${findCard} onClose=${closeCard}
@@ -2377,13 +2388,14 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
2377
2388
  packCard=${cardOf.skin?.pack?.card || null}
2378
2389
  picture=${typeof cardOf.skin?.picture === "function" ? cardOf.skin.picture : null}
2379
2390
  portrait=${cardOf.skin?.pack ? portraitSrc(cardOf.skin.pack, { agent: cardOf.node.name, state: cardOf.node.state }) : null}
2380
- packScale=${cardOf.skin?.pack?.scale || 2} />` : null}
2391
+ packScale=${cardOf.skin?.pack?.scale || 2} action=${cardAction ? cardAction(cardOf.node.name) : null} />` : null}
2381
2392
  <ul class="oo-desks" aria-label=${to("desks")}>${people.map((d) => {
2382
- const nt = nodeText(d.node), cap = caption(officePose(d.node.state), d.node.state), where = d.office ? ` · ${d.office}` : "";
2393
+ const nt = nodeText(d.node), cap = nowOf(d.node), where = d.office ? ` · ${d.office}` : "";
2394
+ const full = words ? `${nt.primary} — ${stateOf(d.node)}` : nt.full;
2383
2395
  return html`<li key=${d.key}>${d.node.i
2384
- ? html`<button type="button" class="oo-desk" data-name=${d.node.name} data-key=${d.key} aria-label=${`${nt.full}${where} · ${cap}.`} aria-haspopup="dialog"
2396
+ ? html`<button type="button" class="oo-desk" data-name=${d.node.name} data-key=${d.key} aria-label=${`${full}${where}${cap ? ` · ${cap}` : ""}.`} aria-haspopup="dialog"
2385
2397
  onFocus=${() => setTip(d.key)} onBlur=${() => setTip(null)} onClick=${() => { cardFrom.current = d.key; setCard((cur) => (cur === d.key ? null : d.key)); }}>${nt.primary}</button>`
2386
- : html`<span class="oo-desk" data-name=${d.node.name} data-key=${d.key}>${nt.full}</span>`}</li>`;
2398
+ : html`<span class="oo-desk" data-name=${d.node.name} data-key=${d.key}>${full}</span>`}</li>`;
2387
2399
  })}</ul>
2388
2400
  <div class="oc-zoom oo-zoom" role="group" aria-label=${t("orgc.view")}>
2389
2401
  <output ref=${pctRef} class="oo-zoom-pct"></output>
@@ -2413,7 +2425,7 @@ export function Office({ view, traffic, q = "", lease, onOpen, assetUrl, assetIm
2413
2425
  ${snackDrag.kind === "feed" ? html`<span class="oo-snack-hint">${to("snackFeed", snackDrag.label)}</span>`
2414
2426
  : snackDrag.kind === "place" ? html`<span class="oo-snack-hint">${to("snackPlace")}</span>` : null}
2415
2427
  </div>` : null}
2416
- ${fs ? html`<div class="oo-fs-bar">${officeSelect("oo-fs-office")}${carChrome()}</div>` : null}
2428
+ ${fs ? html`<div class="oo-fs-bar">${oneOffice ? null : officeSelect("oo-fs-office")}${carChrome()}</div>` : null}
2417
2429
  <svg ref=${miniRef} class="oc-mini oo-mini" viewBox=${`0 0 ${Math.max(1, L.width)} ${Math.max(1, L.height)}`} aria-hidden="true" onClick=${onMini}>
2418
2430
  <title>${to("overview")}</title>
2419
2431
  <rect class="oo-mini-matte" x=${-L.width} y=${-L.height} width=${L.width * 3} height=${L.height * 3} fill=${matte} />
@@ -0,0 +1,362 @@
1
+ // A card's activity (Fleet › Tasks › a card's page): the comments, the progress log and the history are one timeline, oldest
2
+ // first, with the comment box under it. The card API still returns the three lists apart (comments, logs, history); they are
3
+ // merged here, so nothing on the server changes. A history line that only repeats a comment or a log entry ("commented",
4
+ // "logged") is dropped from the merge — the entry itself is shown. The one
5
+ // "logged" line with no entry of its own, a change of the card's watchers (`data.watchers`), stays as a history line.
6
+ // The timeline is read for progress, so what people and agents SAY and DO leads it: a comment has no box — a name and a time,
7
+ // the text under it, drawn by the chat's own Markdown renderer (safe by construction: it escapes first); a progress note is a
8
+ // line with its words in the text colour; the history is the quietest thing on the page (small, grey, a run of the same line
9
+ // from the same hand is one line "×3"); and a day change is a thin separator.
10
+ // The comment box completes `@` with the fleet's instance names: it only types `@<instance name>` into the text; what an
11
+ // @ does to that instance is the board's business (it reads the same plain text), not this box's.
12
+ // No style attribute anywhere (the CSP).
13
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
14
+ import { lang, t } from "/assets/app-i18n.js";
15
+ import "/assets/chat-render.js";
16
+ import "/assets/chat-strings.js";
17
+ import { Icon } from "/assets/ui-icons.js";
18
+ import { BoardOffNote, boardOffTargets, relTime } from "./fleet-task-common.js";
19
+ import { AgentTag } from "./fleet-task-run.js";
20
+ import { WhoCard } from "./fleet-task-owner.js";
21
+ import { insertAtTrigger, triggerAt, withoutCode } from "./trigger-complete.js";
22
+
23
+ export const TIMELINE_FILTERS = ["all", "comments", "log", "history"];
24
+ const RANK = { event: 0, log: 1, comment: 2 }; // at one instant: the move first, then the words that came with it
25
+
26
+ const when = (iso) => { const n = Date.parse(iso); return Number.isFinite(n) ? n : 0; };
27
+
28
+ /**
29
+ * The card detail's three lists as one timeline, oldest first (pure: tests import it). Each entry:
30
+ * { key, type: "comment" | "log" | "event", at, who, by, text?, kind?, authorKind?, ev? } — `ev` is the history event;
31
+ * `by` is who made it (person | instance | script | system) when the server said, else "" (an older entry): an instance's is
32
+ * marked in the timeline.
33
+ */
34
+ export function timelineOf(detail) {
35
+ const out = [];
36
+ for (const e of (detail && detail.comments) || []) out.push({ key: `c${e.id}`, type: "comment", at: e.at, who: e.author, by: e.authorKind || "", text: e.text, kind: e.kind, authorKind: e.authorKind });
37
+ for (const e of (detail && detail.logs) || []) out.push({ key: `l${e.id}`, type: "log", at: e.at, who: e.author, by: e.authorKind || "", text: e.text });
38
+ for (const ev of (detail && detail.history) || []) {
39
+ if (ev.type === "commented" || ev.type === "reordered") continue;
40
+ if (ev.type === "logged" && !(ev.data && ev.data.watchers)) continue; // a log entry is shown as itself; a watcher change has none (the board writes the event only)
41
+ out.push({ key: `h${ev.id}`, type: "event", at: ev.at, who: ev.actor, by: ev.actorKind || "", ev });
42
+ }
43
+ return out.map((e, i) => ({ e, i })).sort((a, b) => when(a.e.at) - when(b.e.at) || RANK[a.e.type] - RANK[b.e.type] || a.i - b.i).map((x) => x.e);
44
+ }
45
+
46
+ /** The entries a filter shows: everything, or one kind of them. */
47
+ export function timelineShown(entries, filter) {
48
+ const type = { comments: "comment", log: "log", history: "event" }[filter];
49
+ return type ? entries.filter((e) => e.type === type) : entries;
50
+ }
51
+
52
+ // ── Completing an @ ───────────────────────────────────────
53
+
54
+ // The word at the caret and its replacement are the shared trigger-complete.js's, with the trigger "@": the list
55
+ // is offered only where the board would read the name as a mention (task-board-mentions.ts), and what is typed in is read
56
+ // back as that instance. withoutCode is the board's own, re-exported for the tests.
57
+ export { withoutCode };
58
+
59
+ /** The `@name` being typed at the caret, or null: { start: where the "@" is, query: the characters after it }. */
60
+ export const mentionAt = (text, caret) => triggerAt(text, caret, "@");
61
+
62
+ /** The names that complete a query: those starting with it first, then those containing it; case does not matter. */
63
+ export function mentionMatches(names, query, limit = 8) {
64
+ const q = query.toLocaleLowerCase();
65
+ const lower = (n) => n.toLocaleLowerCase();
66
+ const starts = names.filter((n) => lower(n).startsWith(q));
67
+ const inside = names.filter((n) => !lower(n).startsWith(q) && lower(n).includes(q));
68
+ return [...starts, ...inside].slice(0, limit);
69
+ }
70
+
71
+ /**
72
+ * The text with the `@query` at `m` replaced by `@name ` (one space after, unless one is already there), and where the
73
+ * caret goes. `names`: the fleet's — the board reads the longest instance name that fits, so a name that the text after the
74
+ * caret would run on into a longer one gets a space of its own.
75
+ */
76
+ export const insertMention = (text, m, caret, name, names = []) => insertAtTrigger(text, m, caret, "@", name, names);
77
+
78
+ // ── The timeline ──────────────────────────────────────────
79
+
80
+ const fullTime = (iso) => { const d = new Date(iso); return Number.isFinite(d.getTime()) ? d.toLocaleString() : ""; };
81
+
82
+ /**
83
+ * A run of the same history line from the same hand ("web-user changed acceptance" three times in a row) is one entry with a
84
+ * `count` and the latest time (pure: tests import it). Only history lines merge; a comment or a progress note never does.
85
+ * `describe(ev)` words a history event (the page's).
86
+ */
87
+ export function collapseEvents(entries, describe) {
88
+ const out = [];
89
+ for (const e of entries) {
90
+ const prev = out[out.length - 1];
91
+ if (prev && e.type === "event" && prev.type === "event" && prev.who === e.who && prev.by === e.by && describe(prev.ev) === describe(e.ev)) {
92
+ out[out.length - 1] = { ...prev, count: (prev.count || 1) + 1, at: e.at };
93
+ continue;
94
+ }
95
+ out.push(e);
96
+ }
97
+ return out;
98
+ }
99
+
100
+ /** The device's calendar day of a time ("2026-11-18"), or "" when it is none. */
101
+ export function dayKey(iso) {
102
+ const d = new Date(iso);
103
+ if (!Number.isFinite(d.getTime())) return "";
104
+ return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;
105
+ }
106
+
107
+ /** A day's name for the separator: Today, Yesterday, else "Wed, Nov 11" (with the year when it is not this one). */
108
+ export function dayLabel(iso, now = Date.now()) {
109
+ const key = dayKey(iso);
110
+ if (!key) return "";
111
+ if (key === dayKey(now)) return t("taskcard.today");
112
+ if (key === dayKey(new Date(now).setDate(new Date(now).getDate() - 1))) return t("taskcard.yesterday");
113
+ const d = new Date(iso);
114
+ const sameYear = d.getFullYear() === new Date(now).getFullYear();
115
+ return d.toLocaleDateString(lang() === "zh-TW" ? "zh-TW" : "en-US", { weekday: "short", month: "short", day: "numeric", ...(sameYear ? {} : { year: "numeric" }) });
116
+ }
117
+
118
+ /** A comment's text as the chat draws a message (Markdown, escaped first); the plain text when the renderer is not there. */
119
+ const commentHtml = (text) => {
120
+ const r = globalThis.AgendChatRender;
121
+ return r && typeof r.renderMarkdown === "function" ? { __html: r.renderMarkdown(text) } : null;
122
+ };
123
+
124
+ /**
125
+ * The stream's items (pure: tests import it): what people and agents SAY — a comment, a progress note — is a card each; the
126
+ * system's lines (history) between two cards are a run, of any length, and a run is folded into one "› N activities" row at first
127
+ *. `entries` are what the filter shows (a run of equal history lines already one line: `collapseEvents`); `group:
128
+ * false` (the History filter, which asks to see them) keeps every line on its own, open.
129
+ * Each item: { kind: "card", entry } | { kind: "run", key, entries, fold } — `fold`: the run starts closed.
130
+ */
131
+ export function streamOf(entries, group = true) {
132
+ const out = [];
133
+ for (const entry of entries) {
134
+ if (entry.type !== "event") { out.push({ kind: "card", entry }); continue; }
135
+ const last = out[out.length - 1];
136
+ if (last && last.kind === "run") last.entries.push(entry);
137
+ else out.push({ kind: "run", key: `run-${entry.key}`, entries: [entry] });
138
+ }
139
+ for (const item of out) if (item.kind === "run") item.fold = group;
140
+ return out;
141
+ }
142
+
143
+ const timeOf = (entry) => html`<time class="muted tl-time" dateTime=${entry.at} title=${fullTime(entry.at)}>${relTime(entry.at)}</time>`;
144
+
145
+ // ── A comment's text as the chat draws a message ─────────────
146
+
147
+ /** The chat's copy: the clipboard, else a hidden text area (a plain-http page has no clipboard API). */
148
+ async function copyText(text) {
149
+ try { if (navigator.clipboard && globalThis.isSecureContext) { await navigator.clipboard.writeText(text); return true; } } catch { /* fall back */ }
150
+ const ta = document.createElement("textarea"); ta.value = text; ta.setAttribute("readonly", ""); ta.className = "offscreen";
151
+ document.body.appendChild(ta); ta.select();
152
+ let ok = false; try { ok = document.execCommand("copy"); } catch { ok = false; }
153
+ ta.remove();
154
+ return ok;
155
+ }
156
+ const storedWrap = () => { try { return localStorage.getItem("agend_code_wrap") === "1"; } catch { return false; } };
157
+
158
+ /**
159
+ * Code blocks as the chat's thread draws them (chat-thread.js `decorateCode`, the same classes, so the same sheet styles them):
160
+ * a header with the language, Wrap and Copy, and a block of more than CODE_FOLD_LINES lines folded until opened. Built from nodes.
161
+ */
162
+ export function decorateCode(root) {
163
+ if (!root || typeof root.querySelectorAll !== "function") return;
164
+ const doc = root.ownerDocument;
165
+ const R = globalThis.AgendChatRender;
166
+ const limit = R && Number.isFinite(R.CODE_FOLD_LINES) ? R.CODE_FOLD_LINES : 30;
167
+ const lineCount = R && typeof R.lineCount === "function" ? R.lineCount : (c) => String(c).split("\n").length;
168
+ for (const pre of root.querySelectorAll("pre")) {
169
+ if (pre.parentNode && pre.parentNode.classList && pre.parentNode.classList.contains("codeblock")) continue;
170
+ const box = doc.createElement("div"); box.className = "codeblock";
171
+ const head = doc.createElement("div"); head.className = "cb-head";
172
+ const lang = doc.createElement("span"); lang.className = "cb-lang"; lang.textContent = pre.dataset.lang || "text";
173
+ const wrap = doc.createElement("button"); wrap.type = "button"; wrap.className = "chip-btn"; wrap.dataset.act = "toggleWrap"; wrap.textContent = t("chat.wrap");
174
+ const copy = doc.createElement("button"); copy.type = "button"; copy.className = "chip-btn"; copy.dataset.act = "copyCode"; copy.textContent = t("chat.copy");
175
+ head.append(lang, wrap, copy);
176
+ pre.replaceWith(box); box.append(head, pre);
177
+ const lines = lineCount(pre.textContent);
178
+ if (lines > limit) {
179
+ box.classList.add("folded");
180
+ const more = doc.createElement("button"); more.type = "button"; more.className = "cb-more"; more.dataset.act = "toggleFold";
181
+ more.dataset.lines = String(lines); more.textContent = t("chat.showAll", lines);
182
+ box.append(more);
183
+ }
184
+ }
185
+ }
186
+
187
+ /** A click on one of a decorated block's buttons (Copy, Wrap, Show all), as the chat's thread answers it. */
188
+ async function onCodeClick(e) {
189
+ const el = e.target && e.target.closest ? e.target.closest("[data-act]") : null;
190
+ if (!el) return;
191
+ const act = el.dataset.act;
192
+ if (act === "copyCode") {
193
+ const pre = el.closest(".codeblock") && el.closest(".codeblock").querySelector("pre");
194
+ if (!pre) return;
195
+ const ok = await copyText(pre.textContent);
196
+ const was = el.dataset.label || el.textContent; el.dataset.label = was;
197
+ el.textContent = t(ok ? "chat.copied" : "chat.copyFailed");
198
+ setTimeout(() => { el.textContent = was; }, 1200);
199
+ } else if (act === "toggleWrap") {
200
+ const stream = el.closest(".tl");
201
+ if (!stream) return;
202
+ const on = stream.classList.toggle("wrap-code");
203
+ try { localStorage.setItem("agend_code_wrap", on ? "1" : "0"); } catch { /* this page only */ }
204
+ } else if (act === "toggleFold") {
205
+ const box = el.closest(".codeblock");
206
+ if (!box) return;
207
+ const folded = box.classList.toggle("folded");
208
+ el.textContent = !folded ? t("chat.showLess") : t("chat.showAll", el.dataset.lines);
209
+ }
210
+ }
211
+
212
+ /** A comment's body: the chat's Markdown, its code blocks decorated as the chat's are. */
213
+ function MdBody({ body }) {
214
+ const ref = useRef(null);
215
+ useEffect(() => { decorateCode(ref.current); });
216
+ return html`<div class="tl-body md" ref=${ref} onClick=${onCodeClick} dangerouslySetInnerHTML=${body}></div>`;
217
+ }
218
+
219
+ /**
220
+ * One entry. A comment and a progress note are each a card (the same: a head with the avatar — an instance's with its state
221
+ * dot —, the name, an "Agent" badge, a tag for what it is, and the time; the text under the name); a history line is a thin row
222
+ * with an icon (a status change's is the status's), the sentence and the time, no box. `who`: the board's cards and the project's
223
+ * lead, for the avatar's info card.
224
+ */
225
+ function Entry({ entry, describe, who }) {
226
+ const time = timeOf(entry);
227
+ const agent = entry.by === "instance";
228
+ const mark = agent ? " by-agent" : "";
229
+ const kind = entry.by === "person" ? "person" : entry.by === "instance" ? "instance" : entry.by ? "none" : "";
230
+ const author = html`<${WhoCard} name=${entry.who} kind=${kind} presence=${agent} cards=${who && who.cards} lead=${who && who.lead} />`;
231
+ if (entry.type === "comment") {
232
+ const body = commentHtml(entry.text);
233
+ return html`<li class=${`tl-item tl-card tl-comment${entry.authorKind === "person" ? " person" : ""}${mark}`}>
234
+ <div class="tl-head">${author}${agent ? html`<${AgentTag} />` : null}
235
+ ${entry.kind === "reject" ? html`<span class="tb-tag st-blocked">${t("taskcard.rejectTag")}</span>` : null}
236
+ ${entry.kind === "approve" ? html`<span class="tb-tag st-done">${t("taskcard.approveTag")}</span>` : null}
237
+ ${time}</div>
238
+ ${body ? html`<${MdBody} body=${body} />` : html`<div class="tl-body">${entry.text}</div>`}</li>`;
239
+ }
240
+ if (entry.type === "log") {
241
+ return html`<li class=${`tl-item tl-card tl-log${mark}`}>
242
+ <div class="tl-head">${author}${agent ? html`<${AgentTag} />` : null}<span class="tb-tag tl-kind" title=${t("taskcard.logTip")}>${t("taskcard.show.log")}</span>${time}</div>
243
+ <div class="tl-body">${entry.text}</div></li>`;
244
+ }
245
+ const to = entry.ev && entry.ev.type === "moved" && entry.ev.data ? entry.ev.data.to : null;
246
+ return html`<li class="tl-item tl-line tl-event"><span class="tl-mark" aria-hidden="true"><span class=${`tb-dot${to ? ` st-${to}` : ""}`}></span></span>
247
+ <span class="tl-sentence"><span class="tl-who"><b>${entry.who}</b>${agent ? html` <${AgentTag} />` : null}</span> <span class="tl-text">${describe(entry.ev)}${entry.count > 1 ? html` <span class="tl-count" title=${t("taskcard.repeated", entry.count)}>×${entry.count}</span>` : null}</span></span>${time}</li>`;
248
+ }
249
+
250
+ /** A run of system lines: one "› N activities" button that opens and closes them (the History filter's runs are always open, no button). */
251
+ function Run({ run, describe, open, onToggle }) {
252
+ const n = run.entries.length;
253
+ return html`<li class="tl-run">
254
+ ${run.fold ? html`<button type="button" class="tl-more" aria-expanded=${open ? "true" : "false"} onClick=${onToggle}>
255
+ <span class="tl-mark" aria-hidden="true"><${Icon} name="chevron" size=${14} cls=${open ? "tb-chev open" : "tb-chev"} /></span><span>${n === 1 ? t("taskcard.activity1") : t("taskcard.activities", n)}</span></button>` : null}
256
+ ${open ? html`<ul class="tl-lines">${run.entries.map((e) => html`<${Entry} key=${e.key} entry=${e} describe=${describe} />`)}</ul>` : null}
257
+ </li>`;
258
+ }
259
+
260
+ /** The activity stream with its filter (all, comments, progress log, history). `describe(ev)` words a history event. */
261
+ export function Timeline({ detail, describe, cards = [], lead = null }) {
262
+ const [filter, setFilter] = useState("all");
263
+ const [toggled, setToggled] = useState({});
264
+ const all = timelineOf(detail);
265
+ // The number on a filter button is the number of lines the list shows for it: a run of equal history lines is one.
266
+ const count = (f) => collapseEvents(timelineShown(all, f), describe).length;
267
+ const shown = collapseEvents(timelineShown(all, filter), describe);
268
+ // A day change is a separator — only when the stream spans more than one day (one day needs no heading); a run never crosses it.
269
+ const days = new Set(shown.map((e) => dayKey(e.at)).filter(Boolean));
270
+ const parts = [];
271
+ let day = "";
272
+ for (const e of shown) {
273
+ const k = dayKey(e.at);
274
+ if (!parts.length || (days.size > 1 && k && k !== day)) parts.push({ day: days.size > 1 && k ? e.at : "", entries: [] });
275
+ if (k) day = k;
276
+ parts[parts.length - 1].entries.push(e);
277
+ }
278
+ const who = { cards, lead };
279
+ const rows = [];
280
+ for (const part of parts) {
281
+ if (part.day) rows.push(html`<li key=${`d${dayKey(part.day)}`} class="tl-day" role="presentation"><span>${dayLabel(part.day)}</span></li>`);
282
+ for (const item of streamOf(part.entries, filter === "all")) {
283
+ if (item.kind === "card") rows.push(html`<${Entry} key=${item.entry.key} entry=${item.entry} describe=${describe} who=${who} />`);
284
+ else {
285
+ const open = item.fold ? toggled[item.key] === true : true;
286
+ rows.push(html`<${Run} key=${item.key} run=${item} describe=${describe} open=${open} onToggle=${() => setToggled((cur) => ({ ...cur, [item.key]: !open }))} />`);
287
+ }
288
+ }
289
+ }
290
+ return html`<section class=${`tl${storedWrap() ? " wrap-code" : ""}`} aria-label=${t("taskcard.activity")}>
291
+ <div class="tl-bar"><h3>${t("taskcard.activity")}</h3>
292
+ <div class="tb-seg tl-filter" role="group" aria-label=${t("taskcard.activityShow")}>${TIMELINE_FILTERS.map((f) =>
293
+ html`<button key=${f} type="button" aria-pressed=${filter === f ? "true" : "false"} class=${`tb-seg-btn${filter === f ? " active" : ""}`} title=${f === "log" ? t("taskcard.logTip") : undefined} onClick=${() => setFilter(f)}>${t(`taskcard.show.${f}`)}${f === "all" ? "" : ` ${count(f)}`}</button>`)}</div></div>
294
+ ${shown.length ? html`<ol class="tl-list">${rows}</ol>`
295
+ : html`<p class="muted tl-none">${t(all.length ? "taskcard.nothingHere" : "taskcard.noActivity")}</p>`}
296
+ </section>`;
297
+ }
298
+
299
+ // ── The comment box ───────────────────────────────────────
300
+
301
+ /**
302
+ * The comment box: Ctrl+Enter or Send posts it; typing `@` offers the instance names (arrows and Enter or Tab choose, Esc
303
+ * closes the list, not the box). `names`: [{ name, off }] — an instance with the task board off is listed, not choosable; one the
304
+ * comment would reach (the card's `assignee`, an @name in the text) with the board off is named under the box, with where to turn it on.
305
+ * `onSend(text)` resolves "ok" for the text to clear.
306
+ */
307
+ export function Composer({ placeholder, names, assignee, onSend }) {
308
+ const [text, setText] = useState("");
309
+ const [caret, setCaret] = useState(0);
310
+ const [hidden, setHidden] = useState(false);
311
+ const [active, setActive] = useState(0);
312
+ const [sending, setSending] = useState(false);
313
+ const busy = useRef(false);
314
+ const box = useRef(null);
315
+ const pending = useRef(null); // where the caret goes once the inserted name is in the box
316
+ const m = hidden ? null : mentionAt(text, caret);
317
+ const found = m ? mentionMatches(names.map((n) => n.name), m.query).map((n) => names.find((x) => x.name === n)) : [];
318
+ const open = found.length > 0;
319
+ useEffect(() => { setActive(0); }, [m ? m.query : null, open]);
320
+ useEffect(() => {
321
+ if (pending.current === null || !box.current) return;
322
+ const c = pending.current;
323
+ pending.current = null;
324
+ try { box.current.focus(); box.current.setSelectionRange(c, c); } catch { /* no selection API */ }
325
+ });
326
+ const note = (e) => setCaret(e.target.selectionStart ?? e.target.value.length);
327
+ function choose(item) {
328
+ if (!item || item.off || !m) return;
329
+ const r = insertMention(text, m, caret, item.name, names.map((n) => n.name));
330
+ pending.current = r.caret;
331
+ setText(r.text);
332
+ setCaret(r.caret);
333
+ }
334
+ async function send() {
335
+ if (!text.trim() || busy.current) return;
336
+ busy.current = true;
337
+ setSending(true);
338
+ try { if ((await onSend(text.trim())) === "ok") { setText(""); setCaret(0); } } finally { setSending(false); busy.current = false; }
339
+ }
340
+ function onKey(e) {
341
+ if (open && (e.key === "ArrowDown" || e.key === "ArrowUp")) { e.preventDefault(); setActive((i) => (i + (e.key === "ArrowDown" ? 1 : found.length - 1)) % found.length); return; }
342
+ if (open && (e.key === "Enter" || e.key === "Tab") && !e.ctrlKey && !e.metaKey && !e.shiftKey && !e.isComposing) {
343
+ if (found[active] && !found[active].off) { e.preventDefault(); choose(found[active]); return; }
344
+ }
345
+ if (e.key === "Escape") { e.preventDefault(); e.stopPropagation(); if (open) setHidden(true); else e.currentTarget.blur(); return; }
346
+ if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) { e.preventDefault(); void send(); }
347
+ }
348
+ return html`<${BoardOffNote} names=${boardOffTargets(names, assignee, text)} textKey="tasks.boardOffCommentNote" />
349
+ <div class="tc-composer">
350
+ <div class="tc-compose-box">
351
+ ${open ? html`<ul class="tc-mentions" role="listbox" aria-label=${t("taskcard.mentionList")}>${found.map((n, i) => html`<li key=${n.name} role="option" aria-selected=${i === active ? "true" : "false"} class=${i === active ? "active" : ""}>
352
+ <button type="button" tabindex="-1" disabled=${!!n.off} title=${n.off ? t("tasks.boardOffHint") : undefined}
353
+ onPointerDown=${(e) => e.preventDefault()} onClick=${() => choose(n)}>
354
+ <span class="tc-mention-name">@${n.name}</span>${n.off ? html`<span class="muted">${t("taskcard.boardOffShort")}</span>` : null}</button></li>`)}</ul>` : null}
355
+ <textarea ref=${box} rows="3" value=${text} placeholder=${placeholder} aria-label=${t("taskcard.commentHint")}
356
+ aria-autocomplete="list" aria-expanded=${open ? "true" : "false"}
357
+ onInput=${(e) => { setText(e.target.value); setHidden(false); note(e); }} onClick=${note} onKeyUp=${(e) => { if (/^(Arrow|Home$|End$)/.test(String(e.key || ""))) note(e); }}
358
+ onKeyDown=${onKey}></textarea>
359
+ </div>
360
+ <button type="button" class="btn btn-primary btn-sm" disabled=${sending || !text.trim()} onClick=${send}>${t("taskcard.send")}</button>
361
+ </div>`;
362
+ }