@vorionsys/runtime 0.1.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/dist/common/logger.d.ts +12 -0
- package/dist/common/logger.d.ts.map +1 -0
- package/dist/common/logger.js +23 -0
- package/dist/common/logger.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/intent-pipeline/index.d.ts +65 -0
- package/dist/intent-pipeline/index.d.ts.map +1 -0
- package/dist/intent-pipeline/index.js +244 -0
- package/dist/intent-pipeline/index.js.map +1 -0
- package/dist/intent-pipeline/types.d.ts +78 -0
- package/dist/intent-pipeline/types.d.ts.map +1 -0
- package/dist/intent-pipeline/types.js +17 -0
- package/dist/intent-pipeline/types.js.map +1 -0
- package/dist/proof-committer/index.d.ts +86 -0
- package/dist/proof-committer/index.d.ts.map +1 -0
- package/dist/proof-committer/index.js +252 -0
- package/dist/proof-committer/index.js.map +1 -0
- package/dist/proof-committer/types.d.ts +107 -0
- package/dist/proof-committer/types.d.ts.map +1 -0
- package/dist/proof-committer/types.js +58 -0
- package/dist/proof-committer/types.js.map +1 -0
- package/dist/stores/index.d.ts +10 -0
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/index.js +10 -0
- package/dist/stores/index.js.map +1 -0
- package/dist/stores/sqlite-proof-store.d.ts +61 -0
- package/dist/stores/sqlite-proof-store.d.ts.map +1 -0
- package/dist/stores/sqlite-proof-store.js +239 -0
- package/dist/stores/sqlite-proof-store.js.map +1 -0
- package/dist/stores/sqlite-trust-store.d.ts +124 -0
- package/dist/stores/sqlite-trust-store.d.ts.map +1 -0
- package/dist/stores/sqlite-trust-store.js +297 -0
- package/dist/stores/sqlite-trust-store.js.map +1 -0
- package/dist/trust-facade/index.d.ts +72 -0
- package/dist/trust-facade/index.d.ts.map +1 -0
- package/dist/trust-facade/index.js +410 -0
- package/dist/trust-facade/index.js.map +1 -0
- package/dist/trust-facade/types.d.ts +211 -0
- package/dist/trust-facade/types.d.ts.map +1 -0
- package/dist/trust-facade/types.js +45 -0
- package/dist/trust-facade/types.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger utility for runtime package
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import pino from 'pino';
|
|
7
|
+
export interface LoggerOptions {
|
|
8
|
+
component: string;
|
|
9
|
+
level?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function createLogger(options: LoggerOptions): pino.Logger;
|
|
12
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/common/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC,MAAM,CAgBhE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger utility for runtime package
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import pino from 'pino';
|
|
7
|
+
export function createLogger(options) {
|
|
8
|
+
return pino({
|
|
9
|
+
name: `@vorionsys/runtime:${options.component}`,
|
|
10
|
+
level: options.level ?? process.env.LOG_LEVEL ?? 'info',
|
|
11
|
+
transport: process.env.NODE_ENV !== 'production'
|
|
12
|
+
? {
|
|
13
|
+
target: 'pino-pretty',
|
|
14
|
+
options: {
|
|
15
|
+
colorize: true,
|
|
16
|
+
translateTime: 'SYS:standard',
|
|
17
|
+
ignore: 'pid,hostname',
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
: undefined,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/common/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAOxB,MAAM,UAAU,YAAY,CAAC,OAAsB;IACjD,OAAO,IAAI,CAAC;QACV,IAAI,EAAE,sBAAsB,OAAO,CAAC,SAAS,EAAE;QAC/C,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM;QACvD,SAAS,EACP,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;YACnC,CAAC,CAAC;gBACE,MAAM,EAAE,aAAa;gBACrB,OAAO,EAAE;oBACP,QAAQ,EAAE,IAAI;oBACd,aAAa,EAAE,cAAc;oBAC7B,MAAM,EAAE,cAAc;iBACvB;aACF;YACH,CAAC,CAAC,SAAS;KAChB,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vorionsys/runtime - Vorion Runtime
|
|
3
|
+
*
|
|
4
|
+
* Orchestration layer for AI agent governance.
|
|
5
|
+
* Combines Gate Trust (the door) and Dynamic Trust (the handshake)
|
|
6
|
+
* into a unified, fast decision system.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
export { TrustFacade, createTrustFacade, type TrustGate, type TrustFacadeConfig, type AgentCredentials, type AdmissionResult, type Action, type AuthorizationResult, type FullCheckResult, type TrustSignal, type TrustTier, type DecisionTier, type Constraints, type Refinement, type ObservationTier, DEFAULT_TRUST_FACADE_CONFIG, TRUST_TIER_NAMES, TRUST_TIER_RANGES, } from './trust-facade/index.js';
|
|
11
|
+
export { ProofCommitter, createProofCommitter, InMemoryProofStore, type ProofEvent, type ProofEventType, type ProofCommitment, type ProofBatch, type ProofCommitterConfig, type ProofStore, DEFAULT_PROOF_COMMITTER_CONFIG, } from './proof-committer/index.js';
|
|
12
|
+
export { IntentPipeline, createIntentPipeline, type Intent, type IntentResult, type PipelineContext, type IntentPipelineConfig, type ExecutionHandler, DEFAULT_INTENT_PIPELINE_CONFIG, } from './intent-pipeline/index.js';
|
|
13
|
+
export { SQLiteProofStore, createSQLiteProofStore, type SQLiteProofStoreConfig, } from './stores/sqlite-proof-store.js';
|
|
14
|
+
export { SQLiteTrustStore, createSQLiteTrustStore, type SQLiteTrustStoreConfig, type TrustStore, type AgentTrustRecord, type TrustSignalRecord, } from './stores/sqlite-trust-store.js';
|
|
15
|
+
export { createLogger, type LoggerOptions } from './common/logger.js';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,WAAW,EACX,iBAAiB,EAEjB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EAEpB,2BAA2B,EAC3B,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAElB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,oBAAoB,EACzB,KAAK,UAAU,EAEf,8BAA8B,GAC/B,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,cAAc,EACd,oBAAoB,EAEpB,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EAErB,8BAA8B,GAC/B,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,KAAK,sBAAsB,GAC5B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,GACvB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vorionsys/runtime - Vorion Runtime
|
|
3
|
+
*
|
|
4
|
+
* Orchestration layer for AI agent governance.
|
|
5
|
+
* Combines Gate Trust (the door) and Dynamic Trust (the handshake)
|
|
6
|
+
* into a unified, fast decision system.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
// TrustFacade - The unified trust interface
|
|
11
|
+
export { TrustFacade, createTrustFacade,
|
|
12
|
+
// Constants
|
|
13
|
+
DEFAULT_TRUST_FACADE_CONFIG, TRUST_TIER_NAMES, TRUST_TIER_RANGES, } from './trust-facade/index.js';
|
|
14
|
+
// ProofCommitter - Zero-latency proof system
|
|
15
|
+
export { ProofCommitter, createProofCommitter, InMemoryProofStore,
|
|
16
|
+
// Constants
|
|
17
|
+
DEFAULT_PROOF_COMMITTER_CONFIG, } from './proof-committer/index.js';
|
|
18
|
+
// IntentPipeline - Orchestrated intent processing
|
|
19
|
+
export { IntentPipeline, createIntentPipeline,
|
|
20
|
+
// Constants
|
|
21
|
+
DEFAULT_INTENT_PIPELINE_CONFIG, } from './intent-pipeline/index.js';
|
|
22
|
+
// Persistent stores
|
|
23
|
+
export { SQLiteProofStore, createSQLiteProofStore, } from './stores/sqlite-proof-store.js';
|
|
24
|
+
export { SQLiteTrustStore, createSQLiteTrustStore, } from './stores/sqlite-trust-store.js';
|
|
25
|
+
// Re-export logger for consumers
|
|
26
|
+
export { createLogger } from './common/logger.js';
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,4CAA4C;AAC5C,OAAO,EACL,WAAW,EACX,iBAAiB;AAejB,YAAY;AACZ,2BAA2B,EAC3B,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAEjC,6CAA6C;AAC7C,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,kBAAkB;AAQlB,YAAY;AACZ,8BAA8B,GAC/B,MAAM,4BAA4B,CAAC;AAEpC,kDAAkD;AAClD,OAAO,EACL,cAAc,EACd,oBAAoB;AAOpB,YAAY;AACZ,8BAA8B,GAC/B,MAAM,4BAA4B,CAAC;AAEpC,oBAAoB;AACpB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,GAEvB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,gBAAgB,EAChB,sBAAsB,GAKvB,MAAM,gCAAgC,CAAC;AAExC,iCAAiC;AACjC,OAAO,EAAE,YAAY,EAAsB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IntentPipeline - Agent Intent Orchestration
|
|
3
|
+
*
|
|
4
|
+
* Wires TrustFacade + ProofCommitter into a unified flow:
|
|
5
|
+
* Intent → Gate Check → Authorization → Execution → Proof
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { TrustFacade, type AgentCredentials, type Action } from '../trust-facade/index.js';
|
|
10
|
+
import { ProofCommitter } from '../proof-committer/index.js';
|
|
11
|
+
import type { IntentResult, IntentPipelineConfig, ExecutionHandler } from './types.js';
|
|
12
|
+
export * from './types.js';
|
|
13
|
+
/**
|
|
14
|
+
* IntentPipeline - Orchestrates the full agent intent lifecycle
|
|
15
|
+
*/
|
|
16
|
+
export declare class IntentPipeline {
|
|
17
|
+
private config;
|
|
18
|
+
private trustFacade;
|
|
19
|
+
private proofCommitter;
|
|
20
|
+
private executionHandlers;
|
|
21
|
+
private totalIntents;
|
|
22
|
+
private allowedIntents;
|
|
23
|
+
private deniedIntents;
|
|
24
|
+
private totalProcessingTimeMs;
|
|
25
|
+
constructor(trustFacade: TrustFacade, proofCommitter: ProofCommitter, config?: Partial<IntentPipelineConfig>);
|
|
26
|
+
/**
|
|
27
|
+
* Register an execution handler for an action type
|
|
28
|
+
*/
|
|
29
|
+
registerHandler(actionType: string, handler: ExecutionHandler): void;
|
|
30
|
+
/**
|
|
31
|
+
* Submit an intent for processing
|
|
32
|
+
*/
|
|
33
|
+
submit(agentCredentials: AgentCredentials, action: Action, metadata?: Record<string, unknown>): Promise<IntentResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Quick authorization check (no execution)
|
|
36
|
+
*/
|
|
37
|
+
check(agentCredentials: AgentCredentials, action: Action): Promise<{
|
|
38
|
+
allowed: boolean;
|
|
39
|
+
tier: string;
|
|
40
|
+
reason: string;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Get pipeline metrics
|
|
44
|
+
*/
|
|
45
|
+
getMetrics(): {
|
|
46
|
+
totalIntents: number;
|
|
47
|
+
allowedIntents: number;
|
|
48
|
+
deniedIntents: number;
|
|
49
|
+
avgProcessingTimeMs: number;
|
|
50
|
+
allowRate: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Flush all pending proofs
|
|
54
|
+
*/
|
|
55
|
+
flushProofs(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Stop the pipeline (cleanup)
|
|
58
|
+
*/
|
|
59
|
+
stop(): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a new IntentPipeline instance
|
|
63
|
+
*/
|
|
64
|
+
export declare function createIntentPipeline(trustFacade: TrustFacade, proofCommitter: ProofCommitter, config?: Partial<IntentPipelineConfig>): IntentPipeline;
|
|
65
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/intent-pipeline/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,MAAM,EAAoB,MAAM,0BAA0B,CAAC;AAC7G,OAAO,EAAE,cAAc,EAAmB,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAEV,YAAY,EAEZ,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAGpB,cAAc,YAAY,CAAC;AAI3B;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,iBAAiB,CAA4C;IAGrE,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,qBAAqB,CAAK;gBAGhC,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,MAAM,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC;IASxC;;OAEG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAKpE;;OAEG;IACG,MAAM,CACV,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,OAAO,CAAC,YAAY,CAAC;IA6KxB;;OAEG;IACG,KAAK,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QACvE,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IAkBF;;OAEG;IACH,UAAU,IAAI;QACZ,YAAY,EAAE,MAAM,CAAC;QACrB,cAAc,EAAE,MAAM,CAAC;QACvB,aAAa,EAAE,MAAM,CAAC;QACtB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,SAAS,EAAE,MAAM,CAAC;KACnB;IAUD;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAI5B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,MAAM,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,GACrC,cAAc,CAEhB"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IntentPipeline - Agent Intent Orchestration
|
|
3
|
+
*
|
|
4
|
+
* Wires TrustFacade + ProofCommitter into a unified flow:
|
|
5
|
+
* Intent → Gate Check → Authorization → Execution → Proof
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import * as crypto from 'node:crypto';
|
|
10
|
+
import { createLogger } from '../common/logger.js';
|
|
11
|
+
import { DEFAULT_INTENT_PIPELINE_CONFIG } from './types.js';
|
|
12
|
+
export * from './types.js';
|
|
13
|
+
const logger = createLogger({ component: 'intent-pipeline' });
|
|
14
|
+
/**
|
|
15
|
+
* IntentPipeline - Orchestrates the full agent intent lifecycle
|
|
16
|
+
*/
|
|
17
|
+
export class IntentPipeline {
|
|
18
|
+
config;
|
|
19
|
+
trustFacade;
|
|
20
|
+
proofCommitter;
|
|
21
|
+
executionHandlers = new Map();
|
|
22
|
+
// Metrics
|
|
23
|
+
totalIntents = 0;
|
|
24
|
+
allowedIntents = 0;
|
|
25
|
+
deniedIntents = 0;
|
|
26
|
+
totalProcessingTimeMs = 0;
|
|
27
|
+
constructor(trustFacade, proofCommitter, config) {
|
|
28
|
+
this.trustFacade = trustFacade;
|
|
29
|
+
this.proofCommitter = proofCommitter;
|
|
30
|
+
this.config = { ...DEFAULT_INTENT_PIPELINE_CONFIG, ...config };
|
|
31
|
+
logger.info({ config: this.config }, 'IntentPipeline initialized');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Register an execution handler for an action type
|
|
35
|
+
*/
|
|
36
|
+
registerHandler(actionType, handler) {
|
|
37
|
+
this.executionHandlers.set(actionType, handler);
|
|
38
|
+
logger.debug({ actionType }, 'Handler registered');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Submit an intent for processing
|
|
42
|
+
*/
|
|
43
|
+
async submit(agentCredentials, action, metadata) {
|
|
44
|
+
const startTime = performance.now();
|
|
45
|
+
const correlationId = crypto.randomUUID();
|
|
46
|
+
const intent = {
|
|
47
|
+
id: crypto.randomUUID(),
|
|
48
|
+
agentId: agentCredentials.agentId,
|
|
49
|
+
action,
|
|
50
|
+
metadata,
|
|
51
|
+
submittedAt: Date.now(),
|
|
52
|
+
};
|
|
53
|
+
const context = {
|
|
54
|
+
correlationId,
|
|
55
|
+
credentials: agentCredentials,
|
|
56
|
+
startTime,
|
|
57
|
+
};
|
|
58
|
+
this.totalIntents++;
|
|
59
|
+
// Record intent submission
|
|
60
|
+
const submitCommitmentId = this.proofCommitter.commit({
|
|
61
|
+
type: 'intent_submitted',
|
|
62
|
+
entityId: intent.agentId,
|
|
63
|
+
payload: { intentId: intent.id, action },
|
|
64
|
+
timestamp: Date.now(),
|
|
65
|
+
correlationId,
|
|
66
|
+
});
|
|
67
|
+
if (this.config.verboseLogging) {
|
|
68
|
+
logger.debug({ intentId: intent.id, correlationId }, 'Intent submitted');
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
// Full trust check (gate + authorization)
|
|
72
|
+
const checkResult = await this.trustFacade.fullCheck(agentCredentials, action);
|
|
73
|
+
// Determine if allowed (must be admitted and authorized)
|
|
74
|
+
const admitted = checkResult.admission.admitted;
|
|
75
|
+
const authorized = checkResult.authorization?.allowed ?? false;
|
|
76
|
+
const allowed = admitted && authorized;
|
|
77
|
+
const tier = checkResult.authorization?.tier ?? 'RED';
|
|
78
|
+
// Record decision
|
|
79
|
+
this.proofCommitter.commit({
|
|
80
|
+
type: 'decision_made',
|
|
81
|
+
entityId: intent.agentId,
|
|
82
|
+
payload: {
|
|
83
|
+
intentId: intent.id,
|
|
84
|
+
allowed,
|
|
85
|
+
tier,
|
|
86
|
+
reason: allowed
|
|
87
|
+
? 'Trust check passed'
|
|
88
|
+
: admitted
|
|
89
|
+
? checkResult.authorization?.reason ?? 'Authorization denied'
|
|
90
|
+
: checkResult.admission.reason ?? 'Admission denied',
|
|
91
|
+
},
|
|
92
|
+
timestamp: Date.now(),
|
|
93
|
+
correlationId,
|
|
94
|
+
});
|
|
95
|
+
if (!allowed) {
|
|
96
|
+
this.deniedIntents++;
|
|
97
|
+
const processingTimeMs = performance.now() - startTime;
|
|
98
|
+
this.totalProcessingTimeMs += processingTimeMs;
|
|
99
|
+
const reason = admitted
|
|
100
|
+
? checkResult.authorization?.reason ?? 'Authorization denied'
|
|
101
|
+
: `Gate denied: ${checkResult.admission.reason ?? 'Admission denied'}`;
|
|
102
|
+
return {
|
|
103
|
+
intentId: intent.id,
|
|
104
|
+
allowed: false,
|
|
105
|
+
tier,
|
|
106
|
+
reason,
|
|
107
|
+
commitmentId: submitCommitmentId,
|
|
108
|
+
processingTimeMs,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// Execute if handler exists
|
|
112
|
+
const handler = this.executionHandlers.get(action.type);
|
|
113
|
+
if (handler) {
|
|
114
|
+
// Record execution start
|
|
115
|
+
this.proofCommitter.commit({
|
|
116
|
+
type: 'execution_started',
|
|
117
|
+
entityId: intent.agentId,
|
|
118
|
+
payload: { intentId: intent.id, actionType: action.type },
|
|
119
|
+
timestamp: Date.now(),
|
|
120
|
+
correlationId,
|
|
121
|
+
});
|
|
122
|
+
const execResult = await handler(intent, context);
|
|
123
|
+
// Record execution completion
|
|
124
|
+
this.proofCommitter.commit({
|
|
125
|
+
type: 'execution_completed',
|
|
126
|
+
entityId: intent.agentId,
|
|
127
|
+
payload: {
|
|
128
|
+
intentId: intent.id,
|
|
129
|
+
success: execResult.success,
|
|
130
|
+
error: execResult.error,
|
|
131
|
+
},
|
|
132
|
+
timestamp: Date.now(),
|
|
133
|
+
correlationId,
|
|
134
|
+
});
|
|
135
|
+
// Auto-record trust signal on execution
|
|
136
|
+
if (this.config.autoRecordSignals) {
|
|
137
|
+
const signal = {
|
|
138
|
+
agentId: intent.agentId,
|
|
139
|
+
type: execResult.success ? 'success' : 'failure',
|
|
140
|
+
source: 'execution',
|
|
141
|
+
weight: execResult.success ? 0.1 : 0.5, // Asymmetric: failures weighted more (weight is 0-1)
|
|
142
|
+
context: { intentId: intent.id, actionType: action.type },
|
|
143
|
+
};
|
|
144
|
+
await this.trustFacade.recordSignal(signal);
|
|
145
|
+
}
|
|
146
|
+
if (!execResult.success) {
|
|
147
|
+
this.deniedIntents++;
|
|
148
|
+
const processingTimeMs = performance.now() - startTime;
|
|
149
|
+
this.totalProcessingTimeMs += processingTimeMs;
|
|
150
|
+
return {
|
|
151
|
+
intentId: intent.id,
|
|
152
|
+
allowed: true, // Was allowed, but execution failed
|
|
153
|
+
tier,
|
|
154
|
+
reason: `Execution failed: ${execResult.error}`,
|
|
155
|
+
commitmentId: submitCommitmentId,
|
|
156
|
+
processingTimeMs,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
this.allowedIntents++;
|
|
161
|
+
const processingTimeMs = performance.now() - startTime;
|
|
162
|
+
this.totalProcessingTimeMs += processingTimeMs;
|
|
163
|
+
// Convert constraints object to string array for result
|
|
164
|
+
const constraintStrings = checkResult.authorization?.constraints
|
|
165
|
+
? Object.entries(checkResult.authorization.constraints)
|
|
166
|
+
.filter(([_, v]) => v !== undefined)
|
|
167
|
+
.map(([k, v]) => `${k}:${JSON.stringify(v)}`)
|
|
168
|
+
: undefined;
|
|
169
|
+
return {
|
|
170
|
+
intentId: intent.id,
|
|
171
|
+
allowed: true,
|
|
172
|
+
tier,
|
|
173
|
+
reason: 'Intent processed successfully',
|
|
174
|
+
commitmentId: submitCommitmentId,
|
|
175
|
+
constraints: constraintStrings,
|
|
176
|
+
processingTimeMs,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
const processingTimeMs = performance.now() - startTime;
|
|
181
|
+
this.totalProcessingTimeMs += processingTimeMs;
|
|
182
|
+
this.deniedIntents++;
|
|
183
|
+
logger.error({ error, intentId: intent.id }, 'Intent processing failed');
|
|
184
|
+
return {
|
|
185
|
+
intentId: intent.id,
|
|
186
|
+
allowed: false,
|
|
187
|
+
tier: 'RED',
|
|
188
|
+
reason: `Processing error: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
189
|
+
commitmentId: submitCommitmentId,
|
|
190
|
+
processingTimeMs,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Quick authorization check (no execution)
|
|
196
|
+
*/
|
|
197
|
+
async check(agentCredentials, action) {
|
|
198
|
+
const result = await this.trustFacade.fullCheck(agentCredentials, action);
|
|
199
|
+
const admitted = result.admission.admitted;
|
|
200
|
+
const authorized = result.authorization?.allowed ?? false;
|
|
201
|
+
const allowed = admitted && authorized;
|
|
202
|
+
return {
|
|
203
|
+
allowed,
|
|
204
|
+
tier: result.authorization?.tier ?? 'RED',
|
|
205
|
+
reason: allowed
|
|
206
|
+
? 'Allowed'
|
|
207
|
+
: admitted
|
|
208
|
+
? result.authorization?.reason ?? 'Authorization denied'
|
|
209
|
+
: result.admission.reason ?? 'Admission denied',
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Get pipeline metrics
|
|
214
|
+
*/
|
|
215
|
+
getMetrics() {
|
|
216
|
+
return {
|
|
217
|
+
totalIntents: this.totalIntents,
|
|
218
|
+
allowedIntents: this.allowedIntents,
|
|
219
|
+
deniedIntents: this.deniedIntents,
|
|
220
|
+
avgProcessingTimeMs: this.totalIntents > 0 ? this.totalProcessingTimeMs / this.totalIntents : 0,
|
|
221
|
+
allowRate: this.totalIntents > 0 ? this.allowedIntents / this.totalIntents : 0,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Flush all pending proofs
|
|
226
|
+
*/
|
|
227
|
+
async flushProofs() {
|
|
228
|
+
await this.proofCommitter.flush();
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Stop the pipeline (cleanup)
|
|
232
|
+
*/
|
|
233
|
+
async stop() {
|
|
234
|
+
await this.proofCommitter.stop();
|
|
235
|
+
logger.info(this.getMetrics(), 'IntentPipeline stopped');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Create a new IntentPipeline instance
|
|
240
|
+
*/
|
|
241
|
+
export function createIntentPipeline(trustFacade, proofCommitter, config) {
|
|
242
|
+
return new IntentPipeline(trustFacade, proofCommitter, config);
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/intent-pipeline/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAUnD,OAAO,EAAE,8BAA8B,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,CAAC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC/F,SAAS,EAAE,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;SAC/E,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;QACjC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,wBAAwB,CAAC,CAAC;IAC3D,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,WAAwB,EACxB,cAA8B,EAC9B,MAAsC;IAEtC,OAAO,IAAI,cAAc,CAAC,WAAW,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IntentPipeline Types
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates the full agent intent lifecycle:
|
|
5
|
+
* Intent → Gate Check → Authorization → Execution → Proof
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { AgentCredentials, Action, DecisionTier } from '../trust-facade/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* An intent submitted by an agent
|
|
12
|
+
*/
|
|
13
|
+
export interface Intent {
|
|
14
|
+
/** Unique intent ID */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Agent submitting the intent */
|
|
17
|
+
agentId: string;
|
|
18
|
+
/** The action the agent wants to perform */
|
|
19
|
+
action: Action;
|
|
20
|
+
/** Optional metadata */
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
/** Submission timestamp */
|
|
23
|
+
submittedAt: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Result of processing an intent through the pipeline
|
|
27
|
+
*/
|
|
28
|
+
export interface IntentResult {
|
|
29
|
+
/** The intent ID */
|
|
30
|
+
intentId: string;
|
|
31
|
+
/** Whether the intent was allowed */
|
|
32
|
+
allowed: boolean;
|
|
33
|
+
/** Decision tier (GREEN/YELLOW/RED) */
|
|
34
|
+
tier: DecisionTier;
|
|
35
|
+
/** Reason for decision */
|
|
36
|
+
reason: string;
|
|
37
|
+
/** Proof commitment ID */
|
|
38
|
+
commitmentId: string;
|
|
39
|
+
/** Constraints applied (if any) */
|
|
40
|
+
constraints?: string[];
|
|
41
|
+
/** Processing time in ms */
|
|
42
|
+
processingTimeMs: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Pipeline execution context
|
|
46
|
+
*/
|
|
47
|
+
export interface PipelineContext {
|
|
48
|
+
/** Correlation ID for tracing */
|
|
49
|
+
correlationId: string;
|
|
50
|
+
/** Agent credentials (cached or fresh) */
|
|
51
|
+
credentials: AgentCredentials;
|
|
52
|
+
/** Start time for metrics */
|
|
53
|
+
startTime: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Pipeline configuration
|
|
57
|
+
*/
|
|
58
|
+
export interface IntentPipelineConfig {
|
|
59
|
+
/** Enable detailed logging */
|
|
60
|
+
verboseLogging: boolean;
|
|
61
|
+
/** Maximum processing time before timeout (ms) */
|
|
62
|
+
timeoutMs: number;
|
|
63
|
+
/** Auto-record signals on execution */
|
|
64
|
+
autoRecordSignals: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Default pipeline configuration
|
|
68
|
+
*/
|
|
69
|
+
export declare const DEFAULT_INTENT_PIPELINE_CONFIG: IntentPipelineConfig;
|
|
70
|
+
/**
|
|
71
|
+
* Execution handler type
|
|
72
|
+
*/
|
|
73
|
+
export type ExecutionHandler = (intent: Intent, context: PipelineContext) => Promise<{
|
|
74
|
+
success: boolean;
|
|
75
|
+
result?: unknown;
|
|
76
|
+
error?: string;
|
|
77
|
+
}>;
|
|
78
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/intent-pipeline/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAe,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGpG;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,uBAAuB;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oBAAoB;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,uCAAuC;IACvC,IAAI,EAAE,YAAY,CAAC;IACnB,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,4BAA4B;IAC5B,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,WAAW,EAAE,gBAAgB,CAAC;IAC9B,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,8BAA8B;IAC9B,cAAc,EAAE,OAAO,CAAC;IACxB,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,eAAO,MAAM,8BAA8B,EAAE,oBAI5C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,eAAe,KACrB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IntentPipeline Types
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates the full agent intent lifecycle:
|
|
5
|
+
* Intent → Gate Check → Authorization → Execution → Proof
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Default pipeline configuration
|
|
11
|
+
*/
|
|
12
|
+
export const DEFAULT_INTENT_PIPELINE_CONFIG = {
|
|
13
|
+
verboseLogging: false,
|
|
14
|
+
timeoutMs: 5000,
|
|
15
|
+
autoRecordSignals: true,
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/intent-pipeline/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiEH;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAyB;IAClE,cAAc,EAAE,KAAK;IACrB,SAAS,EAAE,IAAI;IACf,iBAAiB,EAAE,IAAI;CACxB,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProofCommitter - Zero-Latency Proof System
|
|
3
|
+
*
|
|
4
|
+
* Synchronous hash commitment (<1ms) with async batch processing.
|
|
5
|
+
* Uses Merkle trees for batch integrity and optional Ed25519 signing.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { ProofEvent, ProofCommitment, ProofCommitterConfig, ProofStore } from './types.js';
|
|
10
|
+
export * from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* ProofCommitter - Fast synchronous commitment with async persistence
|
|
13
|
+
*/
|
|
14
|
+
export declare class ProofCommitter {
|
|
15
|
+
private config;
|
|
16
|
+
private buffer;
|
|
17
|
+
private store;
|
|
18
|
+
private flushTimer;
|
|
19
|
+
private privateKey;
|
|
20
|
+
private isFlushing;
|
|
21
|
+
private pendingFlush;
|
|
22
|
+
private totalCommitments;
|
|
23
|
+
private totalBatches;
|
|
24
|
+
private totalFlushTimeMs;
|
|
25
|
+
constructor(config?: Partial<ProofCommitterConfig>, store?: ProofStore);
|
|
26
|
+
/**
|
|
27
|
+
* Commit an event - MUST complete in <1ms
|
|
28
|
+
*
|
|
29
|
+
* This is the HOT PATH - synchronous, fast
|
|
30
|
+
*/
|
|
31
|
+
commit(event: ProofEvent): string;
|
|
32
|
+
/**
|
|
33
|
+
* Fast hash - SHA-256, no signing, ~0.1ms
|
|
34
|
+
*/
|
|
35
|
+
private fastHash;
|
|
36
|
+
/**
|
|
37
|
+
* Flush buffer to proof store (COLD PATH - async)
|
|
38
|
+
*/
|
|
39
|
+
flush(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Build Merkle root from hashes
|
|
42
|
+
*/
|
|
43
|
+
private buildMerkleRoot;
|
|
44
|
+
/**
|
|
45
|
+
* Sign data with Ed25519 (if enabled)
|
|
46
|
+
*/
|
|
47
|
+
private sign;
|
|
48
|
+
/**
|
|
49
|
+
* Start periodic flush timer
|
|
50
|
+
*/
|
|
51
|
+
private startFlushTimer;
|
|
52
|
+
/**
|
|
53
|
+
* Stop the committer (flush remaining and cleanup)
|
|
54
|
+
*/
|
|
55
|
+
stop(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Get current buffer size
|
|
58
|
+
*/
|
|
59
|
+
getBufferSize(): number;
|
|
60
|
+
/**
|
|
61
|
+
* Get metrics
|
|
62
|
+
*/
|
|
63
|
+
getMetrics(): {
|
|
64
|
+
totalCommitments: number;
|
|
65
|
+
totalBatches: number;
|
|
66
|
+
avgFlushTimeMs: number;
|
|
67
|
+
bufferSize: number;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Get commitment by ID (from store)
|
|
71
|
+
*/
|
|
72
|
+
getCommitment(commitmentId: string): Promise<ProofCommitment | null>;
|
|
73
|
+
/**
|
|
74
|
+
* Get all commitments for an entity
|
|
75
|
+
*/
|
|
76
|
+
getCommitmentsForEntity(entityId: string): Promise<ProofCommitment[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Verify a commitment's hash
|
|
79
|
+
*/
|
|
80
|
+
verifyCommitment(commitment: ProofCommitment): boolean;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Create a new ProofCommitter instance
|
|
84
|
+
*/
|
|
85
|
+
export declare function createProofCommitter(config?: Partial<ProofCommitterConfig>, store?: ProofStore): ProofCommitter;
|
|
86
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/proof-committer/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EAEf,oBAAoB,EACpB,UAAU,EACX,MAAM,YAAY,CAAC;AAGpB,cAAc,YAAY,CAAC;AAI3B;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,UAAU,CAA+B;IACjD,OA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