


























@@ -156,6 +156,19 @@ function createMockRuntime(overrides: Record<string, unknown> = {}) {
156156};
157157}
158158159+function readFirstRuntimeFactoryInput(runtimeFactory: { mock: { calls: Array<Array<unknown>> } }) {
160+const input = runtimeFactory.mock.calls[0]?.[0];
161+if (typeof input !== "object" || input === null) {
162+throw new Error("Expected runtimeFactory to be called with an options object");
163+}
164+return input as {
165+pluginConfig: {
166+timeoutSeconds?: number;
167+probeAgent?: string;
168+};
169+};
170+}
171+159172describe("createAcpxRuntimeService", () => {
160173it("registers and unregisters the embedded backend", async () => {
161174const workspaceDir = await makeTempDir();
@@ -371,12 +384,13 @@ describe("createAcpxRuntimeService", () => {
371384if (!backend) {
372385throw new Error("expected ACPX runtime backend");
373386}
374-expect(backend.runtime).toMatchObject({
375-ensureSession: expect.any(Function),
376-});
387+const backendRuntime = backend.runtime as {
388+ensureSession(input: { agent: string; mode: string; sessionKey: string }): Promise<unknown>;
389+};
390+expect(typeof backendRuntime.ensureSession).toBe("function");
377391expect(acpxRuntimeConstructorMock).not.toHaveBeenCalled();
378392379-await backend.runtime.ensureSession({
393+await backendRuntime.ensureSession({
380394agent: "codex",
381395mode: "oneshot",
382396sessionKey: "agent:codex:acp:test",
@@ -442,13 +456,7 @@ describe("createAcpxRuntimeService", () => {
442456443457await service.start(ctx);
444458445-expect(runtimeFactory).toHaveBeenCalledWith(
446-expect.objectContaining({
447-pluginConfig: expect.objectContaining({
448-timeoutSeconds: 120,
449-}),
450-}),
451-);
459+expect(readFirstRuntimeFactoryInput(runtimeFactory).pluginConfig.timeoutSeconds).toBe(120);
452460453461await service.stop?.(ctx);
454462});
@@ -473,13 +481,7 @@ describe("createAcpxRuntimeService", () => {
473481474482await service.start(ctx);
475483476-expect(runtimeFactory).toHaveBeenCalledWith(
477-expect.objectContaining({
478-pluginConfig: expect.objectContaining({
479-probeAgent: "opencode",
480-}),
481-}),
482-);
484+expect(readFirstRuntimeFactoryInput(runtimeFactory).pluginConfig.probeAgent).toBe("opencode");
483485484486await service.stop?.(ctx);
485487});
@@ -500,13 +502,7 @@ describe("createAcpxRuntimeService", () => {
500502501503await service.start(ctx);
502504503-expect(runtimeFactory).toHaveBeenCalledWith(
504-expect.objectContaining({
505-pluginConfig: expect.objectContaining({
506-probeAgent: "opencode",
507-}),
508-}),
509-);
505+expect(readFirstRuntimeFactoryInput(runtimeFactory).pluginConfig.probeAgent).toBe("opencode");
510506511507await service.stop?.(ctx);
512508});
@@ -528,13 +524,7 @@ describe("createAcpxRuntimeService", () => {
528524529525await service.start(ctx);
530526531-expect(runtimeFactory).toHaveBeenCalledWith(
532-expect.objectContaining({
533-pluginConfig: expect.objectContaining({
534-probeAgent: "codex",
535-}),
536-}),
537-);
527+expect(readFirstRuntimeFactoryInput(runtimeFactory).pluginConfig.probeAgent).toBe("codex");
538528539529await service.stop?.(ctx);
540530});
@@ -579,9 +569,7 @@ describe("createAcpxRuntimeService", () => {
579569await service.start(ctx);
580570581571expect(probeAvailability).not.toHaveBeenCalled();
582-expect(getAcpRuntimeBackend("acpx")).toMatchObject({
583-runtime: expect.any(Object),
584-});
572+expect(getAcpRuntimeBackend("acpx")?.runtime).toBe(runtime);
585573expect(getAcpRuntimeBackend("acpx")?.healthy).toBeUndefined();
586574587575await service.stop?.(ctx);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。