File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { AgentControlSDK } from "./generated/sdk/sdk" ;
2+ import type { Logger } from "./generated/lib/logger" ;
23
34export interface StepSchema {
45 name : string ;
@@ -15,6 +16,7 @@ export interface AgentControlInitOptions {
1516 steps ?: StepSchema [ ] ;
1617 timeoutMs ?: number ;
1718 userAgent ?: string ;
19+ debugLogger ?: Logger ;
1820}
1921
2022export type AgentsApi = AgentControlSDK [ "agents" ] ;
@@ -38,6 +40,7 @@ export class AgentControlClient {
3840 apiKeyHeader : options . apiKey ,
3941 timeoutMs : options . timeoutMs ,
4042 userAgent : options . userAgent ,
43+ debugLogger : options . debugLogger ,
4144 } ) ;
4245 }
4346
Original file line number Diff line number Diff line change @@ -61,6 +61,44 @@ describe("AgentControlClient API wiring", () => {
6161 expect ( request . headers . get ( "X-API-Key" ) ) . toBe ( "test-api-key" ) ;
6262 } ) ;
6363
64+ it ( "passes debugLogger through to the generated SDK" , async ( ) => {
65+ const fetchMock = vi . mocked ( globalThis . fetch ) ;
66+ fetchMock . mockResolvedValueOnce (
67+ jsonResponse ( {
68+ agents : [ ] ,
69+ pagination : {
70+ has_more : false ,
71+ limit : 20 ,
72+ next_cursor : null ,
73+ total : 0 ,
74+ } ,
75+ } ) ,
76+ ) ;
77+
78+ const debugLogger = {
79+ group : vi . fn ( ) ,
80+ groupEnd : vi . fn ( ) ,
81+ log : vi . fn ( ) ,
82+ } ;
83+
84+ const client = new AgentControlClient ( ) ;
85+ client . init ( {
86+ agentName : "test-agent" ,
87+ serverUrl : "https://api.example.com" ,
88+ debugLogger,
89+ } ) ;
90+
91+ await client . agents . list ( ) ;
92+
93+ expect ( debugLogger . group ) . toHaveBeenCalledWith (
94+ "> Request: GET https://api.example.com/api/v1/agents" ,
95+ ) ;
96+ expect ( debugLogger . group ) . toHaveBeenCalledWith (
97+ "< Response: GET https://api.example.com/api/v1/agents" ,
98+ ) ;
99+ expect ( debugLogger . log ) . toHaveBeenCalledWith ( "Status Code:" , 200 , "" ) ;
100+ } ) ;
101+
64102 it ( "builds JSON request bodies for write operations" , async ( ) => {
65103 const fetchMock = vi . mocked ( globalThis . fetch ) ;
66104 fetchMock . mockResolvedValueOnce (
You can’t perform that action at this time.
0 commit comments