@triplef/agent 1.0.1 → 1.0.2

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.
@@ -4,7 +4,7 @@ import { Readability } from '@mozilla/readability';
4
4
  import { parseHTML } from 'linkedom';
5
5
  import TurndownService from 'turndown';
6
6
 
7
- // src/tools/bright-data/bright-data.constants.ts
7
+ // src/tools/bright-data/bright-data.constant.ts
8
8
  var SOURCE = "brightData";
9
9
  function buildGoogleUrl(query, params) {
10
10
  const search = new URLSearchParams();
@@ -24,12 +24,12 @@ function engineEnabled(deps, endpoint) {
24
24
  return cfg.apiKey;
25
25
  }
26
26
 
27
- // src/tools/constants/search-timeout.ts
27
+ // src/tools/constants/search-timeout.constant.ts
28
28
  var SEARCH_TIMEOUT_MS = 1e4;
29
29
  var BRIGHT_DATA_TIMEOUT_MS = 3e4;
30
30
  var SEARCH_RETRIES = 1;
31
31
 
32
- // src/tools/helpers/fetch-with-timeout.ts
32
+ // src/tools/helpers/fetch-with-timeout.helper.ts
33
33
  async function fetchWithTimeout(url, init, options = {}) {
34
34
  const timeoutMs = options.timeoutMs ?? SEARCH_TIMEOUT_MS;
35
35
  const retries = options.retries ?? SEARCH_RETRIES;
@@ -75,10 +75,10 @@ async function requestBrightData(apiKey, zone, url, opts) {
75
75
  return res.json();
76
76
  }
77
77
 
78
- // src/tools/constants/recency.constants.ts
78
+ // src/tools/constants/recency.constant.ts
79
79
  var RECENCY_DESCRIPTION = "Restrict results to the given past period (day=24 hours, week=7 days, month=1 month, year=1 year). Use for fresh content such as news, recent releases, or trending topics; leave unset for evergreen, historical, or general queries.";
80
80
 
81
- // src/tools/constants/standalone-query.constants.ts
81
+ // src/tools/constants/standalone-query.constant.ts
82
82
  var STANDALONE_QUERY_DESCRIPTION = 'A standalone, self-contained search query that explicitly names the subject (title, entity, brand, person, place, or topic). Never copy the user message verbatim: rewrite short follow-ups (e.g. "what do the reviews say?") into a full query that names the established subject from the conversation (e.g. "Neverness to Everness NTE reviews").';
83
83
  var STANDALONE_QUERY_TOOL_CLAUSE = "Always pass a standalone query that names the subject explicitly \u2014 never the user message verbatim.";
84
84
 
@@ -92,7 +92,7 @@ var brightDataImageSearchSchema = z.object({
92
92
  recency: z.enum(["day", "week", "month", "year"]).optional().describe(RECENCY_DESCRIPTION)
93
93
  });
94
94
 
95
- // src/schemas/constants/blocked-image-hosts.ts
95
+ // src/schemas/constants/blocked-image-hosts.constant.ts
96
96
  var BLOCKED_IMAGE_HOSTS = /* @__PURE__ */ new Set([
97
97
  // Google thumbnail proxies (low-res, frequently 404 when hot-linked)
98
98
  "encrypted-tbn0.gstatic.com",
@@ -186,7 +186,7 @@ function isTrustedImageUrl(url) {
186
186
  return false;
187
187
  }
188
188
 
189
- // src/tools/constants/image-search.constants.ts
189
+ // src/tools/constants/image-search.constant.ts
190
190
  var MIN_IMAGE_WIDTH = 1280;
191
191
  var MIN_IMAGE_HEIGHT = 720;
192
192
  function meetsMinimumImageDimensions(width, height, minWidth = MIN_IMAGE_WIDTH, minHeight = MIN_IMAGE_HEIGHT) {
@@ -224,7 +224,7 @@ function applyRecencyParam(body, recency) {
224
224
  body.tbs = existing ? `${existing},${qdr}` : qdr;
225
225
  }
226
226
 
227
- // src/tools/helpers/image-size-buckets.ts
227
+ // src/tools/helpers/image-size-buckets.helper.ts
228
228
  var IMAGE_SIZE_BUCKETS = [
229
229
  { mp: 0.12, label: "qsvga" },
230
230
  // > 400×300
@@ -921,7 +921,7 @@ async function resolveOfferMerchantUrl(offer, deps) {
921
921
  };
922
922
  }
923
923
 
924
- // src/tools/helpers/serper-shop-links.ts
924
+ // src/tools/helpers/serper-shop-links.helper.ts
925
925
  var MAX_LINK_RESOLUTIONS = 12;
926
926
  async function resolveSerperShopOfferLinks(offers, deps) {
927
927
  const googleLinked = offers.filter((offer) => offer.link && isGoogleHostUrl(offer.link));
@@ -936,6 +936,50 @@ async function resolveSerperShopOfferLinks(offers, deps) {
936
936
  deps.logger.log(`Resolved ${merchantUrlByLink.size}/${googleLinked.length} Google shop link(s) to merchant URLs`);
937
937
  return offers.map((offer) => applyResolvedMerchantUrl(offer, merchantUrlByLink));
938
938
  }
939
+
940
+ // src/tools/helpers/summarize-content.helper.ts
941
+ var summarizeContent = (data) => ({
942
+ contentLength: typeof data.content === "string" ? data.content.length : 0
943
+ });
944
+
945
+ // src/tools/helpers/summarize-found.helper.ts
946
+ var summarizeFound = (data) => ({
947
+ found: !!data.title || !!data.id
948
+ });
949
+
950
+ // src/tools/helpers/summarize-results.helper.ts
951
+ function extractSources(results) {
952
+ const sources = /* @__PURE__ */ new Set();
953
+ for (const r of results) {
954
+ const src = r.source;
955
+ if (!src) continue;
956
+ sources.add(src);
957
+ }
958
+ return [...sources];
959
+ }
960
+ var summarizeResults = (data) => {
961
+ const results = data.results;
962
+ if (!Array.isArray(results)) return {};
963
+ return {
964
+ resultCount: results.length,
965
+ sources: extractSources(results),
966
+ sampleImageUrls: results.slice(0, 5).map((r) => r.imageUrl).filter((url) => typeof url === "string" && url.length > 0)
967
+ };
968
+ };
969
+
970
+ // src/tools/helpers/default-summarize.helper.ts
971
+ var defaultSummarize = (data) => {
972
+ if (Array.isArray(data.results)) return summarizeResults(data);
973
+ if (typeof data.content === "string") return summarizeContent(data);
974
+ return {};
975
+ };
976
+
977
+ // src/tools/helpers/with-summary.helper.ts
978
+ function withSummary(tool28, summarize = defaultSummarize) {
979
+ const t = tool28;
980
+ t.summarize = summarize;
981
+ return t;
982
+ }
939
983
  var variantRequestSchema = z.object({});
940
984
  function createVariantRequestTool(variant) {
941
985
  const descriptions = {
@@ -1204,7 +1248,7 @@ function mapSerperReviewResult(r, placeName) {
1204
1248
  };
1205
1249
  }
1206
1250
 
1207
- // src/tools/serper/serper.constants.ts
1251
+ // src/tools/serper/serper.constant.ts
1208
1252
  var HEADERS = (apiKey) => ({
1209
1253
  "X-API-KEY": apiKey,
1210
1254
  "Content-Type": "application/json"
@@ -1716,42 +1760,6 @@ function createSerperWebpageScrape(deps) {
1716
1760
  }
1717
1761
  });
1718
1762
  }
1719
-
1720
- // src/tools/tool-factory.ts
1721
- function extractSources(results) {
1722
- const sources = /* @__PURE__ */ new Set();
1723
- for (const r of results) {
1724
- const src = r.source;
1725
- if (!src) continue;
1726
- sources.add(src);
1727
- }
1728
- return [...sources];
1729
- }
1730
- var summarizeResults = (data) => {
1731
- const results = data.results;
1732
- if (!Array.isArray(results)) return {};
1733
- return {
1734
- resultCount: results.length,
1735
- sources: extractSources(results),
1736
- sampleImageUrls: results.slice(0, 5).map((r) => r.imageUrl).filter((url) => typeof url === "string" && url.length > 0)
1737
- };
1738
- };
1739
- var summarizeContent = (data) => ({
1740
- contentLength: typeof data.content === "string" ? data.content.length : 0
1741
- });
1742
- var summarizeFound = (data) => ({
1743
- found: !!data.title || !!data.id
1744
- });
1745
- var defaultSummarize = (data) => {
1746
- if (Array.isArray(data.results)) return summarizeResults(data);
1747
- if (typeof data.content === "string") return summarizeContent(data);
1748
- return {};
1749
- };
1750
- function withSummary(tool28, summarize = defaultSummarize) {
1751
- const t = tool28;
1752
- t.summarize = summarize;
1753
- return t;
1754
- }
1755
1763
  function extractArticleText(html) {
1756
1764
  if (!html.trim()) return "";
1757
1765
  const { document } = parseHTML(html);
@@ -1786,6 +1794,14 @@ function createWebFetchTool() {
1786
1794
  }
1787
1795
  });
1788
1796
  }
1797
+ var youtubeVideoSearchSchema = z.object({
1798
+ query: z.string().describe(`${STANDALONE_QUERY_DESCRIPTION} Add the video type (e.g. review, trailer, tutorial, gameplay).`),
1799
+ count: z.number().optional().describe("Number of results (max 50)"),
1800
+ recency: z.enum(["day", "week", "month", "year"]).optional().describe(
1801
+ "Restrict results to the given past period (day=24 hours, week=7 days, month=1 month, year=1 year). Use for fresh content such as news, recent releases, or trending topics; leave unset for evergreen, historical, or general queries."
1802
+ ),
1803
+ lang: z.string().optional().describe("Two-letter ISO language code for result preference (e.g. en, de, ja)")
1804
+ });
1789
1805
 
1790
1806
  // src/tools/youtube/helpers/map-youtube-video-result.helper.ts
1791
1807
  function formatIsoDuration(iso) {
@@ -1815,16 +1831,8 @@ function mapYoutubeVideoResult(item, stats) {
1815
1831
  lang: detail?.lang
1816
1832
  };
1817
1833
  }
1818
- var youtubeVideoSearchSchema = z.object({
1819
- query: z.string().describe(`${STANDALONE_QUERY_DESCRIPTION} Add the video type (e.g. review, trailer, tutorial, gameplay).`),
1820
- count: z.number().optional().describe("Number of results (max 50)"),
1821
- recency: z.enum(["day", "week", "month", "year"]).optional().describe(
1822
- "Restrict results to the given past period (day=24 hours, week=7 days, month=1 month, year=1 year). Use for fresh content such as news, recent releases, or trending topics; leave unset for evergreen, historical, or general queries."
1823
- ),
1824
- lang: z.string().optional().describe("Two-letter ISO language code for result preference (e.g. en, de, ja)")
1825
- });
1826
1834
 
1827
- // src/tools/youtube/youtube.ts
1835
+ // src/tools/youtube/youtube.tool.ts
1828
1836
  var SEARCH_URL = "https://www.googleapis.com/youtube/v3/search";
1829
1837
  var VIDEOS_URL = "https://www.googleapis.com/youtube/v3/videos";
1830
1838
  var RECENCY_DAYS = {
@@ -1931,4 +1939,4 @@ function createYoutubeVideoSearch(deps) {
1931
1939
  });
1932
1940
  }
1933
1941
 
1934
- export { BRIGHT_DATA_TIMEOUT_MS, HEADERS, MIN_IMAGE_HEIGHT, MIN_IMAGE_WIDTH, RECENCY_DESCRIPTION, SEARCH_RETRIES, SEARCH_TIMEOUT_MS, SOURCE, STANDALONE_QUERY_DESCRIPTION, STANDALONE_QUERY_TOOL_CLAUSE, applyLocaleParams, applyRecencyParam, brightDataImageSearchSchema, brightDataNewsSearchSchema, brightDataPlacesSearchSchema, brightDataShoppingSearchSchema, brightDataVideoSearchSchema, brightDataWebSearchSchema, brightDataWebpageScrapeSchema, buildGoogleUrl, buildYoutubeThumbnailUrl, createBrightDataImageSearch, createBrightDataNewsSearch, createBrightDataPlacesSearch, createBrightDataShoppingSearch, createBrightDataVideoSearch, createBrightDataWebSearch, createBrightDataWebpageScrape, createEncyclopediaReadTool, createEncyclopediaSearchTool, createMemoryCognitionDeleteTool, createMemoryCognitionForgetTool, createMemoryCognitionRememberTool, createMemoryPartitionDeleteTool, createMemoryPartitionRecallTool, createMemoryPartitionRememberTool, createMemoryTaxonomyProbeTool, createSerperBusinessReviewsSearch, createSerperImageSearch, createSerperNewsSearch, createSerperPlacesSearch, createSerperShoppingSearch, createSerperVideoSearch, createSerperWebSearch, createSerperWebpageScrape, createVariantRequestTool, createWebFetchTool, createYoutubeVideoSearch, defaultSummarize, encyclopediaReadSchema, encyclopediaSearchSchema, engineEnabled, extractArticleText, fetchWithTimeout, isGoogleHostUrl, localizedQuerySuffix, meetsMinimumImageDimensions, memoryCognitionDeleteSchema, memoryCognitionForgetSchema, memoryCognitionRememberSchema, memoryPartitionDeleteSchema, memoryPartitionRecallSchema, memoryPartitionRememberSchema, memoryTaxonomyProbeSchema, pickMerchantResult, requestBrightData, resolveSerperShopOfferLinks, serperBusinessReviewsSearchSchema, serperImageSearchSchema, serperNewsSearchSchema, serperPlacesSearchSchema, serperShoppingSearchSchema, serperVideoSearchSchema, serperWebSearchSchema, serperWebpageScrapeSchema, storeHostToken, summarizeContent, summarizeFound, summarizeResults, tbsSizeLabelForPixels, variantRequestSchema, webFetchSchema, withSummary, youtubeVideoSearchSchema };
1942
+ export { BRIGHT_DATA_TIMEOUT_MS, HEADERS, MIN_IMAGE_HEIGHT, MIN_IMAGE_WIDTH, RECENCY_DESCRIPTION, SEARCH_RETRIES, SEARCH_TIMEOUT_MS, SOURCE, STANDALONE_QUERY_DESCRIPTION, STANDALONE_QUERY_TOOL_CLAUSE, applyLocaleParams, applyRecencyParam, brightDataImageSearchSchema, brightDataNewsSearchSchema, brightDataPlacesSearchSchema, brightDataShoppingSearchSchema, brightDataVideoSearchSchema, brightDataWebSearchSchema, brightDataWebpageScrapeSchema, buildGoogleUrl, buildYoutubeThumbnailUrl, createBrightDataImageSearch, createBrightDataNewsSearch, createBrightDataPlacesSearch, createBrightDataShoppingSearch, createBrightDataVideoSearch, createBrightDataWebSearch, createBrightDataWebpageScrape, createEncyclopediaReadTool, createEncyclopediaSearchTool, createMemoryCognitionDeleteTool, createMemoryCognitionForgetTool, createMemoryCognitionRememberTool, createMemoryPartitionDeleteTool, createMemoryPartitionRecallTool, createMemoryPartitionRememberTool, createMemoryTaxonomyProbeTool, createSerperBusinessReviewsSearch, createSerperImageSearch, createSerperNewsSearch, createSerperPlacesSearch, createSerperShoppingSearch, createSerperVideoSearch, createSerperWebSearch, createSerperWebpageScrape, createVariantRequestTool, createWebFetchTool, createYoutubeVideoSearch, encyclopediaReadSchema, encyclopediaSearchSchema, engineEnabled, extractArticleText, fetchWithTimeout, isGoogleHostUrl, localizedQuerySuffix, meetsMinimumImageDimensions, memoryCognitionDeleteSchema, memoryCognitionForgetSchema, memoryCognitionRememberSchema, memoryPartitionDeleteSchema, memoryPartitionRecallSchema, memoryPartitionRememberSchema, memoryTaxonomyProbeSchema, pickMerchantResult, requestBrightData, resolveSerperShopOfferLinks, serperBusinessReviewsSearchSchema, serperImageSearchSchema, serperNewsSearchSchema, serperPlacesSearchSchema, serperShoppingSearchSchema, serperVideoSearchSchema, serperWebSearchSchema, serperWebpageScrapeSchema, storeHostToken, summarizeContent, summarizeFound, summarizeResults, tbsSizeLabelForPixels, variantRequestSchema, webFetchSchema, withSummary, youtubeVideoSearchSchema };
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.1",
5
- "packageManager": "pnpm@11.26.0",
4
+ "version": "1.0.2",
5
+ "packageManager": "pnpm@12.9.1",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "exports": {
@@ -60,8 +60,8 @@
60
60
  "turndown": "^7.2.4"
61
61
  },
62
62
  "peerDependencies": {
63
- "ai": "^7.0.93",
64
- "zod": "^4.5.4"
63
+ "ai": "^7.0.128",
64
+ "zod": "^4.6.5"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "ai": {
@@ -69,30 +69,30 @@
69
69
  }
70
70
  },
71
71
  "devDependencies": {
72
- "@changesets/cli": "^3.0.2",
72
+ "@changesets/cli": "^3.0.3",
73
73
  "@eslint/js": "^10.0.1",
74
74
  "@types/eslint": "^9.6.1",
75
- "@types/node": "^26.5.0",
75
+ "@types/node": "^26.6.4",
76
76
  "@types/turndown": "^5.0.6",
77
- "@vitest/coverage-v8": "4.1.11",
77
+ "@vitest/coverage-v8": "5.0.3",
78
78
  "depcheck": "^1.4.7",
79
- "dependency-cruiser": "^18.2.0",
80
- "eslint": "^10.10.0",
79
+ "dependency-cruiser": "^18.5.0",
80
+ "eslint": "^10.12.0",
81
81
  "eslint-config-prettier": "^10.1.8",
82
82
  "eslint-plugin-prettier": "^5.5.6",
83
83
  "eslint-plugin-simple-import-sort": "^14.0.0",
84
- "eslint-plugin-sonarjs": "^4.2.0",
85
- "globals": "^17.12.0",
84
+ "eslint-plugin-sonarjs": "^4.2.2",
85
+ "globals": "^17.13.0",
86
86
  "husky": "^9.1.7",
87
87
  "jiti": "^2.7.0",
88
- "lint-staged": "^17.5.0",
88
+ "lint-staged": "^17.6.0",
89
89
  "npm-check-updates": "^23.1.0",
90
- "prettier": "^3.9.6",
90
+ "prettier": "^3.9.9",
91
91
  "rimraf": "^6.1.3",
92
92
  "ts-unused-exports": "^11.0.1",
93
93
  "tsup": "^8.5.1",
94
94
  "typescript": "^5.9.3",
95
- "typescript-eslint": "^8.70.0",
96
- "vitest": "^4.1.11"
95
+ "typescript-eslint": "^8.71.1",
96
+ "vitest": "^5.0.3"
97
97
  }
98
98
  }