Skip to content

Commit 8385f49

Browse files
refactor(provider-acp): ACP, ACP Registry and Grok follow the Effect service conventions
Effect http/process modules are imported as subpath namespaces. Factories yield ChildProcessSpawner, FileSystem, Path, AcpRegistryCatalog and the optional AcpRegistryRuntimeCoordinator from the environment instead of taking them as options: makeAcpClientTerminals, makeAcpAdapterV2 clientTerminals, terminateWindowsProcessTreeWithTaskkill, makeGrokAcpRuntime, makeGrokAcpAdapterFlavor, makeAcpRegistryAdapterV2 and acpRegistryManagedBinaryDirectories. Flavor makeRuntime factories may now require ChildProcessSpawner, which the ACP adapter provides. The Grok snapshot error detail no longer copies cause.message. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 31b04e2 commit 8385f49

28 files changed

Lines changed: 436 additions & 452 deletions

‎apps/server/scripts/record-grok-acp-replay-fixture.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import * as FileSystem from "effect/FileSystem";
2121
import * as Layer from "effect/Layer";
2222
import * as Path from "effect/Path";
2323
import * as Schema from "effect/Schema";
24-
import { ChildProcessSpawner } from "effect/process";
2524
import type * as EffectAcpProtocol from "effect-acp/protocol";
2625

2726
import * as TestProviderHost from "@t3tools/provider-testing/TestProviderHost";
@@ -443,7 +442,6 @@ const recordScenario = Effect.fn("recordGrokScenario")(function* (fixtureName: s
443442
const settings = { ...DEFAULT_GROK_SETTINGS, binaryPath: process.env.T3_GROK_BIN ?? "grok" };
444443
const layerRegistry = ProviderAdapterRegistry.layerFromAdaptersEffect(
445444
Effect.gen(function* () {
446-
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
447445
const environment = yield* HostProcessEnvironment;
448446
const adapter = yield* makeGrokAdapterV2({
449447
instanceId: GROK_DEFAULT_INSTANCE_ID,
@@ -460,7 +458,6 @@ const recordScenario = Effect.fn("recordGrokScenario")(function* (fixtureName: s
460458
interruptPromptOnCancel: input.interruptPromptOnCancel ?? false,
461459
grokSettings: settings,
462460
environment,
463-
childProcessSpawner,
464461
runtimeMode: grokLaunchRuntimeMode(runtimePolicy),
465462
}),
466463
});

‎apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts‎

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import * as Sink from "effect/Sink";
4848
import * as Stream from "effect/Stream";
4949
import * as Scope from "effect/Scope";
5050
import * as TestClock from "effect/testing/TestClock";
51-
import { ChildProcessSpawner } from "effect/process";
51+
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
5252
import * as EffectAcpErrors from "effect-acp/errors";
5353
import type * as EffectAcpProtocol from "effect-acp/protocol";
5454
import type * as EffectAcpSchema from "effect-acp/compat";
@@ -1150,7 +1150,7 @@ describe("AcpAdapterV2", () => {
11501150
const adapter = yield* makeAcpAdapterV2({
11511151
instanceId,
11521152
// Production Devin runs commands through client terminals.
1153-
clientTerminals: { childProcessSpawner, shellCommands: true },
1153+
clientTerminals: { shellCommands: true },
11541154
selfInvocation: yield* resolveSelfInvocation(),
11551155
flavor: {
11561156
driver: ACP_TEST_DRIVER,
@@ -2190,7 +2190,7 @@ describe("AcpAdapterV2", () => {
21902190
makeRuntime,
21912191
},
21922192
selfInvocation,
2193-
clientTerminals: { childProcessSpawner },
2193+
clientTerminals: {},
21942194
});
21952195
const sourceThreadId = ThreadId.make("thread-acp-native-fork-source");
21962196
const targetThreadId = ThreadId.make("thread-acp-native-fork-target");
@@ -2476,7 +2476,7 @@ describe("AcpAdapterV2", () => {
24762476
}).pipe(Effect.andThen(makeRuntime(input))),
24772477
},
24782478
selfInvocation,
2479-
clientTerminals: { childProcessSpawner },
2479+
clientTerminals: {},
24802480
});
24812481
const threadId = ThreadId.make("thread-acp-unknown-permission-grant");
24822482
const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
@@ -12045,9 +12045,11 @@ describe("AcpAdapterV2", () => {
1204512045
Effect.gen(function* () {
1204612046
const commands: Array<{ readonly command: string; readonly args: ReadonlyArray<string> }> =
1204712047
[];
12048-
yield* AcpSessionRuntime.terminateWindowsProcessTreeWithTaskkill(
12049-
makeTaskkillSpawner({ exitCode: 0, commands }),
12050-
4321,
12048+
yield* AcpSessionRuntime.terminateWindowsProcessTreeWithTaskkill(4321).pipe(
12049+
Effect.provideService(
12050+
ChildProcessSpawner.ChildProcessSpawner,
12051+
makeTaskkillSpawner({ exitCode: 0, commands }),
12052+
),
1205112053
);
1205212054
assert.deepEqual(commands, [{ command: "taskkill", args: ["/PID", "4321", "/T", "/F"] }]);
1205312055

@@ -12058,10 +12060,13 @@ describe("AcpAdapterV2", () => {
1205812060
{ exitCode: 128, output: "ERROR: Access is denied." },
1205912061
{ exitCode: 1, output: "generic failure" },
1206012062
]) {
12061-
const failed = yield* AcpSessionRuntime.terminateWindowsProcessTreeWithTaskkill(
12062-
makeTaskkillSpawner(fixture),
12063-
4321,
12064-
).pipe(Effect.exit);
12063+
const failed = yield* AcpSessionRuntime.terminateWindowsProcessTreeWithTaskkill(4321).pipe(
12064+
Effect.provideService(
12065+
ChildProcessSpawner.ChildProcessSpawner,
12066+
makeTaskkillSpawner(fixture),
12067+
),
12068+
Effect.exit,
12069+
);
1206512070
if (Exit.isSuccess(failed)) assert.fail(`taskkill ${fixture.exitCode} must fail`);
1206612071
const error = Cause.squash(failed.cause);
1206712072
assert.instanceOf(error, AcpSessionRuntime.AcpProcessGroupTerminationError);
@@ -12082,10 +12087,13 @@ describe("AcpAdapterV2", () => {
1208212087
{ outputFailure: true },
1208312088
{ exitFailure: true },
1208412089
]) {
12085-
const failed = yield* AcpSessionRuntime.terminateWindowsProcessTreeWithTaskkill(
12086-
makeTaskkillSpawner(fixture),
12087-
4321,
12088-
).pipe(Effect.exit);
12090+
const failed = yield* AcpSessionRuntime.terminateWindowsProcessTreeWithTaskkill(4321).pipe(
12091+
Effect.provideService(
12092+
ChildProcessSpawner.ChildProcessSpawner,
12093+
makeTaskkillSpawner(fixture),
12094+
),
12095+
Effect.exit,
12096+
);
1208912097
if (Exit.isSuccess(failed)) assert.fail("taskkill infrastructure failure must fail");
1209012098
const error = Cause.squash(failed.cause);
1209112099
assert.instanceOf(error, AcpSessionRuntime.AcpProcessGroupTerminationError);

‎apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.testkit.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as Layer from "effect/Layer";
1010
import * as Schema from "effect/Schema";
1111
import type * as Scope from "effect/Scope";
1212
import * as Stream from "effect/Stream";
13-
import { ChildProcessSpawner } from "effect/process";
13+
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
1414
import * as EffectAcpErrors from "effect-acp/errors";
1515

1616
import * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";

‎apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.test.ts‎

Lines changed: 64 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import * as Layer from "effect/Layer";
99
import * as Option from "effect/Option";
1010
import * as Path from "effect/Path";
1111
import * as Schema from "effect/Schema";
12-
import { HttpClient, HttpClientResponse } from "effect/http";
13-
import { ChildProcessSpawner } from "effect/process";
12+
import * as HttpClient from "effect/http/HttpClient";
13+
import * as HttpClientResponse from "effect/http/HttpClientResponse";
14+
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
1415
import * as EffectAcpErrors from "effect-acp/errors";
1516

1617
import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
@@ -22,6 +23,7 @@ import type {
2223
AcpRegistryLiveConfiguration,
2324
} from "@t3tools/provider-acp-registry/testing";
2425
import * as AcpRegistrySupport from "@t3tools/provider-acp-registry/server/AcpRegistrySupport";
26+
import * as AcpRegistryRuntimeCoordinator from "@t3tools/provider-acp-registry/server/AcpRegistryRuntimeCoordinator";
2527
import { ACP_SESSION_MODE_OPTION_ID } from "@t3tools/provider-acp/server/sessionConfig";
2628
import * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";
2729
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
@@ -82,6 +84,11 @@ const layerRegistry = Layer.succeed(
8284
),
8385
);
8486

87+
// Adapters given an explicit runtime never resolve through the catalog.
88+
const layerInjectedRuntimeCatalog = Layer.mock(AcpRegistrySupport.AcpRegistryCatalog)({
89+
resolve: () => Effect.die("the runtime is injected"),
90+
});
91+
8592
const layerTest = Layer.mergeAll(
8693
NodeServices.layer,
8794
IdAllocator.layer,
@@ -197,8 +204,6 @@ describe("AcpRegistryAdapterV2", () => {
197204
authMethodId: "test",
198205
}),
199206
environment: {},
200-
childProcessSpawner,
201-
resolver: { resolve: () => Effect.die("the runtime is injected") },
202207
makeRuntime: makeAcpReplayRuntime({
203208
transcript,
204209
statusPath,
@@ -208,7 +213,7 @@ describe("AcpRegistryAdapterV2", () => {
208213
childProcessSpawner,
209214
fileSystem,
210215
}),
211-
});
216+
}).pipe(Effect.provide(layerInjectedRuntimeCatalog));
212217
yield* adapter
213218
.openSession({
214219
threadId: ThreadId.make("thread-acp-registry-mode-pick"),
@@ -279,8 +284,6 @@ describe("AcpRegistryAdapterV2", () => {
279284
instanceId,
280285
settings: yield* decodeAcpRegistryAdapterSettings({ agentId, authMethodId: "test" }),
281286
environment: {},
282-
childProcessSpawner,
283-
resolver: { resolve: () => Effect.die("the runtime is injected") },
284287
makeRuntime: (input) =>
285288
Effect.gen(function* () {
286289
clientCapabilities = input.clientCapabilities;
@@ -305,7 +308,7 @@ describe("AcpRegistryAdapterV2", () => {
305308
Effect.provide(context),
306309
);
307310
}),
308-
});
311+
}).pipe(Effect.provide(layerInjectedRuntimeCatalog));
309312
const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
310313
runtimeMode: "full-access",
311314
interactionMode: "default",
@@ -333,7 +336,6 @@ describe("AcpRegistryAdapterV2", () => {
333336

334337
it.effect("opens a real ACP child process resolved from registry configuration", () =>
335338
Effect.gen(function* () {
336-
const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
337339
const path = yield* Path.Path;
338340
const host = yield* ProviderHost.ProviderHost;
339341
const mockAgentPath = yield* path.fromFileUrl(
@@ -365,55 +367,59 @@ describe("AcpRegistryAdapterV2", () => {
365367
T3_ACP_SESSION_LIFECYCLE: "1",
366368
T3_ACP_COMMAND_ADVERTISEMENT_DELAY_MS: "750",
367369
},
368-
childProcessSpawner,
369-
runtimeCoordinator: {
370-
withForegroundStartup: (agentId, effect) =>
371-
Effect.acquireUseRelease(
372-
Effect.sync(() => {
373-
assert.equal(agentId, "fixture-agent");
374-
startupActive = true;
375-
startupCount += 1;
376-
}),
377-
() => effect,
378-
() =>
379-
Effect.sync(() => {
380-
startupActive = false;
381-
}),
382-
),
383-
runBackgroundProbe: (_agentId, effect) => effect.pipe(Effect.map(Option.some)),
384-
withSessionMutation: (effect) => effect,
385-
clearAvailableCommands: () => Effect.void,
386-
publishAvailableCommands: (publishedInstanceId, commands) =>
387-
Deferred.succeed(commandsPublished, {
388-
instanceId: publishedInstanceId,
389-
commands,
390-
}).pipe(Effect.asVoid),
391-
getAvailableCommands: () => Effect.succeed(Option.none()),
392-
watchAvailableCommands: () => Effect.never,
393-
clearLiveConfiguration: () => Effect.void,
394-
publishLiveConfiguration: (_publishedInstanceId, configuration) =>
395-
Deferred.succeed(configurationPublished, configuration).pipe(Effect.asVoid),
396-
getLiveConfiguration: () => Effect.succeed(Option.none()),
397-
watchLiveConfiguration: () => Effect.never,
398-
requestUrlAuthentication: () => Effect.succeed(false),
399-
acceptUrlAuthentication: () => Effect.succeed(false),
400-
getUrlAuthAction: () => Effect.succeed(Option.none()),
401-
watchUrlAuthAction: () => Effect.never,
402-
},
403-
resolver: {
404-
resolve: (configuredSettings, cwd, environment) =>
405-
Effect.sync(() => assert.isTrue(startupActive)).pipe(
406-
Effect.andThen(resolver.resolve(configuredSettings, cwd, environment)),
407-
Effect.map((resolved) => ({
408-
...resolved,
409-
spawn: {
410-
...resolved.spawn,
411-
args: [mockAgentPath],
412-
},
413-
})),
414-
),
415-
},
416-
});
370+
}).pipe(
371+
Effect.provide(
372+
Layer.mergeAll(
373+
Layer.mock(AcpRegistryRuntimeCoordinator.AcpRegistryRuntimeCoordinator)({
374+
withForegroundStartup: (agentId, effect) =>
375+
Effect.acquireUseRelease(
376+
Effect.sync(() => {
377+
assert.equal(agentId, "fixture-agent");
378+
startupActive = true;
379+
startupCount += 1;
380+
}),
381+
() => effect,
382+
() =>
383+
Effect.sync(() => {
384+
startupActive = false;
385+
}),
386+
),
387+
runBackgroundProbe: (_agentId, effect) => effect.pipe(Effect.map(Option.some)),
388+
withSessionMutation: (effect) => effect,
389+
clearAvailableCommands: () => Effect.void,
390+
publishAvailableCommands: (publishedInstanceId, commands) =>
391+
Deferred.succeed(commandsPublished, {
392+
instanceId: publishedInstanceId,
393+
commands,
394+
}).pipe(Effect.asVoid),
395+
getAvailableCommands: () => Effect.succeed(Option.none()),
396+
watchAvailableCommands: () => Effect.never,
397+
clearLiveConfiguration: () => Effect.void,
398+
publishLiveConfiguration: (_publishedInstanceId, configuration) =>
399+
Deferred.succeed(configurationPublished, configuration).pipe(Effect.asVoid),
400+
getLiveConfiguration: () => Effect.succeed(Option.none()),
401+
watchLiveConfiguration: () => Effect.never,
402+
requestUrlAuthentication: () => Effect.succeed(false),
403+
acceptUrlAuthentication: () => Effect.succeed(false),
404+
getUrlAuthAction: () => Effect.succeed(Option.none()),
405+
watchUrlAuthAction: () => Effect.never,
406+
}),
407+
Layer.mock(AcpRegistrySupport.AcpRegistryCatalog)({
408+
resolve: (configuredSettings, cwd, environment) =>
409+
Effect.sync(() => assert.isTrue(startupActive)).pipe(
410+
Effect.andThen(resolver.resolve(configuredSettings, cwd, environment)),
411+
Effect.map((resolved) => ({
412+
...resolved,
413+
spawn: {
414+
...resolved.spawn,
415+
args: [mockAgentPath],
416+
},
417+
})),
418+
),
419+
}),
420+
),
421+
),
422+
);
417423
const threadId = ThreadId.make("thread-acp-registry-fixture");
418424
const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
419425
runtimeMode: "full-access",

‎apps/server/src/orchestration-v2/Adapters/AcpRegistryAdapterV2.testkit.ts‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as FileSystem from "effect/FileSystem";
66
import * as Layer from "effect/Layer";
77
import * as Path from "effect/Path";
88
import * as Schema from "effect/Schema";
9-
import { ChildProcessSpawner } from "effect/process";
9+
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
1010

1111
import * as TestProviderHost from "@t3tools/provider-testing/TestProviderHost";
1212
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
@@ -25,6 +25,7 @@ import {
2525
ACP_REGISTRY_PROVIDER,
2626
makeAcpRegistryAdapterV2,
2727
} from "@t3tools/provider-acp-registry/testing";
28+
import * as AcpRegistrySupport from "@t3tools/provider-acp-registry/server/AcpRegistrySupport";
2829

2930
const REPLAY_SETTINGS = Schema.decodeUnknownSync(AcpRegistrySettings)({
3031
agentId: "replay-agent",
@@ -56,10 +57,6 @@ function layerAcpRegistryProviderAdapterRegistryReplay(
5657
instanceId: ACP_REGISTRY_DEFAULT_INSTANCE_ID,
5758
settings: REPLAY_SETTINGS,
5859
environment: {},
59-
childProcessSpawner,
60-
resolver: {
61-
resolve: () => Effect.die("ACP registry resolver must not run during replay"),
62-
},
6360
selfInvocation: yield* resolveSelfInvocation(),
6461
makeRuntime: makeAcpReplayRuntime({
6562
transcript,
@@ -74,7 +71,16 @@ function layerAcpRegistryProviderAdapterRegistryReplay(
7471
return [adapter];
7572
}),
7673
).pipe(
77-
Layer.provide(Layer.mergeAll(layerHost, NodeServices.layer, IdAllocator.layer)),
74+
Layer.provide(
75+
Layer.mergeAll(
76+
layerHost,
77+
NodeServices.layer,
78+
IdAllocator.layer,
79+
Layer.mock(AcpRegistrySupport.AcpRegistryCatalog)({
80+
resolve: () => Effect.die("ACP registry resolver must not run during replay"),
81+
}),
82+
),
83+
),
7884
// Held inbound lines must not outlive the scenario and wedge teardown.
7985
Layer.merge(
8086
Layer.effectDiscard(

‎apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import * as Effect from "effect/Effect";
1717
import * as Layer from "effect/Layer";
1818
import * as PlatformError from "effect/PlatformError";
1919
import * as Schema from "effect/Schema";
20-
import { ChildProcessSpawner } from "effect/process";
20+
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
2121
import type * as EffectAcpSchema from "effect-acp/compat";
2222

2323
import * as TestProviderHost from "@t3tools/provider-testing/TestProviderHost";

‎apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.testkit.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as FileSystem from "effect/FileSystem";
55
import * as Layer from "effect/Layer";
66
import * as Path from "effect/Path";
77
import * as Schema from "effect/Schema";
8-
import { ChildProcessSpawner } from "effect/process";
8+
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
99
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
1010
import { resolveSelfInvocation } from "@t3tools/shared/nodeRuntime";
1111

‎apps/server/src/terminal/Manager.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,13 +2253,14 @@ export const makeWithOptions = Effect.fn("TerminalManager.makeWithOptions")(func
22532253
options.managedBinaryToolsDir !== undefined
22542254
) {
22552255
const managedDirectories = yield* acpRegistryManagedBinaryDirectories({
2256-
fileSystem,
2257-
path,
22582256
cacheDir: options.managedBinaryCacheDir,
22592257
toolsDir: options.managedBinaryToolsDir,
22602258
platform,
22612259
architecture,
2262-
});
2260+
}).pipe(
2261+
Effect.provideService(FileSystem.FileSystem, fileSystem),
2262+
Effect.provideService(Path.Path, path),
2263+
);
22632264
if (managedDirectories.length > 0) {
22642265
const delimiter = platform === "win32" ? ";" : ":";
22652266
const pathKey =

0 commit comments

Comments
 (0)