"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AiFinishReasonSchema = exports.AiRoleSchema = exports.AiProviderSchema = exports.AiOperationStatus = exports.AiErrorSchema = exports.StreamingChatResponseSchema = exports.ChatResponseSchema = exports.ChatRequestSchema = exports.MessageSchema = exports.AiConfigSchema = void 0;
const zod_1 = require("zod");
/**
 * Base configuration for AI operations
 */
exports.AiConfigSchema = zod_1.z.object({
    provider: zod_1.z.enum(['openai', 'anthropic', 'azure', 'local']),
    model: zod_1.z.string(),
    temperature: zod_1.z.number().min(0).max(2).optional(),
    maxTokens: zod_1.z.number().positive().optional(),
    stream: zod_1.z.boolean().optional(),
    systemPrompt: zod_1.z.string().optional(),
});
/**
 * Message structure for chat operations
 */
exports.MessageSchema = zod_1.z.object({
    role: zod_1.z.enum(['system', 'user', 'assistant', 'function']),
    content: zod_1.z.string(),
    name: zod_1.z.string().optional(),
    function_call: zod_1.z.object({
        name: zod_1.z.string(),
        arguments: zod_1.z.string(),
    }).optional(),
});
/**
 * Chat completion request
 */
exports.ChatRequestSchema = exports.AiConfigSchema.extend({
    messages: zod_1.z.array(exports.MessageSchema),
    functions: zod_1.z.array(zod_1.z.object({
        name: zod_1.z.string(),
        description: zod_1.z.string().optional(),
        parameters: zod_1.z.record(zod_1.z.unknown()),
    })).optional(),
});
/**
 * Chat completion response
 */
exports.ChatResponseSchema = zod_1.z.object({
    id: zod_1.z.string(),
    model: zod_1.z.string(),
    created: zod_1.z.number(),
    choices: zod_1.z.array(zod_1.z.object({
        index: zod_1.z.number(),
        message: exports.MessageSchema,
        finish_reason: zod_1.z.enum(['stop', 'length', 'function_call', 'content_filter']).optional(),
    })),
    usage: zod_1.z.object({
        prompt_tokens: zod_1.z.number(),
        completion_tokens: zod_1.z.number(),
        total_tokens: zod_1.z.number(),
    }).optional(),
});
/**
 * Streaming chat completion response
 */
exports.StreamingChatResponseSchema = zod_1.z.object({
    id: zod_1.z.string(),
    model: zod_1.z.string(),
    created: zod_1.z.number(),
    choices: zod_1.z.array(zod_1.z.object({
        index: zod_1.z.number(),
        delta: zod_1.z.object({
            role: zod_1.z.enum(['system', 'user', 'assistant', 'function']).optional(),
            content: zod_1.z.string().optional(),
            function_call: zod_1.z.object({
                name: zod_1.z.string().optional(),
                arguments: zod_1.z.string().optional(),
            }).optional(),
        }),
        finish_reason: zod_1.z.enum(['stop', 'length', 'function_call', 'content_filter']).optional(),
    })),
});
/**
 * Error response from AI operations
 */
exports.AiErrorSchema = zod_1.z.object({
    code: zod_1.z.string(),
    message: zod_1.z.string(),
    details: zod_1.z.record(zod_1.z.unknown()).optional(),
});
/**
 * Status of an AI operation
 */
var AiOperationStatus;
(function (AiOperationStatus) {
    AiOperationStatus["IDLE"] = "idle";
    AiOperationStatus["LOADING"] = "loading";
    AiOperationStatus["STREAMING"] = "streaming";
    AiOperationStatus["SUCCESS"] = "success";
    AiOperationStatus["ERROR"] = "error";
})(AiOperationStatus || (exports.AiOperationStatus = AiOperationStatus = {}));
exports.AiProviderSchema = zod_1.z.enum(['openai', 'anthropic', 'azure', 'local']);
exports.AiRoleSchema = zod_1.z.enum(['system', 'user', 'assistant', 'function']);
exports.AiFinishReasonSchema = zod_1.z.enum(['stop', 'length', 'function_call', 'content_filter']);
//# sourceMappingURL=ai.js.map