@llm-dev-ops/agentics-cli 1.4.4 → 1.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/dist/adapters/base-adapter.d.ts +117 -0
  2. package/dist/adapters/base-adapter.d.ts.map +1 -1
  3. package/dist/adapters/base-adapter.js +143 -0
  4. package/dist/adapters/base-adapter.js.map +1 -1
  5. package/dist/agents/cli-ux-agent.d.ts.map +1 -1
  6. package/dist/agents/cli-ux-agent.js +2 -1
  7. package/dist/agents/cli-ux-agent.js.map +1 -1
  8. package/dist/auth/identity-resolver.d.ts +21 -0
  9. package/dist/auth/identity-resolver.d.ts.map +1 -0
  10. package/dist/auth/identity-resolver.js +68 -0
  11. package/dist/auth/identity-resolver.js.map +1 -0
  12. package/dist/auth/index.d.ts +2 -0
  13. package/dist/auth/index.d.ts.map +1 -1
  14. package/dist/auth/index.js +2 -0
  15. package/dist/auth/index.js.map +1 -1
  16. package/dist/auth/role-permissions.d.ts +12 -0
  17. package/dist/auth/role-permissions.d.ts.map +1 -0
  18. package/dist/auth/role-permissions.js +43 -0
  19. package/dist/auth/role-permissions.js.map +1 -0
  20. package/dist/cli/index.js +162 -157
  21. package/dist/cli/index.js.map +1 -1
  22. package/dist/commands/deploy.d.ts +4 -4
  23. package/dist/commands/deploy.d.ts.map +1 -1
  24. package/dist/commands/deploy.js +83 -21
  25. package/dist/commands/deploy.js.map +1 -1
  26. package/dist/commands/erp.d.ts +1 -1
  27. package/dist/commands/erp.d.ts.map +1 -1
  28. package/dist/commands/erp.js +65 -5
  29. package/dist/commands/erp.js.map +1 -1
  30. package/dist/commands/export.d.ts +5 -5
  31. package/dist/commands/export.js +5 -5
  32. package/dist/commands/inspect.d.ts +28 -0
  33. package/dist/commands/inspect.d.ts.map +1 -1
  34. package/dist/commands/inspect.js +113 -0
  35. package/dist/commands/inspect.js.map +1 -1
  36. package/dist/commands/login.d.ts +8 -6
  37. package/dist/commands/login.d.ts.map +1 -1
  38. package/dist/commands/login.js +171 -89
  39. package/dist/commands/login.js.map +1 -1
  40. package/dist/commands/logout.d.ts.map +1 -1
  41. package/dist/commands/logout.js +4 -1
  42. package/dist/commands/logout.js.map +1 -1
  43. package/dist/commands/plan.d.ts +8 -5
  44. package/dist/commands/plan.d.ts.map +1 -1
  45. package/dist/commands/plan.js +88 -63
  46. package/dist/commands/plan.js.map +1 -1
  47. package/dist/commands/policy.d.ts +53 -0
  48. package/dist/commands/policy.d.ts.map +1 -1
  49. package/dist/commands/policy.js +201 -5
  50. package/dist/commands/policy.js.map +1 -1
  51. package/dist/commands/quantify.d.ts +1 -1
  52. package/dist/commands/quantify.d.ts.map +1 -1
  53. package/dist/commands/quantify.js +2 -4
  54. package/dist/commands/quantify.js.map +1 -1
  55. package/dist/commands/simulate.d.ts +3 -2
  56. package/dist/commands/simulate.d.ts.map +1 -1
  57. package/dist/commands/simulate.js +154 -37
  58. package/dist/commands/simulate.js.map +1 -1
  59. package/dist/commands/usage.d.ts +3 -3
  60. package/dist/commands/usage.js +7 -7
  61. package/dist/commands/usage.js.map +1 -1
  62. package/dist/commands/whoami.d.ts +6 -0
  63. package/dist/commands/whoami.d.ts.map +1 -1
  64. package/dist/commands/whoami.js +44 -7
  65. package/dist/commands/whoami.js.map +1 -1
  66. package/dist/contracts/adr-002-operational-enforcement.d.ts +684 -0
  67. package/dist/contracts/adr-002-operational-enforcement.d.ts.map +1 -0
  68. package/dist/contracts/adr-002-operational-enforcement.js +671 -0
  69. package/dist/contracts/adr-002-operational-enforcement.js.map +1 -0
  70. package/dist/contracts/adr-003-governance-architecture.d.ts +766 -0
  71. package/dist/contracts/adr-003-governance-architecture.d.ts.map +1 -0
  72. package/dist/contracts/adr-003-governance-architecture.js +773 -0
  73. package/dist/contracts/adr-003-governance-architecture.js.map +1 -0
  74. package/dist/contracts/adr-004-enterprise-integration-memory.d.ts +1150 -0
  75. package/dist/contracts/adr-004-enterprise-integration-memory.d.ts.map +1 -0
  76. package/dist/contracts/adr-004-enterprise-integration-memory.js +1158 -0
  77. package/dist/contracts/adr-004-enterprise-integration-memory.js.map +1 -0
  78. package/dist/contracts/adr-005-system-coherence-drift-self-governance.d.ts +1393 -0
  79. package/dist/contracts/adr-005-system-coherence-drift-self-governance.d.ts.map +1 -0
  80. package/dist/contracts/adr-005-system-coherence-drift-self-governance.js +1371 -0
  81. package/dist/contracts/adr-005-system-coherence-drift-self-governance.js.map +1 -0
  82. package/dist/contracts/adr-command-semantics.d.ts +150 -0
  83. package/dist/contracts/adr-command-semantics.d.ts.map +1 -0
  84. package/dist/contracts/adr-command-semantics.js +984 -0
  85. package/dist/contracts/adr-command-semantics.js.map +1 -0
  86. package/dist/contracts/index.d.ts +5 -0
  87. package/dist/contracts/index.d.ts.map +1 -1
  88. package/dist/contracts/index.js +16 -0
  89. package/dist/contracts/index.js.map +1 -1
  90. package/dist/enterprise/index.d.ts +16 -0
  91. package/dist/enterprise/index.d.ts.map +1 -0
  92. package/dist/enterprise/index.js +17 -0
  93. package/dist/enterprise/index.js.map +1 -0
  94. package/dist/enterprise/integration-registry.d.ts +73 -0
  95. package/dist/enterprise/integration-registry.d.ts.map +1 -0
  96. package/dist/enterprise/integration-registry.js +252 -0
  97. package/dist/enterprise/integration-registry.js.map +1 -0
  98. package/dist/enterprise/lineage.d.ts +73 -0
  99. package/dist/enterprise/lineage.d.ts.map +1 -0
  100. package/dist/enterprise/lineage.js +218 -0
  101. package/dist/enterprise/lineage.js.map +1 -0
  102. package/dist/gates/argument-guard.d.ts +39 -0
  103. package/dist/gates/argument-guard.d.ts.map +1 -0
  104. package/dist/gates/argument-guard.js +180 -0
  105. package/dist/gates/argument-guard.js.map +1 -0
  106. package/dist/gates/auth-session-gate.d.ts +47 -0
  107. package/dist/gates/auth-session-gate.d.ts.map +1 -0
  108. package/dist/gates/auth-session-gate.js +151 -0
  109. package/dist/gates/auth-session-gate.js.map +1 -0
  110. package/dist/gates/execution-gate.d.ts +12 -17
  111. package/dist/gates/execution-gate.d.ts.map +1 -1
  112. package/dist/gates/execution-gate.js +74 -46
  113. package/dist/gates/execution-gate.js.map +1 -1
  114. package/dist/gates/index.d.ts +25 -2
  115. package/dist/gates/index.d.ts.map +1 -1
  116. package/dist/gates/index.js +31 -2
  117. package/dist/gates/index.js.map +1 -1
  118. package/dist/gates/lineage-gate.d.ts +55 -0
  119. package/dist/gates/lineage-gate.d.ts.map +1 -0
  120. package/dist/gates/lineage-gate.js +127 -0
  121. package/dist/gates/lineage-gate.js.map +1 -0
  122. package/dist/gates/output-format-gate.d.ts +54 -0
  123. package/dist/gates/output-format-gate.d.ts.map +1 -0
  124. package/dist/gates/output-format-gate.js +136 -0
  125. package/dist/gates/output-format-gate.js.map +1 -0
  126. package/dist/gates/service-health-gate.d.ts +56 -0
  127. package/dist/gates/service-health-gate.d.ts.map +1 -0
  128. package/dist/gates/service-health-gate.js +179 -0
  129. package/dist/gates/service-health-gate.js.map +1 -0
  130. package/dist/modules/help-renderer.d.ts +25 -0
  131. package/dist/modules/help-renderer.d.ts.map +1 -0
  132. package/dist/modules/help-renderer.js +163 -0
  133. package/dist/modules/help-renderer.js.map +1 -0
  134. package/dist/modules/index.d.ts +1 -0
  135. package/dist/modules/index.d.ts.map +1 -1
  136. package/dist/modules/index.js +1 -0
  137. package/dist/modules/index.js.map +1 -1
  138. package/dist/server/index.d.ts +2 -0
  139. package/dist/server/index.d.ts.map +1 -1
  140. package/dist/server/index.js +16 -1
  141. package/dist/server/index.js.map +1 -1
  142. package/dist/server/routes/auth.d.ts.map +1 -1
  143. package/dist/server/routes/auth.js +45 -8
  144. package/dist/server/routes/auth.js.map +1 -1
  145. package/dist/server/routes/identity.d.ts +9 -0
  146. package/dist/server/routes/identity.d.ts.map +1 -0
  147. package/dist/server/routes/identity.js +100 -0
  148. package/dist/server/routes/identity.js.map +1 -0
  149. package/dist/server/routes/index.d.ts +2 -0
  150. package/dist/server/routes/index.d.ts.map +1 -1
  151. package/dist/server/routes/index.js +2 -0
  152. package/dist/server/routes/index.js.map +1 -1
  153. package/dist/server/routes/lineage.d.ts +15 -0
  154. package/dist/server/routes/lineage.d.ts.map +1 -0
  155. package/dist/server/routes/lineage.js +128 -0
  156. package/dist/server/routes/lineage.js.map +1 -0
  157. package/dist/types/index.d.ts +134 -0
  158. package/dist/types/index.d.ts.map +1 -1
  159. package/dist/utils/identity-store.d.ts +31 -0
  160. package/dist/utils/identity-store.d.ts.map +1 -0
  161. package/dist/utils/identity-store.js +97 -0
  162. package/dist/utils/identity-store.js.map +1 -0
  163. package/dist/utils/index.d.ts +2 -0
  164. package/dist/utils/index.d.ts.map +1 -1
  165. package/dist/utils/index.js +1 -0
  166. package/dist/utils/index.js.map +1 -1
  167. package/package.json +4 -4
@@ -1,22 +1,18 @@
1
1
  /**
2
2
  * Execution Gate Module
3
3
  *
4
- * HARD EXECUTION KILL-SWITCH
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
- * - Standard entitlements follow existing payment/execution logic
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
- * This is a hard kill-switch, not a pricing feature.
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. If EXECUTION_ENABLED === true allow execution
60
- * 5. Otherwise → block execution
54
+ * 3. If entitlement === "internal" or "paid" → allow execution
55
+ * 4. Otherwiseblock 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 globally enabled.
68
+ * Check if execution is enabled for the current user.
74
69
  *
75
- * @returns true if execution is enabled, false otherwise
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;;;;;;;;;;;;;;;;;;;GAmBG;AAsCH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAqBvD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,IAAI,WAAW,CAqBhD;AAgBD;;;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;;;;;;;;;;;;;;;;;;GAkBG;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,CAE5C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,WAAW,CAAC,MAAM,CAAC,CAExD"}
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
- * HARD EXECUTION KILL-SWITCH
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
- * - Standard entitlements follow existing payment/execution logic
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
- * This is a hard kill-switch, not a pricing feature.
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
- * HARD KILL-SWITCH: Execution is DISABLED by default.
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
- * INTERNAL_EMAILS: Authoritative allow-list for internal maintainers.
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 INTERNAL_EMAILS = new Set([
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 storedEmail = getStoredEmail();
85
- if (storedEmail && INTERNAL_EMAILS.has(storedEmail.toLowerCase())) {
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
- // Future: Check for paid entitlements via payment service
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 email from stored credentials (sync).
123
+ * Read stored credentials (sync).
98
124
  */
99
- function getStoredEmail() {
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
- return creds.email ?? null;
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. If EXECUTION_ENABLED === true allow execution
141
- * 5. Otherwise → block execution
167
+ * 3. If entitlement === "internal" or "paid" → allow execution
168
+ * 4. Otherwiseblock 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 - this is a first-class entitlement
180
+ // Internal users have full access
154
181
  if (entitlement === 'internal') {
155
182
  return { allowed: true };
156
183
  }
157
- // If execution is enabled, allow all commands
158
- if (EXECUTION_ENABLED) {
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 globally enabled.
208
+ * Check if execution is enabled for the current user.
182
209
  *
183
- * @returns true if execution is enabled, false otherwise
210
+ * @returns true if the user has internal or paid entitlement
184
211
  */
185
212
  export function isExecutionEnabled() {
186
- return EXECUTION_ENABLED;
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;;;;;;;;;;;;;;;;;;;GAmBG;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;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,+EAA+E;AAC/E,+BAA+B;AAC/B,+EAA+E;AAE/E;;;;;;;GAOG;AACH,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,KAAK,MAAM,CAAC;AAE5E;;;GAGG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,SAAS;CACV,CAAC,CAAC;AAWH;;;;;;;GAOG;AACH,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC;IACnD,wBAAwB;IACxB,iCAAiC;IACjC,0BAA0B;IAC1B,yBAAyB;IACzB,aAAa;IACb,kBAAkB;IAClB,oBAAoB;IACpB,0BAA0B;CAC3B,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB;IAChC,sEAAsE;IACtE,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACpD,IAAI,QAAQ,IAAI,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,WAA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ACrD,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"}
@@ -1,8 +1,31 @@
1
1
  /**
2
- * Gates Module
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
+ * 5. Argument Guard Gate - Validates argument types per ADR-001
13
+ * 6. Lineage Gate - Enforces simulation traceability per ADR-004
14
+ *
15
+ * CRITICAL REQUIREMENTS MET:
16
+ * - CLI requires Ruvector-backed services (Service Health Gate)
17
+ * - CLI never executes agents locally (Localhost Safeguard in endpoints.ts)
18
+ * - CLI fails loudly if services misconfigured (All gates fail-fast)
19
+ * - Requires authenticated session (Auth Session Gate)
20
+ * - Validates target service availability (Service Health Gate)
21
+ * - Enforces strict JSON outputs (Output Format Gate)
22
+ * - Never allows narrative output (Output Format Gate)
23
+ * - Enterprise artifacts trace to governed simulations (Lineage Gate)
6
24
  */
7
- export { checkExecutionGate, enforceExecutionGate, isExecutionEnabled, getAllowedCommands, EXECUTION_BLOCKED_EXIT_CODE, type ExecutionGateResult, } from './execution-gate.js';
25
+ export { checkExecutionGate, enforceExecutionGate, isExecutionEnabled, getAllowedCommands, resolveEntitlement, EXECUTION_BLOCKED_EXIT_CODE, type ExecutionGateResult, type Entitlement, } from './execution-gate.js';
26
+ export { enforceAuthSessionGate, checkAuthSessionGate, requiresAuthentication, AUTH_REQUIRED_EXIT_CODE, AuthSessionRequiredError, type AuthSessionGateResult, } from './auth-session-gate.js';
27
+ export { enforceServiceHealthGate, checkServiceHealthGate, requiresHealthCheck, SERVICE_UNAVAILABLE_EXIT_CODE, ServiceHealthError, type ServiceHealthResult, type ServiceHealthGateResult, } from './service-health-gate.js';
28
+ export { enforceOutputFormatGate, checkOutputFormatGate, requiresStructuredOutput, getDefaultFormat, INVALID_FORMAT_EXIT_CODE, InvalidOutputFormatError, type OutputFormatGateResult, } from './output-format-gate.js';
29
+ export { checkArgumentGuard, enforceArgumentGuard, requiresArgumentValidation, type ArgumentGuardResult, } from './argument-guard.js';
30
+ export { checkLineageGate, enforceLineageGate, requiresLineageValidation, LINEAGE_VIOLATION_EXIT_CODE, type LineageGateResult, } from './lineage-gate.js';
8
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gates/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,EAC3B,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gates/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,EAC3B,KAAK,mBAAmB,EACxB,KAAK,WAAW,GACjB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,KAAK,qBAAqB,GAC3B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,6BAA6B,EAC7B,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,GAC7B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,sBAAsB,GAC5B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,EAC3B,KAAK,iBAAiB,GACvB,MAAM,mBAAmB,CAAC"}
@@ -1,8 +1,37 @@
1
1
  /**
2
- * Gates Module
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
+ * 5. Argument Guard Gate - Validates argument types per ADR-001
13
+ * 6. Lineage Gate - Enforces simulation traceability per ADR-004
14
+ *
15
+ * CRITICAL REQUIREMENTS MET:
16
+ * - CLI requires Ruvector-backed services (Service Health Gate)
17
+ * - CLI never executes agents locally (Localhost Safeguard in endpoints.ts)
18
+ * - CLI fails loudly if services misconfigured (All gates fail-fast)
19
+ * - Requires authenticated session (Auth Session Gate)
20
+ * - Validates target service availability (Service Health Gate)
21
+ * - Enforces strict JSON outputs (Output Format Gate)
22
+ * - Never allows narrative output (Output Format Gate)
23
+ * - Enterprise artifacts trace to governed simulations (Lineage Gate)
6
24
  */
7
- export { checkExecutionGate, enforceExecutionGate, isExecutionEnabled, getAllowedCommands, EXECUTION_BLOCKED_EXIT_CODE, } from './execution-gate.js';
25
+ // Execution Gate - Hard kill-switch
26
+ export { checkExecutionGate, enforceExecutionGate, isExecutionEnabled, getAllowedCommands, resolveEntitlement, EXECUTION_BLOCKED_EXIT_CODE, } from './execution-gate.js';
27
+ // Auth Session Gate - Requires authenticated session
28
+ export { enforceAuthSessionGate, checkAuthSessionGate, requiresAuthentication, AUTH_REQUIRED_EXIT_CODE, AuthSessionRequiredError, } from './auth-session-gate.js';
29
+ // Service Health Gate - Validates Ruvector-backed services
30
+ export { enforceServiceHealthGate, checkServiceHealthGate, requiresHealthCheck, SERVICE_UNAVAILABLE_EXIT_CODE, ServiceHealthError, } from './service-health-gate.js';
31
+ // Output Format Gate - Enforces strict JSON output
32
+ export { enforceOutputFormatGate, checkOutputFormatGate, requiresStructuredOutput, getDefaultFormat, INVALID_FORMAT_EXIT_CODE, InvalidOutputFormatError, } from './output-format-gate.js';
33
+ // Argument Guard Gate - Validates argument types per ADR-001
34
+ export { checkArgumentGuard, enforceArgumentGuard, requiresArgumentValidation, } from './argument-guard.js';
35
+ // Lineage Gate - Enforces simulation traceability per ADR-004
36
+ export { checkLineageGate, enforceLineageGate, requiresLineageValidation, LINEAGE_VIOLATION_EXIT_CODE, } from './lineage-gate.js';
8
37
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gates/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,GAE5B,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gates/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,oCAAoC;AACpC,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,GAG5B,MAAM,qBAAqB,CAAC;AAE7B,qDAAqD;AACrD,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,GAEzB,MAAM,wBAAwB,CAAC;AAEhC,2DAA2D;AAC3D,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,6BAA6B,EAC7B,kBAAkB,GAGnB,MAAM,0BAA0B,CAAC;AAElC,mDAAmD;AACnD,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,wBAAwB,EACxB,wBAAwB,GAEzB,MAAM,yBAAyB,CAAC;AAEjC,6DAA6D;AAC7D,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,GAE3B,MAAM,qBAAqB,CAAC;AAE7B,8DAA8D;AAC9D,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,GAE5B,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Lineage Gate — Gate 6 (ADR-004 Enforcement)
3
+ *
4
+ * PURPOSE: Enforce that artifact-producing commands reference a valid
5
+ * simulation parent. No integration proposal or ERP mapping may
6
+ * exist without traceability to a governed simulation.
7
+ *
8
+ * INVARIANTS ENFORCED:
9
+ * - ADR-004 Invariant 2: Every integration/ERP mapping derives from a simulation
10
+ * - ADR-004 Invariant 3: No integration proposal without traceability
11
+ * - ADR-004 Invariant 7: CLI is only path for artifact creation
12
+ *
13
+ * EXIT CODE: 110 (LINEAGE_VIOLATION)
14
+ *
15
+ * BEHAVIOR:
16
+ * - Commands that produce enterprise artifacts (erp surface, erp map,
17
+ * erp export) must pass a simulation_id in their positional args
18
+ * or flags when the lineage gate is enabled.
19
+ * - Commands that do not produce artifacts (list, inspect, help)
20
+ * are exempt from lineage validation.
21
+ * - The gate validates that simulation_id is present and non-empty.
22
+ * Whether the simulation exists in Ruvector is validated at the
23
+ * command level, not at the gate level (gate is synchronous).
24
+ */
25
+ import type { CommandObject } from '../types/index.js';
26
+ export declare const LINEAGE_VIOLATION_EXIT_CODE = 110;
27
+ export interface LineageGateResult {
28
+ /** Whether the command passed lineage validation */
29
+ allowed: boolean;
30
+ /** Error message if validation failed */
31
+ message: string;
32
+ /** Exit code if validation failed */
33
+ exitCode: number;
34
+ /** Whether this command requires lineage */
35
+ lineageRequired: boolean;
36
+ }
37
+ /**
38
+ * Check whether a command passes lineage validation.
39
+ * Returns a result indicating whether the command is allowed.
40
+ *
41
+ * Lineage is required when:
42
+ * 1. The command is in LINEAGE_REQUIRED_COMMANDS
43
+ * 2. The command is not in LINEAGE_EXEMPT_COMMANDS
44
+ * 3. The command produces enterprise artifacts
45
+ */
46
+ export declare function checkLineageGate(cmd: CommandObject): LineageGateResult;
47
+ /**
48
+ * Enforce lineage gate — exits the process if validation fails.
49
+ */
50
+ export declare function enforceLineageGate(cmd: CommandObject): void;
51
+ /**
52
+ * Check if a command requires lineage validation.
53
+ */
54
+ export declare function requiresLineageValidation(primary: string, sub?: string): boolean;
55
+ //# sourceMappingURL=lineage-gate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineage-gate.d.ts","sourceRoot":"","sources":["../../src/gates/lineage-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAOvD,eAAO,MAAM,2BAA2B,MAAM,CAAC;AA2B/C,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,OAAO,EAAE,OAAO,CAAC;IACjB,yCAAyC;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,eAAe,EAAE,OAAO,CAAC;CAC1B;AAMD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,aAAa,GAAG,iBAAiB,CAyCtE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAc3D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAMhF"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Lineage Gate — Gate 6 (ADR-004 Enforcement)
3
+ *
4
+ * PURPOSE: Enforce that artifact-producing commands reference a valid
5
+ * simulation parent. No integration proposal or ERP mapping may
6
+ * exist without traceability to a governed simulation.
7
+ *
8
+ * INVARIANTS ENFORCED:
9
+ * - ADR-004 Invariant 2: Every integration/ERP mapping derives from a simulation
10
+ * - ADR-004 Invariant 3: No integration proposal without traceability
11
+ * - ADR-004 Invariant 7: CLI is only path for artifact creation
12
+ *
13
+ * EXIT CODE: 110 (LINEAGE_VIOLATION)
14
+ *
15
+ * BEHAVIOR:
16
+ * - Commands that produce enterprise artifacts (erp surface, erp map,
17
+ * erp export) must pass a simulation_id in their positional args
18
+ * or flags when the lineage gate is enabled.
19
+ * - Commands that do not produce artifacts (list, inspect, help)
20
+ * are exempt from lineage validation.
21
+ * - The gate validates that simulation_id is present and non-empty.
22
+ * Whether the simulation exists in Ruvector is validated at the
23
+ * command level, not at the gate level (gate is synchronous).
24
+ */
25
+ import { validateTraceability } from '../enterprise/lineage.js';
26
+ // ============================================================================
27
+ // Constants
28
+ // ============================================================================
29
+ export const LINEAGE_VIOLATION_EXIT_CODE = 110;
30
+ /**
31
+ * Commands that produce enterprise artifacts requiring lineage.
32
+ * These commands must reference a simulation_id.
33
+ */
34
+ const LINEAGE_REQUIRED_COMMANDS = new Map([
35
+ ['erp', new Set(['surface', 'map', 'export'])],
36
+ ]);
37
+ /**
38
+ * Commands exempt from lineage validation.
39
+ * These commands are read-only or do not produce artifacts.
40
+ */
41
+ const LINEAGE_EXEMPT_COMMANDS = new Set([
42
+ 'help',
43
+ 'version',
44
+ 'login',
45
+ 'logout',
46
+ 'whoami',
47
+ 'usage',
48
+ ]);
49
+ // ============================================================================
50
+ // Gate Implementation
51
+ // ============================================================================
52
+ /**
53
+ * Check whether a command passes lineage validation.
54
+ * Returns a result indicating whether the command is allowed.
55
+ *
56
+ * Lineage is required when:
57
+ * 1. The command is in LINEAGE_REQUIRED_COMMANDS
58
+ * 2. The command is not in LINEAGE_EXEMPT_COMMANDS
59
+ * 3. The command produces enterprise artifacts
60
+ */
61
+ export function checkLineageGate(cmd) {
62
+ const primary = cmd.command;
63
+ const sub = cmd.subcommand;
64
+ // Exempt commands skip lineage validation
65
+ if (LINEAGE_EXEMPT_COMMANDS.has(primary)) {
66
+ return { allowed: true, message: '', exitCode: 0, lineageRequired: false };
67
+ }
68
+ // Check if this command+subcommand requires lineage
69
+ const requiredSubs = LINEAGE_REQUIRED_COMMANDS.get(primary);
70
+ if (!requiredSubs || !sub || !requiredSubs.has(sub)) {
71
+ return { allowed: true, message: '', exitCode: 0, lineageRequired: false };
72
+ }
73
+ // This command requires lineage — check for simulation_id
74
+ // simulation_id can be provided as:
75
+ // 1. A flag: --simulation-id <id>
76
+ // 2. An option: simulation_id in options
77
+ // 3. The first positional arg (for commands that take simulation_id as primary arg)
78
+ const simulationId = cmd.options['simulation-id'] ??
79
+ cmd.options['simulation_id'] ??
80
+ cmd.flags['simulation-id'] ??
81
+ undefined;
82
+ const validation = validateTraceability(simulationId, `${primary} ${sub}`);
83
+ if (!validation.valid) {
84
+ return {
85
+ allowed: false,
86
+ message: `Lineage violation: ${validation.message}\n` +
87
+ `Usage: agentics ${primary} ${sub} --simulation-id <simulation_id>\n` +
88
+ `\n` +
89
+ `Enterprise artifacts must trace to a governed simulation (ADR-004).`,
90
+ exitCode: LINEAGE_VIOLATION_EXIT_CODE,
91
+ lineageRequired: true,
92
+ };
93
+ }
94
+ return { allowed: true, message: '', exitCode: 0, lineageRequired: true };
95
+ }
96
+ /**
97
+ * Enforce lineage gate — exits the process if validation fails.
98
+ */
99
+ export function enforceLineageGate(cmd) {
100
+ const result = checkLineageGate(cmd);
101
+ if (!result.allowed) {
102
+ console.error(JSON.stringify({
103
+ error: {
104
+ code: 'LINEAGE_VIOLATION',
105
+ message: result.message,
106
+ command: `${cmd.command} ${cmd.subcommand ?? ''}`.trim(),
107
+ exit_code: result.exitCode,
108
+ adr: 'ADR-004',
109
+ },
110
+ }));
111
+ process.exit(result.exitCode);
112
+ }
113
+ }
114
+ /**
115
+ * Check if a command requires lineage validation.
116
+ */
117
+ export function requiresLineageValidation(primary, sub) {
118
+ if (LINEAGE_EXEMPT_COMMANDS.has(primary))
119
+ return false;
120
+ const requiredSubs = LINEAGE_REQUIRED_COMMANDS.get(primary);
121
+ if (!requiredSubs)
122
+ return false;
123
+ if (!sub)
124
+ return false;
125
+ return requiredSubs.has(sub);
126
+ }
127
+ //# s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UAAU,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE;gBACxD,SAAS,EAAE,MAAM,CAAC,QAAQ;gBAC1B,GAAG,EAAE,SAAS;aACf;SACF,CAAC,CAAC,CAAC;QACJ,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAe,EAAE,GAAY;IACrE,IAAI,uBAAuB,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IACvD,MAAM,YAAY,GAAG,yBAAyB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5D,IAAI,CAAC,YAAY;QAAE,OAAO,KAAK,CAAC;IAChC,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,OAAO,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC/B,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"}