import type { Database } from './types.js';
import type { Operation } from '@treecrdt/interface';
import type { TreecrdtAdapter } from '@treecrdt/interface';
import type { OpenTreecrdtDbResult } from './open.js';
import type { RpcInitResult, RpcSqlParams } from './rpc.js';
export declare function openedToRpcInitResult(opened: OpenTreecrdtDbResult): RpcInitResult;
/**
 * Shared wa-sqlite + TreeCRDT adapter state for dedicated or shared worker entrypoints.
 * Lifecycle (`init`, port `close`, `broadcastMaterialized`) stays in each worker file.
 */
export declare class CommonWorkerSession {
    db: Database | null;
    api: TreecrdtAdapter | null;
    storedFilename: string | undefined;
    storedStorage: 'memory' | 'opfs';
    protected onAfterReset(): void;
    applyOpened(opened: OpenTreecrdtDbResult): void;
    closeDbAndReset(): Promise<void>;
    drop(): Promise<null>;
    ensureApi(): TreecrdtAdapter;
    ensureDb(): Database;
    sqlExec(sql: string): Promise<null>;
    sqlGetText(sql: string, params?: RpcSqlParams): Promise<string | null>;
    append(op: Operation): Promise<import("@treecrdt/interface").MaterializationOutcome>;
    appendMany(ops: Operation[]): Promise<import("@treecrdt/interface").MaterializationOutcome>;
    opsSince(lamport: number, root: string | undefined): Promise<unknown[]>;
    opRefsAll(): Promise<unknown[]>;
    opRefsChildren(parent: string): Promise<unknown[]>;
    opsByOpRefs(opRefs: number[][]): Promise<unknown[]>;
    treeChildren(parent: string): Promise<unknown[]>;
    treeChildrenPage(parent: string, cursor: {
        orderKey: number[];
        node: number[];
    } | null, limit: number): Promise<unknown[]>;
    treeDump(): Promise<unknown[]>;
    treePayload(node: string): Promise<number[] | null>;
    treeNodeCount(): Promise<number>;
    treeParent(node: string): Promise<number[] | null>;
    treeExists(node: string): Promise<boolean>;
    headLamport(): Promise<number>;
    replicaMaxCounter(replica: number[]): Promise<number>;
}
/** RPC methods shared by dedicated and shared workers (excluding lifecycle). */
export declare function createCommonWorkerRpcHandlers(session: CommonWorkerSession): {
    readonly sqlExec: (sql: string) => Promise<null>;
    readonly sqlGetText: (sql: string, params?: RpcSqlParams) => Promise<string | null>;
    readonly append: (op: Operation) => Promise<import("@treecrdt/interface").MaterializationOutcome>;
    readonly appendMany: (ops: Operation[]) => Promise<import("@treecrdt/interface").MaterializationOutcome>;
    readonly opsSince: (lamport: number, root?: string) => Promise<unknown[]>;
    readonly opRefsAll: () => Promise<unknown[]>;
    readonly opRefsChildren: (parent: string) => Promise<unknown[]>;
    readonly opsByOpRefs: (opRefs: number[][]) => Promise<unknown[]>;
    readonly treeChildren: (parent: string) => Promise<unknown[]>;
    readonly treeChildrenPage: (parent: string, cursor: {
        orderKey: number[];
        node: number[];
    } | null, limit: number) => Promise<unknown[]>;
    readonly treeDump: () => Promise<unknown[]>;
    readonly treeNodeCount: () => Promise<number>;
    readonly treeParent: (node: string) => Promise<number[] | null>;
    readonly treeExists: (node: string) => Promise<boolean>;
    readonly treePayload: (node: string) => Promise<number[] | null>;
    readonly headLamport: () => Promise<number>;
    readonly replicaMaxCounter: (replica: number[]) => Promise<number>;
};
