@llm-dev-ops/agentics-cli 1.0.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 +1 -0
- package/dist/adapters/base-adapter.d.ts +73 -0
- package/dist/adapters/base-adapter.d.ts.map +1 -0
- package/dist/adapters/base-adapter.js +311 -0
- package/dist/adapters/base-adapter.js.map +1 -0
- package/dist/adapters/index.d.ts +8 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +7 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/audit/audit-trail.d.ts +68 -0
- package/dist/audit/audit-trail.d.ts.map +1 -0
- package/dist/audit/audit-trail.js +172 -0
- package/dist/audit/audit-trail.js.map +1 -0
- package/dist/cli/index.d.ts +15 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +265 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/commands/deploy.d.ts +23 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +97 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/diligence.d.ts +23 -0
- package/dist/commands/diligence.d.ts.map +1 -0
- package/dist/commands/diligence.js +97 -0
- package/dist/commands/diligence.js.map +1 -0
- package/dist/commands/export.d.ts +23 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +99 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/index.d.ts +20 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +13 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/inspect.d.ts +25 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +101 -0
- package/dist/commands/inspect.js.map +1 -0
- package/dist/commands/plan.d.ts +23 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +114 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/quantify.d.ts +26 -0
- package/dist/commands/quantify.d.ts.map +1 -0
- package/dist/commands/quantify.js +102 -0
- package/dist/commands/quantify.js.map +1 -0
- package/dist/commands/simulate.d.ts +23 -0
- package/dist/commands/simulate.d.ts.map +1 -0
- package/dist/commands/simulate.js +97 -0
- package/dist/commands/simulate.js.map +1 -0
- package/dist/config/endpoints.d.ts +16 -0
- package/dist/config/endpoints.d.ts.map +1 -0
- package/dist/config/endpoints.js +73 -0
- package/dist/config/endpoints.js.map +1 -0
- package/dist/errors/index.d.ts +120 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +281 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/modules/artifact-handoff.d.ts +57 -0
- package/dist/modules/artifact-handoff.d.ts.map +1 -0
- package/dist/modules/artifact-handoff.js +85 -0
- package/dist/modules/artifact-handoff.js.map +1 -0
- package/dist/modules/command-parser.d.ts +28 -0
- package/dist/modules/command-parser.d.ts.map +1 -0
- package/dist/modules/command-parser.js +176 -0
- package/dist/modules/command-parser.js.map +1 -0
- package/dist/modules/index.d.ts +14 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +10 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/orchestration-engine.d.ts +43 -0
- package/dist/modules/orchestration-engine.d.ts.map +1 -0
- package/dist/modules/orchestration-engine.js +159 -0
- package/dist/modules/orchestration-engine.js.map +1 -0
- package/dist/modules/output-renderer.d.ts +51 -0
- package/dist/modules/output-renderer.d.ts.map +1 -0
- package/dist/modules/output-renderer.js +193 -0
- package/dist/modules/output-renderer.js.map +1 -0
- package/dist/types/index.d.ts +223 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +33 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact Handoff Module (Module D)
|
|
3
|
+
*
|
|
4
|
+
* SPARC Architecture Reference: §2.5
|
|
5
|
+
*
|
|
6
|
+
* PURPOSE: Pass artifacts between services without mutation
|
|
7
|
+
*
|
|
8
|
+
* DEPENDENCIES: None (pure data passthrough)
|
|
9
|
+
*
|
|
10
|
+
* FORBIDDEN:
|
|
11
|
+
* - Artifact Validation (NO schema checking)
|
|
12
|
+
* - Artifact Transformation (NO field mapping)
|
|
13
|
+
* - Artifact Storage (NO caching or persistence)
|
|
14
|
+
* - Content Interpretation (NO parsing of artifact data)
|
|
15
|
+
*/
|
|
16
|
+
import type { BaseReference, PlanReference, SimulationReference, IntentReference, ExportReference, DiligencePackageReference } from '../types/index.js';
|
|
17
|
+
export interface IArtifactHandoff {
|
|
18
|
+
/**
|
|
19
|
+
* Pass artifact from upstream response to downstream request
|
|
20
|
+
* PASSTHROUGH ONLY - no validation or transformation
|
|
21
|
+
*/
|
|
22
|
+
passthrough<T extends BaseReference>(artifact: T): T;
|
|
23
|
+
/**
|
|
24
|
+
* Extract reference from raw response body
|
|
25
|
+
* PASSTHROUGH ONLY - no validation
|
|
26
|
+
*/
|
|
27
|
+
extractReference(body: unknown): BaseReference | null;
|
|
28
|
+
/**
|
|
29
|
+
* Build downstream request payload from reference
|
|
30
|
+
* PASSTHROUGH ONLY - no transformation
|
|
31
|
+
*/
|
|
32
|
+
buildPayload(ref: BaseReference, additionalParams?: Record<string, unknown>): unknown;
|
|
33
|
+
}
|
|
34
|
+
export declare class ArtifactHandoff implements IArtifactHandoff {
|
|
35
|
+
/**
|
|
36
|
+
* Pass artifact through unchanged
|
|
37
|
+
* SPARC: Artifacts are never modified by CLI
|
|
38
|
+
*/
|
|
39
|
+
passthrough<T extends BaseReference>(artifact: T): T;
|
|
40
|
+
/**
|
|
41
|
+
* Extract reference from response body
|
|
42
|
+
* SPARC: No validation, just structural extraction
|
|
43
|
+
*/
|
|
44
|
+
extractReference(body: unknown): BaseReference | null;
|
|
45
|
+
/**
|
|
46
|
+
* Build payload for downstream service
|
|
47
|
+
* SPARC: Reference passed verbatim, additional params merged
|
|
48
|
+
*/
|
|
49
|
+
buildPayload(ref: BaseReference, additionalParams?: Record<string, unknown>): unknown;
|
|
50
|
+
}
|
|
51
|
+
export declare function isPlanReference(ref: BaseReference): ref is PlanReference;
|
|
52
|
+
export declare function isSimulationReference(ref: BaseReference): ref is SimulationReference;
|
|
53
|
+
export declare function isIntentReference(ref: BaseReference): ref is IntentReference;
|
|
54
|
+
export declare function isExportReference(ref: BaseReference): ref is ExportReference;
|
|
55
|
+
export declare function isDiligencePackageReference(ref: BaseReference): ref is DiligencePackageReference;
|
|
56
|
+
export declare function createArtifactHandoff(): IArtifactHandoff;
|
|
57
|
+
//# sourceMappingURL=artifact-handoff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-handoff.d.ts","sourceRoot":"","sources":["../../src/modules/artifact-handoff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,yBAAyB,EAE1B,MAAM,mBAAmB,CAAC;AAM3B,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,WAAW,CAAC,CAAC,SAAS,aAAa,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IAErD;;;OAGG;IACH,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAAC;IAEtD;;;OAGG;IACH,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;CACvF;AAMD,qBAAa,eAAgB,YAAW,gBAAgB;IACtD;;;OAGG;IACH,WAAW,CAAC,CAAC,SAAS,aAAa,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC;IAKpD;;;OAGG;IACH,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI;IAsBrD;;;OAGG;IACH,YAAY,CAAC,GAAG,EAAE,aAAa,EAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO;CAMtF;AAMD,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,GAAG,GAAG,IAAI,aAAa,CAExE;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,aAAa,GAAG,GAAG,IAAI,mBAAmB,CAEpF;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,GAAG,IAAI,eAAe,CAE5E;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,GAAG,IAAI,eAAe,CAE5E;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,aAAa,GAAG,GAAG,IAAI,yBAAyB,CAEhG;AAMD,wBAAgB,qBAAqB,IAAI,gBAAgB,CAExD"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact Handoff Module (Module D)
|
|
3
|
+
*
|
|
4
|
+
* SPARC Architecture Reference: §2.5
|
|
5
|
+
*
|
|
6
|
+
* PURPOSE: Pass artifacts between services without mutation
|
|
7
|
+
*
|
|
8
|
+
* DEPENDENCIES: None (pure data passthrough)
|
|
9
|
+
*
|
|
10
|
+
* FORBIDDEN:
|
|
11
|
+
* - Artifact Validation (NO schema checking)
|
|
12
|
+
* - Artifact Transformation (NO field mapping)
|
|
13
|
+
* - Artifact Storage (NO caching or persistence)
|
|
14
|
+
* - Content Interpretation (NO parsing of artifact data)
|
|
15
|
+
*/
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// Artifact Handoff Implementation
|
|
18
|
+
// ============================================================================
|
|
19
|
+
export class ArtifactHandoff {
|
|
20
|
+
/**
|
|
21
|
+
* Pass artifact through unchanged
|
|
22
|
+
* SPARC: Artifacts are never modified by CLI
|
|
23
|
+
*/
|
|
24
|
+
passthrough(artifact) {
|
|
25
|
+
// Return artifact unchanged - pure passthrough
|
|
26
|
+
return artifact;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Extract reference from response body
|
|
30
|
+
* SPARC: No validation, just structural extraction
|
|
31
|
+
*/
|
|
32
|
+
extractReference(body) {
|
|
33
|
+
if (!body || typeof body !== 'object') {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const obj = body;
|
|
37
|
+
// Check for required reference fields
|
|
38
|
+
if (!('id' in obj) || !('type' in obj) || !('repository' in obj)) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
// Return as BaseReference - no type validation
|
|
42
|
+
return {
|
|
43
|
+
id: String(obj['id']),
|
|
44
|
+
type: obj['type'],
|
|
45
|
+
repository: String(obj['repository']),
|
|
46
|
+
created_at: 'created_at' in obj ? String(obj['created_at']) : new Date().toISOString(),
|
|
47
|
+
checksum: 'checksum' in obj ? String(obj['checksum']) : '',
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Build payload for downstream service
|
|
52
|
+
* SPARC: Reference passed verbatim, additional params merged
|
|
53
|
+
*/
|
|
54
|
+
buildPayload(ref, additionalParams) {
|
|
55
|
+
return {
|
|
56
|
+
ref,
|
|
57
|
+
...additionalParams,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// Reference Type Guards (for type narrowing only, no validation)
|
|
63
|
+
// ============================================================================
|
|
64
|
+
export function isPlanReference(ref) {
|
|
65
|
+
return ref.type === 'PlanReference';
|
|
66
|
+
}
|
|
67
|
+
export function isSimulationReference(ref) {
|
|
68
|
+
return ref.type === 'SimulationReference';
|
|
69
|
+
}
|
|
70
|
+
export function isIntentReference(ref) {
|
|
71
|
+
return ref.type === 'IntentReference';
|
|
72
|
+
}
|
|
73
|
+
export function isExportReference(ref) {
|
|
74
|
+
return ref.type === 'ExportReference';
|
|
75
|
+
}
|
|
76
|
+
export function isDiligencePackageReference(ref) {
|
|
77
|
+
return ref.type === 'DiligencePackageReference';
|
|
78
|
+
}
|
|
79
|
+
// ============================================================================
|
|
80
|
+
// Factory Function
|
|
81
|
+
// ============================================================================
|
|
82
|
+
export function createArtifactHandoff() {
|
|
83
|
+
return new ArtifactHandoff();
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=artifact-handoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-handoff.js","sourceRoot":"","sources":["../../src/modules/artifact-handoff.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAoCH,+EAA+E;AAC/E,kCAAkC;AAClC,+EAA+E;AAE/E,MAAM,OAAO,eAAe;IAC1B;;;OAGG;IACH,WAAW,CAA0B,QAAW;QAC9C,+CAA+C;QAC/C,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACH,gBAAgB,CAAC,IAAa;QAC5B,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,GAAG,GAAG,IAA+B,CAAC;QAE5C,sCAAsC;QACtC,IAAI,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,YAAY,IAAI,GAAG,CAAC,EAAE,CAAC;YACjE,OAAO,IAAI,CAAC;QACd,CAAC;QAED,+CAA+C;QAC/C,OAAO;YACL,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACrB,IAAI,EAAE,GAAG,CAAC,MAAM,CAAkB;YAClC,UAAU,EAAE,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACrC,UAAU,EAAE,YAAY,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACtF,QAAQ,EAAE,UAAU,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;SAC3D,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,GAAkB,EAAE,gBAA0C;QACzE,OAAO;YACL,GAAG;YACH,GAAG,gBAAgB;SACpB,CAAC;IACJ,CAAC;CACF;AAED,+EAA+E;AAC/E,iEAAiE;AACjE,+EAA+E;AAE/E,MAAM,UAAU,eAAe,CAAC,GAAkB;IAChD,OAAO,GAAG,CAAC,IAAI,KAAK,eAAe,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,GAAkB;IACtD,OAAO,GAAG,CAAC,IAAI,KAAK,qBAAqB,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAkB;IAClD,OAAO,GAAG,CAAC,IAAI,KAAK,iBAAiB,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAkB;IAClD,OAAO,GAAG,CAAC,IAAI,KAAK,iBAAiB,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,GAAkB;IAC5D,OAAO,GAAG,CAAC,IAAI,KAAK,2BAA2B,CAAC;AAClD,CAAC;AAED,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,MAAM,UAAU,qBAAqB;IACnC,OAAO,IAAI,eAAe,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Parsing Module (Module A)
|
|
3
|
+
*
|
|
4
|
+
* SPARC Architecture Reference: §2.2
|
|
5
|
+
*
|
|
6
|
+
* PURPOSE: Parse CLI arguments and flags into structured objects
|
|
7
|
+
*
|
|
8
|
+
* DEPENDENCIES: Standard Library ONLY
|
|
9
|
+
*
|
|
10
|
+
* FORBIDDEN:
|
|
11
|
+
* - Business Logic (NO interpretation of command semantics)
|
|
12
|
+
* - Validation beyond format (NO validation of business rules)
|
|
13
|
+
* - Downstream-specific logic
|
|
14
|
+
*/
|
|
15
|
+
import type { CommandObject } from '../types/index.js';
|
|
16
|
+
export interface ICommandParser {
|
|
17
|
+
parse(args: string[]): CommandObject;
|
|
18
|
+
}
|
|
19
|
+
export declare const SUPPORTED_COMMANDS: readonly ["plan", "simulate", "inspect", "quantify", "deploy", "export", "diligence", "audit", "version", "help"];
|
|
20
|
+
export type SupportedCommand = (typeof SUPPORTED_COMMANDS)[number];
|
|
21
|
+
export declare class CommandParser implements ICommandParser {
|
|
22
|
+
parse(args: string[]): CommandObject;
|
|
23
|
+
private isKnownBooleanFlag;
|
|
24
|
+
private expandShortFlag;
|
|
25
|
+
private commandHasSubcommands;
|
|
26
|
+
}
|
|
27
|
+
export declare function createCommandParser(): ICommandParser;
|
|
28
|
+
//# sourceMappingURL=command-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-parser.d.ts","sourceRoot":"","sources":["../../src/modules/command-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAOvD,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC;CACtC;AAMD,eAAO,MAAM,kBAAkB,mHAWrB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAMnE,qBAAa,aAAc,YAAW,cAAc;IAClD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,aAAa;IA2GpC,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,qBAAqB;CAI9B;AAMD,wBAAgB,mBAAmB,IAAI,cAAc,CAEpD"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Parsing Module (Module A)
|
|
3
|
+
*
|
|
4
|
+
* SPARC Architecture Reference: §2.2
|
|
5
|
+
*
|
|
6
|
+
* PURPOSE: Parse CLI arguments and flags into structured objects
|
|
7
|
+
*
|
|
8
|
+
* DEPENDENCIES: Standard Library ONLY
|
|
9
|
+
*
|
|
10
|
+
* FORBIDDEN:
|
|
11
|
+
* - Business Logic (NO interpretation of command semantics)
|
|
12
|
+
* - Validation beyond format (NO validation of business rules)
|
|
13
|
+
* - Downstream-specific logic
|
|
14
|
+
*/
|
|
15
|
+
import { ValidationError } from '../errors/index.js';
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// Command Definitions
|
|
18
|
+
// ============================================================================
|
|
19
|
+
export const SUPPORTED_COMMANDS = [
|
|
20
|
+
'plan',
|
|
21
|
+
'simulate',
|
|
22
|
+
'inspect',
|
|
23
|
+
'quantify',
|
|
24
|
+
'deploy',
|
|
25
|
+
'export',
|
|
26
|
+
'diligence',
|
|
27
|
+
'audit',
|
|
28
|
+
'version',
|
|
29
|
+
'help',
|
|
30
|
+
];
|
|
31
|
+
// ============================================================================
|
|
32
|
+
// Command Parser Implementation
|
|
33
|
+
// ============================================================================
|
|
34
|
+
export class CommandParser {
|
|
35
|
+
parse(args) {
|
|
36
|
+
const flags = {};
|
|
37
|
+
const options = {};
|
|
38
|
+
const positionalArgs = [];
|
|
39
|
+
let command = '';
|
|
40
|
+
let subcommand;
|
|
41
|
+
let expectingValue = null;
|
|
42
|
+
for (let i = 0; i < args.length; i++) {
|
|
43
|
+
const arg = args[i];
|
|
44
|
+
if (arg === undefined)
|
|
45
|
+
continue;
|
|
46
|
+
// Handle expected value from previous flag
|
|
47
|
+
if (expectingValue !== null) {
|
|
48
|
+
options[expectingValue] = arg;
|
|
49
|
+
expectingValue = null;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
// Handle long options (--option=value or --option value)
|
|
53
|
+
if (arg.startsWith('--')) {
|
|
54
|
+
const withoutDashes = arg.slice(2);
|
|
55
|
+
const equalsIndex = withoutDashes.indexOf('=');
|
|
56
|
+
if (equalsIndex !== -1) {
|
|
57
|
+
const key = withoutDashes.slice(0, equalsIndex);
|
|
58
|
+
const value = withoutDashes.slice(equalsIndex + 1);
|
|
59
|
+
if (value === '' || value === 'true') {
|
|
60
|
+
flags[key] = true;
|
|
61
|
+
}
|
|
62
|
+
else if (value === 'false') {
|
|
63
|
+
flags[key] = false;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
options[key] = value;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// Boolean flag or option expecting value
|
|
71
|
+
const key = withoutDashes;
|
|
72
|
+
const nextArg = args[i + 1];
|
|
73
|
+
if (nextArg && !nextArg.startsWith('-')) {
|
|
74
|
+
// Could be a value for this option
|
|
75
|
+
if (this.isKnownBooleanFlag(key)) {
|
|
76
|
+
flags[key] = true;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
expectingValue = key;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
flags[key] = true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
// Handle short options (-o value or -v)
|
|
89
|
+
if (arg.startsWith('-') && arg.length > 1) {
|
|
90
|
+
const key = arg.slice(1);
|
|
91
|
+
if (key.length === 1) {
|
|
92
|
+
// Single character flag
|
|
93
|
+
const expanded = this.expandShortFlag(key);
|
|
94
|
+
const nextArg = args[i + 1];
|
|
95
|
+
if (nextArg && !nextArg.startsWith('-') && !this.isKnownBooleanFlag(expanded)) {
|
|
96
|
+
expectingValue = expanded;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
flags[expanded] = true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
// Multiple short flags (-abc = -a -b -c)
|
|
104
|
+
for (const char of key) {
|
|
105
|
+
flags[this.expandShortFlag(char)] = true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
// Positional arguments
|
|
111
|
+
if (!command) {
|
|
112
|
+
command = arg;
|
|
113
|
+
}
|
|
114
|
+
else if (!subcommand && this.commandHasSubcommands(command)) {
|
|
115
|
+
subcommand = arg;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
positionalArgs.push(arg);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Validate we have a command
|
|
122
|
+
if (!command) {
|
|
123
|
+
throw new ValidationError({
|
|
124
|
+
message: 'No command specified',
|
|
125
|
+
field: 'command',
|
|
126
|
+
expected: SUPPORTED_COMMANDS.join(' | '),
|
|
127
|
+
actual: 'none',
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
command,
|
|
132
|
+
subcommand,
|
|
133
|
+
flags,
|
|
134
|
+
options,
|
|
135
|
+
positionalArgs,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
isKnownBooleanFlag(key) {
|
|
139
|
+
const booleanFlags = [
|
|
140
|
+
'verbose', 'v',
|
|
141
|
+
'quiet', 'q',
|
|
142
|
+
'help', 'h',
|
|
143
|
+
'version', 'V',
|
|
144
|
+
'debug',
|
|
145
|
+
'dry-run',
|
|
146
|
+
'force', 'f',
|
|
147
|
+
'pretty',
|
|
148
|
+
'colorize',
|
|
149
|
+
];
|
|
150
|
+
return booleanFlags.includes(key);
|
|
151
|
+
}
|
|
152
|
+
expandShortFlag(char) {
|
|
153
|
+
const expansions = {
|
|
154
|
+
'v': 'verbose',
|
|
155
|
+
'q': 'quiet',
|
|
156
|
+
'h': 'help',
|
|
157
|
+
'V': 'version',
|
|
158
|
+
'f': 'force',
|
|
159
|
+
'o': 'output',
|
|
160
|
+
't': 'timeout',
|
|
161
|
+
'c': 'config',
|
|
162
|
+
};
|
|
163
|
+
return expansions[char] ?? char;
|
|
164
|
+
}
|
|
165
|
+
commandHasSubcommands(command) {
|
|
166
|
+
const commandsWithSubcommands = ['audit'];
|
|
167
|
+
return commandsWithSubcommands.includes(command);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// ============================================================================
|
|
171
|
+
// Factory Function
|
|
172
|
+
// ============================================================================
|
|
173
|
+
export function createCommandParser() {
|
|
174
|
+
return new CommandParser();
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=command-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-parser.js","sourceRoot":"","sources":["../../src/modules/command-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAUrD,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,MAAM;IACN,UAAU;IACV,SAAS;IACT,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,OAAO;IACP,SAAS;IACT,MAAM;CACE,CAAC;AAIX,+EAA+E;AAC/E,gCAAgC;AAChC,+EAA+E;AAE/E,MAAM,OAAO,aAAa;IACxB,KAAK,CAAC,IAAc;QAClB,MAAM,KAAK,GAA4B,EAAE,CAAC;QAC1C,MAAM,OAAO,GAA2B,EAAE,CAAC;QAC3C,MAAM,cAAc,GAAa,EAAE,CAAC;QAEpC,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,IAAI,UAA8B,CAAC;QACnC,IAAI,cAAc,GAAkB,IAAI,CAAC;QAEzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAEpB,IAAI,GAAG,KAAK,SAAS;gBAAE,SAAS;YAEhC,2CAA2C;YAC3C,IAAI,cAAc,KAAK,IAAI,E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/E,MAAM,UAAU,mBAAmB;IACjC,OAAO,IAAI,aAAa,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module Exports
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all module implementations
|
|
5
|
+
*/
|
|
6
|
+
export { CommandParser, createCommandParser, SUPPORTED_COMMANDS } from './command-parser.js';
|
|
7
|
+
export type { ICommandParser, SupportedCommand } from './command-parser.js';
|
|
8
|
+
export { OrchestrationEngine, createOrchestrationEngine } from './orchestration-engine.js';
|
|
9
|
+
export type { IOrchestrationEngine, OrchestrationStage, StageRequest } from './orchestration-engine.js';
|
|
10
|
+
export { ArtifactHandoff, createArtifactHandoff, isPlanReference, isSimulationReference, isIntentReference, isExportReference, isDiligencePackageReference } from './artifact-handoff.js';
|
|
11
|
+
export type { IArtifactHandoff } from './artifact-handoff.js';
|
|
12
|
+
export { OutputRenderer, createOutputRenderer } from './output-renderer.js';
|
|
13
|
+
export type { IOutputRenderer } from './output-renderer.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC7F,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAC3F,YAAY,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAExG,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,eAAe,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAC1L,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module Exports
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all module implementations
|
|
5
|
+
*/
|
|
6
|
+
export { CommandParser, createCommandParser, SUPPORTED_COMMANDS } from './command-parser.js';
|
|
7
|
+
export { OrchestrationEngine, createOrchestrationEngine } from './orchestration-engine.js';
|
|
8
|
+
export { ArtifactHandoff, createArtifactHandoff, isPlanReference, isSimulationReference, isIntentReference, isExportReference, isDiligencePackageReference } from './artifact-handoff.js';
|
|
9
|
+
export { OutputRenderer, createOutputRenderer } from './output-renderer.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG7F,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAG3F,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,eAAe,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAG1L,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestration Engine Module (Module B)
|
|
3
|
+
*
|
|
4
|
+
* SPARC Architecture Reference: §2.3
|
|
5
|
+
*
|
|
6
|
+
* PURPOSE: Sequence calls to downstream services
|
|
7
|
+
*
|
|
8
|
+
* DEPENDENCIES: Downstream Adapters only
|
|
9
|
+
*
|
|
10
|
+
* FORBIDDEN:
|
|
11
|
+
* - Response Interpretation (NO parsing of downstream responses)
|
|
12
|
+
* - Business Logic (NO conditional branching based on data)
|
|
13
|
+
* - Data Transformation (NO field mapping or conversion)
|
|
14
|
+
* - State Management (NO storage of intermediate results)
|
|
15
|
+
*/
|
|
16
|
+
import type { OrchestrationResult, CommandOptions } from '../types/index.js';
|
|
17
|
+
import type { IDownstreamAdapter } from '../adapters/base-adapter.js';
|
|
18
|
+
export interface IOrchestrationEngine {
|
|
19
|
+
execute(stages: OrchestrationStage[], options: CommandOptions): Promise<OrchestrationResult>;
|
|
20
|
+
}
|
|
21
|
+
export interface OrchestrationStage {
|
|
22
|
+
name: string;
|
|
23
|
+
adapter: IDownstreamAdapter;
|
|
24
|
+
request: StageRequest;
|
|
25
|
+
dependsOn?: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface StageRequest {
|
|
28
|
+
endpoint: string;
|
|
29
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
30
|
+
buildBody: (previousResults: Map<string, unknown>) => unknown;
|
|
31
|
+
}
|
|
32
|
+
export declare class OrchestrationEngine implements IOrchestrationEngine {
|
|
33
|
+
private readonly correlationId;
|
|
34
|
+
constructor(correlationId?: string);
|
|
35
|
+
execute(stages: OrchestrationStage[], options: CommandOptions): Promise<OrchestrationResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Extract artifact reference from response body - PASSTHROUGH only
|
|
38
|
+
* No validation or transformation of the reference
|
|
39
|
+
*/
|
|
40
|
+
private extractArtifact;
|
|
41
|
+
}
|
|
42
|
+
export declare function createOrchestrationEngine(correlationId?: string): IOrchestrationEngine;
|
|
43
|
+
//# sourceMappingURL=orchestration-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestration-engine.d.ts","sourceRoot":"","sources":["../../src/modules/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to downstream services
|
|
7
|
+
*
|
|
8
|
+
* DEPENDENCIES: Downstream Adapters only
|
|
9
|
+
*
|
|
10
|
+
* FORBIDDEN:
|
|
11
|
+
* - Response Interpretation (NO parsing of downstream responses)
|
|
12
|
+
* - Business Logic (NO conditional branching based on data)
|
|
13
|
+
* - Data Transformation (NO field mapping or conversion)
|
|
14
|
+
* - State Management (NO storage of intermediate results)
|
|
15
|
+
*/
|
|
16
|
+
import { CLIError } from '../errors/index.js';
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Orchestration Engine Implementation
|
|
19
|
+
// ============================================================================
|
|
20
|
+
export class OrchestrationEngine {
|
|
21
|
+
correlationId;
|
|
22
|
+
constructor(correlationId) {
|
|
23
|
+
this.correlationId = correlationId ?? crypto.randomUUID();
|
|
24
|
+
}
|
|
25
|
+
async execute(stages, options) {
|
|
26
|
+
const startedAt = new Date().toISOString();
|
|
27
|
+
const startTime = Date.now();
|
|
28
|
+
const stageResults = [];
|
|
29
|
+
const previousResults = new Map();
|
|
30
|
+
const artifacts = [];
|
|
31
|
+
const breakdown = {};
|
|
32
|
+
// Execute stages in dependency order
|
|
33
|
+
const executed = new Set();
|
|
34
|
+
const pending = [...stages];
|
|
35
|
+
while (pending.length > 0) {
|
|
36
|
+
// Find stages ready to execute (all dependencies satisfied)
|
|
37
|
+
const ready = pending.filter(stage => !stage.dependsOn || stage.dependsOn.every(dep => executed.has(dep)));
|
|
38
|
+
if (ready.length === 0 && pending.length > 0) {
|
|
39
|
+
throw new CLIError({
|
|
40
|
+
code: 'ECLI-ORCH-001',
|
|
41
|
+
category: 'INTERNAL_ERROR',
|
|
42
|
+
message: 'Circular dependency detected in orchestration stages',
|
|
43
|
+
module: 'orchestration',
|
|
44
|
+
correlationId: this.correlationId,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
// Execute ready stages sequentially (SPARC: no parallel execution to maintain order)
|
|
48
|
+
for (const stage of ready) {
|
|
49
|
+
const stageStartTime = Date.now();
|
|
50
|
+
try {
|
|
51
|
+
// Build request body from previous results - PASSTHROUGH only
|
|
52
|
+
const body = stage.request.buildBody(previousResults);
|
|
53
|
+
// Invoke downstream adapter
|
|
54
|
+
const response = await stage.adapter.invoke({
|
|
55
|
+
endpoint: stage.request.endpoint,
|
|
56
|
+
method: stage.request.method,
|
|
57
|
+
headers: {},
|
|
58
|
+
body,
|
|
59
|
+
timeout: options.timeout,
|
|
60
|
+
});
|
|
61
|
+
const stageTiming = Date.now() - stageStartTime;
|
|
62
|
+
breakdown[stage.name] = stageTiming;
|
|
63
|
+
// Store raw response for next stages - NO interpretation
|
|
64
|
+
previousResults.set(stage.name, response.body);
|
|
65
|
+
// Extract artifact reference if present - PASSTHROUGH
|
|
66
|
+
const artifact = this.extractArtifact(response.body);
|
|
67
|
+
if (artifact) {
|
|
68
|
+
artifacts.push(artifact);
|
|
69
|
+
}
|
|
70
|
+
stageResults.push({
|
|
71
|
+
name: stage.name,
|
|
72
|
+
status: 'complete',
|
|
73
|
+
response: response.body,
|
|
74
|
+
timing: stageTiming,
|
|
75
|
+
});
|
|
76
|
+
executed.add(stage.name);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
const stageTiming = Date.now() - stageStartTime;
|
|
80
|
+
breakdown[stage.name] = stageTiming;
|
|
81
|
+
stageResults.push({
|
|
82
|
+
name: stage.name,
|
|
83
|
+
status: 'failed',
|
|
84
|
+
response: null,
|
|
85
|
+
error: error instanceof CLIError ? error.toErrorInfo() : {
|
|
86
|
+
code: 'ECLI-ORCH-002',
|
|
87
|
+
category: 'INTERNAL_ERROR',
|
|
88
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
89
|
+
timestamp: new Date().toISOString(),
|
|
90
|
+
module: 'orchestration',
|
|
91
|
+
correlationId: this.correlationId,
|
|
92
|
+
},
|
|
93
|
+
timing: stageTiming,
|
|
94
|
+
});
|
|
95
|
+
// Fail fast - do not continue on error
|
|
96
|
+
const completedAt = new Date().toISOString();
|
|
97
|
+
return {
|
|
98
|
+
stages: stageResults,
|
|
99
|
+
artifacts,
|
|
100
|
+
timing: {
|
|
101
|
+
total: Date.now() - startTime,
|
|
102
|
+
breakdown,
|
|
103
|
+
started_at: startedAt,
|
|
104
|
+
completed_at: completedAt,
|
|
105
|
+
},
|
|
106
|
+
success: false,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
// Remove from pending
|
|
110
|
+
const idx = pending.indexOf(stage);
|
|
111
|
+
if (idx > -1) {
|
|
112
|
+
pending.splice(idx, 1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const completedAt = new Date().toISOString();
|
|
117
|
+
return {
|
|
118
|
+
stages: stageResults,
|
|
119
|
+
artifacts,
|
|
120
|
+
timing: {
|
|
121
|
+
total: Date.now() - startTime,
|
|
122
|
+
breakdown,
|
|
123
|
+
started_at: startedAt,
|
|
124
|
+
completed_at: completedAt,
|
|
125
|
+
},
|
|
126
|
+
success: true,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Extract artifact reference from response body - PASSTHROUGH only
|
|
131
|
+
* No validation or transformation of the reference
|
|
132
|
+
*/
|
|
133
|
+
extractArtifact(body) {
|
|
134
|
+
if (!body || typeof body !== 'object') {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
const obj = body;
|
|
138
|
+
// Check for standard reference fields - PASSTHROUGH
|
|
139
|
+
if ('id' in obj && 'type' in obj) {
|
|
140
|
+
return {
|
|
141
|
+
id: String(obj['id']),
|
|
142
|
+
type: String(obj['type']),
|
|
143
|
+
location: 'location' in obj ? String(obj['location']) : '',
|
|
144
|
+
checksum: 'checksum' in obj ? String(obj['checksum']) : undefined,
|
|
145
|
+
metadata: 'metadata' in obj && typeof obj['metadata'] === 'object'
|
|
146
|
+
? obj['metadata']
|
|
147
|
+
: undefined,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// ============================================================================
|
|
154
|
+
// Factory Function
|
|
155
|
+
// ============================================================================
|
|
156
|
+
export function createOrchestrationEngine(correlationId) {
|
|
157
|
+
return new OrchestrationEngine(correlationId);
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=orchestration-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestration-engine.js","sourceRoot":"","sources":["../../src/modules/orchestration-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAuB9C,+EAA+E;AAC/E,sCAAsC;AACtC,+EAA+E;AAE/E,MAAM,OAAO,mBAAmB;IACb,aAAa,CAAS;IAEvC,YAAY,aAAsB;QAChC,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,OAAO,CACX,MAA4B,EAC5B,OAAuB;QAEvB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC3C,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,YAAY,GAAkB,EAAE,CAAC;QACvC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAmB,CAAC;QACnD,MAAM,SAAS,GAAwB,EAAE,CAAC;QAC1C,MAAM,SAAS,GAA2B,EAAE,CAAC;QAE7C,qCAAqC;QACrC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;QACnC,MAAM,OAAO,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;QAE5B,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,4DAA4D;YAC5D,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACnC,CAAC,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,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