11import { describe , expect , it } from "@effect/vitest" ;
2- import { Effect , Predicate , Result } from "effect" ;
2+ import { Effect , Predicate , Result , Schema } from "effect" ;
33
44import {
55 AuthTemplateSlug ,
@@ -11,6 +11,7 @@ import {
1111 ToolName ,
1212} from "./ids" ;
1313import { createExecutor } from "./executor" ;
14+ import { HealthCheckResult } from "./health-check" ;
1415import { definePlugin } from "./plugin" ;
1516import type { CredentialProvider } from "./provider" ;
1617import { makeTestConfig , makeTestExecutor } from "./testing" ;
@@ -43,6 +44,11 @@ const memoryProvider = (): CredentialProvider => {
4344const INTEG = IntegrationSlug . make ( "vercel" ) ;
4445const TEMPLATE = AuthTemplateSlug . make ( "apiKey" ) ;
4546
47+ const ConnectionListHealthOutput = Schema . Struct ( {
48+ connections : Schema . Array ( Schema . Struct ( { lastHealth : Schema . NullOr ( HealthCheckResult ) } ) ) ,
49+ } ) ;
50+ const decodeConnectionListHealthOutput = Schema . decodeUnknownEffect ( ConnectionListHealthOutput ) ;
51+
4652const demoPlugin = definePlugin ( ( ) => ( {
4753 id : "demo" as const ,
4854 credentialProviders : [ memoryProvider ( ) ] ,
@@ -263,6 +269,58 @@ describe("connections.create", () => {
263269} ) ;
264270
265271describe ( "connections.list / get" , ( ) => {
272+ it . effect ( "only includes full health diagnostics in verbose core tool output" , ( ) =>
273+ Effect . gen ( function * ( ) {
274+ const config = makeTestConfig ( { plugins : [ demoPlugin ] as const , coreTools : { } } ) ;
275+ const executor = yield * createExecutor ( config ) ;
276+ yield * executor . demo . seed ( ) ;
277+ yield * executor . connections . create ( {
278+ owner : "org" ,
279+ name : ConnectionName . make ( "health" ) ,
280+ integration : INTEG ,
281+ template : TEMPLATE ,
282+ value : "v" ,
283+ } ) ;
284+
285+ const health = {
286+ status : "healthy" as const ,
287+ identity : "account@example.com" ,
288+ checkedAt : 1234 ,
289+ httpStatus : 200 ,
290+ detail : "GET /me returned 200" ,
291+ responseSample : [ { path : "user.email" , value : "account@example.com" } ] ,
292+ } ;
293+ yield * Effect . promise ( ( ) =>
294+ config . db . updateMany ( "connection" , {
295+ where : ( b ) => b . and ( b ( "integration" , "=" , String ( INTEG ) ) , b ( "name" , "=" , "health" ) ) ,
296+ set : { last_health : health } ,
297+ } ) ,
298+ ) ;
299+
300+ const list = ( input : { readonly verbose ?: boolean } ) =>
301+ executor
302+ . execute ( ToolAddress . make ( "executor.coreTools.connections.list" ) , {
303+ integration : String ( INTEG ) ,
304+ owner : "org" ,
305+ ...input ,
306+ } )
307+ . pipe ( Effect . flatMap ( decodeConnectionListHealthOutput ) ) ;
308+
309+ const defaultList = yield * list ( { } ) ;
310+ const nonVerboseList = yield * list ( { verbose : false } ) ;
311+ const verboseList = yield * list ( { verbose : true } ) ;
312+ const summary = {
313+ status : "healthy" ,
314+ identity : "account@example.com" ,
315+ checkedAt : 1234 ,
316+ } ;
317+
318+ expect ( defaultList . connections [ 0 ] ?. lastHealth ) . toEqual ( summary ) ;
319+ expect ( nonVerboseList . connections [ 0 ] ?. lastHealth ) . toEqual ( summary ) ;
320+ expect ( verboseList . connections [ 0 ] ?. lastHealth ) . toEqual ( health ) ;
321+ } ) ,
322+ ) ;
323+
266324 it . effect ( "lists created connections and filters by integration" , ( ) =>
267325 Effect . gen ( function * ( ) {
268326 const executor = yield * setup ( ) ;
0 commit comments