@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,331 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
/** Versioned shared-event-bus channel for read-only MCP runtime snapshots. */
|
|
3
|
-
export const MCP_STATUS_EVENT = "pi-mcp-adapter/status/v1";
|
|
4
|
-
export const MCP_STATUS_SNAPSHOT_VERSION = 1;
|
|
5
|
-
// Re-export stream types from the shared lightweight module.
|
|
6
|
-
// This allows the example package to import stream schemas without pulling the full types.ts dependency graph.
|
|
7
|
-
export { UI_STREAM_HOST_CONTEXT_KEY, UI_STREAM_REQUEST_META_KEY, UI_STREAM_RESULT_PATCH_METHOD, SERVER_STREAM_RESULT_PATCH_METHOD, UI_STREAM_STRUCTURED_CONTENT_KEY, uiStreamModeSchema, visualizationStreamPhaseSchema, visualizationStreamFrameTypeSchema, visualizationStreamStatusSchema, uiStreamHostContextSchema, visualizationStreamEnvelopeSchema, uiStreamCallToolResultSchema, uiStreamResultPatchNotificationSchema, serverStreamResultPatchNotificationSchema, getUiStreamHostContext, getVisualizationStreamEnvelope, } from "./ui-stream-types.js";
|
|
8
|
-
/**
|
|
9
|
-
* Extract prompt text from either legacy MCP UI message shapes or native AppBridge user messages.
|
|
10
|
-
*/
|
|
11
|
-
export function extractUiPromptText(params) {
|
|
12
|
-
if (params.type === "prompt" || params.prompt) {
|
|
13
|
-
const prompt = params.prompt ?? String(params.message ?? "");
|
|
14
|
-
return prompt || undefined;
|
|
15
|
-
}
|
|
16
|
-
if (params.role === "user" && Array.isArray(params.content)) {
|
|
17
|
-
const text = params.content
|
|
18
|
-
.map((block) => (block && typeof block === "object" && "text" in block ? String(block.text ?? "") : ""))
|
|
19
|
-
.filter(Boolean)
|
|
20
|
-
.join("\n\n");
|
|
21
|
-
return text || undefined;
|
|
22
|
-
}
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Parse a canonical named UI handoff encoded as `intent\n{json}`.
|
|
27
|
-
*/
|
|
28
|
-
export function parseUiPromptHandoff(prompt) {
|
|
29
|
-
const newlineIndex = prompt.indexOf("\n");
|
|
30
|
-
if (newlineIndex <= 0) {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
const intent = prompt.slice(0, newlineIndex).trim();
|
|
34
|
-
const payloadText = prompt.slice(newlineIndex + 1).trim();
|
|
35
|
-
if (!intent || !payloadText) {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
if (!/^[A-Za-z][A-Za-z0-9_-]*$/.test(intent)) {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
const parsed = JSON.parse(payloadText);
|
|
43
|
-
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
intent,
|
|
48
|
-
params: parsed,
|
|
49
|
-
raw: prompt,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
export function createUiModelContextUpdate(params, maxChars = 12_000) {
|
|
57
|
-
const payload = Object.fromEntries(Object.entries(params).filter(([, value]) => value !== undefined));
|
|
58
|
-
if (Object.keys(payload).length === 0)
|
|
59
|
-
return undefined;
|
|
60
|
-
const serialized = JSON.stringify(payload);
|
|
61
|
-
if (serialized.length <= maxChars) {
|
|
62
|
-
return { payload, summary: serialized, truncated: false };
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
summary: `${serialized.slice(0, Math.max(0, maxChars - 1))}…`,
|
|
66
|
-
truncated: true,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
/** Only the literal boolean `true` disables a server. */
|
|
70
|
-
export function isServerDisabled(definition) {
|
|
71
|
-
return definition?.disabled === true;
|
|
72
|
-
}
|
|
73
|
-
const ENCODED_SERVER_NAMESPACE_MARKER = "_mcpns_";
|
|
74
|
-
// Provider tool-name limit (64 for Bedrock, Anthropic, OpenAI) minus the `mcp__` proxy prefix.
|
|
75
|
-
const MAX_SERVER_NAMESPACE_LENGTH = 59;
|
|
76
|
-
export function formatServerNamespace(serverName) {
|
|
77
|
-
const normalized = serverName.replace(/-/g, "_");
|
|
78
|
-
const safe = /^[A-Za-z0-9_]*$/.test(normalized) && !normalized.startsWith(ENCODED_SERVER_NAMESPACE_MARKER);
|
|
79
|
-
const body = safe ? normalized : encodeServerNamespace(normalized);
|
|
80
|
-
const namespace = safe ? body : `${ENCODED_SERVER_NAMESPACE_MARKER}${body}`;
|
|
81
|
-
if (namespace.length <= MAX_SERVER_NAMESPACE_LENGTH)
|
|
82
|
-
return namespace;
|
|
83
|
-
// Hash the ASCII encoding, not the raw name: lone surrogates and U+FFFD share UTF-8 bytes.
|
|
84
|
-
const digest = createHash("sha256").update(namespace, "utf8").digest("hex").slice(0, 16);
|
|
85
|
-
// `_h_` cannot start an encoded body: `h` is neither `_` nor a hexadecimal digit.
|
|
86
|
-
const hashPrefix = `${ENCODED_SERVER_NAMESPACE_MARKER}_h_`;
|
|
87
|
-
const head = body.slice(0, MAX_SERVER_NAMESPACE_LENGTH - hashPrefix.length - digest.length - 1);
|
|
88
|
-
return `${hashPrefix}${head}_${digest}`;
|
|
89
|
-
}
|
|
90
|
-
// `_` becomes `__`, so `__` and `_<hex>_` form a prefix code and the encoding stays injective.
|
|
91
|
-
function encodeServerNamespace(name) {
|
|
92
|
-
return Array.from(name, character => {
|
|
93
|
-
if (character === "_")
|
|
94
|
-
return "__";
|
|
95
|
-
return /^[A-Za-z0-9]$/.test(character) ? character : `_${character.codePointAt(0).toString(16)}_`;
|
|
96
|
-
}).join("");
|
|
97
|
-
}
|
|
98
|
-
export const MCP_TOOL_APPROVAL_REQUEST_EVENT = "pi-mcp-adapter:tool-approval-request";
|
|
99
|
-
/**
|
|
100
|
-
* Get server prefix based on tool prefix mode.
|
|
101
|
-
*/
|
|
102
|
-
function sanitizeServerPrefix(serverName, preserveProviderValid = true) {
|
|
103
|
-
const validCharacters = preserveProviderValid ? /^[A-Za-z0-9_-]$/ : /^[A-Za-z0-9]$/;
|
|
104
|
-
return Array.from(serverName, char => validCharacters.test(char) ? char : `_${char.codePointAt(0).toString(16)}_`).join("");
|
|
105
|
-
}
|
|
106
|
-
export function getServerPrefix(serverName, mode) {
|
|
107
|
-
if (mode === "none")
|
|
108
|
-
return "";
|
|
109
|
-
if (mode === "short") {
|
|
110
|
-
let short = sanitizeServerPrefix(serverName.replace(/-?mcp$/i, ""));
|
|
111
|
-
if (!short)
|
|
112
|
-
short = "mcp";
|
|
113
|
-
return short;
|
|
114
|
-
}
|
|
115
|
-
if (mode === "mcp")
|
|
116
|
-
return `mcp__${sanitizeServerPrefix(serverName)}`;
|
|
117
|
-
return sanitizeServerPrefix(serverName);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Format a tool name with server prefix.
|
|
121
|
-
*/
|
|
122
|
-
export function formatToolName(toolName, serverName, prefix) {
|
|
123
|
-
const p = getServerPrefix(serverName, prefix);
|
|
124
|
-
const sanitized = toolName.replace(/\./g, "_");
|
|
125
|
-
if (p && sanitized.startsWith(`${p}_`) && sanitized.length > p.length + 1) {
|
|
126
|
-
return sanitized;
|
|
127
|
-
}
|
|
128
|
-
return p ? `${p}_${sanitized}` : sanitized;
|
|
129
|
-
}
|
|
130
|
-
export function resolveToolPrefix(definition, globalPrefix) {
|
|
131
|
-
return definition?.toolPrefix ?? globalPrefix ?? "server";
|
|
132
|
-
}
|
|
133
|
-
/** A canonical name has an owner only when exactly one eligible entry produces it. */
|
|
134
|
-
export function resolveUniqueNameOwnership(entries, getName) {
|
|
135
|
-
const owners = new Map();
|
|
136
|
-
for (const entry of entries) {
|
|
137
|
-
const name = getName(entry);
|
|
138
|
-
const named = owners.get(name) ?? [];
|
|
139
|
-
named.push(entry);
|
|
140
|
-
owners.set(name, named);
|
|
141
|
-
}
|
|
142
|
-
const collisions = new Map([...owners].filter(([, named]) => named.length > 1));
|
|
143
|
-
return {
|
|
144
|
-
unique: entries.filter((entry) => !collisions.has(getName(entry))),
|
|
145
|
-
collisions,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Resolve a configured MCP server name from a prefixed tool name.
|
|
150
|
-
*
|
|
151
|
-
* When the proxy tool is addressed with a fully-qualified name such as
|
|
152
|
-
* `searxng_searxng_web_search`, downstream policy systems (for example a
|
|
153
|
-
* permission gate) need to recover the owning server so they can evaluate
|
|
154
|
-
* server-scoped rules against the bare server name. This performs the inverse
|
|
155
|
-
* of {@link getServerPrefix}: it finds the longest configured server prefix
|
|
156
|
-
* that the tool name starts with and returns that server's name.
|
|
157
|
-
*
|
|
158
|
-
* @param toolName - the tool name as passed to the proxy `mcp({ tool })` call.
|
|
159
|
-
* @param serverNames - the configured MCP server names (keys of `mcpServers`).
|
|
160
|
-
* @param prefix - the active tool-prefix mode.
|
|
161
|
-
* @returns the resolved server name, or `undefined` when no prefix matches or
|
|
162
|
-
* the prefix mode is `"none"`.
|
|
163
|
-
*/
|
|
164
|
-
export function resolveServerFromToolName(toolName, serverNames, prefix) {
|
|
165
|
-
if (prefix === "none")
|
|
166
|
-
return undefined;
|
|
167
|
-
const candidates = [];
|
|
168
|
-
for (const name of serverNames) {
|
|
169
|
-
const p = getServerPrefix(name, prefix);
|
|
170
|
-
if (p && toolName.startsWith(p + "_"))
|
|
171
|
-
candidates.push({ name, prefix: p });
|
|
172
|
-
}
|
|
173
|
-
if (candidates.length === 0)
|
|
174
|
-
return undefined;
|
|
175
|
-
candidates.sort((a, b) => b.prefix.length - a.prefix.length);
|
|
176
|
-
const best = candidates[0];
|
|
177
|
-
// Fail safe: short mode can intentionally map names such as foo and foo-mcp
|
|
178
|
-
// to the same prefix. Return undefined so a downstream permission gate uses
|
|
179
|
-
// its existing wildcard path rather than enforcing a rule against the wrong server.
|
|
180
|
-
if (candidates.some((c) => c.prefix === best.prefix && c.name !== best.name)) {
|
|
181
|
-
return undefined;
|
|
182
|
-
}
|
|
183
|
-
return best?.name;
|
|
184
|
-
}
|
|
185
|
-
export function sanitizePromptName(name) {
|
|
186
|
-
const cleaned = name.replace(/[^A-Za-z0-9_-]+/g, "_").replace(/^[_-]+|[_-]+$/g, "");
|
|
187
|
-
if (!cleaned)
|
|
188
|
-
return "prompt";
|
|
189
|
-
return /^[0-9]/.test(cleaned) ? `_${cleaned}` : cleaned;
|
|
190
|
-
}
|
|
191
|
-
export function formatPromptCommandName(promptName, serverName, prefix) {
|
|
192
|
-
const serverPart = getServerPrefix(serverName, prefix) || sanitizeServerPrefix(serverName) || "server";
|
|
193
|
-
return `mcp__${serverPart}__${sanitizePromptName(promptName)}`;
|
|
194
|
-
}
|
|
195
|
-
function getLegacyServerPrefix(serverName, mode) {
|
|
196
|
-
if (mode === "none")
|
|
197
|
-
return "";
|
|
198
|
-
if (mode === "short")
|
|
199
|
-
return sanitizeServerPrefix(serverName.replace(/-?mcp$/i, ""), false) || "mcp";
|
|
200
|
-
if (mode === "mcp")
|
|
201
|
-
return `mcp__${sanitizeServerPrefix(serverName, false)}`;
|
|
202
|
-
return sanitizeServerPrefix(serverName, false);
|
|
203
|
-
}
|
|
204
|
-
function formatLegacyToolName(toolName, serverName, prefix) {
|
|
205
|
-
const serverPrefix = getLegacyServerPrefix(serverName, prefix);
|
|
206
|
-
const sanitizedToolName = toolName.replace(/[.-]/g, "_");
|
|
207
|
-
return serverPrefix ? `${serverPrefix}_${sanitizedToolName}` : sanitizedToolName;
|
|
208
|
-
}
|
|
209
|
-
export function getToolNameCandidates(toolName, serverName, prefix, includeLegacy = true) {
|
|
210
|
-
const candidates = new Set([
|
|
211
|
-
toolName,
|
|
212
|
-
formatToolName(toolName, serverName, prefix),
|
|
213
|
-
formatToolName(toolName, serverName, "server"),
|
|
214
|
-
formatToolName(toolName, serverName, "short"),
|
|
215
|
-
formatToolName(toolName, serverName, "mcp"),
|
|
216
|
-
]);
|
|
217
|
-
if (includeLegacy) {
|
|
218
|
-
const legacyToolName = toolName.replace(/-/g, "_");
|
|
219
|
-
candidates.add(legacyToolName);
|
|
220
|
-
candidates.add(formatToolName(legacyToolName, serverName, prefix));
|
|
221
|
-
candidates.add(formatToolName(legacyToolName, serverName, "server"));
|
|
222
|
-
candidates.add(formatToolName(legacyToolName, serverName, "short"));
|
|
223
|
-
candidates.add(formatToolName(legacyToolName, serverName, "mcp"));
|
|
224
|
-
candidates.add(formatLegacyToolName(toolName, serverName, prefix));
|
|
225
|
-
candidates.add(formatLegacyToolName(toolName, serverName, "server"));
|
|
226
|
-
candidates.add(formatLegacyToolName(toolName, serverName, "short"));
|
|
227
|
-
candidates.add(formatLegacyToolName(toolName, serverName, "mcp"));
|
|
228
|
-
candidates.add(formatToolName(toolName, serverName, prefix).replace(/-/g, "_"));
|
|
229
|
-
candidates.add(formatToolName(toolName, serverName, "server").replace(/-/g, "_"));
|
|
230
|
-
candidates.add(formatToolName(toolName, serverName, "short").replace(/-/g, "_"));
|
|
231
|
-
candidates.add(formatToolName(toolName, serverName, "mcp").replace(/-/g, "_"));
|
|
232
|
-
}
|
|
233
|
-
return candidates;
|
|
234
|
-
}
|
|
235
|
-
function globToRegExp(pattern) {
|
|
236
|
-
const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
|
|
237
|
-
return new RegExp(`^${escaped}$`);
|
|
238
|
-
}
|
|
239
|
-
export function createToolSelectorCandidateIndex(allCurrentCandidates, additionalCurrentCandidatesByToolName) {
|
|
240
|
-
return {
|
|
241
|
-
allCurrentCandidates,
|
|
242
|
-
matchingCountByPattern: new Map(),
|
|
243
|
-
matcherByPattern: new Map(),
|
|
244
|
-
...(additionalCurrentCandidatesByToolName ? { additionalCurrentCandidatesByToolName } : {}),
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
export function matchesToolPattern(candidates, patterns) {
|
|
248
|
-
if (!Array.isArray(patterns) || patterns.length === 0)
|
|
249
|
-
return false;
|
|
250
|
-
for (const pattern of patterns) {
|
|
251
|
-
if (typeof pattern !== "string")
|
|
252
|
-
continue;
|
|
253
|
-
if (!pattern.includes("*") && !pattern.includes("?") && candidates.has(pattern)) {
|
|
254
|
-
return true;
|
|
255
|
-
}
|
|
256
|
-
if ((pattern.includes("*") || pattern.includes("?")) && [...candidates].some(candidate => globToRegExp(pattern).test(candidate))) {
|
|
257
|
-
return true;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
return false;
|
|
261
|
-
}
|
|
262
|
-
function indexHasOtherCurrentMatch(index, toolName, currentCandidates, pattern) {
|
|
263
|
-
const additionalCandidates = index.additionalCurrentCandidatesByToolName?.get(toolName);
|
|
264
|
-
const hasCandidate = (candidate) => index.allCurrentCandidates.has(candidate) || additionalCandidates?.has(candidate) === true;
|
|
265
|
-
const isGlob = pattern.includes("*") || pattern.includes("?");
|
|
266
|
-
if (!isGlob) {
|
|
267
|
-
return hasCandidate(pattern) && !currentCandidates.has(pattern);
|
|
268
|
-
}
|
|
269
|
-
let matcher = index.matcherByPattern.get(pattern);
|
|
270
|
-
if (!matcher) {
|
|
271
|
-
matcher = globToRegExp(pattern);
|
|
272
|
-
index.matcherByPattern.set(pattern, matcher);
|
|
273
|
-
}
|
|
274
|
-
let matchingCount = index.matchingCountByPattern.get(pattern);
|
|
275
|
-
if (matchingCount === undefined) {
|
|
276
|
-
matchingCount = 0;
|
|
277
|
-
for (const candidate of index.allCurrentCandidates) {
|
|
278
|
-
if (matcher.test(candidate))
|
|
279
|
-
matchingCount++;
|
|
280
|
-
}
|
|
281
|
-
index.matchingCountByPattern.set(pattern, matchingCount);
|
|
282
|
-
}
|
|
283
|
-
let totalMatchingCount = matchingCount;
|
|
284
|
-
if (additionalCandidates) {
|
|
285
|
-
for (const candidate of additionalCandidates) {
|
|
286
|
-
if (!index.allCurrentCandidates.has(candidate) && matcher.test(candidate))
|
|
287
|
-
totalMatchingCount++;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
if (totalMatchingCount === 0)
|
|
291
|
-
return false;
|
|
292
|
-
let currentMatchingCount = 0;
|
|
293
|
-
for (const candidate of currentCandidates) {
|
|
294
|
-
if (hasCandidate(candidate) && matcher.test(candidate))
|
|
295
|
-
currentMatchingCount++;
|
|
296
|
-
}
|
|
297
|
-
return totalMatchingCount > currentMatchingCount;
|
|
298
|
-
}
|
|
299
|
-
function matchesToolSelector(toolName, serverName, prefix, patterns, otherCurrentCandidates) {
|
|
300
|
-
if (!Array.isArray(patterns) || patterns.length === 0)
|
|
301
|
-
return false;
|
|
302
|
-
const currentCandidates = getToolNameCandidates(toolName, serverName, prefix, false);
|
|
303
|
-
if (matchesToolPattern(currentCandidates, patterns))
|
|
304
|
-
return true;
|
|
305
|
-
if (!otherCurrentCandidates)
|
|
306
|
-
return matchesToolPattern(getToolNameCandidates(toolName, serverName, prefix), patterns);
|
|
307
|
-
const legacyCandidates = getToolNameCandidates(toolName, serverName, prefix);
|
|
308
|
-
for (const candidate of currentCandidates)
|
|
309
|
-
legacyCandidates.delete(candidate);
|
|
310
|
-
return patterns.some(pattern => {
|
|
311
|
-
if (typeof pattern !== "string" || !matchesToolPattern(legacyCandidates, [pattern]))
|
|
312
|
-
return false;
|
|
313
|
-
const hasCollision = otherCurrentCandidates instanceof Set
|
|
314
|
-
? matchesToolPattern(otherCurrentCandidates, [pattern])
|
|
315
|
-
: indexHasOtherCurrentMatch(otherCurrentCandidates, toolName, currentCandidates, pattern);
|
|
316
|
-
return !hasCollision;
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
export function isToolIncluded(toolName, serverName, prefix, includeTools, otherCurrentCandidates) {
|
|
320
|
-
if (!Array.isArray(includeTools) || includeTools.length === 0)
|
|
321
|
-
return true;
|
|
322
|
-
return matchesToolSelector(toolName, serverName, prefix, includeTools, otherCurrentCandidates);
|
|
323
|
-
}
|
|
324
|
-
export function isToolExcluded(toolName, serverName, prefix, excludeTools, otherCurrentCandidates) {
|
|
325
|
-
return matchesToolSelector(toolName, serverName, prefix, excludeTools, otherCurrentCandidates);
|
|
326
|
-
}
|
|
327
|
-
export function isToolAllowed(toolName, serverName, prefix, includeTools, excludeTools, otherCurrentCandidates) {
|
|
328
|
-
return isToolIncluded(toolName, serverName, prefix, includeTools, otherCurrentCandidates)
|
|
329
|
-
&& !isToolExcluded(toolName, serverName, prefix, excludeTools, otherCurrentCandidates);
|
|
330
|
-
}
|
|
331
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIzC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAE3D,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAU,CAAC;AA6LtD,6DAA6D;AAC7D,+GAA+G;AAC/G,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,6BAA6B,EAC7B,iCAAiC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,CAAC;WACpF,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,sBAAsB,CAAC,CAAC;AAC3F,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { UiResourcePermissions } from "./types.ts";
|
|
2
|
-
export declare const RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
|
|
3
|
-
export declare function getToolUiResourceUri(tool: {
|
|
4
|
-
_meta?: Record<string, unknown> | undefined;
|
|
5
|
-
}): string | undefined;
|
|
6
|
-
export declare function buildAllowAttribute(permissions: UiResourcePermissions | undefined): string;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export const RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
|
|
2
|
-
const RESOURCE_URI_META_KEY = "ui/resourceUri";
|
|
3
|
-
export function getToolUiResourceUri(tool) {
|
|
4
|
-
const meta = tool._meta;
|
|
5
|
-
let resourceUri = getNestedResourceUri(meta);
|
|
6
|
-
if (resourceUri === undefined) {
|
|
7
|
-
resourceUri = meta?.[RESOURCE_URI_META_KEY];
|
|
8
|
-
}
|
|
9
|
-
if (typeof resourceUri === "string" && resourceUri.startsWith("ui://")) {
|
|
10
|
-
return resourceUri;
|
|
11
|
-
}
|
|
12
|
-
if (resourceUri !== undefined) {
|
|
13
|
-
throw new Error(`Invalid UI resource URI: ${JSON.stringify(resourceUri)}`);
|
|
14
|
-
}
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
export function buildAllowAttribute(permissions) {
|
|
18
|
-
if (!permissions)
|
|
19
|
-
return "";
|
|
20
|
-
const allowed = [];
|
|
21
|
-
if (permissions.camera)
|
|
22
|
-
allowed.push("camera");
|
|
23
|
-
if (permissions.microphone)
|
|
24
|
-
allowed.push("microphone");
|
|
25
|
-
if (permissions.geolocation)
|
|
26
|
-
allowed.push("geolocation");
|
|
27
|
-
if (permissions.clipboardWrite)
|
|
28
|
-
allowed.push("clipboard-write");
|
|
29
|
-
return allowed.join("; ");
|
|
30
|
-
}
|
|
31
|
-
function getNestedResourceUri(meta) {
|
|
32
|
-
const ui = meta?.ui;
|
|
33
|
-
if (!ui || typeof ui !== "object")
|
|
34
|
-
return undefined;
|
|
35
|
-
return ui.resourceUri;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=ui-app-bridge-helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ui-app-bridge-helpers.js","sourceRoot":"","sources":["../ui-app-bridge-helpers.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AAE9D,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C,MAAM,UAAU,oBAAoB,CAAC,IAAqD;IACxF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;IACxB,IAAI,WAAW,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,WAAW,GAAG,IAAI,EAAE,CAAC,qBAAqB,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACvE,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,WAA8C;IAChF,IAAI,CAAC,WAAW;QAAE,OAAO,EAAE,CAAC;IAE5B,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,WAAW,CAAC,MAAM;QAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/C,IAAI,WAAW,CAAC,UAAU;QAAE,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACvD,IAAI,WAAW,CAAC,WAAW;QAAE,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACzD,IAAI,WAAW,CAAC,cAAc;QAAE,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAChE,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAyC;IACrE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC;IACpB,IAAI,CAAC,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACpD,OAAQ,EAA8B,CAAC,WAAW,CAAC;AACrD,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type SessionRecoveryDeps } from "./session-recovery.ts";
|
|
2
|
-
import type { McpServerManager } from "./server-manager.ts";
|
|
3
|
-
import { type McpConfig, type UiResourceContent } from "./types.ts";
|
|
4
|
-
interface ReadUiResourceOptions {
|
|
5
|
-
config?: McpConfig;
|
|
6
|
-
signal?: AbortSignal;
|
|
7
|
-
onNeedsAuth?: SessionRecoveryDeps["onNeedsAuth"];
|
|
8
|
-
}
|
|
9
|
-
export declare class UiResourceHandler {
|
|
10
|
-
private manager;
|
|
11
|
-
private config;
|
|
12
|
-
private log;
|
|
13
|
-
constructor(manager: McpServerManager, config?: McpConfig | undefined);
|
|
14
|
-
readUiResource(serverName: string, uri: string, options?: ReadUiResourceOptions): Promise<UiResourceContent>;
|
|
15
|
-
private getListResourceMeta;
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import { RESOURCE_MIME_TYPE } from "./ui-app-bridge-helpers.js";
|
|
2
|
-
import { UrlElicitationRequiredError } from "@modelcontextprotocol/client";
|
|
3
|
-
import { getInputRequiredNeedsUiDetails, InputRequiredNeedsUiError, ResourceFetchError, ResourceParseError, } from "./errors.js";
|
|
4
|
-
import { logger } from "./logger.js";
|
|
5
|
-
import { SessionRecoveryAuthRequiredError, withSessionRecovery } from "./session-recovery.js";
|
|
6
|
-
import { isServerDisabled } from "./types.js";
|
|
7
|
-
export class UiResourceHandler {
|
|
8
|
-
manager;
|
|
9
|
-
config;
|
|
10
|
-
log = logger.child({ component: "UiResourceHandler" });
|
|
11
|
-
constructor(manager, config = undefined) {
|
|
12
|
-
this.manager = manager;
|
|
13
|
-
this.config = config;
|
|
14
|
-
}
|
|
15
|
-
async readUiResource(serverName, uri, options = {}) {
|
|
16
|
-
const log = this.log.child({ server: serverName, uri });
|
|
17
|
-
if (!uri.startsWith("ui://")) {
|
|
18
|
-
throw new ResourceParseError(uri, "URI must start with ui://", { server: serverName });
|
|
19
|
-
}
|
|
20
|
-
log.debug("Fetching UI resource");
|
|
21
|
-
let result;
|
|
22
|
-
try {
|
|
23
|
-
const config = options.config ?? this.config;
|
|
24
|
-
if (config && isServerDisabled(config.mcpServers[serverName])) {
|
|
25
|
-
throw new Error(`MCP server "${serverName}" is disabled`);
|
|
26
|
-
}
|
|
27
|
-
if (config) {
|
|
28
|
-
this.manager.touch(serverName);
|
|
29
|
-
this.manager.incrementInFlight(serverName);
|
|
30
|
-
try {
|
|
31
|
-
result = await withSessionRecovery({
|
|
32
|
-
manager: this.manager,
|
|
33
|
-
config,
|
|
34
|
-
...(options.signal ? { signal: options.signal } : {}),
|
|
35
|
-
...(options.onNeedsAuth ? { onNeedsAuth: options.onNeedsAuth } : {}),
|
|
36
|
-
}, serverName, async (connection) => {
|
|
37
|
-
const refreshRead = await this.manager.prepareResourceUse?.(serverName, uri, connection);
|
|
38
|
-
const requestOptions = this.manager.getRequestOptions(serverName, options.signal);
|
|
39
|
-
return connection.client.readResource({ uri }, refreshRead ? { ...requestOptions, cacheMode: "refresh" } : requestOptions);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
finally {
|
|
43
|
-
this.manager.decrementInFlight(serverName);
|
|
44
|
-
this.manager.touch(serverName);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
result = await this.manager.readResource(serverName, uri, options.signal);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
if (error instanceof UrlElicitationRequiredError || error instanceof SessionRecoveryAuthRequiredError)
|
|
53
|
-
throw error;
|
|
54
|
-
const inputRequired = getInputRequiredNeedsUiDetails(error, { server: serverName, resourceUri: uri });
|
|
55
|
-
if (inputRequired) {
|
|
56
|
-
throw new InputRequiredNeedsUiError(inputRequired, error instanceof Error ? error : undefined);
|
|
57
|
-
}
|
|
58
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
59
|
-
log.error("Failed to read resource", error instanceof Error ? error : undefined);
|
|
60
|
-
throw new ResourceFetchError(uri, message, {
|
|
61
|
-
server: serverName,
|
|
62
|
-
...(error instanceof Error ? { cause: error } : {}),
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
const content = selectContent(result, uri);
|
|
66
|
-
const mimeType = content.mimeType;
|
|
67
|
-
if (mimeType && !isHtmlMimeType(mimeType)) {
|
|
68
|
-
log.warn("Unsupported MIME type", { mimeType });
|
|
69
|
-
throw new ResourceParseError(uri, `unsupported MIME type "${mimeType}" (expected text/html or ${RESOURCE_MIME_TYPE})`, { server: serverName, mimeType });
|
|
70
|
-
}
|
|
71
|
-
const html = toHtml(content);
|
|
72
|
-
if (!html.trim()) {
|
|
73
|
-
log.warn("Resource content is empty");
|
|
74
|
-
throw new ResourceParseError(uri, "content is empty", { server: serverName });
|
|
75
|
-
}
|
|
76
|
-
const contentMeta = extractUiMeta(content._meta);
|
|
77
|
-
const listMeta = extractUiMeta(this.getListResourceMeta(serverName, uri));
|
|
78
|
-
log.debug("Resource loaded successfully", {
|
|
79
|
-
contentLength: html.length,
|
|
80
|
-
hasCsp: !!contentMeta.csp || !!listMeta.csp,
|
|
81
|
-
});
|
|
82
|
-
return {
|
|
83
|
-
uri: content.uri ?? uri,
|
|
84
|
-
html,
|
|
85
|
-
mimeType: mimeType ?? RESOURCE_MIME_TYPE,
|
|
86
|
-
meta: {
|
|
87
|
-
...((contentMeta.csp ?? listMeta.csp) !== undefined ? { csp: contentMeta.csp ?? listMeta.csp } : {}),
|
|
88
|
-
...((contentMeta.permissions ?? listMeta.permissions) !== undefined
|
|
89
|
-
? { permissions: contentMeta.permissions ?? listMeta.permissions }
|
|
90
|
-
: {}),
|
|
91
|
-
...((contentMeta.domain ?? listMeta.domain) !== undefined ? { domain: contentMeta.domain ?? listMeta.domain } : {}),
|
|
92
|
-
...((contentMeta.prefersBorder ?? listMeta.prefersBorder) !== undefined
|
|
93
|
-
? { prefersBorder: contentMeta.prefersBorder ?? listMeta.prefersBorder }
|
|
94
|
-
: {}),
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
getListResourceMeta(serverName, uri) {
|
|
99
|
-
const connection = this.manager.getConnection(serverName);
|
|
100
|
-
if (!connection?.resources?.length)
|
|
101
|
-
return undefined;
|
|
102
|
-
const resource = connection.resources.find((entry) => entry.uri === uri);
|
|
103
|
-
if (!resource || !resource._meta || typeof resource._meta !== "object")
|
|
104
|
-
return undefined;
|
|
105
|
-
return resource._meta;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
function selectContent(result, preferredUri) {
|
|
109
|
-
const contents = (result.contents ?? []);
|
|
110
|
-
if (contents.length === 0) {
|
|
111
|
-
throw new Error(`No contents returned for UI resource: ${preferredUri}`);
|
|
112
|
-
}
|
|
113
|
-
const byUri = contents.find((content) => content.uri === preferredUri);
|
|
114
|
-
if (byUri)
|
|
115
|
-
return byUri;
|
|
116
|
-
const byHtmlMime = contents.find((content) => content.mimeType && isHtmlMimeType(content.mimeType));
|
|
117
|
-
if (byHtmlMime)
|
|
118
|
-
return byHtmlMime;
|
|
119
|
-
const firstContent = contents[0];
|
|
120
|
-
if (!firstContent) {
|
|
121
|
-
throw new Error(`No contents returned for UI resource: ${preferredUri}`);
|
|
122
|
-
}
|
|
123
|
-
return firstContent;
|
|
124
|
-
}
|
|
125
|
-
function isHtmlMimeType(mimeType) {
|
|
126
|
-
const normalized = mimeType.toLowerCase();
|
|
127
|
-
return normalized.startsWith("text/html") || normalized === RESOURCE_MIME_TYPE.toLowerCase();
|
|
128
|
-
}
|
|
129
|
-
function toHtml(content) {
|
|
130
|
-
if (typeof content.text === "string") {
|
|
131
|
-
return content.text;
|
|
132
|
-
}
|
|
133
|
-
if (typeof content.blob === "string") {
|
|
134
|
-
return Buffer.from(content.blob, "base64").toString("utf-8");
|
|
135
|
-
}
|
|
136
|
-
throw new Error(`UI resource ${content.uri ?? "(unknown)"} did not include text or blob content`);
|
|
137
|
-
}
|
|
138
|
-
const OPENAI_CSP_FIELD_MAPPINGS = [
|
|
139
|
-
["resource_domains", "resourceDomains"],
|
|
140
|
-
["connect_domains", "connectDomains"],
|
|
141
|
-
["frame_domains", "frameDomains"],
|
|
142
|
-
];
|
|
143
|
-
const UI_CSP_DOMAIN_FIELDS = [
|
|
144
|
-
"resourceDomains",
|
|
145
|
-
"connectDomains",
|
|
146
|
-
"frameDomains",
|
|
147
|
-
"baseUriDomains",
|
|
148
|
-
];
|
|
149
|
-
function extractUiMeta(meta) {
|
|
150
|
-
if (!meta || typeof meta !== "object")
|
|
151
|
-
return {};
|
|
152
|
-
const ui = isRecord(meta.ui) ? meta.ui : undefined;
|
|
153
|
-
const out = {};
|
|
154
|
-
const openAiCsp = Object.hasOwn(meta, "openai/widgetCSP")
|
|
155
|
-
? normalizeOpenAiWidgetCsp(meta["openai/widgetCSP"])
|
|
156
|
-
: undefined;
|
|
157
|
-
const hasStandardCsp = !!ui && Object.hasOwn(ui, "csp");
|
|
158
|
-
const standardCspValue = hasStandardCsp ? ui.csp : undefined;
|
|
159
|
-
if (hasStandardCsp && !isRecord(standardCspValue)) {
|
|
160
|
-
// A declared canonical container takes precedence even when malformed.
|
|
161
|
-
out.csp = {};
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
const standardCsp = hasStandardCsp
|
|
165
|
-
? normalizeUiResourceCsp(standardCspValue)
|
|
166
|
-
: undefined;
|
|
167
|
-
if (openAiCsp || standardCsp) {
|
|
168
|
-
out.csp = { ...openAiCsp, ...standardCsp };
|
|
169
|
-
if (isRecord(standardCspValue)) {
|
|
170
|
-
for (const [, standardField] of OPENAI_CSP_FIELD_MAPPINGS) {
|
|
171
|
-
if (Object.hasOwn(standardCspValue, standardField) && !copyStringArray(standardCspValue[standardField])) {
|
|
172
|
-
delete out.csp[standardField];
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
if (ui && isRecord(ui.permissions)) {
|
|
179
|
-
out.permissions = ui.permissions;
|
|
180
|
-
}
|
|
181
|
-
if (ui && typeof ui.domain === "string") {
|
|
182
|
-
out.domain = ui.domain;
|
|
183
|
-
}
|
|
184
|
-
if (ui && typeof ui.prefersBorder === "boolean") {
|
|
185
|
-
out.prefersBorder = ui.prefersBorder;
|
|
186
|
-
}
|
|
187
|
-
return out;
|
|
188
|
-
}
|
|
189
|
-
function normalizeUiResourceCsp(value) {
|
|
190
|
-
if (!isRecord(value))
|
|
191
|
-
return {};
|
|
192
|
-
const csp = {};
|
|
193
|
-
for (const field of UI_CSP_DOMAIN_FIELDS) {
|
|
194
|
-
const domains = copyStringArray(value[field]);
|
|
195
|
-
if (domains)
|
|
196
|
-
csp[field] = domains;
|
|
197
|
-
}
|
|
198
|
-
return csp;
|
|
199
|
-
}
|
|
200
|
-
function normalizeOpenAiWidgetCsp(value) {
|
|
201
|
-
if (!isRecord(value))
|
|
202
|
-
return {};
|
|
203
|
-
const csp = {};
|
|
204
|
-
for (const [sourceField, targetField] of OPENAI_CSP_FIELD_MAPPINGS) {
|
|
205
|
-
const domains = copyStringArray(value[sourceField]);
|
|
206
|
-
if (domains)
|
|
207
|
-
csp[targetField] = domains;
|
|
208
|
-
}
|
|
209
|
-
return csp;
|
|
210
|
-
}
|
|
211
|
-
function copyStringArray(value) {
|
|
212
|
-
return Array.isArray(value) && value.every((entry) => typeof entry === "string")
|
|
213
|
-
? [...value]
|
|
214
|
-
: undefined;
|
|
215
|
-
}
|
|
216
|
-
function isRecord(value) {
|
|
217
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
218
|
-
}
|
|
219
|
-
//# sourceMappingURL=ui-resource-handler.js.map
|