import { BOOLEAN_SCHEMA, EMPTY_OBJECT_SCHEMA, NUMBER_SCHEMA, STRING_SCHEMA, bodyEnvelopeSchema, methodDescriptor, objectSchema } from './method-catalog-shared.js';
import { METADATA_SCHEMA } from './operator-contract-schemas-shared.js';
import { ARTIFACT_ENTITY_OUTPUT_SCHEMA, ARTIFACT_LIST_OUTPUT_SCHEMA, MEDIA_ANALYZE_REQUEST_SCHEMA, MEDIA_ANALYSIS_RESULT_SCHEMA, MEDIA_GENERATION_REQUEST_SCHEMA, MEDIA_GENERATION_RESULT_SCHEMA, MEDIA_TRANSFORM_REQUEST_SCHEMA, MEDIA_PROVIDERS_OUTPUT_SCHEMA, MEDIA_TRANSFORM_RESULT_SCHEMA, MULTIMODAL_ANALYZE_REQUEST_SCHEMA, MULTIMODAL_ANALYZE_OUTPUT_SCHEMA, MULTIMODAL_PACKET_REQUEST_SCHEMA, MULTIMODAL_PACKET_OUTPUT_SCHEMA, MULTIMODAL_PROVIDERS_OUTPUT_SCHEMA, MULTIMODAL_STATUS_SCHEMA, MULTIMODAL_WRITEBACK_REQUEST_SCHEMA, MULTIMODAL_WRITEBACK_OUTPUT_SCHEMA, VOICE_REALTIME_SESSION_REQUEST_SCHEMA, VOICE_SYNTHESIS_REQUEST_SCHEMA, VOICE_TRANSCRIPTION_REQUEST_SCHEMA, VOICE_PROVIDERS_OUTPUT_SCHEMA, VOICE_REALTIME_SESSION_SCHEMA, VOICE_STATUS_SCHEMA, VOICE_SYNTHESIS_RESULT_SCHEMA, VOICE_TRANSCRIPTION_RESULT_SCHEMA, VOICE_VOICES_OUTPUT_SCHEMA, WEB_SEARCH_PROVIDERS_OUTPUT_SCHEMA, WEB_SEARCH_RESPONSE_SCHEMA, } from './operator-contract-schemas.js';
export const builtinGatewayMediaMethodDescriptors = [
    methodDescriptor({
        id: 'voice.status',
        title: 'Voice Status',
        description: 'Return configured voice provider posture and capabilities.',
        category: 'voice',
        scopes: ['read:voice'],
        http: { method: 'GET', path: '/api/voice' },
        inputSchema: EMPTY_OBJECT_SCHEMA,
        outputSchema: VOICE_STATUS_SCHEMA,
    }),
    methodDescriptor({
        id: 'voice.providers.list',
        title: 'List Voice Providers',
        description: 'Return registered voice providers.',
        category: 'voice',
        scopes: ['read:voice'],
        http: { method: 'GET', path: '/api/voice/providers' },
        inputSchema: EMPTY_OBJECT_SCHEMA,
        outputSchema: VOICE_PROVIDERS_OUTPUT_SCHEMA,
    }),
    methodDescriptor({
        id: 'voice.voices.list',
        title: 'List Voices',
        description: 'Return registered voices for a voice provider.',
        category: 'voice',
        scopes: ['read:voice'],
        http: { method: 'GET', path: '/api/voice/voices' },
        inputSchema: objectSchema({ providerId: STRING_SCHEMA }),
        outputSchema: VOICE_VOICES_OUTPUT_SCHEMA,
    }),
    methodDescriptor({
        id: 'voice.tts',
        title: 'Run Text To Speech',
        description: 'Synthesize audio through a registered voice provider.',
        category: 'voice',
        scopes: ['write:voice'],
        http: { method: 'POST', path: '/api/voice/tts' },
        inputSchema: VOICE_SYNTHESIS_REQUEST_SCHEMA,
        outputSchema: VOICE_SYNTHESIS_RESULT_SCHEMA,
    }),
    methodDescriptor({
        id: 'voice.stt',
        title: 'Run Speech To Text',
        description: 'Transcribe an audio artifact through a registered voice provider.',
        category: 'voice',
        scopes: ['write:voice'],
        http: { method: 'POST', path: '/api/voice/stt' },
        inputSchema: VOICE_TRANSCRIPTION_REQUEST_SCHEMA,
        outputSchema: VOICE_TRANSCRIPTION_RESULT_SCHEMA,
    }),
    methodDescriptor({
        id: 'voice.realtime.session',
        title: 'Open Voice Realtime Session',
        description: 'Open a realtime voice session through a registered voice provider.',
        category: 'voice',
        scopes: ['write:voice'],
        http: { method: 'POST', path: '/api/voice/realtime/session' },
        inputSchema: VOICE_REALTIME_SESSION_REQUEST_SCHEMA,
        outputSchema: VOICE_REALTIME_SESSION_SCHEMA,
    }),
    methodDescriptor({
        id: 'web_search.providers.list',
        title: 'List Web Search Providers',
        description: 'Return registered web search provider capabilities.',
        category: 'web-search',
        scopes: ['read:web-search'],
        http: { method: 'GET', path: '/api/web-search/providers' },
        inputSchema: EMPTY_OBJECT_SCHEMA,
        outputSchema: WEB_SEARCH_PROVIDERS_OUTPUT_SCHEMA,
    }),
    methodDescriptor({
        id: 'web_search.query',
        title: 'Run Web Search',
        description: 'Execute a provider-backed web search and return normalized ranked results.',
        category: 'web-search',
        scopes: ['write:web-search'],
        http: { method: 'POST', path: '/api/web-search/query' },
        inputSchema: bodyEnvelopeSchema({
            query: STRING_SCHEMA,
            providerId: STRING_SCHEMA,
            maxResults: NUMBER_SCHEMA,
            verbosity: STRING_SCHEMA,
            region: STRING_SCHEMA,
            safeSearch: STRING_SCHEMA,
            timeRange: STRING_SCHEMA,
            includeInstantAnswer: BOOLEAN_SCHEMA,
            includeEvidence: BOOLEAN_SCHEMA,
            evidenceTopN: NUMBER_SCHEMA,
            evidenceExtract: STRING_SCHEMA,
        }, ['query']),
        outputSchema: WEB_SEARCH_RESPONSE_SCHEMA,
    }),
    methodDescriptor({
        id: 'artifacts.list',
        title: 'List Artifacts',
        description: 'Return stored artifact metadata for files and attachments.',
        category: 'artifacts',
        scopes: ['read:artifacts'],
        http: { method: 'GET', path: '/api/artifacts' },
        inputSchema: EMPTY_OBJECT_SCHEMA,
        outputSchema: ARTIFACT_LIST_OUTPUT_SCHEMA,
    }),
    methodDescriptor({
        id: 'artifacts.create',
        title: 'Create Artifact',
        description: 'Store a file or attachment artifact for later delivery or analysis.',
        category: 'artifacts',
        scopes: ['write:artifacts'],
        http: { method: 'POST', path: '/api/artifacts' },
        inputSchema: bodyEnvelopeSchema({
            kind: STRING_SCHEMA,
            mimeType: STRING_SCHEMA,
            filename: STRING_SCHEMA,
            dataBase64: STRING_SCHEMA,
            text: STRING_SCHEMA,
            path: STRING_SCHEMA,
            uri: STRING_SCHEMA,
            allowPrivateHosts: BOOLEAN_SCHEMA,
            retentionMs: NUMBER_SCHEMA,
            metadata: METADATA_SCHEMA,
        }),
        outputSchema: ARTIFACT_ENTITY_OUTPUT_SCHEMA,
    }),
    methodDescriptor({
        id: 'artifacts.get',
        title: 'Get Artifact',
        description: 'Return metadata for a stored artifact.',
        category: 'artifacts',
        scopes: ['read:artifacts'],
        http: { method: 'GET', path: '/api/artifacts/{artifactId}' },
        inputSchema: objectSchema({ artifactId: STRING_SCHEMA }, ['artifactId']),
        outputSchema: ARTIFACT_ENTITY_OUTPUT_SCHEMA,
    }),
    methodDescriptor({
        id: 'artifacts.content.get',
        title: 'Get Artifact Content',
        description: 'Return the raw content bytes for a stored artifact.',
        category: 'artifacts',
        scopes: ['read:artifacts'],
        transport: ['http'],
        http: { method: 'GET', path: '/api/artifacts/{artifactId}/content' },
        inputSchema: objectSchema({
            artifactId: STRING_SCHEMA,
            download: STRING_SCHEMA,
        }, ['artifactId']),
        outputSchema: objectSchema({
            contentType: STRING_SCHEMA,
            contentLength: NUMBER_SCHEMA,
        }, ['contentType', 'contentLength']),
        invokable: false,
        metadata: { responseKind: 'binary' },
    }),
    methodDescriptor({
        id: 'media.providers.list',
        title: 'List Media Providers',
        description: 'Return registered media provider capabilities.',
        category: 'media',
        scopes: ['read:media'],
        http: { method: 'GET', path: '/api/media/providers' },
        inputSchema: EMPTY_OBJECT_SCHEMA,
        outputSchema: MEDIA_PROVIDERS_OUTPUT_SCHEMA,
    }),
    methodDescriptor({
        id: 'media.analyze',
        title: 'Analyze Media Artifact',
        description: 'Analyze an artifact through a registered media provider.',
        category: 'media',
        scopes: ['write:media'],
        http: { method: 'POST', path: '/api/media/analyze' },
        inputSchema: MEDIA_ANALYZE_REQUEST_SCHEMA,
        outputSchema: MEDIA_ANALYSIS_RESULT_SCHEMA,
    }),
    methodDescriptor({
        id: 'media.transform',
        title: 'Transform Media Artifact',
        description: 'Transform an artifact through a registered media provider.',
        category: 'media',
        scopes: ['write:media'],
        http: { method: 'POST', path: '/api/media/transform' },
        inputSchema: MEDIA_TRANSFORM_REQUEST_SCHEMA,
        outputSchema: MEDIA_TRANSFORM_RESULT_SCHEMA,
    }),
    methodDescriptor({
        id: 'media.generate',
        title: 'Generate Media Artifact',
        description: 'Generate a media artifact through a registered media provider.',
        category: 'media',
        scopes: ['write:media'],
        http: { method: 'POST', path: '/api/media/generate' },
        inputSchema: MEDIA_GENERATION_REQUEST_SCHEMA,
        outputSchema: MEDIA_GENERATION_RESULT_SCHEMA,
    }),
    methodDescriptor({
        id: 'multimodal.status',
        title: 'Multimodal Status',
        description: 'Return the unified multimodal runtime status across image, audio, video, and document analysis.',
        category: 'media',
        scopes: ['read:media'],
        http: { method: 'GET', path: '/api/multimodal' },
        inputSchema: EMPTY_OBJECT_SCHEMA,
        outputSchema: MULTIMODAL_STATUS_SCHEMA,
    }),
    methodDescriptor({
        id: 'multimodal.providers.list',
        title: 'List Multimodal Providers',
        description: 'Return the normalized multimodal provider catalog spanning media understanding, speech-to-text, and extractors.',
        category: 'media',
        scopes: ['read:media'],
        http: { method: 'GET', path: '/api/multimodal/providers' },
        inputSchema: EMPTY_OBJECT_SCHEMA,
        outputSchema: MULTIMODAL_PROVIDERS_OUTPUT_SCHEMA,
    }),
    methodDescriptor({
        id: 'multimodal.analyze',
        title: 'Run Multimodal Analysis',
        description: 'Analyze an image, audio file, video artifact, or document through the unified multimodal service.',
        category: 'media',
        scopes: ['write:media'],
        http: { method: 'POST', path: '/api/multimodal/analyze' },
        inputSchema: MULTIMODAL_ANALYZE_REQUEST_SCHEMA,
        outputSchema: MULTIMODAL_ANALYZE_OUTPUT_SCHEMA,
    }),
    methodDescriptor({
        id: 'multimodal.packet',
        title: 'Build Multimodal Packet',
        description: 'Build a token-efficient packet from an existing multimodal analysis result.',
        category: 'media',
        scopes: ['read:media'],
        http: { method: 'POST', path: '/api/multimodal/packet' },
        inputSchema: MULTIMODAL_PACKET_REQUEST_SCHEMA,
        outputSchema: MULTIMODAL_PACKET_OUTPUT_SCHEMA,
    }),
    methodDescriptor({
        id: 'multimodal.writeback',
        title: 'Write Back Multimodal Analysis',
        description: 'Persist a multimodal analysis result as an artifact and ingest it into the structured knowledge store.',
        category: 'media',
        scopes: ['write:media', 'write:knowledge'],
        access: 'admin',
        http: { method: 'POST', path: '/api/multimodal/writeback' },
        inputSchema: MULTIMODAL_WRITEBACK_REQUEST_SCHEMA,
        outputSchema: MULTIMODAL_WRITEBACK_OUTPUT_SCHEMA,
    }),
];
