Skip to content

feat(server): replace Pi ACP with direct SDK provider#202

Open
boudra wants to merge 3 commits intomainfrom
feat/pi-direct-sdk
Open

feat(server): replace Pi ACP with direct SDK provider#202
boudra wants to merge 3 commits intomainfrom
feat/pi-direct-sdk

Conversation

@boudra
Copy link
Copy Markdown
Collaborator

@boudra boudra commented Apr 6, 2026

Summary

  • Replace the ACP-based Pi provider (which spawned a pi-acp subprocess and talked JSON-RPC over stdio) with a direct in-process integration using @mariozechner/pi-coding-agent as a library
  • New PiDirectAgentClient + PiDirectAgentSession map Pi's AgentSessionEvent stream to Paseo's AgentStreamEvent types — tool execution, text/reasoning deltas, compaction, persistence
  • Thinking levels use the existing thinkingOptionId / setThinkingOption() infrastructure
  • 9 real e2e tests against a live Pi agent covering bash/read/write/edit tool calls, reasoning chunks, session persistence/resume, model listing, and thinking options

Test plan

  • npm run typecheck passes clean
  • 9 Pi e2e tests pass against live Pi agent (28s)
  • Bash tool call — shell detail with command, output, exitCode
  • Read tool — filePath and content extraction
  • Write tool — detail and disk verification
  • Edit tool — oldString/newString and disk verification
  • Reasoning/thinking chunks stream correctly
  • Session persistence survives close and resume
  • Model listing returns expected shape
  • Thinking level reflected in getRuntimeInfo
  • setThinkingOption runtime effect verified

🤖 Generated with Claude Code

boudra and others added 3 commits April 6, 2026 04:45
Replace the ACP-based Pi provider (which spawned a `pi-acp` subprocess
and talked JSON-RPC over stdio) with a direct in-process integration
using `@mariozechner/pi-coding-agent` as a library.

The new `PiDirectAgentClient` and `PiDirectAgentSession` use the Pi SDK
directly — creating sessions via `createAgentSession()`, managing models
via `ModelRegistry`, and mapping Pi's `AgentSessionEvent` stream to
Paseo's `AgentStreamEvent` types including:

- Thread/turn lifecycle events
- Assistant text and thinking/reasoning deltas
- Tool execution (bash, read, write, edit, find, grep, ls) with arg
  caching across start/update/end events
- Compaction events
- Session persistence and resume via `SessionManager`

Thinking levels flow through the existing `thinkingOptionId` /
`setThinkingOption()` infrastructure, not through features.

Includes 9 real e2e tests against a live Pi agent covering tool calls
(bash/read/write/edit), reasoning chunks, session persistence/resume,
model listing, and thinking option management.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address coding standards violations in pi-direct-agent.ts:

- Replace all `as Record<string, unknown>` / `as any` / `as unknown as`
  casts with properly typed boundaries using Pi SDK's exported tool
  input types (BashToolInput, ReadToolInput, EditToolInput, etc.)
- Introduce named interfaces at all boundaries: PiPromptPayload,
  ToolCallOutputSummary, PiModelReference, PiPersistenceMetadata
- Parse tool args once at boundary into typed discriminated union,
  then trust types internally — no more typeof probing in mappers
- Break all dense ternary chains into named steps / helper functions
- Import SDK types directly (RegisteredCommand, ResourceLoader, Skill)
  instead of casting through anonymous inline shapes
- Isolate the system prompt SDK escape hatch into a minimal boundary
  helper with a named interface

Behavior is preserved — all 9 real e2e tests still pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant