@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
@@ -0,0 +1,158 @@
1
+ /**
2
+ * `sn_history`: one record's history, newest first: its audited field
3
+ * changes (`sys_audit`), its comments and work notes (`sys_journal_field`)
4
+ * and the flows that ran on it (`sys_flow_context`).
5
+ *
6
+ * Access plan (`historyAccessPlan`), decided before any read:
7
+ * - the record's table, with `sys_id` and `sys_class_name` readable under
8
+ * field policy (otherwise the call is refused before it reads anything);
9
+ * - `sys_db_object` and `sys_dictionary`, for the class's field types, when
10
+ * the profile may read them. Without them every value is withheld;
11
+ * - each source the profile may read, decided on its own as `sn_codesearch`
12
+ * decides its code tables: a source whose table is not granted (including a
13
+ * named-only table under `"*"`, or a target not bound to this tool), or
14
+ * whose key columns field policy hides, is reported `not_granted` and left
15
+ * out of the plan. The call fails only when a source the caller named
16
+ * explicitly is refused, or when no source is left.
17
+ * The mirror tables (`sys_history_line`, `sys_audit_delete`,
18
+ * `sys_email`) are never read.
19
+ *
20
+ * Reads, at most six per page (four once the class's types are memoized):
21
+ * 1. the record (`GET <table>/<sys_id>`, `sys_id,sys_class_name`). A record
22
+ * that is missing or that the instance refuses is `not_found`; a record
23
+ * whose class is not `table` is refused with the class to call with;
24
+ * 2. the class's extension chain (`sys_db_object`) and every dictionary row
25
+ * of that chain (`sys_dictionary`), uncached and then kept for an hour in
26
+ * the per-credential memo, so a warm call skips both. Skipped as well when
27
+ * no source on the page needs types. The chain counts only when it is
28
+ * known to end at a table that extends nothing;
29
+ * 3. each planned source, newest first, `limit + 1` rows, uncached. The
30
+ * journal and flow reads run with step 2; the audit read follows it, so
31
+ * its query leaves out the chain's journal fields. A source whose page is
32
+ * too large for the client is asked again for half the rows, down to one
33
+ * row; past that it alone is `too_large` and the others still answer.
34
+ *
35
+ * Every source row must carry the record's class and sys_id in its key
36
+ * columns, or it is dropped (`omitted.mismatch`). Then, in order:
37
+ * (a) an audit row for a journal-typed field (by the dictionary type found
38
+ * walking up the class's chain, never by name) is left out of the audit
39
+ * query, and dropped if it comes back anyway: journal text, and whether
40
+ * there is any, comes only through the journal source and its own grant.
41
+ * Without types, the platform's journal field names are left out the same
42
+ * way unless the call reads the journal source;
43
+ * (b) a row whose field the profile may not read on the class (field policy,
44
+ * a sensitive name, a type the call hides, or a column that field policy
45
+ * keeps closed, such as a record payload or a process command line) is
46
+ * dropped (`omitted.unreadable`), unnamed;
47
+ * (c) a value whose field is hidden by type, sits on a credential table or
48
+ * has an unknown type is withheld (`value_hidden`). This uses the shared
49
+ * type helper over the dictionary rows of step 2, so an unreadable
50
+ * dictionary withholds every value.
51
+ * Values are cut at 2,000 characters; references stay raw sys_ids. No row is
52
+ * cached.
53
+ *
54
+ * Paging: each source has its own position, `encodeTailCursor` bound to the
55
+ * record, the source and the filters (`historyCursorFilter`). The newest
56
+ * `limit` events of all sources are returned; a source's cursor stands at
57
+ * the last of its rows this page consumed, so a page never skips or repeats.
58
+ *
59
+ * A page where every source that still has entries is `too_large` carries a
60
+ * `hint` (`STUCK_PAGE_HINT`): repeating the call unchanged would not move on.
61
+ *
62
+ * Registered in `catalog.ts`; its output schema and byte limit are its
63
+ * result-envelope entries.
64
+ *
65
+ * @module tools/history-module
66
+ */
67
+ import { type FieldTypes, type FieldTypesProblemInput } from "../hidden-values.js";
68
+ import { type TableAccessPolicy, type TableAccessRequest } from "../table-policy.js";
69
+ import { type CanonicalHistoryArgs, type HistorySource, type HistorySourceSpec } from "./history-contracts.js";
70
+ import { type TailPosition } from "./syslog-cursor.js";
71
+ /**
72
+ * The platform's own journal fields, by name. Used only to leave rows out when
73
+ * the types cannot be read and the journal source is not in the call: a name
74
+ * never makes a row visible.
75
+ */
76
+ export declare const JOURNAL_FIELD_NAMES: readonly string[];
77
+ /** A dictionary read that returns this many rows may be cut short, so its types are unavailable. */
78
+ export declare const MAX_HISTORY_DICTIONARY_ROWS = 5000;
79
+ /** The fewest rows a source read asks for after a response was too large: one row and the look-ahead. */
80
+ export declare const MIN_SOURCE_READ_ROWS = 2;
81
+ export declare const WRONG_CLASS_HINT: (recordClass: string) => string;
82
+ export declare const INVALID_CURSOR_HINT: string;
83
+ export declare const VALUES_NOT_READABLE_WARNING: (source: HistorySource) => string;
84
+ export declare const TOO_LARGE_WARNING: (source: HistorySource) => string;
85
+ /**
86
+ * Every source with entries left was too large to read on this page, so
87
+ * repeating the call with the same arguments returns the same page. The
88
+ * limit is the client's per-response cap, which `max_response_bytes` does
89
+ * not change.
90
+ */
91
+ export declare const STUCK_PAGE_HINT: (sources: readonly HistorySource[]) => string;
92
+ export declare const FITTED_WARNING = "Fewer events than limit fit max_response_bytes; the rest follow with next_cursor.";
93
+ export interface HistorySourcePlan {
94
+ readonly source: HistorySource;
95
+ readonly spec: HistorySourceSpec;
96
+ /** `not_granted`: refused by table or field policy, and left out of the plan. */
97
+ readonly granted: boolean;
98
+ /** `sysparm_fields` for the read. */
99
+ readonly fields: readonly string[];
100
+ readonly user: boolean;
101
+ /** The value columns are requested (`include_values` and readable). */
102
+ readonly values: boolean;
103
+ /** `include_values` was asked for but field policy hides the value columns. */
104
+ readonly valuesHidden: boolean;
105
+ }
106
+ export interface HistoryPlan {
107
+ readonly table: string;
108
+ /** `sys_db_object` and `sys_dictionary` are in the plan. */
109
+ readonly dictionary: boolean;
110
+ /** The dictionary's `audit` column is readable. */
111
+ readonly auditFlag: boolean;
112
+ /** The sources asked for (explicitly, or every one by default), in canonical order. */
113
+ readonly sources: readonly HistorySourcePlan[];
114
+ readonly requests: readonly TableAccessRequest[];
115
+ }
116
+ /**
117
+ * True for a column that field policy keeps closed on `table` (a record
118
+ * payload or a process command line; see `explicitReadColumns`). History
119
+ * never shows such a column, even where a profile opened it for reading: its
120
+ * audit rows are dropped and it cannot be named in `fields`. A table that
121
+ * extends one with such columns has them too, wherever its chain is known.
122
+ */
123
+ export declare function isRecordContentColumn(table: string, field: string): boolean;
124
+ /**
125
+ * The call's access plan. It throws (and so refuses the call before any read)
126
+ * when the record cannot be identified under field policy, when `fields`
127
+ * names a field the profile may not read, when a source the caller named is
128
+ * refused, or when no source is left. Every other refusal narrows the plan.
129
+ *
130
+ * Pure apart from the policy it consults: the dispatcher runs it inside the
131
+ * call's field-policy and type scopes, and the handler runs it again there,
132
+ * so both see the same plan.
133
+ */
134
+ export declare function historyAccessPlan(args: CanonicalHistoryArgs, tableAccess: TableAccessPolicy): HistoryPlan;
135
+ /** Why a class's types are not known, as the pieces {@link fieldTypesProblemText} words. */
136
+ type ClassTypesWhy = Pick<FieldTypesProblemInput, "problem" | "failure" | "read">;
137
+ /** The warning for a class whose types are not known, worded from its cause. */
138
+ export declare function classTypesWarning(why: ClassTypesWhy | undefined): string;
139
+ /**
140
+ * The audit fields the audit read leaves out, so journal rows never reach a
141
+ * page, its cursors, `has_more` or its counts: every journal-typed field of
142
+ * the class's chain when the types are known. Without types, the platform's
143
+ * journal field names, unless the call also reads the journal source (then
144
+ * those rows are shown without values, as every audit row is).
145
+ */
146
+ export declare function auditExclusions(types: FieldTypes, recordClass: string, journalInCall: boolean): readonly string[];
147
+ /** The encoded query of one source's page: position first, then the record, then the filters. */
148
+ export declare function sourceQuery(spec: HistorySourceSpec, recordClass: string, args: CanonicalHistoryArgs, position: TailPosition | undefined,
149
+ /** Field names the source must not return (journal fields, for the audit log). */
150
+ exclude?: readonly string[]): string;
151
+ /** The plan for one call, as the dispatcher authorizes it. */
152
+ export declare function resolveHistoryAccess(candidate: unknown, tableAccess: TableAccessPolicy): Readonly<{
153
+ args: Record<string, unknown>;
154
+ requests: readonly TableAccessRequest[];
155
+ }>;
156
+ export declare const historyToolModule: import("./tool-module.js").ServiceNowToolModuleContract;
157
+ export {};
158
+ //# sourceMappingURL=history-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history-module.d.ts","sourceRoot":"","sources":["../../src/tools/history-module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AAgBH,OAAO,EAWL,KAAK,UAAU,EACf,KAAK,sBAAsB,EAE5B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAcL,KAAK,oBAAoB,EAGzB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAiE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AActH;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAAyE,CAAC;AAG3H,oGAAoG;AACpG,eAAO,MAAM,2BAA2B,OAAQ,CAAC;AAOjD,yGAAyG;AACzG,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAItC,eAAO,MAAM,gBAAgB,GAAI,aAAa,MAAM,WAC6B,CAAC;AAClF,eAAO,MAAM,mBAAmB,QAE2C,CAAC;AAC5E,eAAO,MAAM,2BAA2B,GAAI,QAAQ,aAAa,WACoB,CAAC;AACtF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,aAAa,WAE+B,CAAC;AACvF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,SAAS,aAAa,EAAE,WAGyB,CAAC;AAC3F,eAAO,MAAM,cAAc,sFAC0D,CAAC;AAMtF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,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