/** * consensus/index.ts — Public orchestrator for the consensus layer. * * F-039 — wraps `ByzantineConsensus` behind a stable factory API and * re-exports every type/utility callers need. This is the surface the * SDK callers and future coordination adapters * consume. * * The orchestrator is intentionally minimal — it's a thin facade over * `ByzantineConsensus` plus the type re-exports. Anything fancier * (proposer scheduling, fault reporting, etc.) belongs in `queen.ts` * or a dedicated adapter. */ import { type ByzantineConsensusOpts } from "./byzantine.js"; import { type CommitResult, type ConsensusStatus, type Decision, type ProposeResult, type ProposalSnapshot, type Vote, type VoteResult, type ViewChangeResult } from "./types.js"; export interface CreateConsensusOpts extends Omit { localAgentId: string; peers: string[]; } export interface ConsensusHandle { /** Identity of the local agent (vote short-circuits on its own calls). */ readonly localAgentId: string; /** Read-only snapshot of every proposal the instance has tracked. */ status(): ConsensusStatus; /** Snapshot of a single proposal, or `undefined` if unknown. */ getProposal(proposalId: string): ProposalSnapshot | undefined; /** Initiate pre-prepare for a new proposal. Re-submitting the same * payload under the same view returns the cached proposalId. */ propose(payload: unknown): ProposeResult; /** Cast a vote for a peer during the `prepare` phase. */ castVote(proposalId: string, agentId: string, decision: Decision, signature?: string): VoteResult; /** Transport-friendly entry point — `onPrepare(proposalId, vote)`. */ onPrepare(proposalId: string, vote: Vote): VoteResult; /** Force-commit a proposal (admin override; rare). */ commit(proposalId: string): CommitResult; /** Trigger a view-change; returns the new proposer + view number. */ viewChange(reason: string, proposalId?: string): ViewChangeResult; /** Head of the round-robin proposer schedule. */ getCurrentProposer(): string; /** Current view number (incremented on every view-change). */ getViewNumber(): number; /** Quorum threshold in effect. */ getQuorum(): number; /** Peer roster (read-only copy). */ getPeers(): string[]; } /** * Build a `ConsensusHandle` for a given local agent + peer roster. * The returned object is the public surface used by the MCP tool and * any presentation-layer wiring. */ export declare function createConsensus(opts: CreateConsensusOpts): ConsensusHandle; export { ByzantineConsensus, type ByzantineConsensusOpts } from "./byzantine.js"; export { QueenCoordinator, type QueenCoordinatorOpts } from "./queen.js"; export { DEFAULT_MAX_FAULTS, DEFAULT_PEER_COUNT, DEFAULT_QUORUM, PHASE_ORDER, } from "./types.js"; export type { CommitResult, ConsensusOpts, ConsensusStatus, Decision, Phase, ProposeResult, Proposal, ProposalSnapshot, ProposalStatus, Vote, VoteResult, ViewChangeResult, } from "./types.js"; export declare function getSharedConsensus(): ConsensusHandle; /** Reset the singleton — test/dev only. */ export declare function resetSharedConsensus(): void; //# sourceMappingURL=index.d.ts.map