@ashx-j/lunr-dev 0.2.13-dev.8.1 → 0.2.19-dev.10.1
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 +60 -1
- package/README.md +7 -1
- package/dist/builtin-extensions/ashxj-thinking.d.ts +1 -0
- package/dist/builtin-extensions/ashxj-thinking.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-thinking.js +44 -19
- package/dist/builtin-extensions/ashxj-thinking.js.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.d.ts +14 -0
- package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.js +37 -3
- package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
- package/dist/builtin-extensions/index.d.ts +1 -15
- package/dist/builtin-extensions/index.d.ts.map +1 -1
- package/dist/builtin-extensions/index.js +8 -21
- package/dist/builtin-extensions/index.js.map +1 -1
- package/dist/builtin-extensions/lunr-computer-use.d.ts +3 -0
- package/dist/builtin-extensions/lunr-computer-use.d.ts.map +1 -0
- package/dist/builtin-extensions/lunr-computer-use.js +157 -0
- package/dist/builtin-extensions/lunr-computer-use.js.map +1 -0
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.d.ts.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js +6 -2
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts +4 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js +172 -171
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.d.ts +50 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.js +131 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.d.ts +7 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js +211 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js.map +1 -0
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts +0 -5
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js +0 -202
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tools.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.js +276 -109
- package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts +4 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.js +10 -3
- package/dist/builtin-extensions/pi-mcp-adapter/init.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.js +6 -1
- package/dist/builtin-extensions/pi-mcp-adapter/metadata-cache.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts +6 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js +33 -8
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js +2 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js +68 -15
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +6 -2
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +5 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.d.ts +10 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.js +38 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +3 -16
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +2 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +72 -31
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js +2 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/extract.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/extract.js +105 -54
- package/dist/builtin-extensions/pi-web-access/extract.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts +1 -1
- package/dist/builtin-extensions/pi-web-access/gemini-search.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/gemini-search.js +82 -65
- package/dist/builtin-extensions/pi-web-access/gemini-search.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/github-extract.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/github-extract.js +2 -0
- package/dist/builtin-extensions/pi-web-access/github-extract.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.js +259 -168
- package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/lazy.d.ts +18 -0
- package/dist/builtin-extensions/pi-web-access/lazy.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/lazy.js +19 -0
- package/dist/builtin-extensions/pi-web-access/lazy.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts +6 -0
- package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/session-cleanup.js +17 -0
- package/dist/builtin-extensions/pi-web-access/session-cleanup.js.map +1 -0
- package/dist/catalog/publication.json +12 -12
- package/dist/cli-runtime.d.ts +3 -0
- package/dist/cli-runtime.d.ts.map +1 -0
- package/dist/cli-runtime.js +73 -0
- package/dist/cli-runtime.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +14 -53
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +3 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +56 -12
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +10 -5
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/computer-use/adapter.d.ts +23 -0
- package/dist/core/computer-use/adapter.d.ts.map +1 -0
- package/dist/core/computer-use/adapter.js +116 -0
- package/dist/core/computer-use/adapter.js.map +1 -0
- package/dist/core/computer-use/lease.d.ts +18 -0
- package/dist/core/computer-use/lease.d.ts.map +1 -0
- package/dist/core/computer-use/lease.js +129 -0
- package/dist/core/computer-use/lease.js.map +1 -0
- package/dist/core/computer-use/macos-runtime.d.ts +14 -0
- package/dist/core/computer-use/macos-runtime.d.ts.map +1 -0
- package/dist/core/computer-use/macos-runtime.js +148 -0
- package/dist/core/computer-use/macos-runtime.js.map +1 -0
- package/dist/core/computer-use/policy.d.ts +19 -0
- package/dist/core/computer-use/policy.d.ts.map +1 -0
- package/dist/core/computer-use/policy.js +66 -0
- package/dist/core/computer-use/policy.js.map +1 -0
- package/dist/core/computer-use/release.generated.d.ts +31 -0
- package/dist/core/computer-use/release.generated.d.ts.map +1 -0
- package/dist/core/computer-use/release.generated.js +36 -0
- package/dist/core/computer-use/release.generated.js.map +1 -0
- package/dist/core/computer-use/runtime.d.ts +13 -0
- package/dist/core/computer-use/runtime.d.ts.map +1 -0
- package/dist/core/computer-use/runtime.js +158 -0
- package/dist/core/computer-use/runtime.js.map +1 -0
- package/dist/core/computer-use/schemas.d.ts +88 -0
- package/dist/core/computer-use/schemas.d.ts.map +1 -0
- package/dist/core/computer-use/schemas.js +80 -0
- package/dist/core/computer-use/schemas.js.map +1 -0
- package/dist/core/computer-use/windows-desktop.d.ts +3 -0
- package/dist/core/computer-use/windows-desktop.d.ts.map +1 -0
- package/dist/core/computer-use/windows-desktop.js +48 -0
- package/dist/core/computer-use/windows-desktop.js.map +1 -0
- package/dist/core/computer-use/workflow.d.ts +24 -0
- package/dist/core/computer-use/workflow.d.ts.map +1 -0
- package/dist/core/computer-use/workflow.js +330 -0
- package/dist/core/computer-use/workflow.js.map +1 -0
- package/dist/core/extensions/host-static.d.ts.map +1 -1
- package/dist/core/extensions/host-static.js +34 -12
- package/dist/core/extensions/host-static.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +1 -2
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +10 -64
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +2 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +2 -0
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/keybindings.d.ts +2 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +2 -2
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-runtime.d.ts +0 -3
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +1 -10
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +1 -1
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/permissions.d.ts +1 -3
- package/dist/core/permissions.d.ts.map +1 -1
- package/dist/core/permissions.js +33 -25
- package/dist/core/permissions.js.map +1 -1
- package/dist/core/plan-mode.d.ts.map +1 -1
- package/dist/core/plan-mode.js +9 -0
- package/dist/core/plan-mode.js.map +1 -1
- package/dist/core/rollback.d.ts.map +1 -1
- package/dist/core/rollback.js +13 -90
- package/dist/core/rollback.js.map +1 -1
- package/dist/core/sdk.d.ts +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +0 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +21 -79
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +6 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +19 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +0 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/timings.d.ts +2 -1
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +17 -2
- package/dist/core/timings.js.map +1 -1
- package/dist/dev-cli.js +0 -0
- package/dist/gateway/agent-bridge.d.ts +6 -1
- package/dist/gateway/agent-bridge.d.ts.map +1 -1
- package/dist/gateway/agent-bridge.js +23 -6
- package/dist/gateway/agent-bridge.js.map +1 -1
- package/dist/gateway/commands.d.ts +1 -1
- package/dist/gateway/commands.d.ts.map +1 -1
- package/dist/gateway/commands.js +1 -18
- package/dist/gateway/commands.js.map +1 -1
- package/dist/gateway/cron.d.ts +1 -1
- package/dist/gateway/cron.d.ts.map +1 -1
- package/dist/gateway/cron.js +23 -7
- package/dist/gateway/cron.js.map +1 -1
- package/dist/main.d.ts +2 -2
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +57 -48
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +4 -2
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +23 -32
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/processes-selector.d.ts +2 -3
- package/dist/modes/interactive/components/processes-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/processes-selector.js +5 -10
- package/dist/modes/interactive/components/processes-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +20 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +12 -21
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +138 -152
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +95 -84
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/thinking-level-slash.d.ts +4 -0
- package/dist/modes/interactive/thinking-level-slash.d.ts.map +1 -0
- package/dist/modes/interactive/thinking-level-slash.js +23 -0
- package/dist/modes/interactive/thinking-level-slash.js.map +1 -0
- package/dist/node-runtime/adapter-AZMY335J.js +279 -0
- package/dist/node-runtime/agent-session-services-RSGP5GDN.js +39 -0
- package/dist/node-runtime/benchmark-request-UC7PD3V3.js +57 -0
- package/dist/node-runtime/brave-UWDA3I22.js +143 -0
- package/dist/node-runtime/builtin-extensions-7STLFW3A.js +29 -0
- package/dist/node-runtime/chunk-2IDTZAG5.js +1415 -0
- package/dist/node-runtime/chunk-3GHXVUAK.js +21 -0
- package/dist/node-runtime/chunk-3RCWXWAY.js +466 -0
- package/dist/node-runtime/chunk-3WFAEVKS.js +115 -0
- package/dist/node-runtime/chunk-3X3KZKMI.js +49 -0
- package/dist/node-runtime/chunk-4HXHDDCF.js +16 -0
- package/dist/node-runtime/chunk-4SJWFTUP.js +24 -0
- package/dist/node-runtime/chunk-4ZWGEEAS.js +69 -0
- package/dist/node-runtime/chunk-53YJI7JU.js +137 -0
- package/dist/node-runtime/chunk-5NWQCSKR.js +19218 -0
- package/dist/node-runtime/chunk-5OLJGVCB.js +68 -0
- package/dist/node-runtime/chunk-5Q45AVQG.js +108 -0
- package/dist/node-runtime/chunk-5SQDLSZJ.js +949 -0
- package/dist/node-runtime/chunk-6SPPH4FY.js +1269 -0
- package/dist/node-runtime/chunk-6UB6NKA3.js +860 -0
- package/dist/node-runtime/chunk-7AFOFSDY.js +105 -0
- package/dist/node-runtime/chunk-7N3YHTYF.js +26 -0
- package/dist/node-runtime/chunk-ARC4KOTI.js +11178 -0
- package/dist/node-runtime/chunk-AUXVGBO4.js +19 -0
- package/dist/node-runtime/chunk-AY6CAJSL.js +30 -0
- package/dist/node-runtime/chunk-BHO7O6E5.js +296 -0
- package/dist/node-runtime/chunk-BI3DHYCN.js +8845 -0
- package/dist/node-runtime/chunk-BKAZ6BKX.js +2185 -0
- package/dist/node-runtime/chunk-BR7YDUKA.js +109 -0
- package/dist/node-runtime/chunk-BRJX2PRC.js +53 -0
- package/dist/node-runtime/chunk-C4O2RSQQ.js +37 -0
- package/dist/node-runtime/chunk-CCZJ3PYY.js +17 -0
- package/dist/node-runtime/chunk-CGBXPL3E.js +1171 -0
- package/dist/node-runtime/chunk-CH6OL6P2.js +295 -0
- package/dist/node-runtime/chunk-CJECDQKP.js +19 -0
- package/dist/node-runtime/chunk-DAPBPCBP.js +53 -0
- package/dist/node-runtime/chunk-DDGMHUOW.js +305 -0
- package/dist/node-runtime/chunk-DMMTJQMQ.js +43 -0
- package/dist/node-runtime/chunk-DVGWF6A2.js +1180 -0
- package/dist/node-runtime/chunk-EH2LJQPM.js +64 -0
- package/dist/node-runtime/chunk-EHMBW7FA.js +772 -0
- package/dist/node-runtime/chunk-FLYMHKCS.js +966 -0
- package/dist/node-runtime/chunk-FVDOXRUD.js +96 -0
- package/dist/node-runtime/chunk-GZQHMEWL.js +126 -0
- package/dist/node-runtime/chunk-H2EOZYMP.js +57 -0
- package/dist/node-runtime/chunk-HQCKFM2O.js +56 -0
- package/dist/node-runtime/chunk-HRS4HMDX.js +610 -0
- package/dist/node-runtime/chunk-HYHJIRDW.js +19 -0
- package/dist/node-runtime/chunk-I6R76AG7.js +22 -0
- package/dist/node-runtime/chunk-ISQDQIZN.js +296 -0
- package/dist/node-runtime/chunk-J7QGQD45.js +24921 -0
- package/dist/node-runtime/chunk-JHYKXIMM.js +378 -0
- package/dist/node-runtime/chunk-JT6YCS5B.js +5648 -0
- package/dist/node-runtime/chunk-JZHEUQRL.js +180 -0
- package/dist/node-runtime/chunk-K72NVGUB.js +2834 -0
- package/dist/node-runtime/chunk-KKSIVROT.js +88 -0
- package/dist/node-runtime/chunk-LCACDWHJ.js +1743 -0
- package/dist/node-runtime/chunk-LTXUQJI4.js +173 -0
- package/dist/node-runtime/chunk-LWJXTA6Z.js +6814 -0
- package/dist/node-runtime/chunk-M3LZLQW2.js +98 -0
- package/dist/node-runtime/chunk-MGSB2C3M.js +46 -0
- package/dist/node-runtime/chunk-MGWCVY6Y.js +47 -0
- package/dist/node-runtime/chunk-MJQDX3BA.js +72 -0
- package/dist/node-runtime/chunk-MUMMMTW4.js +8392 -0
- package/dist/node-runtime/chunk-MX3GJNXJ.js +986 -0
- package/dist/node-runtime/chunk-NUIFPZWX.js +209 -0
- package/dist/node-runtime/chunk-OBMWP3I5.js +68 -0
- package/dist/node-runtime/chunk-OR4L3IB2.js +42 -0
- package/dist/node-runtime/chunk-OTT6JMPU.js +807 -0
- package/dist/node-runtime/chunk-PCIGF2XK.js +250 -0
- package/dist/node-runtime/chunk-PL6JKXWI.js +3622 -0
- package/dist/node-runtime/chunk-PVCDKGR6.js +55 -0
- package/dist/node-runtime/chunk-Q4Q6D4IY.js +364 -0
- package/dist/node-runtime/chunk-Q5ZU2VRT.js +83 -0
- package/dist/node-runtime/chunk-QFWG2RVL.js +5477 -0
- package/dist/node-runtime/chunk-RQ2Q5IYR.js +72 -0
- package/dist/node-runtime/chunk-RQ5DNUNG.js +429 -0
- package/dist/node-runtime/chunk-RRIZE6QQ.js +17 -0
- package/dist/node-runtime/chunk-SN6G4OU6.js +4753 -0
- package/dist/node-runtime/chunk-SWSN6HAB.js +53 -0
- package/dist/node-runtime/chunk-T5GM5BFH.js +7558 -0
- package/dist/node-runtime/chunk-TAP7QTUT.js +1346 -0
- package/dist/node-runtime/chunk-U6C7VTR5.js +2033 -0
- package/dist/node-runtime/chunk-URD2SLIT.js +1019 -0
- package/dist/node-runtime/chunk-VRB2IYGG.js +53 -0
- package/dist/node-runtime/chunk-W3CVH5RX.js +62 -0
- package/dist/node-runtime/chunk-W7S2REEG.js +9478 -0
- package/dist/node-runtime/chunk-XBWPBZBN.js +125 -0
- package/dist/node-runtime/chunk-XTHQ7XR7.js +509 -0
- package/dist/node-runtime/chunk-ZCHMJ34K.js +130 -0
- package/dist/node-runtime/chunk-ZRDIMBEQ.js +651 -0
- package/dist/node-runtime/chunk-ZSEZY3II.js +247 -0
- package/dist/node-runtime/cli-runtime.js +81 -0
- package/dist/node-runtime/clipboard-OZ63BBC6.js +12 -0
- package/dist/node-runtime/clipboard-image-7QR6GXVA.js +13 -0
- package/dist/node-runtime/command-6UXQ6XZN.js +13 -0
- package/dist/node-runtime/commands-LGR5VT5X.js +293 -0
- package/dist/node-runtime/config-FMEOZSWE.js +77 -0
- package/dist/node-runtime/curator-server-XCM43VEF.js +3816 -0
- package/dist/node-runtime/customize-XEXL2DGQ.js +12 -0
- package/dist/node-runtime/direct-tool-executor-TDJS7TBD.js +191 -0
- package/dist/node-runtime/exa-LL64QZR2.js +329 -0
- package/dist/node-runtime/export-html-E4DT6ZJQ.js +150 -0
- package/dist/node-runtime/extension-input-RV5N6APL.js +14 -0
- package/dist/node-runtime/extension-selector-CPD5LWDD.js +14 -0
- package/dist/node-runtime/extract-IUCVZCWC.js +17 -0
- package/dist/node-runtime/file-sync-HCOP2QVF.js +117 -0
- package/dist/node-runtime/gateway-3OLC4GQN.js +2139 -0
- package/dist/node-runtime/gemini-api-QE7ANVDZ.js +29 -0
- package/dist/node-runtime/gemini-search-NCIDF7NE.js +330 -0
- package/dist/node-runtime/gemini-url-context-OKIN7AIP.js +103 -0
- package/dist/node-runtime/gemini-web-MM446SEH.js +14 -0
- package/dist/node-runtime/github-extract-F64RZOEA.js +619 -0
- package/dist/node-runtime/goal-CZQ7FFQJ.js +1831 -0
- package/dist/node-runtime/image-resize-6ZPBFMWW.js +11 -0
- package/dist/node-runtime/index.js +863 -0
- package/dist/node-runtime/init-EKE277AG.js +30 -0
- package/dist/node-runtime/install-cli-TH7IJJQQ.js +308 -0
- package/dist/node-runtime/interactive-mode-S5M26CQ7.js +59 -0
- package/dist/node-runtime/interactive-view-N6F4KUIT.js +247 -0
- package/dist/node-runtime/lsp-manager-3ASUSO4T.js +1104 -0
- package/dist/node-runtime/lunr-computer-use-4X3KUNF4.js +206 -0
- package/dist/node-runtime/lunr-cron-KKBOGAEF.js +274 -0
- package/dist/node-runtime/main.js +57 -0
- package/dist/node-runtime/mcp-auth-flow-YL6RWPYG.js +33 -0
- package/dist/node-runtime/mcp-panel-IIGMXQGP.js +501 -0
- package/dist/node-runtime/mcp-setup-panel-FEK7663I.js +355 -0
- package/dist/node-runtime/memory-cap-3S4XRLNP.js +20 -0
- package/dist/node-runtime/model-tiers-NJLHUEGK.js +20 -0
- package/dist/node-runtime/openai-search-B3MSNCQA.js +288 -0
- package/dist/node-runtime/package-manager-cli-C4EJOO5Q.js +751 -0
- package/dist/node-runtime/parallel-AI2MNSCU.js +265 -0
- package/dist/node-runtime/parser-manager-TQHWYDH7.js +152 -0
- package/dist/node-runtime/pdf-extract-IPE6H4HP.js +57 -0
- package/dist/node-runtime/perplexity-QVJW3I35.js +12 -0
- package/dist/node-runtime/pi-intercom-EEMBGQID.js +2215 -0
- package/dist/node-runtime/pi-mcp-adapter-DPTJGAAL.js +428 -0
- package/dist/node-runtime/pi-ollama-cloud-4VZRMULP.js +1440 -0
- package/dist/node-runtime/pi-prompt-template-model-4QT4LLXF.js +3946 -0
- package/dist/node-runtime/pi-subagents-VKCLYIBY.js +6050 -0
- package/dist/node-runtime/pi-web-access-BV6DSZOP.js +1867 -0
- package/dist/node-runtime/print-mode-VWIRFDAC.js +12 -0
- package/dist/node-runtime/proxy-modes-R64LU6WZ.js +688 -0
- package/dist/node-runtime/rpc-entry.js +65 -0
- package/dist/node-runtime/rpc-mode-SJNSOA4G.js +13 -0
- package/dist/node-runtime/runtime-3SB5ATHQ.js +21 -0
- package/dist/node-runtime/runtime-bridges-UJ5WJJLN.js +14 -0
- package/dist/node-runtime/session-manager-QEMZBMTM.js +33 -0
- package/dist/node-runtime/session-selector-URVJLOTK.js +14 -0
- package/dist/node-runtime/settings-manager-K6IPIQTI.js +23 -0
- package/dist/node-runtime/src-GPFAU3N6.js +2427 -0
- package/dist/node-runtime/subagent-executor-EFLTO32A.js +8501 -0
- package/dist/node-runtime/summary-review-YSMXKITO.js +228 -0
- package/dist/node-runtime/tavily-WEZFVFP7.js +154 -0
- package/dist/node-runtime/timings-UAD5BEAS.js +16 -0
- package/dist/node-runtime/tool-renderer-MV5O452K.js +204 -0
- package/dist/node-runtime/update-cli-I6OVDRPL.js +75 -0
- package/dist/node-runtime/v4-5MNC3H7G.js +424 -0
- package/dist/node-runtime/video-extract-ETA5RA7U.js +304 -0
- package/dist/node-runtime/workflow-SA34S4VX.js +325 -0
- package/dist/node-runtime/workspace-index-6DBXSTJ6.js +163 -0
- package/dist/node-runtime/youtube-extract-SRVGNN26.js +264 -0
- package/dist/rpc.d.ts +3 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +18 -0
- package/dist/rpc.js.map +1 -0
- package/dist/startup/benchmark-request.d.ts +3 -0
- package/dist/startup/benchmark-request.d.ts.map +1 -0
- package/dist/startup/benchmark-request.js +65 -0
- package/dist/startup/benchmark-request.js.map +1 -0
- package/dist/startup/{interactive-shell.d.ts → interactive-view.d.ts} +18 -18
- package/dist/startup/interactive-view.d.ts.map +1 -0
- package/dist/startup/{interactive-shell.js → interactive-view.js} +119 -52
- package/dist/startup/interactive-view.js.map +1 -0
- package/dist/startup/launch-routing.d.ts.map +1 -1
- package/dist/startup/launch-routing.js +9 -10
- package/dist/startup/launch-routing.js.map +1 -1
- package/dist/startup/startup-milestones.d.ts +1 -1
- package/dist/startup/startup-milestones.d.ts.map +1 -1
- package/dist/startup/startup-milestones.js +3 -2
- package/dist/startup/startup-milestones.js.map +1 -1
- package/dist/utils/await-with-abort.d.ts +2 -0
- package/dist/utils/await-with-abort.d.ts.map +1 -0
- package/dist/utils/await-with-abort.js +19 -0
- package/dist/utils/await-with-abort.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +10 -4
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/docs/compaction.md +5 -3
- package/docs/computer-use.md +277 -0
- package/docs/development.md +5 -33
- package/docs/features.md +2 -3
- package/docs/interactive-startup.md +105 -0
- package/docs/keybindings.md +2 -2
- package/docs/terminal-setup.md +1 -1
- package/docs/usage.md +1 -2
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/hidden-thinking-label.ts +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/install-lock/package-lock.json +3827 -0
- package/install-lock/package.json +18 -0
- package/native/computer-use/LICENSE.md +21 -0
- package/npm-shrinkwrap.json +3808 -0
- package/package.json +30 -24
- package/dist/core/swarm.d.ts +0 -23
- package/dist/core/swarm.d.ts.map +0 -1
- package/dist/core/swarm.js +0 -45
- package/dist/core/swarm.js.map +0 -1
- package/dist/startup/interactive-shell.d.ts.map +0 -1
- package/dist/startup/interactive-shell.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
CUSTOMIZE_BRIDGE_SYMBOL,
|
|
4
|
+
getCustomizeBridge,
|
|
5
|
+
registerCustomizeBridge
|
|
6
|
+
} from "./chunk-HQCKFM2O.js";
|
|
7
|
+
import "./chunk-BRJX2PRC.js";
|
|
8
|
+
export {
|
|
9
|
+
CUSTOMIZE_BRIDGE_SYMBOL,
|
|
10
|
+
getCustomizeBridge,
|
|
11
|
+
registerCustomizeBridge
|
|
12
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
guardMcpOutput,
|
|
4
|
+
guardedMcpDetails,
|
|
5
|
+
maybeStartUiSession,
|
|
6
|
+
resolveMcpOutputGuardOptions,
|
|
7
|
+
resolveMcpResultContent,
|
|
8
|
+
transformMcpContent
|
|
9
|
+
} from "./chunk-6SPPH4FY.js";
|
|
10
|
+
import {
|
|
11
|
+
formatSchema,
|
|
12
|
+
getFailureAgeSeconds,
|
|
13
|
+
lazyConnect
|
|
14
|
+
} from "./chunk-BKAZ6BKX.js";
|
|
15
|
+
import {
|
|
16
|
+
abortable,
|
|
17
|
+
formatAuthRequiredMessage,
|
|
18
|
+
throwIfAborted
|
|
19
|
+
} from "./chunk-EHMBW7FA.js";
|
|
20
|
+
import "./chunk-ARC4KOTI.js";
|
|
21
|
+
import "./chunk-LWJXTA6Z.js";
|
|
22
|
+
import {
|
|
23
|
+
authenticate,
|
|
24
|
+
supportsOAuth
|
|
25
|
+
} from "./chunk-U6C7VTR5.js";
|
|
26
|
+
import "./chunk-4HXHDDCF.js";
|
|
27
|
+
import {
|
|
28
|
+
UrlElicitationRequiredError
|
|
29
|
+
} from "./chunk-2IDTZAG5.js";
|
|
30
|
+
import "./chunk-BI3DHYCN.js";
|
|
31
|
+
import "./chunk-Q4Q6D4IY.js";
|
|
32
|
+
import "./chunk-BRJX2PRC.js";
|
|
33
|
+
|
|
34
|
+
// packages/coding-agent/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js
|
|
35
|
+
function getDirectAuthRequiredMessage(state, serverName, defaultMessage = `MCP server "${serverName}" requires OAuth authentication. Run mcp({ action: "auth-start", server: "${serverName}" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`) {
|
|
36
|
+
return formatAuthRequiredMessage(state.config, serverName, defaultMessage);
|
|
37
|
+
}
|
|
38
|
+
function getDirectAuthFailedMessage(state, serverName, message) {
|
|
39
|
+
return state.config.settings?.authRequiredMessage ? `OAuth authentication failed for "${serverName}": ${message}. ${getDirectAuthRequiredMessage(state, serverName)}` : `OAuth authentication failed for "${serverName}": ${message}. Run mcp({ action: "auth-start", server: "${serverName}" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`;
|
|
40
|
+
}
|
|
41
|
+
async function attemptDirectAutoAuth(state, serverName, signal) {
|
|
42
|
+
if (state.config.settings?.autoAuth !== !0)
|
|
43
|
+
return { status: "skipped" };
|
|
44
|
+
let definition = state.config.mcpServers[serverName];
|
|
45
|
+
if (!definition || !supportsOAuth(definition) || !definition.url)
|
|
46
|
+
return { status: "skipped" };
|
|
47
|
+
let grantType = definition.oauth ? definition.oauth.grantType ?? "authorization_code" : "authorization_code";
|
|
48
|
+
if (!state.ui && grantType !== "client_credentials")
|
|
49
|
+
return {
|
|
50
|
+
status: "failed",
|
|
51
|
+
message: getDirectAuthRequiredMessage(state, serverName, `MCP server "${serverName}" requires OAuth authentication. Run mcp({ action: "auth-start", server: "${serverName}" }) to get a browser URL, or /mcp-auth ${serverName} in an interactive local session.`)
|
|
52
|
+
};
|
|
53
|
+
try {
|
|
54
|
+
return await abortable(authenticate(serverName, definition.url, definition), signal), throwIfAborted(signal), { status: "success" };
|
|
55
|
+
} catch (error) {
|
|
56
|
+
throwIfAborted(signal);
|
|
57
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
58
|
+
return {
|
|
59
|
+
status: "failed",
|
|
60
|
+
message: getDirectAuthFailedMessage(state, serverName, message)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function createDirectToolExecutor(getState, getInitPromise, spec) {
|
|
65
|
+
return async function(_toolCallId, params, signal) {
|
|
66
|
+
throwIfAborted(signal);
|
|
67
|
+
let state = getState(), initPromise = getInitPromise();
|
|
68
|
+
if (!state && initPromise)
|
|
69
|
+
try {
|
|
70
|
+
state = await initPromise;
|
|
71
|
+
} catch (error) {
|
|
72
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
73
|
+
return {
|
|
74
|
+
content: [{ type: "text", text: `MCP initialization failed: ${message}` }],
|
|
75
|
+
details: { error: "init_failed", message }
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (!state)
|
|
79
|
+
return {
|
|
80
|
+
content: [{ type: "text", text: "MCP not initialized" }],
|
|
81
|
+
details: { error: "not_initialized" }
|
|
82
|
+
};
|
|
83
|
+
let connected = await lazyConnect(state, spec.serverName, signal);
|
|
84
|
+
throwIfAborted(signal);
|
|
85
|
+
let autoAuthAttempted = !1;
|
|
86
|
+
if (!connected && state.manager.getConnection(spec.serverName)?.status === "needs-auth") {
|
|
87
|
+
autoAuthAttempted = !0;
|
|
88
|
+
let autoAuth = await attemptDirectAutoAuth(state, spec.serverName, signal);
|
|
89
|
+
if (throwIfAborted(signal), autoAuth.status === "failed")
|
|
90
|
+
return {
|
|
91
|
+
content: [{ type: "text", text: autoAuth.message }],
|
|
92
|
+
details: { error: "auth_required", server: spec.serverName, message: autoAuth.message }
|
|
93
|
+
};
|
|
94
|
+
autoAuth.status === "success" && (await state.manager.close(spec.serverName), throwIfAborted(signal), state.failureTracker.delete(spec.serverName), connected = await lazyConnect(state, spec.serverName, signal), throwIfAborted(signal));
|
|
95
|
+
}
|
|
96
|
+
if (!connected) {
|
|
97
|
+
if (state.manager.getConnection(spec.serverName)?.status === "needs-auth") {
|
|
98
|
+
let message = getDirectAuthRequiredMessage(state, spec.serverName);
|
|
99
|
+
return {
|
|
100
|
+
content: [{ type: "text", text: message }],
|
|
101
|
+
details: { error: "auth_required", server: spec.serverName, message, autoAuthAttempted }
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
let failedAgo = getFailureAgeSeconds(state, spec.serverName);
|
|
105
|
+
return {
|
|
106
|
+
content: [{ type: "text", text: `MCP server "${spec.serverName}" not available${failedAgo !== null ? ` (failed ${failedAgo}s ago)` : ""}` }],
|
|
107
|
+
details: { error: "server_unavailable", server: spec.serverName }
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
let connection = state.manager.getConnection(spec.serverName);
|
|
111
|
+
if (!connection || connection.status !== "connected")
|
|
112
|
+
return {
|
|
113
|
+
content: [{ type: "text", text: `MCP server "${spec.serverName}" not connected` }],
|
|
114
|
+
details: { error: "not_connected", server: spec.serverName }
|
|
115
|
+
};
|
|
116
|
+
let uiSession = null, requestOptions = state.manager.getRequestOptions?.(spec.serverName, signal) ?? (signal ? { signal } : void 0), outputGuardOptions = resolveMcpOutputGuardOptions(state.config.settings);
|
|
117
|
+
try {
|
|
118
|
+
if (state.manager.touch(spec.serverName), state.manager.incrementInFlight(spec.serverName), spec.resourceUri) {
|
|
119
|
+
let content2 = ((await connection.client.readResource({ uri: spec.resourceUri }, requestOptions)).contents ?? []).map((c) => ({
|
|
120
|
+
type: "text",
|
|
121
|
+
text: "text" in c ? c.text : "blob" in c ? `[Binary data: ${c.mimeType ?? "unknown"}]` : JSON.stringify(c)
|
|
122
|
+
})), guarded2 = await guardMcpOutput(content2.length > 0 ? content2 : [{ type: "text", text: "(empty resource)" }], outputGuardOptions);
|
|
123
|
+
return {
|
|
124
|
+
content: guarded2.content,
|
|
125
|
+
details: { server: spec.serverName, resourceUri: spec.resourceUri, ...guardedMcpDetails(guarded2) }
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
let hasUi = !!spec.uiResourceUri;
|
|
129
|
+
uiSession = hasUi ? await maybeStartUiSession(state, {
|
|
130
|
+
serverName: spec.serverName,
|
|
131
|
+
toolName: spec.originalName,
|
|
132
|
+
toolArgs: params ?? {},
|
|
133
|
+
uiResourceUri: spec.uiResourceUri,
|
|
134
|
+
streamMode: spec.uiStreamMode
|
|
135
|
+
}) : null, throwIfAborted(signal);
|
|
136
|
+
let resultPromise = connection.client.callTool({
|
|
137
|
+
name: spec.originalName,
|
|
138
|
+
arguments: params ?? {},
|
|
139
|
+
_meta: uiSession?.requestMeta
|
|
140
|
+
}, void 0, requestOptions), result = await abortable(resultPromise, signal);
|
|
141
|
+
if (throwIfAborted(signal), uiSession?.sendToolResult(result), result.isError) {
|
|
142
|
+
let mcpContent = result.content ?? [], content2 = transformMcpContent(mcpContent), outputContent2 = content2.length > 0 ? content2 : [{ type: "text", text: "(empty result)" }], schemaText = spec.inputSchema ? `
|
|
143
|
+
|
|
144
|
+
Expected parameters:
|
|
145
|
+
${formatSchema(spec.inputSchema)}` : "", guarded2 = await guardMcpOutput(outputContent2, { ...outputGuardOptions, prefix: "Error: ", suffix: schemaText, emptyTextFallback: "Tool execution failed" });
|
|
146
|
+
return {
|
|
147
|
+
content: guarded2.content,
|
|
148
|
+
details: { error: "tool_error", server: spec.serverName, ...guardedMcpDetails(guarded2) }
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
let content = resolveMcpResultContent(result), outputContent = content.length > 0 ? content : [{ type: "text", text: "(empty result)" }];
|
|
152
|
+
if (hasUi) {
|
|
153
|
+
let uiMessage = uiSession?.reused ? "Updated the open UI." : "\u{1F4FA} Interactive UI is now open in your browser. I'll respond to your prompts and intents as you interact with it.", guarded2 = await guardMcpOutput(outputContent, { ...outputGuardOptions, suffix: `
|
|
154
|
+
|
|
155
|
+
${uiMessage}` });
|
|
156
|
+
return {
|
|
157
|
+
content: guarded2.content,
|
|
158
|
+
details: { server: spec.serverName, tool: spec.originalName, uiOpen: !0, ...guardedMcpDetails(guarded2) }
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
let guarded = await guardMcpOutput(outputContent, { ...outputGuardOptions });
|
|
162
|
+
return {
|
|
163
|
+
content: guarded.content,
|
|
164
|
+
details: { server: spec.serverName, tool: spec.originalName, ...guardedMcpDetails(guarded) }
|
|
165
|
+
};
|
|
166
|
+
} catch (error) {
|
|
167
|
+
if (error instanceof UrlElicitationRequiredError) {
|
|
168
|
+
let action = await state.manager.handleUrlElicitationRequired(spec.serverName, error), message2 = action === "accept" ? "The original MCP tool did not run. Complete the opened browser interaction, then retry the tool." : `The URL interaction was ${action === "decline" ? "declined" : "cancelled"}.`;
|
|
169
|
+
return uiSession?.sendToolCancelled(message2), {
|
|
170
|
+
content: [{ type: "text", text: message2 }],
|
|
171
|
+
details: { error: "url_elicitation_required", server: spec.serverName, action }
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
175
|
+
uiSession?.sendToolCancelled(message);
|
|
176
|
+
let schemaText = spec.inputSchema ? `
|
|
177
|
+
|
|
178
|
+
Expected parameters:
|
|
179
|
+
${formatSchema(spec.inputSchema)}` : "", guarded = await guardMcpOutput([{ type: "text", text: message }], { ...outputGuardOptions, prefix: "Failed to call tool: ", suffix: schemaText });
|
|
180
|
+
return {
|
|
181
|
+
content: guarded.content,
|
|
182
|
+
details: { error: "call_failed", server: spec.serverName, ...guardedMcpDetails(guarded) }
|
|
183
|
+
};
|
|
184
|
+
} finally {
|
|
185
|
+
uiSession?.reused && uiSession.close(), state.manager.decrementInFlight(spec.serverName), state.manager.touch(spec.serverName);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
export {
|
|
190
|
+
createDirectToolExecutor
|
|
191
|
+
};
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
activityMonitor
|
|
4
|
+
} from "./chunk-DAPBPCBP.js";
|
|
5
|
+
import {
|
|
6
|
+
getWebSearchConfigPath
|
|
7
|
+
} from "./chunk-VRB2IYGG.js";
|
|
8
|
+
import "./chunk-BRJX2PRC.js";
|
|
9
|
+
|
|
10
|
+
// packages/coding-agent/dist/builtin-extensions/pi-web-access/exa.js
|
|
11
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
12
|
+
var EXA_ANSWER_URL = "https://api.exa.ai/answer", EXA_SEARCH_URL = "https://api.exa.ai/search", EXA_MCP_URL = "https://mcp.exa.ai/mcp", CONFIG_PATH = getWebSearchConfigPath(), cachedConfig = null;
|
|
13
|
+
function loadConfig() {
|
|
14
|
+
if (cachedConfig)
|
|
15
|
+
return cachedConfig;
|
|
16
|
+
if (!existsSync(CONFIG_PATH))
|
|
17
|
+
return cachedConfig = {}, cachedConfig;
|
|
18
|
+
let raw = readFileSync(CONFIG_PATH, "utf-8");
|
|
19
|
+
try {
|
|
20
|
+
return cachedConfig = JSON.parse(raw), cachedConfig;
|
|
21
|
+
} catch (err) {
|
|
22
|
+
let message = err instanceof Error ? err.message : String(err);
|
|
23
|
+
throw new Error(`Failed to parse ${CONFIG_PATH}: ${message}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function normalizeApiKey(value) {
|
|
27
|
+
if (typeof value != "string")
|
|
28
|
+
return null;
|
|
29
|
+
let normalized = value.trim();
|
|
30
|
+
return normalized.length > 0 ? normalized : null;
|
|
31
|
+
}
|
|
32
|
+
function getApiKey() {
|
|
33
|
+
return normalizeApiKey(process.env.EXA_API_KEY) ?? normalizeApiKey(loadConfig().exaApiKey);
|
|
34
|
+
}
|
|
35
|
+
function requestSignal(signal) {
|
|
36
|
+
let timeout = AbortSignal.timeout(6e4);
|
|
37
|
+
return signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
38
|
+
}
|
|
39
|
+
function recencyToStartDate(filter) {
|
|
40
|
+
let now = /* @__PURE__ */ new Date(), days = {
|
|
41
|
+
day: 1,
|
|
42
|
+
week: 7,
|
|
43
|
+
month: 30,
|
|
44
|
+
year: 365
|
|
45
|
+
}[filter] ?? 0;
|
|
46
|
+
return new Date(now.getTime() - days * 864e5).toISOString();
|
|
47
|
+
}
|
|
48
|
+
function mapDomainFilter(domainFilter) {
|
|
49
|
+
if (!domainFilter?.length)
|
|
50
|
+
return {};
|
|
51
|
+
let includeDomains = domainFilter.filter((d) => !d.startsWith("-") && d.trim().length > 0).map((d) => d.trim()), excludeDomains = domainFilter.filter((d) => d.startsWith("-")).map((d) => d.slice(1).trim()).filter(Boolean);
|
|
52
|
+
return {
|
|
53
|
+
...includeDomains.length ? { includeDomains } : {},
|
|
54
|
+
...excludeDomains.length ? { excludeDomains } : {}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function normalizeHighlights(value) {
|
|
58
|
+
return Array.isArray(value) ? value.filter((item) => typeof item == "string" && item.trim().length > 0) : [];
|
|
59
|
+
}
|
|
60
|
+
function buildAnswerFromSearchResults(results) {
|
|
61
|
+
if (!results?.length)
|
|
62
|
+
return "";
|
|
63
|
+
let parts = [];
|
|
64
|
+
for (let i = 0; i < results.length; i++) {
|
|
65
|
+
let item = results[i];
|
|
66
|
+
if (!item?.url)
|
|
67
|
+
continue;
|
|
68
|
+
let highlights = normalizeHighlights(item.highlights), content = highlights.length > 0 ? highlights.join(" ") : typeof item.text == "string" ? item.text.trim().slice(0, 1e3) : "";
|
|
69
|
+
if (!content)
|
|
70
|
+
continue;
|
|
71
|
+
let sourceTitle = item.title || `Source ${i + 1}`;
|
|
72
|
+
parts.push(`${content}
|
|
73
|
+
Source: ${sourceTitle} (${item.url})`);
|
|
74
|
+
}
|
|
75
|
+
return parts.join(`
|
|
76
|
+
|
|
77
|
+
`);
|
|
78
|
+
}
|
|
79
|
+
function mapResults(results) {
|
|
80
|
+
if (!Array.isArray(results))
|
|
81
|
+
return [];
|
|
82
|
+
let mapped = [];
|
|
83
|
+
for (let i = 0; i < results.length; i++) {
|
|
84
|
+
let item = results[i];
|
|
85
|
+
item?.url && mapped.push({
|
|
86
|
+
title: item.title || `Source ${i + 1}`,
|
|
87
|
+
url: item.url,
|
|
88
|
+
snippet: ""
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return mapped;
|
|
92
|
+
}
|
|
93
|
+
function mapInlineContent(results) {
|
|
94
|
+
return results?.length ? results.filter((r) => !!r?.url && typeof r.text == "string" && r.text.length > 0).map((r) => ({
|
|
95
|
+
url: r.url,
|
|
96
|
+
title: r.title || "",
|
|
97
|
+
content: r.text,
|
|
98
|
+
error: null
|
|
99
|
+
})) : [];
|
|
100
|
+
}
|
|
101
|
+
async function callExaMcp(toolName, args, signal) {
|
|
102
|
+
let response = await fetch(EXA_MCP_URL, {
|
|
103
|
+
method: "POST",
|
|
104
|
+
headers: {
|
|
105
|
+
"Content-Type": "application/json",
|
|
106
|
+
Accept: "application/json, text/event-stream"
|
|
107
|
+
},
|
|
108
|
+
body: JSON.stringify({
|
|
109
|
+
jsonrpc: "2.0",
|
|
110
|
+
id: 1,
|
|
111
|
+
method: "tools/call",
|
|
112
|
+
params: {
|
|
113
|
+
name: toolName,
|
|
114
|
+
arguments: args
|
|
115
|
+
}
|
|
116
|
+
}),
|
|
117
|
+
signal: requestSignal(signal)
|
|
118
|
+
});
|
|
119
|
+
if (!response.ok) {
|
|
120
|
+
let errorText = await response.text();
|
|
121
|
+
throw new Error(`Exa MCP error ${response.status}: ${errorText.slice(0, 300)}`);
|
|
122
|
+
}
|
|
123
|
+
let body = await response.text(), dataLines = body.split(`
|
|
124
|
+
`).filter((line) => line.startsWith("data:")), parsed = null;
|
|
125
|
+
for (let line of dataLines) {
|
|
126
|
+
let payload = line.slice(5).trim();
|
|
127
|
+
if (payload)
|
|
128
|
+
try {
|
|
129
|
+
let candidate = JSON.parse(payload);
|
|
130
|
+
if (candidate?.result || candidate?.error) {
|
|
131
|
+
parsed = candidate;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
} catch {
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (!parsed)
|
|
138
|
+
try {
|
|
139
|
+
let candidate = JSON.parse(body);
|
|
140
|
+
(candidate?.result || candidate?.error) && (parsed = candidate);
|
|
141
|
+
} catch {
|
|
142
|
+
}
|
|
143
|
+
if (!parsed)
|
|
144
|
+
throw new Error("Exa MCP returned an empty response");
|
|
145
|
+
if (parsed.error) {
|
|
146
|
+
let code = typeof parsed.error.code == "number" ? ` ${parsed.error.code}` : "", message = parsed.error.message || "Unknown error";
|
|
147
|
+
throw new Error(`Exa MCP error${code}: ${message}`);
|
|
148
|
+
}
|
|
149
|
+
if (parsed.result?.isError) {
|
|
150
|
+
let message = parsed.result.content?.find((item) => item.type === "text" && typeof item.text == "string")?.text?.trim();
|
|
151
|
+
throw new Error(message || "Exa MCP returned an error");
|
|
152
|
+
}
|
|
153
|
+
let text = parsed.result?.content?.find((item) => item.type === "text" && typeof item.text == "string" && item.text.trim().length > 0)?.text;
|
|
154
|
+
if (!text)
|
|
155
|
+
throw new Error("Exa MCP returned empty content");
|
|
156
|
+
return text;
|
|
157
|
+
}
|
|
158
|
+
function parseMcpResults(text) {
|
|
159
|
+
let parsed = text.split(/(?=^Title: )/m).filter((block) => block.trim().length > 0).map((block) => {
|
|
160
|
+
let title = block.match(/^Title: (.+)/m)?.[1]?.trim() ?? "", url = block.match(/^URL: (.+)/m)?.[1]?.trim() ?? "", content = "", textStart = block.indexOf(`
|
|
161
|
+
Text: `);
|
|
162
|
+
if (textStart >= 0)
|
|
163
|
+
content = block.slice(textStart + 7).trim();
|
|
164
|
+
else {
|
|
165
|
+
let hlMatch = block.match(/\nHighlights:\s*\n/);
|
|
166
|
+
hlMatch?.index != null && (content = block.slice(hlMatch.index + hlMatch[0].length).trim());
|
|
167
|
+
}
|
|
168
|
+
return content = content.replace(/\n---\s*$/, "").trim(), { title, url, content };
|
|
169
|
+
}).filter((result) => result.url.length > 0);
|
|
170
|
+
return parsed.length > 0 ? parsed : null;
|
|
171
|
+
}
|
|
172
|
+
function buildAnswerFromMcpResults(results) {
|
|
173
|
+
if (results.length === 0)
|
|
174
|
+
return "";
|
|
175
|
+
let parts = [];
|
|
176
|
+
for (let i = 0; i < results.length; i++) {
|
|
177
|
+
let result = results[i], snippet = result.content.replace(/\s+/g, " ").trim().slice(0, 500);
|
|
178
|
+
if (!snippet)
|
|
179
|
+
continue;
|
|
180
|
+
let sourceTitle = result.title || `Source ${i + 1}`;
|
|
181
|
+
parts.push(`${snippet}
|
|
182
|
+
Source: ${sourceTitle} (${result.url})`);
|
|
183
|
+
}
|
|
184
|
+
return parts.join(`
|
|
185
|
+
|
|
186
|
+
`);
|
|
187
|
+
}
|
|
188
|
+
function mapMcpInlineContent(results) {
|
|
189
|
+
return results.filter((result) => result.content.length > 0).map((result) => ({
|
|
190
|
+
url: result.url,
|
|
191
|
+
title: result.title,
|
|
192
|
+
content: result.content,
|
|
193
|
+
error: null
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
function buildMcpQuery(query, options) {
|
|
197
|
+
let parts = [query];
|
|
198
|
+
if (options.domainFilter?.length)
|
|
199
|
+
for (let d of options.domainFilter)
|
|
200
|
+
parts.push(d.startsWith("-") ? `-site:${d.slice(1)}` : `site:${d}`);
|
|
201
|
+
if (options.recencyFilter) {
|
|
202
|
+
let now = /* @__PURE__ */ new Date();
|
|
203
|
+
switch (options.recencyFilter) {
|
|
204
|
+
case "day":
|
|
205
|
+
parts.push("past 24 hours");
|
|
206
|
+
break;
|
|
207
|
+
case "week":
|
|
208
|
+
parts.push("past week");
|
|
209
|
+
break;
|
|
210
|
+
case "month":
|
|
211
|
+
parts.push(`${now.toLocaleString("en", { month: "long" })} ${now.getFullYear()}`);
|
|
212
|
+
break;
|
|
213
|
+
case "year":
|
|
214
|
+
parts.push(String(now.getFullYear()));
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return parts.join(" ");
|
|
219
|
+
}
|
|
220
|
+
async function searchWithExaMcp(query, options = {}) {
|
|
221
|
+
let enrichedQuery = buildMcpQuery(query, options), activityId = activityMonitor.logStart({ type: "api", query: enrichedQuery });
|
|
222
|
+
try {
|
|
223
|
+
let text = await callExaMcp("web_search_exa", {
|
|
224
|
+
query: enrichedQuery,
|
|
225
|
+
numResults: options.numResults ?? 5,
|
|
226
|
+
livecrawl: "fallback",
|
|
227
|
+
type: "auto",
|
|
228
|
+
contextMaxCharacters: options.includeContent ? 5e4 : 3e3
|
|
229
|
+
}, options.signal), parsedResults = parseMcpResults(text);
|
|
230
|
+
if (activityMonitor.logComplete(activityId, 200), !parsedResults)
|
|
231
|
+
return null;
|
|
232
|
+
let response = {
|
|
233
|
+
answer: buildAnswerFromMcpResults(parsedResults),
|
|
234
|
+
results: parsedResults.map((result, index) => ({
|
|
235
|
+
title: result.title || `Source ${index + 1}`,
|
|
236
|
+
url: result.url,
|
|
237
|
+
snippet: ""
|
|
238
|
+
}))
|
|
239
|
+
};
|
|
240
|
+
if (options.includeContent) {
|
|
241
|
+
let inlineContent = mapMcpInlineContent(parsedResults);
|
|
242
|
+
inlineContent.length > 0 && (response.inlineContent = inlineContent);
|
|
243
|
+
}
|
|
244
|
+
return response;
|
|
245
|
+
} catch (err) {
|
|
246
|
+
let message = err instanceof Error ? err.message : String(err);
|
|
247
|
+
throw message.toLowerCase().includes("abort") ? activityMonitor.logComplete(activityId, 0) : activityMonitor.logError(activityId, message), err;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function isExaAvailable() {
|
|
251
|
+
return !0;
|
|
252
|
+
}
|
|
253
|
+
function hasExaApiKey() {
|
|
254
|
+
return !!getApiKey();
|
|
255
|
+
}
|
|
256
|
+
async function searchWithExa(query, options = {}) {
|
|
257
|
+
let apiKey = getApiKey();
|
|
258
|
+
if (!apiKey)
|
|
259
|
+
return searchWithExaMcp(query, options);
|
|
260
|
+
let useSearch = options.includeContent || !!options.recencyFilter || !!options.domainFilter?.length || !!(options.numResults && options.numResults !== 5), activityId = activityMonitor.logStart({ type: "api", query });
|
|
261
|
+
try {
|
|
262
|
+
if (!useSearch) {
|
|
263
|
+
let response2 = await fetch(EXA_ANSWER_URL, {
|
|
264
|
+
method: "POST",
|
|
265
|
+
headers: {
|
|
266
|
+
"x-api-key": apiKey,
|
|
267
|
+
"Content-Type": "application/json"
|
|
268
|
+
},
|
|
269
|
+
body: JSON.stringify({
|
|
270
|
+
query,
|
|
271
|
+
text: !0
|
|
272
|
+
}),
|
|
273
|
+
signal: requestSignal(options.signal)
|
|
274
|
+
});
|
|
275
|
+
if (!response2.ok) {
|
|
276
|
+
let errorText = await response2.text();
|
|
277
|
+
throw new Error(`Exa API error ${response2.status}: ${errorText.slice(0, 300)}`);
|
|
278
|
+
}
|
|
279
|
+
let data2 = await response2.json();
|
|
280
|
+
return activityMonitor.logComplete(activityId, response2.status), {
|
|
281
|
+
answer: data2.answer || "",
|
|
282
|
+
results: mapResults(data2.citations)
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
let startDate = options.recencyFilter ? recencyToStartDate(options.recencyFilter) : null, domainFilters = mapDomainFilter(options.domainFilter), response = await fetch(EXA_SEARCH_URL, {
|
|
286
|
+
method: "POST",
|
|
287
|
+
headers: {
|
|
288
|
+
"x-api-key": apiKey,
|
|
289
|
+
"Content-Type": "application/json"
|
|
290
|
+
},
|
|
291
|
+
body: JSON.stringify({
|
|
292
|
+
query,
|
|
293
|
+
type: "auto",
|
|
294
|
+
numResults: options.numResults ?? 5,
|
|
295
|
+
...domainFilters,
|
|
296
|
+
...startDate ? { startPublishedDate: startDate } : {},
|
|
297
|
+
contents: {
|
|
298
|
+
text: options.includeContent ? !0 : { maxCharacters: 3e3 },
|
|
299
|
+
highlights: !0
|
|
300
|
+
}
|
|
301
|
+
}),
|
|
302
|
+
signal: requestSignal(options.signal)
|
|
303
|
+
});
|
|
304
|
+
if (!response.ok) {
|
|
305
|
+
let errorText = await response.text();
|
|
306
|
+
throw new Error(`Exa API error ${response.status}: ${errorText.slice(0, 300)}`);
|
|
307
|
+
}
|
|
308
|
+
let data = await response.json();
|
|
309
|
+
activityMonitor.logComplete(activityId, response.status);
|
|
310
|
+
let mapped = {
|
|
311
|
+
answer: buildAnswerFromSearchResults(data.results),
|
|
312
|
+
results: mapResults(data.results)
|
|
313
|
+
};
|
|
314
|
+
if (options.includeContent) {
|
|
315
|
+
let inlineContent = mapInlineContent(data.results);
|
|
316
|
+
inlineContent.length > 0 && (mapped.inlineContent = inlineContent);
|
|
317
|
+
}
|
|
318
|
+
return mapped;
|
|
319
|
+
} catch (err) {
|
|
320
|
+
let message = err instanceof Error ? err.message : String(err);
|
|
321
|
+
throw message.toLowerCase().includes("abort") ? activityMonitor.logComplete(activityId, 0) : activityMonitor.logError(activityId, message), err;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
export {
|
|
325
|
+
callExaMcp,
|
|
326
|
+
hasExaApiKey,
|
|
327
|
+
isExaAvailable,
|
|
328
|
+
searchWithExa
|
|
329
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
SessionManager
|
|
4
|
+
} from "./chunk-6UB6NKA3.js";
|
|
5
|
+
import "./chunk-FVDOXRUD.js";
|
|
6
|
+
import {
|
|
7
|
+
getResolvedThemeColors,
|
|
8
|
+
getThemeExportColors
|
|
9
|
+
} from "./chunk-MX3GJNXJ.js";
|
|
10
|
+
import {
|
|
11
|
+
APP_NAME,
|
|
12
|
+
getExportTemplateDir,
|
|
13
|
+
normalizePath,
|
|
14
|
+
resolvePath
|
|
15
|
+
} from "./chunk-PCIGF2XK.js";
|
|
16
|
+
import "./chunk-Q4Q6D4IY.js";
|
|
17
|
+
import "./chunk-BRJX2PRC.js";
|
|
18
|
+
|
|
19
|
+
// packages/coding-agent/dist/core/export-html/index.js
|
|
20
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
21
|
+
import { basename, join } from "path";
|
|
22
|
+
function parseColor(color) {
|
|
23
|
+
let hexMatch = color.match(/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/);
|
|
24
|
+
if (hexMatch)
|
|
25
|
+
return {
|
|
26
|
+
r: Number.parseInt(hexMatch[1], 16),
|
|
27
|
+
g: Number.parseInt(hexMatch[2], 16),
|
|
28
|
+
b: Number.parseInt(hexMatch[3], 16)
|
|
29
|
+
};
|
|
30
|
+
let rgbMatch = color.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);
|
|
31
|
+
if (rgbMatch)
|
|
32
|
+
return {
|
|
33
|
+
r: Number.parseInt(rgbMatch[1], 10),
|
|
34
|
+
g: Number.parseInt(rgbMatch[2], 10),
|
|
35
|
+
b: Number.parseInt(rgbMatch[3], 10)
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function getLuminance(r, g, b) {
|
|
39
|
+
let toLinear = (c) => {
|
|
40
|
+
let s = c / 255;
|
|
41
|
+
return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
42
|
+
};
|
|
43
|
+
return 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b);
|
|
44
|
+
}
|
|
45
|
+
function adjustBrightness(color, factor) {
|
|
46
|
+
let parsed = parseColor(color);
|
|
47
|
+
if (!parsed)
|
|
48
|
+
return color;
|
|
49
|
+
let adjust = (c) => Math.min(255, Math.max(0, Math.round(c * factor)));
|
|
50
|
+
return `rgb(${adjust(parsed.r)}, ${adjust(parsed.g)}, ${adjust(parsed.b)})`;
|
|
51
|
+
}
|
|
52
|
+
function deriveExportColors(baseColor) {
|
|
53
|
+
let parsed = parseColor(baseColor);
|
|
54
|
+
return parsed ? getLuminance(parsed.r, parsed.g, parsed.b) > 0.5 ? {
|
|
55
|
+
pageBg: adjustBrightness(baseColor, 0.96),
|
|
56
|
+
cardBg: baseColor,
|
|
57
|
+
infoBg: `rgb(${Math.min(255, parsed.r + 10)}, ${Math.min(255, parsed.g + 5)}, ${Math.max(0, parsed.b - 20)})`
|
|
58
|
+
} : {
|
|
59
|
+
pageBg: adjustBrightness(baseColor, 0.7),
|
|
60
|
+
cardBg: adjustBrightness(baseColor, 0.85),
|
|
61
|
+
infoBg: `rgb(${Math.min(255, parsed.r + 20)}, ${Math.min(255, parsed.g + 15)}, ${parsed.b})`
|
|
62
|
+
} : {
|
|
63
|
+
pageBg: "rgb(24, 24, 30)",
|
|
64
|
+
cardBg: "rgb(30, 30, 36)",
|
|
65
|
+
infoBg: "rgb(60, 55, 40)"
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function generateThemeVars(themeName) {
|
|
69
|
+
let colors = getResolvedThemeColors(themeName), lines = [];
|
|
70
|
+
for (let [key, value] of Object.entries(colors))
|
|
71
|
+
lines.push(`--${key}: ${value};`);
|
|
72
|
+
let themeExport = getThemeExportColors(themeName), userMessageBg = colors.userMessageBg || "#343541", derivedColors = deriveExportColors(userMessageBg);
|
|
73
|
+
return lines.push(`--exportPageBg: ${themeExport.pageBg ?? derivedColors.pageBg};`), lines.push(`--exportCardBg: ${themeExport.cardBg ?? derivedColors.cardBg};`), lines.push(`--exportInfoBg: ${themeExport.infoBg ?? derivedColors.infoBg};`), lines.join(`
|
|
74
|
+
`);
|
|
75
|
+
}
|
|
76
|
+
function generateHtml(sessionData, themeName) {
|
|
77
|
+
let templateDir = getExportTemplateDir(), template = readFileSync(join(templateDir, "template.html"), "utf-8"), templateCss = readFileSync(join(templateDir, "template.css"), "utf-8"), templateJs = readFileSync(join(templateDir, "template.js"), "utf-8"), markedJs = readFileSync(join(templateDir, "vendor", "marked.min.js"), "utf-8"), hljsJs = readFileSync(join(templateDir, "vendor", "highlight.min.js"), "utf-8"), themeVars = generateThemeVars(themeName), colors = getResolvedThemeColors(themeName), themeExport = getThemeExportColors(themeName), derivedExportColors = deriveExportColors(colors.userMessageBg || "#343541"), bodyBg = themeExport.pageBg ?? derivedExportColors.pageBg, containerBg = themeExport.cardBg ?? derivedExportColors.cardBg, infoBg = themeExport.infoBg ?? derivedExportColors.infoBg, sessionDataBase64 = Buffer.from(JSON.stringify(sessionData)).toString("base64"), css = templateCss.replace("{{THEME_VARS}}", themeVars).replace("{{BODY_BG}}", bodyBg).replace("{{CONTAINER_BG}}", containerBg).replace("{{INFO_BG}}", infoBg);
|
|
78
|
+
return template.replace("{{CSS}}", css).replace("{{JS}}", templateJs).replace("{{SESSION_DATA}}", sessionDataBase64).replace("{{MARKED_JS}}", markedJs).replace("{{HIGHLIGHT_JS}}", hljsJs);
|
|
79
|
+
}
|
|
80
|
+
var TEMPLATE_RENDERED_TOOLS = /* @__PURE__ */ new Set(["bash", "read", "write", "edit", "ls"]);
|
|
81
|
+
function preRenderCustomTools(entries, toolRenderer) {
|
|
82
|
+
let renderedTools = {};
|
|
83
|
+
for (let entry of entries) {
|
|
84
|
+
if (entry.type !== "message")
|
|
85
|
+
continue;
|
|
86
|
+
let msg = entry.message;
|
|
87
|
+
if (msg.role === "assistant" && Array.isArray(msg.content)) {
|
|
88
|
+
for (let block of msg.content)
|
|
89
|
+
if (block.type === "toolCall" && !TEMPLATE_RENDERED_TOOLS.has(block.name)) {
|
|
90
|
+
let callHtml = toolRenderer.renderCall(block.id, block.name, block.arguments);
|
|
91
|
+
callHtml && (renderedTools[block.id] = { callHtml });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (msg.role === "toolResult" && msg.toolCallId) {
|
|
95
|
+
let toolName = msg.toolName || "", existing = renderedTools[msg.toolCallId];
|
|
96
|
+
if (existing || !TEMPLATE_RENDERED_TOOLS.has(toolName)) {
|
|
97
|
+
let rendered = toolRenderer.renderResult(msg.toolCallId, toolName, msg.content, msg.details, msg.isError || !1);
|
|
98
|
+
rendered && (renderedTools[msg.toolCallId] = {
|
|
99
|
+
...existing,
|
|
100
|
+
resultHtmlCollapsed: rendered.collapsed,
|
|
101
|
+
resultHtmlExpanded: rendered.expanded
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return renderedTools;
|
|
107
|
+
}
|
|
108
|
+
async function exportSessionToHtml(sm, state, options) {
|
|
109
|
+
let opts = typeof options == "string" ? { outputPath: options } : options || {}, sessionFile = sm.getSessionFile();
|
|
110
|
+
if (!sessionFile)
|
|
111
|
+
throw new Error("Cannot export in-memory session to HTML");
|
|
112
|
+
if (!existsSync(sessionFile))
|
|
113
|
+
throw new Error("Nothing to export yet - start a conversation first");
|
|
114
|
+
let entries = sm.getEntries(), renderedTools;
|
|
115
|
+
opts.toolRenderer && (renderedTools = preRenderCustomTools(entries, opts.toolRenderer), Object.keys(renderedTools).length === 0 && (renderedTools = void 0));
|
|
116
|
+
let sessionData = {
|
|
117
|
+
header: sm.getHeader(),
|
|
118
|
+
entries,
|
|
119
|
+
leafId: sm.getLeafId(),
|
|
120
|
+
systemPrompt: state?.systemPrompt,
|
|
121
|
+
tools: state?.tools?.map((t) => ({ name: t.name, description: t.description, parameters: t.parameters })),
|
|
122
|
+
renderedTools
|
|
123
|
+
}, html = generateHtml(sessionData, opts.themeName), outputPath = opts.outputPath ? normalizePath(opts.outputPath) : void 0;
|
|
124
|
+
if (!outputPath) {
|
|
125
|
+
let sessionBasename = basename(sessionFile, ".jsonl");
|
|
126
|
+
outputPath = `${APP_NAME}-session-${sessionBasename}.html`;
|
|
127
|
+
}
|
|
128
|
+
return writeFileSync(outputPath, html, "utf8"), outputPath;
|
|
129
|
+
}
|
|
130
|
+
async function exportFromFile(inputPath, options) {
|
|
131
|
+
let opts = typeof options == "string" ? { outputPath: options } : options || {}, resolvedInputPath = resolvePath(inputPath);
|
|
132
|
+
if (!existsSync(resolvedInputPath))
|
|
133
|
+
throw new Error(`File not found: ${resolvedInputPath}`);
|
|
134
|
+
let sm = SessionManager.open(resolvedInputPath), sessionData = {
|
|
135
|
+
header: sm.getHeader(),
|
|
136
|
+
entries: sm.getEntries(),
|
|
137
|
+
leafId: sm.getLeafId(),
|
|
138
|
+
systemPrompt: void 0,
|
|
139
|
+
tools: void 0
|
|
140
|
+
}, html = generateHtml(sessionData, opts.themeName), outputPath = opts.outputPath ? normalizePath(opts.outputPath) : void 0;
|
|
141
|
+
if (!outputPath) {
|
|
142
|
+
let inputBasename = basename(resolvedInputPath, ".jsonl");
|
|
143
|
+
outputPath = `${APP_NAME}-session-${inputBasename}.html`;
|
|
144
|
+
}
|
|
145
|
+
return writeFileSync(outputPath, html, "utf8"), outputPath;
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
exportFromFile,
|
|
149
|
+
exportSessionToHtml
|
|
150
|
+
};
|