diff --git a/apps/server/scripts/record-grok-acp-replay-fixture.ts b/apps/server/scripts/record-grok-acp-replay-fixture.ts index d7c7da2c8e08..fbf381f50537 100644 --- a/apps/server/scripts/record-grok-acp-replay-fixture.ts +++ b/apps/server/scripts/record-grok-acp-replay-fixture.ts @@ -16,7 +16,6 @@ import { HostProcessEnvironment, HostProcessPlatform } from "@t3tools/shared/hos import { resolveSelfInvocation } from "@t3tools/shared/nodeRuntime"; import * as Clock from "effect/Clock"; import * as Console from "effect/Console"; -import * as Crypto from "effect/Crypto"; import * as Effect from "effect/Effect"; import * as FileSystem from "effect/FileSystem"; import * as Layer from "effect/Layer"; @@ -25,7 +24,6 @@ import * as Schema from "effect/Schema"; import { ChildProcessSpawner } from "effect/process"; import type * as EffectAcpProtocol from "effect-acp/protocol"; -import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost"; import { layerTestProviderHost } from "@t3tools/provider-testing/host"; import { GROK_DEFAULT_INSTANCE_ID, @@ -447,16 +445,11 @@ const recordScenario = Effect.fn("recordGrokScenario")(function* (fixtureName: s Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; const environment = yield* HostProcessEnvironment; - const adapter = makeGrokAdapterV2({ + const adapter = yield* makeGrokAdapterV2({ instanceId: GROK_DEFAULT_INSTANCE_ID, settings, environment, hostPlatform: yield* HostProcessPlatform, - childProcessSpawner, - crypto: yield* Crypto.Crypto, - fileSystem: yield* FileSystem.FileSystem, - idAllocator: yield* IdAllocator.IdAllocatorV2, - host: yield* ProviderHost.ProviderHost, selfInvocation: yield* resolveSelfInvocation(), continuationRequests: yield* ProviderContinuationRequests.ProviderContinuationRequests, // Production's runtime factory, with the protocol logger teeing raw lines. diff --git a/apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts index 62bff5add8ef..a8c958209214 100644 --- a/apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts @@ -30,7 +30,6 @@ import { GrokSettings } from "@t3tools/provider-grok/settings"; import { HostProcessIsExecutable, HostProcessPlatform } from "@t3tools/shared/hostProcess"; import { resolveSelfInvocation } from "@t3tools/shared/nodeRuntime"; import * as DateTime from "effect/DateTime"; -import * as Crypto from "effect/Crypto"; import * as Deferred from "effect/Deferred"; import type * as Duration from "effect/Duration"; import * as Cause from "effect/Cause"; @@ -54,7 +53,6 @@ import * as EffectAcpErrors from "effect-acp/errors"; import type * as EffectAcpProtocol from "effect-acp/protocol"; import type * as EffectAcpSchema from "effect-acp/compat"; -import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost"; import { layerTestProviderHost } from "@t3tools/provider-testing/host"; import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession"; import * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime"; @@ -610,12 +608,8 @@ describe("AcpAdapterV2", () => { const path = yield* Path.Path; const instanceId = ProviderInstanceId.make(`vibe-retry-${outcome}`); const threadId = ThreadId.make(`thread-vibe-retry-${outcome}`); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, - fileSystem: yield* FileSystem.FileSystem, - idAllocator: yield* IdAllocator.IdAllocatorV2, - host: yield* ProviderHost.ProviderHost, selfInvocation: yield* resolveSelfInvocation(), flavor: { driver: ProviderDriverKind.make("acpRegistry"), @@ -709,10 +703,7 @@ describe("AcpAdapterV2", () => { it.effect("starts the MCP bridge directly from the self-contained runtime", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation().pipe( Effect.provideService(HostProcessIsExecutable, true), ); @@ -739,8 +730,7 @@ describe("AcpAdapterV2", () => { let runtimeInput: AcpAdapterV2RuntimeInput | undefined; const makeRuntime = makeMockRuntime({ childProcessSpawner, mockAgentPath }); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -750,9 +740,6 @@ describe("AcpAdapterV2", () => { runtimeInput = input; }).pipe(Effect.andThen(makeRuntime(input))), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({ @@ -782,10 +769,7 @@ describe("AcpAdapterV2", () => { it.live("refreshes ACP prompt instructions when the interaction mode changes", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -805,17 +789,13 @@ describe("AcpAdapterV2", () => { yield* Effect.addFinalizer(() => Effect.sync(() => McpProviderSession.clearMcpProviderSession(threadId)), ); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, capabilities: AcpProviderCapabilitiesV2, makeRuntime: makeMockRuntime({ childProcessSpawner, mockAgentPath, protocolEvents }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const policy = (interactionMode: "default" | "plan") => @@ -909,10 +889,7 @@ describe("AcpAdapterV2", () => { it.effect("starts a new replay message after ACP v2 plan boundaries", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -920,8 +897,7 @@ describe("AcpAdapterV2", () => { type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"]; let sessionUpdateHandler: Parameters[0] | undefined; const instanceId = ProviderInstanceId.make("acp-test-v2-plan-replay-boundary"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -938,9 +914,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-v2-plan-replay-boundary"); @@ -1043,12 +1016,8 @@ describe("AcpAdapterV2", () => { ]; }; const instanceId = ProviderInstanceId.make("devin-streamed-write"); - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ instanceId, - crypto: yield* Crypto.Crypto, - fileSystem: yield* FileSystem.FileSystem, - idAllocator: yield* IdAllocator.IdAllocatorV2, - host: yield* ProviderHost.ProviderHost, selfInvocation: yield* resolveSelfInvocation(), flavor: { driver: ACP_TEST_DRIVER, @@ -1178,7 +1147,6 @@ describe("AcpAdapterV2", () => { it.effect("keeps Devin parent paragraphs intact while projecting native child work", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -1187,14 +1155,10 @@ describe("AcpAdapterV2", () => { let handler: Parameters[0] | undefined; let createTerminal: Parameters[0] | undefined; const instanceId = ProviderInstanceId.make("devin-replay"); - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ instanceId, // Production Devin runs commands through client terminals. clientTerminals: { childProcessSpawner, shellCommands: true }, - crypto: yield* Crypto.Crypto, - fileSystem: yield* FileSystem.FileSystem, - idAllocator, - host: yield* ProviderHost.ProviderHost, selfInvocation: yield* resolveSelfInvocation(), flavor: { driver: ACP_TEST_DRIVER, @@ -1511,10 +1475,7 @@ describe("AcpAdapterV2", () => { it.effect("projects ACP v2 fidelity updates into first-class orchestration items", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -1522,8 +1483,7 @@ describe("AcpAdapterV2", () => { type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"]; let sessionUpdateHandler: Parameters[0] | undefined; const instanceId = ProviderInstanceId.make("acp-test-v2-fidelity"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -1541,9 +1501,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-v2-fidelity"); @@ -1705,18 +1662,15 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const protocolEvents = yield* Queue.unbounded(); const instanceId = ProviderInstanceId.make("acp-test-eager-resume"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -1727,9 +1681,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-eager-resume"); @@ -1790,18 +1741,15 @@ describe("AcpAdapterV2", () => { it.live("preserves new-session fallback when an eager ACP session load is stale", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const protocolEvents = yield* Queue.unbounded(); const instanceId = ProviderInstanceId.make("acp-test-stale-eager-resume"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -1814,9 +1762,6 @@ describe("AcpAdapterV2", () => { runtimeOrdinal === 1 ? { T3_ACP_FAIL_LOAD_SESSION: "1" } : {}, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-stale-eager-resume"); @@ -1936,10 +1881,7 @@ describe("AcpAdapterV2", () => { it.live("replaces an unexpectedly terminated ACP runtime before the next turn", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -1955,8 +1897,7 @@ describe("AcpAdapterV2", () => { }, }); const instanceId = ProviderInstanceId.make("acp-test-unexpected-termination"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -1966,9 +1907,6 @@ describe("AcpAdapterV2", () => { runtimeInputs.push(runtimeInput); }).pipe(Effect.andThen(baseMakeRuntime(runtimeInput))), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-unexpected-termination"); @@ -2020,9 +1958,7 @@ describe("AcpAdapterV2", () => { if ((yield* HostProcessPlatform) !== "linux") return; const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -2034,8 +1970,7 @@ describe("AcpAdapterV2", () => { Effect.sync(() => cleanupPublishedDetachedFixture(commandPidPath)), ); const instanceId = ProviderInstanceId.make("acp-test-provider-exit"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -2055,9 +1990,6 @@ describe("AcpAdapterV2", () => { }, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-provider-exit-running-command"); @@ -2104,10 +2036,7 @@ describe("AcpAdapterV2", () => { Effect.gen(function* () { if ((yield* HostProcessPlatform) !== "linux") return; const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -2116,8 +2045,7 @@ describe("AcpAdapterV2", () => { | AcpSessionRuntime.AcpSessionRuntime["Service"]["processContainment"] | undefined; const instanceId = ProviderInstanceId.make("acp-test-cgroup-unavailable"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -2134,9 +2062,6 @@ describe("AcpAdapterV2", () => { }, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-cgroup-unavailable"); @@ -2160,10 +2085,7 @@ describe("AcpAdapterV2", () => { it.live("cleans a cgroup lease when the pre-exec join wrapper fails", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -2192,8 +2114,7 @@ describe("AcpAdapterV2", () => { }, }; const instanceId = ProviderInstanceId.make("acp-test-cgroup-join-failure"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -2206,9 +2127,6 @@ describe("AcpAdapterV2", () => { ownDetachedProcessGroup: true, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-cgroup-join-failure"); @@ -2238,10 +2156,7 @@ describe("AcpAdapterV2", () => { it.effect("negotiates and executes optional native session forks through the ACP runtime", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -2275,17 +2190,13 @@ describe("AcpAdapterV2", () => { }); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, capabilities: AcpProviderCapabilitiesV2, makeRuntime, }, - fileSystem, - idAllocator, - host, selfInvocation, clientTerminals: { childProcessSpawner }, }); @@ -2451,9 +2362,7 @@ describe("AcpAdapterV2", () => { Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -2465,8 +2374,7 @@ describe("AcpAdapterV2", () => { const probeLogPath = path.join(workspace, "fs-probe.jsonl"); const protocolEvents = yield* Queue.unbounded(); const instanceId = ProviderInstanceId.make("acp-test-no-client-fs"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -2481,9 +2389,6 @@ describe("AcpAdapterV2", () => { }, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-no-client-fs"); @@ -2547,10 +2452,7 @@ describe("AcpAdapterV2", () => { it.effect("does not turn an unknown permission approval into an execute grant", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -2576,8 +2478,7 @@ describe("AcpAdapterV2", () => { }), }); const instanceId = ProviderInstanceId.make("acp-test-unknown-permission-grant"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -2588,9 +2489,6 @@ describe("AcpAdapterV2", () => { runtimeInput = input; }).pipe(Effect.andThen(makeRuntime(input))), }, - fileSystem, - idAllocator, - host, selfInvocation, clientTerminals: { childProcessSpawner }, }); @@ -2684,26 +2582,19 @@ describe("AcpAdapterV2", () => { it.effect("fails missing native ACP session ids through the typed start-turn error channel", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const instanceId = ProviderInstanceId.make("acp-test-missing-native-thread"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, capabilities: AcpProviderCapabilitiesV2, makeRuntime: makeMockRuntime({ childProcessSpawner, mockAgentPath }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-missing-native-thread"); @@ -2746,10 +2637,8 @@ describe("AcpAdapterV2", () => { it.effect("replaces the ACP session and clears conversation state on rollback", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -2774,8 +2663,7 @@ describe("AcpAdapterV2", () => { mockAgentPath, environment: { T3_ACP_PROMPT_DELAY_MS: "100" }, }); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -2785,9 +2673,6 @@ describe("AcpAdapterV2", () => { Effect.andThen(makeRuntime(runtimeInput)), ), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-rollback-session"); @@ -2913,10 +2798,7 @@ describe("AcpAdapterV2", () => { it.effect("quarantines callbacks from a failed rollback replacement before retrying", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -2979,8 +2861,7 @@ describe("AcpAdapterV2", () => { }, }); const instanceId = ProviderInstanceId.make("acp-test-rollback-retry-generation"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -2998,9 +2879,6 @@ describe("AcpAdapterV2", () => { }), makeRuntime, }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: () => Effect.void }, }); @@ -3074,10 +2952,8 @@ describe("AcpAdapterV2", () => { it.effect("keeps the original ACP session usable when a staged replacement terminates", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -3109,17 +2985,13 @@ describe("AcpAdapterV2", () => { }; }); const instanceId = ProviderInstanceId.make("acp-test-rollback-failure-compensation"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, capabilities: AcpProviderCapabilitiesV2, makeRuntime, }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-rollback-failure-compensation"); @@ -3190,27 +3062,20 @@ describe("AcpAdapterV2", () => { it.effect("closes an idle ACP session exactly once through the transition permit", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const protocolEvents = yield* Queue.bounded(256); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, capabilities: AcpProviderCapabilitiesV2, makeRuntime: makeMockRuntime({ childProcessSpawner, mockAgentPath, protocolEvents }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-idle-finalizer"); @@ -3241,26 +3106,18 @@ describe("AcpAdapterV2", () => { (model) => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const protocolEvents = yield* Queue.unbounded(); const instanceId = ProviderInstanceId.make("grok-test"); - const adapter = makeGrokAdapterV2({ + const adapter = yield* makeGrokAdapterV2({ instanceId, settings: DEFAULT_GROK_SETTINGS, environment: {}, hostPlatform: yield* HostProcessPlatform, - childProcessSpawner, - crypto: yield* Crypto.Crypto, - fileSystem, - idAllocator, - host, selfInvocation: yield* resolveSelfInvocation(), // Production Grok runtimes are wrapped by the x.ai prompt runtime. makeRuntime: (input) => @@ -3296,26 +3153,18 @@ describe("AcpAdapterV2", () => { it.live("Grok reapplies an explicit return to the session's setup-time model", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const protocolEvents = yield* Queue.unbounded(); const instanceId = ProviderInstanceId.make("grok-test-switch-back"); - const adapter = makeGrokAdapterV2({ + const adapter = yield* makeGrokAdapterV2({ instanceId, settings: DEFAULT_GROK_SETTINGS, environment: {}, hostPlatform: yield* HostProcessPlatform, - childProcessSpawner, - crypto: yield* Crypto.Crypto, - fileSystem, - idAllocator, - host, selfInvocation: yield* resolveSelfInvocation(), // Production Grok runtimes are wrapped by the x.ai prompt runtime. makeRuntime: (input) => @@ -3377,26 +3226,19 @@ describe("AcpAdapterV2", () => { it.effect("skips requested options that the active ACP session does not expose", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, capabilities: AcpProviderCapabilitiesV2, makeRuntime: makeMockRuntime({ childProcessSpawner, mockAgentPath }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-unsupported-option"); @@ -3426,27 +3268,20 @@ describe("AcpAdapterV2", () => { it.effect("reconfigures a loaded ACP session from its own active setup metadata", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const protocolEvents = yield* Queue.bounded(256); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, capabilities: AcpProviderCapabilitiesV2, makeRuntime: makeMockRuntime({ childProcessSpawner, mockAgentPath, protocolEvents }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const firstThreadId = ThreadId.make("thread-acp-active-setup:first"); @@ -3537,18 +3372,15 @@ describe("AcpAdapterV2", () => { it.live("terminalizes an empty successful foreground Bash tool when the turn completes", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const protocolEvents = yield* Queue.bounded(256); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -3565,9 +3397,6 @@ describe("AcpAdapterV2", () => { restartRuntimeAfterInterrupt: true, terminateRuntimeProcessGroupOnInterrupt: true, }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-empty-successful-bash"); @@ -3684,16 +3513,12 @@ describe("AcpAdapterV2", () => { it.effect("drains native ACP cancellation before admitting the next prompt", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const protocolEvents = yield* Queue.unbounded(); const native: { current?: AcpSessionRuntime.AcpSessionRuntime["Service"] } = {}; const instanceId = ProviderInstanceId.make("acp-native-cancel"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -3712,9 +3537,6 @@ describe("AcpAdapterV2", () => { }, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-native-cancel"); @@ -3798,18 +3620,14 @@ describe("AcpAdapterV2", () => { it.effect("cancels pending permission requests while interrupting an ACP turn", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const releaseCancel = yield* Deferred.make(); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -3821,9 +3639,6 @@ describe("AcpAdapterV2", () => { wrapCancel: (cancel) => Deferred.await(releaseCancel).pipe(Effect.andThen(cancel)), }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-cancel-permission"); @@ -3899,10 +3714,7 @@ describe("AcpAdapterV2", () => { it.live("keeps hard teardown excluded until a permission response is enqueued", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -3910,8 +3722,7 @@ describe("AcpAdapterV2", () => { const responseEnqueued = yield* Deferred.make(); const releaseResponseAcknowledgement = yield* Deferred.make(); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -3927,9 +3738,6 @@ describe("AcpAdapterV2", () => { ), }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-response-wins-permission"); @@ -3998,10 +3806,7 @@ describe("AcpAdapterV2", () => { it.live("carries elicitation request identity through the completed stdout write", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -4009,8 +3814,7 @@ describe("AcpAdapterV2", () => { const responseWritten = yield* Deferred.make(); const releaseResponseAcknowledgement = yield* Deferred.make(); const instanceId = ProviderInstanceId.make("acp-test-reordered-elicitation"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -4026,9 +3830,6 @@ describe("AcpAdapterV2", () => { ), }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-reordered-elicitation"); @@ -4087,17 +3888,13 @@ describe("AcpAdapterV2", () => { it.live("auto-approves tagged MCP elicitations under full-access policy", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const instanceId = ProviderInstanceId.make("acp-test-mcp-approval-elicitation"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -4108,9 +3905,6 @@ describe("AcpAdapterV2", () => { environment: { T3_ACP_EMIT_MCP_TOOL_APPROVAL_ELICITATION: "1" }, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-mcp-approval-elicitation"); @@ -4155,10 +3949,7 @@ describe("AcpAdapterV2", () => { it.live("fails a held native response acknowledgement before normal session close", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -4167,8 +3958,7 @@ describe("AcpAdapterV2", () => { const releaseResponseAcknowledgement = yield* Deferred.make(); const responseLifecycle: Array = []; const instanceId = ProviderInstanceId.make("acp-test-normal-close-held-response"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -4184,9 +3974,6 @@ describe("AcpAdapterV2", () => { ), }), }, - fileSystem, - idAllocator, - host, selfInvocation, testHooks: { onNativeResponseLifecycle: (event) => @@ -4263,10 +4050,7 @@ describe("AcpAdapterV2", () => { it.live("rejects delayed native response registration when normal close wins the permit", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -4277,8 +4061,7 @@ describe("AcpAdapterV2", () => { const releaseTransportClose = yield* Deferred.make(); const responseLifecycle: Array = []; const instanceId = ProviderInstanceId.make("acp-test-close-wins-registration"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -4289,9 +4072,6 @@ describe("AcpAdapterV2", () => { environment: { T3_ACP_EMIT_TOOL_CALLS: "1" }, }), }, - fileSystem, - idAllocator, - host, selfInvocation, testHooks: { afterNativeResponseTransportClosed: () => @@ -4377,10 +4157,7 @@ describe("AcpAdapterV2", () => { it.live("bounds a missing pending permission response acknowledgement", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -4390,8 +4167,7 @@ describe("AcpAdapterV2", () => { const responseLifecycle: Array = []; const protocolEvents = yield* Queue.bounded(256); const instanceId = ProviderInstanceId.make("acp-test-pending-response-timeout"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -4423,9 +4199,6 @@ describe("AcpAdapterV2", () => { ), }), }, - fileSystem, - idAllocator, - host, selfInvocation, testHooks: { onNativeResponseLifecycle: (event) => @@ -4518,10 +4291,7 @@ describe("AcpAdapterV2", () => { it.live("defers caller cancellation until a pending response acknowledgement is bounded", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -4529,8 +4299,7 @@ describe("AcpAdapterV2", () => { const responseEnqueued = yield* Deferred.make(); const releaseNativeHook = yield* Deferred.make(); const instanceId = ProviderInstanceId.make("acp-test-pending-response-cancel"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -4561,9 +4330,6 @@ describe("AcpAdapterV2", () => { ), }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-pending-response-cancel"); @@ -4634,10 +4400,8 @@ describe("AcpAdapterV2", () => { it.live("waits for immediate allow and deny permission responses before hard teardown", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -4651,8 +4415,7 @@ describe("AcpAdapterV2", () => { const responseEnqueued = yield* Deferred.make(); const releaseResponseAcknowledgement = yield* Deferred.make(); const instanceId = ProviderInstanceId.make(`acp-test-${name}`); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -4676,9 +4439,6 @@ describe("AcpAdapterV2", () => { ), }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make(`thread-acp-immediate-permission-${name}`); @@ -4739,10 +4499,8 @@ describe("AcpAdapterV2", () => { it.live("waits for immediate URL elicitation responses before hard teardown", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -4750,8 +4508,7 @@ describe("AcpAdapterV2", () => { const responseEnqueued = yield* Deferred.make(); const releaseResponseAcknowledgement = yield* Deferred.make(); const instanceId = ProviderInstanceId.make("acp-test-url-elicitation"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -4775,9 +4532,6 @@ describe("AcpAdapterV2", () => { ), }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-immediate-url-elicitation"); @@ -4832,10 +4586,8 @@ describe("AcpAdapterV2", () => { it.live("bounds a missing immediate response acknowledgement before hard teardown", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -4843,8 +4595,7 @@ describe("AcpAdapterV2", () => { const responseEnqueued = yield* Deferred.make(); const releaseNativeHook = yield* Deferred.make(); const instanceId = ProviderInstanceId.make("acp-test-missing-response-ack"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -4872,9 +4623,6 @@ describe("AcpAdapterV2", () => { ), }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-missing-response-ack"); @@ -4925,10 +4673,7 @@ describe("AcpAdapterV2", () => { it.live("rejects an elicitation response when hard teardown wins admission", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -4936,8 +4681,7 @@ describe("AcpAdapterV2", () => { const teardownStarted = yield* Deferred.make(); const releaseTeardown = yield* Deferred.make(); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -4961,9 +4705,6 @@ describe("AcpAdapterV2", () => { ), }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-teardown-wins-elicitation"); @@ -5038,18 +4779,15 @@ describe("AcpAdapterV2", () => { it.effect("releases an ACP turn when cancellation times out", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const instanceId = ProviderInstanceId.make("acp-test"); const protocolEvents = yield* Queue.bounded(256); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -5061,9 +4799,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-cancel-timeout"); @@ -5141,18 +4876,15 @@ describe("AcpAdapterV2", () => { it.live("treats a second hard Stop as success when the turn is already gone", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const protocolEvents = yield* Queue.bounded(256); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -5168,9 +4900,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-double-stop"); @@ -5239,22 +4968,19 @@ describe("AcpAdapterV2", () => { it.effect("finalizes a settled turn held open for background work when interrupted", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const instanceId = ProviderInstanceId.make("acp-test"); const promptSettled = yield* Deferred.make(); - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ testHooks: { afterPromptSettledWithBackgroundWork: () => Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid), }, - crypto: yield* Crypto.Crypto, instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -5278,9 +5004,6 @@ describe("AcpAdapterV2", () => { environment: { T3_ACP_EMIT_GENERIC_TOOL_PLACEHOLDERS: "1" }, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-interrupt-background-hold"); @@ -5335,10 +5058,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -5346,12 +5067,11 @@ describe("AcpAdapterV2", () => { const instanceId = ProviderInstanceId.make("acp-test"); let subagentPhase: "spawn" | "complete" = "spawn"; const promptSettled = yield* Deferred.make(); - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ testHooks: { afterPromptSettledWithBackgroundWork: () => Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid), }, - crypto: yield* Crypto.Crypto, instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -5388,9 +5108,6 @@ describe("AcpAdapterV2", () => { environment: { T3_ACP_EMIT_GENERIC_TOOL_PLACEHOLDERS: "1" }, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-subagent-carryover"); @@ -5483,10 +5200,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -5494,12 +5209,11 @@ describe("AcpAdapterV2", () => { const instanceId = ProviderInstanceId.make("acp-test"); let subagentPhase: "spawn" | "complete" = "spawn"; const promptSettled = yield* Deferred.make(); - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ testHooks: { afterPromptSettledWithBackgroundWork: () => Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid), }, - crypto: yield* Crypto.Crypto, instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -5534,9 +5248,6 @@ describe("AcpAdapterV2", () => { environment: { T3_ACP_EMIT_GENERIC_TOOL_PLACEHOLDERS: "1" }, }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: () => Effect.void }, }); @@ -5630,10 +5341,8 @@ describe("AcpAdapterV2", () => { it.effect("handles a child terminal after carryover rehydrate", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -5647,12 +5356,11 @@ describe("AcpAdapterV2", () => { type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"]; let sessionUpdateHandler: Parameters[0] | undefined; const promptSettled = yield* Deferred.make(); - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ testHooks: { afterPromptSettledWithBackgroundWork: () => Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid), }, - crypto: yield* Crypto.Crypto, instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -5704,9 +5412,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: () => Effect.void }, }); @@ -5867,10 +5572,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -5903,12 +5606,11 @@ describe("AcpAdapterV2", () => { | Parameters[0] | undefined; const promptSettled = yield* Deferred.make(); - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ testHooks: { afterPromptSettledWithBackgroundWork: () => Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid), }, - crypto: yield* Crypto.Crypto, instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -5955,9 +5657,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: () => Effect.void }, }); @@ -6090,10 +5789,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -6106,12 +5803,11 @@ describe("AcpAdapterV2", () => { let subagentPhase: "spawn" | "complete" = "spawn"; type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"]; let sessionUpdateHandler: Parameters[0] | undefined; - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ testHooks: { afterPromptSettledWithBackgroundWork: () => Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid), }, - crypto: yield* Crypto.Crypto, instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -6154,9 +5850,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -6309,10 +6002,8 @@ describe("AcpAdapterV2", () => { it.effect("finishes a settled root's carryover subagent from its structured end", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -6321,8 +6012,7 @@ describe("AcpAdapterV2", () => { const instanceId = ProviderInstanceId.make("acp-test"); const childSessionId = "019f44a6-4820-7402-925d-bc862ee711dd"; let finishSubagent: AcpAdapterV2ExtensionContext["finishSubagent"] | undefined; - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -6352,9 +6042,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: () => Effect.void }, }); @@ -6457,10 +6144,8 @@ describe("AcpAdapterV2", () => { it.effect("projects completed-root carryover eagerly and drain cannot resurrect it", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -6472,8 +6157,7 @@ describe("AcpAdapterV2", () => { let subagentPhase: "spawn" | "complete" = "spawn"; type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"]; let sessionUpdateHandler: Parameters[0] | undefined; - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -6517,9 +6201,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -6709,10 +6390,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -6724,12 +6403,11 @@ describe("AcpAdapterV2", () => { type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"]; let sessionUpdateHandler: Parameters[0] | undefined; const promptSettled = yield* Deferred.make(); - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ testHooks: { afterPromptSettledWithBackgroundWork: () => Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid), }, - crypto: yield* Crypto.Crypto, instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -6771,9 +6449,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -6997,10 +6672,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -7013,12 +6686,11 @@ describe("AcpAdapterV2", () => { type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"]; let sessionUpdateHandler: Parameters[0] | undefined; const promptSettled = yield* Deferred.make(); - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ testHooks: { afterPromptSettledWithBackgroundWork: () => Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid), }, - crypto: yield* Crypto.Crypto, instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -7069,9 +6741,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -7238,10 +6907,8 @@ describe("AcpAdapterV2", () => { it.effect("projects an interrupted root-session end notice at the next attach", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -7254,12 +6921,11 @@ describe("AcpAdapterV2", () => { let subagentPhase: "spawn" | "complete" = "spawn"; type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"]; let sessionUpdateHandler: Parameters[0] | undefined; - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ testHooks: { afterPromptSettledWithBackgroundWork: () => Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid), }, - crypto: yield* Crypto.Crypto, instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -7313,9 +6979,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -7467,10 +7130,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -7483,12 +7144,11 @@ describe("AcpAdapterV2", () => { type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"]; let sessionUpdateHandler: Parameters[0] | undefined; const promptSettled = yield* Deferred.make(); - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ testHooks: { afterPromptSettledWithBackgroundWork: () => Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid), }, - crypto: yield* Crypto.Crypto, instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -7530,9 +7190,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -7738,10 +7395,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -7753,12 +7408,11 @@ describe("AcpAdapterV2", () => { type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"]; let sessionUpdateHandler: Parameters[0] | undefined; const promptSettled = yield* Deferred.make(); - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ testHooks: { afterPromptSettledWithBackgroundWork: () => Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid), }, - crypto: yield* Crypto.Crypto, instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -7800,9 +7454,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -7980,10 +7631,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -7993,12 +7642,11 @@ describe("AcpAdapterV2", () => { let cancelCalled = false; let runtimeOrdinalSeen = 0; const promptSettled = yield* Deferred.make(); - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ testHooks: { afterPromptSettledWithBackgroundWork: () => Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid), }, - crypto: yield* Crypto.Crypto, instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -8050,9 +7698,6 @@ describe("AcpAdapterV2", () => { }).pipe(Effect.andThen(cancel)), }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-settled-soft-steer"); @@ -8156,18 +7801,15 @@ describe("AcpAdapterV2", () => { it.live("preserveRuntimeOnSettledInterrupt does not soften a mid-prompt steering interrupt", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const protocolEvents = yield* Queue.bounded(256); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -8189,9 +7831,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-unsettled-steer-stays-hard"); @@ -8246,10 +7885,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -8259,8 +7896,7 @@ describe("AcpAdapterV2", () => { const instanceId = ProviderInstanceId.make("acp-test"); let cancelCalled = false; let runtimeOrdinalSeen = 0; - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -8295,9 +7931,6 @@ describe("AcpAdapterV2", () => { }).pipe(Effect.andThen(cancel)), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -8440,10 +8073,8 @@ describe("AcpAdapterV2", () => { it.live("direct Stop quarantine drops late background task mutations from the stopped run", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -8459,8 +8090,7 @@ describe("AcpAdapterV2", () => { }) => Effect.Effect) | null; } = { current: null }; - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -8481,9 +8111,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: () => Effect.void }, }); @@ -8587,10 +8214,8 @@ describe("AcpAdapterV2", () => { it.live("production Grok interrupt flags still hard-kill and respawn on user Stop", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -8598,8 +8223,7 @@ describe("AcpAdapterV2", () => { const protocolEvents = yield* Queue.bounded(256); const instanceId = ProviderInstanceId.make("acp-test"); let runtimeOrdinalSeen = 0; - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -8627,9 +8251,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: () => Effect.void }, }); @@ -8718,10 +8339,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -8736,12 +8355,11 @@ describe("AcpAdapterV2", () => { type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"]; let sessionUpdateHandler: Parameters[0] | undefined; const promptSettled = yield* Deferred.make(); - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ testHooks: { afterPromptSettledWithBackgroundWork: () => Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid), }, - crypto: yield* Crypto.Crypto, instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -8796,9 +8414,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-stop-after-soft-steer-orphan"); @@ -9022,10 +8637,8 @@ describe("AcpAdapterV2", () => { it.live("Direct Stop projects an interrupt-deferred terminal exactly once", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -9036,8 +8649,7 @@ describe("AcpAdapterV2", () => { let subagentPhase: "spawn" | "complete" = "spawn"; type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"]; let sessionUpdateHandler: Parameters[0] | undefined; - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -9084,9 +8696,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: () => Effect.void }, }); @@ -9219,10 +8828,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -9238,8 +8845,7 @@ describe("AcpAdapterV2", () => { // interrupt then ORs wire-done with promptSettled under the permit. const promptWireReturned = yield* Deferred.make(); const releasePromptCompletion = yield* Deferred.make(); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -9295,9 +8901,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-settled-soft-admission-race"); @@ -9389,10 +8992,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -9400,8 +9001,7 @@ describe("AcpAdapterV2", () => { const protocolEvents = yield* Queue.bounded(256); const continuationRequests: Array = []; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -9428,9 +9028,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -9520,10 +9117,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -9532,8 +9127,7 @@ describe("AcpAdapterV2", () => { type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"]; let sessionUpdateHandler: Parameters[0] | undefined; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -9551,9 +9145,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -9640,10 +9231,8 @@ describe("AcpAdapterV2", () => { it.effect("keeps a buffered continuation current when a user turn starts before dispatch", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -9656,8 +9245,7 @@ describe("AcpAdapterV2", () => { type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"]; let sessionUpdateHandler: Parameters[0] | undefined; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -9687,9 +9275,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -9852,7 +9437,6 @@ describe("AcpAdapterV2", () => { const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -9861,8 +9445,7 @@ describe("AcpAdapterV2", () => { const triggerPath = path.join(triggerDir, "report-trigger"); const protocolEvents = yield* Queue.bounded(256); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -9894,9 +9477,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-injected-report-hold"); @@ -10018,7 +9598,6 @@ describe("AcpAdapterV2", () => { const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -10037,8 +9616,7 @@ describe("AcpAdapterV2", () => { | null; } = { current: null }; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -10075,9 +9653,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -10217,10 +9792,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -10240,8 +9813,7 @@ describe("AcpAdapterV2", () => { | null; } = { current: null }; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -10273,9 +9845,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -10457,10 +10026,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -10480,8 +10047,7 @@ describe("AcpAdapterV2", () => { | null; } = { current: null }; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -10520,9 +10086,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -10676,10 +10239,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -10699,8 +10260,7 @@ describe("AcpAdapterV2", () => { | null; } = { current: null }; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -10743,9 +10303,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -10891,10 +10448,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -10914,8 +10469,7 @@ describe("AcpAdapterV2", () => { | null; } = { current: null }; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -10980,9 +10534,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -11263,10 +10814,8 @@ describe("AcpAdapterV2", () => { it.effect("a wake names work that ended while the previous wake was queued", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -11277,8 +10826,7 @@ describe("AcpAdapterV2", () => { let applyMutation: AcpAdapterV2ExtensionContext["applyBackgroundTaskMutation"] | undefined; const promptGate = yield* Deferred.make(); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -11303,9 +10851,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -11417,10 +10962,8 @@ describe("AcpAdapterV2", () => { it.effect("mid-turn completed mutation defers offer until finalize only when unhandled", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -11440,8 +10983,7 @@ describe("AcpAdapterV2", () => { | null; } = { current: null }; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -11487,9 +11029,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -11748,10 +11287,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -11771,8 +11308,7 @@ describe("AcpAdapterV2", () => { | null; } = { current: null }; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -11799,9 +11335,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -11935,10 +11468,8 @@ describe("AcpAdapterV2", () => { it.effect("empty-drain continuation turn waits the quiet window so late frames can attach", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -11958,8 +11489,7 @@ describe("AcpAdapterV2", () => { | null; } = { current: null }; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -11990,9 +11520,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -12179,10 +11706,8 @@ describe("AcpAdapterV2", () => { it.effect("empty-drain continuation turn finalizes after the quiet window with no frames", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -12202,8 +11727,7 @@ describe("AcpAdapterV2", () => { | null; } = { current: null }; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -12232,9 +11756,6 @@ describe("AcpAdapterV2", () => { }), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -12369,18 +11890,15 @@ describe("AcpAdapterV2", () => { it.effect("restarts the ACP child process before the next prompt after interrupt", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const protocolEvents = yield* Queue.bounded(256); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -12392,9 +11910,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-restart-after-interrupt"); @@ -12618,7 +12133,6 @@ describe("AcpAdapterV2", () => { const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -12635,8 +12149,7 @@ describe("AcpAdapterV2", () => { const releaseTeardown = yield* Deferred.make(); let terminatorCallCount = 0; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -12665,9 +12178,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: (request) => @@ -12833,18 +12343,15 @@ describe("AcpAdapterV2", () => { it.live("durably poisons start and resume when required hard teardown is unavailable", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const protocolEvents = yield* Queue.bounded(256); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -12858,9 +12365,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-missing-hard-teardown"); @@ -12922,10 +12426,8 @@ describe("AcpAdapterV2", () => { it.live("holds concurrent startTurn behind successful hard teardown and reloads once", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -12935,8 +12437,7 @@ describe("AcpAdapterV2", () => { const releaseTeardown = yield* Deferred.make(); let runtimeOrdinalSeen = 0; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -12960,9 +12461,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-concurrent-hard-teardown"); @@ -13035,10 +12533,8 @@ describe("AcpAdapterV2", () => { it.live("quarantines old-runtime callbacks after successful hard teardown", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -13101,8 +12597,7 @@ describe("AcpAdapterV2", () => { }; }, }); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -13119,9 +12614,6 @@ describe("AcpAdapterV2", () => { runtimeInputs.push(runtimeInput); }).pipe(Effect.andThen(makeRuntime(runtimeInput))), }, - fileSystem, - idAllocator, - host, selfInvocation, testHooks: { afterHardTeardownTransportDrained: () => @@ -13397,18 +12889,14 @@ describe("AcpAdapterV2", () => { it.live("keeps stale deferred cleanup inert while replacement requests remain live", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); const protocolEvents = yield* Queue.bounded(256); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -13425,9 +12913,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-stale-deferred-cleanup"); @@ -13522,10 +13007,8 @@ describe("AcpAdapterV2", () => { it.live("resolves owner cancellation and concurrent resume waiters after hard teardown", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -13535,8 +13018,7 @@ describe("AcpAdapterV2", () => { const releaseTeardown = yield* Deferred.make(); let runtimeOrdinalSeen = 0; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -13560,9 +13042,6 @@ describe("AcpAdapterV2", () => { protocolEvents, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-concurrent-resume-teardown"); @@ -13659,7 +13138,6 @@ describe("AcpAdapterV2", () => { const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -13673,8 +13151,7 @@ describe("AcpAdapterV2", () => { ); let cancelCalled = false; const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -13711,9 +13188,6 @@ describe("AcpAdapterV2", () => { }).pipe(Effect.andThen(Effect.never)), }), }, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests: { offer: () => Effect.void }, }); @@ -13933,10 +13407,8 @@ describe("AcpAdapterV2", () => { () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -13944,12 +13416,11 @@ describe("AcpAdapterV2", () => { const instanceId = ProviderInstanceId.make("acp-test"); let subagentPhase: "spawn" | "complete" = "spawn"; const promptSettled = yield* Deferred.make(); - const adapter = makeAcpAdapterV2({ + const adapter = yield* makeAcpAdapterV2({ testHooks: { afterPromptSettledWithBackgroundWork: () => Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid), }, - crypto: yield* Crypto.Crypto, instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -13984,9 +13455,6 @@ describe("AcpAdapterV2", () => { environment: { T3_ACP_EMIT_GENERIC_TOOL_PLACEHOLDERS: "1" }, }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-direct-stop-subagent-hold"); @@ -14090,7 +13558,6 @@ describe("AcpAdapterV2", () => { const fileSystem = yield* FileSystem.FileSystem; const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const selfInvocation = yield* resolveSelfInvocation(); const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -14103,8 +13570,7 @@ describe("AcpAdapterV2", () => { Effect.sync(() => cleanupPublishedDetachedFixture(commandPidPath)), ); const instanceId = ProviderInstanceId.make("acp-test"); - const adapter = makeAcpAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpAdapterV2({ instanceId, flavor: { driver: ACP_TEST_DRIVER, @@ -14133,9 +13599,6 @@ describe("AcpAdapterV2", () => { wrapCancel: (cancel) => cancel.pipe(Effect.andThen(Effect.sleep("250 millis"))), }), }, - fileSystem, - idAllocator, - host, selfInvocation, }); const threadId = ThreadId.make("thread-acp-restart-active-in-process"); diff --git a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts index fa861a22dde7..3762cbb6769a 100644 --- a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts @@ -4,7 +4,6 @@ import { ProviderInstanceId, ProviderSessionId, ThreadId } from "@t3tools/contra import { resolveSelfInvocation } from "@t3tools/shared/nodeRuntime"; import * as Deferred from "effect/Deferred"; import * as Effect from "effect/Effect"; -import * as Crypto from "effect/Crypto"; import * as FileSystem from "effect/FileSystem"; import * as Layer from "effect/Layer"; import * as Option from "effect/Option"; @@ -188,8 +187,7 @@ describe("AcpRegistryAdapterV2", () => { ACP_REGISTRY_PROVIDER, ); const instanceId = ProviderInstanceId.make("acp-registry-mode-pick"); - const adapter = makeAcpRegistryAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpRegistryAdapterV2({ selfInvocation: yield* resolveSelfInvocation(), instanceId, settings: yield* decodeAcpRegistryAdapterSettings({ @@ -198,10 +196,7 @@ describe("AcpRegistryAdapterV2", () => { }), environment: {}, childProcessSpawner, - fileSystem, - idAllocator: yield* IdAllocator.IdAllocatorV2, resolver: { resolve: () => Effect.die("the runtime is injected") }, - host: yield* ProviderHost.ProviderHost, makeRuntime: makeAcpReplayRuntime({ transcript, statusPath, @@ -268,10 +263,7 @@ describe("AcpRegistryAdapterV2", () => { it.effect("offers client terminals to Devin only and client fs to no registry agent", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), ); @@ -280,17 +272,13 @@ describe("AcpRegistryAdapterV2", () => { ) { let clientCapabilities: unknown; const instanceId = ProviderInstanceId.make(`acp-registry-capabilities-${agentId}`); - const adapter = makeAcpRegistryAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpRegistryAdapterV2({ selfInvocation: yield* resolveSelfInvocation(), instanceId, settings: yield* decodeAcpRegistryAdapterSettings({ agentId, authMethodId: "test" }), environment: {}, childProcessSpawner, - fileSystem, - idAllocator, resolver: { resolve: () => Effect.die("the runtime is injected") }, - host, makeRuntime: (input) => Effect.gen(function* () { clientCapabilities = input.clientCapabilities; @@ -344,8 +332,6 @@ describe("AcpRegistryAdapterV2", () => { it.effect("opens a real ACP child process resolved from registry configuration", () => Effect.gen(function* () { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const path = yield* Path.Path; const host = yield* ProviderHost.ProviderHost; const mockAgentPath = yield* path.fromFileUrl( @@ -369,8 +355,7 @@ describe("AcpRegistryAdapterV2", () => { readonly commands: AcpRegistryAvailableCommands; }>(); const configurationPublished = yield* Deferred.make(); - const adapter = makeAcpRegistryAdapterV2({ - crypto: yield* Crypto.Crypto, + const adapter = yield* makeAcpRegistryAdapterV2({ selfInvocation: yield* resolveSelfInvocation(), instanceId, settings, @@ -379,8 +364,6 @@ describe("AcpRegistryAdapterV2", () => { T3_ACP_COMMAND_ADVERTISEMENT_DELAY_MS: "750", }, childProcessSpawner, - fileSystem, - idAllocator, runtimeCoordinator: { withForegroundStartup: (agentId, effect) => Effect.acquireUseRelease( @@ -428,7 +411,6 @@ describe("AcpRegistryAdapterV2", () => { })), ), }, - host, }); const threadId = ThreadId.make("thread-acp-registry-fixture"); const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({ diff --git a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.testkit.ts b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.testkit.ts index 9ebe08e40ec1..aefcd190f33d 100644 --- a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.testkit.ts +++ b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.testkit.ts @@ -2,14 +2,12 @@ import * as NodeServices from "@effect/platform-node/NodeServices"; import { AcpRegistrySettings } from "@t3tools/contracts"; import { resolveSelfInvocation } from "@t3tools/shared/nodeRuntime"; import * as Effect from "effect/Effect"; -import * as Crypto from "effect/Crypto"; import * as FileSystem from "effect/FileSystem"; import * as Layer from "effect/Layer"; import * as Path from "effect/Path"; import * as Schema from "effect/Schema"; import { ChildProcessSpawner } from "effect/process"; -import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost"; import { layerTestProviderHost } from "@t3tools/provider-testing/host"; import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator"; import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts"; @@ -44,9 +42,6 @@ function layerAcpRegistryProviderAdapterRegistryReplay( const fileSystem = yield* FileSystem.FileSystem; const path = yield* Path.Path; const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const crypto = yield* Crypto.Crypto; - const idAllocator = yield* IdAllocator.IdAllocatorV2; - const host = yield* ProviderHost.ProviderHost; const replayGate = options.replayGate; const replayDir = yield* fileSystem .makeTempDirectory({ @@ -57,18 +52,14 @@ function layerAcpRegistryProviderAdapterRegistryReplay( const scriptPath = yield* path .fromFileUrl(new URL("../../../scripts/acp-replay-agent.ts", import.meta.url)) .pipe(Effect.orDie); - const adapter = makeAcpRegistryAdapterV2({ + const adapter = yield* makeAcpRegistryAdapterV2({ instanceId: ACP_REGISTRY_DEFAULT_INSTANCE_ID, settings: REPLAY_SETTINGS, environment: {}, childProcessSpawner, - crypto, - fileSystem, - idAllocator, resolver: { resolve: () => Effect.die("ACP registry resolver must not run during replay"), }, - host, selfInvocation: yield* resolveSelfInvocation(), makeRuntime: makeAcpReplayRuntime({ transcript, diff --git a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.ts index d188f9c9266f..99168e136592 100644 --- a/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.ts +++ b/apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.ts @@ -59,13 +59,9 @@ export interface AcpRegistryAdapterV2Options { readonly settings: AcpRegistrySettings; readonly environment: NodeJS.ProcessEnv; readonly childProcessSpawner: ChildProcessSpawner.ChildProcessSpawner["Service"]; - readonly crypto: Crypto.Crypto; readonly selfInvocation: SelfInvocation; - readonly fileSystem: FileSystem.FileSystem; - readonly idAllocator: IdAllocator.IdAllocatorV2["Service"]; readonly resolver: Pick; readonly runtimeCoordinator?: AcpRegistryRuntimeCoordinator.AcpRegistryRuntimeCoordinator["Service"]; - readonly host: ProviderHost.ProviderHostShape; readonly nativeLogging?: Parameters[0]["nativeLogging"]; readonly makeRuntime?: ( input: AcpAdapterV2RuntimeInput, @@ -181,7 +177,9 @@ function makeAcpRegistryRuntime(options: AcpRegistryAdapterV2Options) { }); } -export function makeAcpRegistryAdapterV2(options: AcpRegistryAdapterV2Options) { +export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(function* ( + options: AcpRegistryAdapterV2Options, +) { const runtimeCoordinator = options.runtimeCoordinator; const registryAgentId = options.settings.source === "local" ? "" : options.settings.agentId; const startupKey = @@ -237,13 +235,9 @@ export function makeAcpRegistryAdapterV2(options: AcpRegistryAdapterV2Options) { }), ...(options.assertComplete === undefined ? {} : { assertComplete: options.assertComplete }), }; - return makeAcpAdapterV2({ + return yield* makeAcpAdapterV2({ instanceId: options.instanceId, flavor, - crypto: options.crypto, - fileSystem: options.fileSystem, - idAllocator: options.idAllocator, - host: options.host, selfInvocation: options.selfInvocation, // Per-agent exception (see the note above registerMistralVibeAcpExtensions): // Devin runs commands through client terminals and has no ask mode over @@ -259,7 +253,7 @@ export function makeAcpRegistryAdapterV2(options: AcpRegistryAdapterV2Options) { : {}), ...(options.nativeLogging === undefined ? {} : { nativeLogging: options.nativeLogging }), }); -} +}); export type AcpRegistryAdapterV2DriverEnv = | ChildProcessSpawner.ChildProcessSpawner @@ -283,29 +277,21 @@ export const AcpRegistryAdapterV2Driver: ProviderAdapterDriver< const hostEnvironment = yield* HostProcessEnvironment; const selfInvocation = yield* resolveSelfInvocation(); const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const crypto = yield* Crypto.Crypto; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const providerEventLoggers = yield* ProviderEventLoggers.ProviderEventLoggers; - const host = yield* ProviderHost.ProviderHost; const makeNativeLogger = yield* makeAcpNativeLoggerFactory(); const resolver = yield* AcpRegistrySupport.AcpRegistryCatalog; const runtimeCoordinator = yield* Effect.serviceOption( AcpRegistryRuntimeCoordinator.AcpRegistryRuntimeCoordinator, ); - return makeAcpRegistryAdapterV2({ + return yield* makeAcpRegistryAdapterV2({ instanceId: input.instanceId, settings: { ...input.config, enabled: input.enabled }, environment: mergeProviderInstanceEnvironment(input.environment, hostEnvironment), childProcessSpawner, - crypto, - fileSystem, - idAllocator, resolver, ...(Option.isSome(runtimeCoordinator) ? { runtimeCoordinator: runtimeCoordinator.value } : {}), - host, selfInvocation, nativeLogging: (threadId) => makeNativeLogger({ diff --git a/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts index 4ce55c783307..f997751f2fdd 100644 --- a/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts @@ -38,7 +38,6 @@ const flavor = makeAntigravityAcpAdapterFlavor({ crypto: undefined as never, fileSystem: undefined as never, path: undefined as never, - idAllocator: undefined as never, host: undefined as never, selfInvocation: undefined as never, makeRuntime: () => Effect.die("not spawned in this test"), @@ -149,14 +148,9 @@ describe("AntigravityAdapterV2 client file system", () => { let writeTextFile: Parameters[0] | undefined; const crypto = yield* Crypto.Crypto; const instanceId = ProviderInstanceId.make("antigravity-containment-test"); - const adapter = makeAntigravityAdapterV2({ + const adapter = yield* makeAntigravityAdapterV2({ instanceId, - crypto, selfInvocation: yield* resolveSelfInvocation(), - fileSystem, - path, - idAllocator: yield* IdAllocator.IdAllocatorV2, - host, makeRuntime: (input) => makeAntigravityAcpRuntime({ ...input, @@ -293,7 +287,6 @@ describe("AntigravityAdapterV2 workspace changes", () => { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; const fileSystem = yield* FileSystem.FileSystem; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const crypto = yield* Crypto.Crypto; const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -301,14 +294,9 @@ describe("AntigravityAdapterV2 workspace changes", () => { type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"]; let readTextFile: Parameters[0] | undefined; const instanceId = ProviderInstanceId.make("antigravity-workspace-change-test"); - const adapter = makeAntigravityAdapterV2({ + const adapter = yield* makeAntigravityAdapterV2({ instanceId, - crypto, selfInvocation: yield* resolveSelfInvocation(), - fileSystem, - path, - idAllocator: yield* IdAllocator.IdAllocatorV2, - host, makeRuntime: (input) => makeAntigravityAcpRuntime({ ...input, @@ -430,7 +418,6 @@ describe("AntigravityAdapterV2 client file system under restrictive policies", ( const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; const fileSystem = yield* FileSystem.FileSystem; const path = yield* Path.Path; - const host = yield* ProviderHost.ProviderHost; const crypto = yield* Crypto.Crypto; const mockAgentPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-mock-agent.ts", import.meta.url), @@ -451,14 +438,9 @@ describe("AntigravityAdapterV2 client file system under restrictive policies", ( let readTextFile: Parameters[0] | undefined; let writeTextFile: Parameters[0] | undefined; const instanceId = ProviderInstanceId.make(`antigravity-restrictive-${policy.runtimeMode}`); - const adapter = makeAntigravityAdapterV2({ + const adapter = yield* makeAntigravityAdapterV2({ instanceId, - crypto, selfInvocation: yield* resolveSelfInvocation(), - fileSystem, - path, - idAllocator: yield* IdAllocator.IdAllocatorV2, - host, makeRuntime: (input) => makeAntigravityAcpRuntime({ ...input, diff --git a/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts index 4263618cf32c..431cdf0ee3e9 100644 --- a/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts +++ b/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts @@ -8,8 +8,8 @@ import { import type { SelfInvocation } from "@t3tools/shared/nodeRuntime"; import * as Crypto from "effect/Crypto"; import * as Effect from "effect/Effect"; -import type * as FileSystem from "effect/FileSystem"; -import type * as Path from "effect/Path"; +import * as FileSystem from "effect/FileSystem"; +import * as Path from "effect/Path"; import * as Exit from "effect/Exit"; import * as Scope from "effect/Scope"; import * as EffectAcpErrors from "effect-acp/errors"; @@ -34,7 +34,6 @@ import { makeAntigravityUserInputResponse, normalizeAntigravityToolCall, } from "../../provider/acp/AntigravityProtocol.ts"; -import type { IdAllocatorV2 } from "@t3tools/provider-core/server/IdAllocator"; import { AcpProviderCapabilitiesV2, makeAcpAdapterV2, @@ -63,12 +62,7 @@ const AntigravityProviderCapabilitiesV2 = { export interface AntigravityAdapterV2Options { readonly instanceId: ProviderInstanceId; - readonly crypto: Crypto.Crypto; readonly selfInvocation: SelfInvocation; - readonly fileSystem: FileSystem.FileSystem; - readonly path: Path.Path; - readonly idAllocator: IdAllocatorV2["Service"]; - readonly host: ProviderHost.ProviderHostShape; /** Spawns the official agent with the instance's Google profile. */ readonly makeRuntime: ( input: Omit, @@ -118,8 +112,16 @@ const extractAntigravitySubagentUpdate: NonNullable { it("preserves Grok's rate-limit stop and distinguishes other prompt failures", () => { const flavor = makeGrokAcpAdapterFlavor({ makeRuntime: () => Effect.never, - } as unknown as GrokAdapterV2Options); + } as unknown as Parameters[0]); const limit = flavor.promptFailure?.( new EffectAcpErrors.AcpRequestError({ code: xAiRateLimitedErrorCode, @@ -127,7 +123,7 @@ describe("GrokAdapterV2 capabilities", () => { it("wires hard Stop teardown but soft non-Stop interrupts in the constructor flavor", () => { const flavor = makeGrokAcpAdapterFlavor({ makeRuntime: () => Effect.never, - } as unknown as GrokAdapterV2Options); + } as unknown as Parameters[0]); assert.isFalse(flavor.interruptPromptOnCancel); // User Stop (requestRuntimeRestart) keeps the hard process-group kill and @@ -144,7 +140,7 @@ describe("GrokAdapterV2 capabilities", () => { it("terminalizes only foreground tools under the actual Grok flavor", () => { const flavor = makeGrokAcpAdapterFlavor({ makeRuntime: () => Effect.never, - } as unknown as GrokAdapterV2Options); + } as unknown as Parameters[0]); const foreground = { toolCallId: "foreground-1", title: "Terminal", @@ -289,7 +285,7 @@ describe("ACP permission policy", () => { describe("Grok permission prompts", () => { const disposition = makeGrokAcpAdapterFlavor({ makeRuntime: () => Effect.never, - } as unknown as GrokAdapterV2Options).permissionDisposition; + } as unknown as Parameters[0]).permissionDisposition; // grok_auto_blocked_command replays Auto end to end. When an explicit policy // launches Grok asking instead, T3's policy still answers its prompts. @@ -332,18 +328,13 @@ describe("Grok launch permission mode", () => { ); }); const instanceId = ProviderInstanceId.make("grok-launch-test"); - const adapter = makeGrokAdapterV2({ + const adapter = yield* makeGrokAdapterV2({ instanceId, settings: LAUNCH_TEST_GROK_SETTINGS, environment: {}, hostPlatform: "darwin", - childProcessSpawner, - crypto: yield* Crypto.Crypto, - fileSystem: yield* FileSystem.FileSystem, - idAllocator: yield* IdAllocator.IdAllocatorV2, - host: yield* ProviderHost.ProviderHost, selfInvocation: yield* resolveSelfInvocation(), - }); + }).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, childProcessSpawner)); yield* adapter .openSession({ threadId: ThreadId.make("grok-launch-test"), diff --git a/apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.testkit.ts b/apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.testkit.ts index 172150432f53..37de61f072ce 100644 --- a/apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.testkit.ts +++ b/apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.testkit.ts @@ -1,7 +1,6 @@ import * as NodeServices from "@effect/platform-node/NodeServices"; import { GrokSettings } from "@t3tools/provider-grok/settings"; import * as Effect from "effect/Effect"; -import * as Crypto from "effect/Crypto"; import * as FileSystem from "effect/FileSystem"; import * as Layer from "effect/Layer"; import * as Path from "effect/Path"; @@ -10,7 +9,6 @@ import { ChildProcessSpawner } from "effect/process"; import { HostProcessPlatform } from "@t3tools/shared/hostProcess"; import { resolveSelfInvocation } from "@t3tools/shared/nodeRuntime"; -import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost"; import { layerTestProviderHost } from "@t3tools/provider-testing/host"; import { GROK_ACP_CANCEL_META, GROK_ACP_INITIALIZE_META } from "@t3tools/provider-grok/testing"; import { makeXAiPromptCompletionRuntime } from "@t3tools/provider-grok/testing"; @@ -45,10 +43,7 @@ function layerGrokProviderAdapterRegistryReplay( const fileSystem = yield* FileSystem.FileSystem; const path = yield* Path.Path; const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const crypto = yield* Crypto.Crypto; const hostPlatform = yield* HostProcessPlatform; - const idAllocator = yield* IdAllocator.IdAllocatorV2; - const host = yield* ProviderHost.ProviderHost; // Same queue the continuation worker drains when the fixture runs it. const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests; const replayGate = options.replayGate; @@ -61,16 +56,11 @@ function layerGrokProviderAdapterRegistryReplay( const scriptPath = yield* path .fromFileUrl(new URL("../../../scripts/acp-replay-agent.ts", import.meta.url)) .pipe(Effect.orDie); - const adapter = makeGrokAdapterV2({ + const adapter = yield* makeGrokAdapterV2({ instanceId: GROK_DEFAULT_INSTANCE_ID, settings: DEFAULT_GROK_SETTINGS, environment: {}, hostPlatform, - childProcessSpawner, - crypto, - fileSystem, - idAllocator, - host, selfInvocation: yield* resolveSelfInvocation(), // Same wrapping as makeGrokAcpRuntime: client type and Ctrl+C cancel // metadata and the x.ai prompt-completion race, so replay sends what diff --git a/apps/server/src/orchestration-v2/Adapters/MuseAdapterV2.testkit.ts b/apps/server/src/orchestration-v2/Adapters/MuseAdapterV2.testkit.ts index f36d2c5959f5..1d10bb8e50e1 100644 --- a/apps/server/src/orchestration-v2/Adapters/MuseAdapterV2.testkit.ts +++ b/apps/server/src/orchestration-v2/Adapters/MuseAdapterV2.testkit.ts @@ -24,11 +24,9 @@ import { } from "@t3tools/contracts"; import { MuseSettings } from "@t3tools/provider-muse/settings"; import * as Effect from "effect/Effect"; -import * as FileSystem from "effect/FileSystem"; import * as Layer from "effect/Layer"; import * as Schema from "effect/Schema"; -import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost"; import { layerTestProviderHost } from "@t3tools/provider-testing/host"; import { museInitializeParams, @@ -449,13 +447,10 @@ export function layer(input: { return ProviderAdapterRegistry.layerFromAdaptersEffect( Effect.gen(function* () { return [ - makeMuseAdapterV2({ + yield* makeMuseAdapterV2({ instanceId: ProviderInstanceId.make(MUSE_PROVIDER_KIND), settings: DEFAULT_MUSE_SETTINGS, environment: input.environment ?? {}, - idAllocator: yield* IdAllocator.IdAllocatorV2, - host: yield* ProviderHost, - fileSystem: yield* FileSystem.FileSystem, createHost: input.createHost, // Same queue the continuation worker drains when the fixture runs it. continuationRequests: yield* ProviderContinuationRequests.ProviderContinuationRequests, diff --git a/apps/server/src/provider/Drivers/AntigravityDriver.ts b/apps/server/src/provider/Drivers/AntigravityDriver.ts index fa075fa28dfc..fe2f3f301a58 100644 --- a/apps/server/src/provider/Drivers/AntigravityDriver.ts +++ b/apps/server/src/provider/Drivers/AntigravityDriver.ts @@ -94,7 +94,6 @@ export const AntigravityDriver: ProviderDriver ModelManifest.manifestDefaultModel(manifest, DRIVER)), ); - const orchestrationAdapter = makeAntigravityAdapterV2({ + const orchestrationAdapter = yield* makeAntigravityAdapterV2({ instanceId, - crypto, - fileSystem, - path, - idAllocator, - host, selfInvocation, makeRuntime, withProcess: authFlow.withProcess, diff --git a/packages/provider-acp/src/server/adapter.ts b/packages/provider-acp/src/server/adapter.ts index 03d168c04a5b..65c168314fd1 100644 --- a/packages/provider-acp/src/server/adapter.ts +++ b/packages/provider-acp/src/server/adapter.ts @@ -1,5 +1,4 @@ // @effect-diagnostics nodeBuiltinImport:off -import * as NodePath from "node:path"; import { type ChatAttachment, @@ -57,7 +56,7 @@ import type * as EffectAcpProtocol from "effect-acp/protocol"; import type * as EffectAcpSchema from "effect-acp/compat"; import { formatReadToolLabel, formatSearchToolLabel } from "@t3tools/shared/toolActivity"; -import type * as ProviderHost from "@t3tools/provider-core/server/ProviderHost"; +import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost"; import { makeAcpMcpOverAcpBridge, type AcpMcpOverAcpBridge } from "./mcpOverAcpBridge.ts"; import { mcpToolPresentation } from "@t3tools/provider-core/server/mcpToolPresentation"; import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession"; @@ -480,10 +479,6 @@ export interface AcpAdapterV2SubagentUpdate { export interface AcpAdapterV2Options { readonly instanceId: ProviderInstanceId; readonly flavor: AcpAdapterV2Flavor; - readonly crypto: Crypto.Crypto; - readonly fileSystem: FileSystem.FileSystem; - readonly idAllocator: IdAllocator.IdAllocatorV2Shape; - readonly host: ProviderHost.ProviderHostShape; /** How agents spawn this install's `acp-mcp-bridge`; see `resolveSelfInvocation`. */ readonly selfInvocation: SelfInvocation; /** @@ -1490,10 +1485,14 @@ function shouldPersistToolUpdate( return persist; } -export function makeAcpAdapterV2( +export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* ( options: AcpAdapterV2Options, -): ProviderAdapter.ProviderAdapterV2Shape { - const { flavor, fileSystem, idAllocator, host, selfInvocation: self } = options; +) { + const crypto = yield* Crypto.Crypto; + const fileSystem = yield* FileSystem.FileSystem; + const idAllocator = yield* IdAllocator.IdAllocatorV2; + const host = yield* ProviderHost.ProviderHost; + const { flavor, selfInvocation: self } = options; const driver = flavor.driver; const continuationRequests = options.continuationRequests; const postSettleContinuationEnabled = @@ -5999,7 +5998,7 @@ export function makeAcpAdapterV2( const mcpBridge = yield* makeAcpMcpOverAcpBridge({ endpoint: mcpContext.endpoint, authorization: mcpContext.authorization, - allocateConnectionId: options.crypto.randomUUIDv4.pipe(Effect.orDie), + allocateConnectionId: crypto.randomUUIDv4.pipe(Effect.orDie), }); yield* Scope.addFinalizer(scope, mcpBridge.dispose); return mcpBridge; @@ -6019,7 +6018,7 @@ export function makeAcpAdapterV2( .makeRuntime(makeRuntimeInput(runtimeGeneration, threadId, resumeSessionId)) .pipe( Effect.provideService(Scope.Scope, runtimeScope), - Effect.provideService(Crypto.Crypto, options.crypto), + Effect.provideService(Crypto.Crypto, crypto), ); }); @@ -6096,7 +6095,7 @@ export function makeAcpAdapterV2( ) .pipe( Effect.provideService(Scope.Scope, replacementScope), - Effect.provideService(Crypto.Crypto, options.crypto), + Effect.provideService(Crypto.Crypto, crypto), ); // Session setup may publish commands before it returns. Buffer those // notifications, but do not expose request or extension handlers @@ -8049,6 +8048,6 @@ export function makeAcpAdapterV2( ), ), }); -} +}); export type AcpAdapterV2Env = FileSystem.FileSystem | IdAllocator.IdAllocatorV2; diff --git a/packages/provider-core/src/server/ProviderHost.ts b/packages/provider-core/src/server/ProviderHost.ts index a8509b01e130..9e889f1f816a 100644 --- a/packages/provider-core/src/server/ProviderHost.ts +++ b/packages/provider-core/src/server/ProviderHost.ts @@ -45,7 +45,7 @@ export interface ProviderCredentials { readonly remove: Effect.Effect; } -export interface ProviderHostShape { +interface ProviderHostService { readonly paths: ProviderHostPaths; readonly settings: { readonly get: Effect.Effect; @@ -68,6 +68,6 @@ export interface ProviderHostShape { ) => Effect.Effect; } -export class ProviderHost extends Context.Service()( +export class ProviderHost extends Context.Service()( "@t3tools/provider-core/server/ProviderHost", ) {} diff --git a/packages/provider-core/src/server/managedProvider.test.ts b/packages/provider-core/src/server/managedProvider.test.ts index 76f7fda46954..58eae9fbbd31 100644 --- a/packages/provider-core/src/server/managedProvider.test.ts +++ b/packages/provider-core/src/server/managedProvider.test.ts @@ -99,7 +99,7 @@ const refreshedSnapshotSecond: ServerProvider = { /** A host whose settings never change and whose background demand is fixed. */ function layerProviderHost(input: { readonly runBackgroundWork: boolean; - readonly settings?: Pick["settings"]; + readonly settings?: Pick["settings"]; }) { return Layer.succeed( ProviderHost.ProviderHost, @@ -283,7 +283,7 @@ describe("makeManagedServerProvider", () => { }; const serverSettingsRef = yield* Ref.make(initialServerSettings); const serverSettingsChanges = yield* PubSub.unbounded(); - const hostSettings: ProviderHost.ProviderHostShape["settings"] = { + const hostSettings: ProviderHost.ProviderHost["Service"]["settings"] = { get: Ref.get(serverSettingsRef), changes: Stream.empty, subscribe: PubSub.subscribe(serverSettingsChanges).pipe( diff --git a/packages/provider-core/src/server/snapshotSettings.ts b/packages/provider-core/src/server/snapshotSettings.ts index 5a1d207b15ee..f434d35b967e 100644 --- a/packages/provider-core/src/server/snapshotSettings.ts +++ b/packages/provider-core/src/server/snapshotSettings.ts @@ -29,7 +29,7 @@ export function haveProviderSnapshotSettingsChanged( export function makeProviderSnapshotSettingsSource( provider: Settings, - settings: ProviderHost.ProviderHostShape["settings"], + settings: ProviderHost.ProviderHost["Service"]["settings"], ): { readonly getSettings: Effect.Effect, ServerSettingsError>; readonly streamSettings: Stream.Stream>; diff --git a/packages/provider-cursor/src/server/adapter.test.ts b/packages/provider-cursor/src/server/adapter.test.ts index 730cbb7649f8..5292d782e50d 100644 --- a/packages/provider-cursor/src/server/adapter.test.ts +++ b/packages/provider-cursor/src/server/adapter.test.ts @@ -22,7 +22,6 @@ import * as Path from "effect/Path"; import * as Schema from "effect/Schema"; import * as Stream from "effect/Stream"; -import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost"; import { layerTestProviderHost } from "@t3tools/provider-testing/host"; import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession"; import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator"; @@ -51,7 +50,6 @@ describe("CursorAdapterV2", () => { ({ status, model, lateModel }) => Effect.gen(function* () { const fileSystem = yield* FileSystem.FileSystem; - const path = yield* Path.Path; const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-v2-lifecycle-", }); @@ -63,17 +61,12 @@ describe("CursorAdapterV2", () => { interactionMode: "default", cwd: workspace, }); - const adapter = makeCursorAdapterV2({ + const adapter = yield* makeCursorAdapterV2({ instanceId, settings: yield* decodeCursorSettings({}), environment: { HOME: workspace }, - fileSystem, - path, - idAllocator: yield* IdAllocator.IdAllocatorV2, - host: yield* ProviderHost.ProviderHost.pipe( - Effect.provide(layerTestProviderHost({ cwd: workspace })), - ), - runner: { + }).pipe( + Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, { assertComplete: Effect.void, open: () => Effect.succeed({ @@ -131,8 +124,9 @@ describe("CursorAdapterV2", () => { }; }), }), - }, - }); + }), + Effect.provide(layerTestProviderHost({ cwd: workspace })), + ); const runtime = yield* adapter.openSession({ threadId, providerSessionId: ProviderSessionId.make("cursor-lifecycle-session"), @@ -211,7 +205,6 @@ describe("CursorAdapterV2", () => { it.effect("fails standalone SDK transport diagnostics and sends compaction as /compress", () => Effect.gen(function* () { const fileSystem = yield* FileSystem.FileSystem; - const path = yield* Path.Path; const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-v2-errors-" }); const sentMessages: Array = []; let sendCalls = 0; @@ -223,17 +216,12 @@ describe("CursorAdapterV2", () => { interactionMode: "default", cwd: workspace, }); - const adapter = makeCursorAdapterV2({ + const adapter = yield* makeCursorAdapterV2({ instanceId, settings: yield* decodeCursorSettings({}), environment: { HOME: workspace }, - fileSystem, - path, - idAllocator: yield* IdAllocator.IdAllocatorV2, - host: yield* ProviderHost.ProviderHost.pipe( - Effect.provide(layerTestProviderHost({ cwd: workspace })), - ), - runner: { + }).pipe( + Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, { assertComplete: Effect.void, open: () => Effect.succeed({ @@ -264,8 +252,9 @@ describe("CursorAdapterV2", () => { }; }), }), - }, - }); + }), + Effect.provide(layerTestProviderHost({ cwd: workspace })), + ); const runtime = yield* adapter.openSession({ threadId, providerSessionId: ProviderSessionId.make("cursor-error-session"), @@ -564,17 +553,12 @@ describe("CursorAdapterV2", () => { }, }, ]; - const adapter = makeCursorAdapterV2({ + const adapter = yield* makeCursorAdapterV2({ instanceId, settings: yield* decodeCursorSettings({}), environment: { HOME: workspace }, - fileSystem, - path, - idAllocator: yield* IdAllocator.IdAllocatorV2, - host: yield* ProviderHost.ProviderHost.pipe( - Effect.provide(layerTestProviderHost({ cwd: workspace })), - ), - runner: { + }).pipe( + Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, { assertComplete: Effect.void, open: () => Effect.succeed({ @@ -602,8 +586,9 @@ describe("CursorAdapterV2", () => { }; }), }), - }, - }); + }), + Effect.provide(layerTestProviderHost({ cwd: workspace })), + ); const runtime = yield* adapter.openSession({ threadId, providerSessionId: ProviderSessionId.make("cursor-search-session"), diff --git a/packages/provider-cursor/src/server/adapter.ts b/packages/provider-cursor/src/server/adapter.ts index 33796270205a..5aa9e836bd73 100644 --- a/packages/provider-cursor/src/server/adapter.ts +++ b/packages/provider-cursor/src/server/adapter.ts @@ -844,17 +844,17 @@ export interface CursorAdapterV2Options { readonly instanceId: ProviderInstanceId; readonly settings: CursorSettings; readonly environment: NodeJS.ProcessEnv; - readonly fileSystem: FileSystem.FileSystem; - readonly path: Path.Path; - readonly idAllocator: IdAllocator.IdAllocatorV2Shape; - readonly runner: CursorAgentSdk.CursorAgentSdkRunnerShape; - readonly host: ProviderHost.ProviderHostShape; } -export function makeCursorAdapterV2( - adapterOptions: CursorAdapterV2Options, -): ProviderAdapter.ProviderAdapterV2Shape { - const { fileSystem, path, idAllocator, runner, host } = adapterOptions; +export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* ( + options: CursorAdapterV2Options, +) { + const fileSystem = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const idAllocator = yield* IdAllocator.IdAllocatorV2; + const runner = yield* CursorAgentSdk.CursorAgentSdkRunner; + const host = yield* ProviderHost.ProviderHost; + const adapterOptions = options; const apiKey = adapterOptions.environment.CURSOR_API_KEY?.trim() || undefined; return ProviderAdapter.ProviderAdapterV2.of({ @@ -2596,7 +2596,7 @@ export function makeCursorAdapterV2( ), ), }); -} +}); export type CursorAdapterV2DriverEnv = | CursorAgentSdk.CursorAgentSdkRunner @@ -2615,23 +2615,13 @@ export const CursorAdapterV2Driver: ProviderAdapterDriver< create: Effect.fn("CursorAdapterV2Driver.create")( function* (input: ProviderAdapterDriverCreateInput) { const hostEnvironment = yield* HostProcessEnvironment; - const fileSystem = yield* FileSystem.FileSystem; - const path = yield* Path.Path; - const idAllocator = yield* IdAllocator.IdAllocatorV2; - const runner = yield* CursorAgentSdk.CursorAgentSdkRunner; - const host = yield* ProviderHost.ProviderHost; - return makeCursorAdapterV2({ + return yield* makeCursorAdapterV2({ instanceId: input.instanceId, settings: { ...input.config, enabled: input.enabled, }, environment: mergeProviderInstanceEnvironment(input.environment, hostEnvironment), - fileSystem, - path, - idAllocator, - runner, - host, }); }, (effect, input) => @@ -2661,20 +2651,10 @@ const layer: Layer.Layer< ProviderAdapter.ProviderAdapterV2, Effect.gen(function* () { const hostEnvironment = yield* HostProcessEnvironment; - const fileSystem = yield* FileSystem.FileSystem; - const path = yield* Path.Path; - const idAllocator = yield* IdAllocator.IdAllocatorV2; - const runner = yield* CursorAgentSdk.CursorAgentSdkRunner; - const host = yield* ProviderHost.ProviderHost; - return makeCursorAdapterV2({ + return yield* makeCursorAdapterV2({ instanceId: CURSOR_DEFAULT_INSTANCE_ID, settings: DEFAULT_CURSOR_SETTINGS, environment: hostEnvironment, - fileSystem, - path, - idAllocator, - runner, - host, }); }), ); diff --git a/packages/provider-cursor/src/server/credentialStore.test.ts b/packages/provider-cursor/src/server/credentialStore.test.ts index 5e176b661c46..803324d9f979 100644 --- a/packages/provider-cursor/src/server/credentialStore.test.ts +++ b/packages/provider-cursor/src/server/credentialStore.test.ts @@ -4,7 +4,6 @@ import { ProviderInstanceId } from "@t3tools/contracts"; import * as Effect from "effect/Effect"; import * as FileSystem from "effect/FileSystem"; import * as Path from "effect/Path"; -import * as Option from "effect/Option"; import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost"; import { layerTestProviderHost } from "@t3tools/provider-testing/host"; diff --git a/packages/provider-grok/src/server/adapter.ts b/packages/provider-grok/src/server/adapter.ts index 757e27bceef5..b25faa9db4e7 100644 --- a/packages/provider-grok/src/server/adapter.ts +++ b/packages/provider-grok/src/server/adapter.ts @@ -112,12 +112,7 @@ export interface GrokAdapterV2Options { readonly settings: GrokSettings; readonly environment: NodeJS.ProcessEnv; readonly hostPlatform: NodeJS.Platform; - readonly childProcessSpawner: ChildProcessSpawner.ChildProcessSpawner["Service"]; - readonly crypto: Crypto.Crypto; readonly selfInvocation: SelfInvocation; - readonly fileSystem: FileSystem.FileSystem; - readonly idAllocator: IdAllocator.IdAllocatorV2["Service"]; - readonly host: ProviderHost.ProviderHostShape; readonly nativeLogging?: Parameters[0]["nativeLogging"]; readonly continuationRequests?: Parameters[0]["continuationRequests"]; readonly testHooks?: Parameters[0]["testHooks"]; @@ -229,7 +224,12 @@ export function grokLaunchRuntimeMode( : "approval-required"; } -export function makeGrokAcpAdapterFlavor(options: GrokAdapterV2Options): AcpAdapterV2Flavor { +/** The flavor runs Grok's launcher through the adapter's spawner. */ +export function makeGrokAcpAdapterFlavor( + options: GrokAdapterV2Options & { + readonly childProcessSpawner: ChildProcessSpawner.ChildProcessSpawner["Service"]; + }, +): AcpAdapterV2Flavor { return { driver: GROK_PROVIDER, runtimeHarness: "Grok", @@ -329,15 +329,14 @@ export function makeGrokAcpAdapterFlavor(options: GrokAdapterV2Options): AcpAdap }; } -export function makeGrokAdapterV2(options: GrokAdapterV2Options) { - const flavor = makeGrokAcpAdapterFlavor(options); - return makeAcpAdapterV2({ +export const makeGrokAdapterV2 = Effect.fn("makeGrokAdapterV2")(function* ( + options: GrokAdapterV2Options, +) { + const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; + const flavor = makeGrokAcpAdapterFlavor({ ...options, childProcessSpawner }); + return yield* makeAcpAdapterV2({ instanceId: options.instanceId, flavor, - crypto: options.crypto, - fileSystem: options.fileSystem, - idAllocator: options.idAllocator, - host: options.host, selfInvocation: options.selfInvocation, ...(options.nativeLogging === undefined ? {} : { nativeLogging: options.nativeLogging }), ...(options.continuationRequests === undefined @@ -345,7 +344,7 @@ export function makeGrokAdapterV2(options: GrokAdapterV2Options) { : { continuationRequests: options.continuationRequests }), ...(options.testHooks === undefined ? {} : { testHooks: options.testHooks }), }); -} +}); export type GrokAdapterV2DriverEnv = | ChildProcessSpawner.ChildProcessSpawner @@ -365,24 +364,14 @@ export const GrokAdapterV2Driver: ProviderAdapterDriver @@ -424,24 +413,14 @@ const layer: Layer.Layer< const hostEnvironment = yield* HostProcessEnvironment; const hostPlatform = yield* HostProcessPlatform; const selfInvocation = yield* resolveSelfInvocation(); - const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const crypto = yield* Crypto.Crypto; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const providerEventLoggers = yield* ProviderEventLoggers.ProviderEventLoggers; - const host = yield* ProviderHost.ProviderHost; const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests; const makeNativeLogger = yield* makeAcpNativeLoggerFactory(); - return makeGrokAdapterV2({ + return yield* makeGrokAdapterV2({ instanceId: GROK_DEFAULT_INSTANCE_ID, settings: DEFAULT_GROK_SETTINGS, environment: hostEnvironment, hostPlatform, - childProcessSpawner, - crypto, - fileSystem, - idAllocator, - host, selfInvocation, continuationRequests, nativeLogging: (threadId) => diff --git a/packages/provider-muse/src/server/adapter.test.ts b/packages/provider-muse/src/server/adapter.test.ts index c73dbb4e2297..33191bb8e46e 100644 --- a/packages/provider-muse/src/server/adapter.test.ts +++ b/packages/provider-muse/src/server/adapter.test.ts @@ -24,14 +24,12 @@ import * as Deferred from "effect/Deferred"; import * as Effect from "effect/Effect"; import * as Option from "effect/Option"; import type * as Exit from "effect/Exit"; -import * as FileSystem from "effect/FileSystem"; import * as Fiber from "effect/Fiber"; import * as Layer from "effect/Layer"; import * as Queue from "effect/Queue"; import * as Schema from "effect/Schema"; import * as Stream from "effect/Stream"; -import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost"; import { layerTestProviderHost } from "@t3tools/provider-testing/host"; import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession"; import type { MuseItem } from "./protocol.ts"; @@ -195,13 +193,10 @@ const makeHarness = Effect.fnUntraced(function* ( > = {}, ) { let hostCount = 0; - const adapter = makeMuseAdapterV2({ + const adapter = yield* makeMuseAdapterV2({ instanceId, settings: museSettings, environment: { PATH: "/fake/bin" }, - idAllocator: yield* IdAllocator.IdAllocatorV2, - host: yield* ProviderHost.ProviderHost, - fileSystem: yield* FileSystem.FileSystem, createHost: async () => (hostCount++ === 0 ? fake.host : (replacement ?? fake).host), ...overrides, }); @@ -434,13 +429,10 @@ describe("MuseAdapterV2", () => { for (const kind of ["sessionNotFound", "notFound"] as const) { const fake = yield* makeFakeMuse(); const allocated = yield* preallocatedProviderThread(); - const adapter = makeMuseAdapterV2({ + const adapter = yield* makeMuseAdapterV2({ instanceId: INSTANCE_ID, settings: museSettings, environment: { PATH: "/fake/bin" }, - idAllocator: yield* IdAllocator.IdAllocatorV2, - host: yield* ProviderHost.ProviderHost, - fileSystem: yield* FileSystem.FileSystem, createHost: async () => fake.host, }); const runtime = yield* adapter.openSession({ diff --git a/packages/provider-muse/src/server/adapter.ts b/packages/provider-muse/src/server/adapter.ts index 686fb64f1dc8..c834e1370ebe 100644 --- a/packages/provider-muse/src/server/adapter.ts +++ b/packages/provider-muse/src/server/adapter.ts @@ -35,7 +35,7 @@ import * as Semaphore from "effect/Semaphore"; import * as Scope from "effect/Scope"; import * as Stream from "effect/Stream"; -import type * as ProviderHost from "@t3tools/provider-core/server/ProviderHost"; +import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost"; import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession"; import { buildRuntimeInstructions } from "@t3tools/provider-core/server/runtimeInstructions"; import { museModelCapabilities, resolveMuseReasoningEffort } from "./modelCatalog.ts"; @@ -181,9 +181,6 @@ export interface MuseAdapterV2Options { readonly instanceId: ProviderInstanceId; readonly settings: MuseSettings; readonly environment: NodeJS.ProcessEnv; - readonly idAllocator: IdAllocator.IdAllocatorV2["Service"]; - readonly host: ProviderHost.ProviderHostShape; - readonly fileSystem: FileSystem.FileSystem; readonly modelCatalog?: Effect.Effect>; readonly createHost?: typeof createMuseSdkHost; readonly requestTimeoutMs?: number; @@ -245,10 +242,13 @@ const TOOLS_WITH_NATIVE_ROWS = new Set(["write_todos", "request_user_input", "wo const responseAnswerSchema = Schema.Union([Schema.String, Schema.Array(Schema.String)]); /** One scoped Muse host owns one native session; the orchestrator owns app runs and queuing. */ -export function makeMuseAdapterV2( +export const makeMuseAdapterV2 = Effect.fn("makeMuseAdapterV2")(function* ( options: MuseAdapterV2Options, -): ProviderAdapter.ProviderAdapterV2Shape { - const { idAllocator } = options; +) { + const idAllocator = yield* IdAllocator.IdAllocatorV2; + const providerHost = yield* ProviderHost.ProviderHost; + const fileSystem = yield* FileSystem.FileSystem; + const protocolError = (detail: string, payload?: unknown) => new ProviderAdapter.ProviderAdapterProtocolError({ driver: MUSE_PROVIDER, @@ -269,8 +269,8 @@ export function makeMuseAdapterV2( const scope = yield* Effect.scope; // Muse rejects non-canonical workspace roots (for example macOS /tmp) and // reports canonical paths in approvals, so resolve symlinks once here. - const requestedCwd = input.runtimePolicy.cwd ?? options.host.paths.cwd; - const cwd = yield* options.fileSystem + const requestedCwd = input.runtimePolicy.cwd ?? providerHost.paths.cwd; + const cwd = yield* fileSystem .realPath(requestedCwd) .pipe(Effect.orElseSucceed(() => requestedCwd)); const now = yield* DateTime.now; @@ -1581,14 +1581,14 @@ export function makeMuseAdapterV2( const text = providerMessageTextWithAttachmentPaths({ text: message.text, attachments: message.attachments, - resolveAttachmentPath: options.host.resolveAttachmentPath, + resolveAttachmentPath: providerHost.resolveAttachmentPath, }); if (text) parts.push({ type: "text", text }); for (const attachment of message.attachments) if (isProviderNativeImageAttachment(attachment)) { - const path = options.host.resolveAttachmentPath(attachment); + const path = providerHost.resolveAttachmentPath(attachment); if (!path) return yield* protocolError("Muse image attachment is missing"); - const bytes = yield* options.fileSystem + const bytes = yield* fileSystem .readFile(path) .pipe(Effect.mapError((cause) => protocolError("Cannot read Muse image", cause))); parts.push({ @@ -2031,4 +2031,4 @@ export function makeMuseAdapterV2( return runtime; }), }); -} +}); diff --git a/packages/provider-muse/src/server/driver.ts b/packages/provider-muse/src/server/driver.ts index 8b9b5b1fa967..805749f7ef8c 100644 --- a/packages/provider-muse/src/server/driver.ts +++ b/packages/provider-muse/src/server/driver.ts @@ -63,7 +63,6 @@ export const MuseDriver: ProviderDriver = { const host = yield* ProviderHost.ProviderHost; const eventLoggers = yield* ProviderEventLoggers.ProviderEventLoggers; const { cwd } = host.paths; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests; const hostEnvironment = yield* HostProcessEnvironment; // Drop an inherited META_API_KEY so Muse uses its login; an instance value still wins. @@ -148,13 +147,10 @@ export const MuseDriver: ProviderDriver = { ), ); const modelCatalog = snapshot.getSnapshot.pipe(Effect.map((current) => current.models)); - const orchestrationAdapter = makeMuseAdapterV2({ + const orchestrationAdapter = yield* makeMuseAdapterV2({ instanceId, settings: effectiveConfig, environment: processEnvironment, - idAllocator, - host, - fileSystem, modelCatalog, ...(eventLoggers.native ? { nativeEventLogger: eventLoggers.native } : {}), continuationRequests, diff --git a/packages/provider-opencode/src/server/adapter.test.ts b/packages/provider-opencode/src/server/adapter.test.ts index 9f80cdbead98..a6967c8ec9d8 100644 --- a/packages/provider-opencode/src/server/adapter.test.ts +++ b/packages/provider-opencode/src/server/adapter.test.ts @@ -34,7 +34,7 @@ import * as TestClock from "effect/testing/TestClock"; import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost"; import { layerTestProviderHost } from "@t3tools/provider-testing/host"; import type * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers"; -import type * as OpenCodeRuntime from "./OpenCodeRuntime.ts"; +import * as OpenCodeRuntime from "./OpenCodeRuntime.ts"; import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator"; import { @@ -148,7 +148,6 @@ const makeOpenCodeRuntimeHarness = Effect.fn("makeOpenCodeRuntimeHarness")(funct nativeSessionId: string, client: object, ) { - const idAllocator = yield* IdAllocator.IdAllocatorV2; const instanceId = ProviderInstanceId.make(`opencode-${suffix}`); const threadId = ThreadId.make(`thread-opencode-${suffix}`); const modelSelection = { @@ -157,20 +156,20 @@ const makeOpenCodeRuntimeHarness = Effect.fn("makeOpenCodeRuntimeHarness")(funct options: [], }; const policy = runtimePolicy("full-access", { cwd: "/workspace" }); - const adapter = makeOpenCodeAdapterV2({ + const adapter = yield* makeOpenCodeAdapterV2({ instanceId, settings: OPEN_CODE_TEST_SETTINGS, environment: {}, - runtime: { + }).pipe( + Effect.provideService(OpenCodeRuntime.OpenCodeRuntime, { connectToOpenCodeServer: () => Effect.succeed({ url: "http://test.invalid", external: true }), createOpenCodeSdkClient: () => client, - } as unknown as OpenCodeRuntime.OpenCodeRuntimeShape, - idAllocator, - host: { + } as unknown as OpenCodeRuntime.OpenCodeRuntimeShape), + Effect.provideService(ProviderHost.ProviderHost, { paths: { cwd: "/workspace" }, resolveAttachmentPath: () => null, - } as unknown as ProviderHost.ProviderHostShape, - }); + } as unknown as ProviderHost.ProviderHost["Service"]), + ); const runtime = yield* adapter.openSession({ threadId, providerSessionId: ProviderSessionId.make(`session-opencode-${suffix}`), @@ -1421,7 +1420,6 @@ describe("OpenCodeAdapterV2", () => { it.effect("keeps a newly admitted prompt alive across stale idle and delayed busy evidence", () => Effect.gen(function* () { - const idAllocator = yield* IdAllocator.IdAllocatorV2; const nativeEvents = asyncEventStream(); const prompt = promiseGate(); const promptStarted = promiseGate(); @@ -1488,21 +1486,21 @@ describe("OpenCodeAdapterV2", () => { }, mcp: { add: async () => ({ data: true }) }, }; - const adapter = makeOpenCodeAdapterV2({ + const adapter = yield* makeOpenCodeAdapterV2({ instanceId: ProviderInstanceId.make("opencode-test"), settings: OPEN_CODE_TEST_SETTINGS, environment: {}, - runtime: { + }).pipe( + Effect.provideService(OpenCodeRuntime.OpenCodeRuntime, { connectToOpenCodeServer: () => Effect.succeed({ url: "http://test.invalid", external: true }), createOpenCodeSdkClient: () => client, - } as unknown as OpenCodeRuntime.OpenCodeRuntimeShape, - idAllocator, - host: { + } as unknown as OpenCodeRuntime.OpenCodeRuntimeShape), + Effect.provideService(ProviderHost.ProviderHost, { paths: { cwd: "/workspace" }, resolveAttachmentPath: () => null, - } as unknown as ProviderHost.ProviderHostShape, - }); + } as unknown as ProviderHost.ProviderHost["Service"]), + ); const threadId = ThreadId.make("thread-opencode-admission-race"); const providerSessionId = ProviderSessionId.make("session-opencode-admission-race"); const modelSelection = { @@ -1739,7 +1737,6 @@ describe("OpenCodeAdapterV2", () => { it.effect("interrupts an initial prompt while its SDK request is pending", () => Effect.gen(function* () { - const idAllocator = yield* IdAllocator.IdAllocatorV2; const nativeEvents = asyncEventStream(); const promptStarted = promiseGate(); const abortCalled = promiseGate(); @@ -1783,21 +1780,21 @@ describe("OpenCodeAdapterV2", () => { }, mcp: { add: async () => ({ data: true }) }, }; - const adapter = makeOpenCodeAdapterV2({ + const adapter = yield* makeOpenCodeAdapterV2({ instanceId: ProviderInstanceId.make("opencode-initial-stop-test"), settings: OPEN_CODE_TEST_SETTINGS, environment: {}, - runtime: { + }).pipe( + Effect.provideService(OpenCodeRuntime.OpenCodeRuntime, { connectToOpenCodeServer: () => Effect.succeed({ url: "http://test.invalid", external: true }), createOpenCodeSdkClient: () => client, - } as unknown as OpenCodeRuntime.OpenCodeRuntimeShape, - idAllocator, - host: { + } as unknown as OpenCodeRuntime.OpenCodeRuntimeShape), + Effect.provideService(ProviderHost.ProviderHost, { paths: { cwd: "/workspace" }, resolveAttachmentPath: () => null, - } as unknown as ProviderHost.ProviderHostShape, - }); + } as unknown as ProviderHost.ProviderHost["Service"]), + ); const threadId = ThreadId.make("thread-opencode-initial-stop"); const providerSessionId = ProviderSessionId.make("session-opencode-initial-stop"); const modelSelection = { @@ -2419,8 +2416,6 @@ describe("OpenCodeAdapterV2", () => { it.effect("adopts the handed-over provider thread identity on session create", () => Effect.gen(function* () { - const idAllocator = yield* IdAllocator.IdAllocatorV2; - const host = yield* ProviderHost.ProviderHost; let createCount = 0; const createInputs: Array = []; const fakeClient = { @@ -2467,14 +2462,11 @@ describe("OpenCodeAdapterV2", () => { const instanceId = ProviderInstanceId.make("opencode"); const threadId = ThreadId.make("thread-opencode-adopt"); const modelSelection = { instanceId, model: "default" }; - const adapter = makeOpenCodeAdapterV2({ + const adapter = yield* makeOpenCodeAdapterV2({ instanceId, settings: OPENCODE_TEST_SETTINGS, environment: {}, - runtime, - idAllocator, - host, - }); + }).pipe(Effect.provideService(OpenCodeRuntime.OpenCodeRuntime, runtime)); const session = yield* adapter.openSession({ threadId, providerSessionId: ProviderSessionId.make("provider-session-opencode-adopt"), diff --git a/packages/provider-opencode/src/server/adapter.ts b/packages/provider-opencode/src/server/adapter.ts index 0fa85f3be6d4..8c9f5e83ae6c 100644 --- a/packages/provider-opencode/src/server/adapter.ts +++ b/packages/provider-opencode/src/server/adapter.ts @@ -438,9 +438,6 @@ export interface OpenCodeAdapterV2Options { readonly instanceId: ProviderInstanceId; readonly settings: OpenCodeSettings; readonly environment: NodeJS.ProcessEnv; - readonly runtime: OpenCodeRuntime.OpenCodeRuntimeShape; - readonly idAllocator: IdAllocator.IdAllocatorV2Shape; - readonly host: ProviderHost.ProviderHostShape; readonly nativeEventLogger?: ProviderEventLoggers.EventNdjsonLogger; } @@ -944,10 +941,12 @@ function unwrapData(operation: string, result: { readonly data?: A }): NonNul return result.data as NonNullable; } -export function makeOpenCodeAdapterV2( +export const makeOpenCodeAdapterV2 = Effect.fn("makeOpenCodeAdapterV2")(function* ( options: OpenCodeAdapterV2Options, -): ProviderAdapter.ProviderAdapterV2Shape { - const { idAllocator, runtime, host } = options; +) { + const runtime = yield* OpenCodeRuntime.OpenCodeRuntime; + const idAllocator = yield* IdAllocator.IdAllocatorV2; + const host = yield* ProviderHost.ProviderHost; return ProviderAdapter.ProviderAdapterV2.of({ instanceId: options.instanceId, @@ -3724,7 +3723,7 @@ export function makeOpenCodeAdapterV2( ), ), }); -} +}); export type OpenCodeAdapterV2DriverEnv = | OpenCodeRuntime.OpenCodeRuntime @@ -3742,17 +3741,11 @@ export const OpenCodeAdapterV2Driver: ProviderAdapterDriver< create: Effect.fn("OpenCodeAdapterV2Driver.create")( function* (input: ProviderAdapterDriverCreateInput) { const hostEnvironment = yield* HostProcessEnvironment; - const openCodeRuntime = yield* OpenCodeRuntime.OpenCodeRuntime; - const idAllocator = yield* IdAllocator.IdAllocatorV2; const providerEventLoggers = yield* ProviderEventLoggers.ProviderEventLoggers; - const host = yield* ProviderHost.ProviderHost; - return makeOpenCodeAdapterV2({ + return yield* makeOpenCodeAdapterV2({ instanceId: input.instanceId, settings: { ...input.config, enabled: input.enabled }, environment: mergeProviderInstanceEnvironment(input.environment, hostEnvironment), - runtime: openCodeRuntime, - idAllocator, - host, ...(providerEventLoggers.native === undefined ? {} : { nativeEventLogger: providerEventLoggers.native }), @@ -3778,17 +3771,11 @@ const layer: Layer.Layer, - resolveAttachmentPath: ProviderHost.ProviderHostShape["resolveAttachmentPath"], + resolveAttachmentPath: ProviderHost.ProviderHost["Service"]["resolveAttachmentPath"], ) => Effect.gen(function* () { const { client } = connection; diff --git a/packages/provider-pi/src/server/adapter.test.ts b/packages/provider-pi/src/server/adapter.test.ts index 19a32596ee0e..ff9486cb854c 100644 --- a/packages/provider-pi/src/server/adapter.test.ts +++ b/packages/provider-pi/src/server/adapter.test.ts @@ -22,7 +22,6 @@ import * as DateTime from "effect/DateTime"; import * as Duration from "effect/Duration"; import * as Effect from "effect/Effect"; import * as Fiber from "effect/Fiber"; -import * as FileSystem from "effect/FileSystem"; import * as Layer from "effect/Layer"; import * as PlatformError from "effect/PlatformError"; import * as Queue from "effect/Queue"; @@ -31,21 +30,14 @@ import * as Sink from "effect/Sink"; import * as Stream from "effect/Stream"; import * as TestClock from "effect/testing/TestClock"; import { ChildProcess, ChildProcessSpawner } from "effect/process"; -import { HostProcessEnvironment } from "@t3tools/shared/hostProcess"; -import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost"; import { layerTestProviderHost } from "@t3tools/provider-testing/host"; import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests"; import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession"; import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator"; import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter"; import { handoffBudget } from "@t3tools/provider-core/server/handoffBudget"; -import { - makePiAdapterV2, - PiAdapterV2Driver, - PI_PROVIDER, - type PiAdapterV2Options, -} from "./adapter.ts"; +import { makePiAdapterV2, PI_PROVIDER, type PiAdapterV2Options } from "./adapter.ts"; import { makePiRpcConnection, type PiRpcRecord } from "./rpc.ts"; const layerTest = Layer.mergeAll( @@ -326,9 +318,6 @@ const makeAdapter = Effect.fnUntraced(function* ( forkFake?: FakePi, continuationRequests?: PiAdapterV2Options["continuationRequests"], ) { - const idAllocator = yield* IdAllocator.IdAllocatorV2; - const host = yield* ProviderHost.ProviderHost; - const fileSystem = yield* FileSystem.FileSystem; const spawner = forkFake === undefined ? fake.spawner @@ -337,31 +326,12 @@ const makeAdapter = Effect.fnUntraced(function* ( ? forkFake.spawner.spawn(command) : fake.spawner.spawn(command), ); - if (continuationRequests !== undefined) { - return yield* PiAdapterV2Driver.create({ - instanceId: PI_INSTANCE_ID, - displayName: undefined, - enabled: true, - environment: [], - config: { enabled: true, binaryPath: "pi", launchArgs, customModels: [] }, - }).pipe( - Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner), - Effect.provideService(HostProcessEnvironment, {}), - Effect.provideService(ProviderContinuationRequests.ProviderContinuationRequests, { - ...continuationRequests, - take: Effect.never, - }), - ); - } - return makePiAdapterV2({ + return yield* makePiAdapterV2({ instanceId: PI_INSTANCE_ID, settings: { enabled: true, binaryPath: "pi", launchArgs, customModels: [] }, environment: {}, - spawner, - fileSystem, - idAllocator, - host, - }); + ...(continuationRequests === undefined ? {} : { continuationRequests }), + }).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner)); }); const openRuntime = Effect.fnUntraced(function* ( diff --git a/packages/provider-pi/src/server/adapter.ts b/packages/provider-pi/src/server/adapter.ts index 06f702c7eb31..f27fead50605 100644 --- a/packages/provider-pi/src/server/adapter.ts +++ b/packages/provider-pi/src/server/adapter.ts @@ -228,10 +228,10 @@ export interface PiAdapterV2Options { readonly instanceId: ProviderInstanceId; readonly settings: PiSettings; readonly environment: NodeJS.ProcessEnv; - readonly spawner: ChildProcessSpawner.ChildProcessSpawner["Service"]; - readonly fileSystem: FileSystem.FileSystem; - readonly idAllocator: IdAllocator.IdAllocatorV2["Service"]; - readonly host: ProviderHost.ProviderHostShape; + /** + * Where to offer a wake turn for provider-initiated work. Without one, such + * work has no owner and the adapter stops it. + */ readonly continuationRequests?: { readonly offer: ( request: ProviderContinuationRequests.ProviderContinuationRequest, @@ -386,10 +386,14 @@ interface PiWake { // ── adapter ─────────────────────────────────────────────────── -export function makePiAdapterV2( +export const makePiAdapterV2 = Effect.fn("makePiAdapterV2")(function* ( options: PiAdapterV2Options, -): ProviderAdapter.ProviderAdapterV2Shape { - const { idAllocator } = options; +) { + const spawner = yield* ChildProcessSpawner.ChildProcessSpawner; + const fileSystem = yield* FileSystem.FileSystem; + const idAllocator = yield* IdAllocator.IdAllocatorV2; + const host = yield* ProviderHost.ProviderHost; + const { continuationRequests } = options; const protocolError = (detail: string, payload?: unknown) => new ProviderAdapter.ProviderAdapterProtocolError({ @@ -407,11 +411,11 @@ export function makePiAdapterV2( input: ProviderAdapter.ProviderAdapterV2OpenSessionInput, ) { const scope = yield* Effect.scope; - const cwd = input.runtimePolicy.cwd ?? options.host.paths.cwd; + const cwd = input.runtimePolicy.cwd ?? host.paths.cwd; const mcpSession = McpProviderSession.readMcpProviderSession(input.threadId); const provideCacheFs = (effect: Effect.Effect) => effect.pipe( - Effect.provideService(FileSystem.FileSystem, options.fileSystem), + Effect.provideService(FileSystem.FileSystem, fileSystem), Effect.mapError( (cause) => new ProviderAdapter.ProviderAdapterOpenSessionError({ @@ -425,7 +429,7 @@ export function makePiAdapterV2( // hook. Materialize it even when this session has no MCP credential so // Supervised never silently degrades to unrestricted tool execution. const extensionPath = yield* provideCacheFs( - materializePiT3McpExtension(options.host.paths.providerStatusCacheDir), + materializePiT3McpExtension(host.paths.providerStatusCacheDir), ); const resolvedLaunchArgs = resolvePiLaunchArgs(options.settings.launchArgs); if (!resolvedLaunchArgs.ok) { @@ -444,7 +448,7 @@ export function makePiAdapterV2( cwd, env: launch.env, }).pipe( - Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, options.spawner), + Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner), Effect.mapError( (cause) => new ProviderAdapter.ProviderAdapterOpenSessionError({ @@ -1622,7 +1626,7 @@ export function makePiAdapterV2( if ( turn === null && state?.providerThread.appThreadId != null && - options.continuationRequests !== undefined && + continuationRequests !== undefined && !closed && !stopRequested ) { @@ -1633,7 +1637,7 @@ export function makePiAdapterV2( return; } yield* updateProviderSession("running", null); - yield* options.continuationRequests + yield* continuationRequests .offer({ threadId: state.providerThread.appThreadId, providerThreadId: state.providerThread.id, @@ -2337,10 +2341,10 @@ export function makePiAdapterV2( const images: Array<{ type: "image"; data: string; mimeType: string }> = []; const extraLines: Array = []; for (const attachment of attachments) { - const path = options.host.resolveAttachmentPath(attachment); + const path = host.resolveAttachmentPath(attachment); if (path === null) continue; if (attachment.mimeType.startsWith("image/")) { - const bytes = yield* options.fileSystem.readFile(path); + const bytes = yield* fileSystem.readFile(path); images.push({ type: "image", data: Buffer.from(bytes).toString("base64"), @@ -3033,7 +3037,7 @@ export function makePiAdapterV2( } return file; }), - ).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, options.spawner)); + ).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner)); const now = yield* DateTime.now; return yield* registerThread( { @@ -3082,7 +3086,7 @@ export function makePiAdapterV2( return runtime; }), }); -} +}); /** * Resolve the pi session-tree entry `fork` should re-root at for a rollback. @@ -3210,19 +3214,11 @@ export const PiAdapterV2Driver: ProviderAdapterDriver) { const hostEnvironment = yield* HostProcessEnvironment; - const spawner = yield* ChildProcessSpawner.ChildProcessSpawner; - const fileSystem = yield* FileSystem.FileSystem; - const idAllocator = yield* IdAllocator.IdAllocatorV2; - const host = yield* ProviderHost.ProviderHost; const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests; - return makePiAdapterV2({ + return yield* makePiAdapterV2({ instanceId: input.instanceId, settings: { ...input.config, enabled: input.enabled }, environment: mergeProviderInstanceEnvironment(input.environment, hostEnvironment), - spawner, - fileSystem, - idAllocator, - host, continuationRequests, }); }, @@ -3246,19 +3242,11 @@ const layer: Layer.Layer