refactor(worker): use pi-mono Agent directly

Rewrites the utility-process worker to drive pi-agent-core's Agent class
against pi-ai models and pi-coding-agent tools. The entry file keeps the
queue and cancellation state, delegates runs to WorkerRunner, and routes
RPC responses through WorkerRpcClient so beforeToolCall/afterToolCall
approvals and prepareRun credential resolution travel back to main's
RuntimeBridge. Worker message schema gains `agent-event` + `rpc-request`
envelopes, and run-finished no longer depends on the deleted sessionCodec.
This commit is contained in:
ZacharyZhang-NY committed 2026-04-17 02:21:12 -04:00
1 parent 892476bd36
commit 4de9cd0339
8 files changed
+404 -257

No files matched your search

+2 -1
View File
@@ -20,6 +20,7 @@ export function createWorkerService({
notify,
budgetService,
sessionService,
getRuntimeBridge,
}: WorkerServiceDependencies) {
const MAX_RETRY_ATTEMPTS = 2;
const RETRY_COOLDOWN_MS = 30_000; // 30 seconds
@@ -110,7 +111,7 @@ export function createWorkerService({
await handleWorkerMessage(
message,
worker,
{ db, logger, isQuitting, emitEvent, wakeAgentIfPossible, processRunCompletion, onRunStarted, onRunCompleted, notify, budgetService, sessionService },
{ db, logger, isQuitting, emitEvent, wakeAgentIfPossible, processRunCompletion, onRunStarted, onRunCompleted, notify, budgetService, sessionService, getRuntimeBridge },
workerMessageSchema,
destroyed,
MAX_RETRY_ATTEMPTS,