@fetchbrain.com/sdk 0.5.0 → 0.5.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,7 +1,7 @@
1
1
  /**
2
2
  * FetchBrain SDK Types
3
3
  *
4
- * Type definitions for the FetchBrain AI-powered scraping optimization SDK.
4
+ * Type definitions for the FetchBrain SDK — memory for your scrapers.
5
5
  */
6
6
  /** How far back the brain recalls: fresh=1h, recent=24h, standard=7d, deep=30d */
7
7
  type MemoryDepth = "fresh" | "recent" | "standard" | "deep";
@@ -13,11 +13,11 @@ interface FetchBrainConfig {
13
13
  baseUrl?: string;
14
14
  /** How far back the brain recalls: fresh=1h, recent=24h, standard=7d, deep=30d */
15
15
  memory?: MemoryDepth;
16
- /** Whether AI should learn from new pages */
16
+ /** Teach the brain from scraped data (default: true) */
17
17
  learning?: boolean;
18
18
  /**
19
- * Control which handlers run when AI knows the page.
20
- * - false: Auto-skip all handlers when AI knows (default)
19
+ * Control which handlers run when the brain knows the request.
20
+ * - false: Auto-skip all handlers when the request is known (default)
21
21
  * - true: Always run all handlers
22
22
  * - string[]: Only run handlers with these labels (e.g., ['listing', 'category'])
23
23
  * - 'default': Only run the default handler
@@ -48,8 +48,8 @@ interface FetchBrainConfig {
48
48
  * Crawlee's context-level `enqueueLinks()` and context `addRequests()` reach the queue
49
49
  * via other paths and are not pre-recalled (they still get handler-time recall) — in a
50
50
  * handler, enqueue follow-ups with `context.crawler.addRequests([...])` instead.
51
- * Note recall usage is metered at enqueue time, so requests the queue later dedups
52
- * still count as queries. The recall result is a snapshot as of enqueue: data learned
51
+ * Note known recalls are counted at enqueue time, so known requests the queue later
52
+ * dedups still count as recalls. The recall result is a snapshot as of enqueue: data learned
53
53
  * between enqueue and execution is not picked up (the request is simply scraped and
54
54
  * re-learned). If a request skipped its fetch but its remembered data expired before
55
55
  * execution (e.g. across a process restart), it fails once without retries and lands
@@ -64,11 +64,11 @@ interface FetchBrainConfig {
64
64
  * Called whenever recalled data is delivered in place of a live scrape — the handler
65
65
  * was auto-skipped and the remembered data pushed, or your handler called
66
66
  * `context.brain.use()`. Use it for per-record bookkeeping that normally lives in your
67
- * handler — e.g. platform billing events. Errors are swallowed: a hook failure never
67
+ * handler — e.g. metrics or counters. Errors are swallowed: a hook failure never
68
68
  * breaks the crawl.
69
69
  */
70
70
  onRecalled?: (event: RecalledEvent) => void | Promise<void>;
71
- /** Custom data extractor for learning */
71
+ /** Transform each pushed record before the brain learns it */
72
72
  extractForLearning?: (data: unknown) => Record<string, unknown>;
73
73
  /**
74
74
  * If true, scope both learn and recall to the current build version.
@@ -85,8 +85,8 @@ interface FetchBrainConfig {
85
85
  /** Enable debug logging */
86
86
  debug?: boolean;
87
87
  /**
88
- * Field name to use as URL for learning
89
- * Useful when request URL is an API endpoint but data contains the actual page URL
88
+ * Field name to use as URL for learning.
89
+ * Note: accepted and stored, but not currently applied by the SDK.
90
90
  */
91
91
  learnUrlField?: string;
92
92
  /**
@@ -98,9 +98,9 @@ interface FetchBrainConfig {
98
98
  */
99
99
  circuitBreaker?: Partial<CircuitBreakerConfig>;
100
100
  /**
101
- * Telemetry configuration - opt-in anonymous data sharing
102
- * Helps improve proxy recommendations, detect blocks, optimize configs
103
- * Default: disabled
101
+ * Telemetry configuration — opt-in, pseudonymous (sent with your API key).
102
+ * Helps improve proxy recommendations, detect blocks, optimize configs.
103
+ * Default: disabled. See the README "Telemetry (opt-in)" section for every field sent.
104
104
  */
105
105
  telemetry?: TelemetryConfig;
106
106
  }
@@ -165,13 +165,13 @@ interface StatsResponse {
165
165
  learned: number;
166
166
  period: string;
167
167
  }
168
- /** Result from AI knowledge recall */
168
+ /** Result of a recall */
169
169
  interface RecallResult {
170
170
  known: boolean;
171
171
  data?: Record<string, unknown>;
172
172
  fallback?: boolean;
173
173
  }
174
- /** Response from a natural-language ask against learned knowledge */
174
+ /** Response from a natural-language ask, answered from everything the account has learned */
175
175
  interface AskResponse {
176
176
  sources: {
177
177
  score: number;
@@ -218,21 +218,23 @@ interface Logger {
218
218
  error: (message: string, ...args: unknown[]) => void;
219
219
  }
220
220
  /**
221
- * Telemetry configuration - opt-in data sharing for AI improvements
221
+ * Telemetry configuration — opt-in, pseudonymous diagnostics sent with your API key.
222
+ * When enabled, each sub-flag defaults to true.
222
223
  */
223
224
  interface TelemetryConfig {
224
- /** Enable telemetry collection (default: false — opt in to join the access-intelligence network) */
225
+ /** Enable telemetry collection (default: false — opt-in) */
225
226
  enabled: boolean;
226
- /** Share performance metrics: response times, retries, status codes */
227
+ /** Share performance metrics: timings, retries, status codes, content size (default: true) */
227
228
  sharePerformance?: boolean;
228
- /** Share proxy info: country, type (never IP addresses) */
229
+ /** Share proxy info: country, locally-derived type, success (never proxy URL/IP) (default: true) */
229
230
  shareProxyInfo?: boolean;
230
- /** Share site patterns: block rates, rate limits detected */
231
+ /** Share block indicators derived from status codes and error categories (default: true) */
231
232
  shareSitePatterns?: boolean;
232
233
  }
233
234
  /**
234
- * Telemetry data collected from Crawlee context
235
- * All data is sanitized - no PII, no credentials, no raw content
235
+ * Telemetry data collected from Crawlee context.
236
+ * No raw URLs, bodies, proxy URLs/IPs or error messages. The hostname, generalized
237
+ * path and request label are sent as-is, linked to your API key.
236
238
  */
237
239
  interface TelemetryData {
238
240
  domain: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fetchbrain.com/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "FetchBrain SDK — make your Crawlee scrapers smarter with every run; recall before you fetch, teach what you learn.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -36,8 +36,6 @@
36
36
  "scraping",
37
37
  "web-scraping",
38
38
  "crawlee",
39
- "crawlee",
40
- "apify",
41
39
  "optimization",
42
40
  "ai",
43
41
  "fetchbrain"