




























@@ -26,13 +26,20 @@ const configIoMocks = vi.hoisted(() => ({
2626loadConfig: vi.fn(),
2727readConfigFileSnapshotForWrite: vi.fn(),
2828}));
29+const pluginRegistryMocks = vi.hoisted(() => ({
30+ensurePluginRegistryLoaded: vi.fn(),
31+}));
29323033vi.mock("../config/io.js", () => ({
3134getRuntimeConfig: configIoMocks.loadConfig,
3235loadConfig: configIoMocks.loadConfig,
3336readConfigFileSnapshotForWrite: configIoMocks.readConfigFileSnapshotForWrite,
3437}));
353839+vi.mock("../plugins/runtime/runtime-registry-loader.js", () => ({
40+ensurePluginRegistryLoaded: pluginRegistryMocks.ensurePluginRegistryLoaded,
41+}));
42+3643vi.mock("../agents/auth-profiles/store.js", () => {
3744const createEmptyStore = () => ({ version: 1, profiles: {} });
3845return {
@@ -329,6 +336,55 @@ beforeEach(() => {
329336});
330337331338describe("agentCommand", () => {
339+it("enables the Codex runtime plugin for one-shot OpenAI model overrides", async () => {
340+await withTempHome(async (home) => {
341+const storePath = path.join(home, "sessions.json");
342+mockConfig(home, storePath, { models: undefined });
343+344+await agentCommand(
345+{
346+message: "hi",
347+agentId: "main",
348+model: "openai/gpt-5.2",
349+allowModelOverride: true,
350+},
351+runtime,
352+);
353+354+expect(pluginRegistryMocks.ensurePluginRegistryLoaded).toHaveBeenCalledWith({
355+scope: "all",
356+config: expect.any(Object),
357+activationSourceConfig: expect.any(Object),
358+workspaceDir: path.join(home, "openclaw"),
359+onlyPluginIds: ["codex"],
360+});
361+expectLastRunProviderModel("openai", "gpt-5.2");
362+});
363+});
364+365+it("does not enable Codex for one-shot OpenAI overrides when the agent forces PI", async () => {
366+await withTempHome(async (home) => {
367+const storePath = path.join(home, "sessions.json");
368+mockConfig(home, storePath, {
369+agentRuntime: { id: "pi" },
370+models: undefined,
371+});
372+373+await agentCommand(
374+{
375+message: "hi",
376+agentId: "main",
377+model: "openai/gpt-5.2",
378+allowModelOverride: true,
379+},
380+runtime,
381+);
382+383+expect(pluginRegistryMocks.ensurePluginRegistryLoaded).not.toHaveBeenCalled();
384+expectLastRunProviderModel("openai", "gpt-5.2");
385+});
386+});
387+332388it("enforces ingress trust flags", async () => {
333389await expect(
334390// Runtime guard for non-TS callers; TS callsites are statically typed.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。