import type { ClarificationSubmission, SecretSubmissionPayload } from '@xopcai/gateway-contract'; import type { McpConversationSetup } from '../agent/mcp/conversation-setup.js'; import type { AgentService } from '../agent/service.js'; import { AutomationService, type AutomationEvent } from '../automations/index.js'; import { CalendarService } from '../calendar/index.js'; import { ManagedBrowserLiveRuntime } from '../browser/managed-live-runtime.js'; import { EmbeddedBrowserGrantRegistry } from '../browser/embedded/grant-registry.js'; import type { BrowserSetupService } from '../browser/setup/service.js'; import { ChatPreviewService } from '../chat-previews/index.js'; import { ChatScheduleService } from '../chat-schedules/index.js'; import { type Config } from '../config/schema.js'; import { ConnectionRecoveryService } from '../connectors/connection-recovery-service.js'; import type { ConnectorLearningCoordinator } from '../connectors/learning-coordinator.js'; import { DiscussionLiveStreamGateway, type DiscussionLiveWorker, type DiscussionOrganizerWorker, type DiscussionSealer, type DiscussionService } from '../discussions/index.js'; import { EndpointToolRuntime, type ArtifactBroker } from '../endpoint-tools/index.js'; import type { ExtensionLoader } from '../extensions/index.js'; import type { HomeIntelligenceHost } from '../home-intelligence/host.js'; import { MessageBus } from '../infra/bus/index.js'; import { LocalAppService, MobileAppBuildCoordinator } from '../local-apps/index.js'; import { NotesService } from '../notes/index.js'; import type { MatterInvestigatorService, ProactiveHubService } from '../proactive-hub/index.js'; import { ProjectService } from '../projects/index.js'; import { ModelCatalogSyncService } from '../providers/model-catalog-sync-service.js'; import { BrowserPreviewRuntime } from '../realtime/browser-preview.js'; import { RealtimeRuntime } from '../realtime/runtime.js'; import { SecretRequests } from '../secrets/index.js'; import type { SelfConfigService, UnifiedSetupSceneService } from '../self-config/index.js'; import { SessionIndex } from '../session/index.js'; import { type ConversationUnreadDomain, type ConversationUnreadReason } from '../storage/sqlite/conversation-unread-repository.js'; import type { TaskConversationRepository } from '../tasks/task-conversation-repository.js'; import { type ProductLanguage } from '../voice/language-profile.js'; import type { VoiceRealtimeRuntime } from '../voice/realtime/runtime.js'; import { WorkDiscoveryService } from '../work-discovery/service.js'; import { type ResolvedGatewayAuth } from './auth.js'; import type { GatewayPrincipal } from './security/gateway-principal.js'; import { GatewayAgentRunner } from './service/agent-runner.js'; import { GatewayMarketplaceService } from './service/marketplace-service.js'; import { SessionPreparationWorker } from './service/session-preparation-worker.js'; import { GatewaySessionsApi } from './service/sessions-api.js'; import type { GatewayServiceConfig } from './service/types.js'; import type { EphemeralSideChatManager, SideChatPromotionService, SideChatRunService } from './side-chat/index.js'; import { type GatewayReadinessSnapshot } from './startup-readiness.js'; export type { GatewayChannelStartupPhase1Metrics, GatewayChannelStartupPhase2Metrics, GatewayServiceConfig, } from './service/types.js'; export declare class GatewayService { private serviceConfig; private bus; private config; private configPath; private _agentService; private channelManager; private automationService; private calendarService; private chatSchedules; private notesService; private sessionIndex; private running; private stopping; private startTime; private workspacePath; private readonly configCoordinator; private readonly setupCoordinator; private readonly channelExtensionCoordinator; private readonly proactiveAutomationCoordinator; private readonly modelCatalogSync; private auth; readonly artifactBroker: ArtifactBroker; readonly endpointTools: EndpointToolRuntime; readonly secretRequests: SecretRequests; private isRealtimePrincipalActive; private readonly managedBrowserRuntimes; readonly embeddedBrowserGrants: EmbeddedBrowserGrantRegistry; readonly browserPreviews: BrowserPreviewRuntime; readonly managedBrowserLive: ManagedBrowserLiveRuntime; readonly realtime: RealtimeRuntime; readonly discussionLiveStreams: DiscussionLiveStreamGateway; readonly voiceRealtime: VoiceRealtimeRuntime; private stopGatewayUpdateCheck; private gatewayShutdownForRestart; private lastDeferredChannelConnectIds; private lastChannelConnectDeferMode; private lastChannelConnectDeferSource; private readonly readiness; private startupTrace; private taskAllocationDispatcher; private mcpRunCallbacks; private taskRunDispatcher; private taskRunDispatchTimer; private notificationService; private stopTaskResultQueued; private stopRealtimeLogBridge; private readonly lastPublishedUnreadFingerprint; readonly agentRunner: GatewayAgentRunner; readonly sessionPreparations: SessionPreparationWorker; readonly sideChats: EphemeralSideChatManager; readonly sideChatRuns: SideChatRunService; readonly sideChatPromotions: SideChatPromotionService; readonly sessions: GatewaySessionsApi; readonly marketplace: GatewayMarketplaceService; readonly projects: ProjectService; private _workDiscovery; readonly discussions: DiscussionService; readonly discussionWorker: DiscussionOrganizerWorker; readonly discussionLiveWorker: DiscussionLiveWorker; readonly discussionSealer: DiscussionSealer; readonly localApps: LocalAppService; readonly mobileAppBuilds: MobileAppBuildCoordinator; readonly chatPreviews: ChatPreviewService; private readonly spaceWorker; private readonly musicGenerationWorker; private readonly imageGenerationWorker; private readonly videoGenerationWorker; private readonly mediaGenerationDelivery; private readonly taskRunDispatch; private readonly taskMainUpdateDispatch; private readonly taskResultDispatch; constructor(serviceConfig?: GatewayServiceConfig); getConfig(): Config; get mcpSetup(): McpConversationSetup; getModelCatalogSync(): ModelCatalogSyncService; get selfConfig(): SelfConfigService; get setupScenes(): UnifiedSetupSceneService; get browserSetup(): BrowserSetupService; get workDiscovery(): WorkDiscoveryService; get agentService(): AgentService; refreshActionTrustPolicy(): void; refreshUserProfileContext(): void; refreshAgentCatalog(): void; private ensureAgentService; private createTaskRunDispatcher; private createNotificationService; dispatchTaskRuns(): void; ensureTaskConversation(taskId: string, options?: { runId?: string; requestedAgentId?: string; }): Promise<{ conversationId: string; agentId: string; created: boolean; conversation: ReturnType; }>; dispatchTaskEvents(): void; runAgent(...args: Parameters): ReturnType; readonly connectionRecovery: ConnectionRecoveryService; retryTask(input: import('../tasks/task-retry-service.js').TaskRetryInput): Promise<{ status: "queued" | "cancelled" | "failed" | "running" | "succeeded" | "not_found" | "waiting" | "verifying" | "blocked" | "waiting_connection" | "changed" | "not_retryable"; taskId?: string | undefined; requestId?: string | undefined; runId?: string | undefined; connectionConversationId?: string | undefined; connectionPhase?: "queued" | "ready" | "needs_connection" | "review_scope" | undefined; reason?: "check_failed" | "other_wait" | "read_scope_unverified" | "account_unavailable" | undefined; }>; submitSessionInput(...args: Parameters): Promise<{ ok: true; effectiveDelivery: import("../storage/sqlite/session-input-repository.js").SessionInputDelivery; state: import("../storage/sqlite/session-input-repository.js").SessionInputState; } | { ok: false; code: "BAD_REQUEST" | "QUEUE_FULL" | "CONTEXT_UNAVAILABLE" | "SESSION_CHANGED"; }>; resumeBrowserAssistance(conversationId: string, waitId: string): void; resumeEmbeddedBrowserAssistance(conversationId: string, waitId: string, grantId: string): void; withSessionInputSubmission(conversationId: string, operation: () => Promise): Promise; prepareSessionCommandInput(input: Parameters[0]): Promise<{ payload?: import("../storage/sqlite/session-input-repository.js").SessionInputPayload | undefined; status: "queued"; requestedDelivery: import("../storage/sqlite/session-input-repository.js").SessionInputDelivery; effectiveDelivery: "next"; content: string; attachments: import("./user-turn-input.js").UserTurnAttachment[] | undefined; contextRefs: import("../agent/source-context/types.js").SourceContextRefSummary[]; interruptRequested: boolean; contextSnapshots: import("../agent/source-context/types.js").AgentSourceContext[]; thinking: string | undefined; origin: { type: "endpoint"; endpointId: string; } | { type: "channel"; channel: string; } | { type: "system"; source: "automation" | "cli" | "task" | "heartbeat" | "internal" | "task_update"; }; }>; drainSessionInputs(conversationId: string): Promise; dispatchAcceptedSessionInput(conversationId: string, inputId: string): Promise; publishSecretRequestsUpdated(requests: readonly import('@xopcai/gateway-contract').SecretRequestView[]): void; private appContextDispatcher; prepareSessionAppContext(input: unknown, principal: GatewayPrincipal, conversationId: string, clientMessageId: string): Promise; replaceLatestSessionTurn(...args: Parameters): Promise<{ ok: false; code: "BAD_REQUEST" | "TARGET_NOT_FOUND" | "NOT_LATEST" | "SESSION_BUSY" | "CONTEXT_UNAVAILABLE" | "ROLLBACK_FAILED"; message?: string; } | { ok: true; effectiveDelivery: "next"; state: import("../storage/sqlite/session-input-repository.js").SessionInputState; }>; controlSessionInputs(...args: Parameters): Promise; getSessionInputState(...args: Parameters): import("../storage/sqlite/session-input-repository.js").SessionInputState; updateSessionInput(...args: Parameters): Promise<{ ok: boolean; state: import("../storage/sqlite/session-input-repository.js").SessionInputState; contextUnavailable?: boolean; }>; removeSessionInput(...args: Parameters): { ok: boolean; state: import("../storage/sqlite/session-input-repository.js").SessionInputState; }; abortAgentRun(runId: string): Promise<{ aborted: boolean; idle: boolean; }>; deliverDelegatedTaskSteer(conversationId: string, inputId: string): Promise; resumeDelegatedRunClarification(wait: import('@xopcai/gateway-contract').ClarificationWait): void; stopDelegatedTaskRun(taskRunId: string): void; getActiveWebchatRunId(conversationId: string): string | undefined; answerEphemeralClarification(requestId: string, answer: ClarificationSubmission): boolean; getClarificationState(conversationId: string, actor?: GatewayPrincipal): import("@xopcai/gateway-contract").ClarificationWaitSnapshot | undefined; resolveClarificationResponse(input: Parameters[0]): import("../storage/sqlite/clarification-wait-repository.js").ResolveClarificationResult; listSecretRequests(conversationId: string, actor?: GatewayPrincipal): Promise<{ requestId: string; conversationId: string; runId: string; toolCallId: string; label: string; reason: string; delivery: "file" | "tool"; status: "cancelled" | "pending" | "saved" | "declined"; supportsReference: boolean; createdAt: number; updatedAt: number; url?: string | undefined; placeholder?: string | undefined; fields?: { id: string; label: string; placeholder?: string | undefined; required?: boolean | undefined; secret?: boolean | undefined; }[] | undefined; expiresAt?: number | undefined; }[] | undefined>; resolveSecretRequestResponse(input: { requestId: string; submission: SecretSubmissionPayload; actor?: GatewayPrincipal; }): Promise<{ ok: true; request: import("@xopcai/gateway-contract").SecretRequestView; } | { ok: false; code: string; message: string; }>; ensureChannelRuntimePlugin(channelId: string): Promise | undefined>; private schedulePostReadySidecars; start(): Promise; private startRuntime; markHttpListening(): void; isGatewayReady(): boolean; getGatewayReadiness(): GatewayReadinessSnapshot; private applyStartupReadyDelayForTesting; private markGatewayReady; private runExposureAutoStartIfConfigured; onHttpListening(): Promise; stop(): Promise; private startOutboundProcessor; reloadConfig(): Promise<{ reloaded: boolean; error?: string; }>; afterWeixinCredentialsPersisted(): Promise; afterFeishuCredentialsPersisted(): Promise; saveConfig(config: Config, expectedConfig?: Config, beforeCommit?: () => void): Promise<{ saved: boolean; error?: string; persisted?: boolean; conflict?: boolean; }>; syncVoiceLanguage(language: ProductLanguage): Promise<{ applied: boolean; language: ProductLanguage; mode: "auto" | "manual"; error?: string; }>; setExtensionActivationTarget(extensionId: string, wanted: boolean): Promise<{ ok: boolean; error?: string; requiresGatewayRestart: boolean; }>; updateConfig(updates: Partial): Promise<{ updated: boolean; error?: string; }>; sendMessage(channel: string, chatId: string, content: string): Promise<{ sent: boolean; messageId?: string; }>; getChannelsStatus(): { name: string; enabled: boolean; connected: boolean; connecting?: boolean; reconnectRequired?: boolean; connectionIssue?: import("../channels/channel-domain.js").ChannelConnectionIssue; connectionIssueAccountId?: string; }[]; getRunningChannelIds(): string[]; getChannelRuntimePlugin(channelId: string): import("../channels/plugin-types.js").ChannelPlugin | undefined; restartChannel(channelId: string): Promise; getChannelsHubMeta(): { id: string; label: string; description: string; manageable: boolean; order: number; }[]; requestConnectorLearning(connectionId: string, request?: Parameters[1]): ReturnType; requestConnectorLearningForToolkit(toolkit: string): ReturnType; setConnectorLearningPaused(connectionId: string, paused: boolean): number; registerGatewayShutdownForRestart(handler: () => Promise): void; triggerGatewayProcessRestart(): { ok: boolean; mode: string; message?: string; }; getHealth(): { status: string; service: string; version: string; uptime: number; ready: boolean; httpListening: boolean; startupDurationMs: number | null; channels: { running: number; total: number; }; configPath: string; logs?: { dir: string; errors24h: number; stats: Record; }; }; get isRunning(): boolean; getExtensionRegistry(): import("../extensions/extension-registry-impl.js").ExtensionRegistryImpl | undefined; getExtensionLoader(): ExtensionLoader | null; getModelRegistry(): any; invokeGatewayMethod(method: string, params: Record): Promise; get currentConfig(): Config; get currentWorkspacePath(): string; get homeIntelligence(): HomeIntelligenceHost; get messageBusInstance(): MessageBus; getEffectiveListenPort(): number; get automationServiceInstance(): AutomationService; get calendarServiceInstance(): CalendarService; get chatScheduleServiceInstance(): ChatScheduleService; get notesServiceInstance(): NotesService; get sessionIndexInstance(): SessionIndex; get proactiveHubInstance(): ProactiveHubService; get matterInvestigatorInstance(): MatterInvestigatorService; processDirect(content: string, conversationId?: string): Promise; publishConversationUnread(conversationId: string, reason: ConversationUnreadReason, fallbackDomain?: ConversationUnreadDomain | null): void; publishAllOrdinaryConversationsRead(): void; emit(type: string, payload: unknown): void; ingestAutomationEvent(event: AutomationEvent, options?: { targetAutomationIds?: string[]; }): import("../automations/index.js").AutomationEventIngestResult; validateAuth(headers?: Record): boolean; getAuthMode(): 'none' | 'token' | 'password' | 'trusted-proxy'; getResolvedAuth(): ResolvedGatewayAuth; getAuthToken(): string | undefined; refreshAuthToken(): Promise; }