@aventara/core 1.0.0-rc.0 → 1.0.0-rc.10

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 (338) hide show
  1. package/CHANGELOG.md +2068 -1
  2. package/ERRORS.md +142 -0
  3. package/README.md +485 -60
  4. package/dist/adapters/adapter-discovery-diagnostic.d.ts +4 -4
  5. package/dist/adapters/adapter-discovery-diagnostic.guidance.d.ts +6 -0
  6. package/dist/adapters/adapter-discovery-diagnostic.guidance.js +7 -0
  7. package/dist/adapters/adapter-field.d.ts +33 -11
  8. package/dist/adapters/adapter-identifier.d.ts +15 -6
  9. package/dist/adapters/adapter-identifier.js +6 -1
  10. package/dist/adapters/adapter-model.d.ts +18 -9
  11. package/dist/adapters/adapter-operation-executor.interface.d.ts +4 -4
  12. package/dist/adapters/adapter-operation.d.ts +21 -6
  13. package/dist/adapters/adapter-resource.d.ts +23 -9
  14. package/dist/adapters/adapter-sql-statement.d.ts +19 -0
  15. package/dist/adapters/adapter-transaction-executor.interface.d.ts +19 -0
  16. package/dist/adapters/adapter.interface.d.ts +59 -29
  17. package/dist/avz/avz-check.factory.d.ts +83 -0
  18. package/dist/avz/avz-check.factory.js +116 -0
  19. package/dist/avz/avz-check.registry.d.ts +35 -0
  20. package/dist/avz/avz-check.registry.js +9 -0
  21. package/dist/avz/avz.d.ts +203 -0
  22. package/dist/{json → avz}/avz.js +150 -8
  23. package/dist/{json → avz}/index.d.ts +2 -1
  24. package/dist/{json → avz}/json-shape.registry.d.ts +9 -8
  25. package/dist/{json → avz}/zod-issue.translator.d.ts +8 -2
  26. package/dist/{json → avz}/zod-issue.translator.js +7 -0
  27. package/dist/compiler/contract-compiler-diagnostic.d.ts +31 -5
  28. package/dist/compiler/contract-compiler-diagnostic.guidance.d.ts +6 -0
  29. package/dist/compiler/contract-compiler-diagnostic.guidance.js +97 -0
  30. package/dist/compiler/contract.compiler.d.ts +23 -17
  31. package/dist/compiler/contract.compiler.js +753 -443
  32. package/dist/compiler/create-requirements.projector.d.ts +49 -0
  33. package/dist/compiler/create-requirements.projector.js +423 -0
  34. package/dist/compiler/field-validator.compiler.d.ts +47 -0
  35. package/dist/compiler/field-validator.compiler.js +238 -0
  36. package/dist/compiler/managed-elsewhere.projector.d.ts +52 -0
  37. package/dist/compiler/managed-elsewhere.projector.js +179 -0
  38. package/dist/compiler/managed-elsewhere.validator.d.ts +9 -0
  39. package/dist/compiler/managed-elsewhere.validator.js +74 -0
  40. package/dist/config/any-framework-config.d.ts +19 -12
  41. package/dist/config/computed-fields.d.ts +62 -0
  42. package/dist/config/computed-fields.js +73 -0
  43. package/dist/config/config-diagnostic.d.ts +11 -4
  44. package/dist/config/config-diagnostic.guidance.d.ts +6 -0
  45. package/dist/config/config-diagnostic.guidance.js +32 -0
  46. package/dist/config/config-layer.d.ts +15 -6
  47. package/dist/config/config.resolver.d.ts +98 -31
  48. package/dist/config/config.resolver.js +173 -44
  49. package/dist/config/config.validator.d.ts +7 -7
  50. package/dist/config/config.validator.js +792 -69
  51. package/dist/config/define-resource.d.ts +53 -0
  52. package/dist/config/define-resource.js +14 -0
  53. package/dist/config/effective-fields.d.ts +19 -23
  54. package/dist/config/entrypoint.normalizer.d.ts +4 -3
  55. package/dist/config/exact-framework-config.d.ts +325 -0
  56. package/dist/config/field-compute.resolver.d.ts +21 -0
  57. package/dist/config/field-compute.resolver.js +123 -0
  58. package/dist/config/field-pipeline-config.d.ts +47 -0
  59. package/dist/config/forced-operation.validator.d.ts +10 -0
  60. package/dist/config/forced-operation.validator.js +66 -0
  61. package/dist/config/framework-config.d.ts +148 -39
  62. package/dist/config/framework-exemptions-config.d.ts +91 -0
  63. package/dist/config/framework-exemptions-config.js +1 -0
  64. package/dist/config/framework-field-definition.d.ts +78 -0
  65. package/dist/config/framework-field-definition.js +28 -0
  66. package/dist/config/framework-resources-config.d.ts +127 -0
  67. package/dist/config/framework-resources-config.js +1 -0
  68. package/dist/config/pipeline-config.d.ts +56 -20
  69. package/dist/config/pipeline-tree.resolver.d.ts +79 -0
  70. package/dist/config/pipeline-tree.resolver.js +220 -0
  71. package/dist/config/stage-type.eraser.d.ts +65 -0
  72. package/dist/config/stage-type.eraser.js +1 -0
  73. package/dist/contracts/access-route.rules.d.ts +10 -0
  74. package/dist/contracts/access-route.rules.js +45 -0
  75. package/dist/contracts/capability.d.ts +37 -12
  76. package/dist/contracts/capability.js +20 -0
  77. package/dist/contracts/client-contract-structure.validator.d.ts +621 -114
  78. package/dist/contracts/client-contract-structure.validator.js +189 -10
  79. package/dist/contracts/contract-access.d.ts +29 -0
  80. package/dist/contracts/contract-access.js +1 -0
  81. package/dist/contracts/contract-canonicalizer.d.ts +27 -3
  82. package/dist/contracts/contract-canonicalizer.js +168 -29
  83. package/dist/contracts/contract-hash.d.ts +11 -7
  84. package/dist/contracts/contract-hash.js +4 -3
  85. package/dist/contracts/contract-limits.d.ts +4 -1
  86. package/dist/contracts/contract-limits.js +1 -0
  87. package/dist/contracts/contract-lookup.d.ts +5 -5
  88. package/dist/contracts/contract-protocol.d.ts +4 -4
  89. package/dist/contracts/contract.d.ts +51 -17
  90. package/dist/contracts/create-requirements.d.ts +35 -0
  91. package/dist/contracts/create-requirements.js +1 -0
  92. package/dist/contracts/enum-definition.d.ts +1 -1
  93. package/dist/contracts/field-check.d.ts +101 -0
  94. package/dist/contracts/field-check.js +1 -0
  95. package/dist/contracts/field.d.ts +109 -42
  96. package/dist/contracts/identifier.d.ts +4 -4
  97. package/dist/contracts/json-schema.projector.d.ts +11 -0
  98. package/dist/contracts/json-schema.projector.js +78 -0
  99. package/dist/contracts/json-shape.d.ts +12 -1
  100. package/dist/contracts/lifecycle-trait.d.ts +2 -2
  101. package/dist/contracts/resource-operations.d.ts +28 -28
  102. package/dist/contracts/resource.d.ts +15 -9
  103. package/dist/contracts/scalar-value-type.d.ts +17 -15
  104. package/dist/contracts/scalar.d.ts +3 -3
  105. package/dist/contracts/transaction-capability.d.ts +1 -1
  106. package/dist/contracts/wire-scalar-format.d.ts +4 -4
  107. package/dist/framework/access-facade.d.ts +116 -0
  108. package/dist/framework/access-facade.js +120 -0
  109. package/dist/framework/contract-view.d.ts +315 -145
  110. package/dist/framework/framework-construction.error.d.ts +21 -11
  111. package/dist/framework/framework-construction.error.js +20 -4
  112. package/dist/framework/framework.d.ts +71 -26
  113. package/dist/framework/framework.factory.d.ts +8 -6
  114. package/dist/framework/framework.factory.js +150 -38
  115. package/dist/framework/operation-facade.d.ts +192 -54
  116. package/dist/framework/operation-facade.js +10 -1
  117. package/dist/index.d.ts +67 -50
  118. package/dist/index.js +7 -6
  119. package/dist/internal.d.ts +20 -10
  120. package/dist/internal.js +9 -1
  121. package/dist/operations/database-refusal.d.ts +51 -0
  122. package/dist/operations/database-refusal.js +45 -0
  123. package/dist/operations/operation-arguments.d.ts +381 -228
  124. package/dist/operations/operation-call.d.ts +31 -28
  125. package/dist/operations/operation-identity.d.ts +10 -10
  126. package/dist/operations/operation-result.d.ts +25 -23
  127. package/dist/operations/operation-validator-core.d.ts +6 -6
  128. package/dist/operations/operation-validator-core.js +172 -38
  129. package/dist/operations/operation-validator.d.ts +10 -10
  130. package/dist/operations/projection-scope.resolver.d.ts +6 -6
  131. package/dist/operations/structural-limits.walker.d.ts +7 -7
  132. package/dist/operations/structural-limits.walker.js +145 -0
  133. package/dist/operations/validation-code.d.ts +11 -6
  134. package/dist/operations/validation-code.guidance.d.ts +6 -0
  135. package/dist/operations/validation-code.guidance.js +90 -0
  136. package/dist/operations/validation-code.js +4 -0
  137. package/dist/operations/write-scope.resolver.d.ts +10 -6
  138. package/dist/operations/write-scope.resolver.js +2 -0
  139. package/dist/policy/access-provider.interface.d.ts +91 -0
  140. package/dist/policy/access-provider.interface.js +1 -0
  141. package/dist/policy/access-provider.registry.d.ts +17 -0
  142. package/dist/policy/access-provider.registry.js +15 -0
  143. package/dist/policy/access-question.d.ts +20 -0
  144. package/dist/policy/access-question.js +1 -0
  145. package/dist/policy/access-question.registry.d.ts +5 -0
  146. package/dist/policy/access-question.registry.js +19 -0
  147. package/dist/policy/access-question.runtime.d.ts +36 -0
  148. package/dist/policy/access-question.runtime.js +297 -0
  149. package/dist/policy/access-verb.table.d.ts +56 -0
  150. package/dist/policy/access-verb.table.js +21 -0
  151. package/dist/policy/access-verbs.d.ts +46 -0
  152. package/dist/policy/access-verbs.js +1 -0
  153. package/dist/policy/policy-admission.d.ts +20 -0
  154. package/dist/policy/policy-admission.js +409 -0
  155. package/dist/policy/policy-after-update.runtime.d.ts +79 -0
  156. package/dist/policy/policy-after-update.runtime.js +208 -0
  157. package/dist/policy/policy-condition.d.ts +15 -0
  158. package/dist/policy/policy-condition.js +36 -0
  159. package/dist/policy/policy-engine.d.ts +205 -0
  160. package/dist/policy/policy-engine.js +1 -0
  161. package/dist/policy/policy-named-rows.d.ts +18 -0
  162. package/dist/policy/policy-named-rows.js +51 -0
  163. package/dist/policy/policy-nested-write.runtime.d.ts +44 -0
  164. package/dist/policy/policy-nested-write.runtime.js +545 -0
  165. package/dist/policy/policy-read.runtime.d.ts +81 -0
  166. package/dist/policy/policy-read.runtime.js +503 -0
  167. package/dist/policy/policy-reference-write.runtime.d.ts +51 -0
  168. package/dist/policy/policy-reference-write.runtime.js +345 -0
  169. package/dist/policy/policy-request.d.ts +41 -0
  170. package/dist/policy/policy-request.js +63 -0
  171. package/dist/policy/policy-session.d.ts +106 -0
  172. package/dist/policy/policy-session.js +295 -0
  173. package/dist/policy/policy-startup.validator.d.ts +10 -0
  174. package/dist/policy/policy-startup.validator.js +112 -0
  175. package/dist/policy/policy-write.runtime.d.ts +39 -0
  176. package/dist/policy/policy-write.runtime.js +532 -0
  177. package/dist/prebuilt/core-version.generated.d.ts +2 -0
  178. package/dist/prebuilt/core-version.generated.js +1 -0
  179. package/dist/prebuilt/prebuilt-changes.d.ts +29 -0
  180. package/dist/prebuilt/prebuilt-changes.js +65 -0
  181. package/dist/prebuilt/prebuilt-contracts.d.ts +40 -0
  182. package/dist/prebuilt/prebuilt-contracts.emitter.d.ts +16 -0
  183. package/dist/prebuilt/prebuilt-contracts.emitter.js +50 -0
  184. package/dist/prebuilt/prebuilt-contracts.js +1 -0
  185. package/dist/prebuilt/prebuilt-contracts.loader.d.ts +19 -0
  186. package/dist/prebuilt/prebuilt-contracts.loader.js +77 -0
  187. package/dist/prebuilt/prebuilt-inputs.fingerprint.d.ts +16 -0
  188. package/dist/prebuilt/prebuilt-inputs.fingerprint.js +229 -0
  189. package/dist/protocol/absent-route.responder.d.ts +17 -34
  190. package/dist/protocol/absent-route.responder.js +53 -20
  191. package/dist/protocol/contract-document.responder.d.ts +5 -4
  192. package/dist/protocol/contract-document.responder.js +2 -2
  193. package/dist/protocol/http-request.decoder.d.ts +33 -13
  194. package/dist/protocol/http-request.decoder.js +34 -11
  195. package/dist/protocol/http-request.reader.d.ts +9 -6
  196. package/dist/protocol/http-request.reader.js +1 -0
  197. package/dist/protocol/http-response.encoder.d.ts +4 -4
  198. package/dist/protocol/http-response.encoder.js +94 -55
  199. package/dist/protocol/http-status.table.d.ts +2 -2
  200. package/dist/protocol/operation-response.guard.d.ts +2 -2
  201. package/dist/protocol/protocol-headers.d.ts +3 -3
  202. package/dist/protocol/protocol-surface.d.ts +10 -5
  203. package/dist/protocol/protocol-surface.js +7 -0
  204. package/dist/protocol/protocol.binder.d.ts +66 -28
  205. package/dist/protocol/protocol.binder.js +16 -10
  206. package/dist/protocol/protocol.handler.d.ts +34 -14
  207. package/dist/protocol/protocol.handler.js +122 -18
  208. package/dist/protocol/unmounted-route.error.d.ts +4 -4
  209. package/dist/protocol/unmounted-route.error.js +2 -2
  210. package/dist/runtime/caller-data.copier.d.ts +22 -7
  211. package/dist/runtime/caller-data.copier.js +30 -17
  212. package/dist/runtime/caller-data.door.d.ts +18 -11
  213. package/dist/runtime/caller-data.door.js +6 -4
  214. package/dist/runtime/computed-read-runtime.d.ts +12 -6
  215. package/dist/runtime/computed-read-runtime.js +271 -71
  216. package/dist/runtime/computed-value.error.d.ts +7 -6
  217. package/dist/runtime/computed-value.error.js +5 -4
  218. package/dist/runtime/context-executor.runtime.d.ts +60 -0
  219. package/dist/runtime/context-executor.runtime.js +277 -0
  220. package/dist/runtime/core-class.brand.d.ts +10 -0
  221. package/dist/runtime/core-class.brand.js +21 -0
  222. package/dist/runtime/create-requirement.d.ts +34 -79
  223. package/dist/runtime/create-requirement.js +205 -74
  224. package/dist/runtime/decimal.d.ts +16 -2
  225. package/dist/runtime/decimal.js +22 -1
  226. package/dist/runtime/diagnostics-reporter.d.ts +91 -30
  227. package/dist/runtime/diagnostics-reporter.js +37 -1
  228. package/dist/runtime/error-boundary.d.ts +73 -9
  229. package/dist/runtime/error-boundary.js +57 -19
  230. package/dist/runtime/error-guidance.d.ts +12 -0
  231. package/dist/runtime/error-guidance.js +1 -0
  232. package/dist/runtime/error.catalog.d.ts +49 -0
  233. package/dist/runtime/error.catalog.js +49 -0
  234. package/dist/runtime/execution-options.d.ts +18 -2
  235. package/dist/runtime/field-check.evaluator.d.ts +27 -0
  236. package/dist/runtime/field-check.evaluator.js +521 -0
  237. package/dist/runtime/field-compute.d.ts +65 -0
  238. package/dist/runtime/field-compute.js +1 -0
  239. package/dist/runtime/field-stage.plan.d.ts +15 -0
  240. package/dist/runtime/field-stage.plan.js +27 -0
  241. package/dist/runtime/field-stage.runtime.d.ts +37 -0
  242. package/dist/runtime/field-stage.runtime.js +147 -0
  243. package/dist/runtime/field-validator.runtime.d.ts +29 -0
  244. package/dist/runtime/field-validator.runtime.js +126 -0
  245. package/dist/runtime/framework-error-class.table.d.ts +33 -0
  246. package/dist/runtime/framework-error-class.table.js +25 -0
  247. package/dist/runtime/framework-error.d.ts +68 -8
  248. package/dist/runtime/framework-error.factory.d.ts +4 -0
  249. package/dist/runtime/framework-error.factory.js +15 -0
  250. package/dist/runtime/framework-error.js +32 -2
  251. package/dist/runtime/framework-warning.emitter.d.ts +6 -0
  252. package/dist/runtime/framework-warning.emitter.js +8 -0
  253. package/dist/runtime/interceptor-next.error.d.ts +5 -0
  254. package/dist/runtime/interceptor-next.error.js +6 -0
  255. package/dist/runtime/json-value.d.ts +11 -6
  256. package/dist/runtime/level-lifecycle.runtime.d.ts +26 -0
  257. package/dist/runtime/level-lifecycle.runtime.js +40 -0
  258. package/dist/runtime/misuse-reporter.d.ts +12 -12
  259. package/dist/runtime/mutation-planner.d.ts +20 -16
  260. package/dist/runtime/mutation-planner.js +48 -35
  261. package/dist/runtime/nested-write.walker.d.ts +32 -0
  262. package/dist/runtime/nested-write.walker.js +73 -0
  263. package/dist/runtime/operation-code.guidance.d.ts +6 -0
  264. package/dist/runtime/operation-code.guidance.js +167 -0
  265. package/dist/runtime/operation-request.d.ts +45 -11
  266. package/dist/runtime/operation-response.d.ts +17 -17
  267. package/dist/runtime/operation-runtime.d.ts +133 -27
  268. package/dist/runtime/operation-runtime.js +576 -84
  269. package/dist/runtime/outcome-mapper.d.ts +17 -5
  270. package/dist/runtime/outcome-mapper.js +23 -6
  271. package/dist/runtime/output-validator.d.ts +11 -11
  272. package/dist/runtime/output-validator.js +3 -3
  273. package/dist/runtime/owned-execution.registry.d.ts +16 -6
  274. package/dist/runtime/pipe-output.validator.d.ts +43 -18
  275. package/dist/runtime/pipe-output.validator.js +15 -13
  276. package/dist/runtime/pipeline.d.ts +221 -34
  277. package/dist/runtime/readonly-value.d.ts +47 -0
  278. package/dist/runtime/readonly-value.js +189 -0
  279. package/dist/runtime/referential-action.d.ts +1 -1
  280. package/dist/runtime/request-envelope.validator.d.ts +3 -3
  281. package/dist/runtime/request-envelope.validator.js +12 -7
  282. package/dist/runtime/request-id.d.ts +1 -1
  283. package/dist/runtime/request-state.d.ts +14 -0
  284. package/dist/runtime/request-state.js +1 -0
  285. package/dist/runtime/request-state.resolver.d.ts +12 -0
  286. package/dist/runtime/request-state.resolver.js +20 -0
  287. package/dist/runtime/scalar-runtime.d.ts +33 -25
  288. package/dist/runtime/scalar-runtime.js +105 -38
  289. package/dist/runtime/unsent-value.normalizer.d.ts +15 -0
  290. package/dist/runtime/unsent-value.normalizer.js +128 -0
  291. package/dist/transactions/deferred-operation.d.ts +35 -20
  292. package/dist/transactions/operation-arguments-encoder.d.ts +3 -3
  293. package/dist/transactions/operation-arguments-encoder.js +8 -3
  294. package/dist/transactions/operation-fingerprint.js +2 -2
  295. package/dist/transactions/sql-statement.d.ts +85 -0
  296. package/dist/transactions/sql-statement.js +47 -0
  297. package/dist/transactions/sql-statement.validator.d.ts +44 -0
  298. package/dist/transactions/sql-statement.validator.js +167 -0
  299. package/dist/transactions/transaction-envelope.d.ts +9 -8
  300. package/dist/transactions/transaction-integrity-error.d.ts +6 -6
  301. package/dist/transactions/transaction-integrity-error.js +7 -2
  302. package/dist/transactions/transaction-plan-assembler.d.ts +30 -13
  303. package/dist/transactions/transaction-plan-assembler.js +184 -32
  304. package/dist/transactions/transaction-plan-validator.d.ts +50 -25
  305. package/dist/transactions/transaction-plan-validator.js +96 -38
  306. package/dist/transactions/transaction-reference-collector.d.ts +5 -5
  307. package/dist/transactions/transaction-reference-resolver.d.ts +21 -3
  308. package/dist/transactions/transaction-reference-resolver.js +26 -14
  309. package/dist/transactions/transaction-reference-validator.d.ts +74 -4
  310. package/dist/transactions/transaction-reference-validator.js +129 -71
  311. package/dist/transactions/transaction-reference.d.ts +14 -14
  312. package/dist/transactions/transaction-reference.js +5 -0
  313. package/dist/transactions/transaction-request.d.ts +22 -9
  314. package/dist/transactions/transaction-response.d.ts +6 -6
  315. package/dist/transactions/transaction-runtime.d.ts +12 -8
  316. package/dist/transactions/transaction-runtime.js +218 -50
  317. package/dist/transactions/transaction-settlement.runtime.d.ts +52 -0
  318. package/dist/transactions/transaction-settlement.runtime.js +120 -0
  319. package/dist/transactions/transaction-slot-path-error.d.ts +4 -4
  320. package/dist/transactions/transaction-slot-path-error.js +4 -2
  321. package/dist/transactions/transaction-slot-writer.js +2 -2
  322. package/dist/transactions/transaction-stage.runtime.d.ts +83 -0
  323. package/dist/transactions/transaction-stage.runtime.js +126 -0
  324. package/package.json +11 -9
  325. package/src/runtime/field-check.evaluator.ts +720 -0
  326. package/dist/config/define-fields.d.ts +0 -42
  327. package/dist/config/define-fields.js +0 -3
  328. package/dist/config/framework-behaviors-config.d.ts +0 -30
  329. package/dist/config/framework-fields-config.d.ts +0 -42
  330. package/dist/config/framework-restrictions-config.d.ts +0 -142
  331. package/dist/json/avz.d.ts +0 -96
  332. package/dist/runtime/field-behavior.d.ts +0 -48
  333. /package/dist/{config/framework-behaviors-config.js → adapters/adapter-sql-statement.js} +0 -0
  334. /package/dist/{config/framework-fields-config.js → adapters/adapter-transaction-executor.interface.js} +0 -0
  335. /package/dist/{json → avz}/index.js +0 -0
  336. /package/dist/{json → avz}/json-shape.registry.js +0 -0
  337. /package/dist/config/{framework-restrictions-config.js → exact-framework-config.js} +0 -0
  338. /package/dist/{runtime/field-behavior.js → config/field-pipeline-config.js} +0 -0
@@ -1,6 +1,7 @@
1
- import type { Framework } from "../framework/framework.js";
2
- import type { OperationResponse } from "../runtime/operation-response.js";
3
- import type { TransactionResponse } from "../transactions/transaction-response.js";
1
+ import type { AvFramework } from "../framework/framework.js";
2
+ import type { AvOperationResponse } from "../runtime/operation-response.js";
3
+ import type { AvState } from "../runtime/request-state.js";
4
+ import type { AvTransactionResponse } from "../transactions/transaction-response.js";
4
5
  import { type AvProtocolRequest, type DecodedOperation, type DecodedOperationRequest, type DecodedTransaction } from "./http-request.decoder.js";
5
6
  import { type AvProtocolResponse } from "./http-response.encoder.js";
6
7
  import { transportFailure } from "./protocol-failure.js";
@@ -11,49 +12,52 @@ import { type SurfaceRoute } from "./protocol-surface.js";
11
12
  */
12
13
  export type AvProtocolBinding = {
13
14
  /**
14
- * Every route a host mounts for the bound ClientContract, from one list, each
15
+ * Every route a host mounts for the bound Contract (the Client Contract, or the
16
+ * Agent Contract under `{ origin: "agent" }`), from one list, each
15
17
  * tagged by `kind`: one `POST` `operation` route per `(resource, family, variant)`
16
- * it advertises — nothing it does not — then the `contract` route `GET /_contract`
18
+ * it advertises and no other, then the `contract` route `GET /_contract`
17
19
  * (always), then the `transactions` route `POST /_transactions` exactly when its
18
- * `transactions` is `"interactive"`. Each path is relative to
19
- * `framework.entrypoint`. Read once at bind time: every call answers the same
20
+ * `transactions` is `"interactive"`, then the `can` route `POST /_access/can`
21
+ * exactly when it has its `access` section. Each path is relative to
22
+ * `framework.api`. Read once at bind time: every call answers the same
20
23
  * deep-frozen list, which is passive data a host may serialize.
21
24
  */
22
25
  readonly surface: () => readonly SurfaceRoute[];
23
26
  /**
24
- * An operation route's HTTP request → the client-origin request
27
+ * An operation route's HTTP request → the client-origin (or the binding's
28
+ * agent-origin) request
25
29
  * `framework.execute` takes, or the framework response that answers it instead,
26
30
  * with the request id either way. Answers absence for an unadvertised triple
27
31
  * without executing it, so a catch-all host is safe. Raw body: size, content type,
28
- * JSON and shape enforced; parsed body: shape only — the rest was the host's
29
- * parser's.
32
+ * JSON and shape enforced; parsed body: shape only, since the rest was the
33
+ * host's parser's job.
30
34
  */
31
35
  readonly decodeOperation: (request: AvProtocolRequest) => DecodedOperation;
32
36
  /**
33
- * The same for `/_transactions` → the client-origin plan request
34
- * `framework.executeTransaction` takes; absent unless the ClientContract's
37
+ * The same for `/_transactions` → the binding's origin's plan request
38
+ * `framework.executeTransaction` takes; absent unless the bound Contract's
35
39
  * transactions are `"interactive"`.
36
40
  */
37
41
  readonly decodeTransaction: (request: AvProtocolRequest) => DecodedTransaction;
38
42
  /**
39
- * One operation's framework response — what `framework.execute` answered — as the
43
+ * One operation's framework response (what `framework.execute` answered) as the
40
44
  * HTTP response a host writes: the code's status, `data` in wire forms, `Aventara-
41
45
  * Request-Id` echoed. A result with no wire form answers `A3003` → 500. A
42
46
  * diagnostic of one operation names it (`resource`, `family`, `variant`), so the
43
- * `A3003` reaches the diagnostics sink only when the host passes `decoded` —
44
- * `decodeOperation`'s success value — as `handleOperation` does; without it the
47
+ * `A3003` reaches the diagnostics sink only when the host passes `decoded`
48
+ * (`decodeOperation`'s success value), as `handleOperation` does; without it the
45
49
  * answer is the same and nothing is reported.
46
50
  */
47
- readonly encodeOperation: (response: OperationResponse, requestId: string, decoded?: DecodedOperationRequest) => AvProtocolResponse;
51
+ readonly encodeOperation: (response: AvOperationResponse, requestId: string, decoded?: DecodedOperationRequest) => AvProtocolResponse;
48
52
  /**
49
- * The same for `/_transactions` — what `framework.executeTransaction` answered. An
53
+ * The same for `/_transactions`: what `framework.executeTransaction` answered. An
50
54
  * `A3003` is reported to the Framework's diagnostics sink as a `"transaction"`
51
- * diagnostic — client origin, this `requestId`, the step it blames as `operation` —
55
+ * diagnostic (client origin, this `requestId`, the step it blames as `operation`)
52
56
  * with the value that had no wire form (or what its getter threw) as `error`.
53
57
  */
54
- readonly encodeTransaction: (response: TransactionResponse, requestId: string) => AvProtocolResponse;
58
+ readonly encodeTransaction: (response: AvTransactionResponse, requestId: string) => AvProtocolResponse;
55
59
  /**
56
- * A transport code — `A2000`, `A2010`, `A2011` or `A2012` — as the complete
60
+ * A transport code (`A2000`, `A2010`, `A2011` or `A2012`) as the complete
57
61
  * framework response. For a host that parses the body itself and must answer
58
62
  * its parser's failure. `A2012` requires the methods its route allows, so
59
63
  * every 405 carries `Allow`.
@@ -67,20 +71,44 @@ export type AvProtocolBinding = {
67
71
  * host hands it: one that is not an `AvProtocolRequest` answers `400 A2000`; it
68
72
  * never rejects.
69
73
  */
70
- readonly handleOperation: (request: AvProtocolRequest) => Promise<AvProtocolResponse>;
74
+ readonly handleOperation: (request: AvProtocolRequest, options?: {
75
+ /**
76
+ * Seeds the request's `ctx.$state` (a host reads its platform request
77
+ * here, Passport's `req.user`, say). Called once, after decoding; a
78
+ * throw is answered like any developer failure. Omitted, the state is `{}`.
79
+ */
80
+ readonly state?: () => AvState | Promise<AvState>;
81
+ }) => Promise<AvProtocolResponse>;
71
82
  /**
72
83
  * The same for `/_transactions`: `decodeTransaction` →
73
84
  * `framework.executeTransaction` → `encodeTransaction`. Every step runs under
74
85
  * ClientContract rules; a committed plan is `200 A1009`, a rolled-back one its
75
86
  * failing step's own status.
76
87
  */
77
- readonly handleTransaction: (request: AvProtocolRequest) => Promise<AvProtocolResponse>;
88
+ readonly handleTransaction: (request: AvProtocolRequest, options?: {
89
+ /** Seeds the plan's one `ctx.$state`, as for `handleOperation`. */
90
+ readonly state?: () => AvState | Promise<AvState>;
91
+ }) => Promise<AvProtocolResponse>;
92
+ /**
93
+ * The `POST /_access/can` shortcut: the request decoded, its `ctx.$state`
94
+ * seeded through `options.state`, its `{ questions }` answered by the bound
95
+ * Framework's policy engine under the principal `ctx.$state.me`, and the answer
96
+ * encoded: `200 A1000` with one boolean per question, in order. It only shapes
97
+ * a UI, so it refuses malformed input only, never `403`. Absent (`404 A2002`)
98
+ * unless the bound Contract has its `access` section, which it has exactly when
99
+ * the framework's `access` option is configured. Total over any value, as
100
+ * `handleOperation` is.
101
+ */
102
+ readonly handleCan: (request: AvProtocolRequest, options?: {
103
+ /** Seeds the request's `ctx.$state`, as for `handleOperation`. */
104
+ readonly state?: () => AvState | Promise<AvState>;
105
+ }) => Promise<AvProtocolResponse>;
78
106
  /**
79
107
  * The `GET /_contract` responder: the bound ClientContract's JCS-canonical bytes,
80
108
  * `ETag` its quoted hash, `Cache-Control: no-cache`, and `304` with no body when
81
109
  * `If-None-Match` matches (weak comparison, a list, `*`). Requires no identity
82
- * header; any other method is `405 A2012` with `Allow: GET`. The bytes are written
83
- * once, at bind time.
110
+ * header; any other method is `405 A2012` with `Allow: GET`. The bytes are the ones
111
+ * the Contract's hash was taken over, written once, at construction.
84
112
  */
85
113
  readonly encodeContract: (request: AvProtocolRequest) => AvProtocolResponse;
86
114
  /**
@@ -91,12 +119,22 @@ export type AvProtocolBinding = {
91
119
  * `undefined` for a path outside the protocol's namespace, which the host
92
120
  * answers itself. An operation or `/_transactions` route answered `500 A3000`
93
121
  * is also reported once to the Framework's diagnostics sink, as an
94
- * `UnmountedRouteError` naming the route the host did not mount.
122
+ * `AvUnmountedRouteError` naming the route the host did not mount.
95
123
  */
96
124
  readonly answerAbsent: (request: AvProtocolRequest) => AvProtocolResponse | undefined;
97
125
  };
98
126
  /**
99
- * `AvProtocol.bind(framework)`: reads the instance's compiled ClientContract
100
- * once and returns the bound members, frozen.
127
+ * `AvProtocol.bind(framework, options?)`: reads the instance's compiled Client
128
+ * Contract (or, with `{ origin: "agent" }`, its Agent Contract) once and returns
129
+ * the bound members, frozen. Every request decoded through it runs under that
130
+ * origin.
101
131
  */
102
- export declare function bind(framework: Framework): AvProtocolBinding;
132
+ export declare function bind(framework: AvFramework, options?: {
133
+ /**
134
+ * The origin every request through this binding runs under: `"client"`
135
+ * (the default: the Client Contract, `/_contract`'s document) or `"agent"`
136
+ * (the Agent Contract, its hash and its layer's pipelines), for a host
137
+ * that serves an AI agent — an MCP server.
138
+ */
139
+ readonly origin?: "client" | "agent";
140
+ }): AvProtocolBinding;
@@ -1,36 +1,42 @@
1
+ import { accessQuestionsOf } from "../policy/access-question.registry.js";
1
2
  import { diagnosticsSinkOf } from "../runtime/diagnostics-reporter.js";
2
3
  import { ownedExecutionOf } from "../runtime/owned-execution.registry.js";
3
4
  import { answerAbsentRequest } from "./absent-route.responder.js";
4
5
  import { contractDocumentOf, encodeContractRequest, } from "./contract-document.responder.js";
5
6
  import { decodeOperationRequest, decodeTransactionRequest, } from "./http-request.decoder.js";
6
7
  import { encodeOperationResponse, encodeTransactionResponse, } from "./http-response.encoder.js";
7
- import { handleOperationRequest, handleTransactionRequest, operationUnencodableReport, planUnencodableReport, } from "./protocol.handler.js";
8
+ import { handleCanRequest, handleOperationRequest, handleTransactionRequest, operationUnencodableReport, planUnencodableReport, } from "./protocol.handler.js";
8
9
  import { transportFailure } from "./protocol-failure.js";
9
10
  import { surfaceOf } from "./protocol-surface.js";
10
- export function bind(framework) {
11
+ export function bind(framework, options) {
11
12
  const { contracts } = framework;
12
- const surface = surfaceOf(contracts.client);
13
- const document = contractDocumentOf(contracts.client);
13
+ const origin = options?.origin === "agent" ? "agent" : "client";
14
+ const contract = contracts[origin];
15
+ const surface = surfaceOf(contract);
16
+ const document = contractDocumentOf(contract);
14
17
  const sink = diagnosticsSinkOf(framework);
15
18
  const handler = {
16
19
  contracts,
20
+ origin,
17
21
  execute: (request) => framework.execute(request),
18
22
  executeTransaction: (request) => framework.executeTransaction(request),
19
23
  owned: ownedExecutionOf(framework),
20
24
  sink,
25
+ can: accessQuestionsOf(framework),
21
26
  };
22
27
  return Object.freeze({
23
28
  surface: () => surface,
24
- decodeOperation: (request) => decodeOperationRequest(contracts, request),
25
- decodeTransaction: (request) => decodeTransactionRequest(contracts, request),
29
+ decodeOperation: (request) => decodeOperationRequest(contracts, request, origin),
30
+ decodeTransaction: (request) => decodeTransactionRequest(contracts, request, origin),
26
31
  encodeOperation: (response, requestId, decoded) => encodeOperationResponse(response, requestId, decoded === undefined
27
32
  ? undefined
28
33
  : operationUnencodableReport(sink, decoded.request)),
29
- encodeTransaction: (response, requestId) => encodeTransactionResponse(response, requestId, planUnencodableReport(sink, requestId)),
34
+ encodeTransaction: (response, requestId) => encodeTransactionResponse(response, requestId, planUnencodableReport(sink, requestId, origin)),
30
35
  failure: transportFailure,
31
- handleOperation: (request) => handleOperationRequest(handler, request),
32
- handleTransaction: (request) => handleTransactionRequest(handler, request),
36
+ handleOperation: (request, options) => handleOperationRequest(handler, request, options),
37
+ handleTransaction: (request, options) => handleTransactionRequest(handler, request, options),
38
+ handleCan: (request, options) => handleCanRequest(handler, request, options),
33
39
  encodeContract: (request) => encodeContractRequest(document, request),
34
- answerAbsent: (request) => answerAbsentRequest(contracts, request, sink),
40
+ answerAbsent: (request) => answerAbsentRequest(contracts, request, sink, origin),
35
41
  });
36
42
  }
@@ -1,8 +1,11 @@
1
- import type { FrameworkContracts } from "../compiler/contract.compiler.js";
2
- import type { Framework } from "../framework/framework.js";
3
- import { type FrameworkDiagnosticsSink } from "../runtime/diagnostics-reporter.js";
4
- import type { ClientOperationRequest } from "../runtime/operation-request.js";
1
+ import type { AvContracts } from "../compiler/contract.compiler.js";
2
+ import type { RemoteRequestOrigin } from "../config/config-layer.js";
3
+ import type { AvFramework } from "../framework/framework.js";
4
+ import type { AccessQuestionsAnswerer } from "../policy/access-question.runtime.js";
5
+ import { type AvDiagnosticsSink } from "../runtime/diagnostics-reporter.js";
6
+ import type { RemoteOperationRequest } from "../runtime/operation-request.js";
5
7
  import type { OwnedExecution } from "../runtime/owned-execution.registry.js";
8
+ import type { AvState } from "../runtime/request-state.js";
6
9
  import { type AvProtocolRequest } from "./http-request.decoder.js";
7
10
  import { type AvProtocolResponse, type UnencodableReport } from "./http-response.encoder.js";
8
11
  /**
@@ -11,12 +14,21 @@ import { type AvProtocolResponse, type UnencodableReport } from "./http-response
11
14
  * decoder parsed without copying it again (absent for anything but a
12
15
  * constructed Framework) — and its configured diagnostics sink.
13
16
  */
14
- export type HandlerContext = {
15
- readonly contracts: FrameworkContracts;
16
- readonly execute: Framework["execute"];
17
- readonly executeTransaction: Framework["executeTransaction"];
17
+ type HandlerContext = {
18
+ readonly contracts: AvContracts;
19
+ /** The origin every request the binding decodes runs under. */
20
+ readonly origin: RemoteRequestOrigin;
21
+ readonly execute: AvFramework["execute"];
22
+ readonly executeTransaction: AvFramework["executeTransaction"];
18
23
  readonly owned: OwnedExecution | undefined;
19
- readonly sink: FrameworkDiagnosticsSink | undefined;
24
+ readonly sink: AvDiagnosticsSink | undefined;
25
+ /** The Framework's `can` answerer: absent for one without `access`, or anything `createFramework` did not return. */
26
+ readonly can: AccessQuestionsAnswerer | undefined;
27
+ };
28
+ /** What a host passes beside one protocol request. */
29
+ export type ProtocolCallOptions = {
30
+ /** Seeds the request's `ctx.$state`; called once, after decoding. Omitted, the state is `{}`. */
31
+ readonly state?: () => AvState | Promise<AvState>;
20
32
  };
21
33
  /**
22
34
  * Where a plan's `A3003` goes: the Framework's diagnostics sink, as a `"transaction"`
@@ -24,15 +36,15 @@ export type HandlerContext = {
24
36
  * encoder blames as `operation` when it blames one. One spelling for both
25
37
  * `protocol.encodeTransaction` and `protocol.handleTransaction`.
26
38
  */
27
- export declare function planUnencodableReport(sink: FrameworkDiagnosticsSink | undefined, requestId: string): UnencodableReport;
39
+ export declare function planUnencodableReport(sink: AvDiagnosticsSink | undefined, requestId: string, origin?: RemoteRequestOrigin): UnencodableReport;
28
40
  /**
29
41
  * Where one operation's `A3003` goes: the Framework's diagnostics sink, as an
30
42
  * `"operation"` diagnostic carrying the decoded request's identity and id — the shape
31
- * the public `OperationDiagnostic` already has. One spelling for
43
+ * the public `AvOperationDiagnostic` already has. One spelling for
32
44
  * `protocol.handleOperation` and for `protocol.encodeOperation` given the decoded
33
45
  * request.
34
46
  */
35
- export declare function operationUnencodableReport(sink: FrameworkDiagnosticsSink | undefined, request: ClientOperationRequest): UnencodableReport;
47
+ export declare function operationUnencodableReport(sink: AvDiagnosticsSink | undefined, request: RemoteOperationRequest): UnencodableReport;
36
48
  /**
37
49
  * `protocol.handleOperation(request)`: the three steps a host would otherwise spell
38
50
  * out — `decodeOperation` → `framework.execute` → `encodeOperation` — in one call,
@@ -40,7 +52,7 @@ export declare function operationUnencodableReport(sink: FrameworkDiagnosticsSin
40
52
  * itself (a transport failure, an identity mismatch, an unadvertised route) is
41
53
  * answered without executing.
42
54
  */
43
- export declare function handleOperationRequest(context: HandlerContext, request: AvProtocolRequest): Promise<AvProtocolResponse>;
55
+ export declare function handleOperationRequest(context: HandlerContext, request: AvProtocolRequest, options?: ProtocolCallOptions): Promise<AvProtocolResponse>;
44
56
  /**
45
57
  * `protocol.handleTransaction(request)`: the same shortcut for `/_transactions` —
46
58
  * `decodeTransaction` → `framework.executeTransaction` → `encodeTransaction`. The
@@ -52,4 +64,12 @@ export declare function handleOperationRequest(context: HandlerContext, request:
52
64
  * handleOperationRequest} is; an `A3003` is reported through {@link
53
65
  * planUnencodableReport}.
54
66
  */
55
- export declare function handleTransactionRequest(context: HandlerContext, request: AvProtocolRequest): Promise<AvProtocolResponse>;
67
+ export declare function handleTransactionRequest(context: HandlerContext, request: AvProtocolRequest, options?: ProtocolCallOptions): Promise<AvProtocolResponse>;
68
+ /**
69
+ * `protocol.handleCan(request)`: the `/_access/can` request decoded, its state
70
+ * seeded, its questions answered by the bound Framework, and the answer encoded —
71
+ * `200 A1000` with one boolean per question, in order, or the refusal. Total over
72
+ * any value, as {@link handleOperationRequest} is.
73
+ */
74
+ export declare function handleCanRequest(context: HandlerContext, request: AvProtocolRequest, options?: ProtocolCallOptions): Promise<AvProtocolResponse>;
75
+ export {};
@@ -1,20 +1,79 @@
1
+ import { copyAtDoor } from "../runtime/caller-data.door.js";
1
2
  import { createDiagnosticsReporter, createReporter, } from "../runtime/diagnostics-reporter.js";
2
- import { decodeOperationRequest, decodeTransactionRequest, isParsedByDecoder, } from "./http-request.decoder.js";
3
+ import { sanitizeOperationFailure } from "../runtime/error-boundary.js";
4
+ import { internalFailure, } from "../runtime/operation-response.js";
5
+ import { capturePlanAtCall } from "../transactions/transaction-plan-validator.js";
6
+ import { decodeCanRequest, decodeOperationRequest, decodeTransactionRequest, isParsedByDecoder, } from "./http-request.decoder.js";
3
7
  import { encodeOperationResponse, encodeTransactionResponse, } from "./http-response.encoder.js";
4
- function operationEntry(context, request) {
5
- return context.owned !== undefined && isParsedByDecoder(request.arguments)
6
- ? context.owned.execute
7
- : context.execute;
8
+ function admitOperation(context, request) {
9
+ const owned = context.owned;
10
+ if (isParsedByDecoder(request.arguments)) {
11
+ return { request, run: owned?.execute ?? context.execute };
12
+ }
13
+ const copy = copyAtDoor(request.arguments);
14
+ if (owned === undefined) {
15
+ return {
16
+ request: copy.ok ? { ...request, arguments: copy.value } : request,
17
+ run: context.execute,
18
+ };
19
+ }
20
+ if (copy.ok) {
21
+ return {
22
+ request: { ...request, arguments: copy.value },
23
+ run: (admitted) => owned.execute(admitted),
24
+ };
25
+ }
26
+ return {
27
+ request: { ...request, arguments: {} },
28
+ run: (admitted) => owned.execute(admitted, copy.error),
29
+ };
8
30
  }
9
- function transactionEntry(context, request) {
10
- return context.owned !== undefined && isParsedByDecoder(request.plan)
11
- ? context.owned.executeTransaction
12
- : context.executeTransaction;
31
+ function admitTransaction(context, request) {
32
+ const owned = context.owned;
33
+ if (isParsedByDecoder(request.plan)) {
34
+ return {
35
+ request,
36
+ run: owned?.executeTransaction ?? context.executeTransaction,
37
+ };
38
+ }
39
+ const captured = capturePlanAtCall(request.plan);
40
+ if (owned === undefined) {
41
+ return {
42
+ request: captured.refused.size === 0
43
+ ? { ...request, plan: captured.plan }
44
+ : request,
45
+ run: context.executeTransaction,
46
+ };
47
+ }
48
+ return {
49
+ request: { ...request, plan: captured.plan },
50
+ run: (admitted) => owned.executeTransaction(admitted, captured.refused.size === 0 ? undefined : captured.refused),
51
+ };
52
+ }
53
+ async function seededState(options, report, view) {
54
+ if (options?.state === undefined) {
55
+ return { ok: true, state: undefined };
56
+ }
57
+ try {
58
+ const state = await options.state();
59
+ return {
60
+ ok: true,
61
+ state: typeof state === "object" && state !== null && !Array.isArray(state)
62
+ ? state
63
+ : undefined,
64
+ };
65
+ }
66
+ catch (error) {
67
+ return {
68
+ ok: false,
69
+ response: sanitizeOperationFailure(error, "runtime", report, view),
70
+ };
71
+ }
13
72
  }
14
- export function planUnencodableReport(sink, requestId) {
73
+ export function planUnencodableReport(sink, requestId, origin = "client") {
15
74
  return (error, operation) => createReporter(sink, {
16
75
  kind: "transaction",
17
- origin: "client",
76
+ origin,
18
77
  requestId,
19
78
  ...(operation === undefined ? {} : { operation }),
20
79
  })(error, "A3003");
@@ -22,19 +81,64 @@ export function planUnencodableReport(sink, requestId) {
22
81
  export function operationUnencodableReport(sink, request) {
23
82
  return (error) => createDiagnosticsReporter(sink, request)(error, "A3003");
24
83
  }
25
- export async function handleOperationRequest(context, request) {
26
- const decoded = decodeOperationRequest(context.contracts, request);
84
+ export async function handleOperationRequest(context, request, options) {
85
+ const decoded = decodeOperationRequest(context.contracts, request, context.origin);
27
86
  if (!decoded.ok) {
28
87
  return decoded.response;
29
88
  }
30
- const response = await operationEntry(context, decoded.request)(decoded.request);
89
+ const admitted = admitOperation(context, decoded.request);
90
+ const seeded = await seededState(options, createDiagnosticsReporter(context.sink, admitted.request), { path: ["arguments"], arguments: admitted.request.arguments });
91
+ const response = seeded.ok
92
+ ? await admitted.run(seeded.state === undefined
93
+ ? admitted.request
94
+ : { ...admitted.request, state: seeded.state })
95
+ : seeded.response;
31
96
  return encodeOperationResponse(response, decoded.requestId, operationUnencodableReport(context.sink, decoded.request));
32
97
  }
33
- export async function handleTransactionRequest(context, request) {
34
- const decoded = decodeTransactionRequest(context.contracts, request);
98
+ export async function handleTransactionRequest(context, request, options) {
99
+ const decoded = decodeTransactionRequest(context.contracts, request, context.origin);
35
100
  if (!decoded.ok) {
36
101
  return decoded.response;
37
102
  }
38
- const response = await transactionEntry(context, decoded.request)(decoded.request);
39
- return encodeTransactionResponse(response, decoded.requestId, planUnencodableReport(context.sink, decoded.requestId));
103
+ const admitted = admitTransaction(context, decoded.request);
104
+ const seeded = await seededState(options, createReporter(context.sink, {
105
+ kind: "transaction",
106
+ origin: context.origin,
107
+ requestId: decoded.requestId,
108
+ }), { path: ["plan"], arguments: admitted.request.plan });
109
+ const response = seeded.ok
110
+ ? await admitted.run(seeded.state === undefined
111
+ ? admitted.request
112
+ : { ...admitted.request, state: seeded.state })
113
+ : seeded.response;
114
+ return encodeTransactionResponse(response, decoded.requestId, planUnencodableReport(context.sink, decoded.requestId, context.origin));
115
+ }
116
+ export async function handleCanRequest(context, request, options) {
117
+ const decoded = decodeCanRequest(context.contracts, request, context.origin);
118
+ if (!decoded.ok) {
119
+ return decoded.response;
120
+ }
121
+ const { requestId, body } = decoded.request;
122
+ const report = createReporter(context.sink, {
123
+ kind: "can",
124
+ origin: "client",
125
+ requestId,
126
+ });
127
+ if (context.can === undefined) {
128
+ report(new Error("The bound Framework has no answerer for /_access/can."), "A3000");
129
+ return encodeOperationResponse(internalFailure(), requestId);
130
+ }
131
+ const seeded = await seededState(options, report, {
132
+ path: ["questions"],
133
+ arguments: body,
134
+ });
135
+ const response = seeded.ok
136
+ ? await context.can({
137
+ origin: context.origin,
138
+ requestId,
139
+ ...(seeded.state === undefined ? {} : { state: seeded.state }),
140
+ body,
141
+ })
142
+ : seeded.response;
143
+ return encodeOperationResponse(response, requestId);
40
144
  }
@@ -5,15 +5,15 @@
5
5
  * `500 A3000` is unchanged; this error names the route the host left out, so the
6
6
  * server's diagnostics show it too. It is never sent to the caller.
7
7
  */
8
- export declare class UnmountedRouteError extends Error {
8
+ export declare class AvUnmountedRouteError extends Error {
9
9
  /** What the ClientContract advertises: `resource.family.variant`, or `transactions`. */
10
10
  readonly advertised: string;
11
- /** The route as the request reached it: method and entrypoint-relative path. */
11
+ /** The route as the request reached it: method and api-relative path. */
12
12
  readonly route: string;
13
- readonly name = "UnmountedRouteError";
13
+ readonly name = "AvUnmountedRouteError";
14
14
  constructor(
15
15
  /** What the ClientContract advertises: `resource.family.variant`, or `transactions`. */
16
16
  advertised: string,
17
- /** The route as the request reached it: method and entrypoint-relative path. */
17
+ /** The route as the request reached it: method and api-relative path. */
18
18
  route: string);
19
19
  }
@@ -1,7 +1,7 @@
1
- export class UnmountedRouteError extends Error {
1
+ export class AvUnmountedRouteError extends Error {
2
2
  advertised;
3
3
  route;
4
- name = "UnmountedRouteError";
4
+ name = "AvUnmountedRouteError";
5
5
  constructor(advertised, route) {
6
6
  super(`The ClientContract advertises ${advertised}, but the host mounted no route for ${route}, so protocol.answerAbsent answered it 500 A3000. Mount every protocol.surface() entry.`);
7
7
  this.advertised = advertised;
@@ -1,5 +1,5 @@
1
1
  /** Why a caller value could not be copied. */
2
- export type CallerDataFailureKind = "unreadable-value" | "non-plain-value";
2
+ type CallerDataFailureKind = "unreadable-value" | "non-plain-value";
3
3
  /** A data location inside the copied value, from its root. */
4
4
  export type CallerDataPath = readonly (string | number)[];
5
5
  /**
@@ -7,7 +7,7 @@ export type CallerDataPath = readonly (string | number)[];
7
7
  * root. Thrown by {@link copyCallerData} and caught by every door, which answers it as
8
8
  * the caller's `A2004`/`V1001` at its own address. It never carries the value.
9
9
  */
10
- export declare class CallerDataError extends Error {
10
+ export declare class AvCallerDataError extends Error {
11
11
  readonly kind: CallerDataFailureKind;
12
12
  readonly path: CallerDataPath;
13
13
  /**
@@ -15,7 +15,7 @@ export declare class CallerDataError extends Error {
15
15
  * tripwire read after the door; {@link locateCallerDataError} resolves it.
16
16
  */
17
17
  readonly within?: object | undefined;
18
- readonly name = "CallerDataError";
18
+ readonly name = "AvCallerDataError";
19
19
  constructor(kind: CallerDataFailureKind, path: CallerDataPath,
20
20
  /**
21
21
  * The control mirror `path` starts from, when the failure is a mirror's
@@ -41,19 +41,34 @@ export type CallerDataPolicy = {
41
41
  readonly keep?: CallerDataKeep;
42
42
  readonly mirror?: CallerDataMirror;
43
43
  };
44
+ /** The members a structural mirror copies by value rather than mirroring. */
45
+ type MirrorMembers = {
46
+ /** The policy a member at `path` (from the mirror's root) is copied by, or `undefined`. */
47
+ readonly copyAt: (path: CallerDataPath) => CallerDataPolicy | undefined;
48
+ /** Receives a member whose copy failed; the mirror holds `undefined` for it. */
49
+ readonly refused: (path: CallerDataPath, error: AvCallerDataError) => void;
50
+ };
51
+ /**
52
+ * Mirrors `value` by its descriptors, as a `$ref` control object is mirrored (no
53
+ * getter runs, an accessor stays a tripwire), except the members `members.copyAt`
54
+ * names by their path: each is copied by value under the policy it returns, and one
55
+ * whose copy fails is reported to `members.refused` and held as `undefined`.
56
+ *
57
+ * @throws {@link AvCallerDataError} at `[]` when `value` itself cannot be reflected.
58
+ */
59
+ export declare function mirrorCallerData(value: object, members: MirrorMembers): unknown;
44
60
  /**
45
61
  * Places a mirror tripwire's failure in the value the door copied: its path from the
46
62
  * copy's root, where `error.path` started from the mirror. A failure that is not a
47
63
  * tripwire's, or a mirror the copy does not hold, is returned as it is.
48
64
  */
49
- export declare function locateCallerDataError(error: CallerDataError, copy: unknown): CallerDataError;
65
+ export declare function locateCallerDataError(error: AvCallerDataError, copy: unknown): AvCallerDataError;
50
66
  /**
51
67
  * Copies a caller's value into fresh plain data (see the module note), reading the
52
68
  * caller's objects exactly once.
53
69
  *
54
- * @throws {@link CallerDataError} when a value cannot be read or is not plain data,
70
+ * @throws {@link AvCallerDataError} when a value cannot be read or is not plain data,
55
71
  * naming its path from `value`.
56
72
  */
57
73
  export declare function copyCallerData(value: unknown, policy?: CallerDataPolicy): unknown;
58
- /** The `V1001` message a door answers a {@link CallerDataError} with. */
59
- export declare function callerDataFailureMessage(kind: CallerDataFailureKind): string;
74
+ export {};