Remove desktop compatibility package after runtime-core migration
Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
1 parent
8c74af6c33
commit
f2cd81e0c8
14 files changed
+2
-286
No files matched your search
@@ -17,10 +17,9 @@ If a tradeoff is required, choose correctness and robustness over short-term con
|
||||
## Package Roles
|
||||
|
||||
- `apps/t3`: Node CLI/runtime. Owns WebSocket server lifecycle, browser launch, and RPC routing.
|
||||
- `apps/desktop`: Compatibility re-export surface for runtime internals consumed by `apps/t3`.
|
||||
- `apps/renderer`: React/Vite UI. Owns session UX, conversation/event rendering, and client-side state.
|
||||
- `packages/contracts`: Shared Zod schemas and TypeScript contracts for provider events, WebSocket payloads, and model/session types.
|
||||
- `packages/runtime-core`: Shared Node runtime services (`ProcessManager`, `TodoStore`, `ProviderManager`, `CodexAppServerManager`) reused by `apps/t3` and `apps/desktop`.
|
||||
- `packages/runtime-core`: Shared Node runtime services (`ProcessManager`, `TodoStore`, `ProviderManager`, `CodexAppServerManager`) used by `apps/t3`.
|
||||
|
||||
## Codex App Server (Important)
|
||||
|
||||
|
||||
@@ -52,10 +52,9 @@ Runtime command semantics:
|
||||
## Workspace layout
|
||||
|
||||
- `/apps/t3`: CLI launcher + local WebSocket runtime server.
|
||||
- `/apps/desktop`: Compatibility re-export surface for runtime internals used by `t3` (no Electron app shell).
|
||||
- `/apps/renderer`: React + Vite UI for session control, conversation, and protocol event stream.
|
||||
- `/packages/contracts`: shared Zod schemas + TypeScript types for WS protocol, provider events, and API contracts.
|
||||
- `/packages/runtime-core`: shared Node runtime services (`ProcessManager`, `TodoStore`, `ProviderManager`, `CodexAppServerManager`) consumed by both `apps/t3` and `apps/desktop`.
|
||||
- `/packages/runtime-core`: shared Node runtime services (`ProcessManager`, `TodoStore`, `ProviderManager`, `CodexAppServerManager`) consumed by `apps/t3`.
|
||||
|
||||
## Codex prerequisites
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"name": "@acme/runtime",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@acme/runtime-core": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.2",
|
||||
"typescript": "^5.7.3"
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
classifyCodexStderrLine,
|
||||
isRecoverableThreadResumeError,
|
||||
normalizeCodexModelSlug,
|
||||
} from "./codexAppServerManager";
|
||||
|
||||
describe("classifyCodexStderrLine", () => {
|
||||
it("ignores empty lines", () => {
|
||||
expect(classifyCodexStderrLine(" ")).toBeNull();
|
||||
});
|
||||
|
||||
it("ignores non-error structured codex logs", () => {
|
||||
const line =
|
||||
"2026-02-08T04:24:19.241256Z WARN codex_core::features: unknown feature key in config: skills";
|
||||
expect(classifyCodexStderrLine(line)).toBeNull();
|
||||
});
|
||||
|
||||
it("ignores known benign rollout path errors", () => {
|
||||
const line =
|
||||
"\u001b[2m2026-02-08T04:24:20.085687Z\u001b[0m \u001b[31mERROR\u001b[0m \u001b[2mcodex_core::rollout::list\u001b[0m: state db missing rollout path for thread 019c3b6c-46b8-7b70-ad23-82f824d161fb";
|
||||
expect(classifyCodexStderrLine(line)).toBeNull();
|
||||
});
|
||||
|
||||
it("keeps unknown structured errors", () => {
|
||||
const line = "2026-02-08T04:24:20.085687Z ERROR codex_core::runtime: unrecoverable failure";
|
||||
expect(classifyCodexStderrLine(line)).toEqual({
|
||||
message: line,
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps plain stderr messages", () => {
|
||||
const line = "fatal: permission denied";
|
||||
expect(classifyCodexStderrLine(line)).toEqual({
|
||||
message: line,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("normalizeCodexModelSlug", () => {
|
||||
it("maps 5.3 aliases to gpt-5.3-codex", () => {
|
||||
expect(normalizeCodexModelSlug("5.3")).toBe("gpt-5.3-codex");
|
||||
expect(normalizeCodexModelSlug("gpt-5.3")).toBe("gpt-5.3-codex");
|
||||
});
|
||||
|
||||
it("prefers codex id when model differs", () => {
|
||||
expect(normalizeCodexModelSlug("gpt-5.3", "gpt-5.3-codex")).toBe("gpt-5.3-codex");
|
||||
});
|
||||
|
||||
it("keeps non-aliased models as-is", () => {
|
||||
expect(normalizeCodexModelSlug("gpt-5.2-codex")).toBe("gpt-5.2-codex");
|
||||
expect(normalizeCodexModelSlug("gpt-5.2")).toBe("gpt-5.2");
|
||||
});
|
||||
});
|
||||
|
||||
describe("isRecoverableThreadResumeError", () => {
|
||||
it("matches not-found resume errors", () => {
|
||||
expect(
|
||||
isRecoverableThreadResumeError(new Error("thread/resume failed: thread not found")),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("ignores non-resume errors", () => {
|
||||
expect(
|
||||
isRecoverableThreadResumeError(new Error("thread/start failed: permission denied")),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("ignores non-recoverable resume errors", () => {
|
||||
expect(
|
||||
isRecoverableThreadResumeError(
|
||||
new Error("thread/resume failed: timed out waiting for server"),
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,7 +0,0 @@
|
||||
export {
|
||||
CodexAppServerManager,
|
||||
type CodexAppServerManagerEvents,
|
||||
classifyCodexStderrLine,
|
||||
isRecoverableThreadResumeError,
|
||||
normalizeCodexModelSlug,
|
||||
} from "@acme/runtime-core";
|
||||
@@ -1,18 +0,0 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
|
||||
export function fixPath(): void {
|
||||
if (process.platform !== "darwin") return;
|
||||
|
||||
try {
|
||||
const shell = process.env.SHELL ?? "/bin/zsh";
|
||||
const result = execFileSync(shell, ["-ilc", "echo -n $PATH"], {
|
||||
encoding: "utf8",
|
||||
timeout: 5000,
|
||||
});
|
||||
if (result) {
|
||||
process.env.PATH = result;
|
||||
}
|
||||
} catch {
|
||||
// Silently ignore — keep default PATH
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { ProcessManager } from "./processManager";
|
||||
|
||||
describe("ProcessManager", () => {
|
||||
it("can be instantiated", () => {
|
||||
const pm = new ProcessManager();
|
||||
expect(pm).toBeInstanceOf(ProcessManager);
|
||||
});
|
||||
|
||||
it("spawns a process and receives output", async () => {
|
||||
const pm = new ProcessManager();
|
||||
const chunks: string[] = [];
|
||||
|
||||
const done = new Promise<void>((resolve) => {
|
||||
pm.on("output", (chunk) => {
|
||||
chunks.push(chunk.data);
|
||||
});
|
||||
pm.on("exit", () => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
const sessionId = pm.spawn({ command: "echo", args: ["hello"] });
|
||||
expect(typeof sessionId).toBe("string");
|
||||
expect(sessionId.length).toBeGreaterThan(0);
|
||||
|
||||
await done;
|
||||
|
||||
expect(chunks.join("").trim()).toBe("hello");
|
||||
});
|
||||
|
||||
it("can kill a spawned process", async () => {
|
||||
const pm = new ProcessManager();
|
||||
|
||||
const exited = new Promise<number | null>((resolve) => {
|
||||
pm.on("exit", (exit) => {
|
||||
resolve(exit.code);
|
||||
});
|
||||
});
|
||||
|
||||
const sessionId = pm.spawn({ command: "sleep", args: ["10"] });
|
||||
pm.kill(sessionId);
|
||||
|
||||
const code = await exited;
|
||||
expect(code).not.toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
export {
|
||||
ProcessManager,
|
||||
type ProcessManagerEvents,
|
||||
} from "@acme/runtime-core";
|
||||
@@ -1,62 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { ProviderManager } from "./providerManager";
|
||||
|
||||
describe("ProviderManager", () => {
|
||||
it("detaches provider event listener and ends thread log streams on dispose", () => {
|
||||
const manager = new ProviderManager();
|
||||
const internals = manager as unknown as {
|
||||
codex: { listenerCount: (event: string) => number };
|
||||
onCodexEvent: (event: {
|
||||
id: string;
|
||||
kind: "notification";
|
||||
provider: "codex";
|
||||
sessionId: string;
|
||||
createdAt: string;
|
||||
method: string;
|
||||
threadId: string;
|
||||
}) => void;
|
||||
threadLogStreams: Map<string, { writableEnded: boolean; destroyed: boolean }>;
|
||||
};
|
||||
internals.onCodexEvent({
|
||||
id: "evt-1",
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
sessionId: "sess-1",
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "thread/started",
|
||||
threadId: "thread-1",
|
||||
});
|
||||
const stream = internals.threadLogStreams.get("thread-1");
|
||||
expect(stream).toBeDefined();
|
||||
if (!stream) return;
|
||||
|
||||
expect(internals.codex.listenerCount("event")).toBe(1);
|
||||
manager.dispose();
|
||||
|
||||
expect(internals.codex.listenerCount("event")).toBe(0);
|
||||
expect(stream.writableEnded || stream.destroyed).toBe(true);
|
||||
expect(internals.threadLogStreams.size).toBe(0);
|
||||
});
|
||||
|
||||
it("allows multiple dispose calls", () => {
|
||||
const manager = new ProviderManager();
|
||||
|
||||
manager.dispose();
|
||||
expect(() => manager.dispose()).not.toThrow();
|
||||
});
|
||||
|
||||
it("rejects request responses for unknown sessions", async () => {
|
||||
const manager = new ProviderManager();
|
||||
|
||||
await expect(
|
||||
manager.respondToRequest({
|
||||
sessionId: "missing-session",
|
||||
requestId: "req-1",
|
||||
decision: "accept",
|
||||
}),
|
||||
).rejects.toThrow("Unknown provider session: missing-session");
|
||||
|
||||
manager.dispose();
|
||||
});
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
export {
|
||||
ProviderManager,
|
||||
type ProviderManagerEvents,
|
||||
} from "@acme/runtime-core";
|
||||
@@ -1,23 +0,0 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const WRAPPER_FILES = [
|
||||
"processManager.ts",
|
||||
"todoStore.ts",
|
||||
"providerManager.ts",
|
||||
"codexAppServerManager.ts",
|
||||
] as const;
|
||||
|
||||
describe("desktop runtime compatibility surface", () => {
|
||||
for (const fileName of WRAPPER_FILES) {
|
||||
it(`${fileName} re-exports from runtime-core`, () => {
|
||||
const filePath = path.resolve(import.meta.dirname, fileName);
|
||||
const source = fs.readFileSync(filePath, "utf8");
|
||||
|
||||
expect(source).toContain("@acme/runtime-core");
|
||||
expect(source).toContain("export {");
|
||||
expect(source).not.toContain("class ");
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1 +0,0 @@
|
||||
export { TodoStore } from "@acme/runtime-core";
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"types": ["node"],
|
||||
"lib": ["ES2023", "DOM"]
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -16,17 +16,6 @@
|
||||
"vitest": "^3.0.0",
|
||||
},
|
||||
},
|
||||
"apps/desktop": {
|
||||
"name": "@acme/runtime",
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"@acme/runtime-core": "workspace:*",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.2",
|
||||
"typescript": "^5.7.3",
|
||||
},
|
||||
},
|
||||
"apps/renderer": {
|
||||
"name": "@acme/renderer",
|
||||
"version": "0.0.0",
|
||||
@@ -100,8 +89,6 @@
|
||||
|
||||
"@acme/renderer": ["@acme/renderer@workspace:apps/renderer"],
|
||||
|
||||
"@acme/runtime": ["@acme/runtime@workspace:apps/desktop"],
|
||||
|
||||
"@acme/runtime-core": ["@acme/runtime-core@workspace:packages/runtime-core"],
|
||||
|
||||
"@acme/t3-runtime": ["@acme/t3-runtime@workspace:apps/t3"],
|
||||
|
||||
Reference in new issue
Block a user