@oh-my-pi-zen/pi-coding-agent 16.3.6-zen.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13088 -0
- package/README.md +35 -0
- package/dist/cli.js +22542 -0
- package/dist/types/advisor/__tests__/advisor.test.d.ts +1 -0
- package/dist/types/advisor/__tests__/config.test.d.ts +1 -0
- package/dist/types/advisor/__tests__/emission-guard.test.d.ts +1 -0
- package/dist/types/advisor/advise-tool.d.ts +106 -0
- package/dist/types/advisor/config.d.ts +90 -0
- package/dist/types/advisor/emission-guard.d.ts +73 -0
- package/dist/types/advisor/index.d.ts +6 -0
- package/dist/types/advisor/runtime.d.ts +76 -0
- package/dist/types/advisor/transcript-recorder.d.ts +63 -0
- package/dist/types/advisor/watchdog.d.ts +38 -0
- package/dist/types/async/index.d.ts +1 -0
- package/dist/types/async/job-manager.d.ts +121 -0
- package/dist/types/auto-thinking/classifier.d.ts +37 -0
- package/dist/types/autolearn/controller.d.ts +25 -0
- package/dist/types/autolearn/managed-skills.d.ts +45 -0
- package/dist/types/autoresearch/dashboard.d.ts +4 -0
- package/dist/types/autoresearch/git.d.ts +36 -0
- package/dist/types/autoresearch/helpers.d.ts +24 -0
- package/dist/types/autoresearch/index.d.ts +2 -0
- package/dist/types/autoresearch/state.d.ts +17 -0
- package/dist/types/autoresearch/storage.d.ts +142 -0
- package/dist/types/autoresearch/tools/init-experiment.d.ts +27 -0
- package/dist/types/autoresearch/tools/log-experiment.d.ts +21 -0
- package/dist/types/autoresearch/tools/run-experiment.d.ts +7 -0
- package/dist/types/autoresearch/tools/update-notes.d.ts +11 -0
- package/dist/types/autoresearch/types.d.ts +154 -0
- package/dist/types/capability/context-file.d.ts +17 -0
- package/dist/types/capability/extension-module.d.ts +15 -0
- package/dist/types/capability/extension.d.ts +28 -0
- package/dist/types/capability/fs.d.ts +20 -0
- package/dist/types/capability/hook.d.ts +19 -0
- package/dist/types/capability/index.d.ts +80 -0
- package/dist/types/capability/instruction.d.ts +17 -0
- package/dist/types/capability/mcp.d.ts +47 -0
- package/dist/types/capability/prompt.d.ts +15 -0
- package/dist/types/capability/rule-buckets.d.ts +30 -0
- package/dist/types/capability/rule.d.ts +73 -0
- package/dist/types/capability/settings.d.ts +15 -0
- package/dist/types/capability/skill.d.ts +43 -0
- package/dist/types/capability/slash-command.d.ts +17 -0
- package/dist/types/capability/ssh.d.ts +23 -0
- package/dist/types/capability/system-prompt.d.ts +15 -0
- package/dist/types/capability/tool.d.ts +19 -0
- package/dist/types/capability/types.d.ts +154 -0
- package/dist/types/cli/agents-cli.d.ts +12 -0
- package/dist/types/cli/args.d.ts +77 -0
- package/dist/types/cli/auth-broker-cli.d.ts +25 -0
- package/dist/types/cli/auth-gateway-cli.d.ts +26 -0
- package/dist/types/cli/bench-cli.d.ts +85 -0
- package/dist/types/cli/classify-install-target.d.ts +12 -0
- package/dist/types/cli/claude-trace-cli.d.ts +54 -0
- package/dist/types/cli/commands/init-xdg.d.ts +1 -0
- package/dist/types/cli/completion-gen.d.ts +80 -0
- package/dist/types/cli/config-cli.d.ts +22 -0
- package/dist/types/cli/dry-balance-cli.d.ts +113 -0
- package/dist/types/cli/extension-flags.d.ts +36 -0
- package/dist/types/cli/file-processor.d.ts +11 -0
- package/dist/types/cli/flag-tables.d.ts +144 -0
- package/dist/types/cli/gallery-cli.d.ts +49 -0
- package/dist/types/cli/gallery-fixtures/agentic.d.ts +2 -0
- package/dist/types/cli/gallery-fixtures/codeintel.d.ts +3 -0
- package/dist/types/cli/gallery-fixtures/edit.d.ts +3 -0
- package/dist/types/cli/gallery-fixtures/fs.d.ts +2 -0
- package/dist/types/cli/gallery-fixtures/index.d.ts +4 -0
- package/dist/types/cli/gallery-fixtures/interaction.d.ts +3 -0
- package/dist/types/cli/gallery-fixtures/memory.d.ts +2 -0
- package/dist/types/cli/gallery-fixtures/misc.d.ts +3 -0
- package/dist/types/cli/gallery-fixtures/search.d.ts +3 -0
- package/dist/types/cli/gallery-fixtures/shell.d.ts +3 -0
- package/dist/types/cli/gallery-fixtures/types.d.ts +55 -0
- package/dist/types/cli/gallery-fixtures/web.d.ts +2 -0
- package/dist/types/cli/gallery-screenshot.d.ts +35 -0
- package/dist/types/cli/gc-cli.d.ts +58 -0
- package/dist/types/cli/grep-cli.d.ts +17 -0
- package/dist/types/cli/grievances-cli.d.ts +37 -0
- package/dist/types/cli/initial-message.d.ts +17 -0
- package/dist/types/cli/models-cli.d.ts +49 -0
- package/dist/types/cli/plugin-cli.d.ts +32 -0
- package/dist/types/cli/profile-alias.d.ts +29 -0
- package/dist/types/cli/profile-bootstrap.d.ts +55 -0
- package/dist/types/cli/read-cli.d.ts +4 -0
- package/dist/types/cli/session-picker.d.ts +11 -0
- package/dist/types/cli/setup-cli.d.ts +24 -0
- package/dist/types/cli/setup-model-picker.d.ts +14 -0
- package/dist/types/cli/shell-cli.d.ts +8 -0
- package/dist/types/cli/ssh-cli.d.ts +21 -0
- package/dist/types/cli/startup-cwd.d.ts +2 -0
- package/dist/types/cli/stats-cli.d.ts +17 -0
- package/dist/types/cli/tiny-models-cli.d.ts +11 -0
- package/dist/types/cli/ttsr-cli.d.ts +39 -0
- package/dist/types/cli/update-cli.d.ts +106 -0
- package/dist/types/cli/update-cli.test.d.ts +1 -0
- package/dist/types/cli/usage-cli.d.ts +95 -0
- package/dist/types/cli/web-search-cli.d.ts +20 -0
- package/dist/types/cli/worktree-cli.d.ts +26 -0
- package/dist/types/cli-commands.d.ts +33 -0
- package/dist/types/cli.d.ts +3 -0
- package/dist/types/collab/crypto.d.ts +7 -0
- package/dist/types/collab/display-name.d.ts +3 -0
- package/dist/types/collab/guest.d.ts +52 -0
- package/dist/types/collab/host.d.ts +43 -0
- package/dist/types/collab/protocol.d.ts +143 -0
- package/dist/types/collab/relay-client.d.ts +22 -0
- package/dist/types/collab/replication-shrink.d.ts +39 -0
- package/dist/types/commands/acp.d.ts +12 -0
- package/dist/types/commands/agents.d.ts +34 -0
- package/dist/types/commands/auth-broker.d.ts +54 -0
- package/dist/types/commands/auth-gateway.d.ts +35 -0
- package/dist/types/commands/bench.d.ts +37 -0
- package/dist/types/commands/commit.d.ts +27 -0
- package/dist/types/commands/complete.d.ts +6 -0
- package/dist/types/commands/completions.d.ts +13 -0
- package/dist/types/commands/config.d.ts +30 -0
- package/dist/types/commands/dry-balance.d.ts +31 -0
- package/dist/types/commands/gallery.d.ts +47 -0
- package/dist/types/commands/gc.d.ts +37 -0
- package/dist/types/commands/grep.d.ts +42 -0
- package/dist/types/commands/grievances.d.ts +40 -0
- package/dist/types/commands/install.d.ts +51 -0
- package/dist/types/commands/join.d.ts +12 -0
- package/dist/types/commands/launch.d.ts +148 -0
- package/dist/types/commands/models.d.ts +33 -0
- package/dist/types/commands/plugin.d.ts +52 -0
- package/dist/types/commands/read.d.ts +15 -0
- package/dist/types/commands/say.d.ts +24 -0
- package/dist/types/commands/setup.d.ts +34 -0
- package/dist/types/commands/shell.d.ts +21 -0
- package/dist/types/commands/ssh.d.ts +48 -0
- package/dist/types/commands/stats.d.ts +25 -0
- package/dist/types/commands/tiny-models.d.ts +22 -0
- package/dist/types/commands/token.d.ts +34 -0
- package/dist/types/commands/ttsr.d.ts +57 -0
- package/dist/types/commands/update.d.ts +25 -0
- package/dist/types/commands/usage.d.ts +34 -0
- package/dist/types/commands/web-search.d.ts +33 -0
- package/dist/types/commands/worktree.d.ts +31 -0
- package/dist/types/commit/agentic/agent.d.ts +31 -0
- package/dist/types/commit/agentic/fallback.d.ts +5 -0
- package/dist/types/commit/agentic/index.d.ts +2 -0
- package/dist/types/commit/agentic/state.d.ts +58 -0
- package/dist/types/commit/agentic/tools/analyze-file.d.ts +18 -0
- package/dist/types/commit/agentic/tools/git-file-diff.d.ts +9 -0
- package/dist/types/commit/agentic/tools/git-hunk.d.ts +8 -0
- package/dist/types/commit/agentic/tools/git-overview.d.ts +8 -0
- package/dist/types/commit/agentic/tools/index.d.ts +16 -0
- package/dist/types/commit/agentic/tools/propose-changelog.d.ts +27 -0
- package/dist/types/commit/agentic/tools/propose-commit.d.ts +15 -0
- package/dist/types/commit/agentic/tools/recent-commits.d.ts +6 -0
- package/dist/types/commit/agentic/tools/schemas.d.ts +6 -0
- package/dist/types/commit/agentic/tools/split-commit.d.ts +32 -0
- package/dist/types/commit/agentic/topo-sort.d.ts +4 -0
- package/dist/types/commit/agentic/trivial.d.ts +7 -0
- package/dist/types/commit/agentic/validation.d.ts +20 -0
- package/dist/types/commit/analysis/conventional.d.ts +22 -0
- package/dist/types/commit/analysis/index.d.ts +4 -0
- package/dist/types/commit/analysis/scope.d.ts +6 -0
- package/dist/types/commit/analysis/summary.d.ts +19 -0
- package/dist/types/commit/analysis/validation.d.ts +8 -0
- package/dist/types/commit/changelog/detect.d.ts +2 -0
- package/dist/types/commit/changelog/generate.d.ts +29 -0
- package/dist/types/commit/changelog/index.d.ts +30 -0
- package/dist/types/commit/changelog/parse.d.ts +2 -0
- package/dist/types/commit/cli.d.ts +3 -0
- package/dist/types/commit/git/diff.d.ts +5 -0
- package/dist/types/commit/index.d.ts +4 -0
- package/dist/types/commit/map-reduce/index.d.ts +28 -0
- package/dist/types/commit/map-reduce/map-phase.d.ts +17 -0
- package/dist/types/commit/map-reduce/reduce-phase.d.ts +13 -0
- package/dist/types/commit/map-reduce/utils.d.ts +2 -0
- package/dist/types/commit/message.d.ts +2 -0
- package/dist/types/commit/model-selection.d.ts +26 -0
- package/dist/types/commit/pipeline.d.ts +5 -0
- package/dist/types/commit/shared-llm.d.ts +27 -0
- package/dist/types/commit/types.d.ts +78 -0
- package/dist/types/commit/utils/exclusions.d.ts +4 -0
- package/dist/types/commit/utils.d.ts +20 -0
- package/dist/types/config/api-key-resolver.d.ts +43 -0
- package/dist/types/config/append-only-context-mode.d.ts +9 -0
- package/dist/types/config/config-file.d.ts +62 -0
- package/dist/types/config/file-lock.d.ts +29 -0
- package/dist/types/config/inline-tool-descriptors-mode.d.ts +12 -0
- package/dist/types/config/keybindings.d.ts +362 -0
- package/dist/types/config/model-discovery.d.ts +68 -0
- package/dist/types/config/model-registry.d.ts +251 -0
- package/dist/types/config/model-resolver.d.ts +300 -0
- package/dist/types/config/model-roles.d.ts +29 -0
- package/dist/types/config/models-config-schema.d.ts +697 -0
- package/dist/types/config/models-config.d.ts +436 -0
- package/dist/types/config/prompt-templates.d.ts +32 -0
- package/dist/types/config/provider-globals.d.ts +7 -0
- package/dist/types/config/resolve-config-value.d.ts +17 -0
- package/dist/types/config/service-tier.d.ts +49 -0
- package/dist/types/config/settings-schema.d.ts +5668 -0
- package/dist/types/config/settings.d.ts +181 -0
- package/dist/types/config.d.ts +92 -0
- package/dist/types/cursor.d.ts +22 -0
- package/dist/types/dap/client.d.ts +46 -0
- package/dist/types/dap/config.d.ts +19 -0
- package/dist/types/dap/index.d.ts +4 -0
- package/dist/types/dap/session.d.ts +108 -0
- package/dist/types/dap/types.d.ts +534 -0
- package/dist/types/debug/index.d.ts +15 -0
- package/dist/types/debug/log-formatting.d.ts +4 -0
- package/dist/types/debug/log-viewer.d.ts +69 -0
- package/dist/types/debug/profiler.d.ts +24 -0
- package/dist/types/debug/protocol-probe.d.ts +38 -0
- package/dist/types/debug/raw-sse-buffer.d.ts +44 -0
- package/dist/types/debug/raw-sse.d.ts +19 -0
- package/dist/types/debug/remote-debugger.d.ts +45 -0
- package/dist/types/debug/report-bundle.d.ts +58 -0
- package/dist/types/debug/system-info.d.ts +26 -0
- package/dist/types/debug/terminal-info.d.ts +33 -0
- package/dist/types/discovery/agents-md.d.ts +1 -0
- package/dist/types/discovery/agents.d.ts +12 -0
- package/dist/types/discovery/at-imports.d.ts +15 -0
- package/dist/types/discovery/builtin-defaults.d.ts +1 -0
- package/dist/types/discovery/builtin-rules/index.d.ts +7 -0
- package/dist/types/discovery/builtin.d.ts +1 -0
- package/dist/types/discovery/claude-plugins.d.ts +1 -0
- package/dist/types/discovery/claude.d.ts +1 -0
- package/dist/types/discovery/cline.d.ts +1 -0
- package/dist/types/discovery/codex.d.ts +1 -0
- package/dist/types/discovery/cursor.d.ts +16 -0
- package/dist/types/discovery/gemini.d.ts +1 -0
- package/dist/types/discovery/github.d.ts +1 -0
- package/dist/types/discovery/helpers.d.ts +278 -0
- package/dist/types/discovery/index.d.ts +53 -0
- package/dist/types/discovery/mcp-json.d.ts +1 -0
- package/dist/types/discovery/omp-extension-roots.d.ts +43 -0
- package/dist/types/discovery/omp-plugins.d.ts +1 -0
- package/dist/types/discovery/opencode.d.ts +1 -0
- package/dist/types/discovery/plugin-dir-roots.d.ts +15 -0
- package/dist/types/discovery/ssh.d.ts +1 -0
- package/dist/types/discovery/substitute-plugin-root.d.ts +1 -0
- package/dist/types/discovery/vscode.d.ts +1 -0
- package/dist/types/discovery/windsurf.d.ts +13 -0
- package/dist/types/edit/apply-patch/index.d.ts +35 -0
- package/dist/types/edit/apply-patch/parser.d.ts +34 -0
- package/dist/types/edit/diff.d.ts +60 -0
- package/dist/types/edit/file-snapshot-store.d.ts +74 -0
- package/dist/types/edit/hashline/block-resolver.d.ts +9 -0
- package/dist/types/edit/hashline/diff.d.ts +29 -0
- package/dist/types/edit/hashline/execute.d.ts +28 -0
- package/dist/types/edit/hashline/filesystem.d.ts +43 -0
- package/dist/types/edit/hashline/index.d.ts +5 -0
- package/dist/types/edit/hashline/noop-loop-guard.d.ts +72 -0
- package/dist/types/edit/hashline/params.d.ts +4 -0
- package/dist/types/edit/index.d.ts +83 -0
- package/dist/types/edit/modes/apply-patch.d.ts +23 -0
- package/dist/types/edit/modes/patch.d.ts +101 -0
- package/dist/types/edit/modes/replace.d.ts +141 -0
- package/dist/types/edit/normalize.d.ts +31 -0
- package/dist/types/edit/notebook.d.ts +23 -0
- package/dist/types/edit/read-file.d.ts +2 -0
- package/dist/types/edit/renderer.d.ts +118 -0
- package/dist/types/edit/snapshot-details.d.ts +33 -0
- package/dist/types/edit/streaming.d.ts +105 -0
- package/dist/types/eval/__tests__/agent-bridge.test.d.ts +1 -0
- package/dist/types/eval/__tests__/bridge-timeout.test.d.ts +1 -0
- package/dist/types/eval/__tests__/budget-bridge.test.d.ts +1 -0
- package/dist/types/eval/__tests__/completion-bridge.test.d.ts +1 -0
- package/dist/types/eval/__tests__/helpers-local-roots.test.d.ts +1 -0
- package/dist/types/eval/__tests__/idle-timeout.test.d.ts +1 -0
- package/dist/types/eval/__tests__/js-context-manager.test.d.ts +1 -0
- package/dist/types/eval/__tests__/julia-prelude.test.d.ts +1 -0
- package/dist/types/eval/__tests__/kernel-spawn.test.d.ts +1 -0
- package/dist/types/eval/__tests__/prelude-agent.test.d.ts +1 -0
- package/dist/types/eval/agent-bridge.d.ts +48 -0
- package/dist/types/eval/backend-helpers.d.ts +23 -0
- package/dist/types/eval/backend.d.ts +60 -0
- package/dist/types/eval/bridge-timeout.d.ts +27 -0
- package/dist/types/eval/budget-bridge.d.ts +29 -0
- package/dist/types/eval/completion-bridge.d.ts +25 -0
- package/dist/types/eval/concurrency-bridge.d.ts +26 -0
- package/dist/types/eval/executor-base.d.ts +118 -0
- package/dist/types/eval/idle-timeout.d.ts +26 -0
- package/dist/types/eval/index.d.ts +6 -0
- package/dist/types/eval/jl/executor.d.ts +44 -0
- package/dist/types/eval/jl/index.d.ts +11 -0
- package/dist/types/eval/jl/kernel.d.ts +28 -0
- package/dist/types/eval/jl/prelude.d.ts +1 -0
- package/dist/types/eval/jl/runtime.d.ts +22 -0
- package/dist/types/eval/js/context-manager.d.ts +40 -0
- package/dist/types/eval/js/executor.d.ts +38 -0
- package/dist/types/eval/js/index.d.ts +11 -0
- package/dist/types/eval/js/shared/helpers.d.ts +32 -0
- package/dist/types/eval/js/shared/indirect-eval.d.ts +14 -0
- package/dist/types/eval/js/shared/local-module-loader.d.ts +16 -0
- package/dist/types/eval/js/shared/prelude.d.ts +1 -0
- package/dist/types/eval/js/shared/rewrite-imports.d.ts +25 -0
- package/dist/types/eval/js/shared/runtime.d.ts +59 -0
- package/dist/types/eval/js/shared/types.d.ts +24 -0
- package/dist/types/eval/js/tool-bridge.d.ts +20 -0
- package/dist/types/eval/js/worker-core.d.ts +6 -0
- package/dist/types/eval/js/worker-entry.d.ts +1 -0
- package/dist/types/eval/js/worker-protocol.d.ts +83 -0
- package/dist/types/eval/kernel-base.d.ts +105 -0
- package/dist/types/eval/py/__tests__/prelude.test.d.ts +1 -0
- package/dist/types/eval/py/__tests__/runner-shell-output.test.d.ts +1 -0
- package/dist/types/eval/py/display.d.ts +25 -0
- package/dist/types/eval/py/executor.d.ts +107 -0
- package/dist/types/eval/py/index.d.ts +11 -0
- package/dist/types/eval/py/kernel.d.ts +17 -0
- package/dist/types/eval/py/prelude.d.ts +1 -0
- package/dist/types/eval/py/runtime.d.ts +40 -0
- package/dist/types/eval/py/spawn-options.d.ts +58 -0
- package/dist/types/eval/py/tool-bridge.d.ts +16 -0
- package/dist/types/eval/rb/executor.d.ts +77 -0
- package/dist/types/eval/rb/index.d.ts +11 -0
- package/dist/types/eval/rb/kernel.d.ts +31 -0
- package/dist/types/eval/rb/prelude.d.ts +1 -0
- package/dist/types/eval/rb/runtime.d.ts +23 -0
- package/dist/types/eval/runtime-env.d.ts +24 -0
- package/dist/types/eval/session-id.d.ts +3 -0
- package/dist/types/eval/types.d.ts +52 -0
- package/dist/types/exa/index.d.ts +2 -0
- package/dist/types/exa/mcp-client.d.ts +53 -0
- package/dist/types/exa/types.d.ts +72 -0
- package/dist/types/exec/bash-executor.d.ts +45 -0
- package/dist/types/exec/exec.d.ts +25 -0
- package/dist/types/exec/non-interactive-env.d.ts +3 -0
- package/dist/types/export/custom-share.d.ts +19 -0
- package/dist/types/export/html/index.d.ts +78 -0
- package/dist/types/export/html/web-palette.d.ts +117 -0
- package/dist/types/export/share.d.ts +55 -0
- package/dist/types/export/ttsr.d.ts +67 -0
- package/dist/types/extensibility/custom-commands/bundled/ci-green/index.d.ts +9 -0
- package/dist/types/extensibility/custom-commands/bundled/review/index.d.ts +10 -0
- package/dist/types/extensibility/custom-commands/index.d.ts +2 -0
- package/dist/types/extensibility/custom-commands/loader.d.ts +29 -0
- package/dist/types/extensibility/custom-commands/types.d.ts +112 -0
- package/dist/types/extensibility/custom-tools/index.d.ts +6 -0
- package/dist/types/extensibility/custom-tools/loader.d.ts +89 -0
- package/dist/types/extensibility/custom-tools/types.d.ts +244 -0
- package/dist/types/extensibility/custom-tools/wrapper.d.ts +23 -0
- package/dist/types/extensibility/extensions/compact-handler.d.ts +26 -0
- package/dist/types/extensibility/extensions/get-commands-handler.d.ts +29 -0
- package/dist/types/extensibility/extensions/index.d.ts +8 -0
- package/dist/types/extensibility/extensions/loader.d.ts +59 -0
- package/dist/types/extensibility/extensions/model-api.d.ts +17 -0
- package/dist/types/extensibility/extensions/runner.d.ts +161 -0
- package/dist/types/extensibility/extensions/types.d.ts +962 -0
- package/dist/types/extensibility/extensions/wrapper.d.ts +54 -0
- package/dist/types/extensibility/hooks/index.d.ts +6 -0
- package/dist/types/extensibility/hooks/loader.d.ts +65 -0
- package/dist/types/extensibility/hooks/runner.d.ts +126 -0
- package/dist/types/extensibility/hooks/tool-wrapper.d.ts +25 -0
- package/dist/types/extensibility/hooks/types.d.ts +442 -0
- package/dist/types/extensibility/legacy-pi-ai-shim.d.ts +35 -0
- package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +115 -0
- package/dist/types/extensibility/plugins/doctor.d.ts +3 -0
- package/dist/types/extensibility/plugins/git-url.d.ts +44 -0
- package/dist/types/extensibility/plugins/index.d.ts +7 -0
- package/dist/types/extensibility/plugins/installer.d.ts +5 -0
- package/dist/types/extensibility/plugins/legacy-pi-bundled-keys.d.ts +10 -0
- package/dist/types/extensibility/plugins/legacy-pi-bundled-registry.d.ts +10 -0
- package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +79 -0
- package/dist/types/extensibility/plugins/loader.d.ts +59 -0
- package/dist/types/extensibility/plugins/manager.d.ts +76 -0
- package/dist/types/extensibility/plugins/marketplace/cache.d.ts +41 -0
- package/dist/types/extensibility/plugins/marketplace/fetcher.d.ts +48 -0
- package/dist/types/extensibility/plugins/marketplace/index.d.ts +6 -0
- package/dist/types/extensibility/plugins/marketplace/manager.d.ts +57 -0
- package/dist/types/extensibility/plugins/marketplace/registry.d.ts +34 -0
- package/dist/types/extensibility/plugins/marketplace/source-resolver.d.ts +28 -0
- package/dist/types/extensibility/plugins/marketplace/types.d.ts +131 -0
- package/dist/types/extensibility/plugins/marketplace-auto-update.d.ts +8 -0
- package/dist/types/extensibility/plugins/parser.d.ts +53 -0
- package/dist/types/extensibility/plugins/runtime-config.d.ts +3 -0
- package/dist/types/extensibility/plugins/types.d.ts +149 -0
- package/dist/types/extensibility/session-handler-types.d.ts +23 -0
- package/dist/types/extensibility/shared-events.d.ts +308 -0
- package/dist/types/extensibility/skills.d.ts +97 -0
- package/dist/types/extensibility/slash-commands.d.ts +38 -0
- package/dist/types/extensibility/tool-event-input.d.ts +9 -0
- package/dist/types/extensibility/tool-proxy.d.ts +4 -0
- package/dist/types/extensibility/typebox.d.ts +177 -0
- package/dist/types/extensibility/utils.d.ts +24 -0
- package/dist/types/goals/guided-setup.d.ts +18 -0
- package/dist/types/goals/index.d.ts +3 -0
- package/dist/types/goals/runtime.d.ts +69 -0
- package/dist/types/goals/state.d.ts +35 -0
- package/dist/types/goals/tools/goal-tool.d.ts +53 -0
- package/dist/types/hindsight/backend.d.ts +13 -0
- package/dist/types/hindsight/bank.d.ts +62 -0
- package/dist/types/hindsight/client.d.ts +228 -0
- package/dist/types/hindsight/client.test.d.ts +1 -0
- package/dist/types/hindsight/config.d.ts +51 -0
- package/dist/types/hindsight/content.d.ts +73 -0
- package/dist/types/hindsight/index.d.ts +8 -0
- package/dist/types/hindsight/mental-models.d.ts +134 -0
- package/dist/types/hindsight/state.d.ts +105 -0
- package/dist/types/hindsight/transcript.d.ts +28 -0
- package/dist/types/index.d.ts +43 -0
- package/dist/types/internal-urls/__tests__/ssh-protocol.test.d.ts +1 -0
- package/dist/types/internal-urls/agent-protocol.d.ts +13 -0
- package/dist/types/internal-urls/artifact-protocol.d.ts +15 -0
- package/dist/types/internal-urls/docs-index.d.ts +19 -0
- package/dist/types/internal-urls/filesystem-resource.d.ts +9 -0
- package/dist/types/internal-urls/history-protocol.d.ts +14 -0
- package/dist/types/internal-urls/index.d.ts +25 -0
- package/dist/types/internal-urls/issue-pr-protocol.d.ts +17 -0
- package/dist/types/internal-urls/json-query.d.ts +30 -0
- package/dist/types/internal-urls/local-protocol.d.ts +79 -0
- package/dist/types/internal-urls/mcp-protocol.d.ts +12 -0
- package/dist/types/internal-urls/memory-protocol.d.ts +24 -0
- package/dist/types/internal-urls/omp-protocol.d.ts +13 -0
- package/dist/types/internal-urls/parse.d.ts +19 -0
- package/dist/types/internal-urls/registry-helpers.d.ts +12 -0
- package/dist/types/internal-urls/router.d.ts +21 -0
- package/dist/types/internal-urls/rule-protocol.d.ts +7 -0
- package/dist/types/internal-urls/skill-protocol.d.ts +14 -0
- package/dist/types/internal-urls/ssh-protocol.d.ts +10 -0
- package/dist/types/internal-urls/types.d.ts +175 -0
- package/dist/types/internal-urls/vault-protocol.d.ts +93 -0
- package/dist/types/irc/bus.d.ts +86 -0
- package/dist/types/jsonrpc/message-framing.d.ts +35 -0
- package/dist/types/lib/xai-http.d.ts +40 -0
- package/dist/types/lsp/client.d.ts +84 -0
- package/dist/types/lsp/clients/biome-client.d.ts +16 -0
- package/dist/types/lsp/clients/index.d.ts +19 -0
- package/dist/types/lsp/clients/lsp-linter-client.d.ts +16 -0
- package/dist/types/lsp/clients/swiftlint-client.d.ts +20 -0
- package/dist/types/lsp/config.d.ts +69 -0
- package/dist/types/lsp/diagnostics-ledger.d.ts +10 -0
- package/dist/types/lsp/edits.d.ts +34 -0
- package/dist/types/lsp/format-options.d.ts +32 -0
- package/dist/types/lsp/index.d.ts +120 -0
- package/dist/types/lsp/lspmux.d.ts +58 -0
- package/dist/types/lsp/render.d.ts +32 -0
- package/dist/types/lsp/startup-events.d.ts +11 -0
- package/dist/types/lsp/types.d.ts +300 -0
- package/dist/types/lsp/utils.d.ts +116 -0
- package/dist/types/main.d.ts +70 -0
- package/dist/types/markit/converters/docx.d.ts +6 -0
- package/dist/types/markit/converters/epub.d.ts +15 -0
- package/dist/types/markit/converters/pdf/columns.d.ts +35 -0
- package/dist/types/markit/converters/pdf/extract.d.ts +10 -0
- package/dist/types/markit/converters/pdf/grid.d.ts +25 -0
- package/dist/types/markit/converters/pdf/headers.d.ts +24 -0
- package/dist/types/markit/converters/pdf/index.d.ts +6 -0
- package/dist/types/markit/converters/pdf/render.d.ts +24 -0
- package/dist/types/markit/converters/pdf/types.d.ts +75 -0
- package/dist/types/markit/converters/pptx.d.ts +57 -0
- package/dist/types/markit/converters/xlsx.d.ts +25 -0
- package/dist/types/markit/index.d.ts +2 -0
- package/dist/types/markit/registry.d.ts +16 -0
- package/dist/types/markit/types.d.ts +30 -0
- package/dist/types/mcp/client.d.ts +83 -0
- package/dist/types/mcp/config-writer.d.ts +101 -0
- package/dist/types/mcp/config.d.ts +75 -0
- package/dist/types/mcp/index.d.ts +18 -0
- package/dist/types/mcp/json-rpc.d.ts +32 -0
- package/dist/types/mcp/loader.d.ts +44 -0
- package/dist/types/mcp/manager.d.ts +215 -0
- package/dist/types/mcp/oauth-credentials.d.ts +17 -0
- package/dist/types/mcp/oauth-discovery.d.ts +65 -0
- package/dist/types/mcp/oauth-flow.d.ts +145 -0
- package/dist/types/mcp/render.d.ts +25 -0
- package/dist/types/mcp/smithery-auth.d.ts +16 -0
- package/dist/types/mcp/smithery-connect.d.ts +38 -0
- package/dist/types/mcp/smithery-registry.d.ts +52 -0
- package/dist/types/mcp/smithery-registry.test.d.ts +1 -0
- package/dist/types/mcp/startup-events.d.ts +28 -0
- package/dist/types/mcp/timeout.d.ts +9 -0
- package/dist/types/mcp/tool-bridge.d.ts +95 -0
- package/dist/types/mcp/tool-cache.d.ts +8 -0
- package/dist/types/mcp/transports/http.d.ts +45 -0
- package/dist/types/mcp/transports/index.d.ts +6 -0
- package/dist/types/mcp/transports/sse.d.ts +20 -0
- package/dist/types/mcp/transports/stdio.d.ts +108 -0
- package/dist/types/mcp/transports/stdio.test.d.ts +1 -0
- package/dist/types/mcp/types.d.ts +340 -0
- package/dist/types/memories/index.d.ts +54 -0
- package/dist/types/memories/storage.d.ts +110 -0
- package/dist/types/memory-backend/index.d.ts +7 -0
- package/dist/types/memory-backend/local-backend.d.ts +10 -0
- package/dist/types/memory-backend/off-backend.d.ts +7 -0
- package/dist/types/memory-backend/resolve.d.ts +16 -0
- package/dist/types/memory-backend/runtime.d.ts +4 -0
- package/dist/types/memory-backend/types.d.ts +132 -0
- package/dist/types/mnemopi/backend.d.ts +4 -0
- package/dist/types/mnemopi/config.d.ts +60 -0
- package/dist/types/mnemopi/embed-client.d.ts +53 -0
- package/dist/types/mnemopi/embed-protocol.d.ts +52 -0
- package/dist/types/mnemopi/embed-worker.d.ts +12 -0
- package/dist/types/mnemopi/index.d.ts +3 -0
- package/dist/types/mnemopi/state.d.ts +130 -0
- package/dist/types/modes/acp/acp-agent.d.ts +60 -0
- package/dist/types/modes/acp/acp-client-bridge.d.ts +9 -0
- package/dist/types/modes/acp/acp-event-mapper.d.ts +33 -0
- package/dist/types/modes/acp/acp-mode.d.ts +5 -0
- package/dist/types/modes/acp/index.d.ts +2 -0
- package/dist/types/modes/acp/terminal-auth.d.ts +6 -0
- package/dist/types/modes/components/__tests__/move-overlay.test.d.ts +1 -0
- package/dist/types/modes/components/__tests__/skill-message.test.d.ts +1 -0
- package/dist/types/modes/components/advisor-config.d.ts +59 -0
- package/dist/types/modes/components/advisor-message.d.ts +11 -0
- package/dist/types/modes/components/agent-dashboard.d.ts +22 -0
- package/dist/types/modes/components/agent-hub.d.ts +77 -0
- package/dist/types/modes/components/agent-transcript-viewer.d.ts +40 -0
- package/dist/types/modes/components/assistant-message.d.ts +58 -0
- package/dist/types/modes/components/background-tan-message.d.ts +9 -0
- package/dist/types/modes/components/bash-execution.d.ts +35 -0
- package/dist/types/modes/components/bordered-loader.d.ts +11 -0
- package/dist/types/modes/components/btw-panel.d.ts +19 -0
- package/dist/types/modes/components/cache-invalidation-marker.d.ts +52 -0
- package/dist/types/modes/components/chat-block.d.ts +64 -0
- package/dist/types/modes/components/chat-transcript-builder.d.ts +45 -0
- package/dist/types/modes/components/collab-prompt-message.d.ts +10 -0
- package/dist/types/modes/components/compaction-summary-message.d.ts +46 -0
- package/dist/types/modes/components/copy-selector.d.ts +22 -0
- package/dist/types/modes/components/countdown-timer.d.ts +14 -0
- package/dist/types/modes/components/custom-editor.d.ts +163 -0
- package/dist/types/modes/components/custom-editor.test.d.ts +1 -0
- package/dist/types/modes/components/custom-message.d.ts +15 -0
- package/dist/types/modes/components/diff.d.ts +11 -0
- package/dist/types/modes/components/dynamic-border.d.ts +14 -0
- package/dist/types/modes/components/error-banner.d.ts +11 -0
- package/dist/types/modes/components/eval-execution.d.ts +29 -0
- package/dist/types/modes/components/execution-shared.d.ts +46 -0
- package/dist/types/modes/components/extensions/extension-dashboard.d.ts +43 -0
- package/dist/types/modes/components/extensions/extension-list.d.ts +52 -0
- package/dist/types/modes/components/extensions/index.d.ts +8 -0
- package/dist/types/modes/components/extensions/inspector-panel.d.ts +8 -0
- package/dist/types/modes/components/extensions/state-manager.d.ts +50 -0
- package/dist/types/modes/components/extensions/types.d.ts +147 -0
- package/dist/types/modes/components/footer.d.ts +30 -0
- package/dist/types/modes/components/history-search.d.ts +7 -0
- package/dist/types/modes/components/hook-editor.d.ts +24 -0
- package/dist/types/modes/components/hook-input.d.ts +19 -0
- package/dist/types/modes/components/hook-message.d.ts +15 -0
- package/dist/types/modes/components/hook-selector.d.ts +68 -0
- package/dist/types/modes/components/index.d.ts +38 -0
- package/dist/types/modes/components/keybinding-hints.d.ts +40 -0
- package/dist/types/modes/components/late-diagnostics-message.d.ts +20 -0
- package/dist/types/modes/components/login-dialog.d.ts +40 -0
- package/dist/types/modes/components/logout-account-selector.d.ts +8 -0
- package/dist/types/modes/components/mcp-add-wizard.d.ts +38 -0
- package/dist/types/modes/components/message-frame.d.ts +44 -0
- package/dist/types/modes/components/model-selector.d.ts +36 -0
- package/dist/types/modes/components/move-overlay.d.ts +23 -0
- package/dist/types/modes/components/oauth-selector.d.ts +23 -0
- package/dist/types/modes/components/omfg-panel.d.ts +19 -0
- package/dist/types/modes/components/overlay-box.d.ts +17 -0
- package/dist/types/modes/components/plan-review-overlay.d.ts +61 -0
- package/dist/types/modes/components/plan-toc.d.ts +41 -0
- package/dist/types/modes/components/plugin-selector.d.ts +27 -0
- package/dist/types/modes/components/plugin-settings.d.ts +103 -0
- package/dist/types/modes/components/queue-mode-selector.d.ts +10 -0
- package/dist/types/modes/components/read-tool-group.d.ts +38 -0
- package/dist/types/modes/components/reset-usage-selector.d.ts +12 -0
- package/dist/types/modes/components/segment-track.d.ts +27 -0
- package/dist/types/modes/components/select-list-mouse-routing.d.ts +2 -0
- package/dist/types/modes/components/selector-helpers.d.ts +53 -0
- package/dist/types/modes/components/session-selector.d.ts +94 -0
- package/dist/types/modes/components/settings-defs.d.ts +60 -0
- package/dist/types/modes/components/settings-selector.d.ts +70 -0
- package/dist/types/modes/components/show-images-selector.d.ts +10 -0
- package/dist/types/modes/components/skill-message.d.ts +9 -0
- package/dist/types/modes/components/snapcompact-shape-preview.d.ts +31 -0
- package/dist/types/modes/components/status-line/component.d.ts +94 -0
- package/dist/types/modes/components/status-line/component.test.d.ts +1 -0
- package/dist/types/modes/components/status-line/context-thresholds.d.ts +10 -0
- package/dist/types/modes/components/status-line/git-utils.d.ts +22 -0
- package/dist/types/modes/components/status-line/index.d.ts +5 -0
- package/dist/types/modes/components/status-line/presets.d.ts +3 -0
- package/dist/types/modes/components/status-line/segments.d.ts +5 -0
- package/dist/types/modes/components/status-line/separators.d.ts +3 -0
- package/dist/types/modes/components/status-line/token-rate.d.ts +10 -0
- package/dist/types/modes/components/status-line/types.d.ts +150 -0
- package/dist/types/modes/components/theme-selector.d.ts +11 -0
- package/dist/types/modes/components/thinking-selector.d.ts +11 -0
- package/dist/types/modes/components/tiny-title-download-progress.d.ts +11 -0
- package/dist/types/modes/components/todo-reminder.d.ts +15 -0
- package/dist/types/modes/components/tool-execution.d.ts +117 -0
- package/dist/types/modes/components/transcript-container.d.ts +86 -0
- package/dist/types/modes/components/tree-selector.d.ts +31 -0
- package/dist/types/modes/components/ttsr-notification.d.ts +17 -0
- package/dist/types/modes/components/usage-row.d.ts +3 -0
- package/dist/types/modes/components/user-message-selector.d.ts +28 -0
- package/dist/types/modes/components/user-message.d.ts +9 -0
- package/dist/types/modes/components/visual-truncate.d.ts +19 -0
- package/dist/types/modes/components/welcome.d.ts +66 -0
- package/dist/types/modes/controllers/btw-controller.d.ts +14 -0
- package/dist/types/modes/controllers/command-controller-shared.d.ts +47 -0
- package/dist/types/modes/controllers/command-controller.d.ts +55 -0
- package/dist/types/modes/controllers/event-controller.d.ts +28 -0
- package/dist/types/modes/controllers/extension-ui-controller.d.ts +88 -0
- package/dist/types/modes/controllers/input-controller.d.ts +71 -0
- package/dist/types/modes/controllers/mcp-command-controller.d.ts +44 -0
- package/dist/types/modes/controllers/omfg-controller.d.ts +10 -0
- package/dist/types/modes/controllers/omfg-rule.d.ts +26 -0
- package/dist/types/modes/controllers/selector-controller.d.ts +61 -0
- package/dist/types/modes/controllers/session-focus-controller.d.ts +31 -0
- package/dist/types/modes/controllers/ssh-command-controller.d.ts +10 -0
- package/dist/types/modes/controllers/streaming-reveal.d.ts +45 -0
- package/dist/types/modes/controllers/tan-command-controller.d.ts +6 -0
- package/dist/types/modes/controllers/todo-command-controller.d.ts +7 -0
- package/dist/types/modes/controllers/tool-args-reveal.d.ts +77 -0
- package/dist/types/modes/emoji-autocomplete.d.ts +16 -0
- package/dist/types/modes/gradient-highlight.d.ts +32 -0
- package/dist/types/modes/image-references.d.ts +28 -0
- package/dist/types/modes/index.d.ts +10 -0
- package/dist/types/modes/interactive-mode.d.ts +401 -0
- package/dist/types/modes/internal-url-autocomplete.d.ts +43 -0
- package/dist/types/modes/loop-limit.d.ts +35 -0
- package/dist/types/modes/magic-keywords.d.ts +26 -0
- package/dist/types/modes/markdown-prose.d.ts +27 -0
- package/dist/types/modes/oauth-manual-input.d.ts +15 -0
- package/dist/types/modes/orchestrate.d.ts +15 -0
- package/dist/types/modes/print-mode.d.ts +29 -0
- package/dist/types/modes/prompt-action-autocomplete.d.ts +46 -0
- package/dist/types/modes/rpc/host-tools.d.ts +16 -0
- package/dist/types/modes/rpc/host-uris.d.ts +38 -0
- package/dist/types/modes/rpc/rpc-client.d.ts +304 -0
- package/dist/types/modes/rpc/rpc-mode.d.ts +145 -0
- package/dist/types/modes/rpc/rpc-subagents.d.ts +24 -0
- package/dist/types/modes/rpc/rpc-types.d.ts +705 -0
- package/dist/types/modes/running-subagent-badge.d.ts +6 -0
- package/dist/types/modes/runtime-init.d.ts +25 -0
- package/dist/types/modes/session-observer-registry.d.ts +35 -0
- package/dist/types/modes/session-teardown.d.ts +63 -0
- package/dist/types/modes/session-teardown.test.d.ts +1 -0
- package/dist/types/modes/setup-version.d.ts +11 -0
- package/dist/types/modes/setup-wizard/index.d.ts +22 -0
- package/dist/types/modes/setup-wizard/lazy.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/glyph.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/outro.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/providers.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/sign-in.d.ts +22 -0
- package/dist/types/modes/setup-wizard/scenes/splash.d.ts +11 -0
- package/dist/types/modes/setup-wizard/scenes/theme.d.ts +2 -0
- package/dist/types/modes/setup-wizard/scenes/types.d.ts +52 -0
- package/dist/types/modes/setup-wizard/scenes/web-search.d.ts +23 -0
- package/dist/types/modes/setup-wizard/startup-splash.d.ts +7 -0
- package/dist/types/modes/setup-wizard/wizard-overlay.d.ts +15 -0
- package/dist/types/modes/shared.d.ts +15 -0
- package/dist/types/modes/skill-command.d.ts +32 -0
- package/dist/types/modes/theme/defaults/index.d.ts +9436 -0
- package/dist/types/modes/theme/mermaid-cache.d.ts +26 -0
- package/dist/types/modes/theme/mermaid-rendering.test.d.ts +1 -0
- package/dist/types/modes/theme/shimmer.d.ts +40 -0
- package/dist/types/modes/theme/theme.d.ts +360 -0
- package/dist/types/modes/turn-budget.d.ts +18 -0
- package/dist/types/modes/types.d.ts +399 -0
- package/dist/types/modes/ultrathink.d.ts +15 -0
- package/dist/types/modes/utils/context-usage.d.ts +64 -0
- package/dist/types/modes/utils/copy-targets.d.ts +75 -0
- package/dist/types/modes/utils/hotkeys-markdown.d.ts +5 -0
- package/dist/types/modes/utils/interactive-context-helpers.d.ts +14 -0
- package/dist/types/modes/utils/keybinding-matchers.d.ts +32 -0
- package/dist/types/modes/utils/tools-markdown.d.ts +5 -0
- package/dist/types/modes/utils/transcript-render-helpers.d.ts +63 -0
- package/dist/types/modes/utils/ui-helpers.d.ts +55 -0
- package/dist/types/modes/workflow.d.ts +15 -0
- package/dist/types/plan-mode/approved-plan-prompt.test.d.ts +1 -0
- package/dist/types/plan-mode/approved-plan.d.ts +68 -0
- package/dist/types/plan-mode/plan-handoff.d.ts +20 -0
- package/dist/types/plan-mode/plan-protection.d.ts +12 -0
- package/dist/types/plan-mode/state.d.ts +6 -0
- package/dist/types/registry/agent-lifecycle.d.ts +66 -0
- package/dist/types/registry/agent-registry.d.ts +97 -0
- package/dist/types/sdk.d.ts +370 -0
- package/dist/types/secrets/index.d.ts +9 -0
- package/dist/types/secrets/obfuscator.d.ts +63 -0
- package/dist/types/secrets/regex.d.ts +2 -0
- package/dist/types/session/agent-session.d.ts +1419 -0
- package/dist/types/session/agent-storage.d.ts +97 -0
- package/dist/types/session/artifacts.d.ts +61 -0
- package/dist/types/session/auth-broker-config.d.ts +45 -0
- package/dist/types/session/auth-storage.d.ts +7 -0
- package/dist/types/session/blob-store.d.ts +68 -0
- package/dist/types/session/client-bridge.d.ts +88 -0
- package/dist/types/session/codex-auto-reset.d.ts +111 -0
- package/dist/types/session/compact-modes.d.ts +60 -0
- package/dist/types/session/exit-diagnostics.d.ts +48 -0
- package/dist/types/session/history-storage.d.ts +30 -0
- package/dist/types/session/indexed-session-storage.d.ts +65 -0
- package/dist/types/session/messages.d.ts +220 -0
- package/dist/types/session/messages.test.d.ts +1 -0
- package/dist/types/session/provider-image-budget.d.ts +3 -0
- package/dist/types/session/redis-session-storage.d.ts +51 -0
- package/dist/types/session/session-context.d.ts +44 -0
- package/dist/types/session/session-dump-format.d.ts +30 -0
- package/dist/types/session/session-entries.d.ts +197 -0
- package/dist/types/session/session-history-format.d.ts +49 -0
- package/dist/types/session/session-listing.d.ts +78 -0
- package/dist/types/session/session-loader.d.ts +29 -0
- package/dist/types/session/session-manager.d.ts +306 -0
- package/dist/types/session/session-migrations.d.ts +12 -0
- package/dist/types/session/session-paths.d.ts +25 -0
- package/dist/types/session/session-persistence.d.ts +12 -0
- package/dist/types/session/session-storage.d.ts +129 -0
- package/dist/types/session/session-title-slot.d.ts +19 -0
- package/dist/types/session/settings-stream-fn.d.ts +21 -0
- package/dist/types/session/shake-types.d.ts +24 -0
- package/dist/types/session/snapcompact-inline.d.ts +145 -0
- package/dist/types/session/snapcompact-savings-journal.d.ts +46 -0
- package/dist/types/session/sql-session-storage.d.ts +72 -0
- package/dist/types/session/streaming-output.d.ts +229 -0
- package/dist/types/session/tool-choice-queue.d.ts +94 -0
- package/dist/types/session/turn-persistence.d.ts +88 -0
- package/dist/types/session/unexpected-stop-classifier.d.ts +13 -0
- package/dist/types/session/yield-queue.d.ts +37 -0
- package/dist/types/slash-commands/acp-builtins.d.ts +34 -0
- package/dist/types/slash-commands/available-commands.d.ts +34 -0
- package/dist/types/slash-commands/builtin-registry.d.ts +36 -0
- package/dist/types/slash-commands/helpers/active-oauth-account.d.ts +14 -0
- package/dist/types/slash-commands/helpers/collab-qrcode.d.ts +13 -0
- package/dist/types/slash-commands/helpers/context-report.d.ts +7 -0
- package/dist/types/slash-commands/helpers/format.d.ts +10 -0
- package/dist/types/slash-commands/helpers/logout.d.ts +15 -0
- package/dist/types/slash-commands/helpers/marketplace-manager.d.ts +8 -0
- package/dist/types/slash-commands/helpers/mcp.d.ts +3 -0
- package/dist/types/slash-commands/helpers/parse.d.ts +33 -0
- package/dist/types/slash-commands/helpers/reset-usage.d.ts +27 -0
- package/dist/types/slash-commands/helpers/ssh.d.ts +3 -0
- package/dist/types/slash-commands/helpers/stats-dashboard.d.ts +13 -0
- package/dist/types/slash-commands/helpers/todo.d.ts +3 -0
- package/dist/types/slash-commands/helpers/usage-report.d.ts +7 -0
- package/dist/types/slash-commands/marketplace-install-parser.d.ts +33 -0
- package/dist/types/slash-commands/types.d.ts +127 -0
- package/dist/types/ssh/__tests__/connection-manager-args.test.d.ts +1 -0
- package/dist/types/ssh/__tests__/connection-manager-timeout.test.d.ts +1 -0
- package/dist/types/ssh/__tests__/file-transfer-posix-guard.test.d.ts +1 -0
- package/dist/types/ssh/__tests__/sshfs-mount.test.d.ts +1 -0
- package/dist/types/ssh/config-writer.d.ts +49 -0
- package/dist/types/ssh/connection-manager.d.ts +109 -0
- package/dist/types/ssh/file-transfer.d.ts +79 -0
- package/dist/types/ssh/ssh-executor.d.ts +37 -0
- package/dist/types/ssh/sshfs-mount.d.ts +15 -0
- package/dist/types/ssh/utils.d.ts +24 -0
- package/dist/types/startup-splash.d.ts +12 -0
- package/dist/types/stt/asr-client.d.ts +68 -0
- package/dist/types/stt/asr-protocol.d.ts +97 -0
- package/dist/types/stt/asr-worker.d.ts +2 -0
- package/dist/types/stt/downloader.d.ts +47 -0
- package/dist/types/stt/endpointer.d.ts +59 -0
- package/dist/types/stt/index.d.ts +8 -0
- package/dist/types/stt/models.d.ts +120 -0
- package/dist/types/stt/recorder.d.ts +30 -0
- package/dist/types/stt/stt-controller.d.ts +24 -0
- package/dist/types/stt/submit-trigger.d.ts +30 -0
- package/dist/types/stt/transcriber.d.ts +14 -0
- package/dist/types/stt/wav.d.ts +29 -0
- package/dist/types/subprocess/worker-client.d.ts +163 -0
- package/dist/types/subprocess/worker-runtime.d.ts +118 -0
- package/dist/types/system-prompt.d.ts +128 -0
- package/dist/types/system-prompt.test.d.ts +1 -0
- package/dist/types/task/agents.d.ts +28 -0
- package/dist/types/task/commands.d.ts +35 -0
- package/dist/types/task/discovery.d.ts +20 -0
- package/dist/types/task/executor.d.ts +214 -0
- package/dist/types/task/index.d.ts +79 -0
- package/dist/types/task/isolation-runner.d.ts +128 -0
- package/dist/types/task/name-generator.d.ts +16 -0
- package/dist/types/task/omp-command.d.ts +7 -0
- package/dist/types/task/output-manager.d.ts +20 -0
- package/dist/types/task/parallel.d.ts +55 -0
- package/dist/types/task/persisted-revive.d.ts +36 -0
- package/dist/types/task/provider-concurrency.d.ts +40 -0
- package/dist/types/task/render.d.ts +34 -0
- package/dist/types/task/render.test.d.ts +1 -0
- package/dist/types/task/renderer.d.ts +14 -0
- package/dist/types/task/repair-args.d.ts +53 -0
- package/dist/types/task/spawn-policy.d.ts +17 -0
- package/dist/types/task/spawn-policy.test.d.ts +1 -0
- package/dist/types/task/subprocess-tool-registry.d.ts +72 -0
- package/dist/types/task/types.d.ts +384 -0
- package/dist/types/task/worktree.d.ts +135 -0
- package/dist/types/task/yield-assembly.d.ts +28 -0
- package/dist/types/telemetry-export.d.ts +19 -0
- package/dist/types/thinking.d.ts +96 -0
- package/dist/types/tiny/device.d.ts +78 -0
- package/dist/types/tiny/dtype.d.ts +85 -0
- package/dist/types/tiny/models.d.ts +230 -0
- package/dist/types/tiny/text.d.ts +44 -0
- package/dist/types/tiny/title-client.d.ts +68 -0
- package/dist/types/tiny/title-protocol.d.ts +78 -0
- package/dist/types/tiny/worker.d.ts +2 -0
- package/dist/types/tool-discovery/mode.d.ts +8 -0
- package/dist/types/tool-discovery/tool-index.d.ts +57 -0
- package/dist/types/tools/__tests__/eval-description.test.d.ts +1 -0
- package/dist/types/tools/__tests__/json-tree.test.d.ts +1 -0
- package/dist/types/tools/acp-bridge.d.ts +29 -0
- package/dist/types/tools/approval.d.ts +46 -0
- package/dist/types/tools/ask.d.ts +119 -0
- package/dist/types/tools/ast-edit.d.ts +84 -0
- package/dist/types/tools/ast-grep.d.ts +76 -0
- package/dist/types/tools/auto-generated-guard.d.ts +17 -0
- package/dist/types/tools/bash-command-fixup.d.ts +11 -0
- package/dist/types/tools/bash-interactive.d.ts +16 -0
- package/dist/types/tools/bash-interceptor.d.ts +24 -0
- package/dist/types/tools/bash-pty-selection.d.ts +7 -0
- package/dist/types/tools/bash-skill-urls.d.ts +31 -0
- package/dist/types/tools/bash.d.ts +173 -0
- package/dist/types/tools/browser/aria/aria-snapshot.d.ts +39 -0
- package/dist/types/tools/browser/attach.d.ts +34 -0
- package/dist/types/tools/browser/cmux/cmux-tab.d.ts +212 -0
- package/dist/types/tools/browser/cmux/rpc.d.ts +70 -0
- package/dist/types/tools/browser/cmux/socket-client.d.ts +19 -0
- package/dist/types/tools/browser/launch.d.ts +67 -0
- package/dist/types/tools/browser/readable.d.ts +17 -0
- package/dist/types/tools/browser/registry.d.ts +58 -0
- package/dist/types/tools/browser/render.d.ts +54 -0
- package/dist/types/tools/browser/run-cancellation.d.ts +4 -0
- package/dist/types/tools/browser/tab-protocol.d.ts +146 -0
- package/dist/types/tools/browser/tab-supervisor.d.ts +114 -0
- package/dist/types/tools/browser/tab-worker-entry.d.ts +1 -0
- package/dist/types/tools/browser/tab-worker.d.ts +56 -0
- package/dist/types/tools/browser.d.ts +96 -0
- package/dist/types/tools/builtin-names.d.ts +6 -0
- package/dist/types/tools/checkpoint.d.ts +72 -0
- package/dist/types/tools/conflict-detect.d.ts +221 -0
- package/dist/types/tools/context.d.ts +19 -0
- package/dist/types/tools/debug.d.ts +157 -0
- package/dist/types/tools/eval-backends.d.ts +15 -0
- package/dist/types/tools/eval-render.d.ts +58 -0
- package/dist/types/tools/eval.d.ts +66 -0
- package/dist/types/tools/fetch.d.ts +99 -0
- package/dist/types/tools/file-recorder.d.ts +13 -0
- package/dist/types/tools/fs-cache-invalidation.d.ts +15 -0
- package/dist/types/tools/gh-cache-invalidation.d.ts +6 -0
- package/dist/types/tools/gh-format.d.ts +6 -0
- package/dist/types/tools/gh-renderer.d.ts +25 -0
- package/dist/types/tools/gh.d.ts +331 -0
- package/dist/types/tools/github-cache.d.ts +123 -0
- package/dist/types/tools/glob.d.ts +96 -0
- package/dist/types/tools/grep.d.ts +99 -0
- package/dist/types/tools/grouped-file-output.d.ts +70 -0
- package/dist/types/tools/image-gen.d.ts +66 -0
- package/dist/types/tools/index.d.ts +368 -0
- package/dist/types/tools/inspect-image-renderer.d.ts +26 -0
- package/dist/types/tools/inspect-image.d.ts +32 -0
- package/dist/types/tools/irc.d.ts +112 -0
- package/dist/types/tools/job.d.ts +73 -0
- package/dist/types/tools/json-tree.d.ts +23 -0
- package/dist/types/tools/jtd-to-json-schema.d.ts +29 -0
- package/dist/types/tools/jtd-to-typescript.d.ts +26 -0
- package/dist/types/tools/jtd-utils.d.ts +42 -0
- package/dist/types/tools/learn.d.ts +44 -0
- package/dist/types/tools/list-limit.d.ts +12 -0
- package/dist/types/tools/manage-skill.d.ts +31 -0
- package/dist/types/tools/match-line-format.d.ts +11 -0
- package/dist/types/tools/memory-edit.d.ts +31 -0
- package/dist/types/tools/memory-recall.d.ts +23 -0
- package/dist/types/tools/memory-reflect.d.ts +25 -0
- package/dist/types/tools/memory-render.d.ts +63 -0
- package/dist/types/tools/memory-retain.d.ts +29 -0
- package/dist/types/tools/output-meta.d.ts +211 -0
- package/dist/types/tools/output-schema-validator.d.ts +77 -0
- package/dist/types/tools/path-utils.d.ts +267 -0
- package/dist/types/tools/plan-mode-guard.d.ts +33 -0
- package/dist/types/tools/read.d.ts +87 -0
- package/dist/types/tools/render-utils.d.ts +218 -0
- package/dist/types/tools/renderers.d.ts +49 -0
- package/dist/types/tools/report-tool-issue.d.ts +127 -0
- package/dist/types/tools/resolve.d.ts +94 -0
- package/dist/types/tools/review.d.ts +59 -0
- package/dist/types/tools/search-tool-bm25.d.ts +65 -0
- package/dist/types/tools/sqlite-reader.d.ts +114 -0
- package/dist/types/tools/ssh.d.ts +74 -0
- package/dist/types/tools/todo.d.ts +126 -0
- package/dist/types/tools/tool-errors.d.ts +33 -0
- package/dist/types/tools/tool-result.d.ts +34 -0
- package/dist/types/tools/tool-timeouts.d.ts +51 -0
- package/dist/types/tools/tts.d.ts +42 -0
- package/dist/types/tools/write.d.ts +66 -0
- package/dist/types/tools/yield.d.ts +39 -0
- package/dist/types/tts/downloader.d.ts +20 -0
- package/dist/types/tts/index.d.ts +10 -0
- package/dist/types/tts/models.d.ts +82 -0
- package/dist/types/tts/player.d.ts +32 -0
- package/dist/types/tts/runtime.d.ts +6 -0
- package/dist/types/tts/speakable.d.ts +47 -0
- package/dist/types/tts/speech-enhancer.d.ts +46 -0
- package/dist/types/tts/streaming-player.d.ts +40 -0
- package/dist/types/tts/tts-client.d.ts +69 -0
- package/dist/types/tts/tts-protocol.d.ts +102 -0
- package/dist/types/tts/tts-worker.d.ts +2 -0
- package/dist/types/tts/vocalizer.d.ts +48 -0
- package/dist/types/tts/wav.d.ts +8 -0
- package/dist/types/tui/code-cell.d.ts +47 -0
- package/dist/types/tui/file-list.d.ts +22 -0
- package/dist/types/tui/hyperlink.d.ts +61 -0
- package/dist/types/tui/index.d.ts +12 -0
- package/dist/types/tui/output-block.d.ts +59 -0
- package/dist/types/tui/status-line.d.ts +21 -0
- package/dist/types/tui/tree-list.d.ts +20 -0
- package/dist/types/tui/types.d.ts +13 -0
- package/dist/types/tui/utils.d.ts +36 -0
- package/dist/types/tui/width-aware-text.d.ts +23 -0
- package/dist/types/utils/active-repo-context.d.ts +8 -0
- package/dist/types/utils/block-context.d.ts +35 -0
- package/dist/types/utils/changelog.d.ts +33 -0
- package/dist/types/utils/clipboard.d.ts +37 -0
- package/dist/types/utils/command-args.d.ts +9 -0
- package/dist/types/utils/commit-message-generator.d.ts +7 -0
- package/dist/types/utils/edit-mode.d.ts +13 -0
- package/dist/types/utils/enhanced-paste.d.ts +20 -0
- package/dist/types/utils/event-bus.d.ts +6 -0
- package/dist/types/utils/external-editor.d.ts +27 -0
- package/dist/types/utils/fetch-timeout.d.ts +4 -0
- package/dist/types/utils/file-display-mode.d.ts +27 -0
- package/dist/types/utils/file-mentions.d.ts +13 -0
- package/dist/types/utils/git.d.ts +471 -0
- package/dist/types/utils/image-loading.d.ts +67 -0
- package/dist/types/utils/image-resize.d.ts +42 -0
- package/dist/types/utils/image-vision-fallback.d.ts +28 -0
- package/dist/types/utils/ipc.d.ts +22 -0
- package/dist/types/utils/jj.d.ts +74 -0
- package/dist/types/utils/lang-from-path.d.ts +8 -0
- package/dist/types/utils/markit-cache.d.ts +23 -0
- package/dist/types/utils/markit.d.ts +20 -0
- package/dist/types/utils/mupdf-wasm-embed.d.ts +1 -0
- package/dist/types/utils/open.d.ts +2 -0
- package/dist/types/utils/prompt-path.d.ts +1 -0
- package/dist/types/utils/qrcode.d.ts +48 -0
- package/dist/types/utils/session-color.d.ts +27 -0
- package/dist/types/utils/shell-snapshot.d.ts +15 -0
- package/dist/types/utils/sixel.d.ts +21 -0
- package/dist/types/utils/thinking-display.d.ts +7 -0
- package/dist/types/utils/title-generator.d.ts +33 -0
- package/dist/types/utils/tool-choice.d.ts +15 -0
- package/dist/types/utils/tools-manager.d.ts +12 -0
- package/dist/types/utils/turndown.d.ts +15 -0
- package/dist/types/utils/zip.d.ts +119 -0
- package/dist/types/web/kagi.d.ts +99 -0
- package/dist/types/web/parallel.d.ts +67 -0
- package/dist/types/web/scrapers/artifacthub.d.ts +6 -0
- package/dist/types/web/scrapers/arxiv.d.ts +5 -0
- package/dist/types/web/scrapers/aur.d.ts +5 -0
- package/dist/types/web/scrapers/biorxiv.d.ts +5 -0
- package/dist/types/web/scrapers/bluesky.d.ts +5 -0
- package/dist/types/web/scrapers/brew.d.ts +5 -0
- package/dist/types/web/scrapers/cheatsh.d.ts +8 -0
- package/dist/types/web/scrapers/chocolatey.d.ts +5 -0
- package/dist/types/web/scrapers/choosealicense.d.ts +2 -0
- package/dist/types/web/scrapers/cisa-kev.d.ts +5 -0
- package/dist/types/web/scrapers/clojars.d.ts +5 -0
- package/dist/types/web/scrapers/coingecko.d.ts +5 -0
- package/dist/types/web/scrapers/crates-io.d.ts +5 -0
- package/dist/types/web/scrapers/crossref.d.ts +2 -0
- package/dist/types/web/scrapers/devto.d.ts +5 -0
- package/dist/types/web/scrapers/discogs.d.ts +8 -0
- package/dist/types/web/scrapers/discourse.d.ts +5 -0
- package/dist/types/web/scrapers/dockerhub.d.ts +5 -0
- package/dist/types/web/scrapers/docs-rs.d.ts +2 -0
- package/dist/types/web/scrapers/fdroid.d.ts +5 -0
- package/dist/types/web/scrapers/firefox-addons.d.ts +2 -0
- package/dist/types/web/scrapers/flathub.d.ts +2 -0
- package/dist/types/web/scrapers/github-gist.d.ts +5 -0
- package/dist/types/web/scrapers/github.d.ts +34 -0
- package/dist/types/web/scrapers/gitlab.d.ts +5 -0
- package/dist/types/web/scrapers/go-pkg.d.ts +5 -0
- package/dist/types/web/scrapers/hackage.d.ts +5 -0
- package/dist/types/web/scrapers/hackernews.d.ts +2 -0
- package/dist/types/web/scrapers/hex.d.ts +5 -0
- package/dist/types/web/scrapers/huggingface.d.ts +2 -0
- package/dist/types/web/scrapers/iacr.d.ts +5 -0
- package/dist/types/web/scrapers/index.d.ts +84 -0
- package/dist/types/web/scrapers/jetbrains-marketplace.d.ts +2 -0
- package/dist/types/web/scrapers/lemmy.d.ts +2 -0
- package/dist/types/web/scrapers/lobsters.d.ts +5 -0
- package/dist/types/web/scrapers/mastodon.d.ts +5 -0
- package/dist/types/web/scrapers/maven.d.ts +6 -0
- package/dist/types/web/scrapers/mdn.d.ts +2 -0
- package/dist/types/web/scrapers/metacpan.d.ts +5 -0
- package/dist/types/web/scrapers/musicbrainz.d.ts +5 -0
- package/dist/types/web/scrapers/npm.d.ts +5 -0
- package/dist/types/web/scrapers/nuget.d.ts +5 -0
- package/dist/types/web/scrapers/nvd.d.ts +5 -0
- package/dist/types/web/scrapers/ollama.d.ts +2 -0
- package/dist/types/web/scrapers/open-vsx.d.ts +5 -0
- package/dist/types/web/scrapers/opencorporates.d.ts +5 -0
- package/dist/types/web/scrapers/openlibrary.d.ts +5 -0
- package/dist/types/web/scrapers/orcid.d.ts +5 -0
- package/dist/types/web/scrapers/osv.d.ts +5 -0
- package/dist/types/web/scrapers/packagist.d.ts +5 -0
- package/dist/types/web/scrapers/pub-dev.d.ts +5 -0
- package/dist/types/web/scrapers/pubmed.d.ts +5 -0
- package/dist/types/web/scrapers/pypi.d.ts +5 -0
- package/dist/types/web/scrapers/rawg.d.ts +2 -0
- package/dist/types/web/scrapers/readthedocs.d.ts +5 -0
- package/dist/types/web/scrapers/reddit.d.ts +5 -0
- package/dist/types/web/scrapers/repology.d.ts +5 -0
- package/dist/types/web/scrapers/rfc.d.ts +5 -0
- package/dist/types/web/scrapers/rubygems.d.ts +5 -0
- package/dist/types/web/scrapers/searchcode.d.ts +2 -0
- package/dist/types/web/scrapers/sec-edgar.d.ts +5 -0
- package/dist/types/web/scrapers/semantic-scholar.d.ts +2 -0
- package/dist/types/web/scrapers/snapcraft.d.ts +2 -0
- package/dist/types/web/scrapers/sourcegraph.d.ts +2 -0
- package/dist/types/web/scrapers/spdx.d.ts +5 -0
- package/dist/types/web/scrapers/spotify.d.ts +8 -0
- package/dist/types/web/scrapers/stackoverflow.d.ts +6 -0
- package/dist/types/web/scrapers/terraform.d.ts +5 -0
- package/dist/types/web/scrapers/tldr.d.ts +7 -0
- package/dist/types/web/scrapers/twitter.d.ts +5 -0
- package/dist/types/web/scrapers/types.d.ts +90 -0
- package/dist/types/web/scrapers/utils.d.ts +26 -0
- package/dist/types/web/scrapers/vimeo.d.ts +5 -0
- package/dist/types/web/scrapers/vscode-marketplace.d.ts +5 -0
- package/dist/types/web/scrapers/w3c.d.ts +2 -0
- package/dist/types/web/scrapers/wikidata.d.ts +5 -0
- package/dist/types/web/scrapers/wikipedia.d.ts +5 -0
- package/dist/types/web/scrapers/youtube.d.ts +5 -0
- package/dist/types/web/search/index.d.ts +74 -0
- package/dist/types/web/search/provider.d.ts +30 -0
- package/dist/types/web/search/providers/anthropic.d.ts +33 -0
- package/dist/types/web/search/providers/base.d.ts +84 -0
- package/dist/types/web/search/providers/brave.d.ts +28 -0
- package/dist/types/web/search/providers/codex.d.ts +36 -0
- package/dist/types/web/search/providers/duckduckgo.d.ts +14 -0
- package/dist/types/web/search/providers/exa.d.ts +70 -0
- package/dist/types/web/search/providers/firecrawl.d.ts +28 -0
- package/dist/types/web/search/providers/gemini.d.ts +63 -0
- package/dist/types/web/search/providers/jina.d.ts +31 -0
- package/dist/types/web/search/providers/kagi.d.ts +30 -0
- package/dist/types/web/search/providers/kimi.d.ts +32 -0
- package/dist/types/web/search/providers/parallel.d.ts +16 -0
- package/dist/types/web/search/providers/perplexity-auth.d.ts +37 -0
- package/dist/types/web/search/providers/perplexity.d.ts +58 -0
- package/dist/types/web/search/providers/searxng.d.ts +45 -0
- package/dist/types/web/search/providers/synthetic.d.ts +25 -0
- package/dist/types/web/search/providers/tavily.d.ts +30 -0
- package/dist/types/web/search/providers/tinyfish.d.ts +29 -0
- package/dist/types/web/search/providers/utils.d.ts +52 -0
- package/dist/types/web/search/providers/xai.d.ts +13 -0
- package/dist/types/web/search/providers/zai.d.ts +29 -0
- package/dist/types/web/search/render.d.ts +34 -0
- package/dist/types/web/search/types.d.ts +431 -0
- package/dist/types/web/search/utils.d.ts +4 -0
- package/dist/types/workspace-tree.d.ts +42 -0
- package/examples/README.md +21 -0
- package/examples/custom-tools/README.md +104 -0
- package/examples/custom-tools/hello/index.ts +20 -0
- package/examples/extensions/README.md +142 -0
- package/examples/extensions/api-demo.ts +79 -0
- package/examples/extensions/chalk-logger.ts +25 -0
- package/examples/extensions/hello.ts +31 -0
- package/examples/extensions/pirate.ts +43 -0
- package/examples/extensions/plan-mode.ts +549 -0
- package/examples/extensions/reload-runtime.ts +38 -0
- package/examples/extensions/thinking-note.ts +13 -0
- package/examples/extensions/tools.ts +145 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +17 -0
- 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 +21 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +46 -0
- package/examples/sdk/04-skills.ts +43 -0
- package/examples/sdk/06-extensions.ts +82 -0
- package/examples/sdk/06-hooks.ts +61 -0
- package/examples/sdk/07-context-files.ts +35 -0
- package/examples/sdk/08-prompt-templates.ts +41 -0
- package/examples/sdk/08-slash-commands.ts +46 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +54 -0
- package/examples/sdk/11-sessions.ts +47 -0
- package/examples/sdk/12-redis-sessions.ts +54 -0
- package/examples/sdk/13-sql-sessions.ts +61 -0
- package/examples/sdk/README.md +172 -0
- package/package.json +594 -0
- package/scripts/bench-guard.ts +71 -0
- package/scripts/build-binary.ts +135 -0
- package/scripts/bundle-dist.ts +129 -0
- package/scripts/embed-mupdf-wasm.ts +67 -0
- package/scripts/format-prompts.ts +68 -0
- package/scripts/generate-aria-snapshot.ts +134 -0
- package/scripts/generate-docs-index.ts +148 -0
- package/scripts/generate-legacy-pi-bundled-registry.ts +420 -0
- package/scripts/generate-share-viewer.ts +36 -0
- package/scripts/measure-prompt-tokens.ts +63 -0
- package/scripts/omp +42 -0
- package/scripts/omp.ts +19 -0
- package/src/advisor/__tests__/advisor.test.ts +1662 -0
- package/src/advisor/__tests__/config.test.ts +173 -0
- package/src/advisor/__tests__/emission-guard.test.ts +147 -0
- package/src/advisor/advise-tool.ts +203 -0
- package/src/advisor/config.ts +258 -0
- package/src/advisor/emission-guard.ts +172 -0
- package/src/advisor/index.ts +6 -0
- package/src/advisor/runtime.ts +518 -0
- package/src/advisor/transcript-recorder.ts +159 -0
- package/src/advisor/watchdog.ts +135 -0
- package/src/async/index.ts +1 -0
- package/src/async/job-manager.ts +698 -0
- package/src/auto-thinking/classifier.ts +195 -0
- package/src/autolearn/controller.ts +145 -0
- package/src/autolearn/managed-skills.ts +255 -0
- package/src/autoresearch/command-resume.md +14 -0
- package/src/autoresearch/dashboard.ts +436 -0
- package/src/autoresearch/git.ts +331 -0
- package/src/autoresearch/helpers.ts +218 -0
- package/src/autoresearch/index.ts +541 -0
- package/src/autoresearch/prompt-setup.md +43 -0
- package/src/autoresearch/prompt.md +103 -0
- package/src/autoresearch/resume-message.md +10 -0
- package/src/autoresearch/state.ts +273 -0
- package/src/autoresearch/storage.ts +700 -0
- package/src/autoresearch/tools/init-experiment.ts +269 -0
- package/src/autoresearch/tools/log-experiment.ts +521 -0
- package/src/autoresearch/tools/run-experiment.ts +407 -0
- package/src/autoresearch/tools/update-notes.ts +109 -0
- package/src/autoresearch/types.ts +168 -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 +117 -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 +76 -0
- package/src/capability/prompt.ts +35 -0
- package/src/capability/rule-buckets.ts +66 -0
- package/src/capability/rule.ts +261 -0
- package/src/capability/settings.ts +34 -0
- package/src/capability/skill.ts +63 -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 +393 -0
- package/src/cli/auth-broker-cli.ts +921 -0
- package/src/cli/auth-gateway-cli.ts +608 -0
- package/src/cli/bench-cli.ts +623 -0
- package/src/cli/classify-install-target.ts +76 -0
- package/src/cli/claude-trace-cli.ts +795 -0
- package/src/cli/commands/init-xdg.ts +27 -0
- package/src/cli/completion-gen.ts +550 -0
- package/src/cli/config-cli.ts +422 -0
- package/src/cli/dry-balance-cli.ts +853 -0
- package/src/cli/extension-flags.ts +48 -0
- package/src/cli/file-processor.ts +133 -0
- package/src/cli/flag-tables.ts +325 -0
- package/src/cli/gallery-cli.ts +272 -0
- package/src/cli/gallery-fixtures/agentic.ts +416 -0
- package/src/cli/gallery-fixtures/codeintel.ts +187 -0
- package/src/cli/gallery-fixtures/edit.ts +254 -0
- package/src/cli/gallery-fixtures/fs.ts +220 -0
- package/src/cli/gallery-fixtures/index.ts +40 -0
- package/src/cli/gallery-fixtures/interaction.ts +46 -0
- package/src/cli/gallery-fixtures/memory.ts +81 -0
- package/src/cli/gallery-fixtures/misc.ts +250 -0
- package/src/cli/gallery-fixtures/search.ts +213 -0
- package/src/cli/gallery-fixtures/shell.ts +159 -0
- package/src/cli/gallery-fixtures/types.ts +57 -0
- package/src/cli/gallery-fixtures/web.ts +158 -0
- package/src/cli/gallery-screenshot.ts +279 -0
- package/src/cli/gc-cli.ts +946 -0
- package/src/cli/grep-cli.ts +160 -0
- package/src/cli/grievances-cli.ts +256 -0
- package/src/cli/initial-message.ts +58 -0
- package/src/cli/models-cli.ts +368 -0
- package/src/cli/plugin-cli.ts +996 -0
- package/src/cli/profile-alias.ts +369 -0
- package/src/cli/profile-bootstrap.ts +233 -0
- package/src/cli/read-cli.ts +57 -0
- package/src/cli/session-picker.ts +93 -0
- package/src/cli/setup-cli.ts +332 -0
- package/src/cli/setup-model-picker.ts +43 -0
- package/src/cli/shell-cli.ts +176 -0
- package/src/cli/ssh-cli.ts +179 -0
- package/src/cli/startup-cwd.ts +58 -0
- package/src/cli/stats-cli.ts +229 -0
- package/src/cli/tiny-models-cli.ts +153 -0
- package/src/cli/ttsr-cli.ts +995 -0
- package/src/cli/update-cli.test.ts +28 -0
- package/src/cli/update-cli.ts +944 -0
- package/src/cli/usage-cli.ts +857 -0
- package/src/cli/web-search-cli.ts +137 -0
- package/src/cli/worktree-cli.ts +294 -0
- package/src/cli-commands.ts +131 -0
- package/src/cli.ts +348 -0
- package/src/collab/crypto.ts +63 -0
- package/src/collab/display-name.ts +13 -0
- package/src/collab/guest.ts +731 -0
- package/src/collab/host.ts +690 -0
- package/src/collab/protocol.ts +296 -0
- package/src/collab/relay-client.ts +216 -0
- package/src/collab/replication-shrink.ts +111 -0
- package/src/commands/acp.ts +24 -0
- package/src/commands/agents.ts +57 -0
- package/src/commands/auth-broker.ts +99 -0
- package/src/commands/auth-gateway.ts +69 -0
- package/src/commands/bench.ts +51 -0
- package/src/commands/commit.ts +46 -0
- package/src/commands/complete.ts +66 -0
- package/src/commands/completions.ts +60 -0
- package/src/commands/config.ts +51 -0
- package/src/commands/dry-balance.ts +43 -0
- package/src/commands/gallery.ts +60 -0
- package/src/commands/gc.ts +46 -0
- package/src/commands/grep.ts +48 -0
- package/src/commands/grievances.ts +51 -0
- package/src/commands/install.ts +107 -0
- package/src/commands/join.ts +39 -0
- package/src/commands/launch.ts +182 -0
- package/src/commands/models.ts +60 -0
- package/src/commands/plugin.ts +78 -0
- package/src/commands/read.ts +38 -0
- package/src/commands/say.ts +102 -0
- package/src/commands/setup.ts +67 -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/tiny-models.ts +36 -0
- package/src/commands/token.ts +162 -0
- package/src/commands/ttsr.ts +125 -0
- package/src/commands/update.ts +27 -0
- package/src/commands/usage.ts +43 -0
- package/src/commands/web-search.ts +42 -0
- package/src/commands/worktree.ts +62 -0
- package/src/commit/agentic/agent.ts +318 -0
- package/src/commit/agentic/fallback.ts +96 -0
- package/src/commit/agentic/index.ts +355 -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 +149 -0
- package/src/commit/agentic/tools/git-file-diff.ts +191 -0
- package/src/commit/agentic/tools/git-hunk.ts +52 -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 +147 -0
- package/src/commit/agentic/tools/propose-commit.ts +109 -0
- package/src/commit/agentic/tools/recent-commits.ts +81 -0
- package/src/commit/agentic/tools/schemas.ts +11 -0
- package/src/commit/agentic/tools/split-commit.ts +241 -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 +64 -0
- package/src/commit/analysis/index.ts +4 -0
- package/src/commit/analysis/scope.ts +242 -0
- package/src/commit/analysis/summary.ts +107 -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 +49 -0
- package/src/commit/map-reduce/utils.ts +9 -0
- package/src/commit/message.ts +11 -0
- package/src/commit/model-selection.ts +95 -0
- package/src/commit/pipeline.ts +243 -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/shared-llm.ts +70 -0
- package/src/commit/types.ts +118 -0
- package/src/commit/utils/exclusions.ts +42 -0
- package/src/commit/utils.ts +58 -0
- package/src/config/api-key-resolver.ts +67 -0
- package/src/config/append-only-context-mode.ts +76 -0
- package/src/config/config-file.ts +315 -0
- package/src/config/file-lock.ts +164 -0
- package/src/config/inline-tool-descriptors-mode.ts +26 -0
- package/src/config/keybindings.ts +636 -0
- package/src/config/mcp-schema.json +247 -0
- package/src/config/model-discovery.ts +919 -0
- package/src/config/model-registry.ts +2275 -0
- package/src/config/model-resolver.ts +1798 -0
- package/src/config/model-roles.ts +99 -0
- package/src/config/models-config-schema.ts +293 -0
- package/src/config/models-config.ts +134 -0
- package/src/config/prompt-templates.ts +205 -0
- package/src/config/provider-globals.ts +25 -0
- package/src/config/resolve-config-value.ts +94 -0
- package/src/config/service-tier.ts +116 -0
- package/src/config/settings-schema.ts +5247 -0
- package/src/config/settings.ts +1540 -0
- package/src/config.ts +242 -0
- package/src/cursor.ts +340 -0
- package/src/dap/client.ts +764 -0
- package/src/dap/config.ts +333 -0
- package/src/dap/defaults.json +212 -0
- package/src/dap/index.ts +4 -0
- package/src/dap/session.ts +1441 -0
- package/src/dap/types.ts +610 -0
- package/src/debug/index.ts +584 -0
- package/src/debug/log-formatting.ts +58 -0
- package/src/debug/log-viewer.ts +966 -0
- package/src/debug/profiler.ts +168 -0
- package/src/debug/protocol-probe.ts +267 -0
- package/src/debug/raw-sse-buffer.ts +294 -0
- package/src/debug/raw-sse.ts +312 -0
- package/src/debug/remote-debugger.ts +151 -0
- package/src/debug/report-bundle.ts +375 -0
- package/src/debug/system-info.ts +111 -0
- package/src/debug/terminal-info.ts +124 -0
- package/src/discovery/agents-md.ts +67 -0
- package/src/discovery/agents.ts +230 -0
- package/src/discovery/at-imports.ts +273 -0
- package/src/discovery/builtin-defaults.ts +39 -0
- package/src/discovery/builtin-rules/go-add-cleanup.md +32 -0
- package/src/discovery/builtin-rules/go-bench-loop.md +36 -0
- package/src/discovery/builtin-rules/go-exp-promoted.md +39 -0
- package/src/discovery/builtin-rules/go-ioutil.md +36 -0
- package/src/discovery/builtin-rules/go-join-hostport.md +29 -0
- package/src/discovery/builtin-rules/go-new-expr.md +44 -0
- package/src/discovery/builtin-rules/go-rand-v2.md +40 -0
- package/src/discovery/builtin-rules/go-range-int.md +45 -0
- package/src/discovery/builtin-rules/index.ts +72 -0
- package/src/discovery/builtin-rules/rs-box-leak.md +48 -0
- package/src/discovery/builtin-rules/rs-future-prelude.md +23 -0
- package/src/discovery/builtin-rules/rs-lazylock.md +51 -0
- package/src/discovery/builtin-rules/rs-match-ergonomics.md +67 -0
- package/src/discovery/builtin-rules/rs-parking-lot.md +44 -0
- package/src/discovery/builtin-rules/rs-result-type.md +19 -0
- package/src/discovery/builtin-rules/ts-bare-catch.md +38 -0
- package/src/discovery/builtin-rules/ts-import-type.md +42 -0
- package/src/discovery/builtin-rules/ts-no-any.md +65 -0
- package/src/discovery/builtin-rules/ts-no-deprecated-leftovers.md +44 -0
- package/src/discovery/builtin-rules/ts-no-dynamic-import.md +39 -0
- package/src/discovery/builtin-rules/ts-no-inline-cast-access.md +55 -0
- package/src/discovery/builtin-rules/ts-no-return-type.md +44 -0
- package/src/discovery/builtin-rules/ts-no-test-timers.md +55 -0
- package/src/discovery/builtin-rules/ts-no-tiny-functions.md +51 -0
- package/src/discovery/builtin-rules/ts-promise-with-resolvers.md +65 -0
- package/src/discovery/builtin-rules/ts-redundant-clear-guard.md +75 -0
- package/src/discovery/builtin-rules/ts-set-map.md +28 -0
- package/src/discovery/builtin.ts +934 -0
- package/src/discovery/claude-plugins.ts +387 -0
- package/src/discovery/claude.ts +584 -0
- package/src/discovery/cline.ts +83 -0
- package/src/discovery/codex.ts +530 -0
- package/src/discovery/cursor.ts +220 -0
- package/src/discovery/gemini.ts +383 -0
- package/src/discovery/github.ts +337 -0
- package/src/discovery/helpers.ts +1102 -0
- package/src/discovery/index.ts +81 -0
- package/src/discovery/mcp-json.ts +172 -0
- package/src/discovery/omp-extension-roots.ts +213 -0
- package/src/discovery/omp-plugins.ts +383 -0
- package/src/discovery/opencode.ts +441 -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/apply-patch/index.ts +87 -0
- package/src/edit/apply-patch/parser.ts +174 -0
- package/src/edit/diff.ts +999 -0
- package/src/edit/file-snapshot-store.ts +157 -0
- package/src/edit/hashline/block-resolver.ts +33 -0
- package/src/edit/hashline/diff.ts +356 -0
- package/src/edit/hashline/execute.ts +279 -0
- package/src/edit/hashline/filesystem.ts +205 -0
- package/src/edit/hashline/index.ts +5 -0
- package/src/edit/hashline/noop-loop-guard.ts +99 -0
- package/src/edit/hashline/params.ts +12 -0
- package/src/edit/index.ts +705 -0
- package/src/edit/modes/apply-patch.lark +19 -0
- package/src/edit/modes/apply-patch.ts +53 -0
- package/src/edit/modes/patch.ts +1950 -0
- package/src/edit/modes/replace.ts +1137 -0
- package/src/edit/normalize.ts +345 -0
- package/src/edit/notebook.ts +242 -0
- package/src/edit/read-file.ts +25 -0
- package/src/edit/renderer.ts +969 -0
- package/src/edit/snapshot-details.ts +77 -0
- package/src/edit/streaming.ts +698 -0
- package/src/eval/__tests__/agent-bridge.test.ts +1399 -0
- package/src/eval/__tests__/bridge-timeout.test.ts +64 -0
- package/src/eval/__tests__/budget-bridge.test.ts +69 -0
- package/src/eval/__tests__/completion-bridge.test.ts +412 -0
- package/src/eval/__tests__/helpers-local-roots.test.ts +55 -0
- package/src/eval/__tests__/idle-timeout.test.ts +80 -0
- package/src/eval/__tests__/js-context-manager.test.ts +291 -0
- package/src/eval/__tests__/julia-prelude.test.ts +66 -0
- package/src/eval/__tests__/kernel-spawn.test.ts +103 -0
- package/src/eval/__tests__/prelude-agent.test.ts +107 -0
- package/src/eval/agent-bridge.ts +584 -0
- package/src/eval/backend-helpers.ts +48 -0
- package/src/eval/backend.ts +71 -0
- package/src/eval/bridge-timeout.ts +44 -0
- package/src/eval/budget-bridge.ts +48 -0
- package/src/eval/completion-bridge.ts +211 -0
- package/src/eval/concurrency-bridge.ts +34 -0
- package/src/eval/executor-base.ts +425 -0
- package/src/eval/idle-timeout.ts +91 -0
- package/src/eval/index.ts +6 -0
- package/src/eval/jl/executor.ts +540 -0
- package/src/eval/jl/index.ts +54 -0
- package/src/eval/jl/kernel.ts +235 -0
- package/src/eval/jl/prelude.jl +735 -0
- package/src/eval/jl/prelude.ts +3 -0
- package/src/eval/jl/runner.jl +666 -0
- package/src/eval/jl/runtime.ts +118 -0
- package/src/eval/js/context-manager.ts +621 -0
- package/src/eval/js/executor.ts +173 -0
- package/src/eval/js/index.ts +40 -0
- package/src/eval/js/shared/helpers.ts +170 -0
- package/src/eval/js/shared/indirect-eval.ts +30 -0
- package/src/eval/js/shared/local-module-loader.ts +364 -0
- package/src/eval/js/shared/prelude.ts +2 -0
- package/src/eval/js/shared/prelude.txt +293 -0
- package/src/eval/js/shared/rewrite-imports.ts +532 -0
- package/src/eval/js/shared/runtime.ts +574 -0
- package/src/eval/js/shared/types.ts +18 -0
- package/src/eval/js/tool-bridge.ts +163 -0
- package/src/eval/js/worker-core.ts +151 -0
- package/src/eval/js/worker-entry.ts +37 -0
- package/src/eval/js/worker-protocol.ts +47 -0
- package/src/eval/kernel-base.ts +569 -0
- package/src/eval/py/__tests__/prelude.test.ts +32 -0
- package/src/eval/py/__tests__/runner-shell-output.test.ts +157 -0
- package/src/eval/py/display.ts +71 -0
- package/src/eval/py/executor.ts +533 -0
- package/src/eval/py/index.ts +57 -0
- package/src/eval/py/kernel.ts +233 -0
- package/src/eval/py/prelude.py +625 -0
- package/src/eval/py/prelude.ts +3 -0
- package/src/eval/py/runner.py +1322 -0
- package/src/eval/py/runtime.ts +276 -0
- package/src/eval/py/spawn-options.ts +126 -0
- package/src/eval/py/tool-bridge.ts +182 -0
- package/src/eval/rb/executor.ts +504 -0
- package/src/eval/rb/index.ts +54 -0
- package/src/eval/rb/kernel.ts +230 -0
- package/src/eval/rb/prelude.rb +553 -0
- package/src/eval/rb/prelude.ts +3 -0
- package/src/eval/rb/runner.rb +581 -0
- package/src/eval/rb/runtime.ts +132 -0
- package/src/eval/runtime-env.ts +104 -0
- package/src/eval/session-id.ts +8 -0
- package/src/eval/types.ts +48 -0
- package/src/exa/index.ts +2 -0
- package/src/exa/mcp-client.ts +370 -0
- package/src/exa/types.ts +69 -0
- package/src/exec/bash-executor.ts +473 -0
- package/src/exec/exec.ts +53 -0
- package/src/exec/non-interactive-env.ts +119 -0
- package/src/export/custom-share.ts +65 -0
- package/src/export/html/index.ts +308 -0
- package/src/export/html/share-loader.js +102 -0
- package/src/export/html/template.css +1337 -0
- package/src/export/html/template.html +49 -0
- package/src/export/html/template.js +1634 -0
- package/src/export/html/tool-views.generated.js +37 -0
- package/src/export/html/vendor/highlight.min.js +1213 -0
- package/src/export/html/vendor/marked.min.js +6 -0
- package/src/export/html/web-palette.ts +142 -0
- package/src/export/share.ts +481 -0
- package/src/export/ttsr.ts +583 -0
- package/src/extensibility/custom-commands/bundled/ci-green/index.ts +54 -0
- package/src/extensibility/custom-commands/bundled/review/index.ts +698 -0
- package/src/extensibility/custom-commands/index.ts +2 -0
- package/src/extensibility/custom-commands/loader.ts +242 -0
- package/src/extensibility/custom-commands/types.ts +119 -0
- package/src/extensibility/custom-tools/index.ts +7 -0
- package/src/extensibility/custom-tools/loader.ts +268 -0
- package/src/extensibility/custom-tools/types.ts +280 -0
- package/src/extensibility/custom-tools/wrapper.ts +47 -0
- package/src/extensibility/extensions/compact-handler.ts +40 -0
- package/src/extensibility/extensions/get-commands-handler.ts +78 -0
- package/src/extensibility/extensions/index.ts +16 -0
- package/src/extensibility/extensions/loader.ts +596 -0
- package/src/extensibility/extensions/model-api.ts +39 -0
- package/src/extensibility/extensions/runner.ts +1039 -0
- package/src/extensibility/extensions/types.ts +1394 -0
- package/src/extensibility/extensions/wrapper.ts +266 -0
- package/src/extensibility/hooks/index.ts +6 -0
- package/src/extensibility/hooks/loader.ts +244 -0
- package/src/extensibility/hooks/runner.ts +425 -0
- package/src/extensibility/hooks/tool-wrapper.ts +117 -0
- package/src/extensibility/hooks/types.ts +613 -0
- package/src/extensibility/legacy-pi-ai-shim.ts +73 -0
- package/src/extensibility/legacy-pi-coding-agent-shim.ts +646 -0
- package/src/extensibility/plugins/doctor.ts +65 -0
- package/src/extensibility/plugins/git-url.ts +367 -0
- package/src/extensibility/plugins/index.ts +9 -0
- package/src/extensibility/plugins/installer.ts +201 -0
- package/src/extensibility/plugins/legacy-pi-bundled-keys.ts +1011 -0
- package/src/extensibility/plugins/legacy-pi-bundled-registry.ts +3430 -0
- package/src/extensibility/plugins/legacy-pi-compat.ts +1141 -0
- package/src/extensibility/plugins/loader.ts +535 -0
- package/src/extensibility/plugins/manager.ts +1121 -0
- package/src/extensibility/plugins/marketplace/cache.ts +136 -0
- package/src/extensibility/plugins/marketplace/fetcher.ts +315 -0
- package/src/extensibility/plugins/marketplace/index.ts +6 -0
- package/src/extensibility/plugins/marketplace/manager.ts +926 -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 +192 -0
- package/src/extensibility/plugins/marketplace-auto-update.ts +49 -0
- package/src/extensibility/plugins/parser.ts +107 -0
- package/src/extensibility/plugins/runtime-config.ts +9 -0
- package/src/extensibility/plugins/types.ts +194 -0
- package/src/extensibility/session-handler-types.ts +21 -0
- package/src/extensibility/shared-events.ts +376 -0
- package/src/extensibility/skills.ts +508 -0
- package/src/extensibility/slash-commands.ts +131 -0
- package/src/extensibility/tool-event-input.ts +80 -0
- package/src/extensibility/tool-proxy.ts +28 -0
- package/src/extensibility/typebox.ts +945 -0
- package/src/extensibility/utils.ts +118 -0
- package/src/goals/guided-setup.ts +143 -0
- package/src/goals/index.ts +3 -0
- package/src/goals/runtime.ts +521 -0
- package/src/goals/state.ts +37 -0
- package/src/goals/tools/goal-tool.ts +251 -0
- package/src/hindsight/backend.ts +354 -0
- package/src/hindsight/bank.ts +156 -0
- package/src/hindsight/client.test.ts +33 -0
- package/src/hindsight/client.ts +643 -0
- package/src/hindsight/config.ts +175 -0
- package/src/hindsight/content.ts +266 -0
- package/src/hindsight/index.ts +8 -0
- package/src/hindsight/mental-models.ts +429 -0
- package/src/hindsight/seeds.json +32 -0
- package/src/hindsight/state.ts +492 -0
- package/src/hindsight/transcript.ts +71 -0
- package/src/index.ts +66 -0
- package/src/internal-urls/__tests__/ssh-protocol.test.ts +331 -0
- package/src/internal-urls/agent-protocol.ts +146 -0
- package/src/internal-urls/artifact-protocol.ts +151 -0
- package/src/internal-urls/docs-index.generated.txt +2 -0
- package/src/internal-urls/docs-index.ts +101 -0
- package/src/internal-urls/filesystem-resource.ts +34 -0
- package/src/internal-urls/history-protocol.ts +118 -0
- package/src/internal-urls/index.ts +26 -0
- package/src/internal-urls/issue-pr-protocol.ts +594 -0
- package/src/internal-urls/json-query.ts +126 -0
- package/src/internal-urls/local-protocol.ts +469 -0
- package/src/internal-urls/mcp-protocol.ts +151 -0
- package/src/internal-urls/memory-protocol.ts +173 -0
- package/src/internal-urls/omp-protocol.ts +94 -0
- package/src/internal-urls/parse.ts +72 -0
- package/src/internal-urls/registry-helpers.ts +40 -0
- package/src/internal-urls/router.ts +107 -0
- package/src/internal-urls/rule-protocol.ts +45 -0
- package/src/internal-urls/skill-protocol.ts +112 -0
- package/src/internal-urls/ssh-protocol.ts +367 -0
- package/src/internal-urls/types.ts +182 -0
- package/src/internal-urls/vault-protocol.ts +939 -0
- package/src/irc/bus.ts +320 -0
- package/src/jsonrpc/message-framing.ts +142 -0
- package/src/lib/xai-http.ts +124 -0
- package/src/lsp/client.ts +1249 -0
- package/src/lsp/clients/biome-client.ts +264 -0
- package/src/lsp/clients/index.ts +50 -0
- package/src/lsp/clients/lsp-linter-client.ts +85 -0
- package/src/lsp/clients/swiftlint-client.ts +120 -0
- package/src/lsp/config.ts +531 -0
- package/src/lsp/defaults.json +499 -0
- package/src/lsp/diagnostics-ledger.ts +51 -0
- package/src/lsp/edits.ts +288 -0
- package/src/lsp/format-options.ts +119 -0
- package/src/lsp/index.ts +2539 -0
- package/src/lsp/lspmux.ts +233 -0
- package/src/lsp/render.ts +668 -0
- package/src/lsp/startup-events.ts +13 -0
- package/src/lsp/types.ts +444 -0
- package/src/lsp/utils.ts +718 -0
- package/src/main.ts +1474 -0
- package/src/markit/NOTICE +32 -0
- package/src/markit/converters/docx.ts +56 -0
- package/src/markit/converters/epub.ts +136 -0
- package/src/markit/converters/mammoth.d.ts +24 -0
- package/src/markit/converters/pdf/columns.ts +103 -0
- package/src/markit/converters/pdf/extract.ts +574 -0
- package/src/markit/converters/pdf/grid.ts +780 -0
- package/src/markit/converters/pdf/headers.ts +106 -0
- package/src/markit/converters/pdf/index.ts +146 -0
- package/src/markit/converters/pdf/render.ts +501 -0
- package/src/markit/converters/pdf/types.ts +84 -0
- package/src/markit/converters/pptx.ts +325 -0
- package/src/markit/converters/xlsx.ts +173 -0
- package/src/markit/index.ts +2 -0
- package/src/markit/registry.ts +59 -0
- package/src/markit/types.ts +35 -0
- package/src/mcp/client.ts +511 -0
- package/src/mcp/config-writer.ts +350 -0
- package/src/mcp/config.ts +369 -0
- package/src/mcp/index.ts +29 -0
- package/src/mcp/json-rpc.ts +122 -0
- package/src/mcp/loader.ts +125 -0
- package/src/mcp/manager.ts +1362 -0
- package/src/mcp/oauth-credentials.ts +104 -0
- package/src/mcp/oauth-discovery.ts +560 -0
- package/src/mcp/oauth-flow.ts +787 -0
- package/src/mcp/render.ts +155 -0
- package/src/mcp/smithery-auth.ts +107 -0
- package/src/mcp/smithery-connect.ts +154 -0
- package/src/mcp/smithery-registry.test.ts +51 -0
- package/src/mcp/smithery-registry.ts +500 -0
- package/src/mcp/startup-events.ts +116 -0
- package/src/mcp/timeout.ts +59 -0
- package/src/mcp/tool-bridge.ts +484 -0
- package/src/mcp/tool-cache.ts +117 -0
- package/src/mcp/transports/http.ts +523 -0
- package/src/mcp/transports/index.ts +7 -0
- package/src/mcp/transports/sse.ts +377 -0
- package/src/mcp/transports/stdio.test.ts +95 -0
- package/src/mcp/transports/stdio.ts +663 -0
- package/src/mcp/types.ts +430 -0
- package/src/memories/index.ts +1395 -0
- package/src/memories/storage.ts +578 -0
- package/src/memory-backend/index.ts +18 -0
- package/src/memory-backend/local-backend.ts +47 -0
- package/src/memory-backend/off-backend.ts +25 -0
- package/src/memory-backend/resolve.ts +25 -0
- package/src/memory-backend/runtime.ts +66 -0
- package/src/memory-backend/types.ts +166 -0
- package/src/mnemopi/backend.ts +612 -0
- package/src/mnemopi/config.ts +267 -0
- package/src/mnemopi/embed-client.ts +246 -0
- package/src/mnemopi/embed-protocol.ts +35 -0
- package/src/mnemopi/embed-worker.ts +113 -0
- package/src/mnemopi/index.ts +3 -0
- package/src/mnemopi/state.ts +722 -0
- package/src/modes/acp/acp-agent.ts +2372 -0
- package/src/modes/acp/acp-client-bridge.ts +154 -0
- package/src/modes/acp/acp-event-mapper.ts +1002 -0
- package/src/modes/acp/acp-mode.ts +23 -0
- package/src/modes/acp/index.ts +2 -0
- package/src/modes/acp/terminal-auth.ts +37 -0
- package/src/modes/components/__tests__/move-overlay.test.ts +237 -0
- package/src/modes/components/__tests__/skill-message.test.ts +92 -0
- package/src/modes/components/advisor-config.ts +555 -0
- package/src/modes/components/advisor-message.ts +109 -0
- package/src/modes/components/agent-dashboard.ts +1183 -0
- package/src/modes/components/agent-hub.ts +586 -0
- package/src/modes/components/agent-transcript-viewer.ts +649 -0
- package/src/modes/components/assistant-message.ts +869 -0
- package/src/modes/components/background-tan-message.ts +36 -0
- package/src/modes/components/bash-execution.ts +229 -0
- package/src/modes/components/bordered-loader.ts +41 -0
- package/src/modes/components/btw-panel.ts +124 -0
- package/src/modes/components/cache-invalidation-marker.ts +110 -0
- package/src/modes/components/chat-block.ts +111 -0
- package/src/modes/components/chat-transcript-builder.ts +449 -0
- package/src/modes/components/collab-prompt-message.ts +32 -0
- package/src/modes/components/compaction-summary-message.ts +215 -0
- package/src/modes/components/copy-selector.ts +206 -0
- package/src/modes/components/countdown-timer.ts +75 -0
- package/src/modes/components/custom-editor.test.ts +283 -0
- package/src/modes/components/custom-editor.ts +835 -0
- package/src/modes/components/custom-message.ts +67 -0
- package/src/modes/components/diff.ts +254 -0
- package/src/modes/components/dynamic-border.ts +34 -0
- package/src/modes/components/error-banner.ts +33 -0
- package/src/modes/components/eval-execution.ts +167 -0
- package/src/modes/components/execution-shared.ts +101 -0
- package/src/modes/components/extensions/extension-dashboard.ts +492 -0
- package/src/modes/components/extensions/extension-list.ts +507 -0
- package/src/modes/components/extensions/index.ts +9 -0
- package/src/modes/components/extensions/inspector-panel.ts +321 -0
- package/src/modes/components/extensions/state-manager.ts +648 -0
- package/src/modes/components/extensions/types.ts +186 -0
- package/src/modes/components/footer.ts +276 -0
- package/src/modes/components/history-search.ts +268 -0
- package/src/modes/components/hook-editor.ts +183 -0
- package/src/modes/components/hook-input.ts +87 -0
- package/src/modes/components/hook-message.ts +67 -0
- package/src/modes/components/hook-selector.ts +678 -0
- package/src/modes/components/index.ts +40 -0
- package/src/modes/components/keybinding-hints.ts +65 -0
- package/src/modes/components/late-diagnostics-message.ts +60 -0
- package/src/modes/components/login-dialog.ts +178 -0
- package/src/modes/components/logout-account-selector.ts +130 -0
- package/src/modes/components/mcp-add-wizard.ts +1408 -0
- package/src/modes/components/message-frame.ts +92 -0
- package/src/modes/components/model-selector.ts +1267 -0
- package/src/modes/components/move-overlay.ts +294 -0
- package/src/modes/components/oauth-selector.ts +457 -0
- package/src/modes/components/omfg-panel.ts +141 -0
- package/src/modes/components/overlay-box.ts +109 -0
- package/src/modes/components/plan-review-overlay.ts +847 -0
- package/src/modes/components/plan-toc.ts +138 -0
- package/src/modes/components/plugin-selector.ts +100 -0
- package/src/modes/components/plugin-settings.ts +745 -0
- package/src/modes/components/queue-mode-selector.ts +61 -0
- package/src/modes/components/read-tool-group.ts +676 -0
- package/src/modes/components/reset-usage-selector.ts +161 -0
- package/src/modes/components/segment-track.ts +89 -0
- package/src/modes/components/select-list-mouse-routing.ts +35 -0
- package/src/modes/components/selector-helpers.ts +129 -0
- package/src/modes/components/session-selector.ts +744 -0
- package/src/modes/components/settings-defs.ts +238 -0
- package/src/modes/components/settings-selector.ts +1265 -0
- package/src/modes/components/show-images-selector.ts +50 -0
- package/src/modes/components/skill-message.ts +110 -0
- package/src/modes/components/snapcompact-shape-preview-doc.md +18 -0
- package/src/modes/components/snapcompact-shape-preview.ts +192 -0
- package/src/modes/components/status-line/component.test.ts +44 -0
- package/src/modes/components/status-line/component.ts +1308 -0
- package/src/modes/components/status-line/context-thresholds.ts +86 -0
- package/src/modes/components/status-line/git-utils.ts +42 -0
- package/src/modes/components/status-line/index.ts +5 -0
- package/src/modes/components/status-line/presets.ts +106 -0
- package/src/modes/components/status-line/segments.ts +663 -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 +147 -0
- package/src/modes/components/theme-selector.ts +68 -0
- package/src/modes/components/thinking-selector.ts +57 -0
- package/src/modes/components/tiny-title-download-progress.ts +90 -0
- package/src/modes/components/tips.txt +24 -0
- package/src/modes/components/todo-reminder.ts +43 -0
- package/src/modes/components/tool-execution.ts +1308 -0
- package/src/modes/components/transcript-container.ts +456 -0
- package/src/modes/components/tree-selector.ts +1002 -0
- package/src/modes/components/ttsr-notification.ts +123 -0
- package/src/modes/components/usage-row.ts +32 -0
- package/src/modes/components/user-message-selector.ts +227 -0
- package/src/modes/components/user-message.ts +68 -0
- package/src/modes/components/visual-truncate.ts +63 -0
- package/src/modes/components/welcome.ts +579 -0
- package/src/modes/controllers/btw-controller.ts +198 -0
- package/src/modes/controllers/command-controller-shared.ts +109 -0
- package/src/modes/controllers/command-controller.ts +1751 -0
- package/src/modes/controllers/event-controller.ts +1497 -0
- package/src/modes/controllers/extension-ui-controller.ts +977 -0
- package/src/modes/controllers/input-controller.ts +1851 -0
- package/src/modes/controllers/mcp-command-controller.ts +2364 -0
- package/src/modes/controllers/omfg-controller.ts +283 -0
- package/src/modes/controllers/omfg-rule.ts +647 -0
- package/src/modes/controllers/selector-controller.ts +1443 -0
- package/src/modes/controllers/session-focus-controller.ts +112 -0
- package/src/modes/controllers/ssh-command-controller.ts +384 -0
- package/src/modes/controllers/streaming-reveal.ts +392 -0
- package/src/modes/controllers/tan-command-controller.ts +190 -0
- package/src/modes/controllers/todo-command-controller.ts +484 -0
- package/src/modes/controllers/tool-args-reveal.ts +582 -0
- package/src/modes/data/emojis.json +1 -0
- package/src/modes/emoji-autocomplete.ts +285 -0
- package/src/modes/gradient-highlight.ts +99 -0
- package/src/modes/image-references.ts +137 -0
- package/src/modes/index.ts +17 -0
- package/src/modes/interactive-mode.ts +4223 -0
- package/src/modes/internal-url-autocomplete.ts +158 -0
- package/src/modes/loop-limit.ts +192 -0
- package/src/modes/magic-keywords.ts +42 -0
- package/src/modes/markdown-prose.ts +247 -0
- package/src/modes/oauth-manual-input.ts +69 -0
- package/src/modes/orchestrate.ts +42 -0
- package/src/modes/print-mode.ts +130 -0
- package/src/modes/prompt-action-autocomplete.ts +262 -0
- package/src/modes/rpc/host-tools.ts +186 -0
- package/src/modes/rpc/host-uris.ts +235 -0
- package/src/modes/rpc/rpc-client.ts +1033 -0
- package/src/modes/rpc/rpc-mode.ts +1311 -0
- package/src/modes/rpc/rpc-subagents.ts +265 -0
- package/src/modes/rpc/rpc-types.ts +499 -0
- package/src/modes/running-subagent-badge.ts +13 -0
- package/src/modes/runtime-init.ts +142 -0
- package/src/modes/session-observer-registry.ts +215 -0
- package/src/modes/session-teardown.test.ts +219 -0
- package/src/modes/session-teardown.ts +82 -0
- package/src/modes/setup-version.ts +11 -0
- package/src/modes/setup-wizard/index.ts +101 -0
- package/src/modes/setup-wizard/lazy.ts +16 -0
- package/src/modes/setup-wizard/scenes/glyph.ts +103 -0
- package/src/modes/setup-wizard/scenes/outro.ts +35 -0
- package/src/modes/setup-wizard/scenes/providers.ts +104 -0
- package/src/modes/setup-wizard/scenes/sign-in.ts +304 -0
- package/src/modes/setup-wizard/scenes/splash.ts +201 -0
- package/src/modes/setup-wizard/scenes/theme.ts +320 -0
- package/src/modes/setup-wizard/scenes/types.ts +57 -0
- package/src/modes/setup-wizard/scenes/web-search.ts +140 -0
- package/src/modes/setup-wizard/startup-splash.ts +107 -0
- package/src/modes/setup-wizard/wizard-overlay.ts +335 -0
- package/src/modes/shared.ts +49 -0
- package/src/modes/skill-command.ts +91 -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 +142 -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 +199 -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 +142 -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/light.json +93 -0
- package/src/modes/theme/mermaid-cache.ts +92 -0
- package/src/modes/theme/mermaid-rendering.test.ts +53 -0
- package/src/modes/theme/shimmer.ts +269 -0
- package/src/modes/theme/theme-schema.json +459 -0
- package/src/modes/theme/theme.ts +3004 -0
- package/src/modes/turn-budget.ts +31 -0
- package/src/modes/types.ts +437 -0
- package/src/modes/ultrathink.ts +41 -0
- package/src/modes/utils/context-usage.ts +432 -0
- package/src/modes/utils/copy-targets.ts +378 -0
- package/src/modes/utils/hotkeys-markdown.ts +62 -0
- package/src/modes/utils/interactive-context-helpers.ts +27 -0
- package/src/modes/utils/keybinding-matchers.ts +86 -0
- package/src/modes/utils/tools-markdown.ts +27 -0
- package/src/modes/utils/transcript-render-helpers.ts +184 -0
- package/src/modes/utils/ui-helpers.ts +864 -0
- package/src/modes/workflow.ts +42 -0
- package/src/plan-mode/approved-plan-prompt.test.ts +36 -0
- package/src/plan-mode/approved-plan.ts +186 -0
- package/src/plan-mode/plan-handoff.ts +37 -0
- package/src/plan-mode/plan-protection.ts +31 -0
- package/src/plan-mode/state.ts +6 -0
- package/src/priority.json +60 -0
- package/src/prompts/advisor/active-repo-watchdog.md +6 -0
- package/src/prompts/advisor/advise-tool.md +3 -0
- package/src/prompts/advisor/context-files.md +8 -0
- package/src/prompts/advisor/system.md +89 -0
- package/src/prompts/agents/designer.md +74 -0
- package/src/prompts/agents/explore.md +58 -0
- package/src/prompts/agents/frontmatter.md +11 -0
- package/src/prompts/agents/init.md +33 -0
- package/src/prompts/agents/librarian.md +119 -0
- package/src/prompts/agents/plan.md +48 -0
- package/src/prompts/agents/reviewer.md +140 -0
- package/src/prompts/agents/task.md +17 -0
- package/src/prompts/agents/tester.md +111 -0
- package/src/prompts/bench.md +6 -0
- package/src/prompts/ci-green-request.md +36 -0
- package/src/prompts/dry-balance-bench.md +8 -0
- package/src/prompts/goals/goal-budget-limit.md +16 -0
- package/src/prompts/goals/goal-continuation.md +28 -0
- package/src/prompts/goals/goal-mode-active.md +23 -0
- package/src/prompts/goals/goal-mode-context.md +4 -0
- package/src/prompts/goals/goal-todo-context.md +20 -0
- package/src/prompts/goals/guided-goal-interview.md +8 -0
- package/src/prompts/goals/guided-goal-system.md +12 -0
- package/src/prompts/memories/consolidation.md +30 -0
- package/src/prompts/memories/consolidation_system.md +4 -0
- package/src/prompts/memories/read-path.md +17 -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-custom-request.md +21 -0
- package/src/prompts/review-headless-request.md +16 -0
- package/src/prompts/review-request.md +68 -0
- package/src/prompts/skills/autoload.md +8 -0
- package/src/prompts/skills/user-invocation.md +11 -0
- package/src/prompts/steering/parent-irc.md +5 -0
- package/src/prompts/steering/user-interjection.md +9 -0
- package/src/prompts/system/active-repo-context.md +4 -0
- package/src/prompts/system/agent-creation-architect.md +50 -0
- package/src/prompts/system/agent-creation-user.md +6 -0
- package/src/prompts/system/auto-continue.md +1 -0
- package/src/prompts/system/auto-thinking-difficulty-local.md +14 -0
- package/src/prompts/system/auto-thinking-difficulty.md +12 -0
- package/src/prompts/system/autolearn-guidance-learn.md +1 -0
- package/src/prompts/system/autolearn-guidance.md +7 -0
- package/src/prompts/system/autolearn-nudge-autocontinue.md +5 -0
- package/src/prompts/system/background-tan-dispatch.md +8 -0
- package/src/prompts/system/btw-user.md +8 -0
- package/src/prompts/system/commit-message-system.md +14 -0
- package/src/prompts/system/custom-system-prompt.md +64 -0
- package/src/prompts/system/eager-task.md +7 -0
- package/src/prompts/system/eager-todo.md +18 -0
- package/src/prompts/system/empty-stop-retry.md +4 -0
- package/src/prompts/system/gemini-tool-call-reminder.md +9 -0
- package/src/prompts/system/interrupted-thinking.md +7 -0
- package/src/prompts/system/irc-autoreply.md +6 -0
- package/src/prompts/system/irc-incoming.md +9 -0
- package/src/prompts/system/manual-continue.md +7 -0
- package/src/prompts/system/memory-consolidation-system.md +8 -0
- package/src/prompts/system/memory-extraction-system.md +26 -0
- package/src/prompts/system/mid-run-todo-nudge.md +3 -0
- package/src/prompts/system/omfg-user.md +50 -0
- package/src/prompts/system/orchestrate-notice.md +40 -0
- package/src/prompts/system/personalities/default.md +18 -0
- package/src/prompts/system/personalities/friendly.md +17 -0
- package/src/prompts/system/personalities/pragmatic.md +15 -0
- package/src/prompts/system/plan-mode-active.md +118 -0
- package/src/prompts/system/plan-mode-approved.md +22 -0
- package/src/prompts/system/plan-mode-compact-instructions.md +17 -0
- package/src/prompts/system/plan-mode-reference.md +10 -0
- package/src/prompts/system/plan-mode-subagent.md +33 -0
- package/src/prompts/system/plan-mode-tool-decision-reminder.md +9 -0
- package/src/prompts/system/project-prompt.md +54 -0
- package/src/prompts/system/recap-user.md +9 -0
- package/src/prompts/system/rewind-report.md +6 -0
- package/src/prompts/system/side-channel-no-tools.md +3 -0
- package/src/prompts/system/snapcompact-context-frames-note.md +1 -0
- package/src/prompts/system/snapcompact-context-stub.md +1 -0
- package/src/prompts/system/snapcompact-system-frames-note.md +1 -0
- package/src/prompts/system/snapcompact-system-stub.md +1 -0
- package/src/prompts/system/snapcompact-toolresult-note.md +1 -0
- package/src/prompts/system/speech-rewrite.md +15 -0
- package/src/prompts/system/subagent-system-prompt.md +77 -0
- package/src/prompts/system/subagent-user-prompt.md +3 -0
- package/src/prompts/system/subagent-yield-reminder.md +13 -0
- package/src/prompts/system/system-prompt.md +248 -0
- package/src/prompts/system/thinking-loop-redirect.md +10 -0
- package/src/prompts/system/tiny-title-system.md +8 -0
- package/src/prompts/system/title-marker-instruction.md +1 -0
- package/src/prompts/system/title-system-marker.md +17 -0
- package/src/prompts/system/title-system.md +17 -0
- package/src/prompts/system/tool-call-loop-redirect.md +8 -0
- package/src/prompts/system/ttsr-interrupt.md +7 -0
- package/src/prompts/system/ttsr-tool-reminder.md +5 -0
- package/src/prompts/system/ultrathink-notice.md +3 -0
- package/src/prompts/system/unexpected-stop-classifier.md +17 -0
- package/src/prompts/system/unexpected-stop-retry.md +4 -0
- package/src/prompts/system/web-search.md +25 -0
- package/src/prompts/system/workflow-notice.md +70 -0
- package/src/prompts/tools/apply-patch.md +65 -0
- package/src/prompts/tools/ask.md +22 -0
- package/src/prompts/tools/ast-edit.md +22 -0
- package/src/prompts/tools/ast-grep.md +25 -0
- package/src/prompts/tools/async-result.md +8 -0
- package/src/prompts/tools/bash.md +57 -0
- package/src/prompts/tools/browser.md +45 -0
- package/src/prompts/tools/checkpoint.md +15 -0
- package/src/prompts/tools/debug.md +17 -0
- package/src/prompts/tools/eval.md +72 -0
- package/src/prompts/tools/github.md +17 -0
- package/src/prompts/tools/glob.md +15 -0
- package/src/prompts/tools/goal.md +11 -0
- package/src/prompts/tools/grep.md +22 -0
- package/src/prompts/tools/image-attachment-describe-system.md +8 -0
- package/src/prompts/tools/image-attachment-describe.md +10 -0
- package/src/prompts/tools/image-gen.md +7 -0
- package/src/prompts/tools/inspect-image-system.md +20 -0
- package/src/prompts/tools/inspect-image.md +22 -0
- package/src/prompts/tools/irc.md +24 -0
- package/src/prompts/tools/job.md +11 -0
- package/src/prompts/tools/learn.md +7 -0
- package/src/prompts/tools/lsp-late-diagnostic.md +8 -0
- package/src/prompts/tools/lsp.md +28 -0
- package/src/prompts/tools/manage-skill.md +9 -0
- package/src/prompts/tools/memory-edit.md +8 -0
- package/src/prompts/tools/patch.md +57 -0
- package/src/prompts/tools/read.md +77 -0
- package/src/prompts/tools/recall.md +5 -0
- package/src/prompts/tools/reflect.md +5 -0
- package/src/prompts/tools/replace.md +29 -0
- package/src/prompts/tools/resolve.md +4 -0
- package/src/prompts/tools/retain.md +6 -0
- package/src/prompts/tools/rewind.md +14 -0
- package/src/prompts/tools/search-tool-bm25.md +32 -0
- package/src/prompts/tools/ssh.md +23 -0
- package/src/prompts/tools/task-summary.md +17 -0
- package/src/prompts/tools/task.md +68 -0
- package/src/prompts/tools/todo.md +39 -0
- package/src/prompts/tools/web-search.md +6 -0
- package/src/prompts/tools/write.md +14 -0
- package/src/registry/agent-lifecycle.ts +270 -0
- package/src/registry/agent-registry.ts +190 -0
- package/src/sdk.ts +3037 -0
- package/src/secrets/index.ts +123 -0
- package/src/secrets/obfuscator.ts +441 -0
- package/src/secrets/regex.ts +21 -0
- package/src/session/agent-session.ts +15855 -0
- package/src/session/agent-storage.ts +478 -0
- package/src/session/artifacts.ts +153 -0
- package/src/session/auth-broker-config.ts +92 -0
- package/src/session/auth-storage.ts +24 -0
- package/src/session/blob-store.ts +279 -0
- package/src/session/client-bridge.ts +85 -0
- package/src/session/codex-auto-reset.ts +202 -0
- package/src/session/compact-modes.ts +105 -0
- package/src/session/exit-diagnostics.ts +202 -0
- package/src/session/history-storage.ts +360 -0
- package/src/session/indexed-session-storage.ts +537 -0
- package/src/session/messages.test.ts +125 -0
- package/src/session/messages.ts +740 -0
- package/src/session/provider-image-budget.ts +86 -0
- package/src/session/redis-session-storage.ts +217 -0
- package/src/session/session-context.ts +442 -0
- package/src/session/session-dump-format.ts +216 -0
- package/src/session/session-entries.ts +241 -0
- package/src/session/session-history-format.ts +396 -0
- package/src/session/session-listing.ts +652 -0
- package/src/session/session-loader.ts +284 -0
- package/src/session/session-manager.ts +1995 -0
- package/src/session/session-migrations.ts +78 -0
- package/src/session/session-paths.ts +193 -0
- package/src/session/session-persistence.ts +266 -0
- package/src/session/session-storage.ts +734 -0
- package/src/session/session-title-slot.ts +141 -0
- package/src/session/settings-stream-fn.ts +73 -0
- package/src/session/shake-types.ts +43 -0
- package/src/session/snapcompact-inline.ts +561 -0
- package/src/session/snapcompact-savings-journal.ts +113 -0
- package/src/session/sql-session-storage.ts +374 -0
- package/src/session/streaming-output.ts +1330 -0
- package/src/session/tool-choice-queue.ts +290 -0
- package/src/session/turn-persistence.ts +142 -0
- package/src/session/unexpected-stop-classifier.ts +129 -0
- package/src/session/yield-queue.ts +183 -0
- package/src/slash-commands/acp-builtins.ts +70 -0
- package/src/slash-commands/available-commands.ts +105 -0
- package/src/slash-commands/builtin-registry.ts +2554 -0
- package/src/slash-commands/helpers/active-oauth-account.ts +44 -0
- package/src/slash-commands/helpers/collab-qrcode.ts +28 -0
- package/src/slash-commands/helpers/context-report.ts +66 -0
- package/src/slash-commands/helpers/format.ts +46 -0
- package/src/slash-commands/helpers/logout.ts +88 -0
- package/src/slash-commands/helpers/marketplace-manager.ts +25 -0
- package/src/slash-commands/helpers/mcp.ts +533 -0
- package/src/slash-commands/helpers/parse.ts +85 -0
- package/src/slash-commands/helpers/reset-usage.ts +66 -0
- package/src/slash-commands/helpers/ssh.ts +195 -0
- package/src/slash-commands/helpers/stats-dashboard.ts +85 -0
- package/src/slash-commands/helpers/todo.ts +285 -0
- package/src/slash-commands/helpers/usage-report.ts +162 -0
- package/src/slash-commands/marketplace-install-parser.ts +99 -0
- package/src/slash-commands/types.ts +137 -0
- package/src/ssh/__tests__/connection-manager-args.test.ts +191 -0
- package/src/ssh/__tests__/connection-manager-timeout.test.ts +61 -0
- package/src/ssh/__tests__/file-transfer-posix-guard.test.ts +105 -0
- package/src/ssh/__tests__/sshfs-mount.test.ts +13 -0
- package/src/ssh/config-writer.ts +183 -0
- package/src/ssh/connection-manager.ts +667 -0
- package/src/ssh/file-transfer.ts +214 -0
- package/src/ssh/ssh-executor.ts +178 -0
- package/src/ssh/sshfs-mount.ts +163 -0
- package/src/ssh/utils.ts +51 -0
- package/src/startup-splash.ts +19 -0
- package/src/stt/asr-client.ts +401 -0
- package/src/stt/asr-protocol.ts +65 -0
- package/src/stt/asr-worker.ts +638 -0
- package/src/stt/downloader.ts +144 -0
- package/src/stt/endpointer.ts +259 -0
- package/src/stt/index.ts +8 -0
- package/src/stt/models.ts +150 -0
- package/src/stt/recorder.ts +538 -0
- package/src/stt/stt-controller.ts +409 -0
- package/src/stt/submit-trigger.ts +74 -0
- package/src/stt/transcriber.ts +60 -0
- package/src/stt/wav.ts +173 -0
- package/src/subprocess/worker-client.ts +456 -0
- package/src/subprocess/worker-runtime.ts +494 -0
- package/src/system-prompt.test.ts +158 -0
- package/src/system-prompt.ts +787 -0
- package/src/task/agents.ts +166 -0
- package/src/task/commands.ts +132 -0
- package/src/task/discovery.ts +145 -0
- package/src/task/executor.ts +2481 -0
- package/src/task/index.ts +1481 -0
- package/src/task/isolation-runner.ts +384 -0
- package/src/task/name-generator.ts +1577 -0
- package/src/task/omp-command.ts +26 -0
- package/src/task/output-manager.ts +93 -0
- package/src/task/parallel.ts +178 -0
- package/src/task/persisted-revive.ts +128 -0
- package/src/task/provider-concurrency.ts +100 -0
- package/src/task/render.test.ts +121 -0
- package/src/task/render.ts +1761 -0
- package/src/task/renderer.ts +15 -0
- package/src/task/repair-args.ts +129 -0
- package/src/task/spawn-policy.test.ts +63 -0
- package/src/task/spawn-policy.ts +58 -0
- package/src/task/subprocess-tool-registry.ts +88 -0
- package/src/task/types.ts +495 -0
- package/src/task/worktree.ts +935 -0
- package/src/task/yield-assembly.ts +198 -0
- package/src/telemetry-export.ts +144 -0
- package/src/thinking.ts +219 -0
- package/src/tiny/device.ts +111 -0
- package/src/tiny/dtype.ts +101 -0
- package/src/tiny/models.ts +268 -0
- package/src/tiny/text.ts +336 -0
- package/src/tiny/title-client.ts +438 -0
- package/src/tiny/title-protocol.ts +56 -0
- package/src/tiny/worker.ts +351 -0
- package/src/tool-discovery/mode.ts +24 -0
- package/src/tool-discovery/tool-index.ts +271 -0
- package/src/tools/__tests__/eval-description.test.ts +19 -0
- package/src/tools/__tests__/json-tree.test.ts +35 -0
- package/src/tools/acp-bridge.ts +71 -0
- package/src/tools/approval.ts +189 -0
- package/src/tools/ask.ts +1213 -0
- package/src/tools/ast-edit.ts +708 -0
- package/src/tools/ast-grep.ts +520 -0
- package/src/tools/auto-generated-guard.ts +322 -0
- package/src/tools/bash-command-fixup.ts +37 -0
- package/src/tools/bash-interactive.ts +408 -0
- package/src/tools/bash-interceptor.ts +67 -0
- package/src/tools/bash-pty-selection.ts +14 -0
- package/src/tools/bash-skill-urls.ts +248 -0
- package/src/tools/bash.ts +1421 -0
- package/src/tools/browser/aria/aria-snapshot.bundle.txt +7 -0
- package/src/tools/browser/aria/aria-snapshot.ts +103 -0
- package/src/tools/browser/attach.ts +194 -0
- package/src/tools/browser/cmux/cmux-tab.ts +1378 -0
- package/src/tools/browser/cmux/rpc.ts +156 -0
- package/src/tools/browser/cmux/socket-client.ts +309 -0
- package/src/tools/browser/launch.ts +749 -0
- package/src/tools/browser/readable.ts +112 -0
- package/src/tools/browser/registry.ts +266 -0
- package/src/tools/browser/render.ts +223 -0
- package/src/tools/browser/run-cancellation.ts +47 -0
- package/src/tools/browser/tab-protocol.ts +107 -0
- package/src/tools/browser/tab-supervisor.ts +956 -0
- package/src/tools/browser/tab-worker-entry.ts +29 -0
- package/src/tools/browser/tab-worker.ts +1433 -0
- package/src/tools/browser.ts +409 -0
- package/src/tools/builtin-names.ts +58 -0
- package/src/tools/checkpoint.ts +150 -0
- package/src/tools/conflict-detect.ts +718 -0
- package/src/tools/context.ts +39 -0
- package/src/tools/debug.ts +1088 -0
- package/src/tools/eval-backends.ts +34 -0
- package/src/tools/eval-render.ts +776 -0
- package/src/tools/eval.ts +767 -0
- package/src/tools/fetch.ts +1966 -0
- package/src/tools/file-recorder.ts +35 -0
- package/src/tools/fs-cache-invalidation.ts +28 -0
- package/src/tools/gh-cache-invalidation.ts +255 -0
- package/src/tools/gh-format.ts +12 -0
- package/src/tools/gh-renderer.ts +484 -0
- package/src/tools/gh.ts +3752 -0
- package/src/tools/github-cache.ts +663 -0
- package/src/tools/glob.ts +639 -0
- package/src/tools/grep.ts +1836 -0
- package/src/tools/grouped-file-output.ts +210 -0
- package/src/tools/image-gen.ts +1587 -0
- package/src/tools/index.ts +682 -0
- package/src/tools/inspect-image-renderer.ts +132 -0
- package/src/tools/inspect-image.ts +260 -0
- package/src/tools/irc.ts +827 -0
- package/src/tools/job.ts +612 -0
- package/src/tools/json-tree.ts +260 -0
- package/src/tools/jtd-to-json-schema.ts +219 -0
- package/src/tools/jtd-to-typescript.ts +136 -0
- package/src/tools/jtd-utils.ts +102 -0
- package/src/tools/learn.ts +141 -0
- package/src/tools/list-limit.ts +40 -0
- package/src/tools/manage-skill.ts +100 -0
- package/src/tools/match-line-format.ts +20 -0
- package/src/tools/memory-edit.ts +59 -0
- package/src/tools/memory-recall.ts +102 -0
- package/src/tools/memory-reflect.ts +88 -0
- package/src/tools/memory-render.ts +202 -0
- package/src/tools/memory-retain.ts +89 -0
- package/src/tools/output-meta.ts +818 -0
- package/src/tools/output-schema-validator.ts +307 -0
- package/src/tools/path-utils.ts +1279 -0
- package/src/tools/plan-mode-guard.ts +155 -0
- package/src/tools/puppeteer/00_stealth_tampering.txt +44 -0
- package/src/tools/puppeteer/01_stealth_activity.txt +80 -0
- package/src/tools/puppeteer/02_stealth_hairline.txt +57 -0
- package/src/tools/puppeteer/03_stealth_botd.txt +380 -0
- package/src/tools/puppeteer/04_stealth_iframe.txt +174 -0
- package/src/tools/puppeteer/05_stealth_webgl.txt +233 -0
- package/src/tools/puppeteer/06_stealth_screen.txt +260 -0
- package/src/tools/puppeteer/07_stealth_fonts.txt +99 -0
- package/src/tools/puppeteer/08_stealth_audio.txt +63 -0
- package/src/tools/puppeteer/09_stealth_locale.txt +51 -0
- package/src/tools/puppeteer/10_stealth_plugins.txt +212 -0
- package/src/tools/puppeteer/11_stealth_hardware.txt +59 -0
- package/src/tools/puppeteer/12_stealth_codecs.txt +42 -0
- package/src/tools/puppeteer/13_stealth_worker.txt +235 -0
- package/src/tools/read.ts +3522 -0
- package/src/tools/render-utils.ts +913 -0
- package/src/tools/renderers.ts +107 -0
- package/src/tools/report-tool-issue.ts +530 -0
- package/src/tools/resolve.ts +302 -0
- package/src/tools/review.ts +261 -0
- package/src/tools/search-tool-bm25.ts +351 -0
- package/src/tools/sqlite-reader.ts +884 -0
- package/src/tools/ssh.ts +397 -0
- package/src/tools/todo.ts +944 -0
- package/src/tools/tool-errors.ts +62 -0
- package/src/tools/tool-result.ts +102 -0
- package/src/tools/tool-timeouts.ts +30 -0
- package/src/tools/tts.ts +266 -0
- package/src/tools/write.ts +1219 -0
- package/src/tools/yield.ts +455 -0
- package/src/tts/downloader.ts +64 -0
- package/src/tts/index.ts +10 -0
- package/src/tts/models.ts +137 -0
- package/src/tts/player.ts +137 -0
- package/src/tts/runtime.ts +21 -0
- package/src/tts/speakable.ts +382 -0
- package/src/tts/speech-enhancer.ts +204 -0
- package/src/tts/streaming-player.ts +321 -0
- package/src/tts/tts-client.ts +475 -0
- package/src/tts/tts-protocol.ts +69 -0
- package/src/tts/tts-worker.ts +434 -0
- package/src/tts/vocalizer.ts +393 -0
- package/src/tts/wav.ts +58 -0
- package/src/tui/code-cell.ts +268 -0
- package/src/tui/file-list.ts +55 -0
- package/src/tui/hyperlink.ts +178 -0
- package/src/tui/index.ts +13 -0
- package/src/tui/output-block.ts +251 -0
- package/src/tui/status-line.ts +54 -0
- package/src/tui/tree-list.ts +133 -0
- package/src/tui/types.ts +15 -0
- package/src/tui/utils.ts +103 -0
- package/src/tui/width-aware-text.ts +58 -0
- package/src/utils/active-repo-context.ts +143 -0
- package/src/utils/block-context.ts +312 -0
- package/src/utils/changelog.ts +132 -0
- package/src/utils/clipboard.ts +356 -0
- package/src/utils/command-args.ts +76 -0
- package/src/utils/commit-message-generator.ts +146 -0
- package/src/utils/edit-mode.ts +58 -0
- package/src/utils/enhanced-paste.ts +230 -0
- package/src/utils/event-bus.ts +33 -0
- package/src/utils/external-editor.ts +78 -0
- package/src/utils/fetch-timeout.ts +10 -0
- package/src/utils/file-display-mode.ts +44 -0
- package/src/utils/file-mentions.ts +293 -0
- package/src/utils/git.ts +2181 -0
- package/src/utils/image-loading.ts +231 -0
- package/src/utils/image-resize.ts +420 -0
- package/src/utils/image-vision-fallback.ts +196 -0
- package/src/utils/ipc.ts +38 -0
- package/src/utils/jj.ts +295 -0
- package/src/utils/lang-from-path.ts +244 -0
- package/src/utils/markit-cache.ts +166 -0
- package/src/utils/markit.ts +211 -0
- package/src/utils/mupdf-wasm-embed.ts +12 -0
- package/src/utils/open.ts +100 -0
- package/src/utils/prompt-path.ts +3 -0
- package/src/utils/qrcode.ts +535 -0
- package/src/utils/session-color.ts +142 -0
- package/src/utils/shell-snapshot-fn-env.sh +60 -0
- package/src/utils/shell-snapshot.ts +306 -0
- package/src/utils/sixel.ts +69 -0
- package/src/utils/thinking-display.ts +117 -0
- package/src/utils/title-generator.ts +348 -0
- package/src/utils/tool-choice.ts +49 -0
- package/src/utils/tools-manager.ts +429 -0
- package/src/utils/turndown.ts +83 -0
- package/src/utils/zip.ts +1091 -0
- package/src/web/kagi.ts +304 -0
- package/src/web/parallel.ts +354 -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 +97 -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 +652 -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 +800 -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 +173 -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 +189 -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 +94 -0
- package/src/web/scrapers/types.ts +354 -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 +325 -0
- package/src/web/search/index.ts +312 -0
- package/src/web/search/provider.ts +214 -0
- package/src/web/search/providers/anthropic.ts +343 -0
- package/src/web/search/providers/base.ts +91 -0
- package/src/web/search/providers/brave.ts +152 -0
- package/src/web/search/providers/codex.ts +593 -0
- package/src/web/search/providers/duckduckgo.ts +212 -0
- package/src/web/search/providers/exa.ts +484 -0
- package/src/web/search/providers/firecrawl.ts +144 -0
- package/src/web/search/providers/gemini.ts +618 -0
- package/src/web/search/providers/jina.ts +111 -0
- package/src/web/search/providers/kagi.ts +86 -0
- package/src/web/search/providers/kimi.ts +196 -0
- package/src/web/search/providers/parallel.ts +136 -0
- package/src/web/search/providers/perplexity-auth.ts +133 -0
- package/src/web/search/providers/perplexity.ts +878 -0
- package/src/web/search/providers/searxng.ts +325 -0
- package/src/web/search/providers/synthetic.ts +114 -0
- package/src/web/search/providers/tavily.ts +193 -0
- package/src/web/search/providers/tinyfish.ts +159 -0
- package/src/web/search/providers/utils.ts +128 -0
- package/src/web/search/providers/xai.ts +292 -0
- package/src/web/search/providers/zai.ts +419 -0
- package/src/web/search/render.ts +262 -0
- package/src/web/search/types.ts +470 -0
- package/src/web/search/utils.ts +17 -0
- package/src/workspace-tree.ts +326 -0
|
@@ -0,0 +1,1995 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import type {
|
|
4
|
+
ImageContent,
|
|
5
|
+
Message,
|
|
6
|
+
MessageAttribution,
|
|
7
|
+
ServiceTierByFamily,
|
|
8
|
+
TextContent,
|
|
9
|
+
Usage,
|
|
10
|
+
} from "@oh-my-pi-zen/pi-ai";
|
|
11
|
+
import {
|
|
12
|
+
directoryExists,
|
|
13
|
+
getBlobsDir,
|
|
14
|
+
getProjectDir,
|
|
15
|
+
getSessionsDir,
|
|
16
|
+
isEnoent,
|
|
17
|
+
logger,
|
|
18
|
+
toError,
|
|
19
|
+
} from "@oh-my-pi-zen/pi-utils";
|
|
20
|
+
import { ArtifactManager } from "./artifacts";
|
|
21
|
+
import { type BlobPutOptions, type BlobPutResult, BlobStore } from "./blob-store";
|
|
22
|
+
import {
|
|
23
|
+
type BashExecutionMessage,
|
|
24
|
+
type CustomMessage,
|
|
25
|
+
type FileMentionMessage,
|
|
26
|
+
type HookMessage,
|
|
27
|
+
type PythonExecutionMessage,
|
|
28
|
+
sanitizeRehydratedOpenAIResponsesAssistantMessage,
|
|
29
|
+
stripInternalDetailsFields,
|
|
30
|
+
} from "./messages";
|
|
31
|
+
import { type BuildSessionContextOptions, buildSessionContext, type SessionContext } from "./session-context";
|
|
32
|
+
import {
|
|
33
|
+
type BranchSummaryEntry,
|
|
34
|
+
type CompactionEntry,
|
|
35
|
+
CURRENT_SESSION_VERSION,
|
|
36
|
+
type CustomEntry,
|
|
37
|
+
type CustomMessageEntry,
|
|
38
|
+
type FileEntry,
|
|
39
|
+
type LabelEntry,
|
|
40
|
+
type MCPToolSelectionEntry,
|
|
41
|
+
type ModeChangeEntry,
|
|
42
|
+
type ModelChangeEntry,
|
|
43
|
+
type NewSessionOptions,
|
|
44
|
+
type ServiceTierChangeEntry,
|
|
45
|
+
type SessionEntry,
|
|
46
|
+
type SessionHeader,
|
|
47
|
+
type SessionInitEntry,
|
|
48
|
+
type SessionMessageEntry,
|
|
49
|
+
type SessionTitleSource,
|
|
50
|
+
type SessionTreeNode,
|
|
51
|
+
type ThinkingLevelChangeEntry,
|
|
52
|
+
TITLE_CHANGE_ENTRY_TYPE,
|
|
53
|
+
type TitleChangeEntry,
|
|
54
|
+
type TtsrInjectionEntry,
|
|
55
|
+
type UsageStatistics,
|
|
56
|
+
} from "./session-entries";
|
|
57
|
+
import { findMostRecentSession, listAllSessions, listSessions, type SessionInfo } from "./session-listing";
|
|
58
|
+
import { loadEntriesFromFile, readTitleSlotFromFile, resolveBlobRefsInEntries } from "./session-loader";
|
|
59
|
+
import { generateId, migrateToCurrentVersion } from "./session-migrations";
|
|
60
|
+
import {
|
|
61
|
+
computeDefaultSessionDir,
|
|
62
|
+
readTerminalBreadcrumbEntry,
|
|
63
|
+
resolveManagedSessionRoot,
|
|
64
|
+
writeTerminalBreadcrumb,
|
|
65
|
+
} from "./session-paths";
|
|
66
|
+
import { prepareEntryForPersistence } from "./session-persistence";
|
|
67
|
+
import {
|
|
68
|
+
FileSessionStorage,
|
|
69
|
+
MemorySessionStorage,
|
|
70
|
+
type SessionStorage,
|
|
71
|
+
type SessionStorageWriter,
|
|
72
|
+
} from "./session-storage";
|
|
73
|
+
import { type SessionTitleUpdate, serializeTitleSlot } from "./session-title-slot";
|
|
74
|
+
|
|
75
|
+
const JSONL_SUFFIX_LENGTH = ".jsonl".length;
|
|
76
|
+
const SUPERSEDED_COMPACTION_SUMMARY = "[Superseded compaction summary elided after a newer compaction]";
|
|
77
|
+
const SUPERSEDED_COMPACTION_SHORT_SUMMARY = "Superseded compaction elided";
|
|
78
|
+
|
|
79
|
+
function mintSessionId(): string {
|
|
80
|
+
return Bun.randomUUIDv7();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function nowIso(): string {
|
|
84
|
+
return new Date().toISOString();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function fileSafeTimestamp(iso: string): string {
|
|
88
|
+
return iso.replace(/[:.]/g, "-");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function artifactsDirectoryFor(sessionFile: string | undefined): string | null {
|
|
92
|
+
return sessionFile ? sessionFile.slice(0, -JSONL_SUFFIX_LENGTH) : null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Resolve a breadcrumb's recorded session file to its interactive root. Subagent
|
|
97
|
+
* (and other artifact) sessions live inside a parent session's artifacts dir —
|
|
98
|
+
* `<parent>.jsonl` strips its suffix to `<parent>/`, and a child writes
|
|
99
|
+
* `<parent>/<agentId>.jsonl`. A breadcrumb that points at such a child — a
|
|
100
|
+
* pre-fix poisoned crumb left by a subagent that opened in the parent's TTY, or
|
|
101
|
+
* any nested artifact — must resolve back up to the top-level session so
|
|
102
|
+
* `--continue` resumes the real conversation instead of a subagent transcript.
|
|
103
|
+
*/
|
|
104
|
+
function resolveBreadcrumbToInteractiveRoot(sessionFile: string): string {
|
|
105
|
+
let current = path.resolve(sessionFile);
|
|
106
|
+
// Walk up while the containing dir is itself a session's artifacts dir
|
|
107
|
+
// (`<dir>.jsonl` exists). Capped to defend against pathological layouts.
|
|
108
|
+
for (let depth = 0; depth < 8; depth++) {
|
|
109
|
+
const parentSessionFile = `${path.dirname(current)}.jsonl`;
|
|
110
|
+
if (!fs.existsSync(parentSessionFile)) return current;
|
|
111
|
+
current = parentSessionFile;
|
|
112
|
+
}
|
|
113
|
+
return current;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function emptyUsageStatistics(): UsageStatistics {
|
|
117
|
+
return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, premiumRequests: 0, cost: 0 };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function taskUsageFrom(details: unknown): Usage | undefined {
|
|
121
|
+
if (details === null || typeof details !== "object") return undefined;
|
|
122
|
+
const maybeUsage = (details as Record<string, unknown>).usage;
|
|
123
|
+
return maybeUsage !== null && typeof maybeUsage === "object" ? (maybeUsage as Usage) : undefined;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function entryUsage(entry: SessionEntry): Usage | undefined {
|
|
127
|
+
if (entry.type !== "message") return undefined;
|
|
128
|
+
const message = entry.message;
|
|
129
|
+
if (message.role === "assistant") return message.usage;
|
|
130
|
+
if (message.role === "toolResult" && message.toolName === "task") return taskUsageFrom(message.details);
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function addUsage(target: UsageStatistics, usage: Usage | undefined): void {
|
|
135
|
+
if (!usage) return;
|
|
136
|
+
target.input += usage.input;
|
|
137
|
+
target.output += usage.output;
|
|
138
|
+
target.cacheRead += usage.cacheRead;
|
|
139
|
+
target.cacheWrite += usage.cacheWrite;
|
|
140
|
+
target.premiumRequests += usage.premiumRequests ?? 0;
|
|
141
|
+
target.cost += usage.cost.total;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function isAssistantEntry(entry: SessionEntry): boolean {
|
|
145
|
+
return entry.type === "message" && entry.message.role === "assistant";
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function orderedByTimestamp(a: SessionTreeNode, b: SessionTreeNode): number {
|
|
149
|
+
return new Date(a.entry.timestamp).getTime() - new Date(b.entry.timestamp).getTime();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Maintains the derived views over a session's entry list: id lookup, the
|
|
154
|
+
* parent→children adjacency, the resolved label map, the active leaf, and the
|
|
155
|
+
* running usage totals. Kept in lockstep with the manager's `#entries` so reads
|
|
156
|
+
* stay O(1)/O(children) instead of rescanning the whole journal.
|
|
157
|
+
*/
|
|
158
|
+
class SessionEntryIndex {
|
|
159
|
+
#entriesById = new Map<string, SessionEntry>();
|
|
160
|
+
#children = new Map<string | null, SessionEntry[]>();
|
|
161
|
+
#labels = new Map<string, string>();
|
|
162
|
+
#leaf: string | null = null;
|
|
163
|
+
#usage = emptyUsageStatistics();
|
|
164
|
+
|
|
165
|
+
clear(): void {
|
|
166
|
+
this.#entriesById.clear();
|
|
167
|
+
this.#children.clear();
|
|
168
|
+
this.#labels.clear();
|
|
169
|
+
this.#leaf = null;
|
|
170
|
+
this.#usage = emptyUsageStatistics();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
rebuild(entries: readonly SessionEntry[]): void {
|
|
174
|
+
this.clear();
|
|
175
|
+
for (const entry of entries) this.insert(entry);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
insert(entry: SessionEntry): void {
|
|
179
|
+
this.#entriesById.set(entry.id, entry);
|
|
180
|
+
this.#leaf = entry.id;
|
|
181
|
+
|
|
182
|
+
const bucket = this.#children.get(entry.parentId);
|
|
183
|
+
if (bucket) bucket.push(entry);
|
|
184
|
+
else this.#children.set(entry.parentId, [entry]);
|
|
185
|
+
|
|
186
|
+
if (entry.type === "label") {
|
|
187
|
+
if (entry.label) this.#labels.set(entry.targetId, entry.label);
|
|
188
|
+
else this.#labels.delete(entry.targetId);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
addUsage(this.#usage, entryUsage(entry));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
has(id: string): boolean {
|
|
195
|
+
return this.#entriesById.has(id);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
get(id: string): SessionEntry | undefined {
|
|
199
|
+
return this.#entriesById.get(id);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* The live id→entry map. Read-only for callers (lookups + `generateId`
|
|
204
|
+
* collision checks); never mutate it directly — go through `insert`/`rebuild`.
|
|
205
|
+
*/
|
|
206
|
+
entriesById(): Map<string, SessionEntry> {
|
|
207
|
+
return this.#entriesById;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
leafId(): string | null {
|
|
211
|
+
return this.#leaf;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
leafEntry(): SessionEntry | undefined {
|
|
215
|
+
return this.#leaf ? this.#entriesById.get(this.#leaf) : undefined;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
setLeaf(id: string | null): void {
|
|
219
|
+
this.#leaf = id;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
childrenOf(parentId: string): SessionEntry[] {
|
|
223
|
+
return [...(this.#children.get(parentId) ?? [])];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
labelFor(id: string): string | undefined {
|
|
227
|
+
return this.#labels.get(id);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
labelsInEffect(): IterableIterator<[string, string]> {
|
|
231
|
+
return this.#labels.entries();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
usageSnapshot(): UsageStatistics {
|
|
235
|
+
return { ...this.#usage };
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
pathTo(id: string | null | undefined = this.#leaf): SessionEntry[] {
|
|
239
|
+
const branch: SessionEntry[] = [];
|
|
240
|
+
const seen = new Set<string>();
|
|
241
|
+
let cursor = id ? this.#entriesById.get(id) : undefined;
|
|
242
|
+
|
|
243
|
+
while (cursor && !seen.has(cursor.id)) {
|
|
244
|
+
seen.add(cursor.id);
|
|
245
|
+
branch.push(cursor);
|
|
246
|
+
cursor = cursor.parentId ? this.#entriesById.get(cursor.parentId) : undefined;
|
|
247
|
+
}
|
|
248
|
+
branch.reverse();
|
|
249
|
+
return branch;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
tree(entries: readonly SessionEntry[]): SessionTreeNode[] {
|
|
253
|
+
const nodes = new Map<string, SessionTreeNode>();
|
|
254
|
+
const roots: SessionTreeNode[] = [];
|
|
255
|
+
|
|
256
|
+
for (const entry of entries) {
|
|
257
|
+
nodes.set(entry.id, { entry, children: [], label: this.#labels.get(entry.id) });
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
for (const entry of entries) {
|
|
261
|
+
const node = nodes.get(entry.id)!;
|
|
262
|
+
const parentId = entry.parentId;
|
|
263
|
+
if (parentId === null || parentId === entry.id) {
|
|
264
|
+
roots.push(node);
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const parent = nodes.get(parentId);
|
|
269
|
+
if (parent) parent.children.push(node);
|
|
270
|
+
else roots.push(node);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const stack = [...roots];
|
|
274
|
+
while (stack.length > 0) {
|
|
275
|
+
const node = stack.pop()!;
|
|
276
|
+
node.children.sort(orderedByTimestamp);
|
|
277
|
+
stack.push(...node.children);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return roots;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export type ReadonlySessionManager = Pick<
|
|
285
|
+
SessionManager,
|
|
286
|
+
| "getCwd"
|
|
287
|
+
| "getSessionDir"
|
|
288
|
+
| "getSessionId"
|
|
289
|
+
| "getSessionFile"
|
|
290
|
+
| "getSessionName"
|
|
291
|
+
| "getArtifactsDir"
|
|
292
|
+
| "getArtifactManager"
|
|
293
|
+
| "allocateArtifactPath"
|
|
294
|
+
| "saveArtifact"
|
|
295
|
+
| "getArtifactPath"
|
|
296
|
+
| "getLeafId"
|
|
297
|
+
| "getLeafEntry"
|
|
298
|
+
| "getEntry"
|
|
299
|
+
| "getLabel"
|
|
300
|
+
| "getBranch"
|
|
301
|
+
| "getHeader"
|
|
302
|
+
| "getEntries"
|
|
303
|
+
| "getTree"
|
|
304
|
+
| "getUsageStatistics"
|
|
305
|
+
| "putBlob"
|
|
306
|
+
| "putBlobSync"
|
|
307
|
+
>;
|
|
308
|
+
|
|
309
|
+
interface SessionManagerStateSnapshot {
|
|
310
|
+
cwd: string;
|
|
311
|
+
sessionDir: string;
|
|
312
|
+
sessionId: string;
|
|
313
|
+
sessionName: string | undefined;
|
|
314
|
+
titleSource: SessionTitleSource | undefined;
|
|
315
|
+
sessionFile: string | undefined;
|
|
316
|
+
titleUpdatedAt: string;
|
|
317
|
+
hasTitleSlot: boolean;
|
|
318
|
+
onDisk: boolean;
|
|
319
|
+
needsRewrite: boolean;
|
|
320
|
+
header: SessionHeader;
|
|
321
|
+
entries: SessionEntry[];
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
interface DiskQueueOptions {
|
|
325
|
+
ignorePriorError?: boolean;
|
|
326
|
+
ignoreEpoch?: boolean;
|
|
327
|
+
epoch?: number;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Stores and navigates an append-only conversation journal.
|
|
332
|
+
*
|
|
333
|
+
* A session is a JSONL file: one header line followed by entries. Entries form a
|
|
334
|
+
* tree by `(id, parentId)`, and the mutable leaf pointer selects which path is
|
|
335
|
+
* active for future appends and for LLM context construction.
|
|
336
|
+
*
|
|
337
|
+
* Durability is software-crash safe but not power-loss safe: appends are handed
|
|
338
|
+
* to the OS synchronously in-body (so an entry survives an OOM/SIGKILL the
|
|
339
|
+
* instant `appendMessage` returns) but never `fsync`'d. Full-file rewrites go
|
|
340
|
+
* through the storage layer's atomic temp-write+rename so a crash mid-rewrite
|
|
341
|
+
* cannot truncate the prior good file.
|
|
342
|
+
*/
|
|
343
|
+
export class SessionManager {
|
|
344
|
+
#cwd: string;
|
|
345
|
+
#sessionDir: string;
|
|
346
|
+
readonly #persist: boolean;
|
|
347
|
+
readonly #storage: SessionStorage;
|
|
348
|
+
readonly #blobs: BlobStore;
|
|
349
|
+
|
|
350
|
+
#sessionId = "";
|
|
351
|
+
#sessionName: string | undefined;
|
|
352
|
+
#titleSource: SessionTitleSource | undefined;
|
|
353
|
+
#sessionFile: string | undefined;
|
|
354
|
+
#header!: SessionHeader;
|
|
355
|
+
#titleUpdatedAt = "";
|
|
356
|
+
#hasTitleSlot = true;
|
|
357
|
+
#entries: SessionEntry[] = [];
|
|
358
|
+
#index = new SessionEntryIndex();
|
|
359
|
+
|
|
360
|
+
/** File reflects all current entries; appends can go incrementally. */
|
|
361
|
+
#fileIsCurrent = false;
|
|
362
|
+
/** In-memory entries diverged from disk (load-migration/sanitize) → next persist must full-rewrite. */
|
|
363
|
+
#rewriteRequired = false;
|
|
364
|
+
/** Lazy gate crossed (ensureOnDisk / loaded file): every entry must persist from now on. */
|
|
365
|
+
#forceFileCreation = false;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Collab replication tap: invoked for every appended entry with the
|
|
369
|
+
* in-memory (pre-blob-externalization) entry, so inline images survive.
|
|
370
|
+
*/
|
|
371
|
+
onEntryAppended?: (entry: SessionEntry) => void;
|
|
372
|
+
|
|
373
|
+
#turnBudgetTotal: number | null = null;
|
|
374
|
+
#turnBudgetHard = false;
|
|
375
|
+
#turnOutputBaseline = 0;
|
|
376
|
+
#turnEvalOutput = 0;
|
|
377
|
+
|
|
378
|
+
/** The single open append writer; the manager only ever writes one file at a time. */
|
|
379
|
+
#writer: SessionStorageWriter | undefined;
|
|
380
|
+
/** Serializes async disk work (flush/close/atomic rewrite). Appends are synchronous and bypass it. */
|
|
381
|
+
#diskTail: Promise<void> = Promise.resolve();
|
|
382
|
+
#diskFailure: Error | undefined;
|
|
383
|
+
#diskFailureLogged = false;
|
|
384
|
+
/** Bumped on every sync rewrite / chain reset so stale queued tasks become no-ops. */
|
|
385
|
+
#diskEpoch = 0;
|
|
386
|
+
/**
|
|
387
|
+
* Epoch of the in-flight atomic rewrite, or `null` when no rewrite is running.
|
|
388
|
+
* The fence in {@link #appendToSessionFile} only applies while this matches
|
|
389
|
+
* `#diskEpoch`: once a synchronous rewrite (`flushSync` → `#rewriteSynchronously`)
|
|
390
|
+
* bumps the epoch, the pending atomic publish is guaranteed to abandon via
|
|
391
|
+
* its `commitGuard`, and appends can safely take the hot path against the
|
|
392
|
+
* freshly-published file.
|
|
393
|
+
*/
|
|
394
|
+
#atomicRewriteFenceEpoch: number | null = null;
|
|
395
|
+
/** Set by synchronous appends that land while an atomic replacement is active. */
|
|
396
|
+
#atomicRewriteDirty = false;
|
|
397
|
+
|
|
398
|
+
#artifactManager: ArtifactManager | null = null;
|
|
399
|
+
#artifactManagerSessionFile: string | null = null;
|
|
400
|
+
#adoptedArtifactManager: ArtifactManager | null = null;
|
|
401
|
+
#inMemoryArtifacts: Map<string, string> | null = null;
|
|
402
|
+
#inMemoryArtifactCounter = 0;
|
|
403
|
+
|
|
404
|
+
#suppressBreadcrumb = false;
|
|
405
|
+
#sessionNameChangedCallbacks = new Set<() => void>();
|
|
406
|
+
|
|
407
|
+
private constructor(cwd: string, sessionDir: string, persist: boolean, storage: SessionStorage) {
|
|
408
|
+
this.#cwd = cwd;
|
|
409
|
+
this.#sessionDir = sessionDir;
|
|
410
|
+
this.#persist = persist;
|
|
411
|
+
this.#storage = storage;
|
|
412
|
+
this.#blobs = new BlobStore(getBlobsDir());
|
|
413
|
+
|
|
414
|
+
if (persist && sessionDir) this.#storage.ensureDirSync(sessionDir);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
#rememberBreadcrumb(cwd: string, sessionFile: string): void {
|
|
418
|
+
if (!this.#suppressBreadcrumb) writeTerminalBreadcrumb(cwd, sessionFile);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
#clearDiskError(): void {
|
|
422
|
+
this.#diskFailure = undefined;
|
|
423
|
+
this.#diskFailureLogged = false;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
#noteDiskFailure(errorLike: unknown): Error {
|
|
427
|
+
const error = toError(errorLike);
|
|
428
|
+
if (!this.#diskFailure) this.#diskFailure = error;
|
|
429
|
+
|
|
430
|
+
if (!this.#diskFailureLogged) {
|
|
431
|
+
this.#diskFailureLogged = true;
|
|
432
|
+
logger.error("Session persistence error.", {
|
|
433
|
+
sessionFile: this.#sessionFile,
|
|
434
|
+
error: error.message,
|
|
435
|
+
stack: error.stack,
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
return this.#diskFailure;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
#scheduleDiskWork(work: () => Promise<void>, options: DiskQueueOptions = {}): Promise<void> {
|
|
443
|
+
const epoch = options.epoch ?? this.#diskEpoch;
|
|
444
|
+
const scheduled = this.#diskTail
|
|
445
|
+
.catch(() => undefined)
|
|
446
|
+
.then(async () => {
|
|
447
|
+
if (!options.ignoreEpoch && epoch !== this.#diskEpoch) return;
|
|
448
|
+
if (this.#diskFailure && !options.ignorePriorError) throw this.#diskFailure;
|
|
449
|
+
await work();
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
const reported = scheduled.catch(err => {
|
|
453
|
+
throw this.#noteDiskFailure(err);
|
|
454
|
+
});
|
|
455
|
+
this.#diskTail = reported.catch(() => undefined);
|
|
456
|
+
return reported;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
async #drainAndCloseWriter(): Promise<void> {
|
|
460
|
+
try {
|
|
461
|
+
await this.#scheduleDiskWork(
|
|
462
|
+
async () => {
|
|
463
|
+
await this.#closeWriterHandle();
|
|
464
|
+
},
|
|
465
|
+
{ ignorePriorError: true, ignoreEpoch: true },
|
|
466
|
+
);
|
|
467
|
+
} finally {
|
|
468
|
+
this.#writer = undefined;
|
|
469
|
+
this.#diskTail = Promise.resolve();
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
#closeWriterEventually(): void {
|
|
474
|
+
const writer = this.#writer;
|
|
475
|
+
this.#writer = undefined;
|
|
476
|
+
if (writer) void writer.close().catch(() => undefined);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
async #closeWriterHandle(): Promise<void> {
|
|
480
|
+
const writer = this.#writer;
|
|
481
|
+
if (!writer) return;
|
|
482
|
+
this.#writer = undefined;
|
|
483
|
+
await writer.close();
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
#appendWriter(): SessionStorageWriter {
|
|
487
|
+
if (!this.#sessionFile) throw new Error("Cannot open a session writer before a session file exists");
|
|
488
|
+
|
|
489
|
+
if (this.#writer?.isOpen()) return this.#writer;
|
|
490
|
+
|
|
491
|
+
this.#writer = this.#storage.openWriter(this.#sessionFile, {
|
|
492
|
+
flags: "a",
|
|
493
|
+
onError: err => this.#noteDiskFailure(err),
|
|
494
|
+
});
|
|
495
|
+
return this.#writer;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
#lineFor(entry: FileEntry): string {
|
|
499
|
+
return `${JSON.stringify(prepareEntryForPersistence(entry, this.#blobs))}\n`;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
#titleSlotLine(): string {
|
|
503
|
+
return serializeTitleSlot({
|
|
504
|
+
title: this.#sessionName,
|
|
505
|
+
source: this.#titleSource,
|
|
506
|
+
updatedAt: this.#titleUpdatedAt || this.#header.timestamp,
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
#fileBody(): string {
|
|
511
|
+
let body = this.#titleSlotLine();
|
|
512
|
+
body += this.#lineFor(this.#header);
|
|
513
|
+
for (const entry of this.#entries) body += this.#lineFor(entry);
|
|
514
|
+
return body;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
#historyContainsAssistantMessage(): boolean {
|
|
518
|
+
return this.#entries.some(isAssistantEntry);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
#shouldHaveSessionFile(): boolean {
|
|
522
|
+
return this.#forceFileCreation || this.#fileIsCurrent || this.#historyContainsAssistantMessage();
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
#elideSupersededCompactionsOnBranch(leafId: string | null): boolean {
|
|
526
|
+
if (!leafId) return false;
|
|
527
|
+
let changed = false;
|
|
528
|
+
for (const entry of this.#index.pathTo(leafId)) {
|
|
529
|
+
if (entry.type !== "compaction") continue;
|
|
530
|
+
if (
|
|
531
|
+
entry.summary === SUPERSEDED_COMPACTION_SUMMARY &&
|
|
532
|
+
entry.shortSummary === SUPERSEDED_COMPACTION_SHORT_SUMMARY &&
|
|
533
|
+
entry.preserveData === undefined
|
|
534
|
+
) {
|
|
535
|
+
continue;
|
|
536
|
+
}
|
|
537
|
+
entry.summary = SUPERSEDED_COMPACTION_SUMMARY;
|
|
538
|
+
entry.shortSummary = SUPERSEDED_COMPACTION_SHORT_SUMMARY;
|
|
539
|
+
entry.preserveData = undefined;
|
|
540
|
+
changed = true;
|
|
541
|
+
}
|
|
542
|
+
return changed;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Synchronously rewrite the whole file (header + entries) and keep no open
|
|
547
|
+
* writer; the next append re-opens one. `writeTextSync` returns with the
|
|
548
|
+
* bytes in the kernel page cache, so the file is software-crash durable.
|
|
549
|
+
*/
|
|
550
|
+
#rewriteSynchronously(): void {
|
|
551
|
+
if (!this.#persist || !this.#sessionFile || !this.#shouldHaveSessionFile()) return;
|
|
552
|
+
|
|
553
|
+
try {
|
|
554
|
+
const body = this.#fileBody();
|
|
555
|
+
this.#diskEpoch++;
|
|
556
|
+
this.#diskTail = Promise.resolve();
|
|
557
|
+
this.#closeWriterEventually();
|
|
558
|
+
this.#storage.writeTextSync(this.#sessionFile, body);
|
|
559
|
+
this.#fileIsCurrent = true;
|
|
560
|
+
this.#rewriteRequired = false;
|
|
561
|
+
this.#hasTitleSlot = true;
|
|
562
|
+
} catch (err) {
|
|
563
|
+
this.#noteDiskFailure(err);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Rewrite the whole file atomically (temp-write + rename, EPERM-safe) on the
|
|
569
|
+
* disk chain. The body is serialized after the writer is closed. The fence
|
|
570
|
+
* is enabled BEFORE `#closeWriterHandle()` and stays active until the last
|
|
571
|
+
* atomic publish returns, so a sync append landing in the close-yield window
|
|
572
|
+
* cannot open a fresh writer that the pending replacement would then detach
|
|
573
|
+
* from the current JSONL path. A `commitGuard` also prevents a superseding
|
|
574
|
+
* synchronous rewrite from being overwritten by the stale body serialized
|
|
575
|
+
* before it ran.
|
|
576
|
+
*/
|
|
577
|
+
async #rewriteAtomically(): Promise<void> {
|
|
578
|
+
if (!this.#persist || !this.#sessionFile) return;
|
|
579
|
+
|
|
580
|
+
const startEpoch = this.#diskEpoch;
|
|
581
|
+
await this.#scheduleDiskWork(
|
|
582
|
+
async () => {
|
|
583
|
+
if (await this.#runFencedAtomicRewrite(startEpoch)) {
|
|
584
|
+
this.#fileIsCurrent = true;
|
|
585
|
+
this.#rewriteRequired = false;
|
|
586
|
+
this.#hasTitleSlot = true;
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
{ epoch: startEpoch },
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Shared fenced atomic-rewrite loop used by `#rewriteAtomically` and the
|
|
595
|
+
* `#persistTitleChangeEntry` fallback. Holds `#atomicRewriteActive` across
|
|
596
|
+
* the writer close and the full-file replace, and loops on
|
|
597
|
+
* `#atomicRewriteDirty` so any fenced append that lands during the rewrite
|
|
598
|
+
* is captured before the task resolves. Returns `false` when the disk epoch
|
|
599
|
+
* moved (a superseding synchronous rewrite has taken over) so callers skip
|
|
600
|
+
* their post-publish state updates.
|
|
601
|
+
*/
|
|
602
|
+
async #runFencedAtomicRewrite(epoch: number): Promise<boolean> {
|
|
603
|
+
this.#atomicRewriteFenceEpoch = epoch;
|
|
604
|
+
try {
|
|
605
|
+
do {
|
|
606
|
+
this.#atomicRewriteDirty = false;
|
|
607
|
+
await this.#closeWriterHandle();
|
|
608
|
+
const sessionFile = this.#sessionFile;
|
|
609
|
+
if (!sessionFile) return false;
|
|
610
|
+
if (this.#diskEpoch !== epoch) return false;
|
|
611
|
+
await this.#storage.writeTextAtomic(sessionFile, this.#fileBody(), {
|
|
612
|
+
commitGuard: () => this.#diskEpoch === epoch,
|
|
613
|
+
});
|
|
614
|
+
if (this.#diskEpoch !== epoch) return false;
|
|
615
|
+
} while (this.#atomicRewriteDirty);
|
|
616
|
+
return true;
|
|
617
|
+
} finally {
|
|
618
|
+
// Only relinquish the fence if we still own it. A superseding
|
|
619
|
+
// synchronous rewrite (`flushSync` → `#rewriteSynchronously`) may
|
|
620
|
+
// have reset `#diskTail`, scheduled a fresh atomic task at the new
|
|
621
|
+
// epoch, and that task may have taken ownership of the fence while
|
|
622
|
+
// this stale rewrite was still awaiting storage. Clearing it here
|
|
623
|
+
// unconditionally would strand appends during the newer publish.
|
|
624
|
+
if (this.#atomicRewriteFenceEpoch === epoch) this.#atomicRewriteFenceEpoch = null;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
#appendToSessionFile(entry: SessionEntry): void {
|
|
629
|
+
if (!this.#persist || !this.#sessionFile) return;
|
|
630
|
+
if (this.#diskFailure) throw this.#diskFailure;
|
|
631
|
+
|
|
632
|
+
// Lazy gate: a brand-new session is not written until it has an assistant
|
|
633
|
+
// message (or someone forced creation), so sessions that never produce
|
|
634
|
+
// output never create a file.
|
|
635
|
+
if (!this.#shouldHaveSessionFile()) {
|
|
636
|
+
this.#fileIsCurrent = false;
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// Atomic replacement window: the old path may be moved aside underneath
|
|
641
|
+
// any newly-opened append handle (Windows EPERM fallback). Do not open a
|
|
642
|
+
// writer here; the active rewrite loops and serializes a fresh full body.
|
|
643
|
+
// A superseding synchronous rewrite bumps `#diskEpoch`, at which point
|
|
644
|
+
// the pending atomic publish is guaranteed to abandon via its
|
|
645
|
+
// `commitGuard`, so appends can (and must) take the hot path so they
|
|
646
|
+
// don't strand in memory while `close()` returns without a rewrite.
|
|
647
|
+
if (this.#atomicRewriteFenceEpoch !== null && this.#atomicRewriteFenceEpoch === this.#diskEpoch) {
|
|
648
|
+
this.#fileIsCurrent = false;
|
|
649
|
+
this.#rewriteRequired = true;
|
|
650
|
+
this.#atomicRewriteDirty = true;
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
// Cold/divergent: not on disk yet, or in-memory entries diverged from the
|
|
654
|
+
// file → rewrite the whole file synchronously and keep going.
|
|
655
|
+
if (!this.#fileIsCurrent || this.#rewriteRequired) {
|
|
656
|
+
this.#rewriteSynchronously();
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// Hot path: append synchronously so the entry is durable the instant this
|
|
661
|
+
// returns (file/memory writers perform the write in-body). Never routed
|
|
662
|
+
// through the async disk chain — durability must hold without a flush().
|
|
663
|
+
// A mid-close writer leaves `#writer` undefined, so `#appendWriter` simply
|
|
664
|
+
// opens a fresh append handle and the entry still lands.
|
|
665
|
+
try {
|
|
666
|
+
void this.#appendWriter()
|
|
667
|
+
.append(this.#lineFor(entry))
|
|
668
|
+
.catch(err => this.#noteDiskFailure(err));
|
|
669
|
+
} catch (err) {
|
|
670
|
+
this.#noteDiskFailure(err);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
async #persistTitleChangeEntry(entry: TitleChangeEntry, update: SessionTitleUpdate): Promise<void> {
|
|
675
|
+
if (!this.#persist || !this.#sessionFile) return;
|
|
676
|
+
if (this.#diskFailure) throw this.#diskFailure;
|
|
677
|
+
|
|
678
|
+
if (!this.#shouldHaveSessionFile()) {
|
|
679
|
+
this.#fileIsCurrent = false;
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
if (
|
|
684
|
+
!this.#fileIsCurrent ||
|
|
685
|
+
this.#rewriteRequired ||
|
|
686
|
+
!this.#hasTitleSlot ||
|
|
687
|
+
!this.#storage.existsSync(this.#sessionFile)
|
|
688
|
+
) {
|
|
689
|
+
await this.#rewriteAtomically();
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
const epoch = this.#diskEpoch;
|
|
694
|
+
const line = this.#lineFor(entry);
|
|
695
|
+
await this.#scheduleDiskWork(
|
|
696
|
+
async () => {
|
|
697
|
+
const sessionFile = this.#sessionFile;
|
|
698
|
+
if (!sessionFile) return;
|
|
699
|
+
try {
|
|
700
|
+
await this.#appendWriter().append(line);
|
|
701
|
+
await this.#storage.updateSessionTitle(sessionFile, update);
|
|
702
|
+
if (this.#diskEpoch === epoch) this.#fileIsCurrent = true;
|
|
703
|
+
} catch {
|
|
704
|
+
if (!(await this.#runFencedAtomicRewrite(epoch))) return;
|
|
705
|
+
this.#clearDiskError();
|
|
706
|
+
this.#fileIsCurrent = true;
|
|
707
|
+
this.#rewriteRequired = false;
|
|
708
|
+
this.#hasTitleSlot = true;
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
{ epoch },
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
#notifyEntryAppended(entry: SessionEntry): void {
|
|
716
|
+
const callback = this.onEntryAppended;
|
|
717
|
+
if (callback) {
|
|
718
|
+
try {
|
|
719
|
+
callback(entry);
|
|
720
|
+
} catch (err) {
|
|
721
|
+
logger.warn("collab entry hook failed", { error: String(err) });
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
#resetToNewSession(options?: NewSessionOptions, forcedSessionFile?: string): string | undefined {
|
|
727
|
+
this.#diskTail = Promise.resolve();
|
|
728
|
+
this.#clearDiskError();
|
|
729
|
+
this.#sessionId = mintSessionId();
|
|
730
|
+
this.#sessionName = undefined;
|
|
731
|
+
this.#titleSource = undefined;
|
|
732
|
+
this.#titleUpdatedAt = "";
|
|
733
|
+
this.#hasTitleSlot = true;
|
|
734
|
+
|
|
735
|
+
const timestamp = nowIso();
|
|
736
|
+
this.#header = {
|
|
737
|
+
type: "session",
|
|
738
|
+
version: CURRENT_SESSION_VERSION,
|
|
739
|
+
id: this.#sessionId,
|
|
740
|
+
timestamp,
|
|
741
|
+
cwd: this.#cwd,
|
|
742
|
+
parentSession: options?.parentSession,
|
|
743
|
+
};
|
|
744
|
+
this.#titleUpdatedAt = timestamp;
|
|
745
|
+
|
|
746
|
+
this.#entries = [];
|
|
747
|
+
this.#index.clear();
|
|
748
|
+
this.#fileIsCurrent = false;
|
|
749
|
+
this.#rewriteRequired = false;
|
|
750
|
+
this.#forceFileCreation = false;
|
|
751
|
+
this.#turnBudgetTotal = null;
|
|
752
|
+
this.#turnBudgetHard = false;
|
|
753
|
+
this.#turnOutputBaseline = 0;
|
|
754
|
+
this.#turnEvalOutput = 0;
|
|
755
|
+
this.#artifactManager = null;
|
|
756
|
+
this.#artifactManagerSessionFile = null;
|
|
757
|
+
this.#adoptedArtifactManager = null;
|
|
758
|
+
this.#inMemoryArtifacts = null;
|
|
759
|
+
this.#inMemoryArtifactCounter = 0;
|
|
760
|
+
|
|
761
|
+
if (this.#persist) {
|
|
762
|
+
this.#sessionFile =
|
|
763
|
+
forcedSessionFile ??
|
|
764
|
+
path.join(this.#sessionDir, `${fileSafeTimestamp(timestamp)}_${this.#sessionId}.jsonl`);
|
|
765
|
+
this.#rememberBreadcrumb(this.#cwd, this.#sessionFile);
|
|
766
|
+
} else {
|
|
767
|
+
this.#sessionFile = undefined;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
return this.#sessionFile;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
#applyEntries(header: SessionHeader, entries: SessionEntry[]): void {
|
|
774
|
+
this.#header = header;
|
|
775
|
+
this.#entries = entries;
|
|
776
|
+
this.#sessionId = header.id;
|
|
777
|
+
this.#sessionName = header.title;
|
|
778
|
+
this.#titleSource = header.titleSource;
|
|
779
|
+
this.#titleUpdatedAt = header.timestamp;
|
|
780
|
+
this.#index.rebuild(entries);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
#freshEntryFields(): { id: string; parentId: string | null; timestamp: string } {
|
|
784
|
+
return {
|
|
785
|
+
id: generateId(this.#index),
|
|
786
|
+
parentId: this.#index.leafId(),
|
|
787
|
+
timestamp: nowIso(),
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
#recordEntry(entry: SessionEntry): void {
|
|
792
|
+
this.#entries.push(entry);
|
|
793
|
+
this.#index.insert(entry);
|
|
794
|
+
this.#appendToSessionFile(entry);
|
|
795
|
+
this.#notifyEntryAppended(entry);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
#draftPath(): string | null {
|
|
799
|
+
const artifactsDir = this.getArtifactsDir();
|
|
800
|
+
return artifactsDir ? path.join(artifactsDir, "draft.txt") : null;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
#artifactManagerForSession(): ArtifactManager | null {
|
|
804
|
+
if (this.#adoptedArtifactManager) return this.#adoptedArtifactManager;
|
|
805
|
+
|
|
806
|
+
const sessionFile = this.#sessionFile;
|
|
807
|
+
if (!sessionFile) {
|
|
808
|
+
this.#artifactManager = null;
|
|
809
|
+
this.#artifactManagerSessionFile = null;
|
|
810
|
+
return null;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
if (this.#artifactManager && this.#artifactManagerSessionFile === sessionFile) return this.#artifactManager;
|
|
814
|
+
|
|
815
|
+
this.#artifactManager = new ArtifactManager(sessionFile.slice(0, -JSONL_SUFFIX_LENGTH));
|
|
816
|
+
this.#artifactManagerSessionFile = sessionFile;
|
|
817
|
+
return this.#artifactManager;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
#notifySessionNameListeners(): void {
|
|
821
|
+
for (const callback of [...this.#sessionNameChangedCallbacks]) {
|
|
822
|
+
try {
|
|
823
|
+
callback();
|
|
824
|
+
} catch (err) {
|
|
825
|
+
logger.warn("SessionManager: session name change hook failed", { error: String(err) });
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
static #cleanTitle(raw: string): string {
|
|
831
|
+
return raw
|
|
832
|
+
.replace(/[\u0000-\u001f\u007f-\u009f]/g, " ")
|
|
833
|
+
.replace(/ +/g, " ")
|
|
834
|
+
.trim();
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/** Puts a binary blob into the blob store and returns the blob reference. */
|
|
838
|
+
async putBlob(data: Buffer, options?: BlobPutOptions): Promise<BlobPutResult> {
|
|
839
|
+
return this.#blobs.put(data, options);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/** Synchronous variant of {@link putBlob} for rebuild-only render paths. */
|
|
843
|
+
putBlobSync(data: Buffer, options?: BlobPutOptions): BlobPutResult {
|
|
844
|
+
return this.#blobs.putSync(data, options);
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
captureState(): SessionManagerStateSnapshot {
|
|
848
|
+
return {
|
|
849
|
+
cwd: this.#cwd,
|
|
850
|
+
sessionDir: this.#sessionDir,
|
|
851
|
+
sessionId: this.#sessionId,
|
|
852
|
+
sessionName: this.#sessionName,
|
|
853
|
+
titleSource: this.#titleSource,
|
|
854
|
+
titleUpdatedAt: this.#titleUpdatedAt,
|
|
855
|
+
hasTitleSlot: this.#hasTitleSlot,
|
|
856
|
+
sessionFile: this.#sessionFile,
|
|
857
|
+
onDisk: this.#fileIsCurrent,
|
|
858
|
+
needsRewrite: this.#rewriteRequired,
|
|
859
|
+
// Snapshot header + entries by reference: switch/reload replaces the
|
|
860
|
+
// active header/array wholesale, so rollback needs no deep clone.
|
|
861
|
+
header: this.#header,
|
|
862
|
+
entries: [...this.#entries],
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
restoreState(snapshot: SessionManagerStateSnapshot): void {
|
|
867
|
+
this.#closeWriterEventually();
|
|
868
|
+
this.#diskTail = Promise.resolve();
|
|
869
|
+
this.#clearDiskError();
|
|
870
|
+
|
|
871
|
+
this.#cwd = snapshot.cwd;
|
|
872
|
+
this.#sessionDir = snapshot.sessionDir;
|
|
873
|
+
this.#sessionFile = snapshot.sessionFile;
|
|
874
|
+
this.#fileIsCurrent = snapshot.onDisk;
|
|
875
|
+
this.#rewriteRequired = snapshot.needsRewrite;
|
|
876
|
+
this.#forceFileCreation = snapshot.onDisk;
|
|
877
|
+
this.#applyEntries(snapshot.header, [...snapshot.entries]);
|
|
878
|
+
this.#sessionName = snapshot.sessionName;
|
|
879
|
+
this.#titleSource = snapshot.titleSource;
|
|
880
|
+
this.#titleUpdatedAt = snapshot.titleUpdatedAt;
|
|
881
|
+
this.#hasTitleSlot = snapshot.hasTitleSlot;
|
|
882
|
+
this.#artifactManager = null;
|
|
883
|
+
this.#artifactManagerSessionFile = null;
|
|
884
|
+
this.#adoptedArtifactManager = null;
|
|
885
|
+
|
|
886
|
+
if (this.#sessionFile) this.#rememberBreadcrumb(this.#cwd, this.#sessionFile);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/** Switch to a different session file (resume / branch). */
|
|
890
|
+
async setSessionFile(sessionFile: string): Promise<void> {
|
|
891
|
+
await this.#drainAndCloseWriter();
|
|
892
|
+
this.#clearDiskError();
|
|
893
|
+
|
|
894
|
+
const resolvedSessionFile = path.resolve(sessionFile);
|
|
895
|
+
this.#sessionFile = resolvedSessionFile;
|
|
896
|
+
this.#rememberBreadcrumb(this.#cwd, resolvedSessionFile);
|
|
897
|
+
|
|
898
|
+
const titleSlot = await readTitleSlotFromFile(resolvedSessionFile, this.#storage);
|
|
899
|
+
const fileEntries = await loadEntriesFromFile(resolvedSessionFile, this.#storage);
|
|
900
|
+
if (fileEntries.length === 0) {
|
|
901
|
+
// Explicit but empty/missing path (e.g. --session flag): start fresh but
|
|
902
|
+
// keep the requested path and materialize the header immediately.
|
|
903
|
+
this.#resetToNewSession(undefined, resolvedSessionFile);
|
|
904
|
+
this.#forceFileCreation = true;
|
|
905
|
+
await this.#rewriteAtomically();
|
|
906
|
+
this.#fileIsCurrent = true;
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
const migrated = migrateToCurrentVersion(fileEntries);
|
|
911
|
+
await resolveBlobRefsInEntries(fileEntries, this.#blobs);
|
|
912
|
+
// loadEntriesFromFile guarantees entries[0] is a valid session header.
|
|
913
|
+
const header = fileEntries[0] as SessionHeader;
|
|
914
|
+
|
|
915
|
+
// Adopt the loaded session's working directory. Sessions live in a dir
|
|
916
|
+
// keyed by their cwd, so resuming a session from another project must
|
|
917
|
+
// re-point cwd/sessionDir at that project — unless that project directory
|
|
918
|
+
// no longer exists on disk, in which case adopting it (and the process
|
|
919
|
+
// chdir interactive mode then performs) would fail with ENOENT. Keep the
|
|
920
|
+
// current cwd so the resumed session stays where the user already is.
|
|
921
|
+
const headerCwd = header.cwd ? path.resolve(header.cwd) : undefined;
|
|
922
|
+
if (headerCwd && headerCwd !== path.resolve(this.#cwd) && (await directoryExists(headerCwd))) {
|
|
923
|
+
this.#cwd = headerCwd;
|
|
924
|
+
this.#sessionDir = path.dirname(resolvedSessionFile);
|
|
925
|
+
this.#rememberBreadcrumb(this.#cwd, resolvedSessionFile);
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
this.#applyEntries(header, fileEntries.slice(1) as SessionEntry[]);
|
|
929
|
+
this.#titleUpdatedAt = titleSlot?.updatedAt ?? header.timestamp;
|
|
930
|
+
this.#hasTitleSlot = titleSlot !== undefined;
|
|
931
|
+
this.#fileIsCurrent = true;
|
|
932
|
+
this.#rewriteRequired = migrated;
|
|
933
|
+
this.#forceFileCreation = true;
|
|
934
|
+
this.#artifactManager = null;
|
|
935
|
+
this.#artifactManagerSessionFile = null;
|
|
936
|
+
|
|
937
|
+
if (this.sanitizeLoadedOpenAIResponsesReplayMetadata()) this.#rewriteRequired = true;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
/** Start a new session. Drains and closes any existing writer first. */
|
|
941
|
+
async newSession(options?: NewSessionOptions): Promise<string | undefined> {
|
|
942
|
+
await this.#drainAndCloseWriter();
|
|
943
|
+
return this.#resetToNewSession(options);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
/** Delete a session file and its artifact directory. ENOENT is treated as success. */
|
|
947
|
+
async dropSession(sessionPath: string): Promise<void> {
|
|
948
|
+
await this.#drainAndCloseWriter();
|
|
949
|
+
try {
|
|
950
|
+
await this.#storage.deleteSessionWithArtifacts(sessionPath);
|
|
951
|
+
} catch (err) {
|
|
952
|
+
if (!isEnoent(err)) throw err;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Fork the current session into a new file with the same entries.
|
|
958
|
+
* @returns the old and new session file paths, or undefined when not persisting.
|
|
959
|
+
*/
|
|
960
|
+
async fork(): Promise<{ oldSessionFile: string; newSessionFile: string } | undefined> {
|
|
961
|
+
if (!this.#persist || !this.#sessionFile) return undefined;
|
|
962
|
+
|
|
963
|
+
const oldSessionFile = this.#sessionFile;
|
|
964
|
+
const parentSessionId = this.#sessionId;
|
|
965
|
+
await this.#drainAndCloseWriter();
|
|
966
|
+
this.#clearDiskError();
|
|
967
|
+
|
|
968
|
+
const timestamp = nowIso();
|
|
969
|
+
this.#sessionId = mintSessionId();
|
|
970
|
+
this.#sessionFile = path.join(this.#sessionDir, `${fileSafeTimestamp(timestamp)}_${this.#sessionId}.jsonl`);
|
|
971
|
+
this.#header = {
|
|
972
|
+
type: "session",
|
|
973
|
+
version: CURRENT_SESSION_VERSION,
|
|
974
|
+
id: this.#sessionId,
|
|
975
|
+
title: this.#header.title ?? this.#sessionName,
|
|
976
|
+
titleSource: this.#header.titleSource ?? this.#titleSource,
|
|
977
|
+
timestamp,
|
|
978
|
+
cwd: this.#cwd,
|
|
979
|
+
parentSession: parentSessionId,
|
|
980
|
+
};
|
|
981
|
+
this.#sessionName = this.#header.title;
|
|
982
|
+
this.#titleSource = this.#header.titleSource;
|
|
983
|
+
this.#titleUpdatedAt = timestamp;
|
|
984
|
+
this.#hasTitleSlot = true;
|
|
985
|
+
this.#fileIsCurrent = false;
|
|
986
|
+
this.#rewriteRequired = false;
|
|
987
|
+
this.#forceFileCreation = true;
|
|
988
|
+
this.#artifactManager = null;
|
|
989
|
+
this.#artifactManagerSessionFile = null;
|
|
990
|
+
this.#rememberBreadcrumb(this.#cwd, this.#sessionFile);
|
|
991
|
+
|
|
992
|
+
await this.#rewriteAtomically();
|
|
993
|
+
return { oldSessionFile, newSessionFile: this.#sessionFile };
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* Move the session to a new working directory: relocate the session file and
|
|
998
|
+
* artifacts on disk, update internal references, and rewrite the header cwd.
|
|
999
|
+
*/
|
|
1000
|
+
async moveTo(newCwd: string, targetSessionDir?: string): Promise<void> {
|
|
1001
|
+
const resolvedCwd = path.resolve(newCwd);
|
|
1002
|
+
const resolvedTargetDir = targetSessionDir ? path.resolve(targetSessionDir) : undefined;
|
|
1003
|
+
if (
|
|
1004
|
+
resolvedCwd === path.resolve(this.#cwd) &&
|
|
1005
|
+
(!resolvedTargetDir || resolvedTargetDir === path.resolve(this.#sessionDir))
|
|
1006
|
+
) {
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
const managedRoot = resolveManagedSessionRoot(this.#sessionDir, this.#cwd);
|
|
1011
|
+
const nextSessionDir =
|
|
1012
|
+
resolvedTargetDir ??
|
|
1013
|
+
(managedRoot
|
|
1014
|
+
? computeDefaultSessionDir(resolvedCwd, this.#storage, managedRoot)
|
|
1015
|
+
: computeDefaultSessionDir(resolvedCwd, this.#storage));
|
|
1016
|
+
|
|
1017
|
+
let sessionFileExisted = false;
|
|
1018
|
+
|
|
1019
|
+
if (this.#persist && this.#sessionFile) {
|
|
1020
|
+
this.#storage.ensureDirSync(nextSessionDir);
|
|
1021
|
+
await this.#drainAndCloseWriter();
|
|
1022
|
+
this.#clearDiskError();
|
|
1023
|
+
|
|
1024
|
+
const oldSessionFile = this.#sessionFile;
|
|
1025
|
+
const newSessionFile = path.join(nextSessionDir, path.basename(oldSessionFile));
|
|
1026
|
+
const oldArtifactsDir = artifactsDirectoryFor(oldSessionFile)!;
|
|
1027
|
+
const newArtifactsDir = artifactsDirectoryFor(newSessionFile)!;
|
|
1028
|
+
const sessionPathChanged = path.resolve(oldSessionFile) !== path.resolve(newSessionFile);
|
|
1029
|
+
const artifactPathChanged = path.resolve(oldArtifactsDir) !== path.resolve(newArtifactsDir);
|
|
1030
|
+
sessionFileExisted = this.#storage.existsSync(oldSessionFile);
|
|
1031
|
+
|
|
1032
|
+
let sessionMoved = false;
|
|
1033
|
+
let artifactsMoved = false;
|
|
1034
|
+
|
|
1035
|
+
try {
|
|
1036
|
+
if (sessionFileExisted && sessionPathChanged) {
|
|
1037
|
+
await fs.promises.rename(oldSessionFile, newSessionFile);
|
|
1038
|
+
sessionMoved = true;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
if (artifactPathChanged) {
|
|
1042
|
+
try {
|
|
1043
|
+
const artifactStat = await fs.promises.stat(oldArtifactsDir);
|
|
1044
|
+
if (artifactStat.isDirectory()) {
|
|
1045
|
+
await fs.promises.rename(oldArtifactsDir, newArtifactsDir);
|
|
1046
|
+
artifactsMoved = true;
|
|
1047
|
+
}
|
|
1048
|
+
} catch (err) {
|
|
1049
|
+
if (!isEnoent(err)) throw err;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
} catch (err) {
|
|
1053
|
+
if (artifactsMoved) {
|
|
1054
|
+
try {
|
|
1055
|
+
await fs.promises.rename(newArtifactsDir, oldArtifactsDir);
|
|
1056
|
+
} catch (rollbackErr) {
|
|
1057
|
+
throw new Error(
|
|
1058
|
+
`Failed to move artifacts and rollback: ${rollbackErr instanceof Error ? rollbackErr.message : String(rollbackErr)}`,
|
|
1059
|
+
);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
if (sessionMoved) {
|
|
1064
|
+
try {
|
|
1065
|
+
await fs.promises.rename(newSessionFile, oldSessionFile);
|
|
1066
|
+
} catch (rollbackErr) {
|
|
1067
|
+
throw new Error(
|
|
1068
|
+
`Failed to move session file and rollback: ${rollbackErr instanceof Error ? rollbackErr.message : String(rollbackErr)}`,
|
|
1069
|
+
);
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
throw err;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
this.#sessionFile = newSessionFile;
|
|
1077
|
+
this.#artifactManager = null;
|
|
1078
|
+
this.#artifactManagerSessionFile = null;
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
this.#cwd = resolvedCwd;
|
|
1082
|
+
this.#sessionDir = nextSessionDir;
|
|
1083
|
+
this.#header.cwd = resolvedCwd;
|
|
1084
|
+
|
|
1085
|
+
// Rewrite at the new location when the file already existed (update cwd) or
|
|
1086
|
+
// there is in-memory output worth materializing; otherwise stay lazy.
|
|
1087
|
+
const hasAssistant = this.#historyContainsAssistantMessage();
|
|
1088
|
+
if (this.#persist && this.#sessionFile && (sessionFileExisted || hasAssistant)) {
|
|
1089
|
+
this.#forceFileCreation = true;
|
|
1090
|
+
await this.#rewriteAtomically();
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
if (this.#sessionFile) this.#rememberBreadcrumb(resolvedCwd, this.#sessionFile);
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* Force the session onto disk even with no assistant message yet (ACP
|
|
1098
|
+
* session/new must create a discoverable file immediately).
|
|
1099
|
+
*/
|
|
1100
|
+
async ensureOnDisk(): Promise<void> {
|
|
1101
|
+
if (!this.#persist || !this.#sessionFile) return;
|
|
1102
|
+
this.#forceFileCreation = true;
|
|
1103
|
+
if (this.#fileIsCurrent && !this.#rewriteRequired) return;
|
|
1104
|
+
await this.#rewriteAtomically();
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
/** Flush pending writes. Call before switching sessions or on shutdown. */
|
|
1108
|
+
async flush(): Promise<void> {
|
|
1109
|
+
if (!this.#persist || !this.#sessionFile) return;
|
|
1110
|
+
await this.#scheduleDiskWork(async () => {
|
|
1111
|
+
if (this.#writer?.isOpen()) await this.#writer.flush();
|
|
1112
|
+
});
|
|
1113
|
+
// Drain any fire-and-forget backing writes (e.g. `writeTextSync` queued
|
|
1114
|
+
// on IndexedSessionStorage during `flushSync`) so callers relying on
|
|
1115
|
+
// flush() see the write durably visible to readers.
|
|
1116
|
+
await this.#storage.drain();
|
|
1117
|
+
if (this.#diskFailure) throw this.#diskFailure;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* Synchronously makes the current append-only session durable. Avoid rewriting
|
|
1122
|
+
* an already-current file: large restored sessions can contain GiB of compacted
|
|
1123
|
+
* history, and Ctrl+C must not rebuild the whole JSONL string just to flush.
|
|
1124
|
+
*/
|
|
1125
|
+
flushSync(): void {
|
|
1126
|
+
if (!this.#persist || !this.#sessionFile) return;
|
|
1127
|
+
if (this.#diskFailure) throw this.#diskFailure;
|
|
1128
|
+
if (this.#fileIsCurrent && !this.#rewriteRequired) {
|
|
1129
|
+
const writerError = this.#writer?.getError();
|
|
1130
|
+
if (writerError) throw writerError;
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
this.#rewriteSynchronously();
|
|
1134
|
+
if (this.#diskFailure) throw this.#diskFailure;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
/** Flush, then close the append writer. */
|
|
1138
|
+
async close(): Promise<void> {
|
|
1139
|
+
if (!this.#persist) return;
|
|
1140
|
+
await this.#scheduleDiskWork(async () => {
|
|
1141
|
+
const hadWriter = this.#writer !== undefined;
|
|
1142
|
+
await this.#closeWriterHandle();
|
|
1143
|
+
if (hadWriter || (this.#sessionFile && this.#storage.existsSync(this.#sessionFile)))
|
|
1144
|
+
this.#fileIsCurrent = true;
|
|
1145
|
+
});
|
|
1146
|
+
// Wait for any queued backing writes (IndexedSessionStorage per-path
|
|
1147
|
+
// tail) to become durable so a graceful shutdown does not exit while
|
|
1148
|
+
// a fire-and-forget publish is still on the wire.
|
|
1149
|
+
await this.#storage.drain();
|
|
1150
|
+
if (this.#diskFailure) throw this.#diskFailure;
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
getCwd(): string {
|
|
1154
|
+
return this.#cwd;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
getUsageStatistics(): UsageStatistics {
|
|
1158
|
+
return this.#index.usageSnapshot();
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* Open a new per-turn budget window: snapshot the cumulative output baseline,
|
|
1163
|
+
* reset the eval-subagent counter, and set the (optional) ceiling.
|
|
1164
|
+
*/
|
|
1165
|
+
beginTurnBudget(total: number | null, hard: boolean): void {
|
|
1166
|
+
this.#turnBudgetTotal = total;
|
|
1167
|
+
this.#turnBudgetHard = hard;
|
|
1168
|
+
this.#turnOutputBaseline = this.#index.usageSnapshot().output;
|
|
1169
|
+
this.#turnEvalOutput = 0;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
recordEvalSubagentOutput(output: number): void {
|
|
1173
|
+
if (Number.isFinite(output) && output > 0) this.#turnEvalOutput += output;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
getTurnBudget(): { total: number | null; spent: number; hard: boolean } {
|
|
1177
|
+
const mainOutput = Math.max(0, this.#index.usageSnapshot().output - this.#turnOutputBaseline);
|
|
1178
|
+
return { total: this.#turnBudgetTotal, spent: mainOutput + this.#turnEvalOutput, hard: this.#turnBudgetHard };
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
getSessionDir(): string {
|
|
1182
|
+
return this.#sessionDir;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
getSessionId(): string {
|
|
1186
|
+
return this.#sessionId;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
getSessionFile(): string | undefined {
|
|
1190
|
+
return this.#sessionFile;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
getArtifactsDir(): string | null {
|
|
1194
|
+
if (this.#adoptedArtifactManager) return this.#adoptedArtifactManager.dir;
|
|
1195
|
+
return artifactsDirectoryFor(this.#sessionFile);
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
adoptArtifactManager(manager: ArtifactManager): void {
|
|
1199
|
+
this.#adoptedArtifactManager = manager;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
getArtifactManager(): ArtifactManager | null {
|
|
1203
|
+
return this.#artifactManagerForSession();
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
async allocateArtifactPath(toolType: string): Promise<{ id?: string; path?: string }> {
|
|
1207
|
+
return (await this.#artifactManagerForSession()?.allocatePath(toolType)) ?? {};
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
async saveArtifact(content: string, toolType: string): Promise<string | undefined> {
|
|
1211
|
+
const manager = this.#artifactManagerForSession();
|
|
1212
|
+
if (manager) return manager.save(content, toolType);
|
|
1213
|
+
|
|
1214
|
+
// Non-persistent session: keep an in-memory copy so spill truncation works.
|
|
1215
|
+
this.#inMemoryArtifacts ??= new Map();
|
|
1216
|
+
const id = String(this.#inMemoryArtifactCounter++);
|
|
1217
|
+
this.#inMemoryArtifacts.set(id, content);
|
|
1218
|
+
return id;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
async getArtifactPath(id: string): Promise<string | null> {
|
|
1222
|
+
return (await this.#artifactManagerForSession()?.getPath(id)) ?? null;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
async saveDraft(text: string): Promise<void> {
|
|
1226
|
+
const draftPath = this.#draftPath();
|
|
1227
|
+
if (!draftPath || !this.#persist) return;
|
|
1228
|
+
|
|
1229
|
+
if (text.length === 0) {
|
|
1230
|
+
try {
|
|
1231
|
+
await this.#storage.unlink(draftPath);
|
|
1232
|
+
} catch (err) {
|
|
1233
|
+
if (!isEnoent(err)) throw err;
|
|
1234
|
+
}
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
// Force the header onto disk so resume can find the file this draft attaches to.
|
|
1239
|
+
await this.ensureOnDisk();
|
|
1240
|
+
await this.#storage.writeText(draftPath, text);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
async consumeDraft(): Promise<string | null> {
|
|
1244
|
+
const draftPath = this.#draftPath();
|
|
1245
|
+
if (!draftPath) return null;
|
|
1246
|
+
|
|
1247
|
+
let draft: string;
|
|
1248
|
+
try {
|
|
1249
|
+
draft = await this.#storage.readText(draftPath);
|
|
1250
|
+
} catch (err) {
|
|
1251
|
+
if (isEnoent(err)) return null;
|
|
1252
|
+
throw err;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
try {
|
|
1256
|
+
await this.#storage.unlink(draftPath);
|
|
1257
|
+
} catch (err) {
|
|
1258
|
+
if (!isEnoent(err)) throw err;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
return draft;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
/** The source that set the session name: "user" (manual/RPC) or "auto" (generated title). */
|
|
1265
|
+
get titleSource(): SessionTitleSource | undefined {
|
|
1266
|
+
return this.#titleSource;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
getSessionName(): string | undefined {
|
|
1270
|
+
return this.#sessionName;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
onSessionNameChanged(cb: () => void): () => void {
|
|
1274
|
+
this.#sessionNameChangedCallbacks.add(cb);
|
|
1275
|
+
return () => {
|
|
1276
|
+
this.#sessionNameChangedCallbacks.delete(cb);
|
|
1277
|
+
};
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
/**
|
|
1281
|
+
* Set the session display name.
|
|
1282
|
+
* @param source "user" for explicit renames; "auto" for generated titles.
|
|
1283
|
+
* Auto titles are ignored once the user has set a name.
|
|
1284
|
+
*/
|
|
1285
|
+
async setSessionName(name: string, source: SessionTitleSource = "auto", trigger?: string): Promise<boolean> {
|
|
1286
|
+
if (this.#titleSource === "user" && source === "auto") return false;
|
|
1287
|
+
|
|
1288
|
+
const title = SessionManager.#cleanTitle(name);
|
|
1289
|
+
if (!title) return false;
|
|
1290
|
+
|
|
1291
|
+
const previousTitle = this.#sessionName;
|
|
1292
|
+
const timestamp = nowIso();
|
|
1293
|
+
this.#sessionName = title;
|
|
1294
|
+
this.#titleSource = source;
|
|
1295
|
+
this.#titleUpdatedAt = timestamp;
|
|
1296
|
+
this.#header.title = title;
|
|
1297
|
+
this.#header.titleSource = source;
|
|
1298
|
+
|
|
1299
|
+
const entry: TitleChangeEntry = {
|
|
1300
|
+
type: TITLE_CHANGE_ENTRY_TYPE,
|
|
1301
|
+
...this.#freshEntryFields(),
|
|
1302
|
+
timestamp,
|
|
1303
|
+
title,
|
|
1304
|
+
source,
|
|
1305
|
+
};
|
|
1306
|
+
if (previousTitle) entry.previousTitle = previousTitle;
|
|
1307
|
+
if (trigger) entry.trigger = trigger;
|
|
1308
|
+
this.#entries.push(entry);
|
|
1309
|
+
this.#index.insert(entry);
|
|
1310
|
+
this.#notifyEntryAppended(entry);
|
|
1311
|
+
await this.#persistTitleChangeEntry(entry, { title, source, updatedAt: timestamp });
|
|
1312
|
+
|
|
1313
|
+
this.#notifySessionNameListeners();
|
|
1314
|
+
return true;
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* Append a foreign (host-authored) entry verbatim, preserving its
|
|
1319
|
+
* `id`/`parentId`. Used by collab guests to mirror the host session.
|
|
1320
|
+
*/
|
|
1321
|
+
ingestReplicatedEntry(entry: SessionEntry): void {
|
|
1322
|
+
this.#recordEntry(entry);
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
/**
|
|
1326
|
+
* Snapshot the session for collab replication: the live header plus a deep
|
|
1327
|
+
* copy of every entry (the host mutates entries in place on rewrite paths, so
|
|
1328
|
+
* guests must not share references).
|
|
1329
|
+
*/
|
|
1330
|
+
snapshotForReplication(): { header: SessionHeader; entries: SessionEntry[] } {
|
|
1331
|
+
return { header: structuredClone(this.#header), entries: structuredClone(this.#entries) as SessionEntry[] };
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* Append a message as a child of the current leaf, then advance the leaf.
|
|
1336
|
+
* CompactionSummaryMessage / BranchSummaryMessage are rejected here — they are
|
|
1337
|
+
* top-level entries via appendCompaction()/branchWithSummary().
|
|
1338
|
+
*/
|
|
1339
|
+
appendMessage(
|
|
1340
|
+
message:
|
|
1341
|
+
| Message
|
|
1342
|
+
| CustomMessage
|
|
1343
|
+
| HookMessage
|
|
1344
|
+
| BashExecutionMessage
|
|
1345
|
+
| PythonExecutionMessage
|
|
1346
|
+
| FileMentionMessage,
|
|
1347
|
+
): string {
|
|
1348
|
+
const entry: SessionMessageEntry = { type: "message", ...this.#freshEntryFields(), message };
|
|
1349
|
+
this.#recordEntry(entry);
|
|
1350
|
+
return entry.id;
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
/** Append a thinking level change as child of current leaf, then advance leaf. Returns entry id. */
|
|
1354
|
+
appendThinkingLevelChange(thinkingLevel?: string, configured?: string): string {
|
|
1355
|
+
const entry: ThinkingLevelChangeEntry = {
|
|
1356
|
+
type: "thinking_level_change",
|
|
1357
|
+
...this.#freshEntryFields(),
|
|
1358
|
+
thinkingLevel: thinkingLevel ?? null,
|
|
1359
|
+
configured: configured ?? null,
|
|
1360
|
+
};
|
|
1361
|
+
this.#recordEntry(entry);
|
|
1362
|
+
return entry.id;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
appendServiceTierChange(serviceTier: ServiceTierByFamily | null): string {
|
|
1366
|
+
const entry: ServiceTierChangeEntry = { type: "service_tier_change", ...this.#freshEntryFields(), serviceTier };
|
|
1367
|
+
this.#recordEntry(entry);
|
|
1368
|
+
return entry.id;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
appendModeChange(mode: string, data?: Record<string, unknown>): string {
|
|
1372
|
+
const entry: ModeChangeEntry = { type: "mode_change", ...this.#freshEntryFields(), mode, data };
|
|
1373
|
+
this.#recordEntry(entry);
|
|
1374
|
+
return entry.id;
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
/**
|
|
1378
|
+
* Append a model change as a child of the current leaf, then advance the leaf.
|
|
1379
|
+
* @param model Model in "provider/modelId" format
|
|
1380
|
+
* @param role Optional role (default: "default")
|
|
1381
|
+
*/
|
|
1382
|
+
appendModelChange(model: string, role?: string): string {
|
|
1383
|
+
const entry: ModelChangeEntry = { type: "model_change", ...this.#freshEntryFields(), model, role };
|
|
1384
|
+
this.#recordEntry(entry);
|
|
1385
|
+
return entry.id;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
appendSessionInit(init: {
|
|
1389
|
+
systemPrompt: string;
|
|
1390
|
+
task: string;
|
|
1391
|
+
tools: string[];
|
|
1392
|
+
outputSchema?: unknown;
|
|
1393
|
+
spawns?: string;
|
|
1394
|
+
readSummarize?: boolean;
|
|
1395
|
+
}): string {
|
|
1396
|
+
const entry: SessionInitEntry = { type: "session_init", ...this.#freshEntryFields(), ...init };
|
|
1397
|
+
this.#recordEntry(entry);
|
|
1398
|
+
return entry.id;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
appendCompaction<T = unknown>(
|
|
1402
|
+
summary: string,
|
|
1403
|
+
shortSummary: string | undefined,
|
|
1404
|
+
firstKeptEntryId: string,
|
|
1405
|
+
tokensBefore: number,
|
|
1406
|
+
details?: T,
|
|
1407
|
+
fromExtension?: boolean,
|
|
1408
|
+
preserveData?: Record<string, unknown>,
|
|
1409
|
+
): string {
|
|
1410
|
+
const elidedSupersededCompactions = this.#elideSupersededCompactionsOnBranch(this.#index.leafId());
|
|
1411
|
+
const entry: CompactionEntry<T> = {
|
|
1412
|
+
type: "compaction",
|
|
1413
|
+
...this.#freshEntryFields(),
|
|
1414
|
+
summary,
|
|
1415
|
+
shortSummary,
|
|
1416
|
+
firstKeptEntryId,
|
|
1417
|
+
tokensBefore,
|
|
1418
|
+
details,
|
|
1419
|
+
fromExtension,
|
|
1420
|
+
preserveData,
|
|
1421
|
+
};
|
|
1422
|
+
this.#recordEntry(entry);
|
|
1423
|
+
if (elidedSupersededCompactions) {
|
|
1424
|
+
void this.#rewriteAtomically().catch(err => this.#noteDiskFailure(err));
|
|
1425
|
+
}
|
|
1426
|
+
return entry.id;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
appendCustomEntry(customType: string, data?: unknown): string {
|
|
1430
|
+
const entry: CustomEntry = { type: "custom", customType, data, ...this.#freshEntryFields() };
|
|
1431
|
+
this.#recordEntry(entry);
|
|
1432
|
+
return entry.id;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* Rewrite the session file after in-place entry updates (e.g. pruning old tool
|
|
1437
|
+
* outputs). Use sparingly.
|
|
1438
|
+
*/
|
|
1439
|
+
async rewriteEntries(): Promise<void> {
|
|
1440
|
+
if (!this.#persist || !this.#sessionFile) return;
|
|
1441
|
+
await this.#rewriteAtomically();
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
/**
|
|
1445
|
+
* Append a custom message entry (for extensions) that participates in LLM context.
|
|
1446
|
+
* @param customType Hook identifier for filtering on reload
|
|
1447
|
+
* @param content Message content (string or TextContent/ImageContent array)
|
|
1448
|
+
* @param display Whether to show in TUI (true = styled display, false = hidden)
|
|
1449
|
+
* @param details Optional extension-specific metadata (not sent to LLM)
|
|
1450
|
+
* @param attribution Who initiated this message for billing/attribution semantics
|
|
1451
|
+
*/
|
|
1452
|
+
appendCustomMessageEntry<T = unknown>(
|
|
1453
|
+
customType: string,
|
|
1454
|
+
content: string | (TextContent | ImageContent)[],
|
|
1455
|
+
display: boolean,
|
|
1456
|
+
details?: T,
|
|
1457
|
+
attribution: MessageAttribution = "agent",
|
|
1458
|
+
): string {
|
|
1459
|
+
const entry: CustomMessageEntry<T> = {
|
|
1460
|
+
type: "custom_message",
|
|
1461
|
+
customType,
|
|
1462
|
+
content,
|
|
1463
|
+
display,
|
|
1464
|
+
// Drop AgentSession-internal transient fields before disk persistence.
|
|
1465
|
+
details: stripInternalDetailsFields(details),
|
|
1466
|
+
attribution,
|
|
1467
|
+
...this.#freshEntryFields(),
|
|
1468
|
+
};
|
|
1469
|
+
this.#recordEntry(entry);
|
|
1470
|
+
return entry.id;
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
/**
|
|
1474
|
+
* Append an MCP tool selection entry recording the discovery-selected MCP tools.
|
|
1475
|
+
*/
|
|
1476
|
+
appendMCPToolSelection(selectedToolNames: string[]): string {
|
|
1477
|
+
const entry: MCPToolSelectionEntry = {
|
|
1478
|
+
type: "mcp_tool_selection",
|
|
1479
|
+
...this.#freshEntryFields(),
|
|
1480
|
+
selectedToolNames: [...selectedToolNames],
|
|
1481
|
+
};
|
|
1482
|
+
this.#recordEntry(entry);
|
|
1483
|
+
return entry.id;
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
/** Append a TTSR injection entry recording which rules were injected. */
|
|
1487
|
+
appendTtsrInjection(ruleNames: string[]): string {
|
|
1488
|
+
const entry: TtsrInjectionEntry = {
|
|
1489
|
+
type: "ttsr_injection",
|
|
1490
|
+
...this.#freshEntryFields(),
|
|
1491
|
+
injectedRules: [...ruleNames],
|
|
1492
|
+
};
|
|
1493
|
+
this.#recordEntry(entry);
|
|
1494
|
+
return entry.id;
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
/** All unique TTSR rule names injected on the current branch (root → leaf). */
|
|
1498
|
+
getInjectedTtsrRules(): string[] {
|
|
1499
|
+
const names = new Set<string>();
|
|
1500
|
+
for (const entry of this.getBranch()) {
|
|
1501
|
+
if (entry.type !== "ttsr_injection") continue;
|
|
1502
|
+
for (const name of entry.injectedRules) names.add(name);
|
|
1503
|
+
}
|
|
1504
|
+
return [...names];
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
getLeafId(): string | null {
|
|
1508
|
+
return this.#index.leafId();
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
getLeafEntry(): SessionEntry | undefined {
|
|
1512
|
+
return this.#index.leafEntry();
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
/**
|
|
1516
|
+
* The most recent model role on the current branch, or undefined when no
|
|
1517
|
+
* model change has been recorded.
|
|
1518
|
+
*/
|
|
1519
|
+
getLastModelChangeRole(): string | undefined {
|
|
1520
|
+
const branch = this.getBranch();
|
|
1521
|
+
for (let index = branch.length - 1; index >= 0; index--) {
|
|
1522
|
+
const entry = branch[index];
|
|
1523
|
+
if (entry.type === "model_change") return entry.role ?? "default";
|
|
1524
|
+
}
|
|
1525
|
+
return undefined;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
getEntry(id: string): SessionEntry | undefined {
|
|
1529
|
+
return this.#index.get(id);
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
/** All direct children of an entry. */
|
|
1533
|
+
getChildren(parentId: string): SessionEntry[] {
|
|
1534
|
+
return this.#index.childrenOf(parentId);
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
getLabel(id: string): string | undefined {
|
|
1538
|
+
return this.#index.labelFor(id);
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
/**
|
|
1542
|
+
* Set or clear a label on an entry. Pass undefined/empty to clear.
|
|
1543
|
+
*/
|
|
1544
|
+
appendLabelChange(targetId: string, label: string | undefined): string {
|
|
1545
|
+
if (!this.#index.has(targetId)) throw new Error(`Entry ${targetId} not found`);
|
|
1546
|
+
|
|
1547
|
+
const entry: LabelEntry = { type: "label", ...this.#freshEntryFields(), targetId, label };
|
|
1548
|
+
this.#recordEntry(entry);
|
|
1549
|
+
return entry.id;
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
/**
|
|
1553
|
+
* Walk from an entry to root, returning entries in path order. Includes all
|
|
1554
|
+
* entry types; use buildSessionContext() for the resolved LLM messages.
|
|
1555
|
+
*/
|
|
1556
|
+
getBranch(fromId?: string): SessionEntry[] {
|
|
1557
|
+
return this.#index.pathTo(fromId ?? this.#index.leafId());
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* Build the session context (LLM messages), or — with `{ transcript: true }` —
|
|
1562
|
+
* the full-history display transcript, from the current leaf path.
|
|
1563
|
+
*/
|
|
1564
|
+
buildSessionContext(options?: BuildSessionContextOptions): SessionContext {
|
|
1565
|
+
return buildSessionContext(this.#entries, this.#index.leafId(), this.#index.entriesById(), options);
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
/** Strip stale OpenAI Responses assistant replay metadata from loaded entries. */
|
|
1569
|
+
sanitizeLoadedOpenAIResponsesReplayMetadata(): boolean {
|
|
1570
|
+
let changed = false;
|
|
1571
|
+
for (const entry of this.#entries) {
|
|
1572
|
+
if (entry.type !== "message" || entry.message.role !== "assistant") continue;
|
|
1573
|
+
|
|
1574
|
+
const sanitized = sanitizeRehydratedOpenAIResponsesAssistantMessage(entry.message);
|
|
1575
|
+
if (sanitized === entry.message) continue;
|
|
1576
|
+
|
|
1577
|
+
entry.message = sanitized;
|
|
1578
|
+
changed = true;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
return changed;
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
getHeader(): SessionHeader | null {
|
|
1585
|
+
return this.#header;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
/** All session entries (excludes header). Returns a shallow copy. */
|
|
1589
|
+
getEntries(): SessionEntry[] {
|
|
1590
|
+
return [...this.#entries];
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
/**
|
|
1594
|
+
* The session as a tree. A well-formed session has exactly one root; orphaned
|
|
1595
|
+
* entries (broken parent chain) are returned as roots too.
|
|
1596
|
+
*/
|
|
1597
|
+
getTree(): SessionTreeNode[] {
|
|
1598
|
+
return this.#index.tree(this.#entries);
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
/**
|
|
1602
|
+
* Move the leaf to an earlier entry so the next append forms a new branch.
|
|
1603
|
+
* Existing entries are never modified or deleted.
|
|
1604
|
+
*/
|
|
1605
|
+
branch(branchFromId: string): void {
|
|
1606
|
+
if (!this.#index.has(branchFromId)) throw new Error(`Entry ${branchFromId} not found`);
|
|
1607
|
+
this.#index.setLeaf(branchFromId);
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
/** Reset the leaf to null so the next append creates a new root entry. */
|
|
1611
|
+
resetLeaf(): void {
|
|
1612
|
+
this.#index.setLeaf(null);
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
/** Like branch(), but also records a branch_summary of the abandoned path. */
|
|
1616
|
+
branchWithSummary(branchFromId: string | null, summary: string, details?: unknown, fromExtension?: boolean): string {
|
|
1617
|
+
if (branchFromId !== null && !this.#index.has(branchFromId)) throw new Error(`Entry ${branchFromId} not found`);
|
|
1618
|
+
|
|
1619
|
+
this.#index.setLeaf(branchFromId);
|
|
1620
|
+
const entry: BranchSummaryEntry = {
|
|
1621
|
+
type: "branch_summary",
|
|
1622
|
+
id: generateId(this.#index),
|
|
1623
|
+
parentId: branchFromId,
|
|
1624
|
+
timestamp: nowIso(),
|
|
1625
|
+
fromId: branchFromId ?? "root",
|
|
1626
|
+
summary,
|
|
1627
|
+
details,
|
|
1628
|
+
fromExtension,
|
|
1629
|
+
};
|
|
1630
|
+
this.#recordEntry(entry);
|
|
1631
|
+
return entry.id;
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
/**
|
|
1635
|
+
* Create a new session file containing only the path from root to `leafId`.
|
|
1636
|
+
* Returns the new file path, or undefined when not persisting.
|
|
1637
|
+
*/
|
|
1638
|
+
createBranchedSession(leafId: string): string | undefined {
|
|
1639
|
+
const sourceSessionFile = this.#sessionFile;
|
|
1640
|
+
const branchPath = this.getBranch(leafId);
|
|
1641
|
+
if (branchPath.length === 0) throw new Error(`Entry ${leafId} not found`);
|
|
1642
|
+
|
|
1643
|
+
// Drop label entries from the path; recreate them fresh from the resolved map.
|
|
1644
|
+
const entriesToKeep = branchPath.filter(entry => entry.type !== "label");
|
|
1645
|
+
const keptIds = new Set(entriesToKeep.map(entry => entry.id));
|
|
1646
|
+
const labelsToCarry: Array<{ targetId: string; label: string }> = [];
|
|
1647
|
+
for (const [targetId, label] of this.#index.labelsInEffect()) {
|
|
1648
|
+
if (keptIds.has(targetId)) labelsToCarry.push({ targetId, label });
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
const timestamp = nowIso();
|
|
1652
|
+
const newSessionId = mintSessionId();
|
|
1653
|
+
const newSessionFile = path.join(this.#sessionDir, `${fileSafeTimestamp(timestamp)}_${newSessionId}.jsonl`);
|
|
1654
|
+
const header: SessionHeader = {
|
|
1655
|
+
type: "session",
|
|
1656
|
+
version: CURRENT_SESSION_VERSION,
|
|
1657
|
+
id: newSessionId,
|
|
1658
|
+
timestamp,
|
|
1659
|
+
cwd: this.#cwd,
|
|
1660
|
+
parentSession: this.#persist ? sourceSessionFile : undefined,
|
|
1661
|
+
};
|
|
1662
|
+
|
|
1663
|
+
const labels: LabelEntry[] = [];
|
|
1664
|
+
let parentId = entriesToKeep[entriesToKeep.length - 1]?.id ?? null;
|
|
1665
|
+
for (const carried of labelsToCarry) {
|
|
1666
|
+
const labelEntry: LabelEntry = {
|
|
1667
|
+
type: "label",
|
|
1668
|
+
id: generateId(new Set([...keptIds, ...labels.map(entry => entry.id)])),
|
|
1669
|
+
parentId,
|
|
1670
|
+
timestamp: nowIso(),
|
|
1671
|
+
targetId: carried.targetId,
|
|
1672
|
+
label: carried.label,
|
|
1673
|
+
};
|
|
1674
|
+
labels.push(labelEntry);
|
|
1675
|
+
parentId = labelEntry.id;
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
this.#header = header;
|
|
1679
|
+
this.#entries = [...entriesToKeep, ...labels];
|
|
1680
|
+
this.#sessionId = newSessionId;
|
|
1681
|
+
this.#sessionName = header.title;
|
|
1682
|
+
this.#titleSource = header.titleSource;
|
|
1683
|
+
this.#titleUpdatedAt = timestamp;
|
|
1684
|
+
this.#hasTitleSlot = true;
|
|
1685
|
+
this.#index.rebuild(this.#entries);
|
|
1686
|
+
this.#artifactManager = null;
|
|
1687
|
+
this.#artifactManagerSessionFile = null;
|
|
1688
|
+
this.#forceFileCreation = this.#persist;
|
|
1689
|
+
|
|
1690
|
+
if (!this.#persist) {
|
|
1691
|
+
this.#sessionFile = undefined;
|
|
1692
|
+
this.#fileIsCurrent = false;
|
|
1693
|
+
this.#rewriteRequired = false;
|
|
1694
|
+
return undefined;
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
this.#sessionFile = newSessionFile;
|
|
1698
|
+
this.#rewriteSynchronously();
|
|
1699
|
+
this.#rememberBreadcrumb(this.#cwd, newSessionFile);
|
|
1700
|
+
return newSessionFile;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
/** Resolve the canonical default session directory for a cwd. */
|
|
1704
|
+
static getDefaultSessionDir(
|
|
1705
|
+
cwd: string,
|
|
1706
|
+
agentDir?: string,
|
|
1707
|
+
storage: SessionStorage = new FileSessionStorage(),
|
|
1708
|
+
): string {
|
|
1709
|
+
return computeDefaultSessionDir(cwd, storage, getSessionsDir(agentDir));
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
/**
|
|
1713
|
+
* Create a new session.
|
|
1714
|
+
* @param cwd Working directory (stored in the session header)
|
|
1715
|
+
* @param sessionDir Optional session directory; defaults to the cwd-derived dir.
|
|
1716
|
+
*/
|
|
1717
|
+
static create(cwd: string, sessionDir?: string, storage: SessionStorage = new FileSessionStorage()): SessionManager {
|
|
1718
|
+
const dir = sessionDir ?? SessionManager.getDefaultSessionDir(cwd, undefined, storage);
|
|
1719
|
+
const manager = new SessionManager(cwd, dir, true, storage);
|
|
1720
|
+
manager.#resetToNewSession();
|
|
1721
|
+
return manager;
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
/**
|
|
1725
|
+
* Create a fresh empty session file in the default session directory for
|
|
1726
|
+
* `cwd`, writing only the session header. The returned path can be passed to
|
|
1727
|
+
* `setSessionFile` / `AgentSession.switchSession` when a caller explicitly
|
|
1728
|
+
* needs a brand-new persisted session at a cwd-derived path.
|
|
1729
|
+
*/
|
|
1730
|
+
static createEmptySessionFile(cwd: string, storage: SessionStorage = new FileSessionStorage()): string {
|
|
1731
|
+
const sessionDir = SessionManager.getDefaultSessionDir(cwd, undefined, storage);
|
|
1732
|
+
const id = mintSessionId();
|
|
1733
|
+
const timestamp = nowIso();
|
|
1734
|
+
const header: SessionHeader = {
|
|
1735
|
+
type: "session",
|
|
1736
|
+
version: CURRENT_SESSION_VERSION,
|
|
1737
|
+
id,
|
|
1738
|
+
timestamp,
|
|
1739
|
+
cwd: path.resolve(cwd),
|
|
1740
|
+
};
|
|
1741
|
+
const file = path.join(sessionDir, `${fileSafeTimestamp(timestamp)}_${id}.jsonl`);
|
|
1742
|
+
storage.writeTextSync(file, `${serializeTitleSlot({ updatedAt: timestamp })}${JSON.stringify(header)}\n`);
|
|
1743
|
+
return file;
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
/**
|
|
1747
|
+
* Fork a session into the current project directory: copy history from another
|
|
1748
|
+
* session file while creating a fresh session file in this sessionDir.
|
|
1749
|
+
*
|
|
1750
|
+
* `options.sessionFile` pins the new session's file path (default: an
|
|
1751
|
+
* auto-named `<timestamp>_<id>.jsonl` in `sessionDir`). Callers that register
|
|
1752
|
+
* the fork as a named agent (e.g. `/tan`) pass `<agentId>.jsonl` so the
|
|
1753
|
+
* persisted-subagent scan keys the agent by the same id the live ref uses.
|
|
1754
|
+
*/
|
|
1755
|
+
static async forkFrom(
|
|
1756
|
+
sourcePath: string,
|
|
1757
|
+
cwd: string,
|
|
1758
|
+
sessionDir?: string,
|
|
1759
|
+
storage: SessionStorage = new FileSessionStorage(),
|
|
1760
|
+
options?: { suppressBreadcrumb?: boolean; sessionFile?: string },
|
|
1761
|
+
): Promise<SessionManager> {
|
|
1762
|
+
const dir = sessionDir ?? SessionManager.getDefaultSessionDir(cwd, undefined, storage);
|
|
1763
|
+
const manager = new SessionManager(cwd, dir, true, storage);
|
|
1764
|
+
manager.#suppressBreadcrumb = options?.suppressBreadcrumb === true;
|
|
1765
|
+
|
|
1766
|
+
const sourceEntries = structuredClone(await loadEntriesFromFile(sourcePath, storage)) as FileEntry[];
|
|
1767
|
+
migrateToCurrentVersion(sourceEntries);
|
|
1768
|
+
await resolveBlobRefsInEntries(sourceEntries, manager.#blobs);
|
|
1769
|
+
|
|
1770
|
+
const sourceHeader = sourceEntries.find(entry => entry.type === "session") as SessionHeader | undefined;
|
|
1771
|
+
const history = sourceEntries.filter(entry => entry.type !== "session") as SessionEntry[];
|
|
1772
|
+
manager.#resetToNewSession({ parentSession: sourceHeader?.id }, options?.sessionFile);
|
|
1773
|
+
manager.#header.title = sourceHeader?.title;
|
|
1774
|
+
manager.#header.titleSource = sourceHeader?.titleSource;
|
|
1775
|
+
manager.#sessionName = manager.#header.title;
|
|
1776
|
+
manager.#titleSource = manager.#header.titleSource;
|
|
1777
|
+
manager.#titleUpdatedAt = nowIso();
|
|
1778
|
+
manager.#hasTitleSlot = true;
|
|
1779
|
+
manager.#entries = history;
|
|
1780
|
+
manager.#index.rebuild(history);
|
|
1781
|
+
manager.sanitizeLoadedOpenAIResponsesReplayMetadata();
|
|
1782
|
+
manager.#forceFileCreation = true;
|
|
1783
|
+
await manager.#rewriteAtomically();
|
|
1784
|
+
return manager;
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
/**
|
|
1788
|
+
* Open a specific session file.
|
|
1789
|
+
* @param sessionDir Optional dir for /new or /branch; defaults to the file's parent.
|
|
1790
|
+
* @param options.initialCwd Cwd to use when the file is empty or missing.
|
|
1791
|
+
*/
|
|
1792
|
+
static async open(
|
|
1793
|
+
filePath: string,
|
|
1794
|
+
sessionDir?: string,
|
|
1795
|
+
storage: SessionStorage = new FileSessionStorage(),
|
|
1796
|
+
options?: { initialCwd?: string; suppressBreadcrumb?: boolean },
|
|
1797
|
+
): Promise<SessionManager> {
|
|
1798
|
+
const loaded = await loadEntriesFromFile(filePath, storage);
|
|
1799
|
+
const header = loaded.find(entry => entry.type === "session") as SessionHeader | undefined;
|
|
1800
|
+
// Resume into the session's recorded cwd only when that directory still
|
|
1801
|
+
// exists. A deleted project dir would make the constructor's #cwd — and the
|
|
1802
|
+
// `setProjectDir` chdir interactive mode runs next — point at (and fail on)
|
|
1803
|
+
// a missing path, so fall back to the launch cwd and anchor /new and /branch
|
|
1804
|
+
// there too, keeping the resumed session where the user already is.
|
|
1805
|
+
const recordedCwd = header?.cwd;
|
|
1806
|
+
const recordedCwdUsable = !!recordedCwd && (await directoryExists(recordedCwd));
|
|
1807
|
+
const cwd = recordedCwdUsable ? recordedCwd : (options?.initialCwd ?? getProjectDir());
|
|
1808
|
+
const dir =
|
|
1809
|
+
sessionDir ??
|
|
1810
|
+
(recordedCwd && !recordedCwdUsable
|
|
1811
|
+
? SessionManager.getDefaultSessionDir(cwd, undefined, storage)
|
|
1812
|
+
: path.dirname(path.resolve(filePath)));
|
|
1813
|
+
const manager = new SessionManager(cwd, dir, true, storage);
|
|
1814
|
+
manager.#suppressBreadcrumb = options?.suppressBreadcrumb === true;
|
|
1815
|
+
await manager.setSessionFile(filePath);
|
|
1816
|
+
return manager;
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
/**
|
|
1820
|
+
* Lock-free peek for cold subagent revival: returns the recorded working
|
|
1821
|
+
* directory (session header) and the latest `session_init` contract (system
|
|
1822
|
+
* prompt / tools / output schema) WITHOUT taking the single-writer lock that
|
|
1823
|
+
* {@link open} acquires — the caller re-opens for the actual revive. Returns
|
|
1824
|
+
* null when the file can't be read; `init` is null for files written before
|
|
1825
|
+
* `session_init` was recorded (no faithful contract to rebuild from).
|
|
1826
|
+
*/
|
|
1827
|
+
static async peekSessionInit(
|
|
1828
|
+
filePath: string,
|
|
1829
|
+
storage: SessionStorage = new FileSessionStorage(),
|
|
1830
|
+
): Promise<{
|
|
1831
|
+
cwd: string;
|
|
1832
|
+
init: {
|
|
1833
|
+
systemPrompt: string;
|
|
1834
|
+
task: string;
|
|
1835
|
+
tools: string[];
|
|
1836
|
+
outputSchema?: unknown;
|
|
1837
|
+
spawns?: string;
|
|
1838
|
+
readSummarize?: boolean;
|
|
1839
|
+
} | null;
|
|
1840
|
+
} | null> {
|
|
1841
|
+
let loaded: FileEntry[];
|
|
1842
|
+
try {
|
|
1843
|
+
loaded = await loadEntriesFromFile(filePath, storage);
|
|
1844
|
+
} catch {
|
|
1845
|
+
return null;
|
|
1846
|
+
}
|
|
1847
|
+
// A missing/empty file has no usable session — nothing to revive from.
|
|
1848
|
+
if (loaded.length === 0) return null;
|
|
1849
|
+
const header = loaded.find(entry => entry.type === "session") as SessionHeader | undefined;
|
|
1850
|
+
let init: {
|
|
1851
|
+
systemPrompt: string;
|
|
1852
|
+
task: string;
|
|
1853
|
+
tools: string[];
|
|
1854
|
+
outputSchema?: unknown;
|
|
1855
|
+
spawns?: string;
|
|
1856
|
+
readSummarize?: boolean;
|
|
1857
|
+
} | null = null;
|
|
1858
|
+
for (let index = loaded.length - 1; index >= 0; index--) {
|
|
1859
|
+
const entry = loaded[index];
|
|
1860
|
+
if (entry.type === "session_init") {
|
|
1861
|
+
init = {
|
|
1862
|
+
systemPrompt: entry.systemPrompt,
|
|
1863
|
+
task: entry.task,
|
|
1864
|
+
tools: entry.tools,
|
|
1865
|
+
outputSchema: entry.outputSchema,
|
|
1866
|
+
readSummarize: entry.readSummarize,
|
|
1867
|
+
spawns: entry.spawns,
|
|
1868
|
+
};
|
|
1869
|
+
break;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
return { cwd: header?.cwd ?? getProjectDir(), init };
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
/** Continue the most recent session, or create a new one if none exists. */
|
|
1876
|
+
static async continueRecent(
|
|
1877
|
+
cwd: string,
|
|
1878
|
+
sessionDir?: string,
|
|
1879
|
+
storage: SessionStorage = new FileSessionStorage(),
|
|
1880
|
+
): Promise<SessionManager> {
|
|
1881
|
+
const dir = sessionDir ?? SessionManager.getDefaultSessionDir(cwd, undefined, storage);
|
|
1882
|
+
const resolvedCwd = path.resolve(cwd);
|
|
1883
|
+
const breadcrumb = await readTerminalBreadcrumbEntry();
|
|
1884
|
+
let chosenSession: string | null | undefined;
|
|
1885
|
+
|
|
1886
|
+
if (breadcrumb) {
|
|
1887
|
+
// Recover stale crumbs: a subagent open (pre-fix) may have pointed this
|
|
1888
|
+
// terminal's breadcrumb at an artifact child; resume the parent instead.
|
|
1889
|
+
breadcrumb.sessionFile = resolveBreadcrumbToInteractiveRoot(breadcrumb.sessionFile);
|
|
1890
|
+
const breadcrumbCwd = path.resolve(breadcrumb.cwd);
|
|
1891
|
+
if (breadcrumbCwd === resolvedCwd) {
|
|
1892
|
+
chosenSession = breadcrumb.sessionFile;
|
|
1893
|
+
} else {
|
|
1894
|
+
// The terminal's last session started in a different cwd. If that cwd is
|
|
1895
|
+
// gone (worktree move/rename) and this location has no sessions of its
|
|
1896
|
+
// own, re-root the moved session here instead of starting fresh. When an
|
|
1897
|
+
// explicit sessionDir is reused across the move, the stale breadcrumb file
|
|
1898
|
+
// may be the newest entry there; prefer a genuine current-cwd session.
|
|
1899
|
+
let newestInTargetDir = await findMostRecentSession(dir, storage);
|
|
1900
|
+
const breadcrumbFile = path.resolve(breadcrumb.sessionFile);
|
|
1901
|
+
const breadcrumbCwdMissing = !fs.existsSync(breadcrumbCwd);
|
|
1902
|
+
const newestIsBreadcrumb = newestInTargetDir ? path.resolve(newestInTargetDir) === breadcrumbFile : false;
|
|
1903
|
+
let currentProjectAlreadyHasSession = false;
|
|
1904
|
+
|
|
1905
|
+
if (breadcrumbCwdMissing && newestIsBreadcrumb) {
|
|
1906
|
+
const localSession = (await SessionManager.list(cwd, dir, storage)).find(
|
|
1907
|
+
session =>
|
|
1908
|
+
path.resolve(session.path) !== breadcrumbFile &&
|
|
1909
|
+
session.cwd &&
|
|
1910
|
+
path.resolve(session.cwd) === resolvedCwd,
|
|
1911
|
+
);
|
|
1912
|
+
if (localSession) {
|
|
1913
|
+
newestInTargetDir = localSession.path;
|
|
1914
|
+
currentProjectAlreadyHasSession = true;
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
const looksLikeMovedProject =
|
|
1919
|
+
breadcrumbCwdMissing &&
|
|
1920
|
+
(newestInTargetDir === null || (newestIsBreadcrumb && !currentProjectAlreadyHasSession));
|
|
1921
|
+
if (looksLikeMovedProject) {
|
|
1922
|
+
logger.info("Re-rooting moved session", { from: breadcrumbCwd, to: resolvedCwd });
|
|
1923
|
+
// Anchor at the gone breadcrumb cwd so the moveTo below relocates the
|
|
1924
|
+
// session: open() now falls back to the launch cwd for a missing
|
|
1925
|
+
// recorded cwd, which would no-op moveTo when it equals `cwd`.
|
|
1926
|
+
const manager = await SessionManager.open(breadcrumb.sessionFile, undefined, storage, {
|
|
1927
|
+
initialCwd: breadcrumbCwd,
|
|
1928
|
+
});
|
|
1929
|
+
await manager.moveTo(cwd, sessionDir);
|
|
1930
|
+
return manager;
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
chosenSession = newestInTargetDir;
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
if (chosenSession === undefined) chosenSession = await findMostRecentSession(dir, storage);
|
|
1938
|
+
|
|
1939
|
+
const manager = new SessionManager(cwd, dir, true, storage);
|
|
1940
|
+
if (chosenSession) await manager.setSessionFile(chosenSession);
|
|
1941
|
+
else manager.#resetToNewSession();
|
|
1942
|
+
return manager;
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
/** Create an in-memory session (no file persistence). */
|
|
1946
|
+
static inMemory(
|
|
1947
|
+
cwd: string = getProjectDir(),
|
|
1948
|
+
storage: SessionStorage = new MemorySessionStorage(),
|
|
1949
|
+
): SessionManager {
|
|
1950
|
+
const manager = new SessionManager(cwd, "", false, storage);
|
|
1951
|
+
manager.#resetToNewSession();
|
|
1952
|
+
return manager;
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
/**
|
|
1956
|
+
* List sessions for a project directory.
|
|
1957
|
+
* @param sessionDir Optional dir; defaults to the cwd-derived dir.
|
|
1958
|
+
*/
|
|
1959
|
+
static async list(
|
|
1960
|
+
cwd: string,
|
|
1961
|
+
sessionDir?: string,
|
|
1962
|
+
storage: SessionStorage = new FileSessionStorage(),
|
|
1963
|
+
): Promise<SessionInfo[]> {
|
|
1964
|
+
const dir = sessionDir ?? SessionManager.getDefaultSessionDir(cwd, undefined, storage);
|
|
1965
|
+
return listSessions(dir, storage);
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
/** List all sessions across all project directories. */
|
|
1969
|
+
static listAll(storage: SessionStorage = new FileSessionStorage()): Promise<SessionInfo[]> {
|
|
1970
|
+
return listAllSessions(storage);
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
/**
|
|
1975
|
+
* If the current session was created by `/move` and contains no real
|
|
1976
|
+
* user/assistant messages, delete it so empty move sessions don't accumulate.
|
|
1977
|
+
*/
|
|
1978
|
+
export async function cleanupEmptyMoveSession(
|
|
1979
|
+
sessionManager: SessionManager,
|
|
1980
|
+
movedFromEmptySessionFile: string | undefined,
|
|
1981
|
+
): Promise<void> {
|
|
1982
|
+
const sessionFile = sessionManager.getSessionFile();
|
|
1983
|
+
if (!sessionFile || !movedFromEmptySessionFile) return;
|
|
1984
|
+
if (path.resolve(sessionFile) !== path.resolve(movedFromEmptySessionFile)) return;
|
|
1985
|
+
const entries = sessionManager.getEntries();
|
|
1986
|
+
const hasRealMessages = entries.some(
|
|
1987
|
+
e => e.type === "message" && (e.message.role === "user" || e.message.role === "assistant"),
|
|
1988
|
+
);
|
|
1989
|
+
if (hasRealMessages) return;
|
|
1990
|
+
try {
|
|
1991
|
+
await sessionManager.dropSession(sessionFile);
|
|
1992
|
+
} catch (err) {
|
|
1993
|
+
logger.warn("Failed to clean up empty move session", { sessionFile, error: String(err) });
|
|
1994
|
+
}
|
|
1995
|
+
}
|