@devries-cameron20 / t3code-1 / commits / b000eac171
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

refactor(providers): adapter factories yield their services (#17381)

Julius Marminge committed Oct 8, 2026 at 22:03 UTC b000eac171318bf0130865387ae33523eecd3019
27 files changed +270 -1030
apps/server/scripts/record-grok-acp-replay-fixture.ts
+1 -8
@@ -16,7 +16,6 @@ import { HostProcessEnvironment, HostProcessPlatform } from "@t3tools/shared/hos
16 import { resolveSelfInvocation } from "@t3tools/shared/nodeRuntime";
17 import * as Clock from "effect/Clock";
18 import * as Console from "effect/Console";
19 -import * as Crypto from "effect/Crypto";
19 import * as Effect from "effect/Effect";
20 import * as FileSystem from "effect/FileSystem";
21 import * as Layer from "effect/Layer";
@@ -25,7 +24,6 @@ import * as Schema from "effect/Schema";
24 import { ChildProcessSpawner } from "effect/process";
25 import type * as EffectAcpProtocol from "effect-acp/protocol";
26
28 -import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
27 import { layerTestProviderHost } from "@t3tools/provider-testing/host";
28 import {
29 GROK_DEFAULT_INSTANCE_ID,
@@ -447,16 +445,11 @@ const recordScenario = Effect.fn("recordGrokScenario")(function* (fixtureName: s
445 Effect.gen(function* () {
446 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
447 const environment = yield* HostProcessEnvironment;
450 - const adapter = makeGrokAdapterV2({
448 + const adapter = yield* makeGrokAdapterV2({
449 instanceId: GROK_DEFAULT_INSTANCE_ID,
450 settings,
451 environment,
452 hostPlatform: yield* HostProcessPlatform,
455 - childProcessSpawner,
456 - crypto: yield* Crypto.Crypto,
457 - fileSystem: yield* FileSystem.FileSystem,
458 - idAllocator: yield* IdAllocator.IdAllocatorV2,
459 - host: yield* ProviderHost.ProviderHost,
453 selfInvocation: yield* resolveSelfInvocation(),
454 continuationRequests: yield* ProviderContinuationRequests.ProviderContinuationRequests,
455 // Production's runtime factory, with the protocol logger teeing raw lines.
apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
+86 -623
@@ -30,7 +30,6 @@ import { GrokSettings } from "@t3tools/provider-grok/settings";
30 import { HostProcessIsExecutable, HostProcessPlatform } from "@t3tools/shared/hostProcess";
31 import { resolveSelfInvocation } from "@t3tools/shared/nodeRuntime";
32 import * as DateTime from "effect/DateTime";
33 -import * as Crypto from "effect/Crypto";
33 import * as Deferred from "effect/Deferred";
34 import type * as Duration from "effect/Duration";
35 import * as Cause from "effect/Cause";
@@ -54,7 +53,6 @@ import * as EffectAcpErrors from "effect-acp/errors";
53 import type * as EffectAcpProtocol from "effect-acp/protocol";
54 import type * as EffectAcpSchema from "effect-acp/compat";
55
57 -import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
56 import { layerTestProviderHost } from "@t3tools/provider-testing/host";
57 import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
58 import * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";
@@ -610,12 +608,8 @@ describe("AcpAdapterV2", () => {
608 const path = yield* Path.Path;
609 const instanceId = ProviderInstanceId.make(`vibe-retry-${outcome}`);
610 const threadId = ThreadId.make(`thread-vibe-retry-${outcome}`);
613 - const adapter = makeAcpAdapterV2({
614 - crypto: yield* Crypto.Crypto,
611 + const adapter = yield* makeAcpAdapterV2({
612 instanceId,
616 - fileSystem: yield* FileSystem.FileSystem,
617 - idAllocator: yield* IdAllocator.IdAllocatorV2,
618 - host: yield* ProviderHost.ProviderHost,
613 selfInvocation: yield* resolveSelfInvocation(),
614 flavor: {
615 driver: ProviderDriverKind.make("acpRegistry"),
@@ -709,10 +703,7 @@ describe("AcpAdapterV2", () => {
703 it.effect("starts the MCP bridge directly from the self-contained runtime", () =>
704 Effect.gen(function* () {
705 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
712 - const fileSystem = yield* FileSystem.FileSystem;
713 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
706 const path = yield* Path.Path;
715 - const host = yield* ProviderHost.ProviderHost;
707 const selfInvocation = yield* resolveSelfInvocation().pipe(
708 Effect.provideService(HostProcessIsExecutable, true),
709 );
@@ -739,8 +730,7 @@ describe("AcpAdapterV2", () => {
730
731 let runtimeInput: AcpAdapterV2RuntimeInput | undefined;
732 const makeRuntime = makeMockRuntime({ childProcessSpawner, mockAgentPath });
742 - const adapter = makeAcpAdapterV2({
743 - crypto: yield* Crypto.Crypto,
733 + const adapter = yield* makeAcpAdapterV2({
734 instanceId,
735 flavor: {
736 driver: ACP_TEST_DRIVER,
@@ -750,9 +740,6 @@ describe("AcpAdapterV2", () => {
740 runtimeInput = input;
741 }).pipe(Effect.andThen(makeRuntime(input))),
742 },
753 - fileSystem,
754 - idAllocator,
755 - host,
743 selfInvocation,
744 });
745 const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
@@ -782,10 +769,7 @@ describe("AcpAdapterV2", () => {
769 it.live("refreshes ACP prompt instructions when the interaction mode changes", () =>
770 Effect.gen(function* () {
771 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
785 - const fileSystem = yield* FileSystem.FileSystem;
786 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
772 const path = yield* Path.Path;
788 - const host = yield* ProviderHost.ProviderHost;
773 const selfInvocation = yield* resolveSelfInvocation();
774 const mockAgentPath = yield* path.fromFileUrl(
775 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -805,17 +789,13 @@ describe("AcpAdapterV2", () => {
789 yield* Effect.addFinalizer(() =>
790 Effect.sync(() => McpProviderSession.clearMcpProviderSession(threadId)),
791 );
808 - const adapter = makeAcpAdapterV2({
809 - crypto: yield* Crypto.Crypto,
792 + const adapter = yield* makeAcpAdapterV2({
793 instanceId,
794 flavor: {
795 driver: ACP_TEST_DRIVER,
796 capabilities: AcpProviderCapabilitiesV2,
797 makeRuntime: makeMockRuntime({ childProcessSpawner, mockAgentPath, protocolEvents }),
798 },
816 - fileSystem,
817 - idAllocator,
818 - host,
799 selfInvocation,
800 });
801 const policy = (interactionMode: "default" | "plan") =>
@@ -909,10 +889,7 @@ describe("AcpAdapterV2", () => {
889 it.effect("starts a new replay message after ACP v2 plan boundaries", () =>
890 Effect.gen(function* () {
891 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
912 - const fileSystem = yield* FileSystem.FileSystem;
913 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
892 const path = yield* Path.Path;
915 - const host = yield* ProviderHost.ProviderHost;
893 const selfInvocation = yield* resolveSelfInvocation();
894 const mockAgentPath = yield* path.fromFileUrl(
895 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -920,8 +897,7 @@ describe("AcpAdapterV2", () => {
897 type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
898 let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
899 const instanceId = ProviderInstanceId.make("acp-test-v2-plan-replay-boundary");
923 - const adapter = makeAcpAdapterV2({
924 - crypto: yield* Crypto.Crypto,
900 + const adapter = yield* makeAcpAdapterV2({
901 instanceId,
902 flavor: {
903 driver: ACP_TEST_DRIVER,
@@ -938,9 +914,6 @@ describe("AcpAdapterV2", () => {
914 }),
915 }),
916 },
941 - fileSystem,
942 - idAllocator,
943 - host,
917 selfInvocation,
918 });
919 const threadId = ThreadId.make("thread-acp-v2-plan-replay-boundary");
@@ -1043,12 +1016,8 @@ describe("AcpAdapterV2", () => {
1016 ];
1017 };
1018 const instanceId = ProviderInstanceId.make("devin-streamed-write");
1046 - const adapter = makeAcpAdapterV2({
1019 + const adapter = yield* makeAcpAdapterV2({
1020 instanceId,
1048 - crypto: yield* Crypto.Crypto,
1049 - fileSystem: yield* FileSystem.FileSystem,
1050 - idAllocator: yield* IdAllocator.IdAllocatorV2,
1051 - host: yield* ProviderHost.ProviderHost,
1021 selfInvocation: yield* resolveSelfInvocation(),
1022 flavor: {
1023 driver: ACP_TEST_DRIVER,
@@ -1178,7 +1147,6 @@ describe("AcpAdapterV2", () => {
1147 it.effect("keeps Devin parent paragraphs intact while projecting native child work", () =>
1148 Effect.gen(function* () {
1149 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
1181 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
1150 const path = yield* Path.Path;
1151 const mockAgentPath = yield* path.fromFileUrl(
1152 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -1187,14 +1155,10 @@ describe("AcpAdapterV2", () => {
1155 let handler: Parameters<Runtime["handleSessionUpdate"]>[0] | undefined;
1156 let createTerminal: Parameters<Runtime["handleCreateTerminal"]>[0] | undefined;
1157 const instanceId = ProviderInstanceId.make("devin-replay");
1190 - const adapter = makeAcpAdapterV2({
1158 + const adapter = yield* makeAcpAdapterV2({
1159 instanceId,
1160 // Production Devin runs commands through client terminals.
1161 clientTerminals: { childProcessSpawner, shellCommands: true },
1194 - crypto: yield* Crypto.Crypto,
1195 - fileSystem: yield* FileSystem.FileSystem,
1196 - idAllocator,
1197 - host: yield* ProviderHost.ProviderHost,
1162 selfInvocation: yield* resolveSelfInvocation(),
1163 flavor: {
1164 driver: ACP_TEST_DRIVER,
@@ -1511,10 +1475,7 @@ describe("AcpAdapterV2", () => {
1475 it.effect("projects ACP v2 fidelity updates into first-class orchestration items", () =>
1476 Effect.gen(function* () {
1477 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
1514 - const fileSystem = yield* FileSystem.FileSystem;
1515 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
1478 const path = yield* Path.Path;
1517 - const host = yield* ProviderHost.ProviderHost;
1479 const selfInvocation = yield* resolveSelfInvocation();
1480 const mockAgentPath = yield* path.fromFileUrl(
1481 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -1522,8 +1483,7 @@ describe("AcpAdapterV2", () => {
1483 type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
1484 let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
1485 const instanceId = ProviderInstanceId.make("acp-test-v2-fidelity");
1525 - const adapter = makeAcpAdapterV2({
1526 - crypto: yield* Crypto.Crypto,
1486 + const adapter = yield* makeAcpAdapterV2({
1487 instanceId,
1488 flavor: {
1489 driver: ACP_TEST_DRIVER,
@@ -1541,9 +1501,6 @@ describe("AcpAdapterV2", () => {
1501 }),
1502 }),
1503 },
1544 - fileSystem,
1545 - idAllocator,
1546 - host,
1504 selfInvocation,
1505 });
1506 const threadId = ThreadId.make("thread-acp-v2-fidelity");
@@ -1705,18 +1662,15 @@ describe("AcpAdapterV2", () => {
1662 () =>
1663 Effect.gen(function* () {
1664 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
1708 - const fileSystem = yield* FileSystem.FileSystem;
1665 const idAllocator = yield* IdAllocator.IdAllocatorV2;
1666 const path = yield* Path.Path;
1711 - const host = yield* ProviderHost.ProviderHost;
1667 const selfInvocation = yield* resolveSelfInvocation();
1668 const mockAgentPath = yield* path.fromFileUrl(
1669 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
1670 );
1671 const protocolEvents = yield* Queue.unbounded<EffectAcpProtocol.AcpProtocolLogEvent>();
1672 const instanceId = ProviderInstanceId.make("acp-test-eager-resume");
1718 - const adapter = makeAcpAdapterV2({
1719 - crypto: yield* Crypto.Crypto,
1673 + const adapter = yield* makeAcpAdapterV2({
1674 instanceId,
1675 flavor: {
1676 driver: ACP_TEST_DRIVER,
@@ -1727,9 +1681,6 @@ describe("AcpAdapterV2", () => {
1681 protocolEvents,
1682 }),
1683 },
1730 - fileSystem,
1731 - idAllocator,
1732 - host,
1684 selfInvocation,
1685 });
1686 const threadId = ThreadId.make("thread-acp-eager-resume");
@@ -1790,18 +1741,15 @@ describe("AcpAdapterV2", () => {
1741 it.live("preserves new-session fallback when an eager ACP session load is stale", () =>
1742 Effect.gen(function* () {
1743 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
1793 - const fileSystem = yield* FileSystem.FileSystem;
1744 const idAllocator = yield* IdAllocator.IdAllocatorV2;
1745 const path = yield* Path.Path;
1796 - const host = yield* ProviderHost.ProviderHost;
1746 const selfInvocation = yield* resolveSelfInvocation();
1747 const mockAgentPath = yield* path.fromFileUrl(
1748 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
1749 );
1750 const protocolEvents = yield* Queue.unbounded<EffectAcpProtocol.AcpProtocolLogEvent>();
1751 const instanceId = ProviderInstanceId.make("acp-test-stale-eager-resume");
1803 - const adapter = makeAcpAdapterV2({
1804 - crypto: yield* Crypto.Crypto,
1752 + const adapter = yield* makeAcpAdapterV2({
1753 instanceId,
1754 flavor: {
1755 driver: ACP_TEST_DRIVER,
@@ -1814,9 +1762,6 @@ describe("AcpAdapterV2", () => {
1762 runtimeOrdinal === 1 ? { T3_ACP_FAIL_LOAD_SESSION: "1" } : {},
1763 }),
1764 },
1817 - fileSystem,
1818 - idAllocator,
1819 - host,
1765 selfInvocation,
1766 });
1767 const threadId = ThreadId.make("thread-acp-stale-eager-resume");
@@ -1936,10 +1881,7 @@ describe("AcpAdapterV2", () => {
1881 it.live("replaces an unexpectedly terminated ACP runtime before the next turn", () =>
1882 Effect.gen(function* () {
1883 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
1939 - const fileSystem = yield* FileSystem.FileSystem;
1940 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
1884 const path = yield* Path.Path;
1942 - const host = yield* ProviderHost.ProviderHost;
1885 const selfInvocation = yield* resolveSelfInvocation();
1886 const mockAgentPath = yield* path.fromFileUrl(
1887 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -1955,8 +1897,7 @@ describe("AcpAdapterV2", () => {
1897 },
1898 });
1899 const instanceId = ProviderInstanceId.make("acp-test-unexpected-termination");
1958 - const adapter = makeAcpAdapterV2({
1959 - crypto: yield* Crypto.Crypto,
1900 + const adapter = yield* makeAcpAdapterV2({
1901 instanceId,
1902 flavor: {
1903 driver: ACP_TEST_DRIVER,
@@ -1966,9 +1907,6 @@ describe("AcpAdapterV2", () => {
1907 runtimeInputs.push(runtimeInput);
1908 }).pipe(Effect.andThen(baseMakeRuntime(runtimeInput))),
1909 },
1969 - fileSystem,
1970 - idAllocator,
1971 - host,
1910 selfInvocation,
1911 });
1912 const threadId = ThreadId.make("thread-acp-unexpected-termination");
@@ -2020,9 +1958,7 @@ describe("AcpAdapterV2", () => {
1958 if ((yield* HostProcessPlatform) !== "linux") return;
1959 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
1960 const fileSystem = yield* FileSystem.FileSystem;
2023 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
1961 const path = yield* Path.Path;
2025 - const host = yield* ProviderHost.ProviderHost;
1962 const selfInvocation = yield* resolveSelfInvocation();
1963 const mockAgentPath = yield* path.fromFileUrl(
1964 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -2034,8 +1970,7 @@ describe("AcpAdapterV2", () => {
1970 Effect.sync(() => cleanupPublishedDetachedFixture(commandPidPath)),
1971 );
1972 const instanceId = ProviderInstanceId.make("acp-test-provider-exit");
2037 - const adapter = makeAcpAdapterV2({
2038 - crypto: yield* Crypto.Crypto,
1973 + const adapter = yield* makeAcpAdapterV2({
1974 instanceId,
1975 flavor: {
1976 driver: ACP_TEST_DRIVER,
@@ -2055,9 +1990,6 @@ describe("AcpAdapterV2", () => {
1990 },
1991 }),
1992 },
2058 - fileSystem,
2059 - idAllocator,
2060 - host,
1993 selfInvocation,
1994 });
1995 const threadId = ThreadId.make("thread-acp-provider-exit-running-command");
@@ -2104,10 +2036,7 @@ describe("AcpAdapterV2", () => {
2036 Effect.gen(function* () {
2037 if ((yield* HostProcessPlatform) !== "linux") return;
2038 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
2107 - const fileSystem = yield* FileSystem.FileSystem;
2108 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
2039 const path = yield* Path.Path;
2110 - const host = yield* ProviderHost.ProviderHost;
2040 const selfInvocation = yield* resolveSelfInvocation();
2041 const mockAgentPath = yield* path.fromFileUrl(
2042 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -2116,8 +2045,7 @@ describe("AcpAdapterV2", () => {
2045 | AcpSessionRuntime.AcpSessionRuntime["Service"]["processContainment"]
2046 | undefined;
2047 const instanceId = ProviderInstanceId.make("acp-test-cgroup-unavailable");
2119 - const adapter = makeAcpAdapterV2({
2120 - crypto: yield* Crypto.Crypto,
2048 + const adapter = yield* makeAcpAdapterV2({
2049 instanceId,
2050 flavor: {
2051 driver: ACP_TEST_DRIVER,
@@ -2134,9 +2062,6 @@ describe("AcpAdapterV2", () => {
2062 },
2063 }),
2064 },
2137 - fileSystem,
2138 - idAllocator,
2139 - host,
2065 selfInvocation,
2066 });
2067 const threadId = ThreadId.make("thread-acp-cgroup-unavailable");
@@ -2160,10 +2085,7 @@ describe("AcpAdapterV2", () => {
2085 it.live("cleans a cgroup lease when the pre-exec join wrapper fails", () =>
2086 Effect.gen(function* () {
2087 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
2163 - const fileSystem = yield* FileSystem.FileSystem;
2164 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
2088 const path = yield* Path.Path;
2166 - const host = yield* ProviderHost.ProviderHost;
2089 const selfInvocation = yield* resolveSelfInvocation();
2090 const mockAgentPath = yield* path.fromFileUrl(
2091 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -2192,8 +2114,7 @@ describe("AcpAdapterV2", () => {
2114 },
2115 };
2116 const instanceId = ProviderInstanceId.make("acp-test-cgroup-join-failure");
2195 - const adapter = makeAcpAdapterV2({
2196 - crypto: yield* Crypto.Crypto,
2117 + const adapter = yield* makeAcpAdapterV2({
2118 instanceId,
2119 flavor: {
2120 driver: ACP_TEST_DRIVER,
@@ -2206,9 +2127,6 @@ describe("AcpAdapterV2", () => {
2127 ownDetachedProcessGroup: true,
2128 }),
2129 },
2209 - fileSystem,
2210 - idAllocator,
2211 - host,
2130 selfInvocation,
2131 });
2132 const threadId = ThreadId.make("thread-acp-cgroup-join-failure");
@@ -2238,10 +2156,7 @@ describe("AcpAdapterV2", () => {
2156 it.effect("negotiates and executes optional native session forks through the ACP runtime", () =>
2157 Effect.gen(function* () {
2158 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
2241 - const fileSystem = yield* FileSystem.FileSystem;
2242 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
2159 const path = yield* Path.Path;
2244 - const host = yield* ProviderHost.ProviderHost;
2160 const selfInvocation = yield* resolveSelfInvocation();
2161 const mockAgentPath = yield* path.fromFileUrl(
2162 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -2275,17 +2190,13 @@ describe("AcpAdapterV2", () => {
2190 });
2191
2192 const instanceId = ProviderInstanceId.make("acp-test");
2278 - const adapter = makeAcpAdapterV2({
2279 - crypto: yield* Crypto.Crypto,
2193 + const adapter = yield* makeAcpAdapterV2({
2194 instanceId,
2195 flavor: {
2196 driver: ACP_TEST_DRIVER,
2197 capabilities: AcpProviderCapabilitiesV2,
2198 makeRuntime,
2199 },
2286 - fileSystem,
2287 - idAllocator,
2288 - host,
2200 selfInvocation,
2201 clientTerminals: { childProcessSpawner },
2202 });
@@ -2451,9 +2362,7 @@ describe("AcpAdapterV2", () => {
2362 Effect.gen(function* () {
2363 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
2364 const fileSystem = yield* FileSystem.FileSystem;
2454 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
2365 const path = yield* Path.Path;
2456 - const host = yield* ProviderHost.ProviderHost;
2366 const selfInvocation = yield* resolveSelfInvocation();
2367 const mockAgentPath = yield* path.fromFileUrl(
2368 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -2465,8 +2374,7 @@ describe("AcpAdapterV2", () => {
2374 const probeLogPath = path.join(workspace, "fs-probe.jsonl");
2375 const protocolEvents = yield* Queue.unbounded<EffectAcpProtocol.AcpProtocolLogEvent>();
2376 const instanceId = ProviderInstanceId.make("acp-test-no-client-fs");
2468 - const adapter = makeAcpAdapterV2({
2469 - crypto: yield* Crypto.Crypto,
2377 + const adapter = yield* makeAcpAdapterV2({
2378 instanceId,
2379 flavor: {
2380 driver: ACP_TEST_DRIVER,
@@ -2481,9 +2389,6 @@ describe("AcpAdapterV2", () => {
2389 },
2390 }),
2391 },
2484 - fileSystem,
2485 - idAllocator,
2486 - host,
2392 selfInvocation,
2393 });
2394 const threadId = ThreadId.make("thread-acp-no-client-fs");
@@ -2547,10 +2452,7 @@ describe("AcpAdapterV2", () => {
2452 it.effect("does not turn an unknown permission approval into an execute grant", () =>
2453 Effect.gen(function* () {
2454 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
2550 - const fileSystem = yield* FileSystem.FileSystem;
2551 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
2455 const path = yield* Path.Path;
2553 - const host = yield* ProviderHost.ProviderHost;
2456 const selfInvocation = yield* resolveSelfInvocation();
2457 const mockAgentPath = yield* path.fromFileUrl(
2458 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -2576,8 +2478,7 @@ describe("AcpAdapterV2", () => {
2478 }),
2479 });
2480 const instanceId = ProviderInstanceId.make("acp-test-unknown-permission-grant");
2579 - const adapter = makeAcpAdapterV2({
2580 - crypto: yield* Crypto.Crypto,
2481 + const adapter = yield* makeAcpAdapterV2({
2482 instanceId,
2483 flavor: {
2484 driver: ACP_TEST_DRIVER,
@@ -2588,9 +2489,6 @@ describe("AcpAdapterV2", () => {
2489 runtimeInput = input;
2490 }).pipe(Effect.andThen(makeRuntime(input))),
2491 },
2591 - fileSystem,
2592 - idAllocator,
2593 - host,
2492 selfInvocation,
2493 clientTerminals: { childProcessSpawner },
2494 });
@@ -2684,26 +2582,19 @@ describe("AcpAdapterV2", () => {
2582 it.effect("fails missing native ACP session ids through the typed start-turn error channel", () =>
2583 Effect.gen(function* () {
2584 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
2687 - const fileSystem = yield* FileSystem.FileSystem;
2688 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
2585 const path = yield* Path.Path;
2690 - const host = yield* ProviderHost.ProviderHost;
2586 const selfInvocation = yield* resolveSelfInvocation();
2587 const mockAgentPath = yield* path.fromFileUrl(
2588 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
2589 );
2590 const instanceId = ProviderInstanceId.make("acp-test-missing-native-thread");
2696 - const adapter = makeAcpAdapterV2({
2697 - crypto: yield* Crypto.Crypto,
2591 + const adapter = yield* makeAcpAdapterV2({
2592 instanceId,
2593 flavor: {
2594 driver: ACP_TEST_DRIVER,
2595 capabilities: AcpProviderCapabilitiesV2,
2596 makeRuntime: makeMockRuntime({ childProcessSpawner, mockAgentPath }),
2597 },
2704 - fileSystem,
2705 - idAllocator,
2706 - host,
2598 selfInvocation,
2599 });
2600 const threadId = ThreadId.make("thread-acp-missing-native-thread");
@@ -2746,10 +2637,8 @@ describe("AcpAdapterV2", () => {
2637 it.effect("replaces the ACP session and clears conversation state on rollback", () =>
2638 Effect.gen(function* () {
2639 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
2749 - const fileSystem = yield* FileSystem.FileSystem;
2640 const idAllocator = yield* IdAllocator.IdAllocatorV2;
2641 const path = yield* Path.Path;
2752 - const host = yield* ProviderHost.ProviderHost;
2642 const selfInvocation = yield* resolveSelfInvocation();
2643 const mockAgentPath = yield* path.fromFileUrl(
2644 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -2774,8 +2663,7 @@ describe("AcpAdapterV2", () => {
2663 mockAgentPath,
2664 environment: { T3_ACP_PROMPT_DELAY_MS: "100" },
2665 });
2777 - const adapter = makeAcpAdapterV2({
2778 - crypto: yield* Crypto.Crypto,
2666 + const adapter = yield* makeAcpAdapterV2({
2667 instanceId,
2668 flavor: {
2669 driver: ACP_TEST_DRIVER,
@@ -2785,9 +2673,6 @@ describe("AcpAdapterV2", () => {
2673 Effect.andThen(makeRuntime(runtimeInput)),
2674 ),
2675 },
2788 - fileSystem,
2789 - idAllocator,
2790 - host,
2676 selfInvocation,
2677 });
2678 const threadId = ThreadId.make("thread-acp-rollback-session");
@@ -2913,10 +2798,7 @@ describe("AcpAdapterV2", () => {
2798 it.effect("quarantines callbacks from a failed rollback replacement before retrying", () =>
2799 Effect.gen(function* () {
2800 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
2916 - const fileSystem = yield* FileSystem.FileSystem;
2917 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
2801 const path = yield* Path.Path;
2919 - const host = yield* ProviderHost.ProviderHost;
2802 const selfInvocation = yield* resolveSelfInvocation();
2803 const mockAgentPath = yield* path.fromFileUrl(
2804 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -2979,8 +2861,7 @@ describe("AcpAdapterV2", () => {
2861 },
2862 });
2863 const instanceId = ProviderInstanceId.make("acp-test-rollback-retry-generation");
2982 - const adapter = makeAcpAdapterV2({
2983 - crypto: yield* Crypto.Crypto,
2864 + const adapter = yield* makeAcpAdapterV2({
2865 instanceId,
2866 flavor: {
2867 driver: ACP_TEST_DRIVER,
@@ -2998,9 +2879,6 @@ describe("AcpAdapterV2", () => {
2879 }),
2880 makeRuntime,
2881 },
3001 - fileSystem,
3002 - idAllocator,
3003 - host,
2882 selfInvocation,
2883 continuationRequests: { offer: () => Effect.void },
2884 });
@@ -3074,10 +2952,8 @@ describe("AcpAdapterV2", () => {
2952 it.effect("keeps the original ACP session usable when a staged replacement terminates", () =>
2953 Effect.gen(function* () {
2954 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3077 - const fileSystem = yield* FileSystem.FileSystem;
2955 const idAllocator = yield* IdAllocator.IdAllocatorV2;
2956 const path = yield* Path.Path;
3080 - const host = yield* ProviderHost.ProviderHost;
2957 const selfInvocation = yield* resolveSelfInvocation();
2958 const mockAgentPath = yield* path.fromFileUrl(
2959 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -3109,17 +2985,13 @@ describe("AcpAdapterV2", () => {
2985 };
2986 });
2987 const instanceId = ProviderInstanceId.make("acp-test-rollback-failure-compensation");
3112 - const adapter = makeAcpAdapterV2({
3113 - crypto: yield* Crypto.Crypto,
2988 + const adapter = yield* makeAcpAdapterV2({
2989 instanceId,
2990 flavor: {
2991 driver: ACP_TEST_DRIVER,
2992 capabilities: AcpProviderCapabilitiesV2,
2993 makeRuntime,
2994 },
3120 - fileSystem,
3121 - idAllocator,
3122 - host,
2995 selfInvocation,
2996 });
2997 const threadId = ThreadId.make("thread-acp-rollback-failure-compensation");
@@ -3190,27 +3062,20 @@ describe("AcpAdapterV2", () => {
3062 it.effect("closes an idle ACP session exactly once through the transition permit", () =>
3063 Effect.gen(function* () {
3064 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3193 - const fileSystem = yield* FileSystem.FileSystem;
3194 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
3065 const path = yield* Path.Path;
3196 - const host = yield* ProviderHost.ProviderHost;
3066 const selfInvocation = yield* resolveSelfInvocation();
3067 const mockAgentPath = yield* path.fromFileUrl(
3068 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
3069 );
3070 const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
3071 const instanceId = ProviderInstanceId.make("acp-test");
3203 - const adapter = makeAcpAdapterV2({
3204 - crypto: yield* Crypto.Crypto,
3072 + const adapter = yield* makeAcpAdapterV2({
3073 instanceId,
3074 flavor: {
3075 driver: ACP_TEST_DRIVER,
3076 capabilities: AcpProviderCapabilitiesV2,
3077 makeRuntime: makeMockRuntime({ childProcessSpawner, mockAgentPath, protocolEvents }),
3078 },
3211 - fileSystem,
3212 - idAllocator,
3213 - host,
3079 selfInvocation,
3080 });
3081 const threadId = ThreadId.make("thread-acp-idle-finalizer");
@@ -3241,26 +3106,18 @@ describe("AcpAdapterV2", () => {
3106 (model) =>
3107 Effect.gen(function* () {
3108 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3244 - const fileSystem = yield* FileSystem.FileSystem;
3245 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
3109 const path = yield* Path.Path;
3247 - const host = yield* ProviderHost.ProviderHost;
3110 const selfInvocation = yield* resolveSelfInvocation();
3111 const mockAgentPath = yield* path.fromFileUrl(
3112 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
3113 );
3114 const protocolEvents = yield* Queue.unbounded<EffectAcpProtocol.AcpProtocolLogEvent>();
3115 const instanceId = ProviderInstanceId.make("grok-test");
3254 - const adapter = makeGrokAdapterV2({
3116 + const adapter = yield* makeGrokAdapterV2({
3117 instanceId,
3118 settings: DEFAULT_GROK_SETTINGS,
3119 environment: {},
3120 hostPlatform: yield* HostProcessPlatform,
3259 - childProcessSpawner,
3260 - crypto: yield* Crypto.Crypto,
3261 - fileSystem,
3262 - idAllocator,
3263 - host,
3121 selfInvocation: yield* resolveSelfInvocation(),
3122 // Production Grok runtimes are wrapped by the x.ai prompt runtime.
3123 makeRuntime: (input) =>
@@ -3296,26 +3153,18 @@ describe("AcpAdapterV2", () => {
3153 it.live("Grok reapplies an explicit return to the session's setup-time model", () =>
3154 Effect.gen(function* () {
3155 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3299 - const fileSystem = yield* FileSystem.FileSystem;
3300 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
3156 const path = yield* Path.Path;
3302 - const host = yield* ProviderHost.ProviderHost;
3157 const selfInvocation = yield* resolveSelfInvocation();
3158 const mockAgentPath = yield* path.fromFileUrl(
3159 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
3160 );
3161 const protocolEvents = yield* Queue.unbounded<EffectAcpProtocol.AcpProtocolLogEvent>();
3162 const instanceId = ProviderInstanceId.make("grok-test-switch-back");
3309 - const adapter = makeGrokAdapterV2({
3163 + const adapter = yield* makeGrokAdapterV2({
3164 instanceId,
3165 settings: DEFAULT_GROK_SETTINGS,
3166 environment: {},
3167 hostPlatform: yield* HostProcessPlatform,
3314 - childProcessSpawner,
3315 - crypto: yield* Crypto.Crypto,
3316 - fileSystem,
3317 - idAllocator,
3318 - host,
3168 selfInvocation: yield* resolveSelfInvocation(),
3169 // Production Grok runtimes are wrapped by the x.ai prompt runtime.
3170 makeRuntime: (input) =>
@@ -3377,26 +3226,19 @@ describe("AcpAdapterV2", () => {
3226 it.effect("skips requested options that the active ACP session does not expose", () =>
3227 Effect.gen(function* () {
3228 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3380 - const fileSystem = yield* FileSystem.FileSystem;
3381 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
3229 const path = yield* Path.Path;
3383 - const host = yield* ProviderHost.ProviderHost;
3230 const selfInvocation = yield* resolveSelfInvocation();
3231 const mockAgentPath = yield* path.fromFileUrl(
3232 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
3233 );
3234 const instanceId = ProviderInstanceId.make("acp-test");
3389 - const adapter = makeAcpAdapterV2({
3390 - crypto: yield* Crypto.Crypto,
3235 + const adapter = yield* makeAcpAdapterV2({
3236 instanceId,
3237 flavor: {
3238 driver: ACP_TEST_DRIVER,
3239 capabilities: AcpProviderCapabilitiesV2,
3240 makeRuntime: makeMockRuntime({ childProcessSpawner, mockAgentPath }),
3241 },
3397 - fileSystem,
3398 - idAllocator,
3399 - host,
3242 selfInvocation,
3243 });
3244 const threadId = ThreadId.make("thread-acp-unsupported-option");
@@ -3426,27 +3268,20 @@ describe("AcpAdapterV2", () => {
3268 it.effect("reconfigures a loaded ACP session from its own active setup metadata", () =>
3269 Effect.gen(function* () {
3270 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3429 - const fileSystem = yield* FileSystem.FileSystem;
3430 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
3271 const path = yield* Path.Path;
3432 - const host = yield* ProviderHost.ProviderHost;
3272 const selfInvocation = yield* resolveSelfInvocation();
3273 const mockAgentPath = yield* path.fromFileUrl(
3274 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
3275 );
3276 const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
3277 const instanceId = ProviderInstanceId.make("acp-test");
3439 - const adapter = makeAcpAdapterV2({
3440 - crypto: yield* Crypto.Crypto,
3278 + const adapter = yield* makeAcpAdapterV2({
3279 instanceId,
3280 flavor: {
3281 driver: ACP_TEST_DRIVER,
3282 capabilities: AcpProviderCapabilitiesV2,
3283 makeRuntime: makeMockRuntime({ childProcessSpawner, mockAgentPath, protocolEvents }),
3284 },
3447 - fileSystem,
3448 - idAllocator,
3449 - host,
3285 selfInvocation,
3286 });
3287 const firstThreadId = ThreadId.make("thread-acp-active-setup:first");
@@ -3537,18 +3372,15 @@ describe("AcpAdapterV2", () => {
3372 it.live("terminalizes an empty successful foreground Bash tool when the turn completes", () =>
3373 Effect.gen(function* () {
3374 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3540 - const fileSystem = yield* FileSystem.FileSystem;
3375 const idAllocator = yield* IdAllocator.IdAllocatorV2;
3376 const path = yield* Path.Path;
3543 - const host = yield* ProviderHost.ProviderHost;
3377 const selfInvocation = yield* resolveSelfInvocation();
3378 const mockAgentPath = yield* path.fromFileUrl(
3379 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
3380 );
3381 const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
3382 const instanceId = ProviderInstanceId.make("acp-test");
3550 - const adapter = makeAcpAdapterV2({
3551 - crypto: yield* Crypto.Crypto,
3383 + const adapter = yield* makeAcpAdapterV2({
3384 instanceId,
3385 flavor: {
3386 driver: ACP_TEST_DRIVER,
@@ -3565,9 +3397,6 @@ describe("AcpAdapterV2", () => {
3397 restartRuntimeAfterInterrupt: true,
3398 terminateRuntimeProcessGroupOnInterrupt: true,
3399 },
3568 - fileSystem,
3569 - idAllocator,
3570 - host,
3400 selfInvocation,
3401 });
3402 const threadId = ThreadId.make("thread-acp-empty-successful-bash");
@@ -3684,16 +3513,12 @@ describe("AcpAdapterV2", () => {
3513 it.effect("drains native ACP cancellation before admitting the next prompt", () =>
3514 Effect.gen(function* () {
3515 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3687 - const fileSystem = yield* FileSystem.FileSystem;
3688 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
3516 const path = yield* Path.Path;
3690 - const host = yield* ProviderHost.ProviderHost;
3517 const selfInvocation = yield* resolveSelfInvocation();
3518 const protocolEvents = yield* Queue.unbounded<EffectAcpProtocol.AcpProtocolLogEvent>();
3519 const native: { current?: AcpSessionRuntime.AcpSessionRuntime["Service"] } = {};
3520 const instanceId = ProviderInstanceId.make("acp-native-cancel");
3695 - const adapter = makeAcpAdapterV2({
3696 - crypto: yield* Crypto.Crypto,
3521 + const adapter = yield* makeAcpAdapterV2({
3522 instanceId,
3523 flavor: {
3524 driver: ACP_TEST_DRIVER,
@@ -3712,9 +3537,6 @@ describe("AcpAdapterV2", () => {
3537 },
3538 }),
3539 },
3715 - fileSystem,
3716 - idAllocator,
3717 - host,
3540 selfInvocation,
3541 });
3542 const threadId = ThreadId.make("thread-acp-native-cancel");
@@ -3798,18 +3620,14 @@ describe("AcpAdapterV2", () => {
3620 it.effect("cancels pending permission requests while interrupting an ACP turn", () =>
3621 Effect.gen(function* () {
3622 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3801 - const fileSystem = yield* FileSystem.FileSystem;
3802 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
3623 const path = yield* Path.Path;
3804 - const host = yield* ProviderHost.ProviderHost;
3624 const selfInvocation = yield* resolveSelfInvocation();
3625 const mockAgentPath = yield* path.fromFileUrl(
3626 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
3627 );
3628 const releaseCancel = yield* Deferred.make<void>();
3629 const instanceId = ProviderInstanceId.make("acp-test");
3811 - const adapter = makeAcpAdapterV2({
3812 - crypto: yield* Crypto.Crypto,
3630 + const adapter = yield* makeAcpAdapterV2({
3631 instanceId,
3632 flavor: {
3633 driver: ACP_TEST_DRIVER,
@@ -3821,9 +3639,6 @@ describe("AcpAdapterV2", () => {
3639 wrapCancel: (cancel) => Deferred.await(releaseCancel).pipe(Effect.andThen(cancel)),
3640 }),
3641 },
3824 - fileSystem,
3825 - idAllocator,
3826 - host,
3642 selfInvocation,
3643 });
3644 const threadId = ThreadId.make("thread-acp-cancel-permission");
@@ -3899,10 +3714,7 @@ describe("AcpAdapterV2", () => {
3714 it.live("keeps hard teardown excluded until a permission response is enqueued", () =>
3715 Effect.gen(function* () {
3716 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3902 - const fileSystem = yield* FileSystem.FileSystem;
3903 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
3717 const path = yield* Path.Path;
3905 - const host = yield* ProviderHost.ProviderHost;
3718 const selfInvocation = yield* resolveSelfInvocation();
3719 const mockAgentPath = yield* path.fromFileUrl(
3720 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -3910,8 +3722,7 @@ describe("AcpAdapterV2", () => {
3722 const responseEnqueued = yield* Deferred.make<void>();
3723 const releaseResponseAcknowledgement = yield* Deferred.make<void>();
3724 const instanceId = ProviderInstanceId.make("acp-test");
3913 - const adapter = makeAcpAdapterV2({
3914 - crypto: yield* Crypto.Crypto,
3725 + const adapter = yield* makeAcpAdapterV2({
3726 instanceId,
3727 flavor: {
3728 driver: ACP_TEST_DRIVER,
@@ -3927,9 +3738,6 @@ describe("AcpAdapterV2", () => {
3738 ),
3739 }),
3740 },
3930 - fileSystem,
3931 - idAllocator,
3932 - host,
3741 selfInvocation,
3742 });
3743 const threadId = ThreadId.make("thread-acp-response-wins-permission");
@@ -3998,10 +3806,7 @@ describe("AcpAdapterV2", () => {
3806 it.live("carries elicitation request identity through the completed stdout write", () =>
3807 Effect.gen(function* () {
3808 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
4001 - const fileSystem = yield* FileSystem.FileSystem;
4002 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
3809 const path = yield* Path.Path;
4004 - const host = yield* ProviderHost.ProviderHost;
3810 const selfInvocation = yield* resolveSelfInvocation();
3811 const mockAgentPath = yield* path.fromFileUrl(
3812 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -4009,8 +3814,7 @@ describe("AcpAdapterV2", () => {
3814 const responseWritten = yield* Deferred.make<void>();
3815 const releaseResponseAcknowledgement = yield* Deferred.make<void>();
3816 const instanceId = ProviderInstanceId.make("acp-test-reordered-elicitation");
4012 - const adapter = makeAcpAdapterV2({
4013 - crypto: yield* Crypto.Crypto,
3817 + const adapter = yield* makeAcpAdapterV2({
3818 instanceId,
3819 flavor: {
3820 driver: ACP_TEST_DRIVER,
@@ -4026,9 +3830,6 @@ describe("AcpAdapterV2", () => {
3830 ),
3831 }),
3832 },
4029 - fileSystem,
4030 - idAllocator,
4031 - host,
3833 selfInvocation,
3834 });
3835 const threadId = ThreadId.make("thread-acp-reordered-elicitation");
@@ -4087,17 +3888,13 @@ describe("AcpAdapterV2", () => {
3888 it.live("auto-approves tagged MCP elicitations under full-access policy", () =>
3889 Effect.gen(function* () {
3890 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
4090 - const fileSystem = yield* FileSystem.FileSystem;
4091 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
3891 const path = yield* Path.Path;
4093 - const host = yield* ProviderHost.ProviderHost;
3892 const selfInvocation = yield* resolveSelfInvocation();
3893 const mockAgentPath = yield* path.fromFileUrl(
3894 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
3895 );
3896 const instanceId = ProviderInstanceId.make("acp-test-mcp-approval-elicitation");
4099 - const adapter = makeAcpAdapterV2({
4100 - crypto: yield* Crypto.Crypto,
3897 + const adapter = yield* makeAcpAdapterV2({
3898 instanceId,
3899 flavor: {
3900 driver: ACP_TEST_DRIVER,
@@ -4108,9 +3905,6 @@ describe("AcpAdapterV2", () => {
3905 environment: { T3_ACP_EMIT_MCP_TOOL_APPROVAL_ELICITATION: "1" },
3906 }),
3907 },
4111 - fileSystem,
4112 - idAllocator,
4113 - host,
3908 selfInvocation,
3909 });
3910 const threadId = ThreadId.make("thread-acp-mcp-approval-elicitation");
@@ -4155,10 +3949,7 @@ describe("AcpAdapterV2", () => {
3949 it.live("fails a held native response acknowledgement before normal session close", () =>
3950 Effect.gen(function* () {
3951 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
4158 - const fileSystem = yield* FileSystem.FileSystem;
4159 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
3952 const path = yield* Path.Path;
4161 - const host = yield* ProviderHost.ProviderHost;
3953 const selfInvocation = yield* resolveSelfInvocation();
3954 const mockAgentPath = yield* path.fromFileUrl(
3955 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -4167,8 +3958,7 @@ describe("AcpAdapterV2", () => {
3958 const releaseResponseAcknowledgement = yield* Deferred.make<void>();
3959 const responseLifecycle: Array<string> = [];
3960 const instanceId = ProviderInstanceId.make("acp-test-normal-close-held-response");
4170 - const adapter = makeAcpAdapterV2({
4171 - crypto: yield* Crypto.Crypto,
3961 + const adapter = yield* makeAcpAdapterV2({
3962 instanceId,
3963 flavor: {
3964 driver: ACP_TEST_DRIVER,
@@ -4184,9 +3974,6 @@ describe("AcpAdapterV2", () => {
3974 ),
3975 }),
3976 },
4187 - fileSystem,
4188 - idAllocator,
4189 - host,
3977 selfInvocation,
3978 testHooks: {
3979 onNativeResponseLifecycle: (event) =>
@@ -4263,10 +4050,7 @@ describe("AcpAdapterV2", () => {
4050 it.live("rejects delayed native response registration when normal close wins the permit", () =>
4051 Effect.gen(function* () {
4052 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
4266 - const fileSystem = yield* FileSystem.FileSystem;
4267 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
4053 const path = yield* Path.Path;
4269 - const host = yield* ProviderHost.ProviderHost;
4054 const selfInvocation = yield* resolveSelfInvocation();
4055 const mockAgentPath = yield* path.fromFileUrl(
4056 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -4277,8 +4061,7 @@ describe("AcpAdapterV2", () => {
4061 const releaseTransportClose = yield* Deferred.make<void>();
4062 const responseLifecycle: Array<string> = [];
4063 const instanceId = ProviderInstanceId.make("acp-test-close-wins-registration");
4280 - const adapter = makeAcpAdapterV2({
4281 - crypto: yield* Crypto.Crypto,
4064 + const adapter = yield* makeAcpAdapterV2({
4065 instanceId,
4066 flavor: {
4067 driver: ACP_TEST_DRIVER,
@@ -4289,9 +4072,6 @@ describe("AcpAdapterV2", () => {
4072 environment: { T3_ACP_EMIT_TOOL_CALLS: "1" },
4073 }),
4074 },
4292 - fileSystem,
4293 - idAllocator,
4294 - host,
4075 selfInvocation,
4076 testHooks: {
4077 afterNativeResponseTransportClosed: () =>
@@ -4377,10 +4157,7 @@ describe("AcpAdapterV2", () => {
4157 it.live("bounds a missing pending permission response acknowledgement", () =>
4158 Effect.gen(function* () {
4159 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
4380 - const fileSystem = yield* FileSystem.FileSystem;
4381 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
4160 const path = yield* Path.Path;
4383 - const host = yield* ProviderHost.ProviderHost;
4161 const selfInvocation = yield* resolveSelfInvocation();
4162 const mockAgentPath = yield* path.fromFileUrl(
4163 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -4390,8 +4167,7 @@ describe("AcpAdapterV2", () => {
4167 const responseLifecycle: Array<string> = [];
4168 const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
4169 const instanceId = ProviderInstanceId.make("acp-test-pending-response-timeout");
4393 - const adapter = makeAcpAdapterV2({
4394 - crypto: yield* Crypto.Crypto,
4170 + const adapter = yield* makeAcpAdapterV2({
4171 instanceId,
4172 flavor: {
4173 driver: ACP_TEST_DRIVER,
@@ -4423,9 +4199,6 @@ describe("AcpAdapterV2", () => {
4199 ),
4200 }),
4201 },
4426 - fileSystem,
4427 - idAllocator,
4428 - host,
4202 selfInvocation,
4203 testHooks: {
4204 onNativeResponseLifecycle: (event) =>
@@ -4518,10 +4291,7 @@ describe("AcpAdapterV2", () => {
4291 it.live("defers caller cancellation until a pending response acknowledgement is bounded", () =>
4292 Effect.gen(function* () {
4293 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
4521 - const fileSystem = yield* FileSystem.FileSystem;
4522 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
4294 const path = yield* Path.Path;
4524 - const host = yield* ProviderHost.ProviderHost;
4295 const selfInvocation = yield* resolveSelfInvocation();
4296 const mockAgentPath = yield* path.fromFileUrl(
4297 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -4529,8 +4299,7 @@ describe("AcpAdapterV2", () => {
4299 const responseEnqueued = yield* Deferred.make<void>();
4300 const releaseNativeHook = yield* Deferred.make<void>();
4301 const instanceId = ProviderInstanceId.make("acp-test-pending-response-cancel");
4532 - const adapter = makeAcpAdapterV2({
4533 - crypto: yield* Crypto.Crypto,
4302 + const adapter = yield* makeAcpAdapterV2({
4303 instanceId,
4304 flavor: {
4305 driver: ACP_TEST_DRIVER,
@@ -4561,9 +4330,6 @@ describe("AcpAdapterV2", () => {
4330 ),
4331 }),
4332 },
4564 - fileSystem,
4565 - idAllocator,
4566 - host,
4333 selfInvocation,
4334 });
4335 const threadId = ThreadId.make("thread-acp-pending-response-cancel");
@@ -4634,10 +4400,8 @@ describe("AcpAdapterV2", () => {
4400 it.live("waits for immediate allow and deny permission responses before hard teardown", () =>
4401 Effect.gen(function* () {
4402 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
4637 - const fileSystem = yield* FileSystem.FileSystem;
4403 const idAllocator = yield* IdAllocator.IdAllocatorV2;
4404 const path = yield* Path.Path;
4640 - const host = yield* ProviderHost.ProviderHost;
4405 const selfInvocation = yield* resolveSelfInvocation();
4406 const mockAgentPath = yield* path.fromFileUrl(
4407 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -4651,8 +4415,7 @@ describe("AcpAdapterV2", () => {
4415 const responseEnqueued = yield* Deferred.make<void>();
4416 const releaseResponseAcknowledgement = yield* Deferred.make<void>();
4417 const instanceId = ProviderInstanceId.make(`acp-test-${name}`);
4654 - const adapter = makeAcpAdapterV2({
4655 - crypto: yield* Crypto.Crypto,
4418 + const adapter = yield* makeAcpAdapterV2({
4419 instanceId,
4420 flavor: {
4421 driver: ACP_TEST_DRIVER,
@@ -4676,9 +4439,6 @@ describe("AcpAdapterV2", () => {
4439 ),
4440 }),
4441 },
4679 - fileSystem,
4680 - idAllocator,
4681 - host,
4442 selfInvocation,
4443 });
4444 const threadId = ThreadId.make(`thread-acp-immediate-permission-${name}`);
@@ -4739,10 +4499,8 @@ describe("AcpAdapterV2", () => {
4499 it.live("waits for immediate URL elicitation responses before hard teardown", () =>
4500 Effect.gen(function* () {
4501 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
4742 - const fileSystem = yield* FileSystem.FileSystem;
4502 const idAllocator = yield* IdAllocator.IdAllocatorV2;
4503 const path = yield* Path.Path;
4745 - const host = yield* ProviderHost.ProviderHost;
4504 const selfInvocation = yield* resolveSelfInvocation();
4505 const mockAgentPath = yield* path.fromFileUrl(
4506 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -4750,8 +4508,7 @@ describe("AcpAdapterV2", () => {
4508 const responseEnqueued = yield* Deferred.make<void>();
4509 const releaseResponseAcknowledgement = yield* Deferred.make<void>();
4510 const instanceId = ProviderInstanceId.make("acp-test-url-elicitation");
4753 - const adapter = makeAcpAdapterV2({
4754 - crypto: yield* Crypto.Crypto,
4511 + const adapter = yield* makeAcpAdapterV2({
4512 instanceId,
4513 flavor: {
4514 driver: ACP_TEST_DRIVER,
@@ -4775,9 +4532,6 @@ describe("AcpAdapterV2", () => {
4532 ),
4533 }),
4534 },
4778 - fileSystem,
4779 - idAllocator,
4780 - host,
4535 selfInvocation,
4536 });
4537 const threadId = ThreadId.make("thread-acp-immediate-url-elicitation");
@@ -4832,10 +4586,8 @@ describe("AcpAdapterV2", () => {
4586 it.live("bounds a missing immediate response acknowledgement before hard teardown", () =>
4587 Effect.gen(function* () {
4588 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
4835 - const fileSystem = yield* FileSystem.FileSystem;
4589 const idAllocator = yield* IdAllocator.IdAllocatorV2;
4590 const path = yield* Path.Path;
4838 - const host = yield* ProviderHost.ProviderHost;
4591 const selfInvocation = yield* resolveSelfInvocation();
4592 const mockAgentPath = yield* path.fromFileUrl(
4593 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -4843,8 +4595,7 @@ describe("AcpAdapterV2", () => {
4595 const responseEnqueued = yield* Deferred.make<void>();
4596 const releaseNativeHook = yield* Deferred.make<void>();
4597 const instanceId = ProviderInstanceId.make("acp-test-missing-response-ack");
4846 - const adapter = makeAcpAdapterV2({
4847 - crypto: yield* Crypto.Crypto,
4598 + const adapter = yield* makeAcpAdapterV2({
4599 instanceId,
4600 flavor: {
4601 driver: ACP_TEST_DRIVER,
@@ -4872,9 +4623,6 @@ describe("AcpAdapterV2", () => {
4623 ),
4624 }),
4625 },
4875 - fileSystem,
4876 - idAllocator,
4877 - host,
4626 selfInvocation,
4627 });
4628 const threadId = ThreadId.make("thread-acp-missing-response-ack");
@@ -4925,10 +4673,7 @@ describe("AcpAdapterV2", () => {
4673 it.live("rejects an elicitation response when hard teardown wins admission", () =>
4674 Effect.gen(function* () {
4675 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
4928 - const fileSystem = yield* FileSystem.FileSystem;
4929 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
4676 const path = yield* Path.Path;
4931 - const host = yield* ProviderHost.ProviderHost;
4677 const selfInvocation = yield* resolveSelfInvocation();
4678 const mockAgentPath = yield* path.fromFileUrl(
4679 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -4936,8 +4681,7 @@ describe("AcpAdapterV2", () => {
4681 const teardownStarted = yield* Deferred.make<void>();
4682 const releaseTeardown = yield* Deferred.make<void>();
4683 const instanceId = ProviderInstanceId.make("acp-test");
4939 - const adapter = makeAcpAdapterV2({
4940 - crypto: yield* Crypto.Crypto,
4684 + const adapter = yield* makeAcpAdapterV2({
4685 instanceId,
4686 flavor: {
4687 driver: ACP_TEST_DRIVER,
@@ -4961,9 +4705,6 @@ describe("AcpAdapterV2", () => {
4705 ),
4706 }),
4707 },
4964 - fileSystem,
4965 - idAllocator,
4966 - host,
4708 selfInvocation,
4709 });
4710 const threadId = ThreadId.make("thread-acp-teardown-wins-elicitation");
@@ -5038,18 +4779,15 @@ describe("AcpAdapterV2", () => {
4779 it.effect("releases an ACP turn when cancellation times out", () =>
4780 Effect.gen(function* () {
4781 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
5041 - const fileSystem = yield* FileSystem.FileSystem;
4782 const idAllocator = yield* IdAllocator.IdAllocatorV2;
4783 const path = yield* Path.Path;
5044 - const host = yield* ProviderHost.ProviderHost;
4784 const selfInvocation = yield* resolveSelfInvocation();
4785 const mockAgentPath = yield* path.fromFileUrl(
4786 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
4787 );
4788 const instanceId = ProviderInstanceId.make("acp-test");
4789 const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
5051 - const adapter = makeAcpAdapterV2({
5052 - crypto: yield* Crypto.Crypto,
4790 + const adapter = yield* makeAcpAdapterV2({
4791 instanceId,
4792 flavor: {
4793 driver: ACP_TEST_DRIVER,
@@ -5061,9 +4799,6 @@ describe("AcpAdapterV2", () => {
4799 protocolEvents,
4800 }),
4801 },
5064 - fileSystem,
5065 - idAllocator,
5066 - host,
4802 selfInvocation,
4803 });
4804 const threadId = ThreadId.make("thread-acp-cancel-timeout");
@@ -5141,18 +4876,15 @@ describe("AcpAdapterV2", () => {
4876 it.live("treats a second hard Stop as success when the turn is already gone", () =>
4877 Effect.gen(function* () {
4878 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
5144 - const fileSystem = yield* FileSystem.FileSystem;
4879 const idAllocator = yield* IdAllocator.IdAllocatorV2;
4880 const path = yield* Path.Path;
5147 - const host = yield* ProviderHost.ProviderHost;
4881 const selfInvocation = yield* resolveSelfInvocation();
4882 const mockAgentPath = yield* path.fromFileUrl(
4883 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
4884 );
4885 const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
4886 const instanceId = ProviderInstanceId.make("acp-test");
5154 - const adapter = makeAcpAdapterV2({
5155 - crypto: yield* Crypto.Crypto,
4887 + const adapter = yield* makeAcpAdapterV2({
4888 instanceId,
4889 flavor: {
4890 driver: ACP_TEST_DRIVER,
@@ -5168,9 +4900,6 @@ describe("AcpAdapterV2", () => {
4900 protocolEvents,
4901 }),
4902 },
5171 - fileSystem,
5172 - idAllocator,
5173 - host,
4903 selfInvocation,
4904 });
4905 const threadId = ThreadId.make("thread-acp-double-stop");
@@ -5239,22 +4968,19 @@ describe("AcpAdapterV2", () => {
4968 it.effect("finalizes a settled turn held open for background work when interrupted", () =>
4969 Effect.gen(function* () {
4970 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
5242 - const fileSystem = yield* FileSystem.FileSystem;
4971 const idAllocator = yield* IdAllocator.IdAllocatorV2;
4972 const path = yield* Path.Path;
5245 - const host = yield* ProviderHost.ProviderHost;
4973 const selfInvocation = yield* resolveSelfInvocation();
4974 const mockAgentPath = yield* path.fromFileUrl(
4975 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
4976 );
4977 const instanceId = ProviderInstanceId.make("acp-test");
4978 const promptSettled = yield* Deferred.make<void>();
5252 - const adapter = makeAcpAdapterV2({
4979 + const adapter = yield* makeAcpAdapterV2({
4980 testHooks: {
4981 afterPromptSettledWithBackgroundWork: () =>
4982 Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid),
4983 },
5257 - crypto: yield* Crypto.Crypto,
4984 instanceId,
4985 flavor: {
4986 driver: ACP_TEST_DRIVER,
@@ -5278,9 +5004,6 @@ describe("AcpAdapterV2", () => {
5004 environment: { T3_ACP_EMIT_GENERIC_TOOL_PLACEHOLDERS: "1" },
5005 }),
5006 },
5281 - fileSystem,
5282 - idAllocator,
5283 - host,
5007 selfInvocation,
5008 });
5009 const threadId = ThreadId.make("thread-acp-interrupt-background-hold");
@@ -5335,10 +5058,8 @@ describe("AcpAdapterV2", () => {
5058 () =>
5059 Effect.gen(function* () {
5060 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
5338 - const fileSystem = yield* FileSystem.FileSystem;
5061 const idAllocator = yield* IdAllocator.IdAllocatorV2;
5062 const path = yield* Path.Path;
5341 - const host = yield* ProviderHost.ProviderHost;
5063 const selfInvocation = yield* resolveSelfInvocation();
5064 const mockAgentPath = yield* path.fromFileUrl(
5065 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -5346,12 +5067,11 @@ describe("AcpAdapterV2", () => {
5067 const instanceId = ProviderInstanceId.make("acp-test");
5068 let subagentPhase: "spawn" | "complete" = "spawn";
5069 const promptSettled = yield* Deferred.make<void>();
5349 - const adapter = makeAcpAdapterV2({
5070 + const adapter = yield* makeAcpAdapterV2({
5071 testHooks: {
5072 afterPromptSettledWithBackgroundWork: () =>
5073 Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid),
5074 },
5354 - crypto: yield* Crypto.Crypto,
5075 instanceId,
5076 flavor: {
5077 driver: ACP_TEST_DRIVER,
@@ -5388,9 +5108,6 @@ describe("AcpAdapterV2", () => {
5108 environment: { T3_ACP_EMIT_GENERIC_TOOL_PLACEHOLDERS: "1" },
5109 }),
5110 },
5391 - fileSystem,
5392 - idAllocator,
5393 - host,
5111 selfInvocation,
5112 });
5113 const threadId = ThreadId.make("thread-acp-subagent-carryover");
@@ -5483,10 +5200,8 @@ describe("AcpAdapterV2", () => {
5200 () =>
5201 Effect.gen(function* () {
5202 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
5486 - const fileSystem = yield* FileSystem.FileSystem;
5203 const idAllocator = yield* IdAllocator.IdAllocatorV2;
5204 const path = yield* Path.Path;
5489 - const host = yield* ProviderHost.ProviderHost;
5205 const selfInvocation = yield* resolveSelfInvocation();
5206 const mockAgentPath = yield* path.fromFileUrl(
5207 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -5494,12 +5209,11 @@ describe("AcpAdapterV2", () => {
5209 const instanceId = ProviderInstanceId.make("acp-test");
5210 let subagentPhase: "spawn" | "complete" = "spawn";
5211 const promptSettled = yield* Deferred.make<void>();
5497 - const adapter = makeAcpAdapterV2({
5212 + const adapter = yield* makeAcpAdapterV2({
5213 testHooks: {
5214 afterPromptSettledWithBackgroundWork: () =>
5215 Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid),
5216 },
5502 - crypto: yield* Crypto.Crypto,
5217 instanceId,
5218 flavor: {
5219 driver: ACP_TEST_DRIVER,
@@ -5534,9 +5248,6 @@ describe("AcpAdapterV2", () => {
5248 environment: { T3_ACP_EMIT_GENERIC_TOOL_PLACEHOLDERS: "1" },
5249 }),
5250 },
5537 - fileSystem,
5538 - idAllocator,
5539 - host,
5251 selfInvocation,
5252 continuationRequests: { offer: () => Effect.void },
5253 });
@@ -5630,10 +5341,8 @@ describe("AcpAdapterV2", () => {
5341 it.effect("handles a child terminal after carryover rehydrate", () =>
5342 Effect.gen(function* () {
5343 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
5633 - const fileSystem = yield* FileSystem.FileSystem;
5344 const idAllocator = yield* IdAllocator.IdAllocatorV2;
5345 const path = yield* Path.Path;
5636 - const host = yield* ProviderHost.ProviderHost;
5346 const selfInvocation = yield* resolveSelfInvocation();
5347 const mockAgentPath = yield* path.fromFileUrl(
5348 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -5647,12 +5356,11 @@ describe("AcpAdapterV2", () => {
5356 type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
5357 let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
5358 const promptSettled = yield* Deferred.make<void>();
5650 - const adapter = makeAcpAdapterV2({
5359 + const adapter = yield* makeAcpAdapterV2({
5360 testHooks: {
5361 afterPromptSettledWithBackgroundWork: () =>
5362 Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid),
5363 },
5655 - crypto: yield* Crypto.Crypto,
5364 instanceId,
5365 flavor: {
5366 driver: ACP_TEST_DRIVER,
@@ -5704,9 +5412,6 @@ describe("AcpAdapterV2", () => {
5412 }),
5413 }),
5414 },
5707 - fileSystem,
5708 - idAllocator,
5709 - host,
5415 selfInvocation,
5416 continuationRequests: { offer: () => Effect.void },
5417 });
@@ -5867,10 +5572,8 @@ describe("AcpAdapterV2", () => {
5572 () =>
5573 Effect.gen(function* () {
5574 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
5870 - const fileSystem = yield* FileSystem.FileSystem;
5575 const idAllocator = yield* IdAllocator.IdAllocatorV2;
5576 const path = yield* Path.Path;
5873 - const host = yield* ProviderHost.ProviderHost;
5577 const selfInvocation = yield* resolveSelfInvocation();
5578 const mockAgentPath = yield* path.fromFileUrl(
5579 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -5903,12 +5606,11 @@ describe("AcpAdapterV2", () => {
5606 | Parameters<RuntimeService["handleSessionUpdate"]>[0]
5607 | undefined;
5608 const promptSettled = yield* Deferred.make<void>();
5906 - const adapter = makeAcpAdapterV2({
5609 + const adapter = yield* makeAcpAdapterV2({
5610 testHooks: {
5611 afterPromptSettledWithBackgroundWork: () =>
5612 Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid),
5613 },
5911 - crypto: yield* Crypto.Crypto,
5614 instanceId,
5615 flavor: {
5616 driver: ACP_TEST_DRIVER,
@@ -5955,9 +5657,6 @@ describe("AcpAdapterV2", () => {
5657 }),
5658 }),
5659 },
5958 - fileSystem,
5959 - idAllocator,
5960 - host,
5660 selfInvocation,
5661 continuationRequests: { offer: () => Effect.void },
5662 });
@@ -6090,10 +5789,8 @@ describe("AcpAdapterV2", () => {
5789 () =>
5790 Effect.gen(function* () {
5791 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
6093 - const fileSystem = yield* FileSystem.FileSystem;
5792 const idAllocator = yield* IdAllocator.IdAllocatorV2;
5793 const path = yield* Path.Path;
6096 - const host = yield* ProviderHost.ProviderHost;
5794 const selfInvocation = yield* resolveSelfInvocation();
5795 const mockAgentPath = yield* path.fromFileUrl(
5796 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -6106,12 +5803,11 @@ describe("AcpAdapterV2", () => {
5803 let subagentPhase: "spawn" | "complete" = "spawn";
5804 type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
5805 let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
6109 - const adapter = makeAcpAdapterV2({
5806 + const adapter = yield* makeAcpAdapterV2({
5807 testHooks: {
5808 afterPromptSettledWithBackgroundWork: () =>
5809 Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid),
5810 },
6114 - crypto: yield* Crypto.Crypto,
5811 instanceId,
5812 flavor: {
5813 driver: ACP_TEST_DRIVER,
@@ -6154,9 +5850,6 @@ describe("AcpAdapterV2", () => {
5850 }),
5851 }),
5852 },
6157 - fileSystem,
6158 - idAllocator,
6159 - host,
5853 selfInvocation,
5854 continuationRequests: {
5855 offer: (request) =>
@@ -6309,10 +6002,8 @@ describe("AcpAdapterV2", () => {
6002 it.effect("finishes a settled root's carryover subagent from its structured end", () =>
6003 Effect.gen(function* () {
6004 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
6312 - const fileSystem = yield* FileSystem.FileSystem;
6005 const idAllocator = yield* IdAllocator.IdAllocatorV2;
6006 const path = yield* Path.Path;
6315 - const host = yield* ProviderHost.ProviderHost;
6007 const selfInvocation = yield* resolveSelfInvocation();
6008 const mockAgentPath = yield* path.fromFileUrl(
6009 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -6321,8 +6012,7 @@ describe("AcpAdapterV2", () => {
6012 const instanceId = ProviderInstanceId.make("acp-test");
6013 const childSessionId = "019f44a6-4820-7402-925d-bc862ee711dd";
6014 let finishSubagent: AcpAdapterV2ExtensionContext["finishSubagent"] | undefined;
6324 - const adapter = makeAcpAdapterV2({
6325 - crypto: yield* Crypto.Crypto,
6015 + const adapter = yield* makeAcpAdapterV2({
6016 instanceId,
6017 flavor: {
6018 driver: ACP_TEST_DRIVER,
@@ -6352,9 +6042,6 @@ describe("AcpAdapterV2", () => {
6042 protocolEvents,
6043 }),
6044 },
6355 - fileSystem,
6356 - idAllocator,
6357 - host,
6045 selfInvocation,
6046 continuationRequests: { offer: () => Effect.void },
6047 });
@@ -6457,10 +6144,8 @@ describe("AcpAdapterV2", () => {
6144 it.effect("projects completed-root carryover eagerly and drain cannot resurrect it", () =>
6145 Effect.gen(function* () {
6146 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
6460 - const fileSystem = yield* FileSystem.FileSystem;
6147 const idAllocator = yield* IdAllocator.IdAllocatorV2;
6148 const path = yield* Path.Path;
6463 - const host = yield* ProviderHost.ProviderHost;
6149 const selfInvocation = yield* resolveSelfInvocation();
6150 const mockAgentPath = yield* path.fromFileUrl(
6151 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -6472,8 +6157,7 @@ describe("AcpAdapterV2", () => {
6157 let subagentPhase: "spawn" | "complete" = "spawn";
6158 type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
6159 let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
6475 - const adapter = makeAcpAdapterV2({
6476 - crypto: yield* Crypto.Crypto,
6160 + const adapter = yield* makeAcpAdapterV2({
6161 instanceId,
6162 flavor: {
6163 driver: ACP_TEST_DRIVER,
@@ -6517,9 +6201,6 @@ describe("AcpAdapterV2", () => {
6201 }),
6202 }),
6203 },
6520 - fileSystem,
6521 - idAllocator,
6522 - host,
6204 selfInvocation,
6205 continuationRequests: {
6206 offer: (request) =>
@@ -6709,10 +6390,8 @@ describe("AcpAdapterV2", () => {
6390 () =>
6391 Effect.gen(function* () {
6392 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
6712 - const fileSystem = yield* FileSystem.FileSystem;
6393 const idAllocator = yield* IdAllocator.IdAllocatorV2;
6394 const path = yield* Path.Path;
6715 - const host = yield* ProviderHost.ProviderHost;
6395 const selfInvocation = yield* resolveSelfInvocation();
6396 const mockAgentPath = yield* path.fromFileUrl(
6397 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -6724,12 +6403,11 @@ describe("AcpAdapterV2", () => {
6403 type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
6404 let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
6405 const promptSettled = yield* Deferred.make<void>();
6727 - const adapter = makeAcpAdapterV2({
6406 + const adapter = yield* makeAcpAdapterV2({
6407 testHooks: {
6408 afterPromptSettledWithBackgroundWork: () =>
6409 Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid),
6410 },
6732 - crypto: yield* Crypto.Crypto,
6411 instanceId,
6412 flavor: {
6413 driver: ACP_TEST_DRIVER,
@@ -6771,9 +6449,6 @@ describe("AcpAdapterV2", () => {
6449 }),
6450 }),
6451 },
6774 - fileSystem,
6775 - idAllocator,
6776 - host,
6452 selfInvocation,
6453 continuationRequests: {
6454 offer: (request) =>
@@ -6997,10 +6672,8 @@ describe("AcpAdapterV2", () => {
6672 () =>
6673 Effect.gen(function* () {
6674 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
7000 - const fileSystem = yield* FileSystem.FileSystem;
6675 const idAllocator = yield* IdAllocator.IdAllocatorV2;
6676 const path = yield* Path.Path;
7003 - const host = yield* ProviderHost.ProviderHost;
6677 const selfInvocation = yield* resolveSelfInvocation();
6678 const mockAgentPath = yield* path.fromFileUrl(
6679 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -7013,12 +6686,11 @@ describe("AcpAdapterV2", () => {
6686 type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
6687 let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
6688 const promptSettled = yield* Deferred.make<void>();
7016 - const adapter = makeAcpAdapterV2({
6689 + const adapter = yield* makeAcpAdapterV2({
6690 testHooks: {
6691 afterPromptSettledWithBackgroundWork: () =>
6692 Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid),
6693 },
7021 - crypto: yield* Crypto.Crypto,
6694 instanceId,
6695 flavor: {
6696 driver: ACP_TEST_DRIVER,
@@ -7069,9 +6741,6 @@ describe("AcpAdapterV2", () => {
6741 }),
6742 }),
6743 },
7072 - fileSystem,
7073 - idAllocator,
7074 - host,
6744 selfInvocation,
6745 continuationRequests: {
6746 offer: (request) =>
@@ -7238,10 +6907,8 @@ describe("AcpAdapterV2", () => {
6907 it.effect("projects an interrupted root-session end notice at the next attach", () =>
6908 Effect.gen(function* () {
6909 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
7241 - const fileSystem = yield* FileSystem.FileSystem;
6910 const idAllocator = yield* IdAllocator.IdAllocatorV2;
6911 const path = yield* Path.Path;
7244 - const host = yield* ProviderHost.ProviderHost;
6912 const selfInvocation = yield* resolveSelfInvocation();
6913 const mockAgentPath = yield* path.fromFileUrl(
6914 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -7254,12 +6921,11 @@ describe("AcpAdapterV2", () => {
6921 let subagentPhase: "spawn" | "complete" = "spawn";
6922 type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
6923 let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
7257 - const adapter = makeAcpAdapterV2({
6924 + const adapter = yield* makeAcpAdapterV2({
6925 testHooks: {
6926 afterPromptSettledWithBackgroundWork: () =>
6927 Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid),
6928 },
7262 - crypto: yield* Crypto.Crypto,
6929 instanceId,
6930 flavor: {
6931 driver: ACP_TEST_DRIVER,
@@ -7313,9 +6979,6 @@ describe("AcpAdapterV2", () => {
6979 }),
6980 }),
6981 },
7316 - fileSystem,
7317 - idAllocator,
7318 - host,
6982 selfInvocation,
6983 continuationRequests: {
6984 offer: (request) =>
@@ -7467,10 +7130,8 @@ describe("AcpAdapterV2", () => {
7130 () =>
7131 Effect.gen(function* () {
7132 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
7470 - const fileSystem = yield* FileSystem.FileSystem;
7133 const idAllocator = yield* IdAllocator.IdAllocatorV2;
7134 const path = yield* Path.Path;
7473 - const host = yield* ProviderHost.ProviderHost;
7135 const selfInvocation = yield* resolveSelfInvocation();
7136 const mockAgentPath = yield* path.fromFileUrl(
7137 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -7483,12 +7144,11 @@ describe("AcpAdapterV2", () => {
7144 type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
7145 let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
7146 const promptSettled = yield* Deferred.make<void>();
7486 - const adapter = makeAcpAdapterV2({
7147 + const adapter = yield* makeAcpAdapterV2({
7148 testHooks: {
7149 afterPromptSettledWithBackgroundWork: () =>
7150 Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid),
7151 },
7491 - crypto: yield* Crypto.Crypto,
7152 instanceId,
7153 flavor: {
7154 driver: ACP_TEST_DRIVER,
@@ -7530,9 +7190,6 @@ describe("AcpAdapterV2", () => {
7190 }),
7191 }),
7192 },
7533 - fileSystem,
7534 - idAllocator,
7535 - host,
7193 selfInvocation,
7194 continuationRequests: {
7195 offer: (request) =>
@@ -7738,10 +7395,8 @@ describe("AcpAdapterV2", () => {
7395 () =>
7396 Effect.gen(function* () {
7397 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
7741 - const fileSystem = yield* FileSystem.FileSystem;
7398 const idAllocator = yield* IdAllocator.IdAllocatorV2;
7399 const path = yield* Path.Path;
7744 - const host = yield* ProviderHost.ProviderHost;
7400 const selfInvocation = yield* resolveSelfInvocation();
7401 const mockAgentPath = yield* path.fromFileUrl(
7402 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -7753,12 +7408,11 @@ describe("AcpAdapterV2", () => {
7408 type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
7409 let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
7410 const promptSettled = yield* Deferred.make<void>();
7756 - const adapter = makeAcpAdapterV2({
7411 + const adapter = yield* makeAcpAdapterV2({
7412 testHooks: {
7413 afterPromptSettledWithBackgroundWork: () =>
7414 Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid),
7415 },
7761 - crypto: yield* Crypto.Crypto,
7416 instanceId,
7417 flavor: {
7418 driver: ACP_TEST_DRIVER,
@@ -7800,9 +7454,6 @@ describe("AcpAdapterV2", () => {
7454 }),
7455 }),
7456 },
7803 - fileSystem,
7804 - idAllocator,
7805 - host,
7457 selfInvocation,
7458 continuationRequests: {
7459 offer: (request) =>
@@ -7980,10 +7631,8 @@ describe("AcpAdapterV2", () => {
7631 () =>
7632 Effect.gen(function* () {
7633 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
7983 - const fileSystem = yield* FileSystem.FileSystem;
7634 const idAllocator = yield* IdAllocator.IdAllocatorV2;
7635 const path = yield* Path.Path;
7986 - const host = yield* ProviderHost.ProviderHost;
7636 const selfInvocation = yield* resolveSelfInvocation();
7637 const mockAgentPath = yield* path.fromFileUrl(
7638 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -7993,12 +7642,11 @@ describe("AcpAdapterV2", () => {
7642 let cancelCalled = false;
7643 let runtimeOrdinalSeen = 0;
7644 const promptSettled = yield* Deferred.make<void>();
7996 - const adapter = makeAcpAdapterV2({
7645 + const adapter = yield* makeAcpAdapterV2({
7646 testHooks: {
7647 afterPromptSettledWithBackgroundWork: () =>
7648 Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid),
7649 },
8001 - crypto: yield* Crypto.Crypto,
7650 instanceId,
7651 flavor: {
7652 driver: ACP_TEST_DRIVER,
@@ -8050,9 +7698,6 @@ describe("AcpAdapterV2", () => {
7698 }).pipe(Effect.andThen(cancel)),
7699 }),
7700 },
8053 - fileSystem,
8054 - idAllocator,
8055 - host,
7701 selfInvocation,
7702 });
7703 const threadId = ThreadId.make("thread-acp-settled-soft-steer");
@@ -8156,18 +7801,15 @@ describe("AcpAdapterV2", () => {
7801 it.live("preserveRuntimeOnSettledInterrupt does not soften a mid-prompt steering interrupt", () =>
7802 Effect.gen(function* () {
7803 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
8159 - const fileSystem = yield* FileSystem.FileSystem;
7804 const idAllocator = yield* IdAllocator.IdAllocatorV2;
7805 const path = yield* Path.Path;
8162 - const host = yield* ProviderHost.ProviderHost;
7806 const selfInvocation = yield* resolveSelfInvocation();
7807 const mockAgentPath = yield* path.fromFileUrl(
7808 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
7809 );
7810 const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
7811 const instanceId = ProviderInstanceId.make("acp-test");
8169 - const adapter = makeAcpAdapterV2({
8170 - crypto: yield* Crypto.Crypto,
7812 + const adapter = yield* makeAcpAdapterV2({
7813 instanceId,
7814 flavor: {
7815 driver: ACP_TEST_DRIVER,
@@ -8189,9 +7831,6 @@ describe("AcpAdapterV2", () => {
7831 protocolEvents,
7832 }),
7833 },
8192 - fileSystem,
8193 - idAllocator,
8194 - host,
7834 selfInvocation,
7835 });
7836 const threadId = ThreadId.make("thread-acp-unsettled-steer-stays-hard");
@@ -8246,10 +7885,8 @@ describe("AcpAdapterV2", () => {
7885 () =>
7886 Effect.gen(function* () {
7887 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
8249 - const fileSystem = yield* FileSystem.FileSystem;
7888 const idAllocator = yield* IdAllocator.IdAllocatorV2;
7889 const path = yield* Path.Path;
8252 - const host = yield* ProviderHost.ProviderHost;
7890 const selfInvocation = yield* resolveSelfInvocation();
7891 const mockAgentPath = yield* path.fromFileUrl(
7892 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -8259,8 +7896,7 @@ describe("AcpAdapterV2", () => {
7896 const instanceId = ProviderInstanceId.make("acp-test");
7897 let cancelCalled = false;
7898 let runtimeOrdinalSeen = 0;
8262 - const adapter = makeAcpAdapterV2({
8263 - crypto: yield* Crypto.Crypto,
7899 + const adapter = yield* makeAcpAdapterV2({
7900 instanceId,
7901 flavor: {
7902 driver: ACP_TEST_DRIVER,
@@ -8295,9 +7931,6 @@ describe("AcpAdapterV2", () => {
7931 }).pipe(Effect.andThen(cancel)),
7932 }),
7933 },
8298 - fileSystem,
8299 - idAllocator,
8300 - host,
7934 selfInvocation,
7935 continuationRequests: {
7936 offer: (request) =>
@@ -8440,10 +8073,8 @@ describe("AcpAdapterV2", () => {
8073 it.live("direct Stop quarantine drops late background task mutations from the stopped run", () =>
8074 Effect.gen(function* () {
8075 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
8443 - const fileSystem = yield* FileSystem.FileSystem;
8076 const idAllocator = yield* IdAllocator.IdAllocatorV2;
8077 const path = yield* Path.Path;
8446 - const host = yield* ProviderHost.ProviderHost;
8078 const selfInvocation = yield* resolveSelfInvocation();
8079 const mockAgentPath = yield* path.fromFileUrl(
8080 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -8459,8 +8090,7 @@ describe("AcpAdapterV2", () => {
8090 }) => Effect.Effect<void>)
8091 | null;
8092 } = { current: null };
8462 - const adapter = makeAcpAdapterV2({
8463 - crypto: yield* Crypto.Crypto,
8093 + const adapter = yield* makeAcpAdapterV2({
8094 instanceId,
8095 flavor: {
8096 driver: ACP_TEST_DRIVER,
@@ -8481,9 +8111,6 @@ describe("AcpAdapterV2", () => {
8111 protocolEvents,
8112 }),
8113 },
8484 - fileSystem,
8485 - idAllocator,
8486 - host,
8114 selfInvocation,
8115 continuationRequests: { offer: () => Effect.void },
8116 });
@@ -8587,10 +8214,8 @@ describe("AcpAdapterV2", () => {
8214 it.live("production Grok interrupt flags still hard-kill and respawn on user Stop", () =>
8215 Effect.gen(function* () {
8216 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
8590 - const fileSystem = yield* FileSystem.FileSystem;
8217 const idAllocator = yield* IdAllocator.IdAllocatorV2;
8218 const path = yield* Path.Path;
8593 - const host = yield* ProviderHost.ProviderHost;
8219 const selfInvocation = yield* resolveSelfInvocation();
8220 const mockAgentPath = yield* path.fromFileUrl(
8221 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -8598,8 +8223,7 @@ describe("AcpAdapterV2", () => {
8223 const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
8224 const instanceId = ProviderInstanceId.make("acp-test");
8225 let runtimeOrdinalSeen = 0;
8601 - const adapter = makeAcpAdapterV2({
8602 - crypto: yield* Crypto.Crypto,
8226 + const adapter = yield* makeAcpAdapterV2({
8227 instanceId,
8228 flavor: {
8229 driver: ACP_TEST_DRIVER,
@@ -8627,9 +8251,6 @@ describe("AcpAdapterV2", () => {
8251 protocolEvents,
8252 }),
8253 },
8630 - fileSystem,
8631 - idAllocator,
8632 - host,
8254 selfInvocation,
8255 continuationRequests: { offer: () => Effect.void },
8256 });
@@ -8718,10 +8339,8 @@ describe("AcpAdapterV2", () => {
8339 () =>
8340 Effect.gen(function* () {
8341 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
8721 - const fileSystem = yield* FileSystem.FileSystem;
8342 const idAllocator = yield* IdAllocator.IdAllocatorV2;
8343 const path = yield* Path.Path;
8724 - const host = yield* ProviderHost.ProviderHost;
8344 const selfInvocation = yield* resolveSelfInvocation();
8345 const mockAgentPath = yield* path.fromFileUrl(
8346 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -8736,12 +8355,11 @@ describe("AcpAdapterV2", () => {
8355 type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
8356 let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
8357 const promptSettled = yield* Deferred.make<void>();
8739 - const adapter = makeAcpAdapterV2({
8358 + const adapter = yield* makeAcpAdapterV2({
8359 testHooks: {
8360 afterPromptSettledWithBackgroundWork: () =>
8361 Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid),
8362 },
8744 - crypto: yield* Crypto.Crypto,
8363 instanceId,
8364 flavor: {
8365 driver: ACP_TEST_DRIVER,
@@ -8796,9 +8414,6 @@ describe("AcpAdapterV2", () => {
8414 }),
8415 }),
8416 },
8799 - fileSystem,
8800 - idAllocator,
8801 - host,
8417 selfInvocation,
8418 });
8419 const threadId = ThreadId.make("thread-acp-stop-after-soft-steer-orphan");
@@ -9022,10 +8637,8 @@ describe("AcpAdapterV2", () => {
8637 it.live("Direct Stop projects an interrupt-deferred terminal exactly once", () =>
8638 Effect.gen(function* () {
8639 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
9025 - const fileSystem = yield* FileSystem.FileSystem;
8640 const idAllocator = yield* IdAllocator.IdAllocatorV2;
8641 const path = yield* Path.Path;
9028 - const host = yield* ProviderHost.ProviderHost;
8642 const selfInvocation = yield* resolveSelfInvocation();
8643 const mockAgentPath = yield* path.fromFileUrl(
8644 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -9036,8 +8649,7 @@ describe("AcpAdapterV2", () => {
8649 let subagentPhase: "spawn" | "complete" = "spawn";
8650 type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
8651 let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
9039 - const adapter = makeAcpAdapterV2({
9040 - crypto: yield* Crypto.Crypto,
8652 + const adapter = yield* makeAcpAdapterV2({
8653 instanceId,
8654 flavor: {
8655 driver: ACP_TEST_DRIVER,
@@ -9084,9 +8696,6 @@ describe("AcpAdapterV2", () => {
8696 }),
8697 }),
8698 },
9087 - fileSystem,
9088 - idAllocator,
9089 - host,
8699 selfInvocation,
8700 continuationRequests: { offer: () => Effect.void },
8701 });
@@ -9219,10 +8828,8 @@ describe("AcpAdapterV2", () => {
8828 () =>
8829 Effect.gen(function* () {
8830 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
9222 - const fileSystem = yield* FileSystem.FileSystem;
8831 const idAllocator = yield* IdAllocator.IdAllocatorV2;
8832 const path = yield* Path.Path;
9225 - const host = yield* ProviderHost.ProviderHost;
8833 const selfInvocation = yield* resolveSelfInvocation();
8834 const mockAgentPath = yield* path.fromFileUrl(
8835 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -9238,8 +8845,7 @@ describe("AcpAdapterV2", () => {
8845 // interrupt then ORs wire-done with promptSettled under the permit.
8846 const promptWireReturned = yield* Deferred.make<void>();
8847 const releasePromptCompletion = yield* Deferred.make<void>();
9241 - const adapter = makeAcpAdapterV2({
9242 - crypto: yield* Crypto.Crypto,
8848 + const adapter = yield* makeAcpAdapterV2({
8849 instanceId,
8850 flavor: {
8851 driver: ACP_TEST_DRIVER,
@@ -9295,9 +8901,6 @@ describe("AcpAdapterV2", () => {
8901 }),
8902 }),
8903 },
9298 - fileSystem,
9299 - idAllocator,
9300 - host,
8904 selfInvocation,
8905 });
8906 const threadId = ThreadId.make("thread-acp-settled-soft-admission-race");
@@ -9389,10 +8992,8 @@ describe("AcpAdapterV2", () => {
8992 () =>
8993 Effect.gen(function* () {
8994 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
9392 - const fileSystem = yield* FileSystem.FileSystem;
8995 const idAllocator = yield* IdAllocator.IdAllocatorV2;
8996 const path = yield* Path.Path;
9395 - const host = yield* ProviderHost.ProviderHost;
8997 const selfInvocation = yield* resolveSelfInvocation();
8998 const mockAgentPath = yield* path.fromFileUrl(
8999 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -9400,8 +9001,7 @@ describe("AcpAdapterV2", () => {
9001 const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
9002 const continuationRequests: Array<ProviderContinuationRequest> = [];
9003 const instanceId = ProviderInstanceId.make("acp-test");
9403 - const adapter = makeAcpAdapterV2({
9404 - crypto: yield* Crypto.Crypto,
9004 + const adapter = yield* makeAcpAdapterV2({
9005 instanceId,
9006 flavor: {
9007 driver: ACP_TEST_DRIVER,
@@ -9428,9 +9028,6 @@ describe("AcpAdapterV2", () => {
9028 protocolEvents,
9029 }),
9030 },
9431 - fileSystem,
9432 - idAllocator,
9433 - host,
9031 selfInvocation,
9032 continuationRequests: {
9033 offer: (request) =>
@@ -9520,10 +9117,8 @@ describe("AcpAdapterV2", () => {
9117 () =>
9118 Effect.gen(function* () {
9119 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
9523 - const fileSystem = yield* FileSystem.FileSystem;
9120 const idAllocator = yield* IdAllocator.IdAllocatorV2;
9121 const path = yield* Path.Path;
9526 - const host = yield* ProviderHost.ProviderHost;
9122 const selfInvocation = yield* resolveSelfInvocation();
9123 const mockAgentPath = yield* path.fromFileUrl(
9124 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -9532,8 +9127,7 @@ describe("AcpAdapterV2", () => {
9127 type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
9128 let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
9129 const instanceId = ProviderInstanceId.make("acp-test");
9535 - const adapter = makeAcpAdapterV2({
9536 - crypto: yield* Crypto.Crypto,
9130 + const adapter = yield* makeAcpAdapterV2({
9131 instanceId,
9132 flavor: {
9133 driver: ACP_TEST_DRIVER,
@@ -9551,9 +9145,6 @@ describe("AcpAdapterV2", () => {
9145 }),
9146 }),
9147 },
9554 - fileSystem,
9555 - idAllocator,
9556 - host,
9148 selfInvocation,
9149 continuationRequests: {
9150 offer: (request) =>
@@ -9640,10 +9231,8 @@ describe("AcpAdapterV2", () => {
9231 it.effect("keeps a buffered continuation current when a user turn starts before dispatch", () =>
9232 Effect.gen(function* () {
9233 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
9643 - const fileSystem = yield* FileSystem.FileSystem;
9234 const idAllocator = yield* IdAllocator.IdAllocatorV2;
9235 const path = yield* Path.Path;
9646 - const host = yield* ProviderHost.ProviderHost;
9236 const selfInvocation = yield* resolveSelfInvocation();
9237 const mockAgentPath = yield* path.fromFileUrl(
9238 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -9656,8 +9245,7 @@ describe("AcpAdapterV2", () => {
9245 type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
9246 let sessionUpdateHandler: Parameters<RuntimeService["handleSessionUpdate"]>[0] | undefined;
9247 const instanceId = ProviderInstanceId.make("acp-test");
9659 - const adapter = makeAcpAdapterV2({
9660 - crypto: yield* Crypto.Crypto,
9248 + const adapter = yield* makeAcpAdapterV2({
9249 instanceId,
9250 flavor: {
9251 driver: ACP_TEST_DRIVER,
@@ -9687,9 +9275,6 @@ describe("AcpAdapterV2", () => {
9275 }),
9276 }),
9277 },
9690 - fileSystem,
9691 - idAllocator,
9692 - host,
9278 selfInvocation,
9279 continuationRequests: {
9280 offer: (request) =>
@@ -9852,7 +9437,6 @@ describe("AcpAdapterV2", () => {
9437 const fileSystem = yield* FileSystem.FileSystem;
9438 const idAllocator = yield* IdAllocator.IdAllocatorV2;
9439 const path = yield* Path.Path;
9855 - const host = yield* ProviderHost.ProviderHost;
9440 const selfInvocation = yield* resolveSelfInvocation();
9441 const mockAgentPath = yield* path.fromFileUrl(
9442 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -9861,8 +9445,7 @@ describe("AcpAdapterV2", () => {
9445 const triggerPath = path.join(triggerDir, "report-trigger");
9446 const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
9447 const instanceId = ProviderInstanceId.make("acp-test");
9864 - const adapter = makeAcpAdapterV2({
9865 - crypto: yield* Crypto.Crypto,
9448 + const adapter = yield* makeAcpAdapterV2({
9449 instanceId,
9450 flavor: {
9451 driver: ACP_TEST_DRIVER,
@@ -9894,9 +9477,6 @@ describe("AcpAdapterV2", () => {
9477 protocolEvents,
9478 }),
9479 },
9897 - fileSystem,
9898 - idAllocator,
9899 - host,
9480 selfInvocation,
9481 });
9482 const threadId = ThreadId.make("thread-acp-injected-report-hold");
@@ -10018,7 +9598,6 @@ describe("AcpAdapterV2", () => {
9598 const fileSystem = yield* FileSystem.FileSystem;
9599 const idAllocator = yield* IdAllocator.IdAllocatorV2;
9600 const path = yield* Path.Path;
10021 - const host = yield* ProviderHost.ProviderHost;
9601 const selfInvocation = yield* resolveSelfInvocation();
9602 const mockAgentPath = yield* path.fromFileUrl(
9603 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -10037,8 +9616,7 @@ describe("AcpAdapterV2", () => {
9616 | null;
9617 } = { current: null };
9618 const instanceId = ProviderInstanceId.make("acp-test");
10040 - const adapter = makeAcpAdapterV2({
10041 - crypto: yield* Crypto.Crypto,
9619 + const adapter = yield* makeAcpAdapterV2({
9620 instanceId,
9621 flavor: {
9622 driver: ACP_TEST_DRIVER,
@@ -10075,9 +9653,6 @@ describe("AcpAdapterV2", () => {
9653 protocolEvents,
9654 }),
9655 },
10078 - fileSystem,
10079 - idAllocator,
10080 - host,
9656 selfInvocation,
9657 continuationRequests: {
9658 offer: (request) =>
@@ -10217,10 +9792,8 @@ describe("AcpAdapterV2", () => {
9792 () =>
9793 Effect.gen(function* () {
9794 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
10220 - const fileSystem = yield* FileSystem.FileSystem;
9795 const idAllocator = yield* IdAllocator.IdAllocatorV2;
9796 const path = yield* Path.Path;
10223 - const host = yield* ProviderHost.ProviderHost;
9797 const selfInvocation = yield* resolveSelfInvocation();
9798 const mockAgentPath = yield* path.fromFileUrl(
9799 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -10240,8 +9813,7 @@ describe("AcpAdapterV2", () => {
9813 | null;
9814 } = { current: null };
9815 const instanceId = ProviderInstanceId.make("acp-test");
10243 - const adapter = makeAcpAdapterV2({
10244 - crypto: yield* Crypto.Crypto,
9816 + const adapter = yield* makeAcpAdapterV2({
9817 instanceId,
9818 flavor: {
9819 driver: ACP_TEST_DRIVER,
@@ -10273,9 +9845,6 @@ describe("AcpAdapterV2", () => {
9845 }),
9846 }),
9847 },
10276 - fileSystem,
10277 - idAllocator,
10278 - host,
9848 selfInvocation,
9849 continuationRequests: {
9850 offer: (request) =>
@@ -10457,10 +10026,8 @@ describe("AcpAdapterV2", () => {
10026 () =>
10027 Effect.gen(function* () {
10028 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
10460 - const fileSystem = yield* FileSystem.FileSystem;
10029 const idAllocator = yield* IdAllocator.IdAllocatorV2;
10030 const path = yield* Path.Path;
10463 - const host = yield* ProviderHost.ProviderHost;
10031 const selfInvocation = yield* resolveSelfInvocation();
10032 const mockAgentPath = yield* path.fromFileUrl(
10033 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -10480,8 +10047,7 @@ describe("AcpAdapterV2", () => {
10047 | null;
10048 } = { current: null };
10049 const instanceId = ProviderInstanceId.make("acp-test");
10483 - const adapter = makeAcpAdapterV2({
10484 - crypto: yield* Crypto.Crypto,
10050 + const adapter = yield* makeAcpAdapterV2({
10051 instanceId,
10052 flavor: {
10053 driver: ACP_TEST_DRIVER,
@@ -10520,9 +10086,6 @@ describe("AcpAdapterV2", () => {
10086 }),
10087 }),
10088 },
10523 - fileSystem,
10524 - idAllocator,
10525 - host,
10089 selfInvocation,
10090 continuationRequests: {
10091 offer: (request) =>
@@ -10676,10 +10239,8 @@ describe("AcpAdapterV2", () => {
10239 () =>
10240 Effect.gen(function* () {
10241 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
10679 - const fileSystem = yield* FileSystem.FileSystem;
10242 const idAllocator = yield* IdAllocator.IdAllocatorV2;
10243 const path = yield* Path.Path;
10682 - const host = yield* ProviderHost.ProviderHost;
10244 const selfInvocation = yield* resolveSelfInvocation();
10245 const mockAgentPath = yield* path.fromFileUrl(
10246 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -10699,8 +10260,7 @@ describe("AcpAdapterV2", () => {
10260 | null;
10261 } = { current: null };
10262 const instanceId = ProviderInstanceId.make("acp-test");
10702 - const adapter = makeAcpAdapterV2({
10703 - crypto: yield* Crypto.Crypto,
10263 + const adapter = yield* makeAcpAdapterV2({
10264 instanceId,
10265 flavor: {
10266 driver: ACP_TEST_DRIVER,
@@ -10743,9 +10303,6 @@ describe("AcpAdapterV2", () => {
10303 }),
10304 }),
10305 },
10746 - fileSystem,
10747 - idAllocator,
10748 - host,
10306 selfInvocation,
10307 continuationRequests: {
10308 offer: (request) =>
@@ -10891,10 +10448,8 @@ describe("AcpAdapterV2", () => {
10448 () =>
10449 Effect.gen(function* () {
10450 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
10894 - const fileSystem = yield* FileSystem.FileSystem;
10451 const idAllocator = yield* IdAllocator.IdAllocatorV2;
10452 const path = yield* Path.Path;
10897 - const host = yield* ProviderHost.ProviderHost;
10453 const selfInvocation = yield* resolveSelfInvocation();
10454 const mockAgentPath = yield* path.fromFileUrl(
10455 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -10914,8 +10469,7 @@ describe("AcpAdapterV2", () => {
10469 | null;
10470 } = { current: null };
10471 const instanceId = ProviderInstanceId.make("acp-test");
10917 - const adapter = makeAcpAdapterV2({
10918 - crypto: yield* Crypto.Crypto,
10472 + const adapter = yield* makeAcpAdapterV2({
10473 instanceId,
10474 flavor: {
10475 driver: ACP_TEST_DRIVER,
@@ -10980,9 +10534,6 @@ describe("AcpAdapterV2", () => {
10534 }),
10535 }),
10536 },
10983 - fileSystem,
10984 - idAllocator,
10985 - host,
10537 selfInvocation,
10538 continuationRequests: {
10539 offer: (request) =>
@@ -11263,10 +10814,8 @@ describe("AcpAdapterV2", () => {
10814 it.effect("a wake names work that ended while the previous wake was queued", () =>
10815 Effect.gen(function* () {
10816 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
11266 - const fileSystem = yield* FileSystem.FileSystem;
10817 const idAllocator = yield* IdAllocator.IdAllocatorV2;
10818 const path = yield* Path.Path;
11269 - const host = yield* ProviderHost.ProviderHost;
10819 const selfInvocation = yield* resolveSelfInvocation();
10820 const mockAgentPath = yield* path.fromFileUrl(
10821 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -11277,8 +10826,7 @@ describe("AcpAdapterV2", () => {
10826 let applyMutation: AcpAdapterV2ExtensionContext["applyBackgroundTaskMutation"] | undefined;
10827 const promptGate = yield* Deferred.make<EffectAcpSchema.PromptResponse>();
10828 const instanceId = ProviderInstanceId.make("acp-test");
11280 - const adapter = makeAcpAdapterV2({
11281 - crypto: yield* Crypto.Crypto,
10829 + const adapter = yield* makeAcpAdapterV2({
10830 instanceId,
10831 flavor: {
10832 driver: ACP_TEST_DRIVER,
@@ -11303,9 +10851,6 @@ describe("AcpAdapterV2", () => {
10851 }),
10852 }),
10853 },
11306 - fileSystem,
11307 - idAllocator,
11308 - host,
10854 selfInvocation,
10855 continuationRequests: {
10856 offer: (request) =>
@@ -11417,10 +10962,8 @@ describe("AcpAdapterV2", () => {
10962 it.effect("mid-turn completed mutation defers offer until finalize only when unhandled", () =>
10963 Effect.gen(function* () {
10964 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
11420 - const fileSystem = yield* FileSystem.FileSystem;
10965 const idAllocator = yield* IdAllocator.IdAllocatorV2;
10966 const path = yield* Path.Path;
11423 - const host = yield* ProviderHost.ProviderHost;
10967 const selfInvocation = yield* resolveSelfInvocation();
10968 const mockAgentPath = yield* path.fromFileUrl(
10969 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -11440,8 +10983,7 @@ describe("AcpAdapterV2", () => {
10983 | null;
10984 } = { current: null };
10985 const instanceId = ProviderInstanceId.make("acp-test");
11443 - const adapter = makeAcpAdapterV2({
11444 - crypto: yield* Crypto.Crypto,
10986 + const adapter = yield* makeAcpAdapterV2({
10987 instanceId,
10988 flavor: {
10989 driver: ACP_TEST_DRIVER,
@@ -11487,9 +11029,6 @@ describe("AcpAdapterV2", () => {
11029 }),
11030 }),
11031 },
11490 - fileSystem,
11491 - idAllocator,
11492 - host,
11032 selfInvocation,
11033 continuationRequests: {
11034 offer: (request) =>
@@ -11748,10 +11287,8 @@ describe("AcpAdapterV2", () => {
11287 () =>
11288 Effect.gen(function* () {
11289 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
11751 - const fileSystem = yield* FileSystem.FileSystem;
11290 const idAllocator = yield* IdAllocator.IdAllocatorV2;
11291 const path = yield* Path.Path;
11754 - const host = yield* ProviderHost.ProviderHost;
11292 const selfInvocation = yield* resolveSelfInvocation();
11293 const mockAgentPath = yield* path.fromFileUrl(
11294 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -11771,8 +11308,7 @@ describe("AcpAdapterV2", () => {
11308 | null;
11309 } = { current: null };
11310 const instanceId = ProviderInstanceId.make("acp-test");
11774 - const adapter = makeAcpAdapterV2({
11775 - crypto: yield* Crypto.Crypto,
11311 + const adapter = yield* makeAcpAdapterV2({
11312 instanceId,
11313 flavor: {
11314 driver: ACP_TEST_DRIVER,
@@ -11799,9 +11335,6 @@ describe("AcpAdapterV2", () => {
11335 }),
11336 }),
11337 },
11802 - fileSystem,
11803 - idAllocator,
11804 - host,
11338 selfInvocation,
11339 continuationRequests: {
11340 offer: (request) =>
@@ -11935,10 +11468,8 @@ describe("AcpAdapterV2", () => {
11468 it.effect("empty-drain continuation turn waits the quiet window so late frames can attach", () =>
11469 Effect.gen(function* () {
11470 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
11938 - const fileSystem = yield* FileSystem.FileSystem;
11471 const idAllocator = yield* IdAllocator.IdAllocatorV2;
11472 const path = yield* Path.Path;
11941 - const host = yield* ProviderHost.ProviderHost;
11473 const selfInvocation = yield* resolveSelfInvocation();
11474 const mockAgentPath = yield* path.fromFileUrl(
11475 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -11958,8 +11489,7 @@ describe("AcpAdapterV2", () => {
11489 | null;
11490 } = { current: null };
11491 const instanceId = ProviderInstanceId.make("acp-test");
11961 - const adapter = makeAcpAdapterV2({
11962 - crypto: yield* Crypto.Crypto,
11492 + const adapter = yield* makeAcpAdapterV2({
11493 instanceId,
11494 flavor: {
11495 driver: ACP_TEST_DRIVER,
@@ -11990,9 +11520,6 @@ describe("AcpAdapterV2", () => {
11520 }),
11521 }),
11522 },
11993 - fileSystem,
11994 - idAllocator,
11995 - host,
11523 selfInvocation,
11524 continuationRequests: {
11525 offer: (request) =>
@@ -12179,10 +11706,8 @@ describe("AcpAdapterV2", () => {
11706 it.effect("empty-drain continuation turn finalizes after the quiet window with no frames", () =>
11707 Effect.gen(function* () {
11708 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
12182 - const fileSystem = yield* FileSystem.FileSystem;
11709 const idAllocator = yield* IdAllocator.IdAllocatorV2;
11710 const path = yield* Path.Path;
12185 - const host = yield* ProviderHost.ProviderHost;
11711 const selfInvocation = yield* resolveSelfInvocation();
11712 const mockAgentPath = yield* path.fromFileUrl(
11713 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -12202,8 +11727,7 @@ describe("AcpAdapterV2", () => {
11727 | null;
11728 } = { current: null };
11729 const instanceId = ProviderInstanceId.make("acp-test");
12205 - const adapter = makeAcpAdapterV2({
12206 - crypto: yield* Crypto.Crypto,
11730 + const adapter = yield* makeAcpAdapterV2({
11731 instanceId,
11732 flavor: {
11733 driver: ACP_TEST_DRIVER,
@@ -12232,9 +11756,6 @@ describe("AcpAdapterV2", () => {
11756 }),
11757 }),
11758 },
12235 - fileSystem,
12236 - idAllocator,
12237 - host,
11759 selfInvocation,
11760 continuationRequests: {
11761 offer: (request) =>
@@ -12369,18 +11890,15 @@ describe("AcpAdapterV2", () => {
11890 it.effect("restarts the ACP child process before the next prompt after interrupt", () =>
11891 Effect.gen(function* () {
11892 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
12372 - const fileSystem = yield* FileSystem.FileSystem;
11893 const idAllocator = yield* IdAllocator.IdAllocatorV2;
11894 const path = yield* Path.Path;
12375 - const host = yield* ProviderHost.ProviderHost;
11895 const selfInvocation = yield* resolveSelfInvocation();
11896 const mockAgentPath = yield* path.fromFileUrl(
11897 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
11898 );
11899 const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
11900 const instanceId = ProviderInstanceId.make("acp-test");
12382 - const adapter = makeAcpAdapterV2({
12383 - crypto: yield* Crypto.Crypto,
11901 + const adapter = yield* makeAcpAdapterV2({
11902 instanceId,
11903 flavor: {
11904 driver: ACP_TEST_DRIVER,
@@ -12392,9 +11910,6 @@ describe("AcpAdapterV2", () => {
11910 protocolEvents,
11911 }),
11912 },
12395 - fileSystem,
12396 - idAllocator,
12397 - host,
11913 selfInvocation,
11914 });
11915 const threadId = ThreadId.make("thread-acp-restart-after-interrupt");
@@ -12618,7 +12133,6 @@ describe("AcpAdapterV2", () => {
12133 const fileSystem = yield* FileSystem.FileSystem;
12134 const idAllocator = yield* IdAllocator.IdAllocatorV2;
12135 const path = yield* Path.Path;
12621 - const host = yield* ProviderHost.ProviderHost;
12136 const selfInvocation = yield* resolveSelfInvocation();
12137 const mockAgentPath = yield* path.fromFileUrl(
12138 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -12635,8 +12149,7 @@ describe("AcpAdapterV2", () => {
12149 const releaseTeardown = yield* Deferred.make<void>();
12150 let terminatorCallCount = 0;
12151 const instanceId = ProviderInstanceId.make("acp-test");
12638 - const adapter = makeAcpAdapterV2({
12639 - crypto: yield* Crypto.Crypto,
12152 + const adapter = yield* makeAcpAdapterV2({
12153 instanceId,
12154 flavor: {
12155 driver: ACP_TEST_DRIVER,
@@ -12665,9 +12178,6 @@ describe("AcpAdapterV2", () => {
12178 protocolEvents,
12179 }),
12180 },
12668 - fileSystem,
12669 - idAllocator,
12670 - host,
12181 selfInvocation,
12182 continuationRequests: {
12183 offer: (request) =>
@@ -12833,18 +12343,15 @@ describe("AcpAdapterV2", () => {
12343 it.live("durably poisons start and resume when required hard teardown is unavailable", () =>
12344 Effect.gen(function* () {
12345 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
12836 - const fileSystem = yield* FileSystem.FileSystem;
12346 const idAllocator = yield* IdAllocator.IdAllocatorV2;
12347 const path = yield* Path.Path;
12839 - const host = yield* ProviderHost.ProviderHost;
12348 const selfInvocation = yield* resolveSelfInvocation();
12349 const mockAgentPath = yield* path.fromFileUrl(
12350 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
12351 );
12352 const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
12353 const instanceId = ProviderInstanceId.make("acp-test");
12846 - const adapter = makeAcpAdapterV2({
12847 - crypto: yield* Crypto.Crypto,
12354 + const adapter = yield* makeAcpAdapterV2({
12355 instanceId,
12356 flavor: {
12357 driver: ACP_TEST_DRIVER,
@@ -12858,9 +12365,6 @@ describe("AcpAdapterV2", () => {
12365 protocolEvents,
12366 }),
12367 },
12861 - fileSystem,
12862 - idAllocator,
12863 - host,
12368 selfInvocation,
12369 });
12370 const threadId = ThreadId.make("thread-acp-missing-hard-teardown");
@@ -12922,10 +12426,8 @@ describe("AcpAdapterV2", () => {
12426 it.live("holds concurrent startTurn behind successful hard teardown and reloads once", () =>
12427 Effect.gen(function* () {
12428 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
12925 - const fileSystem = yield* FileSystem.FileSystem;
12429 const idAllocator = yield* IdAllocator.IdAllocatorV2;
12430 const path = yield* Path.Path;
12928 - const host = yield* ProviderHost.ProviderHost;
12431 const selfInvocation = yield* resolveSelfInvocation();
12432 const mockAgentPath = yield* path.fromFileUrl(
12433 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -12935,8 +12437,7 @@ describe("AcpAdapterV2", () => {
12437 const releaseTeardown = yield* Deferred.make<void>();
12438 let runtimeOrdinalSeen = 0;
12439 const instanceId = ProviderInstanceId.make("acp-test");
12938 - const adapter = makeAcpAdapterV2({
12939 - crypto: yield* Crypto.Crypto,
12440 + const adapter = yield* makeAcpAdapterV2({
12441 instanceId,
12442 flavor: {
12443 driver: ACP_TEST_DRIVER,
@@ -12960,9 +12461,6 @@ describe("AcpAdapterV2", () => {
12461 protocolEvents,
12462 }),
12463 },
12963 - fileSystem,
12964 - idAllocator,
12965 - host,
12464 selfInvocation,
12465 });
12466 const threadId = ThreadId.make("thread-acp-concurrent-hard-teardown");
@@ -13035,10 +12533,8 @@ describe("AcpAdapterV2", () => {
12533 it.live("quarantines old-runtime callbacks after successful hard teardown", () =>
12534 Effect.gen(function* () {
12535 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
13038 - const fileSystem = yield* FileSystem.FileSystem;
12536 const idAllocator = yield* IdAllocator.IdAllocatorV2;
12537 const path = yield* Path.Path;
13041 - const host = yield* ProviderHost.ProviderHost;
12538 const selfInvocation = yield* resolveSelfInvocation();
12539 const mockAgentPath = yield* path.fromFileUrl(
12540 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -13101,8 +12597,7 @@ describe("AcpAdapterV2", () => {
12597 };
12598 },
12599 });
13104 - const adapter = makeAcpAdapterV2({
13105 - crypto: yield* Crypto.Crypto,
12600 + const adapter = yield* makeAcpAdapterV2({
12601 instanceId,
12602 flavor: {
12603 driver: ACP_TEST_DRIVER,
@@ -13119,9 +12614,6 @@ describe("AcpAdapterV2", () => {
12614 runtimeInputs.push(runtimeInput);
12615 }).pipe(Effect.andThen(makeRuntime(runtimeInput))),
12616 },
13122 - fileSystem,
13123 - idAllocator,
13124 - host,
12617 selfInvocation,
12618 testHooks: {
12619 afterHardTeardownTransportDrained: () =>
@@ -13397,18 +12889,14 @@ describe("AcpAdapterV2", () => {
12889 it.live("keeps stale deferred cleanup inert while replacement requests remain live", () =>
12890 Effect.gen(function* () {
12891 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
13400 - const fileSystem = yield* FileSystem.FileSystem;
13401 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
12892 const path = yield* Path.Path;
13403 - const host = yield* ProviderHost.ProviderHost;
12893 const selfInvocation = yield* resolveSelfInvocation();
12894 const mockAgentPath = yield* path.fromFileUrl(
12895 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
12896 );
12897 const protocolEvents = yield* Queue.bounded<EffectAcpProtocol.AcpProtocolLogEvent>(256);
12898 const instanceId = ProviderInstanceId.make("acp-test");
13410 - const adapter = makeAcpAdapterV2({
13411 - crypto: yield* Crypto.Crypto,
12899 + const adapter = yield* makeAcpAdapterV2({
12900 instanceId,
12901 flavor: {
12902 driver: ACP_TEST_DRIVER,
@@ -13425,9 +12913,6 @@ describe("AcpAdapterV2", () => {
12913 protocolEvents,
12914 }),
12915 },
13428 - fileSystem,
13429 - idAllocator,
13430 - host,
12916 selfInvocation,
12917 });
12918 const threadId = ThreadId.make("thread-acp-stale-deferred-cleanup");
@@ -13522,10 +13007,8 @@ describe("AcpAdapterV2", () => {
13007 it.live("resolves owner cancellation and concurrent resume waiters after hard teardown", () =>
13008 Effect.gen(function* () {
13009 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
13525 - const fileSystem = yield* FileSystem.FileSystem;
13010 const idAllocator = yield* IdAllocator.IdAllocatorV2;
13011 const path = yield* Path.Path;
13528 - const host = yield* ProviderHost.ProviderHost;
13012 const selfInvocation = yield* resolveSelfInvocation();
13013 const mockAgentPath = yield* path.fromFileUrl(
13014 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -13535,8 +13018,7 @@ describe("AcpAdapterV2", () => {
13018 const releaseTeardown = yield* Deferred.make<void>();
13019 let runtimeOrdinalSeen = 0;
13020 const instanceId = ProviderInstanceId.make("acp-test");
13538 - const adapter = makeAcpAdapterV2({
13539 - crypto: yield* Crypto.Crypto,
13021 + const adapter = yield* makeAcpAdapterV2({
13022 instanceId,
13023 flavor: {
13024 driver: ACP_TEST_DRIVER,
@@ -13560,9 +13042,6 @@ describe("AcpAdapterV2", () => {
13042 protocolEvents,
13043 }),
13044 },
13563 - fileSystem,
13564 - idAllocator,
13565 - host,
13045 selfInvocation,
13046 });
13047 const threadId = ThreadId.make("thread-acp-concurrent-resume-teardown");
@@ -13659,7 +13138,6 @@ describe("AcpAdapterV2", () => {
13138 const fileSystem = yield* FileSystem.FileSystem;
13139 const idAllocator = yield* IdAllocator.IdAllocatorV2;
13140 const path = yield* Path.Path;
13662 - const host = yield* ProviderHost.ProviderHost;
13141 const selfInvocation = yield* resolveSelfInvocation();
13142 const mockAgentPath = yield* path.fromFileUrl(
13143 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -13673,8 +13151,7 @@ describe("AcpAdapterV2", () => {
13151 );
13152 let cancelCalled = false;
13153 const instanceId = ProviderInstanceId.make("acp-test");
13676 - const adapter = makeAcpAdapterV2({
13677 - crypto: yield* Crypto.Crypto,
13154 + const adapter = yield* makeAcpAdapterV2({
13155 instanceId,
13156 flavor: {
13157 driver: ACP_TEST_DRIVER,
@@ -13711,9 +13188,6 @@ describe("AcpAdapterV2", () => {
13188 }).pipe(Effect.andThen(Effect.never)),
13189 }),
13190 },
13714 - fileSystem,
13715 - idAllocator,
13716 - host,
13191 selfInvocation,
13192 continuationRequests: { offer: () => Effect.void },
13193 });
@@ -13933,10 +13407,8 @@ describe("AcpAdapterV2", () => {
13407 () =>
13408 Effect.gen(function* () {
13409 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
13936 - const fileSystem = yield* FileSystem.FileSystem;
13410 const idAllocator = yield* IdAllocator.IdAllocatorV2;
13411 const path = yield* Path.Path;
13939 - const host = yield* ProviderHost.ProviderHost;
13412 const selfInvocation = yield* resolveSelfInvocation();
13413 const mockAgentPath = yield* path.fromFileUrl(
13414 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -13944,12 +13416,11 @@ describe("AcpAdapterV2", () => {
13416 const instanceId = ProviderInstanceId.make("acp-test");
13417 let subagentPhase: "spawn" | "complete" = "spawn";
13418 const promptSettled = yield* Deferred.make<void>();
13947 - const adapter = makeAcpAdapterV2({
13419 + const adapter = yield* makeAcpAdapterV2({
13420 testHooks: {
13421 afterPromptSettledWithBackgroundWork: () =>
13422 Deferred.succeed(promptSettled, undefined).pipe(Effect.asVoid),
13423 },
13952 - crypto: yield* Crypto.Crypto,
13424 instanceId,
13425 flavor: {
13426 driver: ACP_TEST_DRIVER,
@@ -13984,9 +13455,6 @@ describe("AcpAdapterV2", () => {
13455 environment: { T3_ACP_EMIT_GENERIC_TOOL_PLACEHOLDERS: "1" },
13456 }),
13457 },
13987 - fileSystem,
13988 - idAllocator,
13989 - host,
13458 selfInvocation,
13459 });
13460 const threadId = ThreadId.make("thread-acp-direct-stop-subagent-hold");
@@ -14090,7 +13558,6 @@ describe("AcpAdapterV2", () => {
13558 const fileSystem = yield* FileSystem.FileSystem;
13559 const idAllocator = yield* IdAllocator.IdAllocatorV2;
13560 const path = yield* Path.Path;
14093 - const host = yield* ProviderHost.ProviderHost;
13561 const selfInvocation = yield* resolveSelfInvocation();
13562 const mockAgentPath = yield* path.fromFileUrl(
13563 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -14103,8 +13570,7 @@ describe("AcpAdapterV2", () => {
13570 Effect.sync(() => cleanupPublishedDetachedFixture(commandPidPath)),
13571 );
13572 const instanceId = ProviderInstanceId.make("acp-test");
14106 - const adapter = makeAcpAdapterV2({
14107 - crypto: yield* Crypto.Crypto,
13573 + const adapter = yield* makeAcpAdapterV2({
13574 instanceId,
13575 flavor: {
13576 driver: ACP_TEST_DRIVER,
@@ -14133,9 +13599,6 @@ describe("AcpAdapterV2", () => {
13599 wrapCancel: (cancel) => cancel.pipe(Effect.andThen(Effect.sleep("250 millis"))),
13600 }),
13601 },
14136 - fileSystem,
14137 - idAllocator,
14138 - host,
13602 selfInvocation,
13603 });
13604 const threadId = ThreadId.make("thread-acp-restart-active-in-process");
apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts
+3 -21
@@ -4,7 +4,6 @@ import { ProviderInstanceId, ProviderSessionId, ThreadId } from "@t3tools/contra
4 import { resolveSelfInvocation } from "@t3tools/shared/nodeRuntime";
5 import * as Deferred from "effect/Deferred";
6 import * as Effect from "effect/Effect";
7 -import * as Crypto from "effect/Crypto";
7 import * as FileSystem from "effect/FileSystem";
8 import * as Layer from "effect/Layer";
9 import * as Option from "effect/Option";
@@ -188,8 +187,7 @@ describe("AcpRegistryAdapterV2", () => {
187 ACP_REGISTRY_PROVIDER,
188 );
189 const instanceId = ProviderInstanceId.make("acp-registry-mode-pick");
191 - const adapter = makeAcpRegistryAdapterV2({
192 - crypto: yield* Crypto.Crypto,
190 + const adapter = yield* makeAcpRegistryAdapterV2({
191 selfInvocation: yield* resolveSelfInvocation(),
192 instanceId,
193 settings: yield* decodeAcpRegistryAdapterSettings({
@@ -198,10 +196,7 @@ describe("AcpRegistryAdapterV2", () => {
196 }),
197 environment: {},
198 childProcessSpawner,
201 - fileSystem,
202 - idAllocator: yield* IdAllocator.IdAllocatorV2,
199 resolver: { resolve: () => Effect.die("the runtime is injected") },
204 - host: yield* ProviderHost.ProviderHost,
200 makeRuntime: makeAcpReplayRuntime({
201 transcript,
202 statusPath,
@@ -268,10 +263,7 @@ describe("AcpRegistryAdapterV2", () => {
263 it.effect("offers client terminals to Devin only and client fs to no registry agent", () =>
264 Effect.gen(function* () {
265 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
271 - const fileSystem = yield* FileSystem.FileSystem;
272 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
266 const path = yield* Path.Path;
274 - const host = yield* ProviderHost.ProviderHost;
267 const mockAgentPath = yield* path.fromFileUrl(
268 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
269 );
@@ -280,17 +272,13 @@ describe("AcpRegistryAdapterV2", () => {
272 ) {
273 let clientCapabilities: unknown;
274 const instanceId = ProviderInstanceId.make(`acp-registry-capabilities-${agentId}`);
283 - const adapter = makeAcpRegistryAdapterV2({
284 - crypto: yield* Crypto.Crypto,
275 + const adapter = yield* makeAcpRegistryAdapterV2({
276 selfInvocation: yield* resolveSelfInvocation(),
277 instanceId,
278 settings: yield* decodeAcpRegistryAdapterSettings({ agentId, authMethodId: "test" }),
279 environment: {},
280 childProcessSpawner,
290 - fileSystem,
291 - idAllocator,
281 resolver: { resolve: () => Effect.die("the runtime is injected") },
293 - host,
282 makeRuntime: (input) =>
283 Effect.gen(function* () {
284 clientCapabilities = input.clientCapabilities;
@@ -344,8 +332,6 @@ describe("AcpRegistryAdapterV2", () => {
332 it.effect("opens a real ACP child process resolved from registry configuration", () =>
333 Effect.gen(function* () {
334 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
347 - const fileSystem = yield* FileSystem.FileSystem;
348 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
335 const path = yield* Path.Path;
336 const host = yield* ProviderHost.ProviderHost;
337 const mockAgentPath = yield* path.fromFileUrl(
@@ -369,8 +355,7 @@ describe("AcpRegistryAdapterV2", () => {
355 readonly commands: AcpRegistryAvailableCommands;
356 }>();
357 const configurationPublished = yield* Deferred.make<AcpRegistryLiveConfiguration>();
372 - const adapter = makeAcpRegistryAdapterV2({
373 - crypto: yield* Crypto.Crypto,
358 + const adapter = yield* makeAcpRegistryAdapterV2({
359 selfInvocation: yield* resolveSelfInvocation(),
360 instanceId,
361 settings,
@@ -379,8 +364,6 @@ describe("AcpRegistryAdapterV2", () => {
364 T3_ACP_COMMAND_ADVERTISEMENT_DELAY_MS: "750",
365 },
366 childProcessSpawner,
382 - fileSystem,
383 - idAllocator,
367 runtimeCoordinator: {
368 withForegroundStartup: (agentId, effect) =>
369 Effect.acquireUseRelease(
@@ -428,7 +411,6 @@ describe("AcpRegistryAdapterV2", () => {
411 })),
412 ),
413 },
431 - host,
414 });
415 const threadId = ThreadId.make("thread-acp-registry-fixture");
416 const runtimePolicy = ProviderAdapterV2RuntimePolicy.make({
apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.testkit.ts
+1 -10
@@ -2,14 +2,12 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
2 import { AcpRegistrySettings } from "@t3tools/contracts";
3 import { resolveSelfInvocation } from "@t3tools/shared/nodeRuntime";
4 import * as Effect from "effect/Effect";
5 -import * as Crypto from "effect/Crypto";
5 import * as FileSystem from "effect/FileSystem";
6 import * as Layer from "effect/Layer";
7 import * as Path from "effect/Path";
8 import * as Schema from "effect/Schema";
9 import { ChildProcessSpawner } from "effect/process";
10
12 -import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
11 import { layerTestProviderHost } from "@t3tools/provider-testing/host";
12 import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
13 import * as ProviderAdapterRegistry from "../ProviderAdapterRegistry.ts";
@@ -44,9 +42,6 @@ function layerAcpRegistryProviderAdapterRegistryReplay(
42 const fileSystem = yield* FileSystem.FileSystem;
43 const path = yield* Path.Path;
44 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
47 - const crypto = yield* Crypto.Crypto;
48 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
49 - const host = yield* ProviderHost.ProviderHost;
45 const replayGate = options.replayGate;
46 const replayDir = yield* fileSystem
47 .makeTempDirectory({
@@ -57,18 +52,14 @@ function layerAcpRegistryProviderAdapterRegistryReplay(
52 const scriptPath = yield* path
53 .fromFileUrl(new URL("../../../scripts/acp-replay-agent.ts", import.meta.url))
54 .pipe(Effect.orDie);
60 - const adapter = makeAcpRegistryAdapterV2({
55 + const adapter = yield* makeAcpRegistryAdapterV2({
56 instanceId: ACP_REGISTRY_DEFAULT_INSTANCE_ID,
57 settings: REPLAY_SETTINGS,
58 environment: {},
59 childProcessSpawner,
65 - crypto,
66 - fileSystem,
67 - idAllocator,
60 resolver: {
61 resolve: () => Effect.die("ACP registry resolver must not run during replay"),
62 },
71 - host,
63 selfInvocation: yield* resolveSelfInvocation(),
64 makeRuntime: makeAcpReplayRuntime({
65 transcript,
apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.ts
+6 -20
@@ -59,13 +59,9 @@ export interface AcpRegistryAdapterV2Options {
59 readonly settings: AcpRegistrySettings;
60 readonly environment: NodeJS.ProcessEnv;
61 readonly childProcessSpawner: ChildProcessSpawner.ChildProcessSpawner["Service"];
62 - readonly crypto: Crypto.Crypto;
62 readonly selfInvocation: SelfInvocation;
64 - readonly fileSystem: FileSystem.FileSystem;
65 - readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
63 readonly resolver: Pick<AcpRegistrySupport.AcpRegistryCatalog["Service"], "resolve">;
64 readonly runtimeCoordinator?: AcpRegistryRuntimeCoordinator.AcpRegistryRuntimeCoordinator["Service"];
68 - readonly host: ProviderHost.ProviderHostShape;
65 readonly nativeLogging?: Parameters<typeof makeAcpAdapterV2>[0]["nativeLogging"];
66 readonly makeRuntime?: (
67 input: AcpAdapterV2RuntimeInput,
@@ -181,7 +177,9 @@ function makeAcpRegistryRuntime(options: AcpRegistryAdapterV2Options) {
177 });
178 }
179
184 -export function makeAcpRegistryAdapterV2(options: AcpRegistryAdapterV2Options) {
180 +export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(function* (
181 + options: AcpRegistryAdapterV2Options,
182 +) {
183 const runtimeCoordinator = options.runtimeCoordinator;
184 const registryAgentId = options.settings.source === "local" ? "" : options.settings.agentId;
185 const startupKey =
@@ -237,13 +235,9 @@ export function makeAcpRegistryAdapterV2(options: AcpRegistryAdapterV2Options) {
235 }),
236 ...(options.assertComplete === undefined ? {} : { assertComplete: options.assertComplete }),
237 };
240 - return makeAcpAdapterV2({
238 + return yield* makeAcpAdapterV2({
239 instanceId: options.instanceId,
240 flavor,
243 - crypto: options.crypto,
244 - fileSystem: options.fileSystem,
245 - idAllocator: options.idAllocator,
246 - host: options.host,
241 selfInvocation: options.selfInvocation,
242 // Per-agent exception (see the note above registerMistralVibeAcpExtensions):
243 // Devin runs commands through client terminals and has no ask mode over
@@ -259,7 +253,7 @@ export function makeAcpRegistryAdapterV2(options: AcpRegistryAdapterV2Options) {
253 : {}),
254 ...(options.nativeLogging === undefined ? {} : { nativeLogging: options.nativeLogging }),
255 });
262 -}
256 +});
257
258 export type AcpRegistryAdapterV2DriverEnv =
259 | ChildProcessSpawner.ChildProcessSpawner
@@ -283,29 +277,21 @@ export const AcpRegistryAdapterV2Driver: ProviderAdapterDriver<
277 const hostEnvironment = yield* HostProcessEnvironment;
278 const selfInvocation = yield* resolveSelfInvocation();
279 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
286 - const crypto = yield* Crypto.Crypto;
287 - const fileSystem = yield* FileSystem.FileSystem;
288 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
280 const providerEventLoggers = yield* ProviderEventLoggers.ProviderEventLoggers;
290 - const host = yield* ProviderHost.ProviderHost;
281 const makeNativeLogger = yield* makeAcpNativeLoggerFactory();
282 const resolver = yield* AcpRegistrySupport.AcpRegistryCatalog;
283 const runtimeCoordinator = yield* Effect.serviceOption(
284 AcpRegistryRuntimeCoordinator.AcpRegistryRuntimeCoordinator,
285 );
296 - return makeAcpRegistryAdapterV2({
286 + return yield* makeAcpRegistryAdapterV2({
287 instanceId: input.instanceId,
288 settings: { ...input.config, enabled: input.enabled },
289 environment: mergeProviderInstanceEnvironment(input.environment, hostEnvironment),
290 childProcessSpawner,
301 - crypto,
302 - fileSystem,
303 - idAllocator,
291 resolver,
292 ...(Option.isSome(runtimeCoordinator)
293 ? { runtimeCoordinator: runtimeCoordinator.value }
294 : {}),
308 - host,
295 selfInvocation,
296 nativeLogging: (threadId) =>
297 makeNativeLogger({
apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts
+3 -21
@@ -38,7 +38,6 @@ const flavor = makeAntigravityAcpAdapterFlavor({
38 crypto: undefined as never,
39 fileSystem: undefined as never,
40 path: undefined as never,
41 - idAllocator: undefined as never,
41 host: undefined as never,
42 selfInvocation: undefined as never,
43 makeRuntime: () => Effect.die("not spawned in this test"),
@@ -149,14 +148,9 @@ describe("AntigravityAdapterV2 client file system", () => {
148 let writeTextFile: Parameters<RuntimeService["handleWriteTextFile"]>[0] | undefined;
149 const crypto = yield* Crypto.Crypto;
150 const instanceId = ProviderInstanceId.make("antigravity-containment-test");
152 - const adapter = makeAntigravityAdapterV2({
151 + const adapter = yield* makeAntigravityAdapterV2({
152 instanceId,
154 - crypto,
153 selfInvocation: yield* resolveSelfInvocation(),
156 - fileSystem,
157 - path,
158 - idAllocator: yield* IdAllocator.IdAllocatorV2,
159 - host,
154 makeRuntime: (input) =>
155 makeAntigravityAcpRuntime({
156 ...input,
@@ -293,7 +287,6 @@ describe("AntigravityAdapterV2 workspace changes", () => {
287 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
288 const fileSystem = yield* FileSystem.FileSystem;
289 const path = yield* Path.Path;
296 - const host = yield* ProviderHost.ProviderHost;
290 const crypto = yield* Crypto.Crypto;
291 const mockAgentPath = yield* path.fromFileUrl(
292 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -301,14 +294,9 @@ describe("AntigravityAdapterV2 workspace changes", () => {
294 type RuntimeService = AcpSessionRuntime.AcpSessionRuntime["Service"];
295 let readTextFile: Parameters<RuntimeService["handleReadTextFile"]>[0] | undefined;
296 const instanceId = ProviderInstanceId.make("antigravity-workspace-change-test");
304 - const adapter = makeAntigravityAdapterV2({
297 + const adapter = yield* makeAntigravityAdapterV2({
298 instanceId,
306 - crypto,
299 selfInvocation: yield* resolveSelfInvocation(),
308 - fileSystem,
309 - path,
310 - idAllocator: yield* IdAllocator.IdAllocatorV2,
311 - host,
300 makeRuntime: (input) =>
301 makeAntigravityAcpRuntime({
302 ...input,
@@ -430,7 +418,6 @@ describe("AntigravityAdapterV2 client file system under restrictive policies", (
418 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
419 const fileSystem = yield* FileSystem.FileSystem;
420 const path = yield* Path.Path;
433 - const host = yield* ProviderHost.ProviderHost;
421 const crypto = yield* Crypto.Crypto;
422 const mockAgentPath = yield* path.fromFileUrl(
423 new URL("../../../scripts/acp-mock-agent.ts", import.meta.url),
@@ -451,14 +438,9 @@ describe("AntigravityAdapterV2 client file system under restrictive policies", (
438 let readTextFile: Parameters<RuntimeService["handleReadTextFile"]>[0] | undefined;
439 let writeTextFile: Parameters<RuntimeService["handleWriteTextFile"]>[0] | undefined;
440 const instanceId = ProviderInstanceId.make(`antigravity-restrictive-${policy.runtimeMode}`);
454 - const adapter = makeAntigravityAdapterV2({
441 + const adapter = yield* makeAntigravityAdapterV2({
442 instanceId,
456 - crypto,
443 selfInvocation: yield* resolveSelfInvocation(),
458 - fileSystem,
459 - path,
460 - idAllocator: yield* IdAllocator.IdAllocatorV2,
461 - host,
444 makeRuntime: (input) =>
445 makeAntigravityAcpRuntime({
446 ...input,
apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts
+23 -17
@@ -8,8 +8,8 @@ import {
8 import type { SelfInvocation } from "@t3tools/shared/nodeRuntime";
9 import * as Crypto from "effect/Crypto";
10 import * as Effect from "effect/Effect";
11 -import type * as FileSystem from "effect/FileSystem";
12 -import type * as Path from "effect/Path";
11 +import * as FileSystem from "effect/FileSystem";
12 +import * as Path from "effect/Path";
13 import * as Exit from "effect/Exit";
14 import * as Scope from "effect/Scope";
15 import * as EffectAcpErrors from "effect-acp/errors";
@@ -34,7 +34,6 @@ import {
34 makeAntigravityUserInputResponse,
35 normalizeAntigravityToolCall,
36 } from "../../provider/acp/AntigravityProtocol.ts";
37 -import type { IdAllocatorV2 } from "@t3tools/provider-core/server/IdAllocator";
37 import {
38 AcpProviderCapabilitiesV2,
39 makeAcpAdapterV2,
@@ -63,12 +62,7 @@ const AntigravityProviderCapabilitiesV2 = {
62
63 export interface AntigravityAdapterV2Options {
64 readonly instanceId: ProviderInstanceId;
66 - readonly crypto: Crypto.Crypto;
65 readonly selfInvocation: SelfInvocation;
68 - readonly fileSystem: FileSystem.FileSystem;
69 - readonly path: Path.Path;
70 - readonly idAllocator: IdAllocatorV2["Service"];
71 - readonly host: ProviderHost.ProviderHostShape;
66 /** Spawns the official agent with the instance's Google profile. */
67 readonly makeRuntime: (
68 input: Omit<AntigravityAcpRuntimeInput, "spawn" | "childProcessSpawner">,
@@ -118,8 +112,16 @@ const extractAntigravitySubagentUpdate: NonNullable<AcpAdapterV2Flavor["extractS
112 };
113 };
114
115 +/** The services the Antigravity flavor runs its runtime and session files with. */
116 +interface AntigravityFlavorServices {
117 + readonly crypto: Crypto.Crypto;
118 + readonly fileSystem: FileSystem.FileSystem;
119 + readonly path: Path.Path;
120 + readonly host: ProviderHost.ProviderHost["Service"];
121 +}
122 +
123 export function makeAntigravityAcpAdapterFlavor(
122 - options: AntigravityAdapterV2Options,
124 + options: AntigravityAdapterV2Options & AntigravityFlavorServices,
125 ): AcpAdapterV2Flavor {
126 // The attachments dir grant lets the agent read pasted files at the paths
127 // the turn text references. It is a leaf directory of uploads. A session
@@ -224,18 +226,22 @@ export function makeAntigravityAcpAdapterFlavor(
226 };
227 }
228
227 -export function makeAntigravityAdapterV2(options: AntigravityAdapterV2Options) {
228 - return makeAcpAdapterV2({
229 +export const makeAntigravityAdapterV2 = Effect.fn("makeAntigravityAdapterV2")(function* (
230 + options: AntigravityAdapterV2Options,
231 +) {
232 + const services: AntigravityFlavorServices = {
233 + crypto: yield* Crypto.Crypto,
234 + fileSystem: yield* FileSystem.FileSystem,
235 + path: yield* Path.Path,
236 + host: yield* ProviderHost.ProviderHost,
237 + };
238 + return yield* makeAcpAdapterV2({
239 instanceId: options.instanceId,
230 - flavor: makeAntigravityAcpAdapterFlavor(options),
231 - crypto: options.crypto,
232 - fileSystem: options.fileSystem,
233 - idAllocator: options.idAllocator,
234 - host: options.host,
240 + flavor: makeAntigravityAcpAdapterFlavor({ ...options, ...services }),
241 selfInvocation: options.selfInvocation,
242 ...(options.nativeLogging === undefined ? {} : { nativeLogging: options.nativeLogging }),
243 ...(options.continuationRequests === undefined
244 ? {}
245 : { continuationRequests: options.continuationRequests }),
246 });
241 -}
247 +});
apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts
+6 -15
@@ -12,17 +12,14 @@ import { resolveSelfInvocation } from "@t3tools/shared/nodeRuntime";
12 import * as EffectAcpErrors from "effect-acp/errors";
13 import { xAiRateLimitedErrorCode } from "@t3tools/provider-grok/testing";
14 import { assert, describe, it } from "@effect/vitest";
15 -import * as Crypto from "effect/Crypto";
15 import * as DateTime from "effect/DateTime";
16 import * as Effect from "effect/Effect";
18 -import * as FileSystem from "effect/FileSystem";
17 import * as Layer from "effect/Layer";
18 import * as PlatformError from "effect/PlatformError";
19 import * as Schema from "effect/Schema";
20 import { ChildProcessSpawner } from "effect/process";
21 import type * as EffectAcpSchema from "effect-acp/compat";
22
25 -import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
23 import { layerTestProviderHost } from "@t3tools/provider-testing/host";
24 import * as ProjectStore from "../ProjectStore.ts";
25 import { buildInitialGrokProviderSnapshot } from "@t3tools/provider-grok/testing";
@@ -42,7 +39,6 @@ import {
39 makeGrokAcpAdapterFlavor,
40 makeGrokAdapterV2,
41 GrokProviderCapabilitiesV2,
45 - type GrokAdapterV2Options,
42 } from "@t3tools/provider-grok/testing";
43
44 const LAUNCH_TEST_GROK_SETTINGS = Schema.decodeSync(GrokSettings)({
@@ -99,7 +95,7 @@ describe("GrokAdapterV2 capabilities", () => {
95 it("preserves Grok's rate-limit stop and distinguishes other prompt failures", () => {
96 const flavor = makeGrokAcpAdapterFlavor({
97 makeRuntime: () => Effect.never,
102 - } as unknown as GrokAdapterV2Options);
98 + } as unknown as Parameters<typeof makeGrokAcpAdapterFlavor>[0]);
99 const limit = flavor.promptFailure?.(
100 new EffectAcpErrors.AcpRequestError({
101 code: xAiRateLimitedErrorCode,
@@ -127,7 +123,7 @@ describe("GrokAdapterV2 capabilities", () => {
123 it("wires hard Stop teardown but soft non-Stop interrupts in the constructor flavor", () => {
124 const flavor = makeGrokAcpAdapterFlavor({
125 makeRuntime: () => Effect.never,
130 - } as unknown as GrokAdapterV2Options);
126 + } as unknown as Parameters<typeof makeGrokAcpAdapterFlavor>[0]);
127
128 assert.isFalse(flavor.interruptPromptOnCancel);
129 // User Stop (requestRuntimeRestart) keeps the hard process-group kill and
@@ -144,7 +140,7 @@ describe("GrokAdapterV2 capabilities", () => {
140 it("terminalizes only foreground tools under the actual Grok flavor", () => {
141 const flavor = makeGrokAcpAdapterFlavor({
142 makeRuntime: () => Effect.never,
147 - } as unknown as GrokAdapterV2Options);
143 + } as unknown as Parameters<typeof makeGrokAcpAdapterFlavor>[0]);
144 const foreground = {
145 toolCallId: "foreground-1",
146 title: "Terminal",
@@ -289,7 +285,7 @@ describe("ACP permission policy", () => {
285 describe("Grok permission prompts", () => {
286 const disposition = makeGrokAcpAdapterFlavor({
287 makeRuntime: () => Effect.never,
292 - } as unknown as GrokAdapterV2Options).permissionDisposition;
288 + } as unknown as Parameters<typeof makeGrokAcpAdapterFlavor>[0]).permissionDisposition;
289
290 // grok_auto_blocked_command replays Auto end to end. When an explicit policy
291 // launches Grok asking instead, T3's policy still answers its prompts.
@@ -332,18 +328,13 @@ describe("Grok launch permission mode", () => {
328 );
329 });
330 const instanceId = ProviderInstanceId.make("grok-launch-test");
335 - const adapter = makeGrokAdapterV2({
331 + const adapter = yield* makeGrokAdapterV2({
332 instanceId,
333 settings: LAUNCH_TEST_GROK_SETTINGS,
334 environment: {},
335 hostPlatform: "darwin",
340 - childProcessSpawner,
341 - crypto: yield* Crypto.Crypto,
342 - fileSystem: yield* FileSystem.FileSystem,
343 - idAllocator: yield* IdAllocator.IdAllocatorV2,
344 - host: yield* ProviderHost.ProviderHost,
336 selfInvocation: yield* resolveSelfInvocation(),
346 - });
337 + }).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, childProcessSpawner));
338 yield* adapter
339 .openSession({
340 threadId: ThreadId.make("grok-launch-test"),
apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.testkit.ts
+1 -11
@@ -1,7 +1,6 @@
1 import * as NodeServices from "@effect/platform-node/NodeServices";
2 import { GrokSettings } from "@t3tools/provider-grok/settings";
3 import * as Effect from "effect/Effect";
4 -import * as Crypto from "effect/Crypto";
4 import * as FileSystem from "effect/FileSystem";
5 import * as Layer from "effect/Layer";
6 import * as Path from "effect/Path";
@@ -10,7 +9,6 @@ import { ChildProcessSpawner } from "effect/process";
9 import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
10 import { resolveSelfInvocation } from "@t3tools/shared/nodeRuntime";
11
13 -import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
12 import { layerTestProviderHost } from "@t3tools/provider-testing/host";
13 import { GROK_ACP_CANCEL_META, GROK_ACP_INITIALIZE_META } from "@t3tools/provider-grok/testing";
14 import { makeXAiPromptCompletionRuntime } from "@t3tools/provider-grok/testing";
@@ -45,10 +43,7 @@ function layerGrokProviderAdapterRegistryReplay(
43 const fileSystem = yield* FileSystem.FileSystem;
44 const path = yield* Path.Path;
45 const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
48 - const crypto = yield* Crypto.Crypto;
46 const hostPlatform = yield* HostProcessPlatform;
50 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
51 - const host = yield* ProviderHost.ProviderHost;
47 // Same queue the continuation worker drains when the fixture runs it.
48 const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
49 const replayGate = options.replayGate;
@@ -61,16 +56,11 @@ function layerGrokProviderAdapterRegistryReplay(
56 const scriptPath = yield* path
57 .fromFileUrl(new URL("../../../scripts/acp-replay-agent.ts", import.meta.url))
58 .pipe(Effect.orDie);
64 - const adapter = makeGrokAdapterV2({
59 + const adapter = yield* makeGrokAdapterV2({
60 instanceId: GROK_DEFAULT_INSTANCE_ID,
61 settings: DEFAULT_GROK_SETTINGS,
62 environment: {},
63 hostPlatform,
69 - childProcessSpawner,
70 - crypto,
71 - fileSystem,
72 - idAllocator,
73 - host,
64 selfInvocation: yield* resolveSelfInvocation(),
65 // Same wrapping as makeGrokAcpRuntime: client type and Ctrl+C cancel
66 // metadata and the x.ai prompt-completion race, so replay sends what
apps/server/src/orchestration-v2/Adapters/MuseAdapterV2.testkit.ts
+1 -6
@@ -24,11 +24,9 @@ import {
24 } from "@t3tools/contracts";
25 import { MuseSettings } from "@t3tools/provider-muse/settings";
26 import * as Effect from "effect/Effect";
27 -import * as FileSystem from "effect/FileSystem";
27 import * as Layer from "effect/Layer";
28 import * as Schema from "effect/Schema";
29
31 -import { ProviderHost } from "@t3tools/provider-core/server/ProviderHost";
30 import { layerTestProviderHost } from "@t3tools/provider-testing/host";
31 import {
32 museInitializeParams,
@@ -449,13 +447,10 @@ export function layer(input: {
447 return ProviderAdapterRegistry.layerFromAdaptersEffect(
448 Effect.gen(function* () {
449 return [
452 - makeMuseAdapterV2({
450 + yield* makeMuseAdapterV2({
451 instanceId: ProviderInstanceId.make(MUSE_PROVIDER_KIND),
452 settings: DEFAULT_MUSE_SETTINGS,
453 environment: input.environment ?? {},
456 - idAllocator: yield* IdAllocator.IdAllocatorV2,
457 - host: yield* ProviderHost,
458 - fileSystem: yield* FileSystem.FileSystem,
454 createHost: input.createHost,
455 // Same queue the continuation worker drains when the fixture runs it.
456 continuationRequests: yield* ProviderContinuationRequests.ProviderContinuationRequests,
apps/server/src/provider/Drivers/AntigravityDriver.ts
+1 -7
@@ -94,7 +94,6 @@ export const AntigravityDriver: ProviderDriver<AntigravitySettings, AntigravityD
94 const installation = yield* AntigravityInstallation.AntigravityInstallation;
95 const loggers = yield* ProviderEventLoggers.ProviderEventLoggers;
96 const modelManifest = yield* ModelManifest.ModelManifest;
97 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
97 const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
98 const makeNativeLogger = yield* makeAcpNativeLoggerFactory();
99 const settings = { ...config, enabled } satisfies AntigravitySettings;
@@ -397,13 +396,8 @@ export const AntigravityDriver: ProviderDriver<AntigravitySettings, AntigravityD
396 const defaultModel = modelManifest.current.pipe(
397 Effect.map((manifest) => ModelManifest.manifestDefaultModel(manifest, DRIVER)),
398 );
400 - const orchestrationAdapter = makeAntigravityAdapterV2({
399 + const orchestrationAdapter = yield* makeAntigravityAdapterV2({
400 instanceId,
402 - crypto,
403 - fileSystem,
404 - path,
405 - idAllocator,
406 - host,
401 selfInvocation,
402 makeRuntime,
403 withProcess: authFlow.withProcess,
packages/provider-acp/src/server/adapter.ts
+12 -13
@@ -1,5 +1,4 @@
1 // @effect-diagnostics nodeBuiltinImport:off
2 -import * as NodePath from "node:path";
2
3 import {
4 type ChatAttachment,
@@ -57,7 +56,7 @@ import type * as EffectAcpProtocol from "effect-acp/protocol";
56 import type * as EffectAcpSchema from "effect-acp/compat";
57
58 import { formatReadToolLabel, formatSearchToolLabel } from "@t3tools/shared/toolActivity";
60 -import type * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
59 +import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
60 import { makeAcpMcpOverAcpBridge, type AcpMcpOverAcpBridge } from "./mcpOverAcpBridge.ts";
61 import { mcpToolPresentation } from "@t3tools/provider-core/server/mcpToolPresentation";
62 import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
@@ -480,10 +479,6 @@ export interface AcpAdapterV2SubagentUpdate {
479 export interface AcpAdapterV2Options {
480 readonly instanceId: ProviderInstanceId;
481 readonly flavor: AcpAdapterV2Flavor;
483 - readonly crypto: Crypto.Crypto;
484 - readonly fileSystem: FileSystem.FileSystem;
485 - readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
486 - readonly host: ProviderHost.ProviderHostShape;
482 /** How agents spawn this install's `acp-mcp-bridge`; see `resolveSelfInvocation`. */
483 readonly selfInvocation: SelfInvocation;
484 /**
@@ -1490,10 +1485,14 @@ function shouldPersistToolUpdate(
1485 return persist;
1486 }
1487
1493 -export function makeAcpAdapterV2(
1488 +export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
1489 options: AcpAdapterV2Options,
1495 -): ProviderAdapter.ProviderAdapterV2Shape {
1496 - const { flavor, fileSystem, idAllocator, host, selfInvocation: self } = options;
1490 +) {
1491 + const crypto = yield* Crypto.Crypto;
1492 + const fileSystem = yield* FileSystem.FileSystem;
1493 + const idAllocator = yield* IdAllocator.IdAllocatorV2;
1494 + const host = yield* ProviderHost.ProviderHost;
1495 + const { flavor, selfInvocation: self } = options;
1496 const driver = flavor.driver;
1497 const continuationRequests = options.continuationRequests;
1498 const postSettleContinuationEnabled =
@@ -5999,7 +5998,7 @@ export function makeAcpAdapterV2(
5998 const mcpBridge = yield* makeAcpMcpOverAcpBridge({
5999 endpoint: mcpContext.endpoint,
6000 authorization: mcpContext.authorization,
6002 - allocateConnectionId: options.crypto.randomUUIDv4.pipe(Effect.orDie),
6001 + allocateConnectionId: crypto.randomUUIDv4.pipe(Effect.orDie),
6002 });
6003 yield* Scope.addFinalizer(scope, mcpBridge.dispose);
6004 return mcpBridge;
@@ -6019,7 +6018,7 @@ export function makeAcpAdapterV2(
6018 .makeRuntime(makeRuntimeInput(runtimeGeneration, threadId, resumeSessionId))
6019 .pipe(
6020 Effect.provideService(Scope.Scope, runtimeScope),
6022 - Effect.provideService(Crypto.Crypto, options.crypto),
6021 + Effect.provideService(Crypto.Crypto, crypto),
6022 );
6023 });
6024
@@ -6096,7 +6095,7 @@ export function makeAcpAdapterV2(
6095 )
6096 .pipe(
6097 Effect.provideService(Scope.Scope, replacementScope),
6099 - Effect.provideService(Crypto.Crypto, options.crypto),
6098 + Effect.provideService(Crypto.Crypto, crypto),
6099 );
6100 // Session setup may publish commands before it returns. Buffer those
6101 // notifications, but do not expose request or extension handlers
@@ -8049,6 +8048,6 @@ export function makeAcpAdapterV2(
8048 ),
8049 ),
8050 });
8052 -}
8051 +});
8052
8053 export type AcpAdapterV2Env = FileSystem.FileSystem | IdAllocator.IdAllocatorV2;
packages/provider-core/src/server/ProviderHost.ts
+2 -2
@@ -45,7 +45,7 @@ export interface ProviderCredentials {
45 readonly remove: Effect.Effect<void, ProviderCredentialError>;
46 }
47
48 -export interface ProviderHostShape {
48 +interface ProviderHostService {
49 readonly paths: ProviderHostPaths;
50 readonly settings: {
51 readonly get: Effect.Effect<ServerSettings, ServerSettingsError>;
@@ -68,6 +68,6 @@ export interface ProviderHostShape {
68 ) => Effect.Effect<ProviderCredentials>;
69 }
70
71 -export class ProviderHost extends Context.Service<ProviderHost, ProviderHostShape>()(
71 +export class ProviderHost extends Context.Service<ProviderHost, ProviderHostService>()(
72 "@t3tools/provider-core/server/ProviderHost",
73 ) {}
packages/provider-core/src/server/managedProvider.test.ts
+2 -2
@@ -99,7 +99,7 @@ const refreshedSnapshotSecond: ServerProvider = {
99 /** A host whose settings never change and whose background demand is fixed. */
100 function layerProviderHost(input: {
101 readonly runBackgroundWork: boolean;
102 - readonly settings?: Pick<ProviderHost.ProviderHostShape, "settings">["settings"];
102 + readonly settings?: Pick<ProviderHost.ProviderHost["Service"], "settings">["settings"];
103 }) {
104 return Layer.succeed(
105 ProviderHost.ProviderHost,
@@ -283,7 +283,7 @@ describe("makeManagedServerProvider", () => {
283 };
284 const serverSettingsRef = yield* Ref.make(initialServerSettings);
285 const serverSettingsChanges = yield* PubSub.unbounded<typeof initialServerSettings>();
286 - const hostSettings: ProviderHost.ProviderHostShape["settings"] = {
286 + const hostSettings: ProviderHost.ProviderHost["Service"]["settings"] = {
287 get: Ref.get(serverSettingsRef),
288 changes: Stream.empty,
289 subscribe: PubSub.subscribe(serverSettingsChanges).pipe(
packages/provider-core/src/server/snapshotSettings.ts
+1 -1
@@ -29,7 +29,7 @@ export function haveProviderSnapshotSettingsChanged<Settings>(
29
30 export function makeProviderSnapshotSettingsSource<Settings>(
31 provider: Settings,
32 - settings: ProviderHost.ProviderHostShape["settings"],
32 + settings: ProviderHost.ProviderHost["Service"]["settings"],
33 ): {
34 readonly getSettings: Effect.Effect<ProviderSnapshotSettings<Settings>, ServerSettingsError>;
35 readonly streamSettings: Stream.Stream<ProviderSnapshotSettings<Settings>>;
packages/provider-cursor/src/server/adapter.test.ts
+18 -33
@@ -22,7 +22,6 @@ import * as Path from "effect/Path";
22 import * as Schema from "effect/Schema";
23 import * as Stream from "effect/Stream";
24
25 -import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
25 import { layerTestProviderHost } from "@t3tools/provider-testing/host";
26 import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
27 import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
@@ -51,7 +50,6 @@ describe("CursorAdapterV2", () => {
50 ({ status, model, lateModel }) =>
51 Effect.gen(function* () {
52 const fileSystem = yield* FileSystem.FileSystem;
54 - const path = yield* Path.Path;
53 const workspace = yield* fileSystem.makeTempDirectoryScoped({
54 prefix: "cursor-v2-lifecycle-",
55 });
@@ -63,17 +61,12 @@ describe("CursorAdapterV2", () => {
61 interactionMode: "default",
62 cwd: workspace,
63 });
66 - const adapter = makeCursorAdapterV2({
64 + const adapter = yield* makeCursorAdapterV2({
65 instanceId,
66 settings: yield* decodeCursorSettings({}),
67 environment: { HOME: workspace },
70 - fileSystem,
71 - path,
72 - idAllocator: yield* IdAllocator.IdAllocatorV2,
73 - host: yield* ProviderHost.ProviderHost.pipe(
74 - Effect.provide(layerTestProviderHost({ cwd: workspace })),
75 - ),
76 - runner: {
68 + }).pipe(
69 + Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, {
70 assertComplete: Effect.void,
71 open: () =>
72 Effect.succeed({
@@ -131,8 +124,9 @@ describe("CursorAdapterV2", () => {
124 };
125 }),
126 }),
134 - },
135 - });
127 + }),
128 + Effect.provide(layerTestProviderHost({ cwd: workspace })),
129 + );
130 const runtime = yield* adapter.openSession({
131 threadId,
132 providerSessionId: ProviderSessionId.make("cursor-lifecycle-session"),
@@ -211,7 +205,6 @@ describe("CursorAdapterV2", () => {
205 it.effect("fails standalone SDK transport diagnostics and sends compaction as /compress", () =>
206 Effect.gen(function* () {
207 const fileSystem = yield* FileSystem.FileSystem;
214 - const path = yield* Path.Path;
208 const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-v2-errors-" });
209 const sentMessages: Array<string> = [];
210 let sendCalls = 0;
@@ -223,17 +216,12 @@ describe("CursorAdapterV2", () => {
216 interactionMode: "default",
217 cwd: workspace,
218 });
226 - const adapter = makeCursorAdapterV2({
219 + const adapter = yield* makeCursorAdapterV2({
220 instanceId,
221 settings: yield* decodeCursorSettings({}),
222 environment: { HOME: workspace },
230 - fileSystem,
231 - path,
232 - idAllocator: yield* IdAllocator.IdAllocatorV2,
233 - host: yield* ProviderHost.ProviderHost.pipe(
234 - Effect.provide(layerTestProviderHost({ cwd: workspace })),
235 - ),
236 - runner: {
223 + }).pipe(
224 + Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, {
225 assertComplete: Effect.void,
226 open: () =>
227 Effect.succeed({
@@ -264,8 +252,9 @@ describe("CursorAdapterV2", () => {
252 };
253 }),
254 }),
267 - },
268 - });
255 + }),
256 + Effect.provide(layerTestProviderHost({ cwd: workspace })),
257 + );
258 const runtime = yield* adapter.openSession({
259 threadId,
260 providerSessionId: ProviderSessionId.make("cursor-error-session"),
@@ -564,17 +553,12 @@ describe("CursorAdapterV2", () => {
553 },
554 },
555 ];
567 - const adapter = makeCursorAdapterV2({
556 + const adapter = yield* makeCursorAdapterV2({
557 instanceId,
558 settings: yield* decodeCursorSettings({}),
559 environment: { HOME: workspace },
571 - fileSystem,
572 - path,
573 - idAllocator: yield* IdAllocator.IdAllocatorV2,
574 - host: yield* ProviderHost.ProviderHost.pipe(
575 - Effect.provide(layerTestProviderHost({ cwd: workspace })),
576 - ),
577 - runner: {
560 + }).pipe(
561 + Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, {
562 assertComplete: Effect.void,
563 open: () =>
564 Effect.succeed({
@@ -602,8 +586,9 @@ describe("CursorAdapterV2", () => {
586 };
587 }),
588 }),
605 - },
606 - });
589 + }),
590 + Effect.provide(layerTestProviderHost({ cwd: workspace })),
591 + );
592 const runtime = yield* adapter.openSession({
593 threadId,
594 providerSessionId: ProviderSessionId.make("cursor-search-session"),
packages/provider-cursor/src/server/adapter.ts
+12 -32
@@ -844,17 +844,17 @@ export interface CursorAdapterV2Options {
844 readonly instanceId: ProviderInstanceId;
845 readonly settings: CursorSettings;
846 readonly environment: NodeJS.ProcessEnv;
847 - readonly fileSystem: FileSystem.FileSystem;
848 - readonly path: Path.Path;
849 - readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
850 - readonly runner: CursorAgentSdk.CursorAgentSdkRunnerShape;
851 - readonly host: ProviderHost.ProviderHostShape;
847 }
848
854 -export function makeCursorAdapterV2(
855 - adapterOptions: CursorAdapterV2Options,
856 -): ProviderAdapter.ProviderAdapterV2Shape {
857 - const { fileSystem, path, idAllocator, runner, host } = adapterOptions;
849 +export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
850 + options: CursorAdapterV2Options,
851 +) {
852 + const fileSystem = yield* FileSystem.FileSystem;
853 + const path = yield* Path.Path;
854 + const idAllocator = yield* IdAllocator.IdAllocatorV2;
855 + const runner = yield* CursorAgentSdk.CursorAgentSdkRunner;
856 + const host = yield* ProviderHost.ProviderHost;
857 + const adapterOptions = options;
858 const apiKey = adapterOptions.environment.CURSOR_API_KEY?.trim() || undefined;
859
860 return ProviderAdapter.ProviderAdapterV2.of({
@@ -2596,7 +2596,7 @@ export function makeCursorAdapterV2(
2596 ),
2597 ),
2598 });
2599 -}
2599 +});
2600
2601 export type CursorAdapterV2DriverEnv =
2602 | CursorAgentSdk.CursorAgentSdkRunner
@@ -2615,23 +2615,13 @@ export const CursorAdapterV2Driver: ProviderAdapterDriver<
2615 create: Effect.fn("CursorAdapterV2Driver.create")(
2616 function* (input: ProviderAdapterDriverCreateInput<CursorSettings>) {
2617 const hostEnvironment = yield* HostProcessEnvironment;
2618 - const fileSystem = yield* FileSystem.FileSystem;
2619 - const path = yield* Path.Path;
2620 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
2621 - const runner = yield* CursorAgentSdk.CursorAgentSdkRunner;
2622 - const host = yield* ProviderHost.ProviderHost;
2623 - return makeCursorAdapterV2({
2618 + return yield* makeCursorAdapterV2({
2619 instanceId: input.instanceId,
2620 settings: {
2621 ...input.config,
2622 enabled: input.enabled,
2623 },
2624 environment: mergeProviderInstanceEnvironment(input.environment, hostEnvironment),
2630 - fileSystem,
2631 - path,
2632 - idAllocator,
2633 - runner,
2634 - host,
2625 });
2626 },
2627 (effect, input) =>
@@ -2661,20 +2651,10 @@ const layer: Layer.Layer<
2651 ProviderAdapter.ProviderAdapterV2,
2652 Effect.gen(function* () {
2653 const hostEnvironment = yield* HostProcessEnvironment;
2664 - const fileSystem = yield* FileSystem.FileSystem;
2665 - const path = yield* Path.Path;
2666 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
2667 - const runner = yield* CursorAgentSdk.CursorAgentSdkRunner;
2668 - const host = yield* ProviderHost.ProviderHost;
2669 - return makeCursorAdapterV2({
2654 + return yield* makeCursorAdapterV2({
2655 instanceId: CURSOR_DEFAULT_INSTANCE_ID,
2656 settings: DEFAULT_CURSOR_SETTINGS,
2657 environment: hostEnvironment,
2673 - fileSystem,
2674 - path,
2675 - idAllocator,
2676 - runner,
2677 - host,
2658 });
2659 }),
2660 );
packages/provider-cursor/src/server/credentialStore.test.ts
-1
@@ -4,7 +4,6 @@ import { ProviderInstanceId } from "@t3tools/contracts";
4 import * as Effect from "effect/Effect";
5 import * as FileSystem from "effect/FileSystem";
6 import * as Path from "effect/Path";
7 -import * as Option from "effect/Option";
7
8 import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
9 import { layerTestProviderHost } from "@t3tools/provider-testing/host";
packages/provider-grok/src/server/adapter.ts
+15 -36
@@ -112,12 +112,7 @@ export interface GrokAdapterV2Options {
112 readonly settings: GrokSettings;
113 readonly environment: NodeJS.ProcessEnv;
114 readonly hostPlatform: NodeJS.Platform;
115 - readonly childProcessSpawner: ChildProcessSpawner.ChildProcessSpawner["Service"];
116 - readonly crypto: Crypto.Crypto;
115 readonly selfInvocation: SelfInvocation;
118 - readonly fileSystem: FileSystem.FileSystem;
119 - readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
120 - readonly host: ProviderHost.ProviderHostShape;
116 readonly nativeLogging?: Parameters<typeof makeAcpAdapterV2>[0]["nativeLogging"];
117 readonly continuationRequests?: Parameters<typeof makeAcpAdapterV2>[0]["continuationRequests"];
118 readonly testHooks?: Parameters<typeof makeAcpAdapterV2>[0]["testHooks"];
@@ -229,7 +224,12 @@ export function grokLaunchRuntimeMode(
224 : "approval-required";
225 }
226
232 -export function makeGrokAcpAdapterFlavor(options: GrokAdapterV2Options): AcpAdapterV2Flavor {
227 +/** The flavor runs Grok's launcher through the adapter's spawner. */
228 +export function makeGrokAcpAdapterFlavor(
229 + options: GrokAdapterV2Options & {
230 + readonly childProcessSpawner: ChildProcessSpawner.ChildProcessSpawner["Service"];
231 + },
232 +): AcpAdapterV2Flavor {
233 return {
234 driver: GROK_PROVIDER,
235 runtimeHarness: "Grok",
@@ -329,15 +329,14 @@ export function makeGrokAcpAdapterFlavor(options: GrokAdapterV2Options): AcpAdap
329 };
330 }
331
332 -export function makeGrokAdapterV2(options: GrokAdapterV2Options) {
333 - const flavor = makeGrokAcpAdapterFlavor(options);
334 - return makeAcpAdapterV2({
332 +export const makeGrokAdapterV2 = Effect.fn("makeGrokAdapterV2")(function* (
333 + options: GrokAdapterV2Options,
334 +) {
335 + const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
336 + const flavor = makeGrokAcpAdapterFlavor({ ...options, childProcessSpawner });
337 + return yield* makeAcpAdapterV2({
338 instanceId: options.instanceId,
339 flavor,
337 - crypto: options.crypto,
338 - fileSystem: options.fileSystem,
339 - idAllocator: options.idAllocator,
340 - host: options.host,
340 selfInvocation: options.selfInvocation,
341 ...(options.nativeLogging === undefined ? {} : { nativeLogging: options.nativeLogging }),
342 ...(options.continuationRequests === undefined
@@ -345,7 +344,7 @@ export function makeGrokAdapterV2(options: GrokAdapterV2Options) {
344 : { continuationRequests: options.continuationRequests }),
345 ...(options.testHooks === undefined ? {} : { testHooks: options.testHooks }),
346 });
348 -}
347 +});
348
349 export type GrokAdapterV2DriverEnv =
350 | ChildProcessSpawner.ChildProcessSpawner
@@ -365,24 +364,14 @@ export const GrokAdapterV2Driver: ProviderAdapterDriver<GrokSettings, GrokAdapte
364 const hostEnvironment = yield* HostProcessEnvironment;
365 const hostPlatform = yield* HostProcessPlatform;
366 const selfInvocation = yield* resolveSelfInvocation();
368 - const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
369 - const crypto = yield* Crypto.Crypto;
370 - const fileSystem = yield* FileSystem.FileSystem;
371 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
367 const providerEventLoggers = yield* ProviderEventLoggers.ProviderEventLoggers;
373 - const host = yield* ProviderHost.ProviderHost;
368 const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
369 const makeNativeLogger = yield* makeAcpNativeLoggerFactory();
376 - return makeGrokAdapterV2({
370 + return yield* makeGrokAdapterV2({
371 instanceId: input.instanceId,
372 settings: { ...input.config, enabled: input.enabled },
373 environment: mergeProviderInstanceEnvironment(input.environment, hostEnvironment),
374 hostPlatform,
381 - childProcessSpawner,
382 - crypto,
383 - fileSystem,
384 - idAllocator,
385 - host,
375 selfInvocation,
376 continuationRequests,
377 nativeLogging: (threadId) =>
@@ -424,24 +413,14 @@ const layer: Layer.Layer<
413 const hostEnvironment = yield* HostProcessEnvironment;
414 const hostPlatform = yield* HostProcessPlatform;
415 const selfInvocation = yield* resolveSelfInvocation();
427 - const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
428 - const crypto = yield* Crypto.Crypto;
429 - const fileSystem = yield* FileSystem.FileSystem;
430 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
416 const providerEventLoggers = yield* ProviderEventLoggers.ProviderEventLoggers;
432 - const host = yield* ProviderHost.ProviderHost;
417 const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
418 const makeNativeLogger = yield* makeAcpNativeLoggerFactory();
435 - return makeGrokAdapterV2({
419 + return yield* makeGrokAdapterV2({
420 instanceId: GROK_DEFAULT_INSTANCE_ID,
421 settings: DEFAULT_GROK_SETTINGS,
422 environment: hostEnvironment,
423 hostPlatform,
440 - childProcessSpawner,
441 - crypto,
442 - fileSystem,
443 - idAllocator,
444 - host,
424 selfInvocation,
425 continuationRequests,
426 nativeLogging: (threadId) =>
packages/provider-muse/src/server/adapter.test.ts
+2 -10
@@ -24,14 +24,12 @@ import * as Deferred from "effect/Deferred";
24 import * as Effect from "effect/Effect";
25 import * as Option from "effect/Option";
26 import type * as Exit from "effect/Exit";
27 -import * as FileSystem from "effect/FileSystem";
27 import * as Fiber from "effect/Fiber";
28 import * as Layer from "effect/Layer";
29 import * as Queue from "effect/Queue";
30 import * as Schema from "effect/Schema";
31 import * as Stream from "effect/Stream";
32
34 -import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
33 import { layerTestProviderHost } from "@t3tools/provider-testing/host";
34 import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
35 import type { MuseItem } from "./protocol.ts";
@@ -195,13 +193,10 @@ const makeHarness = Effect.fnUntraced(function* (
193 > = {},
194 ) {
195 let hostCount = 0;
198 - const adapter = makeMuseAdapterV2({
196 + const adapter = yield* makeMuseAdapterV2({
197 instanceId,
198 settings: museSettings,
199 environment: { PATH: "/fake/bin" },
202 - idAllocator: yield* IdAllocator.IdAllocatorV2,
203 - host: yield* ProviderHost.ProviderHost,
204 - fileSystem: yield* FileSystem.FileSystem,
200 createHost: async () => (hostCount++ === 0 ? fake.host : (replacement ?? fake).host),
201 ...overrides,
202 });
@@ -434,13 +429,10 @@ describe("MuseAdapterV2", () => {
429 for (const kind of ["sessionNotFound", "notFound"] as const) {
430 const fake = yield* makeFakeMuse();
431 const allocated = yield* preallocatedProviderThread();
437 - const adapter = makeMuseAdapterV2({
432 + const adapter = yield* makeMuseAdapterV2({
433 instanceId: INSTANCE_ID,
434 settings: museSettings,
435 environment: { PATH: "/fake/bin" },
441 - idAllocator: yield* IdAllocator.IdAllocatorV2,
442 - host: yield* ProviderHost.ProviderHost,
443 - fileSystem: yield* FileSystem.FileSystem,
436 createHost: async () => fake.host,
437 });
438 const runtime = yield* adapter.openSession({
packages/provider-muse/src/server/adapter.ts
+13 -13
@@ -35,7 +35,7 @@ import * as Semaphore from "effect/Semaphore";
35 import * as Scope from "effect/Scope";
36 import * as Stream from "effect/Stream";
37
38 -import type * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
38 +import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
39 import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
40 import { buildRuntimeInstructions } from "@t3tools/provider-core/server/runtimeInstructions";
41 import { museModelCapabilities, resolveMuseReasoningEffort } from "./modelCatalog.ts";
@@ -181,9 +181,6 @@ export interface MuseAdapterV2Options {
181 readonly instanceId: ProviderInstanceId;
182 readonly settings: MuseSettings;
183 readonly environment: NodeJS.ProcessEnv;
184 - readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
185 - readonly host: ProviderHost.ProviderHostShape;
186 - readonly fileSystem: FileSystem.FileSystem;
184 readonly modelCatalog?: Effect.Effect<ReadonlyArray<ServerProviderModel>>;
185 readonly createHost?: typeof createMuseSdkHost;
186 readonly requestTimeoutMs?: number;
@@ -245,10 +242,13 @@ const TOOLS_WITH_NATIVE_ROWS = new Set(["write_todos", "request_user_input", "wo
242 const responseAnswerSchema = Schema.Union([Schema.String, Schema.Array(Schema.String)]);
243
244 /** One scoped Muse host owns one native session; the orchestrator owns app runs and queuing. */
248 -export function makeMuseAdapterV2(
245 +export const makeMuseAdapterV2 = Effect.fn("makeMuseAdapterV2")(function* (
246 options: MuseAdapterV2Options,
250 -): ProviderAdapter.ProviderAdapterV2Shape {
251 - const { idAllocator } = options;
247 +) {
248 + const idAllocator = yield* IdAllocator.IdAllocatorV2;
249 + const providerHost = yield* ProviderHost.ProviderHost;
250 + const fileSystem = yield* FileSystem.FileSystem;
251 +
252 const protocolError = (detail: string, payload?: unknown) =>
253 new ProviderAdapter.ProviderAdapterProtocolError({
254 driver: MUSE_PROVIDER,
@@ -269,8 +269,8 @@ export function makeMuseAdapterV2(
269 const scope = yield* Effect.scope;
270 // Muse rejects non-canonical workspace roots (for example macOS /tmp) and
271 // reports canonical paths in approvals, so resolve symlinks once here.
272 - const requestedCwd = input.runtimePolicy.cwd ?? options.host.paths.cwd;
273 - const cwd = yield* options.fileSystem
272 + const requestedCwd = input.runtimePolicy.cwd ?? providerHost.paths.cwd;
273 + const cwd = yield* fileSystem
274 .realPath(requestedCwd)
275 .pipe(Effect.orElseSucceed(() => requestedCwd));
276 const now = yield* DateTime.now;
@@ -1581,14 +1581,14 @@ export function makeMuseAdapterV2(
1581 const text = providerMessageTextWithAttachmentPaths({
1582 text: message.text,
1583 attachments: message.attachments,
1584 - resolveAttachmentPath: options.host.resolveAttachmentPath,
1584 + resolveAttachmentPath: providerHost.resolveAttachmentPath,
1585 });
1586 if (text) parts.push({ type: "text", text });
1587 for (const attachment of message.attachments)
1588 if (isProviderNativeImageAttachment(attachment)) {
1589 - const path = options.host.resolveAttachmentPath(attachment);
1589 + const path = providerHost.resolveAttachmentPath(attachment);
1590 if (!path) return yield* protocolError("Muse image attachment is missing");
1591 - const bytes = yield* options.fileSystem
1591 + const bytes = yield* fileSystem
1592 .readFile(path)
1593 .pipe(Effect.mapError((cause) => protocolError("Cannot read Muse image", cause)));
1594 parts.push({
@@ -2031,4 +2031,4 @@ export function makeMuseAdapterV2(
2031 return runtime;
2032 }),
2033 });
2034 -}
2034 +});
packages/provider-muse/src/server/driver.ts
+1 -5
@@ -63,7 +63,6 @@ export const MuseDriver: ProviderDriver<MuseSettings, MuseDriverEnv> = {
63 const host = yield* ProviderHost.ProviderHost;
64 const eventLoggers = yield* ProviderEventLoggers.ProviderEventLoggers;
65 const { cwd } = host.paths;
66 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
66 const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
67 const hostEnvironment = yield* HostProcessEnvironment;
68 // Drop an inherited META_API_KEY so Muse uses its login; an instance value still wins.
@@ -148,13 +147,10 @@ export const MuseDriver: ProviderDriver<MuseSettings, MuseDriverEnv> = {
147 ),
148 );
149 const modelCatalog = snapshot.getSnapshot.pipe(Effect.map((current) => current.models));
151 - const orchestrationAdapter = makeMuseAdapterV2({
150 + const orchestrationAdapter = yield* makeMuseAdapterV2({
151 instanceId,
152 settings: effectiveConfig,
153 environment: processEnvironment,
155 - idAllocator,
156 - host,
157 - fileSystem,
154 modelCatalog,
155 ...(eventLoggers.native ? { nativeEventLogger: eventLoggers.native } : {}),
156 continuationRequests,
packages/provider-opencode/src/server/adapter.test.ts
+24 -32
@@ -34,7 +34,7 @@ import * as TestClock from "effect/testing/TestClock";
34 import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
35 import { layerTestProviderHost } from "@t3tools/provider-testing/host";
36 import type * as ProviderEventLoggers from "@t3tools/provider-core/server/ProviderEventLoggers";
37 -import type * as OpenCodeRuntime from "./OpenCodeRuntime.ts";
37 +import * as OpenCodeRuntime from "./OpenCodeRuntime.ts";
38 import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
39
40 import {
@@ -148,7 +148,6 @@ const makeOpenCodeRuntimeHarness = Effect.fn("makeOpenCodeRuntimeHarness")(funct
148 nativeSessionId: string,
149 client: object,
150 ) {
151 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
151 const instanceId = ProviderInstanceId.make(`opencode-${suffix}`);
152 const threadId = ThreadId.make(`thread-opencode-${suffix}`);
153 const modelSelection = {
@@ -157,20 +156,20 @@ const makeOpenCodeRuntimeHarness = Effect.fn("makeOpenCodeRuntimeHarness")(funct
156 options: [],
157 };
158 const policy = runtimePolicy("full-access", { cwd: "/workspace" });
160 - const adapter = makeOpenCodeAdapterV2({
159 + const adapter = yield* makeOpenCodeAdapterV2({
160 instanceId,
161 settings: OPEN_CODE_TEST_SETTINGS,
162 environment: {},
164 - runtime: {
163 + }).pipe(
164 + Effect.provideService(OpenCodeRuntime.OpenCodeRuntime, {
165 connectToOpenCodeServer: () => Effect.succeed({ url: "http://test.invalid", external: true }),
166 createOpenCodeSdkClient: () => client,
167 - } as unknown as OpenCodeRuntime.OpenCodeRuntimeShape,
168 - idAllocator,
169 - host: {
167 + } as unknown as OpenCodeRuntime.OpenCodeRuntimeShape),
168 + Effect.provideService(ProviderHost.ProviderHost, {
169 paths: { cwd: "/workspace" },
170 resolveAttachmentPath: () => null,
172 - } as unknown as ProviderHost.ProviderHostShape,
173 - });
171 + } as unknown as ProviderHost.ProviderHost["Service"]),
172 + );
173 const runtime = yield* adapter.openSession({
174 threadId,
175 providerSessionId: ProviderSessionId.make(`session-opencode-${suffix}`),
@@ -1421,7 +1420,6 @@ describe("OpenCodeAdapterV2", () => {
1420
1421 it.effect("keeps a newly admitted prompt alive across stale idle and delayed busy evidence", () =>
1422 Effect.gen(function* () {
1424 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
1423 const nativeEvents = asyncEventStream();
1424 const prompt = promiseGate<void>();
1425 const promptStarted = promiseGate<void>();
@@ -1488,21 +1486,21 @@ describe("OpenCodeAdapterV2", () => {
1486 },
1487 mcp: { add: async () => ({ data: true }) },
1488 };
1491 - const adapter = makeOpenCodeAdapterV2({
1489 + const adapter = yield* makeOpenCodeAdapterV2({
1490 instanceId: ProviderInstanceId.make("opencode-test"),
1491 settings: OPEN_CODE_TEST_SETTINGS,
1492 environment: {},
1495 - runtime: {
1493 + }).pipe(
1494 + Effect.provideService(OpenCodeRuntime.OpenCodeRuntime, {
1495 connectToOpenCodeServer: () =>
1496 Effect.succeed({ url: "http://test.invalid", external: true }),
1497 createOpenCodeSdkClient: () => client,
1499 - } as unknown as OpenCodeRuntime.OpenCodeRuntimeShape,
1500 - idAllocator,
1501 - host: {
1498 + } as unknown as OpenCodeRuntime.OpenCodeRuntimeShape),
1499 + Effect.provideService(ProviderHost.ProviderHost, {
1500 paths: { cwd: "/workspace" },
1501 resolveAttachmentPath: () => null,
1504 - } as unknown as ProviderHost.ProviderHostShape,
1505 - });
1502 + } as unknown as ProviderHost.ProviderHost["Service"]),
1503 + );
1504 const threadId = ThreadId.make("thread-opencode-admission-race");
1505 const providerSessionId = ProviderSessionId.make("session-opencode-admission-race");
1506 const modelSelection = {
@@ -1739,7 +1737,6 @@ describe("OpenCodeAdapterV2", () => {
1737
1738 it.effect("interrupts an initial prompt while its SDK request is pending", () =>
1739 Effect.gen(function* () {
1742 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
1740 const nativeEvents = asyncEventStream();
1741 const promptStarted = promiseGate<void>();
1742 const abortCalled = promiseGate<void>();
@@ -1783,21 +1780,21 @@ describe("OpenCodeAdapterV2", () => {
1780 },
1781 mcp: { add: async () => ({ data: true }) },
1782 };
1786 - const adapter = makeOpenCodeAdapterV2({
1783 + const adapter = yield* makeOpenCodeAdapterV2({
1784 instanceId: ProviderInstanceId.make("opencode-initial-stop-test"),
1785 settings: OPEN_CODE_TEST_SETTINGS,
1786 environment: {},
1790 - runtime: {
1787 + }).pipe(
1788 + Effect.provideService(OpenCodeRuntime.OpenCodeRuntime, {
1789 connectToOpenCodeServer: () =>
1790 Effect.succeed({ url: "http://test.invalid", external: true }),
1791 createOpenCodeSdkClient: () => client,
1794 - } as unknown as OpenCodeRuntime.OpenCodeRuntimeShape,
1795 - idAllocator,
1796 - host: {
1792 + } as unknown as OpenCodeRuntime.OpenCodeRuntimeShape),
1793 + Effect.provideService(ProviderHost.ProviderHost, {
1794 paths: { cwd: "/workspace" },
1795 resolveAttachmentPath: () => null,
1799 - } as unknown as ProviderHost.ProviderHostShape,
1800 - });
1796 + } as unknown as ProviderHost.ProviderHost["Service"]),
1797 + );
1798 const threadId = ThreadId.make("thread-opencode-initial-stop");
1799 const providerSessionId = ProviderSessionId.make("session-opencode-initial-stop");
1800 const modelSelection = {
@@ -2419,8 +2416,6 @@ describe("OpenCodeAdapterV2", () => {
2416
2417 it.effect("adopts the handed-over provider thread identity on session create", () =>
2418 Effect.gen(function* () {
2422 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
2423 - const host = yield* ProviderHost.ProviderHost;
2419 let createCount = 0;
2420 const createInputs: Array<unknown> = [];
2421 const fakeClient = {
@@ -2467,14 +2462,11 @@ describe("OpenCodeAdapterV2", () => {
2462 const instanceId = ProviderInstanceId.make("opencode");
2463 const threadId = ThreadId.make("thread-opencode-adopt");
2464 const modelSelection = { instanceId, model: "default" };
2470 - const adapter = makeOpenCodeAdapterV2({
2465 + const adapter = yield* makeOpenCodeAdapterV2({
2466 instanceId,
2467 settings: OPENCODE_TEST_SETTINGS,
2468 environment: {},
2474 - runtime,
2475 - idAllocator,
2476 - host,
2477 - });
2469 + }).pipe(Effect.provideService(OpenCodeRuntime.OpenCodeRuntime, runtime));
2470 const session = yield* adapter.openSession({
2471 threadId,
2472 providerSessionId: ProviderSessionId.make("provider-session-opencode-adopt"),
packages/provider-opencode/src/server/adapter.ts
+8 -21
@@ -438,9 +438,6 @@ export interface OpenCodeAdapterV2Options {
438 readonly instanceId: ProviderInstanceId;
439 readonly settings: OpenCodeSettings;
440 readonly environment: NodeJS.ProcessEnv;
441 - readonly runtime: OpenCodeRuntime.OpenCodeRuntimeShape;
442 - readonly idAllocator: IdAllocator.IdAllocatorV2Shape;
443 - readonly host: ProviderHost.ProviderHostShape;
441 readonly nativeEventLogger?: ProviderEventLoggers.EventNdjsonLogger;
442 }
443
@@ -944,10 +941,12 @@ function unwrapData<A>(operation: string, result: { readonly data?: A }): NonNul
941 return result.data as NonNullable<A>;
942 }
943
947 -export function makeOpenCodeAdapterV2(
944 +export const makeOpenCodeAdapterV2 = Effect.fn("makeOpenCodeAdapterV2")(function* (
945 options: OpenCodeAdapterV2Options,
949 -): ProviderAdapter.ProviderAdapterV2Shape {
950 - const { idAllocator, runtime, host } = options;
946 +) {
947 + const runtime = yield* OpenCodeRuntime.OpenCodeRuntime;
948 + const idAllocator = yield* IdAllocator.IdAllocatorV2;
949 + const host = yield* ProviderHost.ProviderHost;
950
951 return ProviderAdapter.ProviderAdapterV2.of({
952 instanceId: options.instanceId,
@@ -3724,7 +3723,7 @@ export function makeOpenCodeAdapterV2(
3723 ),
3724 ),
3725 });
3727 -}
3726 +});
3727
3728 export type OpenCodeAdapterV2DriverEnv =
3729 | OpenCodeRuntime.OpenCodeRuntime
@@ -3742,17 +3741,11 @@ export const OpenCodeAdapterV2Driver: ProviderAdapterDriver<
3741 create: Effect.fn("OpenCodeAdapterV2Driver.create")(
3742 function* (input: ProviderAdapterDriverCreateInput<OpenCodeSettings>) {
3743 const hostEnvironment = yield* HostProcessEnvironment;
3745 - const openCodeRuntime = yield* OpenCodeRuntime.OpenCodeRuntime;
3746 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
3744 const providerEventLoggers = yield* ProviderEventLoggers.ProviderEventLoggers;
3748 - const host = yield* ProviderHost.ProviderHost;
3749 - return makeOpenCodeAdapterV2({
3745 + return yield* makeOpenCodeAdapterV2({
3746 instanceId: input.instanceId,
3747 settings: { ...input.config, enabled: input.enabled },
3748 environment: mergeProviderInstanceEnvironment(input.environment, hostEnvironment),
3753 - runtime: openCodeRuntime,
3754 - idAllocator,
3755 - host,
3749 ...(providerEventLoggers.native === undefined
3750 ? {}
3751 : { nativeEventLogger: providerEventLoggers.native }),
@@ -3778,17 +3771,11 @@ const layer: Layer.Layer<ProviderAdapter.ProviderAdapterV2, never, OpenCodeAdapt
3771 ProviderAdapter.ProviderAdapterV2,
3772 Effect.gen(function* () {
3773 const hostEnvironment = yield* HostProcessEnvironment;
3781 - const openCodeRuntime = yield* OpenCodeRuntime.OpenCodeRuntime;
3782 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
3774 const providerEventLoggers = yield* ProviderEventLoggers.ProviderEventLoggers;
3784 - const host = yield* ProviderHost.ProviderHost;
3785 - return makeOpenCodeAdapterV2({
3775 + return yield* makeOpenCodeAdapterV2({
3776 instanceId: OPENCODE_DEFAULT_INSTANCE_ID,
3777 settings: DEFAULT_OPENCODE_SETTINGS,
3778 environment: hostEnvironment,
3789 - runtime: openCodeRuntime,
3790 - idAllocator,
3791 - host,
3779 ...(providerEventLoggers.native === undefined
3780 ? {}
3781 : { nativeEventLogger: providerEventLoggers.native }),
packages/provider-opencode/src/server/v2/textGeneration.ts
+1 -1
@@ -40,7 +40,7 @@ type Outcome =
40 const runOnServer = (
41 connection: OpenCode2Server.OpenCode2Connection,
42 input: TextGenerationOperations.Request<Schema.Top>,
43 - resolveAttachmentPath: ProviderHost.ProviderHostShape["resolveAttachmentPath"],
43 + resolveAttachmentPath: ProviderHost.ProviderHost["Service"]["resolveAttachmentPath"],
44 ) =>
45 Effect.gen(function* () {
46 const { client } = connection;
packages/provider-pi/src/server/adapter.test.ts
+4 -34
@@ -22,7 +22,6 @@ import * as DateTime from "effect/DateTime";
22 import * as Duration from "effect/Duration";
23 import * as Effect from "effect/Effect";
24 import * as Fiber from "effect/Fiber";
25 -import * as FileSystem from "effect/FileSystem";
25 import * as Layer from "effect/Layer";
26 import * as PlatformError from "effect/PlatformError";
27 import * as Queue from "effect/Queue";
@@ -31,21 +30,14 @@ import * as Sink from "effect/Sink";
30 import * as Stream from "effect/Stream";
31 import * as TestClock from "effect/testing/TestClock";
32 import { ChildProcess, ChildProcessSpawner } from "effect/process";
34 -import { HostProcessEnvironment } from "@t3tools/shared/hostProcess";
33
36 -import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
34 import { layerTestProviderHost } from "@t3tools/provider-testing/host";
35 import * as ProviderContinuationRequests from "@t3tools/provider-core/server/continuationRequests";
36 import * as McpProviderSession from "@t3tools/provider-core/server/mcpSession";
37 import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
38 import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
39 import { handoffBudget } from "@t3tools/provider-core/server/handoffBudget";
43 -import {
44 - makePiAdapterV2,
45 - PiAdapterV2Driver,
46 - PI_PROVIDER,
47 - type PiAdapterV2Options,
48 -} from "./adapter.ts";
40 +import { makePiAdapterV2, PI_PROVIDER, type PiAdapterV2Options } from "./adapter.ts";
41 import { makePiRpcConnection, type PiRpcRecord } from "./rpc.ts";
42
43 const layerTest = Layer.mergeAll(
@@ -326,9 +318,6 @@ const makeAdapter = Effect.fnUntraced(function* (
318 forkFake?: FakePi,
319 continuationRequests?: PiAdapterV2Options["continuationRequests"],
320 ) {
329 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
330 - const host = yield* ProviderHost.ProviderHost;
331 - const fileSystem = yield* FileSystem.FileSystem;
321 const spawner =
322 forkFake === undefined
323 ? fake.spawner
@@ -337,31 +326,12 @@ const makeAdapter = Effect.fnUntraced(function* (
326 ? forkFake.spawner.spawn(command)
327 : fake.spawner.spawn(command),
328 );
340 - if (continuationRequests !== undefined) {
341 - return yield* PiAdapterV2Driver.create({
342 - instanceId: PI_INSTANCE_ID,
343 - displayName: undefined,
344 - enabled: true,
345 - environment: [],
346 - config: { enabled: true, binaryPath: "pi", launchArgs, customModels: [] },
347 - }).pipe(
348 - Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
349 - Effect.provideService(HostProcessEnvironment, {}),
350 - Effect.provideService(ProviderContinuationRequests.ProviderContinuationRequests, {
351 - ...continuationRequests,
352 - take: Effect.never,
353 - }),
354 - );
355 - }
356 - return makePiAdapterV2({
329 + return yield* makePiAdapterV2({
330 instanceId: PI_INSTANCE_ID,
331 settings: { enabled: true, binaryPath: "pi", launchArgs, customModels: [] },
332 environment: {},
360 - spawner,
361 - fileSystem,
362 - idAllocator,
363 - host,
364 - });
333 + ...(continuationRequests === undefined ? {} : { continuationRequests }),
334 + }).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner));
335 });
336
337 const openRuntime = Effect.fnUntraced(function* (
packages/provider-pi/src/server/adapter.ts
+23 -35
@@ -228,10 +228,10 @@ export interface PiAdapterV2Options {
228 readonly instanceId: ProviderInstanceId;
229 readonly settings: PiSettings;
230 readonly environment: NodeJS.ProcessEnv;
231 - readonly spawner: ChildProcessSpawner.ChildProcessSpawner["Service"];
232 - readonly fileSystem: FileSystem.FileSystem;
233 - readonly idAllocator: IdAllocator.IdAllocatorV2["Service"];
234 - readonly host: ProviderHost.ProviderHostShape;
231 + /**
232 + * Where to offer a wake turn for provider-initiated work. Without one, such
233 + * work has no owner and the adapter stops it.
234 + */
235 readonly continuationRequests?: {
236 readonly offer: (
237 request: ProviderContinuationRequests.ProviderContinuationRequest,
@@ -386,10 +386,14 @@ interface PiWake {
386
387 // ── adapter ───────────────────────────────────────────────────
388
389 -export function makePiAdapterV2(
389 +export const makePiAdapterV2 = Effect.fn("makePiAdapterV2")(function* (
390 options: PiAdapterV2Options,
391 -): ProviderAdapter.ProviderAdapterV2Shape {
392 - const { idAllocator } = options;
391 +) {
392 + const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
393 + const fileSystem = yield* FileSystem.FileSystem;
394 + const idAllocator = yield* IdAllocator.IdAllocatorV2;
395 + const host = yield* ProviderHost.ProviderHost;
396 + const { continuationRequests } = options;
397
398 const protocolError = (detail: string, payload?: unknown) =>
399 new ProviderAdapter.ProviderAdapterProtocolError({
@@ -407,11 +411,11 @@ export function makePiAdapterV2(
411 input: ProviderAdapter.ProviderAdapterV2OpenSessionInput,
412 ) {
413 const scope = yield* Effect.scope;
410 - const cwd = input.runtimePolicy.cwd ?? options.host.paths.cwd;
414 + const cwd = input.runtimePolicy.cwd ?? host.paths.cwd;
415 const mcpSession = McpProviderSession.readMcpProviderSession(input.threadId);
416 const provideCacheFs = <A, E>(effect: Effect.Effect<A, E, FileSystem.FileSystem>) =>
417 effect.pipe(
414 - Effect.provideService(FileSystem.FileSystem, options.fileSystem),
418 + Effect.provideService(FileSystem.FileSystem, fileSystem),
419 Effect.mapError(
420 (cause) =>
421 new ProviderAdapter.ProviderAdapterOpenSessionError({
@@ -425,7 +429,7 @@ export function makePiAdapterV2(
429 // hook. Materialize it even when this session has no MCP credential so
430 // Supervised never silently degrades to unrestricted tool execution.
431 const extensionPath = yield* provideCacheFs(
428 - materializePiT3McpExtension(options.host.paths.providerStatusCacheDir),
432 + materializePiT3McpExtension(host.paths.providerStatusCacheDir),
433 );
434 const resolvedLaunchArgs = resolvePiLaunchArgs(options.settings.launchArgs);
435 if (!resolvedLaunchArgs.ok) {
@@ -444,7 +448,7 @@ export function makePiAdapterV2(
448 cwd,
449 env: launch.env,
450 }).pipe(
447 - Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, options.spawner),
451 + Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
452 Effect.mapError(
453 (cause) =>
454 new ProviderAdapter.ProviderAdapterOpenSessionError({
@@ -1622,7 +1626,7 @@ export function makePiAdapterV2(
1626 if (
1627 turn === null &&
1628 state?.providerThread.appThreadId != null &&
1625 - options.continuationRequests !== undefined &&
1629 + continuationRequests !== undefined &&
1630 !closed &&
1631 !stopRequested
1632 ) {
@@ -1633,7 +1637,7 @@ export function makePiAdapterV2(
1637 return;
1638 }
1639 yield* updateProviderSession("running", null);
1636 - yield* options.continuationRequests
1640 + yield* continuationRequests
1641 .offer({
1642 threadId: state.providerThread.appThreadId,
1643 providerThreadId: state.providerThread.id,
@@ -2337,10 +2341,10 @@ export function makePiAdapterV2(
2341 const images: Array<{ type: "image"; data: string; mimeType: string }> = [];
2342 const extraLines: Array<string> = [];
2343 for (const attachment of attachments) {
2340 - const path = options.host.resolveAttachmentPath(attachment);
2344 + const path = host.resolveAttachmentPath(attachment);
2345 if (path === null) continue;
2346 if (attachment.mimeType.startsWith("image/")) {
2343 - const bytes = yield* options.fileSystem.readFile(path);
2347 + const bytes = yield* fileSystem.readFile(path);
2348 images.push({
2349 type: "image",
2350 data: Buffer.from(bytes).toString("base64"),
@@ -3033,7 +3037,7 @@ export function makePiAdapterV2(
3037 }
3038 return file;
3039 }),
3036 - ).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, options.spawner));
3040 + ).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner));
3041 const now = yield* DateTime.now;
3042 return yield* registerThread(
3043 {
@@ -3082,7 +3086,7 @@ export function makePiAdapterV2(
3086 return runtime;
3087 }),
3088 });
3085 -}
3089 +});
3090
3091 /**
3092 * Resolve the pi session-tree entry `fork` should re-root at for a rollback.
@@ -3210,19 +3214,11 @@ export const PiAdapterV2Driver: ProviderAdapterDriver<PiSettings, PiAdapterV2Dri
3214 create: Effect.fn("PiAdapterV2Driver.create")(
3215 function* (input: ProviderAdapterDriverCreateInput<PiSettings>) {
3216 const hostEnvironment = yield* HostProcessEnvironment;
3213 - const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3214 - const fileSystem = yield* FileSystem.FileSystem;
3215 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
3216 - const host = yield* ProviderHost.ProviderHost;
3217 const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
3218 - return makePiAdapterV2({
3218 + return yield* makePiAdapterV2({
3219 instanceId: input.instanceId,
3220 settings: { ...input.config, enabled: input.enabled },
3221 environment: mergeProviderInstanceEnvironment(input.environment, hostEnvironment),
3222 - spawner,
3223 - fileSystem,
3224 - idAllocator,
3225 - host,
3222 continuationRequests,
3223 });
3224 },
@@ -3246,19 +3242,11 @@ const layer: Layer.Layer<ProviderAdapter.ProviderAdapterV2, never, PiAdapterV2Dr
3242 ProviderAdapter.ProviderAdapterV2,
3243 Effect.gen(function* () {
3244 const hostEnvironment = yield* HostProcessEnvironment;
3249 - const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
3250 - const fileSystem = yield* FileSystem.FileSystem;
3251 - const idAllocator = yield* IdAllocator.IdAllocatorV2;
3252 - const host = yield* ProviderHost.ProviderHost;
3245 const continuationRequests = yield* ProviderContinuationRequests.ProviderContinuationRequests;
3254 - return makePiAdapterV2({
3246 + return yield* makePiAdapterV2({
3247 instanceId: PI_DEFAULT_INSTANCE_ID,
3248 settings: DEFAULT_PI_SETTINGS,
3249 environment: hostEnvironment,
3258 - spawner,
3259 - fileSystem,
3260 - idAllocator,
3261 - host,
3250 continuationRequests,
3251 });
3252 }),