Skip to content

From Innerpedia, the encyclopedia of you

For the other folder named xo-cowork-api, see xo-cowork-api (disambiguation).

xo-cowork-api is a Python FastAPI service at the top level of github.com/quirq-ai. Created in February 2026, it was last touched in August 2026. It holds 309 files across 70 folders, 1.9 MB in all. Its Git history runs to 72 commits by eight authors, from February 2026 to August 2026. Innerpedia has four articles on folders inside it, the largest being space_ui, project_template and procedural. It keeps instructions for coding agents in CLAUDE.md and AGENTS.md. two agents keep folders of their own here: .agents and .claude.

The local control plane for AI coding agents. One workspace, many runtimes, Claude Code, OpenClaw, Codex, Hermes, Antigravity, and whatever comes next.

Contents
  1. (Top)
  2. Overview
  3. Why it exists
  4. Quick start
  5. A turn, end to end
  6. Pluggable runtimes
  7. API surface at a glance
  8. Connectors
  9. The xo-projects model
  10. Structure
  11. Technology
  12. History
  13. See also
  14. External links

Overview


xo-cowork-api is the FastAPI service that powers an XO Cowork workspace: a local control plane that runs inside every workspace, brokers chat to whichever coding agent runtime you've installed (Claude Code, OpenClaw, Codex), and owns the on-disk project model that travels with your work.

It does not train models, run inference, or compete with the agents — it stitches them together, adds the boring-but-critical glue (sessions, files, secrets, OAuth flows, usage reporting), and exposes one cohesive HTTP/SSE surface that the Tauri UI and any B2B client can build on.

                  ┌────────────────────────────────────────────┐
                  │              xo-cowork (Tauri UI)           │
                  │           or any HTTP/SSE consumer          │
                  └──────────────────────┬─────────────────────┘
                                         │ http://localhost:5002
                                         ▼
       ┌─────────────────────────────────────────────────────────────────┐
       │                       xo-cowork-api  (FastAPI)                   │
       │                                                                  │
       │   /api/chat/*         /api/sessions/*       /api/files/*         │
       │   /api/agents/*       /api/projects/*       /api/secrets/*       │
       │   /api/usage          /api/connectors/*     /xo-auth/*           │
       │                                                                  │
       │   ┌─────────────────────┐    ┌─────────────────────────────┐   │
       │   │  Runtime adapters   │    │  Connector services         │   │
       │   │   • Claude Code     │    │   • Google Drive (rclone)   │   │
       │   │   • OpenClaw        │    │   • OneDrive (rclone)       │   │
       │   │   • Hermes          │    │   • GitHub (PAT + gh CLI)   │   │
       │   │   • Codex (partial) │    │   • Vercel (OAuth + DCR)    │   │
       │   │   • + plug your own │    │   • Manus (API key)         │   │
       │   └─────────────────────┘    └─────────────────────────────┘   │
       └─────┬─────────────────────────────────────────────┬───────────┘
             │                                             │
             ▼                                             ▼
       runtimes on disk                              xo-swarm-api (cloud)
       ~/.claude/  ~/.openclaw/                     Clerk auth + usage sync
       ~/.hermes/  ~/.codex/

Why it exists

Every coding agent ships with its own session store, its own auth, its own todo list, its own way of organising a workspace. The moment you want to combine them — or share a project, or measure usage across all of them, or just see a single chat history — you hit five incompatible filesystems and three half-baked CLIs.

xo-cowork-api is the part of the XO Cowork stack that puts a uniform API in front of all of them, keeps the project folder portable and sharing-safe by construction, and gives you back something you can build a product on.

  • 🧠 Pluggable runtimes — one BaseAgentAdapter contract, one /api/chat/* surface. Claude Code, OpenClaw, Hermes, and Antigravity are first-class; Codex is partial; new runtimes plug in without router changes.
  • 🗂️ Sharing-safe project model — chat content stays in the runtime's own storage (~/.claude/, ~/.openclaw/). The project folder at ~/xo-projects/<id>/ is pure metadata + work files, structurally safe to share, fork, or rebase.
  • 📡 SSE streaming with sane reconnects — event: text-delta / done / heartbeat / agent-error, React-Strict-Mode-safe via a 600 s reconnect window, server-side single-flight on conflicts.
  • 🔌 Connector hub — Google Drive, OneDrive, GitHub (PAT + gh device flow), Vercel (OAuth 2.1 PKCE + Dynamic Client Registration), Manus. Each is dropped into mcp-tokens.json or rclone.conf and survives restarts.
  • 🔐 Clerk-backed identity — browser poll-token flow with cowork-api as the trusted intermediary; tokens never reach the frontend.
  • 📈 Unified usage — /api/usage reads JSONL from every runtime, returns one normalised shape with tokens, cost, model breakdowns, and response-time percentiles.
  • 🛰️ Local-first — runs entirely on your machine. The only cloud call is to xo-swarm-api for identity verification and a daily usage sync. No telemetry, no exfiltration.

Quick start

# 1. Clone
git clone https://github.com/sharmasuraj0123/xo-cowork-api.git
cd xo-cowork-api

# 2. Install dependencies (Python 3.12+)
pip install -r requirements.txt

# 3. Configure
cp .env.example .env       # then edit — see Configuration below

# 4. Boot a runtime (pick at least one)
claude /login                                  # Claude Code
# or
bash config/agents/openclaw/agent.sh start     # OpenClaw gateway on :18789

# 5. Run
python server.py           # http://localhost:5002

# or with auto-reload for development:
uvicorn server:app --host 0.0.0.0 --port 5002 --reload

Verify it's up:

curl http://localhost:5002/health
{
  "status":      "healthy",
  "stage":       "local",
  "ai_provider": "claude",
  "auth":        { "authenticated": true, "user_id": "user_2bX9...", "token_source": "session" },
  ...
}

Process management

cowork-api.sh wraps the server with PID-file management and log redirection:

./cowork-api.sh start      # daemon
./cowork-api.sh status
./cowork-api.sh logs       # tail -f
./cowork-api.sh restart
./cowork-api.sh stop

A turn, end to end

Every chat turn is two HTTP calls:

# 1. Prepare — returns {stream_id, session_id} fast
curl -sX POST http://localhost:5002/api/chat/prompt \
  -H 'Content-Type: application/json' \
  -d '{"text":"Refactor the auth flow to use Clerk"}'
# → {"stream_id":"8f3a...", "session_id":"9d4e..."}

# 2. Consume the SSE stream
curl -N http://localhost:5002/api/chat/stream/8f3a...
event: session-created   data: {"session_id":"9d4e..."}
event: text-delta        data: {"text":"Sure, "}
event: text-delta        data: {"text":"I can do that..."}
event: heartbeat         data: {}
event: done              data: {"finish_reason":"stop","session_id":"9d4e..."}

Full event vocabulary, reconnect semantics, and TypeScript example: see the Frontend Chat API guide.


Pluggable runtimes

Adapters live under services/cowork_agent/adapters/<name>/. The dispatch class in adapter.py implements BaseAgentAdapter: run, stream, and the adapter_name property (setup/health/load_commands are overridable). Everything else an agent provides — usage, models, status, sessions, its own routes — is a separate capability module resolved by AGENT_NAME. See DEVELOPING.md.

RuntimeStatusStorage rootTransport
Claude Code✅ first-class~/.claude/projects/<encoded>/<sid>.jsonlclaude CLI subprocess + --output-format stream-json
OpenClaw✅ first-class~/.openclaw/agents/<a>/sessions/<sid>.jsonlHTTP gateway on :18789 (OpenAI-compatible SSE)
Hermes✅ first-class~/.hermes/profiles/<name>/ (or ~/.hermes/ for default)hermes CLI subprocess + profile-based provider routing
Antigravity✅ first-class~/.gemini/antigravity-cli/brain/<cid>/…/transcript_full.jsonlagy CLI subprocess (-p, transcript-tailing) + Google consumer OAuth (token file, self-refreshing)
Codex🟡 partial — auth + legacy chat~/.codex/...codex CLI subprocess (via /ask_question* legacy path)
Your runtime🔧 fork friendlywherever you likedrop config/agents/<name>/ + adapters/<name>/adapter.py — auto-discovered, zero core edits

The router layer (routers/cowork_agent/chat.py) doesn't know which adapter it's talking to. It picks based on either an explicit agent_name in the request, on-disk session-ownership detection (find_session_backend), or the AGENT_NAME env var. Adapters are auto-discovered — adding a runtime is dropping a folder, no registry edit and no core changes.

Deep dive: Claude Code vs OpenClaw, Streaming protocols compared.


API surface at a glance

Roughly 100 endpoints. Every guide below is a full integration spec — request schemas, response shapes for every status code, edge cases, TypeScript examples.

FamilyRoutesWiki guide
Chat/api/chat/{prompt,stream/{id},abort,respond} + legacy /ask_question*Chat API
Files/api/files/{upload,list-directory,content,content-binary,save,mkdir}Files API
Sessions/api/sessions/*, /api/messages/{id}Sessions & messages
Agents/api/agents/*, /api/models, /api/config/*Agents & config
Auth/xo-auth/*, /connect/claude-code, /connect/codex, /connect/antigravity, /openclaw/usage/*Auth & setup
Connectors/api/connectors/{gdrive,onedrive,github,vercel,manus}/*Connectors
Secrets & misc/api/secrets/*, /api/usage, /api/onboarding/*, /api/channels/addMisc
Server/health, /sessions, /gateway/restart, /app/{restart,update}Server & lifecycle

📚 Full wiki: github.com/sharmasuraj0123/xo-cowork-api/wiki


Connectors

ConnectorMethodWhere credentials live
Google Driverclone authorize drive.file + manual code paste; folder mgmt + 500 MiB streaming uploadsrclone.conf
OneDriverclone authorize Microsoft Graphrclone.conf
GitHubPersonal Access Token paste or gh auth login --web device flowmcp-tokens.json
VercelAPI token paste or OAuth 2.1 PKCE (Dynamic Client Registration on first use)mcp-tokens.json
ManusAPI key pastemcp-tokens.json

Each connector exposes connect, status, disconnect, reconnect plus per-service extras (/sessions/{id}/submit for rclone OAuth code paste; /oauth/start for Vercel; /cli/{start,poll,cancel} for GitHub device flow). The Drive connector additionally ships folder management (mkdir, rmdir, folders) and streaming uploads with no disk spool or RAM buffer.

A :53682-shared single-flight lock between Drive and OneDrive prevents concurrent rclone OAuth flows from colliding on the callback port. See the Connectors guide.


The xo-projects model

Every shared project is a folder under ~/xo-projects/<id>/ with a canonical layout:

~/xo-projects/blackhole/
├── AGENTS.md           ← agent operating contract (read first by agents)
├── CLAUDE.md           ← single line: "@AGENTS.md"
├── PROJECT.md          ← what this project is for
├── OBJECTIVES.md       ← OKRs
├── PLAN.md             ← current plan
├── PROGRESS.md         ← running narrative
├── memory/             ← semantic / episodic / procedural / working
└── .xo/                ← metadata-only — safe to share
    ├─�

Structure

Folders

10 subfolders

.git is left out of the index.

Files

9 files at the top level
  • AGENTS.md
  • CLAUDE.md
  • cowork-api.sh
  • cowork-update.sh
  • DEVELOPING.md
  • Dockerfile
  • README.md
  • requirements.txt
  • server.py

Technology

Languages

share of 304 files
Python69%JSON11%Markdown9.9%JavaScript3.6%Shell3.3%CSS3%HTML<1%

Frameworks and libraries

Dependencies

10 runtime
  • fastapi
  • uvicorn
  • pydantic
  • python-dotenv
  • httpx
  • requests
  • anyio
  • gunicorn
  • python-multipart
  • argus-code

History

72
Commits
8
Authors
Feb 2026
First commit
Aug 2026
Latest commit

Activity

November 2024: 0 commitsDecember 2024: 0 commitsJanuary 2025: 0 commitsFebruary 2025: 0 commitsMarch 2025: 0 commitsApril 2025: 0 commitsMay 2025: 0 commitsJune 2025: 0 commitsJuly 2025: 0 commitsAugust 2025: 0 commitsSeptember 2025: 0 commitsOctober 2025: 0 commitsNovember 2025: 0 commitsDecember 2025: 0 commitsJanuary 2026: 0 commitsFebruary 2026: 22 commitsMarch 2026: 10 commitsApril 2026: 28 commitsMay 2026: 4 commitsJune 2026: 3 commitsJuly 2026: 3 commitsAugust 2026: 2 commitsSeptember 2026: 0 commitsOctober 2026: 0 commits
Commits per month, November 2024 to October 2026. Busiest: April 2026, with 28 commits.

Authors

  • Seemant Tripathi29
  • Mukesh Mali22
  • KrishBhimani8
  • Rohini @ XO4
  • Suraj Sharma3
  • XO3
  • Krish Bhimani2
  • mukesh8041

Recent commits

on main
  1. fix:missing env keys on workspace restart

    KrishBhimani70d288d

  2. Merge Dev to Main (#128)

    KrishBhimani677dbd7

  3. Merge Dev to Main (#120)

    KrishBhimani3314c5e

  4. Merging Dev to Main (#114)

    KrishBhimani095f318

  5. Merging Dev to Main (#111)

    KrishBhimani4885be3

  6. Merge Dev to Main (#99)

    KrishBhimanid4d724c

  7. Merge Dev to Main (#92)

    KrishBhimani317342b

  8. Merge Dev to Main (#88)

    KrishBhimanied72558

  9. Release 5-18 A (#58)

    Suraj Sharma2f53d13

  10. Release v1 Patch 1 (#54)

    Suraj Sharma045d765

See also