import type { ClientRole } from '../../../core/runtime/broker-protocol.js'; import type { CanvasSource } from '../../../core/canvas/source.js'; import type { NodeMeta } from '../../../core/canvas/types.js'; import { BrokerClient } from '../../../core/broker-client/index.js'; /** The hello handshake's initial role. A REMOTE attach (`--canvas`) is a * strictly VIEW-ONLY surface — it must claim observer regardless of * `--observer`, never controller. Local attach claims controller unless * `--observer`. Pure so the "remote is always observer" contract is testable * without constructing a real hello/socket. */ export declare function resolveHelloRole(remote: boolean, observer: boolean): ClientRole; /** bootRoot spawns the viewer BEFORE its freshly-launched broker has bound * view.sock, so the viewer's own CLI boot (~0.4s of module load) overlaps the * broker's ~1s startup instead of serializing after it. When that spawner set * CRTR_ATTACH_WAIT_MS, poll the socket with throwaway probe connects until it * accepts or the deadline passes — then fall through and let the normal * one-shot connect race surface the usual BrokerUnavailableError. Without the * env var this is a no-op: a plain `crtr surface attach` keeps its fail-fast * "attach does NOT launch the engine" contract. */ export declare function preWaitForViewSocket(nodeId: string): Promise; /** A connected viewer's transport facts, established before any UI exists. */ export interface AttachConnection { /** THE single remote/read-only fact for the whole session, derived ONCE here * from `--canvas`. Every local disk/SQLite read or write keyed on the node id * gates on this one flag; no collaborator re-derives "is this remote". */ readonly remote: boolean; /** Canvas read authority: an API source locally, a relayed source remotely. */ readonly canvasSource: CanvasSource; /** Viewer-LOCAL concerns only — `cwd` drives theming and this pane's own git * status, and is the CLI's own cwd under `--canvas`. */ readonly meta: Pick; /** The attached node's persona/lifecycle, when this canvas can tell us — * `undefined` for a remote attach until the viewer refetches it. */ readonly nodeIdentity: Pick | undefined; /** The one socket to the node's headless broker, already connected. */ readonly socket: BrokerClient; /** Re-throw a connect-adjacent failure that landed AFTER `connect` resolved. * Call once, synchronously, just before permanent socket wiring takes over; * a no-op if nothing failed. See the never-removed error listener below. */ assertConnected(): void; } /** Resolve the target, revive the node if it is dormant (server-side), and dial * the broker. Rejects with a plain `InputError` — no terminal has been taken * over at this point, so a failure here is an ordinary non-zero CLI exit. */ export declare function connectToNode(nodeId: string, canvasName?: string): Promise;