snow-flow 8.40.1 → 8.40.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_get_current_scope.d.ts +14 -0
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_get_current_scope.d.ts.map +1 -0
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_get_current_scope.js +220 -0
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_get_current_scope.js.map +1 -0
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_list_applications.d.ts +12 -0
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_list_applications.d.ts.map +1 -0
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_list_applications.js +236 -0
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_list_applications.js.map +1 -0
- package/dist/mcp/servicenow-mcp-unified/tools/automation/index.d.ts +1 -3
- package/dist/mcp/servicenow-mcp-unified/tools/automation/index.d.ts.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/automation/index.js +5 -10
- package/dist/mcp/servicenow-mcp-unified/tools/automation/index.js.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_confirm_script_execution.d.ts +7 -5
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_confirm_script_execution.d.ts.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_confirm_script_execution.js +195 -34
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_confirm_script_execution.js.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_script.d.ts +20 -0
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_script.d.ts.map +1 -0
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_script.js +474 -0
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_script.js.map +1 -0
- package/dist/mcp/servicenow-mcp-unified/tools/deployment/snow_create_artifact.d.ts.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/deployment/snow_create_artifact.js +7 -1
- package/dist/mcp/servicenow-mcp-unified/tools/deployment/snow_create_artifact.js.map +1 -1
- package/dist/templates/agents-md-template.d.ts +1 -1
- package/dist/templates/agents-md-template.d.ts.map +1 -1
- package/dist/templates/agents-md-template.js +4 -4
- package/dist/templates/claude-md-template.d.ts +1 -1
- package/dist/templates/claude-md-template.d.ts.map +1 -1
- package/dist/templates/claude-md-template.js +17 -12
- package/dist/templates/claude-md-template.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* snow_execute_script - Unified script execution tool
|
|
4
|
+
*
|
|
5
|
+
* Executes server-side JavaScript in ServiceNow with comprehensive output capture.
|
|
6
|
+
* Combines functionality of:
|
|
7
|
+
* - snow_execute_script_sync (deprecated)
|
|
8
|
+
* - snow_execute_script_with_output (deprecated)
|
|
9
|
+
* - snow_execute_background_script (deprecated)
|
|
10
|
+
*
|
|
11
|
+
* Uses sysauto_script + sys_trigger approach for reliable execution.
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ CRITICAL: ALL SCRIPTS MUST BE ES5 ONLY!
|
|
14
|
+
* ServiceNow runs on Rhino engine - no const/let/arrow functions/template literals.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.author = exports.version = exports.toolDefinition = void 0;
|
|
18
|
+
exports.execute = execute;
|
|
19
|
+
const auth_js_1 = require("../../shared/auth.js");
|
|
20
|
+
const error_handler_js_1 = require("../../shared/error-handler.js");
|
|
21
|
+
exports.toolDefinition = {
|
|
22
|
+
name: 'snow_execute_script',
|
|
23
|
+
description: 'Execute server-side JavaScript in ServiceNow with output capture (ES5 only). Replaces snow_execute_script_sync, snow_execute_script_with_output, and snow_execute_background_script.',
|
|
24
|
+
// Metadata for tool discovery (not sent to LLM)
|
|
25
|
+
category: 'automation',
|
|
26
|
+
subcategory: 'script-execution',
|
|
27
|
+
use_cases: ['automation', 'scripts', 'execution', 'debugging', 'verification'],
|
|
28
|
+
complexity: 'advanced',
|
|
29
|
+
frequency: 'high',
|
|
30
|
+
// Permission enforcement
|
|
31
|
+
permission: 'write',
|
|
32
|
+
allowedRoles: ['developer', 'admin'],
|
|
33
|
+
inputSchema: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
script: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
description: '🚨 ES5 ONLY! JavaScript code to execute (no const/let/arrows/templates - Rhino engine)'
|
|
39
|
+
},
|
|
40
|
+
description: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
description: 'Clear description of what the script does (required if requireConfirmation=true)'
|
|
43
|
+
},
|
|
44
|
+
scope: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
description: 'Scope to execute in',
|
|
47
|
+
default: 'global',
|
|
48
|
+
enum: ['global', 'rhino']
|
|
49
|
+
},
|
|
50
|
+
timeout: {
|
|
51
|
+
type: 'number',
|
|
52
|
+
description: 'Timeout in milliseconds for polling execution results',
|
|
53
|
+
default: 30000
|
|
54
|
+
},
|
|
55
|
+
validate_es5: {
|
|
56
|
+
type: 'boolean',
|
|
57
|
+
description: 'Validate ES5 syntax before execution',
|
|
58
|
+
default: true
|
|
59
|
+
},
|
|
60
|
+
requireConfirmation: {
|
|
61
|
+
type: 'boolean',
|
|
62
|
+
description: 'Require user confirmation before execution (shows security analysis)',
|
|
63
|
+
default: false
|
|
64
|
+
},
|
|
65
|
+
autoConfirm: {
|
|
66
|
+
type: 'boolean',
|
|
67
|
+
description: '⚠️ DANGEROUS: Skip user confirmation even if requireConfirmation would normally be required',
|
|
68
|
+
default: false
|
|
69
|
+
},
|
|
70
|
+
allowDataModification: {
|
|
71
|
+
type: 'boolean',
|
|
72
|
+
description: 'Whether script is allowed to modify data (for security analysis)',
|
|
73
|
+
default: false
|
|
74
|
+
},
|
|
75
|
+
runAsUser: {
|
|
76
|
+
type: 'string',
|
|
77
|
+
description: 'User to execute script as (optional, defaults to current user)'
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
required: ['script']
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
async function execute(args, context) {
|
|
84
|
+
const { script, description = 'Script execution via snow_execute_script', scope = 'global', timeout = 30000, validate_es5 = true, requireConfirmation = false, autoConfirm = false, allowDataModification = false, runAsUser } = args;
|
|
85
|
+
try {
|
|
86
|
+
// ES5 validation
|
|
87
|
+
if (validate_es5) {
|
|
88
|
+
const es5Validation = validateES5(script);
|
|
89
|
+
if (!es5Validation.valid) {
|
|
90
|
+
throw new error_handler_js_1.SnowFlowError(error_handler_js_1.ErrorType.ES5_SYNTAX_ERROR, 'Script contains non-ES5 syntax', {
|
|
91
|
+
retryable: false,
|
|
92
|
+
details: {
|
|
93
|
+
violations: es5Validation.violations,
|
|
94
|
+
message: 'ServiceNow uses Rhino engine - ES6+ syntax will fail'
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Security analysis
|
|
100
|
+
const securityAnalysis = analyzeScriptSecurity(script);
|
|
101
|
+
// Check if confirmation is needed
|
|
102
|
+
if (requireConfirmation && !autoConfirm) {
|
|
103
|
+
// Return confirmation request
|
|
104
|
+
const confirmationPrompt = generateConfirmationPrompt({
|
|
105
|
+
script,
|
|
106
|
+
description,
|
|
107
|
+
runAsUser,
|
|
108
|
+
allowDataModification,
|
|
109
|
+
securityAnalysis
|
|
110
|
+
});
|
|
111
|
+
return (0, error_handler_js_1.createSuccessResult)({
|
|
112
|
+
requires_confirmation: true,
|
|
113
|
+
confirmation_prompt: confirmationPrompt,
|
|
114
|
+
script_to_execute: script,
|
|
115
|
+
execution_context: {
|
|
116
|
+
runAsUser: runAsUser || 'current',
|
|
117
|
+
allowDataModification,
|
|
118
|
+
securityLevel: securityAnalysis.riskLevel
|
|
119
|
+
},
|
|
120
|
+
next_step: 'Call snow_confirm_script_execution with userConfirmed=true to execute'
|
|
121
|
+
}, {
|
|
122
|
+
action_required: 'User must approve script execution via snow_confirm_script_execution'
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
// Execute the script
|
|
126
|
+
return await executeScript({
|
|
127
|
+
script,
|
|
128
|
+
description,
|
|
129
|
+
timeout,
|
|
130
|
+
securityAnalysis,
|
|
131
|
+
autoConfirm
|
|
132
|
+
}, context);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
return (0, error_handler_js_1.createErrorResult)(error instanceof error_handler_js_1.SnowFlowError
|
|
136
|
+
? error
|
|
137
|
+
: new error_handler_js_1.SnowFlowError(error_handler_js_1.ErrorType.UNKNOWN_ERROR, error.message, { originalError: error }));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
async function executeScript(params, context) {
|
|
141
|
+
const { script, description, timeout, securityAnalysis, autoConfirm } = params;
|
|
142
|
+
const client = await (0, auth_js_1.getAuthenticatedClient)(context);
|
|
143
|
+
// Create unique execution ID for tracking
|
|
144
|
+
const executionId = `exec_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
145
|
+
const outputMarker = `SNOW_FLOW_EXEC_${executionId}`;
|
|
146
|
+
// Wrap script with comprehensive output capture
|
|
147
|
+
const wrappedScript = `
|
|
148
|
+
// Snow-Flow Script Execution - ID: ${executionId}
|
|
149
|
+
// Description: ${description.replace(/'/g, "\\'")}
|
|
150
|
+
var __sfOutput = [];
|
|
151
|
+
var __sfStartTime = new GlideDateTime();
|
|
152
|
+
var __sfResult = null;
|
|
153
|
+
var __sfError = null;
|
|
154
|
+
|
|
155
|
+
// Store original gs methods
|
|
156
|
+
var __sfOrigPrint = gs.print;
|
|
157
|
+
var __sfOrigInfo = gs.info;
|
|
158
|
+
var __sfOrigWarn = gs.warn;
|
|
159
|
+
var __sfOrigError = gs.error;
|
|
160
|
+
|
|
161
|
+
// Override gs methods to capture output
|
|
162
|
+
gs.print = function(msg) {
|
|
163
|
+
var m = String(msg);
|
|
164
|
+
__sfOutput.push({level: 'print', message: m, timestamp: new GlideDateTime().getDisplayValue()});
|
|
165
|
+
__sfOrigPrint(m);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
gs.info = function(msg) {
|
|
169
|
+
var m = String(msg);
|
|
170
|
+
__sfOutput.push({level: 'info', message: m, timestamp: new GlideDateTime().getDisplayValue()});
|
|
171
|
+
__sfOrigInfo(m);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
gs.warn = function(msg) {
|
|
175
|
+
var m = String(msg);
|
|
176
|
+
__sfOutput.push({level: 'warn', message: m, timestamp: new GlideDateTime().getDisplayValue()});
|
|
177
|
+
__sfOrigWarn(m);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
gs.error = function(msg) {
|
|
181
|
+
var m = String(msg);
|
|
182
|
+
__sfOutput.push({level: 'error', message: m, timestamp: new GlideDateTime().getDisplayValue()});
|
|
183
|
+
__sfOrigError(m);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// Execute the user script
|
|
187
|
+
try {
|
|
188
|
+
gs.info('=== Snow-Flow Script Execution Started ===');
|
|
189
|
+
gs.info('Description: ${description.replace(/'/g, "\\'")}');
|
|
190
|
+
|
|
191
|
+
__sfResult = (function() {
|
|
192
|
+
${script}
|
|
193
|
+
})();
|
|
194
|
+
|
|
195
|
+
gs.info('=== Snow-Flow Script Execution Completed ===');
|
|
196
|
+
|
|
197
|
+
if (__sfResult !== undefined && __sfResult !== null) {
|
|
198
|
+
gs.info('Script returned: ' + (typeof __sfResult === 'object' ? JSON.stringify(__sfResult) : String(__sfResult)));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
} catch(e) {
|
|
202
|
+
__sfError = e.toString();
|
|
203
|
+
gs.error('=== Snow-Flow Script Execution Failed ===');
|
|
204
|
+
gs.error('Error: ' + e.toString());
|
|
205
|
+
if (e.stack) {
|
|
206
|
+
gs.error('Stack: ' + e.stack);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Restore original gs methods
|
|
211
|
+
gs.print = __sfOrigPrint;
|
|
212
|
+
gs.info = __sfOrigInfo;
|
|
213
|
+
gs.warn = __sfOrigWarn;
|
|
214
|
+
gs.error = __sfOrigError;
|
|
215
|
+
|
|
216
|
+
// Calculate execution time
|
|
217
|
+
var __sfEndTime = new GlideDateTime();
|
|
218
|
+
var __sfExecTimeMs = Math.abs(GlideDateTime.subtract(__sfStartTime, __sfEndTime).getNumericValue());
|
|
219
|
+
|
|
220
|
+
// Build result object
|
|
221
|
+
var __sfResultObj = {
|
|
222
|
+
executionId: '${executionId}',
|
|
223
|
+
success: __sfError === null,
|
|
224
|
+
result: __sfResult,
|
|
225
|
+
error: __sfError,
|
|
226
|
+
output: __sfOutput,
|
|
227
|
+
executionTimeMs: __sfExecTimeMs,
|
|
228
|
+
completedAt: __sfEndTime.getDisplayValue()
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// Store result in system property for retrieval
|
|
232
|
+
gs.setProperty('${outputMarker}', JSON.stringify(__sfResultObj));
|
|
233
|
+
gs.info('${outputMarker}:DONE');
|
|
234
|
+
`;
|
|
235
|
+
// Step 1: Create Scheduled Script Job (sysauto_script)
|
|
236
|
+
const jobName = `Snow-Flow Exec - ${executionId}`;
|
|
237
|
+
const createResponse = await client.post('/api/now/table/sysauto_script', {
|
|
238
|
+
name: jobName,
|
|
239
|
+
script: wrappedScript,
|
|
240
|
+
active: true,
|
|
241
|
+
run_type: 'on_demand',
|
|
242
|
+
conditional: false
|
|
243
|
+
});
|
|
244
|
+
if (!createResponse.data?.result?.sys_id) {
|
|
245
|
+
throw new error_handler_js_1.SnowFlowError(error_handler_js_1.ErrorType.SERVICENOW_API_ERROR, 'Failed to create scheduled script job', { details: createResponse.data });
|
|
246
|
+
}
|
|
247
|
+
const jobSysId = createResponse.data.result.sys_id;
|
|
248
|
+
// Step 2: Create sys_trigger to execute immediately
|
|
249
|
+
const now = new Date();
|
|
250
|
+
const triggerTime = new Date(now.getTime() + 2000); // 2 seconds from now
|
|
251
|
+
const triggerTimeStr = triggerTime.toISOString().replace('T', ' ').substring(0, 19);
|
|
252
|
+
try {
|
|
253
|
+
await client.post('/api/now/table/sys_trigger', {
|
|
254
|
+
name: jobName,
|
|
255
|
+
next_action: triggerTimeStr,
|
|
256
|
+
trigger_type: 0, // Run Once
|
|
257
|
+
state: 0, // Ready
|
|
258
|
+
document: 'sysauto_script',
|
|
259
|
+
document_key: jobSysId,
|
|
260
|
+
claimed_by: '',
|
|
261
|
+
system_id: 'snow-flow'
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
catch (triggerError) {
|
|
265
|
+
// If trigger creation fails, job won't auto-execute
|
|
266
|
+
// Continue anyway - we'll check results
|
|
267
|
+
}
|
|
268
|
+
// Step 3: Poll for execution results
|
|
269
|
+
const startTime = Date.now();
|
|
270
|
+
let result = null;
|
|
271
|
+
let attempts = 0;
|
|
272
|
+
const maxAttempts = Math.ceil(timeout / 2000);
|
|
273
|
+
while (Date.now() - startTime < timeout && attempts < maxAttempts) {
|
|
274
|
+
attempts++;
|
|
275
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
276
|
+
try {
|
|
277
|
+
// Check sys_properties for output marker
|
|
278
|
+
const propResponse = await client.get('/api/now/table/sys_properties', {
|
|
279
|
+
params: {
|
|
280
|
+
sysparm_query: `name=${outputMarker}`,
|
|
281
|
+
sysparm_fields: 'value,sys_id',
|
|
282
|
+
sysparm_limit: 1
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
if (propResponse.data?.result?.[0]?.value) {
|
|
286
|
+
try {
|
|
287
|
+
result = JSON.parse(propResponse.data.result[0].value);
|
|
288
|
+
// Delete the property after reading
|
|
289
|
+
const propSysId = propResponse.data.result[0].sys_id;
|
|
290
|
+
if (propSysId) {
|
|
291
|
+
await client.delete(`/api/now/table/sys_properties/${propSysId}`).catch(() => { });
|
|
292
|
+
}
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
catch (parseErr) {
|
|
296
|
+
// Continue polling
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
catch (pollError) {
|
|
301
|
+
// Continue polling
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// Step 4: Cleanup - delete the scheduled job
|
|
305
|
+
try {
|
|
306
|
+
await client.delete(`/api/now/table/sysauto_script/${jobSysId}`);
|
|
307
|
+
}
|
|
308
|
+
catch (cleanupError) {
|
|
309
|
+
// Ignore cleanup errors
|
|
310
|
+
}
|
|
311
|
+
// Step 5: Format and return results
|
|
312
|
+
if (result) {
|
|
313
|
+
// Organize output by level
|
|
314
|
+
const organized = {
|
|
315
|
+
print: result.output.filter((o) => o.level === 'print').map((o) => o.message),
|
|
316
|
+
info: result.output.filter((o) => o.level === 'info').map((o) => o.message),
|
|
317
|
+
warn: result.output.filter((o) => o.level === 'warn').map((o) => o.message),
|
|
318
|
+
error: result.output.filter((o) => o.level === 'error').map((o) => o.message),
|
|
319
|
+
success: result.success
|
|
320
|
+
};
|
|
321
|
+
return (0, error_handler_js_1.createSuccessResult)({
|
|
322
|
+
executed: true,
|
|
323
|
+
success: result.success,
|
|
324
|
+
result: result.result,
|
|
325
|
+
error: result.error,
|
|
326
|
+
output: organized,
|
|
327
|
+
raw_output: result.output,
|
|
328
|
+
execution_time_ms: result.executionTimeMs,
|
|
329
|
+
execution_id: executionId,
|
|
330
|
+
auto_confirmed: autoConfirm,
|
|
331
|
+
security_analysis: securityAnalysis
|
|
332
|
+
}, {
|
|
333
|
+
script_length: params.script.length,
|
|
334
|
+
method: 'sysauto_script_with_trigger',
|
|
335
|
+
description
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
// Script was saved but execution couldn't be confirmed
|
|
340
|
+
return (0, error_handler_js_1.createSuccessResult)({
|
|
341
|
+
executed: false,
|
|
342
|
+
execution_id: executionId,
|
|
343
|
+
scheduled_job_sys_id: jobSysId,
|
|
344
|
+
auto_confirmed: autoConfirm,
|
|
345
|
+
security_analysis: securityAnalysis,
|
|
346
|
+
message: 'Script was saved as scheduled job but automatic execution could not be confirmed. The sys_trigger may not have been created (permissions) or the scheduler has not yet picked it up.',
|
|
347
|
+
action_required: `Navigate to System Scheduler > Scheduled Jobs and run: ${jobName}`
|
|
348
|
+
}, {
|
|
349
|
+
script_length: params.script.length,
|
|
350
|
+
method: 'scheduled_job_pending',
|
|
351
|
+
description
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
function validateES5(code) {
|
|
356
|
+
const violations = [];
|
|
357
|
+
const patterns = [
|
|
358
|
+
{ regex: /\b(const|let)\s+/g, type: 'const/let', fix: "Use 'var'" },
|
|
359
|
+
{ regex: /\([^)]*\)\s*=>/g, type: 'arrow_function', fix: 'Use function() {}' },
|
|
360
|
+
{ regex: /`[^`]*`/g, type: 'template_literal', fix: 'Use string concatenation' },
|
|
361
|
+
{ regex: /\{[^}]+\}\s*=\s*/g, type: 'destructuring', fix: 'Use explicit properties' },
|
|
362
|
+
{ regex: /for\s*\([^)]*\s+of\s+/g, type: 'for_of', fix: 'Use traditional for loop' },
|
|
363
|
+
{ regex: /class\s+\w+/g, type: 'class', fix: 'Use function constructor' }
|
|
364
|
+
];
|
|
365
|
+
patterns.forEach(({ regex, type, fix }) => {
|
|
366
|
+
let match;
|
|
367
|
+
while ((match = regex.exec(code)) !== null) {
|
|
368
|
+
violations.push({
|
|
369
|
+
type,
|
|
370
|
+
line: code.substring(0, match.index).split('\n').length,
|
|
371
|
+
code: match[0],
|
|
372
|
+
fix
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
return { valid: violations.length === 0, violations };
|
|
377
|
+
}
|
|
378
|
+
function analyzeScriptSecurity(script) {
|
|
379
|
+
const analysis = {
|
|
380
|
+
riskLevel: 'LOW',
|
|
381
|
+
warnings: [],
|
|
382
|
+
dataOperations: [],
|
|
383
|
+
systemAccess: []
|
|
384
|
+
};
|
|
385
|
+
const dataModificationPatterns = [
|
|
386
|
+
/\.insert\(\)/gi,
|
|
387
|
+
/\.update\(\)/gi,
|
|
388
|
+
/\.deleteRecord\(\)/gi,
|
|
389
|
+
/\.setValue\(/gi
|
|
390
|
+
];
|
|
391
|
+
const systemAccessPatterns = [
|
|
392
|
+
/gs\.getUser\(\)/gi,
|
|
393
|
+
/gs\.getUserID\(\)/gi,
|
|
394
|
+
/gs\.hasRole\(/gi,
|
|
395
|
+
/gs\.executeNow\(/gi
|
|
396
|
+
];
|
|
397
|
+
const dangerousPatterns = [
|
|
398
|
+
/eval\(/gi,
|
|
399
|
+
/new Function\(/gi,
|
|
400
|
+
/\.setWorkflow\(/gi
|
|
401
|
+
];
|
|
402
|
+
dataModificationPatterns.forEach(pattern => {
|
|
403
|
+
const matches = script.match(pattern);
|
|
404
|
+
if (matches) {
|
|
405
|
+
analysis.dataOperations.push(...matches);
|
|
406
|
+
if (analysis.riskLevel === 'LOW')
|
|
407
|
+
analysis.riskLevel = 'MEDIUM';
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
systemAccessPatterns.forEach(pattern => {
|
|
411
|
+
const matches = script.match(pattern);
|
|
412
|
+
if (matches) {
|
|
413
|
+
analysis.systemAccess.push(...matches);
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
dangerousPatterns.forEach(pattern => {
|
|
417
|
+
const matches = script.match(pattern);
|
|
418
|
+
if (matches) {
|
|
419
|
+
analysis.warnings.push(`Potentially dangerous operation detected: ${matches[0]}`);
|
|
420
|
+
analysis.riskLevel = 'HIGH';
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
if (script.includes('while') && (script.includes('.next()') || script.includes('.hasNext()'))) {
|
|
424
|
+
analysis.warnings.push('Script contains loops that may process many records');
|
|
425
|
+
if (analysis.riskLevel === 'LOW')
|
|
426
|
+
analysis.riskLevel = 'MEDIUM';
|
|
427
|
+
}
|
|
428
|
+
return analysis;
|
|
429
|
+
}
|
|
430
|
+
function generateConfirmationPrompt(context) {
|
|
431
|
+
const { script, description, runAsUser, allowDataModification, securityAnalysis } = context;
|
|
432
|
+
const riskEmoji = {
|
|
433
|
+
'LOW': '🟢',
|
|
434
|
+
'MEDIUM': '🟡',
|
|
435
|
+
'HIGH': '🔴'
|
|
436
|
+
}[securityAnalysis.riskLevel] || '⚪';
|
|
437
|
+
return `
|
|
438
|
+
🚨 SCRIPT EXECUTION REQUEST
|
|
439
|
+
|
|
440
|
+
📋 **Description:** ${description}
|
|
441
|
+
|
|
442
|
+
${riskEmoji} **Security Risk Level:** ${securityAnalysis.riskLevel}
|
|
443
|
+
|
|
444
|
+
👤 **Run as User:** ${runAsUser || 'Current User'}
|
|
445
|
+
📝 **Data Modification:** ${allowDataModification ? '✅ ALLOWED' : '❌ READ-ONLY'}
|
|
446
|
+
|
|
447
|
+
🔍 **Script Analysis:**
|
|
448
|
+
${securityAnalysis.dataOperations.length > 0 ?
|
|
449
|
+
`📊 Data Operations Detected: ${securityAnalysis.dataOperations.join(', ')}` : ''}
|
|
450
|
+
${securityAnalysis.systemAccess.length > 0 ?
|
|
451
|
+
`🔧 System Access: ${securityAnalysis.systemAccess.join(', ')}` : ''}
|
|
452
|
+
${securityAnalysis.warnings.length > 0 ?
|
|
453
|
+
`⚠️ Warnings: ${securityAnalysis.warnings.join(', ')}` : ''}
|
|
454
|
+
|
|
455
|
+
📜 **Script to Execute:**
|
|
456
|
+
\`\`\`javascript
|
|
457
|
+
${script}
|
|
458
|
+
\`\`\`
|
|
459
|
+
|
|
460
|
+
⚡ **Impact:** This script will run in ServiceNow's server-side JavaScript context with full API access.
|
|
461
|
+
|
|
462
|
+
❓ **Do you want to proceed with executing this script?**
|
|
463
|
+
|
|
464
|
+
Reply with:
|
|
465
|
+
- ✅ **YES** - Execute the script
|
|
466
|
+
- ❌ **NO** - Cancel execution
|
|
467
|
+
- 📝 **MODIFY** - Make changes before execution
|
|
468
|
+
|
|
469
|
+
⚠️ Only proceed if you understand what this script does and trust its source!
|
|
470
|
+
`.trim();
|
|
471
|
+
}
|
|
472
|
+
exports.version = '2.0.0';
|
|
473
|
+
exports.author = 'Snow-Flow SDK';
|
|
474
|
+
//# sourceMappingURL=snow_execute_script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snow_execute_script.js","sourceRoot":"","sources":["../../../../../src/mcp/servicenow-mcp-unified/tools/automation/snow_execute_script.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAsEH,0BA6EC;AAhJD,kDAA8D;AAC9D,oEAAiH;AAEpG,QAAA,cAAc,GAAsB;IAC/C,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,sLAAsL;IACnM,gDAAgD;IAChD,QAAQ,EAAE,YAAY;IACtB,WAAW,EAAE,kBAAkB;IAC/B,SAAS,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,CAAC;IAC9E,UAAU,EAAE,UAAU;IACtB,SAAS,EAAE,MAAM;IAEjB,yBAAyB;IACzB,UAAU,EAAE,OAAO;IACnB,YAAY,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC;IACpC,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wFAAwF;aACtG;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kFAAkF;aAChG;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,qBAAqB;gBAClC,OAAO,EAAE,QAAQ;gBACjB,IAAI,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;aAC1B;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uDAAuD;gBAC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CAAC,CAAC,CAAC,EAAE;EACjF,gBAAgB,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC1C,qBAAqB,gBAAgB,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;EACpE,gBAAgB,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACtC,gBAAgB,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;;;;EAI3D,MAAM;;;;;;;;;;;;;CAaP,CAAC,IAAI,EAAE,CAAC;AACT,CAAC;AAEY,QAAA,OAAO,GAAG,OAAO,CAAC;AAClB,QAAA,MAAM,GAAG,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snow_create_artifact.d.ts","sourceRoot":"","sources":["../../../../../src/mcp/servicenow-mcp-unified/tools/deployment/snow_create_artifact.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIzF,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"snow_create_artifact.d.ts","sourceRoot":"","sources":["../../../../../src/mcp/servicenow-mcp-unified/tools/deployment/snow_create_artifact.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIzF,eAAO,MAAM,cAAc,EAAE,iBAyE5B,CAAC;AAEF,wBAAsB,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAiKxF;AAiKD,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,MAAM,mBAAmB,CAAC"}
|
|
@@ -12,7 +12,13 @@ const auth_js_1 = require("../../shared/auth.js");
|
|
|
12
12
|
const error_handler_js_1 = require("../../shared/error-handler.js");
|
|
13
13
|
exports.toolDefinition = {
|
|
14
14
|
name: 'snow_create_artifact',
|
|
15
|
-
description:
|
|
15
|
+
description: `Create ServiceNow artifacts (Service Portal widgets, UI pages, scripts, etc.) with a unified interface.
|
|
16
|
+
|
|
17
|
+
📦 APPLICATION SCOPE:
|
|
18
|
+
- By default, artifacts are created in the CURRENT application scope
|
|
19
|
+
- Use application_scope parameter to explicitly specify a scope
|
|
20
|
+
- Use "global" for global scope artifacts
|
|
21
|
+
- Artifacts created in a scoped application will only be visible/accessible within that scope`,
|
|
16
22
|
// Metadata for tool discovery (not sent to LLM)
|
|
17
23
|
category: 'development',
|
|
18
24
|
subcategory: 'deployment',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snow_create_artifact.js","sourceRoot":"","sources":["../../../../../src/mcp/servicenow-mcp-unified/tools/deployment/snow_create_artifact.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;
|
|
1
|
+
{"version":3,"file":"snow_create_artifact.js","sourceRoot":"","sources":["../../../../../src/mcp/servicenow-mcp-unified/tools/deployment/snow_create_artifact.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAiFH,0BAiKC;AA/OD,kDAA8D;AAC9D,oEAAiH;AAEpG,QAAA,cAAc,GAAsB;IAC/C,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE;;;;;;8FAM+E;IAC5F,gDAAgD;IAChD,QAAQ,EAAE,aAAa;IACvB,WAAW,EAAE,YAAY;IACzB,SAAS,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC;IAC7D,UAAU,EAAE,cAAc;IAC1B,SAAS,EAAE,MAAM;IAEjB,yBAAyB;IACzB,UAAU,EAAE,OAAO;IACnB,YAAY,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC;IACpC,WAAW,EAAE;QACX,IAAI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AI,EAAE,CAAC;QAClD,UAAU,CAAC,IAAI,CAAC;YACd,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM;YACvD,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;YACd,GAAG,EAAE,6CAA6C;SACnD,CAAC,CAAC;IACL,CAAC;IAED,8BAA8B;IAC9B,MAAM,eAAe,GAAG,UAAU,CAAC;IACnC,OAAO,CAAC,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACrD,UAAU,CAAC,IAAI,CAAC;YACd,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM;YACvD,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;YACd,GAAG,EAAE,8DAA8D;SACpE,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,KAAK,EAAE,UAAU,CAAC,MAAM,KAAK,CAAC;QAC9B,UAAU;KACX,CAAC;AACJ,CAAC;AAEY,QAAA,OAAO,GAAG,OAAO,CAAC;AAClB,QAAA,MAAM,GAAG,gBAAgB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const AGENTS_MD_TEMPLATE = "# Snow-Flow - ServiceNow Development AI Agent\n\n## \uD83D\uDEA8 CRITICAL: YOU MUST ACTUALLY CALL THE TOOLS!\n\n**MCP tools are JavaScript functions that you MUST call directly!**\n\n```javascript\n// \u2705 CORRECT - Actually call the function:\nconst updateSet = await snow_update_set_manage({\n action: 'create',\n name: \"Feature: Incident Dashboard\"\n});\n// This EXECUTES the tool and returns real data from ServiceNow\n\n// \u274C WRONG - Just showing code without calling it:\nconsole.log(\"I will create an update set like this:\");\nconsole.log(`await snow_update_set_manage({ action: 'create' });`);\n// This does NOTHING - it's just a string!\n```\n\n**If you show code examples without calling tools, you are FAILING your task!**\n\nThe user wants you to:\n- \u2705 **Actually execute tools** and get real results\n- \u2705 **Make real changes** in their ServiceNow instance\n- \u274C **NOT just show code examples** or explain what you \"would\" do\n\n---\n\n## What is Snow-Flow?\n\n**Snow-Flow** is an AI-powered ServiceNow development framework that provides **370+ MCP tools** to automate ServiceNow development, configuration, and administration. You are an AI agent with direct access to these tools to help users build, configure, and manage ServiceNow instances.\n\n## Your Purpose\n\nYou help users:\n- **Develop** ServiceNow artifacts (widgets, business rules, UI pages, flows, etc.)\n- **Configure** ServiceNow instances (properties, update sets, integrations)\n- **Automate** tasks (scripts, workflows, scheduled jobs)\n- **Analyze** data (incidents, reports, performance analytics)\n\n**Remember:** These tools are AVAILABLE and WORKING - just call them!\n\n---\n\n## \uD83D\uDEA8 THE GOLDEN RULE: UPDATE SET WORKFLOW\n\n**EVERY ServiceNow development task MUST follow this workflow:**\n\n```javascript\n// 1. CREATE UPDATE SET (before ANY development!)\nconst updateSet = await snow_update_set_manage({\n action: 'create',\n name: \"Feature: [Descriptive Name]\",\n description: \"What you're building and why\",\n application: \"global\"\n});\n\n// 2. VERIFY UPDATE SET IS ACTIVE\nconst current = await snow_update_set_query({ action: 'current' });\nconsole.log('Active Update Set:', current.name);\n\n// 3. NOW DEVELOP (all changes auto-tracked)\nawait snow_create_artifact({\n type: 'sp_widget',\n name: 'my_widget',\n title: 'My Widget',\n template: '<div>{{data.message}}</div>',\n server_script: 'data.message = \"Hello\";', // ES5 only!\n client_script: 'function($scope) { var c = this; }'\n});\n\n// 4. COMPLETE UPDATE SET when done\nawait snow_update_set_manage({\n action: 'complete',\n update_set_id: updateSet.sys_id\n});\n```\n\n### Update Set Rules:\n- \u2705 **ONE story/task/request = ONE update set** (critical for hygiene and traceability)\n- \u2705 **Create BEFORE any development** (not after!)\n- \u2705 **Descriptive names:** \"Feature: X\", \"Fix: Y\", or \"PROJ-123: Description\"\n- \u2705 **Verify it's active** before making changes\n- \u2705 **All changes tracked** automatically in active update set\n- \u2705 **Never mix unrelated changes** - each update set should be deployable independently\n- \u2705 **Ad-hoc requests too** - even user requests without tickets get their own update set\n\n### ServiceNow Best Practices (ALWAYS FOLLOW!):\n- \u2705 **Scoped Applications**: Use scoped apps for custom development when possible\n- \u2705 **No hardcoded sys_ids**: Use GlideRecord queries or system properties instead\n- \u2705 **Proper error handling**: Wrap GlideRecord operations in try/catch\n- \u2705 **Logging**: Use gs.info/gs.warn/gs.error (remove debug logs before production)\n- \u2705 **Performance**: Limit GlideRecord queries, avoid nested loops with queries\n- \u2705 **Security**: Never store credentials in scripts, use system properties\n- \u2705 **Testing**: Test in sub-production before deploying to production\n\n---\n\n## Core MCP Tools (v8.2.0)\n\n### Update Set Management (MANDATORY!)\n```javascript\n// Merged tools - use 'action' parameter:\nsnow_update_set_manage({ action: 'create' }) // Create new update set\nsnow_update_set_manage({ action: 'complete' }) // Mark as complete\nsnow_update_set_manage({ action: 'export' }) // Export to XML\nsnow_update_set_query({ action: 'current' }) // Get current active\nsnow_update_set_query({ action: 'list' }) // List all update sets\nsnow_ensure_active_update_set({ sys_id }) // Ensure specific set is active\n```\n\n### Record Operations\n```javascript\nsnow_record_manage({ action: 'create', table, data }) // Create record\nsnow_record_manage({ action: 'update', sys_id, data }) // Update record\nsnow_record_manage({ action: 'delete', sys_id }) // Delete record\nsnow_query_table({ table, query, fields }) // Query any table\nsnow_get_by_sysid({ table, sys_id }) // Get specific record\n```\n\n### Development & Deployment\n```javascript\nsnow_create_artifact({ type, name, ... }) // Universal artifact creation (widgets, pages, etc.)\nsnow_create_business_rule({ name, table, script }) // Business rules (ES5 only!)\nsnow_create_script_include({ name, script }) // Script includes\nsnow_create_client_script({ name, table, script }) // Client scripts\nsnow_create_ui_policy({ name, table, conditions }) // UI policies\n```\n\n### Widget Development (CRITICAL!)\n```javascript\n// ALWAYS use local sync for widgets - NEVER snow_query_table!\nsnow_pull_artifact({ sys_id, table: 'sp_widget' }) // Pull to local files\n// ... edit locally with native tools ...\nsnow_push_artifact({ sys_id }) // Push back to ServiceNow\n```\n\n### Change Management\n```javascript\nsnow_change_manage({ action: 'create', ... }) // Create change\nsnow_change_manage({ action: 'approve', ... }) // Approve change\nsnow_change_query({ action: 'search', ... }) // Search changes\n```\n\n### Knowledge Management\n```javascript\nsnow_knowledge_article_manage({ action: 'create' }) // Create article\nsnow_knowledge_article_manage({ action: 'publish' }) // Publish article\nsnow_knowledge_article_manage({ action: 'search' }) // Search articles\n```\n\n### Performance Analytics\n```javascript\nsnow_pa_create({ action: 'indicator', ... }) // Create PA indicator\nsnow_pa_operate({ action: 'collect_data', ... }) // Collect PA data\nsnow_pa_discover({ action: 'indicators' }) // Discover indicators\n```\n\n### UI Builder\n```javascript\nsnow_create_uib_page({ name, title }) // Create UIB page\nsnow_uib_component_manage({ action: 'create' }) // Create component\nsnow_add_uib_page_element({ page_sys_id, component }) // Add element\n```\n\n### Workspace\n```javascript\nsnow_create_complete_workspace({ workspace_name, tables }) // Complete workspace\nsnow_create_workspace_tab({ workspace, tab_config }) // Add tab\n```\n\n### Automation & Scripts\n```javascript\nsnow_execute_script_with_output({ script }) // Test/verify scripts (ES5 ONLY!)\nsnow_schedule_job({ name, script, interval }) // Scheduled jobs\nsnow_get_logs({ level, source, since }) // View system logs\nsnow_get_email_logs({ type, recipient, since }) // View sent/received emails\nsnow_get_outbound_http_logs({ status, endpoint }) // Monitor outgoing REST/SOAP calls\nsnow_get_inbound_http_logs({ status, url_path }) // Track incoming API requests\nsnow_get_flow_execution_logs({ status, flow_name }) // Flow Designer execution history\nsnow_get_scheduled_job_logs({ job_name, failed_only }) // Scheduled job runs and errors\nsnow_get_slow_queries({ table, min_duration }) // Database performance issues\n```\n\n### System Properties\n```javascript\nsnow_property_manage({ action: 'get', name }) // Get property\nsnow_property_manage({ action: 'set', name, value }) // Set property\nsnow_property_query({ action: 'list', pattern }) // List properties\n```\n\n### OAuth & Credentials Management\n```javascript\nsnow_create_oauth_profile({ name, client_id, token_url }) // Create OAuth 2.0 profile\nsnow_create_connection_alias({ name, connection_type }) // Create connection alias for IntegrationHub\nsnow_create_credential_alias({ name, type, basic_auth }) // Store API keys, passwords securely\nsnow_manage_oauth_tokens({ action: 'list' }) // View OAuth token status\nsnow_manage_oauth_tokens({ action: 'refresh', oauth_profile_id }) // Refresh expired tokens\nsnow_manage_oauth_tokens({ action: 'test', oauth_profile_id }) // Test OAuth connectivity\n```\n\n### IntegrationHub & Spokes\n```javascript\nsnow_install_spoke({ action: 'list' }) // List installed spokes\nsnow_install_spoke({ action: 'search', search_query }) // Search available spokes\nsnow_install_spoke({ action: 'status', spoke_name }) // Check spoke status & actions\nsnow_create_flow_action({ name, inputs, outputs }) // Create custom IntegrationHub action\nsnow_manage_spoke_connection({ action: 'list' }) // List spoke connections\nsnow_manage_spoke_connection({ action: 'test', connection_alias_id }) // Test spoke connection\nsnow_manage_spoke_connection({ action: 'troubleshoot', connection_alias_id }) // Diagnose issues\n```\n\n### MID Server Management\n```javascript\nsnow_configure_mid_server({ action: 'list' }) // List all MID Servers\nsnow_configure_mid_server({ action: 'status', mid_server_name }) // Detailed MID status\nsnow_configure_mid_server({ action: 'validate', mid_server_name }) // Validate MID Server\nsnow_test_mid_connectivity({ action: 'test_endpoint', mid_server_name, target_url }) // Test connectivity\nsnow_test_mid_connectivity({ action: 'ping', mid_server_name, target_host }) // Ping from MID\nsnow_test_mid_connectivity({ action: 'full_diagnostic', mid_server_name, target_host }) // Full network diagnostic\nsnow_manage_mid_capabilities({ action: 'list', mid_server_name }) // List MID capabilities\nsnow_manage_mid_capabilities({ action: 'add', mid_server_name, capability_name }) // Add capability\nsnow_manage_mid_capabilities({ action: 'recommend', use_case: 'discovery' }) // Get recommended capabilities\n```\n\n---\n\n## Critical Rules\n\n### 1. ES5 JavaScript Only (ServiceNow Rhino Engine)\n**NEVER USE:**\n- \u274C `const` / `let` (use `var`)\n- \u274C Arrow functions `() => {}` (use `function() {}`)\n- \u274C Template literals \\`${}\\` (use string concatenation `+`)\n- \u274C Destructuring `{a, b} = obj` (use `obj.a`, `obj.b`)\n- \u274C `for...of` loops (use traditional `for` loops)\n\n**ALWAYS USE ES5:**\n```javascript\nvar data = []; // NOT const or let\nfunction process() { return 'result'; } // NOT arrow functions\nvar msg = 'Hello ' + name; // NOT template literals\nfor (var i = 0; i < items.length; i++) { } // NOT for...of\n```\n\n### 2. Widget Debugging = Local Sync\n**ALWAYS use `snow_pull_artifact` for widgets** - NEVER `snow_query_table`!\n- Widget too large? \u2192 `snow_pull_artifact`\n- Widget not working? \u2192 `snow_pull_artifact`\n- Need to edit widget? \u2192 `snow_pull_artifact`\n\n### 3. MCP Tools Are Functions (NOT npm packages!)\n**\uD83D\uDEA8 CRITICAL:** MCP tools work via **Model Context Protocol** - they are **already available** as JavaScript functions!\n\n**\u2705 CORRECT: Just call them directly**\n```javascript\nawait snow_create_ui_page({ name: \"dashboard\", html: \"...\" });\nawait snow_update_set_manage({ action: 'create', name: \"Feature X\" });\n// That's it! No bash, no require(), no npm!\n```\n\n**\u274C FORBIDDEN: These ALWAYS fail!**\n```bash\n# \u274C NEVER DO THIS:\nnode -e \"const { snow_update_set_manage } = require('@snow-flow/mcp-client');\"\n# ERROR: Module '@snow-flow/mcp-client' DOES NOT EXIST!\n\nnode -e \"const { snow_query_table } = require('snow-flow');\"\n# ERROR: MCP tools are NOT exported from npm package!\n\nnode dist/index.js mcp execute snow_create_ui_page {...}\n# ERROR: This command DOES NOT EXIST!\n\nnpx snow-flow-mcp-client servicenow-unified snow_create_ui_page {...}\n# ERROR: This package DOES NOT EXIST!\n\necho \"...\" && node -e \"const { ... } = require(...);\"\n# ERROR: Parser3.init error - breaks SnowCode parser!\n```\n\n**Why?** MCP tools use the MCP protocol (server \u2194 client communication), NOT npm packages or bash commands!\n\n### 4. No Mock Data\n- **FORBIDDEN:** Placeholders, TODOs, \"this would normally...\", test values\n- **REQUIRED:** Complete, production-ready, fully functional code\n\n### 5. Verify First\n- Test before claiming something is broken\n- Check if resources exist before modifying\n- Use `snow_execute_script_with_output` to verify\n\n---\n\n## The Universal Workflow\n\n**Every task follows this pattern:**\n\n1. **\uD83D\uDCE6 UPDATE SET FIRST**\n - `snow_update_set_manage({ action: 'create', ... })`\n - `snow_update_set_query({ action: 'current' })` to verify\n\n2. **\uD83D\uDD0D USE RIGHT TOOL**\n - Creating? \u2192 `snow_create_artifact` or specific `snow_create_*` tool\n - Updating? \u2192 `snow_record_manage({ action: 'update' })`\n - Querying? \u2192 `snow_query_table` or specific query tool\n - Widget development? \u2192 `snow_pull_artifact` + `snow_push_artifact` (local sync!)\n\n3. **\u2705 VERIFY**\n - `snow_execute_script_with_output` for testing\n - Check logs with `snow_get_logs`\n - Validate with `snow_update_set_query({ action: 'current' })`\n\n4. **\u2714\uFE0F COMPLETE**\n - `snow_update_set_manage({ action: 'complete' })`\n\n---\n\n## Quick Reference\n\n| Task | Tool | Notes |\n|------|------|-------|\n| Create update set | `snow_update_set_manage({ action: 'create' })` | **DO THIS FIRST!** |\n| Create widget | `snow_create_artifact({ type: 'sp_widget' })` | Service Portal widget |\n| Fix widget | `snow_pull_artifact` + `snow_push_artifact` | Local sync workflow |\n| Create business rule | `snow_create_business_rule()` | ES5 only! |\n| Query incidents | `snow_query_incidents()` | Specialized tool |\n| Get property | `snow_property_manage({ action: 'get' })` | System properties |\n| Test script | `snow_execute_script_with_output()` | ES5 verification |\n| View emails | `snow_get_email_logs()` | Sent/received emails |\n| Debug integrations | `snow_get_outbound_http_logs()` | Outgoing HTTP calls |\n| Monitor API usage | `snow_get_inbound_http_logs()` | Incoming requests |\n| Debug flows | `snow_get_flow_execution_logs()` | Flow Designer runs |\n| Debug scheduled jobs | `snow_get_scheduled_job_logs()` | Job history & errors |\n| Find slow queries | `snow_get_slow_queries()` | Performance issues |\n| Create OAuth profile | `snow_create_oauth_profile()` | External API auth |\n| Store credentials | `snow_create_credential_alias()` | API keys, passwords |\n| Manage OAuth tokens | `snow_manage_oauth_tokens()` | List, refresh, test |\n| List spokes | `snow_install_spoke({ action: 'list' })` | IntegrationHub |\n| Create flow action | `snow_create_flow_action()` | Custom IH actions |\n| Test spoke connection | `snow_manage_spoke_connection()` | Diagnose issues |\n| List MID Servers | `snow_configure_mid_server()` | On-premise integration |\n| Test MID connectivity | `snow_test_mid_connectivity()` | Network diagnostics |\n| Manage MID capabilities | `snow_manage_mid_capabilities()` | Discovery, Orchestration |\n| Complete work | `snow_update_set_manage({ action: 'complete' })` | **DO THIS LAST!** |\n\n---\n\n**Remember:** Update Set \u2192 Tool \u2192 Verify \u2192 Complete. Every. Single. Time.\n";
|
|
1
|
+
export declare const AGENTS_MD_TEMPLATE = "# Snow-Flow - ServiceNow Development AI Agent\n\n## \uD83D\uDEA8 CRITICAL: YOU MUST ACTUALLY CALL THE TOOLS!\n\n**MCP tools are JavaScript functions that you MUST call directly!**\n\n```javascript\n// \u2705 CORRECT - Actually call the function:\nconst updateSet = await snow_update_set_manage({\n action: 'create',\n name: \"Feature: Incident Dashboard\"\n});\n// This EXECUTES the tool and returns real data from ServiceNow\n\n// \u274C WRONG - Just showing code without calling it:\nconsole.log(\"I will create an update set like this:\");\nconsole.log(`await snow_update_set_manage({ action: 'create' });`);\n// This does NOTHING - it's just a string!\n```\n\n**If you show code examples without calling tools, you are FAILING your task!**\n\nThe user wants you to:\n- \u2705 **Actually execute tools** and get real results\n- \u2705 **Make real changes** in their ServiceNow instance\n- \u274C **NOT just show code examples** or explain what you \"would\" do\n\n---\n\n## What is Snow-Flow?\n\n**Snow-Flow** is an AI-powered ServiceNow development framework that provides **370+ MCP tools** to automate ServiceNow development, configuration, and administration. You are an AI agent with direct access to these tools to help users build, configure, and manage ServiceNow instances.\n\n## Your Purpose\n\nYou help users:\n- **Develop** ServiceNow artifacts (widgets, business rules, UI pages, flows, etc.)\n- **Configure** ServiceNow instances (properties, update sets, integrations)\n- **Automate** tasks (scripts, workflows, scheduled jobs)\n- **Analyze** data (incidents, reports, performance analytics)\n\n**Remember:** These tools are AVAILABLE and WORKING - just call them!\n\n---\n\n## \uD83D\uDEA8 THE GOLDEN RULE: UPDATE SET WORKFLOW\n\n**EVERY ServiceNow development task MUST follow this workflow:**\n\n```javascript\n// 1. CREATE UPDATE SET (before ANY development!)\nconst updateSet = await snow_update_set_manage({\n action: 'create',\n name: \"Feature: [Descriptive Name]\",\n description: \"What you're building and why\",\n application: \"global\"\n});\n\n// 2. VERIFY UPDATE SET IS ACTIVE\nconst current = await snow_update_set_query({ action: 'current' });\nconsole.log('Active Update Set:', current.name);\n\n// 3. NOW DEVELOP (all changes auto-tracked)\nawait snow_create_artifact({\n type: 'sp_widget',\n name: 'my_widget',\n title: 'My Widget',\n template: '<div>{{data.message}}</div>',\n server_script: 'data.message = \"Hello\";', // ES5 only!\n client_script: 'function($scope) { var c = this; }'\n});\n\n// 4. COMPLETE UPDATE SET when done\nawait snow_update_set_manage({\n action: 'complete',\n update_set_id: updateSet.sys_id\n});\n```\n\n### Update Set Rules:\n- \u2705 **ONE story/task/request = ONE update set** (critical for hygiene and traceability)\n- \u2705 **Create BEFORE any development** (not after!)\n- \u2705 **Descriptive names:** \"Feature: X\", \"Fix: Y\", or \"PROJ-123: Description\"\n- \u2705 **Verify it's active** before making changes\n- \u2705 **All changes tracked** automatically in active update set\n- \u2705 **Never mix unrelated changes** - each update set should be deployable independently\n- \u2705 **Ad-hoc requests too** - even user requests without tickets get their own update set\n\n### ServiceNow Best Practices (ALWAYS FOLLOW!):\n- \u2705 **Scoped Applications**: Use scoped apps for custom development when possible\n- \u2705 **No hardcoded sys_ids**: Use GlideRecord queries or system properties instead\n- \u2705 **Proper error handling**: Wrap GlideRecord operations in try/catch\n- \u2705 **Logging**: Use gs.info/gs.warn/gs.error (remove debug logs before production)\n- \u2705 **Performance**: Limit GlideRecord queries, avoid nested loops with queries\n- \u2705 **Security**: Never store credentials in scripts, use system properties\n- \u2705 **Testing**: Test in sub-production before deploying to production\n\n---\n\n## Core MCP Tools (v8.2.0)\n\n### Update Set Management (MANDATORY!)\n```javascript\n// Merged tools - use 'action' parameter:\nsnow_update_set_manage({ action: 'create' }) // Create new update set\nsnow_update_set_manage({ action: 'complete' }) // Mark as complete\nsnow_update_set_manage({ action: 'export' }) // Export to XML\nsnow_update_set_query({ action: 'current' }) // Get current active\nsnow_update_set_query({ action: 'list' }) // List all update sets\nsnow_ensure_active_update_set({ sys_id }) // Ensure specific set is active\n```\n\n### Record Operations\n```javascript\nsnow_record_manage({ action: 'create', table, data }) // Create record\nsnow_record_manage({ action: 'update', sys_id, data }) // Update record\nsnow_record_manage({ action: 'delete', sys_id }) // Delete record\nsnow_query_table({ table, query, fields }) // Query any table\nsnow_get_by_sysid({ table, sys_id }) // Get specific record\n```\n\n### Development & Deployment\n```javascript\nsnow_create_artifact({ type, name, ... }) // Universal artifact creation (widgets, pages, etc.)\nsnow_create_business_rule({ name, table, script }) // Business rules (ES5 only!)\nsnow_create_script_include({ name, script }) // Script includes\nsnow_create_client_script({ name, table, script }) // Client scripts\nsnow_create_ui_policy({ name, table, conditions }) // UI policies\n```\n\n### Widget Development (CRITICAL!)\n```javascript\n// ALWAYS use local sync for widgets - NEVER snow_query_table!\nsnow_pull_artifact({ sys_id, table: 'sp_widget' }) // Pull to local files\n// ... edit locally with native tools ...\nsnow_push_artifact({ sys_id }) // Push back to ServiceNow\n```\n\n### Change Management\n```javascript\nsnow_change_manage({ action: 'create', ... }) // Create change\nsnow_change_manage({ action: 'approve', ... }) // Approve change\nsnow_change_query({ action: 'search', ... }) // Search changes\n```\n\n### Knowledge Management\n```javascript\nsnow_knowledge_article_manage({ action: 'create' }) // Create article\nsnow_knowledge_article_manage({ action: 'publish' }) // Publish article\nsnow_knowledge_article_manage({ action: 'search' }) // Search articles\n```\n\n### Performance Analytics\n```javascript\nsnow_pa_create({ action: 'indicator', ... }) // Create PA indicator\nsnow_pa_operate({ action: 'collect_data', ... }) // Collect PA data\nsnow_pa_discover({ action: 'indicators' }) // Discover indicators\n```\n\n### UI Builder\n```javascript\nsnow_create_uib_page({ name, title }) // Create UIB page\nsnow_uib_component_manage({ action: 'create' }) // Create component\nsnow_add_uib_page_element({ page_sys_id, component }) // Add element\n```\n\n### Workspace\n```javascript\nsnow_create_complete_workspace({ workspace_name, tables }) // Complete workspace\nsnow_create_workspace_tab({ workspace, tab_config }) // Add tab\n```\n\n### Automation & Scripts\n```javascript\nsnow_execute_script({ script, description }) // Test/verify scripts (ES5 ONLY!)\nsnow_schedule_job({ name, script, interval }) // Scheduled jobs\nsnow_get_logs({ level, source, since }) // View system logs\nsnow_get_email_logs({ type, recipient, since }) // View sent/received emails\nsnow_get_outbound_http_logs({ status, endpoint }) // Monitor outgoing REST/SOAP calls\nsnow_get_inbound_http_logs({ status, url_path }) // Track incoming API requests\nsnow_get_flow_execution_logs({ status, flow_name }) // Flow Designer execution history\nsnow_get_scheduled_job_logs({ job_name, failed_only }) // Scheduled job runs and errors\nsnow_get_slow_queries({ table, min_duration }) // Database performance issues\n```\n\n### System Properties\n```javascript\nsnow_property_manage({ action: 'get', name }) // Get property\nsnow_property_manage({ action: 'set', name, value }) // Set property\nsnow_property_query({ action: 'list', pattern }) // List properties\n```\n\n### OAuth & Credentials Management\n```javascript\nsnow_create_oauth_profile({ name, client_id, token_url }) // Create OAuth 2.0 profile\nsnow_create_connection_alias({ name, connection_type }) // Create connection alias for IntegrationHub\nsnow_create_credential_alias({ name, type, basic_auth }) // Store API keys, passwords securely\nsnow_manage_oauth_tokens({ action: 'list' }) // View OAuth token status\nsnow_manage_oauth_tokens({ action: 'refresh', oauth_profile_id }) // Refresh expired tokens\nsnow_manage_oauth_tokens({ action: 'test', oauth_profile_id }) // Test OAuth connectivity\n```\n\n### IntegrationHub & Spokes\n```javascript\nsnow_install_spoke({ action: 'list' }) // List installed spokes\nsnow_install_spoke({ action: 'search', search_query }) // Search available spokes\nsnow_install_spoke({ action: 'status', spoke_name }) // Check spoke status & actions\nsnow_create_flow_action({ name, inputs, outputs }) // Create custom IntegrationHub action\nsnow_manage_spoke_connection({ action: 'list' }) // List spoke connections\nsnow_manage_spoke_connection({ action: 'test', connection_alias_id }) // Test spoke connection\nsnow_manage_spoke_connection({ action: 'troubleshoot', connection_alias_id }) // Diagnose issues\n```\n\n### MID Server Management\n```javascript\nsnow_configure_mid_server({ action: 'list' }) // List all MID Servers\nsnow_configure_mid_server({ action: 'status', mid_server_name }) // Detailed MID status\nsnow_configure_mid_server({ action: 'validate', mid_server_name }) // Validate MID Server\nsnow_test_mid_connectivity({ action: 'test_endpoint', mid_server_name, target_url }) // Test connectivity\nsnow_test_mid_connectivity({ action: 'ping', mid_server_name, target_host }) // Ping from MID\nsnow_test_mid_connectivity({ action: 'full_diagnostic', mid_server_name, target_host }) // Full network diagnostic\nsnow_manage_mid_capabilities({ action: 'list', mid_server_name }) // List MID capabilities\nsnow_manage_mid_capabilities({ action: 'add', mid_server_name, capability_name }) // Add capability\nsnow_manage_mid_capabilities({ action: 'recommend', use_case: 'discovery' }) // Get recommended capabilities\n```\n\n---\n\n## Critical Rules\n\n### 1. ES5 JavaScript Only (ServiceNow Rhino Engine)\n**NEVER USE:**\n- \u274C `const` / `let` (use `var`)\n- \u274C Arrow functions `() => {}` (use `function() {}`)\n- \u274C Template literals \\`${}\\` (use string concatenation `+`)\n- \u274C Destructuring `{a, b} = obj` (use `obj.a`, `obj.b`)\n- \u274C `for...of` loops (use traditional `for` loops)\n\n**ALWAYS USE ES5:**\n```javascript\nvar data = []; // NOT const or let\nfunction process() { return 'result'; } // NOT arrow functions\nvar msg = 'Hello ' + name; // NOT template literals\nfor (var i = 0; i < items.length; i++) { } // NOT for...of\n```\n\n### 2. Widget Debugging = Local Sync\n**ALWAYS use `snow_pull_artifact` for widgets** - NEVER `snow_query_table`!\n- Widget too large? \u2192 `snow_pull_artifact`\n- Widget not working? \u2192 `snow_pull_artifact`\n- Need to edit widget? \u2192 `snow_pull_artifact`\n\n### 3. MCP Tools Are Functions (NOT npm packages!)\n**\uD83D\uDEA8 CRITICAL:** MCP tools work via **Model Context Protocol** - they are **already available** as JavaScript functions!\n\n**\u2705 CORRECT: Just call them directly**\n```javascript\nawait snow_create_ui_page({ name: \"dashboard\", html: \"...\" });\nawait snow_update_set_manage({ action: 'create', name: \"Feature X\" });\n// That's it! No bash, no require(), no npm!\n```\n\n**\u274C FORBIDDEN: These ALWAYS fail!**\n```bash\n# \u274C NEVER DO THIS:\nnode -e \"const { snow_update_set_manage } = require('@snow-flow/mcp-client');\"\n# ERROR: Module '@snow-flow/mcp-client' DOES NOT EXIST!\n\nnode -e \"const { snow_query_table } = require('snow-flow');\"\n# ERROR: MCP tools are NOT exported from npm package!\n\nnode dist/index.js mcp execute snow_create_ui_page {...}\n# ERROR: This command DOES NOT EXIST!\n\nnpx snow-flow-mcp-client servicenow-unified snow_create_ui_page {...}\n# ERROR: This package DOES NOT EXIST!\n\necho \"...\" && node -e \"const { ... } = require(...);\"\n# ERROR: Parser3.init error - breaks SnowCode parser!\n```\n\n**Why?** MCP tools use the MCP protocol (server \u2194 client communication), NOT npm packages or bash commands!\n\n### 4. No Mock Data\n- **FORBIDDEN:** Placeholders, TODOs, \"this would normally...\", test values\n- **REQUIRED:** Complete, production-ready, fully functional code\n\n### 5. Verify First\n- Test before claiming something is broken\n- Check if resources exist before modifying\n- Use `snow_execute_script` to verify\n\n---\n\n## The Universal Workflow\n\n**Every task follows this pattern:**\n\n1. **\uD83D\uDCE6 UPDATE SET FIRST**\n - `snow_update_set_manage({ action: 'create', ... })`\n - `snow_update_set_query({ action: 'current' })` to verify\n\n2. **\uD83D\uDD0D USE RIGHT TOOL**\n - Creating? \u2192 `snow_create_artifact` or specific `snow_create_*` tool\n - Updating? \u2192 `snow_record_manage({ action: 'update' })`\n - Querying? \u2192 `snow_query_table` or specific query tool\n - Widget development? \u2192 `snow_pull_artifact` + `snow_push_artifact` (local sync!)\n\n3. **\u2705 VERIFY**\n - `snow_execute_script` for testing\n - Check logs with `snow_get_logs`\n - Validate with `snow_update_set_query({ action: 'current' })`\n\n4. **\u2714\uFE0F COMPLETE**\n - `snow_update_set_manage({ action: 'complete' })`\n\n---\n\n## Quick Reference\n\n| Task | Tool | Notes |\n|------|------|-------|\n| Create update set | `snow_update_set_manage({ action: 'create' })` | **DO THIS FIRST!** |\n| Create widget | `snow_create_artifact({ type: 'sp_widget' })` | Service Portal widget |\n| Fix widget | `snow_pull_artifact` + `snow_push_artifact` | Local sync workflow |\n| Create business rule | `snow_create_business_rule()` | ES5 only! |\n| Query incidents | `snow_query_incidents()` | Specialized tool |\n| Get property | `snow_property_manage({ action: 'get' })` | System properties |\n| Test script | `snow_execute_script()` | ES5 verification |\n| View emails | `snow_get_email_logs()` | Sent/received emails |\n| Debug integrations | `snow_get_outbound_http_logs()` | Outgoing HTTP calls |\n| Monitor API usage | `snow_get_inbound_http_logs()` | Incoming requests |\n| Debug flows | `snow_get_flow_execution_logs()` | Flow Designer runs |\n| Debug scheduled jobs | `snow_get_scheduled_job_logs()` | Job history & errors |\n| Find slow queries | `snow_get_slow_queries()` | Performance issues |\n| Create OAuth profile | `snow_create_oauth_profile()` | External API auth |\n| Store credentials | `snow_create_credential_alias()` | API keys, passwords |\n| Manage OAuth tokens | `snow_manage_oauth_tokens()` | List, refresh, test |\n| List spokes | `snow_install_spoke({ action: 'list' })` | IntegrationHub |\n| Create flow action | `snow_create_flow_action()` | Custom IH actions |\n| Test spoke connection | `snow_manage_spoke_connection()` | Diagnose issues |\n| List MID Servers | `snow_configure_mid_server()` | On-premise integration |\n| Test MID connectivity | `snow_test_mid_connectivity()` | Network diagnostics |\n| Manage MID capabilities | `snow_manage_mid_capabilities()` | Discovery, Orchestration |\n| Complete work | `snow_update_set_manage({ action: 'complete' })` | **DO THIS LAST!** |\n\n---\n\n**Remember:** Update Set \u2192 Tool \u2192 Verify \u2192 Complete. Every. Single. Time.\n";
|
|
2
2
|
export declare const AGENTS_MD_TEMPLATE_VERSION = "8.6.0-EXTERNAL-INTEGRATION";
|
|
3
3
|
//# sourceMappingURL=agents-md-template.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents-md-template.d.ts","sourceRoot":"","sources":["../../src/templates/agents-md-template.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"agents-md-template.d.ts","sourceRoot":"","sources":["../../src/templates/agents-md-template.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,8yeA6V9B,CAAC;AAEF,eAAO,MAAM,0BAA0B,+BAA+B,CAAC"}
|