/**
 * SSE事件类型定义
 * 基于OpenAI Responses协议的事件规范
 */
// 预定义的验证规则
export const SSE_EVENT_VALIDATION_RULES = {
    'response.created': {
        type: 'response.created',
        requiredFields: ['type', 'response'],
        optionalFields: ['timestamp', 'sequence_number'],
        dependencies: [
            {
                field: 'response',
                condition: (e) => !!e.response,
                requiredFields: ['id', 'object', 'created_at', 'status', 'model', 'output', 'previous_response_id']
            }
        ]
    },
    'response.in_progress': {
        type: 'response.in_progress',
        requiredFields: ['type', 'response'],
        optionalFields: ['timestamp', 'sequence_number'],
        dependencies: [
            {
                field: 'response',
                condition: (e) => !!e.response,
                requiredFields: ['id', 'object', 'created_at', 'status', 'model']
            }
        ]
    },
    'response.completed': {
        type: 'response.completed',
        requiredFields: ['type', 'response'],
        optionalFields: ['timestamp', 'sequence_number'],
        dependencies: [
            {
                field: 'response',
                condition: (e) => !!e.response,
                requiredFields: ['id', 'object', 'created_at', 'status', 'model', 'output', 'usage']
            }
        ]
    },
    'response.required_action': {
        type: 'response.required_action',
        requiredFields: ['type', 'response', 'required_action'],
        optionalFields: ['timestamp', 'sequence_number'],
        dependencies: [
            {
                field: 'response',
                condition: (e) => !!e.response,
                requiredFields: ['id', 'object', 'created_at', 'status', 'model']
            },
            {
                field: 'required_action',
                condition: (e) => !!e.required_action,
                requiredFields: ['type', 'submit_tool_outputs']
            }
        ]
    },
    'response.done': {
        type: 'response.done',
        requiredFields: ['type'],
        optionalFields: ['timestamp', 'sequence_number'],
        dependencies: []
    },
    'response.output_item.added': {
        type: 'response.output_item.added',
        requiredFields: ['type', 'output_index', 'item'],
        optionalFields: ['timestamp', 'sequence_number'],
        dependencies: [
            {
                field: 'item',
                condition: (e) => !!e.item,
                requiredFields: ['id', 'type']
            }
        ]
    },
    'response.output_item.done': {
        type: 'response.output_item.done',
        requiredFields: ['type', 'output_index', 'item'],
        optionalFields: ['timestamp', 'sequence_number'],
        dependencies: [
            {
                field: 'item',
                condition: (e) => !!e.item,
                requiredFields: ['id', 'type']
            }
        ]
    },
    'response.content_part.added': {
        type: 'response.content_part.added',
        requiredFields: ['type', 'item_id', 'output_index', 'content_index', 'part'],
        optionalFields: ['timestamp', 'sequence_number'],
        dependencies: [
            {
                field: 'part',
                condition: (e) => !!e.part,
                requiredFields: ['type', 'text']
            }
        ]
    },
    'response.content_part.done': {
        type: 'response.content_part.done',
        requiredFields: ['type', 'item_id', 'output_index', 'content_index', 'part'],
        optionalFields: ['timestamp', 'sequence_number'],
        dependencies: [
            {
                field: 'part',
                condition: (e) => !!e.part,
                requiredFields: ['type', 'text']
            }
        ]
    },
    'response.output_text.delta': {
        type: 'response.output_text.delta',
        requiredFields: ['type', 'item_id', 'output_index', 'content_index', 'delta'],
        optionalFields: ['timestamp', 'sequence_number', 'logprobs'],
        dependencies: []
    },
    'response.output_text.done': {
        type: 'response.output_text.done',
        requiredFields: ['type', 'item_id', 'output_index', 'content_index'],
        optionalFields: ['timestamp', 'sequence_number'],
        dependencies: []
    },
    'response.reasoning_text.delta': {
        type: 'response.reasoning_text.delta',
        requiredFields: ['type', 'item_id', 'output_index', 'content_index', 'delta'],
        optionalFields: ['timestamp', 'sequence_number'],
        dependencies: []
    },
    'response.reasoning_text.done': {
        type: 'response.reasoning_text.done',
        requiredFields: ['type', 'item_id', 'output_index', 'content_index', 'text'],
        optionalFields: ['timestamp', 'sequence_number'],
        dependencies: []
    },
    'response.function_call_arguments.delta': {
        type: 'response.function_call_arguments.delta',
        requiredFields: ['type', 'item_id', 'output_index', 'delta'],
        optionalFields: ['timestamp', 'sequence_number'],
        dependencies: []
    },
    'response.function_call_arguments.done': {
        type: 'response.function_call_arguments.done',
        requiredFields: ['type', 'item_id', 'output_index', 'arguments'],
        optionalFields: ['timestamp', 'sequence_number'],
        dependencies: []
    }
};
