@@ -9,6 +9,7 @@ import { ProviderInstanceId } from "@t3tools/contracts";
99import { AcpRegistrySettings } from "@t3tools/provider-acp-registry/settings" ;
1010import { describe , expect , it } from "@effect/vitest" ;
1111import * as Effect from "effect/Effect" ;
12+ import * as FileSystem from "effect/FileSystem" ;
1213import * as Schema from "effect/Schema" ;
1314import * as EffectAcpErrors from "effect-acp/errors" ;
1415
@@ -20,6 +21,7 @@ import {
2021 logoutAcpRegistry ,
2122 normalizeAcpRegistryAuthMethods ,
2223 normalizeAcpRegistryCommands ,
24+ probeAcpRegistryConfiguration ,
2325} from "@t3tools/provider-acp-registry/testing" ;
2426import * as AcpRegistrySupport from "@t3tools/provider-acp-registry/server/AcpRegistrySupport" ;
2527
@@ -379,6 +381,60 @@ describe("ACP Registry probe", () => {
379381 ) ;
380382 } ) ;
381383
384+ it . live . each ( [ "succeeds" , "fails" ] as const ) (
385+ "deletes its health-probe session when deletion is advertised and %s" ,
386+ ( deleteOutcome ) =>
387+ Effect . gen ( function * ( ) {
388+ const fs = yield * FileSystem . FileSystem ;
389+ const directory = yield * fs . makeTempDirectoryScoped ( { prefix : "acp-probe-delete-" } ) ;
390+ const requestLogPath = NodePath . join ( directory , "requests.ndjson" ) ;
391+ const catalog = AcpRegistrySupport . AcpRegistryCatalog . of ( {
392+ search : ( ) => Effect . die ( "unused search" ) ,
393+ prepare : ( ) => Effect . die ( "unused prepare" ) ,
394+ inspect : ( ) => Effect . die ( "unused inspect" ) ,
395+ uninstallManagedBinary : ( ) => Effect . die ( "unused uninstall" ) ,
396+ resolve : ( ) =>
397+ Effect . succeed ( {
398+ agent : {
399+ id : "mock-agent" ,
400+ name : "Mock Agent" ,
401+ version : "1.0.0" ,
402+ description : "ACP probe cleanup test agent" ,
403+ distribution :
{ npx :
{ package :
"[email protected] " } } , 404+ } ,
405+ distribution : "npx" as const ,
406+ spawn : {
407+ command : "node" ,
408+ args : [ mockAgentPath ] ,
409+ env : {
410+ ...process . env ,
411+ T3_ACP_V2_MANAGEMENT : "1" ,
412+ T3_ACP_REQUEST_LOG_PATH : requestLogPath ,
413+ ...( deleteOutcome === "fails" ? { T3_ACP_FAIL_DELETE_SESSION : "1" } : { } ) ,
414+ } ,
415+ } ,
416+ } ) ,
417+ } ) ;
418+
419+ const result = yield * probeAcpRegistryConfiguration ( {
420+ instanceId,
421+ settings : decodeSettings ( { agentId : "mock-agent" } ) ,
422+ cwd : process . cwd ( ) ,
423+ environment : process . env ,
424+ } ) . pipe ( Effect . provideService ( AcpRegistrySupport . AcpRegistryCatalog , catalog ) ) ;
425+ expect ( result . probe . ready ) . toBe ( true ) ;
426+ expect ( result . probe . sessionManagement . canDelete ) . toBe ( true ) ;
427+
428+ const requests = ( yield * fs . readFileString ( requestLogPath ) )
429+ . split ( "\n" )
430+ . filter ( ( line ) => line . length > 0 )
431+ . map ( ( line ) => JSON . parse ( line ) ) ;
432+ expect ( requests . filter ( ( request ) => request . method === "session/delete" ) ) . toEqual ( [
433+ expect . objectContaining ( { params : { sessionId : "mock-session-1" } } ) ,
434+ ] ) ;
435+ } ) . pipe ( Effect . scoped , Effect . provide ( Layer . mergeAll ( NodeServices . layer , NodeCrypto . layer ) ) ) ,
436+ ) ;
437+
382438 it ( "distinguishes authentication failures from generic probe failures" , ( ) => {
383439 const advertised = normalizeAcpRegistryAuthMethods ( [
384440 { id : "grok-login" , name : "Log in with Grok" } ,
0 commit comments