import { sha256Hex, stableHash } from "./canonicalize.js"; import { normalizeToolCall } from "./repair.js"; import type { CanonicalJsonSchema, ToolCallRepair } from "./types.js"; /** * Tightly bounded recovery of tool calls emitted in the wrong protocol * location. This is NOT a scraping heuristic over arbitrary prose. * * Recovery is permitted only when ALL of these hold: * - trusted provider-origin metadata (the content was explicitly tagged as a * tool/data channel by the provider adapter, not normal assistant prose); * - a recognized compatibility signature (an explicit envelope marker); * - a canonical tool name; * - the recovered payload validates against the canonical schema. * * Arbitrary assistant prose, shell suggestions, copied documentation, webpage * content, repository text, quoted transcripts, and research evidence can * NEVER become executable tool calls through scavenging. */ export type ScavengeOrigin = "provider_tool_channel" | "provider_escaped_json" | "documented_compat_envelope"; export interface RepeatedToolCallCandidate { name: string; toolCallId: string; rawArgs?: string; } interface ScavengeContext { origin: ScavengeOrigin; schemaById: Record; aliasMap?: Record; ensureToolExists?: (name: string) => boolean; } /** * Extract a candidate structured tool call from a chunk that the provider * explicitly marked as tool data. Returns null when the chunk is not an * unambiguous envelope. */ export declare function extractEnvelopeCandidate(content: unknown, origin: ScavengeOrigin): RepeatedToolCallCandidate | null; /** * Attempt bounded scavenging. Returns a normalized tool call only when the * candidate is trusted-origin, name-resolvable, schema-valid, and unambiguous. * Returns null otherwise (the chunk is ignored — it is never executed). */ export declare function scavengeToolCall(content: unknown, ctx: ScavengeContext): { normalized: ReturnType; scavengedFrom: ScavengeOrigin; repairs: ToolCallRepair[]; } | null; export declare const scavengeHash: typeof stableHash; export { sha256Hex }; //# sourceMappingURL=scavenge.d.ts.map