@warlock.js/ai-tools 5.31.0 → 5.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/cjs/index.cjs +130 -26
- package/cjs/index.cjs.map +1 -1
- package/esm/contracts/http.type.d.mts +4 -5
- package/esm/contracts/http.type.d.mts.map +1 -1
- package/esm/contracts/index.d.mts +2 -1
- package/esm/contracts/mcp-serve.type.d.mts +61 -33
- package/esm/contracts/mcp-serve.type.d.mts.map +1 -1
- package/esm/contracts/mcp.type.d.mts +29 -19
- package/esm/contracts/mcp.type.d.mts.map +1 -1
- package/esm/contracts/utility.type.d.mts +7 -8
- package/esm/contracts/utility.type.d.mts.map +1 -1
- package/esm/contracts/web.type.d.mts +9 -10
- package/esm/contracts/web.type.d.mts.map +1 -1
- package/esm/errors.d.mts +31 -26
- package/esm/errors.d.mts.map +1 -1
- package/esm/http/http-request.d.mts +2 -3
- package/esm/http/http-request.d.mts.map +1 -1
- package/esm/http/http-request.mjs +7 -5
- package/esm/http/http-request.mjs.map +1 -1
- package/esm/index.d.mts +5 -1
- package/esm/index.mjs +2 -1
- package/esm/mcp/client.mjs +2 -1
- package/esm/mcp/client.mjs.map +1 -1
- package/esm/mcp/index.d.mts +5 -4
- package/esm/mcp/index.d.mts.map +1 -1
- package/esm/mcp/index.mjs +2 -1
- package/esm/mcp/index.mjs.map +1 -1
- package/esm/mcp/json-schema-to-standard.d.mts +1 -3
- package/esm/mcp/json-schema-to-standard.d.mts.map +1 -1
- package/esm/mcp/protocol.d.mts +1 -2
- package/esm/mcp/protocol.d.mts.map +1 -1
- package/esm/mcp/result.d.mts +17 -0
- package/esm/mcp/result.d.mts.map +1 -0
- package/esm/mcp/result.mjs +85 -0
- package/esm/mcp/result.mjs.map +1 -0
- package/esm/mcp/serve-http.mjs +4 -3
- package/esm/mcp/serve-http.mjs.map +1 -1
- package/esm/mcp/serve.d.mts +5 -5
- package/esm/mcp/serve.d.mts.map +1 -1
- package/esm/mcp/serve.mjs +17 -7
- package/esm/mcp/serve.mjs.map +1 -1
- package/esm/mcp/transport.d.mts +4 -5
- package/esm/mcp/transport.d.mts.map +1 -1
- package/esm/mcp/transport.mjs +12 -6
- package/esm/mcp/transport.mjs.map +1 -1
- package/esm/mcp/transport.type.d.mts +2 -2
- package/esm/mcp/transport.type.d.mts.map +1 -1
- package/esm/register.d.mts +3 -4
- package/esm/register.d.mts.map +1 -1
- package/esm/utility/calculator.d.mts +1 -3
- package/esm/utility/calculator.d.mts.map +1 -1
- package/esm/utility/date-time.d.mts +3 -5
- package/esm/utility/date-time.d.mts.map +1 -1
- package/esm/utility/date-time.mjs +2 -1
- package/esm/utility/date-time.mjs.map +1 -1
- package/esm/utility/index.d.mts +2 -1
- package/esm/utility/index.mjs +1 -1
- package/esm/web/fetch-url.d.mts +2 -3
- package/esm/web/fetch-url.d.mts.map +1 -1
- package/esm/web/fetch-url.mjs +2 -1
- package/esm/web/fetch-url.mjs.map +1 -1
- package/esm/web/index.d.mts +2 -1
- package/esm/web/index.mjs +1 -1
- package/esm/web/web-search.d.mts +2 -3
- package/esm/web/web-search.d.mts.map +1 -1
- package/esm/web/web-search.mjs +3 -4
- package/esm/web/web-search.mjs.map +1 -1
- package/llms-full.txt +53 -1
- package/package.json +2 -2
- package/skills/expose-as-mcp-server/SKILL.md +53 -1
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
* default policy allows only `"GET"`; mutating methods are opt-in via
|
|
9
9
|
* {@link HttpRequestOptions.allowMethods}.
|
|
10
10
|
*/
|
|
11
|
-
type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
11
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
12
12
|
/**
|
|
13
13
|
* Construction options for `ai.tools.http`. These bound what the model
|
|
14
14
|
* is allowed to do — the model supplies the per-call URL / method /
|
|
15
15
|
* body within these rails.
|
|
16
16
|
*/
|
|
17
|
-
interface HttpRequestOptions {
|
|
17
|
+
export interface HttpRequestOptions {
|
|
18
18
|
/**
|
|
19
19
|
* Override the tool name exposed to the LLM.
|
|
20
20
|
*
|
|
@@ -68,7 +68,7 @@ interface HttpRequestOptions {
|
|
|
68
68
|
/**
|
|
69
69
|
* The validated input shape the model passes to `http_request`.
|
|
70
70
|
*/
|
|
71
|
-
interface HttpRequestInput {
|
|
71
|
+
export interface HttpRequestInput {
|
|
72
72
|
/**
|
|
73
73
|
* HTTP method. Must be one of {@link HttpRequestOptions.allowMethods}
|
|
74
74
|
* (defaults to `"GET"` when omitted).
|
|
@@ -90,7 +90,7 @@ interface HttpRequestInput {
|
|
|
90
90
|
/**
|
|
91
91
|
* The `http_request` tool's output.
|
|
92
92
|
*/
|
|
93
|
-
interface HttpRequestResult {
|
|
93
|
+
export interface HttpRequestResult {
|
|
94
94
|
/** HTTP status code of the response. */
|
|
95
95
|
status: number;
|
|
96
96
|
/** Response headers, lower-cased keys. */
|
|
@@ -104,5 +104,4 @@ interface HttpRequestResult {
|
|
|
104
104
|
truncated: boolean;
|
|
105
105
|
}
|
|
106
106
|
//#endregion
|
|
107
|
-
export { HttpMethod, HttpRequestInput, HttpRequestOptions, HttpRequestResult };
|
|
108
107
|
//# sourceMappingURL=http.type.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-tools/src/contracts/http.type.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-tools/src/contracts/http.type.ts"],"mappings":";;;;;;;;;;YAUY;;;;;;iBAOK;;;;;;EAMf;;;;;EAKA;;;;;;;EAOA,eAAe;;;;;;EAMf;;;;;;;;;;;EAWA;;EAEA,UAAU;;;;;;EAMV;;;;;;EAMA;;;;;iBAMe;;;;;EAKf,SAAS;;;;;EAKT;;EAEA,UAAU;;;;;EAKV;;;;;iBAMe;;EAEf;;EAEA,SAAS;;;;;EAKT;;EAEA"}
|
|
@@ -2,4 +2,5 @@ import { FetchUrlExtract, FetchUrlInput, FetchUrlOptions, FetchUrlResult, Search
|
|
|
2
2
|
import { HttpMethod, HttpRequestInput, HttpRequestOptions, HttpRequestResult } from "./http.type.mjs";
|
|
3
3
|
import { CalculatorInput, CalculatorOptions, CalculatorResult, DateTimeInput, DateTimeOp, DateTimeOptions, DateTimeResult } from "./utility.type.mjs";
|
|
4
4
|
import { JsonRpcError, JsonRpcId, JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, JsonRpcVersion, McpClient, McpClientOptions, McpContentBlock, McpToolCallResult, McpToolDescriptor, McpTransport } from "./mcp.type.mjs";
|
|
5
|
-
import { McpGroupedToolSource, McpHttpAuth, McpHttpRequestInfo, McpHttpServeHandle, McpHttpServeTransport, McpPromptArgument, McpPromptMessage, McpServeCallContext, McpServeHandle, McpServeOptions, McpServePrompt, McpServeResource, McpServeSource, McpServeTransport, McpServer, McpToolSource } from "./mcp-serve.type.mjs";
|
|
5
|
+
import { McpGroupedToolSource, McpHttpAuth, McpHttpRequestInfo, McpHttpServeHandle, McpHttpServeTransport, McpPromptArgument, McpPromptMessage, McpServeCallContext, McpServeHandle, McpServeOptions, McpServePrompt, McpServeResource, McpServeSource, McpServeTransport, McpServer, McpToolSource } from "./mcp-serve.type.mjs";
|
|
6
|
+
export type { CalculatorInput, CalculatorOptions, CalculatorResult, DateTimeInput, DateTimeOp, DateTimeOptions, DateTimeResult, FetchUrlExtract, FetchUrlInput, FetchUrlOptions, FetchUrlResult, HttpMethod, HttpRequestInput, HttpRequestOptions, HttpRequestResult, JsonRpcError, JsonRpcId, JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, JsonRpcVersion, McpClient, McpClientOptions, McpContentBlock, McpGroupedToolSource, McpHttpAuth, McpHttpRequestInfo, McpHttpServeHandle, McpHttpServeTransport, McpPromptArgument, McpPromptMessage, McpServeCallContext, McpServeHandle, McpServeOptions, McpServePrompt, McpServeResource, McpServeSource, McpServeTransport, McpServer, McpToolCallResult, McpToolDescriptor, McpToolSource, McpTransport, SearchProvider, WebSearchInput, WebSearchOptions, WebSearchResult, WebSearchResultItem };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { McpContentBlock } from "./mcp.type.mjs";
|
|
2
2
|
import { JsonSchemaTarget, ToolContract, ToolRequestContext } from "@warlock.js/ai";
|
|
3
|
-
|
|
4
3
|
//#region ../../packages/ai-tools/src/contracts/mcp-serve.type.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Type contracts for `ai.mcp.serve(source, options)` — exposing local
|
|
@@ -12,7 +11,7 @@ import { JsonSchemaTarget, ToolContract, ToolRequestContext } from "@warlock.js/
|
|
|
12
11
|
* One set of tools: an object that can enumerate its `ToolContract`s (a
|
|
13
12
|
* built agent / supervisor / orchestrator / workspace), or a literal array.
|
|
14
13
|
*/
|
|
15
|
-
type McpToolSource = {
|
|
14
|
+
export type McpToolSource = {
|
|
16
15
|
tools(): ToolContract[];
|
|
17
16
|
} | ToolContract[];
|
|
18
17
|
/**
|
|
@@ -23,8 +22,9 @@ type McpToolSource = {
|
|
|
23
22
|
* @example
|
|
24
23
|
* { groups: { github: githubAgent, files: [readFile, writeFile] } }
|
|
25
24
|
*/
|
|
26
|
-
type McpGroupedToolSource = {
|
|
27
|
-
/** Tool sets keyed by group name. */
|
|
25
|
+
export type McpGroupedToolSource = {
|
|
26
|
+
/** Tool sets keyed by group name. */
|
|
27
|
+
groups: Record<string, McpToolSource>;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
30
|
* What `ai.mcp.serve` exposes as tools — one tool set, or several named
|
|
@@ -32,14 +32,16 @@ type McpGroupedToolSource = {
|
|
|
32
32
|
* {@link import("../errors").McpServeError} (`type: "collision"`) when
|
|
33
33
|
* `serve()` is called.
|
|
34
34
|
*/
|
|
35
|
-
type McpServeSource = McpToolSource | McpGroupedToolSource;
|
|
35
|
+
export type McpServeSource = McpToolSource | McpGroupedToolSource;
|
|
36
36
|
/**
|
|
37
37
|
* Normalised metadata of an inbound HTTP request, handed to a custom
|
|
38
38
|
* {@link McpHttpAuth.authorize} hook. Tools receive the same headers on
|
|
39
39
|
* `ctx.request` (see `ToolRequestContext` in `@warlock.js/ai`).
|
|
40
40
|
*/
|
|
41
|
-
type McpHttpRequestInfo = ToolRequestContext & {
|
|
42
|
-
/** The HTTP method, upper-case (`"POST"`, `"GET"`, …). */
|
|
41
|
+
export type McpHttpRequestInfo = ToolRequestContext & {
|
|
42
|
+
/** The HTTP method, upper-case (`"POST"`, `"GET"`, …). */
|
|
43
|
+
method: string;
|
|
44
|
+
/** The request path, without the query string. */
|
|
43
45
|
path: string;
|
|
44
46
|
};
|
|
45
47
|
/**
|
|
@@ -47,7 +49,7 @@ type McpHttpRequestInfo = ToolRequestContext & {
|
|
|
47
49
|
* `bearer` / `authorize` is required; when both are set, a request must
|
|
48
50
|
* pass both. A request that fails gets HTTP 401 before its body is read.
|
|
49
51
|
*/
|
|
50
|
-
type McpHttpAuth = {
|
|
52
|
+
export type McpHttpAuth = {
|
|
51
53
|
/**
|
|
52
54
|
* Accepted bearer token(s), matched against
|
|
53
55
|
* `Authorization: Bearer <token>`. Compared in constant time over
|
|
@@ -69,8 +71,9 @@ type McpHttpAuth = {
|
|
|
69
71
|
* Binds `127.0.0.1` by default. Binding any non-loopback address
|
|
70
72
|
* requires `auth`; `start()` throws otherwise.
|
|
71
73
|
*/
|
|
72
|
-
type McpHttpServeTransport = {
|
|
73
|
-
/** Streamable HTTP transport. */
|
|
74
|
+
export type McpHttpServeTransport = {
|
|
75
|
+
/** Streamable HTTP transport. */
|
|
76
|
+
type: "http";
|
|
74
77
|
/**
|
|
75
78
|
* Interface to bind. Loopback (`127.0.0.1`, `::1`, `localhost`) needs
|
|
76
79
|
* no auth; anything else (`0.0.0.0`, a LAN address) requires `auth`.
|
|
@@ -90,7 +93,8 @@ type McpHttpServeTransport = {
|
|
|
90
93
|
*
|
|
91
94
|
* @default "/mcp"
|
|
92
95
|
*/
|
|
93
|
-
path?: string;
|
|
96
|
+
path?: string;
|
|
97
|
+
/** Bearer token(s) and/or a custom authorize hook. Required off loopback. */
|
|
94
98
|
auth?: McpHttpAuth;
|
|
95
99
|
/**
|
|
96
100
|
* Extra browser origins allowed to call the endpoint, as full origins
|
|
@@ -128,25 +132,32 @@ type McpHttpServeTransport = {
|
|
|
128
132
|
* - `"stdio"` — serve JSON-RPC over this process's stdin/stdout.
|
|
129
133
|
* - `"http"` — serve MCP Streamable HTTP (see {@link McpHttpServeTransport}).
|
|
130
134
|
*/
|
|
131
|
-
type McpServeTransport = {
|
|
135
|
+
export type McpServeTransport = {
|
|
132
136
|
type: "stdio";
|
|
133
137
|
} | McpHttpServeTransport;
|
|
134
138
|
/**
|
|
135
139
|
* Per-call context handed to resource readers and prompt builders (tools
|
|
136
140
|
* receive the same data on their `ToolContext`).
|
|
137
141
|
*/
|
|
138
|
-
type McpServeCallContext = {
|
|
139
|
-
/** The inbound HTTP request; absent over stdio. */
|
|
142
|
+
export type McpServeCallContext = {
|
|
143
|
+
/** The inbound HTTP request; absent over stdio. */
|
|
144
|
+
request?: McpHttpRequestInfo;
|
|
145
|
+
/** Aborted when an HTTP server's `close()` gives up draining. */
|
|
140
146
|
signal?: AbortSignal;
|
|
141
147
|
};
|
|
142
148
|
/**
|
|
143
149
|
* A static MCP resource served by `resources/list` + `resources/read`.
|
|
144
150
|
*/
|
|
145
|
-
type McpServeResource = {
|
|
146
|
-
/** Unique resource URI, e.g. `"docs://handbook"`. */
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
export type McpServeResource = {
|
|
152
|
+
/** Unique resource URI, e.g. `"docs://handbook"`. */
|
|
153
|
+
uri: string;
|
|
154
|
+
/** Resource name. */
|
|
155
|
+
name: string;
|
|
156
|
+
/** Optional display title. */
|
|
157
|
+
title?: string;
|
|
158
|
+
/** Optional description. */
|
|
159
|
+
description?: string;
|
|
160
|
+
/** Optional MIME type, echoed on the read result. */
|
|
150
161
|
mimeType?: string;
|
|
151
162
|
/**
|
|
152
163
|
* Produce the resource's contents. A string is sent as `text`; bytes
|
|
@@ -155,23 +166,32 @@ type McpServeResource = {
|
|
|
155
166
|
read(context: McpServeCallContext): string | Uint8Array | Promise<string | Uint8Array>;
|
|
156
167
|
};
|
|
157
168
|
/** One declared argument of an {@link McpServePrompt}. */
|
|
158
|
-
type McpPromptArgument = {
|
|
159
|
-
/** Argument name. */
|
|
160
|
-
|
|
169
|
+
export type McpPromptArgument = {
|
|
170
|
+
/** Argument name. */
|
|
171
|
+
name: string;
|
|
172
|
+
/** Optional description shown to the user. */
|
|
173
|
+
description?: string;
|
|
174
|
+
/** When `true`, `prompts/get` without it answers an invalid-params error. */
|
|
161
175
|
required?: boolean;
|
|
162
176
|
};
|
|
163
177
|
/** One message of a prompt returned by `prompts/get`. */
|
|
164
|
-
type McpPromptMessage = {
|
|
165
|
-
/** Who speaks the message. */
|
|
178
|
+
export type McpPromptMessage = {
|
|
179
|
+
/** Who speaks the message. */
|
|
180
|
+
role: "user" | "assistant";
|
|
181
|
+
/** The content block (`{ type: "text", text }` for plain text). */
|
|
166
182
|
content: McpContentBlock;
|
|
167
183
|
};
|
|
168
184
|
/**
|
|
169
185
|
* A prompt template served by `prompts/list` + `prompts/get`.
|
|
170
186
|
*/
|
|
171
|
-
type McpServePrompt = {
|
|
172
|
-
/** Unique prompt name. */
|
|
173
|
-
|
|
174
|
-
|
|
187
|
+
export type McpServePrompt = {
|
|
188
|
+
/** Unique prompt name. */
|
|
189
|
+
name: string;
|
|
190
|
+
/** Optional display title. */
|
|
191
|
+
title?: string;
|
|
192
|
+
/** Optional description. */
|
|
193
|
+
description?: string;
|
|
194
|
+
/** Declared arguments. */
|
|
175
195
|
arguments?: McpPromptArgument[];
|
|
176
196
|
/**
|
|
177
197
|
* Build the prompt. A string becomes one `user` text message.
|
|
@@ -184,7 +204,7 @@ type McpServePrompt = {
|
|
|
184
204
|
* Options for `ai.mcp.serve(source, options)` (Direction B: local
|
|
185
205
|
* primitive → MCP server other clients can consume).
|
|
186
206
|
*/
|
|
187
|
-
interface McpServeOptions {
|
|
207
|
+
export interface McpServeOptions {
|
|
188
208
|
/** Server name advertised in the `initialize` response. */
|
|
189
209
|
name: string;
|
|
190
210
|
/**
|
|
@@ -207,6 +227,15 @@ interface McpServeOptions {
|
|
|
207
227
|
* @default "draft-2020-12"
|
|
208
228
|
*/
|
|
209
229
|
schemaTarget?: JsonSchemaTarget;
|
|
230
|
+
/**
|
|
231
|
+
* Opt in to native MCP result detection for objects containing `content`,
|
|
232
|
+
* `isError`, `structuredContent` or `_meta`. Other values still become text.
|
|
233
|
+
* Override per tool with `meta.mcpResults: "native" | "text"`.
|
|
234
|
+
* Explicit `mcpResult()` values always pass through after validation.
|
|
235
|
+
*
|
|
236
|
+
* @default "text"
|
|
237
|
+
*/
|
|
238
|
+
results?: "text" | "native";
|
|
210
239
|
/**
|
|
211
240
|
* Prefix each tool of a grouped source (`{ groups: { … } }`) with its
|
|
212
241
|
* group name. `true` exposes `<group>_<tool>`; a function builds the
|
|
@@ -224,7 +253,7 @@ interface McpServeOptions {
|
|
|
224
253
|
* What a started server resolves with. Over HTTP, `url` is the full
|
|
225
254
|
* endpoint (`http://127.0.0.1:53211/mcp`); over stdio it is absent.
|
|
226
255
|
*/
|
|
227
|
-
interface McpServeHandle {
|
|
256
|
+
export interface McpServeHandle {
|
|
228
257
|
/** The endpoint URL (HTTP only). */
|
|
229
258
|
url?: string;
|
|
230
259
|
/**
|
|
@@ -235,14 +264,14 @@ interface McpServeHandle {
|
|
|
235
264
|
close(): Promise<void>;
|
|
236
265
|
}
|
|
237
266
|
/** The handle of an HTTP-served MCP endpoint — `url` is always set. */
|
|
238
|
-
interface McpHttpServeHandle extends McpServeHandle {
|
|
267
|
+
export interface McpHttpServeHandle extends McpServeHandle {
|
|
239
268
|
/** The endpoint URL, e.g. `http://127.0.0.1:53211/mcp`. */
|
|
240
269
|
url: string;
|
|
241
270
|
}
|
|
242
271
|
/**
|
|
243
272
|
* A `ai.mcp.serve` server. Nothing listens until `start()`.
|
|
244
273
|
*/
|
|
245
|
-
interface McpServer<THandle extends McpServeHandle = McpServeHandle> {
|
|
274
|
+
export interface McpServer<THandle extends McpServeHandle = McpServeHandle> {
|
|
246
275
|
/**
|
|
247
276
|
* Begin serving. Over HTTP, resolves once the port is bound with
|
|
248
277
|
* `{ url, close }`. Calling it again while running resolves the same
|
|
@@ -253,5 +282,4 @@ interface McpServer<THandle extends McpServeHandle = McpServeHandle> {
|
|
|
253
282
|
stop(): Promise<void>;
|
|
254
283
|
}
|
|
255
284
|
//#endregion
|
|
256
|
-
export { McpGroupedToolSource, McpHttpAuth, McpHttpRequestInfo, McpHttpServeHandle, McpHttpServeTransport, McpPromptArgument, McpPromptMessage, McpServeCallContext, McpServeHandle, McpServeOptions, McpServePrompt, McpServeResource, McpServeSource, McpServeTransport, McpServer, McpToolSource };
|
|
257
285
|
//# sourceMappingURL=mcp-serve.type.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-serve.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-tools/src/contracts/mcp-serve.type.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp-serve.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-tools/src/contracts/mcp-serve.type.ts"],"mappings":";;;;;;;;;;;;;YAcY;EAAkB,SAAS;IAAmB;;;;;;;;;YAU9C;;EAEV,QAAQ,eAAe;;;;;;;;YASb,iBAAiB,gBAAgB;;;;;;YAOjC,qBAAqB;;EAE/B;;EAEA;;;;;;;YAQU;;;;;;;;EAQV;;;;;;EAMA,aAAa,SAAS,iCAAiC;;;;;;;;YAS7C;;EAEV;;;;;;;EAOA;;;;;;;EAOA;;;;;;EAMA;;EAEA,OAAO;;;;;;;;;EASP;;;;;;;EAOA;;;;;;EAMA;;;;;;;EAOA;;;;;;;;YASU;EAAsB;IAAkB;;;;;YAMxC;;EAEV,UAAU;;EAEV,SAAS;;;;;YAMC;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;;;;EAKA,KAAK,SAAS,+BAA+B,aAAa,iBAAiB;;;YAIjE;;EAEV;;EAEA;;EAEA;;;YAIU;;EAEV;;EAEA,SAAS;;;;;YAMC;;EAEV;;EAEA;;EAEA;;EAEA,YAAY;;;;;;EAMZ,IACE,MAAM,wBACN,SAAS,+BACC,qBAAqB,iBAAiB;;;;;;iBAOnC;;EAEf;;;;;;EAMA;;;;;;EAMA,YAAY;;;;;;;;EAQZ,eAAe;;;;;;;;;EASf;;;;;;;;EAQA,8BAA8B,eAAe;;EAE7C,YAAY;;EAEZ,UAAU;;;;;;iBAOK;;EAEf;;;;;;EAMA,SAAS;;;iBAIM,2BAA2B;;EAE1C;;;;;iBAMe,UAAU,gBAAgB,iBAAiB;;;;;;EAM1D,SAAS,QAAQ;;EAEjB,QAAQ"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ToolContract } from "@warlock.js/ai";
|
|
2
|
-
|
|
3
2
|
//#region ../../packages/ai-tools/src/contracts/mcp.type.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Type contracts for the Model Context Protocol surface — the
|
|
@@ -19,9 +18,12 @@ import { ToolContract } from "@warlock.js/ai";
|
|
|
19
18
|
* `node:readline`; no dependency).
|
|
20
19
|
* - `"http"` — Streamable HTTP transport against `url`.
|
|
21
20
|
*/
|
|
22
|
-
type McpTransport = {
|
|
23
|
-
/** stdio transport — a spawned child process. */
|
|
24
|
-
|
|
21
|
+
export type McpTransport = {
|
|
22
|
+
/** stdio transport — a spawned child process. */
|
|
23
|
+
type: "stdio";
|
|
24
|
+
/** Executable to spawn (e.g. `"npx"`). */
|
|
25
|
+
command: string;
|
|
26
|
+
/** Arguments passed to `command`. */
|
|
25
27
|
args?: string[];
|
|
26
28
|
/**
|
|
27
29
|
* Additional environment for the child. Explicit values override the
|
|
@@ -30,15 +32,18 @@ type McpTransport = {
|
|
|
30
32
|
*/
|
|
31
33
|
env?: Record<string, string>;
|
|
32
34
|
} | {
|
|
33
|
-
/** Streamable HTTP transport. */
|
|
34
|
-
|
|
35
|
+
/** Streamable HTTP transport. */
|
|
36
|
+
type: "http";
|
|
37
|
+
/** The server endpoint URL. */
|
|
38
|
+
url: string;
|
|
39
|
+
/** Static headers sent with every request (e.g. auth). */
|
|
35
40
|
headers?: Record<string, string>;
|
|
36
41
|
};
|
|
37
42
|
/**
|
|
38
43
|
* Options for the `ai.mcp(server, options)` client (Direction A:
|
|
39
44
|
* external server → local agent tools).
|
|
40
45
|
*/
|
|
41
|
-
interface McpClientOptions {
|
|
46
|
+
export interface McpClientOptions {
|
|
42
47
|
/**
|
|
43
48
|
* Prefix prepended to each remote tool name to avoid colliding with
|
|
44
49
|
* local tools, e.g. `"github."`. The author owns uniqueness — there
|
|
@@ -71,7 +76,7 @@ interface McpClientOptions {
|
|
|
71
76
|
/**
|
|
72
77
|
* The client handle returned by `ai.mcp(server, options)`.
|
|
73
78
|
*/
|
|
74
|
-
interface McpClient {
|
|
79
|
+
export interface McpClient {
|
|
75
80
|
/**
|
|
76
81
|
* Lazily run the `initialize` handshake + `tools/list`, mapping each
|
|
77
82
|
* remote tool to a {@link ToolContract}. Cached after the first call.
|
|
@@ -81,13 +86,13 @@ interface McpClient {
|
|
|
81
86
|
close(): Promise<void>;
|
|
82
87
|
}
|
|
83
88
|
/** The JSON-RPC version literal every message carries. */
|
|
84
|
-
type JsonRpcVersion = "2.0";
|
|
89
|
+
export type JsonRpcVersion = "2.0";
|
|
85
90
|
/** A JSON-RPC id — a string or number (we never send notifications with `null`). */
|
|
86
|
-
type JsonRpcId = string | number;
|
|
91
|
+
export type JsonRpcId = string | number;
|
|
87
92
|
/**
|
|
88
93
|
* A JSON-RPC request: a method invocation that expects a response.
|
|
89
94
|
*/
|
|
90
|
-
interface JsonRpcRequest<TParams = unknown> {
|
|
95
|
+
export interface JsonRpcRequest<TParams = unknown> {
|
|
91
96
|
jsonrpc: JsonRpcVersion;
|
|
92
97
|
id: JsonRpcId;
|
|
93
98
|
/** The RPC method name, e.g. `"tools/list"`. */
|
|
@@ -98,7 +103,7 @@ interface JsonRpcRequest<TParams = unknown> {
|
|
|
98
103
|
/**
|
|
99
104
|
* A JSON-RPC notification: a method invocation with no response.
|
|
100
105
|
*/
|
|
101
|
-
interface JsonRpcNotification<TParams = unknown> {
|
|
106
|
+
export interface JsonRpcNotification<TParams = unknown> {
|
|
102
107
|
jsonrpc: JsonRpcVersion;
|
|
103
108
|
/** The RPC method name. */
|
|
104
109
|
method: string;
|
|
@@ -108,7 +113,7 @@ interface JsonRpcNotification<TParams = unknown> {
|
|
|
108
113
|
/**
|
|
109
114
|
* A JSON-RPC error object, carried in an error response.
|
|
110
115
|
*/
|
|
111
|
-
interface JsonRpcError {
|
|
116
|
+
export interface JsonRpcError {
|
|
112
117
|
/** Numeric error code per the JSON-RPC spec. */
|
|
113
118
|
code: number;
|
|
114
119
|
/** Human-readable error message. */
|
|
@@ -119,7 +124,7 @@ interface JsonRpcError {
|
|
|
119
124
|
/**
|
|
120
125
|
* A JSON-RPC response — exactly one of `result` / `error` is present.
|
|
121
126
|
*/
|
|
122
|
-
interface JsonRpcResponse<TResult = unknown> {
|
|
127
|
+
export interface JsonRpcResponse<TResult = unknown> {
|
|
123
128
|
jsonrpc: JsonRpcVersion;
|
|
124
129
|
id: JsonRpcId;
|
|
125
130
|
/** Present on success. */
|
|
@@ -130,19 +135,21 @@ interface JsonRpcResponse<TResult = unknown> {
|
|
|
130
135
|
/**
|
|
131
136
|
* Any inbound JSON-RPC message the transport may surface.
|
|
132
137
|
*/
|
|
133
|
-
type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcResponse;
|
|
138
|
+
export type JsonRpcMessage = JsonRpcRequest | JsonRpcNotification | JsonRpcResponse;
|
|
134
139
|
/**
|
|
135
140
|
* One tool descriptor as returned by an MCP server's `tools/list`. Its
|
|
136
141
|
* `inputSchema` is a JSON Schema object the client converts into a
|
|
137
142
|
* Standard Schema for the adapted {@link ToolContract}.
|
|
138
143
|
*/
|
|
139
|
-
interface McpToolDescriptor {
|
|
144
|
+
export interface McpToolDescriptor {
|
|
140
145
|
/** The remote tool's name (before any `namePrefix`). */
|
|
141
146
|
name: string;
|
|
142
147
|
/** Human-readable description forwarded to the LLM. */
|
|
143
148
|
description?: string;
|
|
144
149
|
/** JSON Schema for the tool's arguments. */
|
|
145
150
|
inputSchema?: Record<string, unknown>;
|
|
151
|
+
/** JSON Schema for structured results, when declared by the server. */
|
|
152
|
+
outputSchema?: Record<string, unknown>;
|
|
146
153
|
}
|
|
147
154
|
/**
|
|
148
155
|
* One content block in an MCP `tools/call` result. MCP's wire field is
|
|
@@ -150,7 +157,7 @@ interface McpToolDescriptor {
|
|
|
150
157
|
* `kind` for a content variant, the client maps it onto `type` so our
|
|
151
158
|
* shapes only ever expose `type`.
|
|
152
159
|
*/
|
|
153
|
-
interface McpContentBlock {
|
|
160
|
+
export interface McpContentBlock {
|
|
154
161
|
/** The content variant (`"text"`, `"image"`, `"resource"`, …). */
|
|
155
162
|
type: string;
|
|
156
163
|
/** Text payload, present for `type: "text"`. */
|
|
@@ -163,12 +170,15 @@ interface McpContentBlock {
|
|
|
163
170
|
* tool-level failure the client rethrows so `tool()` wraps it as a
|
|
164
171
|
* {@link import("@warlock.js/ai").ToolExecutionError}.
|
|
165
172
|
*/
|
|
166
|
-
interface McpToolCallResult {
|
|
173
|
+
export interface McpToolCallResult {
|
|
167
174
|
/** Ordered content blocks produced by the tool. */
|
|
168
175
|
content: McpContentBlock[];
|
|
169
176
|
/** True when the call represents a tool-level error. */
|
|
170
177
|
isError?: boolean;
|
|
178
|
+
/** Structured tool output (governed by the tool's outputSchema, if present). */
|
|
179
|
+
structuredContent?: Record<string, unknown>;
|
|
180
|
+
/** Protocol metadata forwarded without interpretation. */
|
|
181
|
+
_meta?: Record<string, unknown>;
|
|
171
182
|
}
|
|
172
183
|
//#endregion
|
|
173
|
-
export { JsonRpcError, JsonRpcId, JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, JsonRpcVersion, McpClient, McpClientOptions, McpContentBlock, McpToolCallResult, McpToolDescriptor, McpTransport };
|
|
174
184
|
//# sourceMappingURL=mcp.type.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-tools/src/contracts/mcp.type.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-tools/src/contracts/mcp.type.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;YAqBY;;EAGN;;EAEA;;EAEA;;;;;;EAMA,MAAM;;;EAIN;;EAEA;;EAEA,UAAU;;;;;;iBAOC;;;;;;EAMf;;EAEA,UAAU;;;;;;EAMV;;;;;;;;;;;;;;EAcA,SAAS;;;;;iBAMM;;;;;EAKf,SAAS,QAAQ;;EAEjB,SAAS;;;YAYC;;YAGA;;;;iBAKK,eAAe;EAC9B,SAAS;EACT,IAAI;;EAEJ;;EAEA,SAAS;;;;;iBAMM,oBAAoB;EACnC,SAAS;;EAET;;EAEA,SAAS;;;;;iBAMM;;EAEf;;EAEA;;EAEA;;;;;iBAMe,gBAAgB;EAC/B,SAAS;EACT,IAAI;;EAEJ,SAAS;;EAET,QAAQ;;;;;YAME,iBAAiB,iBAAiB,sBAAsB;;;;;;iBAOnD;;EAEf;;EAEA;;EAEA,cAAc;;EAEd,eAAe;;;;;;;;iBASA;;EAEf;;EAEA;;GAEC;;;;;;;iBAQc;;EAEf,SAAS;;EAET;;EAEA,oBAAoB;;EAEpB,QAAQ"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
/**
|
|
8
8
|
* Construction options for `ai.tools.calculator`.
|
|
9
9
|
*/
|
|
10
|
-
interface CalculatorOptions {
|
|
10
|
+
export interface CalculatorOptions {
|
|
11
11
|
/**
|
|
12
12
|
* Override the tool name exposed to the LLM.
|
|
13
13
|
*
|
|
@@ -18,14 +18,14 @@ interface CalculatorOptions {
|
|
|
18
18
|
/**
|
|
19
19
|
* The validated input shape the model passes to `calculator`.
|
|
20
20
|
*/
|
|
21
|
-
interface CalculatorInput {
|
|
21
|
+
export interface CalculatorInput {
|
|
22
22
|
/** An arithmetic expression to evaluate, e.g. `"(3 + 4) * 2"`. */
|
|
23
23
|
expression: string;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* The `calculator` tool's output.
|
|
27
27
|
*/
|
|
28
|
-
interface CalculatorResult {
|
|
28
|
+
export interface CalculatorResult {
|
|
29
29
|
/** The numeric result of evaluating the expression. */
|
|
30
30
|
result: number;
|
|
31
31
|
}
|
|
@@ -37,11 +37,11 @@ interface CalculatorResult {
|
|
|
37
37
|
* - `"diff"` — difference between two instants, in `unit`.
|
|
38
38
|
* - `"format"` — render `iso` per `format`.
|
|
39
39
|
*/
|
|
40
|
-
type DateTimeOp = "now" | "add" | "diff" | "format";
|
|
40
|
+
export type DateTimeOp = "now" | "add" | "diff" | "format";
|
|
41
41
|
/**
|
|
42
42
|
* Construction options for `ai.tools.dateTime`.
|
|
43
43
|
*/
|
|
44
|
-
interface DateTimeOptions {
|
|
44
|
+
export interface DateTimeOptions {
|
|
45
45
|
/**
|
|
46
46
|
* Override the tool name exposed to the LLM.
|
|
47
47
|
*
|
|
@@ -59,7 +59,7 @@ interface DateTimeOptions {
|
|
|
59
59
|
* The validated input shape the model passes to `date_time`. Which
|
|
60
60
|
* fields are required depends on `op` (validated at the seal layer).
|
|
61
61
|
*/
|
|
62
|
-
interface DateTimeInput {
|
|
62
|
+
export interface DateTimeInput {
|
|
63
63
|
/** Which date-time operation to perform. */
|
|
64
64
|
op: DateTimeOp;
|
|
65
65
|
/** ISO-8601 instant the operation acts on (`add` / `diff` / `format`). */
|
|
@@ -84,7 +84,7 @@ interface DateTimeInput {
|
|
|
84
84
|
/**
|
|
85
85
|
* The `date_time` tool's output.
|
|
86
86
|
*/
|
|
87
|
-
interface DateTimeResult {
|
|
87
|
+
export interface DateTimeResult {
|
|
88
88
|
/**
|
|
89
89
|
* The result, rendered as a string — an ISO instant, a formatted
|
|
90
90
|
* date, or a stringified numeric difference depending on `op`.
|
|
@@ -92,5 +92,4 @@ interface DateTimeResult {
|
|
|
92
92
|
value: string;
|
|
93
93
|
}
|
|
94
94
|
//#endregion
|
|
95
|
-
export { CalculatorInput, CalculatorOptions, CalculatorResult, DateTimeInput, DateTimeOp, DateTimeOptions, DateTimeResult };
|
|
96
95
|
//# sourceMappingURL=utility.type.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utility.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-tools/src/contracts/utility.type.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"utility.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-tools/src/contracts/utility.type.ts"],"mappings":";;;;;;;;;iBASiB;;;;;;EAMf;;;;;iBAMe;;EAEf;;;;;iBAMe;;EAEf;;;;;;;;;;YAWU;;;;iBAKK;;;;;;EAMf;;;;;;EAMA;;;;;;iBAOe;;EAEf,IAAI;;EAEJ;;;;;;EAMA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;iBAMe;;;;;EAKf"}
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Uses `type` as the discriminator everywhere downstream — never `kind`.
|
|
13
13
|
*/
|
|
14
|
-
type SearchProvider = "tavily" | "brave" | "serpapi";
|
|
14
|
+
export type SearchProvider = "tavily" | "brave" | "serpapi";
|
|
15
15
|
/**
|
|
16
16
|
* Construction options for {@link SearchProvider}-backed web search.
|
|
17
17
|
*/
|
|
18
|
-
interface WebSearchOptions {
|
|
18
|
+
export interface WebSearchOptions {
|
|
19
19
|
/** Which optional search backend to use. Its SDK/HTTP key is a lazy peer. */
|
|
20
20
|
provider: SearchProvider;
|
|
21
21
|
/**
|
|
@@ -40,7 +40,7 @@ interface WebSearchOptions {
|
|
|
40
40
|
/**
|
|
41
41
|
* The validated input shape the model passes to the web-search tool.
|
|
42
42
|
*/
|
|
43
|
-
interface WebSearchInput {
|
|
43
|
+
export interface WebSearchInput {
|
|
44
44
|
/** The search query. */
|
|
45
45
|
query: string;
|
|
46
46
|
/** Per-call cap on results, clamped into `[1, options.maxResults]`. */
|
|
@@ -50,7 +50,7 @@ interface WebSearchInput {
|
|
|
50
50
|
* A single web-search hit. `score` is provider-supplied relevance when
|
|
51
51
|
* the backend returns one (Tavily does; some others do not).
|
|
52
52
|
*/
|
|
53
|
-
interface WebSearchResultItem {
|
|
53
|
+
export interface WebSearchResultItem {
|
|
54
54
|
/** Page / document title. */
|
|
55
55
|
title: string;
|
|
56
56
|
/** Canonical URL of the result. */
|
|
@@ -63,7 +63,7 @@ interface WebSearchResultItem {
|
|
|
63
63
|
/**
|
|
64
64
|
* The web-search tool's output — the ranked list of hits.
|
|
65
65
|
*/
|
|
66
|
-
interface WebSearchResult {
|
|
66
|
+
export interface WebSearchResult {
|
|
67
67
|
/** Ranked results, best-first. */
|
|
68
68
|
results: WebSearchResultItem[];
|
|
69
69
|
}
|
|
@@ -76,11 +76,11 @@ interface WebSearchResult {
|
|
|
76
76
|
* - `"html"` — the raw response body, untouched.
|
|
77
77
|
* - `"markdown"` — readability extraction converted to Markdown.
|
|
78
78
|
*/
|
|
79
|
-
type FetchUrlExtract = "text" | "html" | "markdown";
|
|
79
|
+
export type FetchUrlExtract = "text" | "html" | "markdown";
|
|
80
80
|
/**
|
|
81
81
|
* Construction options for `ai.tools.fetchUrl`.
|
|
82
82
|
*/
|
|
83
|
-
interface FetchUrlOptions {
|
|
83
|
+
export interface FetchUrlOptions {
|
|
84
84
|
/**
|
|
85
85
|
* Override the tool name exposed to the LLM.
|
|
86
86
|
*
|
|
@@ -126,14 +126,14 @@ interface FetchUrlOptions {
|
|
|
126
126
|
/**
|
|
127
127
|
* The validated input shape the model passes to `fetch_url`.
|
|
128
128
|
*/
|
|
129
|
-
interface FetchUrlInput {
|
|
129
|
+
export interface FetchUrlInput {
|
|
130
130
|
/** The absolute URL to fetch. */
|
|
131
131
|
url: string;
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
134
|
* The `fetch_url` tool's output.
|
|
135
135
|
*/
|
|
136
|
-
interface FetchUrlResult {
|
|
136
|
+
export interface FetchUrlResult {
|
|
137
137
|
/** The URL that was fetched (after any redirects the platform followed). */
|
|
138
138
|
url: string;
|
|
139
139
|
/** HTTP status code of the final response. */
|
|
@@ -144,5 +144,4 @@ interface FetchUrlResult {
|
|
|
144
144
|
truncated: boolean;
|
|
145
145
|
}
|
|
146
146
|
//#endregion
|
|
147
|
-
export { FetchUrlExtract, FetchUrlInput, FetchUrlOptions, FetchUrlResult, SearchProvider, WebSearchInput, WebSearchOptions, WebSearchResult, WebSearchResultItem };
|
|
148
147
|
//# sourceMappingURL=web.type.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-tools/src/contracts/web.type.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"web.type.d.mts","names":[],"sources":["../../../../../../../../packages/ai-tools/src/contracts/web.type.ts"],"mappings":";;;;;;;;;;;;;YAaY;;;;iBAKK;;EAEf,UAAU;;;;;EAKV;;;;;;;EAOA;;;;;;EAMA;;;;;iBAMe;;EAEf;;EAEA;;;;;;iBAOe;;EAEf;;EAEA;;EAEA;;EAEA;;;;;iBAMe;;EAEf,SAAS;;;;;;;;;;;YAYC;;;;iBAKK;;;;;;EAMf;;;;;;EAMA;;;;;;EAMA;;;;;;EAMA,UAAU;;;;;;EAMV;;;;;;;;;;;EAWA;;;;;iBAMe;;EAEf;;;;;iBAMe;;EAEf;;EAEA;;EAEA;;EAEA"}
|