@decionis/agent-safe-pipeline 0.1.3 → 0.2.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 +477 -16
- package/dist/Index.d.ts +9 -0
- package/dist/Index.d.ts.map +1 -1
- package/dist/Index.js +8 -0
- package/dist/Index.js.map +1 -1
- package/dist/approval/PresenceApprovalCoordinator.d.ts +25 -0
- package/dist/approval/PresenceApprovalCoordinator.d.ts.map +1 -1
- package/dist/approval/PresenceApprovalCoordinator.js +54 -6
- package/dist/approval/PresenceApprovalCoordinator.js.map +1 -1
- package/dist/audit/AuditRecorder.d.ts +122 -0
- package/dist/audit/AuditRecorder.d.ts.map +1 -0
- package/dist/audit/AuditRecorder.js +312 -0
- package/dist/audit/AuditRecorder.js.map +1 -0
- package/dist/decision/CreateGate.d.ts +123 -0
- package/dist/decision/CreateGate.d.ts.map +1 -0
- package/dist/decision/CreateGate.js +211 -0
- package/dist/decision/CreateGate.js.map +1 -0
- package/dist/decision/DecionisGate.d.ts +109 -3
- package/dist/decision/DecionisGate.d.ts.map +1 -1
- package/dist/decision/DecionisGate.js +823 -46
- package/dist/decision/DecionisGate.js.map +1 -1
- package/dist/decision/DecisionAuthority.d.ts +76 -1
- package/dist/decision/DecisionAuthority.d.ts.map +1 -1
- package/dist/decision/DecisionAuthority.js.map +1 -1
- package/dist/decision/FixtureDecisionAuthority.d.ts +27 -1
- package/dist/decision/FixtureDecisionAuthority.d.ts.map +1 -1
- package/dist/decision/FixtureDecisionAuthority.js +47 -0
- package/dist/decision/FixtureDecisionAuthority.js.map +1 -1
- package/dist/decision/ImmutableGateDecision.d.ts.map +1 -1
- package/dist/decision/ImmutableGateDecision.js +26 -0
- package/dist/decision/ImmutableGateDecision.js.map +1 -1
- package/dist/decision/Provision.d.ts +33 -0
- package/dist/decision/Provision.d.ts.map +1 -0
- package/dist/decision/Provision.js +116 -0
- package/dist/decision/Provision.js.map +1 -0
- package/dist/decision/ShadowGate.d.ts +31 -0
- package/dist/decision/ShadowGate.d.ts.map +1 -0
- package/dist/decision/ShadowGate.js +79 -0
- package/dist/decision/ShadowGate.js.map +1 -0
- package/dist/execution/ActionRegistry.d.ts +66 -0
- package/dist/execution/ActionRegistry.d.ts.map +1 -1
- package/dist/execution/ActionRegistry.js +110 -1
- package/dist/execution/ActionRegistry.js.map +1 -1
- package/dist/execution/AuthorizationVerifier.d.ts +149 -1
- package/dist/execution/AuthorizationVerifier.d.ts.map +1 -1
- package/dist/execution/AuthorizationVerifier.js +302 -27
- package/dist/execution/AuthorizationVerifier.js.map +1 -1
- package/dist/execution/SafeExecutor.d.ts +102 -7
- package/dist/execution/SafeExecutor.d.ts.map +1 -1
- package/dist/execution/SafeExecutor.js +288 -17
- package/dist/execution/SafeExecutor.js.map +1 -1
- package/dist/http/ClientIdentification.d.ts +22 -0
- package/dist/http/ClientIdentification.d.ts.map +1 -0
- package/dist/http/ClientIdentification.js +44 -0
- package/dist/http/ClientIdentification.js.map +1 -0
- package/dist/http/Credential.d.ts +17 -0
- package/dist/http/Credential.d.ts.map +1 -0
- package/dist/http/Credential.js +5 -0
- package/dist/http/Credential.js.map +1 -0
- package/dist/http/StoredCredentials.d.ts +34 -0
- package/dist/http/StoredCredentials.d.ts.map +1 -0
- package/dist/http/StoredCredentials.js +85 -0
- package/dist/http/StoredCredentials.js.map +1 -0
- package/dist/intent/CanonicalIntentHasher.d.ts +1 -1
- package/dist/intent/CanonicalIntentHasher.d.ts.map +1 -1
- package/dist/intent/CanonicalIntentHasher.js +9 -2
- package/dist/intent/CanonicalIntentHasher.js.map +1 -1
- package/dist/intent/ExecutionIntent.d.ts +26 -2
- package/dist/intent/ExecutionIntent.d.ts.map +1 -1
- package/dist/intent/ExecutionIntent.js +11 -0
- package/dist/intent/ExecutionIntent.js.map +1 -1
- package/dist/intent/IntentCapture.d.ts +5 -0
- package/dist/intent/IntentCapture.d.ts.map +1 -1
- package/dist/intent/IntentCapture.js +15 -1
- package/dist/intent/IntentCapture.js.map +1 -1
- package/dist/report/DecisionReport.d.ts +22 -0
- package/dist/report/DecisionReport.d.ts.map +1 -0
- package/dist/report/DecisionReport.js +37 -0
- package/dist/report/DecisionReport.js.map +1 -0
- package/dist/report/DossierReport.d.ts +43 -0
- package/dist/report/DossierReport.d.ts.map +1 -0
- package/dist/report/DossierReport.js +130 -0
- package/dist/report/DossierReport.js.map +1 -0
- package/dist/report/HostedOutcome.d.ts +18 -0
- package/dist/report/HostedOutcome.d.ts.map +1 -0
- package/dist/report/HostedOutcome.js +24 -0
- package/dist/report/HostedOutcome.js.map +1 -0
- package/dist/shadow/ShadowPipeline.d.ts +75 -5
- package/dist/shadow/ShadowPipeline.d.ts.map +1 -1
- package/dist/shadow/ShadowPipeline.js +157 -7
- package/dist/shadow/ShadowPipeline.js.map +1 -1
- package/dist/testing/Index.d.ts +12 -0
- package/dist/testing/Index.d.ts.map +1 -0
- package/dist/testing/Index.js +12 -0
- package/dist/testing/Index.js.map +1 -0
- package/dist/testing/LocalAuthority.d.ts +292 -0
- package/dist/testing/LocalAuthority.d.ts.map +1 -0
- package/dist/testing/LocalAuthority.js +1124 -0
- package/dist/testing/LocalAuthority.js.map +1 -0
- package/dist/testing/LocalPresence.d.ts +210 -0
- package/dist/testing/LocalPresence.d.ts.map +1 -0
- package/dist/testing/LocalPresence.js +473 -0
- package/dist/testing/LocalPresence.js.map +1 -0
- package/package.json +40 -4
|
@@ -2,23 +2,44 @@ import { CanonicalIntentHasher } from "../intent/CanonicalIntentHasher.js";
|
|
|
2
2
|
export class SafeExecutor {
|
|
3
3
|
registry;
|
|
4
4
|
verifier;
|
|
5
|
+
audit;
|
|
5
6
|
hasher = new CanonicalIntentHasher();
|
|
6
|
-
constructor(registry, verifier) {
|
|
7
|
+
constructor(registry, verifier, audit) {
|
|
7
8
|
this.registry = registry;
|
|
8
9
|
this.verifier = verifier;
|
|
10
|
+
this.audit = audit;
|
|
9
11
|
}
|
|
10
12
|
async run(captured, decision) {
|
|
13
|
+
const startedAt = Date.now();
|
|
14
|
+
// Stryker disable next-line all: Audit payload mapping is covered by lifecycle event assertions.
|
|
15
|
+
const intentRecorded = await this.record({ eventType: "INTENT_CAPTURED", captured });
|
|
16
|
+
// An observational artifact (shadow observation, serialized audit event) is
|
|
17
|
+
// rejected before it is recorded or inspected as if it were a decision.
|
|
18
|
+
if (!SafeExecutor.isAuthoritativeDecision(decision)) {
|
|
19
|
+
return await this.block(captured, undefined, "DECISION_NOT_AUTHORITATIVE", startedAt);
|
|
20
|
+
}
|
|
21
|
+
// Stryker disable all: Audit payload mapping is covered by lifecycle event assertions.
|
|
22
|
+
const decisionRecorded = await this.record({
|
|
23
|
+
eventType: decision.failClosed ? "AUTHORITY_FAILED_CLOSED" : "AUTHORITY_DECISION",
|
|
24
|
+
captured,
|
|
25
|
+
decision,
|
|
26
|
+
});
|
|
27
|
+
// Stryker restore all
|
|
28
|
+
if (this.audit?.requiresDeliveryBeforeExecution === true &&
|
|
29
|
+
(!intentRecorded || !decisionRecorded)) {
|
|
30
|
+
return await this.block(captured, decision, "AUDIT_UNAVAILABLE", startedAt);
|
|
31
|
+
}
|
|
11
32
|
if (decision.verdict !== "ALLOW" || decision.failClosed) {
|
|
12
|
-
return
|
|
33
|
+
return await this.block(captured, decision, "DECISION_NOT_ALLOW", startedAt);
|
|
13
34
|
}
|
|
14
35
|
if (decision.intentHash !== captured.intentHash) {
|
|
15
|
-
return
|
|
36
|
+
return await this.block(captured, decision, "INTENT_BINDING_MISMATCH", startedAt);
|
|
16
37
|
}
|
|
17
|
-
if (decision.authorization === null) {
|
|
18
|
-
return
|
|
38
|
+
if (decision.authorization === null || typeof decision.authorization !== "object") {
|
|
39
|
+
return await this.block(captured, decision, "AUTHORIZATION_MISSING", startedAt);
|
|
19
40
|
}
|
|
20
41
|
if (!this.intentConforms(captured)) {
|
|
21
|
-
return
|
|
42
|
+
return await this.block(captured, decision, "INTENT_CONFORMANCE_FAILED", startedAt);
|
|
22
43
|
}
|
|
23
44
|
this.registry.validate(captured);
|
|
24
45
|
let authorization;
|
|
@@ -26,10 +47,11 @@ export class SafeExecutor {
|
|
|
26
47
|
authorization = await this.verifier.verifyAndConsume(captured, decision);
|
|
27
48
|
}
|
|
28
49
|
catch {
|
|
29
|
-
return
|
|
50
|
+
return await this.block(captured, decision, "AUTHORIZATION_INVALID", startedAt);
|
|
51
|
+
}
|
|
52
|
+
if (authorization === null) {
|
|
53
|
+
return await this.block(captured, decision, "AUTHORIZATION_INVALID", startedAt);
|
|
30
54
|
}
|
|
31
|
-
if (authorization === null)
|
|
32
|
-
return SafeExecutor.blocked("AUTHORIZATION_INVALID");
|
|
33
55
|
const authorizationExpiry = Date.parse(authorization.expiresAt);
|
|
34
56
|
if (authorization.decisionId !== decision.decisionId ||
|
|
35
57
|
authorization.dossierId !== decision.dossierId ||
|
|
@@ -39,19 +61,208 @@ export class SafeExecutor {
|
|
|
39
61
|
Math.floor(Date.parse(decision.authorization.expiresAt) / 1_000) ||
|
|
40
62
|
authorizationExpiry <= Date.now() ||
|
|
41
63
|
authorizationExpiry > Date.parse(captured.intent.expiresAt)) {
|
|
42
|
-
return
|
|
64
|
+
return await this.block(captured, decision, "AUTHORIZATION_INVALID", startedAt);
|
|
43
65
|
}
|
|
44
66
|
if (!this.intentConforms(captured)) {
|
|
45
|
-
return
|
|
67
|
+
return await this.block(captured, decision, "INTENT_CONFORMANCE_FAILED", startedAt);
|
|
68
|
+
}
|
|
69
|
+
// Stryker disable all: Audit payload mapping is covered by lifecycle event assertions.
|
|
70
|
+
const grantRecorded = await this.record({
|
|
71
|
+
eventType: "GRANT_CONSUMED",
|
|
72
|
+
captured,
|
|
73
|
+
decision,
|
|
74
|
+
authorization,
|
|
75
|
+
durationMs: Date.now() - startedAt,
|
|
76
|
+
});
|
|
77
|
+
// Stryker restore all
|
|
78
|
+
if (this.audit?.requiresDeliveryBeforeExecution === true && !grantRecorded) {
|
|
79
|
+
return await this.failedBeforeDispatch(captured, decision, authorization, "AUDIT_UNAVAILABLE", startedAt);
|
|
80
|
+
}
|
|
81
|
+
// Stryker disable all: Audit payload mapping is covered by lifecycle event assertions.
|
|
82
|
+
const executionRecorded = await this.record({
|
|
83
|
+
eventType: "EXECUTION_STARTED",
|
|
84
|
+
captured,
|
|
85
|
+
decision,
|
|
86
|
+
authorization,
|
|
87
|
+
durationMs: Date.now() - startedAt,
|
|
88
|
+
});
|
|
89
|
+
// Stryker restore all
|
|
90
|
+
if (this.audit?.requiresDeliveryBeforeExecution === true && !executionRecorded) {
|
|
91
|
+
return await this.failedBeforeDispatch(captured, decision, authorization, "AUDIT_UNAVAILABLE", startedAt);
|
|
46
92
|
}
|
|
47
|
-
|
|
93
|
+
const attempt = await this.registry.executeTracked(captured, authorization);
|
|
94
|
+
if (attempt.status === "FAILED_BEFORE_DISPATCH") {
|
|
95
|
+
return await this.failedBeforeDispatch(captured, decision, authorization, "HANDLER_FAILED_BEFORE_DISPATCH", startedAt);
|
|
96
|
+
}
|
|
97
|
+
if (attempt.status === "REFUSED_AFTER_DISPATCH") {
|
|
98
|
+
// The provider said no. That is an outcome, so it is finalized `FAILED`
|
|
99
|
+
// rather than left indeterminate, and `executed` is false rather than
|
|
100
|
+
// null: nothing about it is unknown.
|
|
101
|
+
const finalization = await this.finalize(captured, decision, authorization, "FAILED");
|
|
102
|
+
const result = {
|
|
103
|
+
outcome: "DEFINITELY_NOT_EXECUTED",
|
|
104
|
+
executed: false,
|
|
105
|
+
recovered: false,
|
|
106
|
+
reason: attempt.reason,
|
|
107
|
+
result: null,
|
|
108
|
+
authorization,
|
|
109
|
+
finalization,
|
|
110
|
+
};
|
|
111
|
+
// Stryker disable all: Audit payload mapping is covered by lifecycle event assertions.
|
|
112
|
+
await this.record({
|
|
113
|
+
eventType: "EXECUTION_REFUSED_AFTER_DISPATCH",
|
|
114
|
+
captured,
|
|
115
|
+
decision,
|
|
116
|
+
authorization,
|
|
117
|
+
reasonCodes: [attempt.reason, SafeExecutor.finalizationCode(finalization)],
|
|
118
|
+
durationMs: Date.now() - startedAt,
|
|
119
|
+
});
|
|
120
|
+
// Stryker restore all
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
123
|
+
if (attempt.status === "UNKNOWN_AFTER_DISPATCH") {
|
|
124
|
+
const finalization = await this.finalize(captured, decision, authorization, "INDETERMINATE");
|
|
125
|
+
const result = {
|
|
126
|
+
outcome: "UNKNOWN_AFTER_DISPATCH",
|
|
127
|
+
executed: null,
|
|
128
|
+
reason: "PROVIDER_OUTCOME_UNKNOWN",
|
|
129
|
+
result: null,
|
|
130
|
+
authorization,
|
|
131
|
+
recovery: SafeExecutor.recoveryReference(captured, authorization),
|
|
132
|
+
finalization,
|
|
133
|
+
};
|
|
134
|
+
// Stryker disable all: Audit payload mapping is covered by lifecycle event assertions.
|
|
135
|
+
await this.record({
|
|
136
|
+
eventType: "EXECUTION_OUTCOME_UNKNOWN",
|
|
137
|
+
captured,
|
|
138
|
+
decision,
|
|
139
|
+
authorization,
|
|
140
|
+
reasonCodes: [result.reason, SafeExecutor.finalizationCode(finalization)],
|
|
141
|
+
durationMs: Date.now() - startedAt,
|
|
142
|
+
});
|
|
143
|
+
// Stryker restore all
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
const finalization = await this.finalize(captured, decision, authorization, "COMMITTED");
|
|
147
|
+
const result = {
|
|
148
|
+
outcome: "COMPLETED",
|
|
149
|
+
executed: true,
|
|
150
|
+
recovered: false,
|
|
151
|
+
result: attempt.result,
|
|
152
|
+
authorization,
|
|
153
|
+
finalization,
|
|
154
|
+
};
|
|
155
|
+
// Stryker disable all: Audit payload mapping is covered by lifecycle event assertions.
|
|
156
|
+
await this.record({
|
|
157
|
+
eventType: "EXECUTION_COMPLETED",
|
|
158
|
+
captured,
|
|
159
|
+
decision,
|
|
160
|
+
authorization,
|
|
161
|
+
reasonCodes: [SafeExecutor.finalizationCode(finalization)],
|
|
162
|
+
durationMs: Date.now() - startedAt,
|
|
163
|
+
});
|
|
164
|
+
// Stryker restore all
|
|
165
|
+
return result;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Reports the attempt outcome to the verifier's authority. A missing,
|
|
169
|
+
* failing, or malformed finalization can never alter the execution result.
|
|
170
|
+
*/
|
|
171
|
+
async finalize(captured, decision, authorization, outcome) {
|
|
172
|
+
const finalize = this.verifier.finalize;
|
|
173
|
+
if (finalize === undefined)
|
|
174
|
+
return "UNSUPPORTED";
|
|
48
175
|
try {
|
|
49
|
-
|
|
176
|
+
const status = await finalize.call(this.verifier, {
|
|
177
|
+
captured,
|
|
178
|
+
decision,
|
|
179
|
+
authorization,
|
|
180
|
+
outcome,
|
|
181
|
+
});
|
|
182
|
+
return status === "RECORDED" ? "RECORDED" : "PENDING";
|
|
50
183
|
}
|
|
51
184
|
catch {
|
|
52
|
-
|
|
185
|
+
return "PENDING";
|
|
53
186
|
}
|
|
54
|
-
|
|
187
|
+
}
|
|
188
|
+
static finalizationCode(finalization) {
|
|
189
|
+
return `COMMIT_FINALIZATION_${finalization}`;
|
|
190
|
+
}
|
|
191
|
+
async reconcile(captured, recovery) {
|
|
192
|
+
const startedAt = Date.now();
|
|
193
|
+
if (recovery.version !== "agent-safe.recovery/1" ||
|
|
194
|
+
recovery.intentHash !== captured.intentHash ||
|
|
195
|
+
recovery.idempotencyKey !== captured.intent.idempotencyKey ||
|
|
196
|
+
!this.intentConforms(captured)) {
|
|
197
|
+
return await this.block(captured, undefined, "RECOVERY_BINDING_MISMATCH", startedAt);
|
|
198
|
+
}
|
|
199
|
+
const reconciliation = await this.registry.reconcile(captured, recovery.idempotencyKey);
|
|
200
|
+
const authorization = SafeExecutor.authorizationFrom(recovery);
|
|
201
|
+
if (reconciliation.status === "COMPLETED") {
|
|
202
|
+
const result = {
|
|
203
|
+
outcome: "COMPLETED",
|
|
204
|
+
executed: true,
|
|
205
|
+
recovered: true,
|
|
206
|
+
result: reconciliation.result,
|
|
207
|
+
authorization,
|
|
208
|
+
};
|
|
209
|
+
// Stryker disable all: Audit payload mapping is covered by lifecycle event assertions.
|
|
210
|
+
await this.record({
|
|
211
|
+
eventType: "RECONCILIATION_COMPLETED",
|
|
212
|
+
captured,
|
|
213
|
+
authorization,
|
|
214
|
+
durationMs: Date.now() - startedAt,
|
|
215
|
+
});
|
|
216
|
+
// Stryker restore all
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
if (reconciliation.status === "NOT_EXECUTED") {
|
|
220
|
+
const result = {
|
|
221
|
+
outcome: "DEFINITELY_NOT_EXECUTED",
|
|
222
|
+
executed: false,
|
|
223
|
+
recovered: true,
|
|
224
|
+
reason: "PROVIDER_CONFIRMED_NOT_EXECUTED",
|
|
225
|
+
result: null,
|
|
226
|
+
authorization,
|
|
227
|
+
};
|
|
228
|
+
// Stryker disable all: Audit payload mapping is covered by lifecycle event assertions.
|
|
229
|
+
await this.record({
|
|
230
|
+
eventType: "RECONCILIATION_NOT_EXECUTED",
|
|
231
|
+
captured,
|
|
232
|
+
authorization,
|
|
233
|
+
reasonCodes: [result.reason],
|
|
234
|
+
durationMs: Date.now() - startedAt,
|
|
235
|
+
});
|
|
236
|
+
// Stryker restore all
|
|
237
|
+
return result;
|
|
238
|
+
}
|
|
239
|
+
const result = {
|
|
240
|
+
outcome: "UNKNOWN_AFTER_DISPATCH",
|
|
241
|
+
executed: null,
|
|
242
|
+
reason: "PROVIDER_OUTCOME_UNKNOWN",
|
|
243
|
+
result: null,
|
|
244
|
+
authorization,
|
|
245
|
+
recovery,
|
|
246
|
+
};
|
|
247
|
+
// Stryker disable all: Audit payload mapping is covered by lifecycle event assertions.
|
|
248
|
+
await this.record({
|
|
249
|
+
eventType: "RECONCILIATION_UNKNOWN",
|
|
250
|
+
captured,
|
|
251
|
+
authorization,
|
|
252
|
+
reasonCodes: [result.reason],
|
|
253
|
+
durationMs: Date.now() - startedAt,
|
|
254
|
+
});
|
|
255
|
+
// Stryker restore all
|
|
256
|
+
return result;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Observational artifacts carry an explicit non-authoritative marker. They
|
|
260
|
+
* must never be interpreted as a `GateDecision`, even after an unsafe cast
|
|
261
|
+
* or a JSON round trip.
|
|
262
|
+
*/
|
|
263
|
+
static isAuthoritativeDecision(decision) {
|
|
264
|
+
const candidate = decision;
|
|
265
|
+
return candidate.authority !== "OBSERVATIONAL" && candidate.mode !== "SHADOW";
|
|
55
266
|
}
|
|
56
267
|
intentConforms(captured) {
|
|
57
268
|
let recomputed = null;
|
|
@@ -66,8 +277,68 @@ export class SafeExecutor {
|
|
|
66
277
|
recomputed.canonicalIntent === captured.canonicalIntent &&
|
|
67
278
|
recomputed.byteLength === captured.byteLength);
|
|
68
279
|
}
|
|
69
|
-
|
|
70
|
-
|
|
280
|
+
async block(captured, decision, reason, startedAt) {
|
|
281
|
+
// Stryker disable all: Audit payload mapping is covered by lifecycle event assertions.
|
|
282
|
+
await this.record({
|
|
283
|
+
eventType: "EXECUTION_BLOCKED",
|
|
284
|
+
captured,
|
|
285
|
+
...(decision === undefined ? {} : { decision }),
|
|
286
|
+
reasonCodes: [reason],
|
|
287
|
+
durationMs: Date.now() - startedAt,
|
|
288
|
+
});
|
|
289
|
+
// Stryker restore all
|
|
290
|
+
return { outcome: "BLOCKED", executed: false, reason, result: null, authorization: null };
|
|
291
|
+
}
|
|
292
|
+
async failedBeforeDispatch(captured, decision, authorization, reason, startedAt) {
|
|
293
|
+
// The grant was consumed but no side effect was attempted.
|
|
294
|
+
const finalization = await this.finalize(captured, decision, authorization, "FAILED");
|
|
295
|
+
// Stryker disable all: Audit payload mapping is covered by lifecycle event assertions.
|
|
296
|
+
await this.record({
|
|
297
|
+
eventType: "EXECUTION_FAILED_BEFORE_DISPATCH",
|
|
298
|
+
captured,
|
|
299
|
+
decision,
|
|
300
|
+
authorization,
|
|
301
|
+
reasonCodes: [reason, SafeExecutor.finalizationCode(finalization)],
|
|
302
|
+
durationMs: Date.now() - startedAt,
|
|
303
|
+
});
|
|
304
|
+
// Stryker restore all
|
|
305
|
+
return {
|
|
306
|
+
outcome: "FAILED_BEFORE_DISPATCH",
|
|
307
|
+
executed: false,
|
|
308
|
+
reason,
|
|
309
|
+
result: null,
|
|
310
|
+
authorization,
|
|
311
|
+
finalization,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
async record(input) {
|
|
315
|
+
// Stryker disable next-line BooleanLiteral: The value is irrelevant when no audit policy exists.
|
|
316
|
+
return this.audit === undefined ? true : await this.audit.record(input);
|
|
317
|
+
}
|
|
318
|
+
static recoveryReference(captured, authorization) {
|
|
319
|
+
// Named field by field rather than spread: `agent-safe.recovery/1` is a
|
|
320
|
+
// wire object a caller presents back, so a field added to the
|
|
321
|
+
// authorization must not appear here by accident. The claim lease in
|
|
322
|
+
// particular has no business being here — it is the window this attempt
|
|
323
|
+
// had, and it has certainly closed by the time anyone reconciles.
|
|
324
|
+
return Object.freeze({
|
|
325
|
+
version: "agent-safe.recovery/1",
|
|
326
|
+
decisionId: authorization.decisionId,
|
|
327
|
+
dossierId: authorization.dossierId,
|
|
328
|
+
grantId: authorization.grantId,
|
|
329
|
+
intentHash: authorization.intentHash,
|
|
330
|
+
expiresAt: authorization.expiresAt,
|
|
331
|
+
idempotencyKey: captured.intent.idempotencyKey,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
static authorizationFrom(recovery) {
|
|
335
|
+
return Object.freeze({
|
|
336
|
+
decisionId: recovery.decisionId,
|
|
337
|
+
dossierId: recovery.dossierId,
|
|
338
|
+
grantId: recovery.grantId,
|
|
339
|
+
intentHash: recovery.intentHash,
|
|
340
|
+
expiresAt: recovery.expiresAt,
|
|
341
|
+
});
|
|
71
342
|
}
|
|
72
343
|
}
|
|
73
344
|
//# sourceMappingURL=SafeExecutor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SafeExecutor.js","sourceRoot":"","sources":["../../src/execution/SafeExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,E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,CAAC,SAAS;YAC7B,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,SAAS,EAAE,QAAQ,CAAC,SAAS;SAC9B,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Where a hosted call came from, for the authority's own accounting. Never decision input. */
|
|
2
|
+
export interface ClientSource {
|
|
3
|
+
/** The repository the integration was taken from, as `owner/name`. */
|
|
4
|
+
readonly repo?: string;
|
|
5
|
+
/** The example or integration name within it. */
|
|
6
|
+
readonly example?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Which surface the integration was taken from, `github` for a clone or
|
|
9
|
+
* fork of the repository; the authority stamps an organization it creates
|
|
10
|
+
* for such a caller with it, so a repository's path can be measured.
|
|
11
|
+
*/
|
|
12
|
+
readonly surface?: string;
|
|
13
|
+
}
|
|
14
|
+
/** This package's own version, read once from its manifest; `unknown` if it cannot be. */
|
|
15
|
+
export declare function packageVersion(): string;
|
|
16
|
+
/**
|
|
17
|
+
* The `User-Agent` a hosted call carries: the package and its version, and
|
|
18
|
+
* when the caller says where the integration came from, that too. A value
|
|
19
|
+
* the header could not carry verbatim is left out rather than escaped.
|
|
20
|
+
*/
|
|
21
|
+
export declare function userAgent(source?: ClientSource): string;
|
|
22
|
+
//# sourceMappingURL=ClientIdentification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientIdentification.d.ts","sourceRoot":"","sources":["../../src/http/ClientIdentification.ts"],"names":[],"mappings":"AAEA,+FAA+F;AAC/F,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,iDAAiD;IACjD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAWD,0FAA0F;AAC1F,wBAAgB,cAAc,IAAI,MAAM,CAsBvC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,GAAE,YAAiB,GAAG,MAAM,CAa3D"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
const PRODUCT = "agent-safe-pipeline";
|
|
3
|
+
/** A product token or comment value: what a `User-Agent` may carry without escaping. */
|
|
4
|
+
const TOKEN = /^[\w.\-/@]{1,120}$/;
|
|
5
|
+
let cachedVersion;
|
|
6
|
+
/** This package's own version, read once from its manifest; `unknown` if it cannot be. */
|
|
7
|
+
export function packageVersion() {
|
|
8
|
+
if (cachedVersion === undefined) {
|
|
9
|
+
if (typeof __AGENT_SAFE_PIPELINE_VERSION__ === "string" &&
|
|
10
|
+
TOKEN.test(__AGENT_SAFE_PIPELINE_VERSION__)) {
|
|
11
|
+
cachedVersion = __AGENT_SAFE_PIPELINE_VERSION__;
|
|
12
|
+
return cachedVersion;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const manifest = createRequire(import.meta.url)("../../package.json");
|
|
16
|
+
cachedVersion =
|
|
17
|
+
typeof manifest.version === "string" && TOKEN.test(manifest.version)
|
|
18
|
+
? manifest.version
|
|
19
|
+
: "unknown";
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
cachedVersion = "unknown";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return cachedVersion;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The `User-Agent` a hosted call carries: the package and its version, and
|
|
29
|
+
* when the caller says where the integration came from, that too. A value
|
|
30
|
+
* the header could not carry verbatim is left out rather than escaped.
|
|
31
|
+
*/
|
|
32
|
+
export function userAgent(source = {}) {
|
|
33
|
+
const product = `${PRODUCT}/${packageVersion()}`;
|
|
34
|
+
const comment = [
|
|
35
|
+
["repo", source.repo],
|
|
36
|
+
["example", source.example],
|
|
37
|
+
["surface", source.surface],
|
|
38
|
+
]
|
|
39
|
+
.filter((entry) => typeof entry[1] === "string" && TOKEN.test(entry[1]))
|
|
40
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
41
|
+
.join("; ");
|
|
42
|
+
return comment === "" ? product : `${product} (${comment})`;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=ClientIdentification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientIdentification.js","sourceRoot":"","sources":["../../src/http/ClientIdentification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAgB5C,MAAM,OAAO,GAAG,qBAAqB,CAAC;AACtC,wFAAwF;AACxF,MAAM,KAAK,GAAG,oBAAoB,CAAC;AAEnC,IAAI,aAAiC,CAAC;AAKtC,0FAA0F;AAC1F,MAAM,UAAU,cAAc;IAC5B,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAChC,IACE,OAAO,+BAA+B,KAAK,QAAQ;YACnD,KAAK,CAAC,IAAI,CAAC,+BAA+B,CAAC,EAC3C,CAAC;YACD,aAAa,GAAG,+BAA+B,CAAC;YAChD,OAAO,aAAa,CAAC;QACvB,CAAC;QACD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAEnE,CAAC;YACF,aAAa;gBACX,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;oBAClE,CAAC,CAAC,QAAQ,CAAC,OAAO;oBAClB,CAAC,CAAC,SAAS,CAAC;QAClB,CAAC;QAAC,MAAM,CAAC;YACP,aAAa,GAAG,SAAS,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,SAAuB,EAAE;IACjD,MAAM,OAAO,GAAG,GAAG,OAAO,IAAI,cAAc,EAAE,EAAE,CAAC;IACjD,MAAM,OAAO,GAAG;QACd,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC;QACrB,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC;QAC3B,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC;KAC5B;SACE,MAAM,CACL,CAAC,KAAK,EAA6B,EAAE,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAC3F;SACA,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;SACxC,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,OAAO,GAAG,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A credential a client reads at the moment of use.
|
|
3
|
+
*
|
|
4
|
+
* A deployment whose Decionis credential rotates has two choices. It can
|
|
5
|
+
* rebuild every client that holds the old value, which means a request in
|
|
6
|
+
* flight and the next request can disagree about which client they belong
|
|
7
|
+
* to; or it can hand each client a function and let the value be read per
|
|
8
|
+
* request. The second is what this type is for: the client holds no string,
|
|
9
|
+
* so nothing has to be torn down when the file behind it changes.
|
|
10
|
+
*
|
|
11
|
+
* A plain string is still accepted, and is the right answer for a credential
|
|
12
|
+
* that does not rotate inside a process's life.
|
|
13
|
+
*/
|
|
14
|
+
export type Credential = string | (() => string);
|
|
15
|
+
/** The reader a client keeps: a constant for a value, the caller's own for a function. */
|
|
16
|
+
export declare function credentialReader(credential: Credential): () => string;
|
|
17
|
+
//# sourceMappingURL=Credential.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Credential.d.ts","sourceRoot":"","sources":["../../src/http/Credential.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;AAEjD,0FAA0F;AAC1F,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,MAAM,CAErE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Credential.js","sourceRoot":"","sources":["../../src/http/Credential.ts"],"names":[],"mappings":"AAeA,0FAA0F;AAC1F,MAAM,UAAU,gBAAgB,CAAC,UAAsB;IACrD,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAW,EAAE,CAAC,UAAU,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface StoredCredentials {
|
|
2
|
+
readonly apiKey: string;
|
|
3
|
+
/** The key's organization, which every intent must name; null when the login did not say. */
|
|
4
|
+
readonly tenantId: string | null;
|
|
5
|
+
/** The authority the key belongs to; null means the default. */
|
|
6
|
+
readonly endpoint: string | null;
|
|
7
|
+
/** True for a workspace an example provisioned without an account; absent for a login. */
|
|
8
|
+
readonly provisional?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** The files the store touches, behind a seam so a test hands in a directory of its own. */
|
|
11
|
+
export interface CredentialFiles {
|
|
12
|
+
/** The text, or null when there is no such file. */
|
|
13
|
+
read(path: string): string | null;
|
|
14
|
+
write(path: string, text: string, mode: number): void;
|
|
15
|
+
mkdir(path: string): void;
|
|
16
|
+
}
|
|
17
|
+
export interface CredentialStoreOptions {
|
|
18
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
19
|
+
/** The user's home directory; defaults to the process's. */
|
|
20
|
+
readonly home?: string;
|
|
21
|
+
readonly files?: CredentialFiles;
|
|
22
|
+
}
|
|
23
|
+
export declare const nodeCredentialFiles: CredentialFiles;
|
|
24
|
+
/** Where the credential lives: `$AGENTSAFE_HOME`, else the XDG config directory, under `agentsafe`. */
|
|
25
|
+
export declare function credentialsDirectory(options: CredentialStoreOptions): string;
|
|
26
|
+
export declare function credentialsPath(options: CredentialStoreOptions): string;
|
|
27
|
+
/**
|
|
28
|
+
* The stored credential, or null when there is none, it cannot be read as
|
|
29
|
+
* one, or the process is marked production, where a login is never a source.
|
|
30
|
+
*/
|
|
31
|
+
export declare function readStoredCredentials(options: CredentialStoreOptions): StoredCredentials | null;
|
|
32
|
+
/** Writes the credential, readable by this user alone, and returns where. */
|
|
33
|
+
export declare function writeStoredCredentials(options: CredentialStoreOptions, credentials: StoredCredentials): string;
|
|
34
|
+
//# sourceMappingURL=StoredCredentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StoredCredentials.d.ts","sourceRoot":"","sources":["../../src/http/StoredCredentials.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6FAA6F;IAC7F,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,0FAA0F;IAC1F,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,4FAA4F;AAC5F,MAAM,WAAW,eAAe;IAC9B,oDAAoD;IACpD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAClC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACtD,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3D,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC;CAClC;AAeD,eAAO,MAAM,mBAAmB,EAAE,eAcjC,CAAC;AAEF,uGAAuG;AACvG,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,CAM5E;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,CAEvE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,iBAAiB,GAAG,IAAI,CAe/F;AAED,6EAA6E;AAC7E,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,sBAAsB,EAC/B,WAAW,EAAE,iBAAiB,GAC7B,MAAM,CAOR"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Decionis key a developer keeps on their own machine: what
|
|
3
|
+
* `agentsafe login` stores, and what an example provisions for itself when
|
|
4
|
+
* asked to run hosted with no key set. One file, one shape, readable by its
|
|
5
|
+
* owner alone, so the two paths onto Decionis share a credential rather
|
|
6
|
+
* than each keeping its own. Production never reads it: a server's
|
|
7
|
+
* credential is mounted, not logged in.
|
|
8
|
+
*/
|
|
9
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { homedir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
const CREDENTIALS_FILE = "credentials.json";
|
|
14
|
+
const MAX_CREDENTIALS_BYTES = 16 * 1024;
|
|
15
|
+
const CredentialsSchema = z.strictObject({
|
|
16
|
+
version: z.literal(1),
|
|
17
|
+
decionis: z.strictObject({
|
|
18
|
+
apiKey: z.string().min(1).max(4_096),
|
|
19
|
+
tenantId: z.string().uuid().nullable(),
|
|
20
|
+
endpoint: z.string().min(1).max(500).nullable(),
|
|
21
|
+
provisional: z.boolean().optional(),
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
export const nodeCredentialFiles = {
|
|
25
|
+
read: (path) => {
|
|
26
|
+
try {
|
|
27
|
+
return readFileSync(path, "utf8");
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
write: (path, text, mode) => {
|
|
34
|
+
writeFileSync(path, text, { encoding: "utf8", mode });
|
|
35
|
+
},
|
|
36
|
+
mkdir: (path) => {
|
|
37
|
+
mkdirSync(path, { recursive: true, mode: 0o700 });
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
/** Where the credential lives: `$AGENTSAFE_HOME`, else the XDG config directory, under `agentsafe`. */
|
|
41
|
+
export function credentialsDirectory(options) {
|
|
42
|
+
const explicit = options.env["AGENTSAFE_HOME"]?.trim();
|
|
43
|
+
if (explicit !== undefined && explicit !== "")
|
|
44
|
+
return explicit;
|
|
45
|
+
const xdg = options.env["XDG_CONFIG_HOME"]?.trim();
|
|
46
|
+
const home = options.home ?? homedir();
|
|
47
|
+
return join(xdg !== undefined && xdg !== "" ? xdg : join(home, ".config"), "agentsafe");
|
|
48
|
+
}
|
|
49
|
+
export function credentialsPath(options) {
|
|
50
|
+
return join(credentialsDirectory(options), CREDENTIALS_FILE);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The stored credential, or null when there is none, it cannot be read as
|
|
54
|
+
* one, or the process is marked production, where a login is never a source.
|
|
55
|
+
*/
|
|
56
|
+
export function readStoredCredentials(options) {
|
|
57
|
+
if (options.env["NODE_ENV"] === "production")
|
|
58
|
+
return null;
|
|
59
|
+
const files = options.files ?? nodeCredentialFiles;
|
|
60
|
+
const text = files.read(credentialsPath(options));
|
|
61
|
+
if (text === null || Buffer.byteLength(text, "utf8") > MAX_CREDENTIALS_BYTES)
|
|
62
|
+
return null;
|
|
63
|
+
let parsed;
|
|
64
|
+
try {
|
|
65
|
+
parsed = JSON.parse(text);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const result = CredentialsSchema.safeParse(parsed);
|
|
71
|
+
if (!result.success)
|
|
72
|
+
return null;
|
|
73
|
+
const { provisional, ...credentials } = result.data.decionis;
|
|
74
|
+
return provisional === undefined ? credentials : { ...credentials, provisional };
|
|
75
|
+
}
|
|
76
|
+
/** Writes the credential, readable by this user alone, and returns where. */
|
|
77
|
+
export function writeStoredCredentials(options, credentials) {
|
|
78
|
+
const files = options.files ?? nodeCredentialFiles;
|
|
79
|
+
const directory = credentialsDirectory(options);
|
|
80
|
+
files.mkdir(directory);
|
|
81
|
+
const path = join(directory, CREDENTIALS_FILE);
|
|
82
|
+
files.write(path, `${JSON.stringify({ version: 1, decionis: credentials }, null, 2)}\n`, 0o600);
|
|
83
|
+
return path;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=StoredCredentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StoredCredentials.js","sourceRoot":"","sources":["../../src/http/StoredCredentials.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA2BxB,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAC5C,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,CAAC;AAExC,MAAM,iBAAiB,GAAG,CAAC,CAAC,YAAY,CAAC;IACvC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACrB,QAAQ,EAA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IAC7D,OAAO,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,WAAW,EAAE,WAAW,EAAE,CAAC;AACnF,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,sBAAsB,CACpC,OAA+B,EAC/B,WAA8B;IAE9B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,mBAAmB,CAAC;IACnD,MAAM,SAAS,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAChD,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACvB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;IAC/C,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChG,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AuthorityIntentBinding, type CapturedIntent, type ExecutionIntent } from "./ExecutionIntent.js";
|
|
2
2
|
import type { JsonValue } from "./JsonValue.js";
|
|
3
3
|
export interface CanonicalLimits {
|
|
4
4
|
readonly maxDepth: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanonicalIntentHasher.d.ts","sourceRoot":"","sources":["../../src/intent/CanonicalIntentHasher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"CanonicalIntentHasher.d.ts","sourceRoot":"","sources":["../../src/intent/CanonicalIntentHasher.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;gBAEtB,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC;IAS7C,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc;IAqBhD,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;WAoDjC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,sBAAsB;WAoC1D,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM;IAIjD,OAAO,CAAC,MAAM,CAAC,YAAY;IAW3B,OAAO,CAAC,MAAM,CAAC,UAAU;IAUzB,OAAO,CAAC,aAAa;CAoBtB"}
|