/**
 * Agent SDK
 *
 * Programmatic API for embedding Code Buddy as an agent in other applications.
 */
import { logger } from '../utils/logger.js';
// ============================================================================
// AgentSDK
// ============================================================================
export class AgentSDK {
    config;
    customTools = new Map();
    constructor(config = {}) {
        this.config = {
            model: config.model ?? 'grok-3-mini',
            tools: config.tools ?? [],
            maxTurns: config.maxTurns ?? 10,
            systemPrompt: config.systemPrompt ?? 'You are a helpful coding assistant.',
        };
        logger.debug(`AgentSDK initialized with model: ${this.config.model}`);
    }
    /**
     * Run agent loop with a prompt (returns final result)
     */
    async run(prompt) {
        logger.debug(`AgentSDK.run: ${prompt.slice(0, 100)}`);
        // Stub implementation - in production this would invoke the agent loop
        return {
            success: true,
            output: `Processed: ${prompt}`,
            toolCalls: 0,
            cost: 0,
        };
    }
    /**
     * Run agent loop with streaming events
     */
    async *runStreaming(prompt) {
        logger.debug(`AgentSDK.runStreaming: ${prompt.slice(0, 100)}`);
        yield { type: 'text', data: `Processing: ${prompt}` };
        yield { type: 'done', data: { success: true, toolCalls: 0, cost: 0 } };
    }
    /**
     * Register a custom tool
     */
    addTool(definition) {
        if (this.customTools.has(definition.name)) {
            throw new Error(`Tool "${definition.name}" already registered`);
        }
        this.customTools.set(definition.name, definition);
        logger.debug(`Tool registered: ${definition.name}`);
    }
    /**
     * Remove a custom tool
     */
    removeTool(name) {
        const deleted = this.customTools.delete(name);
        if (deleted) {
            logger.debug(`Tool removed: ${name}`);
        }
        return deleted;
    }
    /**
     * List all available tools (built-in + custom)
     */
    getTools() {
        const builtIn = this.config.tools || [];
        const custom = Array.from(this.customTools.keys());
        return [...builtIn, ...custom];
    }
    /**
     * Update system prompt
     */
    setSystemPrompt(prompt) {
        this.config.systemPrompt = prompt;
    }
    /**
     * Get current configuration
     */
    getConfig() {
        return { ...this.config };
    }
}
// ============================================================================
// Factory
// ============================================================================
export function createAgent(config = {}) {
    return new AgentSDK(config);
}
//# sourceMappingURL=agent-sdk.js.map