Archon is a platform-agnostic AI coding assistant orchestrator built as a Bun + TypeScript monorepo. It connects messaging platforms (Web UI, Telegram, GitHub, Slack, Discord) to AI coding assistants (Claude Code, Codex) via a unified interface. This page explains the package structure, data flow, key interfaces, and the database schema.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/coleam00/Archon/llms.txt
Use this file to discover all available pages before exploring further.
System overview
Key design principles
- Interface-driven — both platform adapters and AI providers implement strict interfaces for swappability
- Streaming-first — all AI responses stream through async generators for real-time delivery
- Session persistence — AI sessions survive restarts via database storage
- File-based commands — users define commands in Git-versioned markdown files, not hardcoded logic
- Platform-specific streaming — each platform controls whether to stream or batch responses
Monorepo package structure
Archon uses Bun workspaces. Each package has a single responsibility and a narrow dependency surface.Package dependency graph
Package responsibilities
@archon/paths — Path utilities and logger
@archon/paths — Path utilities and logger
Zero dependencies on other
@archon/* packages. Provides:- Archon directory path utilities (
getArchonHome,getWebDistDir, etc.) - Pino logger factory (
createLogger) - CWD env stripper (
stripCwdEnv,strip-cwd-env-boot)
packages/paths/src/@archon/git — Git operations
@archon/git — Git operations
Depends only on
@archon/paths. Provides:- Branch operations (checkout, merge detection)
- Repository operations (clone, sync, remote URL)
- Worktree operations (create, remove, list)
execFileAsyncandmkdirAsyncwrappers
@archon/core or higher.Location: packages/git/src/@archon/providers — AI agent providers
@archon/providers — AI agent providers
Owns all AI SDK dependencies. Provides:
IAgentProviderinterface andSendQueryOptionscontract (zero SDK deps, exported via@archon/providers/types)ClaudeProvider—@anthropic-ai/claude-agent-sdkCodexProvider—@openai/codex-sdkPiProvider(community,builtIn: false) —@mariozechner/pi-coding-agent, ~20 LLM backends
@archon/providers/types is the only part imported by @archon/workflows — it has zero SDK deps and zero runtime side effects.Location: packages/providers/src/@archon/isolation — Worktree isolation
@archon/isolation — Worktree isolation
Depends on
@archon/git and @archon/paths. Provides:IIsolationProviderinterfaceWorktreeProvider— default implementation using git worktreesIsolationResolver— maps workflow requests to environmentsclassifyIsolationError— maps git errors to user-friendly messages
packages/isolation/src/@archon/workflows — Workflow engine
@archon/workflows — Workflow engine
The pure execution engine. Depends only on
@archon/git, @archon/paths, and @archon/providers/types. Database and AI are injected via WorkflowDeps. Provides:parseWorkflow— YAML parsing + Zod validationdiscoverWorkflowsWithConfig— filesystem discovery across all three scopesexecuteWorkflow— orchestration entry point- DAG executor with concurrent node execution
- Variable substitution engine
- Bundled default workflows and commands
packages/workflows/src/@archon/core — Business logic
@archon/core — Business logic
Business logic, database, and orchestration. Depends on
@archon/providers for AI. Provides:- Database layer (SQLite/PostgreSQL adapter)
- Orchestrator (conversation management, session lifecycle)
- Command handler (slash commands)
createWorkflowStore()— bridges core DB toIWorkflowStore
packages/core/src/@archon/adapters — Platform adapters
@archon/adapters — Platform adapters
Depends on
@archon/core. Provides adapters for:- Slack (
chat/slack/) — Socket Mode polling - Telegram (
chat/telegram/) — Bot API polling - GitHub (
forge/github/) — Webhook +ghCLI - Discord (
community/chat/discord/) — discord.js WebSocket - GitLab (
forge/gitlab/) — community forge adapter
packages/adapters/src/@archon/server — HTTP server
@archon/server — HTTP server
OpenAPIHono HTTP server with Zod + OpenAPI spec generation. Provides:
- REST API routes (
/api/) - SSE streaming (
/api/stream/) - Web platform adapter (SSE + message buffering)
- Static frontend serving
packages/server/src/@archon/web — React frontend
@archon/web — React frontend
Vite + Tailwind v4 + shadcn/ui + Zustand. API types are derived from the OpenAPI spec (
src/lib/api.generated.d.ts) — never imported from @archon/workflows. Provides:- Chat UI with SSE streaming
- Workflow Builder
- Command Center (run monitoring)
- Settings panels
packages/web/src/Platform adapter pattern
All platform adapters implementIPlatformAdapter (defined in packages/core/src/types/index.ts):
Conversation ID formats
| Platform | Conversation ID format |
|---|---|
| Web UI | User-provided string or auto-generated UUID |
| Telegram | chat_id (e.g., "123456789") |
| GitHub | owner/repo#issue_number (e.g., "user/repo#42") |
| Slack | thread_ts or channel_id+thread_ts |
| Discord | Channel ID |
| CLI | cli-{timestamp}-{random} |
Streaming modes
Each platform supports stream mode (real-time chunks) and batch mode (accumulated final message).| Platform | Default |
|---|---|
| Telegram | stream |
| Slack | batch |
| Discord | batch |
| GitHub | batch |
| Web UI | SSE streaming (always real-time) |
Authorization pattern
Auth checks happen inside adapters — not in the orchestrator. Each adapter reads its allowlist from an environment variable (e.g.,TELEGRAM_ALLOWED_USER_IDS) in the constructor and checks authorization before invoking the onMessage callback. Unauthorized requests are silently rejected and logged with masked user IDs.
AI provider pattern
All AI providers implementIAgentProvider (defined in packages/providers/src/types.ts):
MessageChunk discriminated union
Built-in providers
| Provider | SDK | builtIn |
|---|---|---|
claude | @anthropic-ai/claude-agent-sdk | true |
codex | @openai/codex-sdk | true |
pi | @mariozechner/pi-coding-agent | false (community) |
Provider resolution order
Provider is resolved via an explicit chain:node.provider ?? workflow.provider ?? config.assistant. Model strings are never used to influence provider selection and are forwarded verbatim to the resolved SDK.
Workflow execution model
Workflows use a DAG (directed acyclic graph) execution model:- Discovery —
discoverWorkflowsWithConfig()searches bundled defaults < global (~/.archon/workflows/) < project (.archon/workflows/), with project-level files overriding by filename. - Parsing —
parseWorkflow()validates YAML against the Zod schema. One broken file doesn’t abort discovery. - Routing —
resolveWorkflowName()uses a 4-tier fallback: exact → case-insensitive → suffix → substring. - Execution —
executeWorkflow()builds the DAG, runs independent nodes concurrently, and resolves$nodeId.outputreferences. - Variable substitution — performed before each node executes: workflow vars → context vars → node output refs.
- Isolation — by default, each workflow run gets its own git worktree at
~/.archon/workspaces/<owner>/<repo>/worktrees/<branch>/.
Node execution states
Concurrent execution
Nodes whosedepends_on are all satisfied run concurrently in the same topological layer. A 3-node chain A → B, C → D runs B and C in parallel after A completes.
Database schema
Archon uses an 8-table schema with theremote_agent_ prefix. SQLite is the default (zero setup); PostgreSQL is optional.
Session lifecycle
Sessions are immutable — transitions create new sessions linked viaparent_session_id. The only transition that creates a new session immediately is plan-to-execute. All others deactivate the current session and create a new one on the next message.
Archon directory structure
API Reference
REST API endpoints for the server layer.
Configuration
All configuration options including package-level env vars.
Workflow Schema
Complete YAML schema for workflow and node definitions.
CLI Reference
CLI commands including serve, skill install, and doctor.