Reorganize worker entry layer into worker/entry/ (M8 part 1/3)
Pulls the worker process entry point, parent<->worker IPC plumbing, message validation schema, and crash-recovery handler into a single src/main/worker/entry/ module. No runtime behavior changes — only directory + file-name renames plus import-path updates: worker-entry.ts -> entry/index.ts, worker-message-handler.ts -> entry/message-handler.ts, worker-rpc.ts -> entry/rpc.ts, worker-crash-recovery.ts -> entry/crash-recovery.ts, worker-types.ts -> entry/types.ts. electron.vite.config.ts, worker-service.ts, handlers/*.ts, pi-agent-factory.ts, and worker-runner.ts updated to point at the new locations.
This commit is contained in:
1 parent
0e6cad7f4c
commit
76d9031a41
11 files changed
+26
-26
No files matched your search
@@ -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"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
@@ -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;
|
||||
|
||||
+6
-6
@@ -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,
|
||||
@@ -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;
|
||||
@@ -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"]);
|
||||
|
||||
@@ -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<typeof workerMessageSchema>;
|
||||
|
||||
|
||||
@@ -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<WorkerMessageEvent, { type: "run-finished" }>;
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user