@onlyflows/servicenow-mcp 2.3.0 → 2.4.0-rc.1

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 (131) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +206 -22
  3. package/dist/atf-result-cache.d.ts +2 -2
  4. package/dist/call-metrics.d.ts +11 -1
  5. package/dist/call-metrics.d.ts.map +1 -1
  6. package/dist/call-metrics.js +2 -0
  7. package/dist/call-metrics.js.map +1 -1
  8. package/dist/client.d.ts +10 -0
  9. package/dist/client.d.ts.map +1 -1
  10. package/dist/client.js +31 -3
  11. package/dist/client.js.map +1 -1
  12. package/dist/execution-context.d.ts +3 -3
  13. package/dist/execution-context.d.ts.map +1 -1
  14. package/dist/execution-context.js +7 -2
  15. package/dist/execution-context.js.map +1 -1
  16. package/dist/field-policy.d.ts +8 -0
  17. package/dist/field-policy.d.ts.map +1 -1
  18. package/dist/field-policy.js +239 -46
  19. package/dist/field-policy.js.map +1 -1
  20. package/dist/hidden-values.d.ts +368 -21
  21. package/dist/hidden-values.d.ts.map +1 -1
  22. package/dist/hidden-values.js +1050 -101
  23. package/dist/hidden-values.js.map +1 -1
  24. package/dist/http-observability.js +3 -1
  25. package/dist/http-observability.js.map +1 -1
  26. package/dist/inert-text.d.ts +27 -0
  27. package/dist/inert-text.d.ts.map +1 -0
  28. package/dist/inert-text.js +57 -0
  29. package/dist/inert-text.js.map +1 -0
  30. package/dist/policy-card.d.ts +1 -1
  31. package/dist/policy-card.d.ts.map +1 -1
  32. package/dist/policy-card.js +3 -1
  33. package/dist/policy-card.js.map +1 -1
  34. package/dist/setup-prompts.js +1 -0
  35. package/dist/setup-prompts.js.map +1 -1
  36. package/dist/setup.js +6 -0
  37. package/dist/setup.js.map +1 -1
  38. package/dist/tool-error.d.ts +39 -3
  39. package/dist/tool-error.d.ts.map +1 -1
  40. package/dist/tool-error.js +101 -2
  41. package/dist/tool-error.js.map +1 -1
  42. package/dist/tool-table-access.d.ts.map +1 -1
  43. package/dist/tool-table-access.js +5 -0
  44. package/dist/tool-table-access.js.map +1 -1
  45. package/dist/tools/aggregate.d.ts +8 -0
  46. package/dist/tools/aggregate.d.ts.map +1 -1
  47. package/dist/tools/aggregate.js +70 -11
  48. package/dist/tools/aggregate.js.map +1 -1
  49. package/dist/tools/atf-contracts.d.ts +9 -9
  50. package/dist/tools/catalog.d.ts +2 -2
  51. package/dist/tools/catalog.d.ts.map +1 -1
  52. package/dist/tools/catalog.js +9 -0
  53. package/dist/tools/catalog.js.map +1 -1
  54. package/dist/tools/envelope-text-fit.d.ts +20 -0
  55. package/dist/tools/envelope-text-fit.d.ts.map +1 -0
  56. package/dist/tools/envelope-text-fit.js +33 -0
  57. package/dist/tools/envelope-text-fit.js.map +1 -0
  58. package/dist/tools/flow-view-mermaid.d.ts.map +1 -1
  59. package/dist/tools/flow-view-mermaid.js +6 -13
  60. package/dist/tools/flow-view-mermaid.js.map +1 -1
  61. package/dist/tools/flow-view-module.js +1 -1
  62. package/dist/tools/get-module.js +1 -1
  63. package/dist/tools/history-contracts.d.ts +198 -0
  64. package/dist/tools/history-contracts.d.ts.map +1 -0
  65. package/dist/tools/history-contracts.js +317 -0
  66. package/dist/tools/history-contracts.js.map +1 -0
  67. package/dist/tools/history-module.d.ts +158 -0
  68. package/dist/tools/history-module.d.ts.map +1 -0
  69. package/dist/tools/history-module.js +937 -0
  70. package/dist/tools/history-module.js.map +1 -0
  71. package/dist/tools/history-renderers.d.ts +32 -0
  72. package/dist/tools/history-renderers.d.ts.map +1 -0
  73. package/dist/tools/history-renderers.js +154 -0
  74. package/dist/tools/history-renderers.js.map +1 -0
  75. package/dist/tools/index.d.ts +3 -3
  76. package/dist/tools/index.d.ts.map +1 -1
  77. package/dist/tools/index.js +31 -14
  78. package/dist/tools/index.js.map +1 -1
  79. package/dist/tools/platform-view-contracts.d.ts +4 -4
  80. package/dist/tools/platform-view-contracts.d.ts.map +1 -1
  81. package/dist/tools/platform-view-contracts.js +3 -0
  82. package/dist/tools/platform-view-contracts.js.map +1 -1
  83. package/dist/tools/platform-view-evaluate.d.ts +7 -2
  84. package/dist/tools/platform-view-evaluate.d.ts.map +1 -1
  85. package/dist/tools/platform-view-evaluate.js +44 -130
  86. package/dist/tools/platform-view-evaluate.js.map +1 -1
  87. package/dist/tools/platform-view-module.d.ts +12 -3
  88. package/dist/tools/platform-view-module.d.ts.map +1 -1
  89. package/dist/tools/platform-view-module.js +61 -16
  90. package/dist/tools/platform-view-module.js.map +1 -1
  91. package/dist/tools/platform-view-payload.d.ts +101 -0
  92. package/dist/tools/platform-view-payload.d.ts.map +1 -0
  93. package/dist/tools/platform-view-payload.js +302 -0
  94. package/dist/tools/platform-view-payload.js.map +1 -0
  95. package/dist/tools/platform-view-update-sets.d.ts +129 -0
  96. package/dist/tools/platform-view-update-sets.d.ts.map +1 -0
  97. package/dist/tools/platform-view-update-sets.js +1060 -0
  98. package/dist/tools/platform-view-update-sets.js.map +1 -0
  99. package/dist/tools/query-module.js +1 -1
  100. package/dist/tools/relationships-map.d.ts +59 -0
  101. package/dist/tools/relationships-map.d.ts.map +1 -0
  102. package/dist/tools/relationships-map.js +162 -0
  103. package/dist/tools/relationships-map.js.map +1 -0
  104. package/dist/tools/relationships-renderer.d.ts +22 -0
  105. package/dist/tools/relationships-renderer.d.ts.map +1 -0
  106. package/dist/tools/relationships-renderer.js +90 -0
  107. package/dist/tools/relationships-renderer.js.map +1 -0
  108. package/dist/tools/relationships.d.ts +37 -2
  109. package/dist/tools/relationships.d.ts.map +1 -1
  110. package/dist/tools/relationships.js +602 -183
  111. package/dist/tools/relationships.js.map +1 -1
  112. package/dist/tools/result-envelope.d.ts +314 -15
  113. package/dist/tools/result-envelope.d.ts.map +1 -1
  114. package/dist/tools/result-envelope.js +120 -19
  115. package/dist/tools/result-envelope.js.map +1 -1
  116. package/dist/tools/syslog.d.ts +1 -1
  117. package/dist/tools/table-hierarchy.d.ts +17 -0
  118. package/dist/tools/table-hierarchy.d.ts.map +1 -1
  119. package/dist/tools/table-hierarchy.js +41 -0
  120. package/dist/tools/table-hierarchy.js.map +1 -1
  121. package/dist/version.d.ts +1 -1
  122. package/dist/version.d.ts.map +1 -1
  123. package/dist/version.js +1 -1
  124. package/dist/version.js.map +1 -1
  125. package/docs/CLIENT-SETUP.md +2 -2
  126. package/docs/CROSS-CLIENT-RELEASE-MATRIX.md +2 -2
  127. package/docs/PRODUCTION-SECURITY.md +145 -2
  128. package/docs/RELEASE-VALIDATION.md +2 -2
  129. package/docs/TESTING-OAUTH.md +1 -1
  130. package/package.json +2 -2
  131. package/server.json +2 -2
package/CHANGELOG.md CHANGED
@@ -5,6 +5,29 @@ All notable changes to this project are documented here.
5
5
  The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.4.0-rc.1] — 2026-11-24
9
+
10
+ Release candidate for 2.4.0, published to the `next` dist-tag. It contains the
11
+ changes that follow, on top of 2.3.0.
12
+
13
+ ### Added
14
+
15
+ - `sn_history` shows one record's history, newest first: audited field changes with old and new values, comments and work notes, and the flows that ran on it, with one paging cursor per source. `sys_audit` and `sys_journal_field` must be granted by name, and values need read on `sys_db_object` and `sys_dictionary` as well (a `"*"` grant covers both); bind the tables to the tool with `servicenow-mcp-setup grant --read ... --tools sn_history` (on a `"*"` profile, only `sys_audit` and `sys_journal_field`, since naming a table binds it to the listed tools). A `max_response_bytes` too small for any page is refused as too large, saying to raise it. Entries follow field policy, journal fields come only through the journal source (by dictionary type, so a custom field of another type is an ordinary field), and values follow the field's type and are withheld when the types can't be read. Instance field ACLs don't apply to audit rows. See [docs/HISTORY.md](docs/HISTORY.md).
16
+ - `sn_platform_view` reads platform records behind one `view` argument: `update_sets`, `update_set`, `changes`, `batch`, `remote_update_sets`, `upgrade_skipped`, `scan_findings` and `evaluate`, which runs heuristic rules over an update set's changes. `changes` can show one change's XML, masked, where the profile's own `sys_update_xml` entry names `payload`. The payload view and `evaluate` need the field types; `"fieldTypes": { "dictionary": "not_required" }` doesn't apply to them. See [docs/PLATFORM-VIEW.md](docs/PLATFORM-VIEW.md).
17
+ - `sys_update_xml`, `sys_upgrade_history_log`, `scan_finding`, `scan_result` and `scan_check` are platform tables: a profile's `"*"` field-policy entry narrows them, their default reads leave out the XML, script and matched-code columns, and the policy card shows them as class `platform`.
18
+ - `sn_relationships` takes `map: true`, which adds `nodes`, `edges` (each relationship once, with its type) and a Mermaid `diagram` of the CIs it lists. The diagram draws the nearest CIs within the same limits as `sn_flow_view` diagrams and collapses the rest into one node; the map and the list keep within `max_response_bytes` (new on this tool, default 100,000, as for `sn_query`) and say what they left out. See the README section "CMDB relationship traversal".
19
+
20
+ ### Changed
21
+
22
+ - Process command-line fields in the CMDB are read only when a profile names them. `command`, `parameters` and `key_parameters` on `cmdb_running_process`, the application CI's `running_process_command` and `running_process_key_parameters`, and the command-line and argument columns of a few other CMDB tables (listed in the README), and the tables that extend them, follow the record payload column rules: no wildcard covers them, and each is read or written only where that table's own field-policy entry lists it in `readable` or `writable`. Until then it is refused by name and as a filter, order, group-by, aggregate or write field, and is left out of default, detailed and `fields=all` reads and write echoes. The refusal names the key to set. `tools/list` is unchanged.
23
+ - Read tools treat a table whose parent tables can't all be read from `sys_db_object` (a parent's row hidden from the integration user, or a chain deeper than 12 tables) the same as a table whose field types can't be read: the call is refused, or hides fields by name only when the profile sets `"fieldTypes": { "dictionary": "not_required" }`.
24
+
25
+ ### Fixed
26
+
27
+ - `sn_aggregate` with `group_by` pages correctly. ServiceNow ignores `sysparm_limit` and `sysparm_offset` on grouped statistics, so every `offset` returned the same first groups and a response cut for size gave no `next_offset`. The tool now reads the group list once, orders it, and pages it itself: `offset` is a group offset, `has_more` and `next_offset` are exact (also when a page is cut for size), and `total_groups` gives the number of groups. One call reads at most 5,000 groups, the first 5,000 in the instance's order by the group field; beyond that, or when groups are left out by response limits or field policy, the result is marked truncated, with a warning to group by a field with fewer distinct values, and has no total. A list too large for one response fails with the usual too-large error.
28
+ - `sn_relationships` walks breadth first, a level at a time, so every CI within the depth is found once, at its shortest depth, and the start CI is never listed. It had walked depth first with one visited set, so it could miss CIs and report depths that were not shortest, and listed the same CI more than once. Each level asks `cmdb_rel_ci` for many CIs at once, with the direction (and a `type` filter) in the query, reads no more than the requested page needs, and pages through a CI that has more relationships than a page holds; a hub with more than 100 relationships no longer loses the rest silently. `traversal_requests` counts every upstream request the call makes, and a limit that stops a walk sets `traversal_truncated` and warns, naming the CIs not fully read. `ci_name` matching more than one CI is now refused with the matches, so the retry names one by `sys_id`. Rows now carry `via`, and `meta.total` counts distinct CIs. Only CIs the profile can read are listed, with the fields its policy allows; relationships to other CIs are left out and counted.
29
+ - Read tools no longer answer "Access denied by policy" when field types can't be read for a reason outside this server's policy. The refusal now names the cause: the table doesn't exist, the instance refused the `sys_dictionary` or `sys_db_object` read (with the HTTP status), the read timed out or failed and can be retried (with the status), or a parent table couldn't be read. A timed-out or 5xx read is retried (the client retries a 502, 503 or 504 itself, and the server retries a timeout or other 5xx once), and such a failure is no longer remembered for 30 seconds. `sn_history` and `sn_platform_view` report the same causes. `metadata.timing` adds `field_types_ms`. These refusals are audited as a handler error with reason `field_types_unavailable` rather than as a policy rejection, unless this server's own policy made them. Values stay hidden in every case.
30
+
8
31
  ## [2.3.0] — 2026-11-17
9
32
 
10
33
  2.3.0 is the first stable release since 2.2.1. It contains everything published
package/README.md CHANGED
@@ -11,7 +11,7 @@ Built by [OnlyFlows](https://onlyflows.tech) · Published by [@onlyflowstech](ht
11
11
 
12
12
  ## Governed and safe for production
13
13
 
14
- The server exposes 24 tools over stdio. Every call runs inside controls that
14
+ The server exposes 26 tools over stdio. Every call runs inside controls that
15
15
  you configure and that no tool of this server can change:
16
16
 
17
17
  - **Per-profile table and field policy.** Each profile (a named ServiceNow
@@ -617,7 +617,7 @@ ServiceNow upstream can return HTTP 429 with an empty body, while this server's
617
617
 
618
618
  ## What the tools cover
619
619
 
620
- The registered catalog has 24 tools (see [Tools Reference](#tools-reference)):
620
+ The registered catalog has 26 tools (see [Tools Reference](#tools-reference)):
621
621
 
622
622
  | Area | Tools |
623
623
  |------|-------|
@@ -627,6 +627,7 @@ The registered catalog has 24 tools (see [Tools Reference](#tools-reference)):
627
627
  | CMDB and operations | `sn_relationships`, `sn_attach`, `sn_syslog`, `sn_codesearch`, `sn_discover` |
628
628
  | ATF | `sn_atf_author`, `sn_atf_run`, `sn_atf_results`, `sn_atf_readiness`, `sn_atf` |
629
629
  | Flow Designer (read-only) | `sn_flow_view` |
630
+ | Record history and platform views (read-only) | `sn_history`, `sn_platform_view` |
630
631
  | Profiles | `sn_profile` |
631
632
  | Natural language | `sn_nl` (currently policy-denied pending a typed access plan) |
632
633
 
@@ -748,20 +749,128 @@ in this section is needed to use this server.
748
749
 
749
750
  | Tool | Description |
750
751
  |------|-------------|
751
- | `sn_aggregate` | COUNT, AVG, MIN, MAX, SUM with grouping |
752
+ | `sn_aggregate` | COUNT, AVG, MIN, MAX, SUM with grouping; see [Grouped results](#sn_aggregate-grouped-results) |
752
753
  | `sn_schema` | Table field definitions, types, references |
753
754
  | `sn_health` | Instance version, cluster nodes, stuck jobs, key stats |
754
755
 
756
+ #### sn_aggregate grouped results
757
+
758
+ ServiceNow's Stats API does not page grouped results: it ignores
759
+ `sysparm_limit` and `sysparm_offset` and returns every group. With
760
+ `group_by`, `sn_aggregate` therefore makes one request, orders the groups
761
+ itself and pages them with `offset` and `limit`, so `offset` is a true group
762
+ offset and every page differs. The order is the tool's own: the groups'
763
+ values in code-unit order (the display value first with `display_value: "all"`),
764
+ the same on every call.
765
+
766
+ - **Paging.** `metadata.pagination` (and `has_more` and `next_offset` in the
767
+ data) say whether another page exists and where it starts; a page cut to fit
768
+ the response size continues at the first group not returned. Without
769
+ `group_by` the result is one row and is not paged.
770
+ - **Total.** `total_groups` is the number of groups when every group was read
771
+ and kept. A list with groups missing (cut at the cap, or left out by response
772
+ limits or field policy) has no total.
773
+ - **Cap.** One call reads at most 5,000 groups (a group is about 100 to 150
774
+ bytes, so that fits the 1 MiB upstream response limit). When more exist,
775
+ only the first 5,000 in the instance's order by the group field can be paged
776
+ (the same 5,000 whether or not the instance honours `sysparm_limit`):
777
+ `total_groups` is left out, `truncated` is true, `metadata.truncation` says
778
+ `record_limit`, and `warnings` says to group by a field with fewer distinct
779
+ values. If the
780
+ group list is too large to read in one response at all, the call fails with
781
+ the usual too-large error (lowering `limit` does not help, since the whole
782
+ list is read): group by a field with fewer distinct values, or use
783
+ `display_value: "false"`, which makes each group smaller. The
784
+ request always asks for up to 5,001 groups, even for a small `limit`: an
785
+ instance that does honour `sysparm_limit` then sends more groups than a small
786
+ page needs, a deliberate trade for one request and a stable order. The text
787
+ of a result gives the group total, or the cap warning, after the paging line.
788
+
755
789
  ### CMDB & Operations
756
790
 
757
791
  | Tool | Description |
758
792
  |------|-------------|
759
- | `sn_relationships` | CMDB CI graph traversal — upstream/downstream/both, configurable depth |
793
+ | `sn_relationships` | CMDB CI graph traversal, breadth first — upstream/downstream/both, configurable depth, optional map with a Mermaid diagram ([CMDB relationship traversal](#cmdb-relationship-traversal)) |
760
794
  | `sn_attach` | List attachments, return downloads as inline base64, and upload inline base64 content; never touches a host filesystem path |
761
795
  | `sn_syslog` | Query system logs with severity/source/time filters, newest first. `tail: true` starts a tail (the newest entries, oldest first, plus a `cursor`); each later call with `after_cursor` returns only the entries after it, oldest first, plus a new `cursor` ([Tailing the system log](#tailing-the-system-log)) |
762
796
  | `sn_codesearch` | Search business rules, script includes, client scripts, etc., with a snippet around each match ([Code search](#code-search)). Part of the default read grant, so a plain read grant on a code table allows it |
763
797
  | `sn_discover` | Discover tables, scoped apps, store apps, plugins |
764
798
 
799
+ #### CMDB relationship traversal
800
+
801
+ `sn_relationships` walks `cmdb_rel_ci` outward from one CI, level by level,
802
+ to `depth` (1 to 5, default `SN_REL_DEPTH` or 3).
803
+
804
+ - **Start.** Pass `sys_id`, or `ci_name`. A name that matches more than one CI
805
+ is refused with the matches (name, class, `sys_id`; up to 5, and a note when
806
+ there are more), so the retry names the one you mean. A unique name works.
807
+ - **Shortest depth, each CI once.** Every CI appears once, at its shortest
808
+ distance from the start, with the `type` and `direction` of the relationship
809
+ that first reached it and `via`, the sys_id of the CI it was reached from.
810
+ The start CI is never listed. Rows come nearest first; within a depth, in
811
+ the order of the frontier's chunks of 50 CIs, then of the relationship rows
812
+ (by `sys_id`), so a longer call lists the same CIs first.
813
+ - **Direction is in the query.** `downstream` reads relationships where the CI
814
+ is the parent, `upstream` where it is the child, `both` either. `impact: true`
815
+ is `upstream` only.
816
+ - **Filters.** `type` is a substring of the relationship type; relationships of
817
+ other types are skipped, so nothing is walked through them; the filter is
818
+ also sent in the query (`type.nameLIKE`) and checked on the rows. `class`
819
+ limits which CIs are listed, not which are walked through.
820
+ - **Paging.** `limit` and `offset` page the list. The walk reads only as much as
821
+ the page needs: it stops once the page and one more CI are known, which is
822
+ what makes `has_more` true, and it asks for no more relationship rows and
823
+ CIs than that takes. `meta.total` is the number of CIs found, so a lower
824
+ bound while `has_more` is true. `traversal_truncated` is set only when a limit
825
+ stopped the walk before the page was full or the depth was reached.
826
+ - **Relationship types.** Each relationship row is read with its ends as bare
827
+ sys_ids and its type's name (a dot-walk of `type`); no display value of a CI
828
+ is requested from `cmdb_rel_ci`.
829
+ - **Requests.** Each level reads its CIs in batches (50 CIs per `cmdb_rel_ci`
830
+ query, 100 per `cmdb_ci` read), paging through a CI with more relationships
831
+ than a page holds. `meta.traversal_requests` counts every upstream request
832
+ the call made: the start lookup, relationship pages and CI reads.
833
+
834
+ Limits on one call. A limit that stops a walk sets `meta.traversal_truncated`,
835
+ names the limit in `meta.truncated_by` (`cap`, its `max`, the `depth`, and
836
+ `unread_cis`), and adds a warning that names the CIs whose relationships were
837
+ not fully read.
838
+
839
+ | Limit | Value |
840
+ |-------|-------|
841
+ | Upstream requests (start lookup, relationship pages and CI reads together) | 50, of which 15 are kept for reading CIs |
842
+ | CIs read (the start CI aside) | 1,000 |
843
+ | Relationship rows read (a row read from each end counts twice) | 2,000, in pages of 500 |
844
+ | Upstream response bytes | The client allows 1 MiB of JSON per call. The walk keeps its own estimate and stops short of it (640 KiB for relationship rows, 180 KiB for CI reads). |
845
+ | Output | `limit` up to 1,000 CIs; `max_response_bytes` (default 100,000, 1,000 to 1,000,000, as for `sn_query`) bounds the whole response. Rows that do not fit are dropped from the end, with `next_offset` to continue; a budget too small for any result is refused, saying to raise it |
846
+
847
+ Relationships between two CIs that are both at the depth limit are not read.
848
+
849
+ **CIs the profile cannot read.** Relationship rows are not domain separated,
850
+ and the display values of their `parent` and `child` are not filtered by the
851
+ CI's own access rules, so nothing shown about a CI comes from them. The tool
852
+ reads each level's new CIs from `cmdb_ci`, where the instance applies the
853
+ profile user's ACLs and domain visibility, and the profile's field policy for
854
+ `cmdb_ci` decides which fields are shown: a `name` or `sys_class_name` the
855
+ profile cannot read is left out. A CI that read does not return is not shown
856
+ and is not walked through; `meta.unreadable_relationships` and a warning give
857
+ only a count. If `parent`, `child` or `type` of `cmdb_rel_ci`, or `sys_id` of
858
+ `cmdb_ci`, is not readable under field policy, the call is refused. `ci_name`
859
+ and `type` may be up to 255 characters and `class` up to 80. See
860
+ [Production security](docs/PRODUCTION-SECURITY.md#cmdb-relationships).
861
+
862
+ **Map.** `map: true` adds `nodes` (the start CI and the CIs listed), `edges`
863
+ (each relationship once, by its row's `sys_id`, with `parent`, `child` and
864
+ `type`) and `diagram`, a Mermaid `flowchart TD` with arrows from parent to
865
+ child. The map covers the page of CIs the call lists (nothing more is read for it), so `limit` and `offset`
866
+ page it, and the same field policy applies to every CI attribute in it. The
867
+ diagram draws the nearest 149 CIs at most (150 nodes, 300 edges, 20,000
868
+ characters) and collapses the rest into one node, saying how many in
869
+ `diagram.omitted_nodes`; the map takes at most 48% of `max_response_bytes` (about 48,000 bytes by
870
+ default), and `meta.map_omitted_cis` says how many listed CIs it had to leave
871
+ out. The shared `sn_flow_view` diagram grammar has no edge labels, so diagram
872
+ edges carry no relationship types; they are in `edges`.
873
+
765
874
  #### Tailing the system log
766
875
 
767
876
  `sn_syslog` can follow the log without re-reading it. The first call sends
@@ -815,6 +924,13 @@ stub and is **not published in 2.0** — it does not appear in `tools/list`. Use
815
924
  |------|-------------|
816
925
  | `sn_flow_view` | Show a flow or subflow as a Mermaid diagram, an outline and a structured graph: trigger, steps, branches, loops, error handling, input values under field policy, and called subflows to depth 3. Read-only through the Table API; never calls Flow Designer's internal API. See [docs/FLOW-VIEW.md](docs/FLOW-VIEW.md) |
817
926
 
927
+ ### Record history and platform views
928
+
929
+ | Tool | Description |
930
+ |------|-------------|
931
+ | `sn_history` | One record's history, newest first: audited field changes with old and new values, comments and work notes, and the flows that ran on it. Pages by a cursor per source. Values follow field policy and the field's dictionary type. `sys_audit` and `sys_journal_field` must be granted by name; see [docs/HISTORY.md](docs/HISTORY.md) |
932
+ | `sn_platform_view` | Read-only platform views chosen by `view`: `update_sets`, `update_set`, `changes` (with one change's XML, masked, when the profile names `payload`), `batch`, `remote_update_sets` (with preview problems), `upgrade_skipped`, `scan_findings` and `evaluate` (heuristic rules over an update set's changes). See [docs/PLATFORM-VIEW.md](docs/PLATFORM-VIEW.md) |
933
+
818
934
  ### Profile Management
819
935
 
820
936
  | Tool | Description |
@@ -1057,10 +1173,13 @@ cached just then, or the response is small and not kept), `bypass` (a `force_rec
1057
1173
  call made several cacheable reads with different outcomes, such as an
1058
1174
  `sn_codesearch` with no `table` over the code tables). It is absent when
1059
1175
  the call read no cache-eligible table. `timing` is `{ total_ms, upstream_ms,
1060
- watermark_ms }` in whole milliseconds, measured wall-clock: `total_ms` is the
1061
- whole tool call; `upstream_ms` is the time during which at least one request to
1062
- ServiceNow other than a watermark read was in flight (retry waits included);
1063
- `watermark_ms` is the same for the cache's watermark reads. Overlapping
1176
+ watermark_ms, field_types_ms }` in whole milliseconds, measured wall-clock:
1177
+ `total_ms` is the whole tool call; `upstream_ms` is the time during which at
1178
+ least one request to ServiceNow other than a watermark read was in flight
1179
+ (retry waits included); `watermark_ms` is the same for the cache's watermark
1180
+ reads; `field_types_ms` is the whole field-type lookup that runs before a
1181
+ field-policy tool (the memo check, its reads, and a retry with its pause), 0
1182
+ when the call made none, and its reads are not counted in `upstream_ms`. Overlapping
1064
1183
  requests are counted once, not summed, so each figure is at most `total_ms`,
1065
1184
  though the two can overlap each other and add up to more than it. A hit reports
1066
1185
  `upstream_ms: 0` and the watermark round trip it still costs. Callers that
@@ -1070,7 +1189,7 @@ caller's earlier read made with the same credential. Both fields hold only
1070
1189
  numbers and those four words, and appear whether or not the cache is on
1071
1190
  (`timing` always, `cache` only when a cacheable read happened). Only the server
1072
1191
  sets them; a tool cannot supply its own. Each tool's `outputSchema` grows by
1073
- about 320 characters for them.
1192
+ about 385 characters for them.
1074
1193
 
1075
1194
  If a table's watermark cannot be used, its reads go straight upstream, without
1076
1195
  a watermark request, for a while: 15 minutes when the cause persists (an
@@ -1115,9 +1234,10 @@ means the request must change (fewer `fields`, a lower `limit`, or a higher
1115
1234
  `max_response_bytes`; `sn_get` reads one row). The `hint` says which.
1116
1235
 
1117
1236
  This holds for `sn_query`, `sn_syslog`, `sn_schema`, `sn_relationships`,
1118
- `sn_codesearch`, `sn_discover`, `sn_attach` (list) and `sn_atf`, whose `offset`
1119
- is a row offset into the rows they return. Any other collection result that is cut to size
1120
- (for example `sn_aggregate`) reports `has_more: true` with no `next_offset`.
1237
+ `sn_codesearch`, `sn_discover`, `sn_attach` (list), `sn_atf` and `sn_aggregate`
1238
+ (grouped), whose `offset` is a row offset into the rows they return. Any other
1239
+ collection result that is cut to size reports `has_more: true` with no
1240
+ `next_offset`.
1121
1241
  A page that lost no rows to size is unchanged: `has_more` and `next_offset`
1122
1242
  come from the row after the page, and `next_offset` is `offset + limit`.
1123
1243
 
@@ -1375,9 +1495,13 @@ Fields of type `password`, `password2`, `masked` or `encrypted_text` are denied
1375
1495
  the same way, whatever their name, and a `sys_properties` value shows only for
1376
1496
  a known non-secret `type`. The types come from a cached `sys_dictionary` read,
1377
1497
  so the integration user needs read access to `sys_dictionary` and
1378
- `sys_db_object`; without it the tools refuse, unless the profile sets
1498
+ `sys_db_object`; without it the tools refuse, naming the cause (the table
1499
+ doesn't exist, the instance refused the read, it failed and can be retried, or
1500
+ a parent table couldn't be read), unless the profile sets
1379
1501
  `"fieldTypes": { "dictionary": "not_required" }` to hide by name only (see
1380
- [Production security](docs/PRODUCTION-SECURITY.md#password-type-fields)).
1502
+ [Production security](docs/PRODUCTION-SECURITY.md#password-type-fields)). A
1503
+ table whose parent tables can't all be read from `sys_db_object` (or that is
1504
+ more than 12 levels deep) is treated the same way.
1381
1505
 
1382
1506
  State it on a profile in `~/.servicenow-mcp/config.json`, beside
1383
1507
  `tableAccess`, in one of two forms. A profile that states both fails to load.
@@ -1466,7 +1590,7 @@ The same policy in the list form:
1466
1590
  }
1467
1591
  ```
1468
1592
 
1469
- **Which tables a `"*"` entry reaches.** Tables fall into four groups:
1593
+ **Which tables a `"*"` entry reaches.** Tables fall into five groups:
1470
1594
 
1471
1595
  - **ITSM tables:** `incident`, `change_request`, `problem`, `sc_request`,
1472
1596
  `sc_req_item`, `sc_task`, `task`, `cmdb_ci`, `cmdb_ci_server`,
@@ -1483,13 +1607,20 @@ The same policy in the list form:
1483
1607
  - **The 6 named-only tables:** `sys_audit`, `sys_journal_field`,
1484
1608
  `sys_history_line`, `sys_audit_delete`, `sys_attachment_doc`, `sys_email`. A
1485
1609
  `"*"` entry reaches them once the profile names them in `tableAccess` (below).
1486
-
1487
- On an ITSM table or a table without a built-in entry, named in the policy or
1488
- not, `readable` and `writable` each resolve from the table's own entry, then
1489
- the `"*"` entry, then every field. To keep one key open on such a table under
1490
- a narrowing `"*"` entry, state it on the table, such as
1491
- `"u_x": { "writable": "*" }`. The ITSM tables keep their built-in default
1492
- projections, trimmed to the effective `readable` set.
1610
+ - **The 5 platform tables:** `sys_update_xml`, `sys_upgrade_history_log`,
1611
+ `scan_finding`, `scan_result`, `scan_check`. A `"*"` entry reaches them,
1612
+ named in the field policy or not. Their default reads leave out the XML,
1613
+ script and matched-code columns. The policy card shows them as class
1614
+ `platform`.
1615
+
1616
+ On an ITSM table, a platform table or a table without a built-in entry, named
1617
+ in the policy or not, `readable` and `writable` each resolve from the table's
1618
+ own entry, then the `"*"` entry, then every field. To keep one key open on such
1619
+ a table under a narrowing `"*"` entry, state it on the table, such as
1620
+ `"u_x": { "writable": "*" }`. The ITSM and platform tables keep their built-in
1621
+ default projections, trimmed to the effective `readable` set. Naming a table
1622
+ narrows that table only, not the tables that extend it (the subclasses of
1623
+ `scan_check`, for example): narrow those with the `"*"` entry, or name each.
1493
1624
 
1494
1625
  A `"*"` entry never reaches a system table, named or not: each key comes from
1495
1626
  the table's own entry, or else covers every field. The system tables include
@@ -1602,6 +1733,59 @@ echoes. A named read is denied with:
1602
1733
  Read denied by policy: field "payload" on "sys_update_xml" holds record payloads, so a readable wildcard never covers it. List it explicitly in fieldPolicy.sys_update_xml.readable to allow this read.
1603
1734
  ```
1604
1735
 
1736
+ **Process command-line columns.** Some CMDB columns hold the command line a
1737
+ process was started with, or its arguments. They follow the same rules as the
1738
+ record payload columns: no wildcard covers them, not the open default of a
1739
+ profile with no field policy, a `"*"` entry, or `"*"` on the table's own entry.
1740
+ They are `command`, `parameters` and `key_parameters` on
1741
+ `cmdb_running_process`; `running_process_command` and
1742
+ `running_process_key_parameters` on `cmdb_ci_appl`; `command` on
1743
+ `cmdb_tcp_connection`, `cmdb_tcp_half`, `cmdb_ci_docker_container` and
1744
+ `cmdb_ci_oslv_image`; `command_line` on `cmdb_ci_appl_rabbitmq_cluster`,
1745
+ `cmdb_ci_appl_mongo_config_serv`, `cmdb_ci_appl_ca_id_man`,
1746
+ `cmdb_ci_appl_generic`, `cmdb_ci_appl_rabbitmq`, `cmdb_ci_appl_ca_ent_man`,
1747
+ `cmdb_ci_appl_dot_net`, `cmdb_ci_appl_mongos` and `cmdb_ci_appl_ca_dir_server`;
1748
+ `cmd_line` on `cmdb_ci_endpoint_mq_mem` and `cmdb_ci_endpoint_wmb_depend`;
1749
+ `args` on `cmdb_ci_endpoint_storf`, `cmdb_ci_endpoint_xenapp_citrx` and
1750
+ `cmdb_ci_endpoint_app`; and `app_args` on `cmdb_ci_appl_citrix_app`.
1751
+ `running_process_command` and `running_process_key_parameters` are also covered
1752
+ by name on every table.
1753
+
1754
+ Each is read only where it is named in that table's own `readable`, and written
1755
+ only where it is named in its own `writable`. Until then it is refused by name
1756
+ and as a filter, order, group-by, aggregate or write field, and is left out of
1757
+ `fields=all`, detailed and default reads and write echoes. `sn_history` leaves
1758
+ their audit rows out even where the profile opened them. A dotted name such as
1759
+ `ref_cmdb_running_process.command` or `parent.command` is never accepted as a
1760
+ field by any read tool.
1761
+
1762
+ A table that extends a listed table has its columns too, and only its own entry
1763
+ opens them, not the parent's (so `cmdb_ci_appl` covers every application class,
1764
+ and `cmdb_ci_oslv_image` covers `cmdb_ci_docker_image`). A database view that
1765
+ joins a listed table (or a table with payload columns) has those columns under
1766
+ the view's prefix for that table (`rp_command` for a table joined as `rp`),
1767
+ under the same rules. Both come from the same `sys_db_object` and
1768
+ `sys_db_view_table` reads as the field types, so a table or view whose chain or
1769
+ joined tables can't be read is refused.
1770
+
1771
+ On a profile with `"fieldTypes": { "dictionary": "not_required" }`, such a table
1772
+ or view is not refused. Where its chain or joined tables can be read, it is
1773
+ guarded as above. Where they can't, only exact names apply: the tables in the
1774
+ list above, the out-of-the-box subclass `cmdb_ci_docker_image`, the out-of-the-box
1775
+ views `related_servers` (`rp_command`, `rp_parameters`, `rp_key_parameters`),
1776
+ `classified_apps` (`p_command`, `p_parameters`, `p_key_parameters`,
1777
+ `a_running_process_command`, `a_running_process_key_parameters`),
1778
+ `application_on_servers` and `samp_lrb_to_instances_view` (both
1779
+ `appl_running_process_command` and `appl_running_process_key_parameters`), and
1780
+ the two names that apply to every table. A custom subclass or custom view is
1781
+ covered through its chain or joined tables, so where those can't be read under
1782
+ `not_required` it is covered by the names that apply to every table only. A
1783
+ named read is denied with:
1784
+
1785
+ ```text
1786
+ Read denied by policy: field "command" on "cmdb_running_process" holds process command lines, so a readable wildcard never covers it. List it explicitly in fieldPolicy.cmdb_running_process.readable to allow this read.
1787
+ ```
1788
+
1605
1789
  **`readable: []` and `writable: []`.** `readable: []` makes a table
1606
1790
  write-only: writes succeed and return only `sys_id`, reads are denied, and
1607
1791
  `sn_batch` cannot run there. `writable: []` blocks writes. To make a table
@@ -9,8 +9,8 @@ export declare const atfRunSummarySchema: z.ZodObject<{
9
9
  error: "error";
10
10
  success: "success";
11
11
  pending: "pending";
12
- running: "running";
13
12
  failure: "failure";
13
+ running: "running";
14
14
  skipped: "skipped";
15
15
  canceled: "canceled";
16
16
  success_with_warnings: "success_with_warnings";
@@ -28,8 +28,8 @@ export declare const atfRunSummarySchema: z.ZodObject<{
28
28
  error: "error";
29
29
  success: "success";
30
30
  pending: "pending";
31
- running: "running";
32
31
  failure: "failure";
32
+ running: "running";
33
33
  skipped: "skipped";
34
34
  canceled: "canceled";
35
35
  success_with_warnings: "success_with_warnings";
@@ -22,10 +22,20 @@ export type CacheOutcome = "hit" | "miss" | "bypass";
22
22
  export type CacheStatus = CacheOutcome | "mixed";
23
23
  /** Which kind of ServiceNow request is being timed. */
24
24
  export type RequestLane = "upstream" | "watermark";
25
+ /**
26
+ * The lanes a call's clocks count: the two kinds of request, and the field
27
+ * types lookup the dispatcher makes before a field-policy tool runs.
28
+ */
29
+ export type TimedLane = RequestLane | "field_types";
25
30
  export interface CallTiming {
26
31
  readonly total_ms: number;
27
32
  readonly upstream_ms: number;
28
33
  readonly watermark_ms: number;
34
+ /**
35
+ * The whole field types lookup (memo hit, reads, retry and its pause), 0
36
+ * when the call made none. Its own reads are not in `upstream_ms`.
37
+ */
38
+ readonly field_types_ms: number;
29
39
  }
30
40
  export interface CallMetricsSnapshot {
31
41
  /** Absent when the call made no cacheable read. */
@@ -36,7 +46,7 @@ export declare class CallMetrics {
36
46
  #private;
37
47
  recordCache(outcome: CacheOutcome): void;
38
48
  /** Run one request, counting its time against `lane` whether it settles or throws. */
39
- measure<T>(lane: RequestLane, request: () => Promise<T>): Promise<T>;
49
+ measure<T>(lane: TimedLane, request: () => Promise<T>): Promise<T>;
40
50
  snapshot(): CallMetricsSnapshot;
41
51
  }
42
52
  //# sourceMappingURL=call-metrics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"call-metrics.d.ts","sourceRoot":"","sources":["../src/call-metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,yCAAyC;AACzC,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAErD,4EAA4E;AAC5E,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,OAAO,CAAC;AAEjD,uDAAuD;AACvD,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,WAAW,CAAC;AAEnD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B;AA4BD,qBAAa,WAAW;;IAQtB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAIxC,sFAAsF;IAChF,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAS1E,QAAQ,IAAI,mBAAmB;CAiBhC"}
1
+ {"version":3,"file":"call-metrics.d.ts","sourceRoot":"","sources":["../src/call-metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,yCAAyC;AACzC,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAErD,4EAA4E;AAC5E,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,OAAO,CAAC;AAEjD,uDAAuD;AACvD,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,WAAW,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,aAAa,CAAC;AAEpD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B;AA4BD,qBAAa,WAAW;;IAStB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAIxC,sFAAsF;IAChF,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IASxE,QAAQ,IAAI,mBAAmB;CAkBhC"}
@@ -51,6 +51,7 @@ class CallMetrics {
51
51
  #clocks = {
52
52
  upstream: new BusyClock(),
53
53
  watermark: new BusyClock(),
54
+ field_types: new BusyClock(),
54
55
  };
55
56
  recordCache(outcome) {
56
57
  this.#outcomes.add(outcome);
@@ -78,6 +79,7 @@ class CallMetrics {
78
79
  total_ms: wholeMs(now - this.#startedAt),
79
80
  upstream_ms: wholeMs(this.#clocks.upstream.read(now)),
80
81
  watermark_ms: wholeMs(this.#clocks.watermark.read(now)),
82
+ field_types_ms: wholeMs(this.#clocks.field_types.read(now)),
81
83
  },
82
84
  };
83
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"call-metrics.js","sourceRoot":"","sources":["../src/call-metrics.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAuBH;;;GAGG;AACH,MAAM,SAAS;IACb,OAAO,GAAG,CAAC,CAAC;IACZ,UAAU,GAAG,CAAC,CAAC;IACf,YAAY,GAAG,CAAC,CAAC;IAEjB,KAAK;QACH,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC;YAAE,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAC5D,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;QAClB,IAAI,IAAI,GAAG,KAAK,CAAC;QACjB,OAAO,GAAG,EAAE;YACV,IAAI,IAAI;gBAAE,OAAO;YACjB,IAAI,GAAG,IAAI,CAAC;YACZ,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;YAClB,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC;gBAAE,IAAI,CAAC,YAAY,IAAI,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC;QACnF,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,GAAW;QACd,OAAO,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,CAAC;CACF;AAED,MAAa,WAAW;IACb,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAC/B,SAAS,GAAG,IAAI,GAAG,EAAgB,CAAC;IACpC,OAAO,GAA6C;QAC3D,QAAQ,EAAE,IAAI,SAAS,EAAE;QACzB,SAAS,EAAE,IAAI,SAAS,EAAE;KAC3B,CAAC;IAEF,WAAW,CAAC,OA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C;AAED,SAAS,OAAO,CAAC,KAAa;IAC5B,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC"}
package/dist/client.d.ts CHANGED
@@ -77,6 +77,8 @@ export declare const MAX_ERROR_RESPONSE_BYTES: number;
77
77
  /** Guidance carried by 401 errors on basic-auth profiles (fixed text). */
78
78
  export { BASIC_AUTH_401_HINT };
79
79
  export declare const DEFAULT_MAX_CONCURRENT_REQUESTS = 4;
80
+ /** Statuses the client itself tries again (twice, with backoff) before it gives up. */
81
+ export declare const CLIENT_RETRIED_STATUSES: readonly number[];
80
82
  /**
81
83
  * Bind one immutable execution-context signal and fresh atomic upstream byte
82
84
  * budgets to cached clients without adding mutable state to the client/cache.
@@ -152,6 +154,14 @@ export declare class ServiceNowClient {
152
154
  export declare function createServiceNowOperations(client: ServiceNowOperations): ServiceNowOperations;
153
155
  /** True when a request failed because its caller cancelled it. */
154
156
  export declare function isServiceNowRequestCancellation(error: unknown): boolean;
157
+ /** The running call's cancellation signal, or undefined outside a call. */
158
+ export declare function currentServiceNowRequestSignal(): AbortSignal | undefined;
159
+ /**
160
+ * Wait `ms`, as a pause between two attempts of one read. It ends at once with
161
+ * the request-cancellation error when `signal` (default: the running call's)
162
+ * aborts, and never starts when it already has.
163
+ */
164
+ export declare function pauseUnlessServiceNowRequestCancelled(ms: number, signal?: AbortSignal | undefined): Promise<void>;
155
165
  /**
156
166
  * Parse a Retry-After header value into milliseconds.
157
167
  * Supports both delta-seconds ("120") and HTTP-date forms.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAsD,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAEtG,OAAO,EAA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GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAW1E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB,MAAM,CAOR"}
package/dist/client.js CHANGED
@@ -18,12 +18,14 @@
18
18
  * @module client
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.ServiceNowClient = exports.DEFAULT_MAX_CONCURRENT_REQUESTS = exports.BASIC_AUTH_401_HINT = exports.MAX_ERROR_RESPONSE_BYTES = exports.DEFAULT_MAX_JSON_RESPONSE_BYTES = exports.MAX_CUMULATIVE_RAW_RESPONSE_BYTES = exports.MAX_CUMULATIVE_UPSTREAM_JSON_BYTES = exports.MAX_RETRY_DELAY_MS = exports.DEFAULT_TIMEOUT_MS = exports.isServiceNowResponseTooLarge = exports.ServiceNowResponseTooLargeError = void 0;
21
+ exports.ServiceNowClient = exports.CLIENT_RETRIED_STATUSES = exports.DEFAULT_MAX_CONCURRENT_REQUESTS = exports.BASIC_AUTH_401_HINT = exports.MAX_ERROR_RESPONSE_BYTES = exports.DEFAULT_MAX_JSON_RESPONSE_BYTES = exports.MAX_CUMULATIVE_RAW_RESPONSE_BYTES = exports.MAX_CUMULATIVE_UPSTREAM_JSON_BYTES = exports.MAX_RETRY_DELAY_MS = exports.DEFAULT_TIMEOUT_MS = exports.isServiceNowResponseTooLarge = exports.ServiceNowResponseTooLargeError = void 0;
22
22
  exports.runWithServiceNowRequestSignal = runWithServiceNowRequestSignal;
23
23
  exports.recordCacheOutcome = recordCacheOutcome;
24
24
  exports.asWatermarkRead = asWatermarkRead;
25
25
  exports.createServiceNowOperations = createServiceNowOperations;
26
26
  exports.isServiceNowRequestCancellation = isServiceNowRequestCancellation;
27
+ exports.currentServiceNowRequestSignal = currentServiceNowRequestSignal;
28
+ exports.pauseUnlessServiceNowRequestCancelled = pauseUnlessServiceNowRequestCancelled;
27
29
  exports.parseRetryAfterMs = parseRetryAfterMs;
28
30
  exports.retryDelayMs = retryDelayMs;
29
31
  const atf_form_js_1 = require("./atf-form.js");
@@ -48,6 +50,8 @@ const DEFAULT_BASE_RETRY_DELAY_MS = 500;
48
50
  exports.DEFAULT_MAX_CONCURRENT_REQUESTS = 4;
49
51
  const MAX_CONFIGURED_CONCURRENT_REQUESTS = 32;
50
52
  const RETRYABLE_STATUSES = [429, 502, 503, 504];
53
+ /** Statuses the client itself tries again (twice, with backoff) before it gives up. */
54
+ exports.CLIENT_RETRIED_STATUSES = Object.freeze([...RETRYABLE_STATUSES]);
51
55
  const REQUEST_SCOPE = new node_async_hooks_1.AsyncLocalStorage();
52
56
  /**
53
57
  * Bind one immutable execution-context signal and fresh atomic upstream byte
@@ -353,12 +357,12 @@ class ServiceNowClient {
353
357
  buildHttpError(method, status, headers) {
354
358
  const classification = classifyHttpFailure(status, method);
355
359
  if (status === 401 && this.#auth.kind === "basic") {
356
- return (0, tool_error_js_1.createBasicAuthRestrictedError)();
360
+ return (0, tool_error_js_1.recordTrustedHttpStatus)((0, tool_error_js_1.createBasicAuthRestrictedError)(), status);
357
361
  }
358
362
  const retryAfterSeconds = classification.retry === "retry_later"
359
363
  ? (0, tool_error_js_1.boundedRetryAfterSeconds)(parseRetryAfterMs(headers.get("retry-after")))
360
364
  : undefined;
361
- return (0, tool_error_js_1.createToolError)(classification.category, classification.retry, retryAfterSeconds);
365
+ return (0, tool_error_js_1.recordTrustedHttpStatus)((0, tool_error_js_1.createToolError)(classification.category, classification.retry, retryAfterSeconds), status);
362
366
  }
363
367
  }
364
368
  exports.ServiceNowClient = ServiceNowClient;
@@ -539,6 +543,30 @@ function isServiceNowRequestCancellation(error) {
539
543
  function currentRequestSignal() {
540
544
  return REQUEST_SCOPE.getStore()?.signal;
541
545
  }
546
+ /** The running call's cancellation signal, or undefined outside a call. */
547
+ function currentServiceNowRequestSignal() {
548
+ return currentRequestSignal();
549
+ }
550
+ /**
551
+ * Wait `ms`, as a pause between two attempts of one read. It ends at once with
552
+ * the request-cancellation error when `signal` (default: the running call's)
553
+ * aborts, and never starts when it already has.
554
+ */
555
+ function pauseUnlessServiceNowRequestCancelled(ms, signal = currentRequestSignal()) {
556
+ if (signal?.aborted)
557
+ return Promise.reject(requestCancellationError());
558
+ return new Promise((resolve, reject) => {
559
+ const onAbort = () => {
560
+ clearTimeout(timer);
561
+ reject(requestCancellationError());
562
+ };
563
+ const timer = setTimeout(() => {
564
+ signal?.removeEventListener("abort", onAbort);
565
+ resolve();
566
+ }, Math.max(0, ms));
567
+ signal?.addEventListener("abort", onAbort, { once: true });
568
+ });
569
+ }
542
570
  function currentUpstreamByteBudget() {
543
571
  return REQUEST_SCOPE.getStore()?.upstreamJsonBytes;
544
572
  }