@staticn0va/wigolo 0.6.1 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE +1 -1
  2. package/SKILL.md +1 -1
  3. package/dist/config.js +1 -1
  4. package/dist/config.js.map +1 -1
  5. package/dist/instructions.d.ts +3 -3
  6. package/dist/instructions.d.ts.map +1 -1
  7. package/dist/instructions.js +41 -21
  8. package/dist/instructions.js.map +1 -1
  9. package/dist/research/pipeline.d.ts.map +1 -1
  10. package/dist/research/pipeline.js +36 -1
  11. package/dist/research/pipeline.js.map +1 -1
  12. package/dist/search/answer-synthesis.d.ts +6 -0
  13. package/dist/search/answer-synthesis.d.ts.map +1 -1
  14. package/dist/search/answer-synthesis.js +54 -0
  15. package/dist/search/answer-synthesis.js.map +1 -1
  16. package/dist/search/dedup.d.ts +1 -0
  17. package/dist/search/dedup.d.ts.map +1 -1
  18. package/dist/search/dedup.js +4 -0
  19. package/dist/search/dedup.js.map +1 -1
  20. package/dist/search/rerank.d.ts +1 -0
  21. package/dist/search/rerank.d.ts.map +1 -1
  22. package/dist/search/rerank.js +27 -2
  23. package/dist/search/rerank.js.map +1 -1
  24. package/dist/search/searxng.d.ts.map +1 -1
  25. package/dist/search/searxng.js +17 -8
  26. package/dist/search/searxng.js.map +1 -1
  27. package/dist/search/truncate.d.ts +2 -0
  28. package/dist/search/truncate.d.ts.map +1 -0
  29. package/dist/search/truncate.js +17 -0
  30. package/dist/search/truncate.js.map +1 -0
  31. package/dist/server.d.ts.map +1 -1
  32. package/dist/server.js +7 -2
  33. package/dist/server.js.map +1 -1
  34. package/dist/tools/fetch.d.ts.map +1 -1
  35. package/dist/tools/fetch.js +8 -1
  36. package/dist/tools/fetch.js.map +1 -1
  37. package/dist/tools/search.d.ts.map +1 -1
  38. package/dist/tools/search.js +89 -26
  39. package/dist/tools/search.js.map +1 -1
  40. package/dist/types.d.ts +6 -0
  41. package/dist/types.d.ts.map +1 -1
  42. package/package.json +1 -1
package/LICENSE CHANGED
@@ -19,7 +19,7 @@ Additional Use Grant: You may make production use of the Licensed Work,
19
19
 
20
20
  Change Date: 2029-04-12
21
21
 
22
- Change License: MIT License
22
+ Change License: GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later)
23
23
 
24
24
  For information about alternative licensing arrangements, contact:
25
25
  ktowhid20@gmail.com
package/SKILL.md CHANGED
@@ -357,4 +357,4 @@ Full list: see `src/config.ts`.
357
357
 
358
358
  - Repository: https://github.com/KnockOutEZ/wigolo
359
359
  - npm: https://www.npmjs.com/package/@staticn0va/wigolo
360
- - License: BUSL-1.1 (converts to open source on 2029-04-12)
360
+ - License: BUSL-1.1 (converts to AGPL-3.0 on 2029-04-12)
package/dist/config.js CHANGED
@@ -65,7 +65,7 @@ export function getConfig() {
65
65
  logLevel: envStr('LOG_LEVEL', 'info'),
66
66
  logFormat: envStr('LOG_FORMAT', 'json'),
67
67
  trafilatura: envStr('WIGOLO_TRAFILATURA', 'auto'),
68
- reranker: (envStr('WIGOLO_RERANKER') ?? 'none'),
68
+ reranker: (envStr('WIGOLO_RERANKER') ?? 'flashrank'),
69
69
  rerankerModel: envStr('WIGOLO_RERANKER_MODEL') ?? 'ms-marco-MiniLM-L-12-v2',
70
70
  relevanceThreshold: parseFloat(envStr('WIGOLO_RELEVANCE_THRESHOLD') ?? '0') || 0,
71
71
  bootstrapMaxAttempts: envInt('WIGOLO_BOOTSTRAP_MAX_ATTEMPTS', 3),
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AA2D7D,SAAS,MAAM,CAAC,GAAW,EAAE,WAA0B,IAAI;IACzD,OAAO,OAAO,CAAC,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AE,MAAM,CAAC,kCAAkC,EAAE,IAAI,CAAC;QACxE,aAAa,EAAE,MAAM,CAAC,uBAAuB,CAAC;QAC9C,iBAAiB,EAAE,OAAO,CAAC,2BAA2B,EAAE,KAAK,CAAC;QAC9D,0BAA0B,EAAE,MAAM,CAAC,qCAAqC,EAAE,CAAC,CAAC;KAC7E,CAAC;IAEF,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,YAAY,GAAG,IAAI,CAAC;AACtB,CAAC"}
@@ -14,10 +14,10 @@
14
14
  * Parameter schemas (types, enums, required/optional) belong on the JSON
15
15
  * Schema, not here. Installation/configuration is for humans, not LLMs.
16
16
  */
17
- export declare const WIGOLO_INSTRUCTIONS = "Wigolo 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 SQLite cache that persists across sessions.\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\", \"docs.python.org\"]`, `category: \"docs\"` |\n| Error debugging | `search` | exact error string as query, `category: \"code\"` |\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| Direct answer | `search` | `format: \"answer\"` for a synthesized direct response |\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: \"schema\"` with a JSON Schema, or `mode: \"tables\"` |\n| Site inventory | `crawl` | `strategy: \"map\"` for URL-only discovery, no content fetched |\n\n## Rapidly changing content\n\nFor news, prices, status pages, release notes, or any content that changes frequently, bypass the cache with `force_refresh: true`:\n\n search({ query: \"...\", force_refresh: true })\n fetch({ url: \"...\", force_refresh: true })\n\nWhen freshness matters more than speed, use `force_refresh`. When speed matters more than freshness (documentation, tutorials, reference pages), let the cache work -- it is much faster.\n\n## Check the cache before going to the network\n\nBefore every `search` or `fetch`, consider a `cache` call with the query text or URL pattern. Pages read in this or a prior session return instantly with their full markdown -- no network, no rate limits. The `research` and `agent` tools check the cache internally, so you do not need a separate call for those.\n\n## Multi-query search strategy\n\nFor broad or exploratory queries, pass an array of 3-5 semantically varied keyword forms rather than a single natural-language question. Example: instead of \"how does React handle state management\", pass `[\"react state management\", \"useState useReducer patterns\", \"react hooks state\", \"react context vs redux\"]`. The search tool deduplicates across sub-queries automatically.\n\n## Pick the right strategy\n\n- For documentation sites, prefer `crawl` with `strategy: \"sitemap\"` -- it is faster and more complete than BFS because it reads sitemap.xml directly.\n- When you only need to discover what pages exist on a site, use `crawl` with `strategy: \"map\"`. It returns URLs only, no content, and is far cheaper than a full crawl. Follow up with targeted `fetch` calls.\n- For structured data (prices, specs, listings, table rows), use `extract` with `mode: \"schema\"` or `mode: \"tables\"`. Reach for `fetch` only when you want the whole page as markdown.\n- For complex questions requiring synthesis from multiple sources, use `research` instead of manually chaining `search` + `fetch` calls.\n- For natural-language data gathering tasks (\"find the pricing for the top 5 CRM tools\"), use `agent` with an optional `schema` to structure the output.\n\n## Scope searches, do not just broaden queries\n\n`search` accepts `include_domains` (e.g. `[\"react.dev\", \"developer.mozilla.org\"]`) and a `category` such as `\"docs\"`, `\"code\"`, `\"news\"`, or `\"papers\"`. A scoped query usually beats a broader query with post-filtering.\n\n## Performance\n\n- `max_results: 3` for focused lookups; `5` is the default; `10+` only for broad research.\n- `fetch` with `section: \"Heading Name\"` returns just the content under that heading. Cheaper and more relevant than the whole page.\n- Repeated fetches of the same URL are free -- served directly from the SQLite cache.\n- `research` with `depth: \"quick\"` is fast (~15s) and sufficient for most factual questions. Reserve `\"comprehensive\"` for topics requiring deep investigation.\n- `agent` respects `max_pages` (default 10) and `max_time_ms` (default 60s) to bound resource usage.\n\n## Capabilities worth knowing\n\n- Localhost URLs work: `http://localhost:3000`, `http://127.0.0.1:8080`, and similar. Useful for reading local dev servers and internal docs.\n- `use_auth: true` on `fetch` and `crawl` reuses the user's configured browser session for pages behind a login.\n- `cache` accepts FTS5 query syntax (`AND`, `OR`, `NOT`, `\"exact phrase\"`) for precise lookups.\n- `crawl` accepts regex `include_patterns` and `exclude_patterns` to stay inside a section of a large site.\n- `find_similar` uses cached embeddings when available -- no network call needed if the content has been seen before.\n- `research` and `agent` use MCP requestSampling for intelligent decomposition and synthesis when the client supports it. Without sampling support, they return raw sources in context format.";
17
+ export declare const WIGOLO_INSTRUCTIONS = "Wigolo 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 SQLite cache that persists across sessions.\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| Direct answer | `search` | `format: \"answer\"` for a synthesized direct response |\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: \"schema\"` with a JSON Schema, or `mode: \"tables\"` |\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 (\"find pricing for top 5 CRM tools\"), use `agent` with optional `schema`.\n\n## Scope searches by domain \u2014 biggest single quality lever\n\nFor framework, library, SDK, or tool-specific queries, **always pass `include_domains` with the project's official site(s)**. Unscoped queries return generic results from sites that happen to mention the keywords (MDN glossary entries, Docker images, unrelated tutorials). Domain scoping is the single biggest quality improvement for these queries.\n\nExamples:\n\n search({ query: \"Next.js authentication App Router\", include_domains: [\"nextjs.org\", \"authjs.dev\", \"clerk.com\"] })\n search({ query: \"react server components\", include_domains: [\"react.dev\", \"nextjs.org\"] })\n search({ query: \"prisma migrations\", include_domains: [\"prisma.io\"] })\n search({ query: \"stripe webhooks\", include_domains: [\"stripe.com\", \"docs.stripe.com\"] })\n\nWhen NOT to scope:\n\n- Error strings (errors surface across many sites)\n- Broad exploration (\"state management 2026\")\n- News and current events\n\nIf a first unscoped `search` returns noisy results, retry with `include_domains` scoped to the official source rather than rephrasing the query.\n\n`category` (`\"general\"`, `\"news\"`, `\"code\"`, `\"docs\"`, `\"papers\"`) is a coarse content-type filter and is no substitute for domain scoping. `category: \"docs\"` on its own returns generic documentation portals, not the docs you want -- pair it with `include_domains` or omit it.\n\n## Performance\n\n- `max_results: 3` for focused lookups; `5` default; `10+` only for broad research.\n- `max_content_chars: 3000` on `search` or `fetch` smart-truncates each result's markdown at a paragraph/heading boundary with a `[... content truncated]` marker. Keeps context compact for AI agents. Prefer this over raw `max_chars` slicing.\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 (SQLite 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## Capabilities worth knowing\n\n- Localhost URLs work: `http://localhost:3000`, `http://127.0.0.1:8080`, and similar. Useful for reading local dev servers and internal docs.\n- `use_auth: true` on `fetch` and `crawl` reuses the user's configured browser session for pages behind a login.\n- `cache` accepts FTS5 query syntax (`AND`, `OR`, `NOT`, `\"exact phrase\"`) for precise lookups.\n- `crawl` accepts regex `include_patterns` and `exclude_patterns` to stay inside a section of a large site.\n- `find_similar` uses cached embeddings when available -- no network call needed if the content has been seen before.\n- `research` and `agent` use MCP requestSampling for intelligent decomposition and synthesis when the client supports it. Without sampling support, they return raw sources in context format.";
18
18
  export declare const TOOL_DESCRIPTIONS: {
19
- readonly fetch: "Fetch a single URL and return clean markdown. Use when you have a specific URL to read. Automatically detects if JavaScript rendering is needed.\n\nKey parameters:\n- section: extract content under a specific heading (e.g., section: \"API Reference\") -- faster than reading the whole page\n- use_auth: true to use stored browser session for authenticated/private pages\n- render_js: \"auto\" (default, detects JS need), \"always\" (force browser), \"never\" (HTTP only, fastest)\n- headers: custom HTTP headers if needed\n- force_refresh: true to bypass cache and fetch fresh content from the network\n\nReturns title, markdown content, links, images, and metadata. Result is cached locally -- subsequent fetches of the same URL return instantly. Works with localhost URLs (localhost:3000, etc.) for reading local dev servers.\n\nUse force_refresh: true for pages that change frequently (news sites, changelogs, dashboards, API status pages). By default, previously fetched pages are served from local cache for speed.";
20
- readonly search: "Search the web and return full markdown content from top results. Use for finding information on any topic -- returns extracted page content, not just snippets.\n\nKey parameters:\n- query: a search string, or an array of 3-5 semantically varied keyword forms for broader coverage. Arrays are deduplicated and merged automatically.\n- include_domains/exclude_domains: scope results to specific sites (e.g., include_domains: [\"react.dev\"])\n- category: \"general\", \"news\", \"code\", \"docs\", \"papers\" -- filters by content type\n- from_date/to_date: ISO dates for time-bounded queries\n- max_results: default 5. Use 3 for focused queries, 10+ for research.\n- format: \"full\" (default, structured JSON), \"context\" (single token-budgeted string for LLM injection), \"answer\" (synthesized direct answer via requestSampling), \"stream_answer\" (same as answer, with MCP progress notifications emitted between pipeline phases)\n- force_refresh: true to bypass all caches (search results and page content)\n\nThe \"answer\" format uses the MCP client's sampling capability to synthesize a direct response from search results. If sampling is not supported, falls back to \"context\" format. \"stream_answer\" emits notifications/progress messages at each pipeline phase (search, fetch, synthesize) when the client provides a progressToken via request._meta — token-level streaming of the LLM response is not supported by MCP sampling, so the answer itself still arrives as one block.\n\nResults include title, URL, relevance_score, and full markdown_content per result. Previously fetched pages are served from local cache.\n\nUse force_refresh: true when you need current information that may have changed since the last search. Default behavior uses cached results when available.";
19
+ readonly fetch: "Fetch a single URL and return clean markdown. Use when you have a specific URL to read. Automatically detects if JavaScript rendering is needed.\n\nKey parameters:\n- section: extract content under a specific heading (e.g., section: \"API Reference\") -- faster than reading the whole page\n- max_content_chars: smart-truncate markdown at a paragraph/heading boundary with a `[... content truncated]` marker (e.g., 3000 for compact context). Preferred over max_chars for AI agents.\n- use_auth: true to use stored browser session for authenticated/private pages\n- render_js: \"auto\" (default, detects JS need), \"always\" (force browser), \"never\" (HTTP only, fastest)\n- headers: custom HTTP headers if needed\n- force_refresh: true to bypass cache and fetch fresh content from the network\n\nReturns title, markdown content, links, images, and metadata. Result is cached locally -- subsequent fetches of the same URL return instantly. Works with localhost URLs (localhost:3000, etc.) for reading local dev servers.\n\nUse force_refresh: true for pages that change frequently (news sites, changelogs, dashboards, API status pages). By default, previously fetched pages are served from local cache for speed.";
20
+ readonly search: "Search the web and return full markdown content from top results. Use for finding information on any topic -- returns extracted page content, not just snippets.\n\nKey parameters:\n- query: a search string, or an array of 3-5 semantically varied keyword forms for broader coverage. Arrays are deduplicated and merged automatically.\n- include_domains/exclude_domains: scope results to specific sites (e.g., [\"react.dev\", \"nextjs.org\"]). For framework/library queries, ALWAYS scope to the official site -- unscoped queries return noise.\n- category: \"general\", \"news\", \"code\", \"docs\", \"papers\" -- coarse content-type filter. \"docs\" alone returns generic portals; pair with include_domains or omit.\n- from_date/to_date: ISO dates for time-bounded queries\n- max_results: default 5. Use 3 for focused queries, 10+ for research.\n- format: \"full\" (default), \"context\", \"answer\" (sampling synthesis; heuristic key-point summary if unsupported), \"stream_answer\" (answer + progress notifications)\n- max_content_chars: smart-truncate each result markdown at a paragraph boundary with a `[... content truncated]` marker (e.g., 3000). Preferred for AI agent context budgets.\n- force_refresh: true to bypass all caches (search results and page content)\n\nThe \"answer\" format uses the MCP client's sampling capability to synthesize a direct response from search results. If sampling is not supported, falls back to \"context\" format. \"stream_answer\" emits notifications/progress messages at each pipeline phase (search, fetch, synthesize) when the client provides a progressToken via request._meta — token-level streaming of the LLM response is not supported by MCP sampling, so the answer itself still arrives as one block.\n\nResults include title, URL, relevance_score, and full markdown_content per result. Previously fetched pages are served from local cache.\n\nUse force_refresh: true when you need current information that may have changed since the last search. Default behavior uses cached results when available.";
21
21
  readonly crawl: "Crawl a website starting from a URL and return content from multiple pages. Use for indexing documentation sites, wikis, or any multi-page resource.\n\nKey parameters:\n- strategy: \"bfs\" (breadth-first, default), \"dfs\" (depth-first), \"sitemap\" (use sitemap.xml -- fastest for doc sites), \"map\" (URL discovery only, no content -- fastest for scoping a site)\n- max_depth: how many links deep to follow (default 2)\n- max_pages: maximum pages to fetch (default 20)\n- include_patterns/exclude_patterns: regex filters on URLs\n\nReturns an array of pages with title, markdown, and depth. Content is deduplicated across pages (repeated nav/headers/footers stripped). All pages are cached for later cache queries.";
22
22
  readonly cache: "Search previously fetched content without hitting the network. Use before searching the web -- if relevant content was already fetched or crawled, this returns it instantly.\n\nKey parameters:\n- query: full-text search over cached markdown and titles (supports FTS5 syntax: AND, OR, NOT, \"phrase match\")\n- url_pattern: glob filter on URLs (e.g., \"*example.com*\")\n- since: ISO date -- only results cached after this date\n- stats: true to get cache size, entry count, oldest/newest dates\n- clear: true to delete matching entries\n\nReturns matching cached pages with full markdown content. Cache persists across sessions in local SQLite.";
23
23
  readonly extract: "Extract structured data from a URL or raw HTML. Use when you need specific data points, tables, or metadata rather than full page markdown.\n\nKey parameters:\n- mode: \"selector\" (CSS selector -> text), \"tables\" (HTML tables -> JSON rows), \"metadata\" (title/author/date/description), \"schema\" (JSON Schema -> heuristic field extraction)\n- css_selector: required for mode=\"selector\" -- any valid CSS selector\n- schema: for mode=\"schema\", a JSON Schema object describing the fields to extract\n- multiple: true to return array of all matches (mode=\"selector\" only)\n\nFor mode=\"tables\", returns array of table objects with headers and row data. For mode=\"schema\", pass { price: \"string\", name: \"string\" } and get structured fields extracted from the page.";
@@ -1 +1 @@
1
- {"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,mBAAmB,i/LAuEmK,CAAC;AAEpM,eAAO,MAAM,iBAAiB;;;;;;;;;CA4GpB,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,iBAAiB,CAAC"}
1
+ {"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,mBAAmB,wyNAyFmK,CAAC;AAEpM,eAAO,MAAM,iBAAiB;;;;;;;;;CA8GpB,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,iBAAiB,CAAC"}
@@ -31,8 +31,8 @@ export const WIGOLO_INSTRUCTIONS = `Wigolo is a local-first web access layer: se
31
31
 
32
32
  | Intent | Tool | Key parameters |
33
33
  |--------|------|----------------|
34
- | Documentation lookup | \`search\` | \`include_domains: ["react.dev", "docs.python.org"]\`, \`category: "docs"\` |
35
- | Error debugging | \`search\` | exact error string as query, \`category: "code"\` |
34
+ | Documentation lookup | \`search\` | \`include_domains: ["react.dev", "nextjs.org"]\` -- scope to the project's official site, do not rely on \`category: "docs"\` alone |
35
+ | Error debugging | \`search\` | exact error string as query, \`category: "code"\` (no domain scoping -- errors appear everywhere) |
36
36
  | Library research | \`crawl\` | seed URL of docs site, \`strategy: "sitemap"\`, then \`cache\` for later queries |
37
37
  | Related content | \`find_similar\` | \`url\` of a known good page, or \`concept\` as free text |
38
38
  | Direct answer | \`search\` | \`format: "answer"\` for a synthesized direct response |
@@ -43,40 +43,58 @@ export const WIGOLO_INSTRUCTIONS = `Wigolo is a local-first web access layer: se
43
43
 
44
44
  ## Rapidly changing content
45
45
 
46
- For news, prices, status pages, release notes, or any content that changes frequently, bypass the cache with \`force_refresh: true\`:
46
+ For news, prices, status pages, or release notes, bypass the cache with \`force_refresh: true\`:
47
47
 
48
48
  search({ query: "...", force_refresh: true })
49
49
  fetch({ url: "...", force_refresh: true })
50
50
 
51
- When freshness matters more than speed, use \`force_refresh\`. When speed matters more than freshness (documentation, tutorials, reference pages), let the cache work -- it is much faster.
51
+ For docs, tutorials, and reference pages, let the cache work -- much faster.
52
52
 
53
53
  ## Check the cache before going to the network
54
54
 
55
- Before every \`search\` or \`fetch\`, consider a \`cache\` call with the query text or URL pattern. Pages read in this or a prior session return instantly with their full markdown -- no network, no rate limits. The \`research\` and \`agent\` tools check the cache internally, so you do not need a separate call for those.
55
+ Before 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.
56
56
 
57
57
  ## Multi-query search strategy
58
58
 
59
- For broad or exploratory queries, pass an array of 3-5 semantically varied keyword forms rather than a single natural-language question. Example: instead of "how does React handle state management", pass \`["react state management", "useState useReducer patterns", "react hooks state", "react context vs redux"]\`. The search tool deduplicates across sub-queries automatically.
59
+ For 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.
60
60
 
61
61
  ## Pick the right strategy
62
62
 
63
- - For documentation sites, prefer \`crawl\` with \`strategy: "sitemap"\` -- it is faster and more complete than BFS because it reads sitemap.xml directly.
64
- - When you only need to discover what pages exist on a site, use \`crawl\` with \`strategy: "map"\`. It returns URLs only, no content, and is far cheaper than a full crawl. Follow up with targeted \`fetch\` calls.
65
- - For structured data (prices, specs, listings, table rows), use \`extract\` with \`mode: "schema"\` or \`mode: "tables"\`. Reach for \`fetch\` only when you want the whole page as markdown.
66
- - For complex questions requiring synthesis from multiple sources, use \`research\` instead of manually chaining \`search\` + \`fetch\` calls.
67
- - For natural-language data gathering tasks ("find the pricing for the top 5 CRM tools"), use \`agent\` with an optional \`schema\` to structure the output.
63
+ - For docs sites, prefer \`crawl\` with \`strategy: "sitemap"\` -- faster and more complete than BFS.
64
+ - For URL discovery only, use \`crawl\` with \`strategy: "map"\` -- URLs only, no content. Follow with targeted \`fetch\` calls.
65
+ - 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.
66
+ - For multi-source synthesis, use \`research\` instead of chaining \`search\` + \`fetch\` manually.
67
+ - For natural-language data gathering ("find pricing for top 5 CRM tools"), use \`agent\` with optional \`schema\`.
68
68
 
69
- ## Scope searches, do not just broaden queries
69
+ ## Scope searches by domain biggest single quality lever
70
70
 
71
- \`search\` accepts \`include_domains\` (e.g. \`["react.dev", "developer.mozilla.org"]\`) and a \`category\` such as \`"docs"\`, \`"code"\`, \`"news"\`, or \`"papers"\`. A scoped query usually beats a broader query with post-filtering.
71
+ For framework, library, SDK, or tool-specific queries, **always pass \`include_domains\` with the project's official site(s)**. Unscoped queries return generic results from sites that happen to mention the keywords (MDN glossary entries, Docker images, unrelated tutorials). Domain scoping is the single biggest quality improvement for these queries.
72
+
73
+ Examples:
74
+
75
+ search({ query: "Next.js authentication App Router", include_domains: ["nextjs.org", "authjs.dev", "clerk.com"] })
76
+ search({ query: "react server components", include_domains: ["react.dev", "nextjs.org"] })
77
+ search({ query: "prisma migrations", include_domains: ["prisma.io"] })
78
+ search({ query: "stripe webhooks", include_domains: ["stripe.com", "docs.stripe.com"] })
79
+
80
+ When NOT to scope:
81
+
82
+ - Error strings (errors surface across many sites)
83
+ - Broad exploration ("state management 2026")
84
+ - News and current events
85
+
86
+ If a first unscoped \`search\` returns noisy results, retry with \`include_domains\` scoped to the official source rather than rephrasing the query.
87
+
88
+ \`category\` (\`"general"\`, \`"news"\`, \`"code"\`, \`"docs"\`, \`"papers"\`) is a coarse content-type filter and is no substitute for domain scoping. \`category: "docs"\` on its own returns generic documentation portals, not the docs you want -- pair it with \`include_domains\` or omit it.
72
89
 
73
90
  ## Performance
74
91
 
75
- - \`max_results: 3\` for focused lookups; \`5\` is the default; \`10+\` only for broad research.
76
- - \`fetch\` with \`section: "Heading Name"\` returns just the content under that heading. Cheaper and more relevant than the whole page.
77
- - Repeated fetches of the same URL are free -- served directly from the SQLite cache.
78
- - \`research\` with \`depth: "quick"\` is fast (~15s) and sufficient for most factual questions. Reserve \`"comprehensive"\` for topics requiring deep investigation.
79
- - \`agent\` respects \`max_pages\` (default 10) and \`max_time_ms\` (default 60s) to bound resource usage.
92
+ - \`max_results: 3\` for focused lookups; \`5\` default; \`10+\` only for broad research.
93
+ - \`max_content_chars: 3000\` on \`search\` or \`fetch\` smart-truncates each result's markdown at a paragraph/heading boundary with a \`[... content truncated]\` marker. Keeps context compact for AI agents. Prefer this over raw \`max_chars\` slicing.
94
+ - \`fetch\` with \`section: "Heading Name"\` returns content under that heading -- cheaper than the whole page.
95
+ - Repeated fetches of the same URL are free (SQLite cache).
96
+ - \`research\` with \`depth: "quick"\` (~15s) suits most factual questions; reserve \`"comprehensive"\` for deep investigation.
97
+ - \`agent\` respects \`max_pages\` (default 10) and \`max_time_ms\` (default 60s).
80
98
 
81
99
  ## Capabilities worth knowing
82
100
 
@@ -91,6 +109,7 @@ export const TOOL_DESCRIPTIONS = {
91
109
 
92
110
  Key parameters:
93
111
  - section: extract content under a specific heading (e.g., section: "API Reference") -- faster than reading the whole page
112
+ - max_content_chars: smart-truncate markdown at a paragraph/heading boundary with a \`[... content truncated]\` marker (e.g., 3000 for compact context). Preferred over max_chars for AI agents.
94
113
  - use_auth: true to use stored browser session for authenticated/private pages
95
114
  - render_js: "auto" (default, detects JS need), "always" (force browser), "never" (HTTP only, fastest)
96
115
  - headers: custom HTTP headers if needed
@@ -103,11 +122,12 @@ Use force_refresh: true for pages that change frequently (news sites, changelogs
103
122
 
104
123
  Key parameters:
105
124
  - query: a search string, or an array of 3-5 semantically varied keyword forms for broader coverage. Arrays are deduplicated and merged automatically.
106
- - include_domains/exclude_domains: scope results to specific sites (e.g., include_domains: ["react.dev"])
107
- - category: "general", "news", "code", "docs", "papers" -- filters by content type
125
+ - include_domains/exclude_domains: scope results to specific sites (e.g., ["react.dev", "nextjs.org"]). For framework/library queries, ALWAYS scope to the official site -- unscoped queries return noise.
126
+ - category: "general", "news", "code", "docs", "papers" -- coarse content-type filter. "docs" alone returns generic portals; pair with include_domains or omit.
108
127
  - from_date/to_date: ISO dates for time-bounded queries
109
128
  - max_results: default 5. Use 3 for focused queries, 10+ for research.
110
- - format: "full" (default, structured JSON), "context" (single token-budgeted string for LLM injection), "answer" (synthesized direct answer via requestSampling), "stream_answer" (same as answer, with MCP progress notifications emitted between pipeline phases)
129
+ - format: "full" (default), "context", "answer" (sampling synthesis; heuristic key-point summary if unsupported), "stream_answer" (answer + progress notifications)
130
+ - max_content_chars: smart-truncate each result markdown at a paragraph boundary with a \`[... content truncated]\` marker (e.g., 3000). Preferred for AI agent context budgets.
111
131
  - force_refresh: true to bypass all caches (search results and page content)
112
132
 
113
133
  The "answer" format uses the MCP client's sampling capability to synthesize a direct response from search results. If sampling is not supported, falls back to "context" format. "stream_answer" emits notifications/progress messages at each pipeline phase (search, fetch, synthesize) when the client provides a progressToken via request._meta — token-level streaming of the LLM response is not supported by MCP sampling, so the answer itself still arrives as one block.
@@ -1 +1 @@
1
- {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mMAuEgK,CAAC;AAEpM,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,KAAK,EAAE;;;;;;;;;;;6LAWoL;IAE3L,MAAM,EAAE;;;;;;;;;;;;;;;4JAekJ;IAE1J,KAAK,EAAE;;;;;;;;uLAQ8K;IAErL,KAAK,EAAE;;;;;;;;;0GASiG;IAExG,OAAO,EAAE;;;;;;;;4LAQiL;IAE1L,YAAY,EAAE;;;;;;;;;;;uEAWuD;IAErE,QAAQ,EAAE;;;;;;;;;;;;;;yHAc6G;IAEvH,KAAK,EAAE;;;;;;;;;;;;;;;;sKAgB6J;CAC5J,CAAC"}
1
+ {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mMAyFgK,CAAC;AAEpM,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,KAAK,EAAE;;;;;;;;;;;;6LAYoL;IAE3L,MAAM,EAAE;;;;;;;;;;;;;;;;4JAgBkJ;IAE1J,KAAK,EAAE;;;;;;;;uLAQ8K;IAErL,KAAK,EAAE;;;;;;;;;0GASiG;IAExG,OAAO,EAAE;;;;;;;;4LAQiL;IAE1L,YAAY,EAAE;;;;;;;;;;;uEAWuD;IAErE,QAAQ,EAAE;;;;;;;;;;;;;;yHAc6G;IAEvH,KAAK,EAAE;;;;;;;;;;;;;;;;sKAgB6J;CAC5J,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/research/pipeline.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EAEd,YAAY,EACb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAUtD,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,YAAY,EAAE,EACvB,MAAM,EAAE,WAAW,EACnB,MAAM,CAAC,EAAE,qBAAqB,GAC7B,OAAO,CAAC,cAAc,CAAC,CAmGzB"}
1
+ {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/research/pipeline.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EAEd,YAAY,EACb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAatD,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,YAAY,EAAE,EACvB,MAAM,EAAE,WAAW,EACnB,MAAM,CAAC,EAAE,qBAAqB,GAC7B,OAAO,CAAC,cAAc,CAAC,CAoGzB"}
@@ -6,13 +6,17 @@ import { rerankResults } from '../search/rerank.js';
6
6
  import { applyAllFilters } from '../search/filters.js';
7
7
  import { fanOutSearch } from '../search/multi-query.js';
8
8
  import { extractContent } from '../extraction/pipeline.js';
9
+ import { truncateSmartly } from '../search/truncate.js';
9
10
  import { cacheContent } from '../cache/store.js';
11
+ import { getEmbeddingService } from '../embedding/embed.js';
10
12
  const log = createLogger('research');
11
13
  const DEPTH_CONFIG = {
12
14
  quick: { subQueries: 2, minSources: 5, maxSources: 8 },
13
15
  standard: { subQueries: 4, minSources: 10, maxSources: 15 },
14
16
  comprehensive: { subQueries: 7, minSources: 20, maxSources: 25 },
15
17
  };
18
+ const PER_SOURCE_CHAR_CAP = 3000;
19
+ const TOTAL_SOURCES_CHAR_CAP = 40000;
16
20
  export async function runResearchPipeline(input, engines, router, server) {
17
21
  const start = Date.now();
18
22
  const depth = input.depth ?? 'standard';
@@ -56,6 +60,7 @@ export async function runResearchPipeline(input, engines, router, server) {
56
60
  }
57
61
  // Phase 4: Fetch top sources in parallel
58
62
  const sources = await fetchSources(merged, router, maxSources);
63
+ applySourceBudget(sources, PER_SOURCE_CHAR_CAP, TOTAL_SOURCES_CHAR_CAP);
59
64
  log.info('fetch phase complete', {
60
65
  fetched: sources.filter((s) => s.fetched).length,
61
66
  failed: sources.filter((s) => !s.fetched).length,
@@ -101,16 +106,26 @@ async function fetchSources(merged, router, maxSources) {
101
106
  maxChars: 30000,
102
107
  contentType: raw.contentType,
103
108
  });
109
+ const truncated = truncateSmartly(extraction.markdown, PER_SOURCE_CHAR_CAP);
104
110
  try {
105
111
  cacheContent(raw, extraction);
106
112
  }
107
113
  catch (err) {
108
114
  log.debug('failed to cache research source', { url: result.url, error: String(err) });
109
115
  }
116
+ try {
117
+ const embeddingService = getEmbeddingService();
118
+ if (embeddingService.isAvailable()) {
119
+ embeddingService.embedAsync(raw.finalUrl, extraction.markdown);
120
+ }
121
+ }
122
+ catch (err) {
123
+ log.debug('embedding hook skipped for research source', { error: String(err) });
124
+ }
110
125
  return {
111
126
  url: result.url,
112
127
  title: extraction.title || result.title,
113
- markdown_content: extraction.markdown,
128
+ markdown_content: truncated,
114
129
  relevance_score: result.relevance_score,
115
130
  fetched: true,
116
131
  };
@@ -132,4 +147,24 @@ async function fetchSources(merged, router, maxSources) {
132
147
  });
133
148
  return Promise.all(fetchPromises);
134
149
  }
150
+ // Cap total returned markdown_content across sources in relevance order.
151
+ // Later (lower-relevance) sources get trimmed further when budget runs low;
152
+ // any source past the cap is set to empty content (caller still sees url/title).
153
+ function applySourceBudget(sources, perSourceCap, totalCap) {
154
+ let used = 0;
155
+ for (const s of sources) {
156
+ if (!s.markdown_content)
157
+ continue;
158
+ if (used >= totalCap) {
159
+ s.markdown_content = '';
160
+ continue;
161
+ }
162
+ const remaining = totalCap - used;
163
+ const cap = Math.min(perSourceCap, remaining);
164
+ if (s.markdown_content.length > cap) {
165
+ s.markdown_content = truncateSmartly(s.markdown_content, cap);
166
+ }
167
+ used += s.markdown_content.length;
168
+ }
169
+ }
135
170
  //# s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H,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AACpC,CAAC;AAED,yEAAyE;AACzE,4EAA4E;AAC5E,iFAAiF;AACjF,SAAS,iBAAiB,CACxB,OAAyB,EACzB,YAAoB,EACpB,QAAgB;IAEhB,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,CAAC,CAAC,gBAAgB;YAAE,SAAS;QAClC,IAAI,IAAI,IAAI,QAAQ,EAAE,CAAC;YACrB,CAAC,CAAC,gBAAgB,GAAG,EAAE,CAAC;YACxB,SAAS;QACX,CAAC;QACD,MAAM,SAAS,GAAG,QAAQ,GAAG,IAAI,CAAC;QAClC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;QAC9C,IAAI,CAAC,CAAC,gBAAgB,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YACpC,CAAC,CAAC,gBAAgB,GAAG,eAAe,CAAC,CAAC,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;QAChE,CAAC;QACD,IAAI,IAAI,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC;IACpC,CAAC;AACH,CAAC"}
@@ -9,5 +9,11 @@ export interface SynthesisResult {
9
9
  export declare function synthesizeAnswer(results: SearchResultItem[], query: string, server: SamplingCapableServer): Promise<SynthesisResult>;
10
10
  export declare function buildSourcesText(results: SearchResultItem[]): string;
11
11
  export declare function buildSynthesisPrompt(query: string, sourcesText: string): string;
12
+ export interface StructuredFallbackResult {
13
+ answer: string;
14
+ citations: Citation[];
15
+ warning: string;
16
+ }
17
+ export declare function buildStructuredFallback(results: SearchResultItem[], query: string): StructuredFallbackResult;
12
18
  export declare function extractCitations(answer: string, results: SearchResultItem[]): Citation[];
13
19
  //# sourceMappingURL=answer-synthesis.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"answer-synthesis.d.ts","sourceRoot":"","sources":["../../src/search/answer-synthesis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAa3D,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,gBAAgB,EAAE,EAC3B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,eAAe,CAAC,CAwD1B;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAwBpE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAc/E;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,EAAE,GAC1B,QAAQ,EAAE,CA6BZ"}
1
+ {"version":3,"file":"answer-synthesis.d.ts","sourceRoot":"","sources":["../../src/search/answer-synthesis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAe3D,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,gBAAgB,EAAE,EAC3B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,eAAe,CAAC,CAwD1B;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAwBpE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAc/E;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAID,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,gBAAgB,EAAE,EAC3B,KAAK,EAAE,MAAM,GACZ,wBAAwB,CA8B1B;AAyBD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,gBAAgB,EAAE,GAC1B,QAAQ,EAAE,CA6BZ"}
@@ -3,6 +3,8 @@ import { createLogger } from '../logger.js';
3
3
  const log = createLogger('search');
4
4
  const MAX_CHARS_PER_SOURCE = 3000;
5
5
  const MAX_RESPONSE_TOKENS = 1500;
6
+ const FALLBACK_MAX_BULLETS = 5;
7
+ const FALLBACK_KEYPOINT_MAX_CHARS = 240;
6
8
  export async function synthesizeAnswer(results, query, server) {
7
9
  try {
8
10
  const sourcesText = buildSourcesText(results);
@@ -87,6 +89,58 @@ Instructions:
87
89
  - If the sources don't adequately answer the question, say so.
88
90
  - Do not include information not found in the provided sources.`;
89
91
  }
92
+ // Heuristic answer without LLM sampling: top-N sources as bulleted key points
93
+ // with numeric citations. Used when client lacks sampling capability.
94
+ export function buildStructuredFallback(results, query) {
95
+ const bullets = [];
96
+ const citations = [];
97
+ let n = 0;
98
+ for (const r of results) {
99
+ if (n >= FALLBACK_MAX_BULLETS)
100
+ break;
101
+ const body = (r.markdown_content && r.markdown_content.trim()) || (r.snippet && r.snippet.trim()) || '';
102
+ if (!body)
103
+ continue;
104
+ const keypoint = extractKeypoint(body, FALLBACK_KEYPOINT_MAX_CHARS);
105
+ if (!keypoint)
106
+ continue;
107
+ n += 1;
108
+ bullets.push(`- **${r.title}** — ${keypoint} [${n}]`);
109
+ citations.push({ index: n, url: r.url, title: r.title, snippet: r.snippet });
110
+ }
111
+ if (bullets.length === 0) {
112
+ return { answer: '', citations: [], warning: 'No sampling server available; no content to summarize' };
113
+ }
114
+ const q = query && query.trim() ? query.trim() : 'this query';
115
+ const answer = `Based on the top ${bullets.length} sources for "${q}":\n\n${bullets.join('\n')}\n\nSources:\n${citations.map(c => `[${c.index}] ${c.title} — ${c.url}`).join('\n')}`;
116
+ return {
117
+ answer,
118
+ citations,
119
+ warning: 'Client does not support MCP sampling; returning heuristic key-point summary instead of synthesized answer',
120
+ };
121
+ }
122
+ function extractKeypoint(body, maxChars) {
123
+ const trimmed = body.trim();
124
+ if (!trimmed)
125
+ return '';
126
+ // First paragraph before a blank line
127
+ const firstPara = trimmed.split(/\n\s*\n/)[0].trim();
128
+ if (!firstPara)
129
+ return '';
130
+ // Strip markdown headings at the start
131
+ const stripped = firstPara.replace(/^#+\s*/, '').trim();
132
+ if (!stripped)
133
+ return '';
134
+ if (stripped.length <= maxChars)
135
+ return stripped;
136
+ // Try to cut at sentence end within budget
137
+ const window = stripped.slice(0, maxChars);
138
+ const lastStop = Math.max(window.lastIndexOf('. '), window.lastIndexOf('! '), window.lastIndexOf('? '));
139
+ if (lastStop > maxChars * 0.6) {
140
+ return window.slice(0, lastStop + 1);
141
+ }
142
+ return window + '…';
143
+ }
90
144
  export function extractCitations(answer, results) {
91
145
  try {
92
146
  if (!answer || results.length === 0)
@@ -1 +1 @@
1
- {"version":3,"file":"answer-synthesis.js","sourceRoot":"","sources":["../../src/search/answer-synthesis.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,+BAA+B,GAChC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAA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[];
8
+ published_date?: string;
8
9
  }
9
10
  export declare function deduplicateResults(results: RawSearchResult[]): MergedSearchResult[];
10
11
  //# sourceMappingURL=dedup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dedup.d.ts","sourceRoot":"","sources":["../../src/search/dedup.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,kBAAkB,EAAE,CAkCnF"}
1
+ {"version":3,"file":"dedup.d.ts","sourceRoot":"","sources":["../../src/search/dedup.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,kBAAkB,EAAE,CAsCnF"}
@@ -16,6 +16,9 @@ export function deduplicateResults(results) {
16
16
  existing.title = result.title;
17
17
  existing.snippet = result.snippet;
18
18
  }
19
+ if (result.published_date && !existing.published_date) {
20
+ existing.published_date = result.published_date;
21
+ }
19
22
  if (!existing.engines.includes(result.engine)) {
20
23
  existing.engines.push(result.engine);
21
24
  }
@@ -27,6 +30,7 @@ export function deduplicateResults(results) {
27
30
  snippet: result.snippet,
28
31
  relevance_score: result.relevance_score,
29
32
  engines: [result.engine],
33
+ ...(result.published_date ? { published_date: result.published_date } : {}),
30
34
  });
31
35
  }
32
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dedup.js","sourceRoot":"","sources":["../../src/search/dedup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAWjD,MAAM,UAAU,kBAAkB,CAAC,OAA0B;IAC3D,MAAM,MAAM,GAAG,IAAI,GAAG,EAA8B,CAAC;IAErD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,UAAkB,CAAC;QACvB,IAAI,CAAC;YACH,UAAU,GAAG,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACxC,CAAC;QAAC,MAAM,CAAC;YACP,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC;QAC1B,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAExC,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,MAAM,CAAC,eAAe,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC;gBACtD,QAAQ,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;gBAClD,QAAQ,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;gBAC9B,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;YACpC,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC9C,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE;gBACrB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,OAAO,EAAE,MAAM,C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Ac,CAAC;YAClD,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC9C,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE;gBACrB,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,eAAe,EAAE,MAAM,CAAC,eAAe;gBACvC,OAAO,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;gBACxB,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC5E,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,GAAG,CAAC,CAAC,eAAe,CAAC,CAAC;AACpF,CAAC"}
@@ -1,3 +1,4 @@
1
1
  import type { MergedSearchResult } from './dedup.js';
2
2
  export declare function rerankResults(query: string, results: MergedSearchResult[]): Promise<MergedSearchResult[]>;
3
+ export declare function applyRecencyBoost(results: MergedSearchResult[]): MergedSearchResult[];
3
4
  //# sourceMappingURL=rerank.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rerank.d.ts","sourceRoot":"","sources":["../../src/search/rerank.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAOrD,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,kBAAkB,EAAE,GAC5B,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAgC/B"}
1
+ {"version":3,"file":"rerank.d.ts","sourceRoot":"","sources":["../../src/search/rerank.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAOrD,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,kBAAkB,EAAE,GAC5B,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAoC/B;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,kBAAkB,EAAE,CAkBrF"}
@@ -18,7 +18,9 @@ export async function rerankResults(query, results) {
18
18
  ...results[r.index],
19
19
  relevance_score: r.score,
20
20
  }));
21
- return applyThreshold(reordered, config.relevanceThreshold);
21
+ const boosted = applyRecencyBoost(reordered);
22
+ boosted.sort((a, b) => b.relevance_score - a.relevance_score);
23
+ return applyThreshold(boosted, config.relevanceThreshold);
22
24
  }
23
25
  log.debug('FlashRank returned null, using passthrough');
24
26
  }
@@ -30,7 +32,30 @@ export async function rerankResults(query, results) {
30
32
  log.warn('Unknown reranker configured, passing through', { reranker: config.reranker });
31
33
  }
32
34
  log.debug('Rerank passthrough', { count: results.length });
33
- return applyThreshold(results, config.relevanceThreshold);
35
+ const boosted = applyRecencyBoost(results);
36
+ boosted.sort((a, b) => b.relevance_score - a.relevance_score);
37
+ return applyThreshold(boosted, config.relevanceThreshold);
38
+ }
39
+ export function applyRecencyBoost(results) {
40
+ const now = Date.now();
41
+ return results.map(r => {
42
+ if (!r.published_date)
43
+ return r;
44
+ const ts = new Date(r.published_date).getTime();
45
+ if (isNaN(ts))
46
+ return r;
47
+ const ageDays = (now - ts) / (1000 * 60 * 60 * 24);
48
+ let boost = 1.0;
49
+ if (ageDays < 7)
50
+ boost = 1.2;
51
+ else if (ageDays < 30)
52
+ boost = 1.1;
53
+ else if (ageDays < 90)
54
+ boost = 1.05;
55
+ if (boost === 1.0)
56
+ return r;
57
+ return { ...r, relevance_score: r.relevance_score * boost };
58
+ });
34
59
  }
35
60
  function applyThreshold(results, threshold) {
36
61
  if (!threshold || threshold <= 0)
@@ -1 +1 @@
1
- {"version":3,"file":"rerank.js","sourceRoot":"","sources":["../../src/search/rerank.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,GAAG,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;AAEnC,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,KAAa,EACb,OAA6B;IAE7B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAE3B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IAEzC,IAAI,MAAM,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;QACpC,IAAI,MAAM,oBAAoB,EAAE,EAAE,CAAC;YACjC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;gBACtC,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,OAAO,EAAE;gBAChC,KAAK,EAAE,CAAC;aACT,CAAC,CAAC,CAAC;YAEJ,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;YAC5E,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBACnC,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;oBACnB,eAAe,EAAE,CAAC,CAAC,KAAK;iBACzB,CAAC,CAAC,CAAC;gBAEJ,OAA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,KAAK,EAAE,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CACrB,OAA6B,EAC7B,SAAiB;IAEjB,IAAI,CAAC,SAAS,IAAI,SAAS,IAAI,CAAC;QAAE,OAAO,OAAO,CAAC;IACjD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,IAAI,SAAS,CAAC,CAAC;AAC/D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"searxng.d.ts","sourceRoot":"","sources":["../../src/search/searxng.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA2CtF,qBAAa,aAAc,YAAW,YAAY;IAGpC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,IAAI,SAAa;gBAEY,OAAO,EAAE,MAAM;IAEtC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CAyD3F"}
1
+ {"version":3,"file":"searxng.d.ts","sourceRoot":"","sources":["../../src/search/searxng.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAkDtF,qBAAa,aAAc,YAAW,YAAY;IAGpC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,IAAI,SAAa;gBAEY,OAAO,EAAE,MAAM;IAEtC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CA6D3F"}