"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.workflowSchema = void 0;
const nodeSchema = {
    type: 'object',
    required: ['id'],
    oneOf: [
        { required: ['prompt'], not: { anyOf: [{ required: ['bash'] }, { required: ['command'] }] } },
        { required: ['bash'], not: { anyOf: [{ required: ['prompt'] }, { required: ['command'] }] } },
        { required: ['command'], not: { anyOf: [{ required: ['prompt'] }, { required: ['bash'] }] } },
    ],
    additionalProperties: false,
    properties: {
        id: { type: 'string', minLength: 1 },
        description: { type: 'string' },
        prompt: { type: 'string', minLength: 1 },
        bash: { type: 'string', minLength: 1 },
        command: { type: 'string', minLength: 1 },
        depends_on: { type: 'array', items: { type: 'string' } },
        when: { type: 'string' },
        trigger_rule: { type: 'string', enum: ['all_success', 'one_success'] },
        context: { type: 'string', enum: ['fresh', 'inherit'] },
        model: { type: 'string' },
        workspace: { type: 'boolean' },
        allowed_tools: { type: 'array', items: { type: 'string' } },
        on_error: { type: 'string', enum: ['skip_dependents', 'fail_workflow', 'continue'] },
        output_format: {
            type: 'object',
            required: ['type', 'properties'],
            properties: {
                type: { type: 'string', enum: ['object'] },
                properties: {
                    type: 'object',
                    additionalProperties: {
                        type: 'object',
                        properties: {
                            type: { type: 'string' },
                            enum: { type: 'array', items: { type: 'string' } },
                        },
                    },
                },
                required: { type: 'array', items: { type: 'string' } },
            },
        },
        idempotent: { type: 'boolean' },
        timeout: { type: 'integer', minimum: 1 },
        loop: {
            type: 'object',
            required: ['on_fail', 'max_retries'],
            properties: {
                on_fail: { type: 'string' },
                max_retries: { type: 'integer', minimum: 1 },
                inject_error: { type: 'boolean' },
                backoff_ms: { type: 'integer', minimum: 0 },
            },
            additionalProperties: false,
        },
    },
};
exports.workflowSchema = {
    type: 'object',
    required: ['name', 'nodes'],
    additionalProperties: false,
    properties: {
        name: { type: 'string', minLength: 1 },
        description: { type: 'string' },
        provider: { type: 'string' },
        model: { type: 'string' },
        inputs: {
            type: 'object',
            additionalProperties: {
                type: 'object',
                properties: {
                    type: { type: 'string', enum: ['string', 'number', 'boolean'] },
                    required: { type: 'boolean' },
                    default: { type: 'string' },
                },
            },
        },
        nodes: {
            type: 'array',
            minItems: 1,
            items: nodeSchema,
        },
    },
};
//# sourceMappingURL=workflow-schema.js.map