import type { TurnOrigin } from '@xopcai/endpoint-tools-protocol'; import type { Config } from '../../config/schema.js'; import type { InboundAttachmentInput, MediaRef } from '../../channels/attachments/inbound-persist.js'; import { type SessionConfigStore, type SessionStore } from '../../session/index.js'; import type { SessionContext } from '../session/index.js'; import type { AgentInstanceGateway } from '../agent-instance-gateway.js'; import type { CommandHandler } from '../messaging/command-handler.js'; import type { ModelManager } from '../models/index.js'; import { type AgentSourceContext, type AgentSourceContextResolver } from '../source-context/types.js'; import { type TranscriptUserMessage } from '../inbound/attachment-pipeline.js'; import { type WebchatTtsResult } from './webchat-tts.js'; export type DirectStreamInboundAttachment = InboundAttachmentInput; export type ProcessDirectStreamLog = { info: (obj: Record, msg: string) => void; warn: (obj: Record, msg: string) => void; debug?: (obj: Record, msg: string) => void; }; export interface ProcessDirectStreamingDeps { log: ProcessDirectStreamLog; resolveSessionEndpoint: (conversationId: string) => Promise<{ channel: string; chatId: string; }>; initDirectStreamingSession: (conversationId: string, channel: string, chatId: string, origin: TurnOrigin) => SessionContext; registerWebchatStreamPublisher: (conversationId: string, publisher: (event: { type: string; [key: string]: unknown; }) => void) => void; unregisterWebchatStreamPublisher: (conversationId: string) => void; agentManager: AgentInstanceGateway; hydrateSessionWorkspaceFromStore: (conversationId: string) => Promise; hydrateSessionModelFromStore: (conversationId: string) => Promise; sessionStore: SessionStore; modelManager: ModelManager; applyResolvedThinkingLevel: (conversationId: string, thinking?: string | null) => Promise; getConfig: () => Config | undefined; sessionConfigStore: SessionConfigStore; commandHandler: Pick; prepareInboundAttachments: (conversationId: string, attachments?: DirectStreamInboundAttachment[]) => Promise; buildTranscriptUserMessage: (content: string, prepared: MediaRef[] | undefined, conversationId: string, options?: { suppressMediaPromptUris?: ReadonlySet; }) => Promise; recordTaskReviewStreamHint?: (conversationId: string, task: { skipTaskReview: boolean; }) => void; onTurnComplete?: (conversationId: string, lastAssistantText?: string) => void; enqueueProvisionalSessionTitle?: (conversationId: string, userText: string) => void; /** Disk-only transcript sync (slash receipt already streamed as tokens). */ reloadWebchatTranscript?: (conversationId: string) => void; maybeEmitWebchatTts: (conversationId: string, hadInboundVoice: boolean) => Promise<{ type: 'tts_audio'; uri: string; mimeType: string; name: string; } | null>; endDirectRequestContext: () => void; resetSession: (conversationId: string) => Promise<{ transcriptId: string; previousTranscriptId: string; } | null>; sourceContextResolver?: AgentSourceContextResolver; } export interface ProcessDirectStreamingInput { content: string; conversationId?: string; origin: TurnOrigin; attachments?: DirectStreamInboundAttachment[]; thinking?: string; signal?: AbortSignal; runId?: string; sourceContexts?: AgentSourceContext[]; presentation?: 'voice'; /** Delivers durable audio independently of the completed text run. */ onDeferredAudio?: (audio: WebchatTtsResult) => void; } export type ProcessDirectStreamEvent = { type: string; [key: string]: unknown; }; export declare function runProcessDirectStreaming(deps: ProcessDirectStreamingDeps, input: ProcessDirectStreamingInput): AsyncGenerator;