Skip to main content

OpenCAC: Claude Code, Antigravity, and Codex working together across cloud APIs and local models.

Project description

OpenCAC

OpenCAC is multi-agent orchestration CLI for AI coding tools. Wires Claude Code, Antigravity, and Codex into one pipeline with validated handoffs, audit logging, and speculative decoding for local LLMs.

pip install .
opencac run "refactor the auth module" --mode private

Why

For developers who already use multiple AI coding agents and want one CLI to orchestrate them — with cloud models, local LLMs, or both.

   - Claude Code, Codex, Antigravity powerful alone, but each runs in its own world
   - Cloud api burns money — every hosted model call costs real tokens.
   - Local LLMs lack quality — small models are cheap but can't reliably produce production-grade code.

OpenCAC solves this by chaining agents into a four-role pipeline where each agent does what it's best at, with structured validation at every hop.

Features

1. FOUR-ROLE PIPELINE
   dispatcher → antigravity (research) → claude-code (plan) → codex (execute)
   - Structured envelopes at every hop; downstream critiques upstream before acting
   - Codex runs assess_plan — dangerous commands rejected, not blindly run

2. ROUTING MODES
   private   Loopback only. Private guard required. For sensitive / air-gapped work.
   cloud     Cloud API tokens. No local infra needed.
   hybrid    Cloud first, falls back to local LLM when tokens are missing.

3. LOCAL LLM SUPPORT
   - Each role points to its own llama.cpp server endpoint
   - Built-in spec decoding config (n-gram / draft-model) → generates llama-server commands
   - Probe: constrained-grammar check verifies each endpoint before pipeline starts

4. SIDECAR VALIDATION
   - Schema check on every hop — agent whitelist, message-type whitelist, payload fields
   - Blocked commands: rm -rf /, shutdown, mkfs, fork bomb
   - Private mode: loopback-only on all URLs including callbacks

5. JSONL AUDIT LOG
   - One JSON line per action — timestamp, session_id, kind
   - Filter by session, query last N entries
   - Session resume: rebuild plan from log, skip completed steps

6. CLI + HTTP
   CLI          opencac run, opencac audit, opencac resume, interactive REPL
   HTTP         POST /run, GET /tasks/<id>, per-agent endpoints, /.well-known/agent.json
   Distributed  CLI routes through HTTP service, sync and async

7. SMART QUESTION ROUTING
   - Ends with ? or starts with who/what/how/why → QA path, skips pipeline
   - Task input → full pipeline, outputs artifacts
   - Mentions docs/code/error/test → research step first

Quick Start

git clone https://github.com/lpoee/opencac.git && cd opencac
python3 -m venv .venv && . .venv/bin/activate && pip install .
# Private (local llama.cpp shards)
export A2A_ANTIGRAVITY_URL=http://127.0.0.1:18101
export A2A_CLAUDE_CODE_URL=http://127.0.0.1:18102
export A2A_CODEX_URL=http://127.0.0.1:18103
opencac run "task" --mode private

# Cloud
export A2A_ANTIGRAVITY_TOKEN=...
export A2A_CLAUDE_CODE_TOKEN=...
export A2A_CODEX_TOKEN=...
opencac run "task" --mode cloud

# Hybrid
export A2A_CLOUD_FALLBACK_LOCAL=1
opencac run "task" --mode cloud

Agent Integration

Connect real AI agents for production-quality research, planning, and code generation. When set, the pipeline calls real agents first and falls back to local heuristics on failure.

# Antigravity — Gemini research via JSON-RPC (A2A protocol)
export OPENCAC_RESEARCH_URL=http://127.0.0.1:18791

# Claude Code — planning via Claude Bridge (Anthropic messages API)
export OPENCAC_PLANNER_URL=http://127.0.0.1:9300

# Codex — AI code generation via CLI
export OPENCAC_CODEX_BINARY=/usr/local/bin/codex

opencac run "refactor the auth module" --mode private
Variable Agent Protocol Purpose
OPENCAC_RESEARCH_URL Antigravity JSON-RPC 2.0 message/send Web research via Gemini
OPENCAC_PLANNER_URL Claude Bridge POST /v1/messages Plan generation via Claude
OPENCAC_CODEX_BINARY Codex CLI JSONL subprocess AI code generation

The generate plan action dispatches work to Codex CLI for AI-assisted code generation. Without these variables, the pipeline uses deterministic local heuristics (file search, template plans, subprocess execution).

Docker:

docker build -t opencac .
docker run --rm -p 8000:8000 -v "$(pwd)/data:/data" opencac

Speculative Decoding

opencac run "task" --mode private \
  --spec-type ngram-simple \
  --draft-max 64 --draft-min 16
Strategy Description VRAM
Self-speculative (default) n-gram cache on main model Zero extra
Draft-model Smaller model generates draft tokens Extra model

HTTP API

Method Path Description
GET /.well-known/agent.json Agent card
GET /tasks/<id> Status + steps
GET /audit?session_id=<id>&last=20 Audit log
POST /run Run task
POST /run?distributed=1&async=1 Async distributed
POST /agents/<agent>/message/send Message an agent

Output

  • artifacts/<session-id>/plan.json — execution plan
  • artifacts/<session-id>/result.md — routing, strategy, step results
  • .opencac/audit.jsonl — full event log

Testing

PYTHONPATH=src pytest -q   # 32 tests

Security

See SECURITY.md.

Contributing

CONTRIBUTING.md.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opencac-0.2.0.tar.gz (41.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opencac-0.2.0-py3-none-any.whl (32.2 kB view details)

Uploaded Python 3

File details

Details for the file opencac-0.2.0.tar.gz.

File metadata

  • Download URL: opencac-0.2.0.tar.gz
  • Upload date:
  • Size: 41.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for opencac-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d8654a4fb29c1a60b8ac95eae54c949895b9558b3bbc0500a37bbbaeccd61f92
MD5 0bec82899a642e2eaf006ae37edae6b0
BLAKE2b-256 66ece5340d422a6708a2b1b7e4601546075f7edc8dea0ca49a05bc392e7fd737

See more details on using hashes here.

Provenance

The following attestation bundles were made for opencac-0.2.0.tar.gz:

Publisher: release.yml on lpoee/opencac

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opencac-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: opencac-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 32.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for opencac-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 81c4ae98e072811e9174407bfb4a24d746ce29a7f5a879ac8d360b950669d397
MD5 076a4da07a80f0dff8ae8a98c1f928f7
BLAKE2b-256 8a8dc25dcb79984be53aff5dbb000e33ce9cfeb9ecb48ce52cbea6a8bc932c2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for opencac-0.2.0-py3-none-any.whl:

Publisher: release.yml on lpoee/opencac

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page