@herbertgao/pi-extensions 2026.9.16 → 2026.9.18
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 +14 -15
- package/node_modules/@herbertgao/pi-bark/package.json +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +4 -1
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +4 -1
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +75 -75
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-subagents/package.json +7 -7
- package/node_modules/@herbertgao/resume-from/package.json +4 -2
- package/node_modules/@herbertgao/sol-pi/package.json +6 -6
- package/node_modules/@herbertgao/sol-pi/src/sol-pi/extensions/online-context-compact/extension.ts +11 -53
- package/node_modules/@juicesharp/rpiv-ask-user-question/package.json +99 -99
- package/node_modules/@pi-plugins/fast-mode/package.json +1 -1
- package/node_modules/@tifan/pi-handoff/package.json +1 -1
- package/node_modules/@tifan/pi-handoff/src/index.ts +56 -26
- package/node_modules/@tifan/pi-mermaid-open/package.json +1 -1
- package/node_modules/@tifan/pi-preferred-thinking/package.json +1 -1
- package/node_modules/@tifan/pi-recap/package.json +1 -1
- package/node_modules/@tifan/pi-rename/package.json +1 -1
- package/node_modules/pi-antigravity/package.json +2 -2
- package/node_modules/pi-lens/package.json +158 -158
- package/node_modules/pi-multi-account/package.json +2 -2
- package/node_modules/pi-typesafe/README.md +1 -1
- package/node_modules/pi-typesafe/dist/auth.d.ts +9 -5
- package/node_modules/pi-typesafe/dist/auth.js +7 -3
- package/node_modules/pi-typesafe/dist/backends.d.ts +33 -3
- package/node_modules/pi-typesafe/dist/backends.js +95 -1
- package/node_modules/pi-typesafe/dist/client.d.ts +5 -5
- package/node_modules/pi-typesafe/dist/client.js +12 -9
- package/node_modules/pi-typesafe/dist/credentials.d.ts +14 -8
- package/node_modules/pi-typesafe/dist/credentials.js +10 -7
- package/node_modules/pi-typesafe/dist/errors.d.ts +2 -2
- package/node_modules/pi-typesafe/dist/index.d.ts +2 -2
- package/node_modules/pi-typesafe/dist/index.js +1 -1
- package/node_modules/pi-typesafe/dist/login.d.ts +2 -2
- package/node_modules/pi-typesafe/dist/login.js +2 -2
- package/node_modules/pi-typesafe/package.json +5 -5
- package/node_modules/pi-web-access/package.json +2 -2
- package/node_modules/remote-pi/package.json +5 -1
- package/package.json +16 -28
- package/node_modules/pi-mcp-adapter/CHANGELOG.md +0 -1013
- package/node_modules/pi-mcp-adapter/LICENSE +0 -21
- package/node_modules/pi-mcp-adapter/OAUTH.md +0 -369
- package/node_modules/pi-mcp-adapter/README.md +0 -1021
- package/node_modules/pi-mcp-adapter/abort.ts +0 -34
- package/node_modules/pi-mcp-adapter/agent-dir.ts +0 -68
- package/node_modules/pi-mcp-adapter/agent-plugin-loader.ts +0 -416
- package/node_modules/pi-mcp-adapter/agent-plugin-provenance.ts +0 -36
- package/node_modules/pi-mcp-adapter/app-bridge.bundle.js +0 -67
- package/node_modules/pi-mcp-adapter/banner.png +0 -0
- package/node_modules/pi-mcp-adapter/bearer-command-resolver.ts +0 -193
- package/node_modules/pi-mcp-adapter/claude-plugin-loader.ts +0 -365
- package/node_modules/pi-mcp-adapter/cli.js +0 -454
- package/node_modules/pi-mcp-adapter/commands.ts +0 -861
- package/node_modules/pi-mcp-adapter/config.ts +0 -1565
- package/node_modules/pi-mcp-adapter/consent-manager.ts +0 -95
- package/node_modules/pi-mcp-adapter/direct-tool-surface.ts +0 -244
- package/node_modules/pi-mcp-adapter/direct-tools.ts +0 -428
- package/node_modules/pi-mcp-adapter/dist/abort.d.ts +0 -2
- package/node_modules/pi-mcp-adapter/dist/abort.js +0 -36
- package/node_modules/pi-mcp-adapter/dist/abort.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/agent-dir.d.ts +0 -10
- package/node_modules/pi-mcp-adapter/dist/agent-dir.js +0 -63
- package/node_modules/pi-mcp-adapter/dist/agent-dir.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/agent-plugin-loader.d.ts +0 -8
- package/node_modules/pi-mcp-adapter/dist/agent-plugin-loader.js +0 -398
- package/node_modules/pi-mcp-adapter/dist/agent-plugin-loader.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/agent-plugin-provenance.d.ts +0 -1
- package/node_modules/pi-mcp-adapter/dist/agent-plugin-provenance.js +0 -31
- package/node_modules/pi-mcp-adapter/dist/agent-plugin-provenance.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.d.ts +0 -6
- package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.js +0 -194
- package/node_modules/pi-mcp-adapter/dist/bearer-command-resolver.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/claude-plugin-loader.d.ts +0 -9
- package/node_modules/pi-mcp-adapter/dist/claude-plugin-loader.js +0 -362
- package/node_modules/pi-mcp-adapter/dist/claude-plugin-loader.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/config.d.ts +0 -134
- package/node_modules/pi-mcp-adapter/dist/config.js +0 -1361
- package/node_modules/pi-mcp-adapter/dist/config.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/consent-manager.d.ts +0 -18
- package/node_modules/pi-mcp-adapter/dist/consent-manager.js +0 -88
- package/node_modules/pi-mcp-adapter/dist/consent-manager.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/elicitation-handler.d.ts +0 -17
- package/node_modules/pi-mcp-adapter/dist/elicitation-handler.js +0 -316
- package/node_modules/pi-mcp-adapter/dist/elicitation-handler.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/errors.d.ts +0 -131
- package/node_modules/pi-mcp-adapter/dist/errors.js +0 -278
- package/node_modules/pi-mcp-adapter/dist/errors.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/http-ca.d.ts +0 -8
- package/node_modules/pi-mcp-adapter/dist/http-ca.js +0 -88
- package/node_modules/pi-mcp-adapter/dist/http-ca.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/jev-client.d.ts +0 -14
- package/node_modules/pi-mcp-adapter/dist/jev-client.js +0 -367
- package/node_modules/pi-mcp-adapter/dist/jev-client.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/jev-contracts.d.ts +0 -77
- package/node_modules/pi-mcp-adapter/dist/jev-contracts.js +0 -2
- package/node_modules/pi-mcp-adapter/dist/jev-contracts.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/jev-key-store.d.ts +0 -51
- package/node_modules/pi-mcp-adapter/dist/jev-key-store.js +0 -205
- package/node_modules/pi-mcp-adapter/dist/jev-key-store.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/json-schema-validator.d.ts +0 -2
- package/node_modules/pi-mcp-adapter/dist/json-schema-validator.js +0 -68
- package/node_modules/pi-mcp-adapter/dist/json-schema-validator.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/lifecycle.d.ts +0 -56
- package/node_modules/pi-mcp-adapter/dist/lifecycle.js +0 -410
- package/node_modules/pi-mcp-adapter/dist/lifecycle.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/logger.d.ts +0 -51
- package/node_modules/pi-mcp-adapter/dist/logger.js +0 -131
- package/node_modules/pi-mcp-adapter/dist/logger.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.d.ts +0 -26
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.js +0 -103
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-fetch.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.d.ts +0 -118
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.js +0 -1097
- package/node_modules/pi-mcp-adapter/dist/mcp-auth-flow.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/mcp-auth.d.ts +0 -170
- package/node_modules/pi-mcp-adapter/dist/mcp-auth.js +0 -1142
- package/node_modules/pi-mcp-adapter/dist/mcp-auth.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.d.ts +0 -24
- package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js +0 -203
- package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.d.ts +0 -53
- package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.js +0 -441
- package/node_modules/pi-mcp-adapter/dist/mcp-callback-server.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.d.ts +0 -148
- package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.js +0 -689
- package/node_modules/pi-mcp-adapter/dist/mcp-oauth-provider.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/mcp-probe.d.ts +0 -6
- package/node_modules/pi-mcp-adapter/dist/mcp-probe.js +0 -166
- package/node_modules/pi-mcp-adapter/dist/mcp-probe.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/mcp-tasks.d.ts +0 -102
- package/node_modules/pi-mcp-adapter/dist/mcp-tasks.js +0 -369
- package/node_modules/pi-mcp-adapter/dist/mcp-tasks.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/mcp-trace.d.ts +0 -95
- package/node_modules/pi-mcp-adapter/dist/mcp-trace.js +0 -242
- package/node_modules/pi-mcp-adapter/dist/mcp-trace.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/metadata-cache.d.ts +0 -19
- package/node_modules/pi-mcp-adapter/dist/metadata-cache.js +0 -301
- package/node_modules/pi-mcp-adapter/dist/metadata-cache.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/npx-resolver.d.ts +0 -6
- package/node_modules/pi-mcp-adapter/dist/npx-resolver.js +0 -505
- package/node_modules/pi-mcp-adapter/dist/npx-resolver.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/package-mcp-loader.d.ts +0 -2
- package/node_modules/pi-mcp-adapter/dist/package-mcp-loader.js +0 -144
- package/node_modules/pi-mcp-adapter/dist/package-mcp-loader.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/request-headers-command.d.ts +0 -10
- package/node_modules/pi-mcp-adapter/dist/request-headers-command.js +0 -312
- package/node_modules/pi-mcp-adapter/dist/request-headers-command.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/resource-tools.d.ts +0 -1
- package/node_modules/pi-mcp-adapter/dist/resource-tools.js +0 -15
- package/node_modules/pi-mcp-adapter/dist/resource-tools.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/runtime-owner.d.ts +0 -13
- package/node_modules/pi-mcp-adapter/dist/runtime-owner.js +0 -97
- package/node_modules/pi-mcp-adapter/dist/runtime-owner.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/sampling-handler.d.ts +0 -17
- package/node_modules/pi-mcp-adapter/dist/sampling-handler.js +0 -203
- package/node_modules/pi-mcp-adapter/dist/sampling-handler.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/secure-keyring.d.ts +0 -11
- package/node_modules/pi-mcp-adapter/dist/secure-keyring.js +0 -172
- package/node_modules/pi-mcp-adapter/dist/secure-keyring.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/server-manager.d.ts +0 -157
- package/node_modules/pi-mcp-adapter/dist/server-manager.js +0 -1745
- package/node_modules/pi-mcp-adapter/dist/server-manager.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/session-approvals.d.ts +0 -34
- package/node_modules/pi-mcp-adapter/dist/session-approvals.js +0 -140
- package/node_modules/pi-mcp-adapter/dist/session-approvals.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/session-recovery.d.ts +0 -26
- package/node_modules/pi-mcp-adapter/dist/session-recovery.js +0 -142
- package/node_modules/pi-mcp-adapter/dist/session-recovery.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/state.d.ts +0 -73
- package/node_modules/pi-mcp-adapter/dist/state.js +0 -2
- package/node_modules/pi-mcp-adapter/dist/state.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/types.d.ts +0 -642
- package/node_modules/pi-mcp-adapter/dist/types.js +0 -331
- package/node_modules/pi-mcp-adapter/dist/types.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/ui-app-bridge-helpers.d.ts +0 -6
- package/node_modules/pi-mcp-adapter/dist/ui-app-bridge-helpers.js +0 -37
- package/node_modules/pi-mcp-adapter/dist/ui-app-bridge-helpers.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.d.ts +0 -17
- package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.js +0 -219
- package/node_modules/pi-mcp-adapter/dist/ui-resource-handler.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/ui-stream-types.d.ts +0 -104
- package/node_modules/pi-mcp-adapter/dist/ui-stream-types.js +0 -59
- package/node_modules/pi-mcp-adapter/dist/ui-stream-types.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/ui-tool-visibility.d.ts +0 -4
- package/node_modules/pi-mcp-adapter/dist/ui-tool-visibility.js +0 -27
- package/node_modules/pi-mcp-adapter/dist/ui-tool-visibility.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.d.ts +0 -15
- package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.js +0 -85
- package/node_modules/pi-mcp-adapter/dist/unix-socket-transport.js.map +0 -1
- package/node_modules/pi-mcp-adapter/dist/utils.d.ts +0 -41
- package/node_modules/pi-mcp-adapter/dist/utils.js +0 -417
- package/node_modules/pi-mcp-adapter/dist/utils.js.map +0 -1
- package/node_modules/pi-mcp-adapter/elicitation-handler.ts +0 -358
- package/node_modules/pi-mcp-adapter/error-signal.ts +0 -32
- package/node_modules/pi-mcp-adapter/errors.ts +0 -364
- package/node_modules/pi-mcp-adapter/examples/jev-accessibility-loop.mjs +0 -85
- package/node_modules/pi-mcp-adapter/examples/jev-semantic-filter.mjs +0 -34
- package/node_modules/pi-mcp-adapter/failure-backoff.ts +0 -23
- package/node_modules/pi-mcp-adapter/glimpse-ui.ts +0 -80
- package/node_modules/pi-mcp-adapter/host-html-template.ts +0 -515
- package/node_modules/pi-mcp-adapter/http-ca.ts +0 -84
- package/node_modules/pi-mcp-adapter/index.ts +0 -2106
- package/node_modules/pi-mcp-adapter/init.ts +0 -721
- package/node_modules/pi-mcp-adapter/jev-client.ts +0 -300
- package/node_modules/pi-mcp-adapter/jev-contracts.ts +0 -53
- package/node_modules/pi-mcp-adapter/jev-key-store.ts +0 -192
- package/node_modules/pi-mcp-adapter/json-schema-validator.ts +0 -83
- package/node_modules/pi-mcp-adapter/lazy-loader.ts +0 -7
- package/node_modules/pi-mcp-adapter/lifecycle.ts +0 -457
- package/node_modules/pi-mcp-adapter/logger.ts +0 -169
- package/node_modules/pi-mcp-adapter/mcp-auth-fetch.ts +0 -113
- package/node_modules/pi-mcp-adapter/mcp-auth-flow.ts +0 -1296
- package/node_modules/pi-mcp-adapter/mcp-auth.ts +0 -1287
- package/node_modules/pi-mcp-adapter/mcp-bearer-store.ts +0 -250
- package/node_modules/pi-mcp-adapter/mcp-callback-server.ts +0 -534
- package/node_modules/pi-mcp-adapter/mcp-code.ts +0 -495
- package/node_modules/pi-mcp-adapter/mcp-install.ts +0 -60
- package/node_modules/pi-mcp-adapter/mcp-keyring-helper.cjs +0 -89
- package/node_modules/pi-mcp-adapter/mcp-oauth-provider.ts +0 -819
- package/node_modules/pi-mcp-adapter/mcp-output-guard.ts +0 -511
- package/node_modules/pi-mcp-adapter/mcp-panel-theme.ts +0 -104
- package/node_modules/pi-mcp-adapter/mcp-panel.ts +0 -1099
- package/node_modules/pi-mcp-adapter/mcp-probe.ts +0 -201
- package/node_modules/pi-mcp-adapter/mcp-references.ts +0 -373
- package/node_modules/pi-mcp-adapter/mcp-script-worker.mjs +0 -137
- package/node_modules/pi-mcp-adapter/mcp-setup-panel.ts +0 -747
- package/node_modules/pi-mcp-adapter/mcp-status.ts +0 -105
- package/node_modules/pi-mcp-adapter/mcp-tasks.ts +0 -467
- package/node_modules/pi-mcp-adapter/mcp-trace.ts +0 -306
- package/node_modules/pi-mcp-adapter/metadata-cache.ts +0 -362
- package/node_modules/pi-mcp-adapter/namespace-tools.ts +0 -334
- package/node_modules/pi-mcp-adapter/npx-resolver.ts +0 -543
- package/node_modules/pi-mcp-adapter/oauth-handler.ts +0 -30
- package/node_modules/pi-mcp-adapter/oauth.ts +0 -52
- package/node_modules/pi-mcp-adapter/onboarding-state.ts +0 -76
- package/node_modules/pi-mcp-adapter/package-mcp-loader.ts +0 -156
- package/node_modules/pi-mcp-adapter/package.json +0 -219
- package/node_modules/pi-mcp-adapter/panel-keys.ts +0 -53
- package/node_modules/pi-mcp-adapter/prompts.ts +0 -385
- package/node_modules/pi-mcp-adapter/proxy-modes.ts +0 -1735
- package/node_modules/pi-mcp-adapter/request-headers-command.ts +0 -333
- package/node_modules/pi-mcp-adapter/resource-tools.ts +0 -17
- package/node_modules/pi-mcp-adapter/runtime-owner.ts +0 -106
- package/node_modules/pi-mcp-adapter/sampling-handler.ts +0 -261
- package/node_modules/pi-mcp-adapter/sandbox-proxy-template.ts +0 -144
- package/node_modules/pi-mcp-adapter/search-ranking.ts +0 -309
- package/node_modules/pi-mcp-adapter/secure-keyring.ts +0 -170
- package/node_modules/pi-mcp-adapter/semantic-search.ts +0 -186
- package/node_modules/pi-mcp-adapter/server-manager.ts +0 -2088
- package/node_modules/pi-mcp-adapter/session-approvals.ts +0 -201
- package/node_modules/pi-mcp-adapter/session-recovery.ts +0 -158
- package/node_modules/pi-mcp-adapter/skills/mcp-scripting/SKILL.md +0 -49
- package/node_modules/pi-mcp-adapter/state.ts +0 -71
- package/node_modules/pi-mcp-adapter/tool-approval.ts +0 -205
- package/node_modules/pi-mcp-adapter/tool-metadata.ts +0 -302
- package/node_modules/pi-mcp-adapter/tool-registrar.ts +0 -255
- package/node_modules/pi-mcp-adapter/tool-result-renderer.ts +0 -573
- package/node_modules/pi-mcp-adapter/ts-shape.ts +0 -149
- package/node_modules/pi-mcp-adapter/types.ts +0 -1120
- package/node_modules/pi-mcp-adapter/ui-app-bridge-helpers.ts +0 -40
- package/node_modules/pi-mcp-adapter/ui-resource-handler.ts +0 -266
- package/node_modules/pi-mcp-adapter/ui-server.ts +0 -993
- package/node_modules/pi-mcp-adapter/ui-session.ts +0 -624
- package/node_modules/pi-mcp-adapter/ui-stream-types.ts +0 -89
- package/node_modules/pi-mcp-adapter/ui-tool-visibility.ts +0 -25
- package/node_modules/pi-mcp-adapter/unix-socket-transport.ts +0 -85
- package/node_modules/pi-mcp-adapter/utils.ts +0 -464
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
import type { AgentToolResult, ExtensionAPI, ToolInfo } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { Type } from "typebox";
|
|
3
|
-
import type { McpExtensionState } from "./state.ts";
|
|
4
|
-
import { isServerDisabled, type McpConfig } from "./types.ts";
|
|
5
|
-
import { isServerCacheValid, type MetadataCache } from "./metadata-cache.ts";
|
|
6
|
-
import { createMcpProxyToolCallRenderer, createMcpToolResultRenderer, resolveMcpToolRenderOptions, type McpToolRenderOptions, type RenderTheme, type McpToolRenderContext } from "./tool-result-renderer.ts";
|
|
7
|
-
export { namespaceProxyName } from "./mcp-references.ts";
|
|
8
|
-
import { hasCallableCachedTargets, isMcpServerDirectlyRegistered, namespaceProxyName, type DirectToolSelectorOverride } from "./mcp-references.ts";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Namespace-proxy tool registration for proxy-only MCP servers.
|
|
12
|
-
*
|
|
13
|
-
* For each configured proxy-only server (no `directTools: true` and not a
|
|
14
|
-
* runtime server forced direct), register exactly one tool named
|
|
15
|
-
* `mcp__<server>` (matching the harness `_shared/mcp-tools` resolver's
|
|
16
|
-
* `namespaceProxyName`). Its execute accepts `{tool, args}` and forwards
|
|
17
|
-
* through the adapter's existing `executeCall`, so it inherits the same
|
|
18
|
-
* auto-auth, session recovery, output guard, and approval rules as the
|
|
19
|
-
* single `mcp` proxy tool — without polluting the prompt with one entry
|
|
20
|
-
* per tool.
|
|
21
|
-
*
|
|
22
|
-
* This unblocks `mcp:<server>` references from `tool-groups` and
|
|
23
|
-
* `slow-mode` against proxy-only servers without flipping `directTools: true`.
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
export interface NamespaceProxySpec {
|
|
27
|
-
serverName: string;
|
|
28
|
-
toolName: string;
|
|
29
|
-
description: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function namespaceProxyCandidate(
|
|
33
|
-
config: McpConfig,
|
|
34
|
-
cache: MetadataCache,
|
|
35
|
-
envOverride: DirectToolSelectorOverride | null,
|
|
36
|
-
existingDirectNames: Set<string>,
|
|
37
|
-
serverName: string,
|
|
38
|
-
): NamespaceProxySpec | null {
|
|
39
|
-
const definition = config.mcpServers[serverName];
|
|
40
|
-
if (!definition || isServerDisabled(definition)) return null;
|
|
41
|
-
if (isMcpServerDirectlyRegistered(definition, config.settings, serverName, envOverride)) return null;
|
|
42
|
-
const entry = cache.servers?.[serverName];
|
|
43
|
-
if (!entry || !isServerCacheValid(entry, definition) || !hasCallableCachedTargets(entry, definition)) return null;
|
|
44
|
-
const toolName = namespaceProxyName(serverName);
|
|
45
|
-
if (existingDirectNames.has(toolName)) return null;
|
|
46
|
-
return {
|
|
47
|
-
serverName,
|
|
48
|
-
toolName,
|
|
49
|
-
description:
|
|
50
|
-
`Namespace-proxy for MCP server "${serverName}". ` +
|
|
51
|
-
`Forwards \`{tool, args}\` through the adapter's executeCall, so it inherits ` +
|
|
52
|
-
`the same auth / lifecycle / output-guard rules as the \`mcp\` proxy.`,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function filterCollidingNamespaceProxyTools(candidates: NamespaceProxySpec[]): NamespaceProxySpec[] {
|
|
57
|
-
const names = new Map<string, NamespaceProxySpec[]>();
|
|
58
|
-
for (const spec of candidates) {
|
|
59
|
-
const colliding = names.get(spec.toolName) ?? [];
|
|
60
|
-
colliding.push(spec);
|
|
61
|
-
names.set(spec.toolName, colliding);
|
|
62
|
-
}
|
|
63
|
-
return candidates.filter((spec) => {
|
|
64
|
-
const colliding = names.get(spec.toolName)!;
|
|
65
|
-
if (colliding.length === 1) return true;
|
|
66
|
-
if (colliding[0] === spec) {
|
|
67
|
-
console.warn(`MCP: skipping namespace proxy "${spec.toolName}" because servers ${colliding.map(({ serverName }) => `"${serverName}"`).sort().join(", ")} normalize to the same name`);
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function resolveNamespaceProxyTools(
|
|
74
|
-
config: McpConfig | null,
|
|
75
|
-
cache: MetadataCache | null,
|
|
76
|
-
envOverride: DirectToolSelectorOverride | null,
|
|
77
|
-
existingDirectNames: Set<string>,
|
|
78
|
-
unavailableServers: ReadonlySet<string>,
|
|
79
|
-
): NamespaceProxySpec[] {
|
|
80
|
-
if (!config || !cache || config.settings?.namespaceProxyTools === false) return [];
|
|
81
|
-
return filterCollidingNamespaceProxyTools(
|
|
82
|
-
Object.keys(config.mcpServers)
|
|
83
|
-
.map((serverName) => namespaceProxyCandidate(config, cache, envOverride, existingDirectNames, serverName))
|
|
84
|
-
.filter((spec): spec is NamespaceProxySpec => spec !== null),
|
|
85
|
-
).filter((spec) => !unavailableServers.has(spec.serverName));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Lazily-required reference to the agent state — passed as a closure so the
|
|
90
|
-
* namespace proxy tool's execute can call `executeCall` once `state` exists.
|
|
91
|
-
* `getInitPromise` lets the executor await the first initialization round
|
|
92
|
-
* the same way `createDirectToolExecutor` does.
|
|
93
|
-
*/
|
|
94
|
-
export type GetState = () => McpExtensionState | null;
|
|
95
|
-
export type GetInitPromise = () => Promise<McpExtensionState> | null;
|
|
96
|
-
export type GetPiTools = () => ToolInfo[];
|
|
97
|
-
export type EnsureNamespaceRuntime = (ctx: unknown) => Promise<McpExtensionState | null>;
|
|
98
|
-
export type ExecuteNamespaceCall = (
|
|
99
|
-
state: McpExtensionState,
|
|
100
|
-
toolName: string,
|
|
101
|
-
args: Record<string, unknown>,
|
|
102
|
-
serverName: string,
|
|
103
|
-
getPiTools: GetPiTools,
|
|
104
|
-
signal: AbortSignal | undefined,
|
|
105
|
-
origin: "proxy",
|
|
106
|
-
) => Promise<AgentToolResult<Record<string, unknown>>>;
|
|
107
|
-
|
|
108
|
-
function namespaceExecute(
|
|
109
|
-
getState: GetState,
|
|
110
|
-
getInitPromise: GetInitPromise,
|
|
111
|
-
ensureRuntime: EnsureNamespaceRuntime | undefined,
|
|
112
|
-
executeCall: ExecuteNamespaceCall,
|
|
113
|
-
serverName: string,
|
|
114
|
-
getPiTools: GetPiTools,
|
|
115
|
-
) {
|
|
116
|
-
return async (
|
|
117
|
-
_toolCallId: string,
|
|
118
|
-
params: { tool?: string; args?: Record<string, unknown> },
|
|
119
|
-
signal: AbortSignal | undefined,
|
|
120
|
-
_onUpdate: unknown,
|
|
121
|
-
ctx: unknown,
|
|
122
|
-
): Promise<AgentToolResult<Record<string, unknown>>> => {
|
|
123
|
-
if (typeof params.tool !== "string" || params.tool.length === 0) {
|
|
124
|
-
return {
|
|
125
|
-
content: [{ type: "text" as const, text: `mcp__${serverName} requires a \`tool\` parameter naming the underlying MCP tool.` }],
|
|
126
|
-
details: { error: "missing_tool", server: serverName },
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
let state = getState();
|
|
130
|
-
if (!state && ensureRuntime) {
|
|
131
|
-
try {
|
|
132
|
-
state = await ensureRuntime(ctx);
|
|
133
|
-
} catch (error) {
|
|
134
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
135
|
-
return {
|
|
136
|
-
content: [{ type: "text" as const, text: `MCP initialization failed for ${serverName}: ${message}` }],
|
|
137
|
-
details: { error: "init_failed", server: serverName, message },
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (!state) {
|
|
142
|
-
const initPromise = getInitPromise();
|
|
143
|
-
if (initPromise) {
|
|
144
|
-
try {
|
|
145
|
-
state = await initPromise;
|
|
146
|
-
} catch (error) {
|
|
147
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
148
|
-
return {
|
|
149
|
-
content: [{ type: "text" as const, text: `MCP initialization failed for ${serverName}: ${message}` }],
|
|
150
|
-
details: { error: "init_failed", server: serverName, message },
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (!state) {
|
|
156
|
-
return {
|
|
157
|
-
content: [{ type: "text" as const, text: `MCP not initialized for ${serverName}.` }],
|
|
158
|
-
details: { error: "not_initialized", server: serverName },
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
return executeCall(
|
|
162
|
-
state,
|
|
163
|
-
params.tool,
|
|
164
|
-
params.args ?? {},
|
|
165
|
-
serverName,
|
|
166
|
-
getPiTools,
|
|
167
|
-
signal,
|
|
168
|
-
"proxy",
|
|
169
|
-
);
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const parameters = Type.Object({
|
|
174
|
-
tool: Type.String({ description: "Underlying MCP tool name to call on this server." }),
|
|
175
|
-
args: Type.Optional(Type.Object({}, {
|
|
176
|
-
additionalProperties: true,
|
|
177
|
-
description: "Arguments for the underlying tool. When mcp is available, use mcp({ search: '...' }) to inspect schemas; for unique names use mcp({ describe: 'tool_name' }) with the exact tool name returned by search.",
|
|
178
|
-
})),
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
export interface SyncNamespaceProxyToolsInput {
|
|
182
|
-
config: McpConfig | null;
|
|
183
|
-
cache: MetadataCache | null;
|
|
184
|
-
envOverride: DirectToolSelectorOverride | null;
|
|
185
|
-
existingDirectNames: Set<string>;
|
|
186
|
-
activeDirectNames?: ReadonlySet<string>;
|
|
187
|
-
existingNamespaceNames: Set<string>;
|
|
188
|
-
unavailableServers?: ReadonlySet<string>;
|
|
189
|
-
pi: ExtensionAPI;
|
|
190
|
-
getState: GetState;
|
|
191
|
-
getInitPromise: GetInitPromise;
|
|
192
|
-
ensureRuntime?: EnsureNamespaceRuntime;
|
|
193
|
-
executeCall?: ExecuteNamespaceCall;
|
|
194
|
-
getPiTools: GetPiTools;
|
|
195
|
-
renderOptions?: McpToolRenderOptions;
|
|
196
|
-
renderShell?: "self" | "default";
|
|
197
|
-
renderResult?: unknown;
|
|
198
|
-
guardReentrant?: () => void;
|
|
199
|
-
onToolRegistered?: (name: string) => void;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export interface SyncNamespaceProxyToolsResult {
|
|
203
|
-
specs: NamespaceProxySpec[];
|
|
204
|
-
added: string[];
|
|
205
|
-
updated: string[];
|
|
206
|
-
deactivated: string[];
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function createNamespaceRenderCall(renderOptions: McpToolRenderOptions, serverName: string) {
|
|
210
|
-
const renderCall = createMcpProxyToolCallRenderer(renderOptions);
|
|
211
|
-
return (args: { tool?: string; args?: Record<string, unknown> }, theme?: RenderTheme, context?: McpToolRenderContext) => renderCall({
|
|
212
|
-
...(args.tool !== undefined ? { tool: args.tool } : {}),
|
|
213
|
-
...(args.args !== undefined ? { args: args.args } : {}),
|
|
214
|
-
server: serverName,
|
|
215
|
-
}, theme, context);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
let defaultProxyModesPromise: Promise<typeof import("./proxy-modes.ts")> | null = null;
|
|
219
|
-
async function loadDefaultExecuteCall(): Promise<(typeof import("./proxy-modes.ts"))["executeCall"]> {
|
|
220
|
-
defaultProxyModesPromise ??= import("./proxy-modes.ts").catch((error) => {
|
|
221
|
-
defaultProxyModesPromise = null;
|
|
222
|
-
throw error;
|
|
223
|
-
});
|
|
224
|
-
return (await defaultProxyModesPromise).executeCall;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function registerNamespaceProxyTool(
|
|
228
|
-
input: SyncNamespaceProxyToolsInput,
|
|
229
|
-
spec: NamespaceProxySpec,
|
|
230
|
-
renderOptions: McpToolRenderOptions,
|
|
231
|
-
renderShell: "self" | "default",
|
|
232
|
-
renderResult: unknown,
|
|
233
|
-
): void {
|
|
234
|
-
const executeCall = input.executeCall ?? (async (...args: Parameters<ExecuteNamespaceCall>) => {
|
|
235
|
-
const expectedState = args[0];
|
|
236
|
-
const loadedExecuteCall = await loadDefaultExecuteCall();
|
|
237
|
-
if (input.getState() !== expectedState || expectedState.owner?.isActive() === false) {
|
|
238
|
-
throw expectedState.owner?.signal.reason ?? new Error("MCP namespace operation belongs to a stale session");
|
|
239
|
-
}
|
|
240
|
-
return loadedExecuteCall(...args);
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
input.onToolRegistered?.(spec.toolName);
|
|
244
|
-
input.guardReentrant?.();
|
|
245
|
-
(input.pi.registerTool as (tool: unknown) => unknown)({
|
|
246
|
-
name: spec.toolName,
|
|
247
|
-
label: `MCP: ${spec.serverName}`,
|
|
248
|
-
description: spec.description,
|
|
249
|
-
promptSnippet: `MCP namespace proxy for ${spec.serverName}`,
|
|
250
|
-
parameters,
|
|
251
|
-
renderShell,
|
|
252
|
-
renderCall: createNamespaceRenderCall(renderOptions, spec.serverName),
|
|
253
|
-
renderResult,
|
|
254
|
-
execute: namespaceExecute(
|
|
255
|
-
input.getState,
|
|
256
|
-
input.getInitPromise,
|
|
257
|
-
input.ensureRuntime,
|
|
258
|
-
executeCall,
|
|
259
|
-
spec.serverName,
|
|
260
|
-
input.getPiTools,
|
|
261
|
-
),
|
|
262
|
-
});
|
|
263
|
-
input.guardReentrant?.();
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function getActiveToolsForStaleCleanup(pi: ExtensionAPI, staleNames: string[]): string[] | undefined {
|
|
267
|
-
if (staleNames.length === 0) return undefined;
|
|
268
|
-
try {
|
|
269
|
-
return pi.getActiveTools?.();
|
|
270
|
-
} catch (error) {
|
|
271
|
-
if (error instanceof Error && error.message.includes("Action methods cannot be called during extension loading")) return undefined;
|
|
272
|
-
throw error;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
function deactivateStaleNamespaceTools(input: SyncNamespaceProxyToolsInput, nextNames: Set<string>): string[] {
|
|
277
|
-
const activeDirectNames = input.activeDirectNames ?? new Set<string>();
|
|
278
|
-
const staleNames = [...input.existingNamespaceNames].filter(
|
|
279
|
-
(name) => !nextNames.has(name) && !activeDirectNames.has(name),
|
|
280
|
-
);
|
|
281
|
-
const deactivated: string[] = [];
|
|
282
|
-
const unregisterTool = (input.pi as unknown as {
|
|
283
|
-
unregisterTool?: (name: string) => boolean;
|
|
284
|
-
}).unregisterTool;
|
|
285
|
-
for (const stale of staleNames) {
|
|
286
|
-
input.guardReentrant?.();
|
|
287
|
-
const removed = unregisterTool?.(stale);
|
|
288
|
-
input.guardReentrant?.();
|
|
289
|
-
if (removed) deactivated.push(stale);
|
|
290
|
-
}
|
|
291
|
-
input.guardReentrant?.();
|
|
292
|
-
const activeTools = getActiveToolsForStaleCleanup(input.pi, staleNames);
|
|
293
|
-
input.guardReentrant?.();
|
|
294
|
-
if (!activeTools) return deactivated;
|
|
295
|
-
|
|
296
|
-
const stale = new Set(staleNames);
|
|
297
|
-
const nextActiveTools = activeTools.filter((name) => !stale.has(name));
|
|
298
|
-
if (nextActiveTools.length === activeTools.length) return deactivated;
|
|
299
|
-
|
|
300
|
-
input.guardReentrant?.();
|
|
301
|
-
input.pi.setActiveTools(nextActiveTools);
|
|
302
|
-
input.guardReentrant?.();
|
|
303
|
-
for (const name of staleNames) {
|
|
304
|
-
if (!deactivated.includes(name)) deactivated.push(name);
|
|
305
|
-
}
|
|
306
|
-
return deactivated;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Idempotent sync of namespace-proxy tool registrations.
|
|
311
|
-
*/
|
|
312
|
-
export function syncNamespaceProxyTools(input: SyncNamespaceProxyToolsInput): SyncNamespaceProxyToolsResult {
|
|
313
|
-
const specs = resolveNamespaceProxyTools(
|
|
314
|
-
input.config,
|
|
315
|
-
input.cache,
|
|
316
|
-
input.envOverride,
|
|
317
|
-
input.existingDirectNames,
|
|
318
|
-
input.unavailableServers ?? new Set(),
|
|
319
|
-
);
|
|
320
|
-
const nextNames = new Set(specs.map((s) => s.toolName));
|
|
321
|
-
const result: SyncNamespaceProxyToolsResult = { specs, added: [], updated: [], deactivated: [] };
|
|
322
|
-
const renderOptions = input.renderOptions ?? resolveMcpToolRenderOptions();
|
|
323
|
-
const renderShell = input.renderShell ?? (renderOptions.resultRendering === "compact" ? "self" : "default");
|
|
324
|
-
const renderResult = input.renderResult ?? createMcpToolResultRenderer(renderOptions);
|
|
325
|
-
|
|
326
|
-
for (const spec of specs) {
|
|
327
|
-
registerNamespaceProxyTool(input, spec, renderOptions, renderShell, renderResult);
|
|
328
|
-
(input.existingNamespaceNames.has(spec.toolName) ? result.updated : result.added).push(spec.toolName);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
result.deactivated.push(...deactivateStaleNamespaceTools(input, nextNames));
|
|
332
|
-
|
|
333
|
-
return result;
|
|
334
|
-
}
|