stitchkit 0.1.0 → 0.3.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/README.md +10 -7
- package/dist/browser/http.d.ts +5 -0
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/errors.d.ts +4 -3
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/index.js +1 -1
- package/dist/{index-gfzn1n4n.js → index-0t460v7k.js} +13 -5
- package/dist/{index-n7bmdwmz.js → index-4b1j82gp.js} +8 -4
- package/dist/{index-5sxnvwb1.js → index-4kz3aqpx.js} +2 -2
- package/dist/index-dpj1jcys.js +677 -0
- package/dist/{index-7wfkbvss.js → index-kckky6zw.js} +6 -2
- package/dist/index-kzfs85xp.js +9 -0
- package/dist/index-mwmpw6j1.js +60 -0
- package/dist/index-q6ja2qwq.js +7 -0
- package/dist/index.js +4 -3
- package/dist/internal/errors.d.ts +13 -1
- package/dist/internal/errors.d.ts.map +1 -1
- package/dist/internal/safe-json.d.ts +19 -0
- package/dist/internal/safe-json.d.ts.map +1 -0
- package/dist/internal/within-dir.d.ts +7 -0
- package/dist/internal/within-dir.d.ts.map +1 -0
- package/dist/node.d.ts +4 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +29 -0
- package/dist/observability/context.d.ts +9 -1
- package/dist/observability/context.d.ts.map +1 -1
- package/dist/observability/index.js +35 -15
- package/dist/observability/sanitize.d.ts.map +1 -1
- package/dist/server/context.d.ts +3 -2
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/create.d.ts +3 -3
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/event-bus.d.ts +10 -1
- package/dist/server/event-bus.d.ts.map +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +94 -606
- package/dist/server/logger.d.ts +5 -4
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/middleware/auth.d.ts +24 -1
- package/dist/server/middleware/auth.d.ts.map +1 -1
- package/dist/server/middleware/cookies.d.ts.map +1 -1
- package/dist/server/middleware/cors.d.ts +7 -0
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/multipart.d.ts +2 -1
- package/dist/server/multipart.d.ts.map +1 -1
- package/dist/server/node.d.ts +12 -0
- package/dist/server/node.d.ts.map +1 -0
- package/dist/server/rate-limit.d.ts +7 -2
- package/dist/server/rate-limit.d.ts.map +1 -1
- package/dist/server/request.d.ts +27 -4
- package/dist/server/request.d.ts.map +1 -1
- package/dist/server/router.d.ts +4 -2
- package/dist/server/router.d.ts.map +1 -1
- package/dist/server/stream.d.ts +3 -1
- package/dist/server/stream.d.ts.map +1 -1
- package/dist/server/types.d.ts +35 -20
- package/dist/server/types.d.ts.map +1 -1
- package/dist/tools/agent.d.ts +15 -2
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/coerce.d.ts +12 -0
- package/dist/tools/coerce.d.ts.map +1 -0
- package/dist/tools/execute.d.ts +26 -2
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/flatten.d.ts +15 -0
- package/dist/tools/flatten.d.ts.map +1 -0
- package/dist/tools/json-schema.d.ts +18 -0
- package/dist/tools/json-schema.d.ts.map +1 -0
- package/dist/tools/manifest.d.ts +17 -0
- package/dist/tools/manifest.d.ts.map +1 -0
- package/dist/tools/mcp-handler.d.ts.map +1 -1
- package/dist/tools/mcp.d.ts +53 -3
- package/dist/tools/mcp.d.ts.map +1 -1
- package/dist/tools/mount.d.ts +18 -6
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/schema.d.ts +19 -2
- package/dist/tools/schema.d.ts.map +1 -1
- package/dist/tools/view-file.d.ts.map +1 -1
- package/dist/tools.d.ts +6 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +415 -185
- package/package.json +15 -4
- package/dist/index-ke4mx4ea.js +0 -38
package/dist/tools/mcp.d.ts
CHANGED
|
@@ -1,12 +1,48 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import type { ServiceDef } from '../server/types';
|
|
3
|
-
import type
|
|
2
|
+
import type { ServiceDef, StitchLogger } from '../server/types';
|
|
3
|
+
import { type ToolCallHooks, type ToolLifecycle } from './execute';
|
|
4
4
|
import { type ToolExtend } from './mount';
|
|
5
|
+
/**
|
|
6
|
+
* What to do when a tool's schema cannot be advertised on the MCP surface — a
|
|
7
|
+
* union / discriminated-union input (MCP needs an object), or a construct
|
|
8
|
+
* JSON Schema cannot represent (`z.date()`, `z.map()`, …):
|
|
9
|
+
* - `throw` (default) — fail the build loudly, listing every bad tool. Better
|
|
10
|
+
* a failed deploy than a tool that silently vanishes from the MCP surface.
|
|
11
|
+
* - `warn` — log and drop the tool.
|
|
12
|
+
* - `skip` — drop the tool silently.
|
|
13
|
+
*/
|
|
14
|
+
export type IncompatibleSchemaPolicy = 'throw' | 'skip' | 'warn';
|
|
5
15
|
export interface McpMountConfig {
|
|
6
16
|
context?: Record<string, unknown>;
|
|
17
|
+
/** Tool-call observability hooks. */
|
|
7
18
|
hooks?: ToolCallHooks;
|
|
19
|
+
/**
|
|
20
|
+
* Auth / scope gate and result transform for every tool call — the tool-side
|
|
21
|
+
* twin of `createServer`'s `beforeHandle` / `afterHandle`. Pass the same
|
|
22
|
+
* `createAuthHook` result here as on the HTTP server to guard tools too;
|
|
23
|
+
* without it a tool call bypasses the HTTP `beforeHandle` auth gate.
|
|
24
|
+
*/
|
|
25
|
+
lifecycle?: ToolLifecycle;
|
|
8
26
|
extend?: ToolExtend;
|
|
27
|
+
/** What to do when a tool's schema is not MCP-compatible. Default `'throw'`. */
|
|
28
|
+
onIncompatibleSchema?: IncompatibleSchemaPolicy;
|
|
29
|
+
/** Logger for the `'warn'` policy — defaults to `console`. */
|
|
30
|
+
logger?: StitchLogger;
|
|
31
|
+
/** Coerce JSON-stringified arrays/objects in tool arguments. Default: true. */
|
|
32
|
+
coerceJsonArgs?: boolean;
|
|
33
|
+
/** Flatten discriminated union inputs into a single object. Default: false. */
|
|
34
|
+
flattenUnionInput?: boolean;
|
|
35
|
+
/** Global error hint injected into every failed tool result. */
|
|
36
|
+
errorHint?: (toolName: string, errorCode: string) => string | null;
|
|
9
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Validate that every contract tool in `services` can be advertised on the MCP
|
|
40
|
+
* surface — object-shaped, JSON Schema-compatible input / output, no tool-name
|
|
41
|
+
* collision across services. The build-time check behind `mountMcp` — also
|
|
42
|
+
* callable on its own (a startup assertion, a test) to fail a deploy before
|
|
43
|
+
* the first request.
|
|
44
|
+
*/
|
|
45
|
+
export declare function validateMcpSchemas(services: ServiceDef[], onIncompatibleSchema?: IncompatibleSchemaPolicy, logger?: StitchLogger): void;
|
|
10
46
|
export declare function mountMcp(mcpServer: McpServer, services: ServiceDef | ServiceDef[], config?: McpMountConfig): void;
|
|
11
47
|
/**
|
|
12
48
|
* Transport-neutral build config for an MCP server — everything needed to turn
|
|
@@ -24,15 +60,29 @@ export interface McpServerBuildConfig<TAuth> {
|
|
|
24
60
|
services: ServiceDef[] | ((auth: TAuth) => ServiceDef[]);
|
|
25
61
|
/** Context merged into every contract handler (`mountMcp` context). */
|
|
26
62
|
context?: (auth: TAuth) => Record<string, unknown>;
|
|
27
|
-
/** Tool-call
|
|
63
|
+
/** Tool-call observability hooks — `afterToolCall` fires for every result
|
|
28
64
|
* (success and error), so the consuming app can log MCP tool outcomes. */
|
|
29
65
|
hooks?: ToolCallHooks;
|
|
66
|
+
/** Auth / scope gate and result transform for every tool call — pass the
|
|
67
|
+
* same `createAuthHook` result used for the HTTP `beforeHandle` to guard
|
|
68
|
+
* tools with the identical rules. */
|
|
69
|
+
lifecycle?: ToolLifecycle;
|
|
70
|
+
/** What to do when a tool's schema is not MCP-compatible. Default `'throw'`. */
|
|
71
|
+
onIncompatibleSchema?: IncompatibleSchemaPolicy;
|
|
72
|
+
/** Logger for schema-incompatibility warnings — defaults to `console`. */
|
|
73
|
+
logger?: StitchLogger;
|
|
30
74
|
/** Register native (non-contract) MCP tools — receives the `McpServer`
|
|
31
75
|
* directly. For tools returning multimodal content, e.g. `mountViewFile`. */
|
|
32
76
|
nativeTools?: (server: McpServer) => void;
|
|
33
77
|
/** Server instructions — a short (≤2KB) hint to the host on when and how to
|
|
34
78
|
* use these tools. Surfaced to MCP tool-search. */
|
|
35
79
|
instructions?: string;
|
|
80
|
+
/** Coerce JSON-stringified arrays/objects in tool arguments. Default: true. */
|
|
81
|
+
coerceJsonArgs?: boolean;
|
|
82
|
+
/** Flatten discriminated union inputs into a single object. Default: false. */
|
|
83
|
+
flattenUnionInput?: boolean;
|
|
84
|
+
/** Global error hint injected into every failed tool result. */
|
|
85
|
+
errorHint?: (toolName: string, errorCode: string) => string | null;
|
|
36
86
|
}
|
|
37
87
|
/**
|
|
38
88
|
* Build an `McpServer` from contract services for a resolved identity.
|
package/dist/tools/mcp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/tools/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/tools/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAGnB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;GAQG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AA8JjE,MAAM,WAAW,cAAc;IAC7B,OAAO,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AE,aAAa,CAAC;IACtB;;0CAEsC;IACtC,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,gFAAgF;IAChF,oBAAoB,CAAC,EAAE,wBAAwB,CAAC;IAChD,0EAA0E;IAC1E,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;kFAC8E;IAC9E,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC;IAC1C;wDACoD;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,+EAA+E;IAC/E,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gEAAgE;IAChE,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;CACpE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAClC,MAAM,EAAE,oBAAoB,CAAC,KAAK,CAAC,EACnC,IAAI,EAAE,KAAK,GACV,SAAS,CAoBX"}
|
package/dist/tools/mount.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import type { Transport, TransportSource } from '../contract';
|
|
8
8
|
import type { MethodDef, ServiceDef } from '../server/types';
|
|
9
|
-
import { type ToolCallHooks, type ToolResult } from './execute';
|
|
9
|
+
import { type ToolCallHooks, type ToolLifecycle, type ToolResult } from './execute';
|
|
10
10
|
/**
|
|
11
11
|
* Extra arguments folded into a mounted tool's schema — the host supplies them,
|
|
12
12
|
* `resolve` turns them into handler context. Shared by `mountMcp` / `mountAgent`.
|
|
@@ -26,15 +26,20 @@ export interface MountableTool {
|
|
|
26
26
|
/** Tool name — the `toolName` override, else derived from service + method. */
|
|
27
27
|
name: string;
|
|
28
28
|
/** Merged params + input schema, with the extend fields folded in when they apply. */
|
|
29
|
-
schema: z.
|
|
29
|
+
schema: z.ZodType;
|
|
30
30
|
/** Whether `ToolExtend` applies to this method. */
|
|
31
31
|
shouldExtend: boolean;
|
|
32
32
|
}
|
|
33
|
+
export interface CollectToolsConfig {
|
|
34
|
+
extend?: ToolExtend;
|
|
35
|
+
/** Flatten discriminated union inputs into a single object for MCP. Default: false. */
|
|
36
|
+
flattenUnionInput?: boolean;
|
|
37
|
+
}
|
|
33
38
|
/**
|
|
34
39
|
* Walk a service's methods and resolve each one exposed on `transport` to a
|
|
35
40
|
* tool name and schema — the shared front half of `mountMcp` / `mountAgent`.
|
|
36
41
|
*/
|
|
37
|
-
export declare function collectTools(service: ServiceDef, transport: Transport,
|
|
42
|
+
export declare function collectTools(service: ServiceDef, transport: Transport, config?: CollectToolsConfig): MountableTool[];
|
|
38
43
|
/** Per-mount config a tool runner closes over. */
|
|
39
44
|
export interface ToolRunnerConfig {
|
|
40
45
|
/** Transport tag put on every call's context. */
|
|
@@ -43,8 +48,14 @@ export interface ToolRunnerConfig {
|
|
|
43
48
|
extend?: ToolExtend;
|
|
44
49
|
/** Static context merged into every handler. */
|
|
45
50
|
context?: Record<string, unknown>;
|
|
46
|
-
/** Tool-call
|
|
51
|
+
/** Tool-call observability hooks. */
|
|
47
52
|
hooks?: ToolCallHooks;
|
|
53
|
+
/** Auth / scope gate and result transform — runs for every tool call. */
|
|
54
|
+
lifecycle?: ToolLifecycle;
|
|
55
|
+
/** Global error hint injected into every failed tool result. */
|
|
56
|
+
errorHint?: (toolName: string, errorCode: string) => string | null;
|
|
57
|
+
/** Coerce JSON-stringified arrays/objects in tool arguments. Default: true. */
|
|
58
|
+
coerceJsonArgs?: boolean;
|
|
48
59
|
}
|
|
49
60
|
/**
|
|
50
61
|
* Build the call executor for a mount — resolve the extend context, strip the
|
|
@@ -53,9 +64,10 @@ export interface ToolRunnerConfig {
|
|
|
53
64
|
export declare function createToolRunner(config: ToolRunnerConfig): (tool: MountableTool, rawArgs: Record<string, unknown>) => Promise<ToolResult>;
|
|
54
65
|
/**
|
|
55
66
|
* Shape a failed `ToolResult` into the `{ error, details?, _hint? }` object
|
|
56
|
-
* both transports return on error.
|
|
67
|
+
* both transports return on error. When a global `errorHint` is provided, it
|
|
68
|
+
* is appended after the per-error `AppError.hint` (if any).
|
|
57
69
|
*/
|
|
58
70
|
export declare function formatToolError(result: Extract<ToolResult, {
|
|
59
71
|
ok: false;
|
|
60
|
-
}
|
|
72
|
+
}>, toolName?: string, errorHint?: (toolName: string, errorCode: string) => string | null): Record<string, unknown>;
|
|
61
73
|
//# sourceMappingURL=mount.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/tools/mount.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/tools/mount.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,UAAU,EAChB,MAAM,WAAW,CAAC;AAKnB;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;IAClC,qEAAqE;IACrE,OAAO,EAAE,CACP,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1B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,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,gBAAgB,GACvB,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAsBhF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,OAAO,CAAC,UAAU,EAAE;IAAE,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC,EAC1C,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GACjE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazB"}
|
package/dist/tools/schema.d.ts
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
2
|
+
/** Keys of a Zod object schema's shape — `[]` for a non-object or absent schema. */
|
|
3
|
+
export declare function objectShapeKeys(schema?: z.ZodType): string[];
|
|
4
|
+
/**
|
|
5
|
+
* Merge an endpoint's `params` and `input` schemas into the single schema a
|
|
6
|
+
* tool advertises.
|
|
7
|
+
*
|
|
8
|
+
* - Both object → one merged `z.object`. A key declared in both is a contract
|
|
9
|
+
* bug and throws.
|
|
10
|
+
* - A non-object `input` (a union, a discriminated union, a refined / piped
|
|
11
|
+
* schema) is kept intact and intersected with `params` when present — the
|
|
12
|
+
* transport SDK converts it natively (a discriminated union becomes a clean
|
|
13
|
+
* `oneOf`).
|
|
14
|
+
*
|
|
15
|
+
* The merged schema is exactly the two source schemas side by side: nothing is
|
|
16
|
+
* coerced, flattened or transformed, so the schema a tool advertises is the
|
|
17
|
+
* schema its arguments are validated against (`executeToolMethod` parses each
|
|
18
|
+
* source schema over its own slice of the args).
|
|
19
|
+
*/
|
|
20
|
+
export declare function mergeSchemas(paramsSchema?: z.ZodType<unknown>, inputSchema?: z.ZodType<unknown>): z.ZodType;
|
|
4
21
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/tools/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/tools/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,GAAG,MAAM,EAAE,CAE5D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAC1B,YAAY,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EACjC,WAAW,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAC/B,CAAC,CAAC,OAAO,CA2BX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-file.d.ts","sourceRoot":"","sources":["../../src/tools/view-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"view-file.d.ts","sourceRoot":"","sources":["../../src/tools/view-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA6BzE,6EAA6E;AAC7E,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AA0JD;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,eAAe,EAAE,CAAC,CA+B5B;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,GAAE,eAAoB,GAAG,IAAI,CA4BpF"}
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export { type AgentContext, type AgentMountConfig, mountAgent } from './tools/agent';
|
|
2
|
-
export {
|
|
2
|
+
export { coerceJsonArgs } from './tools/coerce';
|
|
3
|
+
export type { ToolCallHooks, ToolLifecycle, ToolResult } from './tools/execute';
|
|
4
|
+
export { flattenDiscriminatedUnion } from './tools/flatten';
|
|
5
|
+
export { buildToolManifest, type ToolManifestEntry } from './tools/manifest';
|
|
6
|
+
export { buildMcpServer, type IncompatibleSchemaPolicy, type McpMountConfig, type McpServerBuildConfig, mountMcp, validateMcpSchemas, } from './tools/mcp';
|
|
3
7
|
export { createMcpHandler, type McpHandlerConfig } from './tools/mcp-handler';
|
|
4
8
|
export { createStdioMcpServer, type StdioMcpServerConfig } from './tools/mcp-stdio';
|
|
5
|
-
export type
|
|
9
|
+
export { collectTools, type MountableTool, type ToolExtend } from './tools/mount';
|
|
6
10
|
export { type ImplementRemoteOptions, implementRemote } from './tools/remote';
|
|
7
11
|
export { type McpMediaContent, mountViewFile, resolveMedia } from './tools/view-file';
|
|
8
12
|
//# sourceMappingURL=tools.d.ts.map
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EACL,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,QAAQ,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EACL,cAAc,EACd,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,QAAQ,EACR,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,KAAK,sBAAsB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,KAAK,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|