

























@@ -108,6 +108,16 @@ function makeLeaseStore() {
108108};
109109}
110110111+function readFirstEnsureSessionInput(ensure: {
112+mock: { calls: Array<Array<unknown>> };
113+}): Parameters<AcpRuntime["ensureSession"]>[0] {
114+const input = ensure.mock.calls[0]?.[0];
115+if (typeof input !== "object" || input === null) {
116+throw new Error("Expected ensureSession to be called with an input object");
117+}
118+return input as Parameters<AcpRuntime["ensureSession"]>[0];
119+}
120+111121describe("AcpxRuntime fresh reset wrapper", () => {
112122beforeEach(() => {
113123vi.restoreAllMocks();
@@ -174,11 +184,12 @@ describe("AcpxRuntime fresh reset wrapper", () => {
174184model: "openai-codex/gpt-5.4",
175185});
176186177-expect(ensure).toHaveBeenCalledWith(
178-expect.objectContaining({
179-model: "gpt-5.4",
180-}),
181-);
187+expect(readFirstEnsureSessionInput(ensure)).toEqual({
188+sessionKey: "agent:codex:acp:test",
189+agent: "codex",
190+mode: "persistent",
191+model: "gpt-5.4",
192+});
182193});
183194184195it("leaves Codex ACP startup defaults alone when no model or thinking is provided", async () => {
@@ -204,13 +215,14 @@ describe("AcpxRuntime fresh reset wrapper", () => {
204215mode: "persistent",
205216});
206217207-expect(ensure).toHaveBeenCalledWith(
208-expect.objectContaining({
209-agent: "codex",
210-}),
211-);
212-expect(ensure.mock.calls[0]?.[0]).not.toHaveProperty("model");
213-expect(ensure.mock.calls[0]?.[0]).not.toHaveProperty("thinking");
218+const ensureInput = readFirstEnsureSessionInput(ensure);
219+expect(ensureInput).toEqual({
220+sessionKey: "agent:codex:acp:test",
221+agent: "codex",
222+mode: "persistent",
223+});
224+expect(ensureInput).not.toHaveProperty("model");
225+expect(ensureInput).not.toHaveProperty("thinking");
214226});
215227216228it("does not normalize model startup for non-Codex ACP agents", async () => {
@@ -237,12 +249,12 @@ describe("AcpxRuntime fresh reset wrapper", () => {
237249model: "openai-codex/gpt-5.5",
238250});
239251240-expect(ensure).toHaveBeenCalledWith(
241-expect.objectContaining({
242- agent: "main",
243- model: "openai-codex/gpt-5.5",
244-}),
245-);
252+expect(readFirstEnsureSessionInput(ensure)).toEqual({
253+sessionKey: "agent:main:acp:test",
254+agent: "main",
255+mode: "persistent",
256+model: "openai-codex/gpt-5.5",
257+});
246258});
247259248260it("injects Codex ACP startup config into the scoped registry", () => {
@@ -283,11 +295,12 @@ describe("AcpxRuntime fresh reset wrapper", () => {
283295model: "openai-codex/gpt-5.5",
284296});
285297286-expect(ensure).toHaveBeenCalledWith(
287-expect.objectContaining({
288-model: "gpt-5.5",
289-}),
290-);
298+expect(readFirstEnsureSessionInput(ensure)).toEqual({
299+sessionKey: "agent:codex:acp:test",
300+agent: "codex",
301+mode: "persistent",
302+model: "gpt-5.5",
303+});
291304});
292305293306it("maps explicit Codex ACP thinking to startup reasoning effort", async () => {
@@ -315,11 +328,13 @@ describe("AcpxRuntime fresh reset wrapper", () => {
315328thinking: "x-high",
316329});
317330318-expect(ensure).toHaveBeenCalledWith(
319-expect.objectContaining({
320-model: "gpt-5.4/xhigh",
321-}),
322-);
331+expect(readFirstEnsureSessionInput(ensure)).toEqual({
332+sessionKey: "agent:codex:acp:test",
333+agent: "codex",
334+mode: "persistent",
335+model: "gpt-5.4/xhigh",
336+thinking: "x-high",
337+});
323338});
324339325340it("normalizes Codex ACP model config controls to adapter ids", async () => {
@@ -929,9 +944,10 @@ describe("AcpxRuntime fresh reset wrapper", () => {
929944{ pid: 941, signal: "SIGTERM" },
930945{ pid: 940, signal: "SIGTERM" },
931946]);
932-expect(leaseStore.store.markState).not.toHaveBeenCalledWith("lease-old", expect.any(String));
933-expect(leaseStore.store.markState).toHaveBeenCalledWith("lease-current", "closing");
934-expect(leaseStore.store.markState).toHaveBeenLastCalledWith("lease-current", "closed");
947+expect(leaseStore.store.markState.mock.calls).toEqual([
948+["lease-current", "closing"],
949+["lease-current", "closed"],
950+]);
935951});
936952937953it("does not clean up a stale close pid reused by another wrapper root", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。