mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-17 04:11:37 +00:00
* feat(codex): add native session supervision * fix(codex): harden supervision integration * fix(codex): preserve locked harness ownership * fix(codex): fence native session archive * fix(codex): revalidate archive binding ownership * feat(codex): integrate supervision runtime * feat(sessions): preserve harness-owned execution * feat(sessions): persist harness ownership invariants * feat(gateway): enforce harness-owned sessions * feat(setup): enable detected Codex supervision * feat(mac): expose supervised Codex sessions * feat(ui): make Codex sessions actionable * docs(codex): document session supervision * test(codex): cover integration ownership * chore(i18n): refresh supervision inventories * fix(setup): finalize Codex activation atomically * test(codex): narrow binding store update * fix(sessions): preserve legacy model locks * test(macos): serialize Codex catalog fixtures * fix(sessions): preserve legacy lock admission * chore(i18n): reconcile supervision metadata * test(sessions): mark legacy lock fixture * fix(macos): drain final Codex catalog frame * docs: leave supervision note to release * style(macos): satisfy Codex catalog type length * chore: record session accessor seam owners * fix(macos): honor configured Codex supervision * fix(codex): preserve harness-owned model locks * fix(codex): satisfy supervision lint gates * chore(i18n): refresh native supervision inventory * fix(codex): align supervision validation contracts * fix(codex): close supervision boundary gaps * fix(codex): preserve supervision activation contracts * fix(codex): dispose standalone supervision runtime * fix(codex): pin supervised source connection * fix(plugins): bind delegated runs to exact session target * fix(codex): scope supervised sessions to configured agents * fix(codex): fingerprint effective supervision home * fix(codex): normalize supervision plugin policy * fix(codex): keep supervised bindings stable across upgrades * fix(codex): guard all supervised binding connections * fix(codex): preserve catalog filters and pending CAS identity * fix(codex): preserve supervision identity for diagnostics * fix(codex): bind uncertain commits to supervision connection * fix(codex): satisfy supervision type boundaries * fix(macos): reconcile current main validation * fix(codex): handle absent runtime config in supervision * fix(doctor): own local audio acceleration check * fix(codex): satisfy integration lint gates * fix(codex): satisfy lifecycle safety guards
199 lines
6.2 KiB
TypeScript
199 lines
6.2 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
|
|
|
const mocks = vi.hoisted(() => ({
|
|
loadInstalledPluginIndexInstallRecords: vi.fn(),
|
|
repairMissingPluginInstallsForIds: vi.fn(),
|
|
ensureOnboardingPluginInstalled: vi.fn(),
|
|
}));
|
|
|
|
type MissingPluginInstallRepairCall = {
|
|
pluginIds: string[];
|
|
env?: NodeJS.ProcessEnv;
|
|
};
|
|
|
|
function readOnlyMissingPluginInstallRepairCall(): MissingPluginInstallRepairCall {
|
|
expect(mocks.repairMissingPluginInstallsForIds).toHaveBeenCalledOnce();
|
|
const calls = mocks.repairMissingPluginInstallsForIds.mock.calls as unknown as Array<
|
|
[MissingPluginInstallRepairCall]
|
|
>;
|
|
const call = calls[0]?.[0];
|
|
if (!call) {
|
|
throw new Error("Expected missing plugin install repair call");
|
|
}
|
|
return call;
|
|
}
|
|
|
|
vi.mock("./doctor/shared/missing-configured-plugin-install.js", () => ({
|
|
repairMissingPluginInstallsForIds: mocks.repairMissingPluginInstallsForIds,
|
|
}));
|
|
|
|
vi.mock("../plugins/installed-plugin-index-records.js", () => ({
|
|
loadInstalledPluginIndexInstallRecords: mocks.loadInstalledPluginIndexInstallRecords,
|
|
}));
|
|
vi.mock("./onboarding-plugin-install.js", () => ({
|
|
ensureOnboardingPluginInstalled: mocks.ensureOnboardingPluginInstalled,
|
|
}));
|
|
describe("Codex runtime plugin install repair", () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
mocks.loadInstalledPluginIndexInstallRecords.mockResolvedValue({});
|
|
mocks.repairMissingPluginInstallsForIds.mockResolvedValue({
|
|
changes: [],
|
|
warnings: [],
|
|
});
|
|
mocks.ensureOnboardingPluginInstalled.mockResolvedValue({
|
|
cfg: {},
|
|
installed: false,
|
|
pluginId: "codex",
|
|
status: "failed",
|
|
});
|
|
});
|
|
|
|
it("surfaces non-fatal ClawHub repair notices to warning-only callers", async () => {
|
|
const reviewNotice = "REVIEW RECOMMENDED - ClawHub has not completed a fresh clean check";
|
|
mocks.repairMissingPluginInstallsForIds.mockResolvedValue({
|
|
changes: ['Repaired missing configured plugin "codex".'],
|
|
warnings: [],
|
|
notices: [reviewNotice],
|
|
});
|
|
|
|
const { repairCodexRuntimePluginInstallForModelSelection } =
|
|
await import("./codex-runtime-plugin-install.js");
|
|
const result = await repairCodexRuntimePluginInstallForModelSelection({
|
|
cfg: {},
|
|
model: "openai/gpt-5.5",
|
|
env: {},
|
|
});
|
|
|
|
const repairCall = readOnlyMissingPluginInstallRepairCall();
|
|
expect(repairCall.pluginIds).toStrictEqual(["codex"]);
|
|
expect(repairCall.env).toStrictEqual({});
|
|
expect(result).toStrictEqual({
|
|
required: true,
|
|
changes: ['Repaired missing configured plugin "codex".'],
|
|
warnings: [reviewNotice],
|
|
});
|
|
});
|
|
|
|
it.each([
|
|
["plugins disabled", { plugins: { enabled: false } }],
|
|
["denylisted", { plugins: { deny: ["codex"] } }],
|
|
["not allowlisted", { plugins: { allow: ["other"] } }],
|
|
])("does not report an existing Codex install as usable when %s", async (_label, cfg) => {
|
|
mocks.loadInstalledPluginIndexInstallRecords.mockResolvedValue({
|
|
codex: { source: "npm", installPath: process.cwd() },
|
|
});
|
|
const { ensureCodexRuntimePluginForModelSelection } =
|
|
await import("./codex-runtime-plugin-install.js");
|
|
|
|
const result = await ensureCodexRuntimePluginForModelSelection({
|
|
cfg,
|
|
model: "openai/gpt-5.5",
|
|
prompter: {} as never,
|
|
runtime: {} as never,
|
|
});
|
|
|
|
expect(result).toMatchObject({
|
|
cfg,
|
|
required: true,
|
|
installed: false,
|
|
status: "failed",
|
|
});
|
|
expect(result.reason).toBeTruthy();
|
|
});
|
|
|
|
it("enables an allowed existing Codex install", async () => {
|
|
mocks.loadInstalledPluginIndexInstallRecords.mockResolvedValue({
|
|
codex: { source: "npm", installPath: process.cwd() },
|
|
});
|
|
const cfg: OpenClawConfig = {
|
|
plugins: {
|
|
allow: ["codex"],
|
|
entries: { codex: { enabled: false } },
|
|
},
|
|
};
|
|
const { ensureCodexRuntimePluginForModelSelection } =
|
|
await import("./codex-runtime-plugin-install.js");
|
|
|
|
const result = await ensureCodexRuntimePluginForModelSelection({
|
|
cfg,
|
|
model: "openai/gpt-5.5",
|
|
prompter: {} as never,
|
|
runtime: {} as never,
|
|
});
|
|
|
|
expect(result).toMatchObject({
|
|
required: true,
|
|
installed: true,
|
|
status: "installed",
|
|
cfg: { plugins: { entries: { codex: { enabled: true } } } },
|
|
});
|
|
});
|
|
|
|
it("preserves the actionable installer error for setup callers", async () => {
|
|
mocks.ensureOnboardingPluginInstalled.mockResolvedValueOnce({
|
|
cfg: {},
|
|
installed: false,
|
|
pluginId: "codex",
|
|
status: "failed",
|
|
error: "npm registry returned EAI_AGAIN while fetching @openclaw/codex",
|
|
});
|
|
const { ensureCodexRuntimePluginForModelSelection } =
|
|
await import("./codex-runtime-plugin-install.js");
|
|
|
|
const result = await ensureCodexRuntimePluginForModelSelection({
|
|
cfg: {},
|
|
model: "openai/gpt-5.5",
|
|
prompter: {} as never,
|
|
runtime: {} as never,
|
|
});
|
|
|
|
expect(result).toMatchObject({
|
|
required: true,
|
|
installed: false,
|
|
status: "failed",
|
|
reason: "npm registry returned EAI_AGAIN while fetching @openclaw/codex",
|
|
});
|
|
});
|
|
|
|
it("sees an agent-scoped Codex runtime pin behind a custom OpenAI route", async () => {
|
|
mocks.loadInstalledPluginIndexInstallRecords.mockResolvedValue({
|
|
codex: { source: "npm", installPath: process.cwd() },
|
|
});
|
|
const cfg = {
|
|
agents: {
|
|
list: [
|
|
{
|
|
id: "ops",
|
|
default: true,
|
|
model: { primary: "openai/gpt-5.5" },
|
|
models: { "openai/gpt-5.5": { agentRuntime: { id: "codex" } } },
|
|
},
|
|
],
|
|
},
|
|
models: {
|
|
providers: {
|
|
openai: { baseUrl: "https://proxy.example.test/v1", models: [] },
|
|
},
|
|
},
|
|
};
|
|
const { ensureCodexRuntimePluginForModelSelection } =
|
|
await import("./codex-runtime-plugin-install.js");
|
|
|
|
const result = await ensureCodexRuntimePluginForModelSelection({
|
|
cfg,
|
|
model: "openai/gpt-5.5",
|
|
agentId: "ops",
|
|
prompter: {} as never,
|
|
runtime: {} as never,
|
|
});
|
|
|
|
expect(result).toMatchObject({
|
|
required: true,
|
|
installed: true,
|
|
status: "installed",
|
|
});
|
|
});
|
|
});
|