import { type JsonValue } from "../kernel/json.js"; import { type Database } from "../data/database.js"; import { type PreparedAgentInput } from "./context.js"; import { type MemberCursorConfirmation } from "./cursors.js"; import { type Message, type MessageInput } from "./messages.js"; export type DeliveryKind = "ordinary" | "dm"; export interface DeliveryActor { actorKey: string; memberId: string | null; } export interface CapturedDeliverySnapshot { message: { [key: string]: JsonValue; }; origin: "user" | "member" | "system" | "unresolved"; messageType: "chat" | "task_event" | "knowledge_event" | "notification"; senderActorKey: string | null; senderMemberId: string | null; targets: Record; needResponse: DeliveryActor[] | null; } export interface CapturedMessage { scopeId: string; messageId: string; snapshot: CapturedDeliverySnapshot; } export interface DeliveryKey { scopeId: string; messageId: string; targetActorKey: string; deliveryKind: DeliveryKind; } export interface ChatAdmissionToken extends DeliveryKey { sourceRef: string; idempotencyKey: string; cursor: MemberCursorConfirmation | null; } export interface PreparedChatAdmission { memberId: string; sourceRef: string; idempotencyKey: string; input: PreparedAgentInput; replyExpected: boolean; chatToken: ChatAdmissionToken; } export interface MessageAdmissionResult { message: Message; admissions: PreparedChatAdmission[]; } export type ReplyDisposition = "failed" | "cancelled" | "silent" | "broadcast-skipped" | "continuation-exhausted"; export interface ReplyObligation { scopeId: string; messageId: string; actorKey: string; memberId: string | null; reason: "user" | "explicit"; openedAt: number; settledAt: number | null; settledByMessageId: string | null; } export type ReplySelection = { mode: "all-pending"; } | { mode: "reply-target"; messageId: string; }; export declare function readCapture(scope: string, messageId: string, db?: Database): CapturedMessage | null; export declare function listPendingReplies(scope: string, actorKey: string, db?: Database): ReplyObligation[]; export declare function dismissPendingReplies(scope: string, actorKey: string, disposition: ReplyDisposition, diagnosis: string, at: number, messageIds?: string[], db?: Database): number; export declare function settleOwnReply(input: { scopeId: string; replyMessageId: string; actorKey: string; selection: ReplySelection; }, at: number, db?: Database): { applied: boolean; settled: number; }; /** Literal current-name mentions only; code spans/blocks never activate. */ export declare function parseMentions(content: string, members: Array<{ id: string; name: string; }>): { labels: string[]; memberIds: string[]; }; /** Append one message, freeze routing/reply/context facts, and return agent admissions. * The caller invokes agent acceptance for each admission in this same outer SQL * transaction, then calls confirmChatAdmission with the returned input id. */ export declare function appendMessageWithAdmissions(db: Database, source: string, input: MessageInput): MessageAdmissionResult; /** Narrow repair entry: only an explicit durable pending admission can be * retried. Historical captures without this marker and confirmed/terminal work * are never reconstructed from chat history. */ export declare function listPendingChatAdmissions(db: Database): PreparedChatAdmission[]; export declare function repairPendingChatAdmission(db: Database, sourceRef: string, messageId: string, memberId: string): PreparedChatAdmission | null; /** Confirm the queue receipt and cursor in the caller's outer transaction. A * confirmed replay is accepted only with the exact original input id and never * moves a cursor again. */ export declare function confirmChatAdmission(db: Database, token: ChatAdmissionToken, inputId: number, confirmedAt?: number): { confirmed: boolean; cursorConfirmed: boolean; }; //# sourceMappingURL=delivery.d.ts.map