$ show lthoangg/OpenAgentd
OpenAgentd is a local-first, coding-focused AI agent platform that provides a desktop application (Tauri), mobile companion (iOS), browser-based UI (React/Vite), CLI, and an API server. The system orchestrates an agent loop with pluggable LLM providers (Anthropic, OpenAI, DeepSeek, Grok, Ollama, etc.), MCP tool integration, filesystem tools, code analysis, and a scheduler for recurring tasks. It features a dual backend architecture: a legacy Python/FastAPI implementation and a newer Rust v3 rewrite (axum-based) that is progressively replacing the Python version. The web frontend is a rich SPA with real-time streaming, workspace management, telemetry/observability dashboards, and extensive settings panels. The repository also includes code health analysis scripts, document chunking for RAG, and a comprehensive test suite across all layers.
The LLM identified 6 files worth highlighting for reuse:
Implements a bounded-queue JSONL batch writer designed for non-blocking, lossy telemetry export. Uses a daemon flusher thread, partition-grouped file appends (hourly/daily/monthly), and clean shutdown via sentinel. Drops records on queue full to avoid lock contention. This pattern is reusable for any high-throughput, loss-tolerant log or metric export pipeline.
Custom JSON serializer that matches Python's `repr` output for floats and strings, enabling cross-language compatibility between Rust and Python backends. Handles special float values (inf, nan), integer representation, and string escaping. Demonstrates deep understanding of serialization edge cases and is extractable for any Rust project needing Python-compatible JSON output.
Reference-counted per-path async lock manager with ordered acquisition to prevent deadlocks. Provides checkout/checkin semantics for concurrent file operations. The pattern is reusable for any application needing safe concurrent access to filesystem paths, and the ordered-lock strategy is a non-obvious solution to a common concurrency problem.
Implements a background title-generation hook for the agent loop using `asyncio.create_task` with optional timeout. Fires on first user turn, generates a concise title via LLM, and emits SSE events. The hook pattern (subclassing `BaseAgentHook` with `before_agent`/`after_agent` lifecycle) is a clean, reusable abstraction for adding side effects to agent execution without modifying core logic.
Parses free-text file references (e.g., `src/a.ts:12:5`) and resolves them to workspace-relative paths with line/column ranges. Implements disambiguation against touched paths, a MAX_FREE_REFS cap, and heuristic rules to avoid false positives. This utility is reusable for any code-aware application that needs to link model output to source files.
Implements an SSE client with manual chunked transfer decoding, `data:` line parsing, and sentinel termination. Handles edge cases like multi-line data, empty lines, and connection termination. Includes a mock server for testing. This is a robust, self-contained SSE parser that can be extracted for any Rust project needing to consume streaming server-sent events.