@canonry/canonry 7.125.0 → 7.125.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,8 +10,8 @@ import {
10
10
  backfillSnapshotAttributionCommand,
11
11
  backfillTrafficClassificationCommand,
12
12
  replayQueryAuditLog
13
- } from "./chunk-5NC3F52M.js";
14
- import "./chunk-APZ4FBGH.js";
13
+ } from "./chunk-WTAL4GJ4.js";
14
+ import "./chunk-O4S75UQI.js";
15
15
  import "./chunk-OTMAY3N2.js";
16
16
  import "./chunk-FHJU7QBM.js";
17
17
  import "./chunk-GUPHVIGW.js";
@@ -19,7 +19,7 @@ import "./chunk-KUO2TYF4.js";
19
19
  import {
20
20
  backfillProjectAnswerMentions,
21
21
  backfillProjectAnswerMentionsInChunks
22
- } from "./chunk-WG6RJDVW.js";
22
+ } from "./chunk-3PPQMBTA.js";
23
23
  import "./chunk-ZJ6HMVLQ.js";
24
24
  import "./chunk-TNV7DLA7.js";
25
25
  import "./chunk-7M5QTA7T.js";
@@ -57381,16 +57381,45 @@ function orderByEveryDimension(dimensions) {
57381
57381
  }
57382
57382
  async function fetchPagedReport(accessToken, propertyId, baseRequest, pageSize = 1e4) {
57383
57383
  const request = baseRequest.orderBys?.length ? baseRequest : { ...baseRequest, orderBys: orderByEveryDimension(baseRequest.dimensions) };
57384
+ return readSettledRows(accessToken, propertyId, request, pageSize);
57385
+ }
57386
+ async function readSettledRows(accessToken, propertyId, request, pageSize) {
57387
+ const halves = splitByDate(request);
57388
+ const range = request.dateRanges.length === 1 ? request.dateRanges[0] : void 0;
57384
57389
  for (let attempt = 1; attempt <= GA4_PAGED_READ_ATTEMPTS; attempt++) {
57385
57390
  const rows = await readReportPages(accessToken, propertyId, request, pageSize);
57386
57391
  if (rows) return rows;
57387
- ga4Log("info", "paged-report.rows-moved", { propertyId, attempt, attempts: GA4_PAGED_READ_ATTEMPTS });
57392
+ ga4Log("info", "paged-report.rows-moved", {
57393
+ propertyId,
57394
+ startDate: range?.startDate,
57395
+ endDate: range?.endDate,
57396
+ attempt,
57397
+ next: halves ? "split" : attempt < GA4_PAGED_READ_ATTEMPTS ? "retry" : "fail"
57398
+ });
57399
+ if (halves) {
57400
+ const earlier = await readSettledRows(accessToken, propertyId, halves[0], pageSize);
57401
+ const later = await readSettledRows(accessToken, propertyId, halves[1], pageSize);
57402
+ return [...earlier, ...later];
57403
+ }
57388
57404
  }
57405
+ const day = range && range.startDate === range.endDate ? ` for ${range.startDate}` : "";
57389
57406
  throw new GA4ApiError(
57390
- `GA4 report rows moved between pages on ${GA4_PAGED_READ_ATTEMPTS} reads in a row, so no consistent copy could be read. The next sync will try again.`,
57407
+ `GA4 report rows${day} moved between pages on ${GA4_PAGED_READ_ATTEMPTS} reads in a row, so no consistent copy could be read. The next sync will try again.`,
57391
57408
  502
57392
57409
  );
57393
57410
  }
57411
+ function splitByDate(request) {
57412
+ if (request.dateRanges.length !== 1) return null;
57413
+ const [range] = request.dateRanges;
57414
+ if (request.orderBys?.[0]?.dimension?.dimensionName !== GA4_DIMENSIONS.date) return null;
57415
+ const days = inclusiveDayCount(range.startDate, range.endDate);
57416
+ if (days === null || days < 2) return null;
57417
+ const earlierDays = Math.floor(days / 2);
57418
+ return [
57419
+ { ...request, dateRanges: [{ ...range, endDate: shiftIsoCalendarDate(range.startDate, earlierDays - 1) }] },
57420
+ { ...request, dateRanges: [{ ...range, startDate: shiftIsoCalendarDate(range.startDate, earlierDays) }] }
57421
+ ];
57422
+ }
57394
57423
  async function readReportPages(accessToken, propertyId, request, pageSize) {
57395
57424
  const rows = [];
57396
57425
  const seen2 = /* @__PURE__ */ new Set();
@@ -47,7 +47,7 @@ function queueServeHandoff() {
47
47
  async function runPendingServeHandoff(format) {
48
48
  if (!pendingServeHandoff) return;
49
49
  pendingServeHandoff = false;
50
- const { serveCommand } = await import("./serve-LLVRHZCB.js");
50
+ const { serveCommand } = await import("./serve-SMBPWWOI.js");
51
51
  await serveCommand(format);
52
52
  }
53
53
 
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-FHJU7QBM.js";
12
12
  import {
13
13
  buildOpenApiDocument
14
- } from "./chunk-WG6RJDVW.js";
14
+ } from "./chunk-3PPQMBTA.js";
15
15
  import {
16
16
  DEFAULT_COMPETITOR_AUTO_ALIAS_MODE,
17
17
  MeasurementPortfolioLists,
@@ -783,7 +783,7 @@ var DEMO_CLI_COMMANDS = [{
783
783
  options: { host: stringOption(), port: stringOption(), "trust-proxy": multiStringOption() },
784
784
  allowPositionals: false,
785
785
  run: async (input) => {
786
- const { demoCommand } = await import("./demo-HR3FBBIS.js");
786
+ const { demoCommand } = await import("./demo-OKZN2MIB.js");
787
787
  await demoCommand({
788
788
  host: getString(input.values, "host"),
789
789
  port: getString(input.values, "port"),
@@ -804,7 +804,7 @@ var BACKFILL_CLI_COMMANDS = [
804
804
  allowPositionals: false,
805
805
  supportsDryRun: true,
806
806
  run: async (input) => {
807
- const { backfillAnswerVisibilityCommand } = await import("./backfill-WNMMJT44.js");
807
+ const { backfillAnswerVisibilityCommand } = await import("./backfill-FWKKCPH4.js");
808
808
  await backfillAnswerVisibilityCommand({
809
809
  project: getString(input.values, "project"),
810
810
  dryRun: input.dryRun,
@@ -821,7 +821,7 @@ var BACKFILL_CLI_COMMANDS = [
821
821
  allowPositionals: false,
822
822
  supportsDryRun: true,
823
823
  run: async (input) => {
824
- const { backfillAnswerMentionsCommand } = await import("./backfill-WNMMJT44.js");
824
+ const { backfillAnswerMentionsCommand } = await import("./backfill-FWKKCPH4.js");
825
825
  await backfillAnswerMentionsCommand({
826
826
  project: getString(input.values, "project"),
827
827
  dryRun: input.dryRun,
@@ -839,7 +839,7 @@ var BACKFILL_CLI_COMMANDS = [
839
839
  },
840
840
  supportsDryRun: true,
841
841
  run: async (input) => {
842
- const { backfillInsightsCommand } = await import("./backfill-WNMMJT44.js");
842
+ const { backfillInsightsCommand } = await import("./backfill-FWKKCPH4.js");
843
843
  const usage = "canonry backfill insights <project> [--from-run <id>] [--to-run <id>] [--since <date>] [--dry-run] [--format json]";
844
844
  const project3 = requireProject(input, "backfill insights", usage);
845
845
  await backfillInsightsCommand(project3, {
@@ -859,7 +859,7 @@ var BACKFILL_CLI_COMMANDS = [
859
859
  },
860
860
  allowPositionals: false,
861
861
  run: async (input) => {
862
- const { backfillNormalizedPathsCommand } = await import("./backfill-WNMMJT44.js");
862
+ const { backfillNormalizedPathsCommand } = await import("./backfill-FWKKCPH4.js");
863
863
  await backfillNormalizedPathsCommand({
864
864
  project: getString(input.values, "project"),
865
865
  format: input.format
@@ -874,7 +874,7 @@ var BACKFILL_CLI_COMMANDS = [
874
874
  },
875
875
  allowPositionals: false,
876
876
  run: async (input) => {
877
- const { backfillAiReferralPathsCommand } = await import("./backfill-WNMMJT44.js");
877
+ const { backfillAiReferralPathsCommand } = await import("./backfill-FWKKCPH4.js");
878
878
  await backfillAiReferralPathsCommand({
879
879
  project: getString(input.values, "project"),
880
880
  format: input.format
@@ -886,7 +886,7 @@ var BACKFILL_CLI_COMMANDS = [
886
886
  usage: "canonry backfill snapshot-attribution <project> [--dry-run] [--format json]",
887
887
  supportsDryRun: true,
888
888
  run: async (input) => {
889
- const { backfillSnapshotAttributionCommand } = await import("./backfill-WNMMJT44.js");
889
+ const { backfillSnapshotAttributionCommand } = await import("./backfill-FWKKCPH4.js");
890
890
  const usage = "canonry backfill snapshot-attribution <project> [--dry-run] [--format json]";
891
891
  const project3 = requireProject(input, "backfill snapshot-attribution", usage);
892
892
  await backfillSnapshotAttributionCommand({
@@ -905,7 +905,7 @@ var BACKFILL_CLI_COMMANDS = [
905
905
  allowPositionals: false,
906
906
  supportsDryRun: true,
907
907
  run: async (input) => {
908
- const { backfillTrafficClassificationCommand } = await import("./backfill-WNMMJT44.js");
908
+ const { backfillTrafficClassificationCommand } = await import("./backfill-FWKKCPH4.js");
909
909
  await backfillTrafficClassificationCommand({
910
910
  project: getString(input.values, "project"),
911
911
  dryRun: input.dryRun,
@@ -1551,7 +1551,7 @@ var DASHBOARD_CLI_COMMANDS = [
1551
1551
  usage: "canonry dashboard reset-password [--format json]",
1552
1552
  help: "Clears the dashboard password from config.yaml, so the dashboard asks for a new one after a restart.\nLocal only: it edits the config file under CANONRY_CONFIG_DIR and does not call the server.",
1553
1553
  run: async (input) => {
1554
- const { resetDashboardPassword } = await import("./dashboard-7TRWPJFS.js");
1554
+ const { resetDashboardPassword } = await import("./dashboard-ZYVYVNTW.js");
1555
1555
  await resetDashboardPassword({ format: input.format });
1556
1556
  }
1557
1557
  },
@@ -7469,7 +7469,7 @@ var SYSTEM_CLI_COMMANDS = [
7469
7469
  options: { access: stringOption() },
7470
7470
  run: async (input) => {
7471
7471
  if (input.positionals.length > 1) throw usageError("Expected at most one command group");
7472
- const [{ printCliCatalog }, { REGISTERED_CLI_COMMANDS: REGISTERED_CLI_COMMANDS2 }] = await Promise.all([import("./cli-catalog-7WND6LOK.js"), import("./cli-commands-VNYJHERV.js")]);
7472
+ const [{ printCliCatalog }, { REGISTERED_CLI_COMMANDS: REGISTERED_CLI_COMMANDS2 }] = await Promise.all([import("./cli-catalog-7WND6LOK.js"), import("./cli-commands-BMVORBFI.js")]);
7473
7473
  printCliCatalog(REGISTERED_CLI_COMMANDS2, input.format, input.positionals[0], getString(input.values, "access"));
7474
7474
  }
7475
7475
  },
@@ -7518,7 +7518,7 @@ var SYSTEM_CLI_COMMANDS = [
7518
7518
  },
7519
7519
  allowPositionals: false,
7520
7520
  run: async (input) => {
7521
- const { initCommand } = await import("./init-4YY4YJIP.js");
7521
+ const { initCommand } = await import("./init-72RAXVAL.js");
7522
7522
  await initCommand({
7523
7523
  force: getBoolean(input.values, "force"),
7524
7524
  ref: getString(input.values, "ref"),
@@ -7574,7 +7574,7 @@ var SYSTEM_CLI_COMMANDS = [
7574
7574
  allowPositionals: false,
7575
7575
  run: async (input) => {
7576
7576
  applyServerEnv(input.values);
7577
- const { serveCommand } = await import("./serve-LLVRHZCB.js");
7577
+ const { serveCommand } = await import("./serve-SMBPWWOI.js");
7578
7578
  await serveCommand(input.format);
7579
7579
  }
7580
7580
  },
@@ -8950,8 +8950,8 @@ var AGENT_CLI_COMMANDS = [
8950
8950
  "timeout-ms": stringOption()
8951
8951
  },
8952
8952
  run: async (input) => {
8953
- const { coerceAgentProvider } = await import("./session-BZCCNFCC.js");
8954
- const { AERO_TOOL_PROFILES, isAeroToolProfile } = await import("./tools-X6JCH5AF.js");
8953
+ const { coerceAgentProvider } = await import("./session-XCMWUFDH.js");
8954
+ const { AERO_TOOL_PROFILES, isAeroToolProfile } = await import("./tools-F2UCM5HU.js");
8955
8955
  const { agentAsk } = await import("./agent-ask-DQBDMPXP.js");
8956
8956
  const usage = `canonry agent ask <project> "<prompt>" [--provider ${AGENT_PROVIDER_IDS.join("|")}] [--model <id>] [--scope all|read-only] [--profile default|ads-operator] [--context <json>] [--conversation <id>] [--max-tool-calls <n>] [--timeout-ms <ms>] [--format json]`;
8957
8957
  const project3 = requireProject(input, "agent.ask", usage);
@@ -5,7 +5,7 @@ import {
5
5
  isStoredPageReadTool,
6
6
  isStoredReadTool,
7
7
  truncateToolResult
8
- } from "./chunk-EXKK2O2S.js";
8
+ } from "./chunk-CSU4E5KJ.js";
9
9
  import {
10
10
  CANONRY_MCP_TOOLKITS,
11
11
  resolveAeroSkillDir
@@ -7,7 +7,7 @@ import {
7
7
  mergeSplitJourneyVisitors,
8
8
  repairAiReferralArrivalsOnStartup,
9
9
  writeUnrecognizedAgentBuckets
10
- } from "./chunk-WG6RJDVW.js";
10
+ } from "./chunk-3PPQMBTA.js";
11
11
  import {
12
12
  AGENT_TRUST_RULES_VERSION,
13
13
  BROWSER_AGENT_BOT_IDS,
@@ -24,14 +24,14 @@ import {
24
24
  resolveConfiguredAgentProvider,
25
25
  resolveSessionProviderAndModel,
26
26
  setAeroSystemPrompt
27
- } from "./chunk-74254NLQ.js";
27
+ } from "./chunk-HPRUS76O.js";
28
28
  import {
29
29
  AeroToolProfiles,
30
30
  AeroToolScopes,
31
31
  buildAeroStateTools,
32
32
  isAeroToolProfile,
33
33
  truncateToolResult
34
- } from "./chunk-EXKK2O2S.js";
34
+ } from "./chunk-CSU4E5KJ.js";
35
35
  import {
36
36
  answerServiceAdapters,
37
37
  answerServiceDescriptors
@@ -69,7 +69,7 @@ import {
69
69
  openrouterAdapter,
70
70
  perplexityAdapter,
71
71
  startTrafficReclassification
72
- } from "./chunk-APZ4FBGH.js";
72
+ } from "./chunk-O4S75UQI.js";
73
73
  import {
74
74
  classifyUsageSurface,
75
75
  createApiUsageTelemetry,
@@ -169,7 +169,7 @@ import {
169
169
  } from "./chunk-FHJU7QBM.js";
170
170
  import {
171
171
  IntelligenceService
172
- } from "./chunk-VKB4LFYV.js";
172
+ } from "./chunk-XCJSH2FJ.js";
173
173
  import {
174
174
  computeCitedCompetitorDomains,
175
175
  determineCitationState
@@ -334,7 +334,7 @@ import {
334
334
  webhookTargetRefusalReason,
335
335
  webhookUserAgent,
336
336
  writeAuditLog
337
- } from "./chunk-WG6RJDVW.js";
337
+ } from "./chunk-3PPQMBTA.js";
338
338
  import {
339
339
  OperationalLogStore,
340
340
  SentimentIdempotencyConflict,
@@ -6471,7 +6471,7 @@ function nonBlank(value) {
6471
6471
  return trimmed ? trimmed : void 0;
6472
6472
  }
6473
6473
  function resolveBuildCommit(env = process.env) {
6474
- const embedded = true ? "10934954dd8516f191337a47403deff4052704ae" : void 0;
6474
+ const embedded = true ? "a1bab1360e0d34fcdd8d89445d2b2e8e65ae01fa" : void 0;
6475
6475
  return nonBlank(embedded) ?? nonBlank(env.CANONRY_COMMIT);
6476
6476
  }
6477
6477
  function resolveInstanceIdentity(env = process.env) {
@@ -17180,6 +17180,12 @@ var Notifier = class {
17180
17180
  }
17181
17181
  async sendWebhook(url, payload, notificationId, projectId, webhookSecret) {
17182
17182
  const elapsed = startOutcomeTimer();
17183
+ if ("health" in payload) {
17184
+ payload = {
17185
+ ...payload,
17186
+ eventId: "evt_" + crypto25.createHash("sha256").update(JSON.stringify([projectId, notificationId, payload.event, payload.health.checkedAt])).digest("hex")
17187
+ };
17188
+ }
17183
17189
  const destination = resolveDestination(url);
17184
17190
  const body = destination.render ? destination.render(toAlertView(payload)) : payload;
17185
17191
  const signingSecret = destination.signed ? webhookSecret : null;
@@ -8,7 +8,7 @@ import {
8
8
  reparseStoredResult4,
9
9
  reparseStoredResult5,
10
10
  resolveStoredApiResponse
11
- } from "./chunk-APZ4FBGH.js";
11
+ } from "./chunk-O4S75UQI.js";
12
12
  import {
13
13
  loadConfig
14
14
  } from "./chunk-OTMAY3N2.js";
@@ -25,7 +25,7 @@ import {
25
25
  createRunCompetitorResolver,
26
26
  readMarketCompetitorNames,
27
27
  refreshSnapshotMentionIdentity
28
- } from "./chunk-WG6RJDVW.js";
28
+ } from "./chunk-3PPQMBTA.js";
29
29
  import {
30
30
  RawEventSampleEventTypes,
31
31
  auditLog,
@@ -430,7 +430,7 @@ No DB writes performed. Re-run without --dry-run to apply.`);
430
430
  }
431
431
  }
432
432
  async function backfillInsightsCommand(project, opts) {
433
- const { IntelligenceService } = await import("./intelligence-service-J7OEF2BJ.js");
433
+ const { IntelligenceService } = await import("./intelligence-service-7GKHJ3B4.js");
434
434
  const config = loadConfig();
435
435
  const db = createClient(config.database);
436
436
  migrate(db);
@@ -18,7 +18,7 @@ import {
18
18
  notScopedRun,
19
19
  readGscQueryDailyRows,
20
20
  readLatestGscDataDate
21
- } from "./chunk-WG6RJDVW.js";
21
+ } from "./chunk-3PPQMBTA.js";
22
22
  import {
23
23
  competitors,
24
24
  gbpDailyMetrics,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  REGISTERED_CLI_COMMANDS
3
- } from "./chunk-C3RTFCWV.js";
3
+ } from "./chunk-HEKYXSY6.js";
4
4
  import "./chunk-6GO5VVAC.js";
5
5
  import "./chunk-VJWDBFSL.js";
6
6
  import "./chunk-KAFKHQCB.js";
package/dist/cli.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node --import tsx
2
2
  import {
3
3
  REGISTERED_CLI_COMMANDS
4
- } from "./chunk-C3RTFCWV.js";
4
+ } from "./chunk-HEKYXSY6.js";
5
5
  import "./chunk-6GO5VVAC.js";
6
6
  import {
7
7
  buildSetupState,
8
8
  runPendingServeHandoff
9
- } from "./chunk-TEGTNKVN.js";
9
+ } from "./chunk-7OQFD5BW.js";
10
10
  import "./chunk-VJWDBFSL.js";
11
11
  import "./chunk-KAFKHQCB.js";
12
12
  import "./chunk-TSENU4GG.js";
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-FHJU7QBM.js";
8
8
  import {
9
9
  anyUsersExist
10
- } from "./chunk-WG6RJDVW.js";
10
+ } from "./chunk-3PPQMBTA.js";
11
11
  import "./chunk-ZJ6HMVLQ.js";
12
12
  import "./chunk-TNV7DLA7.js";
13
13
  import {
@@ -40,7 +40,7 @@ function parseDemoTrustedProxies(values) {
40
40
  async function demoCommand(options) {
41
41
  const { host, port } = parseDemoListenOptions(options);
42
42
  const trustProxy = parseDemoTrustedProxies(options.trustProxy);
43
- const { createDemoServer } = await import("./demo-server-PXQUQJTQ.js");
43
+ const { createDemoServer } = await import("./demo-server-JWBH7TVQ.js");
44
44
  const app = await createDemoServer({ trustProxy });
45
45
  let stopping = false;
46
46
  const stop = () => {
@@ -19,7 +19,7 @@ import "./chunk-FHJU7QBM.js";
19
19
  import {
20
20
  HISTORY_WINDOW_RUNS,
21
21
  IntelligenceService
22
- } from "./chunk-VKB4LFYV.js";
22
+ } from "./chunk-XCJSH2FJ.js";
23
23
  import {
24
24
  determineCitationState
25
25
  } from "./chunk-GUPHVIGW.js";
@@ -27,7 +27,7 @@ import "./chunk-KUO2TYF4.js";
27
27
  import {
28
28
  apiRoutes,
29
29
  assessConversionTrackingIntegrity
30
- } from "./chunk-WG6RJDVW.js";
30
+ } from "./chunk-3PPQMBTA.js";
31
31
  import "./chunk-ZJ6HMVLQ.js";
32
32
  import "./chunk-TNV7DLA7.js";
33
33
  import {