@decionis/agentsafe 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/README.md +62 -19
  2. package/dist/Cli.js +18 -1
  3. package/dist/Cli.js.map +1 -1
  4. package/dist/Index.d.ts +9 -4
  5. package/dist/Index.d.ts.map +1 -1
  6. package/dist/Index.js +7 -2
  7. package/dist/Index.js.map +1 -1
  8. package/dist/TrustedExecutor.d.ts.map +1 -1
  9. package/dist/TrustedExecutor.js +2 -0
  10. package/dist/TrustedExecutor.js.map +1 -1
  11. package/dist/adapters/AdapterActionHandler.d.ts +36 -12
  12. package/dist/adapters/AdapterActionHandler.d.ts.map +1 -1
  13. package/dist/adapters/AdapterActionHandler.js +99 -100
  14. package/dist/adapters/AdapterActionHandler.js.map +1 -1
  15. package/dist/adapters/EffectAdapter.d.ts +7 -103
  16. package/dist/adapters/EffectAdapter.d.ts.map +1 -1
  17. package/dist/adapters/EffectAdapter.js +7 -18
  18. package/dist/adapters/EffectAdapter.js.map +1 -1
  19. package/dist/adapters/EffectAdapterExecutor.d.ts +93 -0
  20. package/dist/adapters/EffectAdapterExecutor.d.ts.map +1 -0
  21. package/dist/adapters/EffectAdapterExecutor.js +191 -0
  22. package/dist/adapters/EffectAdapterExecutor.js.map +1 -0
  23. package/dist/adapters/banking/BankingExecutor.d.ts +35 -0
  24. package/dist/adapters/banking/BankingExecutor.d.ts.map +1 -0
  25. package/dist/adapters/banking/BankingExecutor.js +64 -0
  26. package/dist/adapters/banking/BankingExecutor.js.map +1 -0
  27. package/dist/adapters/banking/BankingHandlers.d.ts.map +1 -1
  28. package/dist/adapters/banking/BankingHandlers.js +6 -3
  29. package/dist/adapters/banking/BankingHandlers.js.map +1 -1
  30. package/dist/adapters/cards/CardAuthorizationExecutor.d.ts +66 -0
  31. package/dist/adapters/cards/CardAuthorizationExecutor.d.ts.map +1 -0
  32. package/dist/adapters/cards/CardAuthorizationExecutor.js +116 -0
  33. package/dist/adapters/cards/CardAuthorizationExecutor.js.map +1 -0
  34. package/dist/adapters/mcp/McpGuard.d.ts +32 -3
  35. package/dist/adapters/mcp/McpGuard.d.ts.map +1 -1
  36. package/dist/adapters/mcp/McpGuard.js +29 -5
  37. package/dist/adapters/mcp/McpGuard.js.map +1 -1
  38. package/dist/adapters/mcp/McpIntentBinder.d.ts +18 -3
  39. package/dist/adapters/mcp/McpIntentBinder.d.ts.map +1 -1
  40. package/dist/adapters/mcp/McpIntentBinder.js +48 -1
  41. package/dist/adapters/mcp/McpIntentBinder.js.map +1 -1
  42. package/dist/adapters/mcp/McpInvocation.d.ts +9 -2
  43. package/dist/adapters/mcp/McpInvocation.d.ts.map +1 -1
  44. package/dist/adapters/mcp/McpInvocation.js.map +1 -1
  45. package/dist/cli/Actions.d.ts +14 -0
  46. package/dist/cli/Actions.d.ts.map +1 -0
  47. package/dist/cli/Actions.js +168 -0
  48. package/dist/cli/Actions.js.map +1 -0
  49. package/dist/cli/Arguments.d.ts +4 -0
  50. package/dist/cli/Arguments.d.ts.map +1 -1
  51. package/dist/cli/Arguments.js +12 -3
  52. package/dist/cli/Arguments.js.map +1 -1
  53. package/dist/cli/ConfigCommand.d.ts.map +1 -1
  54. package/dist/cli/ConfigCommand.js +5 -0
  55. package/dist/cli/ConfigCommand.js.map +1 -1
  56. package/dist/cli/Doctor.d.ts.map +1 -1
  57. package/dist/cli/Doctor.js +2 -1
  58. package/dist/cli/Doctor.js.map +1 -1
  59. package/dist/cli/Help.d.ts.map +1 -1
  60. package/dist/cli/Help.js +13 -1
  61. package/dist/cli/Help.js.map +1 -1
  62. package/dist/cli/Host.d.ts +5 -2
  63. package/dist/cli/Host.d.ts.map +1 -1
  64. package/dist/cli/Host.js +24 -2
  65. package/dist/cli/Host.js.map +1 -1
  66. package/dist/cli/Profile.d.ts +24 -0
  67. package/dist/cli/Profile.d.ts.map +1 -0
  68. package/dist/cli/Profile.js +168 -0
  69. package/dist/cli/Profile.js.map +1 -0
  70. package/dist/cli/Records.d.ts +15 -0
  71. package/dist/cli/Records.d.ts.map +1 -0
  72. package/dist/cli/Records.js +205 -0
  73. package/dist/cli/Records.js.map +1 -0
  74. package/dist/config/ConfigKeys.d.ts +2 -2
  75. package/dist/config/ConfigKeys.d.ts.map +1 -1
  76. package/dist/config/ConfigKeys.js +6 -0
  77. package/dist/config/ConfigKeys.js.map +1 -1
  78. package/dist/config/ExecutorConfig.d.ts +29 -0
  79. package/dist/config/ExecutorConfig.d.ts.map +1 -1
  80. package/dist/config/ExecutorConfig.js +53 -1
  81. package/dist/config/ExecutorConfig.js.map +1 -1
  82. package/dist/gateway/ForwardHandler.d.ts +22 -4
  83. package/dist/gateway/ForwardHandler.d.ts.map +1 -1
  84. package/dist/gateway/ForwardHandler.js +27 -10
  85. package/dist/gateway/ForwardHandler.js.map +1 -1
  86. package/dist/gateway/Gateway.d.ts +123 -3
  87. package/dist/gateway/Gateway.d.ts.map +1 -1
  88. package/dist/gateway/Gateway.js +513 -16
  89. package/dist/gateway/Gateway.js.map +1 -1
  90. package/dist/gateway/GatewayConfig.d.ts +109 -0
  91. package/dist/gateway/GatewayConfig.d.ts.map +1 -1
  92. package/dist/gateway/GatewayConfig.js +267 -9
  93. package/dist/gateway/GatewayConfig.js.map +1 -1
  94. package/dist/gateway/GatewayReport.d.ts +6 -2
  95. package/dist/gateway/GatewayReport.d.ts.map +1 -1
  96. package/dist/gateway/GatewayReport.js +3 -0
  97. package/dist/gateway/GatewayReport.js.map +1 -1
  98. package/dist/gateway/InterceptedRequest.d.ts +45 -1
  99. package/dist/gateway/InterceptedRequest.d.ts.map +1 -1
  100. package/dist/gateway/InterceptedRequest.js +43 -1
  101. package/dist/gateway/InterceptedRequest.js.map +1 -1
  102. package/dist/gateway/PolicySelector.d.ts +5 -0
  103. package/dist/gateway/PolicySelector.d.ts.map +1 -0
  104. package/dist/gateway/PolicySelector.js +9 -0
  105. package/dist/gateway/PolicySelector.js.map +1 -0
  106. package/dist/gateway/RouteTable.d.ts +44 -7
  107. package/dist/gateway/RouteTable.d.ts.map +1 -1
  108. package/dist/gateway/RouteTable.js +58 -9
  109. package/dist/gateway/RouteTable.js.map +1 -1
  110. package/dist/gateway/SubjectSessions.d.ts +113 -0
  111. package/dist/gateway/SubjectSessions.d.ts.map +1 -0
  112. package/dist/gateway/SubjectSessions.js +219 -0
  113. package/dist/gateway/SubjectSessions.js.map +1 -0
  114. package/dist/gateway/Upstream.d.ts +11 -0
  115. package/dist/gateway/Upstream.d.ts.map +1 -1
  116. package/dist/gateway/Upstream.js +19 -2
  117. package/dist/gateway/Upstream.js.map +1 -1
  118. package/dist/hosted/TenantHost.d.ts +24 -5
  119. package/dist/hosted/TenantHost.d.ts.map +1 -1
  120. package/dist/hosted/TenantHost.js +39 -10
  121. package/dist/hosted/TenantHost.js.map +1 -1
  122. package/dist/hosted/TenantRegistry.d.ts +20 -0
  123. package/dist/hosted/TenantRegistry.d.ts.map +1 -1
  124. package/dist/hosted/TenantRegistry.js +47 -1
  125. package/dist/hosted/TenantRegistry.js.map +1 -1
  126. package/dist/http/GatewayHttpServer.d.ts.map +1 -1
  127. package/dist/http/GatewayHttpServer.js +46 -2
  128. package/dist/http/GatewayHttpServer.js.map +1 -1
  129. package/dist/identity/WorkloadJwtVerifier.d.ts +13 -0
  130. package/dist/identity/WorkloadJwtVerifier.d.ts.map +1 -1
  131. package/dist/identity/WorkloadJwtVerifier.js +40 -8
  132. package/dist/identity/WorkloadJwtVerifier.js.map +1 -1
  133. package/dist/incident/HaltSwitch.d.ts +10 -2
  134. package/dist/incident/HaltSwitch.d.ts.map +1 -1
  135. package/dist/incident/HaltSwitch.js +22 -2
  136. package/dist/incident/HaltSwitch.js.map +1 -1
  137. package/dist/incident/SecurityEvents.d.ts +18 -0
  138. package/dist/incident/SecurityEvents.d.ts.map +1 -1
  139. package/dist/incident/SecurityEvents.js +17 -0
  140. package/dist/incident/SecurityEvents.js.map +1 -1
  141. package/dist/journal/ExecutionJournal.d.ts +5 -120
  142. package/dist/journal/ExecutionJournal.d.ts.map +1 -1
  143. package/dist/journal/ExecutionJournal.js +5 -125
  144. package/dist/journal/ExecutionJournal.js.map +1 -1
  145. package/dist/journal/FileExecutionJournal.d.ts +1 -0
  146. package/dist/journal/FileExecutionJournal.d.ts.map +1 -1
  147. package/dist/journal/FileExecutionJournal.js +4 -1
  148. package/dist/journal/FileExecutionJournal.js.map +1 -1
  149. package/dist/journal/InMemoryExecutionJournal.d.ts +2 -1
  150. package/dist/journal/InMemoryExecutionJournal.d.ts.map +1 -1
  151. package/dist/journal/InMemoryExecutionJournal.js +4 -1
  152. package/dist/journal/InMemoryExecutionJournal.js.map +1 -1
  153. package/dist/limits/HardLimits.d.ts.map +1 -1
  154. package/dist/limits/HardLimits.js.map +1 -1
  155. package/dist/outcomes/CardOutcomeEvidence.d.ts +56 -0
  156. package/dist/outcomes/CardOutcomeEvidence.d.ts.map +1 -0
  157. package/dist/outcomes/CardOutcomeEvidence.js +211 -0
  158. package/dist/outcomes/CardOutcomeEvidence.js.map +1 -0
  159. package/dist/outcomes/CardOutcomeFact.d.ts +90 -0
  160. package/dist/outcomes/CardOutcomeFact.d.ts.map +1 -0
  161. package/dist/outcomes/CardOutcomeFact.js +76 -0
  162. package/dist/outcomes/CardOutcomeFact.js.map +1 -0
  163. package/dist/outcomes/CardOutcomeLedger.d.ts +26 -0
  164. package/dist/outcomes/CardOutcomeLedger.d.ts.map +1 -0
  165. package/dist/outcomes/CardOutcomeLedger.js +31 -0
  166. package/dist/outcomes/CardOutcomeLedger.js.map +1 -0
  167. package/dist/outcomes/CardOutcomeRecorder.d.ts +35 -0
  168. package/dist/outcomes/CardOutcomeRecorder.d.ts.map +1 -0
  169. package/dist/outcomes/CardOutcomeRecorder.js +84 -0
  170. package/dist/outcomes/CardOutcomeRecorder.js.map +1 -0
  171. package/dist/outcomes/CardOutcomes.d.ts +68 -0
  172. package/dist/outcomes/CardOutcomes.d.ts.map +1 -0
  173. package/dist/outcomes/CardOutcomes.js +191 -0
  174. package/dist/outcomes/CardOutcomes.js.map +1 -0
  175. package/dist/outcomes/CoreOutcomeEvidenceClient.d.ts +54 -0
  176. package/dist/outcomes/CoreOutcomeEvidenceClient.d.ts.map +1 -0
  177. package/dist/outcomes/CoreOutcomeEvidenceClient.js +116 -0
  178. package/dist/outcomes/CoreOutcomeEvidenceClient.js.map +1 -0
  179. package/dist/outcomes/FileCardOutcomeLedger.d.ts +36 -0
  180. package/dist/outcomes/FileCardOutcomeLedger.d.ts.map +1 -0
  181. package/dist/outcomes/FileCardOutcomeLedger.js +152 -0
  182. package/dist/outcomes/FileCardOutcomeLedger.js.map +1 -0
  183. package/dist/outcomes/OutcomeEvidence.d.ts +238 -0
  184. package/dist/outcomes/OutcomeEvidence.d.ts.map +1 -0
  185. package/dist/outcomes/OutcomeEvidence.js +130 -0
  186. package/dist/outcomes/OutcomeEvidence.js.map +1 -0
  187. package/dist/outcomes/OutcomeEvidencePublisher.d.ts +81 -0
  188. package/dist/outcomes/OutcomeEvidencePublisher.d.ts.map +1 -0
  189. package/dist/outcomes/OutcomeEvidencePublisher.js +189 -0
  190. package/dist/outcomes/OutcomeEvidencePublisher.js.map +1 -0
  191. package/dist/outcomes/OutcomeEvidenceStore.d.ts +57 -0
  192. package/dist/outcomes/OutcomeEvidenceStore.d.ts.map +1 -0
  193. package/dist/outcomes/OutcomeEvidenceStore.js +191 -0
  194. package/dist/outcomes/OutcomeEvidenceStore.js.map +1 -0
  195. package/dist/service/Requests.d.ts +6 -0
  196. package/dist/service/Requests.d.ts.map +1 -1
  197. package/dist/service/Requests.js +9 -1
  198. package/dist/service/Requests.js.map +1 -1
  199. package/dist/service/TrustedExecutorService.d.ts +21 -1
  200. package/dist/service/TrustedExecutorService.d.ts.map +1 -1
  201. package/dist/service/TrustedExecutorService.js +73 -23
  202. package/dist/service/TrustedExecutorService.js.map +1 -1
  203. package/dist/time/MonotonicClock.d.ts +4 -32
  204. package/dist/time/MonotonicClock.d.ts.map +1 -1
  205. package/dist/time/MonotonicClock.js +4 -49
  206. package/dist/time/MonotonicClock.js.map +1 -1
  207. package/dist/verify/VerifyingProvider.d.ts +32 -6
  208. package/dist/verify/VerifyingProvider.d.ts.map +1 -1
  209. package/dist/verify/VerifyingProvider.js +16 -2
  210. package/dist/verify/VerifyingProvider.js.map +1 -1
  211. package/package.json +6 -5
@@ -0,0 +1,191 @@
1
+ import { IndeterminateOutcome } from "@decionis/agent-safe-pipeline";
2
+ import { authorityEffectEvidence, buildEffectRecord } from "./EffectEvidenceBuilder.js";
3
+ /**
4
+ * Any `EffectAdapter` as a dispatch-style `NativeExecutor`
5
+ * (`agent-safe.executors.native/1`): the adapter keeps its four methods and
6
+ * this class says them in the contract's terms. `prepare` is the adapter's,
7
+ * plus how the action reads as an intent; `execute` is the adapter's write,
8
+ * inside the dispatch the caller opened and within its deadline; `observe`
9
+ * is the adapter's projection turned into the effect record, field by field
10
+ * against what was authorised; `reconcile` is the adapter's read-only
11
+ * lookup, complete only on a matching read-back.
12
+ *
13
+ * The record is evidence, so it rides on the observation for whoever
14
+ * finalizes the grant — the runtime registers it for its verifier — and its
15
+ * wire form rides as `evidence` for a runner that finalizes directly.
16
+ */
17
+ export class EffectAdapterExecutor {
18
+ options;
19
+ platform;
20
+ version;
21
+ style = "dispatch";
22
+ clock;
23
+ /** The adapter's own preparation of each prepared action, so a write never prepares twice. */
24
+ effects = new WeakMap();
25
+ constructor(options) {
26
+ this.options = options;
27
+ this.platform = options.platform;
28
+ this.version = options.adapter.version;
29
+ this.clock = options.clock ?? (() => new Date());
30
+ }
31
+ get actionTypes() {
32
+ return this.options.adapter.actionTypes;
33
+ }
34
+ /** The adapter's observer identity, as the effect record and the authority name it. */
35
+ get observer() {
36
+ return { id: this.options.adapter.id, version: this.options.adapter.version };
37
+ }
38
+ async capabilities(scope) {
39
+ if (this.options.capabilities !== undefined)
40
+ return await this.options.capabilities(scope);
41
+ return this.actionTypes.map((actionType) => ({
42
+ platform: this.platform,
43
+ actionType,
44
+ enabled: true,
45
+ scopeGranted: true,
46
+ connected: true,
47
+ requirement: "",
48
+ }));
49
+ }
50
+ async prepare(action) {
51
+ return await Promise.resolve(this.prepareNow(action));
52
+ }
53
+ /** `prepare`, synchronously: the adapter reaches nothing, so neither does this. */
54
+ prepareNow(action) {
55
+ const effect = this.options.adapter.prepare(action);
56
+ const description = this.options.describe(action, effect);
57
+ const prepared = Object.freeze({
58
+ actionType: description.proposal.action,
59
+ proposal: description.proposal,
60
+ downstreamTarget: description.downstreamTarget,
61
+ idempotencyKey: description.idempotencyKey,
62
+ expectedEffectDigest: effect.expectedEffectDigest,
63
+ requestDigest: effect.requestDigest,
64
+ facts: description.facts,
65
+ });
66
+ this.effects.set(prepared, effect);
67
+ return prepared;
68
+ }
69
+ /**
70
+ * The adapter's write, once, inside the caller's dispatch. A provider that
71
+ * neither committed nor refused is carried as indeterminate, with any
72
+ * receipt it gave; any other error after the dispatch began propagates, so
73
+ * the caller reports an outcome nobody knows.
74
+ */
75
+ async execute(run) {
76
+ const prepared = this.effectOf(run.prepared, run.action);
77
+ let result = null;
78
+ let indeterminate = null;
79
+ let indeterminateReceipt = null;
80
+ try {
81
+ result = await run.dispatch.run(async () => await this.options.adapter.execute({
82
+ action: run.action,
83
+ prepared,
84
+ authorization: run.authorization,
85
+ idempotencyKey: run.dispatch.idempotencyKey,
86
+ deadline: run.deadline,
87
+ }));
88
+ }
89
+ catch (error) {
90
+ if (!(error instanceof IndeterminateOutcome))
91
+ throw error;
92
+ indeterminate = { reason: error.reason, providerStatus: error.providerStatus };
93
+ indeterminateReceipt = error.receipt;
94
+ }
95
+ const signedReceipt = result?.receipt ?? indeterminateReceipt;
96
+ return {
97
+ kind: "DISPATCHED",
98
+ receipt: {
99
+ prepared,
100
+ result,
101
+ indeterminate,
102
+ correlationId: run.intent.intent.intentId,
103
+ idempotencyKey: run.dispatch.idempotencyKey,
104
+ },
105
+ signedReceipt: typeof signedReceipt === "string" ? signedReceipt : null,
106
+ };
107
+ }
108
+ /**
109
+ * The provider's answer as the effect record: the adapter's projection,
110
+ * compared with what was authorised. An outcome nobody can determine stays
111
+ * undetermined; a provider that was reached and said no is a refusal, not
112
+ * a success whose effect block says otherwise.
113
+ */
114
+ async observe(effect) {
115
+ if (effect.kind !== "DISPATCHED" || effect.receipt === null) {
116
+ return await Promise.resolve({ status: "INDETERMINATE", reason: null, result: null });
117
+ }
118
+ const dispatch = effect.receipt;
119
+ const observed = dispatch.result === null
120
+ ? null
121
+ : this.options.adapter.observeEffect(dispatch.result, dispatch.prepared);
122
+ const record = buildEffectRecord({
123
+ prepared: dispatch.prepared,
124
+ result: dispatch.result === null ? null : { ...dispatch.result, observed },
125
+ ...(dispatch.indeterminate === null ? {} : { indeterminate: dispatch.indeterminate }),
126
+ observer: this.observer,
127
+ correlationId: dispatch.correlationId,
128
+ idempotencyKey: dispatch.idempotencyKey,
129
+ observedAt: this.clock().toISOString(),
130
+ });
131
+ const observation = {
132
+ record,
133
+ indeterminate: dispatch.indeterminate,
134
+ correlationId: dispatch.correlationId,
135
+ };
136
+ const evidence = this.evidenceOf(record, dispatch.correlationId);
137
+ if (dispatch.indeterminate !== null) {
138
+ return { status: "INDETERMINATE", reason: null, result: observation, evidence };
139
+ }
140
+ if (record.outcome === "FAILED") {
141
+ return {
142
+ status: "FAILED",
143
+ reason: record.reasonCodes[0] ?? "PROVIDER_REFUSED",
144
+ result: observation,
145
+ evidence,
146
+ };
147
+ }
148
+ return { status: "COMMITTED", reason: null, result: observation, evidence };
149
+ }
150
+ /**
151
+ * The adapter's read-only lookup. Absence of an error is not success: only
152
+ * a read-back whose projection matches what was authorised completes a
153
+ * reconciliation.
154
+ */
155
+ async reconcile(context) {
156
+ const prepared = this.effectOf(context.prepared, context.prepared.proposal.parameters);
157
+ const answer = await this.options.adapter.reconcile({
158
+ idempotencyKey: context.idempotencyKey,
159
+ providerReference: context.providerReference,
160
+ intentHash: context.intent.intentHash,
161
+ prepared,
162
+ });
163
+ if (answer.status !== "COMPLETED")
164
+ return { status: answer.status };
165
+ const observed = this.options.adapter.observeEffect(answer.result, prepared);
166
+ const correlationId = context.intent.intent.intentId;
167
+ const record = buildEffectRecord({
168
+ prepared,
169
+ result: { ...answer.result, observed },
170
+ observer: this.observer,
171
+ correlationId,
172
+ idempotencyKey: context.idempotencyKey,
173
+ observedAt: this.clock().toISOString(),
174
+ });
175
+ if (record.comparison !== "MATCH")
176
+ return { status: "UNKNOWN" };
177
+ return {
178
+ status: "COMPLETED",
179
+ result: { record, indeterminate: null, correlationId },
180
+ evidence: this.evidenceOf(record, correlationId),
181
+ };
182
+ }
183
+ /** The adapter's preparation of a prepared action: remembered from `prepare`, or made again. */
184
+ effectOf(prepared, action) {
185
+ return this.effects.get(prepared) ?? this.options.adapter.prepare(action);
186
+ }
187
+ evidenceOf(record, correlationId) {
188
+ return authorityEffectEvidence(record, correlationId, this.observer);
189
+ }
190
+ }
191
+ //# sourceMappingURL=EffectAdapterExecutor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EffectAdapterExecutor.js","sourceRoot":"","sources":["../../src/adapters/EffectAdapterExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAoBrE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAwCxF;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,qBAAqB;IAYI;IAPpB,QAAQ,CAAa;IACrB,OAAO,CAAS;IAChB,KAAK,GAAG,UAAmB,CAAC;IAC3B,KAAK,CAAa;IACnC,8FAA8F;IAC7E,OAAO,GAAG,IAAI,OAAO,EAAwC,CAAC;IAE/E,YAAoC,OAA8C;QAA9C,YAAO,GAAP,OAAO,CAAuC;QAChF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CA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,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;IAEO,UAAU,CAAC,MAAwB,EAAE,aAAqB;QAChE,OAAO,uBAAuB,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvE,CAAC;CACF"}
@@ -0,0 +1,35 @@
1
+ import type { EffectPreparedAction, ExecutionCapability, ExecutorScope } from "@decionis/agent-safe-pipeline";
2
+ import { EffectAdapterExecutor, type ActionDescription } from "../EffectAdapterExecutor.js";
3
+ import { type BankingAction } from "./BankingAction.js";
4
+ import type { BankingAdapter } from "./BankingAdapter.js";
5
+ export declare const CORE_BANKING_PLATFORM = "core-banking";
6
+ export interface BankingExecutorOptions {
7
+ readonly adapter: BankingAdapter;
8
+ /** What the connection can execute; absent, every registered action is stated as live. */
9
+ readonly capabilities?: (scope: ExecutorScope) => Promise<readonly ExecutionCapability[]>;
10
+ readonly clock?: () => Date;
11
+ }
12
+ /**
13
+ * The banking family on `agent-safe.executors.native/1`, dispatch style: the
14
+ * BEAP adapter performs the write against the core, once, inside the
15
+ * dispatch the runner opens. Everything the family does — the profile's
16
+ * arithmetic, the projection, the comparison, the effect record — is the
17
+ * adapter's, unchanged; this class says how a BEAP action reads as an
18
+ * intent:
19
+ *
20
+ * - the action is the transport name the profile assigns
21
+ * (`beap.<domain>.<type>`) and the resource its target;
22
+ * - the system of record is the downstream provider and operation the
23
+ * action names;
24
+ * - the retry identity is the action's own `request_id`, which the core
25
+ * holds as its idempotency key (by digest when it is longer than an
26
+ * intent carries);
27
+ * - the facts the authority decides with are the domain, the action type and
28
+ * the registered effect, never an amount or an account.
29
+ */
30
+ export declare class BankingExecutor extends EffectAdapterExecutor<BankingAction> {
31
+ constructor(options: BankingExecutorOptions);
32
+ }
33
+ /** How a BEAP action reads as an `agent-safe.intent/1` binding. */
34
+ export declare function describeBankingAction(action: BankingAction, prepared: EffectPreparedAction): ActionDescription;
35
+ //# sourceMappingURL=BankingExecutor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BankingExecutor.d.ts","sourceRoot":"","sources":["../../../src/adapters/banking/BankingExecutor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EAEd,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EAAwC,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AAKpD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,0FAA0F;IAC1F,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,SAAS,mBAAmB,EAAE,CAAC,CAAC;IAC1F,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,eAAgB,SAAQ,qBAAqB,CAAC,aAAa,CAAC;gBACpD,OAAO,EAAE,sBAAsB;CASnD;AAED,mEAAmE;AACnE,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,oBAAoB,GAC7B,iBAAiB,CA2BnB"}
@@ -0,0 +1,64 @@
1
+ import { createHash } from "node:crypto";
2
+ import { EffectAdapterExecutor } from "../EffectAdapterExecutor.js";
3
+ import { transportActionName, transportTarget } from "./BankingAction.js";
4
+ export const CORE_BANKING_PLATFORM = "core-banking";
5
+ /** The longest idempotency key an intent carries; a longer request id is carried by its digest. */
6
+ const MAX_IDEMPOTENCY_KEY = 180;
7
+ /**
8
+ * The banking family on `agent-safe.executors.native/1`, dispatch style: the
9
+ * BEAP adapter performs the write against the core, once, inside the
10
+ * dispatch the runner opens. Everything the family does — the profile's
11
+ * arithmetic, the projection, the comparison, the effect record — is the
12
+ * adapter's, unchanged; this class says how a BEAP action reads as an
13
+ * intent:
14
+ *
15
+ * - the action is the transport name the profile assigns
16
+ * (`beap.<domain>.<type>`) and the resource its target;
17
+ * - the system of record is the downstream provider and operation the
18
+ * action names;
19
+ * - the retry identity is the action's own `request_id`, which the core
20
+ * holds as its idempotency key (by digest when it is longer than an
21
+ * intent carries);
22
+ * - the facts the authority decides with are the domain, the action type and
23
+ * the registered effect, never an amount or an account.
24
+ */
25
+ export class BankingExecutor extends EffectAdapterExecutor {
26
+ constructor(options) {
27
+ super({
28
+ adapter: options.adapter,
29
+ platform: CORE_BANKING_PLATFORM,
30
+ describe: describeBankingAction,
31
+ ...(options.capabilities === undefined ? {} : { capabilities: options.capabilities }),
32
+ ...(options.clock === undefined ? {} : { clock: options.clock }),
33
+ });
34
+ }
35
+ }
36
+ /** How a BEAP action reads as an `agent-safe.intent/1` binding. */
37
+ export function describeBankingAction(action, prepared) {
38
+ const requestId = action.action.request_id;
39
+ return {
40
+ proposal: {
41
+ action: transportActionName(action),
42
+ target: transportTarget(action),
43
+ parameters: action,
44
+ },
45
+ downstreamTarget: {
46
+ system: action.downstream.provider,
47
+ operation: action.downstream.operation,
48
+ ...(action.downstream.environment === undefined
49
+ ? {}
50
+ : { environment: action.downstream.environment }),
51
+ },
52
+ idempotencyKey: requestId.length <= MAX_IDEMPOTENCY_KEY
53
+ ? requestId
54
+ : `sha256:${createHash("sha256").update(requestId, "utf8").digest("hex")}`,
55
+ facts: {
56
+ beap: {
57
+ domain: action.domain,
58
+ action_type: action.action.type,
59
+ effect_type: prepared.effectType,
60
+ },
61
+ },
62
+ };
63
+ }
64
+ //# sourceMappingURL=BankingExecutor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BankingExecutor.js","sourceRoot":"","sources":["../../../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AAG,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS;gBAC7C,CAAC,CAAC,EAAE;gBACJ,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;SACpD;QACD,cAAc,EACZ,SAAS,CAAC,MAAM,IAAI,mBAAmB;YACrC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,UAAU,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;QAC9E,KAAK,EAAE;YACL,IAAI,EAAE;gBACJ,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;gBAC/B,WAAW,EAAE,QAAQ,CAAC,UAAU;aACjC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"BankingHandlers.d.ts","sourceRoot":"","sources":["../../../src/adapters/banking/BankingHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAOjF,MAAM,WAAW,qBAAqB;IACpC,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,oFAAoF;IACpF,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,CAAC;CAC/D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,qBAA0B,GAAG,mBAAmB,CA4BxF"}
1
+ {"version":3,"file":"BankingHandlers.d.ts","sourceRoot":"","sources":["../../../src/adapters/banking/BankingHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAQjF,MAAM,WAAW,qBAAqB;IACpC,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,oFAAoF;IACpF,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,CAAC;CAC/D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,qBAA0B,GAAG,mBAAmB,CA8BxF"}
@@ -1,6 +1,7 @@
1
- import { adapterActionHandler } from "../AdapterActionHandler.js";
1
+ import { executorActionHandler } from "../AdapterActionHandler.js";
2
2
  import { BankingActionWireSchema } from "./BankingAction.js";
3
3
  import { BankingAdapter } from "./BankingAdapter.js";
4
+ import { BankingExecutor } from "./BankingExecutor.js";
4
5
  import { CoreBankingHttpAdapter } from "./CoreBankingHttpAdapter.js";
5
6
  import { REGISTERED_ACTIONS } from "./EffectProjections.js";
6
7
  /**
@@ -31,8 +32,10 @@ export function bankingHandlers(options = {}) {
31
32
  source: "CORE_BANKING_RESPONSE",
32
33
  }),
33
34
  });
34
- const handler = adapterActionHandler({
35
- adapter,
35
+ // The family runs as its native executor: the registry reaches it through
36
+ // the runner, and the adapter's arithmetic, projection and evidence are
37
+ // exactly what they were.
38
+ const handler = executorActionHandler(new BankingExecutor({ adapter }), {
36
39
  schema: BankingActionWireSchema,
37
40
  register,
38
41
  timeoutMs: context.downstream.timeoutMs,
@@ -1 +1 @@
1
- {"version":3,"file":"BankingHandlers.js","sourceRoot":"","sources":["../../../src/adapters/banking/BankingHandlers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,O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AAc,EAAE,OAAO,CAAC,UAAU,CAAC,SAAS;gBAC5C,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM,EAAE,uBAAuB;aAChC,CAAC;SACH,CAAC,CAAC;QACH,0EAA0E;QAC1E,wEAAwE;QACxE,0BAA0B;QAC1B,MAAM,OAAO,GAAG,qBAAqB,CAAgB,IAAI,eAAe,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE;YACrF,MAAM,EAAE,uBAAuB;YAC/B,QAAQ;YACR,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,SAAS;YACvC,GAAG,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;SAChF,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,kBAAkB,CAAC,GAAG,CAClC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAC5E,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACnE,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,66 @@
1
+ import type { ClaimedExecution, EffectObservation, EffectPreparedAction, ExecutionCapability, ExecutionEffect, NativeExecutor, PreparedAction, ReconcileResult } from "@decionis/agent-safe-pipeline";
2
+ import type { RegisteredEffect } from "../EffectEvidenceRegister.js";
3
+ import { type CardAuthorizationRequest, type CardAuthorizationResult, type CardPurchase } from "./CardPurchase.js";
4
+ export declare const CARD_ISSUER_PLATFORM = "card-issuer";
5
+ /**
6
+ * What the issuer reported about an authorization it was told to approve,
7
+ * with the attempt it belongs to: the purchase and the projection its grant
8
+ * was bound to, the issuer's request and result, and whether the claim's
9
+ * lease had closed by the time the result arrived.
10
+ */
11
+ export interface CardAuthorizationReceipt {
12
+ readonly purchase: CardPurchase;
13
+ readonly prepared: EffectPreparedAction;
14
+ readonly request: CardAuthorizationRequest;
15
+ readonly result: CardAuthorizationResult;
16
+ readonly leaseExpired: boolean;
17
+ readonly correlationId: string;
18
+ readonly idempotencyKey: string;
19
+ }
20
+ export interface CardAuthorizationExecutorOptions {
21
+ /** The observer the effect record and the authority name. */
22
+ readonly observer: {
23
+ readonly id: string;
24
+ readonly version: string;
25
+ };
26
+ readonly clock?: () => Date;
27
+ }
28
+ /**
29
+ * The cards family on `agent-safe.executors.native/1`, permit style: the
30
+ * issuer performs the effect, when its real-time authorization hook asks, so
31
+ * this executor never writes anything. The grant is held when the purchase
32
+ * is decided; the issuer's authorization request presents it, which claims
33
+ * it once; the permit is the approval the issuer is answered with; and the
34
+ * issuer's result is the receipt that settles it.
35
+ *
36
+ * - `observe` reads the result into the family's effect record: an approval
37
+ * within the ceiling is the authorised effect, a decline is a refusal, and
38
+ * a result after the claim's lease is indeterminate whatever it says.
39
+ * - `reconcile` has no one to ask: the issuer is the system of record and
40
+ * this boundary has no read path into it, so an authorization whose result
41
+ * never arrived stays unknown until someone who can see the issuer's ledger
42
+ * says.
43
+ */
44
+ export declare class CardAuthorizationExecutor implements NativeExecutor<CardPurchase, CardAuthorizationReceipt, RegisteredEffect> {
45
+ readonly platform = "card-issuer";
46
+ readonly style: "permit";
47
+ readonly actionTypes: readonly string[];
48
+ readonly version: string;
49
+ private readonly observer;
50
+ private readonly clock;
51
+ constructor(options: CardAuthorizationExecutorOptions);
52
+ capabilities(): Promise<readonly ExecutionCapability[]>;
53
+ /**
54
+ * The purchase as an intent: this card, at this merchant, for at most this
55
+ * amount, bound to the projection the issuer's result is later compared
56
+ * with. The retry identity is the purchase's own digest, so the same
57
+ * purchase proposed twice is one purchase.
58
+ */
59
+ prepare(purchase: CardPurchase): Promise<PreparedAction>;
60
+ /** The permit the issuer is answered with: this grant, for this intent, until it expires. */
61
+ execute(run: ClaimedExecution<CardPurchase>): Promise<ExecutionEffect<CardAuthorizationReceipt>>;
62
+ /** The issuer's result as the family's effect record; anything but a receipt is unknown. */
63
+ observe(effect: ExecutionEffect<CardAuthorizationReceipt>): Promise<EffectObservation<RegisteredEffect>>;
64
+ reconcile(): Promise<ReconcileResult<RegisteredEffect>>;
65
+ }
66
+ //# sourceMappingURL=CardAuthorizationExecutor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardAuthorizationExecutor.d.ts","sourceRoot":"","sources":["../../../src/adapters/cards/CardAuthorizationExecutor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EAEf,cAAc,EACd,cAAc,EACd,eAAe,EAChB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EAClB,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;IAC3C,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IACzC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,gCAAgC;IAC/C,6DAA6D;IAC7D,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACrE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,yBAA0B,YAAW,cAAc,CAC9D,YAAY,EACZ,wBAAwB,EACxB,gBAAgB,CACjB;IACC,SAAgB,QAAQ,iBAAwB;IAChD,SAAgB,KAAK,EAAG,QAAQ,CAAU;IAC1C,SAAgB,WAAW,EAAE,SAAS,MAAM,EAAE,CAA0B;IACxE,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoD;IAC7E,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;gBAEhB,OAAO,EAAE,gCAAgC;IAM/C,YAAY,IAAI,OAAO,CAAC,SAAS,mBAAmB,EAAE,CAAC;IAapE;;;;;OAKG;IACU,OAAO,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;IAiBrE,6FAA6F;IAChF,OAAO,CAClB,GAAG,EAAE,gBAAgB,CAAC,YAAY,CAAC,GAClC,OAAO,CAAC,eAAe,CAAC,wBAAwB,CAAC,CAAC;IAcrD,4FAA4F;IAC/E,OAAO,CAClB,MAAM,EAAE,eAAe,CAAC,wBAAwB,CAAC,GAChD,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAmClC,SAAS,IAAI,OAAO,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;CAGrE"}
@@ -0,0 +1,116 @@
1
+ import { authorityEffectEvidence } from "../EffectEvidenceBuilder.js";
2
+ import { cardResultRecord, prepareCardPurchase } from "./CardEffect.js";
3
+ import { CARD_PURCHASE_ACTION, cardTarget, } from "./CardPurchase.js";
4
+ export const CARD_ISSUER_PLATFORM = "card-issuer";
5
+ /**
6
+ * The cards family on `agent-safe.executors.native/1`, permit style: the
7
+ * issuer performs the effect, when its real-time authorization hook asks, so
8
+ * this executor never writes anything. The grant is held when the purchase
9
+ * is decided; the issuer's authorization request presents it, which claims
10
+ * it once; the permit is the approval the issuer is answered with; and the
11
+ * issuer's result is the receipt that settles it.
12
+ *
13
+ * - `observe` reads the result into the family's effect record: an approval
14
+ * within the ceiling is the authorised effect, a decline is a refusal, and
15
+ * a result after the claim's lease is indeterminate whatever it says.
16
+ * - `reconcile` has no one to ask: the issuer is the system of record and
17
+ * this boundary has no read path into it, so an authorization whose result
18
+ * never arrived stays unknown until someone who can see the issuer's ledger
19
+ * says.
20
+ */
21
+ export class CardAuthorizationExecutor {
22
+ platform = CARD_ISSUER_PLATFORM;
23
+ style = "permit";
24
+ actionTypes = [CARD_PURCHASE_ACTION];
25
+ version;
26
+ observer;
27
+ clock;
28
+ constructor(options) {
29
+ this.observer = options.observer;
30
+ this.version = options.observer.version;
31
+ this.clock = options.clock ?? (() => new Date());
32
+ }
33
+ async capabilities() {
34
+ return await Promise.resolve([
35
+ {
36
+ platform: this.platform,
37
+ actionType: CARD_PURCHASE_ACTION,
38
+ enabled: true,
39
+ scopeGranted: true,
40
+ connected: true,
41
+ requirement: "",
42
+ },
43
+ ]);
44
+ }
45
+ /**
46
+ * The purchase as an intent: this card, at this merchant, for at most this
47
+ * amount, bound to the projection the issuer's result is later compared
48
+ * with. The retry identity is the purchase's own digest, so the same
49
+ * purchase proposed twice is one purchase.
50
+ */
51
+ async prepare(purchase) {
52
+ const effect = prepareCardPurchase(purchase);
53
+ return await Promise.resolve({
54
+ actionType: CARD_PURCHASE_ACTION,
55
+ proposal: {
56
+ action: CARD_PURCHASE_ACTION,
57
+ target: cardTarget(purchase),
58
+ parameters: purchase,
59
+ },
60
+ downstreamTarget: { system: CARD_ISSUER_PLATFORM, operation: "authorize" },
61
+ idempotencyKey: `card-purchase:${effect.intentDigest}`,
62
+ expectedEffectDigest: effect.expectedEffectDigest,
63
+ requestDigest: effect.requestDigest,
64
+ facts: {},
65
+ });
66
+ }
67
+ /** The permit the issuer is answered with: this grant, for this intent, until it expires. */
68
+ async execute(run) {
69
+ return await Promise.resolve({
70
+ kind: "PERMIT",
71
+ permit: {
72
+ permitId: run.authorization.grantId,
73
+ intentHash: run.intent.intentHash,
74
+ expiresAt: run.authorization.expiresAt,
75
+ ...(run.authorization.claimAttestation === undefined
76
+ ? {}
77
+ : { claimAttestation: run.authorization.claimAttestation }),
78
+ },
79
+ });
80
+ }
81
+ /** The issuer's result as the family's effect record; anything but a receipt is unknown. */
82
+ async observe(effect) {
83
+ if (effect.kind !== "RECEIPT") {
84
+ return await Promise.resolve({ status: "INDETERMINATE", reason: null, result: null });
85
+ }
86
+ const receipt = effect.receipt;
87
+ const record = cardResultRecord({
88
+ purchase: receipt.purchase,
89
+ prepared: receipt.prepared,
90
+ authorization: receipt.request,
91
+ result: receipt.result,
92
+ leaseExpired: receipt.leaseExpired,
93
+ observer: this.observer,
94
+ correlationId: receipt.correlationId,
95
+ idempotencyKey: receipt.idempotencyKey,
96
+ observedAt: this.clock().toISOString(),
97
+ });
98
+ const evidence = authorityEffectEvidence(record, receipt.correlationId, this.observer);
99
+ if (record.outcome === "INDETERMINATE") {
100
+ return { status: "INDETERMINATE", reason: null, result: record, evidence };
101
+ }
102
+ if (record.outcome === "FAILED") {
103
+ return {
104
+ status: "FAILED",
105
+ reason: record.reasonCodes[0] ?? "ISSUER_DECLINED",
106
+ result: record,
107
+ evidence,
108
+ };
109
+ }
110
+ return { status: "COMMITTED", reason: null, result: record, evidence };
111
+ }
112
+ async reconcile() {
113
+ return await Promise.resolve({ status: "UNKNOWN" });
114
+ }
115
+ }
116
+ //# sourceMappingURL=CardAuthorizationExecutor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardAuthorizationExecutor.js","sourceRoot":"","sources":["../../../src/adapters/cards/CardAuthorizationExecutor.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6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AO;YAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,UAAU,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE;SACvC,CAAC,CAAC;QACH,MAAM,QAAQ,GAA4B,uBAAuB,CAC/D,MAAM,EACN,OAAO,CAAC,aAAa,EACrB,IAAI,CAAC,QAAQ,CACd,CAAC;QACF,IAAI,MAAM,CAAC,OAAO,KAAK,eAAe,EAAE,CAAC;YACvC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QAC7E,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,OAAO;gBACL,MAAM,EAAE,QAAQ;gBAChB,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,iBAAiB;gBAClD,MAAM,EAAE,MAAM;gBACd,QAAQ;aACT,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACzE,CAAC;IAEM,KAAK,CAAC,SAAS;QACpB,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IACtD,CAAC;CACF"}
@@ -1,4 +1,4 @@
1
- import { IntentCapture, type AuditRecorder, type AuthorizationVerifier, type DecisionAuthority, type ExecutionSignals, type IntentActor, type JsonObject } from "@decionis/agent-safe-pipeline";
1
+ import { IntentCapture, type AuditRecorder, type AuthorizationVerifier, type DecisionAuthority, type ExecutionSignals, type IntentActor, type JsonObject, type McpToolProfile } from "@decionis/agent-safe-pipeline";
2
2
  import { McpBindingError } from "./McpIntentBinder.js";
3
3
  import type { McpInvocation, McpToolBinding } from "./McpInvocation.js";
4
4
  /**
@@ -10,8 +10,25 @@ export interface McpTool<TResult = unknown> {
10
10
  readonly binding: McpToolBinding;
11
11
  invoke(args: JsonObject): Promise<TResult>;
12
12
  }
13
+ /**
14
+ * A tool an `agent-safe.profile.mcp/1` profile declares: only its name and
15
+ * what it does. Its action, target, subject, consequential arguments and the
16
+ * arguments it accepts are the profile's, read as data.
17
+ */
18
+ export interface McpProfiledTool<TResult = unknown> {
19
+ readonly tool: string;
20
+ invoke(args: JsonObject): Promise<TResult>;
21
+ }
22
+ /** What the host knows about the session a call belongs to, never what the model sent. */
23
+ export interface McpSession {
24
+ /** The subject the session is pinned to, verified by the host. */
25
+ readonly subject?: string;
26
+ }
13
27
  export interface McpGuardOptions {
14
- readonly tools: readonly McpTool[];
28
+ /** Tools bound in code (`McpTool`), or declared by `profile` (`McpProfiledTool`). */
29
+ readonly tools: readonly (McpTool | McpProfiledTool)[];
30
+ /** The tool profile the profiled tools are declared in. */
31
+ readonly profile?: McpToolProfile;
15
32
  readonly authority: DecisionAuthority;
16
33
  readonly verifier: AuthorizationVerifier;
17
34
  readonly tenantId: string;
@@ -83,9 +100,21 @@ export declare class McpGuard {
83
100
  private readonly executor;
84
101
  private readonly options;
85
102
  constructor(options: McpGuardOptions);
103
+ /**
104
+ * A tool as the guard holds it: a code binding as given, or a profiled
105
+ * tool's binding read from the profile. A profiled tool the profile does
106
+ * not declare is refused at construction, never governed by a guess.
107
+ */
108
+ private static resolve;
86
109
  /** Every tool this guard governs, for a server publishing its tool list. */
87
110
  governs(tool: string): boolean;
88
- guard<TResult = unknown>(invocation: McpInvocation): Promise<McpOutcome<TResult>>;
111
+ /**
112
+ * One invocation, through the lifecycle. `session` is the host's: the
113
+ * subject it verified for this conversation. A tool that names a subject
114
+ * argument is refused without one, or for another subject, before the
115
+ * authority is asked; any tool's intent states it as `session.subject`.
116
+ */
117
+ guard<TResult = unknown>(invocation: McpInvocation, session?: McpSession): Promise<McpOutcome<TResult>>;
89
118
  private outcomeOf;
90
119
  }
91
120
  //# sourceMappingURL=McpGuard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"McpGuard.d.ts","sourceRoot":"","sources":["../../../src/adapters/mcp/McpGuard.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAGb,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EAErB,KAAK,WAAW,EAChB,KAAK,UAAU,EAEhB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAiC,MAAM,sBAAsB,CAAC;AACtF,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAExE;;;;GAIG;AACH,MAAM,WAAW,OAAO,CAAC,OAAO,GAAG,OAAO;IACxC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IACjC,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,CAAC,EAA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