@draht/coding-agent 2026.9.5-1 → 2026.10.4-3
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 +458 -0
- package/dist/bun/cli.d.ts +1 -1
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js +6 -3
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/sandbox-env-setup.d.ts +2 -0
- package/dist/bun/sandbox-env-setup.d.ts.map +1 -0
- package/dist/bun/sandbox-env-setup.js +4 -0
- package/dist/bun/sandbox-env-setup.js.map +1 -0
- package/dist/bundle/chunks/anthropic-messages-E2P6C3P7.js +6 -0
- package/dist/bundle/chunks/anthropic.js +75 -0
- package/dist/bundle/chunks/azure-openai-responses-JZMSTDIM.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +79 -0
- package/dist/bundle/chunks/chunk-2E5VODES.js +2 -0
- package/dist/bundle/chunks/chunk-2FBJKY7F.js +2 -0
- package/dist/bundle/chunks/chunk-2JZLKNZ4.js +3 -0
- package/dist/bundle/chunks/chunk-2N4I6WXC.js +2 -0
- package/dist/bundle/chunks/chunk-3HF756LN.js +1472 -0
- package/dist/bundle/chunks/chunk-5QJFWTKA.js +4 -0
- package/dist/bundle/chunks/chunk-63BK6WK2.js +2 -0
- package/dist/bundle/chunks/chunk-A4OX5CPR.js +146 -0
- package/dist/bundle/chunks/chunk-AFL4IDSI.js +82 -0
- package/dist/bundle/chunks/chunk-D3HO453P.js +42 -0
- package/dist/bundle/chunks/chunk-EBVYI75P.js +2 -0
- package/dist/bundle/chunks/chunk-FBU742QF.js +2 -0
- package/dist/bundle/chunks/chunk-FHX2S5IG.js +31 -0
- package/dist/bundle/chunks/chunk-GBFVS2SF.js +12 -0
- package/dist/bundle/chunks/chunk-GVXA72ZA.js +2 -0
- package/dist/bundle/chunks/chunk-HJ72RANT.js +2 -0
- package/dist/bundle/chunks/chunk-HTJ3L72O.js +2 -0
- package/dist/bundle/chunks/chunk-HZ2UHMBT.js +2 -0
- package/dist/bundle/chunks/chunk-I5OKY6RH.js +11 -0
- package/dist/bundle/chunks/chunk-JTLUBTZT.js +2 -0
- package/dist/bundle/chunks/chunk-KPO5375S.js +2 -0
- package/dist/bundle/chunks/chunk-KY2BG6BC.js +11 -0
- package/dist/bundle/chunks/chunk-LO6CVU2L.js +6 -0
- package/dist/bundle/chunks/chunk-QMN7OD6G.js +2 -0
- package/dist/bundle/chunks/chunk-SDRCE6OP.js +2 -0
- package/dist/bundle/chunks/chunk-SPZUYYP5.js +170 -0
- package/dist/bundle/chunks/chunk-UTRX2VHB.js +44 -0
- package/dist/bundle/chunks/chunk-V5HG6S2T.js +4 -0
- package/dist/bundle/chunks/chunk-VPYAVQLP.js +137 -0
- package/dist/bundle/chunks/chunk-VXUJMEMO.js +2 -0
- package/dist/bundle/chunks/chunk-XBUEMKIY.js +2 -0
- package/dist/bundle/chunks/chunk-XHCO4PPH.js +8 -0
- package/dist/bundle/chunks/chunk-XO3IECI5.js +18 -0
- package/dist/bundle/chunks/chunk-XOGEYN4Q.js +2 -0
- package/dist/bundle/chunks/cli-L74YA5GF.js +51 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-MJKOAE5S.js +2 -0
- package/dist/bundle/chunks/codemode-worker.js +315 -0
- package/dist/bundle/chunks/execute-EMOVNTD6.js +328 -0
- package/dist/bundle/chunks/github-copilot.js +2 -0
- package/dist/bundle/chunks/google-antigravity.js +75 -0
- package/dist/bundle/chunks/google-gemini-cli.js +75 -0
- package/dist/bundle/chunks/google-generative-ai-HPNDIAZD.js +2 -0
- package/dist/bundle/chunks/google-vertex-KPAWJ4SP.js +2 -0
- package/dist/bundle/chunks/https-proxy-agent-WQIRL24U.js +13 -0
- package/dist/bundle/chunks/image-resize-worker.js +2 -0
- package/dist/bundle/chunks/jiti-loader-RKXLMQV2.js +2 -0
- package/dist/bundle/chunks/kimi-coding.js +2 -0
- package/dist/bundle/chunks/lib-ULKZYRGD.js +9 -0
- package/dist/bundle/chunks/llama-cpp-classify-EJ5XMSQL.js +22 -0
- package/dist/bundle/chunks/meta.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-FMSPWQ7A.js +5 -0
- package/dist/bundle/chunks/multipart-parser-HMCXZ4BD.js +3 -0
- package/dist/bundle/chunks/node-4JNG6XQO.js +16 -0
- package/dist/bundle/chunks/node-6IIDYB3K.js +2 -0
- package/dist/bundle/chunks/openai-chatgpt.js +75 -0
- package/dist/bundle/chunks/openai-codex-responses-TU7NGPXE.js +10 -0
- package/dist/bundle/chunks/openai-codex.js +75 -0
- package/dist/bundle/chunks/openai-completions-GANCQQO5.js +7 -0
- package/dist/bundle/chunks/openai-responses-ASDPAX3E.js +3 -0
- package/dist/bundle/chunks/opencode-go.js +2 -0
- package/dist/bundle/chunks/openrouter-images-NROSQXMZ.js +2 -0
- package/dist/bundle/chunks/openrouter.js +75 -0
- package/dist/bundle/chunks/pi-messages-2QEJYOAO.js +8 -0
- package/dist/bundle/chunks/radius.js +75 -0
- package/dist/bundle/chunks/runtime-RYUR6LRB.js +2 -0
- package/dist/bundle/chunks/settings-manager-CHEMMAGQ.js +2 -0
- package/dist/bundle/chunks/src-KDGO7EGF.js +4 -0
- package/dist/bundle/chunks/typesafe-system-one-YBEEY5XU.js +2 -0
- package/dist/bundle/chunks/virtual-modules-OC56AAJ7.js +2 -0
- package/dist/bundle/chunks/xai.js +75 -0
- package/dist/bundle/cli-runtime.js +3 -0
- package/dist/bundle/cli.js +5 -0
- package/dist/bundle/index.js +2 -0
- package/dist/bundle/rpc-entry.js +3 -0
- package/dist/cli/args.d.ts +4 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +72 -21
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-check.d.ts +19 -0
- package/dist/cli/auth-check.d.ts.map +1 -0
- package/dist/cli/auth-check.js +50 -0
- package/dist/cli/auth-check.js.map +1 -0
- package/dist/cli/auth-command.d.ts +24 -0
- package/dist/cli/auth-command.d.ts.map +1 -0
- package/dist/cli/auth-command.js +103 -0
- package/dist/cli/auth-command.js.map +1 -0
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js +3 -2
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/credential-print.d.ts +5 -3
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +42 -30
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/cli/file-processor.d.ts +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +2 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/list-models.d.ts +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +2 -2
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/session-picker.d.ts +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/setup.d.ts +2 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +12 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli/startup-ui.d.ts +2 -2
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +42 -33
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/cli.js +3 -12
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +20 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +42 -6
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +12 -3
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +14 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +237 -39
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1386 -565
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +20 -8
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +199 -56
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bug-report-upload.d.ts +11 -0
- package/dist/core/bug-report-upload.d.ts.map +1 -0
- package/dist/core/bug-report-upload.js +20 -0
- package/dist/core/bug-report-upload.js.map +1 -0
- package/dist/core/bug-report.d.ts +176 -0
- package/dist/core/bug-report.d.ts.map +1 -0
- package/dist/core/bug-report.js +292 -0
- package/dist/core/bug-report.js.map +1 -0
- package/dist/core/builtins/duet.js +2 -2
- package/dist/core/builtins/duet.js.map +1 -1
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +12 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/cache-warmer.d.ts +103 -0
- package/dist/core/cache-warmer.d.ts.map +1 -0
- package/dist/core/cache-warmer.js +356 -0
- package/dist/core/cache-warmer.js.map +1 -0
- package/dist/core/checkpoints/checkpoint-manager.d.ts +8 -4
- package/dist/core/checkpoints/checkpoint-manager.d.ts.map +1 -1
- package/dist/core/checkpoints/checkpoint-manager.js +46 -10
- package/dist/core/checkpoints/checkpoint-manager.js.map +1 -1
- package/dist/core/checkpoints/rewind.d.ts +4 -2
- package/dist/core/checkpoints/rewind.d.ts.map +1 -1
- package/dist/core/checkpoints/rewind.js +4 -3
- package/dist/core/checkpoints/rewind.js.map +1 -1
- package/dist/core/compaction/branch-summarization.js +2 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +9 -6
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +196 -118
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/utils.d.ts +2 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +25 -18
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/context-windows.d.ts.map +1 -1
- package/dist/core/context-windows.js +13 -3
- package/dist/core/context-windows.js.map +1 -1
- package/dist/core/crash-log.d.ts +27 -0
- package/dist/core/crash-log.d.ts.map +1 -0
- package/dist/core/crash-log.js +140 -0
- package/dist/core/crash-log.js.map +1 -0
- package/dist/core/defaults.d.ts +1 -0
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/defaults.js +9 -0
- package/dist/core/defaults.js.map +1 -1
- package/dist/core/experimental.js +1 -1
- package/dist/core/experimental.js.map +1 -1
- package/dist/core/export-html/template.css +10 -0
- package/dist/core/export-html/template.js +72 -18
- package/dist/core/extensions/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/jiti-loader.d.ts +2 -0
- package/dist/core/extensions/jiti-loader.d.ts.map +1 -0
- package/dist/core/extensions/jiti-loader.js +5 -0
- package/dist/core/extensions/jiti-loader.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +228 -89
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +47 -8
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +376 -104
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +521 -88
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +3 -0
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts +3 -0
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/virtual-modules.js +37 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +2 -2
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js +3 -22
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +1 -1
- package/dist/core/footer-data-provider.js +19 -18
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +83 -13
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +33 -7
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +119 -0
- package/dist/core/mcp-servers.d.ts.map +1 -0
- package/dist/core/mcp-servers.js +191 -0
- package/dist/core/mcp-servers.js.map +1 -0
- package/dist/core/messages.d.ts +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +1 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts +202 -20
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +53 -18
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-registry.d.ts +19 -2
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +39 -2
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +7 -5
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +29 -17
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +79 -20
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +460 -134
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/models-store.d.ts +12 -7
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js +87 -18
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/multi-agent/fsm.js +8 -3
- package/dist/core/multi-agent/fsm.js.map +1 -1
- package/dist/core/multi-agent/mailbox.js +1 -3
- package/dist/core/multi-agent/mailbox.js.map +1 -1
- package/dist/core/multi-agent/permission-gate.d.ts +5 -2
- package/dist/core/multi-agent/permission-gate.d.ts.map +1 -1
- package/dist/core/multi-agent/permission-gate.js +597 -34
- package/dist/core/multi-agent/permission-gate.js.map +1 -1
- package/dist/core/multi-agent/task-board.js +2 -4
- package/dist/core/multi-agent/task-board.js.map +1 -1
- package/dist/core/multi-agent/worktree.js +1 -3
- package/dist/core/multi-agent/worktree.js.map +1 -1
- package/dist/core/nested-tool-calls.d.ts +102 -0
- package/dist/core/nested-tool-calls.d.ts.map +1 -0
- package/dist/core/nested-tool-calls.js +178 -0
- package/dist/core/nested-tool-calls.js.map +1 -0
- package/dist/core/package-manager.d.ts +10 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +149 -33
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +13 -12
- package/dist/core/pi-manifest.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +6 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +63 -37
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-attribution.js +5 -5
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/provider-composer.d.ts +44 -20
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +151 -51
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/radius.d.ts +13 -0
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +19 -0
- package/dist/core/radius.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +10 -3
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +105 -81
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +7 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +219 -42
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +5 -5
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +13 -9
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sandbox/executor.js +1 -0
- package/dist/core/sandbox/executor.js.map +1 -1
- package/dist/core/sdk.d.ts +7 -5
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +100 -52
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-cwd.js +1 -0
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/session-export.d.ts +8 -0
- package/dist/core/session-export.d.ts.map +1 -0
- package/dist/core/session-export.js +33 -0
- package/dist/core/session-export.js.map +1 -0
- package/dist/core/session-manager.d.ts +75 -15
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +314 -144
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-diagnostics.d.ts +9 -0
- package/dist/core/settings-diagnostics.d.ts.map +1 -0
- package/dist/core/settings-diagnostics.js +21 -0
- package/dist/core/settings-diagnostics.js.map +1 -0
- package/dist/core/settings-manager.d.ts +84 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +239 -25
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +51 -33
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +3 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/soak/soak-log.js +6 -0
- package/dist/core/soak/soak-log.js.map +1 -1
- package/dist/core/socket-server/socket-server.js +11 -0
- package/dist/core/socket-server/socket-server.js.map +1 -1
- package/dist/core/socket-server/types.d.ts +2 -1
- package/dist/core/socket-server/types.d.ts.map +1 -1
- package/dist/core/socket-server/types.js.map +1 -1
- package/dist/core/source-info.d.ts +8 -0
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js +16 -0
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/system-prompt.d.ts +49 -6
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +126 -89
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +32 -2
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +82 -143
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +0 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +2 -5
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +5 -12
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +19 -171
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +4 -0
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +11 -58
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +4 -0
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +10 -62
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +4 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +18 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +4 -0
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +9 -50
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +11 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +54 -12
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +16 -0
- package/dist/core/tools/powershell.d.ts.map +1 -0
- package/dist/core/tools/powershell.js +39 -0
- package/dist/core/tools/powershell.js.map +1 -0
- package/dist/core/tools/read.d.ts +8 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +16 -123
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +6 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +26 -0
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts +12 -0
- package/dist/core/tools/renderers/bash.d.ts.map +1 -0
- package/dist/core/tools/renderers/bash.js +117 -0
- package/dist/core/tools/renderers/bash.js.map +1 -0
- package/dist/core/tools/renderers/edit.d.ts +23 -0
- package/dist/core/tools/renderers/edit.d.ts.map +1 -0
- package/dist/core/tools/renderers/edit.js +167 -0
- package/dist/core/tools/renderers/edit.js.map +1 -0
- package/dist/core/tools/renderers/find.d.ts +10 -0
- package/dist/core/tools/renderers/find.d.ts.map +1 -0
- package/dist/core/tools/renderers/find.js +64 -0
- package/dist/core/tools/renderers/find.js.map +1 -0
- package/dist/core/tools/renderers/grep.d.ts +10 -0
- package/dist/core/tools/renderers/grep.d.ts.map +1 -0
- package/dist/core/tools/renderers/grep.js +69 -0
- package/dist/core/tools/renderers/grep.js.map +1 -0
- package/dist/core/tools/renderers/index.d.ts +28 -0
- package/dist/core/tools/renderers/index.d.ts.map +1 -0
- package/dist/core/tools/renderers/index.js +47 -0
- package/dist/core/tools/renderers/index.js.map +1 -0
- package/dist/core/tools/renderers/ls.d.ts +10 -0
- package/dist/core/tools/renderers/ls.d.ts.map +1 -0
- package/dist/core/tools/renderers/ls.js +58 -0
- package/dist/core/tools/renderers/ls.js.map +1 -0
- package/dist/core/tools/renderers/read.d.ts +11 -0
- package/dist/core/tools/renderers/read.d.ts.map +1 -0
- package/dist/core/tools/renderers/read.js +130 -0
- package/dist/core/tools/renderers/read.js.map +1 -0
- package/dist/core/tools/renderers/write.d.ts +10 -0
- package/dist/core/tools/renderers/write.d.ts.map +1 -0
- package/dist/core/tools/renderers/write.js +153 -0
- package/dist/core/tools/renderers/write.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +5 -3
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +3 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/truncate.d.ts +14 -0
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +29 -0
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/write.d.ts +4 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +12 -147
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +4 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/usage-totals.d.ts +3 -1
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +28 -1
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/core/virtual-models.d.ts +117 -0
- package/dist/core/virtual-models.d.ts.map +1 -0
- package/dist/core/virtual-models.js +124 -0
- package/dist/core/virtual-models.js.map +1 -0
- package/dist/experimental/micro/api.d.ts +81 -0
- package/dist/experimental/micro/api.d.ts.map +1 -0
- package/dist/experimental/micro/api.js +2 -0
- package/dist/experimental/micro/api.js.map +1 -0
- package/dist/experimental/micro/main.d.ts +3 -0
- package/dist/experimental/micro/main.d.ts.map +1 -0
- package/dist/experimental/micro/main.js +21 -0
- package/dist/experimental/micro/main.js.map +1 -0
- package/dist/experimental/micro/models.d.ts +11 -0
- package/dist/experimental/micro/models.d.ts.map +1 -0
- package/dist/experimental/micro/models.js +95 -0
- package/dist/experimental/micro/models.js.map +1 -0
- package/dist/experimental/micro/runtime.d.ts +12 -0
- package/dist/experimental/micro/runtime.d.ts.map +1 -0
- package/dist/experimental/micro/runtime.js +465 -0
- package/dist/experimental/micro/runtime.js.map +1 -0
- package/dist/experimental/micro/sessions.d.ts +10 -0
- package/dist/experimental/micro/sessions.d.ts.map +1 -0
- package/dist/experimental/micro/sessions.js +41 -0
- package/dist/experimental/micro/sessions.js.map +1 -0
- package/dist/experimental/micro/tools.d.ts +10 -0
- package/dist/experimental/micro/tools.d.ts.map +1 -0
- package/dist/experimental/micro/tools.js +96 -0
- package/dist/experimental/micro/tools.js.map +1 -0
- package/dist/experimental/micro/tui.d.ts +3 -0
- package/dist/experimental/micro/tui.d.ts.map +1 -0
- package/dist/experimental/micro/tui.js +510 -0
- package/dist/experimental/micro/tui.js.map +1 -0
- package/dist/experimental/mini/main.d.ts +7 -0
- package/dist/experimental/mini/main.d.ts.map +1 -0
- package/dist/experimental/mini/main.js +21 -0
- package/dist/experimental/mini/main.js.map +1 -0
- package/dist/experimental/mini/server/entry.d.ts +3 -0
- package/dist/experimental/mini/server/entry.d.ts.map +1 -0
- package/dist/experimental/mini/server/entry.js +11 -0
- package/dist/experimental/mini/server/entry.js.map +1 -0
- package/dist/experimental/mini/server/run.d.ts +13 -0
- package/dist/experimental/mini/server/run.d.ts.map +1 -0
- package/dist/experimental/mini/server/run.js +150 -0
- package/dist/experimental/mini/server/run.js.map +1 -0
- package/dist/experimental/mini/shared/protocol.d.ts +127 -0
- package/dist/experimental/mini/shared/protocol.d.ts.map +1 -0
- package/dist/experimental/mini/shared/protocol.js +13 -0
- package/dist/experimental/mini/shared/protocol.js.map +1 -0
- package/dist/experimental/mini/shared/rpc.d.ts +49 -0
- package/dist/experimental/mini/shared/rpc.d.ts.map +1 -0
- package/dist/experimental/mini/shared/rpc.js +171 -0
- package/dist/experimental/mini/shared/rpc.js.map +1 -0
- package/dist/experimental/mini/shared/transport.d.ts +35 -0
- package/dist/experimental/mini/shared/transport.d.ts.map +1 -0
- package/dist/experimental/mini/shared/transport.js +94 -0
- package/dist/experimental/mini/shared/transport.js.map +1 -0
- package/dist/experimental/mini/tui/run.d.ts +9 -0
- package/dist/experimental/mini/tui/run.d.ts.map +1 -0
- package/dist/experimental/mini/tui/run.js +62 -0
- package/dist/experimental/mini/tui/run.js.map +1 -0
- package/dist/experimental/mini/tui/session.d.ts +26 -0
- package/dist/experimental/mini/tui/session.d.ts.map +1 -0
- package/dist/experimental/mini/tui/session.js +94 -0
- package/dist/experimental/mini/tui/session.js.map +1 -0
- package/dist/experimental/mini/tui/view.d.ts +10 -0
- package/dist/experimental/mini/tui/view.d.ts.map +1 -0
- package/dist/experimental/mini/tui/view.js +461 -0
- package/dist/experimental/mini/tui/view.js.map +1 -0
- package/dist/experimental/mini/worker/entry.d.ts +3 -0
- package/dist/experimental/mini/worker/entry.d.ts.map +1 -0
- package/dist/experimental/mini/worker/entry.js +10 -0
- package/dist/experimental/mini/worker/entry.js.map +1 -0
- package/dist/experimental/mini/worker/lane-service.d.ts +44 -0
- package/dist/experimental/mini/worker/lane-service.d.ts.map +1 -0
- package/dist/experimental/mini/worker/lane-service.js +97 -0
- package/dist/experimental/mini/worker/lane-service.js.map +1 -0
- package/dist/experimental/mini/worker/models-service.d.ts +19 -0
- package/dist/experimental/mini/worker/models-service.d.ts.map +1 -0
- package/dist/experimental/mini/worker/models-service.js +136 -0
- package/dist/experimental/mini/worker/models-service.js.map +1 -0
- package/dist/experimental/mini/worker/run.d.ts +14 -0
- package/dist/experimental/mini/worker/run.d.ts.map +1 -0
- package/dist/experimental/mini/worker/run.js +88 -0
- package/dist/experimental/mini/worker/run.js.map +1 -0
- package/dist/extensions/codemode/execute.d.ts +16 -0
- package/dist/extensions/codemode/execute.d.ts.map +1 -0
- package/dist/extensions/codemode/execute.js +429 -0
- package/dist/extensions/codemode/execute.js.map +1 -0
- package/dist/extensions/codemode/execute.lazy.d.ts +3 -0
- package/dist/extensions/codemode/execute.lazy.d.ts.map +1 -0
- package/dist/extensions/codemode/execute.lazy.js +3 -0
- package/dist/extensions/codemode/execute.lazy.js.map +1 -0
- package/dist/extensions/codemode/index.d.ts +21 -0
- package/dist/extensions/codemode/index.d.ts.map +1 -0
- package/dist/extensions/codemode/index.js +31 -0
- package/dist/extensions/codemode/index.js.map +1 -0
- package/dist/extensions/codemode/renderer.d.ts +12 -0
- package/dist/extensions/codemode/renderer.d.ts.map +1 -0
- package/dist/extensions/codemode/renderer.js +137 -0
- package/dist/extensions/codemode/renderer.js.map +1 -0
- package/dist/extensions/codemode/tool.d.ts +123 -0
- package/dist/extensions/codemode/tool.d.ts.map +1 -0
- package/dist/extensions/codemode/tool.js +315 -0
- package/dist/extensions/codemode/tool.js.map +1 -0
- package/dist/extensions/codemode/worker.d.ts +7 -0
- package/dist/extensions/codemode/worker.d.ts.map +1 -0
- package/dist/extensions/codemode/worker.js +7 -0
- package/dist/extensions/codemode/worker.js.map +1 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +9 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/llama/client.d.ts +8 -0
- package/dist/extensions/llama/client.d.ts.map +1 -1
- package/dist/extensions/llama/client.js +13 -0
- package/dist/extensions/llama/client.js.map +1 -1
- package/dist/extensions/llama/huggingface.js +2 -0
- package/dist/extensions/llama/huggingface.js.map +1 -1
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +13 -2
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts +4 -2
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +119 -17
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/llama/ui.js +28 -12
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/cli.d.ts +21 -0
- package/dist/extensions/mcp/cli.d.ts.map +1 -0
- package/dist/extensions/mcp/cli.js +500 -0
- package/dist/extensions/mcp/cli.js.map +1 -0
- package/dist/extensions/mcp/cli.lazy.d.ts +3 -0
- package/dist/extensions/mcp/cli.lazy.d.ts.map +1 -0
- package/dist/extensions/mcp/cli.lazy.js +3 -0
- package/dist/extensions/mcp/cli.lazy.js.map +1 -0
- package/dist/extensions/mcp/config.d.ts +72 -0
- package/dist/extensions/mcp/config.d.ts.map +1 -0
- package/dist/extensions/mcp/config.js +158 -0
- package/dist/extensions/mcp/config.js.map +1 -0
- package/dist/extensions/mcp/index.d.ts +76 -0
- package/dist/extensions/mcp/index.d.ts.map +1 -0
- package/dist/extensions/mcp/index.js +1055 -0
- package/dist/extensions/mcp/index.js.map +1 -0
- package/dist/extensions/mcp/log.d.ts +16 -0
- package/dist/extensions/mcp/log.d.ts.map +1 -0
- package/dist/extensions/mcp/log.js +66 -0
- package/dist/extensions/mcp/log.js.map +1 -0
- package/dist/extensions/mcp/oauth.d.ts +96 -0
- package/dist/extensions/mcp/oauth.d.ts.map +1 -0
- package/dist/extensions/mcp/oauth.js +333 -0
- package/dist/extensions/mcp/oauth.js.map +1 -0
- package/dist/extensions/mcp/resources.d.ts +43 -0
- package/dist/extensions/mcp/resources.d.ts.map +1 -0
- package/dist/extensions/mcp/resources.js +262 -0
- package/dist/extensions/mcp/resources.js.map +1 -0
- package/dist/extensions/mcp/runtime.d.ts +98 -0
- package/dist/extensions/mcp/runtime.d.ts.map +1 -0
- package/dist/extensions/mcp/runtime.js +394 -0
- package/dist/extensions/mcp/runtime.js.map +1 -0
- package/dist/extensions/mcp/runtime.lazy.d.ts +3 -0
- package/dist/extensions/mcp/runtime.lazy.d.ts.map +1 -0
- package/dist/extensions/mcp/runtime.lazy.js +3 -0
- package/dist/extensions/mcp/runtime.lazy.js.map +1 -0
- package/dist/extensions/mcp/tools.d.ts +84 -0
- package/dist/extensions/mcp/tools.d.ts.map +1 -0
- package/dist/extensions/mcp/tools.js +251 -0
- package/dist/extensions/mcp/tools.js.map +1 -0
- package/dist/extensions/mcp/ui.d.ts +60 -0
- package/dist/extensions/mcp/ui.d.ts.map +1 -0
- package/dist/extensions/mcp/ui.js +174 -0
- package/dist/extensions/mcp/ui.js.map +1 -0
- package/dist/extensions/stub-provider/provider.d.ts +2 -2
- package/dist/extensions/stub-provider/provider.d.ts.map +1 -1
- package/dist/extensions/stub-provider/provider.js +2 -1
- package/dist/extensions/stub-provider/provider.js.map +1 -1
- package/dist/extensions/tool-search/index.d.ts +12 -0
- package/dist/extensions/tool-search/index.d.ts.map +1 -0
- package/dist/extensions/tool-search/index.js +15 -0
- package/dist/extensions/tool-search/index.js.map +1 -0
- package/dist/extensions/tool-search/tool.d.ts +73 -0
- package/dist/extensions/tool-search/tool.d.ts.map +1 -0
- package/dist/extensions/tool-search/tool.js +189 -0
- package/dist/extensions/tool-search/tool.js.map +1 -0
- package/dist/index.d.ts +20 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +4 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +123 -51
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +1 -1
- package/dist/migrations.js +7 -6
- package/dist/migrations.js.map +1 -1
- package/dist/modes/index.d.ts +1 -0
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/bug-report.d.ts +19 -0
- package/dist/modes/interactive/bug-report.d.ts.map +1 -0
- package/dist/modes/interactive/bug-report.js +211 -0
- package/dist/modes/interactive/bug-report.js.map +1 -0
- package/dist/modes/interactive/chat-viewport.d.ts +20 -0
- package/dist/modes/interactive/chat-viewport.d.ts.map +1 -0
- package/dist/modes/interactive/chat-viewport.js +28 -0
- package/dist/modes/interactive/chat-viewport.js.map +1 -0
- package/dist/modes/interactive/components/armin.js +10 -6
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +6 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +38 -15
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +9 -4
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +3 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +15 -6
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +15 -6
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +35 -8
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +5 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +10 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +54 -2
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +4 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +7 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js +8 -6
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +1 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +4 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +14 -3
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +2 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +14 -2
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +16 -1
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +4 -4
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +12 -4
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +7 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +51 -6
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +9 -3
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +3 -0
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
- package/dist/modes/interactive/components/markdown-transform.js +19 -0
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
- package/dist/modes/interactive/components/mermaid.d.ts +11 -0
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
- package/dist/modes/interactive/components/mermaid.js +75 -0
- package/dist/modes/interactive/components/mermaid.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +10 -4
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +101 -40
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +11 -3
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +4 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +60 -32
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +5 -5
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +128 -78
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +23 -4
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +230 -67
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-submenu.js +165 -0
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +1 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +14 -5
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/status-indicator.d.ts +3 -1
- package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-indicator.js +12 -3
- package/dist/modes/interactive/components/status-indicator.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +2 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/themed-text.d.ts +17 -0
- package/dist/modes/interactive/components/themed-text.d.ts.map +1 -0
- package/dist/modes/interactive/components/themed-text.js +29 -0
- package/dist/modes/interactive/components/themed-text.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +15 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +76 -18
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +21 -4
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +78 -52
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +44 -18
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +8 -2
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +6 -3
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +3 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +12 -2
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts +27 -3
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js +39 -6
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +69 -5
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1314 -593
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/model-catalog-refresh.d.ts +7 -0
- package/dist/modes/interactive/model-catalog-refresh.d.ts.map +1 -0
- package/dist/modes/interactive/model-catalog-refresh.js +34 -0
- package/dist/modes/interactive/model-catalog-refresh.js.map +1 -0
- package/dist/modes/interactive/session-share.d.ts +23 -0
- package/dist/modes/interactive/session-share.d.ts.map +1 -0
- package/dist/modes/interactive/session-share.js +130 -0
- package/dist/modes/interactive/session-share.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +54 -63
- package/dist/modes/interactive/theme/light.json +52 -60
- package/dist/modes/interactive/theme/system-theme.d.ts +54 -0
- package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/system-theme.js +535 -0
- package/dist/modes/interactive/theme/system-theme.js.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +59 -7
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +164 -51
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-json.d.ts +85 -0
- package/dist/modes/interactive/theme/theme-json.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-json.js +132 -0
- package/dist/modes/interactive/theme/theme-json.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.json +24 -3
- package/dist/modes/interactive/theme/theme.d.ts +80 -42
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +274 -417
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/tui-renderer.d.ts +22 -0
- package/dist/modes/interactive/tui-renderer.d.ts.map +1 -0
- package/dist/modes/interactive/tui-renderer.js +67 -0
- package/dist/modes/interactive/tui-renderer.js.map +1 -0
- package/dist/modes/json-event.d.ts +34 -0
- package/dist/modes/json-event.d.ts.map +1 -0
- package/dist/modes/json-event.js +29 -0
- package/dist/modes/json-event.js.map +1 -0
- package/dist/modes/print-mode.d.ts +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +12 -2
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +17 -9
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +27 -15
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +14 -12
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +22 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts +1 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +217 -63
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/prompts/commands/plan-phase.md +1 -0
- package/dist/prompts/commands/review.md +2 -0
- package/dist/prompts/commands/verify-work.md +1 -0
- package/dist/prompts/commands/why.md +4 -0
- package/dist/rpc-entry.js +1 -0
- package/dist/rpc-entry.js.map +1 -1
- package/dist/skills/blast-radius/SKILL.md +1 -0
- package/dist/skills/explainers/SKILL.md +65 -0
- package/dist/skills/unslop/SKILL.md +19 -1
- package/dist/utils/abort.d.ts +5 -0
- package/dist/utils/abort.d.ts.map +1 -0
- package/dist/utils/abort.js +48 -0
- package/dist/utils/abort.js.map +1 -0
- package/dist/utils/changelog.js +1 -1
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/child-process.d.ts +1 -1
- package/dist/utils/child-process.js +1 -1
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts +7 -0
- package/dist/utils/clipboard-command.d.ts.map +1 -0
- package/dist/utils/clipboard-command.js +45 -0
- package/dist/utils/clipboard-command.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +60 -91
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +116 -121
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/draht-user-agent.d.ts +2 -0
- package/dist/utils/draht-user-agent.d.ts.map +1 -0
- package/dist/utils/draht-user-agent.js +5 -0
- package/dist/utils/draht-user-agent.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +2 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +2 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/management-http.d.ts +25 -0
- package/dist/utils/management-http.d.ts.map +1 -0
- package/dist/utils/management-http.js +54 -0
- package/dist/utils/management-http.js.map +1 -0
- package/dist/utils/mime.js +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/paths.d.ts +4 -3
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +15 -4
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/photon.d.ts +2 -1
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/shell.d.ts +4 -3
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +20 -35
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +62 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/text.d.ts +8 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -0
- package/dist/utils/tool-result-images.d.ts +21 -0
- package/dist/utils/tool-result-images.d.ts.map +1 -0
- package/dist/utils/tool-result-images.js +48 -0
- package/dist/utils/tool-result-images.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +11 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +53 -36
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts +4 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +30 -9
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/wsl.d.ts +3 -0
- package/dist/utils/wsl.d.ts.map +1 -0
- package/dist/utils/wsl.js +15 -0
- package/dist/utils/wsl.js.map +1 -0
- package/dist/utils/zip.d.ts +7 -0
- package/dist/utils/zip.d.ts.map +1 -0
- package/dist/utils/zip.js +60 -0
- package/dist/utils/zip.js.map +1 -0
- package/docs/cli-integration.md +106 -0
- package/docs/cli.md +374 -0
- package/docs/compaction.md +91 -29
- package/docs/configuration.md +47 -0
- package/docs/containerization.md +100 -66
- package/docs/custom-provider.md +109 -707
- package/docs/docs.json +155 -99
- package/docs/environment-variables.md +30 -17
- package/docs/extensions.md +169 -2811
- package/docs/how-pi-works.md +53 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/index.md +25 -69
- package/docs/json.md +197 -56
- package/docs/keybindings.md +89 -93
- package/docs/llama-cpp.md +18 -3
- package/docs/mcp.md +231 -0
- package/docs/message-types.md +261 -0
- package/docs/models.md +94 -478
- package/docs/packages.md +67 -163
- package/docs/prompt-templates.md +31 -68
- package/docs/providers.md +118 -215
- package/docs/quickstart.md +55 -108
- package/docs/rpc-commands.md +860 -0
- package/docs/rpc-extension-ui.md +200 -0
- package/docs/rpc.md +139 -1518
- package/docs/sdk.md +79 -1127
- package/docs/security.md +76 -32
- package/docs/session-format.md +73 -219
- package/docs/sessions.md +36 -116
- package/docs/settings.md +124 -257
- package/docs/shell-aliases.md +85 -5
- package/docs/skills.md +52 -189
- package/docs/slash-commands.md +61 -0
- package/docs/terminal-setup.md +132 -61
- package/docs/termux.md +74 -84
- package/docs/themes.md +91 -252
- package/docs/tmux.md +31 -39
- package/docs/tui.md +74 -891
- package/docs/usage.md +54 -255
- package/docs/virtual-models.md +114 -0
- package/docs/windows.md +57 -7
- package/examples/extensions/antigravity-image-gen.ts +9 -9
- package/examples/extensions/bash-spawn-hook.ts +1 -1
- package/examples/extensions/border-status-editor.ts +1 -1
- package/examples/extensions/built-in-tool-renderer.ts +16 -40
- package/examples/extensions/custom-compaction.ts +1 -16
- package/examples/extensions/custom-provider-anthropic/index.ts +20 -13
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +4 -3
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +5 -5
- package/examples/extensions/debug-provider.ts +90 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +7 -3
- package/examples/extensions/dynamic-resources/dynamic.json +3 -1
- package/examples/extensions/git-checkpoint.ts +2 -2
- package/examples/extensions/handoff.ts +2 -11
- package/examples/extensions/jev-router.ts +113 -0
- package/examples/extensions/minimal-mode.ts +24 -96
- package/examples/extensions/notify.ts +3 -1
- package/examples/extensions/prompt-customizer.ts +19 -67
- package/examples/extensions/qna.ts +3 -7
- package/examples/extensions/subagent/agents.ts +40 -9
- package/examples/extensions/subagent/index.ts +27 -4
- package/examples/extensions/summarize.ts +7 -18
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/rpc-client.ts +35 -0
- package/examples/rpc-extension-ui.ts +38 -9
- package/examples/sdk/02-custom-model.ts +1 -2
- package/examples/sdk/06-extensions.ts +1 -1
- package/examples/sdk/09-api-keys-and-oauth.ts +1 -1
- package/examples/sdk/12-full-control.ts +1 -1
- package/examples/sdk/14-codemode-mcp.ts +61 -0
- package/package.json +25 -30
- package/prompts/commands/plan-phase.md +1 -0
- package/prompts/commands/review.md +2 -0
- package/prompts/commands/verify-work.md +1 -0
- package/prompts/commands/why.md +4 -0
- package/skills/blast-radius/SKILL.md +1 -0
- package/skills/explainers/SKILL.md +65 -0
- package/skills/unslop/SKILL.md +19 -1
- package/dist/utils/clipboard-native.d.ts +0 -11
- package/dist/utils/clipboard-native.d.ts.map +0 -1
- package/dist/utils/clipboard-native.js +0 -20
- package/dist/utils/clipboard-native.js.map +0 -1
- package/dist/utils/pi-user-agent.d.ts +0 -2
- package/dist/utils/pi-user-agent.d.ts.map +0 -1
- package/dist/utils/pi-user-agent.js +0 -5
- package/dist/utils/pi-user-agent.js.map +0 -1
- package/docs/development.md +0 -71
- package/docs/tree.md +0 -231
- package/examples/extensions/kimi-deferred-tools.ts +0 -61
package/docs/tui.md
CHANGED
|
@@ -1,942 +1,125 @@
|
|
|
1
|
-
|
|
1
|
+
# Terminal UI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@draht/tui` provides the terminal component system used by draht. Extensions use it when built-in dialogs, notifications, status text, and widgets are not enough for the interaction they need.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Start with `ctx.ui` methods from an [extension](extensions.md#interact-with-the-user). Build a custom component only when the UI needs its own rendering, keyboard or mouse input, focus, layout, or lifecycle.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Choose an integration point
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
| Need | Use |
|
|
10
|
+
|---|---|
|
|
11
|
+
| Select, confirm, input, or multi-line editor | `ctx.ui.select()`, `confirm()`, `input()`, or `editor()` |
|
|
12
|
+
| Non-blocking feedback | `ctx.ui.notify()` or `setStatus()` |
|
|
13
|
+
| Persistent content near the editor | `ctx.ui.setWidget()` |
|
|
14
|
+
| Replace the header, footer, or editor | The corresponding `ctx.ui` component factory |
|
|
15
|
+
| Temporary interactive screen or overlay | `ctx.ui.custom()` |
|
|
16
|
+
| Custom rendering for a tool or session entry | An extension renderer |
|
|
10
17
|
|
|
11
|
-
|
|
18
|
+
These APIs receive draht’s active theme and keybindings where needed. Do not create a second terminal renderer inside an extension.
|
|
12
19
|
|
|
13
|
-
|
|
14
|
-
interface Component {
|
|
15
|
-
render(width: number): string[];
|
|
16
|
-
handleInput?(data: string): void;
|
|
17
|
-
wantsKeyRelease?: boolean;
|
|
18
|
-
invalidate(): void;
|
|
19
|
-
}
|
|
20
|
-
```
|
|
20
|
+
## Understand the component model
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|--------|-------------|
|
|
24
|
-
| `render(width)` | Return array of strings (one per line). Each line **must not exceed `width`**. |
|
|
25
|
-
| `handleInput?(data)` | Receive keyboard input when component has focus. |
|
|
26
|
-
| `wantsKeyRelease?` | If true, component receives key release events (Kitty protocol). Default: false. |
|
|
27
|
-
| `invalidate()` | Clear cached render state. Called on theme changes. |
|
|
22
|
+
A component renders an array of terminal lines for an available width. It can optionally handle keyboard and mouse input, and it must invalidate cached output when its state or theme-dependent content changes.
|
|
28
23
|
|
|
29
|
-
|
|
24
|
+
Every rendered line must fit within the supplied width. Measure visible terminal columns rather than string length because ANSI escapes, wide characters, emoji, and combining characters change display width.
|
|
30
25
|
|
|
31
|
-
|
|
26
|
+
Use `visibleWidth()`, `truncateToWidth()`, `sliceByColumn()`, and `wrapTextWithAnsi()` instead of implementing terminal-width handling yourself. draht resets styling and hyperlinks after every line, so reapply styles on each rendered line.
|
|
32
27
|
|
|
33
|
-
|
|
28
|
+
After changing component state, invalidate the affected component and call the injected `tui.requestRender()`. The TUI coalesces render requests and updates the terminal.
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
import { CURSOR_MARKER, type Component, type Focusable } from "@draht/tui";
|
|
37
|
-
|
|
38
|
-
class MyInput implements Component, Focusable {
|
|
39
|
-
focused: boolean = false; // Set by TUI when focus changes
|
|
40
|
-
|
|
41
|
-
render(width: number): string[] {
|
|
42
|
-
const marker = this.focused ? CURSOR_MARKER : "";
|
|
43
|
-
// Emit marker right before the fake cursor
|
|
44
|
-
return [`> ${beforeCursor}${marker}\x1b[7m${atCursor}\x1b[27m${afterCursor}`];
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
```
|
|
30
|
+
## Compose built-in components
|
|
48
31
|
|
|
49
|
-
|
|
50
|
-
1. Sets `focused = true` on the component
|
|
51
|
-
2. Scans rendered output for `CURSOR_MARKER` (a zero-width APC escape sequence)
|
|
52
|
-
3. Positions the hardware terminal cursor at that location
|
|
53
|
-
4. Shows the hardware cursor only when `showHardwareCursor` is enabled
|
|
32
|
+
The package includes components for common layouts and controls:
|
|
54
33
|
|
|
55
|
-
|
|
34
|
+
- `Text`, `Markdown`, `Image`, and `TruncatedText` render content.
|
|
35
|
+
- `Container`, `VStack`, `HStack`, `Box`, and `Spacer` compose layouts.
|
|
36
|
+
- `Input` and `Editor` accept text.
|
|
37
|
+
- `SelectList` and `SettingsList` implement searchable selection and settings flows.
|
|
38
|
+
- `ScrollView` provides a bounded scrollable viewport.
|
|
39
|
+
- `Loader` and `CancellableLoader` report ongoing work.
|
|
40
|
+
- `MouseRegion` adds pointer behavior around another component.
|
|
56
41
|
|
|
57
|
-
|
|
42
|
+
Prefer these components over rebuilding selection, scrolling, text editing, or width handling. The extension examples show how to combine them with draht’s borders and themes.
|
|
58
43
|
|
|
59
|
-
|
|
44
|
+
## Handle keyboard input and focus
|
|
60
45
|
|
|
61
|
-
|
|
62
|
-
import { Container, type Focusable, Input } from "@draht/tui";
|
|
63
|
-
|
|
64
|
-
class SearchDialog extends Container implements Focusable {
|
|
65
|
-
private searchInput: Input;
|
|
66
|
-
|
|
67
|
-
// Focusable implementation - propagate to child input for IME cursor positioning
|
|
68
|
-
private _focused = false;
|
|
69
|
-
get focused(): boolean {
|
|
70
|
-
return this._focused;
|
|
71
|
-
}
|
|
72
|
-
set focused(value: boolean) {
|
|
73
|
-
this._focused = value;
|
|
74
|
-
this.searchInput.focused = value;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
constructor() {
|
|
78
|
-
super();
|
|
79
|
-
this.searchInput = new Input();
|
|
80
|
-
this.addChild(this.searchInput);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
```
|
|
46
|
+
Use `matchesKey()` and `Key` for terminal keyboard input. The parser accounts for supported terminal protocols and key modifiers. Extension components should use the injected `KeybindingsManager` for configurable application actions.
|
|
84
47
|
|
|
85
|
-
|
|
48
|
+
A component that displays a text cursor should implement `Focusable` and place `CURSOR_MARKER` immediately before its visual cursor. The TUI uses that marker to position the hardware cursor for input method editors. Some terminals only place IME candidate windows next to a visible hardware cursor; set `DRAHT_HARDWARE_CURSOR=1` (or the `showHardwareCursor` setting) to show it. The coding agent reads `DRAHT_HARDWARE_CURSOR` and `DRAHT_CLEAR_ON_SHRINK` and passes them to the TUI; `@draht/tui` itself does not read environment variables.
|
|
86
49
|
|
|
87
|
-
|
|
50
|
+
Containers that wrap an `Input` or `Editor` must propagate their `focused` state to that child. Without propagation, Chinese, Japanese, Korean, and other IME candidate windows can appear at the wrong screen position.
|
|
88
51
|
|
|
89
|
-
|
|
52
|
+
Extend draht’s `CustomEditor` when replacing the main editor. It preserves application shortcuts and agent controls.
|
|
90
53
|
|
|
91
|
-
|
|
92
|
-
pi.on("session_start", async (_event, ctx) => {
|
|
93
|
-
const result = await ctx.ui.custom<string | null>((tui, theme, keybindings, done) =>
|
|
94
|
-
new MyComponent({
|
|
95
|
-
theme,
|
|
96
|
-
keybindings,
|
|
97
|
-
onChange: () => tui.requestRender(),
|
|
98
|
-
onSelect: (value) => done(value),
|
|
99
|
-
onCancel: () => done(null),
|
|
100
|
-
})
|
|
101
|
-
);
|
|
102
|
-
});
|
|
103
|
-
```
|
|
54
|
+
Forward keys your editor does not own to the base implementation, and restore the default by clearing the custom editor factory.
|
|
104
55
|
|
|
105
|
-
|
|
56
|
+
## Handle mouse input
|
|
106
57
|
|
|
107
|
-
|
|
108
|
-
async execute(toolCallId, params, signal, onUpdate, ctx) {
|
|
109
|
-
const result = await ctx.ui.custom<string | null>((tui, theme, keybindings, done) =>
|
|
110
|
-
new MyComponent({
|
|
111
|
-
theme,
|
|
112
|
-
keybindings,
|
|
113
|
-
onChange: () => tui.requestRender(),
|
|
114
|
-
onSelect: (value) => done(value),
|
|
115
|
-
onCancel: () => done(null),
|
|
116
|
-
})
|
|
117
|
-
);
|
|
118
|
-
// Use result...
|
|
119
|
-
}
|
|
120
|
-
```
|
|
58
|
+
Fullscreen mode routes normalized mouse events to components. A handler can mark an event handled, capture a drag sequence, request focus, or request a render.
|
|
121
59
|
|
|
122
|
-
|
|
60
|
+
Unhandled wheel events scroll the nearest `ScrollView`. Unhandled primary-button drags remain available for transcript selection. OSC 8 links take precedence over enclosing click regions.
|
|
123
61
|
|
|
124
|
-
|
|
62
|
+
Regular mode leaves mouse input to the terminal because the terminal owns scrollback. Design every interaction with a keyboard path even when fullscreen mouse input is available.
|
|
125
63
|
|
|
126
|
-
|
|
127
|
-
const result = await ctx.ui.custom<string | null>(
|
|
128
|
-
(tui, theme, keybindings, done) => new MyDialog({ onClose: done }),
|
|
129
|
-
{ overlay: true }
|
|
130
|
-
);
|
|
131
|
-
```
|
|
64
|
+
## Use custom screens and overlays
|
|
132
65
|
|
|
133
|
-
|
|
66
|
+
`ctx.ui.custom()` temporarily gives one component control of the interactive area and resolves when that component calls the supplied completion callback.
|
|
134
67
|
|
|
135
|
-
|
|
136
|
-
const result = await ctx.ui.custom<string | null>(
|
|
137
|
-
(tui, theme, keybindings, done) => new SidePanel({ onClose: done }),
|
|
138
|
-
{
|
|
139
|
-
overlay: true,
|
|
140
|
-
overlayOptions: {
|
|
141
|
-
// Size: number or percentage string
|
|
142
|
-
width: "50%", // 50% of terminal width
|
|
143
|
-
minWidth: 40, // minimum 40 columns
|
|
144
|
-
maxHeight: "80%", // max 80% of terminal height
|
|
145
|
-
|
|
146
|
-
// Position: anchor-based (default: "center")
|
|
147
|
-
anchor: "right-center", // 9 positions: center, top-left, top-center, etc.
|
|
148
|
-
offsetX: -2, // offset from anchor
|
|
149
|
-
offsetY: 0,
|
|
150
|
-
|
|
151
|
-
// Or percentage/absolute positioning
|
|
152
|
-
row: "25%", // 25% from top
|
|
153
|
-
col: 10, // column 10
|
|
154
|
-
|
|
155
|
-
// Margins
|
|
156
|
-
margin: 2, // all sides, or { top, right, bottom, left }
|
|
157
|
-
|
|
158
|
-
// Responsive: hide on narrow terminals
|
|
159
|
-
visible: (termWidth, termHeight) => termWidth >= 80,
|
|
160
|
-
},
|
|
161
|
-
// Get handle for programmatic focus and visibility control
|
|
162
|
-
onHandle: (handle) => {
|
|
163
|
-
// handle.focus() - focus this overlay and bring it to the visual front
|
|
164
|
-
// handle.unfocus() - release input to normal fallback
|
|
165
|
-
// handle.unfocus({ target }) - release input to a specific component or null
|
|
166
|
-
// handle.setHidden(true/false) - toggle visibility
|
|
167
|
-
// handle.hide() - permanently remove
|
|
168
|
-
},
|
|
169
|
-
}
|
|
170
|
-
);
|
|
171
|
-
```
|
|
68
|
+
Pass `overlay: true` to draw above existing content. Overlay options control size, anchors, offsets, margins, and responsive visibility. An overlay handle can change focus or temporarily hide and show the overlay with `setHidden()` while the interaction remains active.
|
|
172
69
|
|
|
173
|
-
|
|
70
|
+
Focused overlays retain input ownership across ordinary renders. If another component should receive input while an overlay remains visible, explicitly release or redirect focus through the handle.
|
|
174
71
|
|
|
175
|
-
|
|
72
|
+
Treat each custom component instance as belonging to one interaction. Create a new instance when starting that interaction again.
|
|
176
73
|
|
|
177
|
-
|
|
74
|
+
Finish the interaction with the completion callback supplied to the component factory. It resolves the `ctx.ui.custom()` promise and disposes the component. Do not call `OverlayHandle.hide()` on an overlay created by `ctx.ui.custom()`.
|
|
178
75
|
|
|
179
|
-
|
|
76
|
+
See [`overlay-qa-tests.ts`](../examples/extensions/overlay-qa-tests.ts) for positioning, stacking, focus, responsive visibility, and animation behavior.
|
|
180
77
|
|
|
181
|
-
|
|
78
|
+
## Apply themes correctly
|
|
182
79
|
|
|
183
|
-
|
|
184
|
-
// Wrong - stale reference
|
|
185
|
-
let menu: MenuComponent;
|
|
186
|
-
await ctx.ui.custom((_, __, ___, done) => {
|
|
187
|
-
menu = new MenuComponent(done);
|
|
188
|
-
return menu;
|
|
189
|
-
}, { overlay: true });
|
|
190
|
-
setActiveComponent(menu); // Disposed
|
|
191
|
-
|
|
192
|
-
// Correct - re-call to re-show
|
|
193
|
-
const showMenu = () => ctx.ui.custom((_, __, ___, done) =>
|
|
194
|
-
new MenuComponent(done), { overlay: true });
|
|
195
|
-
|
|
196
|
-
await showMenu(); // First show
|
|
197
|
-
await showMenu(); // "Back" = just call again
|
|
198
|
-
```
|
|
80
|
+
Use the theme passed to the extension or component callback. Theme helpers produce ANSI-styled strings for semantic colors such as accent, muted text, success, warnings, errors, tool output, and Markdown.
|
|
199
81
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
## Built-in Components
|
|
203
|
-
|
|
204
|
-
Import from `@draht/tui`:
|
|
82
|
+
Use `theme.style()` to combine foreground and background colors with text attributes:
|
|
205
83
|
|
|
206
84
|
```typescript
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const text = new Text(
|
|
216
|
-
"Hello World", // content
|
|
217
|
-
1, // paddingX (default: 1)
|
|
218
|
-
1, // paddingY (default: 1)
|
|
219
|
-
(s) => bgGray(s) // optional background function
|
|
85
|
+
return new Text(
|
|
86
|
+
theme.style("Done!", {
|
|
87
|
+
fg: "success",
|
|
88
|
+
bg: "toolSuccessBg",
|
|
89
|
+
bold: true,
|
|
90
|
+
}),
|
|
91
|
+
0,
|
|
92
|
+
0,
|
|
220
93
|
);
|
|
221
|
-
text.setText("Updated");
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### Box
|
|
225
|
-
|
|
226
|
-
Container with padding and background color.
|
|
227
|
-
|
|
228
|
-
```typescript
|
|
229
|
-
const box = new Box(
|
|
230
|
-
1, // paddingX
|
|
231
|
-
1, // paddingY
|
|
232
|
-
(s) => bgGray(s) // background function
|
|
233
|
-
);
|
|
234
|
-
box.addChild(new Text("Content", 0, 0));
|
|
235
|
-
box.setBgFn((s) => bgBlue(s));
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### Container
|
|
239
|
-
|
|
240
|
-
Groups child components vertically.
|
|
241
|
-
|
|
242
|
-
```typescript
|
|
243
|
-
const container = new Container();
|
|
244
|
-
container.addChild(component1);
|
|
245
|
-
container.addChild(component2);
|
|
246
|
-
container.removeChild(component1);
|
|
247
94
|
```
|
|
248
95
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
Empty vertical space.
|
|
252
|
-
|
|
253
|
-
```typescript
|
|
254
|
-
const spacer = new Spacer(2); // 2 empty lines
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
### Markdown
|
|
258
|
-
|
|
259
|
-
Renders markdown with syntax highlighting.
|
|
260
|
-
|
|
261
|
-
```typescript
|
|
262
|
-
const md = new Markdown(
|
|
263
|
-
"# Title\n\nSome **bold** text",
|
|
264
|
-
1, // paddingX
|
|
265
|
-
1, // paddingY
|
|
266
|
-
theme // MarkdownTheme (see below)
|
|
267
|
-
);
|
|
268
|
-
md.setText("Updated markdown");
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
### Image
|
|
272
|
-
|
|
273
|
-
Renders images in supported terminals (Kitty, iTerm2, Ghostty, WezTerm).
|
|
274
|
-
|
|
275
|
-
```typescript
|
|
276
|
-
const image = new Image(
|
|
277
|
-
base64Data, // base64-encoded image
|
|
278
|
-
"image/png", // MIME type
|
|
279
|
-
theme, // ImageTheme
|
|
280
|
-
{ maxWidthCells: 80, maxHeightCells: 24 }
|
|
281
|
-
);
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
## Keyboard Input
|
|
285
|
-
|
|
286
|
-
Use `matchesKey()` for key detection:
|
|
287
|
-
|
|
288
|
-
```typescript
|
|
289
|
-
import { matchesKey, Key } from "@draht/tui";
|
|
290
|
-
|
|
291
|
-
handleInput(data: string) {
|
|
292
|
-
if (matchesKey(data, Key.up)) {
|
|
293
|
-
this.selectedIndex--;
|
|
294
|
-
} else if (matchesKey(data, Key.enter)) {
|
|
295
|
-
this.onSelect?.(this.selectedIndex);
|
|
296
|
-
} else if (matchesKey(data, Key.escape)) {
|
|
297
|
-
this.onCancel?.();
|
|
298
|
-
} else if (matchesKey(data, Key.ctrl("c"))) {
|
|
299
|
-
// Ctrl+C
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
**Key identifiers** (use `Key.*` for autocomplete, or string literals):
|
|
305
|
-
- Basic keys: `Key.enter`, `Key.escape`, `Key.tab`, `Key.space`, `Key.backspace`, `Key.delete`, `Key.home`, `Key.end`
|
|
306
|
-
- Arrow keys: `Key.up`, `Key.down`, `Key.left`, `Key.right`
|
|
307
|
-
- With modifiers: `Key.ctrl("c")`, `Key.shift("tab")`, `Key.alt("left")`, `Key.ctrlShift("p")`
|
|
308
|
-
- String format also works: `"enter"`, `"ctrl+c"`, `"shift+tab"`, `"ctrl+shift+p"`
|
|
309
|
-
|
|
310
|
-
## Line Width
|
|
311
|
-
|
|
312
|
-
**Critical:** Each line from `render()` must not exceed the `width` parameter.
|
|
313
|
-
|
|
314
|
-
```typescript
|
|
315
|
-
import { visibleWidth, truncateToWidth } from "@draht/tui";
|
|
316
|
-
|
|
317
|
-
render(width: number): string[] {
|
|
318
|
-
// Truncate long lines
|
|
319
|
-
return [truncateToWidth(this.text, width)];
|
|
320
|
-
}
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
Utilities:
|
|
324
|
-
- `visibleWidth(str)` - Get display width (ignores ANSI codes)
|
|
325
|
-
- `truncateToWidth(str, width, ellipsis?)` - Truncate with optional ellipsis
|
|
326
|
-
- `wrapTextWithAnsi(str, width)` - Word wrap preserving ANSI codes
|
|
327
|
-
|
|
328
|
-
## Creating Custom Components
|
|
329
|
-
|
|
330
|
-
Example: Interactive selector
|
|
331
|
-
|
|
332
|
-
```typescript
|
|
333
|
-
import {
|
|
334
|
-
matchesKey, Key,
|
|
335
|
-
truncateToWidth, visibleWidth
|
|
336
|
-
} from "@draht/tui";
|
|
337
|
-
|
|
338
|
-
class MySelector {
|
|
339
|
-
private items: string[];
|
|
340
|
-
private selected = 0;
|
|
341
|
-
private cachedWidth?: number;
|
|
342
|
-
private cachedLines?: string[];
|
|
343
|
-
|
|
344
|
-
public onSelect?: (item: string) => void;
|
|
345
|
-
public onCancel?: () => void;
|
|
346
|
-
|
|
347
|
-
constructor(items: string[]) {
|
|
348
|
-
this.items = items;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
handleInput(data: string): void {
|
|
352
|
-
if (matchesKey(data, Key.up) && this.selected > 0) {
|
|
353
|
-
this.selected--;
|
|
354
|
-
this.invalidate();
|
|
355
|
-
} else if (matchesKey(data, Key.down) && this.selected < this.items.length - 1) {
|
|
356
|
-
this.selected++;
|
|
357
|
-
this.invalidate();
|
|
358
|
-
} else if (matchesKey(data, Key.enter)) {
|
|
359
|
-
this.onSelect?.(this.items[this.selected]);
|
|
360
|
-
} else if (matchesKey(data, Key.escape)) {
|
|
361
|
-
this.onCancel?.();
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
render(width: number): string[] {
|
|
366
|
-
if (this.cachedLines && this.cachedWidth === width) {
|
|
367
|
-
return this.cachedLines;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
this.cachedLines = this.items.map((item, i) => {
|
|
371
|
-
const prefix = i === this.selected ? "> " : " ";
|
|
372
|
-
return truncateToWidth(prefix + item, width);
|
|
373
|
-
});
|
|
374
|
-
this.cachedWidth = width;
|
|
375
|
-
return this.cachedLines;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
invalidate(): void {
|
|
379
|
-
this.cachedWidth = undefined;
|
|
380
|
-
this.cachedLines = undefined;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
Usage in an extension:
|
|
386
|
-
|
|
387
|
-
```typescript
|
|
388
|
-
pi.registerCommand("pick", {
|
|
389
|
-
description: "Pick an item",
|
|
390
|
-
handler: async (_args, ctx) => {
|
|
391
|
-
const items = ["Option A", "Option B", "Option C"];
|
|
392
|
-
const selected = await ctx.ui.custom<string | null>((tui, _theme, _keybindings, done) => {
|
|
393
|
-
const selector = new MySelector(items);
|
|
394
|
-
selector.onSelect = done;
|
|
395
|
-
selector.onCancel = () => done(null);
|
|
396
|
-
|
|
397
|
-
return {
|
|
398
|
-
render: (width) => selector.render(width),
|
|
399
|
-
handleInput: (data) => {
|
|
400
|
-
selector.handleInput(data);
|
|
401
|
-
tui.requestRender();
|
|
402
|
-
},
|
|
403
|
-
invalidate: () => selector.invalidate(),
|
|
404
|
-
};
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
if (selected !== null) {
|
|
408
|
-
ctx.ui.notify(`Selected: ${selected}`, "info");
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
});
|
|
412
|
-
```
|
|
413
|
-
|
|
414
|
-
## Theming
|
|
415
|
-
|
|
416
|
-
Components accept theme objects for styling.
|
|
417
|
-
|
|
418
|
-
**In `renderCall`/`renderResult`**, use the `theme` parameter:
|
|
419
|
-
|
|
420
|
-
```typescript
|
|
421
|
-
renderResult(result, options, theme, context) {
|
|
422
|
-
// Use theme.fg() for foreground colors
|
|
423
|
-
return new Text(theme.fg("success", "Done!"), 0, 0);
|
|
424
|
-
|
|
425
|
-
// Use theme.bg() for background colors
|
|
426
|
-
const styled = theme.bg("toolPendingBg", theme.fg("accent", "text"));
|
|
427
|
-
}
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
**Foreground colors** (`theme.fg(color, text)`):
|
|
431
|
-
|
|
432
|
-
| Category | Colors |
|
|
433
|
-
|----------|--------|
|
|
434
|
-
| General | `text`, `accent`, `muted`, `dim` |
|
|
435
|
-
| Status | `success`, `error`, `warning` |
|
|
436
|
-
| Borders | `border`, `borderAccent`, `borderMuted` |
|
|
437
|
-
| Messages | `userMessageText`, `customMessageText`, `customMessageLabel` |
|
|
438
|
-
| Tools | `toolTitle`, `toolOutput` |
|
|
439
|
-
| Diffs | `toolDiffAdded`, `toolDiffRemoved`, `toolDiffContext` |
|
|
440
|
-
| Markdown | `mdHeading`, `mdLink`, `mdLinkUrl`, `mdCode`, `mdCodeBlock`, `mdCodeBlockBorder`, `mdQuote`, `mdQuoteBorder`, `mdHr`, `mdListBullet` |
|
|
441
|
-
| Syntax | `syntaxComment`, `syntaxKeyword`, `syntaxFunction`, `syntaxVariable`, `syntaxString`, `syntaxNumber`, `syntaxType`, `syntaxOperator`, `syntaxPunctuation` |
|
|
442
|
-
| Thinking | `thinkingOff`, `thinkingMinimal`, `thinkingLow`, `thinkingMedium`, `thinkingHigh`, `thinkingXhigh`, `thinkingMax` |
|
|
443
|
-
| Modes | `bashMode` |
|
|
444
|
-
|
|
445
|
-
**Background colors** (`theme.bg(color, text)`):
|
|
446
|
-
|
|
447
|
-
`selectedBg`, `userMessageBg`, `customMessageBg`, `toolPendingBg`, `toolSuccessBg`, `toolErrorBg`
|
|
448
|
-
|
|
449
|
-
**For Markdown**, use `getMarkdownTheme()`:
|
|
450
|
-
|
|
451
|
-
```typescript
|
|
452
|
-
import { getMarkdownTheme } from "@draht/coding-agent";
|
|
453
|
-
import { Markdown } from "@draht/tui";
|
|
454
|
-
|
|
455
|
-
renderResult(result, options, theme, context) {
|
|
456
|
-
const mdTheme = getMarkdownTheme();
|
|
457
|
-
return new Markdown(result.details.markdown, 0, 0, mdTheme);
|
|
458
|
-
}
|
|
459
|
-
```
|
|
96
|
+
A style color can be a semantic theme token or a concrete `Color`. Foreground tokens are accepted as `fg` and background tokens as `bg`; to use a token's color in the other position, pass its concrete color, for example `{ fg: theme.colors.userMessageBg }`. Access concrete colors through `theme.colors` and use utilities such as `mixColors()` from `@draht/tui` when color math is needed. Tokens that a theme sets to the terminal default render with the terminal's own color; `theme.colors` reports the color the terminal announced for them, or a guess when it did not. Use `theme.appearance` (`"dark"` or `"light"`) to decide, for example, whether to lighten or darken a color. draht converts the result to truecolor or 256-color output based on terminal capabilities. Theme tokens are converted once per theme; compute concrete colors outside the render path when possible.
|
|
460
97
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
```typescript
|
|
464
|
-
interface MyTheme {
|
|
465
|
-
selected: (s: string) => string;
|
|
466
|
-
normal: (s: string) => string;
|
|
467
|
-
}
|
|
468
|
-
```
|
|
469
|
-
|
|
470
|
-
## Debug logging
|
|
471
|
-
|
|
472
|
-
Set `PI_TUI_WRITE_LOG` to capture the raw ANSI stream written to stdout.
|
|
473
|
-
|
|
474
|
-
```bash
|
|
475
|
-
PI_TUI_WRITE_LOG=/tmp/tui-ansi.log npx tsx packages/tui/test/chat-simple.ts
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
## Performance
|
|
479
|
-
|
|
480
|
-
Cache rendered output when possible:
|
|
481
|
-
|
|
482
|
-
```typescript
|
|
483
|
-
class CachedComponent {
|
|
484
|
-
private cachedWidth?: number;
|
|
485
|
-
private cachedLines?: string[];
|
|
486
|
-
|
|
487
|
-
render(width: number): string[] {
|
|
488
|
-
if (this.cachedLines && this.cachedWidth === width) {
|
|
489
|
-
return this.cachedLines;
|
|
490
|
-
}
|
|
491
|
-
// ... compute lines ...
|
|
492
|
-
this.cachedWidth = width;
|
|
493
|
-
this.cachedLines = lines;
|
|
494
|
-
return lines;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
invalidate(): void {
|
|
498
|
-
this.cachedWidth = undefined;
|
|
499
|
-
this.cachedLines = undefined;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
```
|
|
503
|
-
|
|
504
|
-
Call `invalidate()` when state changes, then use the injected `tui.requestRender()` to trigger re-render.
|
|
505
|
-
|
|
506
|
-
## Invalidation and Theme Changes
|
|
507
|
-
|
|
508
|
-
When the theme changes, the TUI calls `invalidate()` on all components to clear their caches. Components must properly implement `invalidate()` to ensure theme changes take effect.
|
|
509
|
-
|
|
510
|
-
### The Problem
|
|
511
|
-
|
|
512
|
-
If a component pre-bakes theme colors into strings (via `theme.fg()`, `theme.bg()`, etc.) and caches them, the cached strings contain ANSI escape codes from the old theme. Simply clearing the render cache isn't enough if the component stores the themed content separately.
|
|
513
|
-
|
|
514
|
-
**Wrong approach** (theme colors won't update):
|
|
515
|
-
|
|
516
|
-
```typescript
|
|
517
|
-
class BadComponent extends Container {
|
|
518
|
-
private content: Text;
|
|
519
|
-
|
|
520
|
-
constructor(message: string, theme: Theme) {
|
|
521
|
-
super();
|
|
522
|
-
// Pre-baked theme colors stored in Text component
|
|
523
|
-
this.content = new Text(theme.fg("accent", message), 1, 0);
|
|
524
|
-
this.addChild(this.content);
|
|
525
|
-
}
|
|
526
|
-
// No invalidate override - parent's invalidate only clears
|
|
527
|
-
// child render caches, not the pre-baked content
|
|
528
|
-
}
|
|
529
|
-
```
|
|
530
|
-
|
|
531
|
-
### The Solution
|
|
532
|
-
|
|
533
|
-
Components that build content with theme colors must rebuild that content when `invalidate()` is called:
|
|
534
|
-
|
|
535
|
-
```typescript
|
|
536
|
-
class GoodComponent extends Container {
|
|
537
|
-
private message: string;
|
|
538
|
-
private content: Text;
|
|
539
|
-
|
|
540
|
-
constructor(message: string) {
|
|
541
|
-
super();
|
|
542
|
-
this.message = message;
|
|
543
|
-
this.content = new Text("", 1, 0);
|
|
544
|
-
this.addChild(this.content);
|
|
545
|
-
this.updateDisplay();
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
private updateDisplay(): void {
|
|
549
|
-
// Rebuild content with current theme
|
|
550
|
-
this.content.setText(theme.fg("accent", this.message));
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
override invalidate(): void {
|
|
554
|
-
super.invalidate(); // Clear child caches
|
|
555
|
-
this.updateDisplay(); // Rebuild with new theme
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
```
|
|
559
|
-
|
|
560
|
-
### Pattern: Rebuild on Invalidate
|
|
561
|
-
|
|
562
|
-
For components with complex content:
|
|
563
|
-
|
|
564
|
-
```typescript
|
|
565
|
-
class ComplexComponent extends Container {
|
|
566
|
-
private data: SomeData;
|
|
567
|
-
|
|
568
|
-
constructor(data: SomeData) {
|
|
569
|
-
super();
|
|
570
|
-
this.data = data;
|
|
571
|
-
this.rebuild();
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
private rebuild(): void {
|
|
575
|
-
this.clear(); // Remove all children
|
|
576
|
-
|
|
577
|
-
// Build UI with current theme
|
|
578
|
-
this.addChild(new Text(theme.fg("accent", theme.bold("Title")), 1, 0));
|
|
579
|
-
this.addChild(new Spacer(1));
|
|
580
|
-
|
|
581
|
-
for (const item of this.data.items) {
|
|
582
|
-
const color = item.active ? "success" : "muted";
|
|
583
|
-
this.addChild(new Text(theme.fg(color, item.label), 1, 0));
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
override invalidate(): void {
|
|
588
|
-
super.invalidate();
|
|
589
|
-
this.rebuild();
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
```
|
|
593
|
-
|
|
594
|
-
### When This Matters
|
|
595
|
-
|
|
596
|
-
This pattern is needed when:
|
|
597
|
-
|
|
598
|
-
1. **Pre-baking theme colors** - Using `theme.fg()` or `theme.bg()` to create styled strings stored in child components
|
|
599
|
-
2. **Syntax highlighting** - Using `highlightCode()` which applies theme-based syntax colors
|
|
600
|
-
3. **Complex layouts** - Building child component trees that embed theme colors
|
|
601
|
-
|
|
602
|
-
This pattern is NOT needed when:
|
|
603
|
-
|
|
604
|
-
1. **Using theme callbacks** - Passing functions like `(text) => theme.fg("accent", text)` that are called during render
|
|
605
|
-
2. **Simple containers** - Just grouping other components without adding themed content
|
|
606
|
-
3. **Stateless render** - Computing themed output fresh in every `render()` call (no caching)
|
|
607
|
-
|
|
608
|
-
## Common Patterns
|
|
609
|
-
|
|
610
|
-
These patterns cover the most common UI needs in extensions. **Copy these patterns instead of building from scratch.**
|
|
611
|
-
|
|
612
|
-
### Pattern 1: Selection Dialog (SelectList)
|
|
613
|
-
|
|
614
|
-
For letting users pick from a list of options. Use `SelectList` from `@draht/tui` with `DynamicBorder` for framing.
|
|
615
|
-
|
|
616
|
-
```typescript
|
|
617
|
-
import type { ExtensionAPI } from "@draht/coding-agent";
|
|
618
|
-
import { DynamicBorder } from "@draht/coding-agent";
|
|
619
|
-
import { Container, type SelectItem, SelectList, Text } from "@draht/tui";
|
|
620
|
-
|
|
621
|
-
pi.registerCommand("pick", {
|
|
622
|
-
handler: async (_args, ctx) => {
|
|
623
|
-
const items: SelectItem[] = [
|
|
624
|
-
{ value: "opt1", label: "Option 1", description: "First option" },
|
|
625
|
-
{ value: "opt2", label: "Option 2", description: "Second option" },
|
|
626
|
-
{ value: "opt3", label: "Option 3" }, // description is optional
|
|
627
|
-
];
|
|
628
|
-
|
|
629
|
-
const result = await ctx.ui.custom<string | null>((tui, theme, _kb, done) => {
|
|
630
|
-
const container = new Container();
|
|
631
|
-
|
|
632
|
-
// Top border
|
|
633
|
-
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
634
|
-
|
|
635
|
-
// Title
|
|
636
|
-
container.addChild(new Text(theme.fg("accent", theme.bold("Pick an Option")), 1, 0));
|
|
637
|
-
|
|
638
|
-
// SelectList with theme
|
|
639
|
-
const selectList = new SelectList(items, Math.min(items.length, 10), {
|
|
640
|
-
selectedPrefix: (t) => theme.fg("accent", t),
|
|
641
|
-
selectedText: (t) => theme.fg("accent", t),
|
|
642
|
-
description: (t) => theme.fg("muted", t),
|
|
643
|
-
scrollInfo: (t) => theme.fg("dim", t),
|
|
644
|
-
noMatch: (t) => theme.fg("warning", t),
|
|
645
|
-
});
|
|
646
|
-
selectList.onSelect = (item) => done(item.value);
|
|
647
|
-
selectList.onCancel = () => done(null);
|
|
648
|
-
container.addChild(selectList);
|
|
649
|
-
|
|
650
|
-
// Help text
|
|
651
|
-
container.addChild(new Text(theme.fg("dim", "↑↓ navigate • enter select • esc cancel"), 1, 0));
|
|
652
|
-
|
|
653
|
-
// Bottom border
|
|
654
|
-
container.addChild(new DynamicBorder((s: string) => theme.fg("accent", s)));
|
|
655
|
-
|
|
656
|
-
return {
|
|
657
|
-
render: (w) => container.render(w),
|
|
658
|
-
invalidate: () => container.invalidate(),
|
|
659
|
-
handleInput: (data) => { selectList.handleInput(data); tui.requestRender(); },
|
|
660
|
-
};
|
|
661
|
-
});
|
|
662
|
-
|
|
663
|
-
if (result) {
|
|
664
|
-
ctx.ui.notify(`Selected: ${result}`, "info");
|
|
665
|
-
}
|
|
666
|
-
},
|
|
667
|
-
});
|
|
668
|
-
```
|
|
669
|
-
|
|
670
|
-
**Examples:** [preset.ts](../examples/extensions/preset.ts), [tools.ts](../examples/extensions/tools.ts)
|
|
671
|
-
|
|
672
|
-
### Pattern 2: Async Operation with Cancel (BorderedLoader)
|
|
673
|
-
|
|
674
|
-
For operations that take time and should be cancellable. `BorderedLoader` shows a spinner and handles escape to cancel.
|
|
675
|
-
|
|
676
|
-
```typescript
|
|
677
|
-
import { BorderedLoader } from "@draht/coding-agent";
|
|
678
|
-
|
|
679
|
-
pi.registerCommand("fetch", {
|
|
680
|
-
handler: async (_args, ctx) => {
|
|
681
|
-
const result = await ctx.ui.custom<string | null>((tui, theme, _kb, done) => {
|
|
682
|
-
const loader = new BorderedLoader(tui, theme, "Fetching data...");
|
|
683
|
-
loader.onAbort = () => done(null);
|
|
684
|
-
|
|
685
|
-
// Do async work
|
|
686
|
-
fetchData(loader.signal)
|
|
687
|
-
.then((data) => done(data))
|
|
688
|
-
.catch(() => done(null));
|
|
689
|
-
|
|
690
|
-
return loader;
|
|
691
|
-
});
|
|
692
|
-
|
|
693
|
-
if (result === null) {
|
|
694
|
-
ctx.ui.notify("Cancelled", "info");
|
|
695
|
-
} else {
|
|
696
|
-
ctx.ui.setEditorText(result);
|
|
697
|
-
}
|
|
698
|
-
},
|
|
699
|
-
});
|
|
700
|
-
```
|
|
701
|
-
|
|
702
|
-
**Examples:** [qna.ts](../examples/extensions/qna.ts), [handoff.ts](../examples/extensions/handoff.ts)
|
|
703
|
-
|
|
704
|
-
### Pattern 3: Settings/Toggles (SettingsList)
|
|
705
|
-
|
|
706
|
-
For toggling multiple settings. Use `SettingsList` from `@draht/tui` with `getSettingsListTheme()`.
|
|
707
|
-
|
|
708
|
-
```typescript
|
|
709
|
-
import { getSettingsListTheme } from "@draht/coding-agent";
|
|
710
|
-
import { Container, type SettingItem, SettingsList, Text } from "@draht/tui";
|
|
711
|
-
|
|
712
|
-
pi.registerCommand("settings", {
|
|
713
|
-
handler: async (_args, ctx) => {
|
|
714
|
-
const items: SettingItem[] = [
|
|
715
|
-
{ id: "verbose", label: "Verbose mode", currentValue: "off", values: ["on", "off"] },
|
|
716
|
-
{ id: "color", label: "Color output", currentValue: "on", values: ["on", "off"] },
|
|
717
|
-
];
|
|
718
|
-
|
|
719
|
-
await ctx.ui.custom((_tui, theme, _kb, done) => {
|
|
720
|
-
const container = new Container();
|
|
721
|
-
container.addChild(new Text(theme.fg("accent", theme.bold("Settings")), 1, 1));
|
|
722
|
-
|
|
723
|
-
const settingsList = new SettingsList(
|
|
724
|
-
items,
|
|
725
|
-
Math.min(items.length + 2, 15),
|
|
726
|
-
getSettingsListTheme(),
|
|
727
|
-
(id, newValue) => {
|
|
728
|
-
// Handle value change
|
|
729
|
-
ctx.ui.notify(`${id} = ${newValue}`, "info");
|
|
730
|
-
},
|
|
731
|
-
() => done(undefined), // On close
|
|
732
|
-
{ enableSearch: true }, // Optional: enable fuzzy search by label
|
|
733
|
-
);
|
|
734
|
-
container.addChild(settingsList);
|
|
735
|
-
|
|
736
|
-
return {
|
|
737
|
-
render: (w) => container.render(w),
|
|
738
|
-
invalidate: () => container.invalidate(),
|
|
739
|
-
handleInput: (data) => settingsList.handleInput?.(data),
|
|
740
|
-
};
|
|
741
|
-
});
|
|
742
|
-
},
|
|
743
|
-
});
|
|
744
|
-
```
|
|
745
|
-
|
|
746
|
-
**Examples:** [tools.ts](../examples/extensions/tools.ts)
|
|
747
|
-
|
|
748
|
-
### Pattern 4: Persistent Status Indicator
|
|
749
|
-
|
|
750
|
-
Show status in the footer that persists across renders. Good for mode indicators.
|
|
751
|
-
|
|
752
|
-
```typescript
|
|
753
|
-
// Set status (shown in footer)
|
|
754
|
-
ctx.ui.setStatus("my-ext", ctx.ui.theme.fg("accent", "● active"));
|
|
755
|
-
|
|
756
|
-
// Clear status
|
|
757
|
-
ctx.ui.setStatus("my-ext", undefined);
|
|
758
|
-
```
|
|
759
|
-
|
|
760
|
-
**Examples:** [status-line.ts](../examples/extensions/status-line.ts), [plan-mode.ts](../examples/extensions/plan-mode.ts), [preset.ts](../examples/extensions/preset.ts)
|
|
761
|
-
|
|
762
|
-
### Pattern 4b: Working Indicator Customization
|
|
763
|
-
|
|
764
|
-
Customize the inline working indicator shown while draht is streaming a response.
|
|
765
|
-
|
|
766
|
-
```typescript
|
|
767
|
-
// Static indicator
|
|
768
|
-
ctx.ui.setWorkingIndicator({ frames: [ctx.ui.theme.fg("accent", "●")] });
|
|
769
|
-
|
|
770
|
-
// Custom animated indicator
|
|
771
|
-
ctx.ui.setWorkingIndicator({
|
|
772
|
-
frames: [
|
|
773
|
-
ctx.ui.theme.fg("dim", "·"),
|
|
774
|
-
ctx.ui.theme.fg("muted", "•"),
|
|
775
|
-
ctx.ui.theme.fg("accent", "●"),
|
|
776
|
-
ctx.ui.theme.fg("muted", "•"),
|
|
777
|
-
],
|
|
778
|
-
intervalMs: 120,
|
|
779
|
-
});
|
|
780
|
-
|
|
781
|
-
// Hide the indicator entirely
|
|
782
|
-
ctx.ui.setWorkingIndicator({ frames: [] });
|
|
783
|
-
|
|
784
|
-
// Restore draht's default spinner
|
|
785
|
-
ctx.ui.setWorkingIndicator();
|
|
786
|
-
```
|
|
787
|
-
|
|
788
|
-
This only affects the normal streaming working indicator. Compaction and retry loaders keep their built-in styling. Custom frames are rendered verbatim, so extensions must add their own colors when needed.
|
|
789
|
-
|
|
790
|
-
**Examples:** [working-indicator.ts](../examples/extensions/working-indicator.ts)
|
|
791
|
-
|
|
792
|
-
### Pattern 5: Widgets Above/Below Editor
|
|
793
|
-
|
|
794
|
-
Show persistent content above or below the input editor. Good for todo lists, progress.
|
|
795
|
-
|
|
796
|
-
```typescript
|
|
797
|
-
// Simple string array (above editor by default)
|
|
798
|
-
ctx.ui.setWidget("my-widget", ["Line 1", "Line 2"]);
|
|
799
|
-
|
|
800
|
-
// Render below the editor
|
|
801
|
-
ctx.ui.setWidget("my-widget", ["Line 1", "Line 2"], { placement: "belowEditor" });
|
|
802
|
-
|
|
803
|
-
// Or with theme
|
|
804
|
-
ctx.ui.setWidget("my-widget", (_tui, theme) => {
|
|
805
|
-
const lines = items.map((item, i) =>
|
|
806
|
-
item.done
|
|
807
|
-
? theme.fg("success", "✓ ") + theme.fg("muted", item.text)
|
|
808
|
-
: theme.fg("dim", "○ ") + item.text
|
|
809
|
-
);
|
|
810
|
-
return {
|
|
811
|
-
render: () => lines,
|
|
812
|
-
invalidate: () => {},
|
|
813
|
-
};
|
|
814
|
-
});
|
|
815
|
-
|
|
816
|
-
// Clear
|
|
817
|
-
ctx.ui.setWidget("my-widget", undefined);
|
|
818
|
-
```
|
|
819
|
-
|
|
820
|
-
**Examples:** [plan-mode.ts](../examples/extensions/plan-mode.ts)
|
|
821
|
-
|
|
822
|
-
### Pattern 6: Custom Footer
|
|
823
|
-
|
|
824
|
-
Replace the footer. `footerData` exposes data not otherwise accessible to extensions.
|
|
825
|
-
|
|
826
|
-
```typescript
|
|
827
|
-
ctx.ui.setFooter((tui, theme, footerData) => ({
|
|
828
|
-
invalidate() {},
|
|
829
|
-
render(width: number): string[] {
|
|
830
|
-
// footerData.getGitBranch(): string | null
|
|
831
|
-
// footerData.getExtensionStatuses(): ReadonlyMap<string, string>
|
|
832
|
-
return [`${ctx.model?.id} (${footerData.getGitBranch() || "no git"})`];
|
|
833
|
-
},
|
|
834
|
-
dispose: footerData.onBranchChange(() => tui.requestRender()), // reactive
|
|
835
|
-
}));
|
|
836
|
-
|
|
837
|
-
ctx.ui.setFooter(undefined); // restore default
|
|
838
|
-
```
|
|
839
|
-
|
|
840
|
-
Token stats available via `ctx.sessionManager.getBranch()` and `ctx.model`.
|
|
841
|
-
|
|
842
|
-
**Examples:** [custom-footer.ts](../examples/extensions/custom-footer.ts)
|
|
843
|
-
|
|
844
|
-
### Pattern 7: Custom Editor (vim mode, etc.)
|
|
845
|
-
|
|
846
|
-
Replace the main input editor with a custom implementation. Useful for modal editing (vim), different keybindings (emacs), or specialized input handling.
|
|
847
|
-
|
|
848
|
-
```typescript
|
|
849
|
-
import { CustomEditor, type ExtensionAPI } from "@draht/coding-agent";
|
|
850
|
-
import { matchesKey, truncateToWidth } from "@draht/tui";
|
|
851
|
-
|
|
852
|
-
type Mode = "normal" | "insert";
|
|
853
|
-
|
|
854
|
-
class VimEditor extends CustomEditor {
|
|
855
|
-
private mode: Mode = "insert";
|
|
856
|
-
|
|
857
|
-
handleInput(data: string): void {
|
|
858
|
-
// Escape: switch to normal mode, or pass through for app handling
|
|
859
|
-
if (matchesKey(data, "escape")) {
|
|
860
|
-
if (this.mode === "insert") {
|
|
861
|
-
this.mode = "normal";
|
|
862
|
-
return;
|
|
863
|
-
}
|
|
864
|
-
// In normal mode, escape aborts agent (handled by CustomEditor)
|
|
865
|
-
super.handleInput(data);
|
|
866
|
-
return;
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
// Insert mode: pass everything to CustomEditor
|
|
870
|
-
if (this.mode === "insert") {
|
|
871
|
-
super.handleInput(data);
|
|
872
|
-
return;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
// Normal mode: vim-style navigation
|
|
876
|
-
switch (data) {
|
|
877
|
-
case "i": this.mode = "insert"; return;
|
|
878
|
-
case "h": super.handleInput("\x1b[D"); return; // Left
|
|
879
|
-
case "j": super.handleInput("\x1b[B"); return; // Down
|
|
880
|
-
case "k": super.handleInput("\x1b[A"); return; // Up
|
|
881
|
-
case "l": super.handleInput("\x1b[C"); return; // Right
|
|
882
|
-
}
|
|
883
|
-
// Pass unhandled keys to super (ctrl+c, etc.), but filter printable chars
|
|
884
|
-
if (data.length === 1 && data.charCodeAt(0) >= 32) return;
|
|
885
|
-
super.handleInput(data);
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
render(width: number): string[] {
|
|
889
|
-
const lines = super.render(width);
|
|
890
|
-
// Add mode indicator to bottom border (use truncateToWidth for ANSI-safe truncation)
|
|
891
|
-
if (lines.length > 0) {
|
|
892
|
-
const label = this.mode === "normal" ? " NORMAL " : " INSERT ";
|
|
893
|
-
const lastLine = lines[lines.length - 1]!;
|
|
894
|
-
// Pass "" as ellipsis to avoid adding "..." when truncating
|
|
895
|
-
lines[lines.length - 1] = truncateToWidth(lastLine, width - label.length, "") + label;
|
|
896
|
-
}
|
|
897
|
-
return lines;
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
export default function (pi: ExtensionAPI) {
|
|
902
|
-
pi.on("session_start", (_event, ctx) => {
|
|
903
|
-
// Factory receives the TUI, theme, and keybindings from the app
|
|
904
|
-
ctx.ui.setEditorComponent((tui, theme, keybindings) =>
|
|
905
|
-
new VimEditor(tui, theme, keybindings)
|
|
906
|
-
);
|
|
907
|
-
});
|
|
908
|
-
}
|
|
909
|
-
```
|
|
98
|
+
The existing `theme.fg()` and `theme.bg()` helpers remain available for applying one semantic color.
|
|
910
99
|
|
|
911
|
-
|
|
100
|
+
Do not permanently store strings with theme colors unless `invalidate()` rebuilds them. A theme change clears render caches, but it cannot remove old ANSI colors embedded in application state.
|
|
912
101
|
|
|
913
|
-
|
|
914
|
-
- **Call `super.handleInput(data)`** for keys you don't handle
|
|
915
|
-
- **Factory pattern**: `setEditorComponent` receives a factory function that gets `tui`, `theme`, and `keybindings`
|
|
916
|
-
- **Pass `undefined`** to restore the default editor: `ctx.ui.setEditorComponent(undefined)`
|
|
102
|
+
Theme callbacks evaluated during rendering do not need special rebuilding. Stateless components can also calculate themed output on every render.
|
|
917
103
|
|
|
918
|
-
|
|
104
|
+
Use [Themes](themes.md) to create terminal palettes. Use draht’s `getMarkdownTheme()` when rendering Markdown that should match the active application theme.
|
|
919
105
|
|
|
920
|
-
##
|
|
106
|
+
## Keep rendering responsive
|
|
921
107
|
|
|
922
|
-
|
|
108
|
+
Rendering runs on the interactive path. Cache expensive layout and highlighting work by width and content, then clear that cache from `invalidate()`.
|
|
923
109
|
|
|
924
|
-
|
|
110
|
+
Keep the default view compact and reveal detail through expansion or a dedicated screen. For custom tool rendering, handle partial results and reuse the previous component when it can be updated safely.
|
|
925
111
|
|
|
926
|
-
|
|
112
|
+
Use `DRAHT_TUI_WRITE_LOG` to capture the raw ANSI stream when diagnosing rendering problems. Test narrow widths, wide characters, resize events, theme changes, focus transitions, and both regular and fullscreen modes.
|
|
927
113
|
|
|
928
|
-
|
|
114
|
+
## Examples and source
|
|
929
115
|
|
|
930
|
-
|
|
116
|
+
The checked extension examples cover the main patterns:
|
|
931
117
|
|
|
932
|
-
|
|
118
|
+
- [`preset.ts`](../examples/extensions/preset.ts) and [`tools.ts`](../examples/extensions/tools.ts) use selection and settings lists.
|
|
119
|
+
- [`qna.ts`](../examples/extensions/qna.ts) uses cancellable asynchronous UI.
|
|
120
|
+
- [`modal-editor.ts`](../examples/extensions/modal-editor.ts) replaces the editor.
|
|
121
|
+
- [`custom-footer.ts`](../examples/extensions/custom-footer.ts) replaces the footer.
|
|
122
|
+
- [`widget-placement.ts`](../examples/extensions/widget-placement.ts) places persistent content around the editor.
|
|
123
|
+
- [`doom-overlay/`](../examples/extensions/doom-overlay/) demonstrates a continuously rendered overlay.
|
|
933
124
|
|
|
934
|
-
|
|
935
|
-
- **Async with cancel**: [examples/extensions/qna.ts](../examples/extensions/qna.ts) - BorderedLoader for LLM calls
|
|
936
|
-
- **Settings toggles**: [examples/extensions/tools.ts](../examples/extensions/tools.ts) - SettingsList for tool enable/disable
|
|
937
|
-
- **Status indicators**: [examples/extensions/plan-mode.ts](../examples/extensions/plan-mode.ts) - setStatus and setWidget
|
|
938
|
-
- **Working indicator**: [examples/extensions/working-indicator.ts](../examples/extensions/working-indicator.ts) - setWorkingIndicator
|
|
939
|
-
- **Custom footer**: [examples/extensions/custom-footer.ts](../examples/extensions/custom-footer.ts) - setFooter with stats
|
|
940
|
-
- **Custom editor**: [examples/extensions/modal-editor.ts](../examples/extensions/modal-editor.ts) - Vim-like modal editing
|
|
941
|
-
- **Snake game**: [examples/extensions/snake.ts](../examples/extensions/snake.ts) - Full game with keyboard input, game loop
|
|
942
|
-
- **Custom tool rendering**: [examples/extensions/todo.ts](../examples/extensions/todo.ts) - renderCall and renderResult
|
|
125
|
+
The public exports are defined in [`packages/tui/src/index.ts`](https://github.com/draht-dev/draht/blob/main/packages/tui/src/index.ts). See [Extensions](extensions.md) for extension lifecycle, state, tools, events, and mode behavior.
|