rird 1.0.200
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 +27 -0
- package/Dockerfile +18 -0
- package/README.md +15 -0
- package/bin/opencode +336 -0
- package/bin/pty-wrapper.js +285 -0
- package/bunfig.toml +4 -0
- package/facebook_ads_library.png +0 -0
- package/nul`nif +0 -0
- package/package.json +111 -0
- package/parsers-config.ts +239 -0
- package/rird-1.0.199.tgz +0 -0
- package/script/build-windows.ts +54 -0
- package/script/build.ts +167 -0
- package/script/postinstall.mjs +544 -0
- package/script/publish-registries.ts +187 -0
- package/script/publish.ts +72 -0
- package/script/schema.ts +47 -0
- package/src/acp/README.md +164 -0
- package/src/acp/agent.ts +1063 -0
- package/src/acp/session.ts +101 -0
- package/src/acp/types.ts +22 -0
- package/src/agent/agent.ts +367 -0
- package/src/agent/generate.txt +75 -0
- package/src/agent/prompt/compaction.txt +12 -0
- package/src/agent/prompt/explore.txt +18 -0
- package/src/agent/prompt/summary.txt +10 -0
- package/src/agent/prompt/title.txt +36 -0
- package/src/auth/index.ts +70 -0
- package/src/bun/index.ts +114 -0
- package/src/bus/bus-event.ts +43 -0
- package/src/bus/global.ts +10 -0
- package/src/bus/index.ts +105 -0
- package/src/cli/bootstrap.ts +17 -0
- package/src/cli/cmd/acp.ts +88 -0
- package/src/cli/cmd/agent.ts +256 -0
- package/src/cli/cmd/auth.ts +391 -0
- package/src/cli/cmd/cmd.ts +7 -0
- package/src/cli/cmd/debug/config.ts +15 -0
- package/src/cli/cmd/debug/file.ts +91 -0
- package/src/cli/cmd/debug/index.ts +43 -0
- package/src/cli/cmd/debug/lsp.ts +48 -0
- package/src/cli/cmd/debug/ripgrep.ts +83 -0
- package/src/cli/cmd/debug/scrap.ts +15 -0
- package/src/cli/cmd/debug/skill.ts +15 -0
- package/src/cli/cmd/debug/snapshot.ts +48 -0
- package/src/cli/cmd/export.ts +88 -0
- package/src/cli/cmd/generate.ts +38 -0
- package/src/cli/cmd/github.ts +1400 -0
- package/src/cli/cmd/import.ts +98 -0
- package/src/cli/cmd/mcp.ts +654 -0
- package/src/cli/cmd/models.ts +77 -0
- package/src/cli/cmd/pr.ts +112 -0
- package/src/cli/cmd/run.ts +368 -0
- package/src/cli/cmd/serve.ts +31 -0
- package/src/cli/cmd/session.ts +106 -0
- package/src/cli/cmd/stats.ts +298 -0
- package/src/cli/cmd/tui/app.tsx +696 -0
- package/src/cli/cmd/tui/attach.ts +30 -0
- package/src/cli/cmd/tui/component/border.tsx +21 -0
- package/src/cli/cmd/tui/component/dialog-agent.tsx +31 -0
- package/src/cli/cmd/tui/component/dialog-command.tsx +124 -0
- package/src/cli/cmd/tui/component/dialog-mcp.tsx +86 -0
- package/src/cli/cmd/tui/component/dialog-model.tsx +245 -0
- package/src/cli/cmd/tui/component/dialog-provider.tsx +224 -0
- package/src/cli/cmd/tui/component/dialog-session-list.tsx +102 -0
- package/src/cli/cmd/tui/component/dialog-session-rename.tsx +31 -0
- package/src/cli/cmd/tui/component/dialog-stash.tsx +86 -0
- package/src/cli/cmd/tui/component/dialog-status.tsx +162 -0
- package/src/cli/cmd/tui/component/dialog-tag.tsx +44 -0
- package/src/cli/cmd/tui/component/dialog-theme-list.tsx +50 -0
- package/src/cli/cmd/tui/component/did-you-know.tsx +85 -0
- package/src/cli/cmd/tui/component/logo.tsx +35 -0
- package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +574 -0
- package/src/cli/cmd/tui/component/prompt/history.tsx +108 -0
- package/src/cli/cmd/tui/component/prompt/index.tsx +1090 -0
- package/src/cli/cmd/tui/component/prompt/stash.tsx +101 -0
- package/src/cli/cmd/tui/component/tips.ts +27 -0
- package/src/cli/cmd/tui/component/todo-item.tsx +32 -0
- package/src/cli/cmd/tui/context/args.tsx +14 -0
- package/src/cli/cmd/tui/context/directory.ts +13 -0
- package/src/cli/cmd/tui/context/exit.tsx +23 -0
- package/src/cli/cmd/tui/context/helper.tsx +25 -0
- package/src/cli/cmd/tui/context/keybind.tsx +101 -0
- package/src/cli/cmd/tui/context/kv.tsx +49 -0
- package/src/cli/cmd/tui/context/local.tsx +354 -0
- package/src/cli/cmd/tui/context/prompt.tsx +18 -0
- package/src/cli/cmd/tui/context/route.tsx +46 -0
- package/src/cli/cmd/tui/context/sdk.tsx +74 -0
- package/src/cli/cmd/tui/context/sync.tsx +372 -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/catppuccin-frappe.json +233 -0
- package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +233 -0
- package/src/cli/cmd/tui/context/theme/catppuccin.json +112 -0
- package/src/cli/cmd/tui/context/theme/cobalt2.json +228 -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 +95 -0
- package/src/cli/cmd/tui/context/theme/kanagawa.json +77 -0
- package/src/cli/cmd/tui/context/theme/lucent-orng.json +227 -0
- package/src/cli/cmd/tui/context/theme/material.json +235 -0
- package/src/cli/cmd/tui/context/theme/matrix.json +77 -0
- package/src/cli/cmd/tui/context/theme/mercury.json +252 -0
- package/src/cli/cmd/tui/context/theme/monokai.json +221 -0
- package/src/cli/cmd/tui/context/theme/nightowl.json +221 -0
- package/src/cli/cmd/tui/context/theme/nord.json +223 -0
- package/src/cli/cmd/tui/context/theme/one-dark.json +84 -0
- package/src/cli/cmd/tui/context/theme/orng.json +245 -0
- package/src/cli/cmd/tui/context/theme/palenight.json +222 -0
- package/src/cli/cmd/tui/context/theme/rird.json +245 -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 +1109 -0
- package/src/cli/cmd/tui/event.ts +40 -0
- package/src/cli/cmd/tui/routes/home.tsx +138 -0
- package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +64 -0
- package/src/cli/cmd/tui/routes/session/dialog-message.tsx +109 -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 +88 -0
- package/src/cli/cmd/tui/routes/session/header.tsx +125 -0
- package/src/cli/cmd/tui/routes/session/index.tsx +1864 -0
- package/src/cli/cmd/tui/routes/session/sidebar.tsx +318 -0
- package/src/cli/cmd/tui/spawn.ts +60 -0
- package/src/cli/cmd/tui/thread.ts +142 -0
- package/src/cli/cmd/tui/ui/dialog-alert.tsx +57 -0
- package/src/cli/cmd/tui/ui/dialog-confirm.tsx +83 -0
- package/src/cli/cmd/tui/ui/dialog-help.tsx +38 -0
- package/src/cli/cmd/tui/ui/dialog-prompt.tsx +77 -0
- package/src/cli/cmd/tui/ui/dialog-select.tsx +332 -0
- package/src/cli/cmd/tui/ui/dialog.tsx +170 -0
- package/src/cli/cmd/tui/ui/spinner.ts +368 -0
- package/src/cli/cmd/tui/ui/toast.tsx +100 -0
- package/src/cli/cmd/tui/util/clipboard.ts +127 -0
- package/src/cli/cmd/tui/util/editor.ts +32 -0
- package/src/cli/cmd/tui/util/terminal.ts +114 -0
- package/src/cli/cmd/tui/worker.ts +63 -0
- package/src/cli/cmd/uninstall.ts +344 -0
- package/src/cli/cmd/upgrade.ts +100 -0
- package/src/cli/cmd/web.ts +84 -0
- package/src/cli/error.ts +56 -0
- package/src/cli/ui.ts +84 -0
- package/src/cli/upgrade.ts +25 -0
- package/src/command/index.ts +80 -0
- package/src/command/template/initialize.txt +10 -0
- package/src/command/template/review.txt +97 -0
- package/src/config/config.ts +995 -0
- package/src/config/markdown.ts +41 -0
- package/src/env/index.ts +26 -0
- package/src/file/ignore.ts +83 -0
- package/src/file/index.ts +328 -0
- package/src/file/ripgrep.ts +393 -0
- package/src/file/time.ts +64 -0
- package/src/file/watcher.ts +103 -0
- package/src/flag/flag.ts +46 -0
- package/src/format/formatter.ts +315 -0
- package/src/format/index.ts +137 -0
- package/src/global/index.ts +52 -0
- package/src/id/id.ts +73 -0
- package/src/ide/index.ts +76 -0
- package/src/index.ts +240 -0
- package/src/installation/index.ts +239 -0
- package/src/lsp/client.ts +229 -0
- package/src/lsp/index.ts +485 -0
- package/src/lsp/language.ts +116 -0
- package/src/lsp/server.ts +1895 -0
- package/src/mcp/auth.ts +135 -0
- package/src/mcp/index.ts +690 -0
- package/src/mcp/oauth-callback.ts +200 -0
- package/src/mcp/oauth-provider.ts +154 -0
- package/src/patch/index.ts +622 -0
- package/src/permission/index.ts +199 -0
- package/src/plugin/index.ts +91 -0
- package/src/project/bootstrap.ts +31 -0
- package/src/project/instance.ts +78 -0
- package/src/project/project.ts +221 -0
- package/src/project/state.ts +65 -0
- package/src/project/vcs.ts +76 -0
- package/src/provider/auth.ts +143 -0
- package/src/provider/models-macro.ts +11 -0
- package/src/provider/models.ts +106 -0
- package/src/provider/provider.ts +1071 -0
- package/src/provider/sdk/openai-compatible/src/README.md +5 -0
- package/src/provider/sdk/openai-compatible/src/index.ts +2 -0
- package/src/provider/sdk/openai-compatible/src/openai-compatible-provider.ts +100 -0
- package/src/provider/sdk/openai-compatible/src/responses/convert-to-openai-responses-input.ts +303 -0
- package/src/provider/sdk/openai-compatible/src/responses/map-openai-responses-finish-reason.ts +22 -0
- package/src/provider/sdk/openai-compatible/src/responses/openai-config.ts +18 -0
- package/src/provider/sdk/openai-compatible/src/responses/openai-error.ts +22 -0
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-api-types.ts +207 -0
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-language-model.ts +1713 -0
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-prepare-tools.ts +177 -0
- package/src/provider/sdk/openai-compatible/src/responses/openai-responses-settings.ts +1 -0
- package/src/provider/sdk/openai-compatible/src/responses/tool/code-interpreter.ts +88 -0
- package/src/provider/sdk/openai-compatible/src/responses/tool/file-search.ts +128 -0
- package/src/provider/sdk/openai-compatible/src/responses/tool/image-generation.ts +115 -0
- package/src/provider/sdk/openai-compatible/src/responses/tool/local-shell.ts +65 -0
- package/src/provider/sdk/openai-compatible/src/responses/tool/web-search-preview.ts +104 -0
- package/src/provider/sdk/openai-compatible/src/responses/tool/web-search.ts +103 -0
- package/src/provider/transform.ts +455 -0
- package/src/pty/index.ts +231 -0
- package/src/security/guardrails.test.ts +341 -0
- package/src/security/guardrails.ts +558 -0
- package/src/security/index.ts +19 -0
- package/src/server/error.ts +36 -0
- package/src/server/project.ts +79 -0
- package/src/server/server.ts +2642 -0
- package/src/server/tui.ts +71 -0
- package/src/session/compaction.ts +223 -0
- package/src/session/index.ts +461 -0
- package/src/session/llm.ts +201 -0
- package/src/session/message-v2.ts +690 -0
- package/src/session/message.ts +189 -0
- package/src/session/processor.ts +409 -0
- package/src/session/prompt/act-switch.txt +5 -0
- package/src/session/prompt/anthropic-20250930.txt +166 -0
- package/src/session/prompt/anthropic.txt +85 -0
- package/src/session/prompt/anthropic_spoof.txt +1 -0
- package/src/session/prompt/beast.txt +103 -0
- package/src/session/prompt/codex.txt +304 -0
- package/src/session/prompt/copilot-gpt-5.txt +138 -0
- package/src/session/prompt/gemini.txt +85 -0
- package/src/session/prompt/max-steps.txt +16 -0
- package/src/session/prompt/plan-reminder-anthropic.txt +35 -0
- package/src/session/prompt/plan.txt +24 -0
- package/src/session/prompt/polaris.txt +84 -0
- package/src/session/prompt/qwen.txt +106 -0
- package/src/session/prompt.ts +1509 -0
- package/src/session/retry.ts +86 -0
- package/src/session/revert.ts +108 -0
- package/src/session/sensitive-filter.test.ts +327 -0
- package/src/session/sensitive-filter.ts +466 -0
- package/src/session/status.ts +76 -0
- package/src/session/summary.ts +194 -0
- package/src/session/system.ts +120 -0
- package/src/session/todo.ts +37 -0
- package/src/share/share-next.ts +194 -0
- package/src/share/share.ts +87 -0
- package/src/shell/shell.ts +67 -0
- package/src/skill/index.ts +1 -0
- package/src/skill/skill.ts +83 -0
- package/src/snapshot/index.ts +197 -0
- package/src/storage/storage.ts +226 -0
- package/src/tests/agent.test.ts +308 -0
- package/src/tests/build-guards.test.ts +267 -0
- package/src/tests/config.test.ts +664 -0
- package/src/tests/tool-registry.test.ts +589 -0
- package/src/tool/bash.ts +317 -0
- package/src/tool/bash.txt +158 -0
- package/src/tool/batch.ts +175 -0
- package/src/tool/batch.txt +24 -0
- package/src/tool/codesearch.ts +168 -0
- package/src/tool/codesearch.txt +12 -0
- package/src/tool/edit.ts +675 -0
- package/src/tool/edit.txt +10 -0
- package/src/tool/glob.ts +65 -0
- package/src/tool/glob.txt +6 -0
- package/src/tool/grep.ts +121 -0
- package/src/tool/grep.txt +8 -0
- package/src/tool/invalid.ts +17 -0
- package/src/tool/ls.ts +110 -0
- package/src/tool/ls.txt +1 -0
- package/src/tool/lsp-diagnostics.ts +26 -0
- package/src/tool/lsp-diagnostics.txt +1 -0
- package/src/tool/lsp-hover.ts +31 -0
- package/src/tool/lsp-hover.txt +1 -0
- package/src/tool/lsp.ts +87 -0
- package/src/tool/lsp.txt +19 -0
- package/src/tool/multiedit.ts +46 -0
- package/src/tool/multiedit.txt +41 -0
- package/src/tool/patch.ts +233 -0
- package/src/tool/patch.txt +1 -0
- package/src/tool/read.ts +219 -0
- package/src/tool/read.txt +12 -0
- package/src/tool/registry.ts +162 -0
- package/src/tool/skill.ts +100 -0
- package/src/tool/task.ts +136 -0
- package/src/tool/task.txt +51 -0
- package/src/tool/todo.ts +39 -0
- package/src/tool/todoread.txt +14 -0
- package/src/tool/todowrite.txt +167 -0
- package/src/tool/tool.ts +71 -0
- package/src/tool/webfetch.ts +198 -0
- package/src/tool/webfetch.txt +13 -0
- package/src/tool/websearch.ts +180 -0
- package/src/tool/websearch.txt +11 -0
- package/src/tool/write.ts +110 -0
- package/src/tool/write.txt +8 -0
- package/src/util/archive.ts +16 -0
- package/src/util/color.ts +19 -0
- package/src/util/context.ts +25 -0
- package/src/util/defer.ts +12 -0
- package/src/util/eventloop.ts +20 -0
- package/src/util/filesystem.ts +83 -0
- package/src/util/fn.ts +11 -0
- package/src/util/iife.ts +3 -0
- package/src/util/keybind.ts +102 -0
- package/src/util/lazy.ts +11 -0
- package/src/util/license.ts +325 -0
- package/src/util/locale.ts +81 -0
- package/src/util/lock.ts +98 -0
- package/src/util/log.ts +180 -0
- package/src/util/queue.ts +32 -0
- package/src/util/rpc.ts +42 -0
- package/src/util/scrap.ts +10 -0
- package/src/util/signal.ts +12 -0
- package/src/util/timeout.ts +14 -0
- package/src/util/token.ts +7 -0
- package/src/util/wildcard.ts +54 -0
- package/sst-env.d.ts +9 -0
- package/test/agent/agent.test.ts +146 -0
- package/test/bun.test.ts +53 -0
- package/test/cli/github-remote.test.ts +80 -0
- package/test/config/agent-color.test.ts +66 -0
- package/test/config/config.test.ts +535 -0
- package/test/config/markdown.test.ts +89 -0
- package/test/file/ignore.test.ts +10 -0
- package/test/fixture/fixture.ts +36 -0
- package/test/fixture/lsp/fake-lsp-server.js +77 -0
- package/test/ide/ide.test.ts +82 -0
- package/test/keybind.test.ts +421 -0
- package/test/lsp/client.test.ts +95 -0
- package/test/mcp/headers.test.ts +153 -0
- package/test/patch/patch.test.ts +348 -0
- package/test/preload.ts +57 -0
- package/test/project/project.test.ts +72 -0
- package/test/provider/provider.test.ts +1809 -0
- package/test/provider/transform.test.ts +411 -0
- package/test/session/retry.test.ts +111 -0
- package/test/session/session.test.ts +71 -0
- package/test/skill/skill.test.ts +131 -0
- package/test/snapshot/snapshot.test.ts +939 -0
- package/test/tool/__snapshots__/tool.test.ts.snap +9 -0
- package/test/tool/bash.test.ts +434 -0
- package/test/tool/grep.test.ts +108 -0
- package/test/tool/patch.test.ts +259 -0
- package/test/tool/read.test.ts +42 -0
- package/test/util/iife.test.ts +36 -0
- package/test/util/lazy.test.ts +50 -0
- package/test/util/timeout.test.ts +21 -0
- package/test/util/wildcard.test.ts +55 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
import { render, useKeyboard, useRenderer, useTerminalDimensions } from "@opentui/solid"
|
|
2
|
+
import { Clipboard } from "@tui/util/clipboard"
|
|
3
|
+
import { TextAttributes } from "@opentui/core"
|
|
4
|
+
import { RouteProvider, useRoute } from "@tui/context/route"
|
|
5
|
+
import { Switch, Match, createEffect, untrack, ErrorBoundary, createSignal, onMount, batch, Show, on } from "solid-js"
|
|
6
|
+
import { Installation } from "@/installation"
|
|
7
|
+
import { Global } from "@/global"
|
|
8
|
+
import { Flag } from "@/flag/flag"
|
|
9
|
+
import { DialogProvider, useDialog } from "@tui/ui/dialog"
|
|
10
|
+
import { DialogProvider as DialogProviderList } from "@tui/component/dialog-provider"
|
|
11
|
+
import { SDKProvider, useSDK } from "@tui/context/sdk"
|
|
12
|
+
import { SyncProvider, useSync } from "@tui/context/sync"
|
|
13
|
+
import { LocalProvider, useLocal } from "@tui/context/local"
|
|
14
|
+
import { DialogModel, useConnected } from "@tui/component/dialog-model"
|
|
15
|
+
import { DialogMcp } from "@tui/component/dialog-mcp"
|
|
16
|
+
import { DialogStatus } from "@tui/component/dialog-status"
|
|
17
|
+
import { DialogThemeList } from "@tui/component/dialog-theme-list"
|
|
18
|
+
import { DialogHelp } from "./ui/dialog-help"
|
|
19
|
+
import { CommandProvider, useCommandDialog } from "@tui/component/dialog-command"
|
|
20
|
+
import { DialogAgent } from "@tui/component/dialog-agent"
|
|
21
|
+
import { DialogSessionList } from "@tui/component/dialog-session-list"
|
|
22
|
+
import { KeybindProvider } from "@tui/context/keybind"
|
|
23
|
+
import { ThemeProvider, useTheme } from "@tui/context/theme"
|
|
24
|
+
import { Home } from "@tui/routes/home"
|
|
25
|
+
import { Session } from "@tui/routes/session"
|
|
26
|
+
import { PromptHistoryProvider } from "./component/prompt/history"
|
|
27
|
+
import { PromptStashProvider } from "./component/prompt/stash"
|
|
28
|
+
import { DialogAlert } from "./ui/dialog-alert"
|
|
29
|
+
import { ToastProvider, useToast } from "./ui/toast"
|
|
30
|
+
import { ExitProvider, useExit } from "./context/exit"
|
|
31
|
+
import { Session as SessionApi } from "@/session"
|
|
32
|
+
import { TuiEvent } from "./event"
|
|
33
|
+
import { KVProvider, useKV } from "./context/kv"
|
|
34
|
+
import { Provider } from "@/provider/provider"
|
|
35
|
+
import { ArgsProvider, useArgs, type Args } from "./context/args"
|
|
36
|
+
import open from "open"
|
|
37
|
+
import { PromptRefProvider, usePromptRef } from "./context/prompt"
|
|
38
|
+
|
|
39
|
+
async function getTerminalBackgroundColor(): Promise<"dark" | "light"> {
|
|
40
|
+
// can't set raw mode if not a TTY
|
|
41
|
+
if (!process.stdin.isTTY) return "dark"
|
|
42
|
+
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
let timeout: NodeJS.Timeout
|
|
45
|
+
|
|
46
|
+
const cleanup = () => {
|
|
47
|
+
process.stdin.setRawMode(false)
|
|
48
|
+
process.stdin.removeListener("data", handler)
|
|
49
|
+
clearTimeout(timeout)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const handler = (data: Buffer) => {
|
|
53
|
+
const str = data.toString()
|
|
54
|
+
const match = str.match(/\x1b]11;([^\x07\x1b]+)/)
|
|
55
|
+
if (match) {
|
|
56
|
+
cleanup()
|
|
57
|
+
const color = match[1]
|
|
58
|
+
// Parse RGB values from color string
|
|
59
|
+
// Formats: rgb:RR/GG/BB or #RRGGBB or rgb(R,G,B)
|
|
60
|
+
let r = 0,
|
|
61
|
+
g = 0,
|
|
62
|
+
b = 0
|
|
63
|
+
|
|
64
|
+
if (color.startsWith("rgb:")) {
|
|
65
|
+
const parts = color.substring(4).split("/")
|
|
66
|
+
r = parseInt(parts[0], 16) >> 8 // Convert 16-bit to 8-bit
|
|
67
|
+
g = parseInt(parts[1], 16) >> 8 // Convert 16-bit to 8-bit
|
|
68
|
+
b = parseInt(parts[2], 16) >> 8 // Convert 16-bit to 8-bit
|
|
69
|
+
} else if (color.startsWith("#")) {
|
|
70
|
+
r = parseInt(color.substring(1, 3), 16)
|
|
71
|
+
g = parseInt(color.substring(3, 5), 16)
|
|
72
|
+
b = parseInt(color.substring(5, 7), 16)
|
|
73
|
+
} else if (color.startsWith("rgb(")) {
|
|
74
|
+
const parts = color.substring(4, color.length - 1).split(",")
|
|
75
|
+
r = parseInt(parts[0])
|
|
76
|
+
g = parseInt(parts[1])
|
|
77
|
+
b = parseInt(parts[2])
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Calculate luminance using relative luminance formula
|
|
81
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255
|
|
82
|
+
|
|
83
|
+
// Determine if dark or light based on luminance threshold
|
|
84
|
+
resolve(luminance > 0.5 ? "light" : "dark")
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
process.stdin.setRawMode(true)
|
|
89
|
+
process.stdin.on("data", handler)
|
|
90
|
+
process.stdout.write("\x1b]11;?\x07")
|
|
91
|
+
|
|
92
|
+
timeout = setTimeout(() => {
|
|
93
|
+
cleanup()
|
|
94
|
+
resolve("dark")
|
|
95
|
+
}, 1000)
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function tui(input: { url: string; args: Args; onExit?: () => Promise<void> }) {
|
|
100
|
+
// promise to prevent immediate exit
|
|
101
|
+
return new Promise<void>(async (resolve) => {
|
|
102
|
+
const mode = await getTerminalBackgroundColor()
|
|
103
|
+
const onExit = async () => {
|
|
104
|
+
await input.onExit?.()
|
|
105
|
+
resolve()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
render(
|
|
109
|
+
() => {
|
|
110
|
+
return (
|
|
111
|
+
<ErrorBoundary
|
|
112
|
+
fallback={(error, reset) => <ErrorComponent error={error} reset={reset} onExit={onExit} mode={mode} />}
|
|
113
|
+
>
|
|
114
|
+
<ArgsProvider {...input.args}>
|
|
115
|
+
<ExitProvider onExit={onExit}>
|
|
116
|
+
<KVProvider>
|
|
117
|
+
<ToastProvider>
|
|
118
|
+
<RouteProvider>
|
|
119
|
+
<SDKProvider url={input.url}>
|
|
120
|
+
<SyncProvider>
|
|
121
|
+
<ThemeProvider mode={mode}>
|
|
122
|
+
<LocalProvider>
|
|
123
|
+
<KeybindProvider>
|
|
124
|
+
<PromptStashProvider>
|
|
125
|
+
<DialogProvider>
|
|
126
|
+
<CommandProvider>
|
|
127
|
+
<PromptHistoryProvider>
|
|
128
|
+
<PromptRefProvider>
|
|
129
|
+
<App />
|
|
130
|
+
</PromptRefProvider>
|
|
131
|
+
</PromptHistoryProvider>
|
|
132
|
+
</CommandProvider>
|
|
133
|
+
</DialogProvider>
|
|
134
|
+
</PromptStashProvider>
|
|
135
|
+
</KeybindProvider>
|
|
136
|
+
</LocalProvider>
|
|
137
|
+
</ThemeProvider>
|
|
138
|
+
</SyncProvider>
|
|
139
|
+
</SDKProvider>
|
|
140
|
+
</RouteProvider>
|
|
141
|
+
</ToastProvider>
|
|
142
|
+
</KVProvider>
|
|
143
|
+
</ExitProvider>
|
|
144
|
+
</ArgsProvider>
|
|
145
|
+
</ErrorBoundary>
|
|
146
|
+
)
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
targetFps: 60,
|
|
150
|
+
gatherStats: false,
|
|
151
|
+
exitOnCtrlC: false,
|
|
152
|
+
useKittyKeyboard: {},
|
|
153
|
+
consoleOptions: {
|
|
154
|
+
keyBindings: [{ name: "y", ctrl: true, action: "copy-selection" }],
|
|
155
|
+
onCopySelection: (text) => {
|
|
156
|
+
Clipboard.copy(text).catch((error) => {
|
|
157
|
+
console.error(`Failed to copy console selection to clipboard: ${error}`)
|
|
158
|
+
})
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
)
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function App() {
|
|
167
|
+
const route = useRoute()
|
|
168
|
+
const dimensions = useTerminalDimensions()
|
|
169
|
+
const renderer = useRenderer()
|
|
170
|
+
renderer.disableStdoutInterception()
|
|
171
|
+
const dialog = useDialog()
|
|
172
|
+
const local = useLocal()
|
|
173
|
+
const kv = useKV()
|
|
174
|
+
const command = useCommandDialog()
|
|
175
|
+
const sdk = useSDK()
|
|
176
|
+
const toast = useToast()
|
|
177
|
+
const { theme, mode, setMode } = useTheme()
|
|
178
|
+
const sync = useSync()
|
|
179
|
+
const exit = useExit()
|
|
180
|
+
const promptRef = usePromptRef()
|
|
181
|
+
|
|
182
|
+
// Wire up console copy-to-clipboard via opentui's onCopySelection callback
|
|
183
|
+
renderer.console.onCopySelection = async (text: string) => {
|
|
184
|
+
if (!text || text.length === 0) return
|
|
185
|
+
|
|
186
|
+
const base64 = Buffer.from(text).toString("base64")
|
|
187
|
+
const osc52 = `\x1b]52;c;${base64}\x07`
|
|
188
|
+
const finalOsc52 = process.env["TMUX"] ? `\x1bPtmux;\x1b${osc52}\x1b\\` : osc52
|
|
189
|
+
// @ts-expect-error writeOut is not in type definitions
|
|
190
|
+
renderer.writeOut(finalOsc52)
|
|
191
|
+
await Clipboard.copy(text)
|
|
192
|
+
.then(() => toast.show({ message: "Copied to clipboard", variant: "info" }))
|
|
193
|
+
.catch(toast.error)
|
|
194
|
+
renderer.clearSelection()
|
|
195
|
+
}
|
|
196
|
+
const [terminalTitleEnabled, setTerminalTitleEnabled] = createSignal(kv.get("terminal_title_enabled", true))
|
|
197
|
+
|
|
198
|
+
createEffect(() => {
|
|
199
|
+
console.log(JSON.stringify(route.data))
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
// Update terminal window title based on current route and session
|
|
203
|
+
createEffect(() => {
|
|
204
|
+
if (!terminalTitleEnabled() || Flag.RIRD_DISABLE_TERMINAL_TITLE) return
|
|
205
|
+
|
|
206
|
+
if (route.data.type === "home") {
|
|
207
|
+
renderer.setTerminalTitle("RIRD")
|
|
208
|
+
return
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (route.data.type === "session") {
|
|
212
|
+
const session = sync.session.get(route.data.sessionID)
|
|
213
|
+
if (!session || SessionApi.isDefaultTitle(session.title)) {
|
|
214
|
+
renderer.setTerminalTitle("RIRD")
|
|
215
|
+
return
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Truncate title to 40 chars max
|
|
219
|
+
const title = session.title.length > 40 ? session.title.slice(0, 37) + "..." : session.title
|
|
220
|
+
renderer.setTerminalTitle(`RIRD | ${title}`)
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
const args = useArgs()
|
|
225
|
+
onMount(() => {
|
|
226
|
+
batch(() => {
|
|
227
|
+
if (args.agent) local.agent.set(args.agent)
|
|
228
|
+
if (args.model) {
|
|
229
|
+
const { providerID, modelID } = Provider.parseModel(args.model)
|
|
230
|
+
if (!providerID || !modelID)
|
|
231
|
+
return toast.show({
|
|
232
|
+
variant: "warning",
|
|
233
|
+
message: `Invalid model format`,
|
|
234
|
+
duration: 3000,
|
|
235
|
+
})
|
|
236
|
+
local.model.set({ providerID, modelID }, { recent: true })
|
|
237
|
+
}
|
|
238
|
+
if (args.sessionID) {
|
|
239
|
+
route.navigate({
|
|
240
|
+
type: "session",
|
|
241
|
+
sessionID: args.sessionID,
|
|
242
|
+
})
|
|
243
|
+
}
|
|
244
|
+
})
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
let continued = false
|
|
248
|
+
createEffect(() => {
|
|
249
|
+
// When using -c, session list is loaded in blocking phase, so we can navigate at "partial"
|
|
250
|
+
if (continued || sync.status === "loading" || !args.continue) return
|
|
251
|
+
const match = sync.data.session
|
|
252
|
+
.toSorted((a, b) => b.time.updated - a.time.updated)
|
|
253
|
+
.find((x) => x.parentID === undefined)?.id
|
|
254
|
+
if (match) {
|
|
255
|
+
continued = true
|
|
256
|
+
route.navigate({ type: "session", sessionID: match })
|
|
257
|
+
}
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
createEffect(
|
|
261
|
+
on(
|
|
262
|
+
() => sync.status === "complete" && sync.data.provider.length === 0,
|
|
263
|
+
(isEmpty, wasEmpty) => {
|
|
264
|
+
// only trigger when we transition into an empty-provider state
|
|
265
|
+
if (!isEmpty || wasEmpty) return
|
|
266
|
+
dialog.replace(() => <DialogProviderList />)
|
|
267
|
+
},
|
|
268
|
+
),
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
const connected = useConnected()
|
|
272
|
+
command.register(() => [
|
|
273
|
+
{
|
|
274
|
+
title: "Switch session",
|
|
275
|
+
value: "session.list",
|
|
276
|
+
keybind: "session_list",
|
|
277
|
+
category: "Session",
|
|
278
|
+
suggested: sync.data.session.length > 0,
|
|
279
|
+
onSelect: () => {
|
|
280
|
+
dialog.replace(() => <DialogSessionList />)
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
title: "New session",
|
|
285
|
+
suggested: route.data.type === "session",
|
|
286
|
+
value: "session.new",
|
|
287
|
+
keybind: "session_new",
|
|
288
|
+
category: "Session",
|
|
289
|
+
onSelect: () => {
|
|
290
|
+
const current = promptRef.current
|
|
291
|
+
// Don't require focus - if there's any text, preserve it
|
|
292
|
+
const currentPrompt = current?.current?.input ? current.current : undefined
|
|
293
|
+
route.navigate({
|
|
294
|
+
type: "home",
|
|
295
|
+
initialPrompt: currentPrompt,
|
|
296
|
+
})
|
|
297
|
+
dialog.clear()
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
// Hidden for browser agent - users don't need to switch models
|
|
301
|
+
{
|
|
302
|
+
title: "Switch model",
|
|
303
|
+
value: "model.list",
|
|
304
|
+
keybind: "model_list",
|
|
305
|
+
hidden: true,
|
|
306
|
+
category: "Agent",
|
|
307
|
+
onSelect: () => {
|
|
308
|
+
dialog.replace(() => <DialogModel />)
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
title: "Model cycle",
|
|
313
|
+
disabled: true,
|
|
314
|
+
hidden: true,
|
|
315
|
+
value: "model.cycle_recent",
|
|
316
|
+
keybind: "model_cycle_recent",
|
|
317
|
+
category: "Agent",
|
|
318
|
+
onSelect: () => {
|
|
319
|
+
local.model.cycle(1)
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
title: "Model cycle reverse",
|
|
324
|
+
disabled: true,
|
|
325
|
+
hidden: true,
|
|
326
|
+
value: "model.cycle_recent_reverse",
|
|
327
|
+
keybind: "model_cycle_recent_reverse",
|
|
328
|
+
category: "Agent",
|
|
329
|
+
onSelect: () => {
|
|
330
|
+
local.model.cycle(-1)
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
title: "Favorite cycle",
|
|
335
|
+
value: "model.cycle_favorite",
|
|
336
|
+
keybind: "model_cycle_favorite",
|
|
337
|
+
hidden: true,
|
|
338
|
+
category: "Agent",
|
|
339
|
+
onSelect: () => {
|
|
340
|
+
local.model.cycleFavorite(1)
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
title: "Favorite cycle reverse",
|
|
345
|
+
value: "model.cycle_favorite_reverse",
|
|
346
|
+
keybind: "model_cycle_favorite_reverse",
|
|
347
|
+
hidden: true,
|
|
348
|
+
category: "Agent",
|
|
349
|
+
onSelect: () => {
|
|
350
|
+
local.model.cycleFavorite(-1)
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
// Hidden for browser agent - single agent mode
|
|
354
|
+
{
|
|
355
|
+
title: "Switch agent",
|
|
356
|
+
value: "agent.list",
|
|
357
|
+
keybind: "agent_list",
|
|
358
|
+
hidden: true,
|
|
359
|
+
category: "Agent",
|
|
360
|
+
onSelect: () => {
|
|
361
|
+
dialog.replace(() => <DialogAgent />)
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
title: "Toggle MCPs",
|
|
366
|
+
value: "mcp.list",
|
|
367
|
+
category: "Agent",
|
|
368
|
+
onSelect: () => {
|
|
369
|
+
dialog.replace(() => <DialogMcp />)
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
// Hidden for browser agent - single agent mode
|
|
373
|
+
{
|
|
374
|
+
title: "Agent cycle",
|
|
375
|
+
value: "agent.cycle",
|
|
376
|
+
keybind: "agent_cycle",
|
|
377
|
+
category: "Agent",
|
|
378
|
+
disabled: true,
|
|
379
|
+
hidden: true,
|
|
380
|
+
onSelect: () => {
|
|
381
|
+
local.agent.move(1)
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
title: "Agent cycle reverse",
|
|
386
|
+
value: "agent.cycle.reverse",
|
|
387
|
+
keybind: "agent_cycle_reverse",
|
|
388
|
+
category: "Agent",
|
|
389
|
+
disabled: true,
|
|
390
|
+
hidden: true,
|
|
391
|
+
onSelect: () => {
|
|
392
|
+
local.agent.move(-1)
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
title: "Connect provider",
|
|
397
|
+
value: "provider.connect",
|
|
398
|
+
suggested: !connected(),
|
|
399
|
+
onSelect: () => {
|
|
400
|
+
dialog.replace(() => <DialogProviderList />)
|
|
401
|
+
},
|
|
402
|
+
category: "Provider",
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
title: "View status",
|
|
406
|
+
keybind: "status_view",
|
|
407
|
+
value: "rird.status",
|
|
408
|
+
onSelect: () => {
|
|
409
|
+
dialog.replace(() => <DialogStatus />)
|
|
410
|
+
},
|
|
411
|
+
category: "System",
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
title: "Switch theme",
|
|
415
|
+
value: "theme.switch",
|
|
416
|
+
onSelect: () => {
|
|
417
|
+
dialog.replace(() => <DialogThemeList />)
|
|
418
|
+
},
|
|
419
|
+
category: "System",
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
title: "Toggle appearance",
|
|
423
|
+
value: "theme.switch_mode",
|
|
424
|
+
onSelect: (dialog) => {
|
|
425
|
+
setMode(mode() === "dark" ? "light" : "dark")
|
|
426
|
+
dialog.clear()
|
|
427
|
+
},
|
|
428
|
+
category: "System",
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
title: "Help",
|
|
432
|
+
value: "help.show",
|
|
433
|
+
onSelect: () => {
|
|
434
|
+
dialog.replace(() => <DialogHelp />)
|
|
435
|
+
},
|
|
436
|
+
category: "System",
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
title: "Open docs",
|
|
440
|
+
value: "docs.open",
|
|
441
|
+
onSelect: () => {
|
|
442
|
+
open("https://rird.ai").catch(() => {})
|
|
443
|
+
dialog.clear()
|
|
444
|
+
},
|
|
445
|
+
category: "System",
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
title: "Open WebUI",
|
|
449
|
+
value: "webui.open",
|
|
450
|
+
onSelect: () => {
|
|
451
|
+
open(sdk.url).catch(() => {})
|
|
452
|
+
dialog.clear()
|
|
453
|
+
},
|
|
454
|
+
category: "System",
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
title: "Exit the app",
|
|
458
|
+
value: "app.exit",
|
|
459
|
+
onSelect: () => exit(),
|
|
460
|
+
category: "System",
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
title: "Toggle debug panel",
|
|
464
|
+
category: "System",
|
|
465
|
+
value: "app.debug",
|
|
466
|
+
onSelect: (dialog) => {
|
|
467
|
+
renderer.toggleDebugOverlay()
|
|
468
|
+
dialog.clear()
|
|
469
|
+
},
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
title: "Toggle console",
|
|
473
|
+
category: "System",
|
|
474
|
+
value: "app.console",
|
|
475
|
+
onSelect: (dialog) => {
|
|
476
|
+
renderer.console.toggle()
|
|
477
|
+
dialog.clear()
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
title: "Suspend terminal",
|
|
482
|
+
value: "terminal.suspend",
|
|
483
|
+
keybind: "terminal_suspend",
|
|
484
|
+
category: "System",
|
|
485
|
+
onSelect: () => {
|
|
486
|
+
process.once("SIGCONT", () => {
|
|
487
|
+
renderer.resume()
|
|
488
|
+
})
|
|
489
|
+
|
|
490
|
+
renderer.suspend()
|
|
491
|
+
// pid=0 means send the signal to all processes in the process group
|
|
492
|
+
process.kill(0, "SIGTSTP")
|
|
493
|
+
},
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
title: terminalTitleEnabled() ? "Disable terminal title" : "Enable terminal title",
|
|
497
|
+
value: "terminal.title.toggle",
|
|
498
|
+
keybind: "terminal_title_toggle",
|
|
499
|
+
category: "System",
|
|
500
|
+
onSelect: (dialog) => {
|
|
501
|
+
setTerminalTitleEnabled((prev) => {
|
|
502
|
+
const next = !prev
|
|
503
|
+
kv.set("terminal_title_enabled", next)
|
|
504
|
+
if (!next) renderer.setTerminalTitle("")
|
|
505
|
+
return next
|
|
506
|
+
})
|
|
507
|
+
dialog.clear()
|
|
508
|
+
},
|
|
509
|
+
},
|
|
510
|
+
])
|
|
511
|
+
|
|
512
|
+
createEffect(() => {
|
|
513
|
+
const currentModel = local.model.current()
|
|
514
|
+
if (!currentModel) return
|
|
515
|
+
if (currentModel.providerID === "openrouter" && !kv.get("openrouter_warning", false)) {
|
|
516
|
+
untrack(() => {
|
|
517
|
+
DialogAlert.show(
|
|
518
|
+
dialog,
|
|
519
|
+
"Warning",
|
|
520
|
+
"While openrouter is a convenient way to access LLMs your request will often be routed to subpar providers that do not work well in our testing.\n\nFor reliable access to models check out RIRD Mode\nhttps://rird.ai",
|
|
521
|
+
).then(() => kv.set("openrouter_warning", true))
|
|
522
|
+
})
|
|
523
|
+
}
|
|
524
|
+
})
|
|
525
|
+
|
|
526
|
+
sdk.event.on(TuiEvent.CommandExecute.type, (evt) => {
|
|
527
|
+
command.trigger(evt.properties.command)
|
|
528
|
+
})
|
|
529
|
+
|
|
530
|
+
sdk.event.on(TuiEvent.ToastShow.type, (evt) => {
|
|
531
|
+
toast.show({
|
|
532
|
+
title: evt.properties.title,
|
|
533
|
+
message: evt.properties.message,
|
|
534
|
+
variant: evt.properties.variant,
|
|
535
|
+
duration: evt.properties.duration,
|
|
536
|
+
})
|
|
537
|
+
})
|
|
538
|
+
|
|
539
|
+
sdk.event.on(SessionApi.Event.Deleted.type, (evt) => {
|
|
540
|
+
if (route.data.type === "session" && route.data.sessionID === evt.properties.info.id) {
|
|
541
|
+
route.navigate({ type: "home" })
|
|
542
|
+
toast.show({
|
|
543
|
+
variant: "info",
|
|
544
|
+
message: "The current session was deleted",
|
|
545
|
+
})
|
|
546
|
+
}
|
|
547
|
+
})
|
|
548
|
+
|
|
549
|
+
sdk.event.on(SessionApi.Event.Error.type, (evt) => {
|
|
550
|
+
const error = evt.properties.error
|
|
551
|
+
const message = (() => {
|
|
552
|
+
if (!error) return "An error occured"
|
|
553
|
+
|
|
554
|
+
if (typeof error === "object") {
|
|
555
|
+
const data = error.data
|
|
556
|
+
if ("message" in data && typeof data.message === "string") {
|
|
557
|
+
return data.message
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
return String(error)
|
|
561
|
+
})()
|
|
562
|
+
|
|
563
|
+
toast.show({
|
|
564
|
+
variant: "error",
|
|
565
|
+
message,
|
|
566
|
+
duration: 5000,
|
|
567
|
+
})
|
|
568
|
+
})
|
|
569
|
+
|
|
570
|
+
sdk.event.on(Installation.Event.Updated.type, (evt) => {
|
|
571
|
+
toast.show({
|
|
572
|
+
variant: "success",
|
|
573
|
+
title: "Update Complete",
|
|
574
|
+
message: `RIRD updated to v${evt.properties.version}`,
|
|
575
|
+
duration: 5000,
|
|
576
|
+
})
|
|
577
|
+
})
|
|
578
|
+
|
|
579
|
+
sdk.event.on(Installation.Event.UpdateAvailable.type, (evt) => {
|
|
580
|
+
toast.show({
|
|
581
|
+
variant: "info",
|
|
582
|
+
title: "Update Available",
|
|
583
|
+
message: `RIRD v${evt.properties.version} is available. Run 'rird upgrade' to update manually.`,
|
|
584
|
+
duration: 10000,
|
|
585
|
+
})
|
|
586
|
+
})
|
|
587
|
+
|
|
588
|
+
return (
|
|
589
|
+
<box
|
|
590
|
+
width={dimensions().width}
|
|
591
|
+
height={dimensions().height}
|
|
592
|
+
backgroundColor={theme.background}
|
|
593
|
+
onMouseUp={async () => {
|
|
594
|
+
if (Flag.RIRD_EXPERIMENTAL_DISABLE_COPY_ON_SELECT) {
|
|
595
|
+
renderer.clearSelection()
|
|
596
|
+
return
|
|
597
|
+
}
|
|
598
|
+
const text = renderer.getSelection()?.getSelectedText()
|
|
599
|
+
if (text && text.length > 0) {
|
|
600
|
+
const base64 = Buffer.from(text).toString("base64")
|
|
601
|
+
const osc52 = `\x1b]52;c;${base64}\x07`
|
|
602
|
+
const finalOsc52 = process.env["TMUX"] ? `\x1bPtmux;\x1b${osc52}\x1b\\` : osc52
|
|
603
|
+
/* @ts-expect-error */
|
|
604
|
+
renderer.writeOut(finalOsc52)
|
|
605
|
+
await Clipboard.copy(text)
|
|
606
|
+
.then(() => toast.show({ message: "Copied to clipboard", variant: "info" }))
|
|
607
|
+
.catch(toast.error)
|
|
608
|
+
renderer.clearSelection()
|
|
609
|
+
}
|
|
610
|
+
}}
|
|
611
|
+
>
|
|
612
|
+
<Switch>
|
|
613
|
+
<Match when={route.data.type === "home"}>
|
|
614
|
+
<Home />
|
|
615
|
+
</Match>
|
|
616
|
+
<Match when={route.data.type === "session"}>
|
|
617
|
+
<Session />
|
|
618
|
+
</Match>
|
|
619
|
+
</Switch>
|
|
620
|
+
</box>
|
|
621
|
+
)
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
function ErrorComponent(props: {
|
|
625
|
+
error: Error
|
|
626
|
+
reset: () => void
|
|
627
|
+
onExit: () => Promise<void>
|
|
628
|
+
mode?: "dark" | "light"
|
|
629
|
+
}) {
|
|
630
|
+
const term = useTerminalDimensions()
|
|
631
|
+
useKeyboard((evt) => {
|
|
632
|
+
if (evt.ctrl && evt.name === "c") {
|
|
633
|
+
props.onExit()
|
|
634
|
+
}
|
|
635
|
+
})
|
|
636
|
+
const [copied, setCopied] = createSignal(false)
|
|
637
|
+
|
|
638
|
+
const issueURL = new URL("https://rird.ai#support")
|
|
639
|
+
|
|
640
|
+
// Choose safe fallback colors per mode since theme context may not be available
|
|
641
|
+
const isLight = props.mode === "light"
|
|
642
|
+
const colors = {
|
|
643
|
+
bg: isLight ? "#ffffff" : "#0a0a0a",
|
|
644
|
+
text: isLight ? "#1a1a1a" : "#eeeeee",
|
|
645
|
+
muted: isLight ? "#8a8a8a" : "#808080",
|
|
646
|
+
primary: isLight ? "#3b7dd8" : "#fab283",
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
if (props.error.message) {
|
|
650
|
+
issueURL.searchParams.set("title", `rird: fatal: ${props.error.message}`)
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
if (props.error.stack) {
|
|
654
|
+
issueURL.searchParams.set(
|
|
655
|
+
"description",
|
|
656
|
+
"```\n" + props.error.stack.substring(0, 6000 - issueURL.toString().length) + "...\n```",
|
|
657
|
+
)
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
issueURL.searchParams.set("rird-version", Installation.VERSION)
|
|
661
|
+
|
|
662
|
+
const copyIssueURL = () => {
|
|
663
|
+
Clipboard.copy(issueURL.toString()).then(() => {
|
|
664
|
+
setCopied(true)
|
|
665
|
+
})
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
return (
|
|
669
|
+
<box flexDirection="column" gap={1} backgroundColor={colors.bg}>
|
|
670
|
+
<box flexDirection="row" gap={1} alignItems="center">
|
|
671
|
+
<text attributes={TextAttributes.BOLD} fg={colors.text}>
|
|
672
|
+
Please report an issue.
|
|
673
|
+
</text>
|
|
674
|
+
<box onMouseUp={copyIssueURL} backgroundColor={colors.primary} padding={1}>
|
|
675
|
+
<text attributes={TextAttributes.BOLD} fg={colors.bg}>
|
|
676
|
+
Copy issue URL (exception info pre-filled)
|
|
677
|
+
</text>
|
|
678
|
+
</box>
|
|
679
|
+
{copied() && <text fg={colors.muted}>Successfully copied</text>}
|
|
680
|
+
</box>
|
|
681
|
+
<box flexDirection="row" gap={2} alignItems="center">
|
|
682
|
+
<text fg={colors.text}>A fatal error occurred!</text>
|
|
683
|
+
<box onMouseUp={props.reset} backgroundColor={colors.primary} padding={1}>
|
|
684
|
+
<text fg={colors.bg}>Reset TUI</text>
|
|
685
|
+
</box>
|
|
686
|
+
<box onMouseUp={props.onExit} backgroundColor={colors.primary} padding={1}>
|
|
687
|
+
<text fg={colors.bg}>Exit</text>
|
|
688
|
+
</box>
|
|
689
|
+
</box>
|
|
690
|
+
<scrollbox height={Math.floor(term().height * 0.7)}>
|
|
691
|
+
<text fg={colors.muted}>{props.error.stack}</text>
|
|
692
|
+
</scrollbox>
|
|
693
|
+
<text fg={colors.text}>{props.error.message}</text>
|
|
694
|
+
</box>
|
|
695
|
+
)
|
|
696
|
+
}
|