Download the PHP package tinywan/harness without Composer
On this page you can find all versions of the php package tinywan/harness. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tinywan/harness
More information about tinywan/harness
Files in tinywan/harness
Package harness
Short Description A PHP library for driving AI coding CLIs (Claude Code, Codex, GitHub Copilot CLI, OpenCode) in headless mode.
License MIT
Informations about the package harness
Harness (PHP Version)
English | 简体中文
harness is an orchestration engine library designed for PHP 8.4+, built to unify the execution, scheduling, and monitoring of major AI coding command-line interfaces (AI Coding CLIs) in Headless / Unattended Mode.
Through a unified PHP object-oriented interface, it abstracts away all discrepancies across Claude Code, OpenAI Codex CLI, GitHub Copilot CLI, and OpenCode in command-line arguments, rule files, streaming output, Token billing, and skill distribution.
🧐 Why Harness? (Core Problems Solved)
When automatically scheduling AI coding agents in automated pipelines, background task queues, CI/CD, or sandbox containers, developers typically face the following challenges:
- Heterogeneous CLI arguments and execution modes:
- Claude Code requires
-p --output-format stream-json --permission-mode bypassPermissions - OpenAI Codex requires
exec --json --sandbox danger-full-access - GitHub Copilot CLI requires
-p --output-format json --autopilot --allow-all - OpenCode requires
run --format json --auto
- Claude Code requires
- Inconsistent rules and instruction delivery standards:
- Claude uses
--system-promptorCLAUDE.md; - Codex and OpenCode rely on
AGENTS.mdat the workspace root; - Copilot relies on
.github/copilot-instructions.md.
- Claude uses
- Chaotic output stream formats that are difficult to standardize:
- Disparate stdout/stderr and JSONL event structures across tools make it hard to uniformly capture thinking processes (
Thinking), tool calls (Tool Use), and final results.
- Disparate stdout/stderr and JSONL event structures across tools make it hard to uniformly capture thinking processes (
- Inconsistent Token consumption and cost accounting standards:
- Some CLIs output only token counts, while others output credit billing points, lacking a unified USD cost calculation model.
- Divergent Agent Skills discovery and staging paths:
- Different skill discovery paths (
.claude/skills/,skills/,.github/skills/,.opencode/skill/).
- Different skill discovery paths (
harness standardizes and encapsulates all these underlying details, providing a consistent, reliable PHP API.
🚀 Supported Backend CLIs
Backend (name) |
Binary CLI | Default Model Example | Skill Discovery Path | Project Instruction File | Egress Allowed Hosts |
|---|---|---|---|---|---|
claude |
claude |
claude-opus-4-6, claude-sonnet-4-6 |
.claude/skills/<name> |
CLAUDE.md |
*.anthropic.com |
codex |
codex |
gpt-5.3-codex, deepseek-v4-pro |
skills/<name> |
AGENTS.md |
api.openai.com, auth0.openai.com, chatgpt.com |
copilot |
copilot |
gpt-5.6-sol, claude-sonnet-5 |
.github/skills/<name> |
.github/copilot-instructions.md |
github.com, api.github.com, *.githubcopilot.com |
opencode |
opencode |
anthropic/claude-sonnet-4-6 |
.opencode/skill/<name> |
AGENTS.md |
models.dev, api.openai.com, *.anthropic.com |
🧩 Key Features & Capabilities
- 🎯 Unified Driver Facade: Schedule any backend using a single
Jobentity andRunner::run()method, with support for custom models, thinking turns, reasoning effort, and more. - ⚡ Standardized Event Stream:
EventKind::Thinking: AI deep thinking and reasoning processEventKind::Tool: Tool and command invocation (e.g.bash,read,write,grep, etc.)EventKind::Text: Regular text response from the modelEventKind::Result: Final settlement (including total costcostUSD,turns, and token usage breakdownusage)EventKind::Session: Initial session ID (for breakpoint resumption)EventKind::RateLimit: Rate limit/quota status and reset timestamp (ResetsAt)EventKind::Error: Exceptions and error messages
- 💰 Unified Billing & Cost Accounting: Built-in pricing tables for major models (Anthropic, OpenAI, Copilot Hosted), automatically converting token metrics and Copilot nano-AIU into standardized USD costs.
- 🔄 Session Resumption (Resume): Automatically extracts Session IDs, supporting context continuation after interruptions or error corrections.
- 📦 Agent Skills Specification Support: Fully compatible with the Agent Skills Specification, providing
SKILL.mdYAML frontmatter parsing, parameter validation, and automated staging. - 🛡️ Account Rate Limit & Quota Awareness: Automatically detects provider 429s, quota exhaustion, permission revocations, etc., and throws an
AccountErrorcontaining the reset timestamp for retry scheduling. - 🔒 Security Sandbox & Domain Whitelisting (Egress): One-click generation of Claude domain sandbox configuration (
.claude/settings.json) to block unauthorized external network requests.
📦 Requirements & Installation
- PHP >= 8.4
- Composer
- Docker (Recommended for local development with the
dnmp-php84container)
🛠️ Quick Start
1. Basic Headless Task Execution
2. Loading & Staging Agent Skills (SKILL.md)
3. Session Resume & Context Continuation
💡 Typical Use Cases
- 🏢 Enterprise Automated Code Review & Security Scanning (Code Review & SAST)
- Automatically spin up Claude Code or Codex in GitLab CI / GitHub Actions pipelines or Git Webhooks for headless PR scanning and output standardized JSON review reports.
- 🤖 Automated Issue / Bug Fixing Agent Service
- When a user submits an issue ticket, the background PHP Worker automatically creates an isolated sandbox, drives the AI CLI to locate bugs, modify code, run unit tests, and submit a PR via Git.
- 📊 Multi-Model Capability Benchmarking & Arena Platform (AI Benchmark / Arena)
- Concurrently invoke different AI CLIs against the same test suite via a unified interface, automatically comparing code generation quality, execution time, pass rates, and Token consumption costs.
- ☁️ SaaS Platforms & AI Coding Middle-End Engine
- Encapsulate headless AI coding agent capabilities into asynchronous jobs within web frameworks (Laravel / Webman / Symfony) and stream real-time events to the frontend via WebSocket.
🧪 Pest Unit Testing
This project uses Pest 3.0 for comprehensive unit testing:
1. Run locally
2. Run inside Docker container (dnmp-php84)
🎨 Code Formatting & Linting (Mago)
This project is configured with Mago (a high-performance PHP toolchain written in Rust) via mago.toml:
📄 License
MIT License