@hoknie/aip 0.4.0 → 0.5.0

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 (950) hide show
  1. package/.claude-plugin/marketplace.json +3 -0
  2. package/dist/app/actors.js +82 -0
  3. package/dist/app/actors.js.map +1 -0
  4. package/dist/app/application.js +71 -56
  5. package/dist/app/application.js.map +1 -1
  6. package/dist/app/integration-operations.js +34 -0
  7. package/dist/app/integration-operations.js.map +1 -0
  8. package/dist/app/lifecycle.js +91 -2
  9. package/dist/app/lifecycle.js.map +1 -1
  10. package/dist/app/notifications/index.js +44 -0
  11. package/dist/app/notifications/index.js.map +1 -0
  12. package/dist/app/oidc.js +27 -0
  13. package/dist/app/oidc.js.map +1 -0
  14. package/dist/app/saml.js +43 -0
  15. package/dist/app/saml.js.map +1 -0
  16. package/dist/app/timings.js +2 -1
  17. package/dist/app/timings.js.map +1 -1
  18. package/dist/app/wire.js +88 -0
  19. package/dist/app/wire.js.map +1 -0
  20. package/dist/app/wiring.js +10 -0
  21. package/dist/app/wiring.js.map +1 -1
  22. package/dist/cli/main.js +42 -0
  23. package/dist/cli/main.js.map +1 -1
  24. package/dist/feature/access/services/access.js +73 -0
  25. package/dist/feature/access/services/access.js.map +1 -0
  26. package/dist/feature/access/services/create.js +31 -0
  27. package/dist/feature/access/services/create.js.map +1 -0
  28. package/dist/feature/access/services/index.js +3 -0
  29. package/dist/feature/access/services/index.js.map +1 -0
  30. package/dist/feature/access/types/actions.js +145 -0
  31. package/dist/feature/access/types/actions.js.map +1 -0
  32. package/dist/feature/access/types/evaluate.js +58 -0
  33. package/dist/feature/access/types/evaluate.js.map +1 -0
  34. package/dist/feature/access/types/index.js +4 -0
  35. package/dist/feature/access/types/index.js.map +1 -0
  36. package/dist/feature/access/types/presets.js +41 -0
  37. package/dist/feature/access/types/presets.js.map +1 -0
  38. package/dist/feature/agents/clients/agy/runtime.js +1 -0
  39. package/dist/feature/agents/clients/agy/runtime.js.map +1 -1
  40. package/dist/feature/agents/clients/claude/permissions.js +5 -2
  41. package/dist/feature/agents/clients/claude/permissions.js.map +1 -1
  42. package/dist/feature/agents/clients/claude/runtime.js +2 -0
  43. package/dist/feature/agents/clients/claude/runtime.js.map +1 -1
  44. package/dist/feature/agents/clients/cline/runtime.js +1 -0
  45. package/dist/feature/agents/clients/cline/runtime.js.map +1 -1
  46. package/dist/feature/agents/clients/codex/runtime.js +1 -0
  47. package/dist/feature/agents/clients/codex/runtime.js.map +1 -1
  48. package/dist/feature/agents/clients/copilot/runtime.js +1 -0
  49. package/dist/feature/agents/clients/copilot/runtime.js.map +1 -1
  50. package/dist/feature/agents/clients/kilo/runtime.js +1 -0
  51. package/dist/feature/agents/clients/kilo/runtime.js.map +1 -1
  52. package/dist/feature/agents/clients/opencode/runtime.js +1 -0
  53. package/dist/feature/agents/clients/opencode/runtime.js.map +1 -1
  54. package/dist/feature/agents/services/skills.js +4 -1
  55. package/dist/feature/agents/services/skills.js.map +1 -1
  56. package/dist/feature/agents/services/supervisor.js +7 -3
  57. package/dist/feature/agents/services/supervisor.js.map +1 -1
  58. package/dist/feature/agents/types/mcp/env.js +6 -1
  59. package/dist/feature/agents/types/mcp/env.js.map +1 -1
  60. package/dist/feature/agents/types/message.js +13 -1
  61. package/dist/feature/agents/types/message.js.map +1 -1
  62. package/dist/feature/agents/types/runtime.js.map +1 -1
  63. package/dist/feature/agents/types/worker-tools.js +6 -1
  64. package/dist/feature/agents/types/worker-tools.js.map +1 -1
  65. package/dist/feature/audit/repositories/events.js +66 -0
  66. package/dist/feature/audit/repositories/events.js.map +1 -0
  67. package/dist/feature/audit/repositories/index.js +2 -0
  68. package/dist/feature/audit/repositories/index.js.map +1 -0
  69. package/dist/feature/audit/services/audit-log.js +24 -0
  70. package/dist/feature/audit/services/audit-log.js.map +1 -0
  71. package/dist/feature/audit/services/create.js +6 -0
  72. package/dist/feature/audit/services/create.js.map +1 -0
  73. package/dist/feature/audit/services/index.js +3 -0
  74. package/dist/feature/audit/services/index.js.map +1 -0
  75. package/dist/feature/audit/types/event.js +12 -0
  76. package/dist/feature/audit/types/event.js.map +1 -0
  77. package/dist/feature/audit/types/index.js +2 -0
  78. package/dist/feature/audit/types/index.js.map +1 -0
  79. package/dist/feature/compose/services/repository-move.js +8 -1
  80. package/dist/feature/compose/services/repository-move.js.map +1 -1
  81. package/dist/feature/compose/services/repository-removal.js +6 -1
  82. package/dist/feature/compose/services/repository-removal.js.map +1 -1
  83. package/dist/feature/delivery/ports/authors.js +2 -0
  84. package/dist/feature/delivery/ports/authors.js.map +1 -0
  85. package/dist/feature/delivery/services/commit-stamp.js +20 -0
  86. package/dist/feature/delivery/services/commit-stamp.js.map +1 -0
  87. package/dist/feature/delivery/services/create.js +6 -2
  88. package/dist/feature/delivery/services/create.js.map +1 -1
  89. package/dist/feature/delivery/services/deliver.js +8 -0
  90. package/dist/feature/delivery/services/deliver.js.map +1 -1
  91. package/dist/feature/delivery/services/push.js +23 -0
  92. package/dist/feature/delivery/services/push.js.map +1 -0
  93. package/dist/feature/delivery/types/index.js +2 -0
  94. package/dist/feature/delivery/types/index.js.map +1 -1
  95. package/dist/feature/delivery/types/remote-url.js +44 -0
  96. package/dist/feature/delivery/types/remote-url.js.map +1 -0
  97. package/dist/feature/delivery/types/trailer.js +22 -0
  98. package/dist/feature/delivery/types/trailer.js.map +1 -0
  99. package/dist/feature/identity/clients/oidc/client.js +78 -0
  100. package/dist/feature/identity/clients/oidc/client.js.map +1 -0
  101. package/dist/feature/identity/clients/oidc/index.js +2 -0
  102. package/dist/feature/identity/clients/oidc/index.js.map +1 -0
  103. package/dist/feature/identity/clients/oidc/signature.js +51 -0
  104. package/dist/feature/identity/clients/oidc/signature.js.map +1 -0
  105. package/dist/feature/identity/clients/saml/client.js +108 -0
  106. package/dist/feature/identity/clients/saml/client.js.map +1 -0
  107. package/dist/feature/identity/clients/saml/idp-metadata.js +123 -0
  108. package/dist/feature/identity/clients/saml/idp-metadata.js.map +1 -0
  109. package/dist/feature/identity/clients/saml/index.js +3 -0
  110. package/dist/feature/identity/clients/saml/index.js.map +1 -0
  111. package/dist/feature/identity/ports/clock.js +2 -0
  112. package/dist/feature/identity/ports/clock.js.map +1 -0
  113. package/dist/feature/identity/ports/index.js +2 -0
  114. package/dist/feature/identity/ports/index.js.map +1 -0
  115. package/dist/feature/identity/ports/oidc.js +2 -0
  116. package/dist/feature/identity/ports/oidc.js.map +1 -0
  117. package/dist/feature/identity/ports/saml.js +2 -0
  118. package/dist/feature/identity/ports/saml.js.map +1 -0
  119. package/dist/feature/identity/repositories/index.js +7 -0
  120. package/dist/feature/identity/repositories/index.js.map +1 -0
  121. package/dist/feature/identity/repositories/links.js +57 -0
  122. package/dist/feature/identity/repositories/links.js.map +1 -0
  123. package/dist/feature/identity/repositories/saml-assertions.js +16 -0
  124. package/dist/feature/identity/repositories/saml-assertions.js.map +1 -0
  125. package/dist/feature/identity/repositories/sessions.js +27 -0
  126. package/dist/feature/identity/repositories/sessions.js.map +1 -0
  127. package/dist/feature/identity/repositories/sso-requests.js +34 -0
  128. package/dist/feature/identity/repositories/sso-requests.js.map +1 -0
  129. package/dist/feature/identity/repositories/tokens.js +55 -0
  130. package/dist/feature/identity/repositories/tokens.js.map +1 -0
  131. package/dist/feature/identity/repositories/users.js +75 -0
  132. package/dist/feature/identity/repositories/users.js.map +1 -0
  133. package/dist/feature/identity/services/cli-login.js +48 -0
  134. package/dist/feature/identity/services/cli-login.js.map +1 -0
  135. package/dist/feature/identity/services/create.js +76 -0
  136. package/dist/feature/identity/services/create.js.map +1 -0
  137. package/dist/feature/identity/services/index.js +10 -0
  138. package/dist/feature/identity/services/index.js.map +1 -0
  139. package/dist/feature/identity/services/saml.js +115 -0
  140. package/dist/feature/identity/services/saml.js.map +1 -0
  141. package/dist/feature/identity/services/sessions.js +81 -0
  142. package/dist/feature/identity/services/sessions.js.map +1 -0
  143. package/dist/feature/identity/services/sso-accounts.js +46 -0
  144. package/dist/feature/identity/services/sso-accounts.js.map +1 -0
  145. package/dist/feature/identity/services/sso.js +120 -0
  146. package/dist/feature/identity/services/sso.js.map +1 -0
  147. package/dist/feature/identity/services/system.js +15 -0
  148. package/dist/feature/identity/services/system.js.map +1 -0
  149. package/dist/feature/identity/services/tokens.js +74 -0
  150. package/dist/feature/identity/services/tokens.js.map +1 -0
  151. package/dist/feature/identity/services/users.js +103 -0
  152. package/dist/feature/identity/services/users.js.map +1 -0
  153. package/dist/feature/identity/types/claims.js +39 -0
  154. package/dist/feature/identity/types/claims.js.map +1 -0
  155. package/dist/feature/identity/types/index.js +5 -0
  156. package/dist/feature/identity/types/index.js.map +1 -0
  157. package/dist/feature/identity/types/token.js +11 -0
  158. package/dist/feature/identity/types/token.js.map +1 -0
  159. package/dist/feature/identity/types/ttl.js +19 -0
  160. package/dist/feature/identity/types/ttl.js.map +1 -0
  161. package/dist/feature/identity/types/user.js +47 -0
  162. package/dist/feature/identity/types/user.js.map +1 -0
  163. package/dist/feature/integrations/ports/adapter.js +2 -0
  164. package/dist/feature/integrations/ports/adapter.js.map +1 -0
  165. package/dist/feature/integrations/ports/changes.js +2 -0
  166. package/dist/feature/integrations/ports/changes.js.map +1 -0
  167. package/dist/feature/integrations/ports/index.js +5 -0
  168. package/dist/feature/integrations/ports/index.js.map +1 -0
  169. package/dist/feature/integrations/ports/operations.js +2 -0
  170. package/dist/feature/integrations/ports/operations.js.map +1 -0
  171. package/dist/feature/integrations/ports/secrets.js +2 -0
  172. package/dist/feature/integrations/ports/secrets.js.map +1 -0
  173. package/dist/feature/integrations/repositories/connections.js +89 -0
  174. package/dist/feature/integrations/repositories/connections.js.map +1 -0
  175. package/dist/feature/integrations/repositories/deliveries.js +56 -0
  176. package/dist/feature/integrations/repositories/deliveries.js.map +1 -0
  177. package/dist/feature/integrations/repositories/index.js +4 -0
  178. package/dist/feature/integrations/repositories/index.js.map +1 -0
  179. package/dist/feature/integrations/repositories/secrets.js +102 -0
  180. package/dist/feature/integrations/repositories/secrets.js.map +1 -0
  181. package/dist/feature/integrations/services/access.js +63 -0
  182. package/dist/feature/integrations/services/access.js.map +1 -0
  183. package/dist/feature/integrations/services/catalog.js +38 -0
  184. package/dist/feature/integrations/services/catalog.js.map +1 -0
  185. package/dist/feature/integrations/services/checks.js +66 -0
  186. package/dist/feature/integrations/services/checks.js.map +1 -0
  187. package/dist/feature/integrations/services/connections.js +189 -0
  188. package/dist/feature/integrations/services/connections.js.map +1 -0
  189. package/dist/feature/integrations/services/create.js +71 -0
  190. package/dist/feature/integrations/services/create.js.map +1 -0
  191. package/dist/feature/integrations/services/dispatch.js +162 -0
  192. package/dist/feature/integrations/services/dispatch.js.map +1 -0
  193. package/dist/feature/integrations/services/index.js +9 -0
  194. package/dist/feature/integrations/services/index.js.map +1 -0
  195. package/dist/feature/integrations/services/outbound.js +46 -0
  196. package/dist/feature/integrations/services/outbound.js.map +1 -0
  197. package/dist/feature/integrations/services/secrets.js +271 -0
  198. package/dist/feature/integrations/services/secrets.js.map +1 -0
  199. package/dist/feature/integrations/types/connection.js +81 -0
  200. package/dist/feature/integrations/types/connection.js.map +1 -0
  201. package/dist/feature/integrations/types/deliveries.js +5 -0
  202. package/dist/feature/integrations/types/deliveries.js.map +1 -0
  203. package/dist/feature/integrations/types/errors.js +58 -0
  204. package/dist/feature/integrations/types/errors.js.map +1 -0
  205. package/dist/feature/integrations/types/index.js +6 -0
  206. package/dist/feature/integrations/types/index.js.map +1 -0
  207. package/dist/feature/integrations/types/operations.js +16 -0
  208. package/dist/feature/integrations/types/operations.js.map +1 -0
  209. package/dist/feature/integrations/types/secrets.js +8 -0
  210. package/dist/feature/integrations/types/secrets.js.map +1 -0
  211. package/dist/feature/notifications/clients/index.js +7 -0
  212. package/dist/feature/notifications/clients/index.js.map +1 -0
  213. package/dist/feature/notifications/clients/slack/api.js +133 -0
  214. package/dist/feature/notifications/clients/slack/api.js.map +1 -0
  215. package/dist/feature/notifications/clients/slack/blocks.js +189 -0
  216. package/dist/feature/notifications/clients/slack/blocks.js.map +1 -0
  217. package/dist/feature/notifications/clients/slack/channel.js +219 -0
  218. package/dist/feature/notifications/clients/slack/channel.js.map +1 -0
  219. package/dist/feature/notifications/clients/slack/events.js +117 -0
  220. package/dist/feature/notifications/clients/slack/events.js.map +1 -0
  221. package/dist/feature/notifications/clients/slack/kind.js +39 -0
  222. package/dist/feature/notifications/clients/slack/kind.js.map +1 -0
  223. package/dist/feature/notifications/clients/slack/socket.js +141 -0
  224. package/dist/feature/notifications/clients/slack/socket.js.map +1 -0
  225. package/dist/feature/notifications/clients/telegram/api.js +93 -0
  226. package/dist/feature/notifications/clients/telegram/api.js.map +1 -0
  227. package/dist/feature/notifications/clients/telegram/channel.js +250 -0
  228. package/dist/feature/notifications/clients/telegram/channel.js.map +1 -0
  229. package/dist/feature/notifications/clients/telegram/kind.js +34 -0
  230. package/dist/feature/notifications/clients/telegram/kind.js.map +1 -0
  231. package/dist/feature/notifications/clients/telegram/render.js +68 -0
  232. package/dist/feature/notifications/clients/telegram/render.js.map +1 -0
  233. package/dist/feature/notifications/clients/telegram/updates.js +71 -0
  234. package/dist/feature/notifications/clients/telegram/updates.js.map +1 -0
  235. package/dist/feature/notifications/clients/webhook/channel.js +131 -0
  236. package/dist/feature/notifications/clients/webhook/channel.js.map +1 -0
  237. package/dist/feature/notifications/clients/webhook/kind.js +52 -0
  238. package/dist/feature/notifications/clients/webhook/kind.js.map +1 -0
  239. package/dist/feature/notifications/clients/webhook/payload.js +96 -0
  240. package/dist/feature/notifications/clients/webhook/payload.js.map +1 -0
  241. package/dist/feature/notifications/clients/webhook/sign.js +15 -0
  242. package/dist/feature/notifications/clients/webhook/sign.js.map +1 -0
  243. package/dist/feature/notifications/ports/channel.js +2 -0
  244. package/dist/feature/notifications/ports/channel.js.map +1 -0
  245. package/dist/feature/notifications/ports/index.js +2 -0
  246. package/dist/feature/notifications/ports/index.js.map +1 -0
  247. package/dist/feature/notifications/ports/publish.js +2 -0
  248. package/dist/feature/notifications/ports/publish.js.map +1 -0
  249. package/dist/feature/notifications/repositories/answers.js +25 -0
  250. package/dist/feature/notifications/repositories/answers.js.map +1 -0
  251. package/dist/feature/notifications/repositories/attempts.js +34 -0
  252. package/dist/feature/notifications/repositories/attempts.js.map +1 -0
  253. package/dist/feature/notifications/repositories/cursors.js +25 -0
  254. package/dist/feature/notifications/repositories/cursors.js.map +1 -0
  255. package/dist/feature/notifications/repositories/deliveries.js +118 -0
  256. package/dist/feature/notifications/repositories/deliveries.js.map +1 -0
  257. package/dist/feature/notifications/repositories/index.js +7 -0
  258. package/dist/feature/notifications/repositories/index.js.map +1 -0
  259. package/dist/feature/notifications/repositories/outcomes.js +80 -0
  260. package/dist/feature/notifications/repositories/outcomes.js.map +1 -0
  261. package/dist/feature/notifications/repositories/subscriptions.js +85 -0
  262. package/dist/feature/notifications/repositories/subscriptions.js.map +1 -0
  263. package/dist/feature/notifications/services/channels.js +199 -0
  264. package/dist/feature/notifications/services/channels.js.map +1 -0
  265. package/dist/feature/notifications/services/closer.js +79 -0
  266. package/dist/feature/notifications/services/closer.js.map +1 -0
  267. package/dist/feature/notifications/services/create.js +116 -0
  268. package/dist/feature/notifications/services/create.js.map +1 -0
  269. package/dist/feature/notifications/services/dispatcher.js +210 -0
  270. package/dist/feature/notifications/services/dispatcher.js.map +1 -0
  271. package/dist/feature/notifications/services/drawing.js +27 -0
  272. package/dist/feature/notifications/services/drawing.js.map +1 -0
  273. package/dist/feature/notifications/services/factories.js +31 -0
  274. package/dist/feature/notifications/services/factories.js.map +1 -0
  275. package/dist/feature/notifications/services/inbound.js +172 -0
  276. package/dist/feature/notifications/services/inbound.js.map +1 -0
  277. package/dist/feature/notifications/services/index.js +10 -0
  278. package/dist/feature/notifications/services/index.js.map +1 -0
  279. package/dist/feature/notifications/services/journal.js +38 -0
  280. package/dist/feature/notifications/services/journal.js.map +1 -0
  281. package/dist/feature/notifications/services/lanes.js +28 -0
  282. package/dist/feature/notifications/services/lanes.js.map +1 -0
  283. package/dist/feature/notifications/services/outbox.js +2 -0
  284. package/dist/feature/notifications/services/outbox.js.map +1 -0
  285. package/dist/feature/notifications/services/sender.js +129 -0
  286. package/dist/feature/notifications/services/sender.js.map +1 -0
  287. package/dist/feature/notifications/services/senders/index.js +3 -0
  288. package/dist/feature/notifications/services/senders/index.js.map +1 -0
  289. package/dist/feature/notifications/services/senders/recent.js +32 -0
  290. package/dist/feature/notifications/services/senders/recent.js.map +1 -0
  291. package/dist/feature/notifications/services/senders/senders.js +23 -0
  292. package/dist/feature/notifications/services/senders/senders.js.map +1 -0
  293. package/dist/feature/notifications/services/subscriptions.js +221 -0
  294. package/dist/feature/notifications/services/subscriptions.js.map +1 -0
  295. package/dist/feature/notifications/services/webhooks/index.js +3 -0
  296. package/dist/feature/notifications/services/webhooks/index.js.map +1 -0
  297. package/dist/feature/notifications/services/webhooks/streaks.js +44 -0
  298. package/dist/feature/notifications/services/webhooks/streaks.js.map +1 -0
  299. package/dist/feature/notifications/services/webhooks/webhooks.js +249 -0
  300. package/dist/feature/notifications/services/webhooks/webhooks.js.map +1 -0
  301. package/dist/feature/notifications/types/answers.js +42 -0
  302. package/dist/feature/notifications/types/answers.js.map +1 -0
  303. package/dist/feature/notifications/types/channel.js +20 -0
  304. package/dist/feature/notifications/types/channel.js.map +1 -0
  305. package/dist/feature/notifications/types/display-url.js +11 -0
  306. package/dist/feature/notifications/types/display-url.js.map +1 -0
  307. package/dist/feature/notifications/types/drafts.js +35 -0
  308. package/dist/feature/notifications/types/drafts.js.map +1 -0
  309. package/dist/feature/notifications/types/errors.js +38 -0
  310. package/dist/feature/notifications/types/errors.js.map +1 -0
  311. package/dist/feature/notifications/types/events.js +137 -0
  312. package/dist/feature/notifications/types/events.js.map +1 -0
  313. package/dist/feature/notifications/types/index.js +13 -0
  314. package/dist/feature/notifications/types/index.js.map +1 -0
  315. package/dist/feature/notifications/types/limits.js +32 -0
  316. package/dist/feature/notifications/types/limits.js.map +1 -0
  317. package/dist/feature/notifications/types/model.js +29 -0
  318. package/dist/feature/notifications/types/model.js.map +1 -0
  319. package/dist/feature/notifications/types/render.js +132 -0
  320. package/dist/feature/notifications/types/render.js.map +1 -0
  321. package/dist/feature/notifications/types/retry.js +35 -0
  322. package/dist/feature/notifications/types/retry.js.map +1 -0
  323. package/dist/feature/notifications/types/texts.js +130 -0
  324. package/dist/feature/notifications/types/texts.js.map +1 -0
  325. package/dist/feature/notifications/types/webhooks.js +22 -0
  326. package/dist/feature/notifications/types/webhooks.js.map +1 -0
  327. package/dist/feature/queue/repositories/queues.js +6 -4
  328. package/dist/feature/queue/repositories/queues.js.map +1 -1
  329. package/dist/feature/queue/services/advance.js +2 -0
  330. package/dist/feature/queue/services/advance.js.map +1 -1
  331. package/dist/feature/queue/services/create.js +2 -0
  332. package/dist/feature/queue/services/create.js.map +1 -1
  333. package/dist/feature/queue/services/edit.js +2 -0
  334. package/dist/feature/queue/services/edit.js.map +1 -1
  335. package/dist/feature/queue/services/items.js +26 -47
  336. package/dist/feature/queue/services/items.js.map +1 -1
  337. package/dist/feature/queue/services/projects.js +22 -6
  338. package/dist/feature/queue/services/projects.js.map +1 -1
  339. package/dist/feature/queue/services/worker/tasks.js +108 -0
  340. package/dist/feature/queue/services/worker/tasks.js.map +1 -0
  341. package/dist/feature/queue/types/duplicates.js +46 -0
  342. package/dist/feature/queue/types/duplicates.js.map +1 -0
  343. package/dist/feature/queue/types/edit.js +2 -0
  344. package/dist/feature/queue/types/edit.js.map +1 -1
  345. package/dist/feature/queue/types/index.js +1 -0
  346. package/dist/feature/queue/types/index.js.map +1 -1
  347. package/dist/feature/queue/types/items.js.map +1 -1
  348. package/dist/feature/queue/types/limit-hits.js +2 -0
  349. package/dist/feature/queue/types/limit-hits.js.map +1 -1
  350. package/dist/feature/queue/types/returns.js +2 -0
  351. package/dist/feature/queue/types/returns.js.map +1 -1
  352. package/dist/feature/repos/services/projects.js +26 -2
  353. package/dist/feature/repos/services/projects.js.map +1 -1
  354. package/dist/feature/repos/types/index.js +1 -0
  355. package/dist/feature/repos/types/index.js.map +1 -1
  356. package/dist/feature/repos/types/remote.js +28 -0
  357. package/dist/feature/repos/types/remote.js.map +1 -0
  358. package/dist/feature/runs/machine/answers.js +13 -0
  359. package/dist/feature/runs/machine/answers.js.map +1 -1
  360. package/dist/feature/runs/machine/delivery-checks.js +4 -2
  361. package/dist/feature/runs/machine/delivery-checks.js.map +1 -1
  362. package/dist/feature/runs/machine/delivery-flow.js +3 -0
  363. package/dist/feature/runs/machine/delivery-flow.js.map +1 -1
  364. package/dist/feature/runs/machine/push/index.js +2 -0
  365. package/dist/feature/runs/machine/push/index.js.map +1 -0
  366. package/dist/feature/runs/machine/push/push.js +48 -0
  367. package/dist/feature/runs/machine/push/push.js.map +1 -0
  368. package/dist/feature/runs/machine/transition.js +21 -2
  369. package/dist/feature/runs/machine/transition.js.map +1 -1
  370. package/dist/feature/runs/ports/commits.js +2 -0
  371. package/dist/feature/runs/ports/commits.js.map +1 -0
  372. package/dist/feature/runs/ports/notify.js +2 -0
  373. package/dist/feature/runs/ports/notify.js.map +1 -0
  374. package/dist/feature/runs/ports/push.js +2 -0
  375. package/dist/feature/runs/ports/push.js.map +1 -0
  376. package/dist/feature/runs/ports/registry-project.js +2 -0
  377. package/dist/feature/runs/ports/registry-project.js.map +1 -0
  378. package/dist/feature/runs/ports/registry-skills.js +2 -0
  379. package/dist/feature/runs/ports/registry-skills.js.map +1 -0
  380. package/dist/feature/runs/ports/remote-mcp.js +2 -0
  381. package/dist/feature/runs/ports/remote-mcp.js.map +1 -0
  382. package/dist/feature/runs/repositories/finished-runs.js +5 -1
  383. package/dist/feature/runs/repositories/finished-runs.js.map +1 -1
  384. package/dist/feature/runs/repositories/rows.js +9 -0
  385. package/dist/feature/runs/repositories/rows.js.map +1 -1
  386. package/dist/feature/runs/repositories/write.js +4 -4
  387. package/dist/feature/runs/repositories/write.js.map +1 -1
  388. package/dist/feature/runs/services/create.js +1 -0
  389. package/dist/feature/runs/services/create.js.map +1 -1
  390. package/dist/feature/runs/services/effects/actions.js +2 -1
  391. package/dist/feature/runs/services/effects/actions.js.map +1 -1
  392. package/dist/feature/runs/services/effects/attempts.js +44 -54
  393. package/dist/feature/runs/services/effects/attempts.js.map +1 -1
  394. package/dist/feature/runs/services/effects/context.js +2 -0
  395. package/dist/feature/runs/services/effects/context.js.map +1 -1
  396. package/dist/feature/runs/services/effects/conversations.js +159 -1
  397. package/dist/feature/runs/services/effects/conversations.js.map +1 -1
  398. package/dist/feature/runs/services/effects/effects.js +2 -0
  399. package/dist/feature/runs/services/effects/effects.js.map +1 -1
  400. package/dist/feature/runs/services/effects/git.js +15 -2
  401. package/dist/feature/runs/services/effects/git.js.map +1 -1
  402. package/dist/feature/runs/services/effects/runtime-check.js +24 -0
  403. package/dist/feature/runs/services/effects/runtime-check.js.map +1 -1
  404. package/dist/feature/runs/services/effects/skills/index.js +3 -0
  405. package/dist/feature/runs/services/effects/skills/index.js.map +1 -0
  406. package/dist/feature/runs/services/effects/skills/outside-queue.js +58 -0
  407. package/dist/feature/runs/services/effects/skills/outside-queue.js.map +1 -0
  408. package/dist/feature/runs/services/effects/skills/registry.js +70 -0
  409. package/dist/feature/runs/services/effects/skills/registry.js.map +1 -0
  410. package/dist/feature/runs/services/engine.js +8 -1
  411. package/dist/feature/runs/services/engine.js.map +1 -1
  412. package/dist/feature/runs/services/index.js +1 -1
  413. package/dist/feature/runs/services/index.js.map +1 -1
  414. package/dist/feature/runs/services/reads.js +21 -1
  415. package/dist/feature/runs/services/reads.js.map +1 -1
  416. package/dist/feature/runs/services/requests.js +14 -4
  417. package/dist/feature/runs/services/requests.js.map +1 -1
  418. package/dist/feature/runs/services/states.js +2 -2
  419. package/dist/feature/runs/services/states.js.map +1 -1
  420. package/dist/feature/runs/types/answers/answers-text.js +7 -0
  421. package/dist/feature/runs/types/answers/answers-text.js.map +1 -0
  422. package/dist/feature/runs/types/constants.js +1 -1
  423. package/dist/feature/runs/types/constants.js.map +1 -1
  424. package/dist/feature/runs/types/create.js +5 -3
  425. package/dist/feature/runs/types/create.js.map +1 -1
  426. package/dist/feature/runs/types/index.js +1 -0
  427. package/dist/feature/runs/types/index.js.map +1 -1
  428. package/dist/feature/runs/types/problems.js +9 -5
  429. package/dist/feature/runs/types/problems.js.map +1 -1
  430. package/dist/feature/runs/types/run.js.map +1 -1
  431. package/dist/feature/runs/types/stage-status.js +3 -1
  432. package/dist/feature/runs/types/stage-status.js.map +1 -1
  433. package/dist/feature/service-registry/clients/http-mcp/client.js +164 -0
  434. package/dist/feature/service-registry/clients/http-mcp/client.js.map +1 -0
  435. package/dist/feature/service-registry/clients/http-mcp/index.js +2 -0
  436. package/dist/feature/service-registry/clients/http-mcp/index.js.map +1 -0
  437. package/dist/feature/service-registry/ports/adapter.js +2 -0
  438. package/dist/feature/service-registry/ports/adapter.js.map +1 -0
  439. package/dist/feature/service-registry/ports/index.js +3 -0
  440. package/dist/feature/service-registry/ports/index.js.map +1 -0
  441. package/dist/feature/service-registry/ports/transport.js +2 -0
  442. package/dist/feature/service-registry/ports/transport.js.map +1 -0
  443. package/dist/feature/service-registry/repositories/index.js +2 -0
  444. package/dist/feature/service-registry/repositories/index.js.map +1 -0
  445. package/dist/feature/service-registry/repositories/links.js +61 -0
  446. package/dist/feature/service-registry/repositories/links.js.map +1 -0
  447. package/dist/feature/service-registry/services/adapter.js +63 -0
  448. package/dist/feature/service-registry/services/adapter.js.map +1 -0
  449. package/dist/feature/service-registry/services/calls.js +86 -0
  450. package/dist/feature/service-registry/services/calls.js.map +1 -0
  451. package/dist/feature/service-registry/services/catalog-scan.js +49 -0
  452. package/dist/feature/service-registry/services/catalog-scan.js.map +1 -0
  453. package/dist/feature/service-registry/services/create.js +30 -0
  454. package/dist/feature/service-registry/services/create.js.map +1 -0
  455. package/dist/feature/service-registry/services/forwarder.js +107 -0
  456. package/dist/feature/service-registry/services/forwarder.js.map +1 -0
  457. package/dist/feature/service-registry/services/index.js +6 -0
  458. package/dist/feature/service-registry/services/index.js.map +1 -0
  459. package/dist/feature/service-registry/services/links.js +256 -0
  460. package/dist/feature/service-registry/services/links.js.map +1 -0
  461. package/dist/feature/service-registry/services/skill-cache.js +135 -0
  462. package/dist/feature/service-registry/services/skill-cache.js.map +1 -0
  463. package/dist/feature/service-registry/services/skill-source.js +128 -0
  464. package/dist/feature/service-registry/services/skill-source.js.map +1 -0
  465. package/dist/feature/service-registry/services/skills.js +197 -0
  466. package/dist/feature/service-registry/services/skills.js.map +1 -0
  467. package/dist/feature/service-registry/types/descriptor.js +41 -0
  468. package/dist/feature/service-registry/types/descriptor.js.map +1 -0
  469. package/dist/feature/service-registry/types/endpoint.js +2 -0
  470. package/dist/feature/service-registry/types/endpoint.js.map +1 -0
  471. package/dist/feature/service-registry/types/errors.js +26 -0
  472. package/dist/feature/service-registry/types/errors.js.map +1 -0
  473. package/dist/feature/service-registry/types/index.js +7 -0
  474. package/dist/feature/service-registry/types/index.js.map +1 -0
  475. package/dist/feature/service-registry/types/link.js +26 -0
  476. package/dist/feature/service-registry/types/link.js.map +1 -0
  477. package/dist/feature/service-registry/types/semver.js +2 -0
  478. package/dist/feature/service-registry/types/semver.js.map +1 -0
  479. package/dist/feature/service-registry/types/skills.js +27 -0
  480. package/dist/feature/service-registry/types/skills.js.map +1 -0
  481. package/dist/feature/stats/repositories/meta.js +10 -0
  482. package/dist/feature/stats/repositories/meta.js.map +1 -1
  483. package/dist/feature/stats/repositories/records.js +18 -7
  484. package/dist/feature/stats/repositories/records.js.map +1 -1
  485. package/dist/feature/stats/repositories/report.js +14 -4
  486. package/dist/feature/stats/repositories/report.js.map +1 -1
  487. package/dist/feature/stats/services/ledger.js +16 -1
  488. package/dist/feature/stats/services/ledger.js.map +1 -1
  489. package/dist/feature/stats/services/report.js +7 -2
  490. package/dist/feature/stats/services/report.js.map +1 -1
  491. package/dist/feature/stats/types/capture.js +3 -0
  492. package/dist/feature/stats/types/capture.js.map +1 -1
  493. package/dist/feature/stats/types/records.js.map +1 -1
  494. package/dist/feature/stats/types/report.js +2 -0
  495. package/dist/feature/stats/types/report.js.map +1 -1
  496. package/dist/feature/swarm-config/services/access/file.js +83 -0
  497. package/dist/feature/swarm-config/services/access/file.js.map +1 -0
  498. package/dist/feature/swarm-config/services/access/index.js +3 -0
  499. package/dist/feature/swarm-config/services/access/index.js.map +1 -0
  500. package/dist/feature/swarm-config/services/access/validate.js +134 -0
  501. package/dist/feature/swarm-config/services/access/validate.js.map +1 -0
  502. package/dist/feature/swarm-config/services/assemble.js +32 -1
  503. package/dist/feature/swarm-config/services/assemble.js.map +1 -1
  504. package/dist/feature/swarm-config/services/index.js +3 -2
  505. package/dist/feature/swarm-config/services/index.js.map +1 -1
  506. package/dist/feature/swarm-config/services/load.js +10 -1
  507. package/dist/feature/swarm-config/services/load.js.map +1 -1
  508. package/dist/feature/swarm-config/services/sections/mcp-servers.js +33 -5
  509. package/dist/feature/swarm-config/services/sections/mcp-servers.js.map +1 -1
  510. package/dist/feature/swarm-config/services/sections/server-saml.js +116 -0
  511. package/dist/feature/swarm-config/services/sections/server-saml.js.map +1 -0
  512. package/dist/feature/swarm-config/services/sections/server.js +272 -0
  513. package/dist/feature/swarm-config/services/sections/server.js.map +1 -0
  514. package/dist/feature/swarm-config/services/settings.js +25 -1
  515. package/dist/feature/swarm-config/services/settings.js.map +1 -1
  516. package/dist/feature/swarm-config/services/validate-settings.js +51 -3
  517. package/dist/feature/swarm-config/services/validate-settings.js.map +1 -1
  518. package/dist/feature/swarm-config/services/validate-specialists.js +23 -0
  519. package/dist/feature/swarm-config/services/validate-specialists.js.map +1 -1
  520. package/dist/feature/swarm-config/services/validate.js +30 -2
  521. package/dist/feature/swarm-config/services/validate.js.map +1 -1
  522. package/dist/feature/swarm-config/types/access/index.js +2 -0
  523. package/dist/feature/swarm-config/types/access/index.js.map +1 -0
  524. package/dist/feature/swarm-config/types/access/policy.js +10 -0
  525. package/dist/feature/swarm-config/types/access/policy.js.map +1 -0
  526. package/dist/feature/swarm-config/types/index.js +2 -0
  527. package/dist/feature/swarm-config/types/index.js.map +1 -1
  528. package/dist/feature/swarm-config/types/providers/provider.js +9 -0
  529. package/dist/feature/swarm-config/types/providers/provider.js.map +1 -1
  530. package/dist/feature/swarm-config/types/settings.js +31 -7
  531. package/dist/feature/swarm-config/types/settings.js.map +1 -1
  532. package/dist/feature/swarm-config/types/skills/index.js +3 -0
  533. package/dist/feature/swarm-config/types/skills/index.js.map +1 -0
  534. package/dist/feature/swarm-config/types/skills/semver.js +250 -0
  535. package/dist/feature/swarm-config/types/skills/semver.js.map +1 -0
  536. package/dist/feature/swarm-config/types/skills/skill-ref.js +35 -0
  537. package/dist/feature/swarm-config/types/skills/skill-ref.js.map +1 -0
  538. package/dist/feature/swarm-config/types/specialist.js +2 -0
  539. package/dist/feature/swarm-config/types/specialist.js.map +1 -1
  540. package/dist/feature/swarm-config/types/web/index.js +2 -0
  541. package/dist/feature/swarm-config/types/web/index.js.map +1 -0
  542. package/dist/feature/swarm-config/types/web/settings.js +14 -0
  543. package/dist/feature/swarm-config/types/web/settings.js.map +1 -0
  544. package/dist/feature/swarm-edit/services/mcp/editor-mcp.js +2 -0
  545. package/dist/feature/swarm-edit/services/mcp/editor-mcp.js.map +1 -1
  546. package/dist/feature/swarm-edit/services/plan-settings.js +2 -1
  547. package/dist/feature/swarm-edit/services/plan-settings.js.map +1 -1
  548. package/dist/feature/swarm-edit/services/references.js +2 -0
  549. package/dist/feature/swarm-edit/services/references.js.map +1 -1
  550. package/dist/feature/swarm-edit/types/editor.js.map +1 -1
  551. package/dist/feature/swarm-edit/types/setting-fields.js +1 -0
  552. package/dist/feature/swarm-edit/types/setting-fields.js.map +1 -1
  553. package/dist/platform/archive/index.js +2 -0
  554. package/dist/platform/archive/index.js.map +1 -0
  555. package/dist/platform/archive/zip.js +164 -0
  556. package/dist/platform/archive/zip.js.map +1 -0
  557. package/dist/platform/files/index.js +2 -0
  558. package/dist/platform/files/index.js.map +1 -0
  559. package/dist/platform/files/read.js +20 -0
  560. package/dist/platform/files/read.js.map +1 -0
  561. package/dist/platform/git/authorship.js +12 -0
  562. package/dist/platform/git/authorship.js.map +1 -0
  563. package/dist/platform/git/changes.js +26 -0
  564. package/dist/platform/git/changes.js.map +1 -0
  565. package/dist/platform/git/delivery.js +8 -20
  566. package/dist/platform/git/delivery.js.map +1 -1
  567. package/dist/platform/git/index.js +3 -0
  568. package/dist/platform/git/index.js.map +1 -1
  569. package/dist/platform/git/remote.js +69 -0
  570. package/dist/platform/git/remote.js.map +1 -0
  571. package/dist/platform/git/workspace.js +3 -4
  572. package/dist/platform/git/workspace.js.map +1 -1
  573. package/dist/platform/http/index.js +3 -0
  574. package/dist/platform/http/index.js.map +1 -0
  575. package/dist/platform/http/request.js +157 -0
  576. package/dist/platform/http/request.js.map +1 -0
  577. package/dist/platform/http/websocket-frames.js +155 -0
  578. package/dist/platform/http/websocket-frames.js.map +1 -0
  579. package/dist/platform/http/websocket.js +259 -0
  580. package/dist/platform/http/websocket.js.map +1 -0
  581. package/dist/platform/paths/index.js +1 -1
  582. package/dist/platform/paths/index.js.map +1 -1
  583. package/dist/platform/paths/paths.js +6 -0
  584. package/dist/platform/paths/paths.js.map +1 -1
  585. package/dist/platform/secrets/command.js +30 -0
  586. package/dist/platform/secrets/command.js.map +1 -0
  587. package/dist/platform/secrets/errors.js +16 -0
  588. package/dist/platform/secrets/errors.js.map +1 -0
  589. package/dist/platform/secrets/file-key.js +43 -0
  590. package/dist/platform/secrets/file-key.js.map +1 -0
  591. package/dist/platform/secrets/file.js +158 -0
  592. package/dist/platform/secrets/file.js.map +1 -0
  593. package/dist/platform/secrets/index.js +6 -0
  594. package/dist/platform/secrets/index.js.map +1 -0
  595. package/dist/platform/secrets/keyring.js +73 -0
  596. package/dist/platform/secrets/keyring.js.map +1 -0
  597. package/dist/platform/secrets/select.js +124 -0
  598. package/dist/platform/secrets/select.js.map +1 -0
  599. package/dist/platform/secrets/store.js +2 -0
  600. package/dist/platform/secrets/store.js.map +1 -0
  601. package/dist/platform/sqlite/authorship-migration.js +23 -0
  602. package/dist/platform/sqlite/authorship-migration.js.map +1 -0
  603. package/dist/platform/sqlite/identity-migration.js +52 -0
  604. package/dist/platform/sqlite/identity-migration.js.map +1 -0
  605. package/dist/platform/sqlite/integrations-migration.js +147 -0
  606. package/dist/platform/sqlite/integrations-migration.js.map +1 -0
  607. package/dist/platform/sqlite/parts.js +27 -0
  608. package/dist/platform/sqlite/parts.js.map +1 -1
  609. package/dist/platform/sqlite/saml-migration.js +9 -0
  610. package/dist/platform/sqlite/saml-migration.js.map +1 -0
  611. package/dist/platform/sqlite/sso-migration.js +17 -0
  612. package/dist/platform/sqlite/sso-migration.js.map +1 -0
  613. package/dist/platform/sqlite/stats-migration.js +8 -0
  614. package/dist/platform/sqlite/stats-migration.js.map +1 -1
  615. package/dist/presentation/cli/commands/daemon.js +5 -3
  616. package/dist/presentation/cli/commands/daemon.js.map +1 -1
  617. package/dist/presentation/cli/commands/integration/index.js +3 -0
  618. package/dist/presentation/cli/commands/integration/index.js.map +1 -0
  619. package/dist/presentation/cli/commands/integration/integrations.js +239 -0
  620. package/dist/presentation/cli/commands/integration/integrations.js.map +1 -0
  621. package/dist/presentation/cli/commands/integration/skills.js +24 -0
  622. package/dist/presentation/cli/commands/integration/skills.js.map +1 -0
  623. package/dist/presentation/cli/commands/mcp.js +23 -1
  624. package/dist/presentation/cli/commands/mcp.js.map +1 -1
  625. package/dist/presentation/cli/commands/notify/index.js +2 -0
  626. package/dist/presentation/cli/commands/notify/index.js.map +1 -0
  627. package/dist/presentation/cli/commands/notify/notify.js +145 -0
  628. package/dist/presentation/cli/commands/notify/notify.js.map +1 -0
  629. package/dist/presentation/cli/commands/queue-edit.js +0 -24
  630. package/dist/presentation/cli/commands/queue-edit.js.map +1 -1
  631. package/dist/presentation/cli/commands/queue.js +3 -3
  632. package/dist/presentation/cli/commands/queue.js.map +1 -1
  633. package/dist/presentation/cli/commands/run-delivery.js +23 -2
  634. package/dist/presentation/cli/commands/run-delivery.js.map +1 -1
  635. package/dist/presentation/cli/commands/run.js +26 -8
  636. package/dist/presentation/cli/commands/run.js.map +1 -1
  637. package/dist/presentation/cli/commands/server/access.js +43 -0
  638. package/dist/presentation/cli/commands/server/access.js.map +1 -0
  639. package/dist/presentation/cli/commands/server/admin.js +118 -0
  640. package/dist/presentation/cli/commands/server/admin.js.map +1 -0
  641. package/dist/presentation/cli/commands/server/apply.js +82 -0
  642. package/dist/presentation/cli/commands/server/apply.js.map +1 -0
  643. package/dist/presentation/cli/commands/server/audit.js +38 -0
  644. package/dist/presentation/cli/commands/server/audit.js.map +1 -0
  645. package/dist/presentation/cli/commands/server/login.js +141 -0
  646. package/dist/presentation/cli/commands/server/login.js.map +1 -0
  647. package/dist/presentation/cli/commands/server/profile.js +38 -0
  648. package/dist/presentation/cli/commands/server/profile.js.map +1 -0
  649. package/dist/presentation/cli/commands/server/register.js +12 -0
  650. package/dist/presentation/cli/commands/server/register.js.map +1 -0
  651. package/dist/presentation/cli/commands/server/repository.js +34 -0
  652. package/dist/presentation/cli/commands/server/repository.js.map +1 -0
  653. package/dist/presentation/cli/commands/stats.js +10 -1
  654. package/dist/presentation/cli/commands/stats.js.map +1 -1
  655. package/dist/presentation/cli/commands/web.js +26 -5
  656. package/dist/presentation/cli/commands/web.js.map +1 -1
  657. package/dist/presentation/cli/commands/webhook/index.js +2 -0
  658. package/dist/presentation/cli/commands/webhook/index.js.map +1 -0
  659. package/dist/presentation/cli/commands/webhook/webhook.js +172 -0
  660. package/dist/presentation/cli/commands/webhook/webhook.js.map +1 -0
  661. package/dist/presentation/cli/context.js +34 -2
  662. package/dist/presentation/cli/context.js.map +1 -1
  663. package/dist/presentation/cli/help.js +20 -1
  664. package/dist/presentation/cli/help.js.map +1 -1
  665. package/dist/presentation/cli/io.js.map +1 -1
  666. package/dist/presentation/cli/local/config-check-providers.js +11 -0
  667. package/dist/presentation/cli/local/config-check-providers.js.map +1 -1
  668. package/dist/presentation/cli/local/config-check.js +16 -8
  669. package/dist/presentation/cli/local/config-check.js.map +1 -1
  670. package/dist/presentation/cli/options.js +53 -0
  671. package/dist/presentation/cli/options.js.map +1 -1
  672. package/dist/presentation/cli/program.js +8 -0
  673. package/dist/presentation/cli/program.js.map +1 -1
  674. package/dist/presentation/cli/queue-add.js +53 -35
  675. package/dist/presentation/cli/queue-add.js.map +1 -1
  676. package/dist/presentation/cli/queue-print.js +34 -1
  677. package/dist/presentation/cli/queue-print.js.map +1 -1
  678. package/dist/presentation/cli/secret-keys.js +38 -0
  679. package/dist/presentation/cli/secret-keys.js.map +1 -0
  680. package/dist/presentation/format/access/access.js +30 -0
  681. package/dist/presentation/format/access/access.js.map +1 -0
  682. package/dist/presentation/format/access/index.js +2 -0
  683. package/dist/presentation/format/access/index.js.map +1 -0
  684. package/dist/presentation/format/audit/audit.js +29 -0
  685. package/dist/presentation/format/audit/audit.js.map +1 -0
  686. package/dist/presentation/format/audit/index.js +2 -0
  687. package/dist/presentation/format/audit/index.js.map +1 -0
  688. package/dist/presentation/format/index.js +5 -0
  689. package/dist/presentation/format/index.js.map +1 -1
  690. package/dist/presentation/format/integration/index.js +3 -0
  691. package/dist/presentation/format/integration/index.js.map +1 -0
  692. package/dist/presentation/format/integration/integrations.js +95 -0
  693. package/dist/presentation/format/integration/integrations.js.map +1 -0
  694. package/dist/presentation/format/integration/skills.js +17 -0
  695. package/dist/presentation/format/integration/skills.js.map +1 -0
  696. package/dist/presentation/format/notifications/index.js +2 -0
  697. package/dist/presentation/format/notifications/index.js.map +1 -0
  698. package/dist/presentation/format/notifications/notifications.js +44 -0
  699. package/dist/presentation/format/notifications/notifications.js.map +1 -0
  700. package/dist/presentation/format/overview.js +2 -1
  701. package/dist/presentation/format/overview.js.map +1 -1
  702. package/dist/presentation/format/providers/provider-list.js +4 -1
  703. package/dist/presentation/format/providers/provider-list.js.map +1 -1
  704. package/dist/presentation/format/queue.js +2 -1
  705. package/dist/presentation/format/queue.js.map +1 -1
  706. package/dist/presentation/format/runs.js +30 -2
  707. package/dist/presentation/format/runs.js.map +1 -1
  708. package/dist/presentation/format/stats.js +9 -3
  709. package/dist/presentation/format/stats.js.map +1 -1
  710. package/dist/presentation/format/webhooks/index.js +2 -0
  711. package/dist/presentation/format/webhooks/index.js.map +1 -0
  712. package/dist/presentation/format/webhooks/webhooks.js +59 -0
  713. package/dist/presentation/format/webhooks/webhooks.js.map +1 -0
  714. package/dist/presentation/ipc/client/address.js +8 -0
  715. package/dist/presentation/ipc/client/address.js.map +1 -0
  716. package/dist/presentation/ipc/client/client.js +23 -6
  717. package/dist/presentation/ipc/client/client.js.map +1 -1
  718. package/dist/presentation/ipc/client/index.js +1 -0
  719. package/dist/presentation/ipc/client/index.js.map +1 -1
  720. package/dist/presentation/ipc/client/remote.js +85 -0
  721. package/dist/presentation/ipc/client/remote.js.map +1 -0
  722. package/dist/presentation/ipc/contract/access/access.js +21 -0
  723. package/dist/presentation/ipc/contract/access/access.js.map +1 -0
  724. package/dist/presentation/ipc/contract/access/index.js +2 -0
  725. package/dist/presentation/ipc/contract/access/index.js.map +1 -0
  726. package/dist/presentation/ipc/contract/envelope.js +90 -6
  727. package/dist/presentation/ipc/contract/envelope.js.map +1 -1
  728. package/dist/presentation/ipc/contract/identity/audit.js +21 -0
  729. package/dist/presentation/ipc/contract/identity/audit.js.map +1 -0
  730. package/dist/presentation/ipc/contract/identity/identity.js +120 -0
  731. package/dist/presentation/ipc/contract/identity/identity.js.map +1 -0
  732. package/dist/presentation/ipc/contract/identity/index.js +3 -0
  733. package/dist/presentation/ipc/contract/identity/index.js.map +1 -0
  734. package/dist/presentation/ipc/contract/index.js +6 -0
  735. package/dist/presentation/ipc/contract/index.js.map +1 -1
  736. package/dist/presentation/ipc/contract/integrations/integrations.js +85 -0
  737. package/dist/presentation/ipc/contract/integrations/integrations.js.map +1 -0
  738. package/dist/presentation/ipc/contract/integrations/remote.js +16 -0
  739. package/dist/presentation/ipc/contract/integrations/remote.js.map +1 -0
  740. package/dist/presentation/ipc/contract/notifications/notifications.js +44 -0
  741. package/dist/presentation/ipc/contract/notifications/notifications.js.map +1 -0
  742. package/dist/presentation/ipc/contract/notifications/webhooks.js +48 -0
  743. package/dist/presentation/ipc/contract/notifications/webhooks.js.map +1 -0
  744. package/dist/presentation/ipc/contract/panel.js +5 -1
  745. package/dist/presentation/ipc/contract/panel.js.map +1 -1
  746. package/dist/presentation/ipc/contract/queue.js +46 -5
  747. package/dist/presentation/ipc/contract/queue.js.map +1 -1
  748. package/dist/presentation/ipc/contract/repositories.js +4 -0
  749. package/dist/presentation/ipc/contract/repositories.js.map +1 -1
  750. package/dist/presentation/ipc/contract/responses/stats.js +3 -0
  751. package/dist/presentation/ipc/contract/responses/stats.js.map +1 -1
  752. package/dist/presentation/ipc/contract/runs.js +12 -2
  753. package/dist/presentation/ipc/contract/runs.js.map +1 -1
  754. package/dist/presentation/ipc/contract/stats/stats.js +2 -0
  755. package/dist/presentation/ipc/contract/stats/stats.js.map +1 -1
  756. package/dist/presentation/ipc/handlers/access/access.js +74 -0
  757. package/dist/presentation/ipc/handlers/access/access.js.map +1 -0
  758. package/dist/presentation/ipc/handlers/access/author.js +25 -0
  759. package/dist/presentation/ipc/handlers/access/author.js.map +1 -0
  760. package/dist/presentation/ipc/handlers/access/guard.js +57 -0
  761. package/dist/presentation/ipc/handlers/access/guard.js.map +1 -0
  762. package/dist/presentation/ipc/handlers/access/index.js +5 -0
  763. package/dist/presentation/ipc/handlers/access/index.js.map +1 -0
  764. package/dist/presentation/ipc/handlers/access/method-actions.js +13 -0
  765. package/dist/presentation/ipc/handlers/access/method-actions.js.map +1 -0
  766. package/dist/presentation/ipc/handlers/access/method-runs.js +76 -0
  767. package/dist/presentation/ipc/handlers/access/method-runs.js.map +1 -0
  768. package/dist/presentation/ipc/handlers/access/method-settings.js +120 -0
  769. package/dist/presentation/ipc/handlers/access/method-settings.js.map +1 -0
  770. package/dist/presentation/ipc/handlers/access/resource.js +129 -0
  771. package/dist/presentation/ipc/handlers/access/resource.js.map +1 -0
  772. package/dist/presentation/ipc/handlers/access/visible.js +13 -0
  773. package/dist/presentation/ipc/handlers/access/visible.js.map +1 -0
  774. package/dist/presentation/ipc/handlers/audit/audit-account-actions.js +52 -0
  775. package/dist/presentation/ipc/handlers/audit/audit-account-actions.js.map +1 -0
  776. package/dist/presentation/ipc/handlers/audit/audit-actions.js +220 -0
  777. package/dist/presentation/ipc/handlers/audit/audit-actions.js.map +1 -0
  778. package/dist/presentation/ipc/handlers/audit/audit-helpers.js +56 -0
  779. package/dist/presentation/ipc/handlers/audit/audit-helpers.js.map +1 -0
  780. package/dist/presentation/ipc/handlers/audit/audit-list.js +57 -0
  781. package/dist/presentation/ipc/handlers/audit/audit-list.js.map +1 -0
  782. package/dist/presentation/ipc/handlers/audit/audit-readers.js +74 -0
  783. package/dist/presentation/ipc/handlers/audit/audit-readers.js.map +1 -0
  784. package/dist/presentation/ipc/handlers/audit/audit-settings-actions.js +73 -0
  785. package/dist/presentation/ipc/handlers/audit/audit-settings-actions.js.map +1 -0
  786. package/dist/presentation/ipc/handlers/audit/audit-table.js +10 -0
  787. package/dist/presentation/ipc/handlers/audit/audit-table.js.map +1 -0
  788. package/dist/presentation/ipc/handlers/audit/audit.js +101 -0
  789. package/dist/presentation/ipc/handlers/audit/audit.js.map +1 -0
  790. package/dist/presentation/ipc/handlers/audit/index.js +5 -0
  791. package/dist/presentation/ipc/handlers/audit/index.js.map +1 -0
  792. package/dist/presentation/ipc/handlers/identity/identity.js +182 -0
  793. package/dist/presentation/ipc/handlers/identity/identity.js.map +1 -0
  794. package/dist/presentation/ipc/handlers/identity/index.js +2 -0
  795. package/dist/presentation/ipc/handlers/identity/index.js.map +1 -0
  796. package/dist/presentation/ipc/handlers/integrations/index.js +6 -0
  797. package/dist/presentation/ipc/handlers/integrations/index.js.map +1 -0
  798. package/dist/presentation/ipc/handlers/integrations/integrations.js +114 -0
  799. package/dist/presentation/ipc/handlers/integrations/integrations.js.map +1 -0
  800. package/dist/presentation/ipc/handlers/integrations/notifications.js +49 -0
  801. package/dist/presentation/ipc/handlers/integrations/notifications.js.map +1 -0
  802. package/dist/presentation/ipc/handlers/integrations/remote.js +35 -0
  803. package/dist/presentation/ipc/handlers/integrations/remote.js.map +1 -0
  804. package/dist/presentation/ipc/handlers/integrations/skills.js +18 -0
  805. package/dist/presentation/ipc/handlers/integrations/skills.js.map +1 -0
  806. package/dist/presentation/ipc/handlers/integrations/webhooks.js +30 -0
  807. package/dist/presentation/ipc/handlers/integrations/webhooks.js.map +1 -0
  808. package/dist/presentation/ipc/handlers/observers.js +10 -2
  809. package/dist/presentation/ipc/handlers/observers.js.map +1 -1
  810. package/dist/presentation/ipc/handlers/providers.js +9 -1
  811. package/dist/presentation/ipc/handlers/providers.js.map +1 -1
  812. package/dist/presentation/ipc/handlers/queue.js +70 -18
  813. package/dist/presentation/ipc/handlers/queue.js.map +1 -1
  814. package/dist/presentation/ipc/handlers/repositories.js +28 -13
  815. package/dist/presentation/ipc/handlers/repositories.js.map +1 -1
  816. package/dist/presentation/ipc/handlers/runs.js +13 -5
  817. package/dist/presentation/ipc/handlers/runs.js.map +1 -1
  818. package/dist/presentation/ipc/handlers/stats.js +27 -6
  819. package/dist/presentation/ipc/handlers/stats.js.map +1 -1
  820. package/dist/presentation/ipc/handlers/system.js +8 -1
  821. package/dist/presentation/ipc/handlers/system.js.map +1 -1
  822. package/dist/presentation/ipc/handlers/table.js +18 -3
  823. package/dist/presentation/ipc/handlers/table.js.map +1 -1
  824. package/dist/presentation/ipc/log-signals.js +78 -0
  825. package/dist/presentation/ipc/log-signals.js.map +1 -0
  826. package/dist/presentation/ipc/publisher.js +20 -3
  827. package/dist/presentation/ipc/publisher.js.map +1 -1
  828. package/dist/presentation/ipc/server.js +58 -14
  829. package/dist/presentation/ipc/server.js.map +1 -1
  830. package/dist/presentation/ipc/snapshots.js +22 -3
  831. package/dist/presentation/ipc/snapshots.js.map +1 -1
  832. package/dist/presentation/ipc/views/index.js +2 -0
  833. package/dist/presentation/ipc/views/index.js.map +1 -1
  834. package/dist/presentation/ipc/views/notifications/notifications.js +7 -0
  835. package/dist/presentation/ipc/views/notifications/notifications.js.map +1 -0
  836. package/dist/presentation/ipc/views/notifications/webhooks.js +6 -0
  837. package/dist/presentation/ipc/views/notifications/webhooks.js.map +1 -0
  838. package/dist/presentation/ipc/views/queue.js +3 -0
  839. package/dist/presentation/ipc/views/queue.js.map +1 -1
  840. package/dist/presentation/ipc/views/runs.js +18 -7
  841. package/dist/presentation/ipc/views/runs.js.map +1 -1
  842. package/dist/presentation/ipc/views/stats.js +11 -3
  843. package/dist/presentation/ipc/views/stats.js.map +1 -1
  844. package/dist/presentation/mcp/host-kit.js +2 -1
  845. package/dist/presentation/mcp/host-kit.js.map +1 -1
  846. package/dist/presentation/mcp/host-queue.js +19 -13
  847. package/dist/presentation/mcp/host-queue.js.map +1 -1
  848. package/dist/presentation/mcp/host-runs.js +10 -14
  849. package/dist/presentation/mcp/host-runs.js.map +1 -1
  850. package/dist/presentation/mcp/index.js +1 -0
  851. package/dist/presentation/mcp/index.js.map +1 -1
  852. package/dist/presentation/mcp/remote-bridge.js +50 -0
  853. package/dist/presentation/mcp/remote-bridge.js.map +1 -0
  854. package/dist/presentation/mcp/tools.js +18 -0
  855. package/dist/presentation/mcp/tools.js.map +1 -1
  856. package/dist/presentation/mcp/worker-extra.js +77 -5
  857. package/dist/presentation/mcp/worker-extra.js.map +1 -1
  858. package/dist/presentation/mcp/worker-tools.js.map +1 -1
  859. package/dist/presentation/mcp/worker.js +2 -1
  860. package/dist/presentation/mcp/worker.js.map +1 -1
  861. package/dist/presentation/web/access.js +42 -0
  862. package/dist/presentation/web/access.js.map +1 -0
  863. package/dist/presentation/web/auth/context.js +3 -0
  864. package/dist/presentation/web/auth/context.js.map +1 -0
  865. package/dist/presentation/web/auth/gate.js +33 -0
  866. package/dist/presentation/web/auth/gate.js.map +1 -0
  867. package/dist/presentation/web/auth/oidc.js +49 -0
  868. package/dist/presentation/web/auth/oidc.js.map +1 -0
  869. package/dist/presentation/web/auth/pages.js +43 -0
  870. package/dist/presentation/web/auth/pages.js.map +1 -0
  871. package/dist/presentation/web/auth/proxy.js +54 -0
  872. package/dist/presentation/web/auth/proxy.js.map +1 -0
  873. package/dist/presentation/web/auth/routes.js +152 -0
  874. package/dist/presentation/web/auth/routes.js.map +1 -0
  875. package/dist/presentation/web/auth/saml.js +65 -0
  876. package/dist/presentation/web/auth/saml.js.map +1 -0
  877. package/dist/presentation/web/auth/session.js +53 -0
  878. package/dist/presentation/web/auth/session.js.map +1 -0
  879. package/dist/presentation/web/errors.js +18 -1
  880. package/dist/presentation/web/errors.js.map +1 -1
  881. package/dist/presentation/web/hub.js +101 -22
  882. package/dist/presentation/web/hub.js.map +1 -1
  883. package/dist/presentation/web/live/protocol.js +68 -0
  884. package/dist/presentation/web/live/protocol.js.map +1 -0
  885. package/dist/presentation/web/live/read.js +29 -0
  886. package/dist/presentation/web/live/read.js.map +1 -0
  887. package/dist/presentation/web/live/socket.js +93 -0
  888. package/dist/presentation/web/live/socket.js.map +1 -0
  889. package/dist/presentation/web/live/state-topics.js +127 -0
  890. package/dist/presentation/web/live/state-topics.js.map +1 -0
  891. package/dist/presentation/web/live/topics.js +119 -0
  892. package/dist/presentation/web/live/topics.js.map +1 -0
  893. package/dist/presentation/web/options.js.map +1 -1
  894. package/dist/presentation/web/panel/daemon-panel.js +24 -4
  895. package/dist/presentation/web/panel/daemon-panel.js.map +1 -1
  896. package/dist/presentation/web/request.js +42 -3
  897. package/dist/presentation/web/request.js.map +1 -1
  898. package/dist/presentation/web/routes/access/access.js +14 -0
  899. package/dist/presentation/web/routes/access/access.js.map +1 -0
  900. package/dist/presentation/web/routes/audit/audit.js +11 -0
  901. package/dist/presentation/web/routes/audit/audit.js.map +1 -0
  902. package/dist/presentation/web/routes/integrations/integrations.js +147 -0
  903. package/dist/presentation/web/routes/integrations/integrations.js.map +1 -0
  904. package/dist/presentation/web/routes/integrations/webhooks.js +73 -0
  905. package/dist/presentation/web/routes/integrations/webhooks.js.map +1 -0
  906. package/dist/presentation/web/routes/queue.js +1 -1
  907. package/dist/presentation/web/routes/queue.js.map +1 -1
  908. package/dist/presentation/web/routes/runs.js +5 -1
  909. package/dist/presentation/web/routes/runs.js.map +1 -1
  910. package/dist/presentation/web/routes/system.js +21 -13
  911. package/dist/presentation/web/routes/system.js.map +1 -1
  912. package/dist/presentation/web/server.js +95 -17
  913. package/dist/presentation/web/server.js.map +1 -1
  914. package/dist/presentation/web/visible.js +93 -0
  915. package/dist/presentation/web/visible.js.map +1 -0
  916. package/dist/web/assets/EntryList-CMEscRod.js +3 -0
  917. package/dist/web/assets/FilterField-BQc_UwWN.js +7 -0
  918. package/dist/web/assets/LinkTabs-v8NyjDyU.js +4 -0
  919. package/dist/web/assets/SharedPipelinesGroup-BzlZ5U2Y.js +1 -0
  920. package/dist/web/assets/deliveryModes-CHEVNJxR.js +1 -0
  921. package/dist/web/assets/empty-Bho47NOE.js +41 -0
  922. package/dist/web/assets/index-vRNf1iRZ.css +2 -0
  923. package/dist/web/assets/index-ztjIJ-Ig.js +41 -0
  924. package/dist/web/assets/locales-BTrmAl7v.js +1 -0
  925. package/dist/web/assets/pipelines-DVZ7cqyZ.js +14 -0
  926. package/dist/web/assets/settingFields-iGwxRKJI.js +1 -0
  927. package/dist/web/assets/settings-DN_KmJBg.js +6 -0
  928. package/dist/web/assets/stats-4iy1ZRny.js +1 -0
  929. package/dist/web/assets/tabs-D26rwwNs.js +1 -0
  930. package/dist/web/assets/toggle-group-D-oIoacR.js +1 -0
  931. package/dist/web/assets/topology-CaSfGJbk.js +1 -0
  932. package/dist/web/index.html +10 -10
  933. package/integrations/claude-code/.claude-plugin/plugin.json +1 -1
  934. package/package.json +12 -4
  935. package/dist/web/assets/EntryList-Cyc9PxYQ.js +0 -3
  936. package/dist/web/assets/FilterField-DOat7bHi.js +0 -7
  937. package/dist/web/assets/LinkTabs-V5hVhmkv.js +0 -4
  938. package/dist/web/assets/SharedPipelinesGroup-CMV55Qri.js +0 -1
  939. package/dist/web/assets/card-DDDwEBup.js +0 -1
  940. package/dist/web/assets/deliveryModes-OVH1wAmC.js +0 -1
  941. package/dist/web/assets/empty-CF7EgKd2.js +0 -41
  942. package/dist/web/assets/index-7lFvzi1k.js +0 -41
  943. package/dist/web/assets/index-BJYNhfGR.css +0 -2
  944. package/dist/web/assets/locales-3BQ5tRcZ.js +0 -1
  945. package/dist/web/assets/pipelines-BLhOZXCy.js +0 -14
  946. package/dist/web/assets/settingFields-C8-XJpPl.js +0 -1
  947. package/dist/web/assets/settings-96DThDqz.js +0 -6
  948. package/dist/web/assets/stats-B1imf_Vj.js +0 -1
  949. package/dist/web/assets/tabs-DyEM16mP.js +0 -1
  950. package/dist/web/assets/topology-Dyq425Mw.js +0 -1
@@ -0,0 +1,250 @@
1
+ import { ChannelFailure, texts, } from '../../types/index.js';
2
+ import { TelegramApi, TelegramError, toFailure } from './api.js';
3
+ import { allowedUsers, TELEGRAM_KIND } from './kind.js';
4
+ import { renderMessage } from './render.js';
5
+ import { isCommand, isPerson, isIdCommand, parseUpdates, personOf, shortKeyOfPrompt, } from './updates.js';
6
+ const SEND_TIMEOUT_MS = 15_000;
7
+ /** How long Telegram holds a `getUpdates` call open when there is nothing to tell. */
8
+ const POLL_SECONDS = 25;
9
+ const POLL_TIMEOUT_MS = (POLL_SECONDS + 15) * 1000;
10
+ const MAX_BACKOFF_MS = 60_000;
11
+ const CONFLICT_PAUSE_MS = 60_000;
12
+ const CONFLICT_HINT = 'telegram answered 409: the bot has a webhook or another poller; delete the webhook of the bot';
13
+ function pause(ms, signal) {
14
+ return new Promise((resolve) => {
15
+ if (signal.aborted)
16
+ return resolve();
17
+ const timer = setTimeout(resolve, ms);
18
+ signal.addEventListener('abort', () => {
19
+ clearTimeout(timer);
20
+ resolve();
21
+ }, { once: true });
22
+ });
23
+ }
24
+ /** A chat of Telegram: messages by `sendMessage`, answers by `getUpdates` with a long wait. */
25
+ export class TelegramChannel {
26
+ options;
27
+ constructor(options) {
28
+ this.options = options;
29
+ }
30
+ chat() {
31
+ const chat = this.options.connection.params.chat_id;
32
+ if (chat === undefined || chat === '') {
33
+ throw new ChannelFailure('chat_id is not set', { permanent: true });
34
+ }
35
+ return chat;
36
+ }
37
+ async call(method, body) {
38
+ try {
39
+ return await this.options.api.call(method, body, { timeoutMs: SEND_TIMEOUT_MS });
40
+ }
41
+ catch (error) {
42
+ throw toFailure(error);
43
+ }
44
+ }
45
+ /** The core hands over the delivery; a chat draws it and sends the picture. */
46
+ deliver(message) {
47
+ return this.send(message.draw, message.delivery.shortKey);
48
+ }
49
+ async send(draw, shortKey) {
50
+ const chat = this.chat();
51
+ const { text, keyboard } = renderMessage(draw, shortKey, this.options.language);
52
+ const sent = (await this.call('sendMessage', {
53
+ chat_id: Number(chat),
54
+ text,
55
+ parse_mode: 'HTML',
56
+ link_preview_options: { is_disabled: true },
57
+ ...(keyboard.length === 0 ? {} : { reply_markup: { inline_keyboard: keyboard } }),
58
+ }));
59
+ if (typeof sent?.message_id !== 'number') {
60
+ throw new ChannelFailure('telegram sent no message id', { permanent: false });
61
+ }
62
+ return { chat_id: chat, message_id: sent.message_id };
63
+ }
64
+ async update(ref, draw, shortKey) {
65
+ const { text, keyboard } = renderMessage(draw, shortKey, this.options.language);
66
+ try {
67
+ await this.options.api.call('editMessageText', {
68
+ chat_id: Number(ref.chat_id),
69
+ message_id: Number(ref.message_id),
70
+ text,
71
+ parse_mode: 'HTML',
72
+ link_preview_options: { is_disabled: true },
73
+ reply_markup: { inline_keyboard: keyboard },
74
+ }, { timeoutMs: SEND_TIMEOUT_MS });
75
+ }
76
+ catch (error) {
77
+ if (error instanceof TelegramError && /message is not modified/i.test(error.message))
78
+ return;
79
+ throw toFailure(error);
80
+ }
81
+ }
82
+ async sendText(text) {
83
+ const chat = this.chat();
84
+ const sent = (await this.call('sendMessage', { chat_id: Number(chat), text }));
85
+ return { chat_id: chat, message_id: sent?.message_id ?? 0 };
86
+ }
87
+ async listen(handler, signal, report) {
88
+ let failures = 0;
89
+ let listening = false;
90
+ while (!signal.aborted) {
91
+ const cursor = this.options.cursor.get();
92
+ let result;
93
+ try {
94
+ result = await this.options.api.call('getUpdates', {
95
+ timeout: POLL_SECONDS,
96
+ allowed_updates: ['message', 'callback_query'],
97
+ ...(cursor === null ? {} : { offset: Number(cursor) }),
98
+ }, { timeoutMs: POLL_TIMEOUT_MS, signal });
99
+ }
100
+ catch (error) {
101
+ if (signal.aborted)
102
+ return;
103
+ const failure = toFailure(error);
104
+ listening = false;
105
+ if (failure.unauthorized) {
106
+ report({ state: 'error', error: failure.message, unauthorized: true });
107
+ return;
108
+ }
109
+ const conflict = error instanceof TelegramError && error.status === 409;
110
+ report({
111
+ state: 'error',
112
+ error: conflict ? CONFLICT_HINT : failure.message,
113
+ unauthorized: false,
114
+ });
115
+ failures += 1;
116
+ await pause(conflict
117
+ ? CONFLICT_PAUSE_MS
118
+ : (failure.retryAfterMs ?? Math.min(1000 * 2 ** failures, MAX_BACKOFF_MS)), signal);
119
+ continue;
120
+ }
121
+ failures = 0;
122
+ if (!listening) {
123
+ listening = true;
124
+ report({ state: 'listening' });
125
+ }
126
+ const { updates, last } = parseUpdates(result);
127
+ for (const update of updates) {
128
+ if (signal.aborted)
129
+ break;
130
+ await this.process(update, handler).catch(() => undefined);
131
+ }
132
+ // The position moves after the whole batch: an update seen twice is claimed once by the core.
133
+ if (last !== null)
134
+ this.options.cursor.set(String(last + 1));
135
+ }
136
+ }
137
+ async process(update, handler) {
138
+ const t = texts(this.options.language);
139
+ const event = String(update.update_id);
140
+ const callback = update.callback_query;
141
+ if (callback !== undefined) {
142
+ const [shortKey, ...rest] = (callback.data ?? '').split(':');
143
+ const chat = callback.message?.chat.id;
144
+ if (chat === undefined || shortKey === undefined || rest.length === 0) {
145
+ await this.quiet('answerCallbackQuery', { callback_query_id: callback.id });
146
+ return;
147
+ }
148
+ this.see(callback.from);
149
+ const result = await handler.handle({
150
+ type: 'action',
151
+ event,
152
+ chat: String(chat),
153
+ user: String(callback.from.id),
154
+ shortKey,
155
+ action: rest.join(':'),
156
+ });
157
+ if (result.kind === 'prompt') {
158
+ await this.quiet('answerCallbackQuery', { callback_query_id: callback.id });
159
+ await this.quiet('sendMessage', {
160
+ chat_id: chat,
161
+ text: `${t.replyPrompt(result.questions)}\n#${result.shortKey}`,
162
+ reply_to_message_id: callback.message?.message_id,
163
+ reply_markup: { force_reply: true, selective: true },
164
+ });
165
+ return;
166
+ }
167
+ await this.quiet('answerCallbackQuery', {
168
+ callback_query_id: callback.id,
169
+ ...resultText(result, t.results),
170
+ });
171
+ return;
172
+ }
173
+ const message = update.message;
174
+ if (message?.text === undefined)
175
+ return;
176
+ if (isIdCommand(message.text)) {
177
+ this.see(message.from);
178
+ await this.quiet('sendMessage', {
179
+ chat_id: message.chat.id,
180
+ text: t.who(String(message.chat.id), String(message.from?.id ?? '')),
181
+ });
182
+ return;
183
+ }
184
+ if (isCommand(message.text) || message.from === undefined)
185
+ return;
186
+ const replied = message.reply_to_message;
187
+ if (replied === undefined)
188
+ return;
189
+ this.see(message.from);
190
+ const input = {
191
+ type: 'text',
192
+ event,
193
+ chat: String(message.chat.id),
194
+ user: String(message.from.id),
195
+ text: message.text,
196
+ target: { shortKey: shortKeyOfPrompt(replied.text), message: String(replied.message_id) },
197
+ };
198
+ const result = await handler.handle(input);
199
+ const answer = resultText(result, t.results).text;
200
+ if (answer !== undefined) {
201
+ await this.quiet('sendMessage', {
202
+ chat_id: message.chat.id,
203
+ text: answer,
204
+ reply_to_message_id: message.message_id,
205
+ });
206
+ }
207
+ }
208
+ /** Tells the core who is writing; a failure of that never stops the handling of the update. */
209
+ see(from) {
210
+ if (!isPerson(from))
211
+ return;
212
+ try {
213
+ this.options.seen?.(personOf(from));
214
+ }
215
+ catch {
216
+ // the list of recent senders is a convenience
217
+ }
218
+ }
219
+ /** A call whose failure changes nothing: an acknowledgement or a hint. */
220
+ async quiet(method, body) {
221
+ try {
222
+ await this.options.api.call(method, body, { timeoutMs: SEND_TIMEOUT_MS });
223
+ }
224
+ catch {
225
+ // the user sees no acknowledgement; the answer itself is already handled
226
+ }
227
+ }
228
+ }
229
+ function resultText(result, results) {
230
+ const text = results[result.kind];
231
+ return text === undefined ? {} : { text };
232
+ }
233
+ /** The channel kind `telegram`: how its parameters are read and how its adapter is built. */
234
+ export function telegramChannelFactory(api) {
235
+ const languageOf = (params) => params.language === 'ru' ? 'ru' : 'en';
236
+ return {
237
+ kind: TELEGRAM_KIND,
238
+ language: languageOf,
239
+ allows: (params, chat, user) => params.chat_id !== undefined &&
240
+ params.chat_id === chat &&
241
+ allowedUsers(params).includes(user),
242
+ missingForSubscription: (params) => params.chat_id === undefined || params.chat_id === '' ? 'chat_id' : null,
243
+ create: (options) => new TelegramChannel({
244
+ ...options,
245
+ language: languageOf(options.connection.params),
246
+ api: new TelegramApi({ ...api, token: () => options.secret('bot_token') }),
247
+ }),
248
+ };
249
+ }
250
+ //# sourceMappingURL=channel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel.js","sourceRoot":"","sources":["../../../../../src/feature/notifications/clients/telegram/channel.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,cAAc,EACd,KAAK,GAON,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAA2B,MAAM,UAAU,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,gBAAgB,GAEjB,MAAM,cAAc,CAAC;AAEtB,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,sFAAsF;AACtF,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,eAAe,GAAG,CAAC,YAAY,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC;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,MAAwC,EAAY,EAAE,CACxE,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACzC,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAC7B,MAAM,CAAC,OAAO,KAAK,SAAS;YAC5B,MAAM,CAAC,OAAO,KAAK,IAAI;YACvB,YAAY,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;QACrC,sBAAsB,EAAE,CAAC,MAAM,EAAE,EAAE,CACjC,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;QAC1E,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAClB,IAAI,eAAe,CAAC;YAClB,GAAG,OAAO;YACV,QAAQ,EAAE,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;YAC/C,GAAG,EAAE,IAAI,WAAW,CAAC,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;SAC3E,CAAC;KACL,CAAC;AACJ,CAAC"}
@@ -0,0 +1,34 @@
1
+ export const TELEGRAM_KIND = 'telegram';
2
+ /** What the catalog of integrations knows about the kind: parameters and the one secret slot. */
3
+ export const telegramDescriptor = {
4
+ kind: TELEGRAM_KIND,
5
+ title: 'Telegram bot',
6
+ params: [
7
+ // A user, a group or a supergroup: a signed whole number.
8
+ { name: 'chat_id', required: false, maxLength: 20, pattern: '-?[1-9][0-9]{0,17}' },
9
+ // Positive user ids, separated by commas: the only people whose answers are accepted.
10
+ {
11
+ name: 'allowed_users',
12
+ required: false,
13
+ userList: true,
14
+ maxLength: 400,
15
+ pattern: '[1-9][0-9]{0,17}(,[1-9][0-9]{0,17})*',
16
+ },
17
+ { name: 'language', required: false, maxLength: 2, values: ['en', 'ru'] },
18
+ ],
19
+ secrets: [{ slot: 'bot_token', required: true }],
20
+ directions: ['inbound', 'outbound'],
21
+ operations: [],
22
+ };
23
+ /** The adapter of the integrations: the kind has no operations beyond what the channel does. */
24
+ export function telegramAdapter() {
25
+ return { descriptor: telegramDescriptor };
26
+ }
27
+ /** The ids of the users the connection allows, from the parameter. */
28
+ export function allowedUsers(params) {
29
+ return (params.allowed_users ?? '')
30
+ .split(',')
31
+ .map((one) => one.trim())
32
+ .filter((one) => one !== '');
33
+ }
34
+ //# sourceMappingURL=kind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kind.js","sourceRoot":"","sources":["../../../../../src/feature/notifications/clients/telegram/kind.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;AAExC,iGAAiG;AACjG,MAAM,CAAC,MAAM,kBAAkB,GAAsB;IACnD,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,cAAc;IACrB,MAAM,EAAE;QACN,0DAA0D;QAC1D,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;QAClF,sFAAsF;QACtF;YACE,IAAI,EAAE,eAAe;YACrB,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,GAAG;YACd,OAAO,EAAE,sCAAsC;SAChD;QACD,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE;KAC1E;IACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAChD,UAAU,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC;IACnC,UAAU,EAAE,EAAE;CACf,CAAC;AAEF,gGAAgG;AAChG,MAAM,UAAU,eAAe;IAC7B,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC;AAC5C,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,YAAY,CAAC,MAAwC;IACnE,OAAO,CAAC,MAAM,CAAC,aAAa,IAAI,EAAE,CAAC;SAChC,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACxB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { DEFAULT_LIMITS, texts, tighten, truncate, } from '../../types/index.js';
2
+ /** The most a message may hold in Telegram. */
3
+ export const TEXT_LIMIT = 4096;
4
+ /** The most the data of a button may hold, in bytes. */
5
+ export const CALLBACK_LIMIT = 64;
6
+ const LABEL_LIMIT = 36;
7
+ export function escapeHtml(text) {
8
+ return text.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
9
+ }
10
+ function compose(message, shortKey, language) {
11
+ const t = texts(language);
12
+ const lines = [`<b>${escapeHtml(message.headline)}</b> ${escapeHtml(message.title)}`];
13
+ lines.push(...message.details.map(escapeHtml));
14
+ if (message.link !== null) {
15
+ lines.push(`<a href="${escapeHtml(message.link)}">${escapeHtml(t.openLink)}</a>`);
16
+ }
17
+ if (message.body !== null)
18
+ lines.push('', escapeHtml(message.body));
19
+ for (const question of message.questions) {
20
+ lines.push('', `<b>${question.index}.</b> ${escapeHtml(question.text)}`);
21
+ for (const option of question.options) {
22
+ const marks = `${option.recommended ? '⭐' : ''}${option.selected ? '✅' : ''}`;
23
+ lines.push(`${question.index}.${option.index} ${escapeHtml(option.text)}${marks === '' ? '' : ` ${marks}`}`);
24
+ }
25
+ if (question.options.length === 0 && question.recommendation !== null) {
26
+ lines.push(`⭐ ${escapeHtml(t.recommended)}: ${escapeHtml(question.recommendation)}`);
27
+ }
28
+ lines.push(question.answer === null
29
+ ? `<i>${escapeHtml(t.waiting)}</i>`
30
+ : `→ <b>${escapeHtml(question.answer)}</b>`);
31
+ }
32
+ if (message.status !== null)
33
+ lines.push('', `<i>${escapeHtml(message.status)}</i>`);
34
+ if (message.notice !== null)
35
+ lines.push(`<i>${escapeHtml(message.notice)}</i>`);
36
+ return { text: lines.join('\n'), keyboard: buttons(message, shortKey) };
37
+ }
38
+ /** A button of an option shows `<question>.<option> <text>`, shortened; its data names no text. */
39
+ function buttons(message, shortKey) {
40
+ const byId = new Map(message.questions.flatMap((question) => question.options.map((option) => [`o:${question.index}:${option.index}`, { question, option }])));
41
+ return message.rows.map((row) => row.map((action) => {
42
+ const chosen = byId.get(action.id);
43
+ const label = chosen === undefined
44
+ ? action.label
45
+ : `${chosen.option.recommended ? '⭐ ' : ''}${chosen.option.selected ? '✅ ' : ''}${chosen.question.index}.${chosen.option.index} ${truncate(chosen.option.text, LABEL_LIMIT).text}`;
46
+ const data = `${shortKey}:${action.id}`;
47
+ if (Buffer.byteLength(data) > CALLBACK_LIMIT)
48
+ throw new Error('callback data is too long');
49
+ return { text: label, callback_data: data };
50
+ }));
51
+ }
52
+ /** The message drawn again with tighter limits until it fits in Telegram; every option stays. */
53
+ export function renderMessage(draw, shortKey, language) {
54
+ let limits = DEFAULT_LIMITS;
55
+ for (;;) {
56
+ const rendered = compose(draw(limits), shortKey, language);
57
+ if (rendered.text.length <= TEXT_LIMIT)
58
+ return rendered;
59
+ const next = tighten(limits);
60
+ if (next === null) {
61
+ // Nothing is left to cut but the whole: the end is dropped, the buttons stay.
62
+ const cut = rendered.text.slice(0, TEXT_LIMIT - 2);
63
+ return { ...rendered, text: `${cut.slice(0, Math.max(cut.lastIndexOf('\n'), 0))}\n…` };
64
+ }
65
+ limits = next;
66
+ }
67
+ }
68
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../../../../src/feature/notifications/clients/telegram/render.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,EACL,OAAO,EACP,QAAQ,GAMT,MAAM,sBAAsB,CAAC;AAE9B,+CAA+C;AAC/C,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAC/B,wDAAwD;AACxD,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AACjC,MAAM,WAAW,GAAG,EAAE,CAAC;AAYvB,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACvF,CAAC;AAED,SAAS,OAAO,CAAC,OAAoB,EAAE,QAAgB,EAAE,QAAkB;IACzE,MAAM,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1B,MAAM,KAAK,GAAa,CAAC,MAAM,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAChG,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;IAC/C,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QAC1B,KAAK,CAAC,IAAI,CAAC,YAAY,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACpF,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC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3
+ id: z.number().int(),
4
+ is_bot: z.boolean().optional(),
5
+ username: z.string().optional(),
6
+ first_name: z.string().optional(),
7
+ last_name: z.string().optional(),
8
+ });
9
+ const chat = z.object({ id: z.number().int() });
10
+ const message = z.object({
11
+ message_id: z.number().int(),
12
+ chat,
13
+ from: user.optional(),
14
+ text: z.string().optional(),
15
+ reply_to_message: z
16
+ .object({ message_id: z.number().int(), text: z.string().optional(), from: user.optional() })
17
+ .optional(),
18
+ });
19
+ const callback = z.object({
20
+ id: z.string(),
21
+ from: user,
22
+ message: z.object({ message_id: z.number().int(), chat }).optional(),
23
+ data: z.string().optional(),
24
+ });
25
+ /** An update of `getUpdates`, as far as the daemon looks at it; everything else is dropped. */
26
+ export const updateSchema = z.object({
27
+ update_id: z.number().int(),
28
+ message: message.optional(),
29
+ callback_query: callback.optional(),
30
+ });
31
+ /**
32
+ * The updates of one answer. One that does not fit the schema is skipped, but its id still moves the
33
+ * read position forward, so it is not asked for again.
34
+ */
35
+ export function parseUpdates(result) {
36
+ if (!Array.isArray(result))
37
+ return { updates: [], last: null };
38
+ const updates = [];
39
+ let last = null;
40
+ for (const item of result) {
41
+ const id = item?.update_id;
42
+ if (typeof id === 'number' && Number.isInteger(id))
43
+ last = Math.max(last ?? id, id);
44
+ const parsed = updateSchema.safeParse(item);
45
+ if (parsed.success)
46
+ updates.push(parsed.data);
47
+ }
48
+ return { updates, last };
49
+ }
50
+ /** The short key a prompt of the bot carries in its text: `#ABCDEFGHIJ`. */
51
+ export function shortKeyOfPrompt(text) {
52
+ return /#([A-Z2-7]{10})\b/.exec(text ?? '')?.[1] ?? null;
53
+ }
54
+ /** `/id` and `/id@botname` ask for the ids; every other command is ignored. */
55
+ export function isIdCommand(text) {
56
+ return /^\/id(@\w+)?(\s|$)/i.test(text.trim());
57
+ }
58
+ export function isCommand(text) {
59
+ return text.trim().startsWith('/');
60
+ }
61
+ /** A person of Telegram as a panel shows them: `@username`, else the first and the last name. */
62
+ export function personOf(from) {
63
+ const name = [from.first_name, from.last_name].filter((one) => one !== undefined && one !== '');
64
+ const label = from.username ? `@${from.username}` : name.join(' ');
65
+ return { user: String(from.id), label: label === '' ? null : label };
66
+ }
67
+ /** Whether the sender is a person: a bot is never offered as a user to allow. */
68
+ export function isPerson(from) {
69
+ return from !== undefined && from.is_bot !== true;
70
+ }
71
+ //# sourceMappingURL=updates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updates.js","sourceRoot":"","sources":["../../../../../src/feature/notifications/clients/telegram/updates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC;IACpB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IACpB,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC9B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC;AACH,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAEhD,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC;IACvB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAC5B,IAAI;IACJ,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE;IACrB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,gBAAgB,EAAE,CAAC;SAChB,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,IAAI,EA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FAAiF;AACjF,MAAM,UAAU,QAAQ,CAAC,IAAsC;IAC7D,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC;AACpD,CAAC"}
@@ -0,0 +1,131 @@
1
+ import { httpFailureCode, httpRequest } from '../../../../platform/http/index.js';
2
+ import { ChannelFailure, linkOf, WEBHOOK_RETRY, } from '../../types/index.js';
3
+ import { webhookBody } from './payload.js';
4
+ import { WEBHOOK_KIND, WEBHOOK_SECRET_SLOT } from './kind.js';
5
+ import { signedHeaders } from './sign.js';
6
+ /** One attempt, from the connection to the end of the answer. */
7
+ export const ATTEMPT_TIMEOUT_MS = 10_000;
8
+ /** How much of the answer is read. */
9
+ export const RESPONSE_LIMIT = 64 * 1024;
10
+ const EXCERPT_CHARS = 1024;
11
+ /** The seconds a `Retry-After` header asks for, as milliseconds; null for anything else. */
12
+ export function retryAfterMs(value, now) {
13
+ const text = (Array.isArray(value) ? value[0] : value)?.trim();
14
+ if (text === undefined || text === '')
15
+ return null;
16
+ if (/^\d+$/.test(text))
17
+ return Math.min(Number(text), 86_400) * 1000;
18
+ const at = Date.parse(text);
19
+ return Number.isNaN(at) ? null : Math.max(at - now, 0);
20
+ }
21
+ const ERROR_TEXT = {
22
+ timeout: 'the receiver did not answer in time',
23
+ proxy_refused: 'the proxy refused the connection',
24
+ too_large: 'the answer of the receiver is too large',
25
+ network: 'cannot reach the receiver',
26
+ aborted: 'the request was cancelled',
27
+ };
28
+ /** Sends the events of the runs to the address of a webhook, signed as Standard Webhooks wants. */
29
+ export class WebhookChannel {
30
+ options;
31
+ factory;
32
+ constructor(options, factory) {
33
+ this.options = options;
34
+ this.factory = factory;
35
+ }
36
+ async deliver(message) {
37
+ const { delivery } = message;
38
+ const now = this.options.now ?? Date.now;
39
+ const url = this.options.connection.params.url;
40
+ if (url === undefined)
41
+ throw new ChannelFailure('url is not set', { permanent: true });
42
+ const secret = await this.options.secret(WEBHOOK_SECRET_SLOT);
43
+ if (secret === null) {
44
+ throw new ChannelFailure('signing_secret is not set', { permanent: true });
45
+ }
46
+ const id = `msg_${delivery.shortKey}`;
47
+ const startedAt = now();
48
+ const body = webhookBody({
49
+ kind: delivery.kind,
50
+ key: delivery.eventKey,
51
+ run: delivery.run,
52
+ data: delivery.payload,
53
+ at: delivery.kind === 'test' ? startedAt : delivery.createdAt,
54
+ url: delivery.kind === 'test' ? null : linkOf(message.publicUrl, delivery.run, delivery.group),
55
+ });
56
+ const began = performance.now();
57
+ const record = (attempt) => this.options.record?.(delivery.id, {
58
+ startedAt,
59
+ durationMs: performance.now() - began,
60
+ ...attempt,
61
+ });
62
+ let response;
63
+ try {
64
+ response = await httpRequest({
65
+ url,
66
+ method: 'POST',
67
+ headers: {
68
+ 'content-type': 'application/json',
69
+ 'user-agent': `aip-webhooks/${this.factory.version}`,
70
+ ...signedHeaders(secret, id, Math.floor(startedAt / 1000), body),
71
+ },
72
+ body,
73
+ timeoutMs: this.factory.timeoutMs ?? ATTEMPT_TIMEOUT_MS,
74
+ maxResponseBytes: RESPONSE_LIMIT,
75
+ truncateResponse: true,
76
+ proxy: this.factory.proxy(),
77
+ ...(this.factory.ca === undefined ? {} : { ca: this.factory.ca }),
78
+ });
79
+ }
80
+ catch (error) {
81
+ const kind = httpFailureCode(error) ?? 'network';
82
+ record({ statusCode: null, errorKind: kind, excerpt: null });
83
+ throw new ChannelFailure(ERROR_TEXT[kind] ?? 'cannot reach the receiver', {
84
+ permanent: false,
85
+ });
86
+ }
87
+ const excerpt = Buffer.from(response.body).toString('utf8').slice(0, EXCERPT_CHARS);
88
+ const { status } = response;
89
+ if (status >= 200 && status < 300) {
90
+ record({ statusCode: status, errorKind: null, excerpt });
91
+ return { webhook_id: id, status };
92
+ }
93
+ record({ statusCode: status, errorKind: errorKindOf(status), excerpt });
94
+ if (status === 410) {
95
+ throw new ChannelFailure('the receiver answered 410 Gone', {
96
+ permanent: true,
97
+ disable: true,
98
+ });
99
+ }
100
+ throw new ChannelFailure(`the receiver answered ${status}`, {
101
+ permanent: false,
102
+ ...(status === 429
103
+ ? { retryAfterMs: retryAfterMs(response.headers['retry-after'], now()) }
104
+ : {}),
105
+ });
106
+ }
107
+ }
108
+ function errorKindOf(status) {
109
+ if (status === 410)
110
+ return 'gone';
111
+ if (status === 429)
112
+ return 'rate_limited';
113
+ if (status >= 300 && status < 400)
114
+ return 'redirect';
115
+ if (status >= 400 && status < 500)
116
+ return 'client_error';
117
+ return 'server_error';
118
+ }
119
+ /** The channel kind `webhook`: it only sends, with the retries of a webhook. */
120
+ export function webhookChannelFactory(options) {
121
+ return {
122
+ kind: WEBHOOK_KIND,
123
+ language: () => 'en',
124
+ allows: () => false,
125
+ missingForSubscription: (params) => params.url === undefined || params.url === '' ? 'url' : null,
126
+ retry: WEBHOOK_RETRY,
127
+ editsMessages: false,
128
+ create: (channel) => new WebhookChannel(channel, options),
129
+ };
130
+ }
131
+ //# sourceMappingURL=channel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel.js","sourceRoot":"","sources":["../../../../../src/feature/notifications/clients/webhook/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAOlF,OAAO,EACL,cAAc,EACd,MAAM,EACN,aAAa,GAGd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,iEAAiE;AACjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AACzC,sCAAsC;AACtC,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,CAAC;AACxC,MAAM,aAAa,GAAG,IAAI,CAAC;AAY3B,4FAA4F;AAC5F,MAAM,UAAU,YAAY,CAAC,KAAoC,EAAE,GAAW;IA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