@herbertgao/pi-extensions 2026.9.17 → 2026.9.19
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 +31 -33
- package/THIRD_PARTY_NOTICES.md +1 -1
- 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/extensions/feature/shell/working-message.ts +21 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/index.ts +15 -4
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/index.ts +43 -7
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +7 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/result.ts +1 -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/@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/README.md +29 -6
- package/node_modules/pi-antigravity/package.json +14 -9
- package/node_modules/pi-antigravity/src/auth/accounts.ts +327 -0
- package/node_modules/pi-antigravity/src/auth/index.ts +9 -0
- package/node_modules/pi-antigravity/src/client/client.ts +1 -1
- package/node_modules/pi-antigravity/src/image/image.ts +4 -4
- package/node_modules/pi-antigravity/src/index.ts +203 -13
- package/node_modules/pi-antigravity/src/search/index.ts +1 -0
- package/node_modules/pi-antigravity/src/search/search.ts +325 -0
- package/node_modules/pi-antigravity/src/stream/stream.ts +191 -14
- package/node_modules/pi-antigravity/src/types/enums.ts +45 -36
- package/node_modules/pi-antigravity/src/types/types.ts +5 -12
- package/node_modules/pi-antigravity/src/utils/http.ts +7 -2
- package/node_modules/pi-antigravity/src/utils/util.ts +31 -3
- 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 +3 -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 +6 -5
- package/node_modules/pi-web-access/CHANGELOG.md +72 -0
- package/node_modules/pi-web-access/README.md +34 -13
- package/node_modules/pi-web-access/chrome-cookies.ts +79 -25
- package/node_modules/pi-web-access/curator-page.ts +5 -1
- package/node_modules/pi-web-access/curator-server.ts +2 -0
- package/node_modules/pi-web-access/dist/index.js +1337 -1009
- package/node_modules/pi-web-access/exa.ts +20 -52
- package/node_modules/pi-web-access/extract.ts +41 -4
- package/node_modules/pi-web-access/gemini-search.ts +12 -4
- package/node_modules/pi-web-access/index.ts +29 -37
- package/node_modules/pi-web-access/openai-search.ts +35 -7
- package/node_modules/pi-web-access/package.json +8 -7
- package/node_modules/pi-web-access/page-query.ts +2 -2
- package/node_modules/pi-web-access/query-rewrite.ts +2 -3
- package/node_modules/pi-web-access/ssrf-protection.ts +27 -10
- package/node_modules/pi-web-access/storage.ts +48 -77
- package/node_modules/pi-web-access/summary-model-scope.ts +6 -77
- package/node_modules/pi-web-access/summary-review.ts +3 -4
- package/node_modules/pi-web-access/tavily.ts +67 -20
- package/node_modules/pi-web-access/tool-activation.ts +53 -33
- package/node_modules/pi-web-access/utils.ts +1 -1
- package/node_modules/pi-web-access/you.ts +164 -0
- package/node_modules/pi-web-access/zai.ts +161 -0
- package/node_modules/remote-pi/package.json +5 -1
- package/package.json +19 -31
- 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,428 +0,0 @@
|
|
|
1
|
-
import type { AgentToolResult, AgentToolUpdateCallback, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { UrlElicitationRequiredError, type Client } from "@modelcontextprotocol/client";
|
|
3
|
-
import type { McpExtensionState } from "./state.ts";
|
|
4
|
-
import type { DirectToolSpec, McpContent } from "./types.ts";
|
|
5
|
-
import { lazyConnect, getFailureAgeSeconds, clearFailure } from "./init.ts";
|
|
6
|
-
import { abortable, throwIfAborted } from "./abort.ts";
|
|
7
|
-
import { formatSchema } from "./tool-metadata.ts";
|
|
8
|
-
import { resolveMcpResultContent, transformMcpResourceContents } from "./tool-registrar.ts";
|
|
9
|
-
import { guardMcpOutput, guardedMcpDetails, resolveMcpOutputGuardOptions } from "./mcp-output-guard.ts";
|
|
10
|
-
import { maybeStartUiSession, summarizeUiSessionResult, type UiSessionRuntime } from "./ui-session.ts";
|
|
11
|
-
import { isServerDisabled } from "./types.ts";
|
|
12
|
-
import { authenticate, supportsOAuth } from "./mcp-auth-flow.ts";
|
|
13
|
-
import { formatAuthRequiredMessage, normalizeToolArguments, resolveServerUrl } from "./utils.ts";
|
|
14
|
-
import { SessionRecoveryAuthRequiredError, withSessionRecovery } from "./session-recovery.ts";
|
|
15
|
-
import { combineAbortSignals, isAbortError } from "./runtime-owner.ts";
|
|
16
|
-
import { callToolViaTaskSession } from "./mcp-tasks.ts";
|
|
17
|
-
import { ensureToolCallApproved } from "./tool-approval.ts";
|
|
18
|
-
import { getInputRequiredNeedsUiDetails } from "./errors.ts";
|
|
19
|
-
|
|
20
|
-
type ClientCallToolResult = Awaited<ReturnType<Client["callTool"]>>;
|
|
21
|
-
type ClientReadResourceResult = Awaited<ReturnType<Client["readResource"]>>;
|
|
22
|
-
|
|
23
|
-
type DirectAutoAuthResult =
|
|
24
|
-
| { status: "skipped" }
|
|
25
|
-
| { status: "success" }
|
|
26
|
-
| { status: "failed"; message: string };
|
|
27
|
-
|
|
28
|
-
export {
|
|
29
|
-
DIRECT_TOOLS_ADVISORY_THRESHOLD,
|
|
30
|
-
buildProxyDescription,
|
|
31
|
-
getLargeDirectToolsAdvisory,
|
|
32
|
-
getMissingConfiguredDirectToolServers,
|
|
33
|
-
prepareDirectToolArguments,
|
|
34
|
-
resolveDirectTools,
|
|
35
|
-
} from "./direct-tool-surface.ts";
|
|
36
|
-
|
|
37
|
-
function getDirectAuthRequiredMessage(
|
|
38
|
-
state: McpExtensionState,
|
|
39
|
-
serverName: string,
|
|
40
|
-
defaultMessage = `MCP server "${serverName}" requires OAuth authentication. Run mcp({ action: "auth-start", server: "${serverName}" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,
|
|
41
|
-
): string {
|
|
42
|
-
return formatAuthRequiredMessage(state.config, serverName, defaultMessage);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function getDirectAuthFailedMessage(state: McpExtensionState, serverName: string, message: string): string {
|
|
46
|
-
const customGuidance = state.config.settings?.authRequiredMessage;
|
|
47
|
-
if (customGuidance) {
|
|
48
|
-
return `OAuth authentication failed for "${serverName}": ${message}. ${getDirectAuthRequiredMessage(state, serverName)}`;
|
|
49
|
-
}
|
|
50
|
-
return `OAuth authentication failed for "${serverName}": ${message}. Run mcp({ action: "auth-start", server: "${serverName}" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async function attemptDirectAutoAuth(
|
|
54
|
-
state: McpExtensionState,
|
|
55
|
-
serverName: string,
|
|
56
|
-
signal?: AbortSignal,
|
|
57
|
-
): Promise<DirectAutoAuthResult> {
|
|
58
|
-
if (state.config.settings?.autoAuth !== true) {
|
|
59
|
-
return { status: "skipped" };
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const definition = state.config.mcpServers[serverName];
|
|
63
|
-
if (!definition || isServerDisabled(definition) || !supportsOAuth(definition)) {
|
|
64
|
-
return { status: "skipped" };
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
let serverUrl: string | undefined;
|
|
68
|
-
try {
|
|
69
|
-
serverUrl = resolveServerUrl(definition);
|
|
70
|
-
} catch (error) {
|
|
71
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
72
|
-
return { status: "failed", message: getDirectAuthFailedMessage(state, serverName, message) };
|
|
73
|
-
}
|
|
74
|
-
if (!serverUrl) {
|
|
75
|
-
return { status: "skipped" };
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const grantType = definition.oauth ? definition.oauth.grantType ?? "authorization_code" : "authorization_code";
|
|
79
|
-
if (!state.ui && grantType !== "client_credentials") {
|
|
80
|
-
return {
|
|
81
|
-
status: "failed",
|
|
82
|
-
message: getDirectAuthRequiredMessage(
|
|
83
|
-
state,
|
|
84
|
-
serverName,
|
|
85
|
-
`MCP server "${serverName}" requires OAuth authentication. Run mcp({ action: "auth-start", server: "${serverName}" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`,
|
|
86
|
-
),
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
if (state.authStorageOptions) {
|
|
92
|
-
await authenticate(
|
|
93
|
-
serverName,
|
|
94
|
-
serverUrl,
|
|
95
|
-
definition,
|
|
96
|
-
signal
|
|
97
|
-
? { authStorageOptions: state.authStorageOptions, signal, runtime: state.oauthRuntime }
|
|
98
|
-
: { authStorageOptions: state.authStorageOptions, runtime: state.oauthRuntime },
|
|
99
|
-
);
|
|
100
|
-
} else {
|
|
101
|
-
await authenticate(serverName, serverUrl, definition, {
|
|
102
|
-
...(signal ? { signal } : {}),
|
|
103
|
-
runtime: state.oauthRuntime,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
return { status: "success" };
|
|
107
|
-
} catch (error) {
|
|
108
|
-
if (isAbortError(error, signal)) throw error;
|
|
109
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
110
|
-
return {
|
|
111
|
-
status: "failed",
|
|
112
|
-
message: getDirectAuthFailedMessage(state, serverName, message),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
type DirectToolExecute = (
|
|
118
|
-
toolCallId: string,
|
|
119
|
-
params: Record<string, unknown>,
|
|
120
|
-
signal: AbortSignal | undefined,
|
|
121
|
-
onUpdate: AgentToolUpdateCallback<Record<string, unknown>> | undefined,
|
|
122
|
-
ctx: ExtensionContext,
|
|
123
|
-
) => Promise<AgentToolResult<Record<string, unknown>>>;
|
|
124
|
-
|
|
125
|
-
export function createDirectToolExecutor(
|
|
126
|
-
getState: () => McpExtensionState | null,
|
|
127
|
-
getInitPromise: () => Promise<McpExtensionState> | null,
|
|
128
|
-
spec: DirectToolSpec
|
|
129
|
-
): DirectToolExecute {
|
|
130
|
-
return async function execute(_toolCallId, params, signal) {
|
|
131
|
-
throwIfAborted(signal);
|
|
132
|
-
let state = getState();
|
|
133
|
-
const initPromise = getInitPromise();
|
|
134
|
-
|
|
135
|
-
if (!state && initPromise) {
|
|
136
|
-
try {
|
|
137
|
-
state = await initPromise;
|
|
138
|
-
} catch (error) {
|
|
139
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
140
|
-
return {
|
|
141
|
-
content: [{ type: "text" as const, text: `MCP initialization failed: ${message}` }],
|
|
142
|
-
details: { error: "init_failed", message },
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (!state) {
|
|
147
|
-
return {
|
|
148
|
-
content: [{ type: "text" as const, text: "MCP not initialized" }],
|
|
149
|
-
details: { error: "not_initialized" },
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const definition = state.config.mcpServers[spec.serverName];
|
|
154
|
-
if (isServerDisabled(definition)) {
|
|
155
|
-
const message = `MCP server "${spec.serverName}" is disabled. Run /mcp enable ${spec.serverName} and /reload to enable it.`;
|
|
156
|
-
return {
|
|
157
|
-
content: [{ type: "text" as const, text: message }],
|
|
158
|
-
details: { error: "server_disabled", server: spec.serverName, message },
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const ownedSignal = combineAbortSignals(state.owner?.signal, signal);
|
|
163
|
-
throwIfAborted(ownedSignal);
|
|
164
|
-
let connected = await lazyConnect(state, spec.serverName, ownedSignal);
|
|
165
|
-
let autoAuthAttempted = false;
|
|
166
|
-
|
|
167
|
-
if (!connected && state.manager.getConnection(spec.serverName)?.status === "needs-auth") {
|
|
168
|
-
autoAuthAttempted = true;
|
|
169
|
-
const autoAuth = await attemptDirectAutoAuth(state, spec.serverName, ownedSignal);
|
|
170
|
-
if (autoAuth.status === "failed") {
|
|
171
|
-
return {
|
|
172
|
-
content: [{ type: "text" as const, text: autoAuth.message }],
|
|
173
|
-
details: { error: "auth_required", server: spec.serverName, message: autoAuth.message },
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
if (autoAuth.status === "success") {
|
|
177
|
-
await state.manager.close(spec.serverName);
|
|
178
|
-
clearFailure(state, spec.serverName);
|
|
179
|
-
connected = await lazyConnect(state, spec.serverName, ownedSignal);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (!connected) {
|
|
184
|
-
const authConnection = state.manager.getConnection(spec.serverName);
|
|
185
|
-
if (authConnection?.status === "needs-auth") {
|
|
186
|
-
const message = getDirectAuthRequiredMessage(state, spec.serverName);
|
|
187
|
-
return {
|
|
188
|
-
content: [{ type: "text" as const, text: message }],
|
|
189
|
-
details: { error: "auth_required", server: spec.serverName, message, autoAuthAttempted },
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
const failedAgo = getFailureAgeSeconds(state, spec.serverName);
|
|
193
|
-
return {
|
|
194
|
-
content: [{ type: "text" as const, text: `MCP server "${spec.serverName}" not available${failedAgo !== null ? ` (failed ${failedAgo}s ago)` : ""}` }],
|
|
195
|
-
details: { error: "server_unavailable", server: spec.serverName },
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const connection = state.manager.getConnection(spec.serverName);
|
|
200
|
-
if (!connection || connection.status !== "connected") {
|
|
201
|
-
return {
|
|
202
|
-
content: [{ type: "text" as const, text: `MCP server "${spec.serverName}" not connected` }],
|
|
203
|
-
details: { error: "not_connected", server: spec.serverName },
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const normalizedParams = spec.resourceUri ? params : normalizeToolArguments(params);
|
|
208
|
-
const approval = await ensureToolCallApproved(state, spec.serverName, {
|
|
209
|
-
name: spec.prefixedName,
|
|
210
|
-
originalName: spec.originalName,
|
|
211
|
-
description: spec.description,
|
|
212
|
-
...(spec.inputSchema !== undefined ? { inputSchema: spec.inputSchema } : {}),
|
|
213
|
-
...(spec.resourceUri !== undefined ? { resourceUri: spec.resourceUri } : {}),
|
|
214
|
-
...(spec.uiResourceUri !== undefined ? { uiResourceUri: spec.uiResourceUri } : {}),
|
|
215
|
-
...(spec.uiStreamMode !== undefined ? { uiStreamMode: spec.uiStreamMode } : {}),
|
|
216
|
-
}, normalizedParams, ownedSignal, spec.resourceUri ? "resource" : "direct");
|
|
217
|
-
if (approval.ok === false) {
|
|
218
|
-
const denied = approval.reason === "denied";
|
|
219
|
-
const message = denied
|
|
220
|
-
? `The user declined approval to run MCP tool "${spec.originalName}" on server "${spec.serverName}".`
|
|
221
|
-
: `MCP tool "${spec.originalName}" on server "${spec.serverName}" is approval-gated and requires an interactive session.`;
|
|
222
|
-
return {
|
|
223
|
-
content: [{ type: "text" as const, text: message }],
|
|
224
|
-
details: {
|
|
225
|
-
error: denied ? "approval_denied" : "approval_required",
|
|
226
|
-
server: spec.serverName,
|
|
227
|
-
tool: spec.originalName,
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
let uiSession: UiSessionRuntime | null = null;
|
|
233
|
-
const requestOptions = state.manager.getRequestOptions?.(spec.serverName, ownedSignal) ?? (ownedSignal ? { signal: ownedSignal } : undefined);
|
|
234
|
-
|
|
235
|
-
const outputGuardOptions = resolveMcpOutputGuardOptions(state.config.settings);
|
|
236
|
-
const recoverAuthConnection = async () => {
|
|
237
|
-
const current = state.manager.getConnection(spec.serverName);
|
|
238
|
-
if (current?.status === "connected") return current;
|
|
239
|
-
|
|
240
|
-
if (!autoAuthAttempted) {
|
|
241
|
-
autoAuthAttempted = true;
|
|
242
|
-
const autoAuth = await attemptDirectAutoAuth(state, spec.serverName, ownedSignal);
|
|
243
|
-
if (autoAuth.status === "failed") {
|
|
244
|
-
throw new SessionRecoveryAuthRequiredError(spec.serverName, autoAuth.message);
|
|
245
|
-
}
|
|
246
|
-
if (autoAuth.status === "success") {
|
|
247
|
-
const afterAuth = state.manager.getConnection(spec.serverName);
|
|
248
|
-
if (afterAuth?.status === "connected") return afterAuth;
|
|
249
|
-
if (afterAuth?.status === "needs-auth") {
|
|
250
|
-
await state.manager.close(spec.serverName);
|
|
251
|
-
}
|
|
252
|
-
clearFailure(state, spec.serverName);
|
|
253
|
-
const reconnected = await lazyConnect(state, spec.serverName, ownedSignal);
|
|
254
|
-
return reconnected ? state.manager.getConnection(spec.serverName) : undefined;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return state.manager.getConnection(spec.serverName);
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
try {
|
|
261
|
-
state.manager.touch(spec.serverName);
|
|
262
|
-
state.manager.incrementInFlight(spec.serverName);
|
|
263
|
-
|
|
264
|
-
if (spec.resourceUri) {
|
|
265
|
-
const result = await withSessionRecovery<ClientReadResourceResult>(
|
|
266
|
-
{
|
|
267
|
-
manager: state.manager,
|
|
268
|
-
config: state.config,
|
|
269
|
-
...(ownedSignal ? { signal: ownedSignal } : {}),
|
|
270
|
-
onNeedsAuth: recoverAuthConnection,
|
|
271
|
-
},
|
|
272
|
-
spec.serverName,
|
|
273
|
-
async (conn) => {
|
|
274
|
-
const refreshRead = await state.manager.prepareResourceUse?.(spec.serverName, spec.resourceUri!, conn);
|
|
275
|
-
return conn.client.readResource(
|
|
276
|
-
{ uri: spec.resourceUri! },
|
|
277
|
-
refreshRead ? { ...requestOptions, cacheMode: "refresh" } : requestOptions,
|
|
278
|
-
);
|
|
279
|
-
},
|
|
280
|
-
);
|
|
281
|
-
const content = transformMcpResourceContents(result.contents ?? [], state.owner?.signal);
|
|
282
|
-
const guarded = await guardMcpOutput(content.length > 0 ? content : [{ type: "text" as const, text: "(empty resource)" }], {
|
|
283
|
-
...outputGuardOptions,
|
|
284
|
-
...(state.config.settings?.directToolResultDetails === "bounded" ? { rawMcpResult: result } : {}),
|
|
285
|
-
});
|
|
286
|
-
return {
|
|
287
|
-
content: guarded.content,
|
|
288
|
-
details: { server: spec.serverName, resourceUri: spec.resourceUri, ...guardedMcpDetails(guarded) },
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const hasUi = !!spec.uiResourceUri;
|
|
293
|
-
uiSession = hasUi
|
|
294
|
-
? await maybeStartUiSession(state, {
|
|
295
|
-
serverName: spec.serverName,
|
|
296
|
-
toolName: spec.originalName,
|
|
297
|
-
toolArgs: normalizedParams,
|
|
298
|
-
uiResourceUri: spec.uiResourceUri!,
|
|
299
|
-
...(spec.uiStreamMode !== undefined ? { streamMode: spec.uiStreamMode } : {}),
|
|
300
|
-
...(signal ? { signal } : {}),
|
|
301
|
-
onNeedsAuth: recoverAuthConnection,
|
|
302
|
-
})
|
|
303
|
-
: null;
|
|
304
|
-
|
|
305
|
-
const result = await withSessionRecovery<ClientCallToolResult>(
|
|
306
|
-
{
|
|
307
|
-
manager: state.manager,
|
|
308
|
-
config: state.config,
|
|
309
|
-
...(ownedSignal ? { signal: ownedSignal } : {}),
|
|
310
|
-
onNeedsAuth: recoverAuthConnection,
|
|
311
|
-
},
|
|
312
|
-
spec.serverName,
|
|
313
|
-
async (conn) => {
|
|
314
|
-
await state.manager.ensureListen?.(spec.serverName, conn);
|
|
315
|
-
if (conn.taskSession) {
|
|
316
|
-
return await callToolViaTaskSession(conn.taskSession, {
|
|
317
|
-
name: spec.originalName,
|
|
318
|
-
args: normalizedParams ?? {},
|
|
319
|
-
meta: uiSession?.requestMeta,
|
|
320
|
-
signal: ownedSignal,
|
|
321
|
-
requestTimeoutMs: requestOptions?.timeout,
|
|
322
|
-
}) as unknown as ClientCallToolResult;
|
|
323
|
-
}
|
|
324
|
-
return abortable(conn.client.callTool({
|
|
325
|
-
name: spec.originalName,
|
|
326
|
-
arguments: normalizedParams,
|
|
327
|
-
_meta: uiSession?.requestMeta,
|
|
328
|
-
}, requestOptions), ownedSignal);
|
|
329
|
-
},
|
|
330
|
-
);
|
|
331
|
-
uiSession?.sendToolResult(result as unknown as import("@modelcontextprotocol/client").CallToolResult);
|
|
332
|
-
|
|
333
|
-
if (result.isError) {
|
|
334
|
-
const content = resolveMcpResultContent(result as Record<string, unknown>, state.owner?.signal);
|
|
335
|
-
const outputContent = content.length > 0 ? content : [{ type: "text" as const, text: "(empty result)" }];
|
|
336
|
-
const guarded = await guardMcpOutput(outputContent, {
|
|
337
|
-
...outputGuardOptions,
|
|
338
|
-
prefix: "Error: ",
|
|
339
|
-
emptyTextFallback: "Tool execution failed",
|
|
340
|
-
...(state.config.settings?.directToolResultDetails === "bounded" ? { rawMcpResult: result } : {}),
|
|
341
|
-
});
|
|
342
|
-
return {
|
|
343
|
-
content: guarded.content,
|
|
344
|
-
details: { error: "tool_error", server: spec.serverName, ...guardedMcpDetails(guarded) },
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
const content = resolveMcpResultContent(result as Record<string, unknown>, state.owner?.signal);
|
|
349
|
-
const outputContent = content.length > 0 ? content : [{ type: "text" as const, text: "(empty result)" }];
|
|
350
|
-
if (hasUi) {
|
|
351
|
-
const uiSummary = summarizeUiSessionResult(uiSession);
|
|
352
|
-
const guarded = await guardMcpOutput(outputContent, {
|
|
353
|
-
...outputGuardOptions,
|
|
354
|
-
suffix: `\n\n${uiSummary.message}`,
|
|
355
|
-
...(state.config.settings?.directToolResultDetails === "bounded" ? { rawMcpResult: result } : {}),
|
|
356
|
-
});
|
|
357
|
-
return {
|
|
358
|
-
content: guarded.content,
|
|
359
|
-
details: {
|
|
360
|
-
server: spec.serverName,
|
|
361
|
-
tool: spec.originalName,
|
|
362
|
-
uiOpen: uiSummary.uiOpen,
|
|
363
|
-
uiViewer: uiSummary.uiViewer,
|
|
364
|
-
uiUrl: uiSummary.uiUrl,
|
|
365
|
-
...guardedMcpDetails(guarded),
|
|
366
|
-
},
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
const guarded = await guardMcpOutput(outputContent, {
|
|
371
|
-
...outputGuardOptions,
|
|
372
|
-
...(state.config.settings?.directToolResultDetails === "bounded" ? { rawMcpResult: result } : {}),
|
|
373
|
-
});
|
|
374
|
-
return {
|
|
375
|
-
content: guarded.content,
|
|
376
|
-
details: { server: spec.serverName, tool: spec.originalName, ...guardedMcpDetails(guarded) },
|
|
377
|
-
};
|
|
378
|
-
} catch (error) {
|
|
379
|
-
if (error instanceof SessionRecoveryAuthRequiredError) {
|
|
380
|
-
const message = error.authMessage ?? getDirectAuthRequiredMessage(state, spec.serverName);
|
|
381
|
-
uiSession?.sendToolCancelled(message);
|
|
382
|
-
return {
|
|
383
|
-
content: [{ type: "text" as const, text: message }],
|
|
384
|
-
details: { error: "auth_required", server: spec.serverName, message, autoAuthAttempted },
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
if (error instanceof UrlElicitationRequiredError) {
|
|
388
|
-
const action = await state.manager.handleUrlElicitationRequired(spec.serverName, error);
|
|
389
|
-
const message = action === "accept"
|
|
390
|
-
? "The original MCP tool did not run. Complete the opened browser interaction, then retry the tool."
|
|
391
|
-
: `The URL interaction was ${action === "decline" ? "declined" : "cancelled"}.`;
|
|
392
|
-
uiSession?.sendToolCancelled(message);
|
|
393
|
-
return {
|
|
394
|
-
content: [{ type: "text" as const, text: message }],
|
|
395
|
-
details: { error: "url_elicitation_required", server: spec.serverName, action },
|
|
396
|
-
};
|
|
397
|
-
}
|
|
398
|
-
const inputRequired = getInputRequiredNeedsUiDetails(error, spec.resourceUri
|
|
399
|
-
? { server: spec.serverName, resourceUri: spec.resourceUri }
|
|
400
|
-
: { server: spec.serverName, tool: spec.originalName });
|
|
401
|
-
if (inputRequired) {
|
|
402
|
-
uiSession?.sendToolCancelled(inputRequired.message);
|
|
403
|
-
return {
|
|
404
|
-
content: [{ type: "text" as const, text: inputRequired.message }],
|
|
405
|
-
details: { ...inputRequired },
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
409
|
-
const aborted = isAbortError(error, ownedSignal);
|
|
410
|
-
if (!aborted) {
|
|
411
|
-
await state.manager.close(spec.serverName).catch(() => {});
|
|
412
|
-
}
|
|
413
|
-
uiSession?.sendToolCancelled(message);
|
|
414
|
-
const schemaText = spec.inputSchema ? `\n\nExpected parameters:\n${formatSchema(spec.inputSchema)}` : "";
|
|
415
|
-
const guarded = await guardMcpOutput([{ type: "text" as const, text: message }], { ...outputGuardOptions, prefix: "Failed to call tool: ", suffix: schemaText });
|
|
416
|
-
return {
|
|
417
|
-
content: guarded.content,
|
|
418
|
-
details: { error: aborted ? "aborted" : "call_failed", server: spec.serverName, ...guardedMcpDetails(guarded) },
|
|
419
|
-
};
|
|
420
|
-
} finally {
|
|
421
|
-
if (uiSession?.reused) {
|
|
422
|
-
uiSession.close();
|
|
423
|
-
}
|
|
424
|
-
state.manager.decrementInFlight(spec.serverName);
|
|
425
|
-
state.manager.touch(spec.serverName);
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export function throwIfAborted(signal) {
|
|
2
|
-
if (!signal?.aborted)
|
|
3
|
-
return;
|
|
4
|
-
throw signal.reason instanceof Error ? signal.reason : new Error(String(signal.reason ?? "MCP request aborted"));
|
|
5
|
-
}
|
|
6
|
-
export async function abortable(promise, signal) {
|
|
7
|
-
if (!signal)
|
|
8
|
-
return promise;
|
|
9
|
-
throwIfAborted(signal);
|
|
10
|
-
return await new Promise((resolve, reject) => {
|
|
11
|
-
let settled = false;
|
|
12
|
-
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
13
|
-
const onAbort = () => {
|
|
14
|
-
if (settled)
|
|
15
|
-
return;
|
|
16
|
-
settled = true;
|
|
17
|
-
cleanup();
|
|
18
|
-
reject(signal.reason instanceof Error ? signal.reason : new Error(String(signal.reason ?? "MCP request aborted")));
|
|
19
|
-
};
|
|
20
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
21
|
-
promise.then(value => {
|
|
22
|
-
if (settled)
|
|
23
|
-
return;
|
|
24
|
-
settled = true;
|
|
25
|
-
cleanup();
|
|
26
|
-
resolve(value);
|
|
27
|
-
}, error => {
|
|
28
|
-
if (settled)
|
|
29
|
-
return;
|
|
30
|
-
settled = true;
|
|
31
|
-
cleanup();
|
|
32
|
-
reject(error);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=abort.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"abort.js","sourceRoot":"","sources":["../abort.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAC,MAAoB;IACjD,IAAI,CAAC,MAAM,EAAE,OAAO;QAAE,OAAO;IAC7B,MAAM,MAAM,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,qBAAqB,CAAC,CAAC,CAAC;AACnH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAI,OAAmB,EAAE,MAAoB;IAC1E,IAAI,CAAC,MAAM;QAAE,OAAO,OAAO,CAAC;IAC5B,cAAc,CAAC,MAAM,CAAC,CAAC;IACvB,OAAO,MAAM,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9C,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACnE,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,OAAO,EAAE,CAAC;YACV,MAAM,CAAC,MAAM,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACrH,CAAC,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CACV,KAAK,CAAC,EAAE;YACN,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,OAAO,EAAE,CAAC;YACV,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC,EACD,KAAK,CAAC,EAAE;YACN,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,OAAO,EAAE,CAAC;YACV,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare function getConfigDirName(): string;
|
|
2
|
-
export declare function getAgentDir(): string;
|
|
3
|
-
export declare function getAgentPath(...segments: string[]): string;
|
|
4
|
-
export declare function getAppName(): string;
|
|
5
|
-
/**
|
|
6
|
-
* Home page the host declares for itself, via `piConfig.clientUri` in the same
|
|
7
|
-
* manifest that carries `piConfig.name`. Only the distribution knows its own
|
|
8
|
-
* URL, so this is the one place it can come from without guessing.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getAppClientUri(): string | undefined;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { join, resolve } from "node:path";
|
|
4
|
-
export function getConfigDirName() {
|
|
5
|
-
const configDir = readPiConfig()?.configDir;
|
|
6
|
-
return typeof configDir === "string" && configDir.trim() ? configDir.trim() : ".pi";
|
|
7
|
-
}
|
|
8
|
-
export function getAgentDir() {
|
|
9
|
-
const piConfig = readPiConfig();
|
|
10
|
-
const name = piConfig?.name;
|
|
11
|
-
const appName = typeof name === "string" && name.trim() ? name.trim() : "pi";
|
|
12
|
-
const configured = process.env[`${appName.toUpperCase()}_CODING_AGENT_DIR`]?.trim();
|
|
13
|
-
if (!configured) {
|
|
14
|
-
return join(homedir(), getConfigDirName(), "agent");
|
|
15
|
-
}
|
|
16
|
-
if (configured === "~") {
|
|
17
|
-
return homedir();
|
|
18
|
-
}
|
|
19
|
-
if (configured.startsWith("~/")) {
|
|
20
|
-
return resolve(homedir(), configured.slice(2));
|
|
21
|
-
}
|
|
22
|
-
return resolve(configured);
|
|
23
|
-
}
|
|
24
|
-
export function getAgentPath(...segments) {
|
|
25
|
-
return join(getAgentDir(), ...segments);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* What the host calls itself.
|
|
29
|
-
*
|
|
30
|
-
* pi supports rebranding through `piConfig.name` in the package.json that its
|
|
31
|
-
* `getPackageDir()` resolves, and distributions built on pi (arc, tau, …) point
|
|
32
|
-
* `PI_PACKAGE_DIR` at their own manifest. Read that manifest directly rather
|
|
33
|
-
* than importing pi: this package deliberately depends on pi-ai and pi-tui
|
|
34
|
-
* only, and `getAgentDir()` above reads its env var the same self-contained way.
|
|
35
|
-
*
|
|
36
|
-
* Falls back to "pi", which is what pi's own APP_NAME resolves to.
|
|
37
|
-
*/
|
|
38
|
-
function readPiConfig() {
|
|
39
|
-
const dir = process.env.PI_PACKAGE_DIR?.trim();
|
|
40
|
-
if (!dir)
|
|
41
|
-
return undefined;
|
|
42
|
-
try {
|
|
43
|
-
const manifest = JSON.parse(readFileSync(join(resolve(dir), "package.json"), "utf8"));
|
|
44
|
-
return manifest.piConfig;
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
export function getAppName() {
|
|
51
|
-
const name = readPiConfig()?.name;
|
|
52
|
-
return typeof name === "string" && name.trim() ? name.trim() : "pi";
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Home page the host declares for itself, via `piConfig.clientUri` in the same
|
|
56
|
-
* manifest that carries `piConfig.name`. Only the distribution knows its own
|
|
57
|
-
* URL, so this is the one place it can come from without guessing.
|
|
58
|
-
*/
|
|
59
|
-
export function getAppClientUri() {
|
|
60
|
-
const uri = readPiConfig()?.clientUri;
|
|
61
|
-
return typeof uri === "string" && uri.trim() ? uri.trim() : undefined;
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=agent-dir.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-dir.js","sourceRoot":"","sources":["../agent-dir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,UAAU,gBAAgB;IAC9B,MAAM,SAAS,GAAG,YAAY,EAAE,EAAE,SAAS,CAAC;IAC5C,OAAO,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,MAAM,QAAQ,GAAG,YAAY,EAAE,CAAC;IAChC,MAAM,IAAI,GAAG,QAAQ,EAAE,IAAI,CAAC;IAC5B,MAAM,OAAO,GAAG,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7E,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,WAAW,EAAE,mBAAmB,CAAC,EAAE,IAAI,EAAE,CAAC;IACpF,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,gBAAgB,EAAE,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IACD,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;QACvB,OAAO,OAAO,EAAE,CAAC;IACnB,CAAC;IACD,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAG,QAAkB;IAChD,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,GAAG,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,YAAY;IACnB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,EAAE,CAAA;IAC9C,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAA;IAC1B,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAEnF,CAAA;QACD,OAAO,QAAQ,CAAC,QAAQ,CAAA;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,MAAM,IAAI,GAAG,YAAY,EAAE,EAAE,IAAI,CAAA;IACjC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;AACrE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,GAAG,GAAG,YAAY,EAAE,EAAE,SAAS,CAAA;IACrC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACvE,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { McpConfig } from "./types.ts";
|
|
2
|
-
export interface AgentPluginSummary {
|
|
3
|
-
path: string;
|
|
4
|
-
name?: string;
|
|
5
|
-
serverCount: number;
|
|
6
|
-
}
|
|
7
|
-
export declare function loadAgentPluginConfigs(paths: unknown, cwd?: string): McpConfig;
|
|
8
|
-
export declare function getAgentPluginSummaries(paths: unknown, cwd?: string): AgentPluginSummary[];
|