@f5xc-salesdemos/xcsh 2.2.0 → 14.0.2
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 +6854 -24
- package/README.md +11 -610
- package/examples/README.md +8 -15
- package/examples/custom-tools/README.md +109 -0
- package/examples/custom-tools/hello/index.ts +20 -0
- package/examples/custom-tools/todo/index.ts +206 -0
- package/examples/extensions/README.md +78 -143
- package/examples/extensions/api-demo.ts +89 -0
- package/examples/extensions/chalk-logger.ts +25 -0
- package/examples/extensions/hello.ts +24 -18
- package/examples/extensions/pirate.ts +5 -9
- package/examples/extensions/plan-mode.ts +551 -0
- package/examples/extensions/reload-runtime.ts +1 -1
- package/examples/extensions/todo.ts +18 -19
- package/examples/extensions/tools.ts +23 -19
- package/examples/extensions/with-deps/index.ts +5 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +2 -8
- package/examples/hooks/README.md +56 -0
- package/examples/hooks/auto-commit-on-exit.ts +48 -0
- package/examples/hooks/confirm-destructive.ts +58 -0
- package/examples/hooks/custom-compaction.ts +115 -0
- package/examples/hooks/dirty-repo-guard.ts +51 -0
- package/examples/hooks/file-trigger.ts +40 -0
- package/examples/hooks/git-checkpoint.ts +52 -0
- package/examples/hooks/handoff.ts +149 -0
- package/examples/hooks/permission-gate.ts +33 -0
- package/examples/hooks/protected-paths.ts +29 -0
- package/examples/hooks/qna.ts +118 -0
- package/examples/hooks/status-line.ts +39 -0
- package/examples/sdk/01-minimal.ts +3 -4
- package/examples/sdk/02-custom-model.ts +9 -9
- package/examples/sdk/03-custom-prompt.ts +11 -23
- package/examples/sdk/04-skills.ts +23 -32
- package/examples/sdk/06-extensions.ts +14 -22
- package/examples/sdk/06-hooks.ts +61 -0
- package/examples/sdk/07-context-files.ts +18 -23
- package/examples/sdk/08-prompt-templates.ts +14 -21
- package/examples/sdk/08-slash-commands.ts +46 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +15 -9
- package/examples/sdk/11-sessions.ts +3 -4
- package/examples/sdk/README.md +117 -92
- package/package.json +507 -82
- package/scripts/format-prompts.ts +68 -0
- package/scripts/generate-docs-index.ts +40 -0
- package/scripts/generate-template.ts +32 -0
- package/src/async/index.ts +1 -0
- package/src/async/job-manager.ts +383 -0
- package/src/autoresearch/apply-contract-to-state.ts +24 -0
- package/src/autoresearch/command-resume.md +17 -0
- package/src/autoresearch/contract.ts +288 -0
- package/src/autoresearch/dashboard.ts +446 -0
- package/src/autoresearch/git.ts +329 -0
- package/src/autoresearch/helpers.ts +507 -0
- package/src/autoresearch/index.ts +534 -0
- package/src/autoresearch/prompt.md +244 -0
- package/src/autoresearch/resume-message.md +16 -0
- package/src/autoresearch/state.ts +380 -0
- package/src/autoresearch/tools/init-experiment.ts +395 -0
- package/src/autoresearch/tools/log-experiment.ts +778 -0
- package/src/autoresearch/tools/run-experiment.ts +678 -0
- package/src/autoresearch/types.ts +218 -0
- package/src/bun-imports.d.ts +22 -0
- package/src/capability/context-file.ts +44 -0
- package/src/capability/extension-module.ts +34 -0
- package/src/capability/extension.ts +47 -0
- package/src/capability/fs.ts +107 -0
- package/src/capability/hook.ts +40 -0
- package/src/capability/index.ts +436 -0
- package/src/capability/instruction.ts +37 -0
- package/src/capability/mcp.ts +74 -0
- package/src/capability/prompt.ts +35 -0
- package/src/capability/rule.ts +224 -0
- package/src/capability/settings.ts +34 -0
- package/src/capability/skill.ts +49 -0
- package/src/capability/slash-command.ts +40 -0
- package/src/capability/ssh.ts +41 -0
- package/src/capability/system-prompt.ts +34 -0
- package/src/capability/tool.ts +38 -0
- package/src/capability/types.ts +168 -0
- package/src/cli/agents-cli.ts +138 -0
- package/src/cli/args.ts +283 -0
- package/src/cli/classify-install-target.ts +50 -0
- package/src/cli/commands/init-xdg.ts +27 -0
- package/src/cli/config-cli.ts +418 -0
- package/src/cli/file-processor.ts +123 -0
- package/src/cli/grep-cli.ts +160 -0
- package/src/cli/grievances-cli.ts +78 -0
- package/src/cli/initial-message.ts +58 -0
- package/src/cli/jupyter-cli.ts +106 -0
- package/src/cli/list-models.ts +89 -0
- package/src/cli/plugin-cli.ts +964 -0
- package/src/cli/read-cli.ts +67 -0
- package/src/cli/session-picker.ts +52 -0
- package/src/cli/setup-cli.ts +376 -0
- package/src/cli/shell-cli.ts +174 -0
- package/src/cli/ssh-cli.ts +179 -0
- package/src/cli/stats-cli.ts +182 -0
- package/src/cli/update-cli.ts +342 -0
- package/src/cli/web-search-cli.ts +133 -0
- package/src/cli.ts +96 -0
- package/src/commands/agents.ts +57 -0
- package/src/commands/commit.ts +36 -0
- package/src/commands/config.ts +51 -0
- package/src/commands/grep.ts +48 -0
- package/src/commands/grievances.ts +20 -0
- package/src/commands/jupyter.ts +32 -0
- package/src/commands/launch.ts +141 -0
- package/src/commands/plugin.ts +78 -0
- package/src/commands/read.ts +33 -0
- package/src/commands/setup.ts +42 -0
- package/src/commands/shell.ts +29 -0
- package/src/commands/ssh.ts +60 -0
- package/src/commands/stats.ts +29 -0
- package/src/commands/update.ts +21 -0
- package/src/commands/web-search.ts +42 -0
- package/src/commit/agentic/agent.ts +314 -0
- package/src/commit/agentic/fallback.ts +96 -0
- package/src/commit/agentic/index.ts +354 -0
- package/src/commit/agentic/prompts/analyze-file.md +22 -0
- package/src/commit/agentic/prompts/session-user.md +25 -0
- package/src/commit/agentic/prompts/split-confirm.md +1 -0
- package/src/commit/agentic/prompts/system.md +38 -0
- package/src/commit/agentic/state.ts +60 -0
- package/src/commit/agentic/tools/analyze-file.ts +128 -0
- package/src/commit/agentic/tools/git-file-diff.ts +191 -0
- package/src/commit/agentic/tools/git-hunk.ts +50 -0
- package/src/commit/agentic/tools/git-overview.ts +81 -0
- package/src/commit/agentic/tools/index.ts +54 -0
- package/src/commit/agentic/tools/propose-changelog.ts +139 -0
- package/src/commit/agentic/tools/propose-commit.ts +122 -0
- package/src/commit/agentic/tools/recent-commits.ts +81 -0
- package/src/commit/agentic/tools/schemas.ts +31 -0
- package/src/commit/agentic/tools/split-commit.ts +251 -0
- package/src/commit/agentic/topo-sort.ts +44 -0
- package/src/commit/agentic/trivial.ts +51 -0
- package/src/commit/agentic/validation.ts +183 -0
- package/src/commit/analysis/conventional.ts +122 -0
- package/src/commit/analysis/index.ts +4 -0
- package/src/commit/analysis/scope.ts +242 -0
- package/src/commit/analysis/summary.ts +105 -0
- package/src/commit/analysis/validation.ts +66 -0
- package/src/commit/changelog/detect.ts +40 -0
- package/src/commit/changelog/generate.ts +101 -0
- package/src/commit/changelog/index.ts +234 -0
- package/src/commit/changelog/parse.ts +44 -0
- package/src/commit/cli.ts +85 -0
- package/src/commit/git/diff.ts +148 -0
- package/src/commit/index.ts +5 -0
- package/src/commit/map-reduce/index.ts +69 -0
- package/src/commit/map-reduce/map-phase.ts +193 -0
- package/src/commit/map-reduce/reduce-phase.ts +108 -0
- package/src/commit/map-reduce/utils.ts +9 -0
- package/src/commit/message.ts +11 -0
- package/src/commit/model-selection.ts +63 -0
- package/src/commit/pipeline.ts +242 -0
- package/src/commit/prompts/analysis-system.md +148 -0
- package/src/commit/prompts/analysis-user.md +38 -0
- package/src/commit/prompts/changelog-system.md +50 -0
- package/src/commit/prompts/changelog-user.md +18 -0
- package/src/commit/prompts/file-observer-system.md +24 -0
- package/src/commit/prompts/file-observer-user.md +8 -0
- package/src/commit/prompts/reduce-system.md +50 -0
- package/src/commit/prompts/reduce-user.md +17 -0
- package/src/commit/prompts/summary-retry.md +3 -0
- package/src/commit/prompts/summary-system.md +38 -0
- package/src/commit/prompts/summary-user.md +13 -0
- package/src/commit/prompts/types-description.md +2 -0
- package/src/commit/types.ts +118 -0
- package/src/commit/utils/exclusions.ts +42 -0
- package/src/commit/utils.ts +44 -0
- package/src/config/file-lock.ts +121 -0
- package/src/config/keybindings.ts +493 -0
- package/src/config/mcp-schema.json +230 -0
- package/src/config/model-registry.ts +1917 -0
- package/src/config/model-resolver.ts +1064 -0
- package/src/config/prompt-templates.ts +255 -0
- package/src/config/resolve-config-value.ts +94 -0
- package/src/config/settings-schema.ts +1929 -0
- package/src/config/settings.ts +701 -0
- package/src/config.ts +419 -0
- package/src/cursor.ts +304 -0
- package/src/dap/client.ts +674 -0
- package/src/dap/config.ts +150 -0
- package/src/dap/defaults.json +211 -0
- package/src/dap/index.ts +4 -0
- package/src/dap/session.ts +1255 -0
- package/src/dap/types.ts +600 -0
- package/src/debug/index.ts +438 -0
- package/src/debug/log-formatting.ts +58 -0
- package/src/debug/log-viewer.ts +908 -0
- package/src/debug/profiler.ts +158 -0
- package/src/debug/report-bundle.ts +365 -0
- package/src/debug/system-info.ts +107 -0
- package/src/discovery/agents-md.ts +67 -0
- package/src/discovery/agents.ts +219 -0
- package/src/discovery/builtin.ts +851 -0
- package/src/discovery/claude-plugins.ts +296 -0
- package/src/discovery/claude.ts +543 -0
- package/src/discovery/cline.ts +83 -0
- package/src/discovery/codex.ts +535 -0
- package/src/discovery/cursor.ts +220 -0
- package/src/discovery/gemini.ts +396 -0
- package/src/discovery/github.ts +118 -0
- package/src/discovery/helpers.ts +968 -0
- package/src/discovery/index.ts +79 -0
- package/src/discovery/mcp-json.ts +171 -0
- package/src/discovery/opencode.ts +393 -0
- package/src/discovery/plugin-dir-roots.ts +28 -0
- package/src/discovery/ssh.ts +153 -0
- package/src/discovery/substitute-plugin-root.ts +29 -0
- package/src/discovery/vscode.ts +105 -0
- package/src/discovery/windsurf.ts +147 -0
- package/src/edit/diff.ts +818 -0
- package/src/edit/index.ts +314 -0
- package/src/edit/line-hash.ts +67 -0
- package/src/edit/modes/chunk.ts +454 -0
- package/src/edit/modes/hashline.ts +1341 -0
- package/src/edit/modes/patch.ts +1785 -0
- package/src/edit/modes/replace.ts +1107 -0
- package/src/edit/normalize.ts +375 -0
- package/src/edit/renderer.ts +467 -0
- package/src/exa/factory.ts +59 -0
- package/src/exa/index.ts +27 -0
- package/src/exa/mcp-client.ts +291 -0
- package/src/exa/render.ts +244 -0
- package/src/exa/researcher.ts +47 -0
- package/src/exa/search.ts +86 -0
- package/src/exa/types.ts +166 -0
- package/src/exa/websets.ts +247 -0
- package/src/exec/bash-executor.ts +240 -0
- package/src/exec/exec.ts +53 -0
- package/src/exec/idle-timeout-watchdog.ts +126 -0
- package/src/exec/non-interactive-env.ts +48 -0
- package/src/export/custom-share.ts +65 -0
- package/src/export/html/index.ts +161 -0
- package/src/export/html/template.css +919 -0
- package/src/export/html/template.generated.ts +2 -0
- package/src/export/html/template.html +46 -0
- package/src/export/html/template.js +1458 -0
- package/src/export/html/template.macro.ts +24 -0
- package/src/export/ttsr.ts +434 -0
- package/src/extensibility/custom-commands/bundled/ci-green/index.ts +25 -0
- package/src/extensibility/custom-commands/bundled/review/index.ts +435 -0
- package/src/extensibility/custom-commands/index.ts +2 -0
- package/src/extensibility/custom-commands/loader.ts +236 -0
- package/src/extensibility/custom-commands/types.ts +111 -0
- package/src/extensibility/custom-tools/index.ts +7 -0
- package/src/extensibility/custom-tools/loader.ts +238 -0
- package/src/extensibility/custom-tools/types.ts +255 -0
- package/src/extensibility/custom-tools/wrapper.ts +47 -0
- package/src/extensibility/extensions/index.ts +15 -0
- package/src/extensibility/extensions/loader.ts +516 -0
- package/src/extensibility/extensions/runner.ts +841 -0
- package/src/extensibility/extensions/types.ts +1366 -0
- package/src/extensibility/extensions/wrapper.ts +191 -0
- package/src/extensibility/hooks/index.ts +5 -0
- package/src/extensibility/hooks/loader.ts +255 -0
- package/src/extensibility/hooks/runner.ts +425 -0
- package/src/extensibility/hooks/tool-wrapper.ts +108 -0
- package/src/extensibility/hooks/types.ts +822 -0
- package/src/extensibility/plugins/doctor.ts +66 -0
- package/src/extensibility/plugins/git-url.ts +281 -0
- package/src/extensibility/plugins/index.ts +9 -0
- package/src/extensibility/plugins/installer.ts +192 -0
- package/src/extensibility/plugins/loader.ts +267 -0
- package/src/extensibility/plugins/manager.ts +731 -0
- package/src/extensibility/plugins/marketplace/cache.ts +136 -0
- package/src/extensibility/plugins/marketplace/fetcher.ts +317 -0
- package/src/extensibility/plugins/marketplace/index.ts +6 -0
- package/src/extensibility/plugins/marketplace/manager.ts +751 -0
- package/src/extensibility/plugins/marketplace/registry.ts +196 -0
- package/src/extensibility/plugins/marketplace/source-resolver.ts +147 -0
- package/src/extensibility/plugins/marketplace/types.ts +191 -0
- package/src/extensibility/plugins/parser.ts +105 -0
- package/src/extensibility/plugins/types.ts +194 -0
- package/src/extensibility/skills.ts +252 -0
- package/src/extensibility/slash-commands.ts +227 -0
- package/src/extensibility/tool-proxy.ts +25 -0
- package/src/extensibility/utils.ts +38 -0
- package/src/index.ts +61 -0
- package/src/internal-urls/agent-protocol.ts +136 -0
- package/src/internal-urls/artifact-protocol.ts +97 -0
- package/src/internal-urls/docs-index.generated.ts +57 -0
- package/src/internal-urls/index.ts +35 -0
- package/src/internal-urls/jobs-protocol.ts +118 -0
- package/src/internal-urls/json-query.ts +126 -0
- package/src/internal-urls/local-protocol.ts +206 -0
- package/src/internal-urls/mcp-protocol.ts +156 -0
- package/src/internal-urls/memory-protocol.ts +133 -0
- package/src/internal-urls/parse.ts +72 -0
- package/src/internal-urls/pi-protocol.ts +84 -0
- package/src/internal-urls/router.ts +54 -0
- package/src/internal-urls/rule-protocol.ts +55 -0
- package/src/internal-urls/skill-protocol.ts +111 -0
- package/src/internal-urls/types.ts +52 -0
- package/src/ipy/cancellation.ts +28 -0
- package/src/ipy/executor.ts +762 -0
- package/src/ipy/gateway-coordinator.ts +424 -0
- package/src/ipy/kernel.ts +1065 -0
- package/src/ipy/modules.ts +144 -0
- package/src/ipy/prelude.py +849 -0
- package/src/ipy/prelude.ts +3 -0
- package/src/ipy/runtime.ts +221 -0
- package/src/lsp/client.ts +878 -0
- package/src/lsp/clients/biome-client.ts +202 -0
- package/src/lsp/clients/index.ts +50 -0
- package/src/lsp/clients/lsp-linter-client.ts +93 -0
- package/src/lsp/clients/swiftlint-client.ts +120 -0
- package/src/lsp/config.ts +402 -0
- package/src/lsp/defaults.json +998 -0
- package/src/lsp/edits.ts +109 -0
- package/src/lsp/index.ts +1743 -0
- package/src/lsp/lspmux.ts +233 -0
- package/src/lsp/render.ts +683 -0
- package/src/lsp/startup-events.ts +13 -0
- package/src/lsp/types.ts +438 -0
- package/src/lsp/utils.ts +807 -0
- package/src/main.ts +914 -0
- package/src/mcp/client.ts +482 -0
- package/src/mcp/config-writer.ts +225 -0
- package/src/mcp/config.ts +365 -0
- package/src/mcp/discoverable-tool-metadata.ts +202 -0
- package/src/mcp/index.ts +29 -0
- package/src/mcp/json-rpc.ts +84 -0
- package/src/mcp/loader.ts +124 -0
- package/src/mcp/manager.ts +1152 -0
- package/src/mcp/oauth-discovery.ts +349 -0
- package/src/mcp/oauth-flow.ts +387 -0
- package/src/mcp/render.ts +130 -0
- package/src/mcp/smithery-auth.ts +104 -0
- package/src/mcp/smithery-connect.ts +145 -0
- package/src/mcp/smithery-registry.ts +477 -0
- package/src/mcp/tool-bridge.ts +417 -0
- package/src/mcp/tool-cache.ts +117 -0
- package/src/mcp/transports/http.ts +475 -0
- package/src/mcp/transports/index.ts +6 -0
- package/src/mcp/transports/stdio.ts +325 -0
- package/src/mcp/types.ts +423 -0
- package/src/memories/index.ts +1114 -0
- package/src/memories/storage.ts +577 -0
- package/src/modes/acp/acp-agent.ts +1358 -0
- package/src/modes/acp/acp-event-mapper.ts +538 -0
- package/src/modes/acp/acp-mode.ts +15 -0
- package/src/modes/acp/index.ts +2 -0
- package/src/modes/components/agent-dashboard.ts +1120 -0
- package/src/modes/components/assistant-message.ts +206 -0
- package/src/modes/components/bash-execution.ts +247 -0
- package/src/modes/components/bordered-loader.ts +41 -0
- package/src/modes/components/branch-summary-message.ts +45 -0
- package/src/modes/components/btw-panel.ts +104 -0
- package/src/modes/components/compaction-summary-message.ts +51 -0
- package/src/modes/components/countdown-timer.ts +75 -0
- package/src/modes/components/custom-editor.ts +238 -0
- package/src/modes/components/custom-message.ts +91 -0
- package/src/modes/components/diff.ts +210 -0
- package/src/modes/components/dynamic-border.ts +25 -0
- package/src/modes/components/extensions/extension-dashboard.ts +326 -0
- package/src/modes/components/extensions/extension-list.ts +492 -0
- package/src/modes/components/extensions/index.ts +9 -0
- package/src/modes/components/extensions/inspector-panel.ts +317 -0
- package/src/modes/components/extensions/state-manager.ts +587 -0
- package/src/modes/components/extensions/types.ts +191 -0
- package/src/modes/components/footer.ts +262 -0
- package/src/modes/components/history-search.ts +158 -0
- package/src/modes/components/hook-editor.ts +151 -0
- package/src/modes/components/hook-input.ts +79 -0
- package/src/modes/components/hook-message.ts +100 -0
- package/src/modes/components/hook-selector.ts +190 -0
- package/src/modes/components/index.ts +36 -0
- package/src/modes/components/keybinding-hints.ts +65 -0
- package/src/modes/components/login-dialog.ts +164 -0
- package/src/modes/components/mcp-add-wizard.ts +1314 -0
- package/src/modes/components/model-selector.ts +789 -0
- package/src/modes/components/oauth-selector.ts +211 -0
- package/src/modes/components/plugin-selector.ts +95 -0
- package/src/modes/components/plugin-settings.ts +477 -0
- package/src/modes/components/python-execution.ts +181 -0
- package/src/modes/components/queue-mode-selector.ts +56 -0
- package/src/modes/components/read-tool-group.ts +152 -0
- package/src/modes/components/session-observer-overlay.ts +472 -0
- package/src/modes/components/session-selector.ts +343 -0
- package/src/modes/components/settings-defs.ts +547 -0
- package/src/modes/components/settings-selector.ts +624 -0
- package/src/modes/components/show-images-selector.ts +45 -0
- package/src/modes/components/skill-message.ts +90 -0
- package/src/modes/components/status-line/context-thresholds.ts +68 -0
- package/src/modes/components/status-line/git-utils.ts +42 -0
- package/src/modes/components/status-line/index.ts +4 -0
- package/src/modes/components/status-line/presets.ts +94 -0
- package/src/modes/components/status-line/segments.ts +392 -0
- package/src/modes/components/status-line/separators.ts +55 -0
- package/src/modes/components/status-line/token-rate.ts +66 -0
- package/src/modes/components/status-line/types.ts +82 -0
- package/src/modes/components/status-line-segment-editor.ts +358 -0
- package/src/modes/components/status-line.ts +499 -0
- package/src/modes/components/theme-selector.ts +63 -0
- package/src/modes/components/thinking-selector.ts +52 -0
- package/src/modes/components/todo-reminder.ts +47 -0
- package/src/modes/components/tool-execution.ts +697 -0
- package/src/modes/components/tree-selector.ts +908 -0
- package/src/modes/components/ttsr-notification.ts +80 -0
- package/src/modes/components/user-message-selector.ts +141 -0
- package/src/modes/components/user-message.ts +38 -0
- package/src/modes/components/visual-truncate.ts +63 -0
- package/src/modes/components/welcome.ts +248 -0
- package/src/modes/controllers/btw-controller.ts +193 -0
- package/src/modes/controllers/command-controller.ts +1195 -0
- package/src/modes/controllers/event-controller.ts +644 -0
- package/src/modes/controllers/extension-ui-controller.ts +960 -0
- package/src/modes/controllers/input-controller.ts +762 -0
- package/src/modes/controllers/mcp-command-controller.ts +1926 -0
- package/src/modes/controllers/selector-controller.ts +991 -0
- package/src/modes/controllers/ssh-command-controller.ts +421 -0
- package/src/modes/index.ts +34 -0
- package/src/modes/interactive-mode.ts +1664 -0
- package/src/modes/oauth-manual-input.ts +42 -0
- package/src/modes/print-mode.ts +192 -0
- package/src/modes/prompt-action-autocomplete.ts +233 -0
- package/src/modes/rpc/host-tools.ts +186 -0
- package/src/modes/rpc/rpc-client.ts +750 -0
- package/src/modes/rpc/rpc-mode.ts +825 -0
- package/src/modes/rpc/rpc-types.ts +297 -0
- package/src/modes/session-observer-registry.ts +146 -0
- package/src/modes/shared.ts +30 -0
- package/src/modes/theme/dark.json +95 -0
- package/src/modes/theme/defaults/alabaster.json +93 -0
- package/src/modes/theme/defaults/amethyst.json +96 -0
- package/src/modes/theme/defaults/anthracite.json +93 -0
- package/src/modes/theme/defaults/basalt.json +91 -0
- package/src/modes/theme/defaults/birch.json +95 -0
- package/src/modes/theme/defaults/dark-abyss.json +91 -0
- package/src/modes/theme/defaults/dark-arctic.json +104 -0
- package/src/modes/theme/defaults/dark-aurora.json +95 -0
- package/src/modes/theme/defaults/dark-catppuccin.json +107 -0
- package/src/modes/theme/defaults/dark-cavern.json +91 -0
- package/src/modes/theme/defaults/dark-copper.json +95 -0
- package/src/modes/theme/defaults/dark-cosmos.json +90 -0
- package/src/modes/theme/defaults/dark-cyberpunk.json +102 -0
- package/src/modes/theme/defaults/dark-dracula.json +98 -0
- package/src/modes/theme/defaults/dark-eclipse.json +91 -0
- package/src/modes/theme/defaults/dark-ember.json +95 -0
- package/src/modes/theme/defaults/dark-equinox.json +90 -0
- package/src/modes/theme/defaults/dark-forest.json +96 -0
- package/src/modes/theme/defaults/dark-github.json +105 -0
- package/src/modes/theme/defaults/dark-gruvbox.json +112 -0
- package/src/modes/theme/defaults/dark-lavender.json +95 -0
- package/src/modes/theme/defaults/dark-lunar.json +89 -0
- package/src/modes/theme/defaults/dark-midnight.json +95 -0
- package/src/modes/theme/defaults/dark-monochrome.json +94 -0
- package/src/modes/theme/defaults/dark-monokai.json +98 -0
- package/src/modes/theme/defaults/dark-nebula.json +90 -0
- package/src/modes/theme/defaults/dark-nord.json +97 -0
- package/src/modes/theme/defaults/dark-ocean.json +101 -0
- package/src/modes/theme/defaults/dark-one.json +100 -0
- package/src/modes/theme/defaults/dark-poimandres.json +138 -0
- package/src/modes/theme/defaults/dark-rainforest.json +91 -0
- package/src/modes/theme/defaults/dark-reef.json +91 -0
- package/src/modes/theme/defaults/dark-retro.json +92 -0
- package/src/modes/theme/defaults/dark-rose-pine.json +96 -0
- package/src/modes/theme/defaults/dark-sakura.json +95 -0
- package/src/modes/theme/defaults/dark-slate.json +95 -0
- package/src/modes/theme/defaults/dark-solarized.json +97 -0
- package/src/modes/theme/defaults/dark-solstice.json +90 -0
- package/src/modes/theme/defaults/dark-starfall.json +91 -0
- package/src/modes/theme/defaults/dark-sunset.json +99 -0
- package/src/modes/theme/defaults/dark-swamp.json +90 -0
- package/src/modes/theme/defaults/dark-synthwave.json +103 -0
- package/src/modes/theme/defaults/dark-taiga.json +91 -0
- package/src/modes/theme/defaults/dark-terminal.json +95 -0
- package/src/modes/theme/defaults/dark-tokyo-night.json +101 -0
- package/src/modes/theme/defaults/dark-tundra.json +91 -0
- package/src/modes/theme/defaults/dark-twilight.json +91 -0
- package/src/modes/theme/defaults/dark-volcanic.json +91 -0
- package/src/modes/theme/defaults/graphite.json +92 -0
- package/src/modes/theme/defaults/index.ts +203 -0
- package/src/modes/theme/defaults/light-arctic.json +107 -0
- package/src/modes/theme/defaults/light-aurora-day.json +91 -0
- package/src/modes/theme/defaults/light-canyon.json +91 -0
- package/src/modes/theme/defaults/light-catppuccin.json +106 -0
- package/src/modes/theme/defaults/light-cirrus.json +90 -0
- package/src/modes/theme/defaults/light-coral.json +95 -0
- package/src/modes/theme/defaults/light-cyberpunk.json +96 -0
- package/src/modes/theme/defaults/light-dawn.json +90 -0
- package/src/modes/theme/defaults/light-dunes.json +91 -0
- package/src/modes/theme/defaults/light-eucalyptus.json +95 -0
- package/src/modes/theme/defaults/light-forest.json +100 -0
- package/src/modes/theme/defaults/light-frost.json +95 -0
- package/src/modes/theme/defaults/light-github.json +115 -0
- package/src/modes/theme/defaults/light-glacier.json +91 -0
- package/src/modes/theme/defaults/light-gruvbox.json +108 -0
- package/src/modes/theme/defaults/light-haze.json +90 -0
- package/src/modes/theme/defaults/light-honeycomb.json +95 -0
- package/src/modes/theme/defaults/light-lagoon.json +91 -0
- package/src/modes/theme/defaults/light-lavender.json +95 -0
- package/src/modes/theme/defaults/light-meadow.json +91 -0
- package/src/modes/theme/defaults/light-mint.json +95 -0
- package/src/modes/theme/defaults/light-monochrome.json +101 -0
- package/src/modes/theme/defaults/light-ocean.json +99 -0
- package/src/modes/theme/defaults/light-one.json +99 -0
- package/src/modes/theme/defaults/light-opal.json +91 -0
- package/src/modes/theme/defaults/light-orchard.json +91 -0
- package/src/modes/theme/defaults/light-paper.json +95 -0
- package/src/modes/theme/defaults/light-poimandres.json +138 -0
- package/src/modes/theme/defaults/light-prism.json +90 -0
- package/src/modes/theme/defaults/light-retro.json +98 -0
- package/src/modes/theme/defaults/light-sand.json +95 -0
- package/src/modes/theme/defaults/light-savanna.json +91 -0
- package/src/modes/theme/defaults/light-solarized.json +102 -0
- package/src/modes/theme/defaults/light-soleil.json +90 -0
- package/src/modes/theme/defaults/light-sunset.json +99 -0
- package/src/modes/theme/defaults/light-synthwave.json +98 -0
- package/src/modes/theme/defaults/light-tokyo-night.json +111 -0
- package/src/modes/theme/defaults/light-wetland.json +91 -0
- package/src/modes/theme/defaults/light-zenith.json +89 -0
- package/src/modes/theme/defaults/limestone.json +94 -0
- package/src/modes/theme/defaults/mahogany.json +97 -0
- package/src/modes/theme/defaults/marble.json +93 -0
- package/src/modes/theme/defaults/obsidian.json +91 -0
- package/src/modes/theme/defaults/onyx.json +91 -0
- package/src/modes/theme/defaults/pearl.json +93 -0
- package/src/modes/theme/defaults/porcelain.json +91 -0
- package/src/modes/theme/defaults/quartz.json +96 -0
- package/src/modes/theme/defaults/sandstone.json +95 -0
- package/src/modes/theme/defaults/titanium.json +90 -0
- package/src/modes/theme/defaults/xcsh-dark.json +89 -0
- package/src/modes/theme/defaults/xcsh-light.json +91 -0
- package/src/modes/theme/light.json +93 -0
- package/src/modes/theme/mermaid-cache.ts +70 -0
- package/src/modes/theme/theme-schema.json +429 -0
- package/src/modes/theme/theme.ts +2541 -0
- package/src/modes/types.ts +269 -0
- package/src/modes/utils/hotkeys-markdown.ts +59 -0
- package/src/modes/utils/keybinding-matchers.ts +30 -0
- package/src/modes/utils/tools-markdown.ts +27 -0
- package/src/modes/utils/ui-helpers.ts +620 -0
- package/src/plan-mode/approved-plan.ts +55 -0
- package/src/plan-mode/state.ts +6 -0
- package/src/priority.json +29 -0
- package/src/prompts/agents/designer.md +68 -0
- package/src/prompts/agents/explore.md +60 -0
- package/src/prompts/agents/frontmatter.md +10 -0
- package/src/prompts/agents/init.md +36 -0
- package/src/prompts/agents/librarian.md +121 -0
- package/src/prompts/agents/plan.md +49 -0
- package/src/prompts/agents/reviewer.md +127 -0
- package/src/prompts/agents/task.md +16 -0
- package/src/prompts/ci-green-request.md +36 -0
- package/src/prompts/compaction/branch-summary-context.md +5 -0
- package/src/prompts/compaction/branch-summary-preamble.md +2 -0
- package/src/prompts/compaction/branch-summary.md +30 -0
- package/src/prompts/compaction/compaction-short-summary.md +9 -0
- package/src/prompts/compaction/compaction-summary-context.md +5 -0
- package/src/prompts/compaction/compaction-summary.md +38 -0
- package/src/prompts/compaction/compaction-turn-prefix.md +17 -0
- package/src/prompts/compaction/compaction-update-summary.md +45 -0
- package/src/prompts/memories/consolidation.md +30 -0
- package/src/prompts/memories/read-path.md +11 -0
- package/src/prompts/memories/stage_one_input.md +6 -0
- package/src/prompts/memories/stage_one_system.md +21 -0
- package/src/prompts/review-request.md +64 -0
- package/src/prompts/system/agent-creation-architect.md +65 -0
- package/src/prompts/system/agent-creation-user.md +6 -0
- package/src/prompts/system/auto-handoff-threshold-focus.md +1 -0
- package/src/prompts/system/btw-user.md +8 -0
- package/src/prompts/system/commit-message-system.md +2 -0
- package/src/prompts/system/custom-system-prompt.md +68 -0
- package/src/prompts/system/eager-todo.md +13 -0
- package/src/prompts/system/file-operations.md +10 -0
- package/src/prompts/system/handoff-document.md +46 -0
- package/src/prompts/system/plan-mode-active.md +107 -0
- package/src/prompts/system/plan-mode-approved.md +23 -0
- package/src/prompts/system/plan-mode-reference.md +14 -0
- package/src/prompts/system/plan-mode-subagent.md +34 -0
- package/src/prompts/system/plan-mode-tool-decision-reminder.md +9 -0
- package/src/prompts/system/subagent-submit-reminder.md +11 -0
- package/src/prompts/system/subagent-system-prompt.md +35 -0
- package/src/prompts/system/subagent-user-prompt.md +12 -0
- package/src/prompts/system/summarization-system.md +3 -0
- package/src/prompts/system/system-prompt.md +333 -0
- package/src/prompts/system/title-system.md +2 -0
- package/src/prompts/system/ttsr-interrupt.md +7 -0
- package/src/prompts/system/web-search.md +28 -0
- package/src/prompts/tools/ask.md +28 -0
- package/src/prompts/tools/ast-edit.md +48 -0
- package/src/prompts/tools/ast-grep.md +54 -0
- package/src/prompts/tools/async-result.md +5 -0
- package/src/prompts/tools/await.md +5 -0
- package/src/prompts/tools/bash.md +47 -0
- package/src/prompts/tools/browser.md +24 -0
- package/src/prompts/tools/calculator.md +10 -0
- package/src/prompts/tools/cancel-job.md +5 -0
- package/src/prompts/tools/checkpoint.md +16 -0
- package/src/prompts/tools/chunk-edit.md +219 -0
- package/src/prompts/tools/debug.md +43 -0
- package/src/prompts/tools/exit-plan-mode.md +41 -0
- package/src/prompts/tools/find.md +26 -0
- package/src/prompts/tools/gemini-image.md +7 -0
- package/src/prompts/tools/gh-issue-view.md +11 -0
- package/src/prompts/tools/gh-pr-checkout.md +12 -0
- package/src/prompts/tools/gh-pr-diff.md +12 -0
- package/src/prompts/tools/gh-pr-push.md +11 -0
- package/src/prompts/tools/gh-pr-view.md +11 -0
- package/src/prompts/tools/gh-repo-view.md +11 -0
- package/src/prompts/tools/gh-run-watch.md +12 -0
- package/src/prompts/tools/gh-search-issues.md +11 -0
- package/src/prompts/tools/gh-search-prs.md +11 -0
- package/src/prompts/tools/grep.md +29 -0
- package/src/prompts/tools/hashline.md +131 -0
- package/src/prompts/tools/inspect-image-system.md +20 -0
- package/src/prompts/tools/inspect-image.md +32 -0
- package/src/prompts/tools/lsp.md +33 -0
- package/src/prompts/tools/patch.md +72 -0
- package/src/prompts/tools/python.md +60 -0
- package/src/prompts/tools/read-chunk.md +17 -0
- package/src/prompts/tools/read.md +54 -0
- package/src/prompts/tools/render-mermaid.md +9 -0
- package/src/prompts/tools/replace.md +36 -0
- package/src/prompts/tools/resolve.md +8 -0
- package/src/prompts/tools/rewind.md +13 -0
- package/src/prompts/tools/search-tool-bm25.md +34 -0
- package/src/prompts/tools/ssh.md +44 -0
- package/src/prompts/tools/task-summary.md +28 -0
- package/src/prompts/tools/task.md +131 -0
- package/src/prompts/tools/todo-write.md +89 -0
- package/src/prompts/tools/web-search.md +10 -0
- package/src/prompts/tools/write.md +13 -0
- package/src/sdk.ts +1694 -0
- package/src/secrets/index.ts +116 -0
- package/src/secrets/obfuscator.ts +277 -0
- package/src/secrets/regex.ts +21 -0
- package/src/session/agent-session.ts +6506 -0
- package/src/session/agent-storage.ts +451 -0
- package/src/session/artifacts.ts +132 -0
- package/src/session/auth-storage.ts +17 -0
- package/src/session/blob-store.ts +135 -0
- package/src/session/compaction/branch-summarization.ts +322 -0
- package/src/session/compaction/compaction.ts +1388 -0
- package/src/session/compaction/index.ts +7 -0
- package/src/session/compaction/pruning.ts +91 -0
- package/src/session/compaction/utils.ts +184 -0
- package/src/session/history-storage.ts +253 -0
- package/src/session/messages.ts +373 -0
- package/src/session/session-dump-format.ts +203 -0
- package/src/session/session-manager.ts +2728 -0
- package/src/session/session-storage.ts +367 -0
- package/src/session/streaming-output.ts +752 -0
- package/src/session/tool-choice-queue.ts +213 -0
- package/src/slash-commands/builtin-registry.ts +981 -0
- package/src/slash-commands/marketplace-install-parser.ts +99 -0
- package/src/ssh/config-writer.ts +183 -0
- package/src/ssh/connection-manager.ts +445 -0
- package/src/ssh/ssh-executor.ts +128 -0
- package/src/ssh/sshfs-mount.ts +137 -0
- package/src/ssh/utils.ts +8 -0
- package/src/stt/downloader.ts +71 -0
- package/src/stt/index.ts +3 -0
- package/src/stt/recorder.ts +351 -0
- package/src/stt/setup.ts +52 -0
- package/src/stt/stt-controller.ts +160 -0
- package/src/stt/transcribe.py +70 -0
- package/src/stt/transcriber.ts +91 -0
- package/src/system-prompt.ts +620 -0
- package/src/task/agents.ts +166 -0
- package/src/task/commands.ts +131 -0
- package/src/task/discovery.ts +126 -0
- package/src/task/executor.ts +1293 -0
- package/src/task/index.ts +1199 -0
- package/src/task/isolation-backend.ts +72 -0
- package/src/task/name-generator.ts +1577 -0
- package/src/task/output-manager.ts +107 -0
- package/src/task/parallel.ts +116 -0
- package/src/task/render.ts +1021 -0
- package/src/task/subprocess-tool-registry.ts +88 -0
- package/src/task/template.ts +33 -0
- package/src/task/types.ts +230 -0
- package/src/task/worktree.ts +580 -0
- package/src/task/xcsh-command.ts +26 -0
- package/src/thinking.ts +87 -0
- package/src/tools/archive-reader.ts +315 -0
- package/src/tools/ask.ts +795 -0
- package/src/tools/ast-edit.ts +495 -0
- package/src/tools/ast-grep.ts +456 -0
- package/src/tools/auto-generated-guard.ts +305 -0
- package/src/tools/await-tool.ts +170 -0
- package/src/tools/bash-interactive.ts +377 -0
- package/src/tools/bash-interceptor.ts +67 -0
- package/src/tools/bash-normalize.ts +107 -0
- package/src/tools/bash-skill-urls.ts +246 -0
- package/src/tools/bash.ts +600 -0
- package/src/tools/browser.ts +1473 -0
- package/src/tools/calculator.ts +537 -0
- package/src/tools/cancel-job.ts +99 -0
- package/src/tools/checkpoint.ts +133 -0
- package/src/tools/context.ts +39 -0
- package/src/tools/debug.ts +1007 -0
- package/src/tools/exit-plan-mode.ts +101 -0
- package/src/tools/fetch.ts +1463 -0
- package/src/tools/find.ts +495 -0
- package/src/tools/fs-cache-invalidation.ts +33 -0
- package/src/tools/gemini-image.ts +896 -0
- package/src/tools/gh-renderer.ts +305 -0
- package/src/tools/gh.ts +2546 -0
- package/src/tools/grep.ts +625 -0
- package/src/tools/index.ts +426 -0
- package/src/tools/inspect-image-renderer.ts +103 -0
- package/src/tools/inspect-image.ts +173 -0
- package/src/tools/json-tree.ts +243 -0
- package/src/tools/jtd-to-json-schema.ts +199 -0
- package/src/tools/jtd-to-typescript.ts +136 -0
- package/src/tools/jtd-utils.ts +102 -0
- package/src/tools/list-limit.ts +40 -0
- package/src/tools/notebook.ts +288 -0
- package/src/tools/output-meta.ts +588 -0
- package/src/tools/path-utils.ts +560 -0
- package/src/tools/plan-mode-guard.ts +41 -0
- package/src/tools/puppeteer/00_stealth_tampering.txt +63 -0
- package/src/tools/puppeteer/01_stealth_activity.txt +20 -0
- package/src/tools/puppeteer/02_stealth_hairline.txt +11 -0
- package/src/tools/puppeteer/03_stealth_botd.txt +384 -0
- package/src/tools/puppeteer/04_stealth_iframe.txt +81 -0
- package/src/tools/puppeteer/05_stealth_webgl.txt +75 -0
- package/src/tools/puppeteer/06_stealth_screen.txt +72 -0
- package/src/tools/puppeteer/07_stealth_fonts.txt +97 -0
- package/src/tools/puppeteer/08_stealth_audio.txt +51 -0
- package/src/tools/puppeteer/09_stealth_locale.txt +46 -0
- package/src/tools/puppeteer/10_stealth_plugins.txt +206 -0
- package/src/tools/puppeteer/11_stealth_hardware.txt +8 -0
- package/src/tools/puppeteer/12_stealth_codecs.txt +40 -0
- package/src/tools/puppeteer/13_stealth_worker.txt +74 -0
- package/src/tools/python.ts +1135 -0
- package/src/tools/read.ts +1375 -0
- package/src/tools/render-mermaid.ts +71 -0
- package/src/tools/render-utils.ts +618 -0
- package/src/tools/renderers.ts +68 -0
- package/src/tools/report-tool-issue.ts +80 -0
- package/src/tools/resolve.ts +192 -0
- package/src/tools/review.ts +238 -0
- package/src/tools/search-tool-bm25.ts +283 -0
- package/src/tools/ssh.ts +320 -0
- package/src/tools/submit-result.ts +226 -0
- package/src/tools/todo-write.ts +450 -0
- package/src/tools/tool-errors.ts +62 -0
- package/src/tools/tool-result.ts +86 -0
- package/src/tools/tool-timeouts.ts +30 -0
- package/src/tools/write.ts +479 -0
- package/src/tui/code-cell.ts +113 -0
- package/src/tui/file-list.ts +47 -0
- package/src/tui/index.ts +11 -0
- package/src/tui/output-block.ts +150 -0
- package/src/tui/status-line.ts +39 -0
- package/src/tui/tree-list.ts +84 -0
- package/src/tui/types.ts +15 -0
- package/src/tui/utils.ts +103 -0
- package/src/utils/changelog.ts +98 -0
- package/src/utils/clipboard.ts +80 -0
- package/src/utils/command-args.ts +76 -0
- package/src/utils/commit-message-generator.ts +136 -0
- package/src/utils/edit-mode.ts +49 -0
- package/src/utils/event-bus.ts +33 -0
- package/src/utils/external-editor.ts +65 -0
- package/src/utils/file-display-mode.ts +37 -0
- package/src/utils/file-mentions.ts +376 -0
- package/src/utils/fuzzy.ts +108 -0
- package/src/utils/git.ts +1400 -0
- package/src/utils/image-convert.ts +27 -0
- package/src/utils/image-loading.ts +98 -0
- package/src/utils/image-resize.ts +236 -0
- package/src/utils/markit.ts +81 -0
- package/src/utils/open.ts +20 -0
- package/src/utils/shell-snapshot.ts +188 -0
- package/src/utils/sixel.ts +69 -0
- package/src/utils/title-generator.ts +184 -0
- package/src/utils/tool-choice.ts +28 -0
- package/src/utils/tools-manager.ts +356 -0
- package/src/web/kagi.ts +174 -0
- package/src/web/parallel.ts +346 -0
- package/src/web/scrapers/artifacthub.ts +207 -0
- package/src/web/scrapers/arxiv.ts +83 -0
- package/src/web/scrapers/aur.ts +162 -0
- package/src/web/scrapers/biorxiv.ts +133 -0
- package/src/web/scrapers/bluesky.ts +262 -0
- package/src/web/scrapers/brew.ts +172 -0
- package/src/web/scrapers/cheatsh.ts +68 -0
- package/src/web/scrapers/chocolatey.ts +196 -0
- package/src/web/scrapers/choosealicense.ts +95 -0
- package/src/web/scrapers/cisa-kev.ts +87 -0
- package/src/web/scrapers/clojars.ts +154 -0
- package/src/web/scrapers/coingecko.ts +177 -0
- package/src/web/scrapers/crates-io.ts +110 -0
- package/src/web/scrapers/crossref.ts +136 -0
- package/src/web/scrapers/devto.ts +147 -0
- package/src/web/scrapers/discogs.ts +306 -0
- package/src/web/scrapers/discourse.ts +197 -0
- package/src/web/scrapers/dockerhub.ts +138 -0
- package/src/web/scrapers/docs-rs.ts +653 -0
- package/src/web/scrapers/fdroid.ts +134 -0
- package/src/web/scrapers/firefox-addons.ts +191 -0
- package/src/web/scrapers/flathub.ts +223 -0
- package/src/web/scrapers/github-gist.ts +58 -0
- package/src/web/scrapers/github.ts +452 -0
- package/src/web/scrapers/gitlab.ts +401 -0
- package/src/web/scrapers/go-pkg.ts +266 -0
- package/src/web/scrapers/hackage.ts +140 -0
- package/src/web/scrapers/hackernews.ts +189 -0
- package/src/web/scrapers/hex.ts +105 -0
- package/src/web/scrapers/huggingface.ts +321 -0
- package/src/web/scrapers/iacr.ts +89 -0
- package/src/web/scrapers/index.ts +252 -0
- package/src/web/scrapers/jetbrains-marketplace.ts +159 -0
- package/src/web/scrapers/lemmy.ts +203 -0
- package/src/web/scrapers/lobsters.ts +175 -0
- package/src/web/scrapers/mastodon.ts +292 -0
- package/src/web/scrapers/maven.ts +138 -0
- package/src/web/scrapers/mdn.ts +169 -0
- package/src/web/scrapers/metacpan.ts +222 -0
- package/src/web/scrapers/musicbrainz.ts +250 -0
- package/src/web/scrapers/npm.ts +98 -0
- package/src/web/scrapers/nuget.ts +183 -0
- package/src/web/scrapers/nvd.ts +222 -0
- package/src/web/scrapers/ollama.ts +239 -0
- package/src/web/scrapers/open-vsx.ts +106 -0
- package/src/web/scrapers/opencorporates.ts +292 -0
- package/src/web/scrapers/openlibrary.ts +336 -0
- package/src/web/scrapers/orcid.ts +286 -0
- package/src/web/scrapers/osv.ts +176 -0
- package/src/web/scrapers/packagist.ts +160 -0
- package/src/web/scrapers/pub-dev.ts +143 -0
- package/src/web/scrapers/pubmed.ts +211 -0
- package/src/web/scrapers/pypi.ts +112 -0
- package/src/web/scrapers/rawg.ts +110 -0
- package/src/web/scrapers/readthedocs.ts +120 -0
- package/src/web/scrapers/reddit.ts +95 -0
- package/src/web/scrapers/repology.ts +251 -0
- package/src/web/scrapers/rfc.ts +201 -0
- package/src/web/scrapers/rubygems.ts +103 -0
- package/src/web/scrapers/searchcode.ts +190 -0
- package/src/web/scrapers/sec-edgar.ts +261 -0
- package/src/web/scrapers/semantic-scholar.ts +171 -0
- package/src/web/scrapers/snapcraft.ts +187 -0
- package/src/web/scrapers/sourcegraph.ts +336 -0
- package/src/web/scrapers/spdx.ts +108 -0
- package/src/web/scrapers/spotify.ts +198 -0
- package/src/web/scrapers/stackoverflow.ts +120 -0
- package/src/web/scrapers/terraform.ts +277 -0
- package/src/web/scrapers/tldr.ts +47 -0
- package/src/web/scrapers/twitter.ts +93 -0
- package/src/web/scrapers/types.ts +267 -0
- package/src/web/scrapers/utils.ts +109 -0
- package/src/web/scrapers/vimeo.ts +133 -0
- package/src/web/scrapers/vscode-marketplace.ts +187 -0
- package/src/web/scrapers/w3c.ts +156 -0
- package/src/web/scrapers/wikidata.ts +344 -0
- package/src/web/scrapers/wikipedia.ts +84 -0
- package/src/web/scrapers/youtube.ts +313 -0
- package/src/web/search/index.ts +268 -0
- package/src/web/search/provider.ts +86 -0
- package/src/web/search/providers/anthropic.ts +286 -0
- package/src/web/search/providers/base.ts +25 -0
- package/src/web/search/providers/brave.ts +150 -0
- package/src/web/search/providers/codex.ts +383 -0
- package/src/web/search/providers/exa.ts +264 -0
- package/src/web/search/providers/gemini.ts +566 -0
- package/src/web/search/providers/jina.ts +99 -0
- package/src/web/search/providers/kagi.ts +70 -0
- package/src/web/search/providers/kimi.ts +157 -0
- package/src/web/search/providers/parallel.ts +63 -0
- package/src/web/search/providers/perplexity.ts +546 -0
- package/src/web/search/providers/synthetic.ts +113 -0
- package/src/web/search/providers/tavily.ts +162 -0
- package/src/web/search/providers/utils.ts +36 -0
- package/src/web/search/providers/zai.ts +311 -0
- package/src/web/search/render.ts +299 -0
- package/src/web/search/types.ts +434 -0
- package/src/web/search/utils.ts +17 -0
- package/dist/bun/cli.d.ts +0 -3
- package/dist/bun/cli.d.ts.map +0 -1
- package/dist/bun/cli.js +0 -7
- package/dist/bun/cli.js.map +0 -1
- package/dist/bun/register-bedrock.d.ts +0 -2
- package/dist/bun/register-bedrock.d.ts.map +0 -1
- package/dist/bun/register-bedrock.js +0 -4
- package/dist/bun/register-bedrock.js.map +0 -1
- package/dist/cli/args.d.ts +0 -52
- package/dist/cli/args.d.ts.map +0 -1
- package/dist/cli/args.js +0 -326
- package/dist/cli/args.js.map +0 -1
- package/dist/cli/config-selector.d.ts +0 -14
- package/dist/cli/config-selector.d.ts.map +0 -1
- package/dist/cli/config-selector.js +0 -31
- package/dist/cli/config-selector.js.map +0 -1
- package/dist/cli/file-processor.d.ts +0 -15
- package/dist/cli/file-processor.d.ts.map +0 -1
- package/dist/cli/file-processor.js +0 -83
- package/dist/cli/file-processor.js.map +0 -1
- package/dist/cli/initial-message.d.ts +0 -18
- package/dist/cli/initial-message.d.ts.map +0 -1
- package/dist/cli/initial-message.js +0 -22
- package/dist/cli/initial-message.js.map +0 -1
- package/dist/cli/list-models.d.ts +0 -9
- package/dist/cli/list-models.d.ts.map +0 -1
- package/dist/cli/list-models.js +0 -92
- package/dist/cli/list-models.js.map +0 -1
- package/dist/cli/session-picker.d.ts +0 -9
- package/dist/cli/session-picker.d.ts.map +0 -1
- package/dist/cli/session-picker.js +0 -35
- package/dist/cli/session-picker.js.map +0 -1
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -14
- package/dist/cli.js.map +0 -1
- package/dist/config.d.ts +0 -68
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -203
- package/dist/config.js.map +0 -1
- package/dist/core/agent-session-runtime.d.ts +0 -83
- package/dist/core/agent-session-runtime.d.ts.map +0 -1
- package/dist/core/agent-session-runtime.js +0 -236
- package/dist/core/agent-session-runtime.js.map +0 -1
- package/dist/core/agent-session-services.d.ts +0 -86
- package/dist/core/agent-session-services.d.ts.map +0 -1
- package/dist/core/agent-session-services.js +0 -116
- package/dist/core/agent-session-services.js.map +0 -1
- package/dist/core/agent-session.d.ts +0 -585
- package/dist/core/agent-session.d.ts.map +0 -1
- package/dist/core/agent-session.js +0 -2497
- package/dist/core/agent-session.js.map +0 -1
- package/dist/core/auth-storage.d.ts +0 -132
- package/dist/core/auth-storage.d.ts.map +0 -1
- package/dist/core/auth-storage.js +0 -422
- package/dist/core/auth-storage.js.map +0 -1
- package/dist/core/bash-executor.d.ts +0 -46
- package/dist/core/bash-executor.d.ts.map +0 -1
- package/dist/core/bash-executor.js +0 -125
- package/dist/core/bash-executor.js.map +0 -1
- package/dist/core/compaction/branch-summarization.d.ts +0 -88
- package/dist/core/compaction/branch-summarization.d.ts.map +0 -1
- package/dist/core/compaction/branch-summarization.js +0 -243
- package/dist/core/compaction/branch-summarization.js.map +0 -1
- package/dist/core/compaction/compaction.d.ts +0 -121
- package/dist/core/compaction/compaction.d.ts.map +0 -1
- package/dist/core/compaction/compaction.js +0 -613
- package/dist/core/compaction/compaction.js.map +0 -1
- package/dist/core/compaction/index.d.ts +0 -7
- package/dist/core/compaction/index.d.ts.map +0 -1
- package/dist/core/compaction/index.js +0 -7
- package/dist/core/compaction/index.js.map +0 -1
- package/dist/core/compaction/utils.d.ts +0 -38
- package/dist/core/compaction/utils.d.ts.map +0 -1
- package/dist/core/compaction/utils.js +0 -153
- package/dist/core/compaction/utils.js.map +0 -1
- package/dist/core/defaults.d.ts +0 -3
- package/dist/core/defaults.d.ts.map +0 -1
- package/dist/core/defaults.js +0 -2
- package/dist/core/defaults.js.map +0 -1
- package/dist/core/diagnostics.d.ts +0 -15
- package/dist/core/diagnostics.d.ts.map +0 -1
- package/dist/core/diagnostics.js +0 -2
- package/dist/core/diagnostics.js.map +0 -1
- package/dist/core/event-bus.d.ts +0 -9
- package/dist/core/event-bus.d.ts.map +0 -1
- package/dist/core/event-bus.js +0 -25
- package/dist/core/event-bus.js.map +0 -1
- package/dist/core/exec.d.ts +0 -29
- package/dist/core/exec.d.ts.map +0 -1
- package/dist/core/exec.js +0 -75
- package/dist/core/exec.js.map +0 -1
- package/dist/core/export-html/ansi-to-html.d.ts +0 -22
- package/dist/core/export-html/ansi-to-html.d.ts.map +0 -1
- package/dist/core/export-html/ansi-to-html.js +0 -249
- package/dist/core/export-html/ansi-to-html.js.map +0 -1
- package/dist/core/export-html/index.d.ts +0 -37
- package/dist/core/export-html/index.d.ts.map +0 -1
- package/dist/core/export-html/index.js +0 -224
- package/dist/core/export-html/index.js.map +0 -1
- package/dist/core/export-html/template.css +0 -1001
- package/dist/core/export-html/template.html +0 -55
- package/dist/core/export-html/template.js +0 -1690
- package/dist/core/export-html/tool-renderer.d.ts +0 -40
- package/dist/core/export-html/tool-renderer.d.ts.map +0 -1
- package/dist/core/export-html/tool-renderer.js +0 -95
- package/dist/core/export-html/tool-renderer.js.map +0 -1
- package/dist/core/extensions/index.d.ts +0 -12
- package/dist/core/extensions/index.d.ts.map +0 -1
- package/dist/core/extensions/index.js +0 -9
- package/dist/core/extensions/index.js.map +0 -1
- package/dist/core/extensions/loader.d.ts +0 -25
- package/dist/core/extensions/loader.d.ts.map +0 -1
- package/dist/core/extensions/loader.js +0 -436
- package/dist/core/extensions/loader.js.map +0 -1
- package/dist/core/extensions/runner.d.ts +0 -148
- package/dist/core/extensions/runner.d.ts.map +0 -1
- package/dist/core/extensions/runner.js +0 -700
- package/dist/core/extensions/runner.js.map +0 -1
- package/dist/core/extensions/types.d.ts +0 -1073
- package/dist/core/extensions/types.d.ts.map +0 -1
- package/dist/core/extensions/types.js +0 -45
- package/dist/core/extensions/types.js.map +0 -1
- package/dist/core/extensions/wrapper.d.ts +0 -20
- package/dist/core/extensions/wrapper.d.ts.map +0 -1
- package/dist/core/extensions/wrapper.js +0 -22
- package/dist/core/extensions/wrapper.js.map +0 -1
- package/dist/core/footer-data-provider.d.ts +0 -48
- package/dist/core/footer-data-provider.d.ts.map +0 -1
- package/dist/core/footer-data-provider.js +0 -314
- package/dist/core/footer-data-provider.js.map +0 -1
- package/dist/core/index.d.ts +0 -12
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -12
- package/dist/core/index.js.map +0 -1
- package/dist/core/keybindings.d.ts +0 -288
- package/dist/core/keybindings.d.ts.map +0 -1
- package/dist/core/keybindings.js +0 -240
- package/dist/core/keybindings.js.map +0 -1
- package/dist/core/messages.d.ts +0 -77
- package/dist/core/messages.d.ts.map +0 -1
- package/dist/core/messages.js +0 -123
- package/dist/core/messages.js.map +0 -1
- package/dist/core/model-registry.d.ts +0 -132
- package/dist/core/model-registry.d.ts.map +0 -1
- package/dist/core/model-registry.js +0 -583
- package/dist/core/model-registry.js.map +0 -1
- package/dist/core/model-resolver.d.ts +0 -110
- package/dist/core/model-resolver.d.ts.map +0 -1
- package/dist/core/model-resolver.js +0 -486
- package/dist/core/model-resolver.js.map +0 -1
- package/dist/core/output-guard.d.ts +0 -6
- package/dist/core/output-guard.d.ts.map +0 -1
- package/dist/core/output-guard.js +0 -59
- package/dist/core/output-guard.js.map +0 -1
- package/dist/core/package-manager.d.ts +0 -192
- package/dist/core/package-manager.d.ts.map +0 -1
- package/dist/core/package-manager.js +0 -1832
- package/dist/core/package-manager.js.map +0 -1
- package/dist/core/prompt-templates.d.ts +0 -51
- package/dist/core/prompt-templates.d.ts.map +0 -1
- package/dist/core/prompt-templates.js +0 -249
- package/dist/core/prompt-templates.js.map +0 -1
- package/dist/core/resolve-config-value.d.ts +0 -23
- package/dist/core/resolve-config-value.d.ts.map +0 -1
- package/dist/core/resolve-config-value.js +0 -126
- package/dist/core/resolve-config-value.js.map +0 -1
- package/dist/core/resource-loader.d.ts +0 -185
- package/dist/core/resource-loader.d.ts.map +0 -1
- package/dist/core/resource-loader.js +0 -720
- package/dist/core/resource-loader.js.map +0 -1
- package/dist/core/sdk.d.ts +0 -93
- package/dist/core/sdk.d.ts.map +0 -1
- package/dist/core/sdk.js +0 -236
- package/dist/core/sdk.js.map +0 -1
- package/dist/core/session-cwd.d.ts +0 -19
- package/dist/core/session-cwd.d.ts.map +0 -1
- package/dist/core/session-cwd.js +0 -38
- package/dist/core/session-cwd.js.map +0 -1
- package/dist/core/session-manager.d.ts +0 -333
- package/dist/core/session-manager.d.ts.map +0 -1
- package/dist/core/session-manager.js +0 -1105
- package/dist/core/session-manager.js.map +0 -1
- package/dist/core/settings-manager.d.ts +0 -237
- package/dist/core/settings-manager.d.ts.map +0 -1
- package/dist/core/settings-manager.js +0 -703
- package/dist/core/settings-manager.js.map +0 -1
- package/dist/core/skills.d.ts +0 -60
- package/dist/core/skills.d.ts.map +0 -1
- package/dist/core/skills.js +0 -409
- package/dist/core/skills.js.map +0 -1
- package/dist/core/slash-commands.d.ts +0 -14
- package/dist/core/slash-commands.d.ts.map +0 -1
- package/dist/core/slash-commands.js +0 -23
- package/dist/core/slash-commands.js.map +0 -1
- package/dist/core/source-info.d.ts +0 -18
- package/dist/core/source-info.d.ts.map +0 -1
- package/dist/core/source-info.js +0 -19
- package/dist/core/source-info.js.map +0 -1
- package/dist/core/system-prompt.d.ts +0 -28
- package/dist/core/system-prompt.d.ts.map +0 -1
- package/dist/core/system-prompt.js +0 -116
- package/dist/core/system-prompt.js.map +0 -1
- package/dist/core/timings.d.ts +0 -8
- package/dist/core/timings.d.ts.map +0 -1
- package/dist/core/timings.js +0 -31
- package/dist/core/timings.js.map +0 -1
- package/dist/core/tools/bash.d.ts +0 -73
- package/dist/core/tools/bash.d.ts.map +0 -1
- package/dist/core/tools/bash.js +0 -352
- package/dist/core/tools/bash.js.map +0 -1
- package/dist/core/tools/edit-diff.d.ts +0 -85
- package/dist/core/tools/edit-diff.d.ts.map +0 -1
- package/dist/core/tools/edit-diff.js +0 -337
- package/dist/core/tools/edit-diff.js.map +0 -1
- package/dist/core/tools/edit.d.ts +0 -53
- package/dist/core/tools/edit.d.ts.map +0 -1
- package/dist/core/tools/edit.js +0 -196
- package/dist/core/tools/edit.js.map +0 -1
- package/dist/core/tools/file-mutation-queue.d.ts +0 -6
- package/dist/core/tools/file-mutation-queue.d.ts.map +0 -1
- package/dist/core/tools/file-mutation-queue.js +0 -37
- package/dist/core/tools/file-mutation-queue.js.map +0 -1
- package/dist/core/tools/find.d.ts +0 -46
- package/dist/core/tools/find.d.ts.map +0 -1
- package/dist/core/tools/find.js +0 -258
- package/dist/core/tools/find.js.map +0 -1
- package/dist/core/tools/grep.d.ts +0 -56
- package/dist/core/tools/grep.d.ts.map +0 -1
- package/dist/core/tools/grep.js +0 -293
- package/dist/core/tools/grep.js.map +0 -1
- package/dist/core/tools/index.d.ts +0 -115
- package/dist/core/tools/index.d.ts.map +0 -1
- package/dist/core/tools/index.js +0 -86
- package/dist/core/tools/index.js.map +0 -1
- package/dist/core/tools/ls.d.ts +0 -46
- package/dist/core/tools/ls.d.ts.map +0 -1
- package/dist/core/tools/ls.js +0 -172
- package/dist/core/tools/ls.js.map +0 -1
- package/dist/core/tools/path-utils.d.ts +0 -8
- package/dist/core/tools/path-utils.d.ts.map +0 -1
- package/dist/core/tools/path-utils.js +0 -81
- package/dist/core/tools/path-utils.js.map +0 -1
- package/dist/core/tools/read.d.ts +0 -46
- package/dist/core/tools/read.d.ts.map +0 -1
- package/dist/core/tools/read.js +0 -225
- package/dist/core/tools/read.js.map +0 -1
- package/dist/core/tools/render-utils.d.ts +0 -21
- package/dist/core/tools/render-utils.d.ts.map +0 -1
- package/dist/core/tools/render-utils.js +0 -49
- package/dist/core/tools/render-utils.js.map +0 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts +0 -14
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +0 -1
- package/dist/core/tools/tool-definition-wrapper.js +0 -32
- package/dist/core/tools/tool-definition-wrapper.js.map +0 -1
- package/dist/core/tools/truncate.d.ts +0 -70
- package/dist/core/tools/truncate.d.ts.map +0 -1
- package/dist/core/tools/truncate.js +0 -205
- package/dist/core/tools/truncate.js.map +0 -1
- package/dist/core/tools/write.d.ts +0 -35
- package/dist/core/tools/write.d.ts.map +0 -1
- package/dist/core/tools/write.js +0 -216
- package/dist/core/tools/write.js.map +0 -1
- package/dist/index.d.ts +0 -28
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -43
- package/dist/index.js.map +0 -1
- package/dist/main.d.ts +0 -8
- package/dist/main.d.ts.map +0 -1
- package/dist/main.js +0 -593
- package/dist/main.js.map +0 -1
- package/dist/migrations.d.ts +0 -33
- package/dist/migrations.d.ts.map +0 -1
- package/dist/migrations.js +0 -281
- package/dist/migrations.js.map +0 -1
- package/dist/modes/index.d.ts +0 -9
- package/dist/modes/index.d.ts.map +0 -1
- package/dist/modes/index.js +0 -8
- package/dist/modes/index.js.map +0 -1
- package/dist/modes/interactive/components/armin.d.ts +0 -34
- package/dist/modes/interactive/components/armin.d.ts.map +0 -1
- package/dist/modes/interactive/components/armin.js +0 -333
- package/dist/modes/interactive/components/armin.js.map +0 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +0 -18
- package/dist/modes/interactive/components/assistant-message.d.ts.map +0 -1
- package/dist/modes/interactive/components/assistant-message.js +0 -107
- package/dist/modes/interactive/components/assistant-message.js.map +0 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +0 -34
- package/dist/modes/interactive/components/bash-execution.d.ts.map +0 -1
- package/dist/modes/interactive/components/bash-execution.js +0 -175
- package/dist/modes/interactive/components/bash-execution.js.map +0 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts +0 -16
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +0 -1
- package/dist/modes/interactive/components/bordered-loader.js +0 -51
- package/dist/modes/interactive/components/bordered-loader.js.map +0 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +0 -16
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +0 -1
- package/dist/modes/interactive/components/branch-summary-message.js +0 -44
- package/dist/modes/interactive/components/branch-summary-message.js.map +0 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +0 -16
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +0 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +0 -45
- package/dist/modes/interactive/components/compaction-summary-message.js.map +0 -1
- package/dist/modes/interactive/components/config-selector.d.ts +0 -71
- package/dist/modes/interactive/components/config-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/config-selector.js +0 -479
- package/dist/modes/interactive/components/config-selector.js.map +0 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts +0 -14
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +0 -1
- package/dist/modes/interactive/components/countdown-timer.js +0 -33
- package/dist/modes/interactive/components/countdown-timer.js.map +0 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +0 -21
- package/dist/modes/interactive/components/custom-editor.d.ts.map +0 -1
- package/dist/modes/interactive/components/custom-editor.js +0 -70
- package/dist/modes/interactive/components/custom-editor.js.map +0 -1
- package/dist/modes/interactive/components/custom-message.d.ts +0 -20
- package/dist/modes/interactive/components/custom-message.d.ts.map +0 -1
- package/dist/modes/interactive/components/custom-message.js +0 -79
- package/dist/modes/interactive/components/custom-message.js.map +0 -1
- package/dist/modes/interactive/components/daxnuts.d.ts +0 -23
- package/dist/modes/interactive/components/daxnuts.d.ts.map +0 -1
- package/dist/modes/interactive/components/daxnuts.js +0 -140
- package/dist/modes/interactive/components/daxnuts.js.map +0 -1
- package/dist/modes/interactive/components/diff.d.ts +0 -12
- package/dist/modes/interactive/components/diff.d.ts.map +0 -1
- package/dist/modes/interactive/components/diff.js +0 -133
- package/dist/modes/interactive/components/diff.js.map +0 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts +0 -15
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +0 -1
- package/dist/modes/interactive/components/dynamic-border.js +0 -21
- package/dist/modes/interactive/components/dynamic-border.js.map +0 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +0 -20
- package/dist/modes/interactive/components/extension-editor.d.ts.map +0 -1
- package/dist/modes/interactive/components/extension-editor.js +0 -111
- package/dist/modes/interactive/components/extension-editor.js.map +0 -1
- package/dist/modes/interactive/components/extension-input.d.ts +0 -23
- package/dist/modes/interactive/components/extension-input.d.ts.map +0 -1
- package/dist/modes/interactive/components/extension-input.js +0 -61
- package/dist/modes/interactive/components/extension-input.js.map +0 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +0 -24
- package/dist/modes/interactive/components/extension-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/extension-selector.js +0 -78
- package/dist/modes/interactive/components/extension-selector.js.map +0 -1
- package/dist/modes/interactive/components/footer.d.ts +0 -27
- package/dist/modes/interactive/components/footer.d.ts.map +0 -1
- package/dist/modes/interactive/components/footer.js +0 -201
- package/dist/modes/interactive/components/footer.js.map +0 -1
- package/dist/modes/interactive/components/index.d.ts +0 -32
- package/dist/modes/interactive/components/index.d.ts.map +0 -1
- package/dist/modes/interactive/components/index.js +0 -33
- package/dist/modes/interactive/components/index.js.map +0 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +0 -8
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +0 -1
- package/dist/modes/interactive/components/keybinding-hints.js +0 -22
- package/dist/modes/interactive/components/keybinding-hints.js.map +0 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +0 -42
- package/dist/modes/interactive/components/login-dialog.d.ts.map +0 -1
- package/dist/modes/interactive/components/login-dialog.js +0 -145
- package/dist/modes/interactive/components/login-dialog.js.map +0 -1
- package/dist/modes/interactive/components/model-selector.d.ts +0 -47
- package/dist/modes/interactive/components/model-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/model-selector.js +0 -275
- package/dist/modes/interactive/components/model-selector.js.map +0 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +0 -19
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/oauth-selector.js +0 -97
- package/dist/modes/interactive/components/oauth-selector.js.map +0 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +0 -49
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +0 -275
- package/dist/modes/interactive/components/scoped-models-selector.js.map +0 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts +0 -23
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +0 -1
- package/dist/modes/interactive/components/session-selector-search.js +0 -155
- package/dist/modes/interactive/components/session-selector-search.js.map +0 -1
- package/dist/modes/interactive/components/session-selector.d.ts +0 -95
- package/dist/modes/interactive/components/session-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/session-selector.js +0 -848
- package/dist/modes/interactive/components/session-selector.js.map +0 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +0 -58
- package/dist/modes/interactive/components/settings-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/settings-selector.js +0 -301
- package/dist/modes/interactive/components/settings-selector.js.map +0 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts +0 -10
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/show-images-selector.js +0 -39
- package/dist/modes/interactive/components/show-images-selector.js.map +0 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +0 -17
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +0 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +0 -47
- package/dist/modes/interactive/components/skill-invocation-message.js.map +0 -1
- package/dist/modes/interactive/components/theme-selector.d.ts +0 -11
- package/dist/modes/interactive/components/theme-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/theme-selector.js +0 -50
- package/dist/modes/interactive/components/theme-selector.js.map +0 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts +0 -11
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/thinking-selector.js +0 -51
- package/dist/modes/interactive/components/thinking-selector.js.map +0 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +0 -58
- package/dist/modes/interactive/components/tool-execution.d.ts.map +0 -1
- package/dist/modes/interactive/components/tool-execution.js +0 -274
- package/dist/modes/interactive/components/tool-execution.js.map +0 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +0 -89
- package/dist/modes/interactive/components/tree-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/tree-selector.js +0 -1084
- package/dist/modes/interactive/components/tree-selector.js.map +0 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts +0 -30
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +0 -1
- package/dist/modes/interactive/components/user-message-selector.js +0 -113
- package/dist/modes/interactive/components/user-message-selector.js.map +0 -1
- package/dist/modes/interactive/components/user-message.d.ts +0 -9
- package/dist/modes/interactive/components/user-message.d.ts.map +0 -1
- package/dist/modes/interactive/components/user-message.js +0 -28
- package/dist/modes/interactive/components/user-message.js.map +0 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts +0 -24
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +0 -1
- package/dist/modes/interactive/components/visual-truncate.js +0 -33
- package/dist/modes/interactive/components/visual-truncate.js.map +0 -1
- package/dist/modes/interactive/interactive-mode.d.ts +0 -320
- package/dist/modes/interactive/interactive-mode.d.ts.map +0 -1
- package/dist/modes/interactive/interactive-mode.js +0 -3970
- package/dist/modes/interactive/interactive-mode.js.map +0 -1
- package/dist/modes/interactive/theme/dark.json +0 -85
- package/dist/modes/interactive/theme/light.json +0 -84
- package/dist/modes/interactive/theme/theme-schema.json +0 -335
- package/dist/modes/interactive/theme/theme.d.ts +0 -81
- package/dist/modes/interactive/theme/theme.d.ts.map +0 -1
- package/dist/modes/interactive/theme/theme.js +0 -979
- package/dist/modes/interactive/theme/theme.js.map +0 -1
- package/dist/modes/print-mode.d.ts +0 -28
- package/dist/modes/print-mode.d.ts.map +0 -1
- package/dist/modes/print-mode.js +0 -112
- package/dist/modes/print-mode.js.map +0 -1
- package/dist/modes/rpc/jsonl.d.ts +0 -17
- package/dist/modes/rpc/jsonl.d.ts.map +0 -1
- package/dist/modes/rpc/jsonl.js +0 -49
- package/dist/modes/rpc/jsonl.js.map +0 -1
- package/dist/modes/rpc/rpc-client.d.ts +0 -217
- package/dist/modes/rpc/rpc-client.d.ts.map +0 -1
- package/dist/modes/rpc/rpc-client.js +0 -402
- package/dist/modes/rpc/rpc-client.js.map +0 -1
- package/dist/modes/rpc/rpc-mode.d.ts +0 -20
- package/dist/modes/rpc/rpc-mode.d.ts.map +0 -1
- package/dist/modes/rpc/rpc-mode.js +0 -550
- package/dist/modes/rpc/rpc-mode.js.map +0 -1
- package/dist/modes/rpc/rpc-types.d.ts +0 -408
- package/dist/modes/rpc/rpc-types.d.ts.map +0 -1
- package/dist/modes/rpc/rpc-types.js +0 -8
- package/dist/modes/rpc/rpc-types.js.map +0 -1
- package/dist/package-manager-cli.d.ts +0 -4
- package/dist/package-manager-cli.d.ts.map +0 -1
- package/dist/package-manager-cli.js +0 -234
- package/dist/package-manager-cli.js.map +0 -1
- package/dist/utils/changelog.d.ts +0 -21
- package/dist/utils/changelog.d.ts.map +0 -1
- package/dist/utils/changelog.js +0 -87
- package/dist/utils/changelog.js.map +0 -1
- package/dist/utils/child-process.d.ts +0 -11
- package/dist/utils/child-process.d.ts.map +0 -1
- package/dist/utils/child-process.js +0 -78
- package/dist/utils/child-process.js.map +0 -1
- package/dist/utils/clipboard-image.d.ts +0 -11
- package/dist/utils/clipboard-image.d.ts.map +0 -1
- package/dist/utils/clipboard-image.js +0 -245
- package/dist/utils/clipboard-image.js.map +0 -1
- package/dist/utils/clipboard-native.d.ts +0 -8
- package/dist/utils/clipboard-native.d.ts.map +0 -1
- package/dist/utils/clipboard-native.js +0 -14
- package/dist/utils/clipboard-native.js.map +0 -1
- package/dist/utils/clipboard.d.ts +0 -2
- package/dist/utils/clipboard.d.ts.map +0 -1
- package/dist/utils/clipboard.js +0 -78
- package/dist/utils/clipboard.js.map +0 -1
- package/dist/utils/exif-orientation.d.ts +0 -5
- package/dist/utils/exif-orientation.d.ts.map +0 -1
- package/dist/utils/exif-orientation.js +0 -158
- package/dist/utils/exif-orientation.js.map +0 -1
- package/dist/utils/frontmatter.d.ts +0 -8
- package/dist/utils/frontmatter.d.ts.map +0 -1
- package/dist/utils/frontmatter.js +0 -26
- package/dist/utils/frontmatter.js.map +0 -1
- package/dist/utils/git.d.ts +0 -26
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js +0 -163
- package/dist/utils/git.js.map +0 -1
- package/dist/utils/image-convert.d.ts +0 -9
- package/dist/utils/image-convert.d.ts.map +0 -1
- package/dist/utils/image-convert.js +0 -39
- package/dist/utils/image-convert.js.map +0 -1
- package/dist/utils/image-resize.d.ts +0 -36
- package/dist/utils/image-resize.d.ts.map +0 -1
- package/dist/utils/image-resize.js +0 -137
- package/dist/utils/image-resize.js.map +0 -1
- package/dist/utils/mime.d.ts +0 -2
- package/dist/utils/mime.d.ts.map +0 -1
- package/dist/utils/mime.js +0 -26
- package/dist/utils/mime.js.map +0 -1
- package/dist/utils/paths.d.ts +0 -7
- package/dist/utils/paths.d.ts.map +0 -1
- package/dist/utils/paths.js +0 -19
- package/dist/utils/paths.js.map +0 -1
- package/dist/utils/photon.d.ts +0 -21
- package/dist/utils/photon.d.ts.map +0 -1
- package/dist/utils/photon.js +0 -121
- package/dist/utils/photon.js.map +0 -1
- package/dist/utils/shell.d.ts +0 -26
- package/dist/utils/shell.d.ts.map +0 -1
- package/dist/utils/shell.js +0 -186
- package/dist/utils/shell.js.map +0 -1
- package/dist/utils/sleep.d.ts +0 -5
- package/dist/utils/sleep.d.ts.map +0 -1
- package/dist/utils/sleep.js +0 -17
- package/dist/utils/sleep.js.map +0 -1
- package/dist/utils/tools-manager.d.ts +0 -3
- package/dist/utils/tools-manager.d.ts.map +0 -1
- package/dist/utils/tools-manager.js +0 -252
- package/dist/utils/tools-manager.js.map +0 -1
- package/docs/compaction.md +0 -398
- package/docs/custom-provider.md +0 -597
- package/docs/development.md +0 -72
- package/docs/extensions.md +0 -2288
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/json.md +0 -84
- package/docs/keybindings.md +0 -175
- package/docs/models.md +0 -349
- package/docs/packages.md +0 -219
- package/docs/prompt-templates.md +0 -67
- package/docs/providers.md +0 -200
- package/docs/rpc.md +0 -1425
- package/docs/sdk.md +0 -1136
- package/docs/session.md +0 -423
- package/docs/settings.md +0 -246
- package/docs/shell-aliases.md +0 -13
- package/docs/skills.md +0 -236
- package/docs/terminal-setup.md +0 -108
- package/docs/termux.md +0 -137
- package/docs/themes.md +0 -296
- package/docs/tmux.md +0 -61
- package/docs/tree.md +0 -239
- package/docs/tui.md +0 -890
- package/docs/windows.md +0 -17
- package/examples/extensions/antigravity-image-gen.ts +0 -418
- package/examples/extensions/auto-commit-on-exit.ts +0 -49
- package/examples/extensions/bash-spawn-hook.ts +0 -30
- package/examples/extensions/bookmark.ts +0 -50
- package/examples/extensions/built-in-tool-renderer.ts +0 -246
- package/examples/extensions/claude-rules.ts +0 -86
- package/examples/extensions/commands.ts +0 -72
- package/examples/extensions/confirm-destructive.ts +0 -59
- package/examples/extensions/custom-compaction.ts +0 -127
- package/examples/extensions/custom-footer.ts +0 -64
- package/examples/extensions/custom-header.ts +0 -73
- package/examples/extensions/custom-provider-anthropic/index.ts +0 -604
- package/examples/extensions/custom-provider-anthropic/package-lock.json +0 -24
- package/examples/extensions/custom-provider-anthropic/package.json +0 -19
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +0 -349
- package/examples/extensions/custom-provider-gitlab-duo/package.json +0 -16
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +0 -82
- package/examples/extensions/custom-provider-qwen-cli/index.ts +0 -345
- package/examples/extensions/custom-provider-qwen-cli/package.json +0 -16
- package/examples/extensions/dirty-repo-guard.ts +0 -56
- package/examples/extensions/doom-overlay/README.md +0 -48
- package/examples/extensions/doom-overlay/doom/build/doom.js +0 -21
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +0 -152
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +0 -72
- package/examples/extensions/doom-overlay/doom-component.ts +0 -132
- package/examples/extensions/doom-overlay/doom-engine.ts +0 -173
- package/examples/extensions/doom-overlay/doom-keys.ts +0 -104
- package/examples/extensions/doom-overlay/index.ts +0 -74
- package/examples/extensions/doom-overlay/wad-finder.ts +0 -51
- package/examples/extensions/dynamic-resources/SKILL.md +0 -8
- package/examples/extensions/dynamic-resources/dynamic.json +0 -79
- package/examples/extensions/dynamic-resources/dynamic.md +0 -5
- package/examples/extensions/dynamic-resources/index.ts +0 -15
- package/examples/extensions/dynamic-tools.ts +0 -74
- package/examples/extensions/event-bus.ts +0 -43
- package/examples/extensions/file-trigger.ts +0 -41
- package/examples/extensions/git-checkpoint.ts +0 -53
- package/examples/extensions/handoff.ts +0 -153
- package/examples/extensions/hidden-thinking-label.ts +0 -53
- package/examples/extensions/inline-bash.ts +0 -94
- package/examples/extensions/input-transform.ts +0 -43
- package/examples/extensions/interactive-shell.ts +0 -196
- package/examples/extensions/mac-system-theme.ts +0 -47
- package/examples/extensions/message-renderer.ts +0 -59
- package/examples/extensions/minimal-mode.ts +0 -426
- package/examples/extensions/modal-editor.ts +0 -85
- package/examples/extensions/model-status.ts +0 -31
- package/examples/extensions/notify.ts +0 -55
- package/examples/extensions/overlay-qa-tests.ts +0 -1348
- package/examples/extensions/overlay-test.ts +0 -150
- package/examples/extensions/permission-gate.ts +0 -34
- package/examples/extensions/plan-mode/README.md +0 -69
- package/examples/extensions/plan-mode/index.ts +0 -340
- package/examples/extensions/plan-mode/utils.ts +0 -168
- package/examples/extensions/preset.ts +0 -403
- package/examples/extensions/protected-paths.ts +0 -30
- package/examples/extensions/provider-payload.ts +0 -14
- package/examples/extensions/qna.ts +0 -122
- package/examples/extensions/question.ts +0 -264
- package/examples/extensions/questionnaire.ts +0 -427
- package/examples/extensions/rainbow-editor.ts +0 -88
- package/examples/extensions/rpc-demo.ts +0 -118
- package/examples/extensions/sandbox/index.ts +0 -321
- package/examples/extensions/sandbox/package-lock.json +0 -92
- package/examples/extensions/sandbox/package.json +0 -19
- package/examples/extensions/send-user-message.ts +0 -97
- package/examples/extensions/session-name.ts +0 -27
- package/examples/extensions/shutdown-command.ts +0 -63
- package/examples/extensions/snake.ts +0 -343
- package/examples/extensions/space-invaders.ts +0 -560
- package/examples/extensions/ssh.ts +0 -220
- package/examples/extensions/status-line.ts +0 -32
- package/examples/extensions/subagent/README.md +0 -181
- package/examples/extensions/subagent/agents/planner.md +0 -37
- package/examples/extensions/subagent/agents/reviewer.md +0 -35
- package/examples/extensions/subagent/agents/scout.md +0 -50
- package/examples/extensions/subagent/agents/worker.md +0 -24
- package/examples/extensions/subagent/agents.ts +0 -126
- package/examples/extensions/subagent/index.ts +0 -986
- package/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
- package/examples/extensions/subagent/prompts/implement.md +0 -10
- package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
- package/examples/extensions/summarize.ts +0 -206
- package/examples/extensions/system-prompt-header.ts +0 -17
- package/examples/extensions/timed-confirm.ts +0 -70
- package/examples/extensions/titlebar-spinner.ts +0 -58
- package/examples/extensions/tool-override.ts +0 -144
- package/examples/extensions/trigger-compact.ts +0 -50
- package/examples/extensions/truncated-tool.ts +0 -195
- package/examples/extensions/widget-placement.ts +0 -9
- package/examples/rpc-extension-ui.ts +0 -640
- package/examples/sdk/05-tools.ts +0 -56
- package/examples/sdk/10-settings.ts +0 -51
- package/examples/sdk/12-full-control.ts +0 -81
- package/examples/sdk/13-session-runtime.ts +0 -67
- /package/{dist/core/export-html → src/export/html}/vendor/highlight.min.js +0 -0
- /package/{dist/core/export-html → src/export/html}/vendor/marked.min.js +0 -0
|
@@ -0,0 +1,1375 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import type {
|
|
4
|
+
AgentTool,
|
|
5
|
+
AgentToolContext,
|
|
6
|
+
AgentToolResult,
|
|
7
|
+
AgentToolUpdateCallback,
|
|
8
|
+
} from "@f5xc-salesdemos/pi-agent-core";
|
|
9
|
+
import type { ImageContent, TextContent } from "@f5xc-salesdemos/pi-ai";
|
|
10
|
+
import { glob } from "@f5xc-salesdemos/pi-natives";
|
|
11
|
+
import type { Component } from "@f5xc-salesdemos/pi-tui";
|
|
12
|
+
import { Text } from "@f5xc-salesdemos/pi-tui";
|
|
13
|
+
import { getRemoteDir, prompt, readImageMetadata, untilAborted } from "@f5xc-salesdemos/pi-utils";
|
|
14
|
+
import { type Static, Type } from "@sinclair/typebox";
|
|
15
|
+
import { computeLineHash } from "../edit/line-hash";
|
|
16
|
+
import {
|
|
17
|
+
type ChunkReadTarget,
|
|
18
|
+
formatChunkedRead,
|
|
19
|
+
parseChunkReadPath,
|
|
20
|
+
parseChunkSelector,
|
|
21
|
+
resolveAnchorStyle,
|
|
22
|
+
} from "../edit/modes/chunk";
|
|
23
|
+
import type { RenderResultOptions } from "../extensibility/custom-tools/types";
|
|
24
|
+
import { parseInternalUrl } from "../internal-urls/parse";
|
|
25
|
+
import type { InternalUrl } from "../internal-urls/types";
|
|
26
|
+
import { getLanguageFromPath, type Theme } from "../modes/theme/theme";
|
|
27
|
+
import readDescription from "../prompts/tools/read.md" with { type: "text" };
|
|
28
|
+
import readChunkDescription from "../prompts/tools/read-chunk.md" with { type: "text" };
|
|
29
|
+
import type { ToolSession } from "../sdk";
|
|
30
|
+
import {
|
|
31
|
+
DEFAULT_MAX_BYTES,
|
|
32
|
+
DEFAULT_MAX_LINES,
|
|
33
|
+
noTruncResult,
|
|
34
|
+
type TruncationResult,
|
|
35
|
+
truncateHead,
|
|
36
|
+
truncateHeadBytes,
|
|
37
|
+
} from "../session/streaming-output";
|
|
38
|
+
import { renderCodeCell, renderStatusLine } from "../tui";
|
|
39
|
+
import { CachedOutputBlock } from "../tui/output-block";
|
|
40
|
+
import { resolveEditMode } from "../utils/edit-mode";
|
|
41
|
+
import { resolveFileDisplayMode } from "../utils/file-display-mode";
|
|
42
|
+
import { ImageInputTooLargeError, loadImageInput, MAX_IMAGE_INPUT_BYTES } from "../utils/image-loading";
|
|
43
|
+
import { convertFileWithMarkit } from "../utils/markit";
|
|
44
|
+
import { type ArchiveReader, openArchive, parseArchivePathCandidates } from "./archive-reader";
|
|
45
|
+
|
|
46
|
+
import {
|
|
47
|
+
executeReadUrl,
|
|
48
|
+
isReadableUrlPath,
|
|
49
|
+
loadReadUrlCacheEntry,
|
|
50
|
+
parseReadUrlTarget,
|
|
51
|
+
type ReadUrlToolDetails,
|
|
52
|
+
renderReadUrlCall,
|
|
53
|
+
renderReadUrlResult,
|
|
54
|
+
} from "./fetch";
|
|
55
|
+
import { applyListLimit } from "./list-limit";
|
|
56
|
+
import { formatFullOutputReference, formatStyledTruncationWarning, type OutputMeta } from "./output-meta";
|
|
57
|
+
import { expandPath, resolveReadPath } from "./path-utils";
|
|
58
|
+
import { formatAge, formatBytes, shortenPath, wrapBrackets } from "./render-utils";
|
|
59
|
+
import { ToolAbortError, ToolError, throwIfAborted } from "./tool-errors";
|
|
60
|
+
import { toolResult } from "./tool-result";
|
|
61
|
+
|
|
62
|
+
const PROSE_LANGUAGES = new Set(["markdown", "text", "log", "asciidoc", "restructuredtext"]);
|
|
63
|
+
|
|
64
|
+
function isProseLanguage(language: string | undefined): boolean {
|
|
65
|
+
return language !== undefined && PROSE_LANGUAGES.has(language);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Document types converted to markdown via markit.
|
|
69
|
+
const CONVERTIBLE_EXTENSIONS = new Set([".pdf", ".doc", ".docx", ".ppt", ".pptx", ".xls", ".xlsx", ".rtf", ".epub"]);
|
|
70
|
+
|
|
71
|
+
// Remote mount path prefix (sshfs mounts) - skip fuzzy matching to avoid hangs
|
|
72
|
+
const REMOTE_MOUNT_PREFIX = getRemoteDir() + path.sep;
|
|
73
|
+
|
|
74
|
+
function isRemoteMountPath(absolutePath: string): boolean {
|
|
75
|
+
return absolutePath.startsWith(REMOTE_MOUNT_PREFIX);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function prependLineNumbers(text: string, startNum: number): string {
|
|
79
|
+
const textLines = text.split("\n");
|
|
80
|
+
const lastLineNum = startNum + textLines.length - 1;
|
|
81
|
+
const padWidth = String(lastLineNum).length;
|
|
82
|
+
return textLines
|
|
83
|
+
.map((line, i) => {
|
|
84
|
+
const lineNum = String(startNum + i).padStart(padWidth, " ");
|
|
85
|
+
return `${lineNum}|${line}`;
|
|
86
|
+
})
|
|
87
|
+
.join("\n");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function prependHashLines(text: string, startNum: number): string {
|
|
91
|
+
const textLines = text.split("\n");
|
|
92
|
+
return textLines.map((line, i) => `${startNum + i}#${computeLineHash(startNum + i, line)}:${line}`).join("\n");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function formatTextWithMode(
|
|
96
|
+
text: string,
|
|
97
|
+
startNum: number,
|
|
98
|
+
shouldAddHashLines: boolean,
|
|
99
|
+
shouldAddLineNumbers: boolean,
|
|
100
|
+
): string {
|
|
101
|
+
if (shouldAddHashLines) return prependHashLines(text, startNum);
|
|
102
|
+
if (shouldAddLineNumbers) return prependLineNumbers(text, startNum);
|
|
103
|
+
return text;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const READ_CHUNK_SIZE = 8 * 1024;
|
|
107
|
+
|
|
108
|
+
async function streamLinesFromFile(
|
|
109
|
+
filePath: string,
|
|
110
|
+
startLine: number,
|
|
111
|
+
maxLinesToCollect: number,
|
|
112
|
+
maxBytes: number,
|
|
113
|
+
selectedLineLimit: number | null,
|
|
114
|
+
signal?: AbortSignal,
|
|
115
|
+
): Promise<{
|
|
116
|
+
lines: string[];
|
|
117
|
+
totalFileLines: number;
|
|
118
|
+
collectedBytes: number;
|
|
119
|
+
stoppedByByteLimit: boolean;
|
|
120
|
+
firstLinePreview?: { text: string; bytes: number };
|
|
121
|
+
firstLineByteLength?: number;
|
|
122
|
+
selectedBytesTotal: number;
|
|
123
|
+
}> {
|
|
124
|
+
const bufferChunk = Buffer.allocUnsafe(READ_CHUNK_SIZE);
|
|
125
|
+
const collectedLines: string[] = [];
|
|
126
|
+
let lineIndex = 0;
|
|
127
|
+
let collectedBytes = 0;
|
|
128
|
+
let stoppedByByteLimit = false;
|
|
129
|
+
let doneCollecting = false;
|
|
130
|
+
let fileHandle: fs.FileHandle | null = null;
|
|
131
|
+
let currentLineLength = 0;
|
|
132
|
+
let currentLineChunks: Buffer[] = [];
|
|
133
|
+
let sawAnyByte = false;
|
|
134
|
+
let endedWithNewline = false;
|
|
135
|
+
let firstLinePreviewBytes = 0;
|
|
136
|
+
const firstLinePreviewChunks: Buffer[] = [];
|
|
137
|
+
let firstLineByteLength: number | undefined;
|
|
138
|
+
let selectedBytesTotal = 0;
|
|
139
|
+
let selectedLinesSeen = 0;
|
|
140
|
+
let captureLine = false;
|
|
141
|
+
let discardLineChunks = false;
|
|
142
|
+
let lineCaptureLimit = 0;
|
|
143
|
+
|
|
144
|
+
const setupLineState = () => {
|
|
145
|
+
captureLine = !doneCollecting && lineIndex >= startLine;
|
|
146
|
+
discardLineChunks = !captureLine;
|
|
147
|
+
if (captureLine) {
|
|
148
|
+
const separatorBytes = collectedLines.length > 0 ? 1 : 0;
|
|
149
|
+
lineCaptureLimit = maxBytes - collectedBytes - separatorBytes;
|
|
150
|
+
if (lineCaptureLimit <= 0) {
|
|
151
|
+
discardLineChunks = true;
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
lineCaptureLimit = 0;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const decodeLine = (): string => {
|
|
159
|
+
if (currentLineLength === 0) return "";
|
|
160
|
+
if (currentLineChunks.length === 1 && currentLineChunks[0]?.length === currentLineLength) {
|
|
161
|
+
return currentLineChunks[0].toString("utf-8");
|
|
162
|
+
}
|
|
163
|
+
return Buffer.concat(currentLineChunks, currentLineLength).toString("utf-8");
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const maybeCapturePreview = (segment: Uint8Array) => {
|
|
167
|
+
if (doneCollecting || lineIndex < startLine || collectedLines.length !== 0) return;
|
|
168
|
+
if (firstLinePreviewBytes >= maxBytes || segment.length === 0) return;
|
|
169
|
+
const remaining = maxBytes - firstLinePreviewBytes;
|
|
170
|
+
const slice = segment.length > remaining ? segment.subarray(0, remaining) : segment;
|
|
171
|
+
if (slice.length === 0) return;
|
|
172
|
+
firstLinePreviewChunks.push(Buffer.from(slice));
|
|
173
|
+
firstLinePreviewBytes += slice.length;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const appendSegment = (segment: Uint8Array) => {
|
|
177
|
+
currentLineLength += segment.length;
|
|
178
|
+
maybeCapturePreview(segment);
|
|
179
|
+
if (!captureLine || discardLineChunks || segment.length === 0) return;
|
|
180
|
+
if (currentLineLength <= lineCaptureLimit) {
|
|
181
|
+
currentLineChunks.push(Buffer.from(segment));
|
|
182
|
+
} else {
|
|
183
|
+
discardLineChunks = true;
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const finalizeLine = () => {
|
|
188
|
+
if (lineIndex >= startLine && (selectedLineLimit === null || selectedLinesSeen < selectedLineLimit)) {
|
|
189
|
+
selectedBytesTotal += currentLineLength + (selectedLinesSeen > 0 ? 1 : 0);
|
|
190
|
+
selectedLinesSeen++;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (!doneCollecting && lineIndex >= startLine) {
|
|
194
|
+
const separatorBytes = collectedLines.length > 0 ? 1 : 0;
|
|
195
|
+
if (collectedLines.length >= maxLinesToCollect) {
|
|
196
|
+
doneCollecting = true;
|
|
197
|
+
} else if (collectedLines.length === 0 && currentLineLength > maxBytes) {
|
|
198
|
+
stoppedByByteLimit = true;
|
|
199
|
+
doneCollecting = true;
|
|
200
|
+
if (firstLineByteLength === undefined) {
|
|
201
|
+
firstLineByteLength = currentLineLength;
|
|
202
|
+
}
|
|
203
|
+
} else if (collectedLines.length > 0 && collectedBytes + separatorBytes + currentLineLength > maxBytes) {
|
|
204
|
+
stoppedByByteLimit = true;
|
|
205
|
+
doneCollecting = true;
|
|
206
|
+
} else {
|
|
207
|
+
const lineText = decodeLine();
|
|
208
|
+
collectedLines.push(lineText);
|
|
209
|
+
collectedBytes += separatorBytes + currentLineLength;
|
|
210
|
+
if (firstLineByteLength === undefined) {
|
|
211
|
+
firstLineByteLength = currentLineLength;
|
|
212
|
+
}
|
|
213
|
+
if (collectedBytes > maxBytes) {
|
|
214
|
+
stoppedByByteLimit = true;
|
|
215
|
+
doneCollecting = true;
|
|
216
|
+
} else if (collectedLines.length >= maxLinesToCollect) {
|
|
217
|
+
doneCollecting = true;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
} else if (lineIndex >= startLine && firstLineByteLength === undefined) {
|
|
221
|
+
firstLineByteLength = currentLineLength;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
lineIndex++;
|
|
225
|
+
currentLineLength = 0;
|
|
226
|
+
currentLineChunks = [];
|
|
227
|
+
setupLineState();
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
setupLineState();
|
|
231
|
+
|
|
232
|
+
try {
|
|
233
|
+
fileHandle = await fs.open(filePath, "r");
|
|
234
|
+
|
|
235
|
+
while (true) {
|
|
236
|
+
throwIfAborted(signal);
|
|
237
|
+
const { bytesRead } = await fileHandle.read(bufferChunk, 0, bufferChunk.length, null);
|
|
238
|
+
if (bytesRead === 0) break;
|
|
239
|
+
|
|
240
|
+
sawAnyByte = true;
|
|
241
|
+
const chunk = bufferChunk.subarray(0, bytesRead);
|
|
242
|
+
endedWithNewline = chunk[bytesRead - 1] === 0x0a;
|
|
243
|
+
|
|
244
|
+
let start = 0;
|
|
245
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
246
|
+
if (chunk[i] === 0x0a) {
|
|
247
|
+
const segment = chunk.subarray(start, i);
|
|
248
|
+
if (segment.length > 0) {
|
|
249
|
+
appendSegment(segment);
|
|
250
|
+
}
|
|
251
|
+
finalizeLine();
|
|
252
|
+
start = i + 1;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (start < chunk.length) {
|
|
257
|
+
appendSegment(chunk.subarray(start));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
} finally {
|
|
261
|
+
if (fileHandle) {
|
|
262
|
+
await fileHandle.close();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (endedWithNewline || currentLineLength > 0 || !sawAnyByte) {
|
|
267
|
+
finalizeLine();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
let firstLinePreview: { text: string; bytes: number } | undefined;
|
|
271
|
+
if (firstLinePreviewBytes > 0) {
|
|
272
|
+
const { text, bytes } = truncateHeadBytes(Buffer.concat(firstLinePreviewChunks, firstLinePreviewBytes), maxBytes);
|
|
273
|
+
firstLinePreview = { text, bytes };
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
lines: collectedLines,
|
|
278
|
+
totalFileLines: lineIndex,
|
|
279
|
+
collectedBytes,
|
|
280
|
+
stoppedByByteLimit,
|
|
281
|
+
firstLinePreview,
|
|
282
|
+
firstLineByteLength,
|
|
283
|
+
selectedBytesTotal,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Maximum image file size (20MB) - larger images will be rejected to prevent OOM during serialization
|
|
288
|
+
const MAX_IMAGE_SIZE = MAX_IMAGE_INPUT_BYTES;
|
|
289
|
+
const GLOB_TIMEOUT_MS = 5000;
|
|
290
|
+
|
|
291
|
+
function isNotFoundError(error: unknown): boolean {
|
|
292
|
+
if (!error || typeof error !== "object") return false;
|
|
293
|
+
const code = (error as { code?: string }).code;
|
|
294
|
+
return code === "ENOENT" || code === "ENOTDIR";
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Attempt to resolve a non-existent path by finding a unique suffix match within the workspace.
|
|
299
|
+
* Uses a glob suffix pattern so the native engine handles matching directly.
|
|
300
|
+
* Returns null when 0 or >1 candidates match (ambiguous = no auto-resolution).
|
|
301
|
+
*/
|
|
302
|
+
async function findUniqueSuffixMatch(
|
|
303
|
+
rawPath: string,
|
|
304
|
+
cwd: string,
|
|
305
|
+
signal?: AbortSignal,
|
|
306
|
+
): Promise<{ absolutePath: string; displayPath: string } | null> {
|
|
307
|
+
const normalized = rawPath.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "");
|
|
308
|
+
if (!normalized) return null;
|
|
309
|
+
|
|
310
|
+
const timeoutSignal = AbortSignal.timeout(GLOB_TIMEOUT_MS);
|
|
311
|
+
const combinedSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
|
|
312
|
+
|
|
313
|
+
let matches: string[];
|
|
314
|
+
try {
|
|
315
|
+
const result = await untilAborted(combinedSignal, () =>
|
|
316
|
+
glob({
|
|
317
|
+
pattern: `**/${normalized}`,
|
|
318
|
+
path: cwd,
|
|
319
|
+
// No fileType filter: matches both files and directories
|
|
320
|
+
hidden: true,
|
|
321
|
+
}),
|
|
322
|
+
);
|
|
323
|
+
matches = result.matches.map(m => m.path);
|
|
324
|
+
} catch (error) {
|
|
325
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
326
|
+
if (!signal?.aborted) return null; // timeout — give up silently
|
|
327
|
+
throw new ToolAbortError();
|
|
328
|
+
}
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (matches.length !== 1) return null;
|
|
333
|
+
|
|
334
|
+
return {
|
|
335
|
+
absolutePath: path.resolve(cwd, matches[0]),
|
|
336
|
+
displayPath: matches[0],
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function decodeUtf8Text(bytes: Uint8Array): string | null {
|
|
341
|
+
for (const byte of bytes) {
|
|
342
|
+
if (byte === 0) return null;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
try {
|
|
346
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
347
|
+
} catch {
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function prependSuffixResolutionNotice(text: string, suffixResolution?: { from: string; to: string }): string {
|
|
353
|
+
if (!suffixResolution) return text;
|
|
354
|
+
|
|
355
|
+
const notice = `[Path '${suffixResolution.from}' not found; resolved to '${suffixResolution.to}' via suffix match]`;
|
|
356
|
+
return text ? `${notice}\n${text}` : notice;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const readSchema = Type.Object({
|
|
360
|
+
path: Type.String({ description: "Path or URL to read" }),
|
|
361
|
+
sel: Type.Optional(Type.String({ description: "Selector: chunk path, L10-L50, or raw" })),
|
|
362
|
+
timeout: Type.Optional(Type.Number({ description: "Timeout in seconds (default: 20)" })),
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
export type ReadToolInput = Static<typeof readSchema>;
|
|
366
|
+
|
|
367
|
+
export interface ReadToolDetails {
|
|
368
|
+
kind?: "file" | "url";
|
|
369
|
+
truncation?: TruncationResult;
|
|
370
|
+
isDirectory?: boolean;
|
|
371
|
+
resolvedPath?: string;
|
|
372
|
+
suffixResolution?: { from: string; to: string };
|
|
373
|
+
chunk?: ChunkReadTarget;
|
|
374
|
+
url?: string;
|
|
375
|
+
finalUrl?: string;
|
|
376
|
+
contentType?: string;
|
|
377
|
+
method?: string;
|
|
378
|
+
notes?: string[];
|
|
379
|
+
meta?: OutputMeta;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
type ReadParams = ReadToolInput;
|
|
383
|
+
|
|
384
|
+
/** Parsed representation of the `sel` parameter. */
|
|
385
|
+
type ParsedSelector =
|
|
386
|
+
| { kind: "none" }
|
|
387
|
+
| { kind: "raw" }
|
|
388
|
+
| { kind: "lines"; startLine: number; endLine: number | undefined }
|
|
389
|
+
| { kind: "chunk"; selector: string };
|
|
390
|
+
|
|
391
|
+
const LINE_RANGE_RE = /^L(\d+)(?:-L?(\d+))?$/i;
|
|
392
|
+
|
|
393
|
+
function parseSel(sel: string | undefined): ParsedSelector {
|
|
394
|
+
if (!sel || sel.length === 0) return { kind: "none" };
|
|
395
|
+
const normalizedSelector = parseChunkSelector(sel).selector ?? sel;
|
|
396
|
+
if (normalizedSelector === "raw") return { kind: "raw" };
|
|
397
|
+
const lineMatch = LINE_RANGE_RE.exec(normalizedSelector);
|
|
398
|
+
if (lineMatch) {
|
|
399
|
+
const rawStart = Number.parseInt(lineMatch[1]!, 10);
|
|
400
|
+
if (rawStart < 1) {
|
|
401
|
+
throw new ToolError("L0 is invalid; lines are 1-indexed. Use sel=L1.");
|
|
402
|
+
}
|
|
403
|
+
const rawEnd = lineMatch[2] ? Number.parseInt(lineMatch[2], 10) : undefined;
|
|
404
|
+
if (rawEnd !== undefined && rawEnd < rawStart) {
|
|
405
|
+
throw new ToolError(`Invalid range L${rawStart}-L${rawEnd}: end must be >= start.`);
|
|
406
|
+
}
|
|
407
|
+
return { kind: "lines", startLine: rawStart, endLine: rawEnd };
|
|
408
|
+
}
|
|
409
|
+
return { kind: "chunk", selector: normalizedSelector };
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** Convert a line-range selector to the offset/limit pair used by internal pagination. */
|
|
413
|
+
function selToOffsetLimit(parsed: ParsedSelector): { offset?: number; limit?: number } {
|
|
414
|
+
if (parsed.kind === "lines") {
|
|
415
|
+
const limit = parsed.endLine !== undefined ? parsed.endLine - parsed.startLine + 1 : undefined;
|
|
416
|
+
return { offset: parsed.startLine, limit };
|
|
417
|
+
}
|
|
418
|
+
return {};
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
interface ResolvedArchiveReadPath {
|
|
422
|
+
absolutePath: string;
|
|
423
|
+
archiveSubPath: string;
|
|
424
|
+
suffixResolution?: { from: string; to: string };
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Read tool implementation.
|
|
429
|
+
*
|
|
430
|
+
* Reads files with support for images, converted documents (via markit), and text.
|
|
431
|
+
* Directories return a formatted listing with modification times.
|
|
432
|
+
*/
|
|
433
|
+
export class ReadTool implements AgentTool<typeof readSchema, ReadToolDetails> {
|
|
434
|
+
readonly name = "read";
|
|
435
|
+
readonly label = "Read";
|
|
436
|
+
readonly description: string;
|
|
437
|
+
readonly parameters = readSchema;
|
|
438
|
+
readonly nonAbortable = true;
|
|
439
|
+
readonly strict = true;
|
|
440
|
+
|
|
441
|
+
readonly #autoResizeImages: boolean;
|
|
442
|
+
readonly #defaultLimit: number;
|
|
443
|
+
readonly #inspectImageEnabled: boolean;
|
|
444
|
+
|
|
445
|
+
constructor(private readonly session: ToolSession) {
|
|
446
|
+
const displayMode = resolveFileDisplayMode(session);
|
|
447
|
+
this.#autoResizeImages = session.settings.get("images.autoResize");
|
|
448
|
+
this.#defaultLimit = Math.max(
|
|
449
|
+
1,
|
|
450
|
+
Math.min(session.settings.get("read.defaultLimit") ?? DEFAULT_MAX_LINES, DEFAULT_MAX_LINES),
|
|
451
|
+
);
|
|
452
|
+
this.#inspectImageEnabled = session.settings.get("inspect_image.enabled");
|
|
453
|
+
this.description =
|
|
454
|
+
resolveEditMode(session) === "chunk"
|
|
455
|
+
? prompt.render(readChunkDescription, {
|
|
456
|
+
anchorStyle: resolveAnchorStyle(session.settings),
|
|
457
|
+
})
|
|
458
|
+
: prompt.render(readDescription, {
|
|
459
|
+
DEFAULT_LIMIT: String(this.#defaultLimit),
|
|
460
|
+
DEFAULT_MAX_LINES: String(DEFAULT_MAX_LINES),
|
|
461
|
+
IS_HASHLINE_MODE: displayMode.hashLines,
|
|
462
|
+
IS_LINE_NUMBER_MODE: !displayMode.hashLines && displayMode.lineNumbers,
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
async #resolveArchiveReadPath(readPath: string, signal?: AbortSignal): Promise<ResolvedArchiveReadPath | null> {
|
|
467
|
+
const candidates = parseArchivePathCandidates(readPath);
|
|
468
|
+
for (const candidate of candidates) {
|
|
469
|
+
let absolutePath = resolveReadPath(candidate.archivePath, this.session.cwd);
|
|
470
|
+
let suffixResolution: { from: string; to: string } | undefined;
|
|
471
|
+
|
|
472
|
+
try {
|
|
473
|
+
const stat = await Bun.file(absolutePath).stat();
|
|
474
|
+
if (stat.isDirectory()) continue;
|
|
475
|
+
return {
|
|
476
|
+
absolutePath,
|
|
477
|
+
archiveSubPath: candidate.archivePath === readPath ? "" : candidate.subPath,
|
|
478
|
+
suffixResolution,
|
|
479
|
+
};
|
|
480
|
+
} catch (error) {
|
|
481
|
+
if (!isNotFoundError(error) || isRemoteMountPath(absolutePath)) continue;
|
|
482
|
+
|
|
483
|
+
const suffixMatch = await findUniqueSuffixMatch(candidate.archivePath, this.session.cwd, signal);
|
|
484
|
+
if (!suffixMatch) continue;
|
|
485
|
+
|
|
486
|
+
try {
|
|
487
|
+
const retryStat = await Bun.file(suffixMatch.absolutePath).stat();
|
|
488
|
+
if (retryStat.isDirectory()) continue;
|
|
489
|
+
|
|
490
|
+
absolutePath = suffixMatch.absolutePath;
|
|
491
|
+
suffixResolution = { from: candidate.archivePath, to: suffixMatch.displayPath };
|
|
492
|
+
return {
|
|
493
|
+
absolutePath,
|
|
494
|
+
archiveSubPath: candidate.archivePath === readPath ? "" : candidate.subPath,
|
|
495
|
+
suffixResolution,
|
|
496
|
+
};
|
|
497
|
+
} catch (retryError) {
|
|
498
|
+
if (!isNotFoundError(retryError)) {
|
|
499
|
+
throw retryError;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
return null;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
#buildInMemoryTextResult(
|
|
509
|
+
text: string,
|
|
510
|
+
offset: number | undefined,
|
|
511
|
+
limit: number | undefined,
|
|
512
|
+
options: {
|
|
513
|
+
details?: ReadToolDetails;
|
|
514
|
+
sourcePath?: string;
|
|
515
|
+
sourceUrl?: string;
|
|
516
|
+
sourceInternal?: string;
|
|
517
|
+
entityLabel: string;
|
|
518
|
+
ignoreResultLimits?: boolean;
|
|
519
|
+
},
|
|
520
|
+
): AgentToolResult<ReadToolDetails> {
|
|
521
|
+
const displayMode = resolveFileDisplayMode(this.session);
|
|
522
|
+
const details = options.details ?? {};
|
|
523
|
+
const allLines = text.split("\n");
|
|
524
|
+
const totalLines = allLines.length;
|
|
525
|
+
const startLine = offset ? Math.max(0, offset - 1) : 0;
|
|
526
|
+
const startLineDisplay = startLine + 1;
|
|
527
|
+
const ignoreResultLimits = options.ignoreResultLimits ?? false;
|
|
528
|
+
|
|
529
|
+
const resultBuilder = toolResult(details);
|
|
530
|
+
if (options.sourcePath) {
|
|
531
|
+
resultBuilder.sourcePath(options.sourcePath);
|
|
532
|
+
}
|
|
533
|
+
if (options.sourceUrl) {
|
|
534
|
+
resultBuilder.sourceUrl(options.sourceUrl);
|
|
535
|
+
}
|
|
536
|
+
if (options.sourceInternal) {
|
|
537
|
+
resultBuilder.sourceInternal(options.sourceInternal);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
if (startLine >= allLines.length) {
|
|
541
|
+
const suggestion =
|
|
542
|
+
allLines.length === 0
|
|
543
|
+
? `The ${options.entityLabel} is empty.`
|
|
544
|
+
: `Use sel=L1 to read from the start, or sel=L${allLines.length} to read the last line.`;
|
|
545
|
+
return resultBuilder
|
|
546
|
+
.text(
|
|
547
|
+
`Line ${startLineDisplay} is beyond end of ${options.entityLabel} (${allLines.length} lines total). ${suggestion}`,
|
|
548
|
+
)
|
|
549
|
+
.done();
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
const endLine =
|
|
553
|
+
limit !== undefined && !ignoreResultLimits ? Math.min(startLine + limit, allLines.length) : allLines.length;
|
|
554
|
+
const selectedContent = allLines.slice(startLine, endLine).join("\n");
|
|
555
|
+
const userLimitedLines = limit !== undefined && !ignoreResultLimits ? endLine - startLine : undefined;
|
|
556
|
+
const truncation = ignoreResultLimits ? noTruncResult(selectedContent) : truncateHead(selectedContent);
|
|
557
|
+
|
|
558
|
+
const shouldAddHashLines = displayMode.hashLines;
|
|
559
|
+
const shouldAddLineNumbers = shouldAddHashLines ? false : displayMode.lineNumbers;
|
|
560
|
+
const formatText = (content: string, startNum: number): string =>
|
|
561
|
+
formatTextWithMode(content, startNum, shouldAddHashLines, shouldAddLineNumbers);
|
|
562
|
+
|
|
563
|
+
let outputText: string;
|
|
564
|
+
let truncationInfo:
|
|
565
|
+
| { result: TruncationResult; options: { direction: "head"; startLine?: number; totalFileLines?: number } }
|
|
566
|
+
| undefined;
|
|
567
|
+
|
|
568
|
+
if (truncation.firstLineExceedsLimit) {
|
|
569
|
+
const firstLine = allLines[startLine] ?? "";
|
|
570
|
+
const firstLineBytes = Buffer.byteLength(firstLine, "utf-8");
|
|
571
|
+
const snippet = truncateHeadBytes(firstLine, DEFAULT_MAX_BYTES);
|
|
572
|
+
|
|
573
|
+
if (shouldAddHashLines) {
|
|
574
|
+
outputText = `[Line ${startLineDisplay} is ${formatBytes(
|
|
575
|
+
firstLineBytes,
|
|
576
|
+
)}, exceeds ${formatBytes(DEFAULT_MAX_BYTES)} limit. Hashline output requires full lines; cannot compute hashes for a truncated preview.]`;
|
|
577
|
+
} else {
|
|
578
|
+
outputText = formatText(snippet.text, startLineDisplay);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
if (snippet.text.length === 0) {
|
|
582
|
+
outputText = `[Line ${startLineDisplay} is ${formatBytes(
|
|
583
|
+
firstLineBytes,
|
|
584
|
+
)}, exceeds ${formatBytes(DEFAULT_MAX_BYTES)} limit. Unable to display a valid UTF-8 snippet.]`;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
details.truncation = truncation;
|
|
588
|
+
truncationInfo = {
|
|
589
|
+
result: truncation,
|
|
590
|
+
options: { direction: "head", startLine: startLineDisplay, totalFileLines: totalLines },
|
|
591
|
+
};
|
|
592
|
+
} else if (truncation.truncated) {
|
|
593
|
+
outputText = formatText(truncation.content, startLineDisplay);
|
|
594
|
+
details.truncation = truncation;
|
|
595
|
+
truncationInfo = {
|
|
596
|
+
result: truncation,
|
|
597
|
+
options: { direction: "head", startLine: startLineDisplay, totalFileLines: totalLines },
|
|
598
|
+
};
|
|
599
|
+
} else if (userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length) {
|
|
600
|
+
const remaining = allLines.length - (startLine + userLimitedLines);
|
|
601
|
+
const nextOffset = startLine + userLimitedLines + 1;
|
|
602
|
+
|
|
603
|
+
outputText = formatText(selectedContent, startLineDisplay);
|
|
604
|
+
outputText += `\n\n[${remaining} more lines in ${options.entityLabel}. Use sel=L${nextOffset} to continue]`;
|
|
605
|
+
} else {
|
|
606
|
+
outputText = formatText(truncation.content, startLineDisplay);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
resultBuilder.text(outputText);
|
|
610
|
+
if (truncationInfo) {
|
|
611
|
+
resultBuilder.truncation(truncationInfo.result, truncationInfo.options);
|
|
612
|
+
}
|
|
613
|
+
return resultBuilder.done();
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
async #readArchiveDirectory(
|
|
617
|
+
archive: ArchiveReader,
|
|
618
|
+
archivePath: string,
|
|
619
|
+
subPath: string,
|
|
620
|
+
limit: number | undefined,
|
|
621
|
+
details: ReadToolDetails,
|
|
622
|
+
signal?: AbortSignal,
|
|
623
|
+
): Promise<AgentToolResult<ReadToolDetails>> {
|
|
624
|
+
const DEFAULT_LIMIT = 500;
|
|
625
|
+
const effectiveLimit = limit ?? DEFAULT_LIMIT;
|
|
626
|
+
const entries = archive.listDirectory(subPath);
|
|
627
|
+
|
|
628
|
+
const listLimit = applyListLimit(entries, { limit: effectiveLimit });
|
|
629
|
+
const limitedEntries = listLimit.items;
|
|
630
|
+
const limitMeta = listLimit.meta;
|
|
631
|
+
|
|
632
|
+
const results: string[] = [];
|
|
633
|
+
for (const entry of limitedEntries) {
|
|
634
|
+
throwIfAborted(signal);
|
|
635
|
+
if (entry.isDirectory) {
|
|
636
|
+
results.push(`${entry.name}/`);
|
|
637
|
+
continue;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
const sizeSuffix = entry.size > 0 ? ` (${formatBytes(entry.size)})` : "";
|
|
641
|
+
results.push(`${entry.name}${sizeSuffix}`);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
const output = results.length > 0 ? results.join("\n") : "(empty archive directory)";
|
|
645
|
+
const text = prependSuffixResolutionNotice(output, details.suffixResolution);
|
|
646
|
+
const truncation = truncateHead(text, { maxLines: Number.MAX_SAFE_INTEGER });
|
|
647
|
+
const directoryDetails: ReadToolDetails = { ...details, isDirectory: true };
|
|
648
|
+
const resultBuilder = toolResult<ReadToolDetails>(directoryDetails).text(truncation.content);
|
|
649
|
+
resultBuilder.sourcePath(archivePath).limits({ resultLimit: limitMeta.resultLimit?.reached });
|
|
650
|
+
if (truncation.truncated) {
|
|
651
|
+
directoryDetails.truncation = truncation;
|
|
652
|
+
resultBuilder.truncation(truncation, { direction: "head" });
|
|
653
|
+
}
|
|
654
|
+
return resultBuilder.done();
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
async #readArchive(
|
|
658
|
+
readPath: string,
|
|
659
|
+
offset: number | undefined,
|
|
660
|
+
limit: number | undefined,
|
|
661
|
+
resolvedArchivePath: ResolvedArchiveReadPath,
|
|
662
|
+
signal?: AbortSignal,
|
|
663
|
+
): Promise<AgentToolResult<ReadToolDetails>> {
|
|
664
|
+
throwIfAborted(signal);
|
|
665
|
+
const archive = await openArchive(resolvedArchivePath.absolutePath);
|
|
666
|
+
throwIfAborted(signal);
|
|
667
|
+
|
|
668
|
+
const details: ReadToolDetails = {
|
|
669
|
+
resolvedPath: resolvedArchivePath.absolutePath,
|
|
670
|
+
suffixResolution: resolvedArchivePath.suffixResolution,
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
const node = archive.getNode(resolvedArchivePath.archiveSubPath);
|
|
674
|
+
if (!node) {
|
|
675
|
+
throw new ToolError(`Path '${readPath}' not found inside archive`);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
if (node.isDirectory) {
|
|
679
|
+
return this.#readArchiveDirectory(
|
|
680
|
+
archive,
|
|
681
|
+
resolvedArchivePath.absolutePath,
|
|
682
|
+
resolvedArchivePath.archiveSubPath,
|
|
683
|
+
limit,
|
|
684
|
+
details,
|
|
685
|
+
signal,
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
const entry = await archive.readFile(resolvedArchivePath.archiveSubPath);
|
|
690
|
+
const text = decodeUtf8Text(entry.bytes);
|
|
691
|
+
if (text === null) {
|
|
692
|
+
return toolResult<ReadToolDetails>(details)
|
|
693
|
+
.text(
|
|
694
|
+
prependSuffixResolutionNotice(
|
|
695
|
+
`[Cannot read binary archive entry '${entry.path}' (${formatBytes(entry.size)})]`,
|
|
696
|
+
resolvedArchivePath.suffixResolution,
|
|
697
|
+
),
|
|
698
|
+
)
|
|
699
|
+
.sourcePath(resolvedArchivePath.absolutePath)
|
|
700
|
+
.done();
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
const result = this.#buildInMemoryTextResult(text, offset, limit, {
|
|
704
|
+
details,
|
|
705
|
+
sourcePath: resolvedArchivePath.absolutePath,
|
|
706
|
+
entityLabel: "archive entry",
|
|
707
|
+
});
|
|
708
|
+
const firstText = result.content.find((content): content is TextContent => content.type === "text");
|
|
709
|
+
if (firstText) {
|
|
710
|
+
firstText.text = prependSuffixResolutionNotice(firstText.text, resolvedArchivePath.suffixResolution);
|
|
711
|
+
}
|
|
712
|
+
return result;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
async execute(
|
|
716
|
+
_toolCallId: string,
|
|
717
|
+
params: ReadParams,
|
|
718
|
+
signal?: AbortSignal,
|
|
719
|
+
_onUpdate?: AgentToolUpdateCallback<ReadToolDetails>,
|
|
720
|
+
_toolContext?: AgentToolContext,
|
|
721
|
+
): Promise<AgentToolResult<ReadToolDetails>> {
|
|
722
|
+
let { path: readPath, sel, timeout } = params;
|
|
723
|
+
if (readPath.startsWith("file://")) {
|
|
724
|
+
readPath = expandPath(readPath);
|
|
725
|
+
}
|
|
726
|
+
const displayMode = resolveFileDisplayMode(this.session);
|
|
727
|
+
const chunkMode = resolveEditMode(this.session) === "chunk";
|
|
728
|
+
|
|
729
|
+
// Handle internal URLs (agent://, artifact://, memory://, skill://, rule://, local://, mcp://)
|
|
730
|
+
const internalRouter = this.session.internalRouter;
|
|
731
|
+
if (internalRouter?.canHandle(readPath)) {
|
|
732
|
+
const parsed = parseSel(sel);
|
|
733
|
+
const { offset, limit } = selToOffsetLimit(parsed);
|
|
734
|
+
return this.#handleInternalUrl(readPath, offset, limit);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
const parsedUrlTarget = parseReadUrlTarget(readPath, sel);
|
|
738
|
+
if (parsedUrlTarget) {
|
|
739
|
+
if (!this.session.settings.get("fetch.enabled")) {
|
|
740
|
+
throw new ToolError("URL reads are disabled by settings.");
|
|
741
|
+
}
|
|
742
|
+
if (parsedUrlTarget.offset !== undefined || parsedUrlTarget.limit !== undefined) {
|
|
743
|
+
const cached = await loadReadUrlCacheEntry(
|
|
744
|
+
this.session,
|
|
745
|
+
{ path: parsedUrlTarget.path, timeout, raw: parsedUrlTarget.raw },
|
|
746
|
+
signal,
|
|
747
|
+
{
|
|
748
|
+
ensureArtifact: true,
|
|
749
|
+
preferCached: true,
|
|
750
|
+
},
|
|
751
|
+
);
|
|
752
|
+
return this.#buildInMemoryTextResult(cached.output, parsedUrlTarget.offset, parsedUrlTarget.limit, {
|
|
753
|
+
details: { ...cached.details },
|
|
754
|
+
sourceUrl: cached.details.finalUrl,
|
|
755
|
+
entityLabel: "URL output",
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
return executeReadUrl(this.session, { path: parsedUrlTarget.path, timeout, raw: parsedUrlTarget.raw }, signal);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
const parsedReadPath = chunkMode ? parseChunkReadPath(readPath) : { filePath: readPath };
|
|
762
|
+
const localReadPath = parsedReadPath.filePath;
|
|
763
|
+
const pathSelectorParsed = chunkMode ? parseSel(parsedReadPath.selector) : { kind: "none" as const };
|
|
764
|
+
const pathChunkSelector = pathSelectorParsed.kind === "chunk" ? pathSelectorParsed.selector : undefined;
|
|
765
|
+
const selectorInput = sel ?? parsedReadPath.selector;
|
|
766
|
+
const rawSelectorInput = sel ?? parsedReadPath.selector;
|
|
767
|
+
const parsed = parseSel(selectorInput);
|
|
768
|
+
|
|
769
|
+
const archivePath = await this.#resolveArchiveReadPath(localReadPath, signal);
|
|
770
|
+
if (archivePath) {
|
|
771
|
+
const { offset, limit } = selToOffsetLimit(parsed);
|
|
772
|
+
return this.#readArchive(readPath, offset, limit, archivePath, signal);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
let absolutePath = resolveReadPath(localReadPath, this.session.cwd);
|
|
776
|
+
let suffixResolution: { from: string; to: string } | undefined;
|
|
777
|
+
|
|
778
|
+
let isDirectory = false;
|
|
779
|
+
let fileSize = 0;
|
|
780
|
+
try {
|
|
781
|
+
const stat = await Bun.file(absolutePath).stat();
|
|
782
|
+
fileSize = stat.size;
|
|
783
|
+
isDirectory = stat.isDirectory();
|
|
784
|
+
} catch (error) {
|
|
785
|
+
if (isNotFoundError(error)) {
|
|
786
|
+
// Attempt unique suffix resolution before falling back to fuzzy suggestions
|
|
787
|
+
if (!isRemoteMountPath(absolutePath)) {
|
|
788
|
+
const suffixMatch = await findUniqueSuffixMatch(localReadPath, this.session.cwd, signal);
|
|
789
|
+
if (suffixMatch) {
|
|
790
|
+
try {
|
|
791
|
+
const retryStat = await Bun.file(suffixMatch.absolutePath).stat();
|
|
792
|
+
absolutePath = suffixMatch.absolutePath;
|
|
793
|
+
fileSize = retryStat.size;
|
|
794
|
+
isDirectory = retryStat.isDirectory();
|
|
795
|
+
suffixResolution = { from: localReadPath, to: suffixMatch.displayPath };
|
|
796
|
+
} catch {
|
|
797
|
+
// Suffix match candidate no longer stats — fall through to error path
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
if (!suffixResolution) {
|
|
803
|
+
throw new ToolError(`Path '${localReadPath}' not found`);
|
|
804
|
+
}
|
|
805
|
+
} else {
|
|
806
|
+
throw error;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
if (isDirectory) {
|
|
811
|
+
const dirResult = await this.#readDirectory(absolutePath, selToOffsetLimit(parsed).limit, signal);
|
|
812
|
+
if (suffixResolution) {
|
|
813
|
+
dirResult.details ??= {};
|
|
814
|
+
dirResult.details.suffixResolution = suffixResolution;
|
|
815
|
+
}
|
|
816
|
+
return dirResult;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
const imageMetadata = await readImageMetadata(absolutePath);
|
|
820
|
+
const mimeType = imageMetadata?.mimeType;
|
|
821
|
+
const ext = path.extname(absolutePath).toLowerCase();
|
|
822
|
+
const hasEditTool = this.session.hasEditTool ?? true;
|
|
823
|
+
const language = getLanguageFromPath(absolutePath);
|
|
824
|
+
const skipChunksForExplore = !hasEditTool && !this.session.settings.get("read.explorechunks");
|
|
825
|
+
const skipChunksForProse = isProseLanguage(language) && !this.session.settings.get("read.prosechunks");
|
|
826
|
+
const shouldConvertWithMarkit =
|
|
827
|
+
CONVERTIBLE_EXTENSIONS.has(ext) || (ext === ".ipynb" && (parsed.kind === "raw" || !chunkMode));
|
|
828
|
+
|
|
829
|
+
if (chunkMode && parsed.kind !== "raw" && !skipChunksForExplore && !skipChunksForProse) {
|
|
830
|
+
const absoluteLineRange =
|
|
831
|
+
pathChunkSelector && parsed.kind === "lines"
|
|
832
|
+
? { startLine: parsed.startLine, endLine: parsed.endLine }
|
|
833
|
+
: undefined;
|
|
834
|
+
// sel= wins over path:chunk when both are provided (explicit param > embedded path).
|
|
835
|
+
const effectiveSelector = sel ? selectorInput : (pathChunkSelector ?? selectorInput);
|
|
836
|
+
const rawEffectiveSelector = sel ? selectorInput : (rawSelectorInput ?? effectiveSelector);
|
|
837
|
+
const chunkReadPath =
|
|
838
|
+
parsed.kind === "chunk" || (pathChunkSelector && !sel)
|
|
839
|
+
? rawEffectiveSelector
|
|
840
|
+
? `${localReadPath}:${rawEffectiveSelector}`
|
|
841
|
+
: localReadPath
|
|
842
|
+
: parsed.kind === "lines"
|
|
843
|
+
? parsed.endLine !== undefined
|
|
844
|
+
? `${localReadPath}:L${parsed.startLine}-L${parsed.endLine}`
|
|
845
|
+
: `${localReadPath}:L${parsed.startLine}`
|
|
846
|
+
: localReadPath;
|
|
847
|
+
const chunkResult = await formatChunkedRead({
|
|
848
|
+
filePath: absolutePath,
|
|
849
|
+
readPath: chunkReadPath,
|
|
850
|
+
cwd: this.session.cwd,
|
|
851
|
+
language,
|
|
852
|
+
omitChecksum: !hasEditTool,
|
|
853
|
+
anchorStyle: resolveAnchorStyle(this.session.settings),
|
|
854
|
+
absoluteLineRange,
|
|
855
|
+
});
|
|
856
|
+
let text = chunkResult.text;
|
|
857
|
+
if (suffixResolution) {
|
|
858
|
+
text = prependSuffixResolutionNotice(text, suffixResolution);
|
|
859
|
+
}
|
|
860
|
+
return toolResult<ReadToolDetails>({
|
|
861
|
+
resolvedPath: absolutePath,
|
|
862
|
+
suffixResolution,
|
|
863
|
+
chunk: chunkResult.chunk,
|
|
864
|
+
})
|
|
865
|
+
.text(text)
|
|
866
|
+
.sourcePath(absolutePath)
|
|
867
|
+
.done();
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
// Read the file based on type
|
|
871
|
+
let content: Array<TextContent | ImageContent>;
|
|
872
|
+
let details: ReadToolDetails = {};
|
|
873
|
+
let sourcePath: string | undefined;
|
|
874
|
+
let truncationInfo:
|
|
875
|
+
| { result: TruncationResult; options: { direction: "head"; startLine?: number; totalFileLines?: number } }
|
|
876
|
+
| undefined;
|
|
877
|
+
|
|
878
|
+
if (mimeType) {
|
|
879
|
+
if (this.#inspectImageEnabled) {
|
|
880
|
+
const metadata = imageMetadata;
|
|
881
|
+
const outputMime = metadata?.mimeType ?? mimeType;
|
|
882
|
+
const outputBytes = fileSize;
|
|
883
|
+
const metadataLines = [
|
|
884
|
+
"Image metadata:",
|
|
885
|
+
`- MIME: ${outputMime}`,
|
|
886
|
+
`- Bytes: ${outputBytes} (${formatBytes(outputBytes)})`,
|
|
887
|
+
metadata?.width !== undefined && metadata.height !== undefined
|
|
888
|
+
? `- Dimensions: ${metadata.width}x${metadata.height}`
|
|
889
|
+
: "- Dimensions: unknown",
|
|
890
|
+
metadata?.channels !== undefined ? `- Channels: ${metadata.channels}` : "- Channels: unknown",
|
|
891
|
+
metadata?.hasAlpha === true
|
|
892
|
+
? "- Alpha: yes"
|
|
893
|
+
: metadata?.hasAlpha === false
|
|
894
|
+
? "- Alpha: no"
|
|
895
|
+
: "- Alpha: unknown",
|
|
896
|
+
"",
|
|
897
|
+
`If you want to analyze the image, call inspect_image with path="${readPath}" and a question describing what to inspect and the desired output format.`,
|
|
898
|
+
];
|
|
899
|
+
content = [{ type: "text", text: metadataLines.join("\n") }];
|
|
900
|
+
details = {};
|
|
901
|
+
sourcePath = absolutePath;
|
|
902
|
+
} else {
|
|
903
|
+
if (fileSize > MAX_IMAGE_SIZE) {
|
|
904
|
+
const sizeStr = formatBytes(fileSize);
|
|
905
|
+
const maxStr = formatBytes(MAX_IMAGE_SIZE);
|
|
906
|
+
throw new ToolError(`Image file too large: ${sizeStr} exceeds ${maxStr} limit.`);
|
|
907
|
+
}
|
|
908
|
+
try {
|
|
909
|
+
const imageInput = await loadImageInput({
|
|
910
|
+
path: readPath,
|
|
911
|
+
cwd: this.session.cwd,
|
|
912
|
+
autoResize: this.#autoResizeImages,
|
|
913
|
+
maxBytes: MAX_IMAGE_SIZE,
|
|
914
|
+
resolvedPath: absolutePath,
|
|
915
|
+
detectedMimeType: mimeType,
|
|
916
|
+
});
|
|
917
|
+
if (!imageInput) {
|
|
918
|
+
throw new ToolError(`Read image file [${mimeType}] failed: unsupported image format.`);
|
|
919
|
+
}
|
|
920
|
+
content = [
|
|
921
|
+
{ type: "text", text: imageInput.textNote },
|
|
922
|
+
{ type: "image", data: imageInput.data, mimeType: imageInput.mimeType },
|
|
923
|
+
];
|
|
924
|
+
details = {};
|
|
925
|
+
sourcePath = imageInput.resolvedPath;
|
|
926
|
+
} catch (error) {
|
|
927
|
+
if (error instanceof ImageInputTooLargeError) {
|
|
928
|
+
throw new ToolError(error.message);
|
|
929
|
+
}
|
|
930
|
+
throw error;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
} else if (shouldConvertWithMarkit) {
|
|
934
|
+
// Convert document or notebook via markit.
|
|
935
|
+
const result = await convertFileWithMarkit(absolutePath, signal);
|
|
936
|
+
if (result.ok) {
|
|
937
|
+
// Apply truncation to converted content
|
|
938
|
+
const truncation = truncateHead(result.content);
|
|
939
|
+
const outputText = truncation.content;
|
|
940
|
+
|
|
941
|
+
details = { truncation };
|
|
942
|
+
sourcePath = absolutePath;
|
|
943
|
+
truncationInfo = { result: truncation, options: { direction: "head", startLine: 1 } };
|
|
944
|
+
|
|
945
|
+
content = [{ type: "text", text: outputText }];
|
|
946
|
+
} else if (result.error) {
|
|
947
|
+
content = [{ type: "text", text: `[Cannot read ${ext} file: ${result.error || "conversion failed"}]` }];
|
|
948
|
+
} else {
|
|
949
|
+
content = [{ type: "text", text: `[Cannot read ${ext} file: conversion failed]` }];
|
|
950
|
+
}
|
|
951
|
+
} else {
|
|
952
|
+
// Chunk mode: dispatch to chunk tree unless raw or line range requested
|
|
953
|
+
if (chunkMode && parsed.kind !== "raw" && parsed.kind !== "lines") {
|
|
954
|
+
const chunkSel = parsed.kind === "chunk" ? parsed.selector : undefined;
|
|
955
|
+
const chunkResult = await formatChunkedRead({
|
|
956
|
+
filePath: absolutePath,
|
|
957
|
+
readPath: chunkSel ? `${localReadPath}:${chunkSel}` : localReadPath,
|
|
958
|
+
cwd: this.session.cwd,
|
|
959
|
+
language: getLanguageFromPath(absolutePath),
|
|
960
|
+
omitChecksum: !(this.session.hasEditTool ?? true),
|
|
961
|
+
anchorStyle: resolveAnchorStyle(this.session.settings),
|
|
962
|
+
});
|
|
963
|
+
let text = chunkResult.text;
|
|
964
|
+
if (suffixResolution) {
|
|
965
|
+
text = prependSuffixResolutionNotice(text, suffixResolution);
|
|
966
|
+
}
|
|
967
|
+
return toolResult<ReadToolDetails>({
|
|
968
|
+
resolvedPath: absolutePath,
|
|
969
|
+
suffixResolution,
|
|
970
|
+
chunk: chunkResult.chunk,
|
|
971
|
+
})
|
|
972
|
+
.text(text)
|
|
973
|
+
.sourcePath(absolutePath)
|
|
974
|
+
.done();
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// Raw text or line-range mode
|
|
978
|
+
const { offset, limit } = selToOffsetLimit(parsed);
|
|
979
|
+
const startLine = offset ? Math.max(0, offset - 1) : 0;
|
|
980
|
+
const startLineDisplay = startLine + 1;
|
|
981
|
+
|
|
982
|
+
const DEFAULT_LIMIT = this.#defaultLimit;
|
|
983
|
+
const effectiveLimit = limit ?? DEFAULT_LIMIT;
|
|
984
|
+
const maxLinesToCollect = Math.min(effectiveLimit, DEFAULT_MAX_LINES);
|
|
985
|
+
const selectedLineLimit = effectiveLimit;
|
|
986
|
+
|
|
987
|
+
const streamResult = await streamLinesFromFile(
|
|
988
|
+
absolutePath,
|
|
989
|
+
startLine,
|
|
990
|
+
maxLinesToCollect,
|
|
991
|
+
DEFAULT_MAX_BYTES,
|
|
992
|
+
selectedLineLimit,
|
|
993
|
+
signal,
|
|
994
|
+
);
|
|
995
|
+
|
|
996
|
+
const {
|
|
997
|
+
lines: collectedLines,
|
|
998
|
+
totalFileLines,
|
|
999
|
+
collectedBytes,
|
|
1000
|
+
stoppedByByteLimit,
|
|
1001
|
+
firstLinePreview,
|
|
1002
|
+
firstLineByteLength,
|
|
1003
|
+
} = streamResult;
|
|
1004
|
+
|
|
1005
|
+
// Check if offset is out of bounds - return graceful message instead of throwing
|
|
1006
|
+
if (startLine >= totalFileLines) {
|
|
1007
|
+
const suggestion =
|
|
1008
|
+
totalFileLines === 0
|
|
1009
|
+
? "The file is empty."
|
|
1010
|
+
: `Use sel=L1 to read from the start, or sel=L${totalFileLines} to read the last line.`;
|
|
1011
|
+
return toolResult<ReadToolDetails>({ resolvedPath: absolutePath, suffixResolution })
|
|
1012
|
+
.text(`Line ${startLineDisplay} is beyond end of file (${totalFileLines} lines total). ${suggestion}`)
|
|
1013
|
+
.done();
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
const selectedContent = collectedLines.join("\n");
|
|
1017
|
+
const userLimitedLines = collectedLines.length;
|
|
1018
|
+
|
|
1019
|
+
const totalSelectedLines = totalFileLines - startLine;
|
|
1020
|
+
const totalSelectedBytes = collectedBytes;
|
|
1021
|
+
const wasTruncated = collectedLines.length < totalSelectedLines || stoppedByByteLimit;
|
|
1022
|
+
const firstLineExceedsLimit = firstLineByteLength !== undefined && firstLineByteLength > DEFAULT_MAX_BYTES;
|
|
1023
|
+
|
|
1024
|
+
const truncation: TruncationResult = {
|
|
1025
|
+
content: selectedContent,
|
|
1026
|
+
truncated: wasTruncated,
|
|
1027
|
+
truncatedBy: stoppedByByteLimit ? "bytes" : wasTruncated ? "lines" : undefined,
|
|
1028
|
+
totalLines: totalSelectedLines,
|
|
1029
|
+
totalBytes: totalSelectedBytes,
|
|
1030
|
+
outputLines: collectedLines.length,
|
|
1031
|
+
outputBytes: collectedBytes,
|
|
1032
|
+
lastLinePartial: false,
|
|
1033
|
+
firstLineExceedsLimit,
|
|
1034
|
+
};
|
|
1035
|
+
|
|
1036
|
+
const shouldAddHashLines = displayMode.hashLines;
|
|
1037
|
+
const shouldAddLineNumbers = shouldAddHashLines ? false : displayMode.lineNumbers;
|
|
1038
|
+
const formatText = (text: string, startNum: number): string => {
|
|
1039
|
+
return formatTextWithMode(text, startNum, shouldAddHashLines, shouldAddLineNumbers);
|
|
1040
|
+
};
|
|
1041
|
+
|
|
1042
|
+
let outputText: string;
|
|
1043
|
+
|
|
1044
|
+
if (truncation.firstLineExceedsLimit) {
|
|
1045
|
+
const firstLineBytes = firstLineByteLength ?? 0;
|
|
1046
|
+
const snippet = firstLinePreview ?? { text: "", bytes: 0 };
|
|
1047
|
+
|
|
1048
|
+
if (shouldAddHashLines) {
|
|
1049
|
+
outputText = `[Line ${startLineDisplay} is ${formatBytes(
|
|
1050
|
+
firstLineBytes,
|
|
1051
|
+
)}, exceeds ${formatBytes(DEFAULT_MAX_BYTES)} limit. Hashline output requires full lines; cannot compute hashes for a truncated preview.]`;
|
|
1052
|
+
} else {
|
|
1053
|
+
outputText = formatText(snippet.text, startLineDisplay);
|
|
1054
|
+
}
|
|
1055
|
+
if (snippet.text.length === 0) {
|
|
1056
|
+
outputText = `[Line ${startLineDisplay} is ${formatBytes(
|
|
1057
|
+
firstLineBytes,
|
|
1058
|
+
)}, exceeds ${formatBytes(DEFAULT_MAX_BYTES)} limit. Unable to display a valid UTF-8 snippet.]`;
|
|
1059
|
+
}
|
|
1060
|
+
details = { truncation };
|
|
1061
|
+
sourcePath = absolutePath;
|
|
1062
|
+
truncationInfo = {
|
|
1063
|
+
result: truncation,
|
|
1064
|
+
options: { direction: "head", startLine: startLineDisplay, totalFileLines },
|
|
1065
|
+
};
|
|
1066
|
+
} else if (truncation.truncated) {
|
|
1067
|
+
outputText = formatText(truncation.content, startLineDisplay);
|
|
1068
|
+
details = { truncation };
|
|
1069
|
+
sourcePath = absolutePath;
|
|
1070
|
+
truncationInfo = {
|
|
1071
|
+
result: truncation,
|
|
1072
|
+
options: { direction: "head", startLine: startLineDisplay, totalFileLines },
|
|
1073
|
+
};
|
|
1074
|
+
} else if (startLine + userLimitedLines < totalFileLines) {
|
|
1075
|
+
const remaining = totalFileLines - (startLine + userLimitedLines);
|
|
1076
|
+
const nextOffset = startLine + userLimitedLines + 1;
|
|
1077
|
+
|
|
1078
|
+
outputText = formatText(truncation.content, startLineDisplay);
|
|
1079
|
+
outputText += `\n\n[${remaining} more lines in file. Use sel=L${nextOffset} to continue]`;
|
|
1080
|
+
details = {};
|
|
1081
|
+
sourcePath = absolutePath;
|
|
1082
|
+
} else {
|
|
1083
|
+
// No truncation, no user limit exceeded
|
|
1084
|
+
outputText = formatText(truncation.content, startLineDisplay);
|
|
1085
|
+
details = {};
|
|
1086
|
+
sourcePath = absolutePath;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
content = [{ type: "text", text: outputText }];
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
if (suffixResolution) {
|
|
1093
|
+
details.suffixResolution = suffixResolution;
|
|
1094
|
+
// Inline resolution notice into first text block so the model sees the actual path
|
|
1095
|
+
const notice = `[Path '${suffixResolution.from}' not found; resolved to '${suffixResolution.to}' via suffix match]`;
|
|
1096
|
+
const firstText = content.find((c): c is TextContent => c.type === "text");
|
|
1097
|
+
if (firstText) {
|
|
1098
|
+
firstText.text = `${notice}\n${firstText.text}`;
|
|
1099
|
+
} else {
|
|
1100
|
+
content = [{ type: "text", text: notice }, ...content];
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
const resultBuilder = toolResult(details).content(content);
|
|
1104
|
+
if (sourcePath) {
|
|
1105
|
+
resultBuilder.sourcePath(sourcePath);
|
|
1106
|
+
}
|
|
1107
|
+
if (truncationInfo) {
|
|
1108
|
+
resultBuilder.truncation(truncationInfo.result, truncationInfo.options);
|
|
1109
|
+
}
|
|
1110
|
+
return resultBuilder.done();
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* Handle internal URLs (agent://, artifact://, memory://, skill://, rule://, local://, mcp://).
|
|
1115
|
+
* Supports pagination via offset/limit but rejects them when query extraction is used.
|
|
1116
|
+
*/
|
|
1117
|
+
async #handleInternalUrl(url: string, offset?: number, limit?: number): Promise<AgentToolResult<ReadToolDetails>> {
|
|
1118
|
+
const internalRouter = this.session.internalRouter!;
|
|
1119
|
+
|
|
1120
|
+
// Check if URL has query extraction (agent:// only).
|
|
1121
|
+
// Use parseInternalUrl which handles colons in host (namespaced skills).
|
|
1122
|
+
let parsed: InternalUrl;
|
|
1123
|
+
try {
|
|
1124
|
+
parsed = parseInternalUrl(url);
|
|
1125
|
+
} catch (e) {
|
|
1126
|
+
throw new ToolError(e instanceof Error ? e.message : String(e));
|
|
1127
|
+
}
|
|
1128
|
+
const scheme = parsed.protocol.replace(/:$/, "").toLowerCase();
|
|
1129
|
+
let hasExtraction = false;
|
|
1130
|
+
if (scheme === "agent") {
|
|
1131
|
+
const hasPathExtraction = parsed.pathname && parsed.pathname !== "/" && parsed.pathname !== "";
|
|
1132
|
+
const queryParam = parsed.searchParams.get("q");
|
|
1133
|
+
const hasQueryExtraction = queryParam !== null && queryParam !== "";
|
|
1134
|
+
hasExtraction = hasPathExtraction || hasQueryExtraction;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
// Reject offset/limit with query extraction
|
|
1138
|
+
if (hasExtraction && (offset !== undefined || limit !== undefined)) {
|
|
1139
|
+
throw new ToolError("Cannot combine query extraction with offset/limit");
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
// Resolve the internal URL
|
|
1143
|
+
const resource = await internalRouter.resolve(url);
|
|
1144
|
+
const details: ReadToolDetails = { resolvedPath: resource.sourcePath };
|
|
1145
|
+
|
|
1146
|
+
// If extraction was used, return directly (no pagination)
|
|
1147
|
+
if (hasExtraction) {
|
|
1148
|
+
return toolResult(details).text(resource.content).sourceInternal(url).done();
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
return this.#buildInMemoryTextResult(resource.content, offset, limit, {
|
|
1152
|
+
details,
|
|
1153
|
+
sourcePath: resource.sourcePath,
|
|
1154
|
+
sourceInternal: url,
|
|
1155
|
+
entityLabel: "resource",
|
|
1156
|
+
ignoreResultLimits: scheme === "skill",
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
/** Read directory contents as a formatted listing */
|
|
1161
|
+
async #readDirectory(
|
|
1162
|
+
absolutePath: string,
|
|
1163
|
+
limit: number | undefined,
|
|
1164
|
+
signal?: AbortSignal,
|
|
1165
|
+
): Promise<AgentToolResult<ReadToolDetails>> {
|
|
1166
|
+
const DEFAULT_LIMIT = 500;
|
|
1167
|
+
const effectiveLimit = limit ?? DEFAULT_LIMIT;
|
|
1168
|
+
|
|
1169
|
+
let entries: string[];
|
|
1170
|
+
try {
|
|
1171
|
+
entries = await fs.readdir(absolutePath);
|
|
1172
|
+
} catch (error) {
|
|
1173
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1174
|
+
throw new ToolError(`Cannot read directory: ${message}`);
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
// Sort alphabetically (case-insensitive)
|
|
1178
|
+
entries.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
|
1179
|
+
|
|
1180
|
+
const listLimit = applyListLimit(entries, { limit: effectiveLimit });
|
|
1181
|
+
const limitedEntries = listLimit.items;
|
|
1182
|
+
const limitMeta = listLimit.meta;
|
|
1183
|
+
|
|
1184
|
+
// Format entries with directory indicators and ages
|
|
1185
|
+
const results: string[] = [];
|
|
1186
|
+
|
|
1187
|
+
for (const entry of limitedEntries) {
|
|
1188
|
+
throwIfAborted(signal);
|
|
1189
|
+
const fullPath = path.join(absolutePath, entry);
|
|
1190
|
+
let suffix = "";
|
|
1191
|
+
let age = "";
|
|
1192
|
+
|
|
1193
|
+
try {
|
|
1194
|
+
const entryStat = await fs.stat(fullPath);
|
|
1195
|
+
suffix = entryStat.isDirectory() ? "/" : "";
|
|
1196
|
+
const ageSeconds = Math.floor((Date.now() - entryStat.mtimeMs) / 1000);
|
|
1197
|
+
age = formatAge(ageSeconds);
|
|
1198
|
+
} catch {
|
|
1199
|
+
// Skip entries we can't stat
|
|
1200
|
+
continue;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
const line = age ? `${entry}${suffix} (${age})` : entry + suffix;
|
|
1204
|
+
results.push(line);
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
if (results.length === 0) {
|
|
1208
|
+
return { content: [{ type: "text", text: "(empty directory)" }], details: {} };
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
const output = results.join("\n");
|
|
1212
|
+
const truncation = truncateHead(output, { maxLines: Number.MAX_SAFE_INTEGER });
|
|
1213
|
+
|
|
1214
|
+
const details: ReadToolDetails = {
|
|
1215
|
+
isDirectory: true,
|
|
1216
|
+
};
|
|
1217
|
+
|
|
1218
|
+
const resultBuilder = toolResult(details)
|
|
1219
|
+
.text(truncation.content)
|
|
1220
|
+
.limits({ resultLimit: limitMeta.resultLimit?.reached });
|
|
1221
|
+
if (truncation.truncated) {
|
|
1222
|
+
resultBuilder.truncation(truncation, { direction: "head" });
|
|
1223
|
+
details.truncation = truncation;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
return resultBuilder.done();
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
// =============================================================================
|
|
1231
|
+
// TUI Renderer
|
|
1232
|
+
// =============================================================================
|
|
1233
|
+
|
|
1234
|
+
interface ReadRenderArgs {
|
|
1235
|
+
path?: string;
|
|
1236
|
+
file_path?: string;
|
|
1237
|
+
sel?: string;
|
|
1238
|
+
timeout?: number;
|
|
1239
|
+
// Legacy fields from old schema — tolerated for in-flight tool calls during transition
|
|
1240
|
+
offset?: number;
|
|
1241
|
+
limit?: number;
|
|
1242
|
+
raw?: boolean;
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
export const readToolRenderer = {
|
|
1246
|
+
renderCall(args: ReadRenderArgs, _options: RenderResultOptions, uiTheme: Theme): Component {
|
|
1247
|
+
if (isReadableUrlPath(args.file_path || args.path || "")) {
|
|
1248
|
+
return renderReadUrlCall(args, _options, uiTheme);
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
const rawPath = args.file_path || args.path || "";
|
|
1252
|
+
const filePath = shortenPath(rawPath);
|
|
1253
|
+
const offset = args.offset;
|
|
1254
|
+
const limit = args.limit;
|
|
1255
|
+
|
|
1256
|
+
let pathDisplay = filePath || "…";
|
|
1257
|
+
if (offset !== undefined || limit !== undefined) {
|
|
1258
|
+
const startLine = offset ?? 1;
|
|
1259
|
+
const endLine = limit !== undefined ? startLine + limit - 1 : "";
|
|
1260
|
+
pathDisplay += `:${startLine}${endLine ? `-${endLine}` : ""}`;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
const text = renderStatusLine({ icon: "pending", title: "Read", description: pathDisplay }, uiTheme);
|
|
1264
|
+
return new Text(text, 0, 0);
|
|
1265
|
+
},
|
|
1266
|
+
|
|
1267
|
+
renderResult(
|
|
1268
|
+
result: { content: Array<{ type: string; text?: string }>; details?: ReadToolDetails },
|
|
1269
|
+
_options: RenderResultOptions,
|
|
1270
|
+
uiTheme: Theme,
|
|
1271
|
+
args?: ReadRenderArgs,
|
|
1272
|
+
): Component {
|
|
1273
|
+
const urlDetails = result.details as ReadUrlToolDetails | undefined;
|
|
1274
|
+
if (urlDetails?.kind === "url" || isReadableUrlPath(args?.file_path || args?.path || "")) {
|
|
1275
|
+
return renderReadUrlResult(
|
|
1276
|
+
result as { content: Array<{ type: string; text?: string }>; details?: ReadUrlToolDetails },
|
|
1277
|
+
_options,
|
|
1278
|
+
uiTheme,
|
|
1279
|
+
);
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
const details = result.details;
|
|
1283
|
+
const contentText = result.content?.find(c => c.type === "text")?.text ?? "";
|
|
1284
|
+
const imageContent = result.content?.find(c => c.type === "image");
|
|
1285
|
+
const rawPath = args?.file_path || args?.path || "";
|
|
1286
|
+
const filePath = shortenPath(rawPath);
|
|
1287
|
+
const lang = getLanguageFromPath(rawPath);
|
|
1288
|
+
|
|
1289
|
+
const warningLines: string[] = [];
|
|
1290
|
+
const truncation = details?.meta?.truncation;
|
|
1291
|
+
const fallback = details?.truncation;
|
|
1292
|
+
if (details?.resolvedPath) {
|
|
1293
|
+
warningLines.push(uiTheme.fg("dim", wrapBrackets(`Resolved path: ${details.resolvedPath}`, uiTheme)));
|
|
1294
|
+
}
|
|
1295
|
+
if (truncation) {
|
|
1296
|
+
if (fallback?.firstLineExceedsLimit) {
|
|
1297
|
+
let warning = `First line exceeds ${formatBytes(fallback.outputBytes ?? fallback.totalBytes)} limit`;
|
|
1298
|
+
if (truncation.artifactId) {
|
|
1299
|
+
warning += `. ${formatFullOutputReference(truncation.artifactId)}`;
|
|
1300
|
+
}
|
|
1301
|
+
warningLines.push(uiTheme.fg("warning", wrapBrackets(warning, uiTheme)));
|
|
1302
|
+
} else {
|
|
1303
|
+
const warning = formatStyledTruncationWarning(details?.meta, uiTheme);
|
|
1304
|
+
if (warning) warningLines.push(warning);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
if (imageContent) {
|
|
1309
|
+
const suffix = details?.suffixResolution;
|
|
1310
|
+
const displayPath = suffix ? shortenPath(suffix.to) : filePath || rawPath || "image";
|
|
1311
|
+
const correction = suffix ? ` ${uiTheme.fg("dim", `(corrected from ${shortenPath(suffix.from)})`)}` : "";
|
|
1312
|
+
const header = renderStatusLine(
|
|
1313
|
+
{ icon: suffix ? "warning" : "success", title: "Read", description: `${displayPath}${correction}` },
|
|
1314
|
+
uiTheme,
|
|
1315
|
+
);
|
|
1316
|
+
const detailLines = contentText ? contentText.split("\n").map(line => uiTheme.fg("toolOutput", line)) : [];
|
|
1317
|
+
const lines = [...detailLines, ...warningLines];
|
|
1318
|
+
const outputBlock = new CachedOutputBlock();
|
|
1319
|
+
return {
|
|
1320
|
+
render: (width: number) =>
|
|
1321
|
+
outputBlock.render(
|
|
1322
|
+
{
|
|
1323
|
+
header,
|
|
1324
|
+
state: "success",
|
|
1325
|
+
sections: [
|
|
1326
|
+
{
|
|
1327
|
+
label: uiTheme.fg("toolTitle", "Details"),
|
|
1328
|
+
lines: lines.length > 0 ? lines : [uiTheme.fg("dim", "(image)")],
|
|
1329
|
+
},
|
|
1330
|
+
],
|
|
1331
|
+
width,
|
|
1332
|
+
},
|
|
1333
|
+
uiTheme,
|
|
1334
|
+
),
|
|
1335
|
+
invalidate: () => outputBlock.invalidate(),
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
const suffix = details?.suffixResolution;
|
|
1340
|
+
const displayPath = suffix ? shortenPath(suffix.to) : filePath;
|
|
1341
|
+
const correction = suffix ? ` ${uiTheme.fg("dim", `(corrected from ${shortenPath(suffix.from)})`)}` : "";
|
|
1342
|
+
let title = displayPath ? `Read ${displayPath}${correction}` : "Read";
|
|
1343
|
+
if (args?.offset !== undefined || args?.limit !== undefined) {
|
|
1344
|
+
const startLine = args.offset ?? 1;
|
|
1345
|
+
const endLine = args.limit !== undefined ? startLine + args.limit - 1 : "";
|
|
1346
|
+
title += `:${startLine}${endLine ? `-${endLine}` : ""}`;
|
|
1347
|
+
}
|
|
1348
|
+
let cachedWidth: number | undefined;
|
|
1349
|
+
let cachedLines: string[] | undefined;
|
|
1350
|
+
return {
|
|
1351
|
+
render: (width: number) => {
|
|
1352
|
+
if (cachedLines && cachedWidth === width) return cachedLines;
|
|
1353
|
+
cachedLines = renderCodeCell(
|
|
1354
|
+
{
|
|
1355
|
+
code: contentText,
|
|
1356
|
+
language: lang,
|
|
1357
|
+
title,
|
|
1358
|
+
status: "complete",
|
|
1359
|
+
output: warningLines.length > 0 ? warningLines.join("\n") : undefined,
|
|
1360
|
+
expanded: true,
|
|
1361
|
+
width,
|
|
1362
|
+
},
|
|
1363
|
+
uiTheme,
|
|
1364
|
+
);
|
|
1365
|
+
cachedWidth = width;
|
|
1366
|
+
return cachedLines;
|
|
1367
|
+
},
|
|
1368
|
+
invalidate: () => {
|
|
1369
|
+
cachedWidth = undefined;
|
|
1370
|
+
cachedLines = undefined;
|
|
1371
|
+
},
|
|
1372
|
+
};
|
|
1373
|
+
},
|
|
1374
|
+
mergeCallAndResult: true,
|
|
1375
|
+
};
|