Files
openclaw-openclaw/extensions/codex/harness.test.ts
Peter Steinberger 0d981095d4 refactor(codex): store app-server thread bindings in SQLite plugin state (#101210)
* test(codex): shorten placeholder auth fixture strings

* feat(plugin-state): add reject-new overflow policy for keyed namespaces

* feat(agents): thread agent identity and session generation through reset and hooks

* refactor(codex): add SQLite-backed app-server thread binding store

* refactor(codex): move app-server runtime callers onto the binding store

* refactor(codex): move conversation, entry, and thread-tool flows onto the binding store

* refactor(codex): move command handlers onto the binding store

* feat(codex): import legacy binding sidecars via doctor state migration

* fix(codex): keep doctor sidecar scan inside stateDir

* fix(codex): make binding migration landable

* chore(changelog): defer release note

* test(plugin-state): stabilize durable-capacity ordering
2026-07-07 03:03:44 +01:00

86 lines
2.8 KiB
TypeScript

// Codex tests cover harness plugin behavior.
import { describe, expect, it } from "vitest";
import { createCodexAppServerAgentHarness } from "./harness.js";
import {
createCodexTestBindingStore,
sessionBindingIdentity,
testCodexAppServerBindingStore,
} from "./src/app-server/session-binding.test-helpers.js";
describe("Codex agent harness supports()", () => {
const harness = createCodexAppServerAgentHarness({
bindingStore: testCodexAppServerBindingStore,
});
it("supports the canonical codex virtual provider", () => {
expect(harness.supports({ provider: "codex", requestedRuntime: "codex" })).toEqual({
supported: true,
priority: 100,
});
});
it("supports openai as the primary OpenClaw routing id", () => {
expect(harness.supports({ provider: "openai", requestedRuntime: "codex" })).toEqual({
supported: true,
priority: 100,
});
});
it("supports the canonical openai routing id (documented Codex path)", () => {
expect(harness.supports({ provider: "openai", requestedRuntime: "codex" })).toEqual({
supported: true,
priority: 100,
});
});
it("rejects providers Codex app-server cannot resolve from its own config", () => {
const result = harness.supports({ provider: "9router", requestedRuntime: "codex" });
expect(result.supported).toBe(false);
expect(!result.supported ? (result.reason ?? "") : "").toContain("codex");
});
it("normalizes provider casing", () => {
expect(harness.supports({ provider: "OpenAI", requestedRuntime: "codex" })).toEqual({
supported: true,
priority: 100,
});
});
it("honors explicit provider id overrides", () => {
const narrowHarness = createCodexAppServerAgentHarness({
providerIds: ["codex"],
bindingStore: testCodexAppServerBindingStore,
});
const result = narrowHarness.supports({ provider: "openai", requestedRuntime: "codex" });
expect(result.supported).toBe(false);
});
});
describe("Codex agent harness reset()", () => {
it("retires the physical session generation", async () => {
const bindingStore = createCodexTestBindingStore();
const identity = sessionBindingIdentity({
agentId: "worker",
sessionId: "session-1",
sessionKey: "agent:worker:main",
});
await bindingStore.mutate(identity, {
kind: "set",
binding: { threadId: "thread-1", cwd: "/repo" },
});
const harness = createCodexAppServerAgentHarness({ bindingStore });
if (!harness.reset) {
throw new Error("expected Codex harness reset hook");
}
await harness.reset({
agentId: "worker",
sessionId: "session-1",
sessionKey: "agent:worker:main",
reason: "reset",
});
await expect(bindingStore.read(identity)).resolves.toBeUndefined();
});
});