feat(agents): finish ClaudeAgentPort migration in agent-runner + foreman #529
No reviewers
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks!529
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "boss/517"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Replace direct
query({...})calls inagent-runnerandforemanwithClaudeAgentPort.runTask(), liftSDKMessagetranslation into the adapter, and move the Forgejo PR-URL regex into apr-url.tsdomain helper. The agent-runner ecosystem (runner, foreman, event-log, steer) now consumes onlyTaskEvent; flow-assistant remains on rawquery()as a separate HTTP chat surface (out of scope per issue references).Closes #517
Test plan
bun x turbo run typecheck— clean.bun x @biomejs/biome@^2 check ./format .— clean.bun x turbo run test— 2447 pass / 0 fail.@anthropic-ai/claude-agent-sdkimport remains inagent-runner.ts,foreman.ts,event-log.ts,steer.ts— onlysdk-adapter.tsimports the SDK.agent-runner.test.tsFakeClaudeAgentcovers happy path + invalid-session_idretry against the injected port.SDKUserMessageshape inside the boundary.buildForemanRunRequest+runForemanTurn) drives turns through the port.Replace direct `query({...})` calls in `agent-runner` and `foreman` with `ClaudeAgentPort.runTask()`, drop every SDK import outside `sdk-adapter.ts` in the agent-runner ecosystem, and lift `SDKMessage` translation into the adapter so domain code consumes only `TaskEvent`. - Extend `ClaudeAgentPort.AssistantTurn` with `toolUses` + optional `error` and `SystemEvent` with `details` so event-log consumers can drop their `SDKMessage` cast. `ResultEvent` gains `durationMs`, `subtype`, `errors`. - `agent-runner.ts`: inject `ClaudeAgentPort` (default `SdkClaudeAgent`), replace inline `canUseTool` with the port's `ToolPolicy`, swap `onSDKMessage` for `onTaskEvent`, move the Forgejo PR-URL regex into a new `pr-url.ts` domain helper. - `foreman.ts`: rename `buildForemanSdkOptions` → `buildForemanRunRequest` (returns a `RunTaskRequest`), drive the chat turn through the port, surface the same `onTaskEvent` hook. - `steer.ts`: `steerInputIterator` yields plain strings; the SDK adapter wraps them into `SDKUserMessage` shape inside the boundary. - `event-log.ts`: rename `logSDKMessage` → `logTaskEvent`; consume domain `TaskEvent` directly, including `assistant.toolUses` and `system.details` (api_retry). - `registry.ts`: rewire host-mode and code-flow runs to the new `onTaskEvent` callback. - Tests: update the `extractProgress` and steer-iterator fixtures to `TaskEvent` / string shapes, switch the foreman test surface to `buildForemanRunRequest`, and add a `FakeClaudeAgent` integration covering the invalid-session-id retry path against the new port. Closes #517All acceptance criteria from #517 met, CI green (run #2476, 13m19s).
agent-runner.tsconsumes onlyClaudeAgentPort.runTask();SDKMessageimport gone; no@anthropic-ai/claude-agent-sdkimport outsidesdk-adapter.ts(grep matches are comments, not imports).pr-url.tsdomain helper is a clean extraction.foreman.tsdrives turns through the port viabuildForemanRunRequest+runForemanTurn. Streaming-input steer path preserved —steerInputIteratoryieldsstrings andSdkClaudeAgent.runTaskwraps them viastringsToUserMessages. Session-resume retry intact.FakeClaudeAgentcovers happy path + invalid-session retry with full session-key assertions.Nit (not blocking):
sdk-adapter.tsheader still says "agent-runner.ts remains on the raw SDK path for now — migration is Phase 5." That clause is now false; worth a one-line update to "migration complete (PR #529)" before the next reader is confused.