Skip to content

Commit 495b0dd

Browse files
committed
feat(sdk-ts): expose debug logger option
1 parent b4dff6f commit 495b0dd

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

sdks/typescript/src/client.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AgentControlSDK } from "./generated/sdk/sdk";
2+
import type { Logger } from "./generated/lib/logger";
23

34
export 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

2022
export 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

sdks/typescript/tests/client-api.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff 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(

0 commit comments

Comments
 (0)