/** * Defines the host-owned interaction coordinator consumed by connector plugins. * Connectors render prepared deliveries and submit authenticated inbound events; * they never construct a second session authority or execute effects directly. */ import type { InteractionBlock } from "../types/interactions.js"; import type { IAgentRuntime } from "../types/runtime.js"; import type { ConnectorInteractionCapabilityProfile, InteractionNegotiationContext, NegotiatedInteractionDelivery } from "./interaction-profiles.js"; import type { MessageInteractionAuthorizationDecision, MessageInteractionBindings, MessageInteractionEffect, MessageInteractionPurpose, MessageInteractionResponse, MessageInteractionSession } from "./interaction-sessions.js"; export declare const MESSAGE_INTERACTION_HOST_SERVICE: "message_interaction_host"; export interface PrepareMessageInteractionRequest { block: InteractionBlock; profile: ConnectorInteractionCapabilityProfile; bindings: MessageInteractionBindings; purpose: MessageInteractionPurpose; negotiationContext?: InteractionNegotiationContext; presetResponse?: MessageInteractionResponse; authorization: Omit; effect: MessageInteractionEffect; expiresAt: string; } /** Safe subset a connector needs to render; retained authority is omitted. */ export interface PreparedMessageInteraction { block: InteractionBlock; delivery: NegotiatedInteractionDelivery; /** Present only after negotiation validates a signed-hosted delivery URL. */ hostedUrl?: string; callbackData: string; expiresAt: string; profileId: string; } /** Bindings a connector can authenticate from an inbound provider event. */ export type AuthenticatedMessageInteractionBindings = Omit; export interface MessageInteractionProviderReceipt { source: string; accountId: string; inboundEventId: string; receivedAt: string; } export interface MessageInteractionHostEffectResult { receiptId: string; canonicalInboundEventId: string; auditId: string; appStateResult: Readonly>; result: Readonly>; } export interface MessageInteractionHostEffectHandler { execute(args: { idempotencyKey: string; effect: MessageInteractionEffect; response: MessageInteractionResponse; session: MessageInteractionSession; providerReceipt: MessageInteractionProviderReceipt; }): Promise; } export interface MessageInteractionHostReceipt { receiptId: string; idempotencyKey: string; status: "completed"; completedAt: string; canonicalInboundEventId: string; providerReceipt: MessageInteractionProviderReceipt; auditId: string; appStateResult: Readonly>; result: Readonly>; } export type MessageInteractionHostConsumeOutcome = { status: "completed" | "replay"; receipt: MessageInteractionHostReceipt; } | { status: "in_progress"; } | { status: "denied" | "unavailable"; code: string; message: string; }; export interface ConsumeMessageInteractionRequest { callbackData: string; bindings: AuthenticatedMessageInteractionBindings; response?: MessageInteractionResponse; providerReceipt: MessageInteractionProviderReceipt; } export interface MessageInteractionHost { prepare(request: PrepareMessageInteractionRequest): Promise; consume(request: ConsumeMessageInteractionRequest): Promise; revoke(request: { reference: string; decisionId: string; now?: number; }): Promise; get(reference: string): Promise; registerEffectHandler(kind: string, handler: MessageInteractionHostEffectHandler): () => void; } /** Resolve the one host authority. Absence is an explicit unavailable state. */ export declare function resolveMessageInteractionHost(runtime: IAgentRuntime): MessageInteractionHost | null;