/**
 * Claude Code adapter — concrete {@link AgentProvider} backed by
 * `@anthropic-ai/claude-agent-sdk`'s `query()`.
 *
 * Phase 1: this is a thin pass-through. `options` flows into the SDK unchanged,
 * and the SDK's Query object satisfies {@link AgentQuery} structurally (it already
 * exposes accountInfo/supportedModels/close and is async-iterable). Phase 3 will
 * translate between neutral options/events and the SDK shapes here.
 */
import { query as sdkQuery } from "@anthropic-ai/claude-agent-sdk";
import { buildClaudeCodeToolServer } from "./toolAdapter.js";
import { translateSdkMessages } from "./messageAdapter.js";
/**
 * Wraps the SDK's Query object and exposes it as a normalized {@link AgentQuery}:
 * iteration yields {@link AgentEvent}s (via {@link translateSdkMessages}) while
 * accountInfo/supportedModels/close delegate straight through.
 */
class ClaudeCodeAgentQuery {
    sdk;
    constructor(sdk) {
        this.sdk = sdk;
    }
    [Symbol.asyncIterator]() {
        return translateSdkMessages(this.sdk)[Symbol.asyncIterator]();
    }
    accountInfo() {
        return this.sdk.accountInfo();
    }
    supportedModels() {
        return this.sdk.supportedModels();
    }
    async close() {
        // SDK's close() is sync (returns void) in the current version; wrap for
        // the port's Promise<void> contract so other adapters can be async-native.
        await this.sdk.close();
    }
}
export class ClaudeCodeAdapter {
    kind = "claude-code";
    query(req) {
        // Options/prompt still flow through loosely — Phase 3 normalizes events
        // only; option normalization is a future refinement (see plan).
        const sdk = sdkQuery({
            prompt: req.prompt,
            options: req.options,
        });
        return new ClaudeCodeAgentQuery(sdk);
    }
    buildToolServer(spec) {
        return buildClaudeCodeToolServer(spec);
    }
}
