Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sdks/typescript/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AgentControlSDK } from "./generated/sdk/sdk";
import type { Logger } from "./generated/lib/logger";

export interface StepSchema {
name: string;
Expand All @@ -15,6 +16,7 @@ export interface AgentControlInitOptions {
steps?: StepSchema[];
timeoutMs?: number;
userAgent?: string;
debugLogger?: Logger;
}

export type AgentsApi = AgentControlSDK["agents"];
Expand All @@ -38,6 +40,7 @@ export class AgentControlClient {
apiKeyHeader: options.apiKey,
timeoutMs: options.timeoutMs,
userAgent: options.userAgent,
debugLogger: options.debugLogger,
});
}

Expand Down
38 changes: 38 additions & 0 deletions sdks/typescript/tests/client-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,44 @@ describe("AgentControlClient API wiring", () => {
expect(request.headers.get("X-API-Key")).toBe("test-api-key");
});

it("passes debugLogger through to the generated SDK", async () => {
const fetchMock = vi.mocked(globalThis.fetch);
fetchMock.mockResolvedValueOnce(
jsonResponse({
agents: [],
pagination: {
has_more: false,
limit: 20,
next_cursor: null,
total: 0,
},
}),
);

const debugLogger = {
group: vi.fn(),
groupEnd: vi.fn(),
log: vi.fn(),
};

const client = new AgentControlClient();
client.init({
agentName: "test-agent",
serverUrl: "https://api.example.com",
debugLogger,
});

await client.agents.list();

expect(debugLogger.group).toHaveBeenCalledWith(
"> Request: GET https://api.example.com/api/v1/agents",
);
expect(debugLogger.group).toHaveBeenCalledWith(
"< Response: GET https://api.example.com/api/v1/agents",
);
expect(debugLogger.log).toHaveBeenCalledWith("Status Code:", 200, "");
});

it("builds JSON request bodies for write operations", async () => {
const fetchMock = vi.mocked(globalThis.fetch);
fetchMock.mockResolvedValueOnce(
Expand Down
Loading