@ainyc/canonry 4.46.1 → 4.47.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.
package/assets/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <link rel="icon" type="image/png" sizes="32x32" href="./favicon-32.png" />
13
13
  <link rel="apple-touch-icon" href="./apple-touch-icon.png" />
14
14
  <title>Canonry</title>
15
- <script type="module" crossorigin src="./assets/index-CJWNAoK4.js"></script>
15
+ <script type="module" crossorigin src="./assets/index-CPUAzk7n.js"></script>
16
16
  <link rel="stylesheet" crossorigin href="./assets/index-BDMNXVHa.css">
17
17
  </head>
18
18
  <body>
@@ -2701,6 +2701,48 @@ function formatDeltaCopy(d, suffix, windowLabel = "vs prior 7 days") {
2701
2701
  return `Flat ${windowLabel} (${formatNumber(d.prior)} ${suffix})`;
2702
2702
  }
2703
2703
 
2704
+ // ../contracts/src/ai-engines.ts
2705
+ var AI_ENGINE_DOMAINS = {
2706
+ /** OpenAI marketing/blog/API surface. */
2707
+ openai: "openai.com",
2708
+ /** ChatGPT consumer surface (separate from openai.com per OpenAI's domain split). */
2709
+ chatgpt: "chatgpt.com",
2710
+ /** Anthropic's Claude consumer surface. */
2711
+ claude: "claude.ai",
2712
+ /** Perplexity consumer + docs surface. */
2713
+ perplexity: "perplexity.ai",
2714
+ /** Google Gemini consumer surface. */
2715
+ gemini: "gemini.google.com",
2716
+ /** Google Bard (legacy alias for Gemini surface). */
2717
+ bard: "bard.google.com",
2718
+ /** Microsoft Copilot consumer surface. */
2719
+ copilotMicrosoft: "copilot.microsoft.com",
2720
+ /** Meta AI consumer surface. */
2721
+ metaAi: "meta.ai",
2722
+ /** xAI Grok. */
2723
+ grok: "grok.com",
2724
+ /** You.com. */
2725
+ you: "you.com",
2726
+ /** Phind. */
2727
+ phind: "phind.com"
2728
+ };
2729
+ var AI_ENGINE_SELF_DOMAINS = {
2730
+ chatgpt: [AI_ENGINE_DOMAINS.chatgpt, AI_ENGINE_DOMAINS.openai],
2731
+ claude: [AI_ENGINE_DOMAINS.claude],
2732
+ perplexity: [AI_ENGINE_DOMAINS.perplexity],
2733
+ gemini: [AI_ENGINE_DOMAINS.gemini, AI_ENGINE_DOMAINS.bard]
2734
+ };
2735
+ var ANTHROPIC_API_DOMAIN = "anthropic.com";
2736
+ var GOOGLE_APIS_DOMAIN = "googleapis.com";
2737
+ var VERTEX_AI_SEARCH_PROXY_DOMAIN = "vertexaisearch.cloud.google.com";
2738
+ var AI_PROVIDER_INFRA_DOMAINS = [
2739
+ AI_ENGINE_DOMAINS.openai,
2740
+ AI_ENGINE_DOMAINS.chatgpt,
2741
+ ANTHROPIC_API_DOMAIN,
2742
+ GOOGLE_APIS_DOMAIN,
2743
+ VERTEX_AI_SEARCH_PROXY_DOMAIN
2744
+ ];
2745
+
2704
2746
  export {
2705
2747
  __export,
2706
2748
  providerQuotaPolicySchema,
@@ -2830,5 +2872,9 @@ export {
2830
2872
  formatDateRange,
2831
2873
  deltaPercent,
2832
2874
  deltaTone,
2833
- formatDeltaCopy
2875
+ formatDeltaCopy,
2876
+ AI_ENGINE_DOMAINS,
2877
+ AI_ENGINE_SELF_DOMAINS,
2878
+ VERTEX_AI_SEARCH_PROXY_DOMAIN,
2879
+ AI_PROVIDER_INFRA_DOMAINS
2834
2880
  };
@@ -9,7 +9,7 @@ import {
9
9
  categoryLabel,
10
10
  determineAnswerMentioned,
11
11
  normalizeProjectDomain
12
- } from "./chunk-MM3A2CJK.js";
12
+ } from "./chunk-4WXY57ET.js";
13
13
 
14
14
  // src/intelligence-service.ts
15
15
  import { eq, desc, asc, and, or, inArray } from "drizzle-orm";
@@ -22,7 +22,7 @@ import {
22
22
  trafficConnectVercelRequestSchema,
23
23
  trafficConnectWordpressRequestSchema,
24
24
  trafficEventKindSchema
25
- } from "./chunk-MM3A2CJK.js";
25
+ } from "./chunk-4WXY57ET.js";
26
26
 
27
27
  // src/config.ts
28
28
  import fs from "fs";
@@ -1109,7 +1109,11 @@ function compactStringParams(values, keys) {
1109
1109
  for (const key of keys) {
1110
1110
  const value = values[key];
1111
1111
  if (value === void 0 || value === null || value === "") continue;
1112
- params[key] = String(value);
1112
+ if (typeof value === "string") {
1113
+ params[key] = value;
1114
+ } else if (typeof value === "number" || typeof value === "boolean") {
1115
+ params[key] = String(value);
1116
+ }
1113
1117
  }
1114
1118
  return Object.keys(params).length ? params : void 0;
1115
1119
  }
@@ -5,7 +5,7 @@ import {
5
5
  loadConfig,
6
6
  loadConfigRaw,
7
7
  saveConfigPatch
8
- } from "./chunk-PRNO52YC.js";
8
+ } from "./chunk-ON545FBK.js";
9
9
  import {
10
10
  DEFAULT_RUN_HISTORY_LIMIT,
11
11
  IntelligenceService,
@@ -80,10 +80,13 @@ import {
80
80
  smoothedRunDelta,
81
81
  trafficSources,
82
82
  usageCounters
83
- } from "./chunk-K2TOOQ4F.js";
83
+ } from "./chunk-M7MSNUNQ.js";
84
84
  import {
85
85
  AGENT_MEMORY_VALUE_MAX_BYTES,
86
86
  AGENT_PROVIDER_IDS,
87
+ AI_ENGINE_DOMAINS,
88
+ AI_ENGINE_SELF_DOMAINS,
89
+ AI_PROVIDER_INFRA_DOMAINS,
87
90
  AgentProviderIds,
88
91
  AppError,
89
92
  CcReleaseSyncStatuses,
@@ -110,6 +113,7 @@ import {
110
113
  TrafficSourceAuthModes,
111
114
  TrafficSourceStatuses,
112
115
  TrafficSourceTypes,
116
+ VERTEX_AI_SEARCH_PROXY_DOMAIN,
113
117
  VerificationStatuses,
114
118
  absolutizeProjectUrl,
115
119
  actionConfidenceLabel,
@@ -193,7 +197,7 @@ import {
193
197
  visibilityStateFromAnswerMentioned,
194
198
  windowCutoff,
195
199
  wordpressEnvSchema
196
- } from "./chunk-MM3A2CJK.js";
200
+ } from "./chunk-4WXY57ET.js";
197
201
 
198
202
  // src/telemetry.ts
199
203
  import crypto from "crypto";
@@ -2764,16 +2768,10 @@ async function analyticsRoutes(app) {
2764
2768
  return reply.send({ overall, byQuery, runId: latestRunId, window });
2765
2769
  });
2766
2770
  }
2767
- var PROVIDER_INFRA_DOMAINS = /* @__PURE__ */ new Set([
2768
- "vertexaisearch.cloud.google.com",
2769
- "openai.com",
2770
- "anthropic.com",
2771
- "googleapis.com"
2772
- ]);
2773
2771
  function isProviderInfraDomain(uri) {
2774
2772
  try {
2775
2773
  const host = new URL(uri).hostname.toLowerCase();
2776
- for (const blocked of PROVIDER_INFRA_DOMAINS) {
2774
+ for (const blocked of AI_PROVIDER_INFRA_DOMAINS) {
2777
2775
  if (host === blocked || host.endsWith(`.${blocked}`)) return true;
2778
2776
  }
2779
2777
  } catch {
@@ -11295,7 +11293,7 @@ function parseKindParam(raw) {
11295
11293
  if (raw === void 0 || raw === null || raw === "") return SchedulableRunKinds["answer-visibility"];
11296
11294
  const parsed = schedulableRunKindSchema.safeParse(raw);
11297
11295
  if (!parsed.success) {
11298
- throw validationError(`Invalid kind "${String(raw)}". Must be one of: ${Object.values(SchedulableRunKinds).join(", ")}`);
11296
+ throw validationError(`Invalid kind "${JSON.stringify(raw)}". Must be one of: ${Object.values(SchedulableRunKinds).join(", ")}`);
11299
11297
  }
11300
11298
  return parsed.data;
11301
11299
  }
@@ -11946,6 +11944,22 @@ var GA4_DEFAULT_SYNC_DAYS = 30;
11946
11944
  var GA4_MAX_SYNC_DAYS = 90;
11947
11945
  var GA4_REQUEST_TIMEOUT_MS = 3e4;
11948
11946
  var GA4_MAX_PAGES = 50;
11947
+ var GA4_DIMENSIONS = {
11948
+ date: "date",
11949
+ landingPagePlusQueryString: "landingPagePlusQueryString",
11950
+ sessionSource: "sessionSource",
11951
+ sessionMedium: "sessionMedium",
11952
+ sessionManualSource: "sessionManualSource",
11953
+ sessionManualMedium: "sessionManualMedium",
11954
+ firstUserSource: "firstUserSource",
11955
+ firstUserMedium: "firstUserMedium",
11956
+ sessionDefaultChannelGrouping: "sessionDefaultChannelGrouping",
11957
+ sessionDefaultChannelGroup: "sessionDefaultChannelGroup"
11958
+ };
11959
+ var GA4_METRICS = {
11960
+ sessions: "sessions",
11961
+ totalUsers: "totalUsers"
11962
+ };
11949
11963
 
11950
11964
  // ../integration-google-analytics/src/types.ts
11951
11965
  var GA4ApiError = class extends Error {
@@ -12137,8 +12151,8 @@ var AI_REFERRAL_SOURCE_FILTERS = [
12137
12151
  { matchType: "CONTAINS", value: "anthropic" },
12138
12152
  { matchType: "CONTAINS", value: "copilot" },
12139
12153
  { matchType: "CONTAINS", value: "phind" },
12140
- { matchType: "EXACT", value: "you.com" },
12141
- { matchType: "CONTAINS", value: "meta.ai" }
12154
+ { matchType: "EXACT", value: AI_ENGINE_DOMAINS.you },
12155
+ { matchType: "CONTAINS", value: AI_ENGINE_DOMAINS.metaAi }
12142
12156
  ];
12143
12157
  async function fetchTrafficByLandingPage(accessToken, propertyId, days) {
12144
12158
  validateAccessToken2(accessToken);
@@ -12157,12 +12171,12 @@ async function fetchTrafficByLandingPage(accessToken, propertyId, days) {
12157
12171
  const request = {
12158
12172
  dateRanges: [{ startDate: formatDate2(startDate), endDate: formatDate2(endDate) }],
12159
12173
  dimensions: [
12160
- { name: "date" },
12161
- { name: "landingPagePlusQueryString" }
12174
+ { name: GA4_DIMENSIONS.date },
12175
+ { name: GA4_DIMENSIONS.landingPagePlusQueryString }
12162
12176
  ],
12163
12177
  metrics: [
12164
- { name: "sessions" },
12165
- { name: "totalUsers" }
12178
+ { name: GA4_METRICS.sessions },
12179
+ { name: GA4_METRICS.totalUsers }
12166
12180
  ],
12167
12181
  limit: PAGE_SIZE,
12168
12182
  offset
@@ -12191,11 +12205,11 @@ async function fetchTrafficByLandingPage(accessToken, propertyId, days) {
12191
12205
  organicPageCount++;
12192
12206
  const organicRequest = {
12193
12207
  dateRanges: [{ startDate: formatDate2(startDate), endDate: formatDate2(endDate) }],
12194
- dimensions: [{ name: "date" }, { name: "landingPagePlusQueryString" }],
12195
- metrics: [{ name: "sessions" }],
12208
+ dimensions: [{ name: GA4_DIMENSIONS.date }, { name: GA4_DIMENSIONS.landingPagePlusQueryString }],
12209
+ metrics: [{ name: GA4_METRICS.sessions }],
12196
12210
  dimensionFilter: {
12197
12211
  filter: {
12198
- fieldName: "sessionDefaultChannelGrouping",
12212
+ fieldName: GA4_DIMENSIONS.sessionDefaultChannelGrouping,
12199
12213
  stringFilter: { matchType: "EXACT", value: "Organic Search" }
12200
12214
  }
12201
12215
  },
@@ -12219,11 +12233,11 @@ async function fetchTrafficByLandingPage(accessToken, propertyId, days) {
12219
12233
  directPageCount++;
12220
12234
  const directRequest = {
12221
12235
  dateRanges: [{ startDate: formatDate2(startDate), endDate: formatDate2(endDate) }],
12222
- dimensions: [{ name: "date" }, { name: "landingPagePlusQueryString" }],
12223
- metrics: [{ name: "sessions" }],
12236
+ dimensions: [{ name: GA4_DIMENSIONS.date }, { name: GA4_DIMENSIONS.landingPagePlusQueryString }],
12237
+ metrics: [{ name: GA4_METRICS.sessions }],
12224
12238
  dimensionFilter: {
12225
12239
  filter: {
12226
- fieldName: "sessionDefaultChannelGrouping",
12240
+ fieldName: GA4_DIMENSIONS.sessionDefaultChannelGrouping,
12227
12241
  stringFilter: { matchType: "EXACT", value: "Direct" }
12228
12242
  }
12229
12243
  },
@@ -12268,8 +12282,8 @@ async function verifyConnectionWithToken(accessToken, propertyId) {
12268
12282
  startDate.setDate(startDate.getDate() - 1);
12269
12283
  await runReport(accessToken, propertyId, {
12270
12284
  dateRanges: [{ startDate: formatDate2(startDate), endDate: formatDate2(endDate) }],
12271
- dimensions: [{ name: "date" }],
12272
- metrics: [{ name: "sessions" }],
12285
+ dimensions: [{ name: GA4_DIMENSIONS.date }],
12286
+ metrics: [{ name: GA4_METRICS.sessions }],
12273
12287
  limit: 1
12274
12288
  });
12275
12289
  return true;
@@ -12287,16 +12301,16 @@ async function fetchAggregateSummary(accessToken, propertyId, days) {
12287
12301
  {
12288
12302
  dateRanges: [dateRange],
12289
12303
  dimensions: [],
12290
- metrics: [{ name: "sessions" }, { name: "totalUsers" }],
12304
+ metrics: [{ name: GA4_METRICS.sessions }, { name: GA4_METRICS.totalUsers }],
12291
12305
  limit: 1
12292
12306
  },
12293
12307
  {
12294
12308
  dateRanges: [dateRange],
12295
12309
  dimensions: [],
12296
- metrics: [{ name: "sessions" }],
12310
+ metrics: [{ name: GA4_METRICS.sessions }],
12297
12311
  dimensionFilter: {
12298
12312
  filter: {
12299
- fieldName: "sessionDefaultChannelGrouping",
12313
+ fieldName: GA4_DIMENSIONS.sessionDefaultChannelGrouping,
12300
12314
  stringFilter: { matchType: "EXACT", value: "Organic Search" }
12301
12315
  }
12302
12316
  },
@@ -12332,16 +12346,16 @@ async function fetchWindowSummary(accessToken, propertyId, windowKey) {
12332
12346
  {
12333
12347
  dateRanges: [dateRange],
12334
12348
  dimensions: [],
12335
- metrics: [{ name: "sessions" }, { name: "totalUsers" }],
12349
+ metrics: [{ name: GA4_METRICS.sessions }, { name: GA4_METRICS.totalUsers }],
12336
12350
  limit: 1
12337
12351
  },
12338
12352
  {
12339
12353
  dateRanges: [dateRange],
12340
12354
  dimensions: [],
12341
- metrics: [{ name: "sessions" }],
12355
+ metrics: [{ name: GA4_METRICS.sessions }],
12342
12356
  dimensionFilter: {
12343
12357
  filter: {
12344
- fieldName: "sessionDefaultChannelGrouping",
12358
+ fieldName: GA4_DIMENSIONS.sessionDefaultChannelGrouping,
12345
12359
  stringFilter: { matchType: "EXACT", value: "Organic Search" }
12346
12360
  }
12347
12361
  },
@@ -12350,10 +12364,10 @@ async function fetchWindowSummary(accessToken, propertyId, windowKey) {
12350
12364
  {
12351
12365
  dateRanges: [dateRange],
12352
12366
  dimensions: [],
12353
- metrics: [{ name: "sessions" }],
12367
+ metrics: [{ name: GA4_METRICS.sessions }],
12354
12368
  dimensionFilter: {
12355
12369
  filter: {
12356
- fieldName: "sessionDefaultChannelGrouping",
12370
+ fieldName: GA4_DIMENSIONS.sessionDefaultChannelGrouping,
12357
12371
  stringFilter: { matchType: "EXACT", value: "Direct" }
12358
12372
  }
12359
12373
  },
@@ -12386,9 +12400,9 @@ async function fetchAiReferrals(accessToken, propertyId, days) {
12386
12400
  const PAGE_SIZE = 1e3;
12387
12401
  const rows = [];
12388
12402
  const dimensionPairs = [
12389
- ["sessionSource", "sessionMedium", "session"],
12390
- ["firstUserSource", "firstUserMedium", "first_user"],
12391
- ["sessionManualSource", "sessionManualMedium", "manual_utm"]
12403
+ [GA4_DIMENSIONS.sessionSource, GA4_DIMENSIONS.sessionMedium, "session"],
12404
+ [GA4_DIMENSIONS.firstUserSource, GA4_DIMENSIONS.firstUserMedium, "first_user"],
12405
+ [GA4_DIMENSIONS.sessionManualSource, GA4_DIMENSIONS.sessionManualMedium, "manual_utm"]
12392
12406
  ];
12393
12407
  for (const [sourceDim, mediumDim, dimLabel] of dimensionPairs) {
12394
12408
  let offset = 0;
@@ -12398,15 +12412,15 @@ async function fetchAiReferrals(accessToken, propertyId, days) {
12398
12412
  const request = {
12399
12413
  dateRanges: [{ startDate: formatDate2(startDate), endDate: formatDate2(endDate) }],
12400
12414
  dimensions: [
12401
- { name: "date" },
12415
+ { name: GA4_DIMENSIONS.date },
12402
12416
  { name: sourceDim },
12403
12417
  { name: mediumDim },
12404
- { name: "sessionDefaultChannelGroup" },
12405
- { name: "landingPagePlusQueryString" }
12418
+ { name: GA4_DIMENSIONS.sessionDefaultChannelGrouping },
12419
+ { name: GA4_DIMENSIONS.landingPagePlusQueryString }
12406
12420
  ],
12407
12421
  metrics: [
12408
- { name: "sessions" },
12409
- { name: "totalUsers" }
12422
+ { name: GA4_METRICS.sessions },
12423
+ { name: GA4_METRICS.totalUsers }
12410
12424
  ],
12411
12425
  dimensionFilter: {
12412
12426
  orGroup: {
@@ -12479,20 +12493,20 @@ async function fetchSocialReferrals(accessToken, propertyId, days) {
12479
12493
  const request = {
12480
12494
  dateRanges: [{ startDate: formatDate2(startDate), endDate: formatDate2(endDate) }],
12481
12495
  dimensions: [
12482
- { name: "date" },
12483
- { name: "sessionSource" },
12484
- { name: "sessionMedium" },
12485
- { name: "sessionDefaultChannelGroup" }
12496
+ { name: GA4_DIMENSIONS.date },
12497
+ { name: GA4_DIMENSIONS.sessionSource },
12498
+ { name: GA4_DIMENSIONS.sessionMedium },
12499
+ { name: GA4_DIMENSIONS.sessionDefaultChannelGroup }
12486
12500
  ],
12487
12501
  metrics: [
12488
- { name: "sessions" },
12489
- { name: "totalUsers" }
12502
+ { name: GA4_METRICS.sessions },
12503
+ { name: GA4_METRICS.totalUsers }
12490
12504
  ],
12491
12505
  dimensionFilter: {
12492
12506
  orGroup: {
12493
12507
  expressions: SOCIAL_CHANNEL_GROUPS.map((value) => ({
12494
12508
  filter: {
12495
- fieldName: "sessionDefaultChannelGroup",
12509
+ fieldName: GA4_DIMENSIONS.sessionDefaultChannelGroup,
12496
12510
  stringFilter: { matchType: "EXACT", value }
12497
12511
  }
12498
12512
  }))
@@ -12662,7 +12676,8 @@ async function googleRoutes(app, opts) {
12662
12676
  <li>Under "Authorized redirect URIs", add:<br><code style="background:#1e1e1e;color:#e0e0e0;padding:4px 8px;border-radius:4px;display:inline-block;margin-top:4px">${request.query.state ? (() => {
12663
12677
  try {
12664
12678
  const s = verifySignedState(request.query.state, stateSecret);
12665
- return escapeHtml2(String(s?.redirectUri ?? "Could not determine URI"));
12679
+ const uri = s?.redirectUri;
12680
+ return escapeHtml2(typeof uri === "string" ? uri : "Could not determine URI");
12666
12681
  } catch {
12667
12682
  return "Could not determine URI";
12668
12683
  }
@@ -15669,7 +15684,7 @@ async function deploySchema(connection, slug, schemas, env) {
15669
15684
  return {
15670
15685
  slug,
15671
15686
  status: "stripped",
15672
- schemasInjected: schemas.map((s) => String(s["@type"] ?? "Unknown")),
15687
+ schemasInjected: schemas.map((s) => typeof s["@type"] === "string" ? s["@type"] : "Unknown"),
15673
15688
  manualAssist: {
15674
15689
  manualRequired: true,
15675
15690
  targetUrl: page.link ?? `${site.siteUrl}/${slug}`,
@@ -15686,7 +15701,7 @@ async function deploySchema(connection, slug, schemas, env) {
15686
15701
  return {
15687
15702
  slug,
15688
15703
  status: "deployed",
15689
- schemasInjected: schemas.map((s) => String(s["@type"] ?? "Unknown"))
15704
+ schemasInjected: schemas.map((s) => typeof s["@type"] === "string" ? s["@type"] : "Unknown")
15690
15705
  };
15691
15706
  } catch (error) {
15692
15707
  if (error instanceof WordpressApiError && error.code === "NOT_FOUND") {
@@ -15746,7 +15761,7 @@ async function getSchemaStatus(connection, env) {
15746
15761
  while ((jsonMatch = jsonLdRegex.exec(match[1])) !== null) {
15747
15762
  try {
15748
15763
  const parsed = JSON.parse(jsonMatch[1].trim());
15749
- canonrySchemas.push(String(parsed["@type"] ?? "Unknown"));
15764
+ canonrySchemas.push(typeof parsed["@type"] === "string" ? parsed["@type"] : "Unknown");
15750
15765
  } catch {
15751
15766
  }
15752
15767
  }
@@ -16477,7 +16492,7 @@ async function wordpressRoutes(app, opts) {
16477
16492
  steps.push({ name: "google-submit", status: "completed", summary: `${succeeded}/${pageUrls.length} URLs submitted` });
16478
16493
  } else {
16479
16494
  const body = JSON.parse(googleRes.body);
16480
- const msg = body.message || body.error || `HTTP ${googleRes.statusCode}`;
16495
+ const msg = body.message ?? body.error ?? `HTTP ${googleRes.statusCode}`;
16481
16496
  if (googleRes.statusCode === 400 || googleRes.statusCode === 404) {
16482
16497
  steps.push({ name: "google-submit", status: "skipped", summary: msg });
16483
16498
  } else {
@@ -16502,7 +16517,7 @@ async function wordpressRoutes(app, opts) {
16502
16517
  steps.push({ name: "bing-submit", status: "completed", summary: `${succeeded}/${pageUrls.length} URLs submitted` });
16503
16518
  } else {
16504
16519
  const body = JSON.parse(bingRes.body);
16505
- const msg = body.message || body.error || `HTTP ${bingRes.statusCode}`;
16520
+ const msg = body.message ?? body.error ?? `HTTP ${bingRes.statusCode}`;
16506
16521
  if (bingRes.statusCode === 400 || bingRes.statusCode === 404) {
16507
16522
  steps.push({ name: "bing-submit", status: "skipped", summary: msg });
16508
16523
  } else {
@@ -17521,6 +17536,7 @@ async function listCloudRunTrafficEvents(accessToken, options) {
17521
17536
  }
17522
17537
 
17523
17538
  // ../integration-traffic/src/rules.ts
17539
+ var LEGACY_CHATGPT_DOMAIN = "chat.openai.com";
17524
17540
  var DEFAULT_AI_CRAWLER_RULES = [
17525
17541
  {
17526
17542
  id: "openai-gptbot",
@@ -17615,15 +17631,15 @@ var DEFAULT_AI_CRAWLER_RULES = [
17615
17631
  }
17616
17632
  ];
17617
17633
  var DEFAULT_AI_REFERRER_RULES = [
17618
- { domain: "chatgpt.com", operator: "OpenAI", product: "ChatGPT" },
17619
- { domain: "chat.openai.com", operator: "OpenAI", product: "ChatGPT" },
17620
- { domain: "perplexity.ai", operator: "Perplexity", product: "Perplexity" },
17621
- { domain: "claude.ai", operator: "Anthropic", product: "Claude" },
17622
- { domain: "gemini.google.com", operator: "Google", product: "Gemini" },
17623
- { domain: "copilot.microsoft.com", operator: "Microsoft", product: "Copilot" },
17624
- { domain: "phind.com", operator: "Phind", product: "Phind" },
17625
- { domain: "you.com", operator: "You.com", product: "You.com" },
17626
- { domain: "meta.ai", operator: "Meta", product: "Meta AI" }
17634
+ { domain: AI_ENGINE_DOMAINS.chatgpt, operator: "OpenAI", product: "ChatGPT" },
17635
+ { domain: LEGACY_CHATGPT_DOMAIN, operator: "OpenAI", product: "ChatGPT" },
17636
+ { domain: AI_ENGINE_DOMAINS.perplexity, operator: "Perplexity", product: "Perplexity" },
17637
+ { domain: AI_ENGINE_DOMAINS.claude, operator: "Anthropic", product: "Claude" },
17638
+ { domain: AI_ENGINE_DOMAINS.gemini, operator: "Google", product: "Gemini" },
17639
+ { domain: AI_ENGINE_DOMAINS.copilotMicrosoft, operator: "Microsoft", product: "Copilot" },
17640
+ { domain: AI_ENGINE_DOMAINS.phind, operator: "Phind", product: "Phind" },
17641
+ { domain: AI_ENGINE_DOMAINS.you, operator: "You.com", product: "You.com" },
17642
+ { domain: AI_ENGINE_DOMAINS.metaAi, operator: "Meta", product: "Meta AI" }
17627
17643
  ];
17628
17644
 
17629
17645
  // ../integration-traffic/src/classifier.ts
@@ -21560,10 +21576,10 @@ function extractDomainFromUri(uri) {
21560
21576
  try {
21561
21577
  const url = new URL(uri);
21562
21578
  const hostname = url.hostname.replace(/^www\./, "").toLowerCase();
21563
- if (hostname.includes("chatgpt.com") || hostname.includes("openai.com")) {
21579
+ if (AI_ENGINE_SELF_DOMAINS.chatgpt.some((self) => hostname.includes(self))) {
21564
21580
  return null;
21565
21581
  }
21566
- if (hostname === "vertexaisearch.cloud.google.com") {
21582
+ if (hostname === VERTEX_AI_SEARCH_PROXY_DOMAIN) {
21567
21583
  const redirectPath = url.pathname.replace(/^\/grounding-api-redirect\//, "");
21568
21584
  if (redirectPath && redirectPath !== url.pathname) {
21569
21585
  try {
@@ -21993,7 +22009,7 @@ function extractDomainFromUri2(uri) {
21993
22009
  try {
21994
22010
  const url = new URL(uri);
21995
22011
  const hostname = url.hostname.replace(/^www\./, "").toLowerCase();
21996
- if (hostname.includes("chatgpt.com") || hostname.includes("openai.com")) {
22012
+ if (AI_ENGINE_SELF_DOMAINS.chatgpt.some((self) => hostname.includes(self))) {
21997
22013
  return null;
21998
22014
  }
21999
22015
  return hostname;
@@ -22372,7 +22388,7 @@ function extractDomainFromUri3(uri) {
22372
22388
  try {
22373
22389
  const url = new URL(uri);
22374
22390
  const hostname = url.hostname.replace(/^www\./, "").toLowerCase();
22375
- if (hostname.includes("chatgpt.com") || hostname.includes("openai.com")) {
22391
+ if (AI_ENGINE_SELF_DOMAINS.chatgpt.some((self) => hostname.includes(self))) {
22376
22392
  return null;
22377
22393
  }
22378
22394
  return hostname;
@@ -22917,8 +22933,8 @@ async function waitForStabilization(client, selector, opts = {}) {
22917
22933
  // ../provider-cdp/src/targets/chatgpt.ts
22918
22934
  var chatgptTarget = {
22919
22935
  name: "chatgpt",
22920
- baseUrl: "https://chatgpt.com",
22921
- newConversationUrl: "https://chatgpt.com/?model=auto",
22936
+ baseUrl: `https://${AI_ENGINE_DOMAINS.chatgpt}`,
22937
+ newConversationUrl: `https://${AI_ENGINE_DOMAINS.chatgpt}/?model=auto`,
22922
22938
  responseSelector: '[data-testid="conversation-turn-3"], article:last-of-type, .agent-turn:last-of-type',
22923
22939
  async submitQuery(client, query) {
22924
22940
  const inputReady = await waitForElement(
@@ -23022,8 +23038,10 @@ var chatgptTarget = {
23022
23038
  },
23023
23039
  extractCitations(client) {
23024
23040
  return (async () => {
23041
+ const selfDomainsLiteral = JSON.stringify(AI_ENGINE_SELF_DOMAINS.chatgpt);
23025
23042
  const { result } = await client.Runtime.evaluate({
23026
23043
  expression: `(() => {
23044
+ const SELF_DOMAINS = ${selfDomainsLiteral};
23027
23045
  const sources = [];
23028
23046
  const seen = new Set();
23029
23047
  const turns = document.querySelectorAll('[data-message-author-role="assistant"]');
@@ -23047,7 +23065,7 @@ var chatgptTarget = {
23047
23065
  }
23048
23066
  }
23049
23067
 
23050
- if (!seen.has(href) && hostname !== 'chatgpt.com' && hostname !== 'openai.com') {
23068
+ if (!seen.has(href) && !SELF_DOMAINS.includes(hostname)) {
23051
23069
  seen.add(href);
23052
23070
  sources.push({
23053
23071
  uri: href,
@@ -23064,7 +23082,7 @@ var chatgptTarget = {
23064
23082
  if (href && !seen.has(href)) {
23065
23083
  let hostname = '';
23066
23084
  try { hostname = new URL(href).hostname.replace(/^www\\./, ''); } catch {}
23067
- if (hostname !== 'chatgpt.com' && hostname !== 'openai.com') {
23085
+ if (!SELF_DOMAINS.includes(hostname)) {
23068
23086
  seen.add(href);
23069
23087
  sources.push({ uri: href, title: title || hostname || href });
23070
23088
  }
@@ -23154,7 +23172,7 @@ function extractCitedDomains(groundingSources) {
23154
23172
  try {
23155
23173
  const url = new URL(source.uri);
23156
23174
  const domain = url.hostname.replace(/^www\./, "").toLowerCase();
23157
- if (!domain.includes("chatgpt.com") && !domain.includes("openai.com")) {
23175
+ if (!AI_ENGINE_SELF_DOMAINS.chatgpt.some((self) => domain.includes(self))) {
23158
23176
  domains.add(domain);
23159
23177
  }
23160
23178
  } catch {
@@ -23539,7 +23557,7 @@ function extractDomainFromUri4(uri) {
23539
23557
  try {
23540
23558
  const url = new URL(uri);
23541
23559
  const hostname = url.hostname.replace(/^www\./, "").toLowerCase();
23542
- if (hostname.includes("chatgpt.com") || hostname.includes("openai.com")) {
23560
+ if (AI_ENGINE_SELF_DOMAINS.chatgpt.some((self) => hostname.includes(self))) {
23543
23561
  return null;
23544
23562
  }
23545
23563
  return hostname;
@@ -26325,7 +26343,7 @@ function readStoredGroundingSources(rawResponse) {
26325
26343
  return result;
26326
26344
  }
26327
26345
  async function backfillInsightsCommand(project, opts) {
26328
- const { IntelligenceService: IntelligenceService2 } = await import("./intelligence-service-R3KDVKIB.js");
26346
+ const { IntelligenceService: IntelligenceService2 } = await import("./intelligence-service-ADZRFCGO.js");
26329
26347
  const config = loadConfig();
26330
26348
  const db = createClient(config.database);
26331
26349
  migrate(db);
@@ -26540,8 +26558,8 @@ var Scheduler = class {
26540
26558
  }
26541
26559
  }
26542
26560
  stopTask(key, task, verb) {
26543
- task.stop();
26544
- task.destroy();
26561
+ void task.stop();
26562
+ void task.destroy();
26545
26563
  log9.info(`task.${verb.toLowerCase()}`, { key });
26546
26564
  }
26547
26565
  registerCronTask(schedule) {