@introspection-ai/recipes 0.43.0 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/dist/agents.d.ts.map +1 -1
  2. package/dist/agents.js +11 -4
  3. package/dist/agents.js.map +1 -1
  4. package/dist/api/session.d.ts +2 -1
  5. package/dist/api/session.d.ts.map +1 -1
  6. package/dist/artifact-review-tui.d.ts +0 -2
  7. package/dist/artifact-review-tui.d.ts.map +1 -1
  8. package/dist/artifact-review-tui.js +1 -1
  9. package/dist/artifact-review-tui.js.map +1 -1
  10. package/dist/artifact-review.d.ts +30 -13
  11. package/dist/artifact-review.d.ts.map +1 -1
  12. package/dist/artifact-review.js +80 -12
  13. package/dist/artifact-review.js.map +1 -1
  14. package/dist/artifact-viewer-tui.d.ts.map +1 -1
  15. package/dist/artifact-viewer-tui.js.map +1 -1
  16. package/dist/artifact-viewer.d.ts +1 -63
  17. package/dist/artifact-viewer.d.ts.map +1 -1
  18. package/dist/artifact-viewer.js +6 -9
  19. package/dist/artifact-viewer.js.map +1 -1
  20. package/dist/ask-user-question.d.ts +0 -32
  21. package/dist/ask-user-question.d.ts.map +1 -1
  22. package/dist/ask-user-question.js +9 -5
  23. package/dist/ask-user-question.js.map +1 -1
  24. package/dist/channels/index.d.ts +1 -1
  25. package/dist/channels/index.d.ts.map +1 -1
  26. package/dist/channels/index.js +1 -1
  27. package/dist/channels/index.js.map +1 -1
  28. package/dist/channels/module.d.ts.map +1 -1
  29. package/dist/channels/module.js +15 -5
  30. package/dist/channels/module.js.map +1 -1
  31. package/dist/channels/refs.d.ts.map +1 -1
  32. package/dist/channels/refs.js +10 -2
  33. package/dist/channels/refs.js.map +1 -1
  34. package/dist/channels/tools.d.ts.map +1 -1
  35. package/dist/channels/tools.js +80 -36
  36. package/dist/channels/tools.js.map +1 -1
  37. package/dist/child/agent-completions.d.ts.map +1 -1
  38. package/dist/child/agent-completions.js +3 -1
  39. package/dist/child/agent-completions.js.map +1 -1
  40. package/dist/child/agent-store.d.ts +3 -2
  41. package/dist/child/agent-store.d.ts.map +1 -1
  42. package/dist/child/agent-store.js.map +1 -1
  43. package/dist/child/agent.d.ts.map +1 -1
  44. package/dist/child/agent.js +1 -3
  45. package/dist/child/agent.js.map +1 -1
  46. package/dist/child/session.d.ts +2 -2
  47. package/dist/child/session.d.ts.map +1 -1
  48. package/dist/child/session.js +1 -3
  49. package/dist/child/session.js.map +1 -1
  50. package/dist/connector-tools.d.ts +5 -4
  51. package/dist/connector-tools.d.ts.map +1 -1
  52. package/dist/connector-tools.js +19 -9
  53. package/dist/connector-tools.js.map +1 -1
  54. package/dist/documents/index.d.ts +3 -3
  55. package/dist/documents/index.d.ts.map +1 -1
  56. package/dist/documents/index.js +1 -1
  57. package/dist/documents/index.js.map +1 -1
  58. package/dist/documents/module.d.ts +0 -2
  59. package/dist/documents/module.d.ts.map +1 -1
  60. package/dist/documents/module.js +30 -11
  61. package/dist/documents/module.js.map +1 -1
  62. package/dist/documents/profile.d.ts.map +1 -1
  63. package/dist/documents/profile.js +10 -4
  64. package/dist/documents/profile.js.map +1 -1
  65. package/dist/documents/python.d.ts.map +1 -1
  66. package/dist/documents/python.js +12 -3
  67. package/dist/documents/python.js.map +1 -1
  68. package/dist/documents/tools.d.ts.map +1 -1
  69. package/dist/documents/tools.js +105 -29
  70. package/dist/documents/tools.js.map +1 -1
  71. package/dist/documents/types.d.ts.map +1 -1
  72. package/dist/extensions.d.ts.map +1 -1
  73. package/dist/extensions.js +6 -2
  74. package/dist/extensions.js.map +1 -1
  75. package/dist/genai-spans-file.d.ts +1 -14
  76. package/dist/genai-spans-file.d.ts.map +1 -1
  77. package/dist/genai-spans-file.js +5 -3
  78. package/dist/genai-spans-file.js.map +1 -1
  79. package/dist/index.d.ts +1 -1
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +1 -1
  82. package/dist/index.js.map +1 -1
  83. package/dist/inspect.d.ts.map +1 -1
  84. package/dist/inspect.js +2 -3
  85. package/dist/inspect.js.map +1 -1
  86. package/dist/interaction-tui.d.ts +0 -2
  87. package/dist/interaction-tui.d.ts.map +1 -1
  88. package/dist/interaction-tui.js +9 -4
  89. package/dist/interaction-tui.js.map +1 -1
  90. package/dist/interactions.d.ts.map +1 -1
  91. package/dist/interactions.js +1 -3
  92. package/dist/interactions.js.map +1 -1
  93. package/dist/mcp/catalog.d.ts.map +1 -1
  94. package/dist/mcp/catalog.js.map +1 -1
  95. package/dist/mcp/cli/command-context.d.ts.map +1 -1
  96. package/dist/mcp/cli/command-context.js.map +1 -1
  97. package/dist/mcp/cli/core.d.ts +0 -41
  98. package/dist/mcp/cli/core.d.ts.map +1 -1
  99. package/dist/mcp/cli/core.js +79 -37
  100. package/dist/mcp/cli/core.js.map +1 -1
  101. package/dist/mcp/cli/help.js +3 -3
  102. package/dist/mcp/cli/help.js.map +1 -1
  103. package/dist/mcp/cli/index.js.map +1 -1
  104. package/dist/mcp/cli/policy.d.ts +2 -1
  105. package/dist/mcp/cli/policy.d.ts.map +1 -1
  106. package/dist/mcp/cli/policy.js +19 -11
  107. package/dist/mcp/cli/policy.js.map +1 -1
  108. package/dist/mcp/client-entry.js.map +1 -1
  109. package/dist/mcp/contract.d.ts.map +1 -1
  110. package/dist/mcp/contract.js +8 -3
  111. package/dist/mcp/contract.js.map +1 -1
  112. package/dist/mcp/daemon/client.d.ts +4 -0
  113. package/dist/mcp/daemon/client.d.ts.map +1 -1
  114. package/dist/mcp/daemon/client.js +4 -0
  115. package/dist/mcp/daemon/client.js.map +1 -1
  116. package/dist/mcp/daemon/index.js +9 -4
  117. package/dist/mcp/daemon/index.js.map +1 -1
  118. package/dist/mcp/daemon/protocol.d.ts +7 -6
  119. package/dist/mcp/daemon/protocol.d.ts.map +1 -1
  120. package/dist/mcp/index.d.ts +2 -6
  121. package/dist/mcp/index.d.ts.map +1 -1
  122. package/dist/mcp/index.js +36 -20
  123. package/dist/mcp/index.js.map +1 -1
  124. package/dist/mcp/tools.d.ts +1 -14
  125. package/dist/mcp/tools.d.ts.map +1 -1
  126. package/dist/mcp/tools.js +9 -4
  127. package/dist/mcp/tools.js.map +1 -1
  128. package/dist/mcp-chunks/{chunk-EZKOZO3F.js → chunk-GODH4VLN.js} +179 -70
  129. package/dist/mcp-daemon.js +29 -19
  130. package/dist/mcp-run-worker.js +1 -1
  131. package/dist/memory.d.ts.map +1 -1
  132. package/dist/memory.js +1 -1
  133. package/dist/memory.js.map +1 -1
  134. package/dist/model-binding.d.ts +4 -5
  135. package/dist/model-binding.d.ts.map +1 -1
  136. package/dist/model-binding.js +5 -5
  137. package/dist/model-binding.js.map +1 -1
  138. package/dist/pi-extension.d.ts.map +1 -1
  139. package/dist/pi-extension.js +39 -33
  140. package/dist/pi-extension.js.map +1 -1
  141. package/dist/python.d.ts.map +1 -1
  142. package/dist/python.js +5 -1
  143. package/dist/python.js.map +1 -1
  144. package/dist/recipe/agent.d.ts +9 -6
  145. package/dist/recipe/agent.d.ts.map +1 -1
  146. package/dist/recipe/agent.js +23 -28
  147. package/dist/recipe/agent.js.map +1 -1
  148. package/dist/recipe/companions.d.ts +0 -15
  149. package/dist/recipe/companions.d.ts.map +1 -1
  150. package/dist/recipe/companions.js +29 -11
  151. package/dist/recipe/companions.js.map +1 -1
  152. package/dist/recipe/extensions.d.ts.map +1 -1
  153. package/dist/recipe/extensions.js +23 -6
  154. package/dist/recipe/extensions.js.map +1 -1
  155. package/dist/recipe/mcp-config.d.ts +0 -12
  156. package/dist/recipe/mcp-config.d.ts.map +1 -1
  157. package/dist/recipe/mcp-config.js +1 -70
  158. package/dist/recipe/mcp-config.js.map +1 -1
  159. package/dist/recipe/model.d.ts +8 -7
  160. package/dist/recipe/model.d.ts.map +1 -1
  161. package/dist/recipe/model.js +2 -6
  162. package/dist/recipe/model.js.map +1 -1
  163. package/dist/recipe/package.d.ts +3 -16
  164. package/dist/recipe/package.d.ts.map +1 -1
  165. package/dist/recipe/package.js +105 -40
  166. package/dist/recipe/package.js.map +1 -1
  167. package/dist/recipe/python.d.ts +0 -8
  168. package/dist/recipe/python.d.ts.map +1 -1
  169. package/dist/recipe/python.js +40 -13
  170. package/dist/recipe/python.js.map +1 -1
  171. package/dist/recipe/resolve.d.ts.map +1 -1
  172. package/dist/recipe/resolve.js +4 -9
  173. package/dist/recipe/resolve.js.map +1 -1
  174. package/dist/recipe/session.d.ts +3 -2
  175. package/dist/recipe/session.d.ts.map +1 -1
  176. package/dist/recipe/session.js +4 -3
  177. package/dist/recipe/session.js.map +1 -1
  178. package/dist/recipe/skills-prompt.d.ts.map +1 -1
  179. package/dist/recipe/skills-prompt.js +6 -1
  180. package/dist/recipe/skills-prompt.js.map +1 -1
  181. package/dist/recipe/skills.d.ts +0 -6
  182. package/dist/recipe/skills.d.ts.map +1 -1
  183. package/dist/recipe/skills.js +8 -5
  184. package/dist/recipe/skills.js.map +1 -1
  185. package/dist/recipe/suggestions.d.ts.map +1 -1
  186. package/dist/recipe/suggestions.js +21 -8
  187. package/dist/recipe/suggestions.js.map +1 -1
  188. package/dist/run-controller.d.ts +0 -2
  189. package/dist/run-controller.d.ts.map +1 -1
  190. package/dist/run-controller.js +4 -2
  191. package/dist/run-controller.js.map +1 -1
  192. package/dist/session.d.ts +10 -4
  193. package/dist/session.d.ts.map +1 -1
  194. package/dist/session.js +30 -26
  195. package/dist/session.js.map +1 -1
  196. package/dist/skill-progress.d.ts +69 -20
  197. package/dist/skill-progress.d.ts.map +1 -1
  198. package/dist/skill-progress.js +153 -37
  199. package/dist/skill-progress.js.map +1 -1
  200. package/dist/suggestion-picker.d.ts +0 -3
  201. package/dist/suggestion-picker.d.ts.map +1 -1
  202. package/dist/suggestion-picker.js +4 -2
  203. package/dist/suggestion-picker.js.map +1 -1
  204. package/dist/test-utils.d.ts.map +1 -1
  205. package/dist/test-utils.js.map +1 -1
  206. package/docs/agent-composition.md +1 -0
  207. package/docs/pi-extension.md +41 -5
  208. package/docs/recipe-format.md +6 -0
  209. package/package.json +18 -6
@@ -1,6 +1,6 @@
1
1
  import { createHash, randomUUID } from "node:crypto";
2
2
  import { existsSync } from "node:fs";
3
- import { mkdir, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
3
+ import { mkdir, open, readFile, rename, rm, stat, writeFile, } from "node:fs/promises";
4
4
  import { dirname, join } from "node:path";
5
5
  import { setTimeout as delay } from "node:timers/promises";
6
6
  import { stdin as input, stderr, stdout } from "node:process";
@@ -49,9 +49,9 @@ async function closeOwnedRuntime(runtime, owned) {
49
49
  if (owned)
50
50
  await runtime.close();
51
51
  }
52
- export class McpRunUsageError extends Error {
52
+ class McpRunUsageError extends Error {
53
53
  }
54
- export class McpRunTimeoutError extends Error {
54
+ class McpRunTimeoutError extends Error {
55
55
  outcome = "unknown";
56
56
  constructor(message) {
57
57
  super(message);
@@ -66,7 +66,7 @@ class McpRemoteToolResultError extends Error {
66
66
  this.name = "McpRemoteToolResultError";
67
67
  }
68
68
  }
69
- export class McpRunToolError extends Error {
69
+ class McpRunToolError extends Error {
70
70
  server;
71
71
  tool;
72
72
  kind = "tool_execution";
@@ -117,7 +117,7 @@ function checkedCallResult(callResult) {
117
117
  ? parsedError
118
118
  : typeof errorObject.message === "string"
119
119
  ? errorObject.message
120
- : callResult.text() ?? "MCP tool call failed.";
120
+ : (callResult.text() ?? "MCP tool call failed.");
121
121
  throw new McpRemoteToolResultError({ ...errorObject, message });
122
122
  }
123
123
  return callResult;
@@ -126,7 +126,9 @@ function decodeCallResult(callResult, format, ref) {
126
126
  switch (format) {
127
127
  case "json": {
128
128
  const decoded = callResult.json();
129
- if (decoded === null && callResult.structuredContent() == null && callResult.text() != null) {
129
+ if (decoded === null &&
130
+ callResult.structuredContent() == null &&
131
+ callResult.text() != null) {
130
132
  // The text is usually the reason (not connected, an upstream error), so
131
133
  // it travels with the error instead of being hidden behind a format hint.
132
134
  const text = callResult.text().trim();
@@ -238,7 +240,9 @@ function scoreTool(opts) {
238
240
  const description = opts.tool.description ?? "";
239
241
  const properties = toolProperties(opts.tool);
240
242
  const propertyNames = properties.map((property) => property.name).join(" ");
241
- const propertyDescriptions = properties.map((property) => property.description).join(" ");
243
+ const propertyDescriptions = properties
244
+ .map((property) => property.description)
245
+ .join(" ");
242
246
  const searchable = [
243
247
  ref,
244
248
  opts.serverId,
@@ -298,7 +302,9 @@ function exampleValue(name) {
298
302
  }
299
303
  function callExample(serverId, tool) {
300
304
  const required = toolRequired(tool);
301
- const args = required.slice(0, 4).map((name) => `${name}${exampleValue(name)}`);
305
+ const args = required
306
+ .slice(0, 4)
307
+ .map((name) => `${name}${exampleValue(name)}`);
302
308
  return ["mcp call", `${serverId}.${tool.name}`, ...args].join(" ");
303
309
  }
304
310
  export function searchMcpTools(session, query, opts = {}) {
@@ -421,7 +427,8 @@ async function catalogLockIsStale(path, timeoutMs) {
421
427
  typeof owner.createdAt === "number" &&
422
428
  Number.isFinite(owner.createdAt)) {
423
429
  return (!processExists(owner.pid) ||
424
- Date.now() - owner.createdAt > timeoutMs + CATALOG_LOCK_INCOMPLETE_GRACE_MS);
430
+ Date.now() - owner.createdAt >
431
+ timeoutMs + CATALOG_LOCK_INCOMPLETE_GRACE_MS);
425
432
  }
426
433
  }
427
434
  catch (error) {
@@ -558,16 +565,23 @@ function optionName(value) {
558
565
  }
559
566
  export function parseSearchArgs(args) {
560
567
  if (args.some((arg) => optionName(arg) === "--json")) {
561
- return { error: "mcp search metadata is compact text; JSON is reserved for tool results." };
568
+ return {
569
+ error: "mcp search metadata is compact text; JSON is reserved for tool results.",
570
+ };
562
571
  }
563
572
  let parsed;
564
573
  try {
565
- parsed = parseArgs({ args, options: SEARCH_OPTIONS, allowPositionals: true });
574
+ parsed = parseArgs({
575
+ args,
576
+ options: SEARCH_OPTIONS,
577
+ allowPositionals: true,
578
+ });
566
579
  }
567
580
  catch (error) {
568
581
  // An agent reads these and decides what to try next, so the wording stays
569
582
  // ours rather than Node's.
570
- if (error.code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE") {
583
+ if (error.code ===
584
+ "ERR_PARSE_ARGS_INVALID_OPTION_VALUE") {
571
585
  // parseArgs rejects an option-shaped value (`--limit -1`) before it is
572
586
  // read, so the value has to be recovered to name it back.
573
587
  const index = args.findIndex((arg) => optionName(arg) === "--limit");
@@ -585,7 +599,9 @@ export function parseSearchArgs(args) {
585
599
  if (values.limit !== undefined) {
586
600
  const value = Number(values.limit);
587
601
  if (!Number.isInteger(value) || value <= 0) {
588
- return { error: `--limit expects a positive integer, got '${values.limit}'.` };
602
+ return {
603
+ error: `--limit expects a positive integer, got '${values.limit}'.`,
604
+ };
589
605
  }
590
606
  limit = value;
591
607
  }
@@ -600,7 +616,9 @@ export function renderSearchResults(matches, catalogs) {
600
616
  let budget = MAX_SEARCH_CONTRACT_CHARS;
601
617
  let shortened = false;
602
618
  const blocks = matches.map((match, index) => {
603
- const entry = catalogs.get(match.server)?.find((tool) => tool.name === match.tool);
619
+ const entry = catalogs
620
+ .get(match.server)
621
+ ?.find((tool) => tool.name === match.tool);
604
622
  if (!entry)
605
623
  return `${match.ref}${match.description ? ` — ${match.description}` : ""}\n`;
606
624
  const tool = {
@@ -631,7 +649,7 @@ async function searchCatalog(args) {
631
649
  }
632
650
  const { query, limit, regex } = parsed;
633
651
  if (!query.trim()) {
634
- stderr.write("Usage: mcp search \"what you need\" [--limit N] [--regex]\n");
652
+ stderr.write('Usage: mcp search "what you need" [--limit N] [--regex]\n');
635
653
  return 2;
636
654
  }
637
655
  let matches;
@@ -703,7 +721,9 @@ function toolCount(count) {
703
721
  }
704
722
  export function parseListTimeoutMs(args) {
705
723
  const configured = process.env.MCPORTER_LIST_TIMEOUT;
706
- let raw = configured && /^[1-9]\d*$/.test(configured) ? configured : String(DEFAULT_LIST_TIMEOUT_MS);
724
+ let raw = configured && /^[1-9]\d*$/.test(configured)
725
+ ? configured
726
+ : String(DEFAULT_LIST_TIMEOUT_MS);
707
727
  // Non-strict: every other option on this line belongs to mcporter.
708
728
  const { values } = parseArgs({
709
729
  args: [...args.slice(1)],
@@ -726,7 +746,7 @@ export function parseListTimeoutMs(args) {
726
746
  ? timeout
727
747
  : "mcp list: --timeout must be a positive integer (milliseconds).";
728
748
  }
729
- export function withListTimeout(promise, timeoutMs) {
749
+ function withListTimeout(promise, timeoutMs) {
730
750
  return new Promise((resolve, reject) => {
731
751
  const timer = setTimeout(() => reject(new Error(`timed out after ${timeoutMs}ms`)), timeoutMs);
732
752
  promise.then((value) => {
@@ -738,14 +758,15 @@ export function withListTimeout(promise, timeoutMs) {
738
758
  });
739
759
  });
740
760
  }
741
- export function aggregateListExitCode(hadFailure, args) {
742
- return hadFailure && (args.includes("--quiet") || args.includes("--exit-code"))
761
+ function aggregateListExitCode(hadFailure, args) {
762
+ return hadFailure &&
763
+ (args.includes("--quiet") || args.includes("--exit-code"))
743
764
  ? 1
744
765
  : 0;
745
766
  }
746
767
  function writeCompactListError(error) {
747
768
  const filter = createDelegatedErrorFilter((text) => stderr.write(text));
748
- const message = error instanceof Error ? error.stack ?? error.message : String(error);
769
+ const message = error instanceof Error ? (error.stack ?? error.message) : String(error);
749
770
  filter.push(`mcp list: ${message.endsWith("\n") ? message : `${message}\n`}`);
750
771
  filter.flush();
751
772
  }
@@ -876,7 +897,9 @@ async function compactList(args) {
876
897
  stdout.write(`${server} ok — ${toolCount(tools.length)}\n`);
877
898
  return 0;
878
899
  }
879
- const selected = exact ? tools.filter((tool) => tool.name === exact.tool) : tools;
900
+ const selected = exact
901
+ ? tools.filter((tool) => tool.name === exact.tool)
902
+ : tools;
880
903
  if (exact && selected.length === 0) {
881
904
  stderr.write(`Tool '${exact.tool}' is not available on server '${server}'.\n`);
882
905
  return 1;
@@ -992,7 +1015,9 @@ function improveRunToolError(error, server, tool, knownTools) {
992
1015
  }
993
1016
  if (!RUN_TOOL_REJECTED_PATTERNS.some((pattern) => pattern.test(message)))
994
1017
  return error;
995
- return new Error(describeUnavailableRunTool(server, tool, knownTools), { cause: error });
1018
+ return new Error(describeUnavailableRunTool(server, tool, knownTools), {
1019
+ cause: error,
1020
+ });
996
1021
  }
997
1022
  // A refused version probe means the connection never opened, so the tool did
998
1023
  // not run and the call can be made again. Any later failure may follow a
@@ -1015,7 +1040,9 @@ export async function callToolWithHandshakeRetry(runtime, server, tool, options,
1015
1040
  }
1016
1041
  catch (error) {
1017
1042
  const wait = HANDSHAKE_RETRY_DELAYS_MS[attempt];
1018
- if (wait === undefined || !refusedHandshake(error) || Date.now() + wait >= deadlineMs) {
1043
+ if (wait === undefined ||
1044
+ !refusedHandshake(error) ||
1045
+ Date.now() + wait >= deadlineMs) {
1019
1046
  throw error;
1020
1047
  }
1021
1048
  await delay(wait);
@@ -1092,7 +1119,9 @@ async function createTools(opts) {
1092
1119
  : `MCP tool call ${server}.${property} timed out.`,
1093
1120
  retryable: true,
1094
1121
  action: "inspect_state",
1095
- outcome: improved instanceof McpRunTimeoutError ? "not_started" : "unknown",
1122
+ outcome: improved instanceof McpRunTimeoutError
1123
+ ? "not_started"
1124
+ : "unknown",
1096
1125
  }
1097
1126
  : undefined;
1098
1127
  throw new McpRunToolError(server, property, remoteDetails?.message ?? timeoutDetails?.message ?? message, { cause: improved, details: remoteDetails ?? timeoutDetails });
@@ -1112,7 +1141,8 @@ async function createTools(opts) {
1112
1141
  record.outcome = "succeeded";
1113
1142
  }, (error) => {
1114
1143
  record.outcome = "failed";
1115
- record.error = error instanceof Error ? error.message : String(error);
1144
+ record.error =
1145
+ error instanceof Error ? error.message : String(error);
1116
1146
  });
1117
1147
  // JSON.stringify(promise) is "{}" — the classic missing-await
1118
1148
  // symptom. Make it print a diagnosis instead.
@@ -1170,7 +1200,9 @@ function createVars(vars) {
1170
1200
  return target[property];
1171
1201
  const defined = Object.keys(target);
1172
1202
  throw new Error(`vars.${property} is not defined. Pass it with --var ${property}=value` +
1173
- (defined.length > 0 ? ` (defined vars: ${defined.join(", ")}).` : " (no vars were passed).") +
1203
+ (defined.length > 0
1204
+ ? ` (defined vars: ${defined.join(", ")}).`
1205
+ : " (no vars were passed).") +
1174
1206
  ` Use \`"${property}" in vars\` to test for optional vars.`);
1175
1207
  },
1176
1208
  });
@@ -1194,7 +1226,9 @@ function concurrentOutcomeError(error, calls) {
1194
1226
  outcome: call.outcome,
1195
1227
  ...(call.error ? { error: call.error } : {}),
1196
1228
  }));
1197
- const summary = outcomes.map((call) => `${call.ref}=${call.outcome}`).join(", ");
1229
+ const summary = outcomes
1230
+ .map((call) => `${call.ref}=${call.outcome}`)
1231
+ .join(", ");
1198
1232
  const message = `${error.message} Workflow call outcomes: ${summary}. Inspect state before retrying side-effecting calls.`;
1199
1233
  return new McpRunToolError(error.server, error.tool, message, {
1200
1234
  cause: error,
@@ -1208,7 +1242,7 @@ function positiveInteger(value, label, fallback) {
1208
1242
  }
1209
1243
  return parsed;
1210
1244
  }
1211
- export async function runMcpJavaScript(code, opts = {}) {
1245
+ async function runMcpJavaScript(code, opts = {}) {
1212
1246
  const timeoutMs = positiveInteger(opts.timeoutMs ?? process.env.PI_RECIPES_MCP_RUN_TIMEOUT_MS, "PI_RECIPES_MCP_RUN_TIMEOUT_MS", DEFAULT_RUN_TIMEOUT_MS);
1213
1247
  const callTimeoutMs = positiveInteger(opts.callTimeoutMs ?? process.env.PI_RECIPES_MCP_RUN_CALL_TIMEOUT_MS, "PI_RECIPES_MCP_RUN_CALL_TIMEOUT_MS", Math.min(DEFAULT_TOOL_CALL_TIMEOUT_MS, timeoutMs));
1214
1248
  const maxCalls = positiveInteger(opts.maxCalls ?? process.env.PI_RECIPES_MCP_RUN_MAX_CALLS, "PI_RECIPES_MCP_RUN_MAX_CALLS", DEFAULT_MAX_RUN_TOOL_CALLS);
@@ -1220,7 +1254,8 @@ export async function runMcpJavaScript(code, opts = {}) {
1220
1254
  maxConcurrentCalls,
1221
1255
  deadlineMs,
1222
1256
  });
1223
- const AsyncFunction = Object.getPrototypeOf(async function () { }).constructor;
1257
+ const AsyncFunction = Object.getPrototypeOf(async function () { })
1258
+ .constructor;
1224
1259
  const run = new AsyncFunction("tools", "vars", "process", code);
1225
1260
  let timeout;
1226
1261
  let primaryError;
@@ -1314,6 +1349,7 @@ export async function runMcpJavaScript(code, opts = {}) {
1314
1349
  // Transport cleanup must not replace the typed tool/script error that
1315
1350
  // tells the agent what actually failed. A close-only failure still
1316
1351
  // surfaces normally.
1352
+ // eslint-disable-next-line no-unsafe-finally -- only when nothing else failed
1317
1353
  if (primaryError === undefined)
1318
1354
  throw closeError;
1319
1355
  }
@@ -1350,7 +1386,9 @@ async function runCode(args) {
1350
1386
  jsonErrors = true;
1351
1387
  continue;
1352
1388
  }
1353
- const inline = arg.startsWith("--var=") ? arg.slice("--var=".length) : undefined;
1389
+ const inline = arg.startsWith("--var=")
1390
+ ? arg.slice("--var=".length)
1391
+ : undefined;
1354
1392
  const value = inline ?? (arg === "--var" ? args[++index] : undefined);
1355
1393
  if (arg === "--var" || inline !== undefined) {
1356
1394
  const eq = value?.indexOf("=") ?? -1;
@@ -1396,7 +1434,9 @@ async function runCode(args) {
1396
1434
  ? error.message
1397
1435
  : `${error.name}: ${error.message}`
1398
1436
  : String(error);
1399
- const prefixed = message.startsWith("mcp run") ? message : `mcp run: ${message}`;
1437
+ const prefixed = message.startsWith("mcp run")
1438
+ ? message
1439
+ : `mcp run: ${message}`;
1400
1440
  const code = error instanceof McpRunUsageError ? 2 : 1;
1401
1441
  if (jsonErrors) {
1402
1442
  const remoteDetails = error instanceof McpRunToolError ? error.details : undefined;
@@ -1438,7 +1478,7 @@ async function runCode(args) {
1438
1478
  }
1439
1479
  return 0;
1440
1480
  }
1441
- export function createDelegatedErrorFilter(write) {
1481
+ function createDelegatedErrorFilter(write) {
1442
1482
  let buffer = "";
1443
1483
  let sawOAuthMetadataError = false;
1444
1484
  const emit = (line) => {
@@ -1475,7 +1515,7 @@ export function createDelegatedErrorFilter(write) {
1475
1515
  },
1476
1516
  };
1477
1517
  }
1478
- export function duplicateCallArgumentKeys(args) {
1518
+ function duplicateCallArgumentKeys(args) {
1479
1519
  const seen = new Set();
1480
1520
  const duplicates = new Set();
1481
1521
  for (const token of args.slice(1)) {
@@ -1506,7 +1546,7 @@ export function callJsonArgumentError(args) {
1506
1546
  }
1507
1547
  return null;
1508
1548
  }
1509
- export function malformedCallExpression(args) {
1549
+ function malformedCallExpression(args) {
1510
1550
  const ref = args.find((arg) => !arg.startsWith("-"));
1511
1551
  if (!ref || !/[()]/.test(ref))
1512
1552
  return null;
@@ -1573,7 +1613,8 @@ async function callWithSharedRuntime(runtime, args) {
1573
1613
  break;
1574
1614
  }
1575
1615
  }
1576
- if (normalizedArgs[index] === "--json" && normalizedArgs[index + 1] === "-") {
1616
+ if (normalizedArgs[index] === "--json" &&
1617
+ normalizedArgs[index + 1] === "-") {
1577
1618
  normalizedArgs[index + 1] = await readStdin();
1578
1619
  }
1579
1620
  }
@@ -1714,7 +1755,7 @@ function describeSharedCallError(error, server, tool) {
1714
1755
  const signal = issue.stdioSignal ? ` (signal ${issue.stdioSignal})` : "";
1715
1756
  return `MCP server '${server}' exited with ${exit}${signal}.`;
1716
1757
  }
1717
- return issue.rawMessage || (error instanceof Error ? error.message : String(error));
1758
+ return (issue.rawMessage || (error instanceof Error ? error.message : String(error)));
1718
1759
  }
1719
1760
  function schemaAllowsString(value) {
1720
1761
  const schema = asRecord(value);
@@ -1761,7 +1802,8 @@ async function restoreSchemaStringArguments(runtime, server, tool, values, candi
1761
1802
  return values;
1762
1803
  let corrected;
1763
1804
  for (const [key, rawValue] of Object.entries(candidates)) {
1764
- if (typeof values[key] !== "number" || !schemaAllowsString(properties[key])) {
1805
+ if (typeof values[key] !== "number" ||
1806
+ !schemaAllowsString(properties[key])) {
1765
1807
  continue;
1766
1808
  }
1767
1809
  corrected ??= { ...values };