/** * Gryph bridge — runtime behavioral observability provider. * * Promotes Gryph from optional score enrichment to first-class behavioral source. * Runs a background poll loop that updates panic state independently of MCP tool * calls, closing the blind spot where agents work purely via Bash/Edit/Read. * * Architecture: * RuntimeBehaviorProvider (interface) * └── GryphBehaviorProvider (impl: gryph query CLI) * └── startGryphPolling (background loop → panic state) * * All failures degrade to zero-impact null semantics: * - gryph binary absent → null * - timeout → null * - malformed output → null * - any exception → null * * The poll loop MUST NOT block MCP execution, delay tool responses, or overlap. */ import type { EpistemicTracker } from './epistemic-lease.js'; /** Behavioral snapshot from a runtime observability source. */ export interface RuntimeBehaviorSnapshot { timestamp: number; commandEntropy?: number; repetitiveRetryBurst?: boolean; failingCommandRate?: number; largePatchWhileStale?: { loc: number; entropy: number; }; commandCount?: number; shellActivity?: boolean; } /** Abstraction for runtime behavioral data sources. */ export interface RuntimeBehaviorProvider { collect(since: string): Promise; } /** Kept for backward compat with panic-check.ts enrichment path. */ export interface GryphSignals { commandEntropy: number; repetitiveRetryBurst: boolean; largePatchWhileStale: boolean; largePatchLoc: number; } /** Reset availability cache — for testing only. */ export declare function _resetGryphAvailabilityForTesting(available?: boolean): void; export declare class GryphBehaviorProvider implements RuntimeBehaviorProvider { collect(since: string): Promise; } export interface GryphPollingOptions { directory: string; /** Returns current stale depth from in-memory tracker. */ getTracker: () => EpistemicTracker | null; /** Optional provider override (for testing). */ provider?: RuntimeBehaviorProvider; } /** * Start background Gryph polling. Returns a cleanup function (call on shutdown). * * Invariants: * - One per workspace: registry stops any existing poller for the same directory * - Never overlaps: single-flight protection skips polls while previous is running * - Never blocks: async spawn, isolated from MCP execution path * - Never throws: all errors caught, fail-open * - CAS writes: uses compare-and-swap to prevent overwriting concurrent MCP writes * - Syncs tracker: panicScore/panicLevel/panicRevision updated in-memory after write * so the MCP path doesn't overwrite Gryph-elevated state on the next tool call */ export declare function startGryphPolling(opts: GryphPollingOptions): () => void; /** * Synchronous Gryph query for the panic-check hook enrichment path. * Returns null when Gryph is absent or any error occurs. */ export declare function queryGryphSignals(since: string): GryphSignals | null; /** * Apply Gryph-derived score deltas (backward compat — panic-check enrichment). */ export declare function applyGryphDelta(baseScore: number, signals: GryphSignals, isStale: boolean, triggers: string[]): number; //# sourceMappingURL=gryph-bridge.d.ts.map