n8n-nodes-agentsearch 0.6.0 → 0.7.0

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.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  n8n community node for [AgentSearch](https://agentsearchhq.com/?utm_source=n8n-nodes-agentsearch&utm_medium=package): live web search for workflows and AI agents.
4
4
 
5
5
  - **Free Search**: up to 5 results per call, 25 searches per day per IP, **no credentials**.
6
- - **Extract Page** (new in 0.3.0): read a page as clean markdown or text. $0.007 per call (x402, USDC on Base).
6
+ - **Extract Page** (new in 0.3.0): read a page as clean markdown or text. $0.004 per call (x402, USDC on Base).
7
7
  - **Render Page** (new in 0.3.0): load a JavaScript-heavy page in a headless browser, then read it (markdown, text, HTML, links, optional screenshot). $0.010 per call.
8
8
  - `usableAsTool`: all three work as tools for the n8n AI Agent node (search, then read the best page).
9
9
  - No runtime dependencies.
@@ -30,21 +30,29 @@ Output (default):
30
30
 
31
31
  If the daily free limit is reached (HTTP 429) the node fails with an explanation; enable *Continue On Fail* to keep the workflow running.
32
32
 
33
- **Hit the 429?** Extract (full page text) and Render (JS pages) are in this node at $0.007 / $0.010 per call: see below.
33
+ **Hit the 429?** Extract (full page text) and Render (JS pages) are in this node at $0.004 / $0.010 per call: see below.
34
34
 
35
35
  ## Extract and Render (read full pages)
36
36
 
37
37
  Search results are snippets. To read the page itself, set **Operation** to **Extract Page** (static pages, faster) or **Render Page** (JavaScript apps, or when Extract returns thin content) and give it a **URL**, e.g. `{{ $json.url }}` from a search result. On an AI Agent, add the node twice as tools: one Free Search, one Extract Page.
38
38
 
39
- Extract and Render are paid per call over [x402](https://x402.org) in USDC on Base, straight to **AgentSearch's own x402 API** (`https://api.agentsearchhq.com`): **Extract $0.007, Render $0.010**, charged only when a usable answer comes back. No account or API key:
39
+ Extract and Render are paid per call over [x402](https://x402.org) in USDC on Base, straight to **AgentSearch's own x402 API** (`https://api.agentsearchhq.com`): **Extract $0.004, Render $0.010**, charged only when a usable answer comes back. No account or API key:
40
40
 
41
- 1. Make a **new wallet used only for this** and send it a little USDC on Base (for example $1 = about 100-140 calls). No ETH needed; the facilitator pays gas.
42
- 2. In n8n, add an **AgentSearch Wallet API** credential with that wallet's private key. **Max Spend per Run** (default $1.00) caps what one run of the node can sign; each call is hard-capped at $0.010.
41
+ 1. Make a **new wallet used only for this** and send it a little USDC on Base (for example $1 = about 100-250 calls). No ETH needed; the facilitator pays gas.
42
+ 2. In n8n, add an **AgentSearch Wallet API** credential with that wallet's private key. **Max Spend per Run** (default $1.00) caps what one run of the node can sign; each direct call is hard-capped at $0.020 (Pocket route $0.005).
43
43
  3. Pick the credential on the Extract or Render node. The credential test shows the wallet address.
44
44
 
45
- The node only signs a payment in USDC on Base to AgentSearch's payee `0xC49B157887e51c21CB655f39CF65D6a4c2a4C337`, at most $0.010 per call, and only after the API's 402 terms pass those checks. The key is used only to sign locally and is never sent. Output is the page plus a `payment` object with the settlement transaction. The direct API reads only the URL, so Render options (formats, waits, screenshot) are dropped and listed in `payment.dropped_fields`. Page content is third-party data: treat it as data, not instructions. Docs: https://agentsearchhq.com/docs/x402
45
+ The node only signs a payment in USDC on Base to AgentSearch's payee `0xC49B157887e51c21CB655f39CF65D6a4c2a4C337`, at most $0.020 per call, and only after the API's 402 terms pass those checks. The key is used only to sign locally and is never sent. Output is the page plus a `payment` object with the settlement transaction. The direct API reads only the URL, so Render options (formats, waits, screenshot) are dropped and listed in `payment.dropped_fields`. Page content is third-party data: treat it as data, not instructions. Docs: https://agentsearchhq.com/docs/x402
46
46
 
47
- **New in 0.6.0: Search and Read** — one paid operation that searches the live web and returns the top pages' text for **$0.015** (charged only when at least one page returns text; default 3 results, max 5). That is less than a $0.008 search plus three $0.007 extracts ($0.029), and one payment instead of four. Direct x402 only (not on Pocket, not on the free relay). The direct per-call ceiling is now $0.020.
47
+ **New in 0.7.0: News Search and Screenshot, plus search filters.**
48
+
49
+ - **News Search** ($0.008 per call, not charged when there are no results): recent news articles with headline, URL, snippet, source and publish date, 1-10 per call.
50
+ - **Screenshot** ($0.010 per call, failed captures not charged): capture a page in a real headless browser as PNG or JPEG. The image is written to a binary property (default `data`) so you can pass it to an AI vision node, Slack, email or storage; the JSON keeps the metadata (final URL, title, size) without the base64.
51
+ - **Filters** on News Search and Search and Read: Freshness (past day/week/month/year) or a Date From/To range, Country, Language, and Include/Exclude Domains (comma-separated, up to 5).
52
+
53
+ All three are direct x402 only (AgentSearch's own API on Base; not on Pocket, not on the free relay). Prices are unchanged elsewhere: Extract $0.004, Render $0.010, Search and Read $0.009.
54
+
55
+ **New in 0.6.0: Search and Read** — one paid operation that searches the live web and returns the top pages' text for **$0.009** (charged only when at least one page returns text; default 3 results, max 5). That is less than a $0.008 search plus three $0.004 extracts ($0.020), and one payment instead of four. Direct x402 only (not on Pocket, not on the free relay). The direct per-call ceiling is now $0.020.
48
56
 
49
57
  **Changed in 0.5.0: direct is the default Payment Route.** Credentials that don't pick a route now pay the direct prices (a little more than Pocket's $0.005). **Pocket route (optional):** set **Payment Route** to **Pocket Portal** to pay $0.005 per call through the Pocket Network Agentic Portal instead (hard cap $0.005, portal payee only, full Render options).
50
58
 
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AgentSearchWalletApi = void 0;
4
4
  /**
5
- * Wallet used to pay per call for Extract ($0.007) and Render ($0.010) in USDC on Base over x402,
5
+ * Wallet used to pay per call for Extract ($0.004) and Render ($0.010) in USDC on Base over x402,
6
6
  * by default to AgentSearch's own x402 API (Pocket portal route optional). Free Search never uses it.
7
7
  */
8
8
  class AgentSearchWalletApi {
@@ -19,14 +19,14 @@ class AgentSearchWalletApi {
19
19
  typeOptions: { password: true },
20
20
  default: '',
21
21
  required: true,
22
- description: '64-hex private key of a NEW wallet made only for this, funded with a little USDC on Base (for example $1 = about 100-140 calls; no ETH needed). Used only to sign small USDC payments for Extract/Render; never sent anywhere.',
22
+ description: '64-hex private key of a NEW wallet made only for this, funded with a little USDC on Base (for example $1 = about 100-250 calls; no ETH needed). Used only to sign small USDC payments for Extract/Render; never sent anywhere.',
23
23
  },
24
24
  {
25
25
  displayName: 'Payment Route',
26
26
  name: 'paymentRoute',
27
27
  type: 'options',
28
28
  options: [
29
- { name: 'AgentSearch Direct x402 (Extract $0.007, Render $0.010)', value: 'direct', description: "Pay AgentSearch's own x402 API on Base (api.agentsearchhq.com) (default)" },
29
+ { name: 'AgentSearch Direct x402 (Extract $0.004, Render $0.010)', value: 'direct', description: "Pay AgentSearch's own x402 API on Base (api.agentsearchhq.com) (default)" },
30
30
  { name: 'Pocket Portal ($0.005 per Call)', value: 'pocket', description: 'Pay through the Pocket Network Agentic Portal instead' },
31
31
  ],
32
32
  default: 'direct',
@@ -1,28 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AgentSearch = exports.WALLET_SETUP = exports.PORTAL_SERVICES = exports.LIMIT_MESSAGE = exports.CLIENT_TAG = exports.PORTAL_URL = exports.RELAY_BASE_URL = exports.FREE_RELAY_URL = void 0;
3
+ exports.DIRECT_OPS = exports.AgentSearch = exports.WALLET_SETUP = exports.PORTAL_SERVICES = exports.LIMIT_MESSAGE = exports.CLIENT_TAG = exports.PORTAL_URL = exports.RELAY_BASE_URL = exports.FREE_RELAY_URL = void 0;
4
4
  exports.paidOnlyMessage = paidOnlyMessage;
5
5
  exports.trialLimitMessage = trialLimitMessage;
6
+ exports.filtersBody = filtersBody;
6
7
  const n8n_workflow_1 = require("n8n-workflow");
7
8
  const x402_1 = require("./x402");
8
9
  exports.FREE_RELAY_URL = 'https://relay.agentsearchhq.com/v1/search';
9
10
  exports.RELAY_BASE_URL = 'https://relay.agentsearchhq.com';
10
11
  exports.PORTAL_URL = 'https://agent.pocket.network';
11
- exports.CLIENT_TAG = 'n8n-nodes-agentsearch/0.6.0';
12
+ exports.CLIENT_TAG = 'n8n-nodes-agentsearch/0.7.0';
12
13
  const DOCS = 'https://agentsearchhq.com/?utm_source=n8n-nodes-agentsearch&utm_medium=package';
13
14
  const GUIDE = 'https://agentsearchhq.com/blog/n8n-ai-agent-read-web-pages?utm_source=n8n-nodes-agentsearch&utm_medium=package';
14
- exports.LIMIT_MESSAGE = `Free AgentSearch limit reached (25 searches per day per IP; resets daily). For unlimited search plus extract (static pages) and render (JavaScript-heavy pages, or when extract returns thin content), use the paid API (AgentSearch's own x402 API on Base: Extract $0.007, Render $0.010 per call in USDC; Pocket route $0.005 optional). Docs: ${DOCS}`;
15
+ exports.LIMIT_MESSAGE = `Free AgentSearch limit reached (25 searches per day per IP; resets daily). For unlimited search plus extract (static pages) and render (JavaScript-heavy pages, or when extract returns thin content), use the paid API (AgentSearch's own x402 API on Base: Extract $0.004, Render $0.010 per call in USDC; Pocket route $0.005 optional). Docs: ${DOCS}`;
15
16
  exports.PORTAL_SERVICES = {
16
17
  extract: { serviceId: 'agentsearch-web-extract-v1', path: '/v1/extract' },
17
18
  render: { serviceId: 'agentsearch-web-render-v1', path: '/v1/render' },
18
19
  };
19
- exports.WALLET_SETUP = 'Add an "AgentSearch Wallet API" credential to this node: the private key of a NEW wallet made only for this, funded with a little USDC on Base (for example $1 = about 100-140 calls; no ETH needed). Each call is paid over x402 to AgentSearch\'s own API on Base (Extract $0.007, Render $0.010; failed calls are not charged), or $0.005 through the Pocket Network Agentic Portal if you pick that Payment Route. Free Search stays free and needs no credential. Guide: ' +
20
+ exports.WALLET_SETUP = 'Add an "AgentSearch Wallet API" credential to this node: the private key of a NEW wallet made only for this, funded with a little USDC on Base (for example $1 = about 100-250 calls; no ETH needed). Each call is paid over x402 to AgentSearch\'s own API on Base (Extract $0.004, Render $0.010; failed calls are not charged), or $0.005 through the Pocket Network Agentic Portal if you pick that Payment Route. Free Search stays free and needs no credential. Guide: ' +
20
21
  GUIDE;
21
22
  function paidOnlyMessage(op) {
22
- return `${op === 'extract' ? 'Extract' : 'Render'} is a paid operation (${op === 'extract' ? '$0.007' : '$0.010'} per call in USDC on Base via x402) and no wallet credential is set, so nothing was paid. ${exports.WALLET_SETUP}`;
23
+ return `${op === 'extract' ? 'Extract' : 'Render'} is a paid operation (${op === 'extract' ? '$0.004' : '$0.010'} per call in USDC on Base via x402) and no wallet credential is set, so nothing was paid. ${exports.WALLET_SETUP}`;
23
24
  }
24
25
  function trialLimitMessage(op) {
25
- return `Free ${op} allowance for today is used up. Continue at ${op === 'extract' ? '$0.007' : '$0.010'} per call (x402, USDC on Base): ${exports.WALLET_SETUP}`;
26
+ return `Free ${op} allowance for today is used up. Continue at ${op === 'extract' ? '$0.004' : '$0.010'} per call (x402, USDC on Base): ${exports.WALLET_SETUP}`;
26
27
  }
27
28
  const headerOf = (headers, name) => {
28
29
  const h = (headers ?? {});
@@ -52,7 +53,7 @@ class AgentSearch {
52
53
  group: ['transform'],
53
54
  version: 1,
54
55
  subtitle: '={{$parameter["operation"]}}',
55
- description: 'Free live web search for AI agents, plus page Extract ($0.007), JavaScript Render ($0.010), and Search + Read ($0.015) per call via x402',
56
+ description: 'Free live web search for AI agents, plus News Search ($0.008), page Extract ($0.004), JavaScript Render ($0.010), Screenshot ($0.010), and Search + Read ($0.009) per call via x402',
56
57
  defaults: { name: 'AgentSearch' },
57
58
  inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
58
59
  outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
@@ -62,7 +63,7 @@ class AgentSearch {
62
63
  name: 'agentSearchWalletApi',
63
64
  required: false,
64
65
  testedBy: 'agentSearchWalletTest',
65
- displayOptions: { show: { operation: ['extract', 'render', 'searchAndRead'] } },
66
+ displayOptions: { show: { operation: ['extract', 'render', 'searchAndRead', 'news', 'screenshot'] } },
66
67
  },
67
68
  ],
68
69
  properties: [
@@ -77,7 +78,7 @@ class AgentSearch {
77
78
  name: 'Extract Page',
78
79
  value: 'extract',
79
80
  action: 'Extract a page as markdown',
80
- description: 'Read a page as clean markdown or text ($0.007 per call, wallet credential)',
81
+ description: 'Read a page as clean markdown or text ($0.004 per call, wallet credential)',
81
82
  },
82
83
  {
83
84
  name: 'Render Page',
@@ -85,11 +86,23 @@ class AgentSearch {
85
86
  action: 'Render a dynamic page',
86
87
  description: 'Load a JavaScript-heavy page in a headless browser and read it ($0.010 per call, wallet credential)',
87
88
  },
89
+ {
90
+ name: 'News Search',
91
+ value: 'news',
92
+ action: 'Search recent news',
93
+ description: 'Recent news articles with date, source and snippet ($0.008 per call, not charged when no results; wallet credential; direct x402 only)',
94
+ },
95
+ {
96
+ name: 'Screenshot',
97
+ value: 'screenshot',
98
+ action: 'Take a screenshot of a page',
99
+ description: 'Capture a page in a real headless browser as a PNG or JPEG binary ($0.010 per call, failed captures not charged; wallet credential; direct x402 only)',
100
+ },
88
101
  {
89
102
  name: 'Search and Read',
90
103
  value: 'searchAndRead',
91
104
  action: 'Search and read top pages',
92
- description: 'Search the live web and return the top pages\' text in one paid call ($0.015, charged only when at least one page returns text; wallet credential; direct x402 only)',
105
+ description: 'Search the live web and return the top pages\' text in one paid call ($0.009, charged only when at least one page returns text; wallet credential; direct x402 only)',
93
106
  },
94
107
  ],
95
108
  default: 'freeSearch',
@@ -101,7 +114,7 @@ class AgentSearch {
101
114
  default: '',
102
115
  required: true,
103
116
  placeholder: 'latest n8n release',
104
- displayOptions: { show: { operation: ['freeSearch', 'searchAndRead'] } },
117
+ displayOptions: { show: { operation: ['freeSearch', 'searchAndRead', 'news'] } },
105
118
  },
106
119
  {
107
120
  displayName: 'Max Results',
@@ -111,6 +124,15 @@ class AgentSearch {
111
124
  default: 5,
112
125
  displayOptions: { show: { operation: ['freeSearch'] } },
113
126
  },
127
+ {
128
+ displayName: 'Max Results',
129
+ name: 'newsMaxResults',
130
+ type: 'number',
131
+ typeOptions: { minValue: 1, maxValue: 10 },
132
+ default: 5,
133
+ description: 'How many news articles to return (default 5, max 10)',
134
+ displayOptions: { show: { operation: ['news'] } },
135
+ },
114
136
  {
115
137
  displayName: 'Number of Results to Read',
116
138
  name: 'numResults',
@@ -136,7 +158,7 @@ class AgentSearch {
136
158
  required: true,
137
159
  placeholder: 'https://example.com/article',
138
160
  description: 'Absolute public http(s) URL of the page to read',
139
- displayOptions: { show: { operation: ['extract', 'render'] } },
161
+ displayOptions: { show: { operation: ['extract', 'render', 'screenshot'] } },
140
162
  },
141
163
  {
142
164
  displayName: 'Formats',
@@ -187,9 +209,64 @@ class AgentSearch {
187
209
  name: 'renderFallback',
188
210
  type: 'boolean',
189
211
  default: false,
190
- description: 'Whether to render at most one thin page in the same $0.015 call if extract returns little text',
212
+ description: 'Whether to render at most one thin page in the same $0.009 call if extract returns little text',
191
213
  displayOptions: { show: { operation: ['searchAndRead'] } },
192
214
  },
215
+ {
216
+ displayName: 'Filters',
217
+ name: 'filters',
218
+ type: 'collection',
219
+ placeholder: 'Add Filter',
220
+ default: {},
221
+ description: 'Optional search filters (direct x402 API)',
222
+ displayOptions: { show: { operation: ['news', 'searchAndRead'] } },
223
+ options: [
224
+ { displayName: 'Country', name: 'country', type: 'string', default: '', placeholder: 'us', description: '2-letter ISO 3166-1 country code, e.g. us, gb, de' },
225
+ { displayName: 'Date From', name: 'date_from', type: 'string', default: '', placeholder: '2026-11-01', description: 'Only results on or after this date (YYYY-MM-DD). Do not combine with Freshness.' },
226
+ { displayName: 'Date To', name: 'date_to', type: 'string', default: '', placeholder: '2026-11-12', description: 'Only results on or before this date (YYYY-MM-DD)' },
227
+ { displayName: 'Exclude Domains', name: 'exclude_domains', type: 'string', default: '', placeholder: 'pinterest.com, quora.com', description: 'Comma-separated domains to never return (up to 5)' },
228
+ {
229
+ displayName: 'Freshness',
230
+ name: 'freshness',
231
+ type: 'options',
232
+ options: [
233
+ { name: 'Past Day', value: 'day' },
234
+ { name: 'Past Week', value: 'week' },
235
+ { name: 'Past Month', value: 'month' },
236
+ { name: 'Past Year', value: 'year' },
237
+ ],
238
+ default: 'week',
239
+ description: 'Only results from this recent period',
240
+ },
241
+ { displayName: 'Include Domains', name: 'include_domains', type: 'string', default: '', placeholder: 'reuters.com, apnews.com', description: 'Comma-separated domains to search only (up to 5, subdomains included)' },
242
+ { displayName: 'Language', name: 'language', type: 'string', default: '', placeholder: 'en', description: 'ISO 639-1 language, e.g. en, es or pt-BR' },
243
+ ],
244
+ },
245
+ {
246
+ displayName: 'Image Format',
247
+ name: 'screenshotFormat',
248
+ type: 'options',
249
+ options: [
250
+ { name: 'PNG', value: 'png' },
251
+ { name: 'JPEG', value: 'jpeg' },
252
+ ],
253
+ default: 'png',
254
+ displayOptions: { show: { operation: ['screenshot'] } },
255
+ },
256
+ {
257
+ displayName: 'Options',
258
+ name: 'screenshotOptions',
259
+ type: 'collection',
260
+ placeholder: 'Add Option',
261
+ default: {},
262
+ displayOptions: { show: { operation: ['screenshot'] } },
263
+ options: [
264
+ { displayName: 'Binary Property', name: 'binaryProperty', type: 'string', default: 'data', description: 'Name of the binary property to write the image to' },
265
+ { displayName: 'Full Page', name: 'fullPage', type: 'boolean', default: false, description: 'Whether to capture the whole page (clipped at 4000 px tall) instead of the viewport' },
266
+ { displayName: 'Viewport Height', name: 'height', type: 'number', typeOptions: { minValue: 240, maxValue: 1600 }, default: 800, description: 'Viewport height in CSS pixels (240-1600)' },
267
+ { displayName: 'Viewport Width', name: 'width', type: 'number', typeOptions: { minValue: 320, maxValue: 1920 }, default: 1280, description: 'Viewport width in CSS pixels (320-1920; e.g. 390 for mobile)' },
268
+ ],
269
+ },
193
270
  {
194
271
  displayName: 'Options',
195
272
  name: 'renderOptions',
@@ -272,7 +349,7 @@ class AgentSearch {
272
349
  return { status: 'Error', message: 'Max Spend per Run must be a positive number of USD.' };
273
350
  return {
274
351
  status: 'OK',
275
- message: `Valid key for wallet ${address}. Fund it with USDC on Base (no ETH needed); each Extract ($0.007) or Render ($0.010) call pays AgentSearch's x402 API ($0.005 on the Pocket route).`,
352
+ message: `Valid key for wallet ${address}. Fund it with USDC on Base (no ETH needed); each Extract ($0.004) or Render ($0.010) call pays AgentSearch's x402 API ($0.005 on the Pocket route).`,
276
353
  };
277
354
  },
278
355
  },
@@ -291,10 +368,10 @@ class AgentSearch {
291
368
  out.push({ json: r.json, pairedItem: { item: i } });
292
369
  continue;
293
370
  }
294
- if (operation === 'searchAndRead') {
295
- const r = await searchAndRead.call(this, i, signedAtomic);
371
+ if (operation === 'searchAndRead' || operation === 'news' || operation === 'screenshot') {
372
+ const r = await directPaid.call(this, operation, i, signedAtomic);
296
373
  signedAtomic = r.signedAtomic;
297
- out.push({ json: r.json, pairedItem: { item: i } });
374
+ out.push({ json: r.json, ...(r.binary ? { binary: r.binary } : {}), pairedItem: { item: i } });
298
375
  continue;
299
376
  }
300
377
  const query = this.getNodeParameter('query', i).trim();
@@ -501,20 +578,69 @@ async function readPage(op, i, signedBefore) {
501
578
  };
502
579
  return { json: { ...data, payment, portal: direct ? null : envelope.portal ?? null }, signedAtomic };
503
580
  }
504
- async function searchAndRead(i, signedBefore) {
505
- const query = String(this.getNodeParameter('query', i) ?? '').trim();
506
- if (!query)
507
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Query is empty', { itemIndex: i });
508
- const numResults = this.getNodeParameter('numResults', i, 3);
509
- const maxChars = this.getNodeParameter('searchAndReadMaxChars', i, 8000);
510
- const renderFallback = this.getNodeParameter('renderFallback', i, false);
511
- const body = { query };
512
- if (numResults)
513
- body.num_results = numResults;
514
- if (maxChars)
515
- body.max_chars = maxChars;
516
- if (renderFallback)
517
- body.render_fallback = true;
581
+ exports.DIRECT_OPS = {
582
+ searchAndRead: { path: 'search_and_read', label: 'Search and Read', price: '$0.009', when: 'charged only when at least one page returns text' },
583
+ news: { path: 'news', label: 'News Search', price: '$0.008', when: 'not charged when there are no results' },
584
+ screenshot: { path: 'screenshot', label: 'Screenshot', price: '$0.010', when: 'failed captures are not charged' },
585
+ };
586
+ const domainList = (v) => String(v ?? '')
587
+ .split(',')
588
+ .map((d) => d.trim())
589
+ .filter(Boolean)
590
+ .slice(0, 5);
591
+ function filtersBody(raw) {
592
+ const f = raw ?? {};
593
+ const out = {};
594
+ for (const k of ['freshness', 'date_from', 'date_to', 'country', 'language']) {
595
+ const v = String(f[k] ?? '').trim();
596
+ if (v)
597
+ out[k] = k === 'country' ? v.toLowerCase() : v;
598
+ }
599
+ for (const k of ['include_domains', 'exclude_domains']) {
600
+ const v = domainList(f[k]);
601
+ if (v.length)
602
+ out[k] = v;
603
+ }
604
+ return out;
605
+ }
606
+ async function directPaid(op, i, signedBefore) {
607
+ const meta = exports.DIRECT_OPS[op];
608
+ let body;
609
+ if (op === 'screenshot') {
610
+ const url = String(this.getNodeParameter('url', i) ?? '').trim();
611
+ if (!/^https?:\/\//i.test(url))
612
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'URL must be an absolute http(s) URL', { itemIndex: i });
613
+ const format = this.getNodeParameter('screenshotFormat', i, 'png');
614
+ const o = (this.getNodeParameter('screenshotOptions', i, {}) ?? {});
615
+ body = { url, format };
616
+ if (o.fullPage === true)
617
+ body.full_page = true;
618
+ if (o.width || o.height)
619
+ body.viewport = { ...(o.width ? { width: Number(o.width) } : {}), ...(o.height ? { height: Number(o.height) } : {}) };
620
+ }
621
+ else {
622
+ const query = String(this.getNodeParameter('query', i) ?? '').trim();
623
+ if (!query)
624
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Query is empty', { itemIndex: i });
625
+ body = { query };
626
+ if (op === 'news') {
627
+ const n = this.getNodeParameter('newsMaxResults', i, 5);
628
+ if (n)
629
+ body.max_results = n;
630
+ }
631
+ else {
632
+ const numResults = this.getNodeParameter('numResults', i, 3);
633
+ const maxChars = this.getNodeParameter('searchAndReadMaxChars', i, 8000);
634
+ const renderFallback = this.getNodeParameter('renderFallback', i, false);
635
+ if (numResults)
636
+ body.num_results = numResults;
637
+ if (maxChars)
638
+ body.max_chars = maxChars;
639
+ if (renderFallback)
640
+ body.render_fallback = true;
641
+ }
642
+ Object.assign(body, filtersBody(this.getNodeParameter('filters', i, {})));
643
+ }
518
644
  let creds;
519
645
  try {
520
646
  creds = await this.getCredentials('agentSearchWalletApi', i);
@@ -523,10 +649,10 @@ async function searchAndRead(i, signedBefore) {
523
649
  creds = undefined;
524
650
  }
525
651
  if (!creds?.privateKey) {
526
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Search and Read is a paid operation ($0.015 per call in USDC on Base via x402, charged only when at least one page returns text) and no wallet credential is set, so nothing was paid. It is not on the free relay. ' + exports.WALLET_SETUP, { itemIndex: i });
652
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `${meta.label} is a paid operation (${meta.price} per call in USDC on Base via x402, ${meta.when}) and no wallet credential is set, so nothing was paid. It is not on the free relay. ` + exports.WALLET_SETUP, { itemIndex: i });
527
653
  }
528
654
  if (creds.paymentRoute === 'pocket') {
529
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Search and Read is available only on AgentSearch\'s own x402 API ($0.015 per call when at least one page returns text). Set Payment Route to Direct (the default) on the AgentSearch Wallet API credential. Pocket does not offer this operation. Nothing was signed.', { itemIndex: i });
655
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `${meta.label} is available only on AgentSearch's own x402 API (${meta.price} per call, ${meta.when}). Set Payment Route to Direct (the default) on the AgentSearch Wallet API credential. Pocket does not offer this operation. Nothing was signed.`, { itemIndex: i });
530
656
  }
531
657
  let key;
532
658
  try {
@@ -544,8 +670,8 @@ async function searchAndRead(i, signedBefore) {
544
670
  if (ceiling <= 0n) {
545
671
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Spend cap reached for this run: ${(0, x402_1.atomicToUsd)(signedBefore)} of ${(0, x402_1.atomicToUsd)(capAtomic)} signed. Raise "Max Spend per Run" on the AgentSearch Wallet API credential to spend more. Nothing was signed.`, { itemIndex: i });
546
672
  }
547
- const url = `${x402_1.DIRECT_URL}/x402/v1/search_and_read`;
548
- const expectRes = '/x402/v1/search_and_read';
673
+ const url = `${x402_1.DIRECT_URL}/x402/v1/${meta.path}`;
674
+ const expectRes = `/x402/v1/${meta.path}`;
549
675
  const unpaid = await post.call(this, url, body);
550
676
  if (unpaid.statusCode !== 402) {
551
677
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The AgentSearch x402 API answered ${unpaid.statusCode} before payment: ${errorText(unpaid.body)}. Nothing was signed.`, { itemIndex: i });
@@ -573,7 +699,7 @@ async function searchAndRead(i, signedBefore) {
573
699
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), msg, { itemIndex: i });
574
700
  }
575
701
  if (ceiling < 15000n) {
576
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `${msg} Search and Read costs $0.015; raise "Max Spend per Run" or the per-call ceiling to at least 20000 atomic units ($0.020). Nothing was signed.`, { itemIndex: i });
702
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `${msg} ${meta.label} costs ${meta.price}; raise "Max Spend per Run" or the per-call ceiling to at least 20000 atomic units ($0.020). Nothing was signed.`, { itemIndex: i });
577
703
  }
578
704
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), msg, { itemIndex: i });
579
705
  }
@@ -610,12 +736,33 @@ async function searchAndRead(i, signedBefore) {
610
736
  network: x402_1.BASE_NETWORK,
611
737
  pay_to: payee,
612
738
  payer: from,
613
- service_id: 'search_and_read',
739
+ service_id: meta.path,
614
740
  route: 'agentsearch-x402-direct',
615
741
  settled: receipt?.success ?? false,
616
742
  transaction: tx,
617
743
  ...(tx ? { explorer: `https://basescan.org/tx/${tx}` } : {}),
618
744
  run_spent_usd: (0, x402_1.atomicToUsd)(signedAtomic),
619
745
  };
746
+ if (op === 'screenshot') {
747
+ const shot = (data.screenshot && typeof data.screenshot === 'object' ? data.screenshot : data);
748
+ const b64 = typeof shot.base64 === 'string' ? shot.base64 : '';
749
+ const { base64: _omit, ...shotMeta } = shot;
750
+ const json = { ...data, ...(data.screenshot ? { screenshot: shotMeta } : shotMeta), payment, portal: null };
751
+ if (!data.screenshot)
752
+ delete json.base64;
753
+ if (!b64)
754
+ return { json, signedAtomic };
755
+ const o = (this.getNodeParameter('screenshotOptions', i, {}) ?? {});
756
+ const prop = String(o.binaryProperty || 'data');
757
+ const rawFormat = String(shot.format || body.format || 'png').toLowerCase();
758
+ const format = rawFormat === 'jpg' || rawFormat === 'jpeg' ? 'jpeg' : 'png';
759
+ const mimeType = `image/${format}`;
760
+ const fileName = `screenshot.${format === 'jpeg' ? 'jpg' : format}`;
761
+ const buf = Buffer.from(b64, 'base64');
762
+ const bin = this.helpers.prepareBinaryData
763
+ ? await this.helpers.prepareBinaryData(buf, fileName, mimeType)
764
+ : { data: b64, mimeType, fileName, fileExtension: format === 'jpeg' ? 'jpg' : format };
765
+ return { json, binary: { [prop]: bin }, signedAtomic };
766
+ }
620
767
  return { json: { ...data, payment, portal: null }, signedAtomic };
621
768
  }
@@ -261,7 +261,7 @@ exports.MAX_PER_CALL_ATOMIC = 5000n;
261
261
  /** AgentSearch's own x402 API on Base (opt-in "Payment Route: Direct"). */
262
262
  exports.DIRECT_URL = 'https://api.agentsearchhq.com';
263
263
  exports.DIRECT_PAYEE = '0xC49B157887e51c21CB655f39CF65D6a4c2a4C337';
264
- /** $0.020 hard ceiling per direct call (extract $0.007, render $0.010, search_and_read $0.015). */
264
+ /** $0.020 hard ceiling per direct call (extract $0.004, render $0.010, search_and_read $0.009). */
265
265
  exports.DIRECT_MAX_PER_CALL_ATOMIC = 20000n;
266
266
  const eqAddr = (a, b) => typeof a === 'string' && a.toLowerCase() === b.toLowerCase();
267
267
  function atomicToUsd(a) {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "n8n-nodes-agentsearch",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "author": {
5
5
  "name": "AgentSearch",
6
6
  "email": "AgentSearchhq@gmail.com",
7
7
  "url": "https://agentsearchhq.com"
8
8
  },
9
- "description": "n8n community node for AgentSearch: free live web search for AI agents (no credentials), plus page Extract ($0.007) and JavaScript Render ($0.010) per call, paid in USDC on Base via x402 to AgentSearch's own API",
9
+ "description": "n8n community node for AgentSearch: free live web search for AI agents (no credentials), plus News Search ($0.008), page Extract ($0.004), JavaScript Render ($0.010), Screenshot ($0.010) and Search and Read ($0.009) per call, paid in USDC on Base via x402 to AgentSearch's own API",
10
10
  "keywords": [
11
11
  "n8n-community-node-package",
12
12
  "n8n",
@@ -16,7 +16,11 @@
16
16
  "ai-agent",
17
17
  "extract",
18
18
  "web-scraping",
19
- "x402"
19
+ "x402",
20
+ "news",
21
+ "news-search",
22
+ "screenshot",
23
+ "search-filters"
20
24
  ],
21
25
  "license": "MIT",
22
26
  "homepage": "https://agentsearchhq.com/?utm_source=n8n-nodes-agentsearch&utm_medium=package",