diff --git a/electron.vite.config.ts b/electron.vite.config.ts index 87aab7b8..e32d60da 100644 --- a/electron.vite.config.ts +++ b/electron.vite.config.ts @@ -16,7 +16,7 @@ export default defineConfig({ rollupOptions: { input: { index: resolve("src/main/index.ts"), - worker: resolve("src/main/worker/worker-entry.ts"), + worker: resolve("src/main/worker/entry/index.ts"), }, }, }, diff --git a/src/main/worker-service.ts b/src/main/worker-service.ts index 83f6ad1e..be910591 100644 --- a/src/main/worker-service.ts +++ b/src/main/worker-service.ts @@ -1,9 +1,9 @@ import { app, utilityProcess } from "electron"; -import { workerMessageSchema, type WorkerServiceDependencies } from "./worker/worker-types"; -import { handleWorkerExit } from "./worker/worker-crash-recovery"; -import { handleWorkerMessage } from "./worker/worker-message-handler"; +import { workerMessageSchema, type WorkerServiceDependencies } from "./worker/entry/types"; +import { handleWorkerExit } from "./worker/entry/crash-recovery"; +import { handleWorkerMessage } from "./worker/entry/message-handler"; -export { workerMessageSchema } from "./worker/worker-types"; +export { workerMessageSchema } from "./worker/entry/types"; export function createWorkerService({ db, diff --git a/src/main/worker/worker-crash-recovery.ts b/src/main/worker/entry/crash-recovery.ts similarity index 96% rename from src/main/worker/worker-crash-recovery.ts rename to src/main/worker/entry/crash-recovery.ts index d114f7db..459ff5f5 100644 --- a/src/main/worker/worker-crash-recovery.ts +++ b/src/main/worker/entry/crash-recovery.ts @@ -1,5 +1,5 @@ -import type { WorkerServiceDependencies } from "./worker-types"; -import { resolveWorkspaceWithLockMode } from "../orchestration/resolve-workspace"; +import type { WorkerServiceDependencies } from "./types"; +import { resolveWorkspaceWithLockMode } from "../../orchestration/resolve-workspace"; export function handleWorkerExit( code: number | null, diff --git a/src/main/worker/worker-entry.ts b/src/main/worker/entry/index.ts similarity index 96% rename from src/main/worker/worker-entry.ts rename to src/main/worker/entry/index.ts index 4c5f2b53..caf19b30 100644 --- a/src/main/worker/worker-entry.ts +++ b/src/main/worker/entry/index.ts @@ -1,6 +1,6 @@ -import type { ChildMessage, ParentMessage, RunJob } from "./worker-helpers"; -import { WorkerRpcClient } from "./worker-rpc"; -import { WorkerRunner } from "./worker-runner"; +import type { ChildMessage, ParentMessage, RunJob } from "../worker-helpers"; +import { WorkerRpcClient } from "./rpc"; +import { WorkerRunner } from "../worker-runner"; const parentPort = process.parentPort; diff --git a/src/main/worker/worker-message-handler.ts b/src/main/worker/entry/message-handler.ts similarity index 86% rename from src/main/worker/worker-message-handler.ts rename to src/main/worker/entry/message-handler.ts index 110f99e4..a8c4a2d9 100644 --- a/src/main/worker/worker-message-handler.ts +++ b/src/main/worker/entry/message-handler.ts @@ -1,9 +1,9 @@ -import type { RuntimeBridge, RuntimeMessageInjector } from "../agent-runtime"; -import type { workerMessageSchema } from "./worker-types"; -import { handleRunLog } from "./handlers/run-log-handler"; -import { handleRunStatus } from "./handlers/run-status-handler"; -import { handleRunFinished } from "./handlers/run-finished-handler"; -import type { HandlerContext, HandlerDeps } from "./handlers/handler-context"; +import type { RuntimeBridge, RuntimeMessageInjector } from "../../agent-runtime"; +import type { workerMessageSchema } from "./types"; +import { handleRunLog } from "../handlers/run-log-handler"; +import { handleRunStatus } from "../handlers/run-status-handler"; +import { handleRunFinished } from "../handlers/run-finished-handler"; +import type { HandlerContext, HandlerDeps } from "../handlers/handler-context"; export async function handleWorkerMessage( message: unknown, diff --git a/src/main/worker/worker-rpc.ts b/src/main/worker/entry/rpc.ts similarity index 96% rename from src/main/worker/worker-rpc.ts rename to src/main/worker/entry/rpc.ts index de7424cb..9bd2c799 100644 --- a/src/main/worker/worker-rpc.ts +++ b/src/main/worker/entry/rpc.ts @@ -1,5 +1,5 @@ import { randomUUID } from "node:crypto"; -import type { ChildMessage } from "./worker-helpers"; +import type { ChildMessage } from "../worker-helpers"; interface PendingRpc { resolve: (value: { ok: true; result: unknown } | { ok: false; error: string }) => void; diff --git a/src/main/worker/worker-types.ts b/src/main/worker/entry/types.ts similarity index 90% rename from src/main/worker/worker-types.ts rename to src/main/worker/entry/types.ts index 453ae1d7..db256f73 100644 --- a/src/main/worker/worker-types.ts +++ b/src/main/worker/entry/types.ts @@ -1,10 +1,10 @@ import { z } from "zod"; -import type { AppDatabase } from "../database"; +import type { AppDatabase } from "../../database"; import type { DesktopEvent, RunRecord } from "@shared/types"; -import type { NotificationOptions } from "../notification-service"; -import type { createBudgetEnforcementService } from "../budget-enforcement-service"; -import type { createSessionManagementService } from "../session-management-service"; -import type { RuntimeBridge, RuntimeMessageInjector } from "../agent-runtime"; +import type { NotificationOptions } from "../../notification-service"; +import type { createBudgetEnforcementService } from "../../budget-enforcement-service"; +import type { createSessionManagementService } from "../../session-management-service"; +import type { RuntimeBridge, RuntimeMessageInjector } from "../../agent-runtime"; const runStatusSchema = z.enum(["queued", "running", "succeeded", "failed", "cancelled", "timed_out", "interrupted"]); diff --git a/src/main/worker/handlers/handler-context.ts b/src/main/worker/handlers/handler-context.ts index 5154036d..5668fcda 100644 --- a/src/main/worker/handlers/handler-context.ts +++ b/src/main/worker/handlers/handler-context.ts @@ -1,5 +1,5 @@ import type { z } from "zod"; -import type { WorkerServiceDependencies, workerMessageSchema } from "../worker-types"; +import type { WorkerServiceDependencies, workerMessageSchema } from "../entry/types"; export type WorkerMessageEvent = z.infer; diff --git a/src/main/worker/handlers/run-finished-helpers.ts b/src/main/worker/handlers/run-finished-helpers.ts index 37d8efd0..06c04478 100644 --- a/src/main/worker/handlers/run-finished-helpers.ts +++ b/src/main/worker/handlers/run-finished-helpers.ts @@ -2,7 +2,7 @@ import type { z } from "zod"; import { createCircuitBreaker } from "../circuit-breaker"; import { handleFailureEscalation, handleSuccessReset } from "../failure-escalation"; import { persistRunEvent } from "../run-event-recorder"; -import type { workerMessageSchema } from "../worker-types"; +import type { workerMessageSchema } from "../entry/types"; import type { HandlerContext, HandlerDeps, WorkerMessageEvent } from "./handler-context"; type RunFinishedEvent = Extract; diff --git a/src/main/worker/pi-agent-factory.ts b/src/main/worker/pi-agent-factory.ts index 17978cc3..dd2334b6 100644 --- a/src/main/worker/pi-agent-factory.ts +++ b/src/main/worker/pi-agent-factory.ts @@ -29,7 +29,7 @@ import type { TransformContextRpcPayload, TransformContextRpcResult, } from "@main/agent-runtime/hook-rpc"; -import type { WorkerRpcClient } from "./worker-rpc"; +import type { WorkerRpcClient } from "./entry/rpc"; // Side-effect import: drags the hook signature contract into the typecheck // graph so any drift in pi-agent-core hook shapes breaks the build here. import "./pi-hook-contract"; diff --git a/src/main/worker/worker-runner.ts b/src/main/worker/worker-runner.ts index d3346761..49ca7660 100644 --- a/src/main/worker/worker-runner.ts +++ b/src/main/worker/worker-runner.ts @@ -5,7 +5,7 @@ import type { ChildMessage, RunJob } from "./worker-helpers"; import { applyEnvOverrides, buildRedactor } from "./worker-helpers"; import { createCodingTools } from "@mariozechner/pi-coding-agent"; import { createPiAgent, resolveThinkingLevel } from "./pi-agent-factory"; -import type { WorkerRpcClient } from "./worker-rpc"; +import type { WorkerRpcClient } from "./entry/rpc"; interface PrepareRunResult { provider: string;