@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
@@ -46,7 +46,7 @@ const COMPACT_PAGE_LIMIT_MS = 11 * 60_000;
46
46
  /** Build a store. `deps` (fetch, toast, announce, t, now) are injected so tests can drive every path. */
47
47
  export function createChatStore(deps) {
48
48
  const s = {
49
- msgs: {}, drafts: {}, replies: {}, pendingFiles: {}, sending: {}, outgoing: {}, instanceStatus: {}, waking: {},
49
+ resendOwner: null, resendBusy: new Set(), msgs: {}, drafts: {}, replies: {}, pendingFiles: {}, sending: {}, outgoing: {}, instanceStatus: {}, waking: {},
50
50
  prompts: {}, workingSince: {}, stopping: {}, cancelling: {}, scrollMemo: {}, historyRead: new Set(), gapped: new Set(), allHidden: new Set(), rbBusy: new Set(),
51
51
  pollMine: readPollMine(),
52
52
  // #1823 (#1828 review): the server's clock minus this device's. A poll's deadline is the server's; a page whose clock
@@ -159,7 +159,7 @@ export function createChatStore(deps) {
159
159
  for (const d of list) {
160
160
  if (!d || typeof d.instance !== "string") continue;
161
161
  const before = s.msgs[d.instance];
162
- s.msgs[d.instance] = R().applyDelivery(before, d.messageId, d.delivery);
162
+ s.msgs[d.instance] = R().applyDelivery(before, d.messageId, d.delivery, d);
163
163
  if (s.msgs[d.instance] !== before) touched.add(d.instance);
164
164
  }
165
165
  for (const i of touched) changed(i, "msgs");
@@ -211,6 +211,7 @@ export function createChatStore(deps) {
211
211
  if (!current()) return false;
212
212
  if (signal?.aborted) { s.historyRead.delete(name); return false; }
213
213
  if (!r || !Array.isArray(r.messages)) { s.historyRead.delete(name); return true; }
214
+ if (typeof r.resendOwner === "string") s.resendOwner = r.resendOwner;
214
215
  // Kept even when the person has moved on: the store is page-lived, and the answer belongs to `name`.
215
216
  // #2848: a guest's chat whose every message is hidden from it (between agents): its empty chat says so.
216
217
  if (r.allHidden === true) s.allHidden.add(name); else s.allHidden.delete(name);
@@ -263,7 +264,16 @@ export function createChatStore(deps) {
263
264
  /** `text`: #2675 — the typed answer, for an action the prompt shows a text box for. */
264
265
  async function answerPrompt(p, action, text) {
265
266
  if (p.busy || p.resolved) return;
266
- p.busy = true; changed(p.instance);
267
+ const confirmation = p.actions?.find(a => a.id === action)?.confirmation;
268
+ p.busy = true; p.confirming = !!confirmation; changed(p.instance);
269
+ if (confirmation) {
270
+ const yes = deps.confirm ? await deps.confirm({ ...confirmation, danger: true }) : false;
271
+ p.confirming = false;
272
+ if (!yes || p.resolved || s.prompts[p.nonce] !== p) {
273
+ p.busy = false; changed(p.instance); return;
274
+ }
275
+ }
276
+ changed(p.instance);
267
277
  let r;
268
278
  try { r = await api("POST", "/ui/prompt", { instance: p.instance, nonce: p.nonce, action, ...(text !== undefined ? { text } : {}) }); }
269
279
  catch (err) { r = { error: err && err.message ? err.message : t("chat.disconnected") }; }
@@ -285,16 +295,16 @@ export function createChatStore(deps) {
285
295
  return answerPrompt(p, action);
286
296
  }
287
297
  /** A claim taken elsewhere before this store existed (Needs you, before Chat booted): held here from now on. */
288
- function holdPrompt(item) {
298
+ function holdPrompt(item, confirming = false) {
289
299
  if (!item || typeof item.nonce !== "string") return;
290
300
  let p = s.prompts[item.nonce];
291
301
  if (!p) p = s.prompts[item.nonce] = { instance: item.instance, nonce: item.nonce, text: item.text || item.detail || "", actions: item.actions || [], resolved: false, busy: false };
292
- if (!p.resolved) { p.busy = true; changed(p.instance); }
302
+ if (!p.resolved) { p.busy = true; p.confirming = confirming; changed(p.instance); }
293
303
  }
294
304
  /** That claim's answer was refused: the prompt can be answered again (unless it was settled meanwhile). */
295
305
  function releasePrompt(nonce) {
296
306
  const p = s.prompts[nonce];
297
- if (p && !p.resolved) { p.busy = false; changed(p.instance); }
307
+ if (p && !p.resolved) { p.busy = false; p.confirming = false; changed(p.instance); }
298
308
  }
299
309
  const promptsFor = (instance) => Object.values(s.prompts).filter(p => p.instance === instance);
300
310
 
@@ -325,7 +335,8 @@ export function createChatStore(deps) {
325
335
  /** The thread as drawn: the server's messages, then this page's pending ones. */
326
336
  function threadRows(name) {
327
337
  const out = s.outgoing[name];
328
- return out && out.length ? (s.msgs[name] || []).concat(out) : (s.msgs[name] || []);
338
+ const rows = out && out.length ? (s.msgs[name] || []).concat(out) : (s.msgs[name] || []);
339
+ return s.resendBusy.size ? rows.map(m => s.resendBusy.has(msgKeyOf(m)) ? { ...m, resending: true } : m) : rows;
329
340
  }
330
341
  /** Upload one file, its progress told as it goes (XHR: fetch cannot report an upload's progress). */
331
342
  async function uploadFile(target, file, onProgress) {
@@ -445,6 +456,21 @@ export function createChatStore(deps) {
445
456
  changed(target, "msgs"); changed(target);
446
457
  deps.toast(e.outgoing.error, false);
447
458
  }
459
+ function canResend(target, message) {
460
+ return message?.instance === target && message.role === "user" && message.delivery === "failed"
461
+ && !!s.resendOwner && message.retry?.owner === s.resendOwner;
462
+ }
463
+ async function resendMessage(target, key) {
464
+ const message = (s.msgs[target] || []).find(m => msgKeyOf(m) === key);
465
+ if (!message || !canResend(target, message) || s.resendBusy.has(key)) return;
466
+ s.resendBusy.add(key); changed(target, "msgs");
467
+ try {
468
+ const r = await api("POST", "/ui/resend", { instance: target, boot: message.boot, id: message.id, attempt: message.retry.attempt });
469
+ if (r?.message) applyDeliveries([r.message]);
470
+ if (!r?.sent) deps.toast(t(r?.reason === "attachment_gone" ? "chat.resendAttachmentGone" : r?.reason === "reply_gone" ? "chat.resendReplyGone" : "chat.resendFailed"), false);
471
+ } catch { deps.toast(t("chat.resendFailed"), false); }
472
+ finally { s.resendBusy.delete(key); changed(target, "msgs"); }
473
+ }
448
474
  /** A failed send, sent again (the same bubble; files already uploaded are not uploaded again). */
449
475
  function retryOutgoing(target, clientId) {
450
476
  const e = (s.outgoing[target] || []).find((x) => x.clientId === clientId);
@@ -812,7 +838,7 @@ export function createChatStore(deps) {
812
838
  attach, applyStatus, applyActivity, ingest, applyDeliveries, openHistory, onGap,
813
839
  onPrompt, applyPrompts, resolvePrompt, answerPrompt, answerByNonce, holdPrompt, releasePrompt, promptsFor,
814
840
  applyReplyButtons, clickReplyButton,
815
- uploadFile, send, retryOutgoing, deleteOutgoing, putBackOutgoing, threadRows, addFiles, removeFile, attachPastedText, fileBackAsText, isPasted, setDraft,
841
+ uploadFile, send, retryOutgoing, resendMessage, canResend, deleteOutgoing, putBackOutgoing, threadRows, addFiles, removeFile, attachPastedText, fileBackAsText, isPasted, setDraft,
816
842
  startReply, clearReply, findQuoted, loadOlder, loadNewer, loadAround, backToLatest, pagingState, addToDraft, captureDraft, draftCurrent, clearCapturedDraft, acceptDraft,
817
843
  cancelReply, isUser, runCommand, dismissCommand, commandFree, reloadModelMenu,
818
844
  allHidden: (name) => s.allHidden.has(name),
@@ -0,0 +1,24 @@
1
+ // The words of a task card in the chat — the list that opens when `#` is typed, and a chip's status and tip.
2
+ // The status words are the task board's own (Fleet › Tasks: fleet-task-common.js), so a chip and a card say the same.
3
+ import { register } from "/assets/app-i18n.js";
4
+
5
+ register("taskref", {
6
+ en: {
7
+ list: "Task cards",
8
+ pickHint: "Task cards — press Enter or Tab to put one in",
9
+ none: "No task card matches",
10
+ sub: "sub task",
11
+ main: "main task",
12
+ "s.open": "To do", "s.claimed": "In progress", "s.blocked": "Blocked", "s.review": "To confirm", "s.done": "Done", "s.cancelled": "Cancelled",
13
+ open: "Open task card {0}",
14
+ },
15
+ "zh-TW": {
16
+ list: "任務卡片",
17
+ pickHint: "任務卡片 — 按 Enter 或 Tab 插入",
18
+ none: "找不到符合的任務卡片",
19
+ sub: "子任務",
20
+ main: "主任務",
21
+ "s.open": "待辦", "s.claimed": "進行中", "s.blocked": "卡住", "s.review": "待確認", "s.done": "完成", "s.cancelled": "取消",
22
+ open: "開啟任務卡片 {0}",
23
+ },
24
+ });
@@ -0,0 +1,129 @@
1
+ // Task cards in the web chat. The person types `#` in the chat box, picks a card, and the box holds its number
2
+ // (`#M-3`; M- is a main task, S- a sub task). A hand-typed `#M-3` / `#s3` counts the same; a bare `M-3` does not.
3
+ // Nothing about a reference is stored with the message — the text is the message — so an older chat, and an older AgEnD, read
4
+ // it as the text it is. This file is the page's side:
5
+ // - taskRefAt / insertTaskRef: the `#query` being typed at the caret, and the number put in its place (pure; the shared
6
+ // trigger-complete.js with "#");
7
+ // - createTaskRefIndex: what the page knows of the cards its messages name (GET /ui/tasks/refs, only the numbers asked,
8
+ // each once per page and again after the board changed), and the cards offered while `#` is typed. Until a card's answer
9
+ // arrives (or if the number is no card) the message shows the number as text; when it arrives the messages are drawn again.
10
+ // The chip itself is drawn by the shared renderer (shared/chat-render.js), which asks `taskRefs(code)`.
11
+ //
12
+ // The `@` completion of Fleet › Tasks' comment box (fleet-task-activity.js) is the same function, trigger-complete.js, with "@".
13
+
14
+ import { insertAtTrigger, triggerAt } from "./trigger-complete.js";
15
+
16
+ /** The same rule as the renderer's and the server's (src/chat-task-refs.ts): a test holds the three to one list of cases. */
17
+ const REF = /(?<![A-Za-z0-9_/&#@-])#([MmSs])-?(\d{1,9})(?![A-Za-z0-9_-]|\.\d)/g;
18
+ const MAX_CODES = 50;
19
+ /** A card number as the board writes it: "#s3" / "m 3" → "S-3"; null when it is not one. */
20
+ export function taskRefCode(raw) {
21
+ const m = /^\s*#?\s*([MmSs])\s*-?\s*(\d{1,9})\s*$/.exec(String(raw));
22
+ return m ? `${m[1].toUpperCase()}-${Number(m[2])}` : null;
23
+ }
24
+
25
+ /** The card numbers a text names, normalised, each once, in order. */
26
+ export function taskRefCodes(text, max = 10) {
27
+ const out = [];
28
+ if (typeof text !== "string" || !text) return out;
29
+ for (const m of text.matchAll(REF)) {
30
+ const code = taskRefCode(`${m[1]}-${m[2]}`);
31
+ if (code && !out.includes(code)) out.push(code);
32
+ if (out.length >= max) break;
33
+ }
34
+ return out;
35
+ }
36
+
37
+ // ── Typing a `#` ──────────────────────────────────────────
38
+
39
+ // The `#query` at the caret and the number put in its place are the shared trigger-complete.js's, with the trigger "#"
40
+ //: a "#" that starts the text or
41
+ // follows a space, a bracket or a full-width punctuation mark (not a word, a path or a URL: "page#top", "a/b#c") — the renderer's
42
+ // and the server's rule for what comes before a `#` — then what was typed after it up to the caret; a line that starts
43
+ // with "/" is a command, not a message.
44
+
45
+ /** The `#query` being typed at the caret, or null: { start: where the "#" is, query: the characters after it }. */
46
+ export const taskRefAt = (text, caret) => triggerAt(text, caret, "#");
47
+
48
+ /** The text with the `#query` at `at` replaced by `#M-3 ` (one space after, unless one is already there), and where the caret goes. */
49
+ export const insertTaskRef = (text, at, caret, code) => insertAtTrigger(text, at, caret, "#", code);
50
+
51
+ // ── What the page knows of the cards ──────────────────────
52
+
53
+ /**
54
+ * `fetchImpl(url)` → a Response (or null: no board for this page). Keeps, per card number, the view the server gave
55
+ * ({ code, title, status, assignee, kind }) — or null for a number that is no card (asked once; asked again only after the
56
+ * board changed, which `refresh()` is told of). The messages that name a number come in `ensure(msgs)`; only a person's own
57
+ * words count (`role: "user"`): an agent's "M-3" is its prose, not a reference.
58
+ */
59
+ export function createTaskRefIndex(fetchImpl) {
60
+ const known = new Map(); // code → view | null
61
+ const asked = new Set(); // codes asked and answered (or being asked)
62
+ // Each request is numbered as it starts, and each card number keeps the number of the request its view came from: an
63
+ // answer older than that view is dropped (refresh() can ask again while the first answer is still on its way, and the
64
+ // answers can arrive in either order).
65
+ const from = new Map(); // code → the request its view in `known` came from
66
+ let requests = 0;
67
+ const take = (code, view, seq) => {
68
+ if ((from.get(code) || 0) > seq) return false;
69
+ from.set(code, seq);
70
+ const changed = JSON.stringify(known.get(code) || null) !== JSON.stringify(view);
71
+ known.set(code, view);
72
+ return changed;
73
+ };
74
+ const listeners = new Set();
75
+ let inFlight = 0;
76
+ let suggestSeq = 0;
77
+
78
+ const read = (url) => Promise.resolve().then(() => fetchImpl(url)).then((r) => (r && r.ok ? r.json() : null), () => null);
79
+ const notify = () => { for (const f of [...listeners]) f(); };
80
+
81
+ function ask(codes) {
82
+ for (let i = 0; i < codes.length; i += MAX_CODES) {
83
+ const batch = codes.slice(i, i + MAX_CODES);
84
+ for (const c of batch) asked.add(c);
85
+ inFlight++;
86
+ const seq = ++requests;
87
+ read(`/ui/tasks/refs?codes=${encodeURIComponent(batch.join(","))}`).then((body) => {
88
+ if (!body || !Array.isArray(body.refs)) return; // not answered: the numbers stay text (and are asked again after a change)
89
+ let changed = false;
90
+ const got = new Map(body.refs.filter((v) => v && typeof v.code === "string").map((v) => [v.code, v]));
91
+ for (const c of batch) if (take(c, got.get(c) || null, seq)) changed = true;
92
+ if (changed) notify();
93
+ }).finally(() => { inFlight--; });
94
+ }
95
+ }
96
+
97
+ return {
98
+ /** The card a number is, or null (not asked yet, not a card, or the board cannot be read here). */
99
+ get: (code) => known.get(code) || null,
100
+ /** Ask for the numbers in these messages (a person's own words) that have not been asked about yet. */
101
+ ensure(msgs) {
102
+ const want = [];
103
+ for (const x of msgs || []) {
104
+ if (!x || x.role !== "user" || typeof x.text !== "string" || x.text.length < 3) continue;
105
+ for (const c of taskRefCodes(x.text)) if (!asked.has(c) && !want.includes(c)) want.push(c);
106
+ }
107
+ if (want.length) ask(want);
108
+ },
109
+ /** The board changed: the numbers asked about are asked again (the status and title in a chip follow the card). */
110
+ refresh() {
111
+ const again = [...asked];
112
+ asked.clear();
113
+ if (again.length) ask(again);
114
+ },
115
+ /** The cards to offer for what follows a `#` ("" → the latest changes). Resolves to [] when none, or when a newer call came first. */
116
+ async suggest(query) {
117
+ const mine = ++suggestSeq;
118
+ const seq = ++requests;
119
+ const body = await read(`/ui/tasks/refs?limit=8&q=${encodeURIComponent(query)}`);
120
+ if (mine !== suggestSeq || !body || !Array.isArray(body.refs)) return [];
121
+ // What the list shows is what the page now knows of those cards (a chip drawn later says the same), unless a newer answer came first.
122
+ for (const v of body.refs) if (v && typeof v.code === "string") take(v.code, v, seq);
123
+ return body.refs.filter((v) => v && typeof v.code === "string" && typeof v.title === "string");
124
+ },
125
+ subscribe(f) { listeners.add(f); return () => listeners.delete(f); },
126
+ /** Requests not answered yet (tests). */
127
+ pending: () => inFlight,
128
+ };
129
+ }
@@ -3,8 +3,8 @@ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
3
3
  import { register, t } from "/assets/app-i18n.js";
4
4
  import { confirmDialog } from "/assets/ui-confirm.js";
5
5
  register("claudeTokenFetch",{
6
- en:{get:"Get a token for me",paste:"Or paste a setup-token below",hint:"AgEnD opens a private sign-in session. Sign in on Claude’s website; the token goes straight into encrypted storage and is never displayed.",open:"Open sign-in page",code:"Authorization code",submit:"Submit authorization code",cancel:"Cancel connecting",waiting:"Waiting for Claude’s sign-in page…",working:"Waiting for you to finish signing in…",done:"Token saved. No model request was made.",failed:"The token could not be confirmed saved. Read the account status before retrying here or pasting a token below.",expired:"Sign-in timed out after 10 minutes. Retry here or paste a token below.",revoked:"Your verified session changed. Open this computer’s local dashboard, verify again, and retry.",cleanup:"The private session could not be confirmed closed. Ask the host operator to check it before reconnecting.",confirm:"Get a token and replace the saved credential?",restart:"After sign-in, agents using this account restart only when idle:",go:"Continue",pending:"Saved; these agents still need a restart:"},
7
- "zh-TW":{get:"幫我取得 Token",paste:"或在下方貼上 setup-token",hint:"AgEnD 會開啟私密登入工作階段。請在 Claude 網站登入;Token 會直接加密保存,不會顯示出來。",open:"開啟登入頁面",code:"授權碼",submit:"送出授權碼",cancel:"取消連接",waiting:"正在等候 Claude 登入頁面…",working:"正在等你完成登入…",done:"Token 已儲存,沒有發出模型請求。",failed:"無法確認 Token 是否已儲存。請先讀取帳號狀態,再在這裡重試或在下方貼上 Token。",expired:"登入已超過 10 分鐘。請重試,或在下方貼上 Token。",revoked:"已驗證的工作階段已變更。請在這台電腦開啟本機儀表板,重新驗證後再試。",cleanup:"無法確認私密工作階段已關閉。請先請主機操作者檢查,再重新連接。",confirm:"要取得 Token 並取代保存的憑證嗎?",restart:"登入後,使用這個帳號的 Agent 只會在空閒時重啟:",go:"繼續",pending:"已儲存,以下 Agent 仍需重啟:"}
6
+ en:{unsupported:"This Claude sign-in step is not supported by the helper. Run claude setup-token on your own computer and paste the token below.",get:"Get a token for me",paste:"Or paste a setup-token below",hint:"AgEnD opens a private sign-in session. Sign in on Claude’s website; the token goes straight into encrypted storage and is never displayed.",open:"Open sign-in page",code:"Authorization code",submit:"Submit authorization code",cancel:"Cancel connecting",waiting:"Waiting for Claude’s sign-in page…",working:"Waiting for you to finish signing in…",done:"Token saved. No model request was made.",failed:"The token could not be confirmed saved. Read the account status before retrying here or pasting a token below.",expired:"Sign-in timed out after 10 minutes. Retry here or paste a token below.",revoked:"Your verified session changed. Open this computer’s local dashboard, verify again, and retry.",cleanup:"The private session could not be confirmed closed. Ask the host operator to check it before reconnecting.",confirm:"Get a token and replace the saved credential?",restart:"After sign-in, agents using this account restart only when idle:",go:"Continue",pending:"Saved; these agents still need a restart:"},
7
+ "zh-TW":{unsupported:"這個 Claude 登入步驟尚不支援。請在自己的電腦執行 claude setup-token,再把 Token 貼到下方。",get:"幫我取得 Token",paste:"或在下方貼上 setup-token",hint:"AgEnD 會開啟私密登入工作階段。請在 Claude 網站登入;Token 會直接加密保存,不會顯示出來。",open:"開啟登入頁面",code:"授權碼",submit:"送出授權碼",cancel:"取消連接",waiting:"正在等候 Claude 登入頁面…",working:"正在等你完成登入…",done:"Token 已儲存,沒有發出模型請求。",failed:"無法確認 Token 是否已儲存。請先讀取帳號狀態,再在這裡重試或在下方貼上 Token。",expired:"登入已超過 10 分鐘。請重試,或在下方貼上 Token。",revoked:"已驗證的工作階段已變更。請在這台電腦開啟本機儀表板,重新驗證後再試。",cleanup:"無法確認私密工作階段已關閉。請先請主機操作者檢查,再重新連接。",confirm:"要取得 Token 並取代保存的憑證嗎?",restart:"登入後,使用這個帳號的 Agent 只會在空閒時重啟:",go:"繼續",pending:"已儲存,以下 Agent 仍需重啟:"}
8
8
  });
9
9
  const text=k=>t("claudeTokenFetch."+k);
10
10
  async function request(body){try{const r=await fetch("/ui/claude-credentials/setup-token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(body)});const value=await r.json();return r.ok?value:{error:value.error||"credential_unavailable"};}catch{return {error:"credential_unavailable"};}}
@@ -26,7 +26,7 @@ export function ClaudeTokenFetch({profile,read,onBusy,onSaved}){
26
26
  }finally{if(alive.current)setStarting(false);}};
27
27
  const cancel=async()=>{const id=owned.current||current.current?.login?.id;if(!id)return;owned.current=null;receive(await request({operation:"cancel",id}));};
28
28
  const submit=async()=>{const value=input.current?.value||"";if(!value||!current.current)return;const login=current.current.login;const result=await request({operation:"input",id:login.id,revision:login.revision,action:{kind:"code",value}});if(input.current)input.current.value="";receive(result);};
29
- const login=run?.login,reason=login?.reason,fail=reason==="expired"?"expired":reason==="revoked"?"revoked":reason==="cleanup_failed"?"cleanup":"failed";
29
+ const login=run?.login,reason=login?.reason,fail=reason==="unsupported_prompt"?"unsupported":reason==="expired"?"expired":reason==="revoked"?"revoked":reason==="cleanup_failed"?"cleanup":"failed";
30
30
  return html`<section class="field credential-token-fetch"><button type="button" class="btn" disabled=${starting||ongoing||!read?.ok||!read.local} onClick=${start}>${text("get")}</button><p class="note">${text("hint")}</p>
31
31
  ${ongoing?html`<p role="status">${text(login.url?"working":"waiting")}</p>${login.url?html`<a class="btn btn-primary" data-trust="navigation" href=${login.url} target="_blank" rel="noopener noreferrer">${text("open")}</a>`:null}
32
32
  ${login.phase==="code"&&login.canAct?html`<div class="field"><label for="claudeSetupTokenCode">${text("code")}</label><input ref=${input} id="claudeSetupTokenCode" type="password" autocomplete="off" spellcheck=${false} /><button type="button" class="btn" onClick=${submit}>${text("submit")}</button></div>`:null}
@@ -3,7 +3,7 @@
3
3
  * agent page's Permissions, Fleet → Authorizations, the chat badges, Needs you and the restricted-mode suggestion. en and
4
4
  * zh-TW (admin is 管理員). A module of its own (namespace contactAuth); imports only app-i18n.
5
5
  */
6
- import { register, t } from "/assets/app-i18n.js";
6
+ import { register, t, lang } from "/assets/app-i18n.js";
7
7
 
8
8
  register("contactAuth", {
9
9
  en: {
@@ -66,7 +66,7 @@ register("contactAuth", {
66
66
  // Allowed contacts (grants)
67
67
  grantsTitle: "Allowed contacts", grantsNone: "No allowed contacts. Each request asks the approver.",
68
68
  grantsNote: "For a known origin, every originating person needs a matching allowed contact. Unknown origins cannot match these grants and need separate approval.",
69
- grantRow: "{0} → {1}", grantVerbs: "For: {0}", grantExpires: "Until {0}", grantUses: "{0} uses left", grantUnlimited: "Until it expires",
69
+ grantRow: "From {0} to {1}", grantVerbs: "For: {0}", grantExpires: "Until {0}", grantUses: "{0} uses left", grantUnlimited: "Until it expires",
70
70
  grantRemove: "Remove", grantRemoveConfirm: "Remove this allowed contact? Later requests will ask again.",
71
71
  originTitle: "Retained origin", originClear: "Clear retained origin", originCleared: "Retained origin cleared.",
72
72
  originKind_none: "No retained origin", originKind_human: "One known person", originKind_mixed: "Multiple known people", originKind_unknown: "Unknown origin",
@@ -88,6 +88,19 @@ register("contactAuth", {
88
88
  // M-3385: under the reason — what an approval leaves as it is, and the one way this agent stops needing approval.
89
89
  resetNote: "Approving forwards only this request and leaves the receiving agent's origin unchanged. For this agent's contacts to stop needing approval, a managing administrator can clear its retained origin in its Permissions; it never resets on its own.",
90
90
  created: "Asked {0}", expires: "Expires {0}", decided: "{0} by {1}",
91
+
92
+ grantFutureExpiry: "Choose an expiry in the future.", grantValidUses: "Set a use limit from 1 to 10,000, or leave it empty for unlimited uses.",
93
+ grantSaved: "Request approved and contact rules saved.", grantView: "View rules in Permissions",
94
+ cancel: "Cancel", saving: "Saving…", grantNoMatches: "No matching people.",
95
+ allowPersonTitle: "Allow this person to contact this agent", allowPeopleTitle: "Set allowed contacts for these people", operator: "Administrator",
96
+ allowPerson: "Allow this person to contact this agent…", allowPeople: "Set allowed contacts for these people…", allowAndApprove: "Approve once and save rules",
97
+ grantEdit: "Adjust allowed contact", grantSave: "Save rule", grantSaveFailed: "The rule was not saved. Review the current permissions and try again.",
98
+ grantPeople: "People", grantRoute: "From {0} to {1}", grantType: "Request type: {0}", grantTypes: "Request types",
99
+ grantOneDay: "1 day", grantDuration: "Duration", grantDays: "{0} days", grantCustom: "Custom expiry", grantZone: "Time zone: {0}", grantAdvanced: "Advanced: limit uses",
100
+ grantAllOrigins: "This conversation retains several people's input. Select each person explicitly. Future requests skip approval only when every retained person has a matching rule.",
101
+ grantUnknown: "The complete origin is unknown. You can approve once, but cannot create an allowed contact from this request.",
102
+ grantBoundary: "Until expiry, requests matching these people, this source, this agent and request type will be forwarded without asking again. This does not limit the receiving agent's actions. Revoke the rule in its Permissions.",
103
+ grantEditScope: "This changes the displayed rule only. Previously admitted or delivered requests are not recalled.", grantFilter: "Filter by person", grantAdjust: "Adjust / extend", grantCreated: "Added by {0} · {1}",
91
104
  approveOnce: "Approve once", decline: "Decline", alsoAllowUntil: "Until", alsoAllowUses: "Uses (empty: no limit)",
92
105
  // M-3385: what the card's parts do, said where they are.
93
106
  // M-3385 (the user, 11-20): short visible words; the detail in an ⓘ (ui-style-guide rule 14).
@@ -174,7 +187,7 @@ register("contactAuth", {
174
187
  offByDefault: "Shell、房間暫存資料夾以外的檔案與擁有者的憑證都維持關閉。",
175
188
  grantsTitle: "常用轉交", grantsNone: "沒有常用轉交,每個請求都會詢問核准人。",
176
189
  grantsNote: "來源已知時,每位最初提問者都須有相符的允許聯絡授權。來源不明無法配對這些授權,須另外核准。",
177
- grantRow: "{0} → {1}", grantVerbs: "用途:{0}", grantExpires: "到 {0} 為止", grantUses: "剩下 {0} 次", grantUnlimited: "到期前不限次數",
190
+ grantRow: "從 {0} 給 {1}", grantVerbs: "用途:{0}", grantExpires: "到 {0} 為止", grantUses: "剩下 {0} 次", grantUnlimited: "到期前不限次數",
178
191
  grantRemove: "移除", grantRemoveConfirm: "要移除這個常用轉交嗎?之後的請求會再次詢問。",
179
192
  originTitle: "保留的來源", originClear: "清除保留的來源", originCleared: "已清除保留的來源。",
180
193
  originKind_none: "沒有保留的來源", originKind_human: "一位已知提問者", originKind_mixed: "多位已知提問者", originKind_unknown: "來源不明",
@@ -193,6 +206,19 @@ register("contactAuth", {
193
206
  "reason_unknown-origin": "這個 Agent 保留的歷史來源不明,因此這次聯絡需要核准。",
194
207
  resetNote: "核准只會轉交這一筆,接收 Agent 的來源維持原狀。若要讓這個 Agent 之後的聯絡不再需要核准,具管理權限的管理員可以在它的「權限」頁清除保留的來源;來源不會自動重設。",
195
208
  created: "{0} 提出", expires: "{0} 到期", decided: "{1} 於 {0} 處理",
209
+
210
+ grantFutureExpiry: "請選擇未來的到期時間。", grantValidUses: "請設定 1 至 10,000 次,或留空表示不限次數。",
211
+ grantSaved: "已核准轉交並儲存常用轉交規則。", grantView: "在「權限」查看規則",
212
+ cancel: "取消", saving: "儲存中…", grantNoMatches: "沒有符合的人員。",
213
+ allowPersonTitle: "允許這個人聯絡此 Agent", allowPeopleTitle: "設定這些人的常用轉交", operator: "管理員",
214
+ allowPerson: "允許這個人聯絡此 Agent…", allowPeople: "設定這些人的常用轉交…", allowAndApprove: "核准這一次並儲存規則",
215
+ grantEdit: "調整常用轉交", grantSave: "儲存規則", grantSaveFailed: "規則未儲存,請確認目前的權限後再試。",
216
+ grantPeople: "人員", grantRoute: "從 {0} 給 {1}", grantType: "請求類型:{0}", grantTypes: "請求類型",
217
+ grantOneDay: "1 天", grantDuration: "期限", grantDays: "{0} 天", grantCustom: "自訂到期時間", grantZone: "時區:{0}", grantAdvanced: "進階:限制次數",
218
+ grantAllOrigins: "這個對話保留了多人的輸入,請逐人明確選擇。所有保留來源都有符合規則時,之後才會直接轉交。",
219
+ grantUnknown: "無法確認完整來源,只能核准這一次,不會從這筆申請建立常用轉交。",
220
+ grantBoundary: "到期前,符合這些人員、來源、目標 Agent 與請求類型的訊息會直接轉交,不再逐筆核准。這不限制接收 Agent 採取的操作,可到它的「權限」撤銷規則。",
221
+ grantEditScope: "只變更目前這筆規則,已准入或已送出的請求不會收回。", grantFilter: "依人員篩選", grantAdjust: "調整/延長", grantCreated: "{0} 於 {1} 建立",
196
222
  approveOnce: "核准這一次", decline: "拒絕", alsoAllowUntil: "到期時間", alsoAllowUses: "次數(留空表示不限)",
197
223
  alsoAllow: "之後同樣的請求也直接轉交",
198
224
  alsoAllowMore: "之後 {0} 從 {2} 發給 {3} 的{1}請求會直接轉交,不必再核准。這會在 {3} 的權限頁新增一筆常用轉交,到你設定的到期時間或次數用完為止;隨時可以在那裡移除。",
@@ -224,3 +250,7 @@ register("contactAuth", {
224
250
  });
225
251
 
226
252
  export const ca = (k, ...a) => t(`contactAuth.${k}`, ...a);
253
+
254
+ export const contactPlatformLabel = platform => ({ discord: "Discord", telegram: "Telegram" }[platform] || platform);
255
+ export const contactPersonLabel = person => person?.platform === "host" && person?.userId === "operator" ? ca("operator") : person?.label || person?.userId || "";
256
+ export const contactWhen = value => { const d = new Date(value); return Number.isFinite(d.getTime()) ? d.toLocaleString(lang() === "zh-TW" ? "zh-TW" : "en", { dateStyle: "long", timeStyle: "short" }) : ""; };
@@ -8,11 +8,13 @@
8
8
  // - ?ticket=<id> opens that request at the top (from a chat badge, Needs you or a Permissions history row).
9
9
  // It reads again on the stream's contact-auth frame and when the page is shown again (no timer).
10
10
  import { html, useEffect, useState } from "/assets/app-html.js";
11
- import { register } from "/assets/app-i18n.js";
11
+ import { register, lang } from "/assets/app-i18n.js";
12
12
  import { appStore, useStore } from "/assets/app-store.js";
13
13
  import { toast } from "/assets/ui-toast.js";
14
14
  import { Skeleton, ErrorState, Empty } from "/assets/ui-states.js";
15
+ import { detailsPath } from "/assets/app-route.js";
15
16
  import { labelOf } from "/assets/instance-nav.js";
17
+ import { ContactGrantEditor } from "./contact-grant-editor.js";
16
18
  import { InfoTip } from "/assets/info-tip.js";
17
19
  import { ca } from "./contact-auth-strings.js";
18
20
  import { decideTicket, getTicket, listTickets, personKey, shortTicketId } from "./contact-auth-client.js";
@@ -26,39 +28,33 @@ export const REASONS = new Set(["earlier-non-admin", "unknown-origin"]);
26
28
  const TONE = { pending: "warn", approved: "ok", delivered: "ok", declined: "bad", expired: "muted", unknown: "bad" };
27
29
  const stateOf = (s) => (Object.prototype.hasOwnProperty.call(TONE, s) ? s : "unknown");
28
30
  const label = (p) => (p && (p.label || p.userId)) || "";
29
- /** datetime-local's value for a time `days` from now (the browser's own zone). */
30
- /** M-3385: how long a request waits for a decision (its expiry from when it was asked), in whole minutes; 0 if unknown. */
31
+ /** How long an application waits for a decision, from its server timestamps. */
31
32
  const waitMinutes = (tk) => { const ms = Date.parse(tk.expiresAt) - Date.parse(tk.createdAt); return Number.isFinite(ms) && ms > 0 ? Math.round(ms / 60_000) : 0; };
32
- const localIn = (days) => { const d = new Date(Date.now() + days * 864e5); d.setSeconds(0, 0); return new Date(d.getTime() - d.getTimezoneOffset() * 6e4).toISOString().slice(0, 16); };
33
33
 
34
34
  /** One request: what it is, who asked, and — for its approver, while it waits — the decision. */
35
35
  export function TicketCard({ ticket, onChange, onPerson, focus = false }) {
36
36
  const [busy, setBusy] = useState(false);
37
- const [allow, setAllow] = useState(false);
38
- const [until, setUntil] = useState(() => localIn(7));
39
- const [uses, setUses] = useState("");
37
+ const [grantOpen, setGrantOpen] = useState(false);
40
38
  const { instances } = useStore(appStore);
41
39
  const agentLabel = (name) => labelOf((instances || []).find((i) => i.name === name) || { name });
42
40
  const personLabel = label;
43
41
  const tk = ticket, st = stateOf(tk.state);
44
- const decide = async (decision) => {
45
- if (busy) return;
46
- const n = uses.trim() === "" ? null : Math.max(1, Math.floor(Number(uses)));
47
- const grant = decision === "approve-once" && allow && until && tk.origin?.kind === "human" && (tk.origin?.people || []).length === 1 ? { expiresAt: new Date(until).toISOString(), remainingUses: Number.isFinite(n) ? n : null } : undefined;
42
+ const decide = async (decision, grant) => {
43
+ if (busy) return false;
48
44
  setBusy(true);
49
45
  const r = await decideTicket(tk.id, { revision: tk.revision, decision, ...(grant ? { grant } : {}) });
50
46
  setBusy(false);
51
- if (r.ok) { onChange?.(r.data); return; }
47
+ if (r.ok) { if (grant) toast(ca("grantSaved"), true); onChange?.(r.data); return true; }
52
48
  if (r.code === "already-decided" || r.code === "expired" || r.code === "conflict") {
53
49
  toast(ca("alreadyDecided"), false);
54
50
  const again = await getTicket(tk.id);
55
51
  if (again.ok) onChange?.(again.data);
56
- return;
52
+ return false;
57
53
  }
58
54
  toast(ca(r.code === "forbidden" ? "forbidden" : r.code === "unavailable" ? "unavailable" : "decideFailed"), false);
59
55
  };
60
56
  const people = tk.origin?.people || [];
61
- const grantable = tk.origin?.kind === "human" && people.length === 1;
57
+ const grantable = ["human", "mixed"].includes(tk.origin?.kind) && people.length > 0 && people.length <= 16;
62
58
  // M-3385: when it was decided; or, while it waits, how long it waits and that nothing is forwarded after that.
63
59
  const endsText = tk.decidedAt ? ca("decided", when(tk.decidedAt), personLabel(tk.decidedBy))
64
60
  : st === "pending" && waitMinutes(tk) ? ca("expiresPending", when(tk.expiresAt), waitMinutes(tk)) : ca("expires", when(tk.expiresAt));
@@ -78,21 +74,18 @@ export function TicketCard({ ticket, onChange, onPerson, focus = false }) {
78
74
  <div class="contact-ticket-times"><span class="contact-time-item" title=${ca("created", when(tk.createdAt))}>${ca("created", when(tk.createdAt))}</span>
79
75
  <span class=${`contact-time-item${!tk.decidedAt && st === "pending" && waitMinutes(tk) ? " contact-time-wait" : ""}`} title=${endsText}>${endsText}</span></div>
80
76
  ${st === "delivered" ? html`<p class="note">${ca("deliveryNote")}</p>` : null}
81
- ${REASONS.has(tk.reason) ? html`<p class="note contact-reason" data-reason=${tk.reason}>${ca(`reason_${tk.reason}`)}${st === "pending" ? html` ${ca("resetNote")}` : null}</p>` : null}
77
+ ${REASONS.has(tk.reason) ? html`<p class="note contact-reason" data-reason=${tk.reason}>${ca(`reason_${tk.reason}`)}${st === "pending" ? html`${lang() === "zh-TW" ? "" : " "}${ca("resetNote")}` : null}</p>` : null}
82
78
  </div>
79
+ ${tk.grantIds?.length ? html`<p><a class="st-link" href=${`${detailsPath(tk.target)}?cat=permissions`}>${ca("grantView")}</a></p>` : null}
83
80
  ${tk.canDecide && st === "pending" ? html`<div class="contact-decide">
84
81
  ${/* M-3385 (the user, 11-20: easy to read but too long): one short visible line; what an approval means onward is in its ⓘ. */ ""}
85
82
  <p class="note contact-decided-note">${ca("decidedNote")} <${InfoTip} text=${ca("decidedNoteMore")} label=${ca("decidedNoteAbout")} /></p>
86
- ${allow && grantable ? html`<div class="field-row contact-allow">
87
- <label class="field"><span>${ca("alsoAllowUntil")}</span><input class="input" type="datetime-local" value=${until} disabled=${busy} onInput=${(e) => setUntil(e.currentTarget.value)} /></label>
88
- <label class="field"><span>${ca("alsoAllowUses")}</span><input class="input" type="number" min="1" inputmode="numeric" value=${uses} disabled=${busy} onInput=${(e) => setUses(e.currentTarget.value)} /></label></div>` : null}
89
83
  <div class="contact-decide-controls"><button type="button" class="btn btn-sm btn-primary" disabled=${busy} onClick=${() => void decide("approve-once")}>${ca("approveOnce")}</button>
90
- <button type="button" class="btn btn-sm danger" disabled=${busy} onClick=${() => void decide("decline")}>${ca("decline")}</button>
91
- ${/* M-3385: a standing grant is one person's — offered only for a request from exactly one person (the server refuses
92
- any other: invalid-grant-origin), and said in full: who, what kind, from where to where; where it lives under the row. */ ""}
93
- ${grantable ? html`<span class="contact-toggle-pair"><label class="check contact-toggle"><input type="checkbox" checked=${allow} disabled=${busy} onChange=${(e) => setAllow(e.currentTarget.checked)} />
94
- <span>${ca("alsoAllow")}</span></label><${InfoTip} cls="contact-allow-info" text=${ca("alsoAllowMore", personLabel(people[0]), ca(`verb_${tk.verb}`), agentLabel(tk.source), agentLabel(tk.target))}
95
- label=${ca("alsoAllowAbout")} /></span>` : null}</div>
84
+ <button type="button" class="btn btn-sm" disabled=${busy || !grantable} onClick=${() => setGrantOpen(true)}>${ca(people.length > 1 ? "allowPeople" : "allowPerson")}</button>
85
+ <button type="button" class="btn btn-sm danger" disabled=${busy} onClick=${() => void decide("decline")}>${ca("decline")}</button></div>
86
+ ${!grantable ? html`<p class="note">${ca("grantUnknown")}</p>` : null}
87
+ ${grantOpen && grantable ? html`<${ContactGrantEditor} key=${`${tk.id}:${tk.revision}`} people=${people} source=${agentLabel(tk.source)} target=${agentLabel(tk.target)} verb=${tk.verb}
88
+ onClose=${() => setGrantOpen(false)} onSave=${choice => decide("approve-once", { expiresAt: choice.expiresAt, remainingUses: choice.remainingUses, personKeys: choice.personKeys })} />` : null}
96
89
  </div>` : null}
97
90
  </article>`;
98
91
  }
@@ -0,0 +1,50 @@
1
+ // Shared, explicit contact-only scope editor. Identity/room/target are frozen from the ticket or existing row.
2
+ import { html, useState } from "/assets/app-html.js";
3
+ import { Dialog } from "/assets/ui-dialog.js";
4
+ import { ca, contactPlatformLabel, contactPersonLabel, contactWhen } from "./contact-auth-strings.js";
5
+ import { personKey } from "./contact-auth-client.js";
6
+ export const CONTACT_VERBS = ["send_to_instance", "delegate_task", "request_information", "broadcast", "report_result"];
7
+ const localTime = date => new Date(date.getTime() - date.getTimezoneOffset() * 60000).toISOString().slice(0, 16);
8
+ const afterDays = days => localTime(new Date(Date.now() + days * 86400000));
9
+ export function ContactGrantEditor({ people, source, target, verb, grant = null, onSave, onClose }) {
10
+ const [selected, setSelected] = useState(() => grant ? [personKey(grant.person)] : people.length === 1 ? [personKey(people[0])] : []);
11
+ const [preset, setPreset] = useState(grant ? "custom" : "7");
12
+ const [until, setUntil] = useState(() => grant ? localTime(new Date(grant.expiresAt)) : afterDays(7));
13
+ const [uses, setUses] = useState(grant?.remainingUses == null ? "" : String(grant.remainingUses));
14
+ const [verbs, setVerbs] = useState(() => grant ? [...grant.verbs] : [verb]);
15
+ const [busy, setBusy] = useState(false), [error, setError] = useState("");
16
+ const validUntil = Number.isFinite(new Date(until).getTime()) && new Date(until).getTime() > Date.now();
17
+ const validUses = uses === "" || /^\d+$/.test(uses) && Number(uses) >= 1 && Number(uses) <= 10000;
18
+ const valid = selected.length > 0 && verbs.length > 0 && validUntil && validUses;
19
+ const save = async () => {
20
+ if (busy || !valid) return;
21
+ setBusy(true); setError("");
22
+ try {
23
+ const ok = await onSave({ personKeys: selected, expiresAt: new Date(until).toISOString(), remainingUses: uses === "" ? null : Number(uses), verbs });
24
+ if (ok) onClose(); else setError(ca("grantSaveFailed"));
25
+ } catch { setError(ca("grantSaveFailed")); }
26
+ finally { setBusy(false); }
27
+ };
28
+ const toggle = (values, value, checked) => checked ? [...values, value] : values.filter(v => v !== value);
29
+ return html`<${Dialog} title=${ca(grant ? "grantEdit" : people.length === 1 ? "allowPersonTitle" : "allowPeopleTitle")} busy=${busy} cls="contact-grant-dialog" onClose=${onClose}
30
+ actions=${html`<button type="button" class="btn" disabled=${busy} onClick=${onClose}>${ca("cancel")}</button><button type="button" class="btn btn-primary" disabled=${busy || !valid} onClick=${save}>${ca(busy ? "saving" : grant ? "grantSave" : "allowAndApprove")}</button>`}>
31
+ <p>${ca("grantRoute", source, target)}</p>
32
+ <section class="s-group" aria-label=${ca("grantPeople")}><h3>${ca("grantPeople")}</h3><div class="s-checks">
33
+ ${people.map(person => html`<label class="check"><input type="checkbox" checked=${selected.includes(personKey(person))} disabled=${busy || !!grant}
34
+ onChange=${e => setSelected(toggle(selected, personKey(person), e.currentTarget.checked))} /><span>${contactPersonLabel(person)} · ${contactPlatformLabel(person.platform)}</span></label>`)}
35
+ </div></section>
36
+ ${!grant && people.length > 1 ? html`<p class="note">${ca("grantAllOrigins")}</p>` : null}
37
+ ${grant ? html`<section class="s-group" aria-label=${ca("grantTypes")}><h3>${ca("grantTypes")}</h3><div class="s-checks">${CONTACT_VERBS.map(v => html`<label class="check"><input type="checkbox" checked=${verbs.includes(v)} disabled=${busy}
38
+ onChange=${e => setVerbs(toggle(verbs, v, e.currentTarget.checked))} /><span>${ca(`verb_${v}`)}</span></label>`)}</div></section>` : html`<p>${ca("grantType", ca(`verb_${verb}`))}</p>`}
39
+ <div class="grid2"><label class="field"><span>${ca("grantDuration")}</span><select class="input" value=${preset} disabled=${busy} onChange=${e => { const value = e.currentTarget.value; setPreset(value); if (value !== "custom") setUntil(afterDays(Number(value))); }}>
40
+ ${[1, 7, 30].map(n => html`<option value=${String(n)}>${n === 1 ? ca("grantOneDay") : ca("grantDays", n)}</option>`)}<option value="custom">${ca("grantCustom")}</option></select></label>
41
+ <label class="field"><span>${ca("alsoAllowUntil")}</span><input class="input" type="datetime-local" value=${until} disabled=${busy} onInput=${e => { setPreset("custom"); setUntil(e.currentTarget.value); }} /></label></div>
42
+ ${validUntil ? html`<p class="note contact-grant-expiry">${ca("grantExpires", contactWhen(until))}</p>` : null}
43
+ <p class="note">${ca("grantZone", Intl.DateTimeFormat().resolvedOptions().timeZone)}</p>
44
+ <details open=${grant?.remainingUses === 0}><summary>${ca("grantAdvanced")}</summary><label class="field"><span>${ca("alsoAllowUses")}</span><input class="input" type="number" min="1" max="10000" inputmode="numeric" value=${uses} disabled=${busy} onInput=${e => setUses(e.currentTarget.value)} /></label></details>
45
+ ${!validUntil ? html`<p class="err">${ca("grantFutureExpiry")}</p>` : !validUses ? html`<p class="err">${ca("grantValidUses")}</p>` : null}
46
+ <p class="note">${ca("grantBoundary")}</p>
47
+ ${grant ? html`<p class="note">${ca("grantEditScope")}</p>` : null}
48
+ ${error ? html`<p class="err" role="alert">${error}</p>` : null}
49
+ </${Dialog}>`;
50
+ }
@@ -8,13 +8,15 @@
8
8
  // page's settings Save. The server decides who may see or change anything (canManage / canSetMode); nothing here grants.
9
9
  // It reads again on the stream's contact-auth frame for this agent (a newer revision) and when the page is shown again.
10
10
  import { html, useEffect, useRef, useState } from "/assets/app-html.js";
11
- import { appStore } from "/assets/app-store.js";
11
+ import { appStore, useStore } from "/assets/app-store.js";
12
12
  import { Icon } from "/assets/ui-icons.js";
13
13
  import { toast } from "/assets/ui-toast.js";
14
14
  import { Skeleton, ErrorState } from "/assets/ui-states.js";
15
15
  import { confirmDialog } from "/assets/ui-confirm.js";
16
- import { ca } from "./contact-auth-strings.js";
16
+ import { ca, contactPersonLabel, contactWhen } from "./contact-auth-strings.js";
17
17
  import { getPermissions, putPermissions, clearOrigin, shortTicketId } from "./contact-auth-client.js";
18
+ import { labelOf } from "/assets/instance-nav.js";
19
+ import { ContactGrantEditor } from "./contact-grant-editor.js";
18
20
  import { REASONS } from "./contact-authorizations.js";
19
21
  import { groupWouldDisable } from "./contact-tool-groups.js";
20
22
 
@@ -94,10 +96,14 @@ export function wouldDisableMore(roomTools) {
94
96
 
95
97
  export function ContactPermissionsPanel({ name }) {
96
98
  const perm = usePermissions(name);
99
+ const { instances } = useStore(appStore);
100
+ const agentLabel = value => labelOf((instances || []).find(row => row.name === value) || { name: value });
97
101
  const [busy, setBusy] = useState(false);
98
102
  const [mcpDraft, setMcpDraft] = useState("");
99
103
  const [pick, setPick] = useState("");
104
+ const [editing, setEditing] = useState(null), [grantFilter, setGrantFilter] = useState("");
100
105
  const p = perm.data;
106
+ useEffect(() => { setEditing(null); }, [name, p?.revision]);
101
107
  if (!p && perm.loading !== false && !perm.error) return html`<${Skeleton} lines=${5} label=${ca("loading")} />`;
102
108
  if (!p) return perm.error === "forbidden" ? html`<p class="note contact-forbidden">${ca("forbidden")}</p>`
103
109
  : html`<${ErrorState} message=${ca(perm.error === "unavailable" ? "unavailable" : "loadFailed")} onRetry=${() => void perm.read()} />`;
@@ -146,6 +152,7 @@ export function ContactPermissionsPanel({ name }) {
146
152
  };
147
153
  const grantsWrite = (rows) => write({ grants: rows.map(({ id, person, source, target, verbs, expiresAt, remainingUses }) => ({ id, person, source, target, verbs, expiresAt, remainingUses })) });
148
154
  const g = guardState(p.nativeGuard);
155
+ const shownGrants = p.grants.filter(gr => (gr.person.label || gr.person.userId).toLocaleLowerCase().includes(grantFilter.toLocaleLowerCase()));
149
156
  return html`<div class="contact-perm" aria-busy=${busy ? "true" : undefined}>
150
157
  ${p.originRestriction?.active && REASONS.has(p.originRestriction.reason) ? html`<p class="feedback warning contact-origin-restriction" role="status" data-reason=${p.originRestriction.reason}>
151
158
  ${ca(`reason_${p.originRestriction.reason}`)} ${ca("resetNote")}</p>` : null}
@@ -205,16 +212,22 @@ export function ContactPermissionsPanel({ name }) {
205
212
  })() : null}
206
213
  <p class="note">${ca("approverAdmins")}</p>
207
214
  </section>
215
+ `}
208
216
  <section class="card contact-grants">
209
217
  <h3>${ca("grantsTitle")}</h3>
210
218
  <p class="note">${ca("grantsNote")}</p>
211
- ${p.grants.length ? html`<ul class="contact-list">${p.grants.map((gr) => html`<li key=${gr.id}>
212
- <div><strong>${personLabel(gr.person)}</strong> <span class="muted">${ca("grantRow", gr.source, gr.target)}</span></div>
213
- <div class="muted">${ca("grantVerbs", gr.verbs.map((v) => ca(`verb_${v}`)).join(", "))} · ${ca("grantExpires", when(gr.expiresAt))} · ${gr.remainingUses == null ? ca("grantUnlimited") : ca("grantUses", gr.remainingUses)}</div>
214
- ${canManage ? html`<button type="button" class="btn btn-sm btn-ghost" disabled=${busy} onClick=${async () => {
219
+ <label class="field"><span>${ca("grantFilter")}</span><input class="input" type="search" value=${grantFilter} onInput=${e => setGrantFilter(e.currentTarget.value)} /></label>
220
+ ${p.grants.length && !shownGrants.length ? html`<p class="note">${ca("grantNoMatches")}</p>` : null}
221
+ ${p.grants.length ? html`<ul class="contact-list">${shownGrants.map((gr) => html`<li key=${gr.id}>
222
+ <div><strong>${personLabel(gr.person)}</strong> <span class="muted">${ca("grantRow", agentLabel(gr.source), agentLabel(gr.target))}</span></div>
223
+ <div class="muted contact-grant-meta"><span>${ca("grantVerbs", gr.verbs.map((v) => ca(`verb_${v}`)).join(", "))}</span><span>${ca("grantExpires", contactWhen(gr.expiresAt))}</span><span>${gr.remainingUses == null ? ca("grantUnlimited") : ca("grantUses", gr.remainingUses)}</span></div>
224
+ <p class="note">${ca("grantCreated", contactPersonLabel(gr.createdBy), contactWhen(gr.createdAt))}</p>
225
+ ${canManage ? html`<div class="s-actions"><button type="button" class="btn btn-sm" disabled=${busy} onClick=${() => setEditing({ grant: gr, revision: p.revision })}>${ca("grantAdjust")}</button><button type="button" class="btn btn-sm btn-ghost" disabled=${busy} onClick=${async () => {
215
226
  if (await confirmDialog({ message: ca("grantRemoveConfirm"), confirmLabel: ca("grantRemove"), danger: true })) void grantsWrite(p.grants.filter((x) => x.id !== gr.id));
216
- }}>${ca("grantRemove")}</button>` : null}</li>`)}</ul>` : html`<p class="note">${ca("grantsNone")}</p>`}
217
- </section>`}
227
+ }}>${ca("grantRemove")}</button></div>` : null}</li>`)}</ul>` : html`<p class="note">${ca("grantsNone")}</p>`}
228
+ </section>
229
+ ${editing && editing.revision === p.revision && canManage ? html`<${ContactGrantEditor} key=${`${name}:${p.revision}:${editing.grant.id}`} grant=${editing.grant} people=${[editing.grant.person]} source=${agentLabel(editing.grant.source)} target=${agentLabel(editing.grant.target)}
230
+ onClose=${() => setEditing(null)} onSave=${choice => grantsWrite(p.grants.map(row => row.id === editing.grant.id ? { ...row, expiresAt: choice.expiresAt, remainingUses: choice.remainingUses, verbs: choice.verbs } : row))} />` : null}
218
231
  ${p.originState ? html`<section class="card contact-origin">
219
232
  <h3>${ca("originTitle")}</h3>
220
233
  <p class="contact-origin-state"><strong>${ca(`originKind_${p.originState.kind}`)}</strong></p>