orynacode-ai 1.16.2
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 +131 -0
- package/BUN_SHELL_MIGRATION_PLAN.md +136 -0
- package/Dockerfile +18 -0
- package/README.md +15 -0
- package/bin/orynacode +199 -0
- package/bunfig.toml +7 -0
- package/git +0 -0
- package/migration/20260511173437_session-metadata/migration.sql +1 -0
- package/migration/20260511173437_session-metadata/snapshot.json +1500 -0
- package/package.json +155 -0
- package/parsers-config.ts +386 -0
- package/script/bench-search.ts +115 -0
- package/script/bench-test-suite.ts +52 -0
- package/script/build.ts +244 -0
- package/script/generate.ts +14 -0
- package/script/httpapi-exercise.ts +1 -0
- package/script/postinstall.mjs +189 -0
- package/script/profile-test-files.ts +42 -0
- package/script/publish.ts +213 -0
- package/script/run-workspace-server +106 -0
- package/script/schema.ts +77 -0
- package/script/time.ts +6 -0
- package/script/trace-imports.ts +153 -0
- package/specs/effect/error-boundaries-plan.md +235 -0
- package/specs/effect/errors.md +207 -0
- package/specs/effect/facades.md +218 -0
- package/specs/effect/guide.md +247 -0
- package/specs/effect/instance-context.md +13 -0
- package/specs/effect/loose-ends.md +30 -0
- package/specs/effect/migration.md +62 -0
- package/specs/effect/routes.md +61 -0
- package/specs/effect/schema.md +88 -0
- package/specs/effect/server-package.md +58 -0
- package/specs/effect/todo.md +241 -0
- package/specs/effect/tools.md +88 -0
- package/specs/openapi-translation-cleanup.md +204 -0
- package/specs/tui-plugins.md +544 -0
- package/specs/v2/api.ts +67 -0
- package/specs/v2/message-shape.md +136 -0
- package/specs/v2/notifications.md +13 -0
- package/specs/v2/tui-command-shim.md +67 -0
- package/src/account/account.ts +459 -0
- package/src/account/repo.ts +170 -0
- package/src/account/schema.ts +99 -0
- package/src/account/url.ts +8 -0
- package/src/acp/agent.ts +95 -0
- package/src/acp/config-option.ts +203 -0
- package/src/acp/content.ts +250 -0
- package/src/acp/directory.ts +210 -0
- package/src/acp/error.ts +90 -0
- package/src/acp/event.ts +344 -0
- package/src/acp/permission.ts +145 -0
- package/src/acp/profile.ts +42 -0
- package/src/acp/service.ts +1062 -0
- package/src/acp/session.ts +231 -0
- package/src/acp/tool.ts +317 -0
- package/src/acp/usage.ts +239 -0
- package/src/agent/agent.ts +433 -0
- package/src/agent/generate.txt +75 -0
- package/src/agent/prompt/compaction.txt +9 -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/agent/subagent-permissions.ts +35 -0
- package/src/audio.d.ts +14 -0
- package/src/auth/index.ts +96 -0
- package/src/background/job.ts +36 -0
- package/src/bus/global.ts +22 -0
- package/src/cli/bootstrap.ts +11 -0
- package/src/cli/cmd/account.ts +264 -0
- package/src/cli/cmd/acp.ts +76 -0
- package/src/cli/cmd/agent.ts +259 -0
- package/src/cli/cmd/cmd.ts +7 -0
- package/src/cli/cmd/db.ts +62 -0
- package/src/cli/cmd/debug/agent.handler.ts +193 -0
- package/src/cli/cmd/debug/agent.ts +27 -0
- package/src/cli/cmd/debug/config.ts +14 -0
- package/src/cli/cmd/debug/file.ts +87 -0
- package/src/cli/cmd/debug/index.ts +87 -0
- package/src/cli/cmd/debug/lsp.ts +51 -0
- package/src/cli/cmd/debug/ripgrep.ts +99 -0
- package/src/cli/cmd/debug/scrap.ts +18 -0
- package/src/cli/cmd/debug/skill.ts +15 -0
- package/src/cli/cmd/debug/snapshot.ts +50 -0
- package/src/cli/cmd/debug/startup.ts +11 -0
- package/src/cli/cmd/debug/v2.ts +46 -0
- package/src/cli/cmd/export.ts +292 -0
- package/src/cli/cmd/generate.ts +54 -0
- package/src/cli/cmd/github.handler.ts +1593 -0
- package/src/cli/cmd/github.shared.ts +30 -0
- package/src/cli/cmd/github.ts +42 -0
- package/src/cli/cmd/import.ts +224 -0
- package/src/cli/cmd/mcp.ts +846 -0
- package/src/cli/cmd/models.ts +66 -0
- package/src/cli/cmd/plug.ts +230 -0
- package/src/cli/cmd/pr.ts +115 -0
- package/src/cli/cmd/prompt-display.ts +48 -0
- package/src/cli/cmd/providers.ts +506 -0
- package/src/cli/cmd/run/demo.ts +1274 -0
- package/src/cli/cmd/run/entry.body.ts +194 -0
- package/src/cli/cmd/run/footer.command.tsx +899 -0
- package/src/cli/cmd/run/footer.menu.tsx +306 -0
- package/src/cli/cmd/run/footer.permission.tsx +475 -0
- package/src/cli/cmd/run/footer.prompt.tsx +1207 -0
- package/src/cli/cmd/run/footer.question.tsx +579 -0
- package/src/cli/cmd/run/footer.subagent.tsx +171 -0
- package/src/cli/cmd/run/footer.ts +1092 -0
- package/src/cli/cmd/run/footer.view.tsx +935 -0
- package/src/cli/cmd/run/otel.ts +117 -0
- package/src/cli/cmd/run/permission.shared.ts +256 -0
- package/src/cli/cmd/run/prompt.shared.ts +147 -0
- package/src/cli/cmd/run/question.shared.ts +340 -0
- package/src/cli/cmd/run/runtime.boot.ts +210 -0
- package/src/cli/cmd/run/runtime.lifecycle.ts +369 -0
- package/src/cli/cmd/run/runtime.queue.ts +347 -0
- package/src/cli/cmd/run/runtime.shared.ts +17 -0
- package/src/cli/cmd/run/runtime.stdin.ts +37 -0
- package/src/cli/cmd/run/runtime.ts +879 -0
- package/src/cli/cmd/run/scrollback.shared.ts +92 -0
- package/src/cli/cmd/run/scrollback.surface.ts +435 -0
- package/src/cli/cmd/run/scrollback.writer.tsx +335 -0
- package/src/cli/cmd/run/session-data.ts +1113 -0
- package/src/cli/cmd/run/session-replay.ts +301 -0
- package/src/cli/cmd/run/session.shared.ts +196 -0
- package/src/cli/cmd/run/splash.ts +310 -0
- package/src/cli/cmd/run/stream.transport.ts +1465 -0
- package/src/cli/cmd/run/stream.ts +175 -0
- package/src/cli/cmd/run/subagent-data.ts +844 -0
- package/src/cli/cmd/run/theme.ts +603 -0
- package/src/cli/cmd/run/tool.ts +1489 -0
- package/src/cli/cmd/run/trace.ts +94 -0
- package/src/cli/cmd/run/types.ts +342 -0
- package/src/cli/cmd/run/variant.shared.ts +215 -0
- package/src/cli/cmd/run.ts +879 -0
- package/src/cli/cmd/serve.ts +24 -0
- package/src/cli/cmd/session.ts +147 -0
- package/src/cli/cmd/stats.ts +393 -0
- package/src/cli/cmd/tui/app.tsx +1113 -0
- package/src/cli/cmd/tui/attach.ts +103 -0
- package/src/cli/cmd/tui/attention.ts +262 -0
- package/src/cli/cmd/tui/component/bg-pulse-render.ts +436 -0
- package/src/cli/cmd/tui/component/bg-pulse.tsx +99 -0
- package/src/cli/cmd/tui/component/border.tsx +21 -0
- package/src/cli/cmd/tui/component/command-palette.tsx +79 -0
- package/src/cli/cmd/tui/component/dialog-agent.tsx +31 -0
- package/src/cli/cmd/tui/component/dialog-console-org.tsx +103 -0
- package/src/cli/cmd/tui/component/dialog-mcp.tsx +85 -0
- package/src/cli/cmd/tui/component/dialog-model.tsx +185 -0
- package/src/cli/cmd/tui/component/dialog-move-session.tsx +240 -0
- package/src/cli/cmd/tui/component/dialog-provider.tsx +687 -0
- package/src/cli/cmd/tui/component/dialog-retry-action.tsx +160 -0
- package/src/cli/cmd/tui/component/dialog-session-delete-failed.tsx +99 -0
- package/src/cli/cmd/tui/component/dialog-session-list.tsx +318 -0
- package/src/cli/cmd/tui/component/dialog-session-rename.tsx +31 -0
- package/src/cli/cmd/tui/component/dialog-skill.tsx +36 -0
- package/src/cli/cmd/tui/component/dialog-stash.tsx +87 -0
- package/src/cli/cmd/tui/component/dialog-status.tsx +168 -0
- package/src/cli/cmd/tui/component/dialog-tag.tsx +47 -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-workspace-create.tsx +313 -0
- package/src/cli/cmd/tui/component/dialog-workspace-file-changes.tsx +144 -0
- package/src/cli/cmd/tui/component/dialog-workspace-list.tsx +112 -0
- package/src/cli/cmd/tui/component/dialog-workspace-unavailable.tsx +69 -0
- package/src/cli/cmd/tui/component/error-component.tsx +81 -0
- package/src/cli/cmd/tui/component/logo.tsx +885 -0
- package/src/cli/cmd/tui/component/plugin-route-missing.tsx +14 -0
- package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +799 -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 +117 -0
- package/src/cli/cmd/tui/component/prompt/index.tsx +1725 -0
- package/src/cli/cmd/tui/component/prompt/move.tsx +192 -0
- package/src/cli/cmd/tui/component/prompt/part.ts +31 -0
- package/src/cli/cmd/tui/component/prompt/stash.tsx +101 -0
- package/src/cli/cmd/tui/component/prompt/traits.ts +35 -0
- package/src/cli/cmd/tui/component/prompt/workspace.tsx +137 -0
- package/src/cli/cmd/tui/component/spinner.tsx +24 -0
- package/src/cli/cmd/tui/component/startup-loading.tsx +63 -0
- package/src/cli/cmd/tui/component/todo-item.tsx +32 -0
- package/src/cli/cmd/tui/component/use-connected.tsx +9 -0
- package/src/cli/cmd/tui/component/workspace-label.tsx +19 -0
- package/src/cli/cmd/tui/config/cwd.ts +5 -0
- package/src/cli/cmd/tui/config/keybind.ts +467 -0
- package/src/cli/cmd/tui/config/tui-migrate.ts +154 -0
- package/src/cli/cmd/tui/config/tui-schema.ts +88 -0
- package/src/cli/cmd/tui/config/tui.ts +308 -0
- package/src/cli/cmd/tui/context/agent.tsx +11 -0
- package/src/cli/cmd/tui/context/aggregate-failures.ts +51 -0
- package/src/cli/cmd/tui/context/args.tsx +15 -0
- package/src/cli/cmd/tui/context/directory.ts +15 -0
- package/src/cli/cmd/tui/context/editor-zed.ts +287 -0
- package/src/cli/cmd/tui/context/editor.ts +469 -0
- package/src/cli/cmd/tui/context/event.ts +38 -0
- package/src/cli/cmd/tui/context/exit.tsx +42 -0
- package/src/cli/cmd/tui/context/helper.tsx +25 -0
- package/src/cli/cmd/tui/context/kv.tsx +76 -0
- package/src/cli/cmd/tui/context/local.tsx +510 -0
- package/src/cli/cmd/tui/context/path-format.tsx +39 -0
- package/src/cli/cmd/tui/context/project.tsx +111 -0
- package/src/cli/cmd/tui/context/prompt.tsx +18 -0
- package/src/cli/cmd/tui/context/route.tsx +52 -0
- package/src/cli/cmd/tui/context/sdk.tsx +142 -0
- package/src/cli/cmd/tui/context/sync-v2.tsx +447 -0
- package/src/cli/cmd/tui/context/sync.tsx +628 -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/opencode.json +245 -0
- package/src/cli/cmd/tui/context/theme/orng.json +249 -0
- package/src/cli/cmd/tui/context/theme/oryna.json +95 -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/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 +1341 -0
- package/src/cli/cmd/tui/context/thinking.ts +67 -0
- package/src/cli/cmd/tui/context/tui-config.tsx +9 -0
- package/src/cli/cmd/tui/event.ts +53 -0
- package/src/cli/cmd/tui/feature-plugins/home/footer.tsx +98 -0
- package/src/cli/cmd/tui/feature-plugins/home/tips-view.tsx +288 -0
- package/src/cli/cmd/tui/feature-plugins/home/tips.tsx +59 -0
- package/src/cli/cmd/tui/feature-plugins/session/dialog.tsx +356 -0
- package/src/cli/cmd/tui/feature-plugins/session/index.tsx +32 -0
- package/src/cli/cmd/tui/feature-plugins/session/preview-pane.tsx +288 -0
- package/src/cli/cmd/tui/feature-plugins/session/util.tsx +54 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/context.tsx +65 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/files.tsx +70 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/footer.tsx +96 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/lsp.tsx +65 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/mcp.tsx +97 -0
- package/src/cli/cmd/tui/feature-plugins/sidebar/todo.tsx +49 -0
- package/src/cli/cmd/tui/feature-plugins/system/diff-viewer-file-tree-utils.ts +232 -0
- package/src/cli/cmd/tui/feature-plugins/system/diff-viewer-file-tree.tsx +162 -0
- package/src/cli/cmd/tui/feature-plugins/system/diff-viewer-ui.tsx +103 -0
- package/src/cli/cmd/tui/feature-plugins/system/diff-viewer.tsx +1058 -0
- package/src/cli/cmd/tui/feature-plugins/system/notifications.ts +94 -0
- package/src/cli/cmd/tui/feature-plugins/system/plugins.tsx +269 -0
- package/src/cli/cmd/tui/feature-plugins/system/session-v2.tsx +1184 -0
- package/src/cli/cmd/tui/feature-plugins/system/which-key.tsx +608 -0
- package/src/cli/cmd/tui/keymap.tsx +283 -0
- package/src/cli/cmd/tui/layer.ts +6 -0
- package/src/cli/cmd/tui/plugin/api.tsx +390 -0
- package/src/cli/cmd/tui/plugin/command-shim.ts +109 -0
- package/src/cli/cmd/tui/plugin/internal.ts +42 -0
- package/src/cli/cmd/tui/plugin/runtime.ts +1131 -0
- package/src/cli/cmd/tui/plugin/slots.tsx +60 -0
- package/src/cli/cmd/tui/routes/home/session-destination.tsx +39 -0
- package/src/cli/cmd/tui/routes/home.tsx +149 -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 +108 -0
- package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +26 -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 +2629 -0
- package/src/cli/cmd/tui/routes/session/permission.tsx +729 -0
- package/src/cli/cmd/tui/routes/session/question.tsx +514 -0
- package/src/cli/cmd/tui/routes/session/sidebar.tsx +102 -0
- package/src/cli/cmd/tui/routes/session/subagent-footer.tsx +132 -0
- package/src/cli/cmd/tui/thread.ts +264 -0
- package/src/cli/cmd/tui/ui/dialog-alert.tsx +66 -0
- package/src/cli/cmd/tui/ui/dialog-confirm.tsx +108 -0
- package/src/cli/cmd/tui/ui/dialog-export-options.tsx +217 -0
- package/src/cli/cmd/tui/ui/dialog-help.tsx +40 -0
- package/src/cli/cmd/tui/ui/dialog-prompt.tsx +126 -0
- package/src/cli/cmd/tui/ui/dialog-select.tsx +712 -0
- package/src/cli/cmd/tui/ui/dialog.tsx +218 -0
- package/src/cli/cmd/tui/ui/link.tsx +34 -0
- package/src/cli/cmd/tui/ui/spinner.ts +368 -0
- package/src/cli/cmd/tui/ui/toast.tsx +102 -0
- package/src/cli/cmd/tui/util/audio.ts +58 -0
- package/src/cli/cmd/tui/util/clipboard.ts +181 -0
- package/src/cli/cmd/tui/util/collapse-tool-output.ts +19 -0
- package/src/cli/cmd/tui/util/editor.ts +43 -0
- package/src/cli/cmd/tui/util/layout.ts +25 -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 +25 -0
- package/src/cli/cmd/tui/util/selection.ts +73 -0
- package/src/cli/cmd/tui/util/signal.ts +41 -0
- package/src/cli/cmd/tui/util/transcript.ts +112 -0
- package/src/cli/cmd/tui/validate-session.ts +29 -0
- package/src/cli/cmd/tui/win32.ts +130 -0
- package/src/cli/cmd/tui/worker.ts +99 -0
- package/src/cli/cmd/uninstall.ts +353 -0
- package/src/cli/cmd/upgrade.ts +74 -0
- package/src/cli/cmd/web.ts +84 -0
- package/src/cli/effect/prompt.ts +37 -0
- package/src/cli/effect-cmd.ts +96 -0
- package/src/cli/error.ts +118 -0
- package/src/cli/heap.ts +59 -0
- package/src/cli/logo.ts +21 -0
- package/src/cli/network.ts +64 -0
- package/src/cli/ui.ts +132 -0
- package/src/cli/upgrade.ts +53 -0
- package/src/command/index.ts +181 -0
- package/src/command/template/initialize.txt +66 -0
- package/src/command/template/review.txt +101 -0
- package/src/config/agent.ts +68 -0
- package/src/config/command.ts +45 -0
- package/src/config/config.ts +679 -0
- package/src/config/entry-name.ts +19 -0
- package/src/config/managed.ts +77 -0
- package/src/config/markdown.ts +36 -0
- package/src/config/parse.ts +79 -0
- package/src/config/paths.ts +45 -0
- package/src/config/plugin.ts +79 -0
- package/src/config/reference.ts +48 -0
- package/src/config/variable.ts +91 -0
- package/src/control-plane/adapters/index.ts +41 -0
- package/src/control-plane/adapters/worktree.ts +96 -0
- package/src/control-plane/dev/README.md +19 -0
- package/src/control-plane/dev/debug-workspace-plugin.ts +73 -0
- package/src/control-plane/types.ts +59 -0
- package/src/control-plane/util.ts +39 -0
- package/src/control-plane/workspace-adapter-runtime.ts +51 -0
- package/src/control-plane/workspace-context.ts +26 -0
- package/src/control-plane/workspace.ts +1075 -0
- package/src/effect/app-runtime.ts +133 -0
- package/src/effect/bootstrap-runtime.ts +23 -0
- package/src/effect/bridge.ts +84 -0
- package/src/effect/config-service.ts +67 -0
- package/src/effect/instance-ref.ts +11 -0
- package/src/effect/instance-registry.ts +12 -0
- package/src/effect/instance-state.ts +72 -0
- package/src/effect/promise.ts +17 -0
- package/src/effect/run-service.ts +47 -0
- package/src/effect/runner.ts +217 -0
- package/src/effect/runtime-flags.ts +76 -0
- package/src/env/index.ts +40 -0
- package/src/event-v2-bridge.ts +76 -0
- package/src/format/formatter.ts +404 -0
- package/src/format/index.ts +212 -0
- package/src/git/index.ts +347 -0
- package/src/id/id.ts +80 -0
- package/src/ide/index.ts +70 -0
- package/src/image/image.ts +177 -0
- package/src/index.ts +208 -0
- package/src/installation/index.ts +349 -0
- package/src/lsp/client.ts +686 -0
- package/src/lsp/diagnostic.ts +29 -0
- package/src/lsp/language.ts +121 -0
- package/src/lsp/launch.ts +21 -0
- package/src/lsp/lsp.ts +517 -0
- package/src/lsp/server.ts +2064 -0
- package/src/markdown.d.ts +4 -0
- package/src/mcp/auth.ts +171 -0
- package/src/mcp/index.ts +982 -0
- package/src/mcp/oauth-callback.ts +232 -0
- package/src/mcp/oauth-provider.ts +217 -0
- package/src/node.ts +5 -0
- package/src/oryna/agent.ts +112 -0
- package/src/oryna/reply-service.ts +8 -0
- package/src/patch/index.ts +689 -0
- package/src/permission/arity.ts +163 -0
- package/src/permission/evaluate.ts +1 -0
- package/src/permission/index.ts +230 -0
- package/src/plugin/azure.ts +26 -0
- package/src/plugin/cloudflare.ts +76 -0
- package/src/plugin/digitalocean.ts +391 -0
- package/src/plugin/github-copilot/copilot.ts +417 -0
- package/src/plugin/github-copilot/models.ts +246 -0
- package/src/plugin/index.ts +323 -0
- package/src/plugin/install.ts +439 -0
- package/src/plugin/loader.ts +237 -0
- package/src/plugin/meta.ts +188 -0
- package/src/plugin/openai/README.md +31 -0
- package/src/plugin/openai/codex.ts +647 -0
- package/src/plugin/openai/ws-pool.ts +290 -0
- package/src/plugin/openai/ws.ts +381 -0
- package/src/plugin/oryna.ts +349 -0
- package/src/plugin/shared.ts +323 -0
- package/src/plugin/xai.ts +742 -0
- package/src/project/bootstrap-service.ts +9 -0
- package/src/project/bootstrap.ts +80 -0
- package/src/project/instance-context.ts +24 -0
- package/src/project/instance-layer.ts +11 -0
- package/src/project/instance-runtime.ts +16 -0
- package/src/project/instance-store.ts +207 -0
- package/src/project/project.ts +520 -0
- package/src/project/vcs.ts +435 -0
- package/src/provider/auth.ts +230 -0
- package/src/provider/error.ts +188 -0
- package/src/provider/model-status.ts +8 -0
- package/src/provider/provider.ts +2009 -0
- package/src/provider/transform.ts +1363 -0
- package/src/pty-preparation.ts +30 -0
- package/src/question/index.ts +229 -0
- package/src/question/schema.ts +10 -0
- package/src/reference/reference.ts +239 -0
- package/src/reference/repository-cache.ts +320 -0
- package/src/server/auth.ts +48 -0
- package/src/server/cors.ts +34 -0
- package/src/server/event.ts +13 -0
- package/src/server/global-lifecycle.ts +37 -0
- package/src/server/init-projectors.ts +3 -0
- package/src/server/mdns.ts +60 -0
- package/src/server/projectors.ts +1 -0
- package/src/server/proxy-util.ts +48 -0
- package/src/server/routes/instance/httpapi/AGENTS.md +39 -0
- package/src/server/routes/instance/httpapi/api.ts +78 -0
- package/src/server/routes/instance/httpapi/errors.ts +193 -0
- package/src/server/routes/instance/httpapi/groups/config.ts +65 -0
- package/src/server/routes/instance/httpapi/groups/control-plane.ts +35 -0
- package/src/server/routes/instance/httpapi/groups/control.ts +76 -0
- package/src/server/routes/instance/httpapi/groups/event.ts +29 -0
- package/src/server/routes/instance/httpapi/groups/experimental.ts +260 -0
- package/src/server/routes/instance/httpapi/groups/file.ts +172 -0
- package/src/server/routes/instance/httpapi/groups/global.ts +138 -0
- package/src/server/routes/instance/httpapi/groups/instance.ts +206 -0
- package/src/server/routes/instance/httpapi/groups/mcp.ts +156 -0
- package/src/server/routes/instance/httpapi/groups/metadata.ts +18 -0
- package/src/server/routes/instance/httpapi/groups/permission.ts +61 -0
- package/src/server/routes/instance/httpapi/groups/project-copy.ts +88 -0
- package/src/server/routes/instance/httpapi/groups/project.ts +93 -0
- package/src/server/routes/instance/httpapi/groups/provider.ts +101 -0
- package/src/server/routes/instance/httpapi/groups/pty.ts +172 -0
- package/src/server/routes/instance/httpapi/groups/query.ts +12 -0
- package/src/server/routes/instance/httpapi/groups/question.ts +74 -0
- package/src/server/routes/instance/httpapi/groups/session.ts +462 -0
- package/src/server/routes/instance/httpapi/groups/sync.ts +113 -0
- package/src/server/routes/instance/httpapi/groups/tui.ts +208 -0
- package/src/server/routes/instance/httpapi/groups/workspace.ts +141 -0
- package/src/server/routes/instance/httpapi/handlers/config.ts +151 -0
- package/src/server/routes/instance/httpapi/handlers/control-plane.ts +37 -0
- package/src/server/routes/instance/httpapi/handlers/control.ts +40 -0
- package/src/server/routes/instance/httpapi/handlers/event.ts +102 -0
- package/src/server/routes/instance/httpapi/handlers/experimental.ts +187 -0
- package/src/server/routes/instance/httpapi/handlers/file.ts +103 -0
- package/src/server/routes/instance/httpapi/handlers/global.ts +157 -0
- package/src/server/routes/instance/httpapi/handlers/instance.ts +110 -0
- package/src/server/routes/instance/httpapi/handlers/mcp.ts +111 -0
- package/src/server/routes/instance/httpapi/handlers/permission.ts +41 -0
- package/src/server/routes/instance/httpapi/handlers/project-copy.ts +157 -0
- package/src/server/routes/instance/httpapi/handlers/project.ts +63 -0
- package/src/server/routes/instance/httpapi/handlers/provider.ts +160 -0
- package/src/server/routes/instance/httpapi/handlers/pty.ts +258 -0
- package/src/server/routes/instance/httpapi/handlers/question.ts +54 -0
- package/src/server/routes/instance/httpapi/handlers/session-errors.ts +21 -0
- package/src/server/routes/instance/httpapi/handlers/session.ts +442 -0
- package/src/server/routes/instance/httpapi/handlers/sync.ts +95 -0
- package/src/server/routes/instance/httpapi/handlers/tui.ts +131 -0
- package/src/server/routes/instance/httpapi/handlers/workspace.ts +102 -0
- package/src/server/routes/instance/httpapi/lifecycle.ts +57 -0
- package/src/server/routes/instance/httpapi/middleware/authorization.ts +147 -0
- package/src/server/routes/instance/httpapi/middleware/compression.ts +64 -0
- package/src/server/routes/instance/httpapi/middleware/cors-vary.ts +29 -0
- package/src/server/routes/instance/httpapi/middleware/error.ts +36 -0
- package/src/server/routes/instance/httpapi/middleware/fence.ts +25 -0
- package/src/server/routes/instance/httpapi/middleware/instance-context.ts +43 -0
- package/src/server/routes/instance/httpapi/middleware/proxy.ts +108 -0
- package/src/server/routes/instance/httpapi/middleware/schema-error.ts +42 -0
- package/src/server/routes/instance/httpapi/middleware/workspace-routing.ts +250 -0
- package/src/server/routes/instance/httpapi/public.ts +535 -0
- package/src/server/routes/instance/httpapi/server.ts +277 -0
- package/src/server/routes/instance/httpapi/websocket-tracker.ts +57 -0
- package/src/server/server.ts +218 -0
- package/src/server/shared/fence.ts +68 -0
- package/src/server/shared/pty-ticket.ts +15 -0
- package/src/server/shared/public-ui.ts +12 -0
- package/src/server/shared/tui-control.ts +28 -0
- package/src/server/shared/ui.ts +108 -0
- package/src/server/shared/workspace-routing.ts +38 -0
- package/src/session/compaction.ts +609 -0
- package/src/session/instruction.ts +237 -0
- package/src/session/llm/AGENTS.md +90 -0
- package/src/session/llm/ai-sdk.ts +288 -0
- package/src/session/llm/native-request.ts +196 -0
- package/src/session/llm/native-runtime.ts +195 -0
- package/src/session/llm/request.ts +215 -0
- package/src/session/llm.ts +402 -0
- package/src/session/message-error.ts +14 -0
- package/src/session/message-v2.ts +745 -0
- package/src/session/message.ts +148 -0
- package/src/session/overflow.ts +34 -0
- package/src/session/processor.ts +1063 -0
- package/src/session/prompt/anthropic.txt +105 -0
- package/src/session/prompt/beast.txt +147 -0
- package/src/session/prompt/build-switch.txt +5 -0
- package/src/session/prompt/codex.txt +79 -0
- package/src/session/prompt/copilot-gpt-5.txt +143 -0
- package/src/session/prompt/default.txt +95 -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/plan-mode.txt +70 -0
- package/src/session/prompt/plan-reminder-anthropic.txt +67 -0
- package/src/session/prompt/plan.txt +26 -0
- package/src/session/prompt/reference.ts +72 -0
- package/src/session/prompt/trinity.txt +97 -0
- package/src/session/prompt.ts +1755 -0
- package/src/session/reminders.ts +92 -0
- package/src/session/retry.ts +201 -0
- package/src/session/revert.ts +153 -0
- package/src/session/run-state.ts +153 -0
- package/src/session/schema.ts +26 -0
- package/src/session/session.ts +1116 -0
- package/src/session/status.ts +94 -0
- package/src/session/summary.ts +162 -0
- package/src/session/system.ts +84 -0
- package/src/session/todo.ts +87 -0
- package/src/session/tools.ts +211 -0
- package/src/share/session.ts +58 -0
- package/src/share/share-next.ts +379 -0
- package/src/shell/shell.ts +215 -0
- package/src/skill/discovery.ts +115 -0
- package/src/skill/index.ts +357 -0
- package/src/snapshot/index.ts +759 -0
- package/src/sql.d.ts +4 -0
- package/src/storage/schema.ts +5 -0
- package/src/storage/storage.ts +329 -0
- package/src/sync/README.md +179 -0
- package/src/sync/schema.ts +11 -0
- package/src/temporary.ts +33 -0
- package/src/tool/apply_patch.ts +313 -0
- package/src/tool/apply_patch.txt +33 -0
- package/src/tool/edit.ts +737 -0
- package/src/tool/edit.txt +10 -0
- package/src/tool/external-directory.ts +49 -0
- package/src/tool/glob.ts +84 -0
- package/src/tool/glob.txt +6 -0
- package/src/tool/grep.ts +140 -0
- package/src/tool/grep.txt +8 -0
- package/src/tool/invalid.ts +21 -0
- package/src/tool/json-schema.ts +164 -0
- package/src/tool/lsp.ts +113 -0
- package/src/tool/lsp.txt +24 -0
- package/src/tool/mcp-websearch.ts +96 -0
- package/src/tool/plan-enter.txt +14 -0
- package/src/tool/plan-exit.txt +13 -0
- package/src/tool/plan.ts +79 -0
- package/src/tool/question.ts +44 -0
- package/src/tool/question.txt +10 -0
- package/src/tool/read.ts +392 -0
- package/src/tool/read.txt +14 -0
- package/src/tool/registry.ts +475 -0
- package/src/tool/reply.ts +29 -0
- package/src/tool/schema.ts +14 -0
- package/src/tool/shell/id.ts +19 -0
- package/src/tool/shell/prompt.ts +307 -0
- package/src/tool/shell/shell.txt +21 -0
- package/src/tool/shell.ts +660 -0
- package/src/tool/skill.ts +72 -0
- package/src/tool/skill.txt +5 -0
- package/src/tool/task.ts +338 -0
- package/src/tool/task.txt +19 -0
- package/src/tool/todo.ts +57 -0
- package/src/tool/todowrite.txt +44 -0
- package/src/tool/tool.ts +183 -0
- package/src/tool/truncate.ts +160 -0
- package/src/tool/truncation-dir.ts +4 -0
- package/src/tool/webfetch.ts +192 -0
- package/src/tool/webfetch.txt +13 -0
- package/src/tool/websearch.ts +143 -0
- package/src/tool/websearch.txt +14 -0
- package/src/tool/write.ts +104 -0
- package/src/tool/write.txt +8 -0
- package/src/util/archive.ts +17 -0
- package/src/util/bom.ts +27 -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/error.ts +88 -0
- package/src/util/filesystem.ts +251 -0
- package/src/util/format.ts +20 -0
- package/src/util/iife.ts +3 -0
- package/src/util/lan-scan.ts +90 -0
- package/src/util/lazy.ts +20 -0
- package/src/util/local-context.ts +25 -0
- package/src/util/locale.ts +86 -0
- package/src/util/media.ts +26 -0
- package/src/util/process.ts +176 -0
- package/src/util/proxy-env.ts +72 -0
- package/src/util/queue.ts +32 -0
- package/src/util/record.ts +3 -0
- package/src/util/repository.ts +232 -0
- package/src/util/rpc.ts +66 -0
- package/src/util/signal.ts +12 -0
- package/src/util/timeout.ts +13 -0
- package/src/util/token.ts +1 -0
- package/src/util/wildcard.ts +59 -0
- package/src/worktree/index.ts +645 -0
- package/sst-env.d.ts +10 -0
- package/test/AGENTS.md +204 -0
- package/test/EFFECT_TEST_MIGRATION.md +169 -0
- package/test/account/repo.test.ts +353 -0
- package/test/account/service.test.ts +453 -0
- package/test/acp/config-option.test.ts +229 -0
- package/test/acp/content.test.ts +201 -0
- package/test/acp/directory.test.ts +186 -0
- package/test/acp/error.test.ts +67 -0
- package/test/acp/event.test.ts +711 -0
- package/test/acp/permission.test.ts +273 -0
- package/test/acp/service-session.test.ts +1174 -0
- package/test/acp/session.test.ts +200 -0
- package/test/acp/tool.test.ts +210 -0
- package/test/acp/usage.test.ts +315 -0
- package/test/agent/agent.test.ts +710 -0
- package/test/agent/plan-mode-subagent-bypass.test.ts +213 -0
- package/test/agent/plugin-agent-regression.test.ts +62 -0
- package/test/auth/auth.test.ts +77 -0
- package/test/background/job.test.ts +243 -0
- package/test/cli/account.test.ts +30 -0
- package/test/cli/acp/acp-test-client.ts +97 -0
- package/test/cli/acp/config-options.test.ts +103 -0
- package/test/cli/acp/helpers.ts +96 -0
- package/test/cli/acp/initialize-auth.test.ts +61 -0
- package/test/cli/acp/lifecycle.test.ts +118 -0
- package/test/cli/acp/prompt-content.test.ts +97 -0
- package/test/cli/acp/skills.test.ts +38 -0
- package/test/cli/cmd/tui/aggregate-failures.test.ts +93 -0
- package/test/cli/cmd/tui/attention.test.ts +484 -0
- package/test/cli/cmd/tui/dialog-workspace-create.test.ts +28 -0
- package/test/cli/cmd/tui/model-options.test.ts +30 -0
- package/test/cli/cmd/tui/notifications.test.ts +267 -0
- package/test/cli/cmd/tui/prompt-history.test.ts +44 -0
- package/test/cli/cmd/tui/prompt-part.test.ts +77 -0
- package/test/cli/cmd/tui/prompt-traits.test.ts +29 -0
- package/test/cli/cmd/tui/provider-options.test.ts +29 -0
- package/test/cli/cmd/tui/sync-fixture.tsx +64 -0
- package/test/cli/cmd/tui/sync-live-hydration.test.tsx +278 -0
- package/test/cli/cmd/tui/sync-undefined-messages.test.tsx +47 -0
- package/test/cli/cmd/tui/sync.test.tsx +70 -0
- package/test/cli/effect-cmd-instance-als.test.ts +39 -0
- package/test/cli/error.test.ts +95 -0
- package/test/cli/github-action.test.ts +199 -0
- package/test/cli/github-remote.test.ts +90 -0
- package/test/cli/help/__snapshots__/help-snapshots.test.ts.snap +631 -0
- package/test/cli/help/help-snapshots.test.ts +137 -0
- package/test/cli/import.test.ts +54 -0
- package/test/cli/mcp-add.test.ts +74 -0
- package/test/cli/plugin-auth-picker.test.ts +120 -0
- package/test/cli/run/entry.body.test.ts +536 -0
- package/test/cli/run/footer.menu.test.ts +43 -0
- package/test/cli/run/footer.view.test.tsx +927 -0
- package/test/cli/run/permission.shared.test.ts +144 -0
- package/test/cli/run/prompt.shared.test.ts +133 -0
- package/test/cli/run/question.shared.test.ts +115 -0
- package/test/cli/run/run-process.test.ts +84 -0
- package/test/cli/run/runtime.boot.test.ts +282 -0
- package/test/cli/run/runtime.queue.test.ts +465 -0
- package/test/cli/run/runtime.stdin.test.ts +71 -0
- package/test/cli/run/scrollback.surface.test.ts +1048 -0
- package/test/cli/run/session-data.test.ts +595 -0
- package/test/cli/run/session-replay.test.ts +456 -0
- package/test/cli/run/session.shared.test.ts +247 -0
- package/test/cli/run/stream.test.ts +56 -0
- package/test/cli/run/stream.transport.test.ts +2363 -0
- package/test/cli/run/subagent-data.test.ts +456 -0
- package/test/cli/run/theme.test.ts +152 -0
- package/test/cli/run/variant.shared.test.ts +217 -0
- package/test/cli/serve/serve-process.test.ts +61 -0
- package/test/cli/smokes/read-only.test.ts +115 -0
- package/test/cli/tui/__snapshots__/inline-tool-wrap-snapshot.test.tsx.snap +72 -0
- package/test/cli/tui/app-lifecycle.test.ts +261 -0
- package/test/cli/tui/dialog-prompt.test.tsx +146 -0
- package/test/cli/tui/diff-viewer-file-tree-utils.test.ts +323 -0
- package/test/cli/tui/diff-viewer-file-tree.test.tsx +197 -0
- package/test/cli/tui/diff-viewer.test.tsx +230 -0
- package/test/cli/tui/editor-context-zed.test.ts +384 -0
- package/test/cli/tui/editor-context.test.tsx +288 -0
- package/test/cli/tui/inline-tool-wrap-snapshot.test.tsx +232 -0
- package/test/cli/tui/keymap.test.tsx +136 -0
- package/test/cli/tui/plugin-add.test.ts +110 -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 +485 -0
- package/test/cli/tui/plugin-loader-pure.test.ts +72 -0
- package/test/cli/tui/plugin-loader.test.ts +1332 -0
- package/test/cli/tui/plugin-toggle.test.ts +264 -0
- package/test/cli/tui/prompt-submit-race.test.ts +98 -0
- package/test/cli/tui/revert-diff.test.ts +35 -0
- package/test/cli/tui/slot-replace.test.tsx +50 -0
- package/test/cli/tui/sync-v2.test.tsx +558 -0
- package/test/cli/tui/theme-store.test.ts +76 -0
- package/test/cli/tui/thinking.test.ts +36 -0
- package/test/cli/tui/thread.test.ts +28 -0
- package/test/cli/tui/transcript.test.ts +426 -0
- package/test/cli/tui/use-event.test.tsx +145 -0
- package/test/config/agent-color.test.ts +47 -0
- package/test/config/config.test.ts +1991 -0
- package/test/config/entry-name.test.ts +57 -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 +69 -0
- package/test/config/markdown.test.ts +228 -0
- package/test/config/plugin.test.ts +0 -0
- package/test/config/tui.test.ts +878 -0
- package/test/control-plane/adapters.test.ts +71 -0
- package/test/control-plane/workspace.test.ts +1704 -0
- package/test/effect/app-runtime-logger.test.ts +105 -0
- package/test/effect/config-service.test.ts +65 -0
- package/test/effect/instance-state.test.ts +391 -0
- package/test/effect/run-service.test.ts +89 -0
- package/test/effect/runner.test.ts +514 -0
- package/test/effect/runtime-flags.test.ts +373 -0
- package/test/fake/account.ts +9 -0
- package/test/fake/auth.ts +8 -0
- package/test/fake/npm.ts +8 -0
- package/test/fake/provider.ts +82 -0
- package/test/fake/skill.ts +8 -0
- package/test/filesystem/filesystem.test.ts +319 -0
- package/test/fixture/agent-plugin.constants.ts +6 -0
- package/test/fixture/agent-plugin.ts +12 -0
- package/test/fixture/config.ts +23 -0
- package/test/fixture/db.ts +11 -0
- package/test/fixture/fixture.test.ts +26 -0
- package/test/fixture/fixture.ts +224 -0
- package/test/fixture/flag.ts +20 -0
- package/test/fixture/flock-worker.ts +72 -0
- package/test/fixture/lsp/fake-lsp-server.js +249 -0
- package/test/fixture/plug-worker.ts +93 -0
- package/test/fixture/plugin-meta-worker.ts +19 -0
- package/test/fixture/plugin.ts +10 -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 +355 -0
- package/test/fixture/tui-runtime.ts +64 -0
- package/test/fixture/tui-sdk.ts +82 -0
- package/test/fixture/workspace.ts +30 -0
- package/test/fixtures/recordings/session/native-anthropic-tool-loop.json +49 -0
- package/test/fixtures/recordings/session/native-openai-oauth-tool-loop.json +45 -0
- package/test/fixtures/recordings/session/native-zen-tool-loop.json +49 -0
- package/test/format/format.test.ts +228 -0
- package/test/git/git.test.ts +178 -0
- package/test/ide/ide.test.ts +82 -0
- package/test/image/fixtures/picture-5mb-base64.png +0 -0
- package/test/image/image.test.ts +123 -0
- package/test/installation/installation.test.ts +230 -0
- package/test/lib/cli-process.ts +459 -0
- package/test/lib/effect.ts +177 -0
- package/test/lib/filesystem.ts +10 -0
- package/test/lib/llm-server.ts +771 -0
- package/test/lib/snapshot.ts +73 -0
- package/test/lib/test-provider.ts +37 -0
- package/test/lib/websocket.ts +46 -0
- package/test/lsp/client.test.ts +493 -0
- package/test/lsp/index.test.ts +232 -0
- package/test/lsp/launch.test.ts +22 -0
- package/test/lsp/lifecycle.test.ts +160 -0
- package/test/mcp/auth.test.ts +78 -0
- package/test/mcp/headers.test.ts +126 -0
- package/test/mcp/lifecycle.test.ts +888 -0
- package/test/mcp/oauth-auto-connect.test.ts +236 -0
- package/test/mcp/oauth-browser.test.ts +228 -0
- package/test/mcp/oauth-callback.test.ts +34 -0
- package/test/mcp/oauth-provider.test.ts +61 -0
- package/test/patch/patch.test.ts +383 -0
- package/test/permission/arity.test.ts +33 -0
- package/test/permission/next.test.ts +1176 -0
- package/test/permission-task.test.ts +318 -0
- package/test/plugin/auth-override.test.ts +105 -0
- package/test/plugin/cloudflare.test.ts +68 -0
- package/test/plugin/codex.test.ts +247 -0
- package/test/plugin/github-copilot-models.test.ts +332 -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 +1303 -0
- package/test/plugin/meta.test.ts +137 -0
- package/test/plugin/openai-rollout.test.ts +17 -0
- package/test/plugin/openai-ws.test.ts +877 -0
- package/test/plugin/shared.test.ts +88 -0
- package/test/plugin/trigger.test.ts +120 -0
- package/test/plugin/workspace-adapter.test.ts +137 -0
- package/test/plugin/xai.test.ts +634 -0
- package/test/preload.ts +95 -0
- package/test/project/instance-bootstrap.test.ts +110 -0
- package/test/project/instance.test.ts +245 -0
- package/test/project/migrate-global.test.ts +170 -0
- package/test/project/project-directory.test.ts +169 -0
- package/test/project/project.test.ts +818 -0
- package/test/project/vcs.test.ts +336 -0
- package/test/project/worktree-remove.test.ts +126 -0
- package/test/project/worktree.test.ts +320 -0
- package/test/provider/amazon-bedrock.test.ts +360 -0
- package/test/provider/cf-ai-gateway-e2e.test.ts +132 -0
- package/test/provider/digitalocean.test.ts +123 -0
- package/test/provider/gitlab-duo.test.ts +412 -0
- package/test/provider/header-timeout.test.ts +233 -0
- package/test/provider/model-status.test.ts +61 -0
- package/test/provider/provider.test.ts +1793 -0
- package/test/provider/transform.test.ts +3937 -0
- package/test/pty/pty-shell.test.ts +102 -0
- package/test/question/question.test.ts +465 -0
- package/test/reference/reference.test.ts +310 -0
- package/test/server/AGENTS.md +15 -0
- package/test/server/auth.test.ts +59 -0
- package/test/server/global-bus.ts +31 -0
- package/test/server/global-session-list.test.ts +107 -0
- package/test/server/httpapi-authorization.test.ts +174 -0
- package/test/server/httpapi-compression.test.ts +154 -0
- package/test/server/httpapi-config.test.ts +113 -0
- package/test/server/httpapi-control-plane.test.ts +63 -0
- package/test/server/httpapi-cors-vary.test.ts +66 -0
- package/test/server/httpapi-cors.test.ts +122 -0
- package/test/server/httpapi-error-middleware.test.ts +96 -0
- package/test/server/httpapi-event.test.ts +97 -0
- package/test/server/httpapi-exercise/assertions.ts +64 -0
- package/test/server/httpapi-exercise/backend.ts +144 -0
- package/test/server/httpapi-exercise/dsl.ts +210 -0
- package/test/server/httpapi-exercise/environment.ts +40 -0
- package/test/server/httpapi-exercise/index.ts +1535 -0
- package/test/server/httpapi-exercise/report.ts +66 -0
- package/test/server/httpapi-exercise/routing.ts +96 -0
- package/test/server/httpapi-exercise/runner.ts +267 -0
- package/test/server/httpapi-exercise/runtime.ts +52 -0
- package/test/server/httpapi-exercise/types.ts +123 -0
- package/test/server/httpapi-experimental.test.ts +300 -0
- package/test/server/httpapi-file.test.ts +76 -0
- package/test/server/httpapi-global.test.ts +66 -0
- package/test/server/httpapi-instance-context.test.ts +347 -0
- package/test/server/httpapi-instance-route-auth.test.ts +84 -0
- package/test/server/httpapi-instance.test.ts +265 -0
- package/test/server/httpapi-layer.ts +33 -0
- package/test/server/httpapi-listen.test.ts +415 -0
- package/test/server/httpapi-mcp-oauth.test.ts +73 -0
- package/test/server/httpapi-mcp.test.ts +226 -0
- package/test/server/httpapi-mdns.test.ts +82 -0
- package/test/server/httpapi-promptasync-context.test.ts +222 -0
- package/test/server/httpapi-provider.test.ts +403 -0
- package/test/server/httpapi-pty.test.ts +275 -0
- package/test/server/httpapi-public-openapi.test.ts +297 -0
- package/test/server/httpapi-query-schema-drift.test.ts +330 -0
- package/test/server/httpapi-schema-error-body.test.ts +165 -0
- package/test/server/httpapi-sdk.test.ts +909 -0
- package/test/server/httpapi-session.test.ts +1013 -0
- package/test/server/httpapi-sync.test.ts +154 -0
- package/test/server/httpapi-ui.test.ts +456 -0
- package/test/server/httpapi-v2-location.test.ts +85 -0
- package/test/server/httpapi-workspace-routing.test.ts +554 -0
- package/test/server/httpapi-workspace.test.ts +515 -0
- package/test/server/negative-tokens-regression.test.ts +83 -0
- package/test/server/project-copy.test.ts +101 -0
- package/test/server/project-init-git.test.ts +117 -0
- package/test/server/proxy-util.test.ts +113 -0
- package/test/server/sdk-error-shape.test.ts +84 -0
- package/test/server/sdk-v1-smoke.test.ts +60 -0
- package/test/server/session-actions.test.ts +112 -0
- package/test/server/session-diff-missing-patch.test.ts +99 -0
- package/test/server/session-list.test.ts +314 -0
- package/test/server/session-messages.test.ts +182 -0
- package/test/server/session-select.test.ts +69 -0
- package/test/server/workspace-proxy.test.ts +181 -0
- package/test/server/workspace-routing.test.ts +94 -0
- package/test/server/worktree-endpoint-repro.test.ts +307 -0
- package/test/session/compaction.test.ts +1835 -0
- package/test/session/instruction.test.ts +256 -0
- package/test/session/llm-native-recorded.test.ts +433 -0
- package/test/session/llm-native.test.ts +760 -0
- package/test/session/llm.test.ts +1932 -0
- package/test/session/message-v2.test.ts +1661 -0
- package/test/session/messages-pagination.test.ts +1059 -0
- package/test/session/processor-effect.test.ts +1101 -0
- package/test/session/prompt.test.ts +2318 -0
- package/test/session/retry.test.ts +439 -0
- package/test/session/revert-compact.test.ts +642 -0
- package/test/session/schema-decoding.test.ts +313 -0
- package/test/session/session-schema.test.ts +78 -0
- package/test/session/session.test.ts +251 -0
- package/test/session/snapshot-tool-race.test.ts +280 -0
- package/test/session/structured-output-integration.test.ts +235 -0
- package/test/session/structured-output.test.ts +387 -0
- package/test/session/system.test.ts +84 -0
- package/test/share/share-next.test.ts +344 -0
- package/test/shell/shell.test.ts +99 -0
- package/test/skill/discovery.test.ts +139 -0
- package/test/skill/skill.test.ts +571 -0
- package/test/snapshot/snapshot.test.ts +1121 -0
- package/test/storage/storage.test.ts +296 -0
- package/test/storage/workspace-time-migration.test.ts +50 -0
- package/test/tool/__snapshots__/parameters.test.ts.snap +484 -0
- package/test/tool/__snapshots__/tool.test.ts.snap +9 -0
- package/test/tool/apply_patch.test.ts +533 -0
- package/test/tool/edit.test.ts +578 -0
- package/test/tool/external-directory.test.ts +155 -0
- package/test/tool/fixtures/large-image.png +0 -0
- package/test/tool/fixtures/models-api.json +117299 -0
- package/test/tool/glob.test.ts +188 -0
- package/test/tool/grep.test.ts +266 -0
- package/test/tool/lsp.test.ts +181 -0
- package/test/tool/parameters.test.ts +293 -0
- package/test/tool/question.test.ts +138 -0
- package/test/tool/read.test.ts +654 -0
- package/test/tool/registry.test.ts +539 -0
- package/test/tool/shell.test.ts +1238 -0
- package/test/tool/skill.test.ts +132 -0
- package/test/tool/task.test.ts +901 -0
- package/test/tool/tool-define.test.ts +153 -0
- package/test/tool/truncation.test.ts +266 -0
- package/test/tool/webfetch.test.ts +113 -0
- package/test/tool/websearch.test.ts +99 -0
- package/test/tool/write.test.ts +276 -0
- package/test/util/data-url.test.ts +14 -0
- package/test/util/error.test.ts +64 -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/log.test.ts +77 -0
- package/test/util/module.test.ts +59 -0
- package/test/util/process.test.ts +128 -0
- package/test/util/repository.test.ts +93 -0
- package/test/util/timeout.test.ts +21 -0
- package/test/util/wildcard.test.ts +90 -0
- package/test/v2/session-message-updater.test.ts +270 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,1184 @@
|
|
|
1
|
+
import type { TuiPlugin, TuiPluginApi } from "@opencode-ai/plugin/tui"
|
|
2
|
+
import type { InternalTuiPlugin } from "../../plugin/internal"
|
|
3
|
+
import { useSyncV2 } from "@tui/context/sync-v2"
|
|
4
|
+
import { SplitBorder } from "@tui/component/border"
|
|
5
|
+
import { Spinner } from "@tui/component/spinner"
|
|
6
|
+
import { useTheme } from "@tui/context/theme"
|
|
7
|
+
import { useLocal } from "@tui/context/local"
|
|
8
|
+
import { reasoningSummary, useThinkingMode } from "@tui/context/thinking"
|
|
9
|
+
import { useRenderer, useTerminalDimensions, type JSX } from "@opentui/solid"
|
|
10
|
+
import { RGBA, TextAttributes, type BoxRenderable, type SyntaxStyle } from "@opentui/core"
|
|
11
|
+
import { useBindings } from "../../keymap"
|
|
12
|
+
import { Locale } from "@/util/locale"
|
|
13
|
+
import { LANGUAGE_EXTENSIONS } from "@/lsp/language"
|
|
14
|
+
import { webSearchProviderLabel } from "@/tool/websearch"
|
|
15
|
+
import path from "path"
|
|
16
|
+
import stripAnsi from "strip-ansi"
|
|
17
|
+
import type {
|
|
18
|
+
SessionMessage,
|
|
19
|
+
SessionMessageAgentSwitched,
|
|
20
|
+
SessionMessageAssistant,
|
|
21
|
+
SessionMessageAssistantReasoning,
|
|
22
|
+
SessionMessageAssistantText,
|
|
23
|
+
SessionMessageAssistantTool,
|
|
24
|
+
SessionMessageCompaction,
|
|
25
|
+
SessionMessageModelSwitched,
|
|
26
|
+
SessionMessageShell,
|
|
27
|
+
SessionMessageUser,
|
|
28
|
+
ToolFileContent,
|
|
29
|
+
ToolTextContent,
|
|
30
|
+
} from "@opencode-ai/sdk/v2"
|
|
31
|
+
import { createEffect, createMemo, createSignal, For, Match, Show, Switch } from "solid-js"
|
|
32
|
+
import { collapseToolOutput } from "../../util/collapse-tool-output"
|
|
33
|
+
import { setPreLayoutSiblingMargin } from "../../util/layout"
|
|
34
|
+
|
|
35
|
+
const id = "internal:session-v2-debug"
|
|
36
|
+
const route = "session.v2.messages"
|
|
37
|
+
|
|
38
|
+
function currentSessionID(api: TuiPluginApi) {
|
|
39
|
+
const current = api.route.current
|
|
40
|
+
if (current.name !== "session") return
|
|
41
|
+
const sessionID = current.params?.sessionID
|
|
42
|
+
return typeof sessionID === "string" ? sessionID : undefined
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function View(props: { api: TuiPluginApi; sessionID: string }) {
|
|
46
|
+
const sync = useSyncV2()
|
|
47
|
+
const dimensions = useTerminalDimensions()
|
|
48
|
+
const { theme, syntax, subtleSyntax } = useTheme()
|
|
49
|
+
const messages = createMemo(() => sync.data.messages[props.sessionID] ?? [])
|
|
50
|
+
const renderedMessages = createMemo(() => messages().toReversed())
|
|
51
|
+
const lastAssistant = createMemo(() => renderedMessages().findLast((message) => message.type === "assistant"))
|
|
52
|
+
const lastUserCreated = (index: number) =>
|
|
53
|
+
renderedMessages()
|
|
54
|
+
.slice(0, index)
|
|
55
|
+
.findLast((message) => message.type === "user")?.time.created
|
|
56
|
+
|
|
57
|
+
createEffect(() => {
|
|
58
|
+
void sync.session.message.sync(props.sessionID)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
useBindings(() => ({
|
|
62
|
+
bindings: [
|
|
63
|
+
{
|
|
64
|
+
key: "escape",
|
|
65
|
+
desc: "Back to session",
|
|
66
|
+
group: "Session",
|
|
67
|
+
cmd() {
|
|
68
|
+
props.api.route.navigate("session", { sessionID: props.sessionID })
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
}))
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<box width={dimensions().width} height={dimensions().height} backgroundColor={theme.background}>
|
|
76
|
+
<box flexDirection="row">
|
|
77
|
+
<box flexGrow={1} paddingBottom={1} paddingLeft={2} paddingRight={2} gap={1}>
|
|
78
|
+
<scrollbox
|
|
79
|
+
viewportOptions={{ paddingRight: 0 }}
|
|
80
|
+
verticalScrollbarOptions={{ visible: false }}
|
|
81
|
+
stickyScroll={true}
|
|
82
|
+
stickyStart="bottom"
|
|
83
|
+
flexGrow={1}
|
|
84
|
+
>
|
|
85
|
+
<box height={1} />
|
|
86
|
+
<Show when={messages().length === 0}>
|
|
87
|
+
<MissingData label="Messages" detail="No v2 messages loaded from useSyncV2 yet." />
|
|
88
|
+
</Show>
|
|
89
|
+
<For each={renderedMessages()}>
|
|
90
|
+
{(message, index) => (
|
|
91
|
+
<Switch>
|
|
92
|
+
<Match when={message.type === "user"}>
|
|
93
|
+
<UserMessage message={message as SessionMessageUser} index={index()} />
|
|
94
|
+
</Match>
|
|
95
|
+
<Match when={message.type === "assistant"}>
|
|
96
|
+
<AssistantMessage
|
|
97
|
+
message={message as SessionMessageAssistant}
|
|
98
|
+
sessionID={props.sessionID}
|
|
99
|
+
last={lastAssistant()?.id === message.id}
|
|
100
|
+
syntax={syntax()}
|
|
101
|
+
subtleSyntax={subtleSyntax()}
|
|
102
|
+
start={lastUserCreated(index())}
|
|
103
|
+
/>
|
|
104
|
+
</Match>
|
|
105
|
+
<Match when={message.type === "synthetic"}>
|
|
106
|
+
<></>
|
|
107
|
+
</Match>
|
|
108
|
+
<Match when={message.type === "system"}>
|
|
109
|
+
<></>
|
|
110
|
+
</Match>
|
|
111
|
+
<Match when={message.type === "shell"}>
|
|
112
|
+
<ShellMessage message={message as SessionMessageShell} />
|
|
113
|
+
</Match>
|
|
114
|
+
<Match when={message.type === "compaction"}>
|
|
115
|
+
<CompactionMessage message={message as SessionMessageCompaction} />
|
|
116
|
+
</Match>
|
|
117
|
+
<Match when={message.type === "agent-switched"}>
|
|
118
|
+
<AgentSwitchedMessage message={message as SessionMessageAgentSwitched} />
|
|
119
|
+
</Match>
|
|
120
|
+
<Match when={message.type === "model-switched"}>
|
|
121
|
+
<ModelSwitchedMessage message={message as SessionMessageModelSwitched} />
|
|
122
|
+
</Match>
|
|
123
|
+
<Match when={true}>
|
|
124
|
+
<UnknownMessage message={message} />
|
|
125
|
+
</Match>
|
|
126
|
+
</Switch>
|
|
127
|
+
)}
|
|
128
|
+
</For>
|
|
129
|
+
</scrollbox>
|
|
130
|
+
<MissingData
|
|
131
|
+
label="Session prompt, permission prompt, question prompt, sidebar"
|
|
132
|
+
detail="The v2 message endpoint only exposes messages, so these session UI regions cannot be rendered here. Press Esc to return to the live session."
|
|
133
|
+
/>
|
|
134
|
+
</box>
|
|
135
|
+
</box>
|
|
136
|
+
</box>
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function MissingData(props: { label: string; detail: string }) {
|
|
141
|
+
const { theme } = useTheme()
|
|
142
|
+
return (
|
|
143
|
+
<box
|
|
144
|
+
border={["left"]}
|
|
145
|
+
customBorderChars={SplitBorder.customBorderChars}
|
|
146
|
+
borderColor={theme.warning}
|
|
147
|
+
backgroundColor={theme.backgroundPanel}
|
|
148
|
+
paddingLeft={2}
|
|
149
|
+
paddingTop={1}
|
|
150
|
+
paddingBottom={1}
|
|
151
|
+
marginTop={1}
|
|
152
|
+
flexShrink={0}
|
|
153
|
+
>
|
|
154
|
+
<text fg={theme.text}>
|
|
155
|
+
<span style={{ bg: theme.warning, fg: theme.background, bold: true }}> MISSING DATA </span> {props.label}
|
|
156
|
+
</text>
|
|
157
|
+
<text fg={theme.textMuted}>{props.detail}</text>
|
|
158
|
+
</box>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function UserMessage(props: { message: SessionMessageUser; index: number }) {
|
|
163
|
+
const { theme } = useTheme()
|
|
164
|
+
const attachments = createMemo(() => [...(props.message.files ?? []), ...(props.message.agents ?? [])])
|
|
165
|
+
return (
|
|
166
|
+
<box
|
|
167
|
+
id={props.message.id}
|
|
168
|
+
border={["left"]}
|
|
169
|
+
borderColor={theme.secondary}
|
|
170
|
+
customBorderChars={SplitBorder.customBorderChars}
|
|
171
|
+
marginTop={props.index === 0 ? 0 : 1}
|
|
172
|
+
flexShrink={0}
|
|
173
|
+
paddingTop={1}
|
|
174
|
+
paddingBottom={1}
|
|
175
|
+
paddingLeft={2}
|
|
176
|
+
backgroundColor={theme.backgroundPanel}
|
|
177
|
+
>
|
|
178
|
+
<text fg={theme.text}>{props.message.text}</text>
|
|
179
|
+
<Show when={attachments().length}>
|
|
180
|
+
<box flexDirection="row" paddingTop={1} gap={1} flexWrap="wrap">
|
|
181
|
+
<For each={props.message.files ?? []}>
|
|
182
|
+
{(file) => (
|
|
183
|
+
<text fg={theme.text}>
|
|
184
|
+
<span style={{ bg: theme.secondary, fg: theme.background }}> {file.mime} </span>
|
|
185
|
+
<span style={{ bg: theme.backgroundElement, fg: theme.textMuted }}> {file.name ?? file.uri} </span>
|
|
186
|
+
</text>
|
|
187
|
+
)}
|
|
188
|
+
</For>
|
|
189
|
+
<For each={props.message.agents ?? []}>
|
|
190
|
+
{(agent) => (
|
|
191
|
+
<text fg={theme.text}>
|
|
192
|
+
<span style={{ bg: theme.accent, fg: theme.background }}> agent </span>
|
|
193
|
+
<span style={{ bg: theme.backgroundElement, fg: theme.textMuted }}> {agent.name} </span>
|
|
194
|
+
</text>
|
|
195
|
+
)}
|
|
196
|
+
</For>
|
|
197
|
+
</box>
|
|
198
|
+
</Show>
|
|
199
|
+
</box>
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function ShellMessage(props: { message: SessionMessageShell }) {
|
|
204
|
+
const { theme } = useTheme()
|
|
205
|
+
const dimensions = useTerminalDimensions()
|
|
206
|
+
const output = createMemo(() => stripAnsi(props.message.output.trim()))
|
|
207
|
+
const [expanded, setExpanded] = createSignal(false)
|
|
208
|
+
const maxLines = 10
|
|
209
|
+
const maxChars = createMemo(() => maxLines * Math.max(20, dimensions().width - 6))
|
|
210
|
+
const collapsed = createMemo(() => collapseToolOutput(output(), maxLines, maxChars()))
|
|
211
|
+
const limited = createMemo(() => {
|
|
212
|
+
if (expanded() || !collapsed().overflow) return output()
|
|
213
|
+
return collapsed().output
|
|
214
|
+
})
|
|
215
|
+
return (
|
|
216
|
+
<BlockTool
|
|
217
|
+
title="# Shell"
|
|
218
|
+
spinner={!props.message.time.completed}
|
|
219
|
+
onClick={collapsed().overflow ? () => setExpanded((prev) => !prev) : undefined}
|
|
220
|
+
>
|
|
221
|
+
<box gap={1}>
|
|
222
|
+
<text fg={theme.text}>$ {props.message.command}</text>
|
|
223
|
+
<Show when={output()}>
|
|
224
|
+
<text fg={theme.text}>{limited()}</text>
|
|
225
|
+
</Show>
|
|
226
|
+
<Show when={collapsed().overflow}>
|
|
227
|
+
<text fg={theme.textMuted}>{expanded() ? "Click to collapse" : "Click to expand"}</text>
|
|
228
|
+
</Show>
|
|
229
|
+
</box>
|
|
230
|
+
</BlockTool>
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function CompactionMessage(props: { message: SessionMessageCompaction }) {
|
|
235
|
+
const { theme } = useTheme()
|
|
236
|
+
return (
|
|
237
|
+
<box
|
|
238
|
+
marginTop={1}
|
|
239
|
+
border={["top"]}
|
|
240
|
+
title={props.message.reason === "auto" ? " Auto Compaction " : " Compaction "}
|
|
241
|
+
titleAlignment="center"
|
|
242
|
+
borderColor={theme.borderActive}
|
|
243
|
+
flexShrink={0}
|
|
244
|
+
/>
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function AgentSwitchedMessage(props: { message: SessionMessageAgentSwitched }) {
|
|
249
|
+
const { theme } = useTheme()
|
|
250
|
+
const local = useLocal()
|
|
251
|
+
return (
|
|
252
|
+
<box paddingLeft={3} marginTop={1} flexShrink={0}>
|
|
253
|
+
<text>
|
|
254
|
+
<span style={{ fg: local.agent.color(props.message.agent) }}>▣ </span>
|
|
255
|
+
<span style={{ fg: theme.textMuted }}>Switched agent to </span>
|
|
256
|
+
<span style={{ fg: theme.text }}>{Locale.titlecase(props.message.agent)}</span>
|
|
257
|
+
</text>
|
|
258
|
+
</box>
|
|
259
|
+
)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function ModelSwitchedMessage(props: { message: SessionMessageModelSwitched }) {
|
|
263
|
+
const { theme } = useTheme()
|
|
264
|
+
const model = createMemo(() => {
|
|
265
|
+
const variant = props.message.model.variant ? `/${props.message.model.variant}` : ""
|
|
266
|
+
return `${props.message.model.providerID}/${props.message.model.id}${variant}`
|
|
267
|
+
})
|
|
268
|
+
return (
|
|
269
|
+
<box paddingLeft={3} marginTop={1} flexShrink={0}>
|
|
270
|
+
<text>
|
|
271
|
+
<span style={{ fg: theme.secondary }}>◇ </span>
|
|
272
|
+
<span style={{ fg: theme.textMuted }}>Switched model to </span>
|
|
273
|
+
<span style={{ fg: theme.text }}>{model()}</span>
|
|
274
|
+
</text>
|
|
275
|
+
</box>
|
|
276
|
+
)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function UnknownMessage(props: { message: SessionMessage }) {
|
|
280
|
+
return <MissingData label="Unknown message type" detail={JSON.stringify(props.message)} />
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function AssistantMessage(props: {
|
|
284
|
+
message: SessionMessageAssistant
|
|
285
|
+
sessionID: string
|
|
286
|
+
last: boolean
|
|
287
|
+
syntax: SyntaxStyle
|
|
288
|
+
subtleSyntax: SyntaxStyle
|
|
289
|
+
start?: number
|
|
290
|
+
}) {
|
|
291
|
+
const { theme } = useTheme()
|
|
292
|
+
const local = useLocal()
|
|
293
|
+
const duration = createMemo(() => {
|
|
294
|
+
if (!props.message.time.completed) return 0
|
|
295
|
+
return props.message.time.completed - (props.start ?? props.message.time.created)
|
|
296
|
+
})
|
|
297
|
+
const model = createMemo(() => {
|
|
298
|
+
const variant = props.message.model.variant ? `/${props.message.model.variant}` : ""
|
|
299
|
+
return `${props.message.model.providerID}/${props.message.model.id}${variant}`
|
|
300
|
+
})
|
|
301
|
+
const final = createMemo(() => props.message.finish && !["tool-calls", "unknown"].includes(props.message.finish))
|
|
302
|
+
return (
|
|
303
|
+
<>
|
|
304
|
+
<For each={props.message.content}>
|
|
305
|
+
{(part) => (
|
|
306
|
+
<Switch>
|
|
307
|
+
<Match when={part.type === "text"}>
|
|
308
|
+
<AssistantText part={part as SessionMessageAssistantText} syntax={props.syntax} />
|
|
309
|
+
</Match>
|
|
310
|
+
<Match when={part.type === "reasoning"}>
|
|
311
|
+
<AssistantReasoning
|
|
312
|
+
part={part as SessionMessageAssistantReasoning}
|
|
313
|
+
subtleSyntax={props.subtleSyntax}
|
|
314
|
+
completedAt={() => props.message.time.completed}
|
|
315
|
+
/>
|
|
316
|
+
</Match>
|
|
317
|
+
<Match when={part.type === "tool"}>
|
|
318
|
+
<AssistantTool part={part as SessionMessageAssistantTool} sessionID={props.sessionID} />
|
|
319
|
+
</Match>
|
|
320
|
+
</Switch>
|
|
321
|
+
)}
|
|
322
|
+
</For>
|
|
323
|
+
<Show when={props.message.content.length === 0}>
|
|
324
|
+
<MissingData label="Assistant content" detail={`Assistant message ${props.message.id} has no content items.`} />
|
|
325
|
+
</Show>
|
|
326
|
+
<Show when={props.message.error}>
|
|
327
|
+
<box
|
|
328
|
+
border={["left"]}
|
|
329
|
+
paddingTop={1}
|
|
330
|
+
paddingBottom={1}
|
|
331
|
+
paddingLeft={2}
|
|
332
|
+
marginTop={1}
|
|
333
|
+
backgroundColor={theme.backgroundPanel}
|
|
334
|
+
customBorderChars={SplitBorder.customBorderChars}
|
|
335
|
+
borderColor={theme.error}
|
|
336
|
+
flexShrink={0}
|
|
337
|
+
>
|
|
338
|
+
<text fg={theme.textMuted}>{props.message.error}</text>
|
|
339
|
+
</box>
|
|
340
|
+
</Show>
|
|
341
|
+
<Show when={props.last || final() || props.message.error}>
|
|
342
|
+
<box paddingLeft={3} flexShrink={0}>
|
|
343
|
+
<text marginTop={1}>
|
|
344
|
+
<span style={{ fg: local.agent.color(props.message.agent) }}>▣ </span>
|
|
345
|
+
<span style={{ fg: theme.text }}>{Locale.titlecase(props.message.agent)}</span>
|
|
346
|
+
<span style={{ fg: theme.textMuted }}> · {model()}</span>
|
|
347
|
+
<Show when={duration()}>
|
|
348
|
+
<span style={{ fg: theme.textMuted }}> · {Locale.duration(duration())}</span>
|
|
349
|
+
</Show>
|
|
350
|
+
</text>
|
|
351
|
+
</box>
|
|
352
|
+
</Show>
|
|
353
|
+
</>
|
|
354
|
+
)
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function AssistantText(props: { part: SessionMessageAssistantText; syntax: SyntaxStyle }) {
|
|
358
|
+
const { theme } = useTheme()
|
|
359
|
+
return (
|
|
360
|
+
<Show when={props.part.text.trim()}>
|
|
361
|
+
<box paddingLeft={3} marginTop={1} flexShrink={0} id={`text-${props.part.id}`}>
|
|
362
|
+
<code
|
|
363
|
+
filetype="markdown"
|
|
364
|
+
drawUnstyledText={false}
|
|
365
|
+
streaming={true}
|
|
366
|
+
syntaxStyle={props.syntax}
|
|
367
|
+
content={props.part.text.trim()}
|
|
368
|
+
conceal={true}
|
|
369
|
+
fg={theme.text}
|
|
370
|
+
/>
|
|
371
|
+
</box>
|
|
372
|
+
</Show>
|
|
373
|
+
)
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function AssistantReasoning(props: {
|
|
377
|
+
part: SessionMessageAssistantReasoning
|
|
378
|
+
subtleSyntax: SyntaxStyle
|
|
379
|
+
completedAt: () => number | undefined
|
|
380
|
+
}) {
|
|
381
|
+
const { theme } = useTheme()
|
|
382
|
+
const thinking = useThinkingMode()
|
|
383
|
+
const [expanded, setExpanded] = createSignal(false)
|
|
384
|
+
const content = createMemo(() => props.part.text.replace("[REDACTED]", "").trim())
|
|
385
|
+
const inMinimal = createMemo(() => thinking.mode() === "hide")
|
|
386
|
+
// v2 reasoning parts have no per-part `time.end` (see SessionMessageAssistantReasoning
|
|
387
|
+
// in the v2 SDK); we settle on parent-message completion instead.
|
|
388
|
+
const isDone = createMemo(() => props.completedAt() !== undefined)
|
|
389
|
+
const summary = createMemo(() => reasoningSummary(content()))
|
|
390
|
+
|
|
391
|
+
const toggle = () => {
|
|
392
|
+
if (!inMinimal()) return
|
|
393
|
+
setExpanded((prev) => !prev)
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return (
|
|
397
|
+
<Show when={content()}>
|
|
398
|
+
<box paddingLeft={3} marginTop={1} flexDirection="column" flexShrink={0}>
|
|
399
|
+
<box onMouseUp={toggle}>
|
|
400
|
+
<ReasoningHeader
|
|
401
|
+
toggleable={inMinimal()}
|
|
402
|
+
open={!inMinimal() || expanded()}
|
|
403
|
+
done={isDone()}
|
|
404
|
+
title={summary().title}
|
|
405
|
+
/>
|
|
406
|
+
</box>
|
|
407
|
+
<Show when={(!inMinimal() || expanded()) && summary().body}>
|
|
408
|
+
<box paddingLeft={inMinimal() ? 2 : 0} marginTop={1}>
|
|
409
|
+
<code
|
|
410
|
+
filetype="markdown"
|
|
411
|
+
drawUnstyledText={false}
|
|
412
|
+
streaming={true}
|
|
413
|
+
syntaxStyle={props.subtleSyntax}
|
|
414
|
+
content={summary().body}
|
|
415
|
+
conceal={true}
|
|
416
|
+
fg={theme.textMuted}
|
|
417
|
+
/>
|
|
418
|
+
</box>
|
|
419
|
+
</Show>
|
|
420
|
+
</box>
|
|
421
|
+
</Show>
|
|
422
|
+
)
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function ReasoningHeader(props: { toggleable: boolean; open: boolean; done: boolean; title: string | null }) {
|
|
426
|
+
const { theme } = useTheme()
|
|
427
|
+
const fg = () =>
|
|
428
|
+
props.open
|
|
429
|
+
? RGBA.fromValues(theme.warning.r, theme.warning.g, theme.warning.b, theme.thinkingOpacity)
|
|
430
|
+
: theme.warning
|
|
431
|
+
|
|
432
|
+
return (
|
|
433
|
+
<Switch>
|
|
434
|
+
<Match when={!props.done}>
|
|
435
|
+
<box flexDirection="row">
|
|
436
|
+
<Spinner color={fg()}>{props.title ? "Thinking: " + props.title : "Thinking"}</Spinner>
|
|
437
|
+
</box>
|
|
438
|
+
</Match>
|
|
439
|
+
<Match when={true}>
|
|
440
|
+
<text fg={fg()} wrapMode="none">
|
|
441
|
+
<Show when={props.toggleable}>
|
|
442
|
+
<span>{props.open ? "- " : "+ "}</span>
|
|
443
|
+
</Show>
|
|
444
|
+
<span>Thought</span>
|
|
445
|
+
<Show when={props.title}>
|
|
446
|
+
<span>: </span>
|
|
447
|
+
<span>{props.title}</span>
|
|
448
|
+
</Show>
|
|
449
|
+
</text>
|
|
450
|
+
</Match>
|
|
451
|
+
</Switch>
|
|
452
|
+
)
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
function AssistantTool(props: { part: SessionMessageAssistantTool; sessionID: string }) {
|
|
456
|
+
const input = createMemo(() => toolInputRecord(props.part.state.input))
|
|
457
|
+
const toolprops = {
|
|
458
|
+
get input() {
|
|
459
|
+
return input()
|
|
460
|
+
},
|
|
461
|
+
get metadata() {
|
|
462
|
+
return props.part.provider?.metadata ?? {}
|
|
463
|
+
},
|
|
464
|
+
get output() {
|
|
465
|
+
return props.part.state.status === "pending" ? undefined : toolOutput(props.part.state.content)
|
|
466
|
+
},
|
|
467
|
+
sessionID: props.sessionID,
|
|
468
|
+
part: props.part,
|
|
469
|
+
}
|
|
470
|
+
return (
|
|
471
|
+
<Switch>
|
|
472
|
+
<Match when={props.part.name === "bash"}>
|
|
473
|
+
<Bash {...toolprops} />
|
|
474
|
+
</Match>
|
|
475
|
+
<Match when={props.part.name === "glob"}>
|
|
476
|
+
<Glob {...toolprops} />
|
|
477
|
+
</Match>
|
|
478
|
+
<Match when={props.part.name === "read"}>
|
|
479
|
+
<Read {...toolprops} />
|
|
480
|
+
</Match>
|
|
481
|
+
<Match when={props.part.name === "grep"}>
|
|
482
|
+
<Grep {...toolprops} />
|
|
483
|
+
</Match>
|
|
484
|
+
<Match when={props.part.name === "webfetch"}>
|
|
485
|
+
<WebFetch {...toolprops} />
|
|
486
|
+
</Match>
|
|
487
|
+
<Match when={props.part.name === "websearch"}>
|
|
488
|
+
<WebSearch {...toolprops} />
|
|
489
|
+
</Match>
|
|
490
|
+
<Match when={props.part.name === "write"}>
|
|
491
|
+
<Write {...toolprops} />
|
|
492
|
+
</Match>
|
|
493
|
+
<Match when={props.part.name === "edit"}>
|
|
494
|
+
<Edit {...toolprops} />
|
|
495
|
+
</Match>
|
|
496
|
+
<Match when={props.part.name === "apply_patch"}>
|
|
497
|
+
<ApplyPatch {...toolprops} />
|
|
498
|
+
</Match>
|
|
499
|
+
<Match when={props.part.name === "todowrite"}>
|
|
500
|
+
<TodoWrite {...toolprops} />
|
|
501
|
+
</Match>
|
|
502
|
+
<Match when={props.part.name === "question"}>
|
|
503
|
+
<Question {...toolprops} />
|
|
504
|
+
</Match>
|
|
505
|
+
<Match when={props.part.name === "skill"}>
|
|
506
|
+
<Skill {...toolprops} />
|
|
507
|
+
</Match>
|
|
508
|
+
<Match when={props.part.name === "task"}>
|
|
509
|
+
<Task {...toolprops} />
|
|
510
|
+
</Match>
|
|
511
|
+
<Match when={true}>
|
|
512
|
+
<GenericTool {...toolprops} />
|
|
513
|
+
</Match>
|
|
514
|
+
</Switch>
|
|
515
|
+
)
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
type ToolProps = {
|
|
519
|
+
input: Record<string, unknown>
|
|
520
|
+
metadata: Record<string, unknown>
|
|
521
|
+
output?: string
|
|
522
|
+
sessionID: string
|
|
523
|
+
part: SessionMessageAssistantTool
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function GenericTool(props: ToolProps) {
|
|
527
|
+
const { theme } = useTheme()
|
|
528
|
+
const dimensions = useTerminalDimensions()
|
|
529
|
+
const output = createMemo(() => props.output?.trim() ?? "")
|
|
530
|
+
const [expanded, setExpanded] = createSignal(false)
|
|
531
|
+
const maxLines = 3
|
|
532
|
+
const maxChars = createMemo(() => maxLines * Math.max(20, dimensions().width - 6))
|
|
533
|
+
const collapsed = createMemo(() => collapseToolOutput(output(), maxLines, maxChars()))
|
|
534
|
+
const limited = createMemo(() => {
|
|
535
|
+
if (expanded() || !collapsed().overflow) return output()
|
|
536
|
+
return collapsed().output
|
|
537
|
+
})
|
|
538
|
+
return (
|
|
539
|
+
<Show
|
|
540
|
+
when={output()}
|
|
541
|
+
fallback={
|
|
542
|
+
<InlineTool icon="⚙" pending="Writing command..." complete={toolComplete(props.part)} part={props.part}>
|
|
543
|
+
{props.part.name} {input(props.input)}
|
|
544
|
+
</InlineTool>
|
|
545
|
+
}
|
|
546
|
+
>
|
|
547
|
+
<BlockTool
|
|
548
|
+
title={`# ${props.part.name} ${input(props.input)}`}
|
|
549
|
+
part={props.part}
|
|
550
|
+
onClick={collapsed().overflow ? () => setExpanded((prev) => !prev) : undefined}
|
|
551
|
+
>
|
|
552
|
+
<box gap={1}>
|
|
553
|
+
<text fg={theme.text}>{limited()}</text>
|
|
554
|
+
<Show when={collapsed().overflow}>
|
|
555
|
+
<text fg={theme.textMuted}>{expanded() ? "Click to collapse" : "Click to expand"}</text>
|
|
556
|
+
</Show>
|
|
557
|
+
</box>
|
|
558
|
+
</BlockTool>
|
|
559
|
+
</Show>
|
|
560
|
+
)
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function InlineTool(props: {
|
|
564
|
+
icon: string
|
|
565
|
+
complete: unknown
|
|
566
|
+
pending: string
|
|
567
|
+
spinner?: boolean
|
|
568
|
+
children: JSX.Element
|
|
569
|
+
part: SessionMessageAssistantTool
|
|
570
|
+
}) {
|
|
571
|
+
const { theme } = useTheme()
|
|
572
|
+
const renderer = useRenderer()
|
|
573
|
+
const [hover, setHover] = createSignal(false)
|
|
574
|
+
const [showError, setShowError] = createSignal(false)
|
|
575
|
+
const error = createMemo(() => (props.part.state.status === "error" ? props.part.state.error.message : undefined))
|
|
576
|
+
const complete = createMemo(() => !!props.complete)
|
|
577
|
+
const denied = createMemo(() => {
|
|
578
|
+
const message = error()
|
|
579
|
+
if (!message) return false
|
|
580
|
+
return (
|
|
581
|
+
message.includes("QuestionRejectedError") ||
|
|
582
|
+
message.includes("rejected permission") ||
|
|
583
|
+
message.includes("specified a rule") ||
|
|
584
|
+
message.includes("user dismissed")
|
|
585
|
+
)
|
|
586
|
+
})
|
|
587
|
+
const fg = createMemo(() => {
|
|
588
|
+
if (error()) return theme.error
|
|
589
|
+
if (complete()) return theme.textMuted
|
|
590
|
+
return theme.text
|
|
591
|
+
})
|
|
592
|
+
const attributes = createMemo(() => (denied() ? TextAttributes.STRIKETHROUGH : undefined))
|
|
593
|
+
return (
|
|
594
|
+
<box
|
|
595
|
+
paddingLeft={3}
|
|
596
|
+
flexShrink={0}
|
|
597
|
+
flexDirection="row"
|
|
598
|
+
gap={1}
|
|
599
|
+
backgroundColor={hover() && error() ? theme.backgroundMenu : undefined}
|
|
600
|
+
onMouseOver={() => error() && setHover(true)}
|
|
601
|
+
onMouseOut={() => setHover(false)}
|
|
602
|
+
onMouseUp={() => {
|
|
603
|
+
if (!error()) return
|
|
604
|
+
if (renderer.getSelection()?.getSelectedText()) return
|
|
605
|
+
setShowError((prev) => !prev)
|
|
606
|
+
}}
|
|
607
|
+
ref={(el: BoxRenderable) => {
|
|
608
|
+
setPreLayoutSiblingMargin(el, (previous) => (previous?.id.startsWith("text-") ? 1 : 0))
|
|
609
|
+
}}
|
|
610
|
+
>
|
|
611
|
+
<box flexShrink={0}>
|
|
612
|
+
<Switch>
|
|
613
|
+
<Match when={props.spinner}>
|
|
614
|
+
<Spinner color={theme.text} />
|
|
615
|
+
</Match>
|
|
616
|
+
<Match when={complete()}>
|
|
617
|
+
<text fg={fg()} attributes={attributes()}>
|
|
618
|
+
{props.icon}
|
|
619
|
+
</text>
|
|
620
|
+
</Match>
|
|
621
|
+
<Match when={true}>
|
|
622
|
+
<text fg={fg()} attributes={attributes()}>
|
|
623
|
+
~
|
|
624
|
+
</text>
|
|
625
|
+
</Match>
|
|
626
|
+
</Switch>
|
|
627
|
+
</box>
|
|
628
|
+
<box flexGrow={1}>
|
|
629
|
+
<box>
|
|
630
|
+
<Switch>
|
|
631
|
+
<Match when={complete()}>
|
|
632
|
+
<text fg={fg()} attributes={attributes()}>
|
|
633
|
+
{props.children}
|
|
634
|
+
</text>
|
|
635
|
+
</Match>
|
|
636
|
+
<Match when={true}>
|
|
637
|
+
<text fg={fg()} attributes={attributes()}>
|
|
638
|
+
{props.pending}
|
|
639
|
+
</text>
|
|
640
|
+
</Match>
|
|
641
|
+
</Switch>
|
|
642
|
+
</box>
|
|
643
|
+
<Show when={showError() && error()}>
|
|
644
|
+
<box>
|
|
645
|
+
<text fg={theme.error}>{error()}</text>
|
|
646
|
+
</box>
|
|
647
|
+
</Show>
|
|
648
|
+
</box>
|
|
649
|
+
</box>
|
|
650
|
+
)
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
function BlockTool(props: {
|
|
654
|
+
title: string
|
|
655
|
+
children: JSX.Element
|
|
656
|
+
part?: SessionMessageAssistantTool
|
|
657
|
+
onClick?: () => void
|
|
658
|
+
spinner?: boolean
|
|
659
|
+
}) {
|
|
660
|
+
const { theme } = useTheme()
|
|
661
|
+
const renderer = useRenderer()
|
|
662
|
+
const [hover, setHover] = createSignal(false)
|
|
663
|
+
const error = createMemo(() => (props.part?.state.status === "error" ? props.part.state.error.message : undefined))
|
|
664
|
+
return (
|
|
665
|
+
<box
|
|
666
|
+
border={["left"]}
|
|
667
|
+
paddingTop={1}
|
|
668
|
+
paddingBottom={1}
|
|
669
|
+
paddingLeft={2}
|
|
670
|
+
marginTop={1}
|
|
671
|
+
gap={1}
|
|
672
|
+
backgroundColor={hover() ? theme.backgroundMenu : theme.backgroundPanel}
|
|
673
|
+
customBorderChars={SplitBorder.customBorderChars}
|
|
674
|
+
borderColor={theme.background}
|
|
675
|
+
onMouseOver={() => props.onClick && setHover(true)}
|
|
676
|
+
onMouseOut={() => setHover(false)}
|
|
677
|
+
onMouseUp={() => {
|
|
678
|
+
if (renderer.getSelection()?.getSelectedText()) return
|
|
679
|
+
props.onClick?.()
|
|
680
|
+
}}
|
|
681
|
+
flexShrink={0}
|
|
682
|
+
>
|
|
683
|
+
<Show
|
|
684
|
+
when={props.spinner}
|
|
685
|
+
fallback={
|
|
686
|
+
<text paddingLeft={3} fg={theme.textMuted}>
|
|
687
|
+
{props.title}
|
|
688
|
+
</text>
|
|
689
|
+
}
|
|
690
|
+
>
|
|
691
|
+
<Spinner color={theme.textMuted}>{props.title.replace(/^# /, "")}</Spinner>
|
|
692
|
+
</Show>
|
|
693
|
+
{props.children}
|
|
694
|
+
<Show when={error()}>
|
|
695
|
+
<text fg={theme.error}>{error()}</text>
|
|
696
|
+
</Show>
|
|
697
|
+
</box>
|
|
698
|
+
)
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
function Bash(props: ToolProps) {
|
|
702
|
+
const { theme } = useTheme()
|
|
703
|
+
const dimensions = useTerminalDimensions()
|
|
704
|
+
const output = createMemo(() => stripAnsi((stringValue(props.metadata.output) ?? props.output ?? "").trim()))
|
|
705
|
+
const command = createMemo(() => stringValue(props.input.command) ?? pendingInput(props.part))
|
|
706
|
+
const title = createMemo(() => `# ${stringValue(props.input.description) ?? "Shell"}`)
|
|
707
|
+
const [expanded, setExpanded] = createSignal(false)
|
|
708
|
+
const maxLines = 10
|
|
709
|
+
const maxChars = createMemo(() => maxLines * Math.max(20, dimensions().width - 6))
|
|
710
|
+
const collapsed = createMemo(() => collapseToolOutput(output(), maxLines, maxChars()))
|
|
711
|
+
const limited = createMemo(() => {
|
|
712
|
+
if (expanded() || !collapsed().overflow) return output()
|
|
713
|
+
return collapsed().output
|
|
714
|
+
})
|
|
715
|
+
return (
|
|
716
|
+
<Switch>
|
|
717
|
+
<Match when={output()}>
|
|
718
|
+
<BlockTool
|
|
719
|
+
title={title()}
|
|
720
|
+
part={props.part}
|
|
721
|
+
spinner={props.part.state.status === "running"}
|
|
722
|
+
onClick={collapsed().overflow ? () => setExpanded((prev) => !prev) : undefined}
|
|
723
|
+
>
|
|
724
|
+
<box gap={1}>
|
|
725
|
+
<text fg={theme.text}>$ {command()}</text>
|
|
726
|
+
<text fg={theme.text}>{limited()}</text>
|
|
727
|
+
<Show when={collapsed().overflow}>
|
|
728
|
+
<text fg={theme.textMuted}>{expanded() ? "Click to collapse" : "Click to expand"}</text>
|
|
729
|
+
</Show>
|
|
730
|
+
</box>
|
|
731
|
+
</BlockTool>
|
|
732
|
+
</Match>
|
|
733
|
+
<Match when={true}>
|
|
734
|
+
<InlineTool icon="$" pending="Writing command..." complete={command()} part={props.part}>
|
|
735
|
+
{command()}
|
|
736
|
+
</InlineTool>
|
|
737
|
+
</Match>
|
|
738
|
+
</Switch>
|
|
739
|
+
)
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
function Glob(props: ToolProps) {
|
|
743
|
+
return (
|
|
744
|
+
<InlineTool icon="✱" pending="Finding files..." complete={toolComplete(props.part)} part={props.part}>
|
|
745
|
+
Glob "{stringValue(props.input.pattern) ?? pendingInput(props.part)}"{" "}
|
|
746
|
+
<Show when={stringValue(props.input.path)}>in {normalizePath(stringValue(props.input.path))} </Show>
|
|
747
|
+
<Show when={numberValue(props.metadata.count)}>
|
|
748
|
+
{(count) => (
|
|
749
|
+
<>
|
|
750
|
+
({count()} {count() === 1 ? "match" : "matches"})
|
|
751
|
+
</>
|
|
752
|
+
)}
|
|
753
|
+
</Show>
|
|
754
|
+
</InlineTool>
|
|
755
|
+
)
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
function Read(props: ToolProps) {
|
|
759
|
+
const { theme } = useTheme()
|
|
760
|
+
const loaded = createMemo(() =>
|
|
761
|
+
arrayValue(props.metadata.loaded).filter((item): item is string => typeof item === "string"),
|
|
762
|
+
)
|
|
763
|
+
return (
|
|
764
|
+
<>
|
|
765
|
+
<InlineTool
|
|
766
|
+
icon="→"
|
|
767
|
+
pending="Reading file..."
|
|
768
|
+
complete={stringValue(props.input.filePath) ?? pendingInput(props.part)}
|
|
769
|
+
spinner={props.part.state.status === "running"}
|
|
770
|
+
part={props.part}
|
|
771
|
+
>
|
|
772
|
+
Read {normalizePath(stringValue(props.input.filePath) ?? pendingInput(props.part))}{" "}
|
|
773
|
+
{input(props.input, ["filePath"])}
|
|
774
|
+
</InlineTool>
|
|
775
|
+
<For each={loaded()}>
|
|
776
|
+
{(filepath) => (
|
|
777
|
+
<box paddingLeft={3} flexShrink={0}>
|
|
778
|
+
<text paddingLeft={3} fg={theme.textMuted}>
|
|
779
|
+
↳ Loaded {normalizePath(filepath)}
|
|
780
|
+
</text>
|
|
781
|
+
</box>
|
|
782
|
+
)}
|
|
783
|
+
</For>
|
|
784
|
+
</>
|
|
785
|
+
)
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
function Grep(props: ToolProps) {
|
|
789
|
+
return (
|
|
790
|
+
<InlineTool icon="✱" pending="Searching content..." complete={toolComplete(props.part)} part={props.part}>
|
|
791
|
+
Grep "{stringValue(props.input.pattern) ?? pendingInput(props.part)}"{" "}
|
|
792
|
+
<Show when={stringValue(props.input.path)}>in {normalizePath(stringValue(props.input.path))} </Show>
|
|
793
|
+
<Show when={numberValue(props.metadata.matches)}>
|
|
794
|
+
{(matches) => (
|
|
795
|
+
<>
|
|
796
|
+
({matches()} {matches() === 1 ? "match" : "matches"})
|
|
797
|
+
</>
|
|
798
|
+
)}
|
|
799
|
+
</Show>
|
|
800
|
+
</InlineTool>
|
|
801
|
+
)
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
function WebFetch(props: ToolProps) {
|
|
805
|
+
return (
|
|
806
|
+
<InlineTool icon="%" pending="Fetching from the web..." complete={toolComplete(props.part)} part={props.part}>
|
|
807
|
+
WebFetch {stringValue(props.input.url) ?? pendingInput(props.part)}
|
|
808
|
+
</InlineTool>
|
|
809
|
+
)
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
function WebSearch(props: ToolProps) {
|
|
813
|
+
const label = createMemo(() => webSearchProviderLabel(props.metadata.provider))
|
|
814
|
+
return (
|
|
815
|
+
<InlineTool icon="◈" pending="Searching web..." complete={toolComplete(props.part)} part={props.part}>
|
|
816
|
+
{label()} "{stringValue(props.input.query) ?? pendingInput(props.part)}"{" "}
|
|
817
|
+
<Show when={numberValue(props.metadata.numResults)}>{(results) => <>({results()} results)</>}</Show>
|
|
818
|
+
</InlineTool>
|
|
819
|
+
)
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
function Write(props: ToolProps) {
|
|
823
|
+
const { theme, syntax } = useTheme()
|
|
824
|
+
const filePath = createMemo(() => stringValue(props.input.filePath) ?? "")
|
|
825
|
+
const content = createMemo(() => stringValue(props.input.content) ?? "")
|
|
826
|
+
return (
|
|
827
|
+
<Switch>
|
|
828
|
+
<Match when={content() && props.part.state.status === "completed"}>
|
|
829
|
+
<BlockTool title={"# Wrote " + normalizePath(filePath())} part={props.part}>
|
|
830
|
+
<line_number fg={theme.textMuted} minWidth={3} paddingRight={1}>
|
|
831
|
+
<code
|
|
832
|
+
conceal={false}
|
|
833
|
+
fg={theme.text}
|
|
834
|
+
filetype={filetype(filePath())}
|
|
835
|
+
syntaxStyle={syntax()}
|
|
836
|
+
content={content()}
|
|
837
|
+
/>
|
|
838
|
+
</line_number>
|
|
839
|
+
<Diagnostics diagnostics={props.metadata.diagnostics} filePath={filePath()} />
|
|
840
|
+
</BlockTool>
|
|
841
|
+
</Match>
|
|
842
|
+
<Match when={true}>
|
|
843
|
+
<InlineTool icon="←" pending="Preparing write..." complete={filePath()} part={props.part}>
|
|
844
|
+
Write {normalizePath(filePath())}
|
|
845
|
+
</InlineTool>
|
|
846
|
+
</Match>
|
|
847
|
+
</Switch>
|
|
848
|
+
)
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
function Edit(props: ToolProps) {
|
|
852
|
+
const { theme, syntax } = useTheme()
|
|
853
|
+
const dimensions = useTerminalDimensions()
|
|
854
|
+
const filePath = createMemo(() => stringValue(props.input.filePath) ?? "")
|
|
855
|
+
const diff = createMemo(() => stringValue(props.metadata.diff))
|
|
856
|
+
return (
|
|
857
|
+
<Switch>
|
|
858
|
+
<Match when={diff()}>
|
|
859
|
+
{(diff) => (
|
|
860
|
+
<BlockTool title={"← Edit " + normalizePath(filePath())} part={props.part}>
|
|
861
|
+
<box paddingLeft={1}>
|
|
862
|
+
<diff
|
|
863
|
+
diff={diff()}
|
|
864
|
+
view={dimensions().width > 120 ? "split" : "unified"}
|
|
865
|
+
filetype={filetype(filePath())}
|
|
866
|
+
syntaxStyle={syntax()}
|
|
867
|
+
showLineNumbers={true}
|
|
868
|
+
width="100%"
|
|
869
|
+
wrapMode="word"
|
|
870
|
+
fg={theme.text}
|
|
871
|
+
addedBg={theme.diffAddedBg}
|
|
872
|
+
removedBg={theme.diffRemovedBg}
|
|
873
|
+
contextBg={theme.diffContextBg}
|
|
874
|
+
addedSignColor={theme.diffHighlightAdded}
|
|
875
|
+
removedSignColor={theme.diffHighlightRemoved}
|
|
876
|
+
lineNumberFg={theme.diffLineNumber}
|
|
877
|
+
lineNumberBg={theme.diffContextBg}
|
|
878
|
+
addedLineNumberBg={theme.diffAddedLineNumberBg}
|
|
879
|
+
removedLineNumberBg={theme.diffRemovedLineNumberBg}
|
|
880
|
+
/>
|
|
881
|
+
</box>
|
|
882
|
+
<Diagnostics diagnostics={props.metadata.diagnostics} filePath={filePath()} />
|
|
883
|
+
</BlockTool>
|
|
884
|
+
)}
|
|
885
|
+
</Match>
|
|
886
|
+
<Match when={true}>
|
|
887
|
+
<InlineTool icon="←" pending="Preparing edit..." complete={filePath()} part={props.part}>
|
|
888
|
+
Edit {normalizePath(filePath())} {input({ replaceAll: props.input.replaceAll })}
|
|
889
|
+
</InlineTool>
|
|
890
|
+
</Match>
|
|
891
|
+
</Switch>
|
|
892
|
+
)
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
function ApplyPatch(props: ToolProps) {
|
|
896
|
+
const { theme, syntax } = useTheme()
|
|
897
|
+
const dimensions = useTerminalDimensions()
|
|
898
|
+
const files = createMemo(() => arrayValue(props.metadata.files).flatMap((item) => (isRecord(item) ? [item] : [])))
|
|
899
|
+
const fileTitle = (file: Record<string, unknown>) => {
|
|
900
|
+
const type = stringValue(file.type)
|
|
901
|
+
const relativePath = stringValue(file.relativePath) ?? stringValue(file.filePath) ?? "patch"
|
|
902
|
+
if (type === "delete") return "# Deleted " + relativePath
|
|
903
|
+
if (type === "add") return "# Created " + relativePath
|
|
904
|
+
if (type === "move") return "# Moved " + normalizePath(stringValue(file.filePath)) + " → " + relativePath
|
|
905
|
+
return "← Patched " + relativePath
|
|
906
|
+
}
|
|
907
|
+
return (
|
|
908
|
+
<Switch>
|
|
909
|
+
<Match when={files().length > 0}>
|
|
910
|
+
<For each={files()}>
|
|
911
|
+
{(file) => (
|
|
912
|
+
<BlockTool title={fileTitle(file)} part={props.part}>
|
|
913
|
+
<Show
|
|
914
|
+
when={stringValue(file.patch)}
|
|
915
|
+
fallback={
|
|
916
|
+
<text fg={theme.diffRemoved}>
|
|
917
|
+
-{numberValue(file.deletions) ?? 0} line{numberValue(file.deletions) === 1 ? "" : "s"}
|
|
918
|
+
</text>
|
|
919
|
+
}
|
|
920
|
+
>
|
|
921
|
+
{(patch) => (
|
|
922
|
+
<box paddingLeft={1}>
|
|
923
|
+
<diff
|
|
924
|
+
diff={patch()}
|
|
925
|
+
view={dimensions().width > 120 ? "split" : "unified"}
|
|
926
|
+
filetype={filetype(stringValue(file.filePath) ?? stringValue(file.relativePath))}
|
|
927
|
+
syntaxStyle={syntax()}
|
|
928
|
+
showLineNumbers={true}
|
|
929
|
+
width="100%"
|
|
930
|
+
wrapMode="word"
|
|
931
|
+
fg={theme.text}
|
|
932
|
+
addedBg={theme.diffAddedBg}
|
|
933
|
+
removedBg={theme.diffRemovedBg}
|
|
934
|
+
contextBg={theme.diffContextBg}
|
|
935
|
+
addedSignColor={theme.diffHighlightAdded}
|
|
936
|
+
removedSignColor={theme.diffHighlightRemoved}
|
|
937
|
+
lineNumberFg={theme.diffLineNumber}
|
|
938
|
+
lineNumberBg={theme.diffContextBg}
|
|
939
|
+
addedLineNumberBg={theme.diffAddedLineNumberBg}
|
|
940
|
+
removedLineNumberBg={theme.diffRemovedLineNumberBg}
|
|
941
|
+
/>
|
|
942
|
+
</box>
|
|
943
|
+
)}
|
|
944
|
+
</Show>
|
|
945
|
+
</BlockTool>
|
|
946
|
+
)}
|
|
947
|
+
</For>
|
|
948
|
+
</Match>
|
|
949
|
+
<Match when={true}>
|
|
950
|
+
<InlineTool icon="%" pending="Preparing patch..." complete={false} part={props.part}>
|
|
951
|
+
Patch
|
|
952
|
+
</InlineTool>
|
|
953
|
+
</Match>
|
|
954
|
+
</Switch>
|
|
955
|
+
)
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
function TodoWrite(props: ToolProps) {
|
|
959
|
+
const { theme } = useTheme()
|
|
960
|
+
const todos = createMemo(() => arrayValue(props.input.todos).flatMap((item) => (isRecord(item) ? [item] : [])))
|
|
961
|
+
return (
|
|
962
|
+
<Switch>
|
|
963
|
+
<Match when={todos().length > 0 && props.part.state.status === "completed"}>
|
|
964
|
+
<BlockTool title="# Todos" part={props.part}>
|
|
965
|
+
<box>
|
|
966
|
+
<For each={todos()}>
|
|
967
|
+
{(todo) => (
|
|
968
|
+
<text fg={theme.text}>
|
|
969
|
+
{todoIcon(stringValue(todo.status))} {stringValue(todo.content)}
|
|
970
|
+
</text>
|
|
971
|
+
)}
|
|
972
|
+
</For>
|
|
973
|
+
</box>
|
|
974
|
+
</BlockTool>
|
|
975
|
+
</Match>
|
|
976
|
+
<Match when={true}>
|
|
977
|
+
<InlineTool icon="⚙" pending="Updating todos..." complete={false} part={props.part}>
|
|
978
|
+
Updating todos...
|
|
979
|
+
</InlineTool>
|
|
980
|
+
</Match>
|
|
981
|
+
</Switch>
|
|
982
|
+
)
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
function Question(props: ToolProps) {
|
|
986
|
+
const { theme } = useTheme()
|
|
987
|
+
const questions = createMemo(() =>
|
|
988
|
+
arrayValue(props.input.questions).flatMap((item) => (isRecord(item) ? [item] : [])),
|
|
989
|
+
)
|
|
990
|
+
const answers = createMemo(() => arrayValue(props.metadata.answers))
|
|
991
|
+
return (
|
|
992
|
+
<Switch>
|
|
993
|
+
<Match when={answers().length > 0}>
|
|
994
|
+
<BlockTool title="# Questions" part={props.part}>
|
|
995
|
+
<box gap={1}>
|
|
996
|
+
<For each={questions()}>
|
|
997
|
+
{(question, index) => (
|
|
998
|
+
<box>
|
|
999
|
+
<text fg={theme.textMuted}>{stringValue(question.question)}</text>
|
|
1000
|
+
<text fg={theme.text}>{formatAnswer(answers()[index()])}</text>
|
|
1001
|
+
</box>
|
|
1002
|
+
)}
|
|
1003
|
+
</For>
|
|
1004
|
+
</box>
|
|
1005
|
+
</BlockTool>
|
|
1006
|
+
</Match>
|
|
1007
|
+
<Match when={true}>
|
|
1008
|
+
<InlineTool icon="→" pending="Asking questions..." complete={questions().length} part={props.part}>
|
|
1009
|
+
Asked {questions().length} question{questions().length === 1 ? "" : "s"}
|
|
1010
|
+
</InlineTool>
|
|
1011
|
+
</Match>
|
|
1012
|
+
</Switch>
|
|
1013
|
+
)
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
function Skill(props: ToolProps) {
|
|
1017
|
+
return (
|
|
1018
|
+
<InlineTool icon="→" pending="Loading skill..." complete={toolComplete(props.part)} part={props.part}>
|
|
1019
|
+
Skill "{stringValue(props.input.name) ?? pendingInput(props.part)}"
|
|
1020
|
+
</InlineTool>
|
|
1021
|
+
)
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
function Task(props: ToolProps) {
|
|
1025
|
+
const content = createMemo(() => {
|
|
1026
|
+
const description = stringValue(props.input.description)
|
|
1027
|
+
if (!description) return pendingInput(props.part)
|
|
1028
|
+
return `${Locale.titlecase(stringValue(props.input.subagent_type) ?? "General")} Task — ${description}`
|
|
1029
|
+
})
|
|
1030
|
+
return (
|
|
1031
|
+
<InlineTool
|
|
1032
|
+
icon="│"
|
|
1033
|
+
spinner={props.part.state.status === "running"}
|
|
1034
|
+
complete={toolComplete(props.part)}
|
|
1035
|
+
pending="Delegating..."
|
|
1036
|
+
part={props.part}
|
|
1037
|
+
>
|
|
1038
|
+
{content()}
|
|
1039
|
+
</InlineTool>
|
|
1040
|
+
)
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
function Diagnostics(props: { diagnostics: unknown; filePath: string }) {
|
|
1044
|
+
const { theme } = useTheme()
|
|
1045
|
+
const errors = createMemo(() => {
|
|
1046
|
+
if (!isRecord(props.diagnostics)) return []
|
|
1047
|
+
const value = props.diagnostics[normalizePath(props.filePath)] ?? props.diagnostics[props.filePath]
|
|
1048
|
+
return arrayValue(value)
|
|
1049
|
+
.flatMap((item) => (isRecord(item) ? [item] : []))
|
|
1050
|
+
.filter((diagnostic) => diagnostic.severity === 1)
|
|
1051
|
+
.slice(0, 3)
|
|
1052
|
+
})
|
|
1053
|
+
return (
|
|
1054
|
+
<Show when={errors().length}>
|
|
1055
|
+
<box>
|
|
1056
|
+
<For each={errors()}>
|
|
1057
|
+
{(diagnostic) => <text fg={theme.error}>Error {stringValue(diagnostic.message)}</text>}
|
|
1058
|
+
</For>
|
|
1059
|
+
</box>
|
|
1060
|
+
</Show>
|
|
1061
|
+
)
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
function toolOutput(content?: Array<ToolTextContent | ToolFileContent>) {
|
|
1065
|
+
return (content ?? [])
|
|
1066
|
+
.map((item) => {
|
|
1067
|
+
if (item.type === "text") return item.text.trim()
|
|
1068
|
+
const source =
|
|
1069
|
+
item.source.type === "data" ? "inline data" : item.source.type === "url" ? item.source.url : item.source.uri
|
|
1070
|
+
return `[file ${item.name ?? source}]`
|
|
1071
|
+
})
|
|
1072
|
+
.filter(Boolean)
|
|
1073
|
+
.join("\n")
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
function toolInputRecord(input: string | Record<string, unknown>) {
|
|
1077
|
+
if (typeof input === "string") return {}
|
|
1078
|
+
return input
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
function pendingInput(part: SessionMessageAssistantTool) {
|
|
1082
|
+
if (part.state.status !== "pending") return ""
|
|
1083
|
+
return part.state.input.trim()
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
function toolComplete(part: SessionMessageAssistantTool) {
|
|
1087
|
+
if (part.state.status === "pending") return pendingInput(part)
|
|
1088
|
+
return part.state.status === "completed" || part.state.status === "error" || part.state.status === "running"
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
function stringValue(value: unknown) {
|
|
1092
|
+
return typeof value === "string" ? value : undefined
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
function numberValue(value: unknown) {
|
|
1096
|
+
return typeof value === "number" ? value : undefined
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
function arrayValue(value: unknown): unknown[] {
|
|
1100
|
+
return Array.isArray(value) ? value : []
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
1104
|
+
return !!value && typeof value === "object" && !Array.isArray(value)
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
function input(input: Record<string, unknown>, omit?: string[]) {
|
|
1108
|
+
const primitives = Object.entries(input).filter(([key, value]) => {
|
|
1109
|
+
if (omit?.includes(key)) return false
|
|
1110
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean"
|
|
1111
|
+
})
|
|
1112
|
+
if (primitives.length === 0) return ""
|
|
1113
|
+
return `[${primitives.map(([key, value]) => `${key}=${value}`).join(", ")}]`
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
function normalizePath(input?: string) {
|
|
1117
|
+
if (!input) return ""
|
|
1118
|
+
const absolute = path.isAbsolute(input) ? input : path.resolve(process.cwd(), input)
|
|
1119
|
+
const relative = path.relative(process.cwd(), absolute)
|
|
1120
|
+
if (!relative) return "."
|
|
1121
|
+
if (!relative.startsWith("..")) return relative
|
|
1122
|
+
return absolute
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
function filetype(input?: string) {
|
|
1126
|
+
if (!input) return "none"
|
|
1127
|
+
const language = LANGUAGE_EXTENSIONS[path.extname(input)]
|
|
1128
|
+
if (["typescriptreact", "javascriptreact", "javascript"].includes(language)) return "typescript"
|
|
1129
|
+
return language
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
function todoIcon(status?: string) {
|
|
1133
|
+
if (status === "completed") return "✓"
|
|
1134
|
+
if (status === "in_progress") return "~"
|
|
1135
|
+
if (status === "cancelled") return "✕"
|
|
1136
|
+
return "☐"
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
function formatAnswer(answer: unknown) {
|
|
1140
|
+
if (!Array.isArray(answer)) return "(no answer)"
|
|
1141
|
+
if (answer.length === 0) return "(no answer)"
|
|
1142
|
+
return answer.filter((item): item is string => typeof item === "string").join(", ")
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
const tui: TuiPlugin = async (api) => {
|
|
1146
|
+
api.route.register([
|
|
1147
|
+
{
|
|
1148
|
+
name: route,
|
|
1149
|
+
render(input) {
|
|
1150
|
+
const sessionID = input.params?.sessionID
|
|
1151
|
+
if (typeof sessionID !== "string") {
|
|
1152
|
+
return <text fg={api.theme.current.error}>Missing sessionID</text>
|
|
1153
|
+
}
|
|
1154
|
+
return <View api={api} sessionID={sessionID} />
|
|
1155
|
+
},
|
|
1156
|
+
},
|
|
1157
|
+
])
|
|
1158
|
+
|
|
1159
|
+
api.keymap.registerLayer({
|
|
1160
|
+
commands: [
|
|
1161
|
+
{
|
|
1162
|
+
name: route,
|
|
1163
|
+
title: "View v2 session messages",
|
|
1164
|
+
category: "Debug",
|
|
1165
|
+
namespace: "palette",
|
|
1166
|
+
suggested: () => api.route.current.name === "session",
|
|
1167
|
+
enabled: () => api.route.current.name === "session",
|
|
1168
|
+
run() {
|
|
1169
|
+
const sessionID = currentSessionID(api)
|
|
1170
|
+
if (!sessionID) return
|
|
1171
|
+
api.route.navigate(route, { sessionID })
|
|
1172
|
+
api.ui.dialog.clear()
|
|
1173
|
+
},
|
|
1174
|
+
},
|
|
1175
|
+
],
|
|
1176
|
+
})
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
const plugin: InternalTuiPlugin = {
|
|
1180
|
+
id,
|
|
1181
|
+
tui,
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
export default plugin
|