mcp-scraper 0.86.5 → 0.88.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.
@@ -43,7 +43,7 @@ import {
43
43
  setExtractJobTotal,
44
44
  settleExtractJob,
45
45
  terminalExtractJobStatus
46
- } from "./chunk-KQWVJOVR.js";
46
+ } from "./chunk-IHXAXYIS.js";
47
47
  import {
48
48
  REQUIRED_LOCATION_STATE_CODES,
49
49
  importHostedCensusPlacesCsv,
@@ -105,7 +105,7 @@ import {
105
105
  probeNangoConnectionDirect,
106
106
  recordNangoConnectionCost,
107
107
  settleConnectedUsage
108
- } from "./chunk-WFGAR4BZ.js";
108
+ } from "./chunk-MZDNZQWT.js";
109
109
  import {
110
110
  ANALYTICS_ATTRIBUTION_MODELS,
111
111
  ANALYTICS_CONTENT_SORTS,
@@ -240,7 +240,7 @@ import {
240
240
  serpArrivalUrl,
241
241
  validateProviderSessionId,
242
242
  withRuntimeUserAgent
243
- } from "./chunk-NH4QAH3X.js";
243
+ } from "./chunk-S24LFPL7.js";
244
244
  import {
245
245
  ANALYTICS_REST_GENERIC_EXEMPTIONS,
246
246
  ASSISTANT_COMMAND_SCHEMA_VERSION,
@@ -388,7 +388,7 @@ import {
388
388
  transcribeMediaUrl,
389
389
  transitionAnalyticsExperiment,
390
390
  validateAnalyticsRestResponseForRequest
391
- } from "./chunk-QJJQ4OAZ.js";
391
+ } from "./chunk-2JVZQGSN.js";
392
392
  import {
393
393
  auditImageUrls,
394
394
  auditImages,
@@ -459,7 +459,7 @@ import {
459
459
  tierChangeLeavesPrivateOffer,
460
460
  tierCreditsPerInterval,
461
461
  vendorCostUsdToMc
462
- } from "./chunk-NKRO2SUO.js";
462
+ } from "./chunk-4QMUF6XM.js";
463
463
  import {
464
464
  browserServiceApiKey,
465
465
  browserServiceProfileName,
@@ -483,7 +483,7 @@ import {
483
483
  workflowOutputBaseDir,
484
484
  workflowStepCount,
485
485
  workflowSupportsSteps
486
- } from "./chunk-6IOGTFNS.js";
486
+ } from "./chunk-UZPTGUDV.js";
487
487
  import {
488
488
  csvRecords,
489
489
  parseCsv,
@@ -498,7 +498,7 @@ import {
498
498
  RawMapsHoursRowSchema,
499
499
  RawMapsOverviewSchema,
500
500
  RawMapsReviewStatsSchema
501
- } from "./chunk-OWF2JJKN.js";
501
+ } from "./chunk-GXBZXWXB.js";
502
502
  import {
503
503
  extractContactEvidence
504
504
  } from "./chunk-P7FWOMU7.js";
@@ -509,7 +509,7 @@ import {
509
509
  } from "./chunk-GGZEC22A.js";
510
510
  import {
511
511
  PACKAGE_VERSION
512
- } from "./chunk-BA6BPDSP.js";
512
+ } from "./chunk-XIJI34RM.js";
513
513
  import {
514
514
  CaptchaError,
515
515
  MapsSearchIncompletePageError,
@@ -557,7 +557,6 @@ import {
557
557
  getInboxMessage,
558
558
  getJob,
559
559
  getLedger,
560
- getMemoryPlan,
561
560
  getMemoryProvisioned,
562
561
  getOrCreateRunningJob,
563
562
  getPageSnapshot,
@@ -566,7 +565,6 @@ import {
566
565
  getUserByEmail,
567
566
  getUserById,
568
567
  getUserByStripeCustomerId,
569
- getUserMemoryCreds,
570
568
  getUserStats,
571
569
  getWorkflowArtifact,
572
570
  getWorkflowRun,
@@ -615,7 +613,6 @@ import {
615
613
  setPassword,
616
614
  setStripeCustomerId,
617
615
  setSubscriptionTier,
618
- setUserMemoryCreds,
619
616
  settleDebitMcIdempotent,
620
617
  softDeleteInboxMessage,
621
618
  updateHarvestAttemptProviderTelemetry,
@@ -3972,7 +3969,7 @@ async function generateOgImage(post) {
3972
3969
 
3973
3970
  // src/api/server.ts
3974
3971
  import { Resend as Resend3 } from "resend";
3975
- import { createHash as createHash104, randomUUID as randomUUID69 } from "crypto";
3972
+ import { createHash as createHash105, randomUUID as randomUUID69 } from "crypto";
3976
3973
 
3977
3974
  // src/api/kpo-extractor.ts
3978
3975
  import TurndownService from "turndown";
@@ -9764,7 +9761,7 @@ var siteExtractFn = inngest.createFunction(
9764
9761
  });
9765
9762
  }) : null;
9766
9763
  const finalized = await step.run("finalize", async () => {
9767
- const { assembleExtractArtifacts } = await import("./extract-bundle-FALNLKYY.js");
9764
+ const { assembleExtractArtifacts } = await import("./extract-bundle-565SBZCR.js");
9768
9765
  const current = await getExtractJob(jobId2);
9769
9766
  if (!current) throw new Error("extract job disappeared before finalization");
9770
9767
  const stored = await assembleExtractArtifacts(current, { branding, imageAudit });
@@ -15864,10 +15861,41 @@ async function voidScheduledRunAuthorization(args) {
15864
15861
 
15865
15862
  // src/api/memory.ts
15866
15863
  import { createCipheriv, createDecipheriv, randomBytes, scryptSync } from "crypto";
15867
- import { provisionDefaultsTool } from "mcpscraper-memory-tools/tools/vaults/provision-defaults";
15868
15864
  import { setScheduleEntitlementTool } from "mcpscraper-memory-tools/tools/schedule/set-schedule-entitlement";
15865
+
15866
+ // src/api/oauth-signing.ts
15867
+ import { createHash as createHash5, randomUUID as randomUUID5 } from "crypto";
15868
+ import { exportJWK, importPKCS8, SignJWT } from "jose";
15869
+ var OAUTH_ISSUER = "https://mcpscraper.dev";
15870
+ var cachedKeys = null;
15871
+ async function getKeys() {
15872
+ if (cachedKeys) return cachedKeys;
15873
+ const raw = process.env.OAUTH_SIGNING_KEY;
15874
+ if (!raw?.trim()) throw new Error("OAUTH_SIGNING_KEY is not set");
15875
+ const pem = raw.includes("BEGIN") ? raw : Buffer.from(raw, "base64").toString("utf8");
15876
+ const privateKey = await importPKCS8(pem, "RS256", { extractable: true });
15877
+ const full = await exportJWK(privateKey);
15878
+ const publicJwk = { kty: full.kty, n: full.n, e: full.e };
15879
+ const kid = createHash5("sha256").update(JSON.stringify({ e: publicJwk.e, kty: publicJwk.kty, n: publicJwk.n })).digest("base64url").slice(0, 16);
15880
+ publicJwk.kid = kid;
15881
+ publicJwk.alg = "RS256";
15882
+ publicJwk.use = "sig";
15883
+ cachedKeys = { privateKey, publicJwk, kid };
15884
+ return cachedKeys;
15885
+ }
15886
+ async function getOAuthPublicJwk() {
15887
+ return (await getKeys()).publicJwk;
15888
+ }
15889
+ async function mintOAuthAccessToken(args) {
15890
+ const { privateKey, kid } = await getKeys();
15891
+ return new SignJWT({ scope: args.scope, plan: args.plan }).setProtectedHeader({ alg: "RS256", kid }).setIssuer(OAUTH_ISSUER).setSubject(args.identity).setAudience(args.audience).setIssuedAt().setJti(randomUUID5()).setExpirationTime(`${args.ttlSeconds}s`).sign(privateKey);
15892
+ }
15893
+
15894
+ // src/api/memory.ts
15869
15895
  var MEMORY_BASE_URL = () => (process.env.MCP_MEMORY_BASE_URL ?? "https://memory.mcpscraper.dev").replace(/\/$/, "");
15896
+ var MEMORY_RESOURCE_URL = () => (process.env.MCP_MEMORY_RESOURCE_URL ?? "https://memory.mcpscraper.dev/mcp").replace(/\/$/, "");
15870
15897
  var ADMIN_KEY = () => process.env.MCP_MEMORY_ADMIN_KEY?.trim() ?? "";
15898
+ var MEMORY_SERVICE_TOKEN_TTL_SECONDS = 300;
15871
15899
  function parseMemoryRpcBody(text3) {
15872
15900
  const dataLine = text3.split("\n").find((line) => line.startsWith("data:"));
15873
15901
  const payload = dataLine ? dataLine.slice(5).trim() : text3;
@@ -15945,8 +15973,10 @@ function memoryPlanForReads(user) {
15945
15973
  }
15946
15974
  async function provisionMemoryForUser(user) {
15947
15975
  try {
15948
- const { key: key3 } = await getOrCreateUserMemoryKey(user);
15949
- if (key3) await setMemoryProvisioned(user.id, true);
15976
+ const { key: key3 } = await getMemoryServiceToken(user);
15977
+ if (!key3) return;
15978
+ const result3 = await memoryCall("listVaultsTool", {}, key3);
15979
+ if (result3.ok) await setMemoryProvisioned(user.id, true);
15950
15980
  } catch {
15951
15981
  }
15952
15982
  }
@@ -15959,40 +15989,32 @@ function resolveEffectiveMemoryPlan(user) {
15959
15989
  if (tierIncludesMemory(user.subscription_tier)) return "pro";
15960
15990
  return user.memory_plan === "pro" ? "pro" : "free";
15961
15991
  }
15962
- async function getOrCreateUserMemoryKey(user) {
15963
- const creds = await getUserMemoryCreds(user.id);
15964
- if (creds.memory_key) {
15965
- const decrypted = decryptMemoryKey(creds.memory_key);
15966
- if (decrypted) return { key: decrypted };
15967
- }
15968
- const admin = ADMIN_KEY();
15969
- if (!admin) return { key: null, error: "memory not configured (MCP_MEMORY_ADMIN_KEY missing)" };
15970
- const identity = memoryIdentity(user);
15971
- const plan = isMemoryOperator(user.email) ? "unlimited" : (await getMemoryPlan(user.id)).plan;
15972
- const provisioned = await provisionDefaultsTool.execute(
15973
- { apiKey: admin, granteeIdentity: identity, issueKey: true, plan },
15974
- {}
15975
- );
15976
- if (!provisioned.ok || !provisioned.secret) {
15977
- return { key: null, error: provisioned.error ?? "failed to provision default vaults" };
15992
+ async function getMemoryServiceToken(user, planOverride) {
15993
+ try {
15994
+ const operator = isMemoryOperator(user.email);
15995
+ const plan = operator ? "unlimited" : planOverride ?? resolveEffectiveMemoryPlan(user);
15996
+ const scope = operator ? "memory.read memory.write memory.admin" : "memory.read memory.write";
15997
+ const key3 = await mintOAuthAccessToken({
15998
+ identity: memoryIdentity(user),
15999
+ scope,
16000
+ plan,
16001
+ audience: MEMORY_RESOURCE_URL(),
16002
+ ttlSeconds: MEMORY_SERVICE_TOKEN_TTL_SECONDS
16003
+ });
16004
+ return { key: key3 };
16005
+ } catch (error) {
16006
+ return {
16007
+ key: null,
16008
+ error: error instanceof Error ? error.message : "memory service authorization unavailable"
16009
+ };
15978
16010
  }
15979
- await setUserMemoryCreds(user.id, encryptMemoryKey(provisioned.secret), identity);
15980
- return { key: provisioned.secret };
15981
16011
  }
15982
16012
  async function syncMemoryKeyPlan(user, plan) {
15983
16013
  const effectivePlan = isMemoryOperator(user.email) ? "unlimited" : plan;
15984
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
16014
+ const { key: key3, error } = await getMemoryServiceToken(user, effectivePlan);
15985
16015
  if (!key3) return { ok: false, error: error ?? "memory unavailable" };
15986
- const listed = await memoryCall(
15987
- "listKeysTool",
15988
- {},
15989
- key3
15990
- );
15991
- if (!listed.ok || !listed.keys?.length) return { ok: false, error: listed.error ?? "no memory keys found" };
15992
- const target = listed.keys[0];
15993
- if (target.plan === effectivePlan) return { ok: true };
15994
- const res = await memoryCall("setScopeTool", { keyId: target.keyId, plan: effectivePlan }, key3);
15995
- return { ok: res.ok, error: res.error };
16016
+ const listed = await memoryCall("listVaultsTool", {}, key3);
16017
+ return { ok: listed.ok, error: listed.error };
15996
16018
  }
15997
16019
  async function syncScheduledActionCredentials(user) {
15998
16020
  const admin = ADMIN_KEY();
@@ -19616,7 +19638,7 @@ var adminAuth = createMiddleware3(async (c, next) => {
19616
19638
  import { Hono as Hono9 } from "hono";
19617
19639
 
19618
19640
  // src/api/admin-credits.ts
19619
- import { randomUUID as randomUUID5 } from "crypto";
19641
+ import { randomUUID as randomUUID6 } from "crypto";
19620
19642
  var MIN_ADJUSTMENT_CREDITS = 1;
19621
19643
  var LARGE_ADJUSTMENT_CREDITS = 1e5;
19622
19644
  var MAX_ADJUSTMENT_CREDITS = 1e7;
@@ -19766,7 +19788,7 @@ async function applyAdjustment(input) {
19766
19788
  const credits = validateCredits(input.credits, input.confirmLarge === true);
19767
19789
  const reason = validateReason(input.reason);
19768
19790
  const actor = validateActor(input.actor);
19769
- const reference2 = input.reference?.trim() || `adj_${randomUUID5()}`;
19791
+ const reference2 = input.reference?.trim() || `adj_${randomUUID6()}`;
19770
19792
  if (reference2.length > 120) throw new AdminCreditError(400, "reference must be at most 120 characters");
19771
19793
  const db = getDb();
19772
19794
  const existing = await db.execute({
@@ -21336,11 +21358,11 @@ async function runKernelRedditPipeline(apiKey, input, hooks) {
21336
21358
  }
21337
21359
 
21338
21360
  // src/reddit/bright-data-thread-backup.ts
21339
- import { createHash as createHash6 } from "crypto";
21361
+ import { createHash as createHash7 } from "crypto";
21340
21362
  import { chromium as chromium5 } from "playwright";
21341
21363
 
21342
21364
  // src/api/brightdata-session-telemetry.ts
21343
- import { createHash as createHash5 } from "crypto";
21365
+ import { createHash as createHash6 } from "crypto";
21344
21366
  var DEFAULT_SESSION_API_BASE_URL = "https://api.brightdata.com";
21345
21367
  var DEFAULT_TIMEOUT_MS = 5e3;
21346
21368
  var MAX_PROVIDER_TEXT = 320;
@@ -21517,7 +21539,7 @@ async function enrichPendingBrightDataAttempts(limit = 25, options = {}) {
21517
21539
  return summary;
21518
21540
  }
21519
21541
  function providerSessionHash(sessionId) {
21520
- return createHash5("sha256").update(sessionId).digest("hex").slice(0, 16);
21542
+ return createHash6("sha256").update(sessionId).digest("hex").slice(0, 16);
21521
21543
  }
21522
21544
  async function recordPendingBrightDataRedditUsage(providerSessionId, telemetry) {
21523
21545
  return recordVendorUsage({
@@ -21691,7 +21713,7 @@ function isAcceptedRedditThread(thread, requestedComments) {
21691
21713
  return Boolean(thread.title?.trim()) && thread.comments.length >= redditThreadAcceptanceTarget(thread, requestedComments);
21692
21714
  }
21693
21715
  function hashSessionId(sessionId) {
21694
- return sessionId ? createHash6("sha256").update(sessionId).digest("hex").slice(0, 16) : null;
21716
+ return sessionId ? createHash7("sha256").update(sessionId).digest("hex").slice(0, 16) : null;
21695
21717
  }
21696
21718
  async function reconcileSession(sessionId) {
21697
21719
  if (!sessionId) return null;
@@ -22288,11 +22310,11 @@ configurePostRoute({
22288
22310
  });
22289
22311
 
22290
22312
  // src/api/gmail-routes.ts
22291
- import { createHash as createHash9, timingSafeEqual as timingSafeEqual3 } from "crypto";
22313
+ import { createHash as createHash10, timingSafeEqual as timingSafeEqual3 } from "crypto";
22292
22314
  import { Hono as Hono13 } from "hono";
22293
22315
 
22294
22316
  // src/api/gmail-memory-ingest-repository.ts
22295
- import { randomUUID as randomUUID6 } from "crypto";
22317
+ import { randomUUID as randomUUID7 } from "crypto";
22296
22318
  var GmailImportRepositoryError = class extends Error {
22297
22319
  constructor(code, message, status = 400) {
22298
22320
  super(message);
@@ -22363,7 +22385,7 @@ async function createOrGetGmailImportPlan(ownerId3, data, now = /* @__PURE__ */
22363
22385
  const planFingerprint = gmailFingerprint(data);
22364
22386
  const existing = await getDb().execute({ sql: `SELECT * FROM gmail_import_plans WHERE owner_identity = ? AND plan_fingerprint = ? AND expires_at > ? LIMIT 1`, args: [ownerId3, planFingerprint, now.toISOString()] });
22365
22387
  if (existing.rows[0]) return planFromRow(existing.rows[0]);
22366
- const plan = { ...data, importPlanId: `gplan_${randomUUID6().replace(/-/g, "")}`, ownerId: ownerId3, planFingerprint, createdAt: now.toISOString(), expiresAt: new Date(now.getTime() + 24 * 60 * 60 * 1e3).toISOString() };
22388
+ const plan = { ...data, importPlanId: `gplan_${randomUUID7().replace(/-/g, "")}`, ownerId: ownerId3, planFingerprint, createdAt: now.toISOString(), expiresAt: new Date(now.getTime() + 24 * 60 * 60 * 1e3).toISOString() };
22367
22389
  await getDb().execute({ sql: `INSERT INTO gmail_import_plans (import_plan_id, owner_identity, plan_fingerprint, plan_json, created_at, expires_at) VALUES (?, ?, ?, ?, ?, ?)`, args: [plan.importPlanId, ownerId3, plan.planFingerprint, JSON.stringify(data), plan.createdAt, plan.expiresAt] });
22368
22390
  return plan;
22369
22391
  }
@@ -22393,7 +22415,7 @@ async function beginOrResumeGmailImport(args) {
22393
22415
  }
22394
22416
  const now = args.now ?? /* @__PURE__ */ new Date();
22395
22417
  const leaseExpiresAt = new Date(now.getTime() + (args.leaseMs ?? 45e3)).toISOString();
22396
- const job = { ingestId: `ging_${randomUUID6().replace(/-/g, "")}`, ownerId: args.ownerId, importPlanId: args.plan.importPlanId, idempotencyKey: key3, fingerprint: fingerprint5, status: "running", attempts: 0, leaseExpiresAt, progress: { messagesStored: 0, attachmentsStored: 0, attachmentsIndexed: 0, skipped: 0, errors: [], checkpoints: {} }, createdAt: now.toISOString(), updatedAt: now.toISOString() };
22418
+ const job = { ingestId: `ging_${randomUUID7().replace(/-/g, "")}`, ownerId: args.ownerId, importPlanId: args.plan.importPlanId, idempotencyKey: key3, fingerprint: fingerprint5, status: "running", attempts: 0, leaseExpiresAt, progress: { messagesStored: 0, attachmentsStored: 0, attachmentsIndexed: 0, skipped: 0, errors: [], checkpoints: {} }, createdAt: now.toISOString(), updatedAt: now.toISOString() };
22397
22419
  await getDb().execute({ sql: `INSERT INTO gmail_import_jobs (ingest_id, owner_identity, import_plan_id, idempotency_key, fingerprint, status, attempts, lease_expires_at, progress_json, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, args: [job.ingestId, job.ownerId, job.importPlanId, job.idempotencyKey, job.fingerprint, job.status, job.attempts, job.leaseExpiresAt, JSON.stringify(job.progress), job.createdAt, job.updatedAt] });
22398
22420
  return { job, acquired: true };
22399
22421
  }
@@ -22425,7 +22447,7 @@ async function getGmailImportStatus(ownerId3, ingestId) {
22425
22447
  }
22426
22448
 
22427
22449
  // src/api/gmail-memory-ingest.ts
22428
- import { createHash as createHash7 } from "crypto";
22450
+ import { createHash as createHash8 } from "crypto";
22429
22451
  var GMAIL_IMPORT_MAX_ATTACHMENTS = 1e4;
22430
22452
  var GMAIL_IMPORT_MAX_ATTACHMENT_BYTES = 25 * 1024 * 1024;
22431
22453
  var GMAIL_IMPORT_MAX_TOTAL_ATTACHMENT_BYTES = 250 * 1024 * 1024;
@@ -22584,7 +22606,7 @@ var GmailMemoryIngestService = class {
22584
22606
  }
22585
22607
  };
22586
22608
  function canonicalMessageDigest(message) {
22587
- return createHash7("sha256").update(JSON.stringify({ messageId: message.messageId, threadId: message.threadId, internalDate: message.internalDate, headers: message.headers, labels: message.labels, plainText: message.plainText, sanitizedHtml: message.sanitizedHtml, attachments: message.attachments.map((item) => ({ filename: item.filename, mime: item.declaredMime, size: item.size, partId: item.partId })) })).digest("hex");
22609
+ return createHash8("sha256").update(JSON.stringify({ messageId: message.messageId, threadId: message.threadId, internalDate: message.internalDate, headers: message.headers, labels: message.labels, plainText: message.plainText, sanitizedHtml: message.sanitizedHtml, attachments: message.attachments.map((item) => ({ filename: item.filename, mime: item.declaredMime, size: item.size, partId: item.partId })) })).digest("hex");
22588
22610
  }
22589
22611
  function renderMessageNote(message, attachmentPolicy) {
22590
22612
  const addresses = (values) => values.map((item) => item.name ? `${item.name} <${item.email}>` : item.email).join(", ");
@@ -22611,11 +22633,11 @@ function gmailAttachmentSourceIdentity(messageId, messageDigest, partId, attachm
22611
22633
  return `gmail:${messageId}:${messageDigest}:${partId}:${attachmentDigest}`;
22612
22634
  }
22613
22635
  function gmailAttachmentSaveIdempotencyKey(messageId, messageDigest, partId, attachmentDigest) {
22614
- return `gmail-attachment:${createHash7("sha256").update(gmailAttachmentSourceIdentity(messageId, messageDigest, partId, attachmentDigest)).digest("hex")}`;
22636
+ return `gmail-attachment:${createHash8("sha256").update(gmailAttachmentSourceIdentity(messageId, messageDigest, partId, attachmentDigest)).digest("hex")}`;
22615
22637
  }
22616
22638
 
22617
22639
  // src/api/scheduler-integration-auth.ts
22618
- import { createHash as createHash8, createHmac as createHmac2, timingSafeEqual as timingSafeEqual2 } from "crypto";
22640
+ import { createHash as createHash9, createHmac as createHmac2, timingSafeEqual as timingSafeEqual2 } from "crypto";
22619
22641
  var MAX_CLOCK_SKEW_MS = 5 * 60 * 1e3;
22620
22642
  var SchedulerIntegrationAuthError = class extends Error {
22621
22643
  code;
@@ -22631,7 +22653,7 @@ function signingSecret() {
22631
22653
  return secret;
22632
22654
  }
22633
22655
  function schedulerIntegrationSignature(args) {
22634
- const bodyHash = createHash8("sha256").update(args.body).digest("hex");
22656
+ const bodyHash = createHash9("sha256").update(args.body).digest("hex");
22635
22657
  return createHmac2("sha256", args.secret).update(`${args.method.toUpperCase()}
22636
22658
  ${args.path}
22637
22659
  ${args.timestamp}
@@ -22691,7 +22713,7 @@ var gmailApp = new Hono13();
22691
22713
  var auth = createApiKeyAuth();
22692
22714
  var gmail = new GmailService();
22693
22715
  function ownerId(apiKey) {
22694
- return createHash9("sha256").update(apiKey).digest("hex").slice(0, 24);
22716
+ return createHash10("sha256").update(apiKey).digest("hex").slice(0, 24);
22695
22717
  }
22696
22718
  function caller(c) {
22697
22719
  const user = c.get("user");
@@ -22899,7 +22921,7 @@ function gmailMemoryAssetToolsForMime(mimeType) {
22899
22921
  }
22900
22922
  async function memoryPort(c) {
22901
22923
  const user = c.get("user");
22902
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
22924
+ const { key: key3, error } = await getMemoryServiceToken(user);
22903
22925
  if (!key3) throw new GmailMemoryIngestError("memory_unavailable", error ?? "Memory is unavailable.", 503, true);
22904
22926
  return {
22905
22927
  async validateVault(vault) {
@@ -22931,7 +22953,7 @@ async function memoryPort(c) {
22931
22953
  return { status: "unmatched" };
22932
22954
  },
22933
22955
  async saveNote(args) {
22934
- const path5 = `gmail/${createHash9("sha256").update(args.sourceKey).digest("hex")}.md`;
22956
+ const path5 = `gmail/${createHash10("sha256").update(args.sourceKey).digest("hex")}.md`;
22935
22957
  const result3 = await memoryCall("putTool", gmailMemoryNoteArguments({ ...args, path: path5 }), key3);
22936
22958
  if (!result3.ok) throw new GmailMemoryIngestError("memory_note_failed", String(result3.error ?? "Memory note write failed."), 503, true);
22937
22959
  return { ...result3, path: path5 };
@@ -23112,7 +23134,7 @@ gmailApp.post("/api/internal/integrations/:connectionId/gmail/selections/prepare
23112
23134
  if (!providerIdentity || body3.purpose !== "scheduled_export") throw new GmailServiceError("invalid_request", "identity and scheduled_export purpose are required.");
23113
23135
  const parsedSource = selectionSource(source);
23114
23136
  if (!parsedSource) throw new GmailServiceError("invalid_request", "A valid Gmail selection source is required.");
23115
- const internalOwnerId = createHash9("sha256").update(providerIdentity.toLowerCase()).digest("hex").slice(0, 24);
23137
+ const internalOwnerId = createHash10("sha256").update(providerIdentity.toLowerCase()).digest("hex").slice(0, 24);
23116
23138
  const exactRange = string(range.from) && string(range.to) ? { from: String(range.from), to: String(range.to) } : void 0;
23117
23139
  const selection = await gmail.prepareSelection({ ownerId: internalOwnerId, providerIdentity, connectionId: c.req.param("connectionId"), purpose: "scheduled_export", source: parsedSource, ...exactRange ? { exactRange } : {} });
23118
23140
  return c.json({ ok: true, contract: { version: GMAIL_MAIN_CONTRACT_VERSION, hash: GMAIL_MAIN_CONTRACT_HASH }, selection: await selectionReceipt(selection, providerIdentity, true), untrustedContent: true });
@@ -23129,7 +23151,7 @@ gmailApp.post("/api/internal/integrations/:connectionId/gmail/selections/:select
23129
23151
  const selectionSha256 = string(body3.selectionSha256);
23130
23152
  const expectedCount = integer(body3.expectedCount);
23131
23153
  if (!providerIdentity || !selectionSha256 || expectedCount === null) throw new GmailServiceError("invalid_request", "identity and the exact selection receipt are required.");
23132
- const internalOwnerId = createHash9("sha256").update(providerIdentity.toLowerCase()).digest("hex").slice(0, 24);
23154
+ const internalOwnerId = createHash10("sha256").update(providerIdentity.toLowerCase()).digest("hex").slice(0, 24);
23133
23155
  const exported = await gmail.exportSelection({ ownerId: internalOwnerId, providerIdentity, connectionId: c.req.param("connectionId"), selectionId: c.req.param("selectionId"), selectionSha256, expectedCount });
23134
23156
  return c.json({ ok: true, contract: { version: GMAIL_MAIN_CONTRACT_VERSION, hash: GMAIL_MAIN_CONTRACT_HASH }, export: exported, untrustedContent: true });
23135
23157
  } catch (error) {
@@ -23193,7 +23215,7 @@ function gmailResolvedArtifactHeaders(artifactId, bytes2) {
23193
23215
  decoded = "artifact.bin";
23194
23216
  }
23195
23217
  const filename2 = decoded.replace(/[\r\n]/g, "").slice(0, 500) || "artifact.bin";
23196
- return { filename: filename2, contentType: sniffResolvedArtifactMime(bytes2, filename2), sha256: createHash9("sha256").update(bytes2).digest("hex") };
23218
+ return { filename: filename2, contentType: sniffResolvedArtifactMime(bytes2, filename2), sha256: createHash10("sha256").update(bytes2).digest("hex") };
23197
23219
  }
23198
23220
 
23199
23221
  // src/api/video-routes.ts
@@ -23218,7 +23240,7 @@ videoApp.post("/analyze", createApiKeyAuth(), async (c) => {
23218
23240
  if (!parsed.success) return c.json(invalidRequest6(parsed.error.issues[0]?.message ?? "invalid request"), 400);
23219
23241
  const body3 = parsed.data;
23220
23242
  const user = c.get("user");
23221
- const { key: memKey, error: memErr } = await getOrCreateUserMemoryKey(user);
23243
+ const { key: memKey, error: memErr } = await getMemoryServiceToken(user);
23222
23244
  if (!memKey) return c.json({ error_code: "memory_unavailable", message: memErr ?? "memory unavailable" }, 502);
23223
23245
  const requestedFrames = Math.min(Math.max(body3.maxFrames ?? 120, 1), 480);
23224
23246
  const tiers = tiersFor(requestedFrames);
@@ -23252,7 +23274,7 @@ videoApp.post("/status", createApiKeyAuth(), async (c) => {
23252
23274
  const runId = rawBody.runId?.trim();
23253
23275
  if (!runId) return c.json(invalidRequest6("runId is required"), 400);
23254
23276
  const user = c.get("user");
23255
- const { key: memKey, error: memErr } = await getOrCreateUserMemoryKey(user);
23277
+ const { key: memKey, error: memErr } = await getMemoryServiceToken(user);
23256
23278
  if (!memKey) return c.json({ error_code: "memory_unavailable", message: memErr ?? "memory unavailable" }, 502);
23257
23279
  const st = await memoryCall("videoAnalyzeStatusTool", { runId }, memKey);
23258
23280
  if (!st.ok) return c.json({ error_code: "not_found", message: st.error ?? "run not found" }, 404);
@@ -24071,17 +24093,17 @@ g2App.post("/reviews", createApiKeyAuth(), async (c) => {
24071
24093
  });
24072
24094
 
24073
24095
  // src/api/directory-routes.ts
24074
- import { createHash as createHash10, randomUUID as randomUUID8 } from "crypto";
24096
+ import { createHash as createHash11, randomUUID as randomUUID9 } from "crypto";
24075
24097
  import { Hono as Hono18 } from "hono";
24076
24098
 
24077
24099
  // src/api/directory-workflow-dispatch.ts
24078
- import { randomUUID as randomUUID7 } from "crypto";
24100
+ import { randomUUID as randomUUID8 } from "crypto";
24079
24101
  function retryDelaySeconds(attempts) {
24080
24102
  return Math.min(60 * 60, Math.max(15, 15 * 2 ** Math.min(8, Math.max(0, attempts - 1))));
24081
24103
  }
24082
24104
  async function dispatchPendingDirectoryWorkflows(limit = 25) {
24083
24105
  const rows = await claimDirectoryWorkflowOutbox({
24084
- workerId: `directory-dispatch-${process.pid}-${randomUUID7().slice(0, 8)}`,
24106
+ workerId: `directory-dispatch-${process.pid}-${randomUUID8().slice(0, 8)}`,
24085
24107
  limit
24086
24108
  });
24087
24109
  const result3 = { claimed: rows.length, dispatched: 0, failed: 0 };
@@ -24111,7 +24133,7 @@ function safeOptions(options) {
24111
24133
  return safe;
24112
24134
  }
24113
24135
  function requestFingerprint(options) {
24114
- return createHash10("sha256").update(JSON.stringify(safeOptions(options))).digest("hex");
24136
+ return createHash11("sha256").update(JSON.stringify(safeOptions(options))).digest("hex");
24115
24137
  }
24116
24138
  function idempotencyKey(raw) {
24117
24139
  if (raw !== void 0) {
@@ -24120,14 +24142,14 @@ function idempotencyKey(raw) {
24120
24142
  if (trimmed.length > 500) return { ok: false, message: "Idempotency-Key must be 500 characters or fewer." };
24121
24143
  return { ok: true, key: trimmed };
24122
24144
  }
24123
- return { ok: true, key: `directory-${randomUUID8()}` };
24145
+ return { ok: true, key: `directory-${randomUUID9()}` };
24124
24146
  }
24125
24147
  function debitKeyFor(userId, responseKey) {
24126
- const digest23 = createHash10("sha256").update(String(userId)).update("\0").update(responseKey).digest("hex");
24148
+ const digest23 = createHash11("sha256").update(String(userId)).update("\0").update(responseKey).digest("hex");
24127
24149
  return `directory-workflow:${userId}:${digest23}`;
24128
24150
  }
24129
24151
  function jobId() {
24130
- return `dir_${randomUUID8().replace(/-/g, "")}`;
24152
+ return `dir_${randomUUID9().replace(/-/g, "")}`;
24131
24153
  }
24132
24154
  function publicStatus(job, result3) {
24133
24155
  if (job.status === "failed") return "failed";
@@ -24236,7 +24258,7 @@ async function runSynchronously(c, user, options, plan, responseKey) {
24236
24258
  const csv2 = renderDirectoryWorkflowCsv(result3);
24237
24259
  const artifact = await createDirectoryCsvArtifact({
24238
24260
  ownerId: String(user.id),
24239
- jobId: createHash10("sha256").update(debitKey).digest("hex").slice(0, 32),
24261
+ jobId: createHash11("sha256").update(debitKey).digest("hex").slice(0, 32),
24240
24262
  createdAt: result3.extractedAt,
24241
24263
  filename: `${options.state}-${options.query}-directory.csv`,
24242
24264
  csv: csv2,
@@ -24431,17 +24453,17 @@ directoryApp.get("/jobs/:id", createApiKeyAuth(), async (c) => {
24431
24453
  });
24432
24454
 
24433
24455
  // src/api/lead-list-input-routes.ts
24434
- import { createHash as createHash12 } from "crypto";
24456
+ import { createHash as createHash13 } from "crypto";
24435
24457
  import { Hono as Hono19 } from "hono";
24436
24458
 
24437
24459
  // src/api/lead-list-input-artifacts.ts
24438
- import { createHash as createHash11 } from "crypto";
24460
+ import { createHash as createHash12 } from "crypto";
24439
24461
  import { rm } from "fs/promises";
24440
24462
  import { homedir as homedir3 } from "os";
24441
24463
  import { join as join7 } from "path";
24442
24464
 
24443
24465
  // src/api/lead-list-import-repository.ts
24444
- import { randomUUID as randomUUID9 } from "crypto";
24466
+ import { randomUUID as randomUUID10 } from "crypto";
24445
24467
  var schemaDb4 = null;
24446
24468
  var schemaPromise3 = null;
24447
24469
  function parseJson3(value, fallback) {
@@ -24507,10 +24529,10 @@ function bounded(value, field, min, max) {
24507
24529
  return normalized;
24508
24530
  }
24509
24531
  function newLeadListUploadId() {
24510
- return `upl_${randomUUID9().replace(/-/g, "")}`;
24532
+ return `upl_${randomUUID10().replace(/-/g, "")}`;
24511
24533
  }
24512
24534
  function newImportedLeadListId() {
24513
- return `lst_${randomUUID9().replace(/-/g, "")}`;
24535
+ return `lst_${randomUUID10().replace(/-/g, "")}`;
24514
24536
  }
24515
24537
  async function ensureLeadListImportRepositorySchema() {
24516
24538
  const db = getDb();
@@ -24758,7 +24780,7 @@ function safeFilenameHint(value) {
24758
24780
  return cleaned || null;
24759
24781
  }
24760
24782
  function requestFingerprint2(filenameHint) {
24761
- return createHash11("sha256").update(JSON.stringify({ filenameHint })).digest("hex");
24783
+ return createHash12("sha256").update(JSON.stringify({ filenameHint })).digest("hex");
24762
24784
  }
24763
24785
  function publicBaseUrl() {
24764
24786
  const configured3 = process.env.MCP_SCRAPER_PUBLIC_BASE_URL?.trim() || process.env.PUBLIC_BASE_URL?.trim() || (process.env.VERCEL_PROJECT_PRODUCTION_URL ? `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}` : "") || "https://mcpscraper.dev";
@@ -24914,7 +24936,7 @@ async function inspectLeadListUpload(uploadId, ownerId3) {
24914
24936
  maxBytes: LEAD_LIST_UPLOAD_MAX_BYTES
24915
24937
  });
24916
24938
  if (!buffer) return null;
24917
- const sha2564 = createHash11("sha256").update(buffer).digest("hex");
24939
+ const sha2564 = createHash12("sha256").update(buffer).digest("hex");
24918
24940
  const completed = await completeLeadListUpload({
24919
24941
  id: record7.id,
24920
24942
  ownerId: record7.ownerId,
@@ -25397,7 +25419,7 @@ function canonicalize(value) {
25397
25419
  return `{${Object.keys(object2).sort().map((key3) => `${JSON.stringify(key3)}:${canonicalize(object2[key3])}`).join(",")}}`;
25398
25420
  }
25399
25421
  function fingerprint(value) {
25400
- return createHash12("sha256").update(canonicalize(value)).digest("hex");
25422
+ return createHash13("sha256").update(canonicalize(value)).digest("hex");
25401
25423
  }
25402
25424
  async function safeJson(c) {
25403
25425
  try {
@@ -25652,17 +25674,17 @@ leadListInputApp.post("/imports", async (c) => {
25652
25674
  });
25653
25675
 
25654
25676
  // src/api/lead-list-enrichment-routes.ts
25655
- import { createHash as createHash13, randomUUID as randomUUID11 } from "crypto";
25677
+ import { createHash as createHash14, randomUUID as randomUUID12 } from "crypto";
25656
25678
  import { Hono as Hono20 } from "hono";
25657
25679
  import { z as z25 } from "zod";
25658
25680
 
25659
25681
  // src/api/lead-list-enrichment-dispatch.ts
25660
- import { randomUUID as randomUUID10 } from "crypto";
25682
+ import { randomUUID as randomUUID11 } from "crypto";
25661
25683
  function retryDelaySeconds2(attempts) {
25662
25684
  return Math.min(3600, Math.max(15, 15 * 2 ** Math.min(8, Math.max(0, attempts - 1))));
25663
25685
  }
25664
25686
  async function dispatchPendingLeadListEnrichments(limit = 25) {
25665
- const rows = await claimLeadListEnrichmentOutbox({ workerId: `lead-list-dispatch-${process.pid}-${randomUUID10().slice(0, 8)}`, limit });
25687
+ const rows = await claimLeadListEnrichmentOutbox({ workerId: `lead-list-dispatch-${process.pid}-${randomUUID11().slice(0, 8)}`, limit });
25666
25688
  const result3 = { claimed: rows.length, dispatched: 0, failed: 0 };
25667
25689
  for (const row of rows) {
25668
25690
  if (!row.claimToken) continue;
@@ -25710,15 +25732,15 @@ function idempotencyKey2(raw) {
25710
25732
  return { ok: true, value };
25711
25733
  }
25712
25734
  function newJobId() {
25713
- return `lle_${randomUUID11().replace(/-/g, "")}`;
25735
+ return `lle_${randomUUID12().replace(/-/g, "")}`;
25714
25736
  }
25715
25737
  function debitKeyFor2(userId, key3) {
25716
- const digest23 = createHash13("sha256").update(String(userId)).update("\0").update(key3).digest("hex");
25738
+ const digest23 = createHash14("sha256").update(String(userId)).update("\0").update(key3).digest("hex");
25717
25739
  return `lead-list-enrichment:${userId}:${digest23}`;
25718
25740
  }
25719
25741
  function inlineSourceDigest(headers, rows) {
25720
25742
  const values = rows.map((row) => headers.map((header) => row[header] ?? null));
25721
- return createHash13("sha256").update(stableCanonicalJson({ headers, values })).digest("hex");
25743
+ return createHash14("sha256").update(stableCanonicalJson({ headers, values })).digest("hex");
25722
25744
  }
25723
25745
  function issueMessage(error) {
25724
25746
  const issue = error.issues[0];
@@ -26992,6 +27014,40 @@ function flatFromRecord(record7, seedQuery) {
26992
27014
  extracted_at: record7.observedAt
26993
27015
  };
26994
27016
  }
27017
+ function mergePaaProgressMaterial(existing, incoming) {
27018
+ if (!existing) return structuredClone(incoming);
27019
+ const merged = structuredClone(incoming);
27020
+ const keepOrganic = existing.pagination?.page2Status === "captured" && incoming.pagination?.page2Status !== "captured" || existing.pagination?.page2Status === incoming.pagination?.page2Status && existing.organicResults.length > incoming.organicResults.length || existing.organicResults.length > 0 && incoming.organicResults.length === 0;
27021
+ if (keepOrganic) {
27022
+ merged.organicResults = structuredClone(existing.organicResults);
27023
+ merged.pagination = existing.pagination ? structuredClone(existing.pagination) : incoming.pagination;
27024
+ }
27025
+ const resolvedLinks = /* @__PURE__ */ new Map();
27026
+ for (const row of [...existing.organicResults, ...incoming.organicResults]) {
27027
+ if (row.resolutionStatus !== "resolved" || !row.resolvedUrl) continue;
27028
+ for (const identity of [row.rawUrl, row.url, row.resolvedUrl]) {
27029
+ if (identity) resolvedLinks.set(identity, row);
27030
+ }
27031
+ }
27032
+ merged.organicResults = merged.organicResults.map((row) => {
27033
+ if (row.resolutionStatus !== "unresolved" && row.resolutionStatus !== void 0) return row;
27034
+ const resolved = [row.rawUrl, row.url].filter(Boolean).map((identity) => resolvedLinks.get(identity)).find(Boolean);
27035
+ if (!resolved) return row;
27036
+ return {
27037
+ ...row,
27038
+ url: resolved.url,
27039
+ resolvedUrl: resolved.resolvedUrl,
27040
+ resolutionStatus: resolved.resolutionStatus,
27041
+ domain: resolved.domain
27042
+ };
27043
+ });
27044
+ for (const key3 of ["videos", "forums", "localPack", "whatPeopleSaying"]) {
27045
+ if (!merged[key3].length && existing[key3].length) Object.assign(merged, { [key3]: structuredClone(existing[key3]) });
27046
+ }
27047
+ if (!merged.aiOverview.detected && existing.aiOverview.detected) merged.aiOverview = structuredClone(existing.aiOverview);
27048
+ if (!merged.aiMode.detected && existing.aiMode.detected) merged.aiMode = structuredClone(existing.aiMode);
27049
+ return merged;
27050
+ }
26995
27051
  var ProgressivePaaCheckpoint = class {
26996
27052
  constructor(jobId2, durableMetadata, persist, now = Date.now, initialResult) {
26997
27053
  this.jobId = jobId2;
@@ -27061,7 +27117,7 @@ var ProgressivePaaCheckpoint = class {
27061
27117
  this.sequence += 1;
27062
27118
  if (snapshot.lifecycle) this.lifecycle = { ...snapshot.lifecycle };
27063
27119
  if (snapshot.material) {
27064
- this.material = structuredClone(snapshot.material);
27120
+ this.material = mergePaaProgressMaterial(this.material, snapshot.material);
27065
27121
  this.improvementsSinceWrite += 1;
27066
27122
  }
27067
27123
  for (const question of snapshot.clickedQuestions) if (clean2(question)) this.clickedQuestions.add(clean2(question));
@@ -27166,6 +27222,7 @@ function partialTerminalResult(job, options, maxQuestions, progress, recoveryCou
27166
27222
  resultQuality: "partial",
27167
27223
  degradedResult: false,
27168
27224
  retryRecommended: true,
27225
+ pagination: material?.pagination,
27169
27226
  paaLifecycle: {
27170
27227
  ...progress.lifecycle ?? {
27171
27228
  requestedQuestions: maxQuestions,
@@ -27267,7 +27324,7 @@ async function runPaaHarvestJob(jobId2) {
27267
27324
  };
27268
27325
  const onPaaProgress = async (snapshot) => {
27269
27326
  progress.accept(snapshot);
27270
- const force = snapshot.phase === "attempt_ending" || snapshot.phase === "click_observed" || snapshot.phase === "expansion_finished";
27327
+ const force = snapshot.phase === "serp_captured" || snapshot.phase === "attempt_ending" || snapshot.phase === "click_observed" || snapshot.phase === "expansion_finished";
27271
27328
  await progress.flush(snapshot.phase === "attempt_ending" ? "failed" : "expanding", { force });
27272
27329
  };
27273
27330
  const harvestCtx = currentCostContext();
@@ -27279,6 +27336,7 @@ async function runPaaHarvestJob(jobId2) {
27279
27336
  gl: options.gl ?? "us",
27280
27337
  hl: options.hl ?? "en",
27281
27338
  maxQuestions,
27339
+ pages: options.pages ?? 1,
27282
27340
  maxAttempts: DIRECT_PAA_MAX_ATTEMPTS,
27283
27341
  proxyMode: "none",
27284
27342
  forceManagedSerp: true,
@@ -27297,9 +27355,31 @@ async function runPaaHarvestJob(jobId2) {
27297
27355
  })
27298
27356
  );
27299
27357
  const harvestResult = harvested;
27358
+ if (Array.isArray(harvested.organicResults)) {
27359
+ progress.accept({
27360
+ sequence: 0,
27361
+ observedAt: (/* @__PURE__ */ new Date()).toISOString(),
27362
+ clickedQuestions: [],
27363
+ records: [],
27364
+ phase: "attempt_ending",
27365
+ material: {
27366
+ surface: harvested.surface ?? "unknown",
27367
+ organicResults: harvested.organicResults,
27368
+ videos: harvested.videos ?? [],
27369
+ forums: harvested.forums ?? [],
27370
+ localPack: harvested.localPack ?? [],
27371
+ whatPeopleSaying: harvested.whatPeopleSaying ?? [],
27372
+ aiOverview: harvested.aiOverview ?? { detected: false, text: null, citations: [] },
27373
+ aiMode: harvested.aiMode ?? { detected: false, text: null, citations: [] },
27374
+ entityIds: harvested.entityIds ?? { entities: [], kgIds: [], cids: [], gcids: [] },
27375
+ pagination: harvested.diagnostics?.pagination
27376
+ }
27377
+ });
27378
+ }
27300
27379
  progress.mergeTerminalRows(harvestResult.flat, lastAttempt, (/* @__PURE__ */ new Date()).toISOString());
27301
27380
  await progress.flush("captured", { force: true });
27302
27381
  const terminalProgress = progress.checkpoint("captured");
27382
+ const { pagination: terminalPagination, ...terminalMaterial } = terminalProgress.material ?? {};
27303
27383
  const mergedFlat = terminalProgress.records.map((record7) => flatFromRecord(record7, options.query ?? job.query));
27304
27384
  const rawDiagnostics = harvestResult.diagnostics && typeof harvestResult.diagnostics === "object" ? harvestResult.diagnostics : {};
27305
27385
  const rawCompleteness = rawDiagnostics.completeness && typeof rawDiagnostics.completeness === "object" ? rawDiagnostics.completeness : {};
@@ -27312,11 +27392,13 @@ async function runPaaHarvestJob(jobId2) {
27312
27392
  const automaticRetries = recoveryCount + terminalProgress.interruptions.filter((value) => value.willRetry).length;
27313
27393
  const result3 = {
27314
27394
  ...harvestResult,
27395
+ ...terminalMaterial,
27315
27396
  totalQuestions: mergedFlat.length,
27316
27397
  flat: mergedFlat,
27317
27398
  stats: harvestResult.stats && typeof harvestResult.stats === "object" ? { ...harvestResult.stats, totalQuestions: mergedFlat.length } : harvestResult.stats,
27318
27399
  diagnostics: {
27319
27400
  ...rawDiagnostics,
27401
+ pagination: terminalPagination ?? rawDiagnostics.pagination,
27320
27402
  resultQuality: incomplete ? "partial" : "complete",
27321
27403
  degradedResult: false,
27322
27404
  retryRecommended: discoveryStatus === "interrupted" || discoveryStatus === "recovery_exhausted",
@@ -27446,6 +27528,34 @@ function stalePartialResult(result3, records, seedQuery, recoveryCount) {
27446
27528
  const progress = current.progress && typeof current.progress === "object" ? current.progress : {};
27447
27529
  const material = progress.material && typeof progress.material === "object" ? progress.material : {};
27448
27530
  const diagnostics = current.diagnostics && typeof current.diagnostics === "object" ? current.diagnostics : {};
27531
+ const currentPagination = diagnostics.pagination && typeof diagnostics.pagination === "object" ? diagnostics.pagination : {};
27532
+ const materialPagination = material.pagination && typeof material.pagination === "object" ? material.pagination : {};
27533
+ const currentOrganic = Array.isArray(current.organicResults) ? current.organicResults : [];
27534
+ const materialOrganic = Array.isArray(material.organicResults) ? material.organicResults : [];
27535
+ const capturesPageTwo = (pagination, rows) => pagination.requestedPages === 2 && pagination.capturedPages === 2 && pagination.page2Status === "captured" && typeof pagination.page1OrganicCount === "number" && typeof pagination.page2OrganicCount === "number" && pagination.page2OrganicCount > 0 && rows.length >= pagination.page1OrganicCount + pagination.page2OrganicCount;
27536
+ const currentCaptured = capturesPageTwo(currentPagination, currentOrganic);
27537
+ const materialCaptured = capturesPageTwo(materialPagination, materialOrganic);
27538
+ const keepCurrentOrganic = currentCaptured && !materialCaptured || currentCaptured === materialCaptured && currentOrganic.length > materialOrganic.length;
27539
+ const selectedOrganic = keepCurrentOrganic ? currentOrganic : materialOrganic.length ? materialOrganic : currentOrganic;
27540
+ const fallbackOrganic = keepCurrentOrganic ? materialOrganic : currentOrganic;
27541
+ const resolvedByIdentity = /* @__PURE__ */ new Map();
27542
+ for (const row of [...fallbackOrganic, ...selectedOrganic]) {
27543
+ if (row.resolutionStatus !== "resolved" || typeof row.resolvedUrl !== "string" || !row.resolvedUrl) continue;
27544
+ for (const identity of [row.rawUrl, row.url, row.resolvedUrl]) {
27545
+ if (typeof identity === "string" && identity) resolvedByIdentity.set(identity, row);
27546
+ }
27547
+ }
27548
+ const reconciledOrganic = selectedOrganic.map((row) => {
27549
+ if (row.resolutionStatus !== "unresolved" && row.resolutionStatus !== void 0) return row;
27550
+ const resolved = [row.rawUrl, row.url].filter((identity) => typeof identity === "string" && Boolean(identity)).map((identity) => resolvedByIdentity.get(identity)).find(Boolean);
27551
+ return resolved ? {
27552
+ ...row,
27553
+ url: resolved.url,
27554
+ resolvedUrl: resolved.resolvedUrl,
27555
+ resolutionStatus: resolved.resolutionStatus,
27556
+ domain: resolved.domain
27557
+ } : row;
27558
+ });
27449
27559
  const completeness = diagnostics.completeness && typeof diagnostics.completeness === "object" ? diagnostics.completeness : {};
27450
27560
  const flat = records.map((record7) => ({
27451
27561
  seed_query: typeof record7.seed_query === "string" ? record7.seed_query : seedQuery,
@@ -27470,7 +27580,7 @@ function stalePartialResult(result3, records, seedQuery, recoveryCount) {
27470
27580
  tree: Array.isArray(current.tree) ? current.tree : [],
27471
27581
  videos: Array.isArray(material.videos) ? material.videos : current.videos ?? [],
27472
27582
  forums: Array.isArray(material.forums) ? material.forums : current.forums ?? [],
27473
- organicResults: Array.isArray(material.organicResults) ? material.organicResults : current.organicResults ?? [],
27583
+ organicResults: reconciledOrganic,
27474
27584
  localPack: Array.isArray(material.localPack) ? material.localPack : current.localPack ?? [],
27475
27585
  whatPeopleSaying: Array.isArray(material.whatPeopleSaying) ? material.whatPeopleSaying : current.whatPeopleSaying ?? [],
27476
27586
  aiOverview: material.aiOverview ?? current.aiOverview,
@@ -27480,6 +27590,7 @@ function stalePartialResult(result3, records, seedQuery, recoveryCount) {
27480
27590
  partial: true,
27481
27591
  diagnostics: {
27482
27592
  ...diagnostics,
27593
+ pagination: keepCurrentOrganic ? diagnostics.pagination : material.pagination ?? diagnostics.pagination,
27483
27594
  completionStatus: "paa_found",
27484
27595
  problem: null,
27485
27596
  resultQuality: "partial",
@@ -28292,17 +28403,17 @@ workflowApp.post("/cron/dispatch", async (c) => {
28292
28403
 
28293
28404
  // src/api/serp-intelligence-routes.ts
28294
28405
  import { Hono as Hono24 } from "hono";
28295
- import { createHash as createHash15, randomUUID as randomUUID12 } from "crypto";
28406
+ import { createHash as createHash16, randomUUID as randomUUID13 } from "crypto";
28296
28407
 
28297
28408
  // src/serp-intelligence/page-snapshot-extractor.ts
28298
- import { createHash as createHash14 } from "crypto";
28409
+ import { createHash as createHash15 } from "crypto";
28299
28410
  import pLimit5 from "p-limit";
28300
28411
  var DEFAULT_TIMEOUT_MS2 = 15e3;
28301
28412
  var DEFAULT_MAX_CONCURRENCY = 2;
28302
28413
  var DEFAULT_MAX_CONTENT_CHARS = 25e4;
28303
28414
  function sha256(value) {
28304
28415
  if (!value) return null;
28305
- return createHash14("sha256").update(value).digest("hex");
28416
+ return createHash15("sha256").update(value).digest("hex");
28306
28417
  }
28307
28418
  function countWords(markdown) {
28308
28419
  const matches = markdown.trim().match(/\b[\p{L}\p{N}][\p{L}\p{N}'-]*\b/gu);
@@ -29078,9 +29189,9 @@ async function logRequestEventBestEffort(input) {
29078
29189
  }
29079
29190
  }
29080
29191
  function captureBillingKeys(userId, suppliedKey, body3) {
29081
- const responseKey = suppliedKey?.trim() || randomUUID12();
29082
- const requestFingerprint3 = createHash15("sha256").update(JSON.stringify(body3)).digest("hex");
29083
- const keyDigest = createHash15("sha256").update(String(userId)).update("\0").update(responseKey).digest("hex");
29192
+ const responseKey = suppliedKey?.trim() || randomUUID13();
29193
+ const requestFingerprint3 = createHash16("sha256").update(JSON.stringify(body3)).digest("hex");
29194
+ const keyDigest = createHash16("sha256").update(String(userId)).update("\0").update(responseKey).digest("hex");
29084
29195
  return {
29085
29196
  responseKey,
29086
29197
  debitKey: `serp-capture:${userId}:${keyDigest}`,
@@ -29408,7 +29519,7 @@ var MemoryMcpToolExecutor = class {
29408
29519
  };
29409
29520
 
29410
29521
  // src/api/image-source-artifacts.ts
29411
- import { randomUUID as randomUUID13 } from "crypto";
29522
+ import { randomUUID as randomUUID14 } from "crypto";
29412
29523
  var IMAGE_SOURCE_ARTIFACT_PREFIX = "image-sources/";
29413
29524
  var IMAGE_SOURCE_ARTIFACT_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
29414
29525
  var IMAGE_SOURCE_DOWNLOAD_TTL_MS = 15 * 60 * 1e3;
@@ -29439,7 +29550,7 @@ async function createImageSourceArtifact(args) {
29439
29550
  if (args.content.length === 0 || args.content.length > IMAGE_SOURCE_MAX_BYTES) {
29440
29551
  throw new Error("image_source_size_invalid");
29441
29552
  }
29442
- const id2 = randomUUID13().replaceAll("-", "");
29553
+ const id2 = randomUUID14().replaceAll("-", "");
29443
29554
  return createPrivateArtifact({
29444
29555
  policy: policy3(),
29445
29556
  ownerId: args.ownerId,
@@ -29471,12 +29582,12 @@ var HybridMemoryToolExecutor = class {
29471
29582
  }
29472
29583
  httpExecutor;
29473
29584
  user;
29474
- mkKeyPromise = null;
29475
- async resolveMkKey() {
29476
- if (!this.mkKeyPromise) {
29477
- this.mkKeyPromise = getOrCreateUserMemoryKey(this.user).then((r) => r.key);
29585
+ serviceTokenPromise = null;
29586
+ async resolveServiceToken() {
29587
+ if (!this.serviceTokenPromise) {
29588
+ this.serviceTokenPromise = getMemoryServiceToken(this.user).then((r) => r.key);
29478
29589
  }
29479
- return this.mkKeyPromise;
29590
+ return this.serviceTokenPromise;
29480
29591
  }
29481
29592
  async callMemoryTool(upstreamName, args) {
29482
29593
  const accessDenied = memoryScheduleAccessPayload(upstreamName, this.user);
@@ -29530,10 +29641,10 @@ var HybridMemoryToolExecutor = class {
29530
29641
  }
29531
29642
  const handler = CUTOVER.get(upstreamName);
29532
29643
  if (!handler) return this.httpExecutor.callMemoryTool(upstreamName, args);
29533
- const mkKey = await this.resolveMkKey();
29534
- if (!mkKey) return { content: [{ type: "text", text: "memory unavailable" }], isError: true };
29644
+ const serviceToken = await this.resolveServiceToken();
29645
+ if (!serviceToken) return { content: [{ type: "text", text: "memory unavailable" }], isError: true };
29535
29646
  try {
29536
- return await handler(args, mkKey);
29647
+ return await handler(args, serviceToken);
29537
29648
  } catch (err) {
29538
29649
  const message = err instanceof Error ? err.message : `memory ${upstreamName} failed in-process`;
29539
29650
  return { content: [{ type: "text", text: message }], isError: true };
@@ -29906,7 +30017,7 @@ import { getChatLinkTool } from "mcpscraper-memory-tools/tools/access/get-chat-l
29906
30017
  import { revokeChatLinkTool } from "mcpscraper-memory-tools/tools/access/revoke-chat-link";
29907
30018
  import { getVaultAppLinkTool } from "mcpscraper-memory-tools/tools/access/get-vault-app-link";
29908
30019
  import { revokeVaultAppLinkTool } from "mcpscraper-memory-tools/tools/access/revoke-vault-app-link";
29909
- import { provisionDefaultsTool as provisionDefaultsTool2 } from "mcpscraper-memory-tools/tools/vaults/provision-defaults";
30020
+ import { provisionDefaultsTool } from "mcpscraper-memory-tools/tools/vaults/provision-defaults";
29910
30021
  import { createSecureVaultTool } from "mcpscraper-memory-tools/tools/vaults/create-secure-vault";
29911
30022
  import { createScheduledActionTool } from "mcpscraper-memory-tools/tools/schedule/create-scheduled-action";
29912
30023
  import { getScheduleStatusTool } from "mcpscraper-memory-tools/tools/schedule/get-schedule-status";
@@ -29956,7 +30067,7 @@ function registerBillingCutovers() {
29956
30067
  return { content: [{ type: "text", text: JSON.stringify(result3 ?? {}) }], structuredContent: result3 ?? {}, isError: false };
29957
30068
  });
29958
30069
  registerCutover("provisionDefaultsTool", async (input, apiKey) => {
29959
- const result3 = await provisionDefaultsTool2.execute({ ...input, apiKey }, {});
30070
+ const result3 = await provisionDefaultsTool.execute({ ...input, apiKey }, {});
29960
30071
  return { content: [{ type: "text", text: JSON.stringify(result3 ?? {}) }], structuredContent: result3 ?? {}, isError: false };
29961
30072
  });
29962
30073
  registerCutover("createSecureVaultTool", async (input, apiKey) => {
@@ -30184,11 +30295,11 @@ mcpApp.all("/", async (c) => {
30184
30295
  });
30185
30296
 
30186
30297
  // src/api/browser-agent-routes.ts
30187
- import { randomUUID as randomUUID18 } from "crypto";
30298
+ import { randomUUID as randomUUID19 } from "crypto";
30188
30299
  import { Hono as Hono26 } from "hono";
30189
30300
 
30190
30301
  // src/api/browser-agent-db.ts
30191
- import { randomUUID as randomUUID14 } from "crypto";
30302
+ import { randomUUID as randomUUID15 } from "crypto";
30192
30303
  var _ready = false;
30193
30304
  var _migrationPromise = null;
30194
30305
  async function migrateBrowserAgent() {
@@ -30367,7 +30478,7 @@ async function runBrowserAgentMigration() {
30367
30478
  }
30368
30479
  async function createExtensionRow(input) {
30369
30480
  const db = getDb();
30370
- const id2 = `bext_${randomUUID14().replace(/-/g, "").slice(0, 20)}`;
30481
+ const id2 = `bext_${randomUUID15().replace(/-/g, "").slice(0, 20)}`;
30371
30482
  await db.execute({
30372
30483
  sql: `INSERT INTO browser_agent_extensions (id, user_id, name, backend_id, backend_name, source, source_url, size_bytes)
30373
30484
  VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
@@ -30402,7 +30513,7 @@ async function deleteExtensionRow(userId, name) {
30402
30513
  }
30403
30514
  async function createAuthConnectionRow(input) {
30404
30515
  const db = getDb();
30405
- const connectionId = `authc_${randomUUID14().replace(/-/g, "").slice(0, 20)}`;
30516
+ const connectionId = `authc_${randomUUID15().replace(/-/g, "").slice(0, 20)}`;
30406
30517
  await db.execute({
30407
30518
  sql: `INSERT INTO browser_auth_connections (connection_id, user_id, domain, profile, account_email, note, status, browser_agent_session_id)
30408
30519
  VALUES (?, ?, ?, ?, ?, ?, 'NEEDS_AUTH', ?)`,
@@ -30485,7 +30596,7 @@ async function deleteProfileLabel(userId, profile) {
30485
30596
  }
30486
30597
  async function createSessionRow(input) {
30487
30598
  const db = getDb();
30488
- const id2 = `bas_${randomUUID14().replace(/-/g, "").slice(0, 20)}`;
30599
+ const id2 = `bas_${randomUUID15().replace(/-/g, "").slice(0, 20)}`;
30489
30600
  await db.execute({
30490
30601
  sql: `INSERT INTO browser_agent_sessions (id, runtime_session_id, live_view_url, cdp_ws_url, status, label, user_id, concurrency_lock_id, last_action_at)
30491
30602
  VALUES (?, ?, ?, ?, 'open', ?, ?, ?, datetime('now'))`,
@@ -30563,7 +30674,7 @@ async function recordAction(input) {
30563
30674
  sql: `INSERT INTO browser_agent_actions (id, session_id, type, params_json, ok, error)
30564
30675
  VALUES (?, ?, ?, ?, ?, ?)`,
30565
30676
  args: [
30566
- `baa_${randomUUID14().replace(/-/g, "").slice(0, 20)}`,
30677
+ `baa_${randomUUID15().replace(/-/g, "").slice(0, 20)}`,
30567
30678
  input.sessionId,
30568
30679
  input.type,
30569
30680
  input.params == null ? null : JSON.stringify(input.params),
@@ -31302,7 +31413,7 @@ async function runFanoutCapture(page3, input) {
31302
31413
  }
31303
31414
 
31304
31415
  // src/services/browser-agent/kernel-browser-runtime.ts
31305
- import { createHmac as createHmac4, randomUUID as randomUUID15 } from "crypto";
31416
+ import { createHmac as createHmac4, randomUUID as randomUUID16 } from "crypto";
31306
31417
  import Kernel5 from "@onkernel/sdk";
31307
31418
  import { chromium as playwrightChromium } from "playwright";
31308
31419
 
@@ -31448,7 +31559,7 @@ var KernelBrowserRuntime = class {
31448
31559
  await this.client.browsers.update(browser.session_id, { viewport: input.viewport }).catch(() => void 0);
31449
31560
  }
31450
31561
  const createdAtMs = this.now();
31451
- const sessionRef = `brs_${randomUUID15()}`;
31562
+ const sessionRef = `brs_${randomUUID16()}`;
31452
31563
  const session = {
31453
31564
  ownerRef,
31454
31565
  profileRef,
@@ -32024,9 +32135,9 @@ async function replayList(runtimeSessionId) {
32024
32135
  }
32025
32136
 
32026
32137
  // src/api/serp-identity-db.ts
32027
- import { randomUUID as randomUUID16 } from "crypto";
32138
+ import { randomUUID as randomUUID17 } from "crypto";
32028
32139
  async function createSerpIdentityRow(input) {
32029
- const id2 = `serpi_${randomUUID16().replace(/-/g, "").slice(0, 20)}`;
32140
+ const id2 = `serpi_${randomUUID17().replace(/-/g, "").slice(0, 20)}`;
32030
32141
  await getDb().execute({
32031
32142
  sql: `INSERT INTO serp_identities
32032
32143
  (id, user_id, name, kernel_profile_name, kernel_proxy_id, proxy_type, country, status)
@@ -32073,7 +32184,7 @@ async function deleteSerpIdentityRow(userId, name) {
32073
32184
  }
32074
32185
 
32075
32186
  // src/api/serp-identity-service.ts
32076
- import { createHash as createHash16, randomUUID as randomUUID17 } from "crypto";
32187
+ import { createHash as createHash17, randomUUID as randomUUID18 } from "crypto";
32077
32188
  import Kernel7 from "@onkernel/sdk";
32078
32189
  var MAX_SERP_IDENTITIES_PER_USER = 3;
32079
32190
  function kernelClient() {
@@ -32082,8 +32193,8 @@ function kernelClient() {
32082
32193
  return new Kernel7({ apiKey });
32083
32194
  }
32084
32195
  function backendName(userId, name, resource) {
32085
- const digest23 = createHash16("sha256").update(`${userId}:${name}`).digest("hex").slice(0, 16);
32086
- const nonce = randomUUID17().replace(/-/g, "").slice(0, 8);
32196
+ const digest23 = createHash17("sha256").update(`${userId}:${name}`).digest("hex").slice(0, 16);
32197
+ const nonce = randomUUID18().replace(/-/g, "").slice(0, 8);
32087
32198
  return `mcp-serp-${resource}-${digest23}-${nonce}`;
32088
32199
  }
32089
32200
  function isNotFound3(error) {
@@ -32876,7 +32987,7 @@ function buildBrowserAgentRoutes() {
32876
32987
  }
32877
32988
  const existing = await getExtensionRow(user.id, name);
32878
32989
  if (existing) return c.json({ error: `an extension named "${name}" already exists \u2014 delete it first or pick another name` }, 409);
32879
- const backendName2 = `u${user.id}_${randomUUID18().replace(/-/g, "")}`;
32990
+ const backendName2 = `u${user.id}_${randomUUID19().replace(/-/g, "")}`;
32880
32991
  try {
32881
32992
  const imported = await importExtensionFromStore(storeUrl, backendName2);
32882
32993
  const row = await createExtensionRow({
@@ -33216,7 +33327,7 @@ function shouldGrantScraperSubscriptionCredits(invoiceHasTierLine, invoiceTotal)
33216
33327
  }
33217
33328
 
33218
33329
  // src/api/analytics-journey.ts
33219
- import { createHash as createHash23, createHmac as createHmac8, generateKeyPairSync, randomUUID as randomUUID23, sign } from "crypto";
33330
+ import { createHash as createHash24, createHmac as createHmac8, generateKeyPairSync, randomUUID as randomUUID24, sign } from "crypto";
33220
33331
  import twilio2 from "twilio";
33221
33332
 
33222
33333
  // src/api/analytics-contracts.ts
@@ -33777,11 +33888,11 @@ var AnalyticsEventDefinitionSchema = z32.object({
33777
33888
  });
33778
33889
 
33779
33890
  // src/api/analytics-candidate-associations.ts
33780
- import { createHmac as createHmac5, randomUUID as randomUUID20 } from "crypto";
33891
+ import { createHmac as createHmac5, randomUUID as randomUUID21 } from "crypto";
33781
33892
  import ipaddr from "ipaddr.js";
33782
33893
 
33783
33894
  // src/api/analytics-identity-namespace.ts
33784
- import { randomUUID as randomUUID19 } from "crypto";
33895
+ import { randomUUID as randomUUID20 } from "crypto";
33785
33896
  async function listAnalyticsIdentityNamespaces(input) {
33786
33897
  const result3 = await getAnalyticsPool().query(
33787
33898
  `SELECT id, site_id, name, status, version, approved_at
@@ -33860,7 +33971,7 @@ async function createAnalyticsIdentityNamespace(input) {
33860
33971
  id, site_id, name, status, approved_hosts, approved_sources, version, approved_by_user_id
33861
33972
  ) VALUES ($1,$2,$3,'draft','[]'::jsonb,'[]'::jsonb,1,$4)
33862
33973
  RETURNING id, site_id, name, status, version, approved_at`,
33863
- [randomUUID19(), input.siteId, name, input.createdByUserId]
33974
+ [randomUUID20(), input.siteId, name, input.createdByUserId]
33864
33975
  );
33865
33976
  const saved = created.rows[0];
33866
33977
  await client2.query("COMMIT");
@@ -33900,7 +34011,7 @@ async function approveAnalyticsNamespaceSource(input) {
33900
34011
  ON CONFLICT(namespace_id, source_kind, source_ref) DO UPDATE
33901
34012
  SET status='approved', revoked_at=NULL
33902
34013
  RETURNING id, namespace_id, site_id, source_kind, source_ref, status, created_at, revoked_at`,
33903
- [randomUUID19(), input.namespaceId, input.siteId, storedKind, sourceRef]
34014
+ [randomUUID20(), input.namespaceId, input.siteId, storedKind, sourceRef]
33904
34015
  );
33905
34016
  await client2.query(
33906
34017
  `UPDATE analytics_identity_namespaces
@@ -34061,7 +34172,7 @@ async function promoteAnalyticsCandidateWithDeterministicEvidence(input) {
34061
34172
  ) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)
34062
34173
  ON CONFLICT(association_id, person_id) DO NOTHING`,
34063
34174
  [
34064
- randomUUID20(),
34175
+ randomUUID21(),
34065
34176
  input.siteId,
34066
34177
  input.namespaceId,
34067
34178
  input.associationId,
@@ -34080,7 +34191,7 @@ async function promoteAnalyticsCandidateWithDeterministicEvidence(input) {
34080
34191
  ) VALUES ($1,$2,$3,$4,'candidate_promoted',$5,$6,'promoted',$7::jsonb,$8)
34081
34192
  ON CONFLICT(site_id, idempotency_key) DO NOTHING`,
34082
34193
  [
34083
- randomUUID20(),
34194
+ randomUUID21(),
34084
34195
  input.siteId,
34085
34196
  input.namespaceId,
34086
34197
  input.associationId,
@@ -34099,7 +34210,7 @@ async function promoteAnalyticsCandidateWithDeterministicEvidence(input) {
34099
34210
  'xray.identity-promotion.v1',$11,$12)
34100
34211
  ON CONFLICT(site_id,idempotency_key) DO NOTHING`,
34101
34212
  [
34102
- randomUUID20(),
34213
+ randomUUID21(),
34103
34214
  input.siteId,
34104
34215
  input.namespaceId,
34105
34216
  input.personId,
@@ -34129,16 +34240,16 @@ async function promoteAnalyticsCandidateWithDeterministicEvidence(input) {
34129
34240
  }
34130
34241
 
34131
34242
  // src/api/analytics-crm-outbound.ts
34132
- import { createHash as createHash19 } from "crypto";
34243
+ import { createHash as createHash20 } from "crypto";
34133
34244
  import { z as z33 } from "zod";
34134
34245
 
34135
34246
  // src/api/analytics-crm-repository.ts
34136
- import { createHash as createHash17, randomUUID as randomUUID21 } from "crypto";
34247
+ import { createHash as createHash18, randomUUID as randomUUID22 } from "crypto";
34137
34248
  function dbOrDefault(db) {
34138
34249
  return db ?? getAnalyticsPool();
34139
34250
  }
34140
34251
  function analyticsCrmRequestFingerprint(input) {
34141
- return createHash17("sha256").update(JSON.stringify(input)).digest("hex");
34252
+ return createHash18("sha256").update(JSON.stringify(input)).digest("hex");
34142
34253
  }
34143
34254
  async function requireConnection(input) {
34144
34255
  const result3 = await dbOrDefault(input.db).query(
@@ -34194,7 +34305,7 @@ async function persistAnalyticsCrmProvisioningPlan(input) {
34194
34305
  created_by_user_id,public_plan_id,schema_fingerprint,request_fingerprint,created_at,updated_at
34195
34306
  ) VALUES($1,$2,$3,$4,1,$5,$6::jsonb,'preview',$7,$8,$9,$10,$11,$11)`,
34196
34307
  [
34197
- randomUUID21(),
34308
+ randomUUID22(),
34198
34309
  input.siteId,
34199
34310
  connectionId,
34200
34311
  plan.provider,
@@ -34248,7 +34359,7 @@ async function persistAnalyticsCrmProvisioningReceipt(input) {
34248
34359
  ) VALUES($1,$2,$3,$4,$5,'[]'::jsonb,$6,$7,$8::jsonb)
34249
34360
  ON CONFLICT (public_receipt_id) WHERE public_receipt_id IS NOT NULL
34250
34361
  DO UPDATE SET operation=EXCLUDED.operation,status=EXCLUDED.status,safe_error_code=EXCLUDED.safe_error_code,receipt=EXCLUDED.receipt`,
34251
- [randomUUID21(), plan.rows[0].id, operation, status, receipt4.errorCode ?? null, receipt4.occurredAt, receipt4.receiptId, JSON.stringify(receipt4)]
34362
+ [randomUUID22(), plan.rows[0].id, operation, status, receipt4.errorCode ?? null, receipt4.occurredAt, receipt4.receiptId, JSON.stringify(receipt4)]
34252
34363
  );
34253
34364
  await db.query(
34254
34365
  `UPDATE analytics_crm_provisioning_plans
@@ -34374,7 +34485,7 @@ async function scheduleAnalyticsCrmSyncRun(input) {
34374
34485
  next_attempt_at=CASE WHEN analytics_reconciliation_jobs.status='leased'
34375
34486
  THEN analytics_reconciliation_jobs.next_attempt_at ELSE EXCLUDED.next_attempt_at END,
34376
34487
  updated_at=now()`,
34377
- [randomUUID21(), input.connectionId, input.nextRunAt]
34488
+ [randomUUID22(), input.connectionId, input.nextRunAt]
34378
34489
  );
34379
34490
  }
34380
34491
  return true;
@@ -34446,7 +34557,7 @@ async function completeAnalyticsCrmInboundPage(input) {
34446
34557
  `INSERT INTO analytics_crm_sync_receipts(
34447
34558
  id,site_id,connection_id,direction,operation,subject_ref,external_receipt_id,status,occurred_at
34448
34559
  ) VALUES($1,$2,$3,'inbound','historical_pull',NULL,$4,'accepted',now())`,
34449
- [randomUUID21(), input.siteId, input.connectionId, input.receiptFingerprint]
34560
+ [randomUUID22(), input.siteId, input.connectionId, input.receiptFingerprint]
34450
34561
  );
34451
34562
  }
34452
34563
  async function deferAnalyticsCrmInboundPage(input) {
@@ -34474,7 +34585,7 @@ async function deferAnalyticsCrmInboundPage(input) {
34474
34585
  `INSERT INTO analytics_crm_sync_receipts(
34475
34586
  id,site_id,connection_id,direction,operation,subject_ref,external_receipt_id,status,safe_error_code,occurred_at
34476
34587
  ) VALUES($1,$2,$3,'inbound','historical_pull',NULL,$4,$5,$6,now())`,
34477
- [randomUUID21(), input.siteId, input.connectionId, input.receiptFingerprint, status, input.safeErrorCode]
34588
+ [randomUUID22(), input.siteId, input.connectionId, input.receiptFingerprint, status, input.safeErrorCode]
34478
34589
  );
34479
34590
  }
34480
34591
  function projectOutboundPolicy(row) {
@@ -34646,7 +34757,7 @@ async function claimAnalyticsCrmOutboundJobs(input) {
34646
34757
  await dbOrDefault(input.db).query(
34647
34758
  `INSERT INTO analytics_crm_outbound_attempts(id,job_id,attempt,status,started_at)
34648
34759
  VALUES($1,$2,$3,'started',now()) ON CONFLICT(job_id,attempt) DO NOTHING`,
34649
- [randomUUID21(), row.job_id, Number(row.attempts)]
34760
+ [randomUUID22(), row.job_id, Number(row.attempts)]
34650
34761
  );
34651
34762
  }
34652
34763
  return result3.rows.map((row) => ({
@@ -34749,7 +34860,7 @@ async function settleAnalyticsCrmOutboundJob(input) {
34749
34860
  await db.query(
34750
34861
  `INSERT INTO analytics_crm_outbound_attempts(id,job_id,attempt,status,safe_error_code,completed_at)
34751
34862
  VALUES($1,$2,$3,$4,$5,now()) ON CONFLICT(job_id,attempt) DO UPDATE SET status=EXCLUDED.status,safe_error_code=EXCLUDED.safe_error_code,completed_at=now()`,
34752
- [randomUUID21(), input.jobId, attempt, input.status === "accepted" ? "accepted" : state2 === "retrying" ? "retrying" : "failed", input.safeErrorCode ?? null]
34863
+ [randomUUID22(), input.jobId, attempt, input.status === "accepted" ? "accepted" : state2 === "retrying" ? "retrying" : "failed", input.safeErrorCode ?? null]
34753
34864
  );
34754
34865
  await db.query(
34755
34866
  `INSERT INTO analytics_crm_outbound_receipts(receipt_id,job_id,status,external_receipt_id,safe_error_code)
@@ -34785,7 +34896,7 @@ async function listAnalyticsCrmOutboundReceipts(input) {
34785
34896
  }
34786
34897
 
34787
34898
  // src/api/analytics-crm-provisioning.ts
34788
- import { createHash as createHash18 } from "crypto";
34899
+ import { createHash as createHash19 } from "crypto";
34789
34900
 
34790
34901
  // src/api/analytics-crm-provider-contract.ts
34791
34902
  var ANALYTICS_CRM_PROVIDER_IDS = [
@@ -35156,10 +35267,10 @@ var XRAY_FIELDS = [
35156
35267
  { internalName: "xray_consent_receipt_ref", label: "X-Ray Consent Receipt", type: "string", writable: true }
35157
35268
  ];
35158
35269
  function stableId(prefix, input) {
35159
- return `${prefix}_${createHash18("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24)}`;
35270
+ return `${prefix}_${createHash19("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24)}`;
35160
35271
  }
35161
35272
  function fingerprint2(input) {
35162
- return createHash18("sha256").update(JSON.stringify(input)).digest("hex");
35273
+ return createHash19("sha256").update(JSON.stringify(input)).digest("hex");
35163
35274
  }
35164
35275
  function analyticsCrmSchemaFingerprint(fields) {
35165
35276
  return fingerprint2([...fields].sort(
@@ -35566,7 +35677,7 @@ var OutboundPayloadSchema = z33.object({
35566
35677
  }).strict().nullable()
35567
35678
  }).strict();
35568
35679
  function id(prefix, input) {
35569
- return `${prefix}_${createHash19("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24)}`;
35680
+ return `${prefix}_${createHash20("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24)}`;
35570
35681
  }
35571
35682
  function pathOnly(value) {
35572
35683
  const normalized = normalizeAnalyticsUrl(value);
@@ -35774,7 +35885,7 @@ async function drainAnalyticsCrmOutbound(limit = 10, deadlineMs = Date.now() + D
35774
35885
  }
35775
35886
 
35776
35887
  // src/api/analytics-lead-scoring.ts
35777
- import { createHash as createHash20, randomUUID as randomUUID22 } from "crypto";
35888
+ import { createHash as createHash21, randomUUID as randomUUID23 } from "crypto";
35778
35889
  import { z as z34 } from "zod";
35779
35890
  var SafeIdentifierSchema = z34.string().trim().min(1).max(160).regex(/^[a-zA-Z0-9_.:-]+$/);
35780
35891
  var PropertyNameSchema = z34.string().trim().min(1).max(160).regex(/^[a-zA-Z][a-zA-Z0-9_.:-]*$/);
@@ -35892,11 +36003,11 @@ function predicateEvidence(predicate, facts, evaluatedAt) {
35892
36003
  }
35893
36004
  function stableFingerprint(value) {
35894
36005
  const normalize = (input) => Array.isArray(input) ? input.map(normalize) : input && typeof input === "object" ? Object.fromEntries(Object.entries(input).sort(([a], [b]) => a.localeCompare(b)).map(([property, nested]) => [property, normalize(nested)])) : input;
35895
- return createHash20("sha256").update(JSON.stringify(normalize(value))).digest("hex");
36006
+ return createHash21("sha256").update(JSON.stringify(normalize(value))).digest("hex");
35896
36007
  }
35897
36008
  function createAnalyticsLeadScore(input) {
35898
36009
  const parsed = ScoreDefinitionInputSchema.parse(input.definition);
35899
- const id2 = input.id ?? randomUUID22();
36010
+ const id2 = input.id ?? randomUUID23();
35900
36011
  if (input.tables.definitions.has(key(parsed.namespaceId, id2))) throw new AnalyticsLeadScoringError("analytics_score_exists", "A lead score with this ID already exists.");
35901
36012
  const timestamp5 = nowIso(input.now);
35902
36013
  const definition = { id: id2, ...parsed, groups: parsed.groups.map((group) => ({ ...group, predicates: group.predicates.map((predicate) => ({ ...predicate })) })), version: 1, createdAt: timestamp5, updatedAt: timestamp5 };
@@ -35932,7 +36043,7 @@ function evaluateAnalyticsLeadScore(input) {
35932
36043
  const idempotencyKey4 = stableFingerprint({ namespaceId: input.namespaceId, scoreId: input.scoreId, version: definition.version, subjectRef: input.subjectRef, identityTier: input.identityTier, components, value });
35933
36044
  const existing = input.tables.evaluations.get(idempotencyKey4);
35934
36045
  if (existing) return { ...existing, components: existing.components.map((component) => ({ ...component, evidenceRefs: [...component.evidenceRefs] })), evidenceRefs: [...existing.evidenceRefs] };
35935
- const evaluation = { id: randomUUID22(), namespaceId: input.namespaceId, subjectRef: input.subjectRef, identityTier: input.identityTier, scoreId: definition.id, scoreVersion: definition.version, scoreKind: definition.kind, value, components, evidenceRefs, evaluatedAt, idempotencyKey: idempotencyKey4, providerEligible: input.identityTier === "confirmed" };
36046
+ const evaluation = { id: randomUUID23(), namespaceId: input.namespaceId, subjectRef: input.subjectRef, identityTier: input.identityTier, scoreId: definition.id, scoreVersion: definition.version, scoreKind: definition.kind, value, components, evidenceRefs, evaluatedAt, idempotencyKey: idempotencyKey4, providerEligible: input.identityTier === "confirmed" };
35936
36047
  input.tables.evaluations.set(idempotencyKey4, evaluation);
35937
36048
  input.tables.evaluationHistory.push(evaluation);
35938
36049
  return { ...evaluation, components: evaluation.components.map((component) => ({ ...component, evidenceRefs: [...component.evidenceRefs] })), evidenceRefs: [...evaluation.evidenceRefs] };
@@ -36164,7 +36275,7 @@ function normalizeTwilioWebhook(input) {
36164
36275
  }
36165
36276
 
36166
36277
  // src/api/analytics-session-reports.ts
36167
- import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, createHash as createHash21, createHmac as createHmac7 } from "crypto";
36278
+ import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, createHash as createHash22, createHmac as createHmac7 } from "crypto";
36168
36279
  var prefixes = {
36169
36280
  session: "xrs_",
36170
36281
  visitor: "xrv_",
@@ -36173,7 +36284,7 @@ var prefixes = {
36173
36284
  candidate: "xri_"
36174
36285
  };
36175
36286
  function reportKey(purpose) {
36176
- return createHash21("sha256").update(`xray-report:${purpose}:`).update(getSessionSecret()).digest();
36287
+ return createHash22("sha256").update(`xray-report:${purpose}:`).update(getSessionSecret()).digest();
36177
36288
  }
36178
36289
  function createAnalyticsReportReference(kind, siteId, value) {
36179
36290
  const key3 = reportKey("reference");
@@ -36880,7 +36991,7 @@ async function analyticsInferenceReview(input, db = getAnalyticsPool()) {
36880
36991
  }
36881
36992
 
36882
36993
  // src/api/analytics-providers/crm.ts
36883
- import { createHash as createHash22, createVerify, verify } from "crypto";
36994
+ import { createHash as createHash23, createVerify, verify } from "crypto";
36884
36995
  function verifyHubSpotWebhook(input) {
36885
36996
  if (!webhookTimestampFresh(input.timestamp, input.now)) return false;
36886
36997
  const source = `${input.method.toUpperCase()}${input.url}${input.rawBody}${input.timestamp}`;
@@ -36919,7 +37030,7 @@ function verifyHighLevelWebhook(input) {
36919
37030
  function crmStageToExternalEvent(event2) {
36920
37031
  return {
36921
37032
  schemaVersion: 1,
36922
- eventId: `crm_${createHash22("sha256").update(`${event2.source}:${event2.sourceEventId}`).digest("hex").slice(0, 24)}`,
37033
+ eventId: `crm_${createHash23("sha256").update(`${event2.source}:${event2.sourceEventId}`).digest("hex").slice(0, 24)}`,
36923
37034
  sourceEventId: event2.sourceEventId,
36924
37035
  source: event2.source,
36925
37036
  sourceAccountRef: event2.sourceAccountRef,
@@ -37158,7 +37269,7 @@ async function createAnalyticsEventDefinition(input) {
37158
37269
  status=EXCLUDED.status, version=analytics_event_definitions.version+1, updated_at=now()
37159
37270
  RETURNING id, name, event_name, trigger_kind, definition, version, status, created_at, updated_at`,
37160
37271
  [
37161
- randomUUID23(),
37272
+ randomUUID24(),
37162
37273
  input.siteId,
37163
37274
  definition.name,
37164
37275
  definition.eventName,
@@ -37340,7 +37451,7 @@ async function createAnalyticsConnection(input) {
37340
37451
  (secret_ciphertext IS NOT NULL) AS webhook_secret_configured,
37341
37452
  created_at, updated_at`,
37342
37453
  [
37343
- randomUUID23(),
37454
+ randomUUID24(),
37344
37455
  input.siteId,
37345
37456
  input.provider.trim().toLowerCase().slice(0, 80),
37346
37457
  input.name.trim().slice(0, 120),
@@ -37554,7 +37665,7 @@ async function describeAnalyticsConnectionReconciliation(input) {
37554
37665
  };
37555
37666
  }
37556
37667
  async function recordAnalyticsWebhookReceipt(input) {
37557
- const id2 = randomUUID23();
37668
+ const id2 = randomUUID24();
37558
37669
  const payloadCiphertext = input.rawBody ? encryptAnalyticsRestricted(input.rawBody, "webhook-payload") : null;
37559
37670
  const result3 = await getAnalyticsPool().query(
37560
37671
  `INSERT INTO analytics_webhook_receipts(
@@ -37642,7 +37753,7 @@ async function createAnalyticsConversionRule(input) {
37642
37753
  updated_at = now()
37643
37754
  RETURNING *`,
37644
37755
  [
37645
- randomUUID23(),
37756
+ randomUUID24(),
37646
37757
  input.siteId,
37647
37758
  parsed.name,
37648
37759
  parsed.conversionKind,
@@ -38028,7 +38139,7 @@ async function recordAnalyticsExternalEvent(input) {
38028
38139
  ON CONFLICT(site_id, source, source_account_ref, source_event_id) DO NOTHING
38029
38140
  RETURNING id`,
38030
38141
  [
38031
- randomUUID23(),
38142
+ randomUUID24(),
38032
38143
  input.siteId,
38033
38144
  // This FK targets analytics_webhook_receipts. Consent receipts are
38034
38145
  // separate evidence and remain in eligibility/activation payloads.
@@ -38101,7 +38212,7 @@ async function recordAnalyticsExternalEvent(input) {
38101
38212
  const storedValueMinor = resolvedValue.valueMinor ?? 0;
38102
38213
  const storedCurrency = (resolvedValue.currency || rule.default_currency || "USD").toUpperCase();
38103
38214
  const valueSource = resolvedValue.provenance.resolution === "absent" ? "absent" : resolvedValue.provenance.resolution === "fallback" ? "dynamic" : resolvedValue.provenance.resolution;
38104
- const conversionId = randomUUID23();
38215
+ const conversionId = randomUUID24();
38105
38216
  const result3 = await client2.query(
38106
38217
  `INSERT INTO analytics_conversions(
38107
38218
  id, source_event_id, site_id, session_id, conversion_kind,
@@ -38173,7 +38284,7 @@ async function recordAnalyticsExternalEvent(input) {
38173
38284
  id, destination_id, conversion_id, person_id, payload_ciphertext
38174
38285
  ) VALUES ($1,$2,$3,$4,$5)
38175
38286
  ON CONFLICT(destination_id, conversion_id) DO NOTHING`,
38176
- [randomUUID23(), destination.id, result3.rows[0].id, personId, payload]
38287
+ [randomUUID24(), destination.id, result3.rows[0].id, personId, payload]
38177
38288
  );
38178
38289
  }
38179
38290
  }
@@ -38742,9 +38853,8 @@ async function resolveUser2(customerId, emailFallback) {
38742
38853
  // src/api/oauth-routes.ts
38743
38854
  import { Hono as Hono28 } from "hono";
38744
38855
  import { getCookie, setCookie } from "hono/cookie";
38745
- import { createHash as createHash24, randomBytes as randomBytes3, randomUUID as randomUUID24 } from "crypto";
38746
- import { importPKCS8, exportJWK, SignJWT } from "jose";
38747
- var ISSUER = "https://mcpscraper.dev";
38856
+ import { createHash as createHash25, randomBytes as randomBytes3 } from "crypto";
38857
+ var ISSUER = OAUTH_ISSUER;
38748
38858
  var RESOURCE = () => process.env.MCP_MEMORY_RESOURCE_URL ?? "https://memory.mcpscraper.dev/mcp";
38749
38859
  var SCRAPER_RESOURCE = () => (process.env.MCP_SCRAPER_RESOURCE_URL ?? "https://mcpscraper.dev/mcp").replace(/\/$/, "");
38750
38860
  var MEMORY_SCOPES = ["memory.read", "memory.write", "memory.admin"];
@@ -38791,22 +38901,6 @@ var sessionCookieOptions = {
38791
38901
  maxAge: 60 * 60 * 24 * 30,
38792
38902
  sameSite: "Lax"
38793
38903
  };
38794
- var cachedKeys = null;
38795
- async function getKeys() {
38796
- if (cachedKeys) return cachedKeys;
38797
- const raw = process.env.OAUTH_SIGNING_KEY;
38798
- if (!raw?.trim()) throw new Error("OAUTH_SIGNING_KEY is not set");
38799
- const pem = raw.includes("BEGIN") ? raw : Buffer.from(raw, "base64").toString("utf8");
38800
- const privateKey = await importPKCS8(pem, "RS256", { extractable: true });
38801
- const full = await exportJWK(privateKey);
38802
- const publicJwk = { kty: full.kty, n: full.n, e: full.e };
38803
- const kid = createHash24("sha256").update(JSON.stringify({ e: publicJwk.e, kty: publicJwk.kty, n: publicJwk.n })).digest("base64url").slice(0, 16);
38804
- publicJwk.kid = kid;
38805
- publicJwk.alg = "RS256";
38806
- publicJwk.use = "sig";
38807
- cachedKeys = { privateKey, publicJwk, kid };
38808
- return cachedKeys;
38809
- }
38810
38904
  function isAllowedRedirect(uri) {
38811
38905
  let u;
38812
38906
  try {
@@ -38992,7 +39086,7 @@ oauthApp.get("/.well-known/openid-configuration/*", (c) => {
38992
39086
  return c.json(openidConfiguration());
38993
39087
  });
38994
39088
  oauthApp.get("/.well-known/jwks.json", async (c) => {
38995
- const { publicJwk } = await getKeys();
39089
+ const publicJwk = await getOAuthPublicJwk();
38996
39090
  c.header("Cache-Control", "public, max-age=3600");
38997
39091
  return c.json({ keys: [publicJwk] });
38998
39092
  });
@@ -39122,12 +39216,11 @@ oauthApp.post("/oauth/authorize", async (c) => {
39122
39216
  });
39123
39217
  function pkceMatches(verifier, challenge) {
39124
39218
  if (!verifier) return false;
39125
- const computed = createHash24("sha256").update(verifier).digest("base64url");
39219
+ const computed = createHash25("sha256").update(verifier).digest("base64url");
39126
39220
  return computed === challenge;
39127
39221
  }
39128
39222
  async function mintAccessToken(identity, scope, plan, audience) {
39129
- const { privateKey, kid } = await getKeys();
39130
- return new SignJWT({ scope, plan }).setProtectedHeader({ alg: "RS256", kid }).setIssuer(ISSUER).setSubject(identity).setAudience(audience).setIssuedAt().setJti(randomUUID24()).setExpirationTime(`${ACCESS_TTL_SECONDS}s`).sign(privateKey);
39223
+ return mintOAuthAccessToken({ identity, scope, plan, audience, ttlSeconds: ACCESS_TTL_SECONDS });
39131
39224
  }
39132
39225
  function tokenErrorResponse(c, error, description, status) {
39133
39226
  return c.json({ error, error_description: description }, status);
@@ -40602,7 +40695,7 @@ import { Hono as Hono32 } from "hono";
40602
40695
  import { Resend } from "resend";
40603
40696
 
40604
40697
  // src/api/resend-support-thread.ts
40605
- import { createHash as createHash25 } from "crypto";
40698
+ import { createHash as createHash26 } from "crypto";
40606
40699
  var SUPPORT_TAGS = [
40607
40700
  {
40608
40701
  tag: "support",
@@ -40642,7 +40735,7 @@ function quoteUntrusted(value) {
40642
40735
  return clean3.split("\n").map((line) => `> ${line}`).join("\n");
40643
40736
  }
40644
40737
  function shortHash(value, length = 24) {
40645
- return createHash25("sha256").update(value).digest("hex").slice(0, length);
40738
+ return createHash26("sha256").update(value).digest("hex").slice(0, length);
40646
40739
  }
40647
40740
  function safePathPart(value) {
40648
40741
  return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48) || "contact";
@@ -42141,7 +42234,7 @@ import { Hono as Hono34 } from "hono";
42141
42234
  import { z as z36 } from "zod";
42142
42235
 
42143
42236
  // src/editorial-reading-room/render.ts
42144
- import { createHash as createHash26 } from "crypto";
42237
+ import { createHash as createHash27 } from "crypto";
42145
42238
  import { readFileSync as readFileSync3 } from "fs";
42146
42239
  import { dirname as dirname3, join as join8, resolve } from "path";
42147
42240
  import { Marked, Renderer } from "marked";
@@ -42302,7 +42395,7 @@ function renderEditorialReadingRoom(input, now = /* @__PURE__ */ new Date()) {
42302
42395
  articleCount: articles.length,
42303
42396
  wordCount: totalWordCount,
42304
42397
  bytes: bytes2,
42305
- sha256: createHash26("sha256").update(html).digest("hex"),
42398
+ sha256: createHash27("sha256").update(html).digest("hex"),
42306
42399
  warnings
42307
42400
  };
42308
42401
  }
@@ -42385,7 +42478,7 @@ ${provenance}`;
42385
42478
  ...rendered,
42386
42479
  html,
42387
42480
  bytes: Buffer.byteLength(html),
42388
- sha256: createHash26("sha256").update(html).digest("hex")
42481
+ sha256: createHash27("sha256").update(html).digest("hex")
42389
42482
  };
42390
42483
  }
42391
42484
 
@@ -42508,10 +42601,10 @@ import { Hono as Hono35 } from "hono";
42508
42601
  import { z as z37 } from "zod";
42509
42602
 
42510
42603
  // src/api/commons-repository.ts
42511
- import { createHash as createHash29, randomUUID as randomUUID26 } from "crypto";
42604
+ import { createHash as createHash30, randomUUID as randomUUID26 } from "crypto";
42512
42605
 
42513
42606
  // src/api/commons-image-store.ts
42514
- import { createHash as createHash27 } from "crypto";
42607
+ import { createHash as createHash28 } from "crypto";
42515
42608
  import { lookup as dnsLookup } from "dns/promises";
42516
42609
  import { isIP } from "net";
42517
42610
  var COMMONS_IMAGE_MAX_BYTES = 10 * 1024 * 1024;
@@ -42841,7 +42934,7 @@ async function hostCommonsImage(input) {
42841
42934
  415
42842
42935
  );
42843
42936
  }
42844
- const digest23 = createHash27("sha256").update(bytes2).digest("hex");
42937
+ const digest23 = createHash28("sha256").update(bytes2).digest("hex");
42845
42938
  const existing = await getDb().execute({
42846
42939
  sql: "SELECT id, url, content_type, bytes, source_url FROM commons_images WHERE digest = ? LIMIT 1",
42847
42940
  args: [digest23]
@@ -42973,7 +43066,7 @@ async function schemaObjectsPresent(names) {
42973
43066
  }
42974
43067
 
42975
43068
  // src/api/commons-linksets.ts
42976
- import { createHash as createHash28 } from "crypto";
43069
+ import { createHash as createHash29 } from "crypto";
42977
43070
  var COMMONS_LINKSET_MEDIA_TYPE = "application/linkset+json";
42978
43071
  var COMMONS_RELATIONSHIP_PROFILE = "https://mcpscraper.dev/commons/profiles/relationships/v1";
42979
43072
  var REGISTERED_RELATIONS = /* @__PURE__ */ new Set([
@@ -43080,7 +43173,7 @@ function buildCommonsLinkset(entity, claims) {
43080
43173
  context[claim.predicate] = targets;
43081
43174
  }
43082
43175
  const document2 = { linkset: [context] };
43083
- const etag = `"${createHash28("sha256").update(JSON.stringify(document2)).digest("hex")}"`;
43176
+ const etag = `"${createHash29("sha256").update(JSON.stringify(document2)).digest("hex")}"`;
43084
43177
  return { document: document2, etag, publicUrl, linksetUrl, profile: COMMONS_RELATIONSHIP_PROFILE };
43085
43178
  }
43086
43179
  function commonsLinksetDiscoveryHeader(idOrSlug) {
@@ -44893,7 +44986,7 @@ function commonsIndexDocuments(entity, now) {
44893
44986
  return documents;
44894
44987
  }
44895
44988
  function commonsIndexDocumentId(entityId, documentType, documentKey) {
44896
- return `commons-index-${createHash29("sha256").update(`${entityId}
44989
+ return `commons-index-${createHash30("sha256").update(`${entityId}
44897
44990
  ${documentType}
44898
44991
  ${documentKey}`).digest("hex").slice(0, 32)}`;
44899
44992
  }
@@ -45471,7 +45564,7 @@ var CommonsRepositoryError = class extends Error {
45471
45564
  };
45472
45565
 
45473
45566
  // src/api/commons-publication-repository.ts
45474
- import { createHash as createHash30, randomUUID as randomUUID27 } from "crypto";
45567
+ import { createHash as createHash31, randomUUID as randomUUID27 } from "crypto";
45475
45568
 
45476
45569
  // src/editorial-reading-room/article-page.ts
45477
45570
  function escapeHtml6(value) {
@@ -45760,7 +45853,7 @@ async function publishCommonsEditorial(input, user) {
45760
45853
  JSON.stringify(editionInput.articles),
45761
45854
  html,
45762
45855
  rendered.filename,
45763
- createHash30("sha256").update(html).digest("hex"),
45856
+ createHash31("sha256").update(html).digest("hex"),
45764
45857
  rendered.articleCount,
45765
45858
  rendered.wordCount,
45766
45859
  Buffer.byteLength(html),
@@ -45842,7 +45935,7 @@ async function updateCommonsEditorialArticle(input, user) {
45842
45935
  JSON.stringify(nextArticles),
45843
45936
  html,
45844
45937
  rendered.filename,
45845
- createHash30("sha256").update(html).digest("hex"),
45938
+ createHash31("sha256").update(html).digest("hex"),
45846
45939
  rendered.articleCount,
45847
45940
  rendered.wordCount,
45848
45941
  Buffer.byteLength(html),
@@ -46665,11 +46758,11 @@ function xmlEscape(value) {
46665
46758
  import { Hono as Hono36 } from "hono";
46666
46759
  import { createMiddleware as createMiddleware4 } from "hono/factory";
46667
46760
  import { z as z43 } from "zod";
46668
- import { createHash as createHash43, randomUUID as randomUUID38 } from "crypto";
46761
+ import { createHash as createHash44, randomUUID as randomUUID38 } from "crypto";
46669
46762
  import Papa5 from "papaparse";
46670
46763
 
46671
46764
  // src/api/analytics-manual-imports.ts
46672
- import { createHash as createHash31 } from "crypto";
46765
+ import { createHash as createHash32 } from "crypto";
46673
46766
  import Papa4 from "papaparse";
46674
46767
  import { z as z38 } from "zod";
46675
46768
  var AnalyticsManualImportMappingSchema = z38.object({
@@ -46764,7 +46857,7 @@ function previewAnalyticsManualImport(input) {
46764
46857
  continue;
46765
46858
  }
46766
46859
  identities.add(identityKey2);
46767
- const digest23 = createHash31("sha256").update(`${parsedInput.sourceSystem}:${stableIdentity}`).digest("hex");
46860
+ const digest23 = createHash32("sha256").update(`${parsedInput.sourceSystem}:${stableIdentity}`).digest("hex");
46768
46861
  const crmEntityId = `${digest23.slice(0, 8)}-${digest23.slice(8, 12)}-5${digest23.slice(13, 16)}-${(Number.parseInt(digest23.slice(16, 18), 16) & 63 | 128).toString(16)}${digest23.slice(18, 20)}-${digest23.slice(20, 32)}`;
46769
46862
  rows.push({
46770
46863
  row: rowNumber,
@@ -46786,7 +46879,7 @@ function previewAnalyticsManualImport(input) {
46786
46879
  });
46787
46880
  }
46788
46881
  const headers = parsed.meta.fields ?? [];
46789
- const fingerprint5 = createHash31("sha256").update(canonical({ sourceSystem: parsedInput.sourceSystem, filename: parsedInput.filename, mapping: parsedInput.mapping, rows })).digest("hex");
46882
+ const fingerprint5 = createHash32("sha256").update(canonical({ sourceSystem: parsedInput.sourceSystem, filename: parsedInput.filename, mapping: parsedInput.mapping, rows })).digest("hex");
46790
46883
  return {
46791
46884
  schemaVersion: 1,
46792
46885
  fingerprint: fingerprint5,
@@ -46801,7 +46894,7 @@ function previewAnalyticsManualImport(input) {
46801
46894
  };
46802
46895
  }
46803
46896
  function deterministicAnalyticsManualImportId(input) {
46804
- const hex = createHash31("sha256").update(`${input.siteId}:${input.userId}:${input.idempotencyKey}:${input.fingerprint}`).digest("hex");
46897
+ const hex = createHash32("sha256").update(`${input.siteId}:${input.userId}:${input.idempotencyKey}:${input.fingerprint}`).digest("hex");
46805
46898
  return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-4${hex.slice(13, 16)}-a${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
46806
46899
  }
46807
46900
 
@@ -46971,7 +47064,7 @@ function consumeAnalyticsLinkerToken(input) {
46971
47064
  }
46972
47065
 
46973
47066
  // src/api/nango-control.ts
46974
- import { createHash as createHash32, randomUUID as randomUUID29 } from "crypto";
47067
+ import { createHash as createHash33, randomUUID as randomUUID29 } from "crypto";
46975
47068
 
46976
47069
  // src/api/connected-data-export.ts
46977
47070
  import { randomUUID as randomUUID28 } from "crypto";
@@ -48352,8 +48445,8 @@ async function setScheduleConnectionActionsEnabled(identity, connectionId, enabl
48352
48445
  return data.connection.actionsEnabled === true;
48353
48446
  }
48354
48447
  async function callScheduleConnectionAction(identity, connectionId, input, tool, idempotencyKey4) {
48355
- const requestId = `main-connected-action:${createHash32("sha256").update(identity).update("\0").update(idempotencyKey4?.trim() || randomUUID29()).digest("hex")}`;
48356
- const requestDigest2 = createHash32("sha256").update(connectionId).update("\0").update(tool?.trim() ?? "").update("\0").update(canonicalJson(input)).digest("hex");
48448
+ const requestId = `main-connected-action:${createHash33("sha256").update(identity).update("\0").update(idempotencyKey4?.trim() || randomUUID29()).digest("hex")}`;
48449
+ const requestDigest2 = createHash33("sha256").update(connectionId).update("\0").update(tool?.trim() ?? "").update("\0").update(canonicalJson(input)).digest("hex");
48357
48450
  if (mainOwnsIntegrations()) {
48358
48451
  const selectedTool = tool?.trim();
48359
48452
  if (!selectedTool) throw new NangoControlError("An action tool is required.", 400, "invalid_request", false);
@@ -48504,7 +48597,7 @@ function canonicalJson(value) {
48504
48597
  return JSON.stringify(value);
48505
48598
  }
48506
48599
  function projectedToolSchemaHash(tool) {
48507
- return createHash32("sha256").update(canonicalJson(tool)).digest("hex");
48600
+ return createHash33("sha256").update(canonicalJson(tool)).digest("hex");
48508
48601
  }
48509
48602
  async function describeNangoTool(identity, connectionId, tool, fresh) {
48510
48603
  if (mainOwnsIntegrations()) {
@@ -48695,9 +48788,9 @@ async function callMainOwnedExportPage(identity, input) {
48695
48788
  });
48696
48789
  }
48697
48790
  if (connection.providerConfigKey === "google-mail" && input.dataset === "emails") {
48698
- const { GmailService: GmailService2 } = await import("./gmail-service-BUSU4BVX.js");
48791
+ const { GmailService: GmailService2 } = await import("./gmail-service-E6ALS7JG.js");
48699
48792
  const service = new GmailService2();
48700
- const ownerId3 = createHash32("sha256").update(identity.toLowerCase()).digest("hex").slice(0, 24);
48793
+ const ownerId3 = createHash33("sha256").update(identity.toLowerCase()).digest("hex").slice(0, 24);
48701
48794
  const after = Math.floor(Date.parse(input.from) / 1e3);
48702
48795
  const before = Math.ceil(Date.parse(input.to) / 1e3);
48703
48796
  if (!Number.isFinite(after) || !Number.isFinite(before) || after >= before) throw new NangoControlError("Gmail export range is invalid.", 400, "invalid_request", false);
@@ -48938,7 +49031,7 @@ async function discoverAnalyticsActivationAssets(input) {
48938
49031
 
48939
49032
  // src/api/analytics-entitlement.ts
48940
49033
  import {
48941
- createHash as createHash33,
49034
+ createHash as createHash34,
48942
49035
  createHmac as createHmac10,
48943
49036
  randomBytes as randomBytes4,
48944
49037
  timingSafeEqual as timingSafeEqual6
@@ -49153,7 +49246,7 @@ function dashboardCallbackUrl() {
49153
49246
  async function createThorbitConnectUrl(userId) {
49154
49247
  if (!bridgeConfigured()) throw new Error("Thorbit X-Ray account bridge is not configured");
49155
49248
  const state2 = randomBytes4(32).toString("base64url");
49156
- const stateHash = createHash33("sha256").update(state2).digest("hex");
49249
+ const stateHash = createHash34("sha256").update(state2).digest("hex");
49157
49250
  await getAnalyticsPool().query(
49158
49251
  `INSERT INTO analytics_thorbit_connect_states(state_hash,user_id,expires_at)
49159
49252
  VALUES ($1,$2,now()+interval '10 minutes')
@@ -49182,7 +49275,7 @@ function verifyThorbitAssertion(token7) {
49182
49275
  return parsed.data.entitlement;
49183
49276
  }
49184
49277
  async function consumeThorbitConnectCallback(input) {
49185
- const stateHash = createHash33("sha256").update(input.state).digest("hex");
49278
+ const stateHash = createHash34("sha256").update(input.state).digest("hex");
49186
49279
  const client2 = await getAnalyticsPool().connect();
49187
49280
  try {
49188
49281
  await client2.query("BEGIN");
@@ -49224,7 +49317,7 @@ async function disconnectAnalyticsEntitlement(userId) {
49224
49317
  }
49225
49318
 
49226
49319
  // src/api/analytics-onboarding.ts
49227
- import { createHash as createHash34 } from "crypto";
49320
+ import { createHash as createHash35 } from "crypto";
49228
49321
  var MINIMUM = "minimum_setup";
49229
49322
  var PRODUCTION = "production_readiness";
49230
49323
  var ADVANCED = "advanced_optimization";
@@ -49425,7 +49518,7 @@ var DEFAULT_PRESENTATION = {
49425
49518
  };
49426
49519
  function safeRef(kind, value) {
49427
49520
  if (typeof value !== "string" || !value) return null;
49428
- return `${kind}:${createHash34("sha256").update(value).digest("hex").slice(0, 16)}`;
49521
+ return `${kind}:${createHash35("sha256").update(value).digest("hex").slice(0, 16)}`;
49429
49522
  }
49430
49523
  function asIso(value) {
49431
49524
  if (!value) return null;
@@ -50011,11 +50104,11 @@ async function analyticsFunnel(input) {
50011
50104
  }
50012
50105
 
50013
50106
  // src/api/analytics-site-setup.ts
50014
- import { createHash as createHash38, randomUUID as randomUUID31 } from "crypto";
50107
+ import { createHash as createHash39, randomUUID as randomUUID31 } from "crypto";
50015
50108
  import { load } from "cheerio";
50016
50109
 
50017
50110
  // src/services/analytics-site-setup/action-candidates.ts
50018
- import { createHash as createHash35 } from "crypto";
50111
+ import { createHash as createHash36 } from "crypto";
50019
50112
  var FORBIDDEN_KEYS = /email|phone|name|address|message|query|token|secret|password|visitor|session|person|ip/i;
50020
50113
  var SENSITIVE_VALUE = /@|\b(?:\+?\d[\d\s().-]{7,}\d)\b|bearer\s|api[_-]?key/i;
50021
50114
  function slug3(value) {
@@ -50051,7 +50144,7 @@ function buildAnalyticsActionCandidates(inputs) {
50051
50144
  const exclusionReason = context.rejected ? "sensitive_context" : occurrenceOnly ? "occurrence_only" : input.confidence < 0.7 ? "low_confidence" : void 0;
50052
50145
  return {
50053
50146
  ...input,
50054
- candidateId: `candidate_${createHash35("sha256").update(stableKey).digest("hex").slice(0, 20)}`,
50147
+ candidateId: `candidate_${createHash36("sha256").update(stableKey).digest("hex").slice(0, 20)}`,
50055
50148
  eventName: slug3(`${input.action}_${input.destination ?? input.label}`),
50056
50149
  disposition: exclusionReason ? exclusionReason === "occurrence_only" ? "proposed" : "excluded" : "recommended",
50057
50150
  rationale: input.sourceComponent ? `Instrument the shared ${input.sourceComponent} component instead of repeated route instances.` : `Instrument the meaningful ${input.action} action at its owned source boundary.`,
@@ -50104,10 +50197,10 @@ function buildAnalyticsFirstAnswers(evidence, readiness2, thresholds = DEFAULT_F
50104
50197
  }
50105
50198
 
50106
50199
  // src/services/analytics-site-setup/improvement-loop.ts
50107
- import { createHash as createHash36 } from "crypto";
50200
+ import { createHash as createHash37 } from "crypto";
50108
50201
  function nextAnalyticsImprovement(input) {
50109
50202
  const eligible = input.backlog.filter((item) => item.revision === input.revision && !item.applied && !item.skipped).sort((a, b) => a.rank - b.rank || a.id.localeCompare(b.id))[0] ?? null;
50110
- const proposalId = `improve_${createHash36("sha256").update(`${input.setupId}:${input.revision}:${eligible?.id ?? "none"}`).digest("hex").slice(0, 20)}`;
50203
+ const proposalId = `improve_${createHash37("sha256").update(`${input.setupId}:${input.revision}:${eligible?.id ?? "none"}`).digest("hex").slice(0, 20)}`;
50111
50204
  if (!eligible) return { proposalId, revision: input.revision, action: "none", item: null, confirmationRequired: false, nextAction: "No eligible improvement remains on the active revision." };
50112
50205
  if (eligible.kind === "runtime_rule") return { proposalId, revision: input.revision, action: "publish_runtime_rule", item: eligible, confirmationRequired: true, nextAction: `Approve one bounded runtime-rule change for ${eligible.surfaceId ?? "the measured surface"}, then verify manifest convergence.` };
50113
50206
  if (eligible.kind === "selector_repair") return { proposalId, revision: input.revision, action: "repair_selector", item: eligible, confirmationRequired: true, nextAction: "Confirm the repaired selector, publish one manifest revision, then verify its bounded match count." };
@@ -50262,9 +50355,9 @@ function recommendAnalyticsOutcomePlan(evidence, preferred) {
50262
50355
  }
50263
50356
 
50264
50357
  // src/services/analytics-site-setup/site-inventory.ts
50265
- import { createHash as createHash37 } from "crypto";
50358
+ import { createHash as createHash38 } from "crypto";
50266
50359
  function stableFingerprint2(value) {
50267
- return createHash37("sha256").update(JSON.stringify(value)).digest("hex");
50360
+ return createHash38("sha256").update(JSON.stringify(value)).digest("hex");
50268
50361
  }
50269
50362
  function buildAnalyticsSiteInventory(input) {
50270
50363
  const diagnoses = [];
@@ -50372,7 +50465,7 @@ async function captureAnalyticsSiteSetupEvidence(input) {
50372
50465
  const requestedUrl = urls[index];
50373
50466
  const parsed = new URL(result3.finalUrl || requestedUrl, root);
50374
50467
  const path5 = parsed.pathname || "/";
50375
- const evidenceId = `live:${createHash38("sha256").update(`${requestedUrl}:${result3.status ?? "unreachable"}:${result3.html ? createHash38("sha256").update(result3.html).digest("hex") : "none"}`).digest("hex").slice(0, 24)}`;
50468
+ const evidenceId = `live:${createHash39("sha256").update(`${requestedUrl}:${result3.status ?? "unreachable"}:${result3.html ? createHash39("sha256").update(result3.html).digest("hex") : "none"}`).digest("hex").slice(0, 24)}`;
50376
50469
  if (result3.via === "browser") browserFallbacks += 1;
50377
50470
  if (!result3.html) {
50378
50471
  routes.push({ path: path5, canonicalUrl: parsed.href, surfaceId: "primary-unknown", reachable: false, pixelScripts: 0, pageViewsOnFirstLoad: 0, semanticTags: 0, evidenceIds: [evidenceId], pixelPublicIds: [], duplicatePageViewSource: false, consentMode: "unknown" });
@@ -50464,7 +50557,7 @@ async function captureAnalyticsSiteSetupEvidence(input) {
50464
50557
  }
50465
50558
  var ZERO_BILLING = { billingClass: "xray_entitlement", mcpScraperCreditsCharged: 0, providerCosts: [] };
50466
50559
  function fingerprint3(value) {
50467
- return createHash38("sha256").update(JSON.stringify(value)).digest("hex");
50560
+ return createHash39("sha256").update(JSON.stringify(value)).digest("hex");
50468
50561
  }
50469
50562
  function receipt(record7, operation, occurredAt, providerCosts = [], externalRef) {
50470
50563
  return {
@@ -50675,7 +50768,7 @@ var AnalyticsSiteSetupService = class {
50675
50768
  };
50676
50769
 
50677
50770
  // src/api/analytics-survey-attribution.ts
50678
- import { createHash as createHash39, randomBytes as randomBytes5, randomUUID as randomUUID32 } from "crypto";
50771
+ import { createHash as createHash40, randomBytes as randomBytes5, randomUUID as randomUUID32 } from "crypto";
50679
50772
  var CREDIT_SCALE = 1e6;
50680
50773
  var REPORTED_IMPACT_METHODOLOGY_VERSION = "xray_observed_plus_reported_equal_selected_v1";
50681
50774
  var TOKEN_BYTES = 32;
@@ -50742,10 +50835,10 @@ function stable(value) {
50742
50835
  return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key3, item]) => [key3, stable(item)]));
50743
50836
  }
50744
50837
  function fingerprint4(value) {
50745
- return createHash39("sha256").update(JSON.stringify(stable(value))).digest("hex");
50838
+ return createHash40("sha256").update(JSON.stringify(stable(value))).digest("hex");
50746
50839
  }
50747
50840
  function tokenDigest(value) {
50748
- return createHash39("sha256").update(value).digest("hex");
50841
+ return createHash40("sha256").update(value).digest("hex");
50749
50842
  }
50750
50843
  function opaqueToken(prefix) {
50751
50844
  return `${prefix}_${randomBytes5(TOKEN_BYTES).toString("base64url")}`;
@@ -51274,7 +51367,7 @@ function buildObservedPlusReportedImpact(input) {
51274
51367
  }
51275
51368
 
51276
51369
  // src/api/analytics-provider-view-evidence.ts
51277
- import { createHash as createHash40, randomUUID as randomUUID33 } from "crypto";
51370
+ import { createHash as createHash41, randomUUID as randomUUID33 } from "crypto";
51278
51371
  var ANALYTICS_VIEW_EVIDENCE_RESEARCH_DATE = "2026-09-01";
51279
51372
  var ANALYTICS_VIEW_EVIDENCE_PROVIDERS = [
51280
51373
  "meta",
@@ -51448,7 +51541,7 @@ var PostgresAnalyticsSiteSetupStore = class {
51448
51541
  };
51449
51542
 
51450
51543
  // src/api/analytics-product-health.ts
51451
- import { createHash as createHash41, randomUUID as randomUUID34 } from "crypto";
51544
+ import { createHash as createHash42, randomUUID as randomUUID34 } from "crypto";
51452
51545
  var ANALYTICS_PRODUCT_MILESTONES = [
51453
51546
  "xray_opened",
51454
51547
  "setup_started",
@@ -51475,7 +51568,7 @@ function asIso2(value) {
51475
51568
  }
51476
51569
  function safeReference(kind, value) {
51477
51570
  if (!value) return null;
51478
- return `${kind}:${createHash41("sha256").update(value).digest("hex").slice(0, 16)}`;
51571
+ return `${kind}:${createHash42("sha256").update(value).digest("hex").slice(0, 16)}`;
51479
51572
  }
51480
51573
  function numberValue(value) {
51481
51574
  const number = Number(value ?? 0);
@@ -52744,7 +52837,7 @@ async function drainAnalyticsPrivacyLifecycle(input = {}) {
52744
52837
  }
52745
52838
 
52746
52839
  // src/api/analytics-crm-sync.ts
52747
- import { createHash as createHash42 } from "crypto";
52840
+ import { createHash as createHash43 } from "crypto";
52748
52841
  var VERIFIED_READ_SCOPES = Object.freeze({
52749
52842
  hubspot: ["crm.objects.deals.read"],
52750
52843
  salesforce: ["api"],
@@ -52810,7 +52903,7 @@ async function previewAnalyticsCrmSync(input) {
52810
52903
  };
52811
52904
  }
52812
52905
  function stableId2(prefix, input) {
52813
- return `${prefix}_${createHash42("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24)}`;
52906
+ return `${prefix}_${createHash43("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24)}`;
52814
52907
  }
52815
52908
  function isRecord5(value) {
52816
52909
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
@@ -53175,7 +53268,7 @@ function analyticsSiteSetupService() {
53175
53268
  publishManifest: async ({ record: record7, idempotencyKey: idempotencyKey4 }) => {
53176
53269
  const hostname = new URL(record7.startUrl).hostname.toLowerCase().replace(/\.$/, "");
53177
53270
  const uuidFor = (value) => {
53178
- const hex = createHash43("sha256").update(`${record7.siteId}:${value}`).digest("hex").slice(0, 32).split("");
53271
+ const hex = createHash44("sha256").update(`${record7.siteId}:${value}`).digest("hex").slice(0, 32).split("");
53179
53272
  hex[12] = "4";
53180
53273
  hex[16] = ["8", "9", "a", "b"][Number.parseInt(hex[16], 16) % 4];
53181
53274
  return `${hex.slice(0, 8).join("")}-${hex.slice(8, 12).join("")}-${hex.slice(12, 16).join("")}-${hex.slice(16, 20).join("")}-${hex.slice(20).join("")}`;
@@ -53314,7 +53407,7 @@ function isRecord6(value) {
53314
53407
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
53315
53408
  }
53316
53409
  function analyticsPrivacyRequestFingerprint(siteId, operation, body3) {
53317
- return createHash43("sha256").update(canonicalRequest({ siteId, operation, body: { ...body3, idempotencyKey: void 0 } })).digest("hex");
53410
+ return createHash44("sha256").update(canonicalRequest({ siteId, operation, body: { ...body3, idempotencyKey: void 0 } })).digest("hex");
53318
53411
  }
53319
53412
  function privacyIdempotency(c, body3, siteId, operation) {
53320
53413
  const header = c.req.header("Idempotency-Key")?.trim();
@@ -54122,7 +54215,7 @@ analyticsApp.get("/v1/pixels/:publicPixelId/event-definitions", async (c) => {
54122
54215
  });
54123
54216
  });
54124
54217
  function deterministicRuntimeManifestId(siteId) {
54125
- const hex = createHash43("sha256").update(`xray-runtime-manifest:${siteId}`).digest("hex").slice(0, 32).split("");
54218
+ const hex = createHash44("sha256").update(`xray-runtime-manifest:${siteId}`).digest("hex").slice(0, 32).split("");
54126
54219
  hex[12] = "4";
54127
54220
  hex[16] = ["8", "9", "a", "b"][Number.parseInt(hex[16], 16) % 4];
54128
54221
  return `${hex.slice(0, 8).join("")}-${hex.slice(8, 12).join("")}-${hex.slice(12, 16).join("")}-${hex.slice(16, 20).join("")}-${hex.slice(20).join("")}`;
@@ -54500,7 +54593,7 @@ analyticsApp.post("/v1/events", async (c) => {
54500
54593
  if (rule.condition.eventName && rule.condition.eventName !== event2.eventName) continue;
54501
54594
  const tags = Array.isArray(event2.properties?.tags) ? event2.properties.tags.map(String) : [];
54502
54595
  if ((rule.condition.excludedTags ?? []).some((tag) => tags.includes(tag))) continue;
54503
- const sourceEventId = `browser-rule:${rule.id}:${createHash43("sha256").update(event2.eventId).digest("hex").slice(0, 32)}`;
54596
+ const sourceEventId = `browser-rule:${rule.id}:${createHash44("sha256").update(event2.eventId).digest("hex").slice(0, 32)}`;
54504
54597
  const valueMinor = Number(rule.default_value_minor ?? 0);
54505
54598
  await createAnalyticsConversion({
54506
54599
  userId: ownerUserId2,
@@ -54659,7 +54752,7 @@ analyticsApp.post("/v1/webhooks/:provider/:connectionId", async (c) => {
54659
54752
  connectionId: connection.id,
54660
54753
  provider,
54661
54754
  sourceAccountRef: connection.sourceAccountRef,
54662
- sourceEventId: `invalid:${createHash43("sha256").update(rawBody).digest("hex")}`,
54755
+ sourceEventId: `invalid:${createHash44("sha256").update(rawBody).digest("hex")}`,
54663
54756
  signatureStatus: "invalid"
54664
54757
  });
54665
54758
  await setAnalyticsConnectionReadiness({
@@ -55022,7 +55115,7 @@ function surveyPublicHeaders(c) {
55022
55115
  }
55023
55116
  function surveyRateLimit(c) {
55024
55117
  const networkRef = c.req.header("cf-connecting-ip") ?? c.req.header("x-forwarded-for")?.split(",")[0]?.trim() ?? "unknown";
55025
- const key3 = createHash43("sha256").update(`survey-exchange:${networkRef}`).digest("hex");
55118
+ const key3 = createHash44("sha256").update(`survey-exchange:${networkRef}`).digest("hex");
55026
55119
  const now = Date.now();
55027
55120
  const window2 = surveyExchangeRateWindows.get(key3);
55028
55121
  if (!window2 || now - window2.startedAt >= 6e4) {
@@ -55045,7 +55138,7 @@ function surveyCookie(c) {
55045
55138
  return { siteId, sessionToken };
55046
55139
  }
55047
55140
  async function approvedSurveyExchangeSite(exchangeCode, origin) {
55048
- const digest23 = createHash43("sha256").update(exchangeCode).digest("hex");
55141
+ const digest23 = createHash44("sha256").update(exchangeCode).digest("hex");
55049
55142
  const hostname = normalizeAnalyticsHostname(new URL(origin).hostname);
55050
55143
  const result3 = await getAnalyticsPool().query(
55051
55144
  `SELECT invite.site_id
@@ -55084,7 +55177,7 @@ analyticsApp.post("/survey/exchange", async (c) => {
55084
55177
  return c.redirect("/analytics/survey/session", 303);
55085
55178
  });
55086
55179
  async function readPublicSurveySession(siteId, sessionToken) {
55087
- const digest23 = createHash43("sha256").update(sessionToken).digest("hex");
55180
+ const digest23 = createHash44("sha256").update(sessionToken).digest("hex");
55088
55181
  const session = await getAnalyticsPool().query(
55089
55182
  `SELECT invite.survey_id,invite.survey_revision,invite.conversion_id,invite.session_expires_at,
55090
55183
  survey.state,survey.name,survey.question,survey.selection_mode,survey.eligible_outcome_families,
@@ -55251,10 +55344,10 @@ analyticsApp.post("/v1/conversions", auth4, async (c) => {
55251
55344
  clickIds: clickIds ?? {},
55252
55345
  match: {
55253
55346
  ...normalizedEmail ? {
55254
- emailSha256: createHash43("sha256").update(normalizedEmail).digest("hex")
55347
+ emailSha256: createHash44("sha256").update(normalizedEmail).digest("hex")
55255
55348
  } : {},
55256
55349
  ...normalizedPhone ? {
55257
- phoneSha256: createHash43("sha256").update(normalizedPhone).digest("hex")
55350
+ phoneSha256: createHash44("sha256").update(normalizedPhone).digest("hex")
55258
55351
  } : {}
55259
55352
  }
55260
55353
  }),
@@ -55783,7 +55876,7 @@ analyticsApp.post("/sites/:siteId/crm-imports", auth4, async (c) => {
55783
55876
  rejectedCount += 1;
55784
55877
  continue;
55785
55878
  }
55786
- const digest23 = createHash43("sha256").update(
55879
+ const digest23 = createHash44("sha256").update(
55787
55880
  `${parsed.data.sourceSystem}:${externalId || email || phone || `${fullName}:${index}`}`
55788
55881
  ).digest("hex").slice(0, 16);
55789
55882
  const path5 = `Leads/person-${digest23}`;
@@ -56531,7 +56624,7 @@ analyticsApp.post("/sites/:siteId/consent/withdrawals", auth4, async (c) => {
56531
56624
  try {
56532
56625
  await client2.query("BEGIN");
56533
56626
  await client2.query(`INSERT INTO analytics_privacy_audits(id,site_id,subject_ref,action,idempotency_key,request_fingerprint,actor_user_id,result_code)
56534
- VALUES($1,$2,$3,'withdrawal_applied',$4,$5,$6,'running') ON CONFLICT(site_id,idempotency_key) DO NOTHING`, [randomUUID38(), siteId, `subject:${createHash43("sha256").update(body3.subjectRef).digest("hex").slice(0, 16)}`, idem.key, idem.fingerprint, userId]);
56627
+ VALUES($1,$2,$3,'withdrawal_applied',$4,$5,$6,'running') ON CONFLICT(site_id,idempotency_key) DO NOTHING`, [randomUUID38(), siteId, `subject:${createHash44("sha256").update(body3.subjectRef).digest("hex").slice(0, 16)}`, idem.key, idem.fingerprint, userId]);
56535
56628
  const claimed = await client2.query("SELECT request_fingerprint,result_code,affected_counts FROM analytics_privacy_audits WHERE site_id=$1 AND idempotency_key=$2 FOR UPDATE", [siteId, idem.key]);
56536
56629
  assertAnalyticsPrivacyIdempotencyFingerprint(claimed.rows[0], idem.fingerprint);
56537
56630
  if (claimed.rows[0].result_code === "completed") {
@@ -56789,7 +56882,7 @@ analyticsApp.post("/sites/:siteId/crm/outbound-policies", auth4, async (c) => {
56789
56882
  selectedEvents: z43.array(z43.string().regex(/^[a-z][a-z0-9_]{1,79}$/)).max(100),
56790
56883
  purpose: z43.enum(["necessary_form_fulfillment", "site_analytics", "advertising_measurement"])
56791
56884
  }).strict());
56792
- const policyId = `crmpolicy_${createHash43("sha256").update(JSON.stringify({
56885
+ const policyId = `crmpolicy_${createHash44("sha256").update(JSON.stringify({
56793
56886
  siteId,
56794
56887
  connectionId: body3.connectionId,
56795
56888
  kind: body3.kind,
@@ -57216,7 +57309,7 @@ analyticsApp.post("/sites/:siteId/privacy/subject/export", auth4, async (c) => {
57216
57309
  await getAnalyticsPool().query(
57217
57310
  `INSERT INTO analytics_privacy_audits(id,site_id,subject_ref,action,idempotency_key,request_fingerprint,actor_user_id,result_code,affected_counts,completed_at)
57218
57311
  VALUES($1,$2,$3,'export_completed',$4,$5,$6,'completed',$7::jsonb,now()) ON CONFLICT(site_id,idempotency_key) DO NOTHING`,
57219
- [randomUUID38(), siteId, `person:${createHash43("sha256").update(body3.subjectRef).digest("hex").slice(0, 16)}`, idem.key, idem.fingerprint, userId, JSON.stringify({ export: { schemaVersion: 1, subject: person.rows[0], restrictedIdentityExcluded: true } })]
57312
+ [randomUUID38(), siteId, `person:${createHash44("sha256").update(body3.subjectRef).digest("hex").slice(0, 16)}`, idem.key, idem.fingerprint, userId, JSON.stringify({ export: { schemaVersion: 1, subject: person.rows[0], restrictedIdentityExcluded: true } })]
57220
57313
  );
57221
57314
  const persisted = await getAnalyticsPool().query("SELECT request_fingerprint,affected_counts FROM analytics_privacy_audits WHERE site_id=$1 AND idempotency_key=$2", [siteId, idem.key]);
57222
57315
  assertAnalyticsPrivacyIdempotencyFingerprint(persisted.rows[0], idem.fingerprint);
@@ -57230,7 +57323,7 @@ analyticsApp.post("/sites/:siteId/privacy/subject/delete", auth4, async (c) => {
57230
57323
  try {
57231
57324
  await client2.query("BEGIN");
57232
57325
  await client2.query(`INSERT INTO analytics_privacy_audits(id,site_id,subject_ref,action,idempotency_key,request_fingerprint,actor_user_id,result_code)
57233
- VALUES($1,$2,$3,'deletion_requested',$4,$5,$6,'running') ON CONFLICT(site_id,idempotency_key) DO NOTHING`, [randomUUID38(), siteId, `subject:${createHash43("sha256").update(body3.subjectRef).digest("hex").slice(0, 16)}`, idem.key, idem.fingerprint, userId]);
57326
+ VALUES($1,$2,$3,'deletion_requested',$4,$5,$6,'running') ON CONFLICT(site_id,idempotency_key) DO NOTHING`, [randomUUID38(), siteId, `subject:${createHash44("sha256").update(body3.subjectRef).digest("hex").slice(0, 16)}`, idem.key, idem.fingerprint, userId]);
57234
57327
  const claim = await client2.query("SELECT request_fingerprint,result_code,affected_counts FROM analytics_privacy_audits WHERE site_id=$1 AND idempotency_key=$2 FOR UPDATE", [siteId, idem.key]);
57235
57328
  assertAnalyticsPrivacyIdempotencyFingerprint(claim.rows[0], idem.fingerprint);
57236
57329
  if (claim.rows[0].result_code === "deleted") {
@@ -57248,7 +57341,7 @@ analyticsApp.post("/sites/:siteId/privacy/subject/delete", auth4, async (c) => {
57248
57341
  db: client2
57249
57342
  });
57250
57343
  const counts = { ...deletion.affectedCounts };
57251
- await client2.query(`UPDATE analytics_privacy_audits SET namespace_ref=$3,subject_ref=$4,action='deletion_completed',result_code='deleted',affected_counts=$5::jsonb,completed_at=now() WHERE site_id=$1 AND idempotency_key=$2`, [siteId, idem.key, `namespace:${locked.rows[0].namespace_id}`, `deleted:${createHash43("sha256").update(body3.subjectRef).digest("hex").slice(0, 16)}`, JSON.stringify(counts)]);
57344
+ await client2.query(`UPDATE analytics_privacy_audits SET namespace_ref=$3,subject_ref=$4,action='deletion_completed',result_code='deleted',affected_counts=$5::jsonb,completed_at=now() WHERE site_id=$1 AND idempotency_key=$2`, [siteId, idem.key, `namespace:${locked.rows[0].namespace_id}`, `deleted:${createHash44("sha256").update(body3.subjectRef).digest("hex").slice(0, 16)}`, JSON.stringify(counts)]);
57252
57345
  await client2.query("COMMIT");
57253
57346
  return c.json({ ok: true, deleted: true, counts }, 200, noStore);
57254
57347
  } catch (error) {
@@ -57292,7 +57385,7 @@ analyticsApp.post("/sites/:siteId/privacy/namespace/delete", auth4, async (c) =>
57292
57385
  await client2.query(
57293
57386
  `INSERT INTO analytics_privacy_audits(id,site_id,namespace_ref,action,idempotency_key,actor_user_id,result_code,affected_counts,completed_at)
57294
57387
  VALUES($1,$2,$3,'deletion_completed',$4,$5,'deleted',$6::jsonb,now()) ON CONFLICT(site_id,idempotency_key) DO NOTHING`,
57295
- [randomUUID38(), siteId, `deleted:${createHash43("sha256").update(body3.namespaceId).digest("hex").slice(0, 16)}`, body3.idempotencyKey, userId, JSON.stringify(counts)]
57388
+ [randomUUID38(), siteId, `deleted:${createHash44("sha256").update(body3.namespaceId).digest("hex").slice(0, 16)}`, body3.idempotencyKey, userId, JSON.stringify(counts)]
57296
57389
  );
57297
57390
  await client2.query("COMMIT");
57298
57391
  return c.json({ ok: true, deleted: true, counts }, 200, noStore);
@@ -57759,7 +57852,7 @@ function resultStatus(result3) {
57759
57852
  return 502;
57760
57853
  }
57761
57854
  async function keyFor(c) {
57762
- const { key: key3, error } = await getOrCreateUserMemoryKey(c.get("user"));
57855
+ const { key: key3, error } = await getMemoryServiceToken(c.get("user"));
57763
57856
  if (!key3) return c.json(safeFailure2(error ?? "Memory is unavailable."), 503);
57764
57857
  return key3;
57765
57858
  }
@@ -58112,7 +58205,7 @@ crmApp.post("/deals/:dealId/transitions", async (c) => {
58112
58205
  });
58113
58206
 
58114
58207
  // src/api/crm-bridge-service.ts
58115
- import { createHash as createHash44 } from "crypto";
58208
+ import { createHash as createHash45 } from "crypto";
58116
58209
  var CrmBridgeError = class extends Error {
58117
58210
  constructor(code, message) {
58118
58211
  super(message);
@@ -58122,7 +58215,7 @@ var CrmBridgeError = class extends Error {
58122
58215
  code;
58123
58216
  };
58124
58217
  function stableChildId(parentId, suffix2) {
58125
- const bytes2 = Buffer.from(createHash44("sha256").update(`${parentId}:${suffix2}`).digest().subarray(0, 16));
58218
+ const bytes2 = Buffer.from(createHash45("sha256").update(`${parentId}:${suffix2}`).digest().subarray(0, 16));
58126
58219
  bytes2[6] = bytes2[6] & 15 | 80;
58127
58220
  bytes2[8] = bytes2[8] & 63 | 128;
58128
58221
  const hex = bytes2.toString("hex");
@@ -58242,7 +58335,7 @@ async function deliverPendingAnalyticsForms(limit = 10, dependencies = {}) {
58242
58335
  deferred += 1;
58243
58336
  continue;
58244
58337
  }
58245
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
58338
+ const { key: key3, error } = await getMemoryServiceToken(user);
58246
58339
  if (!key3) {
58247
58340
  await deferAnalyticsFormDelivery(job.id, job.attempts, safeDeliveryError(error));
58248
58341
  deferred += 1;
@@ -58324,7 +58417,7 @@ async function deliverPendingAnalyticsCrmImports(limit = 10) {
58324
58417
  deferred += 1;
58325
58418
  continue;
58326
58419
  }
58327
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
58420
+ const { key: key3, error } = await getMemoryServiceToken(user);
58328
58421
  const result3 = key3 ? await memoryCall("putTool", payload, key3) : { ok: false, error };
58329
58422
  if (result3.ok) {
58330
58423
  await completeAnalyticsCrmImportRow(row.id, row.importId);
@@ -58802,7 +58895,7 @@ async function pollPendingGoogleActivationDiagnostics(limit = 10, deadlineMs = D
58802
58895
  }
58803
58896
 
58804
58897
  // src/api/analytics-reconciliation.ts
58805
- import { createHash as createHash45, randomUUID as randomUUID41 } from "crypto";
58898
+ import { createHash as createHash46, randomUUID as randomUUID41 } from "crypto";
58806
58899
  var RECONCILIATION_INTERVAL_SECONDS = 15 * 60;
58807
58900
  var WEBHOOK_ONLY_RECHECK_SECONDS = 24 * 60 * 60;
58808
58901
  var LEASE_SECONDS = 90;
@@ -58929,14 +59022,14 @@ function crmReadInput(provider, sourceAccountRef, cursorValue, now) {
58929
59022
  }
58930
59023
  }
58931
59024
  function crmOutcomeSourceEventId(outcome) {
58932
- const digest23 = createHash45("sha256").update(`${outcome.provider}:${outcome.sourceRecordId}:${outcome.updatedAt}:${outcome.tombstone}`).digest("hex").slice(0, 40);
59025
+ const digest23 = createHash46("sha256").update(`${outcome.provider}:${outcome.sourceRecordId}:${outcome.updatedAt}:${outcome.tombstone}`).digest("hex").slice(0, 40);
58933
59026
  return `crm:${outcome.provider}:${digest23}`;
58934
59027
  }
58935
59028
  function analyticsCrmOutcomeToExternalEvent(outcome, sourceAccountRef) {
58936
59029
  const sourceEventId = crmOutcomeSourceEventId(outcome);
58937
59030
  return {
58938
59031
  schemaVersion: 1,
58939
- eventId: `crm_${createHash45("sha256").update(sourceEventId).digest("hex").slice(0, 24)}`,
59032
+ eventId: `crm_${createHash46("sha256").update(sourceEventId).digest("hex").slice(0, 24)}`,
58940
59033
  sourceEventId,
58941
59034
  source: outcome.provider,
58942
59035
  sourceAccountRef,
@@ -59236,7 +59329,7 @@ async function deferAnalyticsReconciliationJob(input) {
59236
59329
  connectionId: input.connectionId,
59237
59330
  safeErrorCode: errorCode2,
59238
59331
  nextRunAt: new Date(Date.now() + delaySeconds * 1e3).toISOString(),
59239
- receiptFingerprint: createHash45("sha256").update(`${input.jobId}:${input.attempts}:${errorCode2}`).digest("hex")
59332
+ receiptFingerprint: createHash46("sha256").update(`${input.jobId}:${input.attempts}:${errorCode2}`).digest("hex")
59240
59333
  });
59241
59334
  }
59242
59335
  }
@@ -59347,7 +59440,7 @@ async function reconcileAnalyticsConnection(job, dependencies = defaultDependenc
59347
59440
  deduplicated: duplicates,
59348
59441
  rejected: page3.rejected,
59349
59442
  hasMore: page3.hasMore,
59350
- receiptFingerprint: createHash45("sha256").update(`${job.id}:${JSON.stringify(page3.nextCursor)}:${replayed}:${duplicates}`).digest("hex"),
59443
+ receiptFingerprint: createHash46("sha256").update(`${job.id}:${JSON.stringify(page3.nextCursor)}:${replayed}:${duplicates}`).digest("hex"),
59351
59444
  scheduleConfigured: Boolean(scope.sync_id),
59352
59445
  scheduleIntervalSeconds: scope.sync_interval_seconds ?? null
59353
59446
  }
@@ -59564,13 +59657,13 @@ import { Hono as Hono38 } from "hono";
59564
59657
  import { z as z46 } from "zod";
59565
59658
 
59566
59659
  // src/api/scheduled-artifact-owner.ts
59567
- import { createHash as createHash46 } from "crypto";
59660
+ import { createHash as createHash47 } from "crypto";
59568
59661
  function scheduledArtifactOwnerIdForApiKey(apiKey) {
59569
- return createHash46("sha256").update(apiKey).digest("hex").slice(0, 24);
59662
+ return createHash47("sha256").update(apiKey).digest("hex").slice(0, 24);
59570
59663
  }
59571
59664
 
59572
59665
  // src/api/scheduled-run-view-links.ts
59573
- import { createHash as createHash47, randomBytes as randomBytes6, randomUUID as randomUUID43 } from "crypto";
59666
+ import { createHash as createHash48, randomBytes as randomBytes6, randomUUID as randomUUID43 } from "crypto";
59574
59667
  var schemaReady3 = false;
59575
59668
  async function ensureScheduledRunViewLinksSchema() {
59576
59669
  if (schemaReady3) return;
@@ -59624,7 +59717,7 @@ async function ensureScheduledRunViewLinksSchema() {
59624
59717
  schemaReady3 = true;
59625
59718
  }
59626
59719
  function tokenHash2(token7) {
59627
- return createHash47("sha256").update(token7).digest("hex");
59720
+ return createHash48("sha256").update(token7).digest("hex");
59628
59721
  }
59629
59722
  function mapRow(row) {
59630
59723
  return {
@@ -59711,7 +59804,7 @@ async function revokeScheduledRunViewLink(ownerId3, runId, shareId, now = /* @__
59711
59804
  }
59712
59805
 
59713
59806
  // src/personal-authority/render.ts
59714
- import { createHash as createHash48 } from "crypto";
59807
+ import { createHash as createHash49 } from "crypto";
59715
59808
  function escapeHtml8(value) {
59716
59809
  return value.replace(/[&<>"']/g, (character) => ({
59717
59810
  "&": "&amp;",
@@ -59771,13 +59864,13 @@ ${section(flags.finalCta && Boolean(finalCta), `<section class="section cta" id=
59771
59864
  html,
59772
59865
  filename: `${input.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "personal-authority"}.html`,
59773
59866
  bytes: bytes2,
59774
- sha256: createHash48("sha256").update(html).digest("hex"),
59867
+ sha256: createHash49("sha256").update(html).digest("hex"),
59775
59868
  generatedAt: generatedAtIso
59776
59869
  };
59777
59870
  }
59778
59871
 
59779
59872
  // src/personal-authority/render-v2.ts
59780
- import { createHash as createHash49 } from "crypto";
59873
+ import { createHash as createHash50 } from "crypto";
59781
59874
  var FONT_STACKS = Object.freeze({
59782
59875
  "editorial-serif": "Iowan Old Style, Baskerville, Times New Roman, serif",
59783
59876
  "modern-sans": "Avenir Next, Avenir, Helvetica Neue, Arial, sans-serif",
@@ -59881,13 +59974,13 @@ ${section2(flags.finalCta && Boolean(finalCta), `<section class="section cta" id
59881
59974
  html,
59882
59975
  filename: `${input.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "personal-authority"}.html`,
59883
59976
  bytes: bytes2,
59884
- sha256: createHash49("sha256").update(html).digest("hex"),
59977
+ sha256: createHash50("sha256").update(html).digest("hex"),
59885
59978
  generatedAt: generatedAtIso
59886
59979
  };
59887
59980
  }
59888
59981
 
59889
59982
  // src/newsroom-publisher/render.ts
59890
- import { createHash as createHash50 } from "crypto";
59983
+ import { createHash as createHash51 } from "crypto";
59891
59984
  function escapeHtml10(value) {
59892
59985
  return value.replace(/[&<>"']/g, (character) => ({
59893
59986
  "&": "&amp;",
@@ -59993,13 +60086,13 @@ body{overflow-x:hidden}.lead-story__body,.lead-support__item,.story-card__body{m
59993
60086
  @media(max-width:620px){.desk-section__grid--panorama,.desk-section__grid--mosaic,.desk-section__grid--tiles{grid-template-columns:1fr}.story-card--panorama{display:block}.story-card--panorama h3,.story-card--mosaic-lead h3{font-size:34px}.story-card--mosaic-lead{grid-column:auto;grid-row:auto}.desk-section__grid--tiles>.story-card:nth-child(3n+2){margin-top:0}}
59994
60087
  </style></head><body data-theme="${escapeHtml10(config.theme)}" id="top" data-scheduled-renderer="newsroom_publisher_v1">${ticker}${masthead}${navigation}<main>${leadGrid}${latest}${sections}${newsletter}${pressRoom}${trustCenter}</main>${trustFooter}</body></html>`;
59995
60088
  const bytes2 = Buffer.byteLength(html);
59996
- const sha2564 = createHash50("sha256").update(html).digest("hex");
60089
+ const sha2564 = createHash51("sha256").update(html).digest("hex");
59997
60090
  const filename2 = `${brand.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "newsroom"}-news-site.html`;
59998
60091
  return { html, filename: filename2, bytes: bytes2, sha256: sha2564, generatedAt: generatedAtIso };
59999
60092
  }
60000
60093
 
60001
60094
  // src/blog-article/render.ts
60002
- import { createHash as createHash51 } from "crypto";
60095
+ import { createHash as createHash52 } from "crypto";
60003
60096
  function escapeHtml11(value) {
60004
60097
  return value.replace(
60005
60098
  /[&<>"']/g,
@@ -60087,7 +60180,7 @@ function renderBlogArticleV1(input, config, generatedAt) {
60087
60180
  :root{--ink:#10213d;--ink2:#1c355a;--blue:#2563eb;--blue2:#1749b6;--mint:#45d5aa;--paper:#f7f5f0;--line:#dce4ef;--card:#fff;--body:#475569;--serif:Iowan Old Style,Palatino Linotype,Palatino,Georgia,serif;--sans:Inter,Avenir Next,ui-sans-serif,system-ui,sans-serif}body[data-theme="slate"]{--ink:#1e293b;--ink2:#334155;--blue:#475569;--blue2:#1e293b;--mint:#94a3b8;--paper:#f8fafc}body[data-theme="forest"]{--ink:#12352e;--ink2:#23584c;--blue:#147d64;--blue2:#0c5b48;--mint:#79d8bd;--paper:#f4f8f3}*{box-sizing:border-box}html{scroll-behavior:smooth;background:var(--paper)}body{margin:0;color:#252a33;background:var(--paper);font-family:var(--sans);line-height:1.6}a{color:inherit}button{font:inherit}button:focus-visible,a:focus-visible{outline:3px solid var(--mint);outline-offset:3px}.progress{position:fixed;z-index:50;top:0;left:0;height:4px;width:0;background:var(--mint)}.hero{position:relative;overflow:hidden;color:#fff;background:var(--ink)}.hero:after{position:absolute;right:-110px;top:-150px;width:420px;height:420px;border:1px solid #ffffff1a;border-radius:50%;content:""}.hero-inner{position:relative;z-index:1;max-width:1240px;margin:auto;padding:58px 42px 126px}.breadcrumb{display:flex;gap:8px;margin-bottom:34px;color:#dbeafecc;font-size:14px}.eyebrow{display:block;color:var(--blue);font-size:12px;font-weight:800;letter-spacing:.16em;text-transform:uppercase}.hero .eyebrow{color:var(--mint)}h1,h2,h3,p{margin-top:0}.hero h1{max-width:1000px;margin:14px 0 24px;font:700 clamp(44px,6vw,78px)/.98 var(--serif);letter-spacing:-.035em}.hero .dek{max-width:780px;color:#dbeafe;font-size:20px}.contributors{margin-top:30px;color:#eff6ff;font-size:14px}.contributors a{font-weight:800}.meta{display:flex;flex-wrap:wrap;gap:12px;margin-top:6px;color:#dbeafecc}.layout{position:relative;z-index:2;display:grid;grid-template-columns:minmax(0,760px) 290px;gap:64px;max-width:1240px;margin:-78px auto 0;padding:0 42px 80px}.main{min-width:0}.takeaways{padding:38px 44px;border-radius:24px;background:#fff;box-shadow:0 24px 70px #10213d24}.takeaways h2{margin:5px 0 20px;font:700 32px/1.1 var(--serif);color:var(--ink)}.takeaways ul{display:grid;gap:16px;margin:0;padding:0;list-style:none}.takeaways li{position:relative;padding-left:26px;color:var(--body);font-size:17px}.takeaways li:before{position:absolute;left:2px;top:.7em;width:8px;height:8px;border-radius:50%;background:var(--blue);content:""}.intro{padding:40px 0 4px}.intro p,.article-section>p{margin-bottom:22px;color:var(--body);font:400 18px/1.75 var(--sans)}.article-section{scroll-margin-top:28px;padding-top:45px}.article-section h2,.faq h2{margin:6px 0 20px;color:var(--ink);font:700 38px/1.08 var(--serif);letter-spacing:-.02em}.article-section ul{display:grid;gap:10px;margin:22px 0;padding-left:24px;color:var(--body);font-size:17px}.article-section li::marker{color:var(--blue)}.callout{margin:34px 0;padding:24px 28px;border-left:4px solid var(--blue);border-radius:0 16px 16px 0;background:#fff}.callout span{color:var(--blue);font-size:11px;font-weight:800;letter-spacing:.13em;text-transform:uppercase}.callout h3{margin:5px 0 8px;color:var(--ink);font:700 24px/1.15 var(--serif)}.callout p{margin:0;color:var(--body)}.rail{padding-top:0}.sidebar-media{overflow:hidden;margin:0 0 18px;border:1px solid #dbeafe;border-radius:16px;background:#fff}.sidebar-media img,.sidebar-media svg{display:block;width:100%;aspect-ratio:16/9;object-fit:cover}.sidebar-media figcaption{padding:10px 13px;color:#64748b;font-size:11px}.disclosure{margin-bottom:28px;border-top:1px solid #dbeafe;border-bottom:1px solid #dbeafe}.disclosure button{display:flex;width:100%;align-items:center;justify-content:space-between;gap:14px;padding:15px 0;border:0;color:#64748b;background:transparent;text-align:left;font-size:12px;cursor:pointer}.disclosure button b{color:var(--blue);font-size:18px;transition:transform .2s}.disclosure button[aria-expanded="true"] b{transform:rotate(180deg)}.disclosure p{padding:0 0 16px;margin:0;color:#64748b;font-size:12px}.toc{position:sticky;top:30px;padding:22px;border:1px solid var(--line);border-radius:16px;background:#fff;box-shadow:0 2px 5px #10213d12}.toc header{display:flex;align-items:center;justify-content:space-between}.toc header strong{color:var(--ink);font:700 21px/1 var(--serif)}.toc header button{width:34px;height:34px;border:0;border-radius:50%;color:var(--blue);background:transparent;cursor:pointer}.toc nav{display:grid;margin-top:14px}.toc nav a{display:flex;align-items:flex-start;gap:11px;padding:8px 0;color:#64748b;text-decoration:none;font-size:13px;line-height:1.35}.toc nav i{width:8px;height:8px;margin-top:5px;border:2px solid #bfdbfe;border-radius:50%}.toc nav a[aria-current="location"]{color:var(--ink);font-weight:800}.toc nav a[aria-current="location"] i{border-color:var(--blue);background:var(--blue)}.back-top{width:100%;margin-top:18px;padding:16px 0 0;border:0;border-top:1px solid var(--line);color:var(--blue);background:transparent;text-align:right;font-size:13px;font-weight:800;cursor:pointer}.faq{scroll-margin-top:28px;padding-top:64px}.faq>div{border-top:1px solid var(--line);border-bottom:1px solid var(--line)}.faq article+article{border-top:1px solid var(--line)}.faq h3{margin:0}.faq h3 button{display:flex;width:100%;align-items:center;justify-content:space-between;gap:18px;padding:19px 0;border:0;color:var(--ink);background:transparent;text-align:left;font-weight:800;cursor:pointer}.faq h3 b{color:var(--blue);font-size:22px}.faq article>p{padding:0 0 20px;margin:0;color:var(--body);font-size:16px}.author-card{margin-top:64px;padding:32px 36px;border-radius:18px;background:#fff}.article-actions{display:flex;flex-wrap:wrap;justify-content:space-between;gap:14px}.article-actions button{display:inline-flex;min-height:46px;align-items:center;justify-content:center;gap:8px;padding:8px 18px;border:2px solid var(--blue);border-radius:999px;color:var(--ink);background:#fff;font-weight:800;cursor:pointer}.article-actions button:hover{color:#fff;background:var(--blue)}.action-status{min-height:20px;margin:8px 0 0;color:var(--blue);text-align:right;font-size:13px;font-weight:700}.author-grid{display:grid;grid-template-columns:auto 1fr auto;gap:22px;align-items:center;margin-top:24px}.author-portrait{width:88px;height:88px;border-radius:50%;object-fit:cover}.author-initials{display:grid;place-items:center;color:var(--ink);background:#fecdd3;font-size:22px;font-weight:900}.author-grid span{color:#64748b;font-size:13px}.author-grid h2{margin:2px 0;color:var(--ink);font:700 27px/1 var(--serif)}.author-grid h2 a{text-decoration:none}.author-grid p{margin:8px 0;color:#64748b;font-size:14px}.author-grid nav{display:flex;flex-wrap:wrap;gap:14px}.author-grid nav a{color:#64748b;font-size:12px}.author-more{display:inline-flex;min-height:48px;align-items:center;justify-content:center;padding:10px 24px;border:2px solid var(--blue);color:var(--blue);text-align:center;text-decoration:none;font-size:13px;font-weight:800}.author-bio{margin:24px 0 0!important;padding-top:20px;border-top:1px solid var(--line);color:var(--body);font-size:16px}dialog{width:min(720px,calc(100% - 30px));max-height:calc(100dvh - 30px);padding:0;border:0;border-radius:18px;color:var(--ink);background:#fff;box-shadow:0 24px 70px #10213d38}dialog::backdrop{background:#0f172a7a;backdrop-filter:blur(2px)}dialog>div{position:relative;padding:30px}dialog h2{margin:0 50px 2px 0;font:700 30px/1.1 var(--serif)}dialog>div>p{color:#64748b}.dialog-close{position:absolute;top:13px;right:13px;width:44px;height:44px;border:0;border-radius:50%;color:var(--blue);background:transparent;font-size:29px;cursor:pointer}dialog section{border-top:1px solid var(--line)}dialog section button{display:block;width:100%;padding:17px 5px;border:0;border-bottom:1px solid var(--line);color:var(--body);background:#fff;text-align:left;line-height:1.65;cursor:pointer}.citation-status{min-height:22px;margin:14px 0 0!important;color:var(--blue)!important;font-size:13px;font-weight:800}.generated{max-width:1156px;margin:-52px auto 50px;padding:0 42px;color:#94a3b8;font-size:11px}@media(max-width:900px){.layout{display:block}.rail{display:none}.hero-inner{padding-bottom:116px}}@media(max-width:620px){.hero-inner{padding:36px 20px 104px}.hero h1{font-size:46px}.hero .dek{font-size:17px}.layout{margin-top:-70px;padding:0 16px 54px}.takeaways{padding:28px 24px}.article-section h2,.faq h2{font-size:32px}.author-card{padding:24px}.article-actions{display:grid;justify-content:start}.author-grid{grid-template-columns:1fr;gap:12px}.author-more{width:100%}dialog>div{padding:24px}.generated{padding:0 20px}}
60088
60181
  </style></head><body data-theme="${escapeHtml11(config.theme)}" data-scheduled-renderer="blog_article_v1"><div class="progress" aria-hidden="true"></div><header class="hero"><div class="hero-inner"><nav class="breadcrumb" aria-label="Breadcrumb"><a href="${safeHref4(input.canonicalUrl)}">${escapeHtml11(input.category)}</a><span>/</span><span>Article</span></nav><span class="eyebrow">${escapeHtml11(input.eyebrow)}</span><h1>${escapeHtml11(input.title)}</h1>${input.dek ? `<p class="dek">${escapeHtml11(input.dek)}</p>` : ""}<div class="contributors">${contributorText}<div class="meta"><time datetime="${escapeHtml11(articleDate)}">Updated ${formatDate2(articleDate)}</time><span>\u2022</span><span>${input.readTimeMinutes} min read</span>${input.reviewer ? "<span>\u2022</span><strong>Expert reviewed</strong>" : ""}</div></div></div></header><main class="layout"><article class="main"><section class="takeaways"><span class="eyebrow">The short answer</span><h2>Key takeaways</h2><ul>${input.keyTakeaways.map((item) => `<li>${escapeHtml11(item)}</li>`).join("")}</ul></section><section class="intro">${input.introduction.map((paragraph) => `<p>${escapeHtml11(paragraph)}</p>`).join("")}</section>${sections}${faq}${author}</article><div class="rail">${media}${disclosure}${toc}</div></main>${config.showGeneratedAt ? `<p class="generated">Rendered ${formatDate2(generatedAtIso)} by MCP Scraper.</p>` : ""}${citationDialog}<script>(()=>{const citations=${jsonForScript(citationValues)};const canonical=${jsonForScript(input.canonicalUrl)};const title=${jsonForScript(input.title)};const progress=document.querySelector('.progress');const tocLinks=[...document.querySelectorAll('.toc nav a')];const targets=tocLinks.map(link=>document.querySelector(link.hash)).filter(Boolean);const update=()=>{const max=document.documentElement.scrollHeight-innerHeight;if(progress)progress.style.width=(max>0?scrollY/max*100:0)+'%';let active=targets[0]?.id;for(const target of targets){if(target.getBoundingClientRect().top<=innerHeight*.55)active=target.id}tocLinks.forEach(link=>link.toggleAttribute('aria-current',link.hash==='#'+active));tocLinks.forEach(link=>{if(link.hash==='#'+active)link.setAttribute('aria-current','location');else link.removeAttribute('aria-current')})};addEventListener('scroll',update,{passive:true});addEventListener('resize',update);update();document.querySelectorAll('.faq h3 button').forEach(button=>button.addEventListener('click',()=>{const panel=document.getElementById(button.getAttribute('aria-controls'));const open=button.getAttribute('aria-expanded')==='true';button.setAttribute('aria-expanded',String(!open));panel.hidden=open;button.querySelector('b').textContent=open?'+':'\u2212'}));const disclosure=document.querySelector('.disclosure button');disclosure?.addEventListener('click',()=>{const panel=document.getElementById(disclosure.getAttribute('aria-controls'));const open=disclosure.getAttribute('aria-expanded')==='true';disclosure.setAttribute('aria-expanded',String(!open));panel.hidden=open});const tocToggle=document.querySelector('.toc header button');tocToggle?.addEventListener('click',()=>{const nav=document.getElementById('toc-links');const open=tocToggle.getAttribute('aria-expanded')==='true';tocToggle.setAttribute('aria-expanded',String(!open));nav.hidden=open;tocToggle.textContent=open?'\u2304':'\u2303'});document.querySelector('.back-top')?.addEventListener('click',()=>scrollTo({top:0,behavior:'smooth'}));const copy=async text=>{try{await navigator.clipboard.writeText(text)}catch{const area=document.createElement('textarea');area.value=text;area.style.position='fixed';area.style.opacity='0';document.body.append(area);area.select();document.execCommand('copy');area.remove()}};const dialog=document.getElementById('citation-dialog');document.querySelector('[data-cite]')?.addEventListener('click',()=>dialog.showModal());document.querySelector('.dialog-close')?.addEventListener('click',()=>dialog.close());dialog?.addEventListener('click',event=>{if(event.target===dialog)dialog.close()});document.querySelectorAll('[data-citation]').forEach(button=>button.addEventListener('click',async()=>{const style=button.dataset.citation;await copy(citations[style]);document.querySelector('.citation-status').textContent=style+' citation copied to clipboard.'}));document.querySelector('[data-share]')?.addEventListener('click',async()=>{const status=document.querySelector('.action-status');if(navigator.share){try{await navigator.share({title,url:canonical});status.textContent='Sharing options opened.';return}catch(error){if(error.name==='AbortError')return}}await copy(canonical);status.textContent='Article link copied to clipboard.'})})()</script></body></html>`;
60089
60182
  const bytes2 = Buffer.byteLength(html);
60090
- const sha2564 = createHash51("sha256").update(html).digest("hex");
60183
+ const sha2564 = createHash52("sha256").update(html).digest("hex");
60091
60184
  return {
60092
60185
  html,
60093
60186
  filename: "blog-article.html",
@@ -60218,7 +60311,7 @@ function apiError(error, errorCode2 = "invalid_request") {
60218
60311
  }
60219
60312
  async function memoryContext(c) {
60220
60313
  const user = c.get("user");
60221
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
60314
+ const { key: key3, error } = await getMemoryServiceToken(user);
60222
60315
  return { user, key: key3, error };
60223
60316
  }
60224
60317
  function memoryStatus(result3) {
@@ -60390,7 +60483,7 @@ scheduledResultApp.delete("/schedule-runs/:runId/view-links/:shareId", async (c)
60390
60483
  import { Hono as Hono39 } from "hono";
60391
60484
 
60392
60485
  // src/scheduled-artifacts/scheduled-run-artifact-store.ts
60393
- import { createHash as createHash52 } from "crypto";
60486
+ import { createHash as createHash53 } from "crypto";
60394
60487
  var SCHEDULED_RUN_ARTIFACT_PREFIX = "scheduled-run-artifacts/";
60395
60488
  var SCHEDULED_RUN_ARTIFACT_DOWNLOAD_TTL_MS = 15 * 60 * 1e3;
60396
60489
  var SCHEDULED_RUN_ARTIFACT_MAX_BYTES = 2e6;
@@ -60406,7 +60499,7 @@ function policy5() {
60406
60499
  };
60407
60500
  }
60408
60501
  function runStorageSegment(runId) {
60409
- return /^[a-zA-Z0-9_-]{1,160}$/.test(runId) ? runId : `run-${createHash52("sha256").update(runId).digest("hex").slice(0, 32)}`;
60502
+ return /^[a-zA-Z0-9_-]{1,160}$/.test(runId) ? runId : `run-${createHash53("sha256").update(runId).digest("hex").slice(0, 32)}`;
60410
60503
  }
60411
60504
  async function createScheduledRunArtifact(args) {
60412
60505
  if (args.rendered.bytes > SCHEDULED_RUN_ARTIFACT_MAX_BYTES) {
@@ -60598,11 +60691,11 @@ scheduledArtifactInternalApp.post("/render", async (c) => {
60598
60691
  });
60599
60692
 
60600
60693
  // src/api/personal-assistant-routes.ts
60601
- import { createHash as createHash60, randomUUID as randomUUID45 } from "crypto";
60694
+ import { createHash as createHash61, randomUUID as randomUUID45 } from "crypto";
60602
60695
  import { Hono as Hono42 } from "hono";
60603
60696
 
60604
60697
  // src/api/personal-assistant-schedule-readiness.ts
60605
- import { createHash as createHash53 } from "crypto";
60698
+ import { createHash as createHash54 } from "crypto";
60606
60699
  import { z as z47 } from "zod";
60607
60700
  var opaqueRef = z47.string().trim().regex(/^[a-z][a-z0-9_]*_[A-Za-z0-9_-]{3,128}$/);
60608
60701
  var isoTimestamp2 = z47.iso.datetime({ offset: true });
@@ -60675,7 +60768,7 @@ function canonicalJson2(value) {
60675
60768
  return JSON.stringify(value);
60676
60769
  }
60677
60770
  function digest2(value) {
60678
- return createHash53("sha256").update(canonicalJson2(value)).digest("hex");
60771
+ return createHash54("sha256").update(canonicalJson2(value)).digest("hex");
60679
60772
  }
60680
60773
  function validTimezone2(timezone) {
60681
60774
  try {
@@ -60936,7 +61029,7 @@ async function evaluateScheduleReadiness(rawInput, dependencies) {
60936
61029
  }
60937
61030
 
60938
61031
  // src/api/personal-assistant-command-builder.ts
60939
- import { createHash as createHash54 } from "crypto";
61032
+ import { createHash as createHash55 } from "crypto";
60940
61033
  function canonicalJson3(value) {
60941
61034
  return JSON.stringify(value, (_key, entry) => {
60942
61035
  if (!entry || typeof entry !== "object" || Array.isArray(entry)) return entry;
@@ -60944,7 +61037,7 @@ function canonicalJson3(value) {
60944
61037
  });
60945
61038
  }
60946
61039
  function digest3(value) {
60947
- return createHash54("sha256").update(canonicalJson3(value)).digest("hex");
61040
+ return createHash55("sha256").update(canonicalJson3(value)).digest("hex");
60948
61041
  }
60949
61042
  function explicitControlIntent(text3) {
60950
61043
  const normalized = text3.trim().toLowerCase();
@@ -60993,7 +61086,7 @@ async function buildPersonalAssistantCommand(context, input) {
60993
61086
  }
60994
61087
 
60995
61088
  // src/api/personal-assistant-consent-content.ts
60996
- import { createHash as createHash55 } from "crypto";
61089
+ import { createHash as createHash56 } from "crypto";
60997
61090
  var SUBMITTED_EVIDENCE = Object.freeze({
60998
61091
  evidenceVersion: "twilio-toll-free-submission.2026-08-28.v1",
60999
61092
  policyVersion: "2026-08-28.v1",
@@ -61056,7 +61149,7 @@ var ASSISTANT_ENROLLMENT_DISCLOSURE_TEXT = Object.freeze([
61056
61149
  ASSISTANT_CONSENT_CONTENT_V1.retentionDisclosure,
61057
61150
  ASSISTANT_CONSENT_CONTENT_V1.termsDisclosure
61058
61151
  ].join("\n\n"));
61059
- var ASSISTANT_ENROLLMENT_DISCLOSURE_DIGEST = createHash55("sha256").update(`${ASSISTANT_CONSENT_CONTENT_V1.policyVersion}\0${ASSISTANT_ENROLLMENT_DISCLOSURE_TEXT}`).digest("hex");
61152
+ var ASSISTANT_ENROLLMENT_DISCLOSURE_DIGEST = createHash56("sha256").update(`${ASSISTANT_CONSENT_CONTENT_V1.policyVersion}\0${ASSISTANT_ENROLLMENT_DISCLOSURE_TEXT}`).digest("hex");
61060
61153
  var ASSISTANT_ENROLLMENT_DISCLOSURE_PROJECTION = Object.freeze({
61061
61154
  policyVersion: ASSISTANT_CONSENT_CONTENT_V1.policyVersion,
61062
61155
  disclosureDigest: ASSISTANT_ENROLLMENT_DISCLOSURE_DIGEST,
@@ -61067,11 +61160,11 @@ var ASSISTANT_ENROLLMENT_DISCLOSURE_PROJECTION = Object.freeze({
61067
61160
  });
61068
61161
 
61069
61162
  // src/api/personal-assistant-lifecycle.ts
61070
- import { createHash as createHash57, randomUUID as randomUUID44 } from "crypto";
61163
+ import { createHash as createHash58, randomUUID as randomUUID44 } from "crypto";
61071
61164
  import { z as z48 } from "zod";
61072
61165
 
61073
61166
  // src/api/personal-assistant-db.ts
61074
- import { createHash as createHash56 } from "crypto";
61167
+ import { createHash as createHash57 } from "crypto";
61075
61168
  import { Pool } from "pg";
61076
61169
 
61077
61170
  // src/api/personal-assistant-schema.ts
@@ -61193,7 +61286,7 @@ function assistantDatabaseBindingFingerprint(value) {
61193
61286
  if (!database) {
61194
61287
  throw new AssistantDatabaseError("assistant_database_binding_invalid", "Personal Assistant database name is missing.");
61195
61288
  }
61196
- return createHash56("sha256").update(`${normalizedNeonHost(parsed.hostname)}\0${database}`).digest("hex");
61289
+ return createHash57("sha256").update(`${normalizedNeonHost(parsed.hostname)}\0${database}`).digest("hex");
61197
61290
  }
61198
61291
  function assistantDatabaseRole(value) {
61199
61292
  const role = decodeURIComponent(parseDatabaseUrl(value).username);
@@ -61481,7 +61574,7 @@ var AssistantLifecycleError = class extends Error {
61481
61574
  };
61482
61575
 
61483
61576
  // src/api/personal-assistant-service.ts
61484
- import { createHash as createHash58 } from "crypto";
61577
+ import { createHash as createHash59 } from "crypto";
61485
61578
  var PERSONAL_ASSISTANT_INTENT_ENVELOPE_VERSION = "assistant-intent-envelope.v1";
61486
61579
  var CONTROL_INTENTS = /* @__PURE__ */ new Set(["help", "status", "approve", "reject", "cancel"]);
61487
61580
  var EXPLICIT_TASK_INTENTS = /* @__PURE__ */ new Set([
@@ -61647,7 +61740,7 @@ function canonicalServiceJson(value) {
61647
61740
  });
61648
61741
  }
61649
61742
  function serviceDigest(value) {
61650
- return createHash58("sha256").update(canonicalServiceJson(value)).digest("hex");
61743
+ return createHash59("sha256").update(canonicalServiceJson(value)).digest("hex");
61651
61744
  }
61652
61745
  function serviceReceipt(idempotencyKey4, requestDigest2, occurredAt, state2, result3, error = null) {
61653
61746
  const receiptRef = `receipt_${serviceDigest({ idempotencyKey: idempotencyKey4, requestDigest: requestDigest2 }).slice(0, 32)}`;
@@ -63074,7 +63167,7 @@ import twilio3 from "twilio";
63074
63167
  import { Hono as Hono41 } from "hono";
63075
63168
 
63076
63169
  // src/api/personal-assistant-observability.ts
63077
- import { createHash as createHash59 } from "crypto";
63170
+ import { createHash as createHash60 } from "crypto";
63078
63171
  var OPAQUE_TRACE_REF = /^trace_[A-Za-z0-9_-]{8,128}$/u;
63079
63172
  var KINDS = /* @__PURE__ */ new Set([
63080
63173
  "purchase_unknown",
@@ -63771,7 +63864,7 @@ function payloadWithout(input, ...keys) {
63771
63864
  return Object.fromEntries(Object.entries(input).filter(([key3, value]) => !omitted.has(key3) && value !== void 0));
63772
63865
  }
63773
63866
  function personalAssistantMessagingServiceReviewDigest(review) {
63774
- return createHash60("sha256").update(JSON.stringify({
63867
+ return createHash61("sha256").update(JSON.stringify({
63775
63868
  schemaVersion: "assistant-messaging-service-review.v1",
63776
63869
  numberRef: review.numberRef,
63777
63870
  connectionRef: review.connectionRef,
@@ -63905,7 +63998,7 @@ function ownerCaller(c) {
63905
63998
  throw new OwnerRouteError("not_authenticated", "Authentication is required.", 401);
63906
63999
  }
63907
64000
  if (ownerUserId2 <= 0n) throw new OwnerRouteError("not_authenticated", "Authentication is required.", 401);
63908
- const subjectRef = `owner_${createHash60("sha256").update(ownerUserId2.toString()).digest("hex").slice(0, 24)}`;
64001
+ const subjectRef = `owner_${createHash61("sha256").update(ownerUserId2.toString()).digest("hex").slice(0, 24)}`;
63909
64002
  return { kind: "owner", surface: "rest", ownerUserId: ownerUserId2, subjectRef };
63910
64003
  }
63911
64004
  function enrollmentRequesterBinding(c, caller2) {
@@ -64681,7 +64774,7 @@ function buildPersonalAssistantBrowserProfileRoutes(options) {
64681
64774
  }
64682
64775
 
64683
64776
  // src/api/personal-assistant-browser-production.ts
64684
- import { createHash as createHash64, randomUUID as randomUUID52 } from "crypto";
64777
+ import { createHash as createHash65, randomUUID as randomUUID52 } from "crypto";
64685
64778
 
64686
64779
  // src/api/personal-assistant-browser-handoff-store.ts
64687
64780
  import { createHmac as createHmac12, randomUUID as randomUUID48 } from "crypto";
@@ -64975,7 +65068,7 @@ function createPostgresPersonalAssistantBrowserHandoffStore(options) {
64975
65068
  }
64976
65069
 
64977
65070
  // src/api/personal-assistant-browser-profile-store.ts
64978
- import { createHash as createHash61, createHmac as createHmac13, randomUUID as randomUUID49 } from "crypto";
65071
+ import { createHash as createHash62, createHmac as createHmac13, randomUUID as randomUUID49 } from "crypto";
64979
65072
  import { domainToASCII } from "url";
64980
65073
  var PersonalAssistantBrowserProfileStoreError = class extends Error {
64981
65074
  constructor(code, message = code, status = code.endsWith("revision_conflict") ? 409 : code.endsWith("input_rejected") ? 400 : 404) {
@@ -65105,7 +65198,7 @@ function deriveBrowserProviderNamespaceDigest(keyInput, ownerUserId2, profileRef
65105
65198
  }
65106
65199
  function digestEvidence(value) {
65107
65200
  const canonical3 = JSON.stringify(value, (_key, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b))) : entry);
65108
- return createHash61("sha256").update(canonical3).digest("hex");
65201
+ return createHash62("sha256").update(canonical3).digest("hex");
65109
65202
  }
65110
65203
  function exactCapabilityList(value, allowed) {
65111
65204
  if (!Array.isArray(value)) return [];
@@ -65511,7 +65604,7 @@ function createPostgresPersonalAssistantBrowserProfileStore(options) {
65511
65604
  }
65512
65605
 
65513
65606
  // src/api/personal-assistant-idempotency-store.ts
65514
- import { createHash as createHash62, randomUUID as randomUUID50 } from "crypto";
65607
+ import { createHash as createHash63, randomUUID as randomUUID50 } from "crypto";
65515
65608
  var PersonalAssistantIdempotencyConflictError = class extends Error {
65516
65609
  code = "idempotency_conflict";
65517
65610
  status = 409;
@@ -65540,7 +65633,7 @@ function jsonValue(value) {
65540
65633
  return JSON.parse(serialized);
65541
65634
  }
65542
65635
  function resultDigest(value) {
65543
- return createHash62("sha256").update(canonicalJson4(value)).digest("hex");
65636
+ return createHash63("sha256").update(canonicalJson4(value)).digest("hex");
65544
65637
  }
65545
65638
  function timestamp3(value) {
65546
65639
  return value instanceof Date ? value.toISOString() : new Date(value).toISOString();
@@ -65623,7 +65716,7 @@ function createPostgresPersonalAssistantIdempotencyStore(options = {}) {
65623
65716
  }
65624
65717
 
65625
65718
  // src/api/personal-assistant-browser-account-cleanup.ts
65626
- import { createHash as createHash63, randomUUID as randomUUID51 } from "crypto";
65719
+ import { createHash as createHash64, randomUUID as randomUUID51 } from "crypto";
65627
65720
  function positiveOwner2(value) {
65628
65721
  if (typeof value !== "bigint" || value <= 0n) throw new TypeError("positive ownerUserId is required");
65629
65722
  return value.toString();
@@ -65685,7 +65778,7 @@ function createPersonalAssistantBrowserAccountCleanup(options) {
65685
65778
  cleanupRef: `cleanup_${randomUUID51().replaceAll("-", "")}`,
65686
65779
  state: "confirmed",
65687
65780
  ...evidence,
65688
- evidenceDigest: createHash63("sha256").update(JSON.stringify(evidence)).digest("hex")
65781
+ evidenceDigest: createHash64("sha256").update(JSON.stringify(evidence)).digest("hex")
65689
65782
  });
65690
65783
  };
65691
65784
  }
@@ -65712,7 +65805,7 @@ var VERIFIED_BROWSER_CAPABILITIES = Object.freeze([
65712
65805
  "download"
65713
65806
  ]);
65714
65807
  function digest5(value) {
65715
- return createHash64("sha256").update(JSON.stringify(value, (_key, entry) => {
65808
+ return createHash65("sha256").update(JSON.stringify(value, (_key, entry) => {
65716
65809
  if (typeof entry === "bigint") return entry.toString();
65717
65810
  if (!entry || typeof entry !== "object" || Array.isArray(entry)) return entry;
65718
65811
  return Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b)));
@@ -66283,7 +66376,7 @@ var personalAssistantBrowserHandoffApp = buildPersonalAssistantBrowserHandoffRou
66283
66376
  import { Hono as Hono46 } from "hono";
66284
66377
 
66285
66378
  // src/api/personal-assistant-worker-routes.ts
66286
- import { createHash as createHash65, createPublicKey, verify as verify2 } from "crypto";
66379
+ import { createHash as createHash66, createPublicKey, verify as verify2 } from "crypto";
66287
66380
  import { Hono as Hono45 } from "hono";
66288
66381
  import { z as z49 } from "zod";
66289
66382
  var PERSONAL_ASSISTANT_WORKER_API_PREFIX = "/api/private/v1/assistant-worker";
@@ -66313,11 +66406,11 @@ function canonicalJson5(value) {
66313
66406
  return JSON.stringify(value);
66314
66407
  }
66315
66408
  function personalAssistantWorkerBodyDigest(rawBody) {
66316
- return createHash65("sha256").update(rawBody, "utf8").digest("hex");
66409
+ return createHash66("sha256").update(rawBody, "utf8").digest("hex");
66317
66410
  }
66318
66411
  function personalAssistantPlanDigest(plan) {
66319
66412
  const { planRef: _planRef, planDigest: _planDigest, immutable: _immutable, createdAt: _createdAt, ...proposal } = plan;
66320
- return createHash65("sha256").update(canonicalJson5(proposal)).digest("hex");
66413
+ return createHash66("sha256").update(canonicalJson5(proposal)).digest("hex");
66321
66414
  }
66322
66415
  function personalAssistantWorkerSigningPayload(input) {
66323
66416
  return [
@@ -66471,7 +66564,7 @@ function verifyPolicyEnvelope(identity, envelope, at) {
66471
66564
  if (Date.parse(envelope.expiresAt) <= at.getTime() || Math.abs(at.getTime() - Date.parse(envelope.createdAt)) > 6e4) {
66472
66565
  throw new AssistantWorkerRouteError("worker_policy_request_expired", "The policy request has expired.", 401);
66473
66566
  }
66474
- const expectedDigest = createHash65("sha256").update(canonicalJson5(envelope.body)).digest("hex");
66567
+ const expectedDigest = createHash66("sha256").update(canonicalJson5(envelope.body)).digest("hex");
66475
66568
  if (expectedDigest !== envelope.bodyDigest) throw new AssistantWorkerRouteError("worker_policy_digest_mismatch", "The policy request digest does not match.", 401);
66476
66569
  const { signature, ...unsigned } = envelope;
66477
66570
  let valid = false;
@@ -66489,7 +66582,7 @@ function verifyClaimEnvelope(identity, envelope, at) {
66489
66582
  if (Math.abs(at.getTime() - Date.parse(envelope.createdAt)) > PERSONAL_ASSISTANT_WORKER_SIGNATURE_TTL_MS) {
66490
66583
  throw new AssistantWorkerRouteError("worker_claim_expired", "The worker claim has expired.", 401);
66491
66584
  }
66492
- const expectedDigest = createHash65("sha256").update(canonicalJson5(envelope.body)).digest("hex");
66585
+ const expectedDigest = createHash66("sha256").update(canonicalJson5(envelope.body)).digest("hex");
66493
66586
  if (expectedDigest !== envelope.bodyDigest) throw new AssistantWorkerRouteError("worker_claim_digest_mismatch", "The claim digest does not match.", 401);
66494
66587
  const { signature, ...unsigned } = envelope;
66495
66588
  let valid = false;
@@ -66792,12 +66885,12 @@ var personalAssistantWorkerProductionApp = (() => {
66792
66885
  })();
66793
66886
 
66794
66887
  // src/api/personal-assistant-admin-routes.ts
66795
- import { createHash as createHash67, createPublicKey as createPublicKey2 } from "crypto";
66888
+ import { createHash as createHash68, createPublicKey as createPublicKey2 } from "crypto";
66796
66889
  import { Hono as Hono47 } from "hono";
66797
66890
  import { z as z50 } from "zod";
66798
66891
 
66799
66892
  // src/api/personal-assistant-kill-controls.ts
66800
- import { createHash as createHash66, randomUUID as randomUUID53 } from "crypto";
66893
+ import { createHash as createHash67, randomUUID as randomUUID53 } from "crypto";
66801
66894
  var PERSONAL_ASSISTANT_KILL_SCOPES = [
66802
66895
  "global",
66803
66896
  "outbound",
@@ -66825,7 +66918,7 @@ function canonicalJson6(value) {
66825
66918
  return JSON.stringify(value);
66826
66919
  }
66827
66920
  function digest6(value) {
66828
- return createHash66("sha256").update(canonicalJson6(value)).digest("hex");
66921
+ return createHash67("sha256").update(canonicalJson6(value)).digest("hex");
66829
66922
  }
66830
66923
  function validateTarget(target) {
66831
66924
  if (!PERSONAL_ASSISTANT_KILL_SCOPES.includes(target.scope)) throw new PersonalAssistantKillControlError("invalid_kill_control", "Invalid kill-control scope.", 400);
@@ -67093,7 +67186,7 @@ async function strictJson2(c, maxBodyBytes) {
67093
67186
  }
67094
67187
  }
67095
67188
  function derivedRef(prefix, ...identity) {
67096
- return `${prefix}_${createHash67("sha256").update(identity.join("\0")).digest("base64url").slice(0, 32)}`;
67189
+ return `${prefix}_${createHash68("sha256").update(identity.join("\0")).digest("base64url").slice(0, 32)}`;
67097
67190
  }
67098
67191
  function ownerUserId(target) {
67099
67192
  if (!/^[1-9][0-9]{0,18}$/.test(target.targetKey)) {
@@ -67179,7 +67272,7 @@ function buildPersonalAssistantAdminRoutes(options) {
67179
67272
  const identity = c.get("assistantAdmin");
67180
67273
  requireCapability(identity, "assistant.worker_registration.register");
67181
67274
  const parsed = WorkerRegistrationSchema.safeParse(await strictJson2(c, maxBodyBytes));
67182
- if (!parsed.success || Date.parse(parsed.data.expiresAt) <= now().getTime() || !/^-----BEGIN PUBLIC KEY-----\n[\s\S]+\n-----END PUBLIC KEY-----\n?$/.test(parsed.data.publicKeyPem) || /PRIVATE KEY|ENCRYPTED/.test(parsed.data.publicKeyPem) || createHash67("sha256").update(parsed.success ? parsed.data.publicKeyPem : "").digest("hex") !== (parsed.success ? parsed.data.publicKeySha256 : "")) {
67275
+ if (!parsed.success || Date.parse(parsed.data.expiresAt) <= now().getTime() || !/^-----BEGIN PUBLIC KEY-----\n[\s\S]+\n-----END PUBLIC KEY-----\n?$/.test(parsed.data.publicKeyPem) || /PRIVATE KEY|ENCRYPTED/.test(parsed.data.publicKeyPem) || createHash68("sha256").update(parsed.success ? parsed.data.publicKeyPem : "").digest("hex") !== (parsed.success ? parsed.data.publicKeySha256 : "")) {
67183
67276
  throw new PersonalAssistantAdminRouteError("invalid_worker_registration", "Invalid worker registration request.", 400);
67184
67277
  }
67185
67278
  try {
@@ -67305,24 +67398,24 @@ var personalAssistantCronProductionApp = (() => {
67305
67398
  })();
67306
67399
 
67307
67400
  // src/api/personal-assistant-production.ts
67308
- import { createHash as createHash97 } from "crypto";
67401
+ import { createHash as createHash98 } from "crypto";
67309
67402
 
67310
67403
  // src/api/personal-assistant-admin-production.ts
67311
- import { createHash as createHash71 } from "crypto";
67404
+ import { createHash as createHash72 } from "crypto";
67312
67405
 
67313
67406
  // src/api/personal-assistant-worker-store.ts
67314
- import { createHash as createHash70, randomUUID as randomUUID55 } from "crypto";
67407
+ import { createHash as createHash71, randomUUID as randomUUID55 } from "crypto";
67315
67408
 
67316
67409
  // src/api/personal-assistant-repository.ts
67317
- import { createHash as createHash69, randomBytes as randomBytes7, randomUUID as randomUUID54 } from "crypto";
67410
+ import { createHash as createHash70, randomBytes as randomBytes7, randomUUID as randomUUID54 } from "crypto";
67318
67411
 
67319
67412
  // src/api/personal-assistant-wake-packet.ts
67320
- import { createHash as createHash68 } from "crypto";
67413
+ import { createHash as createHash69 } from "crypto";
67321
67414
  function stableJson(value) {
67322
67415
  return JSON.stringify(value, (_key, entry) => !entry || typeof entry !== "object" || Array.isArray(entry) ? entry : Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b))));
67323
67416
  }
67324
67417
  function stableDigest(value) {
67325
- return createHash68("sha256").update(stableJson(value)).digest("hex");
67418
+ return createHash69("sha256").update(stableJson(value)).digest("hex");
67326
67419
  }
67327
67420
  function deterministicWakePacketRef(snapshot) {
67328
67421
  return `wake_${stableDigest({ assistantRef: snapshot.assistantRef, commandRef: snapshot.commandRef, cycleRef: snapshot.cycleRef, executionRef: snapshot.executionRef, contextVersionRef: snapshot.contextVersion.contextVersionRef }).slice(0, 32)}`;
@@ -67375,10 +67468,10 @@ function canonicalJson7(value) {
67375
67468
  });
67376
67469
  }
67377
67470
  function digest7(value) {
67378
- return createHash69("sha256").update(canonicalJson7(value)).digest("hex");
67471
+ return createHash70("sha256").update(canonicalJson7(value)).digest("hex");
67379
67472
  }
67380
67473
  function deterministicRef2(prefix, identity) {
67381
- return `${prefix}_${createHash69("sha256").update(identity).digest("hex").slice(0, 32)}`;
67474
+ return `${prefix}_${createHash70("sha256").update(identity).digest("hex").slice(0, 32)}`;
67382
67475
  }
67383
67476
  function messageCursor(message) {
67384
67477
  return Buffer.from(JSON.stringify([message.occurredAt, message.messageRef])).toString("base64url");
@@ -67874,7 +67967,7 @@ function createPostgresPersonalAssistantRepositoryStore(options = {}) {
67874
67967
  `, [ownerUserId2.toString(), row.id]);
67875
67968
  }
67876
67969
  const token7 = randomBytes7(32).toString("base64url");
67877
- const tokenHash5 = createHash69("sha256").update(token7).digest("hex");
67970
+ const tokenHash5 = createHash70("sha256").update(token7).digest("hex");
67878
67971
  const leaseRef = deterministicRef2("lease", `${input.executionRef}\0${input.workerRef}\0${input.now}`);
67879
67972
  const expiresAt = new Date(Date.parse(input.now) + input.leaseSeconds * 1e3).toISOString();
67880
67973
  await client2.query(`
@@ -69412,10 +69505,10 @@ var AssistantWorkerStoreError = class extends Error {
69412
69505
  };
69413
69506
  function hash(value) {
69414
69507
  const canonical3 = JSON.stringify(value, (_key, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b))) : entry);
69415
- return createHash70("sha256").update(canonical3).digest("hex");
69508
+ return createHash71("sha256").update(canonical3).digest("hex");
69416
69509
  }
69417
69510
  function ref2(prefix, identity) {
69418
- return `${prefix}_${createHash70("sha256").update(identity).digest("hex").slice(0, 32)}`;
69511
+ return `${prefix}_${createHash71("sha256").update(identity).digest("hex").slice(0, 32)}`;
69419
69512
  }
69420
69513
  function requiredString(input, key3) {
69421
69514
  const value = input[key3];
@@ -69814,7 +69907,7 @@ var INTERNAL_CAPABILITIES = /* @__PURE__ */ new Set([
69814
69907
  "assistant.worker_registration.revoke"
69815
69908
  ]);
69816
69909
  function actorRef(issuer, subject) {
69817
- return `admin_actor_${createHash71("sha256").update(`${issuer}\0${subject}`).digest("base64url").slice(0, 32)}`;
69910
+ return `admin_actor_${createHash72("sha256").update(`${issuer}\0${subject}`).digest("base64url").slice(0, 32)}`;
69818
69911
  }
69819
69912
  var VerifiedPersonalAssistantAdminIdentityPort = class {
69820
69913
  constructor(verifier, configuration) {
@@ -69928,7 +70021,7 @@ function createPersonalAssistantAdminProductionDependencies(input) {
69928
70021
  }
69929
70022
 
69930
70023
  // src/api/personal-assistant-dispatcher.ts
69931
- import { createHash as createHash72, randomBytes as randomBytes8, randomUUID as randomUUID56 } from "crypto";
70024
+ import { createHash as createHash73, randomBytes as randomBytes8, randomUUID as randomUUID56 } from "crypto";
69932
70025
  var AssistantLeaseFenceError = class extends Error {
69933
70026
  code = "assistant_lease_fence_rejected";
69934
70027
  constructor() {
@@ -69942,7 +70035,7 @@ function canonical2(value) {
69942
70035
  return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key3, entry]) => [key3, canonical2(entry)]));
69943
70036
  }
69944
70037
  function digest8(value) {
69945
- return createHash72("sha256").update(JSON.stringify(canonical2(value))).digest("hex");
70038
+ return createHash73("sha256").update(JSON.stringify(canonical2(value))).digest("hex");
69946
70039
  }
69947
70040
  function ref3(prefix, identity) {
69948
70041
  return `${prefix}_${digest8(identity).slice(0, 32)}`;
@@ -70806,10 +70899,10 @@ function createPersonalAssistantReminderRuntime(options) {
70806
70899
  }
70807
70900
 
70808
70901
  // src/api/personal-assistant-reconcile-cron.ts
70809
- import { createHash as createHash74, timingSafeEqual as timingSafeEqual8 } from "crypto";
70902
+ import { createHash as createHash75, timingSafeEqual as timingSafeEqual8 } from "crypto";
70810
70903
 
70811
70904
  // src/api/personal-assistant-reconcile.ts
70812
- import { createHash as createHash73 } from "crypto";
70905
+ import { createHash as createHash74 } from "crypto";
70813
70906
  var PERSONAL_ASSISTANT_RECONCILIATION_LIMITS = Object.freeze({
70814
70907
  defaultBatchSize: 20,
70815
70908
  maxBatchSize: 50,
@@ -70831,7 +70924,7 @@ var PUBLIC_REF = /^[a-z][a-z0-9_]*_[A-Za-z0-9_-]{3,128}$/u;
70831
70924
  var DIGEST2 = /^[a-f0-9]{64}$/u;
70832
70925
  var PROVIDER_REF = /^[A-Za-z0-9:_-]{3,200}$/u;
70833
70926
  function hash2(value) {
70834
- return createHash73("sha256").update(value).digest("hex");
70927
+ return createHash74("sha256").update(value).digest("hex");
70835
70928
  }
70836
70929
  function validateCandidate(candidate) {
70837
70930
  if (!/^[1-9]\d*$/u.test(candidate.ownerUserId) || !PUBLIC_REF.test(candidate.candidateRef) || !/^trace_[A-Za-z0-9_-]{8,128}$/u.test(candidate.traceRef) || !PUBLIC_REF.test(candidate.claimToken) || !PROVIDER_REF.test(candidate.providerAccountRef) || !PROVIDER_REF.test(candidate.providerLocatorRef) || !DIGEST2.test(candidate.expectedDigest) || !Number.isFinite(Date.parse(candidate.stuckSince))) {
@@ -70953,8 +71046,8 @@ async function reconcilePersonalAssistantTransports(dependencies, options = {})
70953
71046
  // src/api/personal-assistant-reconcile-cron.ts
70954
71047
  function authorized(actual, expectedSecret) {
70955
71048
  if (!actual?.startsWith("Bearer ")) return false;
70956
- const actualDigest = createHash74("sha256").update(actual).digest();
70957
- const expectedDigest = createHash74("sha256").update(`Bearer ${expectedSecret}`).digest();
71049
+ const actualDigest = createHash75("sha256").update(actual).digest();
71050
+ const expectedDigest = createHash75("sha256").update(`Bearer ${expectedSecret}`).digest();
70958
71051
  return timingSafeEqual8(actualDigest, expectedDigest);
70959
71052
  }
70960
71053
  function createPersonalAssistantReconcileCronHandler(options) {
@@ -71016,7 +71109,7 @@ function createPersonalAssistantReminderCronHandler(options) {
71016
71109
  }
71017
71110
 
71018
71111
  // src/api/twilio-inbound-admission.ts
71019
- import { createHash as createHash75, randomBytes as randomBytes9 } from "crypto";
71112
+ import { createHash as createHash76, randomBytes as randomBytes9 } from "crypto";
71020
71113
  var ACCOUNT_SID = /^AC[0-9a-f]{32}$/iu;
71021
71114
  var MESSAGE_SID = /^(?:SM|MM)[0-9a-f]{32}$/iu;
71022
71115
  var MESSAGING_SERVICE_SID = /^MG[0-9a-f]{32}$/iu;
@@ -71038,10 +71131,10 @@ function canonicalJson8(value) {
71038
71131
  });
71039
71132
  }
71040
71133
  function digest9(value) {
71041
- return createHash75("sha256").update(canonicalJson8(value)).digest("hex");
71134
+ return createHash76("sha256").update(canonicalJson8(value)).digest("hex");
71042
71135
  }
71043
71136
  function stableRef(prefix, value) {
71044
- return `${prefix}_${createHash75("sha256").update(value).digest("hex").slice(0, 32)}`;
71137
+ return `${prefix}_${createHash76("sha256").update(value).digest("hex").slice(0, 32)}`;
71045
71138
  }
71046
71139
  function normalizeOptionalSid(value) {
71047
71140
  const normalized = value?.trim() || null;
@@ -71187,8 +71280,8 @@ function createTwilioInboundIngressCronHandler(options) {
71187
71280
  return async (request) => {
71188
71281
  if (request.method !== "GET") return Response.json({ error: "method_not_allowed" }, { status: 405, headers: { Allow: "GET" } });
71189
71282
  const actual = request.headers.get("authorization") ?? "";
71190
- const actualDigest = createHash75("sha256").update(actual).digest();
71191
- const expectedDigest = createHash75("sha256").update(expectedAuthorization).digest();
71283
+ const actualDigest = createHash76("sha256").update(actual).digest();
71284
+ const expectedDigest = createHash76("sha256").update(expectedAuthorization).digest();
71192
71285
  if (actualDigest.length !== expectedDigest.length || !actualDigest.equals(expectedDigest)) {
71193
71286
  return Response.json({ error: "unauthorized" }, { status: 401 });
71194
71287
  }
@@ -71230,7 +71323,7 @@ function createPersonalAssistantWorkerAndCronProduction(options) {
71230
71323
  }
71231
71324
 
71232
71325
  // src/api/personal-assistant-control-plane-store.ts
71233
- import { createHash as createHash76, randomUUID as randomUUID57 } from "crypto";
71326
+ import { createHash as createHash77, randomUUID as randomUUID57 } from "crypto";
71234
71327
  var REF = /^[a-z][A-Za-z0-9_-]{2,159}$/;
71235
71328
  var DIGEST4 = /^[a-f0-9]{64}$/;
71236
71329
  function record3(input) {
@@ -71262,7 +71355,7 @@ function canonicalJson9(value) {
71262
71355
  });
71263
71356
  }
71264
71357
  function digest10(value) {
71265
- return createHash76("sha256").update(canonicalJson9(value)).digest("hex");
71358
+ return createHash77("sha256").update(canonicalJson9(value)).digest("hex");
71266
71359
  }
71267
71360
  function normalizeE164(value) {
71268
71361
  const trimmed = value.trim();
@@ -71691,7 +71784,7 @@ function createPostgresPersonalAssistantNumberPort(options) {
71691
71784
  }
71692
71785
 
71693
71786
  // src/api/personal-assistant-scheduling-store.ts
71694
- import { createHash as createHash77, randomUUID as randomUUID58 } from "crypto";
71787
+ import { createHash as createHash78, randomUUID as randomUUID58 } from "crypto";
71695
71788
  var PersonalAssistantSchedulingStoreError = class extends Error {
71696
71789
  constructor(code, message = code, status = code === "schedule_not_found" ? 404 : code === "schedule_activation_unavailable" ? 503 : 409) {
71697
71790
  super(message);
@@ -71718,7 +71811,7 @@ function canonicalJson10(value) {
71718
71811
  return JSON.stringify(value);
71719
71812
  }
71720
71813
  function digest11(value) {
71721
- return createHash77("sha256").update(canonicalJson10(value)).digest("hex");
71814
+ return createHash78("sha256").update(canonicalJson10(value)).digest("hex");
71722
71815
  }
71723
71816
  function authorityClass(value) {
71724
71817
  if (value === "observe") return "observe";
@@ -72162,7 +72255,7 @@ function assertNoRawTwilioSecretEnvironment(environment2 = process.env) {
72162
72255
  }
72163
72256
 
72164
72257
  // src/api/twilio-messaging-service.ts
72165
- import { createHash as createHash78 } from "crypto";
72258
+ import { createHash as createHash79 } from "crypto";
72166
72259
 
72167
72260
  // src/api/personal-assistant-policy.ts
72168
72261
  var AUTHORITY_RANK = {
@@ -72462,10 +72555,10 @@ function canonicalJson11(value) {
72462
72555
  });
72463
72556
  }
72464
72557
  function digest12(value) {
72465
- return createHash78("sha256").update(canonicalJson11(value)).digest("hex");
72558
+ return createHash79("sha256").update(canonicalJson11(value)).digest("hex");
72466
72559
  }
72467
72560
  function deterministicRef3(prefix, identity) {
72468
- return `${prefix}_${createHash78("sha256").update(identity).digest("hex").slice(0, 32)}`;
72561
+ return `${prefix}_${createHash79("sha256").update(identity).digest("hex").slice(0, 32)}`;
72469
72562
  }
72470
72563
  function isBoundedAuthorityRef(value) {
72471
72564
  return typeof value === "string" && value.length >= 3 && value.length <= 240 && !value.includes("\0");
@@ -72637,7 +72730,7 @@ function inboundIdentity(input, route) {
72637
72730
  };
72638
72731
  }
72639
72732
  function sha256Bytes(bytes2) {
72640
- return createHash78("sha256").update(bytes2).digest("hex");
72733
+ return createHash79("sha256").update(bytes2).digest("hex");
72641
72734
  }
72642
72735
  function startsWith(bytes2, signature) {
72643
72736
  return signature.every((value, index) => bytes2[index] === value);
@@ -73816,11 +73909,11 @@ function createTwilioMessagingService(dependencies = {}) {
73816
73909
  }
73817
73910
 
73818
73911
  // src/api/twilio-memory-media.ts
73819
- import { createHash as createHash79, randomUUID as randomUUID59 } from "crypto";
73912
+ import { createHash as createHash80, randomUUID as randomUUID59 } from "crypto";
73820
73913
  var IMAGE_TYPES = /* @__PURE__ */ new Set(["image/jpeg", "image/png", "image/gif", "image/webp"]);
73821
73914
  var FILE_TYPES = /* @__PURE__ */ new Set(["application/pdf", "text/plain"]);
73822
73915
  function digestBytes(bytes2) {
73823
- return createHash79("sha256").update(bytes2).digest("hex");
73916
+ return createHash80("sha256").update(bytes2).digest("hex");
73824
73917
  }
73825
73918
  function publicPointer(pointer) {
73826
73919
  return Object.freeze({
@@ -73904,7 +73997,7 @@ function createTwilioMemoryMedia(options) {
73904
73997
  return publicPointer(await options.pointers.put({
73905
73998
  ownerBindingRef: input.ownerBindingRef,
73906
73999
  mediaRef: input.mediaRef,
73907
- renewablePointerRef: `memory_asset_${createHash79("sha256").update(`${input.ownerBindingRef}\0${asset.assetId}`).digest("hex").slice(0, 32)}`,
74000
+ renewablePointerRef: `memory_asset_${createHash80("sha256").update(`${input.ownerBindingRef}\0${asset.assetId}`).digest("hex").slice(0, 32)}`,
73908
74001
  byteDigest: input.byteDigest,
73909
74002
  contentType: input.contentType,
73910
74003
  byteSize: input.bytes.byteLength,
@@ -73937,7 +74030,7 @@ function createTwilioMemoryMedia(options) {
73937
74030
  }
73938
74031
 
73939
74032
  // src/api/twilio-provider-facade.ts
73940
- import { createHash as createHash80 } from "crypto";
74033
+ import { createHash as createHash81 } from "crypto";
73941
74034
 
73942
74035
  // src/api/twilio-messaging-client.ts
73943
74036
  import twilio4 from "twilio";
@@ -74272,7 +74365,7 @@ function validAuthority(input) {
74272
74365
  return /^[1-9]\d*$/u.test(input.ownerUserId) && PUBLIC_REF2.test(input.executionRef) && ACCOUNT_SID3.test(input.providerAccountRef) && PUBLIC_REF2.test(input.connectionRef) && /^[A-Za-z][A-Za-z0-9_.:-]{2,159}$/u.test(input.environmentRef);
74273
74366
  }
74274
74367
  function digest13(value) {
74275
- return createHash80("sha256").update(JSON.stringify(value, (_key, entry) => {
74368
+ return createHash81("sha256").update(JSON.stringify(value, (_key, entry) => {
74276
74369
  if (!entry || typeof entry !== "object" || Array.isArray(entry)) return entry;
74277
74370
  return Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b)));
74278
74371
  })).digest("hex");
@@ -74461,7 +74554,7 @@ function createTwilioProduction(options) {
74461
74554
  }
74462
74555
 
74463
74556
  // src/runtime/personal-assistant-deployment-config.ts
74464
- import { createHash as createHash81 } from "crypto";
74557
+ import { createHash as createHash82 } from "crypto";
74465
74558
  import { readFileSync as readFileSync4 } from "fs";
74466
74559
  import { resolve as resolve2 } from "path";
74467
74560
  var REF_PATTERN = /^(?:[a-z][a-z0-9+.-]*:\/\/)?[A-Za-z0-9][A-Za-z0-9._:/-]{2,240}$/;
@@ -74497,7 +74590,7 @@ function databaseBinding(value) {
74497
74590
  const database = decodeURIComponent(parsed.pathname.replace(/^\//, ""));
74498
74591
  const role = decodeURIComponent(parsed.username);
74499
74592
  if (!database || !/^[a-z_][a-z0-9_]*$/.test(role)) return null;
74500
- return { fingerprint: createHash81("sha256").update(`${labels.join(".")}\0${database}`).digest("hex"), role };
74593
+ return { fingerprint: createHash82("sha256").update(`${labels.join(".")}\0${database}`).digest("hex"), role };
74501
74594
  } catch {
74502
74595
  return null;
74503
74596
  }
@@ -74959,7 +75052,7 @@ function createPersonalAssistantHostedConfigurationAdapter(input) {
74959
75052
  }
74960
75053
 
74961
75054
  // src/api/personal-assistant-authorization.ts
74962
- import { createHash as createHash82 } from "crypto";
75055
+ import { createHash as createHash83 } from "crypto";
74963
75056
  import { z as z51 } from "zod";
74964
75057
  var ABUSE_GATED_OPERATIONS = /* @__PURE__ */ new Set(["assistant.message.send", "assistant.bulk.send"]);
74965
75058
  var NORMALIZED_RECIPIENT_OPERATIONS = /* @__PURE__ */ new Set([
@@ -75137,7 +75230,7 @@ function canonicalJson12(value) {
75137
75230
  return JSON.stringify(value, (_key, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b))) : entry);
75138
75231
  }
75139
75232
  function factDigest(value) {
75140
- return createHash82("sha256").update(canonicalJson12(value)).digest("hex");
75233
+ return createHash83("sha256").update(canonicalJson12(value)).digest("hex");
75141
75234
  }
75142
75235
  var PostgresPersonalAssistantPolicyFactsRepository = class {
75143
75236
  constructor(db, contexts, now = () => /* @__PURE__ */ new Date()) {
@@ -75327,7 +75420,7 @@ var PostgresPersonalAssistantPolicyFactsRepository = class {
75327
75420
  };
75328
75421
 
75329
75422
  // src/api/personal-assistant-abuse-controls.ts
75330
- import { createHash as createHash83 } from "crypto";
75423
+ import { createHash as createHash84 } from "crypto";
75331
75424
  var EMPTY_STATE = () => ({
75332
75425
  version: 1,
75333
75426
  events: [],
@@ -75338,7 +75431,7 @@ var EMPTY_STATE = () => ({
75338
75431
  bulkIdentities: {}
75339
75432
  });
75340
75433
  function digest14(value) {
75341
- return createHash83("sha256").update(JSON.stringify(value)).digest("hex");
75434
+ return createHash84("sha256").update(JSON.stringify(value)).digest("hex");
75342
75435
  }
75343
75436
  function isDigest(value) {
75344
75437
  return typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
@@ -75598,10 +75691,10 @@ var PostgresPersonalAssistantAbuseStore = class {
75598
75691
  };
75599
75692
 
75600
75693
  // src/api/twilio-authority-billing-postgres.ts
75601
- import { createHash as createHash85, randomUUID as randomUUID60 } from "crypto";
75694
+ import { createHash as createHash86, randomUUID as randomUUID60 } from "crypto";
75602
75695
 
75603
75696
  // src/api/personal-assistant-billing.ts
75604
- import { createHash as createHash84 } from "crypto";
75697
+ import { createHash as createHash85 } from "crypto";
75605
75698
  var AssistantBillingError = class extends Error {
75606
75699
  constructor(code, message) {
75607
75700
  super(message);
@@ -75618,7 +75711,7 @@ function canonicalJson13(value) {
75618
75711
  });
75619
75712
  }
75620
75713
  function digest15(value) {
75621
- return createHash84("sha256").update(canonicalJson13(value)).digest("hex");
75714
+ return createHash85("sha256").update(canonicalJson13(value)).digest("hex");
75622
75715
  }
75623
75716
  function assertMoney(value, field) {
75624
75717
  if (!Number.isSafeInteger(value) || value < 0) throw new AssistantBillingError("billing_invalid_input", `${field} must be a non-negative safe integer.`);
@@ -75663,7 +75756,7 @@ function canonicalJson14(value) {
75663
75756
  });
75664
75757
  }
75665
75758
  function digest16(value) {
75666
- return createHash85("sha256").update(canonicalJson14(value)).digest("hex");
75759
+ return createHash86("sha256").update(canonicalJson14(value)).digest("hex");
75667
75760
  }
75668
75761
  function amountFor2(usage) {
75669
75762
  return usage.reduce((sum2, item) => sum2 + item.units * item.rateMinorPerUnit, 0);
@@ -75898,7 +75991,7 @@ function createPostgresAssistantBillingStore(options = {}) {
75898
75991
  import {
75899
75992
  createCipheriv as createCipheriv3,
75900
75993
  createDecipheriv as createDecipheriv3,
75901
- createHash as createHash86,
75994
+ createHash as createHash87,
75902
75995
  createHmac as createHmac14,
75903
75996
  randomBytes as randomBytes10
75904
75997
  } from "crypto";
@@ -75956,7 +76049,7 @@ function canonicalContext(input) {
75956
76049
  });
75957
76050
  }
75958
76051
  function contextDigest(context) {
75959
- return createHash86("sha256").update(context, "utf8").digest("hex");
76052
+ return createHash87("sha256").update(context, "utf8").digest("hex");
75960
76053
  }
75961
76054
  function decodeBase64Url(value, expectedBytes) {
75962
76055
  if (!value || !BASE64URL.test(value)) throw new PersonalAssistantProtectedDataCryptoError("protected_data_envelope_invalid");
@@ -76145,8 +76238,8 @@ async function resolvePersonalAssistantProtectedDataCryptoFactory(options) {
76145
76238
  }
76146
76239
 
76147
76240
  // src/api/twilio-first-text-context-postgres.ts
76148
- import { createHash as createHash87 } from "crypto";
76149
- var digest17 = (value) => createHash87("sha256").update(value).digest("hex");
76241
+ import { createHash as createHash88 } from "crypto";
76242
+ var digest17 = (value) => createHash88("sha256").update(value).digest("hex");
76150
76243
  function createPostgresTwilioFirstTextDiagnosticContextResolver(options = {}) {
76151
76244
  const queryable = options.queryable ?? getAssistantPool();
76152
76245
  return async (input) => {
@@ -76191,10 +76284,10 @@ function createPostgresTwilioFirstTextDiagnosticContextResolver(options = {}) {
76191
76284
  }
76192
76285
 
76193
76286
  // src/api/twilio-first-text-diagnostic-postgres.ts
76194
- import { createHash as createHash89, randomBytes as randomBytes12, randomUUID as randomUUID61 } from "crypto";
76287
+ import { createHash as createHash90, randomBytes as randomBytes12, randomUUID as randomUUID61 } from "crypto";
76195
76288
 
76196
76289
  // src/api/twilio-first-text-diagnostic.ts
76197
- import { createHash as createHash88, randomBytes as randomBytes11 } from "crypto";
76290
+ import { createHash as createHash89, randomBytes as randomBytes11 } from "crypto";
76198
76291
  var TWILIO_FIRST_TEXT_BODY = ASSISTANT_CONSENT_CONTENT_V1.diagnosticMessage;
76199
76292
  var TwilioFirstTextDiagnosticError = class extends Error {
76200
76293
  constructor(code) {
@@ -76205,10 +76298,10 @@ var TwilioFirstTextDiagnosticError = class extends Error {
76205
76298
  code;
76206
76299
  };
76207
76300
  function digest18(value) {
76208
- return createHash88("sha256").update(JSON.stringify(value)).digest("hex");
76301
+ return createHash89("sha256").update(JSON.stringify(value)).digest("hex");
76209
76302
  }
76210
76303
  function stableRef2(prefix, identity) {
76211
- return `${prefix}_${createHash88("sha256").update(identity).digest("hex").slice(0, 32)}`;
76304
+ return `${prefix}_${createHash89("sha256").update(identity).digest("hex").slice(0, 32)}`;
76212
76305
  }
76213
76306
  function providerSid(result3) {
76214
76307
  const value = result3.receipt.providerMessageSid;
@@ -76320,14 +76413,14 @@ function createTwilioFirstTextDiagnosticService(dependencies) {
76320
76413
  var COLUMNS = `owner_user_id::text,public_id,idempotency_key,request_digest,policy_version,recipient_ref,sender_ref,
76321
76414
  state,mode,stages,provider_message_sid,inbound_event_ref,routing_receipt_ref,acknowledgement_receipt_ref,
76322
76415
  retry_eligible,failure_code,execution_token_digest,created_at,updated_at`;
76323
- var digest19 = (value) => createHash89("sha256").update(value).digest("hex");
76416
+ var digest19 = (value) => createHash90("sha256").update(value).digest("hex");
76324
76417
  var iso5 = (value) => new Date(value).toISOString();
76325
76418
  function receipt3(row) {
76326
76419
  return Object.freeze({
76327
76420
  diagnosticRef: row.public_id,
76328
76421
  ownerUserId: row.owner_user_id,
76329
76422
  idempotencyKey: row.idempotency_key,
76330
- executionRef: `execution_${createHash89("sha256").update(row.public_id).digest("hex").slice(0, 32)}`,
76423
+ executionRef: `execution_${createHash90("sha256").update(row.public_id).digest("hex").slice(0, 32)}`,
76331
76424
  requestDigest: row.request_digest,
76332
76425
  policyVersion: row.policy_version,
76333
76426
  recipientRef: row.recipient_ref,
@@ -76495,10 +76588,10 @@ function createTwilioInboundQuarantineClaimAuthorizer(options) {
76495
76588
  }
76496
76589
 
76497
76590
  // src/api/twilio-inbound-claim-control-plane-postgres.ts
76498
- import { createHash as createHash90, randomUUID as randomUUID62 } from "crypto";
76499
- var stableRef3 = (prefix, value) => `${prefix}_${createHash90("sha256").update(value).digest("hex").slice(0, 32)}`;
76591
+ import { createHash as createHash91, randomUUID as randomUUID62 } from "crypto";
76592
+ var stableRef3 = (prefix, value) => `${prefix}_${createHash91("sha256").update(value).digest("hex").slice(0, 32)}`;
76500
76593
  var stableUuid = (value) => {
76501
- const hex = createHash90("sha256").update(value).digest("hex").slice(0, 32).split("");
76594
+ const hex = createHash91("sha256").update(value).digest("hex").slice(0, 32).split("");
76502
76595
  hex[12] = "5";
76503
76596
  hex[16] = (Number.parseInt(hex[16], 16) & 3 | 8).toString(16);
76504
76597
  return `${hex.slice(0, 8).join("")}-${hex.slice(8, 12).join("")}-${hex.slice(12, 16).join("")}-${hex.slice(16, 20).join("")}-${hex.slice(20).join("")}`;
@@ -76580,12 +76673,12 @@ function createPostgresTwilioInboundClaimControlPlane(options) {
76580
76673
  }
76581
76674
 
76582
76675
  // src/api/twilio-inbound-envelope-postgres.ts
76583
- import { createHash as createHash92 } from "crypto";
76676
+ import { createHash as createHash93 } from "crypto";
76584
76677
 
76585
76678
  // src/api/twilio-inbound-admission-postgres.ts
76586
- import { createHash as createHash91, randomBytes as randomBytes13, randomUUID as randomUUID63 } from "crypto";
76679
+ import { createHash as createHash92, randomBytes as randomBytes13, randomUUID as randomUUID63 } from "crypto";
76587
76680
  function tokenHash4(value) {
76588
- return createHash91("sha256").update(value).digest("hex");
76681
+ return createHash92("sha256").update(value).digest("hex");
76589
76682
  }
76590
76683
  function rowToRecord(row) {
76591
76684
  return Object.freeze({
@@ -76754,7 +76847,7 @@ function createPostgresTwilioInboundAdmissionStore(options = {}) {
76754
76847
 
76755
76848
  // src/api/twilio-inbound-envelope-postgres.ts
76756
76849
  function stableRef4(prefix, identity) {
76757
- return `${prefix}_${createHash92("sha256").update(identity).digest("hex").slice(0, 32)}`;
76850
+ return `${prefix}_${createHash93("sha256").update(identity).digest("hex").slice(0, 32)}`;
76758
76851
  }
76759
76852
  function parseStoredEnvelope(value) {
76760
76853
  let parsed;
@@ -77116,11 +77209,11 @@ function createPostgresTwilioInboundQuarantineStore(options = {}) {
77116
77209
  }
77117
77210
 
77118
77211
  // src/api/twilio-inbound-quarantine.ts
77119
- import { createHash as createHash93, createHmac as createHmac15, timingSafeEqual as timingSafeEqual10 } from "crypto";
77212
+ import { createHash as createHash94, createHmac as createHmac15, timingSafeEqual as timingSafeEqual10 } from "crypto";
77120
77213
  var DIGEST7 = /^[a-f0-9]{64}$/u;
77121
77214
  var OPAQUE2 = /^[A-Za-z][A-Za-z0-9_.:-]{2,199}$/u;
77122
77215
  function digest20(value) {
77123
- return createHash93("sha256").update(value).digest("hex");
77216
+ return createHash94("sha256").update(value).digest("hex");
77124
77217
  }
77125
77218
  function stableRef5(prefix, identity) {
77126
77219
  return `${prefix}_${digest20(identity).slice(0, 32)}`;
@@ -77435,10 +77528,10 @@ async function createPersonalAssistantTwilioTransportProduction(options) {
77435
77528
  }
77436
77529
 
77437
77530
  // src/api/twilio-number-production.ts
77438
- import { createHash as createHash95, randomUUID as randomUUID66 } from "crypto";
77531
+ import { createHash as createHash96, randomUUID as randomUUID66 } from "crypto";
77439
77532
 
77440
77533
  // src/api/twilio-number-repository.ts
77441
- import { createHash as createHash94, randomUUID as randomUUID65 } from "crypto";
77534
+ import { createHash as createHash95, randomUUID as randomUUID65 } from "crypto";
77442
77535
  var PUBLIC_REF3 = /^[a-z][a-z0-9_]*_[A-Za-z0-9_-]{3,128}$/;
77443
77536
  var DIGEST8 = /^[a-f0-9]{64}$/;
77444
77537
  var ACCOUNT_SID4 = /^AC[0-9a-f]{32}$/i;
@@ -77527,7 +77620,7 @@ function priceValue(value) {
77527
77620
  }), blocker: null });
77528
77621
  }
77529
77622
  function digest21(value) {
77530
- return createHash94("sha256").update(JSON.stringify(value, (_key, entry) => {
77623
+ return createHash95("sha256").update(JSON.stringify(value, (_key, entry) => {
77531
77624
  if (!entry || typeof entry !== "object" || Array.isArray(entry)) return entry;
77532
77625
  return Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b)));
77533
77626
  })).digest("hex");
@@ -78314,13 +78407,13 @@ function createPostgresTwilioNumberProductionAdapters(options) {
78314
78407
  }
78315
78408
  function twilioProviderAccountDigest(providerAccountRef) {
78316
78409
  if (!ACCOUNT_SID4.test(providerAccountRef)) throw new TwilioNumberRepositoryError("invalid_provider_account", "Twilio account assignment is invalid.", 400);
78317
- return createHash94("sha256").update(providerAccountRef).digest("hex");
78410
+ return createHash95("sha256").update(providerAccountRef).digest("hex");
78318
78411
  }
78319
78412
 
78320
78413
  // src/api/twilio-number-production.ts
78321
78414
  var DIGEST9 = /^[a-f0-9]{64}$/u;
78322
78415
  function hash3(value) {
78323
- return createHash95("sha256").update(typeof value === "string" ? value : JSON.stringify(value, (_key, entry) => {
78416
+ return createHash96("sha256").update(typeof value === "string" ? value : JSON.stringify(value, (_key, entry) => {
78324
78417
  if (!entry || typeof entry !== "object" || Array.isArray(entry)) return entry;
78325
78418
  return Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b)));
78326
78419
  })).digest("hex");
@@ -78733,7 +78826,7 @@ function createTwilioNumberProductionInterfaces(options) {
78733
78826
  }
78734
78827
 
78735
78828
  // src/api/twilio-number-service.ts
78736
- import { createHash as createHash96, randomUUID as randomUUID67 } from "crypto";
78829
+ import { createHash as createHash97, randomUUID as randomUUID67 } from "crypto";
78737
78830
  var DEFAULT_RESERVATION_TTL_MS = 5 * 60 * 1e3;
78738
78831
  var MIN_RESERVATION_TTL_MS = 60 * 1e3;
78739
78832
  var MAX_RESERVATION_TTL_MS = 10 * 60 * 1e3;
@@ -78869,7 +78962,7 @@ function canonicalJson15(value) {
78869
78962
  });
78870
78963
  }
78871
78964
  function digest22(value) {
78872
- return createHash96("sha256").update(canonicalJson15(value)).digest("hex");
78965
+ return createHash97("sha256").update(canonicalJson15(value)).digest("hex");
78873
78966
  }
78874
78967
  function requireIdempotencyKey(value) {
78875
78968
  if (typeof value !== "string" || !/^[A-Za-z0-9][A-Za-z0-9:._/-]{7,239}$/.test(value)) {
@@ -80298,7 +80391,7 @@ function presence(env) {
80298
80391
  }
80299
80392
  function fingerprintDigest(env) {
80300
80393
  const value = env.PA_NEON_BINDING_FINGERPRINT?.trim();
80301
- return value ? createHash97("sha256").update("personal-assistant-binding-v1\0").update(value).digest("hex") : null;
80394
+ return value ? createHash98("sha256").update("personal-assistant-binding-v1\0").update(value).digest("hex") : null;
80302
80395
  }
80303
80396
  function missingHostedBindings(env) {
80304
80397
  return Object.entries(REQUIRED_HOSTED_BINDINGS).filter(([, variable]) => !env[variable]?.trim()).map(([name]) => `binding_${name}_missing`);
@@ -80531,7 +80624,7 @@ function shouldRunSiteExtractInBackground(input) {
80531
80624
  }
80532
80625
 
80533
80626
  // src/api/page-media-artifacts.ts
80534
- import { createHash as createHash98, randomBytes as randomBytes14 } from "crypto";
80627
+ import { createHash as createHash99, randomBytes as randomBytes14 } from "crypto";
80535
80628
  import { homedir as homedir4 } from "os";
80536
80629
  import { basename, extname, join as join9 } from "path";
80537
80630
  import pLimit6 from "p-limit";
@@ -80678,7 +80771,7 @@ async function fetchMedia(rawUrl, expectedType) {
80678
80771
  finalUrl: checked.parsed.href,
80679
80772
  width: dimensions?.width ?? null,
80680
80773
  height: dimensions?.height ?? null,
80681
- sha256: createHash98("sha256").update(bytes2).digest("hex")
80774
+ sha256: createHash99("sha256").update(bytes2).digest("hex")
80682
80775
  };
80683
80776
  }
80684
80777
  throw new Error("media_redirect_rejected");
@@ -80884,13 +80977,13 @@ async function reconcileSiteExtractSettlements(limit = 25) {
80884
80977
  }
80885
80978
 
80886
80979
  // src/api/page-diff.ts
80887
- import { createHash as createHash99 } from "crypto";
80980
+ import { createHash as createHash100 } from "crypto";
80888
80981
  import { diffLines } from "diff";
80889
80982
  var MAX_SNAPSHOT_CONTENT_CHARS = 25e4;
80890
80983
  var MAX_DIFF_HUNKS = 200;
80891
80984
  var MAX_DIFF_LINES_PER_RESPONSE = 2e3;
80892
80985
  function sha256Hex(value) {
80893
- return createHash99("sha256").update(value).digest("hex");
80986
+ return createHash100("sha256").update(value).digest("hex");
80894
80987
  }
80895
80988
  function truncateForStorage(value, maxChars = MAX_SNAPSHOT_CONTENT_CHARS) {
80896
80989
  if (value.length <= maxChars) return { value, truncated: false };
@@ -80957,7 +81050,7 @@ async function depositScrapeToVault(user, opts) {
80957
81050
  const content = (opts.content ?? "").trim();
80958
81051
  if (!content) return { deposited: false, error: "empty content" };
80959
81052
  const clipped = content.length > MAX_DEPOSIT_CHARS ? content.slice(0, MAX_DEPOSIT_CHARS) : content;
80960
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
81053
+ const { key: key3, error } = await getMemoryServiceToken(user);
80961
81054
  if (!key3) return { deposited: false, error: error ?? "memory unavailable" };
80962
81055
  const vault = opts.vault?.trim() || "Library";
80963
81056
  const title = (opts.title?.trim() || opts.source).slice(0, 200);
@@ -81004,15 +81097,15 @@ async function persistScrapeBody(user, opts) {
81004
81097
  }
81005
81098
 
81006
81099
  // src/api/scrape-image-sink.ts
81007
- import { createHash as createHash100 } from "crypto";
81100
+ import { createHash as createHash101 } from "crypto";
81008
81101
  var MAX_IMAGES_PER_SCRAPE = 25;
81009
81102
  function idempotencyKey3(userId, vault, input) {
81010
- return `scrape-image-${createHash100("sha256").update(`${userId}\0${vault}\0${input.sourceKind}\0${input.sourceUrl}\0${input.imageUrl ?? ""}\0${input.imageBase64 ?? ""}`).digest("hex")}`;
81103
+ return `scrape-image-${createHash101("sha256").update(`${userId}\0${vault}\0${input.sourceKind}\0${input.sourceUrl}\0${input.imageUrl ?? ""}\0${input.imageBase64 ?? ""}`).digest("hex")}`;
81011
81104
  }
81012
81105
  async function persistScrapeImagesToMemory(user, inputs, vault) {
81013
81106
  const selected = inputs.slice(0, MAX_IMAGES_PER_SCRAPE);
81014
81107
  if (selected.length === 0) return { requested: 0, saved: 0, skipped: 0, assets: [] };
81015
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
81108
+ const { key: key3, error } = await getMemoryServiceToken(user);
81016
81109
  if (!key3) {
81017
81110
  return { requested: selected.length, saved: 0, skipped: inputs.length - selected.length, assets: [], error: error ?? "memory unavailable" };
81018
81111
  }
@@ -81479,7 +81572,7 @@ function inferredWaybackCapturedAt(content) {
81479
81572
  }
81480
81573
 
81481
81574
  // src/api/connection-memory-import.ts
81482
- import { createHash as createHash101 } from "crypto";
81575
+ import { createHash as createHash102 } from "crypto";
81483
81576
  var CONNECTION_MEMORY_IMPORT_MAX_ARGS_BYTES = 64 * 1024;
81484
81577
  var CONNECTION_MEMORY_IMPORT_MAX_RESULT_BYTES = 1e6;
81485
81578
  var CONNECTION_MEMORY_IMPORT_MAX_STRING_CHARS = 256e3;
@@ -81509,7 +81602,7 @@ function canonicalJson16(value) {
81509
81602
  return JSON.stringify(value);
81510
81603
  }
81511
81604
  function sha2562(value) {
81512
- return createHash101("sha256").update(value).digest("hex");
81605
+ return createHash102("sha256").update(value).digest("hex");
81513
81606
  }
81514
81607
  function sensitiveKey(key3) {
81515
81608
  const normalized = key3.toLowerCase().replace(/[^a-z0-9]/g, "");
@@ -81778,7 +81871,7 @@ async function cleanupExpiredScrapeBlobs(maxAgeMs = SCRAPE_BLOB_TTL_MS) {
81778
81871
  }
81779
81872
 
81780
81873
  // src/api/site-export-reader.ts
81781
- import { createHash as createHash102 } from "crypto";
81874
+ import { createHash as createHash103 } from "crypto";
81782
81875
  var SiteExportFormatUnavailableError = class extends Error {
81783
81876
  constructor(format) {
81784
81877
  super(`The ${format} representation was not retained for this export page.`);
@@ -81788,7 +81881,7 @@ var SiteExportFormatUnavailableError = class extends Error {
81788
81881
  format;
81789
81882
  };
81790
81883
  function sha2563(value) {
81791
- return createHash102("sha256").update(value).digest("hex");
81884
+ return createHash103("sha256").update(value).digest("hex");
81792
81885
  }
81793
81886
  function publicPageRecord(page3) {
81794
81887
  const { bodyMarkdown: _body, contentRef: _contentRef, discoveryLinks: _discovery, ...metadata } = page3;
@@ -82353,7 +82446,7 @@ async function dbUsage(identity, plan) {
82353
82446
  }
82354
82447
 
82355
82448
  // src/api/resend-control.ts
82356
- import { createHash as createHash103 } from "crypto";
82449
+ import { createHash as createHash104 } from "crypto";
82357
82450
  var DEFAULT_CONNECTION_CONTROL_URL = "https://mcp-scraper-scheduler.vercel.app";
82358
82451
  var RESEND_PROVIDER_CONFIG_KEY = "resend";
82359
82452
  var RESEND_LOGO_URL = "https://cdn.resend.com/brand/resend-icon-black.svg";
@@ -82612,7 +82705,7 @@ async function callResendRead(identity, connectionId, tool, args) {
82612
82705
  return isRecord9(data) ? data.result ?? data : data;
82613
82706
  }
82614
82707
  async function callResendAction(identity, connectionId, tool, input, idempotencyKey4) {
82615
- const requestId = `main-resend-action:${createHash103("sha256").update(identity).update("\0").update(idempotencyKey4.trim()).digest("hex")}`;
82708
+ const requestId = `main-resend-action:${createHash104("sha256").update(identity).update("\0").update(idempotencyKey4.trim()).digest("hex")}`;
82616
82709
  const body3 = await controlRequest2("/api/internal/resend/actions/call", {
82617
82710
  method: "POST",
82618
82711
  headers: { "x-request-id": requestId },
@@ -83191,19 +83284,19 @@ app.post("/memory/mcp-call", auth5, async (c) => {
83191
83284
  }, 503);
83192
83285
  }
83193
83286
  }
83194
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
83287
+ const { key: key3, error } = await getMemoryServiceToken(user);
83195
83288
  if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 502);
83196
83289
  const result3 = await memoryCall(body3.toolName, body3.args ?? {}, key3);
83197
83290
  return c.json(result3);
83198
83291
  });
83199
83292
  app.get("/memory/approved-senders", auth5, async (c) => {
83200
- const { key: key3, error } = await getOrCreateUserMemoryKey(c.get("user"));
83293
+ const { key: key3, error } = await getMemoryServiceToken(c.get("user"));
83201
83294
  if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 502);
83202
83295
  const r = await memoryCall("listApprovedSendersTool", {}, key3);
83203
83296
  return c.json(r);
83204
83297
  });
83205
83298
  app.post("/memory/approved-senders", auth5, async (c) => {
83206
- const { key: key3, error } = await getOrCreateUserMemoryKey(c.get("user"));
83299
+ const { key: key3, error } = await getMemoryServiceToken(c.get("user"));
83207
83300
  if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 502);
83208
83301
  const body3 = await c.req.json().catch(() => ({}));
83209
83302
  const senderIdentity = body3.senderIdentity?.trim();
@@ -83212,29 +83305,34 @@ app.post("/memory/approved-senders", auth5, async (c) => {
83212
83305
  return c.json(r);
83213
83306
  });
83214
83307
  app.delete("/memory/approved-senders/:identity", auth5, async (c) => {
83215
- const { key: key3, error } = await getOrCreateUserMemoryKey(c.get("user"));
83308
+ const { key: key3, error } = await getMemoryServiceToken(c.get("user"));
83216
83309
  if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 502);
83217
83310
  const senderIdentity = c.req.param("identity");
83218
83311
  const r = await memoryCall("removeApprovedSenderTool", { senderIdentity }, key3);
83219
83312
  return c.json(r);
83220
83313
  });
83221
83314
  app.get("/memory/connect", auth5, async (c) => {
83222
- const { key: key3, error } = await getOrCreateUserMemoryKey(c.get("user"));
83223
- if (!key3) return c.json({ error: error ?? "memory unavailable" }, 502);
83224
- const url2 = "https://memory.mcpscraper.dev/mcp";
83315
+ const url2 = "https://mcpscraper.dev/mcp";
83225
83316
  const config = {
83226
83317
  mcpServers: {
83227
- Memory: {
83318
+ "MCP Scraper": {
83228
83319
  url: url2,
83229
- headers: { Authorization: `Bearer ${key3}` }
83320
+ headers: { "x-api-key": "${MCP_SCRAPER_API_KEY}" }
83230
83321
  }
83231
83322
  }
83232
83323
  };
83233
- const codeCommand = `claude mcp add --transport http memory ${url2} --header "Authorization: Bearer ${key3}"`;
83234
- return c.json({ ok: true, url: url2, key: key3, config, codeCommand });
83324
+ const codeCommand = 'claude mcp add --transport http mcp-scraper https://mcpscraper.dev/mcp --header "x-api-key: $MCP_SCRAPER_API_KEY"';
83325
+ return c.json({
83326
+ ok: true,
83327
+ url: url2,
83328
+ apiKeyEnvironmentVariable: "MCP_SCRAPER_API_KEY",
83329
+ authModes: ["x-api-key", "oauth"],
83330
+ config,
83331
+ codeCommand
83332
+ });
83235
83333
  });
83236
83334
  app.post("/memory/vault", auth5, async (c) => {
83237
- const { key: key3, error } = await getOrCreateUserMemoryKey(c.get("user"));
83335
+ const { key: key3, error } = await getMemoryServiceToken(c.get("user"));
83238
83336
  if (!key3) return c.json({ error: error ?? "memory unavailable" }, 502);
83239
83337
  const body3 = await c.req.json().catch(() => ({}));
83240
83338
  const vault = body3.vault?.trim();
@@ -83283,7 +83381,7 @@ app.get("/memory/universe", auth5, async (c) => {
83283
83381
  }
83284
83382
  });
83285
83383
  app.put("/memory/note", auth5, async (c) => {
83286
- const { key: key3, error } = await getOrCreateUserMemoryKey(c.get("user"));
83384
+ const { key: key3, error } = await getMemoryServiceToken(c.get("user"));
83287
83385
  if (!key3) return c.json({ error: error ?? "memory unavailable" }, 502);
83288
83386
  const body3 = await c.req.json().catch(() => ({}));
83289
83387
  if (!body3.path) return c.json({ error: "path required" }, 400);
@@ -83291,7 +83389,7 @@ app.put("/memory/note", auth5, async (c) => {
83291
83389
  return c.json(result3, result3.ok ? 200 : 502);
83292
83390
  });
83293
83391
  app.delete("/memory/note", auth5, async (c) => {
83294
- const { key: key3, error } = await getOrCreateUserMemoryKey(c.get("user"));
83392
+ const { key: key3, error } = await getMemoryServiceToken(c.get("user"));
83295
83393
  if (!key3) return c.json({ error: error ?? "memory unavailable" }, 502);
83296
83394
  const vault = c.req.query("vault");
83297
83395
  const path5 = c.req.query("path");
@@ -83572,7 +83670,7 @@ function renderResendOAuthResult(ok) {
83572
83670
  app.get("/schedule-status", auth5, requirePaidSchedulingTier, async (c) => {
83573
83671
  try {
83574
83672
  const user = c.get("user");
83575
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
83673
+ const { key: key3, error } = await getMemoryServiceToken(user);
83576
83674
  if (!key3) return c.json({ error: error ?? "memory unavailable" }, 503);
83577
83675
  const r = await memoryCall("getScheduleStatusTool", {}, key3);
83578
83676
  return c.json({
@@ -83828,7 +83926,7 @@ app.post("/schedule-connections/actions/gmail/send-message", auth5, requireInteg
83828
83926
  }
83829
83927
  try {
83830
83928
  const result3 = await directGmailService.sendMessage({
83831
- ownerId: createHash104("sha256").update(user.api_key).digest("hex").slice(0, 24),
83929
+ ownerId: createHash105("sha256").update(user.api_key).digest("hex").slice(0, 24),
83832
83930
  providerIdentity: user.email,
83833
83931
  connectionId,
83834
83932
  to: body3.to,
@@ -84017,7 +84115,7 @@ app.post("/schedule-connections/actions/import-memory", auth5, requireIntegratio
84017
84115
  }, {
84018
84116
  listConnections: combinedConnections,
84019
84117
  prepareMemory: async (_identity, requestedVault) => {
84020
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
84118
+ const { key: key3, error } = await getMemoryServiceToken(user);
84021
84119
  if (!key3) throw new ConnectionMemoryImportError("memory_unavailable", error || "Memory is unavailable.", 503, true);
84022
84120
  const listed = await memoryCall("listVaultsTool", {}, key3);
84023
84121
  if (!listed.ok) throw new ConnectionMemoryImportError("memory_unavailable", listed.error || "Memory vaults are unavailable.", 503, true);
@@ -84150,7 +84248,7 @@ app.post("/schedule-connections/actions/export-search-console-table", auth5, req
84150
84248
  const body3 = await c.req.json().catch(() => ({}));
84151
84249
  try {
84152
84250
  const request = validateSearchConsoleTableExportRequest(body3);
84153
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
84251
+ const { key: key3, error } = await getMemoryServiceToken(user);
84154
84252
  if (!key3) return c.json({ ok: false, error: error ?? "Memory table access is unavailable." }, 503);
84155
84253
  const result3 = await exportSearchConsoleTableData({
84156
84254
  ownerId: sha256Hex(user.api_key).slice(0, 24),
@@ -84235,7 +84333,7 @@ app.post("/schedule-link", auth5, requirePaidSchedulingTier, async (c) => {
84235
84333
  if (!credentials.ok) {
84236
84334
  return c.json({ ok: false, code: "schedule_credentials_unavailable", error: credentials.error ?? "Scheduled Actions credentials are unavailable." }, 503);
84237
84335
  }
84238
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
84336
+ const { key: key3, error } = await getMemoryServiceToken(user);
84239
84337
  if (!key3) return c.json({ error: error ?? "memory unavailable" }, 503);
84240
84338
  const r = await memoryCall("getScheduleLinkTool", {}, key3);
84241
84339
  return c.json(r);
@@ -84247,7 +84345,7 @@ app.post("/schedule-link", auth5, requirePaidSchedulingTier, async (c) => {
84247
84345
  });
84248
84346
  app.get("/schedule-actions", auth5, async (c) => {
84249
84347
  const user = c.get("user");
84250
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
84348
+ const { key: key3, error } = await getMemoryServiceToken(user);
84251
84349
  if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
84252
84350
  const r = await memoryCall("listScheduledActionsTool", {}, key3);
84253
84351
  if (!r.ok || !Array.isArray(r.actions)) return c.json(r);
@@ -84278,7 +84376,7 @@ app.post("/schedule-actions", auth5, requirePaidSchedulingTier, async (c) => {
84278
84376
  if (!credentials.ok) {
84279
84377
  return c.json({ ok: false, code: "schedule_credentials_unavailable", error: credentials.error ?? "Scheduled Actions credentials are unavailable." }, 503);
84280
84378
  }
84281
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
84379
+ const { key: key3, error } = await getMemoryServiceToken(user);
84282
84380
  if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
84283
84381
  const body3 = await c.req.json().catch(() => ({}));
84284
84382
  const executionMode = body3.executionMode ?? "agent";
@@ -84319,7 +84417,7 @@ app.post("/schedule-actions", auth5, requirePaidSchedulingTier, async (c) => {
84319
84417
  });
84320
84418
  app.post("/schedule-actions/propose", auth5, async (c) => {
84321
84419
  const user = c.get("user");
84322
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
84420
+ const { key: key3, error } = await getMemoryServiceToken(user);
84323
84421
  if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
84324
84422
  const body3 = await c.req.json().catch(() => ({}));
84325
84423
  const r = await memoryCall("proposeScheduledActionTool", body3, key3);
@@ -84346,7 +84444,7 @@ app.put("/schedule-actions/:id/connections", auth5, requireIntegrationsTier, asy
84346
84444
  }
84347
84445
  try {
84348
84446
  const scheduleActionId = c.req.param("id");
84349
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
84447
+ const { key: key3, error } = await getMemoryServiceToken(user);
84350
84448
  if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
84351
84449
  const schedules = await memoryCall("listScheduledActionsTool", {}, key3);
84352
84450
  if (!schedules.ok || !Array.isArray(schedules.actions)) return c.json(schedules, 502);
@@ -84364,7 +84462,7 @@ app.put("/schedule-actions/:id/connections", auth5, requireIntegrationsTier, asy
84364
84462
  });
84365
84463
  app.get("/schedule-actions/:id/runs", auth5, async (c) => {
84366
84464
  const user = c.get("user");
84367
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
84465
+ const { key: key3, error } = await getMemoryServiceToken(user);
84368
84466
  if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
84369
84467
  const limitRaw = Number(c.req.query("limit") ?? "50");
84370
84468
  const limit = Number.isFinite(limitRaw) ? Math.min(Math.max(Math.round(limitRaw), 1), 100) : 50;
@@ -84373,7 +84471,7 @@ app.get("/schedule-actions/:id/runs", auth5, async (c) => {
84373
84471
  });
84374
84472
  app.put("/schedule-actions/:id", auth5, requirePaidSchedulingTier, async (c) => {
84375
84473
  const user = c.get("user");
84376
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
84474
+ const { key: key3, error } = await getMemoryServiceToken(user);
84377
84475
  if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
84378
84476
  const body3 = await c.req.json().catch(() => ({}));
84379
84477
  const updates = {};
@@ -84388,21 +84486,21 @@ app.put("/schedule-actions/:id", auth5, requirePaidSchedulingTier, async (c) =>
84388
84486
  });
84389
84487
  app.post("/schedule-actions/:id/pause", auth5, async (c) => {
84390
84488
  const user = c.get("user");
84391
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
84489
+ const { key: key3, error } = await getMemoryServiceToken(user);
84392
84490
  if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
84393
84491
  const r = await memoryCall("pauseScheduledActionTool", { id: c.req.param("id") }, key3);
84394
84492
  return c.json(r);
84395
84493
  });
84396
84494
  app.post("/schedule-actions/:id/resume", auth5, requirePaidSchedulingTier, async (c) => {
84397
84495
  const user = c.get("user");
84398
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
84496
+ const { key: key3, error } = await getMemoryServiceToken(user);
84399
84497
  if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
84400
84498
  const r = await memoryCall("resumeScheduledActionTool", { id: c.req.param("id") }, key3);
84401
84499
  return c.json(r);
84402
84500
  });
84403
84501
  app.delete("/schedule-actions/:id", auth5, async (c) => {
84404
84502
  const user = c.get("user");
84405
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
84503
+ const { key: key3, error } = await getMemoryServiceToken(user);
84406
84504
  if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
84407
84505
  const scheduleActionId = c.req.param("id");
84408
84506
  const r = await memoryCall("deleteScheduledActionTool", { id: scheduleActionId }, key3);
@@ -84418,7 +84516,7 @@ app.delete("/schedule-actions/:id", auth5, async (c) => {
84418
84516
  app.post("/schedule-link/revoke", auth5, async (c) => {
84419
84517
  try {
84420
84518
  const user = c.get("user");
84421
- const { key: key3, error } = await getOrCreateUserMemoryKey(user);
84519
+ const { key: key3, error } = await getMemoryServiceToken(user);
84422
84520
  if (!key3) return c.json({ error: error ?? "memory unavailable" }, 503);
84423
84521
  const r = await memoryCall("revokeScheduleLinkTool", {}, key3);
84424
84522
  return c.json(r);
@@ -86145,7 +86243,7 @@ app.get("/cron/tick", async (c) => {
86145
86243
  return c.json({ error: "Unauthorized" }, 401);
86146
86244
  }
86147
86245
  const startedAt = Date.now();
86148
- const { drainQueue } = await import("./worker-OQSFSLNG.js");
86246
+ const { drainQueue } = await import("./worker-LDCAULWL.js");
86149
86247
  const budget = { maxJobs: 10, deadlineMs: startedAt + CRON_TICK_DRAIN_BUDGET_MS };
86150
86248
  const origin = `${new URL(c.req.url).protocol}//${new URL(c.req.url).host}`;
86151
86249
  const unfinished = [];
@@ -86269,8 +86367,8 @@ app.post("/api/internal/extract-refinalize/:id", async (c) => {
86269
86367
  finishExtractJob: finishExtractJob2,
86270
86368
  terminalExtractJobStatus: terminalExtractJobStatus2,
86271
86369
  extractJobLimitInfo: extractJobLimitInfo2
86272
- } = await import("./site-extract-repository-S5FYNFDY.js");
86273
- const { assembleExtractArtifacts } = await import("./extract-bundle-FALNLKYY.js");
86370
+ } = await import("./site-extract-repository-VYFZASPU.js");
86371
+ const { assembleExtractArtifacts } = await import("./extract-bundle-565SBZCR.js");
86274
86372
  const existing = await getExtractJob2(jobId2);
86275
86373
  if (!existing) return c.json({ error: "job not found" }, 404);
86276
86374
  if (existing.status !== "failed") {
@@ -86297,7 +86395,7 @@ app.post("/api/internal/extract-refinalize/:id", async (c) => {
86297
86395
  if (!updated) return c.json({ error: "job state changed during re-finalization" }, 409);
86298
86396
  let settlement = "already_settled_or_refunded";
86299
86397
  if (job.billedMc == null && job.userId != null) {
86300
- const { settleExtractJob: settleExtractJob3, countSuccessfulPages: countSuccessfulPages2 } = await import("./site-extract-repository-S5FYNFDY.js");
86398
+ const { settleExtractJob: settleExtractJob3, countSuccessfulPages: countSuccessfulPages2 } = await import("./site-extract-repository-VYFZASPU.js");
86301
86399
  const heldMc = Number(job.options.heldMc ?? 0);
86302
86400
  const successful = await countSuccessfulPages2(jobId2);
86303
86401
  const usedMc = Math.min(successful * MC_COSTS.page_scrape, heldMc);