

























@@ -1889,8 +1889,8 @@ describe("dispatchReplyFromConfig", () => {
18891889});
1890189018911891expect(dispatcher.sendToolResult).toHaveBeenCalledTimes(1);
1892-expect(dispatcher.sendToolResult).toHaveBeenCalledWith(
1893-expect.objectContaining({ mediaUrl: "https://example.com/tts-preview.opus" }),
1892+expect(firstToolResultPayload(dispatcher)?.mediaUrl).toBe(
1893+"https://example.com/tts-preview.opus",
18941894);
18951895expect(dispatcher.sendFinalReply).toHaveBeenCalledWith({ text: "done" });
18961896});
@@ -1931,17 +1931,13 @@ describe("dispatchReplyFromConfig", () => {
19311931});
1932193219331933expect(dispatcher.sendToolResult).toHaveBeenCalledTimes(1);
1934-expect(firstToolResultPayload(dispatcher)).toEqual(
1935-expect.objectContaining({
1936-channelData: {
1937-execApproval: {
1938-approvalId: "117ba06d-1111-2222-3333-444444444444",
1939-approvalSlug: "117ba06d",
1940-allowedDecisions: ["allow-once", "allow-always", "deny"],
1941-},
1942-},
1943-}),
1944-);
1934+expect(firstToolResultPayload(dispatcher)?.channelData).toStrictEqual({
1935+execApproval: {
1936+approvalId: "117ba06d-1111-2222-3333-444444444444",
1937+approvalSlug: "117ba06d",
1938+allowedDecisions: ["allow-once", "allow-always", "deny"],
1939+},
1940+});
19451941expect(dispatcher.sendFinalReply).toHaveBeenCalledWith({ text: "NO_REPLY" });
19461942});
19471943@@ -2059,21 +2055,21 @@ describe("dispatchReplyFromConfig", () => {
20592055await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
2060205620612057expect(replyResolver).not.toHaveBeenCalled();
2062-expect(runtime.ensureSession).toHaveBeenCalledWith(
2063-expect.objectContaining({
2064-sessionKey: "agent:codex-acp:session-1",
2065-agent: "codex",
2066-mode: "persistent",
2067-}),
2068-);
2058+const ensureSessionOptions = runtime.ensureSession.mock.calls[0]?.[0] as
2059+| { agent?: unknown; mode?: unknown; sessionKey?: unknown }
2060+| undefined;
2061+expect(ensureSessionOptions?.sessionKey).toBe("agent:codex-acp:session-1");
2062+expect(ensureSessionOptions?.agent).toBe("codex");
2063+expect(ensureSessionOptions?.mode).toBe("persistent");
20692064const blockCalls = (dispatcher.sendBlockReply as ReturnType<typeof vi.fn>).mock.calls;
20702065expect(blockCalls.length).toBeGreaterThan(0);
20712066const streamedText = blockCalls.map((call) => (call[0] as ReplyPayload).text ?? "").join("");
20722067expect(streamedText).toContain("hello");
20732068expect(streamedText).toContain("world");
2074-expect(dispatcher.sendFinalReply).toHaveBeenCalledWith(
2075-expect.objectContaining({ text: "hello world" }),
2076-);
2069+const finalPayload = (dispatcher.sendFinalReply as Mock).mock.calls[0]?.[0] as
2070+| ReplyPayload
2071+| undefined;
2072+expect(finalPayload?.text).toBe("hello world");
20772073});
2078207420792075it("emits lifecycle end for ACP turns using the current run id", async () => {
@@ -2122,16 +2118,20 @@ describe("dispatchReplyFromConfig", () => {
21222118},
21232119});
212421202125-expect(agentEventMocks.emitAgentEvent).toHaveBeenCalledWith(
2126-expect.objectContaining({
2127-runId: "run-acp-lifecycle-end",
2128-sessionKey: "agent:codex-acp:session-1",
2129-stream: "lifecycle",
2130-data: expect.objectContaining({
2131-phase: "end",
2132-}),
2133-}),
2134-);
2121+const lifecycleEvent = agentEventMocks.emitAgentEvent.mock.calls
2122+.map(
2123+(call) =>
2124+call[0] as {
2125+data?: { phase?: unknown };
2126+runId?: unknown;
2127+sessionKey?: unknown;
2128+stream?: unknown;
2129+},
2130+)
2131+.find((event) => event.runId === "run-acp-lifecycle-end");
2132+expect(lifecycleEvent?.sessionKey).toBe("agent:codex-acp:session-1");
2133+expect(lifecycleEvent?.stream).toBe("lifecycle");
2134+expect(lifecycleEvent?.data?.phase).toBe("end");
21352135});
2136213621372137it("emits lifecycle error for ACP turn failures using the current run id", async () => {
@@ -2184,17 +2184,21 @@ describe("dispatchReplyFromConfig", () => {
21842184},
21852185});
218621862187-expect(agentEventMocks.emitAgentEvent).toHaveBeenCalledWith(
2188-expect.objectContaining({
2189-runId: "run-acp-lifecycle-error",
2190-sessionKey: "agent:codex-acp:session-1",
2191-stream: "lifecycle",
2192-data: expect.objectContaining({
2193-phase: "error",
2194-error: expect.stringContaining("ACP exploded"),
2195-}),
2196-}),
2197-);
2187+const lifecycleEvent = agentEventMocks.emitAgentEvent.mock.calls
2188+.map(
2189+(call) =>
2190+call[0] as {
2191+data?: { error?: unknown; phase?: unknown };
2192+runId?: unknown;
2193+sessionKey?: unknown;
2194+stream?: unknown;
2195+},
2196+)
2197+.find((event) => event.runId === "run-acp-lifecycle-error");
2198+expect(lifecycleEvent?.sessionKey).toBe("agent:codex-acp:session-1");
2199+expect(lifecycleEvent?.stream).toBe("lifecycle");
2200+expect(lifecycleEvent?.data?.phase).toBe("error");
2201+expect(String(lifecycleEvent?.data?.error)).toContain("ACP exploded");
21982202});
2199220322002204it("posts a one-time resolved-session-id notice in thread after the first ACP turn", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。