@skaft/hamr 0.4.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 +314 -0
- package/LICENSE +27 -0
- package/README.md +96 -0
- package/dist/bun/cli.d.ts +3 -0
- package/dist/bun/cli.d.ts.map +1 -0
- package/dist/bun/cli.js +9 -0
- package/dist/bun/cli.js.map +1 -0
- package/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/bun/register-bedrock.d.ts.map +1 -0
- package/dist/bun/register-bedrock.js +4 -0
- package/dist/bun/register-bedrock.js.map +1 -0
- package/dist/bun/restore-sandbox-env.d.ts +17 -0
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
- package/dist/bun/restore-sandbox-env.js +36 -0
- package/dist/bun/restore-sandbox-env.js.map +1 -0
- package/dist/cli/args.d.ts +57 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +379 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.d.ts.map +1 -0
- package/dist/cli/file-processor.js +82 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/initial-message.d.ts +18 -0
- package/dist/cli/initial-message.d.ts.map +1 -0
- package/dist/cli/initial-message.js +22 -0
- package/dist/cli/initial-message.js.map +1 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.d.ts.map +1 -0
- package/dist/cli/list-models.js +98 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/project-trust.d.ts +10 -0
- package/dist/cli/project-trust.d.ts.map +1 -0
- package/dist/cli/project-trust.js +48 -0
- package/dist/cli/project-trust.js.map +1 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +35 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli/startup-ui.d.ts +17 -0
- package/dist/cli/startup-ui.d.ts.map +1 -0
- package/dist/cli/startup-ui.js +135 -0
- package/dist/cli/startup-ui.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +40 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +92 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +449 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts +119 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -0
- package/dist/core/agent-session-runtime.js +295 -0
- package/dist/core/agent-session-runtime.js.map +1 -0
- package/dist/core/agent-session-services.d.ts +88 -0
- package/dist/core/agent-session-services.d.ts.map +1 -0
- package/dist/core/agent-session-services.js +129 -0
- package/dist/core/agent-session-services.js.map +1 -0
- package/dist/core/agent-session.d.ts +633 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +2512 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/auth-guidance.d.ts +5 -0
- package/dist/core/auth-guidance.d.ts.map +1 -0
- package/dist/core/auth-guidance.js +21 -0
- package/dist/core/auth-guidance.js.map +1 -0
- package/dist/core/auth-storage.d.ts +150 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +446 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +32 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +111 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +92 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +249 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +121 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +619 -0
- package/dist/core/compaction/compaction.js.map +1 -0
- package/dist/core/compaction/index.d.ts +7 -0
- package/dist/core/compaction/index.d.ts.map +1 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/index.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +38 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +153 -0
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.d.ts.map +1 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.js.map +1 -0
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +75 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/experimental.d.ts +2 -0
- package/dist/core/experimental.d.ts.map +1 -0
- package/dist/core/experimental.js +4 -0
- package/dist/core/experimental.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +249 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +37 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +226 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +1066 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +1864 -0
- package/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +108 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +78 -0
- package/dist/core/extensions/index.d.ts +12 -0
- package/dist/core/extensions/index.d.ts.map +1 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/index.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +24 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +481 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +166 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +877 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +1201 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +45 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +22 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +55 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +348 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/http-dispatcher.d.ts +22 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -0
- package/dist/core/http-dispatcher.js +64 -0
- package/dist/core/http-dispatcher.js.map +1 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +13 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/keybindings.d.ts +353 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +294 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/messages.d.ts +77 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +123 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +151 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +734 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +111 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +533 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/output-guard.d.ts +7 -0
- package/dist/core/output-guard.d.ts.map +1 -0
- package/dist/core/output-guard.js +89 -0
- package/dist/core/output-guard.js.map +1 -0
- package/dist/core/package-manager.d.ts +208 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +2061 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/project-trust.d.ts +15 -0
- package/dist/core/project-trust.d.ts.map +1 -0
- package/dist/core/project-trust.js +58 -0
- package/dist/core/project-trust.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +53 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +236 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/provider-attribution.d.ts +4 -0
- package/dist/core/provider-attribution.d.ts.map +1 -0
- package/dist/core/provider-attribution.js +80 -0
- package/dist/core/provider-attribution.js.map +1 -0
- package/dist/core/provider-display-names.d.ts +2 -0
- package/dist/core/provider-display-names.d.ts.map +1 -0
- package/dist/core/provider-display-names.js +36 -0
- package/dist/core/provider-display-names.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +30 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +245 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +205 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +769 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/sdk.d.ts +109 -0
- package/dist/core/sdk.d.ts.map +1 -0
- package/dist/core/sdk.js +267 -0
- package/dist/core/sdk.js.map +1 -0
- package/dist/core/session-cwd.d.ts +19 -0
- package/dist/core/session-cwd.d.ts.map +1 -0
- package/dist/core/session-cwd.js +37 -0
- package/dist/core/session-cwd.js.map +1 -0
- package/dist/core/session-manager.d.ts +332 -0
- package/dist/core/session-manager.d.ts.map +1 -0
- package/dist/core/session-manager.js +1222 -0
- package/dist/core/session-manager.js.map +1 -0
- package/dist/core/settings-manager.d.ts +288 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +862 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +60 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +386 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +14 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +26 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/source-info.d.ts +18 -0
- package/dist/core/source-info.d.ts.map +1 -0
- package/dist/core/source-info.js +19 -0
- package/dist/core/source-info.js.map +1 -0
- package/dist/core/system-prompt.d.ts +28 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +134 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/telemetry.d.ts +3 -0
- package/dist/core/telemetry.d.ts.map +1 -0
- package/dist/core/telemetry.js +9 -0
- package/dist/core/telemetry.js.map +1 -0
- package/dist/core/timings.d.ts +8 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +31 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +68 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +373 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +87 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +345 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +51 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +289 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
- package/dist/core/tools/file-mutation-queue.js +52 -0
- package/dist/core/tools/file-mutation-queue.js.map +1 -0
- package/dist/core/tools/find.d.ts +35 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +297 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +37 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +301 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/index.d.ts +40 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +112 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +37 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +167 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/output-accumulator.d.ts +52 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -0
- package/dist/core/tools/output-accumulator.js +178 -0
- package/dist/core/tools/output-accumulator.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +10 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +99 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/read.d.ts +35 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +286 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/render-utils.d.ts +24 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -0
- package/dist/core/tools/render-utils.js +65 -0
- package/dist/core/tools/render-utils.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.js +34 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +70 -0
- package/dist/core/tools/truncate.d.ts.map +1 -0
- package/dist/core/tools/truncate.js +215 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/write.d.ts +26 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +196 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/core/trust-manager.d.ts +36 -0
- package/dist/core/trust-manager.d.ts.map +1 -0
- package/dist/core/trust-manager.js +201 -0
- package/dist/core/trust-manager.js.map +1 -0
- package/dist/hamr/extensions/context.d.ts +14 -0
- package/dist/hamr/extensions/context.d.ts.map +1 -0
- package/dist/hamr/extensions/context.js +106 -0
- package/dist/hamr/extensions/context.js.map +1 -0
- package/dist/hamr/extensions/index.d.ts +13 -0
- package/dist/hamr/extensions/index.d.ts.map +1 -0
- package/dist/hamr/extensions/index.js +25 -0
- package/dist/hamr/extensions/index.js.map +1 -0
- package/dist/hamr/extensions/memory.d.ts +67 -0
- package/dist/hamr/extensions/memory.d.ts.map +1 -0
- package/dist/hamr/extensions/memory.js +405 -0
- package/dist/hamr/extensions/memory.js.map +1 -0
- package/dist/hamr/extensions/providers.d.ts +8 -0
- package/dist/hamr/extensions/providers.d.ts.map +1 -0
- package/dist/hamr/extensions/providers.js +81 -0
- package/dist/hamr/extensions/providers.js.map +1 -0
- package/dist/hamr/extensions/read-loop-guard.d.ts +3 -0
- package/dist/hamr/extensions/read-loop-guard.d.ts.map +1 -0
- package/dist/hamr/extensions/read-loop-guard.js +26 -0
- package/dist/hamr/extensions/read-loop-guard.js.map +1 -0
- package/dist/hamr/extensions/subagents.d.ts +15 -0
- package/dist/hamr/extensions/subagents.d.ts.map +1 -0
- package/dist/hamr/extensions/subagents.js +264 -0
- package/dist/hamr/extensions/subagents.js.map +1 -0
- package/dist/hamr/handoff/HandoffManager.d.ts +46 -0
- package/dist/hamr/handoff/HandoffManager.d.ts.map +1 -0
- package/dist/hamr/handoff/HandoffManager.js +147 -0
- package/dist/hamr/handoff/HandoffManager.js.map +1 -0
- package/dist/hamr/helpers.d.ts +8 -0
- package/dist/hamr/helpers.d.ts.map +1 -0
- package/dist/hamr/helpers.js +35 -0
- package/dist/hamr/helpers.js.map +1 -0
- package/dist/hamr/memory/HolographicMemory.d.ts +138 -0
- package/dist/hamr/memory/HolographicMemory.d.ts.map +1 -0
- package/dist/hamr/memory/HolographicMemory.js +525 -0
- package/dist/hamr/memory/HolographicMemory.js.map +1 -0
- package/dist/hamr/memory/fts-marks.d.ts +2 -0
- package/dist/hamr/memory/fts-marks.d.ts.map +1 -0
- package/dist/hamr/memory/fts-marks.js +4 -0
- package/dist/hamr/memory/fts-marks.js.map +1 -0
- package/dist/hamr/memory.d.ts +16 -0
- package/dist/hamr/memory.d.ts.map +1 -0
- package/dist/hamr/memory.js +223 -0
- package/dist/hamr/memory.js.map +1 -0
- package/dist/hamr/persistent-editor.d.ts +3 -0
- package/dist/hamr/persistent-editor.d.ts.map +1 -0
- package/dist/hamr/persistent-editor.js +103 -0
- package/dist/hamr/persistent-editor.js.map +1 -0
- package/dist/hamr/providers/parsers/deepseek.d.ts +28 -0
- package/dist/hamr/providers/parsers/deepseek.d.ts.map +1 -0
- package/dist/hamr/providers/parsers/deepseek.js +150 -0
- package/dist/hamr/providers/parsers/deepseek.js.map +1 -0
- package/dist/hamr/providers/parsers/generic.d.ts +19 -0
- package/dist/hamr/providers/parsers/generic.d.ts.map +1 -0
- package/dist/hamr/providers/parsers/generic.js +263 -0
- package/dist/hamr/providers/parsers/generic.js.map +1 -0
- package/dist/hamr/providers/parsers/glm-step.d.ts +28 -0
- package/dist/hamr/providers/parsers/glm-step.d.ts.map +1 -0
- package/dist/hamr/providers/parsers/glm-step.js +289 -0
- package/dist/hamr/providers/parsers/glm-step.js.map +1 -0
- package/dist/hamr/providers/parsers/hermes.d.ts +21 -0
- package/dist/hamr/providers/parsers/hermes.d.ts.map +1 -0
- package/dist/hamr/providers/parsers/hermes.js +114 -0
- package/dist/hamr/providers/parsers/hermes.js.map +1 -0
- package/dist/hamr/providers/parsers/index.d.ts +15 -0
- package/dist/hamr/providers/parsers/index.d.ts.map +1 -0
- package/dist/hamr/providers/parsers/index.js +66 -0
- package/dist/hamr/providers/parsers/index.js.map +1 -0
- package/dist/hamr/providers/parsers/json-in-tags.d.ts +100 -0
- package/dist/hamr/providers/parsers/json-in-tags.d.ts.map +1 -0
- package/dist/hamr/providers/parsers/json-in-tags.js +395 -0
- package/dist/hamr/providers/parsers/json-in-tags.js.map +1 -0
- package/dist/hamr/providers/parsers/llama3-json.d.ts +24 -0
- package/dist/hamr/providers/parsers/llama3-json.d.ts.map +1 -0
- package/dist/hamr/providers/parsers/llama3-json.js +157 -0
- package/dist/hamr/providers/parsers/llama3-json.js.map +1 -0
- package/dist/hamr/providers/parsers/mistral.d.ts +22 -0
- package/dist/hamr/providers/parsers/mistral.d.ts.map +1 -0
- package/dist/hamr/providers/parsers/mistral.js +157 -0
- package/dist/hamr/providers/parsers/mistral.js.map +1 -0
- package/dist/hamr/providers/parsers/pythonic.d.ts +30 -0
- package/dist/hamr/providers/parsers/pythonic.d.ts.map +1 -0
- package/dist/hamr/providers/parsers/pythonic.js +243 -0
- package/dist/hamr/providers/parsers/pythonic.js.map +1 -0
- package/dist/hamr/providers/parsers/qwen3-xml.d.ts +19 -0
- package/dist/hamr/providers/parsers/qwen3-xml.d.ts.map +1 -0
- package/dist/hamr/providers/parsers/qwen3-xml.js +107 -0
- package/dist/hamr/providers/parsers/qwen3-xml.js.map +1 -0
- package/dist/hamr/providers/parsers/registry.d.ts +13 -0
- package/dist/hamr/providers/parsers/registry.d.ts.map +1 -0
- package/dist/hamr/providers/parsers/registry.js +51 -0
- package/dist/hamr/providers/parsers/registry.js.map +1 -0
- package/dist/hamr/providers/parsers/types.d.ts +83 -0
- package/dist/hamr/providers/parsers/types.d.ts.map +1 -0
- package/dist/hamr/providers/parsers/types.js +93 -0
- package/dist/hamr/providers/parsers/types.js.map +1 -0
- package/dist/hamr/providers/parsers/utils.d.ts +106 -0
- package/dist/hamr/providers/parsers/utils.d.ts.map +1 -0
- package/dist/hamr/providers/parsers/utils.js +477 -0
- package/dist/hamr/providers/parsers/utils.js.map +1 -0
- package/dist/hamr/providers/parsers/xlam.d.ts +23 -0
- package/dist/hamr/providers/parsers/xlam.d.ts.map +1 -0
- package/dist/hamr/providers/parsers/xlam.js +119 -0
- package/dist/hamr/providers/parsers/xlam.js.map +1 -0
- package/dist/hamr/providers/relay-provider.d.ts +34 -0
- package/dist/hamr/providers/relay-provider.d.ts.map +1 -0
- package/dist/hamr/providers/relay-provider.js +228 -0
- package/dist/hamr/providers/relay-provider.js.map +1 -0
- package/dist/hamr/providers/repair/json-repair.d.ts +30 -0
- package/dist/hamr/providers/repair/json-repair.d.ts.map +1 -0
- package/dist/hamr/providers/repair/json-repair.js +315 -0
- package/dist/hamr/providers/repair/json-repair.js.map +1 -0
- package/dist/hamr/providers/repair/reasoning-sanitizer.d.ts +28 -0
- package/dist/hamr/providers/repair/reasoning-sanitizer.d.ts.map +1 -0
- package/dist/hamr/providers/repair/reasoning-sanitizer.js +115 -0
- package/dist/hamr/providers/repair/reasoning-sanitizer.js.map +1 -0
- package/dist/hamr/providers/repair/xml-repair.d.ts +31 -0
- package/dist/hamr/providers/repair/xml-repair.d.ts.map +1 -0
- package/dist/hamr/providers/repair/xml-repair.js +295 -0
- package/dist/hamr/providers/repair/xml-repair.js.map +1 -0
- package/dist/hamr/providers/tool-calls.d.ts +7 -0
- package/dist/hamr/providers/tool-calls.d.ts.map +1 -0
- package/dist/hamr/providers/tool-calls.js +148 -0
- package/dist/hamr/providers/tool-calls.js.map +1 -0
- package/dist/hamr/providers/types.d.ts +17 -0
- package/dist/hamr/providers/types.d.ts.map +1 -0
- package/dist/hamr/providers/types.js +2 -0
- package/dist/hamr/providers/types.js.map +1 -0
- package/dist/hamr/repair.d.ts +8 -0
- package/dist/hamr/repair.d.ts.map +1 -0
- package/dist/hamr/repair.js +85 -0
- package/dist/hamr/repair.js.map +1 -0
- package/dist/hamr/shimmer.d.ts +2 -0
- package/dist/hamr/shimmer.d.ts.map +1 -0
- package/dist/hamr/shimmer.js +9 -0
- package/dist/hamr/shimmer.js.map +1 -0
- package/dist/hamr/startup-config.d.ts +78 -0
- package/dist/hamr/startup-config.d.ts.map +1 -0
- package/dist/hamr/startup-config.js +344 -0
- package/dist/hamr/startup-config.js.map +1 -0
- package/dist/hamr/store/sqlite-loader.d.ts +26 -0
- package/dist/hamr/store/sqlite-loader.d.ts.map +1 -0
- package/dist/hamr/store/sqlite-loader.js +36 -0
- package/dist/hamr/store/sqlite-loader.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +12 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +739 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +33 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +281 -0
- package/dist/migrations.js.map +1 -0
- package/dist/modes/index.d.ts +9 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/modes/interactive/components/armin.d.ts.map +1 -0
- package/dist/modes/interactive/components/armin.js +329 -0
- package/dist/modes/interactive/components/armin.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +28 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +172 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +35 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +171 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.js +51 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +42 -0
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +43 -0
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +71 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +496 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.js +28 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +63 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-message.js +73 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/modes/interactive/components/daxnuts.d.ts.map +1 -0
- package/dist/modes/interactive/components/daxnuts.js +138 -0
- package/dist/modes/interactive/components/daxnuts.js.map +1 -0
- package/dist/modes/interactive/components/diff.d.ts +24 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +172 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.js +20 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +20 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +114 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-input.js +55 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +26 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +75 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts +24 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -0
- package/dist/modes/interactive/components/first-time-setup.js +104 -0
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +38 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +314 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +34 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -0
- package/dist/modes/interactive/components/index.js +35 -0
- package/dist/modes/interactive/components/index.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +36 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +52 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/dist/modes/interactive/components/login-dialog.js +175 -0
- package/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +47 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector.js +268 -0
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +31 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.js +156 -0
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +286 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +155 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +832 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +73 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +410 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +38 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +46 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js +48 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.js +50 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +66 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +315 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +89 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +1186 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/trust-selector.d.ts +23 -0
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/trust-selector.js +85 -0
- package/dist/modes/interactive/components/trust-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +111 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +15 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +61 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +416 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +4958 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/interrupt-routing.d.ts +23 -0
- package/dist/modes/interactive/interrupt-routing.d.ts.map +1 -0
- package/dist/modes/interactive/interrupt-routing.js +10 -0
- package/dist/modes/interactive/interrupt-routing.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +112 -0
- package/dist/modes/interactive/theme/default.json +102 -0
- package/dist/modes/interactive/theme/hamr.json +121 -0
- package/dist/modes/interactive/theme/kawaii.json +120 -0
- package/dist/modes/interactive/theme/light.json +111 -0
- package/dist/modes/interactive/theme/pinkOut.json +116 -0
- package/dist/modes/interactive/theme/theme-schema.json +428 -0
- package/dist/modes/interactive/theme/theme.d.ts +196 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +1461 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/dist/modes/print-mode.d.ts +28 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +132 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/modes/rpc/jsonl.d.ts.map +1 -0
- package/dist/modes/rpc/jsonl.js +49 -0
- package/dist/modes/rpc/jsonl.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +227 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +466 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +613 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +420 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/dist/package-manager-cli.d.ts +8 -0
- package/dist/package-manager-cli.d.ts.map +1 -0
- package/dist/package-manager-cli.js +616 -0
- package/dist/package-manager-cli.js.map +1 -0
- package/dist/skills/frontend-design.md +22 -0
- package/dist/skills/using-hamr.md +38 -0
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +52 -0
- package/dist/utils/ansi.js.map +1 -0
- package/dist/utils/changelog.d.ts +22 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +165 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/child-process.d.ts +18 -0
- package/dist/utils/child-process.d.ts.map +1 -0
- package/dist/utils/child-process.js +104 -0
- package/dist/utils/child-process.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +245 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +10 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +20 -0
- package/dist/utils/clipboard-native.js.map +1 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +117 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/deprecation.d.ts +4 -0
- package/dist/utils/deprecation.d.ts.map +1 -0
- package/dist/utils/deprecation.js +13 -0
- package/dist/utils/deprecation.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +5 -0
- package/dist/utils/exif-orientation.d.ts.map +1 -0
- package/dist/utils/exif-orientation.js +158 -0
- package/dist/utils/exif-orientation.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/fs-watch.d.ts +5 -0
- package/dist/utils/fs-watch.d.ts.map +1 -0
- package/dist/utils/fs-watch.js +25 -0
- package/dist/utils/fs-watch.js.map +1 -0
- package/dist/utils/git.d.ts +26 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +195 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/hamr-user-agent.d.ts +2 -0
- package/dist/utils/hamr-user-agent.d.ts.map +1 -0
- package/dist/utils/hamr-user-agent.js +5 -0
- package/dist/utils/hamr-user-agent.js.map +1 -0
- package/dist/utils/html.d.ts +7 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +40 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/image-convert.d.ts +9 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +39 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -0
- package/dist/utils/image-resize-core.js +124 -0
- package/dist/utils/image-resize-core.js.map +1 -0
- package/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/utils/image-resize-worker.d.ts.map +1 -0
- package/dist/utils/image-resize-worker.js +31 -0
- package/dist/utils/image-resize-worker.js.map +1 -0
- package/dist/utils/image-resize.d.ts +16 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +97 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +7 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/mime.d.ts +3 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +69 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/open-browser.d.ts +9 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +22 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/dist/utils/paths.d.ts +31 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +91 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/photon.d.ts +21 -0
- package/dist/utils/photon.d.ts.map +1 -0
- package/dist/utils/photon.js +121 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/shell.d.ts +30 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +195 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -0
- package/dist/utils/syntax-highlight.js +118 -0
- package/dist/utils/syntax-highlight.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +3 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +328 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/dist/utils/version-check.d.ts +20 -0
- package/dist/utils/version-check.d.ts.map +1 -0
- package/dist/utils/version-check.js +92 -0
- package/dist/utils/version-check.js.map +1 -0
- package/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/utils/windows-self-update.d.ts.map +1 -0
- package/dist/utils/windows-self-update.js +77 -0
- package/dist/utils/windows-self-update.js.map +1 -0
- package/docs/compaction.md +394 -0
- package/docs/containerization.md +111 -0
- package/docs/custom-provider.md +736 -0
- package/docs/development.md +71 -0
- package/docs/docs.json +156 -0
- package/docs/extensions.md +2662 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/index.md +82 -0
- package/docs/json.md +82 -0
- package/docs/keybindings.md +197 -0
- package/docs/models.md +492 -0
- package/docs/packages.md +228 -0
- package/docs/prompt-templates.md +95 -0
- package/docs/providers.md +274 -0
- package/docs/quickstart.md +165 -0
- package/docs/rpc.md +1408 -0
- package/docs/sdk.md +1142 -0
- package/docs/security.md +59 -0
- package/docs/session-format.md +412 -0
- package/docs/sessions.md +145 -0
- package/docs/settings.md +308 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +231 -0
- package/docs/terminal-setup.md +148 -0
- package/docs/termux.md +127 -0
- package/docs/themes.md +295 -0
- package/docs/tmux.md +63 -0
- package/docs/tui.md +927 -0
- package/docs/usage.md +305 -0
- package/docs/visual-parity-handoff.md +110 -0
- package/docs/windows.md +17 -0
- package/examples/README.md +25 -0
- package/examples/extensions/README.md +211 -0
- package/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/border-status-editor.ts +150 -0
- package/examples/extensions/built-in-tool-renderer.ts +249 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +72 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +127 -0
- package/examples/extensions/custom-footer.ts +64 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +400 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/dirty-repo-guard.ts +56 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +15 -0
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/examples/extensions/gondolin/index.ts +531 -0
- package/examples/extensions/gondolin/package-lock.json +185 -0
- package/examples/extensions/gondolin/package.json +19 -0
- package/examples/extensions/hamr-browser/README.md +79 -0
- package/examples/extensions/hamr-browser/bun.lock +235 -0
- package/examples/extensions/hamr-browser/index.ts +264 -0
- package/examples/extensions/hamr-browser/package.json +25 -0
- package/examples/extensions/hamr-browser/skills/hamr-browser.md +25 -0
- package/examples/extensions/hamr-browser/src/browser-controller.ts +206 -0
- package/examples/extensions/hamr-browser/src/deps.ts +39 -0
- package/examples/extensions/hamr-browser/src/paths.ts +25 -0
- package/examples/extensions/hamr-browser/src/shims.d.ts +1 -0
- package/examples/extensions/hamr-browser/src/snapshot.ts +84 -0
- package/examples/extensions/hamr-browser/src/targeting.ts +79 -0
- package/examples/extensions/hamr-browser/test/deps.test.ts +23 -0
- package/examples/extensions/hamr-browser/test/paths.test.ts +25 -0
- package/examples/extensions/hamr-browser/test/targeting.test.ts +27 -0
- package/examples/extensions/hamr-browser/tsconfig.json +10 -0
- package/examples/extensions/handoff.ts +191 -0
- package/examples/extensions/hello.ts +26 -0
- package/examples/extensions/hidden-thinking-label.ts +53 -0
- package/examples/extensions/inline-bash.ts +94 -0
- package/examples/extensions/input-transform-streaming.ts +39 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +196 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +426 -0
- package/examples/extensions/modal-editor.ts +85 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +55 -0
- package/examples/extensions/overlay-qa-tests.ts +1450 -0
- package/examples/extensions/overlay-test.ts +153 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +65 -0
- package/examples/extensions/plan-mode/index.ts +340 -0
- package/examples/extensions/plan-mode/utils.ts +168 -0
- package/examples/extensions/preset.ts +430 -0
- package/examples/extensions/project-trust.ts +64 -0
- package/examples/extensions/prompt-customizer.ts +97 -0
- package/examples/extensions/protected-paths.ts +30 -0
- package/examples/extensions/provider-payload.ts +18 -0
- package/examples/extensions/qna.ts +122 -0
- package/examples/extensions/question.ts +285 -0
- package/examples/extensions/questionnaire.ts +448 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/read-loop-guard.ts +32 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +118 -0
- package/examples/extensions/sandbox/index.ts +321 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +343 -0
- package/examples/extensions/space-invaders.ts +560 -0
- package/examples/extensions/ssh.ts +220 -0
- package/examples/extensions/status-line.ts +32 -0
- package/examples/extensions/structured-output.ts +65 -0
- package/examples/extensions/subagent/README.md +175 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +126 -0
- package/examples/extensions/subagent/index.ts +1009 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +206 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/tic-tac-toe.ts +1008 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +297 -0
- package/examples/extensions/tool-override.ts +144 -0
- package/examples/extensions/tools.ts +146 -0
- package/examples/extensions/trigger-compact.ts +50 -0
- package/examples/extensions/truncated-tool.ts +195 -0
- package/examples/extensions/widget-placement.ts +9 -0
- package/examples/extensions/with-deps/index.ts +32 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/extensions/working-indicator.ts +123 -0
- package/examples/extensions/working-message-test.ts +25 -0
- package/examples/rpc-extension-ui.ts +632 -0
- package/examples/sdk/01-minimal.ts +26 -0
- package/examples/sdk/02-custom-model.ts +53 -0
- package/examples/sdk/03-custom-prompt.ts +75 -0
- package/examples/sdk/04-skills.ts +55 -0
- package/examples/sdk/05-tools.ts +48 -0
- package/examples/sdk/06-extensions.ts +99 -0
- package/examples/sdk/07-context-files.ts +47 -0
- package/examples/sdk/08-prompt-templates.ts +51 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +52 -0
- package/examples/sdk/10-settings.ts +53 -0
- package/examples/sdk/11-sessions.ts +52 -0
- package/examples/sdk/12-full-control.ts +77 -0
- package/examples/sdk/13-session-runtime.ts +67 -0
- package/examples/sdk/README.md +144 -0
- package/node_modules/@hamr/agent/dist/agent-loop.d.ts +24 -0
- package/node_modules/@hamr/agent/dist/agent-loop.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/agent-loop.js +510 -0
- package/node_modules/@hamr/agent/dist/agent-loop.js.map +1 -0
- package/node_modules/@hamr/agent/dist/agent.d.ts +125 -0
- package/node_modules/@hamr/agent/dist/agent.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/agent.js +378 -0
- package/node_modules/@hamr/agent/dist/agent.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/agent-harness.d.ts +95 -0
- package/node_modules/@hamr/agent/dist/harness/agent-harness.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/agent-harness.js +950 -0
- package/node_modules/@hamr/agent/dist/harness/agent-harness.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/compaction/branch-summarization.d.ts +53 -0
- package/node_modules/@hamr/agent/dist/harness/compaction/branch-summarization.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/compaction/branch-summarization.js +175 -0
- package/node_modules/@hamr/agent/dist/harness/compaction/branch-summarization.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/compaction/compaction.d.ts +95 -0
- package/node_modules/@hamr/agent/dist/harness/compaction/compaction.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/compaction/compaction.js +528 -0
- package/node_modules/@hamr/agent/dist/harness/compaction/compaction.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/compaction/utils.d.ts +25 -0
- package/node_modules/@hamr/agent/dist/harness/compaction/utils.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/compaction/utils.js +131 -0
- package/node_modules/@hamr/agent/dist/harness/compaction/utils.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/env/nodejs.d.ts +51 -0
- package/node_modules/@hamr/agent/dist/harness/env/nodejs.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/env/nodejs.js +483 -0
- package/node_modules/@hamr/agent/dist/harness/env/nodejs.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/messages.d.ts +51 -0
- package/node_modules/@hamr/agent/dist/harness/messages.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/messages.js +102 -0
- package/node_modules/@hamr/agent/dist/harness/messages.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/prompt-templates.d.ts +48 -0
- package/node_modules/@hamr/agent/dist/harness/prompt-templates.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/prompt-templates.js +230 -0
- package/node_modules/@hamr/agent/dist/harness/prompt-templates.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/session/jsonl-repo.d.ts +26 -0
- package/node_modules/@hamr/agent/dist/harness/session/jsonl-repo.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/session/jsonl-repo.js +95 -0
- package/node_modules/@hamr/agent/dist/harness/session/jsonl-repo.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/session/jsonl-storage.d.ts +33 -0
- package/node_modules/@hamr/agent/dist/harness/session/jsonl-storage.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/session/jsonl-storage.js +224 -0
- package/node_modules/@hamr/agent/dist/harness/session/jsonl-storage.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/session/memory-repo.d.ts +18 -0
- package/node_modules/@hamr/agent/dist/harness/session/memory-repo.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/session/memory-repo.js +44 -0
- package/node_modules/@hamr/agent/dist/harness/session/memory-repo.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/session/memory-storage.d.ts +25 -0
- package/node_modules/@hamr/agent/dist/harness/session/memory-storage.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/session/memory-storage.js +109 -0
- package/node_modules/@hamr/agent/dist/harness/session/memory-storage.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/session/repo-utils.d.ts +11 -0
- package/node_modules/@hamr/agent/dist/harness/session/repo-utils.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/session/repo-utils.js +39 -0
- package/node_modules/@hamr/agent/dist/harness/session/repo-utils.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/session/session.d.ts +33 -0
- package/node_modules/@hamr/agent/dist/harness/session/session.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/session/session.js +209 -0
- package/node_modules/@hamr/agent/dist/harness/session/session.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/session/uuid.d.ts +2 -0
- package/node_modules/@hamr/agent/dist/harness/session/uuid.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/session/uuid.js +50 -0
- package/node_modules/@hamr/agent/dist/harness/session/uuid.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/skills.d.ts +44 -0
- package/node_modules/@hamr/agent/dist/harness/skills.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/skills.js +311 -0
- package/node_modules/@hamr/agent/dist/harness/skills.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/system-prompt.d.ts +3 -0
- package/node_modules/@hamr/agent/dist/harness/system-prompt.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/system-prompt.js +30 -0
- package/node_modules/@hamr/agent/dist/harness/system-prompt.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/types.d.ts +615 -0
- package/node_modules/@hamr/agent/dist/harness/types.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/types.js +81 -0
- package/node_modules/@hamr/agent/dist/harness/types.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/utils/shell-output.d.ts +14 -0
- package/node_modules/@hamr/agent/dist/harness/utils/shell-output.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/utils/shell-output.js +126 -0
- package/node_modules/@hamr/agent/dist/harness/utils/shell-output.js.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/utils/truncate.d.ts +70 -0
- package/node_modules/@hamr/agent/dist/harness/utils/truncate.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/harness/utils/truncate.js +290 -0
- package/node_modules/@hamr/agent/dist/harness/utils/truncate.js.map +1 -0
- package/node_modules/@hamr/agent/dist/index.d.ts +20 -0
- package/node_modules/@hamr/agent/dist/index.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/index.js +25 -0
- package/node_modules/@hamr/agent/dist/index.js.map +1 -0
- package/node_modules/@hamr/agent/dist/node.d.ts +3 -0
- package/node_modules/@hamr/agent/dist/node.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/node.js +3 -0
- package/node_modules/@hamr/agent/dist/node.js.map +1 -0
- package/node_modules/@hamr/agent/dist/proxy.d.ts +69 -0
- package/node_modules/@hamr/agent/dist/proxy.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/proxy.js +278 -0
- package/node_modules/@hamr/agent/dist/proxy.js.map +1 -0
- package/node_modules/@hamr/agent/dist/types.d.ts +405 -0
- package/node_modules/@hamr/agent/dist/types.d.ts.map +1 -0
- package/node_modules/@hamr/agent/dist/types.js +2 -0
- package/node_modules/@hamr/agent/dist/types.js.map +1 -0
- package/node_modules/@hamr/agent/package.json +51 -0
- package/node_modules/@hamr/ai/dist/api-registry.d.ts +20 -0
- package/node_modules/@hamr/ai/dist/api-registry.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/api-registry.js +44 -0
- package/node_modules/@hamr/ai/dist/api-registry.js.map +1 -0
- package/node_modules/@hamr/ai/dist/bedrock-provider.d.ts +5 -0
- package/node_modules/@hamr/ai/dist/bedrock-provider.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/bedrock-provider.js +6 -0
- package/node_modules/@hamr/ai/dist/bedrock-provider.js.map +1 -0
- package/node_modules/@hamr/ai/dist/cli.d.ts +3 -0
- package/node_modules/@hamr/ai/dist/cli.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/cli.js +130 -0
- package/node_modules/@hamr/ai/dist/cli.js.map +1 -0
- package/node_modules/@hamr/ai/dist/env-api-keys.d.ts +20 -0
- package/node_modules/@hamr/ai/dist/env-api-keys.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/env-api-keys.js +163 -0
- package/node_modules/@hamr/ai/dist/env-api-keys.js.map +1 -0
- package/node_modules/@hamr/ai/dist/image-models.d.ts +10 -0
- package/node_modules/@hamr/ai/dist/image-models.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/image-models.generated.d.ts +515 -0
- package/node_modules/@hamr/ai/dist/image-models.generated.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/image-models.generated.js +517 -0
- package/node_modules/@hamr/ai/dist/image-models.generated.js.map +1 -0
- package/node_modules/@hamr/ai/dist/image-models.js +23 -0
- package/node_modules/@hamr/ai/dist/image-models.js.map +1 -0
- package/node_modules/@hamr/ai/dist/images-api-registry.d.ts +14 -0
- package/node_modules/@hamr/ai/dist/images-api-registry.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/images-api-registry.js +22 -0
- package/node_modules/@hamr/ai/dist/images-api-registry.js.map +1 -0
- package/node_modules/@hamr/ai/dist/images.d.ts +4 -0
- package/node_modules/@hamr/ai/dist/images.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/images.js +14 -0
- package/node_modules/@hamr/ai/dist/images.js.map +1 -0
- package/node_modules/@hamr/ai/dist/index.d.ts +32 -0
- package/node_modules/@hamr/ai/dist/index.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/index.js +20 -0
- package/node_modules/@hamr/ai/dist/index.js.map +1 -0
- package/node_modules/@hamr/ai/dist/models.d.ts +18 -0
- package/node_modules/@hamr/ai/dist/models.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/models.generated.d.ts +18774 -0
- package/node_modules/@hamr/ai/dist/models.generated.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/models.generated.js +17803 -0
- package/node_modules/@hamr/ai/dist/models.generated.js.map +1 -0
- package/node_modules/@hamr/ai/dist/models.js +74 -0
- package/node_modules/@hamr/ai/dist/models.js.map +1 -0
- package/node_modules/@hamr/ai/dist/oauth.d.ts +2 -0
- package/node_modules/@hamr/ai/dist/oauth.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/oauth.js +2 -0
- package/node_modules/@hamr/ai/dist/oauth.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/amazon-bedrock.d.ts +38 -0
- package/node_modules/@hamr/ai/dist/providers/amazon-bedrock.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/amazon-bedrock.js +860 -0
- package/node_modules/@hamr/ai/dist/providers/amazon-bedrock.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/anthropic.d.ts +71 -0
- package/node_modules/@hamr/ai/dist/providers/anthropic.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/anthropic.js +966 -0
- package/node_modules/@hamr/ai/dist/providers/anthropic.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/azure-openai-responses.d.ts +15 -0
- package/node_modules/@hamr/ai/dist/providers/azure-openai-responses.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/azure-openai-responses.js +225 -0
- package/node_modules/@hamr/ai/dist/providers/azure-openai-responses.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/cloudflare.d.ts +13 -0
- package/node_modules/@hamr/ai/dist/providers/cloudflare.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/cloudflare.js +27 -0
- package/node_modules/@hamr/ai/dist/providers/cloudflare.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/faux.d.ts +56 -0
- package/node_modules/@hamr/ai/dist/providers/faux.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/faux.js +368 -0
- package/node_modules/@hamr/ai/dist/providers/faux.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/github-copilot-headers.d.ts +8 -0
- package/node_modules/@hamr/ai/dist/providers/github-copilot-headers.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/github-copilot-headers.js +29 -0
- package/node_modules/@hamr/ai/dist/providers/github-copilot-headers.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/google-shared.d.ts +70 -0
- package/node_modules/@hamr/ai/dist/providers/google-shared.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/google-shared.js +329 -0
- package/node_modules/@hamr/ai/dist/providers/google-shared.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/google-vertex.d.ts +15 -0
- package/node_modules/@hamr/ai/dist/providers/google-vertex.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/google-vertex.js +452 -0
- package/node_modules/@hamr/ai/dist/providers/google-vertex.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/google.d.ts +13 -0
- package/node_modules/@hamr/ai/dist/providers/google.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/google.js +403 -0
- package/node_modules/@hamr/ai/dist/providers/google.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/images/openrouter.d.ts +3 -0
- package/node_modules/@hamr/ai/dist/providers/images/openrouter.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/images/openrouter.js +128 -0
- package/node_modules/@hamr/ai/dist/providers/images/openrouter.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/images/register-builtins.d.ts +4 -0
- package/node_modules/@hamr/ai/dist/providers/images/register-builtins.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/images/register-builtins.js +34 -0
- package/node_modules/@hamr/ai/dist/providers/images/register-builtins.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/mistral.d.ts +25 -0
- package/node_modules/@hamr/ai/dist/providers/mistral.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/mistral.js +534 -0
- package/node_modules/@hamr/ai/dist/providers/mistral.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/openai-codex-responses.d.ts +30 -0
- package/node_modules/@hamr/ai/dist/providers/openai-codex-responses.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/openai-codex-responses.js +1164 -0
- package/node_modules/@hamr/ai/dist/providers/openai-codex-responses.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/openai-completions.d.ts +19 -0
- package/node_modules/@hamr/ai/dist/providers/openai-completions.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/openai-completions.js +1201 -0
- package/node_modules/@hamr/ai/dist/providers/openai-completions.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/openai-prompt-cache.d.ts +3 -0
- package/node_modules/@hamr/ai/dist/providers/openai-prompt-cache.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/openai-prompt-cache.js +10 -0
- package/node_modules/@hamr/ai/dist/providers/openai-prompt-cache.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/openai-responses-shared.d.ts +18 -0
- package/node_modules/@hamr/ai/dist/providers/openai-responses-shared.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/openai-responses-shared.js +494 -0
- package/node_modules/@hamr/ai/dist/providers/openai-responses-shared.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/openai-responses.d.ts +13 -0
- package/node_modules/@hamr/ai/dist/providers/openai-responses.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/openai-responses.js +235 -0
- package/node_modules/@hamr/ai/dist/providers/openai-responses.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/register-builtins.d.ts +35 -0
- package/node_modules/@hamr/ai/dist/providers/register-builtins.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/register-builtins.js +254 -0
- package/node_modules/@hamr/ai/dist/providers/register-builtins.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/simple-options.d.ts +8 -0
- package/node_modules/@hamr/ai/dist/providers/simple-options.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/simple-options.js +43 -0
- package/node_modules/@hamr/ai/dist/providers/simple-options.js.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/transform-messages.d.ts +8 -0
- package/node_modules/@hamr/ai/dist/providers/transform-messages.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/providers/transform-messages.js +182 -0
- package/node_modules/@hamr/ai/dist/providers/transform-messages.js.map +1 -0
- package/node_modules/@hamr/ai/dist/session-resources.d.ts +4 -0
- package/node_modules/@hamr/ai/dist/session-resources.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/session-resources.js +22 -0
- package/node_modules/@hamr/ai/dist/session-resources.js.map +1 -0
- package/node_modules/@hamr/ai/dist/stream.d.ts +8 -0
- package/node_modules/@hamr/ai/dist/stream.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/stream.js +39 -0
- package/node_modules/@hamr/ai/dist/stream.js.map +1 -0
- package/node_modules/@hamr/ai/dist/types.d.ts +526 -0
- package/node_modules/@hamr/ai/dist/types.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/types.js +2 -0
- package/node_modules/@hamr/ai/dist/types.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/abort-signals.d.ts +6 -0
- package/node_modules/@hamr/ai/dist/utils/abort-signals.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/abort-signals.js +34 -0
- package/node_modules/@hamr/ai/dist/utils/abort-signals.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/diagnostics.d.ts +19 -0
- package/node_modules/@hamr/ai/dist/utils/diagnostics.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/diagnostics.js +25 -0
- package/node_modules/@hamr/ai/dist/utils/diagnostics.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/event-stream.d.ts +21 -0
- package/node_modules/@hamr/ai/dist/utils/event-stream.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/event-stream.js +77 -0
- package/node_modules/@hamr/ai/dist/utils/event-stream.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/hash.d.ts +3 -0
- package/node_modules/@hamr/ai/dist/utils/hash.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/hash.js +14 -0
- package/node_modules/@hamr/ai/dist/utils/hash.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/headers.d.ts +2 -0
- package/node_modules/@hamr/ai/dist/utils/headers.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/headers.js +8 -0
- package/node_modules/@hamr/ai/dist/utils/headers.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/json-parse.d.ts +16 -0
- package/node_modules/@hamr/ai/dist/utils/json-parse.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/json-parse.js +113 -0
- package/node_modules/@hamr/ai/dist/utils/json-parse.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/node-http-proxy.d.ts +4 -0
- package/node_modules/@hamr/ai/dist/utils/node-http-proxy.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/node-http-proxy.js +92 -0
- package/node_modules/@hamr/ai/dist/utils/node-http-proxy.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/anthropic.d.ts +25 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/anthropic.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/anthropic.js +336 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/anthropic.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/device-code.d.ts +21 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/device-code.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/device-code.js +56 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/device-code.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/github-copilot.d.ts +30 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/github-copilot.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/github-copilot.js +280 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/github-copilot.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/index.d.ts +58 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/index.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/index.js +122 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/index.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/oauth-page.d.ts +3 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/oauth-page.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/oauth-page.js +118 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/oauth-page.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/openai-codex.d.ts +43 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/openai-codex.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/openai-codex.js +488 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/openai-codex.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/pkce.d.ts +13 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/pkce.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/pkce.js +31 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/pkce.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/types.d.ts +64 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/types.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/types.js +2 -0
- package/node_modules/@hamr/ai/dist/utils/oauth/types.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/overflow.d.ts +57 -0
- package/node_modules/@hamr/ai/dist/utils/overflow.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/overflow.js +155 -0
- package/node_modules/@hamr/ai/dist/utils/overflow.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/provider-env.d.ts +7 -0
- package/node_modules/@hamr/ai/dist/utils/provider-env.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/provider-env.js +44 -0
- package/node_modules/@hamr/ai/dist/utils/provider-env.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/sanitize-unicode.d.ts +22 -0
- package/node_modules/@hamr/ai/dist/utils/sanitize-unicode.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/sanitize-unicode.js +26 -0
- package/node_modules/@hamr/ai/dist/utils/sanitize-unicode.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/typebox-helpers.d.ts +17 -0
- package/node_modules/@hamr/ai/dist/utils/typebox-helpers.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/typebox-helpers.js +21 -0
- package/node_modules/@hamr/ai/dist/utils/typebox-helpers.js.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/validation.d.ts +18 -0
- package/node_modules/@hamr/ai/dist/utils/validation.d.ts.map +1 -0
- package/node_modules/@hamr/ai/dist/utils/validation.js +281 -0
- package/node_modules/@hamr/ai/dist/utils/validation.js.map +1 -0
- package/node_modules/@hamr/ai/package.json +93 -0
- package/node_modules/@hamr/tui/dist/autocomplete.d.ts +56 -0
- package/node_modules/@hamr/tui/dist/autocomplete.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/autocomplete.js +629 -0
- package/node_modules/@hamr/tui/dist/autocomplete.js.map +1 -0
- package/node_modules/@hamr/tui/dist/components/box.d.ts +23 -0
- package/node_modules/@hamr/tui/dist/components/box.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/components/box.js +105 -0
- package/node_modules/@hamr/tui/dist/components/box.js.map +1 -0
- package/node_modules/@hamr/tui/dist/components/cancellable-loader.d.ts +22 -0
- package/node_modules/@hamr/tui/dist/components/cancellable-loader.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/components/cancellable-loader.js +36 -0
- package/node_modules/@hamr/tui/dist/components/cancellable-loader.js.map +1 -0
- package/node_modules/@hamr/tui/dist/components/editor.d.ts +255 -0
- package/node_modules/@hamr/tui/dist/components/editor.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/components/editor.js +1905 -0
- package/node_modules/@hamr/tui/dist/components/editor.js.map +1 -0
- package/node_modules/@hamr/tui/dist/components/image.d.ts +28 -0
- package/node_modules/@hamr/tui/dist/components/image.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/components/image.js +81 -0
- package/node_modules/@hamr/tui/dist/components/image.js.map +1 -0
- package/node_modules/@hamr/tui/dist/components/input.d.ts +37 -0
- package/node_modules/@hamr/tui/dist/components/input.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/components/input.js +378 -0
- package/node_modules/@hamr/tui/dist/components/input.js.map +1 -0
- package/node_modules/@hamr/tui/dist/components/loader.d.ts +31 -0
- package/node_modules/@hamr/tui/dist/components/loader.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/components/loader.js +67 -0
- package/node_modules/@hamr/tui/dist/components/loader.js.map +1 -0
- package/node_modules/@hamr/tui/dist/components/markdown.d.ts +97 -0
- package/node_modules/@hamr/tui/dist/components/markdown.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/components/markdown.js +643 -0
- package/node_modules/@hamr/tui/dist/components/markdown.js.map +1 -0
- package/node_modules/@hamr/tui/dist/components/select-list.d.ts +50 -0
- package/node_modules/@hamr/tui/dist/components/select-list.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/components/select-list.js +154 -0
- package/node_modules/@hamr/tui/dist/components/select-list.js.map +1 -0
- package/node_modules/@hamr/tui/dist/components/settings-list.d.ts +53 -0
- package/node_modules/@hamr/tui/dist/components/settings-list.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/components/settings-list.js +185 -0
- package/node_modules/@hamr/tui/dist/components/settings-list.js.map +1 -0
- package/node_modules/@hamr/tui/dist/components/spacer.d.ts +12 -0
- package/node_modules/@hamr/tui/dist/components/spacer.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/components/spacer.js +22 -0
- package/node_modules/@hamr/tui/dist/components/spacer.js.map +1 -0
- package/node_modules/@hamr/tui/dist/components/text.d.ts +21 -0
- package/node_modules/@hamr/tui/dist/components/text.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/components/text.js +97 -0
- package/node_modules/@hamr/tui/dist/components/text.js.map +1 -0
- package/node_modules/@hamr/tui/dist/components/truncated-text.d.ts +13 -0
- package/node_modules/@hamr/tui/dist/components/truncated-text.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/components/truncated-text.js +48 -0
- package/node_modules/@hamr/tui/dist/components/truncated-text.js.map +1 -0
- package/node_modules/@hamr/tui/dist/editor-component.d.ts +39 -0
- package/node_modules/@hamr/tui/dist/editor-component.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/editor-component.js +2 -0
- package/node_modules/@hamr/tui/dist/editor-component.js.map +1 -0
- package/node_modules/@hamr/tui/dist/fuzzy.d.ts +16 -0
- package/node_modules/@hamr/tui/dist/fuzzy.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/fuzzy.js +110 -0
- package/node_modules/@hamr/tui/dist/fuzzy.js.map +1 -0
- package/node_modules/@hamr/tui/dist/index.d.ts +24 -0
- package/node_modules/@hamr/tui/dist/index.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/index.js +34 -0
- package/node_modules/@hamr/tui/dist/index.js.map +1 -0
- package/node_modules/@hamr/tui/dist/keybindings.d.ts +193 -0
- package/node_modules/@hamr/tui/dist/keybindings.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/keybindings.js +172 -0
- package/node_modules/@hamr/tui/dist/keybindings.js.map +1 -0
- package/node_modules/@hamr/tui/dist/keys.d.ts +184 -0
- package/node_modules/@hamr/tui/dist/keys.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/keys.js +1168 -0
- package/node_modules/@hamr/tui/dist/keys.js.map +1 -0
- package/node_modules/@hamr/tui/dist/kill-ring.d.ts +28 -0
- package/node_modules/@hamr/tui/dist/kill-ring.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/kill-ring.js +46 -0
- package/node_modules/@hamr/tui/dist/kill-ring.js.map +1 -0
- package/node_modules/@hamr/tui/dist/native-modifiers.d.ts +3 -0
- package/node_modules/@hamr/tui/dist/native-modifiers.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/native-modifiers.js +53 -0
- package/node_modules/@hamr/tui/dist/native-modifiers.js.map +1 -0
- package/node_modules/@hamr/tui/dist/stdin-buffer.d.ts +50 -0
- package/node_modules/@hamr/tui/dist/stdin-buffer.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/stdin-buffer.js +359 -0
- package/node_modules/@hamr/tui/dist/stdin-buffer.js.map +1 -0
- package/node_modules/@hamr/tui/dist/terminal-colors.d.ts +8 -0
- package/node_modules/@hamr/tui/dist/terminal-colors.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/terminal-colors.js +51 -0
- package/node_modules/@hamr/tui/dist/terminal-colors.js.map +1 -0
- package/node_modules/@hamr/tui/dist/terminal-image.d.ts +90 -0
- package/node_modules/@hamr/tui/dist/terminal-image.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/terminal-image.js +366 -0
- package/node_modules/@hamr/tui/dist/terminal-image.js.map +1 -0
- package/node_modules/@hamr/tui/dist/terminal.d.ts +110 -0
- package/node_modules/@hamr/tui/dist/terminal.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/terminal.js +429 -0
- package/node_modules/@hamr/tui/dist/terminal.js.map +1 -0
- package/node_modules/@hamr/tui/dist/tui.d.ts +255 -0
- package/node_modules/@hamr/tui/dist/tui.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/tui.js +1343 -0
- package/node_modules/@hamr/tui/dist/tui.js.map +1 -0
- package/node_modules/@hamr/tui/dist/undo-stack.d.ts +17 -0
- package/node_modules/@hamr/tui/dist/undo-stack.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/undo-stack.js +27 -0
- package/node_modules/@hamr/tui/dist/undo-stack.js.map +1 -0
- package/node_modules/@hamr/tui/dist/utils.d.ts +85 -0
- package/node_modules/@hamr/tui/dist/utils.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/utils.js +1062 -0
- package/node_modules/@hamr/tui/dist/utils.js.map +1 -0
- package/node_modules/@hamr/tui/dist/word-navigation.d.ts +25 -0
- package/node_modules/@hamr/tui/dist/word-navigation.d.ts.map +1 -0
- package/node_modules/@hamr/tui/dist/word-navigation.js +96 -0
- package/node_modules/@hamr/tui/dist/word-navigation.js.map +1 -0
- package/node_modules/@hamr/tui/package.json +42 -0
- package/node_modules/protobufjs/LICENSE +39 -0
- package/node_modules/protobufjs/README.md +727 -0
- package/node_modules/protobufjs/dist/light/protobuf.js +8041 -0
- package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -0
- package/node_modules/protobufjs/dist/light/protobuf.min.js +8 -0
- package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -0
- package/node_modules/protobufjs/dist/minimal/protobuf.js +2791 -0
- package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -0
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js +8 -0
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -0
- package/node_modules/protobufjs/dist/protobuf.js +9865 -0
- package/node_modules/protobufjs/dist/protobuf.js.map +1 -0
- package/node_modules/protobufjs/dist/protobuf.min.js +8 -0
- package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -0
- package/node_modules/protobufjs/ext/debug/README.md +4 -0
- package/node_modules/protobufjs/ext/debug/index.js +71 -0
- package/node_modules/protobufjs/ext/descriptor/README.md +72 -0
- package/node_modules/protobufjs/ext/descriptor/index.d.ts +195 -0
- package/node_modules/protobufjs/ext/descriptor/index.js +1186 -0
- package/node_modules/protobufjs/ext/descriptor/test.js +54 -0
- package/node_modules/protobufjs/google/LICENSE +27 -0
- package/node_modules/protobufjs/google/README.md +1 -0
- package/node_modules/protobufjs/google/api/annotations.json +83 -0
- package/node_modules/protobufjs/google/api/annotations.proto +11 -0
- package/node_modules/protobufjs/google/api/http.json +86 -0
- package/node_modules/protobufjs/google/api/http.proto +31 -0
- package/node_modules/protobufjs/google/protobuf/api.json +118 -0
- package/node_modules/protobufjs/google/protobuf/api.proto +34 -0
- package/node_modules/protobufjs/google/protobuf/descriptor.json +1382 -0
- package/node_modules/protobufjs/google/protobuf/descriptor.proto +535 -0
- package/node_modules/protobufjs/google/protobuf/source_context.json +20 -0
- package/node_modules/protobufjs/google/protobuf/source_context.proto +7 -0
- package/node_modules/protobufjs/google/protobuf/type.json +202 -0
- package/node_modules/protobufjs/google/protobuf/type.proto +89 -0
- package/node_modules/protobufjs/index.d.ts +2832 -0
- package/node_modules/protobufjs/index.js +4 -0
- package/node_modules/protobufjs/light.d.ts +2 -0
- package/node_modules/protobufjs/light.js +4 -0
- package/node_modules/protobufjs/minimal.d.ts +2 -0
- package/node_modules/protobufjs/minimal.js +4 -0
- package/node_modules/protobufjs/package.json +118 -0
- package/node_modules/protobufjs/scripts/postinstall.js +32 -0
- package/node_modules/protobufjs/src/common.js +399 -0
- package/node_modules/protobufjs/src/converter.js +318 -0
- package/node_modules/protobufjs/src/decoder.js +135 -0
- package/node_modules/protobufjs/src/encoder.js +103 -0
- package/node_modules/protobufjs/src/enum.js +226 -0
- package/node_modules/protobufjs/src/field.js +453 -0
- package/node_modules/protobufjs/src/index-light.js +104 -0
- package/node_modules/protobufjs/src/index-minimal.js +36 -0
- package/node_modules/protobufjs/src/index.js +12 -0
- package/node_modules/protobufjs/src/mapfield.js +126 -0
- package/node_modules/protobufjs/src/message.js +143 -0
- package/node_modules/protobufjs/src/method.js +160 -0
- package/node_modules/protobufjs/src/namespace.js +558 -0
- package/node_modules/protobufjs/src/object.js +382 -0
- package/node_modules/protobufjs/src/oneof.js +222 -0
- package/node_modules/protobufjs/src/parse.js +989 -0
- package/node_modules/protobufjs/src/reader.js +426 -0
- package/node_modules/protobufjs/src/reader_buffer.js +51 -0
- package/node_modules/protobufjs/src/root.js +412 -0
- package/node_modules/protobufjs/src/roots.js +18 -0
- package/node_modules/protobufjs/src/rpc/service.js +142 -0
- package/node_modules/protobufjs/src/rpc.js +36 -0
- package/node_modules/protobufjs/src/service.js +193 -0
- package/node_modules/protobufjs/src/tokenize.js +416 -0
- package/node_modules/protobufjs/src/type.js +632 -0
- package/node_modules/protobufjs/src/types.js +196 -0
- package/node_modules/protobufjs/src/typescript.jsdoc +15 -0
- package/node_modules/protobufjs/src/util/fs.js +11 -0
- package/node_modules/protobufjs/src/util/longbits.js +200 -0
- package/node_modules/protobufjs/src/util/minimal.js +491 -0
- package/node_modules/protobufjs/src/util/patterns.js +7 -0
- package/node_modules/protobufjs/src/util.js +230 -0
- package/node_modules/protobufjs/src/verifier.js +180 -0
- package/node_modules/protobufjs/src/wrappers.js +107 -0
- package/node_modules/protobufjs/src/writer.js +467 -0
- package/node_modules/protobufjs/src/writer_buffer.js +85 -0
- package/node_modules/protobufjs/tsconfig.json +8 -0
- package/package.json +91 -0
- package/skills/frontend-design.md +22 -0
- package/skills/using-hamr.md +38 -0
|
@@ -0,0 +1,1343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal TUI implementation with differential rendering
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from "node:fs";
|
|
5
|
+
import * as os from "node:os";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import { performance } from "node:perf_hooks";
|
|
8
|
+
import { isKeyRelease, matchesKey } from "./keys.js";
|
|
9
|
+
import { isOsc11BackgroundColorResponse, parseOsc11BackgroundColor } from "./terminal-colors.js";
|
|
10
|
+
import { deleteKittyImage, getCapabilities, isImageLine, setCellDimensions } from "./terminal-image.js";
|
|
11
|
+
import { extractSegments, normalizeTerminalOutput, sliceByColumn, sliceWithWidth, visibleWidth } from "./utils.js";
|
|
12
|
+
const KITTY_SEQUENCE_PREFIX = "\x1b_G";
|
|
13
|
+
function parseKittyImageHeader(line) {
|
|
14
|
+
const sequenceStart = line.indexOf(KITTY_SEQUENCE_PREFIX);
|
|
15
|
+
if (sequenceStart === -1)
|
|
16
|
+
return undefined;
|
|
17
|
+
const paramsStart = sequenceStart + KITTY_SEQUENCE_PREFIX.length;
|
|
18
|
+
const paramsEnd = line.indexOf(";", paramsStart);
|
|
19
|
+
if (paramsEnd === -1)
|
|
20
|
+
return undefined;
|
|
21
|
+
const ids = [];
|
|
22
|
+
let rows = 1;
|
|
23
|
+
const params = line.slice(paramsStart, paramsEnd);
|
|
24
|
+
for (const param of params.split(",")) {
|
|
25
|
+
const [key, value] = param.split("=", 2);
|
|
26
|
+
if (value === undefined)
|
|
27
|
+
continue;
|
|
28
|
+
const numberValue = Number(value);
|
|
29
|
+
if (!Number.isInteger(numberValue) || numberValue <= 0 || numberValue > 0xffffffff)
|
|
30
|
+
continue;
|
|
31
|
+
if (key === "i") {
|
|
32
|
+
ids.push(numberValue);
|
|
33
|
+
}
|
|
34
|
+
else if (key === "r") {
|
|
35
|
+
rows = numberValue;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return { ids, rows };
|
|
39
|
+
}
|
|
40
|
+
function extractKittyImageIds(line) {
|
|
41
|
+
return parseKittyImageHeader(line)?.ids ?? [];
|
|
42
|
+
}
|
|
43
|
+
function extractKittyImageRows(line) {
|
|
44
|
+
return parseKittyImageHeader(line)?.rows ?? 1;
|
|
45
|
+
}
|
|
46
|
+
/** Type guard to check if a component implements Focusable */
|
|
47
|
+
export function isFocusable(component) {
|
|
48
|
+
return component !== null && "focused" in component;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Cursor position marker - APC (Application Program Command) sequence.
|
|
52
|
+
* This is a zero-width escape sequence that terminals ignore.
|
|
53
|
+
* Components emit this at the cursor position when focused.
|
|
54
|
+
* TUI finds and strips this marker, then positions the hardware cursor there.
|
|
55
|
+
*/
|
|
56
|
+
export const CURSOR_MARKER = "\x1b_pi:c\x07";
|
|
57
|
+
export { visibleWidth };
|
|
58
|
+
/** Parse a SizeValue into absolute value given a reference size */
|
|
59
|
+
function parseSizeValue(value, referenceSize) {
|
|
60
|
+
if (value === undefined)
|
|
61
|
+
return undefined;
|
|
62
|
+
if (typeof value === "number")
|
|
63
|
+
return value;
|
|
64
|
+
// Parse percentage string like "50%"
|
|
65
|
+
const match = value.match(/^(\d+(?:\.\d+)?)%$/);
|
|
66
|
+
if (match) {
|
|
67
|
+
return Math.floor((referenceSize * parseFloat(match[1])) / 100);
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
function isTermuxSession() {
|
|
72
|
+
return Boolean(process.env.TERMUX_VERSION);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Container - a component that contains other components
|
|
76
|
+
*/
|
|
77
|
+
export class Container {
|
|
78
|
+
constructor() {
|
|
79
|
+
this.children = [];
|
|
80
|
+
}
|
|
81
|
+
addChild(component) {
|
|
82
|
+
this.children.push(component);
|
|
83
|
+
}
|
|
84
|
+
removeChild(component) {
|
|
85
|
+
const index = this.children.indexOf(component);
|
|
86
|
+
if (index !== -1) {
|
|
87
|
+
this.children.splice(index, 1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
clear() {
|
|
91
|
+
this.children = [];
|
|
92
|
+
}
|
|
93
|
+
invalidate() {
|
|
94
|
+
for (const child of this.children) {
|
|
95
|
+
child.invalidate?.();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
render(width) {
|
|
99
|
+
const lines = [];
|
|
100
|
+
for (const child of this.children) {
|
|
101
|
+
const childLines = child.render(width);
|
|
102
|
+
for (const line of childLines) {
|
|
103
|
+
lines.push(line);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return lines;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* TUI - Main class for managing terminal UI with differential rendering
|
|
111
|
+
*/
|
|
112
|
+
export class TUI extends Container {
|
|
113
|
+
static { this.MIN_RENDER_INTERVAL_MS = 16; }
|
|
114
|
+
constructor(terminal, showHardwareCursor) {
|
|
115
|
+
super();
|
|
116
|
+
this.previousLines = [];
|
|
117
|
+
this.previousKittyImageIds = new Set();
|
|
118
|
+
this.previousWidth = 0;
|
|
119
|
+
this.previousHeight = 0;
|
|
120
|
+
this.focusedComponent = null;
|
|
121
|
+
this.inputListeners = new Set();
|
|
122
|
+
this.renderRequested = false;
|
|
123
|
+
this.lastRenderAt = 0;
|
|
124
|
+
this.cursorRow = 0; // Logical cursor row (end of rendered content)
|
|
125
|
+
this.hardwareCursorRow = 0; // Actual terminal cursor row (may differ due to IME positioning)
|
|
126
|
+
this.showHardwareCursor = process.env.PI_HARDWARE_CURSOR === "1";
|
|
127
|
+
this.clearOnShrink = process.env.PI_CLEAR_ON_SHRINK === "1"; // Clear empty rows when content shrinks (default: off)
|
|
128
|
+
this.maxLinesRendered = 0; // Track terminal's working area (max lines ever rendered)
|
|
129
|
+
this.previousViewportTop = 0; // Track previous viewport top for resize-aware cursor moves
|
|
130
|
+
this.fullRedrawCount = 0;
|
|
131
|
+
this.stopped = false;
|
|
132
|
+
this.pendingOsc11BackgroundReplies = 0;
|
|
133
|
+
this.pendingOsc11BackgroundQueries = [];
|
|
134
|
+
// Overlay stack for modal components rendered on top of base content
|
|
135
|
+
this.focusOrderCounter = 0;
|
|
136
|
+
this.overlayStack = [];
|
|
137
|
+
this.overlayFocusRestore = { status: "inactive" };
|
|
138
|
+
this.terminal = terminal;
|
|
139
|
+
if (showHardwareCursor !== undefined) {
|
|
140
|
+
this.showHardwareCursor = showHardwareCursor;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
get fullRedraws() {
|
|
144
|
+
return this.fullRedrawCount;
|
|
145
|
+
}
|
|
146
|
+
getShowHardwareCursor() {
|
|
147
|
+
return this.showHardwareCursor;
|
|
148
|
+
}
|
|
149
|
+
setShowHardwareCursor(enabled) {
|
|
150
|
+
if (this.showHardwareCursor === enabled)
|
|
151
|
+
return;
|
|
152
|
+
this.showHardwareCursor = enabled;
|
|
153
|
+
if (!enabled) {
|
|
154
|
+
this.terminal.hideCursor();
|
|
155
|
+
}
|
|
156
|
+
this.requestRender();
|
|
157
|
+
}
|
|
158
|
+
getClearOnShrink() {
|
|
159
|
+
return this.clearOnShrink;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Set whether to trigger full re-render when content shrinks.
|
|
163
|
+
* When true (default), empty rows are cleared when content shrinks.
|
|
164
|
+
* When false, empty rows remain (reduces redraws on slower terminals).
|
|
165
|
+
*/
|
|
166
|
+
setClearOnShrink(enabled) {
|
|
167
|
+
this.clearOnShrink = enabled;
|
|
168
|
+
}
|
|
169
|
+
setFocus(component) {
|
|
170
|
+
this.setFocusInternal({ component, overlayFocusRestore: "clear" });
|
|
171
|
+
}
|
|
172
|
+
setFocusInternal({ component, overlayFocusRestore, }) {
|
|
173
|
+
const previousFocus = this.focusedComponent;
|
|
174
|
+
let nextFocus = component;
|
|
175
|
+
const previousFocusedOverlay = previousFocus
|
|
176
|
+
? this.overlayStack.find((entry) => entry.component === previousFocus && this.isOverlayVisible(entry))
|
|
177
|
+
: undefined;
|
|
178
|
+
const nextFocusIsOverlay = nextFocus ? this.overlayStack.some((entry) => entry.component === nextFocus) : false;
|
|
179
|
+
const restoreState = this.getVisibleOverlayFocusRestore();
|
|
180
|
+
if (nextFocus && !nextFocusIsOverlay) {
|
|
181
|
+
if (restoreState.status === "blocked" && restoreState.blockedBy === previousFocus) {
|
|
182
|
+
if (restoreState.resume.status === "focus-target" || !this.isComponentMounted(restoreState.blockedBy)) {
|
|
183
|
+
nextFocus = this.resolveBlockedOverlayFocusResume(restoreState);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
this.overlayFocusRestore = {
|
|
187
|
+
status: "blocked",
|
|
188
|
+
overlay: restoreState.overlay,
|
|
189
|
+
blockedBy: nextFocus,
|
|
190
|
+
resume: restoreState.resume,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
else if (previousFocusedOverlay &&
|
|
195
|
+
restoreState.status !== "inactive" &&
|
|
196
|
+
restoreState.overlay === previousFocusedOverlay &&
|
|
197
|
+
!this.isOverlayFocusAncestor(previousFocusedOverlay, nextFocus)) {
|
|
198
|
+
this.overlayFocusRestore = {
|
|
199
|
+
status: "blocked",
|
|
200
|
+
overlay: previousFocusedOverlay,
|
|
201
|
+
blockedBy: nextFocus,
|
|
202
|
+
resume: { status: "restore-overlay" },
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else if (nextFocus === null) {
|
|
207
|
+
if (restoreState.status === "blocked" && restoreState.blockedBy === previousFocus) {
|
|
208
|
+
nextFocus = this.resolveBlockedOverlayFocusResume(restoreState);
|
|
209
|
+
}
|
|
210
|
+
else if (overlayFocusRestore === "clear") {
|
|
211
|
+
this.clearOverlayFocusRestore();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (isFocusable(this.focusedComponent)) {
|
|
215
|
+
this.focusedComponent.focused = false;
|
|
216
|
+
}
|
|
217
|
+
this.focusedComponent = nextFocus;
|
|
218
|
+
if (isFocusable(nextFocus)) {
|
|
219
|
+
nextFocus.focused = true;
|
|
220
|
+
}
|
|
221
|
+
const focusedOverlay = nextFocus
|
|
222
|
+
? this.overlayStack.find((entry) => entry.component === nextFocus && this.isOverlayVisible(entry))
|
|
223
|
+
: undefined;
|
|
224
|
+
if (focusedOverlay) {
|
|
225
|
+
this.overlayFocusRestore = { status: "eligible", overlay: focusedOverlay };
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
clearOverlayFocusRestore() {
|
|
229
|
+
this.overlayFocusRestore = { status: "inactive" };
|
|
230
|
+
}
|
|
231
|
+
clearOverlayFocusRestoreFor(overlay) {
|
|
232
|
+
if (this.overlayFocusRestore.status !== "inactive" && this.overlayFocusRestore.overlay === overlay) {
|
|
233
|
+
this.clearOverlayFocusRestore();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
resolveBlockedOverlayFocusResume(restoreState) {
|
|
237
|
+
if (restoreState.resume.status === "restore-overlay")
|
|
238
|
+
return restoreState.overlay.component;
|
|
239
|
+
this.clearOverlayFocusRestore();
|
|
240
|
+
return restoreState.resume.target;
|
|
241
|
+
}
|
|
242
|
+
getVisibleOverlayFocusRestore() {
|
|
243
|
+
const restoreState = this.overlayFocusRestore;
|
|
244
|
+
if (restoreState.status === "inactive")
|
|
245
|
+
return restoreState;
|
|
246
|
+
if (!this.overlayStack.includes(restoreState.overlay) || !this.isOverlayVisible(restoreState.overlay)) {
|
|
247
|
+
return { status: "inactive" };
|
|
248
|
+
}
|
|
249
|
+
return restoreState;
|
|
250
|
+
}
|
|
251
|
+
isOverlayFocusAncestor(entry, component) {
|
|
252
|
+
const visited = new Set();
|
|
253
|
+
let current = entry.preFocus;
|
|
254
|
+
while (current && !visited.has(current)) {
|
|
255
|
+
visited.add(current);
|
|
256
|
+
if (current === component)
|
|
257
|
+
return true;
|
|
258
|
+
current = this.overlayStack.find((overlay) => overlay.component === current)?.preFocus ?? null;
|
|
259
|
+
}
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
retargetOverlayPreFocus(removed) {
|
|
263
|
+
for (const overlay of this.overlayStack) {
|
|
264
|
+
if (overlay !== removed && overlay.preFocus === removed.component) {
|
|
265
|
+
overlay.preFocus = removed.preFocus;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
isComponentMounted(component) {
|
|
270
|
+
return this.children.some((child) => this.containsComponent(child, component));
|
|
271
|
+
}
|
|
272
|
+
containsComponent(root, target) {
|
|
273
|
+
if (root === target)
|
|
274
|
+
return true;
|
|
275
|
+
if (!(root instanceof Container))
|
|
276
|
+
return false;
|
|
277
|
+
return root.children.some((child) => this.containsComponent(child, target));
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Show an overlay component with configurable positioning and sizing.
|
|
281
|
+
* Returns a handle to control the overlay's visibility.
|
|
282
|
+
*/
|
|
283
|
+
showOverlay(component, options) {
|
|
284
|
+
const entry = {
|
|
285
|
+
component,
|
|
286
|
+
...(options === undefined ? {} : { options }),
|
|
287
|
+
preFocus: this.focusedComponent,
|
|
288
|
+
hidden: false,
|
|
289
|
+
focusOrder: ++this.focusOrderCounter,
|
|
290
|
+
};
|
|
291
|
+
this.overlayStack.push(entry);
|
|
292
|
+
// Only focus if overlay is actually visible
|
|
293
|
+
if (!options?.nonCapturing && this.isOverlayVisible(entry)) {
|
|
294
|
+
this.setFocus(component);
|
|
295
|
+
}
|
|
296
|
+
this.terminal.hideCursor();
|
|
297
|
+
this.requestRender();
|
|
298
|
+
// Return handle for controlling this overlay
|
|
299
|
+
return {
|
|
300
|
+
hide: () => {
|
|
301
|
+
const index = this.overlayStack.indexOf(entry);
|
|
302
|
+
if (index !== -1) {
|
|
303
|
+
this.clearOverlayFocusRestoreFor(entry);
|
|
304
|
+
this.retargetOverlayPreFocus(entry);
|
|
305
|
+
this.overlayStack.splice(index, 1);
|
|
306
|
+
// Restore focus if this overlay had focus
|
|
307
|
+
if (this.focusedComponent === component) {
|
|
308
|
+
const topVisible = this.getTopmostVisibleOverlay();
|
|
309
|
+
this.setFocus(topVisible?.component ?? entry.preFocus);
|
|
310
|
+
}
|
|
311
|
+
if (this.overlayStack.length === 0)
|
|
312
|
+
this.terminal.hideCursor();
|
|
313
|
+
this.requestRender();
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
setHidden: (hidden) => {
|
|
317
|
+
if (entry.hidden === hidden)
|
|
318
|
+
return;
|
|
319
|
+
entry.hidden = hidden;
|
|
320
|
+
// Update focus when hiding/showing
|
|
321
|
+
if (hidden) {
|
|
322
|
+
this.clearOverlayFocusRestoreFor(entry);
|
|
323
|
+
// If this overlay had focus, move focus to next visible or preFocus
|
|
324
|
+
if (this.focusedComponent === component) {
|
|
325
|
+
const topVisible = this.getTopmostVisibleOverlay();
|
|
326
|
+
this.setFocus(topVisible?.component ?? entry.preFocus);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
// Restore focus to this overlay when showing (if it's actually visible)
|
|
331
|
+
if (!options?.nonCapturing && this.isOverlayVisible(entry)) {
|
|
332
|
+
entry.focusOrder = ++this.focusOrderCounter;
|
|
333
|
+
this.setFocus(component);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
this.requestRender();
|
|
337
|
+
},
|
|
338
|
+
isHidden: () => entry.hidden,
|
|
339
|
+
focus: () => {
|
|
340
|
+
if (!this.overlayStack.includes(entry) || !this.isOverlayVisible(entry))
|
|
341
|
+
return;
|
|
342
|
+
entry.focusOrder = ++this.focusOrderCounter;
|
|
343
|
+
this.setFocus(component);
|
|
344
|
+
this.requestRender();
|
|
345
|
+
},
|
|
346
|
+
unfocus: (unfocusOptions) => {
|
|
347
|
+
const isFocused = this.focusedComponent === component;
|
|
348
|
+
const restoreState = this.overlayFocusRestore;
|
|
349
|
+
const hasPendingRestore = restoreState.status !== "inactive" && restoreState.overlay === entry;
|
|
350
|
+
if (!isFocused && !hasPendingRestore)
|
|
351
|
+
return;
|
|
352
|
+
if (restoreState.status === "blocked" &&
|
|
353
|
+
restoreState.overlay === entry &&
|
|
354
|
+
this.focusedComponent === restoreState.blockedBy) {
|
|
355
|
+
if (unfocusOptions) {
|
|
356
|
+
this.overlayFocusRestore = {
|
|
357
|
+
status: "blocked",
|
|
358
|
+
overlay: entry,
|
|
359
|
+
blockedBy: restoreState.blockedBy,
|
|
360
|
+
resume: { status: "focus-target", target: unfocusOptions.target },
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
this.clearOverlayFocusRestore();
|
|
365
|
+
}
|
|
366
|
+
this.requestRender();
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
this.clearOverlayFocusRestoreFor(entry);
|
|
370
|
+
if (isFocused || unfocusOptions) {
|
|
371
|
+
const topVisible = this.getTopmostVisibleOverlay();
|
|
372
|
+
const fallbackTarget = topVisible && topVisible !== entry ? topVisible.component : entry.preFocus;
|
|
373
|
+
this.setFocus(unfocusOptions ? unfocusOptions.target : fallbackTarget);
|
|
374
|
+
}
|
|
375
|
+
this.requestRender();
|
|
376
|
+
},
|
|
377
|
+
isFocused: () => this.focusedComponent === component,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
/** Hide the topmost overlay and restore previous focus. */
|
|
381
|
+
hideOverlay() {
|
|
382
|
+
const overlay = this.overlayStack[this.overlayStack.length - 1];
|
|
383
|
+
if (!overlay)
|
|
384
|
+
return;
|
|
385
|
+
this.clearOverlayFocusRestoreFor(overlay);
|
|
386
|
+
this.retargetOverlayPreFocus(overlay);
|
|
387
|
+
this.overlayStack.pop();
|
|
388
|
+
if (this.focusedComponent === overlay.component) {
|
|
389
|
+
// Find topmost visible overlay, or fall back to preFocus
|
|
390
|
+
const topVisible = this.getTopmostVisibleOverlay();
|
|
391
|
+
this.setFocus(topVisible?.component ?? overlay.preFocus);
|
|
392
|
+
}
|
|
393
|
+
if (this.overlayStack.length === 0)
|
|
394
|
+
this.terminal.hideCursor();
|
|
395
|
+
this.requestRender();
|
|
396
|
+
}
|
|
397
|
+
/** Check if there are any visible overlays */
|
|
398
|
+
hasOverlay() {
|
|
399
|
+
return this.overlayStack.some((o) => this.isOverlayVisible(o));
|
|
400
|
+
}
|
|
401
|
+
/** Check if an overlay entry is currently visible */
|
|
402
|
+
isOverlayVisible(entry) {
|
|
403
|
+
if (entry.hidden)
|
|
404
|
+
return false;
|
|
405
|
+
if (entry.options?.visible) {
|
|
406
|
+
return entry.options.visible(this.terminal.columns, this.terminal.rows);
|
|
407
|
+
}
|
|
408
|
+
return true;
|
|
409
|
+
}
|
|
410
|
+
/** Find the visual-frontmost visible capturing overlay, if any */
|
|
411
|
+
getTopmostVisibleOverlay() {
|
|
412
|
+
let topmost;
|
|
413
|
+
for (const overlay of this.overlayStack) {
|
|
414
|
+
if (overlay.options?.nonCapturing || !this.isOverlayVisible(overlay))
|
|
415
|
+
continue;
|
|
416
|
+
if (!topmost || overlay.focusOrder > topmost.focusOrder) {
|
|
417
|
+
topmost = overlay;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return topmost;
|
|
421
|
+
}
|
|
422
|
+
invalidate() {
|
|
423
|
+
super.invalidate();
|
|
424
|
+
for (const overlay of this.overlayStack)
|
|
425
|
+
overlay.component.invalidate?.();
|
|
426
|
+
}
|
|
427
|
+
start() {
|
|
428
|
+
this.stopped = false;
|
|
429
|
+
this.terminal.start((data) => this.handleInput(data), () => this.requestRender());
|
|
430
|
+
this.terminal.hideCursor();
|
|
431
|
+
this.queryCellSize();
|
|
432
|
+
this.requestRender();
|
|
433
|
+
}
|
|
434
|
+
addInputListener(listener) {
|
|
435
|
+
this.inputListeners.add(listener);
|
|
436
|
+
return () => {
|
|
437
|
+
this.inputListeners.delete(listener);
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
removeInputListener(listener) {
|
|
441
|
+
this.inputListeners.delete(listener);
|
|
442
|
+
}
|
|
443
|
+
queryCellSize() {
|
|
444
|
+
// Only query if terminal supports images (cell size is only used for image rendering)
|
|
445
|
+
if (!getCapabilities().images) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
// Query terminal for cell size in pixels: CSI 16 t
|
|
449
|
+
// Response format: CSI 6 ; height ; width t
|
|
450
|
+
this.terminal.write("\x1b[16t");
|
|
451
|
+
}
|
|
452
|
+
stop() {
|
|
453
|
+
this.stopped = true;
|
|
454
|
+
if (this.renderTimer) {
|
|
455
|
+
clearTimeout(this.renderTimer);
|
|
456
|
+
this.renderTimer = undefined;
|
|
457
|
+
}
|
|
458
|
+
// Move cursor to the end of the content to prevent overwriting/artifacts on exit
|
|
459
|
+
if (this.previousLines.length > 0) {
|
|
460
|
+
const targetRow = this.previousLines.length; // Line after the last content
|
|
461
|
+
const lineDiff = targetRow - this.hardwareCursorRow;
|
|
462
|
+
if (lineDiff > 0) {
|
|
463
|
+
this.terminal.write(`\x1b[${lineDiff}B`);
|
|
464
|
+
}
|
|
465
|
+
else if (lineDiff < 0) {
|
|
466
|
+
this.terminal.write(`\x1b[${-lineDiff}A`);
|
|
467
|
+
}
|
|
468
|
+
this.terminal.write("\r\n");
|
|
469
|
+
}
|
|
470
|
+
this.terminal.showCursor();
|
|
471
|
+
this.terminal.stop();
|
|
472
|
+
}
|
|
473
|
+
requestRender(force = false) {
|
|
474
|
+
if (force) {
|
|
475
|
+
this.previousLines = [];
|
|
476
|
+
this.previousWidth = -1; // -1 triggers widthChanged, forcing a full clear
|
|
477
|
+
this.previousHeight = -1; // -1 triggers heightChanged, forcing a full clear
|
|
478
|
+
this.cursorRow = 0;
|
|
479
|
+
this.hardwareCursorRow = 0;
|
|
480
|
+
this.maxLinesRendered = 0;
|
|
481
|
+
this.previousViewportTop = 0;
|
|
482
|
+
if (this.renderTimer) {
|
|
483
|
+
clearTimeout(this.renderTimer);
|
|
484
|
+
this.renderTimer = undefined;
|
|
485
|
+
}
|
|
486
|
+
this.renderRequested = true;
|
|
487
|
+
process.nextTick(() => {
|
|
488
|
+
if (this.stopped || !this.renderRequested) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
this.renderRequested = false;
|
|
492
|
+
this.lastRenderAt = performance.now();
|
|
493
|
+
this.doRender();
|
|
494
|
+
});
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
if (this.renderRequested)
|
|
498
|
+
return;
|
|
499
|
+
this.renderRequested = true;
|
|
500
|
+
process.nextTick(() => this.scheduleRender());
|
|
501
|
+
}
|
|
502
|
+
scheduleRender() {
|
|
503
|
+
if (this.stopped || this.renderTimer || !this.renderRequested) {
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
const elapsed = performance.now() - this.lastRenderAt;
|
|
507
|
+
const delay = Math.max(0, TUI.MIN_RENDER_INTERVAL_MS - elapsed);
|
|
508
|
+
this.renderTimer = setTimeout(() => {
|
|
509
|
+
this.renderTimer = undefined;
|
|
510
|
+
if (this.stopped || !this.renderRequested) {
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
this.renderRequested = false;
|
|
514
|
+
this.lastRenderAt = performance.now();
|
|
515
|
+
this.doRender();
|
|
516
|
+
if (this.renderRequested) {
|
|
517
|
+
this.scheduleRender();
|
|
518
|
+
}
|
|
519
|
+
}, delay);
|
|
520
|
+
}
|
|
521
|
+
handleInput(data) {
|
|
522
|
+
if (this.consumeOsc11BackgroundResponse(data)) {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
if (this.inputListeners.size > 0) {
|
|
526
|
+
let current = data;
|
|
527
|
+
for (const listener of this.inputListeners) {
|
|
528
|
+
const result = listener(current);
|
|
529
|
+
if (result?.consume) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
if (result?.data !== undefined) {
|
|
533
|
+
current = result.data;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
if (current.length === 0) {
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
data = current;
|
|
540
|
+
}
|
|
541
|
+
// Consume terminal cell size responses without blocking unrelated input.
|
|
542
|
+
if (this.consumeCellSizeResponse(data)) {
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
// Global debug key handler (Shift+Ctrl+D)
|
|
546
|
+
if (matchesKey(data, "shift+ctrl+d") && this.onDebug) {
|
|
547
|
+
this.onDebug();
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
// If focused component is an overlay, verify it's still visible
|
|
551
|
+
// (visibility can change due to terminal resize or visible() callback)
|
|
552
|
+
const focusedOverlay = this.overlayStack.find((o) => o.component === this.focusedComponent);
|
|
553
|
+
if (focusedOverlay && !this.isOverlayVisible(focusedOverlay)) {
|
|
554
|
+
// Focused overlay is no longer visible, redirect to topmost visible overlay
|
|
555
|
+
const topVisible = this.getTopmostVisibleOverlay();
|
|
556
|
+
if (topVisible) {
|
|
557
|
+
this.setFocus(topVisible.component);
|
|
558
|
+
}
|
|
559
|
+
else {
|
|
560
|
+
this.setFocusInternal({ component: focusedOverlay.preFocus, overlayFocusRestore: "preserve" });
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
const focusIsOverlay = this.overlayStack.some((o) => o.component === this.focusedComponent);
|
|
564
|
+
if (!focusIsOverlay) {
|
|
565
|
+
const restoreState = this.getVisibleOverlayFocusRestore();
|
|
566
|
+
if (restoreState.status === "eligible") {
|
|
567
|
+
this.setFocus(restoreState.overlay.component);
|
|
568
|
+
}
|
|
569
|
+
else if (restoreState.status === "blocked" && restoreState.blockedBy !== this.focusedComponent) {
|
|
570
|
+
if (restoreState.resume.status === "restore-overlay") {
|
|
571
|
+
this.setFocus(restoreState.overlay.component);
|
|
572
|
+
}
|
|
573
|
+
else {
|
|
574
|
+
this.clearOverlayFocusRestore();
|
|
575
|
+
this.setFocus(restoreState.resume.target);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
// Pass input to focused component (including Ctrl+C)
|
|
580
|
+
// The focused component can decide how to handle Ctrl+C
|
|
581
|
+
if (this.focusedComponent?.handleInput) {
|
|
582
|
+
// Filter out key release events unless component opts in
|
|
583
|
+
if (isKeyRelease(data) && !this.focusedComponent.wantsKeyRelease) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
this.focusedComponent.handleInput(data);
|
|
587
|
+
this.requestRender();
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
consumeOsc11BackgroundResponse(data) {
|
|
591
|
+
if (this.pendingOsc11BackgroundReplies <= 0) {
|
|
592
|
+
return false;
|
|
593
|
+
}
|
|
594
|
+
if (!isOsc11BackgroundColorResponse(data)) {
|
|
595
|
+
return false;
|
|
596
|
+
}
|
|
597
|
+
const rgb = parseOsc11BackgroundColor(data);
|
|
598
|
+
this.pendingOsc11BackgroundReplies -= 1;
|
|
599
|
+
const query = this.pendingOsc11BackgroundQueries.shift();
|
|
600
|
+
if (query && !query.settled) {
|
|
601
|
+
query.settled = true;
|
|
602
|
+
if (query.timer) {
|
|
603
|
+
clearTimeout(query.timer);
|
|
604
|
+
query.timer = undefined;
|
|
605
|
+
}
|
|
606
|
+
query.resolve?.(rgb);
|
|
607
|
+
query.resolve = undefined;
|
|
608
|
+
}
|
|
609
|
+
return true;
|
|
610
|
+
}
|
|
611
|
+
consumeCellSizeResponse(data) {
|
|
612
|
+
// Response format: ESC [ 6 ; height ; width t
|
|
613
|
+
const match = data.match(/^\x1b\[6;(\d+);(\d+)t$/);
|
|
614
|
+
if (!match) {
|
|
615
|
+
return false;
|
|
616
|
+
}
|
|
617
|
+
const heightPx = parseInt(match[1], 10);
|
|
618
|
+
const widthPx = parseInt(match[2], 10);
|
|
619
|
+
if (heightPx <= 0 || widthPx <= 0) {
|
|
620
|
+
return true;
|
|
621
|
+
}
|
|
622
|
+
setCellDimensions({ widthPx, heightPx });
|
|
623
|
+
// Invalidate all components so images re-render with correct dimensions.
|
|
624
|
+
this.invalidate();
|
|
625
|
+
this.requestRender();
|
|
626
|
+
return true;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Resolve overlay layout from options.
|
|
630
|
+
* Returns { width, row, col, maxHeight } for rendering.
|
|
631
|
+
*/
|
|
632
|
+
resolveOverlayLayout(options, overlayHeight, termWidth, termHeight) {
|
|
633
|
+
const opt = options ?? {};
|
|
634
|
+
// Parse margin (clamp to non-negative)
|
|
635
|
+
const margin = typeof opt.margin === "number"
|
|
636
|
+
? { top: opt.margin, right: opt.margin, bottom: opt.margin, left: opt.margin }
|
|
637
|
+
: (opt.margin ?? {});
|
|
638
|
+
const marginTop = Math.max(0, margin.top ?? 0);
|
|
639
|
+
const marginRight = Math.max(0, margin.right ?? 0);
|
|
640
|
+
const marginBottom = Math.max(0, margin.bottom ?? 0);
|
|
641
|
+
const marginLeft = Math.max(0, margin.left ?? 0);
|
|
642
|
+
// Available space after margins
|
|
643
|
+
const availWidth = Math.max(1, termWidth - marginLeft - marginRight);
|
|
644
|
+
const availHeight = Math.max(1, termHeight - marginTop - marginBottom);
|
|
645
|
+
// === Resolve width ===
|
|
646
|
+
let width = parseSizeValue(opt.width, termWidth) ?? Math.min(80, availWidth);
|
|
647
|
+
// Apply minWidth
|
|
648
|
+
if (opt.minWidth !== undefined) {
|
|
649
|
+
width = Math.max(width, opt.minWidth);
|
|
650
|
+
}
|
|
651
|
+
// Clamp to available space
|
|
652
|
+
width = Math.max(1, Math.min(width, availWidth));
|
|
653
|
+
// === Resolve maxHeight ===
|
|
654
|
+
let maxHeight = parseSizeValue(opt.maxHeight, termHeight);
|
|
655
|
+
// Clamp to available space
|
|
656
|
+
if (maxHeight !== undefined) {
|
|
657
|
+
maxHeight = Math.max(1, Math.min(maxHeight, availHeight));
|
|
658
|
+
}
|
|
659
|
+
// Effective overlay height (may be clamped by maxHeight)
|
|
660
|
+
const effectiveHeight = maxHeight !== undefined ? Math.min(overlayHeight, maxHeight) : overlayHeight;
|
|
661
|
+
// === Resolve position ===
|
|
662
|
+
let row;
|
|
663
|
+
let col;
|
|
664
|
+
if (opt.row !== undefined) {
|
|
665
|
+
if (typeof opt.row === "string") {
|
|
666
|
+
// Percentage: 0% = top, 100% = bottom (overlay stays within bounds)
|
|
667
|
+
const match = opt.row.match(/^(\d+(?:\.\d+)?)%$/);
|
|
668
|
+
if (match) {
|
|
669
|
+
const maxRow = Math.max(0, availHeight - effectiveHeight);
|
|
670
|
+
const percent = parseFloat(match[1]) / 100;
|
|
671
|
+
row = marginTop + Math.floor(maxRow * percent);
|
|
672
|
+
}
|
|
673
|
+
else {
|
|
674
|
+
// Invalid format, fall back to center
|
|
675
|
+
row = this.resolveAnchorRow("center", effectiveHeight, availHeight, marginTop);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
else {
|
|
679
|
+
// Absolute row position
|
|
680
|
+
row = opt.row;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
// Anchor-based (default: center)
|
|
685
|
+
const anchor = opt.anchor ?? "center";
|
|
686
|
+
row = this.resolveAnchorRow(anchor, effectiveHeight, availHeight, marginTop);
|
|
687
|
+
}
|
|
688
|
+
if (opt.col !== undefined) {
|
|
689
|
+
if (typeof opt.col === "string") {
|
|
690
|
+
// Percentage: 0% = left, 100% = right (overlay stays within bounds)
|
|
691
|
+
const match = opt.col.match(/^(\d+(?:\.\d+)?)%$/);
|
|
692
|
+
if (match) {
|
|
693
|
+
const maxCol = Math.max(0, availWidth - width);
|
|
694
|
+
const percent = parseFloat(match[1]) / 100;
|
|
695
|
+
col = marginLeft + Math.floor(maxCol * percent);
|
|
696
|
+
}
|
|
697
|
+
else {
|
|
698
|
+
// Invalid format, fall back to center
|
|
699
|
+
col = this.resolveAnchorCol("center", width, availWidth, marginLeft);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
else {
|
|
703
|
+
// Absolute column position
|
|
704
|
+
col = opt.col;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
else {
|
|
708
|
+
// Anchor-based (default: center)
|
|
709
|
+
const anchor = opt.anchor ?? "center";
|
|
710
|
+
col = this.resolveAnchorCol(anchor, width, availWidth, marginLeft);
|
|
711
|
+
}
|
|
712
|
+
// Apply offsets
|
|
713
|
+
if (opt.offsetY !== undefined)
|
|
714
|
+
row += opt.offsetY;
|
|
715
|
+
if (opt.offsetX !== undefined)
|
|
716
|
+
col += opt.offsetX;
|
|
717
|
+
// Clamp to terminal bounds (respecting margins)
|
|
718
|
+
row = Math.max(marginTop, Math.min(row, termHeight - marginBottom - effectiveHeight));
|
|
719
|
+
col = Math.max(marginLeft, Math.min(col, termWidth - marginRight - width));
|
|
720
|
+
return { width, row, col, maxHeight };
|
|
721
|
+
}
|
|
722
|
+
resolveAnchorRow(anchor, height, availHeight, marginTop) {
|
|
723
|
+
switch (anchor) {
|
|
724
|
+
case "top-left":
|
|
725
|
+
case "top-center":
|
|
726
|
+
case "top-right":
|
|
727
|
+
return marginTop;
|
|
728
|
+
case "bottom-left":
|
|
729
|
+
case "bottom-center":
|
|
730
|
+
case "bottom-right":
|
|
731
|
+
return marginTop + availHeight - height;
|
|
732
|
+
case "left-center":
|
|
733
|
+
case "center":
|
|
734
|
+
case "right-center":
|
|
735
|
+
return marginTop + Math.floor((availHeight - height) / 2);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
resolveAnchorCol(anchor, width, availWidth, marginLeft) {
|
|
739
|
+
switch (anchor) {
|
|
740
|
+
case "top-left":
|
|
741
|
+
case "left-center":
|
|
742
|
+
case "bottom-left":
|
|
743
|
+
return marginLeft;
|
|
744
|
+
case "top-right":
|
|
745
|
+
case "right-center":
|
|
746
|
+
case "bottom-right":
|
|
747
|
+
return marginLeft + availWidth - width;
|
|
748
|
+
case "top-center":
|
|
749
|
+
case "center":
|
|
750
|
+
case "bottom-center":
|
|
751
|
+
return marginLeft + Math.floor((availWidth - width) / 2);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
/** Composite all overlays into content lines (sorted by focusOrder, higher = on top). */
|
|
755
|
+
compositeOverlays(lines, termWidth, termHeight) {
|
|
756
|
+
if (this.overlayStack.length === 0)
|
|
757
|
+
return lines;
|
|
758
|
+
const result = [...lines];
|
|
759
|
+
// Pre-render all visible overlays and calculate positions
|
|
760
|
+
const rendered = [];
|
|
761
|
+
let minLinesNeeded = result.length;
|
|
762
|
+
const visibleEntries = this.overlayStack.filter((e) => this.isOverlayVisible(e));
|
|
763
|
+
visibleEntries.sort((a, b) => a.focusOrder - b.focusOrder);
|
|
764
|
+
for (const entry of visibleEntries) {
|
|
765
|
+
const { component, options } = entry;
|
|
766
|
+
// Get layout with height=0 first to determine width and maxHeight
|
|
767
|
+
// (width and maxHeight don't depend on overlay height)
|
|
768
|
+
const { width, maxHeight } = this.resolveOverlayLayout(options, 0, termWidth, termHeight);
|
|
769
|
+
// Render component at calculated width
|
|
770
|
+
let overlayLines = component.render(width);
|
|
771
|
+
// Apply maxHeight if specified
|
|
772
|
+
if (maxHeight !== undefined && overlayLines.length > maxHeight) {
|
|
773
|
+
overlayLines = overlayLines.slice(0, maxHeight);
|
|
774
|
+
}
|
|
775
|
+
// Get final row/col with actual overlay height
|
|
776
|
+
const { row, col } = this.resolveOverlayLayout(options, overlayLines.length, termWidth, termHeight);
|
|
777
|
+
rendered.push({ overlayLines, row, col, w: width });
|
|
778
|
+
minLinesNeeded = Math.max(minLinesNeeded, row + overlayLines.length);
|
|
779
|
+
}
|
|
780
|
+
// Pad to at least terminal height so overlays have screen-relative positions.
|
|
781
|
+
// Excludes maxLinesRendered: the historical high-water mark caused self-reinforcing
|
|
782
|
+
// inflation that pushed content into scrollback on terminal widen.
|
|
783
|
+
const workingHeight = Math.max(result.length, termHeight, minLinesNeeded);
|
|
784
|
+
// Extend result with empty lines if content is too short for overlay placement or working area
|
|
785
|
+
while (result.length < workingHeight) {
|
|
786
|
+
result.push("");
|
|
787
|
+
}
|
|
788
|
+
const viewportStart = Math.max(0, workingHeight - termHeight);
|
|
789
|
+
// Composite each overlay
|
|
790
|
+
for (const { overlayLines, row, col, w } of rendered) {
|
|
791
|
+
for (let i = 0; i < overlayLines.length; i++) {
|
|
792
|
+
const idx = viewportStart + row + i;
|
|
793
|
+
if (idx >= 0 && idx < result.length) {
|
|
794
|
+
// Defensive: truncate overlay line to declared width before compositing
|
|
795
|
+
// (components should already respect width, but this ensures it)
|
|
796
|
+
const truncatedOverlayLine = visibleWidth(overlayLines[i]) > w ? sliceByColumn(overlayLines[i], 0, w, true) : overlayLines[i];
|
|
797
|
+
result[idx] = this.compositeLineAt(result[idx], truncatedOverlayLine, col, w, termWidth);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
return result;
|
|
802
|
+
}
|
|
803
|
+
static { this.SEGMENT_RESET = "\x1b[0m\x1b]8;;\x07"; }
|
|
804
|
+
applyLineResets(lines) {
|
|
805
|
+
const reset = TUI.SEGMENT_RESET;
|
|
806
|
+
for (let i = 0; i < lines.length; i++) {
|
|
807
|
+
const line = lines[i];
|
|
808
|
+
if (!isImageLine(line)) {
|
|
809
|
+
lines[i] = normalizeTerminalOutput(line) + reset;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return lines;
|
|
813
|
+
}
|
|
814
|
+
collectKittyImageIds(lines) {
|
|
815
|
+
const ids = new Set();
|
|
816
|
+
for (const line of lines) {
|
|
817
|
+
for (const id of extractKittyImageIds(line)) {
|
|
818
|
+
ids.add(id);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
return ids;
|
|
822
|
+
}
|
|
823
|
+
deleteKittyImages(ids) {
|
|
824
|
+
let buffer = "";
|
|
825
|
+
for (const id of ids) {
|
|
826
|
+
buffer += deleteKittyImage(id);
|
|
827
|
+
}
|
|
828
|
+
return buffer;
|
|
829
|
+
}
|
|
830
|
+
getKittyImageReservedRows(lines, index, maxIndex = lines.length - 1) {
|
|
831
|
+
const rows = extractKittyImageRows(lines[index] ?? "");
|
|
832
|
+
if (rows <= 1)
|
|
833
|
+
return 1;
|
|
834
|
+
const maxRows = Math.min(rows, maxIndex - index + 1, lines.length - index);
|
|
835
|
+
let reservedRows = 1;
|
|
836
|
+
while (reservedRows < maxRows) {
|
|
837
|
+
const line = lines[index + reservedRows] ?? "";
|
|
838
|
+
if (isImageLine(line) || visibleWidth(line) > 0)
|
|
839
|
+
break;
|
|
840
|
+
reservedRows++;
|
|
841
|
+
}
|
|
842
|
+
return reservedRows;
|
|
843
|
+
}
|
|
844
|
+
expandChangedRangeForKittyImages(firstChanged, lastChanged, newLines) {
|
|
845
|
+
let expandedFirstChanged = firstChanged;
|
|
846
|
+
let expandedLastChanged = lastChanged;
|
|
847
|
+
const expandForLines = (lines) => {
|
|
848
|
+
for (let i = 0; i < lines.length; i++) {
|
|
849
|
+
if (extractKittyImageIds(lines[i]).length === 0)
|
|
850
|
+
continue;
|
|
851
|
+
const blockEnd = i + this.getKittyImageReservedRows(lines, i) - 1;
|
|
852
|
+
if (i >= firstChanged || (i <= lastChanged && blockEnd >= firstChanged)) {
|
|
853
|
+
expandedFirstChanged = Math.min(expandedFirstChanged, i);
|
|
854
|
+
expandedLastChanged = Math.max(expandedLastChanged, blockEnd);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
expandForLines(this.previousLines);
|
|
859
|
+
expandForLines(newLines);
|
|
860
|
+
return { firstChanged: expandedFirstChanged, lastChanged: expandedLastChanged };
|
|
861
|
+
}
|
|
862
|
+
deleteChangedKittyImages(firstChanged, lastChanged) {
|
|
863
|
+
if (firstChanged < 0 || lastChanged < firstChanged)
|
|
864
|
+
return "";
|
|
865
|
+
const ids = new Set();
|
|
866
|
+
const maxLine = Math.min(lastChanged, this.previousLines.length - 1);
|
|
867
|
+
for (let i = firstChanged; i <= maxLine; i++) {
|
|
868
|
+
for (const id of extractKittyImageIds(this.previousLines[i] ?? "")) {
|
|
869
|
+
ids.add(id);
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
return this.deleteKittyImages(ids);
|
|
873
|
+
}
|
|
874
|
+
/** Splice overlay content into a base line at a specific column. Single-pass optimized. */
|
|
875
|
+
compositeLineAt(baseLine, overlayLine, startCol, overlayWidth, totalWidth) {
|
|
876
|
+
if (isImageLine(baseLine))
|
|
877
|
+
return baseLine;
|
|
878
|
+
// Single pass through baseLine extracts both before and after segments
|
|
879
|
+
const afterStart = startCol + overlayWidth;
|
|
880
|
+
const base = extractSegments(baseLine, startCol, afterStart, totalWidth - afterStart, true);
|
|
881
|
+
// Extract overlay with width tracking (strict=true to exclude wide chars at boundary)
|
|
882
|
+
const overlay = sliceWithWidth(overlayLine, 0, overlayWidth, true);
|
|
883
|
+
// Pad segments to target widths
|
|
884
|
+
const beforePad = Math.max(0, startCol - base.beforeWidth);
|
|
885
|
+
const overlayPad = Math.max(0, overlayWidth - overlay.width);
|
|
886
|
+
const actualBeforeWidth = Math.max(startCol, base.beforeWidth);
|
|
887
|
+
const actualOverlayWidth = Math.max(overlayWidth, overlay.width);
|
|
888
|
+
const afterTarget = Math.max(0, totalWidth - actualBeforeWidth - actualOverlayWidth);
|
|
889
|
+
const afterPad = Math.max(0, afterTarget - base.afterWidth);
|
|
890
|
+
// Compose result
|
|
891
|
+
const r = TUI.SEGMENT_RESET;
|
|
892
|
+
const result = base.before +
|
|
893
|
+
" ".repeat(beforePad) +
|
|
894
|
+
r +
|
|
895
|
+
overlay.text +
|
|
896
|
+
" ".repeat(overlayPad) +
|
|
897
|
+
r +
|
|
898
|
+
base.after +
|
|
899
|
+
" ".repeat(afterPad);
|
|
900
|
+
// CRITICAL: Always verify and truncate to terminal width.
|
|
901
|
+
// This is the final safeguard against width overflow which would crash the TUI.
|
|
902
|
+
// Width tracking can drift from actual visible width due to:
|
|
903
|
+
// - Complex ANSI/OSC sequences (hyperlinks, colors)
|
|
904
|
+
// - Wide characters at segment boundaries
|
|
905
|
+
// - Edge cases in segment extraction
|
|
906
|
+
const resultWidth = visibleWidth(result);
|
|
907
|
+
if (resultWidth <= totalWidth) {
|
|
908
|
+
return result;
|
|
909
|
+
}
|
|
910
|
+
// Truncate with strict=true to ensure we don't exceed totalWidth
|
|
911
|
+
return sliceByColumn(result, 0, totalWidth, true);
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Find and extract cursor position from rendered lines.
|
|
915
|
+
* Searches for CURSOR_MARKER, calculates its position, and strips it from the output.
|
|
916
|
+
* Only scans the bottom terminal height lines (visible viewport).
|
|
917
|
+
* @param lines - Rendered lines to search
|
|
918
|
+
* @param height - Terminal height (visible viewport size)
|
|
919
|
+
* @returns Cursor position { row, col } or null if no marker found
|
|
920
|
+
*/
|
|
921
|
+
extractCursorPosition(lines, height) {
|
|
922
|
+
// Only scan the bottom `height` lines (visible viewport)
|
|
923
|
+
const viewportTop = Math.max(0, lines.length - height);
|
|
924
|
+
for (let row = lines.length - 1; row >= viewportTop; row--) {
|
|
925
|
+
const line = lines[row];
|
|
926
|
+
const markerIndex = line.indexOf(CURSOR_MARKER);
|
|
927
|
+
if (markerIndex !== -1) {
|
|
928
|
+
// Calculate visual column (width of text before marker)
|
|
929
|
+
const beforeMarker = line.slice(0, markerIndex);
|
|
930
|
+
const col = visibleWidth(beforeMarker);
|
|
931
|
+
// Strip marker from the line
|
|
932
|
+
lines[row] = line.slice(0, markerIndex) + line.slice(markerIndex + CURSOR_MARKER.length);
|
|
933
|
+
return { row, col };
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
return null;
|
|
937
|
+
}
|
|
938
|
+
doRender() {
|
|
939
|
+
if (this.stopped)
|
|
940
|
+
return;
|
|
941
|
+
const width = this.terminal.columns;
|
|
942
|
+
const height = this.terminal.rows;
|
|
943
|
+
const widthChanged = this.previousWidth !== 0 && this.previousWidth !== width;
|
|
944
|
+
const heightChanged = this.previousHeight !== 0 && this.previousHeight !== height;
|
|
945
|
+
const previousBufferLength = this.previousHeight > 0 ? this.previousViewportTop + this.previousHeight : height;
|
|
946
|
+
let prevViewportTop = heightChanged ? Math.max(0, previousBufferLength - height) : this.previousViewportTop;
|
|
947
|
+
let viewportTop = prevViewportTop;
|
|
948
|
+
let hardwareCursorRow = this.hardwareCursorRow;
|
|
949
|
+
const computeLineDiff = (targetRow) => {
|
|
950
|
+
const currentScreenRow = hardwareCursorRow - prevViewportTop;
|
|
951
|
+
const targetScreenRow = targetRow - viewportTop;
|
|
952
|
+
return targetScreenRow - currentScreenRow;
|
|
953
|
+
};
|
|
954
|
+
// Render all components to get new lines
|
|
955
|
+
let newLines = this.render(width);
|
|
956
|
+
// Composite overlays into the rendered lines (before differential compare)
|
|
957
|
+
if (this.overlayStack.length > 0) {
|
|
958
|
+
newLines = this.compositeOverlays(newLines, width, height);
|
|
959
|
+
}
|
|
960
|
+
// Extract cursor position before applying line resets (marker must be found first)
|
|
961
|
+
const cursorPos = this.extractCursorPosition(newLines, height);
|
|
962
|
+
newLines = this.applyLineResets(newLines);
|
|
963
|
+
// Helper to clear scrollback and viewport and render all new lines
|
|
964
|
+
const fullRender = (clear) => {
|
|
965
|
+
this.fullRedrawCount += 1;
|
|
966
|
+
let buffer = "\x1b[?2026h"; // Begin synchronized output
|
|
967
|
+
if (clear) {
|
|
968
|
+
buffer += this.deleteKittyImages(this.previousKittyImageIds);
|
|
969
|
+
buffer += "\x1b[2J\x1b[H\x1b[3J"; // Clear screen, home, then clear scrollback
|
|
970
|
+
}
|
|
971
|
+
for (let i = 0; i < newLines.length; i++) {
|
|
972
|
+
if (i > 0)
|
|
973
|
+
buffer += "\r\n";
|
|
974
|
+
const line = newLines[i];
|
|
975
|
+
const isImage = isImageLine(line);
|
|
976
|
+
const imageReservedRows = isImage ? this.getKittyImageReservedRows(newLines, i) : 1;
|
|
977
|
+
if (imageReservedRows > 1 && imageReservedRows <= height) {
|
|
978
|
+
for (let row = 1; row < imageReservedRows; row++) {
|
|
979
|
+
buffer += "\r\n";
|
|
980
|
+
}
|
|
981
|
+
buffer += `\x1b[${imageReservedRows - 1}A`;
|
|
982
|
+
buffer += line;
|
|
983
|
+
buffer += `\x1b[${imageReservedRows - 1}B`;
|
|
984
|
+
i += imageReservedRows - 1;
|
|
985
|
+
continue;
|
|
986
|
+
}
|
|
987
|
+
buffer += line;
|
|
988
|
+
}
|
|
989
|
+
buffer += "\x1b[?2026l"; // End synchronized output
|
|
990
|
+
this.terminal.write(buffer);
|
|
991
|
+
this.cursorRow = Math.max(0, newLines.length - 1);
|
|
992
|
+
this.hardwareCursorRow = this.cursorRow;
|
|
993
|
+
// Reset max lines when clearing, otherwise track growth
|
|
994
|
+
if (clear) {
|
|
995
|
+
this.maxLinesRendered = newLines.length;
|
|
996
|
+
}
|
|
997
|
+
else {
|
|
998
|
+
this.maxLinesRendered = Math.max(this.maxLinesRendered, newLines.length);
|
|
999
|
+
}
|
|
1000
|
+
const bufferLength = Math.max(height, newLines.length);
|
|
1001
|
+
this.previousViewportTop = Math.max(0, bufferLength - height);
|
|
1002
|
+
this.positionHardwareCursor(cursorPos, newLines.length);
|
|
1003
|
+
this.previousLines = newLines;
|
|
1004
|
+
this.previousKittyImageIds = this.collectKittyImageIds(newLines);
|
|
1005
|
+
this.previousWidth = width;
|
|
1006
|
+
this.previousHeight = height;
|
|
1007
|
+
};
|
|
1008
|
+
const debugRedraw = process.env.PI_DEBUG_REDRAW === "1";
|
|
1009
|
+
const logRedraw = (reason) => {
|
|
1010
|
+
if (!debugRedraw)
|
|
1011
|
+
return;
|
|
1012
|
+
const logPath = path.join(os.homedir(), ".pi", "agent", "pi-debug.log");
|
|
1013
|
+
const msg = `[${new Date().toISOString()}] fullRender: ${reason} (prev=${this.previousLines.length}, new=${newLines.length}, height=${height})\n`;
|
|
1014
|
+
fs.appendFileSync(logPath, msg);
|
|
1015
|
+
};
|
|
1016
|
+
// First render - just output everything without clearing (assumes clean screen)
|
|
1017
|
+
if (this.previousLines.length === 0 && !widthChanged && !heightChanged) {
|
|
1018
|
+
logRedraw("first render");
|
|
1019
|
+
fullRender(false);
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
// Width changes always need a full re-render because wrapping changes.
|
|
1023
|
+
if (widthChanged) {
|
|
1024
|
+
logRedraw(`terminal width changed (${this.previousWidth} -> ${width})`);
|
|
1025
|
+
fullRender(true);
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
// Height changes normally need a full re-render to keep the visible viewport aligned,
|
|
1029
|
+
// but Termux changes height when the software keyboard shows or hides.
|
|
1030
|
+
// In that environment, a full redraw causes the entire history to replay on every toggle.
|
|
1031
|
+
if (heightChanged && !isTermuxSession()) {
|
|
1032
|
+
logRedraw(`terminal height changed (${this.previousHeight} -> ${height})`);
|
|
1033
|
+
fullRender(true);
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
1036
|
+
// Content shrunk below the working area and no overlays - re-render to clear empty rows
|
|
1037
|
+
// (overlays need the padding, so only do this when no overlays are active)
|
|
1038
|
+
// Configurable via setClearOnShrink() or PI_CLEAR_ON_SHRINK=0 env var
|
|
1039
|
+
if (this.clearOnShrink && newLines.length < this.maxLinesRendered && this.overlayStack.length === 0) {
|
|
1040
|
+
logRedraw(`clearOnShrink (maxLinesRendered=${this.maxLinesRendered})`);
|
|
1041
|
+
fullRender(true);
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
// Find first and last changed lines
|
|
1045
|
+
let firstChanged = -1;
|
|
1046
|
+
let lastChanged = -1;
|
|
1047
|
+
const maxLines = Math.max(newLines.length, this.previousLines.length);
|
|
1048
|
+
for (let i = 0; i < maxLines; i++) {
|
|
1049
|
+
const oldLine = i < this.previousLines.length ? this.previousLines[i] : "";
|
|
1050
|
+
const newLine = i < newLines.length ? newLines[i] : "";
|
|
1051
|
+
if (oldLine !== newLine) {
|
|
1052
|
+
if (firstChanged === -1) {
|
|
1053
|
+
firstChanged = i;
|
|
1054
|
+
}
|
|
1055
|
+
lastChanged = i;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
const appendedLines = newLines.length > this.previousLines.length;
|
|
1059
|
+
if (appendedLines) {
|
|
1060
|
+
if (firstChanged === -1) {
|
|
1061
|
+
firstChanged = this.previousLines.length;
|
|
1062
|
+
}
|
|
1063
|
+
lastChanged = newLines.length - 1;
|
|
1064
|
+
}
|
|
1065
|
+
if (firstChanged !== -1) {
|
|
1066
|
+
const expandedRange = this.expandChangedRangeForKittyImages(firstChanged, lastChanged, newLines);
|
|
1067
|
+
firstChanged = expandedRange.firstChanged;
|
|
1068
|
+
lastChanged = expandedRange.lastChanged;
|
|
1069
|
+
}
|
|
1070
|
+
const appendStart = appendedLines && firstChanged === this.previousLines.length && firstChanged > 0;
|
|
1071
|
+
// No changes - but still need to update hardware cursor position if it moved
|
|
1072
|
+
if (firstChanged === -1) {
|
|
1073
|
+
this.positionHardwareCursor(cursorPos, newLines.length);
|
|
1074
|
+
this.previousViewportTop = prevViewportTop;
|
|
1075
|
+
this.previousHeight = height;
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
// All changes are in deleted lines (nothing to render, just clear)
|
|
1079
|
+
if (firstChanged >= newLines.length) {
|
|
1080
|
+
if (this.previousLines.length > newLines.length) {
|
|
1081
|
+
let buffer = "\x1b[?2026h";
|
|
1082
|
+
buffer += this.deleteChangedKittyImages(firstChanged, lastChanged);
|
|
1083
|
+
// Move to end of new content (clamp to 0 for empty content)
|
|
1084
|
+
const targetRow = Math.max(0, newLines.length - 1);
|
|
1085
|
+
if (targetRow < prevViewportTop) {
|
|
1086
|
+
logRedraw(`deleted lines moved viewport up (${targetRow} < ${prevViewportTop})`);
|
|
1087
|
+
fullRender(true);
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
const lineDiff = computeLineDiff(targetRow);
|
|
1091
|
+
if (lineDiff > 0)
|
|
1092
|
+
buffer += `\x1b[${lineDiff}B`;
|
|
1093
|
+
else if (lineDiff < 0)
|
|
1094
|
+
buffer += `\x1b[${-lineDiff}A`;
|
|
1095
|
+
buffer += "\r";
|
|
1096
|
+
// Clear extra lines without scrolling
|
|
1097
|
+
const extraLines = this.previousLines.length - newLines.length;
|
|
1098
|
+
if (extraLines > height) {
|
|
1099
|
+
logRedraw(`extraLines > height (${extraLines} > ${height})`);
|
|
1100
|
+
fullRender(true);
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
const clearStartOffset = newLines.length === 0 ? 0 : 1;
|
|
1104
|
+
if (extraLines > 0 && clearStartOffset > 0) {
|
|
1105
|
+
buffer += `\x1b[${clearStartOffset}B`;
|
|
1106
|
+
}
|
|
1107
|
+
for (let i = 0; i < extraLines; i++) {
|
|
1108
|
+
buffer += "\r\x1b[2K";
|
|
1109
|
+
if (i < extraLines - 1)
|
|
1110
|
+
buffer += "\x1b[1B";
|
|
1111
|
+
}
|
|
1112
|
+
const moveBack = Math.max(0, extraLines - 1 + clearStartOffset);
|
|
1113
|
+
if (moveBack > 0) {
|
|
1114
|
+
buffer += `\x1b[${moveBack}A`;
|
|
1115
|
+
}
|
|
1116
|
+
buffer += "\x1b[?2026l";
|
|
1117
|
+
this.terminal.write(buffer);
|
|
1118
|
+
this.cursorRow = targetRow;
|
|
1119
|
+
this.hardwareCursorRow = targetRow;
|
|
1120
|
+
}
|
|
1121
|
+
this.positionHardwareCursor(cursorPos, newLines.length);
|
|
1122
|
+
this.previousLines = newLines;
|
|
1123
|
+
this.previousKittyImageIds = this.collectKittyImageIds(newLines);
|
|
1124
|
+
this.previousWidth = width;
|
|
1125
|
+
this.previousHeight = height;
|
|
1126
|
+
this.previousViewportTop = prevViewportTop;
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
// Differential rendering can only touch what was actually visible.
|
|
1130
|
+
// If the first changed line is above the previous viewport, we need a full redraw.
|
|
1131
|
+
if (firstChanged < prevViewportTop) {
|
|
1132
|
+
logRedraw(`firstChanged < viewportTop (${firstChanged} < ${prevViewportTop})`);
|
|
1133
|
+
fullRender(true);
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
// Render from first changed line to end
|
|
1137
|
+
// Build buffer with all updates wrapped in synchronized output
|
|
1138
|
+
let buffer = "\x1b[?2026h"; // Begin synchronized output
|
|
1139
|
+
buffer += this.deleteChangedKittyImages(firstChanged, lastChanged);
|
|
1140
|
+
const prevViewportBottom = prevViewportTop + height - 1;
|
|
1141
|
+
const moveTargetRow = appendStart ? firstChanged - 1 : firstChanged;
|
|
1142
|
+
if (moveTargetRow > prevViewportBottom) {
|
|
1143
|
+
const currentScreenRow = Math.max(0, Math.min(height - 1, hardwareCursorRow - prevViewportTop));
|
|
1144
|
+
const moveToBottom = height - 1 - currentScreenRow;
|
|
1145
|
+
if (moveToBottom > 0) {
|
|
1146
|
+
buffer += `\x1b[${moveToBottom}B`;
|
|
1147
|
+
}
|
|
1148
|
+
const scroll = moveTargetRow - prevViewportBottom;
|
|
1149
|
+
buffer += "\r\n".repeat(scroll);
|
|
1150
|
+
prevViewportTop += scroll;
|
|
1151
|
+
viewportTop += scroll;
|
|
1152
|
+
hardwareCursorRow = moveTargetRow;
|
|
1153
|
+
}
|
|
1154
|
+
// Move cursor to first changed line (use hardwareCursorRow for actual position)
|
|
1155
|
+
const lineDiff = computeLineDiff(moveTargetRow);
|
|
1156
|
+
if (lineDiff > 0) {
|
|
1157
|
+
buffer += `\x1b[${lineDiff}B`; // Move down
|
|
1158
|
+
}
|
|
1159
|
+
else if (lineDiff < 0) {
|
|
1160
|
+
buffer += `\x1b[${-lineDiff}A`; // Move up
|
|
1161
|
+
}
|
|
1162
|
+
buffer += appendStart ? "\r\n" : "\r"; // Move to column 0
|
|
1163
|
+
// Only render changed lines (firstChanged to lastChanged), not all lines to end
|
|
1164
|
+
// This reduces flicker when only a single line changes (e.g., spinner animation)
|
|
1165
|
+
const renderEnd = Math.min(lastChanged, newLines.length - 1);
|
|
1166
|
+
for (let i = firstChanged; i <= renderEnd; i++) {
|
|
1167
|
+
if (i > firstChanged)
|
|
1168
|
+
buffer += "\r\n";
|
|
1169
|
+
const line = newLines[i];
|
|
1170
|
+
const isImage = isImageLine(line);
|
|
1171
|
+
const imageReservedRows = isImage ? this.getKittyImageReservedRows(newLines, i, renderEnd) : 1;
|
|
1172
|
+
if (imageReservedRows > 1) {
|
|
1173
|
+
const imageStartScreenRow = i - viewportTop;
|
|
1174
|
+
if (imageStartScreenRow < 0 || imageStartScreenRow + imageReservedRows > height) {
|
|
1175
|
+
logRedraw(`kitty image pre-clear would scroll (${imageStartScreenRow} + ${imageReservedRows} > ${height})`);
|
|
1176
|
+
fullRender(true);
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
buffer += "\x1b[2K";
|
|
1180
|
+
for (let row = 1; row < imageReservedRows; row++) {
|
|
1181
|
+
buffer += "\r\n\x1b[2K";
|
|
1182
|
+
}
|
|
1183
|
+
buffer += `\x1b[${imageReservedRows - 1}A`;
|
|
1184
|
+
buffer += line;
|
|
1185
|
+
buffer += `\x1b[${imageReservedRows - 1}B`;
|
|
1186
|
+
i += imageReservedRows - 1;
|
|
1187
|
+
continue;
|
|
1188
|
+
}
|
|
1189
|
+
buffer += "\x1b[2K"; // Clear current line
|
|
1190
|
+
if (!isImage && visibleWidth(line) > width) {
|
|
1191
|
+
// Log all lines to crash file for debugging
|
|
1192
|
+
const crashLogPath = path.join(os.homedir(), ".pi", "agent", "pi-crash.log");
|
|
1193
|
+
const crashData = [
|
|
1194
|
+
`Crash at ${new Date().toISOString()}`,
|
|
1195
|
+
`Terminal width: ${width}`,
|
|
1196
|
+
`Line ${i} visible width: ${visibleWidth(line)}`,
|
|
1197
|
+
"",
|
|
1198
|
+
"=== All rendered lines ===",
|
|
1199
|
+
...newLines.map((l, idx) => `[${idx}] (w=${visibleWidth(l)}) ${l}`),
|
|
1200
|
+
"",
|
|
1201
|
+
].join("\n");
|
|
1202
|
+
fs.mkdirSync(path.dirname(crashLogPath), { recursive: true });
|
|
1203
|
+
fs.writeFileSync(crashLogPath, crashData);
|
|
1204
|
+
// Clean up terminal state before throwing
|
|
1205
|
+
this.stop();
|
|
1206
|
+
const errorMsg = [
|
|
1207
|
+
`Rendered line ${i} exceeds terminal width (${visibleWidth(line)} > ${width}).`,
|
|
1208
|
+
"",
|
|
1209
|
+
"This is likely caused by a custom TUI component not truncating its output.",
|
|
1210
|
+
"Use visibleWidth() to measure and truncateToWidth() to truncate lines.",
|
|
1211
|
+
"",
|
|
1212
|
+
`Debug log written to: ${crashLogPath}`,
|
|
1213
|
+
].join("\n");
|
|
1214
|
+
throw new Error(errorMsg);
|
|
1215
|
+
}
|
|
1216
|
+
buffer += line;
|
|
1217
|
+
}
|
|
1218
|
+
// Track where cursor ended up after rendering
|
|
1219
|
+
let finalCursorRow = renderEnd;
|
|
1220
|
+
// If we had more lines before, clear them and move cursor back
|
|
1221
|
+
if (this.previousLines.length > newLines.length) {
|
|
1222
|
+
// Move to end of new content first if we stopped before it
|
|
1223
|
+
if (renderEnd < newLines.length - 1) {
|
|
1224
|
+
const moveDown = newLines.length - 1 - renderEnd;
|
|
1225
|
+
buffer += `\x1b[${moveDown}B`;
|
|
1226
|
+
finalCursorRow = newLines.length - 1;
|
|
1227
|
+
}
|
|
1228
|
+
const extraLines = this.previousLines.length - newLines.length;
|
|
1229
|
+
for (let i = newLines.length; i < this.previousLines.length; i++) {
|
|
1230
|
+
buffer += "\r\n\x1b[2K";
|
|
1231
|
+
}
|
|
1232
|
+
// Move cursor back to end of new content
|
|
1233
|
+
buffer += `\x1b[${extraLines}A`;
|
|
1234
|
+
}
|
|
1235
|
+
buffer += "\x1b[?2026l"; // End synchronized output
|
|
1236
|
+
if (process.env.PI_TUI_DEBUG === "1") {
|
|
1237
|
+
const debugDir = "/tmp/tui";
|
|
1238
|
+
fs.mkdirSync(debugDir, { recursive: true });
|
|
1239
|
+
const debugPath = path.join(debugDir, `render-${Date.now()}-${Math.random().toString(36).slice(2)}.log`);
|
|
1240
|
+
const debugData = [
|
|
1241
|
+
`firstChanged: ${firstChanged}`,
|
|
1242
|
+
`viewportTop: ${viewportTop}`,
|
|
1243
|
+
`cursorRow: ${this.cursorRow}`,
|
|
1244
|
+
`height: ${height}`,
|
|
1245
|
+
`lineDiff: ${lineDiff}`,
|
|
1246
|
+
`hardwareCursorRow: ${hardwareCursorRow}`,
|
|
1247
|
+
`renderEnd: ${renderEnd}`,
|
|
1248
|
+
`finalCursorRow: ${finalCursorRow}`,
|
|
1249
|
+
`cursorPos: ${JSON.stringify(cursorPos)}`,
|
|
1250
|
+
`newLines.length: ${newLines.length}`,
|
|
1251
|
+
`previousLines.length: ${this.previousLines.length}`,
|
|
1252
|
+
"",
|
|
1253
|
+
"=== newLines ===",
|
|
1254
|
+
JSON.stringify(newLines, null, 2),
|
|
1255
|
+
"",
|
|
1256
|
+
"=== previousLines ===",
|
|
1257
|
+
JSON.stringify(this.previousLines, null, 2),
|
|
1258
|
+
"",
|
|
1259
|
+
"=== buffer ===",
|
|
1260
|
+
JSON.stringify(buffer),
|
|
1261
|
+
].join("\n");
|
|
1262
|
+
fs.writeFileSync(debugPath, debugData);
|
|
1263
|
+
}
|
|
1264
|
+
// Write entire buffer at once
|
|
1265
|
+
this.terminal.write(buffer);
|
|
1266
|
+
// Track cursor position for next render
|
|
1267
|
+
// cursorRow tracks end of content (for viewport calculation)
|
|
1268
|
+
// hardwareCursorRow tracks actual terminal cursor position (for movement)
|
|
1269
|
+
this.cursorRow = Math.max(0, newLines.length - 1);
|
|
1270
|
+
this.hardwareCursorRow = finalCursorRow;
|
|
1271
|
+
// Track terminal's working area (grows but doesn't shrink unless cleared)
|
|
1272
|
+
this.maxLinesRendered = Math.max(this.maxLinesRendered, newLines.length);
|
|
1273
|
+
this.previousViewportTop = Math.max(prevViewportTop, finalCursorRow - height + 1);
|
|
1274
|
+
// Position hardware cursor for IME
|
|
1275
|
+
this.positionHardwareCursor(cursorPos, newLines.length);
|
|
1276
|
+
this.previousLines = newLines;
|
|
1277
|
+
this.previousKittyImageIds = this.collectKittyImageIds(newLines);
|
|
1278
|
+
this.previousWidth = width;
|
|
1279
|
+
this.previousHeight = height;
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* Position the hardware cursor for IME candidate window.
|
|
1283
|
+
* @param cursorPos The cursor position extracted from rendered output, or null
|
|
1284
|
+
* @param totalLines Total number of rendered lines
|
|
1285
|
+
*/
|
|
1286
|
+
positionHardwareCursor(cursorPos, totalLines) {
|
|
1287
|
+
if (!cursorPos || totalLines <= 0) {
|
|
1288
|
+
this.terminal.hideCursor();
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
// Clamp cursor position to valid range
|
|
1292
|
+
const targetRow = Math.max(0, Math.min(cursorPos.row, totalLines - 1));
|
|
1293
|
+
const targetCol = Math.max(0, cursorPos.col);
|
|
1294
|
+
// Move cursor from current position to target
|
|
1295
|
+
const rowDelta = targetRow - this.hardwareCursorRow;
|
|
1296
|
+
let buffer = "";
|
|
1297
|
+
if (rowDelta > 0) {
|
|
1298
|
+
buffer += `\x1b[${rowDelta}B`; // Move down
|
|
1299
|
+
}
|
|
1300
|
+
else if (rowDelta < 0) {
|
|
1301
|
+
buffer += `\x1b[${-rowDelta}A`; // Move up
|
|
1302
|
+
}
|
|
1303
|
+
// Move to absolute column (1-indexed)
|
|
1304
|
+
buffer += `\x1b[${targetCol + 1}G`;
|
|
1305
|
+
if (buffer) {
|
|
1306
|
+
this.terminal.write(buffer);
|
|
1307
|
+
}
|
|
1308
|
+
this.hardwareCursorRow = targetRow;
|
|
1309
|
+
if (this.showHardwareCursor) {
|
|
1310
|
+
this.terminal.showCursor();
|
|
1311
|
+
}
|
|
1312
|
+
else {
|
|
1313
|
+
this.terminal.hideCursor();
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Query the terminal's default background color with OSC 11 (`ESC ] 11 ; ? BEL`).
|
|
1318
|
+
* @param timeoutMs Query timeout in milliseconds.
|
|
1319
|
+
* @returns Promise containing the parsed RGB color, or undefined if it times out or fails to parse.
|
|
1320
|
+
*/
|
|
1321
|
+
queryTerminalBackgroundColor({ timeoutMs }) {
|
|
1322
|
+
return new Promise((resolve) => {
|
|
1323
|
+
const query = {
|
|
1324
|
+
settled: false,
|
|
1325
|
+
resolve,
|
|
1326
|
+
timer: undefined,
|
|
1327
|
+
};
|
|
1328
|
+
query.timer = setTimeout(() => {
|
|
1329
|
+
if (query.settled) {
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
query.settled = true;
|
|
1333
|
+
query.timer = undefined;
|
|
1334
|
+
query.resolve?.(undefined);
|
|
1335
|
+
query.resolve = undefined;
|
|
1336
|
+
}, timeoutMs);
|
|
1337
|
+
this.pendingOsc11BackgroundQueries.push(query);
|
|
1338
|
+
this.pendingOsc11BackgroundReplies += 1;
|
|
1339
|
+
this.terminal.write("\x1b]11;?\x07");
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
//# sourceMappingURL=tui.js.map
|