@tangle-network/agent-app 0.61.4 → 0.62.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (310) hide show
  1. package/dist/{DesignCanvas-L6J72JQ2.js → DesignCanvas-IQKYAEC4.js} +3 -2
  2. package/dist/{DesignCanvasEditor-QFQD63MR.js → DesignCanvasEditor-O7OCZTGC.js} +5 -4
  3. package/dist/{TimelineEditor-7KBPJQLT.js → TimelineEditor-VB2UJ34D.js} +4 -2
  4. package/dist/VaultPane-AYW7CO33.js +8 -0
  5. package/dist/agent-profiles/d1.js +1 -1
  6. package/dist/agent-profiles/index.d.ts +0 -82
  7. package/dist/agent-profiles/index.js +1 -21
  8. package/dist/agent-profiles/self-management.d.ts +0 -55
  9. package/dist/alerting/index.d.ts +1 -1
  10. package/dist/alerting/index.js +1 -3
  11. package/dist/alerting/slack.d.ts +6 -79
  12. package/dist/app-auth/drizzle.d.ts +17 -271
  13. package/dist/app-auth/drizzle.js +6 -2
  14. package/dist/app-auth/drizzle.js.map +1 -1
  15. package/dist/app-auth/index.js +3 -3
  16. package/dist/assets/types.d.ts +2 -1
  17. package/dist/assistant/AssistantPanel.d.ts +1 -1
  18. package/dist/assistant/index.js +635 -392
  19. package/dist/assistant/index.js.map +1 -1
  20. package/dist/billing/identity-locks.d.ts +5 -0
  21. package/dist/billing/index.js +1 -1
  22. package/dist/brand-extraction/index.js.map +1 -1
  23. package/dist/brand-extraction/types.d.ts +2 -1
  24. package/dist/chat-react/index.js +6 -5
  25. package/dist/chat-routes/attachment-write-safety.d.ts +4 -0
  26. package/dist/chat-routes/draft-persistence.d.ts +2 -14
  27. package/dist/chat-routes/index.d.ts +1 -0
  28. package/dist/chat-routes/index.js +853 -773
  29. package/dist/chat-routes/index.js.map +1 -1
  30. package/dist/chat-routes/sandbox-model-source.d.ts +20 -0
  31. package/dist/chat-routes/stored-attachments.d.ts +18 -0
  32. package/dist/chat-routes/turn-admission.d.ts +1 -1
  33. package/dist/chat-routes/turn-execution.d.ts +2 -2
  34. package/dist/chat-routes/turn-route-contracts.d.ts +3 -29
  35. package/dist/chat-store/core.d.ts +19 -1
  36. package/dist/chat-store/index.js.map +1 -1
  37. package/dist/chat-store/store.d.ts +3 -29
  38. package/dist/{chunk-ATQQCG4I.js → chunk-2VJLLRVV.js} +2 -2
  39. package/dist/{chunk-4LBCTFBP.js → chunk-4MD5PS4F.js} +5 -1
  40. package/dist/{chunk-4LBCTFBP.js.map → chunk-4MD5PS4F.js.map} +1 -1
  41. package/dist/{chunk-R4X5474U.js → chunk-52SDU43B.js} +12 -27
  42. package/dist/chunk-52SDU43B.js.map +1 -0
  43. package/dist/{chunk-MDRH3SDA.js → chunk-54YIL7WM.js} +3 -3
  44. package/dist/{chunk-6QJ3GB3A.js → chunk-5GSZGTPJ.js} +2 -2
  45. package/dist/{chunk-5IM2CLYX.js → chunk-6JEDSKFH.js} +232 -218
  46. package/dist/chunk-6JEDSKFH.js.map +1 -0
  47. package/dist/{chunk-6PRQ45QE.js → chunk-6OG4244Y.js} +1 -1
  48. package/dist/chunk-6OG4244Y.js.map +1 -0
  49. package/dist/{chunk-ZDPUC6CM.js → chunk-6ZVSMA4T.js} +3 -3
  50. package/dist/{chunk-TXUAGSFR.js → chunk-76MPX7JQ.js} +47 -1
  51. package/dist/chunk-76MPX7JQ.js.map +1 -0
  52. package/dist/{chunk-BOQ4HVVH.js → chunk-7ISHKBAD.js} +61 -52
  53. package/dist/chunk-7ISHKBAD.js.map +1 -0
  54. package/dist/chunk-7PULOECS.js +22 -0
  55. package/dist/chunk-7PULOECS.js.map +1 -0
  56. package/dist/{chunk-KJODHPWM.js → chunk-CPVGRQ43.js} +511 -339
  57. package/dist/chunk-CPVGRQ43.js.map +1 -0
  58. package/dist/{chunk-LO6VQ35O.js → chunk-CQZVJVME.js} +2 -2
  59. package/dist/{chunk-Y43PXON2.js → chunk-EFQUAWWF.js} +577 -546
  60. package/dist/chunk-EFQUAWWF.js.map +1 -0
  61. package/dist/{chunk-FPNZMIAW.js → chunk-ELX5YITO.js} +1 -1
  62. package/dist/chunk-ELX5YITO.js.map +1 -0
  63. package/dist/chunk-FGAROAUF.js +19 -0
  64. package/dist/chunk-FGAROAUF.js.map +1 -0
  65. package/dist/{chunk-HN6MZ2XL.js → chunk-FTNGGR37.js} +641 -466
  66. package/dist/chunk-FTNGGR37.js.map +1 -0
  67. package/dist/{chunk-G4F2NWZH.js → chunk-FZ3ZFVAC.js} +4 -4
  68. package/dist/{chunk-UCCSJX64.js → chunk-GIEUZBQQ.js} +1112 -644
  69. package/dist/chunk-GIEUZBQQ.js.map +1 -0
  70. package/dist/{chunk-MEKOWH5E.js → chunk-IVBREL7A.js} +785 -526
  71. package/dist/chunk-IVBREL7A.js.map +1 -0
  72. package/dist/{chunk-WSEXFTN4.js → chunk-JBXNU5WD.js} +26 -26
  73. package/dist/chunk-JBXNU5WD.js.map +1 -0
  74. package/dist/{chunk-F2VX6TTJ.js → chunk-JRCZHDRG.js} +2 -41
  75. package/dist/chunk-JRCZHDRG.js.map +1 -0
  76. package/dist/{chunk-LXYQOOXU.js → chunk-JRW6LCIA.js} +552 -302
  77. package/dist/chunk-JRW6LCIA.js.map +1 -0
  78. package/dist/{chunk-TVPH5T4F.js → chunk-KS4I7KVC.js} +16 -22
  79. package/dist/{chunk-TVPH5T4F.js.map → chunk-KS4I7KVC.js.map} +1 -1
  80. package/dist/{chunk-J2BBYVGF.js → chunk-MRZP65DZ.js} +1 -117
  81. package/dist/chunk-MRZP65DZ.js.map +1 -0
  82. package/dist/{chunk-L7LQRJGD.js → chunk-MVKMDROU.js} +48 -48
  83. package/dist/{chunk-L7LQRJGD.js.map → chunk-MVKMDROU.js.map} +1 -1
  84. package/dist/{chunk-4ZSLX3LY.js → chunk-OODZCBSM.js} +1 -1
  85. package/dist/chunk-OODZCBSM.js.map +1 -0
  86. package/dist/chunk-P4RRC4AO.js +47 -0
  87. package/dist/chunk-P4RRC4AO.js.map +1 -0
  88. package/dist/{chunk-ORQD4AUO.js → chunk-PCAY23GS.js} +1 -6
  89. package/dist/chunk-PCAY23GS.js.map +1 -0
  90. package/dist/{chunk-NMZUW6VJ.js → chunk-PEJ5OP5B.js} +3 -3
  91. package/dist/chunk-PEJ5OP5B.js.map +1 -0
  92. package/dist/{chunk-NHYRIM4I.js → chunk-PIPNDZ6H.js} +304 -194
  93. package/dist/chunk-PIPNDZ6H.js.map +1 -0
  94. package/dist/chunk-UHSUY6H6.js +79 -0
  95. package/dist/chunk-UHSUY6H6.js.map +1 -0
  96. package/dist/{chunk-PDD5A43Y.js → chunk-UTL6TEN6.js} +3 -3
  97. package/dist/{chunk-VJBFCNAU.js → chunk-UW2DKTEM.js} +123 -130
  98. package/dist/chunk-UW2DKTEM.js.map +1 -0
  99. package/dist/{chunk-S27DKRI6.js → chunk-VDYEVCQQ.js} +2 -2
  100. package/dist/{chunk-UFQM46NV.js → chunk-VK3F4N4U.js} +2 -2
  101. package/dist/{chunk-6ZIC6OG5.js → chunk-VYBTQK25.js} +126 -122
  102. package/dist/chunk-VYBTQK25.js.map +1 -0
  103. package/dist/{chunk-RL3Z747H.js → chunk-W2BV2XOC.js} +1491 -700
  104. package/dist/chunk-W2BV2XOC.js.map +1 -0
  105. package/dist/{chunk-FUZETA6Z.js → chunk-X6SZGQTK.js} +2 -2
  106. package/dist/{chunk-CD2LQXY6.js → chunk-XOHE6SKU.js} +14 -16
  107. package/dist/{chunk-CD2LQXY6.js.map → chunk-XOHE6SKU.js.map} +1 -1
  108. package/dist/{chunk-ZBB5KQ6B.js → chunk-Y3GO6SG3.js} +73 -66
  109. package/dist/chunk-Y3GO6SG3.js.map +1 -0
  110. package/dist/chunk-ZAMHLXNS.js +56 -0
  111. package/dist/chunk-ZAMHLXNS.js.map +1 -0
  112. package/dist/{chunk-RHFN7TUV.js → chunk-ZDHCV462.js} +47 -44
  113. package/dist/{chunk-RHFN7TUV.js.map → chunk-ZDHCV462.js.map} +1 -1
  114. package/dist/chunk-ZOS3D26Z.js +72 -0
  115. package/dist/chunk-ZOS3D26Z.js.map +1 -0
  116. package/dist/design-canvas/index.js +32 -32
  117. package/dist/design-canvas/index.js.map +1 -1
  118. package/dist/design-canvas-react/components/DesignCanvas.d.ts +1 -1
  119. package/dist/design-canvas-react/components/Workspace.d.ts +1 -1
  120. package/dist/design-canvas-react/components/glyphs.d.ts +31 -40
  121. package/dist/design-canvas-react/components/transform-math.d.ts +0 -8
  122. package/dist/design-canvas-react/components/use-workspace-keyboard.d.ts +2 -2
  123. package/dist/design-canvas-react/contracts.d.ts +2 -2
  124. package/dist/design-canvas-react/engine.js +1 -1
  125. package/dist/design-canvas-react/index.js +9 -7
  126. package/dist/design-canvas-react/index.js.map +1 -1
  127. package/dist/design-canvas-react/lazy.js +1 -1
  128. package/dist/eval/calibration.d.ts +1 -38
  129. package/dist/eval/index.d.ts +2 -4
  130. package/dist/eval/index.js +0 -84
  131. package/dist/eval/index.js.map +1 -1
  132. package/dist/harness/index.d.ts +1 -1
  133. package/dist/harness/index.js +1 -1
  134. package/dist/harness/session-selection.d.ts +2 -2
  135. package/dist/hub-approvals/index.js +1 -1
  136. package/dist/hub-approvals/result.d.ts +1 -1
  137. package/dist/hub-approvals-react/index.js +4 -4
  138. package/dist/hub-approvals-react/index.js.map +1 -1
  139. package/dist/hub-approvals-react/parts.d.ts +1 -1
  140. package/dist/launch-invariants/cli.js +4 -4
  141. package/dist/launch-invariants/index.js +3 -3
  142. package/dist/launch-invariants/testing.js +4 -4
  143. package/dist/legibility/cli.js +1 -1
  144. package/dist/legibility/index.js +1 -1
  145. package/dist/{mention-editor-B23OMFT2.js → mention-editor-4BKBMWIK.js} +83 -57
  146. package/dist/mention-editor-4BKBMWIK.js.map +1 -0
  147. package/dist/missions/index.js +144 -137
  148. package/dist/missions/index.js.map +1 -1
  149. package/dist/operator/index.js +1 -1
  150. package/dist/peer-floors/check.js +1 -1
  151. package/dist/peer-floors/cli.js +6 -14
  152. package/dist/peer-floors/cli.js.map +1 -1
  153. package/dist/peer-floors/source-entries.d.ts +6 -0
  154. package/dist/platform/index.js +10 -10
  155. package/dist/preset-cloudflare/index.js +2 -2
  156. package/dist/profile/index.d.ts +0 -1
  157. package/dist/profile/index.js +1 -422
  158. package/dist/profile/index.js.map +1 -1
  159. package/dist/profile-editor/server.d.ts +0 -1
  160. package/dist/profile-editor/server.js +0 -1
  161. package/dist/profile-editor/server.js.map +1 -1
  162. package/dist/public-consultation/index.d.ts +2 -2
  163. package/dist/public-consultation/index.js +6 -6
  164. package/dist/record/drizzle.js +156 -148
  165. package/dist/record/drizzle.js.map +1 -1
  166. package/dist/runtime/index.js +4 -4
  167. package/dist/runtime/router-turn.js +3 -3
  168. package/dist/sandbox/index.js +8 -6
  169. package/dist/sandbox/transient-failure.d.ts +2 -0
  170. package/dist/sequences/drizzle.js +5 -15
  171. package/dist/sequences/drizzle.js.map +1 -1
  172. package/dist/sequences/index.d.ts +1 -0
  173. package/dist/sequences/index.js +18 -14
  174. package/dist/sequences/index.js.map +1 -1
  175. package/dist/sequences/row-mapping.d.ts +7 -0
  176. package/dist/sequences-react/components/TimelineEditor.d.ts +0 -40
  177. package/dist/sequences-react/components/TimelineHistory.d.ts +31 -0
  178. package/dist/sequences-react/components/glyphs.d.ts +12 -21
  179. package/dist/sequences-react/components/index.d.ts +0 -2
  180. package/dist/sequences-react/components/interaction-math.d.ts +3 -3
  181. package/dist/sequences-react/contracts.d.ts +1 -1
  182. package/dist/sequences-react/engine/snap.d.ts +2 -2
  183. package/dist/sequences-react/index.js +4 -4
  184. package/dist/sequences-react/index.js.map +1 -1
  185. package/dist/settings-react/index.js +13 -30
  186. package/dist/settings-react/index.js.map +1 -1
  187. package/dist/settings-react/timezone-picker.d.ts +0 -6
  188. package/dist/signoff/browser-budget.d.ts +6 -1
  189. package/dist/signoff/cli.d.ts +0 -7
  190. package/dist/signoff/cli.js +1 -2
  191. package/dist/signoff/cli.js.map +1 -1
  192. package/dist/signoff/index.js +1 -1
  193. package/dist/skills/index.d.ts +1 -1
  194. package/dist/skills/index.js +5 -25
  195. package/dist/skills/marketplace.d.ts +1 -75
  196. package/dist/skills-placement/box.js +3 -4
  197. package/dist/skills-placement/box.js.map +1 -1
  198. package/dist/skills-placement/index.js +3 -4
  199. package/dist/spend/cli-args.d.ts +1 -1
  200. package/dist/spend/cli.js +3 -3
  201. package/dist/spend/cli.js.map +1 -1
  202. package/dist/spend/index.js +1 -1
  203. package/dist/stories/design-canvas/fixtures.d.ts +1 -14
  204. package/dist/stream/index.js +17 -17
  205. package/dist/studio/generation.d.ts +1 -1
  206. package/dist/studio/index.js +1 -1
  207. package/dist/studio-react/index.js +353 -184
  208. package/dist/studio-react/index.js.map +1 -1
  209. package/dist/studio-react/studio-composer.d.ts +1 -5
  210. package/dist/studio-react/studio-history-screen.d.ts +1 -1
  211. package/dist/teams/invitations-api.d.ts +3 -3
  212. package/dist/teams/invitations-api.js +74 -72
  213. package/dist/teams/invitations-api.js.map +1 -1
  214. package/dist/teams/member-sync.d.ts +2 -0
  215. package/dist/teams/members-api.d.ts +2 -2
  216. package/dist/teams/members-api.js +1 -1
  217. package/dist/teams-react/index.js +28 -45
  218. package/dist/teams-react/index.js.map +1 -1
  219. package/dist/tools/index.js +1 -1
  220. package/dist/tools/mcp-arguments.d.ts +1 -1
  221. package/dist/trace/index.d.ts +1 -18
  222. package/dist/trace/index.js +1 -36
  223. package/dist/trace/index.js.map +1 -1
  224. package/dist/trace/mission-flow.d.ts +1 -59
  225. package/dist/turn-health/index.d.ts +1 -1
  226. package/dist/turn-health/index.js +2 -2
  227. package/dist/turn-health/sink.d.ts +2 -1
  228. package/dist/turn-trace/index.js +2 -4
  229. package/dist/turn-trace/recorder.d.ts +0 -2
  230. package/dist/vault/VaultPane.d.ts +0 -20
  231. package/dist/vault/VaultPaneOperations.d.ts +318 -0
  232. package/dist/vault/index.js +2 -1
  233. package/dist/vault/index.js.map +1 -1
  234. package/dist/vault/lazy.js +1 -1
  235. package/dist/web-react/agent-profile-editor.d.ts +1 -2
  236. package/dist/web-react/agent-profile-editor.js +6 -5
  237. package/dist/web-react/chat-composer.d.ts +1 -1
  238. package/dist/web-react/durable-plan-flow.d.ts +6 -1
  239. package/dist/web-react/editor-glyphs.d.ts +12 -0
  240. package/dist/web-react/focus-navigation.d.ts +12 -0
  241. package/dist/web-react/history-controls.d.ts +37 -0
  242. package/dist/web-react/index.js +36 -34
  243. package/dist/web-react/interaction-question-card.d.ts +1 -1
  244. package/dist/web-react/record-grid-writes.d.ts +31 -0
  245. package/dist/web-react/record-grid.d.ts +1 -48
  246. package/dist/web-react/session-history-panel.d.ts +1 -9
  247. package/dist/web-react/use-document-dark.d.ts +1 -0
  248. package/dist/workspace-export/engine.d.ts +1 -6
  249. package/dist/workspace-export/index.js +198 -185
  250. package/dist/workspace-export/index.js.map +1 -1
  251. package/dist/workspace-export/routes.d.ts +1 -1
  252. package/dist/workspace-react/index.js +9 -8
  253. package/dist/workspace-react/index.js.map +1 -1
  254. package/package.json +1 -11
  255. package/dist/VaultPane-RXL3WLA2.js +0 -7
  256. package/dist/agent-profiles/reaper.d.ts +0 -31
  257. package/dist/agent-profiles/reaper.js +0 -29
  258. package/dist/agent-profiles/reaper.js.map +0 -1
  259. package/dist/chunk-4ZSLX3LY.js.map +0 -1
  260. package/dist/chunk-5IM2CLYX.js.map +0 -1
  261. package/dist/chunk-6OSJNJA2.js +0 -251
  262. package/dist/chunk-6OSJNJA2.js.map +0 -1
  263. package/dist/chunk-6PRQ45QE.js.map +0 -1
  264. package/dist/chunk-6ZIC6OG5.js.map +0 -1
  265. package/dist/chunk-BDEBQ4WO.js +0 -38
  266. package/dist/chunk-BDEBQ4WO.js.map +0 -1
  267. package/dist/chunk-BOQ4HVVH.js.map +0 -1
  268. package/dist/chunk-F2VX6TTJ.js.map +0 -1
  269. package/dist/chunk-FPNZMIAW.js.map +0 -1
  270. package/dist/chunk-HN6MZ2XL.js.map +0 -1
  271. package/dist/chunk-J2BBYVGF.js.map +0 -1
  272. package/dist/chunk-KJODHPWM.js.map +0 -1
  273. package/dist/chunk-LTWJYNEC.js +0 -100
  274. package/dist/chunk-LTWJYNEC.js.map +0 -1
  275. package/dist/chunk-LXYQOOXU.js.map +0 -1
  276. package/dist/chunk-MEKOWH5E.js.map +0 -1
  277. package/dist/chunk-NHYRIM4I.js.map +0 -1
  278. package/dist/chunk-NMZUW6VJ.js.map +0 -1
  279. package/dist/chunk-ORQD4AUO.js.map +0 -1
  280. package/dist/chunk-R4X5474U.js.map +0 -1
  281. package/dist/chunk-RL3Z747H.js.map +0 -1
  282. package/dist/chunk-TXUAGSFR.js.map +0 -1
  283. package/dist/chunk-UCCSJX64.js.map +0 -1
  284. package/dist/chunk-VJBFCNAU.js.map +0 -1
  285. package/dist/chunk-WSEXFTN4.js.map +0 -1
  286. package/dist/chunk-Y43PXON2.js.map +0 -1
  287. package/dist/chunk-ZBB5KQ6B.js.map +0 -1
  288. package/dist/eval/parity.d.ts +0 -74
  289. package/dist/mention-editor-B23OMFT2.js.map +0 -1
  290. package/dist/profile/humanizer-skill.d.ts +0 -23
  291. package/dist/profile/humanizer-skill.vendored.d.ts +0 -4
  292. package/dist/sequences-react/components/BrandMark.d.ts +0 -10
  293. package/dist/skills/marketplace-drizzle.d.ts +0 -121
  294. package/dist/skills/marketplace-drizzle.js +0 -34
  295. package/dist/skills/marketplace-drizzle.js.map +0 -1
  296. package/dist/teams-react/components/BrandMark.d.ts +0 -10
  297. /package/dist/{DesignCanvas-L6J72JQ2.js.map → DesignCanvas-IQKYAEC4.js.map} +0 -0
  298. /package/dist/{DesignCanvasEditor-QFQD63MR.js.map → DesignCanvasEditor-O7OCZTGC.js.map} +0 -0
  299. /package/dist/{TimelineEditor-7KBPJQLT.js.map → TimelineEditor-VB2UJ34D.js.map} +0 -0
  300. /package/dist/{VaultPane-RXL3WLA2.js.map → VaultPane-AYW7CO33.js.map} +0 -0
  301. /package/dist/{chunk-ATQQCG4I.js.map → chunk-2VJLLRVV.js.map} +0 -0
  302. /package/dist/{chunk-MDRH3SDA.js.map → chunk-54YIL7WM.js.map} +0 -0
  303. /package/dist/{chunk-6QJ3GB3A.js.map → chunk-5GSZGTPJ.js.map} +0 -0
  304. /package/dist/{chunk-ZDPUC6CM.js.map → chunk-6ZVSMA4T.js.map} +0 -0
  305. /package/dist/{chunk-LO6VQ35O.js.map → chunk-CQZVJVME.js.map} +0 -0
  306. /package/dist/{chunk-G4F2NWZH.js.map → chunk-FZ3ZFVAC.js.map} +0 -0
  307. /package/dist/{chunk-PDD5A43Y.js.map → chunk-UTL6TEN6.js.map} +0 -0
  308. /package/dist/{chunk-S27DKRI6.js.map → chunk-VDYEVCQQ.js.map} +0 -0
  309. /package/dist/{chunk-UFQM46NV.js.map → chunk-VK3F4N4U.js.map} +0 -0
  310. /package/dist/{chunk-FUZETA6Z.js.map → chunk-X6SZGQTK.js.map} +0 -0
@@ -7,7 +7,7 @@ var MAX_DEPTH = 4;
7
7
  var MAX_KEYS = 24;
8
8
  var MAX_ITEMS = 50;
9
9
  var MAX_STRING = 600;
10
- function asRecord(value) {
10
+ function hubResultRecord(value) {
11
11
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
12
12
  }
13
13
  function unwrapHubResult(value) {
@@ -27,7 +27,7 @@ function unwrapHubResult(value) {
27
27
  }
28
28
  }
29
29
  for (let depth = 0; depth < 3; depth++) {
30
- const record = asRecord(current);
30
+ const record = hubResultRecord(current);
31
31
  const keys = Object.keys(record);
32
32
  const inner = keys.find((key) => key === "result" || key === "data");
33
33
  if (!inner || keys.length > 3 || record[inner] === null || typeof record[inner] !== "object") break;
@@ -57,7 +57,7 @@ function summarizeHubResult(result) {
57
57
  return bounded(unwrapHubResult(result), 0);
58
58
  }
59
59
  function readText(value, ...keys) {
60
- const record = asRecord(value);
60
+ const record = hubResultRecord(value);
61
61
  for (const key of keys) {
62
62
  const found = record[key];
63
63
  if (typeof found === "string" && found.trim()) return found.trim();
@@ -66,7 +66,7 @@ function readText(value, ...keys) {
66
66
  return void 0;
67
67
  }
68
68
  function readNumber(value, ...keys) {
69
- const record = asRecord(value);
69
+ const record = hubResultRecord(value);
70
70
  for (const key of keys) {
71
71
  const found = record[key];
72
72
  if (typeof found === "number" && Number.isFinite(found)) return found;
@@ -130,8 +130,8 @@ function list(value) {
130
130
  if (!Array.isArray(value)) return [];
131
131
  return value.flatMap((entry) => {
132
132
  if (typeof entry === "string" && entry.trim()) return [entry.trim()];
133
- const record = asRecord(entry);
134
- const address = text(record.email) ?? text(record.address) ?? text(asRecord(record.emailAddress).address);
133
+ const record = hubResultRecord(entry);
134
+ const address = text(record.email) ?? text(record.address) ?? text(hubResultRecord(record.emailAddress).address);
135
135
  return address ? [address] : [];
136
136
  });
137
137
  }
@@ -236,12 +236,12 @@ function branchOf(ref) {
236
236
  return text(ref)?.replace(/^refs\/heads\//, "");
237
237
  }
238
238
  function hubActionFiles(actionPath, input) {
239
- const fields = asRecord(input);
239
+ const fields = hubResultRecord(input);
240
240
  const { action } = splitHubActionPath(actionPath);
241
241
  const entries = action === "git.createTree" ? fields.tree : fields.files;
242
242
  if (!Array.isArray(entries)) return [];
243
243
  return entries.flatMap((entry) => {
244
- const item = asRecord(entry);
244
+ const item = hubResultRecord(entry);
245
245
  const path = text(item.path);
246
246
  if (!path) return [];
247
247
  const deleted = item.delete === true || item.sha === null && item.content === void 0;
@@ -255,7 +255,7 @@ function mergedFiles(declared, counted) {
255
255
  return declared.map((file) => byPath.get(file.path) ?? file);
256
256
  }
257
257
  function emailPreview(input, reply) {
258
- const from = asRecord(input.from);
258
+ const from = hubResultRecord(input.from);
259
259
  const htmlBody = typeof input.html === "string" ? input.html : void 0;
260
260
  return {
261
261
  kind: "email",
@@ -361,12 +361,12 @@ function sendEmail(verb, reply = false) {
361
361
  }
362
362
  function post(channel, reply = false, sponsored = false) {
363
363
  return (input) => {
364
- const container = asRecord(input.container);
364
+ const container = hubResultRecord(input.container);
365
365
  const body = [input.text, input.commentary, input.caption, input.message, container.caption, input.title].find((value) => typeof value === "string") ?? "";
366
366
  const url = text(input.url) ?? text(input.link);
367
367
  const where = { x: "X", linkedin: "LinkedIn", instagram: "Instagram", facebook: "Facebook", tiktok: "TikTok" }[channel];
368
368
  const media = (Array.isArray(input.media) ? input.media : []).flatMap((value) => {
369
- const entry = asRecord(value);
369
+ const entry = hubResultRecord(value);
370
370
  if (entry.kind !== "image" && entry.kind !== "video" || typeof entry.src !== "string") return [];
371
371
  return [{
372
372
  kind: entry.kind,
@@ -399,7 +399,7 @@ function post(channel, reply = false, sponsored = false) {
399
399
  handle: text(input.handle),
400
400
  callToAction: text(input.callToAction),
401
401
  images: (Array.isArray(input.images) ? input.images : input.image ? [input.image] : []).flatMap((image) => {
402
- const record = asRecord(image);
402
+ const record = hubResultRecord(image);
403
403
  const url2 = text(image) ?? text(record.url);
404
404
  return url2 ? [{ url: url2, alt: text(record.alt) }] : [];
405
405
  }),
@@ -431,9 +431,9 @@ function calendarEvent(input, _item) {
431
431
  preview: {
432
432
  kind: "event",
433
433
  title,
434
- start: text(input.start) ?? text(asRecord(input.start).dateTime),
435
- end: text(input.end) ?? text(asRecord(input.end).dateTime),
436
- location: text(input.location) ?? text(asRecord(input.location).displayName),
434
+ start: text(input.start) ?? text(hubResultRecord(input.start).dateTime),
435
+ end: text(input.end) ?? text(hubResultRecord(input.end).dateTime),
436
+ location: text(input.location) ?? text(hubResultRecord(input.location).displayName),
437
437
  attendees: list(input.attendees),
438
438
  description: text(input.description)
439
439
  }
@@ -525,7 +525,7 @@ var PRESENTERS = {
525
525
  },
526
526
  "phony.start_outbound_call": (input) => {
527
527
  const to = text(input.toNumber) ?? text(input.to);
528
- const mission = asRecord(input.mission);
528
+ const mission = hubResultRecord(input.mission);
529
529
  return {
530
530
  action: "Start call",
531
531
  title: to ? `Call ${to}` : "Start an outbound call",
@@ -572,7 +572,7 @@ function presentHubAction(item) {
572
572
  const { provider: pathProvider, action } = splitHubActionPath(item.actionPath);
573
573
  const providerId = item.providerId || pathProvider;
574
574
  const provider = { id: providerId, name: hubProviderName(providerId) };
575
- const input = asRecord(item.input);
575
+ const input = hubResultRecord(item.input);
576
576
  const known = PRESENTERS[item.actionPath];
577
577
  const presented = known ? known(input, item) : (() => {
578
578
  const { verb, noun } = genericVerb(action);
@@ -587,15 +587,15 @@ function presentHubAction(item) {
587
587
  return { provider, ...presented, ...item.preview ? { preview: item.preview } : {}, ...item.bundle ? { title: item.bundle.title } : {} };
588
588
  }
589
589
  function prField(result) {
590
- const pull = asRecord(result.pullRequest);
590
+ const pull = hubResultRecord(result.pullRequest);
591
591
  const number = readNumber(pull, "number") ?? readNumber(result, "number");
592
592
  if (number === void 0) return void 0;
593
593
  return { label: "Pull request", value: `#${number}`, href: resultLink(pull) ?? resultLink(result) };
594
594
  }
595
595
  function receiptTitle(item, presentation, result) {
596
596
  const { action } = splitHubActionPath(item.actionPath);
597
- const input = asRecord(item.input);
598
- const pull = asRecord(result.pullRequest);
597
+ const input = hubResultRecord(item.input);
598
+ const pull = hubResultRecord(result.pullRequest);
599
599
  const number = readNumber(pull, "number") ?? readNumber(result, "number");
600
600
  switch (item.actionPath) {
601
601
  case "github.pulls.propose":
@@ -661,7 +661,7 @@ function receiptFields(item, presentation, result) {
661
661
  const head = readText(result, "branch") ?? preview.head;
662
662
  const base = readText(result, "base") ?? preview.base;
663
663
  if (head && base) fields.push({ label: "Branch", value: `${head} \u2192 ${base}`, mono: true });
664
- const commit = asRecord(result.commit);
664
+ const commit = hubResultRecord(result.commit);
665
665
  const sha = readText(commit, "sha");
666
666
  if (sha) fields.push({ label: "Commit", value: shortSha(sha), href: resultLink(commit), mono: true });
667
667
  const repo = readText(result, "repository") ?? preview.repository;
@@ -711,7 +711,7 @@ function receiptFields(item, presentation, result) {
711
711
  return fields;
712
712
  }
713
713
  case "call": {
714
- const status = readText(asRecord(result.call), "status") ?? readText(result, "status");
714
+ const status = readText(hubResultRecord(result.call), "status") ?? readText(result, "status");
715
715
  if (status) fields.push({ label: "Status", value: status });
716
716
  return fields;
717
717
  }
@@ -738,7 +738,7 @@ function formatWhen(start, end) {
738
738
  function receiptFiles(result) {
739
739
  if (!Array.isArray(result.files)) return void 0;
740
740
  return result.files.flatMap((entry) => {
741
- const file = asRecord(entry);
741
+ const file = hubResultRecord(entry);
742
742
  const path = text(file.path) ?? text(file.filename);
743
743
  if (!path) return [];
744
744
  const status = text(file.status);
@@ -748,7 +748,7 @@ function receiptFiles(result) {
748
748
  }
749
749
  function hubActionReceipt(item) {
750
750
  const presentation = presentHubAction(item);
751
- const result = asRecord(unwrapHubResult(item.result));
751
+ const result = hubResultRecord(unwrapHubResult(item.result));
752
752
  const status = item.phase === "done" || item.phase === "unknown" || item.phase === "failed" || item.phase === "denied" || item.phase === "expired" ? item.phase : item.phase === "queued" || item.phase === "running" ? "running" : "waiting";
753
753
  const base = { provider: presentation.provider, status };
754
754
  if (status === "denied") return { ...base, title: `Denied: ${presentation.title}`, fields: [] };
@@ -758,7 +758,7 @@ function hubActionReceipt(item) {
758
758
  if (status !== "done") return { ...base, title: presentation.title, fields: [] };
759
759
  const title = receiptTitle(item, presentation, result);
760
760
  const fields = receiptFields(item, presentation, result);
761
- const pull = asRecord(result.pullRequest);
761
+ const pull = hubResultRecord(result.pullRequest);
762
762
  const href = presentation.preview.kind === "post" ? postLink(item, result) : resultLink(pull) ?? (item.actionPath.startsWith("github.git.") ? void 0 : resultLink(result));
763
763
  const audio = readText(result, "audioUrl");
764
764
  const seconds = readNumber(result, "durationSeconds", "duration");
@@ -813,4 +813,4 @@ export {
813
813
  HUB_APPROVAL_RESUME_PART,
814
814
  hubApprovalResumePart
815
815
  };
816
- //# sourceMappingURL=chunk-WSEXFTN4.js.map
816
+ //# sourceMappingURL=chunk-JBXNU5WD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hub-approvals/types.ts","../src/hub-approvals/result.ts","../src/hub-approvals/unknown.ts","../src/hub-approvals/present.ts","../src/hub-approvals/index.ts"],"sourcesContent":["/**\n * The vocabulary of a Hub action that waits on a person: where it stands, what\n * it will do in the owner's words, and what it did once it ran.\n */\n\n/** Where one held action stands, as the dock, the list and the transcript show it. */\nexport type HubApprovalPhase =\n /** Held by Hub; the viewer can decide it. */\n | 'waiting'\n /** Held by Hub; someone else (the workspace owner) decides it. */\n | 'blocked'\n /** Approved here; the run has not started. */\n | 'queued'\n /** Approved; Hub is running the call. */\n | 'running'\n | 'done'\n /** Approved, but Hub could not run it. */\n | 'failed'\n /** The provider may have acted; verify there before requesting it again. */\n | 'unknown'\n | 'denied'\n | 'expired'\n\n/** Phases that still need someone's decision. */\nexport const HUB_APPROVAL_OPEN_PHASES: ReadonlySet<HubApprovalPhase> = new Set(['waiting', 'blocked'])\n/** Phases between a decision and its result. */\nexport const HUB_APPROVAL_ACTIVE_PHASES: ReadonlySet<HubApprovalPhase> = new Set(['queued', 'running'])\n\n/** A file a held write changes. Counts stay undefined until someone has read them. */\nexport interface HubActionFile {\n path: string\n /** A rename reads as a modification of its new path. */\n change: 'added' | 'modified' | 'deleted'\n additions?: number\n deletions?: number\n}\n\n/**\n * The change a held call serves, when it is one step of a larger change such\n * as a pull request. The dock then names the change rather than the step.\n */\nexport interface HubActionBundle {\n /** What the whole change does, e.g. `Open PR: Fix the hero on acme/site`. */\n title: string\n steps?: ReadonlyArray<{ label: string; state: 'done' | 'current' | 'upcoming' }>\n}\n\n/** Whether an open call waits for the owner, in the owner's words. */\nexport interface HubApprovalWait {\n /** True when nothing runs until the owner decides; false when a permission runs it. */\n owner: boolean\n /** One sentence: `Publishing always needs your approval.` or `Runs under this conversation’s auto-approve.` */\n reason: string\n /** A stable cause the host can test, e.g. `never_grantable`, `loop_guard`, `daily_cap`. */\n code?: string\n}\n\n/** One held Hub action and its decision, in the form every surface renders. */\nexport interface HubApprovalItem {\n /** Stable within a conversation, such as `<messageId>:<partId>`. */\n id: string\n /** `provider.action`, e.g. `github.pulls.propose`. */\n actionPath: string\n providerId: string\n /** The call's input as Hub received it. */\n input: unknown\n phase: HubApprovalPhase\n /** The connected account the action runs as, e.g. `octocat` or `ops@acme.com`. */\n account?: string | null\n requestedAt?: string | null\n /** When the decision window closes. */\n expiresAt?: string | null\n /** Hub's result, or a bounded projection of it from {@link summarizeHubResult}. */\n result?: unknown\n error?: string | null\n /** The standing permission granted with the approval. */\n grant?: { scope: string; expiresAt: string | null } | null\n /** Set when a permissions mode, not a person, approved it. */\n autoApproved?: string | null\n /**\n * For an open call, what happens next without the viewer: it waits for the\n * owner, and why, or it runs on its own once the agent's reply finishes.\n */\n wait?: HubApprovalWait | null\n /** Files with line counts read by the host, replacing those the input declares. */\n files?: readonly HubActionFile[]\n bundle?: HubActionBundle | null\n /** Previewing and teaching never execute a call. Live approval remains a separate action. */\n executionMode?: 'dry-run' | 'live'\n feedback?: HubApprovalFeedback & { savedAt?: string }\n /** Host-resolved presentation, e.g. a retained page screenshot or ad creative. No remote fetches. */\n preview?: HubActionPreview\n}\n\n/** The host authenticates the reviewer, binds provenance and computes the edit diff. */\nexport interface HubApprovalFeedback {\n score: number\n comment: string\n /** A teaching example only; never replaces the held input or authorizes execution. */\n editedInput?: unknown\n}\n\n/** A labelled value on a preview or a receipt. */\nexport interface HubActionField {\n label: string\n value: string\n href?: string\n /** Render in the monospace face: shas, ids, paths. */\n mono?: boolean\n}\n\n/** Frozen media bytes supplied by the host; renderers never resolve a provider URL. */\nexport interface HubPreviewMedia {\n kind: 'image' | 'video'\n src: string\n alt: string\n poster?: string\n width?: number\n height?: number\n}\n\n/** What a held call will do, shaped for its integration's renderer. */\nexport type HubActionPreview =\n | {\n kind: 'pull-request'\n repository?: string\n title?: string\n body?: string\n head?: string\n base?: string\n draft?: boolean\n files: readonly HubActionFile[]\n }\n | { kind: 'commit'; repository?: string; message?: string; tree?: string; parents: readonly string[] }\n | { kind: 'branch'; repository?: string; branch?: string; sha?: string }\n | { kind: 'files'; repository?: string; files: readonly HubActionFile[] }\n | { kind: 'issue'; repository?: string; number?: number; title?: string; body?: string; verdict?: string }\n | {\n kind: 'email'\n to: readonly string[]\n cc: readonly string[]\n bcc: readonly string[]\n subject?: string\n from?: string\n fromName?: string\n previewText?: string\n body?: string\n html: boolean\n reply: boolean\n }\n | {\n kind: 'post'\n channel: 'x' | 'linkedin' | 'slack' | 'instagram' | 'facebook' | 'tiktok' | 'youtube'\n text: string\n /** The post's place, such as a Slack channel. */\n where?: string\n link?: { url: string; title?: string; description?: string }\n images?: readonly { url: string; alt?: string }[]\n media?: readonly HubPreviewMedia[]\n placement?: 'feed' | 'vertical' | 'carousel'\n sponsored?: boolean\n displayName?: string\n handle?: string\n callToAction?: string\n }\n | { kind: 'ad'; placement: string; advertiser?: string; headline?: string; text?: string; image?: string; destination?: string; callToAction?: string }\n | { kind: 'page'; title?: string; url?: string; screenshot?: string }\n | { kind: 'payment'; label: string; amount?: number; currency?: string; customer?: string; description?: string }\n | { kind: 'speech'; text: string; voice?: string; seconds?: number }\n | { kind: 'call'; to?: string; from?: string; purpose?: string }\n | {\n kind: 'event'\n title?: string\n start?: string\n end?: string\n location?: string\n attendees: readonly string[]\n description?: string\n }\n | { kind: 'fields'; fields: readonly HubActionField[] }\n\n/** A held call in the owner's words. */\nexport interface HubActionPresentation {\n provider: { id: string; name: string }\n /** The imperative, e.g. `Open pull request`. */\n action: string\n /** One line naming the action and its object, e.g. `Open PR: Fix the hero on acme/site`. */\n title: string\n /** Where it acts: a repository, recipients, a channel or a customer. */\n target?: string\n preview: HubActionPreview\n}\n\n/** What a decided call did, as its receipt shows it. */\nexport interface HubActionReceipt {\n provider: { id: string; name: string }\n /** The result in past tense, e.g. `Opened PR #123` or `Sent email to ada@acme.com`. */\n title: string\n /** The result's own page, when it has one: the pull request, the post, the event. */\n href?: string\n status: 'done' | 'unknown' | 'failed' | 'denied' | 'expired' | 'running' | 'waiting'\n fields: readonly HubActionField[]\n files?: readonly HubActionFile[]\n media?: { kind: 'audio'; src: string; seconds?: number }\n error?: string\n /** Guidance for an uncertain outcome, separate from a confirmed failure. */\n warning?: string\n}\n","/**\n * Hub results, read the same way by every receipt: unwrapped from Hub's\n * envelope and bounded before a host persists them.\n */\n\nconst MAX_DEPTH = 4\nconst MAX_KEYS = 24\nconst MAX_ITEMS = 50\nconst MAX_STRING = 600\n\nexport function hubResultRecord(value: unknown): Record<string, unknown> {\n return value && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : {}\n}\n\n/**\n * The provider's own result inside Hub's envelopes. `tools.invoke` answers\n * `{ result: … }` and a connector may wrap its body in `data`; a JSON string,\n * as an older host stored it, is parsed first.\n */\nexport function unwrapHubResult(value: unknown): unknown {\n let current: unknown = value\n if (typeof current === 'string') {\n const text = current\n try {\n current = JSON.parse(text)\n } catch {\n // An older host stored `Hub result: {…}`-style text with a JSON tail.\n const start = text.indexOf('{')\n if (start < 0) return value\n try {\n current = JSON.parse(text.slice(start))\n } catch {\n return value\n }\n }\n }\n for (let depth = 0; depth < 3; depth++) {\n const record = hubResultRecord(current)\n const keys = Object.keys(record)\n const inner = keys.find((key) => key === 'result' || key === 'data')\n // Only a thin envelope is unwrapped; a body that happens to carry a `data`\n // field among its own fields is the result itself.\n if (!inner || keys.length > 3 || record[inner] === null || typeof record[inner] !== 'object') break\n current = record[inner]\n }\n return current\n}\n\nfunction bounded(value: unknown, depth: number): unknown {\n if (value === null || typeof value === 'boolean') return value\n if (typeof value === 'number') return Number.isFinite(value) ? value : null\n if (typeof value === 'string') return value.length > MAX_STRING ? `${value.slice(0, MAX_STRING - 1)}…` : value\n if (depth >= MAX_DEPTH) return undefined\n if (Array.isArray(value)) {\n return value.slice(0, MAX_ITEMS).map((item) => bounded(item, depth + 1)).filter((item) => item !== undefined)\n }\n if (typeof value === 'object') {\n const out: Record<string, unknown> = {}\n for (const [key, entry] of Object.entries(value as Record<string, unknown>).slice(0, MAX_KEYS)) {\n const kept = bounded(entry, depth + 1)\n if (kept !== undefined) out[key] = kept\n }\n return out\n }\n return undefined\n}\n\n/**\n * A bounded copy of a Hub result for a host to store with the decision: the\n * envelope removed, strings, arrays and nesting capped. Receipts read it in\n * place of the full result.\n */\nexport function summarizeHubResult(result: unknown): unknown {\n return bounded(unwrapHubResult(result), 0)\n}\n\n/** The first non-empty string among `keys`, searched one level into nested records. */\nexport function readText(value: unknown, ...keys: string[]): string | undefined {\n const record = hubResultRecord(value)\n for (const key of keys) {\n const found = record[key]\n if (typeof found === 'string' && found.trim()) return found.trim()\n if (typeof found === 'number' && Number.isFinite(found)) return String(found)\n }\n return undefined\n}\n\nexport function readNumber(value: unknown, ...keys: string[]): number | undefined {\n const record = hubResultRecord(value)\n for (const key of keys) {\n const found = record[key]\n if (typeof found === 'number' && Number.isFinite(found)) return found\n }\n return undefined\n}\n\n/** A link a result names for itself, in the order providers use them. */\nexport function resultLink(value: unknown): string | undefined {\n const url = readText(value, 'html_url', 'htmlLink', 'webLink', 'web_url', 'permalink', 'hosted_invoice_url', 'url', 'link')\n return url && /^https:\\/\\//.test(url) ? url : undefined\n}\n","/** Internal safety copy shared by uncertain-outcome surfaces. */\nexport const HUB_APPROVAL_UNKNOWN_WARNING = 'Check the provider before requesting it again'\n","/**\n * Hub actions in an owner's words. Known integrations read as what they do —\n * `github.pulls.propose` is \"Open PR: Fix the hero on acme/site\", `gmail.send`\n * is \"Send email to ada@acme.com\" — and any other Hub action falls back to its\n * own name and its input's scalar fields.\n */\n\nimport { hubResultRecord, readNumber, readText, resultLink, unwrapHubResult } from './result'\nimport { HUB_APPROVAL_UNKNOWN_WARNING } from './unknown'\nimport type {\n HubActionField,\n HubActionFile,\n HubActionPresentation,\n HubActionPreview,\n HubActionReceipt,\n HubApprovalItem,\n HubPreviewMedia,\n} from './types'\n\nconst PROVIDER_NAMES: Record<string, string> = {\n github: 'GitHub',\n gitlab: 'GitLab',\n gmail: 'Gmail',\n google: 'Google',\n 'google-calendar': 'Google Calendar',\n 'microsoft-calendar': 'Outlook Calendar',\n 'outlook-mail': 'Outlook',\n outlook: 'Outlook',\n twitter: 'X',\n x: 'X',\n linkedin: 'LinkedIn',\n stripe: 'Stripe',\n phony: 'ph0ny',\n slack: 'Slack',\n notion: 'Notion',\n hubspot: 'HubSpot',\n linear: 'Linear',\n inkbox: 'Inkbox',\n resend: 'Resend',\n 'instagram-business': 'Instagram',\n 'facebook-pages': 'Facebook',\n 'meta-ads': 'Meta Ads',\n 'linkedin-ads': 'LinkedIn Ads',\n tiktok: 'TikTok',\n 'youtube-data': 'YouTube',\n}\n\n/** A provider's display name: `github` is GitHub, `outlook-mail` is Outlook. */\nexport function hubProviderName(id: string): string {\n if (PROVIDER_NAMES[id]) return PROVIDER_NAMES[id]\n const words = id.split(/[-_\\s]+/).filter(Boolean)\n return words.map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(' ') || id\n}\n\n/** `provider.action` split at the first dot. */\nexport function splitHubActionPath(actionPath: string): { provider: string; action: string } {\n const separator = actionPath.indexOf('.')\n return separator < 0 ? { provider: '', action: actionPath } : { provider: actionPath.slice(0, separator), action: actionPath.slice(separator + 1) }\n}\n\nfunction text(value: unknown): string | undefined {\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\nfunction clipped(value: string, max = 80): string {\n const single = value.replace(/\\s+/g, ' ').trim()\n return single.length > max ? `${single.slice(0, max - 1).trimEnd()}…` : single\n}\n\nfunction list(value: unknown): string[] {\n if (typeof value === 'string') return value.split(/[,;]/).map((entry) => entry.trim()).filter(Boolean)\n if (!Array.isArray(value)) return []\n return value.flatMap((entry) => {\n if (typeof entry === 'string' && entry.trim()) return [entry.trim()]\n const record = hubResultRecord(entry)\n const address = text(record.email) ?? text(record.address) ?? text(hubResultRecord(record.emailAddress).address)\n return address ? [address] : []\n })\n}\n\nfunction people(addresses: readonly string[]): string {\n if (addresses.length === 0) return ''\n if (addresses.length === 1) return addresses[0]!\n return `${addresses[0]} and ${addresses.length - 1} more`\n}\n\nfunction shortSha(sha: string | undefined): string | undefined {\n return sha && /^[0-9a-f]{7,}$/i.test(sha) ? sha.slice(0, 7) : sha\n}\n\n// ---------- verbs ----------\n\nconst PAST: Record<string, string> = {\n add: 'added', approve: 'approved', archive: 'archived', assign: 'assigned', book: 'booked', cancel: 'canceled',\n capture: 'captured', charge: 'charged', clone: 'cloned', close: 'closed', comment: 'commented', create: 'created',\n deactivate: 'deactivated', delete: 'deleted', enroll: 'enrolled', export: 'exported', finalize: 'finalized',\n forward: 'forwarded', import: 'imported', ingest: 'ingested', invite: 'invited', like: 'liked', make: 'made',\n merge: 'merged', move: 'moved', open: 'opened', pay: 'paid', place: 'placed', post: 'posted', provision: 'provisioned',\n publish: 'published', put: 'put', react: 'reacted', refund: 'refunded', remove: 'removed', reply: 'replied',\n retweet: 'reposted', review: 'reviewed', run: 'ran', save: 'saved', schedule: 'scheduled', send: 'sent', set: 'set',\n share: 'shared', start: 'started', stop: 'stopped', submit: 'submitted', subscribe: 'subscribed',\n synthesize: 'synthesized', transfer: 'transferred', translate: 'translated', update: 'updated', upload: 'uploaded',\n upsert: 'saved', void: 'voided', watch: 'watched', write: 'wrote',\n}\n\n/** The past tense of an English verb this vocabulary uses. */\nexport function pastTense(verb: string): string {\n const lower = verb.toLowerCase()\n const past = PAST[lower] ?? (lower.endsWith('e') ? `${lower}d` : `${lower}ed`)\n return verb.charAt(0) === verb.charAt(0).toUpperCase() ? past.charAt(0).toUpperCase() + past.slice(1) : past\n}\n\nfunction words(action: string): string[] {\n return action\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .split(/[._\\-\\s]+/)\n .map((word) => word.toLowerCase())\n .filter(Boolean)\n}\n\nfunction singular(word: string): string {\n if (word.endsWith('ies')) return `${word.slice(0, -3)}y`\n if (word.endsWith('sses') || word.endsWith('ss')) return word\n return word.endsWith('s') && word.length > 3 ? word.slice(0, -1) : word\n}\n\n/** A Hub action's own name as a sentence: `payment-intents.create` is \"Create payment intent\". */\nfunction genericVerb(action: string): { verb: string; noun: string } {\n const parts = words(action)\n const index = parts.findIndex((word) => word in PAST)\n if (index < 0) return { verb: '', noun: parts.join(' ') }\n const noun = [...parts.slice(0, index), ...parts.slice(index + 1)].map(singular).join(' ')\n return { verb: parts[index]!, noun }\n}\n\nfunction sentence(verb: string, noun: string): string {\n const phrase = [verb, noun].filter(Boolean).join(' ')\n return phrase.charAt(0).toUpperCase() + phrase.slice(1)\n}\n\n// ---------- inputs ----------\n\nfunction repository(input: Record<string, unknown>): string | undefined {\n const owner = text(input.owner)\n const repo = text(input.repo)\n if (owner && repo) return `${owner}/${repo}`\n return repo ?? text(input.repository)\n}\n\nfunction branchOf(ref: unknown): string | undefined {\n return text(ref)?.replace(/^refs\\/heads\\//, '')\n}\n\n/** The files a call writes, as its input declares them. */\nexport function hubActionFiles(actionPath: string, input: unknown): HubActionFile[] {\n const fields = hubResultRecord(input)\n const { action } = splitHubActionPath(actionPath)\n const entries = action === 'git.createTree' ? fields.tree : fields.files\n if (!Array.isArray(entries)) return []\n return entries.flatMap((entry): HubActionFile[] => {\n const item = hubResultRecord(entry)\n const path = text(item.path)\n if (!path) return []\n const deleted = item.delete === true || (item.sha === null && item.content === undefined)\n return [{ path, change: deleted ? 'deleted' : 'modified' }]\n })\n}\n\n/** Counted files replace declared ones by path; the declared order stays. */\nfunction mergedFiles(declared: readonly HubActionFile[], counted: readonly HubActionFile[] | undefined): HubActionFile[] {\n if (!counted || counted.length === 0) return [...declared]\n if (declared.length === 0) return [...counted]\n const byPath = new Map(counted.map((file) => [file.path, file]))\n return declared.map((file) => byPath.get(file.path) ?? file)\n}\n\nfunction emailPreview(input: Record<string, unknown>, reply: boolean): HubActionPreview {\n const from = hubResultRecord(input.from)\n const htmlBody = typeof input.html === 'string' ? input.html : undefined\n return {\n kind: 'email',\n to: list(input.to ?? input.recipients),\n cc: list(input.cc),\n bcc: list(input.bcc),\n subject: text(input.subject),\n from: text(input.from) ?? text(from.email) ?? text(from.address),\n fromName: text(input.fromName) ?? text(input.from_name) ?? text(from.name),\n previewText: text(input.previewText) ?? text(input.preview_text) ?? text(input.preheader),\n // The payload is evidence: retain whitespace and prefer the actual HTML part.\n body: htmlBody ?? [input.body, input.text, input.comment].find((value): value is string => typeof value === 'string'),\n html: input.html === true || text(input.bodyType)?.toLowerCase() === 'html' || typeof input.html === 'string',\n reply,\n }\n}\n\nfunction speechSeconds(input: Record<string, unknown>): number | undefined {\n const spoken = text(input.text)\n if (!spoken) return undefined\n const speed = typeof input.speed === 'number' && input.speed > 0 ? input.speed : 1\n // About 2.5 spoken words a second at normal speed.\n return Math.max(1, Math.round(spoken.split(/\\s+/).length / 2.5 / speed))\n}\n\nfunction voiceName(input: Record<string, unknown>): string | undefined {\n const voice = text(input.voiceId)\n // An opaque provider id says nothing to an owner; a named voice does.\n if (voice && !/^[0-9a-f-]{16,}$/i.test(voice) && voice.length <= 32) return voice.charAt(0).toUpperCase() + voice.slice(1)\n return text(input.provider)\n}\n\nconst CURRENCY_DIGITS: Record<string, number> = { jpy: 0, krw: 0, vnd: 0, clp: 0, bhd: 3, kwd: 3, omr: 3 }\n\n/** A Stripe minor-unit amount in its currency: `4900` USD is `$49.00`. */\nexport function formatMinorAmount(amount: number, currency = 'usd'): string {\n const code = currency.toLowerCase()\n const digits = CURRENCY_DIGITS[code] ?? 2\n try {\n return new Intl.NumberFormat('en-US', { style: 'currency', currency: code.toUpperCase(), minimumFractionDigits: digits })\n .format(amount / 10 ** digits)\n } catch {\n return `${(amount / 10 ** digits).toFixed(digits)} ${code.toUpperCase()}`\n }\n}\n\n/** Scalar input fields, for an action no renderer knows. */\nfunction scalarFields(input: Record<string, unknown>, max = 6): HubActionField[] {\n return Object.entries(input).flatMap(([key, value]): HubActionField[] => {\n if (key.startsWith('__')) return []\n if (typeof value === 'string' && value.trim()) return [{ label: labelOf(key), value: clipped(value, 160) }]\n if (typeof value === 'number' || typeof value === 'boolean') return [{ label: labelOf(key), value: String(value) }]\n const strings = Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === 'string') : []\n return strings.length > 0 ? [{ label: labelOf(key), value: clipped(strings.join(', '), 160) }] : []\n }).slice(0, max)\n}\n\nfunction labelOf(key: string): string {\n const spaced = key.replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/[_-]+/g, ' ').trim().toLowerCase()\n return spaced.charAt(0).toUpperCase() + spaced.slice(1)\n}\n\n// ---------- presentation ----------\n\ntype Presenter = (input: Record<string, unknown>, item: Pick<HubApprovalItem, 'actionPath' | 'files'>) => Omit<HubActionPresentation, 'provider'>\n\nfunction pullRequest(input: Record<string, unknown>, item: Pick<HubApprovalItem, 'actionPath' | 'files'>): Omit<HubActionPresentation, 'provider'> {\n const repo = repository(input)\n const title = text(input.title) ?? 'Untitled change'\n return {\n action: 'Open pull request',\n title: `Open PR: ${clipped(title)}${repo ? ` on ${repo}` : ''}`,\n ...(repo ? { target: repo } : {}),\n preview: {\n kind: 'pull-request',\n repository: repo,\n title,\n body: text(input.body),\n head: branchOf(input.branch ?? input.head),\n base: text(input.base),\n draft: item.actionPath.endsWith('.propose') ? true : input.draft === true,\n files: mergedFiles(hubActionFiles(item.actionPath, input), item.files),\n },\n }\n}\n\nfunction issueLike(verb: string, noun: string): Presenter {\n return (input) => {\n const repo = repository(input)\n const number = readNumber(input, 'issue_number', 'pull_number', 'number')\n const title = text(input.title)\n const object = number !== undefined ? `${noun} #${number}` : title ? `${noun}: ${clipped(title)}` : noun\n return {\n action: sentence(verb, noun.toLowerCase()),\n title: `${sentence(verb, object)}${repo ? ` on ${repo}` : ''}`,\n ...(repo ? { target: repo } : {}),\n preview: {\n kind: 'issue',\n repository: repo,\n number,\n title,\n body: text(input.body),\n verdict: text(input.event)?.toLowerCase().replace(/_/g, ' '),\n },\n }\n }\n}\n\nfunction sendEmail(verb: 'Send' | 'Save draft', reply = false): Presenter {\n return (input) => {\n const preview = emailPreview(input, reply)\n const recipients = preview.kind === 'email' ? people(preview.to) : ''\n const action = reply ? 'Send reply' : verb === 'Send' ? 'Send email' : 'Save draft'\n return {\n action,\n title: reply ? 'Send reply' : `${action}${recipients ? ` to ${recipients}` : ''}`,\n ...(recipients ? { target: recipients } : {}),\n preview,\n }\n }\n}\n\nfunction post(channel: 'x' | 'linkedin' | 'instagram' | 'facebook' | 'tiktok', reply = false, sponsored = false): Presenter {\n return (input) => {\n const container = hubResultRecord(input.container)\n const body = [input.text, input.commentary, input.caption, input.message, container.caption, input.title]\n .find((value): value is string => typeof value === 'string') ?? ''\n const url = text(input.url) ?? text(input.link)\n const where = { x: 'X', linkedin: 'LinkedIn', instagram: 'Instagram', facebook: 'Facebook', tiktok: 'TikTok' }[channel]\n const media = (Array.isArray(input.media) ? input.media : []).flatMap((value): HubPreviewMedia[] => {\n const entry = hubResultRecord(value)\n if ((entry.kind !== 'image' && entry.kind !== 'video') || typeof entry.src !== 'string') return []\n return [{ kind: entry.kind, src: entry.src, alt: typeof entry.alt === 'string' ? entry.alt : '',\n ...(typeof entry.poster === 'string' ? { poster: entry.poster } : {}),\n ...(typeof entry.width === 'number' ? { width: entry.width } : {}),\n ...(typeof entry.height === 'number' ? { height: entry.height } : {}) }]\n })\n if (!media.length) {\n const video = text(input.video_url) ?? text(container.video_url)\n const image = text(input.imageUrl) ?? text(input.image_url) ?? text(container.image_url)\n if (video) media.push({ kind: 'video', src: video, alt: '' })\n else if (image) media.push({ kind: 'image', src: image, alt: '' })\n }\n const placement = channel === 'tiktok' || container.media_type === 'REELS' ? 'vertical'\n : container.media_type === 'CAROUSEL' ? 'carousel' : 'feed'\n return {\n action: reply ? `Reply on ${where}` : `Post on ${where}`,\n title: `${reply ? 'Reply' : 'Post'} on ${where}${body ? `: “${clipped(body, 60)}”` : ''}`,\n target: where,\n preview: {\n kind: 'post',\n channel,\n text: body,\n ...(media.length ? { media } : {}),\n placement,\n ...(sponsored ? { sponsored: true } : {}),\n displayName: text(input.displayName),\n handle: text(input.handle),\n callToAction: text(input.callToAction),\n images: (Array.isArray(input.images) ? input.images : input.image ? [input.image] : []).flatMap((image) => {\n const record = hubResultRecord(image)\n const url = text(image) ?? text(record.url)\n return url ? [{ url, alt: text(record.alt) }] : []\n }),\n ...(url ? { link: { url, title: text(input.headline) ?? text(input.title), description: text(input.description) } } : {}),\n },\n }\n }\n}\n\nfunction payment(label: string): Presenter {\n return (input) => {\n const amount = readNumber(input, 'amount')\n const currency = text(input.currency)\n const customer = text(input.customerId) ?? text(input.customer) ?? text(input.email)\n const formatted = amount !== undefined ? formatMinorAmount(amount, currency) : undefined\n const object = formatted ? `${label} of ${formatted}` : label\n return {\n action: sentence('create', label),\n title: `${sentence('create', object)}${customer ? ` for ${customer}` : ''}`,\n ...(customer ? { target: customer } : {}),\n preview: { kind: 'payment', label, amount, currency, customer, description: text(input.description) },\n }\n }\n}\n\nfunction calendarEvent(input: Record<string, unknown>, _item?: Pick<HubApprovalItem, 'actionPath' | 'files'>): Omit<HubActionPresentation, 'provider'> {\n const title = text(input.summary) ?? text(input.title) ?? text(input.subject)\n return {\n action: 'Book event',\n title: title ? `Book “${clipped(title, 60)}”` : 'Book an event',\n preview: {\n kind: 'event',\n title,\n start: text(input.start) ?? text(hubResultRecord(input.start).dateTime),\n end: text(input.end) ?? text(hubResultRecord(input.end).dateTime),\n location: text(input.location) ?? text(hubResultRecord(input.location).displayName),\n attendees: list(input.attendees),\n description: text(input.description),\n },\n }\n}\n\nconst PRESENTERS: Record<string, Presenter> = {\n 'github.pulls.propose': pullRequest,\n 'github.pulls.create': pullRequest,\n 'github.git.createTree': (input, item) => {\n const repo = repository(input)\n const files = mergedFiles(hubActionFiles(item.actionPath, input), item.files)\n return {\n action: 'Write files',\n title: `Write ${files.length === 1 ? files[0]!.path : `${files.length} files`}${repo ? ` to ${repo}` : ''}`,\n ...(repo ? { target: repo } : {}),\n preview: { kind: 'files', repository: repo, files },\n }\n },\n 'github.git.createCommit': (input) => {\n const repo = repository(input)\n const message = text(input.message)\n return {\n action: 'Create commit',\n title: `Commit${message ? ` “${clipped(message, 60)}”` : ''}${repo ? ` to ${repo}` : ''}`,\n ...(repo ? { target: repo } : {}),\n preview: { kind: 'commit', repository: repo, message, tree: text(input.tree), parents: list(input.parents) },\n }\n },\n 'github.git.createRef': (input) => {\n const repo = repository(input)\n const branch = branchOf(input.ref)\n return {\n action: 'Create branch',\n title: `Create branch ${branch ?? ''}${repo ? ` in ${repo}` : ''}`.replace(/\\s+/g, ' ').trim(),\n ...(repo ? { target: repo } : {}),\n preview: { kind: 'branch', repository: repo, branch, sha: text(input.sha) },\n }\n },\n 'github.pulls.merge': issueLike('merge', 'PR'),\n 'github.pulls.reviews.create': issueLike('review', 'PR'),\n 'github.issues.create': issueLike('open', 'Issue'),\n 'github.issues.update': issueLike('update', 'Issue'),\n 'github.issues.createComment': issueLike('comment on', 'Issue'),\n 'gmail.send': sendEmail('Send'),\n 'gmail.send_reply': sendEmail('Send', true),\n 'outlook-mail.send_message': sendEmail('Send'),\n 'outlook-mail.send_draft': sendEmail('Send'),\n 'outlook-mail.create_draft': sendEmail('Save draft'),\n 'outlook-mail.send_reply': sendEmail('Send', true),\n 'inkbox.email.send': sendEmail('Send'),\n 'resend.emails.send': sendEmail('Send'),\n 'resend.emails.reply': sendEmail('Send', true),\n 'twitter.tweets.create': post('x'),\n 'twitter.tweets.reply': post('x', true),\n 'x.tweets.create': post('x'),\n 'linkedin.posts.create': post('linkedin'),\n 'linkedin.shares.create': post('linkedin'),\n 'instagram-business.media.createContainer': post('instagram'),\n 'tiktok.publishing.videoFromUrl': post('tiktok'),\n 'tiktok.publishing.photosFromUrls': post('tiktok'),\n 'facebook-pages.pages.feed.create': post('facebook'),\n 'facebook-pages.pages.photos.create': post('facebook'),\n 'meta-ads.creatives.createLink': post('facebook', false, true),\n 'linkedin-ads.creatives.create': post('linkedin', false, true),\n 'slack.post_message': (input) => {\n const channel = text(input.channel) ?? text(input.channelId)\n const where = channel ? (channel.startsWith('#') || /^[CDG][A-Z0-9]{6,}$/.test(channel) ? channel : `#${channel}`) : undefined\n return {\n action: 'Post in Slack',\n title: `Post in ${where ?? 'Slack'}`,\n ...(where ? { target: where } : {}),\n preview: { kind: 'post', channel: 'slack', text: text(input.text) ?? '', where },\n }\n },\n 'stripe.payment-intents.create': payment('payment'),\n 'stripe.payment-links.create': payment('payment link'),\n 'stripe.invoices.create': payment('invoice'),\n 'stripe.refunds.create': payment('refund'),\n 'stripe.subscriptions.create': payment('subscription'),\n 'phony.synthesize_speech': (input) => {\n const seconds = speechSeconds(input)\n const voice = voiceName(input)\n const detail = [voice, seconds ? `${seconds} s` : undefined].filter(Boolean)\n return {\n action: 'Create voice memo',\n title: `Create voice memo${detail.length ? ` (${detail.join(', ')})` : ''}`,\n preview: { kind: 'speech', text: text(input.text) ?? '', voice, seconds },\n }\n },\n 'phony.start_outbound_call': (input) => {\n const to = text(input.toNumber) ?? text(input.to)\n const mission = hubResultRecord(input.mission)\n return {\n action: 'Start call',\n title: to ? `Call ${to}` : 'Start an outbound call',\n ...(to ? { target: to } : {}),\n preview: {\n kind: 'call',\n to,\n from: text(input.fromNumber),\n purpose: text(mission.goal) ?? text(mission.objective) ?? text(mission.summary) ?? text(input.missionId),\n },\n }\n },\n 'phony.create_agent': (input) => {\n const name = text(input.name)\n return {\n action: 'Create voice agent',\n title: `Create voice agent${name ? ` “${clipped(name, 60)}”` : ''}`,\n preview: { kind: 'fields', fields: scalarFields(input) },\n }\n },\n 'phony.update_agent': (input) => ({\n action: 'Update voice agent',\n title: 'Update a voice agent',\n preview: { kind: 'fields', fields: scalarFields(input) },\n }),\n 'phony.clone_voice': (input) => {\n const name = text(input.name)\n return {\n action: 'Clone voice',\n title: `Clone your voice${name ? ` as “${clipped(name, 60)}”` : ''}`,\n preview: { kind: 'fields', fields: scalarFields(input) },\n }\n },\n 'google-calendar.create_event': calendarEvent,\n 'google-calendar.book_slot': calendarEvent,\n 'google-calendar.update_event': (input, item) => {\n const event = calendarEvent(input, item)\n const title = event.preview.kind === 'event' ? event.preview.title : undefined\n return { ...event, action: 'Update event', title: title ? `Update “${clipped(title, 60)}”` : 'Update an event' }\n },\n 'microsoft-calendar.book_slot': calendarEvent,\n}\n\n/** A held call in the owner's words, with the preview its integration renders. */\nexport function presentHubAction(item: Pick<HubApprovalItem, 'actionPath' | 'providerId' | 'input' | 'files' | 'bundle' | 'preview'>): HubActionPresentation {\n const { provider: pathProvider, action } = splitHubActionPath(item.actionPath)\n const providerId = item.providerId || pathProvider\n const provider = { id: providerId, name: hubProviderName(providerId) }\n const input = hubResultRecord(item.input)\n const known = PRESENTERS[item.actionPath]\n const presented = known\n ? known(input, item)\n : (() => {\n const { verb, noun } = genericVerb(action)\n const phrase = sentence(verb, noun) || action\n const object = text(input.name) ?? text(input.title) ?? text(input.subject) ?? text(input.label)\n return {\n action: phrase,\n title: object ? `${phrase} “${clipped(object, 60)}”` : phrase,\n preview: { kind: 'fields', fields: scalarFields(input) } as HubActionPreview,\n }\n })()\n return { provider, ...presented, ...(item.preview ? { preview: item.preview } : {}), ...(item.bundle ? { title: item.bundle.title } : {}) }\n}\n\n// ---------- receipts ----------\n\nfunction prField(result: Record<string, unknown>): HubActionField | undefined {\n const pull = hubResultRecord(result.pullRequest)\n const number = readNumber(pull, 'number') ?? readNumber(result, 'number')\n if (number === undefined) return undefined\n return { label: 'Pull request', value: `#${number}`, href: resultLink(pull) ?? resultLink(result) }\n}\n\nfunction receiptTitle(item: HubApprovalItem, presentation: HubActionPresentation, result: Record<string, unknown>): string {\n const { action } = splitHubActionPath(item.actionPath)\n const input = hubResultRecord(item.input)\n const pull = hubResultRecord(result.pullRequest)\n const number = readNumber(pull, 'number') ?? readNumber(result, 'number')\n switch (item.actionPath) {\n case 'github.pulls.propose':\n case 'github.pulls.create':\n return number !== undefined ? `Opened PR #${number}` : 'Opened pull request'\n case 'github.git.createCommit': {\n const sha = shortSha(readText(result, 'sha'))\n return sha ? `Created commit ${sha}` : 'Created commit'\n }\n case 'github.git.createTree': {\n const files = hubActionFiles(item.actionPath, input).length\n return `Wrote ${files === 1 ? '1 file' : `${files} files`}`\n }\n case 'github.git.createRef':\n return `Created branch ${branchOf(readText(result, 'ref') ?? input.ref) ?? ''}`.trim()\n case 'github.issues.create':\n return number !== undefined ? `Opened issue #${number}` : 'Opened issue'\n case 'github.issues.createComment': {\n const on = readNumber(input, 'issue_number')\n return on !== undefined ? `Commented on #${on}` : 'Commented'\n }\n case 'github.pulls.reviews.create': {\n const on = readNumber(input, 'pull_number')\n return on !== undefined ? `Reviewed PR #${on}` : 'Reviewed pull request'\n }\n case 'github.pulls.merge': {\n const on = readNumber(input, 'pull_number')\n return on !== undefined ? `Merged PR #${on}` : 'Merged pull request'\n }\n case 'phony.synthesize_speech':\n return 'Created voice memo'\n }\n if (presentation.preview.kind === 'email') {\n const to = people(presentation.preview.to)\n if (presentation.preview.reply) return 'Sent reply'\n return action.includes('draft') && !action.startsWith('send') ? `Saved draft${to ? ` to ${to}` : ''}` : `Sent email${to ? ` to ${to}` : ''}`\n }\n if (presentation.preview.kind === 'post') {\n return presentation.preview.channel === 'slack' ? `Posted in ${presentation.preview.where ?? 'Slack'}` : `Posted on ${presentation.target ?? presentation.provider.name}`\n }\n if (presentation.preview.kind === 'event') {\n const verb = presentation.action === 'Update event' ? 'Updated' : 'Booked'\n return presentation.preview.title ? `${verb} “${clipped(presentation.preview.title, 60)}”` : `${verb} event`\n }\n if (presentation.preview.kind === 'call') return presentation.preview.to ? `Started call to ${presentation.preview.to}` : 'Started call'\n const [first = '', ...rest] = presentation.action.split(' ')\n return [pastTense(first), ...rest].join(' ')\n}\n\nfunction postLink(item: HubApprovalItem, result: Record<string, unknown>): string | undefined {\n const id = readText(result, 'id', 'urn', 'postUrn')\n if (!id) return resultLink(result)\n if (item.providerId === 'twitter' || item.providerId === 'x') return /^\\d+$/.test(id) ? `https://x.com/i/web/status/${id}` : resultLink(result)\n if (item.providerId === 'linkedin') return id.startsWith('urn:li:') ? `https://www.linkedin.com/feed/update/${id}/` : resultLink(result)\n return resultLink(result)\n}\n\nfunction receiptFields(item: HubApprovalItem, presentation: HubActionPresentation, result: Record<string, unknown>): HubActionField[] {\n const fields: HubActionField[] = []\n const preview = presentation.preview\n switch (preview.kind) {\n case 'pull-request': {\n const pr = prField(result)\n if (pr) fields.push(pr)\n const head = readText(result, 'branch') ?? preview.head\n const base = readText(result, 'base') ?? preview.base\n if (head && base) fields.push({ label: 'Branch', value: `${head} → ${base}`, mono: true })\n const commit = hubResultRecord(result.commit)\n const sha = readText(commit, 'sha')\n if (sha) fields.push({ label: 'Commit', value: shortSha(sha)!, href: resultLink(commit), mono: true })\n const repo = readText(result, 'repository') ?? preview.repository\n if (repo) fields.push({ label: 'Repository', value: repo, href: `https://github.com/${repo}` })\n return fields\n }\n case 'commit': {\n const sha = readText(result, 'sha')\n if (sha) fields.push({ label: 'Commit', value: shortSha(sha)!, href: resultLink(result)?.includes('api.github.com') ? undefined : resultLink(result), mono: true })\n if (preview.message) fields.push({ label: 'Message', value: clipped(preview.message, 120) })\n return fields\n }\n case 'branch': {\n const branch = branchOf(readText(result, 'ref')) ?? preview.branch\n if (branch && preview.repository) fields.push({ label: 'Branch', value: branch, href: `https://github.com/${preview.repository}/tree/${branch}`, mono: true })\n return fields\n }\n case 'files': {\n const sha = readText(result, 'sha')\n if (sha) fields.push({ label: 'Tree', value: shortSha(sha)!, mono: true })\n return fields\n }\n case 'email': {\n if (preview.subject) fields.push({ label: 'Subject', value: clipped(preview.subject, 120) })\n if (preview.cc.length) fields.push({ label: 'Cc', value: preview.cc.join(', ') })\n return fields\n }\n case 'payment': {\n const amount = readNumber(result, 'amount', 'amount_total', 'total') ?? preview.amount\n const currency = readText(result, 'currency') ?? preview.currency\n if (amount !== undefined) fields.push({ label: 'Amount', value: formatMinorAmount(amount, currency) })\n const customer = readText(result, 'customer_email', 'customer') ?? preview.customer\n if (customer) fields.push({ label: 'Customer', value: customer, mono: customer.startsWith('cus_') })\n const status = readText(result, 'status')\n if (status) fields.push({ label: 'Status', value: status })\n return fields\n }\n case 'speech': {\n const seconds = readNumber(result, 'durationSeconds', 'duration')\n if (seconds !== undefined) fields.push({ label: 'Length', value: `${Math.round(seconds * 10) / 10} s` })\n if (preview.voice) fields.push({ label: 'Voice', value: preview.voice })\n return fields\n }\n case 'event': {\n if (preview.start) fields.push({ label: 'When', value: formatWhen(preview.start, preview.end) })\n if (preview.attendees.length) fields.push({ label: 'Guests', value: people(preview.attendees) })\n return fields\n }\n case 'call': {\n const status = readText(hubResultRecord(result.call), 'status') ?? readText(result, 'status')\n if (status) fields.push({ label: 'Status', value: status })\n return fields\n }\n default: {\n const id = readText(result, 'id', 'number', 'key')\n if (id) fields.push({ label: 'ID', value: id, mono: true })\n const status = readText(result, 'status', 'state')\n if (status) fields.push({ label: 'Status', value: status })\n const name = readText(result, 'name', 'title')\n if (name) fields.push({ label: 'Name', value: clipped(name, 80) })\n return fields\n }\n }\n}\n\n/** A start and optional end in the viewer's locale: `Tue, Oct 14, 3:00 – 3:30 PM`. */\nexport function formatWhen(start: string, end?: string): string {\n const from = new Date(start)\n if (Number.isNaN(from.getTime())) return end ? `${start} – ${end}` : start\n const day = from.toLocaleDateString(undefined, { weekday: 'short', month: 'short', day: 'numeric' })\n const time = (date: Date) => date.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' })\n const to = end ? new Date(end) : null\n if (!to || Number.isNaN(to.getTime())) return `${day}, ${time(from)}`\n return to.toDateString() === from.toDateString() ? `${day}, ${time(from)} – ${time(to)}` : `${day}, ${time(from)} – ${to.toLocaleDateString(undefined, { month: 'short', day: 'numeric' })}, ${time(to)}`\n}\n\nfunction receiptFiles(result: Record<string, unknown>): HubActionFile[] | undefined {\n if (!Array.isArray(result.files)) return undefined\n return result.files.flatMap((entry): HubActionFile[] => {\n const file = hubResultRecord(entry)\n const path = text(file.path) ?? text(file.filename)\n if (!path) return []\n const status = text(file.status)\n const change = status === 'added' ? 'added' : status === 'removed' || status === 'deleted' ? 'deleted' : 'modified'\n return [{ path, change, additions: readNumber(file, 'additions'), deletions: readNumber(file, 'deletions') }]\n })\n}\n\n/** What a decided call did: its past-tense title, key fields, link, media and files. */\nexport function hubActionReceipt(item: HubApprovalItem): HubActionReceipt {\n const presentation = presentHubAction(item)\n const result = hubResultRecord(unwrapHubResult(item.result))\n const status: HubActionReceipt['status'] = item.phase === 'done' || item.phase === 'unknown' || item.phase === 'failed' || item.phase === 'denied' || item.phase === 'expired'\n ? item.phase\n : item.phase === 'queued' || item.phase === 'running' ? 'running' : 'waiting'\n const base = { provider: presentation.provider, status }\n if (status === 'denied') return { ...base, title: `Denied: ${presentation.title}`, fields: [] }\n if (status === 'expired') return { ...base, title: `Expired: ${presentation.title}`, fields: [] }\n if (status === 'unknown') return { ...base, title: `May have run: ${presentation.title}`, fields: [], warning: HUB_APPROVAL_UNKNOWN_WARNING }\n if (status === 'failed') return { ...base, title: `Could not ${presentation.action.charAt(0).toLowerCase()}${presentation.action.slice(1)}`, fields: [], ...(item.error ? { error: item.error } : {}) }\n if (status !== 'done') return { ...base, title: presentation.title, fields: [] }\n const title = receiptTitle(item, presentation, result)\n const fields = receiptFields(item, presentation, result)\n const pull = hubResultRecord(result.pullRequest)\n const href = presentation.preview.kind === 'post'\n ? postLink(item, result)\n : resultLink(pull) ?? (item.actionPath.startsWith('github.git.') ? undefined : resultLink(result))\n const audio = readText(result, 'audioUrl')\n const seconds = readNumber(result, 'durationSeconds', 'duration')\n const files = receiptFiles(result)\n return {\n ...base,\n title,\n ...(href ? { href } : {}),\n fields,\n ...(files && files.length ? { files } : {}),\n ...(audio && /^https:\\/\\//.test(audio) ? { media: { kind: 'audio' as const, src: audio, ...(seconds !== undefined ? { seconds } : {}) } } : {}),\n }\n}\n","/**\n * `./hub-approvals` — Hub actions that wait on a person, in the owner's words.\n *\n * Pure and browser-safe: a host maps its held calls into {@link HubApprovalItem}s\n * and every surface — the approval dock above the composer, the Approvals list\n * beside the conversation, and the receipts in the transcript — renders the\n * same presentation from them. Servers use {@link summarizeHubResult} to store\n * a bounded result with the decision.\n */\n\nimport type { HubApprovalPhase } from './types'\n\nexport * from './types'\nexport {\n formatMinorAmount,\n formatWhen,\n hubActionFiles,\n hubActionReceipt,\n hubProviderName,\n pastTense,\n presentHubAction,\n splitHubActionPath,\n} from './present'\nexport { summarizeHubResult, unwrapHubResult } from './result'\n\n/** A phase as a status label. */\nexport const HUB_APPROVAL_PHASE_LABELS: Record<HubApprovalPhase, string> = {\n waiting: 'Waiting for you',\n blocked: 'Waiting for the owner',\n queued: 'Queued',\n running: 'Running',\n done: 'Done',\n failed: 'Failed',\n unknown: 'May have run',\n denied: 'Denied',\n expired: 'Expired',\n}\n\n/**\n * The part type marking a user message that resumes the agent after a\n * decision. The message's text goes to the agent unchanged; a transcript\n * renders the decided actions' receipts in its place, never a chat bubble.\n */\nexport const HUB_APPROVAL_RESUME_PART = 'hub-approval-resume'\n\nexport interface HubApprovalResumePart {\n type: typeof HUB_APPROVAL_RESUME_PART\n /** The assistant message whose held calls this resume reports. */\n messageId: string\n}\n\n/** The resume marker among a message's parts, if it carries one. */\nexport function hubApprovalResumePart(parts: ReadonlyArray<Record<string, unknown>> | null | undefined): HubApprovalResumePart | null {\n for (const part of parts ?? []) {\n if (part?.type === HUB_APPROVAL_RESUME_PART && typeof part.messageId === 'string' && part.messageId) {\n return { type: HUB_APPROVAL_RESUME_PART, messageId: part.messageId }\n }\n }\n return null\n}\n"],"mappings":";AAwBO,IAAM,2BAA0D,oBAAI,IAAI,CAAC,WAAW,SAAS,CAAC;AAE9F,IAAM,6BAA4D,oBAAI,IAAI,CAAC,UAAU,SAAS,CAAC;;;ACrBtG,IAAM,YAAY;AAClB,IAAM,WAAW;AACjB,IAAM,YAAY;AAClB,IAAM,aAAa;AAEZ,SAAS,gBAAgB,OAAyC;AACvE,SAAO,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAI,QAAmC,CAAC;AAC3G;AAOO,SAAS,gBAAgB,OAAyB;AACvD,MAAI,UAAmB;AACvB,MAAI,OAAO,YAAY,UAAU;AAC/B,UAAMA,QAAO;AACb,QAAI;AACF,gBAAU,KAAK,MAAMA,KAAI;AAAA,IAC3B,QAAQ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@ async function settleWebhookResponse(response) {
144
144
  }
145
145
  var WEBHOOK_CREDENTIAL_ERRORS = /* @__PURE__ */ new Set(["no_service", "no_team", "invalid_token"]);
146
146
  var WEBHOOK_CHANNEL_ERRORS = /* @__PURE__ */ new Set(["channel_not_found", "channel_is_archived", "action_prohibited"]);
147
- async function checkSlackCredential(options) {
148
- const token = options.token?.trim();
149
- if (!token) {
150
- return {
151
- live: false,
152
- reason: "not-configured",
153
- detail: "no Slack bot token configured \u2014 set SLACK_BOT_TOKEN"
154
- };
155
- }
156
- const fetchImpl = options.fetchImpl ?? fetch;
157
- const controller = new AbortController();
158
- const timer = setTimeout(() => controller.abort(), options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
159
- try {
160
- const response = await fetchImpl(`${SLACK_API}/auth.test`, {
161
- method: "POST",
162
- headers: { Authorization: `Bearer ${token}` },
163
- signal: controller.signal
164
- });
165
- const body = await response.json();
166
- if (body.ok === true) {
167
- return { live: true, team: body.team ?? "unknown", botId: body.bot_id ?? "unknown" };
168
- }
169
- const outcome = classifySlackError(body.error ?? `http_${response.status}`, "(auth.test)");
170
- return {
171
- live: false,
172
- reason: outcome.reason === "channel" ? "credential" : outcome.reason,
173
- detail: outcome.detail
174
- };
175
- } catch (error) {
176
- return {
177
- live: false,
178
- reason: "transport",
179
- detail: `could not reach Slack: ${error instanceof Error ? error.message : String(error)}`
180
- };
181
- } finally {
182
- clearTimeout(timer);
183
- }
184
- }
185
147
 
186
148
  export {
187
- postSlackAlert,
188
- checkSlackCredential
149
+ postSlackAlert
189
150
  };
190
- //# sourceMappingURL=chunk-F2VX6TTJ.js.map
151
+ //# sourceMappingURL=chunk-JRCZHDRG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/alerting/slack.ts"],"sourcesContent":["/**\n * Post operational alerts to Slack with an explicit delivery verdict.\n *\n * Slack can return ok:false under HTTP 200, and revoked webhooks can return\n * no_service. Inspect both status and body. A configured bot token remains\n * authoritative: falling back to a webhook would hide a broken token.\n * Transient failures retry within the caller's bound; credential and channel\n * failures do not. The caller owns escalation and durable incident records.\n */\n\nconst SLACK_API = 'https://slack.com/api'\nconst DEFAULT_TIMEOUT_MS = 10_000\nconst DEFAULT_ATTEMPTS = 3\n\n/**\n * Why an alert did not reach Slack. The split is by what a human must DO about\n * it, since that is the only distinction a caller can act on.\n */\nexport type SlackFailureReason =\n /** No token or no channel configured. Configuration is absent, nothing is broken. */\n | 'not-configured'\n /**\n * The token is dead — revoked, or its app removed from the workspace. No\n * alert will EVER arrive until a human mints a new one. This is itself an\n * incident and the caller should escalate it on a channel that does not\n * depend on Slack.\n */\n | 'credential'\n /**\n * The credential is alive but cannot post HERE: the channel is wrong,\n * archived, or the bot was never invited to it. One human action fixes it.\n */\n | 'channel'\n /** Slack asked us to slow down. Transient; the alert is worth retrying. */\n | 'rate-limited'\n /** The request never got an answer — network, DNS, timeout. Transient. */\n | 'transport'\n /** Slack refused for some other reason; `detail` carries its error code. */\n | 'api'\n\n/** An alert that did not arrive, and why. Named because the classifiers only ever produce this half. */\nexport interface SlackAlertFailure {\n delivered: false\n reason: SlackFailureReason\n /** One line naming what is wrong and what fixes it. Safe to log; carries no token. */\n detail: string\n}\n\n/** What one `postSlackAlert` call did. Never a bare boolean — the caller pages differently per reason. */\nexport type SlackAlertOutcome =\n | {\n delivered: true\n /** The channel id Slack resolved (not necessarily the name that was passed). */\n channel: string\n /** Slack's message timestamp — the message's identity, for a later thread reply. */\n ts: string\n }\n | SlackAlertFailure\n\n/** Define configuration options for posting an alert message to a Slack channel */\nexport interface SlackAlertOptions {\n /**\n * Slack bot token (`xoxb-…`) with `chat:write`. The PREFERRED transport,\n * because it is the only one whose liveness can be checked before an alert\n * needs it. An empty or absent value is `not-configured`, never an error — a\n * product that has not adopted Slack yet must not fail its alerting path.\n */\n token?: string | undefined\n /**\n * Channel to post to: a name (`#infra-alerts`) or an id (`C01234567`). The\n * bot must be a member; Slack answers `not_in_channel` otherwise. Required\n * with `token`, meaningless with `webhookUrl` (a webhook carries its own\n * channel, fixed when it was created).\n */\n channel?: string | undefined\n /**\n * Slack incoming-webhook URL, used only when no `token` is configured.\n *\n * It works and it needs no setup, which is why it is supported — but it\n * cannot be verified without posting, cannot be pointed at a second channel,\n * and gives back an error token instead of a code. Two of the three webhooks\n * this org has held were found revoked. Treat it as the transport you have,\n * not the one you want.\n *\n * When a `token` is also configured this is IGNORED rather than used as a\n * fallback: a dead token must surface as the incident it is, and quietly\n * succeeding over a second transport is how the last outage stayed invisible.\n */\n webhookUrl?: string | undefined\n /** Message body as Slack mrkdwn. Newlines are preserved. */\n text: string\n /**\n * Attempts for a TRANSIENT failure (429 / 5xx / transport). Default 3. A\n * dead credential or a wrong channel is never retried — the answer will not\n * change, and retrying an auth failure is how a token gets rate-limited.\n */\n attempts?: number\n /** Per-request deadline. Default 10s. */\n timeoutMs?: number\n /** Injection seam for tests; defaults to global `fetch`. */\n fetchImpl?: typeof fetch\n /** Injection seam for tests; defaults to a real delay between retries. */\n sleepImpl?: (ms: number) => Promise<void>\n}\n\n/** Slack error codes that mean the CREDENTIAL is dead, not the request. */\nconst CREDENTIAL_ERRORS = new Set([\n 'invalid_auth',\n 'not_authed',\n 'account_inactive',\n 'token_revoked',\n 'token_expired',\n 'no_permission',\n 'missing_scope',\n 'ekm_access_denied',\n])\n\n/** Slack error codes that mean the credential is fine but this CHANNEL is not reachable. */\nconst CHANNEL_ERRORS = new Set([\n 'channel_not_found',\n 'not_in_channel',\n 'is_archived',\n 'restricted_action',\n 'restricted_action_read_only_channel',\n])\n\nfunction remedyFor(reason: SlackFailureReason, error: string, channel: string): string {\n switch (reason) {\n case 'credential':\n return (\n `Slack rejected the bot token (${error}) — no alert can arrive until a human mints a new one. ` +\n 'Reinstall the Slack app and update SLACK_BOT_TOKEN wherever it is stored.'\n )\n case 'channel':\n return (\n `Slack accepted the token but refused ${channel} (${error}) — ` +\n `invite the bot to ${channel}, or correct the channel name.`\n )\n default:\n return `Slack refused the post (${error}).`\n }\n}\n\nfunction classifySlackError(error: string, channel: string): SlackAlertFailure {\n const reason: SlackFailureReason = CREDENTIAL_ERRORS.has(error)\n ? 'credential'\n : CHANNEL_ERRORS.has(error)\n ? 'channel'\n : 'api'\n return { delivered: false, reason, detail: remedyFor(reason, error, channel) }\n}\n\n/** Slack's `Retry-After` is in SECONDS. Bounded so a hostile header cannot park the caller. */\nfunction retryDelayMs(response: Response, attempt: number): number {\n const header = Number(response.headers.get('retry-after'))\n if (Number.isFinite(header) && header > 0) return Math.min(header * 1000, 30_000)\n return Math.min(500 * 2 ** (attempt - 1), 8_000)\n}\n\nconst defaultSleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms))\n\n/**\n * Post one alert to a Slack channel.\n *\n * Never throws and never retries a failure whose answer cannot change. The\n * returned outcome is the whole result — a caller that ignores it has an\n * alerting path it cannot prove works, which is the failure this module was\n * written for.\n */\nexport async function postSlackAlert(options: SlackAlertOptions): Promise<SlackAlertOutcome> {\n const token = options.token?.trim()\n const channel = options.channel?.trim()\n const webhookUrl = options.webhookUrl?.trim()\n\n if (!token && !webhookUrl) {\n return {\n delivered: false,\n reason: 'not-configured',\n detail:\n 'no Slack credential configured — set SLACK_BOT_TOKEN (preferred, verifiable) ' +\n 'or SLACK_WEBHOOK_URL to route alerts to Slack',\n }\n }\n if (token && !channel) {\n return {\n delivered: false,\n reason: 'not-configured',\n detail: 'a Slack bot token is set but no channel is — set the alert channel (e.g. #infra-alerts)',\n }\n }\n\n const fetchImpl = options.fetchImpl ?? fetch\n const sleep = options.sleepImpl ?? defaultSleep\n const attempts = Math.max(1, options.attempts ?? DEFAULT_ATTEMPTS)\n const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS\n\n // A token is never fallen back FROM. If one is configured and dead, that is\n // the incident, and delivering over a webhook instead would hide exactly the\n // condition this module exists to surface.\n const transport: SlackTransport = token\n ? { kind: 'token', token, channel: channel as string }\n : { kind: 'webhook', url: webhookUrl as string }\n\n let lastTransient: SlackAlertFailure = {\n delivered: false,\n reason: 'transport',\n detail: 'Slack was never reached',\n }\n\n for (let attempt = 1; attempt <= attempts; attempt += 1) {\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), timeoutMs)\n let response: Response\n try {\n response = await fetchImpl(requestUrl(transport), {\n method: 'POST',\n headers: requestHeaders(transport),\n body: JSON.stringify(requestBody(transport, options.text)),\n signal: controller.signal,\n })\n } catch (error) {\n lastTransient = {\n delivered: false,\n reason: 'transport',\n detail: `could not reach Slack: ${error instanceof Error ? error.message : String(error)}`,\n }\n if (attempt < attempts) await sleep(Math.min(500 * 2 ** (attempt - 1), 8_000))\n continue\n } finally {\n clearTimeout(timer)\n }\n\n if (response.status === 429 || response.status >= 500) {\n lastTransient = {\n delivered: false,\n reason: response.status === 429 ? 'rate-limited' : 'transport',\n detail: `Slack returned ${response.status}`,\n }\n if (attempt < attempts) await sleep(retryDelayMs(response, attempt))\n continue\n }\n\n // Everything below is a settled answer. BOTH transports put the verdict in\n // the BODY under a 200 — the API as `{\"ok\":false,\"error\":…}`, a webhook as\n // an error token where the literal `ok` should be — so a status check alone\n // reads a revoked credential as a delivered page. That misreading is why\n // this module exists.\n return transport.kind === 'token'\n ? await settleTokenResponse(response, transport.channel)\n : await settleWebhookResponse(response)\n }\n\n return lastTransient\n}\n\ntype SlackTransport =\n | { kind: 'token'; token: string; channel: string }\n | { kind: 'webhook'; url: string }\n\nfunction requestUrl(transport: SlackTransport): string {\n return transport.kind === 'token' ? `${SLACK_API}/chat.postMessage` : transport.url\n}\n\nfunction requestHeaders(transport: SlackTransport): Record<string, string> {\n const headers: Record<string, string> = { 'Content-Type': 'application/json; charset=utf-8' }\n // The token rides a header, never a query string: a URL is logged by proxies\n // and retained in error messages; a header is not. (A webhook URL IS the\n // credential and has no such option — one more reason to prefer a token.)\n if (transport.kind === 'token') headers.Authorization = `Bearer ${transport.token}`\n return headers\n}\n\nfunction requestBody(transport: SlackTransport, text: string): Record<string, string> {\n // A webhook carries its own channel, fixed when it was created; naming one\n // here would be ignored at best and rejected at worst.\n return transport.kind === 'token' ? { channel: transport.channel, text } : { text }\n}\n\nasync function settleTokenResponse(\n response: Response,\n channel: string,\n): Promise<SlackAlertOutcome> {\n let body: { ok?: boolean; error?: string; channel?: string; ts?: string }\n try {\n body = (await response.json()) as typeof body\n } catch {\n return {\n delivered: false,\n reason: 'api',\n detail: `Slack returned ${response.status} with an unreadable body`,\n }\n }\n if (body.ok === true) {\n return { delivered: true, channel: body.channel ?? channel, ts: body.ts ?? '' }\n }\n return classifySlackError(body.error ?? `http_${response.status}`, channel)\n}\n\n/**\n * A webhook confirms delivery with a 2xx AND the literal three-byte body `ok`.\n * A revoked one answers `no_service` / `no_team`, sometimes under a 200. Both\n * halves are required: this is the shape `agent-container` proved against a\n * stand-in webhook, where a healthy, a revoked and a deleted webhook produced\n * byte-identical output under a status-only check.\n */\nasync function settleWebhookResponse(response: Response): Promise<SlackAlertOutcome> {\n const body = (await response.text().catch(() => '')).trim()\n if (response.ok && body === 'ok') {\n // A webhook reports neither the channel it posted to nor a message id.\n return { delivered: true, channel: '(webhook)', ts: '' }\n }\n const error = body || `http_${response.status}`\n const reason: SlackFailureReason = WEBHOOK_CREDENTIAL_ERRORS.has(error)\n ? 'credential'\n : WEBHOOK_CHANNEL_ERRORS.has(error)\n ? 'channel'\n : 'api'\n return {\n delivered: false,\n reason,\n detail:\n reason === 'credential'\n ? `the Slack webhook is revoked (${error}) — no alert can arrive until a human mints a new one. ` +\n 'Prefer replacing it with a bot token, whose liveness can be checked before an alert needs it.'\n : reason === 'channel'\n ? `Slack refused the webhook's channel (${error}) — the channel was archived, or the app lost access.`\n : `Slack refused the webhook post (${error}).`,\n }\n}\n\n/** Webhook error tokens that mean the webhook itself is gone. */\nconst WEBHOOK_CREDENTIAL_ERRORS = new Set(['no_service', 'no_team', 'invalid_token'])\n\n/** Webhook error tokens that mean the webhook is valid but its channel is not usable. */\nconst WEBHOOK_CHANNEL_ERRORS = new Set(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