stitchkit 0.17.0 → 0.19.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/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/http.d.ts +9 -0
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/socket-io.d.ts.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/contract/errors-factory.d.ts +18 -0
- package/dist/contract/errors-factory.d.ts.map +1 -0
- package/dist/contract/factory.d.ts +36 -0
- package/dist/contract/factory.d.ts.map +1 -0
- package/dist/contract/index.d.ts +2 -0
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/contract/index.js +6 -1
- package/dist/contract/pagination.d.ts.map +1 -1
- package/dist/index-809wc1tt.js +18 -0
- package/dist/{index-tm7dqzxc.js → index-c7nyw0yt.js} +9 -9
- package/dist/{index-fwqnkc90.js → index-dzx781tm.js} +5 -41
- package/dist/index-khwedj16.js +40 -0
- package/dist/{index-ktn76xz0.js → index-ng2v2ts4.js} +17 -1
- package/dist/index-tje0q6gp.js +44 -0
- package/dist/{index-6k6y7wat.js → index-wpbn133x.js} +13 -50
- package/dist/{index-yzac2zbh.js → index-x62gnfsk.js} +50 -9
- package/dist/{index-akv8rk4w.js → index-xmncnw8z.js} +2 -2
- package/dist/{index-yv93m4yr.js → index-ynnh9x6h.js} +11 -29
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +141 -73
- package/dist/internal/base64url.d.ts +16 -0
- package/dist/internal/base64url.d.ts.map +1 -0
- package/dist/node.js +6 -4
- package/dist/observability/index.js +9 -7
- package/dist/react/entity-cache.d.ts +54 -0
- package/dist/react/entity-cache.d.ts.map +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +74 -0
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +56 -0
- package/dist/server/error-hook.d.ts.map +1 -0
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +33 -7
- package/dist/server/middleware/auth.d.ts.map +1 -1
- package/dist/server/middleware/cors.d.ts +13 -0
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/middleware/pkce.d.ts +0 -6
- package/dist/server/middleware/pkce.d.ts.map +1 -1
- package/dist/server/router.d.ts +0 -2
- package/dist/server/router.d.ts.map +1 -1
- package/dist/server/types.d.ts +0 -8
- package/dist/server/types.d.ts.map +1 -1
- package/dist/tools/agent.d.ts +2 -2
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/cli-format.d.ts +2 -2
- package/dist/tools/cli-format.d.ts.map +1 -1
- package/dist/tools/cli.d.ts +2 -2
- package/dist/tools/cli.d.ts.map +1 -1
- package/dist/tools/execute.d.ts +7 -0
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +33 -0
- package/dist/tools/list-names.d.ts.map +1 -0
- package/dist/tools/mcp.d.ts +3 -3
- package/dist/tools/mcp.d.ts.map +1 -1
- package/dist/tools/mount.d.ts +3 -3
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/oauth-metadata.d.ts.map +1 -1
- package/dist/tools/oauth-provider.d.ts.map +1 -1
- package/dist/tools/tool-logger.d.ts +31 -0
- package/dist/tools/tool-logger.d.ts.map +1 -0
- package/dist/tools/transports.d.ts +28 -0
- package/dist/tools/transports.d.ts.map +1 -0
- package/dist/tools.d.ts +4 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +114 -25
- package/llms-full.txt +307 -7
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-metadata.d.ts","sourceRoot":"","sources":["../../src/tools/oauth-metadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"oauth-metadata.d.ts","sourceRoot":"","sources":["../../src/tools/oauth-metadata.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,uEAAuE;IACvE,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,iFAAiF;AACjF,eAAO,MAAM,uBAAuB,0CAA0C,CAAC;AAa/E,4EAA4E;AAC5E,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAErE;AAED,wFAAwF;AACxF,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE9D;AASD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,uBAAuB,GAAG,QAAQ,CAqBrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-provider.d.ts","sourceRoot":"","sources":["../../src/tools/oauth-provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"oauth-provider.d.ts","sourceRoot":"","sources":["../../src/tools/oauth-provider.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAIhD,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,gFAAgF;AAChF,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,iFAAiF;AACjF,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,E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AC,CAAC;QACtD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;KAClD,CAAC;IACF,uEAAuE;IACvE,aAAa,CAAC,EAAE;QACd,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACtD,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;KAClD,CAAC;IAEF;;;;OAIG;IACH,aAAa,CACX,GAAG,EAAE,OAAO,EACZ,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,QAAQ,CAAC,CAAC;CAC3C;AAoED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,QAAQ,EAAE,CAkR1E"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ToolCallHooks } from './execute';
|
|
2
|
+
/** The structured record behind each logged line — for metrics via `onRecord`. */
|
|
3
|
+
export interface ToolCallRecord {
|
|
4
|
+
/** The mounted tool name. */
|
|
5
|
+
tool: string;
|
|
6
|
+
/** Owning service (`endpoint.serviceName`). */
|
|
7
|
+
service: string;
|
|
8
|
+
/** Endpoint key / action (`endpoint.key`). */
|
|
9
|
+
action: string;
|
|
10
|
+
/** Whether the call succeeded. */
|
|
11
|
+
ok: boolean;
|
|
12
|
+
/** The error code, when the call failed. */
|
|
13
|
+
code?: string;
|
|
14
|
+
/** Wall-clock duration, milliseconds (rounded). */
|
|
15
|
+
durationMs: number;
|
|
16
|
+
/** Transport tag the call came in on (`ctx.source`). */
|
|
17
|
+
source: string;
|
|
18
|
+
}
|
|
19
|
+
/** Config for `createToolLogger`. */
|
|
20
|
+
export interface ToolLoggerConfig {
|
|
21
|
+
/** Where a formatted line goes. Default `console.info`. */
|
|
22
|
+
log?: (line: string) => void;
|
|
23
|
+
/** Called with the structured record for every call — feed a metrics sink. */
|
|
24
|
+
onRecord?: (record: ToolCallRecord) => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build a `ToolCallHooks` that logs every tool call. Merge it into a mount's
|
|
28
|
+
* `hooks` (or spread alongside your own `beforeToolCall`).
|
|
29
|
+
*/
|
|
30
|
+
export declare function createToolLogger(config?: ToolLoggerConfig): ToolCallHooks;
|
|
31
|
+
//# sourceMappingURL=tool-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-logger.d.ts","sourceRoot":"","sources":["../../src/tools/tool-logger.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,kFAAkF;AAClF,MAAM,WAAW,cAAc;IAC7B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,EAAE,EAAE,OAAO,CAAC;IACZ,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,2DAA2D;IAC3D,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;CAC7C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,gBAAqB,GAAG,aAAa,CAoB7E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A boot-time transport summary — how many operations each service exposes on
|
|
3
|
+
* each transport (HTTP / MCP / AGENT / CLI). Every project logs this by hand and
|
|
4
|
+
* re-derives the `expose` combinatorics (default-on MCP/AGENT, opt-in CLI,
|
|
5
|
+
* multipart is HTTP-only). This returns the data; the app formats its own line.
|
|
6
|
+
*
|
|
7
|
+
* Tool counts come from `collectTools` — the exact resolver the mounts use, so
|
|
8
|
+
* the summary can't drift from what actually mounts.
|
|
9
|
+
*/
|
|
10
|
+
import type { Transport } from '../contract';
|
|
11
|
+
import type { ServiceDef } from '../server/types';
|
|
12
|
+
/** Operation counts per transport, for one service or the whole fleet. */
|
|
13
|
+
export type TransportCounts = Record<Transport, number>;
|
|
14
|
+
/** The result of `summarizeTransports`. */
|
|
15
|
+
export interface TransportSummary {
|
|
16
|
+
/** Number of services summarised. */
|
|
17
|
+
services: number;
|
|
18
|
+
/** Operation counts per transport, summed across every service. */
|
|
19
|
+
totals: TransportCounts;
|
|
20
|
+
/** Per-service breakdown, in input order. */
|
|
21
|
+
perService: Array<{
|
|
22
|
+
service: string;
|
|
23
|
+
counts: TransportCounts;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
/** Summarise how the given services are exposed across the four transports. */
|
|
27
|
+
export declare function summarizeTransports(services: ServiceDef[]): TransportSummary;
|
|
28
|
+
//# sourceMappingURL=transports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transports.d.ts","sourceRoot":"","sources":["../../src/tools/transports.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,0EAA0E;AAC1E,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AAExD,2CAA2C;AAC3C,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,MAAM,EAAE,eAAe,CAAC;IACxB,6CAA6C;IAC7C,UAAU,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;CACjE;AAQD,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,gBAAgB,CAmB5E"}
|
package/dist/tools.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ export { type CliConfig, createCli } from './tools/cli';
|
|
|
4
4
|
export type { ExitCodeMap } from './tools/cli-format';
|
|
5
5
|
export type { CliWaitConfig } from './tools/cli-wait';
|
|
6
6
|
export { coerceJsonArgs } from './tools/coerce';
|
|
7
|
-
export type { ToolCallHooks, ToolLifecycle, ToolResult } from './tools/execute';
|
|
7
|
+
export type { ErrorHintFn, ToolCallHooks, ToolLifecycle, ToolResult } from './tools/execute';
|
|
8
8
|
export { flattenDiscriminatedUnion, flattenUnionsDeep } from './tools/flatten';
|
|
9
|
+
export { listToolNames, type ToolNameEntry } from './tools/list-names';
|
|
9
10
|
export { buildToolManifest, type ToolManifestEntry } from './tools/manifest';
|
|
10
11
|
export { buildMcpServer, type IncompatibleSchemaPolicy, type McpMountConfig, type McpServerBuildConfig, mountMcp, mountMcpResource, validateMcpSchemas, } from './tools/mcp';
|
|
11
12
|
export { EXT_APPS_BUNDLE_PLACEHOLDER, inlineMcpAppBundle, type McpAppCsp, type McpAppResourceMeta, type McpResourceDef, RESOURCE_MIME_TYPE, } from './tools/mcp-app';
|
|
@@ -18,6 +19,8 @@ export { mountWait, type WaitToolConfig } from './tools/mount-wait';
|
|
|
18
19
|
export { oauthProtectedResourceRoute, PROTECTED_RESOURCE_PATH, type ProtectedResourceConfig, protectedResourceMetadataUrl, wwwAuthenticateHeader, } from './tools/oauth-metadata';
|
|
19
20
|
export { type AuthCodeData, type AuthRequest, type ClientMetadata, mountOAuthProvider, type OAuthProviderConfig, type RefreshData, type RegisteredClient, } from './tools/oauth-provider';
|
|
20
21
|
export { type ImplementRemoteOptions, implementRemote } from './tools/remote';
|
|
22
|
+
export { createToolLogger, type ToolCallRecord, type ToolLoggerConfig, } from './tools/tool-logger';
|
|
21
23
|
export { createToolkit, type Toolkit } from './tools/toolkit';
|
|
24
|
+
export { summarizeTransports, type TransportCounts, type TransportSummary, } from './tools/transports';
|
|
22
25
|
export { type McpMediaContent, mountViewFile, resolveMedia } from './tools/view-file';
|
|
23
26
|
//# 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,YAAY,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EA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;AAChC,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,gBAAgB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,KAAK,sBAAsB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EACL,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EACL,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/tools.js
CHANGED
|
@@ -2,7 +2,10 @@ import {
|
|
|
2
2
|
inputIsQuery,
|
|
3
3
|
signJwt,
|
|
4
4
|
verifyPkce
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-ynnh9x6h.js";
|
|
6
|
+
import {
|
|
7
|
+
DEFAULT_CORS_ALLOW_HEADERS
|
|
8
|
+
} from "./index-tje0q6gp.js";
|
|
6
9
|
import {
|
|
7
10
|
coerceJsonArgs,
|
|
8
11
|
collectTools,
|
|
@@ -15,18 +18,19 @@ import {
|
|
|
15
18
|
pollUntil,
|
|
16
19
|
readCapped,
|
|
17
20
|
toolResultFromError
|
|
18
|
-
} from "./index-
|
|
21
|
+
} from "./index-xmncnw8z.js";
|
|
19
22
|
import {
|
|
20
23
|
toJsonSchema
|
|
21
24
|
} from "./index-0ed3bx43.js";
|
|
22
25
|
import {
|
|
23
26
|
AppError,
|
|
24
27
|
isWithinDir
|
|
25
|
-
} from "./index-
|
|
28
|
+
} from "./index-ng2v2ts4.js";
|
|
29
|
+
import"./index-khwedj16.js";
|
|
26
30
|
import {
|
|
27
31
|
isRecord,
|
|
28
32
|
typedEntries
|
|
29
|
-
} from "./index-
|
|
33
|
+
} from "./index-c7nyw0yt.js";
|
|
30
34
|
|
|
31
35
|
// src/tools/agent.ts
|
|
32
36
|
import { tool, zodSchema } from "ai";
|
|
@@ -69,6 +73,30 @@ function mountAgent(services, config = {}) {
|
|
|
69
73
|
}
|
|
70
74
|
return tools;
|
|
71
75
|
}
|
|
76
|
+
// src/tools/list-names.ts
|
|
77
|
+
var TOOL_TRANSPORTS = ["MCP", "AGENT", "CLI"];
|
|
78
|
+
function listToolNames(services) {
|
|
79
|
+
const entries = new Map;
|
|
80
|
+
for (const service of services) {
|
|
81
|
+
for (const transport of TOOL_TRANSPORTS) {
|
|
82
|
+
for (const tool2 of collectTools(service, transport)) {
|
|
83
|
+
const id = `${service.name}\x00${tool2.method.key}`;
|
|
84
|
+
const existing = entries.get(id);
|
|
85
|
+
if (existing) {
|
|
86
|
+
existing.transports.push(transport);
|
|
87
|
+
} else {
|
|
88
|
+
entries.set(id, {
|
|
89
|
+
name: tool2.name,
|
|
90
|
+
service: service.name,
|
|
91
|
+
method: tool2.method.key,
|
|
92
|
+
transports: [transport]
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return [...entries.values()].sort((a, b) => a.name.localeCompare(b.name) || a.service.localeCompare(b.service));
|
|
99
|
+
}
|
|
72
100
|
// src/tools/manifest.ts
|
|
73
101
|
function buildToolManifest(tools) {
|
|
74
102
|
return tools.map((t) => {
|
|
@@ -294,7 +322,7 @@ function wwwAuthenticateHeader(resource) {
|
|
|
294
322
|
var PUBLIC_CORS = {
|
|
295
323
|
"Access-Control-Allow-Origin": "*",
|
|
296
324
|
"Access-Control-Allow-Methods": "GET, OPTIONS",
|
|
297
|
-
"Access-Control-Allow-Headers":
|
|
325
|
+
"Access-Control-Allow-Headers": DEFAULT_CORS_ALLOW_HEADERS
|
|
298
326
|
};
|
|
299
327
|
function oauthProtectedResourceRoute(config) {
|
|
300
328
|
const body = JSON.stringify({
|
|
@@ -574,7 +602,7 @@ import { randomUUID as randomUUID2 } from "node:crypto";
|
|
|
574
602
|
var PUBLIC_CORS2 = {
|
|
575
603
|
"Access-Control-Allow-Origin": "*",
|
|
576
604
|
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
|
577
|
-
"Access-Control-Allow-Headers":
|
|
605
|
+
"Access-Control-Allow-Headers": DEFAULT_CORS_ALLOW_HEADERS
|
|
578
606
|
};
|
|
579
607
|
var AS_METADATA_PATH = "/.well-known/oauth-authorization-server";
|
|
580
608
|
var AUTH_CODE_TTL_MS = 60000;
|
|
@@ -870,10 +898,16 @@ function withTimeout(options, timeout) {
|
|
|
870
898
|
return options;
|
|
871
899
|
return { ...options, timeout };
|
|
872
900
|
}
|
|
901
|
+
function withOutput(endpoint, result) {
|
|
902
|
+
const schema = endpoint.output;
|
|
903
|
+
if (!schema)
|
|
904
|
+
return result;
|
|
905
|
+
return result.then((value) => value === undefined ? undefined : schema.parse(value));
|
|
906
|
+
}
|
|
873
907
|
function isParamArray(value) {
|
|
874
908
|
return Array.isArray(value) && value.every((v) => typeof v === "string" || typeof v === "number");
|
|
875
909
|
}
|
|
876
|
-
function collectQueryParams(args, skipKeys) {
|
|
910
|
+
function collectQueryParams(args, skipKeys, endpoint) {
|
|
877
911
|
const params = {};
|
|
878
912
|
let hasParams = false;
|
|
879
913
|
for (const [key, value] of Object.entries(args)) {
|
|
@@ -882,7 +916,10 @@ function collectQueryParams(args, skipKeys) {
|
|
|
882
916
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || isParamArray(value)) {
|
|
883
917
|
params[key] = value;
|
|
884
918
|
hasParams = true;
|
|
919
|
+
continue;
|
|
885
920
|
}
|
|
921
|
+
const what = Array.isArray(value) ? "an array with non-primitive items" : typeof value === "object" ? "a nested object" : `a ${typeof value}`;
|
|
922
|
+
throw new Error(`${endpoint.method} ${endpoint.path}: input field "${key}" is ${what} — it cannot ` + "travel as a query parameter. GET / DELETE input must be flat (string / number / " + "boolean, or an array of string / number); flatten the field or move the " + "operation to a body verb (POST).");
|
|
886
923
|
}
|
|
887
924
|
return hasParams ? params : undefined;
|
|
888
925
|
}
|
|
@@ -930,18 +967,21 @@ function createHttpMethod(endpoint, prefix, client, config) {
|
|
|
930
967
|
if (!isMultipartFile(file)) {
|
|
931
968
|
throw new Error(`Missing multipart file field: ${endpoint.multipart}`);
|
|
932
969
|
}
|
|
970
|
+
if (httpMethod === "get" || httpMethod === "delete") {
|
|
971
|
+
throw new Error(`Multipart endpoint ${endpoint.method} ${endpoint.path} must be POST / PUT / PATCH`);
|
|
972
|
+
}
|
|
933
973
|
const formData = new FormData;
|
|
934
974
|
appendMultipartFile(formData, endpoint.multipart, file);
|
|
935
975
|
appendFormFields(formData, firstArg, new Set([...prefixKeys, endpoint.multipart]));
|
|
936
|
-
return client
|
|
976
|
+
return withOutput(endpoint, client[httpMethod](url, formData, withTimeout(undefined, endpoint.timeout)));
|
|
937
977
|
}
|
|
938
978
|
if (isGet) {
|
|
939
|
-
const params = collectQueryParams(firstArg, prefixKeys);
|
|
940
|
-
return client.get(url, withTimeout(params ? { params } : undefined, endpoint.timeout));
|
|
979
|
+
const params = collectQueryParams(firstArg, prefixKeys, endpoint);
|
|
980
|
+
return withOutput(endpoint, client.get(url, withTimeout(params ? { params } : undefined, endpoint.timeout)));
|
|
941
981
|
}
|
|
942
982
|
if (httpMethod === "delete") {
|
|
943
|
-
const params = collectQueryParams(firstArg, prefixKeys);
|
|
944
|
-
return client.delete(url, withTimeout(params ? { params } : undefined, endpoint.timeout));
|
|
983
|
+
const params = collectQueryParams(firstArg, prefixKeys, endpoint);
|
|
984
|
+
return withOutput(endpoint, client.delete(url, withTimeout(params ? { params } : undefined, endpoint.timeout)));
|
|
945
985
|
}
|
|
946
986
|
const payload = {};
|
|
947
987
|
for (const [key, value] of Object.entries(firstArg)) {
|
|
@@ -949,7 +989,7 @@ function createHttpMethod(endpoint, prefix, client, config) {
|
|
|
949
989
|
payload[key] = value;
|
|
950
990
|
}
|
|
951
991
|
}
|
|
952
|
-
return client[httpMethod](url, Object.keys(payload).length > 0 ? payload : undefined, withTimeout(undefined, endpoint.timeout));
|
|
992
|
+
return withOutput(endpoint, client[httpMethod](url, Object.keys(payload).length > 0 ? payload : undefined, withTimeout(undefined, endpoint.timeout)));
|
|
953
993
|
};
|
|
954
994
|
}
|
|
955
995
|
function createFetchMethod(endpoint, prefix, config, contractConfig) {
|
|
@@ -966,23 +1006,24 @@ function createFetchMethod(endpoint, prefix, config, contractConfig) {
|
|
|
966
1006
|
Accept: "application/json",
|
|
967
1007
|
...typeof config.headers === "function" ? config.headers() : config.headers
|
|
968
1008
|
};
|
|
1009
|
+
const signal = endpoint.timeout !== undefined ? AbortSignal.timeout(endpoint.timeout) : undefined;
|
|
969
1010
|
const isQuery = inputIsQuery(endpoint.method);
|
|
970
1011
|
const hasBody = !isQuery && !endpoint.multipart && endpoint.input && args;
|
|
971
1012
|
if (isQuery && args) {
|
|
972
1013
|
const remaining = stripParams(args, endpoint.path, prefixKeys);
|
|
973
|
-
const
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
1014
|
+
const params = collectQueryParams(remaining, new Set, endpoint);
|
|
1015
|
+
if (params) {
|
|
1016
|
+
const searchParams = new URLSearchParams;
|
|
1017
|
+
for (const [k, v] of Object.entries(params)) {
|
|
1018
|
+
if (Array.isArray(v)) {
|
|
1019
|
+
for (const item of v)
|
|
1020
|
+
searchParams.append(k, String(item));
|
|
1021
|
+
} else {
|
|
1022
|
+
searchParams.set(k, String(v));
|
|
1023
|
+
}
|
|
982
1024
|
}
|
|
983
|
-
}
|
|
984
|
-
if (searchParams.size > 0)
|
|
985
1025
|
url += `?${searchParams}`;
|
|
1026
|
+
}
|
|
986
1027
|
}
|
|
987
1028
|
if (hasBody)
|
|
988
1029
|
headers["Content-Type"] = "application/json";
|
|
@@ -998,7 +1039,8 @@ function createFetchMethod(endpoint, prefix, config, contractConfig) {
|
|
|
998
1039
|
method: endpoint.method,
|
|
999
1040
|
headers,
|
|
1000
1041
|
credentials: config.credentials,
|
|
1001
|
-
body: formData
|
|
1042
|
+
body: formData,
|
|
1043
|
+
signal
|
|
1002
1044
|
});
|
|
1003
1045
|
if (!res2.ok) {
|
|
1004
1046
|
await throwForErrorResponse(res2, config, null);
|
|
@@ -1012,6 +1054,7 @@ function createFetchMethod(endpoint, prefix, config, contractConfig) {
|
|
|
1012
1054
|
method: endpoint.method,
|
|
1013
1055
|
headers,
|
|
1014
1056
|
credentials: config.credentials,
|
|
1057
|
+
signal,
|
|
1015
1058
|
...hasBody && {
|
|
1016
1059
|
body: JSON.stringify(stripParams(hasBody, endpoint.path, prefixKeys))
|
|
1017
1060
|
}
|
|
@@ -1137,6 +1180,26 @@ function implementRemote(contract, http, options) {
|
|
|
1137
1180
|
methods
|
|
1138
1181
|
};
|
|
1139
1182
|
}
|
|
1183
|
+
// src/tools/tool-logger.ts
|
|
1184
|
+
function createToolLogger(config = {}) {
|
|
1185
|
+
const log = config.log ?? ((line) => console.info(line));
|
|
1186
|
+
return {
|
|
1187
|
+
afterToolCall: (toolName, _args, result, durationMs, context, endpoint) => {
|
|
1188
|
+
const record = {
|
|
1189
|
+
tool: toolName,
|
|
1190
|
+
service: endpoint.serviceName,
|
|
1191
|
+
action: endpoint.key,
|
|
1192
|
+
ok: result.ok,
|
|
1193
|
+
code: result.ok ? undefined : result.code,
|
|
1194
|
+
durationMs: Math.round(durationMs),
|
|
1195
|
+
source: String(context.source)
|
|
1196
|
+
};
|
|
1197
|
+
const codePart = result.ok ? "" : ` ${result.code}`;
|
|
1198
|
+
log(`[tool] ${result.ok ? "ok" : "warn"} ${toolName} (${endpoint.serviceName}.${endpoint.key})${codePart} ${record.durationMs}ms`);
|
|
1199
|
+
config.onRecord?.(record);
|
|
1200
|
+
}
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1140
1203
|
// src/tools/toolkit.ts
|
|
1141
1204
|
function createToolkit() {
|
|
1142
1205
|
return {
|
|
@@ -1148,6 +1211,29 @@ function createToolkit() {
|
|
|
1148
1211
|
createCli: (config) => createCli(config)
|
|
1149
1212
|
};
|
|
1150
1213
|
}
|
|
1214
|
+
// src/tools/transports.ts
|
|
1215
|
+
var TOOL_TRANSPORTS2 = ["MCP", "AGENT", "CLI"];
|
|
1216
|
+
function emptyCounts() {
|
|
1217
|
+
return { HTTP: 0, MCP: 0, AGENT: 0, CLI: 0 };
|
|
1218
|
+
}
|
|
1219
|
+
function summarizeTransports(services) {
|
|
1220
|
+
const totals = emptyCounts();
|
|
1221
|
+
const perService = services.map((service) => {
|
|
1222
|
+
const counts = emptyCounts();
|
|
1223
|
+
for (const method of Object.values(service.methods)) {
|
|
1224
|
+
if (!method.expose || method.expose.includes("HTTP"))
|
|
1225
|
+
counts.HTTP += 1;
|
|
1226
|
+
}
|
|
1227
|
+
for (const transport of TOOL_TRANSPORTS2) {
|
|
1228
|
+
counts[transport] = collectTools(service, transport).length;
|
|
1229
|
+
}
|
|
1230
|
+
for (const transport of Object.keys(counts)) {
|
|
1231
|
+
totals[transport] += counts[transport];
|
|
1232
|
+
}
|
|
1233
|
+
return { service: service.name, counts };
|
|
1234
|
+
});
|
|
1235
|
+
return { services: services.length, totals, perService };
|
|
1236
|
+
}
|
|
1151
1237
|
// src/tools/view-file.ts
|
|
1152
1238
|
import { readFile, realpath, stat } from "node:fs/promises";
|
|
1153
1239
|
import { extname as extname2, resolve } from "node:path";
|
|
@@ -1273,6 +1359,7 @@ function mountViewFile(server, options = {}) {
|
|
|
1273
1359
|
export {
|
|
1274
1360
|
wwwAuthenticateHeader,
|
|
1275
1361
|
validateMcpSchemas,
|
|
1362
|
+
summarizeTransports,
|
|
1276
1363
|
resolveMedia,
|
|
1277
1364
|
protectedResourceMetadataUrl,
|
|
1278
1365
|
oauthProtectedResourceRoute,
|
|
@@ -1284,11 +1371,13 @@ export {
|
|
|
1284
1371
|
mountMcp,
|
|
1285
1372
|
mountDownload,
|
|
1286
1373
|
mountAgent,
|
|
1374
|
+
listToolNames,
|
|
1287
1375
|
inlineMcpAppBundle,
|
|
1288
1376
|
implementRemote,
|
|
1289
1377
|
flattenUnionsDeep,
|
|
1290
1378
|
flattenDiscriminatedUnion,
|
|
1291
1379
|
createToolkit,
|
|
1380
|
+
createToolLogger,
|
|
1292
1381
|
createStdioMcpServer,
|
|
1293
1382
|
createMcpHandler,
|
|
1294
1383
|
createCli,
|