n8n-nodes-agentsearch 0.7.0 → 0.7.1

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ exports.DIRECT_OPS = exports.AgentSearch = exports.WALLET_SETUP = exports.PORTAL_SERVICES = exports.QUERY_TOO_SHORT_MESSAGE = exports.MIN_QUERY_CHARS = 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
6
  exports.filtersBody = filtersBody;
@@ -13,6 +13,8 @@ exports.CLIENT_TAG = 'n8n-nodes-agentsearch/0.7.0';
13
13
  const DOCS = 'https://agentsearchhq.com/?utm_source=n8n-nodes-agentsearch&utm_medium=package';
14
14
  const GUIDE = 'https://agentsearchhq.com/blog/n8n-ai-agent-read-web-pages?utm_source=n8n-nodes-agentsearch&utm_medium=package';
15
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}`;
16
+ exports.MIN_QUERY_CHARS = 2;
17
+ exports.QUERY_TOO_SHORT_MESSAGE = 'Query must be at least 2 characters. Nothing was sent or charged.';
16
18
  exports.PORTAL_SERVICES = {
17
19
  extract: { serviceId: 'agentsearch-web-extract-v1', path: '/v1/extract' },
18
20
  render: { serviceId: 'agentsearch-web-render-v1', path: '/v1/render' },
@@ -377,6 +379,8 @@ class AgentSearch {
377
379
  const query = this.getNodeParameter('query', i).trim();
378
380
  if (!query)
379
381
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Query is empty', { itemIndex: i });
382
+ if (query.length < exports.MIN_QUERY_CHARS)
383
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), exports.QUERY_TOO_SHORT_MESSAGE, { itemIndex: i });
380
384
  const maxResults = this.getNodeParameter('maxResults', i, 5);
381
385
  const split = this.getNodeParameter('split', i, false);
382
386
  let res;
@@ -395,6 +399,10 @@ class AgentSearch {
395
399
  const status = err?.httpCode ?? err?.response?.status ?? err?.statusCode;
396
400
  if (String(status) === '429')
397
401
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), exports.LIMIT_MESSAGE, { itemIndex: i });
402
+ const code = Number(status);
403
+ if (code >= 400 && code < 500 && code !== 408) {
404
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `AgentSearch rejected the request (HTTP ${code}). Fix the input before retrying; retrying the same request will fail again.`, { itemIndex: i });
405
+ }
398
406
  throw new n8n_workflow_1.NodeApiError(this.getNode(), e, { itemIndex: i });
399
407
  }
400
408
  if (res && typeof res === 'object')
@@ -622,6 +630,8 @@ async function directPaid(op, i, signedBefore) {
622
630
  const query = String(this.getNodeParameter('query', i) ?? '').trim();
623
631
  if (!query)
624
632
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Query is empty', { itemIndex: i });
633
+ if (query.length < exports.MIN_QUERY_CHARS)
634
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), exports.QUERY_TOO_SHORT_MESSAGE, { itemIndex: i });
625
635
  body = { query };
626
636
  if (op === 'news') {
627
637
  const n = this.getNodeParameter('newsMaxResults', i, 5);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-agentsearch",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "author": {
5
5
  "name": "AgentSearch",
6
6
  "email": "AgentSearchhq@gmail.com",