/** * Shared tool-call helpers (H1) — the S2/S3 reliability fixes lifted OUT of * `src/cli/chat.ts` so every surface that drives a model through tool calling * (chat's tool loop today; any future execute/plan/… loop or dashboard * console) gets them for free. One copy, one test, one contract. * * - `salvageFailedGeneration` — recover a complete model answer from a * tool-calling 400's `failed_generation` field (S3). The API rejects the * CALL (e.g. the model emitted an Anthropic-style `` tag inside * its content) while the content is a full, deliverable answer — the essay * was sitting in the error payload and being thrown away. * - `compactToolSchemas` — one-line argument shapes for the JSON * fallback transport (S2). The fallback contract lists tool NAMES only, so * a fallback model cannot produce valid arguments for schemas it never saw. * - `buildJsonFallbackPrompt` — the flattened thread + schema-shape section * (the S2 injection), shared so chat and any other loop build identical * prompts. */ import type { ToolMessage } from './interface.js'; import type { FollowupSuggestion, ToolJsonSchema } from '../tools/registry.js'; /** * S3 — salvage the model's generated content from a tool-calling 400. * * OpenAI-compatible APIs (Groq et al.) reject the CALL but often embed the * model's COMPLETE answer in the error body's `failed_generation` field — e.g. * when the model emitted an Anthropic-style `` tag inside its * content (observed with llama-3.3-70b on Groq, which destroyed a perfect * essay). Only salvage when the intended call is the end-of-response marker * (`suggest_followups`) or absent: a rejected REAL tool call (build/repair/…) * must not be "answered" with its intro prose. */ export declare function salvageFailedGeneration(err: unknown): { content: string; followups?: FollowupSuggestion[]; } | null; /** * S2 — compact one-line argument shapes for the JSON-fallback transport. * * The fallback contract (TOOL_CONTRACT_JSON) lists tool NAMES only — a * fallback-transport model (e.g. a small local Ollama model) cannot produce * valid arguments for schemas it never saw (it guessed plain strings / a * `text` key for suggest_followups). Append these shapes to the flattened * prompt: top-level property name + type + required, one line per tool. * Deliberately NOT the full JSON schema (token-heavy for small contexts). */ export declare function compactToolSchemas(schemas: ToolJsonSchema[]): string; /** * S2 — the JSON-fallback flattened prompt WITH the schema-shape section * appended (shared so chat and any other loop build byte-identical prompts). */ export declare function buildJsonFallbackPrompt(messages: ToolMessage[], schemas: ToolJsonSchema[]): string; //# sourceMappingURL=tool-call-utils.d.ts.map