// Channel plugin contract
export type {
  ChannelPlugin,
  ChannelHandle,
  ChannelRegistry,
  ChannelPluginResolver,
} from './plugin.js';

// What channels call on the core
export type {
  CoreApi,
  HttpMethod,
  LogLevel,
  ChannelSocket,
  ChannelSocketHandler,
  ChannelSessionClaims,
} from './coreApi.js';

// Orchestrator access — the typed, blessed way for a channel to resolve the
// ChatAgent it drives turns with (alternative to CoreApi.handleTurnStream when
// a folded SemanticAnswer / richer control is wanted).
export {
  CHAT_AGENT_SERVICE,
  getChatAgent,
  getChatAgentBundle,
  type ChatAgentBundle,
} from './chatAgentService.js';

// US7 per-binding routing — resolve the *scoped* ChatAgent bound to a turn's
// (channelType, channelKey) via the platform channelResolver. Direct-agent
// channels (Teams, Telegram) MUST call this per turn instead of caching
// getChatAgent(ctx), so each conversation reaches the Agent it was bound to.
export {
  CHANNEL_RESOLVER_SERVICE,
  resolveChatAgentForChannel,
  type ChannelBindingResolver,
  type ChannelResolveResult,
  type ChannelResolveDecision,
} from './channelRouting.js';

// Inbound message shape
export type {
  IncomingTurn,
  ChannelUserRef,
  ChannelUserKind,
  IncomingAttachment,
  PlatformIdentity,
  CanvasViewState,
  CanvasSelection,
} from './incoming.js';

// Orchestrator → channel stream envelope (back-compat re-export)
export type { ChatStreamEvent } from './streamEvent.js';

// Omadia UI canvas surface contracts (omadia-canvas-protocol/1.0). Additive —
// the `surface_*` family is folded into `ChatStreamEvent`; classic channels
// default-ignore it.
export type {
  RevisionId,
  DataRef,
  OutgoingSurface,
  PendingCanvasSurface,
  SurfaceStreamEvent,
  SurfaceSnapshotEvent,
  SurfacePatchEvent,
  SurfaceDataRefCreatedEvent,
  SurfaceDataRefInvalidatedEvent,
  SurfaceActionResultEvent,
  SurfaceLocalActionEvent,
  SurfaceErrorEvent,
  SurfaceMutationResolvedEvent,
} from './surface.js';

// Orchestrator surface contract — lifted from the kernel in S+10-2 so
// channel-plugins-final (S+11) and the orchestrator-plugin (S+10-3/4) can
// consume `ChatAgent` without depending on the concrete Orchestrator class.
export type {
  ChatAgent,
  ChatStreamObserver,
  ChatTurnInput,
  ChatTurnAttachment,
  ChatTurnResult,
  VerifierResultSummary,
  RunTracePayload,
  RunStatus,
  RunToolCall,
  RunAgentInvocation,
  DiagramAttachment,
  OutgoingFileAttachment,
  PendingUserChoice,
  PendingSlotCard,
  PendingRoutineList,
  AgentMeta,
} from './chatAgent.js';

// Conversion helper from kernel-shaped result to channel-agnostic outgoing
// message — lifted from `services/orchestrator.ts` in S+10-2 so channel
// adapters can call it without crossing into kernel internals.
export { toSemanticAnswer } from './toSemanticAnswer.js';

// Semantic outgoing-message contracts (connectors render native)
export type {
  SemanticAnswer,
  OutgoingAttachment,
  VerifierBadge,
  FollowUpOption,
  OutgoingInteractive,
  OutgoingChoiceCard,
  OutgoingSlotPicker,
  OutgoingTopicAsk,
  CaptureDisclosure,
} from './outgoing.js';

// Channel-agnostic store interfaces
export type {
  ConversationTurn,
  ConversationHistoryStore,
  PersistedAttachment,
  AttachmentPutInput,
  AttachmentStore,
} from './stores.js';

// Phase 5B: in-memory implementation channel plugins can construct
// directly. Lifted from `middleware/src/services/conversationHistory.ts`
// so dynamic-imported channels don't depend on a kernel singleton.
export {
  InMemoryConversationHistoryStore,
  type InMemoryConversationHistoryStoreOptions,
  type PendingTopicDecision,
} from './inMemoryConversationHistory.js';

// NO_REPLY sentinel: agent emits this literal when it has nothing to say,
// channel adapters drop the message before forwarding to the provider.
export { NO_REPLY_SENTINEL, isNoReply, logNoReplyDrop } from './noReply.js';

// Phase B+ — channel-key discovery for the /operator/channels dashboard.
// Each channel-kind plugin contributes a ChannelKeyDirectory during
// activate(); the kernel aggregates them and exposes the union over REST.
export type {
  ChannelKeyDirectory,
  ChannelKeyEntry,
} from './channelKeyDirectory.js';
