@@ -9,8 +9,9 @@ import * as Layer from "effect/Layer";
99import * as Option from "effect/Option" ;
1010import * as Path from "effect/Path" ;
1111import * 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" ;
1415import * as EffectAcpErrors from "effect-acp/errors" ;
1516
1617import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost" ;
@@ -22,6 +23,7 @@ import type {
2223 AcpRegistryLiveConfiguration ,
2324} from "@t3tools/provider-acp-registry/testing" ;
2425import * as AcpRegistrySupport from "@t3tools/provider-acp-registry/server/AcpRegistrySupport" ;
26+ import * as AcpRegistryRuntimeCoordinator from "@t3tools/provider-acp-registry/server/AcpRegistryRuntimeCoordinator" ;
2527import { ACP_SESSION_MODE_OPTION_ID } from "@t3tools/provider-acp/server/sessionConfig" ;
2628import * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime" ;
2729import * 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+
8592const 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" ,
0 commit comments