tulingcode 0.1.0
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/AGENTS.md +134 -0
- package/Dockerfile +18 -0
- package/README.md +15 -0
- package/bin/tuling +179 -0
- package/bunfig.toml +7 -0
- package/drizzle.config.ts +10 -0
- package/git +0 -0
- package/migration/20260127222353_familiar_lady_ursula/migration.sql +90 -0
- package/migration/20260127222353_familiar_lady_ursula/snapshot.json +796 -0
- package/migration/20260211171708_add_project_commands/migration.sql +1 -0
- package/migration/20260211171708_add_project_commands/snapshot.json +806 -0
- package/migration/20260213144116_wakeful_the_professor/migration.sql +11 -0
- package/migration/20260213144116_wakeful_the_professor/snapshot.json +897 -0
- package/migration/20260225215848_workspace/migration.sql +7 -0
- package/migration/20260225215848_workspace/snapshot.json +959 -0
- package/migration/20260227213759_add_session_workspace_id/migration.sql +2 -0
- package/migration/20260227213759_add_session_workspace_id/snapshot.json +983 -0
- package/migration/20260228203230_blue_harpoon/migration.sql +17 -0
- package/migration/20260228203230_blue_harpoon/snapshot.json +1102 -0
- package/migration/20260303231226_add_workspace_fields/migration.sql +5 -0
- package/migration/20260303231226_add_workspace_fields/snapshot.json +1013 -0
- package/migration/20260309230000_move_org_to_state/migration.sql +3 -0
- package/migration/20260309230000_move_org_to_state/snapshot.json +1156 -0
- package/migration/20260312043431_session_message_cursor/migration.sql +4 -0
- package/migration/20260312043431_session_message_cursor/snapshot.json +1168 -0
- package/migration/20260323234822_events/migration.sql +13 -0
- package/migration/20260323234822_events/snapshot.json +1271 -0
- package/migration/20260410174513_workspace-name/migration.sql +16 -0
- package/migration/20260410174513_workspace-name/snapshot.json +1271 -0
- package/migration/20260413175956_chief_energizer/migration.sql +13 -0
- package/migration/20260413175956_chief_energizer/snapshot.json +1399 -0
- package/migration/20260422160000_context_inheritance/migration.sql +3 -0
- package/migration/20260422170000_task_registry/migration.sql +18 -0
- package/migration/20260423145421_remove_session_entry/migration.sql +4 -0
- package/migration/20260515000000_actor_rename/migration.sql +7 -0
- package/migration/20260515010000_memory_fts/migration.sql +33 -0
- package/migration/20260515020000_user_task/migration.sql +29 -0
- package/migration/20260519000000_last_checkpoint_message_id/migration.sql +1 -0
- package/migration/20260521000000_message_agent_id/migration.sql +2 -0
- package/migration/20260521000100_actor_registry_v6/migration.sql +25 -0
- package/migration/20260521010000_memory_fts_v6/migration.sql +33 -0
- package/migration/20260521020000_memory_fts_triggers/migration.sql +17 -0
- package/migration/20260526000000_agent_id_main/migration.sql +14 -0
- package/migration/20260527000000_actor_lifecycle/migration.sql +8 -0
- package/migration/20260527000100_inbox/migration.sql +12 -0
- package/migration/20260529000000_task_todo_redesign/migration.sql +16 -0
- package/migration/20260603000000_task_in_progress_owner/migration.sql +1 -0
- package/migration/20260603000000_workflow_run/migration.sql +17 -0
- package/migration/20260604000000_workflow_script_sha/migration.sql +1 -0
- package/migration/20260608000000_claude_import/migration.sql +7 -0
- package/migration/20260608010000_claude_import_message_ids/migration.sql +1 -0
- package/migration/20260609000000_history_fts/migration.sql +29 -0
- package/migration/20260609230000_workflow_agent_timeout/migration.sql +1 -0
- package/package.json +196 -0
- package/parsers-config.ts +290 -0
- package/script/build.ts +267 -0
- package/script/check-migrations.ts +16 -0
- package/script/fix-node-pty.ts +28 -0
- package/script/generate.ts +23 -0
- package/script/postinstall.mjs +102 -0
- package/script/publish.ts +60 -0
- package/script/run-workspace-server +106 -0
- package/script/schema.ts +63 -0
- package/script/time.ts +6 -0
- package/script/trace-imports.ts +153 -0
- package/script/upgrade-opentui.ts +64 -0
- package/src/account/account.sql.ts +39 -0
- package/src/account/account.ts +456 -0
- package/src/account/repo.ts +166 -0
- package/src/account/schema.ts +99 -0
- package/src/account/url.ts +8 -0
- package/src/acp/README.md +174 -0
- package/src/acp/agent.ts +1783 -0
- package/src/acp/session.ts +116 -0
- package/src/acp/types.ts +24 -0
- package/src/actor/actor.sql.ts +38 -0
- package/src/actor/events.ts +67 -0
- package/src/actor/index.ts +2 -0
- package/src/actor/registry.ts +412 -0
- package/src/actor/return-header.ts +24 -0
- package/src/actor/schema.ts +47 -0
- package/src/actor/spawn-ref.ts +16 -0
- package/src/actor/spawn.ts +741 -0
- package/src/actor/turn.ts +49 -0
- package/src/actor/waiter.ts +166 -0
- package/src/agent/agent.ts +554 -0
- package/src/agent/config.ts +5 -0
- package/src/agent/generate.txt +75 -0
- package/src/agent/prompt/checkpoint-writer.txt +167 -0
- package/src/agent/prompt/compaction.txt +9 -0
- package/src/agent/prompt/distill.txt +199 -0
- package/src/agent/prompt/dream.txt +155 -0
- package/src/agent/prompt/explore.txt +18 -0
- package/src/agent/prompt/summary.txt +11 -0
- package/src/agent/prompt/title.txt +44 -0
- package/src/audio.d.ts +9 -0
- package/src/auth/index.ts +97 -0
- package/src/bus/bus-event.ts +33 -0
- package/src/bus/global.ts +12 -0
- package/src/bus/index.ts +193 -0
- package/src/cli/bootstrap.ts +33 -0
- package/src/cli/cmd/account.ts +258 -0
- package/src/cli/cmd/acp.ts +70 -0
- package/src/cli/cmd/agent.ts +248 -0
- package/src/cli/cmd/cmd.ts +7 -0
- package/src/cli/cmd/db.ts +120 -0
- package/src/cli/cmd/debug/agent.ts +192 -0
- package/src/cli/cmd/debug/config.ts +17 -0
- package/src/cli/cmd/debug/file.ts +100 -0
- package/src/cli/cmd/debug/index.ts +48 -0
- package/src/cli/cmd/debug/lsp.ts +61 -0
- package/src/cli/cmd/debug/ripgrep.ts +105 -0
- package/src/cli/cmd/debug/scrap.ts +16 -0
- package/src/cli/cmd/debug/skill.ts +23 -0
- package/src/cli/cmd/debug/snapshot.ts +53 -0
- package/src/cli/cmd/export.ts +306 -0
- package/src/cli/cmd/generate.ts +50 -0
- package/src/cli/cmd/github.ts +1647 -0
- package/src/cli/cmd/import.ts +208 -0
- package/src/cli/cmd/mcp.ts +812 -0
- package/src/cli/cmd/models.ts +88 -0
- package/src/cli/cmd/plug.ts +233 -0
- package/src/cli/cmd/pr.ts +138 -0
- package/src/cli/cmd/providers.ts +705 -0
- package/src/cli/cmd/run-completion.ts +77 -0
- package/src/cli/cmd/run.ts +694 -0
- package/src/cli/cmd/serve.ts +21 -0
- package/src/cli/cmd/session.ts +181 -0
- package/src/cli/cmd/stats.ts +413 -0
- package/src/cli/cmd/tui/app.tsx +1130 -0
- package/src/cli/cmd/tui/asset/TEN_VAD_LICENSE +12 -0
- package/src/cli/cmd/tui/asset/charge.wav +0 -0
- package/src/cli/cmd/tui/asset/pulse-a.wav +0 -0
- package/src/cli/cmd/tui/asset/pulse-b.wav +0 -0
- package/src/cli/cmd/tui/asset/pulse-c.wav +0 -0
- package/src/cli/cmd/tui/asset/ten_vad.wasm +0 -0
- package/src/cli/cmd/tui/asset/ten_vad_loader.js +30 -0
- package/src/cli/cmd/tui/attach.ts +83 -0
- package/src/cli/cmd/tui/component/background-image.tsx +150 -0
- package/src/cli/cmd/tui/component/bg-pulse.tsx +130 -0
- package/src/cli/cmd/tui/component/border.tsx +21 -0
- package/src/cli/cmd/tui/component/dialog-agent.tsx +31 -0
- package/src/cli/cmd/tui/component/dialog-command.tsx +208 -0
- package/src/cli/cmd/tui/component/dialog-console-org.tsx +103 -0
- package/src/cli/cmd/tui/component/dialog-go-upsell.tsx +157 -0
- package/src/cli/cmd/tui/component/dialog-image-list.tsx +111 -0
- package/src/cli/cmd/tui/component/dialog-logo-design.tsx +37 -0
- package/src/cli/cmd/tui/component/dialog-mcp.tsx +86 -0
- package/src/cli/cmd/tui/component/dialog-mimo-login.tsx +224 -0
- package/src/cli/cmd/tui/component/dialog-model.tsx +253 -0
- package/src/cli/cmd/tui/component/dialog-provider.tsx +490 -0
- package/src/cli/cmd/tui/component/dialog-session-delete-failed.tsx +101 -0
- package/src/cli/cmd/tui/component/dialog-session-list.tsx +269 -0
- package/src/cli/cmd/tui/component/dialog-session-rename.tsx +31 -0
- package/src/cli/cmd/tui/component/dialog-skill.tsx +42 -0
- package/src/cli/cmd/tui/component/dialog-stash.tsx +87 -0
- package/src/cli/cmd/tui/component/dialog-status.tsx +170 -0
- package/src/cli/cmd/tui/component/dialog-tag.tsx +44 -0
- package/src/cli/cmd/tui/component/dialog-theme-list.tsx +50 -0
- package/src/cli/cmd/tui/component/dialog-variant.tsx +39 -0
- package/src/cli/cmd/tui/component/dialog-workflows.tsx +62 -0
- package/src/cli/cmd/tui/component/dialog-workspace-create.tsx +289 -0
- package/src/cli/cmd/tui/component/dialog-workspace-unavailable.tsx +81 -0
- package/src/cli/cmd/tui/component/dialog-worktree.tsx +90 -0
- package/src/cli/cmd/tui/component/error-component.tsx +92 -0
- package/src/cli/cmd/tui/component/logo.tsx +961 -0
- package/src/cli/cmd/tui/component/plugin-route-missing.tsx +14 -0
- package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +684 -0
- package/src/cli/cmd/tui/component/prompt/cwd.ts +0 -0
- package/src/cli/cmd/tui/component/prompt/frecency.tsx +90 -0
- package/src/cli/cmd/tui/component/prompt/history.tsx +108 -0
- package/src/cli/cmd/tui/component/prompt/index.tsx +1812 -0
- package/src/cli/cmd/tui/component/prompt/part.ts +16 -0
- package/src/cli/cmd/tui/component/prompt/stash.tsx +101 -0
- package/src/cli/cmd/tui/component/spinner.tsx +24 -0
- package/src/cli/cmd/tui/component/starry-background.tsx +305 -0
- package/src/cli/cmd/tui/component/startup-loading.tsx +67 -0
- package/src/cli/cmd/tui/component/task-item.tsx +63 -0
- package/src/cli/cmd/tui/component/textarea-keybindings.ts +73 -0
- package/src/cli/cmd/tui/component/todo-item.tsx +32 -0
- package/src/cli/cmd/tui/config/cwd.ts +5 -0
- package/src/cli/cmd/tui/config/tui-migrate.ts +151 -0
- package/src/cli/cmd/tui/config/tui-schema.ts +38 -0
- package/src/cli/cmd/tui/config/tui.ts +219 -0
- package/src/cli/cmd/tui/context/args.tsx +16 -0
- package/src/cli/cmd/tui/context/directory.ts +15 -0
- package/src/cli/cmd/tui/context/event.ts +45 -0
- package/src/cli/cmd/tui/context/exit.tsx +65 -0
- package/src/cli/cmd/tui/context/helper.tsx +25 -0
- package/src/cli/cmd/tui/context/keybind.tsx +105 -0
- package/src/cli/cmd/tui/context/kv.tsx +76 -0
- package/src/cli/cmd/tui/context/language.tsx +91 -0
- package/src/cli/cmd/tui/context/local.tsx +455 -0
- package/src/cli/cmd/tui/context/plugin-keybinds.ts +41 -0
- package/src/cli/cmd/tui/context/project.tsx +109 -0
- package/src/cli/cmd/tui/context/prompt.tsx +18 -0
- package/src/cli/cmd/tui/context/route.tsx +61 -0
- package/src/cli/cmd/tui/context/sdk.tsx +150 -0
- package/src/cli/cmd/tui/context/sync.tsx +828 -0
- package/src/cli/cmd/tui/context/theme/aura.json +69 -0
- package/src/cli/cmd/tui/context/theme/ayu.json +80 -0
- package/src/cli/cmd/tui/context/theme/carbonfox.json +248 -0
- package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +230 -0
- package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +230 -0
- package/src/cli/cmd/tui/context/theme/catppuccin.json +112 -0
- package/src/cli/cmd/tui/context/theme/cobalt2.json +225 -0
- package/src/cli/cmd/tui/context/theme/cursor.json +249 -0
- package/src/cli/cmd/tui/context/theme/dracula.json +219 -0
- package/src/cli/cmd/tui/context/theme/everforest.json +241 -0
- package/src/cli/cmd/tui/context/theme/flexoki.json +237 -0
- package/src/cli/cmd/tui/context/theme/github.json +233 -0
- package/src/cli/cmd/tui/context/theme/gruvbox.json +242 -0
- package/src/cli/cmd/tui/context/theme/kanagawa.json +77 -0
- package/src/cli/cmd/tui/context/theme/lucent-orng.json +234 -0
- package/src/cli/cmd/tui/context/theme/material.json +235 -0
- package/src/cli/cmd/tui/context/theme/matrix.json +77 -0
- package/src/cli/cmd/tui/context/theme/mercury.json +252 -0
- package/src/cli/cmd/tui/context/theme/monokai.json +221 -0
- package/src/cli/cmd/tui/context/theme/nightowl.json +221 -0
- package/src/cli/cmd/tui/context/theme/nord.json +223 -0
- package/src/cli/cmd/tui/context/theme/one-dark.json +84 -0
- package/src/cli/cmd/tui/context/theme/orng.json +249 -0
- package/src/cli/cmd/tui/context/theme/osaka-jade.json +93 -0
- package/src/cli/cmd/tui/context/theme/palenight.json +222 -0
- package/src/cli/cmd/tui/context/theme/rosepine.json +234 -0
- package/src/cli/cmd/tui/context/theme/solarized.json +223 -0
- package/src/cli/cmd/tui/context/theme/synthwave84.json +226 -0
- package/src/cli/cmd/tui/context/theme/tokyonight.json +243 -0
- package/src/cli/cmd/tui/context/theme/tulingcode.json +245 -0
- package/src/cli/cmd/tui/context/theme/vercel.json +245 -0
- package/src/cli/cmd/tui/context/theme/vesper.json +218 -0
- package/src/cli/cmd/tui/context/theme/zenburn.json +223 -0
- package/src/cli/cmd/tui/context/theme.tsx +1298 -0
- package/src/cli/cmd/tui/context/thinking.ts +48 -0
- package/src/cli/cmd/tui/context/tui-config.tsx +9 -0
- package/src/cli/cmd/tui/event.ts +56 -0
- package/src/cli/cmd/tui/feature-plugins/home/footer.tsx +93 -0
- package/src/cli/cmd/tui/feature-plugins/home/tips-view.tsx +193 -0
- package/src/cli/cmd/tui/feature-plugins/home/tips.tsx +54 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/context.tsx +114 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/cwd.tsx +45 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/files.tsx +62 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/footer.tsx +93 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/goal.tsx +84 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/instructions.tsx +54 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/lsp.tsx +66 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/mcp.tsx +98 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/task.tsx +95 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/todo.tsx +51 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/tps.ts +31 -0
- package/src/cli/cmd/tui/feature-plugins/system/plugins.tsx +274 -0
- package/src/cli/cmd/tui/i18n/en.ts +397 -0
- package/src/cli/cmd/tui/i18n/es.ts +433 -0
- package/src/cli/cmd/tui/i18n/fr.ts +440 -0
- package/src/cli/cmd/tui/i18n/ja.ts +392 -0
- package/src/cli/cmd/tui/i18n/locales.ts +82 -0
- package/src/cli/cmd/tui/i18n/ru.ts +452 -0
- package/src/cli/cmd/tui/i18n/zh.ts +390 -0
- package/src/cli/cmd/tui/i18n/zht.ts +360 -0
- package/src/cli/cmd/tui/layer.ts +6 -0
- package/src/cli/cmd/tui/plugin/api.tsx +402 -0
- package/src/cli/cmd/tui/plugin/index.ts +3 -0
- package/src/cli/cmd/tui/plugin/internal.ts +35 -0
- package/src/cli/cmd/tui/plugin/runtime.ts +1030 -0
- package/src/cli/cmd/tui/plugin/slots.tsx +60 -0
- package/src/cli/cmd/tui/routes/home.tsx +165 -0
- package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +76 -0
- package/src/cli/cmd/tui/routes/session/dialog-message.tsx +116 -0
- package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +47 -0
- package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +47 -0
- package/src/cli/cmd/tui/routes/session/footer.tsx +91 -0
- package/src/cli/cmd/tui/routes/session/index.tsx +2532 -0
- package/src/cli/cmd/tui/routes/session/permission.tsx +691 -0
- package/src/cli/cmd/tui/routes/session/question.tsx +488 -0
- package/src/cli/cmd/tui/routes/session/sidebar.tsx +97 -0
- package/src/cli/cmd/tui/routes/session/subagent-footer.tsx +142 -0
- package/src/cli/cmd/tui/thread.ts +246 -0
- package/src/cli/cmd/tui/ui/dialog-alert.tsx +61 -0
- package/src/cli/cmd/tui/ui/dialog-confirm.tsx +95 -0
- package/src/cli/cmd/tui/ui/dialog-export-options.tsx +223 -0
- package/src/cli/cmd/tui/ui/dialog-help.tsx +42 -0
- package/src/cli/cmd/tui/ui/dialog-prompt.tsx +123 -0
- package/src/cli/cmd/tui/ui/dialog-select.tsx +452 -0
- package/src/cli/cmd/tui/ui/dialog.tsx +207 -0
- package/src/cli/cmd/tui/ui/link.tsx +28 -0
- package/src/cli/cmd/tui/ui/spinner.ts +378 -0
- package/src/cli/cmd/tui/ui/toast.tsx +102 -0
- package/src/cli/cmd/tui/util/clipboard.ts +203 -0
- package/src/cli/cmd/tui/util/editor.ts +35 -0
- package/src/cli/cmd/tui/util/image-protocol.ts +35 -0
- package/src/cli/cmd/tui/util/index.ts +6 -0
- package/src/cli/cmd/tui/util/model.ts +23 -0
- package/src/cli/cmd/tui/util/provider-origin.ts +7 -0
- package/src/cli/cmd/tui/util/revert-diff.ts +18 -0
- package/src/cli/cmd/tui/util/scroll.ts +23 -0
- package/src/cli/cmd/tui/util/selection.ts +23 -0
- package/src/cli/cmd/tui/util/signal.ts +41 -0
- package/src/cli/cmd/tui/util/sound.ts +154 -0
- package/src/cli/cmd/tui/util/system-locale.ts +209 -0
- package/src/cli/cmd/tui/util/terminal.ts +110 -0
- package/src/cli/cmd/tui/util/transcript.ts +112 -0
- package/src/cli/cmd/tui/util/vad.ts +229 -0
- package/src/cli/cmd/tui/util/voice.ts +360 -0
- package/src/cli/cmd/tui/win32.ts +130 -0
- package/src/cli/cmd/tui/worker.ts +104 -0
- package/src/cli/cmd/uninstall.ts +351 -0
- package/src/cli/cmd/upgrade.ts +79 -0
- package/src/cli/cmd/web.ts +81 -0
- package/src/cli/effect/prompt.ts +25 -0
- package/src/cli/error.ts +82 -0
- package/src/cli/heap.ts +59 -0
- package/src/cli/i18n.ts +15 -0
- package/src/cli/logo.ts +53 -0
- package/src/cli/network.ts +62 -0
- package/src/cli/ui.ts +133 -0
- package/src/cli/upgrade.ts +41 -0
- package/src/command/index.ts +276 -0
- package/src/command/template/initialize.txt +66 -0
- package/src/command/template/review.txt +101 -0
- package/src/config/agent.ts +197 -0
- package/src/config/command.ts +69 -0
- package/src/config/config.ts +1024 -0
- package/src/config/console-state.ts +16 -0
- package/src/config/entry-name.ts +16 -0
- package/src/config/error.ts +21 -0
- package/src/config/formatter.ts +17 -0
- package/src/config/history.ts +21 -0
- package/src/config/index.ts +16 -0
- package/src/config/keybinds.ts +127 -0
- package/src/config/layout.ts +10 -0
- package/src/config/lsp.ts +45 -0
- package/src/config/managed.ts +70 -0
- package/src/config/markdown.ts +97 -0
- package/src/config/mcp.ts +172 -0
- package/src/config/model-id.ts +14 -0
- package/src/config/parse.ts +44 -0
- package/src/config/paths.ts +73 -0
- package/src/config/permission.ts +76 -0
- package/src/config/plugin.ts +88 -0
- package/src/config/provider.ts +118 -0
- package/src/config/server.ts +20 -0
- package/src/config/skills.ts +16 -0
- package/src/config/variable.ts +90 -0
- package/src/control-plane/adaptors/index.ts +52 -0
- package/src/control-plane/adaptors/worktree.ts +47 -0
- package/src/control-plane/dev/debug-workspace-plugin.ts +73 -0
- package/src/control-plane/schema.ts +19 -0
- package/src/control-plane/sse.ts +66 -0
- package/src/control-plane/types.ts +34 -0
- package/src/control-plane/util.ts +37 -0
- package/src/control-plane/workspace-context.ts +26 -0
- package/src/control-plane/workspace.sql.ts +17 -0
- package/src/control-plane/workspace.ts +615 -0
- package/src/effect/app-runtime.ts +146 -0
- package/src/effect/bootstrap-runtime.ts +33 -0
- package/src/effect/bridge.ts +48 -0
- package/src/effect/cross-spawn-spawner.ts +514 -0
- package/src/effect/index.ts +5 -0
- package/src/effect/instance-ref.ts +11 -0
- package/src/effect/instance-registry.ts +12 -0
- package/src/effect/instance-state.ts +81 -0
- package/src/effect/logger.ts +73 -0
- package/src/effect/memo-map.ts +3 -0
- package/src/effect/observability.ts +107 -0
- package/src/effect/run-service.ts +52 -0
- package/src/effect/runner.ts +210 -0
- package/src/effect/runtime.ts +19 -0
- package/src/env/index.ts +37 -0
- package/src/file/ignore.ts +81 -0
- package/src/file/index.ts +664 -0
- package/src/file/protected.ts +59 -0
- package/src/file/ripgrep.ts +485 -0
- package/src/file/watcher.ts +163 -0
- package/src/flag/flag.ts +164 -0
- package/src/format/formatter.ts +403 -0
- package/src/format/index.ts +203 -0
- package/src/git/index.ts +260 -0
- package/src/global/index.ts +54 -0
- package/src/history/backfill.ts +162 -0
- package/src/history/extract.ts +67 -0
- package/src/history/fts-query.ts +15 -0
- package/src/history/fts.sql.ts +20 -0
- package/src/history/index.ts +10 -0
- package/src/history/resolve.ts +65 -0
- package/src/history/service.ts +258 -0
- package/src/history/writer.ts +112 -0
- package/src/id/id.ts +87 -0
- package/src/ide/index.ts +73 -0
- package/src/inbox/inbox-ref.ts +38 -0
- package/src/inbox/inbox.sql.ts +26 -0
- package/src/inbox/inbox.ts +223 -0
- package/src/inbox/index.ts +3 -0
- package/src/inbox/render.ts +40 -0
- package/src/index.ts +260 -0
- package/src/installation/index.ts +351 -0
- package/src/installation/version.ts +8 -0
- package/src/lsp/client.ts +249 -0
- package/src/lsp/diagnostic.ts +29 -0
- package/src/lsp/index.ts +3 -0
- package/src/lsp/language.ts +120 -0
- package/src/lsp/launch.ts +21 -0
- package/src/lsp/lsp.ts +519 -0
- package/src/lsp/server.ts +1956 -0
- package/src/mcp/auth.ts +144 -0
- package/src/mcp/index.ts +944 -0
- package/src/mcp/oauth-callback.ts +232 -0
- package/src/mcp/oauth-provider.ts +214 -0
- package/src/memory/fts-query.ts +37 -0
- package/src/memory/fts.sql.ts +19 -0
- package/src/memory/index.ts +1 -0
- package/src/memory/paths.ts +116 -0
- package/src/memory/reconcile.ts +144 -0
- package/src/memory/service.ts +144 -0
- package/src/metrics/client.ts +40 -0
- package/src/metrics/event.ts +43 -0
- package/src/metrics/index.ts +5 -0
- package/src/metrics/installation.ts +18 -0
- package/src/metrics/subscriber.ts +58 -0
- package/src/metrics/util.ts +9 -0
- package/src/node.ts +6 -0
- package/src/npm/config.ts +0 -0
- package/src/npm/index.ts +293 -0
- package/src/npmcli-config.d.ts +43 -0
- package/src/patch/index.ts +680 -0
- package/src/permission/arity.ts +163 -0
- package/src/permission/evaluate.ts +15 -0
- package/src/permission/index.ts +379 -0
- package/src/permission/schema.ts +17 -0
- package/src/plugin/checkpoint-splitover.ts +60 -0
- package/src/plugin/cloud-ai.ts +329 -0
- package/src/plugin/cloudflare.ts +76 -0
- package/src/plugin/codex.ts +607 -0
- package/src/plugin/github-copilot/copilot.ts +368 -0
- package/src/plugin/github-copilot/models.ts +153 -0
- package/src/plugin/index.ts +493 -0
- package/src/plugin/install.ts +439 -0
- package/src/plugin/loader.ts +216 -0
- package/src/plugin/matcher.ts +33 -0
- package/src/plugin/meta.ts +188 -0
- package/src/plugin/mimo-free.ts +153 -0
- package/src/plugin/mimo.ts +124 -0
- package/src/plugin/shared.ts +323 -0
- package/src/plugin/subagent-progress-checker.ts +147 -0
- package/src/project/bootstrap.ts +59 -0
- package/src/project/index.ts +2 -0
- package/src/project/instance.ts +190 -0
- package/src/project/project-id.ts +48 -0
- package/src/project/project.sql.ts +16 -0
- package/src/project/project.ts +501 -0
- package/src/project/schema.ts +15 -0
- package/src/project/vcs.ts +227 -0
- package/src/provider/auth.ts +234 -0
- package/src/provider/error.ts +216 -0
- package/src/provider/index.ts +5 -0
- package/src/provider/models.ts +180 -0
- package/src/provider/provider.ts +1782 -0
- package/src/provider/schema.ts +36 -0
- package/src/provider/sdk/copilot/README.md +5 -0
- package/src/provider/sdk/copilot/chat/convert-to-openai-compatible-chat-messages.ts +170 -0
- package/src/provider/sdk/copilot/chat/get-response-metadata.ts +15 -0
- package/src/provider/sdk/copilot/chat/map-openai-compatible-finish-reason.ts +19 -0
- package/src/provider/sdk/copilot/chat/openai-compatible-api-types.ts +64 -0
- package/src/provider/sdk/copilot/chat/openai-compatible-chat-language-model.ts +815 -0
- package/src/provider/sdk/copilot/chat/openai-compatible-chat-options.ts +28 -0
- package/src/provider/sdk/copilot/chat/openai-compatible-metadata-extractor.ts +44 -0
- package/src/provider/sdk/copilot/chat/openai-compatible-prepare-tools.ts +83 -0
- package/src/provider/sdk/copilot/copilot-provider.ts +100 -0
- package/src/provider/sdk/copilot/index.ts +2 -0
- package/src/provider/sdk/copilot/openai-compatible-error.ts +27 -0
- package/src/provider/sdk/copilot/responses/convert-to-openai-responses-input.ts +335 -0
- package/src/provider/sdk/copilot/responses/map-openai-responses-finish-reason.ts +22 -0
- package/src/provider/sdk/copilot/responses/openai-config.ts +18 -0
- package/src/provider/sdk/copilot/responses/openai-error.ts +22 -0
- package/src/provider/sdk/copilot/responses/openai-responses-api-types.ts +214 -0
- package/src/provider/sdk/copilot/responses/openai-responses-language-model.ts +1770 -0
- package/src/provider/sdk/copilot/responses/openai-responses-prepare-tools.ts +173 -0
- package/src/provider/sdk/copilot/responses/openai-responses-settings.ts +1 -0
- package/src/provider/sdk/copilot/responses/tool/code-interpreter.ts +87 -0
- package/src/provider/sdk/copilot/responses/tool/file-search.ts +127 -0
- package/src/provider/sdk/copilot/responses/tool/image-generation.ts +114 -0
- package/src/provider/sdk/copilot/responses/tool/local-shell.ts +64 -0
- package/src/provider/sdk/copilot/responses/tool/web-search-preview.ts +103 -0
- package/src/provider/sdk/copilot/responses/tool/web-search.ts +102 -0
- package/src/provider/transform.ts +1322 -0
- package/src/pty/index.ts +364 -0
- package/src/pty/pty.bun.ts +26 -0
- package/src/pty/pty.node.ts +27 -0
- package/src/pty/pty.ts +25 -0
- package/src/pty/schema.ts +17 -0
- package/src/question/index.ts +252 -0
- package/src/question/schema.ts +17 -0
- package/src/server/adapter.bun.ts +40 -0
- package/src/server/adapter.node.ts +66 -0
- package/src/server/adapter.ts +21 -0
- package/src/server/error.ts +53 -0
- package/src/server/event.ts +7 -0
- package/src/server/fence.ts +81 -0
- package/src/server/mdns.ts +60 -0
- package/src/server/middleware.ts +92 -0
- package/src/server/projectors.ts +28 -0
- package/src/server/proxy.ts +171 -0
- package/src/server/routes/control/index.ts +160 -0
- package/src/server/routes/control/workspace.ts +203 -0
- package/src/server/routes/global.ts +287 -0
- package/src/server/routes/instance/bash-interactive.ts +82 -0
- package/src/server/routes/instance/config.ts +89 -0
- package/src/server/routes/instance/event.ts +88 -0
- package/src/server/routes/instance/experimental.ts +408 -0
- package/src/server/routes/instance/file.ts +190 -0
- package/src/server/routes/instance/httpapi/config.ts +51 -0
- package/src/server/routes/instance/httpapi/permission.ts +72 -0
- package/src/server/routes/instance/httpapi/project.ts +62 -0
- package/src/server/routes/instance/httpapi/provider.ts +142 -0
- package/src/server/routes/instance/httpapi/question.ts +121 -0
- package/src/server/routes/instance/httpapi/server.ts +136 -0
- package/src/server/routes/instance/index.ts +301 -0
- package/src/server/routes/instance/mcp.ts +260 -0
- package/src/server/routes/instance/middleware.ts +35 -0
- package/src/server/routes/instance/permission.ts +73 -0
- package/src/server/routes/instance/project.ts +122 -0
- package/src/server/routes/instance/provider.ts +158 -0
- package/src/server/routes/instance/pty.ts +247 -0
- package/src/server/routes/instance/question.ts +162 -0
- package/src/server/routes/instance/session.ts +1296 -0
- package/src/server/routes/instance/sync.ts +143 -0
- package/src/server/routes/instance/trace.ts +59 -0
- package/src/server/routes/instance/tui.ts +384 -0
- package/src/server/routes/instance/workflows.ts +72 -0
- package/src/server/routes/ui.ts +55 -0
- package/src/server/server.ts +136 -0
- package/src/server/workspace.ts +122 -0
- package/src/session/auto-dream.ts +123 -0
- package/src/session/boundary.ts +77 -0
- package/src/session/budgeted-read.ts +118 -0
- package/src/session/checkpoint-align.ts +29 -0
- package/src/session/checkpoint-context.ts +36 -0
- package/src/session/checkpoint-paths.ts +86 -0
- package/src/session/checkpoint-progress-reconcile.ts +111 -0
- package/src/session/checkpoint-retry.ts +192 -0
- package/src/session/checkpoint-templates.ts +114 -0
- package/src/session/checkpoint-validator.ts +259 -0
- package/src/session/checkpoint.ts +1478 -0
- package/src/session/classify.ts +92 -0
- package/src/session/claude-import.sql.ts +13 -0
- package/src/session/claude-import.ts +379 -0
- package/src/session/compaction.ts +543 -0
- package/src/session/goal.ts +232 -0
- package/src/session/index.ts +1 -0
- package/src/session/instruction.ts +276 -0
- package/src/session/last-message-info.ts +32 -0
- package/src/session/llm-request-prefix.ts +82 -0
- package/src/session/llm.ts +735 -0
- package/src/session/max-mode.ts +397 -0
- package/src/session/message-v2.ts +1136 -0
- package/src/session/message.ts +191 -0
- package/src/session/overflow.ts +53 -0
- package/src/session/prefix-capture-ref.ts +48 -0
- package/src/session/processor.ts +962 -0
- package/src/session/projectors.ts +137 -0
- package/src/session/prompt/anthropic.txt +154 -0
- package/src/session/prompt/beast.txt +155 -0
- package/src/session/prompt/build-switch.txt +5 -0
- package/src/session/prompt/codex.txt +79 -0
- package/src/session/prompt/compose.txt +115 -0
- package/src/session/prompt/copilot-gpt-5.txt +143 -0
- package/src/session/prompt/default.txt +151 -0
- package/src/session/prompt/gemini.txt +155 -0
- package/src/session/prompt/gpt.txt +107 -0
- package/src/session/prompt/kimi.txt +95 -0
- package/src/session/prompt/max-steps.txt +16 -0
- package/src/session/prompt/trinity.txt +97 -0
- package/src/session/prompt.ts +3355 -0
- package/src/session/prune.ts +481 -0
- package/src/session/retry.ts +166 -0
- package/src/session/revert.ts +161 -0
- package/src/session/run-state.ts +135 -0
- package/src/session/schema.ts +36 -0
- package/src/session/session.sql.ts +110 -0
- package/src/session/session.ts +908 -0
- package/src/session/status.ts +89 -0
- package/src/session/summary.ts +163 -0
- package/src/session/system.ts +86 -0
- package/src/session/todo.ts +77 -0
- package/src/share/index.ts +2 -0
- package/src/share/session.ts +57 -0
- package/src/share/share-next.ts +381 -0
- package/src/share/share.sql.ts +13 -0
- package/src/shell/shell.ts +110 -0
- package/src/skill/compose/.bundle/ask/SKILL.md +58 -0
- package/src/skill/compose/.bundle/brainstorm/SKILL.md +220 -0
- package/src/skill/compose/.bundle/brainstorm/scripts/frame-template.html +214 -0
- package/src/skill/compose/.bundle/brainstorm/scripts/helper.js +88 -0
- package/src/skill/compose/.bundle/brainstorm/scripts/server.cjs +354 -0
- package/src/skill/compose/.bundle/brainstorm/scripts/start-server.sh +148 -0
- package/src/skill/compose/.bundle/brainstorm/scripts/stop-server.sh +56 -0
- package/src/skill/compose/.bundle/brainstorm/spec-document-reviewer-prompt.md +50 -0
- package/src/skill/compose/.bundle/brainstorm/visual-companion.md +287 -0
- package/src/skill/compose/.bundle/debug/CREATION-LOG.md +119 -0
- package/src/skill/compose/.bundle/debug/SKILL.md +297 -0
- package/src/skill/compose/.bundle/debug/condition-based-waiting-example.ts +158 -0
- package/src/skill/compose/.bundle/debug/condition-based-waiting.md +115 -0
- package/src/skill/compose/.bundle/debug/defense-in-depth.md +122 -0
- package/src/skill/compose/.bundle/debug/find-polluter.sh +63 -0
- package/src/skill/compose/.bundle/debug/root-cause-tracing.md +169 -0
- package/src/skill/compose/.bundle/debug/test-academic.md +14 -0
- package/src/skill/compose/.bundle/debug/test-pressure-1.md +58 -0
- package/src/skill/compose/.bundle/debug/test-pressure-2.md +68 -0
- package/src/skill/compose/.bundle/debug/test-pressure-3.md +69 -0
- package/src/skill/compose/.bundle/execute/SKILL.md +71 -0
- package/src/skill/compose/.bundle/feedback/SKILL.md +214 -0
- package/src/skill/compose/.bundle/merge/SKILL.md +252 -0
- package/src/skill/compose/.bundle/new-skill/SKILL.md +656 -0
- package/src/skill/compose/.bundle/new-skill/anthropic-best-practices.md +1150 -0
- package/src/skill/compose/.bundle/new-skill/examples/CLAUDE_MD_TESTING.md +189 -0
- package/src/skill/compose/.bundle/new-skill/graphviz-conventions.dot +172 -0
- package/src/skill/compose/.bundle/new-skill/persuasion-principles.md +187 -0
- package/src/skill/compose/.bundle/new-skill/render-graphs.js +168 -0
- package/src/skill/compose/.bundle/new-skill/testing-skills-with-subagents.md +384 -0
- package/src/skill/compose/.bundle/parallel/SKILL.md +182 -0
- package/src/skill/compose/.bundle/plan/SKILL.md +161 -0
- package/src/skill/compose/.bundle/plan/plan-document-reviewer-prompt.md +50 -0
- package/src/skill/compose/.bundle/report/SKILL.md +180 -0
- package/src/skill/compose/.bundle/review/SKILL.md +104 -0
- package/src/skill/compose/.bundle/review/code-reviewer.md +171 -0
- package/src/skill/compose/.bundle/subagent/SKILL.md +344 -0
- package/src/skill/compose/.bundle/subagent/code-quality-reviewer-prompt.md +24 -0
- package/src/skill/compose/.bundle/subagent/implementer-prompt.md +126 -0
- package/src/skill/compose/.bundle/subagent/spec-reviewer-prompt.md +112 -0
- package/src/skill/compose/.bundle/tdd/SKILL.md +372 -0
- package/src/skill/compose/.bundle/tdd/testing-anti-patterns.md +299 -0
- package/src/skill/compose/.bundle/verify/SKILL.md +140 -0
- package/src/skill/compose/.bundle/worktree/SKILL.md +234 -0
- package/src/skill/compose/LICENSE-karpathy +28 -0
- package/src/skill/compose/LICENSE-superpowers +26 -0
- package/src/skill/compose/bundle.macro.ts +30 -0
- package/src/skill/compose/extract.ts +85 -0
- package/src/skill/discovery.ts +116 -0
- package/src/skill/index.ts +311 -0
- package/src/snapshot/index.ts +777 -0
- package/src/sql.d.ts +4 -0
- package/src/storage/db.bun.ts +8 -0
- package/src/storage/db.node.ts +8 -0
- package/src/storage/db.ts +172 -0
- package/src/storage/index.ts +26 -0
- package/src/storage/json-migration.ts +426 -0
- package/src/storage/schema.sql.ts +10 -0
- package/src/storage/schema.ts +7 -0
- package/src/storage/storage.ts +331 -0
- package/src/sync/README.md +179 -0
- package/src/sync/event.sql.ts +16 -0
- package/src/sync/index.ts +278 -0
- package/src/sync/schema.ts +14 -0
- package/src/task/events.ts +28 -0
- package/src/task/gate-state.ts +54 -0
- package/src/task/gate.ts +116 -0
- package/src/task/index.ts +1 -0
- package/src/task/registry.ts +387 -0
- package/src/task/schema.ts +43 -0
- package/src/task/task.sql.ts +50 -0
- package/src/team/events.ts +22 -0
- package/src/team/index.ts +113 -0
- package/src/team/schema.ts +31 -0
- package/src/temporary.ts +33 -0
- package/src/tool/actor.shell.txt +72 -0
- package/src/tool/actor.ts +803 -0
- package/src/tool/actor.txt +103 -0
- package/src/tool/apply_patch.ts +308 -0
- package/src/tool/apply_patch.txt +33 -0
- package/src/tool/bash-interactive.ts +183 -0
- package/src/tool/bash.ts +696 -0
- package/src/tool/bash.txt +123 -0
- package/src/tool/change-directory.ts +91 -0
- package/src/tool/codesearch.ts +63 -0
- package/src/tool/codesearch.txt +12 -0
- package/src/tool/edit.ts +685 -0
- package/src/tool/edit.txt +10 -0
- package/src/tool/external-directory.ts +132 -0
- package/src/tool/glob.ts +100 -0
- package/src/tool/glob.txt +6 -0
- package/src/tool/grep.ts +145 -0
- package/src/tool/grep.txt +8 -0
- package/src/tool/history.ts +146 -0
- package/src/tool/history.txt +17 -0
- package/src/tool/index.ts +4 -0
- package/src/tool/invalid.ts +20 -0
- package/src/tool/invocation-style.ts +17 -0
- package/src/tool/lsp.ts +91 -0
- package/src/tool/lsp.txt +19 -0
- package/src/tool/mcp-exa.ts +78 -0
- package/src/tool/memory-path-guard.ts +162 -0
- package/src/tool/memory.ts +81 -0
- package/src/tool/memory.txt +69 -0
- package/src/tool/multiedit.ts +61 -0
- package/src/tool/multiedit.txt +41 -0
- package/src/tool/plan-enter.txt +14 -0
- package/src/tool/plan-exit.txt +13 -0
- package/src/tool/plan.ts +90 -0
- package/src/tool/question.ts +67 -0
- package/src/tool/question.txt +10 -0
- package/src/tool/read.ts +327 -0
- package/src/tool/read.txt +14 -0
- package/src/tool/registry.ts +413 -0
- package/src/tool/schema.ts +17 -0
- package/src/tool/session-cwd.ts +35 -0
- package/src/tool/shell-tokenize.ts +346 -0
- package/src/tool/shell-wrap.ts +190 -0
- package/src/tool/skill.ts +76 -0
- package/src/tool/skill.txt +5 -0
- package/src/tool/task.shell.txt +57 -0
- package/src/tool/task.ts +456 -0
- package/src/tool/task.txt +56 -0
- package/src/tool/tool.ts +153 -0
- package/src/tool/truncate.ts +201 -0
- package/src/tool/truncation-dir.ts +4 -0
- package/src/tool/webfetch.ts +199 -0
- package/src/tool/webfetch.txt +13 -0
- package/src/tool/websearch/index.ts +104 -0
- package/src/tool/websearch/mimo.ts +118 -0
- package/src/tool/websearch/websearch.txt +14 -0
- package/src/tool/workflow.ts +164 -0
- package/src/tool/workflow.txt +25 -0
- package/src/tool/write.ts +88 -0
- package/src/tool/write.txt +9 -0
- package/src/util/abort.ts +35 -0
- package/src/util/archive.ts +15 -0
- package/src/util/color.ts +17 -0
- package/src/util/data-url.ts +9 -0
- package/src/util/defer.ts +10 -0
- package/src/util/effect-http-client.ts +11 -0
- package/src/util/effect-zod.ts +367 -0
- package/src/util/error.ts +78 -0
- package/src/util/filesystem.ts +243 -0
- package/src/util/fn.ts +21 -0
- package/src/util/format.ts +20 -0
- package/src/util/iife.ts +3 -0
- package/src/util/index.ts +12 -0
- package/src/util/keybind.ts +101 -0
- package/src/util/lazy.ts +18 -0
- package/src/util/local-context.ts +23 -0
- package/src/util/locale.ts +79 -0
- package/src/util/lock.ts +96 -0
- package/src/util/log.ts +197 -0
- package/src/util/media.ts +26 -0
- package/src/util/mimo-process.ts +24 -0
- package/src/util/network.ts +9 -0
- package/src/util/process.ts +174 -0
- package/src/util/queue.ts +32 -0
- package/src/util/record.ts +3 -0
- package/src/util/rpc.ts +64 -0
- package/src/util/schema.ts +53 -0
- package/src/util/scrap.ts +10 -0
- package/src/util/signal.ts +12 -0
- package/src/util/timeout.ts +14 -0
- package/src/util/token.ts +5 -0
- package/src/util/update-schema.ts +13 -0
- package/src/util/which.ts +14 -0
- package/src/util/wildcard.ts +57 -0
- package/src/workflow/builtin/deep-research.js +391 -0
- package/src/workflow/builtin.ts +54 -0
- package/src/workflow/events.ts +72 -0
- package/src/workflow/meta.ts +335 -0
- package/src/workflow/persistence.ts +312 -0
- package/src/workflow/resolve.ts +45 -0
- package/src/workflow/runtime-ref.ts +18 -0
- package/src/workflow/runtime.ts +1234 -0
- package/src/workflow/sandbox.ts +280 -0
- package/src/workflow/workflow.sql.ts +31 -0
- package/src/workflow/workspace.ts +69 -0
- package/src/worktree/index.ts +614 -0
- package/sst-env.d.ts +10 -0
- package/test/AGENTS.md +133 -0
- package/test/account/repo.test.ts +352 -0
- package/test/account/service.test.ts +456 -0
- package/test/acp/agent-interface.test.ts +51 -0
- package/test/acp/event-subscription.test.ts +725 -0
- package/test/actor/cancel-cascade.test.ts +432 -0
- package/test/actor/no-completion-listener.test.ts +41 -0
- package/test/actor/poststop-progress-write-permission.repro.test.ts +414 -0
- package/test/actor/registry-render.test.ts +113 -0
- package/test/actor/registry-status.test.ts +111 -0
- package/test/actor/registry.test.ts +619 -0
- package/test/actor/return-header.test.ts +40 -0
- package/test/actor/spawn-lifecycle.test.ts +346 -0
- package/test/actor/spawn-no-deadlock.test.ts +340 -0
- package/test/actor/spawn-notification.test.ts +393 -0
- package/test/actor/spawn-task-autostart.test.ts +530 -0
- package/test/actor/spawn.test.ts +1072 -0
- package/test/actor/status-event-payload.test.ts +132 -0
- package/test/actor/terminology.test.ts +39 -0
- package/test/actor/turn.test.ts +125 -0
- package/test/actor/waiter.test.ts +246 -0
- package/test/agent/agent.test.ts +874 -0
- package/test/agent/allowlist.test.ts +45 -0
- package/test/auth/auth.test.ts +86 -0
- package/test/bus/bus-effect.test.ts +162 -0
- package/test/bus/bus-integration.test.ts +87 -0
- package/test/bus/bus.test.ts +219 -0
- package/test/cli/account.test.ts +26 -0
- package/test/cli/cmd/tui/prompt-part.test.ts +47 -0
- package/test/cli/error.test.ts +18 -0
- package/test/cli/github-action.test.ts +198 -0
- package/test/cli/github-remote.test.ts +80 -0
- package/test/cli/import.test.ts +54 -0
- package/test/cli/plugin-auth-picker.test.ts +120 -0
- package/test/cli/run-completion.test.ts +131 -0
- package/test/cli/tui/keybind-plugin.test.ts +90 -0
- package/test/cli/tui/plugin-add.test.ts +111 -0
- package/test/cli/tui/plugin-install.test.ts +87 -0
- package/test/cli/tui/plugin-lifecycle.test.ts +224 -0
- package/test/cli/tui/plugin-loader-entrypoint.test.ts +484 -0
- package/test/cli/tui/plugin-loader-pure.test.ts +71 -0
- package/test/cli/tui/plugin-loader.test.ts +816 -0
- package/test/cli/tui/plugin-toggle.test.ts +157 -0
- package/test/cli/tui/revert-diff.test.ts +35 -0
- package/test/cli/tui/route-agent-id.test.ts +26 -0
- package/test/cli/tui/sidebar-tps.test.ts +63 -0
- package/test/cli/tui/slot-replace.test.tsx +47 -0
- package/test/cli/tui/sync-bucket.test.ts +29 -0
- package/test/cli/tui/theme-store.test.ts +51 -0
- package/test/cli/tui/thread.test.ts +121 -0
- package/test/cli/tui/transcript.test.ts +426 -0
- package/test/cli/tui/use-event.test.tsx +175 -0
- package/test/cli/tui/voice.test.ts +269 -0
- package/test/command/deep-research-command.test.ts +16 -0
- package/test/config/agent-color.test.ts +77 -0
- package/test/config/checkpoint-fork.test.ts +21 -0
- package/test/config/config.test.ts +2577 -0
- package/test/config/fixtures/empty-frontmatter.md +4 -0
- package/test/config/fixtures/frontmatter.md +28 -0
- package/test/config/fixtures/markdown-header.md +11 -0
- package/test/config/fixtures/no-frontmatter.md +1 -0
- package/test/config/fixtures/weird-model-id.md +13 -0
- package/test/config/lsp.test.ts +87 -0
- package/test/config/markdown.test.ts +228 -0
- package/test/config/plugin.test.ts +0 -0
- package/test/config/tui.test.ts +627 -0
- package/test/control-plane/adaptors.test.ts +71 -0
- package/test/control-plane/sse.test.ts +56 -0
- package/test/effect/app-runtime-logger.test.ts +92 -0
- package/test/effect/cross-spawn-spawner.test.ts +411 -0
- package/test/effect/instance-state.test.ts +482 -0
- package/test/effect/observability.test.ts +46 -0
- package/test/effect/run-service.test.ts +46 -0
- package/test/effect/runner-warn-log.test.ts +111 -0
- package/test/effect/runner.test.ts +494 -0
- package/test/fake/provider.ts +90 -0
- package/test/file/fsmonitor.test.ts +68 -0
- package/test/file/ignore.test.ts +10 -0
- package/test/file/index.test.ts +956 -0
- package/test/file/path-traversal.test.ts +204 -0
- package/test/file/ripgrep.test.ts +214 -0
- package/test/file/watcher.test.ts +249 -0
- package/test/filesystem/filesystem.test.ts +319 -0
- package/test/fixture/db.ts +11 -0
- package/test/fixture/fixture.test.ts +58 -0
- package/test/fixture/fixture.ts +190 -0
- package/test/fixture/flock-worker.ts +72 -0
- package/test/fixture/lsp/fake-lsp-server.js +75 -0
- package/test/fixture/plug-worker.ts +93 -0
- package/test/fixture/plugin-meta-worker.ts +19 -0
- package/test/fixture/skills/agents-sdk/SKILL.md +152 -0
- package/test/fixture/skills/agents-sdk/references/callable.md +92 -0
- package/test/fixture/skills/cloudflare/SKILL.md +211 -0
- package/test/fixture/skills/index.json +6 -0
- package/test/fixture/tui-plugin.ts +328 -0
- package/test/fixture/tui-runtime.ts +31 -0
- package/test/format/format.test.ts +244 -0
- package/test/git/git.test.ts +128 -0
- package/test/global/fixture/global-paths-worker.ts +17 -0
- package/test/global/mimocode-home.test.ts +143 -0
- package/test/history/backfill.test.ts +149 -0
- package/test/history/extract.test.ts +106 -0
- package/test/history/fts-query.test.ts +30 -0
- package/test/history/resolve.test.ts +130 -0
- package/test/history/service.test.ts +210 -0
- package/test/history/writer.test.ts +163 -0
- package/test/ide/ide.test.ts +82 -0
- package/test/inbox/drain-in-loop.test.ts +230 -0
- package/test/inbox/fork-agent-compat.test.ts +387 -0
- package/test/inbox/gc-on-init.test.ts +167 -0
- package/test/inbox/send-no-block.test.ts +120 -0
- package/test/inbox/sender-cancel-independence.test.ts +160 -0
- package/test/inbox/wake-matrix.test.ts +141 -0
- package/test/installation/installation.test.ts +226 -0
- package/test/keybind.test.ts +421 -0
- package/test/lib/effect.ts +53 -0
- package/test/lib/filesystem.ts +10 -0
- package/test/lib/llm-server.ts +770 -0
- package/test/lib/scripted-llm-server.ts +245 -0
- package/test/lsp/client.test.ts +98 -0
- package/test/lsp/index.test.ts +109 -0
- package/test/lsp/launch.test.ts +22 -0
- package/test/lsp/lifecycle.test.ts +184 -0
- package/test/mcp/headers.test.ts +178 -0
- package/test/mcp/lifecycle.test.ts +824 -0
- package/test/mcp/oauth-auto-connect.test.ts +281 -0
- package/test/mcp/oauth-browser.test.ts +268 -0
- package/test/mcp/oauth-callback.test.ts +34 -0
- package/test/memory/abort-leak-webfetch.ts +49 -0
- package/test/memory/abort-leak.test.ts +127 -0
- package/test/memory/cc-frontmatter.test.ts +85 -0
- package/test/memory/cc-paths.test.ts +60 -0
- package/test/memory/cc-reconcile.test.ts +239 -0
- package/test/memory/cc-search.test.ts +151 -0
- package/test/memory/fts-query.test.ts +48 -0
- package/test/memory/fts-rowid-stability.test.ts +271 -0
- package/test/memory/paths.test.ts +210 -0
- package/test/memory/reconcile.test.ts +115 -0
- package/test/memory/service.test.ts +169 -0
- package/test/npm.test.ts +18 -0
- package/test/patch/patch.test.ts +348 -0
- package/test/permission/abort.test.ts +116 -0
- package/test/permission/arity.test.ts +33 -0
- package/test/permission/disabled.test.ts +51 -0
- package/test/permission/next.test.ts +1080 -0
- package/test/permission/non-interactive.test.ts +55 -0
- package/test/permission-task.test.ts +326 -0
- package/test/plugin/actor-hooks.test.ts +1471 -0
- package/test/plugin/auth-override.test.ts +79 -0
- package/test/plugin/checkpoint-splitover.test.ts +434 -0
- package/test/plugin/cloudflare.test.ts +68 -0
- package/test/plugin/codex.test.ts +123 -0
- package/test/plugin/github-copilot-models.test.ts +163 -0
- package/test/plugin/install-concurrency.test.ts +140 -0
- package/test/plugin/install.test.ts +570 -0
- package/test/plugin/loader-shared.test.ts +1169 -0
- package/test/plugin/matcher.test.ts +97 -0
- package/test/plugin/meta.test.ts +137 -0
- package/test/plugin/mimo.test.ts +257 -0
- package/test/plugin/shared.test.ts +88 -0
- package/test/plugin/subagent-progress-checker.test.ts +227 -0
- package/test/plugin/trigger.test.ts +116 -0
- package/test/plugin/workspace-adaptor.test.ts +109 -0
- package/test/preload.ts +102 -0
- package/test/project/migrate-global.test.ts +150 -0
- package/test/project/project-id.test.ts +64 -0
- package/test/project/project.test.ts +481 -0
- package/test/project/vcs.test.ts +286 -0
- package/test/project/worktree-remove.test.ts +126 -0
- package/test/project/worktree.test.ts +214 -0
- package/test/provider/amazon-bedrock.test.ts +462 -0
- package/test/provider/copilot/convert-to-copilot-messages.test.ts +523 -0
- package/test/provider/copilot/copilot-chat-model.test.ts +592 -0
- package/test/provider/error.test.ts +160 -0
- package/test/provider/gitlab-duo.test.ts +413 -0
- package/test/provider/model-groups.test.ts +389 -0
- package/test/provider/provider-chunk-timeout.test.ts +23 -0
- package/test/provider/provider.test.ts +2648 -0
- package/test/provider/transform.test.ts +3379 -0
- package/test/pty/pty-output-isolation.test.ts +146 -0
- package/test/pty/pty-session.test.ts +102 -0
- package/test/pty/pty-shell.test.ts +69 -0
- package/test/question/question.test.ts +464 -0
- package/test/server/global-session-list.test.ts +105 -0
- package/test/server/project-init-git.test.ts +122 -0
- package/test/server/session-actions.test.ts +49 -0
- package/test/server/session-list.test.ts +110 -0
- package/test/server/session-messages.test.ts +220 -0
- package/test/server/session-prompt-busy.test.ts +146 -0
- package/test/server/session-select.test.ts +100 -0
- package/test/server/session-task-route.test.ts +165 -0
- package/test/server/summarize-route-main-slice.test.ts +99 -0
- package/test/server/trace-attributes.test.ts +76 -0
- package/test/server/workflows-route.test.ts +279 -0
- package/test/session/bootstrap-skip-system.test.ts +121 -0
- package/test/session/boundary.test.ts +33 -0
- package/test/session/budgeted-read.test.ts +74 -0
- package/test/session/checkpoint-align.test.ts +58 -0
- package/test/session/checkpoint-boundary.test.ts +186 -0
- package/test/session/checkpoint-child-session.test.ts +508 -0
- package/test/session/checkpoint-context.test.ts +141 -0
- package/test/session/checkpoint-drain.test.ts +188 -0
- package/test/session/checkpoint-extract-titles.test.ts +58 -0
- package/test/session/checkpoint-fork-mode.test.ts +576 -0
- package/test/session/checkpoint-main-slice.test.ts +259 -0
- package/test/session/checkpoint-paths.test.ts +78 -0
- package/test/session/checkpoint-permission.test.ts +136 -0
- package/test/session/checkpoint-progress-reconcile.test.ts +219 -0
- package/test/session/checkpoint-rebuild-unify.test.ts +143 -0
- package/test/session/checkpoint-rebuild-v3.test.ts +248 -0
- package/test/session/checkpoint-render-verify.test.ts +512 -0
- package/test/session/checkpoint-retry.test.ts +150 -0
- package/test/session/checkpoint-splitover-integration.test.ts +533 -0
- package/test/session/checkpoint-templates.test.ts +51 -0
- package/test/session/checkpoint-thresholds.test.ts +120 -0
- package/test/session/checkpoint-validator.test.ts +189 -0
- package/test/session/classify-integration.test.ts +476 -0
- package/test/session/classify.test.ts +335 -0
- package/test/session/compaction-agent-scope.test.ts +164 -0
- package/test/session/context-inheritance.test.ts +46 -0
- package/test/session/fork-prefix-invariant.test.ts +116 -0
- package/test/session/goal.test.ts +106 -0
- package/test/session/instruction.test.ts +387 -0
- package/test/session/invalid-output-continuation.test.ts +150 -0
- package/test/session/last-message-info.test.ts +47 -0
- package/test/session/length-tool-safety.test.ts +121 -0
- package/test/session/llm-request-prefix.test.ts +197 -0
- package/test/session/llm-retry.test.ts +59 -0
- package/test/session/llm-system-prompt.test.ts +479 -0
- package/test/session/llm.test.ts +1272 -0
- package/test/session/main-lifecycle.test.ts +51 -0
- package/test/session/main-runloop-history-invariant.test.ts +182 -0
- package/test/session/max-mode-econnreset.test.ts +229 -0
- package/test/session/max-mode.test.ts +54 -0
- package/test/session/message-v2-filter.test.ts +197 -0
- package/test/session/message-v2.test.ts +1119 -0
- package/test/session/messages-default-main.test.ts +105 -0
- package/test/session/messages-pagination.test.ts +888 -0
- package/test/session/overflow.test.ts +576 -0
- package/test/session/processor-effect.test.ts +853 -0
- package/test/session/prompt-effect.test.ts +1574 -0
- package/test/session/prompt-rebuild-loop.test.ts +108 -0
- package/test/session/prompt-rebuild-reset.test.ts +67 -0
- package/test/session/prompt-sweep.test.ts +145 -0
- package/test/session/prompt-task-gate.test.ts +127 -0
- package/test/session/prompt.test.ts +703 -0
- package/test/session/prune-main-slice.test.ts +272 -0
- package/test/session/prune-skip-system.test.ts +346 -0
- package/test/session/prune.test.ts +419 -0
- package/test/session/rebuild-microcompact.test.ts +318 -0
- package/test/session/recall-reminder.test.ts +37 -0
- package/test/session/retry.test.ts +410 -0
- package/test/session/revert-compact.test.ts +639 -0
- package/test/session/run-state-tuple-key.test.ts +152 -0
- package/test/session/session-create-registers-main.test.ts +70 -0
- package/test/session/session.test.ts +181 -0
- package/test/session/snapshot-tool-race.test.ts +301 -0
- package/test/session/structured-output-integration.test.ts +264 -0
- package/test/session/structured-output-retry.test.ts +127 -0
- package/test/session/structured-output.test.ts +397 -0
- package/test/session/summary-main-slice.test.ts +170 -0
- package/test/session/system.test.ts +72 -0
- package/test/share/share-next.test.ts +332 -0
- package/test/shell/shell.test.ts +73 -0
- package/test/skill/compose-review.test.ts +141 -0
- package/test/skill/discovery.test.ts +116 -0
- package/test/skill/skill.test.ts +465 -0
- package/test/snapshot/snapshot.test.ts +1531 -0
- package/test/storage/db.test.ts +16 -0
- package/test/storage/json-migration.test.ts +831 -0
- package/test/storage/storage.test.ts +293 -0
- package/test/sync/index.test.ts +237 -0
- package/test/task/gate-state.test.ts +66 -0
- package/test/task/gate.test.ts +167 -0
- package/test/task/registry.test.ts +152 -0
- package/test/task/state-machine.test.ts +292 -0
- package/test/team/migrate-to-inbox.test.ts +124 -0
- package/test/team/team.test.ts +75 -0
- package/test/tool/__snapshots__/tool.test.ts.snap +9 -0
- package/test/tool/actor-cancel.test.ts +206 -0
- package/test/tool/actor-recover.test.ts +50 -0
- package/test/tool/actor-send.test.ts +200 -0
- package/test/tool/actor-status.test.ts +296 -0
- package/test/tool/actor-wait.test.ts +193 -0
- package/test/tool/actor.shell.test.ts +250 -0
- package/test/tool/actor.test.ts +748 -0
- package/test/tool/apply_patch.test.ts +626 -0
- package/test/tool/bash.test.ts +1195 -0
- package/test/tool/describe-workflow.test.ts +12 -0
- package/test/tool/edit.test.ts +691 -0
- package/test/tool/external-directory.test.ts +207 -0
- package/test/tool/fixtures/large-image.png +0 -0
- package/test/tool/fixtures/models-api.json +65179 -0
- package/test/tool/glob.test.ts +81 -0
- package/test/tool/grep.test.ts +114 -0
- package/test/tool/history.test.ts +144 -0
- package/test/tool/invocation-style.test.ts +30 -0
- package/test/tool/memory-edit-ask-skip.test.ts +62 -0
- package/test/tool/memory-path-guard.test.ts +594 -0
- package/test/tool/memory.test.ts +71 -0
- package/test/tool/question.test.ts +167 -0
- package/test/tool/read.test.ts +483 -0
- package/test/tool/registry-invocation-style.test.ts +121 -0
- package/test/tool/registry.test.ts +164 -0
- package/test/tool/shell-tokenize.test.ts +273 -0
- package/test/tool/shell-wrap-missing-script.test.ts +128 -0
- package/test/tool/shell-wrap.test.ts +257 -0
- package/test/tool/skill.test.ts +99 -0
- package/test/tool/task-recover.test.ts +36 -0
- package/test/tool/task.shell.test.ts +234 -0
- package/test/tool/task.test.ts +296 -0
- package/test/tool/tool-def-shell-shape.test.ts +23 -0
- package/test/tool/tool-define.test.ts +59 -0
- package/test/tool/truncation.test.ts +253 -0
- package/test/tool/webfetch.test.ts +103 -0
- package/test/tool/whitelist.test.ts +373 -0
- package/test/tool/write.test.ts +244 -0
- package/test/util/data-url.test.ts +14 -0
- package/test/util/effect-zod.test.ts +869 -0
- package/test/util/error.test.ts +38 -0
- package/test/util/filesystem.test.ts +656 -0
- package/test/util/format.test.ts +59 -0
- package/test/util/glob.test.ts +164 -0
- package/test/util/iife.test.ts +36 -0
- package/test/util/lazy.test.ts +50 -0
- package/test/util/lock.test.ts +72 -0
- package/test/util/log.test.ts +44 -0
- package/test/util/module.test.ts +59 -0
- package/test/util/process.test.ts +128 -0
- package/test/util/timeout.test.ts +21 -0
- package/test/util/which.test.ts +100 -0
- package/test/util/wildcard.test.ts +90 -0
- package/test/workflow/builtin.test.ts +22 -0
- package/test/workflow/deep-research-cluster.test.ts +47 -0
- package/test/workflow/lib.ts +243 -0
- package/test/workflow/meta.test.ts +142 -0
- package/test/workflow/model-routing.test.ts +68 -0
- package/test/workflow/persistence.test.ts +229 -0
- package/test/workflow/resolve.test.ts +37 -0
- package/test/workflow/runtime-nested.test.ts +419 -0
- package/test/workflow/runtime-worktree.test.ts +261 -0
- package/test/workflow/runtime.test.ts +1078 -0
- package/test/workflow/sandbox.test.ts +259 -0
- package/test/workflow/tool.test.ts +473 -0
- package/test/workflow/verify-wow.test.ts +144 -0
- package/test/workflow/workspace.test.ts +88 -0
- package/test/workspace/workspace-restore.test.ts +281 -0
- package/test/worktree/index.test.ts +30 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,2532 @@
|
|
|
1
|
+
import {
|
|
2
|
+
batch,
|
|
3
|
+
createContext,
|
|
4
|
+
createEffect,
|
|
5
|
+
createMemo,
|
|
6
|
+
createSignal,
|
|
7
|
+
For,
|
|
8
|
+
Match,
|
|
9
|
+
on,
|
|
10
|
+
onCleanup,
|
|
11
|
+
onMount,
|
|
12
|
+
Show,
|
|
13
|
+
Switch,
|
|
14
|
+
useContext,
|
|
15
|
+
} from "solid-js"
|
|
16
|
+
import { Dynamic } from "solid-js/web"
|
|
17
|
+
import path from "path"
|
|
18
|
+
import { useCurrentAgentID, useRoute, useRouteData } from "@tui/context/route"
|
|
19
|
+
import { useProject } from "@tui/context/project"
|
|
20
|
+
import { useSync } from "@tui/context/sync"
|
|
21
|
+
import { useEvent } from "@tui/context/event"
|
|
22
|
+
import { SplitBorder } from "@tui/component/border"
|
|
23
|
+
import { Spinner } from "@tui/component/spinner"
|
|
24
|
+
import { selectedForeground, useTheme } from "@tui/context/theme"
|
|
25
|
+
import { BoxRenderable, ScrollBoxRenderable, addDefaultParsers, TextAttributes, RGBA, MouseEvent } from "@opentui/core"
|
|
26
|
+
import { Prompt, type PromptRef } from "@tui/component/prompt"
|
|
27
|
+
import type {
|
|
28
|
+
AssistantMessage,
|
|
29
|
+
Part,
|
|
30
|
+
Provider,
|
|
31
|
+
ToolPart,
|
|
32
|
+
UserMessage,
|
|
33
|
+
TextPart,
|
|
34
|
+
ReasoningPart,
|
|
35
|
+
} from "@tuling-ai/sdk/v2"
|
|
36
|
+
import { useLocal } from "@tui/context/local"
|
|
37
|
+
import { Locale } from "@/util"
|
|
38
|
+
import type { Tool } from "@/tool"
|
|
39
|
+
import type { ReadTool } from "@/tool/read"
|
|
40
|
+
import type { WriteTool } from "@/tool/write"
|
|
41
|
+
import { BashTool } from "@/tool/bash"
|
|
42
|
+
import type { GlobTool } from "@/tool/glob"
|
|
43
|
+
import type { GrepTool } from "@/tool/grep"
|
|
44
|
+
import type { EditTool } from "@/tool/edit"
|
|
45
|
+
import type { ApplyPatchTool } from "@/tool/apply_patch"
|
|
46
|
+
import type { WebFetchTool } from "@/tool/webfetch"
|
|
47
|
+
import type { CodeSearchTool } from "@/tool/codesearch"
|
|
48
|
+
import type { WebSearchTool } from "@/tool/websearch"
|
|
49
|
+
import type { ActorTool } from "@/tool/actor"
|
|
50
|
+
import type { TaskTool } from "@/tool/task"
|
|
51
|
+
import type { QuestionTool } from "@/tool/question"
|
|
52
|
+
import type { SkillTool } from "@/tool/skill"
|
|
53
|
+
import { useKeyboard, useRenderer, useTerminalDimensions, type JSX } from "@opentui/solid"
|
|
54
|
+
import { useSDK } from "@tui/context/sdk"
|
|
55
|
+
import { useCommandDialog } from "@tui/component/dialog-command"
|
|
56
|
+
import { useLanguage } from "@tui/context/language"
|
|
57
|
+
import type { DialogContext } from "@tui/ui/dialog"
|
|
58
|
+
import { useKeybind } from "@tui/context/keybind"
|
|
59
|
+
import { useDialog } from "../../ui/dialog"
|
|
60
|
+
import { DialogMessage } from "./dialog-message"
|
|
61
|
+
import type { PromptInfo } from "../../component/prompt/history"
|
|
62
|
+
import { DialogConfirm } from "@tui/ui/dialog-confirm"
|
|
63
|
+
import { DialogTimeline } from "./dialog-timeline"
|
|
64
|
+
import { DialogForkFromTimeline } from "./dialog-fork-from-timeline"
|
|
65
|
+
import { DialogSessionRename } from "../../component/dialog-session-rename"
|
|
66
|
+
import { Sidebar } from "./sidebar"
|
|
67
|
+
import { SubagentFooter } from "./subagent-footer.tsx"
|
|
68
|
+
import { DialogSubagent } from "./dialog-subagent.tsx"
|
|
69
|
+
import { Flag } from "@/flag/flag"
|
|
70
|
+
import { LANGUAGE_EXTENSIONS } from "@/lsp/language"
|
|
71
|
+
import parsers from "../../../../../../parsers-config.ts"
|
|
72
|
+
import * as Clipboard from "../../util/clipboard"
|
|
73
|
+
import { Toast, useToast } from "../../ui/toast"
|
|
74
|
+
import { useKV } from "../../context/kv.tsx"
|
|
75
|
+
import * as Editor from "../../util/editor"
|
|
76
|
+
import stripAnsi from "strip-ansi"
|
|
77
|
+
import { usePromptRef } from "../../context/prompt"
|
|
78
|
+
import { useExit } from "../../context/exit"
|
|
79
|
+
import { Filesystem } from "@/util"
|
|
80
|
+
import { Global } from "@/global"
|
|
81
|
+
import { PermissionPrompt } from "./permission"
|
|
82
|
+
import { QuestionPrompt } from "./question"
|
|
83
|
+
import { DialogExportOptions } from "../../ui/dialog-export-options"
|
|
84
|
+
import * as Model from "../../util/model"
|
|
85
|
+
import { formatTranscript } from "../../util/transcript"
|
|
86
|
+
import { UI } from "@/cli/ui.ts"
|
|
87
|
+
import { useTuiConfig } from "../../context/tui-config"
|
|
88
|
+
import { getScrollAcceleration } from "../../util/scroll"
|
|
89
|
+
import { nextThinkingMode, reasoningSummary, useThinkingMode, type ThinkingMode } from "../../context/thinking"
|
|
90
|
+
import { TuiPluginRuntime } from "../../plugin"
|
|
91
|
+
import { DialogGoUpsell } from "../../component/dialog-go-upsell"
|
|
92
|
+
import { SessionRetry } from "@/session/retry"
|
|
93
|
+
import { getRevertDiffFiles } from "../../util/revert-diff"
|
|
94
|
+
|
|
95
|
+
addDefaultParsers(parsers.parsers)
|
|
96
|
+
|
|
97
|
+
const GO_UPSELL_LAST_SEEN_AT = "go_upsell_last_seen_at"
|
|
98
|
+
const GO_UPSELL_DONT_SHOW = "go_upsell_dont_show"
|
|
99
|
+
const GO_UPSELL_WINDOW = 86_400_000 // 24 hrs
|
|
100
|
+
|
|
101
|
+
const context = createContext<{
|
|
102
|
+
width: number
|
|
103
|
+
sessionID: string
|
|
104
|
+
conceal: () => boolean
|
|
105
|
+
thinkingMode: () => ThinkingMode
|
|
106
|
+
showThinking: () => boolean
|
|
107
|
+
showTimestamps: () => boolean
|
|
108
|
+
showDetails: () => boolean
|
|
109
|
+
showGenericToolOutput: () => boolean
|
|
110
|
+
diffWrapMode: () => "word" | "none"
|
|
111
|
+
providers: () => ReadonlyMap<string, Provider>
|
|
112
|
+
sync: ReturnType<typeof useSync>
|
|
113
|
+
tui: ReturnType<typeof useTuiConfig>
|
|
114
|
+
}>()
|
|
115
|
+
|
|
116
|
+
function use() {
|
|
117
|
+
const ctx = useContext(context)
|
|
118
|
+
if (!ctx) throw new Error("useContext must be used within a Session component")
|
|
119
|
+
return ctx
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function Session() {
|
|
123
|
+
const route = useRouteData("session")
|
|
124
|
+
const fullRoute = useRoute()
|
|
125
|
+
const navigate = fullRoute.navigate
|
|
126
|
+
const sync = useSync()
|
|
127
|
+
const event = useEvent()
|
|
128
|
+
const project = useProject()
|
|
129
|
+
const tuiConfig = useTuiConfig()
|
|
130
|
+
const kv = useKV()
|
|
131
|
+
const { theme } = useTheme()
|
|
132
|
+
const promptRef = usePromptRef()
|
|
133
|
+
const session = createMemo(() => sync.session.get(route.sessionID))
|
|
134
|
+
const currentAgentID = useCurrentAgentID()
|
|
135
|
+
const actors = createMemo(() => sync.data.actor[route.sessionID] ?? [])
|
|
136
|
+
const messages = createMemo(() => sync.data.message[route.sessionID]?.[currentAgentID()] ?? [])
|
|
137
|
+
const permissions = createMemo(() => sync.data.permission[route.sessionID] ?? [])
|
|
138
|
+
const questions = createMemo(() => sync.data.question[route.sessionID] ?? [])
|
|
139
|
+
const visible = createMemo(
|
|
140
|
+
() =>
|
|
141
|
+
!session()?.parentID &&
|
|
142
|
+
currentAgentID() === "main" &&
|
|
143
|
+
permissions().length === 0 &&
|
|
144
|
+
questions().length === 0,
|
|
145
|
+
)
|
|
146
|
+
const disabled = createMemo(() => permissions().length > 0 || questions().length > 0)
|
|
147
|
+
|
|
148
|
+
const pending = createMemo(() => {
|
|
149
|
+
return messages().findLast((x) => x.role === "assistant" && !x.time.completed)?.id
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
const lastAssistant = createMemo(() => {
|
|
153
|
+
return messages().findLast((x) => x.role === "assistant")
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
const dimensions = useTerminalDimensions()
|
|
157
|
+
const [sidebar, setSidebar] = kv.signal<"auto" | "hide">("sidebar", "auto")
|
|
158
|
+
const [sidebarOpen, setSidebarOpen] = createSignal(false)
|
|
159
|
+
const [conceal, setConceal] = createSignal(true)
|
|
160
|
+
const thinking = useThinkingMode()
|
|
161
|
+
const thinkingMode = thinking.mode
|
|
162
|
+
const showThinking = createMemo(() => true)
|
|
163
|
+
const [timestamps, setTimestamps] = kv.signal<"hide" | "show">("timestamps", "hide")
|
|
164
|
+
const [showDetails, setShowDetails] = kv.signal("tool_details_visibility", true)
|
|
165
|
+
const [showAssistantMetadata, _setShowAssistantMetadata] = kv.signal("assistant_metadata_visibility", true)
|
|
166
|
+
const [showScrollbar, setShowScrollbar] = kv.signal("scrollbar_visible", false)
|
|
167
|
+
const [scrolling, setScrolling] = createSignal(false)
|
|
168
|
+
let scrollHideTimer: ReturnType<typeof setTimeout> | undefined
|
|
169
|
+
const scrollbarVisible = createMemo(() => showScrollbar() || scrolling())
|
|
170
|
+
const onWheel = (evt: MouseEvent) => {
|
|
171
|
+
if (evt.type !== "scroll") return
|
|
172
|
+
setScrolling(true)
|
|
173
|
+
if (scrollHideTimer) clearTimeout(scrollHideTimer)
|
|
174
|
+
scrollHideTimer = setTimeout(() => setScrolling(false), 1000)
|
|
175
|
+
}
|
|
176
|
+
onCleanup(() => {
|
|
177
|
+
if (scrollHideTimer) clearTimeout(scrollHideTimer)
|
|
178
|
+
})
|
|
179
|
+
const [diffWrapMode] = kv.signal<"word" | "none">("diff_wrap_mode", "word")
|
|
180
|
+
const [_animationsEnabled, _setAnimationsEnabled] = kv.signal("animations_enabled", true)
|
|
181
|
+
const [showGenericToolOutput, setShowGenericToolOutput] = kv.signal("generic_tool_output_visibility", false)
|
|
182
|
+
|
|
183
|
+
const wide = createMemo(() => dimensions().width > 120)
|
|
184
|
+
const sidebarVisible = createMemo(() => {
|
|
185
|
+
if (session()?.parentID) return false
|
|
186
|
+
if (currentAgentID() !== "main") return false
|
|
187
|
+
if (sidebarOpen()) return true
|
|
188
|
+
if (sidebar() === "auto" && wide()) return true
|
|
189
|
+
return false
|
|
190
|
+
})
|
|
191
|
+
const showTimestamps = createMemo(() => timestamps() === "show")
|
|
192
|
+
const contentWidth = createMemo(() => dimensions().width - (sidebarVisible() ? 42 : 0) - 4)
|
|
193
|
+
const providers = createMemo(() => Model.index(sync.data.provider))
|
|
194
|
+
|
|
195
|
+
const scrollAcceleration = createMemo(() => getScrollAcceleration(tuiConfig))
|
|
196
|
+
const toast = useToast()
|
|
197
|
+
const sdk = useSDK()
|
|
198
|
+
|
|
199
|
+
createEffect(async () => {
|
|
200
|
+
const previousWorkspace = project.workspace.current()
|
|
201
|
+
const result = await sdk.client.session.get({ sessionID: route.sessionID }, { throwOnError: true })
|
|
202
|
+
if (!result.data) {
|
|
203
|
+
toast.show({
|
|
204
|
+
message: `Session not found: ${route.sessionID}`,
|
|
205
|
+
variant: "error",
|
|
206
|
+
})
|
|
207
|
+
navigate({ type: "home" })
|
|
208
|
+
return
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (result.data.workspaceID !== previousWorkspace) {
|
|
212
|
+
project.workspace.set(result.data.workspaceID)
|
|
213
|
+
|
|
214
|
+
// Sync all the data for this workspace. Note that this
|
|
215
|
+
// workspace may not exist anymore which is why this is not
|
|
216
|
+
// fatal. If it doesn't we still want to show the session
|
|
217
|
+
// (which will be non-interactive)
|
|
218
|
+
try {
|
|
219
|
+
await sync.bootstrap({ fatal: false })
|
|
220
|
+
} catch (e) {}
|
|
221
|
+
}
|
|
222
|
+
await sync.session.sync(route.sessionID)
|
|
223
|
+
if (scroll) scroll.scrollBy(100_000)
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
let lastSwitch: string | undefined = undefined
|
|
227
|
+
event.on("message.part.updated", (evt) => {
|
|
228
|
+
const part = evt.properties.part
|
|
229
|
+
if (part.type !== "tool") return
|
|
230
|
+
if (part.sessionID !== route.sessionID) return
|
|
231
|
+
if (part.state.status !== "completed") return
|
|
232
|
+
if (part.id === lastSwitch) return
|
|
233
|
+
|
|
234
|
+
if (part.tool === "plan_exit" && part.state.metadata?.switched) {
|
|
235
|
+
local.agent.set("build")
|
|
236
|
+
lastSwitch = part.id
|
|
237
|
+
} else if (part.tool === "plan_enter") {
|
|
238
|
+
local.agent.set("plan")
|
|
239
|
+
lastSwitch = part.id
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
let seeded = false
|
|
244
|
+
let scroll: ScrollBoxRenderable
|
|
245
|
+
let prompt: PromptRef | undefined
|
|
246
|
+
const bind = (r: PromptRef | undefined) => {
|
|
247
|
+
prompt = r
|
|
248
|
+
promptRef.set(r)
|
|
249
|
+
if (seeded || !route.prompt || !r) return
|
|
250
|
+
seeded = true
|
|
251
|
+
r.set(route.prompt)
|
|
252
|
+
}
|
|
253
|
+
const keybind = useKeybind()
|
|
254
|
+
const dialog = useDialog()
|
|
255
|
+
const renderer = useRenderer()
|
|
256
|
+
|
|
257
|
+
event.on("session.status", (evt) => {
|
|
258
|
+
if (evt.properties.sessionID !== route.sessionID) return
|
|
259
|
+
if (evt.properties.status.type !== "retry") return
|
|
260
|
+
if (evt.properties.status.message !== SessionRetry.GO_UPSELL_MESSAGE) return
|
|
261
|
+
if (dialog.stack.length > 0) return
|
|
262
|
+
|
|
263
|
+
const seen = kv.get(GO_UPSELL_LAST_SEEN_AT)
|
|
264
|
+
if (typeof seen === "number" && Date.now() - seen < GO_UPSELL_WINDOW) return
|
|
265
|
+
|
|
266
|
+
if (kv.get(GO_UPSELL_DONT_SHOW)) return
|
|
267
|
+
|
|
268
|
+
void DialogGoUpsell.show(dialog).then((dontShowAgain) => {
|
|
269
|
+
if (dontShowAgain) kv.set(GO_UPSELL_DONT_SHOW, true)
|
|
270
|
+
kv.set(GO_UPSELL_LAST_SEEN_AT, Date.now())
|
|
271
|
+
})
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
// Allow exit when in child session (prompt is hidden)
|
|
275
|
+
const exit = useExit()
|
|
276
|
+
|
|
277
|
+
createEffect(() => {
|
|
278
|
+
const title = Locale.truncate(session()?.title ?? "", 50)
|
|
279
|
+
const pad = (text: string) => text.padEnd(10, " ")
|
|
280
|
+
const weak = (text: string) => UI.Style.TEXT_DIM + pad(text) + UI.Style.TEXT_NORMAL
|
|
281
|
+
const logo = UI.logo(" ").split(/\r?\n/)
|
|
282
|
+
return exit.message.set(
|
|
283
|
+
[
|
|
284
|
+
...logo,
|
|
285
|
+
``,
|
|
286
|
+
` ${weak("Session")}${UI.Style.TEXT_NORMAL_BOLD}${title}${UI.Style.TEXT_NORMAL}`,
|
|
287
|
+
` ${weak("Continue")}${UI.Style.TEXT_NORMAL_BOLD}mimo -s ${session()?.id}${UI.Style.TEXT_NORMAL}`,
|
|
288
|
+
``,
|
|
289
|
+
].join("\n"),
|
|
290
|
+
)
|
|
291
|
+
})
|
|
292
|
+
|
|
293
|
+
useKeyboard((evt) => {
|
|
294
|
+
if (!session()?.parentID && currentAgentID() === "main") return
|
|
295
|
+
if (keybind.match("app_exit", evt)) {
|
|
296
|
+
const status = sync.data.session_status?.[route.sessionID]
|
|
297
|
+
if (status && status.type !== "idle") {
|
|
298
|
+
void sdk.client.session.abort({ sessionID: route.sessionID }).catch(() => {})
|
|
299
|
+
return
|
|
300
|
+
}
|
|
301
|
+
void exit()
|
|
302
|
+
}
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
// Helper: Find next visible message boundary in direction
|
|
306
|
+
const findNextVisibleMessage = (direction: "next" | "prev"): string | null => {
|
|
307
|
+
const children = scroll.getChildren()
|
|
308
|
+
const messagesList = messages()
|
|
309
|
+
const scrollTop = scroll.y
|
|
310
|
+
|
|
311
|
+
// Get visible messages sorted by position, filtering for valid non-synthetic, non-ignored content
|
|
312
|
+
const visibleMessages = children
|
|
313
|
+
.filter((c) => {
|
|
314
|
+
if (!c.id) return false
|
|
315
|
+
const message = messagesList.find((m) => m.id === c.id)
|
|
316
|
+
if (!message) return false
|
|
317
|
+
|
|
318
|
+
// Check if message has valid non-synthetic, non-ignored text parts
|
|
319
|
+
const parts = sync.data.part[message.id]
|
|
320
|
+
if (!parts || !Array.isArray(parts)) return false
|
|
321
|
+
|
|
322
|
+
return parts.some((part) => part && part.type === "text" && !part.synthetic && !part.ignored)
|
|
323
|
+
})
|
|
324
|
+
.sort((a, b) => a.y - b.y)
|
|
325
|
+
|
|
326
|
+
if (visibleMessages.length === 0) return null
|
|
327
|
+
|
|
328
|
+
if (direction === "next") {
|
|
329
|
+
// Find first message below current position
|
|
330
|
+
return visibleMessages.find((c) => c.y > scrollTop + 10)?.id ?? null
|
|
331
|
+
}
|
|
332
|
+
// Find last message above current position
|
|
333
|
+
return [...visibleMessages].reverse().find((c) => c.y < scrollTop - 10)?.id ?? null
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Helper: Scroll to message in direction or fallback to page scroll
|
|
337
|
+
const scrollToMessage = (direction: "next" | "prev", dialog: ReturnType<typeof useDialog>) => {
|
|
338
|
+
const targetID = findNextVisibleMessage(direction)
|
|
339
|
+
|
|
340
|
+
if (!targetID) {
|
|
341
|
+
scroll.scrollBy(direction === "next" ? scroll.height : -scroll.height)
|
|
342
|
+
dialog.clear()
|
|
343
|
+
return
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const child = scroll.getChildren().find((c) => c.id === targetID)
|
|
347
|
+
if (child) scroll.scrollBy(child.y - scroll.y - 1)
|
|
348
|
+
dialog.clear()
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function toBottom() {
|
|
352
|
+
setTimeout(() => {
|
|
353
|
+
if (!scroll || scroll.isDestroyed) return
|
|
354
|
+
scroll.scrollTo(scroll.scrollHeight)
|
|
355
|
+
}, 50)
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const local = useLocal()
|
|
359
|
+
|
|
360
|
+
function moveFirstChild() {
|
|
361
|
+
const list = actors().filter((a) => a.mode === "subagent")
|
|
362
|
+
if (list.length === 0) {
|
|
363
|
+
dialog.replace(() => <DialogSubagent sessionID={route.sessionID} />)
|
|
364
|
+
return
|
|
365
|
+
}
|
|
366
|
+
if (fullRoute.data.type !== "session") return
|
|
367
|
+
navigate({ ...fullRoute.data, agentID: list[0].actor_id })
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function moveChild(direction: 1 | -1) {
|
|
371
|
+
const list = actors().filter((a) => a.mode === "subagent")
|
|
372
|
+
if (list.length === 0) return
|
|
373
|
+
if (fullRoute.data.type !== "session") return
|
|
374
|
+
const cur = currentAgentID()
|
|
375
|
+
const idx = list.findIndex((a) => a.actor_id === cur)
|
|
376
|
+
const next =
|
|
377
|
+
idx === -1
|
|
378
|
+
? direction === 1
|
|
379
|
+
? 0
|
|
380
|
+
: list.length - 1
|
|
381
|
+
: (idx + direction + list.length) % list.length
|
|
382
|
+
navigate({ ...fullRoute.data, agentID: list[next].actor_id })
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const command = useCommandDialog()
|
|
386
|
+
const t = useLanguage().t
|
|
387
|
+
command.register(() => [
|
|
388
|
+
{
|
|
389
|
+
title: t(session()?.share?.url ? "tui.command.session.share.copy_link" : "tui.command.session.share.title"),
|
|
390
|
+
value: "session.share",
|
|
391
|
+
suggested: route.type === "session",
|
|
392
|
+
keybind: "session_share",
|
|
393
|
+
category: "session",
|
|
394
|
+
enabled: sync.data.config.share !== "disabled",
|
|
395
|
+
slash: {
|
|
396
|
+
name: "share",
|
|
397
|
+
},
|
|
398
|
+
onSelect: async (dialog) => {
|
|
399
|
+
const copy = (url: string) =>
|
|
400
|
+
Clipboard.copy(url)
|
|
401
|
+
.then(() => toast.show({ message: "Share URL copied to clipboard!", variant: "success" }))
|
|
402
|
+
.catch(() => toast.show({ message: "Failed to copy URL to clipboard", variant: "error" }))
|
|
403
|
+
const url = session()?.share?.url
|
|
404
|
+
if (url) {
|
|
405
|
+
await copy(url)
|
|
406
|
+
dialog.clear()
|
|
407
|
+
return
|
|
408
|
+
}
|
|
409
|
+
if (!kv.get("share_consent", false)) {
|
|
410
|
+
const ok = await DialogConfirm.show(dialog, "Share Session", "Are you sure you want to share it?")
|
|
411
|
+
if (ok !== true) return
|
|
412
|
+
kv.set("share_consent", true)
|
|
413
|
+
}
|
|
414
|
+
await sdk.client.session
|
|
415
|
+
.share({
|
|
416
|
+
sessionID: route.sessionID,
|
|
417
|
+
})
|
|
418
|
+
.then((res) => copy(res.data!.share!.url))
|
|
419
|
+
.catch((error) => {
|
|
420
|
+
toast.show({
|
|
421
|
+
message: error instanceof Error ? error.message : "Failed to share session",
|
|
422
|
+
variant: "error",
|
|
423
|
+
})
|
|
424
|
+
})
|
|
425
|
+
dialog.clear()
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
title: t("tui.command.session.rename.title"),
|
|
430
|
+
value: "session.rename",
|
|
431
|
+
keybind: "session_rename",
|
|
432
|
+
category: "session",
|
|
433
|
+
slash: {
|
|
434
|
+
name: "rename",
|
|
435
|
+
},
|
|
436
|
+
onSelect: (dialog) => {
|
|
437
|
+
dialog.replace(() => <DialogSessionRename session={route.sessionID} />)
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
title: t("tui.command.session.timeline.title"),
|
|
442
|
+
value: "session.timeline",
|
|
443
|
+
keybind: "session_timeline",
|
|
444
|
+
category: "session",
|
|
445
|
+
slash: {
|
|
446
|
+
name: "timeline",
|
|
447
|
+
},
|
|
448
|
+
onSelect: (dialog) => {
|
|
449
|
+
dialog.replace(() => (
|
|
450
|
+
<DialogTimeline
|
|
451
|
+
onMove={(messageID) => {
|
|
452
|
+
const child = scroll.getChildren().find((child) => {
|
|
453
|
+
return child.id === messageID
|
|
454
|
+
})
|
|
455
|
+
if (child) scroll.scrollBy(child.y - scroll.y - 1)
|
|
456
|
+
}}
|
|
457
|
+
sessionID={route.sessionID}
|
|
458
|
+
setPrompt={(promptInfo) => prompt?.set(promptInfo)}
|
|
459
|
+
/>
|
|
460
|
+
))
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
title: t("tui.command.session.fork.title"),
|
|
465
|
+
value: "session.fork",
|
|
466
|
+
keybind: "session_fork",
|
|
467
|
+
category: "session",
|
|
468
|
+
slash: {
|
|
469
|
+
name: "fork",
|
|
470
|
+
},
|
|
471
|
+
onSelect: (dialog) => {
|
|
472
|
+
dialog.replace(() => (
|
|
473
|
+
<DialogForkFromTimeline
|
|
474
|
+
onMove={(messageID) => {
|
|
475
|
+
if (!messageID) return
|
|
476
|
+
const child = scroll.getChildren().find((child) => {
|
|
477
|
+
return child.id === messageID
|
|
478
|
+
})
|
|
479
|
+
if (child) scroll.scrollBy(child.y - scroll.y - 1)
|
|
480
|
+
}}
|
|
481
|
+
sessionID={route.sessionID}
|
|
482
|
+
/>
|
|
483
|
+
))
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
title: t("tui.command.session.compact.title"),
|
|
488
|
+
value: "session.compact",
|
|
489
|
+
keybind: "session_compact",
|
|
490
|
+
category: "session",
|
|
491
|
+
slash: {
|
|
492
|
+
name: "compact",
|
|
493
|
+
aliases: ["summarize"],
|
|
494
|
+
},
|
|
495
|
+
onSelect: (dialog) => {
|
|
496
|
+
const selectedModel = local.model.current()
|
|
497
|
+
if (!selectedModel) {
|
|
498
|
+
toast.show({
|
|
499
|
+
variant: "warning",
|
|
500
|
+
message: "Connect a provider to summarize this session",
|
|
501
|
+
duration: 3000,
|
|
502
|
+
})
|
|
503
|
+
return
|
|
504
|
+
}
|
|
505
|
+
void sdk.client.session.summarize({
|
|
506
|
+
sessionID: route.sessionID,
|
|
507
|
+
modelID: selectedModel.modelID,
|
|
508
|
+
providerID: selectedModel.providerID,
|
|
509
|
+
})
|
|
510
|
+
dialog.clear()
|
|
511
|
+
},
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
title: t("tui.command.session.unshare.title"),
|
|
515
|
+
value: "session.unshare",
|
|
516
|
+
keybind: "session_unshare",
|
|
517
|
+
category: "session",
|
|
518
|
+
enabled: !!session()?.share?.url,
|
|
519
|
+
slash: {
|
|
520
|
+
name: "unshare",
|
|
521
|
+
},
|
|
522
|
+
onSelect: async (dialog) => {
|
|
523
|
+
await sdk.client.session
|
|
524
|
+
.unshare({
|
|
525
|
+
sessionID: route.sessionID,
|
|
526
|
+
})
|
|
527
|
+
.then(() => toast.show({ message: "Session unshared successfully", variant: "success" }))
|
|
528
|
+
.catch((error) => {
|
|
529
|
+
toast.show({
|
|
530
|
+
message: error instanceof Error ? error.message : "Failed to unshare session",
|
|
531
|
+
variant: "error",
|
|
532
|
+
})
|
|
533
|
+
})
|
|
534
|
+
dialog.clear()
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
title: t("tui.command.session.undo.title"),
|
|
539
|
+
value: "session.undo",
|
|
540
|
+
keybind: "messages_undo",
|
|
541
|
+
category: "session",
|
|
542
|
+
slash: {
|
|
543
|
+
name: "undo",
|
|
544
|
+
},
|
|
545
|
+
onSelect: async (dialog) => {
|
|
546
|
+
const status = sync.data.session_status?.[route.sessionID]
|
|
547
|
+
if (status?.type !== "idle") await sdk.client.session.abort({ sessionID: route.sessionID }).catch(() => {})
|
|
548
|
+
const revert = session()?.revert?.messageID
|
|
549
|
+
const message = messages().findLast((x) => (!revert || x.id < revert) && x.role === "user")
|
|
550
|
+
if (!message) return
|
|
551
|
+
void sdk.client.session
|
|
552
|
+
.revert({
|
|
553
|
+
sessionID: route.sessionID,
|
|
554
|
+
messageID: message.id,
|
|
555
|
+
})
|
|
556
|
+
.then(() => {
|
|
557
|
+
toBottom()
|
|
558
|
+
})
|
|
559
|
+
const parts = sync.data.part[message.id]
|
|
560
|
+
prompt?.set(
|
|
561
|
+
parts.reduce(
|
|
562
|
+
(agg, part) => {
|
|
563
|
+
if (part.type === "text") {
|
|
564
|
+
if (!part.synthetic) agg.input += part.text
|
|
565
|
+
}
|
|
566
|
+
if (part.type === "file") agg.parts.push(part)
|
|
567
|
+
return agg
|
|
568
|
+
},
|
|
569
|
+
{ input: "", parts: [] as PromptInfo["parts"] },
|
|
570
|
+
),
|
|
571
|
+
)
|
|
572
|
+
dialog.clear()
|
|
573
|
+
},
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
title: t("tui.command.session.redo.title"),
|
|
577
|
+
value: "session.redo",
|
|
578
|
+
keybind: "messages_redo",
|
|
579
|
+
category: "session",
|
|
580
|
+
enabled: !!session()?.revert?.messageID,
|
|
581
|
+
slash: {
|
|
582
|
+
name: "redo",
|
|
583
|
+
},
|
|
584
|
+
onSelect: (dialog) => {
|
|
585
|
+
dialog.clear()
|
|
586
|
+
const messageID = session()?.revert?.messageID
|
|
587
|
+
if (!messageID) return
|
|
588
|
+
const message = messages().find((x) => x.role === "user" && x.id > messageID)
|
|
589
|
+
if (!message) {
|
|
590
|
+
void sdk.client.session.unrevert({
|
|
591
|
+
sessionID: route.sessionID,
|
|
592
|
+
})
|
|
593
|
+
prompt?.set({ input: "", parts: [] })
|
|
594
|
+
return
|
|
595
|
+
}
|
|
596
|
+
void sdk.client.session.revert({
|
|
597
|
+
sessionID: route.sessionID,
|
|
598
|
+
messageID: message.id,
|
|
599
|
+
})
|
|
600
|
+
},
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
title: t(sidebarVisible() ? "tui.command.session.sidebar.hide" : "tui.command.session.sidebar.show"),
|
|
604
|
+
value: "session.sidebar.toggle",
|
|
605
|
+
keybind: "sidebar_toggle",
|
|
606
|
+
category: "session",
|
|
607
|
+
onSelect: (dialog) => {
|
|
608
|
+
batch(() => {
|
|
609
|
+
const isVisible = sidebarVisible()
|
|
610
|
+
setSidebar(() => (isVisible ? "hide" : "auto"))
|
|
611
|
+
setSidebarOpen(!isVisible)
|
|
612
|
+
})
|
|
613
|
+
dialog.clear()
|
|
614
|
+
},
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
title: t(conceal() ? "tui.command.session.conceal.disable" : "tui.command.session.conceal.enable"),
|
|
618
|
+
value: "session.toggle.conceal",
|
|
619
|
+
keybind: "messages_toggle_conceal",
|
|
620
|
+
category: "session",
|
|
621
|
+
onSelect: (dialog) => {
|
|
622
|
+
setConceal((prev) => !prev)
|
|
623
|
+
dialog.clear()
|
|
624
|
+
},
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
title: t(showTimestamps() ? "tui.command.session.timestamps.hide" : "tui.command.session.timestamps.show"),
|
|
628
|
+
value: "session.toggle.timestamps",
|
|
629
|
+
category: "session",
|
|
630
|
+
slash: {
|
|
631
|
+
name: "timestamps",
|
|
632
|
+
aliases: ["toggle-timestamps"],
|
|
633
|
+
},
|
|
634
|
+
onSelect: (dialog) => {
|
|
635
|
+
setTimestamps((prev) => (prev === "show" ? "hide" : "show"))
|
|
636
|
+
dialog.clear()
|
|
637
|
+
},
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
title: t(
|
|
641
|
+
nextThinkingMode(thinkingMode()) === "hide"
|
|
642
|
+
? "tui.command.session.thinking.collapse"
|
|
643
|
+
: "tui.command.session.thinking.expand",
|
|
644
|
+
),
|
|
645
|
+
value: "session.toggle.thinking",
|
|
646
|
+
keybind: "display_thinking",
|
|
647
|
+
category: "session",
|
|
648
|
+
slash: {
|
|
649
|
+
name: "thinking",
|
|
650
|
+
aliases: ["toggle-thinking"],
|
|
651
|
+
},
|
|
652
|
+
onSelect: (dialog) => {
|
|
653
|
+
thinking.set(nextThinkingMode(thinkingMode()))
|
|
654
|
+
dialog.clear()
|
|
655
|
+
},
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
title: t(showDetails() ? "tui.command.session.tool_details.hide" : "tui.command.session.tool_details.show"),
|
|
659
|
+
value: "session.toggle.actions",
|
|
660
|
+
keybind: "tool_details",
|
|
661
|
+
category: "session",
|
|
662
|
+
onSelect: (dialog) => {
|
|
663
|
+
setShowDetails((prev) => !prev)
|
|
664
|
+
dialog.clear()
|
|
665
|
+
},
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
title: t("tui.command.session.scrollbar.toggle"),
|
|
669
|
+
value: "session.toggle.scrollbar",
|
|
670
|
+
keybind: "scrollbar_toggle",
|
|
671
|
+
category: "session",
|
|
672
|
+
onSelect: (dialog) => {
|
|
673
|
+
setShowScrollbar((prev) => !prev)
|
|
674
|
+
dialog.clear()
|
|
675
|
+
},
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
title: t(
|
|
679
|
+
showGenericToolOutput()
|
|
680
|
+
? "tui.command.session.generic_tool_output.hide"
|
|
681
|
+
: "tui.command.session.generic_tool_output.show",
|
|
682
|
+
),
|
|
683
|
+
value: "session.toggle.generic_tool_output",
|
|
684
|
+
category: "session",
|
|
685
|
+
onSelect: (dialog) => {
|
|
686
|
+
setShowGenericToolOutput((prev) => !prev)
|
|
687
|
+
dialog.clear()
|
|
688
|
+
},
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
title: t("tui.command.session.page_up.title"),
|
|
692
|
+
value: "session.page.up",
|
|
693
|
+
keybind: "messages_page_up",
|
|
694
|
+
category: "session",
|
|
695
|
+
hidden: true,
|
|
696
|
+
onSelect: (dialog) => {
|
|
697
|
+
scroll.scrollBy(-scroll.height / 2)
|
|
698
|
+
dialog.clear()
|
|
699
|
+
},
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
title: t("tui.command.session.page_down.title"),
|
|
703
|
+
value: "session.page.down",
|
|
704
|
+
keybind: "messages_page_down",
|
|
705
|
+
category: "session",
|
|
706
|
+
hidden: true,
|
|
707
|
+
onSelect: (dialog) => {
|
|
708
|
+
scroll.scrollBy(scroll.height / 2)
|
|
709
|
+
dialog.clear()
|
|
710
|
+
},
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
title: t("tui.command.session.line_up.title"),
|
|
714
|
+
value: "session.line.up",
|
|
715
|
+
keybind: "messages_line_up",
|
|
716
|
+
category: "session",
|
|
717
|
+
disabled: true,
|
|
718
|
+
onSelect: (dialog) => {
|
|
719
|
+
scroll.scrollBy(-1)
|
|
720
|
+
dialog.clear()
|
|
721
|
+
},
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
title: t("tui.command.session.line_down.title"),
|
|
725
|
+
value: "session.line.down",
|
|
726
|
+
keybind: "messages_line_down",
|
|
727
|
+
category: "session",
|
|
728
|
+
disabled: true,
|
|
729
|
+
onSelect: (dialog) => {
|
|
730
|
+
scroll.scrollBy(1)
|
|
731
|
+
dialog.clear()
|
|
732
|
+
},
|
|
733
|
+
},
|
|
734
|
+
{
|
|
735
|
+
title: t("tui.command.session.half_page_up.title"),
|
|
736
|
+
value: "session.half.page.up",
|
|
737
|
+
keybind: "messages_half_page_up",
|
|
738
|
+
category: "session",
|
|
739
|
+
hidden: true,
|
|
740
|
+
onSelect: (dialog) => {
|
|
741
|
+
scroll.scrollBy(-scroll.height / 4)
|
|
742
|
+
dialog.clear()
|
|
743
|
+
},
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
title: t("tui.command.session.half_page_down.title"),
|
|
747
|
+
value: "session.half.page.down",
|
|
748
|
+
keybind: "messages_half_page_down",
|
|
749
|
+
category: "session",
|
|
750
|
+
hidden: true,
|
|
751
|
+
onSelect: (dialog) => {
|
|
752
|
+
scroll.scrollBy(scroll.height / 4)
|
|
753
|
+
dialog.clear()
|
|
754
|
+
},
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
title: t("tui.command.session.first.title"),
|
|
758
|
+
value: "session.first",
|
|
759
|
+
keybind: "messages_first",
|
|
760
|
+
category: "session",
|
|
761
|
+
hidden: true,
|
|
762
|
+
onSelect: (dialog) => {
|
|
763
|
+
scroll.scrollTo(0)
|
|
764
|
+
dialog.clear()
|
|
765
|
+
},
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
title: t("tui.command.session.last.title"),
|
|
769
|
+
value: "session.last",
|
|
770
|
+
keybind: "messages_last",
|
|
771
|
+
category: "session",
|
|
772
|
+
hidden: true,
|
|
773
|
+
onSelect: (dialog) => {
|
|
774
|
+
scroll.scrollTo(scroll.scrollHeight)
|
|
775
|
+
dialog.clear()
|
|
776
|
+
},
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
title: t("tui.command.session.last_user.title"),
|
|
780
|
+
value: "session.messages_last_user",
|
|
781
|
+
keybind: "messages_last_user",
|
|
782
|
+
category: "session",
|
|
783
|
+
hidden: true,
|
|
784
|
+
onSelect: () => {
|
|
785
|
+
const msgs = messages()
|
|
786
|
+
if (!msgs || !msgs.length) return
|
|
787
|
+
|
|
788
|
+
// Find the most recent user message with non-ignored, non-synthetic text parts
|
|
789
|
+
for (let i = msgs.length - 1; i >= 0; i--) {
|
|
790
|
+
const message = msgs[i]
|
|
791
|
+
if (!message || message.role !== "user") continue
|
|
792
|
+
|
|
793
|
+
const parts = sync.data.part[message.id]
|
|
794
|
+
if (!parts || !Array.isArray(parts)) continue
|
|
795
|
+
|
|
796
|
+
const hasValidTextPart = parts.some(
|
|
797
|
+
(part) => part && part.type === "text" && !part.synthetic && !part.ignored,
|
|
798
|
+
)
|
|
799
|
+
|
|
800
|
+
if (hasValidTextPart) {
|
|
801
|
+
const child = scroll.getChildren().find((child) => {
|
|
802
|
+
return child.id === message.id
|
|
803
|
+
})
|
|
804
|
+
if (child) scroll.scrollBy(child.y - scroll.y - 1)
|
|
805
|
+
break
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
},
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
title: t("tui.command.session.message_next.title"),
|
|
812
|
+
value: "session.message.next",
|
|
813
|
+
keybind: "messages_next",
|
|
814
|
+
category: "session",
|
|
815
|
+
hidden: true,
|
|
816
|
+
onSelect: (dialog) => scrollToMessage("next", dialog),
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
title: t("tui.command.session.message_previous.title"),
|
|
820
|
+
value: "session.message.previous",
|
|
821
|
+
keybind: "messages_previous",
|
|
822
|
+
category: "session",
|
|
823
|
+
hidden: true,
|
|
824
|
+
onSelect: (dialog) => scrollToMessage("prev", dialog),
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
title: t("tui.command.messages.copy.title"),
|
|
828
|
+
value: "messages.copy",
|
|
829
|
+
keybind: "messages_copy",
|
|
830
|
+
category: "session",
|
|
831
|
+
onSelect: (dialog) => {
|
|
832
|
+
const revertID = session()?.revert?.messageID
|
|
833
|
+
const lastAssistantMessage = messages().findLast(
|
|
834
|
+
(msg) => msg.role === "assistant" && (!revertID || msg.id < revertID),
|
|
835
|
+
)
|
|
836
|
+
if (!lastAssistantMessage) {
|
|
837
|
+
toast.show({ message: "No assistant messages found", variant: "error" })
|
|
838
|
+
dialog.clear()
|
|
839
|
+
return
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
const parts = sync.data.part[lastAssistantMessage.id] ?? []
|
|
843
|
+
const textParts = parts.filter((part) => part.type === "text")
|
|
844
|
+
if (textParts.length === 0) {
|
|
845
|
+
toast.show({ message: "No text parts found in last assistant message", variant: "error" })
|
|
846
|
+
dialog.clear()
|
|
847
|
+
return
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
const text = textParts
|
|
851
|
+
.map((part) => part.text)
|
|
852
|
+
.join("\n")
|
|
853
|
+
.trim()
|
|
854
|
+
if (!text) {
|
|
855
|
+
toast.show({
|
|
856
|
+
message: "No text content found in last assistant message",
|
|
857
|
+
variant: "error",
|
|
858
|
+
})
|
|
859
|
+
dialog.clear()
|
|
860
|
+
return
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
Clipboard.copy(text)
|
|
864
|
+
.then(() => toast.show({ message: "Message copied to clipboard!", variant: "success" }))
|
|
865
|
+
.catch(() => toast.show({ message: "Failed to copy to clipboard", variant: "error" }))
|
|
866
|
+
dialog.clear()
|
|
867
|
+
},
|
|
868
|
+
},
|
|
869
|
+
{
|
|
870
|
+
title: t("tui.command.session.copy.title"),
|
|
871
|
+
value: "session.copy",
|
|
872
|
+
category: "session",
|
|
873
|
+
slash: {
|
|
874
|
+
name: "copy",
|
|
875
|
+
},
|
|
876
|
+
onSelect: async (dialog) => {
|
|
877
|
+
try {
|
|
878
|
+
const sessionData = session()
|
|
879
|
+
if (!sessionData) return
|
|
880
|
+
const sessionMessages = messages()
|
|
881
|
+
const transcript = formatTranscript(
|
|
882
|
+
sessionData,
|
|
883
|
+
sessionMessages.map((msg) => ({ info: msg, parts: sync.data.part[msg.id] ?? [] })),
|
|
884
|
+
{
|
|
885
|
+
thinking: showThinking(),
|
|
886
|
+
toolDetails: showDetails(),
|
|
887
|
+
assistantMetadata: showAssistantMetadata(),
|
|
888
|
+
providers: sync.data.provider,
|
|
889
|
+
},
|
|
890
|
+
)
|
|
891
|
+
await Clipboard.copy(transcript)
|
|
892
|
+
toast.show({ message: "Session transcript copied to clipboard!", variant: "success" })
|
|
893
|
+
} catch {
|
|
894
|
+
toast.show({ message: "Failed to copy session transcript", variant: "error" })
|
|
895
|
+
}
|
|
896
|
+
dialog.clear()
|
|
897
|
+
},
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
title: t("tui.command.session.export.title"),
|
|
901
|
+
value: "session.export",
|
|
902
|
+
keybind: "session_export",
|
|
903
|
+
category: "session",
|
|
904
|
+
slash: {
|
|
905
|
+
name: "export",
|
|
906
|
+
},
|
|
907
|
+
onSelect: async (dialog) => {
|
|
908
|
+
try {
|
|
909
|
+
const sessionData = session()
|
|
910
|
+
if (!sessionData) return
|
|
911
|
+
const sessionMessages = messages()
|
|
912
|
+
|
|
913
|
+
const defaultFilename = `session-${sessionData.id.slice(0, 8)}.md`
|
|
914
|
+
|
|
915
|
+
const options = await DialogExportOptions.show(
|
|
916
|
+
dialog,
|
|
917
|
+
defaultFilename,
|
|
918
|
+
showThinking(),
|
|
919
|
+
showDetails(),
|
|
920
|
+
showAssistantMetadata(),
|
|
921
|
+
false,
|
|
922
|
+
)
|
|
923
|
+
|
|
924
|
+
if (options === null) return
|
|
925
|
+
|
|
926
|
+
const transcript = formatTranscript(
|
|
927
|
+
sessionData,
|
|
928
|
+
sessionMessages.map((msg) => ({ info: msg, parts: sync.data.part[msg.id] ?? [] })),
|
|
929
|
+
{
|
|
930
|
+
thinking: options.thinking,
|
|
931
|
+
toolDetails: options.toolDetails,
|
|
932
|
+
assistantMetadata: options.assistantMetadata,
|
|
933
|
+
providers: sync.data.provider,
|
|
934
|
+
},
|
|
935
|
+
)
|
|
936
|
+
|
|
937
|
+
if (options.openWithoutSaving) {
|
|
938
|
+
// Just open in editor without saving
|
|
939
|
+
await Editor.open({ value: transcript, renderer })
|
|
940
|
+
} else {
|
|
941
|
+
const exportDir = process.cwd()
|
|
942
|
+
const filename = options.filename.trim()
|
|
943
|
+
const filepath = path.join(exportDir, filename)
|
|
944
|
+
|
|
945
|
+
await Filesystem.write(filepath, transcript)
|
|
946
|
+
|
|
947
|
+
// Open with EDITOR if available
|
|
948
|
+
const result = await Editor.open({ value: transcript, renderer })
|
|
949
|
+
if (result !== undefined) {
|
|
950
|
+
await Filesystem.write(filepath, result)
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
toast.show({ message: `Session exported to ${filename}`, variant: "success" })
|
|
954
|
+
}
|
|
955
|
+
} catch {
|
|
956
|
+
toast.show({ message: "Failed to export session", variant: "error" })
|
|
957
|
+
}
|
|
958
|
+
dialog.clear()
|
|
959
|
+
},
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
title: t("tui.command.session.child_first.title"),
|
|
963
|
+
value: "session.child.first",
|
|
964
|
+
keybind: "session_child_first",
|
|
965
|
+
category: "session",
|
|
966
|
+
hidden: true,
|
|
967
|
+
onSelect: (dialog) => {
|
|
968
|
+
moveFirstChild()
|
|
969
|
+
dialog.clear()
|
|
970
|
+
},
|
|
971
|
+
},
|
|
972
|
+
{
|
|
973
|
+
title: t("tui.command.session.parent.title"),
|
|
974
|
+
value: "session.parent",
|
|
975
|
+
keybind: "session_parent",
|
|
976
|
+
category: "session",
|
|
977
|
+
hidden: true,
|
|
978
|
+
enabled: currentAgentID() !== "main" || !!session()?.parentID,
|
|
979
|
+
onSelect: (dialog) => {
|
|
980
|
+
if (fullRoute.data.type === "session" && currentAgentID() !== "main") {
|
|
981
|
+
navigate({ ...fullRoute.data, agentID: undefined })
|
|
982
|
+
dialog.clear()
|
|
983
|
+
return
|
|
984
|
+
}
|
|
985
|
+
const parentID = session()?.parentID
|
|
986
|
+
if (parentID) {
|
|
987
|
+
navigate({
|
|
988
|
+
type: "session",
|
|
989
|
+
sessionID: parentID,
|
|
990
|
+
})
|
|
991
|
+
}
|
|
992
|
+
dialog.clear()
|
|
993
|
+
},
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
title: t("tui.command.session.child_next.title"),
|
|
997
|
+
value: "session.child.next",
|
|
998
|
+
keybind: "session_child_cycle",
|
|
999
|
+
category: "session",
|
|
1000
|
+
hidden: true,
|
|
1001
|
+
onSelect: (dialog) => {
|
|
1002
|
+
moveChild(1)
|
|
1003
|
+
dialog.clear()
|
|
1004
|
+
},
|
|
1005
|
+
},
|
|
1006
|
+
{
|
|
1007
|
+
title: t("tui.command.session.child_previous.title"),
|
|
1008
|
+
value: "session.child.previous",
|
|
1009
|
+
keybind: "session_child_cycle_reverse",
|
|
1010
|
+
category: "session",
|
|
1011
|
+
hidden: true,
|
|
1012
|
+
onSelect: (dialog) => {
|
|
1013
|
+
moveChild(-1)
|
|
1014
|
+
dialog.clear()
|
|
1015
|
+
},
|
|
1016
|
+
},
|
|
1017
|
+
])
|
|
1018
|
+
|
|
1019
|
+
const revertInfo = createMemo(() => session()?.revert)
|
|
1020
|
+
const revertMessageID = createMemo(() => revertInfo()?.messageID)
|
|
1021
|
+
|
|
1022
|
+
const revertDiffFiles = createMemo(() => getRevertDiffFiles(revertInfo()?.diff ?? ""))
|
|
1023
|
+
|
|
1024
|
+
const revertRevertedMessages = createMemo(() => {
|
|
1025
|
+
const messageID = revertMessageID()
|
|
1026
|
+
if (!messageID) return []
|
|
1027
|
+
return messages().filter((x) => x.id >= messageID && x.role === "user")
|
|
1028
|
+
})
|
|
1029
|
+
|
|
1030
|
+
const revert = createMemo(() => {
|
|
1031
|
+
const info = revertInfo()
|
|
1032
|
+
if (!info) return
|
|
1033
|
+
if (!info.messageID) return
|
|
1034
|
+
return {
|
|
1035
|
+
messageID: info.messageID,
|
|
1036
|
+
reverted: revertRevertedMessages(),
|
|
1037
|
+
diff: info.diff,
|
|
1038
|
+
diffFiles: revertDiffFiles(),
|
|
1039
|
+
}
|
|
1040
|
+
})
|
|
1041
|
+
|
|
1042
|
+
// snap to bottom when session changes
|
|
1043
|
+
createEffect(on(() => route.sessionID, toBottom))
|
|
1044
|
+
|
|
1045
|
+
return (
|
|
1046
|
+
<context.Provider
|
|
1047
|
+
value={{
|
|
1048
|
+
get width() {
|
|
1049
|
+
return contentWidth()
|
|
1050
|
+
},
|
|
1051
|
+
sessionID: route.sessionID,
|
|
1052
|
+
conceal,
|
|
1053
|
+
thinkingMode,
|
|
1054
|
+
showThinking,
|
|
1055
|
+
showTimestamps,
|
|
1056
|
+
showDetails,
|
|
1057
|
+
showGenericToolOutput,
|
|
1058
|
+
diffWrapMode,
|
|
1059
|
+
providers,
|
|
1060
|
+
sync,
|
|
1061
|
+
tui: tuiConfig,
|
|
1062
|
+
}}
|
|
1063
|
+
>
|
|
1064
|
+
<box flexDirection="row">
|
|
1065
|
+
<box flexGrow={1} paddingBottom={1} paddingLeft={2} paddingRight={2} gap={1} onMouse={onWheel}>
|
|
1066
|
+
<Show when={session()}>
|
|
1067
|
+
<scrollbox
|
|
1068
|
+
ref={(r) => (scroll = r)}
|
|
1069
|
+
viewportOptions={{
|
|
1070
|
+
paddingRight: 1,
|
|
1071
|
+
}}
|
|
1072
|
+
verticalScrollbarOptions={{
|
|
1073
|
+
paddingLeft: 1,
|
|
1074
|
+
visible: true,
|
|
1075
|
+
trackOptions: {
|
|
1076
|
+
backgroundColor: scrollbarVisible() ? theme.backgroundElement : theme.background,
|
|
1077
|
+
foregroundColor: scrollbarVisible() ? theme.border : theme.background,
|
|
1078
|
+
},
|
|
1079
|
+
}}
|
|
1080
|
+
stickyScroll={true}
|
|
1081
|
+
stickyStart="bottom"
|
|
1082
|
+
flexGrow={1}
|
|
1083
|
+
scrollAcceleration={scrollAcceleration()}
|
|
1084
|
+
>
|
|
1085
|
+
<box height={1} />
|
|
1086
|
+
<For each={messages()}>
|
|
1087
|
+
{(message, index) => (
|
|
1088
|
+
<Switch>
|
|
1089
|
+
<Match when={message.id === revert()?.messageID}>
|
|
1090
|
+
{(function () {
|
|
1091
|
+
const command = useCommandDialog()
|
|
1092
|
+
const [hover, setHover] = createSignal(false)
|
|
1093
|
+
const dialog = useDialog()
|
|
1094
|
+
|
|
1095
|
+
const handleUnrevert = async () => {
|
|
1096
|
+
const confirmed = await DialogConfirm.show(
|
|
1097
|
+
dialog,
|
|
1098
|
+
"Confirm Redo",
|
|
1099
|
+
"Are you sure you want to restore the reverted messages?",
|
|
1100
|
+
)
|
|
1101
|
+
if (confirmed) {
|
|
1102
|
+
command.trigger("session.redo")
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
return (
|
|
1107
|
+
<box
|
|
1108
|
+
onMouseOver={() => setHover(true)}
|
|
1109
|
+
onMouseOut={() => setHover(false)}
|
|
1110
|
+
onMouseUp={handleUnrevert}
|
|
1111
|
+
marginTop={1}
|
|
1112
|
+
flexShrink={0}
|
|
1113
|
+
border={["left"]}
|
|
1114
|
+
customBorderChars={SplitBorder.customBorderChars}
|
|
1115
|
+
borderColor={theme.backgroundPanel}
|
|
1116
|
+
>
|
|
1117
|
+
<box
|
|
1118
|
+
paddingTop={1}
|
|
1119
|
+
paddingBottom={1}
|
|
1120
|
+
paddingLeft={2}
|
|
1121
|
+
backgroundColor={hover() ? theme.backgroundElement : theme.backgroundPanel}
|
|
1122
|
+
>
|
|
1123
|
+
<text fg={theme.textMuted}>{revert()!.reverted.length} message reverted</text>
|
|
1124
|
+
<text fg={theme.textMuted}>
|
|
1125
|
+
<span style={{ fg: theme.text }}>{keybind.print("messages_redo")}</span> or /redo to
|
|
1126
|
+
restore
|
|
1127
|
+
</text>
|
|
1128
|
+
<Show when={revert()!.diffFiles?.length}>
|
|
1129
|
+
<box marginTop={1}>
|
|
1130
|
+
<For each={revert()!.diffFiles}>
|
|
1131
|
+
{(file) => (
|
|
1132
|
+
<text fg={theme.text}>
|
|
1133
|
+
{file.filename}
|
|
1134
|
+
<Show when={file.additions > 0}>
|
|
1135
|
+
<span style={{ fg: theme.diffAdded }}> +{file.additions}</span>
|
|
1136
|
+
</Show>
|
|
1137
|
+
<Show when={file.deletions > 0}>
|
|
1138
|
+
<span style={{ fg: theme.diffRemoved }}> -{file.deletions}</span>
|
|
1139
|
+
</Show>
|
|
1140
|
+
</text>
|
|
1141
|
+
)}
|
|
1142
|
+
</For>
|
|
1143
|
+
</box>
|
|
1144
|
+
</Show>
|
|
1145
|
+
</box>
|
|
1146
|
+
</box>
|
|
1147
|
+
)
|
|
1148
|
+
})()}
|
|
1149
|
+
</Match>
|
|
1150
|
+
<Match when={revert()?.messageID && message.id >= revert()!.messageID}>
|
|
1151
|
+
<></>
|
|
1152
|
+
</Match>
|
|
1153
|
+
<Match when={message.role === "user"}>
|
|
1154
|
+
<UserMessage
|
|
1155
|
+
index={index()}
|
|
1156
|
+
onMouseUp={() => {
|
|
1157
|
+
if (renderer.getSelection()?.getSelectedText()) return
|
|
1158
|
+
dialog.replace(() => (
|
|
1159
|
+
<DialogMessage
|
|
1160
|
+
messageID={message.id}
|
|
1161
|
+
sessionID={route.sessionID}
|
|
1162
|
+
setPrompt={(promptInfo) => prompt?.set(promptInfo)}
|
|
1163
|
+
/>
|
|
1164
|
+
))
|
|
1165
|
+
}}
|
|
1166
|
+
message={message as UserMessage}
|
|
1167
|
+
parts={sync.data.part[message.id] ?? []}
|
|
1168
|
+
pending={pending()}
|
|
1169
|
+
/>
|
|
1170
|
+
</Match>
|
|
1171
|
+
<Match when={message.role === "assistant"}>
|
|
1172
|
+
<AssistantMessage
|
|
1173
|
+
last={lastAssistant()?.id === message.id}
|
|
1174
|
+
message={message as AssistantMessage}
|
|
1175
|
+
parts={sync.data.part[message.id] ?? []}
|
|
1176
|
+
/>
|
|
1177
|
+
</Match>
|
|
1178
|
+
</Switch>
|
|
1179
|
+
)}
|
|
1180
|
+
</For>
|
|
1181
|
+
</scrollbox>
|
|
1182
|
+
<box flexShrink={0}>
|
|
1183
|
+
<Show when={permissions().length > 0}>
|
|
1184
|
+
<PermissionPrompt request={permissions()[0]} />
|
|
1185
|
+
</Show>
|
|
1186
|
+
<Show when={permissions().length === 0 && questions().length > 0}>
|
|
1187
|
+
<QuestionPrompt request={questions()[0]} />
|
|
1188
|
+
</Show>
|
|
1189
|
+
<Show when={session()?.parentID || currentAgentID() !== "main"}>
|
|
1190
|
+
<SubagentFooter />
|
|
1191
|
+
</Show>
|
|
1192
|
+
<Show when={visible()}>
|
|
1193
|
+
<TuiPluginRuntime.Slot
|
|
1194
|
+
name="session_prompt"
|
|
1195
|
+
mode="replace"
|
|
1196
|
+
session_id={route.sessionID}
|
|
1197
|
+
visible={visible()}
|
|
1198
|
+
disabled={disabled()}
|
|
1199
|
+
on_submit={toBottom}
|
|
1200
|
+
ref={bind}
|
|
1201
|
+
>
|
|
1202
|
+
<Prompt
|
|
1203
|
+
visible={visible()}
|
|
1204
|
+
ref={bind}
|
|
1205
|
+
disabled={disabled()}
|
|
1206
|
+
onSubmit={() => {
|
|
1207
|
+
toBottom()
|
|
1208
|
+
}}
|
|
1209
|
+
sessionID={route.sessionID}
|
|
1210
|
+
right={<TuiPluginRuntime.Slot name="session_prompt_right" session_id={route.sessionID} />}
|
|
1211
|
+
/>
|
|
1212
|
+
</TuiPluginRuntime.Slot>
|
|
1213
|
+
</Show>
|
|
1214
|
+
</box>
|
|
1215
|
+
</Show>
|
|
1216
|
+
<Toast />
|
|
1217
|
+
</box>
|
|
1218
|
+
<Show when={sidebarVisible()}>
|
|
1219
|
+
<Switch>
|
|
1220
|
+
<Match when={wide()}>
|
|
1221
|
+
<Sidebar sessionID={route.sessionID} />
|
|
1222
|
+
</Match>
|
|
1223
|
+
<Match when={!wide()}>
|
|
1224
|
+
<box
|
|
1225
|
+
position="absolute"
|
|
1226
|
+
top={0}
|
|
1227
|
+
left={0}
|
|
1228
|
+
right={0}
|
|
1229
|
+
bottom={0}
|
|
1230
|
+
alignItems="flex-end"
|
|
1231
|
+
backgroundColor={RGBA.fromInts(0, 0, 0, 70)}
|
|
1232
|
+
>
|
|
1233
|
+
<Sidebar sessionID={route.sessionID} />
|
|
1234
|
+
</box>
|
|
1235
|
+
</Match>
|
|
1236
|
+
</Switch>
|
|
1237
|
+
</Show>
|
|
1238
|
+
</box>
|
|
1239
|
+
</context.Provider>
|
|
1240
|
+
)
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
const MIME_BADGE: Record<string, string> = {
|
|
1244
|
+
"text/plain": "txt",
|
|
1245
|
+
"image/png": "img",
|
|
1246
|
+
"image/jpeg": "img",
|
|
1247
|
+
"image/gif": "img",
|
|
1248
|
+
"image/webp": "img",
|
|
1249
|
+
"application/pdf": "pdf",
|
|
1250
|
+
"application/x-directory": "dir",
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
function UserMessage(props: {
|
|
1254
|
+
message: UserMessage
|
|
1255
|
+
parts: Part[]
|
|
1256
|
+
onMouseUp: () => void
|
|
1257
|
+
index: number
|
|
1258
|
+
pending?: string
|
|
1259
|
+
}) {
|
|
1260
|
+
const ctx = use()
|
|
1261
|
+
const local = useLocal()
|
|
1262
|
+
const text = createMemo(() => props.parts.flatMap((x) => (x.type === "text" && !x.synthetic ? [x] : []))[0])
|
|
1263
|
+
const files = createMemo(() => props.parts.flatMap((x) => (x.type === "file" ? [x] : [])))
|
|
1264
|
+
const { theme } = useTheme()
|
|
1265
|
+
const [hover, setHover] = createSignal(false)
|
|
1266
|
+
const queued = createMemo(() => props.pending && props.message.id > props.pending)
|
|
1267
|
+
const color = createMemo(() => local.agent.color(props.message.agent))
|
|
1268
|
+
const queuedFg = createMemo(() => selectedForeground(theme, color()))
|
|
1269
|
+
const metadataVisible = createMemo(() => queued() || ctx.showTimestamps())
|
|
1270
|
+
|
|
1271
|
+
return (
|
|
1272
|
+
<>
|
|
1273
|
+
<Show when={text()}>
|
|
1274
|
+
<box
|
|
1275
|
+
id={props.message.id}
|
|
1276
|
+
border={["left"]}
|
|
1277
|
+
borderColor={color()}
|
|
1278
|
+
customBorderChars={SplitBorder.customBorderChars}
|
|
1279
|
+
marginTop={props.index === 0 ? 0 : 1}
|
|
1280
|
+
>
|
|
1281
|
+
<box
|
|
1282
|
+
onMouseOver={() => {
|
|
1283
|
+
setHover(true)
|
|
1284
|
+
}}
|
|
1285
|
+
onMouseOut={() => {
|
|
1286
|
+
setHover(false)
|
|
1287
|
+
}}
|
|
1288
|
+
onMouseUp={props.onMouseUp}
|
|
1289
|
+
paddingTop={1}
|
|
1290
|
+
paddingBottom={1}
|
|
1291
|
+
paddingLeft={2}
|
|
1292
|
+
backgroundColor={hover() ? theme.backgroundElement : theme.backgroundPanel}
|
|
1293
|
+
flexShrink={0}
|
|
1294
|
+
>
|
|
1295
|
+
<text fg={theme.text}>{text()?.text}</text>
|
|
1296
|
+
<Show when={files().length}>
|
|
1297
|
+
<box flexDirection="row" paddingBottom={metadataVisible() ? 1 : 0} paddingTop={1} gap={1} flexWrap="wrap">
|
|
1298
|
+
<For each={files()}>
|
|
1299
|
+
{(file) => {
|
|
1300
|
+
const bg = createMemo(() => {
|
|
1301
|
+
if (file.mime.startsWith("image/")) return theme.accent
|
|
1302
|
+
if (file.mime === "application/pdf") return theme.primary
|
|
1303
|
+
return theme.secondary
|
|
1304
|
+
})
|
|
1305
|
+
return (
|
|
1306
|
+
<text fg={theme.text}>
|
|
1307
|
+
<span style={{ bg: bg(), fg: theme.background }}> {MIME_BADGE[file.mime] ?? file.mime} </span>
|
|
1308
|
+
<span style={{ bg: theme.backgroundElement, fg: theme.textMuted }}> {file.filename} </span>
|
|
1309
|
+
</text>
|
|
1310
|
+
)
|
|
1311
|
+
}}
|
|
1312
|
+
</For>
|
|
1313
|
+
</box>
|
|
1314
|
+
</Show>
|
|
1315
|
+
<Show
|
|
1316
|
+
when={queued()}
|
|
1317
|
+
fallback={
|
|
1318
|
+
<Show when={ctx.showTimestamps()}>
|
|
1319
|
+
<text fg={theme.textMuted}>
|
|
1320
|
+
<span style={{ fg: theme.textMuted }}>
|
|
1321
|
+
{Locale.todayTimeOrDateTime(props.message.time.created)}
|
|
1322
|
+
</span>
|
|
1323
|
+
</text>
|
|
1324
|
+
</Show>
|
|
1325
|
+
}
|
|
1326
|
+
>
|
|
1327
|
+
<text fg={theme.textMuted}>
|
|
1328
|
+
<span style={{ bg: color(), fg: queuedFg(), bold: true }}> QUEUED </span>
|
|
1329
|
+
</text>
|
|
1330
|
+
</Show>
|
|
1331
|
+
</box>
|
|
1332
|
+
</box>
|
|
1333
|
+
</Show>
|
|
1334
|
+
</>
|
|
1335
|
+
)
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
function AssistantMessage(props: { message: AssistantMessage; parts: Part[]; last: boolean }) {
|
|
1339
|
+
const ctx = use()
|
|
1340
|
+
const local = useLocal()
|
|
1341
|
+
const { theme } = useTheme()
|
|
1342
|
+
const sync = useSync()
|
|
1343
|
+
const messages = createMemo(() => sync.data.message[props.message.sessionID]?.[props.message.agentID ?? "main"] ?? [])
|
|
1344
|
+
const model = createMemo(() => Model.name(ctx.providers(), props.message.providerID, props.message.modelID))
|
|
1345
|
+
|
|
1346
|
+
const final = createMemo(() => {
|
|
1347
|
+
return props.message.finish && props.message.finish !== "tool-calls"
|
|
1348
|
+
})
|
|
1349
|
+
|
|
1350
|
+
const duration = createMemo(() => {
|
|
1351
|
+
if (!final()) return 0
|
|
1352
|
+
if (!props.message.time.completed) return 0
|
|
1353
|
+
const user = messages().find((x) => x.role === "user" && x.id === props.message.parentID)
|
|
1354
|
+
if (!user || !user.time) return 0
|
|
1355
|
+
return props.message.time.completed - user.time.created
|
|
1356
|
+
})
|
|
1357
|
+
|
|
1358
|
+
const keybind = useKeybind()
|
|
1359
|
+
|
|
1360
|
+
// Goal judge verdict for this specific turn, if the stop-condition judge
|
|
1361
|
+
// evaluated it. Rendered as a foldable per-turn marker so the user can trace
|
|
1362
|
+
// back which turn failed the check — without polluting the message stream.
|
|
1363
|
+
const verdict = createMemo(() => sync.data.session_goal?.[props.message.sessionID]?.verdicts?.[props.message.id])
|
|
1364
|
+
const [verdictOpen, setVerdictOpen] = createSignal(false)
|
|
1365
|
+
const verdictMark = createMemo(() => {
|
|
1366
|
+
const v = verdict()
|
|
1367
|
+
if (!v) return undefined
|
|
1368
|
+
if (v.error) return { icon: "!", fg: theme.textMuted, label: "Judge: error (stopped)" }
|
|
1369
|
+
if (v.ok) return { icon: "✓", fg: theme.success, label: "Judge: met" }
|
|
1370
|
+
if (v.impossible) return { icon: "⊘", fg: theme.error, label: "Judge: impossible" }
|
|
1371
|
+
return { icon: "⟳", fg: theme.warning, label: `Judge [round ${v.attempt}]: not met` }
|
|
1372
|
+
})
|
|
1373
|
+
|
|
1374
|
+
return (
|
|
1375
|
+
<>
|
|
1376
|
+
<For each={props.parts}>
|
|
1377
|
+
{(part, index) => {
|
|
1378
|
+
const component = createMemo(() => PART_MAPPING[part.type as keyof typeof PART_MAPPING])
|
|
1379
|
+
return (
|
|
1380
|
+
<Show when={component()}>
|
|
1381
|
+
<Dynamic
|
|
1382
|
+
last={index() === props.parts.length - 1}
|
|
1383
|
+
component={component()}
|
|
1384
|
+
part={part as any}
|
|
1385
|
+
message={props.message}
|
|
1386
|
+
/>
|
|
1387
|
+
</Show>
|
|
1388
|
+
)
|
|
1389
|
+
}}
|
|
1390
|
+
</For>
|
|
1391
|
+
<Show when={props.parts.some((x) => x.type === "tool" && x.tool === "actor")}>
|
|
1392
|
+
<box paddingTop={1} paddingLeft={3}>
|
|
1393
|
+
<text fg={theme.text}>
|
|
1394
|
+
{keybind.print("session_child_first")}
|
|
1395
|
+
<span style={{ fg: theme.textMuted }}> view subagents</span>
|
|
1396
|
+
</text>
|
|
1397
|
+
</box>
|
|
1398
|
+
</Show>
|
|
1399
|
+
<Show when={props.message.error && props.message.error.name !== "MessageAbortedError"}>
|
|
1400
|
+
<ErrorBlock error={props.message.error!} />
|
|
1401
|
+
</Show>
|
|
1402
|
+
<Switch>
|
|
1403
|
+
<Match when={props.last || final() || props.message.error?.name === "MessageAbortedError"}>
|
|
1404
|
+
<box paddingLeft={3}>
|
|
1405
|
+
<text marginTop={1}>
|
|
1406
|
+
<span
|
|
1407
|
+
style={{
|
|
1408
|
+
fg:
|
|
1409
|
+
props.message.error?.name === "MessageAbortedError"
|
|
1410
|
+
? theme.textMuted
|
|
1411
|
+
: local.agent.color(props.message.agent),
|
|
1412
|
+
}}
|
|
1413
|
+
>
|
|
1414
|
+
▣{" "}
|
|
1415
|
+
</span>{" "}
|
|
1416
|
+
<span style={{ fg: theme.text }}>{Locale.titlecase(props.message.mode)}</span>
|
|
1417
|
+
<span style={{ fg: theme.textMuted }}> · {model()}</span>
|
|
1418
|
+
<Show when={duration()}>
|
|
1419
|
+
<span style={{ fg: theme.textMuted }}> · {Locale.duration(duration())}</span>
|
|
1420
|
+
</Show>
|
|
1421
|
+
<Show when={props.message.error?.name === "MessageAbortedError"}>
|
|
1422
|
+
<span style={{ fg: theme.textMuted }}> · interrupted</span>
|
|
1423
|
+
</Show>
|
|
1424
|
+
</text>
|
|
1425
|
+
</box>
|
|
1426
|
+
</Match>
|
|
1427
|
+
</Switch>
|
|
1428
|
+
<Show when={verdictMark()}>
|
|
1429
|
+
{(mark) => (
|
|
1430
|
+
<box paddingLeft={3} onMouseUp={() => setVerdictOpen((x) => !x)}>
|
|
1431
|
+
<text>
|
|
1432
|
+
<span style={{ fg: theme.textMuted }}>{verdictOpen() ? "▼" : "▶"} </span>
|
|
1433
|
+
<span style={{ fg: mark().fg }}>
|
|
1434
|
+
{mark().icon} {mark().label}
|
|
1435
|
+
</span>
|
|
1436
|
+
</text>
|
|
1437
|
+
<Show when={verdictOpen()}>
|
|
1438
|
+
<box paddingLeft={2}>
|
|
1439
|
+
<text fg={theme.textMuted} wrapMode="word">
|
|
1440
|
+
{verdict()!.reason}
|
|
1441
|
+
</text>
|
|
1442
|
+
</box>
|
|
1443
|
+
</Show>
|
|
1444
|
+
</box>
|
|
1445
|
+
)}
|
|
1446
|
+
</Show>
|
|
1447
|
+
</>
|
|
1448
|
+
)
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
const PART_MAPPING = {
|
|
1452
|
+
text: TextPart,
|
|
1453
|
+
tool: ToolPart,
|
|
1454
|
+
reasoning: ReasoningPart,
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
type MessageError = NonNullable<AssistantMessage["error"]>
|
|
1458
|
+
|
|
1459
|
+
function errorBody(error: MessageError): string {
|
|
1460
|
+
if (error.name === "MessageOutputLengthError") return "Output length limit reached"
|
|
1461
|
+
return (error.data as { message?: string }).message ?? "Unknown error"
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
function errorMeta(error: MessageError): string | undefined {
|
|
1465
|
+
if (error.name === "APIError") {
|
|
1466
|
+
const parts: string[] = []
|
|
1467
|
+
if (error.data.statusCode !== undefined) parts.push(`status ${error.data.statusCode}`)
|
|
1468
|
+
parts.push(error.data.isRetryable ? "retryable" : "non-retryable")
|
|
1469
|
+
return parts.join(" · ")
|
|
1470
|
+
}
|
|
1471
|
+
if (error.name === "ProviderAuthError") return `provider: ${error.data.providerID}`
|
|
1472
|
+
if (error.name === "StructuredOutputError") return `retries: ${error.data.retries}`
|
|
1473
|
+
return undefined
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
function ErrorBlock(props: { error: MessageError }) {
|
|
1477
|
+
const { theme } = useTheme()
|
|
1478
|
+
const meta = createMemo(() => errorMeta(props.error))
|
|
1479
|
+
return (
|
|
1480
|
+
<box flexDirection="column" paddingLeft={3} marginTop={1}>
|
|
1481
|
+
<text fg={theme.error} wrapMode="word">
|
|
1482
|
+
<span style={{ fg: theme.error }}>✗ </span>
|
|
1483
|
+
{errorBody(props.error)}
|
|
1484
|
+
</text>
|
|
1485
|
+
<Show when={meta()}>
|
|
1486
|
+
<box paddingLeft={3}>
|
|
1487
|
+
<text fg={theme.textMuted} wrapMode="word">
|
|
1488
|
+
{meta()}
|
|
1489
|
+
</text>
|
|
1490
|
+
</box>
|
|
1491
|
+
</Show>
|
|
1492
|
+
</box>
|
|
1493
|
+
)
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
function ReasoningPart(props: { last: boolean; part: ReasoningPart; message: AssistantMessage }) {
|
|
1497
|
+
const { theme, subtleSyntax } = useTheme()
|
|
1498
|
+
const ctx = use()
|
|
1499
|
+
const [expanded, setExpanded] = createSignal(false)
|
|
1500
|
+
|
|
1501
|
+
const content = createMemo(() => {
|
|
1502
|
+
return props.part.text.replace("[REDACTED]", "").trim()
|
|
1503
|
+
})
|
|
1504
|
+
const isDone = createMemo(() => props.part.time.end !== undefined)
|
|
1505
|
+
const inMinimal = createMemo(() => ctx.thinkingMode() === "hide")
|
|
1506
|
+
const duration = createMemo(() => {
|
|
1507
|
+
const end = props.part.time.end
|
|
1508
|
+
return end === undefined ? 0 : Math.max(0, end - props.part.time.start)
|
|
1509
|
+
})
|
|
1510
|
+
const summary = createMemo(() => reasoningSummary(content()))
|
|
1511
|
+
|
|
1512
|
+
const toggle = () => {
|
|
1513
|
+
if (!inMinimal()) return
|
|
1514
|
+
setExpanded((prev) => !prev)
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
return (
|
|
1518
|
+
<Show when={content()}>
|
|
1519
|
+
<box id={"text-" + props.part.id} paddingLeft={3} marginTop={1} flexDirection="column" flexShrink={0}>
|
|
1520
|
+
<box onMouseUp={toggle}>
|
|
1521
|
+
<ReasoningHeader
|
|
1522
|
+
toggleable={inMinimal()}
|
|
1523
|
+
open={!inMinimal() || expanded()}
|
|
1524
|
+
done={isDone()}
|
|
1525
|
+
title={summary().title}
|
|
1526
|
+
duration={isDone() ? Locale.duration(duration()) : undefined}
|
|
1527
|
+
/>
|
|
1528
|
+
</box>
|
|
1529
|
+
<Show when={(!inMinimal() || expanded()) && summary().body}>
|
|
1530
|
+
<box paddingLeft={inMinimal() ? 2 : 0} marginTop={1}>
|
|
1531
|
+
<code
|
|
1532
|
+
filetype="markdown"
|
|
1533
|
+
drawUnstyledText={false}
|
|
1534
|
+
streaming={true}
|
|
1535
|
+
syntaxStyle={subtleSyntax()}
|
|
1536
|
+
content={summary().body}
|
|
1537
|
+
conceal={ctx.conceal()}
|
|
1538
|
+
fg={theme.textMuted}
|
|
1539
|
+
/>
|
|
1540
|
+
</box>
|
|
1541
|
+
</Show>
|
|
1542
|
+
</box>
|
|
1543
|
+
</Show>
|
|
1544
|
+
)
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
function ReasoningHeader(props: {
|
|
1548
|
+
toggleable: boolean
|
|
1549
|
+
open: boolean
|
|
1550
|
+
done: boolean
|
|
1551
|
+
title: string | null
|
|
1552
|
+
duration?: string
|
|
1553
|
+
}) {
|
|
1554
|
+
const { theme } = useTheme()
|
|
1555
|
+
const fg = () =>
|
|
1556
|
+
props.open
|
|
1557
|
+
? RGBA.fromValues(theme.warning.r, theme.warning.g, theme.warning.b, theme.thinkingOpacity)
|
|
1558
|
+
: theme.warning
|
|
1559
|
+
|
|
1560
|
+
return (
|
|
1561
|
+
<Switch>
|
|
1562
|
+
<Match when={!props.done}>
|
|
1563
|
+
<box flexDirection="row">
|
|
1564
|
+
<Spinner color={fg()}>{props.title ? "Thinking: " + props.title : "Thinking"}</Spinner>
|
|
1565
|
+
</box>
|
|
1566
|
+
</Match>
|
|
1567
|
+
<Match when={true}>
|
|
1568
|
+
<text fg={fg()} wrapMode="none">
|
|
1569
|
+
<Show when={props.toggleable}>
|
|
1570
|
+
<span>{props.open ? "- " : "+ "}</span>
|
|
1571
|
+
</Show>
|
|
1572
|
+
<span>Thought</span>
|
|
1573
|
+
<Show when={props.title || props.duration}>
|
|
1574
|
+
<span>: </span>
|
|
1575
|
+
</Show>
|
|
1576
|
+
<Show when={props.title}>
|
|
1577
|
+
<span>{props.title}</span>
|
|
1578
|
+
</Show>
|
|
1579
|
+
<Show when={props.duration}>
|
|
1580
|
+
<span>
|
|
1581
|
+
{props.title ? " · " : ""}
|
|
1582
|
+
{props.duration}
|
|
1583
|
+
</span>
|
|
1584
|
+
</Show>
|
|
1585
|
+
</text>
|
|
1586
|
+
</Match>
|
|
1587
|
+
</Switch>
|
|
1588
|
+
)
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
function TextPart(props: { last: boolean; part: TextPart; message: AssistantMessage }) {
|
|
1592
|
+
const ctx = use()
|
|
1593
|
+
const { theme, syntax } = useTheme()
|
|
1594
|
+
return (
|
|
1595
|
+
<Show when={props.part.text.trim()}>
|
|
1596
|
+
<box id={"text-" + props.part.id} paddingLeft={3} marginTop={1} flexShrink={0}>
|
|
1597
|
+
<Switch>
|
|
1598
|
+
<Match when={Flag.tulingcode_EXPERIMENTAL_MARKDOWN}>
|
|
1599
|
+
<markdown
|
|
1600
|
+
syntaxStyle={syntax()}
|
|
1601
|
+
streaming={true}
|
|
1602
|
+
content={props.part.text.trim()}
|
|
1603
|
+
conceal={ctx.conceal()}
|
|
1604
|
+
fg={theme.markdownText}
|
|
1605
|
+
bg={theme.background}
|
|
1606
|
+
/>
|
|
1607
|
+
</Match>
|
|
1608
|
+
<Match when={!Flag.tulingcode_EXPERIMENTAL_MARKDOWN}>
|
|
1609
|
+
<code
|
|
1610
|
+
filetype="markdown"
|
|
1611
|
+
drawUnstyledText={false}
|
|
1612
|
+
streaming={true}
|
|
1613
|
+
syntaxStyle={syntax()}
|
|
1614
|
+
content={props.part.text.trim()}
|
|
1615
|
+
conceal={ctx.conceal()}
|
|
1616
|
+
fg={theme.text}
|
|
1617
|
+
/>
|
|
1618
|
+
</Match>
|
|
1619
|
+
</Switch>
|
|
1620
|
+
</box>
|
|
1621
|
+
</Show>
|
|
1622
|
+
)
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
// Pending messages moved to individual tool pending functions
|
|
1626
|
+
|
|
1627
|
+
function ToolPart(props: { last: boolean; part: ToolPart; message: AssistantMessage }) {
|
|
1628
|
+
const ctx = use()
|
|
1629
|
+
const sync = useSync()
|
|
1630
|
+
|
|
1631
|
+
// Hide tool if showDetails is false and tool completed successfully
|
|
1632
|
+
const shouldHide = createMemo(() => {
|
|
1633
|
+
if (ctx.showDetails()) return false
|
|
1634
|
+
if (props.part.state.status !== "completed") return false
|
|
1635
|
+
return true
|
|
1636
|
+
})
|
|
1637
|
+
|
|
1638
|
+
const toolprops = {
|
|
1639
|
+
get metadata() {
|
|
1640
|
+
return props.part.state.status === "pending" ? {} : (props.part.state.metadata ?? {})
|
|
1641
|
+
},
|
|
1642
|
+
get input() {
|
|
1643
|
+
return props.part.state.input ?? {}
|
|
1644
|
+
},
|
|
1645
|
+
get output() {
|
|
1646
|
+
return props.part.state.status === "completed" ? props.part.state.output : undefined
|
|
1647
|
+
},
|
|
1648
|
+
get permission() {
|
|
1649
|
+
const permissions = sync.data.permission[props.message.sessionID] ?? []
|
|
1650
|
+
const permissionIndex = permissions.findIndex((x) => x.tool?.callID === props.part.callID)
|
|
1651
|
+
return permissions[permissionIndex]
|
|
1652
|
+
},
|
|
1653
|
+
get tool() {
|
|
1654
|
+
return props.part.tool
|
|
1655
|
+
},
|
|
1656
|
+
get part() {
|
|
1657
|
+
return props.part
|
|
1658
|
+
},
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
return (
|
|
1662
|
+
<Show when={!shouldHide()}>
|
|
1663
|
+
<Switch>
|
|
1664
|
+
<Match when={props.part.tool === "bash"}>
|
|
1665
|
+
<Bash {...toolprops} />
|
|
1666
|
+
</Match>
|
|
1667
|
+
<Match when={props.part.tool === "glob"}>
|
|
1668
|
+
<Glob {...toolprops} />
|
|
1669
|
+
</Match>
|
|
1670
|
+
<Match when={props.part.tool === "read"}>
|
|
1671
|
+
<Read {...toolprops} />
|
|
1672
|
+
</Match>
|
|
1673
|
+
<Match when={props.part.tool === "grep"}>
|
|
1674
|
+
<Grep {...toolprops} />
|
|
1675
|
+
</Match>
|
|
1676
|
+
<Match when={props.part.tool === "webfetch"}>
|
|
1677
|
+
<WebFetch {...toolprops} />
|
|
1678
|
+
</Match>
|
|
1679
|
+
<Match when={props.part.tool === "codesearch"}>
|
|
1680
|
+
<CodeSearch {...toolprops} />
|
|
1681
|
+
</Match>
|
|
1682
|
+
<Match when={props.part.tool === "websearch"}>
|
|
1683
|
+
<WebSearch {...toolprops} />
|
|
1684
|
+
</Match>
|
|
1685
|
+
<Match when={props.part.tool === "write"}>
|
|
1686
|
+
<Write {...toolprops} />
|
|
1687
|
+
</Match>
|
|
1688
|
+
<Match when={props.part.tool === "edit"}>
|
|
1689
|
+
<Edit {...toolprops} />
|
|
1690
|
+
</Match>
|
|
1691
|
+
<Match when={props.part.tool === "actor"}>
|
|
1692
|
+
<Task {...toolprops} />
|
|
1693
|
+
</Match>
|
|
1694
|
+
<Match when={props.part.tool === "task"}>
|
|
1695
|
+
<WorkItemTask {...toolprops} />
|
|
1696
|
+
</Match>
|
|
1697
|
+
<Match when={props.part.tool === "apply_patch"}>
|
|
1698
|
+
<ApplyPatch {...toolprops} />
|
|
1699
|
+
</Match>
|
|
1700
|
+
<Match when={props.part.tool === "question"}>
|
|
1701
|
+
<Question {...toolprops} />
|
|
1702
|
+
</Match>
|
|
1703
|
+
<Match when={props.part.tool === "skill"}>
|
|
1704
|
+
<Skill {...toolprops} />
|
|
1705
|
+
</Match>
|
|
1706
|
+
<Match when={props.part.tool === "plan_exit"}>
|
|
1707
|
+
<PlanExit {...toolprops} />
|
|
1708
|
+
</Match>
|
|
1709
|
+
<Match when={true}>
|
|
1710
|
+
<GenericTool {...toolprops} />
|
|
1711
|
+
</Match>
|
|
1712
|
+
</Switch>
|
|
1713
|
+
</Show>
|
|
1714
|
+
)
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
type ToolProps<T> = {
|
|
1718
|
+
input: Partial<Tool.InferParameters<T>>
|
|
1719
|
+
metadata: Partial<Tool.InferMetadata<T>>
|
|
1720
|
+
permission: Record<string, any>
|
|
1721
|
+
tool: string
|
|
1722
|
+
output?: string
|
|
1723
|
+
part: ToolPart
|
|
1724
|
+
}
|
|
1725
|
+
function PlanExit(props: ToolProps<any>) {
|
|
1726
|
+
const { theme } = useTheme()
|
|
1727
|
+
const dismissed = createMemo(
|
|
1728
|
+
() => props.part.state.status === "completed" && props.part.state.metadata?.switched === false,
|
|
1729
|
+
)
|
|
1730
|
+
const feedback = createMemo(() => (dismissed() ? props.metadata.feedback : undefined))
|
|
1731
|
+
|
|
1732
|
+
return (
|
|
1733
|
+
<>
|
|
1734
|
+
<InlineTool icon="⚙" pending="Asking..." complete={true} part={props.part} dismissed={dismissed()}>
|
|
1735
|
+
plan_exit
|
|
1736
|
+
</InlineTool>
|
|
1737
|
+
<Show when={feedback()}>
|
|
1738
|
+
<box paddingLeft={6}>
|
|
1739
|
+
<text fg={theme.textMuted}>{feedback()}</text>
|
|
1740
|
+
</box>
|
|
1741
|
+
</Show>
|
|
1742
|
+
</>
|
|
1743
|
+
)
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
function GenericTool(props: ToolProps<any>) {
|
|
1747
|
+
const { theme } = useTheme()
|
|
1748
|
+
const ctx = use()
|
|
1749
|
+
const output = createMemo(() => props.output?.trim() ?? "")
|
|
1750
|
+
const [expanded, setExpanded] = createSignal(false)
|
|
1751
|
+
const lines = createMemo(() => output().split("\n"))
|
|
1752
|
+
const maxLines = 3
|
|
1753
|
+
const overflow = createMemo(() => lines().length > maxLines)
|
|
1754
|
+
const limited = createMemo(() => {
|
|
1755
|
+
if (expanded() || !overflow()) return output()
|
|
1756
|
+
return [...lines().slice(0, maxLines), "…"].join("\n")
|
|
1757
|
+
})
|
|
1758
|
+
|
|
1759
|
+
return (
|
|
1760
|
+
<Show
|
|
1761
|
+
when={props.output && ctx.showGenericToolOutput()}
|
|
1762
|
+
fallback={
|
|
1763
|
+
<InlineTool icon="⚙" pending="Writing command..." complete={true} part={props.part}>
|
|
1764
|
+
{props.tool} {input(props.input)}
|
|
1765
|
+
</InlineTool>
|
|
1766
|
+
}
|
|
1767
|
+
>
|
|
1768
|
+
<BlockTool
|
|
1769
|
+
title={`# ${props.tool} ${input(props.input)}`}
|
|
1770
|
+
part={props.part}
|
|
1771
|
+
onClick={overflow() ? () => setExpanded((prev) => !prev) : undefined}
|
|
1772
|
+
>
|
|
1773
|
+
<box gap={1}>
|
|
1774
|
+
<text fg={theme.text}>{limited()}</text>
|
|
1775
|
+
<Show when={overflow()}>
|
|
1776
|
+
<text fg={theme.textMuted}>{expanded() ? "Click to collapse" : "Click to expand"}</text>
|
|
1777
|
+
</Show>
|
|
1778
|
+
</box>
|
|
1779
|
+
</BlockTool>
|
|
1780
|
+
</Show>
|
|
1781
|
+
)
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
// Inline renderer for the work-item `task` tool (distinct from <Task>, which
|
|
1785
|
+
// renders the subagent-spawning `actor` tool). Shows the operation as a concise
|
|
1786
|
+
// one-liner derived from the nested `{ operation: { action } }` discriminator,
|
|
1787
|
+
// so task create/start/done don't fall through to GenericTool's raw-JSON dump.
|
|
1788
|
+
function WorkItemTask(props: ToolProps<typeof TaskTool>) {
|
|
1789
|
+
const summary = createMemo(() => {
|
|
1790
|
+
const op = (props.input as { operation?: Record<string, any> }).operation
|
|
1791
|
+
if (!op || typeof op !== "object") return "task"
|
|
1792
|
+
const verb = typeof op.action === "string" ? op.action : "task"
|
|
1793
|
+
if (verb === "create") return op.summary ? `create "${op.summary}"` : "create"
|
|
1794
|
+
if (verb === "list") return op.status ? `list ${op.status}` : "list"
|
|
1795
|
+
if (op.id) return `${verb} ${op.id}`
|
|
1796
|
+
return verb
|
|
1797
|
+
})
|
|
1798
|
+
return (
|
|
1799
|
+
<InlineTool icon="#" pending="Updating tasks..." complete={true} part={props.part}>
|
|
1800
|
+
task {summary()}
|
|
1801
|
+
</InlineTool>
|
|
1802
|
+
)
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
function CollapsibleError(props: { error: string; paddingLeft?: number }) {
|
|
1806
|
+
const { theme } = useTheme()
|
|
1807
|
+
const renderer = useRenderer()
|
|
1808
|
+
const [expanded, setExpanded] = createSignal(false)
|
|
1809
|
+
|
|
1810
|
+
|
|
1811
|
+
const lineCount = createMemo(() => props.error.split("\n").length)
|
|
1812
|
+
|
|
1813
|
+
return (
|
|
1814
|
+
<box
|
|
1815
|
+
paddingLeft={props.paddingLeft}
|
|
1816
|
+
onMouseUp={(evt) => {
|
|
1817
|
+
evt.stopPropagation()
|
|
1818
|
+
if (renderer.getSelection()?.getSelectedText()) return
|
|
1819
|
+
setExpanded((prev) => !prev)
|
|
1820
|
+
}}
|
|
1821
|
+
>
|
|
1822
|
+
<Show
|
|
1823
|
+
when={expanded()}
|
|
1824
|
+
fallback={
|
|
1825
|
+
<text fg={theme.error}>
|
|
1826
|
+
+ Error ({lineCount()} {lineCount() === 1 ? "line" : "lines"})
|
|
1827
|
+
</text>
|
|
1828
|
+
}
|
|
1829
|
+
>
|
|
1830
|
+
<text fg={theme.error}>- Error</text>
|
|
1831
|
+
<box paddingLeft={2}>
|
|
1832
|
+
<text fg={theme.error}>{props.error}</text>
|
|
1833
|
+
</box>
|
|
1834
|
+
</Show>
|
|
1835
|
+
</box>
|
|
1836
|
+
)
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
function InlineTool(props: {
|
|
1840
|
+
icon: string
|
|
1841
|
+
iconColor?: RGBA
|
|
1842
|
+
complete: any
|
|
1843
|
+
pending: string
|
|
1844
|
+
spinner?: boolean
|
|
1845
|
+
dismissed?: boolean
|
|
1846
|
+
children: JSX.Element
|
|
1847
|
+
part: ToolPart
|
|
1848
|
+
onClick?: () => void
|
|
1849
|
+
}) {
|
|
1850
|
+
const [margin, setMargin] = createSignal(0)
|
|
1851
|
+
const { theme } = useTheme()
|
|
1852
|
+
const ctx = use()
|
|
1853
|
+
const sync = useSync()
|
|
1854
|
+
const renderer = useRenderer()
|
|
1855
|
+
const [hover, setHover] = createSignal(false)
|
|
1856
|
+
|
|
1857
|
+
const permission = createMemo(() => {
|
|
1858
|
+
const callID = sync.data.permission[ctx.sessionID]?.at(0)?.tool?.callID
|
|
1859
|
+
if (!callID) return false
|
|
1860
|
+
return callID === props.part.callID
|
|
1861
|
+
})
|
|
1862
|
+
|
|
1863
|
+
const fg = createMemo(() => {
|
|
1864
|
+
if (permission()) return theme.warning
|
|
1865
|
+
if (hover() && props.onClick) return theme.text
|
|
1866
|
+
if (props.complete) return theme.textMuted
|
|
1867
|
+
return theme.text
|
|
1868
|
+
})
|
|
1869
|
+
|
|
1870
|
+
const error = createMemo(() => (props.part.state.status === "error" ? props.part.state.error : undefined))
|
|
1871
|
+
|
|
1872
|
+
const denied = createMemo(
|
|
1873
|
+
() =>
|
|
1874
|
+
error()?.includes("QuestionRejectedError") ||
|
|
1875
|
+
error()?.includes("rejected permission") ||
|
|
1876
|
+
error()?.includes("specified a rule") ||
|
|
1877
|
+
error()?.includes("user dismissed"),
|
|
1878
|
+
)
|
|
1879
|
+
|
|
1880
|
+
return (
|
|
1881
|
+
<box
|
|
1882
|
+
marginTop={margin()}
|
|
1883
|
+
paddingLeft={3}
|
|
1884
|
+
onMouseOver={() => props.onClick && setHover(true)}
|
|
1885
|
+
onMouseOut={() => setHover(false)}
|
|
1886
|
+
onMouseUp={() => {
|
|
1887
|
+
if (renderer.getSelection()?.getSelectedText()) return
|
|
1888
|
+
props.onClick?.()
|
|
1889
|
+
}}
|
|
1890
|
+
renderBefore={function () {
|
|
1891
|
+
const el = this as BoxRenderable
|
|
1892
|
+
const parent = el.parent
|
|
1893
|
+
if (!parent) {
|
|
1894
|
+
return
|
|
1895
|
+
}
|
|
1896
|
+
if (el.height > 1) {
|
|
1897
|
+
setMargin(1)
|
|
1898
|
+
return
|
|
1899
|
+
}
|
|
1900
|
+
const children = parent.getChildren()
|
|
1901
|
+
const index = children.indexOf(el)
|
|
1902
|
+
const previous = children[index - 1]
|
|
1903
|
+
if (!previous) {
|
|
1904
|
+
setMargin(0)
|
|
1905
|
+
return
|
|
1906
|
+
}
|
|
1907
|
+
if (previous.height > 1 || previous.id.startsWith("text-")) {
|
|
1908
|
+
setMargin(1)
|
|
1909
|
+
return
|
|
1910
|
+
}
|
|
1911
|
+
}}
|
|
1912
|
+
>
|
|
1913
|
+
<Switch>
|
|
1914
|
+
<Match when={props.spinner}>
|
|
1915
|
+
<Spinner color={fg()} children={props.children} />
|
|
1916
|
+
</Match>
|
|
1917
|
+
<Match when={true}>
|
|
1918
|
+
<text paddingLeft={3} fg={fg()} attributes={denied() || props.dismissed ? TextAttributes.STRIKETHROUGH : undefined}>
|
|
1919
|
+
<Show fallback={<>~ {props.pending}</>} when={props.complete}>
|
|
1920
|
+
<span style={{ fg: props.iconColor }}>{props.icon}</span> {props.children}
|
|
1921
|
+
</Show>
|
|
1922
|
+
</text>
|
|
1923
|
+
</Match>
|
|
1924
|
+
</Switch>
|
|
1925
|
+
<Show when={error() && !denied()}>
|
|
1926
|
+
<CollapsibleError error={error()!} paddingLeft={3} />
|
|
1927
|
+
</Show>
|
|
1928
|
+
</box>
|
|
1929
|
+
)
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
function BlockTool(props: {
|
|
1933
|
+
title: string
|
|
1934
|
+
children: JSX.Element
|
|
1935
|
+
onClick?: () => void
|
|
1936
|
+
part?: ToolPart
|
|
1937
|
+
spinner?: boolean
|
|
1938
|
+
}) {
|
|
1939
|
+
const { theme } = useTheme()
|
|
1940
|
+
const renderer = useRenderer()
|
|
1941
|
+
const [hover, setHover] = createSignal(false)
|
|
1942
|
+
const error = createMemo(() => (props.part?.state.status === "error" ? props.part.state.error : undefined))
|
|
1943
|
+
return (
|
|
1944
|
+
<box
|
|
1945
|
+
border={["left"]}
|
|
1946
|
+
paddingTop={1}
|
|
1947
|
+
paddingBottom={1}
|
|
1948
|
+
paddingLeft={2}
|
|
1949
|
+
marginTop={1}
|
|
1950
|
+
gap={1}
|
|
1951
|
+
backgroundColor={hover() ? theme.backgroundMenu : theme.backgroundPanel}
|
|
1952
|
+
customBorderChars={SplitBorder.customBorderChars}
|
|
1953
|
+
borderColor={theme.background}
|
|
1954
|
+
onMouseOver={() => props.onClick && setHover(true)}
|
|
1955
|
+
onMouseOut={() => setHover(false)}
|
|
1956
|
+
onMouseUp={() => {
|
|
1957
|
+
if (renderer.getSelection()?.getSelectedText()) return
|
|
1958
|
+
props.onClick?.()
|
|
1959
|
+
}}
|
|
1960
|
+
>
|
|
1961
|
+
<Show
|
|
1962
|
+
when={props.spinner}
|
|
1963
|
+
fallback={
|
|
1964
|
+
<text paddingLeft={3} fg={theme.textMuted}>
|
|
1965
|
+
{props.title}
|
|
1966
|
+
</text>
|
|
1967
|
+
}
|
|
1968
|
+
>
|
|
1969
|
+
<Spinner color={theme.textMuted}>{props.title.replace(/^# /, "")}</Spinner>
|
|
1970
|
+
</Show>
|
|
1971
|
+
{props.children}
|
|
1972
|
+
<Show when={error()}>
|
|
1973
|
+
<CollapsibleError error={error()!} />
|
|
1974
|
+
</Show>
|
|
1975
|
+
</box>
|
|
1976
|
+
)
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
const TOOL_COLLAPSE_MAX_LINES = 3
|
|
1980
|
+
const TOOL_COLLAPSE_MAX_LINE_LENGTH = 120
|
|
1981
|
+
|
|
1982
|
+
function displayLines(content: string) {
|
|
1983
|
+
if (!content) return []
|
|
1984
|
+
return content.replace(/\n$/, "").split("\n")
|
|
1985
|
+
}
|
|
1986
|
+
|
|
1987
|
+
function hasLongDisplayLine(content: string) {
|
|
1988
|
+
return displayLines(content).some((line) => line.length > TOOL_COLLAPSE_MAX_LINE_LENGTH)
|
|
1989
|
+
}
|
|
1990
|
+
|
|
1991
|
+
function Bash(props: ToolProps<typeof BashTool>) {
|
|
1992
|
+
const { theme } = useTheme()
|
|
1993
|
+
const sync = useSync()
|
|
1994
|
+
const isRunning = createMemo(() => props.part.state.status === "running")
|
|
1995
|
+
const output = createMemo(() => stripAnsi(props.metadata.output?.trim() ?? ""))
|
|
1996
|
+
const [expanded, setExpanded] = createSignal(false)
|
|
1997
|
+
const lines = createMemo(() => output().split("\n"))
|
|
1998
|
+
const overflow = createMemo(() => lines().length > 10)
|
|
1999
|
+
const limited = createMemo(() => {
|
|
2000
|
+
if (expanded() || !overflow()) return output()
|
|
2001
|
+
return [...lines().slice(0, 10), "…"].join("\n")
|
|
2002
|
+
})
|
|
2003
|
+
|
|
2004
|
+
const workdirDisplay = createMemo(() => {
|
|
2005
|
+
const workdir = props.input.workdir
|
|
2006
|
+
if (!workdir || workdir === ".") return undefined
|
|
2007
|
+
|
|
2008
|
+
const base = sync.path.directory
|
|
2009
|
+
if (!base) return undefined
|
|
2010
|
+
|
|
2011
|
+
const absolute = path.resolve(base, workdir)
|
|
2012
|
+
if (absolute === base) return undefined
|
|
2013
|
+
|
|
2014
|
+
const home = Global.Path.home
|
|
2015
|
+
if (!home) return absolute
|
|
2016
|
+
|
|
2017
|
+
const match = absolute === home || absolute.startsWith(home + path.sep)
|
|
2018
|
+
return match ? absolute.replace(home, "~") : absolute
|
|
2019
|
+
})
|
|
2020
|
+
|
|
2021
|
+
const title = createMemo(() => {
|
|
2022
|
+
const desc = props.input.description ?? "Shell"
|
|
2023
|
+
const wd = workdirDisplay()
|
|
2024
|
+
if (!wd) return `# ${desc}`
|
|
2025
|
+
if (desc.includes(wd)) return `# ${desc}`
|
|
2026
|
+
return `# ${desc} in ${wd}`
|
|
2027
|
+
})
|
|
2028
|
+
|
|
2029
|
+
return (
|
|
2030
|
+
<Switch>
|
|
2031
|
+
<Match when={props.metadata.output !== undefined}>
|
|
2032
|
+
<BlockTool
|
|
2033
|
+
title={title()}
|
|
2034
|
+
part={props.part}
|
|
2035
|
+
spinner={isRunning()}
|
|
2036
|
+
onClick={overflow() ? () => setExpanded((prev) => !prev) : undefined}
|
|
2037
|
+
>
|
|
2038
|
+
<box gap={1}>
|
|
2039
|
+
<text fg={theme.text}>$ {props.input.command}</text>
|
|
2040
|
+
<Show when={output()}>
|
|
2041
|
+
<text fg={theme.text}>{limited()}</text>
|
|
2042
|
+
</Show>
|
|
2043
|
+
<Show when={overflow()}>
|
|
2044
|
+
<text fg={theme.textMuted}>{expanded() ? "Click to collapse" : "Click to expand"}</text>
|
|
2045
|
+
</Show>
|
|
2046
|
+
</box>
|
|
2047
|
+
</BlockTool>
|
|
2048
|
+
</Match>
|
|
2049
|
+
<Match when={true}>
|
|
2050
|
+
<InlineTool icon="$" pending="Writing command..." complete={props.input.command} part={props.part}>
|
|
2051
|
+
{props.input.command}
|
|
2052
|
+
</InlineTool>
|
|
2053
|
+
</Match>
|
|
2054
|
+
</Switch>
|
|
2055
|
+
)
|
|
2056
|
+
}
|
|
2057
|
+
|
|
2058
|
+
function Write(props: ToolProps<typeof WriteTool>) {
|
|
2059
|
+
const { theme, syntax } = useTheme()
|
|
2060
|
+
const [expanded, setExpanded] = createSignal(false)
|
|
2061
|
+
const code = createMemo(() => {
|
|
2062
|
+
if (!props.input.content) return ""
|
|
2063
|
+
return props.input.content
|
|
2064
|
+
})
|
|
2065
|
+
const lineCount = createMemo(() => displayLines(code()).length)
|
|
2066
|
+
const collapsed = createMemo(() => lineCount() > TOOL_COLLAPSE_MAX_LINES || hasLongDisplayLine(code()))
|
|
2067
|
+
|
|
2068
|
+
return (
|
|
2069
|
+
<Switch>
|
|
2070
|
+
<Match when={props.metadata.diagnostics !== undefined}>
|
|
2071
|
+
<BlockTool
|
|
2072
|
+
title={"# Wrote " + normalizePath(props.input.filePath!)}
|
|
2073
|
+
part={props.part}
|
|
2074
|
+
onClick={collapsed() ? () => setExpanded((prev) => !prev) : undefined}
|
|
2075
|
+
>
|
|
2076
|
+
<Show
|
|
2077
|
+
when={!collapsed() || expanded()}
|
|
2078
|
+
fallback={
|
|
2079
|
+
<text fg={theme.textMuted}>
|
|
2080
|
+
Click to expand ({lineCount()} {lineCount() === 1 ? "line" : "lines"})
|
|
2081
|
+
</text>
|
|
2082
|
+
}
|
|
2083
|
+
>
|
|
2084
|
+
<line_number fg={theme.textMuted} minWidth={3} paddingRight={1}>
|
|
2085
|
+
<code
|
|
2086
|
+
conceal={false}
|
|
2087
|
+
fg={theme.text}
|
|
2088
|
+
filetype={filetype(props.input.filePath!)}
|
|
2089
|
+
syntaxStyle={syntax()}
|
|
2090
|
+
content={code()}
|
|
2091
|
+
/>
|
|
2092
|
+
</line_number>
|
|
2093
|
+
<Show when={collapsed()}>
|
|
2094
|
+
<text fg={theme.textMuted}>Click to collapse</text>
|
|
2095
|
+
</Show>
|
|
2096
|
+
</Show>
|
|
2097
|
+
<Diagnostics diagnostics={props.metadata.diagnostics} filePath={props.input.filePath ?? ""} />
|
|
2098
|
+
</BlockTool>
|
|
2099
|
+
</Match>
|
|
2100
|
+
<Match when={true}>
|
|
2101
|
+
<InlineTool icon="←" pending="Preparing write..." complete={props.input.filePath} part={props.part}>
|
|
2102
|
+
Write {normalizePath(props.input.filePath!)}
|
|
2103
|
+
</InlineTool>
|
|
2104
|
+
</Match>
|
|
2105
|
+
</Switch>
|
|
2106
|
+
)
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
function Glob(props: ToolProps<typeof GlobTool>) {
|
|
2110
|
+
return (
|
|
2111
|
+
<InlineTool icon="✱" pending="Finding files..." complete={props.input.pattern} part={props.part}>
|
|
2112
|
+
Glob "{props.input.pattern}" <Show when={props.input.path}>in {normalizePath(props.input.path)} </Show>
|
|
2113
|
+
<Show when={props.metadata.count}>
|
|
2114
|
+
({props.metadata.count} {props.metadata.count === 1 ? "match" : "matches"})
|
|
2115
|
+
</Show>
|
|
2116
|
+
</InlineTool>
|
|
2117
|
+
)
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
function Read(props: ToolProps<typeof ReadTool>) {
|
|
2121
|
+
const { theme } = useTheme()
|
|
2122
|
+
const isRunning = createMemo(() => props.part.state.status === "running")
|
|
2123
|
+
const loaded = createMemo(() => {
|
|
2124
|
+
if (props.part.state.status !== "completed") return []
|
|
2125
|
+
if (props.part.state.time.compacted) return []
|
|
2126
|
+
const value = props.metadata.loaded
|
|
2127
|
+
if (!value || !Array.isArray(value)) return []
|
|
2128
|
+
return value.filter((p): p is string => typeof p === "string")
|
|
2129
|
+
})
|
|
2130
|
+
return (
|
|
2131
|
+
<>
|
|
2132
|
+
<InlineTool
|
|
2133
|
+
icon="→"
|
|
2134
|
+
pending="Reading file..."
|
|
2135
|
+
complete={props.input.filePath}
|
|
2136
|
+
spinner={isRunning()}
|
|
2137
|
+
part={props.part}
|
|
2138
|
+
>
|
|
2139
|
+
Read {normalizePath(props.input.filePath!)} {input(props.input, ["filePath"])}
|
|
2140
|
+
</InlineTool>
|
|
2141
|
+
<For each={loaded()}>
|
|
2142
|
+
{(filepath) => (
|
|
2143
|
+
<box paddingLeft={3}>
|
|
2144
|
+
<text paddingLeft={3} fg={theme.textMuted}>
|
|
2145
|
+
↳ Loaded {normalizePath(filepath)}
|
|
2146
|
+
</text>
|
|
2147
|
+
</box>
|
|
2148
|
+
)}
|
|
2149
|
+
</For>
|
|
2150
|
+
</>
|
|
2151
|
+
)
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2154
|
+
function Grep(props: ToolProps<typeof GrepTool>) {
|
|
2155
|
+
return (
|
|
2156
|
+
<InlineTool icon="✱" pending="Searching content..." complete={props.input.pattern} part={props.part}>
|
|
2157
|
+
Grep "{props.input.pattern}" <Show when={props.input.path}>in {normalizePath(props.input.path)} </Show>
|
|
2158
|
+
<Show when={props.metadata.matches}>
|
|
2159
|
+
({props.metadata.matches} {props.metadata.matches === 1 ? "match" : "matches"})
|
|
2160
|
+
</Show>
|
|
2161
|
+
</InlineTool>
|
|
2162
|
+
)
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
function WebFetch(props: ToolProps<typeof WebFetchTool>) {
|
|
2166
|
+
return (
|
|
2167
|
+
<InlineTool icon="%" pending="Fetching from the web..." complete={props.input.url} part={props.part}>
|
|
2168
|
+
WebFetch {props.input.url}
|
|
2169
|
+
</InlineTool>
|
|
2170
|
+
)
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
function CodeSearch(props: ToolProps<typeof CodeSearchTool>) {
|
|
2174
|
+
const metadata = props.metadata as { results?: number }
|
|
2175
|
+
return (
|
|
2176
|
+
<InlineTool icon="◇" pending="Searching code..." complete={props.input.query} part={props.part}>
|
|
2177
|
+
Exa Code Search "{props.input.query}" <Show when={metadata.results}>({metadata.results} results)</Show>
|
|
2178
|
+
</InlineTool>
|
|
2179
|
+
)
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
function WebSearch(props: ToolProps<typeof WebSearchTool>) {
|
|
2183
|
+
const metadata = props.metadata as { numResults?: number }
|
|
2184
|
+
return (
|
|
2185
|
+
<InlineTool icon="◈" pending="Searching web..." complete={props.input.query} part={props.part}>
|
|
2186
|
+
Web Search "{props.input.query}" <Show when={metadata.numResults}>({metadata.numResults} results)</Show>
|
|
2187
|
+
</InlineTool>
|
|
2188
|
+
)
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
function Task(props: ToolProps<typeof ActorTool>) {
|
|
2192
|
+
const route = useRoute()
|
|
2193
|
+
const sync = useSync()
|
|
2194
|
+
|
|
2195
|
+
// Spawn-shaped view: the Task display is meaningful only for run/spawn calls
|
|
2196
|
+
// (the only actions that create a delegated child session). status/wait/cancel
|
|
2197
|
+
// end up here with these fields undefined and the early returns below render empty.
|
|
2198
|
+
const raw = props.input as Partial<{ operation: { description: string; subagent_type: string } } & {
|
|
2199
|
+
description: string
|
|
2200
|
+
subagent_type: string
|
|
2201
|
+
}>
|
|
2202
|
+
const input: Partial<{ description: string; subagent_type: string }> = raw?.operation ?? raw
|
|
2203
|
+
|
|
2204
|
+
const targetSession = props.metadata.sessionId
|
|
2205
|
+
const targetBucket = (props.metadata.actorId as string | undefined) ?? "main"
|
|
2206
|
+
|
|
2207
|
+
onMount(() => {
|
|
2208
|
+
if (targetSession && !sync.data.message[targetSession]?.[targetBucket]?.length)
|
|
2209
|
+
void sync.session.sync(targetSession)
|
|
2210
|
+
})
|
|
2211
|
+
|
|
2212
|
+
const messages = createMemo(() => sync.data.message[targetSession ?? ""]?.[targetBucket] ?? [])
|
|
2213
|
+
|
|
2214
|
+
const tools = createMemo(() => {
|
|
2215
|
+
return messages().flatMap((msg) =>
|
|
2216
|
+
(sync.data.part[msg.id] ?? [])
|
|
2217
|
+
.filter((part): part is ToolPart => part.type === "tool")
|
|
2218
|
+
.map((part) => ({ tool: part.tool, state: part.state })),
|
|
2219
|
+
)
|
|
2220
|
+
})
|
|
2221
|
+
|
|
2222
|
+
const current = createMemo(() =>
|
|
2223
|
+
tools().findLast((x) => (x.state.status === "running" || x.state.status === "completed") && x.state.title),
|
|
2224
|
+
)
|
|
2225
|
+
|
|
2226
|
+
const isRunning = createMemo(() => props.part.state.status === "running")
|
|
2227
|
+
|
|
2228
|
+
const duration = createMemo(() => {
|
|
2229
|
+
const first = messages().find((x) => x.role === "user")?.time.created
|
|
2230
|
+
const assistant = messages().findLast((x) => x.role === "assistant")?.time.completed
|
|
2231
|
+
if (!first || !assistant) return 0
|
|
2232
|
+
return assistant - first
|
|
2233
|
+
})
|
|
2234
|
+
|
|
2235
|
+
const content = createMemo(() => {
|
|
2236
|
+
if (!input.description) return ""
|
|
2237
|
+
let content = [`${Locale.titlecase(input.subagent_type ?? "General")} Task — ${input.description}`]
|
|
2238
|
+
|
|
2239
|
+
if (isRunning() && tools().length > 0) {
|
|
2240
|
+
// content[0] += ` · ${tools().length} toolcalls`
|
|
2241
|
+
if (current()) {
|
|
2242
|
+
const state = current()!.state
|
|
2243
|
+
const title = state.status === "running" || state.status === "completed" ? state.title : undefined
|
|
2244
|
+
content.push(`↳ ${Locale.titlecase(current()!.tool)} ${title}`)
|
|
2245
|
+
} else content.push(`↳ ${tools().length} toolcalls`)
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2248
|
+
if (props.part.state.status === "completed") {
|
|
2249
|
+
content.push(`└ ${tools().length} toolcalls · ${Locale.duration(duration())}`)
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
return content.join("\n")
|
|
2253
|
+
})
|
|
2254
|
+
|
|
2255
|
+
return (
|
|
2256
|
+
<InlineTool
|
|
2257
|
+
icon="│"
|
|
2258
|
+
spinner={isRunning()}
|
|
2259
|
+
complete={input.description}
|
|
2260
|
+
pending="Delegating..."
|
|
2261
|
+
part={props.part}
|
|
2262
|
+
onClick={() => {
|
|
2263
|
+
const targetSession = props.metadata.sessionId
|
|
2264
|
+
const targetActor = props.metadata.actorId as string | undefined
|
|
2265
|
+
if (!targetSession) return
|
|
2266
|
+
if (
|
|
2267
|
+
route.data.type === "session" &&
|
|
2268
|
+
targetSession === route.data.sessionID &&
|
|
2269
|
+
targetActor
|
|
2270
|
+
) {
|
|
2271
|
+
// Subagent mode (shared sessionID): switch the agent slice in place.
|
|
2272
|
+
route.navigate({ ...route.data, agentID: targetActor })
|
|
2273
|
+
return
|
|
2274
|
+
}
|
|
2275
|
+
// Peer mode (different sessionID): navigate to peer's session, viewing its slice.
|
|
2276
|
+
route.navigate({ type: "session", sessionID: targetSession, agentID: targetActor })
|
|
2277
|
+
}}
|
|
2278
|
+
>
|
|
2279
|
+
{content()}
|
|
2280
|
+
</InlineTool>
|
|
2281
|
+
)
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
function Edit(props: ToolProps<typeof EditTool>) {
|
|
2285
|
+
const ctx = use()
|
|
2286
|
+
const { theme, syntax } = useTheme()
|
|
2287
|
+
|
|
2288
|
+
const view = createMemo(() => {
|
|
2289
|
+
const diffStyle = ctx.tui.diff_style
|
|
2290
|
+
if (diffStyle === "stacked") return "unified"
|
|
2291
|
+
// Default to "auto" behavior
|
|
2292
|
+
return ctx.width > 120 ? "split" : "unified"
|
|
2293
|
+
})
|
|
2294
|
+
|
|
2295
|
+
const ft = createMemo(() => filetype(props.input.filePath))
|
|
2296
|
+
|
|
2297
|
+
const diffContent = createMemo(() => props.metadata.diff)
|
|
2298
|
+
|
|
2299
|
+
return (
|
|
2300
|
+
<Switch>
|
|
2301
|
+
<Match when={props.metadata.diff !== undefined}>
|
|
2302
|
+
<BlockTool title={"← Edit " + normalizePath(props.input.filePath!)} part={props.part}>
|
|
2303
|
+
<box paddingLeft={1}>
|
|
2304
|
+
<diff
|
|
2305
|
+
diff={diffContent()}
|
|
2306
|
+
view={view()}
|
|
2307
|
+
filetype={ft()}
|
|
2308
|
+
syntaxStyle={syntax()}
|
|
2309
|
+
showLineNumbers={true}
|
|
2310
|
+
width="100%"
|
|
2311
|
+
wrapMode={ctx.diffWrapMode()}
|
|
2312
|
+
fg={theme.text}
|
|
2313
|
+
addedBg={theme.diffAddedBg}
|
|
2314
|
+
removedBg={theme.diffRemovedBg}
|
|
2315
|
+
contextBg={theme.diffContextBg}
|
|
2316
|
+
addedSignColor={theme.diffHighlightAdded}
|
|
2317
|
+
removedSignColor={theme.diffHighlightRemoved}
|
|
2318
|
+
lineNumberFg={theme.diffLineNumber}
|
|
2319
|
+
lineNumberBg={theme.diffContextBg}
|
|
2320
|
+
addedLineNumberBg={theme.diffAddedLineNumberBg}
|
|
2321
|
+
removedLineNumberBg={theme.diffRemovedLineNumberBg}
|
|
2322
|
+
/>
|
|
2323
|
+
</box>
|
|
2324
|
+
<Diagnostics diagnostics={props.metadata.diagnostics} filePath={props.input.filePath ?? ""} />
|
|
2325
|
+
</BlockTool>
|
|
2326
|
+
</Match>
|
|
2327
|
+
<Match when={true}>
|
|
2328
|
+
<InlineTool icon="←" pending="Preparing edit..." complete={props.input.filePath} part={props.part}>
|
|
2329
|
+
Edit {normalizePath(props.input.filePath!)} {input({ replaceAll: props.input.replaceAll })}
|
|
2330
|
+
</InlineTool>
|
|
2331
|
+
</Match>
|
|
2332
|
+
</Switch>
|
|
2333
|
+
)
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
function ApplyPatch(props: ToolProps<typeof ApplyPatchTool>) {
|
|
2337
|
+
const ctx = use()
|
|
2338
|
+
const { theme, syntax } = useTheme()
|
|
2339
|
+
const [expanded, setExpanded] = createSignal<string[]>([])
|
|
2340
|
+
|
|
2341
|
+
const files = createMemo(() => props.metadata.files ?? [])
|
|
2342
|
+
|
|
2343
|
+
const view = createMemo(() => {
|
|
2344
|
+
const diffStyle = ctx.tui.diff_style
|
|
2345
|
+
if (diffStyle === "stacked") return "unified"
|
|
2346
|
+
return ctx.width > 120 ? "split" : "unified"
|
|
2347
|
+
})
|
|
2348
|
+
|
|
2349
|
+
function Diff(p: { diff: string; filePath: string }) {
|
|
2350
|
+
return (
|
|
2351
|
+
<box paddingLeft={1}>
|
|
2352
|
+
<diff
|
|
2353
|
+
diff={p.diff}
|
|
2354
|
+
view={view()}
|
|
2355
|
+
filetype={filetype(p.filePath)}
|
|
2356
|
+
syntaxStyle={syntax()}
|
|
2357
|
+
showLineNumbers={true}
|
|
2358
|
+
width="100%"
|
|
2359
|
+
wrapMode={ctx.diffWrapMode()}
|
|
2360
|
+
fg={theme.text}
|
|
2361
|
+
addedBg={theme.diffAddedBg}
|
|
2362
|
+
removedBg={theme.diffRemovedBg}
|
|
2363
|
+
contextBg={theme.diffContextBg}
|
|
2364
|
+
addedSignColor={theme.diffHighlightAdded}
|
|
2365
|
+
removedSignColor={theme.diffHighlightRemoved}
|
|
2366
|
+
lineNumberFg={theme.diffLineNumber}
|
|
2367
|
+
lineNumberBg={theme.diffContextBg}
|
|
2368
|
+
addedLineNumberBg={theme.diffAddedLineNumberBg}
|
|
2369
|
+
removedLineNumberBg={theme.diffRemovedLineNumberBg}
|
|
2370
|
+
/>
|
|
2371
|
+
</box>
|
|
2372
|
+
)
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
function title(file: { type: string; relativePath: string; filePath: string; deletions: number }) {
|
|
2376
|
+
if (file.type === "delete") return "# Deleted " + file.relativePath
|
|
2377
|
+
if (file.type === "add") return "# Created " + file.relativePath
|
|
2378
|
+
if (file.type === "move") return "# Moved " + normalizePath(file.filePath) + " → " + file.relativePath
|
|
2379
|
+
return "← Patched " + file.relativePath
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
function toggle(filePath: string) {
|
|
2383
|
+
setExpanded((prev) => (prev.includes(filePath) ? prev.filter((item) => item !== filePath) : [...prev, filePath]))
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
return (
|
|
2387
|
+
<Switch>
|
|
2388
|
+
<Match when={files().length > 0}>
|
|
2389
|
+
<For each={files()}>
|
|
2390
|
+
{(file) => {
|
|
2391
|
+
const open = createMemo(() => expanded().includes(file.filePath))
|
|
2392
|
+
const count = createMemo(() => file.additions + file.deletions)
|
|
2393
|
+
const collapsed = createMemo(() => count() > TOOL_COLLAPSE_MAX_LINES || hasLongDisplayLine(file.patch))
|
|
2394
|
+
|
|
2395
|
+
return (
|
|
2396
|
+
<BlockTool
|
|
2397
|
+
title={title(file)}
|
|
2398
|
+
part={props.part}
|
|
2399
|
+
onClick={file.type !== "delete" && collapsed() ? () => toggle(file.filePath) : undefined}
|
|
2400
|
+
>
|
|
2401
|
+
<Show
|
|
2402
|
+
when={file.type !== "delete"}
|
|
2403
|
+
fallback={
|
|
2404
|
+
<text fg={theme.diffRemoved}>
|
|
2405
|
+
-{file.deletions} line{file.deletions !== 1 ? "s" : ""}
|
|
2406
|
+
</text>
|
|
2407
|
+
}
|
|
2408
|
+
>
|
|
2409
|
+
<Show
|
|
2410
|
+
when={!collapsed() || open()}
|
|
2411
|
+
fallback={
|
|
2412
|
+
<text fg={theme.textMuted}>
|
|
2413
|
+
Click to expand ({count()} change{count() !== 1 ? "s" : ""})
|
|
2414
|
+
</text>
|
|
2415
|
+
}
|
|
2416
|
+
>
|
|
2417
|
+
<Diff diff={file.patch} filePath={file.filePath} />
|
|
2418
|
+
<Show when={collapsed()}>
|
|
2419
|
+
<text fg={theme.textMuted}>Click to collapse</text>
|
|
2420
|
+
</Show>
|
|
2421
|
+
</Show>
|
|
2422
|
+
<Diagnostics diagnostics={props.metadata.diagnostics} filePath={file.movePath ?? file.filePath} />
|
|
2423
|
+
</Show>
|
|
2424
|
+
</BlockTool>
|
|
2425
|
+
)
|
|
2426
|
+
}}
|
|
2427
|
+
</For>
|
|
2428
|
+
</Match>
|
|
2429
|
+
<Match when={true}>
|
|
2430
|
+
<InlineTool icon="%" pending="Preparing patch..." complete={false} part={props.part}>
|
|
2431
|
+
Patch
|
|
2432
|
+
</InlineTool>
|
|
2433
|
+
</Match>
|
|
2434
|
+
</Switch>
|
|
2435
|
+
)
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
function Question(props: ToolProps<typeof QuestionTool>) {
|
|
2439
|
+
const { theme } = useTheme()
|
|
2440
|
+
const count = createMemo(() => props.input.questions?.length ?? 0)
|
|
2441
|
+
|
|
2442
|
+
function format(answer?: ReadonlyArray<string>) {
|
|
2443
|
+
if (!answer?.length) return "(no answer)"
|
|
2444
|
+
return answer.join(", ")
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
return (
|
|
2448
|
+
<Switch>
|
|
2449
|
+
<Match when={props.metadata.answers}>
|
|
2450
|
+
<BlockTool title="# Questions" part={props.part}>
|
|
2451
|
+
<box gap={1}>
|
|
2452
|
+
<For each={props.input.questions ?? []}>
|
|
2453
|
+
{(q, i) => (
|
|
2454
|
+
<box flexDirection="column">
|
|
2455
|
+
<text fg={theme.textMuted}>{q.question}</text>
|
|
2456
|
+
<text fg={theme.text}>{format(props.metadata.answers?.[i()])}</text>
|
|
2457
|
+
</box>
|
|
2458
|
+
)}
|
|
2459
|
+
</For>
|
|
2460
|
+
</box>
|
|
2461
|
+
</BlockTool>
|
|
2462
|
+
</Match>
|
|
2463
|
+
<Match when={true}>
|
|
2464
|
+
<InlineTool icon="→" pending="Asking questions..." complete={count()} part={props.part}>
|
|
2465
|
+
Asked {count()} question{count() !== 1 ? "s" : ""}
|
|
2466
|
+
</InlineTool>
|
|
2467
|
+
</Match>
|
|
2468
|
+
</Switch>
|
|
2469
|
+
)
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2472
|
+
function Skill(props: ToolProps<typeof SkillTool>) {
|
|
2473
|
+
return (
|
|
2474
|
+
<InlineTool icon="→" pending="Loading skill..." complete={props.input.name} part={props.part}>
|
|
2475
|
+
Skill "{props.input.name}"
|
|
2476
|
+
</InlineTool>
|
|
2477
|
+
)
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
function Diagnostics(props: { diagnostics?: Record<string, Record<string, any>[]>; filePath: string }) {
|
|
2481
|
+
const { theme } = useTheme()
|
|
2482
|
+
const errors = createMemo(() => {
|
|
2483
|
+
const normalized = Filesystem.normalizePath(props.filePath)
|
|
2484
|
+
const arr = props.diagnostics?.[normalized] ?? []
|
|
2485
|
+
return arr.filter((x) => x.severity === 1).slice(0, 3)
|
|
2486
|
+
})
|
|
2487
|
+
|
|
2488
|
+
return (
|
|
2489
|
+
<Show when={errors().length}>
|
|
2490
|
+
<box>
|
|
2491
|
+
<For each={errors()}>
|
|
2492
|
+
{(diagnostic) => (
|
|
2493
|
+
<text fg={theme.error}>
|
|
2494
|
+
Error [{diagnostic.range.start.line + 1}:{diagnostic.range.start.character + 1}] {diagnostic.message}
|
|
2495
|
+
</text>
|
|
2496
|
+
)}
|
|
2497
|
+
</For>
|
|
2498
|
+
</box>
|
|
2499
|
+
</Show>
|
|
2500
|
+
)
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
function normalizePath(input?: string) {
|
|
2504
|
+
if (!input) return ""
|
|
2505
|
+
|
|
2506
|
+
const cwd = process.cwd()
|
|
2507
|
+
const absolute = path.isAbsolute(input) ? input : path.resolve(cwd, input)
|
|
2508
|
+
const relative = path.relative(cwd, absolute)
|
|
2509
|
+
|
|
2510
|
+
if (!relative) return "."
|
|
2511
|
+
if (!relative.startsWith("..")) return relative
|
|
2512
|
+
|
|
2513
|
+
// outside cwd - use absolute
|
|
2514
|
+
return absolute
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
function input(input: Record<string, any>, omit?: string[]): string {
|
|
2518
|
+
const primitives = Object.entries(input).filter(([key, value]) => {
|
|
2519
|
+
if (omit?.includes(key)) return false
|
|
2520
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean"
|
|
2521
|
+
})
|
|
2522
|
+
if (primitives.length === 0) return ""
|
|
2523
|
+
return `[${primitives.map(([key, value]) => `${key}=${value}`).join(", ")}]`
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
function filetype(input?: string) {
|
|
2527
|
+
if (!input) return "none"
|
|
2528
|
+
const ext = path.extname(input)
|
|
2529
|
+
const language = LANGUAGE_EXTENSIONS[ext]
|
|
2530
|
+
if (["typescriptreact", "javascriptreact", "javascript"].includes(language)) return "typescript"
|
|
2531
|
+
return language
|
|
2532
|
+
}
|