import { type Runner } from "../internals/proc.js"; import type { HookClient, JsonValue, NormalizedHookEvent } from "./hook-core.js"; export declare const TOKEN_SAVIOR_RUNTIME_PIN: { readonly package: "token-savior-recall[mcp]==4.21.0"; readonly sourceCommit: "1e5984b452c5b98e6376a7250b3213f5c3500626"; readonly wheelSha256: "36529b132d658225ad6df7c9ec4ca0cbcf0fb48ebb0054099a0284c793fc9363"; readonly license: "MIT"; readonly import: "token_savior.compactors.compact"; }; export declare const TOKEN_SAVIOR_LIMITS: { readonly maxOriginalBytes: number; readonly maxCompactedBytes: number; readonly maxRetentionRecords: 128; readonly maxTimeoutMs: 10000; }; /** * Versioned native transport qualification. Claude preserves a successful tool * result while replacing its model-visible bytes. Codex 0.145.0 exposes only * block feedback for PostToolUse replacement, so its transport is deliberately * experimental and must be re-probed before a client-version update. */ export declare const TOKEN_SAVIOR_NATIVE_TRANSPORTS: { readonly claude: { readonly qualifiedAtVersion: "2.1.220"; readonly status: "qualified"; readonly hook: "PostToolUse"; readonly behavior: "success-output-replacement"; readonly outputField: "hookSpecificOutput.updatedToolOutput"; }; readonly codex: { readonly qualifiedAtVersion: "0.145.0"; readonly status: "experimental-qualified"; readonly hook: "PostToolUse"; readonly behavior: "blocked-result-feedback-replacement"; readonly outputField: "decision:block/reason"; }; }; export declare const TOKEN_SAVIOR_COMPACTOR_BRIDGE: string; export interface TokenSaviorCompactInput { command: string; stdout: string; stderr: string; } export interface TokenSaviorCompactResult { text: string; originalBytes: number; compactBytes: number; savingsPercent: number; originalText: string; } export type TokenSaviorCompactor = (input: Readonly, signal: AbortSignal) => Promise; interface ProcessCompactorOptions { pythonCommand: string; runtimeRoot: string; tempRoot: string; /** Digest independently verified by the acquisition boundary. */ verifiedWheelSha256: string; /** Repository-owned subprocess seam; injectable for hermetic tests. */ run?: Runner; } export interface TokenSaviorRetentionRecord { version: 1; client: HookClient; repositoryId: string; canonicalWorktree: string; sessionIdHash: string; toolUseIdHash: string; retainedAtEpochMs: number; package: typeof TOKEN_SAVIOR_RUNTIME_PIN.package; sourcePin: string; wheelSha256: typeof TOKEN_SAVIOR_RUNTIME_PIN.wheelSha256; originalSha256: string; originalBytes: number; originalText: string; compactedSha256: string; compactedBytes: number; evidencePath: string; } export interface TokenSaviorRetentionStore { retain(record: Omit): TokenSaviorRetentionRecord; list(): readonly TokenSaviorRetentionRecord[]; } interface FileRetentionStoreOptions { stateRoot: string; canonicalWorktree: string; repositoryId: string; maxOriginalBytes?: number; } interface AdapterOptions { canonicalWorktree: string; repositoryId: string; store: TokenSaviorRetentionStore; compact: TokenSaviorCompactor; timeoutMs: number; now?: () => number; } export type TokenSaviorAdapterStatus = "compacted" | "ineligible" | "no-match" | "failed-open" | "timed-out-open" | "retention-failed-open"; export interface TokenSaviorAdapterResult { status: TokenSaviorAdapterStatus; transport: "claude-updated-tool-output" | "codex-post-tool-block-feedback-experimental" | "native-output-unchanged"; qualification: (typeof TOKEN_SAVIOR_NATIVE_TRANSPORTS)[HookClient] | { status: "not-applied"; }; modelOutput: JsonValue; nativeOutput?: JsonValue; originalRetained: boolean; health: { package: typeof TOKEN_SAVIOR_RUNTIME_PIN.package; sourceCommit: typeof TOKEN_SAVIOR_RUNTIME_PIN.sourceCommit; status: TokenSaviorAdapterStatus; }; } export interface TokenSaviorCompactionAdapter { run(event: Readonly): Promise; } export declare function createTokenSaviorProcessCompactor(options: ProcessCompactorOptions): TokenSaviorCompactor; export declare function createFileTokenSaviorRetentionStore(options: FileRetentionStoreOptions): TokenSaviorRetentionStore; export declare function createTokenSaviorCompactionAdapter(options: AdapterOptions): TokenSaviorCompactionAdapter; interface AuditProjectionInput { client: HookClient; enabled: boolean; explicitConsent?: { id: string; sha256: string; }; canonicalWorktree: string; stateRoot: string; transcriptRoot: string; wrapperCommand: string; wrapperSha256: string; } export interface TokenSaviorAuditProjection { client: "claude"; activation: "prepared-not-registered"; command: string; args: readonly string[]; env: Readonly>; allowedTools: readonly ["ts_discover"]; resources: readonly []; provenance: { package: typeof TOKEN_SAVIOR_RUNTIME_PIN.package; sourceCommit: typeof TOKEN_SAVIOR_RUNTIME_PIN.sourceCommit; wheelSha256: typeof TOKEN_SAVIOR_RUNTIME_PIN.wheelSha256; wrapperSha256: string; consentId: string; consentSha256: string; }; } export declare function buildTokenSaviorAuditProjection(input: AuditProjectionInput): TokenSaviorAuditProjection; export declare function guardTokenSaviorAuditCall(tool: string, _arguments: JsonValue): void; interface TokenSaviorAuditToolDescription { name: string; [key: string]: unknown; } export type TokenSaviorAuditMcpRequestDecision = { forward: true; } | { forward: false; response: { jsonrpc: "2.0"; id: string | number | null; result: { resources: []; }; } | { jsonrpc: "2.0"; id: string | number | null; error: { code: -32601; message: string; }; }; }; /** Hard JSON-RPC surface enforced by the later managed audit-MCP wrapper. */ export declare class TokenSaviorAuditMcpPolicyGuard { inspectClientRequest(value: unknown): TokenSaviorAuditMcpRequestDecision; filterToolsList(value: unknown): { tools: TokenSaviorAuditToolDescription[]; }; } export {};