/** * Web Fetch Tool - Lightweight web retrieval with markdown normalization. * * Features: * - Built-in `web_fetch` tool definition for world toolsets * - URL validation with http/https scheme enforcement * - Basic SSRF safeguards for loopback/private/link-local targets * - Lightweight SPA bootstrap-data extraction from HTML script payloads * - Markdown conversion via Turndown + GFM plugin * * Implementation Notes: * - Uses native fetch in Node runtime; no browser automation dependencies * - Does not execute page JavaScript; instead extracts embedded JSON state when available * - Returns deterministic JSON string payloads for downstream tool consumers * - Applies timeout and output-size bounds with explicit truncation metadata * * Recent Changes: * - 2026-03-12: Restored private-target gating in the main execute path so blocked hosts require explicit approval before any network fetch starts. * - 2026-03-12: Shared tool approval flow now persists durable approval prompt/resolution messages for replay-safe local/private access denials. * - 2026-03-12: Removed permission level gating — web_fetch is now allowed at all levels (read/ask/auto), like read_file. * - 2026-03-06: Removed `world.currentChatId` fallback from local/private access approvals; HITL approval now requires explicit `context.chatId`. * - 2026-03-05: Added deterministic timeout-error mapping (`timeout_error`) for aborted fetches caused by per-request timeout limits. * - 2026-03-05: Switched timeout/output bounds constants to shared reliability config. * - 2026-02-28: Initial implementation of fetch-only web retrieval with Turndown conversion and SPA JSON heuristics. */ import { type AgentMessage, type World } from './types.js'; type WebFetchArgs = { url: string; timeoutMs?: number; maxChars?: number; includeLinks?: boolean; includeImages?: boolean; }; type WebFetchToolContext = { world?: World; chatId?: string | null; toolCallId?: string; agentName?: string | null; messages?: AgentMessage[]; }; export declare function createWebFetchToolDefinition(): { description: string; parameters: { type: string; properties: { url: { type: string; description: string; }; timeoutMs: { type: string; description: string; }; maxChars: { type: string; description: string; }; includeLinks: { type: string; description: string; }; includeImages: { type: string; description: string; }; }; required: string[]; additionalProperties: boolean; }; execute: (args: WebFetchArgs, _sequenceId?: string, _parentToolCall?: string, context?: WebFetchToolContext) => Promise; }; export {};