mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-15 14:56:05 +00:00
* feat(openai): add provider-owned route facts * fix(openai): harden provider route facts * test(codex): update rebased auth fixtures * chore: leave release notes to release workflow * fix(openai): align route auth with current contracts * test(openai): align route and shard expectations * test(openai): satisfy route fixture contracts * fix(openai): preserve direct profile forwarding * test(models): complete route auth mocks * test(codex): type compaction factory mock * fix(openai): preserve provider-native model ids * test(agents): align route auth fixtures * style(agents): format route integrations * test(plugin-sdk): pin current surface counts
261 lines
8.4 KiB
TypeScript
261 lines
8.4 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()", () => {
|
|
it("owns auth bootstrap for every native attempt", () => {
|
|
expect(harness.authBootstrap).toBe("harness");
|
|
});
|
|
|
|
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("delegates locked-session execution only to the voice-call plugin", () => {
|
|
expect(harness.delegatedExecutionPluginIds).toEqual(["voice-call"]);
|
|
});
|
|
|
|
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("supports an official route declared compatible with Codex", () => {
|
|
expect(
|
|
harness.supports({
|
|
provider: "openai",
|
|
requestedRuntime: "codex",
|
|
modelProvider: {
|
|
api: "openai-responses",
|
|
baseUrl: "https://api.openai.com/v1",
|
|
requestTransportOverrides: "none",
|
|
runtimePolicy: { compatibleIds: ["openclaw", "codex"] },
|
|
},
|
|
}),
|
|
).toEqual({ supported: true, priority: 100 });
|
|
});
|
|
|
|
it("rejects unresolved harness auth without declared route compatibility", () => {
|
|
const result = harness.supports({
|
|
provider: "openai",
|
|
requestedRuntime: "codex",
|
|
modelProvider: {
|
|
requestTransportOverrides: "none",
|
|
preparedAuth: { source: "harness" },
|
|
},
|
|
});
|
|
expect(result.supported).toBe(false);
|
|
expect(!result.supported ? result.reason : undefined).toContain("not declared");
|
|
});
|
|
|
|
it.each([
|
|
{
|
|
label: "forwarded OAuth subscription",
|
|
preparedAuth: { source: "profile", mode: "oauth", requirement: "subscription" } as const,
|
|
supported: true,
|
|
},
|
|
{
|
|
label: "direct subscription credential",
|
|
preparedAuth: { source: "direct", mode: "oauth", requirement: "subscription" } as const,
|
|
supported: false,
|
|
},
|
|
{
|
|
label: "missing subscription credential",
|
|
preparedAuth: { source: "none", requirement: "subscription" } as const,
|
|
supported: false,
|
|
},
|
|
{
|
|
label: "resolved direct Platform key",
|
|
preparedAuth: { source: "direct", mode: "api-key", requirement: "api-key" } as const,
|
|
supported: true,
|
|
},
|
|
{
|
|
label: "forwarded Platform key profile",
|
|
preparedAuth: { source: "profile", mode: "api_key", requirement: "api-key" } as const,
|
|
supported: true,
|
|
},
|
|
{
|
|
label: "unresolved harness-native auth",
|
|
preparedAuth: { source: "harness" } as const,
|
|
supported: true,
|
|
},
|
|
{
|
|
label: "unvalidated harness-native subscription",
|
|
preparedAuth: { source: "harness", requirement: "subscription" } as const,
|
|
supported: false,
|
|
},
|
|
])("reports $label reproducibility", ({ preparedAuth, supported }) => {
|
|
const result = harness.supports({
|
|
provider: "openai",
|
|
requestedRuntime: "codex",
|
|
modelProvider: {
|
|
api:
|
|
preparedAuth.requirement === "api-key" ? "openai-responses" : "openai-chatgpt-responses",
|
|
baseUrl:
|
|
preparedAuth.requirement === "api-key"
|
|
? "https://api.openai.com/v1"
|
|
: "https://chatgpt.com/backend-api/codex",
|
|
requestTransportOverrides: "none",
|
|
runtimePolicy: { compatibleIds: ["openclaw", "codex"] },
|
|
preparedAuth,
|
|
},
|
|
});
|
|
|
|
expect(result.supported).toBe(supported);
|
|
if (!supported) {
|
|
expect(!result.supported ? result.reason : undefined).toContain("prepared");
|
|
}
|
|
});
|
|
|
|
it.each([
|
|
{
|
|
name: "custom endpoint",
|
|
modelProvider: {
|
|
api: "openai-responses",
|
|
baseUrl: "https://relay.example.test/v1",
|
|
requestTransportOverrides: "none" as const,
|
|
runtimePolicy: { compatibleIds: ["openclaw"] },
|
|
},
|
|
},
|
|
{
|
|
name: "Completions adapter",
|
|
modelProvider: {
|
|
api: "openai-completions",
|
|
baseUrl: "https://api.openai.com/v1",
|
|
requestTransportOverrides: "none" as const,
|
|
runtimePolicy: { compatibleIds: ["openclaw"] },
|
|
},
|
|
},
|
|
{
|
|
name: "HTTP endpoint",
|
|
modelProvider: {
|
|
api: "openai-responses",
|
|
baseUrl: "http://api.openai.com/v1",
|
|
requestTransportOverrides: "none" as const,
|
|
runtimePolicy: { compatibleIds: ["openclaw"] },
|
|
},
|
|
},
|
|
])("rejects a $name that Codex cannot reproduce", ({ modelProvider }) => {
|
|
const result = harness.supports({
|
|
provider: "openai",
|
|
requestedRuntime: "codex",
|
|
modelProvider,
|
|
});
|
|
expect(result.supported).toBe(false);
|
|
expect(!result.supported ? result.reason : undefined).toContain("prepared provider route");
|
|
});
|
|
|
|
it("rejects authored request overrides defensively", () => {
|
|
const result = harness.supports({
|
|
provider: "openai",
|
|
requestedRuntime: "codex",
|
|
modelProvider: {
|
|
api: "openai-responses",
|
|
baseUrl: "https://api.openai.com/v1",
|
|
requestTransportOverrides: "present",
|
|
runtimePolicy: { compatibleIds: ["openclaw", "codex"] },
|
|
preparedAuth: { source: "harness" },
|
|
},
|
|
});
|
|
expect(result.supported).toBe(false);
|
|
expect(!result.supported ? result.reason : undefined).toContain("request transport overrides");
|
|
});
|
|
|
|
it("rejects an OpenAI route without a provider compatibility declaration", () => {
|
|
const result = harness.supports({
|
|
provider: "openai",
|
|
requestedRuntime: "codex",
|
|
modelProvider: {
|
|
api: "openai-responses",
|
|
baseUrl: "https://relay.example.test/v1",
|
|
requestTransportOverrides: "none",
|
|
},
|
|
});
|
|
expect(result.supported).toBe(false);
|
|
expect(!result.supported ? result.reason : undefined).toContain("not declared");
|
|
});
|
|
|
|
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);
|
|
});
|
|
|
|
it("exposes the fail-closed exact runtime artifact validator", async () => {
|
|
if (!harness.runtimeArtifact) {
|
|
throw new Error("expected Codex runtime artifact capability");
|
|
}
|
|
await expect(
|
|
harness.runtimeArtifact.validate({
|
|
id: "codex-app-server:v1:malformed",
|
|
fingerprint: "0".repeat(64),
|
|
}),
|
|
).resolves.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();
|
|
});
|
|
});
|