import type { SessionRecoveryContext } from './mesh-ledger.js';
export declare function readNonEmptyString(value: unknown): string;
export declare function readRecord(value: unknown): Record<string, unknown> | undefined;
/**
 * The relay-safety metadata a worker session must carry so that its completion /
 * generating events route back to the coordinator proactively (without waiting for
 * a mesh_read_chat reconcile). meshCoordinatorDaemonId is the routing anchor the
 * core forwarder (injectMeshSystemMessage) keys on to pick a remote coordinator
 * target; meshNodeFor/meshNodeId identify the worker, and launchedByCoordinator is
 * the delegation proof. See resolveWorkerDelegateRouting().
 */
export interface MeshWorkerRelayStamp {
    meshNodeFor?: string;
    meshNodeId?: string;
    meshCoordinatorDaemonId?: string;
    meshCoordinatorSessionId?: string;
    launchedByCoordinator?: boolean;
}
/**
 * Build the relay-safety stamp from a dispatch's meshContext, only including fields
 * the session does not already carry. Returns undefined when there is nothing new to
 * stamp, so callers can skip a no-op updateSettings() write.
 *
 * This closes the remote-session relay gap: a worker session reached by a dispatch
 * that carries coordinatorDaemonId (mesh_send_task / queue assignment over P2P) gets
 * the coordinator anchor persisted onto its settings at dispatch time, even if it was
 * not launched via mesh_launch_session. Without the stamp the forwarder cannot resolve
 * a remote coordinator and the completion event sits in the pending queue until a
 * read_chat-triggered reconcile drains it.
 */
export declare function buildMeshWorkerRelayStamp(currentSettings: Record<string, unknown> | undefined, meshContext: {
    meshId?: unknown;
    nodeId?: unknown;
    coordinatorDaemonId?: unknown;
    coordinatorSessionId?: unknown;
} | undefined): MeshWorkerRelayStamp | undefined;
export declare function resolveEventSessionId(event: Record<string, unknown>, fallback?: unknown): string;
export declare function readRefineJobId(event: {
    metadataEvent?: Record<string, unknown>;
} | Record<string, unknown>): string;
export declare function readWorkerResultMetadata(event: Record<string, unknown>): Record<string, unknown> | undefined;
/**
 * The worker's final assistant text carried on a completion event — read from
 * `finalSummary` (and the `workerResult.summary` / `result.summary` fallbacks some
 * paths use). Returns '' when the event carries no assistant text (lifecycle events
 * without a summary). Shared by the coordinator chat surface (buildMeshSystemMessage)
 * and the held-event ledger audit record so both read the summary the same way.
 */
export declare function readMeshCompletionSummary(metadataEvent: Record<string, unknown>): string;
export declare function resolveMeshSurfacedSessionPreview(metadataEvent: Record<string, unknown>): {
    preview: string;
    role: 'assistant';
    receivedAt: number;
} | undefined;
export declare function isMissingFinalAssistantDiagnostic(record: Record<string, unknown> | undefined): boolean;
export declare function isFalseIdleCompletion(record: Record<string, unknown>): boolean;
export declare function isWeakCompletionEvidence(record: Record<string, unknown> | undefined): boolean;
export declare function isWeakCompletionMetadata(metadataEvent: Record<string, unknown>): boolean;
export declare function buildMeshSystemMessage(args: {
    event: string;
    nodeLabel: string;
    metadataEvent: Record<string, unknown>;
    recoveryContext?: SessionRecoveryContext | null;
    /**
     * BOOTSTRAP-MSG: true when a queued task targeting this freshly-bootstrapped
     * worktree node is pending/assigned and will be (or has just been) auto-claimed
     * by the post-bootstrap queue re-fire. When set, the worktree_bootstrap_complete
     * message drops the misleading "use mesh_launch_session" advice (which would
     * spawn a DUPLICATE session alongside the auto-claimed one) and tells the
     * coordinator the queue will handle it. Absent/false → no targeted task → keep
     * the manual-launch advice. The caller computes this from the work queue; the
     * builder stays pure so both branches are unit-testable via this flag.
     */
    worktreeHasQueuedTask?: boolean;
}): string;
