Skip to content
/

acpx

acpx

Primitive shape
No installable primitives
00

Summary

acpx — Summary

Slug: acpx Repo: openclaw/acpx Stars: 2759 | Forks: 271 License: MIT Language: TypeScript (Node.js ≥ 22.13.0) Package: npm install -g acpx Homepage: https://acpx.sh

One-Line Description

Headless CLI client for stateful Agent Client Protocol (ACP) sessions — enables agent-to-agent communication without PTY scraping.

What It Is

acpx is a TypeScript/Node.js CLI that wraps the Agent Client Protocol (ACP) to let AI agents, orchestrators, and harnesses talk to coding agents (Claude Code, Codex, Pi, Cursor, Copilot, Gemini, Kiro, and 10+ others) over a structured protocol. It is explicitly designed as an agent-first tool: the primary user is another agent or orchestrator, not a human.

Core Value Proposition

Before acpx: orchestrators had to spawn a PTY (pseudo-terminal), scrape ANSI escape codes, parse unstructured text output, and hope the agent's terminal session didn't die mid-task. After acpx: one CLI that speaks ACP, manages persistent multi-turn sessions, queues prompts safely, handles lifecycle (crash reconnect, cooperative cancel), and returns structured typed output (thinking, tool calls, diffs) — for 17 coding agents.

Key Primitives

  • Persistent sessions: multi-turn conversations scoped per repo/cwd, survive across invocations
  • Named sessions: run parallel workstreams in the same repo (-s backend, -s frontend)
  • Prompt queueing: submit while a turn is in-flight; executes in order
  • fire-and-forget: --no-wait queues without waiting
  • exec mode: one-shot stateless execution (acpx codex exec "summarize repo")
  • Flows: acpx flow run <file> — TypeScript workflow modules over multiple ACP turns, with acp/action/compute/checkpoint node types and decision/decisionEdge for branching
  • Permission policy: approve-all, approve-reads, deny-all modes; JSON policy with autoApprove/autoDeny/escalate/defaultAction
  • Structured output: text, json, quiet formats; --suppress-reads to hide file body dumps
  • 17 built-in agents: pi, openclaw, codex, claude, gemini, cursor, copilot, droid, iflow, kilocode, kimi, kiro, opencode, qoder, qwen, trae + raw --agent escape hatch

Status

Alpha. API/CLI interfaces subject to change. ACP spec coverage tracked in docs/2026-02-19-acp-coverage-roadmap.md. Session state in ~/.acpx/.

01

Overview

acpx — Overview

Origin

Published as acpx on npm by openclaw. TypeScript/Node.js. MIT license. 2759 stars, 271 forks. Homepage: https://acpx.sh. In alpha; API subject to change.

Philosophy

"Your agents love acpx. They hate having to scrape characters from a PTY session."

acpx's thesis: the status quo for agent-to-agent communication is PTY scraping — spawning a terminal session and parsing ANSI escape codes to figure out what the agent said. This is fragile, unstructured, and breaks across agent versions. The Agent Client Protocol (ACP) solves this with a structured protocol; acpx is the reference headless CLI client for ACP.

From VISION.md:

"acpx should be the smallest useful ACP client: a lightweight CLI that lets one agent talk to another agent through the Agent Client Protocol without PTY scraping or adapter-specific glue." "The goal is not to build a giant orchestration layer. The goal is to make ACP practical, robust, and easy to compose in real workflows."

Design Goals

  1. Interoperability first: maximize compatibility across ACP adapters and agent harnesses
  2. Keep the core small: stay focused on ACP client concerns; avoid feature bloat
  3. Robust by default: session continuity, safe queueing, clear failure modes, machine-readable output
  4. Conventions are API surface: data models, config keys, output shapes, naming — all scrutinized before adding; convenience alone is not enough

What ACP Is

The Agent Client Protocol (ACP) is a structured JSON protocol for agent-to-agent communication over stdio/IPC. It replaces PTY scraping with typed messages: session/start, session/cancel, session/set_mode, session/set_config_option, permission requests (tool/request_permission), and structured responses (thinking, tool calls, diffs). acpx wraps this protocol in a human/machine-usable CLI.

Agent Registry

acpx ships with 17 built-in agent adapters:

Name Command
pi npx pi-acp
openclaw openclaw acp
codex npx -y @agentclientprotocol/codex-acp
claude npx -y @agentclientprotocol/claude-agent-acp
gemini gemini --acp
cursor cursor-agent acp
copilot copilot --acp --stdio
droid droid exec --output-format acp
iflow iflow --experimental-acp
kilocode npx -y @kilocode/cli acp
kimi kimi acp
kiro kiro-cli-chat acp
opencode npx -y opencode-ai acp
qoder qodercli --acp
qwen qwen --acp
trae traecli acp serve

Any unlisted agent is passed through as a raw command via --agent '<command>'.

Target Users

acpx is explicitly designed for agent-to-agent use: the primary user is an orchestrator, CI pipeline, or another AI agent. Humans can drive it directly, but human usability is a secondary constraint. The README includes an "install acpx in your agent" paste block specifically so an agent can set itself up to use acpx for all future coding-agent delegation.

02

Architecture

acpx — Architecture

Distribution

npm: npm install -g acpx Runtime: Node.js ≥ 22.13.0 Package manager: pnpm 10.33.2 (for development) Binary: acpx

Source Structure

src/
├── cli.ts                    # Entry point
├── cli-core.ts               # Core CLI logic
├── cli-public.ts             # Public CLI surface
├── cli/                      # CLI command implementations
├── acp/                      # ACP protocol layer
├── agent-registry.ts         # Built-in agent → command mappings
├── async-control.ts          # Queue and async management
├── errors.ts                 # Error types
├── filesystem.ts             # Stable fs/* client methods
├── flows.ts                  # Flow orchestration
├── flows/                    # Flow authoring API
│   ├── authoring.ts          # defineFlow, decision, decisionEdge, acp, action, compute, checkpoint
│   ├── cli.ts                # flow run CLI command
│   ├── decision.ts           # decision/decisionEdge branching
│   ├── definition.ts         # flow definition types
│   ├── executors/            # step type executors
│   ├── graph.ts              # DAG graph
│   ├── runtime.ts            # flow runtime
│   └── store.ts              # run state persistence
├── mcp-servers.ts            # MCP server integration
├── perf-metrics.ts           # Performance metrics capture
├── permission-policy.ts      # JSON permission policy parsing
├── permission-prompt.ts      # Interactive permission prompts
├── permissions.ts            # Permission engine
├── persisted-key-policy.ts   # Persistent allow/deny decisions
├── process-liveness.ts       # Agent process health checks
├── prompt-content.ts         # Prompt input handling (text/file/stdin)
├── runtime.ts                # Main runtime
├── runtime/                  # Runtime components
├── session/                  # Session management
│   ├── persistence/          # Session storage
│   │   ├── repository.ts     # Session CRUD, pruning, git-root discovery
│   │   ├── serialize.ts      # Disk serialization
│   │   └── parse.ts          # Disk deserialization
│   ├── session.ts            # Session state machine
│   ├── event-log.ts          # Event log for session history
│   ├── export.ts             # Session export to archive
│   ├── import.ts             # Session import from archive
│   └── ...
├── spawn-command-options.ts  # Agent process spawn options
├── types.ts                  # Core type definitions
└── version.ts                # Version constants

Session Storage

Session state is stored under ~/.acpx/. Sessions are scoped to a git repository root (discovered via findGitRepositoryRoot) or the cwd if no git root is found.

~/.acpx/
├── config.json               # Global config
└── sessions/
    └── <agent>/
        └── <repo-hash>/
            ├── default/      # Default session for this repo
            │   ├── session.json
            │   └── history/
            └── <name>/       # Named session (-s <name>)
                ├── session.json
                └── history/

IPC for Prompt Queueing

When a session is already running (agent turn in progress), acpx uses IPC (Unix socket / named pipe) to queue the new prompt. The queue owner process receives it and executes it after the current turn completes. --no-wait enqueues and returns immediately (exit 0) without waiting for completion.

Flow Run Storage

~/.acpx/flows/runs/
└── <run-id>/
    ├── state.json            # Current run state
    └── checkpoints/          # Checkpoint snapshots

Permission Model

Three permission modes (set via CLI flag or config):

Mode Behavior
--approve-reads Auto-approve fs/read* requests; prompt for others (default)
--approve-all Auto-approve all tool requests
--deny-all Auto-deny all tool requests (review/planning workflows)

JSON policy --policy '<json>' provides fine-grained control:

{
  "autoApprove": ["fs/read*", "terminal/run_command:npm test"],
  "autoDeny": ["fs/delete*"],
  "escalate": ["terminal/run_command"],
  "defaultAction": "deny"
}

Output Formats

Format Behavior
text Human-readable streaming output (default)
json Structured JSON per ACP message type
quiet Final answer only, no intermediate output

--suppress-reads hides file body content in tool outputs while still showing the tool call itself.

Exit Codes

Code Meaning
0 Success
1 Error
2 Usage error
3 Timeout
4 No session
5 Permission denied
130 Interrupted (Ctrl+C)

These stable exit codes allow orchestrators to branch on failure types.

03

Components

acpx — Components

CLI Command Surface

acpx [global_options] [agent] [verb] [options] [prompt_text...]

Verbs:

Verb Purpose
prompt (default) Submit a multi-turn prompt to a session
exec One-shot stateless execution (no saved session)
cancel Cooperative cancel of in-flight turn
set-mode <mode> Send session/set_mode to agent
set <key> <value> Send session/set_config_option to agent
status Show local process status (running/idle/dead/no-session), pid, uptime, last prompt
sessions Session management (see below)
config Config file management
flow run <file> Execute a TypeScript flow module

Session subcommands:

Subcommand Purpose
sessions list List sessions for this agent
sessions new [--name <name>] Create fresh session
sessions ensure [--name <name>] Return existing or create new
sessions close [name] Close without deleting history
sessions show [name] Inspect session metadata
sessions history [name] [--limit N] Show recent turn history
sessions export [name] --output <path> Export portable archive
sessions import <archive> [--name <name>] Import session archive
sessions prune [--dry-run] [--before <date> | --older-than <days>] Delete old sessions

Global Options

Option Purpose
-s / --session <name> Target named session
--cwd <path> Override working directory
--approve-all Auto-approve all permissions
--approve-reads Auto-approve read permissions (default)
--deny-all Deny all permissions
--policy '<json>' Fine-grained permission policy
--no-wait Enqueue and return immediately
--ttl <seconds> Queue owner keep-alive TTL
`--format text json
--json-strict Machine-safe JSON only (for automation)
--suppress-reads Hide file bodies in output
--timeout <seconds> Turn timeout
--max-turns <n> Maximum LLM turns
--prompt-retries <n> Retry on transient failures
--system-prompt <text> Override Claude system prompt
--append-system-prompt <text> Append to Claude system prompt
--no-terminal Disable terminal capabilities (review-only)
--allowed-tools <list> Tool whitelist
`--non-interactive-permissions deny fail`
--verbose Debug output
--agent '<command>' Raw agent command (escape hatch)
--file <path> Read prompt from file
--default-agent <name> Default agent for flows

Flows API

TypeScript flow authoring via acpx/flows:

Function Purpose
defineFlow(steps) Declare a flow graph
acp(options) Node: routes to ACP agent turn
action(fn) Node: shell command or deterministic logic
compute(fn) Node: local routing/shaping (no agent)
checkpoint(fn) Node: pause for external dependency
decision(options) Branch: ACP-powered yes/no branching
decisionEdge(options) Branch: constrained edge between nodes

Flow runs persist under ~/.acpx/flows/runs/. Flow inputs via --input-json or --input-file.

Skills Integration

skills/
└── acpx/
    └── SKILL.md    # Self-describing SKILL.md for agent consumption

The skill SKILL.md describes every command, flag, and workflow pattern. It is the primary reference for agents consuming acpx. Installation:

npx acpx --skill install acpx --agent codex --scope user
npx acpx --skill install acpx --agent claude --scope user

.agents/ Directory

agents/
├── README.md        # Lists all 17 built-in agents with commands
├── Claude.md        # Claude-specific notes
├── Codex.md         # Codex-specific notes
├── Copilot.md       # Copilot-specific notes
├── Cursor.md        # Cursor-specific notes
├── Droid.md         # Droid-specific notes (factory-droid alias)
├── Gemini.md        # Gemini-specific notes
├── Iflow.md         # iFlow-specific notes
├── Kilocode.md      # Kilocode-specific notes
├── Kimi.md          # Kimi-specific notes
├── Kiro.md          # Kiro-specific notes
├── OpenCode.md      # OpenCode-specific notes
├── Qoder.md         # Qoder-specific notes
├── Qwen.md          # Qwen-specific notes
└── Trae.md          # Trae-specific notes

Config Files

Two-level config merge (later wins):

Level Path
Global ~/.acpx/config.json
Project <cwd>/.acpxrc.json

CLI flags always win over config values. acpx config show shows the resolved merge. acpx config init creates a ~/.acpx/config.json template.

conformance/ Directory

conformance/          # ACP spec conformance tests

Tests that validate acpx against the ACP specification. Coverage tracked in docs/2026-02-19-acp-coverage-roadmap.md.

examples/flows/ Directory

examples/flows/
├── README.md
├── echo/             # Minimal echo flow
├── branch/           # Branching example
├── shell/            # Shell action example
├── workdir/          # Working directory isolation
├── two-turn/         # Multi-turn example
├── pr-triage/        # PR triage (acp → GitHub → acp)
└── replay-viewer/    # Browser-based run inspector
05

Prompts

acpx — Prompts

Self-Describing SKILL.md

acpx ships a SKILL.md that tells agents how to use it. This is the primary "prompt" in the acpx ecosystem — it is loaded by the agent using acpx, not by acpx itself.

---
name: acpx
description: Use acpx as a headless ACP CLI for agent-to-agent communication,
  including prompt/exec/sessions workflows, session scoping, queueing,
  permissions, output formats, system-prompt overrides, and multi-agent
  flows authored with defineFlow/decision/decisionEdge.
---

# acpx

## When to use this skill

Use this skill when you need to run coding agents through `acpx`, manage
persistent ACP sessions, queue prompts, override the Claude system prompt,
prune stale sessions, consume structured agent output from scripts, or
compose multi-agent workflows declaratively with `acpx/flows`.

Technique: The SKILL.md front matter includes a rich description field that lists every major capability in plain language. This is a dense capability summary prompt — an agent reading it knows exactly when to invoke acpx without reading the full file.

System Prompt Override

acpx can inject a system prompt into the underlying agent:

# Replace system prompt
acpx --system-prompt "You are a security auditor. Focus only on vulnerabilities." \
    codex "review auth.ts"

# Append to existing system prompt
acpx --append-system-prompt "Always respond in JSON format." \
    codex "analyze the codebase"

Technique: This is meta-prompting — an orchestrating agent uses acpx to reconfigure the sub-agent's identity for a specific task, then restores it after. The --append-system-prompt variant preserves the sub-agent's base identity while layering task-specific instructions.

Quick Setup Paste Block (README)

The README includes a paste block specifically designed to be inserted into another agent's prompt:

I want you to use acpx to run coding agents over the Agent Client Protocol
(ACP) instead of scraping PTY sessions. Please do the following:

1. Install acpx globally:
   npm install -g acpx@latest

2. Install the acpx skill:
   npx acpx@latest --skill install acpx --agent codex --scope user

3. Read the acpx skill reference:
   https://raw.githubusercontent.com/openclaw/acpx/main/skills/acpx/SKILL.md

From now on, when you need to delegate work to a coding agent, use acpx
instead of spawning raw terminal sessions.

Technique: Bootstrap prompt — the human operator pastes this into their agent session once, and the agent installs acpx and learns to use it for all future sub-agent delegation. The agent learns the tool through a URL-fetched skill file rather than through the operator's explanation.

AGENTS.md (Contributor Orientation)

# AGENTS.md — acpx

## Purpose

This file is for contributors and coding agents working in this repository.

## Product Direction

- `acpx` should be the smallest useful ACP client
- The primary user is another agent, orchestrator, or harness
- Data models, config keys, keywords, flags, output shapes, and naming
  conventions are part of the product surface
- The default stance should be to add fewer conventions, make them clearer,
  and keep them stable
- Read `VISION.md` before changing user-visible behavior or conventions

Technique: The AGENTS.md explicitly orients contributor agents toward VISION.md as the authoritative source before making any user-visible changes. This creates a two-level governance prompt: AGENTS.md is the entry point, VISION.md is the decision authority.

Flow Node Prompts

In flow files, each acp node carries its own prompt:

export default defineFlow({
  review: acp({ prompt: "Review the PR for regressions" }),
  assess: decision({ prompt: "Are there critical issues blocking merge?" }),
  fix: acp({ prompt: "Fix the critical issues identified in review" }),
});

Technique: Inline prompt per step — each LLM call in a flow has a purpose-specific prompt. The decision() node prompt is especially constrained: it must elicit a binary yes/no answer to route the flow. This is a slot-specific prompting pattern where prompt design is part of the flow definition.

09

Uniqueness

acpx — Uniqueness

Differentiator

acpx is the only framework in this corpus whose explicit, primary design goal is to be used by another agent — not by a human. It is an ACP protocol client first, a human CLI second. No other framework positions the agent-as-user this prominently or designs its API surface around it this consistently.

Differs from Seeds

Against the five seed archetypes and 11 seed frameworks:

vs. Skills-only behavioral (superpowers, spec-kit): Seeds add skills to help a single agent do more. acpx enables an agent to delegate to a completely different coding agent (Codex, Claude Code, Cursor, etc.) via a structured protocol. The orchestration is horizontal (agent → different agent), not vertical (agent → more capable self).

vs. Mirror commands+skills (claude-conductor, claude-flow, openspec): claude-conductor and claude-flow coordinate multiple Claude Code instances. acpx is protocol-level — it works with 17 different agents across 8 different vendors (OpenAI, Anthropic, GitHub, Google, etc.) and any agent that speaks ACP. It is not Claude-specific.

vs. MCP-anchored toolserver (spec-driver, ccmemory): Seeds add tools (MCP servers) to an agent. acpx wraps entire agents as addressable services. The level of abstraction is one layer higher: instead of adding a tool, you add an agent.

vs. Markdown scaffold (BMAD-METHOD, taskmaster-ai, agent-os, kiro): These define behavior through markdown files. acpx defines behavior through TypeScript flow modules and session state. The execution model is runtime (ACP protocol messages) not configuration (markdown instructions).

vs. Closed IDE with proprietary primitives (kiro): acpx explicitly supports Kiro as one of 17 agents (kiro -> kiro-cli-chat acp). Like OpenGAP, acpx treats Kiro as a target, not a platform.

ACP as Standard Protocol

No seed framework implements ACP (Agent Client Protocol). The 11 seeds use MCP (tools), git (state), or markdown (behavior). acpx introduces ACP as a third category: structured agent-to-agent communication protocol. This is neither a tool protocol (MCP) nor a state protocol (git) — it is an interaction protocol between running agent processes.

Prompt Queueing at Protocol Level

acpx's IPC-based prompt queue is unique in the corpus. Other frameworks either:

  • Block until the agent is free (synchronous)
  • Spawn parallel agents for concurrent work

acpx allows true prompt queueing: submit-and-forget to a busy agent, with guaranteed in-order execution. No polling loop, no separate job queue infrastructure. This is a novel primitive for agent orchestration.

17-Agent Registry

acpx ships with registered adapters for 17 coding agents spanning 8+ vendors. No other framework in the corpus (batch or seeds) maintains a cross-vendor agent adapter registry. The closest analog is OpenGAP's 12 export adapters, but those are for framework format conversion, not live agent protocol routing.

System Prompt Override for Sub-Agent Role Assignment

--system-prompt and --append-system-prompt allow the orchestrating agent to reconfigure the sub-agent's identity dynamically, without defining separate agents. This "dynamic role assignment" pattern has no equivalent in any seed framework:

# Same codex agent, temporarily reassigned as security auditor
acpx --system-prompt "You are a security auditor..." codex exec "audit auth"

Structured Exit Codes

acpx's 7-code exit code taxonomy (0=success, 1=error, 2=usage, 3=timeout, 4=no-session, 5=permission-denied, 130=interrupted) is designed for orchestrator use. No seed framework defines machine-readable exit codes for agent interactions. This enables branch-on-failure in shell pipelines and CI workflows without parsing output.

What It Does Not Do

  • No agent identity or behavior definition (no SOUL.md equivalent)
  • No LLM gateway or request routing
  • No compliance or SOD enforcement
  • No built-in tools (MCP servers)
  • No cost tracking or optimization
  • No web UI
  • No prompt injection defenses (delegates to underlying agent)

acpx is infrastructure for agent-to-agent communication, not a framework for defining agent behavior. It is the "glue layer" between agents, not the agents themselves.

04

Workflow

acpx — Workflow

Basic Session Workflow

# 1. Create a session for this repo
acpx codex sessions new

# 2. Submit prompts (implicit session, routed by cwd)
acpx codex "find the flaky test and fix it"

# 3. Follow up in the same session
acpx codex "add a regression test for the case you fixed"

# 4. Check session status
acpx codex status

# 5. Close when done
acpx codex sessions close

Sessions are scoped to the git repository root — any subdirectory of the same repo finds the same session.

Named Parallel Sessions

# Two workstreams in the same repo simultaneously
acpx codex sessions new --name api
acpx codex sessions new --name docs

acpx codex -s api "implement token pagination"
acpx codex -s docs "rewrite API docs"

# Check status of each
acpx codex -s api status
acpx codex -s docs status

Fire-and-Forget Workflow

# Queue a prompt and return immediately (doesn't wait for completion)
acpx codex --no-wait "draft test migration plan"

# Later: check if it finished
acpx codex status

# Queue multiple prompts while one runs — they execute in order
acpx codex "implement auth"
acpx codex --no-wait "add auth tests"
acpx codex --no-wait "update auth docs"

Automated Orchestration Workflow

# Agent orchestrates another agent — machine-readable JSON output
acpx --format json codex exec "review changed files" > review.json

# Process result programmatically
# Exit code 0 = success, 1 = error, 3 = timeout, 5 = permission denied
if [ $? -eq 0 ]; then
    acpx --format json codex "apply the recommended fixes"
fi

Permission-Gated Workflow

# Review-only: no tool execution
acpx --deny-all codex "what would you change in auth.ts?"

# Approve all tools (CI/automated)
acpx --approve-all codex "apply the patch and run tests"

# Fine-grained policy
acpx --policy '{"autoApprove":["fs/read*"],"autoDeny":["fs/delete*"],"escalate":["terminal/run_command"],"defaultAction":"deny"}' \
    codex "audit the codebase"

Session Export/Import Workflow

# Export session (with history) for portability
acpx codex sessions export api --output ./api-session.tar.gz

# Import on another machine
acpx codex sessions import ./api-session.tar.gz --name api --cwd ~/repos/shop

Flow Workflow

# Author a flow in TypeScript
cat > pr-review.flow.ts << 'EOF'
import { defineFlow, acp, action, decision } from "acpx/flows";

export default defineFlow({
  start: acp({ prompt: "Review the PR and identify issues" }),
  assess: decision({ prompt: "Are there critical issues?" }),
  fix: acp({ prompt: "Fix the critical issues", depends_on: "assess.yes" }),
  approve: action({ fn: "gh pr review --approve", depends_on: "assess.no" }),
  verify: acp({ prompt: "Verify the fixes", depends_on: "fix" }),
});
EOF

# Run with input
acpx flow run pr-review.flow.ts --input-json '{"pr": 150}'

# Run with timeout
acpx --timeout 1800 flow run pr-review.flow.ts

CI/CD Workflow

# .github/workflows/agent-review.yml
- name: Run agent code review
  run: |
    npm install -g acpx
    acpx --format json --approve-all codex exec \
      "Review the changed files and report issues" \
      > review-output.json
    
- name: Check for critical issues
  run: |
    cat review-output.json | jq '.critical_issues | length'

Session Maintenance Workflow

# Prune sessions older than 30 days (dry run first)
acpx codex sessions prune --dry-run --older-than 30

# Actually prune (with history cleanup)
acpx codex sessions prune --older-than 30 --include-history

# Prune all agents
acpx sessions prune --before 2026-01-01

Crash Recovery

acpx automatically detects dead agent processes via process-liveness.ts:

  1. On next prompt submission, checks if the agent process is alive
  2. If dead: attempts to resume the existing session, or creates a new one
  3. No manual intervention required — the queue and session state persist in ~/.acpx/
06

Memory Context

acpx — Memory & Context

Session Persistence Model

acpx's memory is the ACP session. Sessions are persisted to disk under ~/.acpx/ and survive across invocations, process restarts, and crashes. This is the core innovation over raw PTY sessions, which die when the terminal closes.

~/.acpx/
├── config.json                 # Global configuration
└── sessions/
    └── <agent>/                # One directory per agent type
        └── <repo-hash>/        # Keyed to git repository root
            ├── default/        # Default (unnamed) session
            │   ├── session.json       # Session metadata and state
            │   └── history/           # Turn-by-turn history
            └── <name>/         # Named session (-s <name>)
                ├── session.json
                └── history/

Session Scoping

Sessions are scoped to the git repository root, not a specific directory. findGitRepositoryRoot walks up the directory tree from cwd to find the .git directory. This means:

  • Any subdirectory of ~/repos/myapp finds the same session as ~/repos/myapp itself
  • No session bleeding between different repositories
  • Explicit --cwd override for cross-repo orchestration

Session History

session.json stores metadata: session ID, agent, mode, active/idle/dead status, pid, last activity timestamp, last prompt.

history/ stores the turn-by-turn event log (turn-N.json). Each turn record contains:

  • Prompt text
  • ACP messages received (thinking blocks, tool calls, diffs, text)
  • Tool outcomes
  • Stop reason
  • Timestamps

acpx sessions history --limit 10 returns the most recent turns. This history is the primary context for multi-turn conversations — the underlying agent uses it for conversation continuity.

Cross-Session Portability

Sessions can be exported and imported as archives:

acpx codex sessions export api --output ./api-session.tar.gz
acpx codex sessions import ./api-session.tar.gz --name api --cwd ~/repos/shop

The archive includes session metadata and history. This enables sharing session context between machines or between team members.

Session Pruning

acpx sessions prune --older-than 30          # Remove sessions older than 30 days
acpx sessions prune --before 2026-01-01      # Remove sessions before a date
acpx sessions prune --include-history        # Also delete history files
acpx sessions prune --dry-run                # Preview what would be pruned

Flow Run State

~/.acpx/flows/runs/
└── <run-id>/
    ├── state.json              # Current flow node, outputs, status
    └── checkpoints/
        └── <checkpoint-id>/   # Checkpoint snapshot for resume

Flow runs persist state so they can be resumed after interruption. The checkpoint node type explicitly pauses the flow pending an external signal.

Config Persistence

~/.acpx/config.json             # Global config
<cwd>/.acpxrc.json              # Project config

Two-level merge: project config wins over global. Typical config keys:

  • defaultAgent — default agent when no agent name is given
  • format — default output format
  • permissionMode — default permission mode
  • sessionResumePolicyallow-new (default) or same-session-only

No Context Window Management

acpx does not manage context windows — that is the responsibility of the underlying ACP agent. acpx passes prompts through to the agent and receives structured responses. The agent's own context management (compaction, summarization, etc.) is transparent to acpx.

For very long sessions, acpx sessions close + sessions new gives a fresh context window while preserving history on disk for reference via sessions history.

Persisted Permission Decisions

persisted-key-policy.ts stores allow_always and reject_always decisions:

  • Per-tool permission choices persist to ~/.acpx/ for reuse across sessions
  • A tool once whitelisted stays whitelisted until explicitly revoked
  • --approve-all / --deny-all modes bypass persisted decisions
07

Orchestration

acpx — Orchestration

Prompt Queueing

The core orchestration primitive is the prompt queue. When an agent session is busy (turn in-flight), new prompts submitted via acpx are queued via IPC rather than rejected. The queue owner process dequeues and executes them in order.

acpx codex "implement auth"          # starts turn, blocks
acpx codex --no-wait "add tests"     # queued immediately, returns exit 0
acpx codex --no-wait "update docs"   # also queued
# auth → tests → docs execute in sequence, no polling needed

This is cooperative scheduling: the caller decides whether to wait or fire-and-forget.

Multi-Agent via Named Sessions

Named sessions (-s) provide multi-agent coordination without a separate orchestration layer:

# Parent orchestrator (e.g., another agent) dispatches parallel work
acpx codex -s api "implement token pagination"
acpx codex -s frontend "build pagination UI component"
acpx codex -s tests "write pagination integration tests"

# All three run in parallel; orchestrator waits for all
wait
acpx codex "review the three parallel implementations and reconcile"

No explicit "multi-agent framework" required — multiple named sessions on the same or different agents provide the parallelism.

Flows: Declarative Multi-Step Orchestration

acpx flow run executes TypeScript flow modules. The flow runtime handles step sequencing, output passing, and state persistence.

Node types:

Node Purpose
acp Routes to ACP agent turn (model-shaped work)
action Shell command or deterministic logic outside the agent
compute Local routing, JSON shaping, no agent
checkpoint Pause pending external signal (human approval, webhook)
decision ACP-powered binary branch
decisionEdge Constrained edge between nodes

Flow execution engine:

  1. Load TypeScript flow module
  2. Resolve node graph from defineFlow({}) return value
  3. Execute nodes in topological order (DAG)
  4. Persist state to ~/.acpx/flows/runs/<id>/
  5. acp nodes use active session (or create one per flow step with --default-agent)
  6. action nodes run shell in the flow's working directory
  7. checkpoint nodes write state and pause; resume when triggered

Flow Workspace Isolation

acp({ 
  prompt: "Implement the feature", 
  cwd: "/tmp/feature-worktree"   // isolated worktree
})

acp nodes can target a specific cwd, isolating agent work to a disposable git worktree. This prevents parallel flow steps from stomping on each other's file changes.

Cross-Agent Orchestration

acpx's --agent escape hatch enables routing to any ACP-compatible agent, including custom internal tools:

acpx --agent './bin/dev-acp --profile ci' "run checks"
acpx --agent 'my-company-internal-agent' "review security controls"

Combined with flow run, this supports heterogeneous agent pipelines where different steps use different underlying models or tools.

System Prompt Override for Task-Specific Roles

An orchestrating agent can reconfigure a sub-agent's identity per task:

# Turn codex into a security auditor for this task
acpx --system-prompt "You are a security auditor. Report vulnerabilities only." \
    codex exec "audit authentication flows"

# Turn it into a doc writer
acpx --system-prompt "You are a technical writer. Produce clear markdown docs." \
    codex exec "document the API"

This is dynamic role assignment without separate agent definitions.

ACP Protocol Operations

acpx exposes all ACP protocol control operations:

Operation Command
session/cancel acpx codex cancel
session/set_mode acpx codex set-mode auto
session/set_config_option acpx codex set model 'gpt-5.2[high]'
tool/request_permission Permission prompt to operator
authenticate Credential handshake via env/config

These map 1:1 to ACP protocol methods, giving orchestrators precise control over sub-agent state.

Crash Recovery

process-liveness.ts monitors the agent process:

  1. Before each turn, checks if the agent PID is alive
  2. If dead: session state is preserved in ~/.acpx/
  3. Automatically attempts to resume (restart the agent, reconnect to session)
  4. If resume fails: creates a new session (with history intact for context)
  5. All transparent to the orchestrator — no manual intervention

no-terminal Mode

acpx --no-terminal codex "review the PR"

Disables terminal capabilities, restricting the sub-agent to read-only file access. Useful for orchestrations where the agent should analyze but not modify.

08

Ui Cli Surface

acpx — UI & CLI Surface

CLI Binary

Package: npm install -g acpx Binary: acpx Runtime: Node.js ≥ 22.13.0

No web UI or dashboard. All interaction is through the CLI or programmatic use via the acpx/flows API.

Command Syntax

acpx [global_options] [agent] [verb] [options] [prompt_text...]

Minimum working example:

acpx codex "fix the failing tests"

Output Modes

acpx outputs structured ACP message types:

[thinking] Investigating test suite for flaky failures

[tool] Run npm test -- --reporter=verbose (running)
[tool] Run npm test -- --reporter=verbose (completed)
  output:
    ✓ auth.login (0.8s)
    ✗ checkout.submit (timed out after 5000ms)

[thinking] Found it — checkout.submit has a race condition

[tool] Edit src/checkout.test.ts (completed)

Fixed: added `await` to the setup hook.

[done] end_turn

JSON format (--format json): each ACP message type as a separate JSON object on stdout. For machine consumption.

Quiet format (--format quiet): final answer only, no intermediate output. For minimal automated pipelines.

--suppress-reads: show tool invocations but hide file body content (reduces noise for read-heavy tasks).

Status Display

$ acpx codex status

Session: default (backend-api)
Status: idle
PID: 12847
Uptime: 4h 23m
Last prompt: "implement token pagination" (12m ago)

Sessions List

$ acpx codex sessions list

AGENT  SESSION   STATUS  LAST ACTIVITY
codex  default   idle    12m ago
codex  api       idle    1h ago
codex  frontend  dead    3d ago

Dead sessions (process died) are shown with dead status. They retain history and can be cleaned up with sessions prune.

History Display

$ acpx codex sessions history --limit 5

[2026-05-25 14:30] "implement token pagination"
  → 3 tool calls, 127 tokens, end_turn

[2026-05-25 15:12] "add integration tests for pagination"
  → 5 tool calls, 243 tokens, end_turn

[2026-05-25 16:45] "review the pagination PR"
  → 1 tool call, 89 tokens, end_turn

Config Display

$ acpx config show

{
  "defaultAgent": "codex",
  "format": "text",
  "permissionMode": "approve-reads",
  "sessionResumePolicy": "allow-new"
}
(global: ~/.acpx/config.json)
(project: .acpxrc.json not found)

Skill Installation Surface

# Install acpx skill for a specific agent
npx acpx --skill install acpx --agent codex --scope user
npx acpx --skill install acpx --agent claude --scope user

# Or reference directly via URL (for unsupported harnesses)
https://raw.githubusercontent.com/openclaw/acpx/main/skills/acpx/SKILL.md

The --skill install command places skills/acpx/SKILL.md in the appropriate location for the target agent harness.

Non-Interactive Mode

# In CI pipelines — fail fast if permissions can't be resolved
acpx --non-interactive-permissions fail codex exec "run checks"

# Or silently deny
acpx --non-interactive-permissions deny codex exec "describe the codebase"

--non-interactive-permissions controls behavior when there is no TTY to prompt for permission. fail exits with code 5; deny silently rejects the tool call.

stdin / File Input

# Prompt from stdin
echo "fix the failing test" | acpx codex

# Prompt from file
acpx codex --file prompt.md

# Explicit stdin + appended args
acpx codex --file - "additional context here"

Enables integration with shell pipelines and templated prompt files.

Related frameworks

same archetype · same primary tool · same memory type

BMAD-METHOD ★ 48k

Provides a full agile delivery lifecycle with named expert-persona AI collaborators that elicit the human's best thinking rather…

Agent OS ★ 4.6k

Extracts implicit codebase conventions into token-efficient markdown standards files and injects them selectively into AI agent…

Claude Conductor ★ 367

Gives Claude Code a persistent, cross-linked, auto-analyzed documentation system so it retains codebase context across sessions.

Spec-Driver (Greenfield Spec-Driven Development) ★ 25

Prevents spec rot in AI-assisted development by making implementation changes flow back into evergreen, authoritative specs via…

Anthropic Knowledge Work Plugins ★ 16k

Role-specialized plugin bundles with live MCP connectors that turn Claude into a domain expert for enterprise knowledge workers.

Codex Integration for Claude Code (skill-codex) ★ 1.3k

Single Claude Code skill that handles Codex CLI invocation correctly (stdin blocking, thinking token suppression, session resume)…