snow-flow 10.0.1-dev.442 → 10.0.1-dev.443

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "10.0.1-dev.442",
3
+ "version": "10.0.1-dev.443",
4
4
  "name": "snow-flow",
5
5
  "description": "Snow-Flow - ServiceNow Multi-Agent Development Framework powered by AI",
6
6
  "license": "Elastic-2.0",
@@ -406,7 +406,7 @@ async function resolveFlowId(client: any, flowId: string): Promise<string> {
406
406
 
407
407
  export const toolDefinition: MCPToolDefinition = {
408
408
  name: 'snow_manage_flow',
409
- description: 'Complete Flow Designer lifecycle: create flows/subflows, list, get details, update, activate, deactivate, delete and publish',
409
+ description: 'Complete Flow Designer lifecycle: create flows/subflows, add/update triggers and actions, list, get details, update, activate, deactivate, delete and publish. Use update_trigger to change an existing trigger (e.g. switch from record_created to record_create_or_update) without deleting the flow.',
410
410
  category: 'automation',
411
411
  subcategory: 'flow-designer',
412
412
  use_cases: ['flow-designer', 'automation', 'flow-management', 'subflow'],
@@ -419,8 +419,8 @@ export const toolDefinition: MCPToolDefinition = {
419
419
  properties: {
420
420
  action: {
421
421
  type: 'string',
422
- enum: ['create', 'create_subflow', 'list', 'get', 'update', 'activate', 'deactivate', 'delete', 'publish', 'add_trigger', 'add_action'],
423
- description: 'Action to perform'
422
+ enum: ['create', 'create_subflow', 'list', 'get', 'update', 'activate', 'deactivate', 'delete', 'publish', 'add_trigger', 'update_trigger', 'add_action'],
423
+ description: 'Action to perform. Use add_trigger/add_action to add new elements, update_trigger to change an existing trigger type/table/condition.'
424
424
  },
425
425
 
426
426
  flow_id: {
@@ -469,8 +469,7 @@ export const toolDefinition: MCPToolDefinition = {
469
469
  name: { type: 'string', description: 'Step name' },
470
470
  type: {
471
471
  type: 'string',
472
- enum: ['notification', 'field_update', 'create_record', 'script', 'log', 'wait', 'approval'],
473
- description: 'Action type'
472
+ description: 'Action type - looked up dynamically in sys_hub_action_type_snapshot by internal_name or name. Common values: log, create_record, update_record, send_notification, script, field_update, wait, create_approval'
474
473
  },
475
474
  inputs: { type: 'object', description: 'Step-specific input values' }
476
475
  }
@@ -1351,6 +1350,69 @@ export async function execute(args: any, context: ServiceNowContext): Promise<To
1351
1350
  : createErrorResult(addTrigResult.error || 'Failed to add trigger');
1352
1351
  }
1353
1352
 
1353
+ // ────────────────────────────────────────────────────────────────
1354
+ // UPDATE_TRIGGER — replace existing trigger(s) with a new one
1355
+ // ────────────────────────────────────────────────────────────────
1356
+ case 'update_trigger': {
1357
+ if (!args.flow_id) {
1358
+ throw new SnowFlowError(ErrorType.VALIDATION_ERROR, 'flow_id is required for update_trigger');
1359
+ }
1360
+ var updTrigFlowId = await resolveFlowId(client, args.flow_id);
1361
+ var updTrigType = args.trigger_type || 'record_create_or_update';
1362
+ var updTrigTable = args.table || '';
1363
+ var updTrigCondition = args.trigger_condition || '';
1364
+ var updTrigSteps: any = {};
1365
+
1366
+ // Step 1: Find existing trigger instances on this flow
1367
+ try {
1368
+ var existingTriggers = await client.get('/api/now/table/sys_hub_trigger_instance', {
1369
+ params: {
1370
+ sysparm_query: 'flow=' + updTrigFlowId,
1371
+ sysparm_fields: 'sys_id,name,type',
1372
+ sysparm_limit: 10
1373
+ }
1374
+ });
1375
+ var trigInstances = existingTriggers.data.result || [];
1376
+ updTrigSteps.existing_triggers = trigInstances.map((t: any) => ({ sys_id: t.sys_id, name: t.name, type: t.type }));
1377
+
1378
+ // Step 2: Delete existing triggers via GraphQL
1379
+ if (trigInstances.length > 0) {
1380
+ var deleteIds = trigInstances.map((t: any) => t.sys_id);
1381
+ try {
1382
+ await executeFlowPatchMutation(client, {
1383
+ flowId: updTrigFlowId,
1384
+ triggerInstances: { delete: deleteIds }
1385
+ }, 'triggerInstances { deletes __typename }');
1386
+ updTrigSteps.deleted = deleteIds;
1387
+ } catch (e: any) {
1388
+ updTrigSteps.delete_error = e.message;
1389
+ }
1390
+ }
1391
+ } catch (_) {
1392
+ updTrigSteps.lookup_error = 'Could not query existing triggers';
1393
+ }
1394
+
1395
+ // Step 3: Add the new trigger
1396
+ var updTrigResult = await addTriggerViaGraphQL(client, updTrigFlowId, updTrigType, updTrigTable, updTrigCondition);
1397
+ updTrigSteps.new_trigger = updTrigResult;
1398
+
1399
+ var updTrigSummary = summary();
1400
+ if (updTrigResult.success) {
1401
+ updTrigSummary
1402
+ .success('Trigger updated via GraphQL')
1403
+ .field('Flow', updTrigFlowId)
1404
+ .field('New Type', updTrigType)
1405
+ .field('Trigger ID', updTrigResult.triggerId || 'unknown');
1406
+ if (updTrigTable) updTrigSummary.field('Table', updTrigTable);
1407
+ } else {
1408
+ updTrigSummary.error('Failed to update trigger: ' + (updTrigResult.error || 'unknown'));
1409
+ }
1410
+
1411
+ return updTrigResult.success
1412
+ ? createSuccessResult({ action: 'update_trigger', steps: updTrigSteps }, {}, updTrigSummary.build())
1413
+ : createErrorResult(updTrigResult.error || 'Failed to update trigger');
1414
+ }
1415
+
1354
1416
  // ────────────────────────────────────────────────────────────────
1355
1417
  // ADD_ACTION
1356
1418
  // ────────────────────────────────────────────────────────────────