import type { EffectiveMojoConfig } from './mojo-types.js'; import { type RiffBackendConfig } from './riff-backend.js'; import type { BackendType, PersistentBackendTarget, SessionBackend } from './types.js'; /** * Stable, collision-resistant Herdr agent identity for a Botmux session and * (in production) its canonical Botmux data root. * * Herdr 0.7.5 limits agent names to 32 lowercase ASCII characters. A UUID does * not fit beside the historical `botmux-` prefix verbatim, but its complete * 128-bit value fits in 25 base36 digits (36^25 > 2^128). Non-UUID imported * session ids and data-root-scoped identities use a deterministic 128-bit * SHA-256 prefix instead. */ export declare function managedHerdrAgentName(sessionId: string, ownershipScope?: string): string; /** True only for the strong managed-agent format introduced after the legacy * `botmux-${sessionId.slice(0, 8)}` scheme. Persisted legacy names remain valid * exact targets for reattach/explicit close, but must not be inferred as safe * startup-orphan cleanup authority. */ export declare function isStrongManagedHerdrAgentName(agentName: string): boolean; /** * Retire an old shared-host Herdr agent before a sandbox/MCP incarnation moves * the logical session to its data-root-scoped managed target. * * The durable target stamp is also our cleanup authority. Only the current * strong identity proves that the exact pane belongs to this Botmux session; * persisted legacy short names are safe reattach coordinates, but not enough * authority for automatic destruction. Every close is followed by a probe so * Herdr command failures cannot silently turn into a duplicate CLI. */ export declare function retireSupersededRecordedHerdrTarget(opts: { sessionId: string; ownershipScope?: string; reuseRecordedHerdrTarget: boolean; persistentBackendTarget?: PersistentBackendTarget; }): void; export type BackendGateDecision = { action: 'spawn'; } | { action: 'gate'; reason: string; }; /** * Hard gate (PTY 退役): a requested *persistent* backend (tmux/herdr/zellij/zmx) * that isn't functional on this host no longer silently degrades to raw PTY. * That silent fallback was the root of the "secretly running on PTY, then * hitting all of PTY's problems (no survival across daemon restart, etc.)" * bug class. Instead the worker refuses to spawn and posts an actionable card. * * PTY stays reachable ONLY as an explicit opt-in — `BACKEND_TYPE=pty` or a * per-bot `backendType: 'pty'` — which arrives here as `requested === 'pty'` * and is always allowed straight through. * * `hasExistingSession` lets an already-running persistent session reattach * regardless of a transient functional-probe failure (the known live session * is more authoritative than a separate capability check — see PR#249): * abandoning it would spawn a duplicate CLI and orphan the real conversation. * tmux/zellij capability probes use disposable sessions; ZMX checks its * version and full-list control plane; Herdr uses `herdr --version`. */ export declare function decideBackendGate(opts: { requested: BackendType; available: boolean; hasExistingSession: boolean; }): BackendGateDecision; /** User-facing card shown when {@link decideBackendGate} gates a session. */ export declare function backendGateUserMessage(backend: BackendType, reason: string): string; /** * File/read isolation is currently enforced only when Botmux owns the local * launch wrapper (PTY or tmux). Herdr, Zellij, and ZMX own/spawn the child * outside that bwrap/Seatbelt boundary, so they must fail before backend * selection or migration mutates any live resource. Riff is remote and applies * its own sandbox; local isolation is intentionally bypassed for it. */ export declare function backendSandboxCompatibilityError(opts: { backendType: BackendType; fileSandboxRequested: boolean; /** Compatibility input for callers that still model standalone read * isolation. The worker passes false because its unified sandbox request * already folds in the legacy readIsolation flag on every host. */ effectiveReadIsolationRequested: boolean; /** * mojo only: proof-of-remote inputs. `env` / `jwtEnv` are part of the proof, not * decoration — the launcher env decides which binary actually runs (see * mojoUnprovableEnvKeys), so leaving them out let a redirected launcher pass. */ mojoConfig?: { cloud?: boolean; localDaemon?: boolean; wrapperCli?: string; jwtEnv?: string; env?: Record; }; }): string | undefined; /** Actionable card shown before an incompatible backend/isolation launch fails. */ export declare function backendSandboxCompatibilityUserMessage(reason: string): string; export interface SelectedSessionBackend { backend: SessionBackend; isTmuxMode: boolean; isPipeMode: boolean; /** True for the pty-under-zellij backend. From the worker's POV it behaves * like the non-tmux (pty) path — screenshots via the headless renderer, web * terminal via relay — but it owns a persistent zellij session internally. */ isZellijMode: boolean; persistentSessionName?: string; /** Exact resource owned by this Botmux session; persisted by the daemon. */ persistentBackendTarget?: PersistentBackendTarget; isReattach?: boolean; /** Set when this spawn creates its deterministic Botmux-owned Herdr session. */ createdHerdrSessionName?: string; } export declare function selectSessionBackend(opts: { sessionId: string; backendType: BackendType; backendConfig?: RiffBackendConfig | EffectiveMojoConfig; /** Canonical local ownership boundary used to keep machine-wide Herdr agent * names distinct across independent Botmux data roots/checkouts. */ herdrOwnershipScope?: string; /** Migration compatibility for sessions previously placed in a shared user host. */ reuseRecordedHerdrTarget?: boolean; persistentBackendTarget?: PersistentBackendTarget; hasExistingSession?: boolean; /** Host-persistent journal for fail-closed ZMX composer recovery. */ zmxRecoveryStateDir?: string; }): SelectedSessionBackend; //# sourceMappingURL=session-backend-selector.d.ts.map