@canonry/canonry 4.165.1 → 4.166.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.
Files changed (28) hide show
  1. package/README.md +11 -1
  2. package/assets/agent-workspace/skills/canonry/references/server-side-traffic.md +75 -3
  3. package/assets/assets/{AuditHistoryPanel-IYMElyK5.js → AuditHistoryPanel-CZByTZjH.js} +1 -1
  4. package/assets/assets/{BacklinksPage-BMqIPRvZ.js → BacklinksPage-DPsSKu1M.js} +1 -1
  5. package/assets/assets/{HistoryPage-iuETLmwO.js → HistoryPage-9acsanzg.js} +1 -1
  6. package/assets/assets/{MeasurementPropertyPage-BzNAaB8X.js → MeasurementPropertyPage-gIOHHJ4x.js} +1 -1
  7. package/assets/assets/ProjectPage-CTic0OFR.js +9 -0
  8. package/assets/assets/{RunRow-BkkYxEjl.js → RunRow-cuE1cBCg.js} +1 -1
  9. package/assets/assets/{RunsPage-DGTrqrTA.js → RunsPage-Bt6T2Kz2.js} +1 -1
  10. package/assets/assets/SettingsPage-ChyewFuC.js +1 -0
  11. package/assets/assets/{SiteHealthSection-k4I71wfJ.js → SiteHealthSection-BYM32RDv.js} +3 -3
  12. package/assets/assets/{TrafficPage-C8nyb8l1.js → TrafficPage-DMpuFJua.js} +1 -1
  13. package/assets/assets/{TrafficSourceDetailPage-ry7Da0pV.js → TrafficSourceDetailPage-D4G26uyv.js} +1 -1
  14. package/assets/assets/{extract-error-message-BYyBW07F.js → extract-error-message-D7fD7zwP.js} +1 -1
  15. package/assets/assets/{index-rqOXhYwp.js → index-BliSumN-.js} +20 -20
  16. package/assets/assets/{react-sigma_core.esm.min-BtG8TWTe.js → react-sigma_core.esm.min-CmW2JaYh.js} +1 -1
  17. package/assets/index.html +1 -1
  18. package/dist/{chunk-BU6C2DKF.js → chunk-GU7T2JUB.js} +24 -2
  19. package/dist/{chunk-L5SMSDZB.js → chunk-IUWFALUQ.js} +85 -94
  20. package/dist/{chunk-QKLNTSQ2.js → chunk-KU45I42F.js} +66 -64
  21. package/dist/{chunk-QDOZEMDK.js → chunk-QFMHIUV7.js} +6 -5
  22. package/dist/cli.js +29 -28
  23. package/dist/index.js +4 -4
  24. package/dist/{intelligence-service-RDGUEEZQ.js → intelligence-service-KRQNQNEB.js} +2 -2
  25. package/dist/mcp.js +2 -2
  26. package/package.json +11 -11
  27. package/assets/assets/ProjectPage-DIzi4Ggo.js +0 -9
  28. package/assets/assets/SettingsPage-Cwb_Ft9u.js +0 -1
@@ -10,7 +10,7 @@ import {
10
10
  loadConfig,
11
11
  loadConfigRaw,
12
12
  saveConfigPatch
13
- } from "./chunk-QDOZEMDK.js";
13
+ } from "./chunk-QFMHIUV7.js";
14
14
  import {
15
15
  CC_CACHE_DIR,
16
16
  DUCKDB_SPEC,
@@ -139,7 +139,7 @@ import {
139
139
  siteCrawlSnapshots,
140
140
  toAlertView,
141
141
  usageCounters
142
- } from "./chunk-QKLNTSQ2.js";
142
+ } from "./chunk-KU45I42F.js";
143
143
  import {
144
144
  AGENT_MEMORY_VALUE_MAX_BYTES,
145
145
  AGENT_PROVIDER_IDS,
@@ -204,6 +204,7 @@ import {
204
204
  deriveCitedUrlCandidates,
205
205
  deriveIndexCoverage,
206
206
  deriveSiteHealthState,
207
+ describeError,
207
208
  determineAnswerMentioned,
208
209
  dollarsToMicros,
209
210
  effectiveBrandNames,
@@ -253,7 +254,7 @@ import {
253
254
  validationError,
254
255
  winnabilityClassLabel,
255
256
  withRetry
256
- } from "./chunk-BU6C2DKF.js";
257
+ } from "./chunk-GU7T2JUB.js";
257
258
 
258
259
  // src/telemetry.ts
259
260
  import crypto from "crypto";
@@ -608,7 +609,7 @@ async function withRetry2(fn, options = {}) {
608
609
  onRetry: ({ attempt, err, delayMs }) => {
609
610
  console.warn(
610
611
  `[provider] Attempt ${attempt + 1} failed, retrying in ${delayMs}ms...`,
611
- err instanceof Error ? err.message : String(err)
612
+ describeError(err)
612
613
  );
613
614
  }
614
615
  });
@@ -683,7 +684,7 @@ async function healthcheck(config) {
683
684
  return {
684
685
  ok: false,
685
686
  provider: "gemini",
686
- message: err instanceof Error ? err.message : String(err),
687
+ message: describeError(err),
687
688
  model: config.model ?? DEFAULT_MODEL
688
689
  };
689
690
  }
@@ -713,7 +714,7 @@ async function executeTrackedQuery(input) {
713
714
  searchQueries: parsed.searchQueries
714
715
  };
715
716
  } catch (err) {
716
- const msg = err instanceof Error ? err.message : String(err);
717
+ const msg = describeError(err);
717
718
  throw new Error(`[provider-gemini] ${msg}`);
718
719
  }
719
720
  }
@@ -1056,7 +1057,7 @@ async function withRetry3(fn, options = {}) {
1056
1057
  onRetry: ({ attempt, err, delayMs }) => {
1057
1058
  console.warn(
1058
1059
  `[provider] Attempt ${attempt + 1} failed, retrying in ${delayMs}ms...`,
1059
- err instanceof Error ? err.message : String(err)
1060
+ describeError(err)
1060
1061
  );
1061
1062
  }
1062
1063
  });
@@ -1103,7 +1104,7 @@ async function healthcheck2(config) {
1103
1104
  return {
1104
1105
  ok: false,
1105
1106
  provider: "openai",
1106
- message: err instanceof Error ? err.message : String(err),
1107
+ message: describeError(err),
1107
1108
  model: config.model ?? DEFAULT_MODEL2
1108
1109
  };
1109
1110
  }
@@ -1141,7 +1142,7 @@ async function executeTrackedQuery2(input) {
1141
1142
  searchQueries: parsed.searchQueries
1142
1143
  };
1143
1144
  } catch (err) {
1144
- const msg = err instanceof Error ? err.message : String(err);
1145
+ const msg = describeError(err);
1145
1146
  throw new Error(`[provider-openai] ${msg}`);
1146
1147
  }
1147
1148
  }
@@ -1408,7 +1409,7 @@ async function withRetry4(fn, options = {}) {
1408
1409
  onRetry: ({ attempt, err, delayMs }) => {
1409
1410
  console.warn(
1410
1411
  `[provider] Attempt ${attempt + 1} failed, retrying in ${delayMs}ms...`,
1411
- err instanceof Error ? err.message : String(err)
1412
+ describeError(err)
1412
1413
  );
1413
1414
  }
1414
1415
  });
@@ -1464,7 +1465,7 @@ async function healthcheck3(config) {
1464
1465
  return {
1465
1466
  ok: false,
1466
1467
  provider: "claude",
1467
- message: err instanceof Error ? err.message : String(err),
1468
+ message: describeError(err),
1468
1469
  model: resolveModel2(config)
1469
1470
  };
1470
1471
  }
@@ -1514,7 +1515,7 @@ async function executeTrackedQuery3(input) {
1514
1515
  retrievalContract: CLAUDE_RETRIEVAL_CONTRACT
1515
1516
  };
1516
1517
  } catch (err) {
1517
- const msg = err instanceof Error ? err.message : String(err);
1518
+ const msg = describeError(err);
1518
1519
  throw new Error(`[provider-claude] ${msg}`);
1519
1520
  }
1520
1521
  }
@@ -1798,7 +1799,7 @@ async function withRetry5(fn, options = {}) {
1798
1799
  onRetry: ({ attempt, err, delayMs }) => {
1799
1800
  console.warn(
1800
1801
  `[provider] Attempt ${attempt + 1} failed, retrying in ${delayMs}ms...`,
1801
- err instanceof Error ? err.message : String(err)
1802
+ describeError(err)
1802
1803
  );
1803
1804
  }
1804
1805
  });
@@ -1844,7 +1845,7 @@ async function healthcheck4(config) {
1844
1845
  return {
1845
1846
  ok: false,
1846
1847
  provider: "local",
1847
- message: err instanceof Error ? err.message : String(err),
1848
+ message: describeError(err),
1848
1849
  model: config.model ?? DEFAULT_MODEL4
1849
1850
  };
1850
1851
  }
@@ -1881,7 +1882,7 @@ async function executeTrackedQuery4(input) {
1881
1882
  searchQueries: []
1882
1883
  };
1883
1884
  } catch (err) {
1884
- const msg = err instanceof Error ? err.message : String(err);
1885
+ const msg = describeError(err);
1885
1886
  throw new Error(`[provider-local] ${msg}`);
1886
1887
  }
1887
1888
  }
@@ -2110,7 +2111,7 @@ var CDPConnectionManager = class {
2110
2111
  } catch (err) {
2111
2112
  throw new CDPProviderError(
2112
2113
  "CDP_CONNECTION_REFUSED",
2113
- `Failed to connect to Chrome at ${this.host}:${this.port}: ${err instanceof Error ? err.message : String(err)}`
2114
+ `Failed to connect to Chrome at ${this.host}:${this.port}: ${describeError(err)}`
2114
2115
  );
2115
2116
  }
2116
2117
  }
@@ -2128,7 +2129,7 @@ var CDPConnectionManager = class {
2128
2129
  } catch (err) {
2129
2130
  throw new CDPProviderError(
2130
2131
  "CDP_TARGET_SELECTOR_FAILED",
2131
- `Failed to navigate to ${target.newConversationUrl}: ${err instanceof Error ? err.message : String(err)}`
2132
+ `Failed to navigate to ${target.newConversationUrl}: ${describeError(err)}`
2132
2133
  );
2133
2134
  }
2134
2135
  const entry = this.tabs.get(target.name);
@@ -2542,7 +2543,7 @@ var cdpChatgptAdapter = {
2542
2543
  return {
2543
2544
  ok: false,
2544
2545
  provider: "cdp:chatgpt",
2545
- message: err instanceof Error ? err.message : String(err)
2546
+ message: describeError(err)
2546
2547
  };
2547
2548
  }
2548
2549
  },
@@ -2586,7 +2587,7 @@ var cdpChatgptAdapter = {
2586
2587
  screenshotPath: capturedScreenshotPath
2587
2588
  };
2588
2589
  } catch (err) {
2589
- const msg = err instanceof Error ? err.message : String(err);
2590
+ const msg = describeError(err);
2590
2591
  throw new Error(`[provider-cdp] ${msg}`);
2591
2592
  }
2592
2593
  },
@@ -2614,7 +2615,7 @@ async function withRetry6(fn, options = {}) {
2614
2615
  onRetry: ({ attempt, err, delayMs }) => {
2615
2616
  console.warn(
2616
2617
  `[provider] Attempt ${attempt + 1} failed, retrying in ${delayMs}ms...`,
2617
- err instanceof Error ? err.message : String(err)
2618
+ describeError(err)
2618
2619
  );
2619
2620
  }
2620
2621
  });
@@ -2656,7 +2657,7 @@ async function healthcheck5(config) {
2656
2657
  return {
2657
2658
  ok: false,
2658
2659
  provider: "perplexity",
2659
- message: err instanceof Error ? err.message : String(err),
2660
+ message: describeError(err),
2660
2661
  model: config.model ?? DEFAULT_MODEL5
2661
2662
  };
2662
2663
  }
@@ -2683,7 +2684,7 @@ async function executeTrackedQuery5(input) {
2683
2684
  searchQueries: parsed.searchQueries
2684
2685
  };
2685
2686
  } catch (err) {
2686
- const msg = err instanceof Error ? err.message : String(err);
2687
+ const msg = describeError(err);
2687
2688
  throw new Error(`[provider-perplexity] ${msg}`);
2688
2689
  }
2689
2690
  }
@@ -3831,7 +3832,7 @@ var JobRunner = class {
3831
3832
  runId,
3832
3833
  provider: providerName,
3833
3834
  query: q.query,
3834
- error: err instanceof Error ? err.message : String(err)
3835
+ error: describeError(err)
3835
3836
  });
3836
3837
  }
3837
3838
  this.throwIfRunCancelled(runId);
@@ -3936,7 +3937,7 @@ var JobRunner = class {
3936
3937
  if (err instanceof RunCancelledError) {
3937
3938
  throw err;
3938
3939
  }
3939
- const msg = err instanceof Error ? err.message : String(err);
3940
+ const msg = describeError(err);
3940
3941
  const stack = err instanceof Error ? err.stack : void 0;
3941
3942
  log.error("query.failed", { runId, provider: providerName, query: q.query, error: msg, stack });
3942
3943
  if (!providerErrors.has(providerName)) {
@@ -3989,7 +3990,7 @@ var JobRunner = class {
3989
3990
  runId,
3990
3991
  provider: providerName,
3991
3992
  query: unit.queryText,
3992
- error: err instanceof Error ? err.message : String(err)
3993
+ error: describeError(err)
3993
3994
  });
3994
3995
  }
3995
3996
  this.throwIfRunCancelled(runId);
@@ -4076,7 +4077,7 @@ var JobRunner = class {
4076
4077
  if (err instanceof RunCancelledError) {
4077
4078
  throw err;
4078
4079
  }
4079
- const msg = err instanceof Error ? err.message : String(err);
4080
+ const msg = describeError(err);
4080
4081
  const stack = err instanceof Error ? err.stack : void 0;
4081
4082
  log.error("query.failed", { runId, provider: providerName, query: unit.queryText, executionId: unit.executionId, error: msg, stack });
4082
4083
  if (!providerErrors.has(providerName)) {
@@ -4176,7 +4177,7 @@ var JobRunner = class {
4176
4177
  this.incrementUsage(projectId, "runs", 1);
4177
4178
  if (this.onRunCompleted) {
4178
4179
  this.onRunCompleted(runId, projectId).catch((err) => {
4179
- log.error("notification.callback-failed", { runId, error: err instanceof Error ? err.message : String(err) });
4180
+ log.error("notification.callback-failed", { runId, error: describeError(err) });
4180
4181
  });
4181
4182
  }
4182
4183
  } catch (err) {
@@ -4193,7 +4194,7 @@ var JobRunner = class {
4193
4194
  this.handleCancelledRun(runId, projectId, startTime, executionContext);
4194
4195
  return;
4195
4196
  }
4196
- const errorMessage = err instanceof Error ? err.message : String(err);
4197
+ const errorMessage = describeError(err);
4197
4198
  this.db.update(runs).set({
4198
4199
  status: "failed",
4199
4200
  finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -4234,7 +4235,7 @@ var JobRunner = class {
4234
4235
  }
4235
4236
  if (this.onRunCompleted) {
4236
4237
  this.onRunCompleted(runId, projectId).catch((notifErr) => {
4237
- log.error("notification.callback-failed", { runId, error: notifErr instanceof Error ? notifErr.message : String(notifErr) });
4238
+ log.error("notification.callback-failed", { runId, error: describeError(notifErr) });
4238
4239
  });
4239
4240
  }
4240
4241
  }
@@ -4314,7 +4315,7 @@ var JobRunner = class {
4314
4315
  );
4315
4316
  if (this.onRunCompleted) {
4316
4317
  this.onRunCompleted(runId, projectId).catch((err) => {
4317
- log.error("notification.callback-failed", { runId, error: err instanceof Error ? err.message : String(err) });
4318
+ log.error("notification.callback-failed", { runId, error: describeError(err) });
4318
4319
  });
4319
4320
  }
4320
4321
  }
@@ -4588,7 +4589,7 @@ async function executeGscSync(db, runId, projectId, opts) {
4588
4589
  db.update(runs).set({ status: "completed", finishedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(eq4(runs.id, runId)).run();
4589
4590
  log2.info("sync.completed", { runId, projectId, searchDataRows: rows.length, indexed: coverage.indexed, notIndexed: coverage.notIndexed, unknown: coverage.unknown, verifiedByInspection: coverage.verifiedByInspection });
4590
4591
  } catch (err) {
4591
- const errorMsg = err instanceof Error ? err.message : String(err);
4592
+ const errorMsg = describeError(err);
4592
4593
  db.update(runs).set({ status: "failed", error: errorMsg, finishedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(eq4(runs.id, runId)).run();
4593
4594
  log2.error("sync.failed", { runId, projectId, error: errorMsg });
4594
4595
  throw err;
@@ -4712,7 +4713,7 @@ async function executeGbpSync(db, runId, projectId, opts) {
4712
4713
  placeToTouch = latestPlace.id;
4713
4714
  }
4714
4715
  } catch (placesErr) {
4715
- log3.warn("places.failed", { runId, location: loc.locationName, error: placesErr instanceof Error ? placesErr.message : String(placesErr) });
4716
+ log3.warn("places.failed", { runId, location: loc.locationName, error: describeError(placesErr) });
4716
4717
  }
4717
4718
  }
4718
4719
  }
@@ -4833,8 +4834,8 @@ async function executeGbpSync(db, runId, projectId, opts) {
4833
4834
  });
4834
4835
  okCount++;
4835
4836
  } catch (err) {
4836
- errors.set(loc.locationName, err instanceof Error ? err.message : String(err));
4837
- log3.error("location.failed", { runId, location: loc.locationName, error: err instanceof Error ? err.message : String(err) });
4837
+ errors.set(loc.locationName, describeError(err));
4838
+ log3.error("location.failed", { runId, location: loc.locationName, error: describeError(err) });
4838
4839
  }
4839
4840
  }));
4840
4841
  }
@@ -4856,7 +4857,7 @@ async function executeGbpSync(db, runId, projectId, opts) {
4856
4857
  }
4857
4858
  log3.info("sync.done", { runId, projectId, ok: okCount, failed: errors.size });
4858
4859
  } catch (err) {
4859
- const errorMsg = err instanceof Error ? err.message : String(err);
4860
+ const errorMsg = describeError(err);
4860
4861
  db.update(runs).set({ status: "failed", error: serializeRunError({ message: errorMsg }), finishedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(eq5(runs.id, runId)).run();
4861
4862
  log3.error("sync.failed", { runId, projectId, error: errorMsg });
4862
4863
  throw err;
@@ -5567,8 +5568,8 @@ async function executeAdsSync(db, runId, projectId, opts) {
5567
5568
  insightUpserts.push(...toDailyUpserts("ad_group", group.id, insights2));
5568
5569
  }
5569
5570
  } catch (err) {
5570
- errors.set(campaign.name, err instanceof Error ? err.message : String(err));
5571
- log4.error("campaign.failed", { runId, campaignId: campaign.id, error: err instanceof Error ? err.message : String(err) });
5571
+ errors.set(campaign.name, describeError(err));
5572
+ log4.error("campaign.failed", { runId, campaignId: campaign.id, error: describeError(err) });
5572
5573
  }
5573
5574
  }
5574
5575
  const conversionTrackingConfigured = campaigns.some(
@@ -5690,7 +5691,7 @@ async function executeAdsSync(db, runId, projectId, opts) {
5690
5691
  }
5691
5692
  log4.info("sync.done", { runId, projectId, campaigns: syncedCampaigns.length, insightRows: insightUpserts.length, failed: errors.size });
5692
5693
  } catch (err) {
5693
- const errorMsg = err instanceof Error ? err.message : String(err);
5694
+ const errorMsg = describeError(err);
5694
5695
  db.update(runs).set({ status: "failed", error: serializeRunError({ message: errorMsg }), finishedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(eq6(runs.id, runId)).run();
5695
5696
  log4.error("sync.failed", { runId, projectId, error: errorMsg });
5696
5697
  throw err;
@@ -5746,7 +5747,7 @@ async function parseSitemapRecursive(url, urls, visited, depth, isChild) {
5746
5747
  if (!isChild) throw err;
5747
5748
  log5.warn("child-sitemap.fetch-failed", {
5748
5749
  url,
5749
- error: err instanceof Error ? err.message : String(err)
5750
+ error: describeError(err)
5750
5751
  });
5751
5752
  return;
5752
5753
  }
@@ -5764,7 +5765,7 @@ async function parseSitemapRecursive(url, urls, visited, depth, isChild) {
5764
5765
  if (!isChild) throw err;
5765
5766
  log5.warn("child-sitemap.parse-failed", {
5766
5767
  url,
5767
- error: err instanceof Error ? err.message : String(err)
5768
+ error: describeError(err)
5768
5769
  });
5769
5770
  return;
5770
5771
  }
@@ -5877,7 +5878,7 @@ async function inspectUrlsPaced(urls, cb, deps) {
5877
5878
  url,
5878
5879
  attempt: attempt2,
5879
5880
  delayMs: Math.round(delayMs),
5880
- error: err instanceof Error ? err.message : String(err)
5881
+ error: describeError(err)
5881
5882
  })
5882
5883
  });
5883
5884
  cb.onResult(url, result, index);
@@ -5992,7 +5993,7 @@ async function executeInspectSitemap(db, runId, projectId, opts) {
5992
5993
  log6.info("inspect.url-done", { runId, projectId, url: pageUrl, progress: `${index + 1}/${urls.length}` });
5993
5994
  },
5994
5995
  onError: (pageUrl, err) => {
5995
- log6.error("inspect.url-failed", { runId, projectId, url: pageUrl, error: err instanceof Error ? err.message : String(err) });
5996
+ log6.error("inspect.url-failed", { runId, projectId, url: pageUrl, error: describeError(err) });
5996
5997
  }
5997
5998
  },
5998
5999
  {
@@ -6009,7 +6010,7 @@ async function executeInspectSitemap(db, runId, projectId, opts) {
6009
6010
  }
6010
6011
  );
6011
6012
  if (aborted) {
6012
- const detail = abortError instanceof Error ? abortError.message : String(abortError);
6013
+ const detail = describeError(abortError);
6013
6014
  throw new Error(
6014
6015
  `URL inspection aborted after ${INSPECT_FAILFAST_THRESHOLD} consecutive rate/access failures (likely GSC URL Inspection quota exhaustion or property access loss). Last error: ${detail}`
6015
6016
  );
@@ -6022,7 +6023,7 @@ async function executeInspectSitemap(db, runId, projectId, opts) {
6022
6023
  db.update(runs).set({ status, finishedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(eq7(runs.id, runId)).run();
6023
6024
  log6.info("inspect.completed", { runId, projectId, inspected, errors, total: urls.length, indexed: snapIndexed, notIndexed: snapNotIndexed });
6024
6025
  } catch (err) {
6025
- const errorMsg = err instanceof Error ? err.message : String(err);
6026
+ const errorMsg = describeError(err);
6026
6027
  db.update(runs).set({ status: "failed", error: errorMsg, finishedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(eq7(runs.id, runId)).run();
6027
6028
  log6.error("inspect.failed", { runId, projectId, error: errorMsg });
6028
6029
  throw err;
@@ -6034,16 +6035,6 @@ import crypto11 from "crypto";
6034
6035
  import { eq as eq8, desc as desc3 } from "drizzle-orm";
6035
6036
  var log7 = createLogger("BingInspectSitemap");
6036
6037
  var BING_INSPECT_SPACING_MS = 2e3;
6037
- function describeError(err) {
6038
- if (err instanceof Error) return err.message;
6039
- if (typeof err === "string") return err;
6040
- if (err == null) return "unknown error";
6041
- try {
6042
- return JSON.stringify(err);
6043
- } catch {
6044
- return "unserializable error";
6045
- }
6046
- }
6047
6038
  function parseBingDate(value) {
6048
6039
  if (!value) return null;
6049
6040
  const match = /\/Date\((-?\d+)(?:[-+]\d+)?\)\//.exec(value);
@@ -6103,7 +6094,7 @@ async function executeBingInspectSitemap(db, runId, projectId, opts) {
6103
6094
  log7.warn("crawl-issues.lookup-failed", {
6104
6095
  runId,
6105
6096
  projectId,
6106
- error: err instanceof Error ? err.message : String(err)
6097
+ error: describeError(err)
6107
6098
  });
6108
6099
  blockedUrls = /* @__PURE__ */ new Set();
6109
6100
  }
@@ -6168,7 +6159,7 @@ async function executeBingInspectSitemap(db, runId, projectId, opts) {
6168
6159
  runId,
6169
6160
  projectId,
6170
6161
  url: pageUrl,
6171
- error: err instanceof Error ? err.message : String(err)
6162
+ error: describeError(err)
6172
6163
  });
6173
6164
  }
6174
6165
  },
@@ -6262,7 +6253,7 @@ async function executeBingInspectSitemap(db, runId, projectId, opts) {
6262
6253
  unknown: snapUnknown
6263
6254
  });
6264
6255
  } catch (err) {
6265
- const errorMsg = err instanceof Error ? err.message : String(err);
6256
+ const errorMsg = describeError(err);
6266
6257
  db.update(runs).set({ status: RunStatuses.failed, error: errorMsg, finishedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(eq8(runs.id, runId)).run();
6267
6258
  log7.error("inspect.failed", { runId, projectId, error: errorMsg });
6268
6259
  throw err;
@@ -6336,7 +6327,7 @@ async function maybeRefreshGscCoverage(db, config, projectId, deps = defaultDeps
6336
6327
  log8.error("refresh.failed", {
6337
6328
  projectId,
6338
6329
  runId,
6339
- error: err instanceof Error ? err.message : String(err)
6330
+ error: describeError(err)
6340
6331
  });
6341
6332
  }
6342
6333
  return runId;
@@ -6488,13 +6479,13 @@ async function executeReleaseSync(db, syncId, opts) {
6488
6479
  syncId,
6489
6480
  release,
6490
6481
  projectId: p.id,
6491
- error: err instanceof Error ? err.message : String(err)
6482
+ error: describeError(err)
6492
6483
  });
6493
6484
  }
6494
6485
  }
6495
6486
  }
6496
6487
  } catch (err) {
6497
- const errorMsg = err instanceof Error ? err.message : String(err);
6488
+ const errorMsg = describeError(err);
6498
6489
  const finishedAt = deps.now().toISOString();
6499
6490
  db.update(ccReleaseSyncs).set({
6500
6491
  status: CcReleaseSyncStatuses.failed,
@@ -6632,7 +6623,7 @@ async function executeBacklinkExtract(db, runId, projectId, opts = {}) {
6632
6623
  db.update(runs).set({ status: RunStatuses.completed, finishedAt }).where(eq11(runs.id, runId)).run();
6633
6624
  log10.info("extract.completed", { runId, projectId, release, rows: rows.length });
6634
6625
  } catch (err) {
6635
- const errorMsg = err instanceof Error ? err.message : String(err);
6626
+ const errorMsg = describeError(err);
6636
6627
  const finishedAt = deps.now().toISOString();
6637
6628
  db.update(runs).set({
6638
6629
  status: RunStatuses.failed,
@@ -6741,7 +6732,7 @@ async function executeDiscoveryRun(opts) {
6741
6732
  competitorCount: result.competitorMap.length
6742
6733
  });
6743
6734
  } catch (err) {
6744
- const errorMsg = err instanceof Error ? err.message : String(err);
6735
+ const errorMsg = describeError(err);
6745
6736
  log11.error("discovery.failed", { runId: opts.runId, sessionId: opts.sessionId, error: errorMsg });
6746
6737
  markSessionFailed(opts.db, opts.sessionId, errorMsg);
6747
6738
  opts.db.update(runs).set({
@@ -8452,7 +8443,7 @@ async function executeSiteAudit(db, runId, projectId, opts = {}) {
8452
8443
  log12.warn("graph-layout.persist-failed", {
8453
8444
  runId,
8454
8445
  projectId,
8455
- error: error instanceof Error ? error.message : String(error)
8446
+ error: describeError(error)
8456
8447
  });
8457
8448
  try {
8458
8449
  persistSiteCrawlGraphLayout(db, { projectId, runId, attemptId }, {
@@ -8470,7 +8461,7 @@ async function executeSiteAudit(db, runId, projectId, opts = {}) {
8470
8461
  log12.warn("graph-layout.marker-persist-failed", {
8471
8462
  runId,
8472
8463
  projectId,
8473
- error: markerError instanceof Error ? markerError.message : String(markerError)
8464
+ error: describeError(markerError)
8474
8465
  });
8475
8466
  }
8476
8467
  }
@@ -8589,7 +8580,7 @@ async function executeSiteAudit(db, runId, projectId, opts = {}) {
8589
8580
  log12.warn("graph-layout.cleanup-failed", {
8590
8581
  runId,
8591
8582
  projectId,
8592
- error: cleanupError instanceof Error ? cleanupError.message : String(cleanupError)
8583
+ error: describeError(cleanupError)
8593
8584
  });
8594
8585
  }
8595
8586
  const current = db.select({ status: runs.status }).from(runs).where(eq15(runs.id, runId)).get();
@@ -8600,7 +8591,7 @@ async function executeSiteAudit(db, runId, projectId, opts = {}) {
8600
8591
  } catch (error) {
8601
8592
  const finishedAt = (/* @__PURE__ */ new Date()).toISOString();
8602
8593
  const cancelled = isCancelled(error, opts.signal);
8603
- const message = error instanceof Error ? error.message : String(error);
8594
+ const message = describeError(error);
8604
8595
  db.transaction((tx) => {
8605
8596
  tx.update(siteCrawlAttempts).set({
8606
8597
  state: cancelled ? "cancelled" : "failed",
@@ -9084,7 +9075,7 @@ function readStoredGroundingSources(rawResponse) {
9084
9075
  return result;
9085
9076
  }
9086
9077
  async function backfillInsightsCommand(project, opts) {
9087
- const { IntelligenceService: IntelligenceService2 } = await import("./intelligence-service-RDGUEEZQ.js");
9078
+ const { IntelligenceService: IntelligenceService2 } = await import("./intelligence-service-KRQNQNEB.js");
9088
9079
  const config = loadConfig();
9089
9080
  const db = createClient(config.database);
9090
9081
  migrate(db);
@@ -10384,7 +10375,7 @@ var Scheduler = class {
10384
10375
  log13.info("run.triggered", { runId, projectName: project.name, providers: providers ?? "all" });
10385
10376
  this.callbacks.onRunCreated(runId, projectId, providers, resolvedLocation);
10386
10377
  } catch (err) {
10387
- log13.error("trigger.error", { scheduleId, projectId, kind, error: err instanceof Error ? err.message : String(err) });
10378
+ log13.error("trigger.error", { scheduleId, projectId, kind, error: describeError(err) });
10388
10379
  }
10389
10380
  }
10390
10381
  };
@@ -10406,7 +10397,7 @@ async function refreshAllIntegrations(client, projectName) {
10406
10397
  log14.info("integration.refreshed", { projectName, integration });
10407
10398
  } else {
10408
10399
  const reason = result.reason;
10409
- const message = reason instanceof Error ? reason.message : String(reason);
10400
+ const message = describeError(reason);
10410
10401
  log14.warn("integration.refresh-failed", { projectName, integration, error: message });
10411
10402
  }
10412
10403
  });
@@ -10727,7 +10718,7 @@ var Notifier = class {
10727
10718
  this.logDelivery(projectId, notificationId, payload.event, "failed", errorDetail);
10728
10719
  }
10729
10720
  } catch (err) {
10730
- const errorDetail = err instanceof Error ? err.message : String(err);
10721
+ const errorDetail = describeError(err);
10731
10722
  if (attempt === maxRetries - 1) {
10732
10723
  this.logDelivery(projectId, notificationId, payload.event, "failed", errorDetail);
10733
10724
  log15.error("webhook.exhausted", { event: payload.event, url: targetLabel, maxRetries, error: errorDetail });
@@ -10786,7 +10777,7 @@ var RunCoordinator = class {
10786
10777
  try {
10787
10778
  await this.notifier.onRunCompleted(runId, projectId);
10788
10779
  } catch (err) {
10789
- log16.error("notifier.failed", { runId, error: err instanceof Error ? err.message : String(err) });
10780
+ log16.error("notifier.failed", { runId, error: describeError(err) });
10790
10781
  }
10791
10782
  return;
10792
10783
  }
@@ -10804,12 +10795,12 @@ var RunCoordinator = class {
10804
10795
  try {
10805
10796
  await this.onInsightsGenerated(runId, projectId, result);
10806
10797
  } catch (err) {
10807
- log16.error("insight-webhook.failed", { runId, error: err instanceof Error ? err.message : String(err) });
10798
+ log16.error("insight-webhook.failed", { runId, error: describeError(err) });
10808
10799
  }
10809
10800
  }
10810
10801
  }
10811
10802
  } catch (err) {
10812
- log16.error("intelligence.failed", { runId, error: err instanceof Error ? err.message : String(err) });
10803
+ log16.error("intelligence.failed", { runId, error: describeError(err) });
10813
10804
  }
10814
10805
  } else if (kind === RunKinds["gbp-sync"]) {
10815
10806
  try {
@@ -10822,17 +10813,17 @@ var RunCoordinator = class {
10822
10813
  try {
10823
10814
  await this.onInsightsGenerated(runId, projectId, analysisResultFromInsights(gbpInsights));
10824
10815
  } catch (err) {
10825
- log16.error("gbp-insight-webhook.failed", { runId, error: err instanceof Error ? err.message : String(err) });
10816
+ log16.error("gbp-insight-webhook.failed", { runId, error: describeError(err) });
10826
10817
  }
10827
10818
  }
10828
10819
  } catch (err) {
10829
- log16.error("gbp-intelligence.failed", { runId, error: err instanceof Error ? err.message : String(err) });
10820
+ log16.error("gbp-intelligence.failed", { runId, error: describeError(err) });
10830
10821
  }
10831
10822
  }
10832
10823
  try {
10833
10824
  await this.notifier.onRunCompleted(runId, projectId);
10834
10825
  } catch (err) {
10835
- log16.error("notifier.failed", { runId, error: err instanceof Error ? err.message : String(err) });
10826
+ log16.error("notifier.failed", { runId, error: describeError(err) });
10836
10827
  }
10837
10828
  if (this.onAeroEvent) {
10838
10829
  try {
@@ -10845,7 +10836,7 @@ var RunCoordinator = class {
10845
10836
  };
10846
10837
  await this.onAeroEvent(ctx);
10847
10838
  } catch (err) {
10848
- log16.error("aero.failed", { runId, error: err instanceof Error ? err.message : String(err) });
10839
+ log16.error("aero.failed", { runId, error: describeError(err) });
10849
10840
  }
10850
10841
  }
10851
10842
  }
@@ -11451,7 +11442,7 @@ async function readSection(fn) {
11451
11442
  } catch (err) {
11452
11443
  return {
11453
11444
  status: "error",
11454
- error: err instanceof Error ? err.message : String(err)
11445
+ error: describeError(err)
11455
11446
  };
11456
11447
  }
11457
11448
  }
@@ -12002,7 +11993,7 @@ async function loadExternalMcpTools(servers, opts = {}) {
12002
11993
  } catch (err) {
12003
11994
  log17.error("external-mcp.connect-failed", {
12004
11995
  label,
12005
- error: err instanceof Error ? err.message : String(err)
11996
+ error: describeError(err)
12006
11997
  });
12007
11998
  continue;
12008
11999
  }
@@ -12012,7 +12003,7 @@ async function loadExternalMcpTools(servers, opts = {}) {
12012
12003
  } catch (err) {
12013
12004
  log17.error("external-mcp.list-failed", {
12014
12005
  label,
12015
- error: err instanceof Error ? err.message : String(err)
12006
+ error: describeError(err)
12016
12007
  });
12017
12008
  continue;
12018
12009
  }
@@ -12298,7 +12289,7 @@ var SessionRegistry = class {
12298
12289
  this.externalToolsPromise = loadExternalMcpTools(this.opts.config.externalMcpServers).catch(
12299
12290
  (err) => {
12300
12291
  log18.error("external-mcp.load-failed", {
12301
- error: err instanceof Error ? err.message : String(err)
12292
+ error: describeError(err)
12302
12293
  });
12303
12294
  return [];
12304
12295
  }
@@ -12550,7 +12541,7 @@ ${lines.join("\n")}
12550
12541
  } catch (err) {
12551
12542
  log18.error("compaction.failed", {
12552
12543
  projectName,
12553
- error: err instanceof Error ? err.message : String(err)
12544
+ error: describeError(err)
12554
12545
  });
12555
12546
  }
12556
12547
  }
@@ -12651,7 +12642,7 @@ ${lines.join("\n")}
12651
12642
  } catch (err) {
12652
12643
  log18.error("drain.failed", {
12653
12644
  projectName,
12654
- error: err instanceof Error ? err.message : String(err)
12645
+ error: describeError(err)
12655
12646
  });
12656
12647
  }
12657
12648
  }
@@ -12861,7 +12852,7 @@ function registerAgentRoutes(app, opts) {
12861
12852
  await agent.waitForIdle();
12862
12853
  opts.sessionRegistry.save(project.name);
12863
12854
  } catch (err) {
12864
- write({ type: "error", message: err instanceof Error ? err.message : String(err) });
12855
+ write({ type: "error", message: describeError(err) });
12865
12856
  } finally {
12866
12857
  unsubscribe();
12867
12858
  write({ type: "stream_close" });
@@ -13323,7 +13314,7 @@ var SnapshotService = class {
13323
13314
  const report = await runAeoAudit(homepageUrl);
13324
13315
  return mapAuditReport(report);
13325
13316
  } catch (err) {
13326
- const message = err instanceof Error ? err.message : String(err);
13317
+ const message = describeError(err);
13327
13318
  log19.warn("audit.failed", { homepageUrl, error: message });
13328
13319
  return {
13329
13320
  url: homepageUrl,
@@ -13356,7 +13347,7 @@ var SnapshotService = class {
13356
13347
  log19.warn("profile.generation-failed", {
13357
13348
  domain: ctx.domain,
13358
13349
  provider: ctx.analysisProvider.adapter.name,
13359
- error: err instanceof Error ? err.message : String(err)
13350
+ error: describeError(err)
13360
13351
  });
13361
13352
  }
13362
13353
  }
@@ -13439,7 +13430,7 @@ var SnapshotService = class {
13439
13430
  groundingSources: [],
13440
13431
  searchQueries: [],
13441
13432
  answerText: "",
13442
- error: err instanceof Error ? err.message : String(err)
13433
+ error: describeError(err)
13443
13434
  };
13444
13435
  }
13445
13436
  });
@@ -13498,7 +13489,7 @@ var SnapshotService = class {
13498
13489
  } catch (err) {
13499
13490
  log19.warn("response.analysis-failed", {
13500
13491
  provider: ctx.analysisProvider.adapter.name,
13501
- error: err instanceof Error ? err.message : String(err)
13492
+ error: describeError(err)
13502
13493
  });
13503
13494
  return buildFallbackBatchAssessment(ctx.companyName, ctx.audit);
13504
13495
  }
@@ -13830,7 +13821,7 @@ async function executeResearchRun(db, registry, runId, projectId) {
13830
13821
  try {
13831
13822
  markResearchQueryFailed(db, runId, row.id, error);
13832
13823
  } catch (persistenceError) {
13833
- workerPersistenceErrors.push(persistenceError instanceof Error ? persistenceError.message : String(persistenceError));
13824
+ workerPersistenceErrors.push(describeError(persistenceError));
13834
13825
  }
13835
13826
  }
13836
13827
  });
@@ -13838,7 +13829,7 @@ async function executeResearchRun(db, registry, runId, projectId) {
13838
13829
  fatalError = `Failed to persist one or more research query results: ${workerPersistenceErrors[0]}`;
13839
13830
  }
13840
13831
  } catch (error) {
13841
- fatalError = error instanceof Error ? error.message : String(error);
13832
+ fatalError = describeError(error);
13842
13833
  } finally {
13843
13834
  if (fatalError) markUnfinishedResearchQueriesFailed(db, runId, fatalError);
13844
13835
  finalizeResearchRun(db, runId, fatalError);
@@ -13851,7 +13842,7 @@ function incrementResearchProgress(db, runId, column) {
13851
13842
  db.update(researchRuns).set({ [column]: sql10`${researchRuns[column]} + 1` }).where(eq23(researchRuns.id, runId)).run();
13852
13843
  }
13853
13844
  function markResearchQueryFailed(db, runId, queryId, error) {
13854
- const message = error instanceof Error ? error.message : String(error);
13845
+ const message = describeError(error);
13855
13846
  const failed = db.update(researchRunQueries).set({ status: ResearchQueryStatuses.failed, error: message, finishedAt: (/* @__PURE__ */ new Date()).toISOString() }).where(and17(eq23(researchRunQueries.id, queryId), inArray8(researchRunQueries.status, unfinishedResearchQueryStatuses))).run();
13856
13847
  if (failed.changes === 1) incrementResearchProgress(db, runId, "failedQueries");
13857
13848
  }
@@ -14123,7 +14114,7 @@ async function createServer(opts) {
14123
14114
  dropLegacyCredentialColumns(opts.db);
14124
14115
  } catch (err) {
14125
14116
  log20.warn("credentials.migration.failed", {
14126
- error: err instanceof Error ? err.message : String(err)
14117
+ error: describeError(err)
14127
14118
  });
14128
14119
  }
14129
14120
  log20.info("providers.configured", {
@@ -14524,7 +14515,7 @@ async function createServer(opts) {
14524
14515
  {
14525
14516
  projectName,
14526
14517
  sourceId,
14527
- err: err instanceof Error ? err.message : String(err)
14518
+ err: describeError(err)
14528
14519
  },
14529
14520
  "Scheduled traffic sync failed"
14530
14521
  );
@@ -14585,7 +14576,7 @@ async function createServer(opts) {
14585
14576
  {
14586
14577
  projectName,
14587
14578
  release: probed.release,
14588
- err: err instanceof Error ? err.message : String(err)
14579
+ err: describeError(err)
14589
14580
  },
14590
14581
  "Scheduled backlinks sync failed"
14591
14582
  );