@songsid/agend 2.4.0-beta.26 → 2.4.0-beta.28

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 (506) hide show
  1. package/dist/agent-cli-instructions.md +2 -1
  2. package/dist/agent-cli.js +6 -0
  3. package/dist/agent-cli.js.map +1 -1
  4. package/dist/agent-endpoint.d.ts +1 -0
  5. package/dist/agent-endpoint.js +5 -0
  6. package/dist/agent-endpoint.js.map +1 -1
  7. package/dist/agent-whats-new.js +4 -0
  8. package/dist/agent-whats-new.js.map +1 -1
  9. package/dist/backend/kiro-auth-store.d.ts +15 -2
  10. package/dist/backend/kiro-auth-store.js +64 -0
  11. package/dist/backend/kiro-auth-store.js.map +1 -1
  12. package/dist/build-provenance.json +1 -1
  13. package/dist/channel/adapters/discord.js +4 -4
  14. package/dist/channel/adapters/discord.js.map +1 -1
  15. package/dist/channel/adapters/telegram.js +3 -3
  16. package/dist/channel/adapters/telegram.js.map +1 -1
  17. package/dist/channel/ipc-bridge.d.ts +7 -0
  18. package/dist/channel/ipc-bridge.js +45 -11
  19. package/dist/channel/ipc-bridge.js.map +1 -1
  20. package/dist/channel/mcp-server.js +3 -1
  21. package/dist/channel/mcp-server.js.map +1 -1
  22. package/dist/channel/mcp-tools.js +6 -4
  23. package/dist/channel/mcp-tools.js.map +1 -1
  24. package/dist/claude-turn-boundaries.d.ts +15 -0
  25. package/dist/claude-turn-boundaries.js +88 -0
  26. package/dist/claude-turn-boundaries.js.map +1 -0
  27. package/dist/cli.js +35 -2
  28. package/dist/cli.js.map +1 -1
  29. package/dist/contact-auth-service.js +3 -0
  30. package/dist/contact-auth-service.js.map +1 -1
  31. package/dist/contact-auth-store.d.ts +16 -0
  32. package/dist/contact-auth-store.js +61 -1
  33. package/dist/contact-auth-store.js.map +1 -1
  34. package/dist/daemon.d.ts +76 -4
  35. package/dist/daemon.js +621 -115
  36. package/dist/daemon.js.map +1 -1
  37. package/dist/delivery-outbox.d.ts +145 -7
  38. package/dist/delivery-outbox.js +373 -8
  39. package/dist/delivery-outbox.js.map +1 -1
  40. package/dist/detached-fleet-stop.d.ts +40 -0
  41. package/dist/detached-fleet-stop.js +126 -0
  42. package/dist/detached-fleet-stop.js.map +1 -0
  43. package/dist/fleet-lock.d.ts +5 -0
  44. package/dist/fleet-lock.js +21 -2
  45. package/dist/fleet-lock.js.map +1 -1
  46. package/dist/fleet-manager.d.ts +499 -5
  47. package/dist/fleet-manager.js +2917 -217
  48. package/dist/fleet-manager.js.map +1 -1
  49. package/dist/fleet-windows-runtime.d.ts +39 -3
  50. package/dist/fleet-windows-runtime.js +208 -30
  51. package/dist/fleet-windows-runtime.js.map +1 -1
  52. package/dist/general-knowledge/skills/concepts/SKILL.md +5 -0
  53. package/dist/general-knowledge/skills/hub/SKILL.md +5 -1
  54. package/dist/general-knowledge/skills/task-board/SKILL.md +14 -0
  55. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +96 -26
  56. package/dist/hub/admin-dashboard.js +1 -1
  57. package/dist/hub/admin-dashboard.js.map +1 -1
  58. package/dist/hub/agent-catalog.d.ts +1 -1
  59. package/dist/hub/agent-catalog.js +4 -3
  60. package/dist/hub/agent-catalog.js.map +1 -1
  61. package/dist/hub/agent-intro.d.ts +1 -1
  62. package/dist/hub/agent-intro.js +1 -1
  63. package/dist/hub/agent-intro.js.map +1 -1
  64. package/dist/hub/agent-pictures.d.ts +1 -1
  65. package/dist/hub/agent-pictures.js +4 -3
  66. package/dist/hub/agent-pictures.js.map +1 -1
  67. package/dist/hub/catalog.d.ts +2 -2
  68. package/dist/hub/catalog.js +16 -13
  69. package/dist/hub/catalog.js.map +1 -1
  70. package/dist/hub/client.js +9 -2
  71. package/dist/hub/client.js.map +1 -1
  72. package/dist/hub/compose/member.js +8 -1
  73. package/dist/hub/compose/member.js.map +1 -1
  74. package/dist/hub/compose/server.js +4 -2
  75. package/dist/hub/compose/server.js.map +1 -1
  76. package/dist/hub/fleet-updates.d.ts +2 -2
  77. package/dist/hub/fleet-updates.js +7 -5
  78. package/dist/hub/fleet-updates.js.map +1 -1
  79. package/dist/hub/fleet-versions.d.ts +1 -1
  80. package/dist/hub/fleet-versions.js +3 -2
  81. package/dist/hub/fleet-versions.js.map +1 -1
  82. package/dist/hub/http/compose.js +57 -30
  83. package/dist/hub/http/compose.js.map +1 -1
  84. package/dist/hub/http/schema.js +4 -1
  85. package/dist/hub/http/schema.js.map +1 -1
  86. package/dist/hub/join/service.d.ts +6 -0
  87. package/dist/hub/join/service.js +10 -0
  88. package/dist/hub/join/service.js.map +1 -1
  89. package/dist/hub/member/room-ask.js +2 -0
  90. package/dist/hub/member/room-ask.js.map +1 -1
  91. package/dist/hub/member/room-post.d.ts +4 -0
  92. package/dist/hub/member/room-post.js +26 -1
  93. package/dist/hub/member/room-post.js.map +1 -1
  94. package/dist/hub/protocol.d.ts +58 -0
  95. package/dist/hub/protocol.js +3 -2
  96. package/dist/hub/protocol.js.map +1 -1
  97. package/dist/hub/quota.d.ts +2 -2
  98. package/dist/hub/quota.js +6 -4
  99. package/dist/hub/quota.js.map +1 -1
  100. package/dist/hub/read-statement.d.ts +6 -0
  101. package/dist/hub/read-statement.js +33 -0
  102. package/dist/hub/read-statement.js.map +1 -0
  103. package/dist/hub/recommendations.d.ts +1 -1
  104. package/dist/hub/recommendations.js +3 -2
  105. package/dist/hub/recommendations.js.map +1 -1
  106. package/dist/hub/representative.d.ts +2 -0
  107. package/dist/hub/representative.js +8 -4
  108. package/dist/hub/representative.js.map +1 -1
  109. package/dist/hub/roles/clock.d.ts +1 -1
  110. package/dist/hub/roles/clock.js +9 -7
  111. package/dist/hub/roles/clock.js.map +1 -1
  112. package/dist/hub/roles/read.d.ts +4 -0
  113. package/dist/hub/roles/read.js +37 -7
  114. package/dist/hub/roles/read.js.map +1 -1
  115. package/dist/hub/room-history-model.d.ts +87 -0
  116. package/dist/hub/room-history-model.js +14 -0
  117. package/dist/hub/room-history-model.js.map +1 -0
  118. package/dist/hub/rooms/agents.d.ts +1 -1
  119. package/dist/hub/rooms/agents.js +3 -2
  120. package/dist/hub/rooms/agents.js.map +1 -1
  121. package/dist/hub/rooms/history.d.ts +8 -0
  122. package/dist/hub/rooms/history.js +31 -0
  123. package/dist/hub/rooms/history.js.map +1 -0
  124. package/dist/hub/rooms/schema.d.ts +2 -0
  125. package/dist/hub/rooms/schema.js +4 -0
  126. package/dist/hub/rooms/schema.js.map +1 -1
  127. package/dist/hub/rooms/service.d.ts +35 -19
  128. package/dist/hub/rooms/service.js +105 -26
  129. package/dist/hub/rooms/service.js.map +1 -1
  130. package/dist/hub/server.js +10 -3
  131. package/dist/hub/server.js.map +1 -1
  132. package/dist/hub/session-epoch.js +2 -1
  133. package/dist/hub/session-epoch.js.map +1 -1
  134. package/dist/hub/settings-directory-decision.js +14 -7
  135. package/dist/hub/settings-directory-decision.js.map +1 -1
  136. package/dist/hub/settings-member-address-decision.js +3 -2
  137. package/dist/hub/settings-member-address-decision.js.map +1 -1
  138. package/dist/hub/settings-web-address-decision.js +2 -1
  139. package/dist/hub/settings-web-address-decision.js.map +1 -1
  140. package/dist/hub/store.d.ts +5 -0
  141. package/dist/hub/store.js +28 -5
  142. package/dist/hub/store.js.map +1 -1
  143. package/dist/hub/types.d.ts +2 -2
  144. package/dist/hub-agent-incarnation-record.d.ts +24 -0
  145. package/dist/hub-agent-incarnation-record.js +46 -0
  146. package/dist/hub-agent-incarnation-record.js.map +1 -0
  147. package/dist/human-delivery-receipts.d.ts +16 -4
  148. package/dist/human-delivery-receipts.js +26 -5
  149. package/dist/human-delivery-receipts.js.map +1 -1
  150. package/dist/instance-lifecycle.d.ts +9 -3
  151. package/dist/instance-lifecycle.js +27 -10
  152. package/dist/instance-lifecycle.js.map +1 -1
  153. package/dist/instructions.d.ts +1 -1
  154. package/dist/local-pane-endpoint.d.ts +14 -0
  155. package/dist/local-pane-endpoint.js +32 -0
  156. package/dist/local-pane-endpoint.js.map +1 -1
  157. package/dist/locale.js +68 -4
  158. package/dist/locale.js.map +1 -1
  159. package/dist/native-agent-admission.js +9 -0
  160. package/dist/native-agent-admission.js.map +1 -1
  161. package/dist/native-exec-context.d.ts +11 -0
  162. package/dist/native-exec-context.js +18 -0
  163. package/dist/native-exec-context.js.map +1 -0
  164. package/dist/native-exec-input.d.ts +56 -0
  165. package/dist/native-exec-input.js +89 -0
  166. package/dist/native-exec-input.js.map +1 -0
  167. package/dist/native-mcp.d.ts +9 -1
  168. package/dist/native-mcp.js +29 -7
  169. package/dist/native-mcp.js.map +1 -1
  170. package/dist/native-pane-lifecycle.d.ts +3 -0
  171. package/dist/native-pane-lifecycle.js +2 -0
  172. package/dist/native-pane-lifecycle.js.map +1 -1
  173. package/dist/native-pane-manager.d.ts +18 -0
  174. package/dist/native-pane-manager.js +85 -8
  175. package/dist/native-pane-manager.js.map +1 -1
  176. package/dist/needs-you.d.ts +2 -1
  177. package/dist/needs-you.js.map +1 -1
  178. package/dist/outbound-handlers.d.ts +1 -0
  179. package/dist/outbound-handlers.js +9 -3
  180. package/dist/outbound-handlers.js.map +1 -1
  181. package/dist/outbound-schemas.d.ts +8 -0
  182. package/dist/outbound-schemas.js +6 -2
  183. package/dist/outbound-schemas.js.map +1 -1
  184. package/dist/public-web-gateway.js +3 -1
  185. package/dist/public-web-gateway.js.map +1 -1
  186. package/dist/recover.cjs +1 -0
  187. package/dist/reply-buttons-controller.d.ts +1 -0
  188. package/dist/reply-buttons-controller.js +1 -1
  189. package/dist/reply-buttons-controller.js.map +1 -1
  190. package/dist/request-contact-gate.d.ts +2 -0
  191. package/dist/request-contact-gate.js +8 -3
  192. package/dist/request-contact-gate.js.map +1 -1
  193. package/dist/request-context-activation.d.ts +29 -0
  194. package/dist/request-context-activation.js +85 -0
  195. package/dist/request-context-activation.js.map +1 -0
  196. package/dist/request-context-admission.d.ts +22 -0
  197. package/dist/request-context-admission.js +12 -0
  198. package/dist/request-context-admission.js.map +1 -0
  199. package/dist/request-context-boot.d.ts +35 -0
  200. package/dist/request-context-boot.js +97 -0
  201. package/dist/request-context-boot.js.map +1 -0
  202. package/dist/request-context-call.d.ts +3 -0
  203. package/dist/request-context-call.js.map +1 -1
  204. package/dist/request-context-compatibility.js +10 -2
  205. package/dist/request-context-compatibility.js.map +1 -1
  206. package/dist/request-context-continuation.d.ts +6 -0
  207. package/dist/request-context-continuation.js +24 -0
  208. package/dist/request-context-continuation.js.map +1 -0
  209. package/dist/request-context-control-api.d.ts +119 -0
  210. package/dist/request-context-control-api.js +179 -0
  211. package/dist/request-context-control-api.js.map +1 -0
  212. package/dist/request-context-control-copy.d.ts +3 -0
  213. package/dist/request-context-control-copy.js +7 -0
  214. package/dist/request-context-control-copy.js.map +1 -0
  215. package/dist/request-context-controller.d.ts +44 -0
  216. package/dist/request-context-controller.js +129 -0
  217. package/dist/request-context-controller.js.map +1 -0
  218. package/dist/request-context-delivery-resolver.d.ts +13 -0
  219. package/dist/request-context-delivery-resolver.js +30 -0
  220. package/dist/request-context-delivery-resolver.js.map +1 -0
  221. package/dist/request-context-drain-projection.d.ts +8 -0
  222. package/dist/request-context-drain-projection.js +40 -0
  223. package/dist/request-context-drain-projection.js.map +1 -0
  224. package/dist/request-context-drain.d.ts +22 -0
  225. package/dist/request-context-drain.js +139 -7
  226. package/dist/request-context-drain.js.map +1 -1
  227. package/dist/request-context-enable-offer.d.ts +13 -0
  228. package/dist/request-context-enable-offer.js +31 -0
  229. package/dist/request-context-enable-offer.js.map +1 -0
  230. package/dist/request-context-exec-owner.d.ts +39 -0
  231. package/dist/request-context-exec-owner.js +128 -0
  232. package/dist/request-context-exec-owner.js.map +1 -0
  233. package/dist/request-context-go-back-view.d.ts +1 -0
  234. package/dist/request-context-go-back-view.js +17 -0
  235. package/dist/request-context-go-back-view.js.map +1 -0
  236. package/dist/request-context-helper-readiness.d.ts +14 -0
  237. package/dist/request-context-helper-readiness.js +23 -0
  238. package/dist/request-context-helper-readiness.js.map +1 -0
  239. package/dist/request-context-helper.d.ts +20 -0
  240. package/dist/request-context-helper.js +41 -0
  241. package/dist/request-context-helper.js.map +1 -0
  242. package/dist/request-context-hub-resolver.d.ts +29 -0
  243. package/dist/request-context-hub-resolver.js +90 -0
  244. package/dist/request-context-hub-resolver.js.map +1 -0
  245. package/dist/request-context-human-resolver.d.ts +20 -0
  246. package/dist/request-context-human-resolver.js +77 -0
  247. package/dist/request-context-human-resolver.js.map +1 -0
  248. package/dist/request-context-human.d.ts +112 -0
  249. package/dist/request-context-human.js +176 -0
  250. package/dist/request-context-human.js.map +1 -0
  251. package/dist/request-context-inputs.d.ts +21 -0
  252. package/dist/request-context-inputs.js +63 -0
  253. package/dist/request-context-inputs.js.map +1 -0
  254. package/dist/request-context-installation.d.ts +117 -0
  255. package/dist/request-context-installation.js +328 -0
  256. package/dist/request-context-installation.js.map +1 -0
  257. package/dist/request-context-knowledge.d.ts +5 -0
  258. package/dist/request-context-knowledge.js +32 -0
  259. package/dist/request-context-knowledge.js.map +1 -0
  260. package/dist/request-context-migration.d.ts +11 -0
  261. package/dist/request-context-migration.js +16 -3
  262. package/dist/request-context-migration.js.map +1 -1
  263. package/dist/request-context-native-human.d.ts +20 -0
  264. package/dist/request-context-native-human.js +91 -0
  265. package/dist/request-context-native-human.js.map +1 -0
  266. package/dist/request-context-native-output.d.ts +15 -0
  267. package/dist/request-context-native-output.js +46 -0
  268. package/dist/request-context-native-output.js.map +1 -0
  269. package/dist/request-context-native-result.d.ts +15 -0
  270. package/dist/request-context-native-result.js +46 -0
  271. package/dist/request-context-native-result.js.map +1 -0
  272. package/dist/request-context-off.d.ts +22 -0
  273. package/dist/request-context-off.js +77 -0
  274. package/dist/request-context-off.js.map +1 -0
  275. package/dist/request-context-outside-label.d.ts +5 -0
  276. package/dist/request-context-outside-label.js +28 -0
  277. package/dist/request-context-outside-label.js.map +1 -0
  278. package/dist/request-context-pane.d.ts +8 -0
  279. package/dist/request-context-pane.js +19 -0
  280. package/dist/request-context-pane.js.map +1 -1
  281. package/dist/request-context-pending-work.d.ts +11 -0
  282. package/dist/request-context-pending-work.js +43 -0
  283. package/dist/request-context-pending-work.js.map +1 -0
  284. package/dist/request-context-policy.d.ts +17 -1
  285. package/dist/request-context-policy.js +84 -6
  286. package/dist/request-context-policy.js.map +1 -1
  287. package/dist/request-context-readiness.d.ts +49 -0
  288. package/dist/request-context-readiness.js +64 -0
  289. package/dist/request-context-readiness.js.map +1 -0
  290. package/dist/request-context-recovery.d.ts +6 -2
  291. package/dist/request-context-recovery.js +25 -0
  292. package/dist/request-context-recovery.js.map +1 -1
  293. package/dist/request-context-relay.d.ts +2 -2
  294. package/dist/request-context-relay.js +10 -10
  295. package/dist/request-context-relay.js.map +1 -1
  296. package/dist/request-context-reply-pending.d.ts +16 -0
  297. package/dist/request-context-reply-pending.js +77 -0
  298. package/dist/request-context-reply-pending.js.map +1 -0
  299. package/dist/request-context-resolution.d.ts +35 -0
  300. package/dist/request-context-resolution.js +86 -0
  301. package/dist/request-context-resolution.js.map +1 -0
  302. package/dist/request-context-retirement.d.ts +21 -0
  303. package/dist/request-context-retirement.js +16 -0
  304. package/dist/request-context-retirement.js.map +1 -0
  305. package/dist/request-context-start.d.ts +15 -0
  306. package/dist/request-context-start.js +2 -0
  307. package/dist/request-context-start.js.map +1 -0
  308. package/dist/request-context-turns.d.ts +1 -1
  309. package/dist/request-context-turns.js +3 -2
  310. package/dist/request-context-turns.js.map +1 -1
  311. package/dist/request-context-unproved-label.d.ts +4 -0
  312. package/dist/request-context-unproved-label.js +25 -0
  313. package/dist/request-context-unproved-label.js.map +1 -0
  314. package/dist/request-context-update-guard.d.ts +15 -0
  315. package/dist/request-context-update-guard.js +54 -0
  316. package/dist/request-context-update-guard.js.map +1 -0
  317. package/dist/request-context-work.d.ts +50 -0
  318. package/dist/request-context-work.js +178 -0
  319. package/dist/request-context-work.js.map +1 -0
  320. package/dist/request-hub-context.d.ts +1 -0
  321. package/dist/request-hub-output.d.ts +2 -0
  322. package/dist/request-hub-output.js +12 -0
  323. package/dist/request-hub-output.js.map +1 -1
  324. package/dist/retained-human-control.d.ts +11 -0
  325. package/dist/retained-human-control.js +11 -0
  326. package/dist/retained-human-control.js.map +1 -0
  327. package/dist/runtime-build-info.js +1 -1
  328. package/dist/runtime-build-info.js.map +1 -1
  329. package/dist/runtime-cli.js +1 -1
  330. package/dist/runtime-cli.js.map +1 -1
  331. package/dist/runtime-client-store.js +7 -1
  332. package/dist/runtime-client-store.js.map +1 -1
  333. package/dist/runtime-client.js +15 -3
  334. package/dist/runtime-client.js.map +1 -1
  335. package/dist/runtime-coordinator.d.ts +23 -0
  336. package/dist/runtime-coordinator.js +103 -4
  337. package/dist/runtime-coordinator.js.map +1 -1
  338. package/dist/runtime-pane-mcp.d.ts +9 -0
  339. package/dist/runtime-pane-mcp.js +22 -2
  340. package/dist/runtime-pane-mcp.js.map +1 -1
  341. package/dist/runtime-protocol.d.ts +2 -0
  342. package/dist/runtime-protocol.js.map +1 -1
  343. package/dist/runtime-update-controller.js +1 -1
  344. package/dist/runtime-update-controller.js.map +1 -1
  345. package/dist/runtime-windows-bridge.d.ts +8 -0
  346. package/dist/runtime-windows-bridge.js +50 -3
  347. package/dist/runtime-windows-bridge.js.map +1 -1
  348. package/dist/scheduler/db.js +9 -0
  349. package/dist/scheduler/db.js.map +1 -1
  350. package/dist/scheduler/task-board-text.d.ts +3 -6
  351. package/dist/scheduler/task-board-text.js +15 -10
  352. package/dist/scheduler/task-board-text.js.map +1 -1
  353. package/dist/scheduler/task-board-unread.d.ts +90 -0
  354. package/dist/scheduler/task-board-unread.js +192 -0
  355. package/dist/scheduler/task-board-unread.js.map +1 -0
  356. package/dist/scheduler/task-board.d.ts +324 -6
  357. package/dist/scheduler/task-board.js +786 -47
  358. package/dist/scheduler/task-board.js.map +1 -1
  359. package/dist/service-install-handover.d.ts +52 -0
  360. package/dist/service-install-handover.js +50 -0
  361. package/dist/service-install-handover.js.map +1 -0
  362. package/dist/service-installer.d.ts +12 -0
  363. package/dist/service-installer.js +24 -10
  364. package/dist/service-installer.js.map +1 -1
  365. package/dist/settings-api.d.ts +2 -0
  366. package/dist/settings-api.js +4 -0
  367. package/dist/settings-api.js.map +1 -1
  368. package/dist/settings-baseline.d.ts +1 -0
  369. package/dist/settings-baseline.js +5 -4
  370. package/dist/settings-baseline.js.map +1 -1
  371. package/dist/settings-confirmation.d.ts +2 -0
  372. package/dist/settings-confirmation.js +6 -0
  373. package/dist/settings-confirmation.js.map +1 -1
  374. package/dist/settings-effect.d.ts +2 -0
  375. package/dist/settings-effect.js +59 -1
  376. package/dist/settings-effect.js.map +1 -1
  377. package/dist/settings-http-confirmation.d.ts +3 -0
  378. package/dist/settings-http-confirmation.js +29 -0
  379. package/dist/settings-http-confirmation.js.map +1 -1
  380. package/dist/settings-route-lifetime.d.ts +3 -1
  381. package/dist/settings-route-lifetime.js +15 -5
  382. package/dist/settings-route-lifetime.js.map +1 -1
  383. package/dist/settings-transaction.d.ts +3 -2
  384. package/dist/settings-transaction.js.map +1 -1
  385. package/dist/task-board-tool.js +24 -3
  386. package/dist/task-board-tool.js.map +1 -1
  387. package/dist/task-board-waker.d.ts +53 -2
  388. package/dist/task-board-waker.js +183 -12
  389. package/dist/task-board-waker.js.map +1 -1
  390. package/dist/tips.js +1 -1
  391. package/dist/tips.js.map +1 -1
  392. package/dist/tool-permissions.js +3 -3
  393. package/dist/tool-permissions.js.map +1 -1
  394. package/dist/tool-receipt-output.d.ts +6 -6
  395. package/dist/transcript-monitor.d.ts +6 -1
  396. package/dist/transcript-monitor.js +59 -4
  397. package/dist/transcript-monitor.js.map +1 -1
  398. package/dist/transcript-turns.d.ts +3 -0
  399. package/dist/transcript-turns.js +5 -0
  400. package/dist/transcript-turns.js.map +1 -1
  401. package/dist/turn-reply-guard.d.ts +16 -1
  402. package/dist/turn-reply-guard.js +20 -2
  403. package/dist/turn-reply-guard.js.map +1 -1
  404. package/dist/ui/app.html +2 -2
  405. package/dist/ui/contact-auth-strings.js +6 -6
  406. package/dist/ui/contact-authorizations.js +19 -1
  407. package/dist/ui/contact-grant-editor.js +71 -11
  408. package/dist/ui/contact-needs.js +27 -8
  409. package/dist/ui/contact-permissions.js +25 -8
  410. package/dist/ui/contact-tool-groups.js +1 -1
  411. package/dist/ui/fleet-task-activity.js +164 -24
  412. package/dist/ui/fleet-task-card.js +77 -13
  413. package/dist/ui/fleet-task-common.js +14 -0
  414. package/dist/ui/fleet-task-flow.js +353 -0
  415. package/dist/ui/fleet-task-md.js +1 -1
  416. package/dist/ui/fleet-task-run.js +98 -22
  417. package/dist/ui/fleet-task-thread.js +245 -0
  418. package/dist/ui/fleet-task-unread.js +100 -0
  419. package/dist/ui/fleet-task-view.js +6 -5
  420. package/dist/ui/fleet-task-wake.js +140 -0
  421. package/dist/ui/fleet-tasks.js +13 -6
  422. package/dist/ui/hub-client.js +3 -0
  423. package/dist/ui/hub-room-members.js +4 -2
  424. package/dist/ui/hub-room-settings-strings.js +8 -0
  425. package/dist/ui/hub-room-settings.js +32 -0
  426. package/dist/ui/hub-room-thread.js +7 -1
  427. package/dist/ui/icons/hub-apple-touch-icon.png +0 -0
  428. package/dist/ui/icons/hub-favicon.ico +0 -0
  429. package/dist/ui/icons/hub-favicon.svg +10 -0
  430. package/dist/ui/icons/hub-icon-192.png +0 -0
  431. package/dist/ui/icons/hub-icon-512.png +0 -0
  432. package/dist/ui/icons/hub-icon-maskable-192.png +0 -0
  433. package/dist/ui/icons/hub-icon-maskable-512.png +0 -0
  434. package/dist/ui/icons/hub-maskable.svg +12 -0
  435. package/dist/ui/panel-hub.js +14 -3
  436. package/dist/ui/panel-needs.js +2 -1
  437. package/dist/ui/panel-settings.js +2 -1
  438. package/dist/ui/panel-windows-cli.js +2 -2
  439. package/dist/ui/request-contact-card.js +287 -0
  440. package/dist/ui/request-contact-client.js +83 -0
  441. package/dist/ui/request-contact-page.js +78 -0
  442. package/dist/ui/request-context-control.js +209 -0
  443. package/dist/ui/settings-registry.js +2 -0
  444. package/dist/ui/settings-update.js +3 -2
  445. package/dist/ui/shared/access-overview.css +1 -1
  446. package/dist/ui/shared/app-i18n.js +2 -2
  447. package/dist/ui/shared/app-install.js +2 -2
  448. package/dist/ui/shared/app-shell.js +17 -4
  449. package/dist/ui/shared/app-stream.js +4 -1
  450. package/dist/ui/shared/app-update.js +2 -1
  451. package/dist/ui/shared/app.css +101 -10
  452. package/dist/ui/shared/app.js +19 -2
  453. package/dist/ui/shared/task-board.css +164 -0
  454. package/dist/ui/shared/ui-icons.js +3 -0
  455. package/dist/ui/shared/ui-states.js +6 -0
  456. package/dist/ui/shared/update-card-ui.js +178 -11
  457. package/dist/ui/shared/view-strings.js +18 -0
  458. package/dist/ui/shared/web-authorize.js +1 -1
  459. package/dist/ui/task-unread.js +70 -0
  460. package/dist/ui/windows-cli-catalog.js +33 -6
  461. package/dist/update-card.d.ts +1 -1
  462. package/dist/update-card.js +7 -7
  463. package/dist/update-card.js.map +1 -1
  464. package/dist/update-fix.d.ts +66 -0
  465. package/dist/update-fix.js +67 -0
  466. package/dist/update-fix.js.map +1 -0
  467. package/dist/update-goback.js +15 -3
  468. package/dist/update-goback.js.map +1 -1
  469. package/dist/update-readiness.d.ts +2 -0
  470. package/dist/update-readiness.js +5 -1
  471. package/dist/update-readiness.js.map +1 -1
  472. package/dist/update-snapshot-scope.js +1 -0
  473. package/dist/update-snapshot-scope.js.map +1 -1
  474. package/dist/usage/i18n-keys.d.ts +1 -1
  475. package/dist/usage/i18n-keys.js +9 -0
  476. package/dist/usage/i18n-keys.js.map +1 -1
  477. package/dist/usage/providers.d.ts +3 -11
  478. package/dist/usage/providers.js +93 -131
  479. package/dist/usage/providers.js.map +1 -1
  480. package/dist/web-api.d.ts +49 -1
  481. package/dist/web-api.js +234 -13
  482. package/dist/web-api.js.map +1 -1
  483. package/dist/web-chat-history.d.ts +2 -0
  484. package/dist/web-chat-history.js.map +1 -1
  485. package/dist/web-icons.d.ts +9 -3
  486. package/dist/web-icons.js +62 -5
  487. package/dist/web-icons.js.map +1 -1
  488. package/dist/web-update.d.ts +9 -0
  489. package/dist/windows-agents.d.ts +24 -2
  490. package/dist/windows-agents.js +110 -4
  491. package/dist/windows-agents.js.map +1 -1
  492. package/dist/windows-cli-api.js +4 -2
  493. package/dist/windows-cli-api.js.map +1 -1
  494. package/dist/windows-cli-worker.js +9 -1
  495. package/dist/windows-cli-worker.js.map +1 -1
  496. package/dist/windows-cli.d.ts +55 -1
  497. package/dist/windows-cli.js +147 -17
  498. package/dist/windows-cli.js.map +1 -1
  499. package/dist/windows-shortcuts.d.ts +3 -22
  500. package/dist/windows-shortcuts.js +5 -45
  501. package/dist/windows-shortcuts.js.map +1 -1
  502. package/dist/workflow-templates/default.md +3 -2
  503. package/dist/wsl-host.d.ts +52 -0
  504. package/dist/wsl-host.js +97 -0
  505. package/dist/wsl-host.js.map +1 -0
  506. package/package.json +1 -1
@@ -0,0 +1,287 @@
1
+ // M-3736 J (S-228; design #4456 §6, slice I's V1 contract: docs/design/request-contact-same-card-api.md): the one contact
2
+ // card — the same card in Fleet → Authorizations and Needs you, for every managing admin who may read it.
3
+ // - What it is: the sending Agent → the exact target, who asked (the recorded initiating person, never the approver), how
4
+ // it came in, the message, where replies go, the reason, when it expires; a continued request says so and has no actions.
5
+ // - Continue (with follow-ups) / Set allowed contacts… (the grant editor's own name) / Decline. Continue states its D1 scope (a root request: this request and its
6
+ // later Agent contacts, nothing else); a legacy ticket keeps its old one-request wording.
7
+ // - Not verified yet: the same card, its buttons off, with one line and Authorize this browser inline. Once this browser
8
+ // is verified the card is read again and shows its buttons; one click decides. Verifying never decides anything: a
9
+ // decision is only ever sent from a click on a decision button, never from an effect, a poll, a key or the
10
+ // authorization's completion.
11
+ // - Each card's detail line says its scope in a few words (Continue = this request and its follow-ups; Approve once = this
12
+ // one request), so the two verbs in one list explain themselves; the long wording is in its details.
13
+ // - 409 (decided or changed elsewhere) → read the same card again and show it; never retried.
14
+ // A module of its own, with its own words (the module-skew rule): an older cached page keeps today's cards.
15
+ import { html, useEffect, useRef, useState } from "/assets/app-html.js";
16
+ import { register, t } from "/assets/app-i18n.js";
17
+ import { toast } from "/assets/ui-toast.js";
18
+ import { dateTimeText } from "/assets/clock-text.js";
19
+ import { AuthorizeChip, useWebAuthorization, resetWebAuthorization } from "/assets/web-authorize.js";
20
+ import { detailsPath } from "/assets/app-route.js";
21
+ import { Icon } from "/assets/ui-icons.js";
22
+ import { ca } from "./contact-auth-strings.js";
23
+ import { ContactGrantEditor } from "./contact-grant-editor.js";
24
+ import { decideCard, getCard, RC_REREAD } from "./request-contact-client.js";
25
+
26
+ register("rcard", {
27
+ en: {
28
+ continue: "Continue (with follow-ups)", approveOnce: "Approve once", decline: "Decline",
29
+ scopeRoot: "Continue this request and its later Agent contacts. This does not approve what Agents do or authorize unrelated requests.",
30
+ scopeOperation: "Approve = forward this request once.",
31
+ scopeShortRoot: "Continue = this request and its follow-up contacts only.", scopeShortOperation: "Approve once = this one request only.",
32
+ askedBy: "Asked by {0}", askedByNone: "Can't tell who asked", unknownPerson: "Unknown person", hubPerson: "{0} (Hub)",
33
+ ingress_owner: "An admin's request", "ingress_free-room": "Free room", "ingress_restricted-room": "Restricted room", ingress_guest: "Guest", ingress_hub: "Hub",
34
+ repliesTo: "Replies go back to {0}.", audience_room: "the original room", audience_web: "the web conversation", audience_hub: "the Hub conversation", audience_instance: "the requesting Agent",
35
+ "reason_restricted-room-request": "This was sent while {0} was working on {1}'s request from a restricted room.",
36
+ "reason_guest-request": "This was sent while {0} was working on a request from {1}, a guest.",
37
+ "reason_hub-request": "This was sent while {0} was working on {1}'s request from the Hub.",
38
+ "reason_unproved-recovery": "{0} resumed work whose requester couldn't be proven, so this contact needs approval.",
39
+ "reason_interrupted-launch": "This agent was interrupted; this contact needs one approval.",
40
+ reason_other: "This contact needs an admin's approval.", someone: "someone",
41
+ grantView: "View allowed contacts in Permissions",
42
+ waiting: "Waiting for your Confirm in Discord or Telegram ({0})",
43
+ continuedFrom: "Continued from request #{0}: it needs no decision here.",
44
+ state_approved_root: "Continued", forwardedTo: "Forwarded to {0}.",
45
+ verifyTitle: "Authorize this browser to decide.",
46
+ decidedElsewhere: "This request was decided elsewhere. Here is its outcome.",
47
+ uncertain: "Couldn't confirm the decision. Here is the request as it stands now; nothing was sent again.",
48
+ failed: "Couldn't record the decision: {0}", forbidden: "You can't decide this request.", signIn: "Sign in again to decide.",
49
+ unavailable: "Contact approvals are unavailable right now.", grantInvalid: "That allowed contact can't be saved; approve once or decline.",
50
+ noGrant: "This request's person can't become an allowed contact; Continue or Decline it.",
51
+ decidedAt: "Decided {0}",
52
+ upgrade: "This request stays held until its target is upgraded.",
53
+ readFailed: "Couldn't read this request's current state.", readRetry: "Read again",
54
+ },
55
+ "zh-TW": {
56
+ continue: "繼續(含後續聯絡)", approveOnce: "核准這一次", decline: "拒絕",
57
+ scopeRoot: "繼續這筆請求及它後續的 Agent 聯絡;這不代表核准 Agent 的操作,也不會授權其他請求。",
58
+ scopeOperation: "核准=只轉交這一次。",
59
+ scopeShortRoot: "繼續=只放行這筆請求和它後續的聯絡。", scopeShortOperation: "核准這一次=只轉交這一筆請求。",
60
+ askedBy: "由 {0} 提出", askedByNone: "無法確認是誰提出的", unknownPerson: "身分不明", hubPerson: "{0}(Hub)",
61
+ ingress_owner: "管理員的請求", "ingress_free-room": "自由模式房間", "ingress_restricted-room": "受限模式房間", ingress_guest: "訪客", ingress_hub: "Hub",
62
+ repliesTo: "回覆會回到{0}。", audience_room: "原本的房間", audience_web: "網頁對話", audience_hub: "Hub 對話", audience_instance: "提出請求的 Agent",
63
+ "reason_restricted-room-request": "這是 {0} 處理 {1} 在受限模式房間提出的請求時送出的。",
64
+ "reason_guest-request": "這是 {0} 處理訪客 {1} 的請求時送出的。",
65
+ "reason_hub-request": "這是 {0} 處理 {1} 從 Hub 提出的請求時送出的。",
66
+ "reason_unproved-recovery": "{0} 接續的工作無法證明是誰提出的,因此這次聯絡需要核准。",
67
+ "reason_interrupted-launch": "這個 Agent 曾中斷;這次聯絡需要核准一次。",
68
+ reason_other: "這次聯絡需要管理員核准。", someone: "某人",
69
+ grantView: "在「權限」查看允許的聯絡",
70
+ waiting: "等你在 Discord 或 Telegram 按下確認({0})",
71
+ continuedFrom: "接續申請 #{0}:這裡不需要再決定。",
72
+ state_approved_root: "已繼續", forwardedTo: "已轉交給 {0}。",
73
+ verifyTitle: "授權這個瀏覽器後才能決定。",
74
+ decidedElsewhere: "這筆申請已在別處處理,以下是結果。",
75
+ uncertain: "無法確認這次決定是否完成。以下是這筆申請目前的狀態;沒有再次送出。",
76
+ failed: "無法記錄決定:{0}", forbidden: "你無法決定這筆申請。", signIn: "請重新登入後再決定。",
77
+ unavailable: "目前無法處理聯絡核准。", grantInvalid: "無法儲存這項允許的聯絡;請核准這次或拒絕。",
78
+ noGrant: "這筆申請的提出者無法設為允許的聯絡;請繼續或拒絕。",
79
+ decidedAt: "{0} 已處理",
80
+ upgrade: "這份申請會繼續保留,等接收端升級後才能處理。",
81
+ readFailed: "無法讀取這筆申請目前的狀態。", readRetry: "重新讀取",
82
+ },
83
+ });
84
+ const tr = (k, ...a) => t(`rcard.${k}`, ...a);
85
+ const when = (iso) => { const d = new Date(iso); return Number.isFinite(d.getTime()) ? dateTimeText(d, { dateStyle: "medium", timeStyle: "short" }, []) : ""; };
86
+ const TONE = { pending: "warn", approved: "ok", delivered: "ok", declined: "bad", expired: "muted", unknown: "bad" };
87
+ const stateOf = (s) => (Object.prototype.hasOwnProperty.call(TONE, s) ? s : "unknown");
88
+ const VERBS = new Set(["send_to_instance", "delegate_task", "request_information", "broadcast", "report_result"]);
89
+ const INGRESS = new Set(["owner", "free-room", "restricted-room", "guest", "hub"]);
90
+ const AUDIENCE = new Set(["room", "web", "hub", "instance"]);
91
+ const shortId = (id) => { const s = String(id || ""); return /^R[a-f0-9]{8}-/.test(s) ? s.slice(0, 9) : s; };
92
+
93
+ /** The person's name alone: a verified display name, else their identity; never invented (null: "someone"). */
94
+ export function requesterName(actor) {
95
+ if (!actor || actor.kind === "unknown") return tr("someone");
96
+ if (actor.platform === "hub") return tr("hubPerson", actor.displayName || actor.id);
97
+ if (actor.platform === "host") return ca("operator");
98
+ return actor.displayName || actor.userId;
99
+ }
100
+ /** The card's reason (a stable code, Sentinel #4492): the legacy two in today's words, the scoped ones with who and which Agent. */
101
+ export function reasonText(card) {
102
+ const code = String(card.reason || "");
103
+ if (code === "earlier-non-admin" || code === "unknown-origin") return ca(`request_reason_${code}`, card.sourceLabel);
104
+ // From the Hub, the sentence already says so: the name alone, not "(Hub)" twice.
105
+ const hubName = code === "hub-request" && card.requester && card.requester.platform === "hub" ? card.requester.displayName || card.requester.id : null;
106
+ if (["restricted-room-request", "guest-request", "hub-request"].includes(code)) return tr(`reason_${code}`, card.sourceLabel, hubName || requesterName(card.requester));
107
+ if (code === "unproved-recovery") return tr("reason_unproved-recovery", card.sourceLabel);
108
+ // S-249 (Sentinel H, #4500): a launch cut off mid-request; its requester stays unknown and it offers no grant (canGrant).
109
+ if (code === "interrupted-launch") return tr("reason_interrupted-launch");
110
+ return tr("reason_other");
111
+ }
112
+ /**
113
+ * The card's server-owned candidates as people any copy of the grant editor keys the same way (#4497 review): the
114
+ * server's key is JSON [platform, userId], so each carries the userId its key names — an older cached editor, which keys
115
+ * by [platform, userId] and knows no `keyOf`, still selects exactly these keys.
116
+ */
117
+ export function candidatePeople(card) {
118
+ return (card.grantCandidates || []).map((c) => ({ key: c.key, label: c.label, platform: c.platform, userId: candidateUserId(c) }));
119
+ }
120
+ /** Save control: the rule to send, only for keys this card offered (at least one, never one an editor made up); else null. */
121
+ export function grantFromChoice(card, c) {
122
+ const offered = new Set((card.grantCandidates || []).map((x) => x.key));
123
+ const keys = Array.isArray(c && c.personKeys) ? c.personKeys : [];
124
+ if (!keys.length || !keys.every((k) => typeof k === "string" && offered.has(k))) return null;
125
+ return { expiresAt: c.expiresAt, remainingUses: c.remainingUses, personKeys: keys };
126
+ }
127
+ /** The userId a candidate's server key names (JSON [platform, userId]), or null when the key isn't that shape. */
128
+ export function candidateUserId(c) {
129
+ try { const k = JSON.parse(String(c && c.key)); return Array.isArray(k) && k.length === 2 && k[0] === c.platform && typeof k[1] === "string" ? k[1] : null; } catch { return null; }
130
+ }
131
+ /** The time a request was asked, as Needs you's items show theirs: the clock today, else the date. */
132
+ const clockOf = (iso) => { const d = new Date(iso); if (!Number.isFinite(d.getTime())) return ""; return new Date().toDateString() === d.toDateString()
133
+ ? dateTimeText(d, { hour: "2-digit", minute: "2-digit", hourCycle: "h23" }, []) : dateTimeText(d, { month: "short", day: "numeric" }, []); };
134
+ const mmss = (ms) => { const s = Math.max(0, Math.ceil(ms / 1000)); return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`; };
135
+
136
+ /** Who asked, in words: the recorded initiating actor (request-context-protocol.ts's shape), never an invented person. */
137
+ export function requesterText(actor) {
138
+ if (!actor) return tr("askedByNone");
139
+ if (actor.kind === "unknown") return tr("askedBy", tr("unknownPerson"));
140
+ if (actor.platform === "hub") return tr("askedBy", tr("hubPerson", actor.displayName || actor.id));
141
+ if (actor.platform === "host") return tr("askedBy", ca("operator"));
142
+ return tr("askedBy", actor.displayName || actor.userId);
143
+ }
144
+
145
+
146
+ /**
147
+ * Authorize this browser, from the card's own reading of it (so the card itself sees pending turn into verified): the
148
+ * button where this browser can ask, the countdown while the account's Confirm waits, and otherwise the shared line, which
149
+ * says why this browser can't be authorized here. Asking only asks for the browser's authorization; it decides nothing.
150
+ */
151
+ function authorizeControl(auth) {
152
+ const st = auth.st;
153
+ if (!st) return null;
154
+ if (st.state === "pending") return html`<p class="note rc-auth-wait" role="status">${tr("waiting", mmss(auth.left))}${auth.notice ? html` · ${auth.notice}` : null}</p>`;
155
+ if (st.reason === "not_authorized" || st.reason === "authorization_expired") {
156
+ return html`<div class="rc-auth"><button type="button" class="btn btn-sm rc-auth-ask" onClick=${auth.ask}>${t("webauth.authorize")}</button>${auth.notice ? html` <span class="note" role="status">${auth.notice}</span>` : null}</div>`;
157
+ }
158
+ return html`<${AuthorizeChip} />`;
159
+ }
160
+
161
+ /** Every mounted card's "this browser is verified now" ear, for this page load. */
162
+ const verifiedListeners = new Set();
163
+ function announceVerified(self) { for (const hear of [...verifiedListeners]) if (hear !== self) { try { hear(); } catch { /* one card's read never stops the others' */ } } }
164
+
165
+ /** One card. `onChange(card)`: the server's fresh card after a decision or a re-read. */
166
+ export function RequestContactCard({ card, onChange, focus = false, openHref = null }) {
167
+ const [busy, setBusy] = useState(false);
168
+ const [grantOpen, setGrantOpen] = useState(false);
169
+ const [granted, setGranted] = useState(false);
170
+ // A read of this card that failed (after verifying, or after a decision whose answer was unknown): its state here may be
171
+ // stale, so it says so, its decision buttons stay off, and Read again only reads (#4497 review R2). Never a POST.
172
+ // Kept in a ref as well: an already-open rule editor holds an older onSave, and its Save must see it too (R3).
173
+ const [readFailed, setReadFailed] = useState(false);
174
+ const unread = useRef(false);
175
+ const readCard = async () => {
176
+ const r = await getCard(tk.id);
177
+ if (r.ok) { unread.current = false; setReadFailed(false); onChange?.(r.data); return true; }
178
+ unread.current = true; setReadFailed(true); setGrantOpen(false); // the rule editor closes until a read succeeds
179
+ return false;
180
+ };
181
+ const auth = useWebAuthorization();
182
+ const tk = card.ticket, st = stateOf(tk.state);
183
+ const root = card.approvalScope === "root-request";
184
+ const open = st === "pending" && !card.continuedFrom;
185
+ const needsVerify = open && card.actions.requiresVerification;
186
+ const canDecide = open && card.actions.canDecide && !card.actions.requiresVerification;
187
+ const grantable = card.actions.canGrant && Array.isArray(card.grantCandidates) && card.grantCandidates.length > 0;
188
+
189
+ // Once this browser is verified, read the same card again (only reading: a decision waits for a click on its buttons).
190
+ // Only the card whose Authorize was pressed watches the confirm come in; it tells every other card on the page, which
191
+ // reads itself again too (the capture look: the others stayed "Authorize this browser to decide.").
192
+ const verified = auth.st && auth.st.state === "verified";
193
+ const waits = useRef(needsVerify);
194
+ waits.current = needsVerify;
195
+ const readAgain = useRef(null);
196
+ readAgain.current = () => { void readCard(); };
197
+ const ear = useRef(null);
198
+ useEffect(() => {
199
+ const hear = () => { if (waits.current) readAgain.current(); };
200
+ ear.current = hear;
201
+ verifiedListeners.add(hear);
202
+ return () => { verifiedListeners.delete(hear); };
203
+ }, []);
204
+ useEffect(() => {
205
+ if (!needsVerify || !verified) return undefined;
206
+ readAgain.current();
207
+ announceVerified(ear.current);
208
+ return undefined;
209
+ }, [needsVerify, verified, tk.id]);
210
+
211
+ const reread = async (say) => {
212
+ if (say) toast(say, false);
213
+ await readCard();
214
+ };
215
+ // The one way a decision is sent: never while a send is out, or while this card's state is unknown (a failed read).
216
+ const sending = useRef(false);
217
+ const decide = async (decision, grant) => {
218
+ if (busy || sending.current || unread.current) return false;
219
+ // Held until the whole decision is over — its POST and any read after it — so no other Save can slip in between.
220
+ sending.current = true;
221
+ setBusy(true);
222
+ try {
223
+ const r = await decideCard(card, decision, grant);
224
+ if (r.ok) { if (grant) { setGranted(true); toast(ca("grantSaved"), true); } onChange?.(r.data); return true; }
225
+ if (r.code === "upgrade-required") { toast(r.message || tr("upgrade"), false, { detail: true }); await reread(null); return false; }
226
+ if (r.status === 409 || RC_REREAD.has(r.code)) { await reread(tr("decidedElsewhere")); return false; }
227
+ if (r.code === "verification-required") { resetWebAuthorization(); await reread(null); return false; }
228
+ // A definite refusal (the server said no before deciding) is said; anything else — no answer, an answer that can't be
229
+ // read, a server error — may have committed: read the same card and show what it is now. Never sent again.
230
+ if (r.status === 400 || r.status === 401 || r.status === 403 || r.status === 404) {
231
+ toast(r.code === "forbidden" ? tr("forbidden") : r.code === "sign-in-required" ? tr("signIn") : r.code === "not-found" ? tr("forbidden")
232
+ : r.code === "invalid-grant" || r.code === "invalid-grant-origin" ? tr("grantInvalid") : tr("failed", r.code), false);
233
+ return false;
234
+ }
235
+ await reread(tr("uncertain"));
236
+ return false;
237
+ } finally { sending.current = false; setBusy(false); }
238
+ };
239
+ // A click decides (Always allow opens its rule first). Before verification the buttons are off: nothing to press.
240
+ const press = (which) => {
241
+ if (!canDecide || readFailed) return;
242
+ if (which === "always") { setGrantOpen(true); return; }
243
+ void decide(which === "decline" ? "decline" : "approve-once");
244
+ };
245
+ const people = candidatePeople(card);
246
+ // Continue (a root: this request and its follow-ups) and Approve once (a legacy one-message forward) are different
247
+ // decisions, so they keep different words. The grant button has the grant editor's own name (#4497 capture check).
248
+ const label = (which) => (which === "continue" ? (root ? tr("continue") : tr("approveOnce")) : which === "always" ? ca("grantSet") : tr("decline"));
249
+ const stateText = st === "approved" && root ? tr("state_approved_root") : ca(`state_${st}`);
250
+ const outcome = st === "approved" || st === "delivered" ? `${tr("forwardedTo", card.targetLabel)} ` : "";
251
+ const saveRule = (c) => {
252
+ const grant = grantFromChoice(card, c);
253
+ if (!grant) { toast(tr("grantInvalid"), false); return false; }
254
+ return decide("approve-once", grant);
255
+ };
256
+ const links = openHref ? html`<a class="btn btn-sm btn-ghost rc-open" href=${openHref}>${ca("needsOpen")}</a>` : null;
257
+ const button = (which, cls) => html`<button type="button" class=${`btn btn-sm${cls}`}
258
+ disabled=${busy || readFailed || !canDecide || (which === "always" && !grantable)} data-choice=${which} onClick=${() => press(which)}>${label(which)}</button>`;
259
+
260
+ // The one-card style the user approved for the credits card (the leader, #4492 merge note): a standard Needs-you item —
261
+ // a one-line title, one line of detail (the reason), the rest folded, then normal-size buttons; no raised card.
262
+ const actions = open && (canDecide || needsVerify);
263
+ return html`<article data-trust="permission" class=${`n-item rc-card${focus ? " rc-focus" : ""}`} data-ticket=${tk.id} data-state=${st} data-engine=${card.engine}>
264
+ <span class="n-icon"><${Icon} name="key" size=${18} /></span>
265
+ <div class="n-body">
266
+ <div class="n-title"><strong>${ca("needsTitle", card.sourceLabel, card.targetLabel)}</strong><span class="n-age">${clockOf(tk.createdAt)}</span></div>
267
+ <p class="n-detail rc-reason" data-reason=${card.reason}>${st !== "pending" ? html`<span class=${`tag rc-state${TONE[st] === "ok" ? " s-state ok" : TONE[st] === "bad" ? " s-state bad" : ""}`}>${stateText}</span> ` : null}${outcome ? html`<span class="rc-outcome">${outcome}</span>` : null}${card.continuedFrom ? tr("continuedFrom", shortId(card.continuedFrom)) : reasonText(card)}${open ? html` <span class="rc-scope" data-scope=${card.approvalScope}>${tr(root ? "scopeShortRoot" : "scopeShortOperation")}</span>` : null}</p>
268
+ <details class="n-raw rc-more"><summary>${ca("messageLabel")}</summary>
269
+ ${tk.message ? html`<pre class="n-raw-text rc-message">${tk.message}</pre>` : null}
270
+ <p class="rc-facts"><span class="rc-requester">${requesterText(card.requester)}</span>${INGRESS.has(card.ingress) ? html` · <span class="rc-ingress" data-ingress=${card.ingress}>${tr(`ingress_${card.ingress}`)}</span>` : null}${VERBS.has(tk.verb) ? html` · ${ca(`verb_${tk.verb}`)}` : null}</p>
271
+ ${card.returnAudience && AUDIENCE.has(card.returnAudience.kind) ? html`<p class="rc-return">${tr("repliesTo", tr(`audience_${card.returnAudience.kind}`))}</p>` : null}
272
+ <p class="rc-times" title=${`#${tk.id}`}>${ca("created", when(tk.createdAt))} · ${tk.decidedAt ? tr("decidedAt", when(tk.decidedAt)) : ca("expires", when(tk.expiresAt))}</p>
273
+ ${open ? html`<p class="rc-scope-more">${tr(root ? "scopeRoot" : "scopeOperation")}</p>` : null}
274
+ ${st === "delivered" ? html`<p>${ca("deliveryNote")}</p>` : null}
275
+ </details>
276
+ ${readFailed ? html`<p class="n-detail rc-read-failed" role="status">${tr("readFailed")} <button type="button" class="btn btn-sm rc-read-again" disabled=${busy} onClick=${() => void readCard()}>${tr("readRetry")}</button></p>` : null}
277
+ ${granted ? html`<p class="n-detail"><a class="st-link rc-grant-view" href=${`${detailsPath(tk.target)}?cat=permissions`}>${tr("grantView")}</a></p>` : null}
278
+ ${actions && needsVerify ? html`<div class="rc-verify" role="group" aria-label=${tr("verifyTitle")}><span>${tr("verifyTitle")}</span>${authorizeControl(auth)}</div>` : null}
279
+ ${actions ? html`<div class="n-actions rc-decide">${button("continue", " btn-primary")}${button("always", "")}${button("decline", " btn-ghost")}${links}</div>
280
+ ${!grantable ? html`<p class="n-detail rc-no-grant">${tr("noGrant")}</p>` : null}` : links ? html`<div class="n-actions">${links}</div>` : null}
281
+ ${grantOpen && grantable && canDecide ? html`<${ContactGrantEditor} key=${`${tk.id}:${card.snapshot.ticketRevision}`} people=${people} keyOf=${(p) => p.key}
282
+ source=${card.sourceLabel} target=${card.targetLabel} verb=${tk.verb}
283
+ title=${ca(people.length === 1 ? "grantSetOneTitle" : "allowPeopleTitle")}
284
+ onClose=${() => setGrantOpen(false)} onSave=${saveRule} />` : null}
285
+ </div>
286
+ </article>`;
287
+ }
@@ -0,0 +1,83 @@
1
+ // M-3736 J (S-228; slice I's contract: docs/design/request-contact-same-card-api.md, version 1): the web client of the
2
+ // same-card contact API, /ui/api/request-contact-authorizations. A module of its own (the module-skew rule): the older
3
+ // contact-auth-client.js keeps serving the old namespace while the new host is not installed.
4
+ // Same-origin fetch: the page's sign-in and write protection are added by the shell. The server resolves who is asking;
5
+ // nothing here sends an identity, a person or an engine as authority.
6
+ // Every result is { ok: true, data } or { ok: false, status, code }. `code` is the server's stable error
7
+ // ({ error: <code> }) when it is one this page words, else the status's own: 401 sign-in-required, 403 forbidden,
8
+ // 404 not-found, 409 conflict, 503 unavailable, anything else (a network error included) failed.
9
+ // A decision is never retried here, after any failure or an unknown network outcome: the caller reads the same card.
10
+
11
+ const BASE = "/ui/api/request-contact-authorizations";
12
+ /** The stable error codes the contract lists (§3). */
13
+ export const RC_CODES = new Set(["invalid-request", "invalid-grant", "sign-in-required", "forbidden", "verification-required", "not-found",
14
+ "conflict", "policy-conflict", "operation-conflict", "expired", "already-decided", "stale-generation", "unavailable",
15
+ "upgrade-required", "invalid-grant-origin", "invalid-cursor"]);
16
+ /** The 409s that mean "it was decided or changed elsewhere": read the same card again and show its outcome. */
17
+ export const RC_REREAD = new Set(["conflict", "policy-conflict", "operation-conflict", "expired", "already-decided", "stale-generation"]);
18
+ const byStatus = (s) => (s === 401 ? "sign-in-required" : s === 403 ? "forbidden" : s === 404 ? "not-found" : s === 409 ? "conflict" : s === 503 ? "unavailable" : s === 400 ? "invalid-request" : "failed");
19
+ /** A ticket id as the server makes them: R + a UUID. Anything else is never put in a path. */
20
+ export const RC_ID = /^R[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
21
+
22
+ async function call(method, url, body) {
23
+ let r;
24
+ try {
25
+ r = await fetch(url, { method, credentials: "same-origin", ...(body === undefined ? {} : { headers: { "content-type": "application/json" }, body: JSON.stringify(body) }) });
26
+ } catch { return { ok: false, status: 0, code: "failed" }; }
27
+ if (!r.ok) {
28
+ let code = byStatus(r.status);
29
+ let message = null;
30
+ try { const b = await r.json(); const c = b && b.error; if (typeof c === "string" && RC_CODES.has(c)) code = c; if (b && typeof b.message === "string") message = b.message.slice(0, 500); } catch { /* no body: the status's own code */ }
31
+ // upgrade-required (409): the server's own words (its locale) — the request stays held until its target is upgraded.
32
+ return { ok: false, status: r.status, code, ...(message && code === "upgrade-required" ? { message } : {}) };
33
+ }
34
+ try { return { ok: true, data: await r.json() }; } catch { return { ok: false, status: r.status, code: "failed" }; }
35
+ }
36
+
37
+ /** RequestContactCardPageV1 { version, items, nextCursor }; filters: agent, status ("pending" by default on the server), cursor. */
38
+ export function listCards(filters = {}) {
39
+ const q = new URLSearchParams();
40
+ for (const k of ["agent", "status", "cursor"]) if (filters[k]) q.set(k, String(filters[k]));
41
+ const s = q.toString();
42
+ return call("GET", `${BASE}${s ? `?${s}` : ""}`);
43
+ }
44
+ /** One RequestContactCardV1. */
45
+ export const getCard = (id) => (RC_ID.test(String(id)) ? call("GET", `${BASE}/${id}`) : Promise.resolve({ ok: false, status: 404, code: "not-found" }));
46
+ /**
47
+ * A decision on the card the person saw: its snapshot exactly as read, "approve-once" or "decline", and for Always allow
48
+ * the existing strict grant object (personKeys only from the card's grantCandidates). 200 → the fresh card.
49
+ */
50
+ export function decideCard(card, decision, grant) {
51
+ if (!card || !RC_ID.test(String(card.ticket && card.ticket.id))) return Promise.resolve({ ok: false, status: 400, code: "invalid-request" });
52
+ const s = card.snapshot || {};
53
+ return call("POST", `${BASE}/${card.ticket.id}/decision`, {
54
+ snapshot: { ticketRevision: s.ticketRevision, policyRevision: s.policyRevision, imageSha256: s.imageSha256 },
55
+ decision, ...(grant ? { grant } : {}),
56
+ });
57
+ }
58
+
59
+ /**
60
+ * Is the same-card host installed here? Read once per page load, from the collection (Sentinel, #4492): 200 → "on" (the
61
+ * V1 card everywhere; each card's own approvalScope says what a decision covers), 404 → "off" (the dormant host, no
62
+ * inventory: today's cards). Anything else — 401, 403, 503, a network failure — is "unknown": never a reason to fall back
63
+ * to today's less-scoped reads; the page says why and asks again later (it is not remembered).
64
+ */
65
+ let state = null, lastCode = null, asking = null;
66
+ export function sameCardState() {
67
+ if (state) return Promise.resolve(state);
68
+ asking ??= (async () => {
69
+ let r = null;
70
+ try { r = await fetch(`${BASE}?status=pending`, { credentials: "same-origin" }); } catch { r = null; }
71
+ finally { asking = null; }
72
+ if (r && r.ok) { state = "on"; return state; }
73
+ if (r && r.status === 404) { state = "off"; return state; }
74
+ lastCode = r ? byStatus(r.status) : "failed";
75
+ try { const b = r ? await r.json() : null; if (b && typeof b.error === "string" && RC_CODES.has(b.error)) lastCode = b.error; } catch { /* the status's own code */ }
76
+ return "unknown";
77
+ })();
78
+ return asking;
79
+ }
80
+ /** Why the last answer was "unknown" (a stable code: sign-in-required, forbidden, verification-required, unavailable, failed…). */
81
+ export const sameCardUnknownCode = () => lastCode;
82
+ /** Tests, and a page that learns the host changed (a reload does the same). */
83
+ export function resetSameCardActive() { state = null; lastCode = null; asking = null; }
@@ -0,0 +1,78 @@
1
+ // M-3736 J (S-228): Fleet → Authorizations once the same-card host is installed (request-contact-client.js decides; until
2
+ // then contact-authorizations.js keeps today's page). The server scopes the list to the requests this session's person
3
+ // may manage (32 a page, then a cursor); the page sends no person, only an agent and a status.
4
+ // - Show: waiting (default) or all; one agent. ?ticket=<id> opens that request at the top (Needs you, a chat badge).
5
+ // - Each request is the one card (request-contact-card.js). It reads again on the stream's contact-auth frame and when the
6
+ // page is shown again (no timer); a cursor the server refused (its role snapshot changed) starts the list again.
7
+ import { html, useEffect, useState } from "/assets/app-html.js";
8
+ import { register, t } from "/assets/app-i18n.js";
9
+ import { appStore, useStore } from "/assets/app-store.js";
10
+ import { Skeleton, ErrorState, Empty } from "/assets/ui-states.js";
11
+ import { labelOf } from "/assets/instance-nav.js";
12
+ import { ca } from "./contact-auth-strings.js";
13
+ import { RequestContactCard } from "./request-contact-card.js";
14
+ import { getCard, listCards, RC_ID } from "./request-contact-client.js";
15
+
16
+ register("rcpage", {
17
+ en: { lead: "Contact requests between agents that wait for an admin, and what was decided.", forbidden: "You don't manage the agents these requests are for.",
18
+ signIn: "Sign in to see contact requests.", unavailable: "Contact requests are unavailable right now. Try again in a moment.", failed: "Couldn't load contact requests.", retry: "Try again" },
19
+ "zh-TW": { lead: "Agent 之間等待管理員處理的聯絡申請,以及處理結果。", forbidden: "你沒有管理這些申請所屬的 Agent。",
20
+ signIn: "請登入後查看聯絡申請。", unavailable: "目前無法取得聯絡申請,請稍後再試。", failed: "無法載入聯絡申請。", retry: "重試" },
21
+ });
22
+ const tp = (k, ...a) => t(`rcpage.${k}`, ...a);
23
+ /** Why the requests can't be shown (the host's answer was a refusal or a failure), with Try again. */
24
+ export function SameCardUnknown({ code, onRetry }) {
25
+ const said = code === "sign-in-required" ? tp("signIn") : code === "forbidden" ? tp("forbidden") : code === "unavailable" ? tp("unavailable") : tp("failed");
26
+ return html`<div class="rc-unknown" data-code=${code || "failed"}><p class="note">${said}</p>
27
+ ${code === "sign-in-required" || code === "forbidden" ? null : html`<button type="button" class="btn btn-sm" onClick=${onRetry}>${tp("retry")}</button>`}</div>`;
28
+ }
29
+ const ticketFromSearch = () => { try { const v = new URLSearchParams(location.search).get("ticket"); return v && RC_ID.test(v) ? v : null; } catch { return null; } };
30
+
31
+ export function RequestContactAuthorizations() {
32
+ const { instances } = useStore(appStore);
33
+ const [status, setStatus] = useState("pending");
34
+ const [agent, setAgent] = useState("");
35
+ const [page, setPage] = useState({ loading: true, items: [], next: null });
36
+ const [focus, setFocus] = useState(null);
37
+ const focusId = ticketFromSearch();
38
+ const filters = { status: status === "pending" ? "pending" : "all", ...(agent ? { agent } : {}) };
39
+ const read = async (cursor) => {
40
+ const r = await listCards({ ...filters, ...(cursor ? { cursor } : {}) });
41
+ if (!r.ok) {
42
+ if (cursor && (r.code === "invalid-cursor" || r.status === 409)) { void read(); return; } // its role snapshot changed: from the top
43
+ setPage((p) => ({ ...p, loading: false, error: r.code })); return;
44
+ }
45
+ const items = Array.isArray(r.data.items) ? r.data.items : [];
46
+ setPage((p) => ({ loading: false, items: cursor ? [...p.items, ...items] : items, next: r.data.nextCursor || null }));
47
+ };
48
+ const readFocus = async () => { if (!focusId) return; const r = await getCard(focusId); setFocus(r.ok ? r.data : null); };
49
+ const key = JSON.stringify(filters);
50
+ useEffect(() => {
51
+ setPage({ loading: true, items: [], next: null });
52
+ void read(); void readFocus();
53
+ const sub = appStore.get().streamOn;
54
+ const off = typeof sub === "function" ? sub("contact-auth", () => { void read(); void readFocus(); }) : null;
55
+ const onShow = () => { if (document.visibilityState === "visible") { void read(); void readFocus(); } };
56
+ document.addEventListener("visibilitychange", onShow);
57
+ return () => { if (typeof off === "function") off(); document.removeEventListener("visibilitychange", onShow); };
58
+ }, [key, focusId]);
59
+ const replace = (c) => { setPage((p) => ({ ...p, items: p.items.map((x) => (x.ticket.id === c.ticket.id ? c : x)) })); if (focus && focus.ticket.id === c.ticket.id) setFocus(c); };
60
+ const names = (instances || []).map((i) => i.name).filter(Boolean).sort();
61
+ const list = page.items.filter((x) => !focus || x.ticket.id !== focus.ticket.id);
62
+ return html`<div class="contact-auth-page rc-page">
63
+ <p class="s-page-lead">${tp("lead")}</p>
64
+ <div class="us-bar-top contact-filters">
65
+ <div class="seg-inline" role="group" aria-label=${ca("filterStatus")}>${["pending", "all"].map((s) => html`<button key=${s} type="button" class=${`btn btn-sm${status === s ? " btn-primary" : ""}`}
66
+ aria-pressed=${status === s ? "true" : "false"} onClick=${() => setStatus(s)}>${ca(`filter_${s}`)}</button>`)}</div>
67
+ <label class="us-group contact-agent-filter"><span>${ca("filterAgent")}</span><select value=${agent} onChange=${(e) => setAgent(e.currentTarget.value)}>
68
+ <option value="">${ca("filterAny")}</option>${names.map((n) => html`<option key=${n} value=${n}>${labelOf((instances || []).find((i) => i.name === n))}</option>`)}</select></label>
69
+ </div>
70
+ ${focus ? html`<${RequestContactCard} key=${`f:${focus.ticket.id}`} card=${focus} focus=${true} onChange=${replace} />` : null}
71
+ ${page.loading ? html`<${Skeleton} variant="cards" lines=${2} label=${ca("loading")} />`
72
+ : page.error && !page.items.length ? (page.error === "forbidden" ? html`<p class="note">${tp("forbidden")}</p>`
73
+ : html`<${ErrorState} message=${ca(page.error === "unavailable" ? "unavailable" : "loadFailed")} onRetry=${() => void read()} />`)
74
+ : !list.length && !focus ? html`<${Empty} icon="key" title=${ca(status === "pending" ? "emptyPending" : "empty")} action=${status === "pending" ? html`<button type="button" class="btn btn-sm" onClick=${() => setStatus("all")}>${ca("viewAll")}</button>` : null} />`
75
+ : html`<div class="contact-ticket-list">${list.map((c) => html`<${RequestContactCard} key=${c.ticket.id} card=${c} onChange=${replace} />`)}</div>`}
76
+ ${page.next ? html`<div class="field-row"><button type="button" class="btn btn-sm" onClick=${() => void read(page.next)}>${ca("more")}</button></div>` : null}
77
+ </div>`;
78
+ }