@llm-dev-ops/agentics-cli 1.3.1 → 1.3.3
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/adapters/base-adapter.js +10 -10
- package/dist/adapters/base-adapter.js.map +1 -1
- package/dist/audit/audit-trail.js +1 -1
- package/dist/cli/index.js +6 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/deploy.d.ts +14 -5
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +58 -16
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/diligence.d.ts +12 -4
- package/dist/commands/diligence.d.ts.map +1 -1
- package/dist/commands/diligence.js +54 -14
- package/dist/commands/diligence.js.map +1 -1
- package/dist/commands/export.d.ts +10 -3
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +56 -16
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/inspect.d.ts +13 -7
- package/dist/commands/inspect.d.ts.map +1 -1
- package/dist/commands/inspect.js +57 -19
- package/dist/commands/inspect.js.map +1 -1
- package/dist/commands/login.js +1 -1
- package/dist/commands/plan.d.ts +11 -4
- package/dist/commands/plan.d.ts.map +1 -1
- package/dist/commands/plan.js +39 -12
- package/dist/commands/plan.js.map +1 -1
- package/dist/commands/quantify.d.ts +12 -6
- package/dist/commands/quantify.d.ts.map +1 -1
- package/dist/commands/quantify.js +56 -17
- package/dist/commands/quantify.js.map +1 -1
- package/dist/commands/simulate.d.ts +10 -3
- package/dist/commands/simulate.d.ts.map +1 -1
- package/dist/commands/simulate.js +69 -18
- package/dist/commands/simulate.js.map +1 -1
- package/dist/config/endpoints.d.ts.map +1 -1
- package/dist/config/endpoints.js +10 -8
- package/dist/config/endpoints.js.map +1 -1
- package/dist/contracts/index.d.ts +21 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +20 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/validator.d.ts +62 -0
- package/dist/contracts/validator.d.ts.map +1 -0
- package/dist/contracts/validator.js +397 -0
- package/dist/contracts/validator.js.map +1 -0
- package/dist/server/index.d.ts +26 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +144 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/routes/auth.d.ts +12 -0
- package/dist/server/routes/auth.d.ts.map +1 -0
- package/dist/server/routes/auth.js +111 -0
- package/dist/server/routes/auth.js.map +1 -0
- package/dist/server/routes/diligence.d.ts +12 -0
- package/dist/server/routes/diligence.d.ts.map +1 -0
- package/dist/server/routes/diligence.js +48 -0
- package/dist/server/routes/diligence.js.map +1 -0
- package/dist/server/routes/erpsurface.d.ts +11 -0
- package/dist/server/routes/erpsurface.d.ts.map +1 -0
- package/dist/server/routes/erpsurface.js +59 -0
- package/dist/server/routes/erpsurface.js.map +1 -0
- package/dist/server/routes/exporters.d.ts +12 -0
- package/dist/server/routes/exporters.d.ts.map +1 -0
- package/dist/server/routes/exporters.js +47 -0
- package/dist/server/routes/exporters.js.map +1 -0
- package/dist/server/routes/health.d.ts +11 -0
- package/dist/server/routes/health.d.ts.map +1 -0
- package/dist/server/routes/health.js +33 -0
- package/dist/server/routes/health.js.map +1 -0
- package/dist/server/routes/index.d.ts +17 -0
- package/dist/server/routes/index.d.ts.map +1 -0
- package/dist/server/routes/index.js +17 -0
- package/dist/server/routes/index.js.map +1 -0
- package/dist/server/routes/intent.d.ts +12 -0
- package/dist/server/routes/intent.d.ts.map +1 -0
- package/dist/server/routes/intent.js +50 -0
- package/dist/server/routes/intent.js.map +1 -0
- package/dist/server/routes/manifests.d.ts +12 -0
- package/dist/server/routes/manifests.d.ts.map +1 -0
- package/dist/server/routes/manifests.js +46 -0
- package/dist/server/routes/manifests.js.map +1 -0
- package/dist/server/routes/plans.d.ts +12 -0
- package/dist/server/routes/plans.d.ts.map +1 -0
- package/dist/server/routes/plans.js +47 -0
- package/dist/server/routes/plans.js.map +1 -0
- package/dist/server/routes/roi.d.ts +12 -0
- package/dist/server/routes/roi.d.ts.map +1 -0
- package/dist/server/routes/roi.js +48 -0
- package/dist/server/routes/roi.js.map +1 -0
- package/dist/server/routes/runner.d.ts +12 -0
- package/dist/server/routes/runner.d.ts.map +1 -0
- package/dist/server/routes/runner.js +50 -0
- package/dist/server/routes/runner.js.map +1 -0
- package/dist/server/routes/simulate.d.ts +13 -0
- package/dist/server/routes/simulate.d.ts.map +1 -0
- package/dist/server/routes/simulate.js +58 -0
- package/dist/server/routes/simulate.js.map +1 -0
- package/dist/server/utils/id-generator.d.ts +32 -0
- package/dist/server/utils/id-generator.d.ts.map +1 -0
- package/dist/server/utils/id-generator.js +51 -0
- package/dist/server/utils/id-generator.js.map +1 -0
- package/dist/server/utils/index.d.ts +8 -0
- package/dist/server/utils/index.d.ts.map +1 -0
- package/dist/server/utils/index.js +8 -0
- package/dist/server/utils/index.js.map +1 -0
- package/dist/server/utils/response-builder.d.ts +56 -0
- package/dist/server/utils/response-builder.d.ts.map +1 -0
- package/dist/server/utils/response-builder.js +388 -0
- package/dist/server/utils/response-builder.js.map +1 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +10 -3
package/dist/commands/export.js
CHANGED
|
@@ -5,9 +5,16 @@
|
|
|
5
5
|
*
|
|
6
6
|
* FLOW:
|
|
7
7
|
* 1. Parse arguments → CommandObject
|
|
8
|
-
* 2.
|
|
9
|
-
* 3.
|
|
10
|
-
* 4.
|
|
8
|
+
* 2. VALIDATE request against contract (MUST pass before network call)
|
|
9
|
+
* 3. Generate exports via agentics-deployment-exporters
|
|
10
|
+
* 4. VALIDATE response has execution_metadata (reject if missing)
|
|
11
|
+
* 5. Record audit entry
|
|
12
|
+
* 6. Return ExportReference
|
|
13
|
+
*
|
|
14
|
+
* CONTRACT ENFORCEMENT:
|
|
15
|
+
* - Request validation happens BEFORE any network call
|
|
16
|
+
* - Response validation requires execution_metadata
|
|
17
|
+
* - No bypass flags or soft-fail behavior
|
|
11
18
|
*/
|
|
12
19
|
import { isNaturalLanguage } from '../types/index.js';
|
|
13
20
|
import { ExportersAdapter } from '../adapters/base-adapter.js';
|
|
@@ -16,6 +23,7 @@ import { createArtifactHandoff } from '../modules/artifact-handoff.js';
|
|
|
16
23
|
import { createAuditTrail } from '../audit/audit-trail.js';
|
|
17
24
|
import { failFast } from '../errors/index.js';
|
|
18
25
|
import { loadEndpointConfig } from '../config/endpoints.js';
|
|
26
|
+
import { validateRequest, validateResponse, RequestSchemas, ResponseSchemas, } from '../contracts/validator.js';
|
|
19
27
|
// ============================================================================
|
|
20
28
|
// Export Command Implementation
|
|
21
29
|
// ============================================================================
|
|
@@ -35,18 +43,47 @@ export async function executeExportCommand(input, options) {
|
|
|
35
43
|
name: 'generate-export',
|
|
36
44
|
adapter: exportersAdapter,
|
|
37
45
|
request: {
|
|
38
|
-
endpoint: '/
|
|
46
|
+
endpoint: '/v1/exporters',
|
|
39
47
|
method: 'POST',
|
|
40
|
-
buildBody: () =>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
buildBody: () => {
|
|
49
|
+
let requestBody;
|
|
50
|
+
if (isNaturalLanguage(input.intentRef)) {
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// CONTRACT VALIDATION - Natural language format
|
|
53
|
+
// ============================================================================
|
|
54
|
+
requestBody = {
|
|
55
|
+
intent_ref: {
|
|
56
|
+
natural_language: input.intentRef.description,
|
|
57
|
+
},
|
|
58
|
+
format_spec: {
|
|
59
|
+
format: input.format,
|
|
60
|
+
output_path: input.outputPath,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// CONTRACT VALIDATION - Structured reference format
|
|
67
|
+
// ============================================================================
|
|
68
|
+
const intentRef = input.intentRef;
|
|
69
|
+
requestBody = {
|
|
70
|
+
intent_ref: {
|
|
71
|
+
id: intentRef.id,
|
|
72
|
+
type: 'IntentReference',
|
|
73
|
+
repository: intentRef.repository,
|
|
74
|
+
created_at: intentRef.created_at,
|
|
75
|
+
checksum: intentRef.checksum,
|
|
76
|
+
},
|
|
77
|
+
format_spec: {
|
|
78
|
+
format: input.format,
|
|
79
|
+
output_path: input.outputPath,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
// Validate request against contract BEFORE sending
|
|
84
|
+
validateRequest(RequestSchemas.EXPORT, requestBody, correlationId);
|
|
85
|
+
return requestBody;
|
|
86
|
+
},
|
|
50
87
|
},
|
|
51
88
|
},
|
|
52
89
|
];
|
|
@@ -57,9 +94,12 @@ export async function executeExportCommand(input, options) {
|
|
|
57
94
|
const failedStage = result.stages.find(s => s.status === 'failed');
|
|
58
95
|
throw new Error(failedStage?.error?.message ?? 'Export generation failed');
|
|
59
96
|
}
|
|
60
|
-
//
|
|
97
|
+
// ============================================================================
|
|
98
|
+
// RESPONSE VALIDATION - execution_metadata REQUIRED
|
|
99
|
+
// ============================================================================
|
|
61
100
|
const exportStage = result.stages.find(s => s.name === 'generate-export');
|
|
62
|
-
const
|
|
101
|
+
const validatedExport = validateResponse(ResponseSchemas.EXPORT, exportStage?.response, correlationId);
|
|
102
|
+
const exportRef = handoff.extractReference(validatedExport);
|
|
63
103
|
// Record audit entry
|
|
64
104
|
const intentRefId = isNaturalLanguage(input.intentRef)
|
|
65
105
|
? `nl:${input.intentRef.description.slice(0, 50)}`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAUH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,C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* 2.
|
|
9
|
-
* 3.
|
|
10
|
-
* 4.
|
|
8
|
+
* 2. VALIDATE request against contract (MUST pass before network call)
|
|
9
|
+
* 3. Retrieve simulation output via agentics-simulation-engine
|
|
10
|
+
* 4. VALIDATE response has execution_metadata (reject if missing)
|
|
11
|
+
* 5. Record audit entry
|
|
12
|
+
* 6. Return SimulationOutputReference
|
|
11
13
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
+
* CONTRACT ENFORCEMENT:
|
|
15
|
+
* - Request validation happens BEFORE any network call
|
|
16
|
+
* - Response validation requires execution_metadata
|
|
17
|
+
* - No bypass flags or soft-fail behavior
|
|
14
18
|
*/
|
|
15
|
-
import type { CommandOptions, SimulationOutputReference, SimulationReference,
|
|
19
|
+
import type { CommandOptions, SimulationOutputReference, SimulationReference, FlexibleInput } from '../types/index.js';
|
|
16
20
|
export interface InspectCommandInput {
|
|
17
21
|
simRef: FlexibleInput<SimulationReference>;
|
|
18
|
-
|
|
22
|
+
depth?: 'summary' | 'detailed' | 'full';
|
|
23
|
+
includeMetrics?: boolean;
|
|
24
|
+
includeTraces?: boolean;
|
|
19
25
|
}
|
|
20
26
|
export interface InspectCommandResult {
|
|
21
27
|
reference: SimulationOutputReference;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/commands/inspect.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/commands/inspect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EAEd,MAAM,mBAAmB,CAAC;AAuB3B,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAC3C,KAAK,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;IACxC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,yBAAyB,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;CAChB;AAMD,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,mBAAmB,EAC1B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,oBAAoB,CAAC,CA2I/B"}
|
package/dist/commands/inspect.js
CHANGED
|
@@ -5,12 +5,16 @@
|
|
|
5
5
|
*
|
|
6
6
|
* FLOW:
|
|
7
7
|
* 1. Parse arguments → CommandObject
|
|
8
|
-
* 2.
|
|
9
|
-
* 3.
|
|
10
|
-
* 4.
|
|
8
|
+
* 2. VALIDATE request against contract (MUST pass before network call)
|
|
9
|
+
* 3. Retrieve simulation output via agentics-simulation-engine
|
|
10
|
+
* 4. VALIDATE response has execution_metadata (reject if missing)
|
|
11
|
+
* 5. Record audit entry
|
|
12
|
+
* 6. Return SimulationOutputReference
|
|
11
13
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
+
* CONTRACT ENFORCEMENT:
|
|
15
|
+
* - Request validation happens BEFORE any network call
|
|
16
|
+
* - Response validation requires execution_metadata
|
|
17
|
+
* - No bypass flags or soft-fail behavior
|
|
14
18
|
*/
|
|
15
19
|
import { isNaturalLanguage } from '../types/index.js';
|
|
16
20
|
import { SimulationEngineAdapter } from '../adapters/base-adapter.js';
|
|
@@ -19,6 +23,7 @@ import { createArtifactHandoff } from '../modules/artifact-handoff.js';
|
|
|
19
23
|
import { createAuditTrail } from '../audit/audit-trail.js';
|
|
20
24
|
import { failFast } from '../errors/index.js';
|
|
21
25
|
import { loadEndpointConfig } from '../config/endpoints.js';
|
|
26
|
+
import { validateRequest, validateResponse, RequestSchemas, ResponseSchemas, } from '../contracts/validator.js';
|
|
22
27
|
// ============================================================================
|
|
23
28
|
// Inspect Command Implementation
|
|
24
29
|
// ============================================================================
|
|
@@ -32,23 +37,53 @@ export async function executeInspectCommand(input, options) {
|
|
|
32
37
|
// Create adapter
|
|
33
38
|
const engineConfig = loadEndpointConfig('agentics-simulation-engine');
|
|
34
39
|
const engineAdapter = new SimulationEngineAdapter(engineConfig, correlationId);
|
|
35
|
-
// Default
|
|
36
|
-
const
|
|
40
|
+
// Default depth
|
|
41
|
+
const depth = input.depth ?? 'summary';
|
|
37
42
|
// Define orchestration stages
|
|
38
43
|
const stages = [
|
|
39
44
|
{
|
|
40
45
|
name: 'retrieve-output',
|
|
41
46
|
adapter: engineAdapter,
|
|
42
47
|
request: {
|
|
43
|
-
endpoint: '/
|
|
48
|
+
endpoint: '/v1/simulate',
|
|
44
49
|
method: 'POST',
|
|
45
|
-
buildBody: () =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
buildBody: () => {
|
|
51
|
+
let requestBody;
|
|
52
|
+
if (isNaturalLanguage(input.simRef)) {
|
|
53
|
+
// ============================================================================
|
|
54
|
+
// CONTRACT VALIDATION - Natural language format
|
|
55
|
+
// ============================================================================
|
|
56
|
+
requestBody = {
|
|
57
|
+
sim_ref: {
|
|
58
|
+
natural_language: input.simRef.description,
|
|
59
|
+
},
|
|
60
|
+
depth,
|
|
61
|
+
include_metrics: input.includeMetrics,
|
|
62
|
+
include_traces: input.includeTraces,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// ============================================================================
|
|
67
|
+
// CONTRACT VALIDATION - Structured reference format
|
|
68
|
+
// ============================================================================
|
|
69
|
+
const simRef = input.simRef;
|
|
70
|
+
requestBody = {
|
|
71
|
+
sim_ref: {
|
|
72
|
+
id: simRef.id,
|
|
73
|
+
type: 'SimulationReference',
|
|
74
|
+
repository: simRef.repository,
|
|
75
|
+
created_at: simRef.created_at,
|
|
76
|
+
checksum: simRef.checksum,
|
|
77
|
+
},
|
|
78
|
+
depth,
|
|
79
|
+
include_metrics: input.includeMetrics,
|
|
80
|
+
include_traces: input.includeTraces,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
// Validate request against contract BEFORE sending
|
|
84
|
+
validateRequest(RequestSchemas.INSPECT, requestBody, correlationId);
|
|
85
|
+
return requestBody;
|
|
86
|
+
},
|
|
52
87
|
},
|
|
53
88
|
},
|
|
54
89
|
];
|
|
@@ -59,16 +94,19 @@ export async function executeInspectCommand(input, options) {
|
|
|
59
94
|
const failedStage = result.stages.find(s => s.status === 'failed');
|
|
60
95
|
throw new Error(failedStage?.error?.message ?? 'Output retrieval failed');
|
|
61
96
|
}
|
|
62
|
-
//
|
|
97
|
+
// ============================================================================
|
|
98
|
+
// RESPONSE VALIDATION - execution_metadata REQUIRED
|
|
99
|
+
// ============================================================================
|
|
63
100
|
const outputStage = result.stages.find(s => s.name === 'retrieve-output');
|
|
64
|
-
const
|
|
101
|
+
const validatedOutput = validateResponse(ResponseSchemas.SIMULATION_OUTPUT, outputStage?.response, correlationId);
|
|
102
|
+
const outputRef = handoff.extractReference(validatedOutput);
|
|
65
103
|
// Record audit entry
|
|
66
104
|
const simRefId = isNaturalLanguage(input.simRef)
|
|
67
105
|
? `nl:${input.simRef.description.slice(0, 50)}`
|
|
68
106
|
: input.simRef.id;
|
|
69
107
|
audit.record({
|
|
70
108
|
command: 'inspect',
|
|
71
|
-
inputs: { simRef: simRefId,
|
|
109
|
+
inputs: { simRef: simRefId, depth },
|
|
72
110
|
outputs: outputRef,
|
|
73
111
|
dependencies: [
|
|
74
112
|
{ service: 'agentics-simulation-engine', method: 'retrieve', timestamp: new Date().toISOString(), duration_ms: result.timing.total, success: true },
|
|
@@ -89,7 +127,7 @@ export async function executeInspectCommand(input, options) {
|
|
|
89
127
|
: input.simRef.id;
|
|
90
128
|
audit.record({
|
|
91
129
|
command: 'inspect',
|
|
92
|
-
inputs: { simRef: failedSimRefId,
|
|
130
|
+
inputs: { simRef: failedSimRefId, depth },
|
|
93
131
|
outputs: null,
|
|
94
132
|
dependencies: [],
|
|
95
133
|
duration_ms: Date.now() - startTime,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../src/commands/inspect.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../src/commands/inspect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AASH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EACL,yBAAyB,GAE1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,GAChB,MAAM,2BAA2B,CAAC;AAmBnC,+EAA+E;AAC/E,iCAAiC;AACjC,+EAA+E;AAE/E,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,KAA0B,EAC1B,OAAuB;IAEvB,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;IAC9D,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,wBAAwB;IACxB,MAAM,MAAM,GAAG,yBAAyB,CAAC,aAAa,CAAC,CAAC;IACxD,MAAM,OAAO,GAAG,qBAAqB,EAAE,CAAC;IACxC,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;IAEjC,iBAAiB;IACjB,MAAM,YAAY,GAAG,kBAAkB,CAAC,4BAA4B,CAAC,CAAC;IACtE,MAAM,a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K,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACxE,MAAM,EAAE,KAAK;YACb,aAAa;SACd,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
package/dist/commands/login.js
CHANGED
|
@@ -24,7 +24,7 @@ import { createCredentialStore } from '../utils/credentials.js';
|
|
|
24
24
|
// ============================================================================
|
|
25
25
|
const API_URL = process.env['AGENTICS_API_URL'] ?? 'https://platform.agentics.dev';
|
|
26
26
|
const CLI_NAME = 'Agentics CLI';
|
|
27
|
-
const CLI_VERSION = '1.3.
|
|
27
|
+
const CLI_VERSION = '1.3.2';
|
|
28
28
|
const DEFAULT_POLL_INTERVAL = 5000; // 5 seconds
|
|
29
29
|
const MAX_POLL_ATTEMPTS = 60; // 5 minutes max (60 * 5s)
|
|
30
30
|
// ============================================================================
|
package/dist/commands/plan.d.ts
CHANGED
|
@@ -5,10 +5,17 @@
|
|
|
5
5
|
*
|
|
6
6
|
* FLOW:
|
|
7
7
|
* 1. Parse arguments → CommandObject
|
|
8
|
-
* 2.
|
|
9
|
-
* 3.
|
|
10
|
-
* 4.
|
|
11
|
-
* 5.
|
|
8
|
+
* 2. VALIDATE request against contract (MUST pass before network call)
|
|
9
|
+
* 3. Select manifest via agentics-org-manifests
|
|
10
|
+
* 4. Create plan via agentics-simulation-planner
|
|
11
|
+
* 5. VALIDATE response has execution_metadata (reject if missing)
|
|
12
|
+
* 6. Record audit entry
|
|
13
|
+
* 7. Return PlanReference
|
|
14
|
+
*
|
|
15
|
+
* CONTRACT ENFORCEMENT:
|
|
16
|
+
* - Request validation happens BEFORE any network call
|
|
17
|
+
* - Response validation requires execution_metadata
|
|
18
|
+
* - No bypass flags or soft-fail behavior
|
|
12
19
|
*/
|
|
13
20
|
import type { CommandOptions, PlanReference } from '../types/index.js';
|
|
14
21
|
export interface PlanCommandInput {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/commands/plan.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/commands/plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACd,MAAM,mBAAmB,CAAC;AAyB3B,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,aAAa,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB;AAMD,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CA+I5B"}
|
package/dist/commands/plan.js
CHANGED
|
@@ -5,10 +5,17 @@
|
|
|
5
5
|
*
|
|
6
6
|
* FLOW:
|
|
7
7
|
* 1. Parse arguments → CommandObject
|
|
8
|
-
* 2.
|
|
9
|
-
* 3.
|
|
10
|
-
* 4.
|
|
11
|
-
* 5.
|
|
8
|
+
* 2. VALIDATE request against contract (MUST pass before network call)
|
|
9
|
+
* 3. Select manifest via agentics-org-manifests
|
|
10
|
+
* 4. Create plan via agentics-simulation-planner
|
|
11
|
+
* 5. VALIDATE response has execution_metadata (reject if missing)
|
|
12
|
+
* 6. Record audit entry
|
|
13
|
+
* 7. Return PlanReference
|
|
14
|
+
*
|
|
15
|
+
* CONTRACT ENFORCEMENT:
|
|
16
|
+
* - Request validation happens BEFORE any network call
|
|
17
|
+
* - Response validation requires execution_metadata
|
|
18
|
+
* - No bypass flags or soft-fail behavior
|
|
12
19
|
*/
|
|
13
20
|
import { ManifestsAdapter, PlannerAdapter, } from '../adapters/base-adapter.js';
|
|
14
21
|
import { createOrchestrationEngine, } from '../modules/orchestration-engine.js';
|
|
@@ -16,12 +23,18 @@ import { createArtifactHandoff } from '../modules/artifact-handoff.js';
|
|
|
16
23
|
import { createAuditTrail } from '../audit/audit-trail.js';
|
|
17
24
|
import { failFast } from '../errors/index.js';
|
|
18
25
|
import { loadEndpointConfig } from '../config/endpoints.js';
|
|
26
|
+
import { validateRequest, validateResponse, RequestSchemas, ResponseSchemas, } from '../contracts/validator.js';
|
|
19
27
|
// ============================================================================
|
|
20
28
|
// Plan Command Implementation
|
|
21
29
|
// ============================================================================
|
|
22
30
|
export async function executePlanCommand(input, options) {
|
|
23
31
|
const correlationId = options.trace_id ?? crypto.randomUUID();
|
|
24
32
|
const startTime = Date.now();
|
|
33
|
+
// ============================================================================
|
|
34
|
+
// CONTRACT VALIDATION - BEFORE ANY NETWORK CALL
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// Validate the top-level plan request
|
|
37
|
+
const validatedInput = validateRequest(RequestSchemas.PLAN, { query: input.manifestQuery, params: input.params }, correlationId);
|
|
25
38
|
// Initialize components
|
|
26
39
|
const engine = createOrchestrationEngine(correlationId);
|
|
27
40
|
const handoff = createArtifactHandoff();
|
|
@@ -37,24 +50,35 @@ export async function executePlanCommand(input, options) {
|
|
|
37
50
|
name: 'select-manifest',
|
|
38
51
|
adapter: manifestsAdapter,
|
|
39
52
|
request: {
|
|
40
|
-
endpoint: '/
|
|
53
|
+
endpoint: '/v1/manifests',
|
|
41
54
|
method: 'POST',
|
|
42
|
-
buildBody: () =>
|
|
55
|
+
buildBody: () => {
|
|
56
|
+
// Validate manifests request body before sending
|
|
57
|
+
const manifestsRequest = {
|
|
58
|
+
query: validatedInput.query,
|
|
59
|
+
};
|
|
60
|
+
validateRequest(RequestSchemas.MANIFESTS, manifestsRequest, correlationId);
|
|
61
|
+
return manifestsRequest;
|
|
62
|
+
},
|
|
43
63
|
},
|
|
44
64
|
},
|
|
45
65
|
{
|
|
46
66
|
name: 'create-plan',
|
|
47
67
|
adapter: plannerAdapter,
|
|
48
68
|
request: {
|
|
49
|
-
endpoint: '/
|
|
69
|
+
endpoint: '/v1/plans',
|
|
50
70
|
method: 'POST',
|
|
51
71
|
buildBody: (previousResults) => {
|
|
52
72
|
const manifestResult = previousResults.get('select-manifest');
|
|
53
|
-
|
|
54
|
-
|
|
73
|
+
// Validate manifest response has execution_metadata
|
|
74
|
+
const validatedManifest = validateResponse(ResponseSchemas.MANIFEST, manifestResult, correlationId);
|
|
75
|
+
const manifestRef = handoff.extractReference(validatedManifest);
|
|
76
|
+
// Build and validate plans request
|
|
77
|
+
const plansRequest = {
|
|
55
78
|
manifest_ref: manifestRef,
|
|
56
|
-
params:
|
|
79
|
+
params: validatedInput.params ?? {},
|
|
57
80
|
};
|
|
81
|
+
return plansRequest;
|
|
58
82
|
},
|
|
59
83
|
},
|
|
60
84
|
dependsOn: ['select-manifest'],
|
|
@@ -67,9 +91,12 @@ export async function executePlanCommand(input, options) {
|
|
|
67
91
|
const failedStage = result.stages.find(s => s.status === 'failed');
|
|
68
92
|
throw new Error(failedStage?.error?.message ?? 'Orchestration failed');
|
|
69
93
|
}
|
|
70
|
-
//
|
|
94
|
+
// ============================================================================
|
|
95
|
+
// RESPONSE VALIDATION - execution_metadata REQUIRED
|
|
96
|
+
// ============================================================================
|
|
71
97
|
const planStage = result.stages.find(s => s.name === 'create-plan');
|
|
72
|
-
const
|
|
98
|
+
const validatedPlan = validateResponse(ResponseSchemas.PLAN, planStage?.response, correlationId);
|
|
99
|
+
const planRef = handoff.extractReference(validatedPlan);
|
|
73
100
|
// Record audit entry
|
|
74
101
|
audit.record({
|
|
75
102
|
command: 'plan',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/commands/plan.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/commands/plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,EAC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ommandObject
|
|
8
|
-
* 2.
|
|
9
|
-
* 3.
|
|
10
|
-
* 4.
|
|
8
|
+
* 2. VALIDATE request against contract (MUST pass before network call)
|
|
9
|
+
* 3. Generate ROI report via enterprise-roi-engine
|
|
10
|
+
* 4. VALIDATE response has execution_metadata (reject if missing)
|
|
11
|
+
* 5. Record audit entry
|
|
12
|
+
* 6. Return RoiReportReference
|
|
11
13
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
+
* CONTRACT ENFORCEMENT:
|
|
15
|
+
* - Request validation happens BEFORE any network call
|
|
16
|
+
* - Response validation requires execution_metadata
|
|
17
|
+
* - No bypass flags or soft-fail behavior
|
|
14
18
|
*/
|
|
15
19
|
import type { CommandOptions, RoiReportReference, SimulationReference, RoiReportType, FlexibleInput } from '../types/index.js';
|
|
16
20
|
export interface QuantifyCommandInput {
|
|
17
21
|
simRef: FlexibleInput<SimulationReference>;
|
|
18
22
|
reportType?: RoiReportType;
|
|
19
|
-
|
|
23
|
+
timeHorizon?: 'quarterly' | 'annual' | '3-year' | '5-year';
|
|
24
|
+
currency?: string;
|
|
25
|
+
discountRate?: number;
|
|
20
26
|
}
|
|
21
27
|
export interface QuantifyCommandResult {
|
|
22
28
|
reference: RoiReportReference;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quantify.d.ts","sourceRoot":"","sources":["../../src/commands/quantify.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"quantify.d.ts","sourceRoot":"","sources":["../../src/commands/quantify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,aAAa,EAEd,MAAM,mBAAmB,CAAC;AAuB3B,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAC3C,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,WAAW,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAMD,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,qBAAqB,CAAC,CA6IhC"}
|
|
@@ -5,12 +5,16 @@
|
|
|
5
5
|
*
|
|
6
6
|
* FLOW:
|
|
7
7
|
* 1. Parse arguments → CommandObject
|
|
8
|
-
* 2.
|
|
9
|
-
* 3.
|
|
10
|
-
* 4.
|
|
8
|
+
* 2. VALIDATE request against contract (MUST pass before network call)
|
|
9
|
+
* 3. Generate ROI report via enterprise-roi-engine
|
|
10
|
+
* 4. VALIDATE response has execution_metadata (reject if missing)
|
|
11
|
+
* 5. Record audit entry
|
|
12
|
+
* 6. Return RoiReportReference
|
|
11
13
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
+
* CONTRACT ENFORCEMENT:
|
|
15
|
+
* - Request validation happens BEFORE any network call
|
|
16
|
+
* - Response validation requires execution_metadata
|
|
17
|
+
* - No bypass flags or soft-fail behavior
|
|
14
18
|
*/
|
|
15
19
|
import { isNaturalLanguage } from '../types/index.js';
|
|
16
20
|
import { RoiEngineAdapter } from '../adapters/base-adapter.js';
|
|
@@ -19,6 +23,7 @@ import { createArtifactHandoff } from '../modules/artifact-handoff.js';
|
|
|
19
23
|
import { createAuditTrail } from '../audit/audit-trail.js';
|
|
20
24
|
import { failFast } from '../errors/index.js';
|
|
21
25
|
import { loadEndpointConfig } from '../config/endpoints.js';
|
|
26
|
+
import { validateRequest, validateResponse, RequestSchemas, ResponseSchemas, } from '../contracts/validator.js';
|
|
22
27
|
// ============================================================================
|
|
23
28
|
// Quantify Command Implementation
|
|
24
29
|
// ============================================================================
|
|
@@ -40,16 +45,47 @@ export async function executeQuantifyCommand(input, options) {
|
|
|
40
45
|
name: 'generate-roi-report',
|
|
41
46
|
adapter: roiAdapter,
|
|
42
47
|
request: {
|
|
43
|
-
endpoint: '/
|
|
48
|
+
endpoint: '/v1/roi',
|
|
44
49
|
method: 'POST',
|
|
45
|
-
buildBody: () =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
buildBody: () => {
|
|
51
|
+
let requestBody;
|
|
52
|
+
if (isNaturalLanguage(input.simRef)) {
|
|
53
|
+
// ============================================================================
|
|
54
|
+
// CONTRACT VALIDATION - Natural language format
|
|
55
|
+
// ============================================================================
|
|
56
|
+
requestBody = {
|
|
57
|
+
sim_ref: {
|
|
58
|
+
natural_language: input.simRef.description,
|
|
59
|
+
},
|
|
60
|
+
report_type: reportType,
|
|
61
|
+
time_horizon: input.timeHorizon,
|
|
62
|
+
currency: input.currency,
|
|
63
|
+
discount_rate: input.discountRate,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// CONTRACT VALIDATION - Structured reference format
|
|
69
|
+
// ============================================================================
|
|
70
|
+
const simRef = input.simRef;
|
|
71
|
+
requestBody = {
|
|
72
|
+
sim_ref: {
|
|
73
|
+
id: simRef.id,
|
|
74
|
+
type: 'SimulationReference',
|
|
75
|
+
repository: simRef.repository,
|
|
76
|
+
created_at: simRef.created_at,
|
|
77
|
+
checksum: simRef.checksum,
|
|
78
|
+
},
|
|
79
|
+
report_type: reportType,
|
|
80
|
+
time_horizon: input.timeHorizon,
|
|
81
|
+
currency: input.currency,
|
|
82
|
+
discount_rate: input.discountRate,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// Validate request against contract BEFORE sending
|
|
86
|
+
validateRequest(RequestSchemas.QUANTIFY, requestBody, correlationId);
|
|
87
|
+
return requestBody;
|
|
88
|
+
},
|
|
53
89
|
},
|
|
54
90
|
},
|
|
55
91
|
];
|
|
@@ -60,16 +96,19 @@ export async function executeQuantifyCommand(input, options) {
|
|
|
60
96
|
const failedStage = result.stages.find(s => s.status === 'failed');
|
|
61
97
|
throw new Error(failedStage?.error?.message ?? 'ROI report generation failed');
|
|
62
98
|
}
|
|
63
|
-
//
|
|
99
|
+
// ============================================================================
|
|
100
|
+
// RESPONSE VALIDATION - execution_metadata REQUIRED
|
|
101
|
+
// ============================================================================
|
|
64
102
|
const roiStage = result.stages.find(s => s.name === 'generate-roi-report');
|
|
65
|
-
const
|
|
103
|
+
const validatedRoi = validateResponse(ResponseSchemas.ROI_REPORT, roiStage?.response, correlationId);
|
|
104
|
+
const roiRef = handoff.extractReference(validatedRoi);
|
|
66
105
|
// Record audit entry
|
|
67
106
|
const simRefId = isNaturalLanguage(input.simRef)
|
|
68
107
|
? `nl:${input.simRef.description.slice(0, 50)}`
|
|
69
108
|
: input.simRef.id;
|
|
70
109
|
audit.record({
|
|
71
110
|
command: 'quantify',
|
|
72
|
-
inputs: { simRef: simRefId, reportType
|
|
111
|
+
inputs: { simRef: simRefId, reportType },
|
|
73
112
|
outputs: roiRef,
|
|
74
113
|
dependencies: [
|
|
75
114
|
{ service: 'enterprise-roi-engine', method: 'generate', timestamp: new Date().toISOString(), duration_ms: result.timing.total, success: true },
|