@triplef/agent 1.0.6 → 1.0.7

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.
@@ -1242,17 +1242,18 @@ var STANDALONE_QUERY_RULES = `STANDALONE QUERY RULES (absolute \u2014 they apply
1242
1242
  var PRODUCT_QUERY_GUIDANCE = `QUERY CRAFTING (product task) \u2014 phrase each tool query for its endpoint; never reuse one query for all tools:
1243
1243
  - Language: phrase descriptive query words (review/test/unboxing/specs) in the detected user language; keep product names, brand names, and model numbers verbatim.
1244
1244
  - *ShoppingSearch: the bare product name with exact model number (e.g. "Sony WH-1000XM5"). No extra words like "buy", "price", or "review".
1245
- - *WebSearch: factual queries such as "<product> specifications" and "<product> review" for editorial reviews and facts.
1245
+ - *WebSearch: factual queries such as "<product> specifications" and "<product> review" for editorial reviews and facts. Each call returns only the top 3 results \u2014 one call per distinct aspect, never merge different aspects into one query.
1246
1246
  - *ImageSearch: "<product>" optionally with "official" for clean product shots.
1247
1247
  - *VideoSearch: "<product> review", "<product> hands-on", or "<product> unboxing".
1248
- - *WebpageScrape / webFetch: fetch the most authoritative review or spec page discovered by the *WebSearch results when snippets are insufficient.`;
1248
+ - *WebpageScrape / webFetch: fetch the most authoritative review or spec page discovered by the *WebSearch results when snippets are insufficient. The top 3 search results are already fetched automatically \u2014 only fetch pages beyond those.`;
1249
1249
  var GENERAL_QUERY_GUIDANCE = `QUERY CRAFTING \u2014 phrase each tool query for its endpoint; never reuse one query for all tools:
1250
1250
  - Language: phrase descriptive query words in the detected user language; keep entity names (products, brands, people, places) verbatim.
1251
- - *WebSearch: precise factual queries with the key entities and qualifiers (version, model, location). Only add a year/recency qualifier when the FRESHNESS rules call for it \u2014 not for evergreen topics.
1251
+ - *WebSearch: precise factual queries with the key entities and qualifiers (version, model, location). Only add a year/recency qualifier when the FRESHNESS rules call for it \u2014 not for evergreen topics. Each call returns only the top 3 results, so a request spanning distinct topics or entities MUST issue one call per topic \u2014 never merge unrelated subjects into one query, or coverage is lost.
1252
1252
  - *ReviewsSearch: reviews BUSINESSES only \u2014 call it with an exact business or place name, never with a product or topic.
1253
1253
  - *PlacesSearch: phrase it like a Google Maps search \u2014 a business name or "<business type> in <location>".
1254
1254
  - *ImageSearch: short visual descriptions of the subject.
1255
- - *VideoSearch: subject plus the video type (e.g. "review", "trailer", "tutorial"); vary queries between fresh and evergreen angles as the FRESHNESS rules describe.`;
1255
+ - *VideoSearch: subject plus the video type (e.g. "review", "trailer", "tutorial"); vary queries between fresh and evergreen angles as the FRESHNESS rules describe.
1256
+ - *WebpageScrape / webFetch: the top 3 search results are already fetched automatically \u2014 call a fetch tool only for a specific page beyond those, when snippets are insufficient.`;
1256
1257
  function buildToolExecutePrompt(intent) {
1257
1258
  const tools = intent?.tools ?? [];
1258
1259
  const toolList = tools.length > 0 ? `MANDATORY tools you MUST call: ${tools.join(", ")}.` : "No tools are selected.";
@@ -1283,7 +1284,7 @@ Derive the search query or target URL for each tool from the latest user message
1283
1284
  ${STANDALONE_QUERY_RULES}
1284
1285
  ${queryGuidance}
1285
1286
  Emit ALL mandatory tool calls in ONE response, as parallel tool calls. Do not stop after the first tool call.
1286
- You may call the same tool more than once with differently phrased queries when the task needs broader coverage.
1287
+ You may call the same tool more than once with differently phrased queries when the task needs broader coverage. Because each *WebSearch/*NewsSearch call returns only the top 3 results, every distinct topic or entity gets its own call \u2014 folding two subjects into one query loses the second subject's results.
1287
1288
  When you call the SAME search tool multiple times and an explicit imageCount/videoCount is set, split that total evenly across the calls so their sum equals the target \u2014 never pass the full count to each call. Example: total 10 across 3 queries \u2192 pass count 4, 3, 3. When no explicit count is set, make every call WITHOUT a count parameter and let each tool use its default.
1288
1289
  Each mandatory tool must be called at least once. Missing a mandatory tool is a failure.
1289
1290
  ${countInstruction}
@@ -1297,16 +1298,16 @@ FINAL REMINDER:
1297
1298
  // src/schemas/helpers/tools/tool-registry.constant.ts
1298
1299
  var VARIANT_NAMES = ["grayscale", "denoised", "sharpened", "clahe"];
1299
1300
  var TOOL_DESCRIPTIONS = {
1300
- brightDataWebSearch: "Search the web using Bright Data SERP API (Google). Returns organic results with titles, snippets, and links. Supports an optional recency window (day/week/month/year) for fresh results.",
1301
+ brightDataWebSearch: "Search the web using Bright Data SERP API (Google). Returns at most the top 3 organic results per call (titles, snippets, links) \u2014 a request spanning distinct topics needs one call per topic. Supports an optional recency window (day/week/month/year) for fresh results.",
1301
1302
  brightDataImageSearch: "Search for images using Bright Data SERP API (Google Images). Returns image URLs, source pages, and dimensions. Enforces a minimum of 1280\xD7720 (720p).",
1302
- brightDataNewsSearch: "Search latest news using Bright Data SERP API. Returns headlines, sources, dates, and snippets. Supports an optional recency window (day/week/month/year).",
1303
+ brightDataNewsSearch: "Search latest news using Bright Data SERP API \u2014 at most the top 3 results per call (headlines, sources, dates, snippets), so a request spanning distinct topics needs one call per topic. Supports an optional recency window (day/week/month/year).",
1303
1304
  brightDataPlacesSearch: "Search places and businesses using Bright Data SERP API (Google Maps). Returns addresses, phone numbers, ratings, review counts, and coordinates. Query with a business name or business type plus location.",
1304
1305
  brightDataShoppingSearch: "Search for products using Bright Data SERP API (Google Shopping). Returns prices, sellers, images, and ratings. Query with the bare product name and model number.",
1305
1306
  brightDataVideoSearch: `Search for videos using Bright Data SERP API. Returns titles, links, channel names, duration, and publish dates. Supports an optional recency window (day/week/month/year) for fresh results. ${EMBEDDABLE_VIDEO_PROVIDER_CLAUSE}`,
1306
1307
  brightDataWebpageScrape: "Fetch and render a full webpage using Bright Data Web Unlocker API. Returns clean Markdown text. Use for pages behind anti-bot protection that plain fetch cannot reach.",
1307
- serperWebSearch: "Search the web using Serper.dev (Google). Returns organic results with titles, snippets, and links. Supports an optional recency window (day/week/month/year) for fresh results.",
1308
+ serperWebSearch: "Search the web using Serper.dev (Google). Returns at most the top 3 organic results per call (titles, snippets, links) \u2014 a request spanning distinct topics needs one call per topic. Supports an optional recency window (day/week/month/year) for fresh results.",
1308
1309
  serperImageSearch: "Search for images using Serper.dev (Google Images). Prefers 2560\xD71440 (1440p) images and enforces a minimum of 1280\xD7720 (720p) via the Google Images tbs size filter and a client-side dimension filter. Supports an optional recency window (day/week/month/year).",
1309
- serperNewsSearch: "Search latest news using Serper.dev. Returns headlines, sources, dates, and snippets. Supports an optional recency window (day/week/month/year).",
1310
+ serperNewsSearch: "Search latest news using Serper.dev \u2014 at most the top 3 results per call (headlines, sources, dates, snippets), so a request spanning distinct topics needs one call per topic. Supports an optional recency window (day/week/month/year).",
1310
1311
  serperPlacesSearch: "Search places and businesses using Serper.dev (Google Maps). Returns addresses, phone numbers, ratings, review counts, and coordinates. Query with a business name or business type plus location.",
1311
1312
  serperShoppingSearch: "Search for products using Serper.dev (Google Shopping). Returns prices, sellers, delivery info, images, and per-offer ratings. Query with the bare product name and model number.",
1312
1313
  serperBusinessReviewsSearch: "Fetch Google Maps reviews for a specific business or place using Serper.dev. Returns reviewer snippets with author names, star ratings, and dates. Use for seller/business reputation, not editorial product reviews.",
@@ -1320,7 +1321,7 @@ var TOOL_DESCRIPTIONS = {
1320
1321
  eodhdIntraday: "Fetch intraday OHLCV bars for an EODHD ticker and return a per-day, per-price-band volume profile as chartData for the client heatmap. Use to render a volume heatmap across fixed price bands.",
1321
1322
  eodhdNews: "Fetch recent financial news for an EODHD ticker \u2014 headlines, links, sources, publish dates. Use to ground a stock-market answer in what is happening around a company.",
1322
1323
  eodhdFundamentals: "Fetch company fundamentals for an EODHD ticker \u2014 general info, valuation, and key financial highlights (sector, market cap, P/E, revenue, margins).",
1323
- webFetch: "Fetch the full content of a specific URL (e.g. a search result page) as clean Markdown. Prefer fetching the most relevant search results to ground the answer in full source text rather than relying on snippets alone.",
1324
+ webFetch: "Fetch the full content of a specific URL (e.g. a search result page) as clean Markdown. The top 3 web/news search results are fetched automatically when no fetch tool is selected \u2014 use this only for a specific page beyond those, when full source text is needed beyond the snippets.",
1324
1325
  browser_navigate: "Control a real browser: navigate to a URL. Use for interactive browsing \u2014 JS-heavy pages, content behind clicks, tabs, scrolling, or forms \u2014 that static search/fetch cannot reach. Follow up with browser_snapshot to read the page before acting on it.",
1325
1326
  browser_navigate_back: "Go back to the previous page in the browser history.",
1326
1327
  browser_snapshot: "Read the current browser page as an accessibility snapshot (structured text with element refs). The primary way to see page content and obtain the refs that browser_click/browser_type need.",
@@ -2609,9 +2610,9 @@ var WHEN_TO_USE_TOOLS_RULES = `WHEN TO USE TOOLS
2609
2610
  - user asks about a specific product to buy, prices, or best deals \u2192 product template with a *WebSearch tool, shopping search, and reviews search
2610
2611
  - user asks about specific factual entities, specifications, data, statistics \u2192 the enabled *WebSearch tool`;
2611
2612
  var FETCH_AFTER_SEARCH_RULES = `FETCH-AFTER-SEARCH RULES
2612
- - When you include a *WebSearch tool for factual research (article, news, evaluation, product, or text), also include a fetch tool \u2014 webFetch, serperWebpageScrape, or brightDataWebpageScrape \u2014 to fetch the most relevant result pages (typically 1-3; more when the topic is broad and several pages each add distinct depth).
2613
- - The fetched full content grounds the answer in source text (not just snippets) and populates the knowledge cache for future turns.
2614
- - You decide which pages are worth fetching: fetch only pages whose full content would meaningfully improve the answer. Skip fetching for trivial lookups, quick facts, or when the snippets already answer the request completely.
2613
+ - The top 3 results of every *WebSearch/*NewsSearch call are fetched automatically when no fetch tool is selected. Do NOT include a fetch tool merely to ground the answer \u2014 that grounding always happens on its own.
2614
+ - Include a fetch tool \u2014 webFetch, serperWebpageScrape, or brightDataWebpageScrape \u2014 only when the answer needs full text from a specific page beyond the auto-fetched top 3 (e.g. a spec sheet or review the user asked about).
2615
+ - Fetch sparingly: the 1-2 most authoritative pages whose full content meaningfully improves the answer. Skip fetching for trivial lookups, quick facts, or when the snippets already answer the request completely.
2615
2616
  - Prefer primary/readable sources \u2014 official sites, documentation, Wikipedia, news articles \u2014 over app stores, forums, and discussion threads, unless the question is specifically about those.
2616
2617
  - Prefer webFetch for plain pages; use a scrape tool for pages behind anti-bot protection.`;
2617
2618
  var MEDIA_TYPE_TOOL_RULES = `MEDIA-TYPE TOOL SELECTION
@@ -129,16 +129,16 @@ function categorizeTools(toolNames) {
129
129
  // src/schemas/helpers/tools/tool-registry.constant.ts
130
130
  var VARIANT_NAMES = ["grayscale", "denoised", "sharpened", "clahe"];
131
131
  var TOOL_DESCRIPTIONS = {
132
- brightDataWebSearch: "Search the web using Bright Data SERP API (Google). Returns organic results with titles, snippets, and links. Supports an optional recency window (day/week/month/year) for fresh results.",
132
+ brightDataWebSearch: "Search the web using Bright Data SERP API (Google). Returns at most the top 3 organic results per call (titles, snippets, links) \u2014 a request spanning distinct topics needs one call per topic. Supports an optional recency window (day/week/month/year) for fresh results.",
133
133
  brightDataImageSearch: "Search for images using Bright Data SERP API (Google Images). Returns image URLs, source pages, and dimensions. Enforces a minimum of 1280\xD7720 (720p).",
134
- brightDataNewsSearch: "Search latest news using Bright Data SERP API. Returns headlines, sources, dates, and snippets. Supports an optional recency window (day/week/month/year).",
134
+ brightDataNewsSearch: "Search latest news using Bright Data SERP API \u2014 at most the top 3 results per call (headlines, sources, dates, snippets), so a request spanning distinct topics needs one call per topic. Supports an optional recency window (day/week/month/year).",
135
135
  brightDataPlacesSearch: "Search places and businesses using Bright Data SERP API (Google Maps). Returns addresses, phone numbers, ratings, review counts, and coordinates. Query with a business name or business type plus location.",
136
136
  brightDataShoppingSearch: "Search for products using Bright Data SERP API (Google Shopping). Returns prices, sellers, images, and ratings. Query with the bare product name and model number.",
137
137
  brightDataVideoSearch: `Search for videos using Bright Data SERP API. Returns titles, links, channel names, duration, and publish dates. Supports an optional recency window (day/week/month/year) for fresh results. ${EMBEDDABLE_VIDEO_PROVIDER_CLAUSE}`,
138
138
  brightDataWebpageScrape: "Fetch and render a full webpage using Bright Data Web Unlocker API. Returns clean Markdown text. Use for pages behind anti-bot protection that plain fetch cannot reach.",
139
- serperWebSearch: "Search the web using Serper.dev (Google). Returns organic results with titles, snippets, and links. Supports an optional recency window (day/week/month/year) for fresh results.",
139
+ serperWebSearch: "Search the web using Serper.dev (Google). Returns at most the top 3 organic results per call (titles, snippets, links) \u2014 a request spanning distinct topics needs one call per topic. Supports an optional recency window (day/week/month/year) for fresh results.",
140
140
  serperImageSearch: "Search for images using Serper.dev (Google Images). Prefers 2560\xD71440 (1440p) images and enforces a minimum of 1280\xD7720 (720p) via the Google Images tbs size filter and a client-side dimension filter. Supports an optional recency window (day/week/month/year).",
141
- serperNewsSearch: "Search latest news using Serper.dev. Returns headlines, sources, dates, and snippets. Supports an optional recency window (day/week/month/year).",
141
+ serperNewsSearch: "Search latest news using Serper.dev \u2014 at most the top 3 results per call (headlines, sources, dates, snippets), so a request spanning distinct topics needs one call per topic. Supports an optional recency window (day/week/month/year).",
142
142
  serperPlacesSearch: "Search places and businesses using Serper.dev (Google Maps). Returns addresses, phone numbers, ratings, review counts, and coordinates. Query with a business name or business type plus location.",
143
143
  serperShoppingSearch: "Search for products using Serper.dev (Google Shopping). Returns prices, sellers, delivery info, images, and per-offer ratings. Query with the bare product name and model number.",
144
144
  serperBusinessReviewsSearch: "Fetch Google Maps reviews for a specific business or place using Serper.dev. Returns reviewer snippets with author names, star ratings, and dates. Use for seller/business reputation, not editorial product reviews.",
@@ -152,7 +152,7 @@ var TOOL_DESCRIPTIONS = {
152
152
  eodhdIntraday: "Fetch intraday OHLCV bars for an EODHD ticker and return a per-day, per-price-band volume profile as chartData for the client heatmap. Use to render a volume heatmap across fixed price bands.",
153
153
  eodhdNews: "Fetch recent financial news for an EODHD ticker \u2014 headlines, links, sources, publish dates. Use to ground a stock-market answer in what is happening around a company.",
154
154
  eodhdFundamentals: "Fetch company fundamentals for an EODHD ticker \u2014 general info, valuation, and key financial highlights (sector, market cap, P/E, revenue, margins).",
155
- webFetch: "Fetch the full content of a specific URL (e.g. a search result page) as clean Markdown. Prefer fetching the most relevant search results to ground the answer in full source text rather than relying on snippets alone.",
155
+ webFetch: "Fetch the full content of a specific URL (e.g. a search result page) as clean Markdown. The top 3 web/news search results are fetched automatically when no fetch tool is selected \u2014 use this only for a specific page beyond those, when full source text is needed beyond the snippets.",
156
156
  browser_navigate: "Control a real browser: navigate to a URL. Use for interactive browsing \u2014 JS-heavy pages, content behind clicks, tabs, scrolling, or forms \u2014 that static search/fetch cannot reach. Follow up with browser_snapshot to read the page before acting on it.",
157
157
  browser_navigate_back: "Go back to the previous page in the browser history.",
158
158
  browser_snapshot: "Read the current browser page as an accessibility snapshot (structured text with element refs). The primary way to see page content and obtain the refs that browser_click/browser_type need.",
@@ -342,6 +342,9 @@ var brightDataNewsSearchSchema = z.object({
342
342
  lang: z.string().optional().describe("Two-letter ISO language code for result preference (e.g. en, de, ja)")
343
343
  });
344
344
 
345
+ // src/tools/constants/search-results-cap.constant.ts
346
+ var SEARCH_API_RESULTS_CAP = 3;
347
+
345
348
  // src/tools/bright-data/helpers/map-bright-data-news-result.helper.ts
346
349
  function mapBrightDataNewsResult(r) {
347
350
  return {
@@ -357,7 +360,7 @@ function mapBrightDataNewsResult(r) {
357
360
  // src/tools/bright-data/news-search.tool.ts
358
361
  function createBrightDataNewsSearch(deps) {
359
362
  return tool({
360
- description: 'Search the latest news using Bright Data SERP API. Returns headlines, sources, dates, and snippets. Pass recency ("day"|"week"|"month"|"year") to restrict to a recent period. ' + STANDALONE_QUERY_TOOL_CLAUSE,
363
+ description: 'Search the latest news using Bright Data SERP API. Returns headlines, sources, dates, and snippets \u2014 at most the top 3 per call, so cover each distinct topic with its own call. Pass recency ("day"|"week"|"month"|"year") to restrict to a recent period. ' + STANDALONE_QUERY_TOOL_CLAUSE,
361
364
  inputSchema: brightDataNewsSearchSchema,
362
365
  execute: async ({ query, count: reqCount, recency, lang }) => {
363
366
  const cfg = deps.getLiveConfig().brightData;
@@ -367,12 +370,18 @@ function createBrightDataNewsSearch(deps) {
367
370
  const body = {};
368
371
  applyLocaleParams(body, lang ?? deps.defaultLang);
369
372
  applyRecencyParam(body, recency);
373
+ const num = Math.min(reqCount ?? cfg.news.results, SEARCH_API_RESULTS_CAP);
374
+ if (num < (reqCount ?? cfg.news.results)) {
375
+ deps.logger.warn(
376
+ `Bright Data news results clamped to ${SEARCH_API_RESULTS_CAP} (top-3 rank cutoff) for "${query}"`
377
+ );
378
+ }
370
379
  const url = buildGoogleUrl(query, {
371
380
  tbm: "nws",
372
381
  hl: body.hl,
373
382
  gl: body.gl,
374
383
  tbs: body.tbs,
375
- num: reqCount ?? cfg.news.results
384
+ num
376
385
  });
377
386
  try {
378
387
  const data = await requestBrightData(apiKey, cfg.serpZone, url, {
@@ -429,11 +438,17 @@ function createBrightDataPlacesSearch(deps) {
429
438
  deps.logger.log(`Bright Data places search for "${query}"`);
430
439
  const body = {};
431
440
  applyLocaleParams(body, lang ?? deps.defaultLang);
441
+ const num = Math.min(reqCount ?? cfg.places.results, SEARCH_API_RESULTS_CAP);
442
+ if (num < (reqCount ?? cfg.places.results)) {
443
+ deps.logger.warn(
444
+ `Bright Data places results clamped to ${SEARCH_API_RESULTS_CAP} (top-3 rank cutoff) for "${query}"`
445
+ );
446
+ }
432
447
  const url = buildGoogleUrl(query, {
433
448
  tbm: "lcl",
434
449
  hl: body.hl,
435
450
  gl: body.gl,
436
- num: reqCount ?? cfg.places.results
451
+ num
437
452
  });
438
453
  try {
439
454
  const data = await requestBrightData(apiKey, cfg.serpZone, url, {
@@ -489,11 +504,17 @@ function createBrightDataShoppingSearch(deps) {
489
504
  deps.logger.log(`Bright Data shopping search for "${query}"`);
490
505
  const body = {};
491
506
  applyLocaleParams(body, lang ?? deps.defaultLang);
507
+ const num = Math.min(reqCount ?? cfg.shopping.results, SEARCH_API_RESULTS_CAP);
508
+ if (num < (reqCount ?? cfg.shopping.results)) {
509
+ deps.logger.warn(
510
+ `Bright Data shopping results clamped to ${SEARCH_API_RESULTS_CAP} (top-3 rank cutoff) for "${query}"`
511
+ );
512
+ }
492
513
  const url = buildGoogleUrl(query, {
493
514
  udm: 28,
494
515
  hl: body.hl,
495
516
  gl: body.gl,
496
- num: reqCount ?? cfg.shopping.results
517
+ num
497
518
  });
498
519
  try {
499
520
  const data = await requestBrightData(apiKey, cfg.serpZone, url, {
@@ -647,7 +668,7 @@ function mapBrightDataWebResult(r) {
647
668
  // src/tools/bright-data/web-search.tool.ts
648
669
  function createBrightDataWebSearch(deps) {
649
670
  return tool({
650
- description: 'Search the web using Bright Data SERP API (Google). Returns organic results with titles, snippets, and links. Pass recency ("day"|"week"|"month"|"year") to restrict to fresh results. ' + STANDALONE_QUERY_TOOL_CLAUSE,
671
+ description: 'Search the web using Bright Data SERP API (Google). Returns organic results with titles, snippets, and links \u2014 at most the top 3 per call, so cover each distinct topic or entity with its own call. Pass recency ("day"|"week"|"month"|"year") to restrict to fresh results. ' + STANDALONE_QUERY_TOOL_CLAUSE,
651
672
  inputSchema: brightDataWebSearchSchema,
652
673
  execute: async ({ query, recency, lang }) => {
653
674
  const cfg = deps.getLiveConfig().brightData;
@@ -657,11 +678,17 @@ function createBrightDataWebSearch(deps) {
657
678
  const body = {};
658
679
  applyLocaleParams(body, lang ?? deps.defaultLang);
659
680
  applyRecencyParam(body, recency);
681
+ const num = Math.min(cfg.web.results, SEARCH_API_RESULTS_CAP);
682
+ if (num < cfg.web.results) {
683
+ deps.logger.warn(
684
+ `Bright Data web results clamped from ${cfg.web.results} to ${SEARCH_API_RESULTS_CAP} (top-3 rank cutoff)`
685
+ );
686
+ }
660
687
  const url = buildGoogleUrl(query, {
661
688
  hl: body.hl,
662
689
  gl: body.gl,
663
690
  tbs: body.tbs,
664
- num: cfg.web.results
691
+ num
665
692
  });
666
693
  try {
667
694
  const data = await requestBrightData(apiKey, cfg.serpZone, url, {
@@ -1410,6 +1437,16 @@ var serperNewsSearchSchema = z.object({
1410
1437
  lang: z.string().optional().describe("Two-letter ISO language code for result preference (e.g. en, de, ja)")
1411
1438
  });
1412
1439
 
1440
+ // src/tools/helpers/is-google-goto-link.helper.ts
1441
+ function isGoogleGotoLink(url) {
1442
+ try {
1443
+ const parsed = new URL(url);
1444
+ return /(^|\.)google\.[a-z.]+$/.test(parsed.hostname.toLowerCase()) && parsed.pathname === "/goto";
1445
+ } catch {
1446
+ return false;
1447
+ }
1448
+ }
1449
+
1413
1450
  // src/tools/serper/helpers/map-serper-news-result.helper.ts
1414
1451
  function mapSerperNewsResult(r) {
1415
1452
  return {
@@ -1425,7 +1462,7 @@ function mapSerperNewsResult(r) {
1425
1462
  // src/tools/serper/news-search.tool.ts
1426
1463
  function createSerperNewsSearch(deps) {
1427
1464
  return tool({
1428
- description: 'Search the latest news using Serper.dev. Returns headlines, sources, dates, and snippets. Pass recency ("day"|"week"|"month"|"year") to restrict to a recent period. ' + STANDALONE_QUERY_TOOL_CLAUSE,
1465
+ description: 'Search the latest news using Serper.dev. Returns headlines, sources, dates, and snippets \u2014 at most the top 3 per call, so cover each distinct topic with its own call. Pass recency ("day"|"week"|"month"|"year") to restrict to a recent period. ' + STANDALONE_QUERY_TOOL_CLAUSE,
1429
1466
  inputSchema: serperNewsSearchSchema,
1430
1467
  execute: async ({ query, count: reqCount, recency, lang }) => {
1431
1468
  const cfg = deps.getLiveConfig().serper;
@@ -1433,7 +1470,12 @@ function createSerperNewsSearch(deps) {
1433
1470
  return { results: [], error: "Serper.dev news is not enabled" };
1434
1471
  }
1435
1472
  deps.logger.log(`Serper.dev News search for "${query}"`);
1436
- const num = Math.min(reqCount ?? cfg.news.results, cfg.news.results);
1473
+ const num = Math.min(reqCount ?? cfg.news.results, cfg.news.results, SEARCH_API_RESULTS_CAP);
1474
+ if (num < (reqCount ?? cfg.news.results)) {
1475
+ deps.logger.warn(
1476
+ `Serper.dev news results clamped to ${SEARCH_API_RESULTS_CAP} (top-3 rank cutoff) for "${query}"`
1477
+ );
1478
+ }
1437
1479
  const newsBody = {
1438
1480
  q: query,
1439
1481
  num
@@ -1452,7 +1494,13 @@ function createSerperNewsSearch(deps) {
1452
1494
  if (!res.ok) return { results: [] };
1453
1495
  const data = await res.json();
1454
1496
  if (!data.news?.length) return { results: [] };
1455
- const results = data.news.map(mapSerperNewsResult);
1497
+ const mapped = data.news.map(mapSerperNewsResult);
1498
+ const results = mapped.filter((r) => !isGoogleGotoLink(r.url));
1499
+ if (results.length < mapped.length) {
1500
+ deps.logger.warn(
1501
+ `Serper.dev dropped ${mapped.length - results.length} unresolved google.com/goto link(s) for "${query}"`
1502
+ );
1503
+ }
1456
1504
  return { results };
1457
1505
  }
1458
1506
  });
@@ -1492,7 +1540,12 @@ function createSerperPlacesSearch(deps) {
1492
1540
  return { results: [], error: "Serper.dev places is not enabled" };
1493
1541
  }
1494
1542
  deps.logger.log(`Serper.dev Places search for "${query}"`);
1495
- const num = Math.min(reqCount ?? cfg.places.results, cfg.places.results);
1543
+ const num = Math.min(reqCount ?? cfg.places.results, cfg.places.results, SEARCH_API_RESULTS_CAP);
1544
+ if (num < (reqCount ?? cfg.places.results)) {
1545
+ deps.logger.warn(
1546
+ `Serper.dev places results clamped to ${SEARCH_API_RESULTS_CAP} (top-3 rank cutoff) for "${query}"`
1547
+ );
1548
+ }
1496
1549
  const body = { q: query, num };
1497
1550
  applyLocaleParams(body, lang ?? deps.defaultLang);
1498
1551
  const res = await fetchWithTimeout(
@@ -1553,7 +1606,12 @@ function createSerperShoppingSearch(deps) {
1553
1606
  };
1554
1607
  }
1555
1608
  deps.logger.log(`Serper.dev Shopping search for "${query}"`);
1556
- const num = Math.min(reqCount ?? cfg.shopping.results, cfg.shopping.results);
1609
+ const num = Math.min(reqCount ?? cfg.shopping.results, cfg.shopping.results, SEARCH_API_RESULTS_CAP);
1610
+ if (num < (reqCount ?? cfg.shopping.results)) {
1611
+ deps.logger.warn(
1612
+ `Serper.dev shopping results clamped to ${SEARCH_API_RESULTS_CAP} (top-3 rank cutoff) for "${query}"`
1613
+ );
1614
+ }
1557
1615
  const body = { q: query, num };
1558
1616
  const effectiveLang = lang ?? deps.defaultLang;
1559
1617
  applyLocaleParams(body, effectiveLang);
@@ -1689,7 +1747,7 @@ function mapSerperWebResult(r) {
1689
1747
  // src/tools/serper/web-search.tool.ts
1690
1748
  function createSerperWebSearch(deps) {
1691
1749
  return tool({
1692
- description: 'Search the web using Serper.dev (Google results). Returns organic results with titles, snippets, and links. Pass recency ("day"|"week"|"month"|"year") to restrict to fresh results. ' + STANDALONE_QUERY_TOOL_CLAUSE,
1750
+ description: 'Search the web using Serper.dev (Google results). Returns organic results with titles, snippets, and links \u2014 at most the top 3 per call, so cover each distinct topic or entity with its own call. Pass recency ("day"|"week"|"month"|"year") to restrict to fresh results. ' + STANDALONE_QUERY_TOOL_CLAUSE,
1693
1751
  inputSchema: serperWebSearchSchema,
1694
1752
  execute: async ({ query, recency, lang }) => {
1695
1753
  const cfg = deps.getLiveConfig().serper;
@@ -1697,9 +1755,15 @@ function createSerperWebSearch(deps) {
1697
1755
  return { results: [], error: "Serper.dev web search is not enabled" };
1698
1756
  }
1699
1757
  deps.logger.log(`Serper.dev search for "${query}"`);
1758
+ const num = Math.min(cfg.web.results, SEARCH_API_RESULTS_CAP);
1759
+ if (num < cfg.web.results) {
1760
+ deps.logger.warn(
1761
+ `Serper.dev web results clamped from ${cfg.web.results} to ${SEARCH_API_RESULTS_CAP} (top-3 rank cutoff)`
1762
+ );
1763
+ }
1700
1764
  const body = {
1701
1765
  q: query,
1702
- num: cfg.web.results
1766
+ num
1703
1767
  };
1704
1768
  applyLocaleParams(body, lang ?? deps.defaultLang);
1705
1769
  applyRecencyParam(body, recency);
@@ -1721,7 +1785,13 @@ function createSerperWebSearch(deps) {
1721
1785
  deps.logger.warn(`Serper.dev returned 0 results for "${query}"`);
1722
1786
  return { results: [] };
1723
1787
  }
1724
- const results = data.organic.map(mapSerperWebResult);
1788
+ const mapped = data.organic.map(mapSerperWebResult);
1789
+ const results = mapped.filter((r) => !isGoogleGotoLink(r.url));
1790
+ if (results.length < mapped.length) {
1791
+ deps.logger.warn(
1792
+ `Serper.dev dropped ${mapped.length - results.length} unresolved google.com/goto link(s) for "${query}"`
1793
+ );
1794
+ }
1725
1795
  deps.logger.log(`Serper.dev returned ${results.length} results for "${query}"`);
1726
1796
  return { results };
1727
1797
  }
@@ -1780,7 +1850,7 @@ var webFetchSchema = z.object({
1780
1850
  });
1781
1851
  function createWebFetchTool() {
1782
1852
  return tool({
1783
- description: "Fetch the full content of a specific URL (e.g. a search result page). Returns the main article text as Markdown (boilerplate removed). Prefer fetching the most relevant search results to ground the answer in full source text.",
1853
+ description: "Fetch the full content of a specific URL (e.g. a search result page). Returns the main article text as Markdown (boilerplate removed). The top 3 search results are already fetched automatically when no fetch tool runs \u2014 use this for a specific page beyond those, when the snippets are insufficient.",
1784
1854
  inputSchema: webFetchSchema,
1785
1855
  execute: async ({ url }) => {
1786
1856
  const response = await fetchWithTimeout(
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@triplef/agent",
3
3
  "description": "tripleF (3F) agent domain — structured-output schemas, prompt builders, and model tools shared across the apps.",
4
- "version": "1.0.6",
5
- "packageManager": "pnpm@12.16.1",
4
+ "version": "1.0.7",
5
+ "packageManager": "pnpm@12.17.0",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "exports": {
@@ -55,12 +55,12 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@mozilla/readability": "^0.6.0",
58
- "@triplef/helpers": "^1.6.1",
58
+ "@triplef/helpers": "^1.6.2",
59
59
  "linkedom": "^0.18.14",
60
60
  "turndown": "^7.2.4"
61
61
  },
62
62
  "peerDependencies": {
63
- "ai": "^7.0.157",
63
+ "ai": "^7.0.158",
64
64
  "zod": "^4.6.7"
65
65
  },
66
66
  "peerDependenciesMeta": {