@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,624 +0,0 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
2
|
-
import { randomUUID } from "node:crypto";
|
|
3
|
-
import net from "node:net";
|
|
4
|
-
import { UrlElicitationRequiredError, type CallToolResult } from "@modelcontextprotocol/client";
|
|
5
|
-
import type { McpExtensionState } from "./state.ts";
|
|
6
|
-
import {
|
|
7
|
-
createUiModelContextUpdate,
|
|
8
|
-
extractUiPromptText,
|
|
9
|
-
UI_STREAM_HOST_CONTEXT_KEY,
|
|
10
|
-
UI_STREAM_REQUEST_META_KEY,
|
|
11
|
-
UI_STREAM_STRUCTURED_CONTENT_KEY,
|
|
12
|
-
type UiHostContext,
|
|
13
|
-
type UiMessageParams,
|
|
14
|
-
type UiModelContextParams,
|
|
15
|
-
type UiStreamMode,
|
|
16
|
-
} from "./types.ts";
|
|
17
|
-
import { logger } from "./logger.ts";
|
|
18
|
-
import { startUiServer } from "./ui-server.ts";
|
|
19
|
-
import type { UiServerHandle } from "./types.ts";
|
|
20
|
-
import { isGlimpseAvailable, openGlimpseWindow } from "./glimpse-ui.ts";
|
|
21
|
-
import type { SessionRecoveryDeps } from "./session-recovery.ts";
|
|
22
|
-
import { combineAbortSignals, isAbortError } from "./runtime-owner.ts";
|
|
23
|
-
import { throwIfAborted } from "./abort.ts";
|
|
24
|
-
import { InputRequiredNeedsUiError } from "./errors.ts";
|
|
25
|
-
|
|
26
|
-
let activeGlimpseWindow: { close(): void } | null = null;
|
|
27
|
-
|
|
28
|
-
export interface UiSessionRequest {
|
|
29
|
-
serverName: string;
|
|
30
|
-
toolName: string;
|
|
31
|
-
toolArgs: Record<string, unknown>;
|
|
32
|
-
uiResourceUri: string;
|
|
33
|
-
streamMode?: UiStreamMode;
|
|
34
|
-
signal?: AbortSignal;
|
|
35
|
-
onNeedsAuth?: SessionRecoveryDeps["onNeedsAuth"];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type UiSessionViewer = "browser" | "glimpse" | "orca" | "suppressed";
|
|
39
|
-
|
|
40
|
-
export interface UiSessionRuntime {
|
|
41
|
-
serverName: string;
|
|
42
|
-
toolName: string;
|
|
43
|
-
reused: boolean;
|
|
44
|
-
streamId?: string;
|
|
45
|
-
streamToken?: string;
|
|
46
|
-
streamMode?: UiStreamMode;
|
|
47
|
-
requestMeta?: Record<string, unknown>;
|
|
48
|
-
url: string;
|
|
49
|
-
viewer: UiSessionViewer;
|
|
50
|
-
windowOpen: boolean;
|
|
51
|
-
isActive: () => boolean;
|
|
52
|
-
sendToolResult: (result: CallToolResult) => void;
|
|
53
|
-
sendResultPatch: (result: CallToolResult) => void;
|
|
54
|
-
sendToolCancelled: (reason: string) => void;
|
|
55
|
-
close: (reason?: string) => void;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface UiSessionResultSummary {
|
|
59
|
-
message: string;
|
|
60
|
-
uiOpen: boolean;
|
|
61
|
-
uiViewer?: UiSessionViewer;
|
|
62
|
-
uiUrl?: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function summarizeUiSessionResult(uiSession: UiSessionRuntime | null): UiSessionResultSummary {
|
|
66
|
-
if (!uiSession) {
|
|
67
|
-
return {
|
|
68
|
-
message: "Interactive UI was unavailable; returning the tool result inline.",
|
|
69
|
-
uiOpen: false,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!uiSession.windowOpen) {
|
|
74
|
-
const action = uiSession.reused ? "Updated the suppressed MCP UI session." : "MCP UI window was suppressed.";
|
|
75
|
-
return {
|
|
76
|
-
message: `${action} Open manually: ${uiSession.url}`,
|
|
77
|
-
uiOpen: false,
|
|
78
|
-
uiViewer: uiSession.viewer,
|
|
79
|
-
uiUrl: uiSession.url,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
message: uiSession.reused
|
|
85
|
-
? "Updated the open UI."
|
|
86
|
-
: "Interactive UI is open. I'll respond to your prompts and intents as you interact with it.",
|
|
87
|
-
uiOpen: true,
|
|
88
|
-
uiViewer: uiSession.viewer,
|
|
89
|
-
uiUrl: uiSession.url,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const MAX_COMPLETED_SESSIONS = 10;
|
|
94
|
-
|
|
95
|
-
function withStreamEnvelope(
|
|
96
|
-
result: CallToolResult,
|
|
97
|
-
streamId: string | undefined,
|
|
98
|
-
sequence: number,
|
|
99
|
-
): CallToolResult {
|
|
100
|
-
if (!streamId) {
|
|
101
|
-
return result;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const structuredContent: Record<string, unknown> = result.structuredContent
|
|
105
|
-
&& typeof result.structuredContent === "object"
|
|
106
|
-
&& !Array.isArray(result.structuredContent)
|
|
107
|
-
? { ...(result.structuredContent as Record<string, unknown>) }
|
|
108
|
-
: {};
|
|
109
|
-
|
|
110
|
-
const rawEnvelope = structuredContent[UI_STREAM_STRUCTURED_CONTENT_KEY];
|
|
111
|
-
const envelope = rawEnvelope && typeof rawEnvelope === "object" && !Array.isArray(rawEnvelope)
|
|
112
|
-
? { ...rawEnvelope as Record<string, unknown> }
|
|
113
|
-
: {
|
|
114
|
-
frameType: "final",
|
|
115
|
-
phase: "settled",
|
|
116
|
-
status: result.isError ? "error" : "ok",
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
structuredContent[UI_STREAM_STRUCTURED_CONTENT_KEY] = {
|
|
120
|
-
...envelope,
|
|
121
|
-
streamId,
|
|
122
|
-
sequence,
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
return {
|
|
126
|
-
...result,
|
|
127
|
-
structuredContent,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
async function openInBrowser(state: McpExtensionState, url: string, signal: AbortSignal): Promise<string | null> {
|
|
132
|
-
throwIfAborted(signal);
|
|
133
|
-
try {
|
|
134
|
-
await state.openBrowser(url);
|
|
135
|
-
throwIfAborted(signal);
|
|
136
|
-
return null;
|
|
137
|
-
} catch (error) {
|
|
138
|
-
if (isAbortError(error, signal)) throw error;
|
|
139
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
140
|
-
if (state.owner?.isActive() === false) return null;
|
|
141
|
-
state.ui?.notify(`MCP UI browser open failed: ${message}`, "warning");
|
|
142
|
-
return message;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
async function openInOrcaBrowser(url: string, signal: AbortSignal): Promise<void> {
|
|
147
|
-
throwIfAborted(signal);
|
|
148
|
-
await new Promise<void>((resolve, reject) => {
|
|
149
|
-
execFile("orca", ["goto", "--url", url], { timeout: 10000, signal }, (error) => {
|
|
150
|
-
if (error) {
|
|
151
|
-
reject(error instanceof Error ? error : new Error(String(error)));
|
|
152
|
-
} else {
|
|
153
|
-
resolve();
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function isRemoteSession(): boolean {
|
|
160
|
-
return Boolean(process.env.SSH_CONNECTION || process.env.SSH_TTY);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function hasActiveRemoteLogin(): Promise<boolean> {
|
|
164
|
-
return new Promise((resolve) => {
|
|
165
|
-
execFile("who", { encoding: "utf8", timeout: 2000 }, (error, out) => {
|
|
166
|
-
if (error) {
|
|
167
|
-
resolve(false);
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
resolve(/\(.+\)\s*$/m.test(out));
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function probeMoshiGateway(): Promise<boolean> {
|
|
176
|
-
return new Promise((resolve) => {
|
|
177
|
-
const socket = net.connect({ host: "127.0.0.1", port: 24543 });
|
|
178
|
-
const done = (ok: boolean) => {
|
|
179
|
-
socket.destroy();
|
|
180
|
-
resolve(ok);
|
|
181
|
-
};
|
|
182
|
-
socket.setTimeout(300);
|
|
183
|
-
socket.once("connect", () => done(true));
|
|
184
|
-
socket.once("timeout", () => done(false));
|
|
185
|
-
socket.once("error", () => done(false));
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function remoteAccessHint(opts: { url: string; port: number; proxyPort: number; moshi: boolean; openError: string | null; openedOnHost?: boolean }): string {
|
|
190
|
-
const lines = [
|
|
191
|
-
opts.openError !== null
|
|
192
|
-
? "Couldn't open MCP UI here. Open it from your own device:"
|
|
193
|
-
: opts.openedOnHost
|
|
194
|
-
? "MCP UI opened on this host. If you're controlling this session remotely, open it from your own device:"
|
|
195
|
-
: "This looks like a remote session - if no MCP UI appeared, open it from your own device:",
|
|
196
|
-
` ${opts.url}`,
|
|
197
|
-
];
|
|
198
|
-
if (opts.openError !== null) {
|
|
199
|
-
lines.push(`Browser launch failed: ${opts.openError}`);
|
|
200
|
-
}
|
|
201
|
-
if (opts.moshi) {
|
|
202
|
-
lines.push(
|
|
203
|
-
`Moshi: tap the preview button in the terminal title bar and pick this MCP UI server (it must reach ports ${opts.port} and ${opts.proxyPort}).`,
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
|
-
lines.push(
|
|
207
|
-
`SSH: run \`ssh -L ${opts.port}:127.0.0.1:${opts.port} -L ${opts.proxyPort}:127.0.0.1:${opts.proxyPort} <this-host>\` on your local machine, then open the URL above.`,
|
|
208
|
-
"mosh can't forward ports - run that ssh command in a separate terminal.",
|
|
209
|
-
);
|
|
210
|
-
return lines.join("\n");
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export async function maybeStartUiSession(
|
|
214
|
-
state: McpExtensionState,
|
|
215
|
-
request: UiSessionRequest,
|
|
216
|
-
): Promise<UiSessionRuntime | null> {
|
|
217
|
-
const log = logger.child({
|
|
218
|
-
component: "UiSession",
|
|
219
|
-
server: request.serverName,
|
|
220
|
-
tool: request.toolName,
|
|
221
|
-
});
|
|
222
|
-
const runtimeSignal = combineAbortSignals(state.owner?.signal, request.signal) ?? new AbortController().signal;
|
|
223
|
-
|
|
224
|
-
try {
|
|
225
|
-
throwIfAborted(runtimeSignal);
|
|
226
|
-
if (
|
|
227
|
-
state.uiServer &&
|
|
228
|
-
state.uiServer.serverName === request.serverName &&
|
|
229
|
-
state.uiServer.toolName === request.toolName
|
|
230
|
-
) {
|
|
231
|
-
const existingHandle = state.uiServer;
|
|
232
|
-
const streamMode = request.streamMode;
|
|
233
|
-
const streamId = streamMode ? randomUUID() : undefined;
|
|
234
|
-
const streamToken = streamMode ? randomUUID() : undefined;
|
|
235
|
-
let active = true;
|
|
236
|
-
let nextStreamSequence = 0;
|
|
237
|
-
|
|
238
|
-
const cleanupStreamListener = () => {
|
|
239
|
-
if (streamToken) {
|
|
240
|
-
state.manager.removeUiStreamListener(streamToken);
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
existingHandle.sendToolInput(request.toolArgs);
|
|
245
|
-
|
|
246
|
-
if (streamToken) {
|
|
247
|
-
state.manager.registerUiStreamListener(streamToken, (serverName, notification) => {
|
|
248
|
-
if (!active || state.uiServer !== existingHandle) return;
|
|
249
|
-
if (serverName !== request.serverName) return;
|
|
250
|
-
nextStreamSequence += 1;
|
|
251
|
-
existingHandle.sendResultPatch(
|
|
252
|
-
withStreamEnvelope(notification.result as CallToolResult, streamId, nextStreamSequence),
|
|
253
|
-
);
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return {
|
|
258
|
-
serverName: request.serverName,
|
|
259
|
-
toolName: request.toolName,
|
|
260
|
-
reused: true,
|
|
261
|
-
...(streamId !== undefined ? { streamId } : {}),
|
|
262
|
-
...(streamToken !== undefined ? { streamToken } : {}),
|
|
263
|
-
...(streamMode !== undefined ? { streamMode } : {}),
|
|
264
|
-
...(streamToken ? { requestMeta: { [UI_STREAM_REQUEST_META_KEY]: streamToken } } : {}),
|
|
265
|
-
url: existingHandle.url,
|
|
266
|
-
viewer: existingHandle.viewer ?? "browser",
|
|
267
|
-
windowOpen: existingHandle.windowOpen ?? true,
|
|
268
|
-
isActive: () => active && state.uiServer === existingHandle,
|
|
269
|
-
sendToolResult: (result: CallToolResult) => {
|
|
270
|
-
if (!active || state.uiServer !== existingHandle) return;
|
|
271
|
-
nextStreamSequence += 1;
|
|
272
|
-
existingHandle.sendToolResult(withStreamEnvelope(result, streamId, nextStreamSequence));
|
|
273
|
-
},
|
|
274
|
-
sendResultPatch: (result: CallToolResult) => {
|
|
275
|
-
if (!active || state.uiServer !== existingHandle) return;
|
|
276
|
-
nextStreamSequence += 1;
|
|
277
|
-
existingHandle.sendResultPatch(withStreamEnvelope(result, streamId, nextStreamSequence));
|
|
278
|
-
},
|
|
279
|
-
sendToolCancelled: (reason: string) => {
|
|
280
|
-
if (!active || state.uiServer !== existingHandle) return;
|
|
281
|
-
nextStreamSequence += 1;
|
|
282
|
-
existingHandle.sendToolResult(
|
|
283
|
-
withStreamEnvelope(
|
|
284
|
-
{
|
|
285
|
-
isError: true,
|
|
286
|
-
content: [{ type: "text", text: reason }],
|
|
287
|
-
},
|
|
288
|
-
streamId,
|
|
289
|
-
nextStreamSequence,
|
|
290
|
-
),
|
|
291
|
-
);
|
|
292
|
-
},
|
|
293
|
-
close: () => {
|
|
294
|
-
active = false;
|
|
295
|
-
cleanupStreamListener();
|
|
296
|
-
},
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
const resource = await state.uiResourceHandler.readUiResource(request.serverName, request.uiResourceUri, {
|
|
301
|
-
config: state.config,
|
|
302
|
-
signal: runtimeSignal,
|
|
303
|
-
onNeedsAuth: request.onNeedsAuth,
|
|
304
|
-
});
|
|
305
|
-
throwIfAborted(runtimeSignal);
|
|
306
|
-
|
|
307
|
-
if (state.uiServer) {
|
|
308
|
-
state.uiServer.close("replaced");
|
|
309
|
-
state.uiServer = null;
|
|
310
|
-
}
|
|
311
|
-
if (activeGlimpseWindow) {
|
|
312
|
-
activeGlimpseWindow.close();
|
|
313
|
-
activeGlimpseWindow = null;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const streamMode = request.streamMode;
|
|
317
|
-
const streamId = streamMode ? randomUUID() : undefined;
|
|
318
|
-
const streamToken = streamMode ? randomUUID() : undefined;
|
|
319
|
-
const hostContext: UiHostContext | undefined = streamMode && streamId
|
|
320
|
-
? {
|
|
321
|
-
[UI_STREAM_HOST_CONTEXT_KEY]: {
|
|
322
|
-
mode: streamMode,
|
|
323
|
-
streamId,
|
|
324
|
-
intermediateResultPatches: streamMode === "stream-first",
|
|
325
|
-
partialInput: false,
|
|
326
|
-
},
|
|
327
|
-
}
|
|
328
|
-
: undefined;
|
|
329
|
-
|
|
330
|
-
let active = true;
|
|
331
|
-
let nextStreamSequence = 0;
|
|
332
|
-
let handle: UiServerHandle;
|
|
333
|
-
const resourceListenerToken = randomUUID();
|
|
334
|
-
|
|
335
|
-
const cleanupListeners = () => {
|
|
336
|
-
if (streamToken) {
|
|
337
|
-
state.manager.removeUiStreamListener(streamToken);
|
|
338
|
-
}
|
|
339
|
-
state.manager.removeResourceUpdatedListener?.(resourceListenerToken);
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
handle = await startUiServer({
|
|
343
|
-
serverName: request.serverName,
|
|
344
|
-
toolName: request.toolName,
|
|
345
|
-
toolArgs: streamMode === "stream-first" ? {} : request.toolArgs,
|
|
346
|
-
resource,
|
|
347
|
-
manager: state.manager,
|
|
348
|
-
config: state.config,
|
|
349
|
-
state,
|
|
350
|
-
...(request.onNeedsAuth ? { onNeedsAuth: request.onNeedsAuth } : {}),
|
|
351
|
-
consentManager: state.consentManager,
|
|
352
|
-
...(hostContext !== undefined ? { hostContext } : {}),
|
|
353
|
-
|
|
354
|
-
onMessage: (params: UiMessageParams) => {
|
|
355
|
-
const prompt = extractUiPromptText(params);
|
|
356
|
-
if (prompt) {
|
|
357
|
-
if (state.sendMessage) {
|
|
358
|
-
state.sendMessage(
|
|
359
|
-
{
|
|
360
|
-
customType: "mcp-ui-prompt",
|
|
361
|
-
content: [{ type: "text", text: `User sent prompt from ${request.serverName} UI: "${prompt}"` }],
|
|
362
|
-
display: `💬 UI Prompt: ${prompt}`,
|
|
363
|
-
details: { server: request.serverName, tool: request.toolName, prompt },
|
|
364
|
-
},
|
|
365
|
-
{ triggerTurn: true },
|
|
366
|
-
);
|
|
367
|
-
log.debug("Triggered agent turn for UI prompt", { prompt: prompt.slice(0, 50) });
|
|
368
|
-
}
|
|
369
|
-
} else if (params.type === "intent" || params.intent) {
|
|
370
|
-
const intent = params.intent ?? "";
|
|
371
|
-
const intentParams = params.params;
|
|
372
|
-
if (intent && state.sendMessage) {
|
|
373
|
-
const paramsStr = intentParams ? ` ${JSON.stringify(intentParams)}` : "";
|
|
374
|
-
state.sendMessage(
|
|
375
|
-
{
|
|
376
|
-
customType: "mcp-ui-intent",
|
|
377
|
-
content: [{ type: "text", text: `User triggered intent from ${request.serverName} UI: ${intent}${paramsStr}` }],
|
|
378
|
-
display: `🎯 UI Intent: ${intent}`,
|
|
379
|
-
details: { server: request.serverName, tool: request.toolName, intent, params: intentParams },
|
|
380
|
-
},
|
|
381
|
-
{ triggerTurn: true },
|
|
382
|
-
);
|
|
383
|
-
log.debug("Triggered agent turn for UI intent", { intent });
|
|
384
|
-
}
|
|
385
|
-
} else if (params.type === "notify" || params.message) {
|
|
386
|
-
const text = params.message ?? "";
|
|
387
|
-
if (text && state.ui) {
|
|
388
|
-
state.ui.notify(`[${request.serverName}] ${text}`, "info");
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
},
|
|
392
|
-
|
|
393
|
-
onContextUpdate: (params: UiModelContextParams) => {
|
|
394
|
-
const update = createUiModelContextUpdate(params);
|
|
395
|
-
log.debug("Model context update from UI", {
|
|
396
|
-
hasContent: !!params.content,
|
|
397
|
-
hasStructured: !!params.structuredContent,
|
|
398
|
-
hasUpdate: !!update,
|
|
399
|
-
});
|
|
400
|
-
if (update && state.sendMessage) {
|
|
401
|
-
state.sendMessage(
|
|
402
|
-
{
|
|
403
|
-
customType: "mcp-ui-context",
|
|
404
|
-
content: [{ type: "text", text: `User submitted model context from ${request.serverName} UI:\n${update.summary}` }],
|
|
405
|
-
display: "UI Context submitted",
|
|
406
|
-
details: { server: request.serverName, tool: request.toolName, context: update },
|
|
407
|
-
},
|
|
408
|
-
{ triggerTurn: true },
|
|
409
|
-
);
|
|
410
|
-
}
|
|
411
|
-
},
|
|
412
|
-
|
|
413
|
-
onComplete: (reason: string) => {
|
|
414
|
-
active = false;
|
|
415
|
-
cleanupListeners();
|
|
416
|
-
|
|
417
|
-
if (state.uiServer === handle) {
|
|
418
|
-
const messages = handle.getSessionMessages();
|
|
419
|
-
const stream = handle.getStreamSummary();
|
|
420
|
-
const hasContent =
|
|
421
|
-
messages.prompts.length > 0 ||
|
|
422
|
-
messages.intents.length > 0 ||
|
|
423
|
-
messages.notifications.length > 0 ||
|
|
424
|
-
messages.contexts.length > 0 ||
|
|
425
|
-
!!stream;
|
|
426
|
-
|
|
427
|
-
if (hasContent) {
|
|
428
|
-
state.completedUiSessions.push({
|
|
429
|
-
serverName: handle.serverName,
|
|
430
|
-
toolName: handle.toolName,
|
|
431
|
-
completedAt: new Date(),
|
|
432
|
-
reason,
|
|
433
|
-
messages,
|
|
434
|
-
...(stream !== undefined ? { stream } : {}),
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
while (state.completedUiSessions.length > MAX_COMPLETED_SESSIONS) {
|
|
438
|
-
state.completedUiSessions.shift();
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
log.debug("Session completed", {
|
|
442
|
-
reason,
|
|
443
|
-
prompts: messages.prompts.length,
|
|
444
|
-
intents: messages.intents.length,
|
|
445
|
-
notifications: messages.notifications.length,
|
|
446
|
-
contexts: messages.contexts.length,
|
|
447
|
-
streamFrames: stream?.frames ?? 0,
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
state.uiServer = null;
|
|
452
|
-
if (activeGlimpseWindow) {
|
|
453
|
-
activeGlimpseWindow.close();
|
|
454
|
-
activeGlimpseWindow = null;
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
},
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
if (state.owner?.isActive() === false || runtimeSignal.aborted) {
|
|
461
|
-
handle.close("runtime_owner_stopped");
|
|
462
|
-
throwIfAborted(runtimeSignal);
|
|
463
|
-
throw new Error("MCP UI session became stale before registration");
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
if (streamToken) {
|
|
467
|
-
state.manager.registerUiStreamListener(streamToken, (serverName, notification) => {
|
|
468
|
-
if (!active || state.uiServer !== handle) return;
|
|
469
|
-
if (serverName !== request.serverName) return;
|
|
470
|
-
nextStreamSequence += 1;
|
|
471
|
-
handle.sendResultPatch(withStreamEnvelope(notification.result as CallToolResult, streamId, nextStreamSequence));
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
state.manager.registerResourceUpdatedListener?.(
|
|
476
|
-
resourceListenerToken,
|
|
477
|
-
request.serverName,
|
|
478
|
-
request.uiResourceUri,
|
|
479
|
-
(_serverName, uri) => {
|
|
480
|
-
if (!active || state.uiServer !== handle) return;
|
|
481
|
-
handle.sendResourceUpdated(uri);
|
|
482
|
-
},
|
|
483
|
-
);
|
|
484
|
-
|
|
485
|
-
state.uiServer = handle;
|
|
486
|
-
|
|
487
|
-
const viewerPref = process.env.MCP_UI_VIEWER?.toLowerCase();
|
|
488
|
-
const uiSuppressed = viewerPref === "none" || viewerPref === "off" || viewerPref === "disabled";
|
|
489
|
-
|
|
490
|
-
let viewer: UiSessionViewer = "browser";
|
|
491
|
-
let windowOpen = true;
|
|
492
|
-
const remoteByEnv = isRemoteSession();
|
|
493
|
-
|
|
494
|
-
if (uiSuppressed) {
|
|
495
|
-
viewer = "suppressed";
|
|
496
|
-
windowOpen = false;
|
|
497
|
-
state.ui?.notify(
|
|
498
|
-
`MCP UI window suppressed (MCP_UI_VIEWER=${viewerPref}). Open manually: ${handle.url}\n` +
|
|
499
|
-
`If this session is remote, run ssh -L ${handle.port}:127.0.0.1:${handle.port} -L ${handle.proxyPort}:127.0.0.1:${handle.proxyPort} <this-host> first.`,
|
|
500
|
-
"info",
|
|
501
|
-
);
|
|
502
|
-
} else {
|
|
503
|
-
const remoteLikely = remoteByEnv || await hasActiveRemoteLogin();
|
|
504
|
-
const emitRemoteHint = async (openError: string | null, openedOnHost = false) => {
|
|
505
|
-
state.ui?.notify(remoteAccessHint({
|
|
506
|
-
url: handle.url,
|
|
507
|
-
port: handle.port,
|
|
508
|
-
proxyPort: handle.proxyPort,
|
|
509
|
-
moshi: await probeMoshiGateway(),
|
|
510
|
-
openError,
|
|
511
|
-
openedOnHost,
|
|
512
|
-
}), openError === null ? "info" : "warning");
|
|
513
|
-
};
|
|
514
|
-
// Handle Orca browser viewer
|
|
515
|
-
if (viewerPref === "orca") {
|
|
516
|
-
try {
|
|
517
|
-
await openInOrcaBrowser(handle.url, runtimeSignal);
|
|
518
|
-
if (remoteLikely) {
|
|
519
|
-
await emitRemoteHint(null, true);
|
|
520
|
-
}
|
|
521
|
-
viewer = "orca";
|
|
522
|
-
} catch (error) {
|
|
523
|
-
if (isAbortError(error, runtimeSignal)) throw error;
|
|
524
|
-
log.debug("Orca browser failed, using fallback", {
|
|
525
|
-
error: error instanceof Error ? error.message : String(error),
|
|
526
|
-
});
|
|
527
|
-
const openError = await openInBrowser(state, handle.url, runtimeSignal);
|
|
528
|
-
if (openError !== null || remoteLikely) {
|
|
529
|
-
await emitRemoteHint(openError);
|
|
530
|
-
}
|
|
531
|
-
viewer = "browser";
|
|
532
|
-
}
|
|
533
|
-
} else {
|
|
534
|
-
const glimpseDetected = !remoteByEnv && isGlimpseAvailable();
|
|
535
|
-
const useGlimpse = !remoteByEnv && (viewerPref === "glimpse" ||
|
|
536
|
-
(viewerPref !== "browser" && glimpseDetected));
|
|
537
|
-
|
|
538
|
-
if (useGlimpse) {
|
|
539
|
-
try {
|
|
540
|
-
const glimpseHtml = `<!DOCTYPE html><html><head><meta charset="utf-8"><style>body{margin:0;padding:0;width:100vw;height:100vh;overflow:hidden}iframe{width:100%;height:100%;border:none}</style></head><body><iframe src="${handle.url}"></iframe></body></html>`;
|
|
541
|
-
const glimpseWindow = await openGlimpseWindow(glimpseHtml, {
|
|
542
|
-
title: `MCP · ${request.serverName} · ${request.toolName}`,
|
|
543
|
-
width: 1000,
|
|
544
|
-
height: 800,
|
|
545
|
-
onClosed: () => {
|
|
546
|
-
if (active) handle.close("glimpse-closed");
|
|
547
|
-
},
|
|
548
|
-
});
|
|
549
|
-
if (state.owner?.isActive() === false || runtimeSignal.aborted) {
|
|
550
|
-
glimpseWindow.close();
|
|
551
|
-
throwIfAborted(runtimeSignal);
|
|
552
|
-
throw new Error("MCP Glimpse window became stale before registration");
|
|
553
|
-
}
|
|
554
|
-
activeGlimpseWindow = glimpseWindow;
|
|
555
|
-
viewer = "glimpse";
|
|
556
|
-
if (remoteLikely) {
|
|
557
|
-
await emitRemoteHint(null, true);
|
|
558
|
-
}
|
|
559
|
-
} catch (error) {
|
|
560
|
-
log.debug("Glimpse unavailable, using browser", {
|
|
561
|
-
error: error instanceof Error ? error.message : String(error),
|
|
562
|
-
});
|
|
563
|
-
const openError = await openInBrowser(state, handle.url, runtimeSignal);
|
|
564
|
-
if (openError !== null || remoteLikely) {
|
|
565
|
-
await emitRemoteHint(openError);
|
|
566
|
-
}
|
|
567
|
-
viewer = "browser";
|
|
568
|
-
}
|
|
569
|
-
} else {
|
|
570
|
-
const openError = await openInBrowser(state, handle.url, runtimeSignal);
|
|
571
|
-
if (openError !== null || remoteLikely) {
|
|
572
|
-
await emitRemoteHint(openError);
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
throwIfAborted(runtimeSignal);
|
|
579
|
-
handle.viewer = viewer;
|
|
580
|
-
handle.windowOpen = windowOpen;
|
|
581
|
-
|
|
582
|
-
return {
|
|
583
|
-
serverName: request.serverName,
|
|
584
|
-
toolName: request.toolName,
|
|
585
|
-
reused: false,
|
|
586
|
-
...(streamId !== undefined ? { streamId } : {}),
|
|
587
|
-
...(streamToken !== undefined ? { streamToken } : {}),
|
|
588
|
-
...(streamMode !== undefined ? { streamMode } : {}),
|
|
589
|
-
...(streamToken ? { requestMeta: { [UI_STREAM_REQUEST_META_KEY]: streamToken } } : {}),
|
|
590
|
-
url: handle.url,
|
|
591
|
-
viewer,
|
|
592
|
-
windowOpen,
|
|
593
|
-
isActive: () => active && state.uiServer === handle,
|
|
594
|
-
sendToolResult: (result: CallToolResult) => {
|
|
595
|
-
if (!active || state.uiServer !== handle) return;
|
|
596
|
-
nextStreamSequence += 1;
|
|
597
|
-
handle.sendToolResult(withStreamEnvelope(result, streamId, nextStreamSequence));
|
|
598
|
-
},
|
|
599
|
-
sendResultPatch: (result: CallToolResult) => {
|
|
600
|
-
if (!active || state.uiServer !== handle) return;
|
|
601
|
-
nextStreamSequence += 1;
|
|
602
|
-
handle.sendResultPatch(withStreamEnvelope(result, streamId, nextStreamSequence));
|
|
603
|
-
},
|
|
604
|
-
sendToolCancelled: (reason: string) => {
|
|
605
|
-
if (!active || state.uiServer !== handle) return;
|
|
606
|
-
handle.sendToolCancelled(reason);
|
|
607
|
-
},
|
|
608
|
-
close: (reason?: string) => {
|
|
609
|
-
active = false;
|
|
610
|
-
cleanupListeners();
|
|
611
|
-
handle.close(reason);
|
|
612
|
-
},
|
|
613
|
-
};
|
|
614
|
-
} catch (error) {
|
|
615
|
-
if (error instanceof UrlElicitationRequiredError || error instanceof InputRequiredNeedsUiError || isAbortError(error, runtimeSignal)) throw error;
|
|
616
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
617
|
-
log.error("Failed to start UI session", error instanceof Error ? error : undefined);
|
|
618
|
-
state.ui?.notify(
|
|
619
|
-
`MCP UI unavailable for ${request.toolName} (${request.serverName}): ${message}`,
|
|
620
|
-
"warning",
|
|
621
|
-
);
|
|
622
|
-
return null;
|
|
623
|
-
}
|
|
624
|
-
}
|