@canonry/canonry 7.120.1 → 7.120.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-2SF5JXCY.js";
14
- import "./chunk-FX4VCCSD.js";
13
+ } from "./chunk-FYL67YEU.js";
14
+ import "./chunk-R2CBQPN6.js";
15
15
  import "./chunk-GDRZPBPF.js";
16
16
  import "./chunk-IWQFTZ75.js";
17
17
  import "./chunk-AOD35IKL.js";
@@ -19,7 +19,7 @@ import "./chunk-AHVF5OE5.js";
19
19
  import {
20
20
  backfillProjectAnswerMentions,
21
21
  backfillProjectAnswerMentionsInChunks
22
- } from "./chunk-5LV4OEAO.js";
22
+ } from "./chunk-VK6SYZAH.js";
23
23
  import "./chunk-3Q2D53KV.js";
24
24
  import "./chunk-TTQBEFSU.js";
25
25
  import "./chunk-VCXKSGZF.js";
@@ -5,7 +5,7 @@ import {
5
5
  isStoredPageReadTool,
6
6
  isStoredReadTool,
7
7
  truncateToolResult
8
- } from "./chunk-TNR2O4HU.js";
8
+ } from "./chunk-WLG476HL.js";
9
9
  import {
10
10
  CANONRY_MCP_TOOLKITS,
11
11
  resolveAeroSkillDir
@@ -8,7 +8,7 @@ import {
8
8
  reparseStoredResult4,
9
9
  reparseStoredResult5,
10
10
  resolveStoredApiResponse
11
- } from "./chunk-FX4VCCSD.js";
11
+ } from "./chunk-R2CBQPN6.js";
12
12
  import {
13
13
  loadConfig
14
14
  } from "./chunk-GDRZPBPF.js";
@@ -25,7 +25,7 @@ import {
25
25
  createRunCompetitorResolver,
26
26
  readMarketCompetitorNames,
27
27
  refreshSnapshotMentionIdentity
28
- } from "./chunk-5LV4OEAO.js";
28
+ } from "./chunk-VK6SYZAH.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-KEFHLH3W.js");
433
+ const { IntelligenceService } = await import("./intelligence-service-7S4ZFNB6.js");
434
434
  const config = loadConfig();
435
435
  const db = createClient(config.database);
436
436
  migrate(db);
@@ -24,7 +24,7 @@ import {
24
24
  resolveConfiguredAgentProvider,
25
25
  resolveSessionProviderAndModel,
26
26
  setAeroSystemPrompt
27
- } from "./chunk-2VSOYLSX.js";
27
+ } from "./chunk-6WG3PZUR.js";
28
28
  import {
29
29
  answerServiceAdapters,
30
30
  answerServiceDescriptors
@@ -38,7 +38,7 @@ import {
38
38
  buildAeroStateTools,
39
39
  isAeroToolProfile,
40
40
  truncateToolResult
41
- } from "./chunk-TNR2O4HU.js";
41
+ } from "./chunk-WLG476HL.js";
42
42
  import {
43
43
  getGoogleAuthConfig,
44
44
  getGoogleConnection,
@@ -69,7 +69,7 @@ import {
69
69
  openrouterAdapter,
70
70
  perplexityAdapter,
71
71
  startTrafficReclassification
72
- } from "./chunk-FX4VCCSD.js";
72
+ } from "./chunk-R2CBQPN6.js";
73
73
  import {
74
74
  classifyUsageSurface,
75
75
  createApiUsageTelemetry,
@@ -169,7 +169,7 @@ import {
169
169
  } from "./chunk-IWQFTZ75.js";
170
170
  import {
171
171
  IntelligenceService
172
- } from "./chunk-6DSEIN3U.js";
172
+ } from "./chunk-RDISN2CO.js";
173
173
  import {
174
174
  computeCitedCompetitorDomains,
175
175
  determineCitationState
@@ -270,6 +270,7 @@ import {
270
270
  installDuckdb,
271
271
  isBlockingCrawlIssue,
272
272
  isDuckdbInstalled,
273
+ isScopedRun,
273
274
  isValidReleaseId,
274
275
  latestQueryBasketRevision,
275
276
  listCachedReleases,
@@ -287,6 +288,7 @@ import {
287
288
  nextRunFromCron,
288
289
  nextRunFromSchedule,
289
290
  notProbeRun,
291
+ notScopedRun,
290
292
  parseBingDate,
291
293
  parseChatGptTokenKey,
292
294
  parseCookieHeader,
@@ -330,7 +332,7 @@ import {
330
332
  webhookTargetRefusalReason,
331
333
  webhookUserAgent,
332
334
  writeAuditLog
333
- } from "./chunk-5LV4OEAO.js";
335
+ } from "./chunk-VK6SYZAH.js";
334
336
  import {
335
337
  OperationalLogStore,
336
338
  SentimentIdempotencyConflict,
@@ -6467,7 +6469,7 @@ function nonBlank(value) {
6467
6469
  return trimmed ? trimmed : void 0;
6468
6470
  }
6469
6471
  function resolveBuildCommit(env = process.env) {
6470
- const embedded = true ? "c479f3407ca734cafb5f3c12646d7824ff8c0dec" : void 0;
6472
+ const embedded = true ? "c6eb863a77d21a9dfef1ef7b8c6825eae93b8f68" : void 0;
6471
6473
  return nonBlank(embedded) ?? nonBlank(env.CANONRY_COMMIT);
6472
6474
  }
6473
6475
  function resolveInstanceIdentity(env = process.env) {
@@ -16778,6 +16780,10 @@ var Notifier = class {
16778
16780
  const projectId = project.id;
16779
16781
  const thisRun = this.db.select().from(runs).where(eq29(runs.id, runId)).get();
16780
16782
  if (!thisRun) return none;
16783
+ if (isScopedRun(thisRun)) {
16784
+ log26.info("transitions.skipped-spot-check", { runId });
16785
+ return none;
16786
+ }
16781
16787
  const completeness = measurementRunCompleteness(this.db, runId);
16782
16788
  if (completeness.planned && !completeness.complete) {
16783
16789
  log26.info("transitions.skipped-incomplete", {
@@ -16818,7 +16824,10 @@ var Notifier = class {
16818
16824
  eq29(runs.projectId, projectId),
16819
16825
  eq29(runs.kind, thisRun.kind),
16820
16826
  or2(eq29(runs.status, "completed"), eq29(runs.status, "partial")),
16821
- notProbeRun()
16827
+ notProbeRun(),
16828
+ // The previous sweep, never a spot check between the two: diffed
16829
+ // against a 2-query check, every other query's change is lost.
16830
+ notScopedRun()
16822
16831
  )
16823
16832
  ).orderBy(desc10(runs.createdAt), desc10(runs.id)).limit(RECENT_FETCH_LIMIT).all();
16824
16833
  const groups = groupRunsByCreatedAt(recentRuns);
@@ -17248,6 +17257,15 @@ var RunCoordinator = class {
17248
17257
  log27.error("answers-recorded.failed", { runId, projectId, error: describeError(err) });
17249
17258
  }
17250
17259
  }
17260
+ if (kind === RunKinds["answer-visibility"] && runRow && isScopedRun(runRow)) {
17261
+ log27.info("spot-check.skip-derived", { runId, projectId });
17262
+ try {
17263
+ await this.notifier.onRunCompleted(runId, projectId);
17264
+ } catch (err) {
17265
+ log27.error("notifier.failed", { runId, error: describeError(err) });
17266
+ }
17267
+ return;
17268
+ }
17251
17269
  const completeness = measurementRunCompleteness(this.db, runId);
17252
17270
  if (completeness.planned && !completeness.complete) {
17253
17271
  log27.info("measurement.incomplete-skip-derived", {
@@ -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-FUYRS76Y.js");
50
+ const { serveCommand } = await import("./serve-GLPKVWZE.js");
51
51
  await serveCommand(format);
52
52
  }
53
53
 
@@ -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-LXQZAB7S.js");
786
+ const { demoCommand } = await import("./demo-JGVDDJYC.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-W2EGRHJD.js");
807
+ const { backfillAnswerVisibilityCommand } = await import("./backfill-AE23XODQ.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-W2EGRHJD.js");
824
+ const { backfillAnswerMentionsCommand } = await import("./backfill-AE23XODQ.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-W2EGRHJD.js");
842
+ const { backfillInsightsCommand } = await import("./backfill-AE23XODQ.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-W2EGRHJD.js");
862
+ const { backfillNormalizedPathsCommand } = await import("./backfill-AE23XODQ.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-W2EGRHJD.js");
877
+ const { backfillAiReferralPathsCommand } = await import("./backfill-AE23XODQ.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-W2EGRHJD.js");
889
+ const { backfillSnapshotAttributionCommand } = await import("./backfill-AE23XODQ.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-W2EGRHJD.js");
908
+ const { backfillTrafficClassificationCommand } = await import("./backfill-AE23XODQ.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-EL7ABV7Y.js");
1554
+ const { resetDashboardPassword } = await import("./dashboard-7I6A2XHW.js");
1555
1555
  await resetDashboardPassword({ format: input.format });
1556
1556
  }
1557
1557
  },
@@ -7390,7 +7390,7 @@ var SYSTEM_CLI_COMMANDS = [
7390
7390
  options: { access: stringOption() },
7391
7391
  run: async (input) => {
7392
7392
  if (input.positionals.length > 1) throw usageError("Expected at most one command group");
7393
- const [{ printCliCatalog }, { REGISTERED_CLI_COMMANDS: REGISTERED_CLI_COMMANDS2 }] = await Promise.all([import("./cli-catalog-4ZCK2TFK.js"), import("./cli-commands-3U3WYSCW.js")]);
7393
+ const [{ printCliCatalog }, { REGISTERED_CLI_COMMANDS: REGISTERED_CLI_COMMANDS2 }] = await Promise.all([import("./cli-catalog-4ZCK2TFK.js"), import("./cli-commands-Z7Q5HLBB.js")]);
7394
7394
  printCliCatalog(REGISTERED_CLI_COMMANDS2, input.format, input.positionals[0], getString(input.values, "access"));
7395
7395
  }
7396
7396
  },
@@ -7439,7 +7439,7 @@ var SYSTEM_CLI_COMMANDS = [
7439
7439
  },
7440
7440
  allowPositionals: false,
7441
7441
  run: async (input) => {
7442
- const { initCommand } = await import("./init-GE6BXE4J.js");
7442
+ const { initCommand } = await import("./init-BK6GYDZP.js");
7443
7443
  await initCommand({
7444
7444
  force: getBoolean(input.values, "force"),
7445
7445
  ref: getString(input.values, "ref"),
@@ -7495,7 +7495,7 @@ var SYSTEM_CLI_COMMANDS = [
7495
7495
  allowPositionals: false,
7496
7496
  run: async (input) => {
7497
7497
  applyServerEnv(input.values);
7498
- const { serveCommand } = await import("./serve-FUYRS76Y.js");
7498
+ const { serveCommand } = await import("./serve-GLPKVWZE.js");
7499
7499
  await serveCommand(input.format);
7500
7500
  }
7501
7501
  },
@@ -8871,8 +8871,8 @@ var AGENT_CLI_COMMANDS = [
8871
8871
  "timeout-ms": stringOption()
8872
8872
  },
8873
8873
  run: async (input) => {
8874
- const { coerceAgentProvider } = await import("./session-J7JPFAV3.js");
8875
- const { AERO_TOOL_PROFILES, isAeroToolProfile } = await import("./tools-WTCPC6VA.js");
8874
+ const { coerceAgentProvider } = await import("./session-RJ5AYV6Q.js");
8875
+ const { AERO_TOOL_PROFILES, isAeroToolProfile } = await import("./tools-BCDSJTKK.js");
8876
8876
  const { agentAsk } = await import("./agent-ask-VAZUSWFA.js");
8877
8877
  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]`;
8878
8878
  const project3 = requireProject(input, "agent.ask", usage);
@@ -7,7 +7,7 @@ import {
7
7
  mergeSplitJourneyVisitors,
8
8
  repairAiReferralArrivalsOnStartup,
9
9
  writeUnrecognizedAgentBuckets
10
- } from "./chunk-5LV4OEAO.js";
10
+ } from "./chunk-VK6SYZAH.js";
11
11
  import {
12
12
  AGENT_TRUST_RULES_VERSION,
13
13
  BROWSER_AGENT_BOT_IDS,
@@ -15,9 +15,10 @@ import {
15
15
  compileCompetitiveSignalResolver,
16
16
  extractPlaceAmenities,
17
17
  mergeGscQueryTotalsWithFallback,
18
+ notScopedRun,
18
19
  readGscQueryDailyRows,
19
20
  readLatestGscDataDate
20
- } from "./chunk-5LV4OEAO.js";
21
+ } from "./chunk-VK6SYZAH.js";
21
22
  import {
22
23
  competitors,
23
24
  gbpDailyMetrics,
@@ -62,7 +63,12 @@ function analyzableRunPredicates(projectId) {
62
63
  // Defensive: RunCoordinator already skips probes before analyzeAndPersist
63
64
  // is called, but a future call site invoking it directly for a probe must
64
65
  // still not pollute the intelligence window.
65
- ne(runs.trigger, RunTriggers.probe)
66
+ ne(runs.trigger, RunTriggers.probe),
67
+ // A spot check measured a few queries on purpose. Analyzed, it writes
68
+ // insights and a health row about its slice; as a baseline it hides every
69
+ // other query's change from the next sweep; as a history entry it adds a
70
+ // run to the streaks of the queries it asked.
71
+ notScopedRun()
66
72
  ];
67
73
  }
68
74
  function readStoredGroundingSources(rawResponse) {
@@ -658,8 +664,9 @@ var IntelligenceService = class {
658
664
  eq(runs.projectId, projectId),
659
665
  eq(runs.kind, RunKinds["answer-visibility"]),
660
666
  or(eq(runs.status, "completed"), eq(runs.status, "partial")),
661
- // Defensive — see top of file.
662
- ne(runs.trigger, RunTriggers.probe)
667
+ // Defensive — see top of file. A spot check is not a sweep either.
668
+ ne(runs.trigger, RunTriggers.probe),
669
+ notScopedRun()
663
670
  )
664
671
  ).orderBy(desc(runs.createdAt), desc(runs.id)).limit((RECURRENCE_LOOKBACK_RUNS + 1) * ROWS_PER_GROUP_BUDGET).all();
665
672
  const recentGroups = groupRunsByCreatedAt(recentRunRows);
@@ -1786,8 +1786,17 @@ async function userSessionRoutes(app, opts = {}) {
1786
1786
  }
1787
1787
  var UNKNOWN_ACCOUNT_DIGEST = `${SCRYPT_DIGEST_PREFIX}AAAAAAAAAAAAAAAAAAAAAA==$` + Buffer.alloc(64, 0).toString("base64");
1788
1788
 
1789
+ // ../api-routes/src/run-scope.ts
1790
+ import { and, isNull } from "drizzle-orm";
1791
+ function isScopedRun(run) {
1792
+ return run.queries != null || run.measurementScope != null;
1793
+ }
1794
+ function notScopedRun() {
1795
+ return and(isNull(runs.queries), isNull(runs.measurementScope));
1796
+ }
1797
+
1789
1798
  // ../api-routes/src/sentiment-mention-identity.ts
1790
- import { and, asc, eq as eq2, inArray } from "drizzle-orm";
1799
+ import { and as and2, asc, eq as eq2, inArray } from "drizzle-orm";
1791
1800
 
1792
1801
  // ../api-routes/src/sentiment-input.ts
1793
1802
  import { createHash } from "crypto";
@@ -1904,7 +1913,7 @@ function refreshSnapshotMentionIdentity(db, snapshotIds) {
1904
1913
  edges: sentimentWorkItems.edges,
1905
1914
  outcome: sentimentResults.outcome,
1906
1915
  completedAt: sentimentResults.completedAt
1907
- }).from(sentimentWorkItems).innerJoin(sentimentResults, eq2(sentimentResults.workItemId, sentimentWorkItems.id)).where(and(
1916
+ }).from(sentimentWorkItems).innerJoin(sentimentResults, eq2(sentimentResults.workItemId, sentimentWorkItems.id)).where(and2(
1908
1917
  inArray(sentimentWorkItems.runId, [...new Set(snapshots.map((snapshot) => snapshot.runId))]),
1909
1918
  inArray(sentimentWorkItems.snapshotId, chunk),
1910
1919
  eq2(sentimentWorkItems.status, "completed")
@@ -1961,11 +1970,11 @@ function snapshotsWithSentimentResults(db) {
1961
1970
  }
1962
1971
 
1963
1972
  // ../api-routes/src/plan-competitors.ts
1964
- import { and as and3, desc, eq as eq4, exists, inArray as inArray2, isNotNull, ne, or } from "drizzle-orm";
1973
+ import { and as and4, desc, eq as eq4, exists, inArray as inArray2, isNotNull, ne, or } from "drizzle-orm";
1965
1974
 
1966
1975
  // ../api-routes/src/measurement-draft-repo.ts
1967
1976
  import crypto3 from "crypto";
1968
- import { and as and2, eq as eq3, gt, lte as lte2 } from "drizzle-orm";
1977
+ import { and as and3, eq as eq3, gt, lte as lte2 } from "drizzle-orm";
1969
1978
  var MEASUREMENT_RECEIPT_TTL_MS = 24 * 60 * 60 * 1e3;
1970
1979
  function canonicalJsonValue(value) {
1971
1980
  if (Array.isArray(value)) return value.map(canonicalJsonValue);
@@ -2048,7 +2057,7 @@ function draftCounts(authoring) {
2048
2057
  function activePlanVersionRow(db, projectId) {
2049
2058
  const pointer = db.select().from(measurementPlans).where(eq3(measurementPlans.projectId, projectId)).get();
2050
2059
  if (!pointer) return null;
2051
- const version = db.select().from(measurementPlanVersions).where(and2(
2060
+ const version = db.select().from(measurementPlanVersions).where(and3(
2052
2061
  eq3(measurementPlanVersions.projectId, projectId),
2053
2062
  eq3(measurementPlanVersions.id, pointer.activeVersionId)
2054
2063
  )).get();
@@ -2077,7 +2086,7 @@ function requireIdempotencyKey(request, operation) {
2077
2086
  return value;
2078
2087
  }
2079
2088
  function replayReceipt(db, projectId, lookup, reply) {
2080
- const existing = db.select().from(measurementOperationReceipts).where(and2(
2089
+ const existing = db.select().from(measurementOperationReceipts).where(and3(
2081
2090
  eq3(measurementOperationReceipts.projectId, projectId),
2082
2091
  eq3(measurementOperationReceipts.operation, lookup.operation),
2083
2092
  eq3(measurementOperationReceipts.idempotencyKey, lookup.key),
@@ -2316,7 +2325,7 @@ function draftPinGroups(db, projectId) {
2316
2325
  return groups;
2317
2326
  }
2318
2327
  function supersededRevisionPins(db, projectId, activeVersionId) {
2319
- const measured = db.select({ id: runs.measurementPlanVersionId }).from(runs).where(and3(
2328
+ const measured = db.select({ id: runs.measurementPlanVersionId }).from(runs).where(and4(
2320
2329
  eq4(runs.projectId, projectId),
2321
2330
  eq4(runs.kind, RunKinds["answer-visibility"]),
2322
2331
  isNotNull(runs.measurementPlanVersionId),
@@ -2325,7 +2334,7 @@ function supersededRevisionPins(db, projectId, activeVersionId) {
2325
2334
  exists(db.select({ id: querySnapshots.id }).from(querySnapshots).where(eq4(querySnapshots.runId, runs.id)))
2326
2335
  )
2327
2336
  ));
2328
- const versions = db.select({ id: measurementPlanVersions.id, revision: measurementPlanVersions.revision }).from(measurementPlanVersions).where(and3(
2337
+ const versions = db.select({ id: measurementPlanVersions.id, revision: measurementPlanVersions.revision }).from(measurementPlanVersions).where(and4(
2329
2338
  eq4(measurementPlanVersions.projectId, projectId),
2330
2339
  inArray2(measurementPlanVersions.id, measured),
2331
2340
  ...activeVersionId ? [ne(measurementPlanVersions.id, activeVersionId)] : []
@@ -2335,7 +2344,7 @@ function supersededRevisionPins(db, projectId, activeVersionId) {
2335
2344
 
2336
2345
  // ../api-routes/src/competitor-writes.ts
2337
2346
  import crypto4 from "crypto";
2338
- import { and as and4, eq as eq5, inArray as inArray3, ne as ne2 } from "drizzle-orm";
2347
+ import { and as and5, eq as eq5, inArray as inArray3, ne as ne2 } from "drizzle-orm";
2339
2348
  function normalizeCompetitorList(domains) {
2340
2349
  const seen2 = /* @__PURE__ */ new Set();
2341
2350
  const result = [];
@@ -2382,7 +2391,7 @@ var competitorIdentityColumns = {
2382
2391
  function summarizeBulkCompetitorAdd(db, projectId, plan, options) {
2383
2392
  const wouldAdd = [...plan.added];
2384
2393
  if (wouldAdd.length === 0) return null;
2385
- const measured = db.select({ id: runs.id }).from(runs).where(and4(
2394
+ const measured = db.select({ id: runs.id }).from(runs).where(and5(
2386
2395
  eq5(runs.projectId, projectId),
2387
2396
  eq5(runs.kind, RunKinds["answer-visibility"]),
2388
2397
  inArray3(runs.status, [RunStatuses.completed, RunStatuses.partial]),
@@ -2555,7 +2564,7 @@ function uniqueByBrandKey(names) {
2555
2564
  });
2556
2565
  }
2557
2566
  function storedDomainBlockedAliases(tx, projectId, domain) {
2558
- const row = tx.select({ blockedAliases: marketCompetitorNames.blockedAliases }).from(marketCompetitorNames).where(and4(eq5(marketCompetitorNames.projectId, projectId), eq5(marketCompetitorNames.domain, domain))).get();
2567
+ const row = tx.select({ blockedAliases: marketCompetitorNames.blockedAliases }).from(marketCompetitorNames).where(and5(eq5(marketCompetitorNames.projectId, projectId), eq5(marketCompetitorNames.domain, domain))).get();
2559
2568
  return row?.blockedAliases ?? [];
2560
2569
  }
2561
2570
  function keepBlockedAliasesOfRemovedCompetitors(tx, projectId, removed, now) {
@@ -2566,7 +2575,7 @@ function keepBlockedAliasesOfRemovedCompetitors(tx, projectId, removed, now) {
2566
2575
  byDomain.set(domain, uniqueByBrandKey([...byDomain.get(domain) ?? [], ...row.blockedAliases]));
2567
2576
  }
2568
2577
  for (const [domain, blockedAliases] of byDomain) {
2569
- const stored = tx.select({ id: marketCompetitorNames.id, blockedAliases: marketCompetitorNames.blockedAliases }).from(marketCompetitorNames).where(and4(eq5(marketCompetitorNames.projectId, projectId), eq5(marketCompetitorNames.domain, domain))).get();
2578
+ const stored = tx.select({ id: marketCompetitorNames.id, blockedAliases: marketCompetitorNames.blockedAliases }).from(marketCompetitorNames).where(and5(eq5(marketCompetitorNames.projectId, projectId), eq5(marketCompetitorNames.domain, domain))).get();
2570
2579
  if (stored) {
2571
2580
  if (!sameAliases(stored.blockedAliases, blockedAliases)) {
2572
2581
  tx.update(marketCompetitorNames).set({ blockedAliases, updatedAt: now }).where(eq5(marketCompetitorNames.id, stored.id)).run();
@@ -5543,7 +5552,7 @@ function assessConversionTrackingIntegrity(input) {
5543
5552
  }
5544
5553
 
5545
5554
  // ../api-routes/src/gsc-totals.ts
5546
- import { and as and5, asc as asc2, eq as eq7, sql, max, min } from "drizzle-orm";
5555
+ import { and as and6, asc as asc2, eq as eq7, sql, max, min } from "drizzle-orm";
5547
5556
  var WINDOW_DAYS = { "7d": 7, "30d": 30, "90d": 90 };
5548
5557
  function resolveGscWindowRange(window2, latestDataDate, today) {
5549
5558
  if (window2 === "all") {
@@ -5607,8 +5616,8 @@ function readEarliestGscDataDate(db, projectId) {
5607
5616
  return [property, dimensioned].filter((d) => d !== null).reduce((earliest, d) => earliest === null || d < earliest ? d : earliest, null);
5608
5617
  }
5609
5618
  function readEarliestGscQueryDataDate(db, projectId) {
5610
- const accurate = db.select({ earliest: min(gscQueryDailyTotals.date) }).from(gscQueryDailyTotals).where(and5(eq7(gscQueryDailyTotals.projectId, projectId), sql`${gscQueryDailyTotals.date} <> ''`)).get()?.earliest ?? null;
5611
- const dimensioned = db.select({ earliest: min(gscSearchData.date) }).from(gscSearchData).where(and5(eq7(gscSearchData.projectId, projectId), sql`${gscSearchData.date} <> ''`)).get()?.earliest ?? null;
5619
+ const accurate = db.select({ earliest: min(gscQueryDailyTotals.date) }).from(gscQueryDailyTotals).where(and6(eq7(gscQueryDailyTotals.projectId, projectId), sql`${gscQueryDailyTotals.date} <> ''`)).get()?.earliest ?? null;
5620
+ const dimensioned = db.select({ earliest: min(gscSearchData.date) }).from(gscSearchData).where(and6(eq7(gscSearchData.projectId, projectId), sql`${gscSearchData.date} <> ''`)).get()?.earliest ?? null;
5612
5621
  return [accurate, dimensioned].filter((d) => d !== null).reduce((earliest, d) => earliest === null || d < earliest ? d : earliest, null);
5613
5622
  }
5614
5623
  function readGscDailyTotals(db, projectId, startDate, endDate) {
@@ -5618,7 +5627,7 @@ function readGscDailyTotals(db, projectId, startDate, endDate) {
5618
5627
  impressions: gscDailyTotals.impressions,
5619
5628
  position: gscDailyTotals.position
5620
5629
  }).from(gscDailyTotals).where(
5621
- and5(
5630
+ and6(
5622
5631
  eq7(gscDailyTotals.projectId, projectId),
5623
5632
  sql`${gscDailyTotals.date} >= ${startDate}`,
5624
5633
  sql`${gscDailyTotals.date} <= ${endDate}`
@@ -5648,7 +5657,7 @@ function readGscQueryDailyRows(db, projectId, startDate, endDate) {
5648
5657
  impressions: gscQueryDailyTotals.impressions,
5649
5658
  position: gscQueryDailyTotals.position
5650
5659
  }).from(gscQueryDailyTotals).where(
5651
- and5(
5660
+ and6(
5652
5661
  eq7(gscQueryDailyTotals.projectId, projectId),
5653
5662
  sql`${gscQueryDailyTotals.date} >= ${startDate}`,
5654
5663
  sql`${gscQueryDailyTotals.date} <= ${endDate}`
@@ -5673,7 +5682,7 @@ function readGscQueryDailyFallbackRows(db, projectId, startDate, endDate) {
5673
5682
  impressions: sql`COALESCE(SUM(${gscSearchData.impressions}), 0)`,
5674
5683
  position: sql`COALESCE(SUM(CAST(${gscSearchData.position} AS REAL) * ${gscSearchData.impressions}) * 1.0 / NULLIF(SUM(${gscSearchData.impressions}), 0), 0)`
5675
5684
  }).from(gscSearchData).where(
5676
- and5(
5685
+ and6(
5677
5686
  eq7(gscSearchData.projectId, projectId),
5678
5687
  sql`${gscSearchData.date} >= ${startDate}`,
5679
5688
  sql`${gscSearchData.date} <= ${endDate}`,
@@ -6121,7 +6130,7 @@ function buildGbpSummary(input) {
6121
6130
 
6122
6131
  // ../api-routes/src/snapshot-competitor-refresh.ts
6123
6132
  import { setImmediate as yieldToEventLoop } from "timers/promises";
6124
- import { and as and6, asc as asc3, eq as eq9, inArray as inArray4 } from "drizzle-orm";
6133
+ import { and as and7, asc as asc3, eq as eq9, inArray as inArray4 } from "drizzle-orm";
6125
6134
 
6126
6135
  // ../api-routes/src/answer-identity.ts
6127
6136
  import crypto7 from "crypto";
@@ -6210,7 +6219,7 @@ function* projectAnswerMentionsSteps(db, projectId, opts, driver) {
6210
6219
  examined = 0;
6211
6220
  wouldUpdate = 0;
6212
6221
  mentioned = 0;
6213
- const runRows = db.select({ id: runs.id, planVersionId: runs.measurementPlanVersionId }).from(runs).where(and6(
6222
+ const runRows = db.select({ id: runs.id, planVersionId: runs.measurementPlanVersionId }).from(runs).where(and7(
6214
6223
  eq9(runs.kind, RunKinds["answer-visibility"]),
6215
6224
  eq9(runs.projectId, projectId),
6216
6225
  opts?.runId === void 0 ? void 0 : eq9(runs.id, opts.runId)
@@ -6752,17 +6761,6 @@ import { and as and8, desc as desc2, eq as eq12, like } from "drizzle-orm";
6752
6761
  // ../api-routes/src/helpers.ts
6753
6762
  import crypto9 from "crypto";
6754
6763
  import { eq as eq11, ne as ne3, sql as sql2 } from "drizzle-orm";
6755
-
6756
- // ../api-routes/src/run-scope.ts
6757
- import { and as and7, isNull } from "drizzle-orm";
6758
- function isScopedRun(run) {
6759
- return run.queries != null || run.measurementScope != null;
6760
- }
6761
- function notScopedRun() {
6762
- return and7(isNull(runs.queries), isNull(runs.measurementScope));
6763
- }
6764
-
6765
- // ../api-routes/src/helpers.ts
6766
6764
  function notProbeRun() {
6767
6765
  return ne3(runs.trigger, RunTriggers.probe);
6768
6766
  }
@@ -83172,6 +83170,8 @@ export {
83172
83170
  requireInstanceAdministrator,
83173
83171
  hashApiKey,
83174
83172
  MCP_DELEGATED_KEY_MAX_AGE_MS,
83173
+ isScopedRun,
83174
+ notScopedRun,
83175
83175
  notProbeRun,
83176
83176
  syncRunClaimKey,
83177
83177
  writeAuditLog,
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-IWQFTZ75.js";
12
12
  import {
13
13
  buildOpenApiDocument
14
- } from "./chunk-5LV4OEAO.js";
14
+ } from "./chunk-VK6SYZAH.js";
15
15
  import {
16
16
  DEFAULT_COMPETITOR_AUTO_ALIAS_MODE,
17
17
  MeasurementPortfolioLists,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  REGISTERED_CLI_COMMANDS
3
- } from "./chunk-QGQTURO7.js";
3
+ } from "./chunk-QC4MPO7E.js";
4
4
  import "./chunk-6GO5VVAC.js";
5
5
  import "./chunk-VJWDBFSL.js";
6
6
  import "./chunk-RLLYGXNA.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-QGQTURO7.js";
4
+ } from "./chunk-QC4MPO7E.js";
5
5
  import "./chunk-6GO5VVAC.js";
6
6
  import {
7
7
  buildSetupState,
8
8
  runPendingServeHandoff
9
- } from "./chunk-W54X45I7.js";
9
+ } from "./chunk-PM4GX6FP.js";
10
10
  import "./chunk-VJWDBFSL.js";
11
11
  import "./chunk-RLLYGXNA.js";
12
12
  import "./chunk-TSENU4GG.js";
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-IWQFTZ75.js";
8
8
  import {
9
9
  anyUsersExist
10
- } from "./chunk-5LV4OEAO.js";
10
+ } from "./chunk-VK6SYZAH.js";
11
11
  import "./chunk-3Q2D53KV.js";
12
12
  import "./chunk-TTQBEFSU.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-Y772E2L2.js");
43
+ const { createDemoServer } = await import("./demo-server-YOMJIFPD.js");
44
44
  const app = await createDemoServer({ trustProxy });
45
45
  let stopping = false;
46
46
  const stop = () => {
@@ -19,7 +19,7 @@ import "./chunk-IWQFTZ75.js";
19
19
  import {
20
20
  HISTORY_WINDOW_RUNS,
21
21
  IntelligenceService
22
- } from "./chunk-6DSEIN3U.js";
22
+ } from "./chunk-RDISN2CO.js";
23
23
  import {
24
24
  determineCitationState
25
25
  } from "./chunk-AOD35IKL.js";
@@ -27,7 +27,7 @@ import "./chunk-AHVF5OE5.js";
27
27
  import {
28
28
  apiRoutes,
29
29
  assessConversionTrackingIntegrity
30
- } from "./chunk-5LV4OEAO.js";
30
+ } from "./chunk-VK6SYZAH.js";
31
31
  import "./chunk-3Q2D53KV.js";
32
32
  import "./chunk-TTQBEFSU.js";
33
33
  import {
package/dist/index.js CHANGED
@@ -3,15 +3,15 @@ import {
3
3
  createGoogleMarketingCredentialStore,
4
4
  createGoogleMarketingRuntime,
5
5
  createServer
6
- } from "./chunk-RNUY27TO.js";
7
- import "./chunk-2VSOYLSX.js";
6
+ } from "./chunk-FYTSSBV7.js";
7
+ import "./chunk-6WG3PZUR.js";
8
8
  import "./chunk-OXYZQJLV.js";
9
9
  import "./chunk-XAJS5FH3.js";
10
- import "./chunk-TNR2O4HU.js";
10
+ import "./chunk-WLG476HL.js";
11
11
  import "./chunk-ELCLGWUT.js";
12
12
  import "./chunk-XEBKF4N5.js";
13
13
  import "./chunk-OO4RE44D.js";
14
- import "./chunk-FX4VCCSD.js";
14
+ import "./chunk-R2CBQPN6.js";
15
15
  import "./chunk-5KINLLTJ.js";
16
16
  import "./chunk-TSENU4GG.js";
17
17
  import "./chunk-6KH4XZLA.js";
@@ -30,10 +30,10 @@ import "./chunk-NQFBIMS4.js";
30
30
  import "./chunk-XTR3KSV2.js";
31
31
  import "./chunk-AOJU5LKX.js";
32
32
  import "./chunk-IWQFTZ75.js";
33
- import "./chunk-6DSEIN3U.js";
33
+ import "./chunk-RDISN2CO.js";
34
34
  import "./chunk-AOD35IKL.js";
35
35
  import "./chunk-AHVF5OE5.js";
36
- import "./chunk-5LV4OEAO.js";
36
+ import "./chunk-VK6SYZAH.js";
37
37
  import "./chunk-3Q2D53KV.js";
38
38
  import "./chunk-TTQBEFSU.js";
39
39
  import "./chunk-VCXKSGZF.js";
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  buildSetupState,
9
9
  queueServeHandoff
10
- } from "./chunk-W54X45I7.js";
10
+ } from "./chunk-PM4GX6FP.js";
11
11
  import "./chunk-VJWDBFSL.js";
12
12
  import "./chunk-5KINLLTJ.js";
13
13
  import "./chunk-6KH4XZLA.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  HISTORY_WINDOW_RUNS,
3
3
  IntelligenceService
4
- } from "./chunk-6DSEIN3U.js";
4
+ } from "./chunk-RDISN2CO.js";
5
5
  import "./chunk-AOD35IKL.js";
6
6
  import "./chunk-AHVF5OE5.js";
7
- import "./chunk-5LV4OEAO.js";
7
+ import "./chunk-VK6SYZAH.js";
8
8
  import "./chunk-3Q2D53KV.js";
9
9
  import "./chunk-TTQBEFSU.js";
10
10
  import "./chunk-VCXKSGZF.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  backfillAiReferralPaths,
3
3
  backfillNormalizedPaths
4
- } from "./chunk-2SF5JXCY.js";
4
+ } from "./chunk-FYL67YEU.js";
5
5
  import {
6
6
  operatorHttpUrl
7
7
  } from "./chunk-6GO5VVAC.js";
@@ -9,15 +9,15 @@ import {
9
9
  allowsKeylessFirstRunSetup,
10
10
  createServer,
11
11
  waitForServerRuntimeStartup
12
- } from "./chunk-RNUY27TO.js";
13
- import "./chunk-2VSOYLSX.js";
12
+ } from "./chunk-FYTSSBV7.js";
13
+ import "./chunk-6WG3PZUR.js";
14
14
  import "./chunk-OXYZQJLV.js";
15
15
  import "./chunk-XAJS5FH3.js";
16
- import "./chunk-TNR2O4HU.js";
16
+ import "./chunk-WLG476HL.js";
17
17
  import "./chunk-ELCLGWUT.js";
18
18
  import "./chunk-XEBKF4N5.js";
19
19
  import "./chunk-OO4RE44D.js";
20
- import "./chunk-FX4VCCSD.js";
20
+ import "./chunk-R2CBQPN6.js";
21
21
  import {
22
22
  trackFeatureCompleted
23
23
  } from "./chunk-5KINLLTJ.js";
@@ -59,13 +59,13 @@ import {
59
59
  CliError,
60
60
  isMachineFormat
61
61
  } from "./chunk-IWQFTZ75.js";
62
- import "./chunk-6DSEIN3U.js";
62
+ import "./chunk-RDISN2CO.js";
63
63
  import "./chunk-AOD35IKL.js";
64
64
  import "./chunk-AHVF5OE5.js";
65
65
  import {
66
66
  refreshSnapshotMentionIdentity,
67
67
  snapshotsWithSentimentResults
68
- } from "./chunk-5LV4OEAO.js";
68
+ } from "./chunk-VK6SYZAH.js";
69
69
  import "./chunk-3Q2D53KV.js";
70
70
  import "./chunk-TTQBEFSU.js";
71
71
  import {
@@ -9,8 +9,8 @@ import {
9
9
  resolveAeroModel,
10
10
  resolveConfiguredAgentProvider,
11
11
  resolveSessionProviderAndModel
12
- } from "./chunk-2VSOYLSX.js";
13
- import "./chunk-TNR2O4HU.js";
12
+ } from "./chunk-6WG3PZUR.js";
13
+ import "./chunk-WLG476HL.js";
14
14
  import {
15
15
  resolveAeroSkillDir
16
16
  } from "./chunk-QT475Y6O.js";
@@ -27,7 +27,7 @@ import "./chunk-XTR3KSV2.js";
27
27
  import "./chunk-AOJU5LKX.js";
28
28
  import "./chunk-IWQFTZ75.js";
29
29
  import "./chunk-AHVF5OE5.js";
30
- import "./chunk-5LV4OEAO.js";
30
+ import "./chunk-VK6SYZAH.js";
31
31
  import "./chunk-3Q2D53KV.js";
32
32
  import "./chunk-TTQBEFSU.js";
33
33
  import "./chunk-VCXKSGZF.js";
@@ -11,7 +11,7 @@ import {
11
11
  buildAllTools,
12
12
  buildReadTools,
13
13
  isAeroToolProfile
14
- } from "./chunk-TNR2O4HU.js";
14
+ } from "./chunk-WLG476HL.js";
15
15
  import "./chunk-2FNWSHOE.js";
16
16
  import "./chunk-GDRZPBPF.js";
17
17
  import "./chunk-ZDYWXTNN.js";
@@ -20,7 +20,7 @@ import "./chunk-NQFBIMS4.js";
20
20
  import "./chunk-XTR3KSV2.js";
21
21
  import "./chunk-AOJU5LKX.js";
22
22
  import "./chunk-IWQFTZ75.js";
23
- import "./chunk-5LV4OEAO.js";
23
+ import "./chunk-VK6SYZAH.js";
24
24
  import "./chunk-3Q2D53KV.js";
25
25
  import "./chunk-TTQBEFSU.js";
26
26
  import "./chunk-VCXKSGZF.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonry/canonry",
3
- "version": "7.120.1",
3
+ "version": "7.120.2",
4
4
  "type": "module",
5
5
  "description": "Self-hosted AI visibility (AEO) platform: track how ChatGPT, Claude, Gemini, and Perplexity cite your domain, join it with Search Console, GA4, server-side traffic, and paid media, and fix what you find through agent tools (CLI, REST, MCP). Local SQLite.",
6
6
  "keywords": [