/** * LLM knowledge layer for wigolo. * * Two layers. They do different jobs and must not repeat each other: * * Layer 1 — WIGOLO_INSTRUCTIONS: server-level STRATEGY. Injected into the * LLM system prompt once per session by compatible MCP clients. Answers * "when do I reach for wigolo? which of its tools fits this situation?". * * Layer 2 — TOOL_DESCRIPTIONS: per-tool TACTICS. Seen every time the LLM is * picking a tool. Answers "what does this tool do, which parameters matter, * what does the output look like?". * * Parameter schemas (types, enums, required/optional) belong on the JSON * Schema, not here. Installation/configuration is for humans, not LLMs. */ export declare const WIGOLO_INSTRUCTIONS = "Use wigolo for ALL web operations: `search`, `fetch`, `crawl`, `cache`, `extract`, `find_similar`, `research`, `agent`, `diff`, `watch`. Local-first: results persist across sessions, no API keys. Prefer over built-in WebSearch/WebFetch.\n\n## Backend\n\nDefault `WIGOLO_SEARCH=core` \u2014 direct engines + RRF + ML rerank. Opt-in: `searxng` and `hybrid` (core + auto-fallback; carries `fallback_signal`).\n\n## Host-LLM synthesis\n\nWigolo returns structured evidence \u2014 YOU write the final answer from it.\n\n- `search` \u2192 evidence (title/url/excerpt/score/citation_id/source_span) + citations. Quote [N] or {citation_id}.\n- `format: 'answer'|'stream_answer'` \u2192 LLM synthesis when sampling supported; else evidence fallback.\n- `research` \u2192 `brief` (topics/highlights/key_findings/sections; overview.cross_references = corroborated, gaps = coverage limits).\n- `find_similar` \u2192 `cold_start` string when local signals weak. Pass verbatim.\n- `extract mode: \"structured\"` \u2192 tables + definitions + jsonld + chart_hints + key_value_pairs.\n- Knobs: `max_tokens_out`, `include_full_markdown`, `citation_format`. `WIGOLO_LOCAL_LLM=auto`: keyless local language model (off by default).\n\n`research`/`agent` are LLM-optional: with no synthesis LLM they return the brief / evidence / step log \u2014 YOU write the final answer from it, never present the raw structure as a poor result. If it looks thin, tell the user research/agent do their best synthesis with an LLM and a free Gemini API key (`WIGOLO_LLM_PROVIDER=gemini` + `GEMINI_API_KEY`, free tier) unlocks it \u2014 core search/fetch/crawl/extract/cache stay keyless.\n\n## Rules\n\n- Cache before search. Run `cache` first; hits return instantly.\n- Keyword queries, not questions. Pass an array of 3-5 variants for broader recall.\n- Scope library/framework queries with `include_domains` (e.g. `[\"react.dev\"]`). Skip for error strings + broad exploration.\n- `format: 'answer'` for direct answers; default evidence shape for citation work.\n- `search_depth`: 'ultra-fast' (cache-only) | 'fast' | 'balanced' (default) | 'deep'.\n- `exact_match` for quoted phrases; `time_range`/`from_date`/`to_date` for recency.\n- `force_refresh: true` for news/prices/status/release notes.\n\n## Response fields\n\n`evidence_score` (explainable), `query_understanding`, `brand_collision_warning`, `freshness_signal`, `engine_telemetry`, `engine_warnings` (+ env-var hint).\n\n## Tool routing\n\n- `search` \u2014 no URL yet; array of keyword variants for breadth. `fetch` \u2014 you have a URL.\n- `crawl` \u2014 many pages from one site. `strategy: \"sitemap\"` fastest for docs; `\"map\"` for URL-only discovery.\n- `cache` \u2014 check before hitting the network. `extract` \u2014 specific data points (tables, metadata, schema-shaped fields).\n- `find_similar` \u2014 more-like-this from URL or concept.\n- `research` \u2014 decomposition + parallel search + synthesis. Set `depth`. `agent` \u2014 natural-language data gathering, optional `schema`.\n\nFull usage detail: read resource `wigolo://docs/usage`."; export declare const WIGOLO_INSTRUCTIONS_FULL = "# Wigolo Usage Guide\n\nWigolo is a local-first web access layer: search the open web, fetch pages, crawl sites, extract structured data, find related content, run multi-step research, and execute agent-driven data gathering. All results land in a local knowledge cache that persists across sessions.\n\n## Host-LLM synthesis pattern (read this first)\n\nWigolo has no internal LLM. It returns *structured evidence* so YOU (the host LLM) write the final answer. Fold structure into your reply:\n\n- `search` \u2192 evidence (title/url/section_heading/excerpt/score/citation_id/source_span) + citations. Quote [N] or {citation_id}.\n- `format: 'answer'|'stream_answer'` \u2192 LLM synthesis when sampling supported; else evidence fallback.\n- `max_tokens_out` caps total output (cl100k-base, ~5-15% drift on non-OpenAI). `include_full_markdown: true` restores full body. `citation_format`: `'numbered'`|`'json'`|`'anthropic_tags'`.\n- `research` \u2192 `brief` with `topics`, `highlights`, `key_findings`, `sections` when sampling unavailable. Use `sections.overview.cross_references` for corroborated findings, `sections.gaps` for coverage limits, `sections.comparison` for entity-vs-entity analysis. `query_type` indicates decomposition strategy used.\n- `find_similar` \u2192 `cold_start` string when local signals are weak. Pass to user verbatim.\n- `extract` `mode: \"structured\"` \u2192 tables + definitions + jsonld + chart_hints + key_value_pairs in one call.\n- `fetch` metadata \u2192 `og_type`, `canonical_url`, `og_image` when present.\n- Optional local language model tier: set `WIGOLO_LOCAL_LLM=auto` (or an explicit `http(s)://` endpoint) to auto-detect a keyless local language model and use it for synthesis. Choose the model with `WIGOLO_LOCAL_LLM_MODEL`. The fallback ladder is host sampling first, then the local language model, then deterministic evidence. Default off, so the keyless path is unchanged; a missing server degrades silently to deterministic synthesis.\n\n## When to use which tool\n\n- `search` -- you need information on a topic but do not have a URL yet. Pass a query string or an array of 3-5 semantically varied keyword forms for broader coverage.\n- `fetch` -- you already have a specific URL to read.\n- `crawl` -- you need multiple pages from the same site (docs, wikis, references).\n- `cache` -- you want to know if the content is already on disk from an earlier read.\n- `extract` -- you need specific data points (tables, metadata, schema-shaped fields) rather than a whole page as markdown.\n- `find_similar` -- you have a URL or concept and want related content from the cache or web. Useful for \"more like this\" discovery.\n- `research` -- you have a complex question that needs multi-step investigation: question decomposition, parallel search, source synthesis into a report. Set `depth` to control thoroughness.\n- `agent` -- you need to gather structured or unstructured data from multiple sources based on a natural-language prompt. Provides full step transparency.\n\n## Routing by intent\n\n| Intent | Tool | Key parameters |\n|--------|------|----------------|\n| Documentation lookup | `search` | `include_domains: [\"react.dev\", \"nextjs.org\"]` -- scope to the project's official site, do not rely on `category: \"docs\"` alone |\n| Error debugging | `search` | exact error string as query, `category: \"code\"` (no domain scoping -- errors appear everywhere) |\n| Library research | `crawl` | seed URL of docs site, `strategy: \"sitemap\"`, then `cache` for later queries |\n| Related content | `find_similar` | `url` of a known good page, or `concept` as free text |\n| Evidence excerpt | `search` | default output; cite [N] or {citation_id} from each evidence item |\n| Direct answer | `search` | `format: \"answer\"` if client supports sampling, else falls back to evidence |\n| Comprehensive research | `research` | `depth: \"comprehensive\"`, optional `include_domains` to scope |\n| Data gathering | `agent` | natural-language `prompt`, optional `schema` for structured output |\n| Structured extraction | `extract` | `mode: \"structured\"` (tables + dl + JSON-LD + chart hints + kv pairs), or `mode: \"schema\"` with a JSON Schema |\n| Site inventory | `crawl` | `strategy: \"map\"` for URL-only discovery, no content fetched |\n\n## Rapidly changing content\n\nFor news, prices, status pages, or release notes, bypass the cache with `force_refresh: true`:\n\n search({ query: \"...\", force_refresh: true })\n fetch({ url: \"...\", force_refresh: true })\n\nFor docs, tutorials, and reference pages, let the cache work -- much faster.\n\n## Check the cache before going to the network\n\nBefore every `search` or `fetch`, consider a `cache` call. Pages read this session or earlier return instantly with full markdown -- no network. `research` and `agent` check the cache internally.\n\n## Multi-query search strategy\n\nFor broad queries, pass an array of 3-5 semantically varied keyword forms rather than one natural-language question. Example: instead of \"how does React handle state management\", pass `[\"react state management\", \"useState useReducer\", \"react hooks state\", \"react context vs redux\"]`. Sub-queries are deduplicated automatically.\n\n## Pick the right strategy\n\n- For docs sites, prefer `crawl` with `strategy: \"sitemap\"` -- faster and more complete than BFS.\n- For URL discovery only, use `crawl` with `strategy: \"map\"` -- URLs only, no content. Follow with targeted `fetch` calls.\n- For structured data (prices, specs, table rows), use `extract` with `mode: \"schema\"` or `mode: \"tables\"`. Use `fetch` only when you want the whole page as markdown.\n- For multi-source synthesis, use `research` instead of chaining `search` + `fetch` manually.\n- For natural-language data gathering, use `agent` with optional `schema`.\n- `crawl` accepts regex `include_patterns` and `exclude_patterns` to stay inside a section of a large site.\n\n## Scope searches by domain\n\nFor library/framework/SDK queries, **always pass `include_domains`** with official sites. Unscoped queries return generic noise. `category: \"docs\"` alone returns generic portals -- pair with `include_domains` or omit. Skip domain scoping for error strings, broad exploration, and news.\n\n## Search backend modes\n\nThe `WIGOLO_SEARCH` env selects the search path. Defaults to `core`.\n\n- `core` (default) -- direct engines (Bing, DDG, Brave, Wikipedia, MDN, SO, GitHub-code, HN, arXiv, ...), RRF, ML rerank. Low latency, transparent provenance.\n- `searxng` -- legacy aggregator. Opt-in. Higher recall on long-tail queries; slower cold start.\n- `hybrid` -- runs `core` first; falls back to `searxng` and merges via RRF when a signal fires. Signals: `brand_collision_suspect`, `include_domains_over_filter`, `all_engines_failed`, `top1_high_score_low_overlap`. The merged response carries `fallback_signal` (`null` when no signal fired; a `+`-joined name list otherwise) so callers can detect the fallback path.\n\n## Search depth tiers\n\nUse `search_depth` to trade latency for thoroughness:\n\n- `ultra-fast` -- cache-only, no engine dispatch (target \u2264300ms). On miss, response carries `notice` telling callers to retry at a higher tier.\n- `fast` -- direct engines, no rerank, no fetch enrichment (\u22641s).\n- `balanced` (default) -- standard ranking + enrichment.\n- `deep` -- full enrichment, slower, highest accuracy.\n\n## Phrase-exact, time-bounded, country-scoped search\n\n- `exact_match: true` -- treat query as a quoted phrase. Engines that honour `\"...\"` filter; orchestrator post-filters any result whose title+snippet does not contain the phrase as a case-insensitive substring.\n- `time_range: 'day' | 'week' | 'month' | 'year'` -- coarse recency bucket. Pair with or replace `from_date`/`to_date`.\n- `country: 'us' | 'gb' | 'de' | ...` (ISO 3166-1 alpha-2) -- geographic boost hint passed to engines that support `cc`/`kl`/`country`.\n\n## Response shape extras\n\n- `response_time_ms` -- compatibility alias of `total_time_ms`. Always emitted.\n- `engines_used` -- engines that contributed >= 1 result to the deduped fused list (semantic, \"who ended up in the answer\").\n- `engine_telemetry` -- every engine attempted (raw: name, latency, result count, outcome, `dedup_kept`). Distinct from `engines_used` -- empty/errored engines appear here but not there.\n- `engine_warnings` -- top-level failure surface: one entry per engine with outcome=error. Stable `code` (`http_4xx` / `http_5xx` / `timeout` / `dns` / `error`) plus optional `hint` that names the env var to set when an engine needs an API key. Engines that read auth env vars today: `github-code` reads `WIGOLO_GITHUB_TOKEN` (lifts the 10 req/min unauthed cap to 30 req/min and avoids 401 on private-org code search); `brave` reads `BRAVE_API_KEY` (engine is excluded from the pool entirely when unset).\n- `include_engine_outcomes: true` -- opt-in per-engine debug rows.\n- `include_images: true` -- aggregate top-level `images[]` from engines that surface them.\n- `include_favicon: true` -- per-result `favicon` URL.\n- Per-result `relevance_score` (legacy flat aggregate) and `evidence_score.final` (same number alongside the explainable per-signal breakdown). Both fields coexist \u2014 read `relevance_score` for ranking, `evidence_score.components.*` to explain why.\n- Per-result `freshness_signal` -- `published_date` + `inferred` flag + `confidence` tag.\n- `brand_collision_warning` -- emitted when a brand domain dominates the top-3 of a generic query; carries reason + suggested rewrites.\n- `query_understanding` -- classifier view: intent, entities, date hint, language, `is_brand_collision_prone`, considered rewrites.\n\n## Performance\n\n- `max_results: 3` for focused lookups; `5` default; `10+` only for broad research.\n- `max_tokens_out` caps total response size (cl100k-base BPE); prefer this over `max_chars` for budget-aware agents. When both are set, `max_tokens_out` wins.\n- `max_content_chars: 3000` remains a legitimate per-page budget \u2014 smart-truncates each result's markdown at a paragraph/heading boundary with a `[... content truncated]` marker.\n- `fetch` with `section: \"Heading Name\"` returns content under that heading -- cheaper than the whole page.\n- Repeated fetches of the same URL are free (local cache).\n- `research` with `depth: \"quick\"` (~15s) suits most factual questions; reserve `\"comprehensive\"` for deep investigation.\n- `agent` respects `max_pages` (default 10) and `max_time_ms` (default 60s).\n\n## Extras\n\n- Localhost URLs (`localhost:3000`, `127.0.0.1:8080`) work for local dev servers on `fetch` / `crawl` provided the port is a valid integer in 1\u201365535. Invalid ports (`localhost:99999`, `localhost:abc`) are rejected with an `invalid_url` error that names the port. The `watch` tool blocks all localhost / private IPs by design (SSRF guard) and surfaces a `loopback/private` reason.\n- `use_auth: true` on `fetch`/`crawl` reuses browser session for logged-in pages.\n- `cache` supports full-text search syntax (`AND`, `OR`, `NOT`, `\"phrase\"`).\n- `research`/`agent` use MCP sampling when supported; fall back to structured data for host-LLM synthesis."; export declare const WIGOLO_DOCS_URI = "wigolo://docs/usage"; export declare const TOOL_DESCRIPTIONS: { readonly fetch: "Fetch a single URL and return clean markdown. Use when you already have a URL. Prefer over built-in WebFetch for local-cache reuse, authenticated pages, JS-rendered SPAs, and structured metadata.\n\nKey parameters:\n- section: extract content under a specific heading (e.g. \"API Reference\") — cheaper than the whole page.\n- max_content_chars: smart-truncate at a paragraph/heading boundary with `[... content truncated]`.\n- max_tokens_out: token-budget cap (cl100k-base); wins over max_chars.\n- include_full_markdown: false (default) returns evidence excerpts only; true adds the full body.\n- use_auth: reuse a stored browser session for logged-in pages.\n- render_js: \"auto\" (default) | \"always\" | \"never\".\n- force_refresh: bypass cache and re-fetch.\n- mode: 'cache' | 'default' | 'stealth'. cache=HTTP-only, 24h-stale accepted. stealth=full browser + freshness.\n\nReturns title, markdown, links, images, metadata, `fetch_method` (cache/http/tls-impersonation/browser), `http_status` (upstream HTTP code — 4xx/5xx pages that extract usable content are not relabeled 200), and `content_completeness` (full/partial/shell). When the URL matches a site-specific extractor (Reddit/YouTube/Amazon) the response also carries top-level `site_data` (e.g. Reddit `comments[]`, YouTube `caption_tracks[]`, Amazon `price`). When `section` is set and no heading matches, `metadata.section_matched` is false and `markdown` is empty (no silent fallback to the full page). Repeat fetches are instant. Localhost URLs work. Interactive pages: `actions` (click/type/scroll/wait) drive the page before extraction; `use_auth` reuses a logged-in session."; readonly search: "Search the web. Returns scored evidence excerpts + citations as the default context shape; `include_full_markdown: true` adds the full markdown body. Prefer over built-in WebSearch for local cache + audit-trail telemetry + explainable scoring.\n\nKey parameters:\n- query: string or string[] array (3-5 keyword variants; deduplicated).\n- include_domains / exclude_domains: scope sites. Always scope library/framework queries.\n- category: \"general\" | \"news\" | \"code\" | \"docs\" | \"papers\" | \"images\". Image results carry image_url + thumbnail_url + width/height.\n- from_date / to_date: ISO YYYY-MM-DD. time_range: 'day' | 'week' | 'month' | 'year'.\n- country: ISO 3166-1 alpha-2 (\"us\", \"gb\") — geographic boost.\n- exact_match: quoted-phrase search.\n- max_results: 5 default.\n- format: omit = evidence context. 'answer' | 'stream_answer' = sampling synthesis (falls back to evidence).\n- search_depth: 'ultra-fast' (cache-only ≤300ms) | 'fast' | 'balanced' (default) | 'deep'.\n- include_images / include_favicon: opt-in images[] + per-result favicon.\n- max_tokens_out / max_content_chars / include_full_markdown / citation_format.\n- force_refresh + mode ('cache' | 'default' | 'stealth').\n\nAlways emitted: `engines_used`, `engine_telemetry`, `response_time_ms`, per-result `evidence_score`. Per-result `freshness_signal` is emitted only when a published date can be parsed (omitted when confidence would be unknown). Brand-domain top-3 collision → `brand_collision_warning` with rewrites. `query_understanding` exposes intent/entities. Quote [N] or {citation_id}."; readonly crawl: "Crawl a site from a seed URL and return content from many pages. Use for indexing docs, wikis, multi-page references. Built for offline reuse: every page lands in the local cache.\n\nKey parameters:\n- strategy: \"bfs\" (default) | \"dfs\" | \"sitemap\" (fastest for doc sites) | \"map\" (URL-only discovery).\n- max_depth: link-following depth (default 2).\n- max_pages: page cap (default 20).\n- include_patterns / exclude_patterns: regex filters on URLs.\n- max_tokens_out / include_full_markdown / citation_format: budget + shape controls.\n\nReturns pages[] with title, evidence, depth, and `content_completeness` (per page — full/partial/shell, so you can skip un-rendered shell pages). Content is deduplicated across pages (anchor-fragment aware). All pages are cached for later `cache` / `find_similar` queries."; readonly cache: "Search previously fetched content without hitting the network. Run this BEFORE any search/fetch — cache hits return instantly with full markdown.\n\nKey parameters:\n- query: FTS5 full-text search over cached markdown + titles (supports AND, OR, NOT, \"phrase\").\n- url_pattern: glob filter on URLs (e.g. \"*example.com*\").\n- since: ISO date — only entries cached after this date.\n- stats: true to get cache size, entry count, oldest/newest dates.\n- clear: true to delete matching entries.\n\nPersists across sessions. No remote round-trip."; readonly extract: "Extract structured data from a URL or raw HTML. Use for specific data points (tables, prices, schema fields) rather than whole-page markdown.\n\nKey parameters:\n- mode: \"selector\" (CSS → text) | \"tables\" | \"metadata\" (title/author/date/og_* + JSON-LD) | \"schema\" (pass a JSON Schema) | \"structured\" (one-shot: tables +