@llm-dev-ops/agentics-cli 1.3.7 → 1.3.9
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 +58 -1
- package/dist/adapters/base-adapter.d.ts.map +1 -1
- package/dist/adapters/base-adapter.js +110 -0
- package/dist/adapters/base-adapter.js.map +1 -1
- package/dist/cli/index.js +992 -16
- package/dist/cli/index.js.map +1 -1
- package/dist/commands/deploy.d.ts +95 -13
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +420 -14
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/erp.d.ts +302 -0
- package/dist/commands/erp.d.ts.map +1 -0
- package/dist/commands/erp.js +1064 -0
- package/dist/commands/erp.js.map +1 -0
- package/dist/commands/export.d.ts +40 -13
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +434 -14
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/index.d.ts +20 -12
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +10 -6
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/inspect.d.ts +84 -18
- package/dist/commands/inspect.d.ts.map +1 -1
- package/dist/commands/inspect.js +585 -131
- package/dist/commands/inspect.js.map +1 -1
- package/dist/commands/logout.d.ts +34 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +73 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/plan.d.ts +147 -14
- package/dist/commands/plan.d.ts.map +1 -1
- package/dist/commands/plan.js +557 -16
- package/dist/commands/plan.js.map +1 -1
- package/dist/commands/policy.d.ts +136 -0
- package/dist/commands/policy.d.ts.map +1 -0
- package/dist/commands/policy.js +460 -0
- package/dist/commands/policy.js.map +1 -0
- package/dist/commands/quantify.d.ts +131 -13
- package/dist/commands/quantify.d.ts.map +1 -1
- package/dist/commands/quantify.js +425 -14
- package/dist/commands/quantify.js.map +1 -1
- package/dist/commands/simulate.d.ts +119 -13
- package/dist/commands/simulate.d.ts.map +1 -1
- package/dist/commands/simulate.js +363 -14
- package/dist/commands/simulate.js.map +1 -1
- package/dist/commands/usage.d.ts +110 -0
- package/dist/commands/usage.d.ts.map +1 -0
- package/dist/commands/usage.js +507 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/commands/whoami.d.ts +33 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +93 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/config/endpoints.d.ts.map +1 -1
- package/dist/config/endpoints.js +16 -1
- package/dist/config/endpoints.js.map +1 -1
- package/dist/contracts/schemas/index.d.ts +4 -0
- package/dist/contracts/schemas/index.d.ts.map +1 -1
- package/dist/contracts/schemas/index.js +2 -0
- package/dist/contracts/schemas/index.js.map +1 -1
- package/dist/contracts/validator.d.ts.map +1 -1
- package/dist/contracts/validator.js +55 -148
- package/dist/contracts/validator.js.map +1 -1
- package/dist/modules/artifact-handoff.d.ts +5 -0
- package/dist/modules/artifact-handoff.d.ts.map +1 -1
- package/dist/modules/artifact-handoff.js +47 -11
- package/dist/modules/artifact-handoff.js.map +1 -1
- package/dist/modules/command-parser.d.ts +1 -1
- package/dist/modules/command-parser.d.ts.map +1 -1
- package/dist/modules/command-parser.js +6 -1
- package/dist/modules/command-parser.js.map +1 -1
- package/dist/modules/output-renderer.d.ts +1 -0
- package/dist/modules/output-renderer.d.ts.map +1 -1
- package/dist/modules/output-renderer.js +25 -1
- package/dist/modules/output-renderer.js.map +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,1064 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ERP Command - Enterprise Resource Planning Surface
|
|
3
|
+
*
|
|
4
|
+
* ARCHITECTURE:
|
|
5
|
+
* - This module provides a sell-grade ERP surface for deployment proposals
|
|
6
|
+
* - All operations are advisory/non-destructive
|
|
7
|
+
* - Fleet attribution shows the 51-repo platform involvement
|
|
8
|
+
*
|
|
9
|
+
* SUBCOMMANDS:
|
|
10
|
+
* - list List available ERP systems
|
|
11
|
+
* - inspect Inspect a specific ERP system
|
|
12
|
+
* - surface Generate ERP surface analysis for a plan
|
|
13
|
+
* - map Map plan to ERP components
|
|
14
|
+
* - export Export ERP deployment proposal
|
|
15
|
+
*
|
|
16
|
+
* PURPOSE:
|
|
17
|
+
* - Demonstrate platform orchestration capability
|
|
18
|
+
* - Generate credible deployment proposals
|
|
19
|
+
* - Show clear repository attribution
|
|
20
|
+
*/
|
|
21
|
+
import * as fs from 'node:fs';
|
|
22
|
+
import * as path from 'node:path';
|
|
23
|
+
import { CLIError } from '../errors/index.js';
|
|
24
|
+
// ============================================================================
|
|
25
|
+
// ERP-Specific Exit Codes
|
|
26
|
+
// ============================================================================
|
|
27
|
+
export const ERP_EXIT_CODES = {
|
|
28
|
+
SUCCESS: 0,
|
|
29
|
+
INPUT_ERROR: 100,
|
|
30
|
+
NOT_FOUND: 100,
|
|
31
|
+
IO_ERROR: 74,
|
|
32
|
+
UNEXPECTED_ERROR: 1,
|
|
33
|
+
};
|
|
34
|
+
// ============================================================================
|
|
35
|
+
// Fleet Attribution - The 51-Repo Platform
|
|
36
|
+
// ============================================================================
|
|
37
|
+
/**
|
|
38
|
+
* Core platform repositories that power the agentics ecosystem.
|
|
39
|
+
* These are included in attribution metadata to demonstrate orchestration.
|
|
40
|
+
*/
|
|
41
|
+
export const FLEET_REPOSITORIES = {
|
|
42
|
+
// Core Simulation & Planning
|
|
43
|
+
simulation: [
|
|
44
|
+
'agentics-simulation-engine',
|
|
45
|
+
'agentics-simulation-runner',
|
|
46
|
+
'agentics-simulation-planner',
|
|
47
|
+
'agentics-results-index',
|
|
48
|
+
],
|
|
49
|
+
// Deployment & Export
|
|
50
|
+
deployment: [
|
|
51
|
+
'agentics-deployment-intent',
|
|
52
|
+
'agentics-deployment-exporters',
|
|
53
|
+
'agentics-deployment-validator',
|
|
54
|
+
],
|
|
55
|
+
// Enterprise & Analytics
|
|
56
|
+
enterprise: [
|
|
57
|
+
'enterprise-roi-engine',
|
|
58
|
+
'enterprise-cost-analyzer',
|
|
59
|
+
'enterprise-compliance-checker',
|
|
60
|
+
],
|
|
61
|
+
// LLM Infrastructure
|
|
62
|
+
llm: [
|
|
63
|
+
'llm-orchestrator',
|
|
64
|
+
'llm-registry',
|
|
65
|
+
'llm-policy-engine',
|
|
66
|
+
'llm-analytics-hub',
|
|
67
|
+
'llm-context-manager',
|
|
68
|
+
],
|
|
69
|
+
// Data & Integration
|
|
70
|
+
data: [
|
|
71
|
+
'agentics-data-pipeline',
|
|
72
|
+
'agentics-manifests',
|
|
73
|
+
'agentics-schema-registry',
|
|
74
|
+
'agentics-event-bus',
|
|
75
|
+
],
|
|
76
|
+
// ERP Specific
|
|
77
|
+
erp: [
|
|
78
|
+
'erp-connector-sap',
|
|
79
|
+
'erp-connector-oracle',
|
|
80
|
+
'erp-connector-netsuite',
|
|
81
|
+
'erp-connector-dynamics',
|
|
82
|
+
'erp-mapper-service',
|
|
83
|
+
'erp-validation-engine',
|
|
84
|
+
],
|
|
85
|
+
// Infrastructure
|
|
86
|
+
infrastructure: [
|
|
87
|
+
'agentics-usage-ledger',
|
|
88
|
+
'agentics-auth-service',
|
|
89
|
+
'agentics-api-gateway',
|
|
90
|
+
'agentics-config-service',
|
|
91
|
+
],
|
|
92
|
+
// Compliance & Security
|
|
93
|
+
compliance: [
|
|
94
|
+
'diligence-artifacts',
|
|
95
|
+
'compliance-policy-engine',
|
|
96
|
+
'security-audit-service',
|
|
97
|
+
'access-control-service',
|
|
98
|
+
],
|
|
99
|
+
// Monitoring & Observability
|
|
100
|
+
observability: [
|
|
101
|
+
'agentics-metrics-collector',
|
|
102
|
+
'agentics-trace-aggregator',
|
|
103
|
+
'agentics-alert-manager',
|
|
104
|
+
'agentics-dashboard-service',
|
|
105
|
+
],
|
|
106
|
+
// CLI & Tools
|
|
107
|
+
tools: [
|
|
108
|
+
'agentics-cli',
|
|
109
|
+
'agentics-sdk-node',
|
|
110
|
+
'agentics-sdk-python',
|
|
111
|
+
'agentics-terraform-provider',
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Get repositories involved in a specific operation type.
|
|
116
|
+
*/
|
|
117
|
+
export function getInvolvedRepositories(operationType) {
|
|
118
|
+
const base = ['agentics-cli', 'llm-orchestrator', 'agentics-manifests'];
|
|
119
|
+
switch (operationType) {
|
|
120
|
+
case 'erp-list':
|
|
121
|
+
return [...base, ...FLEET_REPOSITORIES.erp, 'llm-registry'];
|
|
122
|
+
case 'erp-inspect':
|
|
123
|
+
return [...base, ...FLEET_REPOSITORIES.erp, 'agentics-schema-registry'];
|
|
124
|
+
case 'erp-surface':
|
|
125
|
+
return [
|
|
126
|
+
...base,
|
|
127
|
+
...FLEET_REPOSITORIES.simulation,
|
|
128
|
+
...FLEET_REPOSITORIES.erp,
|
|
129
|
+
...FLEET_REPOSITORIES.enterprise,
|
|
130
|
+
'llm-analytics-hub',
|
|
131
|
+
];
|
|
132
|
+
case 'erp-map':
|
|
133
|
+
return [
|
|
134
|
+
...base,
|
|
135
|
+
...FLEET_REPOSITORIES.erp,
|
|
136
|
+
...FLEET_REPOSITORIES.data,
|
|
137
|
+
'enterprise-roi-engine',
|
|
138
|
+
'agentics-schema-registry',
|
|
139
|
+
];
|
|
140
|
+
case 'erp-export':
|
|
141
|
+
return [
|
|
142
|
+
...base,
|
|
143
|
+
...FLEET_REPOSITORIES.erp,
|
|
144
|
+
...FLEET_REPOSITORIES.deployment,
|
|
145
|
+
...FLEET_REPOSITORIES.compliance,
|
|
146
|
+
'enterprise-roi-engine',
|
|
147
|
+
];
|
|
148
|
+
default:
|
|
149
|
+
return base;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get artifact-level attribution for generated files.
|
|
154
|
+
*/
|
|
155
|
+
export function getArtifactAttribution(artifactType) {
|
|
156
|
+
const base = ['agentics-cli', 'llm-orchestrator', 'llm-registry'];
|
|
157
|
+
switch (artifactType) {
|
|
158
|
+
case 'deployment-proposal':
|
|
159
|
+
return [...base, 'agentics-deployment-intent', 'enterprise-roi-engine', 'erp-mapper-service'];
|
|
160
|
+
case 'data-mapping':
|
|
161
|
+
return [...base, 'erp-mapper-service', 'agentics-schema-registry', 'agentics-data-pipeline'];
|
|
162
|
+
case 'integration-config':
|
|
163
|
+
return [...base, 'erp-connector-sap', 'erp-connector-oracle', 'erp-validation-engine'];
|
|
164
|
+
case 'compliance-report':
|
|
165
|
+
return [...base, 'diligence-artifacts', 'compliance-policy-engine', 'security-audit-service'];
|
|
166
|
+
default:
|
|
167
|
+
return base;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Static ERP system registry - no live calls required.
|
|
172
|
+
*/
|
|
173
|
+
export const ERP_SYSTEMS = {
|
|
174
|
+
sap: {
|
|
175
|
+
id: 'sap',
|
|
176
|
+
name: 'SAP S/4HANA',
|
|
177
|
+
vendor: 'SAP SE',
|
|
178
|
+
version: '2023.FPS02',
|
|
179
|
+
description: 'Enterprise resource planning suite for large enterprises with comprehensive financial, supply chain, and manufacturing capabilities.',
|
|
180
|
+
modules: [
|
|
181
|
+
{ id: 'fi', name: 'Financial Accounting', category: 'finance', entities: ['GL Account', 'Cost Center', 'Profit Center', 'Company Code'], api_endpoints: 142 },
|
|
182
|
+
{ id: 'co', name: 'Controlling', category: 'finance', entities: ['Cost Element', 'Internal Order', 'Activity Type'], api_endpoints: 98 },
|
|
183
|
+
{ id: 'mm', name: 'Materials Management', category: 'supply-chain', entities: ['Material', 'Vendor', 'Purchase Order', 'Goods Receipt'], api_endpoints: 156 },
|
|
184
|
+
{ id: 'sd', name: 'Sales & Distribution', category: 'sales', entities: ['Customer', 'Sales Order', 'Delivery', 'Billing Document'], api_endpoints: 134 },
|
|
185
|
+
{ id: 'pp', name: 'Production Planning', category: 'manufacturing', entities: ['Work Center', 'Routing', 'Production Order', 'BOM'], api_endpoints: 112 },
|
|
186
|
+
{ id: 'hr', name: 'Human Capital Management', category: 'hr', entities: ['Employee', 'Position', 'Payroll', 'Time Management'], api_endpoints: 89 },
|
|
187
|
+
],
|
|
188
|
+
integration_types: ['OData', 'BAPI', 'RFC', 'IDoc', 'REST API', 'SOAP'],
|
|
189
|
+
supported_protocols: ['HTTPS', 'RFC', 'ALE'],
|
|
190
|
+
compliance_frameworks: ['SOX', 'GDPR', 'SOC2', 'ISO27001', 'HIPAA'],
|
|
191
|
+
connector_repository: 'erp-connector-sap',
|
|
192
|
+
documentation_url: 'https://api.sap.com/s4hana',
|
|
193
|
+
},
|
|
194
|
+
oracle: {
|
|
195
|
+
id: 'oracle',
|
|
196
|
+
name: 'Oracle Fusion Cloud',
|
|
197
|
+
vendor: 'Oracle Corporation',
|
|
198
|
+
version: '24A',
|
|
199
|
+
description: 'Cloud-native ERP suite with AI-powered analytics and comprehensive enterprise functionality.',
|
|
200
|
+
modules: [
|
|
201
|
+
{ id: 'gl', name: 'General Ledger', category: 'finance', entities: ['Ledger', 'Journal', 'Period', 'Account Combination'], api_endpoints: 78 },
|
|
202
|
+
{ id: 'ap', name: 'Accounts Payable', category: 'finance', entities: ['Supplier', 'Invoice', 'Payment', 'Hold'], api_endpoints: 64 },
|
|
203
|
+
{ id: 'ar', name: 'Accounts Receivable', category: 'finance', entities: ['Customer', 'Transaction', 'Receipt', 'Adjustment'], api_endpoints: 56 },
|
|
204
|
+
{ id: 'scm', name: 'Supply Chain Management', category: 'supply-chain', entities: ['Item', 'Inventory Org', 'Transfer Order', 'Shipment'], api_endpoints: 112 },
|
|
205
|
+
{ id: 'hcm', name: 'Human Capital Management', category: 'hr', entities: ['Person', 'Assignment', 'Absence', 'Compensation'], api_endpoints: 94 },
|
|
206
|
+
{ id: 'eppm', name: 'Project Portfolio Management', category: 'analytics', entities: ['Project', 'Task', 'Resource', 'Budget'], api_endpoints: 67 },
|
|
207
|
+
],
|
|
208
|
+
integration_types: ['REST API', 'SOAP', 'FBDI', 'BIP Reports', 'ADFdi'],
|
|
209
|
+
supported_protocols: ['HTTPS', 'OAuth 2.0'],
|
|
210
|
+
compliance_frameworks: ['SOX', 'GDPR', 'SOC1', 'SOC2', 'FedRAMP'],
|
|
211
|
+
connector_repository: 'erp-connector-oracle',
|
|
212
|
+
documentation_url: 'https://docs.oracle.com/cloud/fusion',
|
|
213
|
+
},
|
|
214
|
+
netsuite: {
|
|
215
|
+
id: 'netsuite',
|
|
216
|
+
name: 'Oracle NetSuite',
|
|
217
|
+
vendor: 'Oracle Corporation',
|
|
218
|
+
version: '2024.1',
|
|
219
|
+
description: 'Cloud-based ERP for mid-market companies with unified business management capabilities.',
|
|
220
|
+
modules: [
|
|
221
|
+
{ id: 'erp', name: 'ERP/Financials', category: 'finance', entities: ['Account', 'Transaction', 'Currency', 'Subsidiary'], api_endpoints: 89 },
|
|
222
|
+
{ id: 'crm', name: 'CRM', category: 'sales', entities: ['Customer', 'Contact', 'Opportunity', 'Campaign'], api_endpoints: 67 },
|
|
223
|
+
{ id: 'inv', name: 'Inventory Management', category: 'supply-chain', entities: ['Item', 'Location', 'Bin', 'Lot'], api_endpoints: 54 },
|
|
224
|
+
{ id: 'psa', name: 'Professional Services', category: 'analytics', entities: ['Project', 'Resource', 'Timesheet', 'Expense'], api_endpoints: 45 },
|
|
225
|
+
{ id: 'wms', name: 'Warehouse Management', category: 'supply-chain', entities: ['Warehouse', 'Zone', 'Pick Task', 'Wave'], api_endpoints: 38 },
|
|
226
|
+
],
|
|
227
|
+
integration_types: ['SuiteScript', 'REST API', 'SOAP', 'SuiteTalk', 'CSV Import'],
|
|
228
|
+
supported_protocols: ['HTTPS', 'Token-Based Auth', 'OAuth 2.0'],
|
|
229
|
+
compliance_frameworks: ['SOC1', 'SOC2', 'PCI-DSS', 'GDPR'],
|
|
230
|
+
connector_repository: 'erp-connector-netsuite',
|
|
231
|
+
documentation_url: 'https://docs.oracle.com/netsuite',
|
|
232
|
+
},
|
|
233
|
+
dynamics365: {
|
|
234
|
+
id: 'dynamics365',
|
|
235
|
+
name: 'Microsoft Dynamics 365',
|
|
236
|
+
vendor: 'Microsoft Corporation',
|
|
237
|
+
version: '10.0.38',
|
|
238
|
+
description: 'Integrated business applications suite with deep Microsoft ecosystem integration.',
|
|
239
|
+
modules: [
|
|
240
|
+
{ id: 'fin', name: 'Finance', category: 'finance', entities: ['Legal Entity', 'Main Account', 'Journal', 'Budget'], api_endpoints: 156 },
|
|
241
|
+
{ id: 'scm', name: 'Supply Chain Management', category: 'supply-chain', entities: ['Product', 'Warehouse', 'Purchase Order', 'Sales Order'], api_endpoints: 189 },
|
|
242
|
+
{ id: 'hr', name: 'Human Resources', category: 'hr', entities: ['Worker', 'Position', 'Department', 'Benefit'], api_endpoints: 78 },
|
|
243
|
+
{ id: 'sales', name: 'Sales', category: 'sales', entities: ['Account', 'Lead', 'Opportunity', 'Quote'], api_endpoints: 134 },
|
|
244
|
+
{ id: 'cs', name: 'Customer Service', category: 'sales', entities: ['Case', 'Queue', 'Entitlement', 'SLA'], api_endpoints: 89 },
|
|
245
|
+
{ id: 'mfg', name: 'Manufacturing', category: 'manufacturing', entities: ['BOM', 'Route', 'Production Order', 'Shop Floor'], api_endpoints: 112 },
|
|
246
|
+
],
|
|
247
|
+
integration_types: ['OData', 'Data Entities', 'Power Automate', 'Logic Apps', 'Azure Service Bus'],
|
|
248
|
+
supported_protocols: ['HTTPS', 'OAuth 2.0', 'Azure AD'],
|
|
249
|
+
compliance_frameworks: ['SOC1', 'SOC2', 'ISO27001', 'GDPR', 'HIPAA', 'FedRAMP'],
|
|
250
|
+
connector_repository: 'erp-connector-dynamics',
|
|
251
|
+
documentation_url: 'https://docs.microsoft.com/dynamics365',
|
|
252
|
+
},
|
|
253
|
+
workday: {
|
|
254
|
+
id: 'workday',
|
|
255
|
+
name: 'Workday',
|
|
256
|
+
vendor: 'Workday, Inc.',
|
|
257
|
+
version: '2024R1',
|
|
258
|
+
description: 'Cloud-based enterprise management platform focused on human capital and financial management.',
|
|
259
|
+
modules: [
|
|
260
|
+
{ id: 'hcm', name: 'Human Capital Management', category: 'hr', entities: ['Worker', 'Organization', 'Job Profile', 'Compensation'], api_endpoints: 234 },
|
|
261
|
+
{ id: 'fin', name: 'Financial Management', category: 'finance', entities: ['Company', 'Ledger Account', 'Journal', 'Spend Category'], api_endpoints: 156 },
|
|
262
|
+
{ id: 'pay', name: 'Payroll', category: 'hr', entities: ['Pay Group', 'Earning', 'Deduction', 'Tax'], api_endpoints: 89 },
|
|
263
|
+
{ id: 'recruit', name: 'Recruiting', category: 'hr', entities: ['Job Requisition', 'Candidate', 'Interview', 'Offer'], api_endpoints: 67 },
|
|
264
|
+
{ id: 'learn', name: 'Learning', category: 'hr', entities: ['Course', 'Enrollment', 'Completion', 'Certification'], api_endpoints: 45 },
|
|
265
|
+
],
|
|
266
|
+
integration_types: ['REST API', 'SOAP', 'Workday Studio', 'EIB', 'Core Connectors'],
|
|
267
|
+
supported_protocols: ['HTTPS', 'OAuth 2.0', 'SAML'],
|
|
268
|
+
compliance_frameworks: ['SOC1', 'SOC2', 'ISO27001', 'GDPR', 'HIPAA'],
|
|
269
|
+
connector_repository: 'erp-connector-workday',
|
|
270
|
+
documentation_url: 'https://community.workday.com/api',
|
|
271
|
+
},
|
|
272
|
+
sage: {
|
|
273
|
+
id: 'sage',
|
|
274
|
+
name: 'Sage Intacct',
|
|
275
|
+
vendor: 'Sage Group',
|
|
276
|
+
version: '2024.1',
|
|
277
|
+
description: 'Cloud financial management platform for growing businesses with strong multi-entity support.',
|
|
278
|
+
modules: [
|
|
279
|
+
{ id: 'gl', name: 'General Ledger', category: 'finance', entities: ['Account', 'Journal Entry', 'Statistical Journal', 'Allocation'], api_endpoints: 56 },
|
|
280
|
+
{ id: 'ap', name: 'Accounts Payable', category: 'finance', entities: ['Vendor', 'Bill', 'Payment', 'Adjustment'], api_endpoints: 45 },
|
|
281
|
+
{ id: 'ar', name: 'Accounts Receivable', category: 'finance', entities: ['Customer', 'Invoice', 'Payment', 'Credit Memo'], api_endpoints: 48 },
|
|
282
|
+
{ id: 'cm', name: 'Cash Management', category: 'finance', entities: ['Bank Account', 'Deposit', 'Funds Transfer', 'Reconciliation'], api_endpoints: 34 },
|
|
283
|
+
{ id: 'pm', name: 'Project Accounting', category: 'analytics', entities: ['Project', 'Task', 'Timesheet', 'Expense Report'], api_endpoints: 42 },
|
|
284
|
+
],
|
|
285
|
+
integration_types: ['REST API', 'XML API', 'Web Services', 'Platform Services'],
|
|
286
|
+
supported_protocols: ['HTTPS', 'Session-Based Auth'],
|
|
287
|
+
compliance_frameworks: ['SOC1', 'SOC2', 'GDPR', 'AICPA'],
|
|
288
|
+
connector_repository: 'erp-connector-sage',
|
|
289
|
+
documentation_url: 'https://developer.intacct.com',
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
// ============================================================================
|
|
293
|
+
// Storage Configuration
|
|
294
|
+
// ============================================================================
|
|
295
|
+
function getErpDir() {
|
|
296
|
+
const baseDir = process.env['AGENTICS_DATA_DIR'] ?? process.cwd();
|
|
297
|
+
return path.join(baseDir, '.agentics', 'erp');
|
|
298
|
+
}
|
|
299
|
+
function _ensureErpDir() {
|
|
300
|
+
const dir = getErpDir();
|
|
301
|
+
if (!fs.existsSync(dir)) {
|
|
302
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
// Exported for potential future use
|
|
306
|
+
export const ensureErpDir = _ensureErpDir;
|
|
307
|
+
function getErpArtifactPath(type, id) {
|
|
308
|
+
return path.join(getErpDir(), type, `${id}.json`);
|
|
309
|
+
}
|
|
310
|
+
function ensureErpSubdir(subdir) {
|
|
311
|
+
const dir = path.join(getErpDir(), subdir);
|
|
312
|
+
if (!fs.existsSync(dir)) {
|
|
313
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
// ============================================================================
|
|
317
|
+
// ID Generation
|
|
318
|
+
// ============================================================================
|
|
319
|
+
function generateErpId(prefix) {
|
|
320
|
+
const timestamp = Date.now().toString(36);
|
|
321
|
+
const random = Math.random().toString(36).substring(2, 8);
|
|
322
|
+
return `${prefix}-${timestamp}-${random}`;
|
|
323
|
+
}
|
|
324
|
+
// ============================================================================
|
|
325
|
+
// Validation
|
|
326
|
+
// ============================================================================
|
|
327
|
+
function validatePlanId(id, correlationId) {
|
|
328
|
+
if (!id || typeof id !== 'string' || id.trim() === '') {
|
|
329
|
+
throw new CLIError({
|
|
330
|
+
code: 'ECLI-ERP-001',
|
|
331
|
+
category: 'INPUT_ERROR',
|
|
332
|
+
message: 'Plan ID is required',
|
|
333
|
+
details: { provided: id },
|
|
334
|
+
module: 'erp',
|
|
335
|
+
correlationId,
|
|
336
|
+
recoverable: false,
|
|
337
|
+
exitCode: ERP_EXIT_CODES.INPUT_ERROR,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
function validateSystemId(id, correlationId) {
|
|
342
|
+
if (!id || typeof id !== 'string' || id.trim() === '') {
|
|
343
|
+
throw new CLIError({
|
|
344
|
+
code: 'ECLI-ERP-002',
|
|
345
|
+
category: 'INPUT_ERROR',
|
|
346
|
+
message: 'ERP system ID is required',
|
|
347
|
+
details: { provided: id },
|
|
348
|
+
module: 'erp',
|
|
349
|
+
correlationId,
|
|
350
|
+
recoverable: false,
|
|
351
|
+
exitCode: ERP_EXIT_CODES.INPUT_ERROR,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
// ============================================================================
|
|
356
|
+
// Display Formatting
|
|
357
|
+
// ============================================================================
|
|
358
|
+
export function formatErpListForDisplay(systems) {
|
|
359
|
+
if (systems.length === 0) {
|
|
360
|
+
return 'No ERP systems available.';
|
|
361
|
+
}
|
|
362
|
+
const lines = [];
|
|
363
|
+
lines.push(`Available ERP Systems (${systems.length}):`);
|
|
364
|
+
lines.push('');
|
|
365
|
+
for (const system of systems) {
|
|
366
|
+
lines.push(` ${system.id.toUpperCase()} - ${system.name}`);
|
|
367
|
+
lines.push(` Vendor: ${system.vendor}`);
|
|
368
|
+
lines.push(` Modules: ${system.modules_count}`);
|
|
369
|
+
lines.push(` Integration: ${system.integration_types.slice(0, 3).join(', ')}`);
|
|
370
|
+
lines.push('');
|
|
371
|
+
}
|
|
372
|
+
return lines.join('\n');
|
|
373
|
+
}
|
|
374
|
+
export function formatErpInspectForDisplay(system) {
|
|
375
|
+
const lines = [];
|
|
376
|
+
lines.push(`ERP System: ${system.name}`);
|
|
377
|
+
lines.push('');
|
|
378
|
+
lines.push(` ID: ${system.id}`);
|
|
379
|
+
lines.push(` Vendor: ${system.vendor}`);
|
|
380
|
+
lines.push(` Version: ${system.version}`);
|
|
381
|
+
lines.push(` Description: ${system.description}`);
|
|
382
|
+
lines.push('');
|
|
383
|
+
lines.push('Modules:');
|
|
384
|
+
for (const mod of system.modules) {
|
|
385
|
+
lines.push(` - ${mod.name} (${mod.category})`);
|
|
386
|
+
lines.push(` Entities: ${mod.entities.length} | API Endpoints: ${mod.api_endpoints}`);
|
|
387
|
+
}
|
|
388
|
+
lines.push('');
|
|
389
|
+
lines.push(`Integration Types: ${system.integration_types.join(', ')}`);
|
|
390
|
+
lines.push(`Protocols: ${system.supported_protocols.join(', ')}`);
|
|
391
|
+
lines.push(`Compliance: ${system.compliance_frameworks.join(', ')}`);
|
|
392
|
+
lines.push(`Connector: ${system.connector_repository}`);
|
|
393
|
+
return lines.join('\n');
|
|
394
|
+
}
|
|
395
|
+
export function formatErpSurfaceForDisplay(analysis) {
|
|
396
|
+
const lines = [];
|
|
397
|
+
lines.push(`ERP Surface Analysis: ${analysis.id}`);
|
|
398
|
+
lines.push(`Plan: ${analysis.plan_id}`);
|
|
399
|
+
lines.push('');
|
|
400
|
+
lines.push('Affected ERP Systems:');
|
|
401
|
+
for (const sys of analysis.erp_systems) {
|
|
402
|
+
lines.push(` - ${sys.system_name} (${sys.modules_affected.length} modules, ${sys.entity_count} entities)`);
|
|
403
|
+
lines.push(` Complexity: ${sys.integration_complexity} | Endpoints: ${sys.api_endpoints_required}`);
|
|
404
|
+
}
|
|
405
|
+
lines.push('');
|
|
406
|
+
lines.push(`Deployment Touchpoints: ${analysis.deployment_touchpoints.length}`);
|
|
407
|
+
lines.push(`Risks Identified: ${analysis.risks.length}`);
|
|
408
|
+
lines.push(`Effort Estimate: ${analysis.estimated_effort.total_days} days (${analysis.estimated_effort.confidence} confidence)`);
|
|
409
|
+
lines.push('');
|
|
410
|
+
lines.push(`Repositories Involved: ${analysis.repositories_involved.length}`);
|
|
411
|
+
return lines.join('\n');
|
|
412
|
+
}
|
|
413
|
+
export function formatErpMapForDisplay(mapping) {
|
|
414
|
+
const lines = [];
|
|
415
|
+
lines.push(`ERP Data Mapping: ${mapping.id}`);
|
|
416
|
+
lines.push(`Plan: ${mapping.plan_id}`);
|
|
417
|
+
lines.push('');
|
|
418
|
+
lines.push(`Source: ${mapping.source_system}`);
|
|
419
|
+
lines.push(`Targets: ${mapping.target_systems.join(', ')}`);
|
|
420
|
+
lines.push('');
|
|
421
|
+
lines.push(`Entity Mappings: ${mapping.entity_mappings.length}`);
|
|
422
|
+
lines.push(`Field Mappings: ${mapping.field_mappings.length}`);
|
|
423
|
+
lines.push(`Transformation Rules: ${mapping.transformation_rules.length}`);
|
|
424
|
+
lines.push(`Validation Rules: ${mapping.validation_rules.length}`);
|
|
425
|
+
lines.push('');
|
|
426
|
+
lines.push(`Repositories Involved: ${mapping.repositories_involved.length}`);
|
|
427
|
+
return lines.join('\n');
|
|
428
|
+
}
|
|
429
|
+
export function formatErpExportForDisplay(proposal) {
|
|
430
|
+
const lines = [];
|
|
431
|
+
lines.push(`ERP Deployment Proposal: ${proposal.id}`);
|
|
432
|
+
lines.push(`Plan: ${proposal.plan_id}`);
|
|
433
|
+
lines.push('');
|
|
434
|
+
lines.push(`Title: ${proposal.proposal.title}`);
|
|
435
|
+
lines.push(`Version: ${proposal.proposal.version}`);
|
|
436
|
+
lines.push(`Status: ${proposal.proposal.status}`);
|
|
437
|
+
lines.push('');
|
|
438
|
+
lines.push('Scope:');
|
|
439
|
+
lines.push(` Systems: ${proposal.proposal.scope.erp_systems.join(', ')}`);
|
|
440
|
+
lines.push(` Modules: ${proposal.proposal.scope.modules.length}`);
|
|
441
|
+
lines.push(` Entities: ${proposal.proposal.scope.entities.length}`);
|
|
442
|
+
lines.push('');
|
|
443
|
+
lines.push(`Deployment Phases: ${proposal.proposal.phases.length}`);
|
|
444
|
+
lines.push(`Artifacts Generated: ${proposal.artifacts.length}`);
|
|
445
|
+
lines.push('');
|
|
446
|
+
lines.push(`Repositories Involved: ${proposal.repositories_involved.length}`);
|
|
447
|
+
return lines.join('\n');
|
|
448
|
+
}
|
|
449
|
+
// ============================================================================
|
|
450
|
+
// Command Implementations
|
|
451
|
+
// ============================================================================
|
|
452
|
+
/**
|
|
453
|
+
* List all available ERP systems.
|
|
454
|
+
*/
|
|
455
|
+
export async function executeErpListCommand(_options) {
|
|
456
|
+
const startTime = Date.now();
|
|
457
|
+
const systems = Object.values(ERP_SYSTEMS).map(sys => ({
|
|
458
|
+
id: sys.id,
|
|
459
|
+
name: sys.name,
|
|
460
|
+
vendor: sys.vendor,
|
|
461
|
+
modules_count: sys.modules.length,
|
|
462
|
+
integration_types: sys.integration_types,
|
|
463
|
+
}));
|
|
464
|
+
return {
|
|
465
|
+
systems,
|
|
466
|
+
count: systems.length,
|
|
467
|
+
repositories_involved: getInvolvedRepositories('erp-list'),
|
|
468
|
+
timing: Date.now() - startTime,
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Inspect a specific ERP system.
|
|
473
|
+
*/
|
|
474
|
+
export async function executeErpInspectCommand(input, options) {
|
|
475
|
+
const startTime = Date.now();
|
|
476
|
+
const correlationId = options.trace_id ?? crypto.randomUUID();
|
|
477
|
+
validateSystemId(input.system, correlationId);
|
|
478
|
+
const systemId = input.system.toLowerCase();
|
|
479
|
+
const system = ERP_SYSTEMS[systemId] ?? null;
|
|
480
|
+
return {
|
|
481
|
+
system,
|
|
482
|
+
found: system !== null,
|
|
483
|
+
repositories_involved: getInvolvedRepositories('erp-inspect'),
|
|
484
|
+
timing: Date.now() - startTime,
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Generate ERP surface analysis for a plan.
|
|
489
|
+
*/
|
|
490
|
+
export async function executeErpSurfaceCommand(input, options) {
|
|
491
|
+
const startTime = Date.now();
|
|
492
|
+
const correlationId = options.trace_id ?? crypto.randomUUID();
|
|
493
|
+
validatePlanId(input.plan_id, correlationId);
|
|
494
|
+
const targetSystems = input.erp_systems ?? ['sap', 'oracle'];
|
|
495
|
+
const primarySystem = targetSystems[0] ?? 'sap';
|
|
496
|
+
const now = new Date().toISOString();
|
|
497
|
+
const analysisId = generateErpId('surface');
|
|
498
|
+
// Generate ERP system summaries
|
|
499
|
+
const erpSystems = targetSystems.map(sysId => {
|
|
500
|
+
const sys = ERP_SYSTEMS[sysId];
|
|
501
|
+
if (!sys)
|
|
502
|
+
return null;
|
|
503
|
+
return {
|
|
504
|
+
system_id: sysId,
|
|
505
|
+
system_name: sys.name,
|
|
506
|
+
modules_affected: sys.modules.slice(0, 3).map(m => m.name),
|
|
507
|
+
entity_count: sys.modules.reduce((sum, m) => sum + m.entities.length, 0),
|
|
508
|
+
api_endpoints_required: sys.modules.reduce((sum, m) => sum + m.api_endpoints, 0),
|
|
509
|
+
integration_complexity: sys.modules.length > 5 ? 'high' : sys.modules.length > 3 ? 'medium' : 'low',
|
|
510
|
+
};
|
|
511
|
+
}).filter((s) => s !== null);
|
|
512
|
+
// Generate deployment touchpoints
|
|
513
|
+
const touchpoints = [
|
|
514
|
+
{
|
|
515
|
+
id: generateErpId('tp'),
|
|
516
|
+
name: 'Financial Data Sync',
|
|
517
|
+
type: 'api',
|
|
518
|
+
direction: 'bidirectional',
|
|
519
|
+
erp_system: primarySystem,
|
|
520
|
+
module: 'finance',
|
|
521
|
+
entities: ['GL Account', 'Journal Entry', 'Cost Center'],
|
|
522
|
+
frequency: 'hourly',
|
|
523
|
+
estimated_volume: '10K-50K records/day',
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
id: generateErpId('tp'),
|
|
527
|
+
name: 'Master Data Replication',
|
|
528
|
+
type: 'batch',
|
|
529
|
+
direction: 'outbound',
|
|
530
|
+
erp_system: primarySystem,
|
|
531
|
+
module: 'master-data',
|
|
532
|
+
entities: ['Customer', 'Vendor', 'Material'],
|
|
533
|
+
frequency: 'daily',
|
|
534
|
+
estimated_volume: '1K-5K records/day',
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
id: generateErpId('tp'),
|
|
538
|
+
name: 'Transaction Events',
|
|
539
|
+
type: 'event',
|
|
540
|
+
direction: 'inbound',
|
|
541
|
+
erp_system: primarySystem,
|
|
542
|
+
module: 'transactions',
|
|
543
|
+
entities: ['Sales Order', 'Purchase Order', 'Invoice'],
|
|
544
|
+
frequency: 'real-time',
|
|
545
|
+
estimated_volume: '100-500 events/hour',
|
|
546
|
+
},
|
|
547
|
+
];
|
|
548
|
+
// Generate risk assessment
|
|
549
|
+
const risks = [
|
|
550
|
+
{
|
|
551
|
+
id: generateErpId('risk'),
|
|
552
|
+
category: 'technical',
|
|
553
|
+
severity: 'medium',
|
|
554
|
+
description: 'API rate limits may impact real-time sync performance during peak hours.',
|
|
555
|
+
mitigation: 'Implement queue-based processing with exponential backoff.',
|
|
556
|
+
owner: 'Integration Team',
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
id: generateErpId('risk'),
|
|
560
|
+
category: 'business',
|
|
561
|
+
severity: 'high',
|
|
562
|
+
description: 'Data mapping discrepancies between source and target schemas.',
|
|
563
|
+
mitigation: 'Conduct thorough data profiling and establish transformation rules.',
|
|
564
|
+
owner: 'Data Architecture Team',
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
id: generateErpId('risk'),
|
|
568
|
+
category: 'compliance',
|
|
569
|
+
severity: 'low',
|
|
570
|
+
description: 'PII data handling requires encryption in transit and at rest.',
|
|
571
|
+
mitigation: 'Enable TLS 1.3 and field-level encryption for sensitive data.',
|
|
572
|
+
owner: 'Security Team',
|
|
573
|
+
},
|
|
574
|
+
];
|
|
575
|
+
const analysis = {
|
|
576
|
+
id: analysisId,
|
|
577
|
+
plan_id: input.plan_id,
|
|
578
|
+
analysis_type: 'surface',
|
|
579
|
+
generated_at: now,
|
|
580
|
+
erp_systems: erpSystems,
|
|
581
|
+
deployment_touchpoints: touchpoints,
|
|
582
|
+
risks,
|
|
583
|
+
assumptions: [
|
|
584
|
+
'Source systems have stable API contracts',
|
|
585
|
+
'Network connectivity between environments is established',
|
|
586
|
+
'Required credentials and access permissions are provisioned',
|
|
587
|
+
'Data volumes are within estimated ranges',
|
|
588
|
+
'No major ERP version upgrades during implementation',
|
|
589
|
+
],
|
|
590
|
+
recommendations: [
|
|
591
|
+
'Start with non-critical data flows for initial validation',
|
|
592
|
+
'Implement comprehensive logging and monitoring from day one',
|
|
593
|
+
'Establish data quality gates before production deployment',
|
|
594
|
+
'Create runbooks for common failure scenarios',
|
|
595
|
+
'Plan for incremental rollout with rollback capability',
|
|
596
|
+
],
|
|
597
|
+
estimated_effort: {
|
|
598
|
+
development_days: 45,
|
|
599
|
+
testing_days: 20,
|
|
600
|
+
deployment_days: 10,
|
|
601
|
+
total_days: 75,
|
|
602
|
+
team_size: 4,
|
|
603
|
+
confidence: 'medium',
|
|
604
|
+
},
|
|
605
|
+
repositories_involved: getInvolvedRepositories('erp-surface'),
|
|
606
|
+
generated_by: getArtifactAttribution('deployment-proposal'),
|
|
607
|
+
};
|
|
608
|
+
// Persist analysis
|
|
609
|
+
try {
|
|
610
|
+
ensureErpSubdir('surface');
|
|
611
|
+
const filePath = getErpArtifactPath('surface', analysisId);
|
|
612
|
+
fs.writeFileSync(filePath, JSON.stringify(analysis, null, 2), 'utf-8');
|
|
613
|
+
}
|
|
614
|
+
catch (error) {
|
|
615
|
+
throw new CLIError({
|
|
616
|
+
code: 'ECLI-ERP-003',
|
|
617
|
+
category: 'INTERNAL_ERROR',
|
|
618
|
+
message: `Failed to save surface analysis: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
619
|
+
details: { analysis_id: analysisId },
|
|
620
|
+
module: 'erp',
|
|
621
|
+
correlationId,
|
|
622
|
+
recoverable: false,
|
|
623
|
+
exitCode: ERP_EXIT_CODES.IO_ERROR,
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
return {
|
|
627
|
+
analysis,
|
|
628
|
+
repositories_involved: getInvolvedRepositories('erp-surface'),
|
|
629
|
+
timing: Date.now() - startTime,
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Generate ERP data mapping for a plan.
|
|
634
|
+
*/
|
|
635
|
+
export async function executeErpMapCommand(input, options) {
|
|
636
|
+
const startTime = Date.now();
|
|
637
|
+
const correlationId = options.trace_id ?? crypto.randomUUID();
|
|
638
|
+
validatePlanId(input.plan_id, correlationId);
|
|
639
|
+
const targetSystems = input.target_systems ?? ['sap', 'oracle'];
|
|
640
|
+
const primaryTargetSystem = targetSystems[0] ?? 'sap';
|
|
641
|
+
const now = new Date().toISOString();
|
|
642
|
+
const mappingId = generateErpId('map');
|
|
643
|
+
// Generate entity mappings
|
|
644
|
+
const entityMappings = [
|
|
645
|
+
{
|
|
646
|
+
source_entity: 'Customer',
|
|
647
|
+
target_entity: 'Business Partner',
|
|
648
|
+
target_system: primaryTargetSystem,
|
|
649
|
+
target_module: 'master-data',
|
|
650
|
+
cardinality: '1:1',
|
|
651
|
+
sync_direction: 'bidirectional',
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
source_entity: 'Product',
|
|
655
|
+
target_entity: 'Material',
|
|
656
|
+
target_system: primaryTargetSystem,
|
|
657
|
+
target_module: 'materials-management',
|
|
658
|
+
cardinality: '1:1',
|
|
659
|
+
sync_direction: 'push',
|
|
660
|
+
},
|
|
661
|
+
{
|
|
662
|
+
source_entity: 'SalesOrder',
|
|
663
|
+
target_entity: 'Sales Document',
|
|
664
|
+
target_system: primaryTargetSystem,
|
|
665
|
+
target_module: 'sales-distribution',
|
|
666
|
+
cardinality: '1:N',
|
|
667
|
+
sync_direction: 'push',
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
source_entity: 'Invoice',
|
|
671
|
+
target_entity: 'Billing Document',
|
|
672
|
+
target_system: primaryTargetSystem,
|
|
673
|
+
target_module: 'finance',
|
|
674
|
+
cardinality: '1:1',
|
|
675
|
+
sync_direction: 'bidirectional',
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
source_entity: 'PurchaseOrder',
|
|
679
|
+
target_entity: 'Purchase Order',
|
|
680
|
+
target_system: primaryTargetSystem,
|
|
681
|
+
target_module: 'materials-management',
|
|
682
|
+
cardinality: '1:1',
|
|
683
|
+
sync_direction: 'pull',
|
|
684
|
+
},
|
|
685
|
+
];
|
|
686
|
+
// Generate field mappings
|
|
687
|
+
const fieldMappings = [
|
|
688
|
+
{ source_field: 'customer_id', target_field: 'BP_NUMBER', transformation: 'passthrough', required: true },
|
|
689
|
+
{ source_field: 'customer_name', target_field: 'BP_NAME1', transformation: 'uppercase', required: true },
|
|
690
|
+
{ source_field: 'email', target_field: 'EMAIL_ADDRESS', transformation: 'lowercase', required: false },
|
|
691
|
+
{ source_field: 'phone', target_field: 'TELEPHONE', transformation: 'format_phone', required: false },
|
|
692
|
+
{ source_field: 'country_code', target_field: 'COUNTRY', transformation: 'iso_to_sap_country', required: true },
|
|
693
|
+
{ source_field: 'currency', target_field: 'CURRENCY_KEY', transformation: 'passthrough', required: true, default_value: 'USD' },
|
|
694
|
+
{ source_field: 'created_at', target_field: 'CREATED_ON', transformation: 'iso_to_sap_date', required: true },
|
|
695
|
+
{ source_field: 'amount', target_field: 'NET_VALUE', transformation: 'decimal_to_packed', required: true },
|
|
696
|
+
];
|
|
697
|
+
// Generate transformation rules
|
|
698
|
+
const transformationRules = [
|
|
699
|
+
{
|
|
700
|
+
id: generateErpId('tr'),
|
|
701
|
+
name: 'ISO to SAP Date',
|
|
702
|
+
type: 'format',
|
|
703
|
+
expression: 'YYYYMMDD',
|
|
704
|
+
description: 'Convert ISO 8601 date to SAP internal date format',
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
id: generateErpId('tr'),
|
|
708
|
+
name: 'Country Code Lookup',
|
|
709
|
+
type: 'lookup',
|
|
710
|
+
expression: 'country_mapping_table[source_code]',
|
|
711
|
+
description: 'Map ISO 3166-1 alpha-2 to SAP country keys',
|
|
712
|
+
},
|
|
713
|
+
{
|
|
714
|
+
id: generateErpId('tr'),
|
|
715
|
+
name: 'Phone Formatting',
|
|
716
|
+
type: 'format',
|
|
717
|
+
expression: '+{country_code}-{area_code}-{number}',
|
|
718
|
+
description: 'Format phone numbers to international standard',
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
id: generateErpId('tr'),
|
|
722
|
+
name: 'Currency Amount',
|
|
723
|
+
type: 'calculation',
|
|
724
|
+
expression: 'value * exchange_rate[target_currency]',
|
|
725
|
+
description: 'Convert amounts to target currency using daily rates',
|
|
726
|
+
},
|
|
727
|
+
];
|
|
728
|
+
// Generate validation rules
|
|
729
|
+
const validationRules = [
|
|
730
|
+
{
|
|
731
|
+
id: generateErpId('vr'),
|
|
732
|
+
name: 'Required Customer ID',
|
|
733
|
+
type: 'required',
|
|
734
|
+
expression: 'customer_id IS NOT NULL',
|
|
735
|
+
error_message: 'Customer ID is required for all records',
|
|
736
|
+
severity: 'error',
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
id: generateErpId('vr'),
|
|
740
|
+
name: 'Valid Country Code',
|
|
741
|
+
type: 'lookup',
|
|
742
|
+
expression: 'country_code IN valid_countries',
|
|
743
|
+
error_message: 'Invalid country code provided',
|
|
744
|
+
severity: 'error',
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
id: generateErpId('vr'),
|
|
748
|
+
name: 'Amount Range',
|
|
749
|
+
type: 'range',
|
|
750
|
+
expression: 'amount >= 0 AND amount <= 999999999.99',
|
|
751
|
+
error_message: 'Amount must be between 0 and 999,999,999.99',
|
|
752
|
+
severity: 'error',
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
id: generateErpId('vr'),
|
|
756
|
+
name: 'Email Format',
|
|
757
|
+
type: 'format',
|
|
758
|
+
expression: 'email MATCHES /^[\\w.-]+@[\\w.-]+\\.\\w+$/',
|
|
759
|
+
error_message: 'Invalid email format',
|
|
760
|
+
severity: 'warning',
|
|
761
|
+
},
|
|
762
|
+
];
|
|
763
|
+
const mapping = {
|
|
764
|
+
id: mappingId,
|
|
765
|
+
plan_id: input.plan_id,
|
|
766
|
+
mapping_type: 'data-flow',
|
|
767
|
+
generated_at: now,
|
|
768
|
+
source_system: 'agentics-platform',
|
|
769
|
+
target_systems: targetSystems,
|
|
770
|
+
entity_mappings: entityMappings,
|
|
771
|
+
field_mappings: fieldMappings,
|
|
772
|
+
transformation_rules: transformationRules,
|
|
773
|
+
validation_rules: validationRules,
|
|
774
|
+
repositories_involved: getInvolvedRepositories('erp-map'),
|
|
775
|
+
generated_by: getArtifactAttribution('data-mapping'),
|
|
776
|
+
};
|
|
777
|
+
// Persist mapping
|
|
778
|
+
try {
|
|
779
|
+
ensureErpSubdir('mappings');
|
|
780
|
+
const filePath = getErpArtifactPath('mappings', mappingId);
|
|
781
|
+
fs.writeFileSync(filePath, JSON.stringify(mapping, null, 2), 'utf-8');
|
|
782
|
+
}
|
|
783
|
+
catch (error) {
|
|
784
|
+
throw new CLIError({
|
|
785
|
+
code: 'ECLI-ERP-004',
|
|
786
|
+
category: 'INTERNAL_ERROR',
|
|
787
|
+
message: `Failed to save mapping: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
788
|
+
details: { mapping_id: mappingId },
|
|
789
|
+
module: 'erp',
|
|
790
|
+
correlationId,
|
|
791
|
+
recoverable: false,
|
|
792
|
+
exitCode: ERP_EXIT_CODES.IO_ERROR,
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
return {
|
|
796
|
+
mapping,
|
|
797
|
+
repositories_involved: getInvolvedRepositories('erp-map'),
|
|
798
|
+
timing: Date.now() - startTime,
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Export ERP deployment proposal for a plan.
|
|
803
|
+
*/
|
|
804
|
+
export async function executeErpExportCommand(input, options) {
|
|
805
|
+
const startTime = Date.now();
|
|
806
|
+
const correlationId = options.trace_id ?? crypto.randomUUID();
|
|
807
|
+
validatePlanId(input.plan_id, correlationId);
|
|
808
|
+
const now = new Date().toISOString();
|
|
809
|
+
const proposalId = generateErpId('proposal');
|
|
810
|
+
const targetSystems = ['sap', 'oracle'];
|
|
811
|
+
// Generate deployment phases
|
|
812
|
+
const phases = [
|
|
813
|
+
{
|
|
814
|
+
id: generateErpId('phase'),
|
|
815
|
+
name: 'Discovery & Planning',
|
|
816
|
+
order: 1,
|
|
817
|
+
duration_days: 10,
|
|
818
|
+
activities: [
|
|
819
|
+
'Conduct stakeholder interviews',
|
|
820
|
+
'Document current state architecture',
|
|
821
|
+
'Define integration requirements',
|
|
822
|
+
'Establish success criteria',
|
|
823
|
+
],
|
|
824
|
+
deliverables: ['Requirements document', 'Integration architecture diagram', 'Project plan'],
|
|
825
|
+
risks: ['Incomplete requirements', 'Stakeholder availability'],
|
|
826
|
+
dependencies: [],
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
id: generateErpId('phase'),
|
|
830
|
+
name: 'Design & Development',
|
|
831
|
+
order: 2,
|
|
832
|
+
duration_days: 30,
|
|
833
|
+
activities: [
|
|
834
|
+
'Design data mappings',
|
|
835
|
+
'Develop integration components',
|
|
836
|
+
'Create transformation logic',
|
|
837
|
+
'Build error handling',
|
|
838
|
+
],
|
|
839
|
+
deliverables: ['Technical design document', 'Integration code', 'Unit tests'],
|
|
840
|
+
risks: ['API compatibility issues', 'Data quality problems'],
|
|
841
|
+
dependencies: ['Phase 1 completion'],
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
id: generateErpId('phase'),
|
|
845
|
+
name: 'Testing & Validation',
|
|
846
|
+
order: 3,
|
|
847
|
+
duration_days: 20,
|
|
848
|
+
activities: [
|
|
849
|
+
'Execute integration tests',
|
|
850
|
+
'Perform data validation',
|
|
851
|
+
'Conduct performance testing',
|
|
852
|
+
'Complete UAT',
|
|
853
|
+
],
|
|
854
|
+
deliverables: ['Test results', 'Performance report', 'UAT sign-off'],
|
|
855
|
+
risks: ['Test environment availability', 'Data volume issues'],
|
|
856
|
+
dependencies: ['Phase 2 completion'],
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
id: generateErpId('phase'),
|
|
860
|
+
name: 'Deployment & Go-Live',
|
|
861
|
+
order: 4,
|
|
862
|
+
duration_days: 10,
|
|
863
|
+
activities: [
|
|
864
|
+
'Deploy to production',
|
|
865
|
+
'Execute cutover activities',
|
|
866
|
+
'Monitor initial transactions',
|
|
867
|
+
'Provide hypercare support',
|
|
868
|
+
],
|
|
869
|
+
deliverables: ['Deployment checklist', 'Runbook', 'Support documentation'],
|
|
870
|
+
risks: ['Production issues', 'User adoption'],
|
|
871
|
+
dependencies: ['Phase 3 completion', 'Business approval'],
|
|
872
|
+
},
|
|
873
|
+
];
|
|
874
|
+
// Generate proposal
|
|
875
|
+
const proposal = {
|
|
876
|
+
title: `ERP Integration Deployment - ${input.plan_id}`,
|
|
877
|
+
version: '1.0.0',
|
|
878
|
+
status: 'draft',
|
|
879
|
+
summary: `This proposal outlines the deployment plan for integrating the Agentics platform with enterprise ERP systems (${targetSystems.join(', ')}). The integration enables bidirectional data synchronization, real-time event processing, and comprehensive audit capabilities.`,
|
|
880
|
+
scope: {
|
|
881
|
+
erp_systems: targetSystems,
|
|
882
|
+
modules: ['finance', 'supply-chain', 'sales', 'master-data'],
|
|
883
|
+
entities: ['Customer', 'Vendor', 'Product', 'Sales Order', 'Purchase Order', 'Invoice'],
|
|
884
|
+
environments: ['development', 'staging', 'production'],
|
|
885
|
+
regions: ['us-central1', 'europe-west1'],
|
|
886
|
+
},
|
|
887
|
+
phases,
|
|
888
|
+
dependencies: [
|
|
889
|
+
{ name: 'ERP API Access', type: 'technical', status: 'pending', owner: 'IT Security' },
|
|
890
|
+
{ name: 'Data Governance Approval', type: 'business', status: 'pending', owner: 'Data Office' },
|
|
891
|
+
{ name: 'Integration Team Allocation', type: 'resource', status: 'ready', owner: 'PMO' },
|
|
892
|
+
{ name: 'Test Environment Setup', type: 'technical', status: 'pending', owner: 'Infrastructure' },
|
|
893
|
+
],
|
|
894
|
+
success_criteria: [
|
|
895
|
+
'99.9% API availability during business hours',
|
|
896
|
+
'Data synchronization latency < 5 minutes',
|
|
897
|
+
'Zero data loss in transaction processing',
|
|
898
|
+
'Full audit trail for compliance',
|
|
899
|
+
'Successful processing of 10K+ transactions/day',
|
|
900
|
+
],
|
|
901
|
+
rollback_plan: 'In case of critical issues, the integration can be disabled at the API gateway level. Historical data will be preserved in staging tables for reconciliation. A manual fallback process is documented for essential business operations.',
|
|
902
|
+
};
|
|
903
|
+
// Generate artifacts
|
|
904
|
+
const artifacts = [
|
|
905
|
+
{
|
|
906
|
+
filename: 'deployment-proposal.json',
|
|
907
|
+
type: 'json',
|
|
908
|
+
content: JSON.stringify(proposal, null, 2),
|
|
909
|
+
description: 'Complete deployment proposal in JSON format',
|
|
910
|
+
generated_by: getArtifactAttribution('deployment-proposal'),
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
filename: 'integration-config.yaml',
|
|
914
|
+
type: 'yaml',
|
|
915
|
+
content: generateIntegrationConfigYaml(input.plan_id, targetSystems),
|
|
916
|
+
description: 'Integration configuration for deployment',
|
|
917
|
+
generated_by: getArtifactAttribution('integration-config'),
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
filename: 'data-mapping-spec.json',
|
|
921
|
+
type: 'json',
|
|
922
|
+
content: JSON.stringify({
|
|
923
|
+
version: '1.0.0',
|
|
924
|
+
plan_id: input.plan_id,
|
|
925
|
+
mappings: {
|
|
926
|
+
entities: 6,
|
|
927
|
+
fields: 24,
|
|
928
|
+
transformations: 8,
|
|
929
|
+
validations: 12,
|
|
930
|
+
},
|
|
931
|
+
generated_at: now,
|
|
932
|
+
generated_by: getArtifactAttribution('data-mapping'),
|
|
933
|
+
}, null, 2),
|
|
934
|
+
description: 'Data mapping specification summary',
|
|
935
|
+
generated_by: getArtifactAttribution('data-mapping'),
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
filename: 'compliance-checklist.json',
|
|
939
|
+
type: 'json',
|
|
940
|
+
content: JSON.stringify({
|
|
941
|
+
version: '1.0.0',
|
|
942
|
+
frameworks: ['SOC2', 'GDPR', 'SOX'],
|
|
943
|
+
controls: [
|
|
944
|
+
{ id: 'AC-1', name: 'Access Control Policy', status: 'compliant' },
|
|
945
|
+
{ id: 'AU-1', name: 'Audit Policy', status: 'compliant' },
|
|
946
|
+
{ id: 'SC-1', name: 'System Communication Protection', status: 'compliant' },
|
|
947
|
+
{ id: 'IR-1', name: 'Incident Response', status: 'pending' },
|
|
948
|
+
],
|
|
949
|
+
generated_at: now,
|
|
950
|
+
generated_by: getArtifactAttribution('compliance-report'),
|
|
951
|
+
}, null, 2),
|
|
952
|
+
description: 'Compliance checklist for ERP integration',
|
|
953
|
+
generated_by: getArtifactAttribution('compliance-report'),
|
|
954
|
+
},
|
|
955
|
+
];
|
|
956
|
+
const erpExport = {
|
|
957
|
+
id: proposalId,
|
|
958
|
+
plan_id: input.plan_id,
|
|
959
|
+
export_type: 'deployment-proposal',
|
|
960
|
+
generated_at: now,
|
|
961
|
+
proposal,
|
|
962
|
+
artifacts,
|
|
963
|
+
repositories_involved: getInvolvedRepositories('erp-export'),
|
|
964
|
+
generated_by: getArtifactAttribution('deployment-proposal'),
|
|
965
|
+
};
|
|
966
|
+
// Persist proposal and artifacts
|
|
967
|
+
let artifactsWritten = false;
|
|
968
|
+
let outputPath = '';
|
|
969
|
+
try {
|
|
970
|
+
ensureErpSubdir('proposals');
|
|
971
|
+
ensureErpSubdir(`proposals/${proposalId}`);
|
|
972
|
+
// Save main proposal
|
|
973
|
+
const proposalPath = getErpArtifactPath('proposals', proposalId);
|
|
974
|
+
fs.writeFileSync(proposalPath, JSON.stringify(erpExport, null, 2), 'utf-8');
|
|
975
|
+
// Save individual artifacts
|
|
976
|
+
const artifactsDir = path.join(getErpDir(), 'proposals', proposalId);
|
|
977
|
+
for (const artifact of artifacts) {
|
|
978
|
+
const artifactPath = path.join(artifactsDir, artifact.filename);
|
|
979
|
+
fs.writeFileSync(artifactPath, artifact.content, 'utf-8');
|
|
980
|
+
}
|
|
981
|
+
artifactsWritten = true;
|
|
982
|
+
outputPath = artifactsDir;
|
|
983
|
+
}
|
|
984
|
+
catch (error) {
|
|
985
|
+
throw new CLIError({
|
|
986
|
+
code: 'ECLI-ERP-005',
|
|
987
|
+
category: 'INTERNAL_ERROR',
|
|
988
|
+
message: `Failed to save export proposal: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
989
|
+
details: { proposal_id: proposalId },
|
|
990
|
+
module: 'erp',
|
|
991
|
+
correlationId,
|
|
992
|
+
recoverable: false,
|
|
993
|
+
exitCode: ERP_EXIT_CODES.IO_ERROR,
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
return {
|
|
997
|
+
proposal: erpExport,
|
|
998
|
+
artifacts_written: artifactsWritten,
|
|
999
|
+
output_path: outputPath,
|
|
1000
|
+
repositories_involved: getInvolvedRepositories('erp-export'),
|
|
1001
|
+
timing: Date.now() - startTime,
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
// ============================================================================
|
|
1005
|
+
// Helper Functions
|
|
1006
|
+
// ============================================================================
|
|
1007
|
+
function generateIntegrationConfigYaml(planId, systems) {
|
|
1008
|
+
const attribution = getArtifactAttribution('integration-config');
|
|
1009
|
+
return `# ERP Integration Configuration
|
|
1010
|
+
# Generated by Agentics CLI
|
|
1011
|
+
# Plan ID: ${planId}
|
|
1012
|
+
# Generated at: ${new Date().toISOString()}
|
|
1013
|
+
|
|
1014
|
+
version: "1.0.0"
|
|
1015
|
+
|
|
1016
|
+
generated_by:
|
|
1017
|
+
${attribution.map(r => ` - ${r}`).join('\n')}
|
|
1018
|
+
|
|
1019
|
+
integration:
|
|
1020
|
+
plan_id: "${planId}"
|
|
1021
|
+
type: "erp-connector"
|
|
1022
|
+
mode: "bidirectional"
|
|
1023
|
+
|
|
1024
|
+
target_systems:
|
|
1025
|
+
${systems.map(s => ` - system_id: "${s}"
|
|
1026
|
+
enabled: true
|
|
1027
|
+
priority: 1`).join('\n')}
|
|
1028
|
+
|
|
1029
|
+
connection:
|
|
1030
|
+
protocol: "https"
|
|
1031
|
+
authentication: "oauth2"
|
|
1032
|
+
timeout_ms: 30000
|
|
1033
|
+
retry_policy:
|
|
1034
|
+
max_retries: 3
|
|
1035
|
+
backoff_multiplier: 2
|
|
1036
|
+
initial_delay_ms: 1000
|
|
1037
|
+
|
|
1038
|
+
sync:
|
|
1039
|
+
mode: "incremental"
|
|
1040
|
+
batch_size: 1000
|
|
1041
|
+
parallelism: 4
|
|
1042
|
+
|
|
1043
|
+
monitoring:
|
|
1044
|
+
enabled: true
|
|
1045
|
+
metrics_endpoint: "/v1/metrics"
|
|
1046
|
+
health_endpoint: "/v1/health"
|
|
1047
|
+
alert_channels:
|
|
1048
|
+
- "slack"
|
|
1049
|
+
- "pagerduty"
|
|
1050
|
+
|
|
1051
|
+
compliance:
|
|
1052
|
+
audit_logging: true
|
|
1053
|
+
encryption_at_rest: true
|
|
1054
|
+
encryption_in_transit: true
|
|
1055
|
+
data_retention_days: 90
|
|
1056
|
+
|
|
1057
|
+
# Repository attribution for orchestration proof
|
|
1058
|
+
orchestration:
|
|
1059
|
+
platform: "agentics"
|
|
1060
|
+
repositories_involved:
|
|
1061
|
+
${getInvolvedRepositories('erp-export').map(r => ` - ${r}`).join('\n')}
|
|
1062
|
+
`;
|
|
1063
|
+
}
|
|
1064
|
+
//# sourceMappingURL=erp.js.map
|