import { AgentUpdateManager } from "../../agents/shared/agent-updates.js";
import { AuditLogStore } from "../../access/audit-log.js";
import { SessionLockStore } from "../../access/session-locks.js";
import { UserStore } from "../../access/user-management.js";
import { RemoteRelayClient } from "../../peers/peer-client.js";
import { RelayArtifactService } from "../../runtime/relay-artifact-service.js";
import { RelayAuthService } from "../../runtime/relay-auth-service.js";
import { BotPreferencesStore } from "../../state/bot-preferences.js";
import { PromptStore } from "../../state/prompt-store.js";
import { WebActivityStore } from "../../web/web-state.js";
import { createChannelBusyStore, createChannelQueueStatusController } from "./channel-bridge-controller.js";
import { ChannelCommandService } from "./channel-command-service.js";
export function createChannelBridgeEnvironment(config, options = {}) {
    return {
        promptStore: new PromptStore(config.workspace, config.stateBackend),
        preferencesStore: new BotPreferencesStore(config.workspace, config.stateBackend),
        activityStore: new WebActivityStore(config.workspace, config.stateBackend, config.auditMaxEvents),
        auditLog: new AuditLogStore(config.workspace, config.stateBackend, config.auditMaxEvents),
        lockStore: new SessionLockStore(config.workspace, config.stateBackend),
        userStore: new UserStore(),
        artifactService: new RelayArtifactService(config),
        authService: new RelayAuthService(config),
        agentUpdates: new AgentUpdateManager(options.agentUpdates),
        commandService: new ChannelCommandService(config),
        busyStates: createChannelBusyStore(options.busyDefaults),
        turnProgress: new Map(),
        draining: new Set(),
        externalMirrors: new Map(),
        queueStatusMessages: options.queueStatus
            ? createChannelQueueStatusController(options.queueStatus)
            : undefined,
        remoteClient: new RemoteRelayClient(),
    };
}
