import { createAssetSummaryContext, summarizeAsset as summarizeAssetFlow, } from "../run/flows/asset/summary.js";
import { createUrlFlowContext, } from "../run/flows/url/types.js";
export function createRunFlowContexts(options) {
    const { cacheState, mediaCache, io, flags, model, runtimeHooks, eventHooks, assetSummaryOverrides, perfTrace = null, } = options;
    const assetSummaryContext = createAssetSummaryContext({
        io: {
            env: io.env,
            envForRun: io.envForRun,
            stdout: io.stdout,
            stderr: io.stderr,
            execFileImpl: io.execFileImpl,
            trackedFetch: io.fetch,
        },
        summary: {
            timeoutMs: flags.timeoutMs,
            preprocessMode: flags.preprocessMode,
            format: flags.format,
            extractMode: flags.extractMode,
            lengthArg: flags.lengthArg,
            forceSummary: flags.forceSummary,
            outputLanguage: flags.outputLanguage,
            videoMode: flags.videoMode,
            transcriptTimestamps: flags.transcriptTimestamps,
            transcriptDiarization: flags.transcriptDiarization,
            speakerIdentification: flags.speakerIdentification,
            configPath: flags.configPath,
            promptOverride: flags.promptOverride,
            lengthInstruction: flags.lengthInstruction,
            languageInstruction: flags.languageInstruction,
            maxOutputTokensArg: flags.maxOutputTokensArg,
            summaryCacheBypass: flags.summaryCacheBypass,
            ...assetSummaryOverrides,
        },
        model: {
            fixedModelSpec: model.fixedModelSpec,
            isFallbackModel: model.isFallbackModel,
            isImplicitAutoSelection: model.isImplicitAutoSelection,
            allowAutoCliFallback: model.allowAutoCliFallback,
            desiredOutputTokens: model.desiredOutputTokens,
            envForAuto: model.envForAuto,
            configForModelSelection: model.configForModelSelection,
            cliAvailability: model.cliAvailability,
            requestedModel: model.requestedModel,
            requestedModelInput: model.requestedModelInput,
            requestedModelLabel: model.requestedModelLabel,
            wantsFreeNamedModel: model.wantsFreeNamedModel,
            isNamedModelSelection: model.isNamedModelSelection,
            summaryEngine: model.summaryEngine,
            summaryStream: model.summaryStream,
            getLiteLlmCatalog: model.getLiteLlmCatalog,
            llmCalls: model.llmCalls,
        },
        output: {
            json: flags.json,
            metricsEnabled: flags.metricsEnabled,
            metricsDetailed: flags.metricsDetailed,
            shouldComputeReport: flags.shouldComputeReport,
            runStartedAtMs: flags.runStartedAtMs,
            verbose: flags.verbose,
            verboseColor: flags.verboseColor,
            streamingEnabled: flags.streamingEnabled,
            plain: flags.plain,
        },
        hooks: {
            writeViaFooter: runtimeHooks.writeViaFooter,
            clearProgressForStdout: runtimeHooks.clearProgressForStdout,
            restoreProgressAfterStdout: runtimeHooks.restoreProgressAfterStdout,
            buildReport: runtimeHooks.buildReport,
            estimateCostUsd: runtimeHooks.estimateCostUsd,
            onSummaryCached: eventHooks?.onSummaryCached ?? null,
        },
        cache: {
            cache: cacheState,
            mediaCache,
        },
        apiStatus: model.apiStatus,
    });
    const summarizeAsset = (args) => summarizeAssetFlow(assetSummaryContext, args);
    return {
        assetSummaryContext,
        summarizeAsset,
        urlFlowContext: createUrlFlowContext({
            io,
            flags,
            model,
            cache: cacheState,
            mediaCache,
            perfTrace,
            runtimeHooks: {
                ...runtimeHooks,
                summarizeAsset,
            },
            eventHooks,
        }),
    };
}
//# sourceMappingURL=flow-contexts.js.map