mcp-scraper 0.28.0 → 0.28.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.
@@ -7,7 +7,7 @@ import {
7
7
  registerMemoryMcpTools,
8
8
  registerPaaExtractorMcpTools,
9
9
  registerSerpIntelligenceCaptureTools
10
- } from "../chunk-LTT7QX3C.js";
10
+ } from "../chunk-Q7VZUYRR.js";
11
11
  import "../chunk-R7EETU7Z.js";
12
12
  import "../chunk-MTSBI7ZH.js";
13
13
  import {
@@ -16,7 +16,7 @@ import {
16
16
  import "../chunk-ZQSHKWV4.js";
17
17
  import {
18
18
  PACKAGE_VERSION
19
- } from "../chunk-QG77M3YJ.js";
19
+ } from "../chunk-GOAQIV6K.js";
20
20
  import "../chunk-4767BA2O.js";
21
21
  import "../chunk-M2S27J6Z.js";
22
22
  import "../chunk-ICT7DDHL.js";
@@ -0,0 +1,7 @@
1
+ // src/version.ts
2
+ var PACKAGE_VERSION = "0.28.2";
3
+
4
+ export {
5
+ PACKAGE_VERSION
6
+ };
7
+ //# sourceMappingURL=chunk-GOAQIV6K.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/version.ts"],"sourcesContent":["export const PACKAGE_VERSION = '0.28.2'\n"],"mappings":";AAAO,IAAM,kBAAkB;","names":[]}
@@ -19,7 +19,7 @@ import {
19
19
  } from "./chunk-ZQSHKWV4.js";
20
20
  import {
21
21
  PACKAGE_VERSION
22
- } from "./chunk-QG77M3YJ.js";
22
+ } from "./chunk-GOAQIV6K.js";
23
23
  import {
24
24
  MC_PER_CREDIT
25
25
  } from "./chunk-4767BA2O.js";
@@ -10069,4 +10069,4 @@ export {
10069
10069
  MEMORY_TOOL_SCHEMAS,
10070
10070
  registerMemoryMcpTools
10071
10071
  };
10072
- //# sourceMappingURL=chunk-LTT7QX3C.js.map
10072
+ //# sourceMappingURL=chunk-Q7VZUYRR.js.map
@@ -36,7 +36,7 @@ import {
36
36
  sanitizeAttempts,
37
37
  sanitizeHarvestResult,
38
38
  transcribeMediaUrl
39
- } from "./chunk-LTT7QX3C.js";
39
+ } from "./chunk-Q7VZUYRR.js";
40
40
  import {
41
41
  auditImages,
42
42
  buildLinkReport,
@@ -77,7 +77,7 @@ import {
77
77
  RawMapsOverviewSchema,
78
78
  RawMapsReviewStatsSchema
79
79
  } from "./chunk-ZQSHKWV4.js";
80
- import "./chunk-QG77M3YJ.js";
80
+ import "./chunk-GOAQIV6K.js";
81
81
  import {
82
82
  completeExtractJob,
83
83
  countSuccessfulPages,
@@ -20699,6 +20699,9 @@ loadChannels();
20699
20699
  // src/api/vault-routes.ts
20700
20700
  import { Hono as Hono22 } from "hono";
20701
20701
  var VAULTS = ["People", "Projects", "Tasks", "Communications"];
20702
+ var MAX_VAULT_RECORDS = 200;
20703
+ var MAX_MEMORY_READ_CONCURRENCY = 4;
20704
+ var MAX_MEMORY_READ_ATTEMPTS = 3;
20702
20705
  var vaultApp = new Hono22();
20703
20706
  function validToken(token) {
20704
20707
  return !!token && token.startsWith("mk_") && token.length > 20 && token.length < 256;
@@ -20719,7 +20722,7 @@ function propsValue(value) {
20719
20722
  }
20720
20723
  function cors(c) {
20721
20724
  const origin = c.req.header("origin");
20722
- const configured = (process.env.VAULT_APP_ALLOWED_ORIGINS ?? "https://vault.mcpscraper.dev").split(",").map((value) => value.trim()).filter(Boolean);
20725
+ const configured = (process.env.VAULT_APP_ALLOWED_ORIGINS ?? "https://mcpscraper.dev").split(",").map((value) => value.trim()).filter(Boolean);
20723
20726
  const local = !!origin && /^http:\/\/localhost(?::\d+)?$/.test(origin);
20724
20727
  if (origin && (configured.includes(origin) || local)) c.header("Access-Control-Allow-Origin", origin);
20725
20728
  c.header("Vary", "Origin");
@@ -20748,24 +20751,55 @@ function workspaceRecord(vault, note) {
20748
20751
  };
20749
20752
  }
20750
20753
  function defaultType(vault) {
20751
- if (vault === "People") return "person";
20754
+ if (vault === "People" || vault === "Communications") return "unclassified";
20752
20755
  if (vault === "Projects") return "project";
20753
20756
  if (vault === "Tasks") return "task";
20754
- return "activity";
20757
+ return "unclassified";
20755
20758
  }
20756
20759
  function defaultStatus(vault) {
20757
20760
  if (vault === "People") return "active";
20758
20761
  if (vault === "Projects") return "active";
20759
20762
  if (vault === "Tasks") return "to_do";
20760
- return "triaged";
20763
+ return "inbox";
20764
+ }
20765
+ function shouldRetryMemoryRead(error) {
20766
+ return /deadlock|timeout|timed out|temporar|econnreset|fetch failed/i.test(error ?? "");
20767
+ }
20768
+ function sleep(ms) {
20769
+ return new Promise((resolve) => setTimeout(resolve, ms));
20770
+ }
20771
+ async function readMemory(tool, args, token) {
20772
+ let result = await memoryCall(tool, args, token);
20773
+ for (let attempt = 1; !result.ok && attempt < MAX_MEMORY_READ_ATTEMPTS && shouldRetryMemoryRead(result.error); attempt += 1) {
20774
+ await sleep(attempt * 150);
20775
+ result = await memoryCall(tool, args, token);
20776
+ }
20777
+ return result;
20778
+ }
20779
+ async function mapWithConcurrency(items, limit, map) {
20780
+ const values = new Array(items.length);
20781
+ let cursor = 0;
20782
+ const worker = async () => {
20783
+ while (cursor < items.length) {
20784
+ const index = cursor;
20785
+ cursor += 1;
20786
+ values[index] = await map(items[index]);
20787
+ }
20788
+ };
20789
+ await Promise.all(Array.from({ length: Math.min(limit, items.length) }, () => worker()));
20790
+ return values;
20761
20791
  }
20762
20792
  async function readVault(vault, token) {
20763
- const list = await memoryCall("listTool", { vault }, token);
20793
+ const list = await readMemory("listTool", { vault }, token);
20764
20794
  if (!list.ok) throw new Error(list.error ?? `unable to read ${vault}`);
20765
- const noteRefs = (list.notes ?? []).slice(0, 200);
20766
- const notes = await Promise.all(
20767
- noteRefs.map(async ({ path: path5 }) => memoryCall("getTool", { vault, path: path5 }, token))
20795
+ const noteRefs = (list.notes ?? []).slice(0, MAX_VAULT_RECORDS);
20796
+ const notes = await mapWithConcurrency(
20797
+ noteRefs,
20798
+ MAX_MEMORY_READ_CONCURRENCY,
20799
+ ({ path: path5 }) => readMemory("getTool", { vault, path: path5 }, token)
20768
20800
  );
20801
+ const failed = notes.find((result) => !result.ok);
20802
+ if (failed && !failed.ok) throw new Error(failed.error ?? `unable to read ${vault} record`);
20769
20803
  return notes.filter((result) => result.ok && !!result.note).map((result) => workspaceRecord(vault, result.note));
20770
20804
  }
20771
20805
  vaultApp.get("/api/workspace", async (c) => {
@@ -20774,7 +20808,8 @@ vaultApp.get("/api/workspace", async (c) => {
20774
20808
  try {
20775
20809
  const requested = c.req.query("vault");
20776
20810
  const vaults = isVault(requested) ? [requested] : VAULTS;
20777
- const results = await Promise.all(vaults.map((vault) => readVault(vault, token)));
20811
+ const results = [];
20812
+ for (const vault of vaults) results.push(await readVault(vault, token));
20778
20813
  const records = results.flat().sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
20779
20814
  return c.json({ ok: true, records, limited: results.some((result) => result.length >= 200) });
20780
20815
  } catch (error) {
@@ -20804,7 +20839,7 @@ vaultApp.post("/api/records/transition", async (c) => {
20804
20839
  const status = stringValue(body.status, 80);
20805
20840
  const baseRevision = typeof body.baseRevision === "number" && Number.isInteger(body.baseRevision) ? body.baseRevision : void 0;
20806
20841
  if (!isVault(vault) || !path5 || !status) return c.json({ ok: false, error: "valid vault, path, and status are required" }, 400);
20807
- const current = await memoryCall("getTool", { vault, path: path5 }, token);
20842
+ const current = await readMemory("getTool", { vault, path: path5 }, token);
20808
20843
  if (!current.ok || !current.note) return c.json(current, current.ok ? 404 : 502);
20809
20844
  const result = await memoryCall("putTool", {
20810
20845
  vault,
@@ -20816,6 +20851,67 @@ vaultApp.post("/api/records/transition", async (c) => {
20816
20851
  }, token);
20817
20852
  return c.json(result, result.ok ? 200 : result.conflict ? 409 : 502);
20818
20853
  });
20854
+ vaultApp.post("/api/records/update", async (c) => {
20855
+ const body = await c.req.json().catch(() => ({}));
20856
+ const token = typeof body.token === "string" ? body.token : void 0;
20857
+ if (!validToken(token)) return c.json({ ok: false, error: "missing or malformed Vault App link" }, 401);
20858
+ const vault = body.vault;
20859
+ const path5 = stringValue(body.path, 320);
20860
+ const title = typeof body.title === "string" ? stringValue(body.title, 320) : void 0;
20861
+ const content = typeof body.content === "string" && body.content.length <= 1e5 ? body.content : void 0;
20862
+ const props = body.props === void 0 ? void 0 : propsValue(body.props);
20863
+ const baseRevision = typeof body.baseRevision === "number" && Number.isInteger(body.baseRevision) ? body.baseRevision : void 0;
20864
+ if (!isVault(vault) || !path5 || body.title !== void 0 && !title || body.props !== void 0 && !props) {
20865
+ return c.json({ ok: false, error: "valid vault, path, and optional record fields are required" }, 400);
20866
+ }
20867
+ const current = await readMemory("getTool", { vault, path: path5 }, token);
20868
+ if (!current.ok || !current.note) return c.json(current, current.ok ? 404 : 502);
20869
+ const result = await memoryCall("putTool", {
20870
+ vault,
20871
+ path: path5,
20872
+ title: title ?? current.note.title,
20873
+ content: content ?? current.note.content,
20874
+ props: { ...current.note.props ?? {}, ...props ?? {} },
20875
+ baseRevision: baseRevision ?? current.note.revision
20876
+ }, token);
20877
+ return c.json(result, result.ok ? 200 : result.conflict ? 409 : 502);
20878
+ });
20879
+ vaultApp.post("/api/communications/review", async (c) => {
20880
+ const body = await c.req.json().catch(() => ({}));
20881
+ const token = typeof body.token === "string" ? body.token : void 0;
20882
+ if (!validToken(token)) return c.json({ ok: false, error: "missing or malformed Vault App link" }, 401);
20883
+ const path5 = stringValue(body.path, 320);
20884
+ const action = stringValue(body.action, 24);
20885
+ const title = typeof body.title === "string" ? stringValue(body.title, 320) : void 0;
20886
+ const content = typeof body.content === "string" && body.content.length <= 1e5 ? body.content : void 0;
20887
+ const feedback = typeof body.feedback === "string" ? body.feedback.trim().slice(0, 1e4) : void 0;
20888
+ const baseRevision = typeof body.baseRevision === "number" && Number.isInteger(body.baseRevision) ? body.baseRevision : void 0;
20889
+ if (!path5 || !action || !["accept", "deny", "edit"].includes(action) || body.title !== void 0 && !title) {
20890
+ return c.json({ ok: false, error: "valid path, action, and optional draft fields are required" }, 400);
20891
+ }
20892
+ const current = await readMemory("getTool", { vault: "Communications", path: path5 }, token);
20893
+ if (!current.ok || !current.note) return c.json(current, current.ok ? 404 : 502);
20894
+ if (current.note.props?.type !== "email") return c.json({ ok: false, error: "only email communications can be reviewed" }, 400);
20895
+ const reviewed = action === "accept" || action === "deny";
20896
+ const reviewState = action === "accept" ? "accepted" : action === "deny" ? "denied" : "pending";
20897
+ const status = action === "accept" ? "triaged" : action === "deny" ? "archived" : typeof current.note.props?.status === "string" ? current.note.props.status : "inbox";
20898
+ const props = {
20899
+ ...current.note.props ?? {},
20900
+ status,
20901
+ review_state: reviewState,
20902
+ ...reviewed ? { reviewed_at: (/* @__PURE__ */ new Date()).toISOString() } : {},
20903
+ ...feedback ? { review_feedback: feedback } : {}
20904
+ };
20905
+ const result = await memoryCall("putTool", {
20906
+ vault: "Communications",
20907
+ path: path5,
20908
+ title: title ?? current.note.title,
20909
+ content: content ?? current.note.content,
20910
+ props,
20911
+ baseRevision: baseRevision ?? current.note.revision
20912
+ }, token);
20913
+ return c.json(result, result.ok ? 200 : result.conflict ? 409 : 502);
20914
+ });
20819
20915
  vaultApp.post("/api/activity", async (c) => {
20820
20916
  const body = await c.req.json().catch(() => ({}));
20821
20917
  const token = typeof body.token === "string" ? body.token : void 0;
@@ -20834,12 +20930,6 @@ vaultApp.post("/api/activity", async (c) => {
20834
20930
  }, token);
20835
20931
  return c.json(result, result.ok ? 200 : 502);
20836
20932
  });
20837
- vaultApp.get("/:token", (c) => {
20838
- const token = c.req.param("token");
20839
- if (!validToken(token)) return c.html('<!doctype html><html><body style="font-family:system-ui;padding:40px"><h2>This Vault App link is not valid.</h2><p>Ask the AI to run get-vault-app-link again, or revoke-vault-app-link and issue a replacement.</p></body></html>', 401);
20840
- const base = (process.env.VAULT_APP_BASE_URL ?? "https://vault.mcpscraper.dev").replace(/\/$/, "");
20841
- return c.redirect(`${base}/vault/${encodeURIComponent(token)}`, 302);
20842
- });
20843
20933
 
20844
20934
  // src/api/schedule-routes.ts
20845
20935
  import { Hono as Hono23 } from "hono";
@@ -27362,4 +27452,4 @@ app.get("/blog/:slug/", (c) => {
27362
27452
  export {
27363
27453
  app
27364
27454
  };
27365
- //# sourceMappingURL=server-QQB4BNAB.js.map
27455
+ //# sourceMappingURL=server-TB3USFGN.js.map