Repository navigation
Split createRunner into runner modules (behavior-preserving) - #127
Merged
Merged
Conversation
Behavior-preserving refactor of src/agent.ts. createRunner kept the Pi Agent/AgentSession wiring and the AgentRunner methods; self-contained pieces move to src/runner/: - run-state.ts: RunState type, per-run reset/clear, output queue, splitMessage - session-events.ts: AgentSession/CLI tool event handling (logs, snapshots, tool progress, thread transcript, usage, compaction status) - stream-fn.ts: provider stream boundary (option shaping, CLI routing, compact prompt, input budget, local prefill watch) - handoff.ts: handoff_context tool callback and pressure extension - private-checkpoint.ts: out-of-session checkpoint call - compaction.ts: timeout, status tracker, settings proxy - context-transitions.ts, presentation.ts, prompt-message.ts, run-outcome.ts, skills.ts, context-files.ts, event-format.ts Code moved verbatim apart from passing closure state as explicit dependencies or getters. Source-shape tests now read agent.ts plus src/runner/*.ts via test/support/runner-source.ts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Behavior-preserving refactor of
src/agent.ts.createRunnerwas one ~1,900-line closure; it is now ~1,000 lines of wiring plus theAgentRunnermethods, with self-contained pieces moved tosrc/runner/:run-state.tsRunStatetype + factory, per-run reset (beginRunState) and clear (clearRunState), the per-run output queue (createRunQueue),splitMessage/MAX_MESSAGE_LENGTHsession-events.tsstream-fn.tshandoff.tshandoff_contexttool callback and the pressure-triggered handoff extensionprivate-checkpoint.tscompaction.tsisCliHarnessProvidercontext-transitions.tspresentation.tsprompt-message.tsrun-outcome.tsskills.ts,context-files.ts,event-format.tsCode moved verbatim except where closure state is now passed as explicit dependencies or getters (read at call time, as before).
agent.tsre-exportsDEFAULT_COMPACTION_TIMEOUT_MS,resolveCompactionTimeoutMsandCompactionStatus, so imports are unchanged.Tests: source-shape assertions that read
src/agent.tsnow read agent.ts +src/runner/*.tsthroughtest/support/runner-source.ts; the asserted patterns are unchanged.Verified:
pnpm run typecheck,pnpm run build,pnpm run check:public-safety, fullpnpm testlocally (same results as main; the remaining local failures are environment-specific and also fail on main), and the Tests workflow in CI.🤖 Generated with Claude Code