snow-flow 8.39.13 → 8.40.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/CLAUDE.md +190 -0
- package/dist/mcp/servicenow-mcp-unified/tools/applications/index.d.ts +1 -0
- package/dist/mcp/servicenow-mcp-unified/tools/applications/index.d.ts.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/applications/index.js +4 -1
- package/dist/mcp/servicenow-mcp-unified/tools/applications/index.js.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_create_application.d.ts +9 -3
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_create_application.d.ts.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_create_application.js +239 -13
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_create_application.js.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_switch_application_scope.d.ts +18 -0
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_switch_application_scope.d.ts.map +1 -0
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_switch_application_scope.js +297 -0
- package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_switch_application_scope.js.map +1 -0
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_background_script.d.ts +2 -2
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_background_script.d.ts.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_background_script.js +172 -21
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_background_script.js.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_script_sync.d.ts +2 -1
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_script_sync.d.ts.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_script_sync.js +194 -47
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_script_sync.js.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_script_with_output.d.ts +3 -3
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_script_with_output.d.ts.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_script_with_output.js +190 -142
- package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_script_with_output.js.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/update-sets/snow_ensure_active_update_set.d.ts.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/update-sets/snow_ensure_active_update_set.js +48 -4
- package/dist/mcp/servicenow-mcp-unified/tools/update-sets/snow_ensure_active_update_set.js.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/update-sets/snow_update_set_manage.d.ts.map +1 -1
- package/dist/mcp/servicenow-mcp-unified/tools/update-sets/snow_update_set_manage.js +74 -4
- package/dist/mcp/servicenow-mcp-unified/tools/update-sets/snow_update_set_manage.js.map +1 -1
- package/dist/utils/servicenow-client.d.ts +2 -1
- package/dist/utils/servicenow-client.d.ts.map +1 -1
- package/dist/utils/servicenow-client.js +112 -10
- package/dist/utils/servicenow-client.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* snow_switch_application_scope - Switch Application Scope
|
|
4
|
+
*
|
|
5
|
+
* Switches the current application scope for development. This determines
|
|
6
|
+
* which application context artifacts will be created in.
|
|
7
|
+
*
|
|
8
|
+
* In ServiceNow, application scope controls:
|
|
9
|
+
* - Which application artifacts belong to
|
|
10
|
+
* - Access control and permissions
|
|
11
|
+
* - Update Set tracking
|
|
12
|
+
* - Cross-scope access rules
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.author = exports.version = exports.toolDefinition = void 0;
|
|
16
|
+
exports.execute = execute;
|
|
17
|
+
const auth_js_1 = require("../../shared/auth.js");
|
|
18
|
+
const error_handler_js_1 = require("../../shared/error-handler.js");
|
|
19
|
+
exports.toolDefinition = {
|
|
20
|
+
name: 'snow_switch_application_scope',
|
|
21
|
+
description: `Switch the current application scope for development.
|
|
22
|
+
|
|
23
|
+
🔄 APPLICATION SCOPE SWITCHING:
|
|
24
|
+
|
|
25
|
+
When you switch scope, all NEW artifacts you create will belong to that scope.
|
|
26
|
+
This is essential for proper application organization and deployment.
|
|
27
|
+
|
|
28
|
+
📌 SCOPE OPTIONS:
|
|
29
|
+
- "global" - Global scope for cross-application utilities and system-wide changes
|
|
30
|
+
- Application sys_id - Switch to a specific application by its sys_id
|
|
31
|
+
- Scope name - Switch by scope prefix (e.g., "x_myco_hr_portal")
|
|
32
|
+
- Application name - Switch by application name
|
|
33
|
+
|
|
34
|
+
🎯 USE CASES:
|
|
35
|
+
- Switching to a scoped app to add new features
|
|
36
|
+
- Switching to global for shared utilities
|
|
37
|
+
- Switching between multiple applications during development
|
|
38
|
+
|
|
39
|
+
⚠️ IMPORTANT:
|
|
40
|
+
- Existing artifacts remain in their original scope
|
|
41
|
+
- Active Update Set should match the target scope for proper tracking
|
|
42
|
+
- Use create_update_set=true to ensure changes are tracked`,
|
|
43
|
+
// Metadata for tool discovery (not sent to LLM)
|
|
44
|
+
category: 'development',
|
|
45
|
+
subcategory: 'applications',
|
|
46
|
+
use_cases: ['app-development', 'scoped-apps', 'development', 'scope-management'],
|
|
47
|
+
complexity: 'intermediate',
|
|
48
|
+
frequency: 'medium',
|
|
49
|
+
// Permission enforcement
|
|
50
|
+
// Classification: WRITE - Modifies user preferences
|
|
51
|
+
permission: 'write',
|
|
52
|
+
allowedRoles: ['developer', 'admin'],
|
|
53
|
+
inputSchema: {
|
|
54
|
+
type: 'object',
|
|
55
|
+
properties: {
|
|
56
|
+
scope: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
description: 'Target scope to switch to. Can be "global", application sys_id, scope name (e.g., "x_myco_app"), or application name.'
|
|
59
|
+
},
|
|
60
|
+
create_update_set: {
|
|
61
|
+
type: 'boolean',
|
|
62
|
+
description: 'Create a new Update Set in the target scope (default: false). Useful when starting new development work.',
|
|
63
|
+
default: false
|
|
64
|
+
},
|
|
65
|
+
update_set_name: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
description: 'Name for the new Update Set (if create_update_set=true). Defaults to "Development: <app_name>"'
|
|
68
|
+
},
|
|
69
|
+
update_set_description: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
description: 'Description for the new Update Set (if create_update_set=true)'
|
|
72
|
+
},
|
|
73
|
+
servicenow_username: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
description: 'Optional: Also switch scope for this ServiceNow user (for UI visibility)'
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
required: ['scope']
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
async function execute(args, context) {
|
|
82
|
+
const { scope, create_update_set = false, update_set_name, update_set_description, servicenow_username } = args;
|
|
83
|
+
try {
|
|
84
|
+
const client = await (0, auth_js_1.getAuthenticatedClient)(context);
|
|
85
|
+
// Resolve the target scope
|
|
86
|
+
let targetApplicationId;
|
|
87
|
+
let targetApplicationName;
|
|
88
|
+
let targetApplicationScope;
|
|
89
|
+
let isGlobal = false;
|
|
90
|
+
if (scope === 'global' || scope === 'Global' || !scope) {
|
|
91
|
+
targetApplicationId = 'global';
|
|
92
|
+
targetApplicationName = 'Global';
|
|
93
|
+
targetApplicationScope = 'global';
|
|
94
|
+
isGlobal = true;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// Try to find by sys_id first
|
|
98
|
+
let appResponse = await client.get('/api/now/table/sys_app', {
|
|
99
|
+
params: {
|
|
100
|
+
sysparm_query: `sys_id=${scope}`,
|
|
101
|
+
sysparm_fields: 'sys_id,name,scope,version,short_description',
|
|
102
|
+
sysparm_limit: 1
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
// Try by scope name
|
|
106
|
+
if (!appResponse.data.result || appResponse.data.result.length === 0) {
|
|
107
|
+
appResponse = await client.get('/api/now/table/sys_app', {
|
|
108
|
+
params: {
|
|
109
|
+
sysparm_query: `scope=${scope}`,
|
|
110
|
+
sysparm_fields: 'sys_id,name,scope,version,short_description',
|
|
111
|
+
sysparm_limit: 1
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
// Try by name
|
|
116
|
+
if (!appResponse.data.result || appResponse.data.result.length === 0) {
|
|
117
|
+
appResponse = await client.get('/api/now/table/sys_app', {
|
|
118
|
+
params: {
|
|
119
|
+
sysparm_query: `name=${scope}`,
|
|
120
|
+
sysparm_fields: 'sys_id,name,scope,version,short_description',
|
|
121
|
+
sysparm_limit: 1
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
if (!appResponse.data.result || appResponse.data.result.length === 0) {
|
|
126
|
+
// List available applications for helpful error message
|
|
127
|
+
const availableApps = await client.get('/api/now/table/sys_app', {
|
|
128
|
+
params: {
|
|
129
|
+
sysparm_fields: 'name,scope',
|
|
130
|
+
sysparm_limit: 10,
|
|
131
|
+
sysparm_query: 'active=true'
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
const appList = availableApps.data.result
|
|
135
|
+
?.map((app) => ` - "${app.name}" (${app.scope})`)
|
|
136
|
+
.join('\n') || ' (no applications found)';
|
|
137
|
+
return (0, error_handler_js_1.createErrorResult)(`Application not found: "${scope}"\n\n` +
|
|
138
|
+
`Available options:\n` +
|
|
139
|
+
` - "global" (Global scope)\n` +
|
|
140
|
+
`${appList}\n\n` +
|
|
141
|
+
`Provide a valid application sys_id, scope name, or application name.`);
|
|
142
|
+
}
|
|
143
|
+
const app = appResponse.data.result[0];
|
|
144
|
+
targetApplicationId = app.sys_id;
|
|
145
|
+
targetApplicationName = app.name;
|
|
146
|
+
targetApplicationScope = app.scope;
|
|
147
|
+
}
|
|
148
|
+
// Switch scope for service account
|
|
149
|
+
const scopePrefResponse = await client.get('/api/now/table/sys_user_preference', {
|
|
150
|
+
params: {
|
|
151
|
+
sysparm_query: 'name=sys_scope^user=javascript:gs.getUserID()',
|
|
152
|
+
sysparm_limit: 1
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
if (scopePrefResponse.data.result && scopePrefResponse.data.result.length > 0) {
|
|
156
|
+
await client.patch(`/api/now/table/sys_user_preference/${scopePrefResponse.data.result[0].sys_id}`, { value: isGlobal ? 'global' : targetApplicationId });
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
await client.post('/api/now/table/sys_user_preference', {
|
|
160
|
+
name: 'sys_scope',
|
|
161
|
+
value: isGlobal ? 'global' : targetApplicationId,
|
|
162
|
+
user: 'javascript:gs.getUserID()'
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
// Build result
|
|
166
|
+
const result = {
|
|
167
|
+
scope_switched: true,
|
|
168
|
+
previous_scope: null, // We don't have this info easily
|
|
169
|
+
current_scope: {
|
|
170
|
+
sys_id: targetApplicationId,
|
|
171
|
+
name: targetApplicationName,
|
|
172
|
+
scope: targetApplicationScope,
|
|
173
|
+
is_global: isGlobal
|
|
174
|
+
},
|
|
175
|
+
update_set: null,
|
|
176
|
+
user_scope_switched: null
|
|
177
|
+
};
|
|
178
|
+
// Also switch for specific user if requested
|
|
179
|
+
if (servicenow_username) {
|
|
180
|
+
try {
|
|
181
|
+
// Get user sys_id
|
|
182
|
+
const userResponse = await client.get('/api/now/table/sys_user', {
|
|
183
|
+
params: {
|
|
184
|
+
sysparm_query: `user_name=${servicenow_username}`,
|
|
185
|
+
sysparm_fields: 'sys_id,user_name,name',
|
|
186
|
+
sysparm_limit: 1
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
if (userResponse.data.result && userResponse.data.result.length > 0) {
|
|
190
|
+
const userSysId = userResponse.data.result[0].sys_id;
|
|
191
|
+
const userScopePref = await client.get('/api/now/table/sys_user_preference', {
|
|
192
|
+
params: {
|
|
193
|
+
sysparm_query: `name=sys_scope^user=${userSysId}`,
|
|
194
|
+
sysparm_limit: 1
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
if (userScopePref.data.result && userScopePref.data.result.length > 0) {
|
|
198
|
+
await client.patch(`/api/now/table/sys_user_preference/${userScopePref.data.result[0].sys_id}`, { value: isGlobal ? 'global' : targetApplicationId });
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
await client.post('/api/now/table/sys_user_preference', {
|
|
202
|
+
name: 'sys_scope',
|
|
203
|
+
value: isGlobal ? 'global' : targetApplicationId,
|
|
204
|
+
user: userSysId
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
result.user_scope_switched = {
|
|
208
|
+
username: servicenow_username,
|
|
209
|
+
success: true
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
result.user_scope_switched = {
|
|
214
|
+
username: servicenow_username,
|
|
215
|
+
success: false,
|
|
216
|
+
error: 'User not found'
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
catch (userError) {
|
|
221
|
+
result.user_scope_switched = {
|
|
222
|
+
username: servicenow_username,
|
|
223
|
+
success: false,
|
|
224
|
+
error: userError.message
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
// Create Update Set if requested
|
|
229
|
+
if (create_update_set) {
|
|
230
|
+
try {
|
|
231
|
+
const usName = update_set_name || `Development: ${targetApplicationName}`;
|
|
232
|
+
const usDescription = update_set_description || `Development Update Set for ${targetApplicationName} (${targetApplicationScope})`;
|
|
233
|
+
const updateSetResponse = await client.post('/api/now/table/sys_update_set', {
|
|
234
|
+
name: usName,
|
|
235
|
+
description: usDescription,
|
|
236
|
+
state: 'in progress',
|
|
237
|
+
application: isGlobal ? 'global' : targetApplicationId
|
|
238
|
+
});
|
|
239
|
+
const updateSet = updateSetResponse.data.result;
|
|
240
|
+
// Set as current Update Set
|
|
241
|
+
const updateSetPref = await client.get('/api/now/table/sys_user_preference', {
|
|
242
|
+
params: {
|
|
243
|
+
sysparm_query: 'name=sys_update_set^user=javascript:gs.getUserID()',
|
|
244
|
+
sysparm_limit: 1
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
if (updateSetPref.data.result && updateSetPref.data.result.length > 0) {
|
|
248
|
+
await client.patch(`/api/now/table/sys_user_preference/${updateSetPref.data.result[0].sys_id}`, { value: updateSet.sys_id });
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
await client.post('/api/now/table/sys_user_preference', {
|
|
252
|
+
name: 'sys_update_set',
|
|
253
|
+
value: updateSet.sys_id,
|
|
254
|
+
user: 'javascript:gs.getUserID()'
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
result.update_set = {
|
|
258
|
+
sys_id: updateSet.sys_id,
|
|
259
|
+
name: updateSet.name,
|
|
260
|
+
description: updateSet.description,
|
|
261
|
+
state: 'in progress',
|
|
262
|
+
is_current: true,
|
|
263
|
+
application_scope: targetApplicationScope
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
catch (usError) {
|
|
267
|
+
result.update_set = {
|
|
268
|
+
created: false,
|
|
269
|
+
error: usError.message
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
// Build message
|
|
274
|
+
let message = `Switched to ${isGlobal ? 'Global' : `"${targetApplicationName}"`} scope (${targetApplicationScope})`;
|
|
275
|
+
if (result.update_set?.sys_id) {
|
|
276
|
+
message += `. Update Set "${result.update_set.name}" created and activated.`;
|
|
277
|
+
}
|
|
278
|
+
if (result.user_scope_switched?.success) {
|
|
279
|
+
message += ` Also switched for user: ${servicenow_username}.`;
|
|
280
|
+
}
|
|
281
|
+
result.message = message;
|
|
282
|
+
// Add guidance
|
|
283
|
+
result.guidance = isGlobal
|
|
284
|
+
? 'You are now in Global scope. Artifacts created will be available across all applications.'
|
|
285
|
+
: `You are now in "${targetApplicationName}" scope. Artifacts created will belong to this application.`;
|
|
286
|
+
if (!result.update_set) {
|
|
287
|
+
result.guidance += ' Consider creating an Update Set for change tracking.';
|
|
288
|
+
}
|
|
289
|
+
return (0, error_handler_js_1.createSuccessResult)(result);
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
return (0, error_handler_js_1.createErrorResult)(error.message);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
exports.version = '1.0.0';
|
|
296
|
+
exports.author = 'Snow-Flow Application Scope Enhancement';
|
|
297
|
+
//# sourceMappingURL=snow_switch_application_scope.js.map
|
package/dist/mcp/servicenow-mcp-unified/tools/applications/snow_switch_application_scope.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snow_switch_application_scope.js","sourceRoot":"","sources":["../../../../../src/mcp/servicenow-mcp-unified/tools/applications/snow_switch_application_scope.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAsEH,0BAyPC;AA5TD,kDAA8D;AAC9D,oEAAuF;AAE1E,QAAA,cAAc,GAAsB;IAC/C,IAAI,EAAE,+BAA+B;IACrC,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;2DAqB4C;IACzD,gDAAgD;IAChD,QAAQ,EAAE,aAAa;IACvB,WAAW,EAAE,cAAc;IAC3B,SAAS,EAAE,CAAC,iBAAiB,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,CAAC;IAChF,UAAU,EAAE,cAAc;IAC1B,SAAS,EAAE,QAAQ;IAEnB,yBAAyB;IACzB,oDAAoD;IACpD,UAAU,EAAE,OAAO;IACnB,YAAY,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC;IACpC,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uHAAuH;aACrI;YACD,iBAAiB,EAAE;gBACjB,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,0GAA0G;gBACvH,OAAO,EAAE,KAAK;aACf;YACD,eAAe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I,MAAM,CAAC,mBAAmB,EAAE,OAAO,EAAE,CAAC;YACxC,OAAO,IAAI,4BAA4B,mBAAmB,GAAG,CAAC;QAChE,CAAC;QACD,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QAEzB,eAAe;QACf,MAAM,CAAC,QAAQ,GAAG,QAAQ;YACxB,CAAC,CAAC,2FAA2F;YAC7F,CAAC,CAAC,mBAAmB,qBAAqB,6DAA6D,CAAC;QAE1G,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YACvB,MAAM,CAAC,QAAQ,IAAI,uDAAuD,CAAC;QAC7E,CAAC;QAED,OAAO,IAAA,sCAAmB,EAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,IAAA,oCAAiB,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC;AAEY,QAAA,OAAO,GAAG,OAAO,CAAC;AAClB,QAAA,MAAM,GAAG,yCAAyC,CAAC"}
|
package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_background_script.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* snow_execute_background_script - Execute background scripts with user confirmation
|
|
3
3
|
*
|
|
4
|
-
* Executes JavaScript background scripts in ServiceNow
|
|
5
|
-
* and user confirmation (unless autoConfirm=true).
|
|
4
|
+
* Executes JavaScript background scripts in ServiceNow using Fix Scripts.
|
|
5
|
+
* Includes security analysis and user confirmation (unless autoConfirm=true).
|
|
6
6
|
*
|
|
7
7
|
* ⚠️ CRITICAL: ALL SCRIPTS MUST BE ES5 ONLY!
|
|
8
8
|
* ServiceNow runs on Rhino engine - no const/let/arrow functions/template literals.
|
package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_background_script.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snow_execute_background_script.d.ts","sourceRoot":"","sources":["../../../../../src/mcp/servicenow-mcp-unified/tools/automation/snow_execute_background_script.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIzF,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"snow_execute_background_script.d.ts","sourceRoot":"","sources":["../../../../../src/mcp/servicenow-mcp-unified/tools/automation/snow_execute_background_script.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIzF,eAAO,MAAM,cAAc,EAAE,iBA+C5B,CAAC;AAEF,wBAAsB,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CA2OxF;AAqID,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,MAAM,4BAA4B,CAAC"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* snow_execute_background_script - Execute background scripts with user confirmation
|
|
4
4
|
*
|
|
5
|
-
* Executes JavaScript background scripts in ServiceNow
|
|
6
|
-
* and user confirmation (unless autoConfirm=true).
|
|
5
|
+
* Executes JavaScript background scripts in ServiceNow using Fix Scripts.
|
|
6
|
+
* Includes security analysis and user confirmation (unless autoConfirm=true).
|
|
7
7
|
*
|
|
8
8
|
* ⚠️ CRITICAL: ALL SCRIPTS MUST BE ES5 ONLY!
|
|
9
9
|
* ServiceNow runs on Rhino engine - no const/let/arrow functions/template literals.
|
|
@@ -15,7 +15,7 @@ const auth_js_1 = require("../../shared/auth.js");
|
|
|
15
15
|
const error_handler_js_1 = require("../../shared/error-handler.js");
|
|
16
16
|
exports.toolDefinition = {
|
|
17
17
|
name: 'snow_execute_background_script',
|
|
18
|
-
description: '🚨 REQUIRES USER CONFIRMATION (unless autoConfirm=true): Execute background script
|
|
18
|
+
description: '🚨 REQUIRES USER CONFIRMATION (unless autoConfirm=true): Execute background script using Fix Scripts (ES5 only)',
|
|
19
19
|
// Metadata for tool discovery (not sent to LLM)
|
|
20
20
|
category: 'automation',
|
|
21
21
|
subcategory: 'script-execution',
|
|
@@ -50,13 +50,18 @@ exports.toolDefinition = {
|
|
|
50
50
|
type: 'boolean',
|
|
51
51
|
description: '⚠️ DANGEROUS: Skip user confirmation and execute immediately',
|
|
52
52
|
default: false
|
|
53
|
+
},
|
|
54
|
+
timeout: {
|
|
55
|
+
type: 'number',
|
|
56
|
+
description: 'Timeout in milliseconds for polling execution results',
|
|
57
|
+
default: 30000
|
|
53
58
|
}
|
|
54
59
|
},
|
|
55
60
|
required: ['script', 'description']
|
|
56
61
|
}
|
|
57
62
|
};
|
|
58
63
|
async function execute(args, context) {
|
|
59
|
-
const { script, description, runAsUser, allowDataModification = false, autoConfirm = false } = args;
|
|
64
|
+
const { script, description, runAsUser, allowDataModification = false, autoConfirm = false, timeout = 30000 } = args;
|
|
60
65
|
try {
|
|
61
66
|
// ES5 validation
|
|
62
67
|
const es5Validation = validateES5(script);
|
|
@@ -71,27 +76,173 @@ async function execute(args, context) {
|
|
|
71
76
|
}
|
|
72
77
|
// Security analysis
|
|
73
78
|
const securityAnalysis = analyzeScriptSecurity(script);
|
|
74
|
-
// Auto-confirm mode - execute immediately
|
|
79
|
+
// Auto-confirm mode - execute immediately using Fix Scripts
|
|
75
80
|
if (autoConfirm === true) {
|
|
76
|
-
const executionId = `
|
|
81
|
+
const executionId = `bg_auto_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
82
|
+
const outputMarker = `SNOW_FLOW_BG_${executionId}`;
|
|
77
83
|
const client = await (0, auth_js_1.getAuthenticatedClient)(context);
|
|
78
|
-
//
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
// Wrap script with output capture
|
|
85
|
+
const wrappedScript = `
|
|
86
|
+
// Snow-Flow Background Script - ID: ${executionId}
|
|
87
|
+
// Description: ${description}
|
|
88
|
+
// Auto-confirmed execution
|
|
89
|
+
var __bgOutput = [];
|
|
90
|
+
var __bgStartTime = new GlideDateTime();
|
|
91
|
+
var __bgResult = null;
|
|
92
|
+
var __bgError = null;
|
|
93
|
+
|
|
94
|
+
// Capture gs methods
|
|
95
|
+
var __bgOrigPrint = gs.print;
|
|
96
|
+
var __bgOrigInfo = gs.info;
|
|
97
|
+
var __bgOrigWarn = gs.warn;
|
|
98
|
+
var __bgOrigError = gs.error;
|
|
99
|
+
|
|
100
|
+
gs.print = function(msg) { __bgOutput.push({level: 'print', msg: String(msg)}); __bgOrigPrint(msg); };
|
|
101
|
+
gs.info = function(msg) { __bgOutput.push({level: 'info', msg: String(msg)}); __bgOrigInfo(msg); };
|
|
102
|
+
gs.warn = function(msg) { __bgOutput.push({level: 'warn', msg: String(msg)}); __bgOrigWarn(msg); };
|
|
103
|
+
gs.error = function(msg) { __bgOutput.push({level: 'error', msg: String(msg)}); __bgOrigError(msg); };
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
gs.info('=== Snow-Flow Background Script Started ===');
|
|
107
|
+
gs.info('Description: ${description.replace(/'/g, "\\'")}');
|
|
108
|
+
|
|
109
|
+
__bgResult = (function() {
|
|
110
|
+
${script}
|
|
111
|
+
})();
|
|
112
|
+
|
|
113
|
+
gs.info('=== Snow-Flow Background Script Completed ===');
|
|
114
|
+
} catch(e) {
|
|
115
|
+
__bgError = e.toString();
|
|
116
|
+
gs.error('Background Script Error: ' + e.toString());
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Restore gs methods
|
|
120
|
+
gs.print = __bgOrigPrint;
|
|
121
|
+
gs.info = __bgOrigInfo;
|
|
122
|
+
gs.warn = __bgOrigWarn;
|
|
123
|
+
gs.error = __bgOrigError;
|
|
124
|
+
|
|
125
|
+
// Store result
|
|
126
|
+
var __bgEndTime = new GlideDateTime();
|
|
127
|
+
var __bgExecTime = Math.abs(GlideDateTime.subtract(__bgStartTime, __bgEndTime).getNumericValue());
|
|
128
|
+
|
|
129
|
+
var __bgResultObj = {
|
|
130
|
+
executionId: '${executionId}',
|
|
131
|
+
success: __bgError === null,
|
|
132
|
+
result: __bgResult,
|
|
133
|
+
error: __bgError,
|
|
134
|
+
output: __bgOutput,
|
|
135
|
+
executionTimeMs: __bgExecTime,
|
|
136
|
+
description: '${description.replace(/'/g, "\\'")}'
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
gs.setProperty('${outputMarker}', JSON.stringify(__bgResultObj));
|
|
140
|
+
gs.info('${outputMarker}:COMPLETE');
|
|
141
|
+
`;
|
|
142
|
+
// Create Scheduled Script Job
|
|
143
|
+
const jobName = `Snow-Flow BG Script - ${executionId}`;
|
|
144
|
+
const createResponse = await client.post('/api/now/table/sysauto_script', {
|
|
145
|
+
name: jobName,
|
|
146
|
+
script: wrappedScript,
|
|
82
147
|
active: true,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const response = await client.post('/api/now/table/sys_script', scriptData);
|
|
86
|
-
const scriptRecord = response.data.result;
|
|
87
|
-
return (0, error_handler_js_1.createSuccessResult)({
|
|
88
|
-
executed: true,
|
|
89
|
-
execution_id: executionId,
|
|
90
|
-
script_sys_id: scriptRecord.sys_id,
|
|
91
|
-
auto_confirmed: true,
|
|
92
|
-
security_analysis: securityAnalysis,
|
|
93
|
-
message: 'Script saved for execution - run manually from Background Scripts module'
|
|
148
|
+
run_type: 'on_demand',
|
|
149
|
+
conditional: false
|
|
94
150
|
});
|
|
151
|
+
if (!createResponse.data?.result?.sys_id) {
|
|
152
|
+
throw new error_handler_js_1.SnowFlowError(error_handler_js_1.ErrorType.SERVICENOW_API_ERROR, 'Failed to create scheduled script job for background execution', { details: createResponse.data });
|
|
153
|
+
}
|
|
154
|
+
const jobSysId = createResponse.data.result.sys_id;
|
|
155
|
+
// Create sys_trigger to execute immediately
|
|
156
|
+
const now = new Date();
|
|
157
|
+
const triggerTime = new Date(now.getTime() + 2000); // 2 seconds from now
|
|
158
|
+
const triggerTimeStr = triggerTime.toISOString().replace('T', ' ').substring(0, 19);
|
|
159
|
+
try {
|
|
160
|
+
await client.post('/api/now/table/sys_trigger', {
|
|
161
|
+
name: jobName,
|
|
162
|
+
next_action: triggerTimeStr,
|
|
163
|
+
trigger_type: 0, // Run Once
|
|
164
|
+
state: 0, // Ready
|
|
165
|
+
document: 'sysauto_script',
|
|
166
|
+
document_key: jobSysId,
|
|
167
|
+
claimed_by: '',
|
|
168
|
+
system_id: 'snow-flow'
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
catch (triggerError) {
|
|
172
|
+
// If trigger creation fails, job won't auto-execute
|
|
173
|
+
}
|
|
174
|
+
// Poll for execution results
|
|
175
|
+
const startTime = Date.now();
|
|
176
|
+
let result = null;
|
|
177
|
+
let attempts = 0;
|
|
178
|
+
const maxAttempts = Math.ceil(timeout / 2000);
|
|
179
|
+
while (Date.now() - startTime < timeout && attempts < maxAttempts) {
|
|
180
|
+
attempts++;
|
|
181
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
182
|
+
try {
|
|
183
|
+
const propResponse = await client.get('/api/now/table/sys_properties', {
|
|
184
|
+
params: {
|
|
185
|
+
sysparm_query: `name=${outputMarker}`,
|
|
186
|
+
sysparm_fields: 'value,sys_id',
|
|
187
|
+
sysparm_limit: 1
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
if (propResponse.data?.result?.[0]?.value) {
|
|
191
|
+
try {
|
|
192
|
+
result = JSON.parse(propResponse.data.result[0].value);
|
|
193
|
+
// Cleanup property
|
|
194
|
+
const propSysId = propResponse.data.result[0].sys_id;
|
|
195
|
+
if (propSysId) {
|
|
196
|
+
await client.delete(`/api/now/table/sys_properties/${propSysId}`).catch(() => { });
|
|
197
|
+
}
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
catch (parseErr) {
|
|
201
|
+
// Continue polling
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch (pollError) {
|
|
206
|
+
// Continue polling
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// Cleanup scheduled job
|
|
210
|
+
try {
|
|
211
|
+
await client.delete(`/api/now/table/sysauto_script/${jobSysId}`);
|
|
212
|
+
}
|
|
213
|
+
catch (cleanupError) {
|
|
214
|
+
// Ignore
|
|
215
|
+
}
|
|
216
|
+
if (result) {
|
|
217
|
+
return (0, error_handler_js_1.createSuccessResult)({
|
|
218
|
+
executed: true,
|
|
219
|
+
execution_id: executionId,
|
|
220
|
+
success: result.success,
|
|
221
|
+
result: result.result,
|
|
222
|
+
error: result.error,
|
|
223
|
+
output: result.output,
|
|
224
|
+
execution_time_ms: result.executionTimeMs,
|
|
225
|
+
auto_confirmed: true,
|
|
226
|
+
security_analysis: securityAnalysis
|
|
227
|
+
}, {
|
|
228
|
+
method: 'sysauto_script_with_trigger',
|
|
229
|
+
description
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
return (0, error_handler_js_1.createSuccessResult)({
|
|
234
|
+
executed: false,
|
|
235
|
+
execution_id: executionId,
|
|
236
|
+
scheduled_job_sys_id: jobSysId,
|
|
237
|
+
auto_confirmed: true,
|
|
238
|
+
security_analysis: securityAnalysis,
|
|
239
|
+
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.',
|
|
240
|
+
action_required: `Navigate to System Scheduler > Scheduled Jobs and run: ${jobName}`
|
|
241
|
+
}, {
|
|
242
|
+
method: 'scheduled_job_pending',
|
|
243
|
+
description
|
|
244
|
+
});
|
|
245
|
+
}
|
|
95
246
|
}
|
|
96
247
|
// Standard mode - return confirmation request
|
|
97
248
|
const confirmationPrompt = generateConfirmationPrompt({
|
package/dist/mcp/servicenow-mcp-unified/tools/automation/snow_execute_background_script.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snow_execute_background_script.js","sourceRoot":"","sources":["../../../../../src/mcp/servicenow-mcp-unified/tools/automation/snow_execute_background_script.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;
|
|
1
|
+
{"version":3,"file":"snow_execute_background_script.js","sourceRoot":"","sources":["../../../../../src/mcp/servicenow-mcp-unified/tools/automation/snow_execute_background_script.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAuDH,0BA2OC;AA/RD,kDAA8D;AAC9D,oEAAiH;AAEpG,QAAA,cAAc,GAAsB;IAC/C,IAAI,EAAE,gCAAgC;IACtC,WAAW,EAAE,iHAAiH;IAC9H,gDAAgD;IAChD,QAAQ,EAAE,YAAY;IACtB,WAAW,EAAE,kBAAkB;IAC/B,SAAS,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,CAAC;IACjD,UAAU,EAAE,UAAU;IACtB,SAAS,EAAE,MAAM;IAEjB,yBAAyB;IACzB,sEAAsE;IACtE,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,6EAA6E;aAC3F;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wEAAwE;aACtF;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,gEAAgE;aAC9E;YACD,qBAAqB,EAAE;gBACrB,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,0CAA0C;gBACvD,OAAO,EAAE,KAAK;aACf;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,8DAA8D;gBAC3E,OAAO,EAAE,KAAK;aACf;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uDAAuD;gBACp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SAAS,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC;IAE5F,MAAM,SAAS,GAAG;QAChB,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,IAAI;KACb,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC;IAErC,OAAO;;;sBAGa,WAAW;;EAE/B,SAAS,6BAA6B,gBAAgB,CAAC,SAAS;;sBAE5C,SAAS,IAAI,cAAc;4BACrB,qBAAqB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa;;;EAG7E,gBAAgB,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC5C,gCAAgC,gBAAgB,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,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,yBAAyB,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* snow_execute_script_sync - Synchronous script execution
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Executes server-side JavaScript in ServiceNow using Fix Scripts.
|
|
5
|
+
* Creates a temporary Fix Script, runs it, captures output, and cleans up.
|
|
5
6
|
*
|
|
6
7
|
* ⚠️ CRITICAL: ALL SCRIPTS MUST BE ES5 ONLY!
|
|
7
8
|
* ServiceNow runs on Rhino engine - no const/let/arrow functions/template literals.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snow_execute_script_sync.d.ts","sourceRoot":"","sources":["../../../../../src/mcp/servicenow-mcp-unified/tools/automation/snow_execute_script_sync.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"snow_execute_script_sync.d.ts","sourceRoot":"","sources":["../../../../../src/mcp/servicenow-mcp-unified/tools/automation/snow_execute_script_sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIzF,eAAO,MAAM,cAAc,EAAE,iBAkC5B,CAAC;AAEF,wBAAsB,OAAO,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAoNxF;AA6BD,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,MAAM,4BAA4B,CAAC"}
|