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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/dist/adapters/base-adapter.d.ts +117 -0
  2. package/dist/adapters/base-adapter.d.ts.map +1 -1
  3. package/dist/adapters/base-adapter.js +143 -0
  4. package/dist/adapters/base-adapter.js.map +1 -1
  5. package/dist/auth/identity-resolver.d.ts +21 -0
  6. package/dist/auth/identity-resolver.d.ts.map +1 -0
  7. package/dist/auth/identity-resolver.js +68 -0
  8. package/dist/auth/identity-resolver.js.map +1 -0
  9. package/dist/auth/index.d.ts +2 -0
  10. package/dist/auth/index.d.ts.map +1 -1
  11. package/dist/auth/index.js +2 -0
  12. package/dist/auth/index.js.map +1 -1
  13. package/dist/auth/role-permissions.d.ts +12 -0
  14. package/dist/auth/role-permissions.d.ts.map +1 -0
  15. package/dist/auth/role-permissions.js +43 -0
  16. package/dist/auth/role-permissions.js.map +1 -0
  17. package/dist/cli/index.js +139 -134
  18. package/dist/cli/index.js.map +1 -1
  19. package/dist/commands/erp.d.ts.map +1 -1
  20. package/dist/commands/erp.js +62 -0
  21. package/dist/commands/erp.js.map +1 -1
  22. package/dist/commands/login.d.ts.map +1 -1
  23. package/dist/commands/login.js +25 -0
  24. package/dist/commands/login.js.map +1 -1
  25. package/dist/commands/logout.d.ts.map +1 -1
  26. package/dist/commands/logout.js +4 -1
  27. package/dist/commands/logout.js.map +1 -1
  28. package/dist/commands/plan.d.ts.map +1 -1
  29. package/dist/commands/plan.js +6 -5
  30. package/dist/commands/plan.js.map +1 -1
  31. package/dist/commands/simulate.d.ts.map +1 -1
  32. package/dist/commands/simulate.js +57 -1
  33. package/dist/commands/simulate.js.map +1 -1
  34. package/dist/commands/whoami.d.ts +4 -0
  35. package/dist/commands/whoami.d.ts.map +1 -1
  36. package/dist/commands/whoami.js +22 -5
  37. package/dist/commands/whoami.js.map +1 -1
  38. package/dist/contracts/adr-002-operational-enforcement.d.ts +684 -0
  39. package/dist/contracts/adr-002-operational-enforcement.d.ts.map +1 -0
  40. package/dist/contracts/adr-002-operational-enforcement.js +671 -0
  41. package/dist/contracts/adr-002-operational-enforcement.js.map +1 -0
  42. package/dist/contracts/adr-003-governance-architecture.d.ts +766 -0
  43. package/dist/contracts/adr-003-governance-architecture.d.ts.map +1 -0
  44. package/dist/contracts/adr-003-governance-architecture.js +773 -0
  45. package/dist/contracts/adr-003-governance-architecture.js.map +1 -0
  46. package/dist/contracts/adr-004-enterprise-integration-memory.d.ts +1150 -0
  47. package/dist/contracts/adr-004-enterprise-integration-memory.d.ts.map +1 -0
  48. package/dist/contracts/adr-004-enterprise-integration-memory.js +1158 -0
  49. package/dist/contracts/adr-004-enterprise-integration-memory.js.map +1 -0
  50. package/dist/contracts/adr-005-system-coherence-drift-self-governance.d.ts +1393 -0
  51. package/dist/contracts/adr-005-system-coherence-drift-self-governance.d.ts.map +1 -0
  52. package/dist/contracts/adr-005-system-coherence-drift-self-governance.js +1371 -0
  53. package/dist/contracts/adr-005-system-coherence-drift-self-governance.js.map +1 -0
  54. package/dist/contracts/adr-006-claude-code-synthesis-runner.d.ts +196 -0
  55. package/dist/contracts/adr-006-claude-code-synthesis-runner.d.ts.map +1 -0
  56. package/dist/contracts/adr-006-claude-code-synthesis-runner.js +177 -0
  57. package/dist/contracts/adr-006-claude-code-synthesis-runner.js.map +1 -0
  58. package/dist/contracts/adr-007-subcommand-synthesis-router.d.ts +273 -0
  59. package/dist/contracts/adr-007-subcommand-synthesis-router.d.ts.map +1 -0
  60. package/dist/contracts/adr-007-subcommand-synthesis-router.js +226 -0
  61. package/dist/contracts/adr-007-subcommand-synthesis-router.js.map +1 -0
  62. package/dist/contracts/adr-008-synthesis-artifact-persistence.d.ts +323 -0
  63. package/dist/contracts/adr-008-synthesis-artifact-persistence.d.ts.map +1 -0
  64. package/dist/contracts/adr-008-synthesis-artifact-persistence.js +184 -0
  65. package/dist/contracts/adr-008-synthesis-artifact-persistence.js.map +1 -0
  66. package/dist/contracts/adr-command-semantics.d.ts +150 -0
  67. package/dist/contracts/adr-command-semantics.d.ts.map +1 -0
  68. package/dist/contracts/adr-command-semantics.js +984 -0
  69. package/dist/contracts/adr-command-semantics.js.map +1 -0
  70. package/dist/contracts/index.d.ts +5 -0
  71. package/dist/contracts/index.d.ts.map +1 -1
  72. package/dist/contracts/index.js +16 -0
  73. package/dist/contracts/index.js.map +1 -1
  74. package/dist/enterprise/index.d.ts +16 -0
  75. package/dist/enterprise/index.d.ts.map +1 -0
  76. package/dist/enterprise/index.js +17 -0
  77. package/dist/enterprise/index.js.map +1 -0
  78. package/dist/enterprise/integration-registry.d.ts +73 -0
  79. package/dist/enterprise/integration-registry.d.ts.map +1 -0
  80. package/dist/enterprise/integration-registry.js +252 -0
  81. package/dist/enterprise/integration-registry.js.map +1 -0
  82. package/dist/enterprise/lineage.d.ts +73 -0
  83. package/dist/enterprise/lineage.d.ts.map +1 -0
  84. package/dist/enterprise/lineage.js +218 -0
  85. package/dist/enterprise/lineage.js.map +1 -0
  86. package/dist/gates/argument-guard.d.ts +39 -0
  87. package/dist/gates/argument-guard.d.ts.map +1 -0
  88. package/dist/gates/argument-guard.js +180 -0
  89. package/dist/gates/argument-guard.js.map +1 -0
  90. package/dist/gates/index.d.ts +5 -0
  91. package/dist/gates/index.d.ts.map +1 -1
  92. package/dist/gates/index.js +7 -0
  93. package/dist/gates/index.js.map +1 -1
  94. package/dist/gates/lineage-gate.d.ts +55 -0
  95. package/dist/gates/lineage-gate.d.ts.map +1 -0
  96. package/dist/gates/lineage-gate.js +127 -0
  97. package/dist/gates/lineage-gate.js.map +1 -0
  98. package/dist/mcp/mcp-server.d.ts +35 -0
  99. package/dist/mcp/mcp-server.d.ts.map +1 -0
  100. package/dist/mcp/mcp-server.js +692 -0
  101. package/dist/mcp/mcp-server.js.map +1 -0
  102. package/dist/modules/help-renderer.d.ts +25 -0
  103. package/dist/modules/help-renderer.d.ts.map +1 -0
  104. package/dist/modules/help-renderer.js +163 -0
  105. package/dist/modules/help-renderer.js.map +1 -0
  106. package/dist/modules/index.d.ts +1 -0
  107. package/dist/modules/index.d.ts.map +1 -1
  108. package/dist/modules/index.js +1 -0
  109. package/dist/modules/index.js.map +1 -1
  110. package/dist/runtime/claude-code-runner.d.ts +93 -0
  111. package/dist/runtime/claude-code-runner.d.ts.map +1 -0
  112. package/dist/runtime/claude-code-runner.js +588 -0
  113. package/dist/runtime/claude-code-runner.js.map +1 -0
  114. package/dist/runtime/index.d.ts +5 -0
  115. package/dist/runtime/index.d.ts.map +1 -0
  116. package/dist/runtime/index.js +5 -0
  117. package/dist/runtime/index.js.map +1 -0
  118. package/dist/server/index.d.ts +2 -0
  119. package/dist/server/index.d.ts.map +1 -1
  120. package/dist/server/index.js +16 -1
  121. package/dist/server/index.js.map +1 -1
  122. package/dist/server/routes/identity.d.ts +9 -0
  123. package/dist/server/routes/identity.d.ts.map +1 -0
  124. package/dist/server/routes/identity.js +100 -0
  125. package/dist/server/routes/identity.js.map +1 -0
  126. package/dist/server/routes/index.d.ts +2 -0
  127. package/dist/server/routes/index.d.ts.map +1 -1
  128. package/dist/server/routes/index.js +2 -0
  129. package/dist/server/routes/index.js.map +1 -1
  130. package/dist/server/routes/lineage.d.ts +15 -0
  131. package/dist/server/routes/lineage.d.ts.map +1 -0
  132. package/dist/server/routes/lineage.js +128 -0
  133. package/dist/server/routes/lineage.js.map +1 -0
  134. package/dist/synthesis/artifact-writer.d.ts +62 -0
  135. package/dist/synthesis/artifact-writer.d.ts.map +1 -0
  136. package/dist/synthesis/artifact-writer.js +603 -0
  137. package/dist/synthesis/artifact-writer.js.map +1 -0
  138. package/dist/synthesis/index.d.ts +7 -0
  139. package/dist/synthesis/index.d.ts.map +1 -0
  140. package/dist/synthesis/index.js +7 -0
  141. package/dist/synthesis/index.js.map +1 -0
  142. package/dist/synthesis/prompts/index.d.ts +50 -0
  143. package/dist/synthesis/prompts/index.d.ts.map +1 -0
  144. package/dist/synthesis/prompts/index.js +502 -0
  145. package/dist/synthesis/prompts/index.js.map +1 -0
  146. package/dist/synthesis/router.d.ts +70 -0
  147. package/dist/synthesis/router.d.ts.map +1 -0
  148. package/dist/synthesis/router.js +346 -0
  149. package/dist/synthesis/router.js.map +1 -0
  150. package/dist/types/index.d.ts +132 -0
  151. package/dist/types/index.d.ts.map +1 -1
  152. package/dist/utils/identity-store.d.ts +31 -0
  153. package/dist/utils/identity-store.d.ts.map +1 -0
  154. package/dist/utils/identity-store.js +97 -0
  155. package/dist/utils/identity-store.js.map +1 -0
  156. package/dist/utils/index.d.ts +2 -0
  157. package/dist/utils/index.d.ts.map +1 -1
  158. package/dist/utils/index.js +1 -0
  159. package/dist/utils/index.js.map +1 -1
  160. package/package.json +1 -1
@@ -0,0 +1,692 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Agentics CLI — MCP Server (stdio transport)
4
+ *
5
+ * Exposes every CLI command + subcommand as an MCP tool so Claude Code
6
+ * can call them directly, the same way claude-flow works.
7
+ *
8
+ * Protocol: JSON-RPC 2.0 over newline-delimited stdin/stdout
9
+ *
10
+ * Tool inventory (48 tools across 12 domains):
11
+ *
12
+ * Identity & Access login, logout, whoami
13
+ * Simulation simulate_create, simulate_run, simulate_list,
14
+ * simulate_inspect, simulate_delete
15
+ * Planning plan_create, plan_list, plan_inspect,
16
+ * plan_approve, plan_delete
17
+ * Inspect inspect_query, inspect_run, inspect_latest,
18
+ * inspect_artifacts
19
+ * Usage & Billing usage, usage_history, usage_limits, usage_reset
20
+ * ROI / Quantify quantify_create, quantify_inspect, quantify_list,
21
+ * quantify_compare
22
+ * Deployment deploy_preview, deploy_run, deploy_status,
23
+ * deploy_rollback
24
+ * Export export_terraform, export_kubernetes, export_erp
25
+ * Policy policy_list, policy_inspect, policy_create,
26
+ * policy_edit, policy_delete, policy_enable,
27
+ * policy_disable, policy_dry_run, policy_scope
28
+ * ERP Surface erp_list, erp_inspect, erp_surface, erp_map,
29
+ * erp_export
30
+ * Diligence diligence
31
+ * Audit audit
32
+ * Meta version, help
33
+ */
34
+ import { execFile } from 'node:child_process';
35
+ import { randomUUID } from 'node:crypto';
36
+ import * as path from 'node:path';
37
+ import { fileURLToPath } from 'node:url';
38
+ const __filename = fileURLToPath(import.meta.url);
39
+ const __dirname = path.dirname(__filename);
40
+ const VERSION = '1.4.5';
41
+ const SESSION_ID = `agentics-mcp-${Date.now()}-${randomUUID().slice(0, 8)}`;
42
+ const CLI_ENTRY = path.resolve(__dirname, '../cli/index.js');
43
+ // ---------------------------------------------------------------------------
44
+ // Logging (stderr only — stdout is reserved for JSON-RPC)
45
+ // ---------------------------------------------------------------------------
46
+ function log(level, msg) {
47
+ process.stderr.write(`[${new Date().toISOString()}] ${level} [agentics-mcp] (${SESSION_ID}) ${msg}\n`);
48
+ }
49
+ log('INFO', 'Starting in stdio mode');
50
+ log('INFO', JSON.stringify({
51
+ arch: process.arch,
52
+ mode: 'mcp-stdio',
53
+ nodeVersion: process.version,
54
+ pid: process.pid,
55
+ platform: process.platform,
56
+ protocol: 'stdio',
57
+ sessionId: SESSION_ID,
58
+ version: VERSION,
59
+ }));
60
+ // ---------------------------------------------------------------------------
61
+ // Shared schema fragments
62
+ // ---------------------------------------------------------------------------
63
+ const FORMAT_PROP = {
64
+ format: { type: 'string', enum: ['json', 'yaml', 'text'], description: 'Output format (default: json)' },
65
+ };
66
+ const VERBOSE_PROP = {
67
+ verbose: { type: 'boolean', description: 'Enable verbose output' },
68
+ };
69
+ const GLOBAL_OPTS = { ...FORMAT_PROP, ...VERBOSE_PROP };
70
+ function obj(properties, required) {
71
+ const schema = {
72
+ type: 'object',
73
+ properties,
74
+ additionalProperties: false,
75
+ };
76
+ if (required && required.length > 0) {
77
+ schema['required'] = required;
78
+ }
79
+ return schema;
80
+ }
81
+ // ---------------------------------------------------------------------------
82
+ // Helpers to build arg lists
83
+ // ---------------------------------------------------------------------------
84
+ function globalFlags(p) {
85
+ const a = [];
86
+ if (p['format'])
87
+ a.push('--format', String(p['format']));
88
+ else
89
+ a.push('--format', 'json');
90
+ if (p['verbose'])
91
+ a.push('--verbose');
92
+ return a;
93
+ }
94
+ // ---------------------------------------------------------------------------
95
+ // === TOOL DEFINITIONS (48 tools) ==========================================
96
+ // ---------------------------------------------------------------------------
97
+ const TOOLS = [
98
+ // ===================== META =====================
99
+ {
100
+ name: 'agentics_version',
101
+ description: 'Show the Agentics CLI version',
102
+ inputSchema: obj({}),
103
+ toArgs: () => ['version'],
104
+ },
105
+ {
106
+ name: 'agentics_help',
107
+ description: 'Show help for the Agentics CLI or a specific command',
108
+ inputSchema: obj({
109
+ command: { type: 'string', description: 'Command name to get help for' },
110
+ }),
111
+ toArgs: (p) => p['command'] ? ['help', String(p['command'])] : ['help'],
112
+ },
113
+ // ===================== IDENTITY & ACCESS =====================
114
+ {
115
+ name: 'agentics_login',
116
+ description: 'Authenticate the CLI via browser-based auth or API key. No synthesis.',
117
+ inputSchema: obj({
118
+ api_key: { type: 'string', description: 'API key for non-interactive auth' },
119
+ }),
120
+ toArgs: (p) => {
121
+ const a = ['login'];
122
+ if (p['api_key'])
123
+ a.push('--api-key', String(p['api_key']));
124
+ return a;
125
+ },
126
+ },
127
+ {
128
+ name: 'agentics_logout',
129
+ description: 'Clear local authentication state. No synthesis.',
130
+ inputSchema: obj({}),
131
+ toArgs: () => ['logout'],
132
+ },
133
+ {
134
+ name: 'agentics_whoami',
135
+ description: 'Show current identity, org, and role. No synthesis.',
136
+ inputSchema: obj({ ...GLOBAL_OPTS }),
137
+ toArgs: (p) => ['whoami', ...globalFlags(p)],
138
+ },
139
+ // ===================== SIMULATION =====================
140
+ {
141
+ name: 'agentics_simulate_create',
142
+ description: '[synth] Create a new simulation from a natural-language scenario description.',
143
+ inputSchema: obj({
144
+ description: { type: 'string', description: 'Natural language scenario description' },
145
+ ...GLOBAL_OPTS,
146
+ }, ['description']),
147
+ toArgs: (p) => ['simulate', 'create', String(p['description']), ...globalFlags(p)],
148
+ },
149
+ {
150
+ name: 'agentics_simulate_run',
151
+ description: '[synth] Execute an existing simulation scenario. Incurs cost & risk analysis.',
152
+ inputSchema: obj({
153
+ scenario: { type: 'string', description: 'Scenario name or ID to run' },
154
+ ...GLOBAL_OPTS,
155
+ }, ['scenario']),
156
+ toArgs: (p) => ['simulate', 'run', String(p['scenario']), ...globalFlags(p)],
157
+ },
158
+ {
159
+ name: 'agentics_simulate_list',
160
+ description: 'List all simulations. Read-only, no synthesis.',
161
+ inputSchema: obj({ ...GLOBAL_OPTS }),
162
+ toArgs: (p) => ['simulate', 'list', ...globalFlags(p)],
163
+ },
164
+ {
165
+ name: 'agentics_simulate_inspect',
166
+ description: 'Inspect a simulation run by ID. Read-only, no synthesis.',
167
+ inputSchema: obj({
168
+ id: { type: 'string', description: 'Simulation run ID to inspect' },
169
+ ...GLOBAL_OPTS,
170
+ }, ['id']),
171
+ toArgs: (p) => ['simulate', 'inspect', String(p['id']), ...globalFlags(p)],
172
+ },
173
+ {
174
+ name: 'agentics_simulate_delete',
175
+ description: 'Delete a simulation scenario. Admin-only, no synthesis.',
176
+ inputSchema: obj({
177
+ scenario: { type: 'string', description: 'Scenario name or ID to delete' },
178
+ ...GLOBAL_OPTS,
179
+ }, ['scenario']),
180
+ toArgs: (p) => ['simulate', 'delete', String(p['scenario']), ...globalFlags(p)],
181
+ },
182
+ // ===================== PLANNING =====================
183
+ {
184
+ name: 'agentics_plan_create',
185
+ description: '[synth] Create a new deployment plan from a natural-language description.',
186
+ inputSchema: obj({
187
+ description: { type: 'string', description: 'Natural language deployment plan description' },
188
+ ...GLOBAL_OPTS,
189
+ }, ['description']),
190
+ toArgs: (p) => ['plan', 'create', String(p['description']), ...globalFlags(p)],
191
+ },
192
+ {
193
+ name: 'agentics_plan_list',
194
+ description: 'List all plans. Read-only, no synthesis.',
195
+ inputSchema: obj({ ...GLOBAL_OPTS }),
196
+ toArgs: (p) => ['plan', 'list', ...globalFlags(p)],
197
+ },
198
+ {
199
+ name: 'agentics_plan_inspect',
200
+ description: 'Inspect a plan by ID. Read-only, no synthesis.',
201
+ inputSchema: obj({
202
+ id: { type: 'string', description: 'Plan ID to inspect' },
203
+ ...GLOBAL_OPTS,
204
+ }, ['id']),
205
+ toArgs: (p) => ['plan', 'inspect', String(p['id']), ...globalFlags(p)],
206
+ },
207
+ {
208
+ name: 'agentics_plan_approve',
209
+ description: '[synth] Approve a plan — explicit commitment. Critical decision-grade operation.',
210
+ inputSchema: obj({
211
+ id: { type: 'string', description: 'Plan ID to approve' },
212
+ ...GLOBAL_OPTS,
213
+ }, ['id']),
214
+ toArgs: (p) => ['plan', 'approve', String(p['id']), ...globalFlags(p)],
215
+ },
216
+ {
217
+ name: 'agentics_plan_delete',
218
+ description: 'Delete a plan by ID. Admin-only, no synthesis.',
219
+ inputSchema: obj({
220
+ id: { type: 'string', description: 'Plan ID to delete' },
221
+ ...GLOBAL_OPTS,
222
+ }, ['id']),
223
+ toArgs: (p) => ['plan', 'delete', String(p['id']), ...globalFlags(p)],
224
+ },
225
+ // ===================== INSPECTION & OBSERVABILITY =====================
226
+ {
227
+ name: 'agentics_inspect_query',
228
+ description: 'Inspect a resource by natural-language query. Read-only, no synthesis.',
229
+ inputSchema: obj({
230
+ query: { type: 'string', description: 'Natural language query or resource reference' },
231
+ ...GLOBAL_OPTS,
232
+ }, ['query']),
233
+ toArgs: (p) => ['inspect', String(p['query']), ...globalFlags(p)],
234
+ },
235
+ {
236
+ name: 'agentics_inspect_run',
237
+ description: 'Inspect a specific run by ID. Read-only, no synthesis.',
238
+ inputSchema: obj({
239
+ id: { type: 'string', description: 'Run ID to inspect' },
240
+ ...GLOBAL_OPTS,
241
+ }, ['id']),
242
+ toArgs: (p) => ['inspect', 'run', String(p['id']), ...globalFlags(p)],
243
+ },
244
+ {
245
+ name: 'agentics_inspect_latest',
246
+ description: 'Inspect the most recent run. Read-only, no synthesis.',
247
+ inputSchema: obj({ ...GLOBAL_OPTS }),
248
+ toArgs: (p) => ['inspect', 'latest', ...globalFlags(p)],
249
+ },
250
+ {
251
+ name: 'agentics_inspect_artifacts',
252
+ description: 'List artifacts for a specific run. Read-only, no synthesis.',
253
+ inputSchema: obj({
254
+ id: { type: 'string', description: 'Run ID to list artifacts for' },
255
+ ...GLOBAL_OPTS,
256
+ }, ['id']),
257
+ toArgs: (p) => ['inspect', 'artifacts', String(p['id']), ...globalFlags(p)],
258
+ },
259
+ // ===================== USAGE & BILLING =====================
260
+ {
261
+ name: 'agentics_usage',
262
+ description: 'Show current usage summary (tokens, costs, rate limits). No synthesis.',
263
+ inputSchema: obj({ ...GLOBAL_OPTS }),
264
+ toArgs: (p) => ['usage', ...globalFlags(p)],
265
+ },
266
+ {
267
+ name: 'agentics_usage_history',
268
+ description: 'Show usage history over time. No synthesis.',
269
+ inputSchema: obj({ ...GLOBAL_OPTS }),
270
+ toArgs: (p) => ['usage', 'history', ...globalFlags(p)],
271
+ },
272
+ {
273
+ name: 'agentics_usage_limits',
274
+ description: 'Show current usage limits and quotas. No synthesis.',
275
+ inputSchema: obj({ ...GLOBAL_OPTS }),
276
+ toArgs: (p) => ['usage', 'limits', ...globalFlags(p)],
277
+ },
278
+ {
279
+ name: 'agentics_usage_reset',
280
+ description: 'Reset usage counters. No synthesis.',
281
+ inputSchema: obj({ ...GLOBAL_OPTS }),
282
+ toArgs: (p) => ['usage', 'reset', ...globalFlags(p)],
283
+ },
284
+ // ===================== ROI & QUANTIFICATION =====================
285
+ {
286
+ name: 'agentics_quantify_create',
287
+ description: '[synth] Create an ROI report from a natural-language scenario.',
288
+ inputSchema: obj({
289
+ description: { type: 'string', description: 'Natural language ROI scenario description' },
290
+ ...GLOBAL_OPTS,
291
+ }, ['description']),
292
+ toArgs: (p) => ['quantify', 'create', String(p['description']), ...globalFlags(p)],
293
+ },
294
+ {
295
+ name: 'agentics_quantify_inspect',
296
+ description: 'Inspect an ROI report by ID. Read-only, no synthesis.',
297
+ inputSchema: obj({
298
+ id: { type: 'string', description: 'ROI report ID to inspect' },
299
+ ...GLOBAL_OPTS,
300
+ }, ['id']),
301
+ toArgs: (p) => ['quantify', 'inspect', String(p['id']), ...globalFlags(p)],
302
+ },
303
+ {
304
+ name: 'agentics_quantify_list',
305
+ description: 'List all ROI reports. Read-only, no synthesis.',
306
+ inputSchema: obj({ ...GLOBAL_OPTS }),
307
+ toArgs: (p) => ['quantify', 'list', ...globalFlags(p)],
308
+ },
309
+ {
310
+ name: 'agentics_quantify_compare',
311
+ description: '[synth] Compare two ROI reports — explicit tradeoff decision.',
312
+ inputSchema: obj({
313
+ id_a: { type: 'string', description: 'First ROI report ID' },
314
+ id_b: { type: 'string', description: 'Second ROI report ID' },
315
+ ...GLOBAL_OPTS,
316
+ }, ['id_a', 'id_b']),
317
+ toArgs: (p) => ['quantify', 'compare', String(p['id_a']), String(p['id_b']), ...globalFlags(p)],
318
+ },
319
+ // ===================== DEPLOYMENT =====================
320
+ {
321
+ name: 'agentics_deploy_preview',
322
+ description: '[synth] Preview a deployment for a plan — risk analysis.',
323
+ inputSchema: obj({
324
+ id: { type: 'string', description: 'Plan ID to preview deployment for' },
325
+ ...GLOBAL_OPTS,
326
+ }, ['id']),
327
+ toArgs: (p) => ['deploy', 'preview', String(p['id']), ...globalFlags(p)],
328
+ },
329
+ {
330
+ name: 'agentics_deploy_run',
331
+ description: '[synth] Execute a deployment — irreversible commitment. Requires confirmation.',
332
+ inputSchema: obj({
333
+ id: { type: 'string', description: 'Plan ID to deploy' },
334
+ ...GLOBAL_OPTS,
335
+ }, ['id']),
336
+ toArgs: (p) => ['deploy', 'run', String(p['id']), ...globalFlags(p)],
337
+ },
338
+ {
339
+ name: 'agentics_deploy_status',
340
+ description: 'Check deployment status by ID. Read-only, no synthesis.',
341
+ inputSchema: obj({
342
+ id: { type: 'string', description: 'Deployment ID to check status' },
343
+ ...GLOBAL_OPTS,
344
+ }, ['id']),
345
+ toArgs: (p) => ['deploy', 'status', String(p['id']), ...globalFlags(p)],
346
+ },
347
+ {
348
+ name: 'agentics_deploy_rollback',
349
+ description: '[synth] Rollback a deployment — incident-grade decision.',
350
+ inputSchema: obj({
351
+ id: { type: 'string', description: 'Deployment ID to rollback' },
352
+ ...GLOBAL_OPTS,
353
+ }, ['id']),
354
+ toArgs: (p) => ['deploy', 'rollback', String(p['id']), ...globalFlags(p)],
355
+ },
356
+ // ===================== EXPORT & INFRASTRUCTURE =====================
357
+ {
358
+ name: 'agentics_export_terraform',
359
+ description: '[synth] Export deployment artifacts as Terraform IaC.',
360
+ inputSchema: obj({
361
+ id: { type: 'string', description: 'Plan ID to export as Terraform' },
362
+ ...GLOBAL_OPTS,
363
+ }, ['id']),
364
+ toArgs: (p) => ['export', 'terraform', String(p['id']), ...globalFlags(p)],
365
+ },
366
+ {
367
+ name: 'agentics_export_kubernetes',
368
+ description: '[synth] Export deployment artifacts as Kubernetes manifests.',
369
+ inputSchema: obj({
370
+ id: { type: 'string', description: 'Plan ID to export as Kubernetes' },
371
+ ...GLOBAL_OPTS,
372
+ }, ['id']),
373
+ toArgs: (p) => ['export', 'kubernetes', String(p['id']), ...globalFlags(p)],
374
+ },
375
+ {
376
+ name: 'agentics_export_erp',
377
+ description: '[synth] Export ERP integration artifacts for a plan.',
378
+ inputSchema: obj({
379
+ id: { type: 'string', description: 'Plan ID to export ERP artifacts for' },
380
+ ...GLOBAL_OPTS,
381
+ }, ['id']),
382
+ toArgs: (p) => ['export', 'erp', String(p['id']), ...globalFlags(p)],
383
+ },
384
+ // ===================== GOVERNANCE & POLICY =====================
385
+ {
386
+ name: 'agentics_policy_list',
387
+ description: 'List all governance policies. Read-only, no synthesis.',
388
+ inputSchema: obj({ ...GLOBAL_OPTS }),
389
+ toArgs: (p) => ['policy', 'list', ...globalFlags(p)],
390
+ },
391
+ {
392
+ name: 'agentics_policy_inspect',
393
+ description: 'Inspect a specific policy. Read-only, no synthesis.',
394
+ inputSchema: obj({
395
+ policy: { type: 'string', description: 'Policy name or ID to inspect' },
396
+ ...GLOBAL_OPTS,
397
+ }, ['policy']),
398
+ toArgs: (p) => ['policy', 'inspect', String(p['policy']), ...globalFlags(p)],
399
+ },
400
+ {
401
+ name: 'agentics_policy_create',
402
+ description: '[synth] Create a new governance policy. Optionally provide a --name.',
403
+ inputSchema: obj({
404
+ description: { type: 'string', description: 'Natural language policy description' },
405
+ name: { type: 'string', description: 'Policy name (e.g. "cost-cap-prod")' },
406
+ ...GLOBAL_OPTS,
407
+ }),
408
+ toArgs: (p) => {
409
+ const a = ['policy', 'create'];
410
+ if (p['description'])
411
+ a.push(String(p['description']));
412
+ if (p['name'])
413
+ a.push('--name', String(p['name']));
414
+ return [...a, ...globalFlags(p)];
415
+ },
416
+ },
417
+ {
418
+ name: 'agentics_policy_edit',
419
+ description: '[synth] Edit an existing governance policy.',
420
+ inputSchema: obj({
421
+ policy: { type: 'string', description: 'Policy name or ID to edit' },
422
+ ...GLOBAL_OPTS,
423
+ }, ['policy']),
424
+ toArgs: (p) => ['policy', 'edit', String(p['policy']), ...globalFlags(p)],
425
+ },
426
+ {
427
+ name: 'agentics_policy_delete',
428
+ description: 'Delete a governance policy. Admin-only, no synthesis.',
429
+ inputSchema: obj({
430
+ policy: { type: 'string', description: 'Policy name or ID to delete' },
431
+ ...GLOBAL_OPTS,
432
+ }, ['policy']),
433
+ toArgs: (p) => ['policy', 'delete', String(p['policy']), ...globalFlags(p)],
434
+ },
435
+ {
436
+ name: 'agentics_policy_enable',
437
+ description: '[synth] Enable a governance policy — critical operational decision.',
438
+ inputSchema: obj({
439
+ policy: { type: 'string', description: 'Policy name or ID to enable' },
440
+ ...GLOBAL_OPTS,
441
+ }, ['policy']),
442
+ toArgs: (p) => ['policy', 'enable', String(p['policy']), ...globalFlags(p)],
443
+ },
444
+ {
445
+ name: 'agentics_policy_disable',
446
+ description: '[synth] Disable a governance policy.',
447
+ inputSchema: obj({
448
+ policy: { type: 'string', description: 'Policy name or ID to disable' },
449
+ ...GLOBAL_OPTS,
450
+ }, ['policy']),
451
+ toArgs: (p) => ['policy', 'disable', String(p['policy']), ...globalFlags(p)],
452
+ },
453
+ {
454
+ name: 'agentics_policy_dry_run',
455
+ description: '[synth] Dry-run a policy to evaluate its impact without applying it.',
456
+ inputSchema: obj({
457
+ policy: { type: 'string', description: 'Policy name or ID to dry-run' },
458
+ ...GLOBAL_OPTS,
459
+ }, ['policy']),
460
+ toArgs: (p) => ['policy', 'dry-run', String(p['policy']), ...globalFlags(p)],
461
+ },
462
+ {
463
+ name: 'agentics_policy_scope',
464
+ description: 'Show the scope of a governance policy. Read-only, no synthesis.',
465
+ inputSchema: obj({
466
+ policy: { type: 'string', description: 'Policy name or ID to show scope for' },
467
+ ...GLOBAL_OPTS,
468
+ }, ['policy']),
469
+ toArgs: (p) => ['policy', 'scope', String(p['policy']), ...globalFlags(p)],
470
+ },
471
+ // ===================== ERP SURFACE =====================
472
+ {
473
+ name: 'agentics_erp_list',
474
+ description: 'List all connected ERP systems. Read-only, no synthesis.',
475
+ inputSchema: obj({ ...GLOBAL_OPTS }),
476
+ toArgs: (p) => ['erp', 'list', ...globalFlags(p)],
477
+ },
478
+ {
479
+ name: 'agentics_erp_inspect',
480
+ description: 'Inspect a specific ERP system. Read-only, no synthesis.',
481
+ inputSchema: obj({
482
+ system: { type: 'string', description: 'ERP system name or ID to inspect' },
483
+ ...GLOBAL_OPTS,
484
+ }, ['system']),
485
+ toArgs: (p) => ['erp', 'inspect', String(p['system']), ...globalFlags(p)],
486
+ },
487
+ {
488
+ name: 'agentics_erp_surface',
489
+ description: '[synth] Surface ERP integration points for a scenario.',
490
+ inputSchema: obj({
491
+ description: { type: 'string', description: 'Natural language scenario for ERP surfacing' },
492
+ ...GLOBAL_OPTS,
493
+ }, ['description']),
494
+ toArgs: (p) => ['erp', 'surface', String(p['description']), ...globalFlags(p)],
495
+ },
496
+ {
497
+ name: 'agentics_erp_map',
498
+ description: '[synth] Map a plan to ERP integration points — integration commitment.',
499
+ inputSchema: obj({
500
+ id: { type: 'string', description: 'Plan ID to map to ERP' },
501
+ ...GLOBAL_OPTS,
502
+ }, ['id']),
503
+ toArgs: (p) => ['erp', 'map', String(p['id']), ...globalFlags(p)],
504
+ },
505
+ {
506
+ name: 'agentics_erp_export',
507
+ description: '[synth] Export ERP integration artifacts for a plan.',
508
+ inputSchema: obj({
509
+ id: { type: 'string', description: 'Plan ID to export ERP integration for' },
510
+ ...GLOBAL_OPTS,
511
+ }, ['id']),
512
+ toArgs: (p) => ['erp', 'export', String(p['id']), ...globalFlags(p)],
513
+ },
514
+ // ===================== DILIGENCE =====================
515
+ {
516
+ name: 'agentics_diligence',
517
+ description: '[synth] Run due diligence analysis on references.',
518
+ inputSchema: obj({
519
+ description: { type: 'string', description: 'Natural language description or references for due diligence' },
520
+ ...GLOBAL_OPTS,
521
+ }, ['description']),
522
+ toArgs: (p) => ['diligence', String(p['description']), ...globalFlags(p)],
523
+ },
524
+ // ===================== AUDIT =====================
525
+ {
526
+ name: 'agentics_audit',
527
+ description: '[synth] Run audit analysis on the current project or references.',
528
+ inputSchema: obj({
529
+ description: { type: 'string', description: 'Natural language description or references for audit' },
530
+ ...GLOBAL_OPTS,
531
+ }),
532
+ toArgs: (p) => {
533
+ const a = ['audit'];
534
+ if (p['description'])
535
+ a.push(String(p['description']));
536
+ return [...a, ...globalFlags(p)];
537
+ },
538
+ },
539
+ ];
540
+ // ---------------------------------------------------------------------------
541
+ // Tool lookup map
542
+ // ---------------------------------------------------------------------------
543
+ const TOOL_MAP = new Map(TOOLS.map(t => [t.name, t]));
544
+ // ---------------------------------------------------------------------------
545
+ // CLI execution helper
546
+ // ---------------------------------------------------------------------------
547
+ function runCLI(args) {
548
+ return new Promise((resolve) => {
549
+ execFile('node', [CLI_ENTRY, ...args], {
550
+ timeout: 120_000,
551
+ env: { ...process.env, FORCE_COLOR: '0' },
552
+ maxBuffer: 4 * 1024 * 1024,
553
+ }, (error, stdout, stderr) => {
554
+ resolve({
555
+ stdout: stdout ?? '',
556
+ stderr: stderr ?? '',
557
+ code: error && 'code' in error ? error.code ?? 1 : 0,
558
+ });
559
+ });
560
+ });
561
+ }
562
+ // ---------------------------------------------------------------------------
563
+ // JSON-RPC message handler
564
+ // ---------------------------------------------------------------------------
565
+ async function handleMessage(msg) {
566
+ if (!msg.method) {
567
+ return {
568
+ jsonrpc: '2.0',
569
+ id: msg.id ?? null,
570
+ error: { code: -32600, message: 'Invalid Request: missing method' },
571
+ };
572
+ }
573
+ const params = (msg.params ?? {});
574
+ try {
575
+ switch (msg.method) {
576
+ // ---- Lifecycle ----
577
+ case 'initialize':
578
+ return {
579
+ jsonrpc: '2.0',
580
+ id: msg.id ?? null,
581
+ result: {
582
+ protocolVersion: '2024-11-05',
583
+ serverInfo: { name: 'agentics-cli', version: VERSION },
584
+ capabilities: {
585
+ tools: { listChanged: false },
586
+ },
587
+ },
588
+ };
589
+ case 'notifications/initialized':
590
+ log('INFO', 'Client initialized');
591
+ return null;
592
+ case 'ping':
593
+ return { jsonrpc: '2.0', id: msg.id ?? null, result: {} };
594
+ // ---- Tools ----
595
+ case 'tools/list':
596
+ return {
597
+ jsonrpc: '2.0',
598
+ id: msg.id ?? null,
599
+ result: {
600
+ tools: TOOLS.map(t => ({
601
+ name: t.name,
602
+ description: t.description,
603
+ inputSchema: t.inputSchema,
604
+ })),
605
+ },
606
+ };
607
+ case 'tools/call': {
608
+ const toolName = params['name'];
609
+ const toolArgs = (params['arguments'] ?? {});
610
+ const tool = TOOL_MAP.get(toolName);
611
+ if (!tool) {
612
+ return {
613
+ jsonrpc: '2.0',
614
+ id: msg.id ?? null,
615
+ error: { code: -32601, message: `Tool not found: ${toolName}` },
616
+ };
617
+ }
618
+ const cliArgs = tool.toArgs(toolArgs);
619
+ log('INFO', `Calling CLI: agentics ${cliArgs.join(' ')}`);
620
+ const result = await runCLI(cliArgs);
621
+ const output = result.stdout || result.stderr || '(no output)';
622
+ return {
623
+ jsonrpc: '2.0',
624
+ id: msg.id ?? null,
625
+ result: {
626
+ content: [{ type: 'text', text: output.trim() }],
627
+ isError: result.code !== 0,
628
+ },
629
+ };
630
+ }
631
+ default:
632
+ return {
633
+ jsonrpc: '2.0',
634
+ id: msg.id ?? null,
635
+ error: { code: -32601, message: `Method not found: ${msg.method}` },
636
+ };
637
+ }
638
+ }
639
+ catch (err) {
640
+ log('ERROR', `${msg.method}: ${err instanceof Error ? err.message : String(err)}`);
641
+ return {
642
+ jsonrpc: '2.0',
643
+ id: msg.id ?? null,
644
+ error: {
645
+ code: -32603,
646
+ message: err instanceof Error ? err.message : 'Internal error',
647
+ },
648
+ };
649
+ }
650
+ }
651
+ // ---------------------------------------------------------------------------
652
+ // stdio transport
653
+ // ---------------------------------------------------------------------------
654
+ let buffer = '';
655
+ process.stdin.setEncoding('utf8');
656
+ process.stdin.on('data', async (chunk) => {
657
+ buffer += chunk;
658
+ const lines = buffer.split('\n');
659
+ buffer = lines.pop() ?? '';
660
+ for (const line of lines) {
661
+ if (!line.trim())
662
+ continue;
663
+ try {
664
+ const message = JSON.parse(line);
665
+ const response = await handleMessage(message);
666
+ if (response) {
667
+ process.stdout.write(JSON.stringify(response) + '\n');
668
+ }
669
+ }
670
+ catch {
671
+ log('ERROR', 'Failed to parse message');
672
+ process.stdout.write(JSON.stringify({
673
+ jsonrpc: '2.0',
674
+ id: null,
675
+ error: { code: -32700, message: 'Parse error' },
676
+ }) + '\n');
677
+ }
678
+ }
679
+ });
680
+ process.stdin.on('end', () => {
681
+ log('INFO', 'stdin closed, shutting down');
682
+ process.exit(0);
683
+ });
684
+ process.on('SIGINT', () => {
685
+ log('INFO', 'Received SIGINT');
686
+ process.exit(0);
687
+ });
688
+ process.on('SIGTERM', () => {
689
+ log('INFO', 'Received SIGTERM');
690
+ process.exit(0);
691
+ });
692
+ //# sourceMappingURL=mcp-server.js.map