Vishal.dev
Back
Astra — Terminal AI Coding Agent — live site preview
Backend

Astra — Terminal AI Coding Agent

Feature-rich terminal coding agent with 23 built-in tools, multi-provider LLM failover, multi-agent orchestration, browser automation, and messaging gateways for Telegram, Discord, and WhatsApp.

TypeScriptNode.js 20+Ink (React for CLI)OpenAI SDKPlaywrightgrammY (Telegram)discord.js v14Baileys (WhatsApp)VitestDocker
23
Built-in tools
5
LLM providers
3
Messaging platforms
3
Failover attempts/turn

Domain Knowledge

What problem this project solves

AI coding agents face a fundamental tension: power versus safety. Astra resolves this with a permission system (allow/ask/deny by pattern), approval gates for destructive operations, and scope isolation for multi-agent runs. The multi-provider failover means if one LLM hits rate limits, Astra seamlessly switches to the next provider — up to 3 switches per turn. The boss orchestrator mode delegates to specialized workers (explore, implement, shell, plan) while the multi-agent mode runs agents in parallel with disjoint file-scope claims.

Architecture

How the system is structured

The system uses a tool-use architecture where the LLM orchestrates a set of 23 registered tools. Each tool has a schema definition, permission level, and execution handler. The agent loop: user input → LLM reasoning → tool selection → permission check → execution → result → next iteration. Multi-agent mode uses file-scope claims — each agent locks specific file paths to prevent concurrent write conflicts. The messaging gateways (Telegram, Discord, WhatsApp) are thin adapters that map platform messages to the agent's standard input format and render tool approval buttons as platform-native interactive elements.

Data Model

Schema design and data flow

The agent maintains conversation history with context compaction when approaching model limits. Tool results are stored with correlation IDs linking them to the triggering LLM decision. Permission presets are defined per-pattern (bash: allow 'npm *', ask 'rm *', deny 'sudo *'). Project rules auto-discover AGENTS.md/CLAUDE.md files injected into system prompts. Skills are installable modules from the Vercel Agent Skills ecosystem.

Key Challenges

Hardest problems encountered

The hardest challenge was multi-agent file-scope coordination. When multiple agents work on the same codebase, concurrent writes can corrupt files. Solved with a claim system: each agent declares which files it needs before starting work, and the orchestrator rejects overlapping claims. Context compaction required careful history summarization to preserve critical decisions while reducing token count. The messaging gateways needed platform-specific UX — Telegram's inline buttons for approve/deny, Discord's component interactions, WhatsApp's reply-based flow.

Scaling Strategy

How the system grows

The agent is single-process but handles load through tool parallelism (multiple independent tool calls in one turn). Multi-agent mode scales horizontally by running separate Node.js processes with the orchestrator as coordinator. Docker deployment provides isolation per agent run. Conversation compaction keeps memory usage bounded regardless of session length.

Security

Defense-in-depth approach

Permission presets enforce granular access control: bash commands pattern-matched against allow/ask/deny lists. Shell approval gates require explicit human consent for destructive operations. API keys are environment-only, never logged. MCP server connections are validated before tool registration. Skills are sandboxed — they can only access declared capabilities.

Failure Handling

Resilience and recovery

Tool execution failures are reported to the LLM for retry with modified approach. Provider failover handles rate limits and API errors transparently. Browser automation pauses for CAPTCHAs and OTPs. Context overflow triggers compaction rather than truncation. Conversation history is persisted to disk so crashes don't lose work.

Observability

Monitoring and debugging

Every tool call is logged with timing, input, output, and success/failure status. LLM token usage tracked per turn with cost estimation. Multi-agent runs show a coordination timeline. Permission denials are logged with pattern and reason. Provider failover events include trigger reason and recovery.

Trade-offs

Engineering decisions and alternatives

Ink over Blessed for React-native component model. OpenAI SDK as universal provider client over per-provider SDKs. Playwright over Puppeteer for better cross-browser support. Permission patterns over per-command approval for UX. Boss mode (sequential) over fully parallel for predictability. Docker over process isolation for reproducibility.

Architecture Decisions

Key choices and what was rejected

Decision
Chosen
Rejected
CLI framework
Ink (React for CLI)
Blessed (low-level, verbose)
Multi-agent coordination
File-scope claims with orchestrator
Lock-based concurrency (deadlock risk)
Provider management
Unified SDK with automatic failover
Per-provider clients (duplicated logic)
Permission model
Pattern-based presets with approval gates
Per-command approval (UX friction)

Senior-Level Topics

Concepts this project explores

Tool-Use ArchitectureMulti-Provider FailoverFile-Scope CoordinationPermission SystemsBrowser AutomationMessage Gateway DesignContext CompactionAgent Orchestration