Skip to content

Implement CLIRuntimeBase abstract class#6

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

Implement CLIRuntimeBase abstract class#6
alexey-pelykh merged 1 commit intomainfrom
feat/cli-runtime-base

Conversation

@alexey-pelykh
Copy link
Copy Markdown

Summary

  • Implements CLIRuntimeBase abstract class in src/middleware/cli-runtime-base.ts (~200 lines)
  • Implements AgentRuntime interface with an async generator execute() method
  • Provides shared subprocess machinery: NDJSON parsing, watchdog timer, abort signal propagation, stderr capture, stdin prompt delivery for long prompts (>10K chars)
  • Defines three abstract methods for concrete runtimes: buildArgs(), extractEvent(), buildEnv()
  • Adds 16 unit tests covering all acceptance criteria in src/middleware/cli-runtime-base.test.ts

Closes #5

Test plan

  • NDJSON parsing: valid lines, malformed lines, empty lines, null extractEvent results
  • Abort signal: fires mid-execution, already-aborted signal
  • Watchdog timer: kills on inactivity, resets on output
  • Stdin prompt delivery: long prompts written to stdin, short prompts not written
  • Subprocess spawning: command/args, working directory, environment merging
  • Stderr capture: captured without producing error events
  • Done event: includes duration, always emitted last
  • pnpm check passes (format + typecheck + lint)

🤖 Generated with Claude Code

@alexey-pelykh alexey-pelykh enabled auto-merge (squash) February 25, 2026 10:31
Add the shared subprocess machinery for CLI-based agent runtimes.
CLIRuntimeBase implements AgentRuntime as an abstract class with:

- Subprocess spawning via child_process.spawn()
- NDJSON stdout parsing with malformed line handling
- Async generator yielding AgentEvent objects
- Watchdog timer with configurable inactivity timeout
- Abort signal propagation to child process
- Stderr capture into buffer
- Long prompt delivery via stdin (>10K chars)
- Three abstract methods for subclasses: buildArgs, extractEvent, buildEnv

Closes #5

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@alexey-pelykh alexey-pelykh merged commit 85e080b into main Feb 25, 2026
2 checks passed
@alexey-pelykh alexey-pelykh deleted the feat/cli-runtime-base branch February 25, 2026 11:21
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 CLIRuntimeBase abstract class

1 participant