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,372 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Message,
|
|
3
|
+
Agent,
|
|
4
|
+
Provider,
|
|
5
|
+
Session,
|
|
6
|
+
Part,
|
|
7
|
+
Config,
|
|
8
|
+
Todo,
|
|
9
|
+
Command,
|
|
10
|
+
Permission,
|
|
11
|
+
LspStatus,
|
|
12
|
+
McpStatus,
|
|
13
|
+
FormatterStatus,
|
|
14
|
+
SessionStatus,
|
|
15
|
+
ProviderListResponse,
|
|
16
|
+
ProviderAuthMethod,
|
|
17
|
+
VcsInfo,
|
|
18
|
+
} from "@opencode-ai/sdk/v2"
|
|
19
|
+
import { createStore, produce, reconcile } from "solid-js/store"
|
|
20
|
+
import { useSDK } from "@tui/context/sdk"
|
|
21
|
+
import { Binary } from "@opencode-ai/util/binary"
|
|
22
|
+
import { createSimpleContext } from "./helper"
|
|
23
|
+
import type { Snapshot } from "@/snapshot"
|
|
24
|
+
import { useExit } from "./exit"
|
|
25
|
+
import { useArgs } from "./args"
|
|
26
|
+
import { batch, onMount } from "solid-js"
|
|
27
|
+
import { Log } from "@/util/log"
|
|
28
|
+
import type { Path } from "@opencode-ai/sdk"
|
|
29
|
+
|
|
30
|
+
export const { use: useSync, provider: SyncProvider } = createSimpleContext({
|
|
31
|
+
name: "Sync",
|
|
32
|
+
init: () => {
|
|
33
|
+
const [store, setStore] = createStore<{
|
|
34
|
+
status: "loading" | "partial" | "complete"
|
|
35
|
+
provider: Provider[]
|
|
36
|
+
provider_default: Record<string, string>
|
|
37
|
+
provider_next: ProviderListResponse
|
|
38
|
+
provider_auth: Record<string, ProviderAuthMethod[]>
|
|
39
|
+
agent: Agent[]
|
|
40
|
+
command: Command[]
|
|
41
|
+
permission: {
|
|
42
|
+
[sessionID: string]: Permission[]
|
|
43
|
+
}
|
|
44
|
+
config: Config
|
|
45
|
+
session: Session[]
|
|
46
|
+
session_status: {
|
|
47
|
+
[sessionID: string]: SessionStatus
|
|
48
|
+
}
|
|
49
|
+
session_diff: {
|
|
50
|
+
[sessionID: string]: Snapshot.FileDiff[]
|
|
51
|
+
}
|
|
52
|
+
todo: {
|
|
53
|
+
[sessionID: string]: Todo[]
|
|
54
|
+
}
|
|
55
|
+
message: {
|
|
56
|
+
[sessionID: string]: Message[]
|
|
57
|
+
}
|
|
58
|
+
part: {
|
|
59
|
+
[messageID: string]: Part[]
|
|
60
|
+
}
|
|
61
|
+
lsp: LspStatus[]
|
|
62
|
+
mcp: {
|
|
63
|
+
[key: string]: McpStatus
|
|
64
|
+
}
|
|
65
|
+
formatter: FormatterStatus[]
|
|
66
|
+
vcs: VcsInfo | undefined
|
|
67
|
+
path: Path
|
|
68
|
+
}>({
|
|
69
|
+
provider_next: {
|
|
70
|
+
all: [],
|
|
71
|
+
default: {},
|
|
72
|
+
connected: [],
|
|
73
|
+
},
|
|
74
|
+
provider_auth: {},
|
|
75
|
+
config: {},
|
|
76
|
+
status: "loading",
|
|
77
|
+
agent: [],
|
|
78
|
+
permission: {},
|
|
79
|
+
command: [],
|
|
80
|
+
provider: [],
|
|
81
|
+
provider_default: {},
|
|
82
|
+
session: [],
|
|
83
|
+
session_status: {},
|
|
84
|
+
session_diff: {},
|
|
85
|
+
todo: {},
|
|
86
|
+
message: {},
|
|
87
|
+
part: {},
|
|
88
|
+
lsp: [],
|
|
89
|
+
mcp: {},
|
|
90
|
+
formatter: [],
|
|
91
|
+
vcs: undefined,
|
|
92
|
+
path: { state: "", config: "", worktree: "", directory: "" },
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const sdk = useSDK()
|
|
96
|
+
|
|
97
|
+
sdk.event.listen((e) => {
|
|
98
|
+
const event = e.details
|
|
99
|
+
switch (event.type) {
|
|
100
|
+
case "permission.updated": {
|
|
101
|
+
const permissions = store.permission[event.properties.sessionID]
|
|
102
|
+
if (!permissions) {
|
|
103
|
+
setStore("permission", event.properties.sessionID, [event.properties])
|
|
104
|
+
break
|
|
105
|
+
}
|
|
106
|
+
const match = Binary.search(permissions, event.properties.id, (p) => p.id)
|
|
107
|
+
setStore(
|
|
108
|
+
"permission",
|
|
109
|
+
event.properties.sessionID,
|
|
110
|
+
produce((draft) => {
|
|
111
|
+
if (match.found) {
|
|
112
|
+
draft[match.index] = event.properties
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
draft.push(event.properties)
|
|
116
|
+
}),
|
|
117
|
+
)
|
|
118
|
+
break
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
case "permission.replied": {
|
|
122
|
+
const permissions = store.permission[event.properties.sessionID]
|
|
123
|
+
const match = Binary.search(permissions, event.properties.permissionID, (p) => p.id)
|
|
124
|
+
if (!match.found) break
|
|
125
|
+
setStore(
|
|
126
|
+
"permission",
|
|
127
|
+
event.properties.sessionID,
|
|
128
|
+
produce((draft) => {
|
|
129
|
+
draft.splice(match.index, 1)
|
|
130
|
+
}),
|
|
131
|
+
)
|
|
132
|
+
break
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
case "todo.updated":
|
|
136
|
+
setStore("todo", event.properties.sessionID, event.properties.todos)
|
|
137
|
+
break
|
|
138
|
+
|
|
139
|
+
case "session.diff":
|
|
140
|
+
setStore("session_diff", event.properties.sessionID, event.properties.diff)
|
|
141
|
+
break
|
|
142
|
+
|
|
143
|
+
case "session.deleted": {
|
|
144
|
+
const result = Binary.search(store.session, event.properties.info.id, (s) => s.id)
|
|
145
|
+
if (result.found) {
|
|
146
|
+
setStore(
|
|
147
|
+
"session",
|
|
148
|
+
produce((draft) => {
|
|
149
|
+
draft.splice(result.index, 1)
|
|
150
|
+
}),
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
break
|
|
154
|
+
}
|
|
155
|
+
case "session.updated": {
|
|
156
|
+
const result = Binary.search(store.session, event.properties.info.id, (s) => s.id)
|
|
157
|
+
if (result.found) {
|
|
158
|
+
setStore("session", result.index, reconcile(event.properties.info))
|
|
159
|
+
break
|
|
160
|
+
}
|
|
161
|
+
setStore(
|
|
162
|
+
"session",
|
|
163
|
+
produce((draft) => {
|
|
164
|
+
draft.splice(result.index, 0, event.properties.info)
|
|
165
|
+
}),
|
|
166
|
+
)
|
|
167
|
+
break
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
case "session.status": {
|
|
171
|
+
setStore("session_status", event.properties.sessionID, event.properties.status)
|
|
172
|
+
break
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
case "message.updated": {
|
|
176
|
+
const messages = store.message[event.properties.info.sessionID]
|
|
177
|
+
if (!messages) {
|
|
178
|
+
setStore("message", event.properties.info.sessionID, [event.properties.info])
|
|
179
|
+
break
|
|
180
|
+
}
|
|
181
|
+
const result = Binary.search(messages, event.properties.info.id, (m) => m.id)
|
|
182
|
+
if (result.found) {
|
|
183
|
+
setStore("message", event.properties.info.sessionID, result.index, reconcile(event.properties.info))
|
|
184
|
+
break
|
|
185
|
+
}
|
|
186
|
+
setStore(
|
|
187
|
+
"message",
|
|
188
|
+
event.properties.info.sessionID,
|
|
189
|
+
produce((draft) => {
|
|
190
|
+
draft.splice(result.index, 0, event.properties.info)
|
|
191
|
+
if (draft.length > 100) draft.shift()
|
|
192
|
+
}),
|
|
193
|
+
)
|
|
194
|
+
break
|
|
195
|
+
}
|
|
196
|
+
case "message.removed": {
|
|
197
|
+
const messages = store.message[event.properties.sessionID]
|
|
198
|
+
const result = Binary.search(messages, event.properties.messageID, (m) => m.id)
|
|
199
|
+
if (result.found) {
|
|
200
|
+
setStore(
|
|
201
|
+
"message",
|
|
202
|
+
event.properties.sessionID,
|
|
203
|
+
produce((draft) => {
|
|
204
|
+
draft.splice(result.index, 1)
|
|
205
|
+
}),
|
|
206
|
+
)
|
|
207
|
+
}
|
|
208
|
+
break
|
|
209
|
+
}
|
|
210
|
+
case "message.part.updated": {
|
|
211
|
+
const parts = store.part[event.properties.part.messageID]
|
|
212
|
+
if (!parts) {
|
|
213
|
+
setStore("part", event.properties.part.messageID, [event.properties.part])
|
|
214
|
+
break
|
|
215
|
+
}
|
|
216
|
+
const result = Binary.search(parts, event.properties.part.id, (p) => p.id)
|
|
217
|
+
if (result.found) {
|
|
218
|
+
setStore("part", event.properties.part.messageID, result.index, reconcile(event.properties.part))
|
|
219
|
+
break
|
|
220
|
+
}
|
|
221
|
+
setStore(
|
|
222
|
+
"part",
|
|
223
|
+
event.properties.part.messageID,
|
|
224
|
+
produce((draft) => {
|
|
225
|
+
draft.splice(result.index, 0, event.properties.part)
|
|
226
|
+
}),
|
|
227
|
+
)
|
|
228
|
+
break
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
case "message.part.removed": {
|
|
232
|
+
const parts = store.part[event.properties.messageID]
|
|
233
|
+
const result = Binary.search(parts, event.properties.partID, (p) => p.id)
|
|
234
|
+
if (result.found)
|
|
235
|
+
setStore(
|
|
236
|
+
"part",
|
|
237
|
+
event.properties.messageID,
|
|
238
|
+
produce((draft) => {
|
|
239
|
+
draft.splice(result.index, 1)
|
|
240
|
+
}),
|
|
241
|
+
)
|
|
242
|
+
break
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
case "lsp.updated": {
|
|
246
|
+
sdk.client.lsp.status().then((x) => setStore("lsp", x.data!))
|
|
247
|
+
break
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
case "vcs.branch.updated": {
|
|
251
|
+
setStore("vcs", { branch: event.properties.branch })
|
|
252
|
+
break
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
const exit = useExit()
|
|
258
|
+
const args = useArgs()
|
|
259
|
+
|
|
260
|
+
async function bootstrap() {
|
|
261
|
+
const sessionListPromise = sdk.client.session.list().then((x) =>
|
|
262
|
+
setStore(
|
|
263
|
+
"session",
|
|
264
|
+
(x.data ?? []).toSorted((a, b) => a.id.localeCompare(b.id)),
|
|
265
|
+
),
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
// blocking - include session.list when continuing a session
|
|
269
|
+
const blockingRequests: Promise<unknown>[] = [
|
|
270
|
+
sdk.client.config.providers({}, { throwOnError: true }).then((x) => {
|
|
271
|
+
batch(() => {
|
|
272
|
+
setStore("provider", x.data!.providers)
|
|
273
|
+
setStore("provider_default", x.data!.default)
|
|
274
|
+
})
|
|
275
|
+
}),
|
|
276
|
+
sdk.client.provider.list({}, { throwOnError: true }).then((x) => {
|
|
277
|
+
batch(() => {
|
|
278
|
+
setStore("provider_next", x.data!)
|
|
279
|
+
})
|
|
280
|
+
}),
|
|
281
|
+
sdk.client.app.agents({}, { throwOnError: true }).then((x) => setStore("agent", x.data ?? [])),
|
|
282
|
+
sdk.client.config.get({}, { throwOnError: true }).then((x) => setStore("config", x.data!)),
|
|
283
|
+
...(args.continue ? [sessionListPromise] : []),
|
|
284
|
+
]
|
|
285
|
+
|
|
286
|
+
await Promise.all(blockingRequests)
|
|
287
|
+
.then(() => {
|
|
288
|
+
if (store.status !== "complete") setStore("status", "partial")
|
|
289
|
+
// non-blocking
|
|
290
|
+
Promise.all([
|
|
291
|
+
...(args.continue ? [] : [sessionListPromise]),
|
|
292
|
+
sdk.client.command.list().then((x) => setStore("command", x.data ?? [])),
|
|
293
|
+
sdk.client.lsp.status().then((x) => setStore("lsp", x.data!)),
|
|
294
|
+
sdk.client.mcp.status().then((x) => setStore("mcp", x.data!)),
|
|
295
|
+
sdk.client.formatter.status().then((x) => setStore("formatter", x.data!)),
|
|
296
|
+
sdk.client.session.status().then((x) => setStore("session_status", x.data!)),
|
|
297
|
+
sdk.client.provider.auth().then((x) => setStore("provider_auth", x.data ?? {})),
|
|
298
|
+
sdk.client.vcs.get().then((x) => setStore("vcs", x.data)),
|
|
299
|
+
sdk.client.path.get().then((x) => setStore("path", x.data!)),
|
|
300
|
+
]).then(() => {
|
|
301
|
+
setStore("status", "complete")
|
|
302
|
+
})
|
|
303
|
+
})
|
|
304
|
+
.catch(async (e) => {
|
|
305
|
+
Log.Default.error("tui bootstrap failed", {
|
|
306
|
+
error: e instanceof Error ? e.message : String(e),
|
|
307
|
+
name: e instanceof Error ? e.name : undefined,
|
|
308
|
+
stack: e instanceof Error ? e.stack : undefined,
|
|
309
|
+
})
|
|
310
|
+
await exit(e)
|
|
311
|
+
})
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
onMount(() => {
|
|
315
|
+
bootstrap()
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
const fullSyncedSessions = new Set<string>()
|
|
319
|
+
const result = {
|
|
320
|
+
data: store,
|
|
321
|
+
set: setStore,
|
|
322
|
+
get status() {
|
|
323
|
+
return store.status
|
|
324
|
+
},
|
|
325
|
+
get ready() {
|
|
326
|
+
return store.status !== "loading"
|
|
327
|
+
},
|
|
328
|
+
session: {
|
|
329
|
+
get(sessionID: string) {
|
|
330
|
+
const match = Binary.search(store.session, sessionID, (s) => s.id)
|
|
331
|
+
if (match.found) return store.session[match.index]
|
|
332
|
+
return undefined
|
|
333
|
+
},
|
|
334
|
+
status(sessionID: string) {
|
|
335
|
+
const session = result.session.get(sessionID)
|
|
336
|
+
if (!session) return "idle"
|
|
337
|
+
if (session.time.compacting) return "compacting"
|
|
338
|
+
const messages = store.message[sessionID] ?? []
|
|
339
|
+
const last = messages.at(-1)
|
|
340
|
+
if (!last) return "idle"
|
|
341
|
+
if (last.role === "user") return "working"
|
|
342
|
+
return last.time.completed ? "idle" : "working"
|
|
343
|
+
},
|
|
344
|
+
async sync(sessionID: string) {
|
|
345
|
+
if (fullSyncedSessions.has(sessionID)) return
|
|
346
|
+
const [session, messages, todo, diff] = await Promise.all([
|
|
347
|
+
sdk.client.session.get({ sessionID }, { throwOnError: true }),
|
|
348
|
+
sdk.client.session.messages({ sessionID, limit: 100 }),
|
|
349
|
+
sdk.client.session.todo({ sessionID }),
|
|
350
|
+
sdk.client.session.diff({ sessionID }),
|
|
351
|
+
])
|
|
352
|
+
setStore(
|
|
353
|
+
produce((draft) => {
|
|
354
|
+
const match = Binary.search(draft.session, sessionID, (s) => s.id)
|
|
355
|
+
if (match.found) draft.session[match.index] = session.data!
|
|
356
|
+
if (!match.found) draft.session.splice(match.index, 0, session.data!)
|
|
357
|
+
draft.todo[sessionID] = todo.data ?? []
|
|
358
|
+
draft.message[sessionID] = messages.data!.map((x) => x.info)
|
|
359
|
+
for (const message of messages.data!) {
|
|
360
|
+
draft.part[message.info.id] = message.parts
|
|
361
|
+
}
|
|
362
|
+
draft.session_diff[sessionID] = diff.data ?? []
|
|
363
|
+
}),
|
|
364
|
+
)
|
|
365
|
+
fullSyncedSessions.add(sessionID)
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
bootstrap,
|
|
369
|
+
}
|
|
370
|
+
return result
|
|
371
|
+
},
|
|
372
|
+
})
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://rird.ai/theme.json",
|
|
3
|
+
"defs": {
|
|
4
|
+
"darkBg": "#0f0f0f",
|
|
5
|
+
"darkBgPanel": "#15141b",
|
|
6
|
+
"darkBorder": "#2d2d2d",
|
|
7
|
+
"darkFgMuted": "#6d6d6d",
|
|
8
|
+
"darkFg": "#edecee",
|
|
9
|
+
"purple": "#a277ff",
|
|
10
|
+
"pink": "#f694ff",
|
|
11
|
+
"blue": "#82e2ff",
|
|
12
|
+
"red": "#ff6767",
|
|
13
|
+
"orange": "#ffca85",
|
|
14
|
+
"cyan": "#61ffca",
|
|
15
|
+
"green": "#9dff65"
|
|
16
|
+
},
|
|
17
|
+
"theme": {
|
|
18
|
+
"primary": "purple",
|
|
19
|
+
"secondary": "pink",
|
|
20
|
+
"accent": "purple",
|
|
21
|
+
"error": "red",
|
|
22
|
+
"warning": "orange",
|
|
23
|
+
"success": "cyan",
|
|
24
|
+
"info": "purple",
|
|
25
|
+
"text": "darkFg",
|
|
26
|
+
"textMuted": "darkFgMuted",
|
|
27
|
+
"background": "darkBg",
|
|
28
|
+
"backgroundPanel": "darkBgPanel",
|
|
29
|
+
"backgroundElement": "darkBgPanel",
|
|
30
|
+
"border": "darkBorder",
|
|
31
|
+
"borderActive": "darkFgMuted",
|
|
32
|
+
"borderSubtle": "darkBorder",
|
|
33
|
+
"diffAdded": "cyan",
|
|
34
|
+
"diffRemoved": "red",
|
|
35
|
+
"diffContext": "darkFgMuted",
|
|
36
|
+
"diffHunkHeader": "darkFgMuted",
|
|
37
|
+
"diffHighlightAdded": "cyan",
|
|
38
|
+
"diffHighlightRemoved": "red",
|
|
39
|
+
"diffAddedBg": "#354933",
|
|
40
|
+
"diffRemovedBg": "#3f191a",
|
|
41
|
+
"diffContextBg": "darkBgPanel",
|
|
42
|
+
"diffLineNumber": "darkBorder",
|
|
43
|
+
"diffAddedLineNumberBg": "#162620",
|
|
44
|
+
"diffRemovedLineNumberBg": "#26161a",
|
|
45
|
+
"markdownText": "darkFg",
|
|
46
|
+
"markdownHeading": "purple",
|
|
47
|
+
"markdownLink": "pink",
|
|
48
|
+
"markdownLinkText": "purple",
|
|
49
|
+
"markdownCode": "cyan",
|
|
50
|
+
"markdownBlockQuote": "darkFgMuted",
|
|
51
|
+
"markdownEmph": "orange",
|
|
52
|
+
"markdownStrong": "purple",
|
|
53
|
+
"markdownHorizontalRule": "darkFgMuted",
|
|
54
|
+
"markdownListItem": "purple",
|
|
55
|
+
"markdownListEnumeration": "purple",
|
|
56
|
+
"markdownImage": "pink",
|
|
57
|
+
"markdownImageText": "purple",
|
|
58
|
+
"markdownCodeBlock": "darkFg",
|
|
59
|
+
"syntaxComment": "darkFgMuted",
|
|
60
|
+
"syntaxKeyword": "pink",
|
|
61
|
+
"syntaxFunction": "purple",
|
|
62
|
+
"syntaxVariable": "purple",
|
|
63
|
+
"syntaxString": "cyan",
|
|
64
|
+
"syntaxNumber": "green",
|
|
65
|
+
"syntaxType": "purple",
|
|
66
|
+
"syntaxOperator": "pink",
|
|
67
|
+
"syntaxPunctuation": "darkFg"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://rird.ai/theme.json",
|
|
3
|
+
"defs": {
|
|
4
|
+
"darkBg": "#0B0E14",
|
|
5
|
+
"darkBgAlt": "#0D1017",
|
|
6
|
+
"darkLine": "#11151C",
|
|
7
|
+
"darkPanel": "#0F131A",
|
|
8
|
+
"darkFg": "#BFBDB6",
|
|
9
|
+
"darkFgMuted": "#565B66",
|
|
10
|
+
"darkGutter": "#6C7380",
|
|
11
|
+
"darkTag": "#39BAE6",
|
|
12
|
+
"darkFunc": "#FFB454",
|
|
13
|
+
"darkEntity": "#59C2FF",
|
|
14
|
+
"darkString": "#AAD94C",
|
|
15
|
+
"darkRegexp": "#95E6CB",
|
|
16
|
+
"darkMarkup": "#F07178",
|
|
17
|
+
"darkKeyword": "#FF8F40",
|
|
18
|
+
"darkSpecial": "#E6B673",
|
|
19
|
+
"darkComment": "#ACB6BF",
|
|
20
|
+
"darkConstant": "#D2A6FF",
|
|
21
|
+
"darkOperator": "#F29668",
|
|
22
|
+
"darkAdded": "#7FD962",
|
|
23
|
+
"darkRemoved": "#F26D78",
|
|
24
|
+
"darkAccent": "#E6B450",
|
|
25
|
+
"darkError": "#D95757",
|
|
26
|
+
"darkIndentActive": "#6C7380"
|
|
27
|
+
},
|
|
28
|
+
"theme": {
|
|
29
|
+
"primary": "darkEntity",
|
|
30
|
+
"secondary": "darkConstant",
|
|
31
|
+
"accent": "darkAccent",
|
|
32
|
+
"error": "darkError",
|
|
33
|
+
"warning": "darkSpecial",
|
|
34
|
+
"success": "darkAdded",
|
|
35
|
+
"info": "darkTag",
|
|
36
|
+
"text": "darkFg",
|
|
37
|
+
"textMuted": "darkFgMuted",
|
|
38
|
+
"background": "darkBg",
|
|
39
|
+
"backgroundPanel": "darkPanel",
|
|
40
|
+
"backgroundElement": "darkBgAlt",
|
|
41
|
+
"border": "darkGutter",
|
|
42
|
+
"borderActive": "darkIndentActive",
|
|
43
|
+
"borderSubtle": "darkLine",
|
|
44
|
+
"diffAdded": "darkAdded",
|
|
45
|
+
"diffRemoved": "darkRemoved",
|
|
46
|
+
"diffContext": "darkComment",
|
|
47
|
+
"diffHunkHeader": "darkComment",
|
|
48
|
+
"diffHighlightAdded": "darkString",
|
|
49
|
+
"diffHighlightRemoved": "darkMarkup",
|
|
50
|
+
"diffAddedBg": "#20303b",
|
|
51
|
+
"diffRemovedBg": "#37222c",
|
|
52
|
+
"diffContextBg": "darkPanel",
|
|
53
|
+
"diffLineNumber": "darkGutter",
|
|
54
|
+
"diffAddedLineNumberBg": "#1b2b34",
|
|
55
|
+
"diffRemovedLineNumberBg": "#2d1f26",
|
|
56
|
+
"markdownText": "darkFg",
|
|
57
|
+
"markdownHeading": "darkConstant",
|
|
58
|
+
"markdownLink": "darkEntity",
|
|
59
|
+
"markdownLinkText": "darkTag",
|
|
60
|
+
"markdownCode": "darkString",
|
|
61
|
+
"markdownBlockQuote": "darkSpecial",
|
|
62
|
+
"markdownEmph": "darkSpecial",
|
|
63
|
+
"markdownStrong": "darkFunc",
|
|
64
|
+
"markdownHorizontalRule": "darkFgMuted",
|
|
65
|
+
"markdownListItem": "darkEntity",
|
|
66
|
+
"markdownListEnumeration": "darkTag",
|
|
67
|
+
"markdownImage": "darkEntity",
|
|
68
|
+
"markdownImageText": "darkTag",
|
|
69
|
+
"markdownCodeBlock": "darkFg",
|
|
70
|
+
"syntaxComment": "darkComment",
|
|
71
|
+
"syntaxKeyword": "darkKeyword",
|
|
72
|
+
"syntaxFunction": "darkFunc",
|
|
73
|
+
"syntaxVariable": "darkEntity",
|
|
74
|
+
"syntaxString": "darkString",
|
|
75
|
+
"syntaxNumber": "darkConstant",
|
|
76
|
+
"syntaxType": "darkSpecial",
|
|
77
|
+
"syntaxOperator": "darkOperator",
|
|
78
|
+
"syntaxPunctuation": "darkFg"
|
|
79
|
+
}
|
|
80
|
+
}
|