import type { LucidClientLike, LucidRawRunner } from '../stores/lucid.js';
/**
 * What one owner (a person/account of this app) holds at one Company: the Company's issuer and
 * domain, the scope granted, and the sealed client state (User ID, DPoP key, Account Token, Session
 * Tokens). `status`: `pending` while signing in, `active` with an Account Token, `revoked` after a
 * disconnect (either side).
 */
export interface PoppyConnectionRecord {
    owner: string;
    issuer: string;
    domain: string;
    organization: string;
    scope: string;
    status: 'pending' | 'active' | 'revoked';
    /** Sealed `CompanyState` of the poppy-client (see `Sealer`). */
    state: string;
    createdAt: number;
    updatedAt: number;
}
/** A sign-in started by the `connect` tool, completed on this app's connect page. */
export interface PoppyPendingConnect {
    /** Unguessable (128 bits): the connect page's URL is a bearer link. */
    id: string;
    owner: string;
    domain: string;
    issuer: string;
    organization: string;
    scope: string;
    /** The actor the turn ran as, to decide the parked call on completion. */
    actor: {
        id: string;
        roles?: string[];
        tenantRef?: string;
    } | null;
    threadId: string | null;
    runId: string | null;
    toolCallId: string | null;
    /** Sealed per-method state (PKCE verifier, mediated sign-in id). Never the credentials. */
    flow: string | null;
    status: 'open' | 'connected' | 'failed';
    expiresAt: number;
    createdAt: number;
}
export interface PoppyConnectionStore {
    listConnections(owner: string): Promise<PoppyConnectionRecord[]>;
    getConnection(owner: string, issuer: string): Promise<PoppyConnectionRecord | null>;
    saveConnection(record: PoppyConnectionRecord): Promise<void>;
    deleteConnection(owner: string, issuer: string): Promise<void>;
    createPending(record: PoppyPendingConnect): Promise<void>;
    getPending(id: string): Promise<PoppyPendingConnect | null>;
    updatePending(id: string, patch: Partial<Pick<PoppyPendingConnect, 'flow' | 'status'>>): Promise<void>;
}
export declare class InMemoryPoppyConnectionStore implements PoppyConnectionStore {
    #private;
    listConnections(owner: string): Promise<{
        owner: string;
        issuer: string;
        domain: string;
        organization: string;
        scope: string;
        status: 'pending' | 'active' | 'revoked';
        /** Sealed `CompanyState` of the poppy-client (see `Sealer`). */
        state: string;
        createdAt: number;
        updatedAt: number;
    }[]>;
    getConnection(owner: string, issuer: string): Promise<{
        owner: string;
        issuer: string;
        domain: string;
        organization: string;
        scope: string;
        status: 'pending' | 'active' | 'revoked';
        /** Sealed `CompanyState` of the poppy-client (see `Sealer`). */
        state: string;
        createdAt: number;
        updatedAt: number;
    } | null>;
    saveConnection(record: PoppyConnectionRecord): Promise<void>;
    deleteConnection(owner: string, issuer: string): Promise<void>;
    createPending(record: PoppyPendingConnect): Promise<void>;
    getPending(id: string): Promise<PoppyPendingConnect | null>;
    updatePending(id: string, patch: Partial<Pick<PoppyPendingConnect, 'flow' | 'status'>>): Promise<void>;
}
export declare const POPPY_CONNECTION_TABLES: {
    readonly connections: 'agent_poppy_connection';
    readonly pending: 'agent_poppy_connect';
};
export declare function poppyConnectionTableStatements(): string[];
export declare function ensurePoppyConnectionTables(db: LucidRawRunner): Promise<void>;
/** {@link PoppyConnectionStore} over Lucid (SQLite / Postgres / MySQL); tables created on first use. */
export declare class LucidPoppyConnectionStore implements PoppyConnectionStore {
    #private;
    private readonly db;
    constructor(db: LucidClientLike & LucidRawRunner, options?: {
        autoCreateTables?: boolean;
    });
    ready(): Promise<void>;
    listConnections(owner: string): Promise<PoppyConnectionRecord[]>;
    getConnection(owner: string, issuer: string): Promise<PoppyConnectionRecord | null>;
    saveConnection(record: PoppyConnectionRecord): Promise<void>;
    deleteConnection(owner: string, issuer: string): Promise<void>;
    createPending(record: PoppyPendingConnect): Promise<void>;
    getPending(id: string): Promise<{
        id: string;
        owner: string;
        domain: string;
        issuer: string;
        organization: string;
        scope: string;
        actor: {
            id: string;
            roles?: string[];
            tenantRef?: string;
        } | null;
        threadId: string | null;
        runId: string | null;
        toolCallId: string | null;
        flow: string | null;
        status: PoppyPendingConnect['status'];
        expiresAt: number;
        createdAt: number;
    } | null>;
    updatePending(id: string, patch: Partial<Pick<PoppyPendingConnect, 'flow' | 'status'>>): Promise<void>;
}
/** The slice of a Redis client {@link redisPoppyConnectionStore} uses (ioredis has it). */
export interface PoppyConnectionRedisClient {
    get(key: string): Promise<string | null>;
    set(key: string, value: string, ...args: (string | number)[]): Promise<unknown>;
    del(...keys: string[]): Promise<unknown>;
    sadd(key: string, ...members: string[]): Promise<unknown>;
    srem(key: string, ...members: string[]): Promise<unknown>;
    smembers(key: string): Promise<string[]>;
}
/** {@link PoppyConnectionStore} over Redis: JSON values, an index set per owner. */
export declare function redisPoppyConnectionStore(redis: PoppyConnectionRedisClient, options?: {
    prefix?: string;
}): PoppyConnectionStore;
//# sourceMappingURL=store.d.ts.map