"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldsValidationSchema = exports.fields = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const atoms_1 = require("../../../api/schema/atoms");
const zod_1 = __importDefault(require("zod"));
const getTimezones_1 = require("../../../../awell/v1/actions/updatePatient/config/getTimezones");
const sharedActionFields_1 = require("../../../lib/sharedActionFields");
exports.fields = {
    phoneNumber: {
        id: 'phoneNumber',
        label: 'Phone number',
        description: 'The phone number to call.',
        type: extensions_core_1.FieldType.STRING,
        stringType: extensions_core_1.StringType.PHONE,
        required: true,
    },
    webhook: {
        id: 'webhook',
        label: 'Webhook',
        description: 'The webhook to send the call completed event to.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
    },
    task: {
        id: 'task',
        label: 'Task',
        description: 'Provide instructions, relevant information, and examples of the ideal conversation flow.',
        type: extensions_core_1.FieldType.TEXT,
        required: true,
    },
    voice: {
        id: 'voice',
        label: 'Voice',
        description: 'The voice of the AI agent to use. Accepts any form of voice ID, including custom voice clones and voice presets.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
    },
    background_track: {
        id: 'background_track',
        label: 'Background track',
        description: 'Select an audio track that you’d like to play in the background during the call. The audio will play continuously when the agent isn’t speaking, and is incorporated into it’s speech as well.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
        options: {
            dropdownOptions: atoms_1.backgroundTrackOptions,
        },
    },
    first_sentence: {
        id: 'first_sentence',
        label: 'First sentence',
        description: 'Makes your agent say a specific phrase or sentence for it’s first response.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
    },
    wait_for_greeting: {
        id: 'wait_for_greeting',
        label: 'Wait for greeting',
        description: 'When enabled, the agent will wait for the call recipient to speak first before responding.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
        options: {
            dropdownOptions: sharedActionFields_1.dropdownOptionsBoolean,
        },
    },
    block_interruptions: {
        id: 'block_interruptions',
        label: 'Block interruptions',
        description: 'When enabled, the AI will not respond or process interruptions from the user.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
        options: {
            dropdownOptions: sharedActionFields_1.dropdownOptionsBoolean,
        },
    },
    interruption_threshold: {
        id: 'interruption_threshold',
        label: 'Interruption threshold',
        description: 'Adjusts how patient the AI is when waiting for the user to finish speaking. Lower values mean the AI will respond more quickly, while higher values mean the AI will wait longer before responding.',
        type: extensions_core_1.FieldType.NUMERIC,
        required: false,
    },
    model: {
        id: 'model',
        label: 'Model',
        description: 'Select a model to use for your call.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
        options: {
            dropdownOptions: Object.values(atoms_1.ModelSchema.enum).map((model) => ({
                label: model,
                value: model,
            })),
        },
    },
    temperature: {
        id: 'temperature',
        label: 'Temperature',
        description: 'A value between 0 and 1 that controls the randomness of the LLM. 0 will cause more deterministic outputs while 1 will cause more random.',
        type: extensions_core_1.FieldType.NUMERIC,
        required: false,
    },
    dynamic_data: {
        id: 'dynamic_data',
        label: 'Dynamic data',
        description: 'Integrate data from external APIs into your agent’s knowledge.',
        type: extensions_core_1.FieldType.JSON,
        required: false,
    },
    keywords: {
        id: 'keywords',
        label: 'Keywords',
        description: 'Comma-separated list of keywords. These words will be boosted in the transcription engine - recommended for proper nouns or words that are frequently mis-transcribed.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
    },
    pronunciation_guide: {
        id: 'pronunciation_guide',
        label: 'Pronunciation guide',
        description: 'The pronunciation guide is an array of objects that guides the agent on how to say specific words. This is great for situations with complicated terms or names.',
        type: extensions_core_1.FieldType.JSON,
        required: false,
    },
    language: {
        id: 'language',
        label: 'Language',
        description: 'Optimizes transcription, speech, and other inner workings for the specified language. Enter a 2-letter ISO 639-1 code in lowercase, for example: en, es, fr. Defaults to English if not set.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
    },
    local_dialing: {
        id: 'local_dialing',
        label: 'Local dialing',
        description: 'When true, automatically selects a “from” number that matches the callee’s area code for US-based calls. Must have purchased a local dialing add-on.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
        options: {
            dropdownOptions: sharedActionFields_1.dropdownOptionsBoolean,
        },
    },
    voicemail_sms: {
        id: 'voicemail_sms',
        label: 'Voicemail SMS',
        description: 'Configure SMS settings for voicemail notifications.',
        type: extensions_core_1.FieldType.JSON,
        required: false,
    },
    dispatch_hours: {
        id: 'dispatch_hours',
        label: 'Dispatch hours',
        description: 'Restricts calls to certain hours in your timezone.',
        type: extensions_core_1.FieldType.JSON,
        required: false,
    },
    sensitive_voicemail_detection: {
        id: 'sensitive_voicemail_detection',
        label: 'Sensitive voicemail detection',
        description: 'When true, uses LLM-based analysis to detect frequent voicemails.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
        options: {
            dropdownOptions: sharedActionFields_1.dropdownOptionsBoolean,
        },
    },
    noise_cancellation: {
        id: 'noise_cancellation',
        label: 'Noise cancellation',
        description: 'Toggles noise filtering or suppression in the audio stream to filter out background noise.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
        options: {
            dropdownOptions: sharedActionFields_1.dropdownOptionsBoolean,
        },
    },
    ignore_button_press: {
        id: 'ignore_button_press',
        label: 'Ignore button press',
        description: 'When true, DTMF (digit) presses are ignored, disabling menu navigation or call transfers triggered by keypad input.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
        options: {
            dropdownOptions: sharedActionFields_1.dropdownOptionsBoolean,
        },
    },
    timezone: {
        id: 'timezone',
        label: 'Timezone',
        description: 'Set the timezone for the call. Handled automatically for calls in the US.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
        options: {
            dropdownOptions: (0, getTimezones_1.getTimezoneOptions)(),
        },
    },
    tools: {
        id: 'tools',
        label: 'Tools',
        description: 'Interact with the real world through API calls.',
        type: extensions_core_1.FieldType.JSON,
        required: false,
    },
    voicemail_message: {
        id: 'voicemail_message',
        label: 'Voicemail message',
        description: 'When the AI encounters a voicemail, it will leave this message after the beep and then immediately end the call.',
        type: extensions_core_1.FieldType.TEXT,
        required: false,
    },
    voicemail_action: {
        id: 'voicemail_action',
        label: 'Voicemail action',
        description: 'This is processed separately from the AI’s decision making, and overrides it. If voicemail_message is set, then the AI will leave the message regardless of the voicemail_action.',
        type: extensions_core_1.FieldType.JSON,
        required: false,
    },
    retry: {
        id: 'retry',
        label: 'Retry',
        description: 'If the call goes to voicemail, you can set up the call to retry, after a configurable delay.',
        type: extensions_core_1.FieldType.JSON,
        required: false,
    },
    max_duration: {
        id: 'max_duration',
        label: 'Max duration (minutes)',
        description: 'When the call starts, a timer is set for the max_duration minutes. At the end of that timer, if the call is still active it will be automatically ended.',
        type: extensions_core_1.FieldType.NUMERIC,
        required: false,
    },
    record: {
        id: 'record',
        label: 'Record call',
        description: 'When your call completes, you can access through the recording_url field in the call details or your webhook.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
        options: {
            dropdownOptions: sharedActionFields_1.dropdownOptionsBoolean,
        },
    },
    metadata: {
        id: 'metadata',
        label: 'Metadata',
        description: 'Add any additional information you want to associate with the call. This data is accessible for all calls, regardless of if they are picked up or not. This can be used to track calls or add custom data to the call.',
        type: extensions_core_1.FieldType.JSON,
        required: false,
    },
    analysis_preset: {
        id: 'analysis_preset',
        label: 'Analysis preset',
        description: 'The analysis preset UUID used to analyze the call, must be created on the analysis presets page.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
    },
    available_tags: {
        id: 'available_tags',
        label: 'Available tags',
        description: 'Comma-separated list of disposition tags. Upon call completion, the AI will evaluate the transcripts of the call and assign one of the tags to the “disposition_tag” field.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
    },
    geospatial_dialing: {
        id: 'geospatial_dialing',
        label: 'Geospatial dialing',
        description: 'The geospatial dialing pool UUID.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
    },
    precall_dtmf_sequence: {
        id: 'precall_dtmf_sequence',
        label: 'Pre-call DTMF sequence',
        description: 'A sequence of DTMF digits that will be played before the call starts.',
        type: extensions_core_1.FieldType.STRING,
        required: false,
    },
    requestData: {
        id: 'requestData',
        label: 'Request data',
        description: 'Any JSON you put in here will be visible to the AI agent during the call - and can also be referenced with Prompt Variables.',
        type: extensions_core_1.FieldType.JSON,
        required: false,
    },
    analysisSchema: {
        id: 'analysisSchema',
        label: 'Analysis schema',
        description: 'Define a JSON schema for how you want to get information about the call - information like email addresses, names, appointment times or any other type of custom data.',
        type: extensions_core_1.FieldType.JSON,
        required: false,
    },
    otherData: {
        id: 'otherData',
        label: 'Other data',
        description: 'Any fields you put in here will be sent in the request body of the call, but will be overridden by all other fields above if that field is also set.',
        type: extensions_core_1.FieldType.JSON,
        required: false,
    },
    completeExtensionActivityAsync: {
        id: 'completeExtensionActivityAsync',
        label: 'Complete extension activity async',
        description: 'Whether to complete the extension activity async. When true, the extension activity will be completed asynchronously via a webhook.',
        type: extensions_core_1.FieldType.BOOLEAN,
        required: false,
    },
};
exports.FieldsValidationSchema = zod_1.default.object({
    phoneNumber: zod_1.default.string().trim().min(1),
    task: zod_1.default.string().trim().min(1),
    voice: zod_1.default.string().optional(),
    background_track: atoms_1.BackgroundTrackEnum.optional(),
    first_sentence: zod_1.default.string().optional(),
    wait_for_greeting: sharedActionFields_1.dropdownOptionsBooleanSchema.optional(),
    block_interruptions: sharedActionFields_1.dropdownOptionsBooleanSchema.optional(),
    interruption_threshold: zod_1.default.number().optional(),
    model: atoms_1.ModelSchema.optional(),
    temperature: zod_1.default.number().optional(),
    dynamic_data: sharedActionFields_1.JsonArraySchema.optional(),
    keywords: zod_1.default
        .string()
        .transform((val) => val
        .trim()
        .split(',')
        .map((keyword) => keyword.trim()))
        .optional(),
    pronunciation_guide: sharedActionFields_1.JsonArraySchema.optional(),
    language: zod_1.default.string().optional(),
    local_dialing: sharedActionFields_1.dropdownOptionsBooleanSchema.optional(),
    voicemail_sms: sharedActionFields_1.JsonObjectSchema.optional(),
    dispatch_hours: sharedActionFields_1.JsonObjectSchema.optional(),
    sensitive_voicemail_detection: sharedActionFields_1.dropdownOptionsBooleanSchema.optional(),
    noise_cancellation: sharedActionFields_1.dropdownOptionsBooleanSchema.optional(),
    ignore_button_press: sharedActionFields_1.dropdownOptionsBooleanSchema.optional(),
    timezone: zod_1.default.string().optional(),
    tools: sharedActionFields_1.JsonArraySchema.optional(),
    voicemail_message: zod_1.default.string().optional(),
    voicemail_action: atoms_1.VoicemailActionSchema.optional(),
    retry: sharedActionFields_1.JsonObjectSchema.optional(),
    max_duration: zod_1.default.number().optional(),
    webhook: zod_1.default.string().optional(),
    record: sharedActionFields_1.dropdownOptionsBooleanSchema.optional(),
    metadata: sharedActionFields_1.JsonObjectSchema.optional(),
    analysis_preset: zod_1.default.string().optional(),
    available_tags: zod_1.default
        .string()
        .transform((val) => val
        .trim()
        .split(',')
        .map((tag) => tag.trim()))
        .optional(),
    geospatial_dialing: zod_1.default.string().optional(),
    precall_dtmf_sequence: zod_1.default.string().optional(),
    requestData: sharedActionFields_1.JsonObjectSchema.optional(),
    analysisSchema: sharedActionFields_1.JsonObjectSchema.optional(),
    otherData: sharedActionFields_1.JsonObjectSchema.optional(),
    completeExtensionActivityAsync: zod_1.default.boolean().default(false),
});
//# sourceMappingURL=fields.js.map