import type { Identity, OwnIdentity } from '@kokuin/token'; import { KubunDB } from '@kubun/db'; import { NodeSQLiteAdapter } from '@kubun/db-node-sqlite'; import { PostgresAdapter } from '@kubun/db-postgres'; import { KubunEngine } from '@kubun/engine'; /** * The graph a peer device serves its own p2p surface from. * * Deployed with no clusters: a headless peer learns a model from whichever * device already has it (the negotiate response carries the cluster), so * requiring the operator to supply model definitions up front would be asking * for something sync provides. */ export declare const PEER_GRAPH_ID = "kubun-peer"; /** The adapters a CLI device can run on, kept concrete so `@kubun/db-adapter` stays out of the manifest. */ export type PeerAdapter = NodeSQLiteAdapter | PostgresAdapter; export declare function createAdapter(db?: string): PeerAdapter; export type BuildEngineParams = { identity: Identity | OwnIdentity; adapter: PeerAdapter; /** Omit to bind no HTTP listener at all — the hub-only participant. */ http?: { port?: number; allowedOrigin?: string; }; p2p?: { autoAcceptPeers?: Array; }; }; /** * The engine every command builds, with or without an HTTP listener. * * With `http` omitted the p2p plugin also drops its HTTP sync transport, so the * device is reachable only through a group's hub tunnel. That is the whole * difference between the two topologies: hub relay and tunnel dialling are * always wired, and the hub client factory defaults to HTTP on its own. */ export declare function buildEngine(params: BuildEngineParams): { engine: KubunEngine; db: KubunDB; }; /** Deploy the peer graph, which is what carries the p2p mutations. */ export declare function deployPeerGraph(engine: KubunEngine): Promise; /** * Advertise this device to its co-members. * * Presence is opt-in — a device with no local profile publishes nothing and * never appears in another device's projection, so without this call a headless * peer is running and unselectable. */ export declare function announceSelf(engine: KubunEngine, params: { label: string; availability: 'always-on' | 'interactive' | 'mobile'; }): Promise; export type StartNodeParams = BuildEngineParams & { label?: string; }; export type StartedNode = { engine: KubunEngine; /** The device's stores, so a caller can read what the engine wrote. */ db: KubunDB; /** The peer graph's id, or null when p2p is off and none was deployed. */ deployID: string | null; /** Null for a hub-only peer, which binds no listener. */ url: string | null; }; /** * Bring a device up: the engine, its peer graph, and its advertisement. * * `serve` is a thin wrapper over this so a test can start the same device * without a process to signal — the alternative is a test that re-types the * startup and then agrees with itself. */ export declare function startNode(params: StartNodeParams): Promise;