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 = "assistant" | "attach" | "chat" | "code" | "document" | "notes" | "scratch" | "task" | "tools" | "workbook"; 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: "chat" | "save"; 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): Promise | void; openTask(content: MatrxTransferContent): Promise | void; openCode(content: MatrxTransferContent): Promise | void; openAttachment(target: TransferTarget): Promise | void; openChat(content: MatrxTransferContent, mode: "assistant" | "chat" | "tools", identity: MatrxTransferIdentity): Promise | void; } /** Portable workflow and failure semantics; hosts bind only their concrete services and UI openers. */ declare function createMatrxTransferPorts(bindings: MatrxTransferBindings): Required; type MatrxContentTransferStatus = "cancelled" | "completed" | "detached" | "failed" | "unavailable"; interface MatrxContentTransferIdentity { requestId: string; conversationId: string; executionId: null | string; snapshotId: string; sourceId: string; sourceRevision: string; draftRevision: number; } interface MatrxContentTransferProgress { requestId: null | string; conversationId: string; executionId: null | string; status: "detached" | "starting" | "streaming" | MatrxRuntimeExecutionStatus; } 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: null | string; } interface MatrxContentTransferDbRow { id: string; content?: unknown; metadata?: unknown; iteration?: null | number; } interface MatrxContentTransferDbResponse { data: MatrxContentTransferDbRow[] | null; error: null | { message?: null | string; }; } 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: "message" | "request"): { select(columns: string): MatrxContentTransferQuery; }; }; } interface MatrxContentTransferAdapterOptions { transport: (() => MatrxTransport) | MatrxTransport; supabase: MatrxContentTransferSupabase; organizationId: (() => string) | string; sourceApp: "dashboard" | "matrx-frontend"; /** * 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?: "auto" | "user"; /** The original NDJSON stream, exposed without consuming it twice. */ onStreamEvent?: (event: MatrxStreamEnvelope) => void; /** Durable runtime lifecycle events emitted during recovery. */ onRuntimeEvent?: (event: MatrxRuntimeOperationEvent, seq: null | number) => 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 };