@llm-dev-ops/agentics-cli 1.4.4 → 1.4.6
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/agents/cli-ux-agent.d.ts.map +1 -1
- package/dist/agents/cli-ux-agent.js +2 -1
- package/dist/agents/cli-ux-agent.js.map +1 -1
- package/dist/cli/index.js +132 -23
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/deploy.d.ts +4 -4
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +83 -21
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/erp.d.ts +1 -1
- package/dist/commands/erp.d.ts.map +1 -1
- package/dist/commands/erp.js +3 -5
- package/dist/commands/erp.js.map +1 -1
- package/dist/commands/export.d.ts +5 -5
- package/dist/commands/export.js +5 -5
- package/dist/commands/inspect.d.ts +28 -0
- package/dist/commands/inspect.d.ts.map +1 -1
- package/dist/commands/inspect.js +113 -0
- package/dist/commands/inspect.js.map +1 -1
- package/dist/commands/login.d.ts +8 -6
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +146 -89
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/plan.d.ts +8 -5
- package/dist/commands/plan.d.ts.map +1 -1
- package/dist/commands/plan.js +84 -60
- package/dist/commands/plan.js.map +1 -1
- package/dist/commands/policy.d.ts +53 -0
- package/dist/commands/policy.d.ts.map +1 -1
- package/dist/commands/policy.js +201 -5
- package/dist/commands/policy.js.map +1 -1
- package/dist/commands/quantify.d.ts +1 -1
- package/dist/commands/quantify.d.ts.map +1 -1
- package/dist/commands/quantify.js +2 -4
- package/dist/commands/quantify.js.map +1 -1
- package/dist/commands/simulate.d.ts +3 -2
- package/dist/commands/simulate.d.ts.map +1 -1
- package/dist/commands/simulate.js +97 -36
- package/dist/commands/simulate.js.map +1 -1
- package/dist/commands/usage.d.ts +3 -3
- package/dist/commands/usage.js +7 -7
- package/dist/commands/usage.js.map +1 -1
- package/dist/commands/whoami.d.ts +2 -0
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +25 -5
- package/dist/commands/whoami.js.map +1 -1
- package/dist/gates/auth-session-gate.d.ts +47 -0
- package/dist/gates/auth-session-gate.d.ts.map +1 -0
- package/dist/gates/auth-session-gate.js +151 -0
- package/dist/gates/auth-session-gate.js.map +1 -0
- package/dist/gates/execution-gate.d.ts +12 -17
- package/dist/gates/execution-gate.d.ts.map +1 -1
- package/dist/gates/execution-gate.js +74 -46
- package/dist/gates/execution-gate.js.map +1 -1
- package/dist/gates/index.d.ts +20 -2
- package/dist/gates/index.d.ts.map +1 -1
- package/dist/gates/index.js +24 -2
- package/dist/gates/index.js.map +1 -1
- package/dist/gates/output-format-gate.d.ts +54 -0
- package/dist/gates/output-format-gate.d.ts.map +1 -0
- package/dist/gates/output-format-gate.js +136 -0
- package/dist/gates/output-format-gate.js.map +1 -0
- package/dist/gates/service-health-gate.d.ts +56 -0
- package/dist/gates/service-health-gate.d.ts.map +1 -0
- package/dist/gates/service-health-gate.js +179 -0
- package/dist/gates/service-health-gate.js.map +1 -0
- package/dist/server/routes/auth.d.ts.map +1 -1
- package/dist/server/routes/auth.js +45 -8
- package/dist/server/routes/auth.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Execution Gate Module
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* PURPOSE: Global execution gate that prevents all operational commands from running
|
|
7
|
-
* unless execution is explicitly enabled. This is a binary gate enforced
|
|
8
|
-
* BEFORE any entitlement, usage, or billing logic.
|
|
4
|
+
* PURPOSE: Global execution gate that controls command access based on
|
|
5
|
+
* user entitlement (internal email or paid API key).
|
|
9
6
|
*
|
|
10
7
|
* ENTITLEMENTS:
|
|
11
8
|
* - "internal" - Internal maintainers (allow-listed by email)
|
|
12
|
-
* -
|
|
13
|
-
*
|
|
14
|
-
* FORBIDDEN:
|
|
15
|
-
* - Consulting usage or billing for internal users
|
|
16
|
-
* - Allowing partial execution
|
|
17
|
-
* - Allowing "free tier" commands
|
|
9
|
+
* - "paid" - Users with a valid API key
|
|
10
|
+
* - "none" - No entitlement, blocked from operational commands
|
|
18
11
|
*
|
|
19
|
-
*
|
|
12
|
+
* LOGIC:
|
|
13
|
+
* - Identity commands (login, logout, whoami, help, version) always allowed
|
|
14
|
+
* - Internal or paid users get full access to all commands
|
|
15
|
+
* - Users with no entitlement are blocked
|
|
20
16
|
*/
|
|
21
17
|
import * as fs from 'node:fs';
|
|
22
18
|
import * as path from 'node:path';
|
|
@@ -27,16 +23,7 @@ import { getActiveAccount } from '../auth/gcp-identity.js';
|
|
|
27
23
|
// Execution Gate Configuration
|
|
28
24
|
// ============================================================================
|
|
29
25
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* To enable execution, set environment variable:
|
|
33
|
-
* AGENTICS_EXECUTION_ENABLED=true
|
|
34
|
-
*
|
|
35
|
-
* This gate decides IF execution is possible at all.
|
|
36
|
-
*/
|
|
37
|
-
const EXECUTION_ENABLED = process.env.AGENTICS_EXECUTION_ENABLED === 'true';
|
|
38
|
-
/**
|
|
39
|
-
* Commands that are ALWAYS allowed, regardless of execution gate status.
|
|
26
|
+
* Commands that are ALWAYS allowed, regardless of entitlement.
|
|
40
27
|
* These are identity and help commands only.
|
|
41
28
|
*/
|
|
42
29
|
const ALLOWED_COMMANDS = new Set([
|
|
@@ -47,14 +34,9 @@ const ALLOWED_COMMANDS = new Set([
|
|
|
47
34
|
'version',
|
|
48
35
|
]);
|
|
49
36
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* Users with emails in this list are granted the "internal" entitlement,
|
|
53
|
-
* which allows full CLI execution without payment verification.
|
|
54
|
-
*
|
|
55
|
-
* This is a first-class entitlement, not a bypass or debug shortcut.
|
|
37
|
+
* Default internal emails (fallback if config file doesn't exist).
|
|
56
38
|
*/
|
|
57
|
-
const
|
|
39
|
+
const DEFAULT_INTERNAL_EMAILS = [
|
|
58
40
|
'nick@nicholasruest.com',
|
|
59
41
|
'sales@globalbusinessadvisors.co',
|
|
60
42
|
'nicholasruest1@gmail.com',
|
|
@@ -63,7 +45,44 @@ const INTERNAL_EMAILS = new Set([
|
|
|
63
45
|
'ruv@agentics.org',
|
|
64
46
|
'cvsrohit@gmail.com',
|
|
65
47
|
'rishubcheddlla@gmail.com',
|
|
66
|
-
]
|
|
48
|
+
];
|
|
49
|
+
/**
|
|
50
|
+
* Load internal emails from config file or use defaults.
|
|
51
|
+
* Config file: ~/.agentics/internal-users.json
|
|
52
|
+
* Format: { "emails": ["email1@example.com", "email2@example.com"] }
|
|
53
|
+
*/
|
|
54
|
+
function loadInternalEmails() {
|
|
55
|
+
try {
|
|
56
|
+
const configPath = path.join(os.homedir(), '.agentics', 'internal-users.json');
|
|
57
|
+
if (fs.existsSync(configPath)) {
|
|
58
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
59
|
+
const config = JSON.parse(content);
|
|
60
|
+
if (Array.isArray(config.emails)) {
|
|
61
|
+
return new Set(config.emails.map((e) => e.toLowerCase()));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// Config file doesn't exist or is invalid, use defaults
|
|
67
|
+
}
|
|
68
|
+
// Create default config file if it doesn't exist
|
|
69
|
+
try {
|
|
70
|
+
const configDir = path.join(os.homedir(), '.agentics');
|
|
71
|
+
const configPath = path.join(configDir, 'internal-users.json');
|
|
72
|
+
if (!fs.existsSync(configPath)) {
|
|
73
|
+
if (!fs.existsSync(configDir)) {
|
|
74
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
75
|
+
}
|
|
76
|
+
fs.writeFileSync(configPath, JSON.stringify({ emails: DEFAULT_INTERNAL_EMAILS }, null, 2));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
// Failed to create config file, continue with defaults
|
|
81
|
+
}
|
|
82
|
+
return new Set(DEFAULT_INTERNAL_EMAILS.map(e => e.toLowerCase()));
|
|
83
|
+
}
|
|
84
|
+
// Load internal emails once at startup
|
|
85
|
+
const INTERNAL_EMAILS = loadInternalEmails();
|
|
67
86
|
/**
|
|
68
87
|
* Resolve the entitlement for the currently authenticated user.
|
|
69
88
|
*
|
|
@@ -80,28 +99,37 @@ export function resolveEntitlement() {
|
|
|
80
99
|
if (envEmail && INTERNAL_EMAILS.has(envEmail.toLowerCase())) {
|
|
81
100
|
return 'internal';
|
|
82
101
|
}
|
|
83
|
-
// Check stored credentials for email
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
102
|
+
// Check stored credentials for email and payment status
|
|
103
|
+
const storedCreds = getStoredCredentials();
|
|
104
|
+
if (storedCreds?.email && INTERNAL_EMAILS.has(storedCreds.email.toLowerCase())) {
|
|
86
105
|
return 'internal';
|
|
87
106
|
}
|
|
107
|
+
// Check if API key holder has paid status
|
|
108
|
+
if (storedCreds?.api_key && storedCreds.payment_status === 'paid') {
|
|
109
|
+
return 'paid';
|
|
110
|
+
}
|
|
88
111
|
// Fall back to gcloud account
|
|
89
112
|
const account = getActiveAccount();
|
|
90
113
|
if (account && INTERNAL_EMAILS.has(account.toLowerCase())) {
|
|
91
114
|
return 'internal';
|
|
92
115
|
}
|
|
93
|
-
//
|
|
116
|
+
// If user has a valid API key, treat as paid (API keys are issued to paying users)
|
|
117
|
+
if (storedCreds?.api_key) {
|
|
118
|
+
return 'paid';
|
|
119
|
+
}
|
|
94
120
|
return 'none';
|
|
95
121
|
}
|
|
96
122
|
/**
|
|
97
|
-
* Read
|
|
123
|
+
* Read stored credentials (sync).
|
|
98
124
|
*/
|
|
99
|
-
function
|
|
125
|
+
function getStoredCredentials() {
|
|
100
126
|
try {
|
|
101
127
|
const credPath = path.join(os.homedir(), '.agentics', 'credentials.json');
|
|
102
128
|
const content = fs.readFileSync(credPath, 'utf-8');
|
|
103
129
|
const creds = JSON.parse(content);
|
|
104
|
-
|
|
130
|
+
if (!creds.api_key)
|
|
131
|
+
return null;
|
|
132
|
+
return creds;
|
|
105
133
|
}
|
|
106
134
|
catch {
|
|
107
135
|
return null;
|
|
@@ -136,9 +164,8 @@ Contact the Agentics team to enable execution.
|
|
|
136
164
|
* Execution flow:
|
|
137
165
|
* 1. Always allow identity and help commands
|
|
138
166
|
* 2. Resolve user entitlement
|
|
139
|
-
* 3. If entitlement === "internal" → allow execution
|
|
140
|
-
* 4.
|
|
141
|
-
* 5. Otherwise → block execution
|
|
167
|
+
* 3. If entitlement === "internal" or "paid" → allow execution
|
|
168
|
+
* 4. Otherwise → block execution
|
|
142
169
|
*
|
|
143
170
|
* @param command - The command name (e.g., 'plan', 'simulate', 'login')
|
|
144
171
|
* @returns ExecutionGateResult indicating if execution is allowed
|
|
@@ -150,12 +177,12 @@ export function checkExecutionGate(command) {
|
|
|
150
177
|
}
|
|
151
178
|
// Resolve entitlement before applying execution gate
|
|
152
179
|
const entitlement = resolveEntitlement();
|
|
153
|
-
// Internal users have full access
|
|
180
|
+
// Internal users have full access
|
|
154
181
|
if (entitlement === 'internal') {
|
|
155
182
|
return { allowed: true };
|
|
156
183
|
}
|
|
157
|
-
//
|
|
158
|
-
if (
|
|
184
|
+
// Paid users have full access
|
|
185
|
+
if (entitlement === 'paid') {
|
|
159
186
|
return { allowed: true };
|
|
160
187
|
}
|
|
161
188
|
// Block all other commands
|
|
@@ -178,12 +205,13 @@ export function enforceExecutionGate(command) {
|
|
|
178
205
|
}
|
|
179
206
|
}
|
|
180
207
|
/**
|
|
181
|
-
* Check if execution is
|
|
208
|
+
* Check if execution is enabled for the current user.
|
|
182
209
|
*
|
|
183
|
-
* @returns true if
|
|
210
|
+
* @returns true if the user has internal or paid entitlement
|
|
184
211
|
*/
|
|
185
212
|
export function isExecutionEnabled() {
|
|
186
|
-
|
|
213
|
+
const entitlement = resolveEntitlement();
|
|
214
|
+
return entitlement === 'internal' || entitlement === 'paid';
|
|
187
215
|
}
|
|
188
216
|
/**
|
|
189
217
|
* Get the list of commands that are always allowed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-gate.js","sourceRoot":"","sources":["../../src/gates/execution-gate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"execution-gate.js","sourceRoot":"","sources":["../../src/gates/execution-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,+EAA+E;AAC/E,+BAA+B;AAC/B,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,SAAS;CACV,CAAC,CAAC;AAWH;;GAEG;AACH,MAAM,uBAAuB,GAAG;IAC9B,wBAAwB;IACxB,iCAAiC;IACjC,0BAA0B;IAC1B,yBAAyB;IACzB,aAAa;IACb,kBAAkB;IAClB,oBAAoB;IACpB,0BAA0B;CAC3B,CAAC;AAEF;;;;GAIG;AACH,SAAS,kBAAkB;IACzB,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,qBAAqB,CAAC,CAAC;QAC/E,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9B,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YACrD,MAAM,MAAM,GAAG,I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,UAAU,kBAAkB;IAChC,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAC;IACzC,OAAO,WAAW,KAAK,UAAU,IAAI,WAAW,KAAK,MAAM,CAAC;AAC9D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
package/dist/gates/index.d.ts
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Gates
|
|
2
|
+
* Control Plane Hardening Gates Index
|
|
3
3
|
*
|
|
4
4
|
* Centralized execution control for the Agentics CLI.
|
|
5
5
|
* This module contains all gate logic for controlling command execution.
|
|
6
|
+
*
|
|
7
|
+
* GATE ENFORCEMENT ORDER:
|
|
8
|
+
* 1. Execution Gate - Kill-switch (entitlement check)
|
|
9
|
+
* 2. Auth Session Gate - Requires authenticated session
|
|
10
|
+
* 3. Service Health Gate - Validates Ruvector-backed service availability
|
|
11
|
+
* 4. Output Format Gate - Enforces strict JSON output
|
|
12
|
+
*
|
|
13
|
+
* CRITICAL REQUIREMENTS MET:
|
|
14
|
+
* - CLI requires Ruvector-backed services (Service Health Gate)
|
|
15
|
+
* - CLI never executes agents locally (Localhost Safeguard in endpoints.ts)
|
|
16
|
+
* - CLI fails loudly if services misconfigured (All gates fail-fast)
|
|
17
|
+
* - Requires authenticated session (Auth Session Gate)
|
|
18
|
+
* - Validates target service availability (Service Health Gate)
|
|
19
|
+
* - Enforces strict JSON outputs (Output Format Gate)
|
|
20
|
+
* - Never allows narrative output (Output Format Gate)
|
|
6
21
|
*/
|
|
7
|
-
export { checkExecutionGate, enforceExecutionGate, isExecutionEnabled, getAllowedCommands, EXECUTION_BLOCKED_EXIT_CODE, type ExecutionGateResult, } from './execution-gate.js';
|
|
22
|
+
export { checkExecutionGate, enforceExecutionGate, isExecutionEnabled, getAllowedCommands, resolveEntitlement, EXECUTION_BLOCKED_EXIT_CODE, type ExecutionGateResult, type Entitlement, } from './execution-gate.js';
|
|
23
|
+
export { enforceAuthSessionGate, checkAuthSessionGate, requiresAuthentication, AUTH_REQUIRED_EXIT_CODE, AuthSessionRequiredError, type AuthSessionGateResult, } from './auth-session-gate.js';
|
|
24
|
+
export { enforceServiceHealthGate, checkServiceHealthGate, requiresHealthCheck, SERVICE_UNAVAILABLE_EXIT_CODE, ServiceHealthError, type ServiceHealthResult, type ServiceHealthGateResult, } from './service-health-gate.js';
|
|
25
|
+
export { enforceOutputFormatGate, checkOutputFormatGate, requiresStructuredOutput, getDefaultFormat, INVALID_FORMAT_EXIT_CODE, InvalidOutputFormatError, type OutputFormatGateResult, } from './output-format-gate.js';
|
|
8
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gates/index.ts"],"names":[],"mappings":"AAAA
|
|
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"}
|
package/dist/gates/index.js
CHANGED
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Gates
|
|
2
|
+
* Control Plane Hardening Gates Index
|
|
3
3
|
*
|
|
4
4
|
* Centralized execution control for the Agentics CLI.
|
|
5
5
|
* This module contains all gate logic for controlling command execution.
|
|
6
|
+
*
|
|
7
|
+
* GATE ENFORCEMENT ORDER:
|
|
8
|
+
* 1. Execution Gate - Kill-switch (entitlement check)
|
|
9
|
+
* 2. Auth Session Gate - Requires authenticated session
|
|
10
|
+
* 3. Service Health Gate - Validates Ruvector-backed service availability
|
|
11
|
+
* 4. Output Format Gate - Enforces strict JSON output
|
|
12
|
+
*
|
|
13
|
+
* CRITICAL REQUIREMENTS MET:
|
|
14
|
+
* - CLI requires Ruvector-backed services (Service Health Gate)
|
|
15
|
+
* - CLI never executes agents locally (Localhost Safeguard in endpoints.ts)
|
|
16
|
+
* - CLI fails loudly if services misconfigured (All gates fail-fast)
|
|
17
|
+
* - Requires authenticated session (Auth Session Gate)
|
|
18
|
+
* - Validates target service availability (Service Health Gate)
|
|
19
|
+
* - Enforces strict JSON outputs (Output Format Gate)
|
|
20
|
+
* - Never allows narrative output (Output Format Gate)
|
|
6
21
|
*/
|
|
7
|
-
|
|
22
|
+
// Execution Gate - Hard kill-switch
|
|
23
|
+
export { checkExecutionGate, enforceExecutionGate, isExecutionEnabled, getAllowedCommands, resolveEntitlement, EXECUTION_BLOCKED_EXIT_CODE, } from './execution-gate.js';
|
|
24
|
+
// Auth Session Gate - Requires authenticated session
|
|
25
|
+
export { enforceAuthSessionGate, checkAuthSessionGate, requiresAuthentication, AUTH_REQUIRED_EXIT_CODE, AuthSessionRequiredError, } from './auth-session-gate.js';
|
|
26
|
+
// Service Health Gate - Validates Ruvector-backed services
|
|
27
|
+
export { enforceServiceHealthGate, checkServiceHealthGate, requiresHealthCheck, SERVICE_UNAVAILABLE_EXIT_CODE, ServiceHealthError, } from './service-health-gate.js';
|
|
28
|
+
// Output Format Gate - Enforces strict JSON output
|
|
29
|
+
export { enforceOutputFormatGate, checkOutputFormatGate, requiresStructuredOutput, getDefaultFormat, INVALID_FORMAT_EXIT_CODE, InvalidOutputFormatError, } from './output-format-gate.js';
|
|
8
30
|
//# sourceMappingURL=index.js.map
|
package/dist/gates/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gates/index.ts"],"names":[],"mappings":"AAAA
|
|
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"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Format Gate Module
|
|
3
|
+
*
|
|
4
|
+
* CONTROL PLANE HARDENING
|
|
5
|
+
*
|
|
6
|
+
* PURPOSE: Enforce strict JSON-only output for CLI operations.
|
|
7
|
+
* CLI MUST NOT produce narrative output for operational commands.
|
|
8
|
+
*
|
|
9
|
+
* CRITICAL REQUIREMENTS:
|
|
10
|
+
* - Enforce strict JSON outputs
|
|
11
|
+
* - Never allow narrative output
|
|
12
|
+
* - Validate output format before rendering
|
|
13
|
+
*
|
|
14
|
+
* FORBIDDEN:
|
|
15
|
+
* - Narrative/prose output
|
|
16
|
+
* - Unstructured text responses
|
|
17
|
+
* - Human-readable summaries (for operational commands)
|
|
18
|
+
*/
|
|
19
|
+
import { type OutputFormat } from '../types/index.js';
|
|
20
|
+
/**
|
|
21
|
+
* Exit code for invalid output format.
|
|
22
|
+
*/
|
|
23
|
+
export declare const INVALID_FORMAT_EXIT_CODE: 65;
|
|
24
|
+
export declare class InvalidOutputFormatError extends Error {
|
|
25
|
+
readonly requestedFormat: string;
|
|
26
|
+
readonly allowedFormats: string[];
|
|
27
|
+
constructor(requestedFormat: string, allowedFormats: string[]);
|
|
28
|
+
}
|
|
29
|
+
export interface OutputFormatGateResult {
|
|
30
|
+
valid: boolean;
|
|
31
|
+
format: OutputFormat;
|
|
32
|
+
exitCode?: number;
|
|
33
|
+
message?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validate the requested output format.
|
|
37
|
+
* Only structured formats (json, yaml) are allowed for operational commands.
|
|
38
|
+
*/
|
|
39
|
+
export declare function checkOutputFormatGate(requestedFormat: OutputFormat | undefined, command: string): OutputFormatGateResult;
|
|
40
|
+
/**
|
|
41
|
+
* Enforce the output format gate.
|
|
42
|
+
* Exits the process if an invalid format is requested.
|
|
43
|
+
*/
|
|
44
|
+
export declare function enforceOutputFormatGate(requestedFormat: OutputFormat | undefined, command: string): OutputFormat;
|
|
45
|
+
/**
|
|
46
|
+
* Check if a command requires structured output.
|
|
47
|
+
*/
|
|
48
|
+
export declare function requiresStructuredOutput(command: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Get the default output format for a command.
|
|
51
|
+
* Always returns 'json' for operational commands.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getDefaultFormat(command: string): OutputFormat;
|
|
54
|
+
//# sourceMappingURL=output-format-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-format-gate.d.ts","sourceRoot":"","sources":["../../src/gates/output-format-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAelE;;GAEG;AACH,eAAO,MAAM,wBAAwB,IAA+B,CAAC;AAMrE,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;gBAEtB,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE;CA0B9D;AAMD,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAMD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,YAAY,GAAG,SAAS,EACzC,OAAO,EAAE,MAAM,GACd,sBAAsB,CAmBxB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,eAAe,EAAE,YAAY,GAAG,SAAS,EACzC,OAAO,EAAE,MAAM,GACd,YAAY,CASd;AAoBD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAK9D"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Format Gate Module
|
|
3
|
+
*
|
|
4
|
+
* CONTROL PLANE HARDENING
|
|
5
|
+
*
|
|
6
|
+
* PURPOSE: Enforce strict JSON-only output for CLI operations.
|
|
7
|
+
* CLI MUST NOT produce narrative output for operational commands.
|
|
8
|
+
*
|
|
9
|
+
* CRITICAL REQUIREMENTS:
|
|
10
|
+
* - Enforce strict JSON outputs
|
|
11
|
+
* - Never allow narrative output
|
|
12
|
+
* - Validate output format before rendering
|
|
13
|
+
*
|
|
14
|
+
* FORBIDDEN:
|
|
15
|
+
* - Narrative/prose output
|
|
16
|
+
* - Unstructured text responses
|
|
17
|
+
* - Human-readable summaries (for operational commands)
|
|
18
|
+
*/
|
|
19
|
+
import { EXIT_CODES } from '../types/index.js';
|
|
20
|
+
// ============================================================================
|
|
21
|
+
// Output Format Gate Configuration
|
|
22
|
+
// ============================================================================
|
|
23
|
+
/**
|
|
24
|
+
* Allowed output formats for operational commands.
|
|
25
|
+
* Only structured formats are permitted.
|
|
26
|
+
*/
|
|
27
|
+
const ALLOWED_STRUCTURED_FORMATS = new Set([
|
|
28
|
+
'json',
|
|
29
|
+
'yaml',
|
|
30
|
+
]);
|
|
31
|
+
/**
|
|
32
|
+
* Exit code for invalid output format.
|
|
33
|
+
*/
|
|
34
|
+
export const INVALID_FORMAT_EXIT_CODE = EXIT_CODES.DATA_FORMAT_ERROR;
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// Output Format Gate Error
|
|
37
|
+
// ============================================================================
|
|
38
|
+
export class InvalidOutputFormatError extends Error {
|
|
39
|
+
requestedFormat;
|
|
40
|
+
allowedFormats;
|
|
41
|
+
constructor(requestedFormat, allowedFormats) {
|
|
42
|
+
super(`\n` +
|
|
43
|
+
`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` +
|
|
44
|
+
` INVALID OUTPUT FORMAT\n` +
|
|
45
|
+
`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` +
|
|
46
|
+
`\n` +
|
|
47
|
+
` Requested format: ${requestedFormat}\n` +
|
|
48
|
+
` Allowed formats: ${allowedFormats.join(', ')}\n` +
|
|
49
|
+
`\n` +
|
|
50
|
+
` The CLI enforces strict JSON output for operational commands.\n` +
|
|
51
|
+
` Narrative output formats are not permitted.\n` +
|
|
52
|
+
`\n` +
|
|
53
|
+
` TO FIX:\n` +
|
|
54
|
+
`\n` +
|
|
55
|
+
` Use --format json (default) or --format yaml\n` +
|
|
56
|
+
`\n` +
|
|
57
|
+
` Example:\n` +
|
|
58
|
+
` agentics plan "my plan" --format json\n` +
|
|
59
|
+
`\n` +
|
|
60
|
+
`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`);
|
|
61
|
+
this.name = 'InvalidOutputFormatError';
|
|
62
|
+
this.requestedFormat = requestedFormat;
|
|
63
|
+
this.allowedFormats = allowedFormats;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// ============================================================================
|
|
67
|
+
// Output Format Gate Implementation
|
|
68
|
+
// ============================================================================
|
|
69
|
+
/**
|
|
70
|
+
* Validate the requested output format.
|
|
71
|
+
* Only structured formats (json, yaml) are allowed for operational commands.
|
|
72
|
+
*/
|
|
73
|
+
export function checkOutputFormatGate(requestedFormat, command) {
|
|
74
|
+
// Default to JSON if no format specified
|
|
75
|
+
const format = requestedFormat ?? 'json';
|
|
76
|
+
// Check if format is allowed
|
|
77
|
+
if (requiresStructuredOutput(command) && !ALLOWED_STRUCTURED_FORMATS.has(format)) {
|
|
78
|
+
const allowedFormats = Array.from(ALLOWED_STRUCTURED_FORMATS);
|
|
79
|
+
return {
|
|
80
|
+
valid: false,
|
|
81
|
+
format,
|
|
82
|
+
exitCode: INVALID_FORMAT_EXIT_CODE,
|
|
83
|
+
message: new InvalidOutputFormatError(format, allowedFormats).message,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
valid: true,
|
|
88
|
+
format,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Enforce the output format gate.
|
|
93
|
+
* Exits the process if an invalid format is requested.
|
|
94
|
+
*/
|
|
95
|
+
export function enforceOutputFormatGate(requestedFormat, command) {
|
|
96
|
+
const result = checkOutputFormatGate(requestedFormat, command);
|
|
97
|
+
if (!result.valid) {
|
|
98
|
+
console.error(result.message);
|
|
99
|
+
process.exit(result.exitCode);
|
|
100
|
+
}
|
|
101
|
+
return result.format;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Commands that require structured (JSON/YAML) output.
|
|
105
|
+
* All operational commands require structured output.
|
|
106
|
+
* Identity and meta commands can use any format.
|
|
107
|
+
*/
|
|
108
|
+
const STRUCTURED_OUTPUT_COMMANDS = new Set([
|
|
109
|
+
'plan',
|
|
110
|
+
'simulate',
|
|
111
|
+
'inspect',
|
|
112
|
+
'quantify',
|
|
113
|
+
'deploy',
|
|
114
|
+
'export',
|
|
115
|
+
'diligence',
|
|
116
|
+
'usage',
|
|
117
|
+
'policy',
|
|
118
|
+
'erp',
|
|
119
|
+
]);
|
|
120
|
+
/**
|
|
121
|
+
* Check if a command requires structured output.
|
|
122
|
+
*/
|
|
123
|
+
export function requiresStructuredOutput(command) {
|
|
124
|
+
return STRUCTURED_OUTPUT_COMMANDS.has(command);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Get the default output format for a command.
|
|
128
|
+
* Always returns 'json' for operational commands.
|
|
129
|
+
*/
|
|
130
|
+
export function getDefaultFormat(command) {
|
|
131
|
+
if (requiresStructuredOutput(command)) {
|
|
132
|
+
return 'json';
|
|
133
|
+
}
|
|
134
|
+
return 'text';
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=output-format-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-format-gate.js","sourceRoot":"","sources":["../../src/gates/output-format-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAqB,MAAM,m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: Validate Ruvector-backed service availability before ANY remote execution.
|
|
7
|
+
* This gate ensures the CLI NEVER executes against misconfigured or unavailable services.
|
|
8
|
+
*
|
|
9
|
+
* CRITICAL REQUIREMENTS:
|
|
10
|
+
* - CLI MUST require Ruvector-backed services
|
|
11
|
+
* - CLI MUST fail loudly if services are misconfigured
|
|
12
|
+
* - Abort command if health check fails
|
|
13
|
+
*
|
|
14
|
+
* FORBIDDEN:
|
|
15
|
+
* - Fallback behavior
|
|
16
|
+
* - Local caching of results
|
|
17
|
+
* - Silent failures
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Exit code for service unavailable.
|
|
21
|
+
*/
|
|
22
|
+
export declare const SERVICE_UNAVAILABLE_EXIT_CODE: 69;
|
|
23
|
+
export declare class ServiceHealthError extends Error {
|
|
24
|
+
readonly serviceName: string;
|
|
25
|
+
readonly healthCheckUrl: string;
|
|
26
|
+
readonly cause?: Error;
|
|
27
|
+
constructor(serviceName: string, healthCheckUrl: string, cause?: Error);
|
|
28
|
+
}
|
|
29
|
+
export interface ServiceHealthResult {
|
|
30
|
+
healthy: boolean;
|
|
31
|
+
service: string;
|
|
32
|
+
url: string;
|
|
33
|
+
latency?: number;
|
|
34
|
+
error?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ServiceHealthGateResult {
|
|
37
|
+
passed: boolean;
|
|
38
|
+
results: ServiceHealthResult[];
|
|
39
|
+
exitCode?: number;
|
|
40
|
+
message?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Check if all critical services are healthy.
|
|
44
|
+
* Returns a structured result - does not exit the process.
|
|
45
|
+
*/
|
|
46
|
+
export declare function checkServiceHealthGate(): Promise<ServiceHealthGateResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Enforce the service health gate. Exits the process if any critical service is unhealthy.
|
|
49
|
+
* This is the HARD gate that blocks all operations if services are misconfigured.
|
|
50
|
+
*/
|
|
51
|
+
export declare function enforceServiceHealthGate(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Check if a command requires service health check.
|
|
54
|
+
*/
|
|
55
|
+
export declare function requiresHealthCheck(command: string): boolean;
|
|
56
|
+
//# sourceMappingURL=service-health-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-health-gate.d.ts","sourceRoot":"","sources":["../../src/gates/service-health-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAsBH;;GAEG;AACH,eAAO,MAAM,6BAA6B,IAAiC,CAAC;AAM5E,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;gBAEX,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAoCvE;AAMD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA4CD;;;GAGG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAgC/E;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CAO9D;AAoBD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE5D"}
|