nowaikit 4.1.6 → 4.4.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.
Files changed (57) hide show
  1. package/README.md +3 -3
  2. package/dist/embed.d.ts +37 -0
  3. package/dist/embed.d.ts.map +1 -0
  4. package/dist/embed.js +75 -0
  5. package/dist/embed.js.map +1 -0
  6. package/dist/server.d.ts.map +1 -1
  7. package/dist/server.js +12 -2
  8. package/dist/server.js.map +1 -1
  9. package/dist/servicenow/client.d.ts +13 -0
  10. package/dist/servicenow/client.d.ts.map +1 -1
  11. package/dist/servicenow/client.js +52 -1
  12. package/dist/servicenow/client.js.map +1 -1
  13. package/dist/servicenow/instances.d.ts.map +1 -1
  14. package/dist/servicenow/instances.js +20 -0
  15. package/dist/servicenow/instances.js.map +1 -1
  16. package/dist/tools/blast-radius.d.ts +75 -0
  17. package/dist/tools/blast-radius.d.ts.map +1 -0
  18. package/dist/tools/blast-radius.js +185 -0
  19. package/dist/tools/blast-radius.js.map +1 -0
  20. package/dist/tools/catalog.d.ts.map +1 -1
  21. package/dist/tools/catalog.js +20 -3
  22. package/dist/tools/catalog.js.map +1 -1
  23. package/dist/tools/core.js +2 -2
  24. package/dist/tools/core.js.map +1 -1
  25. package/dist/tools/index.d.ts +147 -779
  26. package/dist/tools/index.d.ts.map +1 -1
  27. package/dist/tools/index.js +16 -2
  28. package/dist/tools/index.js.map +1 -1
  29. package/dist/tools/knowledge.d.ts.map +1 -1
  30. package/dist/tools/knowledge.js +9 -3
  31. package/dist/tools/knowledge.js.map +1 -1
  32. package/dist/tools/local-sync.d.ts +55 -0
  33. package/dist/tools/local-sync.d.ts.map +1 -0
  34. package/dist/tools/local-sync.js +210 -0
  35. package/dist/tools/local-sync.js.map +1 -0
  36. package/dist/tools/ml.d.ts +1 -1
  37. package/dist/tools/now-assist.d.ts +11 -145
  38. package/dist/tools/now-assist.d.ts.map +1 -1
  39. package/dist/tools/now-assist.js +50 -110
  40. package/dist/tools/now-assist.js.map +1 -1
  41. package/dist/tools/reporting.d.ts +55 -17
  42. package/dist/tools/reporting.d.ts.map +1 -1
  43. package/dist/tools/reporting.js +24 -15
  44. package/dist/tools/reporting.js.map +1 -1
  45. package/dist/tools-manifest.json +204 -95
  46. package/dist/transport/index.d.ts.map +1 -1
  47. package/dist/transport/index.js +18 -2
  48. package/dist/transport/index.js.map +1 -1
  49. package/dist/utils/permissions.d.ts +10 -5
  50. package/dist/utils/permissions.d.ts.map +1 -1
  51. package/dist/utils/permissions.js +43 -20
  52. package/dist/utils/permissions.js.map +1 -1
  53. package/dist/utils/request-context.d.ts +28 -0
  54. package/dist/utils/request-context.d.ts.map +1 -0
  55. package/dist/utils/request-context.js +49 -0
  56. package/dist/utils/request-context.js.map +1 -0
  57. package/package.json +8 -3
@@ -347,7 +347,7 @@
347
347
  },
348
348
  {
349
349
  "name": "natural_language_search",
350
- "description": "Search ServiceNow using plain English (experimental)",
350
+ "description": "Search ServiceNow using plain English",
351
351
  "inputSchema": {
352
352
  "type": "object",
353
353
  "properties": {
@@ -367,7 +367,7 @@
367
367
  },
368
368
  {
369
369
  "name": "natural_language_update",
370
- "description": "Update a record using natural language (experimental, requires WRITE_ENABLED=true)",
370
+ "description": "Update a record using natural language (requires WRITE_ENABLED=true)",
371
371
  "inputSchema": {
372
372
  "type": "object",
373
373
  "properties": {
@@ -1914,22 +1914,28 @@
1914
1914
  },
1915
1915
  {
1916
1916
  "name": "get_performance_analytics",
1917
- "description": "Get Performance Analytics widget data (requires PA plugin; latest release: /api/now/pa/widget/{sys_id})",
1917
+ "description": "Read Performance Analytics scorecard/indicator data (requires PA plugin; GET /api/now/pa/scorecards). Pass an indicator sys_id, or a PA widget sys_id to resolve its indicator.",
1918
1918
  "inputSchema": {
1919
1919
  "type": "object",
1920
1920
  "properties": {
1921
+ "indicator_sys_id": {
1922
+ "type": "string",
1923
+ "description": "sys_id of the PA indicator (pa_indicators)"
1924
+ },
1921
1925
  "widget_sys_id": {
1922
1926
  "type": "string",
1923
- "description": "sys_id of the PA widget"
1927
+ "description": "sys_id of a PA widget (pa_widgets); its indicator is resolved automatically"
1928
+ },
1929
+ "from": {
1930
+ "type": "string",
1931
+ "description": "Optional score-series start date (YYYY-MM-DD)"
1924
1932
  },
1925
- "time_range": {
1933
+ "to": {
1926
1934
  "type": "string",
1927
- "description": "Time range (e.g., \"last_30_days\", \"last_quarter\")"
1935
+ "description": "Optional score-series end date (YYYY-MM-DD)"
1928
1936
  }
1929
1937
  },
1930
- "required": [
1931
- "widget_sys_id"
1932
- ]
1938
+ "required": []
1933
1939
  }
1934
1940
  },
1935
1941
  {
@@ -2523,46 +2529,9 @@
2523
2529
  ]
2524
2530
  }
2525
2531
  },
2526
- {
2527
- "name": "generate_summary",
2528
- "description": "Generate an AI summary of any record using Now Assist (latest release: sn_assist/skill/summarize)",
2529
- "inputSchema": {
2530
- "type": "object",
2531
- "properties": {
2532
- "table": {
2533
- "type": "string",
2534
- "description": "Table name (e.g., \"incident\", \"change_request\")"
2535
- },
2536
- "sys_id": {
2537
- "type": "string",
2538
- "description": "System ID of the record"
2539
- }
2540
- },
2541
- "required": [
2542
- "table",
2543
- "sys_id"
2544
- ]
2545
- }
2546
- },
2547
- {
2548
- "name": "suggest_resolution",
2549
- "description": "Get AI-powered resolution suggestion for an incident based on similar past incidents",
2550
- "inputSchema": {
2551
- "type": "object",
2552
- "properties": {
2553
- "incident_sys_id": {
2554
- "type": "string",
2555
- "description": "System ID of the incident"
2556
- }
2557
- },
2558
- "required": [
2559
- "incident_sys_id"
2560
- ]
2561
- }
2562
- },
2563
2532
  {
2564
2533
  "name": "categorize_incident",
2565
- "description": "Use Predictive Intelligence to predict category, assignment group, and priority (latest release: LightGBM algorithm)",
2534
+ "description": "Suggest category, assignment group, and priority for an incident by analysing similar resolved incidents (Table API). Predictive Intelligence has no public REST prediction endpoint; for model-based scoring run PI on-record and read the predicted field.",
2566
2535
  "inputSchema": {
2567
2536
  "type": "object",
2568
2537
  "properties": {
@@ -2572,7 +2541,7 @@
2572
2541
  },
2573
2542
  "description": {
2574
2543
  "type": "string",
2575
- "description": "Optional full description for better accuracy"
2544
+ "description": "Optional full description (not required for the heuristic)"
2576
2545
  }
2577
2546
  },
2578
2547
  "required": [
@@ -2582,7 +2551,7 @@
2582
2551
  },
2583
2552
  {
2584
2553
  "name": "get_virtual_agent_topics",
2585
- "description": "List Virtual Agent topics available in the instance (latest release: streaming VA API)",
2554
+ "description": "List Virtual Agent topics available in the instance (sys_cs_topic)",
2586
2555
  "inputSchema": {
2587
2556
  "type": "object",
2588
2557
  "properties": {
@@ -2602,29 +2571,9 @@
2602
2571
  "required": []
2603
2572
  }
2604
2573
  },
2605
- {
2606
- "name": "trigger_agentic_playbook",
2607
- "description": "Invoke an Agentic Playbook — context-aware AI agents that complete tasks autonomously ",
2608
- "inputSchema": {
2609
- "type": "object",
2610
- "properties": {
2611
- "playbook_sys_id": {
2612
- "type": "string",
2613
- "description": "System ID of the Agentic Playbook"
2614
- },
2615
- "context": {
2616
- "type": "object",
2617
- "description": "Context key-value pairs to pass to the playbook"
2618
- }
2619
- },
2620
- "required": [
2621
- "playbook_sys_id"
2622
- ]
2623
- }
2624
- },
2625
2574
  {
2626
2575
  "name": "get_ms_copilot_topics",
2627
- "description": "List VA topics exposed to Microsoft Copilot 365 via Custom Engine Agent integration ",
2576
+ "description": "List the Virtual Agent topics (sys_cs_topic) that back a Microsoft Copilot integration. Copilot topic mapping itself is configured in Copilot Studio on the Microsoft side, not exposed via ServiceNow REST.",
2628
2577
  "inputSchema": {
2629
2578
  "type": "object",
2630
2579
  "properties": {
@@ -2636,31 +2585,6 @@
2636
2585
  "required": []
2637
2586
  }
2638
2587
  },
2639
- {
2640
- "name": "generate_work_notes",
2641
- "description": "Generate AI-drafted work notes for a record based on its current context",
2642
- "inputSchema": {
2643
- "type": "object",
2644
- "properties": {
2645
- "table": {
2646
- "type": "string",
2647
- "description": "Table name"
2648
- },
2649
- "sys_id": {
2650
- "type": "string",
2651
- "description": "System ID of the record"
2652
- },
2653
- "context": {
2654
- "type": "string",
2655
- "description": "Additional context to include in the draft"
2656
- }
2657
- },
2658
- "required": [
2659
- "table",
2660
- "sys_id"
2661
- ]
2662
- }
2663
- },
2664
2588
  {
2665
2589
  "name": "get_pi_models",
2666
2590
  "description": "List available Predictive Intelligence solutions (classification/similarity models)",
@@ -9390,5 +9314,190 @@
9390
9314
  "table"
9391
9315
  ]
9392
9316
  }
9317
+ },
9318
+ {
9319
+ "name": "blast_radius_table_configs",
9320
+ "description": "Blast radius: list every configuration artifact scoped to a table (business rules, client scripts, UI policies, ACLs, UI actions, data policies, dictionary fields). Run before altering or removing a table.",
9321
+ "inputSchema": {
9322
+ "type": "object",
9323
+ "properties": {
9324
+ "table": {
9325
+ "type": "string",
9326
+ "description": "Table name, e.g. \"incident\""
9327
+ },
9328
+ "limit": {
9329
+ "type": "number",
9330
+ "description": "Max records per artifact type (default 50)"
9331
+ }
9332
+ },
9333
+ "required": [
9334
+ "table"
9335
+ ]
9336
+ }
9337
+ },
9338
+ {
9339
+ "name": "blast_radius_field_references",
9340
+ "description": "Blast radius: find where a table field is referenced — its dictionary entry plus any scripts (business rules, script includes, client scripts, UI actions, widgets) that mention the field name. Run before renaming or removing a field.",
9341
+ "inputSchema": {
9342
+ "type": "object",
9343
+ "properties": {
9344
+ "table": {
9345
+ "type": "string",
9346
+ "description": "Table name, e.g. \"incident\""
9347
+ },
9348
+ "field": {
9349
+ "type": "string",
9350
+ "description": "Field (column) name, e.g. \"u_custom_field\""
9351
+ },
9352
+ "limit": {
9353
+ "type": "number",
9354
+ "description": "Max matches per source (default 50)"
9355
+ }
9356
+ },
9357
+ "required": [
9358
+ "table",
9359
+ "field"
9360
+ ]
9361
+ }
9362
+ },
9363
+ {
9364
+ "name": "blast_radius_script_dependents",
9365
+ "description": "Blast radius: find what references a script include / artifact by name — scans script-bearing config tables for textual use of the name. Run before renaming or deleting a Script Include, Script Action, etc.",
9366
+ "inputSchema": {
9367
+ "type": "object",
9368
+ "properties": {
9369
+ "name": {
9370
+ "type": "string",
9371
+ "description": "Artifact name to search for, e.g. a Script Include class name"
9372
+ },
9373
+ "limit": {
9374
+ "type": "number",
9375
+ "description": "Max matches per source (default 50)"
9376
+ }
9377
+ },
9378
+ "required": [
9379
+ "name"
9380
+ ]
9381
+ }
9382
+ },
9383
+ {
9384
+ "name": "blast_radius_update_sets",
9385
+ "description": "Blast radius: list the update sets that contain changes to an artifact (by name), so you know what is in-flight or already captured for promotion before you touch it.",
9386
+ "inputSchema": {
9387
+ "type": "object",
9388
+ "properties": {
9389
+ "name": {
9390
+ "type": "string",
9391
+ "description": "Artifact name (or partial) to match against captured updates"
9392
+ },
9393
+ "limit": {
9394
+ "type": "number",
9395
+ "description": "Max update records to scan (default 100)"
9396
+ }
9397
+ },
9398
+ "required": [
9399
+ "name"
9400
+ ]
9401
+ }
9402
+ },
9403
+ {
9404
+ "name": "blast_radius_property_usage",
9405
+ "description": "Blast radius: find scripts that read a system property (sys_properties) by name, plus the property record itself. Run before changing or removing a property.",
9406
+ "inputSchema": {
9407
+ "type": "object",
9408
+ "properties": {
9409
+ "name": {
9410
+ "type": "string",
9411
+ "description": "System property name, e.g. \"glide.ui.incident_reassignment_action\""
9412
+ },
9413
+ "limit": {
9414
+ "type": "number",
9415
+ "description": "Max matches per source (default 50)"
9416
+ }
9417
+ },
9418
+ "required": [
9419
+ "name"
9420
+ ]
9421
+ }
9422
+ },
9423
+ {
9424
+ "name": "list_supported_artifacts",
9425
+ "description": "Local sync: list the artifact types (tables) that support pull/push to local files and which fields sync for each.",
9426
+ "inputSchema": {
9427
+ "type": "object",
9428
+ "properties": {},
9429
+ "required": []
9430
+ }
9431
+ },
9432
+ {
9433
+ "name": "pull_artifact",
9434
+ "description": "Local sync: fetch an artifact's editable fields (e.g. a Service Portal widget's template/css/script). Returns the content inline; when NOWAIKIT_SYNC_DIR is set it also writes one file per field and returns the paths.",
9435
+ "inputSchema": {
9436
+ "type": "object",
9437
+ "properties": {
9438
+ "table": {
9439
+ "type": "string",
9440
+ "description": "Artifact table, e.g. \"sp_widget\", \"sys_script_include\""
9441
+ },
9442
+ "sys_id": {
9443
+ "type": "string",
9444
+ "description": "sys_id of the record"
9445
+ }
9446
+ },
9447
+ "required": [
9448
+ "table",
9449
+ "sys_id"
9450
+ ]
9451
+ }
9452
+ },
9453
+ {
9454
+ "name": "push_artifact",
9455
+ "description": "Local sync: write edited fields back to an artifact (requires WRITE_ENABLED=true). Pass fields inline as {field:value}; if omitted and NOWAIKIT_SYNC_DIR is set, reads them from the pulled files on disk.",
9456
+ "inputSchema": {
9457
+ "type": "object",
9458
+ "properties": {
9459
+ "table": {
9460
+ "type": "string",
9461
+ "description": "Artifact table"
9462
+ },
9463
+ "sys_id": {
9464
+ "type": "string",
9465
+ "description": "sys_id of the record"
9466
+ },
9467
+ "fields": {
9468
+ "type": "object",
9469
+ "description": "Optional map of {field: newValue} to update; defaults to the on-disk files under NOWAIKIT_SYNC_DIR"
9470
+ }
9471
+ },
9472
+ "required": [
9473
+ "table",
9474
+ "sys_id"
9475
+ ]
9476
+ }
9477
+ },
9478
+ {
9479
+ "name": "sync_status",
9480
+ "description": "Local sync: compare an artifact's current instance content against your local/edited content field-by-field and report which fields changed.",
9481
+ "inputSchema": {
9482
+ "type": "object",
9483
+ "properties": {
9484
+ "table": {
9485
+ "type": "string",
9486
+ "description": "Artifact table"
9487
+ },
9488
+ "sys_id": {
9489
+ "type": "string",
9490
+ "description": "sys_id of the record"
9491
+ },
9492
+ "fields": {
9493
+ "type": "object",
9494
+ "description": "Optional {field: localValue} to compare; defaults to files under NOWAIKIT_SYNC_DIR"
9495
+ }
9496
+ },
9497
+ "required": [
9498
+ "table",
9499
+ "sys_id"
9500
+ ]
9501
+ }
9393
9502
  }
9394
9503
  ]
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transport/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAIxE,OAAO,EAAoB,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAErD,wBAAgB,gBAAgB,IAAI,aAAa,CAIhD;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAqBpC;AAyFD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transport/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAIxE,OAAO,EAAoB,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAG7E,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAErD,wBAAgB,gBAAgB,IAAI,aAAa,CAIhD;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAqBpC;AAuGD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -2,6 +2,7 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
2
2
  import { logger } from '../utils/logging.js';
3
3
  import { VERSION, SERVER_NAME } from '../utils/version.js';
4
4
  import { createHttpServer } from './http-server.js';
5
+ import { isDelegatedAuthEnabled, parseDelegatedAuthHeaders, runWithDelegatedAuth } from '../utils/request-context.js';
5
6
  export function getTransportType() {
6
7
  const transport = (process.env.TRANSPORT || 'stdio').toLowerCase();
7
8
  if (transport === 'sse' || transport === 'http')
@@ -57,7 +58,9 @@ async function setupSseTransport(server, httpServer) {
57
58
  return;
58
59
  }
59
60
  const transport = sessions.get(sessionId);
60
- await transport.handlePostMessage(req, res);
61
+ // Pass the already-parsed body (the HTTP server drained the stream) — same
62
+ // reason as the streamable-HTTP path below.
63
+ await transport.handlePostMessage(req, res, req.body);
61
64
  }, true);
62
65
  // Health endpoint (no auth required)
63
66
  addHealthRoute(httpServer);
@@ -74,7 +77,20 @@ async function setupStreamableHttpTransport(server, httpServer) {
74
77
  });
75
78
  // Mount transport on /mcp
76
79
  httpServer.post('/mcp', async (req, res) => {
77
- await transport.handleRequest(req, res);
80
+ // DELEGATED_AUTH: bind the per-user identity/policy from headers for this
81
+ // request's lifetime (used by the ServiceNow client + permission checks).
82
+ // The HTTP server already drains + parses the POST body into req.body, so the
83
+ // stream is consumed by the time we get here. Pass that parsed body through to
84
+ // the MCP transport (3rd arg) — otherwise it re-reads an empty stream and the
85
+ // request fails with a JSON-RPC parse error (-32700).
86
+ const parsedBody = req.body;
87
+ if (isDelegatedAuthEnabled()) {
88
+ const ctx = parseDelegatedAuthHeaders(req.headers);
89
+ await runWithDelegatedAuth(ctx, () => transport.handleRequest(req, res, parsedBody));
90
+ }
91
+ else {
92
+ await transport.handleRequest(req, res, parsedBody);
93
+ }
78
94
  }, true);
79
95
  httpServer.get('/mcp', async (req, res) => {
80
96
  await transport.handleRequest(req, res);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transport/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAA2B,MAAM,kBAAkB,CAAC;AAI7E,MAAM,UAAU,gBAAgB;IAC9B,MAAM,SAAS,GAAG,CAAC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AAU,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;QAC3C,MAAM,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC,EAAE,IAAI,CAAC,CAAC;IAET,cAAc,CAAC,UAAU,CAAC,CAAC;IAC3B,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;AAC3B,CAAC;AAED,iDAAiD;AACjD,SAAS,cAAc,CAAC,UAA8B;IACpD,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC5C,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;QACzB,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC;QAC3D,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;YACrB,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,OAAO;YAChB,SAAS,EAAE,gBAAgB,EAAE;YAC7B,WAAW,EAAE,KAAK,CAAC,MAAM;YACzB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC,CAAC;IACN,CAAC,EAAE,KAAK,CAAC,CAAC;AACZ,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -7,7 +7,17 @@
7
7
  * Tier 3 – WRITE_ENABLED=true + SCRIPTING_ENABLED=true (scripts/changesets)
8
8
  * Tier AI – NOW_ASSIST_ENABLED=true (generative AI tools)
9
9
  * Tier ATF – ATF_ENABLED=true (test execution)
10
+ *
11
+ * Source of truth: process.env by default. When a request runs under a
12
+ * delegated-auth context (DELEGATED_AUTH mode, e.g. behind NowAIKit Gateway),
13
+ * the per-user policy on that context takes precedence — so capability is
14
+ * governed per user/request, not per server.
10
15
  */
16
+ export declare function isWriteEnabled(): boolean;
17
+ export declare function isCmdbWriteEnabled(): boolean;
18
+ export declare function isScriptingEnabled(): boolean;
19
+ export declare function isNowAssistEnabled(): boolean;
20
+ export declare function isAtfEnabled(): boolean;
11
21
  export declare function requireWrite(): void;
12
22
  export declare function requireCmdbWrite(): void;
13
23
  export declare function requireScripting(): void;
@@ -15,9 +25,4 @@ export declare function requireNowAssist(): void;
15
25
  export declare function requireAtf(): void;
16
26
  export declare function requireFluent(): void;
17
27
  export declare function isFluentEnabled(): boolean;
18
- export declare function isWriteEnabled(): boolean;
19
- export declare function isCmdbWriteEnabled(): boolean;
20
- export declare function isScriptingEnabled(): boolean;
21
- export declare function isNowAssistEnabled(): boolean;
22
- export declare function isAtfEnabled(): boolean;
23
28
  //# sourceMappingURL=permissions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/utils/permissions.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,wBAAgB,YAAY,IAAI,IAAI,CAOnC;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAQvC;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAQvC;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAOvC;AAED,wBAAgB,UAAU,IAAI,IAAI,CAOjC;AAED,wBAAgB,aAAa,IAAI,IAAI,CAOpC;AAED,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAED,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/utils/permissions.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,cAAc,IAAI,OAAO,CAIxC;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAI5C;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAI5C;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAI5C;AAED,wBAAgB,YAAY,IAAI,OAAO,CAItC;AAED,wBAAgB,YAAY,IAAI,IAAI,CAOnC;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAQvC;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAQvC;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAOvC;AAED,wBAAgB,UAAU,IAAI,IAAI,CAOjC;AAID,wBAAgB,aAAa,IAAI,IAAI,CAOpC;AAED,wBAAgB,eAAe,IAAI,OAAO,CAEzC"}
@@ -1,4 +1,5 @@
1
1
  import { ServiceNowError } from './errors.js';
2
+ import { getDelegatedAuth } from './request-context.js';
2
3
  /**
3
4
  * Permission tier utilities for NowAIKit tools.
4
5
  *
@@ -8,34 +9,71 @@ import { ServiceNowError } from './errors.js';
8
9
  * Tier 3 – WRITE_ENABLED=true + SCRIPTING_ENABLED=true (scripts/changesets)
9
10
  * Tier AI – NOW_ASSIST_ENABLED=true (generative AI tools)
10
11
  * Tier ATF – ATF_ENABLED=true (test execution)
12
+ *
13
+ * Source of truth: process.env by default. When a request runs under a
14
+ * delegated-auth context (DELEGATED_AUTH mode, e.g. behind NowAIKit Gateway),
15
+ * the per-user policy on that context takes precedence — so capability is
16
+ * governed per user/request, not per server.
11
17
  */
18
+ export function isWriteEnabled() {
19
+ const d = getDelegatedAuth();
20
+ if (d)
21
+ return d.flags?.write === true;
22
+ return process.env.WRITE_ENABLED === 'true';
23
+ }
24
+ export function isCmdbWriteEnabled() {
25
+ const d = getDelegatedAuth();
26
+ if (d)
27
+ return d.flags?.write === true && d.flags?.cmdbWrite === true;
28
+ return process.env.WRITE_ENABLED === 'true' && process.env.CMDB_WRITE_ENABLED === 'true';
29
+ }
30
+ export function isScriptingEnabled() {
31
+ const d = getDelegatedAuth();
32
+ if (d)
33
+ return d.flags?.write === true && d.flags?.scripting === true;
34
+ return process.env.WRITE_ENABLED === 'true' && process.env.SCRIPTING_ENABLED === 'true';
35
+ }
36
+ export function isNowAssistEnabled() {
37
+ const d = getDelegatedAuth();
38
+ if (d)
39
+ return d.flags?.nowAssist === true;
40
+ return process.env.NOW_ASSIST_ENABLED === 'true';
41
+ }
42
+ export function isAtfEnabled() {
43
+ const d = getDelegatedAuth();
44
+ if (d)
45
+ return d.flags?.atf === true;
46
+ return process.env.ATF_ENABLED === 'true';
47
+ }
12
48
  export function requireWrite() {
13
- if (process.env.WRITE_ENABLED !== 'true') {
49
+ if (!isWriteEnabled()) {
14
50
  throw new ServiceNowError('Write operations are disabled. Set WRITE_ENABLED=true to enable.', 'WRITE_NOT_ENABLED');
15
51
  }
16
52
  }
17
53
  export function requireCmdbWrite() {
18
54
  requireWrite();
19
- if (process.env.CMDB_WRITE_ENABLED !== 'true') {
55
+ if (!isCmdbWriteEnabled()) {
20
56
  throw new ServiceNowError('CMDB write operations are disabled. Set WRITE_ENABLED=true and CMDB_WRITE_ENABLED=true to enable.', 'CMDB_WRITE_NOT_ENABLED');
21
57
  }
22
58
  }
23
59
  export function requireScripting() {
24
60
  requireWrite();
25
- if (process.env.SCRIPTING_ENABLED !== 'true') {
61
+ if (!isScriptingEnabled()) {
26
62
  throw new ServiceNowError('Scripting operations are disabled. Set WRITE_ENABLED=true and SCRIPTING_ENABLED=true to enable.', 'SCRIPTING_NOT_ENABLED');
27
63
  }
28
64
  }
29
65
  export function requireNowAssist() {
30
- if (process.env.NOW_ASSIST_ENABLED !== 'true') {
66
+ if (!isNowAssistEnabled()) {
31
67
  throw new ServiceNowError('Now Assist / AI features are disabled. Set NOW_ASSIST_ENABLED=true to enable.', 'NOW_ASSIST_NOT_ENABLED');
32
68
  }
33
69
  }
34
70
  export function requireAtf() {
35
- if (process.env.ATF_ENABLED !== 'true') {
71
+ if (!isAtfEnabled()) {
36
72
  throw new ServiceNowError('ATF test execution is disabled. Set ATF_ENABLED=true to enable.', 'ATF_NOT_ENABLED');
37
73
  }
38
74
  }
75
+ // Fluent/now-sdk availability is a local server concern, not a per-user policy —
76
+ // it always reads from the environment.
39
77
  export function requireFluent() {
40
78
  if (process.env.FLUENT_ENABLED !== 'true') {
41
79
  throw new ServiceNowError('Fluent/now-sdk operations are disabled. Set FLUENT_ENABLED=true to enable.', 'FLUENT_NOT_ENABLED');
@@ -44,19 +82,4 @@ export function requireFluent() {
44
82
  export function isFluentEnabled() {
45
83
  return process.env.FLUENT_ENABLED === 'true';
46
84
  }
47
- export function isWriteEnabled() {
48
- return process.env.WRITE_ENABLED === 'true';
49
- }
50
- export function isCmdbWriteEnabled() {
51
- return process.env.WRITE_ENABLED === 'true' && process.env.CMDB_WRITE_ENABLED === 'true';
52
- }
53
- export function isScriptingEnabled() {
54
- return process.env.WRITE_ENABLED === 'true' && process.env.SCRIPTING_ENABLED === 'true';
55
- }
56
- export function isNowAssistEnabled() {
57
- return process.env.NOW_ASSIST_ENABLED === 'true';
58
- }
59
- export function isAtfEnabled() {
60
- return process.env.ATF_ENABLED === 'true';
61
- }
62
85
  //# sourceMappingURL=permissions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/utils/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;;;GASG;AAEH,MAAM,UAAU,YAAY;IAC1B,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,MAAM,EAAE,CAAC;QACzC,MAAM,IAAI,eAAe,CACvB,kEAAkE,EAClE,mBAAmB,CACpB,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,YAAY,EAAE,CAAC;IACf,IAAI,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B,MAAM,IAAI,eAAe,CACvB,+EAA+E,EAC/E,wBAAwB,CACzB,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;QACpB,MAAM,IAAI,eAAe,CACvB,iEAAiE,EACjE,iBAAiB,CAClB,CAAC;IACJ,CAAC;AACH,CAAC;AAED,iFAAiF;AACjF,wCAAwC;AACxC,MAAM,UAAU,aAAa;IAC3B,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM,EAAE,CAAC;QAC1C,MAAM,IAAI,eAAe,CACvB,4EAA4E,EAC5E,oBAAoB,CACrB,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,28 @@
1
+ export interface DelegatedFlags {
2
+ write?: boolean;
3
+ cmdbWrite?: boolean;
4
+ scripting?: boolean;
5
+ nowAssist?: boolean;
6
+ atf?: boolean;
7
+ }
8
+ export interface DelegatedAuth {
9
+ /** The user's ServiceNow access token (OBO-exchanged upstream). */
10
+ bearerToken?: string;
11
+ /** Instance URL the upstream resolved for this user (multi-instance routing). */
12
+ instanceUrl?: string;
13
+ /** Per-user capability policy resolved by the upstream gateway. */
14
+ flags?: DelegatedFlags;
15
+ /** Resolved tool package / persona (informational). */
16
+ toolPackage?: string;
17
+ /** User identifier (for audit/logging only). */
18
+ user?: string;
19
+ }
20
+ /** True when delegated-auth mode is switched on. */
21
+ export declare function isDelegatedAuthEnabled(): boolean;
22
+ /** Run `fn` with the given delegated-auth context bound for its async lifetime. */
23
+ export declare function runWithDelegatedAuth<T>(ctx: DelegatedAuth, fn: () => T): T;
24
+ /** The current request's delegated-auth context, or undefined outside one. */
25
+ export declare function getDelegatedAuth(): DelegatedAuth | undefined;
26
+ /** Build a delegated-auth context from inbound (lowercased) HTTP headers. */
27
+ export declare function parseDelegatedAuthHeaders(headers: Record<string, string | string[] | undefined>): DelegatedAuth;
28
+ //# sourceMappingURL=request-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/utils/request-context.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAID,oDAAoD;AACpD,wBAAgB,sBAAsB,IAAI,OAAO,CAEhD;AAED,mFAAmF;AACnF,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAE1E;AAED,8EAA8E;AAC9E,wBAAgB,gBAAgB,IAAI,aAAa,GAAG,SAAS,CAE5D;AAED,6EAA6E;AAC7E,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,GACrD,aAAa,CAmBf"}