snow-flow 3.0.9 → 3.0.13
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/claude-flow.bat +0 -0
- package/claude-flow.ps1 +0 -0
- package/dist/mcp/intelligent-reporting-mcp.d.ts +7 -0
- package/dist/mcp/intelligent-reporting-mcp.js +379 -0
- package/dist/mcp/servicenow-automation-mcp.js +0 -0
- package/dist/mcp/servicenow-deployment-mcp.js +0 -0
- package/dist/mcp/servicenow-integration-mcp.js +0 -0
- package/dist/mcp/servicenow-mcp-server.js +0 -0
- package/dist/mcp/servicenow-operations-mcp.js +0 -0
- package/dist/mcp/servicenow-platform-development-mcp.js +0 -0
- package/dist/mcp/servicenow-progressive-indexer.js +0 -0
- package/dist/mcp/servicenow-reporting-analytics-mcp.js +280 -29
- package/dist/mcp/servicenow-security-compliance-mcp.js +0 -0
- package/dist/mcp/servicenow-update-set-mcp.js +0 -0
- package/dist/mcp/start-all-mcp-servers.js +0 -0
- package/dist/mcp/start-servicenow-mcp.js +0 -0
- package/dist/services/widget-deployment-service.d.ts +2 -1
- package/dist/services/widget-deployment-service.js +17 -16
- package/dist/utils/anti-mock-data-validator.d.ts +66 -0
- package/dist/utils/anti-mock-data-validator.js +316 -0
- package/dist/utils/servicenow-eventual-consistency.d.ts +120 -0
- package/dist/utils/servicenow-eventual-consistency.js +220 -0
- package/memory/agents/README.md +1 -1
- package/memory/claude-flow-data.json +1 -1
- package/memory/sessions/README.md +1 -1
- package/package.json +4 -3
- package/.mcp.json +0 -22
- package/claude-flow.config.json +0 -20
- package/dist/agents/app-creator.agent.d.ts +0 -55
- package/dist/agents/app-creator.agent.js +0 -1292
- package/dist/agents/base/base-snow-agent.d.ts +0 -75
- package/dist/agents/base/base-snow-agent.js +0 -169
- package/dist/agents/base-snow-agent.d.ts +0 -63
- package/dist/agents/base-snow-agent.js +0 -296
- package/dist/agents/coordinator.d.ts +0 -200
- package/dist/agents/coordinator.js +0 -777
- package/dist/agents/flow-builder-agent.d.ts +0 -18
- package/dist/agents/flow-builder-agent.js +0 -197
- package/dist/agents/queen-403-handler.d.ts +0 -47
- package/dist/agents/queen-403-handler.js +0 -175
- package/dist/agents/queen-agent-example.d.ts +0 -23
- package/dist/agents/queen-agent-example.js +0 -240
- package/dist/agents/queen-agent.test.d.ts +0 -6
- package/dist/agents/script-generator.agent.d.ts +0 -32
- package/dist/agents/script-generator.agent.js +0 -772
- package/dist/agents/script-writer-agent.d.ts +0 -22
- package/dist/agents/script-writer-agent.js +0 -695
- package/dist/agents/security-agent.d.ts +0 -23
- package/dist/agents/security-agent.js +0 -619
- package/dist/agents/specialists/automation-specialist.agent.d.ts +0 -44
- package/dist/agents/specialists/automation-specialist.agent.js +0 -204
- package/dist/agents/specialists/data-specialist.agent.d.ts +0 -165
- package/dist/agents/specialists/data-specialist.agent.js +0 -484
- package/dist/agents/specialists/integration-specialist.agent.d.ts +0 -227
- package/dist/agents/specialists/integration-specialist.agent.js +0 -725
- package/dist/agents/specialists/reporting-specialist.agent.d.ts +0 -54
- package/dist/agents/specialists/reporting-specialist.agent.js +0 -193
- package/dist/agents/specialists/security-specialist.agent.d.ts +0 -85
- package/dist/agents/specialists/security-specialist.agent.js +0 -309
- package/dist/agents/teams/adaptive/adaptive-coordinator.agent.d.ts +0 -111
- package/dist/agents/teams/adaptive/adaptive-coordinator.agent.js +0 -383
- package/dist/agents/teams/base-team.d.ts +0 -72
- package/dist/agents/teams/base-team.js +0 -253
- package/dist/agents/teams/team-types.d.ts +0 -265
- package/dist/agents/teams/team-types.js +0 -3
- package/dist/agents/teams/widget/widget-architect.agent.d.ts +0 -61
- package/dist/agents/teams/widget/widget-architect.agent.js +0 -436
- package/dist/agents/teams/widget/widget-backend.agent.d.ts +0 -74
- package/dist/agents/teams/widget/widget-backend.agent.js +0 -1531
- package/dist/agents/teams/widget/widget-frontend.agent.d.ts +0 -67
- package/dist/agents/teams/widget/widget-frontend.agent.js +0 -1014
- package/dist/agents/teams/widget/widget-platform.agent.d.ts +0 -90
- package/dist/agents/teams/widget/widget-platform.agent.js +0 -1190
- package/dist/agents/teams/widget/widget-uiux.agent.d.ts +0 -107
- package/dist/agents/teams/widget/widget-uiux.agent.js +0 -1033
- package/dist/agents/test-agent.d.ts +0 -26
- package/dist/agents/test-agent.js +0 -734
- package/dist/agents/test-agents.d.ts +0 -7
- package/dist/agents/test-agents.js +0 -64
- package/dist/agents/ui-builder.agent.d.ts +0 -50
- package/dist/agents/ui-builder.agent.js +0 -1539
- package/dist/agents/widget-builder.agent.d.ts +0 -32
- package/dist/agents/widget-builder.agent.js +0 -439
- package/dist/agents/widget-creator-agent.d.ts +0 -18
- package/dist/agents/widget-creator-agent.js +0 -498
- package/dist/agents/workflow-designer.agent.d.ts +0 -31
- package/dist/agents/workflow-designer.agent.js +0 -583
- package/dist/api/error-handling.d.ts +0 -325
- package/dist/api/error-handling.js +0 -1488
- package/dist/api/flow-designer-api.d.ts +0 -167
- package/dist/api/flow-designer-api.js +0 -554
- package/dist/api/natural-language-mapper.d.ts +0 -124
- package/dist/api/natural-language-mapper.js +0 -501
- package/dist/api/performance-optimizer.d.ts +0 -240
- package/dist/api/performance-optimizer.js +0 -706
- package/dist/api/transaction-manager.d.ts +0 -189
- package/dist/api/transaction-manager.js +0 -576
- package/dist/assembly/team-assembler.d.ts +0 -140
- package/dist/assembly/team-assembler.js +0 -502
- package/dist/benchmark-performance.d.ts +0 -41
- package/dist/benchmark-performance.js +0 -230
- package/dist/cli/snow-flow-cli-integration.d.ts +0 -30
- package/dist/cli/snow-flow-cli-integration.js +0 -396
- package/dist/coordination/coordination-engine.d.ts +0 -41
- package/dist/coordination/coordination-engine.js +0 -324
- package/dist/coordination/coordination.test.d.ts +0 -6
- package/dist/coordination/example.d.ts +0 -31
- package/dist/coordination/example.js +0 -394
- package/dist/coordination/execution-patterns.d.ts +0 -43
- package/dist/coordination/execution-patterns.js +0 -507
- package/dist/coordination/factory.d.ts +0 -94
- package/dist/coordination/factory.js +0 -433
- package/dist/coordination/index.d.ts +0 -71
- package/dist/coordination/index.js +0 -135
- package/dist/coordination/progress-monitor.d.ts +0 -71
- package/dist/coordination/progress-monitor.js +0 -505
- package/dist/coordination/quality-gates.d.ts +0 -124
- package/dist/coordination/quality-gates.js +0 -577
- package/dist/coordination/shared-memory.d.ts +0 -39
- package/dist/coordination/shared-memory.js +0 -289
- package/dist/coordination/task-dependencies.d.ts +0 -50
- package/dist/coordination/task-dependencies.js +0 -407
- package/dist/coordination/team-coordinator.d.ts +0 -59
- package/dist/coordination/team-coordinator.js +0 -550
- package/dist/coordination/types.d.ts +0 -152
- package/dist/coordination/types.js +0 -3
- package/dist/mcp/mcp-wrapper.d.ts +0 -8
- package/dist/mcp/mcp-wrapper.js +0 -77
- package/dist/mcp/servicenow-flow-composer-enhanced.js +0 -396
- package/dist/mcp/servicenow-flow-composer-mcp.d.ts +0 -7
- package/dist/mcp/servicenow-flow-composer-mcp.js +0 -3103
- package/dist/mcp/servicenow-graph-memory-mcp.d.ts +0 -7
- package/dist/mcp/servicenow-intelligent-mcp.d.ts +0 -143
- package/dist/mcp/servicenow-intelligent-mcp.js +0 -4156
- package/dist/mcp/servicenow-xml-flow-mcp.d.ts +0 -53
- package/dist/mcp/servicenow-xml-flow-mcp.js +0 -1704
- package/dist/mcp/singleton-check.js +0 -31
- package/dist/mcp/test-simple-mcp.d.ts +0 -6
- package/dist/mcp/test-simple-mcp.js +0 -63
- package/dist/memory/hierarchical-memory-system.d.ts +0 -90
- package/dist/memory/hierarchical-memory-system.js +0 -400
- package/dist/memory/index.d.ts +0 -9
- package/dist/memory/index.js +0 -20
- package/dist/memory/mcp-integration-example.d.ts +0 -6
- package/dist/memory/mcp-integration-example.js +0 -281
- package/dist/memory/memory-client.d.ts +0 -199
- package/dist/memory/memory-client.js +0 -364
- package/dist/memory/memory-manager.d.ts +0 -29
- package/dist/memory/memory-manager.js +0 -280
- package/dist/memory/memory-operations.d.ts +0 -179
- package/dist/memory/memory-operations.js +0 -691
- package/dist/memory/memory-system.d.ts +0 -153
- package/dist/memory/memory-system.js +0 -651
- package/dist/memory/memory-test.d.ts +0 -6
- package/dist/memory/memory-test.js +0 -161
- package/dist/memory/snow-flow-memory-patterns.d.ts +0 -213
- package/dist/memory/snow-flow-memory-patterns.js +0 -200
- package/dist/memory/snow-memory.d.ts +0 -54
- package/dist/memory/snow-memory.js +0 -301
- package/dist/memory/swarm-memory.d.ts +0 -135
- package/dist/memory/swarm-memory.js +0 -378
- package/dist/optimization/flow-performance-optimizer.js +0 -723
- package/dist/orchestration/discovery/service-discovery.d.ts +0 -81
- package/dist/orchestration/discovery/service-discovery.js +0 -808
- package/dist/orchestration/distributed-orchestrator.d.ts +0 -131
- package/dist/orchestration/distributed-orchestrator.js +0 -712
- package/dist/orchestration/distribution/task-distribution-engine.d.ts +0 -53
- package/dist/orchestration/distribution/task-distribution-engine.js +0 -586
- package/dist/orchestration/flow-update-orchestrator.js +0 -648
- package/dist/orchestration/interfaces/distributed-orchestration.interface.d.ts +0 -606
- package/dist/orchestration/interfaces/distributed-orchestration.interface.js +0 -65
- package/dist/orchestration/protocols/mcpx-protocol.d.ts +0 -71
- package/dist/orchestration/protocols/mcpx-protocol.js +0 -668
- package/dist/orchestration/state/distributed-state-manager.d.ts +0 -89
- package/dist/orchestration/state/distributed-state-manager.js +0 -716
- package/dist/orchestrator/flow-composer.d.ts +0 -105
- package/dist/orchestrator/flow-composer.js +0 -404
- package/dist/orchestrator/flow-pattern-templates.d.ts +0 -260
- package/dist/orchestrator/flow-pattern-templates.js +0 -908
- package/dist/orchestrator/flow-subflow-decision-engine.d.ts +0 -202
- package/dist/orchestrator/flow-subflow-decision-engine.js +0 -769
- package/dist/orchestrator/flow-validation-engine.d.ts +0 -169
- package/dist/orchestrator/flow-validation-engine.js +0 -913
- package/dist/orchestrator/snow-orchestrator.d.ts +0 -49
- package/dist/orchestrator/snow-orchestrator.js +0 -235
- package/dist/orchestrator/subflow-creation-handler.d.ts +0 -230
- package/dist/orchestrator/subflow-creation-handler.js +0 -791
- package/dist/patterns/adaptive-patterns.d.ts +0 -140
- package/dist/patterns/adaptive-patterns.js +0 -549
- package/dist/queen/advanced-integration-test.d.ts +0 -48
- package/dist/queen/advanced-integration-test.js +0 -473
- package/dist/queen/integration-example.d.ts +0 -82
- package/dist/queen/integration-example.js +0 -219
- package/dist/queen/integration-test.d.ts +0 -72
- package/dist/queen/integration-test.js +0 -563
- package/dist/queen/mock-mcp-client.d.ts +0 -71
- package/dist/queen/mock-mcp-client.js +0 -317
- package/dist/queen/run-integration-tests.d.ts +0 -9
- package/dist/queen/run-integration-tests.js +0 -27
- package/dist/sparc/coordinators/adaptive-coordinator.d.ts +0 -54
- package/dist/sparc/coordinators/adaptive-coordinator.js +0 -367
- package/dist/sparc/coordinators/team-coordinator.d.ts +0 -66
- package/dist/sparc/coordinators/team-coordinator.js +0 -402
- package/dist/sparc/modes/team-modes.d.ts +0 -33
- package/dist/sparc/modes/team-modes.js +0 -399
- package/dist/sparc/teams/application-team.d.ts +0 -73
- package/dist/sparc/teams/application-team.js +0 -463
- package/dist/sparc/teams/flow-team.d.ts +0 -67
- package/dist/sparc/teams/flow-team.js +0 -373
- package/dist/sparc/teams/widget-team.d.ts +0 -61
- package/dist/sparc/teams/widget-team.js +0 -280
- package/dist/specialists/app-specialists.d.ts +0 -93
- package/dist/specialists/app-specialists.js +0 -1639
- package/dist/specialists/base-specialist.d.ts +0 -19
- package/dist/specialists/base-specialist.js +0 -54
- package/dist/specialists/flow-specialists.d.ts +0 -113
- package/dist/specialists/flow-specialists.js +0 -1787
- package/dist/specialists/individual-specialists.d.ts +0 -67
- package/dist/specialists/individual-specialists.js +0 -632
- package/dist/specialists/widget-specialists.d.ts +0 -70
- package/dist/specialists/widget-specialists.js +0 -1264
- package/dist/src/utils/agent-detector.js +0 -655
- package/dist/teams/adaptive-team.d.ts +0 -81
- package/dist/teams/adaptive-team.js +0 -1153
- package/dist/teams/application-team.d.ts +0 -30
- package/dist/teams/application-team.js +0 -547
- package/dist/teams/base-team.d.ts +0 -55
- package/dist/teams/base-team.js +0 -243
- package/dist/teams/flow-team.d.ts +0 -28
- package/dist/teams/flow-team.js +0 -525
- package/dist/teams/widget-team.d.ts +0 -26
- package/dist/teams/widget-team.js +0 -459
- package/dist/templates/flow-template-system.js +0 -625
- package/dist/test-fetch-incidents.d.ts +0 -2
- package/dist/test-fetch-incidents.js +0 -84
- package/dist/test-incident-access.d.ts +0 -2
- package/dist/test-incident-access.js +0 -72
- package/dist/test-iphone-flow.js +0 -189
- package/dist/test-limit-problem.d.ts +0 -2
- package/dist/test-limit-problem.js +0 -60
- package/dist/test-ml-batch-fix.d.ts +0 -2
- package/dist/test-ml-batch-fix.js +0 -104
- package/dist/test-ml-batch.d.ts +0 -2
- package/dist/test-ml-batch.js +0 -87
- package/dist/test-ml-query.d.ts +0 -2
- package/dist/test-ml-query.js +0 -100
- package/dist/test-ml-training-fix.d.ts +0 -12
- package/dist/test-ml-training-fix.js +0 -113
- package/dist/test-ml-training.d.ts +0 -2
- package/dist/test-ml-training.js +0 -32
- package/dist/test-operations-query.d.ts +0 -2
- package/dist/test-operations-query.js +0 -84
- package/dist/test-performance-query.d.ts +0 -2
- package/dist/test-performance-query.js +0 -52
- package/dist/test-singleton-protection.d.ts +0 -8
- package/dist/test-singleton-protection.js +0 -110
- package/dist/test-smart-limits.d.ts +0 -13
- package/dist/test-smart-limits.js +0 -100
- package/dist/test-snow-query-incidents.d.ts +0 -2
- package/dist/test-snow-query-incidents.js +0 -66
- package/dist/test-universal-query.d.ts +0 -2
- package/dist/test-universal-query.js +0 -106
- package/dist/testing/flow-testing-automation.js +0 -641
- package/dist/utils/complete-flow-xml-generator.js +0 -1285
- package/dist/utils/file-storage-fallback.d.ts +0 -62
- package/dist/utils/file-storage-fallback.js +0 -289
- package/dist/utils/flow-api-discovery.d.ts +0 -151
- package/dist/utils/flow-api-discovery.js +0 -439
- package/dist/utils/flow-examples.js +0 -720
- package/dist/utils/flow-structure-builder.js +0 -677
- package/dist/utils/flow-xml-generator.d.ts +0 -41
- package/dist/utils/flow-xml-generator.js +0 -258
- package/dist/utils/improved-flow-xml-generator.js +0 -820
- package/dist/utils/mcp-process-manager.backup.d.ts +0 -58
- package/dist/utils/mcp-process-manager.backup.js +0 -220
- package/dist/utils/mcp-singleton-enforcer.d.ts +0 -36
- package/dist/utils/mcp-singleton-enforcer.js +0 -201
- package/dist/utils/mcp-timeout-fix.d.ts +0 -53
- package/dist/utils/mcp-timeout-fix.js +0 -221
- package/dist/utils/migrate-claude-flow.d.ts +0 -22
- package/dist/utils/migrate-claude-flow.js +0 -120
- package/dist/utils/scope-utils.d.ts +0 -72
- package/dist/utils/scope-utils.js +0 -386
- package/dist/utils/snow-oauth-old.d.ts +0 -65
- package/dist/utils/snow-oauth-old.js +0 -345
- package/dist/utils/xml-first-flow-generator.js +0 -513
- package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +0 -30
- package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +0 -36
- package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +0 -30
- package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +0 -30
- package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +0 -55
- package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +0 -55
- package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +0 -9
- package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +0 -9
- package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +0 -8
- package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +0 -9
- package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +0 -9
- package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +0 -9
- package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +0 -58
- package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +0 -9
- package/reports/swarm-auto-centralized-1752649029776.json +0 -13
- package/src/memory/README.md +0 -240
|
@@ -1,769 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ServiceNow Flow vs Subflow Decision Engine
|
|
4
|
-
*
|
|
5
|
-
* This module implements intelligent decision logic to determine when to create
|
|
6
|
-
* flows versus subflows in ServiceNow. It analyzes natural language requirements
|
|
7
|
-
* and provides recommendations based on complexity, reusability, and best practices.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.FlowSubflowDecisionEngine = exports.FlowContext = exports.ReusabilityLevel = exports.ComplexityLevel = exports.FlowType = void 0;
|
|
11
|
-
const logger_js_1 = require("../utils/logger.js");
|
|
12
|
-
const servicenow_client_js_1 = require("../utils/servicenow-client.js");
|
|
13
|
-
/**
|
|
14
|
-
* Enumeration of flow types
|
|
15
|
-
*/
|
|
16
|
-
var FlowType;
|
|
17
|
-
(function (FlowType) {
|
|
18
|
-
FlowType["MAIN_FLOW"] = "main_flow";
|
|
19
|
-
FlowType["SUBFLOW"] = "subflow";
|
|
20
|
-
})(FlowType || (exports.FlowType = FlowType = {}));
|
|
21
|
-
/**
|
|
22
|
-
* Complexity levels for flow analysis
|
|
23
|
-
*/
|
|
24
|
-
var ComplexityLevel;
|
|
25
|
-
(function (ComplexityLevel) {
|
|
26
|
-
ComplexityLevel["LOW"] = "low";
|
|
27
|
-
ComplexityLevel["MEDIUM"] = "medium";
|
|
28
|
-
ComplexityLevel["HIGH"] = "high";
|
|
29
|
-
ComplexityLevel["VERY_HIGH"] = "very_high";
|
|
30
|
-
})(ComplexityLevel || (exports.ComplexityLevel = ComplexityLevel = {}));
|
|
31
|
-
/**
|
|
32
|
-
* Reusability assessment
|
|
33
|
-
*/
|
|
34
|
-
var ReusabilityLevel;
|
|
35
|
-
(function (ReusabilityLevel) {
|
|
36
|
-
ReusabilityLevel["NONE"] = "none";
|
|
37
|
-
ReusabilityLevel["LOW"] = "low";
|
|
38
|
-
ReusabilityLevel["MEDIUM"] = "medium";
|
|
39
|
-
ReusabilityLevel["HIGH"] = "high";
|
|
40
|
-
})(ReusabilityLevel || (exports.ReusabilityLevel = ReusabilityLevel = {}));
|
|
41
|
-
/**
|
|
42
|
-
* Flow context types
|
|
43
|
-
*/
|
|
44
|
-
var FlowContext;
|
|
45
|
-
(function (FlowContext) {
|
|
46
|
-
FlowContext["APPROVAL_WORKFLOW"] = "approval_workflow";
|
|
47
|
-
FlowContext["FULFILLMENT_WORKFLOW"] = "fulfillment_workflow";
|
|
48
|
-
FlowContext["NOTIFICATION_WORKFLOW"] = "notification_workflow";
|
|
49
|
-
FlowContext["INTEGRATION_WORKFLOW"] = "integration_workflow";
|
|
50
|
-
FlowContext["UTILITY_WORKFLOW"] = "utility_workflow";
|
|
51
|
-
FlowContext["BUSINESS_LOGIC"] = "business_logic";
|
|
52
|
-
})(FlowContext || (exports.FlowContext = FlowContext = {}));
|
|
53
|
-
/**
|
|
54
|
-
* Flow vs Subflow Decision Engine
|
|
55
|
-
*/
|
|
56
|
-
class FlowSubflowDecisionEngine {
|
|
57
|
-
constructor() {
|
|
58
|
-
this.patterns = [];
|
|
59
|
-
this.logger = new logger_js_1.Logger('FlowSubflowDecisionEngine');
|
|
60
|
-
this.client = new servicenow_client_js_1.ServiceNowClient();
|
|
61
|
-
this.initializePatterns();
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Main decision method - analyzes requirements and recommends flow type
|
|
65
|
-
*/
|
|
66
|
-
async analyzeAndRecommend(instruction) {
|
|
67
|
-
this.logger.info('Analyzing instruction for flow vs subflow decision', { instruction });
|
|
68
|
-
// Parse the instruction to extract requirements
|
|
69
|
-
const parsedRequirements = this.parseRequirements(instruction);
|
|
70
|
-
// Analyze complexity
|
|
71
|
-
const complexity = this.analyzeComplexity(parsedRequirements);
|
|
72
|
-
// Analyze reusability
|
|
73
|
-
const reusability = this.analyzeReusability(parsedRequirements);
|
|
74
|
-
// Determine context
|
|
75
|
-
const context = this.determineContext(parsedRequirements);
|
|
76
|
-
// Build decision criteria
|
|
77
|
-
const criteria = this.buildDecisionCriteria(parsedRequirements, complexity, reusability, context);
|
|
78
|
-
// Make the decision
|
|
79
|
-
const decision = this.makeDecision(criteria);
|
|
80
|
-
// Identify subflow candidates
|
|
81
|
-
const subflowCandidates = this.identifySubflowCandidates(parsedRequirements);
|
|
82
|
-
// Match patterns
|
|
83
|
-
const patterns = this.matchPatterns(parsedRequirements, context);
|
|
84
|
-
// Generate alternatives
|
|
85
|
-
const alternatives = this.generateAlternatives(criteria);
|
|
86
|
-
const result = {
|
|
87
|
-
recommendedType: decision.type,
|
|
88
|
-
confidence: decision.confidence,
|
|
89
|
-
rationale: [decision.rationale],
|
|
90
|
-
criteria,
|
|
91
|
-
alternatives,
|
|
92
|
-
patterns,
|
|
93
|
-
subflowCandidates
|
|
94
|
-
};
|
|
95
|
-
this.logger.info('Flow analysis complete', {
|
|
96
|
-
recommendedType: result.recommendedType,
|
|
97
|
-
confidence: result.confidence,
|
|
98
|
-
subflowCandidates: result.subflowCandidates.length
|
|
99
|
-
});
|
|
100
|
-
return result;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Parse natural language requirements into structured data
|
|
104
|
-
*/
|
|
105
|
-
parseRequirements(instruction) {
|
|
106
|
-
const lowerInstruction = instruction.toLowerCase();
|
|
107
|
-
return {
|
|
108
|
-
originalInstruction: instruction,
|
|
109
|
-
// Action analysis
|
|
110
|
-
actions: this.extractActions(lowerInstruction),
|
|
111
|
-
// Logical flow analysis
|
|
112
|
-
hasConditionalLogic: this.hasConditionalLogic(lowerInstruction),
|
|
113
|
-
hasLoops: this.hasLoops(lowerInstruction),
|
|
114
|
-
hasParallelActions: this.hasParallelActions(lowerInstruction),
|
|
115
|
-
// Integration analysis
|
|
116
|
-
hasExternalIntegrations: this.hasExternalIntegrations(lowerInstruction),
|
|
117
|
-
hasDataTransformation: this.hasDataTransformation(lowerInstruction),
|
|
118
|
-
// Business logic analysis
|
|
119
|
-
hasBusinessRules: this.hasBusinessRules(lowerInstruction),
|
|
120
|
-
hasApprovalLogic: this.hasApprovalLogic(lowerInstruction),
|
|
121
|
-
// Reusability indicators
|
|
122
|
-
hasReusableComponents: this.hasReusableComponents(lowerInstruction),
|
|
123
|
-
isUtilityFunction: this.isUtilityFunction(lowerInstruction),
|
|
124
|
-
// Error handling
|
|
125
|
-
hasErrorHandling: this.hasErrorHandling(lowerInstruction),
|
|
126
|
-
// Input/Output analysis
|
|
127
|
-
inputParameters: this.extractInputParameters(lowerInstruction),
|
|
128
|
-
outputParameters: this.extractOutputParameters(lowerInstruction),
|
|
129
|
-
// Context indicators
|
|
130
|
-
contextIndicators: this.extractContextIndicators(lowerInstruction)
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Analyze complexity based on parsed requirements
|
|
135
|
-
*/
|
|
136
|
-
analyzeComplexity(requirements) {
|
|
137
|
-
let complexityScore = 0;
|
|
138
|
-
// Base complexity from action count
|
|
139
|
-
complexityScore += Math.min(requirements.actions.length * 0.5, 5);
|
|
140
|
-
// Logical complexity
|
|
141
|
-
if (requirements.hasConditionalLogic)
|
|
142
|
-
complexityScore += 2;
|
|
143
|
-
if (requirements.hasLoops)
|
|
144
|
-
complexityScore += 3;
|
|
145
|
-
if (requirements.hasParallelActions)
|
|
146
|
-
complexityScore += 2;
|
|
147
|
-
// Integration complexity
|
|
148
|
-
if (requirements.hasExternalIntegrations)
|
|
149
|
-
complexityScore += 3;
|
|
150
|
-
if (requirements.hasDataTransformation)
|
|
151
|
-
complexityScore += 2;
|
|
152
|
-
// Business logic complexity
|
|
153
|
-
if (requirements.hasBusinessRules)
|
|
154
|
-
complexityScore += 2;
|
|
155
|
-
if (requirements.hasApprovalLogic)
|
|
156
|
-
complexityScore += 3;
|
|
157
|
-
// Error handling complexity
|
|
158
|
-
if (requirements.hasErrorHandling)
|
|
159
|
-
complexityScore += 1;
|
|
160
|
-
// Parameter complexity
|
|
161
|
-
complexityScore += Math.min(requirements.inputParameters.length * 0.3, 3);
|
|
162
|
-
complexityScore += Math.min(requirements.outputParameters.length * 0.3, 3);
|
|
163
|
-
// Determine complexity level
|
|
164
|
-
if (complexityScore >= 15)
|
|
165
|
-
return ComplexityLevel.VERY_HIGH;
|
|
166
|
-
if (complexityScore >= 10)
|
|
167
|
-
return ComplexityLevel.HIGH;
|
|
168
|
-
if (complexityScore >= 5)
|
|
169
|
-
return ComplexityLevel.MEDIUM;
|
|
170
|
-
return ComplexityLevel.LOW;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Analyze reusability potential
|
|
174
|
-
*/
|
|
175
|
-
analyzeReusability(requirements) {
|
|
176
|
-
let reusabilityScore = 0;
|
|
177
|
-
// Utility function indicators
|
|
178
|
-
if (requirements.isUtilityFunction)
|
|
179
|
-
reusabilityScore += 5;
|
|
180
|
-
// Reusable component indicators
|
|
181
|
-
if (requirements.hasReusableComponents)
|
|
182
|
-
reusabilityScore += 3;
|
|
183
|
-
// Generic patterns
|
|
184
|
-
if (this.isGenericPattern(requirements))
|
|
185
|
-
reusabilityScore += 4;
|
|
186
|
-
// Common business logic
|
|
187
|
-
if (requirements.hasBusinessRules && this.isCommonBusinessLogic(requirements))
|
|
188
|
-
reusabilityScore += 3;
|
|
189
|
-
// Data transformation utilities
|
|
190
|
-
if (requirements.hasDataTransformation)
|
|
191
|
-
reusabilityScore += 2;
|
|
192
|
-
// Multiple context applicability
|
|
193
|
-
if (requirements.contextIndicators.length > 1)
|
|
194
|
-
reusabilityScore += 2;
|
|
195
|
-
// Determine reusability level
|
|
196
|
-
if (reusabilityScore >= 12)
|
|
197
|
-
return ReusabilityLevel.HIGH;
|
|
198
|
-
if (reusabilityScore >= 8)
|
|
199
|
-
return ReusabilityLevel.MEDIUM;
|
|
200
|
-
if (reusabilityScore >= 4)
|
|
201
|
-
return ReusabilityLevel.LOW;
|
|
202
|
-
return ReusabilityLevel.NONE;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Determine the flow context
|
|
206
|
-
*/
|
|
207
|
-
determineContext(requirements) {
|
|
208
|
-
const contextIndicators = requirements.contextIndicators;
|
|
209
|
-
if (contextIndicators.includes('approval') || requirements.hasApprovalLogic) {
|
|
210
|
-
return FlowContext.APPROVAL_WORKFLOW;
|
|
211
|
-
}
|
|
212
|
-
if (contextIndicators.includes('fulfillment') || contextIndicators.includes('order')) {
|
|
213
|
-
return FlowContext.FULFILLMENT_WORKFLOW;
|
|
214
|
-
}
|
|
215
|
-
if (contextIndicators.includes('notification') || contextIndicators.includes('email')) {
|
|
216
|
-
return FlowContext.NOTIFICATION_WORKFLOW;
|
|
217
|
-
}
|
|
218
|
-
if (requirements.hasExternalIntegrations) {
|
|
219
|
-
return FlowContext.INTEGRATION_WORKFLOW;
|
|
220
|
-
}
|
|
221
|
-
if (requirements.isUtilityFunction || requirements.hasReusableComponents) {
|
|
222
|
-
return FlowContext.UTILITY_WORKFLOW;
|
|
223
|
-
}
|
|
224
|
-
if (requirements.hasBusinessRules) {
|
|
225
|
-
return FlowContext.BUSINESS_LOGIC;
|
|
226
|
-
}
|
|
227
|
-
return FlowContext.UTILITY_WORKFLOW;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Build comprehensive decision criteria
|
|
231
|
-
*/
|
|
232
|
-
buildDecisionCriteria(requirements, complexity, reusability, context) {
|
|
233
|
-
return {
|
|
234
|
-
complexity,
|
|
235
|
-
reusability,
|
|
236
|
-
context,
|
|
237
|
-
actionCount: requirements.actions.length,
|
|
238
|
-
inputParameters: requirements.inputParameters.length,
|
|
239
|
-
outputParameters: requirements.outputParameters.length,
|
|
240
|
-
businessLogicComplexity: this.calculateBusinessLogicComplexity(requirements),
|
|
241
|
-
integrationPoints: this.calculateIntegrationPoints(requirements),
|
|
242
|
-
errorHandlingComplexity: this.calculateErrorHandlingComplexity(requirements),
|
|
243
|
-
testabilityScore: this.calculateTestabilityScore(requirements),
|
|
244
|
-
maintainabilityScore: this.calculateMaintainabilityScore(requirements)
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Make the main decision based on criteria
|
|
249
|
-
*/
|
|
250
|
-
makeDecision(criteria) {
|
|
251
|
-
const rationale = [];
|
|
252
|
-
let score = 0;
|
|
253
|
-
// Complexity scoring (favors subflows for high complexity reusable components)
|
|
254
|
-
if (criteria.complexity === ComplexityLevel.HIGH || criteria.complexity === ComplexityLevel.VERY_HIGH) {
|
|
255
|
-
if (criteria.reusability === ReusabilityLevel.HIGH || criteria.reusability === ReusabilityLevel.MEDIUM) {
|
|
256
|
-
score += 30;
|
|
257
|
-
rationale.push('High complexity with high reusability favors subflow creation');
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
score -= 10;
|
|
261
|
-
rationale.push('High complexity with low reusability favors main flow');
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
// Reusability scoring
|
|
265
|
-
if (criteria.reusability === ReusabilityLevel.HIGH) {
|
|
266
|
-
score += 25;
|
|
267
|
-
rationale.push('High reusability strongly favors subflow');
|
|
268
|
-
}
|
|
269
|
-
else if (criteria.reusability === ReusabilityLevel.MEDIUM) {
|
|
270
|
-
score += 15;
|
|
271
|
-
rationale.push('Medium reusability moderately favors subflow');
|
|
272
|
-
}
|
|
273
|
-
// Context scoring
|
|
274
|
-
if (criteria.context === FlowContext.UTILITY_WORKFLOW) {
|
|
275
|
-
score += 20;
|
|
276
|
-
rationale.push('Utility workflow context favors subflow');
|
|
277
|
-
}
|
|
278
|
-
else if (criteria.context === FlowContext.BUSINESS_LOGIC) {
|
|
279
|
-
score += 15;
|
|
280
|
-
rationale.push('Business logic context favors subflow for reusability');
|
|
281
|
-
}
|
|
282
|
-
// Action count scoring
|
|
283
|
-
if (criteria.actionCount >= 10) {
|
|
284
|
-
score += 10;
|
|
285
|
-
rationale.push('High action count favors subflow for maintainability');
|
|
286
|
-
}
|
|
287
|
-
else if (criteria.actionCount <= 3) {
|
|
288
|
-
score -= 5;
|
|
289
|
-
rationale.push('Low action count favors main flow');
|
|
290
|
-
}
|
|
291
|
-
// Input/Output parameter scoring
|
|
292
|
-
if (criteria.inputParameters >= 5 || criteria.outputParameters >= 3) {
|
|
293
|
-
score += 10;
|
|
294
|
-
rationale.push('High parameter count favors subflow for clarity');
|
|
295
|
-
}
|
|
296
|
-
// Business logic complexity
|
|
297
|
-
if (criteria.businessLogicComplexity >= 8) {
|
|
298
|
-
score += 15;
|
|
299
|
-
rationale.push('Complex business logic favors subflow for separation of concerns');
|
|
300
|
-
}
|
|
301
|
-
// Integration points
|
|
302
|
-
if (criteria.integrationPoints >= 3) {
|
|
303
|
-
score += 10;
|
|
304
|
-
rationale.push('Multiple integration points favor subflow for modularity');
|
|
305
|
-
}
|
|
306
|
-
// Testability score
|
|
307
|
-
if (criteria.testabilityScore >= 8) {
|
|
308
|
-
score += 10;
|
|
309
|
-
rationale.push('High testability requirements favor subflow');
|
|
310
|
-
}
|
|
311
|
-
// Maintainability score
|
|
312
|
-
if (criteria.maintainabilityScore >= 8) {
|
|
313
|
-
score += 10;
|
|
314
|
-
rationale.push('High maintainability requirements favor subflow');
|
|
315
|
-
}
|
|
316
|
-
// Determine recommendation based on score
|
|
317
|
-
const confidence = Math.min(Math.abs(score) / 100, 0.95);
|
|
318
|
-
if (score >= 30) {
|
|
319
|
-
return {
|
|
320
|
-
type: FlowType.SUBFLOW,
|
|
321
|
-
confidence: confidence,
|
|
322
|
-
rationale: rationale.join('; '),
|
|
323
|
-
pros: [
|
|
324
|
-
'Improved reusability across multiple flows',
|
|
325
|
-
'Better maintainability and testability',
|
|
326
|
-
'Clear separation of concerns',
|
|
327
|
-
'Reduced code duplication'
|
|
328
|
-
],
|
|
329
|
-
cons: [
|
|
330
|
-
'Additional complexity in flow design',
|
|
331
|
-
'Potential performance overhead',
|
|
332
|
-
'More artifacts to manage'
|
|
333
|
-
]
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
else {
|
|
337
|
-
return {
|
|
338
|
-
type: FlowType.MAIN_FLOW,
|
|
339
|
-
confidence: confidence,
|
|
340
|
-
rationale: rationale.join('; ') || 'Simple workflow without complex reusability requirements',
|
|
341
|
-
pros: [
|
|
342
|
-
'Simpler flow design',
|
|
343
|
-
'Fewer artifacts to manage',
|
|
344
|
-
'Direct execution path',
|
|
345
|
-
'Easier debugging'
|
|
346
|
-
],
|
|
347
|
-
cons: [
|
|
348
|
-
'Potential code duplication',
|
|
349
|
-
'Limited reusability',
|
|
350
|
-
'May become complex over time'
|
|
351
|
-
]
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Identify potential subflow candidates within the requirements
|
|
357
|
-
*/
|
|
358
|
-
identifySubflowCandidates(requirements) {
|
|
359
|
-
const candidates = [];
|
|
360
|
-
// Approval logic candidate
|
|
361
|
-
if (requirements.hasApprovalLogic) {
|
|
362
|
-
candidates.push({
|
|
363
|
-
name: 'Approval Process',
|
|
364
|
-
description: 'Reusable approval workflow with configurable approvers',
|
|
365
|
-
reason: 'Approval logic is commonly reused across different workflows',
|
|
366
|
-
complexity: ComplexityLevel.MEDIUM,
|
|
367
|
-
reusability: ReusabilityLevel.HIGH,
|
|
368
|
-
inputs: [
|
|
369
|
-
{
|
|
370
|
-
name: 'record',
|
|
371
|
-
type: 'reference',
|
|
372
|
-
required: true,
|
|
373
|
-
description: 'Record requiring approval'
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
name: 'approvers',
|
|
377
|
-
type: 'string',
|
|
378
|
-
required: true,
|
|
379
|
-
description: 'Comma-separated list of approvers'
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
name: 'timeout_hours',
|
|
383
|
-
type: 'integer',
|
|
384
|
-
required: false,
|
|
385
|
-
description: 'Approval timeout in hours',
|
|
386
|
-
defaultValue: 48
|
|
387
|
-
}
|
|
388
|
-
],
|
|
389
|
-
outputs: [
|
|
390
|
-
{
|
|
391
|
-
name: 'approval_state',
|
|
392
|
-
type: 'string',
|
|
393
|
-
description: 'Final approval state (approved/rejected/timeout)'
|
|
394
|
-
},
|
|
395
|
-
{
|
|
396
|
-
name: 'approved_by',
|
|
397
|
-
type: 'string',
|
|
398
|
-
description: 'User who approved the request'
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
name: 'approval_comments',
|
|
402
|
-
type: 'string',
|
|
403
|
-
description: 'Comments from the approver'
|
|
404
|
-
}
|
|
405
|
-
],
|
|
406
|
-
actions: ['request_approval', 'check_timeout', 'process_response']
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
// Notification candidate
|
|
410
|
-
if (requirements.contextIndicators.includes('notification') || requirements.contextIndicators.includes('email')) {
|
|
411
|
-
candidates.push({
|
|
412
|
-
name: 'Notification Handler',
|
|
413
|
-
description: 'Reusable notification system with multiple delivery methods',
|
|
414
|
-
reason: 'Notification logic is commonly reused across different workflows',
|
|
415
|
-
complexity: ComplexityLevel.LOW,
|
|
416
|
-
reusability: ReusabilityLevel.HIGH,
|
|
417
|
-
inputs: [
|
|
418
|
-
{
|
|
419
|
-
name: 'recipients',
|
|
420
|
-
type: 'string',
|
|
421
|
-
required: true,
|
|
422
|
-
description: 'Recipients for the notification'
|
|
423
|
-
},
|
|
424
|
-
{
|
|
425
|
-
name: 'message_template',
|
|
426
|
-
type: 'string',
|
|
427
|
-
required: true,
|
|
428
|
-
description: 'Message template to use'
|
|
429
|
-
},
|
|
430
|
-
{
|
|
431
|
-
name: 'notification_type',
|
|
432
|
-
type: 'string',
|
|
433
|
-
required: false,
|
|
434
|
-
description: 'Type of notification (email, sms, push)',
|
|
435
|
-
defaultValue: 'email'
|
|
436
|
-
}
|
|
437
|
-
],
|
|
438
|
-
outputs: [
|
|
439
|
-
{
|
|
440
|
-
name: 'notification_sent',
|
|
441
|
-
type: 'boolean',
|
|
442
|
-
description: 'Whether notification was sent successfully'
|
|
443
|
-
},
|
|
444
|
-
{
|
|
445
|
-
name: 'delivery_status',
|
|
446
|
-
type: 'string',
|
|
447
|
-
description: 'Delivery status details'
|
|
448
|
-
}
|
|
449
|
-
],
|
|
450
|
-
actions: ['format_message', 'send_notification', 'track_delivery']
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
// Data transformation candidate
|
|
454
|
-
if (requirements.hasDataTransformation) {
|
|
455
|
-
candidates.push({
|
|
456
|
-
name: 'Data Transformer',
|
|
457
|
-
description: 'Reusable data transformation utility',
|
|
458
|
-
reason: 'Data transformation logic can be reused across multiple contexts',
|
|
459
|
-
complexity: ComplexityLevel.MEDIUM,
|
|
460
|
-
reusability: ReusabilityLevel.MEDIUM,
|
|
461
|
-
inputs: [
|
|
462
|
-
{
|
|
463
|
-
name: 'source_data',
|
|
464
|
-
type: 'object',
|
|
465
|
-
required: true,
|
|
466
|
-
description: 'Source data to transform'
|
|
467
|
-
},
|
|
468
|
-
{
|
|
469
|
-
name: 'transformation_rules',
|
|
470
|
-
type: 'object',
|
|
471
|
-
required: true,
|
|
472
|
-
description: 'Rules for data transformation'
|
|
473
|
-
}
|
|
474
|
-
],
|
|
475
|
-
outputs: [
|
|
476
|
-
{
|
|
477
|
-
name: 'transformed_data',
|
|
478
|
-
type: 'object',
|
|
479
|
-
description: 'Transformed data result'
|
|
480
|
-
},
|
|
481
|
-
{
|
|
482
|
-
name: 'transformation_success',
|
|
483
|
-
type: 'boolean',
|
|
484
|
-
description: 'Whether transformation was successful'
|
|
485
|
-
}
|
|
486
|
-
],
|
|
487
|
-
actions: ['validate_input', 'apply_transformation', 'validate_output']
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
// Business rule candidate
|
|
491
|
-
if (requirements.hasBusinessRules) {
|
|
492
|
-
candidates.push({
|
|
493
|
-
name: 'Business Rule Processor',
|
|
494
|
-
description: 'Reusable business rule evaluation engine',
|
|
495
|
-
reason: 'Business rules are often reused across different business processes',
|
|
496
|
-
complexity: ComplexityLevel.HIGH,
|
|
497
|
-
reusability: ReusabilityLevel.HIGH,
|
|
498
|
-
inputs: [
|
|
499
|
-
{
|
|
500
|
-
name: 'business_object',
|
|
501
|
-
type: 'object',
|
|
502
|
-
required: true,
|
|
503
|
-
description: 'Business object to evaluate'
|
|
504
|
-
},
|
|
505
|
-
{
|
|
506
|
-
name: 'rule_set',
|
|
507
|
-
type: 'string',
|
|
508
|
-
required: true,
|
|
509
|
-
description: 'Rule set identifier'
|
|
510
|
-
}
|
|
511
|
-
],
|
|
512
|
-
outputs: [
|
|
513
|
-
{
|
|
514
|
-
name: 'rule_result',
|
|
515
|
-
type: 'object',
|
|
516
|
-
description: 'Result of rule evaluation'
|
|
517
|
-
},
|
|
518
|
-
{
|
|
519
|
-
name: 'violated_rules',
|
|
520
|
-
type: 'array',
|
|
521
|
-
description: 'List of violated rules'
|
|
522
|
-
}
|
|
523
|
-
],
|
|
524
|
-
actions: ['load_rules', 'evaluate_rules', 'format_results']
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
return candidates;
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* Match known patterns to the requirements
|
|
531
|
-
*/
|
|
532
|
-
matchPatterns(requirements, context) {
|
|
533
|
-
return this.patterns.filter(pattern => {
|
|
534
|
-
// Match by context
|
|
535
|
-
if (pattern.context === context)
|
|
536
|
-
return true;
|
|
537
|
-
// Match by actions
|
|
538
|
-
const actionMatch = pattern.commonActions.some(action => requirements.actions.some((reqAction) => reqAction.includes(action)));
|
|
539
|
-
return actionMatch;
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
/**
|
|
543
|
-
* Generate alternative recommendations
|
|
544
|
-
*/
|
|
545
|
-
generateAlternatives(criteria) {
|
|
546
|
-
const alternatives = [];
|
|
547
|
-
// Always provide the opposite recommendation as an alternative
|
|
548
|
-
if (criteria.reusability === ReusabilityLevel.HIGH) {
|
|
549
|
-
alternatives.push({
|
|
550
|
-
type: FlowType.MAIN_FLOW,
|
|
551
|
-
confidence: 0.3,
|
|
552
|
-
rationale: 'Direct implementation without subflow abstraction',
|
|
553
|
-
pros: ['Simpler initial implementation', 'Fewer dependencies'],
|
|
554
|
-
cons: ['Limited reusability', 'Potential duplication']
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
else {
|
|
558
|
-
alternatives.push({
|
|
559
|
-
type: FlowType.SUBFLOW,
|
|
560
|
-
confidence: 0.4,
|
|
561
|
-
rationale: 'Create subflow for future reusability',
|
|
562
|
-
pros: ['Future-proof design', 'Easier to test'],
|
|
563
|
-
cons: ['Over-engineering for current needs', 'Additional complexity']
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
return alternatives;
|
|
567
|
-
}
|
|
568
|
-
/**
|
|
569
|
-
* Initialize common flow patterns
|
|
570
|
-
*/
|
|
571
|
-
initializePatterns() {
|
|
572
|
-
this.patterns = [
|
|
573
|
-
{
|
|
574
|
-
name: 'Approval Workflow',
|
|
575
|
-
description: 'Standard approval process with configurable approvers',
|
|
576
|
-
context: FlowContext.APPROVAL_WORKFLOW,
|
|
577
|
-
recommendedType: FlowType.SUBFLOW,
|
|
578
|
-
commonActions: ['approve', 'reject', 'timeout'],
|
|
579
|
-
inputPatterns: ['approvers', 'record', 'timeout'],
|
|
580
|
-
outputPatterns: ['approval_state', 'approved_by'],
|
|
581
|
-
complexity: ComplexityLevel.MEDIUM
|
|
582
|
-
},
|
|
583
|
-
{
|
|
584
|
-
name: 'Notification Dispatcher',
|
|
585
|
-
description: 'Multi-channel notification system',
|
|
586
|
-
context: FlowContext.NOTIFICATION_WORKFLOW,
|
|
587
|
-
recommendedType: FlowType.SUBFLOW,
|
|
588
|
-
commonActions: ['send_email', 'send_sms', 'track_delivery'],
|
|
589
|
-
inputPatterns: ['recipients', 'message', 'channel'],
|
|
590
|
-
outputPatterns: ['delivery_status', 'sent_count'],
|
|
591
|
-
complexity: ComplexityLevel.LOW
|
|
592
|
-
},
|
|
593
|
-
{
|
|
594
|
-
name: 'Order Fulfillment',
|
|
595
|
-
description: 'Complete order processing workflow',
|
|
596
|
-
context: FlowContext.FULFILLMENT_WORKFLOW,
|
|
597
|
-
recommendedType: FlowType.MAIN_FLOW,
|
|
598
|
-
commonActions: ['validate_order', 'process_payment', 'ship_order'],
|
|
599
|
-
inputPatterns: ['order', 'customer', 'payment_method'],
|
|
600
|
-
outputPatterns: ['order_status', 'tracking_number'],
|
|
601
|
-
complexity: ComplexityLevel.HIGH
|
|
602
|
-
},
|
|
603
|
-
{
|
|
604
|
-
name: 'Data Validation',
|
|
605
|
-
description: 'Reusable data validation utility',
|
|
606
|
-
context: FlowContext.UTILITY_WORKFLOW,
|
|
607
|
-
recommendedType: FlowType.SUBFLOW,
|
|
608
|
-
commonActions: ['validate_format', 'check_constraints', 'sanitize'],
|
|
609
|
-
inputPatterns: ['data', 'validation_rules'],
|
|
610
|
-
outputPatterns: ['is_valid', 'errors'],
|
|
611
|
-
complexity: ComplexityLevel.LOW
|
|
612
|
-
},
|
|
613
|
-
{
|
|
614
|
-
name: 'Integration Connector',
|
|
615
|
-
description: 'External system integration pattern',
|
|
616
|
-
context: FlowContext.INTEGRATION_WORKFLOW,
|
|
617
|
-
recommendedType: FlowType.SUBFLOW,
|
|
618
|
-
commonActions: ['authenticate', 'transform_data', 'call_api'],
|
|
619
|
-
inputPatterns: ['endpoint', 'credentials', 'payload'],
|
|
620
|
-
outputPatterns: ['response', 'status'],
|
|
621
|
-
complexity: ComplexityLevel.MEDIUM
|
|
622
|
-
}
|
|
623
|
-
];
|
|
624
|
-
}
|
|
625
|
-
// Helper methods for requirement analysis
|
|
626
|
-
extractActions(instruction) {
|
|
627
|
-
const actions = [];
|
|
628
|
-
const actionKeywords = [
|
|
629
|
-
'approve', 'reject', 'notify', 'send', 'create', 'update', 'delete',
|
|
630
|
-
'validate', 'process', 'transform', 'integrate', 'schedule', 'assign',
|
|
631
|
-
'escalate', 'complete', 'cancel', 'retry', 'log', 'track', 'monitor'
|
|
632
|
-
];
|
|
633
|
-
actionKeywords.forEach(keyword => {
|
|
634
|
-
if (instruction.includes(keyword)) {
|
|
635
|
-
actions.push(keyword);
|
|
636
|
-
}
|
|
637
|
-
});
|
|
638
|
-
return actions;
|
|
639
|
-
}
|
|
640
|
-
hasConditionalLogic(instruction) {
|
|
641
|
-
return /\b(if|when|unless|condition|check|validate|approve|reject)\b/.test(instruction);
|
|
642
|
-
}
|
|
643
|
-
hasLoops(instruction) {
|
|
644
|
-
return /\b(loop|repeat|iterate|foreach|while|until|retry)\b/.test(instruction);
|
|
645
|
-
}
|
|
646
|
-
hasParallelActions(instruction) {
|
|
647
|
-
return /\b(parallel|concurrent|simultaneously|at the same time)\b/.test(instruction);
|
|
648
|
-
}
|
|
649
|
-
hasExternalIntegrations(instruction) {
|
|
650
|
-
return /\b(api|integration|external|third-party|webhook|service)\b/.test(instruction);
|
|
651
|
-
}
|
|
652
|
-
hasDataTransformation(instruction) {
|
|
653
|
-
return /\b(transform|convert|map|format|parse|serialize)\b/.test(instruction);
|
|
654
|
-
}
|
|
655
|
-
hasBusinessRules(instruction) {
|
|
656
|
-
return /\b(business rule|policy|constraint|validation|compliance)\b/.test(instruction);
|
|
657
|
-
}
|
|
658
|
-
hasApprovalLogic(instruction) {
|
|
659
|
-
return /\b(approval|approve|reject|escalate|manager|supervisor)\b/.test(instruction);
|
|
660
|
-
}
|
|
661
|
-
hasReusableComponents(instruction) {
|
|
662
|
-
return /\b(reuse|common|shared|utility|helper|generic)\b/.test(instruction);
|
|
663
|
-
}
|
|
664
|
-
isUtilityFunction(instruction) {
|
|
665
|
-
return /\b(utility|helper|common|shared|library|function)\b/.test(instruction);
|
|
666
|
-
}
|
|
667
|
-
hasErrorHandling(instruction) {
|
|
668
|
-
return /\b(error|exception|fail|retry|fallback|recovery)\b/.test(instruction);
|
|
669
|
-
}
|
|
670
|
-
extractInputParameters(instruction) {
|
|
671
|
-
const parameters = [];
|
|
672
|
-
const parameterPatterns = [
|
|
673
|
-
/with\s+([a-zA-Z_][a-zA-Z0-9_]*)/g,
|
|
674
|
-
/using\s+([a-zA-Z_][a-zA-Z0-9_]*)/g,
|
|
675
|
-
/input\s+([a-zA-Z_][a-zA-Z0-9_]*)/g
|
|
676
|
-
];
|
|
677
|
-
parameterPatterns.forEach(pattern => {
|
|
678
|
-
let match;
|
|
679
|
-
while ((match = pattern.exec(instruction)) !== null) {
|
|
680
|
-
parameters.push(match[1]);
|
|
681
|
-
}
|
|
682
|
-
});
|
|
683
|
-
return parameters;
|
|
684
|
-
}
|
|
685
|
-
extractOutputParameters(instruction) {
|
|
686
|
-
const parameters = [];
|
|
687
|
-
const parameterPatterns = [
|
|
688
|
-
/returns?\s+([a-zA-Z_][a-zA-Z0-9_]*)/g,
|
|
689
|
-
/output\s+([a-zA-Z_][a-zA-Z0-9_]*)/g,
|
|
690
|
-
/result\s+([a-zA-Z_][a-zA-Z0-9_]*)/g
|
|
691
|
-
];
|
|
692
|
-
parameterPatterns.forEach(pattern => {
|
|
693
|
-
let match;
|
|
694
|
-
while ((match = pattern.exec(instruction)) !== null) {
|
|
695
|
-
parameters.push(match[1]);
|
|
696
|
-
}
|
|
697
|
-
});
|
|
698
|
-
return parameters;
|
|
699
|
-
}
|
|
700
|
-
extractContextIndicators(instruction) {
|
|
701
|
-
const indicators = [];
|
|
702
|
-
const contextKeywords = [
|
|
703
|
-
'approval', 'fulfillment', 'notification', 'integration', 'utility',
|
|
704
|
-
'business', 'order', 'catalog', 'incident', 'problem', 'change'
|
|
705
|
-
];
|
|
706
|
-
contextKeywords.forEach(keyword => {
|
|
707
|
-
if (instruction.includes(keyword)) {
|
|
708
|
-
indicators.push(keyword);
|
|
709
|
-
}
|
|
710
|
-
});
|
|
711
|
-
return indicators;
|
|
712
|
-
}
|
|
713
|
-
isGenericPattern(requirements) {
|
|
714
|
-
return requirements.isUtilityFunction ||
|
|
715
|
-
requirements.hasReusableComponents ||
|
|
716
|
-
requirements.contextIndicators.length > 2;
|
|
717
|
-
}
|
|
718
|
-
isCommonBusinessLogic(requirements) {
|
|
719
|
-
const commonLogicPatterns = ['approval', 'validation', 'notification', 'assignment'];
|
|
720
|
-
return commonLogicPatterns.some(pattern => requirements.contextIndicators.includes(pattern));
|
|
721
|
-
}
|
|
722
|
-
calculateBusinessLogicComplexity(requirements) {
|
|
723
|
-
let complexity = 0;
|
|
724
|
-
if (requirements.hasBusinessRules)
|
|
725
|
-
complexity += 3;
|
|
726
|
-
if (requirements.hasApprovalLogic)
|
|
727
|
-
complexity += 2;
|
|
728
|
-
if (requirements.hasConditionalLogic)
|
|
729
|
-
complexity += 2;
|
|
730
|
-
if (requirements.hasLoops)
|
|
731
|
-
complexity += 3;
|
|
732
|
-
return complexity;
|
|
733
|
-
}
|
|
734
|
-
calculateIntegrationPoints(requirements) {
|
|
735
|
-
let points = 0;
|
|
736
|
-
if (requirements.hasExternalIntegrations)
|
|
737
|
-
points += 2;
|
|
738
|
-
if (requirements.hasDataTransformation)
|
|
739
|
-
points += 1;
|
|
740
|
-
return points;
|
|
741
|
-
}
|
|
742
|
-
calculateErrorHandlingComplexity(requirements) {
|
|
743
|
-
return requirements.hasErrorHandling ? 3 : 0;
|
|
744
|
-
}
|
|
745
|
-
calculateTestabilityScore(requirements) {
|
|
746
|
-
let score = 5; // Base score
|
|
747
|
-
if (requirements.inputParameters.length > 0)
|
|
748
|
-
score += 2;
|
|
749
|
-
if (requirements.outputParameters.length > 0)
|
|
750
|
-
score += 2;
|
|
751
|
-
if (requirements.hasBusinessRules)
|
|
752
|
-
score += 1;
|
|
753
|
-
return Math.min(score, 10);
|
|
754
|
-
}
|
|
755
|
-
calculateMaintainabilityScore(requirements) {
|
|
756
|
-
let score = 5; // Base score
|
|
757
|
-
if (requirements.actions.length > 5)
|
|
758
|
-
score += 2;
|
|
759
|
-
if (requirements.hasBusinessRules)
|
|
760
|
-
score += 1;
|
|
761
|
-
if (requirements.hasErrorHandling)
|
|
762
|
-
score += 1;
|
|
763
|
-
if (requirements.hasReusableComponents)
|
|
764
|
-
score += 1;
|
|
765
|
-
return Math.min(score, 10);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
exports.FlowSubflowDecisionEngine = FlowSubflowDecisionEngine;
|
|
769
|
-
//# sourceMappingURL=flow-subflow-decision-engine.js.map
|