stitchkit 0.129.0 → 0.130.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/CHANGELOG.md +32 -0
- package/dist/agent-executor/acp/v1-connect.d.ts +87 -19
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-driver.d.ts +4 -2
- package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-handlers.d.ts +56 -0
- package/dist/agent-executor/acp/v1-handlers.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-map.d.ts +13 -2
- package/dist/agent-executor/acp/v1-map.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-permission.d.ts +44 -0
- package/dist/agent-executor/acp/v1-permission.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts +63 -10
- package/dist/agent-executor/acp/v1-protocol.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-session.d.ts +34 -7
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-turn.d.ts +51 -13
- package/dist/agent-executor/acp/v1-turn.d.ts.map +1 -1
- package/dist/agent-executor/claude/classify.d.ts +10 -0
- package/dist/agent-executor/claude/classify.d.ts.map +1 -1
- package/dist/agent-executor/claude/cli-driver.d.ts +4 -1
- package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -1
- package/dist/agent-executor/claude/events.d.ts +146 -0
- package/dist/agent-executor/claude/events.d.ts.map +1 -0
- package/dist/agent-executor/claude/limits.d.ts +7 -1
- package/dist/agent-executor/claude/limits.d.ts.map +1 -1
- package/dist/agent-executor/claude/protocol.d.ts +49 -9
- package/dist/agent-executor/claude/protocol.d.ts.map +1 -1
- package/dist/agent-executor/claude/session.d.ts +2 -0
- package/dist/agent-executor/claude/session.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/controls.d.ts +10 -1
- package/dist/agent-executor/claude-sdk/controls.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/driver.d.ts +97 -3
- package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/probe.d.ts +29 -0
- package/dist/agent-executor/claude-sdk/probe.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/query-loop.d.ts +53 -5
- package/dist/agent-executor/claude-sdk/query-loop.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/query-options.d.ts +2 -0
- package/dist/agent-executor/claude-sdk/query-options.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/session.d.ts +2 -3
- package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/turn-usage.d.ts +81 -0
- package/dist/agent-executor/claude-sdk/turn-usage.d.ts.map +1 -0
- package/dist/agent-executor/codex/classify.d.ts +4 -0
- package/dist/agent-executor/codex/classify.d.ts.map +1 -1
- package/dist/agent-executor/codex/connect.d.ts +5 -2
- package/dist/agent-executor/codex/connect.d.ts.map +1 -1
- package/dist/agent-executor/codex/control-client.d.ts +206 -0
- package/dist/agent-executor/codex/control-client.d.ts.map +1 -0
- package/dist/agent-executor/codex/driver.d.ts +35 -5
- package/dist/agent-executor/codex/driver.d.ts.map +1 -1
- package/dist/agent-executor/codex/handlers.d.ts +52 -0
- package/dist/agent-executor/codex/handlers.d.ts.map +1 -0
- package/dist/agent-executor/codex/limits.d.ts.map +1 -1
- package/dist/agent-executor/codex/protocol.d.ts +128 -0
- package/dist/agent-executor/codex/protocol.d.ts.map +1 -1
- package/dist/agent-executor/codex/request-answers.d.ts +101 -0
- package/dist/agent-executor/codex/request-answers.d.ts.map +1 -0
- package/dist/agent-executor/codex/session-controls.d.ts +124 -61
- package/dist/agent-executor/codex/session-controls.d.ts.map +1 -1
- package/dist/agent-executor/codex/session.d.ts +10 -36
- package/dist/agent-executor/codex/session.d.ts.map +1 -1
- package/dist/agent-executor/codex/shared-server.d.ts +31 -0
- package/dist/agent-executor/codex/shared-server.d.ts.map +1 -0
- package/dist/agent-executor/codex/shared-thread.d.ts +46 -0
- package/dist/agent-executor/codex/shared-thread.d.ts.map +1 -0
- package/dist/agent-executor/codex/thread-controls.d.ts +144 -0
- package/dist/agent-executor/codex/thread-controls.d.ts.map +1 -0
- package/dist/agent-executor/codex/thread-open.d.ts +66 -0
- package/dist/agent-executor/codex/thread-open.d.ts.map +1 -0
- package/dist/agent-executor/codex/turn-input.d.ts +47 -0
- package/dist/agent-executor/codex/turn-input.d.ts.map +1 -0
- package/dist/agent-executor/contract.d.ts +77 -0
- package/dist/agent-executor/contract.d.ts.map +1 -1
- package/dist/agent-executor/engine.d.ts +6 -2
- package/dist/agent-executor/engine.d.ts.map +1 -1
- package/dist/agent-executor/executor-contract.d.ts +54 -0
- package/dist/agent-executor/executor-contract.d.ts.map +1 -1
- package/dist/agent-executor/handoff-schemas.d.ts +407 -0
- package/dist/agent-executor/handoff-schemas.d.ts.map +1 -0
- package/dist/agent-executor/handoff.d.ts +12 -0
- package/dist/agent-executor/handoff.d.ts.map +1 -0
- package/dist/agent-executor/hello.d.ts +72 -0
- package/dist/agent-executor/hello.d.ts.map +1 -1
- package/dist/agent-executor/image-input.d.ts +22 -0
- package/dist/agent-executor/image-input.d.ts.map +1 -1
- package/dist/agent-executor/projection.d.ts +2 -2
- package/dist/agent-executor/projection.d.ts.map +1 -1
- package/dist/agent-executor/session-primitives.d.ts +10 -1
- package/dist/agent-executor/session-primitives.d.ts.map +1 -1
- package/dist/agent-executor/testing/conformance.d.ts.map +1 -1
- package/dist/agent-executor/testing/replay-driver.d.ts +41 -0
- package/dist/agent-executor/testing/replay-driver.d.ts.map +1 -0
- package/dist/agent-executor/testing/replay-gate.d.ts +11 -0
- package/dist/agent-executor/testing/replay-gate.d.ts.map +1 -0
- package/dist/agent-executor/testing/replay-runner.d.ts +27 -0
- package/dist/agent-executor/testing/replay-runner.d.ts.map +1 -0
- package/dist/agent-executor/testing/replay-scenarios.d.ts +21 -0
- package/dist/agent-executor/testing/replay-scenarios.d.ts.map +1 -0
- package/dist/agent-executor/testing/replay-transcript.d.ts +296 -0
- package/dist/agent-executor/testing/replay-transcript.d.ts.map +1 -0
- package/dist/agent-executor/vocabulary.d.ts +135 -0
- package/dist/agent-executor/vocabulary.d.ts.map +1 -1
- package/dist/agent-runtime/branch-observations.d.ts +18 -18
- package/dist/agent-runtime/branch-provider.d.ts +2 -2
- package/dist/agent-runtime/deferred-tool-selection.d.ts.map +1 -1
- package/dist/agent-runtime/sql-rows.d.ts +10 -10
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +20 -20
- package/dist/agent-runtime/store-conformance-support.d.ts +10 -10
- package/dist/agent-runtime/terminal-commit.d.ts +10 -10
- package/dist/entrypoints/agent-executor/acp.d.ts +4 -1
- package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +847 -214
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts +5 -1
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/claude-sdk.js +713 -205
- package/dist/entrypoints/agent-executor/claude.js +44 -19
- package/dist/entrypoints/agent-executor/codex.d.ts +10 -2
- package/dist/entrypoints/agent-executor/codex.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/codex.js +2269 -600
- package/dist/entrypoints/agent-executor/testing.d.ts +4 -0
- package/dist/entrypoints/agent-executor/testing.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/testing.js +1002 -2
- package/dist/entrypoints/agent-executor.d.ts +4 -2
- package/dist/entrypoints/agent-executor.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor.js +411 -23
- package/dist/entrypoints/agent-runtime.js +4 -23
- package/dist/entrypoints/tools/mcp.d.ts +1 -0
- package/dist/entrypoints/tools/mcp.d.ts.map +1 -1
- package/dist/entrypoints/tools/mcp.js +1 -1
- package/dist/entrypoints/tools/toolkit.js +1 -1
- package/dist/{index-wv2amqm4.js → index-2s8sy57y.js} +36 -103
- package/dist/{index-afb6z77w.js → index-dbp6xemn.js} +75 -7
- package/dist/{index-bjmj2q1z.js → index-jrn3prgm.js} +1 -1
- package/dist/index-kne9g2c5.js +30 -0
- package/dist/index-p1qmpq0p.js +1300 -0
- package/dist/{index-7jqn3b3g.js → index-v759mzed.js} +152 -2
- package/dist/{index-cbhxhma2.js → index-x5ayy5bn.js} +1 -0
- package/dist/index-y0a4gt1s.js +142 -0
- package/dist/tools/internal/rank-tools.d.ts +10 -0
- package/dist/tools/internal/rank-tools.d.ts.map +1 -0
- package/dist/tools/mcp/handler.d.ts +7 -3
- package/dist/tools/mcp/handler.d.ts.map +1 -1
- package/dist/tools/mcp/lazy-discovery.d.ts +47 -0
- package/dist/tools/mcp/lazy-discovery.d.ts.map +1 -0
- package/dist/tools/mcp/mount.d.ts +7 -0
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts +2 -2
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/llms/agent-executor-acp.txt +7 -8
- package/llms/agent-executor-claude-sdk.txt +4 -2
- package/llms/agent-executor-codex.txt +8 -4
- package/llms/agent-executor-testing.txt +5 -1
- package/llms/agent-executor.txt +7 -6
- package/llms/stitchkit.txt +74 -74
- package/llms/tools-mcp.txt +3 -2
- package/llms/tools.txt +24 -0
- package/llms/{upgrading-0.128.0-0.129.0.txt → upgrading-0.128.0-0.130.0.txt} +30 -3
- package/llms/upgrading.txt +1 -1
- package/llms-full.txt +159 -97
- package/llms.txt +8 -8
- package/package.json +1 -1
- package/dist/index-y71zn1gw.js +0 -586
|
@@ -33,6 +33,9 @@ import {
|
|
|
33
33
|
import {
|
|
34
34
|
jsonResponse
|
|
35
35
|
} from "./index-kyejf658.js";
|
|
36
|
+
import {
|
|
37
|
+
rankToolsByQuery
|
|
38
|
+
} from "./index-kne9g2c5.js";
|
|
36
39
|
import {
|
|
37
40
|
MCP_CATALOG_HEADER,
|
|
38
41
|
mcpCatalogMeta2,
|
|
@@ -56,6 +59,9 @@ import {
|
|
|
56
59
|
runWithRequestContext2,
|
|
57
60
|
getRequestContext2
|
|
58
61
|
} from "./index-x6sp5vpa.js";
|
|
62
|
+
import {
|
|
63
|
+
defineRuntimeTool2
|
|
64
|
+
} from "./index-7csn6pva.js";
|
|
59
65
|
import {
|
|
60
66
|
AppError2
|
|
61
67
|
} from "./index-9pv126eh.js";
|
|
@@ -66,6 +72,9 @@ import {
|
|
|
66
72
|
import {
|
|
67
73
|
resolvePropagationContext2
|
|
68
74
|
} from "./index-y7sy1xdp.js";
|
|
75
|
+
import {
|
|
76
|
+
assertPositiveSafeInteger
|
|
77
|
+
} from "./index-gr0kxymw.js";
|
|
69
78
|
import {
|
|
70
79
|
isRecord
|
|
71
80
|
} from "./index-ps3djm8d.js";
|
|
@@ -150,6 +159,9 @@ function stampToolResult(result, stamp) {
|
|
|
150
159
|
return { ...result, _meta: { ...result._meta, ...mcpCatalogMeta2(stamp) } };
|
|
151
160
|
}
|
|
152
161
|
|
|
162
|
+
// src/tools/mcp/lazy-discovery.ts
|
|
163
|
+
import { z as z3 } from "zod";
|
|
164
|
+
|
|
153
165
|
// src/tools/mcp/prepare.ts
|
|
154
166
|
function textBlock(text) {
|
|
155
167
|
return [{ type: "text", text }];
|
|
@@ -582,7 +594,7 @@ function registerMcpTool(server, presentation, descriptor, config) {
|
|
|
582
594
|
}
|
|
583
595
|
const { name } = presentation;
|
|
584
596
|
const format = config.formatResult;
|
|
585
|
-
server.registerTool(name, stampToolRegistration(toolConfig, config.catalog), async (rawArgs, mcpContext) => stampToolResult(await runInMcpRequestContext(mcpContext, name, async () => {
|
|
597
|
+
return server.registerTool(name, stampToolRegistration(toolConfig, config.catalog), async (rawArgs, mcpContext) => stampToolResult(await runInMcpRequestContext(mcpContext, name, async () => {
|
|
586
598
|
const inspectErr = inspectOnlyError(config.lifecycle);
|
|
587
599
|
if (inspectErr)
|
|
588
600
|
return format(toolResultFromError(inspectErr), "none", name);
|
|
@@ -698,6 +710,122 @@ function mountPreparedRuntimeMcp(server, tools, config) {
|
|
|
698
710
|
}
|
|
699
711
|
}
|
|
700
712
|
|
|
713
|
+
// src/tools/mcp/lazy-discovery.ts
|
|
714
|
+
var DEFAULT_SEARCH_TOOL_NAME = "tool_search";
|
|
715
|
+
var DEFAULT_MAX_RESULTS = 10;
|
|
716
|
+
var HARD_MAX_RESULTS = 50;
|
|
717
|
+
var LazySearchInputSchema = z3.strictObject({
|
|
718
|
+
query: z3.string().trim().min(1).max(256),
|
|
719
|
+
limit: z3.int().positive().max(HARD_MAX_RESULTS).optional()
|
|
720
|
+
});
|
|
721
|
+
var LazySearchMatchSchema = z3.strictObject({
|
|
722
|
+
name: z3.string().min(1),
|
|
723
|
+
description: z3.string(),
|
|
724
|
+
newlyEnabled: z3.boolean()
|
|
725
|
+
});
|
|
726
|
+
var LazySearchOutputSchema = z3.strictObject({
|
|
727
|
+
query: z3.string(),
|
|
728
|
+
enabledTools: z3.array(z3.string()),
|
|
729
|
+
matches: z3.array(LazySearchMatchSchema),
|
|
730
|
+
totalHiddenRemaining: z3.int().nonnegative()
|
|
731
|
+
});
|
|
732
|
+
function validateMcpLazyDiscovery(rawConfig, contractToolNames, reservedToolNames = []) {
|
|
733
|
+
if (!isRecord(rawConfig)) {
|
|
734
|
+
throw new TypeError("[stitchkit] MCP discovery config must be an object");
|
|
735
|
+
}
|
|
736
|
+
if (rawConfig.mode !== "lazy") {
|
|
737
|
+
throw new TypeError(`[stitchkit] MCP discovery mode must be "lazy" (received ${JSON.stringify(rawConfig.mode)})`);
|
|
738
|
+
}
|
|
739
|
+
if (!Array.isArray(rawConfig.initialTools)) {
|
|
740
|
+
throw new TypeError("[stitchkit] MCP discovery.initialTools must be an array of tool names");
|
|
741
|
+
}
|
|
742
|
+
const searchToolName = rawConfig.searchToolName === undefined ? DEFAULT_SEARCH_TOOL_NAME : typeof rawConfig.searchToolName === "string" ? rawConfig.searchToolName.trim() : "";
|
|
743
|
+
if (searchToolName.length === 0) {
|
|
744
|
+
throw new TypeError("[stitchkit] MCP discovery.searchToolName must be a non-empty string");
|
|
745
|
+
}
|
|
746
|
+
if (rawConfig.maxResults !== undefined && typeof rawConfig.maxResults !== "number") {
|
|
747
|
+
throw new TypeError("[stitchkit] MCP discovery.maxResults must be a positive integer");
|
|
748
|
+
}
|
|
749
|
+
const maxResults = rawConfig.maxResults ?? DEFAULT_MAX_RESULTS;
|
|
750
|
+
assertPositiveSafeInteger("[stitchkit] MCP discovery.maxResults", maxResults);
|
|
751
|
+
if (maxResults > HARD_MAX_RESULTS) {
|
|
752
|
+
throw new RangeError(`[stitchkit] MCP discovery.maxResults (${maxResults}) must not exceed ${HARD_MAX_RESULTS}`);
|
|
753
|
+
}
|
|
754
|
+
const knownContract = new Set(contractToolNames);
|
|
755
|
+
const allOccupied = new Set([...contractToolNames, ...reservedToolNames]);
|
|
756
|
+
if (allOccupied.has(searchToolName)) {
|
|
757
|
+
throw new Error(`[stitchkit] MCP discovery.searchToolName "${searchToolName}" collides with an existing mounted tool`);
|
|
758
|
+
}
|
|
759
|
+
const initialTools = new Set;
|
|
760
|
+
for (const name of rawConfig.initialTools) {
|
|
761
|
+
if (typeof name !== "string" || name.trim().length === 0) {
|
|
762
|
+
throw new TypeError("[stitchkit] MCP discovery.initialTools entries must be non-empty strings");
|
|
763
|
+
}
|
|
764
|
+
if (!knownContract.has(name)) {
|
|
765
|
+
throw new Error(`[stitchkit] MCP discovery.initialTools contains unknown contract tool "${name}"`);
|
|
766
|
+
}
|
|
767
|
+
initialTools.add(name);
|
|
768
|
+
}
|
|
769
|
+
return { initialTools, searchToolName, maxResults };
|
|
770
|
+
}
|
|
771
|
+
function applyMcpLazyDiscovery(input) {
|
|
772
|
+
const { server, discovery, tools } = input;
|
|
773
|
+
const hiddenTools = [];
|
|
774
|
+
for (const entry of tools) {
|
|
775
|
+
if (!discovery.initialTools.has(entry.name)) {
|
|
776
|
+
entry.registered.enabled = false;
|
|
777
|
+
hiddenTools.push(entry);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
const searchTool = defineRuntimeTool2({
|
|
781
|
+
name: discovery.searchToolName,
|
|
782
|
+
description: "Search hidden tools by name or description and enable matching tools for this MCP session. " + "An exact tool name ranks first, followed by whole-phrase matches and multi-word matches.",
|
|
783
|
+
identity: { serviceName: "mcp", action: discovery.searchToolName, method: "POST" },
|
|
784
|
+
input: LazySearchInputSchema,
|
|
785
|
+
output: LazySearchOutputSchema,
|
|
786
|
+
expose: ["MCP"],
|
|
787
|
+
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
788
|
+
handler: ({ input: args }) => {
|
|
789
|
+
const cap = Math.min(args.limit ?? discovery.maxResults, discovery.maxResults);
|
|
790
|
+
const ranked = rankToolsByQuery(args.query, hiddenTools).slice(0, cap);
|
|
791
|
+
const enabledTools = [];
|
|
792
|
+
const matches = [];
|
|
793
|
+
for (const entry of ranked) {
|
|
794
|
+
const newlyEnabled = !entry.registered.enabled;
|
|
795
|
+
if (newlyEnabled) {
|
|
796
|
+
entry.registered.enabled = true;
|
|
797
|
+
enabledTools.push(entry.name);
|
|
798
|
+
}
|
|
799
|
+
matches.push({
|
|
800
|
+
name: entry.name,
|
|
801
|
+
description: entry.description,
|
|
802
|
+
newlyEnabled
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
if (enabledTools.length > 0) {
|
|
806
|
+
server.sendToolListChanged();
|
|
807
|
+
}
|
|
808
|
+
const totalHiddenRemaining = hiddenTools.filter((entry) => !entry.registered.enabled).length;
|
|
809
|
+
return {
|
|
810
|
+
query: args.query,
|
|
811
|
+
enabledTools,
|
|
812
|
+
matches,
|
|
813
|
+
totalHiddenRemaining
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
const prepared = prepareMcpServerSurface({ services: [], runtimeTools: [searchTool] });
|
|
818
|
+
mountPreparedRuntimeMcp(server, prepared.runtimeTools, {
|
|
819
|
+
catalog: input.catalog,
|
|
820
|
+
context: input.context,
|
|
821
|
+
hooks: input.hooks,
|
|
822
|
+
lifecycle: input.lifecycle,
|
|
823
|
+
coerceJsonArgs: input.coerceJsonArgs,
|
|
824
|
+
onOutputStrip: input.onOutputStrip,
|
|
825
|
+
formatResult: (result, mode, toolName) => formatMcpResult(result, mode, toolName, input.errorHint)
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
|
|
701
829
|
// src/tools/mcp/mount.ts
|
|
702
830
|
function validateMcpSchemas2(config) {
|
|
703
831
|
prepareMcpSurface(config.services, {
|
|
@@ -724,6 +852,7 @@ function mountMcp2(mcpServer, services, config) {
|
|
|
724
852
|
}
|
|
725
853
|
function mountPreparedMcp(mcpServer, prepared, config) {
|
|
726
854
|
const lifecycle = resolveToolAccess("mountPreparedMcp", config);
|
|
855
|
+
const validatedDiscovery = config.discovery !== undefined ? validateMcpLazyDiscovery(config.discovery, prepared.map((descriptor) => descriptor.mountable.name), config.reservedToolNames) : undefined;
|
|
727
856
|
const runTool = createToolRunner({
|
|
728
857
|
source: "mcp",
|
|
729
858
|
toolSurface: true,
|
|
@@ -734,9 +863,10 @@ function mountPreparedMcp(mcpServer, prepared, config) {
|
|
|
734
863
|
coerceJsonArgs: config.coerceJsonArgs,
|
|
735
864
|
onOutputStrip: config.onOutputStrip
|
|
736
865
|
});
|
|
866
|
+
const registeredTools = [];
|
|
737
867
|
for (const descriptor of prepared) {
|
|
738
868
|
const { method, name } = descriptor.mountable;
|
|
739
|
-
registerMcpTool(mcpServer, {
|
|
869
|
+
const registered = registerMcpTool(mcpServer, {
|
|
740
870
|
name,
|
|
741
871
|
description: method.desc,
|
|
742
872
|
ui: method.ui
|
|
@@ -749,6 +879,21 @@ function mountPreparedMcp(mcpServer, prepared, config) {
|
|
|
749
879
|
lifecycle,
|
|
750
880
|
context: config.context
|
|
751
881
|
});
|
|
882
|
+
registeredTools.push({ name, description: method.desc, registered });
|
|
883
|
+
}
|
|
884
|
+
if (validatedDiscovery !== undefined) {
|
|
885
|
+
applyMcpLazyDiscovery({
|
|
886
|
+
server: mcpServer,
|
|
887
|
+
discovery: validatedDiscovery,
|
|
888
|
+
tools: registeredTools,
|
|
889
|
+
lifecycle,
|
|
890
|
+
hooks: config.hooks,
|
|
891
|
+
context: config.context,
|
|
892
|
+
catalog: config.catalog,
|
|
893
|
+
coerceJsonArgs: config.coerceJsonArgs,
|
|
894
|
+
errorHint: config.errorHint,
|
|
895
|
+
onOutputStrip: config.onOutputStrip
|
|
896
|
+
});
|
|
752
897
|
}
|
|
753
898
|
}
|
|
754
899
|
function buildMcpServer2(config, auth) {
|
|
@@ -833,6 +978,8 @@ function buildMcpServerFromPrepared(config, auth, prepared) {
|
|
|
833
978
|
inputRecursionDepth: config.inputRecursionDepth,
|
|
834
979
|
errorHint: config.errorHint,
|
|
835
980
|
onOutputStrip: config.onOutputStrip,
|
|
981
|
+
discovery: config.discovery,
|
|
982
|
+
reservedToolNames: prepared.runtimeTools.map((entry) => entry.definition.name),
|
|
836
983
|
...roundCodec !== undefined && {
|
|
837
984
|
multiRoundRuntime: {
|
|
838
985
|
codec: roundCodec,
|
|
@@ -933,6 +1080,9 @@ function prepareStaticSurface(config) {
|
|
|
933
1080
|
}
|
|
934
1081
|
function createMcpHandler2(config) {
|
|
935
1082
|
resolveToolAccess("createMcpHandler", config);
|
|
1083
|
+
if ("discovery" in config && config.discovery !== undefined) {
|
|
1084
|
+
throw new TypeError("[stitchkit] createMcpHandler: lazy tool discovery requires a stateful MCP session; use createStdioMcpServer, buildMcpServer, or mountMcp instead");
|
|
1085
|
+
}
|
|
936
1086
|
const buildPrepared = prepareStaticSurface(config);
|
|
937
1087
|
const authByCarrier = new WeakMap;
|
|
938
1088
|
let closed = false;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {
|
|
2
|
+
assertPositiveSafeInteger
|
|
3
|
+
} from "./index-gr0kxymw.js";
|
|
4
|
+
import {
|
|
5
|
+
raceAbort
|
|
6
|
+
} from "./index-rptj3qnc.js";
|
|
7
|
+
|
|
8
|
+
// src/agent-executor/image-input.ts
|
|
9
|
+
var DEFAULT_MAX_IMAGE_BYTES = 5 * 1024 * 1024;
|
|
10
|
+
var CLAUDE_CLI_MAX_LINE_BYTES = 16 * 1024 * 1024;
|
|
11
|
+
var SUPPORTED_IMAGE_MEDIA_TYPES = new Set([
|
|
12
|
+
"image/png",
|
|
13
|
+
"image/jpeg",
|
|
14
|
+
"image/gif",
|
|
15
|
+
"image/webp"
|
|
16
|
+
]);
|
|
17
|
+
function isSupportedImageMediaType(value) {
|
|
18
|
+
return value === "image/png" || value === "image/jpeg" || value === "image/gif" || value === "image/webp";
|
|
19
|
+
}
|
|
20
|
+
function validateImageOptions(options) {
|
|
21
|
+
assertPositiveSafeInteger("maxImageBytes", options.maxImageBytes);
|
|
22
|
+
}
|
|
23
|
+
function bytesToBase64(bytes) {
|
|
24
|
+
return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
|
|
25
|
+
}
|
|
26
|
+
async function resolveImageBytes(reference, options) {
|
|
27
|
+
assertPositiveSafeInteger("maxImageBytes", options.maxImageBytes);
|
|
28
|
+
let bytes;
|
|
29
|
+
try {
|
|
30
|
+
bytes = await options.resolveFile(reference);
|
|
31
|
+
} catch {
|
|
32
|
+
throw new Error("Failed to resolve image input");
|
|
33
|
+
}
|
|
34
|
+
if (!(bytes instanceof Uint8Array)) {
|
|
35
|
+
throw new TypeError("resolveFile must return a Uint8Array");
|
|
36
|
+
}
|
|
37
|
+
if (bytes.byteLength === 0) {
|
|
38
|
+
throw new RangeError("The image is empty (0 bytes)");
|
|
39
|
+
}
|
|
40
|
+
if (bytes.byteLength > options.maxImageBytes) {
|
|
41
|
+
throw new RangeError(`The image is ${bytes.byteLength} bytes, over maxImageBytes ${options.maxImageBytes}`);
|
|
42
|
+
}
|
|
43
|
+
return bytes;
|
|
44
|
+
}
|
|
45
|
+
async function inlineOrderedParts(parts, options) {
|
|
46
|
+
const maxImageBytes = options.maxImageBytes ?? DEFAULT_MAX_IMAGE_BYTES;
|
|
47
|
+
assertPositiveSafeInteger("maxImageBytes", maxImageBytes);
|
|
48
|
+
const accepted = options.acceptedDescription ?? "text and images";
|
|
49
|
+
const extras = new Map;
|
|
50
|
+
for (let index = 0;index < parts.length; index += 1) {
|
|
51
|
+
const part = parts[index];
|
|
52
|
+
if (part === undefined)
|
|
53
|
+
continue;
|
|
54
|
+
const extra = options.validateExtra?.(part);
|
|
55
|
+
if (extra !== undefined) {
|
|
56
|
+
extras.set(index, extra);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (part.type === "text")
|
|
60
|
+
continue;
|
|
61
|
+
if (part.type !== "file") {
|
|
62
|
+
throw new TypeError(`${options.driverLabel} sends ${accepted}, received ${part.type}`);
|
|
63
|
+
}
|
|
64
|
+
if (!("mediaType" in part) || typeof part.mediaType !== "string" || !isSupportedImageMediaType(part.mediaType)) {
|
|
65
|
+
const mediaType = "mediaType" in part ? String(part.mediaType) : "unknown";
|
|
66
|
+
throw new TypeError(`${options.driverLabel} sends PNG, JPEG, GIF or WebP images only, received a file of ${mediaType}`);
|
|
67
|
+
}
|
|
68
|
+
if (options.resolveFile === undefined) {
|
|
69
|
+
throw new TypeError("An image needs resolveFile to read its bytes");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const resolved = [];
|
|
73
|
+
for (let index = 0;index < parts.length; index += 1) {
|
|
74
|
+
const part = parts[index];
|
|
75
|
+
if (part === undefined)
|
|
76
|
+
continue;
|
|
77
|
+
if (extras.has(index)) {
|
|
78
|
+
const extra = extras.get(index);
|
|
79
|
+
if (extra !== undefined)
|
|
80
|
+
resolved.push(extra);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (part.type === "text" && "text" in part && typeof part.text === "string") {
|
|
84
|
+
resolved.push({ type: "text", text: part.text });
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (part.type !== "file" || !("reference" in part) || typeof part.reference !== "string" || !("mediaType" in part) || typeof part.mediaType !== "string" || options.resolveFile === undefined) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const read = resolveImageBytes(part.reference, {
|
|
91
|
+
resolveFile: options.resolveFile,
|
|
92
|
+
maxImageBytes
|
|
93
|
+
});
|
|
94
|
+
const bytes = options.signal ? await raceAbort(read, options.signal) : await read;
|
|
95
|
+
resolved.push({
|
|
96
|
+
type: "image",
|
|
97
|
+
mediaType: part.mediaType,
|
|
98
|
+
base64: bytesToBase64(bytes)
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return resolved;
|
|
102
|
+
}
|
|
103
|
+
function inlineParts(parts, options) {
|
|
104
|
+
return inlineOrderedParts(parts, options);
|
|
105
|
+
}
|
|
106
|
+
function assertImageFrameBytes(serialized, maxBytes) {
|
|
107
|
+
const byteLength = Buffer.byteLength(serialized);
|
|
108
|
+
if (byteLength > maxBytes) {
|
|
109
|
+
throw new RangeError(`Turn input frame is ${byteLength} bytes, over the ${maxBytes}-byte frame limit`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function guardedTurnStarter(options) {
|
|
113
|
+
let preparing = false;
|
|
114
|
+
return async (input) => {
|
|
115
|
+
if (preparing)
|
|
116
|
+
throw new Error(options.busyMessage);
|
|
117
|
+
options.check(input);
|
|
118
|
+
preparing = true;
|
|
119
|
+
let parts;
|
|
120
|
+
try {
|
|
121
|
+
parts = await options.inline(input);
|
|
122
|
+
} finally {
|
|
123
|
+
preparing = false;
|
|
124
|
+
}
|
|
125
|
+
options.check(input);
|
|
126
|
+
return await options.dispatch(input, parts);
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function imageTurnStarter(options) {
|
|
130
|
+
return guardedTurnStarter({
|
|
131
|
+
busyMessage: options.busyMessage,
|
|
132
|
+
check: options.check,
|
|
133
|
+
inline: (input) => inlineParts(input.input, {
|
|
134
|
+
...options.imageOptions,
|
|
135
|
+
driverLabel: options.driverLabel,
|
|
136
|
+
signal: options.signal
|
|
137
|
+
}),
|
|
138
|
+
dispatch: options.dispatch
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export { DEFAULT_MAX_IMAGE_BYTES, CLAUDE_CLI_MAX_LINE_BYTES, isSupportedImageMediaType, validateImageOptions, bytesToBase64, resolveImageBytes, inlineOrderedParts, assertImageFrameBytes, guardedTurnStarter, imageTurnStarter };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rank tool catalog entries against a search query: whole phrase first (exact name → prefix →
|
|
3
|
+
* token-prefix → name substring → description substring), then deduplicated multi-word hits as
|
|
4
|
+
* a deterministic fallback preserving manifest order on ties.
|
|
5
|
+
*/
|
|
6
|
+
export declare function rankToolsByQuery<T extends {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly description: string;
|
|
9
|
+
}>(query: string, entries: readonly T[]): T[];
|
|
10
|
+
//# sourceMappingURL=rank-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rank-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/internal/rank-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EACjE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,EAAE,CAG3C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ProtectedResourceConfig } from '../../server/oauth/metadata.js';
|
|
2
2
|
import type { RawRoute } from '../../server/types.js';
|
|
3
|
-
import { type
|
|
3
|
+
import { type DirectMcpSurfaceConfig, type FiniteMcpSurfaceConfig, type McpServerSharedConfig } from './mount.js';
|
|
4
4
|
import { type McpSurfaceRegistry } from './prepare.js';
|
|
5
5
|
/** Compatibility posture for protocol revisions predating 2026-07-28. */
|
|
6
6
|
export type McpLegacyPolicy = 'serve' | 'reject';
|
|
@@ -31,9 +31,13 @@ export interface McpHttpConfig<TAuth> {
|
|
|
31
31
|
}) => void | Promise<void>;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* Full config for `createMcpHandler`: the shared surface config
|
|
34
|
+
* Full config for `createMcpHandler`: the shared surface config (excluding stateful lazy
|
|
35
|
+
* `discovery`) plus the HTTP auth settings.
|
|
35
36
|
*/
|
|
36
|
-
export type McpHandlerConfig<TAuth, TSurfaces extends McpSurfaceRegistry = McpSurfaceRegistry> =
|
|
37
|
+
export type McpHandlerConfig<TAuth, TSurfaces extends McpSurfaceRegistry = McpSurfaceRegistry> = Omit<McpServerSharedConfig<TAuth>, 'discovery'> & {
|
|
38
|
+
/** Lazy tool discovery requires a stateful MCP session and is refused on stateless HTTP handlers. */
|
|
39
|
+
readonly discovery?: never;
|
|
40
|
+
} & (DirectMcpSurfaceConfig<TAuth> | FiniteMcpSurfaceConfig<TAuth, TSurfaces>) & McpHttpConfig<TAuth>;
|
|
37
41
|
/** Framework-owned Fetch face for one stateless dual-era MCP endpoint. */
|
|
38
42
|
export interface McpHttpHandler {
|
|
39
43
|
fetch(request: Request): Promise<Response>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/tools/mcp/handler.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAOnD,OAAO,EAGL,KAAK,
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/tools/mcp/handler.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,QAAQ,EAAE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sB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,GAC5E,aAAa,CAAC,KAAK,CAAC,CAAC;AAEvB,0EAA0E;AAC1E,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAiFD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EACL,KAAK,CAAC,SAAS,SAAS,kBAAkB,GAAG,kBAAkB,EAC/D,MAAM,EAAE,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,cAAc,CA+F5D;AA8BD,0EAA0E;AAC1E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,QAAQ,CAMX"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { McpServer, RegisteredTool } from '@modelcontextprotocol/server';
|
|
2
|
+
import type { ErrorHintFn, ToolCallHooks, ToolLifecycle } from '../execute-hooks.js';
|
|
3
|
+
import type { McpCatalogStamp } from './catalog-stamp.js';
|
|
4
|
+
/** Opt-in lazy tool discovery configuration for stateful `stitchkit/tools/mcp` mounts. */
|
|
5
|
+
export interface McpLazyDiscoveryConfig {
|
|
6
|
+
readonly mode: 'lazy';
|
|
7
|
+
/** Contract tool names enabled immediately on session start; all other contract tools start disabled. */
|
|
8
|
+
readonly initialTools: readonly string[];
|
|
9
|
+
/** Name of the built-in discovery tool. Default `'tool_search'`. */
|
|
10
|
+
readonly searchToolName?: string;
|
|
11
|
+
/** Maximum matching hidden tools returned and enabled per search call (`1..50`). Default `10`. */
|
|
12
|
+
readonly maxResults?: number;
|
|
13
|
+
}
|
|
14
|
+
/** Normalized lazy discovery parameters returned by {@link validateMcpLazyDiscovery}. */
|
|
15
|
+
export interface ValidatedMcpLazyDiscovery {
|
|
16
|
+
readonly initialTools: ReadonlySet<string>;
|
|
17
|
+
readonly searchToolName: string;
|
|
18
|
+
readonly maxResults: number;
|
|
19
|
+
}
|
|
20
|
+
/** One contract tool handle managed by lazy discovery on a single `McpServer` session. */
|
|
21
|
+
export interface ManagedLazyMcpTool {
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly description: string;
|
|
24
|
+
readonly registered: RegisteredTool;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Synchronously validate `discovery` configuration before any tools are registered on `McpServer`.
|
|
28
|
+
* Refuses unknown `initialTools`, name collisions with contract or runtime tools, and invalid bounds.
|
|
29
|
+
*/
|
|
30
|
+
export declare function validateMcpLazyDiscovery(rawConfig: unknown, contractToolNames: readonly string[], reservedToolNames?: readonly string[]): ValidatedMcpLazyDiscovery;
|
|
31
|
+
/**
|
|
32
|
+
* Hide non-initial contract tools on this `McpServer` session and register the built-in discovery
|
|
33
|
+
* tool through Stitchkit's standard runtime-tool pipeline (`access`, `hooks`, `catalog` stamp).
|
|
34
|
+
*/
|
|
35
|
+
export declare function applyMcpLazyDiscovery(input: {
|
|
36
|
+
readonly server: McpServer;
|
|
37
|
+
readonly discovery: ValidatedMcpLazyDiscovery;
|
|
38
|
+
readonly tools: readonly ManagedLazyMcpTool[];
|
|
39
|
+
readonly lifecycle: ToolLifecycle;
|
|
40
|
+
readonly hooks?: ToolCallHooks;
|
|
41
|
+
readonly context?: Record<string, unknown>;
|
|
42
|
+
readonly catalog?: McpCatalogStamp;
|
|
43
|
+
readonly coerceJsonArgs?: boolean;
|
|
44
|
+
readonly errorHint?: ErrorHintFn;
|
|
45
|
+
readonly onOutputStrip?: (toolName: string, paths: string[]) => void;
|
|
46
|
+
}): void;
|
|
47
|
+
//# sourceMappingURL=lazy-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-discovery.d.ts","sourceRoot":"","sources":["../../../src/tools/mcp/lazy-discovery.ts"],"names":[],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,EAAE,CAAC;IAC9C,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC;IACjC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACtE,GAAG,IAAI,CA+DP"}
|
|
@@ -6,6 +6,7 @@ import { type ToolExtend } from '../mount.js';
|
|
|
6
6
|
import type { RuntimeToolDefinition } from '../runtime-tool-declaration.js';
|
|
7
7
|
import { type McpResourceDef } from './app.js';
|
|
8
8
|
import type { McpCatalogStamp } from './catalog-stamp.js';
|
|
9
|
+
import { type McpLazyDiscoveryConfig } from './lazy-discovery.js';
|
|
9
10
|
import { type McpSchemaValidationConfig, type McpSurfaceRegistry, type PreparedMcpServerSurface, type PreparedMcpSurface, type ValidateMcpSchemasConfig } from './prepare.js';
|
|
10
11
|
import type { McpRoundRuntime } from './round.js';
|
|
11
12
|
/**
|
|
@@ -41,11 +42,15 @@ export interface McpMountConfig {
|
|
|
41
42
|
errorHint?: ErrorHintFn;
|
|
42
43
|
/** Report output keys the contract schema removed — → ADR 0037. */
|
|
43
44
|
onOutputStrip?: (toolName: string, paths: string[]) => void;
|
|
45
|
+
/** Opt-in lazy tool discovery hiding non-initial contract tools behind a built-in search tool. */
|
|
46
|
+
discovery?: McpLazyDiscoveryConfig;
|
|
44
47
|
}
|
|
45
48
|
interface PreparedMcpMountConfig extends McpMountConfig {
|
|
46
49
|
multiRoundRuntime?: McpRoundRuntime;
|
|
47
50
|
/** The catalog this surface advertises, stamped onto listings and results. */
|
|
48
51
|
catalog?: McpCatalogStamp;
|
|
52
|
+
/** Additional tool names mounted on the same server (for example runtime tools) that `searchToolName` cannot collide with. */
|
|
53
|
+
reservedToolNames?: readonly string[];
|
|
49
54
|
}
|
|
50
55
|
/**
|
|
51
56
|
* Validate that every contract tool in `services` can be advertised on the MCP
|
|
@@ -132,6 +137,8 @@ export interface McpServerSharedConfig<TAuth> {
|
|
|
132
137
|
errorHint?: ErrorHintFn;
|
|
133
138
|
/** Report output keys the contract schema removed — → ADR 0037. */
|
|
134
139
|
onOutputStrip?: (toolName: string, paths: string[]) => void;
|
|
140
|
+
/** Opt-in lazy tool discovery hiding non-initial contract tools behind a built-in search tool. */
|
|
141
|
+
discovery?: McpLazyDiscoveryConfig;
|
|
135
142
|
}
|
|
136
143
|
/**
|
|
137
144
|
* Surface config with a fixed or per-identity list of services and runtime tools; cannot be
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../../src/tools/mcp/mount.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EAET,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,KAAK,cAAc,EAAsB,MAAM,OAAO,CAAC;AAEhE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAEL,KAAK,yBAAyB,EAE9B,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,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,sBAAsB,CAAC,KAAK,EAAE,SAAS,SAAS,kBAAkB;IACjF,oEAAoE;IACpE,QAAQ,EAAE,SAAS,CAAC;IACpB,6DAA6D;IAC7D,aAAa,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,MAAM,SAAS,EAAE,MAAM,CAAC,CAAC;IACjE,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,YAAY,CAAC,EAAE,KAAK,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAC9B,KAAK,EACL,SAAS,SAAS,kBAAkB,GAAG,kBAAkB,IACvD,qBAAqB,CAAC,KAAK,CAAC,GAC9B,CAAC,sBAAsB,CAAC,KAAK,CAAC,GAAG,sBAAsB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;AAE7E;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,oBAAoB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;AACnF,wBAAgB,cAAc,CAAC,KAAK,EAClC,MAAM,EAAE,oBAAoB,CAAC,KAAK,CAAC,EACnC,IAAI,EAAE,KAAK,GACV,SAAS,CAAC;AA4Cb;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,eAAe,GAAG,SAAS,CAE/E;AAED,iFAAiF;AACjF,wBAAgB,0BAA0B,CAAC,KAAK,EAC9C,MAAM,EAAE,oBAAoB,CAAC,KAAK,CAAC,EACnC,IAAI,EAAE,KAAK,EACX,QAAQ,EAAE,wBAAwB,GACjC,SAAS,CA4EX;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI,CAmBlF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CallToolResult, type McpServer } from '@modelcontextprotocol/server';
|
|
1
|
+
import { type CallToolResult, type McpServer, type RegisteredTool } from '@modelcontextprotocol/server';
|
|
2
2
|
import type { EndpointUiMeta } from '../../contract/tool-options.js';
|
|
3
3
|
import type { ToolExecutionOptions } from '../execute.js';
|
|
4
4
|
import type { ToolCallHooks, ToolLifecycle } from '../execute-hooks.js';
|
|
@@ -35,5 +35,5 @@ export interface McpToolRegistrationConfig {
|
|
|
35
35
|
* as an `isError` tool result: MCP reserves JSON-RPC errors for the protocol, and
|
|
36
36
|
* a tool's own failure is a result the model can read.
|
|
37
37
|
*/
|
|
38
|
-
export declare function registerMcpTool(server: McpServer, presentation: McpToolPresentation, descriptor: PreparedMcpTool, config: McpToolRegistrationConfig):
|
|
38
|
+
export declare function registerMcpTool(server: McpServer, presentation: McpToolPresentation, descriptor: PreparedMcpTool, config: McpToolRegistrationConfig): RegisteredTool;
|
|
39
39
|
//# sourceMappingURL=register.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/tools/mcp/register.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/tools/mcp/register.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,SAAS,EACd,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,KAAK,EAA2B,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAI3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,KAAK,EAAmB,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,KAAK,UAAU,EAAuB,MAAM,mBAAmB,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAK9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAA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
27
|
Whether an agent pauses for host approval before running a tool is controlled by the agent
|
|
28
28
|
itself, not by ACP: the driver's `approvalEnforcement` is `'agent-initiated'`, meaning it
|
|
29
29
|
answers `session/request_permission` requests when the agent sends them and never synthesizes
|
|
30
|
-
approvals for unprompted tool calls.
|
|
31
|
-
`session/request_permission` in their default configuration; a host that requires interactive
|
|
32
|
-
tool approval must configure the agent's own approval policy (for example `toolPermission: "strict"`
|
|
33
|
-
in the agent's settings under `profile.home`, bearing in mind whether the agent's OAuth session
|
|
34
|
-
is bound to that profile directory).
|
|
30
|
+
approvals for unprompted tool calls. Explicit `approve` supports `scope: 'once'` (selecting `allow_once`), `scope: 'session'` (selecting `allow_always` when the agent advertises one, refusing fail-closed otherwise), or direct `optionId` via `{ kind: 'input', value: { optionId } }`; `approve.updatedInput` and `deny` with `interrupt: true` are refused fail-closed with `TypeError`. Host-specific environment variables (such as `TMPDIR`, `SSH_CONNECTION`, or agent-specific `AGY_*` variables) can be forwarded explicitly via `profile.env`.
|
|
35
31
|
|
|
36
32
|
| Export | Kind | Purpose |
|
|
37
33
|
|--------|------|---------|
|
|
38
|
-
| `createAcpDriver` / `AcpDriver` / `AcpDriverConfig` | function / _types_ | the driver (`approvalEnforcement: 'agent-initiated'`): `executable` and `args`; `
|
|
39
|
-
| `AcpSession` / `AcpConfigOption` / `AcpApprovalEnforcement` | _types_ | a session's settings, title and commands
|
|
34
|
+
| `createAcpDriver` / `AcpDriver` / `AcpDriverConfig` | function / _types_ | the driver (`approvalEnforcement: 'agent-initiated'`): `executable` and `args`; optional `clientInfo`, `sessionMeta`, `stdoutLineFilter`, `probeMode` (`'ephemeral-session' \| 'initialize-only' \| 'passive'`) / `passiveVersion`, `model` / `thoughtLevel` / `mode` (also overridable per open via `AcpOpenInput`, falling back to `session/set_model`), `mcpServers`, `transformUpdate`, post-settle `onUpdate` / `onPermissionRequest`, `onDisconnect`, `watchPromptOutcome`, `usageInputIncludesCachedRead`, `steerMode` (`'none' \| 'prompt'`), `resolveFile`, `maxImageBytes` (5 MiB), `maxFrameBytes` (8 MiB), `ambient`, and `requestTimeoutMs` (60 s, capping `session/close` / `session/delete` to at most 5 s) |
|
|
35
|
+
| `AcpSession` / `AcpOpenInput` / `AcpSteerTurnInput` / `AcpConfigOption` / `AcpApprovalEnforcement` | _types_ | a session's settings, title and commands, `approvalEnforcement` (`'agent-initiated'`), `setConfigOption(category or id, value)`, `respond(interactionId, reply)` for post-settle permissions, `steerTurn(input)` when `steerMode: 'prompt'`, and per-open overrides on `AcpOpenInput` |
|
|
36
|
+
| `AcpProbeMode` / `AcpSteerMode` / `AcpSessionMetaInput` / `AcpWatchPromptOutcome` / `AcpPromptOutcomeOverride` | _types_ | probe strategy, steer mode, static or `initialize`-derived `_meta` attachment on session open, and prompt-outcome verification hook reclassifying masked `end_turn` failures with `errorKind` and `threadDisposition` |
|
|
37
|
+
| `AcpTransformUpdate` / `AcpUpdateEvent` / `AcpPermissionRequestEvent` | _types_ | update normalizer (`transformUpdate`), live/post-settle `session/update` observer payload (`onUpdate`), and out-of-turn permission request payload with `respond()` (`onPermissionRequest`) |
|
|
38
|
+
| `AcpClientInfoSchema` / `AcpClientInfo` / `AcpInitializeResult` / `AcpSessionUpdate` / `AcpPromptResult` / `AcpPromptUsage` / `AcpPermissionRequest` / `AcpPermissionOption` | schema / _types_ | typed ACP v1 wire payloads exposed to `sessionMeta`, `transformUpdate`, `onUpdate`, `onPermissionRequest`, and `watchPromptOutcome` |
|
|
40
39
|
| `AcpSessionSummary` | _type_ | a session the agent keeps: id, working directory, title, last update |
|
|
41
40
|
| `AcpMcpServerSchema` / `AcpMcpServer` | schema / _type_ | an MCP server as ACP v1 names it: a command with arguments and environment, or an `http`/`sse` URL with headers |
|
|
42
|
-
| `ACP_PROTOCOL_VERSION` | constant | `1`;
|
|
41
|
+
| `ACP_PROTOCOL_VERSION` | constant | `1`; ACP v1 agents answering `protocolVersion >= 1` are accepted while protocol `< 1` and ACP v2 responses carrying `"info"` are refused at hello |
|
|
43
42
|
| `acpFakeScenarios` | constant | the conformance scenarios in this dialect, for a scripted agent |
|
|
44
43
|
|
|
45
44
|
A turn's input is text and images: an image `file` part goes as an `image`
|
|
@@ -26,8 +26,10 @@ profile's transcript. Evolving.
|
|
|
26
26
|
|
|
27
27
|
| Export | Kind | Purpose |
|
|
28
28
|
|--------|------|---------|
|
|
29
|
-
| `createClaudeSdkDriver` / `ClaudeSdkDriver` / `ClaudeSdkDriverConfig` | function / _types_ | the driver: `query` and `sdkVersion` required; optional `forkSession`, `model`, `permissionMode` (default `default`), `allowDangerouslySkipPermissions`, `pathToClaudeCodeExecutable`, `systemPrompt`, `settingSources`, `enableFileCheckpointing`, `supportedDialogKinds` / `onUserDialog`, `hooks`, `tools`, `allowedTools`, `disallowedTools`, `mcpServers`, `mcpServersDelivery`, `strictMcpConfig`, `plugins`, `agents`, `extraArgs`, `stderr`, `spawnClaudeCodeProcess`, `onProviderPid`, `verifyDelegation`, `resolveFile`, `maxImageBytes` (default 5 MiB), and `ambient`. `
|
|
30
|
-
| `ClaudeSdkSession` |
|
|
29
|
+
| `createClaudeSdkDriver` / `ClaudeSdkDriver` / `ClaudeSdkDriverConfig` | function / _types_ | the driver: `query` and `sdkVersion` required; optional `forkSession`, `model`, `permissionMode` (default `default`), `allowDangerouslySkipPermissions`, `pathToClaudeCodeExecutable`, `systemPrompt`, `settingSources`, `enableFileCheckpointing`, `supportedDialogKinds` / `onUserDialog`, `hooks`, `tools`, `allowedTools`, `disallowedTools`, `mcpServers`, `mcpServersDelivery`, `strictMcpConfig`, `plugins`, `agents`, `extraArgs`, `stderr`, `spawnClaudeCodeProcess`, `onProviderPid`, `onQueryExit`, `onElicitation`, `onPermissionRequest`, `onEvent`, `onTurnUsage`, `verifyDelegation`, `resolveFile`, `maxImageBytes` (default 5 MiB), and `ambient`. Exposes `probeCapabilities(input)` for isolated never-yielding capability probes, `status` over passive `rate_limit_event` or active `readUsage()`, and `forkSession(sessionId, options?)` |
|
|
30
|
+
| `ClaudeSdkSession` / `ClaudeSdkOpenInput` / `ClaudeSdkUsageRead` / `ClaudeSdkQueryExitContext` / `ClaudeSdkPermissionRequestMeta` | _types_ | extended session returned by `open(ClaudeSdkOpenInput)` (supporting `resumeSessionAt`, `resumeDropsTurn`, and `onStartupPhase`): exposes `providerPid`, `readUsage(opts?)`, `setModel`, `setPermissionMode`, `applyFlagSettings`, `initializationResult`, `supportedModels`, `supportedCommands`, `accountInfo`, `getContextUsage`, `mcpServerStatus`, `toggleMcpServer`, `reconnectMcpServer`, `setMcpServers`, `stopTask`, `backgroundTasks`, and `rewindFiles`; supports `approve` with `updatedInput` for `AskUserQuestion` and emits `ClaudeSdkPermissionRequestMeta` (`toolName`, `toolUseID`, `turnId`, `interactionId`, `input`, `decisionReason`, `blockedPath`, `suggestions`, `requestId`, `title`, `displayName`, `description`, `agentID`, `mcpServer`, `defaultToNo`, `suppressAlwaysAllowRule`, `matchedAskRule`) to `onPermissionRequest` |
|
|
31
|
+
| `ClaudeRuntimeEventSchema` / `ClaudeRuntimeEvent` / `ClaudeTaskUsageSchema` / `ClaudeTaskUsage` / `ClaudeSdkTurnUsageSchema` / `ClaudeSdkTurnUsage` / `ClaudeSdkTokenPairSchema` / `ClaudeSdkTokenPair` | schemas / _types_ | structured runtime events delivered to `onEvent` during and after turns (`task_started`, `task_updated`, `task_progress`, `task_notification`, `background_tasks_changed`, `tool_progress`, `api_retry`, `elicitation_complete`) alongside `compact_boundary` → `window { reset: 'context' }`, plus per-turn additive `modelUsage` deltas and `otherUsage` delivered to `onTurnUsage` |
|
|
32
|
+
| `ClaudeSdkProbeCapabilitiesInput` / `ClaudeSdkCapabilitiesProbe` | _types_ | input and result shapes for `driver.probeCapabilities(input)`: runs an isolated never-yielding SDK query to inspect models, commands, account info, and optional usage, always closing the query in `finally` |
|
|
31
33
|
| `ClaudeSdkDelegationCheck` | _type_ | fail-closed startup verification options (`requireHooksApplied`, `requireNoMcpServers`, `timeoutMs`) enforced at `open()` and on every query restart |
|
|
32
34
|
| `ClaudeSdkQuery` / `ClaudeSdkRun` / `ClaudeSdkForkSession` | _types_ | the SDK `query` / `forkSession` signatures the leaf takes and the subset of a running `Query` it uses; the SDK's own functions fit as they are |
|
|
33
35
|
|