@llm-dev-ops/agentics-cli 1.4.6 → 1.4.8

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.
Files changed (160) hide show
  1. package/dist/adapters/base-adapter.d.ts +117 -0
  2. package/dist/adapters/base-adapter.d.ts.map +1 -1
  3. package/dist/adapters/base-adapter.js +143 -0
  4. package/dist/adapters/base-adapter.js.map +1 -1
  5. package/dist/auth/identity-resolver.d.ts +21 -0
  6. package/dist/auth/identity-resolver.d.ts.map +1 -0
  7. package/dist/auth/identity-resolver.js +68 -0
  8. package/dist/auth/identity-resolver.js.map +1 -0
  9. package/dist/auth/index.d.ts +2 -0
  10. package/dist/auth/index.d.ts.map +1 -1
  11. package/dist/auth/index.js +2 -0
  12. package/dist/auth/index.js.map +1 -1
  13. package/dist/auth/role-permissions.d.ts +12 -0
  14. package/dist/auth/role-permissions.d.ts.map +1 -0
  15. package/dist/auth/role-permissions.js +43 -0
  16. package/dist/auth/role-permissions.js.map +1 -0
  17. package/dist/cli/index.js +139 -134
  18. package/dist/cli/index.js.map +1 -1
  19. package/dist/commands/erp.d.ts.map +1 -1
  20. package/dist/commands/erp.js +62 -0
  21. package/dist/commands/erp.js.map +1 -1
  22. package/dist/commands/login.d.ts.map +1 -1
  23. package/dist/commands/login.js +25 -0
  24. package/dist/commands/login.js.map +1 -1
  25. package/dist/commands/logout.d.ts.map +1 -1
  26. package/dist/commands/logout.js +4 -1
  27. package/dist/commands/logout.js.map +1 -1
  28. package/dist/commands/plan.d.ts.map +1 -1
  29. package/dist/commands/plan.js +6 -5
  30. package/dist/commands/plan.js.map +1 -1
  31. package/dist/commands/simulate.d.ts.map +1 -1
  32. package/dist/commands/simulate.js +57 -1
  33. package/dist/commands/simulate.js.map +1 -1
  34. package/dist/commands/whoami.d.ts +4 -0
  35. package/dist/commands/whoami.d.ts.map +1 -1
  36. package/dist/commands/whoami.js +22 -5
  37. package/dist/commands/whoami.js.map +1 -1
  38. package/dist/contracts/adr-002-operational-enforcement.d.ts +684 -0
  39. package/dist/contracts/adr-002-operational-enforcement.d.ts.map +1 -0
  40. package/dist/contracts/adr-002-operational-enforcement.js +671 -0
  41. package/dist/contracts/adr-002-operational-enforcement.js.map +1 -0
  42. package/dist/contracts/adr-003-governance-architecture.d.ts +766 -0
  43. package/dist/contracts/adr-003-governance-architecture.d.ts.map +1 -0
  44. package/dist/contracts/adr-003-governance-architecture.js +773 -0
  45. package/dist/contracts/adr-003-governance-architecture.js.map +1 -0
  46. package/dist/contracts/adr-004-enterprise-integration-memory.d.ts +1150 -0
  47. package/dist/contracts/adr-004-enterprise-integration-memory.d.ts.map +1 -0
  48. package/dist/contracts/adr-004-enterprise-integration-memory.js +1158 -0
  49. package/dist/contracts/adr-004-enterprise-integration-memory.js.map +1 -0
  50. package/dist/contracts/adr-005-system-coherence-drift-self-governance.d.ts +1393 -0
  51. package/dist/contracts/adr-005-system-coherence-drift-self-governance.d.ts.map +1 -0
  52. package/dist/contracts/adr-005-system-coherence-drift-self-governance.js +1371 -0
  53. package/dist/contracts/adr-005-system-coherence-drift-self-governance.js.map +1 -0
  54. package/dist/contracts/adr-006-claude-code-synthesis-runner.d.ts +196 -0
  55. package/dist/contracts/adr-006-claude-code-synthesis-runner.d.ts.map +1 -0
  56. package/dist/contracts/adr-006-claude-code-synthesis-runner.js +177 -0
  57. package/dist/contracts/adr-006-claude-code-synthesis-runner.js.map +1 -0
  58. package/dist/contracts/adr-007-subcommand-synthesis-router.d.ts +273 -0
  59. package/dist/contracts/adr-007-subcommand-synthesis-router.d.ts.map +1 -0
  60. package/dist/contracts/adr-007-subcommand-synthesis-router.js +226 -0
  61. package/dist/contracts/adr-007-subcommand-synthesis-router.js.map +1 -0
  62. package/dist/contracts/adr-008-synthesis-artifact-persistence.d.ts +323 -0
  63. package/dist/contracts/adr-008-synthesis-artifact-persistence.d.ts.map +1 -0
  64. package/dist/contracts/adr-008-synthesis-artifact-persistence.js +184 -0
  65. package/dist/contracts/adr-008-synthesis-artifact-persistence.js.map +1 -0
  66. package/dist/contracts/adr-command-semantics.d.ts +150 -0
  67. package/dist/contracts/adr-command-semantics.d.ts.map +1 -0
  68. package/dist/contracts/adr-command-semantics.js +984 -0
  69. package/dist/contracts/adr-command-semantics.js.map +1 -0
  70. package/dist/contracts/index.d.ts +5 -0
  71. package/dist/contracts/index.d.ts.map +1 -1
  72. package/dist/contracts/index.js +16 -0
  73. package/dist/contracts/index.js.map +1 -1
  74. package/dist/enterprise/index.d.ts +16 -0
  75. package/dist/enterprise/index.d.ts.map +1 -0
  76. package/dist/enterprise/index.js +17 -0
  77. package/dist/enterprise/index.js.map +1 -0
  78. package/dist/enterprise/integration-registry.d.ts +73 -0
  79. package/dist/enterprise/integration-registry.d.ts.map +1 -0
  80. package/dist/enterprise/integration-registry.js +252 -0
  81. package/dist/enterprise/integration-registry.js.map +1 -0
  82. package/dist/enterprise/lineage.d.ts +73 -0
  83. package/dist/enterprise/lineage.d.ts.map +1 -0
  84. package/dist/enterprise/lineage.js +218 -0
  85. package/dist/enterprise/lineage.js.map +1 -0
  86. package/dist/gates/argument-guard.d.ts +39 -0
  87. package/dist/gates/argument-guard.d.ts.map +1 -0
  88. package/dist/gates/argument-guard.js +180 -0
  89. package/dist/gates/argument-guard.js.map +1 -0
  90. package/dist/gates/index.d.ts +5 -0
  91. package/dist/gates/index.d.ts.map +1 -1
  92. package/dist/gates/index.js +7 -0
  93. package/dist/gates/index.js.map +1 -1
  94. package/dist/gates/lineage-gate.d.ts +55 -0
  95. package/dist/gates/lineage-gate.d.ts.map +1 -0
  96. package/dist/gates/lineage-gate.js +127 -0
  97. package/dist/gates/lineage-gate.js.map +1 -0
  98. package/dist/mcp/mcp-server.d.ts +35 -0
  99. package/dist/mcp/mcp-server.d.ts.map +1 -0
  100. package/dist/mcp/mcp-server.js +692 -0
  101. package/dist/mcp/mcp-server.js.map +1 -0
  102. package/dist/modules/help-renderer.d.ts +25 -0
  103. package/dist/modules/help-renderer.d.ts.map +1 -0
  104. package/dist/modules/help-renderer.js +163 -0
  105. package/dist/modules/help-renderer.js.map +1 -0
  106. package/dist/modules/index.d.ts +1 -0
  107. package/dist/modules/index.d.ts.map +1 -1
  108. package/dist/modules/index.js +1 -0
  109. package/dist/modules/index.js.map +1 -1
  110. package/dist/runtime/claude-code-runner.d.ts +93 -0
  111. package/dist/runtime/claude-code-runner.d.ts.map +1 -0
  112. package/dist/runtime/claude-code-runner.js +588 -0
  113. package/dist/runtime/claude-code-runner.js.map +1 -0
  114. package/dist/runtime/index.d.ts +5 -0
  115. package/dist/runtime/index.d.ts.map +1 -0
  116. package/dist/runtime/index.js +5 -0
  117. package/dist/runtime/index.js.map +1 -0
  118. package/dist/server/index.d.ts +2 -0
  119. package/dist/server/index.d.ts.map +1 -1
  120. package/dist/server/index.js +16 -1
  121. package/dist/server/index.js.map +1 -1
  122. package/dist/server/routes/identity.d.ts +9 -0
  123. package/dist/server/routes/identity.d.ts.map +1 -0
  124. package/dist/server/routes/identity.js +100 -0
  125. package/dist/server/routes/identity.js.map +1 -0
  126. package/dist/server/routes/index.d.ts +2 -0
  127. package/dist/server/routes/index.d.ts.map +1 -1
  128. package/dist/server/routes/index.js +2 -0
  129. package/dist/server/routes/index.js.map +1 -1
  130. package/dist/server/routes/lineage.d.ts +15 -0
  131. package/dist/server/routes/lineage.d.ts.map +1 -0
  132. package/dist/server/routes/lineage.js +128 -0
  133. package/dist/server/routes/lineage.js.map +1 -0
  134. package/dist/synthesis/artifact-writer.d.ts +62 -0
  135. package/dist/synthesis/artifact-writer.d.ts.map +1 -0
  136. package/dist/synthesis/artifact-writer.js +603 -0
  137. package/dist/synthesis/artifact-writer.js.map +1 -0
  138. package/dist/synthesis/index.d.ts +7 -0
  139. package/dist/synthesis/index.d.ts.map +1 -0
  140. package/dist/synthesis/index.js +7 -0
  141. package/dist/synthesis/index.js.map +1 -0
  142. package/dist/synthesis/prompts/index.d.ts +50 -0
  143. package/dist/synthesis/prompts/index.d.ts.map +1 -0
  144. package/dist/synthesis/prompts/index.js +502 -0
  145. package/dist/synthesis/prompts/index.js.map +1 -0
  146. package/dist/synthesis/router.d.ts +70 -0
  147. package/dist/synthesis/router.d.ts.map +1 -0
  148. package/dist/synthesis/router.js +346 -0
  149. package/dist/synthesis/router.js.map +1 -0
  150. package/dist/types/index.d.ts +132 -0
  151. package/dist/types/index.d.ts.map +1 -1
  152. package/dist/utils/identity-store.d.ts +31 -0
  153. package/dist/utils/identity-store.d.ts.map +1 -0
  154. package/dist/utils/identity-store.js +97 -0
  155. package/dist/utils/identity-store.js.map +1 -0
  156. package/dist/utils/index.d.ts +2 -0
  157. package/dist/utils/index.d.ts.map +1 -1
  158. package/dist/utils/index.js +1 -0
  159. package/dist/utils/index.js.map +1 -1
  160. package/package.json +1 -1
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Lineage Tracking Module (ADR-004, Domain 2)
3
+ *
4
+ * PURPOSE: Track parent-child relationships between simulation artifacts.
5
+ * Ruvector stores lineage as first-class data, not inferred from timestamps.
6
+ *
7
+ * INVARIANTS ENFORCED:
8
+ * - Invariant 1: Every simulation has a memory footprint
9
+ * - Invariant 2: Every integration/ERP mapping derives from a simulation
10
+ * - Invariant 3: No integration proposal without traceability
11
+ * - Invariant 7: CLI is only path for artifact creation
12
+ *
13
+ * FORBIDDEN:
14
+ * - Creating lineage without a simulation parent
15
+ * - Querying live enterprise systems
16
+ * - Storing credentials or tokens
17
+ * - Business logic (lineage is structural, not behavioral)
18
+ */
19
+ import * as crypto from 'node:crypto';
20
+ // ============================================================================
21
+ // Lineage Record Construction
22
+ // ============================================================================
23
+ /**
24
+ * Create a lineage record for an artifact.
25
+ * Every artifact persisted in Ruvector must have a corresponding lineage record.
26
+ *
27
+ * @param artifactId - The artifact this lineage entry describes
28
+ * @param category - The type of artifact
29
+ * @param simulationId - The parent simulation (Invariant 2)
30
+ * @param decisionContext - The natural language input that seeded synthesis
31
+ * @param attribution - Identity attribution (user_id, org_id)
32
+ * @param planId - The plan this artifact belongs to (optional)
33
+ */
34
+ export function createLineageRecord(artifactId, category, simulationId, decisionContext, attribution, planId) {
35
+ return {
36
+ id: `lin-${crypto.randomUUID()}`,
37
+ artifact_id: artifactId,
38
+ artifact_category: category,
39
+ simulation_id: simulationId,
40
+ plan_id: planId,
41
+ decision_context: decisionContext,
42
+ attribution,
43
+ governance: {
44
+ gate_pipeline_version: '1.0.0',
45
+ synthesis_classification: classifySynthesis(category),
46
+ },
47
+ created_at: new Date().toISOString(),
48
+ };
49
+ }
50
+ /**
51
+ * Determine the synthesis classification for an artifact category.
52
+ * Mirrors ADR-001 classifications.
53
+ */
54
+ function classifySynthesis(category) {
55
+ switch (category) {
56
+ case 'simulation':
57
+ case 'plan':
58
+ case 'integration_mapping':
59
+ case 'erp_proposal':
60
+ case 'cost_projection':
61
+ case 'risk_assessment':
62
+ return 'SYNTHESIS_REQUIRED';
63
+ case 'deployment':
64
+ case 'decision':
65
+ return 'COMMITMENT_GRADE';
66
+ default:
67
+ return 'SYNTHESIS_REQUIRED';
68
+ }
69
+ }
70
+ // ============================================================================
71
+ // Simulation Memory Record Construction
72
+ // ============================================================================
73
+ /**
74
+ * Create a simulation memory record for Ruvector persistence (Invariant 1).
75
+ * Called when a simulation is initiated through the CLI.
76
+ */
77
+ export function createSimulationMemoryRecord(id, intent, attribution) {
78
+ const now = new Date().toISOString();
79
+ return {
80
+ id,
81
+ type: 'simulation',
82
+ intent,
83
+ status: 'created',
84
+ attribution,
85
+ artifact_ids: [],
86
+ created_at: now,
87
+ updated_at: now,
88
+ checksum: computeChecksum({ id, intent, created_at: now }),
89
+ };
90
+ }
91
+ /**
92
+ * Update a simulation memory record with completion data.
93
+ */
94
+ export function completeSimulationMemoryRecord(record, result, artifactIds) {
95
+ const now = new Date().toISOString();
96
+ return {
97
+ ...record,
98
+ status: 'completed',
99
+ result,
100
+ artifact_ids: [...record.artifact_ids, ...artifactIds],
101
+ updated_at: now,
102
+ checksum: computeChecksum({ ...record, result, updated_at: now }),
103
+ };
104
+ }
105
+ /**
106
+ * Mark a simulation memory record as failed.
107
+ */
108
+ export function failSimulationMemoryRecord(record, error) {
109
+ const now = new Date().toISOString();
110
+ return {
111
+ ...record,
112
+ status: 'failed',
113
+ result: { error },
114
+ updated_at: now,
115
+ checksum: computeChecksum({ ...record, error, updated_at: now }),
116
+ };
117
+ }
118
+ // ============================================================================
119
+ // Integration Proposal Construction
120
+ // ============================================================================
121
+ /**
122
+ * Create an integration proposal derived from a simulation (Invariant 2).
123
+ * Proposals describe what would change, not what has changed.
124
+ */
125
+ export function createIntegrationProposal(integrationName, proposedChanges, risks, dependencies, simulationId, attribution, planId) {
126
+ return {
127
+ id: `intprop-${crypto.randomUUID()}`,
128
+ type: 'integration_proposal',
129
+ integration_name: integrationName,
130
+ proposed_changes: proposedChanges,
131
+ risks,
132
+ dependencies,
133
+ simulation_id: simulationId,
134
+ plan_id: planId,
135
+ attribution,
136
+ created_at: new Date().toISOString(),
137
+ };
138
+ }
139
+ // ============================================================================
140
+ // ERP Surface Mapping Construction
141
+ // ============================================================================
142
+ /**
143
+ * Create an ERP Surface mapping derived from a simulation (Invariant 6).
144
+ * ERP Surface never initiates — it receives proposed implementations.
145
+ */
146
+ export function createErpSurfaceMapping(erpType, entityType, proposedImplementation, simulationId, integrationProposalIds, attribution) {
147
+ return {
148
+ id: `erpmap-${crypto.randomUUID()}`,
149
+ type: 'erp_mapping',
150
+ erp_type: erpType,
151
+ entity_type: entityType,
152
+ proposed_implementation: proposedImplementation,
153
+ simulation_id: simulationId,
154
+ integration_proposal_ids: integrationProposalIds,
155
+ attribution,
156
+ created_at: new Date().toISOString(),
157
+ };
158
+ }
159
+ // ============================================================================
160
+ // Traceability Validation
161
+ // ============================================================================
162
+ /**
163
+ * Validate that an artifact has a valid simulation parent.
164
+ * Returns a validation result with specific error messaging.
165
+ *
166
+ * ADR-004, Invariant 3: No integration proposal exists without traceability.
167
+ */
168
+ export function validateTraceability(simulationId, artifactType) {
169
+ if (!simulationId) {
170
+ return {
171
+ valid: false,
172
+ message: `${artifactType} requires a simulation_id. ` +
173
+ `All enterprise artifacts must trace to a governed simulation ` +
174
+ `(ADR-004, Invariant 2).`,
175
+ };
176
+ }
177
+ if (typeof simulationId !== 'string' || simulationId.trim() === '') {
178
+ return {
179
+ valid: false,
180
+ message: `${artifactType} simulation_id must be a non-empty string. ` +
181
+ `Received: ${String(simulationId)}`,
182
+ };
183
+ }
184
+ return { valid: true, message: '' };
185
+ }
186
+ /**
187
+ * Validate that a lineage chain is complete.
188
+ * Checks that simulation → plan → artifact chain is traceable.
189
+ */
190
+ export function validateLineageChain(records) {
191
+ const missing = [];
192
+ for (const record of records) {
193
+ if (!record.simulation_id) {
194
+ missing.push(`Lineage ${record.id}: missing simulation_id`);
195
+ }
196
+ if (!record.attribution.created_by) {
197
+ missing.push(`Lineage ${record.id}: missing attribution.created_by`);
198
+ }
199
+ if (!record.attribution.org_id) {
200
+ missing.push(`Lineage ${record.id}: missing attribution.org_id`);
201
+ }
202
+ if (!record.decision_context) {
203
+ missing.push(`Lineage ${record.id}: missing decision_context`);
204
+ }
205
+ }
206
+ return {
207
+ complete: missing.length === 0,
208
+ missing,
209
+ };
210
+ }
211
+ // ============================================================================
212
+ // Internal Helpers
213
+ // ============================================================================
214
+ function computeChecksum(data) {
215
+ const canonical = JSON.stringify(data);
216
+ return crypto.createHash('sha256').update(canonical).digest('hex');
217
+ }
218
+ //# sourceMappingURL=lineage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineage.js","sourceRoot":"","sources":["../../src/enterprise/lineage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAUtC,+EAA+E;AAC/E,8BAA8B;AAC9B,+EAA+E;AAE/E;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CACjC,UAAkB,EAClB,QAA0B,EAC1B,YAAoB,EACpB,eAAuB,EACvB,WAAw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,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;YAC1B,OAAO,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,EAAE,yBAAyB,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;YACnC,OAAO,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,EAAE,kCAAkC,CAAC,CAAC;QACvE,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,EAAE,8BAA8B,CAAC,CAAC;QACnE,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,EAAE,4BAA4B,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC;QAC9B,OAAO;KACR,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,SAAS,eAAe,CAAC,IAAa;IACpC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACrE,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Argument Guard Gate (Gate 5)
3
+ *
4
+ * Runtime validation middleware derived from ADR-001 (Command Argument Semantics).
5
+ * This gate enforces:
6
+ *
7
+ * 1. ID vs Natural Language argument rules
8
+ * 2. Required argument presence
9
+ * 3. Synthesis allow/deny per command
10
+ * 4. Confirmation enforcement for irreversible commands
11
+ * 5. Deterministic, instructional error messages
12
+ *
13
+ * The ADR (adr-command-semantics.ts) is the authoritative policy.
14
+ * This gate is mechanically derived from it.
15
+ */
16
+ import type { CommandObject } from '../types/index.js';
17
+ import { type CommandSpec } from '../contracts/adr-command-semantics.js';
18
+ export interface ArgumentGuardResult {
19
+ allowed: boolean;
20
+ exitCode?: number;
21
+ message?: string;
22
+ spec?: CommandSpec;
23
+ }
24
+ /**
25
+ * Check if the given command object passes argument validation.
26
+ * Returns a result indicating whether the command may proceed.
27
+ */
28
+ export declare function checkArgumentGuard(cmd: CommandObject): ArgumentGuardResult;
29
+ /**
30
+ * Enforce the argument guard. Exits the process on failure.
31
+ * Follows the same pattern as other gates (execution-gate, auth-session-gate).
32
+ */
33
+ export declare function enforceArgumentGuard(cmd: CommandObject): void;
34
+ /**
35
+ * Check if a command requires argument validation.
36
+ * Built-in commands (help, version) are exempt.
37
+ */
38
+ export declare function requiresArgumentValidation(command: string): boolean;
39
+ //# sourceMappingURL=argument-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argument-guard.d.ts","sourceRoot":"","sources":["../../src/gates/argument-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAIL,KAAK,WAAW,EAEjB,MAAM,uCAAuC,CAAC;AAO/C,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAMD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,mBAAmB,CA6B1E;AA6HD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAO7D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGnE"}
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Argument Guard Gate (Gate 5)
3
+ *
4
+ * Runtime validation middleware derived from ADR-001 (Command Argument Semantics).
5
+ * This gate enforces:
6
+ *
7
+ * 1. ID vs Natural Language argument rules
8
+ * 2. Required argument presence
9
+ * 3. Synthesis allow/deny per command
10
+ * 4. Confirmation enforcement for irreversible commands
11
+ * 5. Deterministic, instructional error messages
12
+ *
13
+ * The ADR (adr-command-semantics.ts) is the authoritative policy.
14
+ * This gate is mechanically derived from it.
15
+ */
16
+ import { lookupCommand, classifyArgument, validateArgument, } from '../contracts/adr-command-semantics.js';
17
+ import { EXIT_CODES } from '../types/index.js';
18
+ // ============================================================================
19
+ // Guard Implementation
20
+ // ============================================================================
21
+ /**
22
+ * Check if the given command object passes argument validation.
23
+ * Returns a result indicating whether the command may proceed.
24
+ */
25
+ export function checkArgumentGuard(cmd) {
26
+ const { command, subcommand, positionalArgs } = cmd;
27
+ // Step 1: Look up command spec in ADR registry
28
+ const spec = lookupCommand(command, subcommand);
29
+ if (!spec) {
30
+ // Command not in registry. Commands like 'help', 'version' may have
31
+ // no subcommand spec. Allow unregistered commands to pass through
32
+ // (other gates handle unknown commands).
33
+ const primarySpec = lookupCommand(command);
34
+ if (!primarySpec && subcommand) {
35
+ // Try: maybe the subcommand is actually a positional arg
36
+ // for the primary command (e.g., "plan <manifestQuery>")
37
+ const parentSpec = lookupCommand(command);
38
+ if (parentSpec) {
39
+ const modifiedCmd = {
40
+ ...cmd,
41
+ positionalArgs: [subcommand, ...positionalArgs],
42
+ };
43
+ return validateArgs(parentSpec, modifiedCmd);
44
+ }
45
+ }
46
+ // No spec found — allow through (other gates will catch truly invalid commands)
47
+ return { allowed: true };
48
+ }
49
+ // Step 2: Validate argument count, types, and confirmation requirements
50
+ return validateArgs(spec, cmd);
51
+ }
52
+ /**
53
+ * Validate positional arguments against the command spec.
54
+ * Accepts the full CommandObject to access flags for confirmation checks.
55
+ */
56
+ function validateArgs(spec, cmd) {
57
+ const positionalArgs = cmd.positionalArgs;
58
+ const requiredArgs = spec.args.filter(a => a.required);
59
+ // Case A: Missing required arguments
60
+ if (requiredArgs.length > 0 && positionalArgs.length < requiredArgs.length) {
61
+ const missing = requiredArgs.slice(positionalArgs.length);
62
+ const missingNames = missing.map(a => `<${a.name}>`).join(' ');
63
+ const examples = missing.map(a => ` ${a.example} — ${a.description}`).join('\n');
64
+ return {
65
+ allowed: false,
66
+ exitCode: EXIT_CODES.ARG_VALIDATION_ERROR,
67
+ message: `Error: Missing required argument${missing.length > 1 ? 's' : ''}: ${missingNames}\n` +
68
+ `\n` +
69
+ `Usage: agentics ${spec.command} ${spec.args.map(a => a.required ? `<${a.name}>` : `[${a.name}]`).join(' ')}\n` +
70
+ `\n` +
71
+ `Expected:\n` +
72
+ `${examples}\n` +
73
+ `\n` +
74
+ formatArgumentTypeHint(missing[0].type),
75
+ spec,
76
+ };
77
+ }
78
+ // Case B/C: Wrong argument type
79
+ for (let i = 0; i < spec.args.length && i < positionalArgs.length; i++) {
80
+ const argSpec = spec.args[i];
81
+ const argValue = positionalArgs[i];
82
+ const error = validateArgument(argValue, argSpec);
83
+ if (error) {
84
+ return {
85
+ allowed: false,
86
+ exitCode: EXIT_CODES.ARG_VALIDATION_ERROR,
87
+ message: `Error: Invalid argument for '${spec.command}'\n` +
88
+ `\n` +
89
+ `${error}\n` +
90
+ `\n` +
91
+ `Usage: agentics ${spec.command} ${spec.args.map(a => a.required ? `<${a.name}>` : `[${a.name}]`).join(' ')}`,
92
+ spec,
93
+ };
94
+ }
95
+ }
96
+ // Case D: Synthesis attempted on forbidden command
97
+ // (Checked at the command level — if NL detected on SYNTHESIS_FORBIDDEN)
98
+ if (spec.synthesis === 'SYNTHESIS_FORBIDDEN') {
99
+ for (let i = 0; i < spec.args.length && i < positionalArgs.length; i++) {
100
+ const argSpec = spec.args[i];
101
+ if (argSpec.type === 'ID') {
102
+ const detected = classifyArgument(positionalArgs[i]);
103
+ if (detected === 'NATURAL_LANGUAGE') {
104
+ return {
105
+ allowed: false,
106
+ exitCode: EXIT_CODES.ARG_VALIDATION_ERROR,
107
+ message: `Error: Synthesis is not allowed on '${spec.command}'.\n` +
108
+ `\n` +
109
+ `This command requires an ID, not a description.\n` +
110
+ `Natural language input triggers synthesis, which is forbidden for this command.\n` +
111
+ `\n` +
112
+ `Usage: agentics ${spec.command} <${argSpec.name}>\n` +
113
+ `Example: agentics ${spec.command} ${argSpec.example}`,
114
+ spec,
115
+ };
116
+ }
117
+ }
118
+ }
119
+ }
120
+ // Case E: Irreversible command without explicit confirmation (ADR-002 Decision 2, Rule 4)
121
+ if (spec.requiresConfirmation) {
122
+ const hasForceFlag = cmd.flags['force'] === true;
123
+ if (!hasForceFlag) {
124
+ const argsUsage = spec.args.map(a => a.required ? `<${a.name}>` : `[${a.name}]`).join(' ');
125
+ return {
126
+ allowed: false,
127
+ exitCode: EXIT_CODES.ARG_VALIDATION_ERROR,
128
+ message: `Error: Command '${spec.command}' requires explicit confirmation.\n` +
129
+ `\n` +
130
+ (spec.irreversible
131
+ ? `This command performs an irreversible operation and cannot be undone.\n`
132
+ : `This command requires confirmation before proceeding.\n`) +
133
+ `You must provide the --force flag to confirm.\n` +
134
+ `\n` +
135
+ `Usage: agentics ${spec.command} ${argsUsage} --force`,
136
+ spec,
137
+ };
138
+ }
139
+ }
140
+ return { allowed: true, spec };
141
+ }
142
+ /**
143
+ * Generate a hint string for the expected argument type.
144
+ */
145
+ function formatArgumentTypeHint(type) {
146
+ switch (type) {
147
+ case 'ID':
148
+ return 'Hint: IDs are lowercase, hyphenated identifiers or UUIDs.\n' +
149
+ ' They resolve to persisted objects. Never use quoted text here.';
150
+ case 'NATURAL_LANGUAGE':
151
+ return 'Hint: Descriptions must be quoted natural language strings.\n' +
152
+ ' They seed synthesis to create new resources.';
153
+ case 'SELECTOR':
154
+ return 'Hint: Selectors are keywords like "latest" or UUIDs.\n' +
155
+ ' They select existing resources without triggering synthesis.';
156
+ }
157
+ }
158
+ // ============================================================================
159
+ // Gate Enforcement
160
+ // ============================================================================
161
+ /**
162
+ * Enforce the argument guard. Exits the process on failure.
163
+ * Follows the same pattern as other gates (execution-gate, auth-session-gate).
164
+ */
165
+ export function enforceArgumentGuard(cmd) {
166
+ const result = checkArgumentGuard(cmd);
167
+ if (!result.allowed) {
168
+ console.error(result.message);
169
+ process.exit(result.exitCode ?? EXIT_CODES.ARG_VALIDATION_ERROR);
170
+ }
171
+ }
172
+ /**
173
+ * Check if a command requires argument validation.
174
+ * Built-in commands (help, version) are exempt.
175
+ */
176
+ export function requiresArgumentValidation(command) {
177
+ const exempt = ['help', 'version'];
178
+ return !exempt.includes(command);
179
+ }
180
+ //# sourceMappingURL=argument-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argument-guard.js","sourceRoot":"","sources":["../../src/gates/argument-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GAGjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAa/C,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAkB;IACnD,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,GAAG,GAAG,CAAC;IAEpD,+CAA+C;IAC/C,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAEhD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,oEAAoE;QACpE,kEAAkE;QAClE,yCAAyC;QACzC,MAAM,WAAW,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;QAC3C,IAAI,CAAC,WAAW,IAAI,UAAU,EAAE,CAAC;YAC/B,yDAAyD;YACzD,yDAAyD;YACzD,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;YAC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UAAU,CAAC,oBAAoB,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAAe;IACxD,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACnC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC"}
@@ -9,6 +9,8 @@
9
9
  * 2. Auth Session Gate - Requires authenticated session
10
10
  * 3. Service Health Gate - Validates Ruvector-backed service availability
11
11
  * 4. Output Format Gate - Enforces strict JSON output
12
+ * 5. Argument Guard Gate - Validates argument types per ADR-001
13
+ * 6. Lineage Gate - Enforces simulation traceability per ADR-004
12
14
  *
13
15
  * CRITICAL REQUIREMENTS MET:
14
16
  * - CLI requires Ruvector-backed services (Service Health Gate)
@@ -18,9 +20,12 @@
18
20
  * - Validates target service availability (Service Health Gate)
19
21
  * - Enforces strict JSON outputs (Output Format Gate)
20
22
  * - Never allows narrative output (Output Format Gate)
23
+ * - Enterprise artifacts trace to governed simulations (Lineage Gate)
21
24
  */
22
25
  export { checkExecutionGate, enforceExecutionGate, isExecutionEnabled, getAllowedCommands, resolveEntitlement, EXECUTION_BLOCKED_EXIT_CODE, type ExecutionGateResult, type Entitlement, } from './execution-gate.js';
23
26
  export { enforceAuthSessionGate, checkAuthSessionGate, requiresAuthentication, AUTH_REQUIRED_EXIT_CODE, AuthSessionRequiredError, type AuthSessionGateResult, } from './auth-session-gate.js';
24
27
  export { enforceServiceHealthGate, checkServiceHealthGate, requiresHealthCheck, SERVICE_UNAVAILABLE_EXIT_CODE, ServiceHealthError, type ServiceHealthResult, type ServiceHealthGateResult, } from './service-health-gate.js';
25
28
  export { enforceOutputFormatGate, checkOutputFormatGate, requiresStructuredOutput, getDefaultFormat, INVALID_FORMAT_EXIT_CODE, InvalidOutputFormatError, type OutputFormatGateResult, } from './output-format-gate.js';
29
+ export { checkArgumentGuard, enforceArgumentGuard, requiresArgumentValidation, type ArgumentGuardResult, } from './argument-guard.js';
30
+ export { checkLineageGate, enforceLineageGate, requiresLineageValidation, LINEAGE_VIOLATION_EXIT_CODE, type LineageGateResult, } from './lineage-gate.js';
26
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gates/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,EAC3B,KAAK,mBAAmB,EACxB,KAAK,WAAW,GACjB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,KAAK,qBAAqB,GAC3B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,6BAA6B,EAC7B,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,GAC7B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,sBAAsB,GAC5B,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gates/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,EAC3B,KAAK,mBAAmB,EACxB,KAAK,WAAW,GACjB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,KAAK,qBAAqB,GAC3B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,6BAA6B,EAC7B,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,GAC7B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,sBAAsB,GAC5B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,EAC3B,KAAK,iBAAiB,GACvB,MAAM,mBAAmB,CAAC"}
@@ -9,6 +9,8 @@
9
9
  * 2. Auth Session Gate - Requires authenticated session
10
10
  * 3. Service Health Gate - Validates Ruvector-backed service availability
11
11
  * 4. Output Format Gate - Enforces strict JSON output
12
+ * 5. Argument Guard Gate - Validates argument types per ADR-001
13
+ * 6. Lineage Gate - Enforces simulation traceability per ADR-004
12
14
  *
13
15
  * CRITICAL REQUIREMENTS MET:
14
16
  * - CLI requires Ruvector-backed services (Service Health Gate)
@@ -18,6 +20,7 @@
18
20
  * - Validates target service availability (Service Health Gate)
19
21
  * - Enforces strict JSON outputs (Output Format Gate)
20
22
  * - Never allows narrative output (Output Format Gate)
23
+ * - Enterprise artifacts trace to governed simulations (Lineage Gate)
21
24
  */
22
25
  // Execution Gate - Hard kill-switch
23
26
  export { checkExecutionGate, enforceExecutionGate, isExecutionEnabled, getAllowedCommands, resolveEntitlement, EXECUTION_BLOCKED_EXIT_CODE, } from './execution-gate.js';
@@ -27,4 +30,8 @@ export { enforceAuthSessionGate, checkAuthSessionGate, requiresAuthentication, A
27
30
  export { enforceServiceHealthGate, checkServiceHealthGate, requiresHealthCheck, SERVICE_UNAVAILABLE_EXIT_CODE, ServiceHealthError, } from './service-health-gate.js';
28
31
  // Output Format Gate - Enforces strict JSON output
29
32
  export { enforceOutputFormatGate, checkOutputFormatGate, requiresStructuredOutput, getDefaultFormat, INVALID_FORMAT_EXIT_CODE, InvalidOutputFormatError, } from './output-format-gate.js';
33
+ // Argument Guard Gate - Validates argument types per ADR-001
34
+ export { checkArgumentGuard, enforceArgumentGuard, requiresArgumentValidation, } from './argument-guard.js';
35
+ // Lineage Gate - Enforces simulation traceability per ADR-004
36
+ export { checkLineageGate, enforceLineageGate, requiresLineageValidation, LINEAGE_VIOLATION_EXIT_CODE, } from './lineage-gate.js';
30
37
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gates/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,oCAAoC;AACpC,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,GAG5B,MAAM,qBAAqB,CAAC;AAE7B,qDAAqD;AACrD,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,GAEzB,MAAM,wBAAwB,CAAC;AAEhC,2DAA2D;AAC3D,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,6BAA6B,EAC7B,kBAAkB,GAGnB,MAAM,0BAA0B,CAAC;AAElC,mDAAmD;AACnD,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,GAEzB,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gates/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,oCAAoC;AACpC,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,GAG5B,MAAM,qBAAqB,CAAC;AAE7B,qDAAqD;AACrD,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,GAEzB,MAAM,wBAAwB,CAAC;AAEhC,2DAA2D;AAC3D,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,6BAA6B,EAC7B,kBAAkB,GAGnB,MAAM,0BAA0B,CAAC;AAElC,mDAAmD;AACnD,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,GAEzB,MAAM,yBAAyB,CAAC;AAEjC,6DAA6D;AAC7D,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,GAE3B,MAAM,qBAAqB,CAAC;AAE7B,8DAA8D;AAC9D,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,GAE5B,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Lineage Gate — Gate 6 (ADR-004 Enforcement)
3
+ *
4
+ * PURPOSE: Enforce that artifact-producing commands reference a valid
5
+ * simulation parent. No integration proposal or ERP mapping may
6
+ * exist without traceability to a governed simulation.
7
+ *
8
+ * INVARIANTS ENFORCED:
9
+ * - ADR-004 Invariant 2: Every integration/ERP mapping derives from a simulation
10
+ * - ADR-004 Invariant 3: No integration proposal without traceability
11
+ * - ADR-004 Invariant 7: CLI is only path for artifact creation
12
+ *
13
+ * EXIT CODE: 110 (LINEAGE_VIOLATION)
14
+ *
15
+ * BEHAVIOR:
16
+ * - Commands that produce enterprise artifacts (erp surface, erp map,
17
+ * erp export) must pass a simulation_id in their positional args
18
+ * or flags when the lineage gate is enabled.
19
+ * - Commands that do not produce artifacts (list, inspect, help)
20
+ * are exempt from lineage validation.
21
+ * - The gate validates that simulation_id is present and non-empty.
22
+ * Whether the simulation exists in Ruvector is validated at the
23
+ * command level, not at the gate level (gate is synchronous).
24
+ */
25
+ import type { CommandObject } from '../types/index.js';
26
+ export declare const LINEAGE_VIOLATION_EXIT_CODE = 110;
27
+ export interface LineageGateResult {
28
+ /** Whether the command passed lineage validation */
29
+ allowed: boolean;
30
+ /** Error message if validation failed */
31
+ message: string;
32
+ /** Exit code if validation failed */
33
+ exitCode: number;
34
+ /** Whether this command requires lineage */
35
+ lineageRequired: boolean;
36
+ }
37
+ /**
38
+ * Check whether a command passes lineage validation.
39
+ * Returns a result indicating whether the command is allowed.
40
+ *
41
+ * Lineage is required when:
42
+ * 1. The command is in LINEAGE_REQUIRED_COMMANDS
43
+ * 2. The command is not in LINEAGE_EXEMPT_COMMANDS
44
+ * 3. The command produces enterprise artifacts
45
+ */
46
+ export declare function checkLineageGate(cmd: CommandObject): LineageGateResult;
47
+ /**
48
+ * Enforce lineage gate — exits the process if validation fails.
49
+ */
50
+ export declare function enforceLineageGate(cmd: CommandObject): void;
51
+ /**
52
+ * Check if a command requires lineage validation.
53
+ */
54
+ export declare function requiresLineageValidation(primary: string, sub?: string): boolean;
55
+ //# sourceMappingURL=lineage-gate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineage-gate.d.ts","sourceRoot":"","sources":["../../src/gates/lineage-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAOvD,eAAO,MAAM,2BAA2B,MAAM,CAAC;AA2B/C,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,OAAO,EAAE,OAAO,CAAC;IACjB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,eAAe,EAAE,OAAO,CAAC;CAC1B;AAMD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,aAAa,GAAG,iBAAiB,CAyCtE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAc3D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAMhF"}