@wildo-ai/saas-backend-lib 1.1.12 → 1.1.13

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 (226) hide show
  1. package/dist/esm/base-classes/models/manual-controllers.backend.definition.d.ts.map +1 -1
  2. package/dist/esm/base-classes/models/manual-controllers.backend.definition.js +2 -0
  3. package/dist/esm/base-classes/models/manual-controllers.backend.definition.js.map +1 -1
  4. package/dist/esm/base-classes/services/repositories/stored-field-omission.backend.d.ts +4 -0
  5. package/dist/esm/base-classes/services/repositories/stored-field-omission.backend.d.ts.map +1 -1
  6. package/dist/esm/base-classes/services/repositories/stored-field-omission.backend.js +20 -5
  7. package/dist/esm/base-classes/services/repositories/stored-field-omission.backend.js.map +1 -1
  8. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-registry.backend.service.d.ts +3 -0
  9. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-registry.backend.service.d.ts.map +1 -1
  10. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-registry.backend.service.js +10 -1
  11. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-registry.backend.service.js.map +1 -1
  12. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation.factory.backend.d.ts +22 -0
  13. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation.factory.backend.d.ts.map +1 -1
  14. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation.factory.backend.js +25 -1
  15. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation.factory.backend.js.map +1 -1
  16. package/dist/esm/base-classes/services/services/resource-operation-transaction-persistence.backend.utils.d.ts +38 -3
  17. package/dist/esm/base-classes/services/services/resource-operation-transaction-persistence.backend.utils.d.ts.map +1 -1
  18. package/dist/esm/base-classes/services/services/resource-operation-transaction-persistence.backend.utils.js +68 -5
  19. package/dist/esm/base-classes/services/services/resource-operation-transaction-persistence.backend.utils.js.map +1 -1
  20. package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.d.ts +2 -2
  21. package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.d.ts.map +1 -1
  22. package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.js +6 -3
  23. package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.js.map +1 -1
  24. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.d.ts +83 -0
  25. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.d.ts.map +1 -1
  26. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.js +217 -14
  27. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.js.map +1 -1
  28. package/dist/esm/compliance/approval-seals/approval-seal-currency.backend.d.ts +32 -0
  29. package/dist/esm/compliance/approval-seals/approval-seal-currency.backend.d.ts.map +1 -0
  30. package/dist/esm/compliance/approval-seals/approval-seal-currency.backend.js +36 -0
  31. package/dist/esm/compliance/approval-seals/approval-seal-currency.backend.js.map +1 -0
  32. package/dist/esm/compliance/approval-seals/approval-seal-on-record.backend.d.ts +38 -0
  33. package/dist/esm/compliance/approval-seals/approval-seal-on-record.backend.d.ts.map +1 -0
  34. package/dist/esm/compliance/approval-seals/approval-seal-on-record.backend.js +83 -0
  35. package/dist/esm/compliance/approval-seals/approval-seal-on-record.backend.js.map +1 -0
  36. package/dist/esm/compliance/approval-seals/approval-seal-presentation-read.backend.d.ts +36 -0
  37. package/dist/esm/compliance/approval-seals/approval-seal-presentation-read.backend.d.ts.map +1 -0
  38. package/dist/esm/compliance/approval-seals/approval-seal-presentation-read.backend.js +51 -0
  39. package/dist/esm/compliance/approval-seals/approval-seal-presentation-read.backend.js.map +1 -0
  40. package/dist/esm/compliance/approval-seals/approval-seal-relay-store.backend.d.ts +46 -0
  41. package/dist/esm/compliance/approval-seals/approval-seal-relay-store.backend.d.ts.map +1 -1
  42. package/dist/esm/compliance/approval-seals/approval-seal-relay-store.backend.js +68 -0
  43. package/dist/esm/compliance/approval-seals/approval-seal-relay-store.backend.js.map +1 -1
  44. package/dist/esm/compliance/approval-seals/approval-seal-store.backend.d.ts +27 -0
  45. package/dist/esm/compliance/approval-seals/approval-seal-store.backend.d.ts.map +1 -1
  46. package/dist/esm/compliance/approval-seals/approval-seal-store.backend.js +42 -3
  47. package/dist/esm/compliance/approval-seals/approval-seal-store.backend.js.map +1 -1
  48. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.contracts.d.ts +26 -1
  49. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.contracts.d.ts.map +1 -1
  50. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.contracts.js +10 -0
  51. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.contracts.js.map +1 -1
  52. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.controller.d.ts +10 -1
  53. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.controller.d.ts.map +1 -1
  54. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.controller.js +60 -28
  55. package/dist/esm/compliance/approval-seals/approval-seals-admin.backend.controller.js.map +1 -1
  56. package/dist/esm/compliance/approval-seals/approval-seals-on-record.backend.controller.d.ts +90 -0
  57. package/dist/esm/compliance/approval-seals/approval-seals-on-record.backend.controller.d.ts.map +1 -0
  58. package/dist/esm/compliance/approval-seals/approval-seals-on-record.backend.controller.js +373 -0
  59. package/dist/esm/compliance/approval-seals/approval-seals-on-record.backend.controller.js.map +1 -0
  60. package/dist/esm/compliance/approval-seals/decision-presentation.backend.d.ts +29 -2
  61. package/dist/esm/compliance/approval-seals/decision-presentation.backend.d.ts.map +1 -1
  62. package/dist/esm/compliance/approval-seals/decision-presentation.backend.js +40 -3
  63. package/dist/esm/compliance/approval-seals/decision-presentation.backend.js.map +1 -1
  64. package/dist/esm/compliance/electronic-signatures/pdf-signature-structure.backend.d.ts.map +1 -1
  65. package/dist/esm/compliance/electronic-signatures/pdf-signature-structure.backend.js +34 -6
  66. package/dist/esm/compliance/electronic-signatures/pdf-signature-structure.backend.js.map +1 -1
  67. package/dist/esm/compliance/electronic-signatures/signature-request-evidence-files.backend.d.ts +30 -6
  68. package/dist/esm/compliance/electronic-signatures/signature-request-evidence-files.backend.d.ts.map +1 -1
  69. package/dist/esm/compliance/electronic-signatures/signature-request-evidence-files.backend.js +67 -22
  70. package/dist/esm/compliance/electronic-signatures/signature-request-evidence-files.backend.js.map +1 -1
  71. package/dist/esm/compliance/electronic-signatures/signature-request-poll.batch.backend.service.d.ts.map +1 -1
  72. package/dist/esm/compliance/electronic-signatures/signature-request-poll.batch.backend.service.js +18 -1
  73. package/dist/esm/compliance/electronic-signatures/signature-request-poll.batch.backend.service.js.map +1 -1
  74. package/dist/esm/compliance/electronic-signatures/signature-requests.backend.service.d.ts +66 -1
  75. package/dist/esm/compliance/electronic-signatures/signature-requests.backend.service.d.ts.map +1 -1
  76. package/dist/esm/compliance/electronic-signatures/signature-requests.backend.service.js +161 -14
  77. package/dist/esm/compliance/electronic-signatures/signature-requests.backend.service.js.map +1 -1
  78. package/dist/esm/compliance/electronic-signatures/signed-document-validation.backend.d.ts +47 -0
  79. package/dist/esm/compliance/electronic-signatures/signed-document-validation.backend.d.ts.map +1 -1
  80. package/dist/esm/compliance/electronic-signatures/signed-document-validation.backend.js.map +1 -1
  81. package/dist/esm/external-providers/services/content-safety.backend.service.d.ts +27 -2
  82. package/dist/esm/external-providers/services/content-safety.backend.service.d.ts.map +1 -1
  83. package/dist/esm/external-providers/services/content-safety.backend.service.js +46 -1
  84. package/dist/esm/external-providers/services/content-safety.backend.service.js.map +1 -1
  85. package/dist/esm/external-providers/services/embeddings.backend.service.d.ts.map +1 -1
  86. package/dist/esm/external-providers/services/embeddings.backend.service.js +2 -0
  87. package/dist/esm/external-providers/services/embeddings.backend.service.js.map +1 -1
  88. package/dist/esm/external-providers/services/external-providers-registry.backend.service.d.ts +11 -0
  89. package/dist/esm/external-providers/services/external-providers-registry.backend.service.d.ts.map +1 -1
  90. package/dist/esm/external-providers/services/external-providers-registry.backend.service.js +23 -0
  91. package/dist/esm/external-providers/services/external-providers-registry.backend.service.js.map +1 -1
  92. package/dist/esm/external-providers/services/provider-service-account-token.backend.d.ts +19 -1
  93. package/dist/esm/external-providers/services/provider-service-account-token.backend.d.ts.map +1 -1
  94. package/dist/esm/external-providers/services/provider-service-account-token.backend.js +41 -1
  95. package/dist/esm/external-providers/services/provider-service-account-token.backend.js.map +1 -1
  96. package/dist/esm/files/utils/file-parent-read-context.backend.d.ts +27 -2
  97. package/dist/esm/files/utils/file-parent-read-context.backend.d.ts.map +1 -1
  98. package/dist/esm/files/utils/file-parent-read-context.backend.js +23 -4
  99. package/dist/esm/files/utils/file-parent-read-context.backend.js.map +1 -1
  100. package/dist/esm/flows-actors/content-guardrails/classifier-availability.backend.utils.d.ts +26 -0
  101. package/dist/esm/flows-actors/content-guardrails/classifier-availability.backend.utils.d.ts.map +1 -1
  102. package/dist/esm/flows-actors/content-guardrails/classifier-availability.backend.utils.js +100 -8
  103. package/dist/esm/flows-actors/content-guardrails/classifier-availability.backend.utils.js.map +1 -1
  104. package/dist/esm/flows-actors/content-guardrails/record-owner-policy.backend.d.ts +3 -1
  105. package/dist/esm/flows-actors/content-guardrails/record-owner-policy.backend.d.ts.map +1 -1
  106. package/dist/esm/flows-actors/content-guardrails/record-owner-policy.backend.js +8 -2
  107. package/dist/esm/flows-actors/content-guardrails/record-owner-policy.backend.js.map +1 -1
  108. package/dist/esm/flows-actors/models/function-tools.backend.definitions.d.ts +43 -0
  109. package/dist/esm/flows-actors/models/function-tools.backend.definitions.d.ts.map +1 -1
  110. package/dist/esm/flows-actors/models/function-tools.backend.definitions.js +37 -0
  111. package/dist/esm/flows-actors/models/function-tools.backend.definitions.js.map +1 -1
  112. package/dist/esm/flows-actors/services/agent-work-decisions.backend.service.d.ts +7 -0
  113. package/dist/esm/flows-actors/services/agent-work-decisions.backend.service.d.ts.map +1 -1
  114. package/dist/esm/flows-actors/services/agent-work-decisions.backend.service.js +8 -3
  115. package/dist/esm/flows-actors/services/agent-work-decisions.backend.service.js.map +1 -1
  116. package/dist/esm/flows-actors/services/agents.backend.service.d.ts +31 -6
  117. package/dist/esm/flows-actors/services/agents.backend.service.d.ts.map +1 -1
  118. package/dist/esm/flows-actors/services/agents.backend.service.js +78 -30
  119. package/dist/esm/flows-actors/services/agents.backend.service.js.map +1 -1
  120. package/dist/esm/flows-actors/services/autonomous-agent-turn.backend.service.d.ts.map +1 -1
  121. package/dist/esm/flows-actors/services/autonomous-agent-turn.backend.service.js +4 -0
  122. package/dist/esm/flows-actors/services/autonomous-agent-turn.backend.service.js.map +1 -1
  123. package/dist/esm/flows-actors/services/conversational-execution.backend.service.d.ts +28 -2
  124. package/dist/esm/flows-actors/services/conversational-execution.backend.service.d.ts.map +1 -1
  125. package/dist/esm/flows-actors/services/conversational-execution.backend.service.js +132 -22
  126. package/dist/esm/flows-actors/services/conversational-execution.backend.service.js.map +1 -1
  127. package/dist/esm/flows-actors/services/flow-actor-executions.custom-impl.backend.service.d.ts.map +1 -1
  128. package/dist/esm/flows-actors/services/flow-actor-executions.custom-impl.backend.service.js +12 -8
  129. package/dist/esm/flows-actors/services/flow-actor-executions.custom-impl.backend.service.js.map +1 -1
  130. package/dist/esm/flows-actors/services/flows-actors-registry.service.d.ts +5 -0
  131. package/dist/esm/flows-actors/services/flows-actors-registry.service.d.ts.map +1 -1
  132. package/dist/esm/flows-actors/services/flows-actors-registry.service.js +18 -2
  133. package/dist/esm/flows-actors/services/flows-actors-registry.service.js.map +1 -1
  134. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.d.ts +33 -0
  135. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.d.ts.map +1 -1
  136. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.js +58 -0
  137. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.js.map +1 -1
  138. package/dist/esm/inbound/services/inbound-delivery-dispatch.backend.service.d.ts +12 -1
  139. package/dist/esm/inbound/services/inbound-delivery-dispatch.backend.service.d.ts.map +1 -1
  140. package/dist/esm/inbound/services/inbound-delivery-dispatch.backend.service.js +23 -4
  141. package/dist/esm/inbound/services/inbound-delivery-dispatch.backend.service.js.map +1 -1
  142. package/dist/esm/inbound/services/inbound-delivery-receiver.backend.service.d.ts +12 -1
  143. package/dist/esm/inbound/services/inbound-delivery-receiver.backend.service.d.ts.map +1 -1
  144. package/dist/esm/inbound/services/inbound-delivery-receiver.backend.service.js +55 -17
  145. package/dist/esm/inbound/services/inbound-delivery-receiver.backend.service.js.map +1 -1
  146. package/dist/esm/inbound/services/inbound-delivery-store.backend.service.d.ts +22 -1
  147. package/dist/esm/inbound/services/inbound-delivery-store.backend.service.d.ts.map +1 -1
  148. package/dist/esm/inbound/services/inbound-delivery-store.backend.service.js +52 -9
  149. package/dist/esm/inbound/services/inbound-delivery-store.backend.service.js.map +1 -1
  150. package/dist/esm/inbound/services/inbound-delivery-stored-body.backend.service.d.ts +79 -0
  151. package/dist/esm/inbound/services/inbound-delivery-stored-body.backend.service.d.ts.map +1 -0
  152. package/dist/esm/inbound/services/inbound-delivery-stored-body.backend.service.js +211 -0
  153. package/dist/esm/inbound/services/inbound-delivery-stored-body.backend.service.js.map +1 -0
  154. package/dist/esm/inbound/services/inbound-delivery-subject-erasure-severance.backend.d.ts +2 -2
  155. package/dist/esm/inbound/services/inbound-delivery-subject-erasure-severance.backend.d.ts.map +1 -1
  156. package/dist/esm/inbound/services/inbound-delivery-subject-erasure-severance.backend.js +9 -1
  157. package/dist/esm/inbound/services/inbound-delivery-subject-erasure-severance.backend.js.map +1 -1
  158. package/dist/esm/index.d.ts +1 -0
  159. package/dist/esm/index.d.ts.map +1 -1
  160. package/dist/esm/index.js +1 -0
  161. package/dist/esm/index.js.map +1 -1
  162. package/dist/esm/inject/models/container.d.ts.map +1 -1
  163. package/dist/esm/inject/models/container.js +6 -0
  164. package/dist/esm/inject/models/container.js.map +1 -1
  165. package/dist/esm/inject/models/service-types.d.ts +5 -0
  166. package/dist/esm/inject/models/service-types.d.ts.map +1 -1
  167. package/dist/esm/inject/models/service-types.js +3 -0
  168. package/dist/esm/inject/models/service-types.js.map +1 -1
  169. package/dist/esm/monitoring/observability/models/observability.backend.schemas.d.ts +5 -0
  170. package/dist/esm/monitoring/observability/models/observability.backend.schemas.d.ts.map +1 -1
  171. package/dist/esm/monitoring/observability/models/observability.backend.schemas.js.map +1 -1
  172. package/dist/esm/monitoring/observability/services/metrics.service.d.ts +34 -1
  173. package/dist/esm/monitoring/observability/services/metrics.service.d.ts.map +1 -1
  174. package/dist/esm/monitoring/observability/services/metrics.service.js +49 -0
  175. package/dist/esm/monitoring/observability/services/metrics.service.js.map +1 -1
  176. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.d.ts +6 -1
  177. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.d.ts.map +1 -1
  178. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.js +15 -4
  179. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.js.map +1 -1
  180. package/dist/esm/notifications/webhooks/outbound/services/m2m-webhook-delivery-log.custom-impl.backend.service.d.ts.map +1 -1
  181. package/dist/esm/notifications/webhooks/outbound/services/m2m-webhook-delivery-log.custom-impl.backend.service.js +3 -1
  182. package/dist/esm/notifications/webhooks/outbound/services/m2m-webhook-delivery-log.custom-impl.backend.service.js.map +1 -1
  183. package/dist/esm/runtime/services/http-server.backend.service.d.ts +3 -1
  184. package/dist/esm/runtime/services/http-server.backend.service.d.ts.map +1 -1
  185. package/dist/esm/runtime/services/http-server.backend.service.js +11 -3
  186. package/dist/esm/runtime/services/http-server.backend.service.js.map +1 -1
  187. package/dist/esm/runtime/services/utils/inbound-endpoint-raw-body.backend.utils.d.ts +22 -0
  188. package/dist/esm/runtime/services/utils/inbound-endpoint-raw-body.backend.utils.d.ts.map +1 -1
  189. package/dist/esm/runtime/services/utils/inbound-endpoint-raw-body.backend.utils.js +54 -0
  190. package/dist/esm/runtime/services/utils/inbound-endpoint-raw-body.backend.utils.js.map +1 -1
  191. package/dist/esm/security/authentications/services/auth-methods/auth-password-reset.backend.service.d.ts +51 -0
  192. package/dist/esm/security/authentications/services/auth-methods/auth-password-reset.backend.service.d.ts.map +1 -1
  193. package/dist/esm/security/authentications/services/auth-methods/auth-password-reset.backend.service.js +87 -15
  194. package/dist/esm/security/authentications/services/auth-methods/auth-password-reset.backend.service.js.map +1 -1
  195. package/dist/esm/security/authentications/services/custom-impls/siem-delivery-dlq.custom-impl.backend.service.d.ts.map +1 -1
  196. package/dist/esm/security/authentications/services/custom-impls/siem-delivery-dlq.custom-impl.backend.service.js +5 -2
  197. package/dist/esm/security/authentications/services/custom-impls/siem-delivery-dlq.custom-impl.backend.service.js.map +1 -1
  198. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.d.ts.map +1 -1
  199. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.js +65 -24
  200. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.js.map +1 -1
  201. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.d.ts +64 -1
  202. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.d.ts.map +1 -1
  203. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.js +84 -2
  204. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.js.map +1 -1
  205. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.d.ts +14 -0
  206. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.d.ts.map +1 -1
  207. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.js +13 -5
  208. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.js.map +1 -1
  209. package/dist/esm/users/services/anonymous-consent.custom-impl.backend.service.d.ts.map +1 -1
  210. package/dist/esm/users/services/anonymous-consent.custom-impl.backend.service.js +6 -2
  211. package/dist/esm/users/services/anonymous-consent.custom-impl.backend.service.js.map +1 -1
  212. package/dist/esm/users/services/user-force-password-reset.custom-impl.backend.service.d.ts +7 -0
  213. package/dist/esm/users/services/user-force-password-reset.custom-impl.backend.service.d.ts.map +1 -1
  214. package/dist/esm/users/services/user-force-password-reset.custom-impl.backend.service.js +65 -20
  215. package/dist/esm/users/services/user-force-password-reset.custom-impl.backend.service.js.map +1 -1
  216. package/dist/esm/users/services/user-role-administration.custom-impl.backend.service.d.ts.map +1 -1
  217. package/dist/esm/users/services/user-role-administration.custom-impl.backend.service.js +11 -4
  218. package/dist/esm/users/services/user-role-administration.custom-impl.backend.service.js.map +1 -1
  219. package/dist/esm/users/services/user-self-custom-implementations.backend.d.ts.map +1 -1
  220. package/dist/esm/users/services/user-self-custom-implementations.backend.js +4 -2
  221. package/dist/esm/users/services/user-self-custom-implementations.backend.js.map +1 -1
  222. package/dist/esm/users/services/user-super-admin-floor.custom-impl.backend.service.d.ts.map +1 -1
  223. package/dist/esm/users/services/user-super-admin-floor.custom-impl.backend.service.js +16 -0
  224. package/dist/esm/users/services/user-super-admin-floor.custom-impl.backend.service.js.map +1 -1
  225. package/dist/tsconfig.build.tsbuildinfo +1 -1
  226. package/package.json +10 -10
@@ -12,6 +12,7 @@ import { type AnyInboundHandlerDefinition, type InboundRetryPolicy } from '../..
12
12
  import type { ChatMemberActionsBackendService } from '../../inbound/services/chat-member-actions.backend.service';
13
13
  import type { InboundHandlerRegistryBackendService } from './inbound-handler-registry.backend.service';
14
14
  import { type InboundDeliveryLocation, type InboundDeliveryRow, type InboundDeliveryStoreBackendService } from './inbound-delivery-store.backend.service';
15
+ import { type InboundDeliveryStoredBodyBackendService } from './inbound-delivery-stored-body.backend.service';
15
16
  import type { ProviderOperationExecutorBackendService } from '../../external-providers/operations/provider-operation-executor.backend.service';
16
17
  /** What one dispatch concluded. */
17
18
  export declare enum InboundDispatchOutcome {
@@ -120,6 +121,8 @@ export declare class InboundDeliveryDispatchBackendService {
120
121
  * `autonomousAgentTurns`: a process without it runs handlers the same and refuses a provider call.
121
122
  */
122
123
  private readonly providerOperations?;
124
+ /** #3395: reads a body stored outside its row. Bound in every backend; a row naming one with none bound is retried. */
125
+ private readonly storedBodies?;
123
126
  private readonly audit;
124
127
  clock: () => Date;
125
128
  constructor(logger: LoggerService, registry: InboundHandlerRegistryBackendService, store: InboundDeliveryStoreBackendService, executionContextCreator: Pick<ExecutionContextCreatorBackendService, 'createForInboundDelivery' | 'createForSubCall'>, servicesRegistry: Pick<ServicesRegistryHandlerBackendService, 'create' | 'read' | 'list' | 'update' | 'delete' | 'executeCustomOperation'>, authorizations: Pick<AuthorizationsBackendService, 'authorizeInController'>, queue?: Pick<QueueBackendService, 'enqueueCustomBatch'>, auditLogs?: AuditLogsBackendService,
@@ -143,10 +146,18 @@ export declare class InboundDeliveryDispatchBackendService {
143
146
  * What `ctx.providers` calls through (#2664). `@optional()` and appended last for the same reasons as
144
147
  * `autonomousAgentTurns`: a process without it runs handlers the same and refuses a provider call.
145
148
  */
146
- providerOperations?: Pick<ProviderOperationExecutorBackendService, 'forExecution'>);
149
+ providerOperations?: Pick<ProviderOperationExecutorBackendService, 'forExecution'>,
150
+ /** #3395: reads a body stored outside its row. Bound in every backend; a row naming one with none bound is retried. */
151
+ storedBodies?: Pick<InboundDeliveryStoredBodyBackendService, 'read'>);
147
152
  private get authorizationDeps();
148
153
  /** Run one delivery's handler, once, and settle the row. */
149
154
  dispatch(location: InboundDeliveryLocation): Promise<InboundDispatchOutcome>;
155
+ /**
156
+ * The bytes the delivery was received with (#3395): from the row, or, for a body too large for it, from the file the row
157
+ * names, checked against the SHA-256 and length the row recorded at receipt. A chat message is never stored outside its
158
+ * row (the receiver refuses one that large), which is why the chat readers below read `rawBody` directly.
159
+ */
160
+ private storedBodyOf;
150
161
  /** Settle a completed attempt PROCESSED, audit it, and wake the delivery waiting behind it. */
151
162
  private settleProcessed;
152
163
  /** Enqueue every due delivery (received, retry due, or lease expired). Returns how many were found. */
@@ -1 +1 @@
1
- {"version":3,"file":"inbound-delivery-dispatch.backend.service.d.ts","sourceRoot":"","sources":["../../../../src/inbound/services/inbound-delivery-dispatch.backend.service.ts"],"names":[],"mappings":"AAsCA,OAAO,EAWL,wBAAwB,EAGxB,4BAA4B,EAI5B,KAAK,yBAAyB,EAC9B,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,+EAA+E,CAAC;AAC3I,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAC;AAC5G,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,6FAA6F,CAAC;AACzJ,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oFAAoF,CAAC;AACvI,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gFAAgF,CAAC;AAC9H,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAE1F,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,gFAAgF,CAAC;AAGxI,OAAO,KAAK,EAAE,6CAA6C,EAAE,MAAM,sFAAsF,CAAC;AAO1J,OAAO,EASL,KAAK,2BAA2B,EAGhC,KAAK,kBAAkB,EACxB,MAAM,uEAAuE,CAAC;AAI/E,OAAO,KAAK,EAAmB,+BAA+B,EAAE,MAAM,yEAAyE,CAAC;AAChJ,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,4CAA4C,CAAC;AACvG,OAAO,EAAE,KAAK,uBAAuB,EAAE,KAAK,kBAAkB,EAAE,KAAK,kCAAkC,EAAE,MAAM,0CAA0C,CAAC;AAM1J,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,8FAA8F,CAAC;AAE5J,mCAAmC;AACnC,oBAAY,sBAAsB;IAChC,SAAS,cAAc;IACvB,eAAe,oBAAoB;IACnC,IAAI,SAAS;IACb,6FAA6F;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OAAO,CAAC,gBAAgB;IA0BxB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAazB;;;;;OAKG;YACW,6BAA6B;IAW3C;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAkBtB;;;;;;OAMG;YACW,mBAAmB;IAyDjC;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAUtB,wGAAwG;IACxG;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;CAqBvB"}
1
+ {"version":3,"file":"inbound-delivery-dispatch.backend.service.d.ts","sourceRoot":"","sources":["../../../../src/inbound/services/inbound-delivery-dispatch.backend.service.ts"],"names":[],"mappings":"AAsCA,OAAO,EAWL,wBAAwB,EAGxB,4BAA4B,EAI5B,KAAK,yBAAyB,EAC9B,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,+EAA+E,CAAC;AAC3I,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAC;AAC5G,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,6FAA6F,CAAC;AACzJ,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oFAAoF,CAAC;AACvI,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gFAAgF,CAAC;AAC9H,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAE1F,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,gFAAgF,CAAC;AAGxI,OAAO,KAAK,EAAE,6CAA6C,EAAE,MAAM,sFAAsF,CAAC;AAO1J,OAAO,EASL,KAAK,2BAA2B,EAGhC,KAAK,kBAAkB,EACxB,MAAM,uEAAuE,CAAC;AAI/E,OAAO,KAAK,EAAmB,+BAA+B,EAAE,MAAM,yEAAyE,CAAC;AAChJ,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,4CA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E,IAAI,CAAC,uCAAuC,EAAE,MAAM,CAAC;IAKhK,OAAO,KAAK,iBAAiB,GAE5B;IAED,4DAA4D;IACtD,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAuGlF;;;;OAIG;YACW,YAAY;IAM1B,+FAA+F;YACjF,eAAe;IAW7B,uGAAuG;IACjG,KAAK,CAAC,KAAK,SAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAW3B,aAAa;IAQ3B;;;;OAIG;YACW,MAAM;IAepB,iHAAiH;YACnG,aAAa;IAM3B;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAwBnB;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;IA+DjB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAazB;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IA0BxB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAazB;;;;;OAKG;YACW,6BAA6B;IAW3C;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAkBtB;;;;;;OAMG;YACW,mBAAmB;IAyDjC;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAUtB,wGAAwG;IACxG;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;CAqBvB"}
@@ -55,6 +55,7 @@ import { projectCaughtErrorLogFields } from '../../errors/utils/error-log-level-
55
55
  import { engineInboundHandlerCapabilityOf, inboundScopeStandingPolicyOf, } from '../../inbound/models/inbound-engine-handler.backend.js';
56
56
  import { actingRolesForScope, ChatConverseOutcomeKind, ChatLinkPageUnavailableError, DEFAULT_INBOUND_RETRY_POLICY, InboundChatScopeError, InboundNotYetUnwarrantedError, InboundChatUnavailableError, InboundHandlerOutcome, } from '../../inbound/models/inbound-handler.backend.definitions.js';
57
57
  import { readInboundChatCommand, readInboundChatMessage } from '../../notifications/webhooks/services/webhook-handler.backend.service.js';
58
+ import { InboundStoredBodyIntegrityError } from './inbound-delivery-stored-body.backend.service.js';
58
59
  import { InboundDeliveryAudit } from './inbound-delivery-audit.backend.js';
59
60
  import { decodeInboundBody, storedInboundContentType } from '../../inbound/models/inbound-body-decoding.backend.js';
60
61
  import { enqueueInboundDeliveryDispatch } from './inbound-delivery-dispatch-queue.backend.js';
@@ -165,7 +166,9 @@ export function isPermanentInboundHandlerError(error) {
165
166
  || error instanceof InboundNotYetUnwarrantedError
166
167
  // `ctx.providers` refusals no retry changes (#2664 review R-8): a connection this delivery may not spend, or no
167
168
  // executor bound. An unconnected account or a token endpoint that did not answer stays retryable.
168
- || error instanceof ProviderConnectionTargetRefusedError || error.name === 'InboundProviderOperationsUnavailable');
169
+ || error instanceof ProviderConnectionTargetRefusedError || error.name === 'InboundProviderOperationsUnavailable'
170
+ // A body stored outside its row that is gone or no longer the bytes received (#3395): no retry brings it back.
171
+ || error instanceof InboundStoredBodyIntegrityError);
169
172
  }
170
173
  /**
171
174
  * The error code a delivery settles DEAD with when its stored scope is not one a handler can run in (#1774).
@@ -215,9 +218,10 @@ let InboundDeliveryDispatchBackendService = class InboundDeliveryDispatchBackend
215
218
  pipelineKeyRequests;
216
219
  chatMemberActions;
217
220
  providerOperations;
221
+ storedBodies;
218
222
  audit;
219
223
  clock = () => new Date();
220
- constructor(logger, registry, store, executionContextCreator, servicesRegistry, authorizations, queue, auditLogs, autonomousAgentTurns, pipelineKeyRequests, chatMemberActions, providerOperations) {
224
+ constructor(logger, registry, store, executionContextCreator, servicesRegistry, authorizations, queue, auditLogs, autonomousAgentTurns, pipelineKeyRequests, chatMemberActions, providerOperations, storedBodies) {
221
225
  this.logger = logger;
222
226
  this.registry = registry;
223
227
  this.store = store;
@@ -229,6 +233,7 @@ let InboundDeliveryDispatchBackendService = class InboundDeliveryDispatchBackend
229
233
  this.pipelineKeyRequests = pipelineKeyRequests;
230
234
  this.chatMemberActions = chatMemberActions;
231
235
  this.providerOperations = providerOperations;
236
+ this.storedBodies = storedBodies;
232
237
  this.audit = new InboundDeliveryAudit(auditLogs);
233
238
  }
234
239
  get authorizationDeps() {
@@ -290,7 +295,7 @@ let InboundDeliveryDispatchBackendService = class InboundDeliveryDispatchBackend
290
295
  const context = await this.buildHandlerContext(leased, handler, chatDoor);
291
296
  // Decoded as it was received (#2659): the receiver checked THIS value against the payload schema, so the
292
297
  // handler runs on the same thing, a form's fields included.
293
- const decoded = decodeInboundBody(Buffer.from(leased.rawBody, 'base64'), storedInboundContentType(leased.headers));
298
+ const decoded = decodeInboundBody(await this.storedBodyOf(location, leased), storedInboundContentType(leased.headers));
294
299
  // Literal comparison: this package compiles without strictNullChecks, where `!decoded.ok` does not narrow.
295
300
  if (decoded.ok === false)
296
301
  throw Object.assign(new Error('The stored inbound body no longer decodes as the media type it was received as'), { name: 'InboundBodyUndecodable' });
@@ -338,6 +343,18 @@ let InboundDeliveryDispatchBackendService = class InboundDeliveryDispatchBackend
338
343
  const heldBy = engineInboundHandlerCapabilityOf(handler)?.bodyHeldOnceProcessedBy;
339
344
  return this.settleProcessed(location, leased, heldBy === undefined ? {} : { redactBody: { heldBy } });
340
345
  }
346
+ /**
347
+ * The bytes the delivery was received with (#3395): from the row, or, for a body too large for it, from the file the row
348
+ * names, checked against the SHA-256 and length the row recorded at receipt. A chat message is never stored outside its
349
+ * row (the receiver refuses one that large), which is why the chat readers below read `rawBody` directly.
350
+ */
351
+ async storedBodyOf(location, leased) {
352
+ if (!leased.storedBody)
353
+ return Buffer.from(leased.rawBody, 'base64');
354
+ if (!this.storedBodies)
355
+ throw Object.assign(new Error('An inbound delivery\'s body is stored outside its row, and no reader for it is bound'), { name: 'InboundStoredBodyReaderUnavailable' });
356
+ return this.storedBodies.read(location.resourceType, leased);
357
+ }
341
358
  /** Settle a completed attempt PROCESSED, audit it, and wake the delivery waiting behind it. */
342
359
  async settleProcessed(location, leased, options) {
343
360
  const processed = await this.store.markProcessed(location, leased, options);
@@ -722,7 +739,9 @@ InboundDeliveryDispatchBackendService = __decorate([
722
739
  __param(10, optional()),
723
740
  __param(11, inject(SAAS_SERVICE_TYPES.ProviderOperationExecutorService)),
724
741
  __param(11, optional()),
725
- __metadata("design:paramtypes", [Function, Function, Function, Object, Object, Object, Object, Function, Object, Object, Object, Object])
742
+ __param(12, inject(SAAS_SERVICE_TYPES.InboundDeliveryStoredBodyService)),
743
+ __param(12, optional()),
744
+ __metadata("design:paramtypes", [Function, Function, Function, Object, Object, Object, Object, Function, Object, Object, Object, Object, Object])
726
745
  ], InboundDeliveryDispatchBackendService);
727
746
  export { InboundDeliveryDispatchBackendService };
728
747
  //# sourceMappingURL=inbound-delivery-dispatch.backend.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inbound-delivery-dispatch.backend.service.js","sourceRoot":"","sources":["../../../../src/inbound/services/inbound-delivery-dispatch.backend.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,qBAAqB,EAErB,qBAAqB,EACrB,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EAEpB,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,EACjB,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,GAGpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAAE,kCAAkC,EAAE,MAAM,6EAA6E,CAAC;AAQjI,OAAO,EAAE,2BAA2B,EAAE,MAAM,8EAA8E,CAAC;AAK3H,OAAO,EACL,gCAAgC,EAChC,4BAA4B,GAG7B,MAAM,kEAAkE,CAAC;AAC1E,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,qBAAqB,EACrB,6BAA6B,EAC7B,2BAA2B,EAC3B,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AA,QAAQ,EAAE,CAAA;IAK7E,YAAA,MAAM,CAAC,kBAAkB,CAAC,wBAAwB,CAAC,CAAA;IAAE,YAAA,QAAQ,EAAE,CAAA;IAK/D,YAAA,MAAM,CAAC,kBAAkB,CAAC,gCAAgC,CAAC,CAAA;IAAE,YAAA,QAAQ,EAAE,CAAA;;GAlC/D,qCAAqC,CA2gBjD","sourcesContent":["/**\n * The inbound dispatch worker (#1596): runs ONE stored delivery's handler under the delivery's own\n * authority, and settles the row.\n *\n * ## The context is rebuilt from the ROW, never carried\n *\n * A custom-batch job carries no execution context across the queue, and that is the right shape here\n * rather than a limitation: the handler's authority is a function of two durable facts — the scope the\n * delivery resolved to (on the row) and the roles the handler declares (in code). Rebuilding from them\n * means a job payload cannot widen what a handler may do, and a replay weeks later runs with the roles\n * the handler declares TODAY.\n *\n * ## `ctx.resources` applies the controller's gate\n *\n * The service tier deliberately applies no operation role ACL — that gate lives at the controller,\n * where an untrusted principal names an operation (see the note above\n * `ServicesRegistryHandlerBackendService.create`). A handler is exactly such a principal, so each\n * call here builds a sub-context and runs `authorizeInController` on it before the service call:\n * roles, parent scope, unit narrowing, the per-row tenant check. Without that, `actingRoles` would be a\n * declaration that constrained nothing. The call must also resolve to an `API_CALL` variant: an\n * `INTERNAL_CALL` or repository-only variant is the engine's own door (the retention sweep's delete, for\n * one) and no HTTP caller reaches it, so neither may a handler.\n *\n * ## Delivery semantics: stored once, run at least once\n *\n * The store keeps one row per event. The handler may still run more than once for that row — a crash\n * after `handle()` returned but before the row settled, or a throw after some writes — so handlers must\n * be idempotent per `ctx.delivery.id`. The lease is renewed while a handler runs, so a slow handler is\n * not taken over by a second worker mid-run.\n *\n * ## Ordering waits do not reschedule themselves\n *\n * A delivery blocked by an earlier one on its ordering key is re-dated ({@link INBOUND_ORDERING_RECHECK_MS})\n * and left for the sweep; when the predecessor settles, the dispatcher wakes the next waiting delivery.\n * An earlier version re-enqueued the blocked row every ten seconds, and the sweep started another such\n * chain every minute, so a key blocked behind a failing delivery multiplied its own jobs without bound.\n */\nimport { inject, injectable, optional } from 'inversify';\nimport {\n ChatCommandOutcomeKind,\n inboundDeliveryCarriesChatInput,\n AutonomousTurnTrigger,\n type InboundChatCommandRunResult,\n CoreResourceOperation,\n CoreResourceType,\n ErrorType,\n ExecutionRefKind,\n InboundChatInputKind,\n InboundDeliveryUnroutableReason,\n InboundResolvedScopeKind,\n InboundRetryBackoffKind,\n InboundSourceKind,\n ResourceOperationVariantType,\n ResourcePrimaryScope,\n isWildoBackendError,\n jsonParsingSchemaOf,\n type ExecutionContext_RoleInfo,\n type ResourceType,\n} from '@wildo-ai/saas-models';\n\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\nimport { runWithRelationshipProvenanceFrame } from '~wildo-backend-lib/runtime/models/relationship-provenance-frame.als.backend';\nimport type { LoggerService } from '~wildo-backend-lib/monitoring/logger/services/logger.service';\nimport type { ExecutionContextCreatorBackendService } from '~wildo-backend-lib/runtime/services/execution-context-creator.backend.service';\nimport type { ExecutionContext } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\nimport type { ServicesRegistryHandlerBackendService } from '~wildo-backend-lib/base-classes/services/services/services-registry-handler.backend.service';\nimport type { AuthorizationsBackendService } from '~wildo-backend-lib/security/authorizations/services/authorizations.backend.service';\nimport type { AuditLogsBackendService } from '~wildo-backend-lib/compliance/audit-trails/services/audit-logs.backend.service';\nimport type { QueueBackendService } from '~wildo-backend-lib/queue/queue.backend.service';\nimport { projectCaughtErrorLogFields } from '~wildo-backend-lib/errors/utils/error-log-level-classification.backend.utils';\nimport type { AutonomousAgentTurnBackendService } from '~wildo-backend-lib/flows-actors/services/autonomous-agent-turn.backend.service';\nimport type { InboundHandlerAgents } from '~wildo-backend-lib/inbound/models/inbound-handler-agents.backend.definitions';\nimport type { InboundHandlerPipelines } from '~wildo-backend-lib/inbound/models/inbound-handler-pipelines.backend.definitions';\nimport type { ExternalDataPipelineKeyRequestsBackendService } from '~wildo-backend-lib/external-data/external-data-pipeline-key-requests.backend.service';\nimport {\n engineInboundHandlerCapabilityOf,\n inboundScopeStandingPolicyOf,\n type EngineInboundHandlerContext,\n type InboundEngineOperationAccess,\n} from '~wildo-backend-lib/inbound/models/inbound-engine-handler.backend';\nimport {\n actingRolesForScope,\n ChatConverseOutcomeKind,\n ChatLinkPageUnavailableError,\n DEFAULT_INBOUND_RETRY_POLICY,\n InboundChatScopeError,\n InboundNotYetUnwarrantedError,\n InboundChatUnavailableError,\n InboundHandlerOutcome,\n type AnyInboundHandlerDefinition,\n type InboundHandlerChat,\n type InboundHandlerContext,\n type InboundRetryPolicy,\n} from '~wildo-backend-lib/inbound/models/inbound-handler.backend.definitions';\nimport { readInboundChatCommand, readInboundChatMessage } from '~wildo-backend-lib/notifications/webhooks/services/webhook-handler.backend.service';\nimport type { Hook_InboundChatCommand, Hook_InboundChatMessage } from '@wildo-ai/external-connectors-models';\nimport type { ChatCommandRunRecord } from '~wildo-backend-lib/inbound/chat-commands/chat-command-door.backend.service';\nimport type { ChatDeliveryPin, ChatMemberActionsBackendService } from '~wildo-backend-lib/inbound/services/chat-member-actions.backend.service';\nimport type { InboundHandlerRegistryBackendService } from './inbound-handler-registry.backend.service';\nimport { type InboundDeliveryLocation, type InboundDeliveryRow, type InboundDeliveryStoreBackendService } from './inbound-delivery-store.backend.service';\nimport { InboundDeliveryAudit } from './inbound-delivery-audit.backend';\nimport { decodeInboundBody, storedInboundContentType } from '~wildo-backend-lib/inbound/models/inbound-body-decoding.backend';\nimport { enqueueInboundDeliveryDispatch } from './inbound-delivery-dispatch-queue.backend';\nimport { runWithWorkAttributionFrame } from '~wildo-backend-lib/runtime/models/work-attribution.als.backend';\nimport { ProviderConnectionTargetRefusedError } from '~wildo-backend-lib/external-providers/services/provider-http-access.backend';\nimport type { ProviderOperationExecutorBackendService } from '~wildo-backend-lib/external-providers/operations/provider-operation-executor.backend.service';\n\n/** What one dispatch concluded. */\nexport enum InboundDispatchOutcome {\n PROCESSED = 'processed',\n RETRY_SCHEDULED = 'retry_scheduled',\n DEAD = 'dead',\n /** An earlier delivery with the same ordering key is still pending; nothing was consumed. */\n DEFERRED_FOR_ORDERING = 'deferred_for_ordering',\n /** The row is gone (erased with its organization, or never existed). */\n SKIPPED_MISSING = 'skipped_missing',\n /** Another worker holds or has settled the row, or it is not due. */\n SKIPPED_NOT_DUE = 'skipped_not_due',\n /** The handler answered `NOT_YET` (a chat conversation still runs a turn): released, no attempt spent (#2665 S6). */\n NOT_YET = 'not_yet',\n}\n\n/**\n * How far a delivery blocked by its ordering predecessor is re-dated. The sweep's cadence: the blocked\n * row is looked at again by the next sweep, or sooner when its predecessor settles and wakes it.\n */\nexport const INBOUND_ORDERING_RECHECK_MS = 60_000;\n\n/** The variants an application handler's `ctx.resources` may reach: what an HTTP caller reaches. */\nexport const APPLICATION_HANDLER_OPERATION_VARIANTS: ReadonlySet<ResourceOperationVariantType> = new Set([ResourceOperationVariantType.API_CALL]);\n\n/**\n * The variants an ENGINE handler's door may reach (#1629): also the engine's service-pipeline operations, which\n * register no route. Never REPOSITORY_ONLY — that is plumbing, and has no business-operation authorization.\n */\nexport const ENGINE_HANDLER_OPERATION_VARIANTS: ReadonlySet<ResourceOperationVariantType> = new Set([\n ResourceOperationVariantType.API_CALL,\n ResourceOperationVariantType.INTERNAL_CALL,\n]);\n\n/**\n * The role entry a delivery's principal carries: the handler's declared roles for the delivery's scope. A person's\n * own data gates on APPLICATION roles, so a user-scope delivery carries its roles as an application entry; the\n * ownership check and the scope filter confine them to that one person (#1629).\n */\nexport function inboundHandlerInitiatorRoles(\n actingRoles: AnyInboundHandlerDefinition['actingRoles'],\n scope: Exclude<InboundDeliveryRow['resolvedScope'], { kind: InboundResolvedScopeKind.UNROUTABLE }>,\n): ExecutionContext_RoleInfo[] {\n const roles = [...(actingRolesForScope(actingRoles, scope.kind) ?? [])];\n return scope.kind === InboundResolvedScopeKind.ORGANIZATION\n ? [{ roles, relatedPrimaryScope: ResourcePrimaryScope.ORGANIZATIONS, relatedResourceId: scope.organizationId }]\n : [{ roles, relatedPrimaryScope: ResourcePrimaryScope.APPLICATION }];\n}\n\n/** What {@link authorizeInboundSubCall} needs: the context creator and the authorizer. */\nexport interface InboundSubCallAuthorizationDeps {\n readonly executionContextCreator: Pick<ExecutionContextCreatorBackendService, 'createForSubCall'>;\n readonly authorizations: Pick<AuthorizationsBackendService, 'authorizeInController'>;\n}\n\n/**\n * One sub-context of a delivery's context, authorized as at the controller: the operation must resolve to one\n * of `admittedVariants`, then `authorizeInController` runs on it — roles, parent scope, unit narrowing, the\n * per-row tenant check. The ONE implementation behind `ctx.resources` and the engine door (#1629), exported so\n * the integration lanes authorize through it instead of re-implementing it.\n */\nexport async function authorizeInboundSubCall(\n deps: InboundSubCallAuthorizationDeps,\n executionContext: ExecutionContext<any>,\n resourceType: ResourceType,\n operation: string,\n id: string | undefined,\n admittedVariants: ReadonlySet<ResourceOperationVariantType>,\n): Promise<ExecutionContext<any>> {\n // sub-call-transaction: N/A — a delivery holds no transaction here; the operation this context authorizes opens its own (#3066).\n const sub = await deps.executionContextCreator.createForSubCall(executionContext, resourceType, operation, undefined, id);\n // assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — a handler reaches only what an HTTP caller can: the engine's internal and repository-only doors are refused (an engine handler additionally reaches INTERNAL_CALL, never repository-only).\n if (!sub.operation?.variantType || !admittedVariants.has(sub.operation.variantType)) {\n throw Object.assign(new Error(`'${String(resourceType)}.${operation}' is not an operation this inbound handler may call`), { name: 'InboundHandlerOperationNotAddressable' });\n }\n await deps.authorizations.authorizeInController(id, sub);\n return sub;\n}\n\n/** How often a running attempt renews its lease: a third of the lease, so two renewals may fail before it lapses. */\nexport const INBOUND_LEASE_RENEWAL_MS = 10 * 60 * 1000;\n\n/** The wait before the next attempt, per the handler's backoff. `attempt` is 1-based (the attempt that just failed). */\nexport function inboundRetryDelaySeconds(policy: InboundRetryPolicy, attempt: number): number {\n const { kind, baseSeconds, maxSeconds } = policy.backoff;\n switch (kind) {\n case InboundRetryBackoffKind.FIXED: return baseSeconds;\n case InboundRetryBackoffKind.EXPONENTIAL: {\n const grown = baseSeconds * 2 ** Math.max(0, attempt - 1);\n return maxSeconds !== undefined ? Math.min(grown, maxSeconds) : grown;\n }\n default: {\n const unhandled: never = kind;\n return unhandled;\n }\n }\n}\n\n/**\n * When the next attempt runs, or `null` when the budget is spent: the attempts since the budget\n * started reached `maxAttempts`, or the next attempt would fall past the window.\n */\nexport function nextInboundAttemptAt(policy: InboundRetryPolicy, row: Pick<InboundDeliveryRow, 'attemptCount' | 'budgetBaseAttemptCount' | 'budgetStartedAt'>, now: Date): Date | null {\n const attemptsInBudget = row.attemptCount - row.budgetBaseAttemptCount;\n if (attemptsInBudget >= policy.maxAttempts) return null;\n const next = new Date(now.getTime() + inboundRetryDelaySeconds(policy, attemptsInBudget) * 1000);\n const windowEnds = row.budgetStartedAt.getTime() + policy.maxWindowSeconds * 1000;\n return next.getTime() > windowEnds ? null : next;\n}\n\n/**\n * A failure no retry can cure: the handler is not authorized, its input does not validate, or the stored\n * body no longer parses. It goes straight to `DEAD`, where a replay after the fix runs it again, rather\n * than spending the retry budget on the same refusal. A `NOT_FOUND` stays retryable: a sender may\n * deliver an event before the record it names exists.\n */\nexport function isPermanentInboundHandlerError(error: unknown): boolean {\n if (isWildoBackendError(error)) {\n return error.type === ErrorType.AUTHORIZATION || error.type === ErrorType.AUTHENTICATION\n || error.type === ErrorType.VALIDATION || error.type === ErrorType.PAYLOAD_TOO_LARGE;\n }\n return error instanceof Error\n && (error.name === 'ZodError' || error.name === 'SyntaxError' || error.name === 'InboundHandlerOperationNotAddressable'\n // `ctx.chat` refusals no retry changes (#2664): a delivery with no chat member, an unbound door, no link page.\n || error instanceof InboundChatScopeError || error instanceof InboundChatUnavailableError || error instanceof ChatLinkPageUnavailableError\n // A NOT_YET the chat door did not give (#2665 S6 review M2): the handler's code is wrong, and no retry changes it.\n || error instanceof InboundNotYetUnwarrantedError\n // `ctx.providers` refusals no retry changes (#2664 review R-8): a connection this delivery may not spend, or no\n // executor bound. An unconnected account or a token endpoint that did not answer stays retryable.\n || error instanceof ProviderConnectionTargetRefusedError || error.name === 'InboundProviderOperationsUnavailable');\n}\n\n/**\n * The error code a delivery settles DEAD with when its stored scope is not one a handler can run in (#1774).\n *\n * A row reaches the dispatcher only after the receiver resolved it to ORGANIZATION or APPLICATION, so any\n * other shape means the stored row was damaged after it was accepted. It must never fall through to the\n * application's roles: that is how a replayed organization delivery ran with application authority.\n */\nexport const INBOUND_DELIVERY_SCOPE_MALFORMED = 'InboundDeliveryScopeMalformed';\n\n/**\n * Whether a stored row's scope is one the dispatcher may run, and agrees with the table it lives in: an\n * ORGANIZATION scope naming the row's own organization, in the organization variant; APPLICATION, or USER naming\n * a person, in the application variant. Anything else is refused, never defaulted.\n */\nexport function hasRunnableInboundScope(row: Pick<InboundDeliveryRow, 'resolvedScope' | 'organizationId'>, resourceType: string): boolean {\n const scope = row.resolvedScope as { kind?: unknown; organizationId?: unknown; userId?: unknown } | undefined;\n if (scope?.kind === InboundResolvedScopeKind.ORGANIZATION) {\n return resourceType === CoreResourceType.ORGANIZATION_INBOUND_DELIVERIES\n && typeof scope.organizationId === 'string' && scope.organizationId.length > 0\n && scope.organizationId === row.organizationId;\n }\n if (scope?.kind === InboundResolvedScopeKind.APPLICATION) return resourceType === CoreResourceType.APPLICATION_INBOUND_DELIVERIES;\n // A person's delivery lives in the application variant (#1629) and must name the person.\n if (scope?.kind === InboundResolvedScopeKind.USER) {\n return resourceType === CoreResourceType.APPLICATION_INBOUND_DELIVERIES && typeof scope.userId === 'string' && scope.userId.length > 0;\n }\n return false;\n}\n\n/** A classification of a handler failure — an error type and reference, never a message (which can quote the payload). */\nexport function classifyInboundHandlerError(error: unknown): string {\n if (isWildoBackendError(error)) return [error.type, error.customMessageReference].filter(Boolean).join(':');\n if (error instanceof Error) return error.name || 'Error';\n return 'unknown';\n}\n\n/** The relationship one delivery turned out to be the act of (#2722), filled by the chat door and read by `ctx.resources`. */\ninterface InboundDeliveryProvenance {\n relationshipId?: string;\n}\n\n/**\n * What the chat door did with one attempt's message (#2665 S6, plan V3), on state the DISPATCHER owns, set by\n * `ctx.chat.converse()`: the conversation whose transcript took it, and what the door answered last. Read when the attempt\n * ends, so the chat message's body is emptied with the right reason in the settle itself, and a wait is the door's\n * decision rather than the handler's (review M2).\n */\ninterface InboundChatDoorRecord {\n /** Where the delivery is stored: what the door empties once the conversation holds the message. */\n readonly location: InboundDeliveryLocation;\n heldByExecutionId?: string;\n /** The kind of the door's last answer in this attempt; absent when the door gave none (no converse, no message read, or a throw). */\n answered?: ChatConverseOutcomeKind;\n}\n\n@injectable()\nexport class InboundDeliveryDispatchBackendService {\n private readonly audit: InboundDeliveryAudit;\n\n clock: () => Date = () => new Date();\n\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) private readonly logger: LoggerService,\n @inject(SAAS_SERVICE_TYPES.InboundHandlerRegistryService) private readonly registry: InboundHandlerRegistryBackendService,\n @inject(SAAS_SERVICE_TYPES.InboundDeliveryStoreService) private readonly store: InboundDeliveryStoreBackendService,\n @inject(SAAS_SERVICE_TYPES.ExecutionContextCreatorBackendService) private readonly executionContextCreator: Pick<ExecutionContextCreatorBackendService, 'createForInboundDelivery' | 'createForSubCall'>,\n @inject(SAAS_SERVICE_TYPES.ServicesRegistryHandlerService) private readonly servicesRegistry: Pick<ServicesRegistryHandlerBackendService, 'create' | 'read' | 'list' | 'update' | 'delete' | 'executeCustomOperation'>,\n @inject(SAAS_SERVICE_TYPES.AuthorizationsService) private readonly authorizations: Pick<AuthorizationsBackendService, 'authorizeInController'>,\n @inject(SAAS_SERVICE_TYPES.QueueBackendService) @optional() private readonly queue?: Pick<QueueBackendService, 'enqueueCustomBatch'>,\n @inject(SAAS_SERVICE_TYPES.AuditLogsService) @optional() auditLogs?: AuditLogsBackendService,\n /**\n * The autonomous entry point `ctx.agents` hands a delivery to (#1611). `@optional()` and appended last:\n * a process without it runs handlers the same and refuses to start agents, and hand-built test doubles\n * construct this service positionally.\n */\n @inject(SAAS_SERVICE_TYPES.AutonomousAgentTurnService) @optional() private readonly autonomousAgentTurns?: Pick<AutonomousAgentTurnBackendService, 'startAutonomousAgentTurn'>,\n /**\n * The pipeline key-request door `ctx.pipelines` reaches (#1688). `@optional()` and appended last for the same reasons\n * as `autonomousAgentTurns`: a process without it runs handlers the same and refuses a key request.\n */\n @inject(SAAS_SERVICE_TYPES.ExternalDataPipelineKeyRequestsService) @optional() private readonly pipelineKeyRequests?: Pick<ExternalDataPipelineKeyRequestsBackendService, 'requestPipelineKeys'>,\n /**\n * What `ctx.chat` acts through (#2664). `@optional()` and appended last for the same reasons as\n * `autonomousAgentTurns`: a process without it runs handlers the same and refuses a chat act.\n */\n @inject(SAAS_SERVICE_TYPES.ChatMemberActionsService) @optional() private readonly chatMemberActions?: Pick<ChatMemberActionsBackendService, 'resolveActingMember' | 'answerDecision' | 'converse' | 'runCommand'>,\n /**\n * What `ctx.providers` calls through (#2664). `@optional()` and appended last for the same reasons as\n * `autonomousAgentTurns`: a process without it runs handlers the same and refuses a provider call.\n */\n @inject(SAAS_SERVICE_TYPES.ProviderOperationExecutorService) @optional() private readonly providerOperations?: Pick<ProviderOperationExecutorBackendService, 'forExecution'>,\n ) {\n this.audit = new InboundDeliveryAudit(auditLogs);\n }\n\n private get authorizationDeps(): InboundSubCallAuthorizationDeps {\n return { executionContextCreator: this.executionContextCreator, authorizations: this.authorizations };\n }\n\n /** Run one delivery's handler, once, and settle the row. */\n async dispatch(location: InboundDeliveryLocation): Promise<InboundDispatchOutcome> {\n const row = await this.store.read(location);\n if (!row) return InboundDispatchOutcome.SKIPPED_MISSING;\n\n // Asked BEFORE the lease, so a blocked delivery consumes no attempt. It is re-dated and NOT\n // re-enqueued: the sweep, or its predecessor settling, brings it back (see the header).\n if (await this.store.hasPendingPredecessor(location, row)) {\n await this.store.deferForOrdering(location, row, new Date(this.clock().getTime() + INBOUND_ORDERING_RECHECK_MS));\n return InboundDispatchOutcome.DEFERRED_FOR_ORDERING;\n }\n\n const leased = await this.store.lease(location, row);\n if (!leased) return InboundDispatchOutcome.SKIPPED_NOT_DUE;\n\n const handler = this.registry.getHandler(leased.handlerRef);\n // assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — a delivery runs only in the scope it was stored with; a damaged scope ends DEAD, never defaulted to the application's roles.\n if (!hasRunnableInboundScope(leased, String(location.resourceType))) {\n this.logger.error('Inbound delivery refused: its stored scope is not one a handler can run in', { inboundDeliveryId: location.id, handlerRef: leased.handlerRef });\n return this.settle(location, leased, INBOUND_DELIVERY_SCOPE_MALFORMED, null);\n }\n // assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — an organization or person that lost its authority after the delivery arrived does not act through its retries.\n // A failed read settles like any failed attempt (retried, audited, lease released) rather than leaving the\n // row PROCESSING until its lease expires with nothing recorded. An engine handler recording a third party's\n // facts runs whatever the standing (#1629), but never for a scope that no longer exists.\n let refusal: InboundDeliveryUnroutableReason | null;\n try {\n refusal = await this.store.scopeStandingRefusal(leased, inboundScopeStandingPolicyOf(handler));\n } catch (error) {\n return this.settleFailure(location, leased, handler, error);\n }\n if (refusal) return this.settle(location, leased, refusal, null);\n // #2665 S6 (plan B4): a delivery whose body was emptied has been answered: its conversation's transcript took the\n // message (this is the retry of an attempt that threw after the turn started), or it was answered and kept nowhere.\n // Nothing is left to run, and the empty body would not decode: settled PROCESSED without the handler.\n if (leased.bodyRedactedAt) return this.settleProcessed(location, leased, {});\n\n const renewal = setInterval(() => {\n void this.store.renewLease(location, leased).then((renewed) => {\n if (!renewed) this.logger.warn('Inbound handler still running, but its lease was lost', { inboundDeliveryId: location.id, handlerRef: leased.handlerRef });\n }, (error: unknown) => this.logger.warn('Inbound lease renewal failed', { inboundDeliveryId: location.id, ...projectCaughtErrorLogFields(error) }));\n }, INBOUND_LEASE_RENEWAL_MS);\n renewal.unref?.();\n let handlerOutcome: void | InboundHandlerOutcome;\n const chatDoor: InboundChatDoorRecord = { location };\n try {\n if (!handler) {\n // A deployment removed or renamed the handler. The row keeps its budget and retries: the next\n // deployment may bring it back, and DEAD is where an operator will look if it does not.\n throw Object.assign(new Error(`No inbound handler is declared for '${leased.handlerRef}'`), { name: 'InboundHandlerNotDeclared' });\n }\n const context = await this.buildHandlerContext(leased, handler, chatDoor);\n // Decoded as it was received (#2659): the receiver checked THIS value against the payload schema, so the\n // handler runs on the same thing, a form's fields included.\n const decoded = decodeInboundBody(Buffer.from(leased.rawBody, 'base64'), storedInboundContentType(leased.headers));\n // Literal comparison: this package compiles without strictNullChecks, where `!decoded.ok` does not narrow.\n if (decoded.ok === false) throw Object.assign(new Error('The stored inbound body no longer decodes as the media type it was received as'), { name: 'InboundBodyUndecodable' });\n // The receiver's schema (#3478): the stored body is JSON, read through the payload schema's JSON form.\n const payload = jsonParsingSchemaOf(handler.payloadSchema).parse(decoded.body);\n // #1598 (§4, S8): a model call the handler makes (an embedding, an extraction, an agent turn it starts) is\n // attributed to THIS delivery and to the organization the delivery was stored in — the row's own scope,\n // never the payload. A channel handler narrows it to the thread's case (`InboundChannelRuntimeBackendService`).\n handlerOutcome = await runWithWorkAttributionFrame({\n ...(leased.organizationId ? { organizationId: leased.organizationId } : {}),\n executionRef: { kind: ExecutionRefKind.INBOUND_DELIVERY, id: location.id },\n }, () => handler.handle(context, payload));\n } catch (error) {\n return this.settleFailure(location, leased, handler, error);\n } finally {\n clearInterval(renewal);\n }\n\n // #2665 S6 (plans B5, V5, review M2): the chat door said the message must wait. Released without spending the attempt,\n // without a failure audit, and without waking a successor: the delivery has not settled, so nothing behind it may\n // run. The DOOR's answer decides, whatever the handler returned: a handler that dropped it would otherwise settle the\n // message as answered and lose it, and a NOT_YET the door did not give would recycle the delivery with no bound.\n const doorSaidNotYet = chatDoor.answered === ChatConverseOutcomeKind.NOT_YET;\n if (handlerOutcome === InboundHandlerOutcome.NOT_YET && !doorSaidNotYet) {\n return this.settleFailure(location, leased, handler, new InboundNotYetUnwarrantedError(\n `Inbound handler '${leased.handlerRef}' answered NOT_YET, which only ctx.chat.converse() may decide; the delivery cannot wait without a bound`,\n ));\n }\n if (doorSaidNotYet) {\n if (handlerOutcome !== InboundHandlerOutcome.NOT_YET) {\n this.logger.warn('Inbound handler did not return the chat door\\'s NOT_YET; the delivery waits anyway', { inboundDeliveryId: location.id, handlerRef: leased.handlerRef });\n }\n const released = await this.store.releaseNotYet(location, leased, new Date(this.clock().getTime() + INBOUND_ORDERING_RECHECK_MS));\n if (!released) {\n this.logger.warn('Inbound delivery could not run yet, but its lease was lost before it could be released', { inboundDeliveryId: location.id, handlerRef: leased.handlerRef });\n return InboundDispatchOutcome.SKIPPED_NOT_DUE;\n }\n return InboundDispatchOutcome.NOT_YET;\n }\n\n // #2665 S6 (plan V3): a chat message has one copy once it settles: its conversation's transcript, or none.\n if (inboundDeliveryCarriesChatInput(leased)) {\n return this.settleProcessed(location, leased, { redactBody: chatDoor.heldByExecutionId ? { heldByExecutionId: chatDoor.heldByExecutionId } : {} });\n }\n // #3395, #3394: a body its engine handler keeps elsewhere (received-email rows, an SMS provider event row) has one\n // copy once it settles: that one.\n const heldBy = engineInboundHandlerCapabilityOf(handler)?.bodyHeldOnceProcessedBy;\n return this.settleProcessed(location, leased, heldBy === undefined ? {} : { redactBody: { heldBy } });\n }\n\n /** Settle a completed attempt PROCESSED, audit it, and wake the delivery waiting behind it. */\n private async settleProcessed(location: InboundDeliveryLocation, leased: InboundDeliveryRow, options: Parameters<InboundDeliveryStoreBackendService['markProcessed']>[2]): Promise<InboundDispatchOutcome> {\n const processed = await this.store.markProcessed(location, leased, options);\n if (!processed) {\n this.logger.warn('Inbound delivery processed, but its lease was lost before it could be settled', { inboundDeliveryId: location.id, handlerRef: leased.handlerRef });\n return InboundDispatchOutcome.SKIPPED_NOT_DUE;\n }\n await this.audit.processed(processed);\n await this.wakeSuccessor(location, processed);\n return InboundDispatchOutcome.PROCESSED;\n }\n\n /** Enqueue every due delivery (received, retry due, or lease expired). Returns how many were found. */\n async sweep(limit = 200): Promise<number> {\n const due = await this.store.findDue(limit);\n for (const { location } of due) {\n if (this.queue) await enqueueInboundDeliveryDispatch(this.queue, location, this.logger);\n else await this.dispatch(location);\n }\n return due.length;\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n\n private async settleFailure(location: InboundDeliveryLocation, leased: InboundDeliveryRow, handler: AnyInboundHandlerDefinition | undefined, error: unknown): Promise<InboundDispatchOutcome> {\n const errorCode = classifyInboundHandlerError(error);\n this.logger.warn('Inbound handler attempt failed', { inboundDeliveryId: location.id, handlerRef: leased.handlerRef, attempt: leased.attemptCount, errorCode, ...projectCaughtErrorLogFields(error) });\n const policy = handler ? this.registry.retryPolicyOf(handler) : DEFAULT_INBOUND_RETRY_POLICY;\n const retryAt = isPermanentInboundHandlerError(error) ? null : nextInboundAttemptAt(policy, leased, this.clock());\n return this.settle(location, leased, errorCode, retryAt);\n }\n\n /**\n * Settle a failed attempt: scheduled for `retryAt`, or `DEAD` without one. A chat COMMAND that dies is emptied as it\n * dies (#2666 S7 slice review F3): its text is the person's, it can no longer run once its staleness window passes, and\n * nothing else would ever empty it (`runCommand()` keeps nothing, so no PROCESSED settle will come).\n */\n private async settle(location: InboundDeliveryLocation, leased: InboundDeliveryRow, errorCode: string, retryAt: Date | null): Promise<InboundDispatchOutcome> {\n const settled = leased.chatInput === InboundChatInputKind.COMMAND\n ? await this.store.markFailed(location, leased, errorCode, retryAt, { redactBodyIfDead: {} })\n : await this.store.markFailed(location, leased, errorCode, retryAt);\n if (!settled) return InboundDispatchOutcome.SKIPPED_NOT_DUE;\n if (retryAt) {\n await this.audit.failed(settled, errorCode, retryAt);\n await enqueueInboundDeliveryDispatch(this.queue, location, this.logger, Math.max(0, retryAt.getTime() - this.clock().getTime()));\n return InboundDispatchOutcome.RETRY_SCHEDULED;\n }\n await this.audit.dead(settled, errorCode);\n await this.wakeSuccessor(location, settled);\n return InboundDispatchOutcome.DEAD;\n }\n\n /** A settled delivery releases the next one waiting on its ordering key, rather than leaving it to the sweep. */\n private async wakeSuccessor(location: InboundDeliveryLocation, settled: InboundDeliveryRow): Promise<void> {\n const next = await this.store.wakeOrderingSuccessor(location, settled);\n // Enqueued for when it is due: a re-read trigger's trailing delivery stays held to its window (#2909 review N1).\n if (next && this.queue) await enqueueInboundDeliveryDispatch(this.queue, next, this.logger, Math.max(0, next.dueAt.getTime() - this.clock().getTime()));\n }\n\n /**\n * `ctx.agents` (#1611): the delivery handed to a declared autonomous agent. The occurrence IS the delivery,\n * so a retry, a crash-and-rerun or an operator's replay starts nothing twice; the trigger marks the turn's\n * input as untrusted for its whole life. Only an organization-scoped delivery can start one.\n */\n private buildAgents(deliveryId: string, sourceKey: string, organizationId: string | undefined): InboundHandlerAgents {\n return {\n startAutonomousTurn: async (request) => {\n if (!organizationId) {\n throw Object.assign(new Error('An autonomous agent runs in an organization; this delivery resolved to none, so no agent can be started from it.'), { name: 'InboundAutonomousTurnScopeError' });\n }\n if (!this.autonomousAgentTurns) {\n throw Object.assign(new Error('No autonomous entry point is bound in this process, so no agent can be started from an inbound delivery.'), { name: 'InboundAutonomousTurnUnavailableError' });\n }\n return this.autonomousAgentTurns.startAutonomousAgentTurn({\n autonomousAgentRef: request.autonomousAgentRef,\n organizationId,\n occurrenceKey: deliveryId,\n trigger: AutonomousTurnTrigger.INBOUND_DELIVERY,\n // #2973: the delivery the turn came through, from the stored row (never from the handler's request), so every\n // call the turn makes is metered on the lane its endpoint dictates (`ConnectionRateBudgetBackendService.laneOf`).\n arrivedThrough: { inboundSourceKey: sourceKey, inboundDeliveryId: deliveryId },\n ...(request.input ? { input: request.input } : {}),\n ...(request.caseRef ? { caseRef: request.caseRef } : {}),\n });\n },\n };\n }\n\n /**\n * `ctx.chat` (#2664): what a chat delivery's handler does as the member who sent it. Pinned to the delivery: its\n * ORGANIZATION (the one the receiver routed it to from the vendor's own facts) and its provider, which is the chat\n * connection every account it names belongs to. A delivery from an application endpoint, from a provider endpoint\n * whose verified request names no chat member (`InboundHandlerRegistryBackendService.endpointNamesChatMember`), or one\n * that resolved to another scope, has no chat member to act as, and every call refuses.\n */\n private buildChat(row: InboundDeliveryRow, handler: AnyInboundHandlerDefinition, provenance: InboundDeliveryProvenance, chatDoor: InboundChatDoorRecord, executionContext: ExecutionContext<any>): InboundHandlerChat {\n const pin = (): ChatDeliveryPin => {\n const scope = row.resolvedScope;\n if (handler.source.kind !== InboundSourceKind.PROVIDER_ENDPOINT || scope.kind !== InboundResolvedScopeKind.ORGANIZATION) {\n throw new InboundChatScopeError('A chat member acts in the organization a provider\\'s delivery was routed to; this delivery has none, so nobody can act from it.');\n }\n // assurance-control: WILDO.IDENTITY.DELEGATED_AUTHORIZATION — only an endpoint whose verified request names a chat\n // person may act as that person's linked member. A webhook, an email (whose From is not verified by anything) or\n // any other provider endpoint names nobody the engine has checked, so its handler acts as no one (S5a review F1).\n if (!this.registry.endpointNamesChatMember(handler.source.providerRef, handler.source.endpointKey)) {\n throw new InboundChatScopeError(`The endpoint '${handler.source.providerRef}:${handler.source.endpointKey}' names no chat member its vendor verified, so nobody can act from its deliveries.`);\n }\n if (!this.chatMemberActions) {\n throw new InboundChatUnavailableError('No chat member door is bound in this process, so no chat delivery can act as a member.');\n }\n return { organizationId: scope.organizationId, connectionRef: handler.source.providerRef, sourceKey: row.sourceKey, deliveryId: String(row._id) };\n };\n /** The command's run record for this attempt, built on the first `runCommand()` and shared by every later one. */\n let commandRun: ChatCommandRunRecord | undefined;\n return {\n actingMember: async (account) => {\n const pinned = pin();\n const resolved = await this.chatMemberActions!.resolveActingMember(pinned, account);\n // #2722: the delivery is now this member's act. When they stand in the organization through one relationship,\n // what the handler creates from here on is that relationship's work (`buildResources`).\n if (resolved.throughRelationshipId) provenance.relationshipId = resolved.throughRelationshipId;\n return resolved.member;\n },\n answerDecision: async (input) => {\n const pinned = pin();\n return this.chatMemberActions!.answerDecision(pinned, input);\n },\n converse: async () => {\n const pinned = pin();\n const message = this.storedChatMessage(row, handler);\n if (!message) return { kind: ChatConverseOutcomeKind.NO_MESSAGE };\n const outcome = await this.chatMemberActions!.converse(pinned, message, row.budgetStartedAt);\n chatDoor.answered = outcome.kind;\n if (outcome.kind === ChatConverseOutcomeKind.STARTED || outcome.kind === ChatConverseOutcomeKind.ALREADY_RECEIVED) {\n await this.holdChatMessageInConversation(row, chatDoor, outcome.executionId);\n }\n return outcome;\n },\n runCommand: async () => {\n const pinned = pin();\n const command = this.storedChatCommand(row, handler);\n // A command endpoint's request whose command could not be read: marked COMMAND at receipt, so its body is still\n // emptied when it settles, and nothing runs.\n if (!command) return { kind: ChatCommandOutcomeKind.NO_COMMAND };\n // ONE run record for the attempt (5f re-review R4): built from the leased row once, so a second call of a WRITE sees\n // the first one's start and answers its outcome, instead of starting from the stale snapshot, losing the start and\n // retrying the attempt into a second answer. A READ records no start, so a second call runs it again, and its\n // outcome cannot replace the first one's (the door audits it as an unrecorded outcome).\n commandRun ??= this.commandRunRecord(chatDoor.location, row);\n return this.chatMemberActions!.runCommand(pinned, command, {\n receivedAt: row.receivedAt,\n run: commandRun,\n deliveryContext: executionContext,\n });\n },\n };\n }\n\n /**\n * The chat command a person sent, read again from the stored delivery through its endpoint's `chatCommandOf` (#2666 S7),\n * exactly as the receiver read it: on the bytes the engine verified, never from the handler.\n */\n private storedChatCommand(row: InboundDeliveryRow, handler: AnyInboundHandlerDefinition): Hook_InboundChatCommand | undefined {\n if (handler.source.kind !== InboundSourceKind.PROVIDER_ENDPOINT) return undefined;\n const endpoint = this.registry.chatCommandEndpoint(handler.source.providerRef, handler.source.endpointKey);\n if (!endpoint || !row.rawBody) return undefined;\n const rawBody = Buffer.from(row.rawBody, 'base64');\n const contentType = storedInboundContentType(row.headers);\n const decoded = decodeInboundBody(rawBody, contentType);\n if (decoded.ok === false) return undefined;\n return readInboundChatCommand(endpoint, { rawBody, headers: row.headers ?? {}, contentType, body: decoded.body }, (error) => this.logger.error(\n 'An inbound chat endpoint could not read the command from a stored delivery', { inboundDeliveryId: String(row._id), handlerRef: handler.ref, ...projectCaughtErrorLogFields(error) },\n ));\n }\n\n /**\n * The command's run record over the leased row (#2666 S7, design N1). Stateful for the attempt: a second\n * `runCommand()` of a write in the same attempt sees the start and the outcome the first one recorded, and answers them\n * instead of losing a compare-and-swap. A read records no start, so a second call runs it again. Every write is fenced\n * on the lease.\n */\n private commandRunRecord(location: InboundDeliveryLocation, leased: InboundDeliveryRow): ChatCommandRunRecord {\n const now = () => this.clock();\n let startedAt: Date | null = leased.commandRunStartedAt ?? null;\n let result: InboundChatCommandRunResult | null = leased.commandRunResult ?? null;\n let auditedAt: Date | null = leased.commandRunAuditedAt ?? null;\n return {\n get startedAt() { return startedAt; },\n get result() { return result; },\n get auditedAt() { return auditedAt; },\n start: async () => {\n const started = await this.store.startCommandRun(location, leased);\n if (started) startedAt = started.commandRunStartedAt ?? now();\n return started !== null;\n },\n recordResult: async (outcome) => {\n const recorded = await this.store.recordCommandRunResult(location, leased, outcome);\n if (recorded) result = outcome;\n return recorded !== null;\n },\n markAudited: async () => {\n const marked = await this.store.markCommandRunAudited(location, leased);\n if (marked) auditedAt = marked.commandRunAuditedAt ?? now();\n },\n };\n }\n\n /**\n * The message a person wrote, read again from the stored delivery through its endpoint's `chatMessageOf` (#2665 S6): the\n * same function the receiver read it with, on the bytes the engine verified, so nothing about it was copied at receipt\n * and nothing about it comes from the handler.\n */\n private storedChatMessage(row: InboundDeliveryRow, handler: AnyInboundHandlerDefinition): Hook_InboundChatMessage | undefined {\n if (handler.source.kind !== InboundSourceKind.PROVIDER_ENDPOINT) return undefined;\n const endpoint = this.registry.chatMessageEndpoint(handler.source.providerRef, handler.source.endpointKey);\n if (!endpoint || !row.rawBody) return undefined;\n const rawBody = Buffer.from(row.rawBody, 'base64');\n const contentType = storedInboundContentType(row.headers);\n const decoded = decodeInboundBody(rawBody, contentType);\n if (decoded.ok === false) return undefined;\n return readInboundChatMessage(endpoint, { rawBody, headers: row.headers ?? {}, contentType, body: decoded.body }, (error) => this.logger.error(\n 'An inbound chat endpoint could not read the message from a stored delivery', { inboundDeliveryId: String(row._id), handlerRef: handler.ref, ...projectCaughtErrorLogFields(error) },\n ));\n }\n\n /**\n * The conversation's transcript holds the message now (#2665 S6, plans B4, V3): empty the delivery's copy at once, so a\n * handler that throws after this leaves none for its retry. Recorded on the dispatcher's own state first, so the\n * PROCESSED settle names the conversation even when this write misses (a lease lost, a store that failed); the retry\n * that follows a throw finds the message held and settles.\n */\n private async holdChatMessageInConversation(row: InboundDeliveryRow, chatDoor: InboundChatDoorRecord, executionId: string): Promise<void> {\n chatDoor.heldByExecutionId = executionId;\n try {\n await this.store.redactBody(chatDoor.location, row, { heldByExecutionId: executionId });\n } catch (error) {\n this.logger.warn('A chat delivery\\'s body could not be emptied once its conversation took the message; its settle empties it', {\n inboundDeliveryId: String(row._id), executionId, ...projectCaughtErrorLogFields(error),\n });\n }\n }\n\n /**\n * `ctx.pipelines` (#1688): the one way a handler affects a data pipeline — it names records, and the pipeline re-reads\n * them from the system of record under its own lease. The handler's authority here is its `pipelineKeyRequests`\n * declaration, checked at startup against each pipeline and here against the call; its roles do not apply, because it\n * writes nothing: the keyed run loads what the SOURCE serves, exactly as a scheduled pass would. Any delivery scope may\n * ask, for the same reason — a re-read only makes the pipeline's copy current sooner.\n */\n private buildPipelines(deliveryId: string, handler: AnyInboundHandlerDefinition): InboundHandlerPipelines {\n const declared = new Set<string>(handler.pipelineKeyRequests ?? []);\n return {\n requestPipelineKeys: async (resourceType, remoteKeys) => {\n // assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — a handler reaches only the pipelines it declared.\n if (!declared.has(resourceType)) {\n throw Object.assign(new Error(`Inbound handler '${handler.ref}' did not declare '${resourceType}' in pipelineKeyRequests, so it cannot ask that pipeline to re-read records.`),\n { name: 'InboundPipelineKeyRequestUndeclared' });\n }\n if (!this.pipelineKeyRequests) {\n throw Object.assign(new Error('No pipeline key-request door is bound in this process, so no pipeline can be asked to re-read records from an inbound delivery.'),\n { name: 'InboundPipelineKeyRequestUnavailable' });\n }\n return this.pipelineKeyRequests.requestPipelineKeys({ resourceType, remoteKeys, inboundDeliveryId: deliveryId });\n },\n };\n }\n\n /**\n * The handler's whole world: its authority is the declared roles in the delivery's ONE scope, reached\n * through `resources`. The handler has no actor call of its own (I10), and an agent turn never runs with its roles: it\n * goes through `agents`, the autonomous entry point (#1611), under the principal the organization granted that agent\n * and with a reviewer for a proposed side effect; or, for a message a member wrote to the bot, through\n * `chat.converse()`, as that member (#2665).\n */\n private async buildHandlerContext(row: InboundDeliveryRow, handler: AnyInboundHandlerDefinition, chatDoor: InboundChatDoorRecord): Promise<InboundHandlerContext> {\n const scope = row.resolvedScope;\n if (scope.kind === InboundResolvedScopeKind.UNROUTABLE) {\n throw Object.assign(new Error('An unroutable delivery has no scope to run in'), { name: 'InboundDeliveryUnroutable' });\n }\n const initiatorRoles = inboundHandlerInitiatorRoles(handler.actingRoles, scope);\n // The relationship the delivery turns out to be the act of (#2722): set by the chat door once it names the member.\n const provenance: InboundDeliveryProvenance = {};\n\n // assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — the handler acts with the roles it declares, in the one scope its delivery resolved to.\n const executionContext = await this.executionContextCreator.createForInboundDelivery({\n inboundDeliveryId: String(row._id),\n inboundHandlerRef: row.handlerRef,\n // Every act of the handler names the delivery it came through (#2665): `arrivedThrough` on each audit row.\n inboundSourceKey: row.sourceKey,\n ...(scope.kind === InboundResolvedScopeKind.ORGANIZATION\n ? { organizationId: scope.organizationId, contextResourcesFieldIdentifier: new Map([['organizationId', scope.organizationId]]) }\n : {}),\n ...(scope.kind === InboundResolvedScopeKind.USER\n ? { scopeUserId: scope.userId, contextResourcesFieldIdentifier: new Map([['userId', scope.userId]]) }\n : {}),\n // assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — the sender is recorded for identification; the roles above are the whole authority, whatever the assurance (#1630, I8).\n inboundSender: { channel: row.channel, assurance: row.senderAssurance },\n initiatorRoles,\n });\n\n const context: InboundHandlerContext = {\n delivery: {\n id: String(row._id),\n handlerRef: handler.ref,\n sourceKey: row.sourceKey,\n receivedAt: row.receivedAt,\n ...(row.providerDeliveryId !== undefined ? { providerDeliveryId: row.providerDeliveryId } : {}),\n // Within the current retry budget, so the first attempt after a replay is 1 again.\n attempt: row.attemptCount - row.budgetBaseAttemptCount,\n scope: scope.kind === InboundResolvedScopeKind.ORGANIZATION\n ? { kind: InboundResolvedScopeKind.ORGANIZATION, organizationId: scope.organizationId }\n : scope.kind === InboundResolvedScopeKind.USER\n ? { kind: InboundResolvedScopeKind.USER, userId: scope.userId }\n : { kind: InboundResolvedScopeKind.APPLICATION },\n },\n resources: this.buildResources(executionContext, provenance, scope.kind === InboundResolvedScopeKind.ORGANIZATION ? scope.organizationId : undefined),\n agents: this.buildAgents(String(row._id), row.sourceKey, scope.kind === InboundResolvedScopeKind.ORGANIZATION ? scope.organizationId : undefined),\n pipelines: this.buildPipelines(String(row._id), handler),\n chat: this.buildChat(row, handler, provenance, chatDoor, executionContext),\n providers: this.buildProviders(executionContext),\n };\n if (!engineInboundHandlerCapabilityOf(handler)) return context;\n // The engine door (#1629): the same authorization as `resources`, admitting INTERNAL_CALL too. Only a handler\n // carrying the engine capability — which application code cannot declare — receives it.\n const engine: InboundEngineOperationAccess = {\n authorize: (resourceType, operation, id) => authorizeInboundSubCall(this.authorizationDeps, executionContext, resourceType, operation, id, ENGINE_HANDLER_OPERATION_VARIANTS),\n };\n const engineContext: EngineInboundHandlerContext = { ...context, engine };\n return engineContext;\n }\n\n /**\n * `ctx.providers` (#2664): the executor bound to the delivery's own context, so the connection target is authorized\n * by the same rule as an HTTP caller's (`ConnectionTargetAuthorizationPort`). That context's only organization entry\n * is the delivery's organization, organization-wide, and it carries no authenticated user, so it may spend the\n * application's connection, that organization's, and no person's (see `InboundHandlerContext.providers`).\n */\n private buildProviders(executionContext: ExecutionContext<any>): InboundHandlerContext['providers'] {\n return async (providerRef, operationId, input, connection) => {\n if (!this.providerOperations) {\n throw Object.assign(new Error('No provider operation executor is bound in this process, so no provider operation can be called from an inbound delivery.'),\n { name: 'InboundProviderOperationsUnavailable' });\n }\n return this.providerOperations.forExecution(executionContext)(providerRef, operationId, input, connection);\n };\n }\n\n /** Every call is a sub-context of the delivery's context, authorized as at the controller, then run. */\n /**\n * `ctx.resources`: the handler's declared roles, in the delivery's one scope. Its writes run inside the relationship the\n * delivery turned out to be the act of, when it is one (#2722): a representative's linked chat account. The handler acts\n * on the framework's own delegated context, which takes a new record's provenance from that frame\n * (`takesRelationshipProvenanceFromFrame`); with none set, the frame the handler already runs in is left as it is (a\n * channel thread's, `InboundChannelRuntimeBackendService.run`).\n */\n private buildResources(executionContext: ExecutionContext<any>, provenance: InboundDeliveryProvenance, organizationId: string | undefined): InboundHandlerContext['resources'] {\n const authorized = (resourceType: ResourceType, operation: string, id?: string) =>\n authorizeInboundSubCall(this.authorizationDeps, executionContext, resourceType, operation, id, APPLICATION_HANDLER_OPERATION_VARIANTS);\n const inRelationship = <T>(fn: () => Promise<T>): Promise<T> => (provenance.relationshipId && organizationId\n ? runWithRelationshipProvenanceFrame({ organizationId, relationshipId: provenance.relationshipId }, fn)\n : fn());\n return {\n create: async <T>(resourceType: ResourceType, data: unknown) =>\n inRelationship(async () => this.servicesRegistry.create<T>(resourceType, await authorized(resourceType, CoreResourceOperation.CREATE), data)),\n read: async <T>(resourceType: ResourceType, id: string) =>\n this.servicesRegistry.read<T>(resourceType, await authorized(resourceType, CoreResourceOperation.READ, id), id),\n list: async <T>(resourceType: ResourceType, filter?: Record<string, unknown>, pagination?: Parameters<ServicesRegistryHandlerBackendService['list']>[3]) =>\n this.servicesRegistry.list<T>(resourceType, await authorized(resourceType, CoreResourceOperation.LIST), filter, pagination),\n update: async <T>(resourceType: ResourceType, id: string, data: unknown) =>\n inRelationship(async () => this.servicesRegistry.update<T>(resourceType, await authorized(resourceType, CoreResourceOperation.UPDATE, id), id, data)),\n delete: async <T>(resourceType: ResourceType, id: string) =>\n this.servicesRegistry.delete<T>(resourceType, await authorized(resourceType, CoreResourceOperation.DELETE, id), id),\n executeCustomOperation: async <T>(resourceType: ResourceType, operation: string, id?: string, data?: unknown) =>\n inRelationship(async () => this.servicesRegistry.executeCustomOperation<T>(resourceType, operation, await authorized(resourceType, operation, id), id, data)),\n };\n }\n}\n"]}
1
+ {"version":3,"file":"inbound-delivery-dispatch.backend.service.js","sourceRoot":"","sources":["../../../../src/inbound/services/inbound-delivery-dispatch.backend.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,qBAAqB,EAErB,qBAAqB,EACrB,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EAEpB,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,EACjB,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,GAGpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAAE,kCAAkC,EAAE,MAAM,6EAA6E,CAAC;AAQjI,OAAO,EAAE,2BAA2B,EAAE,MAAM,8EAA8E,CAAC;AAK3H,OAAO,EACL,gCAAgC,EAChC,4BAA4B,GAG7B,MAAM,kEAAkE,CAAC;AAC1E,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC5B,qBAAqB,EACrB,6BAA6B,EAC7B,2BAA2B,EAC3B,qBAAqB,GAKtB,MAAM,uEAAuE,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,oFAAoF,CAAC;AAMpJ,OAAO,EAAE,+BAA+B,EAAgD,MAAM,gDAAgD,CAAC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AAC,8BAA8B,CAAC,CAAA;IACzD,WAAA,MAAM,CAAC,kBAAkB,CAAC,qBAAqB,CAAC,CAAA;IAChD,WAAA,MAAM,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;IAAE,WAAA,QAAQ,EAAE,CAAA;IAC1D,WAAA,MAAM,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAA;IAAE,WAAA,QAAQ,EAAE,CAAA;IAMvD,WAAA,MAAM,CAAC,kBAAkB,CAAC,0BAA0B,CAAC,CAAA;IAAE,WAAA,QAAQ,EAAE,CAAA;IAKjE,WAAA,MAAM,CAAC,kBAAkB,CAAC,sCAAsC,CAAC,CAAA;IAAE,WAAA,QAAQ,EAAE,CAAA;IAK7E,YAAA,MAAM,CAAC,kBAAkB,CAAC,wBAAwB,CAAC,CAAA;IAAE,YAAA,QAAQ,EAAE,CAAA;IAK/D,YAAA,MAAM,CAAC,kBAAkB,CAAC,gCAAgC,CAAC,CAAA;IAAE,YAAA,QAAQ,EAAE,CAAA;IAEvE,YAAA,MAAM,CAAC,kBAAkB,CAAC,gCAAgC,CAAC,CAAA;IAAE,YAAA,QAAQ,EAAE,CAAA;;GApC/D,qCAAqC,CAwhBjD","sourcesContent":["/**\n * The inbound dispatch worker (#1596): runs ONE stored delivery's handler under the delivery's own\n * authority, and settles the row.\n *\n * ## The context is rebuilt from the ROW, never carried\n *\n * A custom-batch job carries no execution context across the queue, and that is the right shape here\n * rather than a limitation: the handler's authority is a function of two durable facts — the scope the\n * delivery resolved to (on the row) and the roles the handler declares (in code). Rebuilding from them\n * means a job payload cannot widen what a handler may do, and a replay weeks later runs with the roles\n * the handler declares TODAY.\n *\n * ## `ctx.resources` applies the controller's gate\n *\n * The service tier deliberately applies no operation role ACL — that gate lives at the controller,\n * where an untrusted principal names an operation (see the note above\n * `ServicesRegistryHandlerBackendService.create`). A handler is exactly such a principal, so each\n * call here builds a sub-context and runs `authorizeInController` on it before the service call:\n * roles, parent scope, unit narrowing, the per-row tenant check. Without that, `actingRoles` would be a\n * declaration that constrained nothing. The call must also resolve to an `API_CALL` variant: an\n * `INTERNAL_CALL` or repository-only variant is the engine's own door (the retention sweep's delete, for\n * one) and no HTTP caller reaches it, so neither may a handler.\n *\n * ## Delivery semantics: stored once, run at least once\n *\n * The store keeps one row per event. The handler may still run more than once for that row — a crash\n * after `handle()` returned but before the row settled, or a throw after some writes — so handlers must\n * be idempotent per `ctx.delivery.id`. The lease is renewed while a handler runs, so a slow handler is\n * not taken over by a second worker mid-run.\n *\n * ## Ordering waits do not reschedule themselves\n *\n * A delivery blocked by an earlier one on its ordering key is re-dated ({@link INBOUND_ORDERING_RECHECK_MS})\n * and left for the sweep; when the predecessor settles, the dispatcher wakes the next waiting delivery.\n * An earlier version re-enqueued the blocked row every ten seconds, and the sweep started another such\n * chain every minute, so a key blocked behind a failing delivery multiplied its own jobs without bound.\n */\nimport { inject, injectable, optional } from 'inversify';\nimport {\n ChatCommandOutcomeKind,\n inboundDeliveryCarriesChatInput,\n AutonomousTurnTrigger,\n type InboundChatCommandRunResult,\n CoreResourceOperation,\n CoreResourceType,\n ErrorType,\n ExecutionRefKind,\n InboundChatInputKind,\n InboundDeliveryUnroutableReason,\n InboundResolvedScopeKind,\n InboundRetryBackoffKind,\n InboundSourceKind,\n ResourceOperationVariantType,\n ResourcePrimaryScope,\n isWildoBackendError,\n jsonParsingSchemaOf,\n type ExecutionContext_RoleInfo,\n type ResourceType,\n} from '@wildo-ai/saas-models';\n\nimport { SAAS_SERVICE_TYPES } from '~wildo-backend-lib/inject/models/service-types';\nimport { runWithRelationshipProvenanceFrame } from '~wildo-backend-lib/runtime/models/relationship-provenance-frame.als.backend';\nimport type { LoggerService } from '~wildo-backend-lib/monitoring/logger/services/logger.service';\nimport type { ExecutionContextCreatorBackendService } from '~wildo-backend-lib/runtime/services/execution-context-creator.backend.service';\nimport type { ExecutionContext } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\nimport type { ServicesRegistryHandlerBackendService } from '~wildo-backend-lib/base-classes/services/services/services-registry-handler.backend.service';\nimport type { AuthorizationsBackendService } from '~wildo-backend-lib/security/authorizations/services/authorizations.backend.service';\nimport type { AuditLogsBackendService } from '~wildo-backend-lib/compliance/audit-trails/services/audit-logs.backend.service';\nimport type { QueueBackendService } from '~wildo-backend-lib/queue/queue.backend.service';\nimport { projectCaughtErrorLogFields } from '~wildo-backend-lib/errors/utils/error-log-level-classification.backend.utils';\nimport type { AutonomousAgentTurnBackendService } from '~wildo-backend-lib/flows-actors/services/autonomous-agent-turn.backend.service';\nimport type { InboundHandlerAgents } from '~wildo-backend-lib/inbound/models/inbound-handler-agents.backend.definitions';\nimport type { InboundHandlerPipelines } from '~wildo-backend-lib/inbound/models/inbound-handler-pipelines.backend.definitions';\nimport type { ExternalDataPipelineKeyRequestsBackendService } from '~wildo-backend-lib/external-data/external-data-pipeline-key-requests.backend.service';\nimport {\n engineInboundHandlerCapabilityOf,\n inboundScopeStandingPolicyOf,\n type EngineInboundHandlerContext,\n type InboundEngineOperationAccess,\n} from '~wildo-backend-lib/inbound/models/inbound-engine-handler.backend';\nimport {\n actingRolesForScope,\n ChatConverseOutcomeKind,\n ChatLinkPageUnavailableError,\n DEFAULT_INBOUND_RETRY_POLICY,\n InboundChatScopeError,\n InboundNotYetUnwarrantedError,\n InboundChatUnavailableError,\n InboundHandlerOutcome,\n type AnyInboundHandlerDefinition,\n type InboundHandlerChat,\n type InboundHandlerContext,\n type InboundRetryPolicy,\n} from '~wildo-backend-lib/inbound/models/inbound-handler.backend.definitions';\nimport { readInboundChatCommand, readInboundChatMessage } from '~wildo-backend-lib/notifications/webhooks/services/webhook-handler.backend.service';\nimport type { Hook_InboundChatCommand, Hook_InboundChatMessage } from '@wildo-ai/external-connectors-models';\nimport type { ChatCommandRunRecord } from '~wildo-backend-lib/inbound/chat-commands/chat-command-door.backend.service';\nimport type { ChatDeliveryPin, ChatMemberActionsBackendService } from '~wildo-backend-lib/inbound/services/chat-member-actions.backend.service';\nimport type { InboundHandlerRegistryBackendService } from './inbound-handler-registry.backend.service';\nimport { type InboundDeliveryLocation, type InboundDeliveryRow, type InboundDeliveryStoreBackendService } from './inbound-delivery-store.backend.service';\nimport { InboundStoredBodyIntegrityError, type InboundDeliveryStoredBodyBackendService } from './inbound-delivery-stored-body.backend.service';\nimport { InboundDeliveryAudit } from './inbound-delivery-audit.backend';\nimport { decodeInboundBody, storedInboundContentType } from '~wildo-backend-lib/inbound/models/inbound-body-decoding.backend';\nimport { enqueueInboundDeliveryDispatch } from './inbound-delivery-dispatch-queue.backend';\nimport { runWithWorkAttributionFrame } from '~wildo-backend-lib/runtime/models/work-attribution.als.backend';\nimport { ProviderConnectionTargetRefusedError } from '~wildo-backend-lib/external-providers/services/provider-http-access.backend';\nimport type { ProviderOperationExecutorBackendService } from '~wildo-backend-lib/external-providers/operations/provider-operation-executor.backend.service';\n\n/** What one dispatch concluded. */\nexport enum InboundDispatchOutcome {\n PROCESSED = 'processed',\n RETRY_SCHEDULED = 'retry_scheduled',\n DEAD = 'dead',\n /** An earlier delivery with the same ordering key is still pending; nothing was consumed. */\n DEFERRED_FOR_ORDERING = 'deferred_for_ordering',\n /** The row is gone (erased with its organization, or never existed). */\n SKIPPED_MISSING = 'skipped_missing',\n /** Another worker holds or has settled the row, or it is not due. */\n SKIPPED_NOT_DUE = 'skipped_not_due',\n /** The handler answered `NOT_YET` (a chat conversation still runs a turn): released, no attempt spent (#2665 S6). */\n NOT_YET = 'not_yet',\n}\n\n/**\n * How far a delivery blocked by its ordering predecessor is re-dated. The sweep's cadence: the blocked\n * row is looked at again by the next sweep, or sooner when its predecessor settles and wakes it.\n */\nexport const INBOUND_ORDERING_RECHECK_MS = 60_000;\n\n/** The variants an application handler's `ctx.resources` may reach: what an HTTP caller reaches. */\nexport const APPLICATION_HANDLER_OPERATION_VARIANTS: ReadonlySet<ResourceOperationVariantType> = new Set([ResourceOperationVariantType.API_CALL]);\n\n/**\n * The variants an ENGINE handler's door may reach (#1629): also the engine's service-pipeline operations, which\n * register no route. Never REPOSITORY_ONLY — that is plumbing, and has no business-operation authorization.\n */\nexport const ENGINE_HANDLER_OPERATION_VARIANTS: ReadonlySet<ResourceOperationVariantType> = new Set([\n ResourceOperationVariantType.API_CALL,\n ResourceOperationVariantType.INTERNAL_CALL,\n]);\n\n/**\n * The role entry a delivery's principal carries: the handler's declared roles for the delivery's scope. A person's\n * own data gates on APPLICATION roles, so a user-scope delivery carries its roles as an application entry; the\n * ownership check and the scope filter confine them to that one person (#1629).\n */\nexport function inboundHandlerInitiatorRoles(\n actingRoles: AnyInboundHandlerDefinition['actingRoles'],\n scope: Exclude<InboundDeliveryRow['resolvedScope'], { kind: InboundResolvedScopeKind.UNROUTABLE }>,\n): ExecutionContext_RoleInfo[] {\n const roles = [...(actingRolesForScope(actingRoles, scope.kind) ?? [])];\n return scope.kind === InboundResolvedScopeKind.ORGANIZATION\n ? [{ roles, relatedPrimaryScope: ResourcePrimaryScope.ORGANIZATIONS, relatedResourceId: scope.organizationId }]\n : [{ roles, relatedPrimaryScope: ResourcePrimaryScope.APPLICATION }];\n}\n\n/** What {@link authorizeInboundSubCall} needs: the context creator and the authorizer. */\nexport interface InboundSubCallAuthorizationDeps {\n readonly executionContextCreator: Pick<ExecutionContextCreatorBackendService, 'createForSubCall'>;\n readonly authorizations: Pick<AuthorizationsBackendService, 'authorizeInController'>;\n}\n\n/**\n * One sub-context of a delivery's context, authorized as at the controller: the operation must resolve to one\n * of `admittedVariants`, then `authorizeInController` runs on it — roles, parent scope, unit narrowing, the\n * per-row tenant check. The ONE implementation behind `ctx.resources` and the engine door (#1629), exported so\n * the integration lanes authorize through it instead of re-implementing it.\n */\nexport async function authorizeInboundSubCall(\n deps: InboundSubCallAuthorizationDeps,\n executionContext: ExecutionContext<any>,\n resourceType: ResourceType,\n operation: string,\n id: string | undefined,\n admittedVariants: ReadonlySet<ResourceOperationVariantType>,\n): Promise<ExecutionContext<any>> {\n // sub-call-transaction: N/A — a delivery holds no transaction here; the operation this context authorizes opens its own (#3066).\n const sub = await deps.executionContextCreator.createForSubCall(executionContext, resourceType, operation, undefined, id);\n // assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — a handler reaches only what an HTTP caller can: the engine's internal and repository-only doors are refused (an engine handler additionally reaches INTERNAL_CALL, never repository-only).\n if (!sub.operation?.variantType || !admittedVariants.has(sub.operation.variantType)) {\n throw Object.assign(new Error(`'${String(resourceType)}.${operation}' is not an operation this inbound handler may call`), { name: 'InboundHandlerOperationNotAddressable' });\n }\n await deps.authorizations.authorizeInController(id, sub);\n return sub;\n}\n\n/** How often a running attempt renews its lease: a third of the lease, so two renewals may fail before it lapses. */\nexport const INBOUND_LEASE_RENEWAL_MS = 10 * 60 * 1000;\n\n/** The wait before the next attempt, per the handler's backoff. `attempt` is 1-based (the attempt that just failed). */\nexport function inboundRetryDelaySeconds(policy: InboundRetryPolicy, attempt: number): number {\n const { kind, baseSeconds, maxSeconds } = policy.backoff;\n switch (kind) {\n case InboundRetryBackoffKind.FIXED: return baseSeconds;\n case InboundRetryBackoffKind.EXPONENTIAL: {\n const grown = baseSeconds * 2 ** Math.max(0, attempt - 1);\n return maxSeconds !== undefined ? Math.min(grown, maxSeconds) : grown;\n }\n default: {\n const unhandled: never = kind;\n return unhandled;\n }\n }\n}\n\n/**\n * When the next attempt runs, or `null` when the budget is spent: the attempts since the budget\n * started reached `maxAttempts`, or the next attempt would fall past the window.\n */\nexport function nextInboundAttemptAt(policy: InboundRetryPolicy, row: Pick<InboundDeliveryRow, 'attemptCount' | 'budgetBaseAttemptCount' | 'budgetStartedAt'>, now: Date): Date | null {\n const attemptsInBudget = row.attemptCount - row.budgetBaseAttemptCount;\n if (attemptsInBudget >= policy.maxAttempts) return null;\n const next = new Date(now.getTime() + inboundRetryDelaySeconds(policy, attemptsInBudget) * 1000);\n const windowEnds = row.budgetStartedAt.getTime() + policy.maxWindowSeconds * 1000;\n return next.getTime() > windowEnds ? null : next;\n}\n\n/**\n * A failure no retry can cure: the handler is not authorized, its input does not validate, or the stored\n * body no longer parses. It goes straight to `DEAD`, where a replay after the fix runs it again, rather\n * than spending the retry budget on the same refusal. A `NOT_FOUND` stays retryable: a sender may\n * deliver an event before the record it names exists.\n */\nexport function isPermanentInboundHandlerError(error: unknown): boolean {\n if (isWildoBackendError(error)) {\n return error.type === ErrorType.AUTHORIZATION || error.type === ErrorType.AUTHENTICATION\n || error.type === ErrorType.VALIDATION || error.type === ErrorType.PAYLOAD_TOO_LARGE;\n }\n return error instanceof Error\n && (error.name === 'ZodError' || error.name === 'SyntaxError' || error.name === 'InboundHandlerOperationNotAddressable'\n // `ctx.chat` refusals no retry changes (#2664): a delivery with no chat member, an unbound door, no link page.\n || error instanceof InboundChatScopeError || error instanceof InboundChatUnavailableError || error instanceof ChatLinkPageUnavailableError\n // A NOT_YET the chat door did not give (#2665 S6 review M2): the handler's code is wrong, and no retry changes it.\n || error instanceof InboundNotYetUnwarrantedError\n // `ctx.providers` refusals no retry changes (#2664 review R-8): a connection this delivery may not spend, or no\n // executor bound. An unconnected account or a token endpoint that did not answer stays retryable.\n || error instanceof ProviderConnectionTargetRefusedError || error.name === 'InboundProviderOperationsUnavailable'\n // A body stored outside its row that is gone or no longer the bytes received (#3395): no retry brings it back.\n || error instanceof InboundStoredBodyIntegrityError);\n}\n\n/**\n * The error code a delivery settles DEAD with when its stored scope is not one a handler can run in (#1774).\n *\n * A row reaches the dispatcher only after the receiver resolved it to ORGANIZATION or APPLICATION, so any\n * other shape means the stored row was damaged after it was accepted. It must never fall through to the\n * application's roles: that is how a replayed organization delivery ran with application authority.\n */\nexport const INBOUND_DELIVERY_SCOPE_MALFORMED = 'InboundDeliveryScopeMalformed';\n\n/**\n * Whether a stored row's scope is one the dispatcher may run, and agrees with the table it lives in: an\n * ORGANIZATION scope naming the row's own organization, in the organization variant; APPLICATION, or USER naming\n * a person, in the application variant. Anything else is refused, never defaulted.\n */\nexport function hasRunnableInboundScope(row: Pick<InboundDeliveryRow, 'resolvedScope' | 'organizationId'>, resourceType: string): boolean {\n const scope = row.resolvedScope as { kind?: unknown; organizationId?: unknown; userId?: unknown } | undefined;\n if (scope?.kind === InboundResolvedScopeKind.ORGANIZATION) {\n return resourceType === CoreResourceType.ORGANIZATION_INBOUND_DELIVERIES\n && typeof scope.organizationId === 'string' && scope.organizationId.length > 0\n && scope.organizationId === row.organizationId;\n }\n if (scope?.kind === InboundResolvedScopeKind.APPLICATION) return resourceType === CoreResourceType.APPLICATION_INBOUND_DELIVERIES;\n // A person's delivery lives in the application variant (#1629) and must name the person.\n if (scope?.kind === InboundResolvedScopeKind.USER) {\n return resourceType === CoreResourceType.APPLICATION_INBOUND_DELIVERIES && typeof scope.userId === 'string' && scope.userId.length > 0;\n }\n return false;\n}\n\n/** A classification of a handler failure — an error type and reference, never a message (which can quote the payload). */\nexport function classifyInboundHandlerError(error: unknown): string {\n if (isWildoBackendError(error)) return [error.type, error.customMessageReference].filter(Boolean).join(':');\n if (error instanceof Error) return error.name || 'Error';\n return 'unknown';\n}\n\n/** The relationship one delivery turned out to be the act of (#2722), filled by the chat door and read by `ctx.resources`. */\ninterface InboundDeliveryProvenance {\n relationshipId?: string;\n}\n\n/**\n * What the chat door did with one attempt's message (#2665 S6, plan V3), on state the DISPATCHER owns, set by\n * `ctx.chat.converse()`: the conversation whose transcript took it, and what the door answered last. Read when the attempt\n * ends, so the chat message's body is emptied with the right reason in the settle itself, and a wait is the door's\n * decision rather than the handler's (review M2).\n */\ninterface InboundChatDoorRecord {\n /** Where the delivery is stored: what the door empties once the conversation holds the message. */\n readonly location: InboundDeliveryLocation;\n heldByExecutionId?: string;\n /** The kind of the door's last answer in this attempt; absent when the door gave none (no converse, no message read, or a throw). */\n answered?: ChatConverseOutcomeKind;\n}\n\n@injectable()\nexport class InboundDeliveryDispatchBackendService {\n private readonly audit: InboundDeliveryAudit;\n\n clock: () => Date = () => new Date();\n\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) private readonly logger: LoggerService,\n @inject(SAAS_SERVICE_TYPES.InboundHandlerRegistryService) private readonly registry: InboundHandlerRegistryBackendService,\n @inject(SAAS_SERVICE_TYPES.InboundDeliveryStoreService) private readonly store: InboundDeliveryStoreBackendService,\n @inject(SAAS_SERVICE_TYPES.ExecutionContextCreatorBackendService) private readonly executionContextCreator: Pick<ExecutionContextCreatorBackendService, 'createForInboundDelivery' | 'createForSubCall'>,\n @inject(SAAS_SERVICE_TYPES.ServicesRegistryHandlerService) private readonly servicesRegistry: Pick<ServicesRegistryHandlerBackendService, 'create' | 'read' | 'list' | 'update' | 'delete' | 'executeCustomOperation'>,\n @inject(SAAS_SERVICE_TYPES.AuthorizationsService) private readonly authorizations: Pick<AuthorizationsBackendService, 'authorizeInController'>,\n @inject(SAAS_SERVICE_TYPES.QueueBackendService) @optional() private readonly queue?: Pick<QueueBackendService, 'enqueueCustomBatch'>,\n @inject(SAAS_SERVICE_TYPES.AuditLogsService) @optional() auditLogs?: AuditLogsBackendService,\n /**\n * The autonomous entry point `ctx.agents` hands a delivery to (#1611). `@optional()` and appended last:\n * a process without it runs handlers the same and refuses to start agents, and hand-built test doubles\n * construct this service positionally.\n */\n @inject(SAAS_SERVICE_TYPES.AutonomousAgentTurnService) @optional() private readonly autonomousAgentTurns?: Pick<AutonomousAgentTurnBackendService, 'startAutonomousAgentTurn'>,\n /**\n * The pipeline key-request door `ctx.pipelines` reaches (#1688). `@optional()` and appended last for the same reasons\n * as `autonomousAgentTurns`: a process without it runs handlers the same and refuses a key request.\n */\n @inject(SAAS_SERVICE_TYPES.ExternalDataPipelineKeyRequestsService) @optional() private readonly pipelineKeyRequests?: Pick<ExternalDataPipelineKeyRequestsBackendService, 'requestPipelineKeys'>,\n /**\n * What `ctx.chat` acts through (#2664). `@optional()` and appended last for the same reasons as\n * `autonomousAgentTurns`: a process without it runs handlers the same and refuses a chat act.\n */\n @inject(SAAS_SERVICE_TYPES.ChatMemberActionsService) @optional() private readonly chatMemberActions?: Pick<ChatMemberActionsBackendService, 'resolveActingMember' | 'answerDecision' | 'converse' | 'runCommand'>,\n /**\n * What `ctx.providers` calls through (#2664). `@optional()` and appended last for the same reasons as\n * `autonomousAgentTurns`: a process without it runs handlers the same and refuses a provider call.\n */\n @inject(SAAS_SERVICE_TYPES.ProviderOperationExecutorService) @optional() private readonly providerOperations?: Pick<ProviderOperationExecutorBackendService, 'forExecution'>,\n /** #3395: reads a body stored outside its row. Bound in every backend; a row naming one with none bound is retried. */\n @inject(SAAS_SERVICE_TYPES.InboundDeliveryStoredBodyService) @optional() private readonly storedBodies?: Pick<InboundDeliveryStoredBodyBackendService, 'read'>,\n ) {\n this.audit = new InboundDeliveryAudit(auditLogs);\n }\n\n private get authorizationDeps(): InboundSubCallAuthorizationDeps {\n return { executionContextCreator: this.executionContextCreator, authorizations: this.authorizations };\n }\n\n /** Run one delivery's handler, once, and settle the row. */\n async dispatch(location: InboundDeliveryLocation): Promise<InboundDispatchOutcome> {\n const row = await this.store.read(location);\n if (!row) return InboundDispatchOutcome.SKIPPED_MISSING;\n\n // Asked BEFORE the lease, so a blocked delivery consumes no attempt. It is re-dated and NOT\n // re-enqueued: the sweep, or its predecessor settling, brings it back (see the header).\n if (await this.store.hasPendingPredecessor(location, row)) {\n await this.store.deferForOrdering(location, row, new Date(this.clock().getTime() + INBOUND_ORDERING_RECHECK_MS));\n return InboundDispatchOutcome.DEFERRED_FOR_ORDERING;\n }\n\n const leased = await this.store.lease(location, row);\n if (!leased) return InboundDispatchOutcome.SKIPPED_NOT_DUE;\n\n const handler = this.registry.getHandler(leased.handlerRef);\n // assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — a delivery runs only in the scope it was stored with; a damaged scope ends DEAD, never defaulted to the application's roles.\n if (!hasRunnableInboundScope(leased, String(location.resourceType))) {\n this.logger.error('Inbound delivery refused: its stored scope is not one a handler can run in', { inboundDeliveryId: location.id, handlerRef: leased.handlerRef });\n return this.settle(location, leased, INBOUND_DELIVERY_SCOPE_MALFORMED, null);\n }\n // assurance-control: WILDO.ACCESS.SCOPE_CONFINEMENT — an organization or person that lost its authority after the delivery arrived does not act through its retries.\n // A failed read settles like any failed attempt (retried, audited, lease released) rather than leaving the\n // row PROCESSING until its lease expires with nothing recorded. An engine handler recording a third party's\n // facts runs whatever the standing (#1629), but never for a scope that no longer exists.\n let refusal: InboundDeliveryUnroutableReason | null;\n try {\n refusal = await this.store.scopeStandingRefusal(leased, inboundScopeStandingPolicyOf(handler));\n } catch (error) {\n return this.settleFailure(location, leased, handler, error);\n }\n if (refusal) return this.settle(location, leased, refusal, null);\n // #2665 S6 (plan B4): a delivery whose body was emptied has been answered: its conversation's transcript took the\n // message (this is the retry of an attempt that threw after the turn started), or it was answered and kept nowhere.\n // Nothing is left to run, and the empty body would not decode: settled PROCESSED without the handler.\n if (leased.bodyRedactedAt) return this.settleProcessed(location, leased, {});\n\n const renewal = setInterval(() => {\n void this.store.renewLease(location, leased).then((renewed) => {\n if (!renewed) this.logger.warn('Inbound handler still running, but its lease was lost', { inboundDeliveryId: location.id, handlerRef: leased.handlerRef });\n }, (error: unknown) => this.logger.warn('Inbound lease renewal failed', { inboundDeliveryId: location.id, ...projectCaughtErrorLogFields(error) }));\n }, INBOUND_LEASE_RENEWAL_MS);\n renewal.unref?.();\n let handlerOutcome: void | InboundHandlerOutcome;\n const chatDoor: InboundChatDoorRecord = { location };\n try {\n if (!handler) {\n // A deployment removed or renamed the handler. The row keeps its budget and retries: the next\n // deployment may bring it back, and DEAD is where an operator will look if it does not.\n throw Object.assign(new Error(`No inbound handler is declared for '${leased.handlerRef}'`), { name: 'InboundHandlerNotDeclared' });\n }\n const context = await this.buildHandlerContext(leased, handler, chatDoor);\n // Decoded as it was received (#2659): the receiver checked THIS value against the payload schema, so the\n // handler runs on the same thing, a form's fields included.\n const decoded = decodeInboundBody(await this.storedBodyOf(location, leased), storedInboundContentType(leased.headers));\n // Literal comparison: this package compiles without strictNullChecks, where `!decoded.ok` does not narrow.\n if (decoded.ok === false) throw Object.assign(new Error('The stored inbound body no longer decodes as the media type it was received as'), { name: 'InboundBodyUndecodable' });\n // The receiver's schema (#3478): the stored body is JSON, read through the payload schema's JSON form.\n const payload = jsonParsingSchemaOf(handler.payloadSchema).parse(decoded.body);\n // #1598 (§4, S8): a model call the handler makes (an embedding, an extraction, an agent turn it starts) is\n // attributed to THIS delivery and to the organization the delivery was stored in — the row's own scope,\n // never the payload. A channel handler narrows it to the thread's case (`InboundChannelRuntimeBackendService`).\n handlerOutcome = await runWithWorkAttributionFrame({\n ...(leased.organizationId ? { organizationId: leased.organizationId } : {}),\n executionRef: { kind: ExecutionRefKind.INBOUND_DELIVERY, id: location.id },\n }, () => handler.handle(context, payload));\n } catch (error) {\n return this.settleFailure(location, leased, handler, error);\n } finally {\n clearInterval(renewal);\n }\n\n // #2665 S6 (plans B5, V5, review M2): the chat door said the message must wait. Released without spending the attempt,\n // without a failure audit, and without waking a successor: the delivery has not settled, so nothing behind it may\n // run. The DOOR's answer decides, whatever the handler returned: a handler that dropped it would otherwise settle the\n // message as answered and lose it, and a NOT_YET the door did not give would recycle the delivery with no bound.\n const doorSaidNotYet = chatDoor.answered === ChatConverseOutcomeKind.NOT_YET;\n if (handlerOutcome === InboundHandlerOutcome.NOT_YET && !doorSaidNotYet) {\n return this.settleFailure(location, leased, handler, new InboundNotYetUnwarrantedError(\n `Inbound handler '${leased.handlerRef}' answered NOT_YET, which only ctx.chat.converse() may decide; the delivery cannot wait without a bound`,\n ));\n }\n if (doorSaidNotYet) {\n if (handlerOutcome !== InboundHandlerOutcome.NOT_YET) {\n this.logger.warn('Inbound handler did not return the chat door\\'s NOT_YET; the delivery waits anyway', { inboundDeliveryId: location.id, handlerRef: leased.handlerRef });\n }\n const released = await this.store.releaseNotYet(location, leased, new Date(this.clock().getTime() + INBOUND_ORDERING_RECHECK_MS));\n if (!released) {\n this.logger.warn('Inbound delivery could not run yet, but its lease was lost before it could be released', { inboundDeliveryId: location.id, handlerRef: leased.handlerRef });\n return InboundDispatchOutcome.SKIPPED_NOT_DUE;\n }\n return InboundDispatchOutcome.NOT_YET;\n }\n\n // #2665 S6 (plan V3): a chat message has one copy once it settles: its conversation's transcript, or none.\n if (inboundDeliveryCarriesChatInput(leased)) {\n return this.settleProcessed(location, leased, { redactBody: chatDoor.heldByExecutionId ? { heldByExecutionId: chatDoor.heldByExecutionId } : {} });\n }\n // #3395, #3394: a body its engine handler keeps elsewhere (received-email rows, an SMS provider event row) has one\n // copy once it settles: that one.\n const heldBy = engineInboundHandlerCapabilityOf(handler)?.bodyHeldOnceProcessedBy;\n return this.settleProcessed(location, leased, heldBy === undefined ? {} : { redactBody: { heldBy } });\n }\n\n /**\n * The bytes the delivery was received with (#3395): from the row, or, for a body too large for it, from the file the row\n * names, checked against the SHA-256 and length the row recorded at receipt. A chat message is never stored outside its\n * row (the receiver refuses one that large), which is why the chat readers below read `rawBody` directly.\n */\n private async storedBodyOf(location: InboundDeliveryLocation, leased: InboundDeliveryRow): Promise<Buffer> {\n if (!leased.storedBody) return Buffer.from(leased.rawBody, 'base64');\n if (!this.storedBodies) throw Object.assign(new Error('An inbound delivery\\'s body is stored outside its row, and no reader for it is bound'), { name: 'InboundStoredBodyReaderUnavailable' });\n return this.storedBodies.read(location.resourceType, leased);\n }\n\n /** Settle a completed attempt PROCESSED, audit it, and wake the delivery waiting behind it. */\n private async settleProcessed(location: InboundDeliveryLocation, leased: InboundDeliveryRow, options: Parameters<InboundDeliveryStoreBackendService['markProcessed']>[2]): Promise<InboundDispatchOutcome> {\n const processed = await this.store.markProcessed(location, leased, options);\n if (!processed) {\n this.logger.warn('Inbound delivery processed, but its lease was lost before it could be settled', { inboundDeliveryId: location.id, handlerRef: leased.handlerRef });\n return InboundDispatchOutcome.SKIPPED_NOT_DUE;\n }\n await this.audit.processed(processed);\n await this.wakeSuccessor(location, processed);\n return InboundDispatchOutcome.PROCESSED;\n }\n\n /** Enqueue every due delivery (received, retry due, or lease expired). Returns how many were found. */\n async sweep(limit = 200): Promise<number> {\n const due = await this.store.findDue(limit);\n for (const { location } of due) {\n if (this.queue) await enqueueInboundDeliveryDispatch(this.queue, location, this.logger);\n else await this.dispatch(location);\n }\n return due.length;\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n\n private async settleFailure(location: InboundDeliveryLocation, leased: InboundDeliveryRow, handler: AnyInboundHandlerDefinition | undefined, error: unknown): Promise<InboundDispatchOutcome> {\n const errorCode = classifyInboundHandlerError(error);\n this.logger.warn('Inbound handler attempt failed', { inboundDeliveryId: location.id, handlerRef: leased.handlerRef, attempt: leased.attemptCount, errorCode, ...projectCaughtErrorLogFields(error) });\n const policy = handler ? this.registry.retryPolicyOf(handler) : DEFAULT_INBOUND_RETRY_POLICY;\n const retryAt = isPermanentInboundHandlerError(error) ? null : nextInboundAttemptAt(policy, leased, this.clock());\n return this.settle(location, leased, errorCode, retryAt);\n }\n\n /**\n * Settle a failed attempt: scheduled for `retryAt`, or `DEAD` without one. A chat COMMAND that dies is emptied as it\n * dies (#2666 S7 slice review F3): its text is the person's, it can no longer run once its staleness window passes, and\n * nothing else would ever empty it (`runCommand()` keeps nothing, so no PROCESSED settle will come).\n */\n private async settle(location: InboundDeliveryLocation, leased: InboundDeliveryRow, errorCode: string, retryAt: Date | null): Promise<InboundDispatchOutcome> {\n const settled = leased.chatInput === InboundChatInputKind.COMMAND\n ? await this.store.markFailed(location, leased, errorCode, retryAt, { redactBodyIfDead: {} })\n : await this.store.markFailed(location, leased, errorCode, retryAt);\n if (!settled) return InboundDispatchOutcome.SKIPPED_NOT_DUE;\n if (retryAt) {\n await this.audit.failed(settled, errorCode, retryAt);\n await enqueueInboundDeliveryDispatch(this.queue, location, this.logger, Math.max(0, retryAt.getTime() - this.clock().getTime()));\n return InboundDispatchOutcome.RETRY_SCHEDULED;\n }\n await this.audit.dead(settled, errorCode);\n await this.wakeSuccessor(location, settled);\n return InboundDispatchOutcome.DEAD;\n }\n\n /** A settled delivery releases the next one waiting on its ordering key, rather than leaving it to the sweep. */\n private async wakeSuccessor(location: InboundDeliveryLocation, settled: InboundDeliveryRow): Promise<void> {\n const next = await this.store.wakeOrderingSuccessor(location, settled);\n // Enqueued for when it is due: a re-read trigger's trailing delivery stays held to its window (#2909 review N1).\n if (next && this.queue) await enqueueInboundDeliveryDispatch(this.queue, next, this.logger, Math.max(0, next.dueAt.getTime() - this.clock().getTime()));\n }\n\n /**\n * `ctx.agents` (#1611): the delivery handed to a declared autonomous agent. The occurrence IS the delivery,\n * so a retry, a crash-and-rerun or an operator's replay starts nothing twice; the trigger marks the turn's\n * input as untrusted for its whole life. Only an organization-scoped delivery can start one.\n */\n private buildAgents(deliveryId: string, sourceKey: string, organizationId: string | undefined): InboundHandlerAgents {\n return {\n startAutonomousTurn: async (request) => {\n if (!organizationId) {\n throw Object.assign(new Error('An autonomous agent runs in an organization; this delivery resolved to none, so no agent can be started from it.'), { name: 'InboundAutonomousTurnScopeError' });\n }\n if (!this.autonomousAgentTurns) {\n throw Object.assign(new Error('No autonomous entry point is bound in this process, so no agent can be started from an inbound delivery.'), { name: 'InboundAutonomousTurnUnavailableError' });\n }\n return this.autonomousAgentTurns.startAutonomousAgentTurn({\n autonomousAgentRef: request.autonomousAgentRef,\n organizationId,\n occurrenceKey: deliveryId,\n trigger: AutonomousTurnTrigger.INBOUND_DELIVERY,\n // #2973: the delivery the turn came through, from the stored row (never from the handler's request), so every\n // call the turn makes is metered on the lane its endpoint dictates (`ConnectionRateBudgetBackendService.laneOf`).\n arrivedThrough: { inboundSourceKey: sourceKey, inboundDeliveryId: deliveryId },\n ...(request.input ? { input: request.input } : {}),\n ...(request.caseRef ? { caseRef: request.caseRef } : {}),\n });\n },\n };\n }\n\n /**\n * `ctx.chat` (#2664): what a chat delivery's handler does as the member who sent it. Pinned to the delivery: its\n * ORGANIZATION (the one the receiver routed it to from the vendor's own facts) and its provider, which is the chat\n * connection every account it names belongs to. A delivery from an application endpoint, from a provider endpoint\n * whose verified request names no chat member (`InboundHandlerRegistryBackendService.endpointNamesChatMember`), or one\n * that resolved to another scope, has no chat member to act as, and every call refuses.\n */\n private buildChat(row: InboundDeliveryRow, handler: AnyInboundHandlerDefinition, provenance: InboundDeliveryProvenance, chatDoor: InboundChatDoorRecord, executionContext: ExecutionContext<any>): InboundHandlerChat {\n const pin = (): ChatDeliveryPin => {\n const scope = row.resolvedScope;\n if (handler.source.kind !== InboundSourceKind.PROVIDER_ENDPOINT || scope.kind !== InboundResolvedScopeKind.ORGANIZATION) {\n throw new InboundChatScopeError('A chat member acts in the organization a provider\\'s delivery was routed to; this delivery has none, so nobody can act from it.');\n }\n // assurance-control: WILDO.IDENTITY.DELEGATED_AUTHORIZATION — only an endpoint whose verified request names a chat\n // person may act as that person's linked member. A webhook, an email (whose From is not verified by anything) or\n // any other provider endpoint names nobody the engine has checked, so its handler acts as no one (S5a review F1).\n if (!this.registry.endpointNamesChatMember(handler.source.providerRef, handler.source.endpointKey)) {\n throw new InboundChatScopeError(`The endpoint '${handler.source.providerRef}:${handler.source.endpointKey}' names no chat member its vendor verified, so nobody can act from its deliveries.`);\n }\n if (!this.chatMemberActions) {\n throw new InboundChatUnavailableError('No chat member door is bound in this process, so no chat delivery can act as a member.');\n }\n return { organizationId: scope.organizationId, connectionRef: handler.source.providerRef, sourceKey: row.sourceKey, deliveryId: String(row._id) };\n };\n /** The command's run record for this attempt, built on the first `runCommand()` and shared by every later one. */\n let commandRun: ChatCommandRunRecord | undefined;\n return {\n actingMember: async (account) => {\n const pinned = pin();\n const resolved = await this.chatMemberActions!.resolveActingMember(pinned, account);\n // #2722: the delivery is now this member's act. When they stand in the organization through one relationship,\n // what the handler creates from here on is that relationship's work (`buildResources`).\n if (resolved.throughRelationshipId) provenance.relationshipId = resolved.throughRelationshipId;\n return resolved.member;\n },\n answerDecision: async (input) => {\n const pinned = pin();\n return this.chatMemberActions!.answerDecision(pinned, input);\n },\n converse: async () => {\n const pinned = pin();\n const message = this.storedChatMessage(row, handler);\n if (!message) return { kind: ChatConverseOutcomeKind.NO_MESSAGE };\n const outcome = await this.chatMemberActions!.converse(pinned, message, row.budgetStartedAt);\n chatDoor.answered = outcome.kind;\n if (outcome.kind === ChatConverseOutcomeKind.STARTED || outcome.kind === ChatConverseOutcomeKind.ALREADY_RECEIVED) {\n await this.holdChatMessageInConversation(row, chatDoor, outcome.executionId);\n }\n return outcome;\n },\n runCommand: async () => {\n const pinned = pin();\n const command = this.storedChatCommand(row, handler);\n // A command endpoint's request whose command could not be read: marked COMMAND at receipt, so its body is still\n // emptied when it settles, and nothing runs.\n if (!command) return { kind: ChatCommandOutcomeKind.NO_COMMAND };\n // ONE run record for the attempt (5f re-review R4): built from the leased row once, so a second call of a WRITE sees\n // the first one's start and answers its outcome, instead of starting from the stale snapshot, losing the start and\n // retrying the attempt into a second answer. A READ records no start, so a second call runs it again, and its\n // outcome cannot replace the first one's (the door audits it as an unrecorded outcome).\n commandRun ??= this.commandRunRecord(chatDoor.location, row);\n return this.chatMemberActions!.runCommand(pinned, command, {\n receivedAt: row.receivedAt,\n run: commandRun,\n deliveryContext: executionContext,\n });\n },\n };\n }\n\n /**\n * The chat command a person sent, read again from the stored delivery through its endpoint's `chatCommandOf` (#2666 S7),\n * exactly as the receiver read it: on the bytes the engine verified, never from the handler.\n */\n private storedChatCommand(row: InboundDeliveryRow, handler: AnyInboundHandlerDefinition): Hook_InboundChatCommand | undefined {\n if (handler.source.kind !== InboundSourceKind.PROVIDER_ENDPOINT) return undefined;\n const endpoint = this.registry.chatCommandEndpoint(handler.source.providerRef, handler.source.endpointKey);\n if (!endpoint || !row.rawBody) return undefined;\n const rawBody = Buffer.from(row.rawBody, 'base64');\n const contentType = storedInboundContentType(row.headers);\n const decoded = decodeInboundBody(rawBody, contentType);\n if (decoded.ok === false) return undefined;\n return readInboundChatCommand(endpoint, { rawBody, headers: row.headers ?? {}, contentType, body: decoded.body }, (error) => this.logger.error(\n 'An inbound chat endpoint could not read the command from a stored delivery', { inboundDeliveryId: String(row._id), handlerRef: handler.ref, ...projectCaughtErrorLogFields(error) },\n ));\n }\n\n /**\n * The command's run record over the leased row (#2666 S7, design N1). Stateful for the attempt: a second\n * `runCommand()` of a write in the same attempt sees the start and the outcome the first one recorded, and answers them\n * instead of losing a compare-and-swap. A read records no start, so a second call runs it again. Every write is fenced\n * on the lease.\n */\n private commandRunRecord(location: InboundDeliveryLocation, leased: InboundDeliveryRow): ChatCommandRunRecord {\n const now = () => this.clock();\n let startedAt: Date | null = leased.commandRunStartedAt ?? null;\n let result: InboundChatCommandRunResult | null = leased.commandRunResult ?? null;\n let auditedAt: Date | null = leased.commandRunAuditedAt ?? null;\n return {\n get startedAt() { return startedAt; },\n get result() { return result; },\n get auditedAt() { return auditedAt; },\n start: async () => {\n const started = await this.store.startCommandRun(location, leased);\n if (started) startedAt = started.commandRunStartedAt ?? now();\n return started !== null;\n },\n recordResult: async (outcome) => {\n const recorded = await this.store.recordCommandRunResult(location, leased, outcome);\n if (recorded) result = outcome;\n return recorded !== null;\n },\n markAudited: async () => {\n const marked = await this.store.markCommandRunAudited(location, leased);\n if (marked) auditedAt = marked.commandRunAuditedAt ?? now();\n },\n };\n }\n\n /**\n * The message a person wrote, read again from the stored delivery through its endpoint's `chatMessageOf` (#2665 S6): the\n * same function the receiver read it with, on the bytes the engine verified, so nothing about it was copied at receipt\n * and nothing about it comes from the handler.\n */\n private storedChatMessage(row: InboundDeliveryRow, handler: AnyInboundHandlerDefinition): Hook_InboundChatMessage | undefined {\n if (handler.source.kind !== InboundSourceKind.PROVIDER_ENDPOINT) return undefined;\n const endpoint = this.registry.chatMessageEndpoint(handler.source.providerRef, handler.source.endpointKey);\n if (!endpoint || !row.rawBody) return undefined;\n const rawBody = Buffer.from(row.rawBody, 'base64');\n const contentType = storedInboundContentType(row.headers);\n const decoded = decodeInboundBody(rawBody, contentType);\n if (decoded.ok === false) return undefined;\n return readInboundChatMessage(endpoint, { rawBody, headers: row.headers ?? {}, contentType, body: decoded.body }, (error) => this.logger.error(\n 'An inbound chat endpoint could not read the message from a stored delivery', { inboundDeliveryId: String(row._id), handlerRef: handler.ref, ...projectCaughtErrorLogFields(error) },\n ));\n }\n\n /**\n * The conversation's transcript holds the message now (#2665 S6, plans B4, V3): empty the delivery's copy at once, so a\n * handler that throws after this leaves none for its retry. Recorded on the dispatcher's own state first, so the\n * PROCESSED settle names the conversation even when this write misses (a lease lost, a store that failed); the retry\n * that follows a throw finds the message held and settles.\n */\n private async holdChatMessageInConversation(row: InboundDeliveryRow, chatDoor: InboundChatDoorRecord, executionId: string): Promise<void> {\n chatDoor.heldByExecutionId = executionId;\n try {\n await this.store.redactBody(chatDoor.location, row, { heldByExecutionId: executionId });\n } catch (error) {\n this.logger.warn('A chat delivery\\'s body could not be emptied once its conversation took the message; its settle empties it', {\n inboundDeliveryId: String(row._id), executionId, ...projectCaughtErrorLogFields(error),\n });\n }\n }\n\n /**\n * `ctx.pipelines` (#1688): the one way a handler affects a data pipeline — it names records, and the pipeline re-reads\n * them from the system of record under its own lease. The handler's authority here is its `pipelineKeyRequests`\n * declaration, checked at startup against each pipeline and here against the call; its roles do not apply, because it\n * writes nothing: the keyed run loads what the SOURCE serves, exactly as a scheduled pass would. Any delivery scope may\n * ask, for the same reason — a re-read only makes the pipeline's copy current sooner.\n */\n private buildPipelines(deliveryId: string, handler: AnyInboundHandlerDefinition): InboundHandlerPipelines {\n const declared = new Set<string>(handler.pipelineKeyRequests ?? []);\n return {\n requestPipelineKeys: async (resourceType, remoteKeys) => {\n // assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — a handler reaches only the pipelines it declared.\n if (!declared.has(resourceType)) {\n throw Object.assign(new Error(`Inbound handler '${handler.ref}' did not declare '${resourceType}' in pipelineKeyRequests, so it cannot ask that pipeline to re-read records.`),\n { name: 'InboundPipelineKeyRequestUndeclared' });\n }\n if (!this.pipelineKeyRequests) {\n throw Object.assign(new Error('No pipeline key-request door is bound in this process, so no pipeline can be asked to re-read records from an inbound delivery.'),\n { name: 'InboundPipelineKeyRequestUnavailable' });\n }\n return this.pipelineKeyRequests.requestPipelineKeys({ resourceType, remoteKeys, inboundDeliveryId: deliveryId });\n },\n };\n }\n\n /**\n * The handler's whole world: its authority is the declared roles in the delivery's ONE scope, reached\n * through `resources`. The handler has no actor call of its own (I10), and an agent turn never runs with its roles: it\n * goes through `agents`, the autonomous entry point (#1611), under the principal the organization granted that agent\n * and with a reviewer for a proposed side effect; or, for a message a member wrote to the bot, through\n * `chat.converse()`, as that member (#2665).\n */\n private async buildHandlerContext(row: InboundDeliveryRow, handler: AnyInboundHandlerDefinition, chatDoor: InboundChatDoorRecord): Promise<InboundHandlerContext> {\n const scope = row.resolvedScope;\n if (scope.kind === InboundResolvedScopeKind.UNROUTABLE) {\n throw Object.assign(new Error('An unroutable delivery has no scope to run in'), { name: 'InboundDeliveryUnroutable' });\n }\n const initiatorRoles = inboundHandlerInitiatorRoles(handler.actingRoles, scope);\n // The relationship the delivery turns out to be the act of (#2722): set by the chat door once it names the member.\n const provenance: InboundDeliveryProvenance = {};\n\n // assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — the handler acts with the roles it declares, in the one scope its delivery resolved to.\n const executionContext = await this.executionContextCreator.createForInboundDelivery({\n inboundDeliveryId: String(row._id),\n inboundHandlerRef: row.handlerRef,\n // Every act of the handler names the delivery it came through (#2665): `arrivedThrough` on each audit row.\n inboundSourceKey: row.sourceKey,\n ...(scope.kind === InboundResolvedScopeKind.ORGANIZATION\n ? { organizationId: scope.organizationId, contextResourcesFieldIdentifier: new Map([['organizationId', scope.organizationId]]) }\n : {}),\n ...(scope.kind === InboundResolvedScopeKind.USER\n ? { scopeUserId: scope.userId, contextResourcesFieldIdentifier: new Map([['userId', scope.userId]]) }\n : {}),\n // assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — the sender is recorded for identification; the roles above are the whole authority, whatever the assurance (#1630, I8).\n inboundSender: { channel: row.channel, assurance: row.senderAssurance },\n initiatorRoles,\n });\n\n const context: InboundHandlerContext = {\n delivery: {\n id: String(row._id),\n handlerRef: handler.ref,\n sourceKey: row.sourceKey,\n receivedAt: row.receivedAt,\n ...(row.providerDeliveryId !== undefined ? { providerDeliveryId: row.providerDeliveryId } : {}),\n // Within the current retry budget, so the first attempt after a replay is 1 again.\n attempt: row.attemptCount - row.budgetBaseAttemptCount,\n scope: scope.kind === InboundResolvedScopeKind.ORGANIZATION\n ? { kind: InboundResolvedScopeKind.ORGANIZATION, organizationId: scope.organizationId }\n : scope.kind === InboundResolvedScopeKind.USER\n ? { kind: InboundResolvedScopeKind.USER, userId: scope.userId }\n : { kind: InboundResolvedScopeKind.APPLICATION },\n },\n resources: this.buildResources(executionContext, provenance, scope.kind === InboundResolvedScopeKind.ORGANIZATION ? scope.organizationId : undefined),\n agents: this.buildAgents(String(row._id), row.sourceKey, scope.kind === InboundResolvedScopeKind.ORGANIZATION ? scope.organizationId : undefined),\n pipelines: this.buildPipelines(String(row._id), handler),\n chat: this.buildChat(row, handler, provenance, chatDoor, executionContext),\n providers: this.buildProviders(executionContext),\n };\n if (!engineInboundHandlerCapabilityOf(handler)) return context;\n // The engine door (#1629): the same authorization as `resources`, admitting INTERNAL_CALL too. Only a handler\n // carrying the engine capability — which application code cannot declare — receives it.\n const engine: InboundEngineOperationAccess = {\n authorize: (resourceType, operation, id) => authorizeInboundSubCall(this.authorizationDeps, executionContext, resourceType, operation, id, ENGINE_HANDLER_OPERATION_VARIANTS),\n };\n const engineContext: EngineInboundHandlerContext = { ...context, engine };\n return engineContext;\n }\n\n /**\n * `ctx.providers` (#2664): the executor bound to the delivery's own context, so the connection target is authorized\n * by the same rule as an HTTP caller's (`ConnectionTargetAuthorizationPort`). That context's only organization entry\n * is the delivery's organization, organization-wide, and it carries no authenticated user, so it may spend the\n * application's connection, that organization's, and no person's (see `InboundHandlerContext.providers`).\n */\n private buildProviders(executionContext: ExecutionContext<any>): InboundHandlerContext['providers'] {\n return async (providerRef, operationId, input, connection) => {\n if (!this.providerOperations) {\n throw Object.assign(new Error('No provider operation executor is bound in this process, so no provider operation can be called from an inbound delivery.'),\n { name: 'InboundProviderOperationsUnavailable' });\n }\n return this.providerOperations.forExecution(executionContext)(providerRef, operationId, input, connection);\n };\n }\n\n /** Every call is a sub-context of the delivery's context, authorized as at the controller, then run. */\n /**\n * `ctx.resources`: the handler's declared roles, in the delivery's one scope. Its writes run inside the relationship the\n * delivery turned out to be the act of, when it is one (#2722): a representative's linked chat account. The handler acts\n * on the framework's own delegated context, which takes a new record's provenance from that frame\n * (`takesRelationshipProvenanceFromFrame`); with none set, the frame the handler already runs in is left as it is (a\n * channel thread's, `InboundChannelRuntimeBackendService.run`).\n */\n private buildResources(executionContext: ExecutionContext<any>, provenance: InboundDeliveryProvenance, organizationId: string | undefined): InboundHandlerContext['resources'] {\n const authorized = (resourceType: ResourceType, operation: string, id?: string) =>\n authorizeInboundSubCall(this.authorizationDeps, executionContext, resourceType, operation, id, APPLICATION_HANDLER_OPERATION_VARIANTS);\n const inRelationship = <T>(fn: () => Promise<T>): Promise<T> => (provenance.relationshipId && organizationId\n ? runWithRelationshipProvenanceFrame({ organizationId, relationshipId: provenance.relationshipId }, fn)\n : fn());\n return {\n create: async <T>(resourceType: ResourceType, data: unknown) =>\n inRelationship(async () => this.servicesRegistry.create<T>(resourceType, await authorized(resourceType, CoreResourceOperation.CREATE), data)),\n read: async <T>(resourceType: ResourceType, id: string) =>\n this.servicesRegistry.read<T>(resourceType, await authorized(resourceType, CoreResourceOperation.READ, id), id),\n list: async <T>(resourceType: ResourceType, filter?: Record<string, unknown>, pagination?: Parameters<ServicesRegistryHandlerBackendService['list']>[3]) =>\n this.servicesRegistry.list<T>(resourceType, await authorized(resourceType, CoreResourceOperation.LIST), filter, pagination),\n update: async <T>(resourceType: ResourceType, id: string, data: unknown) =>\n inRelationship(async () => this.servicesRegistry.update<T>(resourceType, await authorized(resourceType, CoreResourceOperation.UPDATE, id), id, data)),\n delete: async <T>(resourceType: ResourceType, id: string) =>\n this.servicesRegistry.delete<T>(resourceType, await authorized(resourceType, CoreResourceOperation.DELETE, id), id),\n executeCustomOperation: async <T>(resourceType: ResourceType, operation: string, id?: string, data?: unknown) =>\n inRelationship(async () => this.servicesRegistry.executeCustomOperation<T>(resourceType, operation, await authorized(resourceType, operation, id), id, data)),\n };\n }\n}\n"]}
@@ -10,6 +10,7 @@ import type { RateLimitBackendService } from '../../errors/services/rate-limit.b
10
10
  import { type AnyInboundHandlerDefinition } from '../../inbound/models/inbound-handler.backend.definitions';
11
11
  import type { InboundApplicationEndpoint, InboundHandlerRegistryBackendService } from './inbound-handler-registry.backend.service';
12
12
  import { type InboundDeliveryStoreBackendService } from './inbound-delivery-store.backend.service';
13
+ import { type InboundDeliveryStoredBodyBackendService } from './inbound-delivery-stored-body.backend.service';
13
14
  import type { ChatIdentityLinkBackendService } from './chat-identity-link.backend.service';
14
15
  import { type ChatSearchLaneBackendService } from '../../inbound/chat-commands/chat-search-lane.backend.service';
15
16
  import { type ChatCommandFormLaneBackendService } from '../../inbound/chat-commands/chat-command-form-lane.backend.service';
@@ -76,6 +77,11 @@ export declare class InboundDeliveryReceiverBackendService {
76
77
  private readonly rateLimits?;
77
78
  /** #2770: where a chat command's form is opened while the person waits. Optional: without it every command runs as typed. */
78
79
  private readonly chatCommandFormLane?;
80
+ /**
81
+ * #3395: where a body larger than a delivery row is written. Optional: without it such a body is refused 413, as it
82
+ * was before bodies could be stored outside the row.
83
+ */
84
+ private readonly storedBodies?;
79
85
  private readonly audit;
80
86
  constructor(logger: LoggerService, registry: InboundHandlerRegistryBackendService, store: InboundDeliveryStoreBackendService, repositoriesRegistry: Pick<RepositoriesRegistryHandlerBackendService, 'findManyForInfrastructure' | 'readUnscopedByKey'>, resourcesRegistry: Pick<ResourcesRegistryBackendService, 'getResourceConfiguration'>,
81
87
  /**
@@ -92,7 +98,12 @@ export declare class InboundDeliveryReceiverBackendService {
92
98
  /** #2909: the per-endpoint limit of a re-read trigger. Absent, every such notification is dropped (fail closed). */
93
99
  rateLimits?: Pick<RateLimitBackendService, 'checkPolicyForSubject'>,
94
100
  /** #2770: where a chat command's form is opened while the person waits. Optional: without it every command runs as typed. */
95
- chatCommandFormLane?: Pick<ChatCommandFormLaneBackendService, 'open'>);
101
+ chatCommandFormLane?: Pick<ChatCommandFormLaneBackendService, 'open'>,
102
+ /**
103
+ * #3395: where a body larger than a delivery row is written. Optional: without it such a body is refused 413, as it
104
+ * was before bodies could be stored outside the row.
105
+ */
106
+ storedBodies?: Pick<InboundDeliveryStoredBodyBackendService, 'write' | 'discard'>);
96
107
  /** The clock; a property so tests can pin time without DI trying to inject it. */
97
108
  clock: () => Date;
98
109
  receiveApplicationEndpoint(endpoint: InboundApplicationEndpoint, request: InboundRawRequest): Promise<InboundReceiveAnswer>;
@@ -1 +1 @@
1
- {"version":3,"file":"inbound-delivery-receiver.backend.service.d.ts","sourceRoot":"","sources":["../../../../src/inbound/services/inbound-delivery-receiver.backend.service.ts"],"names":[],"mappings":"AAwDA,OAAO,EAKL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAMnB,MAAM,sCAAsC,CAAC;AAI9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAC;AAClG,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,qGAAqG,CAAC;AACrK,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,0EAA0E,CAAC;AAChI,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,+EAA+E,CAAC;AACvI,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gFAAgF,CAAC;AAC9H,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,EAA2D,KAAK,4BAA4B,EAAE,MAAM,oFAAoF,CAAC;AAEhM,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+DAA+D,CAAC;AAG7G,OAAO,EAIL,KAAK,2BAA2B,EAIjC,MAAM,uEAAuE,CAAC;AAG/E,OAAO,KAAK,EAAE,0BAA0B,EAAE,oCAAoC,EAAE,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