import { createDirectTransportServices, } from '../foundation-services.js';
import { createOperatorClient } from '../operator-client.js';
import { createPeerClient } from '../peer-client.js';
import { createDirectClientTransport } from './direct-client.js';
export { createDirectClientTransport } from './direct-client.js';
export function createDirectTransportFromServices(services) {
    const operator = createOperatorClient(services.operator);
    const peer = createPeerClient(services.peer);
    const transport = createDirectClientTransport(operator, peer);
    return Object.freeze({
        ...transport,
        async snapshot() {
            const [providers] = await Promise.all([
                operator.providers.snapshot(),
            ]);
            return {
                kind: 'direct',
                operator: {
                    currentSession: operator.sessions.current(),
                    tasks: operator.tasks.snapshot(),
                    approvals: operator.approvals.list(),
                    sessions: operator.sessions.list(),
                    controlPlane: operator.controlPlane.snapshot(),
                    providers,
                    shellPaths: operator.shellPaths,
                },
                peer: peer.getSnapshot(),
            };
        },
    });
}
export function createRuntimeDirectTransport(runtimeServices) {
    return createDirectTransportFromServices(createDirectTransportServices(runtimeServices));
}
export function createDirectTransport(runtimeServices) {
    return createRuntimeDirectTransport(runtimeServices);
}
