@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
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExtensionContext } from "../host.ts";
|
|
2
|
+
import type { SearchOptions, SearchResponse } from "./perplexity.ts";
|
|
3
|
+
export declare function isKimiSearchAvailable(ctx?: ExtensionContext): Promise<boolean>;
|
|
4
|
+
export declare function searchWithKimi(query: string, options?: SearchOptions, ctx?: ExtensionContext): Promise<SearchResponse>;
|
|
5
|
+
//# sourceMappingURL=kimi-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kimi-search.d.ts","sourceRoot":"","sources":["../../../../src/humain/web-access/vendor/kimi-search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAgB,MAAM,iBAAiB,CAAC;AAgKnF,wBAAsB,qBAAqB,CAAC,GAAG,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAMpF;AAED,wBAAsB,cAAc,CACnC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,aAAkB,EAC3B,GAAG,CAAC,EAAE,gBAAgB,GACpB,OAAO,CAAC,cAAc,CAAC,CAyDzB"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { activityMonitor } from "./activity.js";
|
|
3
|
+
import { redactCredential } from "./credential-source.js";
|
|
4
|
+
const KIMI_SEARCH_URL = "https://api.kimi.com/coding/v1/search";
|
|
5
|
+
const KIMI_PROVIDERS = ["kimi-coding", "kimi-code"];
|
|
6
|
+
const SEARCH_TIMEOUT_MS = 30_000;
|
|
7
|
+
function buildRequestHeaders(auth) {
|
|
8
|
+
const headers = new Headers();
|
|
9
|
+
for (const [name, value] of Object.entries(auth.headers)) {
|
|
10
|
+
if (value !== null)
|
|
11
|
+
headers.set(name, value);
|
|
12
|
+
}
|
|
13
|
+
headers.set("Authorization", `Bearer ${auth.apiKey}`);
|
|
14
|
+
headers.set("Content-Type", "application/json");
|
|
15
|
+
headers.set("X-Msh-Tool-Call-Id", randomUUID());
|
|
16
|
+
return headers;
|
|
17
|
+
}
|
|
18
|
+
function bearerToken(headers) {
|
|
19
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
20
|
+
if (name.toLowerCase() !== "authorization" || typeof value !== "string")
|
|
21
|
+
continue;
|
|
22
|
+
const match = /^Bearer\s+(.+)$/i.exec(value.trim());
|
|
23
|
+
if (match?.[1])
|
|
24
|
+
return match[1];
|
|
25
|
+
}
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
async function resolveKimiAuth(ctx) {
|
|
29
|
+
if (!ctx)
|
|
30
|
+
return undefined;
|
|
31
|
+
const models = ctx.modelRegistry.getAll();
|
|
32
|
+
let firstError;
|
|
33
|
+
for (const provider of KIMI_PROVIDERS) {
|
|
34
|
+
for (const model of models) {
|
|
35
|
+
if (model.provider !== provider)
|
|
36
|
+
continue;
|
|
37
|
+
let resolved;
|
|
38
|
+
try {
|
|
39
|
+
resolved = await ctx.modelRegistry.getApiKeyAndHeaders(model);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
firstError ??= err;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (!resolved.ok)
|
|
46
|
+
continue;
|
|
47
|
+
const headers = resolved.headers ?? {};
|
|
48
|
+
const apiKey = resolved.apiKey || bearerToken(headers);
|
|
49
|
+
if (apiKey)
|
|
50
|
+
return { apiKey, headers };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (firstError)
|
|
54
|
+
throw firstError;
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
function normalizeCount(value) {
|
|
58
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
59
|
+
return 5;
|
|
60
|
+
return Math.max(1, Math.min(Math.floor(value), 20));
|
|
61
|
+
}
|
|
62
|
+
function normalizeDomain(value) {
|
|
63
|
+
let input = value.trim().toLowerCase();
|
|
64
|
+
if (!input)
|
|
65
|
+
return null;
|
|
66
|
+
if (input.startsWith("-"))
|
|
67
|
+
input = input.slice(1).trim();
|
|
68
|
+
if (!input)
|
|
69
|
+
return null;
|
|
70
|
+
try {
|
|
71
|
+
const parsed = input.includes("://") ? new URL(input) : new URL(`https://${input}`);
|
|
72
|
+
input = parsed.hostname;
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
input = input.split("/")[0]?.split(":")[0] ?? "";
|
|
76
|
+
}
|
|
77
|
+
input = input.replace(/^\.+|\.+$/g, "");
|
|
78
|
+
return /^[a-z0-9][a-z0-9.-]*\.[a-z]{2,}$/i.test(input) ? input : null;
|
|
79
|
+
}
|
|
80
|
+
function normalizeDomainFilters(domainFilter) {
|
|
81
|
+
const filters = { allowed: [], blocked: [] };
|
|
82
|
+
if (!domainFilter?.length)
|
|
83
|
+
return filters;
|
|
84
|
+
for (const raw of domainFilter) {
|
|
85
|
+
const domain = normalizeDomain(raw);
|
|
86
|
+
if (!domain)
|
|
87
|
+
continue;
|
|
88
|
+
const target = raw.trim().startsWith("-") ? filters.blocked : filters.allowed;
|
|
89
|
+
if (!target.includes(domain))
|
|
90
|
+
target.push(domain);
|
|
91
|
+
}
|
|
92
|
+
return filters;
|
|
93
|
+
}
|
|
94
|
+
function hostMatchesDomain(hostname, domain) {
|
|
95
|
+
return hostname === domain || hostname.endsWith(`.${domain}`);
|
|
96
|
+
}
|
|
97
|
+
function matchesDomainFilters(url, filters) {
|
|
98
|
+
if (filters.allowed.length === 0 && filters.blocked.length === 0)
|
|
99
|
+
return true;
|
|
100
|
+
let hostname = "";
|
|
101
|
+
try {
|
|
102
|
+
hostname = new URL(url).hostname.toLowerCase();
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
if (filters.allowed.length > 0 && !filters.allowed.some((domain) => hostMatchesDomain(hostname, domain))) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
return !filters.blocked.some((domain) => hostMatchesDomain(hostname, domain));
|
|
111
|
+
}
|
|
112
|
+
function normalizeResultUrl(value) {
|
|
113
|
+
if (typeof value !== "string")
|
|
114
|
+
return null;
|
|
115
|
+
const input = value.trim();
|
|
116
|
+
if (!input)
|
|
117
|
+
return null;
|
|
118
|
+
try {
|
|
119
|
+
const url = new URL(input);
|
|
120
|
+
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
121
|
+
return null;
|
|
122
|
+
return url.href;
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function parseResults(value, options) {
|
|
129
|
+
if (!value || typeof value !== "object" || !Array.isArray(value.search_results)) {
|
|
130
|
+
throw new Error("Kimi Code search API returned an invalid response: search_results must be an array");
|
|
131
|
+
}
|
|
132
|
+
const filters = normalizeDomainFilters(options.domainFilter);
|
|
133
|
+
const numResults = normalizeCount(options.numResults);
|
|
134
|
+
const results = [];
|
|
135
|
+
for (const item of value.search_results) {
|
|
136
|
+
if (!item || typeof item !== "object")
|
|
137
|
+
continue;
|
|
138
|
+
const record = item;
|
|
139
|
+
const url = normalizeResultUrl(record.url);
|
|
140
|
+
if (!url || !matchesDomainFilters(url, filters))
|
|
141
|
+
continue;
|
|
142
|
+
results.push({
|
|
143
|
+
title: typeof record.title === "string" && record.title.trim() ? record.title : url,
|
|
144
|
+
url,
|
|
145
|
+
snippet: typeof record.snippet === "string" ? record.snippet : "",
|
|
146
|
+
});
|
|
147
|
+
if (results.length >= numResults)
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
return results;
|
|
151
|
+
}
|
|
152
|
+
function formatAnswer(results) {
|
|
153
|
+
return results
|
|
154
|
+
.map((result) => result.snippet
|
|
155
|
+
? `${result.snippet}\nSource: ${result.title} (${result.url})`
|
|
156
|
+
: `Source: ${result.title} (${result.url})`)
|
|
157
|
+
.join("\n\n");
|
|
158
|
+
}
|
|
159
|
+
export async function isKimiSearchAvailable(ctx) {
|
|
160
|
+
try {
|
|
161
|
+
return !!(await resolveKimiAuth(ctx));
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
export async function searchWithKimi(query, options = {}, ctx) {
|
|
168
|
+
const auth = await resolveKimiAuth(ctx);
|
|
169
|
+
if (!auth) {
|
|
170
|
+
throw new Error("Kimi Code web search unavailable. Run /login kimi-coding to authenticate a Kimi Code Plan account.");
|
|
171
|
+
}
|
|
172
|
+
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
173
|
+
const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS);
|
|
174
|
+
const requestSignal = options.signal
|
|
175
|
+
? AbortSignal.any([timeoutSignal, options.signal])
|
|
176
|
+
: timeoutSignal;
|
|
177
|
+
try {
|
|
178
|
+
const response = await fetch(KIMI_SEARCH_URL, {
|
|
179
|
+
method: "POST",
|
|
180
|
+
headers: buildRequestHeaders(auth),
|
|
181
|
+
body: JSON.stringify({ text_query: query }),
|
|
182
|
+
signal: requestSignal,
|
|
183
|
+
});
|
|
184
|
+
if (!response.ok) {
|
|
185
|
+
activityMonitor.logError(activityId, `HTTP ${response.status}`);
|
|
186
|
+
const errorText = redactCredential(await response.text(), auth.apiKey);
|
|
187
|
+
throw new Error(`Kimi Code search API error ${response.status}: ${errorText.slice(0, 300)}`);
|
|
188
|
+
}
|
|
189
|
+
let parsed;
|
|
190
|
+
try {
|
|
191
|
+
parsed = await response.json();
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
195
|
+
throw new Error(`Kimi Code search API returned invalid JSON: ${message}`);
|
|
196
|
+
}
|
|
197
|
+
const results = parseResults(parsed, options);
|
|
198
|
+
if (results.length === 0) {
|
|
199
|
+
throw new Error("Kimi Code search API returned no results");
|
|
200
|
+
}
|
|
201
|
+
activityMonitor.logComplete(activityId, response.status);
|
|
202
|
+
return { answer: formatAnswer(results), results };
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
206
|
+
const redactedMessage = redactCredential(message, auth.apiKey);
|
|
207
|
+
if (options.signal?.aborted) {
|
|
208
|
+
activityMonitor.logComplete(activityId, 0);
|
|
209
|
+
}
|
|
210
|
+
else if (timeoutSignal.aborted || (err instanceof Error && err.name === "TimeoutError")) {
|
|
211
|
+
activityMonitor.logError(activityId, "Kimi Code search API timed out");
|
|
212
|
+
throw new Error("Kimi Code search API timed out");
|
|
213
|
+
}
|
|
214
|
+
else if (redactedMessage.toLowerCase().includes("abort")) {
|
|
215
|
+
activityMonitor.logComplete(activityId, 0);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
activityMonitor.logError(activityId, redactedMessage);
|
|
219
|
+
}
|
|
220
|
+
if (redactedMessage === message)
|
|
221
|
+
throw err;
|
|
222
|
+
const redactedError = new Error(redactedMessage);
|
|
223
|
+
if (err instanceof Error)
|
|
224
|
+
redactedError.name = err.name;
|
|
225
|
+
throw redactedError;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
//# sourceMappingURL=kimi-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kimi-search.js","sourceRoot":"","sources":["../../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,CAAC,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACP,eAAe,CAAC,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;QACvD,CAAC;QACD,IAAI,eAAe,KAAK,OAAO;YAAE,MAAM,GAAG,CAAC;QAC3C,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;QACjD,IAAI,GAAG,YAAY,KAAK;YAAE,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACxD,MAAM,aAAa,CAAC;IACrB,CAAC;AACF,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { ExtensionContext } from \"../host.ts\";\nimport { activityMonitor } from \"./activity.ts\";\nimport { redactCredential } from \"./credential-source.ts\";\nimport type { SearchOptions, SearchResponse, SearchResult } from \"./perplexity.ts\";\n\nconst KIMI_SEARCH_URL = \"https://api.kimi.com/coding/v1/search\";\nconst KIMI_PROVIDERS = [\"kimi-coding\", \"kimi-code\"] as const;\nconst SEARCH_TIMEOUT_MS = 30_000;\n\ntype ProviderHeaders = Record<string, string | null>;\n\ninterface KimiAuth {\n\tapiKey: string;\n\theaders: ProviderHeaders;\n}\n\ninterface NormalizedDomainFilters {\n\tallowed: string[];\n\tblocked: string[];\n}\n\nfunction buildRequestHeaders(auth: KimiAuth): Headers {\n\tconst headers = new Headers();\n\tfor (const [name, value] of Object.entries(auth.headers)) {\n\t\tif (value !== null) headers.set(name, value);\n\t}\n\theaders.set(\"Authorization\", `Bearer ${auth.apiKey}`);\n\theaders.set(\"Content-Type\", \"application/json\");\n\theaders.set(\"X-Msh-Tool-Call-Id\", randomUUID());\n\treturn headers;\n}\n\nfunction bearerToken(headers: ProviderHeaders): string | undefined {\n\tfor (const [name, value] of Object.entries(headers)) {\n\t\tif (name.toLowerCase() !== \"authorization\" || typeof value !== \"string\") continue;\n\t\tconst match = /^Bearer\\s+(.+)$/i.exec(value.trim());\n\t\tif (match?.[1]) return match[1];\n\t}\n\treturn undefined;\n}\n\nasync function resolveKimiAuth(ctx?: ExtensionContext): Promise<KimiAuth | undefined> {\n\tif (!ctx) return undefined;\n\n\tconst models = ctx.modelRegistry.getAll();\n\tlet firstError: unknown;\n\n\tfor (const provider of KIMI_PROVIDERS) {\n\t\tfor (const model of models) {\n\t\t\tif (model.provider !== provider) continue;\n\t\t\tlet resolved: Awaited<ReturnType<typeof ctx.modelRegistry.getApiKeyAndHeaders>>;\n\t\t\ttry {\n\t\t\t\tresolved = await ctx.modelRegistry.getApiKeyAndHeaders(model);\n\t\t\t} catch (err) {\n\t\t\t\tfirstError ??= err;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!resolved.ok) continue;\n\t\t\tconst headers = resolved.headers ?? {};\n\t\t\tconst apiKey = resolved.apiKey || bearerToken(headers);\n\t\t\tif (apiKey) return { apiKey, headers };\n\t\t}\n\t}\n\tif (firstError) throw firstError;\n\treturn undefined;\n}\n\nfunction normalizeCount(value: number | undefined): number {\n\tif (typeof value !== \"number\" || !Number.isFinite(value)) return 5;\n\treturn Math.max(1, Math.min(Math.floor(value), 20));\n}\n\nfunction normalizeDomain(value: string): string | null {\n\tlet input = value.trim().toLowerCase();\n\tif (!input) return null;\n\tif (input.startsWith(\"-\")) input = input.slice(1).trim();\n\tif (!input) return null;\n\ttry {\n\t\tconst parsed = input.includes(\"://\") ? new URL(input) : new URL(`https://${input}`);\n\t\tinput = parsed.hostname;\n\t} catch {\n\t\tinput = input.split(\"/\")[0]?.split(\":\")[0] ?? \"\";\n\t}\n\tinput = input.replace(/^\\.+|\\.+$/g, \"\");\n\treturn /^[a-z0-9][a-z0-9.-]*\\.[a-z]{2,}$/i.test(input) ? input : null;\n}\n\nfunction normalizeDomainFilters(domainFilter: string[] | undefined): NormalizedDomainFilters {\n\tconst filters: NormalizedDomainFilters = { allowed: [], blocked: [] };\n\tif (!domainFilter?.length) return filters;\n\n\tfor (const raw of domainFilter) {\n\t\tconst domain = normalizeDomain(raw);\n\t\tif (!domain) continue;\n\t\tconst target = raw.trim().startsWith(\"-\") ? filters.blocked : filters.allowed;\n\t\tif (!target.includes(domain)) target.push(domain);\n\t}\n\treturn filters;\n}\n\nfunction hostMatchesDomain(hostname: string, domain: string): boolean {\n\treturn hostname === domain || hostname.endsWith(`.${domain}`);\n}\n\nfunction matchesDomainFilters(url: string, filters: NormalizedDomainFilters): boolean {\n\tif (filters.allowed.length === 0 && filters.blocked.length === 0) return true;\n\n\tlet hostname = \"\";\n\ttry {\n\t\thostname = new URL(url).hostname.toLowerCase();\n\t} catch {\n\t\treturn false;\n\t}\n\tif (filters.allowed.length > 0 && !filters.allowed.some((domain) => hostMatchesDomain(hostname, domain))) {\n\t\treturn false;\n\t}\n\treturn !filters.blocked.some((domain) => hostMatchesDomain(hostname, domain));\n}\n\nfunction normalizeResultUrl(value: unknown): string | null {\n\tif (typeof value !== \"string\") return null;\n\tconst input = value.trim();\n\tif (!input) return null;\n\ttry {\n\t\tconst url = new URL(input);\n\t\tif (url.protocol !== \"http:\" && url.protocol !== \"https:\") return null;\n\t\treturn url.href;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction parseResults(value: unknown, options: SearchOptions): SearchResult[] {\n\tif (!value || typeof value !== \"object\" || !Array.isArray((value as { search_results?: unknown }).search_results)) {\n\t\tthrow new Error(\"Kimi Code search API returned an invalid response: search_results must be an array\");\n\t}\n\n\tconst filters = normalizeDomainFilters(options.domainFilter);\n\tconst numResults = normalizeCount(options.numResults);\n\tconst results: SearchResult[] = [];\n\tfor (const item of (value as { search_results: unknown[] }).search_results) {\n\t\tif (!item || typeof item !== \"object\") continue;\n\t\tconst record = item as Record<string, unknown>;\n\t\tconst url = normalizeResultUrl(record.url);\n\t\tif (!url || !matchesDomainFilters(url, filters)) continue;\n\t\tresults.push({\n\t\t\ttitle: typeof record.title === \"string\" && record.title.trim() ? record.title : url,\n\t\t\turl,\n\t\t\tsnippet: typeof record.snippet === \"string\" ? record.snippet : \"\",\n\t\t});\n\t\tif (results.length >= numResults) break;\n\t}\n\treturn results;\n}\n\nfunction formatAnswer(results: SearchResult[]): string {\n\treturn results\n\t\t.map((result) => result.snippet\n\t\t\t? `${result.snippet}\\nSource: ${result.title} (${result.url})`\n\t\t\t: `Source: ${result.title} (${result.url})`)\n\t\t.join(\"\\n\\n\");\n}\n\nexport async function isKimiSearchAvailable(ctx?: ExtensionContext): Promise<boolean> {\n\ttry {\n\t\treturn !!(await resolveKimiAuth(ctx));\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport async function searchWithKimi(\n\tquery: string,\n\toptions: SearchOptions = {},\n\tctx?: ExtensionContext,\n): Promise<SearchResponse> {\n\tconst auth = await resolveKimiAuth(ctx);\n\tif (!auth) {\n\t\tthrow new Error(\"Kimi Code web search unavailable. Run /login kimi-coding to authenticate a Kimi Code Plan account.\");\n\t}\n\n\tconst activityId = activityMonitor.logStart({ type: \"api\", query });\n\tconst timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS);\n\tconst requestSignal = options.signal\n\t\t? AbortSignal.any([timeoutSignal, options.signal])\n\t\t: timeoutSignal;\n\ttry {\n\t\tconst response = await fetch(KIMI_SEARCH_URL, {\n\t\t\tmethod: \"POST\",\n\t\t\theaders: buildRequestHeaders(auth),\n\t\t\tbody: JSON.stringify({ text_query: query }),\n\t\t\tsignal: requestSignal,\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tactivityMonitor.logError(activityId, `HTTP ${response.status}`);\n\t\t\tconst errorText = redactCredential(await response.text(), auth.apiKey);\n\t\t\tthrow new Error(`Kimi Code search API error ${response.status}: ${errorText.slice(0, 300)}`);\n\t\t}\n\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = await response.json();\n\t\t} catch (err) {\n\t\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\t\tthrow new Error(`Kimi Code search API returned invalid JSON: ${message}`);\n\t\t}\n\t\tconst results = parseResults(parsed, options);\n\t\tif (results.length === 0) {\n\t\t\tthrow new Error(\"Kimi Code search API returned no results\");\n\t\t}\n\n\t\tactivityMonitor.logComplete(activityId, response.status);\n\t\treturn { answer: formatAnswer(results), results };\n\t} catch (err) {\n\t\tconst message = err instanceof Error ? err.message : String(err);\n\t\tconst redactedMessage = redactCredential(message, auth.apiKey);\n\t\tif (options.signal?.aborted) {\n\t\t\tactivityMonitor.logComplete(activityId, 0);\n\t\t} else if (timeoutSignal.aborted || (err instanceof Error && err.name === \"TimeoutError\")) {\n\t\t\tactivityMonitor.logError(activityId, \"Kimi Code search API timed out\");\n\t\t\tthrow new Error(\"Kimi Code search API timed out\");\n\t\t} else if (redactedMessage.toLowerCase().includes(\"abort\")) {\n\t\t\tactivityMonitor.logComplete(activityId, 0);\n\t\t} else {\n\t\t\tactivityMonitor.logError(activityId, redactedMessage);\n\t\t}\n\t\tif (redactedMessage === message) throw err;\n\t\tconst redactedError = new Error(redactedMessage);\n\t\tif (err instanceof Error) redactedError.name = err.name;\n\t\tthrow redactedError;\n\t}\n}\n"]}
|
|
@@ -7,9 +7,12 @@ interface OpenAIAuth {
|
|
|
7
7
|
model: string;
|
|
8
8
|
headers: ProviderHeaders;
|
|
9
9
|
responsesUrl: string;
|
|
10
|
+
useCodexEndpoint?: boolean;
|
|
10
11
|
}
|
|
12
|
+
export declare function isCurrentModelHostedSearchEligible(ctx?: Pick<ExtensionContext, "model">): boolean;
|
|
11
13
|
export declare function resolveOpenAIAuth(ctx?: ExtensionContext, signal?: AbortSignal): Promise<OpenAIAuth | undefined>;
|
|
12
14
|
export declare function isOpenAISearchAvailable(ctx?: ExtensionContext): Promise<boolean>;
|
|
13
15
|
export declare function searchWithOpenAI(query: string, options?: SearchOptions, ctx?: ExtensionContext): Promise<SearchResponse>;
|
|
16
|
+
export declare function searchWithCurrentModelOpenAI(query: string, options?: SearchOptions, ctx?: ExtensionContext): Promise<SearchResponse>;
|
|
14
17
|
export {};
|
|
15
18
|
//# sourceMappingURL=openai-search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-search.d.ts","sourceRoot":"","sources":["../../../../src/humain/web-access/vendor/openai-search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAgB,MAAM,iBAAiB,CAAC;AAsCnF,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;AAErD,UAAU,UAAU;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,eAAe,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"openai-search.d.ts","sourceRoot":"","sources":["../../../../src/humain/web-access/vendor/openai-search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAgB,MAAM,iBAAiB,CAAC;AAsCnF,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;AAErD,UAAU,UAAU;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,eAAe,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC3B;AA+BD,wBAAgB,kCAAkC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,GAAG,OAAO,CASjG;AA0JD,wBAAsB,iBAAiB,CAAC,GAAG,CAAC,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAyBrH;AAED,wBAAsB,uBAAuB,CAAC,GAAG,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAUtF;AA6RD,wBAAsB,gBAAgB,CACrC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,aAAkB,EAC3B,GAAG,CAAC,EAAE,gBAAgB,GACpB,OAAO,CAAC,cAAc,CAAC,CAWzB;AAED,wBAAsB,4BAA4B,CACjD,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,aAAkB,EAC3B,GAAG,CAAC,EAAE,gBAAgB,GACpB,OAAO,CAAC,cAAc,CAAC,CAIzB"}
|
|
@@ -27,6 +27,35 @@ function pickSearchModel(models) {
|
|
|
27
27
|
}
|
|
28
28
|
return candidates[0];
|
|
29
29
|
}
|
|
30
|
+
function resolveCurrentModelSearchTarget(model) {
|
|
31
|
+
const url = new URL(model.baseUrl);
|
|
32
|
+
if (url.protocol !== "https:")
|
|
33
|
+
throw new Error("Current model base URL must use HTTPS");
|
|
34
|
+
if (model.provider === "openai" && model.api === "openai-responses" && url.hostname.toLowerCase() === "api.openai.com") {
|
|
35
|
+
const pathname = url.pathname.replace(/\/+$/u, "");
|
|
36
|
+
url.pathname = `${pathname}/responses`;
|
|
37
|
+
return { responsesUrl: url.toString(), useCodexEndpoint: false };
|
|
38
|
+
}
|
|
39
|
+
if (model.provider === "openai-codex" &&
|
|
40
|
+
model.api === "openai-codex-responses" &&
|
|
41
|
+
url.hostname.toLowerCase() === "chatgpt.com" &&
|
|
42
|
+
url.pathname.replace(/\/+$/u, "") === "/backend-api") {
|
|
43
|
+
return { responsesUrl: CODEX_RESPONSES_URL, useCodexEndpoint: true };
|
|
44
|
+
}
|
|
45
|
+
throw new Error("Current model is not backed by an official OpenAI Responses endpoint");
|
|
46
|
+
}
|
|
47
|
+
export function isCurrentModelHostedSearchEligible(ctx) {
|
|
48
|
+
const model = ctx?.model;
|
|
49
|
+
if (!model || !/^gpt-/iu.test(model.id))
|
|
50
|
+
return false;
|
|
51
|
+
try {
|
|
52
|
+
resolveCurrentModelSearchTarget(model);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
30
59
|
let cachedConfig = null;
|
|
31
60
|
function loadConfig() {
|
|
32
61
|
if (cachedConfig)
|
|
@@ -218,6 +247,28 @@ export async function isOpenAISearchAvailable(ctx) {
|
|
|
218
247
|
environmentValue: process.env.OPENAI_API_KEY,
|
|
219
248
|
});
|
|
220
249
|
}
|
|
250
|
+
async function resolveCurrentModelAuth(ctx, signal) {
|
|
251
|
+
const model = ctx.model;
|
|
252
|
+
if (!model || !isCurrentModelHostedSearchEligible(ctx)) {
|
|
253
|
+
throw new Error("Current model is not eligible for official OpenAI Hosted web search");
|
|
254
|
+
}
|
|
255
|
+
const target = resolveCurrentModelSearchTarget(model);
|
|
256
|
+
const resolved = await ctx.modelRegistry.getApiKeyAndHeaders(model);
|
|
257
|
+
if (signal?.aborted)
|
|
258
|
+
signal.throwIfAborted();
|
|
259
|
+
if (!resolved.ok)
|
|
260
|
+
throw new Error(`OpenAI current model authentication failed: ${resolved.error}`);
|
|
261
|
+
if (!resolved.apiKey)
|
|
262
|
+
throw new Error("OpenAI current model authentication failed: API key unavailable");
|
|
263
|
+
return {
|
|
264
|
+
provider: "openai",
|
|
265
|
+
apiKey: resolved.apiKey,
|
|
266
|
+
model: model.id,
|
|
267
|
+
headers: resolved.headers ?? {},
|
|
268
|
+
responsesUrl: target.responsesUrl,
|
|
269
|
+
useCodexEndpoint: target.useCodexEndpoint,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
221
272
|
function buildInstructions(options) {
|
|
222
273
|
const lines = [
|
|
223
274
|
"Search the web and return a concise answer grounded only in the web results.",
|
|
@@ -253,15 +304,20 @@ function buildWebSearchTool(options) {
|
|
|
253
304
|
}
|
|
254
305
|
return tool;
|
|
255
306
|
}
|
|
307
|
+
function isWebSearchCall(item) {
|
|
308
|
+
return !!item && typeof item === "object" && item.type === "web_search_call";
|
|
309
|
+
}
|
|
256
310
|
async function parseOpenAIResponse(response) {
|
|
257
311
|
const text = await response.text();
|
|
258
312
|
const trimmed = text.trim();
|
|
259
313
|
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
260
314
|
try {
|
|
261
315
|
const parsed = JSON.parse(trimmed);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
316
|
+
const payload = Array.isArray(parsed)
|
|
317
|
+
? { output: parsed }
|
|
318
|
+
: parsed && typeof parsed === "object" ? parsed : { output: [] };
|
|
319
|
+
const output = Array.isArray(payload.output) ? payload.output : [];
|
|
320
|
+
return { payload, webSearchCallSeen: output.some(isWebSearchCall) };
|
|
265
321
|
}
|
|
266
322
|
catch (err) {
|
|
267
323
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -270,6 +326,7 @@ async function parseOpenAIResponse(response) {
|
|
|
270
326
|
}
|
|
271
327
|
const outputItems = [];
|
|
272
328
|
let completedResponse = null;
|
|
329
|
+
let webSearchCallSeen = false;
|
|
273
330
|
for (const line of text.split("\n")) {
|
|
274
331
|
if (!line.startsWith("data: "))
|
|
275
332
|
continue;
|
|
@@ -278,8 +335,12 @@ async function parseOpenAIResponse(response) {
|
|
|
278
335
|
continue;
|
|
279
336
|
try {
|
|
280
337
|
const parsed = JSON.parse(data);
|
|
281
|
-
if (parsed.type === "
|
|
338
|
+
if (typeof parsed.type === "string" && parsed.type.startsWith("response.web_search_call"))
|
|
339
|
+
webSearchCallSeen = true;
|
|
340
|
+
if (parsed.type === "response.output_item.done" && parsed.item) {
|
|
282
341
|
outputItems.push(parsed.item);
|
|
342
|
+
webSearchCallSeen ||= isWebSearchCall(parsed.item);
|
|
343
|
+
}
|
|
283
344
|
if ((parsed.type === "response.done" || parsed.type === "response.completed") && parsed.response && typeof parsed.response === "object") {
|
|
284
345
|
completedResponse = parsed.response;
|
|
285
346
|
}
|
|
@@ -289,10 +350,11 @@ async function parseOpenAIResponse(response) {
|
|
|
289
350
|
}
|
|
290
351
|
if (completedResponse) {
|
|
291
352
|
const output = Array.isArray(completedResponse.output) ? completedResponse.output : [];
|
|
292
|
-
|
|
353
|
+
const payload = output.length > 0 ? completedResponse : { ...completedResponse, output: outputItems };
|
|
354
|
+
return { payload, webSearchCallSeen: webSearchCallSeen || output.some(isWebSearchCall) };
|
|
293
355
|
}
|
|
294
356
|
if (outputItems.length > 0)
|
|
295
|
-
return { output: outputItems };
|
|
357
|
+
return { payload: { output: outputItems }, webSearchCallSeen: webSearchCallSeen || outputItems.some(isWebSearchCall) };
|
|
296
358
|
throw new Error("OpenAI API returned no parseable response output");
|
|
297
359
|
}
|
|
298
360
|
function cleanSourceUrl(rawUrl) {
|
|
@@ -392,14 +454,7 @@ function extractAnswer(output) {
|
|
|
392
454
|
}
|
|
393
455
|
return parts.join("\n").trim();
|
|
394
456
|
}
|
|
395
|
-
|
|
396
|
-
const auth = await resolveOpenAIAuth(ctx, options.signal);
|
|
397
|
-
if (!auth) {
|
|
398
|
-
throw new Error("OpenAI web search unavailable. Either:\n" +
|
|
399
|
-
" 1. Use /login to sign in with a Codex subscription\n" +
|
|
400
|
-
` 2. Create ${CONFIG_PATH} with { "openaiApiKey": "your-key" }\n` +
|
|
401
|
-
" 3. Set OPENAI_API_KEY environment variable");
|
|
402
|
-
}
|
|
457
|
+
async function runOpenAISearch(query, options, auth) {
|
|
403
458
|
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
404
459
|
const headers = {
|
|
405
460
|
...toRequestHeaders(auth.headers),
|
|
@@ -407,7 +462,7 @@ export async function searchWithOpenAI(query, options = {}, ctx) {
|
|
|
407
462
|
"Content-Type": "application/json",
|
|
408
463
|
"OpenAI-Beta": "responses=experimental",
|
|
409
464
|
};
|
|
410
|
-
const useCodexEndpoint = auth.provider === "openai-codex" || isCodexJwt(auth.apiKey);
|
|
465
|
+
const useCodexEndpoint = auth.useCodexEndpoint ?? (auth.provider === "openai-codex" || isCodexJwt(auth.apiKey));
|
|
411
466
|
if (useCodexEndpoint) {
|
|
412
467
|
const accountId = extractAccountId(auth.apiKey);
|
|
413
468
|
if (accountId)
|
|
@@ -440,7 +495,9 @@ export async function searchWithOpenAI(query, options = {}, ctx) {
|
|
|
440
495
|
throw new Error(`OpenAI API error ${response.status}: ${errorText.slice(0, 300)}`);
|
|
441
496
|
}
|
|
442
497
|
const parsed = await parseOpenAIResponse(response);
|
|
443
|
-
const output = Array.isArray(parsed.output) ? parsed.output : [];
|
|
498
|
+
const output = Array.isArray(parsed.payload.output) ? parsed.payload.output : [];
|
|
499
|
+
if (!parsed.webSearchCallSeen)
|
|
500
|
+
throw new Error("OpenAI web_search returned no web_search_call");
|
|
444
501
|
const answer = extractAnswer(output);
|
|
445
502
|
const results = extractSearchResults(output, options.numResults);
|
|
446
503
|
if (!answer && results.length === 0) {
|
|
@@ -466,4 +523,20 @@ export async function searchWithOpenAI(query, options = {}, ctx) {
|
|
|
466
523
|
throw redactedError;
|
|
467
524
|
}
|
|
468
525
|
}
|
|
526
|
+
export async function searchWithOpenAI(query, options = {}, ctx) {
|
|
527
|
+
const auth = await resolveOpenAIAuth(ctx, options.signal);
|
|
528
|
+
if (!auth) {
|
|
529
|
+
throw new Error("OpenAI web search unavailable. Either:\n" +
|
|
530
|
+
" 1. Use /login to sign in with a Codex subscription\n" +
|
|
531
|
+
` 2. Create ${CONFIG_PATH} with { "openaiApiKey": "your-key" }\n` +
|
|
532
|
+
" 3. Set OPENAI_API_KEY environment variable");
|
|
533
|
+
}
|
|
534
|
+
return runOpenAISearch(query, options, auth);
|
|
535
|
+
}
|
|
536
|
+
export async function searchWithCurrentModelOpenAI(query, options = {}, ctx) {
|
|
537
|
+
if (!ctx)
|
|
538
|
+
throw new Error("OpenAI current-model search requires an extension context");
|
|
539
|
+
const auth = await resolveCurrentModelAuth(ctx, options.signal);
|
|
540
|
+
return runOpenAISearch(query, options, auth);
|
|
541
|
+
}
|
|
469
542
|
//# sourceMappingURL=openai-search.js.map
|