@humain/terminal 0.0.6 → 0.0.7
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/CHANGELOG.md +52 -0
- package/README.md +10 -4
- package/dist/bundle/chunks/anthropic-messages-GDMGYAZB.js +6 -0
- package/dist/bundle/chunks/anthropic.js +75 -0
- package/dist/bundle/chunks/azure-openai-responses-ZN52D6YC.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +77 -0
- package/dist/bundle/chunks/chunk-3D3G2X5U.js +6 -0
- package/dist/bundle/chunks/chunk-3VI4HD7D.js +31 -0
- package/dist/bundle/chunks/chunk-6R7UI4IY.js +2 -0
- package/dist/bundle/chunks/chunk-72KO4OMP.js +2 -0
- package/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
- package/dist/bundle/chunks/chunk-ARF4OE6X.js +105 -0
- package/dist/bundle/chunks/chunk-BOW22LW6.js +42 -0
- package/dist/bundle/chunks/chunk-BZQ53VGE.js +70 -0
- package/dist/bundle/chunks/chunk-CBHC6EL7.js +133 -0
- package/dist/bundle/chunks/chunk-D7XAASZM.js +4 -0
- package/dist/bundle/chunks/chunk-ECWELYBH.js +17 -0
- package/dist/bundle/chunks/chunk-GMWCTUPB.js +2 -0
- package/dist/bundle/chunks/chunk-H2O6VOXT.js +11 -0
- package/dist/bundle/chunks/chunk-HNVPY4LZ.js +5995 -0
- package/dist/bundle/chunks/chunk-JUUC5AZY.js +2 -0
- package/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
- package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
- package/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
- package/dist/bundle/chunks/chunk-M2GYSCCG.js +44 -0
- package/dist/bundle/chunks/chunk-MA4UUCYX.js +18 -0
- package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
- package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
- package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
- package/dist/bundle/chunks/chunk-SGTGQNNP.js +4 -0
- package/dist/bundle/chunks/chunk-TEPMHNKQ.js +2 -0
- package/dist/bundle/chunks/chunk-TXBQIIIO.js +2 -0
- package/dist/bundle/chunks/chunk-WJZ4KLGL.js +2 -0
- package/dist/bundle/chunks/chunk-XNGRGP62.js +2 -0
- package/dist/bundle/chunks/dist-7DSXV2TY.js +9 -0
- package/dist/bundle/chunks/dist-BXEVYJIO.js +7 -0
- package/dist/bundle/chunks/es-P2KNSZYR.js +9 -0
- package/dist/bundle/chunks/es5-FGTJ7ZFW.js +2 -0
- package/dist/bundle/chunks/event-streams-JOSQQSII.js +2 -0
- package/dist/bundle/chunks/extract-2L7ZVN7F.js +106 -0
- package/dist/bundle/chunks/github-copilot.js +2 -0
- package/dist/bundle/chunks/google-generative-ai-XT7NQJ2E.js +2 -0
- package/dist/bundle/chunks/google-vertex-IDQ6Z53W.js +2 -0
- package/dist/bundle/chunks/image-resize-worker.js +2 -0
- package/dist/bundle/chunks/kimi-coding.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-HHDZ4FHR.js +5 -0
- package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
- package/dist/bundle/chunks/node-XY3CBY3C.js +294 -0
- package/dist/bundle/chunks/node-ZHY4LHC7.js +15 -0
- package/dist/bundle/chunks/openai-codex-responses-HRVCDY54.js +8 -0
- package/dist/bundle/chunks/openai-codex.js +75 -0
- package/dist/bundle/chunks/openai-completions-6QBYTBXY.js +7 -0
- package/dist/bundle/chunks/openai-responses-4MWLJHIK.js +2 -0
- package/dist/bundle/chunks/openrouter-images-Y2PCWAQH.js +2 -0
- package/dist/bundle/chunks/openrouter.js +75 -0
- package/dist/bundle/chunks/pdfjs-UKQT3OWY.js +107 -0
- package/dist/bundle/chunks/pi-messages-57K43J6J.js +8 -0
- package/dist/bundle/chunks/promise-J5TGSM32.js +2 -0
- package/dist/bundle/chunks/radius.js +75 -0
- package/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
- package/dist/bundle/chunks/undici-D6ABF53Q.js +2 -0
- package/dist/bundle/chunks/webapi-AFS5FDJJ.js +5 -0
- package/dist/bundle/chunks/xai.js +2 -0
- package/dist/bundle/cli.js +3 -0
- package/dist/bundle/client.js +2 -0
- package/dist/bundle/index.js +2 -0
- package/dist/bundle/rpc-entry.js +3 -0
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +29 -9
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +2 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +19 -11
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +50 -14
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +163 -95
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +6 -7
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +3 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +4 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +41 -32
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/defaults.d.ts +1 -0
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/defaults.js +9 -0
- package/dist/core/defaults.js.map +1 -1
- package/dist/core/extensions/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +115 -48
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +38 -9
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +3 -0
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +1 -1
- package/dist/core/footer-data-provider.js +1 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/keybindings.d.ts +20 -19
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +26 -5
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-config.d.ts +5 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +3 -1
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +14 -8
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js +2 -1
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +22 -14
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +2 -1
- package/dist/core/pi-manifest.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +2 -1
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +3 -2
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +10 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-export.d.ts +4 -0
- package/dist/core/session-export.d.ts.map +1 -0
- package/dist/core/session-export.js +32 -0
- package/dist/core/session-export.js.map +1 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +2 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-diagnostics.d.ts +9 -0
- package/dist/core/settings-diagnostics.d.ts.map +1 -0
- package/dist/core/settings-diagnostics.js +21 -0
- package/dist/core/settings-diagnostics.js.map +1 -0
- package/dist/core/settings-manager.d.ts +9 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +51 -10
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +51 -33
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +11 -2
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +16 -3
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +62 -29
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +0 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +2 -5
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +20 -4
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/index.d.ts +4 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +19 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +16 -0
- package/dist/core/tools/powershell.d.ts.map +1 -0
- package/dist/core/tools/powershell.js +39 -0
- package/dist/core/tools/powershell.js.map +1 -0
- package/dist/core/tools/subagent.d.ts.map +1 -1
- package/dist/core/tools/subagent.js +4 -1
- package/dist/core/tools/subagent.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +2 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +2 -0
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +6 -2
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/humain/agent-execution-protocol.d.ts +1 -217
- package/dist/humain/agent-execution-protocol.d.ts.map +1 -1
- package/dist/humain/agent-execution-protocol.js +1 -203
- package/dist/humain/agent-execution-protocol.js.map +1 -1
- package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +107 -16
- package/dist/humain/mcp-adapter/vendor/CHANGELOG.md +82 -0
- package/dist/humain/mcp-adapter/vendor/README.md +47 -15
- package/dist/humain/mcp-adapter/vendor/cli.js +4 -4
- package/dist/humain/mcp-adapter/vendor/commands.ts +5 -3
- package/dist/humain/mcp-adapter/vendor/config.ts +46 -5
- package/dist/humain/mcp-adapter/vendor/direct-tools.ts +103 -92
- package/dist/humain/mcp-adapter/vendor/dist/agent-dir.d.ts +10 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-dir.js +63 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-dir.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-loader.d.ts +8 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-loader.js +356 -0
- package/dist/humain/mcp-adapter/vendor/dist/agent-plugin-loader.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/config.d.ts +123 -0
- package/dist/humain/mcp-adapter/vendor/dist/config.js +1088 -0
- package/dist/humain/mcp-adapter/vendor/dist/config.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/mcp-bearer-store.d.ts +24 -0
- package/dist/humain/mcp-adapter/vendor/dist/mcp-bearer-store.js +336 -0
- package/dist/humain/mcp-adapter/vendor/dist/mcp-bearer-store.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/metadata-cache.d.ts +19 -0
- package/dist/humain/mcp-adapter/vendor/dist/metadata-cache.js +319 -0
- package/dist/humain/mcp-adapter/vendor/dist/metadata-cache.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/package-mcp-loader.d.ts +2 -0
- package/dist/humain/mcp-adapter/vendor/dist/package-mcp-loader.js +156 -0
- package/dist/humain/mcp-adapter/vendor/dist/package-mcp-loader.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/resource-tools.d.ts +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/resource-tools.js +15 -0
- package/dist/humain/mcp-adapter/vendor/dist/resource-tools.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/types.d.ts +566 -0
- package/dist/humain/mcp-adapter/vendor/dist/types.js +287 -0
- package/dist/humain/mcp-adapter/vendor/dist/types.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-app-bridge-helpers.d.ts +6 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-app-bridge-helpers.js +37 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-app-bridge-helpers.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-stream-types.d.ts +104 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-stream-types.js +59 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-stream-types.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-tool-visibility.d.ts +4 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-tool-visibility.js +27 -0
- package/dist/humain/mcp-adapter/vendor/dist/ui-tool-visibility.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/dist/utils.d.ts +32 -0
- package/dist/humain/mcp-adapter/vendor/dist/utils.js +338 -0
- package/dist/humain/mcp-adapter/vendor/dist/utils.js.map +1 -0
- package/dist/humain/mcp-adapter/vendor/failure-backoff.ts +23 -0
- package/dist/humain/mcp-adapter/vendor/index.bundle.mjs +4870 -3878
- package/dist/humain/mcp-adapter/vendor/index.ts +294 -88
- package/dist/humain/mcp-adapter/vendor/init.ts +41 -30
- package/dist/humain/mcp-adapter/vendor/lifecycle.ts +16 -8
- package/dist/humain/mcp-adapter/vendor/mcp-auth-flow.ts +124 -32
- package/dist/humain/mcp-adapter/vendor/mcp-bearer-store.ts +0 -2
- package/dist/humain/mcp-adapter/vendor/mcp-code.ts +2 -0
- package/dist/humain/mcp-adapter/vendor/mcp-oauth-provider.ts +155 -16
- package/dist/humain/mcp-adapter/vendor/mcp-output-guard.ts +95 -7
- package/dist/humain/mcp-adapter/vendor/mcp-probe.ts +18 -4
- package/dist/humain/mcp-adapter/vendor/mcp-references.ts +376 -0
- package/dist/humain/mcp-adapter/vendor/mcp-status.ts +8 -19
- package/dist/humain/mcp-adapter/vendor/metadata-cache.ts +20 -12
- package/dist/humain/mcp-adapter/vendor/namespace-tools.ts +276 -0
- package/dist/humain/mcp-adapter/vendor/package.json +26 -8
- package/dist/humain/mcp-adapter/vendor/proxy-modes.ts +128 -32
- package/dist/humain/mcp-adapter/vendor/request-headers-command.ts +1 -1
- package/dist/humain/mcp-adapter/vendor/search-ranking.ts +2 -0
- package/dist/humain/mcp-adapter/vendor/server-manager.ts +69 -12
- package/dist/humain/mcp-adapter/vendor/state.ts +1 -3
- package/dist/humain/mcp-adapter/vendor/tool-result-renderer.ts +16 -2
- package/dist/humain/mcp-adapter/vendor/types.ts +51 -2
- package/dist/humain/mcp-adapter/vendor/ui-server.ts +3 -19
- package/dist/humain/mcp-adapter/vendor/ui-session.ts +2 -1
- package/dist/humain/mcp-adapter/vendor/utils.ts +21 -19
- package/dist/humain/mcp-adapter.d.ts.map +1 -1
- package/dist/humain/mcp-adapter.js +4 -0
- package/dist/humain/mcp-adapter.js.map +1 -1
- package/dist/humain/web-access/vendor/chrome-cookies.d.ts +14 -0
- package/dist/humain/web-access/vendor/chrome-cookies.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/chrome-cookies.js +85 -33
- package/dist/humain/web-access/vendor/chrome-cookies.js.map +1 -1
- package/dist/humain/web-access/vendor/credential-source.d.ts +1 -1
- package/dist/humain/web-access/vendor/credential-source.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/credential-source.js +3 -1
- package/dist/humain/web-access/vendor/credential-source.js.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.d.ts +2 -29
- package/dist/humain/web-access/vendor/curator-page.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-page.js +10 -1
- package/dist/humain/web-access/vendor/curator-page.js.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.d.ts +2 -29
- package/dist/humain/web-access/vendor/curator-server.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/curator-server.js +4 -0
- package/dist/humain/web-access/vendor/curator-server.js.map +1 -1
- package/dist/humain/web-access/vendor/extract.d.ts +11 -0
- package/dist/humain/web-access/vendor/extract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/extract.js +163 -20
- package/dist/humain/web-access/vendor/extract.js.map +1 -1
- package/dist/humain/web-access/vendor/fetch-params.d.ts +2 -0
- package/dist/humain/web-access/vendor/fetch-params.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/fetch-params.js +11 -0
- package/dist/humain/web-access/vendor/fetch-params.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-adc.d.ts +10 -0
- package/dist/humain/web-access/vendor/gemini-adc.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/gemini-adc.js +268 -0
- package/dist/humain/web-access/vendor/gemini-adc.js.map +1 -0
- package/dist/humain/web-access/vendor/gemini-api.d.ts +7 -1
- package/dist/humain/web-access/vendor/gemini-api.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-api.js +51 -15
- package/dist/humain/web-access/vendor/gemini-api.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-search.d.ts +9 -4
- package/dist/humain/web-access/vendor/gemini-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-search.js +63 -21
- package/dist/humain/web-access/vendor/gemini-search.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-url-context.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-url-context.js +3 -2
- package/dist/humain/web-access/vendor/gemini-url-context.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web-config.d.ts +8 -1
- package/dist/humain/web-access/vendor/gemini-web-config.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web-config.js +49 -4
- package/dist/humain/web-access/vendor/gemini-web-config.js.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web.d.ts +2 -1
- package/dist/humain/web-access/vendor/gemini-web.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/gemini-web.js +8 -3
- package/dist/humain/web-access/vendor/gemini-web.js.map +1 -1
- package/dist/humain/web-access/vendor/github-api.d.ts +1 -1
- package/dist/humain/web-access/vendor/github-api.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/github-api.js +6 -4
- package/dist/humain/web-access/vendor/github-api.js.map +1 -1
- package/dist/humain/web-access/vendor/github-extract.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/github-extract.js +50 -3
- package/dist/humain/web-access/vendor/github-extract.js.map +1 -1
- package/dist/humain/web-access/vendor/github-issue-pr.d.ts +27 -0
- package/dist/humain/web-access/vendor/github-issue-pr.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/github-issue-pr.js +701 -0
- package/dist/humain/web-access/vendor/github-issue-pr.js.map +1 -0
- package/dist/humain/web-access/vendor/index.d.ts +3 -31
- package/dist/humain/web-access/vendor/index.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/index.js +643 -530
- package/dist/humain/web-access/vendor/index.js.map +1 -1
- package/dist/humain/web-access/vendor/kimi-search.d.ts +5 -0
- package/dist/humain/web-access/vendor/kimi-search.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/kimi-search.js +228 -0
- package/dist/humain/web-access/vendor/kimi-search.js.map +1 -0
- package/dist/humain/web-access/vendor/openai-search.d.ts +3 -0
- package/dist/humain/web-access/vendor/openai-search.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/openai-search.js +89 -16
- package/dist/humain/web-access/vendor/openai-search.js.map +1 -1
- package/dist/humain/web-access/vendor/page-query.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/page-query.js +56 -8
- package/dist/humain/web-access/vendor/page-query.js.map +1 -1
- package/dist/humain/web-access/vendor/ssrf-protection.js +6 -1
- package/dist/humain/web-access/vendor/ssrf-protection.js.map +1 -1
- package/dist/humain/web-access/vendor/utils.d.ts +12 -0
- package/dist/humain/web-access/vendor/utils.d.ts.map +1 -1
- package/dist/humain/web-access/vendor/utils.js +343 -1
- package/dist/humain/web-access/vendor/utils.js.map +1 -1
- package/dist/humain/web-access/vendor/xcrawl.d.ts +4 -0
- package/dist/humain/web-access/vendor/xcrawl.d.ts.map +1 -0
- package/dist/humain/web-access/vendor/xcrawl.js +251 -0
- package/dist/humain/web-access/vendor/xcrawl.js.map +1 -0
- package/dist/humain/web-access/vendor/youtube-extract.js +2 -2
- package/dist/humain/web-access/vendor/youtube-extract.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +17 -14
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +4 -3
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +9 -3
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +53 -10
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +7 -2
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +118 -55
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-submenu.js +151 -0
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +68 -17
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +11 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +176 -106
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/session-share.d.ts +16 -0
- package/dist/modes/interactive/session-share.d.ts.map +1 -0
- package/dist/modes/interactive/session-share.js +188 -0
- package/dist/modes/interactive/session-share.js.map +1 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +6 -5
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/json-event.d.ts +16 -13
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js +20 -6
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +3 -2
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +2 -7
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +1 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +189 -3
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/changelog.d.ts +1 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +12 -2
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +2 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/management-http.d.ts +5 -3
- package/dist/utils/management-http.d.ts.map +1 -1
- package/dist/utils/management-http.js +14 -10
- package/dist/utils/management-http.js.map +1 -1
- package/dist/utils/shell.d.ts +3 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +17 -5
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +64 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/text.d.ts +8 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -0
- package/dist/utils/version-check.js +4 -4
- package/dist/utils/version-check.js.map +1 -1
- package/docs/compaction.md +15 -0
- package/docs/custom-provider.md +5 -2
- package/docs/environment-variables.md +7 -7
- package/docs/extensions.md +17 -7
- package/docs/json.md +7 -2
- package/docs/keybindings.md +8 -8
- package/docs/llama-cpp.md +2 -0
- package/docs/models.md +8 -2
- package/docs/packages.md +2 -2
- package/docs/rpc.md +9 -3
- package/docs/sdk.md +7 -2
- package/docs/settings.md +11 -3
- package/docs/skills.md +3 -2
- package/docs/terminal-setup.md +8 -0
- package/docs/usage.md +10 -7
- package/docs/windows.md +15 -1
- package/examples/extensions/border-status-editor.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +70 -8
- package/examples/extensions/custom-provider-anthropic/package.json +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/git-checkpoint.ts +2 -2
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/notify.ts +3 -1
- package/examples/extensions/sandbox/package-lock.json +14 -40
- package/examples/extensions/sandbox/package.json +2 -2
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/extensions/with-deps/package-lock.json +4 -4
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/rpc-extension-ui.ts +1 -1
- package/examples/sdk/06-extensions.ts +1 -1
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +293 -221
- package/package.json +21 -18
- package/src/humain/mcp-adapter/UPSTREAM.md +15 -5
- package/src/humain/mcp-adapter/upstream.json +4 -3
- package/src/humain/mcp-adapter/vendor/CHANGELOG.md +82 -0
- package/src/humain/web-access/UPSTREAM.md +1 -1
- package/src/humain/web-access/upstream.json +6 -4
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import {
|
|
9
9
|
UnauthorizedError,
|
|
10
10
|
type AddClientAuthentication,
|
|
11
|
+
type OAuthClientInformationContext,
|
|
11
12
|
type OAuthClientProvider,
|
|
12
13
|
type OAuthDiscoveryState,
|
|
13
14
|
} from "@modelcontextprotocol/client"
|
|
@@ -21,14 +22,14 @@ import {
|
|
|
21
22
|
updateTokens,
|
|
22
23
|
updateClientInfo,
|
|
23
24
|
clearAllCredentials,
|
|
24
|
-
clearClientInfo,
|
|
25
25
|
clearCodeVerifier,
|
|
26
|
-
|
|
26
|
+
invalidateAuthEntryCache,
|
|
27
27
|
type AuthEntry,
|
|
28
28
|
type AuthStorageOptions,
|
|
29
29
|
type StoredTokens,
|
|
30
30
|
type StoredClientInfo,
|
|
31
31
|
} from "./mcp-auth.ts"
|
|
32
|
+
import { OAuthMetadataSchema, OpenIdProviderDiscoveryMetadataSchema } from "@modelcontextprotocol/core"
|
|
32
33
|
import { resolveCommandSecret } from "./utils.ts"
|
|
33
34
|
import { getAppClientUri, getAppName } from "./agent-dir.ts"
|
|
34
35
|
|
|
@@ -71,6 +72,18 @@ function issuersMatch(first: string, second: string): boolean {
|
|
|
71
72
|
|| (second.endsWith("/") && second.slice(0, -1) === first)
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
function toOAuthTokens(tokens: StoredTokens): IssuerBoundTokens {
|
|
76
|
+
const result: IssuerBoundTokens = {
|
|
77
|
+
access_token: tokens.accessToken,
|
|
78
|
+
token_type: "Bearer",
|
|
79
|
+
}
|
|
80
|
+
if (tokens.refreshToken !== undefined) result.refresh_token = tokens.refreshToken
|
|
81
|
+
if (tokens.expiresAt !== undefined) result.expires_in = Math.max(0, Math.floor(tokens.expiresAt - Date.now() / 1000))
|
|
82
|
+
if (tokens.scope !== undefined) result.scope = tokens.scope
|
|
83
|
+
if (tokens.issuer !== undefined) result.issuer = tokens.issuer
|
|
84
|
+
return result
|
|
85
|
+
}
|
|
86
|
+
|
|
74
87
|
// Callback server configuration
|
|
75
88
|
const DEFAULT_OAUTH_CALLBACK_PORT = 19876
|
|
76
89
|
const DEFAULT_OAUTH_CALLBACK_PATH = "/callback"
|
|
@@ -118,6 +131,7 @@ export interface McpOAuthConfig {
|
|
|
118
131
|
clientName?: string
|
|
119
132
|
clientUri?: string
|
|
120
133
|
logoUri?: string
|
|
134
|
+
authServerMetadataUrl?: string
|
|
121
135
|
skipIssuerMetadataValidation?: boolean
|
|
122
136
|
}
|
|
123
137
|
|
|
@@ -149,6 +163,85 @@ export interface McpOAuthCallbacks {
|
|
|
149
163
|
onRedirect: (url: URL) => void | Promise<void>
|
|
150
164
|
}
|
|
151
165
|
|
|
166
|
+
function inferIssuerFromMetadataUrl(metadataUrl: string): string | undefined {
|
|
167
|
+
const url = new URL(metadataUrl)
|
|
168
|
+
const pathname = url.pathname.replace(/\/+$/, "") || "/"
|
|
169
|
+
const oauthPrefix = "/.well-known/oauth-authorization-server"
|
|
170
|
+
if (pathname === oauthPrefix || pathname.startsWith(`${oauthPrefix}/`)) {
|
|
171
|
+
const issuerPath = pathname.slice(oauthPrefix.length) || "/"
|
|
172
|
+
return new URL(issuerPath, url.origin).toString()
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const oidcPath = "/.well-known/openid-configuration"
|
|
176
|
+
if (pathname === oidcPath || pathname.startsWith(`${oidcPath}/`)) {
|
|
177
|
+
const issuerPath = pathname.slice(oidcPath.length) || "/"
|
|
178
|
+
return new URL(issuerPath, url.origin).toString()
|
|
179
|
+
}
|
|
180
|
+
if (pathname.endsWith(oidcPath)) {
|
|
181
|
+
const issuerPath = pathname.slice(0, -oidcPath.length) || "/"
|
|
182
|
+
return new URL(issuerPath, url.origin).toString()
|
|
183
|
+
}
|
|
184
|
+
return undefined
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function validateConfiguredIssuer(metadataUrl: string, issuer: string, skipIssuerValidation: boolean): void {
|
|
188
|
+
let parsedIssuer: URL
|
|
189
|
+
try {
|
|
190
|
+
parsedIssuer = new URL(issuer)
|
|
191
|
+
} catch (error) {
|
|
192
|
+
throw new Error("OAuth authorization-server metadata issuer must be an absolute URL", { cause: error })
|
|
193
|
+
}
|
|
194
|
+
if (parsedIssuer.protocol !== "http:" && parsedIssuer.protocol !== "https:") {
|
|
195
|
+
throw new Error("OAuth authorization-server metadata issuer must use http:// or https://")
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const expectedIssuer = inferIssuerFromMetadataUrl(metadataUrl)
|
|
199
|
+
if (skipIssuerValidation) return
|
|
200
|
+
if (expectedIssuer !== undefined && !issuersMatch(expectedIssuer, issuer)) {
|
|
201
|
+
throw new Error(
|
|
202
|
+
`OAuth authorization-server metadata issuer does not match authServerMetadataUrl: expected ${expectedIssuer}`,
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
if (expectedIssuer === undefined && !issuersMatch(new URL(metadataUrl).origin, issuer)) {
|
|
206
|
+
throw new Error(
|
|
207
|
+
`OAuth authorization-server metadata issuer does not match authServerMetadataUrl origin: expected ${new URL(metadataUrl).origin}`,
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async function loadConfiguredDiscoveryState(
|
|
213
|
+
metadataUrl: string,
|
|
214
|
+
serverUrl: string,
|
|
215
|
+
skipIssuerValidation: boolean,
|
|
216
|
+
signal?: AbortSignal,
|
|
217
|
+
): Promise<OAuthDiscoveryState> {
|
|
218
|
+
const response = await fetch(metadataUrl, {
|
|
219
|
+
headers: { accept: "application/json" },
|
|
220
|
+
...(signal !== undefined ? { signal } : {}),
|
|
221
|
+
})
|
|
222
|
+
if (!response.ok) {
|
|
223
|
+
await response.text().catch(() => {})
|
|
224
|
+
throw new Error(`OAuth authServerMetadataUrl request failed with HTTP ${response.status}`)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const payload = await response.json()
|
|
228
|
+
const oauthResult = OAuthMetadataSchema.safeParse(payload)
|
|
229
|
+
const metadata = oauthResult.success
|
|
230
|
+
? oauthResult.data
|
|
231
|
+
: OpenIdProviderDiscoveryMetadataSchema.parse(payload)
|
|
232
|
+
validateConfiguredIssuer(metadataUrl, metadata.issuer, skipIssuerValidation)
|
|
233
|
+
|
|
234
|
+
const resource = new URL(serverUrl)
|
|
235
|
+
resource.hash = ""
|
|
236
|
+
return {
|
|
237
|
+
authorizationServerUrl: metadata.issuer,
|
|
238
|
+
authorizationServerMetadata: metadata,
|
|
239
|
+
// The configured AS document is authoritative, so avoid a second PRM
|
|
240
|
+
// lookup while still binding the token request to the configured resource.
|
|
241
|
+
resourceMetadata: { resource: resource.toString() },
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
152
245
|
/**
|
|
153
246
|
* OAuth provider implementation for MCP servers.
|
|
154
247
|
* Implements the OAuthClientProvider interface from the MCP SDK.
|
|
@@ -161,6 +254,11 @@ export class McpOAuthProvider implements OAuthClientProvider {
|
|
|
161
254
|
private flowDiscoveryState: OAuthDiscoveryState | undefined
|
|
162
255
|
private flowIssuerMismatch = false
|
|
163
256
|
private flowState: string | undefined
|
|
257
|
+
private invalidatedAccessToken: string | undefined
|
|
258
|
+
private invalidatedClientId: string | undefined
|
|
259
|
+
private lastObservedClientId: string | undefined
|
|
260
|
+
private lastSavedAccessToken: string | undefined
|
|
261
|
+
private pendingAuthAccessToken: string | undefined
|
|
164
262
|
|
|
165
263
|
constructor(
|
|
166
264
|
private serverName: string,
|
|
@@ -188,6 +286,11 @@ export class McpOAuthProvider implements OAuthClientProvider {
|
|
|
188
286
|
|
|
189
287
|
deactivate(): void {
|
|
190
288
|
this.active = false
|
|
289
|
+
this.invalidatedAccessToken = undefined
|
|
290
|
+
this.invalidatedClientId = undefined
|
|
291
|
+
this.lastObservedClientId = undefined
|
|
292
|
+
this.lastSavedAccessToken = undefined
|
|
293
|
+
this.pendingAuthAccessToken = undefined
|
|
191
294
|
}
|
|
192
295
|
|
|
193
296
|
private assertStoredIssuerBindings(entry: AuthEntry | undefined, issuer: string | undefined): void {
|
|
@@ -264,6 +367,9 @@ export class McpOAuthProvider implements OAuthClientProvider {
|
|
|
264
367
|
* Returns undefined if no client info exists or if the server URL has changed.
|
|
265
368
|
*/
|
|
266
369
|
async clientInformation(): Promise<OAuthClientInformationMixed | undefined> {
|
|
370
|
+
if (this.invalidatedClientId !== undefined) {
|
|
371
|
+
invalidateAuthEntryCache(this.serverName)
|
|
372
|
+
}
|
|
267
373
|
const issuer = this.discoveredIssuer
|
|
268
374
|
const stored = await getAuthForUrl(this.serverName, this.serverUrl, this.storageOptions)
|
|
269
375
|
this.assertStoredIssuerBindings(stored, issuer)
|
|
@@ -298,7 +404,9 @@ export class McpOAuthProvider implements OAuthClientProvider {
|
|
|
298
404
|
// Keep client registration associated with this in-flight flow even if
|
|
299
405
|
// another runtime writes the shared persistent entry for the same name.
|
|
300
406
|
const clientInfo = this.flowClientInfo ?? stored?.clientInfo
|
|
407
|
+
if (clientInfo?.clientId === this.invalidatedClientId) return undefined
|
|
301
408
|
if (clientInfo) {
|
|
409
|
+
this.invalidatedClientId = undefined
|
|
302
410
|
// A stored SEP-2352 issuer stub for a config-pre-registered client
|
|
303
411
|
// (identified by the explicit marker, or by the legacy stub shape of
|
|
304
412
|
// {clientId, issuer} with no registration metadata) is only meaningful
|
|
@@ -329,6 +437,7 @@ export class McpOAuthProvider implements OAuthClientProvider {
|
|
|
329
437
|
}
|
|
330
438
|
// Return all registration metadata and the local issuer extension.
|
|
331
439
|
// This keeps the SDK OAuth view and the stored issuer binding consistent.
|
|
440
|
+
this.lastObservedClientId = clientInfo.clientId
|
|
332
441
|
return {
|
|
333
442
|
client_id: clientInfo.clientId,
|
|
334
443
|
client_secret: clientInfo.clientSecret,
|
|
@@ -380,6 +489,8 @@ export class McpOAuthProvider implements OAuthClientProvider {
|
|
|
380
489
|
...(issuer !== undefined ? { issuer } : {}),
|
|
381
490
|
}
|
|
382
491
|
this.flowClientInfo = clientInfo
|
|
492
|
+
this.invalidatedClientId = undefined
|
|
493
|
+
this.lastObservedClientId = clientInfo.clientId
|
|
383
494
|
updateClientInfo(this.serverName, clientInfo, this.serverUrl, this.storageOptions)
|
|
384
495
|
}
|
|
385
496
|
|
|
@@ -387,27 +498,28 @@ export class McpOAuthProvider implements OAuthClientProvider {
|
|
|
387
498
|
* Get stored OAuth tokens.
|
|
388
499
|
* Returns undefined if no tokens exist or if the server URL has changed.
|
|
389
500
|
*/
|
|
390
|
-
async tokens(): Promise<OAuthTokens | undefined> {
|
|
501
|
+
async tokens(ctx?: OAuthClientInformationContext): Promise<OAuthTokens | undefined> {
|
|
502
|
+
// Once this provider rejects a token, bypass its process-local cache until
|
|
503
|
+
// another process replaces that token in shared secure storage.
|
|
504
|
+
if (this.invalidatedAccessToken !== undefined) {
|
|
505
|
+
invalidateAuthEntryCache(this.serverName)
|
|
506
|
+
}
|
|
507
|
+
|
|
391
508
|
// Use getAuthForUrl to validate tokens are for the current server URL.
|
|
392
509
|
const entry = await getAuthForUrl(this.serverName, this.serverUrl, this.storageOptions)
|
|
393
|
-
if (!entry?.tokens) return undefined
|
|
510
|
+
if (!entry?.tokens || entry.tokens.accessToken === this.invalidatedAccessToken) return undefined
|
|
511
|
+
this.invalidatedAccessToken = undefined
|
|
394
512
|
const issuer = this.discoveredIssuer
|
|
395
513
|
this.assertStoredIssuerBindings(entry, issuer)
|
|
396
514
|
if (issuer && entry.tokens.issuer === undefined) {
|
|
397
515
|
entry.tokens.issuer = issuer
|
|
398
516
|
updateTokens(this.serverName, entry.tokens, this.serverUrl, this.storageOptions)
|
|
399
517
|
}
|
|
518
|
+
if (ctx !== undefined) {
|
|
519
|
+
this.pendingAuthAccessToken = entry.tokens.accessToken
|
|
520
|
+
}
|
|
400
521
|
|
|
401
|
-
return
|
|
402
|
-
access_token: entry.tokens.accessToken,
|
|
403
|
-
token_type: "Bearer",
|
|
404
|
-
refresh_token: entry.tokens.refreshToken,
|
|
405
|
-
expires_in: entry.tokens.expiresAt
|
|
406
|
-
? Math.max(0, Math.floor(entry.tokens.expiresAt - Date.now() / 1000))
|
|
407
|
-
: undefined,
|
|
408
|
-
scope: entry.tokens.scope,
|
|
409
|
-
...(entry.tokens.issuer !== undefined ? { issuer: entry.tokens.issuer } : {}),
|
|
410
|
-
} as IssuerBoundTokens
|
|
522
|
+
return toOAuthTokens(entry.tokens)
|
|
411
523
|
}
|
|
412
524
|
|
|
413
525
|
/**
|
|
@@ -427,6 +539,8 @@ export class McpOAuthProvider implements OAuthClientProvider {
|
|
|
427
539
|
}
|
|
428
540
|
this.throwIfInactive()
|
|
429
541
|
updateTokens(this.serverName, storedTokens, this.serverUrl, this.storageOptions)
|
|
542
|
+
this.invalidatedAccessToken = undefined
|
|
543
|
+
this.lastSavedAccessToken = storedTokens.accessToken
|
|
430
544
|
// Discovery must survive the browser redirect so the callback can verify
|
|
431
545
|
// the authorization server that minted the code. Once token issuance
|
|
432
546
|
// succeeds, clear it so a later 401 re-reads PRM and can observe an
|
|
@@ -492,6 +606,14 @@ export class McpOAuthProvider implements OAuthClientProvider {
|
|
|
492
606
|
|
|
493
607
|
async discoveryState(): Promise<OAuthDiscoveryState | undefined> {
|
|
494
608
|
this.throwIfInactive()
|
|
609
|
+
if (!this.flowDiscoveryState && this.config.authServerMetadataUrl !== undefined) {
|
|
610
|
+
this.flowDiscoveryState = await loadConfiguredDiscoveryState(
|
|
611
|
+
this.config.authServerMetadataUrl,
|
|
612
|
+
this.serverUrl,
|
|
613
|
+
this.config.skipIssuerMetadataValidation === true,
|
|
614
|
+
this.runtimeSignal,
|
|
615
|
+
)
|
|
616
|
+
}
|
|
495
617
|
return this.flowDiscoveryState ? structuredClone(this.flowDiscoveryState) : undefined
|
|
496
618
|
}
|
|
497
619
|
|
|
@@ -533,14 +655,31 @@ export class McpOAuthProvider implements OAuthClientProvider {
|
|
|
533
655
|
this.flowDiscoveryState = undefined
|
|
534
656
|
this.flowIssuerMismatch = false
|
|
535
657
|
this.flowState = undefined
|
|
658
|
+
this.invalidatedAccessToken = undefined
|
|
659
|
+
this.invalidatedClientId = undefined
|
|
660
|
+
this.lastObservedClientId = undefined
|
|
661
|
+
this.lastSavedAccessToken = undefined
|
|
662
|
+
this.pendingAuthAccessToken = undefined
|
|
536
663
|
clearAllCredentials(this.serverName, this.storageOptions)
|
|
537
664
|
break
|
|
538
665
|
case "client":
|
|
666
|
+
// Dynamic client registrations share the same credential-store entry as
|
|
667
|
+
// tokens. Keep SDK invalidation local so a stale process cannot rewrite
|
|
668
|
+
// that entry over credentials another process just authorized.
|
|
669
|
+
this.invalidatedClientId = this.lastObservedClientId
|
|
670
|
+
this.lastObservedClientId = undefined
|
|
539
671
|
this.flowClientInfo = undefined
|
|
540
|
-
|
|
672
|
+
invalidateAuthEntryCache(this.serverName)
|
|
541
673
|
break
|
|
542
674
|
case "tokens":
|
|
543
|
-
|
|
675
|
+
// Invalidation is provider-local. Persistently deleting a shared token
|
|
676
|
+
// here lets a process refreshing stale cached credentials erase a token
|
|
677
|
+
// that another process just authorized. A later tokens() call bypasses
|
|
678
|
+
// the local cache and adopts a replacement token when one exists.
|
|
679
|
+
this.invalidatedAccessToken = this.pendingAuthAccessToken ?? this.lastSavedAccessToken
|
|
680
|
+
this.lastSavedAccessToken = undefined
|
|
681
|
+
this.pendingAuthAccessToken = undefined
|
|
682
|
+
invalidateAuthEntryCache(this.serverName)
|
|
544
683
|
break
|
|
545
684
|
case "verifier":
|
|
546
685
|
clearCodeVerifier(this.serverName, this.storageOptions)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomBytes } from "node:crypto";
|
|
2
|
-
import { mkdtemp, writeFile } from "node:fs/promises";
|
|
2
|
+
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
5
|
import type { ContentBlock, McpSettings } from "./types.ts";
|
|
6
6
|
|
|
7
7
|
export const DEFAULT_MCP_OUTPUT_MAX_BYTES = 50 * 1024;
|
|
@@ -10,7 +10,9 @@ export const DEFAULT_MCP_DETAILS_MAX_BYTES = 16 * 1024;
|
|
|
10
10
|
|
|
11
11
|
const CONTENT_SUMMARY_LIMIT = 20;
|
|
12
12
|
const KEY_PREVIEW_LIMIT = 20;
|
|
13
|
-
const
|
|
13
|
+
const KEY_MAX_BYTES = 120;
|
|
14
|
+
const STRUCTURED_CONTENT_PRESERVE_MAX_BYTES = 4 * 1024;
|
|
15
|
+
const STRUCTURED_CONTENT_FIELD_PRESERVE_MAX_BYTES = 512;
|
|
14
16
|
|
|
15
17
|
type Recordish = Record<string, unknown>;
|
|
16
18
|
|
|
@@ -269,7 +271,33 @@ async function boundMcpResult(result: unknown, detailsMaxBytes: number): Promise
|
|
|
269
271
|
const raw = safeStringify(result);
|
|
270
272
|
const rawBytes = byteLength(raw);
|
|
271
273
|
if (rawBytes <= detailsMaxBytes) return result;
|
|
272
|
-
|
|
274
|
+
const marker = { omitted: true } as const;
|
|
275
|
+
if (byteLength(safeStringify(marker)) > detailsMaxBytes) return undefined;
|
|
276
|
+
|
|
277
|
+
const summary = await summarizeMcpResult(result, raw, rawBytes);
|
|
278
|
+
if (byteLength(safeStringify(summary)) <= detailsMaxBytes) return summary;
|
|
279
|
+
return compactMcpResultOmission(summary, marker, detailsMaxBytes);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
async function compactMcpResultOmission(
|
|
283
|
+
summary: McpResultSummary,
|
|
284
|
+
marker: Readonly<{ omitted: true }>,
|
|
285
|
+
maxBytes: number,
|
|
286
|
+
): Promise<unknown> {
|
|
287
|
+
if (summary.fullResultPath) {
|
|
288
|
+
const withPathAndSize = {
|
|
289
|
+
...marker,
|
|
290
|
+
rawResultBytes: summary.rawResultBytes,
|
|
291
|
+
fullResultPath: summary.fullResultPath,
|
|
292
|
+
};
|
|
293
|
+
if (byteLength(safeStringify(withPathAndSize)) <= maxBytes) return withPathAndSize;
|
|
294
|
+
const withPath = { ...marker, fullResultPath: summary.fullResultPath };
|
|
295
|
+
if (byteLength(safeStringify(withPath)) <= maxBytes) return withPath;
|
|
296
|
+
await discardArtifact(summary.fullResultPath);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const withSize = { ...marker, rawResultBytes: summary.rawResultBytes };
|
|
300
|
+
return byteLength(safeStringify(withSize)) <= maxBytes ? withSize : marker;
|
|
273
301
|
}
|
|
274
302
|
|
|
275
303
|
async function summarizeMcpResult(result: unknown, raw: string, rawBytes: number): Promise<McpResultSummary> {
|
|
@@ -289,7 +317,7 @@ async function summarizeMcpResult(result: unknown, raw: string, rawBytes: number
|
|
|
289
317
|
};
|
|
290
318
|
|
|
291
319
|
if (record && "structuredContent" in record) {
|
|
292
|
-
summary.structuredContent =
|
|
320
|
+
summary.structuredContent = summarizeStructuredContent(record.structuredContent);
|
|
293
321
|
}
|
|
294
322
|
if (record && "_meta" in record) {
|
|
295
323
|
summary.meta = summarizeValue(record._meta);
|
|
@@ -336,11 +364,41 @@ function summarizeValue(value: unknown): Record<string, unknown> {
|
|
|
336
364
|
type: Array.isArray(value) ? "array" : "object",
|
|
337
365
|
estimatedBytes: estimateValueBytes(value),
|
|
338
366
|
keyCount: keys.length,
|
|
339
|
-
keysPreview: keys.slice(0, KEY_PREVIEW_LIMIT)
|
|
367
|
+
keysPreview: uniqueBoundedKeys(keys.slice(0, KEY_PREVIEW_LIMIT)),
|
|
340
368
|
omitted: true,
|
|
341
369
|
};
|
|
342
370
|
}
|
|
343
371
|
|
|
372
|
+
function summarizeStructuredContent(value: unknown): Record<string, unknown> {
|
|
373
|
+
const record = asRecord(value);
|
|
374
|
+
if (!record || Array.isArray(value)) return summarizeValue(value);
|
|
375
|
+
const keys = Object.keys(record);
|
|
376
|
+
const entries = Object.entries(record).slice(0, KEY_PREVIEW_LIMIT);
|
|
377
|
+
const previewKeys = uniqueBoundedKeys(entries.map(([key]) => key));
|
|
378
|
+
const fields: Record<string, unknown> = {};
|
|
379
|
+
let preservedBytes = byteLength("{}");
|
|
380
|
+
for (const [key, field] of entries) {
|
|
381
|
+
const fieldBytes = byteLength(safeStringify(field));
|
|
382
|
+
const candidate = fieldBytes <= STRUCTURED_CONTENT_FIELD_PRESERVE_MAX_BYTES
|
|
383
|
+
? field
|
|
384
|
+
: summarizeValue(field);
|
|
385
|
+
const entryBytes = serializedObjectEntryBytes(key, candidate, Object.keys(fields).length > 0);
|
|
386
|
+
if (preservedBytes + entryBytes > STRUCTURED_CONTENT_PRESERVE_MAX_BYTES) continue;
|
|
387
|
+
fields[key] = candidate;
|
|
388
|
+
preservedBytes += entryBytes;
|
|
389
|
+
}
|
|
390
|
+
return {
|
|
391
|
+
preservedFields: fields,
|
|
392
|
+
summary: {
|
|
393
|
+
type: "object",
|
|
394
|
+
estimatedBytes: estimateValueBytes(value),
|
|
395
|
+
keyCount: keys.length,
|
|
396
|
+
keysPreview: previewKeys,
|
|
397
|
+
omitted: true,
|
|
398
|
+
},
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
|
|
344
402
|
function estimateValueBytes(value: unknown, depth = 0): number {
|
|
345
403
|
if (value === null || value === undefined) return 0;
|
|
346
404
|
if (typeof value === "string") return byteLength(value);
|
|
@@ -352,7 +410,29 @@ function estimateValueBytes(value: unknown, depth = 0): number {
|
|
|
352
410
|
}
|
|
353
411
|
|
|
354
412
|
function truncateKey(key: string): string {
|
|
355
|
-
|
|
413
|
+
if (byteLength(key) <= KEY_MAX_BYTES) return key;
|
|
414
|
+
const suffix = "…";
|
|
415
|
+
return `${truncateStringToBytes(key, KEY_MAX_BYTES - byteLength(suffix))}${suffix}`;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function uniqueBoundedKeys(keys: string[]): string[] {
|
|
419
|
+
const used = new Set<string>();
|
|
420
|
+
return keys.map((key) => {
|
|
421
|
+
let candidate = truncateKey(key);
|
|
422
|
+
let ordinal = 2;
|
|
423
|
+
while (used.has(candidate)) {
|
|
424
|
+
const suffix = `~${ordinal}`;
|
|
425
|
+
candidate = `${truncateStringToBytes(key, KEY_MAX_BYTES - byteLength(suffix))}${suffix}`;
|
|
426
|
+
ordinal += 1;
|
|
427
|
+
}
|
|
428
|
+
used.add(candidate);
|
|
429
|
+
return candidate;
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function serializedObjectEntryBytes(key: string, value: unknown, hasPrevious: boolean): number {
|
|
434
|
+
const serialized = safeStringify({ [key]: value });
|
|
435
|
+
return Math.max(0, byteLength(serialized) - byteLength("{}")) + (hasPrevious ? 1 : 0);
|
|
356
436
|
}
|
|
357
437
|
|
|
358
438
|
async function saveArtifact(kind: string, text: string): Promise<{ path?: string; error?: string }> {
|
|
@@ -366,6 +446,14 @@ async function saveArtifact(kind: string, text: string): Promise<{ path?: string
|
|
|
366
446
|
}
|
|
367
447
|
}
|
|
368
448
|
|
|
449
|
+
async function discardArtifact(path: string): Promise<void> {
|
|
450
|
+
try {
|
|
451
|
+
await rm(dirname(path), { recursive: true, force: true });
|
|
452
|
+
} catch {
|
|
453
|
+
// Cleanup cannot increase the returned details payload.
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
369
457
|
function asRecord(value: unknown): Recordish | undefined {
|
|
370
458
|
return typeof value === "object" && value !== null ? value as Recordish : undefined;
|
|
371
459
|
}
|
|
@@ -5,6 +5,7 @@ const JSON_ACCEPT = "application/json, text/event-stream";
|
|
|
5
5
|
const SSE_ACCEPT = "text/event-stream";
|
|
6
6
|
const MODERN_FALLBACK_STATUSES = new Set([400, 401, 404, 405, 406, 415]);
|
|
7
7
|
const POST_ENDPOINT_MISMATCH_STATUSES = new Set([404, 405, 406, 415]);
|
|
8
|
+
const AMBIGUOUS_STATUSES = new Set([202, 401, 503]);
|
|
8
9
|
|
|
9
10
|
export interface McpProbeResult {
|
|
10
11
|
isMcp: boolean;
|
|
@@ -163,25 +164,38 @@ async function probe(url: string | URL, strategy: ProbeStrategy): Promise<ProbeR
|
|
|
163
164
|
}
|
|
164
165
|
|
|
165
166
|
function notMcp(response: Response): McpProbeResult {
|
|
167
|
+
const responseDescription = `endpoint returned ${responseKind(response)} (${response.status})`;
|
|
166
168
|
return {
|
|
167
169
|
isMcp: false,
|
|
168
|
-
classification:
|
|
170
|
+
classification: response.status === 503
|
|
171
|
+
? `${responseDescription} — server is temporarily unavailable; MCP endpoint shape could not be determined`
|
|
172
|
+
: response.status === 202
|
|
173
|
+
? `${responseDescription} — MCP endpoint shape could not be determined`
|
|
174
|
+
: response.status === 401
|
|
175
|
+
? `${responseDescription} — authentication may be required; MCP endpoint shape could not be determined`
|
|
176
|
+
: `${responseDescription} — this URL does not appear to speak MCP`,
|
|
169
177
|
};
|
|
170
178
|
}
|
|
171
179
|
|
|
180
|
+
function ambiguousNotMcp(response: Response): McpProbeResult | undefined {
|
|
181
|
+
return AMBIGUOUS_STATUSES.has(response.status) ? notMcp(response) : undefined;
|
|
182
|
+
}
|
|
183
|
+
|
|
172
184
|
/** Makes one unauthenticated metadata-only request to identify an HTTP endpoint's protocol shape. */
|
|
173
185
|
export async function probeMcpEndpoint(url: string | URL): Promise<McpProbeResult> {
|
|
174
186
|
const { response: modernResponse, outcome: modernOutcome } = await probe(url, MODERN_STRATEGY);
|
|
175
187
|
if (modernOutcome.kind === "mcp") return modernOutcome.result;
|
|
188
|
+
let ambiguousResult = ambiguousNotMcp(modernResponse);
|
|
176
189
|
|
|
177
190
|
if (modernOutcome.kind !== "unsupported-modern" && !MODERN_FALLBACK_STATUSES.has(modernResponse.status)) {
|
|
178
|
-
return notMcp(modernResponse);
|
|
191
|
+
return ambiguousResult ?? notMcp(modernResponse);
|
|
179
192
|
}
|
|
180
193
|
|
|
181
194
|
const { response: postResponse, outcome: postOutcome } = await probe(url, LEGACY_POST_STRATEGY);
|
|
182
195
|
if (postOutcome.kind === "mcp") return postOutcome.result;
|
|
183
|
-
|
|
196
|
+
ambiguousResult ??= ambiguousNotMcp(postResponse);
|
|
197
|
+
if (!POST_ENDPOINT_MISMATCH_STATUSES.has(postResponse.status)) return ambiguousNotMcp(postResponse) ?? ambiguousResult ?? notMcp(postResponse);
|
|
184
198
|
|
|
185
199
|
const { response: getResponse, outcome: getOutcome } = await probe(url, LEGACY_SSE_STRATEGY);
|
|
186
|
-
return getOutcome.kind === "mcp" ? getOutcome.result : notMcp(getResponse);
|
|
200
|
+
return getOutcome.kind === "mcp" ? getOutcome.result : ambiguousNotMcp(getResponse) ?? ambiguousResult ?? notMcp(getResponse);
|
|
187
201
|
}
|