witnora 0.13.3 → 0.13.5
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/dist/gateway.js +686 -29
- package/dist/internal/control-client/collector-gateway.d.ts +18 -1
- package/dist/internal/control-client/collector-gateway.d.ts.map +1 -1
- package/dist/internal/control-client/collector-gateway.js +34 -3
- package/dist/internal/control-client/durable-action-worker.d.ts +194 -0
- package/dist/internal/control-client/durable-action-worker.d.ts.map +1 -0
- package/dist/internal/control-client/durable-action-worker.js +359 -0
- package/dist/internal/control-client/remote-collector.d.ts +20 -0
- package/dist/internal/control-client/remote-collector.d.ts.map +1 -1
- package/dist/internal/control-client/remote-collector.js +1 -0
- package/dist/onboard.js +99 -12
- package/dist/probe-process.js +135 -0
- package/dist/runtime-bootstrap.js +333 -0
- package/dist/runtime-sandbox-fixture.js +166 -0
- package/dist/runtime-sandbox-kit.js +295 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomerSourceKeyRing, type CustomerSourceSigner, type RemoteCollectorAck, type RemoteTrustedSourceRecord } from "./remote-collector.js";
|
|
1
|
+
import { CustomerSourceKeyRing, type CustomerSourceSigner, type CollectorRuntimeHeartbeat, type RuntimeReadinessBinding, type RemoteCollectorAck, type RemoteTrustedSourceRecord } from "./remote-collector.js";
|
|
2
2
|
export interface RemoteCollectorTransport {
|
|
3
3
|
registerSourceKey(input: {
|
|
4
4
|
collectorId: string;
|
|
@@ -12,6 +12,7 @@ export interface RemoteCollectorTransport {
|
|
|
12
12
|
signer: CustomerSourceSigner;
|
|
13
13
|
pendingRecordCount: number;
|
|
14
14
|
lastAckSequence?: number;
|
|
15
|
+
runtime?: CollectorRuntimeHeartbeat;
|
|
15
16
|
}): Promise<Record<string, unknown>>;
|
|
16
17
|
reconcile(runId: string, receipt: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
17
18
|
proposeAction(proposal: Record<string, unknown>, idempotencyKey: string): Promise<Record<string, unknown>>;
|
|
@@ -30,6 +31,21 @@ export interface CustomerOwnedCollectorGatewayOptions {
|
|
|
30
31
|
flushIntervalMs?: number;
|
|
31
32
|
heartbeatIntervalMs?: number;
|
|
32
33
|
maxBodyBytes?: number;
|
|
34
|
+
actionWorker?: {
|
|
35
|
+
track(input: {
|
|
36
|
+
actionId: string;
|
|
37
|
+
proposal: Record<string, unknown>;
|
|
38
|
+
}): Promise<unknown>;
|
|
39
|
+
status(): Promise<Record<string, unknown>>;
|
|
40
|
+
close?(): void | Promise<void>;
|
|
41
|
+
runtimeBinding?: {
|
|
42
|
+
classification: "LOCAL_SANDBOX_ONLY";
|
|
43
|
+
binding: RuntimeReadinessBinding;
|
|
44
|
+
fixtureReady: boolean;
|
|
45
|
+
workerReady?: boolean;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
runtimeBinding?: RuntimeReadinessBinding;
|
|
33
49
|
}
|
|
34
50
|
export interface CustomerOwnedCollectorGateway {
|
|
35
51
|
baseUrl: string;
|
|
@@ -50,6 +66,7 @@ export interface CollectorGatewayStatus {
|
|
|
50
66
|
lastAckSequence?: number;
|
|
51
67
|
lastRemoteSuccessAt?: string;
|
|
52
68
|
lastRemoteError?: string;
|
|
69
|
+
actionWorker?: Record<string, unknown>;
|
|
53
70
|
}
|
|
54
71
|
export declare function startCustomerOwnedCollectorGateway(options: CustomerOwnedCollectorGatewayOptions): Promise<CustomerOwnedCollectorGateway>;
|
|
55
72
|
//# sourceMappingURL=collector-gateway.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collector-gateway.d.ts","sourceRoot":"","sources":["../../../../agentcert-sdk/src/collector-gateway.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,qBAAqB,EAGrB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC/B,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,wBAAwB;IACvC,iBAAiB,CAAC,KAAK,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AAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAUD,wBAAsB,kCAAkC,CAAC,OAAO,EAAE,oCAAoC,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAmM9I"}
|
|
@@ -10,6 +10,10 @@ export async function startCustomerOwnedCollectorGateway(options) {
|
|
|
10
10
|
const storageDirectory = resolve(options.storageDirectory);
|
|
11
11
|
await mkdir(storageDirectory, { recursive: true });
|
|
12
12
|
const signer = options.keyRing.activeSigner();
|
|
13
|
+
const runtimeBinding = options.actionWorker?.runtimeBinding?.binding ?? options.runtimeBinding;
|
|
14
|
+
if (runtimeBinding && (runtimeBinding.collectorId !== options.keyRing.collectorId || runtimeBinding.sourceKeyId !== signer.keyId)) {
|
|
15
|
+
throw new Error("runtimeBinding must match the Gateway collector and active source key.");
|
|
16
|
+
}
|
|
13
17
|
let sourceKeyRegistered = false;
|
|
14
18
|
const journals = new Map();
|
|
15
19
|
const activeCollector = {
|
|
@@ -84,6 +88,7 @@ export async function startCustomerOwnedCollectorGateway(options) {
|
|
|
84
88
|
lastAckSequence,
|
|
85
89
|
lastRemoteSuccessAt,
|
|
86
90
|
lastRemoteError,
|
|
91
|
+
...(options.actionWorker ? { actionWorker: await options.actionWorker.status() } : {}),
|
|
87
92
|
};
|
|
88
93
|
};
|
|
89
94
|
const server = createServer(async (request, response) => {
|
|
@@ -96,7 +101,12 @@ export async function startCustomerOwnedCollectorGateway(options) {
|
|
|
96
101
|
return json(response, 200, await flush());
|
|
97
102
|
if (request.method === "POST" && url.pathname === "/v1/actions") {
|
|
98
103
|
const body = await readJson(request, options.maxBodyBytes ?? 1_048_576);
|
|
99
|
-
|
|
104
|
+
const proposal = object(body.proposal);
|
|
105
|
+
const hostedProposal = runtimeBinding ? { ...proposal, localRuntimeBinding: runtimeBinding } : proposal;
|
|
106
|
+
const action = await options.client.proposeAction(hostedProposal, identifier(body.idempotencyKey, "idempotencyKey"));
|
|
107
|
+
if (options.actionWorker)
|
|
108
|
+
await options.actionWorker.track({ actionId: identifier(action.id, "actionId"), proposal });
|
|
109
|
+
return json(response, 202, action);
|
|
100
110
|
}
|
|
101
111
|
const actionRoute = url.pathname.match(/^\/v1\/actions\/([A-Za-z0-9._:-]+)$/);
|
|
102
112
|
if (request.method === "GET" && actionRoute) {
|
|
@@ -160,15 +170,17 @@ export async function startCustomerOwnedCollectorGateway(options) {
|
|
|
160
170
|
if (!address || typeof address === "string")
|
|
161
171
|
throw new Error("Collector gateway did not bind a TCP port.");
|
|
162
172
|
const flushTimer = setInterval(() => void flush(), options.flushIntervalMs ?? 5_000);
|
|
163
|
-
const
|
|
173
|
+
const sendHeartbeat = async () => {
|
|
164
174
|
const current = await status();
|
|
165
175
|
try {
|
|
166
176
|
await ensureSourceKeyRegistered();
|
|
177
|
+
const workerStatus = options.actionWorker ? await options.actionWorker.status() : undefined;
|
|
167
178
|
await options.client.heartbeat({
|
|
168
179
|
collectorId: activeCollector.id,
|
|
169
180
|
signer,
|
|
170
181
|
pendingRecordCount: current.pendingRecordCount,
|
|
171
182
|
lastAckSequence: current.lastAckSequence,
|
|
183
|
+
runtime: runtimeBinding && workerStatus ? runtimeHeartbeat(runtimeBinding, workerStatus, options.actionWorker?.runtimeBinding?.fixtureReady) : undefined,
|
|
172
184
|
});
|
|
173
185
|
lastRemoteSuccessAt = new Date().toISOString();
|
|
174
186
|
lastRemoteError = undefined;
|
|
@@ -176,17 +188,20 @@ export async function startCustomerOwnedCollectorGateway(options) {
|
|
|
176
188
|
catch (error) {
|
|
177
189
|
lastRemoteError = message(error);
|
|
178
190
|
}
|
|
179
|
-
}
|
|
191
|
+
};
|
|
192
|
+
const heartbeatTimer = setInterval(() => void sendHeartbeat(), options.heartbeatIntervalMs ?? 30_000);
|
|
180
193
|
flushTimer.unref();
|
|
181
194
|
heartbeatTimer.unref();
|
|
182
195
|
for (const runId of await discoverRunIds(storageDirectory))
|
|
183
196
|
await journalFor(runId);
|
|
184
197
|
await flush();
|
|
198
|
+
await sendHeartbeat();
|
|
185
199
|
return {
|
|
186
200
|
baseUrl: `http://${options.host ?? "127.0.0.1"}:${address.port}`,
|
|
187
201
|
close: async () => {
|
|
188
202
|
clearInterval(flushTimer);
|
|
189
203
|
clearInterval(heartbeatTimer);
|
|
204
|
+
await options.actionWorker?.close?.();
|
|
190
205
|
await flush();
|
|
191
206
|
await close(server);
|
|
192
207
|
},
|
|
@@ -194,6 +209,22 @@ export async function startCustomerOwnedCollectorGateway(options) {
|
|
|
194
209
|
status,
|
|
195
210
|
};
|
|
196
211
|
}
|
|
212
|
+
function runtimeHeartbeat(binding, status, configuredFixtureReady) {
|
|
213
|
+
const boundary = status.runtimeBoundary && typeof status.runtimeBoundary === "object" && !Array.isArray(status.runtimeBoundary)
|
|
214
|
+
? status.runtimeBoundary
|
|
215
|
+
: undefined;
|
|
216
|
+
const fixture = boundary?.fixture && typeof boundary.fixture === "object" && !Array.isArray(boundary.fixture)
|
|
217
|
+
? boundary.fixture
|
|
218
|
+
: undefined;
|
|
219
|
+
const lastError = typeof status.lastError === "string" && status.lastError.trim() ? status.lastError.slice(0, 1_000) : undefined;
|
|
220
|
+
return {
|
|
221
|
+
classification: "LOCAL_SANDBOX_ONLY",
|
|
222
|
+
binding,
|
|
223
|
+
workerReady: status.ready === true,
|
|
224
|
+
fixtureReady: fixture?.ready === true || status.fixtureReady === true || configuredFixtureReady === true,
|
|
225
|
+
...(lastError ? { lastError } : {}),
|
|
226
|
+
};
|
|
227
|
+
}
|
|
197
228
|
class GatewayRunJournal {
|
|
198
229
|
runId;
|
|
199
230
|
collector;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
export type DurableActionPhase = "TRACKED" | "WAITING_APPROVAL" | "DENIED" | "EXPIRED" | "BLOCKED" | "GRANT_ISSUED" | "EXECUTION_STARTED" | "UNKNOWN_RESULT" | "EXECUTED" | "PROBED" | "COMPLETED";
|
|
2
|
+
export interface DurableWorkerProposal {
|
|
3
|
+
externalId: string;
|
|
4
|
+
actionType: string;
|
|
5
|
+
targetSystem: string;
|
|
6
|
+
expectedState?: Record<string, unknown>;
|
|
7
|
+
executionIntent: {
|
|
8
|
+
adapterId: string;
|
|
9
|
+
adapterVersionConstraint: string;
|
|
10
|
+
allowedOrigins: string[];
|
|
11
|
+
allowedOperation: string;
|
|
12
|
+
allowedResource: string;
|
|
13
|
+
approvedParameters: Record<string, unknown>;
|
|
14
|
+
outcomePredicate: Record<string, unknown>;
|
|
15
|
+
agentBuildId: string;
|
|
16
|
+
agentBuildDigest: string;
|
|
17
|
+
};
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
export interface DurableWorkerAction {
|
|
21
|
+
id: string;
|
|
22
|
+
externalId: string;
|
|
23
|
+
status: "PENDING_APPROVAL" | "APPROVED" | "ALLOWED" | "REJECTED" | "DENIED" | "APPROVAL_EXPIRED" | "GRANT_EXPIRED" | "VERIFIED" | string;
|
|
24
|
+
actionType: string;
|
|
25
|
+
targetSystem: string;
|
|
26
|
+
expectedState?: Record<string, unknown>;
|
|
27
|
+
approvalExpiresAt?: string;
|
|
28
|
+
assuranceContext?: {
|
|
29
|
+
executionIntent?: {
|
|
30
|
+
adapterId: string;
|
|
31
|
+
adapterVersionConstraint: string;
|
|
32
|
+
allowedOrigins: string[];
|
|
33
|
+
allowedOperation: string;
|
|
34
|
+
allowedResource: string;
|
|
35
|
+
approvedParametersDigest: string;
|
|
36
|
+
outcomePredicateDigest: string;
|
|
37
|
+
agentBuildId: string;
|
|
38
|
+
agentBuildDigest: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
export interface DurableWorkerGrant {
|
|
44
|
+
id: string;
|
|
45
|
+
status: string;
|
|
46
|
+
grant: {
|
|
47
|
+
payload?: Record<string, unknown>;
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
};
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
}
|
|
52
|
+
export interface DurableWorkerExecutionResult {
|
|
53
|
+
executionSessionId: string;
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
}
|
|
56
|
+
export interface DurableWorkerHostedReservation {
|
|
57
|
+
executionSessionId: string;
|
|
58
|
+
claim: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
export interface DurableWorkerObservation {
|
|
61
|
+
observedState: Record<string, unknown>;
|
|
62
|
+
observationMethod: "TARGET_API" | "TARGET_UI" | "TARGET_AUDIT_LOG" | "WEBHOOK" | "DATABASE_QUERY" | "THIRD_PARTY_CONFIRMATION";
|
|
63
|
+
observationSource: string;
|
|
64
|
+
evidenceReferences?: string[];
|
|
65
|
+
confidence?: number;
|
|
66
|
+
}
|
|
67
|
+
export interface DurableActionCheckpoint {
|
|
68
|
+
schemaVersion: "witnora.durable_action_checkpoint.v0.1";
|
|
69
|
+
actionId: string;
|
|
70
|
+
phase: DurableActionPhase;
|
|
71
|
+
proposal: DurableWorkerProposal;
|
|
72
|
+
proposalSha256: string;
|
|
73
|
+
grant?: DurableWorkerGrant;
|
|
74
|
+
execution?: DurableWorkerExecutionResult;
|
|
75
|
+
observation?: DurableWorkerObservation;
|
|
76
|
+
receiptId?: string;
|
|
77
|
+
executionClaimId?: string;
|
|
78
|
+
hostedReservation?: DurableWorkerHostedReservation;
|
|
79
|
+
limitation?: string;
|
|
80
|
+
updatedAt: string;
|
|
81
|
+
}
|
|
82
|
+
export interface ActionCheckpointStore {
|
|
83
|
+
load(actionId: string): Promise<DurableActionCheckpoint | undefined>;
|
|
84
|
+
save(checkpoint: DurableActionCheckpoint): Promise<void>;
|
|
85
|
+
list(): Promise<DurableActionCheckpoint[]>;
|
|
86
|
+
claimExecution(actionId: string, ownerId: string, claimedAt: string): Promise<{
|
|
87
|
+
acquired: boolean;
|
|
88
|
+
claimId: string;
|
|
89
|
+
}>;
|
|
90
|
+
}
|
|
91
|
+
export declare class FileActionCheckpointStore implements ActionCheckpointStore {
|
|
92
|
+
private readonly directory;
|
|
93
|
+
constructor(directory: string);
|
|
94
|
+
load(actionId: string): Promise<DurableActionCheckpoint | undefined>;
|
|
95
|
+
save(checkpoint: DurableActionCheckpoint): Promise<void>;
|
|
96
|
+
list(): Promise<DurableActionCheckpoint[]>;
|
|
97
|
+
claimExecution(actionId: string, ownerId: string, claimedAt: string): Promise<{
|
|
98
|
+
acquired: boolean;
|
|
99
|
+
claimId: string;
|
|
100
|
+
}>;
|
|
101
|
+
private path;
|
|
102
|
+
private claimPath;
|
|
103
|
+
}
|
|
104
|
+
export interface DurableApprovedActionWorkerOptions {
|
|
105
|
+
config: {
|
|
106
|
+
adapterId: string;
|
|
107
|
+
adapterVersion: string;
|
|
108
|
+
probeId: string;
|
|
109
|
+
probeCredentialHandle: string;
|
|
110
|
+
runtimeIdentityId: string;
|
|
111
|
+
grantTtlSeconds?: number;
|
|
112
|
+
pollIntervalMs?: number;
|
|
113
|
+
};
|
|
114
|
+
store: ActionCheckpointStore;
|
|
115
|
+
hosted: {
|
|
116
|
+
getAction(actionId: string): Promise<DurableWorkerAction>;
|
|
117
|
+
issueExecutionGrant(actionId: string, input: Record<string, unknown>, idempotencyKey: string): Promise<DurableWorkerGrant>;
|
|
118
|
+
verifyAction(actionId: string, input: Record<string, unknown>, idempotencyKey: string): Promise<{
|
|
119
|
+
status: string;
|
|
120
|
+
verificationSuccess?: boolean;
|
|
121
|
+
}>;
|
|
122
|
+
listActionReceipts(actionId: string): Promise<Array<{
|
|
123
|
+
id: string;
|
|
124
|
+
receipt?: {
|
|
125
|
+
signatureSet?: unknown[];
|
|
126
|
+
};
|
|
127
|
+
}>>;
|
|
128
|
+
claimExecutionGrant(executionGrantId: string, claim: Record<string, unknown>, idempotencyKey: string): Promise<{
|
|
129
|
+
acquired: boolean;
|
|
130
|
+
}>;
|
|
131
|
+
};
|
|
132
|
+
runtime: {
|
|
133
|
+
reconcileReadOnly: true;
|
|
134
|
+
prepareClaim(input: {
|
|
135
|
+
action: DurableWorkerAction;
|
|
136
|
+
proposal: DurableWorkerProposal;
|
|
137
|
+
grant: DurableWorkerGrant;
|
|
138
|
+
}): Promise<DurableWorkerHostedReservation>;
|
|
139
|
+
execute(input: {
|
|
140
|
+
action: DurableWorkerAction;
|
|
141
|
+
proposal: DurableWorkerProposal;
|
|
142
|
+
grant: DurableWorkerGrant;
|
|
143
|
+
hostedReservation: DurableWorkerHostedReservation;
|
|
144
|
+
}): Promise<DurableWorkerExecutionResult>;
|
|
145
|
+
reconcile(input: {
|
|
146
|
+
action: DurableWorkerAction;
|
|
147
|
+
proposal: DurableWorkerProposal;
|
|
148
|
+
grant: DurableWorkerGrant;
|
|
149
|
+
}): Promise<DurableWorkerExecutionResult | undefined>;
|
|
150
|
+
};
|
|
151
|
+
probe: {
|
|
152
|
+
id: string;
|
|
153
|
+
credentialHandle: string;
|
|
154
|
+
readOnly: true;
|
|
155
|
+
observe(input: {
|
|
156
|
+
action: DurableWorkerAction;
|
|
157
|
+
proposal: DurableWorkerProposal;
|
|
158
|
+
grant: DurableWorkerGrant;
|
|
159
|
+
execution: DurableWorkerExecutionResult;
|
|
160
|
+
}): Promise<DurableWorkerObservation>;
|
|
161
|
+
};
|
|
162
|
+
now?: () => Date;
|
|
163
|
+
}
|
|
164
|
+
export interface DurableActionWorkerStatus {
|
|
165
|
+
schemaVersion: "witnora.durable_action_worker_status.v0.1";
|
|
166
|
+
ready: boolean;
|
|
167
|
+
trackedActionCount: number;
|
|
168
|
+
pendingActionCount: number;
|
|
169
|
+
unknownResultCount: number;
|
|
170
|
+
lastHeartbeatAt: string;
|
|
171
|
+
lastError?: string;
|
|
172
|
+
}
|
|
173
|
+
export declare class DurableApprovedActionWorker {
|
|
174
|
+
private readonly options;
|
|
175
|
+
private readonly now;
|
|
176
|
+
private readonly chains;
|
|
177
|
+
private timer?;
|
|
178
|
+
private lastHeartbeatAt;
|
|
179
|
+
private lastError?;
|
|
180
|
+
private readonly workerId;
|
|
181
|
+
constructor(options: DurableApprovedActionWorkerOptions);
|
|
182
|
+
track(input: {
|
|
183
|
+
actionId: string;
|
|
184
|
+
proposal: DurableWorkerProposal;
|
|
185
|
+
}): Promise<DurableActionCheckpoint>;
|
|
186
|
+
tick(actionId: string): Promise<DurableActionCheckpoint>;
|
|
187
|
+
start(): void;
|
|
188
|
+
stop(): void;
|
|
189
|
+
status(): Promise<DurableActionWorkerStatus>;
|
|
190
|
+
private tickOnce;
|
|
191
|
+
private persist;
|
|
192
|
+
}
|
|
193
|
+
export declare function runtimeAdapterVersionSatisfies(version: string, constraint: string): boolean;
|
|
194
|
+
//# sourceMappingURL=durable-action-worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durable-action-worker.d.ts","sourceRoot":"","sources":["../../../../agentcert-sdk/src/durable-action-worker.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GACT,kBAAkB,GAClB,QAAQ,GACR,SAAS,GACT,SAAS,GACT,cAAc,GACd,mBAAmB,GACnB,gBAAgB,GAChB,UAAU,GACV,QAAQ,GACR,WAAW,CAAC;AAEhB,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,eAAe,EAAE;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,wBAAwB,EAAE,MAAM,CAAC;QACjC,cAAc,EAAE,MAAM,EAAE,CAAC;QACzB,gBAAgB,EAAE,MAAM,CAAC;QACzB,eAAe,EAAE,MAAM,CAAC;QACxB,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC5C,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC1C,YAAY,EAAE,MAAM,CAAC;QACrB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC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