export function buildChannelRouteContext(input) {
    return {
        channelPlugins: {
            listAccounts: (surface) => input.channelPlugins.listAccounts(surface),
            getAccount: (surface, accountId) => input.channelPlugins.getAccount(surface, accountId),
            getSetupSchema: (surface, accountId) => input.channelPlugins.getSetupSchema(surface, accountId),
            doctor: (surface, accountId) => input.channelPlugins.doctor(surface, accountId),
            listRepairActions: (surface, accountId) => input.channelPlugins.listRepairActions(surface, accountId),
            getLifecycleState: (surface, accountId) => input.channelPlugins.getLifecycleState(surface, accountId),
            migrateLifecycle: (surface, accountId, body) => input.channelPlugins.migrateLifecycle(surface, accountId, body),
            runAccountAction: (surface, action, accountId, body) => input.channelPlugins.runAccountAction(surface, action, accountId, body),
            listCapabilities: (surface) => input.channelPlugins.listCapabilities(surface),
            listTools: (surface) => input.channelPlugins.listTools(surface),
            listAgentTools: (surface) => input.channelPlugins.listAgentTools(surface),
            runTool: (surface, toolId, body) => input.channelPlugins.runTool(surface, toolId, body),
            listOperatorActions: (surface) => input.channelPlugins.listOperatorActions(surface),
            runOperatorAction: (surface, actionId, body) => input.channelPlugins.runOperatorAction(surface, actionId, body),
            resolveTarget: (surface, target) => input.channelPlugins.resolveTarget(surface, target),
            authorizeActorAction: (surface, authz) => input.channelPlugins.authorizeActorAction(surface, authz),
            resolveAllowlist: (surface, allowlist) => input.channelPlugins.resolveAllowlist(surface, allowlist),
            editAllowlist: (surface, allowlist) => input.channelPlugins.editAllowlist(surface, allowlist),
            listStatus: () => input.channelPlugins.listStatus(),
            queryDirectory: (surface, query) => input.channelPlugins.queryDirectory(surface, query),
        },
        channelPolicy: {
            listPolicies: () => input.channelPolicy.listPolicies(),
            upsertPolicy: (surface, policy) => input.channelPolicy.upsertPolicy(surface, policy),
            listAudit: (limit) => input.channelPolicy.listAudit(limit),
        },
        parseJsonBody: input.parseJsonBody,
        parseOptionalJsonBody: input.parseOptionalJsonBody,
        requireAdmin: input.requireAdmin,
        surfaceRegistry: input.surfaceRegistry,
    };
}
export function buildSystemRouteContext(input) {
    const castWatcherRecord = (value) => value;
    return {
        approvalBroker: input.approvalBroker,
        configManager: input.configManager,
        integrationHelpers: input.integrationHelpers,
        inspectInboundTls: input.inspectInboundTls,
        inspectOutboundTls: input.inspectOutboundTls,
        isValidConfigKey: input.isValidConfigKey,
        parseJsonBody: input.parseJsonBody,
        parseOptionalJsonBody: input.parseOptionalJsonBody,
        platformServiceManager: {
            status: () => input.platformServiceManager.status(),
            install: () => input.platformServiceManager.install(),
            start: () => input.platformServiceManager.start(),
            stop: () => input.platformServiceManager.stop(),
            restart: () => input.platformServiceManager.restart(),
            uninstall: () => input.platformServiceManager.uninstall(),
        },
        recordApiResponse: input.recordApiResponse,
        requireAdmin: input.requireAdmin,
        requireAuthenticatedSession: input.requireAuthenticatedSession,
        routeBindings: {
            listBindings: () => input.routeBindings.listBindings(),
            upsertBinding: (binding) => input.routeBindings.upsertBinding(binding),
            patchBinding: (bindingId, patch) => input.routeBindings.patchBinding(bindingId, patch),
            removeBinding: (bindingId) => input.routeBindings.removeBinding(bindingId),
        },
        watcherRegistry: {
            list: () => input.watcherRegistry.list(),
            removeWatcher: (watcherId) => input.watcherRegistry.removeWatcher(watcherId),
            registerWatcher: (watcher) => input.watcherRegistry.registerWatcher(watcher),
            getWatcher: (watcherId) => castWatcherRecord(input.watcherRegistry.getWatcher(watcherId)),
            startWatcher: (watcherId) => castWatcherRecord(input.watcherRegistry.startWatcher(watcherId)),
            stopWatcher: (watcherId, reason) => castWatcherRecord(input.watcherRegistry.stopWatcher(watcherId, reason)),
            runWatcherNow: async (watcherId) => castWatcherRecord(await input.watcherRegistry.runWatcherNow(watcherId)),
        },
    };
}
export function buildKnowledgeRouteContext(input) {
    return {
        configManager: input.configManager,
        inspectGraphqlAccess: input.inspectGraphqlAccess,
        normalizeAtSchedule: input.normalizeAtSchedule,
        normalizeEverySchedule: input.normalizeEverySchedule,
        normalizeCronSchedule: input.normalizeCronSchedule,
        parseJsonBody: input.parseJsonBody,
        parseOptionalJsonBody: input.parseOptionalJsonBody,
        parseJsonText: input.parseJsonText,
        requireAdmin: input.requireAdmin,
        resolveAuthenticatedPrincipal: input.resolveAuthenticatedPrincipal,
        knowledgeService: {
            getStatus: () => input.knowledgeService.getStatus(),
            listSources: (limit) => input.knowledgeService.listSources(limit),
            listNodes: (limit) => input.knowledgeService.listNodes(limit),
            listIssues: (limit) => input.knowledgeService.listIssues(limit),
            getItem: (id) => input.knowledgeService.getItem(id),
            listConnectors: () => input.knowledgeService.listConnectors(),
            getConnector: (id) => input.knowledgeService.getConnector(id),
            doctorConnector: (id) => input.knowledgeService.doctorConnector(id),
            listProjectionTargets: (limit) => input.knowledgeService.listProjectionTargets(limit),
            listExtractions: (limit, sourceId) => input.knowledgeService.listExtractions(limit, sourceId),
            listUsageRecords: (limit, filter) => input.knowledgeService.listUsageRecords(limit, filter),
            listConsolidationCandidates: (limit, filter) => input.knowledgeService.listConsolidationCandidates(limit, filter),
            getConsolidationCandidate: (id) => input.knowledgeService.getConsolidationCandidate(id),
            listConsolidationReports: (limit) => input.knowledgeService.listConsolidationReports(limit),
            getConsolidationReport: (id) => input.knowledgeService.getConsolidationReport(id),
            getExtraction: (id) => input.knowledgeService.getExtraction(id),
            getSourceExtraction: (id) => input.knowledgeService.getSourceExtraction(id),
            listJobs: () => input.knowledgeService.listJobs(),
            getJob: (jobId) => input.knowledgeService.getJob(jobId),
            listJobRuns: (limit, jobId) => input.knowledgeService.listJobRuns(limit, jobId),
            listSchedules: (limit) => input.knowledgeService.listSchedules(limit),
            getSchedule: (id) => input.knowledgeService.getSchedule(id),
            ingestUrl: (body) => input.knowledgeService.ingestUrl(body),
            ingestArtifact: (body) => input.knowledgeService.ingestArtifact(body),
            importBookmarksFromFile: (body) => input.knowledgeService.importBookmarksFromFile(body),
            importUrlsFromFile: (body) => input.knowledgeService.importUrlsFromFile(body),
            ingestConnectorInput: (body) => input.knowledgeService.ingestConnectorInput(body),
            search: (query, limit) => input.knowledgeService.search(query, limit),
            buildPacket: (task, writeScope, limit, options) => input.knowledgeService.buildPacket(task, writeScope, limit, options),
            decideConsolidationCandidate: (id, decision, body) => input.knowledgeService.decideConsolidationCandidate(id, decision, body),
            runJob: (jobId, body) => input.knowledgeService.runJob(jobId, body),
            lint: () => input.knowledgeService.lint(),
            reindex: () => input.knowledgeService.reindex(),
            saveSchedule: (schedule) => input.knowledgeService.saveSchedule(schedule),
            deleteSchedule: (id) => input.knowledgeService.deleteSchedule(id),
            setScheduleEnabled: (id, enabled) => input.knowledgeService.setScheduleEnabled(id, enabled),
            renderProjection: (projection) => input.knowledgeService.renderProjection(projection),
            materializeProjection: (projection) => input.knowledgeService.materializeProjection(projection),
        },
        knowledgeGraphqlService: input.knowledgeGraphqlService,
    };
}
export function buildMediaRouteContext(input) {
    return {
        artifactStore: input.artifactStore,
        configManager: input.configManager,
        mediaProviders: {
            status: () => input.mediaProviders.status(),
            findProvider: (capability, providerId) => input.mediaProviders.findProvider(capability, providerId),
        },
        multimodalService: {
            getStatus: () => input.multimodalService.getStatus(),
            listProviders: () => input.multimodalService.listProviders(),
            analyze: (body) => input.multimodalService.analyze(body),
            buildPacket: (analysis, detail, budgetLimit) => input.multimodalService.buildPacket(analysis, detail, budgetLimit),
            writeBackAnalysis: (analysis, body) => input.multimodalService.writeBackAnalysis(analysis, body),
        },
        parseJsonBody: input.parseJsonBody,
        requireAdmin: input.requireAdmin,
        voiceService: {
            getStatus: (enabled) => input.voiceService.getStatus(enabled),
            listVoices: (providerId) => input.voiceService.listVoices(providerId),
            synthesize: (providerId, body) => input.voiceService.synthesize(providerId, body),
            transcribe: (providerId, body) => input.voiceService.transcribe(providerId, body),
            openRealtimeSession: (providerId, body) => input.voiceService.openRealtimeSession(providerId, body),
        },
        webSearchService: {
            getStatus: () => input.webSearchService.getStatus(),
            search: (body) => input.webSearchService.search(body),
        },
    };
}
export function buildIntegrationRouteContext(input) {
    return input;
}
