@llm-dev-ops/agentics-cli 1.4.1 → 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/adapters/base-adapter.d.ts.map +1 -1
- package/dist/adapters/base-adapter.js +2 -41
- package/dist/adapters/base-adapter.js.map +1 -1
- 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 +155 -38
- 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
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication Session Gate Module
|
|
3
|
+
*
|
|
4
|
+
* CONTROL PLANE HARDENING
|
|
5
|
+
*
|
|
6
|
+
* PURPOSE: Enforce authenticated session requirement for ALL operational commands.
|
|
7
|
+
* CLI MUST require valid authentication before invoking remote services.
|
|
8
|
+
*
|
|
9
|
+
* CRITICAL REQUIREMENTS:
|
|
10
|
+
* - CLI requires authenticated session
|
|
11
|
+
* - No anonymous operations allowed
|
|
12
|
+
* - Clear error messaging for auth failures
|
|
13
|
+
*
|
|
14
|
+
* FORBIDDEN:
|
|
15
|
+
* - Fallback to anonymous access
|
|
16
|
+
* - Silent auth bypass
|
|
17
|
+
* - Local execution fallback
|
|
18
|
+
*/
|
|
19
|
+
import { hasValidCredentials, getActiveAccount } from '../auth/gcp-identity.js';
|
|
20
|
+
import { createCredentialStore } from '../utils/credentials.js';
|
|
21
|
+
import { EXIT_CODES } from '../types/index.js';
|
|
22
|
+
// ============================================================================
|
|
23
|
+
// Authentication Gate Configuration
|
|
24
|
+
// ============================================================================
|
|
25
|
+
/**
|
|
26
|
+
* Exit code for authentication required.
|
|
27
|
+
*/
|
|
28
|
+
export const AUTH_REQUIRED_EXIT_CODE = EXIT_CODES.AUTH_ERROR;
|
|
29
|
+
// ============================================================================
|
|
30
|
+
// Authentication Gate Error
|
|
31
|
+
// ============================================================================
|
|
32
|
+
export class AuthSessionRequiredError extends Error {
|
|
33
|
+
constructor() {
|
|
34
|
+
super(`\n` +
|
|
35
|
+
`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` +
|
|
36
|
+
` AUTHENTICATION REQUIRED\n` +
|
|
37
|
+
`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n` +
|
|
38
|
+
`\n` +
|
|
39
|
+
` The CLI requires an authenticated session to execute this command.\n` +
|
|
40
|
+
` No valid credentials were found.\n` +
|
|
41
|
+
`\n` +
|
|
42
|
+
` TO AUTHENTICATE:\n` +
|
|
43
|
+
`\n` +
|
|
44
|
+
` Option 1: Platform login (recommended)\n` +
|
|
45
|
+
` agentics login\n` +
|
|
46
|
+
`\n` +
|
|
47
|
+
` Option 2: GCP authentication\n` +
|
|
48
|
+
` gcloud auth login\n` +
|
|
49
|
+
`\n` +
|
|
50
|
+
` After authenticating, re-run your command.\n` +
|
|
51
|
+
`\n` +
|
|
52
|
+
`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`);
|
|
53
|
+
this.name = 'AuthSessionRequiredError';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// ============================================================================
|
|
57
|
+
// Authentication Gate Implementation
|
|
58
|
+
// ============================================================================
|
|
59
|
+
/**
|
|
60
|
+
* Check if user has valid platform credentials.
|
|
61
|
+
*/
|
|
62
|
+
async function hasPlatformCredentials() {
|
|
63
|
+
try {
|
|
64
|
+
const store = createCredentialStore();
|
|
65
|
+
const credentials = await store.load();
|
|
66
|
+
if (credentials && credentials.api_key) {
|
|
67
|
+
return { valid: true, email: credentials.email };
|
|
68
|
+
}
|
|
69
|
+
return { valid: false };
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return { valid: false };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Check if user has valid GCP credentials.
|
|
77
|
+
*/
|
|
78
|
+
function hasGcpCredentials() {
|
|
79
|
+
const hasCredentials = hasValidCredentials();
|
|
80
|
+
if (hasCredentials) {
|
|
81
|
+
const account = getActiveAccount();
|
|
82
|
+
return { valid: true, account: account ?? undefined };
|
|
83
|
+
}
|
|
84
|
+
return { valid: false };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Check if user has valid authentication.
|
|
88
|
+
* Checks both platform credentials and GCP credentials.
|
|
89
|
+
*/
|
|
90
|
+
export async function checkAuthSessionGate() {
|
|
91
|
+
// Check platform credentials first
|
|
92
|
+
const platformAuth = await hasPlatformCredentials();
|
|
93
|
+
if (platformAuth.valid) {
|
|
94
|
+
return {
|
|
95
|
+
authenticated: true,
|
|
96
|
+
method: 'platform',
|
|
97
|
+
account: platformAuth.email,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
// Fall back to GCP credentials
|
|
101
|
+
const gcpAuth = hasGcpCredentials();
|
|
102
|
+
if (gcpAuth.valid) {
|
|
103
|
+
return {
|
|
104
|
+
authenticated: true,
|
|
105
|
+
method: 'gcp',
|
|
106
|
+
account: gcpAuth.account,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
// No valid credentials found
|
|
110
|
+
return {
|
|
111
|
+
authenticated: false,
|
|
112
|
+
exitCode: AUTH_REQUIRED_EXIT_CODE,
|
|
113
|
+
message: new AuthSessionRequiredError().message,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Enforce the authentication session gate.
|
|
118
|
+
* Exits the process if no valid authentication is found.
|
|
119
|
+
*/
|
|
120
|
+
export async function enforceAuthSessionGate() {
|
|
121
|
+
const result = await checkAuthSessionGate();
|
|
122
|
+
if (!result.authenticated) {
|
|
123
|
+
console.error(result.message);
|
|
124
|
+
process.exit(result.exitCode);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Commands that require authentication.
|
|
129
|
+
* All operational commands require authentication.
|
|
130
|
+
* Only login, whoami, help, and version are allowed without authentication.
|
|
131
|
+
*/
|
|
132
|
+
const AUTH_REQUIRED_COMMANDS = new Set([
|
|
133
|
+
'plan',
|
|
134
|
+
'simulate',
|
|
135
|
+
'inspect',
|
|
136
|
+
'quantify',
|
|
137
|
+
'deploy',
|
|
138
|
+
'export',
|
|
139
|
+
'diligence',
|
|
140
|
+
'usage',
|
|
141
|
+
'policy',
|
|
142
|
+
'erp',
|
|
143
|
+
'logout',
|
|
144
|
+
]);
|
|
145
|
+
/**
|
|
146
|
+
* Check if a command requires authentication.
|
|
147
|
+
*/
|
|
148
|
+
export function requiresAuthentication(command) {
|
|
149
|
+
return AUTH_REQUIRED_COMMANDS.has(command);
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=auth-session-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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AAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,MAAM;IACN,UAAU;IACV,SAAS;IACT,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,OAAO;IACP,QAAQ;IACR,KAAK;IACL,QAAQ;CACT,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,OAAO,sBAAsB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -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
|
/**
|
|
22
18
|
* Entitlement types supported by the execution gate.
|
|
@@ -55,9 +51,8 @@ export interface ExecutionGateResult {
|
|
|
55
51
|
* Execution flow:
|
|
56
52
|
* 1. Always allow identity and help commands
|
|
57
53
|
* 2. Resolve user entitlement
|
|
58
|
-
* 3. If entitlement === "internal" → allow execution
|
|
59
|
-
* 4.
|
|
60
|
-
* 5. Otherwise → block execution
|
|
54
|
+
* 3. If entitlement === "internal" or "paid" → allow execution
|
|
55
|
+
* 4. Otherwise → block execution
|
|
61
56
|
*
|
|
62
57
|
* @param command - The command name (e.g., 'plan', 'simulate', 'login')
|
|
63
58
|
* @returns ExecutionGateResult indicating if execution is allowed
|
|
@@ -70,9 +65,9 @@ export declare function checkExecutionGate(command: string): ExecutionGateResult
|
|
|
70
65
|
*/
|
|
71
66
|
export declare function enforceExecutionGate(command: string): void;
|
|
72
67
|
/**
|
|
73
|
-
* Check if execution is
|
|
68
|
+
* Check if execution is enabled for the current user.
|
|
74
69
|
*
|
|
75
|
-
* @returns true if
|
|
70
|
+
* @returns true if the user has internal or paid entitlement
|
|
76
71
|
*/
|
|
77
72
|
export declare function isExecutionEnabled(): boolean;
|
|
78
73
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution-gate.d.ts","sourceRoot":"","sources":["../../src/gates/execution-gate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"execution-gate.d.ts","sourceRoot":"","sources":["../../src/gates/execution-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA6BH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAuDvD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,IAAI,WAAW,CA8BhD;AAiBD;;;GAGG;AACH,eAAO,MAAM,2BAA2B,IAA+B,CAAC;AAoBxE,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB,CAyBvE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAO1D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAG5C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,WAAW,CAAC,MAAM,CAAC,CAExD"}
|
|
@@ -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,OA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AAE,CAAC;IAC3B,CAAC;IAED,qDAAqD;IACrD,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAC;IAEzC,kCAAkC;IAClC,IAAI,WAAW,KAAK,UAAU,EAAE,CAAC;QAC/B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,8BAA8B;IAC9B,IAAI,WAAW,KAAK,MAAM,EAAE,CAAC;QAC3B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,2BAA2B;IAC3B,OAAO;QACL,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,2BAA2B;QACrC,OAAO,EAAE,eAAe;KACzB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAe;IAClD,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAE3C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,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"}
|