@agntn/tools 0.3.0 → 0.3.2

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.
@@ -12,6 +12,14 @@ export interface McpServerInfo {
12
12
  /** Project home a client can link to. */
13
13
  readonly websiteUrl?: string;
14
14
  }
15
+ /** What a tool finds in `host` over MCP. The client wrote all of it, so none of it is proof. */
16
+ export interface McpHost {
17
+ readonly mcp: true;
18
+ /** The HTTP request behind the call, headers included. Absent over stdio. */
19
+ readonly request?: Request;
20
+ /** The call's `_meta` as the transport hands it over, such as a harness's session id. */
21
+ readonly meta?: Readonly<Record<string, unknown>>;
22
+ }
15
23
  /**
16
24
  * Maps a tool's title and declared effect to MCP annotations. Claude Code reads its label here.
17
25
  * A process the tool starts can delete anything, so `exec` counts as destructive.
@@ -1,6 +1,16 @@
1
1
  import { Check, Errors } from "./libs/typebox.mjs";
2
2
  import { ToolInputError, indexTools, invokeTool, sanitizeLine, wireSchema } from "./src.mjs";
3
+ import { causeLines } from "./causes.mjs";
3
4
  import { hostAsk, readAnswer } from "./questions.mjs";
5
+ function mcpHost(from) {
6
+ const { request, meta } = from;
7
+ if (request === void 0 && meta === void 0) return {};
8
+ return { host: {
9
+ mcp: true,
10
+ ...request === void 0 ? {} : { request },
11
+ ...meta === void 0 ? {} : { meta }
12
+ } };
13
+ }
4
14
  function toolAnnotations(tool) {
5
15
  return {
6
16
  title: tool.title,
@@ -45,7 +55,7 @@ async function callTool(info, tools, name, args = {}, context = {}) {
45
55
  return answer(tool, await invokeTool(tool, args, context));
46
56
  } catch (error) {
47
57
  if (error instanceof ToolInputError) return errorResult(...error.lines);
48
- return errorResult(`${tool.name} failed: ${error instanceof Error ? error.message : String(error)}`);
58
+ return errorResult(`${tool.name} failed: ${error instanceof Error ? error.message : String(error)}`, ...causeLines(error));
49
59
  }
50
60
  }
51
61
  function answer(tool, result) {
@@ -180,4 +190,4 @@ function progressSteps(notify) {
180
190
  });
181
191
  };
182
192
  }
183
- export { callAsking, callTool, canAsk, copyIcons, errorResult, listTools, progressSteps, questionRound, toolAnnotations };
193
+ export { callAsking, callTool, canAsk, copyIcons, errorResult, listTools, mcpHost, progressSteps, questionRound, toolAnnotations };
package/dist/ai.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ToolDefinitionError, indexTools, invokeTool, resultText, validateInput, wireSchema } from "./_chunks/src.mjs";
2
+ import { throwWithCauses } from "./_chunks/causes.mjs";
2
3
  import { jsonSchema, tool } from "ai";
3
4
  function toAiTool(definition) {
4
5
  return tool({
@@ -15,7 +16,7 @@ function toAiTool(definition) {
15
16
  };
16
17
  } }),
17
18
  async execute(input, { abortSignal }) {
18
- const result = await invokeTool(definition, input, abortSignal ? { signal: abortSignal } : {});
19
+ const result = await invokeTool(definition, input, abortSignal ? { signal: abortSignal } : {}).catch(throwWithCauses);
19
20
  const text = resultText(result);
20
21
  if (result.isError) throw new Error(text);
21
22
  return aiOutput(definition.name, result, text);
package/dist/cli.d.mts CHANGED
@@ -16,18 +16,29 @@ export interface CliOptions {
16
16
  * and leaves `progress` alone: on a terminal its line would sit in front of the rows.
17
17
  */
18
18
  readonly commands?: readonly ToolDefinition[];
19
- /** Command for an empty command line. */
19
+ /**
20
+ * Groups the `cli.command` hints open with a first word, as `servers` in
21
+ * `servers list`: their line in the command list and more words for them.
22
+ */
23
+ readonly groups?: Readonly<Record<string, CliGroup>>;
24
+ /** Command for an empty command line, two words for a command in a group. */
20
25
  readonly default?: string;
21
26
  /** Command for a first word that names no command: `hashes sha256 x` runs `hashes hash sha256 x`. */
22
27
  readonly fallback?: string;
23
28
  /** Adds `mcp` over stdio, named by the CLI on `true` or by the server info it's handed. */
24
29
  readonly mcp?: boolean | McpServerInfo;
25
30
  /**
26
- * Errors the package throws on purpose. They print as one line with exit
27
- * code 1; any other error keeps its stack trace.
31
+ * Errors the package throws on purpose. They print as one line with a `caused by:`
32
+ * line per cause and exit code 1; any other error keeps its stack trace.
28
33
  */
29
34
  readonly expected?: (error: unknown) => boolean;
30
35
  }
36
+ /** A group of commands: `servers` in `servers list` and `servers add`. */
37
+ export interface CliGroup {
38
+ /** Line in the command list. Defaults to the names of its commands. */
39
+ readonly description?: string;
40
+ readonly aliases?: readonly string[];
41
+ }
31
42
  /** What a CLI command finds in `host`: narrow to it and look at `json` before writing a byte. */
32
43
  export interface CliHost {
33
44
  readonly cli: true;
@@ -36,7 +47,8 @@ export interface CliHost {
36
47
  }
37
48
  /**
38
49
  * @param tool - Tool to name.
39
- * @returns {string} The hinted command, or the tool name without its package prefix, in kebab case.
50
+ * @returns {string} The hinted command, two words for one in a group, or the tool name without
51
+ * its package prefix, in kebab case.
40
52
  */
41
53
  export declare function commandName(tool: ToolDefinition): string;
42
54
  /** A built command line interface. */
@@ -50,7 +62,8 @@ export interface Cli {
50
62
  *
51
63
  * @param options - CLI options.
52
64
  * @returns {Cli} The CLI.
53
- * @throws {ToolDefinitionError} When two commands share a name or alias, a hint does not fit its schema, or `default` or `fallback` names no command.
65
+ * @throws {ToolDefinitionError} When two commands share a name or alias, a hint does not fit its
66
+ * schema, `groups` names no group, or `default` or `fallback` names no command.
54
67
  */
55
68
  export declare function createCli(options: CliOptions): Cli;
56
69
  /**
package/dist/cli.mjs CHANGED
@@ -22,7 +22,7 @@ function flagName(key) {
22
22
  return key.replaceAll(/([a-z0-9])([A-Z])/g, "$1-$2").replaceAll("_", "-").toLowerCase();
23
23
  }
24
24
  function commandName(tool) {
25
- if (tool.cli?.command !== void 0) return commandWord(tool.name, tool.cli.command);
25
+ if (tool.cli?.command !== void 0) return commandPath(tool.name, tool.cli.command);
26
26
  const separator = tool.name.indexOf("_");
27
27
  const derived = separator === -1 ? tool.name : tool.name.slice(separator + 1);
28
28
  return commandWord(tool.name, derived.replaceAll("_", "-"));
@@ -32,6 +32,12 @@ function commandWord(owner, word) {
32
32
  if (!COMMAND_WORD.test(word)) throw new ToolDefinitionError(`${owner}: command ${JSON.stringify(word)} must match ${COMMAND_WORD}`);
33
33
  return word;
34
34
  }
35
+ function commandPath(owner, path) {
36
+ const words = path.split(" ");
37
+ if (words.length > 2) throw new ToolDefinitionError(`${owner}: command ${JSON.stringify(path)} takes two words at most`);
38
+ for (const word of words) commandWord(owner, word);
39
+ return path;
40
+ }
35
41
  function fieldKind(schema) {
36
42
  if (Array.isArray(schema.enum) && schema.enum.every((value) => typeof value === "string")) return "enum";
37
43
  if ((Array.isArray(schema.anyOf) ? schema.anyOf : []).some((branch) => fieldKind(branch) === "json")) return "json";
@@ -456,18 +462,20 @@ function fail(lines) {
456
462
  writeLine("stderr", lines.map(sanitizeLine).join("\n"));
457
463
  process.exitCode = 1;
458
464
  }
459
- function handleError(options, error) {
465
+ async function handleError(options, error) {
460
466
  if (error instanceof ToolInputError) fail(error.lines);
461
- else if (options.expected?.(error) === true) fail([error instanceof Error ? error.message : String(error)]);
462
- else throw error;
467
+ else if (options.expected?.(error) === true) {
468
+ const { causeLines } = await import("./_chunks/causes.mjs").then((n) => n.causes_exports);
469
+ fail([error instanceof Error ? error.message : String(error), ...causeLines(error)]);
470
+ } else throw error;
463
471
  }
464
472
  function detailsJson(details) {
465
473
  return (JSON.stringify(details, (_key, value) => typeof value === "bigint" ? value.toString() : value, 2) ?? "null").replaceAll(JSON_FORGING, (character) => `\\u${(character.codePointAt(0) ?? 0).toString(16).padStart(4, "0")}`);
466
474
  }
467
475
  const JSON_FORGING = /[\u007F-\u009F\u061C\u200E\u200F\u2028\u2029\u202A-\u202E\u2066-\u206F]/g;
468
- const GRAPHEMES = new Intl.Segmenter();
476
+ let graphemes;
469
477
  const WIDE = /^(?:\p{Extended_Pictographic}|[\u1100-\u115F\u231A\u231B\u2329\u232A\u2630-\u2637\u268A-\u268F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DFF\u4E00-\u9FFF\uA000-\uA4CF\uA960-\uA97F\uAC00-\uD7A3\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6\u{16FE0}-\u{18DFF}\u{1AFF0}-\u{1B2FF}\u{1D15E}-\u{1D164}\u{1D1BB}-\u{1D1C0}\u{1D300}-\u{1D376}\u{1F000}-\u{1FAFF}\u{20000}-\u{3FFFD}])$/u;
470
- const EMOJI = /^\p{RGI_Emoji}$/v;
478
+ let emoji;
471
479
  const ZERO_WIDTH = /^[\p{Mn}\p{Me}]$/u;
472
480
  function pointCells(point) {
473
481
  if (WIDE.test(point)) return 2;
@@ -476,12 +484,14 @@ function pointCells(point) {
476
484
  function graphemeCells(grapheme) {
477
485
  let size = 0;
478
486
  for (const point of grapheme.normalize("NFC")) size += pointCells(point);
479
- return Math.max(EMOJI.test(grapheme) ? 2 : 1, size);
487
+ emoji ??= /^\p{RGI_Emoji}$/v;
488
+ return Math.max(emoji.test(grapheme) ? 2 : 1, size);
480
489
  }
481
490
  function fitLine(text, room) {
482
491
  let fitted = "";
483
492
  let used = 0;
484
- for (const { segment } of GRAPHEMES.segment(text)) {
493
+ graphemes ??= new Intl.Segmenter();
494
+ for (const { segment } of graphemes.segment(text)) {
485
495
  const size = graphemeCells(segment);
486
496
  if (used + size > room) break;
487
497
  fitted += segment;
@@ -521,8 +531,10 @@ function progressLine() {
521
531
  function toolCommand(tool) {
522
532
  const fields = toolFields(tool);
523
533
  const [summary = tool.title] = tool.description.split(/(?<=[.!?])\s/, 1);
534
+ const name = commandName(tool);
524
535
  return {
525
- name: commandName(tool),
536
+ name,
537
+ word: name.slice(name.indexOf(" ") + 1),
526
538
  aliases: (tool.cli?.aliases ?? []).map((alias) => commandWord(tool.name, alias)),
527
539
  summary: tool.cli?.description ?? summary,
528
540
  fields,
@@ -559,6 +571,7 @@ function toolCommand(tool) {
559
571
  function mcpCommand(options) {
560
572
  return {
561
573
  name: "mcp",
574
+ word: "mcp",
562
575
  aliases: [],
563
576
  summary: `Run the ${options.name} MCP server over stdio`,
564
577
  fields: [],
@@ -579,19 +592,67 @@ function commandTools(options) {
579
592
  function builtInMcp(options) {
580
593
  return options.mcp !== void 0 && options.mcp !== false && !(options.commands ?? []).some((command) => commandName(command) === "mcp");
581
594
  }
582
- function commandWords(options) {
583
- return [...commandTools(options).flatMap((tool) => [commandName(tool), ...tool.cli?.aliases ?? []]), ...builtInMcp(options) ? ["mcp"] : []];
595
+ function leadWords(options) {
596
+ return [
597
+ ...commandTools(options).flatMap((tool) => {
598
+ const [lead = "", word] = commandName(tool).split(" ");
599
+ return word === void 0 ? [lead, ...tool.cli?.aliases ?? []] : [lead];
600
+ }),
601
+ ...Object.values(options.groups ?? {}).flatMap((group) => group.aliases ?? []),
602
+ ...builtInMcp(options) ? ["mcp"] : []
603
+ ];
604
+ }
605
+ function findEntry(entries, word) {
606
+ return entries.find((entry) => entry.word === word || entry.aliases.includes(word));
607
+ }
608
+ function findCommand(entries, words) {
609
+ const [first, ...rest] = words;
610
+ const entry = first === void 0 ? void 0 : findEntry(entries, first);
611
+ if (entry !== void 0 && "scope" in entry) return findCommand(entry.scope.entries, rest);
612
+ return rest.length === 0 ? entry : void 0;
613
+ }
614
+ function assertUnique(prefix, entries) {
615
+ const words = entries.flatMap((entry) => [entry.word, ...entry.aliases]);
616
+ const repeated = words.find((word, index) => words.indexOf(word) !== index);
617
+ if (repeated !== void 0) throw new ToolDefinitionError(`Two commands are named ${prefix}${repeated}`);
618
+ }
619
+ function commandGroup(options, word, commands) {
620
+ const hints = options.groups?.[word] ?? {};
621
+ assertUnique(`${word} `, commands);
622
+ return {
623
+ word,
624
+ aliases: (hints.aliases ?? []).map((alias) => commandWord(`${options.name} ${word}`, alias)),
625
+ summary: hints.description ?? commands.map((command) => command.word).join(", "),
626
+ scope: {
627
+ words: [word],
628
+ title: `${hints.description ?? `Commands of ${word}`} (${options.name} ${word} v${options.version})`,
629
+ entries: commands
630
+ }
631
+ };
632
+ }
633
+ function rootEntries(options, commands) {
634
+ const entries = [...Map.groupBy(commands, (command) => command.name.split(" ", 1)[0] ?? "")].flatMap(([lead, members]) => {
635
+ const grouped = members.filter((command) => command.name !== command.word);
636
+ const single = members.filter((command) => command.name === command.word);
637
+ return grouped.length === 0 ? single : [...single, commandGroup(options, lead, grouped)];
638
+ });
639
+ const unknown = Object.keys(options.groups ?? {}).find((word) => !entries.some((entry) => "scope" in entry && entry.word === word));
640
+ if (unknown !== void 0) throw new ToolDefinitionError(`${options.name}: no group ${unknown}`);
641
+ assertUnique("", entries);
642
+ return entries;
584
643
  }
585
644
  function createCli(options) {
586
645
  indexTools(options.tools);
587
646
  indexTools(options.commands ?? []);
588
647
  const commands = [...commandTools(options).map((tool) => toolCommand(tool)), ...builtInMcp(options) ? [mcpCommand(options)] : []];
589
- const words = commandWords(options);
590
- const repeated = words.find((word, index) => words.indexOf(word) !== index);
591
- if (repeated !== void 0) throw new ToolDefinitionError(`Two commands are named ${repeated}`);
592
- const missing = [options.default, options.fallback].find((name) => name !== void 0 && !words.includes(name));
648
+ const root = {
649
+ words: [],
650
+ title: `${options.description} (${options.name} v${options.version})`,
651
+ entries: rootEntries(options, commands)
652
+ };
653
+ const missing = [options.default, options.fallback].find((name) => name !== void 0 && findCommand(root.entries, name.split(" ")) === void 0);
593
654
  if (missing !== void 0) throw new ToolDefinitionError(`${options.name}: no command ${missing}`);
594
- return { run: (argv) => dispatch(options, commands, normalizeArgv(options, argv)) };
655
+ return { run: (argv) => dispatch(options, root, normalizeArgv(options, argv)) };
595
656
  }
596
657
  const ROOT_FLAGS = /* @__PURE__ */ new Set([
597
658
  "--help",
@@ -601,22 +662,30 @@ const ROOT_FLAGS = /* @__PURE__ */ new Set([
601
662
  ]);
602
663
  function normalizeArgv(options, argv) {
603
664
  const [first] = argv;
604
- if (first === void 0) return options.default === void 0 ? [] : [options.default];
605
- if (options.fallback === void 0 || ROOT_FLAGS.has(first) || commandWords(options).includes(first)) return [...argv];
606
- return [options.fallback, ...argv];
665
+ if (first === void 0) return options.default?.split(" ") ?? [];
666
+ if (options.fallback === void 0 || ROOT_FLAGS.has(first) || leadWords(options).includes(first)) return [...argv];
667
+ return [...options.fallback.split(" "), ...argv];
607
668
  }
608
- async function dispatch(options, commands, argv) {
609
- const [first, ...rest] = argv;
669
+ async function dispatch(options, root, argv) {
670
+ const [first] = argv;
610
671
  if (argv.length === 1 && (first === "--version" || first === "-v")) writeLine("stdout", sanitizeLine(options.version));
611
- else if (first === "--help" || first === "-h") writeLine("stdout", sanitizeText(mainUsage(options, commands)));
612
- else if (first === void 0) {
613
- writeLine("stderr", sanitizeText(mainUsage(options, commands)));
672
+ else await dispatchIn(options, root, argv);
673
+ }
674
+ async function dispatchIn(options, scope, argv) {
675
+ const [first, ...rest] = argv;
676
+ if (first === void 0) {
677
+ writeLine("stderr", sanitizeText(scopeUsage(options, scope)));
614
678
  fail(["No command specified"]);
615
- } else {
616
- const command = commands.find((each) => each.name === first || each.aliases.includes(first));
617
- if (command === void 0) fail([`Unknown command ${JSON.stringify(first)}`, `Run ${options.name} --help for the commands`]);
618
- else await runCommand(options, command, rest);
679
+ return;
619
680
  }
681
+ if (first === "--help" || first === "-h") {
682
+ writeLine("stdout", sanitizeText(scopeUsage(options, scope)));
683
+ return;
684
+ }
685
+ const entry = findEntry(scope.entries, first);
686
+ if (entry === void 0) fail([`Unknown command ${JSON.stringify([...scope.words, first].join(" "))}`, `Run ${scopePath(options, scope)} --help for the commands`]);
687
+ else if ("scope" in entry) await dispatchIn(options, entry.scope, rest);
688
+ else await runCommand(options, entry, rest);
620
689
  }
621
690
  async function runCommand(options, command, rawArgs) {
622
691
  const words = parseWords(rawArgs, command.fields, command.json);
@@ -628,24 +697,28 @@ async function runCommand(options, command, rawArgs) {
628
697
  if (words.errors.length > 0) throw new ToolInputError(words.errors);
629
698
  await command.run(words);
630
699
  } catch (error) {
631
- handleError(options, error);
700
+ await handleError(options, error);
632
701
  }
633
702
  }
634
703
  function table(rows) {
635
704
  const width = Math.max(0, ...rows.map(([left]) => left.length));
636
705
  return rows.map(([left, right]) => ` ${left.padEnd(width)} ${right}`.trimEnd());
637
706
  }
638
- function mainUsage(options, commands) {
707
+ function scopePath(options, scope) {
708
+ return [options.name, ...scope.words].join(" ");
709
+ }
710
+ function scopeUsage(options, scope) {
711
+ const path = scopePath(options, scope);
639
712
  return [
640
- `${options.description} (${options.name} v${options.version})`,
713
+ scope.title,
641
714
  "",
642
- `USAGE ${options.name} <command> [OPTIONS]`,
715
+ `USAGE ${path} <command> [OPTIONS]`,
643
716
  "",
644
717
  "COMMANDS",
645
718
  "",
646
- ...table(commands.map((command) => [[command.name, ...command.aliases].join(", "), command.summary])),
719
+ ...table(scope.entries.map((entry) => [[entry.word, ...entry.aliases].join(", "), entry.summary])),
647
720
  "",
648
- `Use ${options.name} <command> --help for more information about a command.`
721
+ `Use ${path} <command> --help for more information about a command.`
649
722
  ].join("\n");
650
723
  }
651
724
  function commandUsage(options, command) {
package/dist/h3.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ToolDefinition as ToolDefinition$1 } from "./_chunks/index.mjs";
2
+ import { McpHost } from "./_chunks/mcp-answers.mjs";
2
3
  import { JsonSchema, ToolDefinition } from "h3-mcp";
3
4
  /** An h3-mcp tool whose `inputSchema` is the plain JSON Schema `tools/list` sends. */
4
5
  export type H3Tool = ToolDefinition<JsonSchema>;
@@ -12,6 +13,8 @@ export type H3Tool = ToolDefinition<JsonSchema>;
12
13
  * instead. An unknown name never reaches a handler: h3-mcp answers it itself
13
14
  * with a JSON-RPC error.
14
15
  *
16
+ * `host` is an {@link McpHost} with the event's request and the call's raw `_meta`.
17
+ *
15
18
  * `ask` reaches a client with `elicitation` on the 2026 revision only: h3-mcp has no 2025 shim.
16
19
  *
17
20
  * Imports only types from h3-mcp, so the adapter loads neither h3-mcp nor the MCP SDK.
@@ -23,4 +26,5 @@ export type H3Tool = ToolDefinition<JsonSchema>;
23
26
  */
24
27
  export declare function toH3Tools(info: {
25
28
  readonly name: string;
26
- }, tools: readonly ToolDefinition$1[]): H3Tool[];
29
+ }, tools: readonly ToolDefinition$1[]): H3Tool[];
30
+ export type { McpHost };
package/dist/h3.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./_chunks/src.mjs";
2
- import { callAsking, canAsk, listTools, progressSteps, questionRound } from "./_chunks/mcp-answers.mjs";
2
+ import { callAsking, canAsk, listTools, mcpHost, progressSteps, questionRound } from "./_chunks/mcp-answers.mjs";
3
3
  function toH3Tools(info, tools) {
4
4
  return listTools(tools).map((entry) => ({
5
5
  name: entry.name,
@@ -16,6 +16,10 @@ function toH3Tools(info, tools) {
16
16
  const progress = mcp?.progressToken === void 0 ? void 0 : mcp.progress;
17
17
  const context = {
18
18
  signal: mcp?.signal,
19
+ ...mcpHost({
20
+ request: event.req,
21
+ meta: mcp?.meta
22
+ }),
19
23
  ...progress === void 0 ? {} : { progress: numbered(progress) }
20
24
  };
21
25
  return await callAsking(info, tools, entry.name, args, context, round);
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { AddImmutable, AddImmutableDeferred, AddOptional, AddOptionalDeferred, AddReadonly, AddReadonlyDeferred, Any, ArrayOptions, BigInt, BigIntPattern, Boolean, Broaden, Call, CallConstruct, CanComposite, Capitalize, CapitalizeAction, CapitalizeDeferred, CapitalizeInstantiate, Codec, CollapseToObject, Compare, CompareResultDisjoint, CompareResultEqual, CompareResultLeftInside, CompareResultRightInside, Composite, Conditional, ConditionalAction, ConditionalDeferred, ConditionalInstantiate, Constructor, ConstructorOptions, ConstructorParameters, ConstructorParametersAction, ConstructorParametersDeferred, ConstructorParametersInstantiate, ConvertToIntegerKey, Cyclic, CyclicCandidates, CyclicCheck, CyclicDependencies, CyclicExtends, CyclicOptions, CyclicTarget, Decode, DecodeBuilder, Deferred, Dependent, DependentOptions, Distribute, Encode, EncodeBuilder, Enum, Evaluate, EvaluateAction, EvaluateDeferred, EvaluateDependent, EvaluateEnum, EvaluateInstantiate, EvaluateIntersect, EvaluateTemplateLiteral, EvaluateType, EvaluateUnion, EvaluateUnionFast, Exclude, ExcludeAction, ExcludeDeferred, ExcludeInstantiate, Extends, Extract, ExtractAction, ExtractDeferred, ExtractInstantiate, Flatten, FunctionOptions, Generic, Identifier, Immutable, Index, IndexAction, IndexDeferred, IndexInstantiate, Infer, InstanceType, InstanceTypeAction, InstanceTypeDeferred, InstanceTypeInstantiate, Instantiate, InstantiateCyclic, Integer, IntegerKey, IntegerPattern, Interface, InterfaceAction, InterfaceDeferred, InterfaceInstantiate, Intersect, IntersectOptions, InvalidLiteralValue, IsAny, IsArray, IsBigInt, IsBoolean, IsCall, IsCodec, IsConstructor, IsCyclic, IsDeferred, IsDependent, IsEnum, IsEnumValue, IsFunction, IsGeneric, IsIdentifier, IsImmutable, IsInfer, IsInteger, IsInterfaceDeferred, IsIntersect, IsKind, IsLiteral, IsLiteralBigInt, IsLiteralBoolean, IsLiteralNumber, IsLiteralString, IsLiteralValue, IsNever, IsNull, IsNumber, IsObject, IsOptional, IsParameter, IsReadonly, IsRecord, IsRef, IsRefine, IsRefinement, IsRest, IsSchema, IsString, IsSymbol, IsTemplateLiteral, IsTemplateLiteralDeferred, IsTemplateLiteralFinite, IsTemplateLiteralPattern, IsThis, IsTuple, IsTypeScriptEnumLike, IsUndefined, IsUnion, IsUnknown, IsUnsafe, IsVoid, KeyOf, KeyOfAction, KeyOfDeferred, KeyOfInstantiate, KeysToIndexer, Literal, LiteralTypeName, Lowercase, LowercaseAction, LowercaseDeferred, LowercaseInstantiate, Mapped, MappedAction, MappedDeferred, MappedInstantiate, Module, ModuleDeferred, ModuleInstantiate, Narrow, Never, NeverPattern, NonNullable, NonNullableAction, NonNullableDeferred, NonNullableInstantiate, Null, Number, NumberKey, NumberPattern, ObjectOptions, Omit, OmitAction, OmitDeferred, OmitInstantiate, Optional, Parameter, Parameters, ParametersAction, ParametersDeferred, ParametersInstantiate, ParsePatternIntoTypes, ParseTemplateIntoTypes, Partial, PartialAction, PartialDeferred, PartialInstantiate, Pick, PickAction, PickDeferred, PickInstantiate, Priority, PropertyKeys, PropertyValues, Readonly, ReadonlyObject, ReadonlyObjectAction, ReadonlyObjectDeferred, ReadonlyObjectInstantiate, ReadonlyType, Record, RecordAction, RecordDeferred, RecordFromPattern, RecordInstantiate, RecordKey, RecordOptions, RecordPattern, RecordPatternToType, RecordValue, Ref, RefInstantiate, Refine, RefineAdd, RemoveImmutable, RemoveImmutableDeferred, RemoveOptional, RemoveOptionalDeferred, RemoveReadonly, RemoveReadonlyDeferred, Required, RequiredAction, RequiredArray, RequiredDeferred, RequiredInstantiate, Rest, ReturnType, ReturnTypeAction, ReturnTypeDeferred, ReturnTypeInstantiate, Script, Static, StaticAny, StaticArray, StaticBigInt, StaticBoolean, StaticCodec, StaticConstructor, StaticCyclic, StaticDecode, StaticDependent, StaticDirection, StaticEncode, StaticEnum, StaticEvaluate, StaticFunction, StaticInstantiatedParameters, StaticInteger, StaticIntersect, StaticLiteral, StaticNever, StaticNull, StaticNumber, StaticObject, StaticParse, StaticProperties, StaticRecord, StaticRef, StaticString, StaticSymbol, StaticTemplateLiteral, StaticThis, StaticTuple, StaticType, StaticUndefined, StaticUnion, StaticUnknown, StaticUnsafe, StaticVoid, String, StringKey, StringPattern, Symbol, TAddImmutable, TAddImmutableDeferred, TAddOptional, TAddOptionalDeferred, TAddReadonly, TAddReadonlyDeferred, TAny, TArray, TArrayOptions, TBigInt, TBoolean, TBroaden, TCall, TCallConstruct, TCanComposite, TCapitalize, TCapitalizeAction, TCapitalizeDeferred, TCapitalizeInstantiate, TCodec, TCollapseToObject, TCompare, TCompareResult, TComposite, TConditional, TConditionalAction, TConditionalDeferred, TConditionalInstantiate, TConstructor, TConstructorParameters, TConstructorParametersAction, TConstructorParametersDeferred, TConstructorParametersInstantiate, TConvertToIntegerKey, TCyclic, TCyclicCandidates, TCyclicCheck, TCyclicDependencies, TCyclicExtends, TCyclicTarget, TDecodeCallback, TDeferred, TDependent, TDistribute, TEncodeCallback, TEnum, TEnumValue, TEvaluate, TEvaluateAction, TEvaluateDeferred, TEvaluateDependent, TEvaluateEnum, TEvaluateInstantiate, TEvaluateIntersect, TEvaluateTemplateLiteral, TEvaluateType, TEvaluateUnion, TEvaluateUnionFast, TExclude, TExcludeAction, TExcludeDeferred, TExcludeInstantiate, TExtends, TExtract, TExtractAction, TExtractDeferred, TExtractInstantiate, TFlatten, TFormat, TFunction, TGeneric, TIdentifier, TImmutable, TIndex, TIndexAction, TIndexDeferred, TIndexInstantiate, TInfer, TInstanceType, TInstanceTypeAction, TInstanceTypeDeferred, TInstanceTypeInstantiate, TInstantiate, TInstantiateCyclic, TInteger, TIntegerKey, TInterface, TInterfaceAction, TInterfaceDeferred, TInterfaceInstantiate, TIntersect, TIntersectOptions, TIsTemplateLiteralFinite, TIsTemplateLiteralPattern, TKeyOf, TKeyOfAction, TKeyOfDeferred, TKeyOfInstantiate, TKeysToIndexer, TLiteral, TLiteralTypeName, TLiteralValue, TLowercase, TLowercaseAction, TLowercaseDeferred, TLowercaseInstantiate, TMapped, TMappedAction, TMappedDeferred, TMappedInstantiate, TModule, TModuleDeferred, TModuleInstantiate, TNarrow, TNever, TNonNullable, TNonNullableAction, TNonNullableDeferred, TNonNullableInstantiate, TNull, TNumber, TNumberKey, TNumberOptions, TObject, TObjectOptions, TOmit, TOmitAction, TOmitDeferred, TOmitInstantiate, TOptional, TParameter, TParameters, TParametersAction, TParametersDeferred, TParametersInstantiate, TParsePatternIntoTypes, TParseTemplateIntoTypes, TPartial, TPartialAction, TPartialDeferred, TPartialInstantiate, TPick, TPickAction, TPickDeferred, TPickInstantiate, TPriority, TProperties, TPropertyKeys, TPropertyValues, TReadonly, TReadonlyObject, TReadonlyObjectAction, TReadonlyObjectDeferred, TReadonlyObjectInstantiate, TRecord, TRecordAction, TRecordDeferred, TRecordInstantiate, TRecordKey, TRecordPattern, TRecordPatternToType, TRecordValue, TRef, TRefInstantiate, TRefine, TRefineAdd, TRefineCheckCallback, TRefineErrorCallback, TRefinement, TRemoveImmutable, TRemoveImmutableDeferred, TRemoveOptional, TRemoveOptionalDeferred, TRemoveReadonly, TRemoveReadonlyDeferred, TRequired, TRequiredAction, TRequiredArray, TRequiredDeferred, TRequiredInstantiate, TRest, TReturnType, TReturnTypeAction, TReturnTypeDeferred, TReturnTypeInstantiate, TSchema, TSchemaOptions, TScript, TScriptOptions, TStaticElements, TString, TStringKey, TStringOptions, TSymbol, TTemplateLiteral, TTemplateLiteralDecode, TTemplateLiteralDecodeUnsafe, TTemplateLiteralDeferred, TTemplateLiteralEncode, TTemplateLiteralFromString, TTemplateLiteralFromTypes, TTemplateLiteralStatic, TThis, TTuple, TTupleOptions, TTupleToIntersect, TTupleToUnion, TTypeScriptEnumLike, TTypeScriptEnumToEnumValues, TUncapitalize, TUncapitalizeAction, TUncapitalizeDeferred, TUncapitalizeInstantiate, TUndefined, TUnion, TUnionLast, TUnionToIntersect, TUnionToTuple, TUnknown, TUnsafe, TUppercase, TUppercaseAction, TUppercaseDeferred, TUppercaseInstantiate, TVoid, TWith, TWithAction, TWithDeferred, TWithInstantiate, TemplateLiteral, TemplateLiteralCreate, TemplateLiteralDecode, TemplateLiteralDecodeUnsafe, TemplateLiteralDeferred, TemplateLiteralEncode, TemplateLiteralFromString, TemplateLiteralFromTypes, This, Tuple, TupleOptions, TypeScriptEnumToEnumValues, Uncapitalize, UncapitalizeAction, UncapitalizeDeferred, UncapitalizeInstantiate, Undefined, Union, UnionOptions, Unknown, Unsafe, Uppercase, UppercaseAction, UppercaseDeferred, UppercaseInstantiate, Void, With, WithAction, WithDeferred, WithInstantiate, _Array_, _Function_, _Object_, index_d_exports, result_d_exports } from "./_chunks/libs/typebox.mjs";
1
+ import { AddImmutable, AddImmutableDeferred, AddOptional, AddOptionalDeferred, AddReadonly, AddReadonlyDeferred, Any, ArrayOptions, BigInt, BigIntPattern, Boolean, Broaden, Call, CallConstruct, Capitalize, CapitalizeAction, CapitalizeDeferred, CapitalizeInstantiate, Codec, CollapseToObject, Compare, CompareResultDisjoint, CompareResultEqual, CompareResultLeftInside, CompareResultRightInside, Composite, Conditional, ConditionalAction, ConditionalDeferred, ConditionalInstantiate, Constructor, ConstructorOptions, ConstructorParameters, ConstructorParametersAction, ConstructorParametersDeferred, ConstructorParametersInstantiate, ConvertToIntegerKey, Cyclic, CyclicCandidates, CyclicCheck, CyclicDependencies, CyclicExtends, CyclicOptions, CyclicTarget, Decode, DecodeBuilder, Deferred, Dependent, DependentOptions, Distribute, Encode, EncodeBuilder, Enum, Evaluate, EvaluateAction, EvaluateDeferred, EvaluateDependent, EvaluateEnum, EvaluateInstantiate, EvaluateIntersect, EvaluatePropertyIntersect, EvaluatePropertyUnion, EvaluateTemplateLiteral, EvaluateType, EvaluateUnion, EvaluateUnionFast, Exclude, ExcludeAction, ExcludeDeferred, ExcludeInstantiate, Extends, Extract, ExtractAction, ExtractDeferred, ExtractInstantiate, Flatten, FunctionOptions, Generic, Identifier, Immutable, Index, IndexAction, IndexDeferred, IndexInstantiate, Infer, InstanceType, InstanceTypeAction, InstanceTypeDeferred, InstanceTypeInstantiate, Instantiate, InstantiateCyclic, Integer, IntegerKey, IntegerPattern, Interface, InterfaceAction, InterfaceDeferred, InterfaceInstantiate, Intersect, IntersectOptions, InvalidLiteralValue, IsAny, IsArray, IsBigInt, IsBoolean, IsCall, IsCodec, IsConstructor, IsCyclic, IsDeferred, IsDependent, IsEnum, IsEnumValue, IsFunction, IsGeneric, IsIdentifier, IsImmutable, IsInfer, IsInteger, IsInterfaceDeferred, IsIntersect, IsKind, IsLiteral, IsLiteralBigInt, IsLiteralBoolean, IsLiteralNumber, IsLiteralString, IsLiteralValue, IsNever, IsNull, IsNumber, IsObject, IsOptional, IsParameter, IsReadonly, IsRecord, IsRef, IsRefine, IsRefinement, IsRest, IsSchema, IsString, IsSymbol, IsTemplateLiteral, IsTemplateLiteralDeferred, IsTemplateLiteralFinite, IsTemplateLiteralPattern, IsThis, IsTuple, IsTypeScriptEnumLike, IsUndefined, IsUnion, IsUnknown, IsUnsafe, IsVoid, KeyOf, KeyOfAction, KeyOfDeferred, KeyOfInstantiate, KeysToIndexer, Literal, LiteralTypeName, Lowercase, LowercaseAction, LowercaseDeferred, LowercaseInstantiate, Mapped, MappedAction, MappedDeferred, MappedInstantiate, Module, ModuleDeferred, ModuleInstantiate, Narrow, Never, NeverPattern, NonNullable, NonNullableAction, NonNullableDeferred, NonNullableInstantiate, Null, Number, NumberKey, NumberPattern, ObjectOptions, Omit, OmitAction, OmitDeferred, OmitInstantiate, Optional, Parameter, Parameters, ParametersAction, ParametersDeferred, ParametersInstantiate, ParsePatternIntoTypes, ParseTemplateIntoTypes, Partial, PartialAction, PartialDeferred, PartialInstantiate, Pick, PickAction, PickDeferred, PickInstantiate, Priority, PropertyKeys, PropertyValues, Readonly, ReadonlyObject, ReadonlyObjectAction, ReadonlyObjectDeferred, ReadonlyObjectInstantiate, ReadonlyType, Record, RecordAction, RecordDeferred, RecordFromPattern, RecordInstantiate, RecordKey, RecordOptions, RecordPattern, RecordPatternToType, RecordValue, Ref, RefInstantiate, Refine, RefineAdd, RemoveImmutable, RemoveImmutableDeferred, RemoveOptional, RemoveOptionalDeferred, RemoveReadonly, RemoveReadonlyDeferred, Required, RequiredAction, RequiredArray, RequiredDeferred, RequiredInstantiate, Rest, ReturnType, ReturnTypeAction, ReturnTypeDeferred, ReturnTypeInstantiate, Script, Static, StaticAny, StaticArray, StaticBigInt, StaticBoolean, StaticCodec, StaticConstructor, StaticCyclic, StaticDecode, StaticDependent, StaticDirection, StaticEncode, StaticEnum, StaticEvaluate, StaticFunction, StaticInstantiatedParameters, StaticInteger, StaticIntersect, StaticLiteral, StaticNever, StaticNull, StaticNumber, StaticObject, StaticParse, StaticProperties, StaticRecord, StaticRef, StaticString, StaticSymbol, StaticTemplateLiteral, StaticThis, StaticTuple, StaticType, StaticUndefined, StaticUnion, StaticUnknown, StaticUnsafe, StaticVoid, String, StringKey, StringPattern, Symbol, TAddImmutable, TAddImmutableDeferred, TAddOptional, TAddOptionalDeferred, TAddReadonly, TAddReadonlyDeferred, TAny, TArray, TArrayOptions, TBigInt, TBoolean, TBroaden, TCall, TCallConstruct, TCapitalize, TCapitalizeAction, TCapitalizeDeferred, TCapitalizeInstantiate, TCodec, TCollapseToObject, TCompare, TCompareResult, TComposite, TConditional, TConditionalAction, TConditionalDeferred, TConditionalInstantiate, TConstructor, TConstructorParameters, TConstructorParametersAction, TConstructorParametersDeferred, TConstructorParametersInstantiate, TConvertToIntegerKey, TCyclic, TCyclicCandidates, TCyclicCheck, TCyclicDependencies, TCyclicExtends, TCyclicTarget, TDecodeCallback, TDeferred, TDependent, TDistribute, TEncodeCallback, TEnum, TEnumValue, TEvaluate, TEvaluateAction, TEvaluateDeferred, TEvaluateDependent, TEvaluateEnum, TEvaluateInstantiate, TEvaluateIntersect, TEvaluatePropertyIntersect, TEvaluatePropertyUnion, TEvaluateTemplateLiteral, TEvaluateType, TEvaluateUnion, TEvaluateUnionFast, TExclude, TExcludeAction, TExcludeDeferred, TExcludeInstantiate, TExtends, TExtract, TExtractAction, TExtractDeferred, TExtractInstantiate, TFlatten, TFormat, TFunction, TGeneric, TIdentifier, TImmutable, TIndex, TIndexAction, TIndexDeferred, TIndexInstantiate, TInfer, TInstanceType, TInstanceTypeAction, TInstanceTypeDeferred, TInstanceTypeInstantiate, TInstantiate, TInstantiateCyclic, TInteger, TIntegerKey, TInterface, TInterfaceAction, TInterfaceDeferred, TInterfaceInstantiate, TIntersect, TIntersectOptions, TIsTemplateLiteralFinite, TIsTemplateLiteralPattern, TKeyOf, TKeyOfAction, TKeyOfDeferred, TKeyOfInstantiate, TKeysToIndexer, TLiteral, TLiteralTypeName, TLiteralValue, TLowercase, TLowercaseAction, TLowercaseDeferred, TLowercaseInstantiate, TMapped, TMappedAction, TMappedDeferred, TMappedInstantiate, TModule, TModuleDeferred, TModuleInstantiate, TNarrow, TNever, TNonNullable, TNonNullableAction, TNonNullableDeferred, TNonNullableInstantiate, TNull, TNumber, TNumberKey, TNumberOptions, TObject, TObjectOptions, TOmit, TOmitAction, TOmitDeferred, TOmitInstantiate, TOptional, TParameter, TParameters, TParametersAction, TParametersDeferred, TParametersInstantiate, TParsePatternIntoTypes, TParseTemplateIntoTypes, TPartial, TPartialAction, TPartialDeferred, TPartialInstantiate, TPick, TPickAction, TPickDeferred, TPickInstantiate, TPriority, TProperties, TPropertyKeys, TPropertyValues, TReadonly, TReadonlyObject, TReadonlyObjectAction, TReadonlyObjectDeferred, TReadonlyObjectInstantiate, TRecord, TRecordAction, TRecordDeferred, TRecordInstantiate, TRecordKey, TRecordPattern, TRecordPatternToType, TRecordValue, TRef, TRefInstantiate, TRefine, TRefineAdd, TRefineCheckCallback, TRefineErrorCallback, TRefinement, TRemoveImmutable, TRemoveImmutableDeferred, TRemoveOptional, TRemoveOptionalDeferred, TRemoveReadonly, TRemoveReadonlyDeferred, TRequired, TRequiredAction, TRequiredArray, TRequiredDeferred, TRequiredInstantiate, TRest, TReturnType, TReturnTypeAction, TReturnTypeDeferred, TReturnTypeInstantiate, TSchema, TSchemaOptions, TScript, TScriptOptions, TStaticElements, TString, TStringKey, TStringOptions, TSymbol, TTemplateLiteral, TTemplateLiteralDecode, TTemplateLiteralDecodeUnsafe, TTemplateLiteralDeferred, TTemplateLiteralEncode, TTemplateLiteralFromString, TTemplateLiteralFromTypes, TTemplateLiteralStatic, TThis, TTuple, TTupleOptions, TTupleToIntersect, TTupleToUnion, TTypeScriptEnumLike, TTypeScriptEnumToEnumValues, TUncapitalize, TUncapitalizeAction, TUncapitalizeDeferred, TUncapitalizeInstantiate, TUndefined, TUnion, TUnionLast, TUnionToIntersect, TUnionToTuple, TUnknown, TUnsafe, TUppercase, TUppercaseAction, TUppercaseDeferred, TUppercaseInstantiate, TVoid, TWith, TWithAction, TWithDeferred, TWithInstantiate, TemplateLiteral, TemplateLiteralCreate, TemplateLiteralDecode, TemplateLiteralDecodeUnsafe, TemplateLiteralDeferred, TemplateLiteralEncode, TemplateLiteralFromString, TemplateLiteralFromTypes, This, Tuple, TupleOptions, TypeScriptEnumToEnumValues, Uncapitalize, UncapitalizeAction, UncapitalizeDeferred, UncapitalizeInstantiate, Undefined, Union, UnionOptions, Unknown, Unsafe, Uppercase, UppercaseAction, UppercaseDeferred, UppercaseInstantiate, Void, With, WithAction, WithDeferred, WithInstantiate, _Array_, _Function_, _Object_, index_d_exports, result_d_exports } from "./_chunks/libs/typebox.mjs";
2
2
  import { Icon, InputCheck, InputIssue, ToolAnswer, ToolAsk, ToolCallContext, ToolCliHints, ToolContent, ToolDefinition, ToolDefinitionError, ToolEffect, ToolInputError, ToolProgress, ToolQuestion, ToolResult, defineTool, indexTools, invokeTool, resultText, sanitizeLine, sanitizeText, validateInput, wireSchema } from "./_chunks/index.mjs";
3
- export { type AddImmutable, type AddImmutableDeferred, type AddOptional, type AddOptionalDeferred, type AddReadonly, type AddReadonlyDeferred, type Any, type _Array_ as Array, type _Array_, type ArrayOptions, type BigInt, type BigIntPattern, type Boolean, type Broaden, type Call, type CallConstruct, type CanComposite, type Capitalize, type CapitalizeAction, type CapitalizeDeferred, type CapitalizeInstantiate, type Codec, type CollapseToObject, type Compare, type CompareResultDisjoint, type CompareResultEqual, type CompareResultLeftInside, type CompareResultRightInside, type Composite, type Conditional, type ConditionalAction, type ConditionalDeferred, type ConditionalInstantiate, type Constructor, type ConstructorOptions, type ConstructorParameters, type ConstructorParametersAction, type ConstructorParametersDeferred, type ConstructorParametersInstantiate, type ConvertToIntegerKey, type Cyclic, type CyclicCandidates, type CyclicCheck, type CyclicDependencies, type CyclicExtends, type CyclicOptions, type CyclicTarget, type Decode, type DecodeBuilder, type Deferred, type Dependent, type DependentOptions, type Distribute, type Encode, type EncodeBuilder, type Enum, type Evaluate, type EvaluateAction, type EvaluateDeferred, type EvaluateDependent, type EvaluateEnum, type EvaluateInstantiate, type EvaluateIntersect, type EvaluateTemplateLiteral, type EvaluateType, type EvaluateUnion, type EvaluateUnionFast, type Exclude, type ExcludeAction, type ExcludeDeferred, type ExcludeInstantiate, type Extends, type result_d_exports as ExtendsResult, type Extract, type ExtractAction, type ExtractDeferred, type ExtractInstantiate, type Flatten, type _Function_ as Function, type _Function_, type FunctionOptions, type Generic, Icon, type Identifier, type Immutable, type Index, type IndexAction, type IndexDeferred, type IndexInstantiate, type Infer, InputCheck, InputIssue, type InstanceType, type InstanceTypeAction, type InstanceTypeDeferred, type InstanceTypeInstantiate, type Instantiate, type InstantiateCyclic, type Integer, type IntegerKey, type IntegerPattern, type Interface, type InterfaceAction, type InterfaceDeferred, type InterfaceInstantiate, type Intersect, type IntersectOptions, type InvalidLiteralValue, type IsAny, type IsArray, type IsBigInt, type IsBoolean, type IsCall, type IsCodec, type IsConstructor, type IsCyclic, type IsDeferred, type IsDependent, type IsEnum, type IsEnumValue, type IsFunction, type IsGeneric, type IsIdentifier, type IsImmutable, type IsInfer, type IsInteger, type IsInterfaceDeferred, type IsIntersect, type IsKind, type IsLiteral, type IsLiteralBigInt, type IsLiteralBoolean, type IsLiteralNumber, type IsLiteralString, type IsLiteralValue, type IsNever, type IsNull, type IsNumber, type IsObject, type IsOptional, type IsParameter, type IsReadonly, type IsRecord, type IsRef, type IsRefine, type IsRefinement, type IsRest, type IsSchema, type IsString, type IsSymbol, type IsTemplateLiteral, type IsTemplateLiteralDeferred, type IsTemplateLiteralFinite, type IsTemplateLiteralPattern, type IsThis, type IsTuple, type IsTypeScriptEnumLike, type IsUndefined, type IsUnion, type IsUnknown, type IsUnsafe, type IsVoid, type KeyOf, type KeyOfAction, type KeyOfDeferred, type KeyOfInstantiate, type KeysToIndexer, type Literal, type LiteralTypeName, type Lowercase, type LowercaseAction, type LowercaseDeferred, type LowercaseInstantiate, type Mapped, type MappedAction, type MappedDeferred, type MappedInstantiate, type Module, type ModuleDeferred, type ModuleInstantiate, type Narrow, type Never, type NeverPattern, type NonNullable, type NonNullableAction, type NonNullableDeferred, type NonNullableInstantiate, type Null, type Number, type NumberKey, type NumberPattern, type _Object_ as Object, type _Object_, type ObjectOptions, type Omit, type OmitAction, type OmitDeferred, type OmitInstantiate, type Optional, type Parameter, type Parameters, type ParametersAction, type ParametersDeferred, type ParametersInstantiate, type ParsePatternIntoTypes, type ParseTemplateIntoTypes, type Partial, type PartialAction, type PartialDeferred, type PartialInstantiate, type Pick, type PickAction, type PickDeferred, type PickInstantiate, type Priority, type PropertyKeys, type PropertyValues, type Readonly, type ReadonlyObject, type ReadonlyObjectAction, type ReadonlyObjectDeferred, type ReadonlyObjectInstantiate, type ReadonlyType, type Record, type RecordAction, type RecordDeferred, type RecordFromPattern, type RecordInstantiate, type RecordKey, type RecordOptions, type RecordPattern, type RecordPatternToType, type RecordValue, type Ref, type RefInstantiate, type Refine, type RefineAdd, type RemoveImmutable, type RemoveImmutableDeferred, type RemoveOptional, type RemoveOptionalDeferred, type RemoveReadonly, type RemoveReadonlyDeferred, type Required, type RequiredAction, type RequiredArray, type RequiredDeferred, type RequiredInstantiate, type Rest, type ReturnType, type ReturnTypeAction, type ReturnTypeDeferred, type ReturnTypeInstantiate, type Script, type Static, type StaticAny, type StaticArray, type StaticBigInt, type StaticBoolean, type StaticCodec, type StaticConstructor, type StaticCyclic, type StaticDecode, type StaticDependent, type StaticDirection, type StaticEncode, type StaticEnum, type StaticEvaluate, type StaticFunction, type StaticInstantiatedParameters, type StaticInteger, type StaticIntersect, type StaticLiteral, type StaticNever, type StaticNull, type StaticNumber, type StaticObject, type StaticParse, type StaticProperties, type StaticRecord, type StaticRef, type StaticString, type StaticSymbol, type StaticTemplateLiteral, type StaticThis, type StaticTuple, type StaticType, type StaticUndefined, type StaticUnion, type StaticUnknown, type StaticUnsafe, type StaticVoid, type String, type StringKey, type StringPattern, type Symbol, type TAddImmutable, type TAddImmutableDeferred, type TAddOptional, type TAddOptionalDeferred, type TAddReadonly, type TAddReadonlyDeferred, type TAny, type TArray, type TArrayOptions, type TBigInt, type TBoolean, type TBroaden, type TCall, type TCallConstruct, type TCanComposite, type TCapitalize, type TCapitalizeAction, type TCapitalizeDeferred, type TCapitalizeInstantiate, type TCodec, type TCollapseToObject, type TCompare, type TCompareResult, type TComposite, type TConditional, type TConditionalAction, type TConditionalDeferred, type TConditionalInstantiate, type TConstructor, type TConstructorParameters, type TConstructorParametersAction, type TConstructorParametersDeferred, type TConstructorParametersInstantiate, type TConvertToIntegerKey, type TCyclic, type TCyclicCandidates, type TCyclicCheck, type TCyclicDependencies, type TCyclicExtends, type TCyclicTarget, type TDecodeCallback, type TDeferred, type TDependent, type TDistribute, type TEncodeCallback, type TEnum, type TEnumValue, type TEvaluate, type TEvaluateAction, type TEvaluateDeferred, type TEvaluateDependent, type TEvaluateEnum, type TEvaluateInstantiate, type TEvaluateIntersect, type TEvaluateTemplateLiteral, type TEvaluateType, type TEvaluateUnion, type TEvaluateUnionFast, type TExclude, type TExcludeAction, type TExcludeDeferred, type TExcludeInstantiate, type TExtends, type TExtract, type TExtractAction, type TExtractDeferred, type TExtractInstantiate, type TFlatten, type TFormat, type TFunction, type TGeneric, type TIdentifier, type TImmutable, type TIndex, type TIndexAction, type TIndexDeferred, type TIndexInstantiate, type TInfer, type TInstanceType, type TInstanceTypeAction, type TInstanceTypeDeferred, type TInstanceTypeInstantiate, type TInstantiate, type TInstantiateCyclic, type TInteger, type TIntegerKey, type TInterface, type TInterfaceAction, type TInterfaceDeferred, type TInterfaceInstantiate, type TIntersect, type TIntersectOptions, type TIsTemplateLiteralFinite, type TIsTemplateLiteralPattern, type TKeyOf, type TKeyOfAction, type TKeyOfDeferred, type TKeyOfInstantiate, type TKeysToIndexer, type TLiteral, type TLiteralTypeName, type TLiteralValue, type TLowercase, type TLowercaseAction, type TLowercaseDeferred, type TLowercaseInstantiate, type TMapped, type TMappedAction, type TMappedDeferred, type TMappedInstantiate, type TModule, type TModuleDeferred, type TModuleInstantiate, type TNarrow, type TNever, type TNonNullable, type TNonNullableAction, type TNonNullableDeferred, type TNonNullableInstantiate, type TNull, type TNumber, type TNumberKey, type TNumberOptions, type TObject, type TObjectOptions, type TOmit, type TOmitAction, type TOmitDeferred, type TOmitInstantiate, type TOptional, type TParameter, type TParameters, type TParametersAction, type TParametersDeferred, type TParametersInstantiate, type TParsePatternIntoTypes, type TParseTemplateIntoTypes, type TPartial, type TPartialAction, type TPartialDeferred, type TPartialInstantiate, type TPick, type TPickAction, type TPickDeferred, type TPickInstantiate, type TPriority, type TProperties, type TPropertyKeys, type TPropertyValues, type TReadonly, type TReadonlyObject, type TReadonlyObjectAction, type TReadonlyObjectDeferred, type TReadonlyObjectInstantiate, type TRecord, type TRecordAction, type TRecordDeferred, type TRecordInstantiate, type TRecordKey, type TRecordPattern, type TRecordPatternToType, type TRecordValue, type TRef, type TRefInstantiate, type TRefine, type TRefineAdd, type TRefineCheckCallback, type TRefineErrorCallback, type TRefinement, type TRemoveImmutable, type TRemoveImmutableDeferred, type TRemoveOptional, type TRemoveOptionalDeferred, type TRemoveReadonly, type TRemoveReadonlyDeferred, type TRequired, type TRequiredAction, type TRequiredArray, type TRequiredDeferred, type TRequiredInstantiate, type TRest, type TReturnType, type TReturnTypeAction, type TReturnTypeDeferred, type TReturnTypeInstantiate, type TSchema, type TSchemaOptions, type TScript, type TScriptOptions, type TStaticElements, type TString, type TStringKey, type TStringOptions, type TSymbol, type TTemplateLiteral, type TTemplateLiteralDecode, type TTemplateLiteralDecodeUnsafe, type TTemplateLiteralDeferred, type TTemplateLiteralEncode, type TTemplateLiteralFromString, type TTemplateLiteralFromTypes, type TTemplateLiteralStatic, type TThis, type TTuple, type TTupleOptions, type TTupleToIntersect, type TTupleToUnion, type TTypeScriptEnumLike, type TTypeScriptEnumToEnumValues, type TUncapitalize, type TUncapitalizeAction, type TUncapitalizeDeferred, type TUncapitalizeInstantiate, type TUndefined, type TUnion, type TUnionLast, type TUnionToIntersect, type TUnionToTuple, type TUnknown, type TUnsafe, type TUppercase, type TUppercaseAction, type TUppercaseDeferred, type TUppercaseInstantiate, type TVoid, type TWith, type TWithAction, type TWithDeferred, type TWithInstantiate, type TemplateLiteral, type TemplateLiteralCreate, type TemplateLiteralDecode, type TemplateLiteralDecodeUnsafe, type TemplateLiteralDeferred, type TemplateLiteralEncode, type TemplateLiteralFromString, type TemplateLiteralFromTypes, type This, ToolAnswer, ToolAsk, ToolCallContext, ToolCliHints, ToolContent, ToolDefinition, ToolDefinitionError, ToolEffect, ToolInputError, ToolProgress, ToolQuestion, ToolResult, type Tuple, type TupleOptions, index_d_exports as Type, type TypeScriptEnumToEnumValues, type Uncapitalize, type UncapitalizeAction, type UncapitalizeDeferred, type UncapitalizeInstantiate, type Undefined, type Union, type UnionOptions, type Unknown, type Unsafe, type Uppercase, type UppercaseAction, type UppercaseDeferred, type UppercaseInstantiate, type Void, type With, type WithAction, type WithDeferred, type WithInstantiate, defineTool, indexTools, invokeTool, resultText, sanitizeLine, sanitizeText, validateInput, wireSchema };
3
+ export { type AddImmutable, type AddImmutableDeferred, type AddOptional, type AddOptionalDeferred, type AddReadonly, type AddReadonlyDeferred, type Any, type _Array_ as Array, type _Array_, type ArrayOptions, type BigInt, type BigIntPattern, type Boolean, type Broaden, type Call, type CallConstruct, type Capitalize, type CapitalizeAction, type CapitalizeDeferred, type CapitalizeInstantiate, type Codec, type CollapseToObject, type Compare, type CompareResultDisjoint, type CompareResultEqual, type CompareResultLeftInside, type CompareResultRightInside, type Composite, type Conditional, type ConditionalAction, type ConditionalDeferred, type ConditionalInstantiate, type Constructor, type ConstructorOptions, type ConstructorParameters, type ConstructorParametersAction, type ConstructorParametersDeferred, type ConstructorParametersInstantiate, type ConvertToIntegerKey, type Cyclic, type CyclicCandidates, type CyclicCheck, type CyclicDependencies, type CyclicExtends, type CyclicOptions, type CyclicTarget, type Decode, type DecodeBuilder, type Deferred, type Dependent, type DependentOptions, type Distribute, type Encode, type EncodeBuilder, type Enum, type Evaluate, type EvaluateAction, type EvaluateDeferred, type EvaluateDependent, type EvaluateEnum, type EvaluateInstantiate, type EvaluateIntersect, type EvaluatePropertyIntersect, type EvaluatePropertyUnion, type EvaluateTemplateLiteral, type EvaluateType, type EvaluateUnion, type EvaluateUnionFast, type Exclude, type ExcludeAction, type ExcludeDeferred, type ExcludeInstantiate, type Extends, type result_d_exports as ExtendsResult, type Extract, type ExtractAction, type ExtractDeferred, type ExtractInstantiate, type Flatten, type _Function_ as Function, type _Function_, type FunctionOptions, type Generic, Icon, type Identifier, type Immutable, type Index, type IndexAction, type IndexDeferred, type IndexInstantiate, type Infer, InputCheck, InputIssue, type InstanceType, type InstanceTypeAction, type InstanceTypeDeferred, type InstanceTypeInstantiate, type Instantiate, type InstantiateCyclic, type Integer, type IntegerKey, type IntegerPattern, type Interface, type InterfaceAction, type InterfaceDeferred, type InterfaceInstantiate, type Intersect, type IntersectOptions, type InvalidLiteralValue, type IsAny, type IsArray, type IsBigInt, type IsBoolean, type IsCall, type IsCodec, type IsConstructor, type IsCyclic, type IsDeferred, type IsDependent, type IsEnum, type IsEnumValue, type IsFunction, type IsGeneric, type IsIdentifier, type IsImmutable, type IsInfer, type IsInteger, type IsInterfaceDeferred, type IsIntersect, type IsKind, type IsLiteral, type IsLiteralBigInt, type IsLiteralBoolean, type IsLiteralNumber, type IsLiteralString, type IsLiteralValue, type IsNever, type IsNull, type IsNumber, type IsObject, type IsOptional, type IsParameter, type IsReadonly, type IsRecord, type IsRef, type IsRefine, type IsRefinement, type IsRest, type IsSchema, type IsString, type IsSymbol, type IsTemplateLiteral, type IsTemplateLiteralDeferred, type IsTemplateLiteralFinite, type IsTemplateLiteralPattern, type IsThis, type IsTuple, type IsTypeScriptEnumLike, type IsUndefined, type IsUnion, type IsUnknown, type IsUnsafe, type IsVoid, type KeyOf, type KeyOfAction, type KeyOfDeferred, type KeyOfInstantiate, type KeysToIndexer, type Literal, type LiteralTypeName, type Lowercase, type LowercaseAction, type LowercaseDeferred, type LowercaseInstantiate, type Mapped, type MappedAction, type MappedDeferred, type MappedInstantiate, type Module, type ModuleDeferred, type ModuleInstantiate, type Narrow, type Never, type NeverPattern, type NonNullable, type NonNullableAction, type NonNullableDeferred, type NonNullableInstantiate, type Null, type Number, type NumberKey, type NumberPattern, type _Object_ as Object, type _Object_, type ObjectOptions, type Omit, type OmitAction, type OmitDeferred, type OmitInstantiate, type Optional, type Parameter, type Parameters, type ParametersAction, type ParametersDeferred, type ParametersInstantiate, type ParsePatternIntoTypes, type ParseTemplateIntoTypes, type Partial, type PartialAction, type PartialDeferred, type PartialInstantiate, type Pick, type PickAction, type PickDeferred, type PickInstantiate, type Priority, type PropertyKeys, type PropertyValues, type Readonly, type ReadonlyObject, type ReadonlyObjectAction, type ReadonlyObjectDeferred, type ReadonlyObjectInstantiate, type ReadonlyType, type Record, type RecordAction, type RecordDeferred, type RecordFromPattern, type RecordInstantiate, type RecordKey, type RecordOptions, type RecordPattern, type RecordPatternToType, type RecordValue, type Ref, type RefInstantiate, type Refine, type RefineAdd, type RemoveImmutable, type RemoveImmutableDeferred, type RemoveOptional, type RemoveOptionalDeferred, type RemoveReadonly, type RemoveReadonlyDeferred, type Required, type RequiredAction, type RequiredArray, type RequiredDeferred, type RequiredInstantiate, type Rest, type ReturnType, type ReturnTypeAction, type ReturnTypeDeferred, type ReturnTypeInstantiate, type Script, type Static, type StaticAny, type StaticArray, type StaticBigInt, type StaticBoolean, type StaticCodec, type StaticConstructor, type StaticCyclic, type StaticDecode, type StaticDependent, type StaticDirection, type StaticEncode, type StaticEnum, type StaticEvaluate, type StaticFunction, type StaticInstantiatedParameters, type StaticInteger, type StaticIntersect, type StaticLiteral, type StaticNever, type StaticNull, type StaticNumber, type StaticObject, type StaticParse, type StaticProperties, type StaticRecord, type StaticRef, type StaticString, type StaticSymbol, type StaticTemplateLiteral, type StaticThis, type StaticTuple, type StaticType, type StaticUndefined, type StaticUnion, type StaticUnknown, type StaticUnsafe, type StaticVoid, type String, type StringKey, type StringPattern, type Symbol, type TAddImmutable, type TAddImmutableDeferred, type TAddOptional, type TAddOptionalDeferred, type TAddReadonly, type TAddReadonlyDeferred, type TAny, type TArray, type TArrayOptions, type TBigInt, type TBoolean, type TBroaden, type TCall, type TCallConstruct, type TCapitalize, type TCapitalizeAction, type TCapitalizeDeferred, type TCapitalizeInstantiate, type TCodec, type TCollapseToObject, type TCompare, type TCompareResult, type TComposite, type TConditional, type TConditionalAction, type TConditionalDeferred, type TConditionalInstantiate, type TConstructor, type TConstructorParameters, type TConstructorParametersAction, type TConstructorParametersDeferred, type TConstructorParametersInstantiate, type TConvertToIntegerKey, type TCyclic, type TCyclicCandidates, type TCyclicCheck, type TCyclicDependencies, type TCyclicExtends, type TCyclicTarget, type TDecodeCallback, type TDeferred, type TDependent, type TDistribute, type TEncodeCallback, type TEnum, type TEnumValue, type TEvaluate, type TEvaluateAction, type TEvaluateDeferred, type TEvaluateDependent, type TEvaluateEnum, type TEvaluateInstantiate, type TEvaluateIntersect, type TEvaluatePropertyIntersect, type TEvaluatePropertyUnion, type TEvaluateTemplateLiteral, type TEvaluateType, type TEvaluateUnion, type TEvaluateUnionFast, type TExclude, type TExcludeAction, type TExcludeDeferred, type TExcludeInstantiate, type TExtends, type TExtract, type TExtractAction, type TExtractDeferred, type TExtractInstantiate, type TFlatten, type TFormat, type TFunction, type TGeneric, type TIdentifier, type TImmutable, type TIndex, type TIndexAction, type TIndexDeferred, type TIndexInstantiate, type TInfer, type TInstanceType, type TInstanceTypeAction, type TInstanceTypeDeferred, type TInstanceTypeInstantiate, type TInstantiate, type TInstantiateCyclic, type TInteger, type TIntegerKey, type TInterface, type TInterfaceAction, type TInterfaceDeferred, type TInterfaceInstantiate, type TIntersect, type TIntersectOptions, type TIsTemplateLiteralFinite, type TIsTemplateLiteralPattern, type TKeyOf, type TKeyOfAction, type TKeyOfDeferred, type TKeyOfInstantiate, type TKeysToIndexer, type TLiteral, type TLiteralTypeName, type TLiteralValue, type TLowercase, type TLowercaseAction, type TLowercaseDeferred, type TLowercaseInstantiate, type TMapped, type TMappedAction, type TMappedDeferred, type TMappedInstantiate, type TModule, type TModuleDeferred, type TModuleInstantiate, type TNarrow, type TNever, type TNonNullable, type TNonNullableAction, type TNonNullableDeferred, type TNonNullableInstantiate, type TNull, type TNumber, type TNumberKey, type TNumberOptions, type TObject, type TObjectOptions, type TOmit, type TOmitAction, type TOmitDeferred, type TOmitInstantiate, type TOptional, type TParameter, type TParameters, type TParametersAction, type TParametersDeferred, type TParametersInstantiate, type TParsePatternIntoTypes, type TParseTemplateIntoTypes, type TPartial, type TPartialAction, type TPartialDeferred, type TPartialInstantiate, type TPick, type TPickAction, type TPickDeferred, type TPickInstantiate, type TPriority, type TProperties, type TPropertyKeys, type TPropertyValues, type TReadonly, type TReadonlyObject, type TReadonlyObjectAction, type TReadonlyObjectDeferred, type TReadonlyObjectInstantiate, type TRecord, type TRecordAction, type TRecordDeferred, type TRecordInstantiate, type TRecordKey, type TRecordPattern, type TRecordPatternToType, type TRecordValue, type TRef, type TRefInstantiate, type TRefine, type TRefineAdd, type TRefineCheckCallback, type TRefineErrorCallback, type TRefinement, type TRemoveImmutable, type TRemoveImmutableDeferred, type TRemoveOptional, type TRemoveOptionalDeferred, type TRemoveReadonly, type TRemoveReadonlyDeferred, type TRequired, type TRequiredAction, type TRequiredArray, type TRequiredDeferred, type TRequiredInstantiate, type TRest, type TReturnType, type TReturnTypeAction, type TReturnTypeDeferred, type TReturnTypeInstantiate, type TSchema, type TSchemaOptions, type TScript, type TScriptOptions, type TStaticElements, type TString, type TStringKey, type TStringOptions, type TSymbol, type TTemplateLiteral, type TTemplateLiteralDecode, type TTemplateLiteralDecodeUnsafe, type TTemplateLiteralDeferred, type TTemplateLiteralEncode, type TTemplateLiteralFromString, type TTemplateLiteralFromTypes, type TTemplateLiteralStatic, type TThis, type TTuple, type TTupleOptions, type TTupleToIntersect, type TTupleToUnion, type TTypeScriptEnumLike, type TTypeScriptEnumToEnumValues, type TUncapitalize, type TUncapitalizeAction, type TUncapitalizeDeferred, type TUncapitalizeInstantiate, type TUndefined, type TUnion, type TUnionLast, type TUnionToIntersect, type TUnionToTuple, type TUnknown, type TUnsafe, type TUppercase, type TUppercaseAction, type TUppercaseDeferred, type TUppercaseInstantiate, type TVoid, type TWith, type TWithAction, type TWithDeferred, type TWithInstantiate, type TemplateLiteral, type TemplateLiteralCreate, type TemplateLiteralDecode, type TemplateLiteralDecodeUnsafe, type TemplateLiteralDeferred, type TemplateLiteralEncode, type TemplateLiteralFromString, type TemplateLiteralFromTypes, type This, ToolAnswer, ToolAsk, ToolCallContext, ToolCliHints, ToolContent, ToolDefinition, ToolDefinitionError, ToolEffect, ToolInputError, ToolProgress, ToolQuestion, ToolResult, type Tuple, type TupleOptions, index_d_exports as Type, type TypeScriptEnumToEnumValues, type Uncapitalize, type UncapitalizeAction, type UncapitalizeDeferred, type UncapitalizeInstantiate, type Undefined, type Union, type UnionOptions, type Unknown, type Unsafe, type Uppercase, type UppercaseAction, type UppercaseDeferred, type UppercaseInstantiate, type Void, type With, type WithAction, type WithDeferred, type WithInstantiate, defineTool, indexTools, invokeTool, resultText, sanitizeLine, sanitizeText, validateInput, wireSchema };
package/dist/mcp.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ToolDefinition } from "./_chunks/index.mjs";
2
- import { McpServerInfo, callTool, errorResult, listTools, toolAnnotations } from "./_chunks/mcp-answers.mjs";
2
+ import { McpHost, McpServerInfo, callTool, errorResult, listTools, toolAnnotations } from "./_chunks/mcp-answers.mjs";
3
3
  import { Server } from "@modelcontextprotocol/server";
4
4
  /**
5
5
  * Creates an unconnected MCP server exposing the tools.
@@ -20,10 +20,12 @@ import { Server } from "@modelcontextprotocol/server";
20
20
  * A client that declares `elicitation` gets `ask`, through `input_required` on both revisions.
21
21
  * A 2026 request carries its capabilities itself, a 2025 one declared them at `initialize`.
22
22
  *
23
+ * `host` is an {@link McpHost}: the HTTP request on an HTTP transport, the call's `_meta` on any.
24
+ *
23
25
  * @param info - Name, version and optional title, description, icons and website, sent as given.
24
26
  * @param tools - Tools to serve.
25
27
  * @returns {Server} Unconnected MCP server.
26
28
  * @throws {ToolDefinitionError} When two tools share a name.
27
29
  */
28
30
  export declare function createMcpServer(info: McpServerInfo, tools: readonly ToolDefinition[]): Server;
29
- export { type McpServerInfo, callTool, errorResult, listTools, toolAnnotations };
31
+ export { type McpHost, type McpServerInfo, callTool, errorResult, listTools, toolAnnotations };
package/dist/mcp.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { indexTools } from "./_chunks/src.mjs";
2
- import { callAsking, callTool, canAsk, copyIcons, errorResult, listTools, progressSteps, questionRound, toolAnnotations } from "./_chunks/mcp-answers.mjs";
2
+ import { callAsking, callTool, canAsk, copyIcons, errorResult, listTools, mcpHost, progressSteps, questionRound, toolAnnotations } from "./_chunks/mcp-answers.mjs";
3
3
  import { Server } from "@modelcontextprotocol/server";
4
4
  function createMcpServer(info, tools) {
5
5
  indexTools(tools);
@@ -14,7 +14,8 @@ function createMcpServer(info, tools) {
14
14
  }, { capabilities: { tools: {} } });
15
15
  server.setRequestHandler("tools/list", () => ({ tools: listTools(tools) }));
16
16
  server.setRequestHandler("tools/call", async (request, ctx) => {
17
- const progressToken = ctx.mcpReq._meta?.progressToken;
17
+ const meta = ctx.mcpReq._meta;
18
+ const progressToken = meta?.progressToken;
18
19
  const notify = (params) => {
19
20
  ctx.mcpReq.notify({
20
21
  method: "notifications/progress",
@@ -30,6 +31,10 @@ function createMcpServer(info, tools) {
30
31
  const round = canAsk(capabilities) ? questionRound(ctx.mcpReq.inputResponses, stateOf(ctx.mcpReq.requestState())) : void 0;
31
32
  const context = {
32
33
  signal: ctx.mcpReq.signal,
34
+ ...mcpHost({
35
+ request: ctx.http?.req,
36
+ meta
37
+ }),
33
38
  ...progressToken === void 0 ? {} : { progress: progressSteps(notify) }
34
39
  };
35
40
  const { name, arguments: args } = request.params;
package/dist/omp.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { indexTools, invokeTool, sanitizeLine, wireSchema } from "./_chunks/src.mjs";
2
+ import { throwWithCauses } from "./_chunks/causes.mjs";
2
3
  import { hostContext } from "./_chunks/updates.mjs";
3
4
  const APPROVAL = {
4
5
  read: "read",
@@ -21,7 +22,8 @@ function registerOmpTools(pi, tools, options) {
21
22
  loadMode: options.loadMode,
22
23
  strict: false,
23
24
  async execute(_toolCallId, params, signal, onUpdate, ctx) {
24
- return await invokeTool(tool, params, hostContext(signal, onUpdate, ctx));
25
+ const context = hostContext(signal, onUpdate, ctx);
26
+ return await invokeTool(tool, params, context).catch(throwWithCauses);
25
27
  },
26
28
  renderCall(args, renderOptions, theme) {
27
29
  if (renderers?.renderCall) return renderers.renderCall(args, renderOptions, theme);
package/dist/pi.d.mts CHANGED
@@ -21,6 +21,23 @@ export interface PiToolOptions {
21
21
  readonly confirm?: Readonly<Record<string, PiConfirm>>;
22
22
  /** Pi's argument repair by tool name, run before validation. A name off the list throws. */
23
23
  readonly prepareArguments?: Readonly<Record<string, PiPrepareArguments>>;
24
+ /** How the model reaches the tools, for all or by name. Left out, Pi's `direct`. */
25
+ readonly exposure?: PiToolExposure | PiExposures;
26
+ /** Group the tools share, as Pi groups the tools of one MCP server. */
27
+ readonly namespace?: PiToolNamespace;
28
+ }
29
+ /** Pi's `ToolExposure`, spelled out so older Pi types still compile. */
30
+ export type PiToolExposure = "direct" | "model-only" | "codemode" | "deferred" | "hidden";
31
+ /** Exposure by tool name, with a fallback for the rest. A name off the list throws. */
32
+ export interface PiExposures {
33
+ readonly default?: PiToolExposure;
34
+ readonly tools?: Readonly<Record<string, PiToolExposure>>;
35
+ }
36
+ /** Pi's `ToolNamespace`: what `describeNamespace()` and `tool_search` read. */
37
+ export interface PiToolNamespace {
38
+ readonly name: string;
39
+ readonly description?: string;
40
+ readonly instructions?: string;
24
41
  }
25
42
  /** Repairs raw model input before validation. Hand back what it doesn't recognise untouched. */
26
43
  export type PiPrepareArguments = (args: unknown) => unknown;
@@ -41,8 +58,9 @@ export interface PiRenderers extends Readonly<Pick<ToolDefinition, "renderCall"
41
58
  *
42
59
  * @param pi - Pi extension API.
43
60
  * @param tools - Tools to register.
44
- * @param options - Failure policy, host `Text`, renderers, questions and argument repairs.
61
+ * @param options - Failure policy, host `Text`, renderers, questions, repairs and exposure.
45
62
  * @throws {ToolDefinitionError} When two tools share a name, a tool has `describeCall` but no
46
- * `Text` came with it, or `confirm` or `prepareArguments` names a tool that isn't in the list.
63
+ * `Text` came with it, `confirm`, `prepareArguments` or `exposure` names a tool that isn't in
64
+ * the list, or an exposure isn't one Pi knows.
47
65
  */
48
66
  export declare function registerPiTools(pi: ExtensionAPI, tools: readonly ToolDefinition$1[], options?: PiToolOptions): void;