@openadapter/koda 1.0.0-beta.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 +4448 -0
- package/README.md +665 -0
- package/dist/bun/cli.d.ts +2 -0
- package/dist/bun/cli.js +2 -0
- package/dist/bun/register-bedrock.d.ts +1 -0
- package/dist/bun/register-bedrock.js +1 -0
- package/dist/bun/restore-sandbox-env.d.ts +12 -0
- package/dist/bun/restore-sandbox-env.js +1 -0
- package/dist/cli/args.d.ts +55 -0
- package/dist/cli/args.js +167 -0
- package/dist/cli/config-selector.d.ts +13 -0
- package/dist/cli/config-selector.js +1 -0
- package/dist/cli/file-processor.d.ts +14 -0
- package/dist/cli/file-processor.js +7 -0
- package/dist/cli/import-sessions.d.ts +34 -0
- package/dist/cli/import-sessions.js +6 -0
- package/dist/cli/initial-message.d.ts +17 -0
- package/dist/cli/initial-message.js +1 -0
- package/dist/cli/list-models.d.ts +8 -0
- package/dist/cli/list-models.js +2 -0
- package/dist/cli/openadapter-setup.d.ts +29 -0
- package/dist/cli/openadapter-setup.js +3 -0
- package/dist/cli/session-picker.d.ts +8 -0
- package/dist/cli/session-picker.js +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +2 -0
- package/dist/config.d.ts +92 -0
- package/dist/config.js +1 -0
- package/dist/core/agent-session-runtime.d.ts +116 -0
- package/dist/core/agent-session-runtime.js +1 -0
- package/dist/core/agent-session-services.d.ts +86 -0
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session.d.ts +747 -0
- package/dist/core/agent-session.js +32 -0
- package/dist/core/auth-guidance.d.ts +4 -0
- package/dist/core/auth-guidance.js +8 -0
- package/dist/core/auth-storage.d.ts +140 -0
- package/dist/core/auth-storage.js +1 -0
- package/dist/core/bash-executor.d.ts +31 -0
- package/dist/core/bash-executor.js +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +89 -0
- package/dist/core/compaction/branch-summarization.js +38 -0
- package/dist/core/compaction/compaction.d.ts +120 -0
- package/dist/core/compaction/compaction.js +104 -0
- package/dist/core/compaction/index.d.ts +6 -0
- package/dist/core/compaction/index.js +1 -0
- package/dist/core/compaction/utils.d.ts +37 -0
- package/dist/core/compaction/utils.js +19 -0
- package/dist/core/defaults.d.ts +2 -0
- package/dist/core/defaults.js +1 -0
- package/dist/core/diagnostics.d.ts +14 -0
- package/dist/core/diagnostics.js +0 -0
- package/dist/core/event-bus.d.ts +8 -0
- package/dist/core/event-bus.js +1 -0
- package/dist/core/exec.d.ts +28 -0
- package/dist/core/exec.js +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +21 -0
- package/dist/core/export-html/ansi-to-html.js +1 -0
- package/dist/core/export-html/index.d.ts +36 -0
- package/dist/core/export-html/index.js +2 -0
- package/dist/core/export-html/template.css +1066 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +72 -0
- package/dist/core/export-html/tool-renderer.d.ts +33 -0
- package/dist/core/export-html/tool-renderer.js +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +8 -0
- package/dist/core/export-html/vendor/marked.min.js +56 -0
- package/dist/core/extensions/index.d.ts +11 -0
- package/dist/core/extensions/index.js +1 -0
- package/dist/core/extensions/loader.d.ts +23 -0
- package/dist/core/extensions/loader.js +1 -0
- package/dist/core/extensions/runner.d.ts +160 -0
- package/dist/core/extensions/runner.js +1 -0
- package/dist/core/extensions/types.d.ts +1180 -0
- package/dist/core/extensions/types.js +1 -0
- package/dist/core/extensions/wrapper.d.ts +19 -0
- package/dist/core/extensions/wrapper.js +1 -0
- package/dist/core/footer-data-provider.d.ts +53 -0
- package/dist/core/footer-data-provider.js +1 -0
- package/dist/core/http-dispatcher.d.ts +20 -0
- package/dist/core/http-dispatcher.js +1 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.js +1 -0
- package/dist/core/keybindings.d.ts +352 -0
- package/dist/core/keybindings.js +1 -0
- package/dist/core/messages.d.ts +76 -0
- package/dist/core/messages.js +17 -0
- package/dist/core/model-registry.d.ts +149 -0
- package/dist/core/model-registry.js +9 -0
- package/dist/core/model-resolver.d.ts +109 -0
- package/dist/core/model-resolver.js +1 -0
- package/dist/core/output-guard.d.ts +6 -0
- package/dist/core/output-guard.js +1 -0
- package/dist/core/package-manager.d.ts +203 -0
- package/dist/core/package-manager.js +3 -0
- package/dist/core/prompt-templates.d.ts +51 -0
- package/dist/core/prompt-templates.js +2 -0
- package/dist/core/provider-attribution.d.ts +3 -0
- package/dist/core/provider-attribution.js +1 -0
- package/dist/core/provider-display-names.d.ts +1 -0
- package/dist/core/provider-display-names.js +1 -0
- package/dist/core/resolve-config-value.d.ts +30 -0
- package/dist/core/resolve-config-value.js +1 -0
- package/dist/core/resource-loader.d.ts +193 -0
- package/dist/core/resource-loader.js +1 -0
- package/dist/core/sdk.d.ts +108 -0
- package/dist/core/sdk.js +1 -0
- package/dist/core/session-cwd.d.ts +18 -0
- package/dist/core/session-cwd.js +7 -0
- package/dist/core/session-manager.d.ts +331 -0
- package/dist/core/session-manager.js +11 -0
- package/dist/core/settings-manager.d.ts +265 -0
- package/dist/core/settings-manager.js +1 -0
- package/dist/core/skills.d.ts +59 -0
- package/dist/core/skills.js +4 -0
- package/dist/core/slash-commands.d.ts +13 -0
- package/dist/core/slash-commands.js +1 -0
- package/dist/core/source-info.d.ts +17 -0
- package/dist/core/source-info.js +1 -0
- package/dist/core/system-prompt.d.ts +27 -0
- package/dist/core/system-prompt.js +52 -0
- package/dist/core/telemetry.d.ts +2 -0
- package/dist/core/telemetry.js +1 -0
- package/dist/core/timings.d.ts +7 -0
- package/dist/core/timings.js +3 -0
- package/dist/core/tools/bash.d.ts +67 -0
- package/dist/core/tools/bash.js +18 -0
- package/dist/core/tools/edit-diff.d.ts +86 -0
- package/dist/core/tools/edit-diff.js +16 -0
- package/dist/core/tools/edit.d.ts +50 -0
- package/dist/core/tools/edit.js +2 -0
- package/dist/core/tools/file-mutation-queue.d.ts +5 -0
- package/dist/core/tools/file-mutation-queue.js +1 -0
- package/dist/core/tools/find.d.ts +34 -0
- package/dist/core/tools/find.js +13 -0
- package/dist/core/tools/grep.d.ts +36 -0
- package/dist/core/tools/grep.js +13 -0
- package/dist/core/tools/index.d.ts +39 -0
- package/dist/core/tools/index.js +1 -0
- package/dist/core/tools/ls.d.ts +36 -0
- package/dist/core/tools/ls.js +9 -0
- package/dist/core/tools/output-accumulator.d.ts +51 -0
- package/dist/core/tools/output-accumulator.js +4 -0
- package/dist/core/tools/path-utils.d.ts +9 -0
- package/dist/core/tools/path-utils.js +1 -0
- package/dist/core/tools/read.d.ts +34 -0
- package/dist/core/tools/read.js +22 -0
- package/dist/core/tools/render-utils.d.ts +23 -0
- package/dist/core/tools/render-utils.js +4 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +13 -0
- package/dist/core/tools/tool-definition-wrapper.js +1 -0
- package/dist/core/tools/truncate.d.ts +69 -0
- package/dist/core/tools/truncate.js +5 -0
- package/dist/core/tools/write.d.ts +25 -0
- package/dist/core/tools/write.js +13 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +1 -0
- package/dist/main.d.ts +11 -0
- package/dist/main.js +1 -0
- package/dist/migrations.d.ts +32 -0
- package/dist/migrations.js +8 -0
- package/dist/modes/index.d.ts +8 -0
- package/dist/modes/index.js +1 -0
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/components/armin.d.ts +33 -0
- package/dist/modes/interactive/components/armin.js +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +19 -0
- package/dist/modes/interactive/components/assistant-message.js +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +33 -0
- package/dist/modes/interactive/components/bash-execution.js +13 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +15 -0
- package/dist/modes/interactive/components/bordered-loader.js +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +15 -0
- package/dist/modes/interactive/components/branch-summary-message.js +3 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +15 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +3 -0
- package/dist/modes/interactive/components/config-selector.d.ts +70 -0
- package/dist/modes/interactive/components/config-selector.js +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +13 -0
- package/dist/modes/interactive/components/countdown-timer.js +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +20 -0
- package/dist/modes/interactive/components/custom-editor.js +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +19 -0
- package/dist/modes/interactive/components/custom-message.js +2 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +22 -0
- package/dist/modes/interactive/components/daxnuts.js +1 -0
- package/dist/modes/interactive/components/diff.d.ts +11 -0
- package/dist/modes/interactive/components/diff.js +3 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +14 -0
- package/dist/modes/interactive/components/dynamic-border.js +1 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts +4 -0
- package/dist/modes/interactive/components/earendil-announcement.js +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +19 -0
- package/dist/modes/interactive/components/extension-editor.js +3 -0
- package/dist/modes/interactive/components/extension-input.d.ts +22 -0
- package/dist/modes/interactive/components/extension-input.js +2 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +25 -0
- package/dist/modes/interactive/components/extension-selector.js +2 -0
- package/dist/modes/interactive/components/footer.d.ts +27 -0
- package/dist/modes/interactive/components/footer.js +1 -0
- package/dist/modes/interactive/components/index.d.ts +31 -0
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +12 -0
- package/dist/modes/interactive/components/keybinding-hints.js +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +51 -0
- package/dist/modes/interactive/components/login-dialog.js +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +46 -0
- package/dist/modes/interactive/components/model-selector.js +2 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +30 -0
- package/dist/modes/interactive/components/oauth-selector.js +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +41 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +22 -0
- package/dist/modes/interactive/components/session-selector-search.js +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/modes/interactive/components/session-selector.js +2 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +68 -0
- package/dist/modes/interactive/components/settings-selector.js +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +9 -0
- package/dist/modes/interactive/components/show-images-selector.js +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +16 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +3 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +10 -0
- package/dist/modes/interactive/components/theme-selector.js +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +10 -0
- package/dist/modes/interactive/components/thinking-selector.js +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +62 -0
- package/dist/modes/interactive/components/tool-execution.js +4 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +88 -0
- package/dist/modes/interactive/components/tree-selector.js +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +29 -0
- package/dist/modes/interactive/components/user-message-selector.js +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +9 -0
- package/dist/modes/interactive/components/user-message.js +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +23 -0
- package/dist/modes/interactive/components/visual-truncate.js +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +417 -0
- package/dist/modes/interactive/interactive-mode.js +116 -0
- package/dist/modes/interactive/theme/dark.json +86 -0
- package/dist/modes/interactive/theme/light.json +85 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.d.ts +101 -0
- package/dist/modes/interactive/theme/theme.js +18 -0
- package/dist/modes/print-mode.d.ts +27 -0
- package/dist/modes/print-mode.js +4 -0
- package/dist/modes/rpc/jsonl.d.ts +16 -0
- package/dist/modes/rpc/jsonl.js +3 -0
- package/dist/modes/rpc/rpc-client.d.ts +226 -0
- package/dist/modes/rpc/rpc-client.js +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +19 -0
- package/dist/modes/rpc/rpc-mode.js +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +419 -0
- package/dist/modes/rpc/rpc-types.js +0 -0
- package/dist/package-manager-cli.d.ts +3 -0
- package/dist/package-manager-cli.js +49 -0
- package/dist/utils/ansi.d.ts +1 -0
- package/dist/utils/ansi.js +1 -0
- package/dist/utils/auto-update.d.ts +13 -0
- package/dist/utils/auto-update.js +1 -0
- package/dist/utils/changelog.d.ts +20 -0
- package/dist/utils/changelog.js +4 -0
- package/dist/utils/child-process.d.ts +14 -0
- package/dist/utils/child-process.js +1 -0
- package/dist/utils/clipboard-image.d.ts +10 -0
- package/dist/utils/clipboard-image.js +1 -0
- package/dist/utils/clipboard-native.d.ts +9 -0
- package/dist/utils/clipboard-native.js +1 -0
- package/dist/utils/clipboard.d.ts +1 -0
- package/dist/utils/clipboard.js +1 -0
- package/dist/utils/deprecation.d.ts +3 -0
- package/dist/utils/deprecation.js +1 -0
- package/dist/utils/exif-orientation.d.ts +4 -0
- package/dist/utils/exif-orientation.js +1 -0
- package/dist/utils/frontmatter.d.ts +7 -0
- package/dist/utils/frontmatter.js +4 -0
- package/dist/utils/fs-watch.d.ts +4 -0
- package/dist/utils/fs-watch.js +1 -0
- package/dist/utils/git.d.ts +25 -0
- package/dist/utils/git.js +1 -0
- package/dist/utils/html.d.ts +6 -0
- package/dist/utils/html.js +1 -0
- package/dist/utils/image-convert.d.ts +8 -0
- package/dist/utils/image-convert.js +1 -0
- package/dist/utils/image-resize-core.d.ts +29 -0
- package/dist/utils/image-resize-core.js +1 -0
- package/dist/utils/image-resize-worker.d.ts +1 -0
- package/dist/utils/image-resize-worker.js +1 -0
- package/dist/utils/image-resize.d.ts +15 -0
- package/dist/utils/image-resize.js +1 -0
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/json.js +1 -0
- package/dist/utils/koda-user-agent.d.ts +1 -0
- package/dist/utils/koda-user-agent.js +1 -0
- package/dist/utils/mime.d.ts +2 -0
- package/dist/utils/mime.js +1 -0
- package/dist/utils/paths.d.ts +30 -0
- package/dist/utils/paths.js +1 -0
- package/dist/utils/photon.d.ts +20 -0
- package/dist/utils/photon.js +1 -0
- package/dist/utils/shell.d.ts +29 -0
- package/dist/utils/shell.js +8 -0
- package/dist/utils/sleep.d.ts +4 -0
- package/dist/utils/sleep.js +1 -0
- package/dist/utils/syntax-highlight.d.ts +11 -0
- package/dist/utils/syntax-highlight.js +2 -0
- package/dist/utils/tools-manager.d.ts +2 -0
- package/dist/utils/tools-manager.js +1 -0
- package/dist/utils/version-check.d.ts +14 -0
- package/dist/utils/version-check.js +1 -0
- package/dist/utils/windows-self-update.d.ts +2 -0
- package/dist/utils/windows-self-update.js +1 -0
- package/docs/compaction.md +394 -0
- package/docs/custom-provider.md +736 -0
- package/docs/development.md +71 -0
- package/docs/docs.json +148 -0
- package/docs/extensions.md +2626 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/index.md +80 -0
- package/docs/json.md +82 -0
- package/docs/keybindings.md +197 -0
- package/docs/models.md +493 -0
- package/docs/packages.md +226 -0
- package/docs/prompt-templates.md +88 -0
- package/docs/providers.md +253 -0
- package/docs/quickstart.md +165 -0
- package/docs/rpc.md +1408 -0
- package/docs/sdk.md +1137 -0
- package/docs/session-format.md +412 -0
- package/docs/sessions.md +145 -0
- package/docs/settings.md +281 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +231 -0
- package/docs/terminal-setup.md +114 -0
- package/docs/termux.md +127 -0
- package/docs/themes.md +295 -0
- package/docs/tmux.md +61 -0
- package/docs/tui.md +927 -0
- package/docs/usage.md +288 -0
- package/docs/windows.md +17 -0
- package/npm-shrinkwrap.json +1792 -0
- package/openadapter/extensions/koda-ask.js +12 -0
- package/openadapter/extensions/koda-bg.js +14 -0
- package/openadapter/extensions/koda-commands.mjs +15 -0
- package/openadapter/extensions/koda-help.js +8 -0
- package/openadapter/extensions/koda-memory.js +16 -0
- package/openadapter/extensions/koda-status.js +1 -0
- package/openadapter/extensions/koda-todo.js +4 -0
- package/openadapter/extensions/koda-vision.js +4 -0
- package/openadapter/extensions/koda-web.js +7 -0
- package/openadapter/setup.mjs +173 -0
- package/openadapter/skills/code-review/SKILL.md +22 -0
- package/openadapter/skills/debugging/SKILL.md +28 -0
- package/openadapter/skills/frontend/SKILL.md +38 -0
- package/package.json +108 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ThinkingLevel } from "@openadapter/koda-agent-core";
|
|
2
|
+
import type { Transport } from "@openadapter/koda-ai";
|
|
3
|
+
import { Container, SettingsList } from "@openadapter/koda-tui";
|
|
4
|
+
import type { WarningSettings } from "../../../core/settings-manager.ts";
|
|
5
|
+
export interface SettingsConfig {
|
|
6
|
+
autoCompact: boolean;
|
|
7
|
+
showImages: boolean;
|
|
8
|
+
imageWidthCells: number;
|
|
9
|
+
autoResizeImages: boolean;
|
|
10
|
+
blockImages: boolean;
|
|
11
|
+
enableSkillCommands: boolean;
|
|
12
|
+
steeringMode: "all" | "one-at-a-time";
|
|
13
|
+
followUpMode: "all" | "one-at-a-time";
|
|
14
|
+
transport: Transport;
|
|
15
|
+
httpIdleTimeoutMs: number;
|
|
16
|
+
thinkingLevel: ThinkingLevel;
|
|
17
|
+
availableThinkingLevels: ThinkingLevel[];
|
|
18
|
+
currentTheme: string;
|
|
19
|
+
availableThemes: string[];
|
|
20
|
+
hideThinkingBlock: boolean;
|
|
21
|
+
collapseChangelog: boolean;
|
|
22
|
+
enableInstallTelemetry: boolean;
|
|
23
|
+
doubleEscapeAction: "fork" | "tree" | "none";
|
|
24
|
+
treeFilterMode: "default" | "no-tools" | "user-only" | "labeled-only" | "all";
|
|
25
|
+
showHardwareCursor: boolean;
|
|
26
|
+
editorPaddingX: number;
|
|
27
|
+
autocompleteMaxVisible: number;
|
|
28
|
+
quietStartup: boolean;
|
|
29
|
+
clearOnShrink: boolean;
|
|
30
|
+
showTerminalProgress: boolean;
|
|
31
|
+
warnings: WarningSettings;
|
|
32
|
+
}
|
|
33
|
+
export interface SettingsCallbacks {
|
|
34
|
+
onAutoCompactChange: (enabled: boolean) => void;
|
|
35
|
+
onShowImagesChange: (enabled: boolean) => void;
|
|
36
|
+
onImageWidthCellsChange: (width: number) => void;
|
|
37
|
+
onAutoResizeImagesChange: (enabled: boolean) => void;
|
|
38
|
+
onBlockImagesChange: (blocked: boolean) => void;
|
|
39
|
+
onEnableSkillCommandsChange: (enabled: boolean) => void;
|
|
40
|
+
onSteeringModeChange: (mode: "all" | "one-at-a-time") => void;
|
|
41
|
+
onFollowUpModeChange: (mode: "all" | "one-at-a-time") => void;
|
|
42
|
+
onTransportChange: (transport: Transport) => void;
|
|
43
|
+
onHttpIdleTimeoutMsChange: (timeoutMs: number) => void;
|
|
44
|
+
onThinkingLevelChange: (level: ThinkingLevel) => void;
|
|
45
|
+
onThemeChange: (theme: string) => void;
|
|
46
|
+
onThemePreview?: (theme: string) => void;
|
|
47
|
+
onHideThinkingBlockChange: (hidden: boolean) => void;
|
|
48
|
+
onCollapseChangelogChange: (collapsed: boolean) => void;
|
|
49
|
+
onEnableInstallTelemetryChange: (enabled: boolean) => void;
|
|
50
|
+
onDoubleEscapeActionChange: (action: "fork" | "tree" | "none") => void;
|
|
51
|
+
onTreeFilterModeChange: (mode: "default" | "no-tools" | "user-only" | "labeled-only" | "all") => void;
|
|
52
|
+
onShowHardwareCursorChange: (enabled: boolean) => void;
|
|
53
|
+
onEditorPaddingXChange: (padding: number) => void;
|
|
54
|
+
onAutocompleteMaxVisibleChange: (maxVisible: number) => void;
|
|
55
|
+
onQuietStartupChange: (enabled: boolean) => void;
|
|
56
|
+
onClearOnShrinkChange: (enabled: boolean) => void;
|
|
57
|
+
onShowTerminalProgressChange: (enabled: boolean) => void;
|
|
58
|
+
onWarningsChange: (warnings: WarningSettings) => void;
|
|
59
|
+
onCancel: () => void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Main settings selector component.
|
|
63
|
+
*/
|
|
64
|
+
export declare class SettingsSelectorComponent extends Container {
|
|
65
|
+
private settingsList;
|
|
66
|
+
constructor(config: SettingsConfig, callbacks: SettingsCallbacks);
|
|
67
|
+
getSettingsList(): SettingsList;
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var E=Object.defineProperty;var l=(h,e)=>E(h,"name",{value:e,configurable:!0});import{Container as g,getCapabilities as M,SelectList as P,SettingsList as f,Spacer as b,Text as C}from"@openadapter/koda-tui";import{formatHttpIdleTimeoutMs as A,HTTP_IDLE_TIMEOUT_CHOICES as k}from"../../../core/http-dispatcher.js";import{getSelectListTheme as H,getSettingsListTheme as w,theme as c}from"../theme/theme.js";import{DynamicBorder as I}from"./dynamic-border.js";import{keyDisplayText as D}from"./keybinding-hints.js";const U={minPrimaryColumnWidth:12,maxPrimaryColumnWidth:32},z={off:"No reasoning",minimal:"Very brief reasoning (~1k tokens)",low:"Light reasoning (~2k tokens)",medium:"Moderate reasoning (~8k tokens)",high:"Deep reasoning (~16k tokens)",xhigh:"Maximum reasoning (~32k tokens)"};class W extends g{static{l(this,"WarningSettingsSubmenu")}settingsList;state;constructor(e,t,n){super(),this.state={...e};const d=[{id:"anthropic-extra-usage",label:"Anthropic extra usage",description:"Warn when Anthropic subscription auth may use paid extra usage",currentValue:this.state.anthropicExtraUsage??!0?"true":"false",values:["true","false"]}];this.settingsList=new f(d,Math.min(d.length,10),w(),(u,a)=>{u==="anthropic-extra-usage"&&(this.state={...this.state,anthropicExtraUsage:a==="true"},t({...this.state}))},n),this.addChild(this.settingsList)}handleInput(e){this.settingsList.handleInput(e)}}class S extends g{static{l(this,"SelectSubmenu")}selectList;constructor(e,t,n,d,u,a,m){super(),this.addChild(new C(c.bold(c.fg("accent",e)),0,0)),t&&(this.addChild(new b(1)),this.addChild(new C(c.fg("muted",t),0,0))),this.addChild(new b(1)),this.selectList=new P(n,Math.min(n.length,10),H(),U);const p=n.findIndex(o=>o.value===d);p!==-1&&this.selectList.setSelectedIndex(p),this.selectList.onSelect=o=>{u(o.value)},this.selectList.onCancel=a,m&&(this.selectList.onSelectionChange=o=>{m(o.value)}),this.addChild(this.selectList),this.addChild(new b(1)),this.addChild(new C(c.fg("dim"," Enter to select \xB7 Esc to go back"),0,0))}handleInput(e){this.selectList.handleInput(e)}}class q extends g{static{l(this,"SettingsSelectorComponent")}settingsList;constructor(e,t){super();const n=M().images,d=D("app.message.followUp");let u={...e.warnings};const a=[{id:"autocompact",label:"Auto-compact",description:"Automatically compact context when it gets too large",currentValue:e.autoCompact?"true":"false",values:["true","false"]},{id:"steering-mode",label:"Steering mode",description:"Enter while streaming queues steering messages. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.",currentValue:e.steeringMode,values:["one-at-a-time","all"]},{id:"follow-up-mode",label:"Follow-up mode",description:`${d} queues follow-up messages until agent stops. 'one-at-a-time': deliver one, wait for response. 'all': deliver all at once.`,currentValue:e.followUpMode,values:["one-at-a-time","all"]},{id:"transport",label:"Transport",description:"Preferred transport for providers that support multiple transports",currentValue:e.transport,values:["sse","websocket","websocket-cached","auto"]},{id:"http-idle-timeout",label:"HTTP idle timeout",description:"Maximum idle gap while waiting for HTTP headers or body chunks. Disable for local models that pause longer than five minutes.",currentValue:A(e.httpIdleTimeoutMs),values:k.map(s=>s.label)},{id:"hide-thinking",label:"Hide thinking",description:"Hide thinking blocks in assistant responses",currentValue:e.hideThinkingBlock?"true":"false",values:["true","false"]},{id:"collapse-changelog",label:"Collapse changelog",description:"Show condensed changelog after updates",currentValue:e.collapseChangelog?"true":"false",values:["true","false"]},{id:"quiet-startup",label:"Quiet startup",description:"Disable verbose printing at startup",currentValue:e.quietStartup?"true":"false",values:["true","false"]},{id:"install-telemetry",label:"Install telemetry",description:"Send an anonymous version/update ping after changelog-detected updates",currentValue:e.enableInstallTelemetry?"true":"false",values:["true","false"]},{id:"double-escape-action",label:"Double-escape action",description:"Action when pressing Escape twice with empty editor",currentValue:e.doubleEscapeAction,values:["tree","fork","none"]},{id:"tree-filter-mode",label:"Tree filter mode",description:"Default filter when opening /tree",currentValue:e.treeFilterMode,values:["default","no-tools","user-only","labeled-only","all"]},{id:"warnings",label:"Warnings",description:"Enable or disable individual warnings",currentValue:"configure",submenu:l((s,i)=>new W(u,r=>{u=r,t.onWarningsChange(r)},()=>i()),"submenu")},{id:"thinking",label:"Thinking level",description:"Reasoning depth for thinking-capable models",currentValue:e.thinkingLevel,submenu:l((s,i)=>new S("Thinking Level","Select reasoning depth for thinking-capable models",e.availableThinkingLevels.map(r=>({value:r,label:r,description:z[r]})),s,r=>{t.onThinkingLevelChange(r),i(r)},()=>i()),"submenu")},{id:"theme",label:"Theme",description:"Color theme for the interface",currentValue:e.currentTheme,submenu:l((s,i)=>new S("Theme","Select color theme",e.availableThemes.map(r=>({value:r,label:r})),s,r=>{t.onThemeChange(r),i(r)},()=>{t.onThemePreview?.(s),i()},r=>{t.onThemePreview?.(r)}),"submenu")}];n&&(a.splice(1,0,{id:"show-images",label:"Show images",description:"Render images inline in terminal",currentValue:e.showImages?"true":"false",values:["true","false"]}),a.splice(2,0,{id:"image-width-cells",label:"Image width",description:"Preferred inline image width in terminal cells",currentValue:String(e.imageWidthCells),values:["60","80","120"]})),a.splice(n?3:1,0,{id:"auto-resize-images",label:"Auto-resize images",description:"Resize large images to 2000x2000 max for better model compatibility",currentValue:e.autoResizeImages?"true":"false",values:["true","false"]});const m=a.findIndex(s=>s.id==="auto-resize-images");a.splice(m+1,0,{id:"block-images",label:"Block images",description:"Prevent images from being sent to LLM providers",currentValue:e.blockImages?"true":"false",values:["true","false"]});const p=a.findIndex(s=>s.id==="block-images");a.splice(p+1,0,{id:"skill-commands",label:"Skill commands",description:"Register skills as /skill:name commands",currentValue:e.enableSkillCommands?"true":"false",values:["true","false"]});const o=a.findIndex(s=>s.id==="skill-commands");a.splice(o+1,0,{id:"show-hardware-cursor",label:"Show hardware cursor",description:"Show the terminal cursor while still positioning it for IME support",currentValue:e.showHardwareCursor?"true":"false",values:["true","false"]});const v=a.findIndex(s=>s.id==="show-hardware-cursor");a.splice(v+1,0,{id:"editor-padding",label:"Editor padding",description:"Horizontal padding for input editor (0-3)",currentValue:String(e.editorPaddingX),values:["0","1","2","3"]});const T=a.findIndex(s=>s.id==="editor-padding");a.splice(T+1,0,{id:"autocomplete-max-visible",label:"Autocomplete max items",description:"Max visible items in autocomplete dropdown (3-20)",currentValue:String(e.autocompleteMaxVisible),values:["3","5","7","10","15","20"]});const x=a.findIndex(s=>s.id==="autocomplete-max-visible");a.splice(x+1,0,{id:"clear-on-shrink",label:"Clear on shrink",description:"Clear empty rows when content shrinks (may cause flicker)",currentValue:e.clearOnShrink?"true":"false",values:["true","false"]});const L=a.findIndex(s=>s.id==="clear-on-shrink");a.splice(L+1,0,{id:"terminal-progress",label:"Terminal progress",description:"Show OSC 9;4 progress indicators in the terminal tab bar",currentValue:e.showTerminalProgress?"true":"false",values:["true","false"]}),this.addChild(new I),this.settingsList=new f(a,10,w(),(s,i)=>{switch(s){case"autocompact":t.onAutoCompactChange(i==="true");break;case"show-images":t.onShowImagesChange(i==="true");break;case"image-width-cells":t.onImageWidthCellsChange(parseInt(i,10));break;case"auto-resize-images":t.onAutoResizeImagesChange(i==="true");break;case"block-images":t.onBlockImagesChange(i==="true");break;case"skill-commands":t.onEnableSkillCommandsChange(i==="true");break;case"steering-mode":t.onSteeringModeChange(i);break;case"follow-up-mode":t.onFollowUpModeChange(i);break;case"transport":t.onTransportChange(i);break;case"http-idle-timeout":{const r=k.find(y=>y.label===i);r&&t.onHttpIdleTimeoutMsChange(r.timeoutMs);break}case"hide-thinking":t.onHideThinkingBlockChange(i==="true");break;case"collapse-changelog":t.onCollapseChangelogChange(i==="true");break;case"quiet-startup":t.onQuietStartupChange(i==="true");break;case"install-telemetry":t.onEnableInstallTelemetryChange(i==="true");break;case"double-escape-action":t.onDoubleEscapeActionChange(i);break;case"tree-filter-mode":t.onTreeFilterModeChange(i);break;case"show-hardware-cursor":t.onShowHardwareCursorChange(i==="true");break;case"editor-padding":t.onEditorPaddingXChange(parseInt(i,10));break;case"autocomplete-max-visible":t.onAutocompleteMaxVisibleChange(parseInt(i,10));break;case"clear-on-shrink":t.onClearOnShrinkChange(i==="true");break;case"terminal-progress":t.onShowTerminalProgressChange(i==="true");break}},t.onCancel,{enableSearch:!0}),this.addChild(this.settingsList),this.addChild(new I)}getSettingsList(){return this.settingsList}}export{q as SettingsSelectorComponent};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Container, SelectList } from "@openadapter/koda-tui";
|
|
2
|
+
/**
|
|
3
|
+
* Component that renders a show images selector with borders
|
|
4
|
+
*/
|
|
5
|
+
export declare class ShowImagesSelectorComponent extends Container {
|
|
6
|
+
private selectList;
|
|
7
|
+
constructor(currentValue: boolean, onSelect: (show: boolean) => void, onCancel: () => void);
|
|
8
|
+
getSelectList(): SelectList;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=Object.defineProperty;var i=(t,e)=>c(t,"name",{value:e,configurable:!0});import{Container as a,SelectList as d}from"@openadapter/koda-tui";import{getSelectListTheme as h}from"../theme/theme.js";import{DynamicBorder as s}from"./dynamic-border.js";const m={minPrimaryColumnWidth:12,maxPrimaryColumnWidth:32};class u extends a{static{i(this,"ShowImagesSelectorComponent")}selectList;constructor(e,l,n){super();const o=[{value:"yes",label:"Yes",description:"Show images inline in terminal"},{value:"no",label:"No",description:"Show text placeholder instead"}];this.addChild(new s),this.selectList=new d(o,5,h(),m),this.selectList.setSelectedIndex(e?0:1),this.selectList.onSelect=r=>{l(r.value==="yes")},this.selectList.onCancel=()=>{n()},this.addChild(this.selectList),this.addChild(new s)}getSelectList(){return this.selectList}}export{u as ShowImagesSelectorComponent};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Box, type MarkdownTheme } from "@openadapter/koda-tui";
|
|
2
|
+
import type { ParsedSkillBlock } from "../../../core/agent-session.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Component that renders a skill invocation message with collapsed/expanded state.
|
|
5
|
+
* Uses same background color as custom messages for visual consistency.
|
|
6
|
+
* Only renders the skill block itself - user message is rendered separately.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SkillInvocationMessageComponent extends Box {
|
|
9
|
+
private expanded;
|
|
10
|
+
private skillBlock;
|
|
11
|
+
private markdownTheme;
|
|
12
|
+
constructor(skillBlock: ParsedSkillBlock, markdownTheme?: MarkdownTheme);
|
|
13
|
+
setExpanded(expanded: boolean): void;
|
|
14
|
+
invalidate(): void;
|
|
15
|
+
private updateDisplay;
|
|
16
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var d=Object.defineProperty;var i=(l,e)=>d(l,"name",{value:e,configurable:!0});import{Box as n,Markdown as m,Text as o}from"@openadapter/koda-tui";import{getMarkdownTheme as h,theme as s}from"../theme/theme.js";import{keyText as p}from"./keybinding-hints.js";class g extends n{static{i(this,"SkillInvocationMessageComponent")}expanded=!1;skillBlock;markdownTheme;constructor(e,t=h()){super(1,1,a=>s.bg("customMessageBg",a)),this.skillBlock=e,this.markdownTheme=t,this.updateDisplay()}setExpanded(e){this.expanded=e,this.updateDisplay()}invalidate(){super.invalidate(),this.updateDisplay()}updateDisplay(){if(this.clear(),this.expanded){const e=s.fg("customMessageLabel","\x1B[1m[skill]\x1B[22m");this.addChild(new o(e,0,0));const t=`**${this.skillBlock.name}**
|
|
2
|
+
|
|
3
|
+
`;this.addChild(new m(t+this.skillBlock.content,0,0,this.markdownTheme,{color:i(a=>s.fg("customMessageText",a),"color")}))}else{const e=s.fg("customMessageLabel","\x1B[1m[skill]\x1B[22m ")+s.fg("customMessageText",this.skillBlock.name)+s.fg("dim",` (${p("app.tools.expand")} to expand)`);this.addChild(new o(e,0,0))}}}export{g as SkillInvocationMessageComponent};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Container, SelectList } from "@openadapter/koda-tui";
|
|
2
|
+
/**
|
|
3
|
+
* Component that renders a theme selector
|
|
4
|
+
*/
|
|
5
|
+
export declare class ThemeSelectorComponent extends Container {
|
|
6
|
+
private selectList;
|
|
7
|
+
private onPreview;
|
|
8
|
+
constructor(currentTheme: string, onSelect: (themeName: string) => void, onCancel: () => void, onPreview: (themeName: string) => void);
|
|
9
|
+
getSelectList(): SelectList;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var m=Object.defineProperty;var l=(i,t)=>m(i,"name",{value:t,configurable:!0});import{Container as a,SelectList as L}from"@openadapter/koda-tui";import{getAvailableThemes as u,getSelectListTheme as C}from"../theme/theme.js";import{DynamicBorder as o}from"./dynamic-border.js";const S={minPrimaryColumnWidth:12,maxPrimaryColumnWidth:32};class x extends a{static{l(this,"ThemeSelectorComponent")}selectList;onPreview;constructor(t,c,r,h){super(),this.onPreview=h;const s=u(),d=s.map(e=>({value:e,label:e,description:e===t?"(current)":void 0}));this.addChild(new o),this.selectList=new L(d,10,C(),S);const n=s.indexOf(t);n!==-1&&this.selectList.setSelectedIndex(n),this.selectList.onSelect=e=>{c(e.value)},this.selectList.onCancel=()=>{r()},this.selectList.onSelectionChange=e=>{this.onPreview(e.value)},this.addChild(this.selectList),this.addChild(new o)}getSelectList(){return this.selectList}}export{x as ThemeSelectorComponent};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ThinkingLevel } from "@openadapter/koda-agent-core";
|
|
2
|
+
import { Container, SelectList } from "@openadapter/koda-tui";
|
|
3
|
+
/**
|
|
4
|
+
* Component that renders a thinking level selector with borders
|
|
5
|
+
*/
|
|
6
|
+
export declare class ThinkingSelectorComponent extends Container {
|
|
7
|
+
private selectList;
|
|
8
|
+
constructor(currentLevel: ThinkingLevel, availableLevels: ThinkingLevel[], onSelect: (level: ThinkingLevel) => void, onCancel: () => void);
|
|
9
|
+
getSelectList(): SelectList;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var h=Object.defineProperty;var o=(n,t)=>h(n,"name",{value:t,configurable:!0});import{Container as m,SelectList as d}from"@openadapter/koda-tui";import{getSelectListTheme as L}from"../theme/theme.js";import{DynamicBorder as r}from"./dynamic-border.js";const g={minPrimaryColumnWidth:12,maxPrimaryColumnWidth:32},k={off:"No reasoning",minimal:"Very brief reasoning (~1k tokens)",low:"Light reasoning (~2k tokens)",medium:"Moderate reasoning (~8k tokens)",high:"Deep reasoning (~16k tokens)",xhigh:"Maximum reasoning (~32k tokens)"};class f extends m{static{o(this,"ThinkingSelectorComponent")}selectList;constructor(t,l,a,c){super();const i=l.map(e=>({value:e,label:e,description:k[e]}));this.addChild(new r),this.selectList=new d(i,i.length,L(),g);const s=i.findIndex(e=>e.value===t);s!==-1&&this.selectList.setSelectedIndex(s),this.selectList.onSelect=e=>{a(e.value)},this.selectList.onCancel=()=>{c()},this.addChild(this.selectList),this.addChild(new r)}getSelectList(){return this.selectList}}export{f as ThinkingSelectorComponent};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Container, type TUI } from "@openadapter/koda-tui";
|
|
2
|
+
import type { ToolDefinition } from "../../../core/extensions/types.ts";
|
|
3
|
+
export interface ToolExecutionOptions {
|
|
4
|
+
showImages?: boolean;
|
|
5
|
+
imageWidthCells?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class ToolExecutionComponent extends Container {
|
|
8
|
+
private contentBox;
|
|
9
|
+
private contentText;
|
|
10
|
+
private selfRenderContainer;
|
|
11
|
+
private callRendererComponent?;
|
|
12
|
+
private resultRendererComponent?;
|
|
13
|
+
private rendererState;
|
|
14
|
+
private imageComponents;
|
|
15
|
+
private imageSpacers;
|
|
16
|
+
private toolName;
|
|
17
|
+
private toolCallId;
|
|
18
|
+
private args;
|
|
19
|
+
private expanded;
|
|
20
|
+
private showImages;
|
|
21
|
+
private imageWidthCells;
|
|
22
|
+
private isPartial;
|
|
23
|
+
private toolDefinition?;
|
|
24
|
+
private builtInToolDefinition?;
|
|
25
|
+
private ui;
|
|
26
|
+
private cwd;
|
|
27
|
+
private executionStarted;
|
|
28
|
+
private argsComplete;
|
|
29
|
+
private result?;
|
|
30
|
+
private convertedImages;
|
|
31
|
+
private hideComponent;
|
|
32
|
+
constructor(toolName: string, toolCallId: string, args: any, options: ToolExecutionOptions | undefined, toolDefinition: ToolDefinition<any, any> | undefined, ui: TUI, cwd: string);
|
|
33
|
+
private getCallRenderer;
|
|
34
|
+
private getResultRenderer;
|
|
35
|
+
private hasRendererDefinition;
|
|
36
|
+
private getRenderShell;
|
|
37
|
+
private getRenderContext;
|
|
38
|
+
private createCallFallback;
|
|
39
|
+
private createResultFallback;
|
|
40
|
+
updateArgs(args: any): void;
|
|
41
|
+
markExecutionStarted(): void;
|
|
42
|
+
setArgsComplete(): void;
|
|
43
|
+
updateResult(result: {
|
|
44
|
+
content: Array<{
|
|
45
|
+
type: string;
|
|
46
|
+
text?: string;
|
|
47
|
+
data?: string;
|
|
48
|
+
mimeType?: string;
|
|
49
|
+
}>;
|
|
50
|
+
details?: any;
|
|
51
|
+
isError: boolean;
|
|
52
|
+
}, isPartial?: boolean): void;
|
|
53
|
+
private maybeConvertImagesForKitty;
|
|
54
|
+
setExpanded(expanded: boolean): void;
|
|
55
|
+
setShowImages(show: boolean): void;
|
|
56
|
+
setImageWidthCells(width: number): void;
|
|
57
|
+
invalidate(): void;
|
|
58
|
+
render(width: number): string[];
|
|
59
|
+
private updateDisplay;
|
|
60
|
+
private getTextOutput;
|
|
61
|
+
private formatToolExecution;
|
|
62
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var x=Object.defineProperty;var h=(u,t)=>x(u,"name",{value:t,configurable:!0});import{Box as f,Container as p,getCapabilities as C,Image as T,Spacer as R,Text as d}from"@openadapter/koda-tui";import{createAllToolDefinitions as I}from"../../../core/tools/index.js";import{getTextOutput as b}from"../../../core/tools/render-utils.js";import{convertToPng as y}from"../../../utils/image-convert.js";import{theme as r}from"../theme/theme.js";class P extends p{static{h(this,"ToolExecutionComponent")}contentBox;contentText;selfRenderContainer;callRendererComponent;resultRendererComponent;rendererState={};imageComponents=[];imageSpacers=[];toolName;toolCallId;args;expanded=!1;showImages;imageWidthCells;isPartial=!0;toolDefinition;builtInToolDefinition;ui;cwd;executionStarted=!1;argsComplete=!1;result;convertedImages=new Map;hideComponent=!1;constructor(t,i,e,s={},o,n,l){super(),this.toolName=t,this.toolCallId=i,this.args=e,this.toolDefinition=o,this.builtInToolDefinition=I(l)[t],this.showImages=s.showImages??!0,this.imageWidthCells=s.imageWidthCells??60,this.ui=n,this.cwd=l,this.addChild(new R(1)),this.contentBox=new f(1,1,a=>r.bg("toolPendingBg",a)),this.contentText=new d("",1,1,a=>r.bg("toolPendingBg",a)),this.selfRenderContainer=new p,this.hasRendererDefinition()?this.addChild(this.getRenderShell()==="self"?this.selfRenderContainer:this.contentBox):this.addChild(this.contentText),this.updateDisplay()}getCallRenderer(){return this.builtInToolDefinition?this.toolDefinition?this.toolDefinition.renderCall??this.builtInToolDefinition.renderCall:this.builtInToolDefinition.renderCall:this.toolDefinition?.renderCall}getResultRenderer(){return this.builtInToolDefinition?this.toolDefinition?this.toolDefinition.renderResult??this.builtInToolDefinition.renderResult:this.builtInToolDefinition.renderResult:this.toolDefinition?.renderResult}hasRendererDefinition(){return this.builtInToolDefinition!==void 0||this.toolDefinition!==void 0}getRenderShell(){return this.builtInToolDefinition?this.toolDefinition?this.toolDefinition.renderShell??this.builtInToolDefinition.renderShell??"default":this.builtInToolDefinition.renderShell??"default":this.toolDefinition?.renderShell??"default"}getRenderContext(t){return{args:this.args,toolCallId:this.toolCallId,invalidate:h(()=>{this.invalidate(),this.ui.requestRender()},"invalidate"),lastComponent:t,state:this.rendererState,cwd:this.cwd,executionStarted:this.executionStarted,argsComplete:this.argsComplete,isPartial:this.isPartial,expanded:this.expanded,showImages:this.showImages,isError:this.result?.isError??!1}}createCallFallback(){return new d(r.fg("toolTitle",r.bold(this.toolName)),0,0)}createResultFallback(){const t=this.getTextOutput();if(t)return new d(r.fg("toolOutput",t),0,0)}updateArgs(t){this.args=t,this.updateDisplay()}markExecutionStarted(){this.executionStarted=!0,this.updateDisplay(),this.ui.requestRender()}setArgsComplete(){this.argsComplete=!0,this.updateDisplay(),this.ui.requestRender()}updateResult(t,i=!1){this.result=t,this.isPartial=i,this.updateDisplay(),this.maybeConvertImagesForKitty()}maybeConvertImagesForKitty(){if(C().images!=="kitty"||!this.result)return;const i=this.result.content.filter(e=>e.type==="image");for(let e=0;e<i.length;e++){const s=i[e];if(!s.data||!s.mimeType||s.mimeType==="image/png"||this.convertedImages.has(e))continue;const o=e;y(s.data,s.mimeType).then(n=>{n&&(this.convertedImages.set(o,n),this.updateDisplay(),this.ui.requestRender())})}}setExpanded(t){this.expanded=t,this.updateDisplay()}setShowImages(t){this.showImages=t,this.updateDisplay()}setImageWidthCells(t){this.imageWidthCells=Math.max(1,Math.floor(t)),this.updateDisplay()}invalidate(){super.invalidate(),this.updateDisplay()}render(t){if(this.hideComponent)return[];if(this.hasRendererDefinition()&&this.getRenderShell()==="self"){const i=this.selfRenderContainer.render(t);if(i.length===0&&this.imageComponents.length===0)return[];const e=[];i.length>0&&(e.push(""),e.push(...i));for(let s=0;s<this.imageComponents.length;s++){const o=this.imageSpacers[s];o&&e.push(...o.render(t));const n=this.imageComponents[s];n&&e.push(...n.render(t))}return e}return super.render(t)}updateDisplay(){const t=this.isPartial?e=>r.bg("toolPendingBg",e):this.result?.isError?e=>r.bg("toolErrorBg",e):e=>r.bg("toolSuccessBg",e);let i=!1;if(this.hideComponent=!1,this.hasRendererDefinition()){const e=this.getRenderShell()==="self"?this.selfRenderContainer:this.contentBox;e instanceof f&&e.setBgFn(t),e.clear();const s=this.getCallRenderer();if(!s)e.addChild(this.createCallFallback()),i=!0;else try{const o=s(this.args,r,this.getRenderContext(this.callRendererComponent));this.callRendererComponent=o,e.addChild(o),i=!0}catch{this.callRendererComponent=void 0,e.addChild(this.createCallFallback()),i=!0}if(this.result){const o=this.getResultRenderer();if(o)try{const n=o({content:this.result.content,details:this.result.details},{expanded:this.expanded,isPartial:this.isPartial},r,this.getRenderContext(this.resultRendererComponent));this.resultRendererComponent=n,e.addChild(n),i=!0}catch{this.resultRendererComponent=void 0;const n=this.createResultFallback();n&&(e.addChild(n),i=!0)}else{const n=this.createResultFallback();n&&(e.addChild(n),i=!0)}}}else this.contentText.setCustomBgFn(t),this.contentText.setText(this.formatToolExecution()),i=!0;for(const e of this.imageComponents)this.removeChild(e);this.imageComponents=[];for(const e of this.imageSpacers)this.removeChild(e);if(this.imageSpacers=[],this.result){const e=this.result.content.filter(o=>o.type==="image"),s=C();for(let o=0;o<e.length;o++){const n=e[o];if(s.images&&this.showImages&&n.data&&n.mimeType){const l=this.convertedImages.get(o),a=l?.data??n.data,m=l?.mimeType??n.mimeType;if(s.images==="kitty"&&m!=="image/png")continue;const g=new R(1);this.addChild(g),this.imageSpacers.push(g);const c=new T(a,m,{fallbackColor:h(D=>r.fg("toolOutput",D),"fallbackColor")},{maxWidthCells:this.imageWidthCells});this.imageComponents.push(c),this.addChild(c)}}}this.hasRendererDefinition()&&!i&&this.imageComponents.length===0&&(this.hideComponent=!0)}getTextOutput(){return b(this.result,this.showImages)}formatToolExecution(){let t=r.fg("toolTitle",r.bold(this.toolName));const i=JSON.stringify(this.args,null,2);i&&(t+=`
|
|
2
|
+
|
|
3
|
+
${i}`);const e=this.getTextOutput();return e&&(t+=`
|
|
4
|
+
${e}`),t}}export{P as ToolExecutionComponent};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type Component, Container, type Focusable } from "@openadapter/koda-tui";
|
|
2
|
+
import type { SessionTreeNode } from "../../../core/session-manager.ts";
|
|
3
|
+
/** Filter mode for tree display */
|
|
4
|
+
export type FilterMode = "default" | "no-tools" | "user-only" | "labeled-only" | "all";
|
|
5
|
+
declare class TreeList implements Component {
|
|
6
|
+
private flatNodes;
|
|
7
|
+
private filteredNodes;
|
|
8
|
+
private selectedIndex;
|
|
9
|
+
private currentLeafId;
|
|
10
|
+
private maxVisibleLines;
|
|
11
|
+
private filterMode;
|
|
12
|
+
private searchQuery;
|
|
13
|
+
private toolCallMap;
|
|
14
|
+
private multipleRoots;
|
|
15
|
+
private showLabelTimestamps;
|
|
16
|
+
private activePathIds;
|
|
17
|
+
private visibleParentMap;
|
|
18
|
+
private visibleChildrenMap;
|
|
19
|
+
private lastSelectedId;
|
|
20
|
+
private foldedNodes;
|
|
21
|
+
onSelect?: (entryId: string) => void;
|
|
22
|
+
onCancel?: () => void;
|
|
23
|
+
onLabelEdit?: (entryId: string, currentLabel: string | undefined) => void;
|
|
24
|
+
constructor(tree: SessionTreeNode[], currentLeafId: string | null, maxVisibleLines: number, initialSelectedId?: string, initialFilterMode?: FilterMode);
|
|
25
|
+
/**
|
|
26
|
+
* Find the index of the nearest visible entry, walking up the parent chain if needed.
|
|
27
|
+
* Returns the index in filteredNodes, or the last index as fallback.
|
|
28
|
+
*/
|
|
29
|
+
private findNearestVisibleIndex;
|
|
30
|
+
/** Build the set of entry IDs on the path from root to current leaf */
|
|
31
|
+
private buildActivePath;
|
|
32
|
+
private flattenTree;
|
|
33
|
+
private applyFilter;
|
|
34
|
+
/**
|
|
35
|
+
* Recompute indentation/connectors for the filtered view
|
|
36
|
+
*
|
|
37
|
+
* Filtering can hide intermediate entries; descendants attach to the nearest visible ancestor.
|
|
38
|
+
* Keep indentation semantics aligned with flattenTree() so single-child chains don't drift right.
|
|
39
|
+
*/
|
|
40
|
+
private recalculateVisualStructure;
|
|
41
|
+
/** Get searchable text content from a node */
|
|
42
|
+
private getSearchableText;
|
|
43
|
+
invalidate(): void;
|
|
44
|
+
getSearchQuery(): string;
|
|
45
|
+
getSelectedNode(): SessionTreeNode | undefined;
|
|
46
|
+
updateNodeLabel(entryId: string, label: string | undefined, labelTimestamp?: string): void;
|
|
47
|
+
private getStatusLabels;
|
|
48
|
+
render(width: number): string[];
|
|
49
|
+
private getEntryDisplayText;
|
|
50
|
+
private formatLabelTimestamp;
|
|
51
|
+
private extractContent;
|
|
52
|
+
private hasTextContent;
|
|
53
|
+
private formatToolCall;
|
|
54
|
+
handleInput(keyData: string): void;
|
|
55
|
+
/**
|
|
56
|
+
* Whether a node can be folded. A node is foldable if it has visible children
|
|
57
|
+
* and is either a root (no visible parent) or a segment start (visible parent
|
|
58
|
+
* has multiple visible children).
|
|
59
|
+
*/
|
|
60
|
+
private isFoldable;
|
|
61
|
+
/**
|
|
62
|
+
* Find the index of the next branch segment start in the given direction.
|
|
63
|
+
* A segment start is the first child of a branch point.
|
|
64
|
+
*
|
|
65
|
+
* "up" walks the visible parent chain; "down" walks visible children
|
|
66
|
+
* (always following the first child).
|
|
67
|
+
*/
|
|
68
|
+
private findBranchSegmentStart;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Component that renders a session tree selector for navigation
|
|
72
|
+
*/
|
|
73
|
+
export declare class TreeSelectorComponent extends Container implements Focusable {
|
|
74
|
+
private treeList;
|
|
75
|
+
private labelInput;
|
|
76
|
+
private labelInputContainer;
|
|
77
|
+
private treeContainer;
|
|
78
|
+
private onLabelChangeCallback?;
|
|
79
|
+
private _focused;
|
|
80
|
+
get focused(): boolean;
|
|
81
|
+
set focused(value: boolean);
|
|
82
|
+
constructor(tree: SessionTreeNode[], currentLeafId: string | null, terminalHeight: number, onSelect: (entryId: string) => void, onCancel: () => void, onLabelChange?: (entryId: string, label: string | undefined) => void, initialSelectedId?: string, initialFilterMode?: FilterMode);
|
|
83
|
+
private showLabelInput;
|
|
84
|
+
private hideLabelInput;
|
|
85
|
+
handleInput(keyData: string): void;
|
|
86
|
+
getTreeList(): TreeList;
|
|
87
|
+
}
|
|
88
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var B=Object.defineProperty;var w=(S,s)=>B(S,"name",{value:s,configurable:!0});import{Container as _,getKeybindings as A,Input as j,Spacer as V,Text as Q,TruncatedText as U,truncateToWidth as M}from"@openadapter/koda-tui";import{theme as a}from"../theme/theme.js";import{DynamicBorder as O}from"./dynamic-border.js";import{keyHint as E,keyText as y}from"./keybinding-hints.js";class W{static{w(this,"TreeList")}flatNodes=[];filteredNodes=[];selectedIndex=0;currentLeafId;maxVisibleLines;filterMode="default";searchQuery="";toolCallMap=new Map;multipleRoots=!1;showLabelTimestamps=!1;activePathIds=new Set;visibleParentMap=new Map;visibleChildrenMap=new Map;lastSelectedId=null;foldedNodes=new Set;onSelect;onCancel;onLabelEdit;constructor(s,t,e,n,i){this.currentLeafId=t,this.maxVisibleLines=e,this.filterMode=i??"default",this.multipleRoots=s.length>1,this.flatNodes=this.flattenTree(s),this.buildActivePath(),this.applyFilter();const l=n??t;this.selectedIndex=this.findNearestVisibleIndex(l),this.lastSelectedId=this.filteredNodes[this.selectedIndex]?.node.entry.id??null}findNearestVisibleIndex(s){if(this.filteredNodes.length===0)return 0;const t=new Map;for(const i of this.flatNodes)t.set(i.node.entry.id,i);const e=new Map(this.filteredNodes.map((i,l)=>[i.node.entry.id,l]));let n=s;for(;n!==null;){const i=e.get(n);if(i!==void 0)return i;const l=t.get(n);if(!l)break;n=l.node.entry.parentId??null}return this.filteredNodes.length-1}buildActivePath(){if(this.activePathIds.clear(),!this.currentLeafId)return;const s=new Map;for(const e of this.flatNodes)s.set(e.node.entry.id,e);let t=this.currentLeafId;for(;t;){this.activePathIds.add(t);const e=s.get(t);if(!e)break;t=e.node.entry.parentId??null}}flattenTree(s){const t=[];this.toolCallMap.clear();const e=[],n=new Map,i=this.currentLeafId;{const r=[],o=[...s];for(;o.length>0;){const h=o.pop();r.push(h);for(let c=h.children.length-1;c>=0;c--)o.push(h.children[c])}for(let h=r.length-1;h>=0;h--){const c=r[h];let m=i!==null&&c.entry.id===i;for(const g of c.children)n.get(g)&&(m=!0);n.set(c,m)}}const l=s.length>1,d=[...s].sort((r,o)=>Number(n.get(o))-Number(n.get(r)));for(let r=d.length-1;r>=0;r--){const o=r===d.length-1;e.push([d[r],l?1:0,l,l,o,[],l])}for(;e.length>0;){const[r,o,h,c,m,g,p]=e.pop(),L=r.entry;if(L.type==="message"&&L.message.role==="assistant"){const f=L.message.content;if(Array.isArray(f)){for(const u of f)if(typeof u=="object"&&u!==null&&"type"in u&&u.type==="toolCall"){const C=u;this.toolCallMap.set(C.id,{name:C.name,arguments:C.arguments})}}}t.push({node:r,indent:o,showConnector:c,isLast:m,gutters:g,isVirtualRootChild:p});const b=r.children,I=b.length>1,N=(()=>{const f=[],u=[];for(const C of b)n.get(C)?f.push(C):u.push(C);return[...f,...u]})();let x;I||h&&o>0?x=o+1:x=o;const $=c&&!p,T=this.multipleRoots?Math.max(0,o-1):o,v=Math.max(0,T-1),k=$?[...g,{position:v,show:!m}]:g;for(let f=N.length-1;f>=0;f--){const u=f===N.length-1;e.push([N[f],x,I,I,u,k,!1])}}return t}applyFilter(){this.filteredNodes.length>0&&(this.lastSelectedId=this.filteredNodes[this.selectedIndex]?.node.entry.id??this.lastSelectedId);const s=this.searchQuery.toLowerCase().split(/\s+/).filter(Boolean);if(this.filteredNodes=this.flatNodes.filter(t=>{const e=t.node.entry,n=e.id===this.currentLeafId;if(e.type==="message"&&e.message.role==="assistant"&&!n){const d=e.message,r=this.hasTextContent(d.content),o=d.stopReason&&d.stopReason!=="stop"&&d.stopReason!=="toolUse";if(!r&&!o)return!1}let i=!0;const l=e.type==="label"||e.type==="custom"||e.type==="model_change"||e.type==="thinking_level_change"||e.type==="session_info";switch(this.filterMode){case"user-only":i=e.type==="message"&&e.message.role==="user";break;case"no-tools":i=!l&&!(e.type==="message"&&e.message.role==="toolResult");break;case"labeled-only":i=t.node.label!==void 0;break;case"all":i=!0;break;default:i=!l;break}if(!i)return!1;if(s.length>0){const d=this.getSearchableText(t.node).toLowerCase();return s.every(r=>d.includes(r))}return!0}),this.foldedNodes.size>0){const t=new Set;for(const e of this.flatNodes){const{id:n,parentId:i}=e.node.entry;i!=null&&(this.foldedNodes.has(i)||t.has(i))&&t.add(n)}this.filteredNodes=this.filteredNodes.filter(e=>!t.has(e.node.entry.id))}this.recalculateVisualStructure(),this.lastSelectedId?this.selectedIndex=this.findNearestVisibleIndex(this.lastSelectedId):this.selectedIndex>=this.filteredNodes.length&&(this.selectedIndex=Math.max(0,this.filteredNodes.length-1)),this.filteredNodes.length>0&&(this.lastSelectedId=this.filteredNodes[this.selectedIndex]?.node.entry.id??this.lastSelectedId)}recalculateVisualStructure(){if(this.filteredNodes.length===0)return;const s=new Set(this.filteredNodes.map(o=>o.node.entry.id)),t=new Map;for(const o of this.flatNodes)t.set(o.node.entry.id,o);const e=w(o=>{let h=t.get(o)?.node.entry.parentId??null;for(;h!==null;){if(s.has(h))return h;h=t.get(h)?.node.entry.parentId??null}return null},"findVisibleAncestor"),n=new Map,i=new Map;i.set(null,[]);for(const o of this.filteredNodes){const h=o.node.entry.id,c=e(h);n.set(h,c),i.has(c)||i.set(c,[]),i.get(c).push(h)}const l=i.get(null);this.multipleRoots=l.length>1;const d=new Map;for(const o of this.filteredNodes)d.set(o.node.entry.id,o);const r=[];for(let o=l.length-1;o>=0;o--){const h=o===l.length-1;r.push([l[o],this.multipleRoots?1:0,this.multipleRoots,this.multipleRoots,h,[],this.multipleRoots])}for(;r.length>0;){const[o,h,c,m,g,p,L]=r.pop(),b=d.get(o);if(!b)continue;b.indent=h,b.showConnector=m,b.isLast=g,b.gutters=p,b.isVirtualRootChild=L;const I=i.get(o)||[],N=I.length>1;let x;N||c&&h>0?x=h+1:x=h;const $=m&&!L,T=this.multipleRoots?Math.max(0,h-1):h,v=Math.max(0,T-1),k=$?[...p,{position:v,show:!g}]:p;for(let f=I.length-1;f>=0;f--){const u=f===I.length-1;r.push([I[f],x,N,N,u,k,!1])}}this.visibleParentMap=n,this.visibleChildrenMap=i}getSearchableText(s){const t=s.entry,e=[];switch(s.label&&e.push(s.label),t.type){case"message":{const n=t.message;if(e.push(n.role),"content"in n&&n.content&&e.push(this.extractContent(n.content)),n.role==="bashExecution"){const i=n;i.command&&e.push(i.command)}break}case"custom_message":{e.push(t.customType),typeof t.content=="string"?e.push(t.content):e.push(this.extractContent(t.content));break}case"compaction":e.push("compaction");break;case"branch_summary":e.push("branch summary",t.summary);break;case"session_info":e.push("title"),t.name&&e.push(t.name);break;case"model_change":e.push("model",t.modelId);break;case"thinking_level_change":e.push("thinking",t.thinkingLevel);break;case"custom":e.push("custom",t.customType);break;case"label":e.push("label",t.label??"");break}return e.join(" ")}invalidate(){}getSearchQuery(){return this.searchQuery}getSelectedNode(){return this.filteredNodes[this.selectedIndex]?.node}updateNodeLabel(s,t,e){for(const n of this.flatNodes)if(n.node.entry.id===s){n.node.label=t,n.node.labelTimestamp=t?e??new Date().toISOString():void 0;break}}getStatusLabels(){let s="";switch(this.filterMode){case"no-tools":s+=" [no-tools]";break;case"user-only":s+=" [user]";break;case"labeled-only":s+=" [labeled]";break;case"all":s+=" [all]";break}return this.showLabelTimestamps&&(s+=" [+label time]"),s}render(s){const t=[];if(this.filteredNodes.length===0)return t.push(M(a.fg("muted"," No entries found"),s)),t.push(M(a.fg("muted",` (0/0)${this.getStatusLabels()}`),s)),t;const e=Math.max(0,Math.min(this.selectedIndex-Math.floor(this.maxVisibleLines/2),this.filteredNodes.length-this.maxVisibleLines)),n=Math.min(e+this.maxVisibleLines,this.filteredNodes.length);for(let i=e;i<n;i++){const l=this.filteredNodes[i],d=l.node.entry,r=i===this.selectedIndex,o=r?a.fg("accent","\u203A "):" ",h=this.multipleRoots?Math.max(0,l.indent-1):l.indent,c=l.showConnector&&!l.isVirtualRootChild?l.isLast?"\u2514\u2500 ":"\u251C\u2500 ":"",m=c?h-1:-1,g=h*3,p=[],L=this.foldedNodes.has(d.id);for(let u=0;u<g;u++){const C=Math.floor(u/3),F=u%3,P=l.gutters.find(R=>R.position===C);if(P)F===0?p.push(P.show?"\u2502":" "):p.push(" ");else if(c&&C===m)if(F===0)p.push(l.isLast?"\u2514":"\u251C");else if(F===1){const R=this.isFoldable(d.id);p.push(L?"\u229E":R?"\u229F":"\u2500")}else p.push(" ");else p.push(" ")}const b=p.join(""),I=l.showConnector&&!l.isVirtualRootChild,N=L&&!I?a.fg("accent","\u229E "):"",$=this.activePathIds.has(d.id)?a.fg("accent","\u2022 "):"",T=l.node.label?a.fg("warning",`[${l.node.label}] `):"",v=this.showLabelTimestamps&&l.node.label&&l.node.labelTimestamp?a.fg("muted",`${this.formatLabelTimestamp(l.node.labelTimestamp)} `):"",k=this.getEntryDisplayText(l.node,r);let f=o+a.fg("dim",b)+N+$+T+v+k;r&&(f=a.bg("selectedBg",f)),t.push(M(f,s))}return t.push(M(a.fg("muted",` (${this.selectedIndex+1}/${this.filteredNodes.length})${this.getStatusLabels()}`),s)),t}getEntryDisplayText(s,t){const e=s.entry;let n;const i=w(l=>l.replace(/[\n\t]/g," ").trim(),"normalize");switch(e.type){case"message":{const l=e.message,d=l.role;if(d==="user"){const r=l,o=i(this.extractContent(r.content));n=a.fg("accent","user: ")+o}else if(d==="assistant"){const r=l,o=i(this.extractContent(r.content));if(o)n=a.fg("success","assistant: ")+o;else if(r.stopReason==="aborted")n=a.fg("success","assistant: ")+a.fg("muted","(aborted)");else if(r.errorMessage){const h=i(r.errorMessage).slice(0,80);n=a.fg("success","assistant: ")+a.fg("error",h)}else n=a.fg("success","assistant: ")+a.fg("muted","(no content)")}else if(d==="toolResult"){const r=l,o=r.toolCallId?this.toolCallMap.get(r.toolCallId):void 0;o?n=a.fg("muted",this.formatToolCall(o.name,o.arguments)):n=a.fg("muted",`[${r.toolName??"tool"}]`)}else if(d==="bashExecution"){const r=l;n=a.fg("dim",`[bash]: ${i(r.command??"")}`)}else n=a.fg("dim",`[${d}]`);break}case"custom_message":{const l=typeof e.content=="string"?e.content:e.content.filter(d=>d.type==="text").map(d=>d.text).join("");n=a.fg("customMessageLabel",`[${e.customType}]: `)+i(l);break}case"compaction":{const l=Math.round(e.tokensBefore/1e3);n=a.fg("borderAccent",`[compaction: ${l}k tokens]`);break}case"branch_summary":n=a.fg("warning","[branch summary]: ")+i(e.summary);break;case"model_change":n=a.fg("dim",`[model: ${e.modelId}]`);break;case"thinking_level_change":n=a.fg("dim",`[thinking: ${e.thinkingLevel}]`);break;case"custom":n=a.fg("dim",`[custom: ${e.customType}]`);break;case"label":n=a.fg("dim",`[label: ${e.label??"(cleared)"}]`);break;case"session_info":n=e.name?[a.fg("dim","[title: "),a.fg("dim",e.name),a.fg("dim","]")].join(""):[a.fg("dim","[title: "),a.italic(a.fg("dim","empty")),a.fg("dim","]")].join("");break;default:n=""}return t?a.bold(n):n}formatLabelTimestamp(s){const t=new Date(s),e=new Date,n=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0"),l=`${n}:${i}`;if(t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate())return l;const d=t.getMonth()+1,r=t.getDate();return t.getFullYear()===e.getFullYear()?`${d}/${r} ${l}`:`${t.getFullYear().toString().slice(-2)}/${d}/${r} ${l}`}extractContent(s){if(typeof s=="string")return s.slice(0,200);if(Array.isArray(s)){let e="";for(const n of s)if(typeof n=="object"&&n!==null&&"type"in n&&n.type==="text"&&(e+=n.text,e.length>=200))return e.slice(0,200);return e}return""}hasTextContent(s){if(typeof s=="string")return s.trim().length>0;if(Array.isArray(s)){for(const t of s)if(typeof t=="object"&&t!==null&&"type"in t&&t.type==="text"){const e=t.text;if(e&&e.trim().length>0)return!0}}return!1}formatToolCall(s,t){const e=w(n=>{const i=process.env.HOME||process.env.USERPROFILE||"";return i&&n.startsWith(i)?`~${n.slice(i.length)}`:n},"shortenPath");switch(s){case"read":{const n=e(String(t.path||t.file_path||"")),i=t.offset,l=t.limit;let d=n;if(i!==void 0||l!==void 0){const r=i??1,o=l!==void 0?r+l-1:"";d+=`:${r}${o?`-${o}`:""}`}return`[read: ${d}]`}case"write":return`[write: ${e(String(t.path||t.file_path||""))}]`;case"edit":return`[edit: ${e(String(t.path||t.file_path||""))}]`;case"bash":{const n=String(t.command||"");return`[bash: ${n.replace(/[\n\t]/g," ").trim().slice(0,50)}${n.length>50?"...":""}]`}case"grep":{const n=String(t.pattern||""),i=e(String(t.path||"."));return`[grep: /${n}/ in ${i}]`}case"find":{const n=String(t.pattern||""),i=e(String(t.path||"."));return`[find: ${n} in ${i}]`}case"ls":return`[ls: ${e(String(t.path||"."))}]`;default:{const n=JSON.stringify(t).slice(0,40);return`[${s}: ${n}${JSON.stringify(t).length>40?"...":""}]`}}}handleInput(s){const t=A();if(t.matches(s,"tui.select.up"))this.selectedIndex=this.selectedIndex===0?this.filteredNodes.length-1:this.selectedIndex-1;else if(t.matches(s,"tui.select.down"))this.selectedIndex=this.selectedIndex===this.filteredNodes.length-1?0:this.selectedIndex+1;else if(t.matches(s,"app.tree.foldOrUp")){const e=this.filteredNodes[this.selectedIndex]?.node.entry.id;e&&this.isFoldable(e)&&!this.foldedNodes.has(e)?(this.foldedNodes.add(e),this.applyFilter()):this.selectedIndex=this.findBranchSegmentStart("up")}else if(t.matches(s,"app.tree.unfoldOrDown")){const e=this.filteredNodes[this.selectedIndex]?.node.entry.id;e&&this.foldedNodes.has(e)?(this.foldedNodes.delete(e),this.applyFilter()):this.selectedIndex=this.findBranchSegmentStart("down")}else if(t.matches(s,"tui.editor.cursorLeft")||t.matches(s,"tui.select.pageUp"))this.selectedIndex=Math.max(0,this.selectedIndex-this.maxVisibleLines);else if(t.matches(s,"tui.editor.cursorRight")||t.matches(s,"tui.select.pageDown"))this.selectedIndex=Math.min(this.filteredNodes.length-1,this.selectedIndex+this.maxVisibleLines);else if(t.matches(s,"tui.select.confirm")){const e=this.filteredNodes[this.selectedIndex];e&&this.onSelect&&this.onSelect(e.node.entry.id)}else if(t.matches(s,"tui.select.cancel"))this.searchQuery?(this.searchQuery="",this.foldedNodes.clear(),this.applyFilter()):this.onCancel?.();else if(t.matches(s,"app.tree.filter.default"))this.filterMode="default",this.foldedNodes.clear(),this.applyFilter();else if(t.matches(s,"app.tree.filter.noTools"))this.filterMode=this.filterMode==="no-tools"?"default":"no-tools",this.foldedNodes.clear(),this.applyFilter();else if(t.matches(s,"app.tree.filter.userOnly"))this.filterMode=this.filterMode==="user-only"?"default":"user-only",this.foldedNodes.clear(),this.applyFilter();else if(t.matches(s,"app.tree.filter.labeledOnly"))this.filterMode=this.filterMode==="labeled-only"?"default":"labeled-only",this.foldedNodes.clear(),this.applyFilter();else if(t.matches(s,"app.tree.filter.all"))this.filterMode=this.filterMode==="all"?"default":"all",this.foldedNodes.clear(),this.applyFilter();else if(t.matches(s,"app.tree.filter.cycleBackward")){const e=["default","no-tools","user-only","labeled-only","all"],n=e.indexOf(this.filterMode);this.filterMode=e[(n-1+e.length)%e.length],this.foldedNodes.clear(),this.applyFilter()}else if(t.matches(s,"app.tree.filter.cycleForward")){const e=["default","no-tools","user-only","labeled-only","all"],n=e.indexOf(this.filterMode);this.filterMode=e[(n+1)%e.length],this.foldedNodes.clear(),this.applyFilter()}else if(t.matches(s,"tui.editor.deleteCharBackward"))this.searchQuery.length>0&&(this.searchQuery=this.searchQuery.slice(0,-1),this.foldedNodes.clear(),this.applyFilter());else if(t.matches(s,"app.tree.editLabel")){const e=this.filteredNodes[this.selectedIndex];e&&this.onLabelEdit&&this.onLabelEdit(e.node.entry.id,e.node.label)}else t.matches(s,"app.tree.toggleLabelTimestamp")?this.showLabelTimestamps=!this.showLabelTimestamps:![...s].some(n=>{const i=n.charCodeAt(0);return i<32||i===127||i>=128&&i<=159})&&s.length>0&&(this.searchQuery+=s,this.foldedNodes.clear(),this.applyFilter())}isFoldable(s){const t=this.visibleChildrenMap.get(s);if(!t||t.length===0)return!1;const e=this.visibleParentMap.get(s);if(e==null)return!0;const n=this.visibleChildrenMap.get(e);return n!==void 0&&n.length>1}findBranchSegmentStart(s){const t=this.filteredNodes[this.selectedIndex]?.node.entry.id;if(!t)return this.selectedIndex;const e=new Map(this.filteredNodes.map((i,l)=>[i.node.entry.id,l]));let n=t;if(s==="down")for(;;){const i=this.visibleChildrenMap.get(n)??[];if(i.length===0)return e.get(n);if(i.length>1)return e.get(i[0]);n=i[0]}for(;;){const i=this.visibleParentMap.get(n)??null;if(i===null)return e.get(n);if((this.visibleChildrenMap.get(i)??[]).length>1){const d=e.get(n);if(d<this.selectedIndex)return d}n=i}}}class Y{static{w(this,"SearchLine")}treeList;constructor(s){this.treeList=s}invalidate(){}render(s){const t=this.treeList.getSearchQuery();return t?[M(` ${a.fg("muted","Type to search:")} ${a.fg("accent",t)}`,s)]:[M(` ${a.fg("muted","Type to search:")}`,s)]}handleInput(s){}}class K{static{w(this,"LabelInput")}input;entryId;onSubmit;onCancel;_focused=!1;get focused(){return this._focused}set focused(s){this._focused=s,this.input.focused=s}constructor(s,t){this.entryId=s,this.input=new j,t&&this.input.setValue(t)}invalidate(){}render(s){const t=[],n=s-2;return t.push(M(` ${a.fg("muted","Label (empty to remove):")}`,s)),t.push(...this.input.render(n).map(i=>M(` ${i}`,s))),t.push(M(` ${E("tui.select.confirm","save")} ${E("tui.select.cancel","cancel")}`,s)),t}handleInput(s){const t=A();if(t.matches(s,"tui.select.confirm")){const e=this.input.getValue().trim();this.onSubmit?.(this.entryId,e||void 0)}else t.matches(s,"tui.select.cancel")?this.onCancel?.():this.input.handleInput(s)}}class X extends _{static{w(this,"TreeSelectorComponent")}treeList;labelInput=null;labelInputContainer;treeContainer;onLabelChangeCallback;_focused=!1;get focused(){return this._focused}set focused(s){this._focused=s,this.labelInput&&(this.labelInput.focused=s)}constructor(s,t,e,n,i,l,d,r){super(),this.onLabelChangeCallback=l;const o=Math.max(5,Math.floor(e/2));this.treeList=new W(s,t,o,d,r),this.treeList.onSelect=n,this.treeList.onCancel=i,this.treeList.onLabelEdit=(g,p)=>this.showLabelInput(g,p),this.treeContainer=new _,this.treeContainer.addChild(this.treeList),this.labelInputContainer=new _,this.addChild(new V(1)),this.addChild(new O),this.addChild(new Q(a.bold(" Session Tree"),1,0));const h=[y("app.tree.filter.default"),y("app.tree.filter.noTools"),y("app.tree.filter.userOnly"),y("app.tree.filter.labeledOnly"),y("app.tree.filter.all")].join("/"),c=`${y("app.tree.filter.cycleForward")}/${y("app.tree.filter.cycleBackward")}`,m=`${y("app.tree.foldOrUp")}/${y("app.tree.unfoldOrDown")}`;this.addChild(new U(a.fg("muted",` \u2191/\u2193: move. \u2190/\u2192: page. ${m}: fold/branch. ${y("app.tree.editLabel")}: label. ${h}: filters (${c} cycle). ${y("app.tree.toggleLabelTimestamp")}: label time`),0,0)),this.addChild(new Y(this.treeList)),this.addChild(new O),this.addChild(new V(1)),this.addChild(this.treeContainer),this.addChild(this.labelInputContainer),this.addChild(new V(1)),this.addChild(new O),s.length===0&&setTimeout(()=>i(),100)}showLabelInput(s,t){this.labelInput=new K(s,t),this.labelInput.onSubmit=(e,n)=>{this.treeList.updateNodeLabel(e,n),this.onLabelChangeCallback?.(e,n),this.hideLabelInput()},this.labelInput.onCancel=()=>this.hideLabelInput(),this.labelInput.focused=this._focused,this.treeContainer.clear(),this.labelInputContainer.clear(),this.labelInputContainer.addChild(this.labelInput)}hideLabelInput(){this.labelInput=null,this.labelInputContainer.clear(),this.treeContainer.clear(),this.treeContainer.addChild(this.treeList)}handleInput(s){this.labelInput?this.labelInput.handleInput(s):this.treeList.handleInput(s)}getTreeList(){return this.treeList}}export{X as TreeSelectorComponent};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Component, Container } from "@openadapter/koda-tui";
|
|
2
|
+
interface UserMessageItem {
|
|
3
|
+
id: string;
|
|
4
|
+
text: string;
|
|
5
|
+
timestamp?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Custom user message list component with selection
|
|
9
|
+
*/
|
|
10
|
+
declare class UserMessageList implements Component {
|
|
11
|
+
private messages;
|
|
12
|
+
private selectedIndex;
|
|
13
|
+
onSelect?: (entryId: string) => void;
|
|
14
|
+
onCancel?: () => void;
|
|
15
|
+
private maxVisible;
|
|
16
|
+
constructor(messages: UserMessageItem[], initialSelectedId?: string);
|
|
17
|
+
invalidate(): void;
|
|
18
|
+
render(width: number): string[];
|
|
19
|
+
handleInput(keyData: string): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Component that renders a user message selector for branching
|
|
23
|
+
*/
|
|
24
|
+
export declare class UserMessageSelectorComponent extends Container {
|
|
25
|
+
private messageList;
|
|
26
|
+
constructor(messages: UserMessageItem[], onSelect: (entryId: string) => void, onCancel: () => void, initialSelectedId?: string);
|
|
27
|
+
getMessageList(): UserMessageList;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var M=Object.defineProperty;var o=(a,s)=>M(a,"name",{value:s,configurable:!0});import{Container as w,getKeybindings as L,Spacer as d,Text as m,truncateToWidth as b}from"@openadapter/koda-tui";import{theme as n}from"../theme/theme.js";import{DynamicBorder as g}from"./dynamic-border.js";class S{static{o(this,"UserMessageList")}messages=[];selectedIndex=0;onSelect;onCancel;maxVisible=10;constructor(s,e){this.messages=s;const t=e?s.findIndex(h=>h.id===e):-1;this.selectedIndex=t>=0?t:Math.max(0,s.length-1)}invalidate(){}render(s){const e=[];if(this.messages.length===0)return e.push(n.fg("muted"," No user messages found")),e;const t=Math.max(0,Math.min(this.selectedIndex-Math.floor(this.maxVisible/2),this.messages.length-this.maxVisible)),h=Math.min(t+this.maxVisible,this.messages.length);for(let i=t;i<h;i++){const r=this.messages[i],c=i===this.selectedIndex,u=r.text.replace(/\n/g," ").trim(),x=c?n.fg("accent","\u203A "):" ",f=s-2,l=b(u,f),p=x+(c?n.bold(l):l);e.push(p);const I=` Message ${i+1} of ${this.messages.length}`,C=n.fg("muted",I);e.push(C),e.push("")}if(t>0||h<this.messages.length){const i=n.fg("muted",` (${this.selectedIndex+1}/${this.messages.length})`);e.push(i)}return e}handleInput(s){const e=L();if(e.matches(s,"tui.select.up"))this.selectedIndex=this.selectedIndex===0?this.messages.length-1:this.selectedIndex-1;else if(e.matches(s,"tui.select.down"))this.selectedIndex=this.selectedIndex===this.messages.length-1?0:this.selectedIndex+1;else if(e.matches(s,"tui.select.confirm")){const t=this.messages[this.selectedIndex];t&&this.onSelect&&this.onSelect(t.id)}else e.matches(s,"tui.select.cancel")&&this.onCancel&&this.onCancel()}}class W extends w{static{o(this,"UserMessageSelectorComponent")}messageList;constructor(s,e,t,h){super(),this.addChild(new d(1)),this.addChild(new m(n.bold("Fork from Message"),1,0)),this.addChild(new m(n.fg("muted","Select a user message to copy the active path up to that point into a new session"),1,0)),this.addChild(new d(1)),this.addChild(new g),this.addChild(new d(1)),this.messageList=new S(s,h),this.messageList.onSelect=e,this.messageList.onCancel=t,this.addChild(this.messageList),this.addChild(new d(1)),this.addChild(new g),s.length===0&&setTimeout(()=>t(),100)}getMessageList(){return this.messageList}}export{W as UserMessageSelectorComponent};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Container, type MarkdownTheme } from "@openadapter/koda-tui";
|
|
2
|
+
/**
|
|
3
|
+
* Component that renders a user message
|
|
4
|
+
*/
|
|
5
|
+
export declare class UserMessageComponent extends Container {
|
|
6
|
+
private contentBox;
|
|
7
|
+
constructor(text: string, markdownTheme?: MarkdownTheme);
|
|
8
|
+
render(width: number): string[];
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var x=Object.defineProperty;var n=(o,t)=>x(o,"name",{value:t,configurable:!0});import{Box as d,Container as c,Markdown as i}from"@openadapter/koda-tui";import{getMarkdownTheme as h,theme as s}from"../theme/theme.js";const a="\x1B]133;A\x07",g="\x1B]133;B\x07",l="\x1B]133;C\x07";class p extends c{static{n(this,"UserMessageComponent")}contentBox;constructor(t,e=h()){super(),this.contentBox=new d(1,1,r=>s.bg("userMessageBg",r)),this.contentBox.addChild(new i(t,0,0,e,{color:n(r=>s.fg("userMessageText",r),"color")},{preserveOrderedListMarkers:!0})),this.addChild(this.contentBox)}render(t){const e=super.render(t);return e.length===0||(e[0]=a+e[0],e[e.length-1]=g+l+e[e.length-1]),e}}export{p as UserMessageComponent};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utility for truncating text to visual lines (accounting for line wrapping).
|
|
3
|
+
* Used by both tool-execution.ts and bash-execution.ts for consistent behavior.
|
|
4
|
+
*/
|
|
5
|
+
export interface VisualTruncateResult {
|
|
6
|
+
/** The visual lines to display */
|
|
7
|
+
visualLines: string[];
|
|
8
|
+
/** Number of visual lines that were skipped (hidden) */
|
|
9
|
+
skippedCount: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Truncate text to a maximum number of visual lines (from the end).
|
|
13
|
+
* This accounts for line wrapping based on terminal width.
|
|
14
|
+
*
|
|
15
|
+
* @param text - The text content (may contain newlines)
|
|
16
|
+
* @param maxVisualLines - Maximum number of visual lines to show
|
|
17
|
+
* @param width - Terminal/render width
|
|
18
|
+
* @param paddingX - Horizontal padding for Text component (default 0).
|
|
19
|
+
* Use 0 when result will be placed in a Box (Box adds its own padding).
|
|
20
|
+
* Use 1 when result will be placed in a plain Container.
|
|
21
|
+
* @returns The truncated visual lines and count of skipped lines
|
|
22
|
+
*/
|
|
23
|
+
export declare function truncateToVisualLines(text: string, maxVisualLines: number, width: number, paddingX?: number): VisualTruncateResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p=Object.defineProperty;var i=(n,e)=>p(n,"name",{value:e,configurable:!0});import{Text as c}from"@openadapter/koda-tui";function f(n,e,s,r=0){if(!n)return{visualLines:[],skippedCount:0};const t=new c(n,r,0).render(s);if(t.length<=e)return{visualLines:t,skippedCount:0};const o=t.slice(-e),u=t.length-e;return{visualLines:o,skippedCount:u}}i(f,"truncateToVisualLines");export{f as truncateToVisualLines};
|