























@@ -1273,20 +1273,19 @@ describe("runCodexAppServerAttempt", () => {
12731273});
12741274await vi.waitFor(() => expect(handleRequest).toBeTypeOf("function"), { interval: 1 });
127512751276-await expect(
1277-handleRequest?.({
1278-id: "request-tool-1",
1279-method: "item/tool/call",
1280-params: {
1281-threadId: "thread-1",
1282-turnId: "turn-1",
1283-callId: "call-1",
1284-namespace: null,
1285-tool: "message",
1286-arguments: { action: "send", text: "already sent" },
1287-},
1288-}),
1289-).resolves.toMatchObject({ success: false });
1276+const toolResult = (await handleRequest?.({
1277+id: "request-tool-1",
1278+method: "item/tool/call",
1279+params: {
1280+threadId: "thread-1",
1281+turnId: "turn-1",
1282+callId: "call-1",
1283+namespace: null,
1284+tool: "message",
1285+arguments: { action: "send", text: "already sent" },
1286+},
1287+})) as { success?: boolean };
1288+expect(toolResult.success).toBe(false);
12901289await notify({
12911290method: "rawResponseItem/completed",
12921291params: {
@@ -1301,29 +1300,42 @@ describe("runCodexAppServerAttempt", () => {
13011300},
13021301});
130313021304-await expect(run).resolves.toMatchObject({
1305-aborted: true,
1306-timedOut: true,
1307-promptError: "codex app-server turn idle timed out waiting for turn/completed",
1308-});
1309-expect(warn).toHaveBeenCalledWith(
1310-"codex app-server turn idle timed out waiting for terminal event",
1311-expect.objectContaining({
1312-threadId: "thread-1",
1313-turnId: "turn-1",
1314-timeoutMs: 5,
1315-lastActivityReason: "notification:rawResponseItem/completed",
1316-lastNotificationMethod: "rawResponseItem/completed",
1317-lastNotificationItemId: "raw-status-1",
1318-lastNotificationItemType: "message",
1319-lastNotificationItemRole: "assistant",
1320-lastAssistantTextPreview: "I'm writing the report now.",
1321-}),
1303+const result = await run;
1304+expect(result.aborted).toBe(true);
1305+expect(result.timedOut).toBe(true);
1306+expect(result.promptError).toBe(
1307+"codex app-server turn idle timed out waiting for turn/completed",
13221308);
1323-expect(warn).not.toHaveBeenCalledWith(
1324-"codex app-server turn idle timed out waiting for completion",
1325-expect.anything(),
1309+const terminalWarnCall = warn.mock.calls.find(
1310+([message]) => message === "codex app-server turn idle timed out waiting for terminal event",
13261311);
1312+const terminalWarnData = terminalWarnCall?.[1] as
1313+| {
1314+lastActivityReason?: string;
1315+lastAssistantTextPreview?: string;
1316+lastNotificationItemId?: string;
1317+lastNotificationItemRole?: string;
1318+lastNotificationItemType?: string;
1319+lastNotificationMethod?: string;
1320+threadId?: string;
1321+timeoutMs?: number;
1322+turnId?: string;
1323+}
1324+| undefined;
1325+expect(terminalWarnData?.threadId).toBe("thread-1");
1326+expect(terminalWarnData?.turnId).toBe("turn-1");
1327+expect(terminalWarnData?.timeoutMs).toBe(5);
1328+expect(terminalWarnData?.lastActivityReason).toBe("notification:rawResponseItem/completed");
1329+expect(terminalWarnData?.lastNotificationMethod).toBe("rawResponseItem/completed");
1330+expect(terminalWarnData?.lastNotificationItemId).toBe("raw-status-1");
1331+expect(terminalWarnData?.lastNotificationItemType).toBe("message");
1332+expect(terminalWarnData?.lastNotificationItemRole).toBe("assistant");
1333+expect(terminalWarnData?.lastAssistantTextPreview).toBe("I'm writing the report now.");
1334+expect(
1335+warn.mock.calls.some(
1336+([message]) => message === "codex app-server turn idle timed out waiting for completion",
1337+),
1338+).toBe(false);
13271339});
1328134013291341it("releases the session when Codex accepts a turn but never sends progress", async () => {
@@ -1337,11 +1349,12 @@ describe("runCodexAppServerAttempt", () => {
13371349const run = runCodexAppServerAttempt(params, { turnTerminalIdleTimeoutMs: 5 });
13381350await harness.waitForMethod("turn/start");
133913511340-await expect(run).resolves.toMatchObject({
1341-aborted: true,
1342-timedOut: true,
1343-promptError: "codex app-server turn idle timed out waiting for turn/completed",
1344-});
1352+const result = await run;
1353+expect(result.aborted).toBe(true);
1354+expect(result.timedOut).toBe(true);
1355+expect(result.promptError).toBe(
1356+"codex app-server turn idle timed out waiting for turn/completed",
1357+);
13451358await vi.waitFor(
13461359() =>
13471360expect(harness.request).toHaveBeenCalledWith("turn/interrupt", {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。