import { type BrokerTransport, type ParsedArgs } from "@cotal-ai/core"; import { presentationOf, type MaintenanceLock, type Report, type UserAuthInfo } from "@cotal-ai/workspace"; import { type StackJournal, type StackMode, type StackSettlement } from "../lib/stack-journal.js"; import { type StackUserPrepared } from "./stack-user-auth.js"; /** Callbacks into the native broker preparation that `up.ts` owns. They hold private authority * material and are passed in, so this module never re-derives trust or a transport decision. */ export interface StackUpNative { /** `userAuth` asks the native `authSetup` user arm (`prepareServer`) and must return its private * `user` material; any other mode must return none. */ prepareBroker(opts: { transport: BrokerTransport; server: string; space: string; open: boolean; userAuth?: { idpUrl?: string; }; host?: string; storeDir?: string; existingStore?: ExistingStorePin; maxFileStore?: number; channels?: string; seed?: unknown; }): Promise<{ root: string; server: string; space: string; storeDir: string; transport: BrokerTransport; setup?: { creds: string; wsPort: number; }; user?: StackUserPrepared; confPath: string; bin: string; seedFile?: unknown; }>; initializeStreams(server: string, space: string, setup: { creds: string; } | undefined, seedFile: unknown): Promise; recordMesh(entry: { space: string; server: string; root: string; mode: StackMode; tlsRequired: boolean; storeDir: string; userAuth?: UserAuthInfo; maxSessions?: number; attachHost?: string; maxFileStore?: number; }): void; commitTransport(root: string, transport: BrokerTransport): void; } /** The identity of an existing broker store that a start must reuse and never create. */ export interface ExistingStorePin { named: string; path: string; dev: string; ino: string; birthtimeNs: string; } /** Pin a named store that must already exist as a real directory, refusing a missing path, a * non-directory and a symlink. The pin and its rechecks narrow the window in which another local * process can replace the path. They cannot close it: neither Node nor nats-server opens a * directory by identity, and the last recheck still precedes the broker's own open. */ export declare function pinExistingStore(named: string, target: Record): ExistingStorePin; /** Check a pinned store again: the named path must still resolve to the pinned directory. A missing, * replaced or relinked store refuses. */ export declare function recheckExistingStore(pin: ExistingStorePin, target: Record): void; export interface StackUpRequest { /** The root maintenance lock the caller holds for this whole start. Holding it proves no other * whole-stack operation is in flight, which is what lets an unsettled earlier one be settled. */ maintenanceLock: MaintenanceLock; root: string; space: string; server: string; transport: BrokerTransport; runtime: string; noManager: boolean; /** An explicitly requested mode. Omitted keeps the journal's pinned mode, or static auth. */ mode?: StackMode; /** The IdP a first user-auth enable pins (`--idp`); refused outside user mode. */ idp?: string; host?: string; storeDir?: string; maxFileStore?: number; maxSessions?: number; channels?: string; foreground: boolean; presentation: ReturnType; /** A fresh team boot's frozen manifest inputs. `seed` replaces `channels` for the broker's native * channel registry seed. `launchSpec` runs once, after broker (and user auth-service) * preparation and immediately before the manager member is defined, and returns the private * native launch spec the manager service pins by digest. It is never called for a reused manager. */ manifest?: { /** The boot's own retained fresh intent, which is unsettled by design until its summary. Only * this exact ID is exempt from the unsettled-attempt refusal; every other one still refuses. */ deploymentId: string; seed: unknown; launchSpec(context: { root: string; space: string; server: string; mode: StackMode; user?: StackUserPrepared; }): Promise<{ path: string; sha256: string; }>; }; /** Compare-and-swap binding for a team boot that resumes an exact stopped stack: the journal bytes * read by its eligibility gate under the same maintenance lock. Any change before this call's * own read refuses; nothing is re-planned from different records. */ expectPriorDown?: { journalSha256: string; operationId: string; }; } /** The domain outcome of a successful whole-stack start, for a caller that renders its own receipt. * Every refusal, partial or unknown outcome is still thrown as a classified failure. */ export interface StackUpResult { journal: StackJournal; changed: unknown[]; allReused: boolean; /** The manager's pinned launch spec, when this call defined one. */ launch?: { path: string; sha256: string; }; /** A settled active restore of this stack that its retained journal did not fence. */ admittedRestore?: string; /** An earlier operation with no recorded outcome that this call settled before it started. */ settled?: StackSettlement; } /** The mode an invocation explicitly asks for, or none for a bare `up`. */ export declare function requestedStackMode(values: ParsedArgs["values"]): StackMode | undefined; /** A root takes the controller route when it already has a stack journal, or when it is a fresh, * prepared root with nothing legacy, maintenance or team-owned retained under it and the * invocation names only controller-supported inputs. A static-auth request needs an `up` * registration in auth mode or none. An `--open` request needs an open registration or none, and * a root that holds no broker account. A prepared user-auth root uses the same controller with * its native auth service. Anything else keeps the retained path. */ export declare function controllerStackApplies(root: string, space: string, values: ParsedArgs["values"]): boolean; /** `cotal up`'s controller route: start, seed the default persona into the root, then write its * own receipt. The stack is up by then, so a persona that cannot be written is a warning. */ export declare function stackUp(request: StackUpRequest, native: StackUpNative): Promise; /** Start the recorded stack and return its domain result without writing any receipt. */ export declare function startControllerStack(request: StackUpRequest, native: StackUpNative): Promise; /** The member table and evidence text a caller embeds in its own receipt. */ export declare function stackMembersView(journal: StackJournal, title: string): Report; export declare function stackUpForegroundNotice(presentation: ReturnType, space: string): void; //# sourceMappingURL=stack-up.d.ts.map