@wildo-ai/saas-backend-lib 1.1.3 → 1.1.4

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 (1056) hide show
  1. package/dist/esm/__tests__/fixture-deep-partial.d.ts.map +1 -1
  2. package/dist/esm/__tests__/integration/redis-integration-gate.d.ts.map +1 -1
  3. package/dist/esm/__tests__/setup.d.ts.map +1 -1
  4. package/dist/esm/__tests__/test-container.d.ts.map +1 -1
  5. package/dist/esm/applications/models/applications.backend.schemas.d.ts.map +1 -1
  6. package/dist/esm/applications/seeds/application-metadata-defaults.seeds.d.ts.map +1 -1
  7. package/dist/esm/applications/services/worker-remote-client-factory.backend.service.d.ts.map +1 -1
  8. package/dist/esm/applications/services/worker-remote-client-factory.backend.service.js.map +1 -1
  9. package/dist/esm/base-classes/models/manual-controllers.backend.definition.d.ts.map +1 -1
  10. package/dist/esm/base-classes/models/manual-controllers.backend.definition.js.map +1 -1
  11. package/dist/esm/base-classes/models/repositories.backend.schemas.d.ts.map +1 -1
  12. package/dist/esm/base-classes/services/__tests__/mock-resource-operation-helper.service.d.ts +1 -1
  13. package/dist/esm/base-classes/services/__tests__/mock-resource-operation-helper.service.d.ts.map +1 -1
  14. package/dist/esm/base-classes/services/batches/batches-cronjobs-custom-execution.service.d.ts.map +1 -1
  15. package/dist/esm/base-classes/services/batches/batches-cronjobs-executor.backend.service.d.ts.map +1 -1
  16. package/dist/esm/base-classes/services/batches/batches-cronjobs-resource-execution.backend.service.d.ts.map +1 -1
  17. package/dist/esm/base-classes/services/batches/child-lifecycle-teardown.batch.backend.service.d.ts.map +1 -1
  18. package/dist/esm/base-classes/services/batches/child-lifecycle-teardown.batch.backend.service.js.map +1 -1
  19. package/dist/esm/base-classes/services/batches/credential-expiry-sweep.batch.backend.service.d.ts.map +1 -1
  20. package/dist/esm/base-classes/services/batches/credential-expiry-sweep.batch.backend.service.js +12 -1
  21. package/dist/esm/base-classes/services/batches/credential-expiry-sweep.batch.backend.service.js.map +1 -1
  22. package/dist/esm/base-classes/services/batches/engine-custom-batch-manifests.d.ts.map +1 -1
  23. package/dist/esm/base-classes/services/batches/engine-custom-batch-manifests.js.map +1 -1
  24. package/dist/esm/base-classes/services/batches/resource-retention-sweep.batch.backend.service.d.ts.map +1 -1
  25. package/dist/esm/base-classes/services/batches/suspension-reactivation-sweep.batch.backend.service.d.ts.map +1 -1
  26. package/dist/esm/base-classes/services/controllers/abstract-controller.backend.service.d.ts.map +1 -1
  27. package/dist/esm/base-classes/services/controllers/controller-resource.backend.service.d.ts.map +1 -1
  28. package/dist/esm/base-classes/services/controllers/controller-resource.backend.service.js.map +1 -1
  29. package/dist/esm/base-classes/services/controllers/controllers-registry-handler.backend.service.d.ts.map +1 -1
  30. package/dist/esm/base-classes/services/controllers/controllers-registry-handler.backend.service.js.map +1 -1
  31. package/dist/esm/base-classes/services/controllers/utils/audit-access-fields.backend.utils.d.ts.map +1 -1
  32. package/dist/esm/base-classes/services/controllers/utils/operation-response-serializer.backend.utils.d.ts.map +1 -1
  33. package/dist/esm/base-classes/services/controllers/validate-field-handler.backend.service.d.ts.map +1 -1
  34. package/dist/esm/base-classes/services/repositories/__tests__/method-span-scan.guard-helpers.d.ts.map +1 -1
  35. package/dist/esm/base-classes/services/repositories/__tests__/mock-repositories-registry-handler.service.d.ts.map +1 -1
  36. package/dist/esm/base-classes/services/repositories/field-clearing-partition.backend.d.ts.map +1 -1
  37. package/dist/esm/base-classes/services/repositories/http-api/http-api-filter-translation.backend.d.ts.map +1 -1
  38. package/dist/esm/base-classes/services/repositories/http-api/http-api-provider-access.backend.d.ts.map +1 -1
  39. package/dist/esm/base-classes/services/repositories/http-api/http-api-provider-access.backend.js +13 -4
  40. package/dist/esm/base-classes/services/repositories/http-api/http-api-provider-access.backend.js.map +1 -1
  41. package/dist/esm/base-classes/services/repositories/http-api/http-api-query.backend.d.ts.map +1 -1
  42. package/dist/esm/base-classes/services/repositories/http-api/http-api-read-client.backend.d.ts.map +1 -1
  43. package/dist/esm/base-classes/services/repositories/http-api/http-api-read-client.backend.js +17 -0
  44. package/dist/esm/base-classes/services/repositories/http-api/http-api-read-client.backend.js.map +1 -1
  45. package/dist/esm/base-classes/services/repositories/http-api/http-api-resource-repository.backend.service.d.ts.map +1 -1
  46. package/dist/esm/base-classes/services/repositories/http-api/http-api-resource-repository.backend.service.js.map +1 -1
  47. package/dist/esm/base-classes/services/repositories/http-api/http-api-rest-operation-reference.backend.d.ts.map +1 -1
  48. package/dist/esm/base-classes/services/repositories/http-api/http-api-rest-operation-reference.backend.js.map +1 -1
  49. package/dist/esm/base-classes/services/repositories/http-api/http-api-row-projection.backend.d.ts.map +1 -1
  50. package/dist/esm/base-classes/services/repositories/http-api/http-api-subject-erasure-effect.backend.d.ts.map +1 -1
  51. package/dist/esm/base-classes/services/repositories/http-api/http-api-transport.backend.d.ts.map +1 -1
  52. package/dist/esm/base-classes/services/repositories/http-api/http-api-transport.backend.js.map +1 -1
  53. package/dist/esm/base-classes/services/repositories/http-api/odata-query-compiler.backend.d.ts.map +1 -1
  54. package/dist/esm/base-classes/services/repositories/http-api/odoo-jsonrpc-compiler.backend.d.ts.map +1 -1
  55. package/dist/esm/base-classes/services/repositories/http-api/rest-json-query-compiler.backend.d.ts.map +1 -1
  56. package/dist/esm/base-classes/services/repositories/infrastructure-tier-contract.backend.d.ts.map +1 -1
  57. package/dist/esm/base-classes/services/repositories/infrastructure-tier-contract.backend.js.map +1 -1
  58. package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-repository.backend.service.d.ts.map +1 -1
  59. package/dist/esm/base-classes/services/repositories/introspection/introspection-resource-source.backend.port.d.ts.map +1 -1
  60. package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.d.ts +57 -0
  61. package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.d.ts.map +1 -1
  62. package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.js +95 -2
  63. package/dist/esm/base-classes/services/repositories/postgresql-resource-repository.backend.service.js.map +1 -1
  64. package/dist/esm/base-classes/services/repositories/repositories-registry-handler.backend.service.d.ts.map +1 -1
  65. package/dist/esm/base-classes/services/repositories/repositories-registry-handler.backend.service.js.map +1 -1
  66. package/dist/esm/base-classes/services/repositories/repository-guarded-mutation.backend.types.d.ts.map +1 -1
  67. package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.d.ts +5 -2
  68. package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.d.ts.map +1 -1
  69. package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.js +14 -3
  70. package/dist/esm/base-classes/services/repositories/repository-resource.backend.service.js.map +1 -1
  71. package/dist/esm/base-classes/services/repositories/repository-version-metadata.backend.utils.d.ts.map +1 -1
  72. package/dist/esm/base-classes/services/repositories/resource-write-integrity.backend.d.ts.map +1 -1
  73. package/dist/esm/base-classes/services/repositories/seed-row-default-materialization.backend.d.ts +72 -0
  74. package/dist/esm/base-classes/services/repositories/seed-row-default-materialization.backend.d.ts.map +1 -0
  75. package/dist/esm/base-classes/services/repositories/seed-row-default-materialization.backend.js +88 -0
  76. package/dist/esm/base-classes/services/repositories/seed-row-default-materialization.backend.js.map +1 -0
  77. package/dist/esm/base-classes/services/repositories/unique-constraint-conflict-reference.backend.d.ts.map +1 -1
  78. package/dist/esm/base-classes/services/resource-operations-helper.backend.service.d.ts.map +1 -1
  79. package/dist/esm/base-classes/services/services/__tests__/mock-services-registry-handler.service.d.ts.map +1 -1
  80. package/dist/esm/base-classes/services/services/__tests__/mock-system-access.service.d.ts.map +1 -1
  81. package/dist/esm/base-classes/services/services/read-only-field-change.backend.utils.d.ts.map +1 -1
  82. package/dist/esm/base-classes/services/services/resource-operation-audit-emission.backend.utils.d.ts.map +1 -1
  83. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-base.backend.service.d.ts.map +1 -1
  84. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-base.backend.service.js.map +1 -1
  85. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation-registry.backend.service.d.ts.map +1 -1
  86. package/dist/esm/base-classes/services/services/resource-operation-custom-implementation.factory.backend.d.ts.map +1 -1
  87. package/dist/esm/base-classes/services/services/resource-operation-implementation-coverage.backend.utils.d.ts.map +1 -1
  88. package/dist/esm/base-classes/services/services/resource-operation-server-injected-fields.backend.utils.d.ts.map +1 -1
  89. package/dist/esm/base-classes/services/services/resource-operation-transaction-persistence.backend.utils.d.ts.map +1 -1
  90. package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.d.ts.map +1 -1
  91. package/dist/esm/base-classes/services/services/resource-status-transition.custom-impl.backend.service.js.map +1 -1
  92. package/dist/esm/base-classes/services/services/resource-status-transition.definitions.backend.d.ts.map +1 -1
  93. package/dist/esm/base-classes/services/services/resource-status-transition.definitions.backend.js.map +1 -1
  94. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.d.ts.map +1 -1
  95. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.js +44 -6
  96. package/dist/esm/base-classes/services/services/services-registry-handler.backend.service.js.map +1 -1
  97. package/dist/esm/base-classes/services/services/system-access.backend.service.d.ts.map +1 -1
  98. package/dist/esm/base-classes/services/services/system-access.backend.service.js.map +1 -1
  99. package/dist/esm/base-classes/utils/backend-type-utils.d.ts.map +1 -1
  100. package/dist/esm/base-classes/utils/single-subject-addressing.backend.utils.d.ts.map +1 -1
  101. package/dist/esm/billing/batches/billing-reconciliation.batch.backend.service.d.ts.map +1 -1
  102. package/dist/esm/billing/batches/billing-reconciliation.batch.backend.service.js.map +1 -1
  103. package/dist/esm/billing/batches/usage-flush.batch.backend.service.d.ts.map +1 -1
  104. package/dist/esm/billing/batches/usage-flush.batch.backend.service.js.map +1 -1
  105. package/dist/esm/billing/models/billing-provider-event-settlement.backend.schemas.d.ts.map +1 -1
  106. package/dist/esm/billing/models/billing-provider-event-settlement.backend.schemas.js.map +1 -1
  107. package/dist/esm/billing/services/back-office/abstract-billing.backend.service.d.ts.map +1 -1
  108. package/dist/esm/billing/services/back-office/billing-feature-sync.backend.service.d.ts.map +1 -1
  109. package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.d.ts +1 -1
  110. package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.d.ts.map +1 -1
  111. package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.js +5 -4
  112. package/dist/esm/billing/services/back-office/billing-reconciliation.backend.service.js.map +1 -1
  113. package/dist/esm/billing/services/back-office/billing-state.backend.service.d.ts.map +1 -1
  114. package/dist/esm/billing/services/back-office/billing-state.backend.service.js +11 -1
  115. package/dist/esm/billing/services/back-office/billing-state.backend.service.js.map +1 -1
  116. package/dist/esm/billing/services/back-office/billing-subject-erasure-effect.backend.d.ts.map +1 -1
  117. package/dist/esm/billing/services/back-office/product-catalog-sync.backend.service.d.ts.map +1 -1
  118. package/dist/esm/billing/services/back-office/product-catalog-sync.backend.service.js.map +1 -1
  119. package/dist/esm/billing/services/back-office/usage-metering.backend.service.d.ts.map +1 -1
  120. package/dist/esm/billing/services/back-office/usage-metering.backend.service.js.map +1 -1
  121. package/dist/esm/billing/services/billing-adapter-registry.backend.d.ts.map +1 -1
  122. package/dist/esm/billing/services/billing-adapter-registry.backend.js.map +1 -1
  123. package/dist/esm/billing/services/billing-checkout-metadata.backend.utils.d.ts.map +1 -1
  124. package/dist/esm/billing/services/billing-checkout-metadata.backend.utils.js.map +1 -1
  125. package/dist/esm/billing/services/billing.utils.d.ts.map +1 -1
  126. package/dist/esm/billing/services/custom-impl/billing-account.mutations.custom-impl.backend.service.d.ts.map +1 -1
  127. package/dist/esm/billing/services/custom-impl/billing-account.mutations.custom-impl.backend.service.js.map +1 -1
  128. package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.d.ts +32 -0
  129. package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.d.ts.map +1 -1
  130. package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.js +32 -1
  131. package/dist/esm/billing/services/custom-impl/billing-custom-impl-utils.backend.js.map +1 -1
  132. package/dist/esm/billing/services/custom-impl/billing-custom-implementations.backend.d.ts.map +1 -1
  133. package/dist/esm/billing/services/custom-impl/billing-custom-implementations.backend.js.map +1 -1
  134. package/dist/esm/billing/services/custom-impl/credit-pool.custom-ops.custom-impl.backend.service.d.ts.map +1 -1
  135. package/dist/esm/billing/services/custom-impl/promotion.custom-ops.custom-impl.backend.service.d.ts.map +1 -1
  136. package/dist/esm/billing/services/custom-impl/promotion.custom-ops.custom-impl.backend.service.js.map +1 -1
  137. package/dist/esm/billing/services/custom-impl/subscription.mutations.custom-impl.backend.service.d.ts.map +1 -1
  138. package/dist/esm/billing/services/custom-impl/subscription.mutations.custom-impl.backend.service.js.map +1 -1
  139. package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.d.ts +9 -6
  140. package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.d.ts.map +1 -1
  141. package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.js +9 -6
  142. package/dist/esm/billing/services/stripe-standard-billing-provider.backend.service.js.map +1 -1
  143. package/dist/esm/billing/services/webhooks/__tests__/settlement-ledger.test-double.d.ts.map +1 -1
  144. package/dist/esm/billing/services/webhooks/__tests__/settlement-ledger.test-double.js.map +1 -1
  145. package/dist/esm/billing/services/webhooks/billing-webhook-adapter.backend.service.d.ts.map +1 -1
  146. package/dist/esm/billing/services/webhooks/billing-webhook-capability-handler.backend.service.d.ts.map +1 -1
  147. package/dist/esm/billing/services/webhooks/billing-webhook-event-router.backend.service.d.ts.map +1 -1
  148. package/dist/esm/billing/services/webhooks/billing-webhook-event-router.backend.service.js +50 -3
  149. package/dist/esm/billing/services/webhooks/billing-webhook-event-router.backend.service.js.map +1 -1
  150. package/dist/esm/billing/testing/billing-test-fixtures.d.ts.map +1 -1
  151. package/dist/esm/billing/testing/mock-billing-provider.d.ts.map +1 -1
  152. package/dist/esm/billing/testing/mock-billing-provider.js.map +1 -1
  153. package/dist/esm/charts/controllers/chart.backend.controller.d.ts.map +1 -1
  154. package/dist/esm/charts/services/chart-registry.backend.service.d.ts +80 -7
  155. package/dist/esm/charts/services/chart-registry.backend.service.d.ts.map +1 -1
  156. package/dist/esm/charts/services/chart-registry.backend.service.js +115 -8
  157. package/dist/esm/charts/services/chart-registry.backend.service.js.map +1 -1
  158. package/dist/esm/companion-exports.d.ts.map +1 -1
  159. package/dist/esm/compliance/audit-trails/audit-logs.custom-impl.backend.service.d.ts.map +1 -1
  160. package/dist/esm/compliance/audit-trails/batches/audit-logs-archive.batch.backend.service.d.ts.map +1 -1
  161. package/dist/esm/compliance/audit-trails/batches/audit-logs-archive.batch.backend.service.js.map +1 -1
  162. package/dist/esm/compliance/audit-trails/batches/immudb-audit-reconcile.batch.backend.service.d.ts.map +1 -1
  163. package/dist/esm/compliance/audit-trails/batches/siem-webhook-delivery.batch.backend.service.d.ts.map +1 -1
  164. package/dist/esm/compliance/audit-trails/services/__tests__/mock-audit-logs.service.d.ts.map +1 -1
  165. package/dist/esm/compliance/audit-trails/services/audit-event-dispatcher.backend.service.d.ts.map +1 -1
  166. package/dist/esm/compliance/audit-trails/services/audit-event-dispatcher.backend.service.js.map +1 -1
  167. package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.d.ts +107 -4
  168. package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.d.ts.map +1 -1
  169. package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.js +176 -5
  170. package/dist/esm/compliance/audit-trails/services/audit-logs.backend.service.js.map +1 -1
  171. package/dist/esm/compliance/audit-trails/services/composite-audit-log-sink.backend.d.ts.map +1 -1
  172. package/dist/esm/compliance/audit-trails/services/composite-audit-log-sink.backend.js.map +1 -1
  173. package/dist/esm/compliance/audit-trails/services/siem-export-config-cache-invalidation.custom-impl.backend.service.d.ts.map +1 -1
  174. package/dist/esm/compliance/audit-trails/services/siem-export-config-cache-invalidation.custom-impl.backend.service.js.map +1 -1
  175. package/dist/esm/compliance/audit-trails/services/siem-webhook-delivery.backend.service.d.ts.map +1 -1
  176. package/dist/esm/compliance/audit-trails/services/siem-webhook-delivery.backend.service.js.map +1 -1
  177. package/dist/esm/compliance/audit-trails/services/utils/leased-value-cache.backend.utils.d.ts.map +1 -1
  178. package/dist/esm/compliance/audit-trails/services/utils/leased-value-cache.backend.utils.js.map +1 -1
  179. package/dist/esm/compliance/audit-trails/services/utils/ocsf-activity-mapping.backend.utils.d.ts.map +1 -1
  180. package/dist/esm/compliance/audit-trails/services/utils/ocsf-activity-mapping.backend.utils.js +21 -0
  181. package/dist/esm/compliance/audit-trails/services/utils/ocsf-activity-mapping.backend.utils.js.map +1 -1
  182. package/dist/esm/compliance/audit-trails/services/utils/ocsf-class-mapping.backend.utils.d.ts.map +1 -1
  183. package/dist/esm/compliance/audit-trails/services/utils/siem-dictionary.backend.utils.d.ts.map +1 -1
  184. package/dist/esm/compliance/audit-trails/services/utils/siem-ocsf-projection.backend.utils.d.ts.map +1 -1
  185. package/dist/esm/compliance/audit-trails/services/utils/siem-projection-contract.backend.utils.d.ts.map +1 -1
  186. package/dist/esm/compliance/audit-trails/utils/audit-actor.backend.utils.d.ts.map +1 -1
  187. package/dist/esm/compliance/audit-trails/utils/layer2-audit-provider-boot-diagnostic.backend.utils.d.ts.map +1 -1
  188. package/dist/esm/compliance/index.d.ts.map +1 -1
  189. package/dist/esm/compliance/privacy/retention-hide-predicate.backend.d.ts.map +1 -1
  190. package/dist/esm/compliance/privacy/services/subject-erasure-external-effects.backend.service.d.ts.map +1 -1
  191. package/dist/esm/compliance/privacy/services/subject-session-revocation.backend.service.d.ts.map +1 -1
  192. package/dist/esm/config/bootstrap/application-runtime-profile.backend.d.ts.map +1 -1
  193. package/dist/esm/config/bootstrap/application-runtime-profile.backend.js.map +1 -1
  194. package/dist/esm/config/bootstrap/minion-initialization-projection.backend.d.ts.map +1 -1
  195. package/dist/esm/config/bootstrap/runtime-principal-attestation.backend.service.d.ts.map +1 -1
  196. package/dist/esm/config/bootstrap/runtime-principal-attestation.backend.service.js +3 -0
  197. package/dist/esm/config/bootstrap/runtime-principal-attestation.backend.service.js.map +1 -1
  198. package/dist/esm/config/bootstrap/runtime-principal.backend.service.d.ts.map +1 -1
  199. package/dist/esm/config/custom/application-config-controller.backend.service.d.ts.map +1 -1
  200. package/dist/esm/config/models/app-config-secrets.backend.schemas.d.ts.map +1 -1
  201. package/dist/esm/config/models/app-config.backend-authored.definitions.d.ts.map +1 -1
  202. package/dist/esm/config/models/app-config.backend.schemas.d.ts +4 -4
  203. package/dist/esm/config/models/app-config.backend.schemas.d.ts.map +1 -1
  204. package/dist/esm/config/models/app-config.backend.schemas.js.map +1 -1
  205. package/dist/esm/config/models/app-env-config.backend.schemas.d.ts.map +1 -1
  206. package/dist/esm/config/models/apps-manager-transport.backend.definitions.d.ts +36 -0
  207. package/dist/esm/config/models/apps-manager-transport.backend.definitions.d.ts.map +1 -0
  208. package/dist/esm/config/models/apps-manager-transport.backend.definitions.js +36 -0
  209. package/dist/esm/config/models/apps-manager-transport.backend.definitions.js.map +1 -0
  210. package/dist/esm/config/models/config-mutation-boundary.utils.d.ts.map +1 -1
  211. package/dist/esm/config/models/postgresql-env-config.backend.schemas.d.ts.map +1 -1
  212. package/dist/esm/config/models/provider-runtime-artifact.backend.schemas.d.ts.map +1 -1
  213. package/dist/esm/config/models/provider-runtime-artifact.backend.schemas.js.map +1 -1
  214. package/dist/esm/config/models/runtime-topology.backend.contracts.d.ts.map +1 -1
  215. package/dist/esm/config/services/__tests__/mock-app-configuration.service.d.ts.map +1 -1
  216. package/dist/esm/config/services/app-configuration-loader.backend.service.d.ts.map +1 -1
  217. package/dist/esm/config/services/app-configuration-loader.backend.service.js +3 -0
  218. package/dist/esm/config/services/app-configuration-loader.backend.service.js.map +1 -1
  219. package/dist/esm/config/services/app-configuration.backend.service.d.ts.map +1 -1
  220. package/dist/esm/config/services/app-configuration.backend.service.js.map +1 -1
  221. package/dist/esm/config/services/app-configuration.backend.utils.d.ts.map +1 -1
  222. package/dist/esm/config/services/app-configuration.backend.utils.js.map +1 -1
  223. package/dist/esm/config/services/application-startup-config-validator.backend.service.d.ts +12 -0
  224. package/dist/esm/config/services/application-startup-config-validator.backend.service.d.ts.map +1 -1
  225. package/dist/esm/config/services/application-startup-config-validator.backend.service.js +28 -0
  226. package/dist/esm/config/services/application-startup-config-validator.backend.service.js.map +1 -1
  227. package/dist/esm/data-seeding/batches/data-seeding-run-cleanup.batch.backend.service.d.ts.map +1 -1
  228. package/dist/esm/data-seeding/batches/data-seeding-scheduled-rerun.batch.backend.service.d.ts.map +1 -1
  229. package/dist/esm/data-seeding/controllers/data-seeding-admin.backend.contracts.d.ts.map +1 -1
  230. package/dist/esm/data-seeding/controllers/data-seeding-admin.backend.controller.d.ts.map +1 -1
  231. package/dist/esm/data-seeding/data-seeding-models.d.ts.map +1 -1
  232. package/dist/esm/data-seeding/models/business-key-resolver.shared.utils.d.ts.map +1 -1
  233. package/dist/esm/data-seeding/models/data-seed-execution-context.shared.types.d.ts.map +1 -1
  234. package/dist/esm/data-seeding/models/data-seed-migrator-runner.shared.utils.d.ts.map +1 -1
  235. package/dist/esm/data-seeding/models/data-seed-reconciler.shared.utils.d.ts.map +1 -1
  236. package/dist/esm/data-seeding/models/data-seed-row-metadata.shared.schemas.d.ts.map +1 -1
  237. package/dist/esm/data-seeding/models/data-seed-row-metadata.shared.utils.d.ts.map +1 -1
  238. package/dist/esm/data-seeding/models/data-seed-run.shared.resources-config.schemas.d.ts.map +1 -1
  239. package/dist/esm/data-seeding/models/data-seed-run.shared.schemas.d.ts.map +1 -1
  240. package/dist/esm/data-seeding/models/data-seed-trigger-mode-matrix.shared.utils.d.ts.map +1 -1
  241. package/dist/esm/data-seeding/models/data-seed.shared.schemas.d.ts.map +1 -1
  242. package/dist/esm/data-seeding/services/data-seed-application-bootstrap.backend.d.ts.map +1 -1
  243. package/dist/esm/data-seeding/services/data-seed-dispatcher.backend.service.d.ts.map +1 -1
  244. package/dist/esm/data-seeding/services/data-seed-registry.backend.service.d.ts.map +1 -1
  245. package/dist/esm/data-seeding/services/data-seed-scope-resolver-registry.backend.service.d.ts.map +1 -1
  246. package/dist/esm/data-seeding/services/engines/additive-seed-engine.backend.service.d.ts.map +1 -1
  247. package/dist/esm/data-seeding/services/engines/lazy-seed-engine.backend.service.d.ts.map +1 -1
  248. package/dist/esm/data-seeding/services/engines/manual-seed-engine.backend.service.d.ts.map +1 -1
  249. package/dist/esm/data-seeding/services/engines/sync-seed-engine.backend.service.d.ts.map +1 -1
  250. package/dist/esm/data-seeding/services/engines/upgrade-seed-engine.backend.service.d.ts.map +1 -1
  251. package/dist/esm/data-seeding/services/shared/data-seed-business-key.shared.utils.d.ts.map +1 -1
  252. package/dist/esm/data-seeding/services/shared/data-seed-error.shared.utils.d.ts.map +1 -1
  253. package/dist/esm/data-seeding/services/shared/data-seed-run-counters.shared.types.d.ts.map +1 -1
  254. package/dist/esm/data-seeding/services/shared/data-seed-run-ledger.backend.d.ts.map +1 -1
  255. package/dist/esm/data-seeding/services/shared/data-seed-scope-anchor.shared.types.d.ts.map +1 -1
  256. package/dist/esm/data-seeding/services/shared/data-seed-scope-iteration.shared.utils.d.ts.map +1 -1
  257. package/dist/esm/data-seeding/services/shared/data-seed-scope-resolution.backend.d.ts.map +1 -1
  258. package/dist/esm/databases/models/aggregation.backend.schemas.d.ts.map +1 -1
  259. package/dist/esm/databases/models/databases.backend.schemas.d.ts.map +1 -1
  260. package/dist/esm/databases/models/filter.backend.schemas.d.ts.map +1 -1
  261. package/dist/esm/databases/models/resolve-persistence-adapter.backend.utils.d.ts.map +1 -1
  262. package/dist/esm/databases/models/sql.backend.schemas.d.ts.map +1 -1
  263. package/dist/esm/databases/models/transaction.shared.schemas.d.ts.map +1 -1
  264. package/dist/esm/databases/services/__tests__/mock-mongo-transaction-registry.service.d.ts.map +1 -1
  265. package/dist/esm/databases/services/__tests__/mock-mongodb.service.d.ts.map +1 -1
  266. package/dist/esm/databases/services/__tests__/mock-mongoose-model.service.d.ts.map +1 -1
  267. package/dist/esm/databases/services/__tests__/mock-redis.service.d.ts.map +1 -1
  268. package/dist/esm/databases/services/__tests__/mock-zod-mongoose-schema-convertor.service.d.ts.map +1 -1
  269. package/dist/esm/databases/services/aggregation/aggregation-authorization.backend.service.d.ts.map +1 -1
  270. package/dist/esm/databases/services/aggregation/aggregation-query.backend.service.d.ts.map +1 -1
  271. package/dist/esm/databases/services/aggregation/computed-measure-evaluator.backend.service.d.ts.map +1 -1
  272. package/dist/esm/databases/services/aggregation/field-access-validator.backend.service.d.ts.map +1 -1
  273. package/dist/esm/databases/services/aggregation/time-series-densifier.backend.service.d.ts.map +1 -1
  274. package/dist/esm/databases/services/aggregation/topn-processor.backend.service.d.ts.map +1 -1
  275. package/dist/esm/databases/services/aggregation/window-function-processor.backend.service.d.ts.map +1 -1
  276. package/dist/esm/databases/services/db-utils.d.ts.map +1 -1
  277. package/dist/esm/databases/services/mongo-aggregation.backend.service.d.ts.map +1 -1
  278. package/dist/esm/databases/services/mongodb.service.d.ts.map +1 -1
  279. package/dist/esm/databases/services/postgresql-aggregation.backend.service.d.ts.map +1 -1
  280. package/dist/esm/databases/services/postgresql-database.backend.service.d.ts.map +1 -1
  281. package/dist/esm/databases/services/postgresql-development-provisioning.backend.d.ts.map +1 -1
  282. package/dist/esm/databases/services/postgresql-filter.backend.service.d.ts.map +1 -1
  283. package/dist/esm/databases/services/postgresql-migration-runner.backend.d.ts.map +1 -1
  284. package/dist/esm/databases/services/postgresql-schema-ddl.backend.d.ts.map +1 -1
  285. package/dist/esm/databases/services/postgresql-schema-migration-sql.backend.d.ts.map +1 -1
  286. package/dist/esm/databases/services/postgresql-schema-plan-diff.backend.d.ts.map +1 -1
  287. package/dist/esm/databases/services/postgresql-schema-plan-diff.backend.js.map +1 -1
  288. package/dist/esm/databases/services/postgresql-schema-plan-lockfile.backend.d.ts.map +1 -1
  289. package/dist/esm/databases/services/redis.service.d.ts.map +1 -1
  290. package/dist/esm/databases/services/resource-persistence-unit-of-work.backend.service.d.ts.map +1 -1
  291. package/dist/esm/databases/services/schema-planning-standalone.backend.d.ts.map +1 -1
  292. package/dist/esm/databases/services/zod-to-mongoose-schema-convertor.backend.service.d.ts.map +1 -1
  293. package/dist/esm/databases/services/zod-to-sql-hybrid-schema.planner.d.ts.map +1 -1
  294. package/dist/esm/databases/utils/postgresql-identifier.backend.utils.d.ts.map +1 -1
  295. package/dist/esm/errors/services/__tests__/mock-error-builder.service.d.ts.map +1 -1
  296. package/dist/esm/errors/services/error-builder.backend.service.d.ts.map +1 -1
  297. package/dist/esm/errors/services/error-builder.backend.service.js.map +1 -1
  298. package/dist/esm/errors/services/error-handler.backend.service.d.ts.map +1 -1
  299. package/dist/esm/errors/services/error-handler.backend.service.js.map +1 -1
  300. package/dist/esm/errors/services/rate-limit.backend.service.d.ts.map +1 -1
  301. package/dist/esm/errors/services/rate-limit.backend.service.js.map +1 -1
  302. package/dist/esm/errors/utils/error-log-level-classification.backend.utils.d.ts.map +1 -1
  303. package/dist/esm/errors/utils/error-log-level-classification.backend.utils.js.map +1 -1
  304. package/dist/esm/errors/utils/rate-limit-environment-relaxation.backend.utils.d.ts.map +1 -1
  305. package/dist/esm/errors/utils/rate-limit-environment-relaxation.backend.utils.js.map +1 -1
  306. package/dist/esm/external-data/batches/external-data-pipeline-scheduled-run.batch.backend.service.d.ts.map +1 -1
  307. package/dist/esm/external-data/controllers/external-data-admin.backend.contracts.d.ts.map +1 -1
  308. package/dist/esm/external-data/controllers/external-data-admin.backend.controller.d.ts.map +1 -1
  309. package/dist/esm/external-data/external-data-extraction-source.backend.d.ts.map +1 -1
  310. package/dist/esm/external-data/external-data-models.exports.d.ts.map +1 -1
  311. package/dist/esm/external-data/external-data-pipeline-run.backend.service.d.ts.map +1 -1
  312. package/dist/esm/external-data/external-data-pipeline-run.backend.service.js.map +1 -1
  313. package/dist/esm/external-data/external-data-transform.backend.d.ts.map +1 -1
  314. package/dist/esm/external-data/models/external-data-pipeline-state.backend.schemas.d.ts.map +1 -1
  315. package/dist/esm/external-providers/models/external-providers.backend.schemas.d.ts.map +1 -1
  316. package/dist/esm/external-providers/models/provider-selection-resolution-evidence.backend.definitions.d.ts.map +1 -1
  317. package/dist/esm/external-providers/models/provider-selection-resolution-evidence.backend.definitions.js.map +1 -1
  318. package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.d.ts +102 -52
  319. package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.d.ts.map +1 -1
  320. package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.js +117 -71
  321. package/dist/esm/external-providers/operations/provider-operation-executor.backend.service.js.map +1 -1
  322. package/dist/esm/external-providers/operations/provider-operation-request.backend.d.ts.map +1 -1
  323. package/dist/esm/external-providers/operations/provider-operation-request.backend.js.map +1 -1
  324. package/dist/esm/external-providers/operations/provider-request-signing.backend.d.ts.map +1 -1
  325. package/dist/esm/external-providers/operations/provider-request-signing.backend.js +26 -7
  326. package/dist/esm/external-providers/operations/provider-request-signing.backend.js.map +1 -1
  327. package/dist/esm/external-providers/operations/provider-rest-call-client.backend.d.ts.map +1 -1
  328. package/dist/esm/external-providers/operations/provider-rest-call-client.backend.js.map +1 -1
  329. package/dist/esm/external-providers/services/__tests__/mock-external-providers-registry.service.d.ts.map +1 -1
  330. package/dist/esm/external-providers/services/__tests__/mock-external-providers-registry.service.js.map +1 -1
  331. package/dist/esm/external-providers/services/backend-provider-loader.backend.service.d.ts.map +1 -1
  332. package/dist/esm/external-providers/services/backend-provider-loader.backend.service.js.map +1 -1
  333. package/dist/esm/external-providers/services/backend-provider-registry.backend.service.d.ts.map +1 -1
  334. package/dist/esm/external-providers/services/backend-provider-registry.backend.service.js.map +1 -1
  335. package/dist/esm/external-providers/services/document-extraction.backend.service.d.ts +81 -34
  336. package/dist/esm/external-providers/services/document-extraction.backend.service.d.ts.map +1 -1
  337. package/dist/esm/external-providers/services/document-extraction.backend.service.js +179 -98
  338. package/dist/esm/external-providers/services/document-extraction.backend.service.js.map +1 -1
  339. package/dist/esm/external-providers/services/embeddings.backend.service.d.ts.map +1 -1
  340. package/dist/esm/external-providers/services/embeddings.backend.service.js.map +1 -1
  341. package/dist/esm/external-providers/services/external-api-handler.backend.service.d.ts.map +1 -1
  342. package/dist/esm/external-providers/services/external-providers-registry.backend.service.d.ts +121 -0
  343. package/dist/esm/external-providers/services/external-providers-registry.backend.service.d.ts.map +1 -1
  344. package/dist/esm/external-providers/services/external-providers-registry.backend.service.js +151 -0
  345. package/dist/esm/external-providers/services/external-providers-registry.backend.service.js.map +1 -1
  346. package/dist/esm/external-providers/services/frontend-bootstrap.backend.service.d.ts +15 -1
  347. package/dist/esm/external-providers/services/frontend-bootstrap.backend.service.d.ts.map +1 -1
  348. package/dist/esm/external-providers/services/frontend-bootstrap.backend.service.js +60 -4
  349. package/dist/esm/external-providers/services/frontend-bootstrap.backend.service.js.map +1 -1
  350. package/dist/esm/features/controllers/features.backend.controller.d.ts.map +1 -1
  351. package/dist/esm/features/services/__tests__/mock-feature-definition-registry.service.d.ts.map +1 -1
  352. package/dist/esm/features/services/__tests__/mock-feature-resolution.service.d.ts.map +1 -1
  353. package/dist/esm/features/services/application-features-admin-write-path.custom-impl.backend.service.d.ts.map +1 -1
  354. package/dist/esm/features/services/feature-definition-registry.backend.service.d.ts.map +1 -1
  355. package/dist/esm/features/services/feature-gate.backend.service.d.ts.map +1 -1
  356. package/dist/esm/features/services/feature-resolution.backend.service.d.ts.map +1 -1
  357. package/dist/esm/features/services/organization-features-admin-write-path.custom-impl.backend.service.d.ts.map +1 -1
  358. package/dist/esm/features/services/scope-feature-ledger-relationship.backend.utils.d.ts.map +1 -1
  359. package/dist/esm/features/services/scope-features-cache-invalidation.custom-impl.backend.service.d.ts.map +1 -1
  360. package/dist/esm/features/testing/feature-test-utils.d.ts.map +1 -1
  361. package/dist/esm/files/batches/files-cleanup.batch.backend.service.d.ts.map +1 -1
  362. package/dist/esm/files/constraints/file-analyzers.types.d.ts.map +1 -1
  363. package/dist/esm/files/constraints/file-constraint-resolver-chain.backend.service.d.ts.map +1 -1
  364. package/dist/esm/files/constraints/file-constraint.types.d.ts.map +1 -1
  365. package/dist/esm/files/constraints/file-validation.backend.service.d.ts.map +1 -1
  366. package/dist/esm/files/constraints/resource-field-constraint-resolver.backend.service.d.ts.map +1 -1
  367. package/dist/esm/files/controllers/file.controller.d.ts.map +1 -1
  368. package/dist/esm/files/controllers/file.controller.js.map +1 -1
  369. package/dist/esm/files/handlers/file-upload-route-locals.backend.types.d.ts.map +1 -1
  370. package/dist/esm/files/handlers/file-upload-route-locals.backend.types.js.map +1 -1
  371. package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.d.ts +37 -0
  372. package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.d.ts.map +1 -1
  373. package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.js +221 -21
  374. package/dist/esm/files/handlers/resource-file-upload-handler.backend.service.js.map +1 -1
  375. package/dist/esm/files/scanning/clamav-scanner.backend.service.d.ts.map +1 -1
  376. package/dist/esm/files/scanning/file-scan.types.d.ts.map +1 -1
  377. package/dist/esm/files/scanning/yara-scanner.backend.service.d.ts.map +1 -1
  378. package/dist/esm/files/scanning/yara-scanner.backend.service.js +20 -2
  379. package/dist/esm/files/scanning/yara-scanner.backend.service.js.map +1 -1
  380. package/dist/esm/files/services/__tests__/mock-file-field-detection.service.d.ts.map +1 -1
  381. package/dist/esm/files/services/__tests__/mock-file-operation-handler.service.d.ts.map +1 -1
  382. package/dist/esm/files/services/__tests__/mock-file-repository.service.d.ts.map +1 -1
  383. package/dist/esm/files/services/file-field-detection.backend.service.d.ts.map +1 -1
  384. package/dist/esm/files/services/file-operation-handler.backend.service.d.ts.map +1 -1
  385. package/dist/esm/files/services/file-operation-handler.backend.service.js.map +1 -1
  386. package/dist/esm/files/services/file-population.backend.service.d.ts.map +1 -1
  387. package/dist/esm/files/services/file-scanning.backend.service.d.ts.map +1 -1
  388. package/dist/esm/files/services/file-scanning.backend.service.js +5 -0
  389. package/dist/esm/files/services/file-scanning.backend.service.js.map +1 -1
  390. package/dist/esm/files/services/file-text-extraction.backend.service.d.ts.map +1 -1
  391. package/dist/esm/files/services/file-text-extraction.backend.service.js +8 -5
  392. package/dist/esm/files/services/file-text-extraction.backend.service.js.map +1 -1
  393. package/dist/esm/files/services/file-upload-grant.backend.service.d.ts.map +1 -1
  394. package/dist/esm/files/services/file-upload-grant.backend.service.js.map +1 -1
  395. package/dist/esm/files/services/files.backend.service.d.ts.map +1 -1
  396. package/dist/esm/files/services/files.backend.service.js +3 -1
  397. package/dist/esm/files/services/files.backend.service.js.map +1 -1
  398. package/dist/esm/files/services/rag-source-field-detection.backend.service.d.ts.map +1 -1
  399. package/dist/esm/files/storage/application-storage-key.backend.utils.d.ts.map +1 -1
  400. package/dist/esm/files/storage/application-storage-key.backend.utils.js.map +1 -1
  401. package/dist/esm/files/storage/file-storage-path-resolver.backend.service.d.ts.map +1 -1
  402. package/dist/esm/files/storage/file-storage-provider.types.d.ts +36 -1
  403. package/dist/esm/files/storage/file-storage-provider.types.d.ts.map +1 -1
  404. package/dist/esm/files/storage/file-storage-provider.types.js.map +1 -1
  405. package/dist/esm/files/storage/file-storage-router.backend.service.d.ts +21 -3
  406. package/dist/esm/files/storage/file-storage-router.backend.service.d.ts.map +1 -1
  407. package/dist/esm/files/storage/file-storage-router.backend.service.js +38 -5
  408. package/dist/esm/files/storage/file-storage-router.backend.service.js.map +1 -1
  409. package/dist/esm/files/storage/google-drive-storage-provider.backend.service.d.ts +87 -0
  410. package/dist/esm/files/storage/google-drive-storage-provider.backend.service.d.ts.map +1 -0
  411. package/dist/esm/files/storage/google-drive-storage-provider.backend.service.js +340 -0
  412. package/dist/esm/files/storage/google-drive-storage-provider.backend.service.js.map +1 -0
  413. package/dist/esm/files/storage/local-directory-storage-provider.backend.service.d.ts.map +1 -1
  414. package/dist/esm/files/storage/local-directory-storage-provider.backend.service.js.map +1 -1
  415. package/dist/esm/files/storage/storage-credential-provider.backend.utils.d.ts.map +1 -1
  416. package/dist/esm/files/storage/storage-platform-sts-credential-resolver.backend.utils.d.ts.map +1 -1
  417. package/dist/esm/files/storage/storage-sts-credential-resolver.backend.utils.d.ts.map +1 -1
  418. package/dist/esm/files/storage/storage-sts-credential-resolver.backend.utils.js +10 -3
  419. package/dist/esm/files/storage/storage-sts-credential-resolver.backend.utils.js.map +1 -1
  420. package/dist/esm/files/storage/wildo-managed-storage-provider.backend.service.d.ts.map +1 -1
  421. package/dist/esm/files/storage/wildo-managed-storage-provider.backend.service.js.map +1 -1
  422. package/dist/esm/files/utils/file-field-schema-path.backend.utils.d.ts.map +1 -1
  423. package/dist/esm/files/utils/file-field-schema-path.backend.utils.js.map +1 -1
  424. package/dist/esm/files/utils/file-upload.utils.d.ts.map +1 -1
  425. package/dist/esm/files/utils/file-uploader.utils.d.ts.map +1 -1
  426. package/dist/esm/files/utils/file-uploader.utils.js.map +1 -1
  427. package/dist/esm/files/utils/file-validation.utils.d.ts.map +1 -1
  428. package/dist/esm/files/utils/image-derivation.backend.utils.d.ts.map +1 -1
  429. package/dist/esm/files/utils/image-thumbnail.backend.utils.d.ts.map +1 -1
  430. package/dist/esm/files/utils/office-document-text-extraction.backend.utils.d.ts.map +1 -1
  431. package/dist/esm/files/utils/office-document-text-extraction.backend.utils.js.map +1 -1
  432. package/dist/esm/files/utils/rag-source-field-schema-path.backend.utils.d.ts.map +1 -1
  433. package/dist/esm/files/utils/storage-application-identity.backend.utils.d.ts.map +1 -1
  434. package/dist/esm/flows-actors/a2a/batches/a2a-abandoned-task-sweep.batch.backend.service.d.ts.map +1 -1
  435. package/dist/esm/flows-actors/a2a/batches/a2a-abandoned-task-sweep.batch.backend.service.js.map +1 -1
  436. package/dist/esm/flows-actors/a2a/batches/a2a-push-delivery.batch.backend.service.d.ts.map +1 -1
  437. package/dist/esm/flows-actors/a2a/controllers/a2a.controller.d.ts.map +1 -1
  438. package/dist/esm/flows-actors/a2a/controllers/a2a.controller.js.map +1 -1
  439. package/dist/esm/flows-actors/a2a/models/a2a-dialect.backend.schemas.d.ts.map +1 -1
  440. package/dist/esm/flows-actors/a2a/models/a2a-push-notification-delivery.backend.utils.d.ts.map +1 -1
  441. package/dist/esm/flows-actors/a2a/models/a2a-push-notification.backend.schemas.d.ts.map +1 -1
  442. package/dist/esm/flows-actors/a2a/models/a2a.backend.schemas.d.ts.map +1 -1
  443. package/dist/esm/flows-actors/a2a/models/a2a.backend.schemas.js.map +1 -1
  444. package/dist/esm/flows-actors/a2a/services/a2a-push-delivery-log.repository.d.ts.map +1 -1
  445. package/dist/esm/flows-actors/a2a/services/a2a-push-dispatcher.backend.service.d.ts.map +1 -1
  446. package/dist/esm/flows-actors/a2a/services/a2a-task-cancellation.backend.service.d.ts.map +1 -1
  447. package/dist/esm/flows-actors/a2a/services/a2a-task-cancellation.backend.service.js.map +1 -1
  448. package/dist/esm/flows-actors/a2a/services/a2a-task.backend.service.d.ts.map +1 -1
  449. package/dist/esm/flows-actors/a2a/services/a2a-task.backend.service.js.map +1 -1
  450. package/dist/esm/flows-actors/a2a/services/a2a-token-budget.backend.service.d.ts.map +1 -1
  451. package/dist/esm/flows-actors/a2a/services/a2a-token-budget.backend.service.js.map +1 -1
  452. package/dist/esm/flows-actors/a2a/services/a2a.backend.service.d.ts.map +1 -1
  453. package/dist/esm/flows-actors/a2a/services/a2a.backend.service.js.map +1 -1
  454. package/dist/esm/flows-actors/controllers/flows-actors.controller.d.ts.map +1 -1
  455. package/dist/esm/flows-actors/models/agent-catalogs.backend.definitions.d.ts.map +1 -1
  456. package/dist/esm/flows-actors/models/agent-catalogs.backend.definitions.js.map +1 -1
  457. package/dist/esm/flows-actors/models/agent-facets.backend.definitions.d.ts.map +1 -1
  458. package/dist/esm/flows-actors/models/agents.backend.definitions.d.ts.map +1 -1
  459. package/dist/esm/flows-actors/models/core-facets.backend.definitions.d.ts.map +1 -1
  460. package/dist/esm/flows-actors/models/core-facets.backend.definitions.js.map +1 -1
  461. package/dist/esm/flows-actors/models/flows-actors.backend.definitions.d.ts.map +1 -1
  462. package/dist/esm/flows-actors/models/flows-actors.backend.schemas.d.ts.map +1 -1
  463. package/dist/esm/flows-actors/models/flows-actors.backend.schemas.js.map +1 -1
  464. package/dist/esm/flows-actors/models/function-tools.backend.definitions.d.ts +107 -16
  465. package/dist/esm/flows-actors/models/function-tools.backend.definitions.d.ts.map +1 -1
  466. package/dist/esm/flows-actors/models/function-tools.backend.definitions.js +118 -18
  467. package/dist/esm/flows-actors/models/function-tools.backend.definitions.js.map +1 -1
  468. package/dist/esm/flows-actors/models/market-generation.actors-system.backend.definitions.d.ts.map +1 -1
  469. package/dist/esm/flows-actors/models/market-generation.actors-system.backend.definitions.js.map +1 -1
  470. package/dist/esm/flows-actors/models/mcp-client.backend.definitions.d.ts.map +1 -1
  471. package/dist/esm/flows-actors/models/mcp-client.backend.definitions.js.map +1 -1
  472. package/dist/esm/flows-actors/services/__tests__/fixtures/meta-workflow-evaluation-treatment.test-fixture.d.ts.map +1 -1
  473. package/dist/esm/flows-actors/services/actors-system.backend.service.d.ts.map +1 -1
  474. package/dist/esm/flows-actors/services/actors-system.backend.service.js.map +1 -1
  475. package/dist/esm/flows-actors/services/agent-call-trace-sink.backend.d.ts.map +1 -1
  476. package/dist/esm/flows-actors/services/agent-facets.backend.service.d.ts.map +1 -1
  477. package/dist/esm/flows-actors/services/agents.backend.service.d.ts +104 -5
  478. package/dist/esm/flows-actors/services/agents.backend.service.d.ts.map +1 -1
  479. package/dist/esm/flows-actors/services/agents.backend.service.js +263 -31
  480. package/dist/esm/flows-actors/services/agents.backend.service.js.map +1 -1
  481. package/dist/esm/flows-actors/services/context-curation.backend.service.d.ts.map +1 -1
  482. package/dist/esm/flows-actors/services/conversational-execution.backend.service.d.ts +46 -1
  483. package/dist/esm/flows-actors/services/conversational-execution.backend.service.d.ts.map +1 -1
  484. package/dist/esm/flows-actors/services/conversational-execution.backend.service.js +193 -6
  485. package/dist/esm/flows-actors/services/conversational-execution.backend.service.js.map +1 -1
  486. package/dist/esm/flows-actors/services/flows-actors-registry.service.d.ts.map +1 -1
  487. package/dist/esm/flows-actors/services/flows-actors-registry.service.js.map +1 -1
  488. package/dist/esm/flows-actors/services/flows.backend.services.d.ts.map +1 -1
  489. package/dist/esm/flows-actors/services/flows.backend.services.js.map +1 -1
  490. package/dist/esm/flows-actors/services/llm-observability-agent-call-trace-sink.backend.d.ts.map +1 -1
  491. package/dist/esm/flows-actors/services/llm-observability-agent-call-trace-sink.backend.js.map +1 -1
  492. package/dist/esm/flows-actors/services/mcp-client.backend.service.d.ts.map +1 -1
  493. package/dist/esm/flows-actors/services/mcp-client.backend.service.js +3 -0
  494. package/dist/esm/flows-actors/services/mcp-client.backend.service.js.map +1 -1
  495. package/dist/esm/flows-actors/services/mcp-credential-resolver.backend.service.d.ts +99 -0
  496. package/dist/esm/flows-actors/services/mcp-credential-resolver.backend.service.d.ts.map +1 -0
  497. package/dist/esm/flows-actors/services/mcp-credential-resolver.backend.service.js +155 -0
  498. package/dist/esm/flows-actors/services/mcp-credential-resolver.backend.service.js.map +1 -0
  499. package/dist/esm/flows-actors/services/meta-workflow-evaluation-treatment-compiler.backend.service.d.ts.map +1 -1
  500. package/dist/esm/flows-actors/services/meta-workflow-standard-action-contracts.backend.service.d.ts.map +1 -1
  501. package/dist/esm/flows-actors/services/meta-workflow-standard-evaluation-contracts.backend.service.d.ts.map +1 -1
  502. package/dist/esm/flows-actors/services/meta-workflow-structured-artifact-action-compiler.backend.service.d.ts.map +1 -1
  503. package/dist/esm/flows-actors/services/prompt-compiler.backend.service.d.ts.map +1 -1
  504. package/dist/esm/flows-actors/services/prompt-compiler.backend.service.js.map +1 -1
  505. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.d.ts.map +1 -1
  506. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.js +9 -0
  507. package/dist/esm/flows-actors/utils/acp-session-runner.backend.utils.js.map +1 -1
  508. package/dist/esm/flows-actors/utils/bounded-subprocess.backend.utils.d.ts.map +1 -1
  509. package/dist/esm/flows-actors/utils/flows-actors-frontend-extractor.utils.d.ts.map +1 -1
  510. package/dist/esm/flows-actors/utils/meta-workflow-canonical-json.backend.utils.d.ts.map +1 -1
  511. package/dist/esm/flows-actors/utils/meta-workflow-canonical-json.backend.utils.js.map +1 -1
  512. package/dist/esm/flows-actors/utils/meta-workflow-structured-generation-plan.backend.utils.d.ts.map +1 -1
  513. package/dist/esm/flows-actors/utils/meta-workflow-structured-generation-plan.backend.utils.js.map +1 -1
  514. package/dist/esm/flows-actors/utils/prompt-ir-adapters.backend.utils.d.ts.map +1 -1
  515. package/dist/esm/flows-actors/utils/tool-approval-modification.backend.utils.d.ts +77 -0
  516. package/dist/esm/flows-actors/utils/tool-approval-modification.backend.utils.d.ts.map +1 -0
  517. package/dist/esm/flows-actors/utils/tool-approval-modification.backend.utils.js +164 -0
  518. package/dist/esm/flows-actors/utils/tool-approval-modification.backend.utils.js.map +1 -0
  519. package/dist/esm/flows-actors/utils/tool-approval-signing.backend.utils.d.ts +48 -0
  520. package/dist/esm/flows-actors/utils/tool-approval-signing.backend.utils.d.ts.map +1 -0
  521. package/dist/esm/flows-actors/utils/tool-approval-signing.backend.utils.js +101 -0
  522. package/dist/esm/flows-actors/utils/tool-approval-signing.backend.utils.js.map +1 -0
  523. package/dist/esm/guidance/batches/dormancy-detection.batch.backend.service.d.ts.map +1 -1
  524. package/dist/esm/guidance/services/guidance-trigger-evaluator.backend.service.d.ts.map +1 -1
  525. package/dist/esm/guidance/services/lifecycle-custom-implementations.backend.d.ts.map +1 -1
  526. package/dist/esm/guidance/services/lifecycle-evaluator.backend.service.d.ts.map +1 -1
  527. package/dist/esm/guidance/services/lifecycle-scope-id.backend.utils.d.ts.map +1 -1
  528. package/dist/esm/guidance/services/milestone-condition-registry.backend.service.d.ts.map +1 -1
  529. package/dist/esm/guidance/services/milestone-definition-registry.backend.service.d.ts.map +1 -1
  530. package/dist/esm/guidance/services/milestone-evaluator.backend.service.d.ts.map +1 -1
  531. package/dist/esm/guidance/services/milestone-evaluator.backend.service.js.map +1 -1
  532. package/dist/esm/guidance/services/progression-state-store.backend.service.d.ts.map +1 -1
  533. package/dist/esm/guidance/services/progression-state-store.backend.service.js.map +1 -1
  534. package/dist/esm/guidance/services/scoped-state-read-custom-implementations.backend.d.ts.map +1 -1
  535. package/dist/esm/i18n/controllers/i18n-controller.backend.service.d.ts.map +1 -1
  536. package/dist/esm/i18n/controllers/i18n-controller.backend.service.js.map +1 -1
  537. package/dist/esm/i18n/services/i18n.backend.service.d.ts.map +1 -1
  538. package/dist/esm/index.d.ts +0 -1
  539. package/dist/esm/index.d.ts.map +1 -1
  540. package/dist/esm/index.js +0 -1
  541. package/dist/esm/index.js.map +1 -1
  542. package/dist/esm/inject/models/container.d.ts +10 -0
  543. package/dist/esm/inject/models/container.d.ts.map +1 -1
  544. package/dist/esm/inject/models/container.js +49 -1
  545. package/dist/esm/inject/models/container.js.map +1 -1
  546. package/dist/esm/inject/models/service-types.d.ts +3 -0
  547. package/dist/esm/inject/models/service-types.d.ts.map +1 -1
  548. package/dist/esm/inject/models/service-types.js +3 -0
  549. package/dist/esm/inject/models/service-types.js.map +1 -1
  550. package/dist/esm/mcp/controllers/mcp.controller.d.ts.map +1 -1
  551. package/dist/esm/mcp/controllers/mcp.controller.js +50 -3
  552. package/dist/esm/mcp/controllers/mcp.controller.js.map +1 -1
  553. package/dist/esm/mcp/models/mcp-protocol.backend.schemas.d.ts.map +1 -1
  554. package/dist/esm/mcp/models/mcp-tool.backend.schemas.d.ts.map +1 -1
  555. package/dist/esm/mcp/models/mcp-tool.backend.schemas.js.map +1 -1
  556. package/dist/esm/mcp/services/mcp-server.backend.service.d.ts.map +1 -1
  557. package/dist/esm/mcp/services/mcp-server.backend.service.js.map +1 -1
  558. package/dist/esm/mcp/services/mcp-tool-adapter.backend.service.d.ts.map +1 -1
  559. package/dist/esm/mcp/services/mcp-tool-adapter.backend.service.js.map +1 -1
  560. package/dist/esm/mcp/services/resource-server-instances-registry.backend.service.d.ts.map +1 -1
  561. package/dist/esm/mcp/utils/zod-to-mcp-json-schema.backend.utils.d.ts.map +1 -1
  562. package/dist/esm/meta-workflow-runtime.exports.d.ts.map +1 -1
  563. package/dist/esm/monitoring/analytics/controllers/analytics.backend.controller.d.ts.map +1 -1
  564. package/dist/esm/monitoring/analytics/controllers/analytics.backend.controller.js.map +1 -1
  565. package/dist/esm/monitoring/analytics/services/value-moment-definition-registry.backend.service.d.ts.map +1 -1
  566. package/dist/esm/monitoring/analytics/services/value-moment-definition-registry.backend.service.js.map +1 -1
  567. package/dist/esm/monitoring/analytics/services/value-moment-engine.backend.service.d.ts.map +1 -1
  568. package/dist/esm/monitoring/analytics/services/value-moment-engine.backend.service.js.map +1 -1
  569. package/dist/esm/monitoring/analytics/services/value-moment-handler-registry.backend.service.d.ts.map +1 -1
  570. package/dist/esm/monitoring/analytics/services/value-moment-handler-registry.backend.service.js.map +1 -1
  571. package/dist/esm/monitoring/logger/models/logger.backend.schemas.d.ts.map +1 -1
  572. package/dist/esm/monitoring/logger/models/logger.backend.schemas.js.map +1 -1
  573. package/dist/esm/monitoring/logger/services/__tests__/mock-logger.service.d.ts.map +1 -1
  574. package/dist/esm/monitoring/logger/services/logger.service.d.ts +12 -0
  575. package/dist/esm/monitoring/logger/services/logger.service.d.ts.map +1 -1
  576. package/dist/esm/monitoring/logger/services/logger.service.js +3 -3
  577. package/dist/esm/monitoring/logger/services/logger.service.js.map +1 -1
  578. package/dist/esm/monitoring/logger/utils/log-severity-floor.backend.utils.d.ts.map +1 -1
  579. package/dist/esm/monitoring/logger/utils/log-severity-floor.backend.utils.js.map +1 -1
  580. package/dist/esm/monitoring/logger/utils/log-value-normalization.backend.utils.d.ts.map +1 -1
  581. package/dist/esm/monitoring/observability/audit-observation-emission.backend.d.ts +10 -6
  582. package/dist/esm/monitoring/observability/audit-observation-emission.backend.d.ts.map +1 -1
  583. package/dist/esm/monitoring/observability/audit-observation-emission.backend.js +10 -6
  584. package/dist/esm/monitoring/observability/audit-observation-emission.backend.js.map +1 -1
  585. package/dist/esm/monitoring/observability/models/observability.backend.schemas.d.ts.map +1 -1
  586. package/dist/esm/monitoring/observability/models/observability.backend.schemas.js.map +1 -1
  587. package/dist/esm/monitoring/observability/otel-preload.d.ts.map +1 -1
  588. package/dist/esm/monitoring/observability/otel-sdk-global-handle.d.ts.map +1 -1
  589. package/dist/esm/monitoring/observability/services/__tests__/mock-metrics.service.d.ts.map +1 -1
  590. package/dist/esm/monitoring/observability/services/metrics.service.d.ts.map +1 -1
  591. package/dist/esm/monitoring/observability/services/metrics.service.js.map +1 -1
  592. package/dist/esm/monitoring/observability/services/observability.backend.service.d.ts.map +1 -1
  593. package/dist/esm/notifications/email/components/email-components.d.ts.map +1 -1
  594. package/dist/esm/notifications/email/models/email-template-definition.d.ts.map +1 -1
  595. package/dist/esm/notifications/email/models/email-transport.backend.definitions.d.ts.map +1 -1
  596. package/dist/esm/notifications/email/services/email-batch-send.batch.backend.service.d.ts.map +1 -1
  597. package/dist/esm/notifications/email/services/email-template-registry.backend.service.d.ts.map +1 -1
  598. package/dist/esm/notifications/email/services/email-template-registry.backend.service.js.map +1 -1
  599. package/dist/esm/notifications/email/services/email-template-validator.backend.service.d.ts.map +1 -1
  600. package/dist/esm/notifications/email/services/email-template-validator.backend.service.js.map +1 -1
  601. package/dist/esm/notifications/email/services/email.backend.service.d.ts +47 -6
  602. package/dist/esm/notifications/email/services/email.backend.service.d.ts.map +1 -1
  603. package/dist/esm/notifications/email/services/email.backend.service.js +86 -36
  604. package/dist/esm/notifications/email/services/email.backend.service.js.map +1 -1
  605. package/dist/esm/notifications/email/utils/color-conversion.utils.d.ts.map +1 -1
  606. package/dist/esm/notifications/email/utils/color-conversion.utils.js.map +1 -1
  607. package/dist/esm/notifications/email/utils/interpolate-email-label.utils.d.ts.map +1 -1
  608. package/dist/esm/notifications/email/utils/zod-to-typescript.utils.d.ts.map +1 -1
  609. package/dist/esm/notifications/services/notification-badge.backend.service.d.ts.map +1 -1
  610. package/dist/esm/notifications/services/notification-badge.backend.service.js.map +1 -1
  611. package/dist/esm/notifications/services/notifications-dispatcher.backend.service.d.ts.map +1 -1
  612. package/dist/esm/notifications/services/notifications-dispatcher.backend.service.js.map +1 -1
  613. package/dist/esm/notifications/sms/models/sms-transport.backend.definitions.d.ts +32 -0
  614. package/dist/esm/notifications/sms/models/sms-transport.backend.definitions.d.ts.map +1 -0
  615. package/dist/esm/notifications/sms/models/sms-transport.backend.definitions.js +32 -0
  616. package/dist/esm/notifications/sms/models/sms-transport.backend.definitions.js.map +1 -0
  617. package/dist/esm/notifications/sms/services/sms.backend.service.d.ts +64 -10
  618. package/dist/esm/notifications/sms/services/sms.backend.service.d.ts.map +1 -1
  619. package/dist/esm/notifications/sms/services/sms.backend.service.js +277 -82
  620. package/dist/esm/notifications/sms/services/sms.backend.service.js.map +1 -1
  621. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.d.ts.map +1 -1
  622. package/dist/esm/notifications/webhooks/controllers/webhook-auto-controller.backend.service.js.map +1 -1
  623. package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.backend.service.d.ts.map +1 -1
  624. package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.backend.service.js.map +1 -1
  625. package/dist/esm/notifications/webhooks/outbound/batches/m2m-webhook-delivery.batch.utils.d.ts.map +1 -1
  626. package/dist/esm/notifications/webhooks/outbound/m2m-webhook-signed-request.backend.utils.d.ts.map +1 -1
  627. package/dist/esm/notifications/webhooks/outbound/m2m-webhook-signed-request.backend.utils.js.map +1 -1
  628. package/dist/esm/notifications/webhooks/outbound/services/m2m-webhook-delivery-log.custom-impl.backend.service.d.ts.map +1 -1
  629. package/dist/esm/notifications/webhooks/outbound/services/m2m-webhook-delivery-log.repository.d.ts.map +1 -1
  630. package/dist/esm/notifications/webhooks/outbound/services/m2m-webhook-dispatcher.backend.service.d.ts.map +1 -1
  631. package/dist/esm/notifications/webhooks/outbound/services/webhook-config-public-key.custom-impl.backend.service.d.ts.map +1 -1
  632. package/dist/esm/notifications/webhooks/outbound/services/webhook-config-test-endpoint.custom-impl.backend.service.d.ts.map +1 -1
  633. package/dist/esm/notifications/webhooks/outbound/services/webhook-config-test-endpoint.custom-impl.backend.service.js.map +1 -1
  634. package/dist/esm/notifications/webhooks/outbound/services/webhook-config.backend.service.d.ts.map +1 -1
  635. package/dist/esm/notifications/webhooks/services/polymorphic-lookup.backend.service.d.ts.map +1 -1
  636. package/dist/esm/notifications/webhooks/services/webhook-handler.backend.service.d.ts.map +1 -1
  637. package/dist/esm/notifications/webhooks/services/webhook-handler.backend.service.js.map +1 -1
  638. package/dist/esm/organizations/batches/organization-member-invitation-sweep.batch.backend.service.d.ts.map +1 -1
  639. package/dist/esm/organizations/batches/organization-purge.batch.backend.service.d.ts.map +1 -1
  640. package/dist/esm/organizations/batches/organization-purge.batch.backend.service.js.map +1 -1
  641. package/dist/esm/organizations/services/authority-change-audit.backend.utils.d.ts.map +1 -1
  642. package/dist/esm/organizations/services/invitation-acceptance.backend.utils.d.ts.map +1 -1
  643. package/dist/esm/organizations/services/org-creation-on-registration.backend.utils.d.ts.map +1 -1
  644. package/dist/esm/organizations/services/org-member-roles-validation.backend.utils.d.ts.map +1 -1
  645. package/dist/esm/organizations/services/organization-custom-implementation.backend.service.d.ts.map +1 -1
  646. package/dist/esm/organizations/services/organization-custom-implementation.backend.service.js.map +1 -1
  647. package/dist/esm/organizations/services/organization-deletion-audit.custom-impl.backend.service.d.ts.map +1 -1
  648. package/dist/esm/organizations/services/organization-member-custom-implementation.backend.service.d.ts.map +1 -1
  649. package/dist/esm/organizations/services/organization-onboarding-operation.backend.utils.d.ts.map +1 -1
  650. package/dist/esm/organizations/services/organization-unit-custom-implementation.backend.service.d.ts.map +1 -1
  651. package/dist/esm/organizations/services/organization-unit-member-custom-implementation.backend.service.d.ts.map +1 -1
  652. package/dist/esm/organizations/services/scim-provisioning-gate.backend.utils.d.ts.map +1 -1
  653. package/dist/esm/organizations/services/user-org-type-grant.backend.utils.d.ts.map +1 -1
  654. package/dist/esm/organizations/services/user-type-revocation-on-org-leave.backend.utils.d.ts.map +1 -1
  655. package/dist/esm/pdf-templates/__tests__/fixtures/tiny-pdf-template.fixture.d.ts.map +1 -1
  656. package/dist/esm/pdf-templates/models/pdf-template-binding.d.ts.map +1 -1
  657. package/dist/esm/pdf-templates/models/pdf-template-definition.d.ts.map +1 -1
  658. package/dist/esm/pdf-templates/services/pdf-generated-file-writer.backend.service.d.ts.map +1 -1
  659. package/dist/esm/pdf-templates/services/pdf-generation-orchestrator.backend.service.d.ts.map +1 -1
  660. package/dist/esm/pdf-templates/services/pdf-renderer.backend.service.d.ts.map +1 -1
  661. package/dist/esm/pdf-templates/services/pdf-template-binding.backend.service.d.ts.map +1 -1
  662. package/dist/esm/queue/adapters/in-memory-queue-adapter.backend.service.d.ts.map +1 -1
  663. package/dist/esm/queue/adapters/in-memory-queue-adapter.backend.service.js.map +1 -1
  664. package/dist/esm/queue/adapters/queue-adapter.backend.binding.d.ts.map +1 -1
  665. package/dist/esm/queue/adapters/queue-adapter.backend.binding.js.map +1 -1
  666. package/dist/esm/queue/adapters/queue-adapter.backend.interface.d.ts.map +1 -1
  667. package/dist/esm/queue/adapters/queue-adapter.backend.interface.js.map +1 -1
  668. package/dist/esm/queue/adapters/queue-adapter.backend.options.d.ts.map +1 -1
  669. package/dist/esm/queue/adapters/queue-adapter.backend.options.js.map +1 -1
  670. package/dist/esm/queue/adapters/rabbitmq-adapter.backend.service.d.ts.map +1 -1
  671. package/dist/esm/queue/adapters/rabbitmq-adapter.backend.service.js.map +1 -1
  672. package/dist/esm/queue/apps-crontabs-manager.backend.service.d.ts.map +1 -1
  673. package/dist/esm/queue/cron-job-sync.backend.service.d.ts.map +1 -1
  674. package/dist/esm/queue/domain-queue-consumer.backend.service.d.ts.map +1 -1
  675. package/dist/esm/queue/domain-queue-consumer.backend.service.js.map +1 -1
  676. package/dist/esm/queue/job-completion-registry.backend.service.d.ts.map +1 -1
  677. package/dist/esm/queue/job-consumer.backend.service.d.ts.map +1 -1
  678. package/dist/esm/queue/job-consumer.backend.service.js.map +1 -1
  679. package/dist/esm/queue/job-executor.backend.service.d.ts.map +1 -1
  680. package/dist/esm/queue/job-executor.backend.service.js.map +1 -1
  681. package/dist/esm/queue/job-payload-storage.backend.service.d.ts.map +1 -1
  682. package/dist/esm/queue/job-status-tracking.backend.service.d.ts.map +1 -1
  683. package/dist/esm/queue/queue-monitoring.backend.service.d.ts.map +1 -1
  684. package/dist/esm/queue/queue-monitoring.backend.service.js.map +1 -1
  685. package/dist/esm/queue/queue-worker-initializer.backend.service.d.ts.map +1 -1
  686. package/dist/esm/queue/queue-worker-initializer.backend.service.js.map +1 -1
  687. package/dist/esm/queue/queue.backend.service.d.ts.map +1 -1
  688. package/dist/esm/queue/queue.backend.service.js.map +1 -1
  689. package/dist/esm/queue/scheduled-message-verifier.backend.service.d.ts.map +1 -1
  690. package/dist/esm/queue/worker-shutdown-manager.backend.service.d.ts.map +1 -1
  691. package/dist/esm/queue/worker-shutdown-manager.backend.service.js.map +1 -1
  692. package/dist/esm/rag/batches/rag-embedding-drain.batch.backend.service.d.ts.map +1 -1
  693. package/dist/esm/rag/batches/rag-reconciliation-sweep.batch.backend.service.d.ts.map +1 -1
  694. package/dist/esm/rag/models/rag-chunk-store.backend.types.d.ts.map +1 -1
  695. package/dist/esm/rag/models/rag-retrieval.backend.types.d.ts.map +1 -1
  696. package/dist/esm/rag/services/mongodb-rag-chunk-store.backend.service.d.ts.map +1 -1
  697. package/dist/esm/rag/services/postgresql-rag-chunk-store.backend.service.d.ts.map +1 -1
  698. package/dist/esm/rag/services/rag-chunk-collection.mongodb-ddl.backend.d.ts.map +1 -1
  699. package/dist/esm/rag/services/rag-chunk-retrieval.mongodb-query.backend.d.ts.map +1 -1
  700. package/dist/esm/rag/services/rag-chunk-retrieval.postgresql-query.backend.d.ts.map +1 -1
  701. package/dist/esm/rag/services/rag-chunk-store.backend.service.d.ts.map +1 -1
  702. package/dist/esm/rag/services/rag-chunk-table.postgresql-ddl.backend.d.ts.map +1 -1
  703. package/dist/esm/rag/services/rag-ingestion.backend.service.d.ts.map +1 -1
  704. package/dist/esm/rag/services/rag-retrieval.backend.service.d.ts.map +1 -1
  705. package/dist/esm/rag/utils/rag-chunk-fusion.backend.utils.d.ts.map +1 -1
  706. package/dist/esm/rag/utils/rag-chunk-removal.backend.utils.d.ts.map +1 -1
  707. package/dist/esm/rag/utils/rag-chunk-row-shaping.backend.utils.d.ts.map +1 -1
  708. package/dist/esm/rag/utils/rag-chunking.backend.utils.d.ts.map +1 -1
  709. package/dist/esm/rag/utils/rag-chunking.backend.utils.js.map +1 -1
  710. package/dist/esm/rag/utils/rag-context-assembly.backend.utils.d.ts.map +1 -1
  711. package/dist/esm/rag/utils/rag-context-assembly.backend.utils.js.map +1 -1
  712. package/dist/esm/rag/utils/rag-ingestion-trigger.backend.utils.d.ts.map +1 -1
  713. package/dist/esm/rag/utils/rag-retrieval-scope.backend.utils.d.ts.map +1 -1
  714. package/dist/esm/rag/utils/rag-source-field-value.backend.utils.d.ts.map +1 -1
  715. package/dist/esm/requests/models/api-routes.backend.defintions.d.ts.map +1 -1
  716. package/dist/esm/requests/models/requests.backend.schemas.d.ts.map +1 -1
  717. package/dist/esm/requests/service/platform-mutualized-handler.backend.service.d.ts.map +1 -1
  718. package/dist/esm/requests/service/platform-requests.backend.utils.d.ts.map +1 -1
  719. package/dist/esm/requests/service/remote-client-base.backend.service.d.ts.map +1 -1
  720. package/dist/esm/requests/service/serverless-services-handler.backend.service.d.ts.map +1 -1
  721. package/dist/esm/requests/service/websocket.service.d.ts.map +1 -1
  722. package/dist/esm/requests/service/websocket.service.js +49 -1
  723. package/dist/esm/requests/service/websocket.service.js.map +1 -1
  724. package/dist/esm/resources/backend-resource-registry.exports.d.ts.map +1 -1
  725. package/dist/esm/resources/models/custom-service-implementations.backend.definition.d.ts.map +1 -1
  726. package/dist/esm/resources/models/custom-service-implementations.backend.definition.js +2 -0
  727. package/dist/esm/resources/models/custom-service-implementations.backend.definition.js.map +1 -1
  728. package/dist/esm/resources/models/index.d.ts.map +1 -1
  729. package/dist/esm/resources/models/resources-operations.backend.definitions.d.ts.map +1 -1
  730. package/dist/esm/resources/models/resources-operations.backend.definitions.js.map +1 -1
  731. package/dist/esm/resources/models/resources-relationships.backend.definitions.d.ts.map +1 -1
  732. package/dist/esm/resources/models/resources-relationships.backend.definitions.js.map +1 -1
  733. package/dist/esm/resources/models/resources-types.backend.schemas.d.ts.map +1 -1
  734. package/dist/esm/resources/models/resources-types.backend.schemas.js.map +1 -1
  735. package/dist/esm/resources/models/resources.backend.schemas.d.ts.map +1 -1
  736. package/dist/esm/resources/models/virtual-fields.backend.types.d.ts.map +1 -1
  737. package/dist/esm/resources/services/__tests__/mock-resources-registry.service.d.ts.map +1 -1
  738. package/dist/esm/resources/services/resource-context.backend.service.d.ts.map +1 -1
  739. package/dist/esm/resources/services/resource-id.backend.service.d.ts.map +1 -1
  740. package/dist/esm/resources/services/resource-population.backend.service.d.ts +17 -2
  741. package/dist/esm/resources/services/resource-population.backend.service.d.ts.map +1 -1
  742. package/dist/esm/resources/services/resource-population.backend.service.js +74 -18
  743. package/dist/esm/resources/services/resource-population.backend.service.js.map +1 -1
  744. package/dist/esm/resources/services/resources-registry.backend.service.d.ts +23 -0
  745. package/dist/esm/resources/services/resources-registry.backend.service.d.ts.map +1 -1
  746. package/dist/esm/resources/services/resources-registry.backend.service.js +31 -0
  747. package/dist/esm/resources/services/resources-registry.backend.service.js.map +1 -1
  748. package/dist/esm/resources/services/virtual-fields.backend.service.d.ts.map +1 -1
  749. package/dist/esm/resources/utils/resource-retention.backend.utils.d.ts.map +1 -1
  750. package/dist/esm/runtime/controllers/health-controller.backend.service.d.ts.map +1 -1
  751. package/dist/esm/runtime/controllers/health-controller.backend.service.js.map +1 -1
  752. package/dist/esm/runtime/domain-module.backend.definitions.d.ts.map +1 -1
  753. package/dist/esm/runtime/domain-module.backend.definitions.js.map +1 -1
  754. package/dist/esm/runtime/models/execution-context.backend.schemas.d.ts.map +1 -1
  755. package/dist/esm/runtime/models/request-context.als.backend.d.ts.map +1 -1
  756. package/dist/esm/runtime/models/runtime.backend.schemas.d.ts.map +1 -1
  757. package/dist/esm/runtime/services/execution-context-creator.backend.service.d.ts.map +1 -1
  758. package/dist/esm/runtime/services/execution-context-creator.backend.service.js.map +1 -1
  759. package/dist/esm/runtime/services/execution-context-handler.backend.service.d.ts.map +1 -1
  760. package/dist/esm/runtime/services/health-readiness-contributor.backend.interface.d.ts.map +1 -1
  761. package/dist/esm/runtime/services/health-readiness-contributor.backend.interface.js.map +1 -1
  762. package/dist/esm/runtime/services/http-server.backend.service.d.ts.map +1 -1
  763. package/dist/esm/runtime/services/http-server.backend.service.js +10 -0
  764. package/dist/esm/runtime/services/http-server.backend.service.js.map +1 -1
  765. package/dist/esm/runtime/services/start-application.backend.service.d.ts.map +1 -1
  766. package/dist/esm/runtime/services/start-application.backend.service.js +26 -12
  767. package/dist/esm/runtime/services/start-application.backend.service.js.map +1 -1
  768. package/dist/esm/runtime/services/utils/oauth-body-cap.backend.utils.d.ts.map +1 -1
  769. package/dist/esm/runtime/testing/execution-context-test-fixtures.d.ts.map +1 -1
  770. package/dist/esm/runtime/testing/mock-execution-context-creator.service.d.ts.map +1 -1
  771. package/dist/esm/runtime/utils/application-startup-config-access.backend.utils.d.ts.map +1 -1
  772. package/dist/esm/runtime/utils/feature-gated-core-resource-exclusions.backend.utils.d.ts.map +1 -1
  773. package/dist/esm/runtime/utils/request-client-ip.utils.d.ts.map +1 -1
  774. package/dist/esm/runtime/utils/scan-default-exports.backend.utils.d.ts.map +1 -1
  775. package/dist/esm/security/api-keys/api-key-generation.backend.utils.d.ts.map +1 -1
  776. package/dist/esm/security/api-keys/api-keys.custom-impl.backend.service.d.ts.map +1 -1
  777. package/dist/esm/security/api-keys/api-keys.custom-impl.backend.service.js.map +1 -1
  778. package/dist/esm/security/authentications/batches/anonymous-session-cleanup.batch.backend.service.d.ts.map +1 -1
  779. package/dist/esm/security/authentications/batches/anonymous-session-cleanup.batch.backend.service.js.map +1 -1
  780. package/dist/esm/security/authentications/controllers/auth-method-management-controller.backend.service.d.ts.map +1 -1
  781. package/dist/esm/security/authentications/controllers/authentication-controller.backend.service.d.ts +22 -0
  782. package/dist/esm/security/authentications/controllers/authentication-controller.backend.service.d.ts.map +1 -1
  783. package/dist/esm/security/authentications/controllers/authentication-controller.backend.service.js +84 -0
  784. package/dist/esm/security/authentications/controllers/authentication-controller.backend.service.js.map +1 -1
  785. package/dist/esm/security/authentications/controllers/oauth-provider-controller.backend.service.d.ts.map +1 -1
  786. package/dist/esm/security/authentications/controllers/oauth-provider-controller.backend.service.js.map +1 -1
  787. package/dist/esm/security/authentications/models/auth-constants.backend.d.ts.map +1 -1
  788. package/dist/esm/security/authentications/models/authentications.backend.schemas.d.ts.map +1 -1
  789. package/dist/esm/security/authentications/models/authorization-client.backend.schemas.d.ts.map +1 -1
  790. package/dist/esm/security/authentications/models/cimd.backend.schemas.d.ts.map +1 -1
  791. package/dist/esm/security/authentications/models/cimd.backend.schemas.js.map +1 -1
  792. package/dist/esm/security/authentications/models/federated-auth-transport.backend.definitions.d.ts +37 -0
  793. package/dist/esm/security/authentications/models/federated-auth-transport.backend.definitions.d.ts.map +1 -0
  794. package/dist/esm/security/authentications/models/federated-auth-transport.backend.definitions.js +37 -0
  795. package/dist/esm/security/authentications/models/federated-auth-transport.backend.definitions.js.map +1 -0
  796. package/dist/esm/security/authentications/models/identity-persistence-boundaries.backend.d.ts.map +1 -1
  797. package/dist/esm/security/authentications/models/jwt.backend.schemas.d.ts.map +1 -1
  798. package/dist/esm/security/authentications/models/oauth2-connection.backend.schemas.d.ts +15 -0
  799. package/dist/esm/security/authentications/models/oauth2-connection.backend.schemas.d.ts.map +1 -1
  800. package/dist/esm/security/authentications/models/oauth2-connection.backend.schemas.js.map +1 -1
  801. package/dist/esm/security/authentications/models/saml-authentication.backend.schemas.d.ts.map +1 -1
  802. package/dist/esm/security/authentications/models/sso-connection.backend.schemas.d.ts.map +1 -1
  803. package/dist/esm/security/authentications/models/user-authorization-version.backend.utils.d.ts.map +1 -1
  804. package/dist/esm/security/authentications/seeds/enterprise-config-defaults.seeds.d.ts.map +1 -1
  805. package/dist/esm/security/authentications/services/__tests__/mock-auth-execution-context-factory.service.d.ts.map +1 -1
  806. package/dist/esm/security/authentications/services/__tests__/mock-auth-token-issuer.service.d.ts.map +1 -1
  807. package/dist/esm/security/authentications/services/__tests__/oauth-provider-audit-spies.mock.d.ts.map +1 -1
  808. package/dist/esm/security/authentications/services/admin-config/__tests__/mock-domain-to-org-lookup.service.d.ts.map +1 -1
  809. package/dist/esm/security/authentications/services/admin-config/__tests__/mock-enterprise-user-provisioning.service.d.ts.map +1 -1
  810. package/dist/esm/security/authentications/services/admin-config/auth-organization-configuration.service.d.ts.map +1 -1
  811. package/dist/esm/security/authentications/services/admin-config/auth-organization-configuration.service.js.map +1 -1
  812. package/dist/esm/security/authentications/services/admin-config/domain-to-org-lookup.backend.service.d.ts.map +1 -1
  813. package/dist/esm/security/authentications/services/admin-config/domain-to-org-lookup.backend.service.js.map +1 -1
  814. package/dist/esm/security/authentications/services/admin-config/domain-verification.backend.service.d.ts.map +1 -1
  815. package/dist/esm/security/authentications/services/admin-config/domain-verification.backend.service.js.map +1 -1
  816. package/dist/esm/security/authentications/services/admin-config/enterprise-user-provisioning.backend.service.d.ts.map +1 -1
  817. package/dist/esm/security/authentications/services/admin-config/enterprise-user-provisioning.backend.service.js.map +1 -1
  818. package/dist/esm/security/authentications/services/admin-config/oidc-discovery.backend.service.d.ts.map +1 -1
  819. package/dist/esm/security/authentications/services/admin-config/oidc-discovery.backend.service.js +2 -1
  820. package/dist/esm/security/authentications/services/admin-config/oidc-discovery.backend.service.js.map +1 -1
  821. package/dist/esm/security/authentications/services/anonymous-session.backend.service.d.ts +9 -2
  822. package/dist/esm/security/authentications/services/anonymous-session.backend.service.d.ts.map +1 -1
  823. package/dist/esm/security/authentications/services/anonymous-session.backend.service.js +9 -2
  824. package/dist/esm/security/authentications/services/anonymous-session.backend.service.js.map +1 -1
  825. package/dist/esm/security/authentications/services/auth-credential-verifier.backend.service.d.ts.map +1 -1
  826. package/dist/esm/security/authentications/services/auth-execution-context-factory.backend.service.d.ts.map +1 -1
  827. package/dist/esm/security/authentications/services/auth-methods/auth-method-management.backend.service.d.ts.map +1 -1
  828. package/dist/esm/security/authentications/services/auth-methods/auth-method-management.backend.service.js.map +1 -1
  829. package/dist/esm/security/authentications/services/auth-methods/auth-mfa.backend.service.d.ts.map +1 -1
  830. package/dist/esm/security/authentications/services/auth-methods/auth-password-reset.backend.service.d.ts.map +1 -1
  831. package/dist/esm/security/authentications/services/auth-methods/auth-phone-verification.backend.service.d.ts.map +1 -1
  832. package/dist/esm/security/authentications/services/auth-methods/auth-registration.backend.service.d.ts.map +1 -1
  833. package/dist/esm/security/authentications/services/auth-methods/auth-registration.backend.service.js.map +1 -1
  834. package/dist/esm/security/authentications/services/auth-methods/oauth2-authentication.backend.service.d.ts +97 -0
  835. package/dist/esm/security/authentications/services/auth-methods/oauth2-authentication.backend.service.d.ts.map +1 -1
  836. package/dist/esm/security/authentications/services/auth-methods/oauth2-authentication.backend.service.js +218 -26
  837. package/dist/esm/security/authentications/services/auth-methods/oauth2-authentication.backend.service.js.map +1 -1
  838. package/dist/esm/security/authentications/services/auth-methods/oauth2-connection-resolver.backend.service.d.ts +14 -0
  839. package/dist/esm/security/authentications/services/auth-methods/oauth2-connection-resolver.backend.service.d.ts.map +1 -1
  840. package/dist/esm/security/authentications/services/auth-methods/oauth2-connection-resolver.backend.service.js +36 -0
  841. package/dist/esm/security/authentications/services/auth-methods/oauth2-connection-resolver.backend.service.js.map +1 -1
  842. package/dist/esm/security/authentications/services/auth-methods/saml-assertion-validator.backend.service.d.ts.map +1 -1
  843. package/dist/esm/security/authentications/services/auth-methods/saml-authentication.backend.service.d.ts.map +1 -1
  844. package/dist/esm/security/authentications/services/auth-methods/saml-metadata.backend.service.d.ts.map +1 -1
  845. package/dist/esm/security/authentications/services/auth-methods/saml-replay-guard.backend.service.d.ts.map +1 -1
  846. package/dist/esm/security/authentications/services/auth-methods/webauthn.backend.service.d.ts.map +1 -1
  847. package/dist/esm/security/authentications/services/auth-methods/webauthn.backend.service.js.map +1 -1
  848. package/dist/esm/security/authentications/services/auth-session-store.backend.service.d.ts.map +1 -1
  849. package/dist/esm/security/authentications/services/auth-token-issuer.backend.service.d.ts.map +1 -1
  850. package/dist/esm/security/authentications/services/auth-token-issuer.backend.service.js.map +1 -1
  851. package/dist/esm/security/authentications/services/authentication-orchestrator.backend.service.d.ts.map +1 -1
  852. package/dist/esm/security/authentications/services/authentication-orchestrator.backend.service.js.map +1 -1
  853. package/dist/esm/security/authentications/services/cimd-client-metadata.backend.service.d.ts.map +1 -1
  854. package/dist/esm/security/authentications/services/cimd-client-metadata.backend.service.js.map +1 -1
  855. package/dist/esm/security/authentications/services/custom-impls/auth-custom-implementations.backend.d.ts.map +1 -1
  856. package/dist/esm/security/authentications/services/custom-impls/auth-custom-implementations.backend.js.map +1 -1
  857. package/dist/esm/security/authentications/services/custom-impls/scim-tokens.custom-impl.backend.service.d.ts.map +1 -1
  858. package/dist/esm/security/authentications/services/custom-impls/siem-delivery-dlq.custom-impl.backend.service.d.ts.map +1 -1
  859. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.d.ts.map +1 -1
  860. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.js +57 -1
  861. package/dist/esm/security/authentications/services/custom-impls/sso-config-domain-verification.custom-impl.backend.service.js.map +1 -1
  862. package/dist/esm/security/authentications/services/custom-impls/sso-config.custom-impl.backend.service.d.ts.map +1 -1
  863. package/dist/esm/security/authentications/services/custom-impls/sso-config.custom-impl.backend.service.js.map +1 -1
  864. package/dist/esm/security/authentications/services/custom-impls/sso-connection.custom-impl.backend.service.d.ts.map +1 -1
  865. package/dist/esm/security/authentications/services/custom-impls/sso-connection.custom-impl.backend.service.js +11 -1
  866. package/dist/esm/security/authentications/services/custom-impls/sso-connection.custom-impl.backend.service.js.map +1 -1
  867. package/dist/esm/security/authentications/services/email-verification-initiator.backend.service.d.ts.map +1 -1
  868. package/dist/esm/security/authentications/services/machine-token-issuer.backend.service.d.ts.map +1 -1
  869. package/dist/esm/security/authentications/services/oauth-provider-token.backend.service.d.ts.map +1 -1
  870. package/dist/esm/security/authentications/services/oauth-provider-token.backend.service.js.map +1 -1
  871. package/dist/esm/security/authentications/services/oidc-authorization-code.backend.service.d.ts.map +1 -1
  872. package/dist/esm/security/authentications/services/oidc-authorization-code.backend.service.js.map +1 -1
  873. package/dist/esm/security/authentications/services/oidc-user-claims.backend.service.d.ts.map +1 -1
  874. package/dist/esm/security/authentications/services/resolve-active-member-orgs.backend.utils.d.ts.map +1 -1
  875. package/dist/esm/security/authentications/services/utils/__tests__/mock-auth-user-lookup.service.d.ts.map +1 -1
  876. package/dist/esm/security/authentications/services/utils/auth-controller.utils.d.ts.map +1 -1
  877. package/dist/esm/security/authentications/services/utils/auth-credential-ops.backend.service.d.ts.map +1 -1
  878. package/dist/esm/security/authentications/services/utils/auth-policy-resolution.backend.utils.d.ts.map +1 -1
  879. package/dist/esm/security/authentications/services/utils/auth-policy-resolution.backend.utils.js.map +1 -1
  880. package/dist/esm/security/authentications/services/utils/auth-response-helper.backend.service.d.ts.map +1 -1
  881. package/dist/esm/security/authentications/services/utils/auth-user-lookup.backend.service.d.ts.map +1 -1
  882. package/dist/esm/security/authentications/services/utils/auth-user-lookup.backend.service.js.map +1 -1
  883. package/dist/esm/security/authentications/services/utils/concurrent-session-eviction.backend.utils.d.ts.map +1 -1
  884. package/dist/esm/security/authentications/services/utils/ensure-user-profile.backend.utils.d.ts.map +1 -1
  885. package/dist/esm/security/authentications/services/utils/external-turn-rate-limit.backend.utils.d.ts.map +1 -1
  886. package/dist/esm/security/authentications/services/utils/external-turn-rate-limit.backend.utils.js.map +1 -1
  887. package/dist/esm/security/authentications/services/utils/machine-auth-rate-limit.backend.utils.d.ts.map +1 -1
  888. package/dist/esm/security/authentications/services/utils/pkce.backend.utils.d.ts.map +1 -1
  889. package/dist/esm/security/authentications/services/utils/saml-java-availability.d.ts.map +1 -1
  890. package/dist/esm/security/authentications/utils/application-auth-policy-audit.backend.utils.d.ts.map +1 -1
  891. package/dist/esm/security/authentications/utils/enterprise-sso-enforcement.backend.utils.d.ts.map +1 -1
  892. package/dist/esm/security/authentications/utils/enterprise-sso-enforcement.backend.utils.js.map +1 -1
  893. package/dist/esm/security/authentications/utils/one-off-session-lifetime.backend.utils.d.ts.map +1 -1
  894. package/dist/esm/security/authentications/utils/social-oauth2-purpose.backend.utils.d.ts.map +1 -1
  895. package/dist/esm/security/authorizations/access-grant-decision.factory.backend.d.ts +59 -0
  896. package/dist/esm/security/authorizations/access-grant-decision.factory.backend.d.ts.map +1 -0
  897. package/dist/esm/security/authorizations/access-grant-decision.factory.backend.js +111 -0
  898. package/dist/esm/security/authorizations/access-grant-decision.factory.backend.js.map +1 -0
  899. package/dist/esm/security/authorizations/access-grant-lifecycle-audit.backend.d.ts +57 -0
  900. package/dist/esm/security/authorizations/access-grant-lifecycle-audit.backend.d.ts.map +1 -0
  901. package/dist/esm/security/authorizations/access-grant-lifecycle-audit.backend.js +133 -0
  902. package/dist/esm/security/authorizations/access-grant-lifecycle-audit.backend.js.map +1 -0
  903. package/dist/esm/security/authorizations/application-access-grant-custom-implementation.backend.service.d.ts +41 -0
  904. package/dist/esm/security/authorizations/application-access-grant-custom-implementation.backend.service.d.ts.map +1 -0
  905. package/dist/esm/security/authorizations/application-access-grant-custom-implementation.backend.service.js +157 -0
  906. package/dist/esm/security/authorizations/application-access-grant-custom-implementation.backend.service.js.map +1 -0
  907. package/dist/esm/security/authorizations/application-wide-read-admission.backend.d.ts +84 -0
  908. package/dist/esm/security/authorizations/application-wide-read-admission.backend.d.ts.map +1 -0
  909. package/dist/esm/security/authorizations/application-wide-read-admission.backend.js +99 -0
  910. package/dist/esm/security/authorizations/application-wide-read-admission.backend.js.map +1 -0
  911. package/dist/esm/security/authorizations/authorization-denial-audit.backend.utils.d.ts.map +1 -1
  912. package/dist/esm/security/authorizations/cross-tenant-read-observation.backend.d.ts.map +1 -1
  913. package/dist/esm/security/authorizations/cross-tenant-read-observation.backend.js.map +1 -1
  914. package/dist/esm/security/authorizations/initiator-organization-confinement.backend.d.ts.map +1 -1
  915. package/dist/esm/security/authorizations/junction-scope-resolution.backend.d.ts.map +1 -1
  916. package/dist/esm/security/authorizations/organization-owner-floor.backend.utils.d.ts.map +1 -1
  917. package/dist/esm/security/authorizations/organization-owner-floor.backend.utils.js.map +1 -1
  918. package/dist/esm/security/authorizations/organization-unit-narrowing-enforcement.backend.d.ts.map +1 -1
  919. package/dist/esm/security/authorizations/platform-access-grant-custom-implementation.backend.service.d.ts.map +1 -1
  920. package/dist/esm/security/authorizations/platform-access-grant-custom-implementation.backend.service.js +20 -181
  921. package/dist/esm/security/authorizations/platform-access-grant-custom-implementation.backend.service.js.map +1 -1
  922. package/dist/esm/security/authorizations/privileged-access-review.backend.utils.d.ts.map +1 -1
  923. package/dist/esm/security/authorizations/relationship-foreign-key-filter.backend.d.ts.map +1 -1
  924. package/dist/esm/security/authorizations/role-ceiling.backend.utils.d.ts.map +1 -1
  925. package/dist/esm/security/authorizations/role-ceiling.backend.utils.js.map +1 -1
  926. package/dist/esm/security/authorizations/role-conferral.backend.utils.d.ts +40 -0
  927. package/dist/esm/security/authorizations/role-conferral.backend.utils.d.ts.map +1 -1
  928. package/dist/esm/security/authorizations/role-conferral.backend.utils.js +43 -1
  929. package/dist/esm/security/authorizations/role-conferral.backend.utils.js.map +1 -1
  930. package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.d.ts +27 -17
  931. package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.d.ts.map +1 -1
  932. package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.js +27 -17
  933. package/dist/esm/security/authorizations/scope-root-collection-confinement.backend.js.map +1 -1
  934. package/dist/esm/security/authorizations/services/authorizations.backend.service.d.ts +72 -0
  935. package/dist/esm/security/authorizations/services/authorizations.backend.service.d.ts.map +1 -1
  936. package/dist/esm/security/authorizations/services/authorizations.backend.service.js +153 -10
  937. package/dist/esm/security/authorizations/services/authorizations.backend.service.js.map +1 -1
  938. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.d.ts.map +1 -1
  939. package/dist/esm/security/authorizations/super-admin-floor.backend.utils.js.map +1 -1
  940. package/dist/esm/security/connected-accounts/connection-target-authorization.backend.d.ts.map +1 -1
  941. package/dist/esm/security/connected-accounts/connection-target-authorization.backend.js.map +1 -1
  942. package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.d.ts +139 -1
  943. package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.d.ts.map +1 -1
  944. package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.js +474 -33
  945. package/dist/esm/security/connected-accounts/controllers/provider-connection.controller.backend.service.js.map +1 -1
  946. package/dist/esm/security/connected-accounts/organization-provider-credential-resolver.port.d.ts +40 -0
  947. package/dist/esm/security/connected-accounts/organization-provider-credential-resolver.port.d.ts.map +1 -1
  948. package/dist/esm/security/connected-accounts/organization-provider-credential-resolver.port.js.map +1 -1
  949. package/dist/esm/security/connected-accounts/provider-oauth2-refresher.port.d.ts.map +1 -1
  950. package/dist/esm/security/connected-accounts/provider-oauth2-refresher.port.js.map +1 -1
  951. package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.d.ts +19 -0
  952. package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.d.ts.map +1 -1
  953. package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.js +38 -0
  954. package/dist/esm/security/connected-accounts/services/organization-provider-credential-store.backend.service.js.map +1 -1
  955. package/dist/esm/security/connected-accounts/services/organization-provider-credentials.custom-impl.backend.service.d.ts.map +1 -1
  956. package/dist/esm/security/connected-accounts/services/organization-provider-credentials.custom-impl.backend.service.js.map +1 -1
  957. package/dist/esm/security/connected-accounts/services/provider-oauth2-exchange.backend.d.ts.map +1 -1
  958. package/dist/esm/security/connected-accounts/services/provider-oauth2-exchange.backend.js +17 -1
  959. package/dist/esm/security/connected-accounts/services/provider-oauth2-exchange.backend.js.map +1 -1
  960. package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.d.ts +14 -0
  961. package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.d.ts.map +1 -1
  962. package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.js +16 -0
  963. package/dist/esm/security/connected-accounts/services/provider-oauth2-pending-authorization.backend.service.js.map +1 -1
  964. package/dist/esm/security/connected-accounts/services/provider-oauth2-refresher.backend.service.d.ts.map +1 -1
  965. package/dist/esm/security/connected-accounts/services/provider-oauth2-refresher.backend.service.js +1 -1
  966. package/dist/esm/security/connected-accounts/services/provider-oauth2-refresher.backend.service.js.map +1 -1
  967. package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.d.ts +19 -0
  968. package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.d.ts.map +1 -1
  969. package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.js +45 -2
  970. package/dist/esm/security/connected-accounts/services/user-provider-credential-store.backend.service.js.map +1 -1
  971. package/dist/esm/security/connected-accounts/services/user-provider-credentials.custom-impl.backend.service.d.ts.map +1 -1
  972. package/dist/esm/security/connected-accounts/services/user-provider-credentials.custom-impl.backend.service.js.map +1 -1
  973. package/dist/esm/security/connected-accounts/user-provider-credential-resolver.port.d.ts +37 -1
  974. package/dist/esm/security/connected-accounts/user-provider-credential-resolver.port.d.ts.map +1 -1
  975. package/dist/esm/security/connected-accounts/user-provider-credential-resolver.port.js.map +1 -1
  976. package/dist/esm/security/connected-accounts/utils/provider-credential-envelope.backend.utils.d.ts.map +1 -1
  977. package/dist/esm/security/connected-accounts/utils/provider-credential-envelope.backend.utils.js.map +1 -1
  978. package/dist/esm/security/connected-accounts/utils/stored-credential-value.backend.utils.d.ts.map +1 -1
  979. package/dist/esm/security/connected-accounts/utils/stored-credential-value.backend.utils.js.map +1 -1
  980. package/dist/esm/security/connected-accounts/utils/user-delegated-access-token-slot.backend.utils.d.ts +34 -0
  981. package/dist/esm/security/connected-accounts/utils/user-delegated-access-token-slot.backend.utils.d.ts.map +1 -0
  982. package/dist/esm/security/connected-accounts/utils/user-delegated-access-token-slot.backend.utils.js +39 -0
  983. package/dist/esm/security/connected-accounts/utils/user-delegated-access-token-slot.backend.utils.js.map +1 -0
  984. package/dist/esm/security/consumable-tokens/batches/consumable-tokens-cleanup.batch.backend.service.d.ts.map +1 -1
  985. package/dist/esm/security/consumable-tokens/consumable-token-models.exports.d.ts.map +1 -1
  986. package/dist/esm/security/consumable-tokens/models/consumable-tokens.backend.resources-config.schemas.d.ts.map +1 -1
  987. package/dist/esm/security/consumable-tokens/models/consumable-tokens.shared.schemas.d.ts.map +1 -1
  988. package/dist/esm/security/consumable-tokens/models/index.d.ts.map +1 -1
  989. package/dist/esm/security/consumable-tokens/services/__tests__/mock-consumable-token.service.d.ts.map +1 -1
  990. package/dist/esm/security/consumable-tokens/services/consumable-token.backend.service.d.ts.map +1 -1
  991. package/dist/esm/security/consumable-tokens/services/consumable-token.backend.service.js.map +1 -1
  992. package/dist/esm/security/credential-rotation-grace.backend.utils.d.ts.map +1 -1
  993. package/dist/esm/security/credential-rotation-grace.backend.utils.js.map +1 -1
  994. package/dist/esm/security/jwt/services/auth-jwt-guard.backend.service.d.ts.map +1 -1
  995. package/dist/esm/security/jwt/services/jwt.backend.service.d.ts.map +1 -1
  996. package/dist/esm/security/jwt/services/wildo-worker-bootstrap-client.backend.service.d.ts +13 -0
  997. package/dist/esm/security/jwt/services/wildo-worker-bootstrap-client.backend.service.d.ts.map +1 -1
  998. package/dist/esm/security/jwt/services/wildo-worker-bootstrap-client.backend.service.js +14 -0
  999. package/dist/esm/security/jwt/services/wildo-worker-bootstrap-client.backend.service.js.map +1 -1
  1000. package/dist/esm/security/jwt/utils/jwt-verification-error-classification.backend.utils.d.ts.map +1 -1
  1001. package/dist/esm/security/oauth-clients/oauth-client-generation.backend.utils.d.ts.map +1 -1
  1002. package/dist/esm/security/oauth-clients/oauth-client-generation.backend.utils.js.map +1 -1
  1003. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.d.ts.map +1 -1
  1004. package/dist/esm/security/oauth-clients/oauth-clients.custom-impl.backend.service.js.map +1 -1
  1005. package/dist/esm/security/outbound/outbound-request-deadline.backend.utils.d.ts +39 -0
  1006. package/dist/esm/security/outbound/outbound-request-deadline.backend.utils.d.ts.map +1 -0
  1007. package/dist/esm/security/outbound/outbound-request-deadline.backend.utils.js +60 -0
  1008. package/dist/esm/security/outbound/outbound-request-deadline.backend.utils.js.map +1 -0
  1009. package/dist/esm/security/outbound/outbound-request-headers.backend.utils.d.ts +66 -0
  1010. package/dist/esm/security/outbound/outbound-request-headers.backend.utils.d.ts.map +1 -0
  1011. package/dist/esm/security/outbound/outbound-request-headers.backend.utils.js +75 -0
  1012. package/dist/esm/security/outbound/outbound-request-headers.backend.utils.js.map +1 -0
  1013. package/dist/esm/security/scim/controllers/scim.backend.controller.d.ts.map +1 -1
  1014. package/dist/esm/security/scim/controllers/scim.backend.controller.js.map +1 -1
  1015. package/dist/esm/security/scim/models/scim-protocol.backend.schemas.d.ts.map +1 -1
  1016. package/dist/esm/security/scim/models/scim-protocol.backend.schemas.js.map +1 -1
  1017. package/dist/esm/security/scim/utils/scim-attribute-path-resolver.backend.utils.d.ts.map +1 -1
  1018. package/dist/esm/security/scim/utils/scim-filter-parser.d.ts.map +1 -1
  1019. package/dist/esm/security/scim/utils/scim-response-formatter.d.ts.map +1 -1
  1020. package/dist/esm/security/session-invalidation-fence.backend.utils.d.ts.map +1 -1
  1021. package/dist/esm/security/ssrf/outbound-target-guard.backend.utils.d.ts.map +1 -1
  1022. package/dist/esm/security/ssrf/outbound-target-guard.backend.utils.js.map +1 -1
  1023. package/dist/esm/security/ssrf/pinned-outbound-fetch.backend.utils.d.ts.map +1 -1
  1024. package/dist/esm/security/ssrf/pinned-outbound-fetch.backend.utils.js.map +1 -1
  1025. package/dist/esm/security/token-invalidation-fence.backend.utils.d.ts.map +1 -1
  1026. package/dist/esm/testing.d.ts.map +1 -1
  1027. package/dist/esm/users/services/inbound-contact-custom-implementation.backend.service.d.ts.map +1 -1
  1028. package/dist/esm/users/services/user-deletion-audit.custom-impl.backend.service.d.ts.map +1 -1
  1029. package/dist/esm/users/services/user-force-password-reset.custom-impl.backend.service.d.ts.map +1 -1
  1030. package/dist/esm/users/services/user-read-retained.custom-impl.backend.service.d.ts.map +1 -1
  1031. package/dist/esm/users/services/user-read-retained.custom-impl.backend.service.js.map +1 -1
  1032. package/dist/esm/users/services/user-role-administration.custom-impl.backend.service.d.ts.map +1 -1
  1033. package/dist/esm/users/services/user-self-custom-implementations.backend.d.ts.map +1 -1
  1034. package/dist/esm/users/services/user-super-admin-floor.custom-impl.backend.service.d.ts.map +1 -1
  1035. package/dist/tsconfig.build.tsbuildinfo +1 -1
  1036. package/package.json +9 -9
  1037. package/dist/esm/external-providers/services/flow-actor-design.backend.service.d.ts +0 -45
  1038. package/dist/esm/external-providers/services/flow-actor-design.backend.service.d.ts.map +0 -1
  1039. package/dist/esm/external-providers/services/flow-actor-design.backend.service.js +0 -22
  1040. package/dist/esm/external-providers/services/flow-actor-design.backend.service.js.map +0 -1
  1041. package/dist/esm/notifications/email/models/email-context-provider.interface.d.ts +0 -0
  1042. package/dist/esm/notifications/email/models/email-context-provider.interface.d.ts.map +0 -0
  1043. package/dist/esm/notifications/email/models/email-context-provider.interface.js +0 -0
  1044. package/dist/esm/notifications/email/models/email-context-provider.interface.js.map +0 -0
  1045. package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.d.ts +0 -0
  1046. package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.d.ts.map +0 -0
  1047. package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.js +0 -0
  1048. package/dist/esm/notifications/email/services/email-context-provider-registry.backend.service.js.map +0 -0
  1049. package/dist/esm/notifications/email/services/email-template-compiler.backend.service.d.ts +0 -0
  1050. package/dist/esm/notifications/email/services/email-template-compiler.backend.service.d.ts.map +0 -0
  1051. package/dist/esm/notifications/email/services/email-template-compiler.backend.service.js +0 -0
  1052. package/dist/esm/notifications/email/services/email-template-compiler.backend.service.js.map +0 -0
  1053. package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.d.ts +0 -0
  1054. package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.d.ts.map +0 -0
  1055. package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.js +0 -0
  1056. package/dist/esm/notifications/email/services/email-template-sandbox.backend.service.js.map +0 -0
@@ -27,26 +27,36 @@ import type { SocketAuthResult } from '../../runtime/models/execution-context.ba
27
27
  *
28
28
  * Backend services a tool may use at execution time (supplied by the caller).
29
29
  *
30
- * ⚠️ **Two of these are OBLIGATIONS, not conveniences, for a hand-written tool that dispatches a
31
- * resource operation.**
30
+ * ⚠️ **If your tool DISPATCHES a resource operation, call `dispatchResourceOperationAsTool` — do not
31
+ * reach for these services yourself.**
32
32
  *
33
- * A tool enters at the SERVICE tier, bypassing Express — so the two gates that live on the HTTP
34
- * controller never run for it. `resourceReadTool` and `resourceWriteTool` discharge both on your
35
- * behalf. A tool you write yourself owes the same two calls:
33
+ * A tool enters at the SERVICE tier, bypassing Express, so two gates that live on the HTTP
34
+ * controller never run for it: the operation's declared `roles` ACL and its authored `rateLimit?`.
35
+ * `dispatchResourceOperationAsTool` resolves the operation, builds the scoped execution context,
36
+ * applies both gates in the right order and dispatches — one exported call, and the same one
37
+ * `resourceReadTool` and `resourceWriteTool` use.
36
38
  *
37
- * | gate | why the service tier does not apply it | what your tool must call |
38
- * |---|---|---|
39
- * | the operation's declared `roles` ACL | it is a CONTROLLER-tier gate; the service verbs deliberately apply no role check, because their dominant population is the authentication reads that run BEFORE a role-bearing principal exists | `ctx.services.authorizer.authorizeInController(...)` |
40
- * | the operation's authored `rateLimit?` policy | the declared policy's only other consumer is the HTTP controller pre-flight | `ctx.services.rateLimitService.checkPolicyForSubject(...)` |
39
+ * ```ts
40
+ * const rows = await dispatchResourceOperationAsTool({
41
+ * ctx, resourceType: 'todos', operationIdentifier: CoreResourceOperation.LIST,
42
+ * data: { filter: undefined, page: 1, limit: 20 }, options: { paginated: true },
43
+ * });
44
+ * ```
41
45
  *
42
- * Both are on THIS interface for exactly that reason. The factories below wrap them in the private
43
- * helpers `authorizeToolDispatch` / `assertDeclaredOperationRateLimit`, which are module-scoped and
44
- * not importable — a hand-written tool calls the services directly.
46
+ * **This prose used to name two calls a hand-written tool owed, and both were module-private (#556)
47
+ * — so an author who read it and agreed could not discharge the obligation.** Naming ONE importable
48
+ * call replaces that: the correct path is now also the shortest, which is the only mechanism that
49
+ * survives an author who has not read this paragraph.
45
50
  *
46
- * Skipping the first means a caller whose roles the operation REFUSES, but whose tenancy admits the
47
- * row, succeeds — the operation's `accessControl` simply unenforced on this plane. That is right for
48
- * a framework-internal caller and wrong here, where the caller is an external principal naming an
49
- * operation on their own authority.
51
+ * Skipping the gates means a caller whose roles the operation REFUSES, but whose tenancy admits the
52
+ * row, succeeds — the operation's `accessControl` simply unenforced on this plane. It is quiet:
53
+ * tenancy still applies, so the tool returns the caller's own tenant's rows and LOOKS like it works.
54
+ * That is right for a framework-internal caller and wrong here, where the caller is an external
55
+ * principal naming an operation on their own authority.
56
+ *
57
+ * The services below remain on this interface because the seam is built from them, and because a
58
+ * tool that dispatches NOTHING — a calculator, a formatter, a unit converter — is a legitimate shape
59
+ * that needs neither gate.
50
60
  *
51
61
  * What you still get for free, on every tool: the repository's contextual filter in full — tenancy,
52
62
  * relationship narrowing, organization-unit narrowing, the anonymous guard and the retention hide,
@@ -158,6 +168,87 @@ export interface FunctionTool {
158
168
  */
159
169
  requiresHumanApproval?: boolean;
160
170
  }
171
+ /** @wildo_source:part:end saas.backend.flows-actors.function-tool */
172
+ /**
173
+ * The name a `functionRef` is exposed to the model under.
174
+ *
175
+ * Provider tool names must be identifier-safe and a `functionRef` uses dots, so the two differ for
176
+ * every tool. ONE definition, because the mapping is used in opposite directions by two sites: the
177
+ * turn BUILDS the tool set from refs, and a resume that re-signs a modified approval must find the
178
+ * FunctionTool behind a name it reads back out of the model SDK's own message array. A second copy
179
+ * of this expression would make an approval unmodifiable for exactly the refs the two spelled
180
+ * differently.
181
+ *
182
+ * Not injective by construction (`a.b` and `a_b` collapse), and deliberately not made so: the
183
+ * forward direction is what the model sees, and a reverse lookup resolves against ONE agent's
184
+ * declared refs, where a collision would already be an authoring defect.
185
+ */
186
+ export declare function modelToolNameForFunctionRef(functionRef: string): string;
187
+ /**
188
+ * Dispatch a resource operation from a function tool, carrying BOTH gates the service tier skips.
189
+ *
190
+ * ## What this exists to prevent (#556)
191
+ *
192
+ * A `FunctionTool` enters at the SERVICE tier. It never passes through Express, so two
193
+ * controller-tier gates are simply absent from its path — the operation's declared `roles` ACL and
194
+ * its declared `rateLimit?`. That skip is CORRECT for the service tier's intended caller (the
195
+ * authentication reads that run before a role-bearing principal exists) and wrong for this plane,
196
+ * whose caller is an external principal naming an operation on their own authority.
197
+ *
198
+ * The failure is quiet, which is what makes it worth a seam. Tenancy still applies — the
199
+ * repository's contextual filter runs regardless — so an unauthorized tool returns the caller's own
200
+ * tenant's rows and LOOKS like it works. Nothing throws and nothing logs. What is missing is only
201
+ * the row-level `roles` ACL: a caller whose roles the operation refuses, but whose tenancy admits
202
+ * the row, succeeds.
203
+ *
204
+ * Until this existed the two gates were applied by hand at three sites in this file, and both helpers
205
+ * were module-private — so an application author writing their own tool could not discharge the
206
+ * obligation even after reading about it. The engine's own rule
207
+ * (`invariant-call-site-enumeration.md`) asks for the opposite: prefer making the invariant
208
+ * unbypassable over applying it N times. **This is the shortest path to a dispatch, so the correct
209
+ * path is also the easy one.**
210
+ *
211
+ * ## The order is authorize → charge → dispatch, and it is not arbitrary
212
+ *
213
+ * Authorization first, so an unauthorized caller cannot spend an authorized caller's quota. The
214
+ * charge before the dispatch, so a refused budget costs no work. This is the same order the MCP
215
+ * plane uses, deliberately — one refusal vocabulary across every plane that enters here.
216
+ *
217
+ * ## One id, two uses, and why that is safer than two parameters
218
+ *
219
+ * `recordId` addresses the row AND is the authorization subject, because at every existing call site
220
+ * those are the same value: an UPDATE passes the id to both, a CREATE/LIST/SEARCH passes it to
221
+ * neither. Splitting them into two parameters would make it possible to authorize a collection call
222
+ * while dispatching a row call — a question nobody asked, failing for the wrong reason. A bulk
223
+ * operation addressed by a FILTER passes `dispatchFilter` instead, which is never an authorization
224
+ * subject because a filter-addressed operation IS a collection call.
225
+ *
226
+ * assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — an external caller reaching a resource operation
227
+ * off the HTTP plane is held to that operation's own declared authority, through the same predicate.
228
+ *
229
+ * @throws AUTHORIZATION when the operation's roles refuse the caller — surfaced to the model as a
230
+ * tool error, so the agent can say it was refused. Recorded by the authorizer's own denial-audit
231
+ * funnel, so the evidence matches a denied HTTP request.
232
+ * @throws RATE_LIMIT (429) carrying `context.retryAfterSeconds`, the same envelope the HTTP and MCP
233
+ * seams throw.
234
+ * @throws NOT_FOUND when the resource declares no dispatchable operation under that identifier.
235
+ */
236
+ export declare function dispatchResourceOperationAsTool<TResult = any>(input: {
237
+ ctx: FunctionToolExecutionContext;
238
+ resourceType: ResourceType;
239
+ /** A `CoreResourceOperation` member, or a custom operation identifier the resource declares. */
240
+ operationIdentifier: string;
241
+ /** The addressed row, for a row-scoped operation. Authorizes AND addresses; omit for a collection call. */
242
+ recordId?: string;
243
+ /** A filter addressing a COLLECTION, for a bulk operation. Never an authorization subject. */
244
+ dispatchFilter?: any;
245
+ /** Parent / context resource ids used to build the scoped execution context. */
246
+ contextIds?: any;
247
+ /** The operation payload — the body for a write, the query options for a read. */
248
+ data?: any;
249
+ /** Repository options passed through, e.g. `{ paginated: true }` for a LIST envelope. */
250
+ options?: any;
251
+ }): Promise<TResult>;
161
252
  /**
162
253
  * @wildo_source:part:start saas.backend.flows-actors.resource-read-tool facet:layer:backend facet:family:flows-actors
163
254
  *
@@ -1 +1 @@
1
- {"version":3,"file":"function-tools.backend.definitions.d.ts","sourceRoot":"","sources":["../../../../../src/flows-actors/models/function-tools.backend.definitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,qBAAqB,EAKrB,KAAK,YAAY,EAGlB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oFAAoF,CAAC;AAEvI,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,+EAA+E,CAAC;AAC3I,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+DAA+D,CAAC;AAC7G,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,0EAA0E,CAAC;AAChI,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,6FAA6F,CAAC;AACzJ,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAC;AAE5G;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,WAAW,6BAA6B;IAC5C,iBAAiB,EAAE,+BAA+B,CAAC;IACnD,uBAAuB,EAAE,qCAAqC,CAAC;IAC/D,uBAAuB,EAAE,qCAAqC,CAAC;IAC/D;;;;;;;;;OASG;IACH,gBAAgB,EAAE,uBAAuB,CAAC;IAC1C;;;;;;;;;;;;;;;OAeG;IACH,UAAU,EAAE,4BAA4B,CAAC;CAC1C;AACD,iFAAiF;AAEjF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,4B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ACjC,GACA,YAAY,CAuDd"}
1
+ {"version":3,"file":"function-tools.backend.definitions.d.ts","sourceRoot":"","sources":["../../../../src/flows-actors/models/function-tools.backend.definitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,qBAAqB,EAKrB,KAAK,YAAY,EAGlB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oFAAoF,CAAC;AAEvI,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,+EAA+E,CAAC;AAC3I,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+DAA+D,CAAC;AAC7G,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,0EAA0E,CAAC;AAChI,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,6FAA6F,CAAC;AACzJ,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qEAAqE,CAAC;AAE5G;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,WAAW,6BAA6B;IAC5C,iBAAiB,EAAE,+BAA+B,CAAC;IACnD,uBAAuB,EAAE,qCAAqC,CAAC;IAC/D,uBAAuB,EAAE,qCAAqC,CAAC;IAC/D;;;;;;;;;OASG;IACH,gBAAgB,EAAE,uBAAuB,CAAC;IAC1C;;;;;;;;;;;;;;;OAeG;IACH,UAAU,EAAE,4BAA4B,CAAC;CAC1C;AACD,iFAAiF;AAEjF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,4BAA4B;IAC3C,mEAAmE;IACnE,IAAI,EAAE,gBAAgB,CAAC;IACvB,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yCAAyC;IACzC,QAAQ,EAAE,6BAA6B,CAAC;CACzC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,YAAY;IAC3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AQ,CAAC,EAAE,MAAM,CAAA;CAAE,GACjG,YAAY,CAoFd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,YAAY,EAC1B,EAAE,EAAE,qBAAqB,CAAC,MAAM,GAAG,qBAAqB,CAAC,MAAM,EAC/D,OAAO,EAAE;IACP,WAAW,EAAE,CAAC,CAAC,UAAU,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;OAQG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,GACA,YAAY,CAsDd"}
@@ -2,6 +2,24 @@ import { z } from 'zod';
2
2
  import { CoreResourceOperation, ErrorType, ResourceOperationVariantType, ResourcesConfig_OperationPathUtils, isWildoBackendError, } from '@wildo-ai/saas-models';
3
3
  import { toResponseSafeToolOutput } from '../../base-classes/services/controllers/utils/operation-response-serializer.backend.utils.js';
4
4
  import { resolveDeclaredPolicySubjectKey } from '../../security/authentications/services/utils/external-turn-rate-limit.backend.utils.js';
5
+ /** @wildo_source:part:end saas.backend.flows-actors.function-tool */
6
+ /**
7
+ * The name a `functionRef` is exposed to the model under.
8
+ *
9
+ * Provider tool names must be identifier-safe and a `functionRef` uses dots, so the two differ for
10
+ * every tool. ONE definition, because the mapping is used in opposite directions by two sites: the
11
+ * turn BUILDS the tool set from refs, and a resume that re-signs a modified approval must find the
12
+ * FunctionTool behind a name it reads back out of the model SDK's own message array. A second copy
13
+ * of this expression would make an approval unmodifiable for exactly the refs the two spelled
14
+ * differently.
15
+ *
16
+ * Not injective by construction (`a.b` and `a_b` collapse), and deliberately not made so: the
17
+ * forward direction is what the model sees, and a reverse lookup resolves against ONE agent's
18
+ * declared refs, where a collision would already be an authoring defect.
19
+ */
20
+ export function modelToolNameForFunctionRef(functionRef) {
21
+ return functionRef.replace(/[^a-zA-Z0-9_-]/g, '_');
22
+ }
5
23
  /** Normalize a handler list/search result (array or paginated) to the tool result shape. */
6
24
  function toReadResult(result, limit) {
7
25
  if (Array.isArray(result)) {
@@ -242,6 +260,79 @@ async function assertDeclaredOperationRateLimit(ctx, operation, resourceType, op
242
260
  }
243
261
  await ctx.services.rateLimitService.checkPolicyForSubject(policy, `agent-tool:resource:${resourceType}:${operationIdentifier}`, subjectKey, ctx.organizationId);
244
262
  }
263
+ /**
264
+ * Dispatch a resource operation from a function tool, carrying BOTH gates the service tier skips.
265
+ *
266
+ * ## What this exists to prevent (#556)
267
+ *
268
+ * A `FunctionTool` enters at the SERVICE tier. It never passes through Express, so two
269
+ * controller-tier gates are simply absent from its path — the operation's declared `roles` ACL and
270
+ * its declared `rateLimit?`. That skip is CORRECT for the service tier's intended caller (the
271
+ * authentication reads that run before a role-bearing principal exists) and wrong for this plane,
272
+ * whose caller is an external principal naming an operation on their own authority.
273
+ *
274
+ * The failure is quiet, which is what makes it worth a seam. Tenancy still applies — the
275
+ * repository's contextual filter runs regardless — so an unauthorized tool returns the caller's own
276
+ * tenant's rows and LOOKS like it works. Nothing throws and nothing logs. What is missing is only
277
+ * the row-level `roles` ACL: a caller whose roles the operation refuses, but whose tenancy admits
278
+ * the row, succeeds.
279
+ *
280
+ * Until this existed the two gates were applied by hand at three sites in this file, and both helpers
281
+ * were module-private — so an application author writing their own tool could not discharge the
282
+ * obligation even after reading about it. The engine's own rule
283
+ * (`invariant-call-site-enumeration.md`) asks for the opposite: prefer making the invariant
284
+ * unbypassable over applying it N times. **This is the shortest path to a dispatch, so the correct
285
+ * path is also the easy one.**
286
+ *
287
+ * ## The order is authorize → charge → dispatch, and it is not arbitrary
288
+ *
289
+ * Authorization first, so an unauthorized caller cannot spend an authorized caller's quota. The
290
+ * charge before the dispatch, so a refused budget costs no work. This is the same order the MCP
291
+ * plane uses, deliberately — one refusal vocabulary across every plane that enters here.
292
+ *
293
+ * ## One id, two uses, and why that is safer than two parameters
294
+ *
295
+ * `recordId` addresses the row AND is the authorization subject, because at every existing call site
296
+ * those are the same value: an UPDATE passes the id to both, a CREATE/LIST/SEARCH passes it to
297
+ * neither. Splitting them into two parameters would make it possible to authorize a collection call
298
+ * while dispatching a row call — a question nobody asked, failing for the wrong reason. A bulk
299
+ * operation addressed by a FILTER passes `dispatchFilter` instead, which is never an authorization
300
+ * subject because a filter-addressed operation IS a collection call.
301
+ *
302
+ * assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — an external caller reaching a resource operation
303
+ * off the HTTP plane is held to that operation's own declared authority, through the same predicate.
304
+ *
305
+ * @throws AUTHORIZATION when the operation's roles refuse the caller — surfaced to the model as a
306
+ * tool error, so the agent can say it was refused. Recorded by the authorizer's own denial-audit
307
+ * funnel, so the evidence matches a denied HTTP request.
308
+ * @throws RATE_LIMIT (429) carrying `context.retryAfterSeconds`, the same envelope the HTTP and MCP
309
+ * seams throw.
310
+ * @throws NOT_FOUND when the resource declares no dispatchable operation under that identifier.
311
+ */
312
+ export async function dispatchResourceOperationAsTool(input) {
313
+ const { ctx, resourceType, operationIdentifier, recordId, dispatchFilter, contextIds, data, options } = input;
314
+ const operation = requireDispatchableOperation(ctx, resourceType, operationIdentifier);
315
+ // Rebuild a scoped ExecutionContext from the CALLER's verified auth for THIS operation. Never
316
+ // reuse one built for another operation: the scope it resolves is operation-specific.
317
+ const executionContext = await ctx.services.executionContextCreator.buildContextFromSocketAuth(ctx.auth, operation, contextIds);
318
+ await authorizeToolDispatch(ctx, executionContext, recordId);
319
+ await assertDeclaredOperationRateLimit(ctx, operation, resourceType, operationIdentifier);
320
+ const operationPath = ResourcesConfig_OperationPathUtils.extractOperationPath(operation);
321
+ const subject = recordId ?? dispatchFilter;
322
+ /*
323
+ * The trailing `options` is OMITTED rather than passed as `undefined` when absent, so this seam
324
+ * calls the dispatcher with exactly the arity each site used before it existed.
325
+ *
326
+ * Behaviourally the two are identical for an optional parameter. What differs is what a test can
327
+ * see: the authorization and write pins here assert the dispatch with `toHaveBeenCalledWith`,
328
+ * which is arity-exact, so a uniform five-argument call would have required editing four tests
329
+ * that guard an authorization path. Preserving the shape proves the refactor changed nothing,
330
+ * which is the property that matters most for the one seam every tool dispatch now goes through.
331
+ */
332
+ return options === undefined
333
+ ? ctx.services.servicesRegistryHandler.doByOperationPath(operationPath, executionContext, subject, data)
334
+ : ctx.services.servicesRegistryHandler.doByOperationPath(operationPath, executionContext, subject, data, options);
335
+ }
245
336
  /**
246
337
  * Is this a REFUSAL the read tool must never launder into a different operation?
247
338
  *
@@ -326,13 +417,18 @@ export function resourceReadTool(resourceType, options) {
326
417
  // which is the documented degradation rather than a refusal.
327
418
  searchOp = resolveDispatchableOperation(ctx, resourceType, CoreResourceOperation.SEARCH);
328
419
  if (searchOp) {
329
- const searchEc = await executionContextCreator.buildContextFromSocketAuth(ctx.auth, searchOp, contextIds);
330
- // Authorize, then charge, then dispatch — the MCP order. Both gates sit inside this try
420
+ // The seam authorizes, charges and dispatches in that order. It sits inside this try
331
421
  // because that is where the dispatch is; the catch below re-throws either refusal so
332
- // neither can be laundered into an ungated LIST.
333
- await authorizeToolDispatch(ctx, searchEc);
334
- await assertDeclaredOperationRateLimit(ctx, searchOp, resourceType, CoreResourceOperation.SEARCH);
335
- searchResult = await servicesRegistryHandler.doByOperationPath(ResourcesConfig_OperationPathUtils.extractOperationPath(searchOp), searchEc, undefined, { searchQuery, filter: undefined });
422
+ // neither can be laundered into an ungated LIST. The operation is resolved twice — once
423
+ // above to decide whether SEARCH is even available, once inside the seam — and that is
424
+ // deliberate: the availability question is this factory's, the gates are the seam's.
425
+ searchResult = await dispatchResourceOperationAsTool({
426
+ ctx,
427
+ resourceType,
428
+ operationIdentifier: CoreResourceOperation.SEARCH,
429
+ contextIds,
430
+ data: { searchQuery, filter: undefined },
431
+ });
336
432
  }
337
433
  }
338
434
  catch (error) {
@@ -355,13 +451,17 @@ export function resourceReadTool(resourceType, options) {
355
451
  // does both twice — two operations were attempted, exactly as two HTTP requests would be, and
356
452
  // that path is only reached when the search dispatch failed for a reason that is not a refusal.
357
453
  const listOp = requireDispatchableOperation(ctx, resourceType, CoreResourceOperation.LIST);
358
- const listEc = await executionContextCreator.buildContextFromSocketAuth(ctx.auth, listOp, contextIds);
359
- await authorizeToolDispatch(ctx, listEc);
360
- await assertDeclaredOperationRateLimit(ctx, listOp, resourceType, CoreResourceOperation.LIST);
361
454
  // `paginated: true` yields the `{ data, pagination }` envelope the LIST response DTO expects
362
455
  // (the same shape the HTTP controller requests) — a bare array would fail the wrapper-DTO
363
456
  // projection in `toResponseSafeToolOutput` below.
364
- const listResult = await servicesRegistryHandler.doByOperationPath(ResourcesConfig_OperationPathUtils.extractOperationPath(listOp), listEc, undefined, { filter: undefined, page: 1, limit }, { paginated: true });
457
+ const listResult = await dispatchResourceOperationAsTool({
458
+ ctx,
459
+ resourceType,
460
+ operationIdentifier: CoreResourceOperation.LIST,
461
+ contextIds,
462
+ data: { filter: undefined, page: 1, limit },
463
+ options: { paginated: true },
464
+ });
365
465
  const safeListResult = await toResponseSafeToolOutput(listOp, listResult);
366
466
  return toReadResult(safeListResult, limit);
367
467
  },
@@ -448,19 +548,19 @@ export function resourceWriteTool(resourceType, op, options) {
448
548
  // Rebuild a scoped ExecutionContext from the CALLER's verified auth for this operation, then
449
549
  // apply the operation's own role + scope ACL against it (fail-closed) before anything is
450
550
  // written. The write runs as the user, never with an ACL bypass.
451
- const ec = await executionContextCreator.buildContextFromSocketAuth(ctx.auth, operation, contextIds);
452
- await authorizeToolDispatch(ctx, ec, isUpdate ? id : undefined);
453
- // The operation's own declared budget, charged after authorization so an unauthorized caller
454
- // cannot spend an authorized one's quota, and before any write happens.
455
- await assertDeclaredOperationRateLimit(ctx, operation, resourceType, op);
456
551
  if (!isUpdate) {
457
- const created = await servicesRegistryHandler.doByOperationPath(operationPath, ec, undefined, args);
552
+ // The seam authorizes as a COLLECTION call (no row addressed), charges the operation's own
553
+ // budget after authorization so an unauthorized caller cannot spend an authorized one's, and
554
+ // writes as the user — never with an ACL bypass.
555
+ const created = await dispatchResourceOperationAsTool({ ctx, resourceType, operationIdentifier: op, contextIds, data: args });
458
556
  // Return the same JSON-safe, response-DTO-projected record the REST endpoint would, so no
459
557
  // `Date`/backend-only/secret reaches the model and the tool-loop CONTINUATION step validates.
460
558
  return toResponseSafeToolOutput(operation, created);
461
559
  }
462
- // UPDATE: the record "id" addresses the row; the remaining fields are the patch.
463
- const updated = await servicesRegistryHandler.doByOperationPath(operationPath, ec, id, patch);
560
+ // UPDATE: the record "id" addresses the row AND is the authorization subject — the seam takes
561
+ // one value for both, which is what makes authorizing a collection call while dispatching a
562
+ // row call unrepresentable.
563
+ const updated = await dispatchResourceOperationAsTool({ ctx, resourceType, operationIdentifier: op, recordId: id, contextIds, data: patch });
464
564
  return toResponseSafeToolOutput(operation, updated);
465
565
  },
466
566
  };
@@ -1 +1 @@
1
- {"version":3,"file":"function-tools.backend.definitions.js","sourceRoot":"","sources":["../../../../../src/flows-actors/models/function-tools.backend.definitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,qBAAqB,EACrB,SAAS,EACT,4BAA4B,EAC5B,kCAAkC,EAClC,mBAAmB,GAIpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,wGAAwG,CAAC;AAClJ,OAAO,EAAE,+BAA+B,EAAE,MAAM,mGAAmG,CAAC;AA6KpJ,4FAA4F;AAC5F,SAAS,YAAY,CAAC,MAAe,EAAE,KAAa;IAClD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,GAAG,KAAK,EAAE,CAAC;IAC5E,CAAC;IACD,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,I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C,CAAC;YACtE,MAAM,aAAa,GAAG,kCAAkC,CAAC,oBAAoB,CAAC,SAAS,CAAkD,CAAC;YAE1I,6FAA6F;YAC7F,yFAAyF;YACzF,iEAAiE;YACjE,MAAM,EAAE,GAAG,MAAM,uBAAuB,CAAC,0BAA0B,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;YACrG,MAAM,qBAAqB,CAAC,GAAG,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YAChE,6FAA6F;YAC7F,wEAAwE;YACxE,MAAM,gCAAgC,CAAC,GAAG,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;YAEzE,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,MAAM,OAAO,GAAG,MAAM,uBAAuB,CAAC,iBAAiB,CAAC,aAAa,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;gBACpG,0FAA0F;gBAC1F,8FAA8F;gBAC9F,OAAO,wBAAwB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YACtD,CAAC;YAED,iFAAiF;YACjF,MAAM,OAAO,GAAG,MAAM,uBAAuB,CAAC,iBAAiB,CAAC,aAAa,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;YAC9F,OAAO,wBAAwB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { z } from 'zod';\nimport {\n CoreResourceOperation,\n ErrorType,\n ResourceOperationVariantType,\n ResourcesConfig_OperationPathUtils,\n isWildoBackendError,\n type ResourceType,\n type ResourceConfiguration_Operation,\n type ResourceConfiguration_OperationPath,\n} from '@wildo-ai/saas-models';\n\nimport { toResponseSafeToolOutput } from '~wildo-backend-lib/base-classes/services/controllers/utils/operation-response-serializer.backend.utils';\nimport { resolveDeclaredPolicySubjectKey } from '~wildo-backend-lib/security/authentications/services/utils/external-turn-rate-limit.backend.utils';\nimport type { AuthorizationsBackendService } from '~wildo-backend-lib/security/authorizations/services/authorizations.backend.service';\nimport type { ExecutionContext } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\nimport type { ExecutionContextCreatorBackendService } from '~wildo-backend-lib/runtime/services/execution-context-creator.backend.service';\nimport type { RateLimitBackendService } from '~wildo-backend-lib/errors/services/rate-limit.backend.service';\nimport type { ResourcesRegistryBackendService } from '~wildo-backend-lib/resources/services/resources-registry.backend.service';\nimport type { ServicesRegistryHandlerBackendService } from '~wildo-backend-lib/base-classes/services/services/services-registry-handler.backend.service';\nimport type { SocketAuthResult } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\n\n/**\n * Function-Tool Contract (backend)\n * ================================\n *\n * An executable tool an AI agent can call during an invocation (the runtime\n * behind an agent's declarative `capabilities.tools.functionRefs`). Unlike the\n * shared agent/system schemas, a `FunctionTool` carries backend execution logic,\n * so it lives in `saas-backend-lib`, not `saas-models`.\n *\n * Tools are registered per-application through\n * `BackendDomainModule.flowsActors.functionTools`, indexed by `functionRef` in\n * the `FlowsActorsRegistryService`, and resolved + wired into the AI-SDK `tools`\n * parameter by `AgentsBackendService` when a streaming invocation runs. The\n * engine supplies the execution *context* (caller identity + backend services)\n * at call time; the tool itself stays a pure, reusable declaration.\n */\n\n/**\n * @wildo_source:part:start saas.backend.flows-actors.tool-dispatch-obligations facet:layer:backend facet:audience:app-developer\n *\n * Backend services a tool may use at execution time (supplied by the caller).\n *\n * ⚠️ **Two of these are OBLIGATIONS, not conveniences, for a hand-written tool that dispatches a\n * resource operation.**\n *\n * A tool enters at the SERVICE tier, bypassing Express — so the two gates that live on the HTTP\n * controller never run for it. `resourceReadTool` and `resourceWriteTool` discharge both on your\n * behalf. A tool you write yourself owes the same two calls:\n *\n * | gate | why the service tier does not apply it | what your tool must call |\n * |---|---|---|\n * | the operation's declared `roles` ACL | it is a CONTROLLER-tier gate; the service verbs deliberately apply no role check, because their dominant population is the authentication reads that run BEFORE a role-bearing principal exists | `ctx.services.authorizer.authorizeInController(...)` |\n * | the operation's authored `rateLimit?` policy | the declared policy's only other consumer is the HTTP controller pre-flight | `ctx.services.rateLimitService.checkPolicyForSubject(...)` |\n *\n * Both are on THIS interface for exactly that reason. The factories below wrap them in the private\n * helpers `authorizeToolDispatch` / `assertDeclaredOperationRateLimit`, which are module-scoped and\n * not importable — a hand-written tool calls the services directly.\n *\n * Skipping the first means a caller whose roles the operation REFUSES, but whose tenancy admits the\n * row, succeeds — the operation's `accessControl` simply unenforced on this plane. That is right for\n * a framework-internal caller and wrong here, where the caller is an external principal naming an\n * operation on their own authority.\n *\n * What you still get for free, on every tool: the repository's contextual filter in full — tenancy,\n * relationship narrowing, organization-unit narrowing, the anonymous guard and the retention hide,\n * all fail-closed — plus the whole operation pipeline of validation, enabled conditions, custom\n * implementation and hooks.\n */\nexport interface FunctionToolExecutionServices {\n resourcesRegistry: ResourcesRegistryBackendService;\n servicesRegistryHandler: ServicesRegistryHandlerBackendService;\n executionContextCreator: ExecutionContextCreatorBackendService;\n /**\n * Enforces an operation's OWN authored `rateLimit?` policy on this plane.\n *\n * Present because a tool DISPATCHES A RESOURCE OPERATION while bypassing Express, so the\n * declared policy's only other consumer — the HTTP controller pre-flight — never runs. A\n * hand-written {@link FunctionTool} that dispatches an operation itself owes the same charge —\n * call `checkPolicyForSubject(...)` on THIS service. (The factories below wrap it in the\n * module-private `assertDeclaredOperationRateLimit`, which is not importable from outside this\n * file; the service on this interface is the reachable path.)\n */\n rateLimitService: RateLimitBackendService;\n /**\n * Applies the dispatched operation's own declared `roles` ACL.\n *\n * Present because a tool enters at the SERVICE tier, and **the role gate is a CONTROLLER-tier\n * gate** — `ServicesRegistryHandlerBackendService`'s verbs apply the repository's contextual\n * filter and the whole operation pipeline, and deliberately apply no role check, because their\n * dominant population is the authentication reads that run before a role-bearing principal\n * exists. That is right for a framework-internal caller and wrong for this plane, whose caller is\n * an external principal (an A2A agent, or a user's own WebSocket) naming an operation on their\n * own authority. Without this the operation's `accessControl` was simply unenforced here: a\n * caller whose roles the operation refuses, but whose tenancy admits the row, succeeded.\n *\n * A hand-written {@link FunctionTool} that dispatches a resource operation owes the same call —\n * `authorizeInController(idOrIds, executionContext)` on THIS service. (The factories below wrap it\n * in the module-private `authorizeToolDispatch`, which is not importable from outside this file.)\n */\n authorizer: AuthorizationsBackendService;\n}\n/** @wildo_source:part:end saas.backend.flows-actors.tool-dispatch-obligations */\n\n/**\n * @wildo_source:part:start saas.backend.flows-actors.function-tool facet:layer:backend facet:family:flows-actors\n *\n * Execution context threaded into every tool call. Carries the CALLER's verified\n * identity (`auth`) so a tool reads/writes as the user with the user's own\n * visibility — never trusting LLM-supplied identity — plus the backend services\n * the tool may use. The engine supplies this at call time; a tool never fabricates\n * identity from the model's arguments.\n *\n * Import path: `@wildo-ai/saas-backend-lib`.\n */\nexport interface FunctionToolExecutionContext {\n /** The authenticated caller (server-verified identity + roles). */\n auth: SocketAuthResult;\n /** Active organization scope for the call, when applicable. */\n organizationId?: string;\n /** Backend services the tool may use. */\n services: FunctionToolExecutionServices;\n}\n\n/**\n * A single agent-callable tool (grounding / action an agent can invoke).\n *\n * Register instances on a backend module's `flowsActors.functionTools`; reference\n * one from an agent's `capabilities.tools.functionRefs` by its `functionRef`. The\n * engine resolves each declared ref into an AI-SDK tool at invocation time and\n * calls `execute(args, context)` with the caller's {@link FunctionToolExecutionContext}\n * (so the tool acts as the user, with the user's own visibility). For reading a\n * resource, prefer the `resourceReadTool(resourceType)` factory over a hand-written\n * tool. Import path: `@wildo-ai/saas-backend-lib`.\n *\n * @example\n * // a custom tool\n * const echoTool: FunctionTool = {\n * functionRef: 'demo.echo',\n * description: 'Echo the provided text back.',\n * inputSchema: z.object({ text: z.string() }),\n * execute: async (args) => ({ echoed: args.text }),\n * };\n */\nexport interface FunctionTool {\n /** Stable id referenced from `agent.capabilities.tools.functionRefs`. */\n functionRef: string;\n /** Natural-language description shown to the model (what the tool does + when). */\n description: string;\n /** Zod schema of the tool's arguments (surfaced to the model). */\n inputSchema: z.ZodTypeAny;\n /** Execute the tool with validated args under the caller's context. */\n execute: (args: any, context: FunctionToolExecutionContext) => Promise<unknown>;\n /**\n * Require a HUMAN decision before this tool runs (human-in-the-loop).\n *\n * When set, a turn that reaches this tool SUSPENDS instead of executing it: the run state is\n * persisted, the execution moves to `AWAITING_APPROVAL`, and the caller is asked to approve or\n * deny. Approving resumes the turn and runs the tool; denying resumes it and tells the model the\n * call was refused, so the agent can respond rather than silently stalling.\n *\n * Declare it on tools whose effect a person should authorise — sending money, emailing a\n * customer, deleting at scale — not on reads.\n *\n * ⚠️ Two things worth knowing before you set this:\n *\n * 1. **It requires a configured approval secret.** Approval decisions are HMAC-signed so a client\n * cannot forge one. A turn that would expose an approval-gated tool with no secret configured\n * REFUSES TO RUN rather than falling back to unsigned approvals — the tools someone bothered to\n * gate are exactly the ones where a forged approval matters most.\n * 2. **This is Wildo's declaration, not the model SDK's.** The engine translates it into the\n * SDK's call-level approval configuration. Do not reach for the SDK's own tool-level\n * `needsApproval`: it is deprecated, and approval is handled at the call level now.\n */\n requiresHumanApproval?: boolean;\n}\n/** @wildo_source:part:end saas.backend.flows-actors.function-tool */\n\n/** Uniform, model-facing result shape for read tools. */\ninterface ResourceReadToolResult {\n data: unknown[];\n pagination?: unknown;\n truncated?: boolean;\n}\n\n/** Normalize a handler list/search result (array or paginated) to the tool result shape. */\nfunction toReadResult(result: unknown, limit: number): ResourceReadToolResult {\n if (Array.isArray(result)) {\n return { data: result.slice(0, limit), truncated: result.length > limit };\n }\n if (result && typeof result === 'object' && 'data' in result && Array.isArray((result as { data: unknown[] }).data)) {\n const paged = result as { data: unknown[]; pagination?: unknown };\n return { data: paged.data.slice(0, limit), pagination: paged.pagination, truncated: paged.data.length > limit };\n }\n return { data: [] };\n}\n\n/**\n * Resolve the operation a tool DISPATCHES for `(resourceType, operationIdentifier)`: the\n * URL-BEARING default, and nothing else.\n *\n * ## The defect this closes — `authorize ≡ advertise ≡ execute`\n *\n * Both factories used to resolve through `getServiceOperationPathDefault`, and they dispatched\n * through the `ServicesRegistryHandlerBackendService` convenience verbs (`create` / `update` /\n * `list` / `search`), which re-resolve the same way. That resolver PREFERS an `INTERNAL_CALL`\n * default over the URL-bearing one — deliberately, because it is the SERVICE layer's native\n * transport and the trusted internal callers it was written for want exactly that. This plane is\n * not one of them: it faces an external principal and advertises a public operation to a model.\n *\n * So for a resource declaring BOTH defaults, the tool advertised one operation and executed\n * another — a different `requestDto` validating the model's arguments, a different response DTO,\n * a different `roles` declaration, and different prefix / postfix / custom-impl side effects.\n *\n * **Measured 2026-09-08, and exactly one resource declares both: `organizations` CREATE.** The\n * divergence there is not cosmetic. Its `INTERNAL_CALL` default is the transport registration owns,\n * so the shared CREATE prefix treats that path as registration-managed and SKIPS the\n * `org_type_creation_restricted` guard that confines creation-policy-managed organization types to\n * the registration flow; and the founding-owner postfix is registered on the DEFAULT `API_CALL`\n * variant ONLY, so the internal path writes no owner membership. An agent tool wired to\n * `resourceWriteTool(ORGANIZATIONS, CREATE)` therefore created a tenant with no owner — precisely\n * the stranded state `administrative-continuity-floors.md` exists to prevent — while also reaching\n * a restricted organization type. The MCP tool plane had already made this exact decision and wrote\n * down the reasoning (`McpServerBackendService.callTool`); this plane simply had not.\n *\n * ## Why \"no URL-bearing default\" now REFUSES, and why that is the safe direction\n *\n * This is a behaviour change, and it is intended. A resource whose only default for an identifier\n * is `INTERNAL_CALL` has NO HTTP surface, and its author reasoned from exactly that: `users` LIST\n * declares `roles: []` and says in as many words that the empty set \"is inert here precisely\n * because it is not URL-bearing\". A tool that dispatched it made a route-less, deliberately\n * unexposed operation reachable by an external agent — the opposite of what the declaration\n * assumed. Refusing is fail-closed, and the refusal names the resource and the operation so an app\n * author who genuinely wants that surface exposed can declare a URL-bearing default for it.\n *\n * @returns the URL-bearing default operation, or `undefined` when the resource declares none.\n */\nfunction resolveDispatchableOperation(\n ctx: FunctionToolExecutionContext,\n resourceType: ResourceType,\n operationIdentifier: string,\n): ResourceConfiguration_Operation<any, any, any> | undefined {\n const { resourcesRegistry } = ctx.services;\n // Non-throwing probe FIRST: `getOperationPathDefault` mints an alert-grade INTERNAL error on its\n // miss path, and merely CONSTRUCTING a Wildo error fires its backend actions (LOG / ALERT /\n // METRICS) before any `catch` could downgrade them. A resource with no URL-bearing default for\n // this identifier is an ordinary, expected shape here — not an incident.\n if (!resourcesRegistry.hasOperationPathDefault(resourceType, operationIdentifier)) {\n return undefined;\n }\n return resourcesRegistry.getOperationFromPath(\n resourcesRegistry.getOperationPathDefault(resourceType, operationIdentifier),\n );\n}\n\n/** {@link resolveDispatchableOperation}, refusing rather than returning `undefined`. */\nfunction requireDispatchableOperation(\n ctx: FunctionToolExecutionContext,\n resourceType: ResourceType,\n operationIdentifier: string,\n): ResourceConfiguration_Operation<any, any, any> {\n const operation = resolveDispatchableOperation(ctx, resourceType, operationIdentifier);\n if (!operation) {\n throw new Error(\n `Agent function tool for \"${resourceType}.${operationIdentifier}\": the resource declares no default URL-bearing `\n + 'variant for this operation, so there is no publicly-advertised operation for the tool to dispatch. Declare an '\n + 'API_CALL default for it, or expose a different operation.',\n );\n }\n return operation;\n}\n\n/**\n * Apply the dispatched operation's OWN `roles` ACL — the gate this plane was missing entirely.\n *\n * ## What was broken\n *\n * A function tool dispatches a resource operation through\n * `ServicesRegistryHandlerBackendService`, i.e. it enters at the SERVICE tier. The service tier\n * applies the repository's contextual filter (tenancy, FK narrowing, unit narrowing, the anonymous\n * guard, the retention row-hide — all fail-closed) and the whole operation pipeline (Zod, enabled\n * conditions, custom impl, hooks). It applies NO role check, and that is deliberate and\n * load-bearing: its dominant population is authentication, SCIM provisioning, webhook routing and\n * sweeps, which run BEFORE a role-bearing principal exists. Enforcing declared roles there would\n * deny the reads that ESTABLISH identity.\n *\n * `AuthorizationsBackendService.authorizeInController` is therefore the ONLY place an operation's\n * declared `roles` are checked, and it is mounted at the CONTROLLER tier — the boundary, because\n * that is where an untrusted principal names an operation.\n *\n * **This plane is that boundary and did not ask.** A tool call arrives from an external principal\n * (an A2A agent's token, or a user's own WebSocket) naming an operation on their own authority, and\n * dispatched it with the role ACL unread. A caller whose roles the operation refuses, but whose\n * tenancy admits the row, succeeded — so `roles: [ORG_MEMBER]` on Wonder Todos' todos CREATE, and\n * `roles: [APP_USER]` on the organizations self-service CREATE, were both statements about the HTTP\n * door only. Worse, the factories' own JSDoc, the app's registration comment and\n * `authenticateExternalToken`'s contract all asserted the opposite, so the gap read as closed.\n *\n * The MCP plane, which faces the same class of caller through a different transport, has always run\n * this gate (`McpServerBackendService.callTool`). This is the same call, on the sibling plane.\n *\n * ## Collection vs row\n *\n * `idOrIds` is `undefined` for CREATE / LIST / SEARCH (collection: roles + parent scope) and the\n * addressed record id for UPDATE (row: additionally FK reachability and per-row access). Passing a\n * value in the row's place for a collection call would authorize a READ of a row whose id happens\n * to be a scope id — a question nobody asked, failing for the wrong reason.\n *\n * Refusals are recorded by the authorizer's own denial-audit funnel, so a tool call denied here\n * produces the same `RESOURCE_OPERATION_DENIED` evidence a denied HTTP request produces.\n *\n * assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — an external caller reaching a resource operation\n * off the HTTP plane is held to that operation's own declared authority, through the same predicate.\n *\n * @throws AUTHORIZATION — surfaced to the model as a tool error, so the agent can say it was refused.\n */\nasync function authorizeToolDispatch(\n ctx: FunctionToolExecutionContext,\n executionContext: ExecutionContext<any>,\n idOrIds?: string,\n): Promise<void> {\n await ctx.services.authorizer.authorizeInController(idOrIds, executionContext);\n}\n\n/**\n * Charge ONE dispatch against the operation's own authored `rateLimit?` policy, before the\n * dispatch happens.\n *\n * ## What was broken\n *\n * `rateLimit?` is authored on an `API_CALL` / `API_CALL_WITH_CALLBACK` variant and had exactly\n * two consumers: `RateLimitBackendService.checkPolicyForVariant` at the HTTP controller\n * pre-flight, and `McpServerBackendService.assertOperationRateLimitPolicy` on the MCP tool plane.\n * The factories below dispatch the SAME operations through the SAME service pipeline while\n * bypassing Express entirely, so the identical operation was throttled over REST, throttled over\n * MCP, and unthrottled as an agent tool.\n *\n * The exposure is larger here than on either of those planes, which is why this is not merely a\n * consistency fix. A2A's blanket per-principal cap (`A2A_EXTERNAL_TURN_RATE_MAX`) bounds TURNS,\n * and one turn's tool loop may issue arbitrarily many tool calls — so an operation declaring\n * `requestsPerMinute: 5` could be dispatched far more than five times a minute by an external\n * caller spending a single turn. MCP has no such multiplier: one `tools/call` is one dispatch, so\n * its transport cap bounds dispatches 1:1.\n *\n * ## The policy is read off the operation actually being DISPATCHED — which is now the right one\n *\n * This guard originally re-resolved the URL-bearing default for itself, because the factories\n * dispatched the `INTERNAL_CALL` default and `rateLimit?` does not exist on that variant at all —\n * so reading the dispatched operation would have made the guard permanently inert for precisely\n * the resources that declare both. That divergence is gone: {@link resolveDispatchableOperation}\n * makes the URL-bearing default the dispatched operation, and this function takes it as an\n * argument. Policy-source and dispatch-target are now the same object rather than two resolutions\n * that agreed by discipline — which is what stops them separating again.\n *\n * Reading a single declaration as the OPERATION's budget is the framework's own established\n * reading of the field, not an invention: `resources-config.shared.factory.ts` projects\n * `rateLimit: defaultApiCallVariant.rateLimit` onto every derived auto-variant, stating that \"a\n * single declaration on the default URL-bearing variant covers all derived auto-variants\".\n *\n * ## Subject: the CREDENTIAL, not the tenant\n *\n * See {@link resolveDeclaredPolicySubjectKey} for the full argument. In short, an authored\n * `requestsPerMinute` has always meant \"per CLIENT\" — the HTTP seam keys on the source IP — so\n * the faithful translation onto a plane whose callers are credentials is the credential, then the\n * delegated user, then the owning scope. Keying on the tenant would silently make the same\n * declared number several times stricter here than over REST for any tenant running more than one\n * agent. Every branch reads a SERVER-VERIFIED field of the caller's auth; nothing here may ever be\n * sourced from a tool argument, or the throttle becomes opt-out by a model choosing a fresh bucket.\n *\n * ## Scope: a THIRD bucket, deliberately\n *\n * `agent-tool:resource:<resource>:<operation>`, distinct from the HTTP seam's\n * `resource:<resource>:<operation>` and MCP's `mcp:resource:<resource>:<operation>`. The three\n * count different SUBJECTS (an IP, a credential, a credential on a different transport); one\n * shared bucket would mix identity spaces and let a browser's traffic spend an agent's budget.\n *\n * ## Ordering: AFTER authorization\n *\n * Reversed 2026-09-08, when the role gate landed beside it, and MCP's argument is adopted verbatim:\n * a caller who may not run the operation at all must be refused with AUTHORIZATION rather than told\n * how much of a budget they have, and must not consume a slot of a budget that is not theirs —\n * which would let an unauthorized caller exhaust an authorized one's quota. The HTTP seam orders\n * these the other way round because it has no choice (`checkPolicyForVariant` runs pre-flight,\n * before the execution context authorization needs exists); here the identity is already resolved,\n * so the safer order is available and is taken.\n *\n * ## Postures\n *\n * - **No declared policy, or a non-HTTP default** -> no-op, zero Redis traffic. The overwhelmingly\n * common case: most operations declare nothing.\n * - **Unkeyable subject with a policy declared** -> REFUSE. This diverges from MCP's\n * proceed-and-log, and the reason is the tool-loop multiplier described above: there, an\n * unkeyed call is still bounded 1:1 by the transport's per-principal cap, so proceeding costs a\n * bounded amount; here an unkeyed turn could drive an uncounted, unbounded loop against an\n * endpoint whose author asked for a budget. The branch is structurally unreachable — a tool runs\n * only inside an authenticated turn, and an authenticated principal always carries one of the\n * four identity fields — so the refusal costs nothing today and cannot decay into a silent hole.\n * - **Limiter outage** -> propagates, exactly as it does over HTTP and MCP for the same declared\n * policy. An authored budget must not quietly become \"unlimited\" on one plane while it is a 500\n * on the others. (Contrast `assertExternalTurnWithinRate`, the framework-default abuse throttle,\n * which fails OPEN because nobody declared it.)\n *\n * ## Call-site enumeration, so the next reader does not re-derive it\n *\n * The invariant is \"a resource operation dispatched on behalf of an external CLIENT is charged\n * against its declared budget\". Enumerated 2026-09-08 over every caller of the generic service\n * dispatch (`doByOperationPath` and the `ServicesRegistryHandlerBackendService` verbs):\n *\n * | Plane | Verdict |\n * |---|---|\n * | REST route (`ControllerResourceBackendService.doOperation`) | charged — `checkPolicyForVariant`, IP-keyed |\n * | MCP `tools/call` (`McpServerBackendService`) | charged — `checkPolicyForSubject`, credential-keyed |\n * | Agent function tool (here; reachable over A2A and the app WebSocket) | charged — this function |\n * | Queue job executor (`job-executor.backend.service.ts`) | **N/A** — a REPLAY of an operation already authorized, and already charged, at enqueue time (`isWorkerExecution: true`). Charging again would double-count one client request and throttle a background worker against a client's budget |\n * | Minion-scoped handler (`saas-minions-lib`) | **N/A** — same worker plane, one scope deeper |\n * | Custom controllers (SCIM, charts, flows-actors) | **N/A** — the separate authoring surface: they declare their own policy and call `checkPolicy` inline (SCIM does, with its own scope key) rather than inheriting a resource operation's |\n * | Engine-internal collaborators (auth, org, RAG, seeding, retention) | **N/A** — not client-driven; reached from a plane that already charged, or from a system path with no client at all |\n *\n * The rule that generalises: a NEW plane that dispatches a resource operation on a client's behalf\n * owes its own `checkPolicyForSubject` call — AND its own `authorizeInController`. Nothing\n * structural forces either; both fields are simply unread where nobody reads them, which is how\n * both the MCP plane and this one shipped unthrottled, and how this one shipped unauthorized.\n *\n * @throws RATE_LIMIT (429) carrying `context.retryAfterSeconds` — the same envelope the HTTP and\n * MCP seams throw, so one refusal vocabulary covers all three planes. The AI SDK surfaces it to\n * the model as a tool error, so the agent can tell the user it is being throttled.\n */\nasync function assertDeclaredOperationRateLimit(\n ctx: FunctionToolExecutionContext,\n operation: ResourceConfiguration_Operation<any, any, any>,\n resourceType: ResourceType,\n operationIdentifier: string,\n): Promise<void> {\n // Defensive: `resolveDispatchableOperation` already filters to URL-bearing variants, so this\n // narrow exists to reach `rateLimit` on the union rather than to exclude a reachable case.\n if (\n operation.variantType !== ResourceOperationVariantType.API_CALL\n && operation.variantType !== ResourceOperationVariantType.API_CALL_WITH_CALLBACK\n ) {\n return;\n }\n const policy = operation.rateLimit;\n if (!policy) {\n return;\n }\n\n const subjectKey = resolveDeclaredPolicySubjectKey(ctx.auth?.initiatorIds);\n if (!subjectKey) {\n throw new Error(\n `Agent function tool for \"${resourceType}.${operationIdentifier}\": the operation declares a rateLimit policy but the `\n + 'caller carries no server-verified identity to count it against, so the declared budget cannot be honoured.',\n );\n }\n\n await ctx.services.rateLimitService.checkPolicyForSubject(\n policy,\n `agent-tool:resource:${resourceType}:${operationIdentifier}`,\n subjectKey,\n ctx.organizationId,\n );\n}\n\n/**\n * Is this a REFUSAL the read tool must never launder into a different operation?\n *\n * Exists for exactly one reason: the read tool's SEARCH branch degrades to a scoped LIST on any\n * throw, and a refusal swallowed there would silently become an UNGATED LIST — the guard present\n * and inert, which is worse than absent because it reads as enforced. Two refusal kinds qualify:\n *\n * - **RATE_LIMIT** — a declared budget is an application's statement about the endpoint, not a\n * reason to reach for a different one.\n * - **AUTHORIZATION** — stronger still. A denial has already been RECORDED by the authorizer's\n * audit funnel, so proceeding would leave a `RESOURCE_OPERATION_DENIED` row beside a request\n * that then succeeded, making the access trail describe something that did not happen.\n *\n * A genuine \"this resource has no URL-bearing SEARCH operation\" still degrades, unchanged.\n */\nfunction isNonDegradableRefusal(error: unknown): boolean {\n return isWildoBackendError(error)\n && (error.type === ErrorType.RATE_LIMIT || error.type === ErrorType.AUTHORIZATION);\n}\n\n/**\n * @wildo_source:part:start saas.backend.flows-actors.resource-read-tool facet:layer:backend facet:family:flows-actors\n *\n * Generic resource-read tool factory. Produces a {@link FunctionTool} that lets\n * an agent look up records of ONE resource type **scoped to the calling user**,\n * with that user's own visibility — no `systemAccessPolicy` bypass. Instantiate\n * it per resource an agent should be able to read (e.g. `resourceReadTool(TODOS)`),\n * making any registered resource agent-readable without hand-writing a tool.\n *\n * The tool dispatches the resource's PUBLIC, URL-bearing default LIST / SEARCH — the same\n * operation a REST client reaches — under a user `ExecutionContext` rebuilt from the caller's\n * socket auth, and applies that operation's own declared `roles` ACL through\n * `AuthorizationsBackendService.authorizeInController` before dispatching it. So the framework's\n * contextual filter AND the role ACL apply exactly as for the user's own request. (The role gate\n * is named explicitly because it does NOT come free with the service path: the service tier\n * applies tenancy and the operation pipeline and no role check, so a tool that merely dispatched\n * would run with the ACL unread — which is what this factory did until 2026-09-08.) A resource\n * that declares no URL-bearing default for the operation is REFUSED rather than served through its\n * route-less internal variant. Identity is NEVER taken\n * from the model — only the `searchQuery` / `limit` args are. Its `functionRef`\n * defaults to `resource.<resourceType>.read` — reference that exact string from\n * your agent's `capabilities.tools.functionRefs`. Import path:\n * `@wildo-ai/saas-backend-lib`.\n *\n * @param resourceType the resource to expose (any registered `ResourceType`).\n * @param options optional `functionRef` / `description` / `defaultLimit` / `maxLimit` overrides.\n * @example\n * // in a backend module's `flowsActors.functionTools` contribution:\n * functionTools: [resourceReadTool(TasksManager_ResourceType.TODOS)]\n * // and on the agent:\n * capabilities: { tools: { functionRefs: ['resource.todos.read'], mcpRefs: [] } }\n */\nexport function resourceReadTool(\n resourceType: ResourceType,\n options?: { functionRef?: string; description?: string; defaultLimit?: number; maxLimit?: number },\n): FunctionTool {\n /** @wildo_source:part:end saas.backend.flows-actors.resource-read-tool */\n const defaultLimit = options?.defaultLimit ?? 50;\n const maxLimit = options?.maxLimit ?? 100;\n\n return {\n functionRef: options?.functionRef ?? `resource.${resourceType}.read`,\n description:\n options?.description ??\n `Look up the current user's \"${resourceType}\" records to answer their questions about them. ` +\n `Optionally pass a free-text searchQuery to narrow the results. Only the current user's own records are ever returned.`,\n inputSchema: z.object({\n searchQuery: z.string().optional(),\n limit: z.number().int().min(1).max(maxLimit).optional(),\n }),\n execute: async (args: { searchQuery?: string; limit?: number }, ctx: FunctionToolExecutionContext): Promise<ResourceReadToolResult> => {\n const { servicesRegistryHandler, executionContextCreator } = ctx.services;\n const limit = typeof args?.limit === 'number' ? Math.min(args.limit, maxLimit) : defaultLimit;\n const searchQuery = typeof args?.searchQuery === 'string' && args.searchQuery.trim().length > 0 ? args.searchQuery.trim() : undefined;\n const contextIds: Record<string, string> = ctx.organizationId ? { organizationId: ctx.organizationId } : {};\n\n // Prefer SEARCH when a query is supplied AND the resource EXPOSES it; fall back to a scoped\n // LIST. Both run as the user, under the operation's own role ACL (no bypass).\n if (searchQuery) {\n // The fallback catch covers ONLY op-resolution + the search call — a resource may expose no\n // SEARCH operation, in which case we degrade to a scoped LIST. It deliberately does NOT wrap\n // the response-DTO projection below: a projection failure there is a real server contract\n // violation (a record that violates its own response DTO) and must surface as a tool error,\n // exactly as it would on the LIST path — never silently degrade to an unfiltered LIST.\n let searchOp: ResourceConfiguration_Operation<any, any, any> | undefined;\n let searchResult: unknown;\n try {\n // Non-throwing: a resource with no URL-bearing SEARCH default has nothing to expose here,\n // which is the documented degradation rather than a refusal.\n searchOp = resolveDispatchableOperation(ctx, resourceType, CoreResourceOperation.SEARCH);\n if (searchOp) {\n const searchEc = await executionContextCreator.buildContextFromSocketAuth(ctx.auth, searchOp, contextIds);\n // Authorize, then charge, then dispatch — the MCP order. Both gates sit inside this try\n // because that is where the dispatch is; the catch below re-throws either refusal so\n // neither can be laundered into an ungated LIST.\n await authorizeToolDispatch(ctx, searchEc);\n await assertDeclaredOperationRateLimit(ctx, searchOp, resourceType, CoreResourceOperation.SEARCH);\n searchResult = await servicesRegistryHandler.doByOperationPath(\n ResourcesConfig_OperationPathUtils.extractOperationPath(searchOp) as ResourceConfiguration_OperationPath<any, any>,\n searchEc,\n undefined,\n { searchQuery, filter: undefined },\n );\n }\n } catch (error) {\n // A declared budget, or a role refusal, is a statement about THIS endpoint — not a reason\n // to reach for a different one. Degrading here would answer the model with LIST results\n // the caller was just refused: enforcement that reports success.\n if (isNonDegradableRefusal(error)) throw error;\n searchOp = undefined; // SEARCH failed to resolve or dispatch — fall through to LIST.\n }\n if (searchOp !== undefined) {\n // Project through the SEARCH operation's response DTO + JSON wire step, exactly as the\n // REST controller does, so no `Date`/backend-only/secret field reaches the model.\n const safeSearchResult = await toResponseSafeToolOutput(searchOp, searchResult);\n return toReadResult(safeSearchResult, limit);\n }\n }\n\n // LIST is a distinct operation with its own ACL and its own declared budget, so it is\n // authorized and charged separately. A call that resolved SEARCH and then degraded to LIST\n // does both twice — two operations were attempted, exactly as two HTTP requests would be, and\n // that path is only reached when the search dispatch failed for a reason that is not a refusal.\n const listOp = requireDispatchableOperation(ctx, resourceType, CoreResourceOperation.LIST);\n const listEc = await executionContextCreator.buildContextFromSocketAuth(ctx.auth, listOp, contextIds);\n await authorizeToolDispatch(ctx, listEc);\n await assertDeclaredOperationRateLimit(ctx, listOp, resourceType, CoreResourceOperation.LIST);\n // `paginated: true` yields the `{ data, pagination }` envelope the LIST response DTO expects\n // (the same shape the HTTP controller requests) — a bare array would fail the wrapper-DTO\n // projection in `toResponseSafeToolOutput` below.\n const listResult = await servicesRegistryHandler.doByOperationPath(\n ResourcesConfig_OperationPathUtils.extractOperationPath(listOp) as ResourceConfiguration_OperationPath<any, any>,\n listEc,\n undefined,\n { filter: undefined, page: 1, limit },\n { paginated: true },\n );\n const safeListResult = await toResponseSafeToolOutput(listOp, listResult);\n return toReadResult(safeListResult, limit);\n },\n };\n}\n\n/**\n * @wildo_source:part:start saas.backend.flows-actors.resource-write-tool facet:layer:backend facet:family:flows-actors\n *\n * Generic resource-WRITE tool factory. The mutating sibling of {@link resourceReadTool}.\n * Produces a {@link FunctionTool} that lets an agent CREATE or UPDATE ONE resource\n * type **as the calling user**, under the caller's own `ExecutionContext` rebuilt\n * from their verified socket auth — no `systemAccessPolicy` bypass, and identity is\n * NEVER taken from the model. It dispatches the resource's PUBLIC, URL-bearing default CREATE /\n * UPDATE — the same operation a REST client reaches, with the same request DTO validating the\n * model's arguments and the same prefix / postfix side effects — and applies that operation's own\n * `accessControl` (roles + parent scope, plus per-row access on UPDATE) through\n * `AuthorizationsBackendService.authorizeInController` before the write. Authorization is therefore\n * **fail-closed**: a caller lacking the operation's role gets a thrown authz error, not a silent\n * write.\n *\n * Both halves of that are load-bearing and neither came free, so do not simplify them away. The\n * service tier applies tenancy and the operation pipeline and NO role check, and the service\n * layer's own default resolver PREFERS a route-less `INTERNAL_CALL` variant over the public one —\n * so before 2026-09-08 this factory dispatched a different operation from the one it advertises,\n * with the ACL unread. On `organizations` CREATE that combination created ownerless tenants.\n *\n * A resource that declares no URL-bearing default for the operation is REFUSED rather than written\n * through its internal variant. Owner FKs and\n * other server-set fields are EC-injected / `excludeFromCreate`, so the model can\n * never spoof ownership through the tool arguments.\n *\n * Unlike the read tool (whose args are a fixed `{ searchQuery, limit }`), a write\n * tool's arguments are resource-specific, so the caller MUST supply the model-facing\n * `inputSchema` — the create/update field contract shown to the model. Keep it to the\n * fields the model should legitimately set. For `UPDATE`, include the record `id` in\n * the schema; the factory splits `id` out to address the row and passes the remaining\n * fields as the patch.\n *\n * `functionRef` defaults to `resource.<resourceType>.<op>` (e.g. `resource.todos.create`)\n * — reference that exact string from your agent's `capabilities.tools.functionRefs`.\n * Import path: `@wildo-ai/saas-backend-lib`.\n *\n * @param resourceType the resource to expose (any registered `ResourceType`).\n * @param op `CoreResourceOperation.CREATE` or `CoreResourceOperation.UPDATE`.\n * @param options `{ inputSchema, functionRef?, description? }` — `inputSchema` is REQUIRED (the model-facing argument contract).\n * @example\n * // in a backend module's `flowsActors.functionTools` contribution:\n * functionTools: [\n * resourceWriteTool(TasksManager_ResourceType.TODOS, CoreResourceOperation.CREATE, {\n * inputSchema: z.object({ title: z.string(), todoListId: z.string(), description: z.string().optional() }),\n * }),\n * ]\n * // and on the agent:\n * capabilities: { tools: { functionRefs: ['resource.todos.create'], mcpRefs: [] } }\n */\nexport function resourceWriteTool(\n resourceType: ResourceType,\n op: CoreResourceOperation.CREATE | CoreResourceOperation.UPDATE,\n options: {\n inputSchema: z.ZodTypeAny;\n functionRef?: string;\n description?: string;\n /**\n * Gate this write behind a HUMAN decision (see {@link FunctionTool.requiresHumanApproval}).\n *\n * Without this passthrough the flag was declarable only by hand-rolling a `FunctionTool`, so\n * the approval gate was unreachable from the factory every app author actually uses — a\n * capability present in the contract and absent from the authoring surface. Reads are not\n * offered the option: approval exists to gate EFFECTS, and gating a read teaches authors to\n * approve things reflexively, which is how an approval prompt stops being read.\n */\n requiresHumanApproval?: boolean;\n },\n): FunctionTool {\n /** @wildo_source:part:end saas.backend.flows-actors.resource-write-tool */\n return {\n functionRef: options.functionRef ?? `resource.${resourceType}.${op}`,\n requiresHumanApproval: options.requiresHumanApproval,\n description:\n options.description ??\n (op === CoreResourceOperation.CREATE\n ? `Create a new \"${resourceType}\" record on behalf of the current user from the provided fields. The record is owned by and scoped to the current user; ownership fields are set by the system, not from the arguments.`\n : `Update an existing \"${resourceType}\" record the current user owns. Pass the record \"id\" plus only the fields to change.`),\n inputSchema: options.inputSchema,\n execute: async (args: Record<string, unknown>, ctx: FunctionToolExecutionContext): Promise<unknown> => {\n const { servicesRegistryHandler, executionContextCreator } = ctx.services;\n const contextIds: Record<string, string> = ctx.organizationId ? { organizationId: ctx.organizationId } : {};\n\n // UPDATE addresses a row; CREATE does not. Split FIRST, before anything is resolved: this is\n // a check on the tool AUTHOR's own `inputSchema`, independent of the registry, and surfacing\n // it ahead of a resolution failure keeps the actionable message the actionable one.\n // `authorizeInController` then takes the addressed id and runs the row-scoped phases only\n // when there is one.\n const isUpdate = op === CoreResourceOperation.UPDATE;\n const { id, ...patch } = args as { id?: string };\n if (isUpdate && (typeof id !== 'string' || id.length === 0)) {\n throw new Error(\n `resourceWriteTool(${resourceType}, update): the \"id\" argument is required — declare it in the tool's inputSchema.`,\n );\n }\n\n // The operation the tool ADVERTISES is the resource's public, URL-bearing default; dispatch\n // that exact one rather than re-resolving through the service layer's INTERNAL-preferred\n // resolver. See `resolveDispatchableOperation` for what diverged and what it cost.\n const operation = requireDispatchableOperation(ctx, resourceType, op);\n const operationPath = ResourcesConfig_OperationPathUtils.extractOperationPath(operation) as ResourceConfiguration_OperationPath<any, any>;\n\n // Rebuild a scoped ExecutionContext from the CALLER's verified auth for this operation, then\n // apply the operation's own role + scope ACL against it (fail-closed) before anything is\n // written. The write runs as the user, never with an ACL bypass.\n const ec = await executionContextCreator.buildContextFromSocketAuth(ctx.auth, operation, contextIds);\n await authorizeToolDispatch(ctx, ec, isUpdate ? id : undefined);\n // The operation's own declared budget, charged after authorization so an unauthorized caller\n // cannot spend an authorized one's quota, and before any write happens.\n await assertDeclaredOperationRateLimit(ctx, operation, resourceType, op);\n\n if (!isUpdate) {\n const created = await servicesRegistryHandler.doByOperationPath(operationPath, ec, undefined, args);\n // Return the same JSON-safe, response-DTO-projected record the REST endpoint would, so no\n // `Date`/backend-only/secret reaches the model and the tool-loop CONTINUATION step validates.\n return toResponseSafeToolOutput(operation, created);\n }\n\n // UPDATE: the record \"id\" addresses the row; the remaining fields are the patch.\n const updated = await servicesRegistryHandler.doByOperationPath(operationPath, ec, id, patch);\n return toResponseSafeToolOutput(operation, updated);\n },\n };\n}\n"]}
1
+ {"version":3,"file":"function-tools.backend.definitions.js","sourceRoot":"","sources":["../../../../src/flows-actors/models/function-tools.backend.definitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,qBAAqB,EACrB,SAAS,EACT,4BAA4B,EAC5B,kCAAkC,EAClC,mBAAmB,GAIpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,wGAAwG,CAAC;AAClJ,OAAO,EAAE,+BAA+B,EAAE,MAAM,mGAAmG,CAAC;AA8KpJ,qEAAqE;AAErE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,2BAA2B,CAAC,WAAmB;IAC7D,OAAO,WAAW,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;AACrD,CAAC;AASD,4FAA4F;AAC5F,SAAS,YAAY,CAAC,MAAe,EAAE,KAAa;IAClD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,GAAG,KAAK,EAAE,CAAC;IAC5E,CAAC;IACD,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAI,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mBAAmB,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YAC7I,OAAO,wBAAwB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { z } from 'zod';\nimport {\n CoreResourceOperation,\n ErrorType,\n ResourceOperationVariantType,\n ResourcesConfig_OperationPathUtils,\n isWildoBackendError,\n type ResourceType,\n type ResourceConfiguration_Operation,\n type ResourceConfiguration_OperationPath,\n} from '@wildo-ai/saas-models';\n\nimport { toResponseSafeToolOutput } from '~wildo-backend-lib/base-classes/services/controllers/utils/operation-response-serializer.backend.utils';\nimport { resolveDeclaredPolicySubjectKey } from '~wildo-backend-lib/security/authentications/services/utils/external-turn-rate-limit.backend.utils';\nimport type { AuthorizationsBackendService } from '~wildo-backend-lib/security/authorizations/services/authorizations.backend.service';\nimport type { ExecutionContext } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\nimport type { ExecutionContextCreatorBackendService } from '~wildo-backend-lib/runtime/services/execution-context-creator.backend.service';\nimport type { RateLimitBackendService } from '~wildo-backend-lib/errors/services/rate-limit.backend.service';\nimport type { ResourcesRegistryBackendService } from '~wildo-backend-lib/resources/services/resources-registry.backend.service';\nimport type { ServicesRegistryHandlerBackendService } from '~wildo-backend-lib/base-classes/services/services/services-registry-handler.backend.service';\nimport type { SocketAuthResult } from '~wildo-backend-lib/runtime/models/execution-context.backend.schemas';\n\n/**\n * Function-Tool Contract (backend)\n * ================================\n *\n * An executable tool an AI agent can call during an invocation (the runtime\n * behind an agent's declarative `capabilities.tools.functionRefs`). Unlike the\n * shared agent/system schemas, a `FunctionTool` carries backend execution logic,\n * so it lives in `saas-backend-lib`, not `saas-models`.\n *\n * Tools are registered per-application through\n * `BackendDomainModule.flowsActors.functionTools`, indexed by `functionRef` in\n * the `FlowsActorsRegistryService`, and resolved + wired into the AI-SDK `tools`\n * parameter by `AgentsBackendService` when a streaming invocation runs. The\n * engine supplies the execution *context* (caller identity + backend services)\n * at call time; the tool itself stays a pure, reusable declaration.\n */\n\n/**\n * @wildo_source:part:start saas.backend.flows-actors.tool-dispatch-obligations facet:layer:backend facet:audience:app-developer\n *\n * Backend services a tool may use at execution time (supplied by the caller).\n *\n * ⚠️ **If your tool DISPATCHES a resource operation, call `dispatchResourceOperationAsTool` — do not\n * reach for these services yourself.**\n *\n * A tool enters at the SERVICE tier, bypassing Express, so two gates that live on the HTTP\n * controller never run for it: the operation's declared `roles` ACL and its authored `rateLimit?`.\n * `dispatchResourceOperationAsTool` resolves the operation, builds the scoped execution context,\n * applies both gates in the right order and dispatches — one exported call, and the same one\n * `resourceReadTool` and `resourceWriteTool` use.\n *\n * ```ts\n * const rows = await dispatchResourceOperationAsTool({\n * ctx, resourceType: 'todos', operationIdentifier: CoreResourceOperation.LIST,\n * data: { filter: undefined, page: 1, limit: 20 }, options: { paginated: true },\n * });\n * ```\n *\n * **This prose used to name two calls a hand-written tool owed, and both were module-private (#556)\n * — so an author who read it and agreed could not discharge the obligation.** Naming ONE importable\n * call replaces that: the correct path is now also the shortest, which is the only mechanism that\n * survives an author who has not read this paragraph.\n *\n * Skipping the gates means a caller whose roles the operation REFUSES, but whose tenancy admits the\n * row, succeeds — the operation's `accessControl` simply unenforced on this plane. It is quiet:\n * tenancy still applies, so the tool returns the caller's own tenant's rows and LOOKS like it works.\n * That is right for a framework-internal caller and wrong here, where the caller is an external\n * principal naming an operation on their own authority.\n *\n * The services below remain on this interface because the seam is built from them, and because a\n * tool that dispatches NOTHING — a calculator, a formatter, a unit converter — is a legitimate shape\n * that needs neither gate.\n *\n * What you still get for free, on every tool: the repository's contextual filter in full — tenancy,\n * relationship narrowing, organization-unit narrowing, the anonymous guard and the retention hide,\n * all fail-closed — plus the whole operation pipeline of validation, enabled conditions, custom\n * implementation and hooks.\n */\nexport interface FunctionToolExecutionServices {\n resourcesRegistry: ResourcesRegistryBackendService;\n servicesRegistryHandler: ServicesRegistryHandlerBackendService;\n executionContextCreator: ExecutionContextCreatorBackendService;\n /**\n * Enforces an operation's OWN authored `rateLimit?` policy on this plane.\n *\n * Present because a tool DISPATCHES A RESOURCE OPERATION while bypassing Express, so the\n * declared policy's only other consumer — the HTTP controller pre-flight — never runs. A\n * hand-written {@link FunctionTool} that dispatches an operation itself owes the same charge —\n * call `checkPolicyForSubject(...)` on THIS service. (The factories below wrap it in the\n * module-private `assertDeclaredOperationRateLimit`, which is not importable from outside this\n * file; the service on this interface is the reachable path.)\n */\n rateLimitService: RateLimitBackendService;\n /**\n * Applies the dispatched operation's own declared `roles` ACL.\n *\n * Present because a tool enters at the SERVICE tier, and **the role gate is a CONTROLLER-tier\n * gate** — `ServicesRegistryHandlerBackendService`'s verbs apply the repository's contextual\n * filter and the whole operation pipeline, and deliberately apply no role check, because their\n * dominant population is the authentication reads that run before a role-bearing principal\n * exists. That is right for a framework-internal caller and wrong for this plane, whose caller is\n * an external principal (an A2A agent, or a user's own WebSocket) naming an operation on their\n * own authority. Without this the operation's `accessControl` was simply unenforced here: a\n * caller whose roles the operation refuses, but whose tenancy admits the row, succeeded.\n *\n * A hand-written {@link FunctionTool} that dispatches a resource operation owes the same call —\n * `authorizeInController(idOrIds, executionContext)` on THIS service. (The factories below wrap it\n * in the module-private `authorizeToolDispatch`, which is not importable from outside this file.)\n */\n authorizer: AuthorizationsBackendService;\n}\n/** @wildo_source:part:end saas.backend.flows-actors.tool-dispatch-obligations */\n\n/**\n * @wildo_source:part:start saas.backend.flows-actors.function-tool facet:layer:backend facet:family:flows-actors\n *\n * Execution context threaded into every tool call. Carries the CALLER's verified\n * identity (`auth`) so a tool reads/writes as the user with the user's own\n * visibility — never trusting LLM-supplied identity — plus the backend services\n * the tool may use. The engine supplies this at call time; a tool never fabricates\n * identity from the model's arguments.\n *\n * Import path: `@wildo-ai/saas-backend-lib`.\n */\nexport interface FunctionToolExecutionContext {\n /** The authenticated caller (server-verified identity + roles). */\n auth: SocketAuthResult;\n /** Active organization scope for the call, when applicable. */\n organizationId?: string;\n /** Backend services the tool may use. */\n services: FunctionToolExecutionServices;\n}\n\n/**\n * A single agent-callable tool (grounding / action an agent can invoke).\n *\n * Register instances on a backend module's `flowsActors.functionTools`; reference\n * one from an agent's `capabilities.tools.functionRefs` by its `functionRef`. The\n * engine resolves each declared ref into an AI-SDK tool at invocation time and\n * calls `execute(args, context)` with the caller's {@link FunctionToolExecutionContext}\n * (so the tool acts as the user, with the user's own visibility). For reading a\n * resource, prefer the `resourceReadTool(resourceType)` factory over a hand-written\n * tool. Import path: `@wildo-ai/saas-backend-lib`.\n *\n * @example\n * // a custom tool\n * const echoTool: FunctionTool = {\n * functionRef: 'demo.echo',\n * description: 'Echo the provided text back.',\n * inputSchema: z.object({ text: z.string() }),\n * execute: async (args) => ({ echoed: args.text }),\n * };\n */\nexport interface FunctionTool {\n /** Stable id referenced from `agent.capabilities.tools.functionRefs`. */\n functionRef: string;\n /** Natural-language description shown to the model (what the tool does + when). */\n description: string;\n /** Zod schema of the tool's arguments (surfaced to the model). */\n inputSchema: z.ZodTypeAny;\n /** Execute the tool with validated args under the caller's context. */\n execute: (args: any, context: FunctionToolExecutionContext) => Promise<unknown>;\n /**\n * Require a HUMAN decision before this tool runs (human-in-the-loop).\n *\n * When set, a turn that reaches this tool SUSPENDS instead of executing it: the run state is\n * persisted, the execution moves to `AWAITING_APPROVAL`, and the caller is asked to approve or\n * deny. Approving resumes the turn and runs the tool; denying resumes it and tells the model the\n * call was refused, so the agent can respond rather than silently stalling.\n *\n * Declare it on tools whose effect a person should authorise — sending money, emailing a\n * customer, deleting at scale — not on reads.\n *\n * ⚠️ Two things worth knowing before you set this:\n *\n * 1. **It requires a configured approval secret.** Approval decisions are HMAC-signed so a client\n * cannot forge one. A turn that would expose an approval-gated tool with no secret configured\n * REFUSES TO RUN rather than falling back to unsigned approvals — the tools someone bothered to\n * gate are exactly the ones where a forged approval matters most.\n * 2. **This is Wildo's declaration, not the model SDK's.** The engine translates it into the\n * SDK's call-level approval configuration. Do not reach for the SDK's own tool-level\n * `needsApproval`: it is deprecated, and approval is handled at the call level now.\n */\n requiresHumanApproval?: boolean;\n}\n/** @wildo_source:part:end saas.backend.flows-actors.function-tool */\n\n/**\n * The name a `functionRef` is exposed to the model under.\n *\n * Provider tool names must be identifier-safe and a `functionRef` uses dots, so the two differ for\n * every tool. ONE definition, because the mapping is used in opposite directions by two sites: the\n * turn BUILDS the tool set from refs, and a resume that re-signs a modified approval must find the\n * FunctionTool behind a name it reads back out of the model SDK's own message array. A second copy\n * of this expression would make an approval unmodifiable for exactly the refs the two spelled\n * differently.\n *\n * Not injective by construction (`a.b` and `a_b` collapse), and deliberately not made so: the\n * forward direction is what the model sees, and a reverse lookup resolves against ONE agent's\n * declared refs, where a collision would already be an authoring defect.\n */\nexport function modelToolNameForFunctionRef(functionRef: string): string {\n return functionRef.replace(/[^a-zA-Z0-9_-]/g, '_');\n}\n\n/** Uniform, model-facing result shape for read tools. */\ninterface ResourceReadToolResult {\n data: unknown[];\n pagination?: unknown;\n truncated?: boolean;\n}\n\n/** Normalize a handler list/search result (array or paginated) to the tool result shape. */\nfunction toReadResult(result: unknown, limit: number): ResourceReadToolResult {\n if (Array.isArray(result)) {\n return { data: result.slice(0, limit), truncated: result.length > limit };\n }\n if (result && typeof result === 'object' && 'data' in result && Array.isArray((result as { data: unknown[] }).data)) {\n const paged = result as { data: unknown[]; pagination?: unknown };\n return { data: paged.data.slice(0, limit), pagination: paged.pagination, truncated: paged.data.length > limit };\n }\n return { data: [] };\n}\n\n/**\n * Resolve the operation a tool DISPATCHES for `(resourceType, operationIdentifier)`: the\n * URL-BEARING default, and nothing else.\n *\n * ## The defect this closes — `authorize ≡ advertise ≡ execute`\n *\n * Both factories used to resolve through `getServiceOperationPathDefault`, and they dispatched\n * through the `ServicesRegistryHandlerBackendService` convenience verbs (`create` / `update` /\n * `list` / `search`), which re-resolve the same way. That resolver PREFERS an `INTERNAL_CALL`\n * default over the URL-bearing one — deliberately, because it is the SERVICE layer's native\n * transport and the trusted internal callers it was written for want exactly that. This plane is\n * not one of them: it faces an external principal and advertises a public operation to a model.\n *\n * So for a resource declaring BOTH defaults, the tool advertised one operation and executed\n * another — a different `requestDto` validating the model's arguments, a different response DTO,\n * a different `roles` declaration, and different prefix / postfix / custom-impl side effects.\n *\n * **Measured 2026-09-08, and exactly one resource declares both: `organizations` CREATE.** The\n * divergence there is not cosmetic. Its `INTERNAL_CALL` default is the transport registration owns,\n * so the shared CREATE prefix treats that path as registration-managed and SKIPS the\n * `org_type_creation_restricted` guard that confines creation-policy-managed organization types to\n * the registration flow; and the founding-owner postfix is registered on the DEFAULT `API_CALL`\n * variant ONLY, so the internal path writes no owner membership. An agent tool wired to\n * `resourceWriteTool(ORGANIZATIONS, CREATE)` therefore created a tenant with no owner — precisely\n * the stranded state `administrative-continuity-floors.md` exists to prevent — while also reaching\n * a restricted organization type. The MCP tool plane had already made this exact decision and wrote\n * down the reasoning (`McpServerBackendService.callTool`); this plane simply had not.\n *\n * ## Why \"no URL-bearing default\" now REFUSES, and why that is the safe direction\n *\n * This is a behaviour change, and it is intended. A resource whose only default for an identifier\n * is `INTERNAL_CALL` has NO HTTP surface, and its author reasoned from exactly that: `users` LIST\n * declares `roles: []` and says in as many words that the empty set \"is inert here precisely\n * because it is not URL-bearing\". A tool that dispatched it made a route-less, deliberately\n * unexposed operation reachable by an external agent — the opposite of what the declaration\n * assumed. Refusing is fail-closed, and the refusal names the resource and the operation so an app\n * author who genuinely wants that surface exposed can declare a URL-bearing default for it.\n *\n * @returns the URL-bearing default operation, or `undefined` when the resource declares none.\n */\nfunction resolveDispatchableOperation(\n ctx: FunctionToolExecutionContext,\n resourceType: ResourceType,\n operationIdentifier: string,\n): ResourceConfiguration_Operation<any, any, any> | undefined {\n const { resourcesRegistry } = ctx.services;\n // Non-throwing probe FIRST: `getOperationPathDefault` mints an alert-grade INTERNAL error on its\n // miss path, and merely CONSTRUCTING a Wildo error fires its backend actions (LOG / ALERT /\n // METRICS) before any `catch` could downgrade them. A resource with no URL-bearing default for\n // this identifier is an ordinary, expected shape here — not an incident.\n if (!resourcesRegistry.hasOperationPathDefault(resourceType, operationIdentifier)) {\n return undefined;\n }\n return resourcesRegistry.getOperationFromPath(\n resourcesRegistry.getOperationPathDefault(resourceType, operationIdentifier),\n );\n}\n\n/** {@link resolveDispatchableOperation}, refusing rather than returning `undefined`. */\nfunction requireDispatchableOperation(\n ctx: FunctionToolExecutionContext,\n resourceType: ResourceType,\n operationIdentifier: string,\n): ResourceConfiguration_Operation<any, any, any> {\n const operation = resolveDispatchableOperation(ctx, resourceType, operationIdentifier);\n if (!operation) {\n throw new Error(\n `Agent function tool for \"${resourceType}.${operationIdentifier}\": the resource declares no default URL-bearing `\n + 'variant for this operation, so there is no publicly-advertised operation for the tool to dispatch. Declare an '\n + 'API_CALL default for it, or expose a different operation.',\n );\n }\n return operation;\n}\n\n/**\n * Apply the dispatched operation's OWN `roles` ACL — the gate this plane was missing entirely.\n *\n * ## What was broken\n *\n * A function tool dispatches a resource operation through\n * `ServicesRegistryHandlerBackendService`, i.e. it enters at the SERVICE tier. The service tier\n * applies the repository's contextual filter (tenancy, FK narrowing, unit narrowing, the anonymous\n * guard, the retention row-hide — all fail-closed) and the whole operation pipeline (Zod, enabled\n * conditions, custom impl, hooks). It applies NO role check, and that is deliberate and\n * load-bearing: its dominant population is authentication, SCIM provisioning, webhook routing and\n * sweeps, which run BEFORE a role-bearing principal exists. Enforcing declared roles there would\n * deny the reads that ESTABLISH identity.\n *\n * `AuthorizationsBackendService.authorizeInController` is therefore the ONLY place an operation's\n * declared `roles` are checked, and it is mounted at the CONTROLLER tier — the boundary, because\n * that is where an untrusted principal names an operation.\n *\n * **This plane is that boundary and did not ask.** A tool call arrives from an external principal\n * (an A2A agent's token, or a user's own WebSocket) naming an operation on their own authority, and\n * dispatched it with the role ACL unread. A caller whose roles the operation refuses, but whose\n * tenancy admits the row, succeeded — so `roles: [ORG_MEMBER]` on Wonder Todos' todos CREATE, and\n * `roles: [APP_USER]` on the organizations self-service CREATE, were both statements about the HTTP\n * door only. Worse, the factories' own JSDoc, the app's registration comment and\n * `authenticateExternalToken`'s contract all asserted the opposite, so the gap read as closed.\n *\n * The MCP plane, which faces the same class of caller through a different transport, has always run\n * this gate (`McpServerBackendService.callTool`). This is the same call, on the sibling plane.\n *\n * ## Collection vs row\n *\n * `idOrIds` is `undefined` for CREATE / LIST / SEARCH (collection: roles + parent scope) and the\n * addressed record id for UPDATE (row: additionally FK reachability and per-row access). Passing a\n * value in the row's place for a collection call would authorize a READ of a row whose id happens\n * to be a scope id — a question nobody asked, failing for the wrong reason.\n *\n * Refusals are recorded by the authorizer's own denial-audit funnel, so a tool call denied here\n * produces the same `RESOURCE_OPERATION_DENIED` evidence a denied HTTP request produces.\n *\n * assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — an external caller reaching a resource operation\n * off the HTTP plane is held to that operation's own declared authority, through the same predicate.\n *\n * @throws AUTHORIZATION — surfaced to the model as a tool error, so the agent can say it was refused.\n */\nasync function authorizeToolDispatch(\n ctx: FunctionToolExecutionContext,\n executionContext: ExecutionContext<any>,\n idOrIds?: string,\n): Promise<void> {\n await ctx.services.authorizer.authorizeInController(idOrIds, executionContext);\n}\n\n/**\n * Charge ONE dispatch against the operation's own authored `rateLimit?` policy, before the\n * dispatch happens.\n *\n * ## What was broken\n *\n * `rateLimit?` is authored on an `API_CALL` / `API_CALL_WITH_CALLBACK` variant and had exactly\n * two consumers: `RateLimitBackendService.checkPolicyForVariant` at the HTTP controller\n * pre-flight, and `McpServerBackendService.assertOperationRateLimitPolicy` on the MCP tool plane.\n * The factories below dispatch the SAME operations through the SAME service pipeline while\n * bypassing Express entirely, so the identical operation was throttled over REST, throttled over\n * MCP, and unthrottled as an agent tool.\n *\n * The exposure is larger here than on either of those planes, which is why this is not merely a\n * consistency fix. A2A's blanket per-principal cap (`A2A_EXTERNAL_TURN_RATE_MAX`) bounds TURNS,\n * and one turn's tool loop may issue arbitrarily many tool calls — so an operation declaring\n * `requestsPerMinute: 5` could be dispatched far more than five times a minute by an external\n * caller spending a single turn. MCP has no such multiplier: one `tools/call` is one dispatch, so\n * its transport cap bounds dispatches 1:1.\n *\n * ## The policy is read off the operation actually being DISPATCHED — which is now the right one\n *\n * This guard originally re-resolved the URL-bearing default for itself, because the factories\n * dispatched the `INTERNAL_CALL` default and `rateLimit?` does not exist on that variant at all —\n * so reading the dispatched operation would have made the guard permanently inert for precisely\n * the resources that declare both. That divergence is gone: {@link resolveDispatchableOperation}\n * makes the URL-bearing default the dispatched operation, and this function takes it as an\n * argument. Policy-source and dispatch-target are now the same object rather than two resolutions\n * that agreed by discipline — which is what stops them separating again.\n *\n * Reading a single declaration as the OPERATION's budget is the framework's own established\n * reading of the field, not an invention: `resources-config.shared.factory.ts` projects\n * `rateLimit: defaultApiCallVariant.rateLimit` onto every derived auto-variant, stating that \"a\n * single declaration on the default URL-bearing variant covers all derived auto-variants\".\n *\n * ## Subject: the CREDENTIAL, not the tenant\n *\n * See {@link resolveDeclaredPolicySubjectKey} for the full argument. In short, an authored\n * `requestsPerMinute` has always meant \"per CLIENT\" — the HTTP seam keys on the source IP — so\n * the faithful translation onto a plane whose callers are credentials is the credential, then the\n * delegated user, then the owning scope. Keying on the tenant would silently make the same\n * declared number several times stricter here than over REST for any tenant running more than one\n * agent. Every branch reads a SERVER-VERIFIED field of the caller's auth; nothing here may ever be\n * sourced from a tool argument, or the throttle becomes opt-out by a model choosing a fresh bucket.\n *\n * ## Scope: a THIRD bucket, deliberately\n *\n * `agent-tool:resource:<resource>:<operation>`, distinct from the HTTP seam's\n * `resource:<resource>:<operation>` and MCP's `mcp:resource:<resource>:<operation>`. The three\n * count different SUBJECTS (an IP, a credential, a credential on a different transport); one\n * shared bucket would mix identity spaces and let a browser's traffic spend an agent's budget.\n *\n * ## Ordering: AFTER authorization\n *\n * Reversed 2026-09-08, when the role gate landed beside it, and MCP's argument is adopted verbatim:\n * a caller who may not run the operation at all must be refused with AUTHORIZATION rather than told\n * how much of a budget they have, and must not consume a slot of a budget that is not theirs —\n * which would let an unauthorized caller exhaust an authorized one's quota. The HTTP seam orders\n * these the other way round because it has no choice (`checkPolicyForVariant` runs pre-flight,\n * before the execution context authorization needs exists); here the identity is already resolved,\n * so the safer order is available and is taken.\n *\n * ## Postures\n *\n * - **No declared policy, or a non-HTTP default** -> no-op, zero Redis traffic. The overwhelmingly\n * common case: most operations declare nothing.\n * - **Unkeyable subject with a policy declared** -> REFUSE. This diverges from MCP's\n * proceed-and-log, and the reason is the tool-loop multiplier described above: there, an\n * unkeyed call is still bounded 1:1 by the transport's per-principal cap, so proceeding costs a\n * bounded amount; here an unkeyed turn could drive an uncounted, unbounded loop against an\n * endpoint whose author asked for a budget. The branch is structurally unreachable — a tool runs\n * only inside an authenticated turn, and an authenticated principal always carries one of the\n * four identity fields — so the refusal costs nothing today and cannot decay into a silent hole.\n * - **Limiter outage** -> propagates, exactly as it does over HTTP and MCP for the same declared\n * policy. An authored budget must not quietly become \"unlimited\" on one plane while it is a 500\n * on the others. (Contrast `assertExternalTurnWithinRate`, the framework-default abuse throttle,\n * which fails OPEN because nobody declared it.)\n *\n * ## Call-site enumeration, so the next reader does not re-derive it\n *\n * The invariant is \"a resource operation dispatched on behalf of an external CLIENT is charged\n * against its declared budget\". Enumerated 2026-09-08 over every caller of the generic service\n * dispatch (`doByOperationPath` and the `ServicesRegistryHandlerBackendService` verbs):\n *\n * | Plane | Verdict |\n * |---|---|\n * | REST route (`ControllerResourceBackendService.doOperation`) | charged — `checkPolicyForVariant`, IP-keyed |\n * | MCP `tools/call` (`McpServerBackendService`) | charged — `checkPolicyForSubject`, credential-keyed |\n * | Agent function tool (here; reachable over A2A and the app WebSocket) | charged — this function |\n * | Queue job executor (`job-executor.backend.service.ts`) | **N/A** — a REPLAY of an operation already authorized, and already charged, at enqueue time (`isWorkerExecution: true`). Charging again would double-count one client request and throttle a background worker against a client's budget |\n * | Minion-scoped handler (`saas-minions-lib`) | **N/A** — same worker plane, one scope deeper |\n * | Custom controllers (SCIM, charts, flows-actors) | **N/A** — the separate authoring surface: they declare their own policy and call `checkPolicy` inline (SCIM does, with its own scope key) rather than inheriting a resource operation's |\n * | Engine-internal collaborators (auth, org, RAG, seeding, retention) | **N/A** — not client-driven; reached from a plane that already charged, or from a system path with no client at all |\n *\n * The rule that generalises: a NEW plane that dispatches a resource operation on a client's behalf\n * owes its own `checkPolicyForSubject` call — AND its own `authorizeInController`. Nothing\n * structural forces either; both fields are simply unread where nobody reads them, which is how\n * both the MCP plane and this one shipped unthrottled, and how this one shipped unauthorized.\n *\n * @throws RATE_LIMIT (429) carrying `context.retryAfterSeconds` — the same envelope the HTTP and\n * MCP seams throw, so one refusal vocabulary covers all three planes. The AI SDK surfaces it to\n * the model as a tool error, so the agent can tell the user it is being throttled.\n */\nasync function assertDeclaredOperationRateLimit(\n ctx: FunctionToolExecutionContext,\n operation: ResourceConfiguration_Operation<any, any, any>,\n resourceType: ResourceType,\n operationIdentifier: string,\n): Promise<void> {\n // Defensive: `resolveDispatchableOperation` already filters to URL-bearing variants, so this\n // narrow exists to reach `rateLimit` on the union rather than to exclude a reachable case.\n if (\n operation.variantType !== ResourceOperationVariantType.API_CALL\n && operation.variantType !== ResourceOperationVariantType.API_CALL_WITH_CALLBACK\n ) {\n return;\n }\n const policy = operation.rateLimit;\n if (!policy) {\n return;\n }\n\n const subjectKey = resolveDeclaredPolicySubjectKey(ctx.auth?.initiatorIds);\n if (!subjectKey) {\n throw new Error(\n `Agent function tool for \"${resourceType}.${operationIdentifier}\": the operation declares a rateLimit policy but the `\n + 'caller carries no server-verified identity to count it against, so the declared budget cannot be honoured.',\n );\n }\n\n await ctx.services.rateLimitService.checkPolicyForSubject(\n policy,\n `agent-tool:resource:${resourceType}:${operationIdentifier}`,\n subjectKey,\n ctx.organizationId,\n );\n}\n\n/**\n * Dispatch a resource operation from a function tool, carrying BOTH gates the service tier skips.\n *\n * ## What this exists to prevent (#556)\n *\n * A `FunctionTool` enters at the SERVICE tier. It never passes through Express, so two\n * controller-tier gates are simply absent from its path — the operation's declared `roles` ACL and\n * its declared `rateLimit?`. That skip is CORRECT for the service tier's intended caller (the\n * authentication reads that run before a role-bearing principal exists) and wrong for this plane,\n * whose caller is an external principal naming an operation on their own authority.\n *\n * The failure is quiet, which is what makes it worth a seam. Tenancy still applies — the\n * repository's contextual filter runs regardless — so an unauthorized tool returns the caller's own\n * tenant's rows and LOOKS like it works. Nothing throws and nothing logs. What is missing is only\n * the row-level `roles` ACL: a caller whose roles the operation refuses, but whose tenancy admits\n * the row, succeeds.\n *\n * Until this existed the two gates were applied by hand at three sites in this file, and both helpers\n * were module-private — so an application author writing their own tool could not discharge the\n * obligation even after reading about it. The engine's own rule\n * (`invariant-call-site-enumeration.md`) asks for the opposite: prefer making the invariant\n * unbypassable over applying it N times. **This is the shortest path to a dispatch, so the correct\n * path is also the easy one.**\n *\n * ## The order is authorize → charge → dispatch, and it is not arbitrary\n *\n * Authorization first, so an unauthorized caller cannot spend an authorized caller's quota. The\n * charge before the dispatch, so a refused budget costs no work. This is the same order the MCP\n * plane uses, deliberately — one refusal vocabulary across every plane that enters here.\n *\n * ## One id, two uses, and why that is safer than two parameters\n *\n * `recordId` addresses the row AND is the authorization subject, because at every existing call site\n * those are the same value: an UPDATE passes the id to both, a CREATE/LIST/SEARCH passes it to\n * neither. Splitting them into two parameters would make it possible to authorize a collection call\n * while dispatching a row call — a question nobody asked, failing for the wrong reason. A bulk\n * operation addressed by a FILTER passes `dispatchFilter` instead, which is never an authorization\n * subject because a filter-addressed operation IS a collection call.\n *\n * assurance-control: WILDO.ACCESS.LEAST_PRIVILEGE — an external caller reaching a resource operation\n * off the HTTP plane is held to that operation's own declared authority, through the same predicate.\n *\n * @throws AUTHORIZATION when the operation's roles refuse the caller — surfaced to the model as a\n * tool error, so the agent can say it was refused. Recorded by the authorizer's own denial-audit\n * funnel, so the evidence matches a denied HTTP request.\n * @throws RATE_LIMIT (429) carrying `context.retryAfterSeconds`, the same envelope the HTTP and MCP\n * seams throw.\n * @throws NOT_FOUND when the resource declares no dispatchable operation under that identifier.\n */\nexport async function dispatchResourceOperationAsTool<TResult = any>(input: {\n ctx: FunctionToolExecutionContext;\n resourceType: ResourceType;\n /** A `CoreResourceOperation` member, or a custom operation identifier the resource declares. */\n operationIdentifier: string;\n /** The addressed row, for a row-scoped operation. Authorizes AND addresses; omit for a collection call. */\n recordId?: string;\n /** A filter addressing a COLLECTION, for a bulk operation. Never an authorization subject. */\n dispatchFilter?: any;\n /** Parent / context resource ids used to build the scoped execution context. */\n contextIds?: any;\n /** The operation payload — the body for a write, the query options for a read. */\n data?: any;\n /** Repository options passed through, e.g. `{ paginated: true }` for a LIST envelope. */\n options?: any;\n}): Promise<TResult> {\n const { ctx, resourceType, operationIdentifier, recordId, dispatchFilter, contextIds, data, options } = input;\n\n const operation = requireDispatchableOperation(ctx, resourceType, operationIdentifier);\n // Rebuild a scoped ExecutionContext from the CALLER's verified auth for THIS operation. Never\n // reuse one built for another operation: the scope it resolves is operation-specific.\n const executionContext = await ctx.services.executionContextCreator.buildContextFromSocketAuth(ctx.auth, operation, contextIds);\n\n await authorizeToolDispatch(ctx, executionContext, recordId);\n await assertDeclaredOperationRateLimit(ctx, operation, resourceType, operationIdentifier);\n\n const operationPath = ResourcesConfig_OperationPathUtils.extractOperationPath(operation) as ResourceConfiguration_OperationPath<any, any>;\n const subject = recordId ?? dispatchFilter;\n\n /*\n * The trailing `options` is OMITTED rather than passed as `undefined` when absent, so this seam\n * calls the dispatcher with exactly the arity each site used before it existed.\n *\n * Behaviourally the two are identical for an optional parameter. What differs is what a test can\n * see: the authorization and write pins here assert the dispatch with `toHaveBeenCalledWith`,\n * which is arity-exact, so a uniform five-argument call would have required editing four tests\n * that guard an authorization path. Preserving the shape proves the refactor changed nothing,\n * which is the property that matters most for the one seam every tool dispatch now goes through.\n */\n return options === undefined\n ? ctx.services.servicesRegistryHandler.doByOperationPath(operationPath, executionContext, subject, data)\n : ctx.services.servicesRegistryHandler.doByOperationPath(operationPath, executionContext, subject, data, options);\n}\n\n/**\n * Is this a REFUSAL the read tool must never launder into a different operation?\n *\n * Exists for exactly one reason: the read tool's SEARCH branch degrades to a scoped LIST on any\n * throw, and a refusal swallowed there would silently become an UNGATED LIST — the guard present\n * and inert, which is worse than absent because it reads as enforced. Two refusal kinds qualify:\n *\n * - **RATE_LIMIT** — a declared budget is an application's statement about the endpoint, not a\n * reason to reach for a different one.\n * - **AUTHORIZATION** — stronger still. A denial has already been RECORDED by the authorizer's\n * audit funnel, so proceeding would leave a `RESOURCE_OPERATION_DENIED` row beside a request\n * that then succeeded, making the access trail describe something that did not happen.\n *\n * A genuine \"this resource has no URL-bearing SEARCH operation\" still degrades, unchanged.\n */\nfunction isNonDegradableRefusal(error: unknown): boolean {\n return isWildoBackendError(error)\n && (error.type === ErrorType.RATE_LIMIT || error.type === ErrorType.AUTHORIZATION);\n}\n\n/**\n * @wildo_source:part:start saas.backend.flows-actors.resource-read-tool facet:layer:backend facet:family:flows-actors\n *\n * Generic resource-read tool factory. Produces a {@link FunctionTool} that lets\n * an agent look up records of ONE resource type **scoped to the calling user**,\n * with that user's own visibility — no `systemAccessPolicy` bypass. Instantiate\n * it per resource an agent should be able to read (e.g. `resourceReadTool(TODOS)`),\n * making any registered resource agent-readable without hand-writing a tool.\n *\n * The tool dispatches the resource's PUBLIC, URL-bearing default LIST / SEARCH — the same\n * operation a REST client reaches — under a user `ExecutionContext` rebuilt from the caller's\n * socket auth, and applies that operation's own declared `roles` ACL through\n * `AuthorizationsBackendService.authorizeInController` before dispatching it. So the framework's\n * contextual filter AND the role ACL apply exactly as for the user's own request. (The role gate\n * is named explicitly because it does NOT come free with the service path: the service tier\n * applies tenancy and the operation pipeline and no role check, so a tool that merely dispatched\n * would run with the ACL unread — which is what this factory did until 2026-09-08.) A resource\n * that declares no URL-bearing default for the operation is REFUSED rather than served through its\n * route-less internal variant. Identity is NEVER taken\n * from the model — only the `searchQuery` / `limit` args are. Its `functionRef`\n * defaults to `resource.<resourceType>.read` — reference that exact string from\n * your agent's `capabilities.tools.functionRefs`. Import path:\n * `@wildo-ai/saas-backend-lib`.\n *\n * @param resourceType the resource to expose (any registered `ResourceType`).\n * @param options optional `functionRef` / `description` / `defaultLimit` / `maxLimit` overrides.\n * @example\n * // in a backend module's `flowsActors.functionTools` contribution:\n * functionTools: [resourceReadTool(TasksManager_ResourceType.TODOS)]\n * // and on the agent:\n * capabilities: { tools: { functionRefs: ['resource.todos.read'], mcpRefs: [] } }\n */\nexport function resourceReadTool(\n resourceType: ResourceType,\n options?: { functionRef?: string; description?: string; defaultLimit?: number; maxLimit?: number },\n): FunctionTool {\n /** @wildo_source:part:end saas.backend.flows-actors.resource-read-tool */\n const defaultLimit = options?.defaultLimit ?? 50;\n const maxLimit = options?.maxLimit ?? 100;\n\n return {\n functionRef: options?.functionRef ?? `resource.${resourceType}.read`,\n description:\n options?.description ??\n `Look up the current user's \"${resourceType}\" records to answer their questions about them. ` +\n `Optionally pass a free-text searchQuery to narrow the results. Only the current user's own records are ever returned.`,\n inputSchema: z.object({\n searchQuery: z.string().optional(),\n limit: z.number().int().min(1).max(maxLimit).optional(),\n }),\n execute: async (args: { searchQuery?: string; limit?: number }, ctx: FunctionToolExecutionContext): Promise<ResourceReadToolResult> => {\n const { servicesRegistryHandler, executionContextCreator } = ctx.services;\n const limit = typeof args?.limit === 'number' ? Math.min(args.limit, maxLimit) : defaultLimit;\n const searchQuery = typeof args?.searchQuery === 'string' && args.searchQuery.trim().length > 0 ? args.searchQuery.trim() : undefined;\n const contextIds: Record<string, string> = ctx.organizationId ? { organizationId: ctx.organizationId } : {};\n\n // Prefer SEARCH when a query is supplied AND the resource EXPOSES it; fall back to a scoped\n // LIST. Both run as the user, under the operation's own role ACL (no bypass).\n if (searchQuery) {\n // The fallback catch covers ONLY op-resolution + the search call — a resource may expose no\n // SEARCH operation, in which case we degrade to a scoped LIST. It deliberately does NOT wrap\n // the response-DTO projection below: a projection failure there is a real server contract\n // violation (a record that violates its own response DTO) and must surface as a tool error,\n // exactly as it would on the LIST path — never silently degrade to an unfiltered LIST.\n let searchOp: ResourceConfiguration_Operation<any, any, any> | undefined;\n let searchResult: unknown;\n try {\n // Non-throwing: a resource with no URL-bearing SEARCH default has nothing to expose here,\n // which is the documented degradation rather than a refusal.\n searchOp = resolveDispatchableOperation(ctx, resourceType, CoreResourceOperation.SEARCH);\n if (searchOp) {\n // The seam authorizes, charges and dispatches in that order. It sits inside this try\n // because that is where the dispatch is; the catch below re-throws either refusal so\n // neither can be laundered into an ungated LIST. The operation is resolved twice — once\n // above to decide whether SEARCH is even available, once inside the seam — and that is\n // deliberate: the availability question is this factory's, the gates are the seam's.\n searchResult = await dispatchResourceOperationAsTool({\n ctx,\n resourceType,\n operationIdentifier: CoreResourceOperation.SEARCH,\n contextIds,\n data: { searchQuery, filter: undefined },\n });\n }\n } catch (error) {\n // A declared budget, or a role refusal, is a statement about THIS endpoint — not a reason\n // to reach for a different one. Degrading here would answer the model with LIST results\n // the caller was just refused: enforcement that reports success.\n if (isNonDegradableRefusal(error)) throw error;\n searchOp = undefined; // SEARCH failed to resolve or dispatch — fall through to LIST.\n }\n if (searchOp !== undefined) {\n // Project through the SEARCH operation's response DTO + JSON wire step, exactly as the\n // REST controller does, so no `Date`/backend-only/secret field reaches the model.\n const safeSearchResult = await toResponseSafeToolOutput(searchOp, searchResult);\n return toReadResult(safeSearchResult, limit);\n }\n }\n\n // LIST is a distinct operation with its own ACL and its own declared budget, so it is\n // authorized and charged separately. A call that resolved SEARCH and then degraded to LIST\n // does both twice — two operations were attempted, exactly as two HTTP requests would be, and\n // that path is only reached when the search dispatch failed for a reason that is not a refusal.\n const listOp = requireDispatchableOperation(ctx, resourceType, CoreResourceOperation.LIST);\n // `paginated: true` yields the `{ data, pagination }` envelope the LIST response DTO expects\n // (the same shape the HTTP controller requests) — a bare array would fail the wrapper-DTO\n // projection in `toResponseSafeToolOutput` below.\n const listResult = await dispatchResourceOperationAsTool({\n ctx,\n resourceType,\n operationIdentifier: CoreResourceOperation.LIST,\n contextIds,\n data: { filter: undefined, page: 1, limit },\n options: { paginated: true },\n });\n const safeListResult = await toResponseSafeToolOutput(listOp, listResult);\n return toReadResult(safeListResult, limit);\n },\n };\n}\n\n/**\n * @wildo_source:part:start saas.backend.flows-actors.resource-write-tool facet:layer:backend facet:family:flows-actors\n *\n * Generic resource-WRITE tool factory. The mutating sibling of {@link resourceReadTool}.\n * Produces a {@link FunctionTool} that lets an agent CREATE or UPDATE ONE resource\n * type **as the calling user**, under the caller's own `ExecutionContext` rebuilt\n * from their verified socket auth — no `systemAccessPolicy` bypass, and identity is\n * NEVER taken from the model. It dispatches the resource's PUBLIC, URL-bearing default CREATE /\n * UPDATE — the same operation a REST client reaches, with the same request DTO validating the\n * model's arguments and the same prefix / postfix side effects — and applies that operation's own\n * `accessControl` (roles + parent scope, plus per-row access on UPDATE) through\n * `AuthorizationsBackendService.authorizeInController` before the write. Authorization is therefore\n * **fail-closed**: a caller lacking the operation's role gets a thrown authz error, not a silent\n * write.\n *\n * Both halves of that are load-bearing and neither came free, so do not simplify them away. The\n * service tier applies tenancy and the operation pipeline and NO role check, and the service\n * layer's own default resolver PREFERS a route-less `INTERNAL_CALL` variant over the public one —\n * so before 2026-09-08 this factory dispatched a different operation from the one it advertises,\n * with the ACL unread. On `organizations` CREATE that combination created ownerless tenants.\n *\n * A resource that declares no URL-bearing default for the operation is REFUSED rather than written\n * through its internal variant. Owner FKs and\n * other server-set fields are EC-injected / `excludeFromCreate`, so the model can\n * never spoof ownership through the tool arguments.\n *\n * Unlike the read tool (whose args are a fixed `{ searchQuery, limit }`), a write\n * tool's arguments are resource-specific, so the caller MUST supply the model-facing\n * `inputSchema` — the create/update field contract shown to the model. Keep it to the\n * fields the model should legitimately set. For `UPDATE`, include the record `id` in\n * the schema; the factory splits `id` out to address the row and passes the remaining\n * fields as the patch.\n *\n * `functionRef` defaults to `resource.<resourceType>.<op>` (e.g. `resource.todos.create`)\n * — reference that exact string from your agent's `capabilities.tools.functionRefs`.\n * Import path: `@wildo-ai/saas-backend-lib`.\n *\n * @param resourceType the resource to expose (any registered `ResourceType`).\n * @param op `CoreResourceOperation.CREATE` or `CoreResourceOperation.UPDATE`.\n * @param options `{ inputSchema, functionRef?, description? }` — `inputSchema` is REQUIRED (the model-facing argument contract).\n * @example\n * // in a backend module's `flowsActors.functionTools` contribution:\n * functionTools: [\n * resourceWriteTool(TasksManager_ResourceType.TODOS, CoreResourceOperation.CREATE, {\n * inputSchema: z.object({ title: z.string(), todoListId: z.string(), description: z.string().optional() }),\n * }),\n * ]\n * // and on the agent:\n * capabilities: { tools: { functionRefs: ['resource.todos.create'], mcpRefs: [] } }\n */\nexport function resourceWriteTool(\n resourceType: ResourceType,\n op: CoreResourceOperation.CREATE | CoreResourceOperation.UPDATE,\n options: {\n inputSchema: z.ZodTypeAny;\n functionRef?: string;\n description?: string;\n /**\n * Gate this write behind a HUMAN decision (see {@link FunctionTool.requiresHumanApproval}).\n *\n * Without this passthrough the flag was declarable only by hand-rolling a `FunctionTool`, so\n * the approval gate was unreachable from the factory every app author actually uses — a\n * capability present in the contract and absent from the authoring surface. Reads are not\n * offered the option: approval exists to gate EFFECTS, and gating a read teaches authors to\n * approve things reflexively, which is how an approval prompt stops being read.\n */\n requiresHumanApproval?: boolean;\n },\n): FunctionTool {\n /** @wildo_source:part:end saas.backend.flows-actors.resource-write-tool */\n return {\n functionRef: options.functionRef ?? `resource.${resourceType}.${op}`,\n requiresHumanApproval: options.requiresHumanApproval,\n description:\n options.description ??\n (op === CoreResourceOperation.CREATE\n ? `Create a new \"${resourceType}\" record on behalf of the current user from the provided fields. The record is owned by and scoped to the current user; ownership fields are set by the system, not from the arguments.`\n : `Update an existing \"${resourceType}\" record the current user owns. Pass the record \"id\" plus only the fields to change.`),\n inputSchema: options.inputSchema,\n execute: async (args: Record<string, unknown>, ctx: FunctionToolExecutionContext): Promise<unknown> => {\n const { servicesRegistryHandler, executionContextCreator } = ctx.services;\n const contextIds: Record<string, string> = ctx.organizationId ? { organizationId: ctx.organizationId } : {};\n\n // UPDATE addresses a row; CREATE does not. Split FIRST, before anything is resolved: this is\n // a check on the tool AUTHOR's own `inputSchema`, independent of the registry, and surfacing\n // it ahead of a resolution failure keeps the actionable message the actionable one.\n // `authorizeInController` then takes the addressed id and runs the row-scoped phases only\n // when there is one.\n const isUpdate = op === CoreResourceOperation.UPDATE;\n const { id, ...patch } = args as { id?: string };\n if (isUpdate && (typeof id !== 'string' || id.length === 0)) {\n throw new Error(\n `resourceWriteTool(${resourceType}, update): the \"id\" argument is required — declare it in the tool's inputSchema.`,\n );\n }\n\n // The operation the tool ADVERTISES is the resource's public, URL-bearing default; dispatch\n // that exact one rather than re-resolving through the service layer's INTERNAL-preferred\n // resolver. See `resolveDispatchableOperation` for what diverged and what it cost.\n const operation = requireDispatchableOperation(ctx, resourceType, op);\n const operationPath = ResourcesConfig_OperationPathUtils.extractOperationPath(operation) as ResourceConfiguration_OperationPath<any, any>;\n\n // Rebuild a scoped ExecutionContext from the CALLER's verified auth for this operation, then\n // apply the operation's own role + scope ACL against it (fail-closed) before anything is\n // written. The write runs as the user, never with an ACL bypass.\n if (!isUpdate) {\n // The seam authorizes as a COLLECTION call (no row addressed), charges the operation's own\n // budget after authorization so an unauthorized caller cannot spend an authorized one's, and\n // writes as the user — never with an ACL bypass.\n const created = await dispatchResourceOperationAsTool({ ctx, resourceType, operationIdentifier: op, contextIds, data: args });\n // Return the same JSON-safe, response-DTO-projected record the REST endpoint would, so no\n // `Date`/backend-only/secret reaches the model and the tool-loop CONTINUATION step validates.\n return toResponseSafeToolOutput(operation, created);\n }\n\n // UPDATE: the record \"id\" addresses the row AND is the authorization subject — the seam takes\n // one value for both, which is what makes authorizing a collection call while dispatching a\n // row call unrepresentable.\n const updated = await dispatchResourceOperationAsTool({ ctx, resourceType, operationIdentifier: op, recordId: id, contextIds, data: patch });\n return toResponseSafeToolOutput(operation, updated);\n },\n };\n}\n"]}