@herbertgao/pi-extensions 2026.8.5 → 2026.8.6
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 +5 -5
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +74 -5
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +48 -6
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -3
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +10 -0
- package/node_modules/@herbertgao/pi-subagents/package.json +3 -3
- package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +5 -2
- package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +15 -6
- package/node_modules/@herbertgao/pi-subagents/src/worktree.ts +9 -5
- package/node_modules/@juicesharp/rpiv-ask-user-question/README.md +2 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/ask-user-question.ts +20 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/docs/hosts.md +6 -0
- package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +2 -2
- package/node_modules/@narumitw/pi-btw/README.md +24 -17
- package/node_modules/@narumitw/pi-btw/package.json +5 -5
- package/node_modules/@narumitw/pi-btw/src/btw.ts +4 -2
- package/node_modules/@narumitw/pi-btw/src/menu.ts +33 -13
- package/node_modules/@narumitw/pi-btw/src/settings.ts +22 -2
- package/node_modules/pi-lens/CHANGELOG.md +95 -0
- package/node_modules/pi-lens/dist/clients/advisory-provenance.js +314 -0
- package/node_modules/pi-lens/dist/clients/agent-nudge.js +14 -7
- package/node_modules/pi-lens/dist/clients/biome-client.js +121 -13
- package/node_modules/pi-lens/dist/clients/bus-events-logger.js +62 -6
- package/node_modules/pi-lens/dist/clients/bus-publish.js +11 -3
- package/node_modules/pi-lens/dist/clients/cascade-format.js +57 -2
- package/node_modules/pi-lens/dist/clients/console-guard-install.js +16 -4
- package/node_modules/pi-lens/dist/clients/dead-code-client.js +135 -30
- package/node_modules/pi-lens/dist/clients/dependency-checker.js +19 -7
- package/node_modules/pi-lens/dist/clients/diagnostic-dispositions.js +6 -4
- package/node_modules/pi-lens/dist/clients/diagnostics-publish.js +10 -3
- package/node_modules/pi-lens/dist/clients/dispatch/dispatcher.js +114 -10
- package/node_modules/pi-lens/dist/clients/dispatch/integration.js +101 -16
- package/node_modules/pi-lens/dist/clients/dispatch/runners/lsp.js +37 -4
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/availability-policy.js +226 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/candidate-probe.js +69 -0
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/runner-helpers.js +230 -50
- package/node_modules/pi-lens/dist/clients/dispatch/runners/utils/toolchain-availability.js +97 -0
- package/node_modules/pi-lens/dist/clients/disposition-publish.js +10 -3
- package/node_modules/pi-lens/dist/clients/eval-timestamp.js +17 -0
- package/node_modules/pi-lens/dist/clients/extension-log.js +296 -3
- package/node_modules/pi-lens/dist/clients/fix-worklog.js +5 -1
- package/node_modules/pi-lens/dist/clients/format-events-publish.js +39 -8
- package/node_modules/pi-lens/dist/clients/git-guard.js +18 -21
- package/node_modules/pi-lens/dist/clients/go-client.js +21 -39
- package/node_modules/pi-lens/dist/clients/govulncheck-client.js +116 -7
- package/node_modules/pi-lens/dist/clients/host-ports.js +1 -1
- package/node_modules/pi-lens/dist/clients/installer/index.js +5 -1
- package/node_modules/pi-lens/dist/clients/jscpd-client.js +4 -9
- package/node_modules/pi-lens/dist/clients/knip-client.js +51 -14
- package/node_modules/pi-lens/dist/clients/latency-logger.js +50 -1
- package/node_modules/pi-lens/dist/clients/lens-events.js +56 -25
- package/node_modules/pi-lens/dist/clients/lens-flag-registry.js +8 -0
- package/node_modules/pi-lens/dist/clients/live-bus-emitter.js +45 -2
- package/node_modules/pi-lens/dist/clients/lsp/aggregation.js +30 -4
- package/node_modules/pi-lens/dist/clients/lsp/cascade-tier.js +58 -13
- package/node_modules/pi-lens/dist/clients/lsp/client.js +169 -8
- package/node_modules/pi-lens/dist/clients/lsp/diagnostic-binding.js +29 -0
- package/node_modules/pi-lens/dist/clients/lsp/index.js +264 -66
- package/node_modules/pi-lens/dist/clients/lsp/server.js +247 -60
- package/node_modules/pi-lens/dist/clients/lsp/tsserver-sync.js +96 -0
- package/node_modules/pi-lens/dist/clients/lsp/wait-policy/classification.js +21 -5
- package/node_modules/pi-lens/dist/clients/lsp/wait-policy/strategies.js +18 -3
- package/node_modules/pi-lens/dist/clients/mcp/analyze.js +4 -0
- package/node_modules/pi-lens/dist/clients/mcp/session.js +30 -17
- package/node_modules/pi-lens/dist/clients/model-provider.js +53 -0
- package/node_modules/pi-lens/dist/clients/pipeline.js +29 -2
- package/node_modules/pi-lens/dist/clients/project-diagnostics/fresh-fetch.js +1 -1
- package/node_modules/pi-lens/dist/clients/project-diagnostics/runner-adapters/runner-findings.js +23 -2
- package/node_modules/pi-lens/dist/clients/review-graph/query.js +24 -0
- package/node_modules/pi-lens/dist/clients/run-duration.js +55 -0
- package/node_modules/pi-lens/dist/clients/runtime-agent-end.js +153 -7
- package/node_modules/pi-lens/dist/clients/runtime-context.js +104 -11
- package/node_modules/pi-lens/dist/clients/runtime-coordinator.js +170 -22
- package/node_modules/pi-lens/dist/clients/runtime-session.js +28 -5
- package/node_modules/pi-lens/dist/clients/runtime-tool-result.js +124 -10
- package/node_modules/pi-lens/dist/clients/runtime-turn.js +388 -35
- package/node_modules/pi-lens/dist/clients/rust-client.js +21 -37
- package/node_modules/pi-lens/dist/clients/security-scan-client.js +88 -5
- package/node_modules/pi-lens/dist/clients/sg-runner.js +141 -23
- package/node_modules/pi-lens/dist/clients/smells-rollup.js +18 -11
- package/node_modules/pi-lens/dist/clients/startup-timing.js +7 -1
- package/node_modules/pi-lens/dist/clients/test-runner-client.js +431 -24
- package/node_modules/pi-lens/dist/clients/tool-policy.js +2 -0
- package/node_modules/pi-lens/dist/clients/tool-set-policy.js +76 -0
- package/node_modules/pi-lens/dist/clients/warm-attach.js +17 -0
- package/node_modules/pi-lens/dist/clients/word-index.js +305 -33
- package/node_modules/pi-lens/dist/index.js +4827 -1633
- package/node_modules/pi-lens/dist/mcp/server.js +8 -2
- package/node_modules/pi-lens/dist/tools/activate-tools.js +17 -5
- package/node_modules/pi-lens/dist/tools/ast-grep-replace.js +9 -4
- package/node_modules/pi-lens/dist/tools/lens-diagnostic-mark.js +5 -2
- package/node_modules/pi-lens/dist/tools/lens-diagnostics.js +3 -2
- package/node_modules/pi-lens/dist/tools/lsp-diagnostics.js +62 -7
- package/node_modules/pi-lens/dist/tools/symbol-search.js +1 -1
- package/node_modules/pi-lens/docs/agent-guide.md +38 -13
- package/node_modules/pi-lens/docs/ast-grep_rules_catalog.md +11 -3
- package/node_modules/pi-lens/docs/features.md +14 -1
- package/node_modules/pi-lens/docs/globalconfig.md +11 -0
- package/node_modules/pi-lens/docs/servercapabilities.md +1 -1
- package/node_modules/pi-lens/docs/settings.md +6 -0
- package/node_modules/pi-lens/docs/usage.md +23 -5
- package/node_modules/pi-lens/docs/word-index.md +35 -0
- package/node_modules/pi-lens/package.json +1 -1
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-chained-type-assertions-test.yml +8 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-conditional-empty-object-spread-js-test.yml +9 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-conditional-empty-object-spread-test.yml +9 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-reflect-apply-js-test.yml +7 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-reflect-apply-test.yml +7 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-reflect-get-js-test.yml +8 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-reflect-get-test.yml +8 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rule-tests/no-unknown-laundering-test.yml +11 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-chained-type-assertions.yml +21 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-conditional-empty-object-spread-js.yml +21 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-conditional-empty-object-spread.yml +29 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-reflect-apply-js.yml +9 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-reflect-apply.yml +9 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-reflect-get-js.yml +13 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-reflect-get.yml +16 -0
- package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-unknown-laundering.yml +27 -0
- package/node_modules/pi-lens/scripts/analyze-pi-lens-logs.mjs +79 -0
- package/node_modules/pi-lens/skills/pi-lens-ast-grep/SKILL.md +10 -11
- package/node_modules/pi-lens/skills/pi-lens-lsp-navigation/SKILL.md +22 -22
- package/node_modules/pi-lens/skills/pi-lens-write-ast-grep-rule/SKILL.md +8 -114
- package/node_modules/pi-lens/skills/pi-lens-write-ast-grep-rule/reference.md +129 -0
- package/node_modules/pi-lens/skills/pi-lens-write-tree-sitter-rule/SKILL.md +3 -1
- package/node_modules/pi-mcp-adapter/CHANGELOG.md +13 -0
- package/node_modules/pi-mcp-adapter/README.md +4 -1
- package/node_modules/pi-mcp-adapter/agent-dir.ts +12 -4
- package/node_modules/pi-mcp-adapter/cli.js +25 -4
- package/node_modules/pi-mcp-adapter/config.ts +4 -4
- package/node_modules/pi-mcp-adapter/direct-tools.ts +18 -15
- package/node_modules/pi-mcp-adapter/mcp-setup-panel.ts +2 -1
- package/node_modules/pi-mcp-adapter/metadata-cache.ts +18 -8
- package/node_modules/pi-mcp-adapter/package.json +2 -1
- package/node_modules/pi-mcp-adapter/request-headers-command.ts +336 -0
- package/node_modules/pi-mcp-adapter/server-manager.ts +5 -0
- package/node_modules/pi-mcp-adapter/tool-metadata.ts +38 -18
- package/node_modules/pi-mcp-adapter/types.ts +93 -10
- package/node_modules/pi-web-access/CHANGELOG.md +14 -0
- package/node_modules/pi-web-access/README.md +18 -12
- package/node_modules/pi-web-access/auth-fetch.ts +148 -0
- package/node_modules/pi-web-access/chrome-cookies.ts +110 -23
- package/node_modules/pi-web-access/curator-page.ts +5 -3
- package/node_modules/pi-web-access/curator-server.ts +2 -1
- package/node_modules/pi-web-access/extract.ts +106 -34
- package/node_modules/pi-web-access/fetch-params.ts +17 -3
- package/node_modules/pi-web-access/firecrawl.ts +172 -12
- package/node_modules/pi-web-access/gemini-search.ts +18 -4
- package/node_modules/pi-web-access/index.ts +120 -48
- package/node_modules/pi-web-access/package.json +2 -2
- package/node_modules/pi-web-access/summary-review.ts +11 -5
- package/node_modules/pi-web-access/youtube-extract.ts +2 -2
- package/package.json +9 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-mcp-adapter",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.26.0",
|
|
4
4
|
"description": "MCP (Model Context Protocol) adapter extension for Pi coding agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./index.ts",
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"ui-app-bridge-helpers.ts",
|
|
90
90
|
"config.ts",
|
|
91
91
|
"server-manager.ts",
|
|
92
|
+
"request-headers-command.ts",
|
|
92
93
|
"unix-socket-transport.ts",
|
|
93
94
|
"json-schema-validator.ts",
|
|
94
95
|
"session-recovery.ts",
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { spawn, spawnSync, type ChildProcess } from "node:child_process";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import type { FetchLike } from "@modelcontextprotocol/client";
|
|
4
|
+
import type { HttpRequestHeadersCommand } from "./types.ts";
|
|
5
|
+
import { interpolateEnvVars } from "./utils.ts";
|
|
6
|
+
|
|
7
|
+
const DEFAULT_TIMEOUT_MS = 10_000;
|
|
8
|
+
const MAX_OUTPUT_BYTES = 64 * 1024;
|
|
9
|
+
const USE_PROCESS_GROUP = process.platform !== "win32";
|
|
10
|
+
const CLEANUP_TOKEN_ENV = "PI_MCP_REQUEST_HEADERS_CLEANUP_TOKEN";
|
|
11
|
+
|
|
12
|
+
function isNoSuchProcessError(error: unknown): boolean {
|
|
13
|
+
return typeof error === "object" && error !== null && "code" in error && (error as NodeJS.ErrnoException).code === "ESRCH";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function runPosixPs(args: string[]): { status: number | null; stdout: string } {
|
|
17
|
+
if (process.env.PI_MCP_ADAPTER_TEST_FAIL_PS === "1") return { status: 1, stdout: "" };
|
|
18
|
+
return spawnSync("ps", args, { encoding: "utf8" });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function collectPosixDescendantPids(rootPid: number): number[] {
|
|
22
|
+
const result = runPosixPs(["-axo", "pid=,ppid="]);
|
|
23
|
+
if (result.status !== 0) {
|
|
24
|
+
throw new Error(`HTTP request headers command cleanup failed: ps exited with code ${result.status ?? "unknown"}`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const childrenByParent = new Map<number, number[]>();
|
|
28
|
+
for (const line of result.stdout.split("\n")) {
|
|
29
|
+
const [pidText, ppidText] = line.trim().split(/\s+/, 2);
|
|
30
|
+
const pid = Number(pidText);
|
|
31
|
+
const ppid = Number(ppidText);
|
|
32
|
+
if (!Number.isInteger(pid) || !Number.isInteger(ppid)) continue;
|
|
33
|
+
const children = childrenByParent.get(ppid);
|
|
34
|
+
if (children) children.push(pid);
|
|
35
|
+
else childrenByParent.set(ppid, [pid]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const descendants: number[] = [];
|
|
39
|
+
const stack = [...(childrenByParent.get(rootPid) ?? [])];
|
|
40
|
+
while (stack.length > 0) {
|
|
41
|
+
const pid = stack.pop()!;
|
|
42
|
+
descendants.push(pid);
|
|
43
|
+
stack.push(...(childrenByParent.get(pid) ?? []));
|
|
44
|
+
}
|
|
45
|
+
return descendants;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function collectPosixCleanupTokenPids(cleanupToken: string): number[] {
|
|
49
|
+
const result = runPosixPs(["axeww", "-o", "pid=,command="]);
|
|
50
|
+
if (result.status !== 0) {
|
|
51
|
+
throw new Error(`HTTP request headers command cleanup failed: ps exited with code ${result.status ?? "unknown"}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const needle = `${CLEANUP_TOKEN_ENV}=${cleanupToken}`;
|
|
55
|
+
const pids: number[] = [];
|
|
56
|
+
for (const line of result.stdout.split("\n")) {
|
|
57
|
+
const trimmed = line.trim();
|
|
58
|
+
if (!trimmed.includes(needle)) continue;
|
|
59
|
+
const [pidText] = trimmed.split(/\s+/, 1);
|
|
60
|
+
const pid = Number(pidText);
|
|
61
|
+
if (Number.isInteger(pid) && pid !== process.pid) pids.push(pid);
|
|
62
|
+
}
|
|
63
|
+
return pids;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function assertPosixProcessDiscoveryAvailable(): void {
|
|
67
|
+
collectPosixDescendantPids(process.pid);
|
|
68
|
+
collectPosixCleanupTokenPids(`${process.pid}-preflight`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function isTaskkillNoSuchProcess(result: ReturnType<typeof spawnSync>): boolean {
|
|
72
|
+
return `${result.stdout ?? ""}\n${result.stderr ?? ""}`.toLowerCase().includes("not found");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function signalPid(pid: number, signal: NodeJS.Signals): void {
|
|
76
|
+
try {
|
|
77
|
+
process.kill(pid, signal);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
if (!isNoSuchProcessError(error)) throw error;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function signalProcessGroup(pid: number, signal: NodeJS.Signals): void {
|
|
84
|
+
try {
|
|
85
|
+
process.kill(-pid, signal);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (!isNoSuchProcessError(error)) throw error;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function killRequestHeadersCommand(child: ChildProcess, trackedPosixDescendantPids = new Set<number>(), cleanupToken?: string): void {
|
|
92
|
+
if (process.platform === "win32" && child.pid !== undefined) {
|
|
93
|
+
const result = spawnSync("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
|
|
94
|
+
encoding: "utf8",
|
|
95
|
+
windowsHide: true,
|
|
96
|
+
});
|
|
97
|
+
if (result.status === 0 || isTaskkillNoSuchProcess(result)) return;
|
|
98
|
+
throw new Error(`HTTP request headers command cleanup failed: taskkill exited with code ${result.status ?? "unknown"}`);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (USE_PROCESS_GROUP && child.pid !== undefined) {
|
|
102
|
+
const frozenPids = new Set<number>();
|
|
103
|
+
let cleanupError: Error | undefined;
|
|
104
|
+
try {
|
|
105
|
+
signalProcessGroup(child.pid, "SIGSTOP");
|
|
106
|
+
for (const pid of trackedPosixDescendantPids) {
|
|
107
|
+
signalPid(pid, "SIGSTOP");
|
|
108
|
+
frozenPids.add(pid);
|
|
109
|
+
}
|
|
110
|
+
let stablePasses = 0;
|
|
111
|
+
for (let pass = 0; pass < 16; pass++) {
|
|
112
|
+
const candidates = [
|
|
113
|
+
...collectPosixDescendantPids(child.pid),
|
|
114
|
+
...(cleanupToken ? collectPosixCleanupTokenPids(cleanupToken) : []),
|
|
115
|
+
];
|
|
116
|
+
const newPids = candidates.filter(pid => !frozenPids.has(pid));
|
|
117
|
+
if (newPids.length === 0) {
|
|
118
|
+
stablePasses++;
|
|
119
|
+
if (stablePasses >= 2) return;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
stablePasses = 0;
|
|
123
|
+
for (const pid of newPids) {
|
|
124
|
+
signalPid(pid, "SIGSTOP");
|
|
125
|
+
frozenPids.add(pid);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
cleanupError = new Error("HTTP request headers command cleanup failed: descendant process tree did not stabilize");
|
|
129
|
+
} catch (error) {
|
|
130
|
+
cleanupError = error instanceof Error ? error : new Error(String(error));
|
|
131
|
+
} finally {
|
|
132
|
+
signalProcessGroup(child.pid, "SIGKILL");
|
|
133
|
+
for (const pid of frozenPids) signalPid(pid, "SIGKILL");
|
|
134
|
+
}
|
|
135
|
+
if (cleanupError) throw cleanupError;
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
child.kill("SIGKILL");
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface HttpRequestCommandEnvelope {
|
|
143
|
+
version: 1;
|
|
144
|
+
method: string;
|
|
145
|
+
url: string;
|
|
146
|
+
bodyBase64: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
type CommandResult =
|
|
150
|
+
| { status: "error"; error: Error }
|
|
151
|
+
| { status: "success"; headers: Headers };
|
|
152
|
+
|
|
153
|
+
function resolvedCommand(config: HttpRequestHeadersCommand): {
|
|
154
|
+
command: string;
|
|
155
|
+
args: string[];
|
|
156
|
+
env: NodeJS.ProcessEnv;
|
|
157
|
+
timeoutMs: number;
|
|
158
|
+
} {
|
|
159
|
+
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
160
|
+
throw new Error("HTTP request headers command must be an object");
|
|
161
|
+
}
|
|
162
|
+
if (typeof config.command !== "string" || config.command.trim() === "") {
|
|
163
|
+
throw new Error("HTTP request headers command requires a non-empty command");
|
|
164
|
+
}
|
|
165
|
+
if (config.args !== undefined && (!Array.isArray(config.args) || config.args.some(arg => typeof arg !== "string"))) {
|
|
166
|
+
throw new Error("HTTP request headers command args must be strings");
|
|
167
|
+
}
|
|
168
|
+
if (config.env !== undefined && (
|
|
169
|
+
typeof config.env !== "object"
|
|
170
|
+
|| Array.isArray(config.env)
|
|
171
|
+
|| Object.values(config.env).some(value => typeof value !== "string")
|
|
172
|
+
)) {
|
|
173
|
+
throw new Error("HTTP request headers command env values must be strings");
|
|
174
|
+
}
|
|
175
|
+
const timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
176
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > 60_000) {
|
|
177
|
+
throw new Error("HTTP request headers command timeoutMs must be an integer between 1 and 60000");
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
command: interpolateEnvVars(config.command),
|
|
181
|
+
args: (config.args ?? []).map(interpolateEnvVars),
|
|
182
|
+
env: {
|
|
183
|
+
...process.env,
|
|
184
|
+
...Object.fromEntries(
|
|
185
|
+
Object.entries(config.env ?? {}).map(([key, value]) => [key, interpolateEnvVars(value)]),
|
|
186
|
+
),
|
|
187
|
+
},
|
|
188
|
+
timeoutMs,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async function invokeRequestHeadersCommand(
|
|
193
|
+
config: HttpRequestHeadersCommand,
|
|
194
|
+
envelope: HttpRequestCommandEnvelope,
|
|
195
|
+
signal: AbortSignal,
|
|
196
|
+
): Promise<Headers> {
|
|
197
|
+
const resolved = resolvedCommand(config);
|
|
198
|
+
if (USE_PROCESS_GROUP) assertPosixProcessDiscoveryAvailable();
|
|
199
|
+
return new Promise<Headers>((resolve, reject) => {
|
|
200
|
+
let stdout = Buffer.alloc(0);
|
|
201
|
+
let settled = false;
|
|
202
|
+
const cleanupToken = randomUUID();
|
|
203
|
+
const child = spawn(resolved.command, resolved.args, {
|
|
204
|
+
env: { ...resolved.env, [CLEANUP_TOKEN_ENV]: cleanupToken },
|
|
205
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
206
|
+
windowsHide: true,
|
|
207
|
+
detached: USE_PROCESS_GROUP,
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
const trackedPosixDescendantPids = new Set<number>();
|
|
211
|
+
let trackingError: Error | undefined;
|
|
212
|
+
const trackPosixDescendants = () => {
|
|
213
|
+
if (!USE_PROCESS_GROUP || child.pid === undefined || settled || trackingError) return;
|
|
214
|
+
try {
|
|
215
|
+
for (const pid of collectPosixDescendantPids(child.pid)) trackedPosixDescendantPids.add(pid);
|
|
216
|
+
for (const pid of collectPosixCleanupTokenPids(cleanupToken)) trackedPosixDescendantPids.add(pid);
|
|
217
|
+
} catch (error) {
|
|
218
|
+
trackingError = error instanceof Error ? error : new Error(String(error));
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
const descendantTracker = USE_PROCESS_GROUP ? setInterval(trackPosixDescendants, 50) : undefined;
|
|
222
|
+
descendantTracker?.unref();
|
|
223
|
+
|
|
224
|
+
const finish = (result: CommandResult) => {
|
|
225
|
+
if (settled) return;
|
|
226
|
+
settled = true;
|
|
227
|
+
clearTimeout(timer);
|
|
228
|
+
if (descendantTracker) clearInterval(descendantTracker);
|
|
229
|
+
signal.removeEventListener("abort", abort);
|
|
230
|
+
if (result.status === "error") reject(result.error);
|
|
231
|
+
else resolve(result.headers);
|
|
232
|
+
};
|
|
233
|
+
const finishAfterKill = (result: CommandResult) => {
|
|
234
|
+
try {
|
|
235
|
+
killRequestHeadersCommand(child, trackedPosixDescendantPids, cleanupToken);
|
|
236
|
+
finish(result);
|
|
237
|
+
} catch (cleanupError) {
|
|
238
|
+
finish({ status: "error", error: cleanupError instanceof Error ? cleanupError : new Error(String(cleanupError)) });
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
const failAfterKill = (message: string) => {
|
|
242
|
+
finishAfterKill({ status: "error", error: trackingError ?? new Error(message) });
|
|
243
|
+
};
|
|
244
|
+
const abort = () => {
|
|
245
|
+
failAfterKill("HTTP request headers command aborted");
|
|
246
|
+
};
|
|
247
|
+
const timer = setTimeout(() => {
|
|
248
|
+
failAfterKill(`HTTP request headers command timed out after ${resolved.timeoutMs}ms`);
|
|
249
|
+
}, resolved.timeoutMs);
|
|
250
|
+
|
|
251
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
252
|
+
if (signal.aborted) {
|
|
253
|
+
abort();
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
child.on("error", () => finish({ status: "error", error: new Error("HTTP request headers command failed to start") }));
|
|
258
|
+
child.stdout.on("data", (chunk: Buffer | string) => {
|
|
259
|
+
if (settled) return;
|
|
260
|
+
stdout = Buffer.concat([stdout, Buffer.from(chunk)]);
|
|
261
|
+
if (stdout.byteLength > MAX_OUTPUT_BYTES) {
|
|
262
|
+
failAfterKill("HTTP request headers command output exceeded 64 KiB");
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
child.on("close", code => {
|
|
266
|
+
if (settled) return;
|
|
267
|
+
if (trackingError) {
|
|
268
|
+
failAfterKill(trackingError.message);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (code !== 0) {
|
|
272
|
+
failAfterKill(`HTTP request headers command exited with code ${code ?? "unknown"}`);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
let parsed: unknown;
|
|
276
|
+
try {
|
|
277
|
+
parsed = JSON.parse(stdout.toString("utf8"));
|
|
278
|
+
} catch {
|
|
279
|
+
finishAfterKill({ status: "error", error: new Error("HTTP request headers command returned invalid JSON") });
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
283
|
+
finishAfterKill({ status: "error", error: new Error("HTTP request headers command must return a JSON object") });
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const entries = Object.entries(parsed);
|
|
287
|
+
if (entries.some(([, value]) => typeof value !== "string")) {
|
|
288
|
+
finishAfterKill({ status: "error", error: new Error("HTTP request headers command values must be strings") });
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
try {
|
|
292
|
+
finishAfterKill({ status: "success", headers: new Headers(entries as Array<[string, string]>) });
|
|
293
|
+
} catch {
|
|
294
|
+
finishAfterKill({ status: "error", error: new Error("HTTP request headers command returned an invalid header") });
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
child.stdin.on("error", () => {});
|
|
299
|
+
child.stdin.end(JSON.stringify(envelope));
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/** Wrap fetch so a trusted command can derive headers from the exact request. */
|
|
304
|
+
export function createRequestHeadersCommandFetch(
|
|
305
|
+
config: HttpRequestHeadersCommand,
|
|
306
|
+
delegate: FetchLike = globalThis.fetch,
|
|
307
|
+
): FetchLike {
|
|
308
|
+
// Validate static configuration before the first request.
|
|
309
|
+
resolvedCommand(config);
|
|
310
|
+
return async (input: URL | RequestInfo, init?: RequestInit): Promise<Response> => {
|
|
311
|
+
const request = new Request(input, init);
|
|
312
|
+
const body = Buffer.from(await request.clone().arrayBuffer());
|
|
313
|
+
const derived = await invokeRequestHeadersCommand(config, {
|
|
314
|
+
version: 1,
|
|
315
|
+
method: request.method.toUpperCase(),
|
|
316
|
+
url: request.url,
|
|
317
|
+
bodyBase64: body.toString("base64"),
|
|
318
|
+
}, request.signal);
|
|
319
|
+
const headers = new Headers(request.headers);
|
|
320
|
+
derived.forEach((value, name) => headers.set(name, value));
|
|
321
|
+
return delegate(new URL(request.url), {
|
|
322
|
+
method: request.method,
|
|
323
|
+
headers,
|
|
324
|
+
...(request.method === "GET" || request.method === "HEAD" ? {} : { body }),
|
|
325
|
+
signal: request.signal,
|
|
326
|
+
cache: request.cache,
|
|
327
|
+
credentials: request.credentials,
|
|
328
|
+
integrity: request.integrity,
|
|
329
|
+
keepalive: request.keepalive,
|
|
330
|
+
mode: request.mode,
|
|
331
|
+
redirect: request.redirect,
|
|
332
|
+
referrer: request.referrer,
|
|
333
|
+
referrerPolicy: request.referrerPolicy,
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
}
|
|
@@ -56,6 +56,7 @@ import {
|
|
|
56
56
|
traceTransportKind,
|
|
57
57
|
wrapTransportWithMcpTrace,
|
|
58
58
|
} from "./mcp-trace.ts";
|
|
59
|
+
import { createRequestHeadersCommandFetch } from "./request-headers-command.ts";
|
|
59
60
|
|
|
60
61
|
const MAX_CAPTURED_STDERR_BYTES = 8 * 1024;
|
|
61
62
|
const MAX_CAPTURED_STDERR_LINES = 3;
|
|
@@ -746,6 +747,9 @@ export class McpServerManager {
|
|
|
746
747
|
}
|
|
747
748
|
|
|
748
749
|
const requestInit = Object.keys(headers).length > 0 ? { headers } : undefined;
|
|
750
|
+
const requestFetch = definition.requestHeadersCommand
|
|
751
|
+
? createRequestHeadersCommandFetch(definition.requestHeadersCommand)
|
|
752
|
+
: undefined;
|
|
749
753
|
const createAuthProvider = (): McpOAuthProvider => new McpOAuthProvider(
|
|
750
754
|
serverName,
|
|
751
755
|
serverUrl,
|
|
@@ -772,6 +776,7 @@ export class McpServerManager {
|
|
|
772
776
|
const authProvider = "provider" in authState ? authState.provider : undefined;
|
|
773
777
|
const transportOptions = {
|
|
774
778
|
...(requestInit !== undefined ? { requestInit } : {}),
|
|
779
|
+
...(requestFetch !== undefined ? { fetch: requestFetch } : {}),
|
|
775
780
|
...(authProvider !== undefined ? { authProvider } : {}),
|
|
776
781
|
...(authProvider !== undefined
|
|
777
782
|
&& definition.oauth !== false
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getToolUiResourceUri } from "./ui-app-bridge-helpers.ts";
|
|
2
2
|
import type { McpExtensionState } from "./state.ts";
|
|
3
3
|
import type { ToolMetadata, McpTool, McpResource, ServerEntry, ToolPrefix } from "./types.ts";
|
|
4
|
-
import { formatToolName, getToolNameCandidates, isToolAllowed, resolveToolPrefix } from "./types.ts";
|
|
4
|
+
import { createToolSelectorCandidateIndex, formatToolName, getToolNameCandidates, isToolAllowed, resolveToolPrefix } from "./types.ts";
|
|
5
5
|
import { resourceNameToToolName } from "./resource-tools.ts";
|
|
6
6
|
import { extractToolUiStreamMode } from "./utils.ts";
|
|
7
7
|
import { extractUiToolVisibility, isUiToolVisibleToModel } from "./ui-tool-visibility.ts";
|
|
@@ -20,48 +20,68 @@ export function buildToolMetadata(
|
|
|
20
20
|
const failedTools: string[] = [];
|
|
21
21
|
const seenNames = new Set<string>();
|
|
22
22
|
const effectivePrefix = resolveToolPrefix(definition, prefix);
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const hasToolFilters =
|
|
24
|
+
(Array.isArray(definition.includeTools) && definition.includeTools.length > 0) ||
|
|
25
|
+
(Array.isArray(definition.excludeTools) && definition.excludeTools.length > 0);
|
|
26
|
+
const selectorCandidateIndex = hasToolFilters && configuredServers ? (() => {
|
|
25
27
|
const candidates = new Set<string>();
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
+
const additionalCandidatesByToolName = new Map<string, Set<string>>();
|
|
29
|
+
const evaluatedToolNames = new Set<string>();
|
|
30
|
+
const addCandidates = (
|
|
31
|
+
target: Set<string>,
|
|
32
|
+
originalName: string,
|
|
33
|
+
candidateServerName: string,
|
|
34
|
+
candidatePrefix: ToolPrefix,
|
|
35
|
+
) => {
|
|
36
|
+
for (const candidate of getToolNameCandidates(originalName, candidateServerName, candidatePrefix, false)) target.add(candidate);
|
|
28
37
|
};
|
|
29
38
|
|
|
30
39
|
for (const tool of tools) {
|
|
31
|
-
if (tool?.name)
|
|
40
|
+
if (!tool?.name) continue;
|
|
41
|
+
evaluatedToolNames.add(tool.name);
|
|
42
|
+
addCandidates(candidates, tool.name, serverName, effectivePrefix);
|
|
32
43
|
}
|
|
33
44
|
if (definition.exposeResources !== false) {
|
|
34
45
|
for (const resource of resources) {
|
|
35
|
-
|
|
46
|
+
const baseName = `read_${resourceNameToToolName(resource.name)}`;
|
|
47
|
+
evaluatedToolNames.add(baseName);
|
|
48
|
+
if (resource?.name && resource?.uri) addCandidates(candidates, baseName, serverName, effectivePrefix);
|
|
36
49
|
}
|
|
37
50
|
}
|
|
38
51
|
for (const [otherServerName, otherDefinition] of Object.entries(configuredServers)) {
|
|
39
52
|
if (otherServerName === serverName) continue;
|
|
53
|
+
const otherPrefix = resolveToolPrefix(otherDefinition, prefix);
|
|
40
54
|
const knownTools = knownMetadata?.get(otherServerName);
|
|
41
55
|
if (knownTools) {
|
|
42
|
-
const otherPrefix = resolveToolPrefix(otherDefinition, prefix);
|
|
43
56
|
for (const tool of knownTools) {
|
|
44
57
|
candidates.add(tool.name);
|
|
45
|
-
addCandidates(tool.originalName, otherServerName, otherPrefix);
|
|
58
|
+
addCandidates(candidates, tool.originalName, otherServerName, otherPrefix);
|
|
46
59
|
}
|
|
47
60
|
} else if (!knownMetadata || includeMissingConfiguredCandidates) {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
for (const toolName of evaluatedToolNames) {
|
|
62
|
+
let additionalCandidates = additionalCandidatesByToolName.get(toolName);
|
|
63
|
+
if (!additionalCandidates) {
|
|
64
|
+
additionalCandidates = new Set<string>();
|
|
65
|
+
additionalCandidatesByToolName.set(toolName, additionalCandidates);
|
|
66
|
+
}
|
|
67
|
+
addCandidates(additionalCandidates, toolName, otherServerName, otherPrefix);
|
|
68
|
+
if (includeMissingConfiguredCandidates) {
|
|
69
|
+
for (const candidate of getToolNameCandidates(toolName, otherServerName, otherPrefix, false)) {
|
|
70
|
+
additionalCandidates.add(candidate.replace(/-/g, "_"));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
52
73
|
}
|
|
53
74
|
}
|
|
54
75
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
76
|
+
return createToolSelectorCandidateIndex(candidates, additionalCandidatesByToolName);
|
|
77
|
+
})() : undefined;
|
|
58
78
|
|
|
59
79
|
for (const tool of tools) {
|
|
60
80
|
if (!tool?.name) {
|
|
61
81
|
failedTools.push("(unnamed)");
|
|
62
82
|
continue;
|
|
63
83
|
}
|
|
64
|
-
if (!isToolAllowed(tool.name, serverName, effectivePrefix, definition.includeTools, definition.excludeTools,
|
|
84
|
+
if (!isToolAllowed(tool.name, serverName, effectivePrefix, definition.includeTools, definition.excludeTools, selectorCandidateIndex)) {
|
|
65
85
|
continue;
|
|
66
86
|
}
|
|
67
87
|
|
|
@@ -97,7 +117,7 @@ export function buildToolMetadata(
|
|
|
97
117
|
if (definition.exposeResources !== false) {
|
|
98
118
|
for (const resource of resources) {
|
|
99
119
|
const baseName = `read_${resourceNameToToolName(resource.name)}`;
|
|
100
|
-
if (!isToolAllowed(baseName, serverName, effectivePrefix, definition.includeTools, definition.excludeTools,
|
|
120
|
+
if (!isToolAllowed(baseName, serverName, effectivePrefix, definition.includeTools, definition.excludeTools, selectorCandidateIndex)) {
|
|
101
121
|
continue;
|
|
102
122
|
}
|
|
103
123
|
|
|
@@ -356,6 +356,19 @@ export interface OAuthConfig {
|
|
|
356
356
|
skipIssuerMetadataValidation?: boolean;
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
+
/**
|
|
360
|
+
* Trusted executable invoked for every outbound HTTP request. The adapter
|
|
361
|
+
* writes a versioned JSON request envelope to stdin and expects a JSON object
|
|
362
|
+
* containing headers on stdout. This is intended for caller-bound signing
|
|
363
|
+
* schemes whose headers depend on the exact request body.
|
|
364
|
+
*/
|
|
365
|
+
export interface HttpRequestHeadersCommand {
|
|
366
|
+
command: string;
|
|
367
|
+
args?: string[];
|
|
368
|
+
env?: Record<string, string>;
|
|
369
|
+
timeoutMs?: number;
|
|
370
|
+
}
|
|
371
|
+
|
|
359
372
|
// Server configuration
|
|
360
373
|
export interface ServerEntry {
|
|
361
374
|
command?: string;
|
|
@@ -367,6 +380,8 @@ export interface ServerEntry {
|
|
|
367
380
|
// HTTP fields
|
|
368
381
|
url?: string;
|
|
369
382
|
headers?: Record<string, string>;
|
|
383
|
+
/** Add or replace HTTP headers by running a trusted command for each request. */
|
|
384
|
+
requestHeadersCommand?: HttpRequestHeadersCommand;
|
|
370
385
|
/**
|
|
371
386
|
* Authentication type:
|
|
372
387
|
* - 'oauth' - Use OAuth 2.1 (auto-discovers endpoints, supports dynamic client registration)
|
|
@@ -489,6 +504,8 @@ export interface McpSettings {
|
|
|
489
504
|
idleTimeout?: number; // minutes, default 10, 0 to disable
|
|
490
505
|
requestTimeoutMs?: number; // milliseconds, overrides the SDK request timeout when > 0
|
|
491
506
|
directTools?: boolean;
|
|
507
|
+
/** Show the advisory when 75 or more direct tools resolve. Defaults to true. */
|
|
508
|
+
warnOnLargeDirectTools?: boolean;
|
|
492
509
|
/** Register the trusted MCP-only JavaScript scripting tool. Defaults to true; set false to hide it. */
|
|
493
510
|
scriptMode?: boolean;
|
|
494
511
|
/** Render MCP tool results as compact self-rendered rows by default, or as the legacy boxed row. */
|
|
@@ -789,6 +806,25 @@ function globToRegExp(pattern: string): RegExp {
|
|
|
789
806
|
return new RegExp(`^${escaped}$`);
|
|
790
807
|
}
|
|
791
808
|
|
|
809
|
+
export interface ToolSelectorCandidateIndex {
|
|
810
|
+
readonly allCurrentCandidates: ReadonlySet<string>;
|
|
811
|
+
readonly matchingCountByPattern: Map<string, number>;
|
|
812
|
+
readonly matcherByPattern: Map<string, RegExp>;
|
|
813
|
+
readonly additionalCurrentCandidatesByToolName?: ReadonlyMap<string, ReadonlySet<string>>;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
export function createToolSelectorCandidateIndex(
|
|
817
|
+
allCurrentCandidates: Set<string>,
|
|
818
|
+
additionalCurrentCandidatesByToolName?: ReadonlyMap<string, ReadonlySet<string>>,
|
|
819
|
+
): ToolSelectorCandidateIndex {
|
|
820
|
+
return {
|
|
821
|
+
allCurrentCandidates,
|
|
822
|
+
matchingCountByPattern: new Map<string, number>(),
|
|
823
|
+
matcherByPattern: new Map<string, RegExp>(),
|
|
824
|
+
...(additionalCurrentCandidatesByToolName ? { additionalCurrentCandidatesByToolName } : {}),
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
|
|
792
828
|
export function matchesToolPattern(candidates: Set<string>, patterns?: unknown): boolean {
|
|
793
829
|
if (!Array.isArray(patterns) || patterns.length === 0) return false;
|
|
794
830
|
|
|
@@ -805,24 +841,71 @@ export function matchesToolPattern(candidates: Set<string>, patterns?: unknown):
|
|
|
805
841
|
return false;
|
|
806
842
|
}
|
|
807
843
|
|
|
844
|
+
export type ToolSelectorCandidateContext = Set<string> | ToolSelectorCandidateIndex;
|
|
845
|
+
|
|
846
|
+
function indexHasOtherCurrentMatch(
|
|
847
|
+
index: ToolSelectorCandidateIndex,
|
|
848
|
+
toolName: string,
|
|
849
|
+
currentCandidates: Set<string>,
|
|
850
|
+
pattern: string,
|
|
851
|
+
): boolean {
|
|
852
|
+
const additionalCandidates = index.additionalCurrentCandidatesByToolName?.get(toolName);
|
|
853
|
+
const hasCandidate = (candidate: string): boolean =>
|
|
854
|
+
index.allCurrentCandidates.has(candidate) || additionalCandidates?.has(candidate) === true;
|
|
855
|
+
const isGlob = pattern.includes("*") || pattern.includes("?");
|
|
856
|
+
if (!isGlob) {
|
|
857
|
+
return hasCandidate(pattern) && !currentCandidates.has(pattern);
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
let matcher = index.matcherByPattern.get(pattern);
|
|
861
|
+
if (!matcher) {
|
|
862
|
+
matcher = globToRegExp(pattern);
|
|
863
|
+
index.matcherByPattern.set(pattern, matcher);
|
|
864
|
+
}
|
|
865
|
+
let matchingCount = index.matchingCountByPattern.get(pattern);
|
|
866
|
+
if (matchingCount === undefined) {
|
|
867
|
+
matchingCount = 0;
|
|
868
|
+
for (const candidate of index.allCurrentCandidates) {
|
|
869
|
+
if (matcher.test(candidate)) matchingCount++;
|
|
870
|
+
}
|
|
871
|
+
index.matchingCountByPattern.set(pattern, matchingCount);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
let totalMatchingCount = matchingCount;
|
|
875
|
+
if (additionalCandidates) {
|
|
876
|
+
for (const candidate of additionalCandidates) {
|
|
877
|
+
if (!index.allCurrentCandidates.has(candidate) && matcher.test(candidate)) totalMatchingCount++;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
if (totalMatchingCount === 0) return false;
|
|
881
|
+
|
|
882
|
+
let currentMatchingCount = 0;
|
|
883
|
+
for (const candidate of currentCandidates) {
|
|
884
|
+
if (hasCandidate(candidate) && matcher.test(candidate)) currentMatchingCount++;
|
|
885
|
+
}
|
|
886
|
+
return totalMatchingCount > currentMatchingCount;
|
|
887
|
+
}
|
|
888
|
+
|
|
808
889
|
function matchesToolSelector(
|
|
809
890
|
toolName: string,
|
|
810
891
|
serverName: string,
|
|
811
892
|
prefix: ToolPrefix,
|
|
812
893
|
patterns: unknown,
|
|
813
|
-
otherCurrentCandidates?:
|
|
894
|
+
otherCurrentCandidates?: ToolSelectorCandidateContext,
|
|
814
895
|
): boolean {
|
|
896
|
+
if (!Array.isArray(patterns) || patterns.length === 0) return false;
|
|
815
897
|
const currentCandidates = getToolNameCandidates(toolName, serverName, prefix, false);
|
|
816
898
|
if (matchesToolPattern(currentCandidates, patterns)) return true;
|
|
817
899
|
if (!otherCurrentCandidates) return matchesToolPattern(getToolNameCandidates(toolName, serverName, prefix), patterns);
|
|
818
900
|
const legacyCandidates = getToolNameCandidates(toolName, serverName, prefix);
|
|
819
901
|
for (const candidate of currentCandidates) legacyCandidates.delete(candidate);
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
902
|
+
return patterns.some(pattern => {
|
|
903
|
+
if (typeof pattern !== "string" || !matchesToolPattern(legacyCandidates, [pattern])) return false;
|
|
904
|
+
const hasCollision = otherCurrentCandidates instanceof Set
|
|
905
|
+
? matchesToolPattern(otherCurrentCandidates, [pattern])
|
|
906
|
+
: indexHasOtherCurrentMatch(otherCurrentCandidates, toolName, currentCandidates, pattern);
|
|
907
|
+
return !hasCollision;
|
|
908
|
+
});
|
|
826
909
|
}
|
|
827
910
|
|
|
828
911
|
export function isToolIncluded(
|
|
@@ -830,7 +913,7 @@ export function isToolIncluded(
|
|
|
830
913
|
serverName: string,
|
|
831
914
|
prefix: ToolPrefix,
|
|
832
915
|
includeTools?: unknown,
|
|
833
|
-
otherCurrentCandidates?:
|
|
916
|
+
otherCurrentCandidates?: ToolSelectorCandidateContext,
|
|
834
917
|
): boolean {
|
|
835
918
|
if (!Array.isArray(includeTools) || includeTools.length === 0) return true;
|
|
836
919
|
return matchesToolSelector(toolName, serverName, prefix, includeTools, otherCurrentCandidates);
|
|
@@ -841,7 +924,7 @@ export function isToolExcluded(
|
|
|
841
924
|
serverName: string,
|
|
842
925
|
prefix: ToolPrefix,
|
|
843
926
|
excludeTools?: unknown,
|
|
844
|
-
otherCurrentCandidates?:
|
|
927
|
+
otherCurrentCandidates?: ToolSelectorCandidateContext,
|
|
845
928
|
): boolean {
|
|
846
929
|
return matchesToolSelector(toolName, serverName, prefix, excludeTools, otherCurrentCandidates);
|
|
847
930
|
}
|
|
@@ -852,7 +935,7 @@ export function isToolAllowed(
|
|
|
852
935
|
prefix: ToolPrefix,
|
|
853
936
|
includeTools?: unknown,
|
|
854
937
|
excludeTools?: unknown,
|
|
855
|
-
otherCurrentCandidates?:
|
|
938
|
+
otherCurrentCandidates?: ToolSelectorCandidateContext,
|
|
856
939
|
): boolean {
|
|
857
940
|
return isToolIncluded(toolName, serverName, prefix, includeTools, otherCurrentCandidates)
|
|
858
941
|
&& !isToolExcluded(toolName, serverName, prefix, excludeTools, otherCurrentCandidates);
|
|
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.23.0] - 2026-08-15
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Added opt-in `authFetch` profiles for local browser-cookie `fetch_content` requests. Thanks Luka (`@lmilojevicc`) for issue #254.
|
|
11
|
+
- Added Firecrawl as a `web_search` provider using the existing Firecrawl configuration. Thanks Andrés Sanabria (`@andy-spike`) for issue #246.
|
|
12
|
+
- Added macOS Brave profile support for opt-in Gemini Web browser-cookie access. Thanks Rajyavardhan Singh (`@imrajyavardhan12`) for PR #248.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- Made local-video detection use an explicit result state in extraction code.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- Preserve summary draft completion routing through the model registry. Thanks `@limwa` for PR #249.
|
|
19
|
+
- Constrain numeric tool parameters to supported integer ranges. Thanks `@jaudiger` for issue #250 and PR #251.
|
|
20
|
+
|
|
7
21
|
## [0.22.0] - 2026-08-11
|
|
8
22
|
|
|
9
23
|
### Added
|