import * as _ai_matrx_api from '@ai-matrx/api'; import { MatrxTransport, MatrxRuntimeOperationEvent, MatrxRuntimeExecutionStatus } from '@ai-matrx/api'; import { PageAction, Payload, Snapshot, Draft, TransferOutcome, TransferTarget } from '@ai-matrx/alchemy/operate'; import { MatrxStreamEnvelope } from '@ai-matrx/api/stream'; /** Bind once in a host; every menu and declared surface inherits these actions. */ type MatrxTransferDestination = "notes" | "scratch" | "document" | "workbook" | "task" | "attach" | "chat" | "assistant" | "tools" | "code"; interface MatrxTransferContent { label: string; markdown: string; plainText: string; payload: Payload; snapshot: Snapshot; draft: Draft; table?: { name: string; headers: string[]; rows: string[][]; }; signal: AbortSignal; } type MatrxTransferPorts = Partial Promise>>; type MatrxTransferAction = PageAction & { group: "save" | "chat"; hint: string; /** Only these actions are offered for a manually prepared revision. */ prepared: true; }; /** Serializes the captured CURRENT revision, never re-reads the host's source. */ declare function createMatrxTransferActions(ports: MatrxTransferPorts): MatrxTransferAction[]; type MatrxTransferIdentity = { userId: string; organizationId: string; }; type SaveResult = { ok: boolean; id?: string; href?: string; error?: string; }; interface MatrxTransferBindings { getIdentity(): MatrxTransferIdentity; saveNote(content: MatrxTransferContent, folder: string): Promise; saveDocument(content: MatrxTransferContent): Promise; saveWorkbook(content: MatrxTransferContent): Promise; openNotes(content: MatrxTransferContent): void | Promise; openTask(content: MatrxTransferContent): void | Promise; openCode(content: MatrxTransferContent): void | Promise; openAttachment(target: TransferTarget): void | Promise; openChat(content: MatrxTransferContent, mode: "chat" | "assistant" | "tools", identity: MatrxTransferIdentity): void | Promise; } /** Portable workflow and failure semantics; hosts bind only their concrete services and UI openers. */ declare function createMatrxTransferPorts(bindings: MatrxTransferBindings): Required; type MatrxContentTransferStatus = "completed" | "failed" | "cancelled" | "detached" | "unavailable"; interface MatrxContentTransferIdentity { requestId: string; conversationId: string; executionId: string | null; snapshotId: string; sourceId: string; sourceRevision: string; draftRevision: number; } interface MatrxContentTransferProgress { requestId: string | null; conversationId: string; executionId: string | null; status: "starting" | "streaming" | MatrxRuntimeExecutionStatus | "detached"; } interface MatrxContentTransferResult { status: MatrxContentTransferStatus; identity: MatrxContentTransferIdentity | null; /** A new draft only; the caller's original draft remains unchanged. */ draft: Draft | null; /** Human-readable reason for an honest partial/failure/cancelled state. */ message: string | null; } interface MatrxContentTransferDbRow { id: string; content?: unknown; metadata?: unknown; iteration?: number | null; } interface MatrxContentTransferDbResponse { data: MatrxContentTransferDbRow[] | null; error: { message?: string | null; } | null; } interface MatrxContentTransferQuery extends PromiseLike { eq(column: string, value: unknown): this; is(column: string, value: null): this; not(column: string, operator: "is", value: null): this; order(column: string, options: { ascending: boolean; }): this; limit(count: number): this; } interface MatrxContentTransferSupabase { schema(schema: "chat"): { from(table: "request" | "message"): { select(columns: string): MatrxContentTransferQuery; }; }; } interface MatrxContentTransferAdapterOptions { transport: MatrxTransport | (() => MatrxTransport); supabase: MatrxContentTransferSupabase; organizationId: string | (() => string); sourceApp: "matrx-frontend" | "dashboard"; /** * Interactivity attestation for the preparation run. `launch()` is the * Alchemy door a person opens by hand, so "user" is the default and the * server classes the conversation `origin_class = 'human'`; an embedder that * fires a transfer from client code with no gesture behind it passes "auto". * Omitting the field entirely is what left these runs reading as unattested * API traffic (census 2026-09-20). */ initiation?: "user" | "auto"; /** The original NDJSON stream, exposed without consuming it twice. */ onStreamEvent?: (event: MatrxStreamEnvelope) => void; /** Durable runtime lifecycle events emitted during recovery. */ onRuntimeEvent?: (event: MatrxRuntimeOperationEvent, seq: number | null) => void; } interface MatrxContentTransferLaunchInput { snapshot: Snapshot; draft: Draft; instruction: string; signal?: AbortSignal; onProgress?: (progress: MatrxContentTransferProgress) => void; } /** * The mapped-only offered values of `alchemy.prepared_content` (server * `client_mandates.py`), built from facts this launch already holds. Sent by * name beside the four by-name values; the mandate door drops them unless a * binding's consumption map names one, so no current Holder's payload changes. * Absent facts are omitted, never sent empty. */ declare function preparedContentOfferedValues(snapshot: Snapshot, draft: Draft): Record; /** One monotonic generation fences every public launch/recover/rejoin. */ declare function createMatrxContentTransferAdapter(options: MatrxContentTransferAdapterOptions): { launch(input: MatrxContentTransferLaunchInput): Promise; recover(identity: MatrxContentTransferIdentity, source: Draft, onProgress?: MatrxContentTransferLaunchInput["onProgress"], signal?: AbortSignal): Promise; rejoin(identity: MatrxContentTransferIdentity, source: Draft, onProgress?: MatrxContentTransferLaunchInput["onProgress"], signal?: AbortSignal): Promise; cancel(requestId: string): Promise<_ai_matrx_api.MatrxCancelResponse>; }; type MatrxContentTransferAdapter = ReturnType; export { createMatrxContentTransferAdapter, createMatrxTransferActions, createMatrxTransferPorts, preparedContentOfferedValues }; export type { MatrxContentTransferAdapter, MatrxContentTransferAdapterOptions, MatrxContentTransferDbResponse, MatrxContentTransferDbRow, MatrxContentTransferIdentity, MatrxContentTransferLaunchInput, MatrxContentTransferProgress, MatrxContentTransferQuery, MatrxContentTransferResult, MatrxContentTransferStatus, MatrxContentTransferSupabase, MatrxTransferAction, MatrxTransferBindings, MatrxTransferContent, MatrxTransferDestination, MatrxTransferIdentity, MatrxTransferPorts };