import { TeamshareApi } from '../lib/api'; export declare function setSpawnWatchScheduler(fn: (agentId: string, wakeType: string) => void): void; /** Flag a real spawn so the watchdog can verify session:start happened. */ export declare function callSpawnWatchScheduler(agentId: string, wakeType: string): void; export declare function setSessionRunningProbe(fn: (agentId: string) => boolean): void; /** True when the agent has a live session (healthy long runs stay quiet). */ export declare function sessionRunningIsActive(agentId: string): boolean; /** Build run state lives here - its existence means a build is in progress. */ export declare const BUILD_STATE_DIR: string; export declare const STOP_DIR: string; export declare const SIGNAL_DIR: string; /** * Write the agent-wide stop file. Honored by the build loop (between tasks) * and by the orchestrator worker (before picking work). Shared by * session.stop / build.stop / tool.stop so a stop always lands immediately. */ export declare function writeAgentStopFile(agentId: string): void; /** * True when the agent has an active stop marker (2026-10). * * A stop is sticky for automation, but it must NOT block the next real run: * callers pair this with a live-session check, so a new session (which clears * the marker on a manual start) can always work. Used by the browser gate to * refuse a surviving harness that outlived its bridge session. */ export declare function hasAgentStopFile(agentId: string): boolean; /** * Clear an agent's local build-run state files and tell the backend those runs * stopped. Without this, a later `question.answered` (which spawns a build * whenever a state file exists) would restart a build the human just stopped, * and the UI would keep showing a live run. Best-effort. */ export declare function clearAgentBuildState(agentId: string, api: TeamshareApi): void; /** * Heartbeat cadence: 2 min keeps every backend kill-threshold at ≥2.5× margin * (liveness TTL 5 min, orphan stale 5 min, zombie silence 15 min). The WS * socket itself marks the agent online/offline, so a beat is only a * lastSeenAt refresher - slow is safe. */ export declare const HEARTBEAT_MS = 120000; /** Bridge-state pushes are cosmetic UI state (busy/queued/projects) - slow * cadence plus push-on-change below keeps idle agents near zero calls. */ export declare const PUSH_STATE_MS: number; /** Per-agent last-sent bridge-state snapshot (push-on-change diff). */ export declare const lastBridgeState: Map; /** Per-agent wall-clock time of the last SENT bridge-state (not just diffed). */ export declare const lastBridgePushAt: Map; /** * While an agent is BUSY, re-push at least this often even when the payload * is byte-identical. The backend gates `busy` on a 5-minute TTL (so a crashed * daemon can't pin a permanent Busy), and push-on-change alone would starve a * long run of refreshes - 60 s keeps a live run well inside the TTL. */ export declare const BUSY_REFRESH_MS = 60000; /** * Stagger counter so N agents never fire their first heartbeat in the * same second (multi-agent flood flattening). */ export declare function nextAgentLoopSeq(): number; /** * Detects a healthy bridge daemon already listening on a candidate port. * Works regardless of who started it (autostart, `start`, detached scripts - * none of which reliably leave a pid file behind). * * Thin delegate to `daemon-instance`, which is the single owner of "is a * daemon running". Kept as a named export because `doctor` and the boot guard * read better with this name. */ export declare function detectRunningDaemon(): Promise<{ port: number; version: string; } | null>; export declare function writeDaemonPidFile(): void; /** * Release daemon ownership on exit. * * The old condition was `if (!current || current === process.pid) rmSync(...)`. * `!current` is true for an EMPTY or unparseable file, so every short-lived * daemon the watchdog spawned - which returns before it ever writes a pid and * therefore can only ever REMOVE - could delete a live daemon's pid file on * `process.on('exit')`. `runningPid()` cannot tell an empty file from a * missing one (`Number('') === 0`), so the watchdog then read "not running" * and started yet another daemon. Ownership is now positive evidence only. */ export declare function clearDaemonPidFile(): void; export declare function readFileSyncSafe(): string; export declare function log(line: string): void; export declare function inQuietHours(quietHours: { start: string; end: string; } | null | undefined): boolean;