/** * Franklin Agent Loop * The core reasoning-action cycle: prompt → model → extract capabilities → execute → repeat. */ import type { AgentConfig, ContentPart, Dialogue, StreamEvent } from './types.js'; export declare function isExternalWallFailure(toolName: string, output: string, isError?: boolean): boolean; /** * Detect when the gateway leaked an upstream rate-limit / quota error as a * 200-OK text content block instead of a real HTTP error. The Anthropic * provider in particular surfaces per-day TPM exhaustion as a bracketed * "[Error: Too many tokens per day, please wait before trying again.]" * message glued into the assistant text channel, which then poisons grounding * checks and gets persisted to session history as if it were a real reply. * * Treat any assistant turn whose entire text payload is a single bracketed * `[Error: ...]` line — and contains no tool_use / thinking blocks — as a * masquerading transport error. The caller throws to let the existing * classifier + retry path take over. */ export declare function looksLikeGatewayErrorAsText(parts: ContentPart[]): { match: boolean; message: string; }; /** * Detect a "stalled at intent" assistant turn: model emitted text-of-intent * (e.g. "Let me check Node.js…", "I'll start by running npm install") but * never bound a tool_use block. Coder-tuned models (qwen3-coder-*) and * NIM-hosted Llama-4-Maverick frequently end_turn after declaring an action, * stranding the agent loop with no progress. * * Returns true when the turn looks like a stall — caller should switch to a * tool-use-strong model and retry the same prompt instead of treating the * declared-but-unexecuted intent as the model's final answer. * * Conservative by design: only fires when the *tail* of the text shows * action-intent + the message is long enough to look like a real plan, so * legitimate short answers ("yes", "looks good") never get re-invoked. */ export declare function looksLikeStalledIntent(text: string): boolean; /** * Walk a Dialogue and replace large `image.source.data` (base64) blocks * inside `tool_result.content` arrays with a tiny placeholder. The * accompanying text block already names the file path so the model on * resume can re-Read it if it needs to see the image again. Returns a * shallow clone so the in-memory history (used for the rest of the * current turn) keeps the full image data. */ export declare function stripLargeImageData(message: Dialogue): Dialogue; /** * Identify models known to hallucinate tool calls (invented names, literal * `[TOOLCALL]` / `` text in answers) — they need the explicit * "Available tools" inventory appended to the system prompt. Strong frontier * models skip the nag so their prompt cache doesn't turn over. * * Exported so tests can pin the classification without a live API. */ export declare function isWeakModel(model: string): boolean; /** * Run a multi-turn interactive session. * Each user message triggers a full agent loop. * Returns the accumulated conversation history. */ export declare function interactiveSession(config: AgentConfig, getUserInput: () => Promise, onEvent: (event: StreamEvent) => void, onAbortReady?: (abort: () => void) => void): Promise;