import { listHookPointContracts } from '../hooks/index.js';
import { createDirectTransportServices, } from './foundation-services.js';
import { createRuntimeHookApi } from './runtime-hook-api.js';
import { createRuntimeKnowledgeApi } from './runtime-knowledge-api.js';
import { createRuntimeMcpApi } from './runtime-mcp-api.js';
import { createRuntimeOpsApi } from './runtime-ops-api.js';
import { createRuntimeProviderApi } from './runtime-provider-api.js';
import { createDirectTransportFromServices } from './transports/direct.js';
export function createRuntimeFoundationClients(options) {
    const { runtimeServices, tasksReadModel, taskManager, opsControlPlane, getControlPlaneRecentEvents, } = options;
    const transportServices = createDirectTransportServices(runtimeServices, {
        ...(getControlPlaneRecentEvents ? { getControlPlaneRecentEvents } : {}),
    });
    const directTransport = createDirectTransportFromServices(transportServices);
    return {
        transportServices,
        directTransport,
        providerApi: createRuntimeProviderApi(runtimeServices),
        knowledgeApi: createRuntimeKnowledgeApi(runtimeServices),
        hookApi: createRuntimeHookApi({
            dispatcher: {
                listHooks: () => runtimeServices.hookDispatcher.listHooks(),
                listChains: () => runtimeServices.hookWorkbench.listManagedChains(),
            },
            workbench: runtimeServices.hookWorkbench,
            listContracts: () => listHookPointContracts(),
        }),
        mcpApi: createRuntimeMcpApi(runtimeServices.mcpRegistry),
        opsApi: createRuntimeOpsApi({
            tasksReadModel,
            taskManager,
            opsControlPlane,
        }),
    };
}
