import { sdk } from '../sdk' import { configFile } from '../file-models/config.json' const { InputSpec, Value } = sdk // Operator's Parakeet endpoint + which model to request. Both fields // live-reload — change them via this action and the next relay request // picks up the new values without a daemon restart. const inputSpec = InputSpec.of({ relay_parakeet_base_url: Value.text({ name: 'Parakeet Base URL', description: 'URL of the operator\'s Parakeet (or any Whisper-API-compatible) transcription endpoint. Used as the overflow path once a user exceeds their monthly Gemini cap. Leave empty to hard-cap at the Gemini limit. Example: http://192.168.1.87:8000', required: false, default: '', minLength: 0, maxLength: 256, patterns: [ { regex: '^(https?://.+)?$', description: 'Must be empty or start with http:// or https://', }, ], }), relay_parakeet_model: Value.text({ name: 'Parakeet Model Name', description: 'The model identifier sent in upstream requests (the "model" field in the OpenAI Whisper API body). Match whatever name your Parakeet wrapper expects. Default: parakeet-tdt-0.6b-v3', required: true, default: 'parakeet-tdt-0.6b-v3', minLength: 1, maxLength: 128, }), }) export const setParakeetUrl = sdk.Action.withInput( 'set-parakeet-url', async ({ effects }) => ({ name: 'Set Parakeet URL', description: "Optional. Where the relay forwards transcription requests once a user exceeds their monthly Gemini cap. Leave URL empty to disable the operator-hardware fallback.", warning: null, allowedStatuses: 'any', group: null, visibility: 'enabled', }), inputSpec, async ({ effects }) => { const config = await configFile.read().once() return { relay_parakeet_base_url: config?.relay_parakeet_base_url || '', relay_parakeet_model: config?.relay_parakeet_model || 'parakeet-tdt-0.6b-v3', } }, async ({ effects, input }) => { await configFile.merge(effects, { relay_parakeet_base_url: (input.relay_parakeet_base_url || '').trim(), relay_parakeet_model: (input.relay_parakeet_model || 'parakeet-tdt-0.6b-v3').trim(), }) return null }, )