




















@@ -11,6 +11,7 @@ import type { SessionEntry } from "../config/sessions.js";
1111import type { OpenClawConfig } from "../config/types.openclaw.js";
1212import type * as ManifestRegistryModule from "../plugins/manifest-registry.js";
1313import { runAgentAttempt } from "./command/attempt-execution.js";
14+import type { RunEmbeddedPiAgentParams } from "./pi-embedded-runner/run/params.js";
1415import type { EmbeddedPiRunResult } from "./pi-embedded.js";
1516import { resolveProviderIdForAuth } from "./provider-auth-aliases.js";
1617@@ -68,6 +69,15 @@ vi.mock("./pi-embedded.js", () => ({
6869runEmbeddedPiAgent: runEmbeddedPiAgentMock,
6970}));
707172+function capturedEmbeddedRunParams(): RunEmbeddedPiAgentParams {
73+expect(runEmbeddedPiAgentMock).toHaveBeenCalledTimes(1);
74+const call = runEmbeddedPiAgentMock.mock.calls[0];
75+if (!call) {
76+throw new Error("expected runEmbeddedPiAgent to be called");
77+}
78+return call[0] as RunEmbeddedPiAgentParams;
79+}
80+7181function makeCliResult(text: string): EmbeddedPiRunResult {
7282return {
7383payloads: [{ text }],
@@ -377,10 +387,9 @@ describe("Auth profile runtime contract - Pi and CLI adapter", () => {
377387});
378388379389expect(runEmbeddedPiAgentMock).toHaveBeenCalledTimes(1);
380-expect(runEmbeddedPiAgentMock.mock.calls[0]?.[0]).toMatchObject({
381-provider: AUTH_PROFILE_RUNTIME_CONTRACT.openAiProvider,
382-authProfileId: AUTH_PROFILE_RUNTIME_CONTRACT.openAiProfileId,
383-});
390+const params = capturedEmbeddedRunParams();
391+expect(params.provider).toBe(AUTH_PROFILE_RUNTIME_CONTRACT.openAiProvider);
392+expect(params.authProfileId).toBe(AUTH_PROFILE_RUNTIME_CONTRACT.openAiProfileId);
384393});
385394386395it("forwards an OpenAI Codex auth profile through the default OpenAI Codex harness path", async () => {
@@ -393,9 +402,9 @@ describe("Auth profile runtime contract - Pi and CLI adapter", () => {
393402});
394403395404expect(runEmbeddedPiAgentMock).toHaveBeenCalledTimes(1);
396-expect(runEmbeddedPiAgentMock.mock.calls[0]?.[0]).toMatchObject({
397-authProfileId: AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId,
398-});
405+expect(capturedEmbeddedRunParams().authProfileId).toBe(
406+AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId,
407+);
399408});
400409401410it("routes explicit OpenAI PI runs with Codex OAuth through OpenAI Codex transport", async () => {
@@ -409,10 +418,9 @@ describe("Auth profile runtime contract - Pi and CLI adapter", () => {
409418});
410419411420expect(runEmbeddedPiAgentMock).toHaveBeenCalledTimes(1);
412-expect(runEmbeddedPiAgentMock.mock.calls[0]?.[0]).toMatchObject({
413-provider: AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProvider,
414-authProfileId: AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId,
415-});
421+const params = capturedEmbeddedRunParams();
422+expect(params.provider).toBe(AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProvider);
423+expect(params.authProfileId).toBe(AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId);
416424});
417425418426it("preserves OpenAI Codex auth profiles through the real codex/* harness startup path", async () => {
@@ -426,9 +434,9 @@ describe("Auth profile runtime contract - Pi and CLI adapter", () => {
426434});
427435428436expect(runEmbeddedPiAgentMock).toHaveBeenCalledTimes(1);
429-expect(runEmbeddedPiAgentMock.mock.calls[0]?.[0]).toMatchObject({
430-authProfileId: AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId,
431-});
437+expect(capturedEmbeddedRunParams().authProfileId).toBe(
438+AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId,
439+);
432440});
433441434442it("validates openai/* forced through the Codex harness can use OpenAI Codex OAuth profiles", async () => {
@@ -442,9 +450,9 @@ describe("Auth profile runtime contract - Pi and CLI adapter", () => {
442450});
443451444452expect(runEmbeddedPiAgentMock).toHaveBeenCalledTimes(1);
445-expect(runEmbeddedPiAgentMock.mock.calls[0]?.[0]).toMatchObject({
446-authProfileId: AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId,
447-});
453+expect(capturedEmbeddedRunParams().authProfileId).toBe(
454+AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId,
455+);
448456});
449457450458it("preserves configured Codex harness when a skeleton session entry is considered history", async () => {
@@ -459,8 +467,8 @@ describe("Auth profile runtime contract - Pi and CLI adapter", () => {
459467});
460468461469expect(runEmbeddedPiAgentMock).toHaveBeenCalledTimes(1);
462-expect(runEmbeddedPiAgentMock.mock.calls[0]?.[0]).toMatchObject({
463-authProfileId: AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId,
464-});
470+expect(capturedEmbeddedRunParams().authProfileId).toBe(
471+AUTH_PROFILE_RUNTIME_CONTRACT.openAiCodexProfileId,
472+);
465473});
466474});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。