@agntn/tools 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/_chunks/index.d.mts +205 -0
- package/dist/_chunks/index.d.mts.map +1 -0
- package/dist/_chunks/libs/typebox.mjs +3 -234
- package/dist/_chunks/libs/typebox.mjs.map +1 -1
- package/dist/_chunks/mcp-answers.mjs +67 -0
- package/dist/_chunks/mcp-answers.mjs.map +1 -0
- package/dist/_chunks/src.mjs +21 -2
- package/dist/_chunks/src.mjs.map +1 -1
- package/dist/_chunks/updates.mjs +16 -0
- package/dist/_chunks/updates.mjs.map +1 -0
- package/dist/ai.d.mts +2 -1
- package/dist/ai.d.mts.map +1 -1
- package/dist/ai.mjs +2 -1
- package/dist/ai.mjs.map +1 -1
- package/dist/cli.d.mts +4 -3
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +184 -37
- package/dist/cli.mjs.map +1 -1
- package/dist/h3.d.mts +25 -0
- package/dist/h3.d.mts.map +1 -0
- package/dist/h3.mjs +23 -0
- package/dist/h3.mjs.map +1 -0
- package/dist/index.d.mts +3 -165
- package/dist/index.mjs +2 -2
- package/dist/mcp.d.mts +30 -4
- package/dist/mcp.d.mts.map +1 -1
- package/dist/mcp.mjs +25 -42
- package/dist/mcp.mjs.map +1 -1
- package/dist/omp.d.mts +7 -2
- package/dist/omp.d.mts.map +1 -1
- package/dist/omp.mjs +19 -6
- package/dist/omp.mjs.map +1 -1
- package/dist/pi.d.mts +24 -5
- package/dist/pi.d.mts.map +1 -1
- package/dist/pi.mjs +39 -5
- package/dist/pi.mjs.map +1 -1
- package/package.json +13 -3
- package/dist/index.d.mts.map +0 -1
package/dist/h3.d.mts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ToolDefinition as ToolDefinition$1 } from "./_chunks/index.mjs";
|
|
2
|
+
import { JsonSchema, ToolDefinition } from "h3-mcp";
|
|
3
|
+
/** An h3-mcp tool whose `inputSchema` is the plain JSON Schema `tools/list` sends. */
|
|
4
|
+
export type H3Tool = ToolDefinition<JsonSchema>;
|
|
5
|
+
/**
|
|
6
|
+
* Turns tools into h3-mcp tool definitions for `defineMcpHandler({ tools })`.
|
|
7
|
+
*
|
|
8
|
+
* Each entry carries what `listTools` lists, and its handler answers through
|
|
9
|
+
* `callTool`, so the text, the validation lines and the sanitized errors are the
|
|
10
|
+
* ones every other MCP transport gives. The schema goes out as plain JSON
|
|
11
|
+
* Schema, which h3-mcp passes through without validating; the core validates
|
|
12
|
+
* instead. An unknown name never reaches a handler: h3-mcp answers it itself
|
|
13
|
+
* with a JSON-RPC error.
|
|
14
|
+
*
|
|
15
|
+
* Imports only types from h3-mcp, so the adapter loads neither h3-mcp nor the MCP SDK.
|
|
16
|
+
*
|
|
17
|
+
* @param info - Server info; `name` is the word in the message for an unknown tool.
|
|
18
|
+
* @param tools - Tools to serve.
|
|
19
|
+
* @returns {H3Tool[]} Tool definitions in the order given.
|
|
20
|
+
* @throws {ToolDefinitionError} When two tools share a name.
|
|
21
|
+
*/
|
|
22
|
+
export declare function toH3Tools(info: {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
}, tools: readonly ToolDefinition$1[]): H3Tool[];
|
|
25
|
+
//# sourceMappingURL=h3.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"h3.d.mts","names":["H3ToolDefinition","ToolDefinition"],"sources":["../src/h3.ts"],"mappings":";;;YAUY,SAASA,eAAiB;;;;;;;;;;;;;;;;;;wBAmBtB,UACd;WAAiB;GACjB,gBAAgBC,qBACf"}
|
package/dist/h3.mjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "./_chunks/src.mjs";
|
|
2
|
+
import { callTool, listTools, progressSteps } from "./_chunks/mcp-answers.mjs";
|
|
3
|
+
function toH3Tools(info, tools) {
|
|
4
|
+
return listTools(tools).map((entry) => ({
|
|
5
|
+
name: entry.name,
|
|
6
|
+
title: entry.title,
|
|
7
|
+
description: entry.description,
|
|
8
|
+
...entry.icons === void 0 ? {} : { icons: entry.icons },
|
|
9
|
+
inputSchema: entry.inputSchema,
|
|
10
|
+
annotations: entry.annotations,
|
|
11
|
+
handler: (args, event) => {
|
|
12
|
+
const mcp = event.context.mcp;
|
|
13
|
+
const context = {
|
|
14
|
+
signal: mcp?.signal,
|
|
15
|
+
...mcp?.progressToken === void 0 || mcp.progress === void 0 ? {} : { progress: progressSteps(({ progress, total, message }) => mcp.progress?.(progress, total, message)) }
|
|
16
|
+
};
|
|
17
|
+
return callTool(info, tools, entry.name, args, context);
|
|
18
|
+
}
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
export { toH3Tools };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=h3.mjs.map
|
package/dist/h3.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"h3.mjs","names":[],"sources":["../src/h3.ts"],"sourcesContent":["/**\n * h3-mcp adapter: hands {@link ToolDefinition}s to `defineMcpHandler` from h3-mcp.\n */\n\nimport type { JsonSchema, ToolDefinition as H3ToolDefinition } from \"h3-mcp\";\n\nimport { type ToolCallContext, type ToolDefinition } from \"./index.ts\";\nimport { callTool, listTools, progressSteps } from \"./mcp-answers.ts\";\n\n/** An h3-mcp tool whose `inputSchema` is the plain JSON Schema `tools/list` sends. */\nexport type H3Tool = H3ToolDefinition<JsonSchema>;\n\n/**\n * Turns tools into h3-mcp tool definitions for `defineMcpHandler({ tools })`.\n *\n * Each entry carries what `listTools` lists, and its handler answers through\n * `callTool`, so the text, the validation lines and the sanitized errors are the\n * ones every other MCP transport gives. The schema goes out as plain JSON\n * Schema, which h3-mcp passes through without validating; the core validates\n * instead. An unknown name never reaches a handler: h3-mcp answers it itself\n * with a JSON-RPC error.\n *\n * Imports only types from h3-mcp, so the adapter loads neither h3-mcp nor the MCP SDK.\n *\n * @param info - Server info; `name` is the word in the message for an unknown tool.\n * @param tools - Tools to serve.\n * @returns {H3Tool[]} Tool definitions in the order given.\n * @throws {ToolDefinitionError} When two tools share a name.\n */\nexport function toH3Tools(\n info: { readonly name: string },\n tools: readonly ToolDefinition[],\n): H3Tool[] {\n return listTools(tools).map((entry) => ({\n name: entry.name,\n title: entry.title,\n description: entry.description,\n ...(entry.icons === undefined ? {} : { icons: entry.icons }),\n inputSchema: entry.inputSchema as JsonSchema,\n annotations: entry.annotations,\n handler: (args, event) => {\n // Read now: a legacy batch shares one context between its calls.\n const mcp = event.context.mcp;\n const context: ToolCallContext = {\n signal: mcp?.signal,\n ...(mcp?.progressToken === undefined || mcp.progress === undefined\n ? {}\n : {\n progress: progressSteps(({ progress, total, message }) =>\n mcp.progress?.(progress, total, message),\n ),\n }),\n };\n return callTool(info, tools, entry.name, args, context);\n },\n }));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;CA6BA,EAAA;AAIE;AAEE,SAAO"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,165 +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
|
|
2
|
-
|
|
3
|
-
export type ToolContent = {
|
|
4
|
-
type: "text";
|
|
5
|
-
text: string;
|
|
6
|
-
} | {
|
|
7
|
-
type: "image";
|
|
8
|
-
data: string;
|
|
9
|
-
mimeType: string;
|
|
10
|
-
};
|
|
11
|
-
/** Text for the model plus details for the harness. */
|
|
12
|
-
export interface ToolResult<Details = unknown> {
|
|
13
|
-
content: ToolContent[];
|
|
14
|
-
details: Details;
|
|
15
|
-
/** Set when the tool could not answer. Each adapter carries it to its host. */
|
|
16
|
-
isError?: boolean;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* What a call does to the world, mapped to MCP annotations and OMP approval.
|
|
20
|
-
*
|
|
21
|
-
* - `read` changes nothing.
|
|
22
|
-
* - `write` changes state that the next call can undo or overwrite.
|
|
23
|
-
* - `destructive` deletes or overwrites what cannot be recovered.
|
|
24
|
-
*/
|
|
25
|
-
export type ToolEffect = "read" | "write" | "destructive";
|
|
26
|
-
/**
|
|
27
|
-
* How a tool reads on the command line. Without hints the command is the tool
|
|
28
|
-
* name without its package prefix, in kebab case, and every property is a flag.
|
|
29
|
-
*/
|
|
30
|
-
export interface ToolCliHints {
|
|
31
|
-
/** Command name instead of the derived one. */
|
|
32
|
-
readonly command?: string;
|
|
33
|
-
readonly aliases?: readonly string[];
|
|
34
|
-
/** Line in the command list. Defaults to the first sentence of `description`. */
|
|
35
|
-
readonly description?: string;
|
|
36
|
-
/** Properties taken in this order as positional arguments instead of flags. */
|
|
37
|
-
readonly positional?: readonly string[];
|
|
38
|
-
/** String properties that read stdin when given as `-`. */
|
|
39
|
-
readonly stdin?: readonly string[];
|
|
40
|
-
}
|
|
41
|
-
/** Per-call context the adapters hand to `execute`. */
|
|
42
|
-
export interface ToolCallContext {
|
|
43
|
-
signal?: AbortSignal;
|
|
44
|
-
}
|
|
45
|
-
export interface ToolDefinition<Input extends TObject = TObject, Details = unknown> {
|
|
46
|
-
/** Wire name, `<package>_<operation>`. */
|
|
47
|
-
readonly name: string;
|
|
48
|
-
/** Human label: MCP `title` and `annotations.title`, Pi and OMP `label`. */
|
|
49
|
-
readonly title: string;
|
|
50
|
-
/** Complete instruction for the model. MCP clients see nothing else. */
|
|
51
|
-
readonly description: string;
|
|
52
|
-
/** Pi `promptSnippet`. */
|
|
53
|
-
readonly snippet?: string;
|
|
54
|
-
/** Pi `promptGuidelines`. Must not promise anything `description` lacks. */
|
|
55
|
-
readonly guidelines?: readonly string[];
|
|
56
|
-
readonly effect: ToolEffect;
|
|
57
|
-
/** Repeating the call with the same input has no further effect. Defaults to `effect === "read"`. */
|
|
58
|
-
readonly idempotent?: boolean;
|
|
59
|
-
/** The call reaches outside the local machine. */
|
|
60
|
-
readonly openWorld?: boolean;
|
|
61
|
-
readonly input: Input;
|
|
62
|
-
/** Command line shape for `@agntn/tools/cli`. No other surface reads it. */
|
|
63
|
-
readonly cli?: ToolCliHints;
|
|
64
|
-
/**
|
|
65
|
-
* Runs the tool on input that already passed {@link validateInput}.
|
|
66
|
-
*
|
|
67
|
-
* Method syntax on purpose: it keeps the parameter bivariant, so a list of
|
|
68
|
-
* tools with different inputs is still a `readonly ToolDefinition[]`.
|
|
69
|
-
*/
|
|
70
|
-
execute(input: Static<Input>, context: ToolCallContext): ToolResult<Details> | Promise<ToolResult<Details>>;
|
|
71
|
-
}
|
|
72
|
-
/** Thrown when a tool definition breaks a contract every surface relies on. */
|
|
73
|
-
export declare class ToolDefinitionError extends Error {
|
|
74
|
-
name: string;
|
|
75
|
-
}
|
|
76
|
-
/** Thrown by {@link invokeTool} when the arguments fail the tool schema. */
|
|
77
|
-
export declare class ToolInputError extends Error {
|
|
78
|
-
name: string;
|
|
79
|
-
/** One validation failure per line. Only these line breaks are the core's own. */
|
|
80
|
-
readonly lines: readonly string[];
|
|
81
|
-
/**
|
|
82
|
-
* @param lines - One validation failure per line.
|
|
83
|
-
*/
|
|
84
|
-
constructor(lines: readonly string[]);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Declares a tool and checks the schema rules every surface depends on.
|
|
88
|
-
*
|
|
89
|
-
* @param tool - Tool definition.
|
|
90
|
-
* @returns {ToolDefinition<Input, Details>} The same definition, typed.
|
|
91
|
-
*/
|
|
92
|
-
export declare function defineTool<const Input extends TObject, Details>(tool: ToolDefinition<Input, Details>): ToolDefinition<Input, Details>;
|
|
93
|
-
/**
|
|
94
|
-
* The input schema as the plain JSON Schema object every host receives.
|
|
95
|
-
*
|
|
96
|
-
* TypeBox 1.x schemas are plain objects already; this only drops the static
|
|
97
|
-
* type, which lacks the index signature host APIs declare.
|
|
98
|
-
*
|
|
99
|
-
* @param tool - Tool whose schema to emit.
|
|
100
|
-
* @returns {Record<string, unknown>} JSON Schema document.
|
|
101
|
-
*/
|
|
102
|
-
export declare function wireSchema(tool: ToolDefinition): Record<string, unknown>;
|
|
103
|
-
/**
|
|
104
|
-
* Indexes tools by name.
|
|
105
|
-
*
|
|
106
|
-
* A `Map`, not a plain object: a lookup of `toString` in a `Record` finds
|
|
107
|
-
* `Object.prototype.toString` and skips the unknown-tool branch.
|
|
108
|
-
*
|
|
109
|
-
* @param tools - Tools to index.
|
|
110
|
-
* @returns {ReadonlyMap<string, ToolDefinition>} Tools by wire name.
|
|
111
|
-
*/
|
|
112
|
-
export declare function indexTools(tools: readonly ToolDefinition[]): ReadonlyMap<string, ToolDefinition>;
|
|
113
|
-
export type InputCheck<Input extends TObject> = {
|
|
114
|
-
ok: true;
|
|
115
|
-
value: Static<Input>;
|
|
116
|
-
} | {
|
|
117
|
-
ok: false;
|
|
118
|
-
lines: readonly string[];
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Validates arguments against the tool schema, reporting every failure.
|
|
122
|
-
*
|
|
123
|
-
* Runs on every surface, not only MCP: a host may skip its own validation, and
|
|
124
|
-
* OMP's omptype drops `pattern` from the schema it emits. The message has one
|
|
125
|
-
* line per failure: an undeclared key names itself with the keys its object
|
|
126
|
-
* takes, at any depth, and an enum failure names the allowed values, so the
|
|
127
|
-
* caller does not go back to the tool list and guess. Format from agntn/hashes
|
|
128
|
-
* (#58). TypeBox stops at eight errors, so root keys are read off the arguments.
|
|
129
|
-
*
|
|
130
|
-
* @param tool - Tool whose schema applies.
|
|
131
|
-
* @param args - Arguments as received from the host.
|
|
132
|
-
* @returns {InputCheck<Input>} The typed value, or the failures, one per line.
|
|
133
|
-
*/
|
|
134
|
-
export declare function validateInput<Input extends TObject>(tool: ToolDefinition<Input, unknown>, args: unknown): InputCheck<Input>;
|
|
135
|
-
/**
|
|
136
|
-
* Validates and runs a tool. Every adapter calls through here.
|
|
137
|
-
*
|
|
138
|
-
* @param tool - Tool to run.
|
|
139
|
-
* @param args - Arguments as received from the host.
|
|
140
|
-
* @param context - Per-call context.
|
|
141
|
-
* @returns {Promise<ToolResult>} The executor's result, unchanged.
|
|
142
|
-
* @throws {ToolInputError} When the arguments fail the schema.
|
|
143
|
-
*/
|
|
144
|
-
export declare function invokeTool(tool: ToolDefinition, args: unknown, context?: ToolCallContext): Promise<ToolResult>;
|
|
145
|
-
/**
|
|
146
|
-
* Makes a value safe for one line of terminal or protocol text.
|
|
147
|
-
*
|
|
148
|
-
* Removes escape sequences, then replaces every control, format, line and
|
|
149
|
-
* paragraph separator character with a space: a raw newline, U+2028 or a bidi
|
|
150
|
-
* override (U+202E, a `Cf`) in an echoed value forges a line that reads as the
|
|
151
|
-
* tool's own output. `String()` first, since hostile JSON ignores declared types.
|
|
152
|
-
*
|
|
153
|
-
* @param value - Value to render.
|
|
154
|
-
* @returns {string} Single-line text.
|
|
155
|
-
*/
|
|
156
|
-
export declare function sanitizeLine(value: unknown): string;
|
|
157
|
-
/**
|
|
158
|
-
* Text of a result, for hosts that carry failures as thrown errors.
|
|
159
|
-
*
|
|
160
|
-
* @param result - Tool result.
|
|
161
|
-
* @returns {string} Text blocks joined by newlines.
|
|
162
|
-
*/
|
|
163
|
-
export declare function resultText(result: ToolResult): string;
|
|
164
|
-
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, type Identifier, type Immutable, type Index, type IndexAction, type IndexDeferred, type IndexInstantiate, type Infer, 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$1 as 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, 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 };
|
|
165
|
-
//# sourceMappingURL=index.d.mts.map
|
|
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";
|
|
2
|
+
import { Icon, InputCheck, ToolCallContext, ToolCliHints, ToolContent, ToolDefinition, ToolDefinitionError, ToolEffect, ToolInputError, ToolProgress, 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, 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, ToolCallContext, ToolCliHints, ToolContent, ToolDefinition, ToolDefinitionError, ToolEffect, ToolInputError, ToolProgress, 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/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type_exports } from "./_chunks/libs/typebox.mjs";
|
|
2
|
-
import { ToolDefinitionError, ToolInputError, defineTool, indexTools, invokeTool, resultText, sanitizeLine, validateInput, wireSchema } from "./_chunks/src.mjs";
|
|
3
|
-
export { ToolDefinitionError, ToolInputError, type_exports as Type, defineTool, indexTools, invokeTool, resultText, sanitizeLine, validateInput, wireSchema };
|
|
2
|
+
import { ToolDefinitionError, ToolInputError, defineTool, indexTools, invokeTool, resultText, sanitizeLine, sanitizeText, validateInput, wireSchema } from "./_chunks/src.mjs";
|
|
3
|
+
export { ToolDefinitionError, ToolInputError, type_exports as Type, defineTool, indexTools, invokeTool, resultText, sanitizeLine, sanitizeText, validateInput, wireSchema };
|
package/dist/mcp.d.mts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { ToolDefinition } from "./index.mjs";
|
|
2
|
-
import { CallToolResult, Server, ToolAnnotations } from "@modelcontextprotocol/server";
|
|
3
|
-
|
|
1
|
+
import { Icon, ToolCallContext, ToolDefinition } from "./_chunks/index.mjs";
|
|
2
|
+
import { CallToolResult, Server, Tool, ToolAnnotations } from "@modelcontextprotocol/server";
|
|
3
|
+
interface McpServerInfo {
|
|
4
4
|
/** Server name, also used in the unknown-tool message. */
|
|
5
5
|
readonly name: string;
|
|
6
6
|
readonly version: string;
|
|
7
7
|
/** Display name for clients that show one, such as `Forges`. */
|
|
8
8
|
readonly title?: string;
|
|
9
|
+
/** One line under the name on a connector card or in a registry. */
|
|
10
|
+
readonly description?: string;
|
|
11
|
+
readonly icons?: readonly Icon[];
|
|
9
12
|
/** Project home a client can link to. */
|
|
10
13
|
readonly websiteUrl?: string;
|
|
11
14
|
}
|
|
@@ -28,6 +31,25 @@ export declare function toolAnnotations(tool: ToolDefinition): ToolAnnotations;
|
|
|
28
31
|
* @returns {CallToolResult} MCP error result.
|
|
29
32
|
*/
|
|
30
33
|
export declare function errorResult(...lines: readonly string[]): CallToolResult;
|
|
34
|
+
/**
|
|
35
|
+
* The entries `tools/list` answers with, in the order given.
|
|
36
|
+
*
|
|
37
|
+
* @param tools - Tools to list.
|
|
38
|
+
* @returns {Tool[]} Name, title, description, icons, schema and annotations of each tool.
|
|
39
|
+
* @throws {ToolDefinitionError} When two tools share a name.
|
|
40
|
+
*/
|
|
41
|
+
export declare function listTools(tools: readonly ToolDefinition[]): Tool[];
|
|
42
|
+
/**
|
|
43
|
+
* Answers one call as `tools/call` does and never throws, so every transport gives the same text.
|
|
44
|
+
*
|
|
45
|
+
* @param info - Server info; `name` is the word in the message for an unknown tool.
|
|
46
|
+
* @param tools - Tools to look the name up in.
|
|
47
|
+
* @param name - Tool name as the client sent it.
|
|
48
|
+
* @param args - Arguments as the client sent them; missing ones count as `{}`.
|
|
49
|
+
* @param context - Context for this call, such as the request's abort signal.
|
|
50
|
+
* @returns {Promise<CallToolResult>} The tool's text, or the sanitized error.
|
|
51
|
+
*/
|
|
52
|
+
export declare function callTool(info: Pick<McpServerInfo, "name">, tools: readonly ToolDefinition[], name: string, args?: unknown, context?: ToolCallContext): Promise<CallToolResult>;
|
|
31
53
|
/**
|
|
32
54
|
* Creates an unconnected MCP server exposing the tools.
|
|
33
55
|
*
|
|
@@ -42,9 +64,13 @@ export declare function errorResult(...lines: readonly string[]): CallToolResult
|
|
|
42
64
|
* clients that see structured output prefer it over `content` and would hide
|
|
43
65
|
* the readable answer. Every fact a follow-up call needs belongs in the text.
|
|
44
66
|
*
|
|
45
|
-
*
|
|
67
|
+
* A progress notification that fails to send goes to `onerror`, never to the tool.
|
|
68
|
+
*
|
|
69
|
+
* @param info - Name, version and optional title, description, icons and website, sent as given.
|
|
46
70
|
* @param tools - Tools to serve.
|
|
47
71
|
* @returns {Server} Unconnected MCP server.
|
|
72
|
+
* @throws {ToolDefinitionError} When two tools share a name.
|
|
48
73
|
*/
|
|
49
74
|
export declare function createMcpServer(info: McpServerInfo, tools: readonly ToolDefinition[]): Server;
|
|
75
|
+
export type { McpServerInfo };
|
|
50
76
|
//# sourceMappingURL=mcp.d.mts.map
|
package/dist/mcp.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.mts","names":[],"sources":["../src/mcp.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"mcp.d.mts","names":[],"sources":["../src/mcp-answers.ts","../src/mcp.ts"],"mappings":";;UAoBiB;;WAEN;WACA;;WAEA;;WAEA;WACA,iBAAiB;;WAEjB;;;;;;;;wBASK,gBAAgB,MAAM,iBAAiB;;;;;;;;;;;;wBAqBvC,eAAe,2BAA2B;;;;;;;;wBAW1C,UAAU,gBAAgB,mBAAmB;;;;;;;;;;;wBAkCvC,SACpB,MAAM,KAAK,wBACX,gBAAgB,kBAChB,cACA,gBACA,UAAS,kBACR,QAAQ;;;;;;;;;;;;;;;;;;;;;;wBClEK,gBAAgB,MAAM,eAAe,gBAAgB,mBAAmB"}
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,55 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { indexTools } from "./_chunks/src.mjs";
|
|
2
|
+
import { callTool, copyIcons, errorResult, listTools, progressSteps, toolAnnotations } from "./_chunks/mcp-answers.mjs";
|
|
2
3
|
import { Server } from "@modelcontextprotocol/server";
|
|
3
|
-
function toolAnnotations(tool) {
|
|
4
|
-
return {
|
|
5
|
-
title: tool.title,
|
|
6
|
-
readOnlyHint: tool.effect === "read",
|
|
7
|
-
destructiveHint: tool.effect === "destructive",
|
|
8
|
-
idempotentHint: tool.idempotent ?? tool.effect === "read",
|
|
9
|
-
openWorldHint: tool.openWorld ?? false
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
function errorResult(...lines) {
|
|
13
|
-
return {
|
|
14
|
-
content: [{
|
|
15
|
-
type: "text",
|
|
16
|
-
text: lines.map(sanitizeLine).join("\n")
|
|
17
|
-
}],
|
|
18
|
-
isError: true
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
4
|
function createMcpServer(info, tools) {
|
|
22
|
-
|
|
23
|
-
const { name, version, title, websiteUrl } = info;
|
|
5
|
+
indexTools(tools);
|
|
6
|
+
const { name, version, title, description, icons, websiteUrl } = info;
|
|
24
7
|
const server = new Server({
|
|
25
8
|
name,
|
|
26
9
|
version,
|
|
27
10
|
title,
|
|
11
|
+
description,
|
|
12
|
+
...icons === void 0 ? {} : { icons: copyIcons(icons) },
|
|
28
13
|
websiteUrl
|
|
29
14
|
}, { capabilities: { tools: {} } });
|
|
30
|
-
server.setRequestHandler("tools/list", () => ({ tools: tools
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return errorResult(`${tool.name} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
49
|
-
}
|
|
15
|
+
server.setRequestHandler("tools/list", () => ({ tools: listTools(tools) }));
|
|
16
|
+
server.setRequestHandler("tools/call", (request, ctx) => {
|
|
17
|
+
const progressToken = ctx.mcpReq._meta?.progressToken;
|
|
18
|
+
const notify = (params) => {
|
|
19
|
+
ctx.mcpReq.notify({
|
|
20
|
+
method: "notifications/progress",
|
|
21
|
+
params: {
|
|
22
|
+
progressToken,
|
|
23
|
+
...params
|
|
24
|
+
}
|
|
25
|
+
}).catch((error) => {
|
|
26
|
+
server.onerror?.(error instanceof Error ? error : new Error(String(error)));
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
return callTool(info, tools, request.params.name, request.params.arguments, {
|
|
30
|
+
signal: ctx.mcpReq.signal,
|
|
31
|
+
...progressToken === void 0 ? {} : { progress: progressSteps(notify) }
|
|
32
|
+
});
|
|
50
33
|
});
|
|
51
34
|
return server;
|
|
52
35
|
}
|
|
53
|
-
export { createMcpServer, errorResult, toolAnnotations };
|
|
36
|
+
export { callTool, createMcpServer, errorResult, listTools, toolAnnotations };
|
|
54
37
|
|
|
55
38
|
//# sourceMappingURL=mcp.mjs.map
|
package/dist/mcp.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.mjs","names":[],"sources":["../src/mcp.ts"],"sourcesContent":["/**\n * MCP adapter: serves {@link ToolDefinition}s from an unconnected MCP server.\n */\n\nimport {
|
|
1
|
+
{"version":3,"file":"mcp.mjs","names":[],"sources":["../src/mcp.ts"],"sourcesContent":["/**\n * MCP adapter: serves {@link ToolDefinition}s from an unconnected MCP server.\n */\n\nimport { Server } from \"@modelcontextprotocol/server\";\n\nimport { indexTools, type ToolDefinition } from \"./index.ts\";\nimport {\n callTool,\n copyIcons,\n listTools,\n progressSteps,\n type McpServerInfo,\n type ProgressParams,\n} from \"./mcp-answers.ts\";\n\nexport {\n callTool,\n errorResult,\n listTools,\n toolAnnotations,\n type McpServerInfo,\n} from \"./mcp-answers.ts\";\n\n/**\n * Creates an unconnected MCP server exposing the tools.\n *\n * Built on the low-level `Server` of MCP SDK v2, which the SDK marks\n * `@deprecated`, not on `McpServer`. `McpServer.registerTool` in 2.2.0 would\n * take the schema, but it answers `toString`, `constructor` and `__proto__` as\n * \"Tool toString disabled\" (a lookup that reaches `Object.prototype`), echoes a\n * raw tool name with newlines and escapes into its error, joins validation\n * failures into one line and passes a thrown message through unsanitized.\n *\n * `details` never reaches the client and `structuredContent` is never set:\n * clients that see structured output prefer it over `content` and would hide\n * the readable answer. Every fact a follow-up call needs belongs in the text.\n *\n * A progress notification that fails to send goes to `onerror`, never to the tool.\n *\n * @param info - Name, version and optional title, description, icons and website, sent as given.\n * @param tools - Tools to serve.\n * @returns {Server} Unconnected MCP server.\n * @throws {ToolDefinitionError} When two tools share a name.\n */\nexport function createMcpServer(info: McpServerInfo, tools: readonly ToolDefinition[]): Server {\n indexTools(tools);\n const { name, version, title, description, icons, websiteUrl } = info;\n const server = new Server(\n {\n name,\n version,\n title,\n description,\n ...(icons === undefined ? {} : { icons: copyIcons(icons) }),\n websiteUrl,\n },\n { capabilities: { tools: {} } },\n );\n\n server.setRequestHandler(\"tools/list\", () => ({ tools: listTools(tools) }));\n server.setRequestHandler(\"tools/call\", (request, ctx) => {\n const progressToken = ctx.mcpReq._meta?.progressToken;\n const notify = (params: ProgressParams): void => {\n ctx.mcpReq\n .notify({ method: \"notifications/progress\", params: { progressToken, ...params } })\n .catch((error: unknown) => {\n server.onerror?.(error instanceof Error ? error : new Error(String(error)));\n });\n };\n return callTool(info, tools, request.params.name, request.params.arguments, {\n signal: ctx.mcpReq.signal,\n ...(progressToken === undefined ? {} : { progress: progressSteps(notify) }),\n });\n });\n\n return server;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;IA6CA,OAAgB,UAAA,iBAA+E,QAAA,QAAA,IAAA,MAAA,OAAA,KAAA,CAAA,CAAA;GAC7F,CAAA;EACA;EACA,OAAM,SAAS,MAAI,OACjB,QAAA,OAAA,MAAA,QAAA,OAAA,WAAA;GACE,QAAA,IAAA,OAAA;GACA,GAAA,kBAAA,KAAA,IAAA,CAAA,IAAA,EAAA,UAAA,cAAA,MAAA,EAAA;EACA,CAAA;CACA,CAAA;CACA,OAAI;AACJ;AAKJ,SAAO,UAAA,iBAAkB,aAAuB,WAAO"}
|
package/dist/omp.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ToolDefinition as ToolDefinition$1 } from "./index.mjs";
|
|
1
|
+
import { ToolDefinition as ToolDefinition$1 } from "./_chunks/index.mjs";
|
|
2
2
|
import { ExtensionAPI, Text, ToolDefinition } from "@oh-my-pi/pi-coding-agent";
|
|
3
3
|
type TextComponent = typeof Text;
|
|
4
4
|
/** The part of a host result a renderer reads. */
|
|
@@ -10,6 +10,8 @@ export interface OmpResultView {
|
|
|
10
10
|
export interface OmpRenderers {
|
|
11
11
|
/** One-line summary of the arguments after the title. Sanitized by the adapter. */
|
|
12
12
|
describeCall?(args: Readonly<Record<string, unknown>>): unknown;
|
|
13
|
+
/** Replaces the whole call line, `describeCall` included. It owns sanitizing what it draws. */
|
|
14
|
+
renderCall?: ToolDefinition["renderCall"];
|
|
13
15
|
/** Short metadata after the badge, one entry per fact. Each entry is sanitized. */
|
|
14
16
|
describeResult?(result: OmpResultView): readonly unknown[];
|
|
15
17
|
/**
|
|
@@ -21,6 +23,8 @@ export interface OmpRenderers {
|
|
|
21
23
|
export interface OmpToolOptions {
|
|
22
24
|
/** The host `Text` component, imported by the extension from the package root. */
|
|
23
25
|
readonly Text: TextComponent;
|
|
26
|
+
/** `"essential"` keeps every tool in OMP's top-level list. Left out, OMP hides them behind discovery. */
|
|
27
|
+
readonly loadMode?: ToolDefinition["loadMode"];
|
|
24
28
|
/** Status-line renderers by tool name. */
|
|
25
29
|
readonly renderers?: Readonly<Record<string, OmpRenderers>>;
|
|
26
30
|
}
|
|
@@ -34,7 +38,8 @@ export interface OmpToolOptions {
|
|
|
34
38
|
*
|
|
35
39
|
* @param pi - OMP extension API.
|
|
36
40
|
* @param tools - Tools to register.
|
|
37
|
-
* @param options - Host `Text
|
|
41
|
+
* @param options - Host `Text`, optional load mode and renderers.
|
|
42
|
+
* @throws {ToolDefinitionError} When two tools share a name.
|
|
38
43
|
*/
|
|
39
44
|
export declare function registerOmpTools(pi: ExtensionAPI, tools: readonly ToolDefinition$1[], options: OmpToolOptions): void;
|
|
40
45
|
//# sourceMappingURL=omp.d.mts.map
|
package/dist/omp.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"omp.d.mts","names":["HostText","OmpToolDefinition","ToolDefinition"],"sources":["../src/omp.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"omp.d.mts","names":["HostText","OmpToolDefinition","ToolDefinition"],"sources":["../src/omp.ts"],"mappings":";;KA2BK,uBAAuBA;;iBAIX;WACN;WACA;;;iBAIM;;EAEf,cAAc,MAAM,SAAS;;EAE7B,aAAaC;;EAEb,gBAAgB,QAAQ;;;;;EAKxB,eAAeA;;iBAGA;;WAEN,MAAM;;WAEN,WAAWA;;WAEX,YAAY,SAAS,eAAe;;;;;;;;;;;;;;;wBAuB/B,iBACd,IAAI,cACJ,gBAAgBC,oBAChB,SAAS"}
|
package/dist/omp.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { invokeTool, sanitizeLine, wireSchema } from "./_chunks/src.mjs";
|
|
1
|
+
import { indexTools, invokeTool, sanitizeLine, wireSchema } from "./_chunks/src.mjs";
|
|
2
|
+
import { hostContext } from "./_chunks/updates.mjs";
|
|
2
3
|
const APPROVAL = {
|
|
3
4
|
read: "read",
|
|
4
5
|
write: "write",
|
|
5
6
|
destructive: "write"
|
|
6
7
|
};
|
|
7
8
|
function registerOmpTools(pi, tools, options) {
|
|
9
|
+
indexTools(tools);
|
|
8
10
|
const { Type } = pi.typebox;
|
|
9
11
|
const { Text } = options;
|
|
10
12
|
for (const tool of tools) {
|
|
@@ -15,26 +17,37 @@ function registerOmpTools(pi, tools, options) {
|
|
|
15
17
|
description: tool.description,
|
|
16
18
|
parameters: Type.Unsafe(wireSchema(tool)),
|
|
17
19
|
approval: APPROVAL[tool.effect],
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
loadMode: options.loadMode,
|
|
21
|
+
async execute(_toolCallId, params, signal, onUpdate, ctx) {
|
|
22
|
+
return await invokeTool(tool, params, hostContext(signal, onUpdate, ctx));
|
|
20
23
|
},
|
|
21
24
|
renderCall(args, renderOptions, theme) {
|
|
25
|
+
if (renderers?.renderCall) return renderers.renderCall(args, renderOptions, theme);
|
|
22
26
|
const summary = renderers?.describeCall ? sanitizeLine(renderers.describeCall(args)) : "";
|
|
23
27
|
const title = theme.fg("accent", sanitizeLine(tool.title));
|
|
24
28
|
return new Text(`${callIcon(renderOptions, theme)} ${title}${summary ? `: ${theme.fg("muted", summary)}` : ""}`, 0, 0);
|
|
25
29
|
},
|
|
26
30
|
renderResult(result, renderOptions, theme, args) {
|
|
27
31
|
if (renderers?.renderResult) return renderers.renderResult(result, renderOptions, theme, args);
|
|
32
|
+
if (renderOptions.isPartial) return new Text(progressLine(tool, result, renderOptions, theme), 0, 0);
|
|
28
33
|
const icon = result.isError ? theme.styledSymbol("status.error", "error") : theme.styledSymbol("status.done", "success");
|
|
29
34
|
const { bracketLeft, bracketRight } = theme.format;
|
|
30
35
|
const badge = theme.fg("accent", `${bracketLeft}${APPROVAL[tool.effect]}${bracketRight}`);
|
|
31
|
-
const facts = result.isError ? [] : renderers?.describeResult?.(result)
|
|
32
|
-
|
|
33
|
-
return new Text(`${icon} ${theme.fg("accent", sanitizeLine(tool.title))} ${badge}${meta}`, 0, 0);
|
|
36
|
+
const facts = result.isError ? [] : renderers?.describeResult?.(result) ?? [];
|
|
37
|
+
return new Text(`${icon} ${theme.fg("accent", sanitizeLine(tool.title))} ${badge}${dimFacts(facts, theme)}`, 0, 0);
|
|
34
38
|
}
|
|
35
39
|
});
|
|
36
40
|
}
|
|
37
41
|
}
|
|
42
|
+
function progressLine(tool, result, options, theme) {
|
|
43
|
+
const message = sanitizeLine(result.content.findLast((block) => block.type === "text")?.text ?? "");
|
|
44
|
+
const title = theme.fg("accent", sanitizeLine(tool.title));
|
|
45
|
+
return `${callIcon(options, theme)} ${title}${message ? ` ${theme.fg("dim", message)}` : ""}`;
|
|
46
|
+
}
|
|
47
|
+
function dimFacts(facts, theme) {
|
|
48
|
+
const shown = facts.map(sanitizeLine).filter(Boolean);
|
|
49
|
+
return shown.length > 0 ? ` ${theme.fg("dim", shown.join(theme.sep.dot))}` : "";
|
|
50
|
+
}
|
|
38
51
|
function callIcon(options, theme) {
|
|
39
52
|
if (!options.isPartial) return theme.styledSymbol("status.done", "success");
|
|
40
53
|
if (options.spinnerFrame === void 0) return theme.styledSymbol("status.pending", "muted");
|