export declare const SUBAGENT_TRACKING_SCHEMA_VERSION = 1; export declare const DEFAULT_SUBAGENT_ACTIVE_WINDOW_MS = 120000; export declare const NATIVE_SUBAGENT_PROVENANCE = "native_subagent"; export declare const DESCRIPTIVE_ADAPTED_PROVENANCE = "adapted"; export type SubagentAvailabilityStatus = 'available' | 'closed' | 'unavailable'; export interface TrackedSubagentThread { thread_id: string; kind: 'leader' | 'subagent'; first_seen_at: string; last_seen_at: string; completed_at?: string; last_turn_id?: string; last_completed_turn_id?: string; turn_count: number; mode?: string; role?: string; provenance_kind?: string; lane_id?: string; scope?: string; agent_nickname?: string; completion_source?: string; status?: SubagentAvailabilityStatus; last_handoff_summary?: string; resume_requested_at?: string; resume_completed_at?: string; resume_failed_at?: string; resume_failure_reason?: string; direct_child_root_id?: string; direct_child_parent_id?: string; reopen_authority_revoked?: boolean; reopen_authority_conflict_reason?: string; reopen_authority_conflict_at?: string; } export interface TrackedSubagentSession { session_id: string; leader_thread_id?: string; updated_at: string; threads: Record; } export interface SubagentTrackingState { schemaVersion: 1; sessions: Record; } export interface RecordSubagentTurnInput { sessionId: string; threadId: string; turnId?: string; timestamp?: string; mode?: string; role?: string; provenanceKind?: string; laneId?: string; scope?: string; agentNickname?: string; kind?: 'leader' | 'subagent'; leaderThreadId?: string; completed?: boolean; completionSource?: string; status?: SubagentAvailabilityStatus; lastHandoffSummary?: string; resumeRequestedAt?: string; resumeCompletedAt?: string; resumeFailedAt?: string; resumeFailureReason?: string; preserveCompletionEvidence?: boolean; } export interface NativeSubagentAuthorityObservation { sessionIds: string[]; childThreadId: string; parentThreadId: string; rootNativeSessionId?: string; authorityEvidence?: 'valid' | 'untrusted' | 'absent'; implicatedChildThreadIds?: string[]; mode?: string; timestamp?: string; } export interface SubagentSessionSummary { sessionId: string; leaderThreadId?: string; allThreadIds: string[]; allSubagentThreadIds: string[]; activeSubagentThreadIds: string[]; savedSubagents: SubagentResumeEntry[]; updatedAt?: string; } export interface SubagentResumeEntry { agentId: string; threadId: string; role?: string; laneId?: string; scope?: string; agentNickname?: string; status: SubagentAvailabilityStatus; } export interface SubagentLedgerEntry extends SubagentResumeEntry { lastSeenAt?: string; completedAt?: string; lastHandoffSummary?: string; resumeRequestedAt?: string; resumeCompletedAt?: string; resumeFailedAt?: string; resumeFailureReason?: string; } export interface SubagentResumeLedger extends SubagentSessionSummary { savedSubagents: SubagentLedgerEntry[]; resumeTargets: SubagentLedgerEntry[]; unavailableSubagents: SubagentLedgerEntry[]; } export declare function subagentTrackingPath(cwd: string): string; export declare function resolveInstalledRoleName(role: string, codexHomeOverride?: string, projectRootOverride?: string): string | null; export declare function createSubagentTrackingState(): SubagentTrackingState; export declare function isTrustedSubagentThread(session: TrackedSubagentSession | null | undefined, threadId: string): boolean; export declare function normalizeSubagentTrackingState(input: unknown): SubagentTrackingState; export declare const DEFAULT_CROSS_PROCESS_LOCK_MAX_ATTEMPTS = 80; export declare const DEFAULT_CROSS_PROCESS_LOCK_RETRY_MS = 2; export declare const CROSS_PROCESS_LOCK_LEASE_MS = 60000; export type CrossProcessFileLockContext = { assertOwnership(): void; publish(contents: string): void; }; export declare class CrossProcessLockLostError extends Error { constructor(lockPath: string); } export declare function crossProcessLockPath(resourcePath: string): string; export declare function readProcessStartIdentity(pid: number): string | undefined; export declare const CROSS_PROCESS_LOCK_ARTIFACT_SWEEP_CAP = 64; export declare function __setCrossProcessPublishBarrierForTest(barrier: (() => void) | null): void; export declare function __setCrossProcessQuarantineBarrierForTest(barrier: ((lockPath: string, quarantinedPath: string) => void) | null): void; export declare function withCrossProcessFileLockSync(resourcePath: string, operation: (context: CrossProcessFileLockContext) => T, options?: { maxAttempts?: number; retryMs?: number; }): T; export declare function hasLeaderSubagentCollision(state: SubagentTrackingState, leaderThreadId: string): boolean; export declare function readSubagentTrackingStateStrict(cwd: string): Promise<{ ok: true; state: SubagentTrackingState; } | { ok: false; }>; export declare function readSubagentTrackingState(cwd: string): Promise; export declare function writeSubagentTrackingState(cwd: string, state: SubagentTrackingState): Promise; export declare function recordSubagentTurn(state: SubagentTrackingState, input: RecordSubagentTurnInput): SubagentTrackingState; export declare function recordSubagentTurnForSession(cwd: string, input: RecordSubagentTurnInput): Promise; export declare function recordNativeSubagentAuthorityObservation(cwd: string, observation: NativeSubagentAuthorityObservation): SubagentTrackingState; /** Upper bound on fenced ids, so repeated failures cannot grow the fence without limit. */ export declare const AUTHORITY_FENCE_MAX_IDS = 512; /** * Record ids whose revocation could not be persisted, so reopen stays denied. * * Every fence mutation runs under a dedicated cross-process lock on the fence * path so read/merge/publish is atomic with respect to concurrent fencing and * clearing. Returns true when the denial is durable; the caller must treat * false as an unresolved fail-closed condition. */ export declare function fenceNativeSubagentAuthorities(cwd: string, childThreadIds: string[], reason: string): boolean; /** * Last-resort global denial used when BOTH the tracker revocation transaction * and the locked fence publication fail. It deliberately avoids the fence lock * (which may be exactly what is unavailable) and writes an intentionally * unreadable sentinel directly, because `readAuthorityFence` treats any * unreadable fence as a denial of every id. Returns true when the denial is * durable on disk. */ export declare function forceGlobalAuthorityDenial(cwd: string, reason: string): boolean; export declare function revokeNativeSubagentAuthorities(cwd: string, childThreadIds: string[], reason?: string): SubagentTrackingState; export interface DirectChildReopenContext { sessionId: string; rootNativeSessionId: string; source: string; } /** * Pointer-authoritative root identity repair, decoupled from reopen candidate * output. Runs under the tracker lock and fails closed on malformed bytes. */ export declare function repairPersistedRootIdentity(cwd: string, context: { sessionId: string; rootNativeSessionId: string; }): boolean; /** * Quarantine reopen authority for a root that is persisted as a subagent when * the identity evidence is contradictory (for example a self-parented * transcript marker). Unlike full repair this never asserts leader identity, so * legitimate descriptive subagent evidence is preserved; it only strips the * authority and resume bookkeeping that a root must never carry. Returns true * when any record changed. */ export declare function quarantinePersistedRootAuthority(cwd: string, context: { sessionId: string; rootNativeSessionId: string; }): boolean; /** Strict, lock-serialized authority consumption for SessionStart persisted reopen output. */ export declare function consumeDirectChildReopenContext(cwd: string, context: DirectChildReopenContext): string | null; export declare function summarizeSubagentSession(state: SubagentTrackingState, sessionId: string, options?: { now?: string | Date; activeWindowMs?: number; }): SubagentSessionSummary | null; export declare function buildSubagentResumeLedger(state: SubagentTrackingState, sessionId: string, options?: { now?: string | Date; activeWindowMs?: number; }): SubagentResumeLedger | null; export declare function readSubagentSessionLedger(cwd: string, sessionId: string, options?: { now?: string | Date; activeWindowMs?: number; }): Promise; export declare function selectReusableSubagentEntry(entries: readonly SubagentLedgerEntry[], criteria?: { role?: string; laneId?: string; scope?: string; agentNickname?: string; }): SubagentLedgerEntry | null; export declare function readSubagentSessionSummary(cwd: string, sessionId: string, options?: { now?: string | Date; activeWindowMs?: number; }): Promise; //# sourceMappingURL=tracker.d.ts.map