@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,807 @@
|
|
|
1
|
+
import { createRequire as __lunrRequire } from "node:module"; const require = __lunrRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
CONFIG_DIR_NAME,
|
|
4
|
+
getAgentDir
|
|
5
|
+
} from "./chunk-PCIGF2XK.js";
|
|
6
|
+
|
|
7
|
+
// packages/coding-agent/dist/core/usage-adapters/shared.js
|
|
8
|
+
async function fetchWithTimeout(url, init, timeoutMs = 1e4) {
|
|
9
|
+
let controller = new AbortController(), timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
10
|
+
try {
|
|
11
|
+
return await fetch(url, { ...init, signal: controller.signal });
|
|
12
|
+
} finally {
|
|
13
|
+
clearTimeout(timeout);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function asObject(value) {
|
|
17
|
+
if (!(!value || typeof value != "object" || Array.isArray(value)))
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
function asString(value) {
|
|
21
|
+
return typeof value == "string" && value.trim() ? value : void 0;
|
|
22
|
+
}
|
|
23
|
+
function asNumber(value) {
|
|
24
|
+
if (typeof value == "number" && Number.isFinite(value))
|
|
25
|
+
return value;
|
|
26
|
+
if (typeof value == "string" && value.trim()) {
|
|
27
|
+
let parsed = Number(value);
|
|
28
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function clampPercent(value) {
|
|
32
|
+
return Math.max(0, Math.min(100, value));
|
|
33
|
+
}
|
|
34
|
+
function toEpochMs(value) {
|
|
35
|
+
let asNumberValue = asNumber(value);
|
|
36
|
+
if (asNumberValue !== void 0)
|
|
37
|
+
return asNumberValue < 1e12 ? Math.round(asNumberValue * 1e3) : Math.round(asNumberValue);
|
|
38
|
+
let asStringValue = asString(value);
|
|
39
|
+
if (asStringValue) {
|
|
40
|
+
let parsed = Date.parse(asStringValue);
|
|
41
|
+
if (Number.isFinite(parsed))
|
|
42
|
+
return parsed;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function unwrapVal(value) {
|
|
46
|
+
let object = asObject(value);
|
|
47
|
+
return object && "val" in object ? asNumber(object.val) : asNumber(value);
|
|
48
|
+
}
|
|
49
|
+
function usedPercentFromRemaining(limit, remaining) {
|
|
50
|
+
let total = asNumber(limit), left = asNumber(remaining);
|
|
51
|
+
if (!(total === void 0 || left === void 0 || total <= 0))
|
|
52
|
+
return clampPercent(100 - left / total * 100);
|
|
53
|
+
}
|
|
54
|
+
function usedPercentFromUsed(total, used) {
|
|
55
|
+
let cap = asNumber(total), spent = asNumber(used);
|
|
56
|
+
if (!(cap === void 0 || spent === void 0 || cap <= 0))
|
|
57
|
+
return clampPercent(spent / cap * 100);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// packages/coding-agent/dist/core/usage-adapters/kimi-coding.js
|
|
61
|
+
var KIMI_PROVIDER_ID = "kimi-coding", KIMI_USAGE_URL = "https://api.kimi.com/coding/v1/usages", TIME_UNIT_SECONDS = {
|
|
62
|
+
seconds: 1,
|
|
63
|
+
second: 1,
|
|
64
|
+
minutes: 60,
|
|
65
|
+
minute: 60,
|
|
66
|
+
hours: 3600,
|
|
67
|
+
hour: 3600,
|
|
68
|
+
days: 86400,
|
|
69
|
+
day: 86400,
|
|
70
|
+
weeks: 604800,
|
|
71
|
+
week: 604800
|
|
72
|
+
};
|
|
73
|
+
function durationLabel(duration, timeUnit) {
|
|
74
|
+
let amount = asNumber(duration), unit = typeof timeUnit == "string" ? timeUnit.toLowerCase() : void 0, seconds = amount !== void 0 && unit ? TIME_UNIT_SECONDS[unit] : void 0;
|
|
75
|
+
if (amount === void 0 || seconds === void 0)
|
|
76
|
+
return "Limit";
|
|
77
|
+
let totalSeconds = amount * seconds;
|
|
78
|
+
return totalSeconds >= 604800 ? "Weekly" : totalSeconds >= 86400 ? `${Math.round(totalSeconds / 86400)}d` : totalSeconds >= 3600 ? `${Math.round(totalSeconds / 3600)}h` : `${Math.max(1, Math.round(totalSeconds / 60))}m`;
|
|
79
|
+
}
|
|
80
|
+
function detailWindow(label, detail) {
|
|
81
|
+
let object = asObject(detail);
|
|
82
|
+
if (!object)
|
|
83
|
+
return;
|
|
84
|
+
let usedPercent = usedPercentFromRemaining(object.limit, object.remaining);
|
|
85
|
+
if (usedPercent !== void 0)
|
|
86
|
+
return { label, usedPercent, resetsAt: toEpochMs(object.resetTime) };
|
|
87
|
+
}
|
|
88
|
+
async function fetchKimiPlanUsage(runtime) {
|
|
89
|
+
let apiKey = (await runtime.getAuth(KIMI_PROVIDER_ID))?.auth.apiKey;
|
|
90
|
+
if (!apiKey)
|
|
91
|
+
return;
|
|
92
|
+
let response = await fetchWithTimeout(KIMI_USAGE_URL, {
|
|
93
|
+
headers: { Authorization: `Bearer ${apiKey}`, Accept: "application/json" }
|
|
94
|
+
});
|
|
95
|
+
if (!response.ok)
|
|
96
|
+
return;
|
|
97
|
+
let payload = asObject(await response.json());
|
|
98
|
+
if (!payload)
|
|
99
|
+
return;
|
|
100
|
+
let windows = [], weekly = detailWindow("Weekly", payload.usage);
|
|
101
|
+
weekly && windows.push(weekly);
|
|
102
|
+
let limits = Array.isArray(payload.limits) ? payload.limits : [];
|
|
103
|
+
for (let item of limits) {
|
|
104
|
+
let limit = asObject(item);
|
|
105
|
+
if (!limit)
|
|
106
|
+
continue;
|
|
107
|
+
let window = detailWindow(durationLabel(asObject(limit.window)?.duration, asObject(limit.window)?.timeUnit), limit.detail);
|
|
108
|
+
window && windows.push(window);
|
|
109
|
+
}
|
|
110
|
+
if (windows.length !== 0)
|
|
111
|
+
return { provider: KIMI_PROVIDER_ID, windows };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// packages/coding-agent/dist/core/usage-adapters/openai-codex.js
|
|
115
|
+
var CODEX_PROVIDER_ID = "openai-codex", CODEX_USAGE_URL = "https://chatgpt.com/backend-api/wham/usage", MAX_ERROR_BODY_CHARS = 600;
|
|
116
|
+
function normalizeBackendPayload(payload) {
|
|
117
|
+
let snapshots = [], planType = asString(payload.plan_type), primary = normalizeBackendSnapshot("codex", void 0, payload.rate_limit, payload.credits);
|
|
118
|
+
primary && snapshots.push(primary);
|
|
119
|
+
let additional = Array.isArray(payload.additional_rate_limits) ? payload.additional_rate_limits : [];
|
|
120
|
+
for (let item of additional) {
|
|
121
|
+
let additionalLimit = asObject(item);
|
|
122
|
+
if (!additionalLimit)
|
|
123
|
+
continue;
|
|
124
|
+
let limitId = asString(additionalLimit.metered_feature) ?? asString(additionalLimit.limit_name);
|
|
125
|
+
if (limitId)
|
|
126
|
+
try {
|
|
127
|
+
let snapshot = normalizeBackendSnapshot(limitId, asString(additionalLimit.limit_name), additionalLimit.rate_limit, void 0);
|
|
128
|
+
snapshot && snapshots.push(snapshot);
|
|
129
|
+
} catch {
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (snapshots.length === 0)
|
|
133
|
+
throw new Error("Codex usage endpoint returned no displayable usage data.");
|
|
134
|
+
return { planType, snapshots };
|
|
135
|
+
}
|
|
136
|
+
function normalizeBackendSnapshot(limitId, limitName, rateLimit, credits) {
|
|
137
|
+
if (rateLimit == null)
|
|
138
|
+
return normalizeBackendCredits(credits) ? { limitId, limitName } : void 0;
|
|
139
|
+
let details = asObject(rateLimit);
|
|
140
|
+
if (!details)
|
|
141
|
+
throw new Error("rate limit was not an object.");
|
|
142
|
+
let primary = normalizeBackendWindow(details.primary_window), secondary = normalizeBackendWindow(details.secondary_window);
|
|
143
|
+
if (!(!primary && !secondary && !normalizeBackendCredits(credits)))
|
|
144
|
+
return { limitId, limitName, primary, secondary };
|
|
145
|
+
}
|
|
146
|
+
function normalizeBackendWindow(value) {
|
|
147
|
+
if (value == null)
|
|
148
|
+
return;
|
|
149
|
+
let window = asObject(value);
|
|
150
|
+
if (!window)
|
|
151
|
+
throw new Error("rate-limit window was not an object.");
|
|
152
|
+
let usedPercent = asNumber(window.used_percent);
|
|
153
|
+
if (usedPercent === void 0)
|
|
154
|
+
return;
|
|
155
|
+
let limitSeconds = asNumber(window.limit_window_seconds);
|
|
156
|
+
return {
|
|
157
|
+
usedPercent,
|
|
158
|
+
windowMinutes: limitSeconds && limitSeconds > 0 ? Math.ceil(limitSeconds / 60) : void 0,
|
|
159
|
+
resetsAt: toEpochMs(window.reset_at)
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function normalizeBackendCredits(value) {
|
|
163
|
+
let credits = asObject(value);
|
|
164
|
+
return credits ? credits.has_credits !== void 0 && credits.unlimited !== void 0 : !1;
|
|
165
|
+
}
|
|
166
|
+
async function resolveCodexHeaders(runtime) {
|
|
167
|
+
let candidates = [], seen = /* @__PURE__ */ new Set(), add = (model) => {
|
|
168
|
+
if (!model || model.provider !== CODEX_PROVIDER_ID)
|
|
169
|
+
return;
|
|
170
|
+
let key = `${model.provider}/${model.id}`;
|
|
171
|
+
seen.has(key) || (seen.add(key), candidates.push(model));
|
|
172
|
+
};
|
|
173
|
+
for (let model of runtime.getAvailableSnapshot())
|
|
174
|
+
add(model);
|
|
175
|
+
for (let model of runtime.getModels())
|
|
176
|
+
add(model);
|
|
177
|
+
for (let model of candidates) {
|
|
178
|
+
let resolution;
|
|
179
|
+
try {
|
|
180
|
+
resolution = await runtime.getAuth(model);
|
|
181
|
+
} catch {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (!resolution)
|
|
185
|
+
continue;
|
|
186
|
+
let headers = {};
|
|
187
|
+
for (let [name, value] of Object.entries(resolution.auth.headers ?? {}))
|
|
188
|
+
value != null && (headers[name] = String(value));
|
|
189
|
+
if (!hasHeader(headers, "Authorization") && resolution.auth.apiKey && (headers.Authorization = `Bearer ${resolution.auth.apiKey}`), hasHeader(headers, "User-Agent") || (headers["User-Agent"] = "lunr-usage-service"), hasHeader(headers, "Authorization"))
|
|
190
|
+
return headers;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function hasHeader(headers, name) {
|
|
194
|
+
return Object.keys(headers).some((key) => key.toLowerCase() === name.toLowerCase());
|
|
195
|
+
}
|
|
196
|
+
function redactErrorBody(body) {
|
|
197
|
+
let redacted = body.replace(/Bearer\s+[A-Za-z0-9._~+/=-]+/gi, "Bearer <redacted>").replace(/"access_token"\s*:\s*"[^"]+"/gi, '"access_token":"<redacted>"').trim();
|
|
198
|
+
return redacted.length > MAX_ERROR_BODY_CHARS ? `${redacted.slice(0, MAX_ERROR_BODY_CHARS - 1)}\u2026` : redacted;
|
|
199
|
+
}
|
|
200
|
+
function windowLabel(window, fallback) {
|
|
201
|
+
let minutes = window.windowMinutes;
|
|
202
|
+
return minutes === void 0 ? fallback ?? "Limit" : minutes >= 10080 ? "Weekly" : minutes >= 1440 ? `${Math.round(minutes / 1440)}d` : minutes >= 60 ? `${Math.round(minutes / 60)}h` : `${minutes}m`;
|
|
203
|
+
}
|
|
204
|
+
function toPlanUsage(report) {
|
|
205
|
+
return report.snapshots.flatMap((snapshot, index) => {
|
|
206
|
+
let windows = [];
|
|
207
|
+
for (let window of [snapshot.secondary, snapshot.primary])
|
|
208
|
+
window && windows.push({
|
|
209
|
+
label: windowLabel(window, snapshot.limitName),
|
|
210
|
+
usedPercent: window.usedPercent,
|
|
211
|
+
resetsAt: window.resetsAt
|
|
212
|
+
});
|
|
213
|
+
return windows.length === 0 ? [] : [
|
|
214
|
+
{
|
|
215
|
+
provider: CODEX_PROVIDER_ID,
|
|
216
|
+
planLabel: index === 0 ? report.planType : snapshot.limitName ?? snapshot.limitId,
|
|
217
|
+
windows
|
|
218
|
+
}
|
|
219
|
+
];
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
async function fetchCodexPlanUsage(runtime) {
|
|
223
|
+
let headers = await resolveCodexHeaders(runtime);
|
|
224
|
+
if (!headers)
|
|
225
|
+
return;
|
|
226
|
+
let response = await fetchWithTimeout(CODEX_USAGE_URL, { headers }), text = await response.text();
|
|
227
|
+
if (!response.ok)
|
|
228
|
+
throw new Error(`Codex usage endpoint returned ${response.status}: ${redactErrorBody(text)}`);
|
|
229
|
+
let payload = asObject(JSON.parse(text));
|
|
230
|
+
if (payload)
|
|
231
|
+
return toPlanUsage(normalizeBackendPayload(payload));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// packages/coding-agent/dist/core/usage-adapters/xai.js
|
|
235
|
+
import { ModelsError } from "@ashx-j/lunr-ai";
|
|
236
|
+
var XAI_PROVIDER_ID = "xai", XAI_BILLING_URL = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
|
|
237
|
+
function currentPeriod(config) {
|
|
238
|
+
return asObject(config.currentPeriod) ?? asObject(config.current_period);
|
|
239
|
+
}
|
|
240
|
+
function weeklyWindow(config) {
|
|
241
|
+
let period = currentPeriod(config), raw = unwrapVal(config.creditUsagePercent ?? config.credit_usage_percent);
|
|
242
|
+
return raw === void 0 && !period ? void 0 : {
|
|
243
|
+
label: "Weekly",
|
|
244
|
+
usedPercent: raw === void 0 ? 0 : clampPercent(raw),
|
|
245
|
+
resetsAt: toEpochMs(period?.end)
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
async function fetchXaiPlanUsage(runtime) {
|
|
249
|
+
if (!runtime.isUsingOAuth(XAI_PROVIDER_ID))
|
|
250
|
+
return;
|
|
251
|
+
let accessToken = (await runtime.getAuth(XAI_PROVIDER_ID))?.auth.apiKey;
|
|
252
|
+
if (!accessToken)
|
|
253
|
+
return;
|
|
254
|
+
let response = await fetchWithTimeout(XAI_BILLING_URL, {
|
|
255
|
+
headers: {
|
|
256
|
+
Authorization: `Bearer ${accessToken}`,
|
|
257
|
+
Accept: "application/json",
|
|
258
|
+
"x-xai-token-auth": "xai-grok-cli"
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
if (response.status === 401 || response.status === 403)
|
|
262
|
+
throw new ModelsError("oauth", `xAI billing rejected the session (HTTP ${response.status})`);
|
|
263
|
+
if (!response.ok)
|
|
264
|
+
return;
|
|
265
|
+
let payload = asObject(await response.json());
|
|
266
|
+
if (!payload)
|
|
267
|
+
return;
|
|
268
|
+
let config = asObject(payload.config) ?? payload, windows = [], weekly = weeklyWindow(config);
|
|
269
|
+
weekly && windows.push(weekly);
|
|
270
|
+
let onDemandCap = unwrapVal(config.onDemandCap);
|
|
271
|
+
if (onDemandCap !== void 0 && onDemandCap > 0) {
|
|
272
|
+
let usedPercent = usedPercentFromUsed(onDemandCap, unwrapVal(config.onDemandUsed) ?? 0);
|
|
273
|
+
usedPercent !== void 0 && windows.push({
|
|
274
|
+
label: "Extra",
|
|
275
|
+
usedPercent,
|
|
276
|
+
resetsAt: weekly?.resetsAt
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
if (windows.length === 0)
|
|
280
|
+
return;
|
|
281
|
+
let planLabel = asString(config.subscriptionTier) ?? asString(config.subscription_tier);
|
|
282
|
+
return { provider: XAI_PROVIDER_ID, planLabel, windows };
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// packages/coding-agent/dist/core/usage-adapters/zai.js
|
|
286
|
+
var ZAI_PROVIDER_ID = "zai", ZAI_QUOTA_URL = "https://api.z.ai/api/monitor/usage/quota/limit";
|
|
287
|
+
function limitLabel(limit) {
|
|
288
|
+
let type = asString(limit.type);
|
|
289
|
+
if (type === "TIME_LIMIT")
|
|
290
|
+
return "Monthly";
|
|
291
|
+
if (type !== "TOKENS_LIMIT")
|
|
292
|
+
return;
|
|
293
|
+
let unit = asNumber(limit.unit), number = asNumber(limit.number);
|
|
294
|
+
return unit === 1 && number !== void 0 ? `${number}d` : unit === 3 && number !== void 0 ? `${number}h` : unit === 5 && number !== void 0 ? `${number}m` : unit === 6 ? "Weekly" : "Limit";
|
|
295
|
+
}
|
|
296
|
+
async function fetchZaiPlanUsage(runtime) {
|
|
297
|
+
let apiKey = (await runtime.getAuth(ZAI_PROVIDER_ID))?.auth.apiKey;
|
|
298
|
+
if (!apiKey)
|
|
299
|
+
return;
|
|
300
|
+
let response = await fetchWithTimeout(ZAI_QUOTA_URL, {
|
|
301
|
+
headers: {
|
|
302
|
+
Authorization: `Bearer ${apiKey}`,
|
|
303
|
+
Accept: "application/json",
|
|
304
|
+
"Accept-Language": "en-US,en"
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
if (!response.ok)
|
|
308
|
+
return;
|
|
309
|
+
let payload = asObject(await response.json());
|
|
310
|
+
if (!payload || payload.success !== !0 || asNumber(payload.code) !== 200)
|
|
311
|
+
return;
|
|
312
|
+
let data = asObject(payload.data), limits = Array.isArray(data?.limits) ? data.limits : [], windows = [];
|
|
313
|
+
for (let item of limits) {
|
|
314
|
+
let limit = asObject(item);
|
|
315
|
+
if (!limit)
|
|
316
|
+
continue;
|
|
317
|
+
let label = limitLabel(limit), percentage = asNumber(limit.percentage);
|
|
318
|
+
!label || percentage === void 0 || windows.push({ label, usedPercent: clampPercent(percentage), resetsAt: toEpochMs(limit.nextResetTime) });
|
|
319
|
+
}
|
|
320
|
+
if (windows.length === 0)
|
|
321
|
+
return;
|
|
322
|
+
let planLabel = asString(data?.planName) ?? asString(data?.plan) ?? asString(data?.level);
|
|
323
|
+
return { provider: ZAI_PROVIDER_ID, planLabel, windows };
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// packages/coding-agent/dist/core/usage-service.js
|
|
327
|
+
var XAI_RELOGIN = "xAI login expired. Run /login xai.";
|
|
328
|
+
function errorChain(error) {
|
|
329
|
+
let parts = [], current = error, seen = /* @__PURE__ */ new Set();
|
|
330
|
+
for (; current && typeof current == "object" && !seen.has(current); ) {
|
|
331
|
+
if (seen.add(current), current instanceof Error) {
|
|
332
|
+
parts.push(current.message), current = current.cause;
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
return parts.join(" ");
|
|
338
|
+
}
|
|
339
|
+
function planUsageAuthError(error) {
|
|
340
|
+
let chain = errorChain(error);
|
|
341
|
+
if (!/timed out|aborted|cancelled|ECONN|ENOTFOUND|network/i.test(chain) && (/xai billing rejected the session \(HTTP 401\)/i.test(chain) || /invalid_grant|refresh token revoked/i.test(chain)))
|
|
342
|
+
return XAI_RELOGIN;
|
|
343
|
+
}
|
|
344
|
+
var ADAPTERS = {
|
|
345
|
+
"openai-codex": fetchCodexPlanUsage,
|
|
346
|
+
"kimi-coding": fetchKimiPlanUsage,
|
|
347
|
+
zai: fetchZaiPlanUsage,
|
|
348
|
+
xai: fetchXaiPlanUsage
|
|
349
|
+
}, PLAN_USAGE_CACHE_TTL_MS = 60 * 1e3;
|
|
350
|
+
function isWeeklyPlanWindow(window) {
|
|
351
|
+
return /week/i.test(window.label);
|
|
352
|
+
}
|
|
353
|
+
function isFiveHourPlanWindow(window) {
|
|
354
|
+
return /5h/i.test(window.label) || window.label === "5h";
|
|
355
|
+
}
|
|
356
|
+
function pickPlanWindow(usage, preferred) {
|
|
357
|
+
if (!usage?.windows.length)
|
|
358
|
+
return;
|
|
359
|
+
let usable = usage.windows.filter((w) => !/extra/i.test(w.label)), weekly = usable.find(isWeeklyPlanWindow), fiveH = usable.find(isFiveHourPlanWindow);
|
|
360
|
+
return preferred === "5h" ? fiveH ?? weekly ?? usable[0] ?? usage.windows[0] : weekly ?? fiveH ?? usable[0] ?? usage.windows[0];
|
|
361
|
+
}
|
|
362
|
+
function footerPlanLabel(window) {
|
|
363
|
+
return isFiveHourPlanWindow(window) ? "5h" : isWeeklyPlanWindow(window) ? "wk" : window.label.length <= 4 ? window.label : window.label.slice(0, 4);
|
|
364
|
+
}
|
|
365
|
+
var cache = /* @__PURE__ */ new Map(), inflight = /* @__PURE__ */ new Map();
|
|
366
|
+
function hasPlanUsageAdapter(providerId) {
|
|
367
|
+
return providerId in ADAPTERS;
|
|
368
|
+
}
|
|
369
|
+
async function getPlanUsage(providerId, runtime) {
|
|
370
|
+
return (await getPlanUsageResult(providerId, runtime)).usage;
|
|
371
|
+
}
|
|
372
|
+
async function getPlanUsageResult(providerId, runtime) {
|
|
373
|
+
let adapter = ADAPTERS[providerId];
|
|
374
|
+
if (!adapter)
|
|
375
|
+
return {};
|
|
376
|
+
let now = Date.now(), cached = cache.get(providerId);
|
|
377
|
+
if (cached && cached.expiresAt > now)
|
|
378
|
+
return { usage: cached.value[0], usages: cached.value };
|
|
379
|
+
let pending = inflight.get(providerId);
|
|
380
|
+
if (pending)
|
|
381
|
+
return pending;
|
|
382
|
+
let task = (async () => {
|
|
383
|
+
try {
|
|
384
|
+
let value = await adapter(runtime), usages = value === void 0 ? [] : Array.isArray(value) ? value : [value];
|
|
385
|
+
return cache.set(providerId, { expiresAt: Date.now() + PLAN_USAGE_CACHE_TTL_MS, value: usages }), { usage: usages[0], usages };
|
|
386
|
+
} catch (error) {
|
|
387
|
+
let authError = planUsageAuthError(error);
|
|
388
|
+
return authError ? { error: authError } : (cache.set(providerId, { expiresAt: Date.now() + PLAN_USAGE_CACHE_TTL_MS, value: [] }), {});
|
|
389
|
+
} finally {
|
|
390
|
+
inflight.delete(providerId);
|
|
391
|
+
}
|
|
392
|
+
})();
|
|
393
|
+
return inflight.set(providerId, task), task;
|
|
394
|
+
}
|
|
395
|
+
async function getAllPlanUsageResults(currentProvider, runtime) {
|
|
396
|
+
let stored = new Set((await runtime.listCredentials()).map((credential) => credential.providerId)), providers = Object.keys(ADAPTERS).filter((providerId) => stored.has(providerId) || providerId === currentProvider), results = await Promise.all(providers.map((providerId) => getPlanUsageResult(providerId, runtime)));
|
|
397
|
+
return {
|
|
398
|
+
usages: results.flatMap((result) => result.usages ?? []),
|
|
399
|
+
errors: results.flatMap((result) => result.error ? [`${result.error}`] : [])
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
function peekPlanUsage(providerId) {
|
|
403
|
+
return cache.get(providerId)?.value[0];
|
|
404
|
+
}
|
|
405
|
+
function clearPlanUsageCache() {
|
|
406
|
+
cache.clear(), inflight.clear();
|
|
407
|
+
}
|
|
408
|
+
var USAGE_SERVICE_BRIDGE_SYMBOL = /* @__PURE__ */ Symbol.for("@lunr/usage-service"), activeRuntime, activeUsageSettings, onUsageUpdate;
|
|
409
|
+
function preferredWindow() {
|
|
410
|
+
return activeUsageSettings?.getPlanUsageWindow() ?? "weekly";
|
|
411
|
+
}
|
|
412
|
+
var usageBridge = {
|
|
413
|
+
peek(providerId) {
|
|
414
|
+
return peekPlanUsage(providerId);
|
|
415
|
+
},
|
|
416
|
+
prefetch(providerId) {
|
|
417
|
+
!activeRuntime || !hasPlanUsageAdapter(providerId) || getPlanUsage(providerId, activeRuntime).then(() => onUsageUpdate?.());
|
|
418
|
+
},
|
|
419
|
+
setOnUpdate(fn) {
|
|
420
|
+
onUsageUpdate = fn;
|
|
421
|
+
},
|
|
422
|
+
getPreferredWindow() {
|
|
423
|
+
return preferredWindow();
|
|
424
|
+
},
|
|
425
|
+
pickForFooter(providerId) {
|
|
426
|
+
let window = pickPlanWindow(peekPlanUsage(providerId), preferredWindow());
|
|
427
|
+
if (window)
|
|
428
|
+
return { label: footerPlanLabel(window), usedPercent: window.usedPercent };
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
function registerUsageServiceBridge(runtime, settingsManager) {
|
|
432
|
+
activeRuntime = runtime, activeUsageSettings = settingsManager, globalThis[USAGE_SERVICE_BRIDGE_SYMBOL] = usageBridge;
|
|
433
|
+
}
|
|
434
|
+
function getUsageServiceBridge() {
|
|
435
|
+
return globalThis[USAGE_SERVICE_BRIDGE_SYMBOL];
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// packages/coding-agent/dist/core/rollback.js
|
|
439
|
+
import { spawnSync } from "node:child_process";
|
|
440
|
+
import { createHash } from "node:crypto";
|
|
441
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
|
|
442
|
+
import { homedir } from "node:os";
|
|
443
|
+
import { dirname, join, normalize, resolve } from "node:path";
|
|
444
|
+
var ROLLBACK_BASE = join(homedir(), ".lunr", "rollback"), contexts = /* @__PURE__ */ new Map(), lastSessionId, globalSettingsManager, warningHandler;
|
|
445
|
+
function setRollbackWarningHandler(handler) {
|
|
446
|
+
warningHandler = handler;
|
|
447
|
+
}
|
|
448
|
+
function createContext(sessionId) {
|
|
449
|
+
return {
|
|
450
|
+
sessionId,
|
|
451
|
+
settingsManager: globalSettingsManager,
|
|
452
|
+
sessionForceEnabled: !1,
|
|
453
|
+
turns: [],
|
|
454
|
+
currentTurnIndex: -1,
|
|
455
|
+
repoWarningShown: !1,
|
|
456
|
+
externalModWarningShown: !1
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
function getContext(sessionId) {
|
|
460
|
+
let sid = sessionId ?? lastSessionId ?? "default", ctx = contexts.get(sid);
|
|
461
|
+
return ctx || (ctx = createContext(sid), contexts.set(sid, ctx)), ctx;
|
|
462
|
+
}
|
|
463
|
+
function initRollback(sm, sid) {
|
|
464
|
+
globalSettingsManager = sm, lastSessionId = sid, contexts.set(sid, createContext(sid));
|
|
465
|
+
let ctx = contexts.get(sid);
|
|
466
|
+
ctx.settingsManager = sm, loadPersistedTurns(ctx);
|
|
467
|
+
}
|
|
468
|
+
function isRollbackEnabled(sessionId) {
|
|
469
|
+
let ctx = getContext(sessionId);
|
|
470
|
+
return (ctx.settingsManager?.getRollbackEnabled() ?? !1) || ctx.sessionForceEnabled;
|
|
471
|
+
}
|
|
472
|
+
function isRollbackSessionForceEnabled(sessionId) {
|
|
473
|
+
return getContext(sessionId).sessionForceEnabled;
|
|
474
|
+
}
|
|
475
|
+
function enableRollbackForSession(sessionId) {
|
|
476
|
+
getContext(sessionId).sessionForceEnabled = !0;
|
|
477
|
+
}
|
|
478
|
+
function disableRollbackForSession(sessionId) {
|
|
479
|
+
getContext(sessionId).sessionForceEnabled = !1;
|
|
480
|
+
}
|
|
481
|
+
function pruneTurns(ctx) {
|
|
482
|
+
let maxTurns = ctx.settingsManager?.getRollbackTurns() ?? 2;
|
|
483
|
+
for (; ctx.turns.length > maxTurns; ) {
|
|
484
|
+
let old = ctx.turns.shift();
|
|
485
|
+
old && cleanupTurnFiles(ctx, old);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
function beginTurn(cwd, sessionId) {
|
|
489
|
+
let ctx = getContext(sessionId);
|
|
490
|
+
if (!isRollbackEnabled(ctx.sessionId))
|
|
491
|
+
return;
|
|
492
|
+
cwd && (ctx.lastCwd = cwd), ctx.currentTurnIndex++;
|
|
493
|
+
let turn = { turnIndex: ctx.currentTurnIndex, cwd, files: /* @__PURE__ */ new Map() };
|
|
494
|
+
ctx.turns.push(turn), pruneTurns(ctx), cwd && ctx.settingsManager?.getRollbackScope() === "tree" && captureTreeBaseline(ctx, cwd);
|
|
495
|
+
}
|
|
496
|
+
function rollbackSnapshotBeforeWrite(absPath, sessionId) {
|
|
497
|
+
let ctx = getContext(sessionId);
|
|
498
|
+
if (!isRollbackEnabled(ctx.sessionId))
|
|
499
|
+
return;
|
|
500
|
+
(ctx.currentTurnIndex < 0 || ctx.turns.length === 0) && beginTurn(ctx.lastCwd, ctx.sessionId);
|
|
501
|
+
let turn = ctx.turns[ctx.turns.length - 1];
|
|
502
|
+
if (turn && !turn.files.has(absPath))
|
|
503
|
+
try {
|
|
504
|
+
let existed = existsSync(absPath), content;
|
|
505
|
+
existed && (content = readFileSync(absPath)), turn.files.set(absPath, {
|
|
506
|
+
existed,
|
|
507
|
+
content,
|
|
508
|
+
createdByTool: !0
|
|
509
|
+
}), persistSnapshot(ctx, turn, absPath);
|
|
510
|
+
} catch {
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
function captureTreeBaseline(ctx, cwd) {
|
|
514
|
+
let turn = ctx.turns[ctx.turns.length - 1];
|
|
515
|
+
if (!turn)
|
|
516
|
+
return;
|
|
517
|
+
let entries = gitPorcelain(ctx, cwd);
|
|
518
|
+
if (entries)
|
|
519
|
+
for (let { path } of entries) {
|
|
520
|
+
if (!path)
|
|
521
|
+
continue;
|
|
522
|
+
let abs = join(cwd, path);
|
|
523
|
+
if (!turn.files.has(abs))
|
|
524
|
+
try {
|
|
525
|
+
let existed = existsSync(abs);
|
|
526
|
+
turn.files.set(abs, {
|
|
527
|
+
existed,
|
|
528
|
+
content: existed ? readFileSync(abs) : void 0,
|
|
529
|
+
createdByTool: !1
|
|
530
|
+
}), persistSnapshot(ctx, turn, abs);
|
|
531
|
+
} catch {
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
function captureTreeChanges(cwd, sessionId) {
|
|
536
|
+
let ctx = getContext(sessionId);
|
|
537
|
+
if (!isRollbackEnabled(ctx.sessionId) || ctx.settingsManager?.getRollbackScope() !== "tree" || ctx.currentTurnIndex < 0 || ctx.turns.length === 0)
|
|
538
|
+
return;
|
|
539
|
+
let turn = ctx.turns[ctx.turns.length - 1];
|
|
540
|
+
if (!turn)
|
|
541
|
+
return;
|
|
542
|
+
let entries = gitPorcelain(ctx, cwd);
|
|
543
|
+
if (entries)
|
|
544
|
+
for (let { status, path, source } of entries) {
|
|
545
|
+
if (!path)
|
|
546
|
+
continue;
|
|
547
|
+
let abs = join(cwd, path);
|
|
548
|
+
if (!turn.files.has(abs))
|
|
549
|
+
try {
|
|
550
|
+
if (status === "??" || status.includes("R")) {
|
|
551
|
+
if (turn.files.set(abs, { existed: !1, createdByTool: !1 }), persistSnapshot(ctx, turn, abs), status.includes("R") && source) {
|
|
552
|
+
let sourceAbs = join(cwd, source);
|
|
553
|
+
if (!turn.files.has(sourceAbs)) {
|
|
554
|
+
let headSrc = spawnSync("git", ["show", `HEAD:${source}`], {
|
|
555
|
+
cwd,
|
|
556
|
+
timeout: 5e3,
|
|
557
|
+
maxBuffer: 33554432
|
|
558
|
+
});
|
|
559
|
+
!headSrc.error && headSrc.status === 0 && headSrc.stdout && (turn.files.set(sourceAbs, {
|
|
560
|
+
existed: !0,
|
|
561
|
+
content: headSrc.stdout,
|
|
562
|
+
createdByTool: !1
|
|
563
|
+
}), persistSnapshot(ctx, turn, sourceAbs));
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
} else {
|
|
567
|
+
let head = spawnSync("git", ["show", `HEAD:${path}`], {
|
|
568
|
+
cwd,
|
|
569
|
+
timeout: 5e3,
|
|
570
|
+
maxBuffer: 33554432
|
|
571
|
+
});
|
|
572
|
+
if (head.error || head.status !== 0 || !head.stdout)
|
|
573
|
+
continue;
|
|
574
|
+
turn.files.set(abs, {
|
|
575
|
+
existed: !0,
|
|
576
|
+
content: head.stdout,
|
|
577
|
+
createdByTool: !1
|
|
578
|
+
}), persistSnapshot(ctx, turn, abs);
|
|
579
|
+
}
|
|
580
|
+
} catch {
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
function gitPorcelain(ctx, cwd) {
|
|
585
|
+
try {
|
|
586
|
+
let result = spawnSync("git", ["status", "--porcelain", "-z"], { cwd, encoding: "utf8", timeout: 5e3 });
|
|
587
|
+
if (result.error || result.status !== 0) {
|
|
588
|
+
warnOnce(ctx, "Rollback tree scope: not a git repository (or git failed) \u2014 bash side-effects won't be captured.");
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
let fields = (result.stdout ?? "").split("\0").filter((f) => f.length > 0), entries = [];
|
|
592
|
+
for (let i = 0; i < fields.length; i++) {
|
|
593
|
+
let field = fields[i], status = field.slice(0, 2), path = field.slice(3), source;
|
|
594
|
+
(status.includes("R") || status.includes("C")) && (source = fields[i + 1], i++), entries.push({ status, path, source });
|
|
595
|
+
}
|
|
596
|
+
return entries;
|
|
597
|
+
} catch {
|
|
598
|
+
warnOnce(ctx, "Rollback tree scope: not a git repository (or git failed) \u2014 bash side-effects won't be captured.");
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
function warnOnce(ctx, message) {
|
|
603
|
+
if (!ctx.repoWarningShown) {
|
|
604
|
+
ctx.repoWarningShown = !0;
|
|
605
|
+
try {
|
|
606
|
+
warningHandler?.(message);
|
|
607
|
+
} catch {
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
function persistSnapshot(ctx, turn, absPath) {
|
|
612
|
+
try {
|
|
613
|
+
let snap = turn.files.get(absPath);
|
|
614
|
+
if (!snap)
|
|
615
|
+
return;
|
|
616
|
+
let turnDir = getTurnDir(ctx, turn.turnIndex);
|
|
617
|
+
mkdirSync(turnDir, { recursive: !0 });
|
|
618
|
+
let manifestPath = join(turnDir, "manifest.json"), manifest = readManifest(manifestPath), entry = { existed: snap.existed, createdByTool: snap.createdByTool };
|
|
619
|
+
if (snap.content) {
|
|
620
|
+
let snapFile = snapFileName(absPath);
|
|
621
|
+
writeFileSync(join(turnDir, snapFile), snap.content), entry.snapFile = snapFile;
|
|
622
|
+
}
|
|
623
|
+
manifest.files[absPath] = entry, turn.cwd && (manifest.cwd = turn.cwd), writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
|
624
|
+
} catch {
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
function readManifest(path) {
|
|
628
|
+
if (!existsSync(path))
|
|
629
|
+
return { files: {} };
|
|
630
|
+
try {
|
|
631
|
+
let parsed = JSON.parse(readFileSync(path, "utf-8"));
|
|
632
|
+
if (parsed && typeof parsed == "object" && !Array.isArray(parsed)) {
|
|
633
|
+
let files = parsed.files;
|
|
634
|
+
return {
|
|
635
|
+
cwd: typeof parsed.cwd == "string" ? parsed.cwd : void 0,
|
|
636
|
+
files: files && typeof files == "object" && !Array.isArray(files) ? files : {}
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
return { files: {} };
|
|
640
|
+
} catch {
|
|
641
|
+
return { files: {} };
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
function loadPersistedTurns(ctx) {
|
|
645
|
+
try {
|
|
646
|
+
let sessionDir = join(ROLLBACK_BASE, ctx.sessionId);
|
|
647
|
+
if (!existsSync(sessionDir))
|
|
648
|
+
return;
|
|
649
|
+
let loaded = [];
|
|
650
|
+
for (let dirName of readdirSync(sessionDir)) {
|
|
651
|
+
let match = /^turn-(\d+)$/.exec(dirName);
|
|
652
|
+
if (!match)
|
|
653
|
+
continue;
|
|
654
|
+
let turnIndex = Number(match[1]), turnDir = join(sessionDir, dirName), manifest = readManifest(join(turnDir, "manifest.json")), files = /* @__PURE__ */ new Map();
|
|
655
|
+
for (let [absPath, meta] of Object.entries(manifest.files)) {
|
|
656
|
+
let content;
|
|
657
|
+
if (meta.snapFile)
|
|
658
|
+
try {
|
|
659
|
+
content = readFileSync(join(turnDir, meta.snapFile));
|
|
660
|
+
} catch {
|
|
661
|
+
content = void 0;
|
|
662
|
+
}
|
|
663
|
+
files.set(absPath, { existed: meta.existed, content, createdByTool: meta.createdByTool });
|
|
664
|
+
}
|
|
665
|
+
loaded.push({ turnIndex, cwd: manifest.cwd, files });
|
|
666
|
+
}
|
|
667
|
+
loaded.sort((a, b) => a.turnIndex - b.turnIndex), ctx.turns = loaded, ctx.currentTurnIndex = loaded.length > 0 ? loaded[loaded.length - 1].turnIndex : -1, pruneTurns(ctx);
|
|
668
|
+
} catch {
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
function getTurnDir(ctx, turnIndex) {
|
|
672
|
+
return join(ROLLBACK_BASE, ctx.sessionId, `turn-${turnIndex}`);
|
|
673
|
+
}
|
|
674
|
+
function cleanupTurnFiles(ctx, turn) {
|
|
675
|
+
try {
|
|
676
|
+
let dir = getTurnDir(ctx, turn.turnIndex);
|
|
677
|
+
existsSync(dir) && rmSync(dir, { recursive: !0, force: !0 });
|
|
678
|
+
} catch {
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
function isPathUnderRoot(absPath, root) {
|
|
682
|
+
let normRoot = normalize(root).replace(/\\$/g, ""), normPath = normalize(absPath).replace(/\\$/g, "");
|
|
683
|
+
return process.platform === "win32" && (normRoot = normRoot.toLowerCase(), normPath = normPath.toLowerCase()), normPath === normRoot || normPath.startsWith(`${normRoot}/`) || normPath.startsWith(`${normRoot}\\`);
|
|
684
|
+
}
|
|
685
|
+
function isWithinAllowedRoots(absPath, turn) {
|
|
686
|
+
return turn.cwd ? [
|
|
687
|
+
ROLLBACK_BASE,
|
|
688
|
+
join(homedir(), CONFIG_DIR_NAME),
|
|
689
|
+
// lunr: agent settings / cron jobs.json live under the config dir
|
|
690
|
+
// lunr: simple-memory lives next to the lunr agent dir (~/.lunr/simple-memory)
|
|
691
|
+
join(dirname(getAgentDir()), "simple-memory"),
|
|
692
|
+
resolve(turn.cwd)
|
|
693
|
+
].some((root) => isPathUnderRoot(absPath, root)) : !0;
|
|
694
|
+
}
|
|
695
|
+
function warnExternalModification(ctx, message) {
|
|
696
|
+
if (!(ctx.externalModWarningShown || !warningHandler)) {
|
|
697
|
+
ctx.externalModWarningShown = !0;
|
|
698
|
+
try {
|
|
699
|
+
warningHandler(message);
|
|
700
|
+
} catch {
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
function peekRollbackTurnsConsumed(sessionId) {
|
|
705
|
+
let ctx = getContext(sessionId);
|
|
706
|
+
if (!isRollbackEnabled(ctx.sessionId) || ctx.turns.length === 0)
|
|
707
|
+
return 0;
|
|
708
|
+
let consumed = 0;
|
|
709
|
+
for (let i = ctx.turns.length - 1; i >= 0 && (consumed++, !(ctx.turns[i].files.size > 0)); i--)
|
|
710
|
+
;
|
|
711
|
+
return consumed;
|
|
712
|
+
}
|
|
713
|
+
function rollbackLastTurn(sessionId) {
|
|
714
|
+
let ctx = getContext(sessionId), empty = { restored: [], deleted: [], turnsConsumed: 0 };
|
|
715
|
+
if (!isRollbackEnabled(ctx.sessionId))
|
|
716
|
+
return empty;
|
|
717
|
+
let turnsConsumed = 0;
|
|
718
|
+
for (; ctx.turns.length > 0 && ctx.turns[ctx.turns.length - 1].files.size === 0; ) {
|
|
719
|
+
let skipped = ctx.turns.pop();
|
|
720
|
+
skipped && (cleanupTurnFiles(ctx, skipped), turnsConsumed++);
|
|
721
|
+
}
|
|
722
|
+
if (ctx.turns.length === 0)
|
|
723
|
+
return empty;
|
|
724
|
+
turnsConsumed++;
|
|
725
|
+
let turn = ctx.turns[ctx.turns.length - 1], capture = ctx.settingsManager?.getRollbackCapture() ?? "copies", restored = [], deleted = [];
|
|
726
|
+
for (let [absPath, snap] of turn.files)
|
|
727
|
+
try {
|
|
728
|
+
if (!isWithinAllowedRoots(absPath, turn)) {
|
|
729
|
+
warnExternalModification(ctx, `Rollback skipped ${absPath}: outside the session working directory or lunR config dir.`);
|
|
730
|
+
continue;
|
|
731
|
+
}
|
|
732
|
+
if (snap.existed && snap.content) {
|
|
733
|
+
if (!snap.createdByTool && existsSync(absPath) && readFileSync(absPath).equals(snap.content))
|
|
734
|
+
continue;
|
|
735
|
+
mkdirSync(dirname(absPath), { recursive: !0 }), writeFileSync(absPath, snap.content), restored.push(absPath);
|
|
736
|
+
} else snap.existed || (snap.createdByTool || capture === "hybrid" || capture === "shadow-git") && existsSync(absPath) && (unlinkSync(absPath), deleted.push(absPath));
|
|
737
|
+
} catch {
|
|
738
|
+
}
|
|
739
|
+
return cleanupTurnFiles(ctx, turn), ctx.turns.pop(), { restored, deleted, turnsConsumed };
|
|
740
|
+
}
|
|
741
|
+
function migrateRollbackSession(oldSessionId, newSessionId) {
|
|
742
|
+
if (oldSessionId === newSessionId)
|
|
743
|
+
return;
|
|
744
|
+
let ctx = contexts.get(oldSessionId);
|
|
745
|
+
ctx && (contexts.delete(oldSessionId), ctx.sessionId = newSessionId, contexts.set(newSessionId, ctx));
|
|
746
|
+
try {
|
|
747
|
+
let oldDir = join(ROLLBACK_BASE, oldSessionId), newDir = join(ROLLBACK_BASE, newSessionId);
|
|
748
|
+
if (existsSync(oldDir)) {
|
|
749
|
+
existsSync(newDir) && rmSync(newDir, { recursive: !0, force: !0 });
|
|
750
|
+
try {
|
|
751
|
+
renameSync(oldDir, newDir);
|
|
752
|
+
} catch {
|
|
753
|
+
cpSync(oldDir, newDir, { recursive: !0 }), rmSync(oldDir, { recursive: !0, force: !0 });
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
} catch {
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
function clearRollback(sessionId) {
|
|
760
|
+
if (sessionId === void 0) {
|
|
761
|
+
for (let ctx2 of contexts.values()) {
|
|
762
|
+
for (let turn of ctx2.turns)
|
|
763
|
+
cleanupTurnFiles(ctx2, turn);
|
|
764
|
+
try {
|
|
765
|
+
let sessionDir = join(ROLLBACK_BASE, ctx2.sessionId);
|
|
766
|
+
existsSync(sessionDir) && rmSync(sessionDir, { recursive: !0, force: !0 });
|
|
767
|
+
} catch {
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
contexts.clear();
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
let ctx = contexts.get(sessionId);
|
|
774
|
+
if (ctx) {
|
|
775
|
+
for (let turn of ctx.turns)
|
|
776
|
+
cleanupTurnFiles(ctx, turn);
|
|
777
|
+
try {
|
|
778
|
+
let sessionDir = join(ROLLBACK_BASE, sessionId);
|
|
779
|
+
existsSync(sessionDir) && rmSync(sessionDir, { recursive: !0, force: !0 });
|
|
780
|
+
} catch {
|
|
781
|
+
}
|
|
782
|
+
contexts.delete(sessionId);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
function snapFileName(absPath) {
|
|
786
|
+
return `${createHash("sha1").update(absPath).digest("hex")}.snap`;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
export {
|
|
790
|
+
getAllPlanUsageResults,
|
|
791
|
+
clearPlanUsageCache,
|
|
792
|
+
registerUsageServiceBridge,
|
|
793
|
+
getUsageServiceBridge,
|
|
794
|
+
setRollbackWarningHandler,
|
|
795
|
+
initRollback,
|
|
796
|
+
isRollbackEnabled,
|
|
797
|
+
isRollbackSessionForceEnabled,
|
|
798
|
+
enableRollbackForSession,
|
|
799
|
+
disableRollbackForSession,
|
|
800
|
+
beginTurn,
|
|
801
|
+
rollbackSnapshotBeforeWrite,
|
|
802
|
+
captureTreeChanges,
|
|
803
|
+
peekRollbackTurnsConsumed,
|
|
804
|
+
rollbackLastTurn,
|
|
805
|
+
migrateRollbackSession,
|
|
806
|
+
clearRollback
|
|
807
|
+
};
|