rird 2.1.231 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +86 -0
- package/COMPLETED_TEST_SUITE.txt +280 -0
- package/Dockerfile +18 -0
- package/README.md +397 -6
- package/RIRD_ERROR_HANDLING_SUMMARY.md +307 -0
- package/TESTING.md +512 -0
- package/TEST_IMPLEMENTATION_REPORT.md +463 -0
- package/TEST_SUITE.md +307 -0
- package/TEST_SUMMARY.txt +380 -0
- package/bin/rird-perf.js +37 -0
- package/bin/rird.js +43 -8
- package/bunfig.toml +4 -0
- package/create-wrapper.ps1 +51 -0
- package/docs/ARCHITECTURE.md +768 -0
- package/docs/CLI_REFERENCE.md +681 -0
- package/docs/DOCUMENTATION_MANIFEST.md +392 -0
- package/docs/INDEX.md +295 -0
- package/docs/PRODUCTION_SETUP.md +633 -0
- package/docs/TROUBLESHOOTING.md +914 -0
- package/facebook_ads_library.png +0 -0
- package/nul +0 -0
- package/nul`nif +0 -0
- package/package.json +104 -15
- package/parsers-config.ts +239 -0
- package/rird-1.0.199.tgz +0 -0
- package/rird-1.0.205.tgz +0 -0
- package/script/build-windows.ts +56 -0
- package/script/build.ts +165 -0
- package/{postinstall.mjs → script/postinstall.mjs} +47 -68
- package/script/publish-registries.ts +187 -0
- package/script/publish.ts +85 -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 +104 -0
- package/src/cli/cmd/activate.ts +50 -0
- package/src/cli/cmd/agent.ts +256 -0
- package/src/cli/cmd/auth.ts +412 -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 +68 -0
- package/src/cli/cmd/pr.ts +112 -0
- package/src/cli/cmd/run.ts +434 -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 +694 -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 +236 -0
- package/src/cli/cmd/tui/component/dialog-provider.tsx +240 -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 +48 -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 +1087 -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 +345 -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/hooks/use-safe-terminal-dimensions.ts +12 -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 +1876 -0
- package/src/cli/cmd/tui/routes/session/sidebar.tsx +320 -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 +333 -0
- package/src/cli/cmd/tui/ui/dialog.tsx +171 -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 +146 -0
- package/src/cli/cmd/tui/worker.ts +63 -0
- package/src/cli/cmd/uninstall.ts +344 -0
- package/src/cli/cmd/upgrade.ts +127 -0
- package/src/cli/cmd/web.ts +84 -0
- package/src/cli/error.ts +69 -0
- package/src/cli/ui.ts +101 -0
- package/src/cli/upgrade.ts +28 -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 +994 -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 +84 -0
- package/src/format/formatter.ts +315 -0
- package/src/format/index.ts +137 -0
- package/src/global/index.ts +101 -0
- package/src/id/id.ts +73 -0
- package/src/ide/index.ts +76 -0
- package/src/index.ts +297 -0
- package/src/index.ts.backup +271 -0
- package/src/installation/index.ts +258 -0
- package/src/lib/IMPLEMENTATION_NOTES.md +345 -0
- package/src/lib/error-handler.ts +225 -0
- package/src/lib/error-testing-guide.md +258 -0
- package/src/lib/errors.ts +285 -0
- package/src/lib/performance.ts +70 -0
- package/src/lib/telemetry.ts +282 -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 +1117 -0
- package/src/mcp/intent-analyzer.ts +376 -0
- package/src/mcp/oauth-callback.ts +200 -0
- package/src/mcp/oauth-provider.ts +154 -0
- package/src/patch/index.ts +632 -0
- package/src/permission/index.ts +199 -0
- package/src/plugin/index.ts +91 -0
- package/src/project/bootstrap.ts +33 -0
- package/src/project/instance.ts +78 -0
- package/src/project/project.ts +236 -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 +55 -0
- package/src/provider/models.ts +161 -0
- package/src/provider/provider.ts +1109 -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 +570 -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 +2641 -0
- package/src/server/tui.ts +71 -0
- package/src/session/compaction.ts +228 -0
- package/src/session/index.ts +464 -0
- package/src/session/llm.ts +201 -0
- package/src/session/message-v2.ts +695 -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 +63 -0
- package/src/session/prompt/anthropic_spoof.txt +1 -0
- package/src/session/prompt/beast.txt +76 -0
- package/src/session/prompt/codex.txt +304 -0
- package/src/session/prompt/copilot-gpt-5.txt +137 -0
- package/src/session/prompt/gemini.txt +62 -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 +88 -0
- package/src/session/prompt/qwen.txt +59 -0
- package/src/session/prompt.ts +1552 -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 +209 -0
- package/src/session/system.ts +122 -0
- package/src/session/todo.ts +37 -0
- package/src/share/share-next.ts +222 -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 +314 -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 +184 -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 +268 -0
- package/src/tool/websearch.txt +13 -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 +362 -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/cmd/acp.test.ts +144 -0
- package/test/cli/cmd/run.test.ts +250 -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 +536 -0
- package/test/config/markdown.test.ts +89 -0
- package/test/file/ignore.test.ts +10 -0
- package/test/fixture/fixture.ts +37 -0
- package/test/fixture/lsp/fake-lsp-server.js +77 -0
- package/test/helpers.ts +172 -0
- package/test/ide/ide.test.ts +82 -0
- package/test/installation/installation.test.ts +143 -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 +74 -0
- package/test/provider/provider.test.ts +74 -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 +940 -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/license.test.ts +235 -0
- package/test/util/timeout.test.ts +21 -0
- package/test/util/wildcard.test.ts +55 -0
- package/tsconfig.json +16 -0
- package/update-versions.ps1 +65 -0
|
@@ -0,0 +1,768 @@
|
|
|
1
|
+
# RIRD CLI Architecture
|
|
2
|
+
|
|
3
|
+
Technical architecture and system design of RIRD AI Agent.
|
|
4
|
+
|
|
5
|
+
## System Architecture Overview
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
9
|
+
│ User Interface Layer │
|
|
10
|
+
│ Terminal UI (TUI) | API Server | CLI Commands │
|
|
11
|
+
└────────────────────────────┬────────────────────────────────┘
|
|
12
|
+
│
|
|
13
|
+
┌────────────────────────────▼────────────────────────────────┐
|
|
14
|
+
│ Agent Control Layer │
|
|
15
|
+
│ Command Router | State Management | Session Handler │
|
|
16
|
+
└────────────────────────────┬────────────────────────────────┘
|
|
17
|
+
│
|
|
18
|
+
┌────────────────────────────▼────────────────────────────────┐
|
|
19
|
+
│ Execution Engine Layer │
|
|
20
|
+
│ Task Processing | Planning | Tool Calling | Response Gen │
|
|
21
|
+
└────────────────────────────┬────────────────────────────────┘
|
|
22
|
+
│
|
|
23
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
24
|
+
│ Integration Layer │
|
|
25
|
+
│ ┌──────────────┐ ┌──────────────┐ ┌─────────────────┐ │
|
|
26
|
+
│ │ LLM Proxy │ │ MCP Servers │ │ File System │ │
|
|
27
|
+
│ │ (Anthropic, │ │ (Browser, │ │ (Read/Write) │ │
|
|
28
|
+
│ │ OpenAI, │ │ Computer │ │ │ │
|
|
29
|
+
│ │ Google, │ │ Use) │ │ │ │
|
|
30
|
+
│ │ etc) │ │ │ │ │ │
|
|
31
|
+
│ └──────────────┘ └──────────────┘ └─────────────────┘ │
|
|
32
|
+
└─────────────────────────────────────────────────────────────┘
|
|
33
|
+
│
|
|
34
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
35
|
+
│ Foundation Layer │
|
|
36
|
+
│ Configuration | License | Logging | Error Handling │
|
|
37
|
+
└─────────────────────────────────────────────────────────────┘
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Component Responsibilities
|
|
41
|
+
|
|
42
|
+
### User Interface Layer
|
|
43
|
+
|
|
44
|
+
**Terminal UI (TUI)**
|
|
45
|
+
- Interactive conversation interface
|
|
46
|
+
- Real-time task progress display
|
|
47
|
+
- Keyboard navigation and shortcuts
|
|
48
|
+
- Session management (save/resume)
|
|
49
|
+
- Syntax highlighting for code
|
|
50
|
+
|
|
51
|
+
**API Server**
|
|
52
|
+
- REST endpoints for remote task submission
|
|
53
|
+
- Bearer token authentication
|
|
54
|
+
- WebSocket support for streaming
|
|
55
|
+
- Health checks and status reporting
|
|
56
|
+
|
|
57
|
+
**CLI Commands**
|
|
58
|
+
- One-shot task execution
|
|
59
|
+
- License management (activate, status)
|
|
60
|
+
- System information (version, health)
|
|
61
|
+
- Configuration management
|
|
62
|
+
- Update/upgrade functionality
|
|
63
|
+
|
|
64
|
+
### Agent Control Layer
|
|
65
|
+
|
|
66
|
+
**Command Router**
|
|
67
|
+
- Parses user input and shell arguments
|
|
68
|
+
- Routes to appropriate handler
|
|
69
|
+
- Validates command syntax
|
|
70
|
+
- Handles special commands (--version, --help)
|
|
71
|
+
|
|
72
|
+
**State Management**
|
|
73
|
+
- Maintains conversation history
|
|
74
|
+
- Tracks task progress and results
|
|
75
|
+
- Manages session persistence
|
|
76
|
+
- Handles interrupts and signals
|
|
77
|
+
|
|
78
|
+
**Session Handler**
|
|
79
|
+
- Creates new sessions
|
|
80
|
+
- Loads previous conversations
|
|
81
|
+
- Saves state to disk
|
|
82
|
+
- Implements session recovery
|
|
83
|
+
|
|
84
|
+
### Execution Engine Layer
|
|
85
|
+
|
|
86
|
+
**Task Processing**
|
|
87
|
+
- Breaks down user tasks into steps
|
|
88
|
+
- Manages task lifecycle (queue, execute, complete)
|
|
89
|
+
- Implements retry logic with exponential backoff
|
|
90
|
+
- Tracks execution metrics and timings
|
|
91
|
+
|
|
92
|
+
**Planning**
|
|
93
|
+
- Analyzes user intent and requirements
|
|
94
|
+
- Generates execution plan
|
|
95
|
+
- Determines required tools and models
|
|
96
|
+
- Estimates resource usage
|
|
97
|
+
|
|
98
|
+
**Tool Calling**
|
|
99
|
+
- Invokes appropriate tools based on plan
|
|
100
|
+
- Manages tool execution and result handling
|
|
101
|
+
- Implements tool chaining (output of one tool feeds into another)
|
|
102
|
+
- Handles tool errors with fallbacks
|
|
103
|
+
|
|
104
|
+
**Response Generation**
|
|
105
|
+
- Synthesizes results from tool calls
|
|
106
|
+
- Generates human-readable explanations
|
|
107
|
+
- Formats output (text, JSON, code)
|
|
108
|
+
- Implements streaming for large results
|
|
109
|
+
|
|
110
|
+
### Integration Layer
|
|
111
|
+
|
|
112
|
+
**LLM Proxy**
|
|
113
|
+
- Communicates with remote LLM servers
|
|
114
|
+
- Handles authentication and API keys
|
|
115
|
+
- Implements retry logic for transient failures
|
|
116
|
+
- Caches model responses
|
|
117
|
+
- Streams tokens for real-time display
|
|
118
|
+
|
|
119
|
+
**MCP Servers**
|
|
120
|
+
- Browser automation (Playwright/Puppeteer)
|
|
121
|
+
- Computer use (mouse, keyboard, screenshots)
|
|
122
|
+
- File system operations (read, write, edit)
|
|
123
|
+
- Web scraping and extraction
|
|
124
|
+
- Image analysis and OCR
|
|
125
|
+
|
|
126
|
+
**File System**
|
|
127
|
+
- Read files for analysis
|
|
128
|
+
- Write generated code
|
|
129
|
+
- Edit existing files
|
|
130
|
+
- Manage project structure
|
|
131
|
+
|
|
132
|
+
### Foundation Layer
|
|
133
|
+
|
|
134
|
+
**Configuration**
|
|
135
|
+
- Loads YAML/JSON configuration files
|
|
136
|
+
- Validates configuration schema
|
|
137
|
+
- Provides sensible defaults
|
|
138
|
+
- Environment variable overrides
|
|
139
|
+
|
|
140
|
+
**License Management**
|
|
141
|
+
- Validates license key format
|
|
142
|
+
- Communicates with license server
|
|
143
|
+
- Manages device fingerprinting
|
|
144
|
+
- Implements 24-hour cache for offline use
|
|
145
|
+
|
|
146
|
+
**Logging**
|
|
147
|
+
- Structured logging (JSON or text)
|
|
148
|
+
- Configurable log levels (debug, info, warn, error)
|
|
149
|
+
- File and console output
|
|
150
|
+
- Log rotation and cleanup
|
|
151
|
+
|
|
152
|
+
**Error Handling**
|
|
153
|
+
- Graceful degradation
|
|
154
|
+
- User-friendly error messages
|
|
155
|
+
- Error context and debugging info
|
|
156
|
+
- Recovery suggestions
|
|
157
|
+
|
|
158
|
+
## Data Flow Diagrams
|
|
159
|
+
|
|
160
|
+
### Task Execution Flow
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
User Input
|
|
164
|
+
│
|
|
165
|
+
▼
|
|
166
|
+
┌─────────────────────────┐
|
|
167
|
+
│ Parse & Validate Input │
|
|
168
|
+
└──────────┬──────────────┘
|
|
169
|
+
│
|
|
170
|
+
▼
|
|
171
|
+
┌─────────────────────────┐
|
|
172
|
+
│ License Check │
|
|
173
|
+
│ (If not cached) │
|
|
174
|
+
└──────────┬──────────────┘
|
|
175
|
+
│
|
|
176
|
+
▼
|
|
177
|
+
┌─────────────────────────┐
|
|
178
|
+
│ Load Configuration │
|
|
179
|
+
│ & Environment Variables │
|
|
180
|
+
└──────────┬──────────────┘
|
|
181
|
+
│
|
|
182
|
+
▼
|
|
183
|
+
┌─────────────────────────┐
|
|
184
|
+
│ Initialize Session │
|
|
185
|
+
│ (Load history if resume)│
|
|
186
|
+
└──────────┬──────────────┘
|
|
187
|
+
│
|
|
188
|
+
▼
|
|
189
|
+
┌─────────────────────────┐
|
|
190
|
+
│ Send to LLM │
|
|
191
|
+
│ (Planning phase) │
|
|
192
|
+
└──────────┬──────────────┘
|
|
193
|
+
│
|
|
194
|
+
▼
|
|
195
|
+
┌─────────────────────────┐
|
|
196
|
+
│ Tool Selection Phase │
|
|
197
|
+
│ (Analyze LLM response) │
|
|
198
|
+
└──────────┬──────────────┘
|
|
199
|
+
│
|
|
200
|
+
▼
|
|
201
|
+
┌─────────────────────────┐
|
|
202
|
+
│ Execute Tools via MCP │
|
|
203
|
+
│ (Browser, File I/O, │
|
|
204
|
+
│ Computer use, etc) │
|
|
205
|
+
└──────────┬──────────────┘
|
|
206
|
+
│
|
|
207
|
+
▼
|
|
208
|
+
┌─────────────────────────┐
|
|
209
|
+
│ Collect Tool Results │
|
|
210
|
+
│ (Process output) │
|
|
211
|
+
└──────────┬──────────────┘
|
|
212
|
+
│
|
|
213
|
+
▼
|
|
214
|
+
┌─────────────────────────┐
|
|
215
|
+
│ Feed Results to LLM │
|
|
216
|
+
│ (Reasoning phase) │
|
|
217
|
+
└──────────┬──────────────┘
|
|
218
|
+
│
|
|
219
|
+
▼
|
|
220
|
+
┌─────────────────────────┐
|
|
221
|
+
│ Generate Response │
|
|
222
|
+
│ (Save to session) │
|
|
223
|
+
└──────────┬──────────────┘
|
|
224
|
+
│
|
|
225
|
+
▼
|
|
226
|
+
Output to User
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### LLM Communication Flow
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
RIRD Agent
|
|
233
|
+
│
|
|
234
|
+
├─── Remote URL ────────┐
|
|
235
|
+
│ ▼
|
|
236
|
+
│ ┌──────────────────────┐
|
|
237
|
+
│ │ License Validation │
|
|
238
|
+
│ │ (Include license key) │
|
|
239
|
+
│ └──────────┬───────────┘
|
|
240
|
+
│ │
|
|
241
|
+
│ ▼
|
|
242
|
+
│ ┌──────────────────────┐
|
|
243
|
+
│ │ Model Selection │
|
|
244
|
+
│ │ (main/fast/vision) │
|
|
245
|
+
│ └──────────┬───────────┘
|
|
246
|
+
│ │
|
|
247
|
+
│ ▼
|
|
248
|
+
│ ┌──────────────────────┐
|
|
249
|
+
│ │ Prepare Prompt │
|
|
250
|
+
│ │ (Context + Tools) │
|
|
251
|
+
│ └──────────┬───────────┘
|
|
252
|
+
│ │
|
|
253
|
+
│ ▼
|
|
254
|
+
│ ┌──────────────────────┐
|
|
255
|
+
│ │ Send to LLM │
|
|
256
|
+
│ │ (via HTTPS) │
|
|
257
|
+
│ └──────────┬───────────┘
|
|
258
|
+
│ │
|
|
259
|
+
│ ▼
|
|
260
|
+
│ ┌──────────────────────┐
|
|
261
|
+
│ │ Stream Tokens │
|
|
262
|
+
│ │ (Real-time display) │
|
|
263
|
+
│ └──────────┬───────────┘
|
|
264
|
+
│ │
|
|
265
|
+
│ ▼
|
|
266
|
+
│ ┌──────────────────────┐
|
|
267
|
+
│ │ Parse Response │
|
|
268
|
+
│ │ (Extract tool calls) │
|
|
269
|
+
│ └──────────┬───────────┘
|
|
270
|
+
│ │
|
|
271
|
+
└───────────────────┘
|
|
272
|
+
│
|
|
273
|
+
▼
|
|
274
|
+
Execute Tool Calls
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## Security Model
|
|
278
|
+
|
|
279
|
+
### Authentication & Authorization
|
|
280
|
+
|
|
281
|
+
**License Key Authentication**
|
|
282
|
+
- Token format: `rird_` prefix + 32+ characters
|
|
283
|
+
- Stored in: `~/.rird/license.key` (user-readable, must be protected)
|
|
284
|
+
- Validated: On-demand with 24-hour cache
|
|
285
|
+
- Device-bound: SHA256 fingerprint prevents key sharing
|
|
286
|
+
|
|
287
|
+
**Device Fingerprinting**
|
|
288
|
+
```
|
|
289
|
+
fingerprint = SHA256(
|
|
290
|
+
hostname +
|
|
291
|
+
platform +
|
|
292
|
+
architecture +
|
|
293
|
+
total_memory_bytes +
|
|
294
|
+
cpu_count
|
|
295
|
+
)
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Benefits:
|
|
299
|
+
- Prevents unauthorized device use
|
|
300
|
+
- Survives system updates (hostname typically stable)
|
|
301
|
+
- User-local computation only
|
|
302
|
+
- No personal data transmission
|
|
303
|
+
|
|
304
|
+
**API Key Management**
|
|
305
|
+
- Separate from license key
|
|
306
|
+
- Can be rotated without reinstalling
|
|
307
|
+
- Stored in config file (should be protected via file permissions)
|
|
308
|
+
- Environment variable override for CI/CD safety
|
|
309
|
+
|
|
310
|
+
### Network Security
|
|
311
|
+
|
|
312
|
+
**HTTPS Enforcement**
|
|
313
|
+
- All API communication over HTTPS
|
|
314
|
+
- Certificate validation enabled
|
|
315
|
+
- TLS 1.2+ required
|
|
316
|
+
- Cipher suite validation
|
|
317
|
+
|
|
318
|
+
**Request Signing** (if applicable)
|
|
319
|
+
- Timestamp-based to prevent replay
|
|
320
|
+
- HMAC-SHA256 for integrity
|
|
321
|
+
- Rate limiting on server-side
|
|
322
|
+
|
|
323
|
+
**Proxy Support**
|
|
324
|
+
- HTTP/HTTPS proxy support
|
|
325
|
+
- Authentication headers passed through
|
|
326
|
+
- Certificate validation preserved
|
|
327
|
+
|
|
328
|
+
### Data Privacy
|
|
329
|
+
|
|
330
|
+
**Local-First Architecture**
|
|
331
|
+
- Conversations stored locally in `~/.rird/engine/sessions/`
|
|
332
|
+
- Configuration kept local (not synced)
|
|
333
|
+
- License cache encrypted with device fingerprint
|
|
334
|
+
- No telemetry without explicit consent
|
|
335
|
+
|
|
336
|
+
**Information Shared with Servers**
|
|
337
|
+
1. **License Validation**:
|
|
338
|
+
- License key
|
|
339
|
+
- Device fingerprint (SHA256 hash only)
|
|
340
|
+
- Version number
|
|
341
|
+
- Platform/architecture
|
|
342
|
+
|
|
343
|
+
2. **LLM Requests**:
|
|
344
|
+
- Task description
|
|
345
|
+
- Required tool specifications
|
|
346
|
+
- Previous conversation context
|
|
347
|
+
- File contents (if user provides)
|
|
348
|
+
|
|
349
|
+
3. **NOT Shared**:
|
|
350
|
+
- File system structure (only file contents explicitly provided)
|
|
351
|
+
- Sensitive credentials in ~/.rird/
|
|
352
|
+
- Local environment variables (unless explicitly used in task)
|
|
353
|
+
- Browsing history or local data
|
|
354
|
+
|
|
355
|
+
**Data Retention**
|
|
356
|
+
- User data retained for billing/support purposes only
|
|
357
|
+
- Can request deletion via support@rird.ai
|
|
358
|
+
- GDPR/CCPA compliant
|
|
359
|
+
- Automatic logs deletion after 90 days
|
|
360
|
+
|
|
361
|
+
## Anti-Detection Mechanisms
|
|
362
|
+
|
|
363
|
+
RIRD implements 12+ techniques to avoid bot detection:
|
|
364
|
+
|
|
365
|
+
### 1. Fingerprint Spoofing
|
|
366
|
+
```javascript
|
|
367
|
+
// Spoof canvas fingerprint
|
|
368
|
+
canvas.toDataURL = () => {
|
|
369
|
+
// Return modified fingerprint
|
|
370
|
+
return "data:image/png;base64,..."
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// Spoof WebGL
|
|
374
|
+
overrideWebGL()
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### 2. Humanized Timing
|
|
378
|
+
```python
|
|
379
|
+
# Add random jitter to all timings
|
|
380
|
+
base_delay = 1000 # 1 second
|
|
381
|
+
jitter = random(0, 500) # 0-500ms variance
|
|
382
|
+
actual_delay = base_delay + jitter
|
|
383
|
+
time.sleep(actual_delay / 1000)
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### 3. Mouse Movement Simulation
|
|
387
|
+
```python
|
|
388
|
+
# Curved trajectory with acceleration/deceleration
|
|
389
|
+
start = (100, 100)
|
|
390
|
+
end = (500, 500)
|
|
391
|
+
for t in smooth_curve(0, 1, steps=50):
|
|
392
|
+
x = interpolate(start[0], end[0], t)
|
|
393
|
+
y = interpolate(start[1], end[1], t)
|
|
394
|
+
move_mouse(x, y)
|
|
395
|
+
sleep(random(10, 50))
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### 4. User-Agent Rotation
|
|
399
|
+
```python
|
|
400
|
+
user_agents = [
|
|
401
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
|
|
402
|
+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36",
|
|
403
|
+
# ... more variations
|
|
404
|
+
]
|
|
405
|
+
random_agent = random.choice(user_agents)
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### 5. Header Manipulation
|
|
409
|
+
```python
|
|
410
|
+
headers = {
|
|
411
|
+
'User-Agent': random_user_agent(),
|
|
412
|
+
'Accept-Language': 'en-US,en;q=0.9',
|
|
413
|
+
'Referer': 'https://google.com',
|
|
414
|
+
'DNT': '1',
|
|
415
|
+
'Connection': 'keep-alive'
|
|
416
|
+
}
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### 6. Cookie Management
|
|
420
|
+
- Persist cookies across requests
|
|
421
|
+
- Rotate cookies periodically
|
|
422
|
+
- Simulate realistic cookie aging
|
|
423
|
+
- Handle cookie domains properly
|
|
424
|
+
|
|
425
|
+
### 7. Referrer Spoofing
|
|
426
|
+
- Set realistic referrers
|
|
427
|
+
- Rotate between common sources (Google, direct, etc.)
|
|
428
|
+
- Respect rel="noreferrer" attributes
|
|
429
|
+
|
|
430
|
+
### 8. Screen Resolution Tricks
|
|
431
|
+
```python
|
|
432
|
+
# Vary reported screen dimensions
|
|
433
|
+
resolutions = [
|
|
434
|
+
(1920, 1080), # 1080p
|
|
435
|
+
(1366, 768), # HD
|
|
436
|
+
(2560, 1440), # 2K
|
|
437
|
+
]
|
|
438
|
+
random_res = random.choice(resolutions)
|
|
439
|
+
set_screen_resolution(random_res)
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### 9. Proxy Rotation
|
|
443
|
+
- Support HTTP/HTTPS proxies
|
|
444
|
+
- Rotate through proxy pool
|
|
445
|
+
- Fallback to direct if proxy fails
|
|
446
|
+
- Geographic IP spoofing support
|
|
447
|
+
|
|
448
|
+
### 10. WebDriver Detection Evasion
|
|
449
|
+
```python
|
|
450
|
+
# Hide webdriver property
|
|
451
|
+
driver.execute_script(
|
|
452
|
+
"Object.defineProperty(navigator, 'webdriver', "
|
|
453
|
+
"{get: () => false})"
|
|
454
|
+
)
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### 11. CDP Detection Bypass
|
|
458
|
+
```python
|
|
459
|
+
# Chrome DevTools Protocol detection avoidance
|
|
460
|
+
# - Disable --enable-automation flag
|
|
461
|
+
# - Use --disable-blink-features=AutomationControlled
|
|
462
|
+
# - Override cdp property
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
### 12. Headless Detection Mitigation
|
|
466
|
+
```python
|
|
467
|
+
# Headless-specific detections
|
|
468
|
+
chrome_args = [
|
|
469
|
+
'--disable-web-resources',
|
|
470
|
+
'--disable-component-extensions-with-background-pages',
|
|
471
|
+
'--disable-background-networking'
|
|
472
|
+
]
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
## Configuration Management
|
|
476
|
+
|
|
477
|
+
### Configuration Hierarchy (Priority Order)
|
|
478
|
+
|
|
479
|
+
```
|
|
480
|
+
1. Command-line Arguments (highest priority)
|
|
481
|
+
└─ rird --config /custom/path.yaml <task>
|
|
482
|
+
|
|
483
|
+
2. Environment Variables
|
|
484
|
+
└─ export RIRD_HOME=/custom/rird
|
|
485
|
+
|
|
486
|
+
3. Config File (YAML or JSON)
|
|
487
|
+
└─ ~/.rird/engine/config.yaml
|
|
488
|
+
|
|
489
|
+
4. Default Values (lowest priority)
|
|
490
|
+
└─ Built-in defaults in binary
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
### Configuration File Structure
|
|
494
|
+
|
|
495
|
+
```yaml
|
|
496
|
+
# ~/.rird/engine/config.yaml
|
|
497
|
+
|
|
498
|
+
app:
|
|
499
|
+
name: rird
|
|
500
|
+
version: 2.1.239
|
|
501
|
+
debug: false
|
|
502
|
+
|
|
503
|
+
# LLM Configuration
|
|
504
|
+
llm:
|
|
505
|
+
mode: remote # 'remote' or 'local'
|
|
506
|
+
remote_url: https://rird.ai/api/llm
|
|
507
|
+
|
|
508
|
+
models:
|
|
509
|
+
main: 0000/ui-tars-1.5-7b:latest
|
|
510
|
+
fast: 0000/ui-tars-1.5-7b:latest
|
|
511
|
+
vision: 0000/ui-tars-1.5-7b:latest
|
|
512
|
+
|
|
513
|
+
parameters:
|
|
514
|
+
temperature: 0.7
|
|
515
|
+
top_p: 0.9
|
|
516
|
+
max_tokens: 4096
|
|
517
|
+
timeout: 30000
|
|
518
|
+
|
|
519
|
+
# Browser Configuration
|
|
520
|
+
browser:
|
|
521
|
+
enabled: true
|
|
522
|
+
headless: true
|
|
523
|
+
timeout: 30000
|
|
524
|
+
stealth_mode: true
|
|
525
|
+
viewport:
|
|
526
|
+
width: 1920
|
|
527
|
+
height: 1080
|
|
528
|
+
proxy: null
|
|
529
|
+
|
|
530
|
+
# MCP Servers
|
|
531
|
+
mcp:
|
|
532
|
+
enabled: true
|
|
533
|
+
servers:
|
|
534
|
+
- name: stealth-browser-mcp
|
|
535
|
+
type: browser
|
|
536
|
+
enabled: true
|
|
537
|
+
- name: computer-use
|
|
538
|
+
type: system
|
|
539
|
+
enabled: true
|
|
540
|
+
|
|
541
|
+
# Execution Control
|
|
542
|
+
execution:
|
|
543
|
+
max_concurrent_tasks: 1
|
|
544
|
+
task_timeout: 300000 # 5 minutes
|
|
545
|
+
max_retries: 3
|
|
546
|
+
retry_delay: 1000
|
|
547
|
+
|
|
548
|
+
circuit_breaker:
|
|
549
|
+
enabled: true
|
|
550
|
+
failure_threshold: 5
|
|
551
|
+
reset_timeout: 60000
|
|
552
|
+
|
|
553
|
+
# Logging
|
|
554
|
+
logging:
|
|
555
|
+
level: info # debug, info, warn, error
|
|
556
|
+
format: json # json or text
|
|
557
|
+
file: ~/.rird/logs/rird.log
|
|
558
|
+
max_size: 104857600 # 100MB
|
|
559
|
+
max_files: 10
|
|
560
|
+
|
|
561
|
+
# Security
|
|
562
|
+
security:
|
|
563
|
+
ssl_verify: true
|
|
564
|
+
insecure_skip_verify: false # Debug only
|
|
565
|
+
|
|
566
|
+
# Storage
|
|
567
|
+
storage:
|
|
568
|
+
sessions_dir: ~/.rird/sessions
|
|
569
|
+
cache_dir: ~/.rird/cache
|
|
570
|
+
logs_dir: ~/.rird/logs
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
## Error Handling Strategy
|
|
574
|
+
|
|
575
|
+
### Error Classification
|
|
576
|
+
|
|
577
|
+
**Fatal Errors** (Exit with code 1)
|
|
578
|
+
- License invalid or expired
|
|
579
|
+
- Configuration file corrupted
|
|
580
|
+
- Python environment missing
|
|
581
|
+
- Network completely unavailable
|
|
582
|
+
|
|
583
|
+
**Recoverable Errors** (Retry with backoff)
|
|
584
|
+
- Temporary network timeout
|
|
585
|
+
- API rate limit (429)
|
|
586
|
+
- Service temporarily unavailable (503)
|
|
587
|
+
- Tool execution failure
|
|
588
|
+
|
|
589
|
+
**User Errors** (Exit with code 2)
|
|
590
|
+
- Invalid arguments
|
|
591
|
+
- Task description too vague
|
|
592
|
+
- Unsupported file format
|
|
593
|
+
- Missing required input
|
|
594
|
+
|
|
595
|
+
### Retry Strategy
|
|
596
|
+
|
|
597
|
+
```python
|
|
598
|
+
def execute_with_retry(fn, max_retries=3, initial_delay=1):
|
|
599
|
+
"""Execute with exponential backoff retry."""
|
|
600
|
+
for attempt in range(max_retries):
|
|
601
|
+
try:
|
|
602
|
+
return fn()
|
|
603
|
+
except RecoverableError as e:
|
|
604
|
+
if attempt >= max_retries - 1:
|
|
605
|
+
raise
|
|
606
|
+
|
|
607
|
+
delay = initial_delay * (2 ** attempt)
|
|
608
|
+
jitter = random(0, delay * 0.1)
|
|
609
|
+
total_delay = delay + jitter
|
|
610
|
+
|
|
611
|
+
logger.warn(
|
|
612
|
+
f"Retry {attempt + 1}/{max_retries} after {total_delay}ms: {e}"
|
|
613
|
+
)
|
|
614
|
+
sleep(total_delay / 1000)
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
### Error Messages
|
|
618
|
+
|
|
619
|
+
Clear, actionable error messages with:
|
|
620
|
+
- What went wrong
|
|
621
|
+
- Why it happened
|
|
622
|
+
- How to fix it
|
|
623
|
+
- Where to get help
|
|
624
|
+
|
|
625
|
+
**Example**:
|
|
626
|
+
```
|
|
627
|
+
Error: Invalid license key
|
|
628
|
+
|
|
629
|
+
The license key you provided is not in the correct format.
|
|
630
|
+
|
|
631
|
+
Expected format: rird_<32+ characters>
|
|
632
|
+
|
|
633
|
+
Fix:
|
|
634
|
+
1. Go to https://rird.ai/dashboard
|
|
635
|
+
2. Copy your license key (starts with 'rird_')
|
|
636
|
+
3. Run: rird activate YOUR_LICENSE_KEY
|
|
637
|
+
|
|
638
|
+
Need help? Email support@rird.ai
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
## Performance Characteristics
|
|
642
|
+
|
|
643
|
+
### Time Complexity
|
|
644
|
+
|
|
645
|
+
| Operation | Time | Notes |
|
|
646
|
+
|-----------|------|-------|
|
|
647
|
+
| License validation (cached) | 0ms | Local file read |
|
|
648
|
+
| License validation (online) | 100-500ms | Network request |
|
|
649
|
+
| Config load and parse | 5-20ms | YAML parsing |
|
|
650
|
+
| Task initialization | 50-200ms | MCP server startup |
|
|
651
|
+
| LLM request | 1-10s | Depends on task complexity |
|
|
652
|
+
| Tool execution | Variable | Depends on tool (browser 5-30s) |
|
|
653
|
+
|
|
654
|
+
### Space Complexity
|
|
655
|
+
|
|
656
|
+
| Component | Memory | Notes |
|
|
657
|
+
|-----------|--------|-------|
|
|
658
|
+
| RIRD binary | 156MB | Standalone executable |
|
|
659
|
+
| Runtime overhead | 50-100MB | Node.js/Python process |
|
|
660
|
+
| Session history | 1-50MB | Depends on conversation length |
|
|
661
|
+
| Cache | 100-500MB | Configurable |
|
|
662
|
+
| Total | 300-700MB | Typical usage |
|
|
663
|
+
|
|
664
|
+
## Concurrency Model
|
|
665
|
+
|
|
666
|
+
**Single-threaded by design**
|
|
667
|
+
- One task executed at a time
|
|
668
|
+
- Prevents race conditions in file I/O
|
|
669
|
+
- Simplified state management
|
|
670
|
+
- Clear execution ordering
|
|
671
|
+
|
|
672
|
+
**Future: Parallel Execution**
|
|
673
|
+
```bash
|
|
674
|
+
rird --parallel 4 batch-process-files
|
|
675
|
+
```
|
|
676
|
+
Would process 4 files concurrently with separate agent instances.
|
|
677
|
+
|
|
678
|
+
## Testing and Quality
|
|
679
|
+
|
|
680
|
+
### Test Pyramid
|
|
681
|
+
|
|
682
|
+
```
|
|
683
|
+
/\
|
|
684
|
+
/ \ Unit Tests (60%)
|
|
685
|
+
/────\
|
|
686
|
+
/ \ Integration Tests (25%)
|
|
687
|
+
/────────\
|
|
688
|
+
/ \ E2E Tests (15%)
|
|
689
|
+
/────────────\
|
|
690
|
+
/ Smoke Tests \
|
|
691
|
+
/────────────────\
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
### Coverage Goals
|
|
695
|
+
- Unit: 80%+ coverage
|
|
696
|
+
- Integration: Key workflows
|
|
697
|
+
- E2E: Critical user paths
|
|
698
|
+
- Performance: Benchmarks tracked
|
|
699
|
+
|
|
700
|
+
## Deployment Architecture
|
|
701
|
+
|
|
702
|
+
### Single Machine
|
|
703
|
+
```
|
|
704
|
+
User -> RIRD Binary -> LLM API -> Result
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
### Server Mode (Cloud)
|
|
708
|
+
```
|
|
709
|
+
Clients -> API Server (rird serve)
|
|
710
|
+
/ | \
|
|
711
|
+
Task Q Worker Status DB
|
|
712
|
+
|
|
|
713
|
+
LLM API
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
### Kubernetes (Enterprise)
|
|
717
|
+
```
|
|
718
|
+
Load Balancer
|
|
719
|
+
|
|
|
720
|
+
+---+---+
|
|
721
|
+
| | |
|
|
722
|
+
Pod Pod Pod <- RIRD containers (scaled)
|
|
723
|
+
| | |
|
|
724
|
+
+---+---+
|
|
725
|
+
|
|
|
726
|
+
Task Queue (Redis)
|
|
727
|
+
|
|
|
728
|
+
LLM API
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
## Monitoring and Observability
|
|
732
|
+
|
|
733
|
+
### Metrics Collected
|
|
734
|
+
- Task execution time
|
|
735
|
+
- Success/failure rate
|
|
736
|
+
- Tool usage statistics
|
|
737
|
+
- LLM token consumption
|
|
738
|
+
- Error frequencies
|
|
739
|
+
|
|
740
|
+
### Health Checks
|
|
741
|
+
```bash
|
|
742
|
+
rird health-check
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
Verifies:
|
|
746
|
+
- License validity
|
|
747
|
+
- Python environment
|
|
748
|
+
- MCP server status
|
|
749
|
+
- Network connectivity
|
|
750
|
+
- Disk space availability
|
|
751
|
+
|
|
752
|
+
### Logging Levels
|
|
753
|
+
|
|
754
|
+
| Level | Use Case | Example |
|
|
755
|
+
|-------|----------|---------|
|
|
756
|
+
| ERROR | Fatal issues | License validation failed |
|
|
757
|
+
| WARN | Concerning but recoverable | Retry attempt 2 of 3 |
|
|
758
|
+
| INFO | Normal operations | Task started, tool called |
|
|
759
|
+
| DEBUG | Detailed troubleshooting | Full request/response bodies |
|
|
760
|
+
|
|
761
|
+
## Future Architecture Enhancements
|
|
762
|
+
|
|
763
|
+
1. **Plugin System**: Allow third-party tool extensions
|
|
764
|
+
2. **Distributed Execution**: Process tasks across multiple machines
|
|
765
|
+
3. **Real-time Collaboration**: Multiple users on shared sessions
|
|
766
|
+
4. **Advanced Caching**: Persistent learned patterns
|
|
767
|
+
5. **Custom Models**: Support for fine-tuned domain-specific models
|
|
768
|
+
6. **Multi-agent Coordination**: Teams of specialized agents
|