Skip to content

Commit d7c045a

Browse files
authored
Merge pull request #3 from ebarti/stack/phase-3-claude-codex
Add Claude and Codex runtime adapters
2 parents 3382cad + 1aef930 commit d7c045a

18 files changed

Lines changed: 1165 additions & 24 deletions

File tree

.planning/REQUIREMENTS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ Which phases cover which requirements. Updated during roadmap creation.
166166
| EVNT-03 | Phase 2 | Complete |
167167
| EVNT-04 | Phase 2 | Complete |
168168
| EVNT-05 | Phase 2 | Complete |
169-
| ADPT-01 | Phase 3 | Pending |
170-
| ADPT-02 | Phase 3 | Pending |
171-
| ADPT-03 | Phase 3 | Pending |
172-
| ADPT-04 | Phase 3 | Pending |
169+
| ADPT-01 | Phase 3 | Complete |
170+
| ADPT-02 | Phase 3 | Complete |
171+
| ADPT-03 | Phase 3 | Complete |
172+
| ADPT-04 | Phase 3 | Complete |
173173
| ADPT-05 | Phase 4 | Pending |
174174
| ADPT-06 | Phase 4 | Pending |
175175
| ADPT-07 | Phase 4 | Pending |
@@ -180,7 +180,7 @@ Which phases cover which requirements. Updated during roadmap creation.
180180
| TEST-05 | Phase 5 | Pending |
181181
| TEST-06 | Phase 4 | Pending |
182182
| DOCS-01 | Phase 5 | Pending |
183-
| DOCS-02 | Phase 3 | Pending |
183+
| DOCS-02 | Phase 3 | Complete |
184184
| DOCS-03 | Phase 4 | Pending |
185185
| DOCS-04 | Phase 5 | Pending |
186186
| DOCS-05 | Phase 5 | Pending |

.planning/ROADMAP.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Decimal phases appear between their surrounding integers in numeric order.
1919

2020
- [x] **Phase 1: Core Runtime Skeleton** - Installable core package with public task/result/runtime contracts.
2121
- [x] **Phase 2: Events and Test Harness** - Optional extras skeleton, event system, and fake SDK contract tests.
22-
- [ ] **Phase 3: Claude and Codex Runtimes** - First two real vendor adapters through the shared API.
22+
- [x] **Phase 3: Claude and Codex Runtimes** - First two real vendor adapters through the shared API.
2323
- [ ] **Phase 4: Antigravity and Cross-Runtime Proof** - Third adapter plus same-task multi-runtime proof and Mestre compatibility checks.
2424
- [ ] **Phase 5: Public Release Readiness** - Documentation, capability matrix, live-smoke guidance, and PyPI publish checklist.
2525

@@ -119,6 +119,6 @@ Phases execute in numeric order: 1 -> 2 -> 3 -> 4 -> 5
119119
|-------|----------------|--------|-----------|
120120
| 1. Core Runtime Skeleton | 3/3 | Complete | 2026-06-10 |
121121
| 2. Events and Test Harness | 3/3 | Complete | 2026-06-10 |
122-
| 3. Claude and Codex Runtimes | 0/3 | Not started | - |
122+
| 3. Claude and Codex Runtimes | 3/3 | Complete | 2026-06-10 |
123123
| 4. Antigravity and Cross-Runtime Proof | 0/3 | Not started | - |
124124
| 5. Public Release Readiness | 0/3 | Not started | - |

.planning/STATE.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ gsd_state_version: '1.0'
33
status: executing
44
progress:
55
total_phases: 5
6-
completed_phases: 2
6+
completed_phases: 3
77
total_plans: 15
8-
completed_plans: 6
9-
percent: 40
8+
completed_plans: 9
9+
percent: 60
1010
---
1111

1212
# Project State
@@ -18,21 +18,21 @@ See: .planning/PROJECT.md (updated 2026-06-10)
1818
**Core value:** Developers can run the same agentic task through Claude, Codex,
1919
or Antigravity using one small, typed Python API while preserving the
2020
vendor-specific capabilities needed for real work.
21-
**Current focus:** Phase 3: Claude and Codex Runtimes
21+
**Current focus:** Phase 4: Antigravity and Cross-Runtime Proof
2222

2323
## Current Position
2424

25-
Phase: 3 of 5 (Claude and Codex Runtimes)
25+
Phase: 4 of 5 (Antigravity and Cross-Runtime Proof)
2626
Plan: 0 of 3 in current phase
27-
Status: Phase 2 complete; ready for Phase 3
28-
Last activity: 2026-06-10 - Phase 2 added normalized events and fake SDK contract helpers.
27+
Status: Phase 3 complete; ready for Phase 4
28+
Last activity: 2026-06-10 - Phase 3 added Claude and Codex adapters.
2929

30-
Progress: [####------] 40%
30+
Progress: [######----] 60%
3131

3232
## Performance Metrics
3333

3434
**Velocity:**
35-
- Total plans completed: 6
35+
- Total plans completed: 9
3636
- Average duration: n/a
3737
- Total execution time: 0.0 hours
3838

@@ -42,9 +42,10 @@ Progress: [####------] 40%
4242
|-------|-------|-------|----------|
4343
| 1. Core Runtime Skeleton | 3 | 3 | n/a |
4444
| 2. Events and Test Harness | 3 | 3 | n/a |
45+
| 3. Claude and Codex Runtimes | 3 | 3 | n/a |
4546

4647
**Recent Trend:**
47-
- Last 5 plans: 01-02, 01-03, 02-01, 02-02, 02-03
48+
- Last 5 plans: 02-02, 02-03, 03-01, 03-02, 03-03
4849
- Trend: n/a
4950

5051
*Updated after each plan completion*
@@ -65,6 +66,8 @@ Recent decisions affecting current work:
6566
to optional adapter modules.
6667
- Phase 2: Event payloads use a normalized dictionary shape and sanitize
6768
sensitive/high-volume attributes before emission.
69+
- Phase 3: Claude and Codex adapters use lazy imports and fake-injected tests
70+
so default CI remains credential-free.
6871

6972
### Pending Todos
7073

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Phase 3: Claude and Codex Runtimes - Context
2+
3+
**Gathered:** 2026-06-10
4+
**Status:** Ready for planning
5+
6+
<domain>
7+
## Phase Boundary
8+
9+
Implement runnable Claude Agent SDK and OpenAI Codex SDK adapters through the
10+
shared runtime API, with clear diagnostics and fake-injected tests.
11+
12+
</domain>
13+
14+
<decisions>
15+
## Implementation Decisions
16+
17+
### Adapter Boundaries
18+
- Keep imports lazy so `agent_runtime_kit` remains dependency-free.
19+
- Expose real adapter classes under `agent_runtime_kit.adapters`.
20+
- Use injected SDK surfaces in tests rather than live credentials.
21+
- Reject unsupported provider inputs with typed errors.
22+
23+
### Provider Mapping
24+
- Claude maps system prompt, cwd, permissions, MCP, sessions, structured
25+
output, allowed/disallowed tools, and budget where supported.
26+
- Codex maps cwd, developer instructions, model, approval mode, sandbox,
27+
sessions, structured output, and reasoning effort.
28+
- Codex rejects per-task MCP because the Python SDK does not expose that
29+
configuration path.
30+
31+
### the agent's Discretion
32+
Use generic, community-facing names while preserving Mestre-compatible fields.
33+
34+
</decisions>
35+
36+
<code_context>
37+
## Existing Code Insights
38+
39+
### Reusable Assets
40+
- Phase 2 events and fake SDK helpers provide adapter test surfaces.
41+
- Mestre's Claude and Codex vendor-lane adapters informed mapping choices.
42+
43+
### Established Patterns
44+
- Runtime adapters emit normalized events and return `AgentResult`.
45+
46+
### Integration Points
47+
- `agent_runtime_kit.adapters.register_adapters()` registers provider runtimes
48+
into the core registry.
49+
50+
</code_context>
51+
52+
<specifics>
53+
## Specific Ideas
54+
55+
The quickstart should demonstrate one provider end to end through the public
56+
API.
57+
58+
</specifics>
59+
60+
<deferred>
61+
## Deferred Ideas
62+
63+
Antigravity and cross-runtime proof are deferred to Phase 4.
64+
65+
</deferred>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Phase 3: Claude and Codex Runtimes - Plan
2+
3+
## Plan 03-01: Claude Agent SDK adapter and tests
4+
5+
- Implement `ClaudeAgentRuntime`.
6+
- Map task fields into `ClaudeAgentOptions`.
7+
- Translate streamed SDK messages into `AgentResult`.
8+
- Cover success, tools, sessions, diagnostics, and unsupported model handling.
9+
10+
## Plan 03-02: Codex SDK adapter and tests
11+
12+
- Implement `CodexAgentRuntime`.
13+
- Map task fields into `AsyncCodex`, `CodexConfig`, thread start/resume, and
14+
thread run kwargs.
15+
- Cover success, structured output, sessions, diagnostics, and unsupported MCP.
16+
17+
## Plan 03-03: One-runtime quickstart and provider diagnostics docs
18+
19+
- Add quickstart documentation using Claude.
20+
- Add provider diagnostics documentation.
21+
- Add a diagnostics helper for installed adapter availability.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Phase 3: Claude and Codex Runtimes - Summary
2+
3+
Implemented the first real vendor adapters:
4+
5+
- `ClaudeAgentRuntime` with lazy `claude-agent-sdk` imports and injected SDK
6+
tests.
7+
- `CodexAgentRuntime` with lazy `openai-codex` imports and injected SDK tests.
8+
- Adapter registry helper.
9+
- Provider diagnostics helper.
10+
- Quickstart and provider diagnostics docs.
11+
12+
Default tests remain credential-free and do not require vendor packages.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
status: passed
3+
---
4+
5+
# Phase 3 Verification
6+
7+
## Automated Checks
8+
9+
- `uv run pytest` - passed, 17 tests.
10+
- `uv run ruff check .` - passed.
11+
- `uv run mypy` - passed.
12+
13+
## Result
14+
15+
Phase 3 success criteria are satisfied. Claude and Codex adapters are runnable
16+
through injected SDK surfaces, missing-package diagnostics are exposed through
17+
`availability()`, unsupported model/MCP cases are typed, and the quickstart
18+
documents one provider end to end.

docs/providers.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Provider Diagnostics
2+
3+
`agent-runtime-kit` keeps provider setup checks explicit. Each runtime exposes
4+
`availability()` and returns a `RuntimeAvailability` value with:
5+
6+
- runtime kind
7+
- availability flag
8+
- reason
9+
- message
10+
- package name
11+
- installed version when discoverable
12+
13+
Claude uses the `claude-agent-sdk` package and maps working directory,
14+
permissions, MCP servers, sessions, structured output, tool allow/deny lists,
15+
and budget where supported by the installed SDK.
16+
17+
Codex uses the `openai-codex` package and maps working directory, session
18+
resume, approval mode, sandbox, structured output, model, and reasoning effort.
19+
Codex does not currently support per-task MCP server configuration through this
20+
adapter, so `mcp_servers` is rejected with a typed error.

docs/quickstart.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Quickstart
2+
3+
Install the dependency-free core:
4+
5+
```bash
6+
pip install agent-runtime-kit
7+
```
8+
9+
Install one provider extra:
10+
11+
```bash
12+
pip install "agent-runtime-kit[claude]"
13+
```
14+
15+
Run a task:
16+
17+
```python
18+
import asyncio
19+
20+
from agent_runtime_kit import AgentTask
21+
from agent_runtime_kit.adapters import ClaudeAgentRuntime
22+
23+
24+
async def main() -> None:
25+
runtime = ClaudeAgentRuntime(default_model="claude-sonnet-4-6")
26+
result = await runtime.run(AgentTask(goal="Summarize this repository"))
27+
print(result.output)
28+
29+
30+
asyncio.run(main())
31+
```
32+
33+
Use `runtime.availability()` before dispatching work in applications that need
34+
clear setup diagnostics.
Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
"""Vendor adapter modules.
1+
"""Vendor adapter modules."""
22

3-
Import concrete adapters from their provider modules so optional dependencies
4-
remain lazy.
5-
"""
3+
from agent_runtime_kit._types import AgentRuntimeKind
4+
from agent_runtime_kit.adapters.claude import ClaudeAgentRuntime
5+
from agent_runtime_kit.adapters.codex import CodexAgentRuntime
6+
from agent_runtime_kit.registry import RuntimeRegistry
7+
8+
__all__ = [
9+
"ClaudeAgentRuntime",
10+
"CodexAgentRuntime",
11+
"register_adapters",
12+
]
13+
14+
15+
def register_adapters(registry: RuntimeRegistry, *, replace: bool = False) -> None:
16+
"""Register the built-in vendor adapters in a runtime registry."""
17+
18+
registry.register(AgentRuntimeKind.CLAUDE_AGENT_SDK, ClaudeAgentRuntime, replace=replace)
19+
registry.register(AgentRuntimeKind.CODEX_AGENT_SDK, CodexAgentRuntime, replace=replace)

0 commit comments

Comments
 (0)