Skip to content

feat(middleware): implement ClaudeCliRuntime concrete class#9

Merged
alexey-pelykh merged 1 commit intomainfrom
feat/claude-cli-runtime
Feb 25, 2026
Merged

feat(middleware): implement ClaudeCliRuntime concrete class#9
alexey-pelykh merged 1 commit intomainfrom
feat/claude-cli-runtime

Conversation

@alexey-pelykh
Copy link
Copy Markdown

@alexey-pelykh alexey-pelykh commented Feb 25, 2026

Summary

Closes #8.

  • Implements ClaudeCliRuntime extending CLIRuntimeBase — the first concrete runtime for the new middleware architecture
  • Maps Claude CLI stream-json NDJSON output (stream_event envelopes + result line) to AgentEvent instances
  • Passes MCP server config as inline JSON string via --mcp-config
  • Overrides execute() to enrich the base class done event with accumulated text, session ID, usage, cost, and turn metadata
  • 31 unit tests covering argument construction (7), event extraction (15), environment setup (2), MCP config inline JSON (2), and done event enrichment (3)

Test plan

  • pnpm build passes
  • pnpm check passes (format + typecheck + lint)
  • pnpm test — 31 new tests, all passing
  • Existing cli-runtime-base.test.ts (16 tests) unaffected

🤖 Generated with Claude Code

@alexey-pelykh alexey-pelykh force-pushed the feat/claude-cli-runtime branch from d62e2b7 to 0330b24 Compare February 25, 2026 12:09
First concrete runtime extending CLIRuntimeBase. Invokes `claude -p
--output-format stream-json --verbose` and maps the streaming NDJSON
output (stream_event envelopes and result line) to AgentEvent instances.

Key capabilities:
- buildArgs: session resume, inline MCP config JSON, prompt as positional
- extractEvent: stateful parsing of text deltas, tool_use buffering,
  session ID tracking, usage/cost extraction from result line
- execute override: enriches base class done event with accumulated state

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@alexey-pelykh alexey-pelykh force-pushed the feat/claude-cli-runtime branch from 0330b24 to d525ffc Compare February 25, 2026 12:13
@alexey-pelykh alexey-pelykh merged commit 581210f into main Feb 25, 2026
2 checks passed
@alexey-pelykh alexey-pelykh deleted the feat/claude-cli-runtime branch February 25, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement ClaudeCliRuntime concrete class

1 participant