@onlyflows/servicenow-mcp 2.1.0 → 2.2.0-dev.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 (79) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +3 -2
  3. package/dist/atf-config.d.ts +72 -0
  4. package/dist/atf-config.d.ts.map +1 -0
  5. package/dist/atf-config.js +179 -0
  6. package/dist/atf-config.js.map +1 -0
  7. package/dist/atf-policy.d.ts +46 -0
  8. package/dist/atf-policy.d.ts.map +1 -0
  9. package/dist/atf-policy.js +83 -0
  10. package/dist/atf-policy.js.map +1 -0
  11. package/dist/atf-result-cache.d.ts +104 -0
  12. package/dist/atf-result-cache.d.ts.map +1 -0
  13. package/dist/atf-result-cache.js +260 -0
  14. package/dist/atf-result-cache.js.map +1 -0
  15. package/dist/config.d.ts +8 -0
  16. package/dist/config.d.ts.map +1 -1
  17. package/dist/config.js +15 -0
  18. package/dist/config.js.map +1 -1
  19. package/dist/execution-context.d.ts +7 -3
  20. package/dist/execution-context.d.ts.map +1 -1
  21. package/dist/execution-context.js +6 -2
  22. package/dist/execution-context.js.map +1 -1
  23. package/dist/field-policy.d.ts.map +1 -1
  24. package/dist/field-policy.js +42 -0
  25. package/dist/field-policy.js.map +1 -1
  26. package/dist/http-entrypoint.d.ts.map +1 -1
  27. package/dist/http-entrypoint.js +3 -0
  28. package/dist/http-entrypoint.js.map +1 -1
  29. package/dist/http-observability.js +2 -1
  30. package/dist/http-observability.js.map +1 -1
  31. package/dist/index.js +3 -0
  32. package/dist/index.js.map +1 -1
  33. package/dist/profile-manager.d.ts +12 -0
  34. package/dist/profile-manager.d.ts.map +1 -1
  35. package/dist/profile-manager.js +30 -3
  36. package/dist/profile-manager.js.map +1 -1
  37. package/dist/setup-prompts.js +1 -1
  38. package/dist/setup-prompts.js.map +1 -1
  39. package/dist/setup.d.ts.map +1 -1
  40. package/dist/setup.js +11 -4
  41. package/dist/setup.js.map +1 -1
  42. package/dist/tools/atf-author-module.d.ts +35 -0
  43. package/dist/tools/atf-author-module.d.ts.map +1 -0
  44. package/dist/tools/atf-author-module.js +125 -0
  45. package/dist/tools/atf-author-module.js.map +1 -0
  46. package/dist/tools/atf.d.ts +2 -2
  47. package/dist/tools/catalog.d.ts +2 -2
  48. package/dist/tools/catalog.d.ts.map +1 -1
  49. package/dist/tools/catalog.js +2 -0
  50. package/dist/tools/catalog.js.map +1 -1
  51. package/dist/tools/index.d.ts +3 -3
  52. package/dist/tools/index.d.ts.map +1 -1
  53. package/dist/tools/index.js +24 -8
  54. package/dist/tools/index.js.map +1 -1
  55. package/dist/tools/markdown.d.ts +77 -0
  56. package/dist/tools/markdown.d.ts.map +1 -0
  57. package/dist/tools/markdown.js +279 -0
  58. package/dist/tools/markdown.js.map +1 -0
  59. package/dist/tools/nl.d.ts +2 -2
  60. package/dist/tools/result-envelope.d.ts +91 -13
  61. package/dist/tools/result-envelope.d.ts.map +1 -1
  62. package/dist/tools/result-envelope.js +88 -2
  63. package/dist/tools/result-envelope.js.map +1 -1
  64. package/dist/tools/tool-module.d.ts +11 -3
  65. package/dist/tools/tool-module.d.ts.map +1 -1
  66. package/dist/tools/tool-module.js +1 -0
  67. package/dist/tools/tool-module.js.map +1 -1
  68. package/dist/version.d.ts +1 -1
  69. package/dist/version.d.ts.map +1 -1
  70. package/dist/version.js +1 -1
  71. package/dist/version.js.map +1 -1
  72. package/docs/CLIENT-SETUP.md +2 -2
  73. package/docs/CONTAINER-DEPLOYMENT.md +11 -0
  74. package/docs/CROSS-CLIENT-RELEASE-MATRIX.md +1 -1
  75. package/docs/PROFILE-CREDENTIALS.md +63 -0
  76. package/docs/RELEASE-VALIDATION.md +29 -2
  77. package/docs/TESTING-OAUTH.md +1 -1
  78. package/package.json +2 -2
  79. package/scripts/release-validate.mjs +14 -4
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+ /**
3
+ * Escaping-first markdown builders for tool text renderers.
4
+ *
5
+ * Everything a renderer shows a person passes through here. ServiceNow
6
+ * content -- test names, step output, messages -- is untrusted: a record can
7
+ * carry markdown, HTML, or text written to steer whoever reads it. Plain
8
+ * values are therefore always escaped into inert text, and only fragments
9
+ * issued by this module are composed verbatim. A hand-built look-alike object
10
+ * is never trusted, so instance text has no path to becoming a link, an
11
+ * image, raw HTML, a table break, or an escape from a fenced block.
12
+ *
13
+ * @module tools/markdown
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.MAX_UNTRUSTED_BLOCK_LENGTH = exports.MAX_LIST_ITEMS = exports.MAX_TABLE_COLUMNS = exports.MAX_TABLE_ROWS = exports.MAX_INLINE_LENGTH = void 0;
17
+ exports.isMarkdownFragment = isMarkdownFragment;
18
+ exports.escapeInline = escapeInline;
19
+ exports.text = text;
20
+ exports.inline = inline;
21
+ exports.badge = badge;
22
+ exports.headline = headline;
23
+ exports.table = table;
24
+ exports.bulletList = bulletList;
25
+ exports.untrustedBlock = untrustedBlock;
26
+ exports.canonicalHttpsOrigin = canonicalHttpsOrigin;
27
+ exports.recordLink = recordLink;
28
+ exports.formatDuration = formatDuration;
29
+ exports.formatTimestamp = formatTimestamp;
30
+ exports.renderMarkdown = renderMarkdown;
31
+ exports.MAX_INLINE_LENGTH = 300;
32
+ exports.MAX_TABLE_ROWS = 50;
33
+ exports.MAX_TABLE_COLUMNS = 12;
34
+ exports.MAX_LIST_ITEMS = 50;
35
+ exports.MAX_UNTRUSTED_BLOCK_LENGTH = 2_000;
36
+ const ISSUED_FRAGMENTS = new WeakMap();
37
+ const STATUS_BADGES = Object.freeze({
38
+ pass: "✅",
39
+ fail: "❌",
40
+ warn: "⚠️",
41
+ skip: "⏭",
42
+ });
43
+ const LINE_BREAKS = /\r\n?|[\n\u2028\u2029]/gu;
44
+ // C0/C1 controls (tab and newline are handled separately) and bidirectional
45
+ // overrides, which can make displayed text read differently from its bytes.
46
+ const UNSAFE_CHARACTERS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\u202A-\u202E\u2066-\u2069]/gu;
47
+ // Characters with inline meaning. Escaping brackets and angle brackets
48
+ // disables links, images, autolinks, and raw HTML; `!` is escaped everywhere
49
+ // so escaped text ending in one cannot turn a following issued link into an
50
+ // image; `|` keeps table cells intact; backticks prevent code spans; `&`
51
+ // blocks character references.
52
+ const INLINE_SPECIAL = /[\\`*~[\]<>|&!]/gu;
53
+ const TABLE_NAME = /^[a-z][a-z0-9_]{0,79}$/u;
54
+ const SYS_ID = /^[0-9a-f]{32}$/u;
55
+ const ZONED_ISO_TIMESTAMP = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2})$/u;
56
+ const SERVICENOW_TIMESTAMP = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/u;
57
+ function issue(markdown, kind) {
58
+ const fragment = Object.freeze({ markdown });
59
+ ISSUED_FRAGMENTS.set(fragment, kind);
60
+ return fragment;
61
+ }
62
+ /** True only for fragments this module issued, never for look-alikes. */
63
+ function isMarkdownFragment(value) {
64
+ return (typeof value === "object" && value !== null && ISSUED_FRAGMENTS.has(value));
65
+ }
66
+ function plainText(value) {
67
+ if (typeof value === "string")
68
+ return value;
69
+ if (typeof value === "number" ||
70
+ typeof value === "boolean" ||
71
+ typeof value === "bigint") {
72
+ return String(value);
73
+ }
74
+ if (value === null || value === undefined)
75
+ return "";
76
+ try {
77
+ return JSON.stringify(value) ?? "";
78
+ }
79
+ catch {
80
+ return "";
81
+ }
82
+ }
83
+ function truncate(text, maxLength, marker) {
84
+ const limit = Math.max(1, Math.floor(maxLength));
85
+ // Code points are at most two UTF-16 units, so this bounds the split work
86
+ // without cutting inside anything that survives the final slice.
87
+ const characters = Array.from(text.slice(0, (limit + 1) * 2));
88
+ if (characters.length <= limit)
89
+ return text;
90
+ return characters.slice(0, limit).join("") + marker;
91
+ }
92
+ function escapeLeadingBlockMarker(text) {
93
+ const ordered = /^(\d{1,9})([.)])/u.exec(text);
94
+ if (ordered) {
95
+ return `${ordered[1]}\\${ordered[2]}${text.slice(ordered[0].length)}`;
96
+ }
97
+ return /^[#>+\-=]/u.test(text) ? `\\${text}` : text;
98
+ }
99
+ /** Stop GFM from turning bare URLs, www. hosts, or addresses into links. */
100
+ function defuseAutolinks(text) {
101
+ return text
102
+ .replace(/:\/\//gu, "\\://")
103
+ .replace(/\b(www)\./giu, "$1\\.")
104
+ .replace(/@/gu, "\\@");
105
+ }
106
+ /**
107
+ * Escape any value into single-line inert markdown text, bounded to
108
+ * `maxLength` code points before escaping.
109
+ */
110
+ function escapeInline(value, maxLength = exports.MAX_INLINE_LENGTH) {
111
+ const flat = plainText(value)
112
+ .replace(LINE_BREAKS, " ")
113
+ .replace(/\t/gu, " ")
114
+ .replace(UNSAFE_CHARACTERS, "");
115
+ return escapeLeadingBlockMarker(defuseAutolinks(truncate(flat, maxLength, "…").replace(INLINE_SPECIAL, "\\$&")));
116
+ }
117
+ function inlineMarkdown(value, maxLength = exports.MAX_INLINE_LENGTH) {
118
+ if (isMarkdownFragment(value)) {
119
+ if (ISSUED_FRAGMENTS.get(value) !== "inline") {
120
+ throw new TypeError("a block markdown fragment cannot be used inline");
121
+ }
122
+ return value.markdown;
123
+ }
124
+ return escapeInline(value, maxLength);
125
+ }
126
+ function cellMarkdown(value, maxLength) {
127
+ return isMarkdownFragment(value)
128
+ ? inlineMarkdown(value)
129
+ : escapeInline(plainText(value).trim(), maxLength);
130
+ }
131
+ /** Escaped inline text. */
132
+ function text(value, maxLength = exports.MAX_INLINE_LENGTH) {
133
+ return issue(escapeInline(value, maxLength), "inline");
134
+ }
135
+ /** Concatenate inline parts; plain parts are escaped. */
136
+ function inline(...parts) {
137
+ return issue(parts.map((part) => inlineMarkdown(part)).join(""), "inline");
138
+ }
139
+ function badge(kind) {
140
+ if (!Object.hasOwn(STATUS_BADGES, kind)) {
141
+ throw new TypeError("unknown status badge");
142
+ }
143
+ return issue(STATUS_BADGES[kind], "inline");
144
+ }
145
+ function headline(title, options = {}) {
146
+ const prefix = options.status === undefined ? "" : `${badge(options.status).markdown} `;
147
+ const detail = options.detail === undefined || options.detail === null || options.detail === ""
148
+ ? ""
149
+ : ` — ${inlineMarkdown(options.detail)}`;
150
+ return issue(`### ${prefix}${inlineMarkdown(title)}${detail}`, "block");
151
+ }
152
+ /** A GFM table with escaped, bounded cells and a bounded row count. */
153
+ function table(columns, rows, options = {}) {
154
+ if (columns.length === 0 || columns.length > exports.MAX_TABLE_COLUMNS) {
155
+ throw new TypeError(`a table needs 1 to ${exports.MAX_TABLE_COLUMNS} columns`);
156
+ }
157
+ if (rows.length === 0)
158
+ return issue("_No rows._", "block");
159
+ const maxRows = Math.max(1, Math.floor(options.maxRows ?? exports.MAX_TABLE_ROWS));
160
+ const maxCellLength = options.maxCellLength ?? exports.MAX_INLINE_LENGTH;
161
+ const line = (cells) => `| ${cells.join(" | ")} |`;
162
+ const lines = [
163
+ line(columns.map((column) => cellMarkdown(column, maxCellLength))),
164
+ line(columns.map(() => "---")),
165
+ ...rows
166
+ .slice(0, maxRows)
167
+ .map((row) => line(columns.map((_, index) => cellMarkdown(row[index], maxCellLength)))),
168
+ ];
169
+ const omitted = rows.length - maxRows;
170
+ if (omitted > 0)
171
+ lines.push("", `_…and ${omitted} more not shown._`);
172
+ return issue(lines.join("\n"), "block");
173
+ }
174
+ function bulletList(items, maxItems = exports.MAX_LIST_ITEMS) {
175
+ if (items.length === 0)
176
+ return issue("_None._", "block");
177
+ const limit = Math.max(1, Math.floor(maxItems));
178
+ const lines = items
179
+ .slice(0, limit)
180
+ .map((item) => `- ${cellMarkdown(item, exports.MAX_INLINE_LENGTH)}`);
181
+ const omitted = items.length - limit;
182
+ if (omitted > 0)
183
+ lines.push(`- _…and ${omitted} more not shown._`);
184
+ return issue(lines.join("\n"), "block");
185
+ }
186
+ /**
187
+ * Untrusted multi-line text in a fenced block. The fence is longer than any
188
+ * backtick run in the content, so no content line can close it.
189
+ */
190
+ function untrustedBlock(label, content, maxLength = exports.MAX_UNTRUSTED_BLOCK_LENGTH) {
191
+ const body = truncate(plainText(content)
192
+ .replace(LINE_BREAKS, "\n")
193
+ .replace(UNSAFE_CHARACTERS, ""), maxLength, "…[truncated]") || "(empty)";
194
+ const longestRun = (body.match(/`+/gu) ?? []).reduce((longest, run) => Math.max(longest, run.length), 0);
195
+ const fence = "`".repeat(Math.max(3, longestRun + 1));
196
+ return issue(`**${inlineMarkdown(label)} (untrusted):**\n${fence}text\n${body}\n${fence}`, "block");
197
+ }
198
+ /**
199
+ * The canonical `https://host[:port]` origin of a bare instance URL, or
200
+ * undefined for anything else (another scheme, credentials, path, query).
201
+ */
202
+ function canonicalHttpsOrigin(candidate) {
203
+ if (typeof candidate !== "string")
204
+ return undefined;
205
+ let url;
206
+ try {
207
+ url = new URL(candidate);
208
+ }
209
+ catch {
210
+ return undefined;
211
+ }
212
+ if (url.protocol !== "https:" ||
213
+ url.username !== "" ||
214
+ url.password !== "" ||
215
+ url.search !== "" ||
216
+ url.hash !== "" ||
217
+ (url.pathname !== "/" && url.pathname !== "")) {
218
+ return undefined;
219
+ }
220
+ return url.origin;
221
+ }
222
+ /**
223
+ * Link to one record on the profile's instance. The URL is built only from a
224
+ * validated https origin, a ServiceNow table identifier, and a canonical
225
+ * sys_id; anything else degrades to the escaped label with no link.
226
+ */
227
+ function recordLink(instanceOrigin, tableName, sysId, label) {
228
+ const origin = canonicalHttpsOrigin(instanceOrigin);
229
+ const escapedLabel = inlineMarkdown(label);
230
+ if (origin === undefined || !TABLE_NAME.test(tableName) || !SYS_ID.test(sysId)) {
231
+ return issue(escapedLabel, "inline");
232
+ }
233
+ return issue(`[${escapedLabel}](${origin}/${tableName}.do?sys_id=${sysId})`, "inline");
234
+ }
235
+ /** Compact duration such as `45s`, `3m12s`, or `1h02m`. */
236
+ function formatDuration(milliseconds) {
237
+ if (!Number.isFinite(milliseconds) || milliseconds < 0)
238
+ return "—";
239
+ if (milliseconds < 1_000)
240
+ return milliseconds === 0 ? "0s" : "<1s";
241
+ const total = Math.round(milliseconds / 1_000);
242
+ const hours = Math.floor(total / 3_600);
243
+ const minutes = Math.floor((total % 3_600) / 60);
244
+ const seconds = total % 60;
245
+ const pad = (value) => String(value).padStart(2, "0");
246
+ if (hours > 0)
247
+ return `${hours}h${pad(minutes)}m`;
248
+ if (minutes > 0)
249
+ return `${minutes}m${pad(seconds)}s`;
250
+ return `${seconds}s`;
251
+ }
252
+ /**
253
+ * Format an instant as `YYYY-MM-DD HH:MM:SS UTC`. A zoneless ServiceNow
254
+ * timestamp is already in the instance's zone and is returned unchanged;
255
+ * any other string is not guessed at.
256
+ */
257
+ function formatTimestamp(value) {
258
+ if (typeof value === "string") {
259
+ if (SERVICENOW_TIMESTAMP.test(value))
260
+ return value;
261
+ if (!ZONED_ISO_TIMESTAMP.test(value))
262
+ return "—";
263
+ }
264
+ const instant = value instanceof Date ? value : new Date(value);
265
+ if (Number.isNaN(instant.getTime()))
266
+ return "—";
267
+ return `${instant.toISOString().slice(0, 19).replace("T", " ")} UTC`;
268
+ }
269
+ /**
270
+ * Join blocks into the final renderer text. Anything that is not an issued
271
+ * fragment is escaped as a paragraph rather than passed through.
272
+ */
273
+ function renderMarkdown(...blocks) {
274
+ return blocks
275
+ .filter((block) => Boolean(block))
276
+ .map((block) => (isMarkdownFragment(block) ? block.markdown : escapeInline(block)))
277
+ .join("\n\n");
278
+ }
279
+ //# sourceMappingURL=markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/tools/markdown.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AA2DH,gDAIC;AAgDD,oCAWC;AAmBD,oBAEC;AAGD,wBAEC;AAED,sBAKC;AAED,4BAUC;AAGD,sBAwBC;AAED,gCAYC;AAMD,wCAsBC;AAMD,oDAmBC;AAOD,gCAeC;AAGD,wCAWC;AAOD,0CAQC;AAMD,wCAOC;AAnUY,QAAA,iBA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efault<z.ZodOptional<z.ZodBoolean>>;
21
21
  }, "strip", z.ZodTypeAny, {
22
22
  text: string;
23
- confirm: boolean;
24
23
  execute: boolean;
24
+ confirm: boolean;
25
25
  force: boolean;
26
26
  }, {
27
27
  text: string;
28
- confirm?: boolean | undefined;
29
28
  execute?: boolean | undefined;
29
+ confirm?: boolean | undefined;
30
30
  force?: boolean | undefined;
31
31
  }>;
32
32
  export declare function handler(args: z.infer<typeof schema>, client: ServiceNowOperations, _config: ServiceNowToolSettings, _context: ExecutionContext): Promise<{
@@ -318,23 +318,23 @@ declare const productionDataSchemas: Readonly<{
318
318
  matched: number;
319
319
  message?: string | undefined;
320
320
  failed?: number | undefined;
321
- processed?: number | undefined;
322
321
  dry_run?: boolean | undefined;
322
+ processed?: number | undefined;
323
323
  }, {
324
324
  table: string;
325
325
  action: "delete" | "update";
326
326
  matched: number;
327
327
  message?: string | undefined;
328
328
  failed?: number | undefined;
329
- processed?: number | undefined;
330
329
  dry_run?: boolean | undefined;
330
+ processed?: number | undefined;
331
331
  }>;
332
332
  sn_aggregate: z.ZodObject<{
333
333
  result: z.ZodUnion<[z.ZodNull, z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown, "many">]>;
334
334
  }, "strict", z.ZodTypeAny, {
335
- result: string | number | boolean | unknown[] | Record<string, unknown> | null;
335
+ result: string | number | boolean | Record<string, unknown> | unknown[] | null;
336
336
  }, {
337
- result: string | number | boolean | unknown[] | Record<string, unknown> | null;
337
+ result: string | number | boolean | Record<string, unknown> | unknown[] | null;
338
338
  }>;
339
339
  sn_schema: z.ZodObject<{
340
340
  fields: z.ZodArray<z.ZodUnknown, "many">;
@@ -354,10 +354,10 @@ declare const productionDataSchemas: Readonly<{
354
354
  action: z.ZodEnum<["list", "download", "upload"]>;
355
355
  result: z.ZodUnion<[z.ZodNull, z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown, "many">]>;
356
356
  }, "strict", z.ZodTypeAny, {
357
- result: string | number | boolean | unknown[] | Record<string, unknown> | null;
357
+ result: string | number | boolean | Record<string, unknown> | unknown[] | null;
358
358
  action: "list" | "download" | "upload";
359
359
  }, {
360
- result: string | number | boolean | unknown[] | Record<string, unknown> | null;
360
+ result: string | number | boolean | Record<string, unknown> | unknown[] | null;
361
361
  action: "list" | "download" | "upload";
362
362
  }>;
363
363
  sn_relationships: z.ZodObject<{
@@ -428,11 +428,48 @@ declare const productionDataSchemas: Readonly<{
428
428
  action: z.ZodEnum<["list", "suites", "run", "run-suite", "results"]>;
429
429
  result: z.ZodUnion<[z.ZodNull, z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodUnknown, "many">]>;
430
430
  }, "strict", z.ZodTypeAny, {
431
- result: string | number | boolean | unknown[] | Record<string, unknown> | null;
432
- action: "run" | "list" | "suites" | "results" | "run-suite";
433
- }, {
434
- result: string | number | boolean | unknown[] | Record<string, unknown> | null;
435
- action: "run" | "list" | "suites" | "results" | "run-suite";
431
+ result: string | number | boolean | Record<string, unknown> | unknown[] | null;
432
+ action: "suites" | "run" | "list" | "results" | "run-suite";
433
+ }, {
434
+ result: string | number | boolean | Record<string, unknown> | unknown[] | null;
435
+ action: "suites" | "run" | "list" | "results" | "run-suite";
436
+ }>;
437
+ sn_atf_author: z.ZodObject<{
438
+ action: z.ZodEnum<["create_test", "create_suite", "add_tests_to_suite"]>;
439
+ outcome: z.ZodEnum<["created", "failed"]>;
440
+ results: z.ZodArray<z.ZodObject<{
441
+ table: z.ZodEnum<["sys_atf_test", "sys_atf_test_suite", "sys_atf_test_suite_test"]>;
442
+ sys_id: z.ZodString;
443
+ }, "strict", z.ZodTypeAny, {
444
+ sys_id: string;
445
+ table: "sys_atf_test" | "sys_atf_test_suite" | "sys_atf_test_suite_test";
446
+ }, {
447
+ sys_id: string;
448
+ table: "sys_atf_test" | "sys_atf_test_suite" | "sys_atf_test_suite_test";
449
+ }>, "many">;
450
+ rolled_back: z.ZodArray<z.ZodString, "many">;
451
+ rollback_failed: z.ZodArray<z.ZodString, "many">;
452
+ uncertain_insert: z.ZodBoolean;
453
+ }, "strict", z.ZodTypeAny, {
454
+ outcome: "failed" | "created";
455
+ action: "create_test" | "create_suite" | "add_tests_to_suite";
456
+ results: {
457
+ sys_id: string;
458
+ table: "sys_atf_test" | "sys_atf_test_suite" | "sys_atf_test_suite_test";
459
+ }[];
460
+ rolled_back: string[];
461
+ rollback_failed: string[];
462
+ uncertain_insert: boolean;
463
+ }, {
464
+ outcome: "failed" | "created";
465
+ action: "create_test" | "create_suite" | "add_tests_to_suite";
466
+ results: {
467
+ sys_id: string;
468
+ table: "sys_atf_test" | "sys_atf_test_suite" | "sys_atf_test_suite_test";
469
+ }[];
470
+ rolled_back: string[];
471
+ rollback_failed: string[];
472
+ uncertain_insert: boolean;
436
473
  }>;
437
474
  sn_nl: z.ZodObject<{
438
475
  request: z.ZodRecord<z.ZodString, z.ZodUnknown>;
@@ -576,6 +613,13 @@ export declare const productionToolOutputSchemas: Readonly<{
576
613
  }, {
577
614
  [x: string]: any;
578
615
  }>;
616
+ sn_atf_author: z.ZodObject<{} & {
617
+ [x: string]: z.ZodTypeAny;
618
+ }, "strict", z.ZodTypeAny, {
619
+ [x: string]: any;
620
+ }, {
621
+ [x: string]: any;
622
+ }>;
579
623
  sn_nl: z.ZodObject<{} & {
580
624
  [x: string]: z.ZodTypeAny;
581
625
  }, "strict", z.ZodTypeAny, {
@@ -592,12 +636,46 @@ export declare const productionToolOutputSchemas: Readonly<{
592
636
  }>;
593
637
  }>;
594
638
  export declare function isProductionToolName(name: string): name is ProductionToolName;
639
+ /** Read-only copy of a finalized envelope handed to a tool text renderer. */
640
+ export interface RenderableEnvelope {
641
+ readonly profile?: string;
642
+ readonly data: unknown;
643
+ readonly metadata: Readonly<z.infer<typeof resultMetadataSchema>>;
644
+ }
645
+ export interface EnvelopeTextRenderContext {
646
+ /** The generic one-line summary, including continuation/truncation guidance. */
647
+ readonly summary: string;
648
+ /**
649
+ * Canonical https origin of the resolved profile's instance, for building
650
+ * record links. Coordinator-supplied, never taken from ServiceNow content,
651
+ * and absent when the profile instance is not a bare https origin.
652
+ */
653
+ readonly instanceOrigin?: string;
654
+ }
655
+ /** Trusted coordinator inputs to text rendering; never part of structuredContent. */
656
+ export interface EnvelopeTextRenderOptions {
657
+ readonly instanceOrigin?: string;
658
+ }
659
+ /**
660
+ * Human-readable text for one tool's successful result. It receives a deeply
661
+ * frozen copy, so it cannot alter structuredContent, and the values in it come
662
+ * from ServiceNow: build output only with the escaping helpers in markdown.ts.
663
+ */
664
+ export type EnvelopeTextRenderer = (envelope: RenderableEnvelope, context: EnvelopeTextRenderContext) => string;
665
+ /** Register the text renderer for one production tool, once, before first use. */
666
+ export declare function registerEnvelopeTextRenderer(tool: ProductionToolName, renderer: EnvelopeTextRenderer): void;
595
667
  export declare function envelopeCompatibilityResult(name: ProductionToolName, args: Readonly<Record<string, unknown>>, result: CallToolResult): CallToolResult;
596
668
  /**
597
- * Replace handler text with a coordinator-rendered summary and enforce the
669
+ * Replace handler text with coordinator-rendered text and enforce the
598
670
  * declared final MCP result byte limit. Returns undefined when even a fully
599
671
  * minimized valid envelope cannot fit, causing the caller to fail closed.
672
+ *
673
+ * The envelope is always fitted against the generic one-line summary. A tool
674
+ * with a registered renderer then gets its readable text only if the fitted
675
+ * result still fits with it; a renderer that throws, returns no text, or
676
+ * overflows the budget falls back to the summary. Readable text therefore
677
+ * never costs structured records and never turns a success into an error.
600
678
  */
601
- export declare function finalizeEnvelopeResult(result: CallToolResult): CallToolResult | undefined;
679
+ export declare function finalizeEnvelopeResult(result: CallToolResult, tool?: string, options?: EnvelopeTextRenderOptions): CallToolResult | undefined;
602
680
  export {};
603
681
  //# sourceMappingURL=result-envelope.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"result-envelope.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Ac,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,CACjC,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,EAAE,yBAAyB,KAC/B,MAAM,CAAC;AAOZ,kFAAkF;AAClF,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,kBAAkB,EACxB,QAAQ,EAAE,oBAAoB,GAC7B,IAAI,CAcN;AA2VD,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,kBAAkB,EACxB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACvC,MAAM,EAAE,cAAc,GACrB,cAAc,CA6EhB;AAwID;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,cAAc,EACtB,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,GAAE,yBAA8B,GACtC,cAAc,GAAG,SAAS,CA+B5B"}
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.productionToolOutputSchemas = exports.ENVELOPE_HINT_KEY = exports.resultMetadataSchema = exports.resultPaginationSchema = exports.ATTACHMENT_RESULT_BYTE_LIMIT = exports.DEFAULT_RESULT_BYTE_LIMIT = exports.DEFAULT_RESULT_RECORD_LIMIT = void 0;
5
5
  exports.withStructuredResultEnvelope = withStructuredResultEnvelope;
6
6
  exports.isProductionToolName = isProductionToolName;
7
+ exports.registerEnvelopeTextRenderer = registerEnvelopeTextRenderer;
7
8
  exports.envelopeCompatibilityResult = envelopeCompatibilityResult;
8
9
  exports.finalizeEnvelopeResult = finalizeEnvelopeResult;
9
10
  const zod_1 = require("zod");
10
11
  const utils_js_1 = require("../utils.js");
12
+ const markdown_js_1 = require("./markdown.js");
11
13
  const tool_module_js_1 = require("./tool-module.js");
12
14
  exports.DEFAULT_RESULT_RECORD_LIMIT = 1_000;
13
15
  exports.DEFAULT_RESULT_BYTE_LIMIT = utils_js_1.MAX_RESPONSE_BYTES_DEFAULT;
@@ -135,6 +137,18 @@ const atfResultEnvelopeSchema = zod_1.z
135
137
  result: dynamicJsonRootSchema,
136
138
  })
137
139
  .strict();
140
+ const atfRecordIdSchema = zod_1.z.string().regex(/^[a-f0-9]{32}$/);
141
+ const atfAuthorResultSchema = zod_1.z.object({
142
+ action: zod_1.z.enum(["create_test", "create_suite", "add_tests_to_suite"]),
143
+ outcome: zod_1.z.enum(["created", "failed"]),
144
+ results: zod_1.z.array(zod_1.z.object({
145
+ table: zod_1.z.enum(["sys_atf_test", "sys_atf_test_suite", "sys_atf_test_suite_test"]),
146
+ sys_id: atfRecordIdSchema,
147
+ }).strict()).max(100),
148
+ rolled_back: zod_1.z.array(atfRecordIdSchema).max(100),
149
+ rollback_failed: zod_1.z.array(atfRecordIdSchema).max(100),
150
+ uncertain_insert: zod_1.z.boolean(),
151
+ }).strict();
138
152
  const queryResultSchema = zod_1.z
139
153
  .object({
140
154
  record_count: nonNegativeInteger,
@@ -222,6 +236,7 @@ const productionDataSchemas = Object.freeze({
222
236
  sn_codesearch: listResultSchema,
223
237
  sn_discover: listResultSchema,
224
238
  sn_atf: atfResultEnvelopeSchema,
239
+ sn_atf_author: atfAuthorResultSchema,
225
240
  sn_nl: naturalLanguageResultSchema,
226
241
  sn_profile: profileResultSchema,
227
242
  });
@@ -243,12 +258,33 @@ exports.productionToolOutputSchemas = Object.freeze({
243
258
  sn_codesearch: withStructuredResultEnvelope(productionDataSchemas.sn_codesearch),
244
259
  sn_discover: withStructuredResultEnvelope(productionDataSchemas.sn_discover),
245
260
  sn_atf: withStructuredResultEnvelope(productionDataSchemas.sn_atf),
261
+ sn_atf_author: withStructuredResultEnvelope(productionDataSchemas.sn_atf_author),
246
262
  sn_nl: withStructuredResultEnvelope(productionDataSchemas.sn_nl),
247
263
  sn_profile: withStructuredResultEnvelope(productionDataSchemas.sn_profile),
248
264
  });
249
265
  function isProductionToolName(name) {
250
266
  return Object.hasOwn(exports.productionToolOutputSchemas, name);
251
267
  }
268
+ // Populated while modules load, then sealed by the first finalized result so a
269
+ // renderer cannot be added or swapped once tool calls are being served.
270
+ const ENVELOPE_TEXT_RENDERERS = new Map();
271
+ let envelopeTextRenderersSealed = false;
272
+ /** Register the text renderer for one production tool, once, before first use. */
273
+ function registerEnvelopeTextRenderer(tool, renderer) {
274
+ if (envelopeTextRenderersSealed) {
275
+ throw new TypeError("envelope text renderers are sealed once results are finalized");
276
+ }
277
+ if (typeof tool !== "string" || !isProductionToolName(tool)) {
278
+ throw new TypeError("envelope text renderer requires a production tool name");
279
+ }
280
+ if (typeof renderer !== "function") {
281
+ throw new TypeError(`${tool}: envelope text renderer must be a function`);
282
+ }
283
+ if (ENVELOPE_TEXT_RENDERERS.has(tool)) {
284
+ throw new TypeError(`${tool}: envelope text renderer is already registered`);
285
+ }
286
+ ENVELOPE_TEXT_RENDERERS.set(tool, renderer);
287
+ }
252
288
  function parseHandlerJson(result) {
253
289
  if (result.content.length !== 1 || result.content[0]?.type !== "text") {
254
290
  throw new TypeError("successful compatibility handler must return one text block");
@@ -700,12 +736,62 @@ function truncateLongestString(data) {
700
736
  }
701
737
  return true;
702
738
  }
739
+ function deepFreeze(value) {
740
+ if (typeof value === "object" && value !== null) {
741
+ for (const entry of Object.values(value))
742
+ deepFreeze(entry);
743
+ Object.freeze(value);
744
+ }
745
+ return value;
746
+ }
747
+ function renderedEnvelopeText(renderer, envelope, context) {
748
+ try {
749
+ const view = deepFreeze(JSON.parse(JSON.stringify(envelope)));
750
+ const text = renderer(view, context);
751
+ return typeof text === "string" && text.trim() !== "" ? text : undefined;
752
+ }
753
+ catch {
754
+ return undefined;
755
+ }
756
+ }
703
757
  /**
704
- * Replace handler text with a coordinator-rendered summary and enforce the
758
+ * Replace handler text with coordinator-rendered text and enforce the
705
759
  * declared final MCP result byte limit. Returns undefined when even a fully
706
760
  * minimized valid envelope cannot fit, causing the caller to fail closed.
761
+ *
762
+ * The envelope is always fitted against the generic one-line summary. A tool
763
+ * with a registered renderer then gets its readable text only if the fitted
764
+ * result still fits with it; a renderer that throws, returns no text, or
765
+ * overflows the budget falls back to the summary. Readable text therefore
766
+ * never costs structured records and never turns a success into an error.
707
767
  */
708
- function finalizeEnvelopeResult(result) {
768
+ function finalizeEnvelopeResult(result, tool, options = {}) {
769
+ envelopeTextRenderersSealed = true;
770
+ const summarized = finalizeSummaryResult(result);
771
+ const renderer = tool === undefined ? undefined : ENVELOPE_TEXT_RENDERERS.get(tool);
772
+ if (!summarized ||
773
+ !renderer ||
774
+ !isMutableEnvelope(summarized.structuredContent)) {
775
+ return summarized;
776
+ }
777
+ const envelope = summarized.structuredContent;
778
+ const block = summarized.content[0];
779
+ const instanceOrigin = (0, markdown_js_1.canonicalHttpsOrigin)(options.instanceOrigin);
780
+ const text = renderedEnvelopeText(renderer, envelope, Object.freeze({
781
+ summary: block?.type === "text" ? block.text : "",
782
+ ...(instanceOrigin === undefined ? {} : { instanceOrigin }),
783
+ }));
784
+ if (text === undefined)
785
+ return summarized;
786
+ const rendered = {
787
+ ...summarized,
788
+ content: [{ type: "text", text }],
789
+ };
790
+ return resultBytes(rendered) <= envelope.metadata.limits.max_bytes
791
+ ? rendered
792
+ : summarized;
793
+ }
794
+ function finalizeSummaryResult(result) {
709
795
  if (!isMutableEnvelope(result.structuredContent))
710
796
  return result;
711
797
  const sourceEnvelope = JSON.parse(JSON.stringify(result.structuredContent));