snow-flow 1.1.0
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/.env.example +49 -0
- package/.mcp.json +106 -0
- package/.mcp.json.template +106 -0
- package/LICENSE +21 -0
- package/README.md +236 -0
- package/bin/snow-flow +4 -0
- package/bin/snow-flow.js +3 -0
- package/claude-flow +79 -0
- package/claude-flow.bat +18 -0
- package/claude-flow.config.json +20 -0
- package/claude-flow.ps1 +24 -0
- package/dist/agents/app-creator.agent.d.ts +55 -0
- package/dist/agents/app-creator.agent.d.ts.map +1 -0
- package/dist/agents/app-creator.agent.js +1292 -0
- package/dist/agents/app-creator.agent.js.map +1 -0
- package/dist/agents/base-snow-agent.d.ts +63 -0
- package/dist/agents/base-snow-agent.d.ts.map +1 -0
- package/dist/agents/base-snow-agent.js +296 -0
- package/dist/agents/base-snow-agent.js.map +1 -0
- package/dist/agents/script-generator.agent.d.ts +32 -0
- package/dist/agents/script-generator.agent.d.ts.map +1 -0
- package/dist/agents/script-generator.agent.js +772 -0
- package/dist/agents/script-generator.agent.js.map +1 -0
- package/dist/agents/ui-builder.agent.d.ts +50 -0
- package/dist/agents/ui-builder.agent.d.ts.map +1 -0
- package/dist/agents/ui-builder.agent.js +1539 -0
- package/dist/agents/ui-builder.agent.js.map +1 -0
- package/dist/agents/widget-builder.agent.d.ts +32 -0
- package/dist/agents/widget-builder.agent.d.ts.map +1 -0
- package/dist/agents/widget-builder.agent.js +439 -0
- package/dist/agents/widget-builder.agent.js.map +1 -0
- package/dist/agents/workflow-designer.agent.d.ts +31 -0
- package/dist/agents/workflow-designer.agent.d.ts.map +1 -0
- package/dist/agents/workflow-designer.agent.js +583 -0
- package/dist/agents/workflow-designer.agent.js.map +1 -0
- package/dist/api/error-handling.d.ts +214 -0
- package/dist/api/error-handling.d.ts.map +1 -0
- package/dist/api/error-handling.js +594 -0
- package/dist/api/error-handling.js.map +1 -0
- package/dist/api/flow-designer-api.d.ts +167 -0
- package/dist/api/flow-designer-api.d.ts.map +1 -0
- package/dist/api/flow-designer-api.js +555 -0
- package/dist/api/flow-designer-api.js.map +1 -0
- package/dist/api/natural-language-mapper.d.ts +126 -0
- package/dist/api/natural-language-mapper.d.ts.map +1 -0
- package/dist/api/natural-language-mapper.js +498 -0
- package/dist/api/natural-language-mapper.js.map +1 -0
- package/dist/api/performance-optimizer.d.ts +240 -0
- package/dist/api/performance-optimizer.d.ts.map +1 -0
- package/dist/api/performance-optimizer.js +701 -0
- package/dist/api/performance-optimizer.js.map +1 -0
- package/dist/api/transaction-manager.d.ts +189 -0
- package/dist/api/transaction-manager.d.ts.map +1 -0
- package/dist/api/transaction-manager.js +576 -0
- package/dist/api/transaction-manager.js.map +1 -0
- package/dist/cli/deploy-artifact.d.ts +7 -0
- package/dist/cli/deploy-artifact.d.ts.map +1 -0
- package/dist/cli/deploy-artifact.js +279 -0
- package/dist/cli/deploy-artifact.js.map +1 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +2057 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/managers/scope-manager.d.ts +75 -0
- package/dist/managers/scope-manager.d.ts.map +1 -0
- package/dist/managers/scope-manager.js +448 -0
- package/dist/managers/scope-manager.js.map +1 -0
- package/dist/mcp/mcp-wrapper.d.ts +8 -0
- package/dist/mcp/mcp-wrapper.d.ts.map +1 -0
- package/dist/mcp/mcp-wrapper.js +77 -0
- package/dist/mcp/mcp-wrapper.js.map +1 -0
- package/dist/mcp/servicenow-automation-mcp.d.ts +8 -0
- package/dist/mcp/servicenow-automation-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-automation-mcp.js +683 -0
- package/dist/mcp/servicenow-automation-mcp.js.map +1 -0
- package/dist/mcp/servicenow-deployment-mcp.d.ts +7 -0
- package/dist/mcp/servicenow-deployment-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-deployment-mcp.js +972 -0
- package/dist/mcp/servicenow-deployment-mcp.js.map +1 -0
- package/dist/mcp/servicenow-flow-composer-mcp.d.ts +7 -0
- package/dist/mcp/servicenow-flow-composer-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-flow-composer-mcp.js +1121 -0
- package/dist/mcp/servicenow-flow-composer-mcp.js.map +1 -0
- package/dist/mcp/servicenow-graph-memory-mcp.d.ts +7 -0
- package/dist/mcp/servicenow-graph-memory-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-graph-memory-mcp.js +703 -0
- package/dist/mcp/servicenow-graph-memory-mcp.js.map +1 -0
- package/dist/mcp/servicenow-integration-mcp.d.ts +8 -0
- package/dist/mcp/servicenow-integration-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-integration-mcp.js +689 -0
- package/dist/mcp/servicenow-integration-mcp.js.map +1 -0
- package/dist/mcp/servicenow-intelligent-mcp.d.ts +7 -0
- package/dist/mcp/servicenow-intelligent-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-intelligent-mcp.js +1138 -0
- package/dist/mcp/servicenow-intelligent-mcp.js.map +1 -0
- package/dist/mcp/servicenow-mcp-server.d.ts +37 -0
- package/dist/mcp/servicenow-mcp-server.d.ts.map +1 -0
- package/dist/mcp/servicenow-mcp-server.js +648 -0
- package/dist/mcp/servicenow-mcp-server.js.map +1 -0
- package/dist/mcp/servicenow-operations-mcp.d.ts +15 -0
- package/dist/mcp/servicenow-operations-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-operations-mcp.js +1287 -0
- package/dist/mcp/servicenow-operations-mcp.js.map +1 -0
- package/dist/mcp/servicenow-platform-development-mcp.d.ts +8 -0
- package/dist/mcp/servicenow-platform-development-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-platform-development-mcp.js +557 -0
- package/dist/mcp/servicenow-platform-development-mcp.js.map +1 -0
- package/dist/mcp/servicenow-progressive-indexer.d.ts +79 -0
- package/dist/mcp/servicenow-progressive-indexer.d.ts.map +1 -0
- package/dist/mcp/servicenow-progressive-indexer.js +320 -0
- package/dist/mcp/servicenow-progressive-indexer.js.map +1 -0
- package/dist/mcp/servicenow-reporting-analytics-mcp.d.ts +8 -0
- package/dist/mcp/servicenow-reporting-analytics-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-reporting-analytics-mcp.js +888 -0
- package/dist/mcp/servicenow-reporting-analytics-mcp.js.map +1 -0
- package/dist/mcp/servicenow-security-compliance-mcp.d.ts +8 -0
- package/dist/mcp/servicenow-security-compliance-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-security-compliance-mcp.js +812 -0
- package/dist/mcp/servicenow-security-compliance-mcp.js.map +1 -0
- package/dist/mcp/servicenow-update-set-mcp.d.ts +7 -0
- package/dist/mcp/servicenow-update-set-mcp.d.ts.map +1 -0
- package/dist/mcp/servicenow-update-set-mcp.js +599 -0
- package/dist/mcp/servicenow-update-set-mcp.js.map +1 -0
- package/dist/mcp/start-all-mcp-servers.d.ts +6 -0
- package/dist/mcp/start-all-mcp-servers.d.ts.map +1 -0
- package/dist/mcp/start-all-mcp-servers.js +65 -0
- package/dist/mcp/start-all-mcp-servers.js.map +1 -0
- package/dist/mcp/start-servicenow-mcp.d.ts +7 -0
- package/dist/mcp/start-servicenow-mcp.d.ts.map +1 -0
- package/dist/mcp/start-servicenow-mcp.js +64 -0
- package/dist/mcp/start-servicenow-mcp.js.map +1 -0
- package/dist/mcp/test-simple-mcp.d.ts +6 -0
- package/dist/mcp/test-simple-mcp.d.ts.map +1 -0
- package/dist/mcp/test-simple-mcp.js +64 -0
- package/dist/mcp/test-simple-mcp.js.map +1 -0
- package/dist/orchestrator/flow-composer.d.ts +269 -0
- package/dist/orchestrator/flow-composer.d.ts.map +1 -0
- package/dist/orchestrator/flow-composer.js +2221 -0
- package/dist/orchestrator/flow-composer.js.map +1 -0
- package/dist/orchestrator/flow-pattern-templates.d.ts +260 -0
- package/dist/orchestrator/flow-pattern-templates.d.ts.map +1 -0
- package/dist/orchestrator/flow-pattern-templates.js +906 -0
- package/dist/orchestrator/flow-pattern-templates.js.map +1 -0
- package/dist/orchestrator/flow-subflow-decision-engine.d.ts +202 -0
- package/dist/orchestrator/flow-subflow-decision-engine.d.ts.map +1 -0
- package/dist/orchestrator/flow-subflow-decision-engine.js +769 -0
- package/dist/orchestrator/flow-subflow-decision-engine.js.map +1 -0
- package/dist/orchestrator/flow-validation-engine.d.ts +145 -0
- package/dist/orchestrator/flow-validation-engine.d.ts.map +1 -0
- package/dist/orchestrator/flow-validation-engine.js +663 -0
- package/dist/orchestrator/flow-validation-engine.js.map +1 -0
- package/dist/orchestrator/snow-orchestrator.d.ts +49 -0
- package/dist/orchestrator/snow-orchestrator.d.ts.map +1 -0
- package/dist/orchestrator/snow-orchestrator.js +235 -0
- package/dist/orchestrator/snow-orchestrator.js.map +1 -0
- package/dist/orchestrator/subflow-creation-handler.d.ts +230 -0
- package/dist/orchestrator/subflow-creation-handler.d.ts.map +1 -0
- package/dist/orchestrator/subflow-creation-handler.js +791 -0
- package/dist/orchestrator/subflow-creation-handler.js.map +1 -0
- package/dist/strategies/global-scope-strategy.d.ts +123 -0
- package/dist/strategies/global-scope-strategy.d.ts.map +1 -0
- package/dist/strategies/global-scope-strategy.js +585 -0
- package/dist/strategies/global-scope-strategy.js.map +1 -0
- package/dist/types/index.d.ts +138 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/servicenow.types.d.ts +260 -0
- package/dist/types/servicenow.types.d.ts.map +1 -0
- package/dist/types/servicenow.types.js +3 -0
- package/dist/types/servicenow.types.js.map +1 -0
- package/dist/types/snow-flow.types.d.ts +114 -0
- package/dist/types/snow-flow.types.d.ts.map +1 -0
- package/dist/types/snow-flow.types.js +3 -0
- package/dist/types/snow-flow.types.js.map +1 -0
- package/dist/utils/action-type-cache.d.ts +66 -0
- package/dist/utils/action-type-cache.d.ts.map +1 -0
- package/dist/utils/action-type-cache.js +237 -0
- package/dist/utils/action-type-cache.js.map +1 -0
- package/dist/utils/agent-detector.d.ts +35 -0
- package/dist/utils/agent-detector.d.ts.map +1 -0
- package/dist/utils/agent-detector.js +353 -0
- package/dist/utils/agent-detector.js.map +1 -0
- package/dist/utils/flow-api-discovery.d.ts +151 -0
- package/dist/utils/flow-api-discovery.d.ts.map +1 -0
- package/dist/utils/flow-api-discovery.js +440 -0
- package/dist/utils/flow-api-discovery.js.map +1 -0
- package/dist/utils/flow-xml-generator.d.ts +41 -0
- package/dist/utils/flow-xml-generator.d.ts.map +1 -0
- package/dist/utils/flow-xml-generator.js +258 -0
- package/dist/utils/flow-xml-generator.js.map +1 -0
- package/dist/utils/logger.d.ts +13 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +51 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/mcp-auth-middleware.d.ts +58 -0
- package/dist/utils/mcp-auth-middleware.d.ts.map +1 -0
- package/dist/utils/mcp-auth-middleware.js +227 -0
- package/dist/utils/mcp-auth-middleware.js.map +1 -0
- package/dist/utils/mcp-config-manager.d.ts +126 -0
- package/dist/utils/mcp-config-manager.d.ts.map +1 -0
- package/dist/utils/mcp-config-manager.js +209 -0
- package/dist/utils/mcp-config-manager.js.map +1 -0
- package/dist/utils/mcp-server-manager.d.ts +91 -0
- package/dist/utils/mcp-server-manager.d.ts.map +1 -0
- package/dist/utils/mcp-server-manager.js +338 -0
- package/dist/utils/mcp-server-manager.js.map +1 -0
- package/dist/utils/scope-utils.d.ts +72 -0
- package/dist/utils/scope-utils.d.ts.map +1 -0
- package/dist/utils/scope-utils.js +386 -0
- package/dist/utils/scope-utils.js.map +1 -0
- package/dist/utils/servicenow-client.d.ts +233 -0
- package/dist/utils/servicenow-client.d.ts.map +1 -0
- package/dist/utils/servicenow-client.js +1465 -0
- package/dist/utils/servicenow-client.js.map +1 -0
- package/dist/utils/snow-oauth-old.d.ts +65 -0
- package/dist/utils/snow-oauth-old.d.ts.map +1 -0
- package/dist/utils/snow-oauth-old.js +345 -0
- package/dist/utils/snow-oauth-old.js.map +1 -0
- package/dist/utils/snow-oauth.d.ts +85 -0
- package/dist/utils/snow-oauth.d.ts.map +1 -0
- package/dist/utils/snow-oauth.js +512 -0
- package/dist/utils/snow-oauth.js.map +1 -0
- package/dist/utils/template-engine.d.ts +76 -0
- package/dist/utils/template-engine.d.ts.map +1 -0
- package/dist/utils/template-engine.js +391 -0
- package/dist/utils/template-engine.js.map +1 -0
- package/dist/version.d.ts +35 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +72 -0
- package/dist/version.js.map +1 -0
- package/mcp-wrapper.sh +12 -0
- package/package.json +77 -0
- package/reports/swarm-auto-centralized-1752649029776.json +13 -0
- package/scripts/postinstall.js +30 -0
- package/scripts/setup-mcp.js +89 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ServiceNow Action Type Cache
|
|
4
|
+
* Dynamically discovers and caches Flow Designer action types
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ActionTypeCache = void 0;
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const logger_js_1 = require("./logger.js");
|
|
14
|
+
class ActionTypeCache {
|
|
15
|
+
constructor(client) {
|
|
16
|
+
this.actionTypesCache = new Map();
|
|
17
|
+
this.triggerTypesCache = new Map();
|
|
18
|
+
this.cacheLoaded = false;
|
|
19
|
+
this.logger = new logger_js_1.Logger('ActionTypeCache');
|
|
20
|
+
this.client = client;
|
|
21
|
+
this.cacheDir = path_1.default.join(process.cwd(), '.snow-flow', 'cache');
|
|
22
|
+
this.ensureCacheDir();
|
|
23
|
+
}
|
|
24
|
+
ensureCacheDir() {
|
|
25
|
+
if (!fs_1.default.existsSync(this.cacheDir)) {
|
|
26
|
+
fs_1.default.mkdirSync(this.cacheDir, { recursive: true });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get action type by name or label
|
|
31
|
+
*/
|
|
32
|
+
async getActionType(nameOrLabel) {
|
|
33
|
+
await this.ensureCache();
|
|
34
|
+
// First try exact match
|
|
35
|
+
for (const [_, actionType] of this.actionTypesCache) {
|
|
36
|
+
if (actionType.name === nameOrLabel || actionType.label === nameOrLabel) {
|
|
37
|
+
return actionType;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Then try case-insensitive match
|
|
41
|
+
const lowerSearch = nameOrLabel.toLowerCase();
|
|
42
|
+
for (const [_, actionType] of this.actionTypesCache) {
|
|
43
|
+
if (actionType.name.toLowerCase() === lowerSearch ||
|
|
44
|
+
actionType.label.toLowerCase() === lowerSearch) {
|
|
45
|
+
return actionType;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Finally try partial match
|
|
49
|
+
for (const [_, actionType] of this.actionTypesCache) {
|
|
50
|
+
if (actionType.name.toLowerCase().includes(lowerSearch) ||
|
|
51
|
+
actionType.label.toLowerCase().includes(lowerSearch)) {
|
|
52
|
+
return actionType;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get trigger type by name or label
|
|
59
|
+
*/
|
|
60
|
+
async getTriggerType(nameOrLabel) {
|
|
61
|
+
await this.ensureCache();
|
|
62
|
+
// Map common names to actual trigger names
|
|
63
|
+
const triggerMap = {
|
|
64
|
+
'record_created': 'Created',
|
|
65
|
+
'record_updated': 'Updated',
|
|
66
|
+
'record_deleted': 'Deleted',
|
|
67
|
+
'created_or_updated': 'Created or Updated',
|
|
68
|
+
'scheduled': 'Scheduled',
|
|
69
|
+
'manual': 'Manual'
|
|
70
|
+
};
|
|
71
|
+
const searchName = triggerMap[nameOrLabel] || nameOrLabel;
|
|
72
|
+
// Try exact match
|
|
73
|
+
for (const [_, triggerType] of this.triggerTypesCache) {
|
|
74
|
+
if (triggerType.name === searchName || triggerType.label === searchName) {
|
|
75
|
+
return triggerType;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Try case-insensitive match
|
|
79
|
+
const lowerSearch = searchName.toLowerCase();
|
|
80
|
+
for (const [_, triggerType] of this.triggerTypesCache) {
|
|
81
|
+
if (triggerType.name.toLowerCase() === lowerSearch ||
|
|
82
|
+
triggerType.label.toLowerCase() === lowerSearch) {
|
|
83
|
+
return triggerType;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Ensure cache is loaded
|
|
90
|
+
*/
|
|
91
|
+
async ensureCache() {
|
|
92
|
+
if (this.cacheLoaded)
|
|
93
|
+
return;
|
|
94
|
+
// Try to load from file cache first
|
|
95
|
+
if (this.loadFromFile()) {
|
|
96
|
+
this.cacheLoaded = true;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
// Otherwise fetch from ServiceNow
|
|
100
|
+
await this.refreshCache();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Load cache from file
|
|
104
|
+
*/
|
|
105
|
+
loadFromFile() {
|
|
106
|
+
try {
|
|
107
|
+
const actionTypesFile = path_1.default.join(this.cacheDir, 'action_types.json');
|
|
108
|
+
const triggerTypesFile = path_1.default.join(this.cacheDir, 'trigger_types.json');
|
|
109
|
+
if (fs_1.default.existsSync(actionTypesFile) && fs_1.default.existsSync(triggerTypesFile)) {
|
|
110
|
+
const actionTypes = JSON.parse(fs_1.default.readFileSync(actionTypesFile, 'utf-8'));
|
|
111
|
+
const triggerTypes = JSON.parse(fs_1.default.readFileSync(triggerTypesFile, 'utf-8'));
|
|
112
|
+
// Check if cache is recent (less than 24 hours old)
|
|
113
|
+
const stats = fs_1.default.statSync(actionTypesFile);
|
|
114
|
+
const ageInHours = (Date.now() - stats.mtime.getTime()) / (1000 * 60 * 60);
|
|
115
|
+
if (ageInHours < 24) {
|
|
116
|
+
// Load into memory
|
|
117
|
+
actionTypes.forEach((at) => {
|
|
118
|
+
this.actionTypesCache.set(at.sys_id, at);
|
|
119
|
+
});
|
|
120
|
+
triggerTypes.forEach((tt) => {
|
|
121
|
+
this.triggerTypesCache.set(tt.sys_id, tt);
|
|
122
|
+
});
|
|
123
|
+
this.logger.info(`Loaded ${actionTypes.length} action types and ${triggerTypes.length} trigger types from cache`);
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
this.logger.warn('Failed to load cache from file:', error);
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Save cache to file
|
|
135
|
+
*/
|
|
136
|
+
saveToFile() {
|
|
137
|
+
try {
|
|
138
|
+
const actionTypesFile = path_1.default.join(this.cacheDir, 'action_types.json');
|
|
139
|
+
const triggerTypesFile = path_1.default.join(this.cacheDir, 'trigger_types.json');
|
|
140
|
+
const actionTypes = Array.from(this.actionTypesCache.values());
|
|
141
|
+
const triggerTypes = Array.from(this.triggerTypesCache.values());
|
|
142
|
+
fs_1.default.writeFileSync(actionTypesFile, JSON.stringify(actionTypes, null, 2));
|
|
143
|
+
fs_1.default.writeFileSync(triggerTypesFile, JSON.stringify(triggerTypes, null, 2));
|
|
144
|
+
this.logger.info('Saved cache to file');
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
this.logger.warn('Failed to save cache to file:', error);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Refresh cache from ServiceNow
|
|
152
|
+
*/
|
|
153
|
+
async refreshCache() {
|
|
154
|
+
this.logger.info('Refreshing action type cache from ServiceNow...');
|
|
155
|
+
try {
|
|
156
|
+
// Fetch all action types
|
|
157
|
+
const actionTypesResponse = await this.client.getRecords('sys_hub_action_type_base', {
|
|
158
|
+
sysparm_limit: 1000,
|
|
159
|
+
sysparm_fields: 'sys_id,name,label,category,active',
|
|
160
|
+
sysparm_query: 'active=true'
|
|
161
|
+
});
|
|
162
|
+
if (actionTypesResponse.success && actionTypesResponse.data) {
|
|
163
|
+
this.actionTypesCache.clear();
|
|
164
|
+
actionTypesResponse.data.forEach((at) => {
|
|
165
|
+
this.actionTypesCache.set(at.sys_id, {
|
|
166
|
+
sys_id: at.sys_id,
|
|
167
|
+
name: at.name,
|
|
168
|
+
label: at.label || at.name,
|
|
169
|
+
category: at.category
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
this.logger.info(`Cached ${actionTypesResponse.data.length} action types`);
|
|
173
|
+
}
|
|
174
|
+
// Fetch all trigger types
|
|
175
|
+
const triggerTypesResponse = await this.client.getRecords('sys_hub_trigger_type', {
|
|
176
|
+
sysparm_limit: 100,
|
|
177
|
+
sysparm_fields: 'sys_id,name,label,table_name'
|
|
178
|
+
});
|
|
179
|
+
if (triggerTypesResponse.success && triggerTypesResponse.data) {
|
|
180
|
+
this.triggerTypesCache.clear();
|
|
181
|
+
triggerTypesResponse.data.forEach((tt) => {
|
|
182
|
+
this.triggerTypesCache.set(tt.sys_id, {
|
|
183
|
+
sys_id: tt.sys_id,
|
|
184
|
+
name: tt.name,
|
|
185
|
+
label: tt.label || tt.name,
|
|
186
|
+
table_name: tt.table_name
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
this.logger.info(`Cached ${triggerTypesResponse.data.length} trigger types`);
|
|
190
|
+
}
|
|
191
|
+
// Save to file
|
|
192
|
+
this.saveToFile();
|
|
193
|
+
this.cacheLoaded = true;
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
this.logger.error('Failed to refresh cache:', error);
|
|
197
|
+
// Try to continue with empty cache
|
|
198
|
+
this.cacheLoaded = true;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Get all action types (for debugging/listing)
|
|
203
|
+
*/
|
|
204
|
+
async getAllActionTypes() {
|
|
205
|
+
await this.ensureCache();
|
|
206
|
+
return Array.from(this.actionTypesCache.values());
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Get all trigger types (for debugging/listing)
|
|
210
|
+
*/
|
|
211
|
+
async getAllTriggerTypes() {
|
|
212
|
+
await this.ensureCache();
|
|
213
|
+
return Array.from(this.triggerTypesCache.values());
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Clear cache (force refresh on next access)
|
|
217
|
+
*/
|
|
218
|
+
clearCache() {
|
|
219
|
+
this.actionTypesCache.clear();
|
|
220
|
+
this.triggerTypesCache.clear();
|
|
221
|
+
this.cacheLoaded = false;
|
|
222
|
+
// Also remove cache files
|
|
223
|
+
try {
|
|
224
|
+
const actionTypesFile = path_1.default.join(this.cacheDir, 'action_types.json');
|
|
225
|
+
const triggerTypesFile = path_1.default.join(this.cacheDir, 'trigger_types.json');
|
|
226
|
+
if (fs_1.default.existsSync(actionTypesFile))
|
|
227
|
+
fs_1.default.unlinkSync(actionTypesFile);
|
|
228
|
+
if (fs_1.default.existsSync(triggerTypesFile))
|
|
229
|
+
fs_1.default.unlinkSync(triggerTypesFile);
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
// Ignore errors
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.ActionTypeCache = ActionTypeCache;
|
|
237
|
+
//# sourceMappingURL=action-type-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-type-cache.js","sourceRoot":"","sources":["../../src/utils/action-type-cache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,4CAAoB;AACpB,gDAAwB;AAExB,2CAAqC;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IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB;QACtB,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QAEzB,0BAA0B;QAC1B,IAAI,CAAC;YACH,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;YACtE,MAAM,gBAAgB,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;YAExE,IAAI,YAAE,CAAC,UAAU,CAAC,eAAe,CAAC;gBAAE,YAAE,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;YACnE,IAAI,YAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC;gBAAE,YAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;QACvE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,gBAAgB;QAClB,CAAC;IACH,CAAC;CACF;AAlQD,0CAkQC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intelligent Agent Detection System
|
|
3
|
+
* Dynamically determines which agents to spawn based on task analysis
|
|
4
|
+
*/
|
|
5
|
+
export interface AgentCapability {
|
|
6
|
+
type: string;
|
|
7
|
+
confidence: number;
|
|
8
|
+
requiredFor: string[];
|
|
9
|
+
description: string;
|
|
10
|
+
}
|
|
11
|
+
export interface TaskAnalysis {
|
|
12
|
+
primaryAgent: string;
|
|
13
|
+
supportingAgents: string[];
|
|
14
|
+
complexity: 'simple' | 'medium' | 'complex';
|
|
15
|
+
estimatedAgentCount: number;
|
|
16
|
+
requiresUpdateSet: boolean;
|
|
17
|
+
requiresApplication: boolean;
|
|
18
|
+
taskType: string;
|
|
19
|
+
serviceNowArtifacts: string[];
|
|
20
|
+
}
|
|
21
|
+
export declare class AgentDetector {
|
|
22
|
+
private static readonly AGENT_PATTERNS;
|
|
23
|
+
private static readonly SERVICENOW_ARTIFACTS;
|
|
24
|
+
static analyzeTask(objective: string): TaskAnalysis;
|
|
25
|
+
private static detectAgentCapabilities;
|
|
26
|
+
private static determinePrimaryAgent;
|
|
27
|
+
private static determineSupportingAgents;
|
|
28
|
+
private static assessComplexity;
|
|
29
|
+
private static detectServiceNowArtifacts;
|
|
30
|
+
private static requiresUpdateSet;
|
|
31
|
+
private static requiresApplication;
|
|
32
|
+
private static determineTaskType;
|
|
33
|
+
static generateAgentPrompt(agentType: string, objective: string, analysis: TaskAnalysis): string;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=agent-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-detector.d.ts","sourceRoot":"","sources":["../../src/utils/agent-detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,UAAU,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC5C,mBAAmB,EAAE,MAAM,CAAC;IAC5B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAqEpC;IAEF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAY1C;IAEF,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY;IAwCnD,OAAO,CAAC,MAAM,CAAC,uBAAuB;IA2BtC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAepC,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAoBxC,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAiB/B,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAmCxC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA2BhC,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAWlC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAyBhC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,MAAM;CAsFjG"}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Intelligent Agent Detection System
|
|
4
|
+
* Dynamically determines which agents to spawn based on task analysis
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.AgentDetector = void 0;
|
|
8
|
+
class AgentDetector {
|
|
9
|
+
static analyzeTask(objective) {
|
|
10
|
+
const lowerObjective = objective.toLowerCase();
|
|
11
|
+
const words = lowerObjective.split(/\s+/);
|
|
12
|
+
// Detect agent capabilities
|
|
13
|
+
const agentCapabilities = this.detectAgentCapabilities(lowerObjective);
|
|
14
|
+
// Determine primary agent
|
|
15
|
+
const primaryAgent = this.determinePrimaryAgent(agentCapabilities);
|
|
16
|
+
// Determine supporting agents
|
|
17
|
+
const supportingAgents = this.determineSupportingAgents(agentCapabilities, primaryAgent);
|
|
18
|
+
// Assess complexity
|
|
19
|
+
const complexity = this.assessComplexity(objective, agentCapabilities);
|
|
20
|
+
// Determine ServiceNow artifacts
|
|
21
|
+
const serviceNowArtifacts = this.detectServiceNowArtifacts(lowerObjective);
|
|
22
|
+
// Determine if Update Set is required
|
|
23
|
+
const requiresUpdateSet = this.requiresUpdateSet(lowerObjective, serviceNowArtifacts);
|
|
24
|
+
// Determine if new Application is required
|
|
25
|
+
const requiresApplication = this.requiresApplication(lowerObjective, serviceNowArtifacts);
|
|
26
|
+
// Determine task type
|
|
27
|
+
const taskType = this.determineTaskType(lowerObjective, serviceNowArtifacts);
|
|
28
|
+
return {
|
|
29
|
+
primaryAgent,
|
|
30
|
+
supportingAgents,
|
|
31
|
+
complexity,
|
|
32
|
+
estimatedAgentCount: Math.min(Math.max(supportingAgents.length + 1, 2), 8),
|
|
33
|
+
requiresUpdateSet,
|
|
34
|
+
requiresApplication,
|
|
35
|
+
taskType,
|
|
36
|
+
serviceNowArtifacts
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
static detectAgentCapabilities(objective) {
|
|
40
|
+
const capabilities = [];
|
|
41
|
+
for (const [agentType, config] of Object.entries(this.AGENT_PATTERNS)) {
|
|
42
|
+
let matchCount = 0;
|
|
43
|
+
let totalKeywords = config.keywords.length;
|
|
44
|
+
for (const keyword of config.keywords) {
|
|
45
|
+
if (objective.includes(keyword)) {
|
|
46
|
+
matchCount++;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (matchCount > 0) {
|
|
50
|
+
const confidence = (matchCount / totalKeywords) * config.confidence;
|
|
51
|
+
capabilities.push({
|
|
52
|
+
type: agentType,
|
|
53
|
+
confidence,
|
|
54
|
+
requiredFor: config.requiredFor,
|
|
55
|
+
description: config.description
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return capabilities.sort((a, b) => b.confidence - a.confidence);
|
|
60
|
+
}
|
|
61
|
+
static determinePrimaryAgent(capabilities) {
|
|
62
|
+
if (capabilities.length === 0)
|
|
63
|
+
return 'orchestrator';
|
|
64
|
+
// Special logic for ServiceNow-specific tasks
|
|
65
|
+
const serviceNowAgents = capabilities.filter(c => ['flow_designer', 'widget_builder', 'integration_specialist', 'database_expert'].includes(c.type));
|
|
66
|
+
if (serviceNowAgents.length > 0) {
|
|
67
|
+
return serviceNowAgents[0].type;
|
|
68
|
+
}
|
|
69
|
+
return capabilities[0].type;
|
|
70
|
+
}
|
|
71
|
+
static determineSupportingAgents(capabilities, primaryAgent) {
|
|
72
|
+
const supportingAgents = capabilities
|
|
73
|
+
.filter(c => c.type !== primaryAgent && c.confidence > 0.3)
|
|
74
|
+
.slice(0, 5) // Max 5 supporting agents
|
|
75
|
+
.map(c => c.type);
|
|
76
|
+
// Always include orchestrator for complex tasks
|
|
77
|
+
if (capabilities.length > 3 && !supportingAgents.includes('orchestrator')) {
|
|
78
|
+
supportingAgents.push('orchestrator');
|
|
79
|
+
}
|
|
80
|
+
// Always include tester for development tasks
|
|
81
|
+
const developmentAgents = ['coder', 'architect', 'flow_designer', 'widget_builder'];
|
|
82
|
+
if (developmentAgents.includes(primaryAgent) && !supportingAgents.includes('tester')) {
|
|
83
|
+
supportingAgents.push('tester');
|
|
84
|
+
}
|
|
85
|
+
return supportingAgents;
|
|
86
|
+
}
|
|
87
|
+
static assessComplexity(objective, capabilities) {
|
|
88
|
+
const wordCount = objective.split(/\s+/).length;
|
|
89
|
+
const agentCount = capabilities.length;
|
|
90
|
+
// Complex indicators
|
|
91
|
+
const complexKeywords = ['integrate', 'multiple', 'complex', 'advanced', 'system', 'architecture', 'enterprise'];
|
|
92
|
+
const hasComplexKeywords = complexKeywords.some(keyword => objective.toLowerCase().includes(keyword));
|
|
93
|
+
if (wordCount > 20 || agentCount > 4 || hasComplexKeywords) {
|
|
94
|
+
return 'complex';
|
|
95
|
+
}
|
|
96
|
+
else if (wordCount > 10 || agentCount > 2) {
|
|
97
|
+
return 'medium';
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
return 'simple';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
static detectServiceNowArtifacts(objective) {
|
|
104
|
+
const artifacts = [];
|
|
105
|
+
const lowerObjective = objective.toLowerCase();
|
|
106
|
+
// Check for explicit artifact mentions
|
|
107
|
+
for (const [artifact, _] of Object.entries(this.SERVICENOW_ARTIFACTS)) {
|
|
108
|
+
if (lowerObjective.includes(artifact)) {
|
|
109
|
+
artifacts.push(artifact);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Check for business rule specifically
|
|
113
|
+
if (lowerObjective.includes('business rule') || lowerObjective.includes('business_rule')) {
|
|
114
|
+
if (!artifacts.includes('business_rule')) {
|
|
115
|
+
artifacts.push('business_rule');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Check for script include
|
|
119
|
+
if (lowerObjective.includes('script include') || lowerObjective.includes('script_include')) {
|
|
120
|
+
if (!artifacts.includes('script')) {
|
|
121
|
+
artifacts.push('script');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Check for client script
|
|
125
|
+
if (lowerObjective.includes('client script') || lowerObjective.includes('client_script')) {
|
|
126
|
+
if (!artifacts.includes('script')) {
|
|
127
|
+
artifacts.push('script');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return artifacts;
|
|
131
|
+
}
|
|
132
|
+
static requiresUpdateSet(objective, artifacts) {
|
|
133
|
+
const lowerObjective = objective.toLowerCase();
|
|
134
|
+
// Always require Update Set for development tasks
|
|
135
|
+
const developmentKeywords = [
|
|
136
|
+
'create', 'build', 'implement', 'develop', 'make', 'generate', 'add',
|
|
137
|
+
'bouw', 'maak', 'schrijf', 'write', 'update', 'modify', 'change',
|
|
138
|
+
'business rule', 'script', 'flow', 'widget', 'workflow', 'client script',
|
|
139
|
+
'ui action', 'scheduled job', 'transform', 'integration'
|
|
140
|
+
];
|
|
141
|
+
const hasDevelopmentKeywords = developmentKeywords.some(keyword => lowerObjective.includes(keyword));
|
|
142
|
+
// Or if ServiceNow artifacts are involved
|
|
143
|
+
const hasServiceNowArtifacts = artifacts.length > 0;
|
|
144
|
+
// Or if task type indicates development
|
|
145
|
+
const developmentTaskTypes = [
|
|
146
|
+
'widget_development', 'flow_development', 'script_development',
|
|
147
|
+
'application_development', 'integration_development', 'database_development',
|
|
148
|
+
'reporting_development', 'general_development'
|
|
149
|
+
];
|
|
150
|
+
const taskType = this.determineTaskType(objective, artifacts);
|
|
151
|
+
const isDevelopmentTask = developmentTaskTypes.includes(taskType);
|
|
152
|
+
return hasDevelopmentKeywords || hasServiceNowArtifacts || isDevelopmentTask;
|
|
153
|
+
}
|
|
154
|
+
static requiresApplication(objective, artifacts) {
|
|
155
|
+
// Require new application for comprehensive systems
|
|
156
|
+
const applicationKeywords = ['application', 'app', 'system', 'complete', 'full', 'comprehensive', 'applicatie'];
|
|
157
|
+
const hasApplicationKeywords = applicationKeywords.some(keyword => objective.toLowerCase().includes(keyword));
|
|
158
|
+
// Or if multiple complex artifacts are involved
|
|
159
|
+
const hasMultipleArtifacts = artifacts.length >= 3;
|
|
160
|
+
return hasApplicationKeywords || hasMultipleArtifacts;
|
|
161
|
+
}
|
|
162
|
+
static determineTaskType(objective, artifacts) {
|
|
163
|
+
// Determine based on detected artifacts and keywords
|
|
164
|
+
if (artifacts.includes('widget'))
|
|
165
|
+
return 'widget_development';
|
|
166
|
+
if (artifacts.includes('flow') || artifacts.includes('workflow'))
|
|
167
|
+
return 'flow_development';
|
|
168
|
+
if (artifacts.includes('application'))
|
|
169
|
+
return 'application_development';
|
|
170
|
+
if (artifacts.includes('script') || artifacts.includes('business_rule'))
|
|
171
|
+
return 'script_development';
|
|
172
|
+
if (artifacts.includes('integration') || artifacts.includes('api'))
|
|
173
|
+
return 'integration_development';
|
|
174
|
+
if (artifacts.includes('table') || artifacts.includes('database'))
|
|
175
|
+
return 'database_development';
|
|
176
|
+
if (artifacts.includes('report') || artifacts.includes('dashboard'))
|
|
177
|
+
return 'reporting_development';
|
|
178
|
+
// Fallback to general development
|
|
179
|
+
const developmentKeywords = ['create', 'build', 'implement', 'develop', 'make', 'generate', 'bouw', 'maak'];
|
|
180
|
+
const hasDevelopmentKeywords = developmentKeywords.some(keyword => objective.toLowerCase().includes(keyword));
|
|
181
|
+
if (hasDevelopmentKeywords)
|
|
182
|
+
return 'general_development';
|
|
183
|
+
// Research or analysis tasks
|
|
184
|
+
const researchKeywords = ['research', 'analyze', 'investigate', 'study', 'explore'];
|
|
185
|
+
const hasResearchKeywords = researchKeywords.some(keyword => objective.toLowerCase().includes(keyword));
|
|
186
|
+
if (hasResearchKeywords)
|
|
187
|
+
return 'research_task';
|
|
188
|
+
return 'orchestration_task';
|
|
189
|
+
}
|
|
190
|
+
static generateAgentPrompt(agentType, objective, analysis) {
|
|
191
|
+
const agentConfig = this.AGENT_PATTERNS[agentType];
|
|
192
|
+
const basePrompt = `You are a specialized ${agentType} agent in a ServiceNow multi-agent development swarm.
|
|
193
|
+
|
|
194
|
+
🎯 **Your Role**: ${agentConfig?.description || 'Specialized agent'}
|
|
195
|
+
|
|
196
|
+
🔍 **Task Context**: ${objective}
|
|
197
|
+
|
|
198
|
+
🏗️ **Project Setup**:
|
|
199
|
+
${analysis.requiresUpdateSet ? '- ✅ Update Set will be automatically created' : '- ⚠️ No Update Set required'}
|
|
200
|
+
${analysis.requiresApplication ? '- ✅ New Application will be automatically created' : '- ⚠️ Using existing application context'}
|
|
201
|
+
|
|
202
|
+
🤖 **Team Coordination**:
|
|
203
|
+
- Primary Agent: ${analysis.primaryAgent}
|
|
204
|
+
- Supporting Agents: ${analysis.supportingAgents.join(', ')}
|
|
205
|
+
- Task Complexity: ${analysis.complexity}
|
|
206
|
+
- ServiceNow Artifacts: ${analysis.serviceNowArtifacts.join(', ')}
|
|
207
|
+
|
|
208
|
+
📋 **Your Responsibilities**:`;
|
|
209
|
+
// Add agent-specific responsibilities
|
|
210
|
+
switch (agentType) {
|
|
211
|
+
case 'architect':
|
|
212
|
+
return basePrompt + `
|
|
213
|
+
- Design system architecture and data models
|
|
214
|
+
- Define relationships between ServiceNow components
|
|
215
|
+
- Create technical specifications
|
|
216
|
+
- Ensure scalability and best practices
|
|
217
|
+
- Coordinate with other agents on implementation approach`;
|
|
218
|
+
case 'coder':
|
|
219
|
+
return basePrompt + `
|
|
220
|
+
- Implement code based on architectural designs
|
|
221
|
+
- Write ServiceNow scripts, business rules, and functions
|
|
222
|
+
- Ensure code quality and maintainability
|
|
223
|
+
- Follow ServiceNow development best practices
|
|
224
|
+
- Collaborate with testers on code validation`;
|
|
225
|
+
case 'flow_designer':
|
|
226
|
+
return basePrompt + `
|
|
227
|
+
- Design and implement ServiceNow flows and workflows
|
|
228
|
+
- Configure approval processes and routing logic
|
|
229
|
+
- Set up triggers and conditions
|
|
230
|
+
- Ensure proper integration with other system components
|
|
231
|
+
- Test flow execution and error handling`;
|
|
232
|
+
case 'widget_builder':
|
|
233
|
+
return basePrompt + `
|
|
234
|
+
- Design and implement Service Portal widgets
|
|
235
|
+
- Create HTML templates and CSS styling
|
|
236
|
+
- Develop client-side and server-side scripts
|
|
237
|
+
- Ensure responsive design and accessibility
|
|
238
|
+
- Integrate with ServiceNow APIs and data sources`;
|
|
239
|
+
case 'tester':
|
|
240
|
+
return basePrompt + `
|
|
241
|
+
- Develop and execute test plans
|
|
242
|
+
- Validate functionality and performance
|
|
243
|
+
- Identify and report bugs and issues
|
|
244
|
+
- Ensure quality standards are met
|
|
245
|
+
- Coordinate with development agents on fixes`;
|
|
246
|
+
case 'researcher':
|
|
247
|
+
return basePrompt + `
|
|
248
|
+
- Research ServiceNow best practices and patterns
|
|
249
|
+
- Analyze requirements and gather information
|
|
250
|
+
- Provide insights and recommendations
|
|
251
|
+
- Study existing implementations and solutions
|
|
252
|
+
- Document findings and share knowledge`;
|
|
253
|
+
case 'orchestrator':
|
|
254
|
+
return basePrompt + `
|
|
255
|
+
- Coordinate activities between all agents
|
|
256
|
+
- Manage task priorities and dependencies
|
|
257
|
+
- Ensure project timeline and milestones
|
|
258
|
+
- Facilitate communication and collaboration
|
|
259
|
+
- Monitor progress and address blockers`;
|
|
260
|
+
default:
|
|
261
|
+
return basePrompt + `
|
|
262
|
+
- Provide specialized expertise in your domain
|
|
263
|
+
- Collaborate effectively with other agents
|
|
264
|
+
- Ensure quality and best practices
|
|
265
|
+
- Contribute to overall project success`;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
exports.AgentDetector = AgentDetector;
|
|
270
|
+
AgentDetector.AGENT_PATTERNS = {
|
|
271
|
+
// Development agents
|
|
272
|
+
architect: {
|
|
273
|
+
keywords: ['design', 'architecture', 'structure', 'database', 'schema', 'model', 'entity', 'relationship', 'system'],
|
|
274
|
+
confidence: 0.9,
|
|
275
|
+
description: 'System architecture and design',
|
|
276
|
+
requiredFor: ['applications', 'complex_systems', 'integrations']
|
|
277
|
+
},
|
|
278
|
+
coder: {
|
|
279
|
+
keywords: ['implement', 'code', 'script', 'function', 'api', 'endpoint', 'logic', 'algorithm', 'business_rule', 'schrijf', 'write', 'develop', 'programmeer'],
|
|
280
|
+
confidence: 0.8,
|
|
281
|
+
description: 'Code implementation and development',
|
|
282
|
+
requiredFor: ['scripts', 'functions', 'business_rules', 'apis']
|
|
283
|
+
},
|
|
284
|
+
researcher: {
|
|
285
|
+
keywords: ['research', 'analyze', 'investigate', 'study', 'explore', 'understand', 'learn', 'discover'],
|
|
286
|
+
confidence: 0.7,
|
|
287
|
+
description: 'Research and analysis',
|
|
288
|
+
requiredFor: ['requirements', 'best_practices', 'patterns']
|
|
289
|
+
},
|
|
290
|
+
tester: {
|
|
291
|
+
keywords: ['test', 'verify', 'validate', 'check', 'ensure', 'quality', 'bug', 'debug'],
|
|
292
|
+
confidence: 0.8,
|
|
293
|
+
description: 'Testing and quality assurance',
|
|
294
|
+
requiredFor: ['validation', 'quality_control', 'debugging']
|
|
295
|
+
},
|
|
296
|
+
reviewer: {
|
|
297
|
+
keywords: ['review', 'audit', 'examine', 'evaluate', 'assess', 'approve', 'feedback'],
|
|
298
|
+
confidence: 0.7,
|
|
299
|
+
description: 'Code and process review',
|
|
300
|
+
requiredFor: ['code_review', 'approval_process', 'quality_gates']
|
|
301
|
+
},
|
|
302
|
+
documenter: {
|
|
303
|
+
keywords: ['document', 'documentation', 'guide', 'manual', 'readme', 'help', 'instructions'],
|
|
304
|
+
confidence: 0.6,
|
|
305
|
+
description: 'Documentation and guides',
|
|
306
|
+
requiredFor: ['documentation', 'user_guides', 'api_docs']
|
|
307
|
+
},
|
|
308
|
+
orchestrator: {
|
|
309
|
+
keywords: ['coordinate', 'manage', 'orchestrate', 'organize', 'plan', 'schedule', 'oversee'],
|
|
310
|
+
confidence: 0.9,
|
|
311
|
+
description: 'Task coordination and management',
|
|
312
|
+
requiredFor: ['complex_tasks', 'multi_agent_coordination', 'project_management']
|
|
313
|
+
},
|
|
314
|
+
// ServiceNow specific agents
|
|
315
|
+
flow_designer: {
|
|
316
|
+
keywords: ['flow', 'workflow', 'process', 'automation', 'approval', 'routing', 'trigger'],
|
|
317
|
+
confidence: 0.9,
|
|
318
|
+
description: 'ServiceNow Flow Designer specialist',
|
|
319
|
+
requiredFor: ['flows', 'workflows', 'approvals', 'automation']
|
|
320
|
+
},
|
|
321
|
+
widget_builder: {
|
|
322
|
+
keywords: ['widget', 'portal', 'dashboard', 'ui', 'interface', 'frontend', 'display'],
|
|
323
|
+
confidence: 0.9,
|
|
324
|
+
description: 'Service Portal widget development',
|
|
325
|
+
requiredFor: ['widgets', 'portals', 'dashboards', 'ui_components']
|
|
326
|
+
},
|
|
327
|
+
integration_specialist: {
|
|
328
|
+
keywords: ['integration', 'api', 'rest', 'soap', 'webhook', 'external', 'third_party'],
|
|
329
|
+
confidence: 0.8,
|
|
330
|
+
description: 'System integration and APIs',
|
|
331
|
+
requiredFor: ['integrations', 'apis', 'webhooks', 'external_systems']
|
|
332
|
+
},
|
|
333
|
+
database_expert: {
|
|
334
|
+
keywords: ['database', 'table', 'field', 'record', 'data', 'schema', 'query', 'report'],
|
|
335
|
+
confidence: 0.8,
|
|
336
|
+
description: 'Database and data management',
|
|
337
|
+
requiredFor: ['tables', 'databases', 'reports', 'data_management']
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
AgentDetector.SERVICENOW_ARTIFACTS = {
|
|
341
|
+
'widget': ['widget_builder', 'coder', 'tester'],
|
|
342
|
+
'flow': ['flow_designer', 'architect', 'tester'],
|
|
343
|
+
'workflow': ['flow_designer', 'architect', 'tester'],
|
|
344
|
+
'application': ['architect', 'coder', 'database_expert', 'tester', 'documenter'],
|
|
345
|
+
'script': ['coder', 'reviewer', 'tester'],
|
|
346
|
+
'business_rule': ['coder', 'reviewer', 'tester'],
|
|
347
|
+
'integration': ['integration_specialist', 'architect', 'tester'],
|
|
348
|
+
'api': ['integration_specialist', 'coder', 'tester'],
|
|
349
|
+
'table': ['database_expert', 'architect', 'coder'],
|
|
350
|
+
'report': ['database_expert', 'analyst', 'coder'],
|
|
351
|
+
'dashboard': ['widget_builder', 'database_expert', 'coder']
|
|
352
|
+
};
|
|
353
|
+
//# sourceMappingURL=agent-detector.js.map
|