/**
 * GovernanceRuntime -- Core enforcement layer for AI agent governance.
 *
 * This module provides SHA-256 tamper detection on governance files,
 * deny-by-default permission filtering, and activity logging.
 *
 * Portable: works in any Claude Code project. No external dependencies.
 *
 * @connexum/ai-governance
 */
export interface GovernanceConfig {
    /** Path to governance rules file */
    governanceFile: string;
    /** Path to directory containing agent permissions */
    permissionsDir: string;
    /** Path for activity logs */
    logDir: string;
    /** Enable SHA-256 tamper detection (default: true) */
    tamperDetection?: boolean;
    /** Cycle timeout in milliseconds (default: 300000 = 5 min) */
    cycleTimeoutMs?: number;
    /** Admin token for authorizing governance hash updates (from env: GOVERNANCE_ADMIN_TOKEN) */
    adminToken?: string;
}
export interface PermissionLevel {
    tool: string;
    level: 'ALLOWED' | 'BLOCKED' | 'APPROVAL_REQUIRED';
}
export interface GovernanceVerification {
    valid: boolean;
    hash: string;
    expectedHash: string | null;
    timestamp: string;
}
export interface ActivityLogEntry {
    timestamp: string;
    agent: string;
    action: string;
    target: string;
    result: 'allowed' | 'blocked' | 'error';
    detail?: string;
}
export declare class GovernanceTamperError extends Error {
    expectedHash: string;
    actualHash: string;
    file: string;
    constructor(expectedHash: string, actualHash: string, file: string);
}
export declare class GovernanceRuntime {
    private config;
    private governanceHash;
    private hashManifest;
    private activityLog;
    /**
     * AIAG-024: Cache parsed permissions keyed by (agentName, file-mtime-ms).
     * Prevents a disk read on every preAction/filterTools/checkToolAccess call
     * in hot paths. Cache auto-invalidates when the permissions file is edited.
     */
    private permissionsCache;
    constructor(config: GovernanceConfig);
    /**
     * Verify governance file integrity.
     * Throws GovernanceTamperError if tampered.
     */
    verifyGovernance(): GovernanceVerification;
    /**
     * Build and verify a hash manifest for multiple governance files.
     */
    buildHashManifest(files: string[]): Map<string, string>;
    /**
     * Verify all files in the hash manifest.
     * Returns list of tampered/missing files.
     */
    verifyManifest(): {
        tampered: string[];
        missing: string[];
        valid: string[];
    };
    /**
     * Load and parse agent permissions from PERMISSIONS.md format.
     * Returns empty map if file missing (deny-by-default).
     */
    loadPermissions(agentName: string): Map<string, PermissionLevel>;
    /**
     * Filter tools based on agent permissions. Deny-by-default.
     * Tools not in permissions = BLOCKED.
     */
    filterTools(tools: string[], agentName: string): string[];
    /**
     * Check if a specific tool call is allowed for an agent.
     */
    checkToolAccess(toolName: string, agentName: string): {
        allowed: boolean;
        level: string;
        reason: string;
    };
    /**
     * Log an activity entry.
     */
    logActivity(entry: ActivityLogEntry): void;
    /**
     * Get activity log entries (in-memory).
     */
    getActivityLog(): ActivityLogEntry[];
    /**
     * Update governance hash after an authorized change.
     * Only call this when a human operator intentionally modifies governance.
     * Requires an authorization token to prevent unauthorized hash resets.
     */
    updateGovernanceHash(authorizationToken?: string): string;
    /**
     * Export hash manifest to JSON file for persistence across sessions.
     */
    exportManifest(outputPath: string): void;
    /**
     * Import hash manifest from JSON file.
     */
    importManifest(inputPath: string): void;
    /**
     * Get the path where the governance hash is persisted.
     */
    private getHashFilePath;
    /**
     * Persist governance hash to disk for cross-restart tamper detection.
     */
    private persistHash;
    /**
     * Set the active compliance pack selection for a project via the governance server.
     *
     * Calls POST /api/v1/projects/:projectId/packs and emits a
     * project.packs.changed canonical audit event server-side.
     *
     * @param projectId - The project to configure
     * @param packIds - Pack IDs to activate for this project
     * @param versions - Optional semver pins per packId
     * @param opts - Connection options (apiUrl, licenseKey). Defaults to env vars.
     */
    setProjectPacks(projectId: string, packIds: string[], versions?: Record<string, string>, opts?: {
        apiUrl?: string;
        licenseKey?: string;
    }): Promise<{
        selectedPackIds: string[];
        selectedPackVersions: Record<string, string>;
    }>;
    private computeHash;
    private ensureDir;
}
//# sourceMappingURL=governance-runtime.d.ts.map