mcp-scraper 0.4.5 → 0.4.12

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.
Files changed (52) hide show
  1. package/dist/bin/api-server.cjs +1866 -1376
  2. package/dist/bin/api-server.cjs.map +1 -1
  3. package/dist/bin/api-server.js +3 -3
  4. package/dist/bin/mcp-scraper-cli.cjs +1 -1
  5. package/dist/bin/mcp-scraper-cli.cjs.map +1 -1
  6. package/dist/bin/mcp-scraper-cli.js +1 -1
  7. package/dist/bin/mcp-scraper-install.cjs +1 -1
  8. package/dist/bin/mcp-scraper-install.cjs.map +1 -1
  9. package/dist/bin/mcp-scraper-install.js +1 -1
  10. package/dist/bin/mcp-stdio-server.cjs +89 -1
  11. package/dist/bin/mcp-stdio-server.cjs.map +1 -1
  12. package/dist/bin/mcp-stdio-server.js +2 -2
  13. package/dist/bin/paa-harvest.cjs +13 -4
  14. package/dist/bin/paa-harvest.cjs.map +1 -1
  15. package/dist/bin/paa-harvest.js +2 -2
  16. package/dist/{chunk-NJK5BTUK.js → chunk-2YY46QYT.js} +28 -11
  17. package/dist/chunk-2YY46QYT.js.map +1 -0
  18. package/dist/{chunk-WI4A3KFQ.js → chunk-6EXP6DQG.js} +90 -2
  19. package/dist/chunk-6EXP6DQG.js.map +1 -0
  20. package/dist/{chunk-5LO6EHEH.js → chunk-EMY7ELRU.js} +35 -7
  21. package/dist/chunk-EMY7ELRU.js.map +1 -0
  22. package/dist/{chunk-FUVQR6GK.js → chunk-GL4BW4CP.js} +49 -1
  23. package/dist/chunk-GL4BW4CP.js.map +1 -0
  24. package/dist/{chunk-3UH3BEIZ.js → chunk-HE2LQPJ2.js} +2 -2
  25. package/dist/{chunk-4ZZWFI6L.js → chunk-ONIOF5XW.js} +3 -3
  26. package/dist/chunk-SHXJQQOH.js +7 -0
  27. package/dist/chunk-SHXJQQOH.js.map +1 -0
  28. package/dist/{db-H3S3M6KK.js → db-LIOTIWVN.js} +6 -2
  29. package/dist/{extract-bundle-UKE273TV.js → extract-bundle-COS56ZDO.js} +2 -2
  30. package/dist/index.cjs +59 -4
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.js +9 -3
  33. package/dist/index.js.map +1 -1
  34. package/dist/{server-XCDFHHLE.js → server-UNID3SJU.js} +570 -276
  35. package/dist/server-UNID3SJU.js.map +1 -0
  36. package/dist/{site-extract-repository-THBVEXMP.js → site-extract-repository-HTIY52MW.js} +4 -4
  37. package/dist/{worker-YHKUJR5P.js → worker-HTYZAYGB.js} +18 -14
  38. package/dist/worker-HTYZAYGB.js.map +1 -0
  39. package/package.json +2 -2
  40. package/dist/chunk-5LO6EHEH.js.map +0 -1
  41. package/dist/chunk-FUVQR6GK.js.map +0 -1
  42. package/dist/chunk-NJK5BTUK.js.map +0 -1
  43. package/dist/chunk-UGQC2FOX.js +0 -7
  44. package/dist/chunk-UGQC2FOX.js.map +0 -1
  45. package/dist/chunk-WI4A3KFQ.js.map +0 -1
  46. package/dist/server-XCDFHHLE.js.map +0 -1
  47. package/dist/worker-YHKUJR5P.js.map +0 -1
  48. /package/dist/{chunk-3UH3BEIZ.js.map → chunk-HE2LQPJ2.js.map} +0 -0
  49. /package/dist/{chunk-4ZZWFI6L.js.map → chunk-ONIOF5XW.js.map} +0 -0
  50. /package/dist/{db-H3S3M6KK.js.map → db-LIOTIWVN.js.map} +0 -0
  51. /package/dist/{extract-bundle-UKE273TV.js.map → extract-bundle-COS56ZDO.js.map} +0 -0
  52. /package/dist/{site-extract-repository-THBVEXMP.js.map → site-extract-repository-HTIY52MW.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -315,11 +315,25 @@ function currentCostContext() {
315
315
  // src/api/cost-rates.ts
316
316
  var KERNEL_HEADLESS_USD_PER_SEC = 166667e-10;
317
317
  var KERNEL_HEADFUL_USD_PER_SEC = 1333336e-10;
318
- var HEADLESS_OPS = /* @__PURE__ */ new Set(["harvest", "maps_search", "yt_channel", "fb_search", "fb_ad", "instagram"]);
318
+ var HEADLESS_OPS = /* @__PURE__ */ new Set(["serp", "maps_search", "yt_channel", "yt_transcription", "fb_search", "fb_ad", "instagram"]);
319
+ var FAL_WIZPER_USD_PER_COMPUTE_SEC = 111e-5;
320
+ var FAL_WIZPER_WALLCLOCK_TO_COMPUTE_SEC_FACTOR = 4;
321
+ var DEEPINFRA_QWEN_USD_PER_1K_OUT_TOKENS = 4e-4;
319
322
  function kernelCostUsd(ms, headful) {
320
323
  const sec = Math.max(0, ms) / 1e3;
321
324
  return sec * (headful ? KERNEL_HEADFUL_USD_PER_SEC : KERNEL_HEADLESS_USD_PER_SEC);
322
325
  }
326
+ function vendorCostUsd(vendor, units) {
327
+ if (vendor === "fal_wizper") {
328
+ const estimatedComputeSec = Math.max(0, units) / FAL_WIZPER_WALLCLOCK_TO_COMPUTE_SEC_FACTOR;
329
+ return estimatedComputeSec * FAL_WIZPER_USD_PER_COMPUTE_SEC;
330
+ }
331
+ if (vendor === "deepinfra_qwen") return Math.max(0, units) / 1e3 * DEEPINFRA_QWEN_USD_PER_1K_OUT_TOKENS;
332
+ if (vendor === "openrouter") return Math.max(0, units);
333
+ if (vendor === "mcp_memory_video") return Math.max(0, units);
334
+ if (vendor === "mcp_memory_ai") return Math.max(0, units);
335
+ return 0;
336
+ }
323
337
 
324
338
  // src/api/cost-telemetry.ts
325
339
  var _ready = false;
@@ -358,6 +372,10 @@ async function migrateCostTelemetry() {
358
372
  await db.execute(`ALTER TABLE kernel_session_log ADD COLUMN proxy_type TEXT`);
359
373
  } catch {
360
374
  }
375
+ try {
376
+ await db.execute(`ALTER TABLE kernel_session_log ADD COLUMN method TEXT`);
377
+ } catch {
378
+ }
361
379
  await db.execute(`
362
380
  CREATE TABLE IF NOT EXISTS vendor_usage_log (
363
381
  id TEXT PRIMARY KEY,
@@ -376,6 +394,10 @@ async function migrateCostTelemetry() {
376
394
  await db.execute(`CREATE INDEX IF NOT EXISTS vendor_usage_log_op ON vendor_usage_log(op)`);
377
395
  await db.execute(`CREATE INDEX IF NOT EXISTS vendor_usage_log_probe ON vendor_usage_log(probe_run_id)`);
378
396
  await db.execute(`CREATE INDEX IF NOT EXISTS vendor_usage_log_created ON vendor_usage_log(created_at)`);
397
+ try {
398
+ await db.execute(`ALTER TABLE vendor_usage_log ADD COLUMN method TEXT`);
399
+ } catch {
400
+ }
379
401
  await db.execute(`
380
402
  CREATE TABLE IF NOT EXISTS cost_probe_runs (
381
403
  id TEXT PRIMARY KEY,
@@ -422,8 +444,8 @@ async function recordKernelSession(r) {
422
444
  const db = getDb();
423
445
  await db.execute({
424
446
  sql: `INSERT INTO kernel_session_log
425
- (id, kernel_session_id, op, source, probe_run_id, user_id, stealth, headless_sent, proxy_used, proxy_source, proxy_type, fallback, opened_at, closed_at, duration_ms, est_cost_usd_headless, est_cost_usd_headful, error)
426
- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
447
+ (id, kernel_session_id, op, source, probe_run_id, user_id, stealth, headless_sent, proxy_used, proxy_source, proxy_type, fallback, opened_at, closed_at, duration_ms, est_cost_usd_headless, est_cost_usd_headful, error, method)
448
+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`,
427
449
  args: [
428
450
  (0, import_node_crypto2.randomUUID)(),
429
451
  r.kernelSessionId ?? null,
@@ -442,13 +464,41 @@ async function recordKernelSession(r) {
442
464
  durationMs,
443
465
  kernelCostUsd(durationMs, false),
444
466
  kernelCostUsd(durationMs, true),
445
- r.error ?? null
467
+ r.error ?? null,
468
+ ctx?.subOp ?? null
446
469
  ]
447
470
  });
448
471
  } catch (err) {
449
472
  console.warn("[cost-telemetry] recordKernelSession failed:", err instanceof Error ? err.message : String(err));
450
473
  }
451
474
  }
475
+ async function recordVendorUsage(r) {
476
+ try {
477
+ await migrateCostTelemetry();
478
+ const ctx = currentCostContext();
479
+ const db = getDb();
480
+ await db.execute({
481
+ sql: `INSERT INTO vendor_usage_log
482
+ (id, op, probe_run_id, user_id, vendor, model, units, unit_type, est_cost_usd, error, method)
483
+ VALUES (?,?,?,?,?,?,?,?,?,?,?)`,
484
+ args: [
485
+ (0, import_node_crypto2.randomUUID)(),
486
+ ctx?.op ?? null,
487
+ ctx?.probeRunId ?? null,
488
+ ctx?.userId ?? null,
489
+ r.vendor,
490
+ r.model ?? null,
491
+ r.units,
492
+ r.unitType,
493
+ vendorCostUsd(r.vendor, r.units),
494
+ r.error ?? null,
495
+ ctx?.subOp ?? null
496
+ ]
497
+ });
498
+ } catch (err) {
499
+ console.warn("[cost-telemetry] recordVendorUsage failed:", err instanceof Error ? err.message : String(err));
500
+ }
501
+ }
452
502
  function boolToInt(v) {
453
503
  if (v === null || v === void 0) return null;
454
504
  return v ? 1 : 0;
@@ -3457,6 +3507,11 @@ Answer: ${answer.slice(0, 500)}` }
3457
3507
  });
3458
3508
  if (!res.ok) throw new Error(`LLM call failed (${res.status}): ${await res.text()}`);
3459
3509
  const data = await res.json();
3510
+ if (baseUrl === OPENROUTER_URL) {
3511
+ void recordVendorUsage({ vendor: "openrouter", model: QWEN_MODEL, units: data.usage?.cost ?? 0, unitType: "usd" });
3512
+ } else {
3513
+ void recordVendorUsage({ vendor: "deepinfra_qwen", model: QWEN_MODEL, units: data.usage?.completion_tokens ?? 0, unitType: "tokens" });
3514
+ }
3460
3515
  const raw = data.choices[0]?.message?.content?.trim() ?? "";
3461
3516
  const match = raw.match(/\{[\s\S]*\}/);
3462
3517
  if (!match) throw new Error(`No JSON in QWEN response: ${raw.slice(0, 200)}`);