@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.
- package/README.md +62 -19
- package/dist/Cli.js +18 -1
- package/dist/Cli.js.map +1 -1
- package/dist/Index.d.ts +9 -4
- package/dist/Index.d.ts.map +1 -1
- package/dist/Index.js +7 -2
- package/dist/Index.js.map +1 -1
- package/dist/TrustedExecutor.d.ts.map +1 -1
- package/dist/TrustedExecutor.js +2 -0
- package/dist/TrustedExecutor.js.map +1 -1
- package/dist/adapters/AdapterActionHandler.d.ts +36 -12
- package/dist/adapters/AdapterActionHandler.d.ts.map +1 -1
- package/dist/adapters/AdapterActionHandler.js +99 -100
- package/dist/adapters/AdapterActionHandler.js.map +1 -1
- package/dist/adapters/EffectAdapter.d.ts +7 -103
- package/dist/adapters/EffectAdapter.d.ts.map +1 -1
- package/dist/adapters/EffectAdapter.js +7 -18
- package/dist/adapters/EffectAdapter.js.map +1 -1
- package/dist/adapters/EffectAdapterExecutor.d.ts +93 -0
- package/dist/adapters/EffectAdapterExecutor.d.ts.map +1 -0
- package/dist/adapters/EffectAdapterExecutor.js +191 -0
- package/dist/adapters/EffectAdapterExecutor.js.map +1 -0
- package/dist/adapters/banking/BankingExecutor.d.ts +35 -0
- package/dist/adapters/banking/BankingExecutor.d.ts.map +1 -0
- package/dist/adapters/banking/BankingExecutor.js +64 -0
- package/dist/adapters/banking/BankingExecutor.js.map +1 -0
- package/dist/adapters/banking/BankingHandlers.d.ts.map +1 -1
- package/dist/adapters/banking/BankingHandlers.js +6 -3
- package/dist/adapters/banking/BankingHandlers.js.map +1 -1
- package/dist/adapters/cards/CardAuthorizationExecutor.d.ts +66 -0
- package/dist/adapters/cards/CardAuthorizationExecutor.d.ts.map +1 -0
- package/dist/adapters/cards/CardAuthorizationExecutor.js +116 -0
- package/dist/adapters/cards/CardAuthorizationExecutor.js.map +1 -0
- package/dist/adapters/mcp/McpGuard.d.ts +32 -3
- package/dist/adapters/mcp/McpGuard.d.ts.map +1 -1
- package/dist/adapters/mcp/McpGuard.js +29 -5
- package/dist/adapters/mcp/McpGuard.js.map +1 -1
- package/dist/adapters/mcp/McpIntentBinder.d.ts +18 -3
- package/dist/adapters/mcp/McpIntentBinder.d.ts.map +1 -1
- package/dist/adapters/mcp/McpIntentBinder.js +48 -1
- package/dist/adapters/mcp/McpIntentBinder.js.map +1 -1
- package/dist/adapters/mcp/McpInvocation.d.ts +9 -2
- package/dist/adapters/mcp/McpInvocation.d.ts.map +1 -1
- package/dist/adapters/mcp/McpInvocation.js.map +1 -1
- package/dist/cli/Actions.d.ts +14 -0
- package/dist/cli/Actions.d.ts.map +1 -0
- package/dist/cli/Actions.js +168 -0
- package/dist/cli/Actions.js.map +1 -0
- package/dist/cli/Arguments.d.ts +4 -0
- package/dist/cli/Arguments.d.ts.map +1 -1
- package/dist/cli/Arguments.js +12 -3
- package/dist/cli/Arguments.js.map +1 -1
- package/dist/cli/ConfigCommand.d.ts.map +1 -1
- package/dist/cli/ConfigCommand.js +5 -0
- package/dist/cli/ConfigCommand.js.map +1 -1
- package/dist/cli/Doctor.d.ts.map +1 -1
- package/dist/cli/Doctor.js +2 -1
- package/dist/cli/Doctor.js.map +1 -1
- package/dist/cli/Help.d.ts.map +1 -1
- package/dist/cli/Help.js +13 -1
- package/dist/cli/Help.js.map +1 -1
- package/dist/cli/Host.d.ts +5 -2
- package/dist/cli/Host.d.ts.map +1 -1
- package/dist/cli/Host.js +24 -2
- package/dist/cli/Host.js.map +1 -1
- package/dist/cli/Profile.d.ts +24 -0
- package/dist/cli/Profile.d.ts.map +1 -0
- package/dist/cli/Profile.js +168 -0
- package/dist/cli/Profile.js.map +1 -0
- package/dist/cli/Records.d.ts +15 -0
- package/dist/cli/Records.d.ts.map +1 -0
- package/dist/cli/Records.js +205 -0
- package/dist/cli/Records.js.map +1 -0
- package/dist/config/ConfigKeys.d.ts +2 -2
- package/dist/config/ConfigKeys.d.ts.map +1 -1
- package/dist/config/ConfigKeys.js +6 -0
- package/dist/config/ConfigKeys.js.map +1 -1
- package/dist/config/ExecutorConfig.d.ts +29 -0
- package/dist/config/ExecutorConfig.d.ts.map +1 -1
- package/dist/config/ExecutorConfig.js +53 -1
- package/dist/config/ExecutorConfig.js.map +1 -1
- package/dist/gateway/ForwardHandler.d.ts +22 -4
- package/dist/gateway/ForwardHandler.d.ts.map +1 -1
- package/dist/gateway/ForwardHandler.js +27 -10
- package/dist/gateway/ForwardHandler.js.map +1 -1
- package/dist/gateway/Gateway.d.ts +123 -3
- package/dist/gateway/Gateway.d.ts.map +1 -1
- package/dist/gateway/Gateway.js +513 -16
- package/dist/gateway/Gateway.js.map +1 -1
- package/dist/gateway/GatewayConfig.d.ts +109 -0
- package/dist/gateway/GatewayConfig.d.ts.map +1 -1
- package/dist/gateway/GatewayConfig.js +267 -9
- package/dist/gateway/GatewayConfig.js.map +1 -1
- package/dist/gateway/GatewayReport.d.ts +6 -2
- package/dist/gateway/GatewayReport.d.ts.map +1 -1
- package/dist/gateway/GatewayReport.js +3 -0
- package/dist/gateway/GatewayReport.js.map +1 -1
- package/dist/gateway/InterceptedRequest.d.ts +45 -1
- package/dist/gateway/InterceptedRequest.d.ts.map +1 -1
- package/dist/gateway/InterceptedRequest.js +43 -1
- package/dist/gateway/InterceptedRequest.js.map +1 -1
- package/dist/gateway/PolicySelector.d.ts +5 -0
- package/dist/gateway/PolicySelector.d.ts.map +1 -0
- package/dist/gateway/PolicySelector.js +9 -0
- package/dist/gateway/PolicySelector.js.map +1 -0
- package/dist/gateway/RouteTable.d.ts +44 -7
- package/dist/gateway/RouteTable.d.ts.map +1 -1
- package/dist/gateway/RouteTable.js +58 -9
- package/dist/gateway/RouteTable.js.map +1 -1
- package/dist/gateway/SubjectSessions.d.ts +113 -0
- package/dist/gateway/SubjectSessions.d.ts.map +1 -0
- package/dist/gateway/SubjectSessions.js +219 -0
- package/dist/gateway/SubjectSessions.js.map +1 -0
- package/dist/gateway/Upstream.d.ts +11 -0
- package/dist/gateway/Upstream.d.ts.map +1 -1
- package/dist/gateway/Upstream.js +19 -2
- package/dist/gateway/Upstream.js.map +1 -1
- package/dist/hosted/TenantHost.d.ts +24 -5
- package/dist/hosted/TenantHost.d.ts.map +1 -1
- package/dist/hosted/TenantHost.js +39 -10
- package/dist/hosted/TenantHost.js.map +1 -1
- package/dist/hosted/TenantRegistry.d.ts +20 -0
- package/dist/hosted/TenantRegistry.d.ts.map +1 -1
- package/dist/hosted/TenantRegistry.js +47 -1
- package/dist/hosted/TenantRegistry.js.map +1 -1
- package/dist/http/GatewayHttpServer.d.ts.map +1 -1
- package/dist/http/GatewayHttpServer.js +46 -2
- package/dist/http/GatewayHttpServer.js.map +1 -1
- package/dist/identity/WorkloadJwtVerifier.d.ts +13 -0
- package/dist/identity/WorkloadJwtVerifier.d.ts.map +1 -1
- package/dist/identity/WorkloadJwtVerifier.js +40 -8
- package/dist/identity/WorkloadJwtVerifier.js.map +1 -1
- package/dist/incident/HaltSwitch.d.ts +10 -2
- package/dist/incident/HaltSwitch.d.ts.map +1 -1
- package/dist/incident/HaltSwitch.js +22 -2
- package/dist/incident/HaltSwitch.js.map +1 -1
- package/dist/incident/SecurityEvents.d.ts +18 -0
- package/dist/incident/SecurityEvents.d.ts.map +1 -1
- package/dist/incident/SecurityEvents.js +17 -0
- package/dist/incident/SecurityEvents.js.map +1 -1
- package/dist/journal/ExecutionJournal.d.ts +5 -120
- package/dist/journal/ExecutionJournal.d.ts.map +1 -1
- package/dist/journal/ExecutionJournal.js +5 -125
- package/dist/journal/ExecutionJournal.js.map +1 -1
- package/dist/journal/FileExecutionJournal.d.ts +1 -0
- package/dist/journal/FileExecutionJournal.d.ts.map +1 -1
- package/dist/journal/FileExecutionJournal.js +4 -1
- package/dist/journal/FileExecutionJournal.js.map +1 -1
- package/dist/journal/InMemoryExecutionJournal.d.ts +2 -1
- package/dist/journal/InMemoryExecutionJournal.d.ts.map +1 -1
- package/dist/journal/InMemoryExecutionJournal.js +4 -1
- package/dist/journal/InMemoryExecutionJournal.js.map +1 -1
- package/dist/limits/HardLimits.d.ts.map +1 -1
- package/dist/limits/HardLimits.js.map +1 -1
- package/dist/outcomes/CardOutcomeEvidence.d.ts +56 -0
- package/dist/outcomes/CardOutcomeEvidence.d.ts.map +1 -0
- package/dist/outcomes/CardOutcomeEvidence.js +211 -0
- package/dist/outcomes/CardOutcomeEvidence.js.map +1 -0
- package/dist/outcomes/CardOutcomeFact.d.ts +90 -0
- package/dist/outcomes/CardOutcomeFact.d.ts.map +1 -0
- package/dist/outcomes/CardOutcomeFact.js +76 -0
- package/dist/outcomes/CardOutcomeFact.js.map +1 -0
- package/dist/outcomes/CardOutcomeLedger.d.ts +26 -0
- package/dist/outcomes/CardOutcomeLedger.d.ts.map +1 -0
- package/dist/outcomes/CardOutcomeLedger.js +31 -0
- package/dist/outcomes/CardOutcomeLedger.js.map +1 -0
- package/dist/outcomes/CardOutcomeRecorder.d.ts +35 -0
- package/dist/outcomes/CardOutcomeRecorder.d.ts.map +1 -0
- package/dist/outcomes/CardOutcomeRecorder.js +84 -0
- package/dist/outcomes/CardOutcomeRecorder.js.map +1 -0
- package/dist/outcomes/CardOutcomes.d.ts +68 -0
- package/dist/outcomes/CardOutcomes.d.ts.map +1 -0
- package/dist/outcomes/CardOutcomes.js +191 -0
- package/dist/outcomes/CardOutcomes.js.map +1 -0
- package/dist/outcomes/CoreOutcomeEvidenceClient.d.ts +54 -0
- package/dist/outcomes/CoreOutcomeEvidenceClient.d.ts.map +1 -0
- package/dist/outcomes/CoreOutcomeEvidenceClient.js +116 -0
- package/dist/outcomes/CoreOutcomeEvidenceClient.js.map +1 -0
- package/dist/outcomes/FileCardOutcomeLedger.d.ts +36 -0
- package/dist/outcomes/FileCardOutcomeLedger.d.ts.map +1 -0
- package/dist/outcomes/FileCardOutcomeLedger.js +152 -0
- package/dist/outcomes/FileCardOutcomeLedger.js.map +1 -0
- package/dist/outcomes/OutcomeEvidence.d.ts +238 -0
- package/dist/outcomes/OutcomeEvidence.d.ts.map +1 -0
- package/dist/outcomes/OutcomeEvidence.js +130 -0
- package/dist/outcomes/OutcomeEvidence.js.map +1 -0
- package/dist/outcomes/OutcomeEvidencePublisher.d.ts +81 -0
- package/dist/outcomes/OutcomeEvidencePublisher.d.ts.map +1 -0
- package/dist/outcomes/OutcomeEvidencePublisher.js +189 -0
- package/dist/outcomes/OutcomeEvidencePublisher.js.map +1 -0
- package/dist/outcomes/OutcomeEvidenceStore.d.ts +57 -0
- package/dist/outcomes/OutcomeEvidenceStore.d.ts.map +1 -0
- package/dist/outcomes/OutcomeEvidenceStore.js +191 -0
- package/dist/outcomes/OutcomeEvidenceStore.js.map +1 -0
- package/dist/service/Requests.d.ts +6 -0
- package/dist/service/Requests.d.ts.map +1 -1
- package/dist/service/Requests.js +9 -1
- package/dist/service/Requests.js.map +1 -1
- package/dist/service/TrustedExecutorService.d.ts +21 -1
- package/dist/service/TrustedExecutorService.d.ts.map +1 -1
- package/dist/service/TrustedExecutorService.js +73 -23
- package/dist/service/TrustedExecutorService.js.map +1 -1
- package/dist/time/MonotonicClock.d.ts +4 -32
- package/dist/time/MonotonicClock.d.ts.map +1 -1
- package/dist/time/MonotonicClock.js +4 -49
- package/dist/time/MonotonicClock.js.map +1 -1
- package/dist/verify/VerifyingProvider.d.ts +32 -6
- package/dist/verify/VerifyingProvider.d.ts.map +1 -1
- package/dist/verify/VerifyingProvider.js +16 -2
- package/dist/verify/VerifyingProvider.js.map +1 -1
- package/package.json +6 -5
|
@@ -1,64 +1,70 @@
|
|
|
1
1
|
import { ProviderRefusal } from "@decionis/agent-safe-pipeline";
|
|
2
2
|
import { dispatchBudgetMs, MonotonicDeadline } from "../time/MonotonicClock.js";
|
|
3
3
|
import { IndeterminateOutcome } from "./EffectAdapter.js";
|
|
4
|
-
import {
|
|
4
|
+
import { EffectAdapterExecutor } from "./EffectAdapterExecutor.js";
|
|
5
5
|
/**
|
|
6
|
-
* The bridge from any `EffectAdapter` to the pipeline's `ActionHandler
|
|
7
|
-
*
|
|
6
|
+
* The bridge from any `EffectAdapter` to the pipeline's `ActionHandler`: the
|
|
7
|
+
* adapter as a dispatch-style `NativeExecutor` (`EffectAdapterExecutor`),
|
|
8
|
+
* bridged by `executorActionHandler`. Kept so every registration written
|
|
9
|
+
* against it keeps its signature.
|
|
10
|
+
*/
|
|
11
|
+
export function adapterActionHandler(options) {
|
|
12
|
+
const executor = new EffectAdapterExecutor({
|
|
13
|
+
adapter: options.adapter,
|
|
14
|
+
platform: options.adapter.id,
|
|
15
|
+
describe: describeByEffect,
|
|
16
|
+
...(options.clock === undefined ? {} : { clock: options.clock }),
|
|
17
|
+
});
|
|
18
|
+
return executorActionHandler(executor, {
|
|
19
|
+
schema: options.schema,
|
|
20
|
+
register: options.register,
|
|
21
|
+
timeoutMs: options.timeoutMs,
|
|
22
|
+
...(options.onMismatch === undefined ? {} : { onMismatch: options.onMismatch }),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The bridge from a dispatch-style executor over an effect adapter to the
|
|
27
|
+
* pipeline's `ActionHandler`, so the registry the runtime runs through
|
|
28
|
+
* `GovernedExecutionRunner` reaches it. It keeps the shape the boundary
|
|
29
|
+
* requires and adds the effect plane:
|
|
8
30
|
*
|
|
9
|
-
* prepare
|
|
31
|
+
* the executor's `prepare`, which reaches nothing; then its write inside
|
|
10
32
|
* `dispatch.run`, bounded by the smaller of the configured timeout and what
|
|
11
|
-
* is left of the grant; then
|
|
33
|
+
* is left of the grant; then its observation, compared field by field
|
|
12
34
|
* against what was authorised; then the record, registered against this
|
|
13
35
|
* exact authorization for the verifier to finalize with.
|
|
14
36
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* and
|
|
19
|
-
*
|
|
20
|
-
* what the effect plane says about it is separate, and that is deliberate.
|
|
37
|
+
* What the executor observed is said to the registry in the registry's own
|
|
38
|
+
* terms: an outcome nobody can determine is re-raised as
|
|
39
|
+
* `IndeterminateOutcome`, which the registry reports as unknown; a provider
|
|
40
|
+
* that was reached and said no is a `ProviderRefusal`, which it reports as
|
|
41
|
+
* definitely not executed; and a commit returns its effect block.
|
|
21
42
|
*/
|
|
22
|
-
export function
|
|
23
|
-
const clock = options.clock ?? (() => new Date());
|
|
24
|
-
const observer = { id: options.adapter.id, version: options.adapter.version };
|
|
43
|
+
export function executorActionHandler(executor, options) {
|
|
25
44
|
const execute = async (context) => {
|
|
26
|
-
const prepared =
|
|
45
|
+
const prepared = executor.prepareNow(context.parameters);
|
|
27
46
|
const deadline = MonotonicDeadline.after(dispatchBudgetMs(options.timeoutMs, context.authorization));
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let indeterminateReceipt = null;
|
|
31
|
-
try {
|
|
32
|
-
result = await context.dispatch.run(async () => await options.adapter.execute({
|
|
33
|
-
action: context.parameters,
|
|
34
|
-
prepared,
|
|
35
|
-
authorization: context.authorization,
|
|
36
|
-
idempotencyKey: context.dispatch.idempotencyKey,
|
|
37
|
-
deadline,
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
if (!(error instanceof IndeterminateOutcome))
|
|
42
|
-
throw error;
|
|
43
|
-
indeterminate = { reason: error.reason, providerStatus: error.providerStatus };
|
|
44
|
-
indeterminateReceipt = error.receipt;
|
|
45
|
-
}
|
|
46
|
-
// The provider's receipt rides on the attempt to the finalization, where
|
|
47
|
-
// the authority verifies it; this layer only compares what it states. An
|
|
48
|
-
// indeterminate answer can carry one too, and it is not dropped with it.
|
|
49
|
-
const receipt = result?.receipt ?? indeterminateReceipt;
|
|
50
|
-
if (typeof receipt === "string")
|
|
51
|
-
context.dispatch.receipt(receipt);
|
|
52
|
-
const observed = result === null ? null : options.adapter.observeEffect(result, prepared);
|
|
53
|
-
const record = buildEffectRecord({
|
|
47
|
+
const effect = await executor.execute({
|
|
48
|
+
action: context.parameters,
|
|
54
49
|
prepared,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
correlationId: context.intent.intent.intentId,
|
|
50
|
+
intent: context.intent,
|
|
51
|
+
scope: null,
|
|
52
|
+
authorization: context.authorization,
|
|
59
53
|
idempotencyKey: context.dispatch.idempotencyKey,
|
|
60
|
-
|
|
54
|
+
deadline,
|
|
55
|
+
dispatch: context.dispatch,
|
|
61
56
|
});
|
|
57
|
+
// The provider's receipt rides on the attempt to the finalization, where
|
|
58
|
+
// the authority verifies it; this layer only compares what it states. An
|
|
59
|
+
// indeterminate answer can carry one too, and it is not dropped with it.
|
|
60
|
+
const signedReceipt = effect.kind === "DISPATCHED" ? (effect.signedReceipt ?? null) : null;
|
|
61
|
+
if (typeof signedReceipt === "string")
|
|
62
|
+
context.dispatch.receipt(signedReceipt);
|
|
63
|
+
const observation = await executor.observe(effect);
|
|
64
|
+
const observed = observation.result;
|
|
65
|
+
if (observed === null)
|
|
66
|
+
throw new IndeterminateOutcome("EXECUTOR_OBSERVATION_MISSING");
|
|
67
|
+
const record = observed.record;
|
|
62
68
|
options.register.attach(context.authorization, record);
|
|
63
69
|
if (record.comparison === "MISMATCH" || record.receipt.comparison === "MISMATCH") {
|
|
64
70
|
options.onMismatch?.(record.mismatched);
|
|
@@ -66,77 +72,70 @@ export function adapterActionHandler(options) {
|
|
|
66
72
|
// An outcome nobody can determine stays undetermined: the throw is
|
|
67
73
|
// re-raised so the pipeline reports an unknown outcome rather than a
|
|
68
74
|
// failure or a success.
|
|
69
|
-
if (
|
|
70
|
-
throw new IndeterminateOutcome(indeterminate
|
|
75
|
+
if (observation.status === "INDETERMINATE") {
|
|
76
|
+
throw new IndeterminateOutcome(observed.indeterminate?.reason ?? "PROVIDER_OUTCOME_UNKNOWN", observed.indeterminate?.providerStatus ?? null, signedReceipt);
|
|
71
77
|
}
|
|
72
78
|
// A provider that was reached and said no is a fact, not a success. The
|
|
73
79
|
// evidence is registered above either way, so the authority still learns
|
|
74
80
|
// what was observed; the throw is what tells the pipeline that nothing
|
|
75
81
|
// was effected, so it reports `DEFINITELY_NOT_EXECUTED` rather than a
|
|
76
82
|
// completed execution whose own effect block says otherwise.
|
|
77
|
-
if (
|
|
78
|
-
throw new ProviderRefusal(
|
|
83
|
+
if (observation.status === "FAILED") {
|
|
84
|
+
throw new ProviderRefusal(observation.reason ?? "PROVIDER_REFUSED");
|
|
79
85
|
}
|
|
80
|
-
return
|
|
81
|
-
outcome: "COMMITTED",
|
|
82
|
-
confirmation: record.confirmation,
|
|
83
|
-
comparison: record.comparison,
|
|
84
|
-
mismatchedFields: record.mismatched,
|
|
85
|
-
observationMethod: record.observationMethod,
|
|
86
|
-
expectedEffectDigest: record.expectedEffectDigest,
|
|
87
|
-
observedEffectDigest: record.observedEffectDigest,
|
|
88
|
-
responseDigest: record.responseDigest,
|
|
89
|
-
providerReference: record.providerReference,
|
|
90
|
-
evidenceDigest: record.evidenceDigest,
|
|
91
|
-
reasonCodes: record.reasonCodes,
|
|
92
|
-
receiptComparison: record.receipt.comparison,
|
|
93
|
-
receiptStatus: record.receipt.status,
|
|
94
|
-
};
|
|
86
|
+
return executionResultOf(record);
|
|
95
87
|
};
|
|
96
88
|
const reconcile = async (context) => {
|
|
97
|
-
const
|
|
98
|
-
|
|
89
|
+
const answer = await executor.reconcile({
|
|
90
|
+
intent: context.intent,
|
|
91
|
+
prepared: executor.prepareNow(context.parameters),
|
|
99
92
|
idempotencyKey: context.idempotencyKey,
|
|
93
|
+
scope: null,
|
|
100
94
|
providerReference: null,
|
|
101
|
-
intentHash: context.intent.intentHash,
|
|
102
|
-
prepared,
|
|
103
95
|
});
|
|
104
96
|
if (answer.status !== "COMPLETED")
|
|
105
97
|
return { status: answer.status };
|
|
106
|
-
|
|
107
|
-
const record = buildEffectRecord({
|
|
108
|
-
prepared,
|
|
109
|
-
result: { ...answer.result, observed },
|
|
110
|
-
observer,
|
|
111
|
-
correlationId: context.intent.intent.intentId,
|
|
112
|
-
idempotencyKey: context.idempotencyKey,
|
|
113
|
-
observedAt: clock().toISOString(),
|
|
114
|
-
});
|
|
115
|
-
// Absence of an error is not success: only a read-back whose projection
|
|
116
|
-
// matches what was authorised is a completed reconciliation.
|
|
117
|
-
if (record.comparison !== "MATCH")
|
|
118
|
-
return { status: "UNKNOWN" };
|
|
119
|
-
return {
|
|
120
|
-
status: "COMPLETED",
|
|
121
|
-
result: {
|
|
122
|
-
outcome: "COMMITTED",
|
|
123
|
-
confirmation: record.confirmation,
|
|
124
|
-
comparison: record.comparison,
|
|
125
|
-
mismatchedFields: record.mismatched,
|
|
126
|
-
observationMethod: record.observationMethod,
|
|
127
|
-
expectedEffectDigest: record.expectedEffectDigest,
|
|
128
|
-
observedEffectDigest: record.observedEffectDigest,
|
|
129
|
-
responseDigest: record.responseDigest,
|
|
130
|
-
providerReference: record.providerReference,
|
|
131
|
-
evidenceDigest: record.evidenceDigest,
|
|
132
|
-
reasonCodes: record.reasonCodes,
|
|
133
|
-
receiptComparison: record.receipt.comparison,
|
|
134
|
-
receiptStatus: record.receipt.status,
|
|
135
|
-
},
|
|
136
|
-
};
|
|
98
|
+
return { status: "COMPLETED", result: executionResultOf(answer.result.record) };
|
|
137
99
|
};
|
|
138
100
|
return { parametersSchema: options.schema, execute, reconcile };
|
|
139
101
|
}
|
|
102
|
+
/** What the executor reports about a committed attempt, from its effect record. */
|
|
103
|
+
function executionResultOf(record) {
|
|
104
|
+
return {
|
|
105
|
+
outcome: "COMMITTED",
|
|
106
|
+
confirmation: record.confirmation,
|
|
107
|
+
comparison: record.comparison,
|
|
108
|
+
mismatchedFields: record.mismatched,
|
|
109
|
+
observationMethod: record.observationMethod,
|
|
110
|
+
expectedEffectDigest: record.expectedEffectDigest,
|
|
111
|
+
observedEffectDigest: record.observedEffectDigest,
|
|
112
|
+
responseDigest: record.responseDigest,
|
|
113
|
+
providerReference: record.providerReference,
|
|
114
|
+
evidenceDigest: record.evidenceDigest,
|
|
115
|
+
reasonCodes: record.reasonCodes,
|
|
116
|
+
receiptComparison: record.receipt.comparison,
|
|
117
|
+
receiptStatus: record.receipt.status,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* How an adapter with no description of its own reads as an intent: its
|
|
122
|
+
* effect's action type and resource, the action itself as the parameters,
|
|
123
|
+
* and the canonical action's digest as the retry identity. The registry path
|
|
124
|
+
* never asks, because the intent was captured before the handler ran; a
|
|
125
|
+
* family that is submitted to the runner directly describes itself.
|
|
126
|
+
*/
|
|
127
|
+
export function describeByEffect(action, prepared) {
|
|
128
|
+
return {
|
|
129
|
+
proposal: {
|
|
130
|
+
action: prepared.actionType.toLowerCase(),
|
|
131
|
+
target: prepared.resourceRef,
|
|
132
|
+
parameters: action,
|
|
133
|
+
},
|
|
134
|
+
downstreamTarget: { system: prepared.domain.toLowerCase(), operation: prepared.effectType },
|
|
135
|
+
idempotencyKey: prepared.intentDigest,
|
|
136
|
+
facts: {},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
140
139
|
/** The effect block a response carries, from the handler's own result. */
|
|
141
140
|
export function effectBlock(result) {
|
|
142
141
|
if (typeof result !== "object" || result === null)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdapterActionHandler.js","sourceRoot":"","sources":["../../src/adapters/AdapterActionHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"AdapterActionHandler.js","sourceRoot":"","sources":["../../src/adapters/AdapterActionHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAUhE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAsB,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAA0B,MAAM,4BAA4B,CAAC;AAwC3F;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC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AI;QAC9D,sBAAsB,EAAE,SAAS,CAAC,oBAAoB,IAAI,IAAI;QAC9D,eAAe,EAAE,SAAS,CAAC,cAAc,IAAI,IAAI;QACjD,kBAAkB,EAAE,SAAS,CAAC,iBAAiB,IAAI,IAAI;QACvD,eAAe,EAAE,SAAS,CAAC,cAAc;QACzC,YAAY,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;QAChD,kBAAkB,EAAE,SAAS,CAAC,iBAAiB,IAAI,IAAI;QACvD,cAAc,EAAE,SAAS,CAAC,aAAa,IAAI,IAAI;KAChD,CAAC;AACJ,CAAC"}
|
|
@@ -1,107 +1,11 @@
|
|
|
1
|
-
import type { JsonObject, JsonValue, VerifiedAuthorization } from "@decionis/agent-safe-pipeline";
|
|
2
|
-
import type { MonotonicDeadline } from "../time/MonotonicClock.js";
|
|
3
|
-
import type { Sha256 } from "./JcsDigest.js";
|
|
4
|
-
/** What the adapter worked out before anything left the process. */
|
|
5
|
-
export interface PreparedAction {
|
|
6
|
-
/** The effect the action asks for, as the profile's projection of it. */
|
|
7
|
-
readonly expectedEffect: JsonObject;
|
|
8
|
-
readonly expectedEffectDigest: Sha256;
|
|
9
|
-
/** The digest of the canonical action itself, for the authority's binding. */
|
|
10
|
-
readonly intentDigest: Sha256;
|
|
11
|
-
/** The digest of what will be sent, so a later reader can tell what was asked. */
|
|
12
|
-
readonly requestDigest: Sha256;
|
|
13
|
-
/** The resource the effect lands on, as the profile names it. */
|
|
14
|
-
readonly resourceRef: string;
|
|
15
|
-
readonly effectType: string;
|
|
16
|
-
readonly domain: string;
|
|
17
|
-
readonly actionType: string;
|
|
18
|
-
}
|
|
19
|
-
/** What the provider said, as the adapter read it. Never a body, never a credential. */
|
|
20
|
-
export interface ProviderResult {
|
|
21
|
-
readonly status: "COMMITTED" | "FAILED";
|
|
22
|
-
readonly providerStatus: string | null;
|
|
23
|
-
readonly providerReference: string | null;
|
|
24
|
-
readonly responseDigest: Sha256 | null;
|
|
25
|
-
/** A profile reason code when the provider refused; null when it accepted. */
|
|
26
|
-
readonly failureReason: string | null;
|
|
27
|
-
/** The observed effect as the adapter could read it, or null when it could not. */
|
|
28
|
-
readonly observed: JsonObject | null;
|
|
29
|
-
readonly observationMethod: ObservationMethod;
|
|
30
|
-
readonly providerGenerated: boolean;
|
|
31
|
-
readonly source: string;
|
|
32
|
-
/**
|
|
33
|
-
* The provider's effect receipt (VP-3), verbatim, when its answer carried
|
|
34
|
-
* one in `x-agent-safe-effect-receipt`. Forwarded to the authority
|
|
35
|
-
* unread; its statement is compared with this executor's own account.
|
|
36
|
-
*/
|
|
37
|
-
readonly receipt?: string | null;
|
|
38
|
-
}
|
|
39
|
-
export type ObservationMethod = "DOWNSTREAM_ACK" | "READ_AFTER_WRITE" | "EVENT_CONFIRMATION" | "STATE_RECONCILIATION" | "SIGNED_RECEIPT" | "EXTERNAL_ATTESTATION" | "HUMAN_VALIDATION";
|
|
40
1
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
2
|
+
* The effect-adapter contract moved into `@decionis/agent-safe-pipeline`,
|
|
3
|
+
* where it is the dispatch style of `agent-safe.executors.native/1` under its
|
|
4
|
+
* earlier name (`EffectAdapterExecutor` runs one as a `NativeExecutor`).
|
|
5
|
+
* Re-exported here, unchanged, so every adapter and import written against
|
|
6
|
+
* this module keeps working.
|
|
44
7
|
*
|
|
45
|
-
*
|
|
46
|
-
* the effect all the same. `receipt` carries it to the finalization, where
|
|
47
|
-
* the authority verifies it, instead of it being dropped with the answer.
|
|
8
|
+
* @deprecated Implement the pipeline's `NativeExecutor` with `style: "dispatch"`.
|
|
48
9
|
*/
|
|
49
|
-
export
|
|
50
|
-
readonly reason: string;
|
|
51
|
-
readonly providerStatus: string | null;
|
|
52
|
-
readonly receipt: string | null;
|
|
53
|
-
constructor(reason: string, providerStatus?: string | null, receipt?: string | null);
|
|
54
|
-
}
|
|
55
|
-
export interface AdapterExecution<TAction> {
|
|
56
|
-
readonly action: TAction;
|
|
57
|
-
readonly prepared: PreparedAction;
|
|
58
|
-
readonly authorization: VerifiedAuthorization;
|
|
59
|
-
readonly idempotencyKey: string;
|
|
60
|
-
/** The budget left for this dispatch: the smaller of the timeout and the grant. */
|
|
61
|
-
readonly deadline: MonotonicDeadline;
|
|
62
|
-
}
|
|
63
|
-
export interface AdapterReconciliation {
|
|
64
|
-
readonly idempotencyKey: string;
|
|
65
|
-
readonly providerReference: string | null;
|
|
66
|
-
readonly intentHash: string;
|
|
67
|
-
readonly prepared: PreparedAction;
|
|
68
|
-
}
|
|
69
|
-
export type ProviderReconciliationResult = {
|
|
70
|
-
readonly status: "COMPLETED";
|
|
71
|
-
readonly result: ProviderResult;
|
|
72
|
-
} | {
|
|
73
|
-
readonly status: "NOT_EXECUTED";
|
|
74
|
-
} | {
|
|
75
|
-
readonly status: "UNKNOWN";
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* One contract for every family of consequential actions. It is deliberately
|
|
79
|
-
* four small methods, three of them pure:
|
|
80
|
-
*
|
|
81
|
-
* - `prepare` works out what the action asks for and what its effect should
|
|
82
|
-
* be. It reaches nothing and may be called before the authority is asked.
|
|
83
|
-
* - `execute` performs the side effect, once, inside the dispatch the
|
|
84
|
-
* pipeline opened. A provider that neither committed nor refused is an
|
|
85
|
-
* `IndeterminateOutcome`, never a guess.
|
|
86
|
-
* - `observeEffect` reads what the provider said into the profile's
|
|
87
|
-
* projection. Pure: no second call, no interpretation of silence.
|
|
88
|
-
* - `reconcile` asks the provider what it did with an idempotency key,
|
|
89
|
-
* read-only, and may never initiate anything.
|
|
90
|
-
*
|
|
91
|
-
* A second family is a directory beside `banking/`, not a rewrite: the
|
|
92
|
-
* handler bridge, the comparison, the evidence and the verifier all work off
|
|
93
|
-
* this contract alone.
|
|
94
|
-
*/
|
|
95
|
-
export interface EffectAdapter<TAction> {
|
|
96
|
-
readonly id: string;
|
|
97
|
-
readonly version: string;
|
|
98
|
-
/** The transport action names this adapter answers for. */
|
|
99
|
-
readonly actionTypes: readonly string[];
|
|
100
|
-
prepare(action: TAction): PreparedAction;
|
|
101
|
-
execute(execution: AdapterExecution<TAction>): Promise<ProviderResult>;
|
|
102
|
-
observeEffect(result: ProviderResult, prepared: PreparedAction): JsonObject | null;
|
|
103
|
-
reconcile(context: AdapterReconciliation): Promise<ProviderReconciliationResult>;
|
|
104
|
-
}
|
|
105
|
-
/** A value the projection can hold, narrowed for comparison. */
|
|
106
|
-
export type ProjectionValue = JsonValue;
|
|
10
|
+
export { IndeterminateOutcome, type AdapterExecution, type AdapterReconciliation, type EffectAdapter, type EffectPreparedAction as PreparedAction, type ObservationMethod, type ProjectionValue, type ProviderReconciliationResult, type ProviderResult, } from "@decionis/agent-safe-pipeline";
|
|
107
11
|
//# sourceMappingURL=EffectAdapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EffectAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/EffectAdapter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"EffectAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/EffectAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,oBAAoB,IAAI,cAAc,EAC3C,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,4BAA4B,EACjC,KAAK,cAAc,GACpB,MAAM,+BAA+B,CAAC"}
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The effect-adapter contract moved into `@decionis/agent-safe-pipeline`,
|
|
3
|
+
* where it is the dispatch style of `agent-safe.executors.native/1` under its
|
|
4
|
+
* earlier name (`EffectAdapterExecutor` runs one as a `NativeExecutor`).
|
|
5
|
+
* Re-exported here, unchanged, so every adapter and import written against
|
|
6
|
+
* this module keeps working.
|
|
5
7
|
*
|
|
6
|
-
*
|
|
7
|
-
* the effect all the same. `receipt` carries it to the finalization, where
|
|
8
|
-
* the authority verifies it, instead of it being dropped with the answer.
|
|
8
|
+
* @deprecated Implement the pipeline's `NativeExecutor` with `style: "dispatch"`.
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
11
|
-
reason;
|
|
12
|
-
providerStatus;
|
|
13
|
-
receipt;
|
|
14
|
-
constructor(reason, providerStatus = null, receipt = null) {
|
|
15
|
-
super(reason);
|
|
16
|
-
this.reason = reason;
|
|
17
|
-
this.providerStatus = providerStatus;
|
|
18
|
-
this.receipt = receipt;
|
|
19
|
-
this.name = "IndeterminateOutcome";
|
|
20
|
-
}
|
|
21
|
-
}
|
|
10
|
+
export { IndeterminateOutcome, } from "@decionis/agent-safe-pipeline";
|
|
22
11
|
//# sourceMappingURL=EffectAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EffectAdapter.js","sourceRoot":"","sources":["../../src/adapters/EffectAdapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EffectAdapter.js","sourceRoot":"","sources":["../../src/adapters/EffectAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,oBAAoB,GASrB,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { AgentProposal, ClaimedExecution, DownstreamTarget, EffectAdapter, EffectObservation, EffectPreparedAction, ExecutionCapability, ExecutionEffect, ExecutorScope, JsonObject, NativeExecutor, PlatformId, PreparedAction, ProviderResult, ReconcileContext, ReconcileResult } from "@decionis/agent-safe-pipeline";
|
|
2
|
+
import type { RegisteredEffect } from "./EffectEvidenceRegister.js";
|
|
3
|
+
/** How an adapter's action is described to the authority: what `prepare` binds beyond the effect. */
|
|
4
|
+
export interface ActionDescription {
|
|
5
|
+
readonly proposal: AgentProposal;
|
|
6
|
+
readonly downstreamTarget: DownstreamTarget;
|
|
7
|
+
readonly idempotencyKey: string;
|
|
8
|
+
readonly facts: JsonObject;
|
|
9
|
+
}
|
|
10
|
+
export interface EffectAdapterExecutorOptions<TAction> {
|
|
11
|
+
readonly adapter: EffectAdapter<TAction>;
|
|
12
|
+
readonly platform: PlatformId;
|
|
13
|
+
/** How the action reads as an intent; the adapter itself only knows its effect. */
|
|
14
|
+
readonly describe: (action: TAction, prepared: EffectPreparedAction) => ActionDescription;
|
|
15
|
+
/** What the connection can execute; absent, every action type is stated as live. */
|
|
16
|
+
readonly capabilities?: (scope: ExecutorScope) => Promise<readonly ExecutionCapability[]>;
|
|
17
|
+
readonly clock?: () => Date;
|
|
18
|
+
}
|
|
19
|
+
/** What the adapter's dispatch left for `observe`: everything the effect record is built from. */
|
|
20
|
+
export interface AdapterDispatchReceipt {
|
|
21
|
+
readonly prepared: EffectPreparedAction;
|
|
22
|
+
readonly result: ProviderResult | null;
|
|
23
|
+
readonly indeterminate: {
|
|
24
|
+
readonly reason: string;
|
|
25
|
+
readonly providerStatus: string | null;
|
|
26
|
+
} | null;
|
|
27
|
+
readonly correlationId: string;
|
|
28
|
+
readonly idempotencyKey: string;
|
|
29
|
+
}
|
|
30
|
+
/** What `observe` reads a dispatch as: the effect record, and the attempt it was observed for. */
|
|
31
|
+
export interface AdapterObservation {
|
|
32
|
+
readonly record: RegisteredEffect;
|
|
33
|
+
readonly indeterminate: AdapterDispatchReceipt["indeterminate"];
|
|
34
|
+
readonly correlationId: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Any `EffectAdapter` as a dispatch-style `NativeExecutor`
|
|
38
|
+
* (`agent-safe.executors.native/1`): the adapter keeps its four methods and
|
|
39
|
+
* this class says them in the contract's terms. `prepare` is the adapter's,
|
|
40
|
+
* plus how the action reads as an intent; `execute` is the adapter's write,
|
|
41
|
+
* inside the dispatch the caller opened and within its deadline; `observe`
|
|
42
|
+
* is the adapter's projection turned into the effect record, field by field
|
|
43
|
+
* against what was authorised; `reconcile` is the adapter's read-only
|
|
44
|
+
* lookup, complete only on a matching read-back.
|
|
45
|
+
*
|
|
46
|
+
* The record is evidence, so it rides on the observation for whoever
|
|
47
|
+
* finalizes the grant — the runtime registers it for its verifier — and its
|
|
48
|
+
* wire form rides as `evidence` for a runner that finalizes directly.
|
|
49
|
+
*/
|
|
50
|
+
export declare class EffectAdapterExecutor<TAction> implements NativeExecutor<TAction, AdapterDispatchReceipt, AdapterObservation> {
|
|
51
|
+
private readonly options;
|
|
52
|
+
readonly platform: PlatformId;
|
|
53
|
+
readonly version: string;
|
|
54
|
+
readonly style: "dispatch";
|
|
55
|
+
private readonly clock;
|
|
56
|
+
/** The adapter's own preparation of each prepared action, so a write never prepares twice. */
|
|
57
|
+
private readonly effects;
|
|
58
|
+
constructor(options: EffectAdapterExecutorOptions<TAction>);
|
|
59
|
+
get actionTypes(): readonly string[];
|
|
60
|
+
/** The adapter's observer identity, as the effect record and the authority name it. */
|
|
61
|
+
get observer(): {
|
|
62
|
+
readonly id: string;
|
|
63
|
+
readonly version: string;
|
|
64
|
+
};
|
|
65
|
+
capabilities(scope: ExecutorScope): Promise<readonly ExecutionCapability[]>;
|
|
66
|
+
prepare(action: TAction): Promise<PreparedAction>;
|
|
67
|
+
/** `prepare`, synchronously: the adapter reaches nothing, so neither does this. */
|
|
68
|
+
prepareNow(action: TAction): PreparedAction;
|
|
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
|
+
execute(run: ClaimedExecution<TAction>): Promise<ExecutionEffect<AdapterDispatchReceipt>>;
|
|
76
|
+
/**
|
|
77
|
+
* The provider's answer as the effect record: the adapter's projection,
|
|
78
|
+
* compared with what was authorised. An outcome nobody can determine stays
|
|
79
|
+
* undetermined; a provider that was reached and said no is a refusal, not
|
|
80
|
+
* a success whose effect block says otherwise.
|
|
81
|
+
*/
|
|
82
|
+
observe(effect: ExecutionEffect<AdapterDispatchReceipt>): Promise<EffectObservation<AdapterObservation>>;
|
|
83
|
+
/**
|
|
84
|
+
* The adapter's read-only lookup. Absence of an error is not success: only
|
|
85
|
+
* a read-back whose projection matches what was authorised completes a
|
|
86
|
+
* reconciliation.
|
|
87
|
+
*/
|
|
88
|
+
reconcile(context: ReconcileContext): Promise<ReconcileResult<AdapterObservation>>;
|
|
89
|
+
/** The adapter's preparation of a prepared action: remembered from `prepare`, or made again. */
|
|
90
|
+
private effectOf;
|
|
91
|
+
private evidenceOf;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=EffectAdapterExecutor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EffectAdapterExecutor.d.ts","sourceRoot":"","sources":["../../src/adapters/EffectAdapterExecutor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EAEb,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,UAAU,EACV,cAAc,EACd,UAAU,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,eAAe,EAChB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,qGAAqG;AACrG,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC5B;AAED,MAAM,WAAW,4BAA4B,CAAC,OAAO;IACnD,QAAQ,CAAC,OAA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