@canonry/canonry 4.129.0 → 4.130.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 (32) hide show
  1. package/README.md +1 -60
  2. package/assets/assets/{AuditHistoryPanel-DwJpVWme.js → AuditHistoryPanel-Ydzb2Y_Y.js} +1 -1
  3. package/assets/assets/BacklinksPage-DYodEusK.js +1 -0
  4. package/assets/assets/{ChartPrimitives-6oFKrJFk.js → ChartPrimitives-D67hsnF7.js} +1 -1
  5. package/assets/assets/{HistoryPage-DwOAoN1Z.js → HistoryPage-_h9ITL1w.js} +1 -1
  6. package/assets/assets/ProjectPage-fCJKCcHE.js +8 -0
  7. package/assets/assets/{RunRow-lt9IS99U.js → RunRow-DzUNyTE-.js} +1 -1
  8. package/assets/assets/{RunsPage-DitYcIdx.js → RunsPage-FTvAjptk.js} +1 -1
  9. package/assets/assets/{SettingsPage-CAOrh65Q.js → SettingsPage-CvgpYEAt.js} +1 -1
  10. package/assets/assets/{TrafficPage-BqzNvx75.js → TrafficPage-qaMW9k6o.js} +1 -1
  11. package/assets/assets/TrafficSourceDetailPage-CRCso7_A.js +1 -0
  12. package/assets/assets/{arrow-left-AmG4gtUR.js → arrow-left-C--lHdP2.js} +1 -1
  13. package/assets/assets/extract-error-message-DVqYbKpB.js +1 -0
  14. package/assets/assets/index-CdXn0JEf.js +210 -0
  15. package/assets/assets/{index-jymsMBpZ.css → index-JhX-wfQO.css} +1 -1
  16. package/assets/assets/trash-2-CyKRU3tR.js +1 -0
  17. package/assets/index.html +2 -2
  18. package/dist/{chunk-EF67Y6CI.js → chunk-5XU6WEMK.js} +728 -292
  19. package/dist/{chunk-BLSHHRRU.js → chunk-NVRJZU6V.js} +2758 -2613
  20. package/dist/{chunk-ZHWWSU7H.js → chunk-QR5U2K3O.js} +508 -355
  21. package/dist/{chunk-IHRW6WWV.js → chunk-WIALMCXM.js} +127 -6
  22. package/dist/cli.js +446 -184
  23. package/dist/index.js +4 -4
  24. package/dist/{intelligence-service-NTIKN7YG.js → intelligence-service-53GUE6EI.js} +2 -2
  25. package/dist/mcp.js +5 -5
  26. package/package.json +6 -6
  27. package/assets/assets/BacklinksPage-K8FQUBxI.js +0 -1
  28. package/assets/assets/ProjectPage-CdgFUk7h.js +0 -7
  29. package/assets/assets/TrafficSourceDetailPage-DXbygZUA.js +0 -1
  30. package/assets/assets/extract-error-message-DlVtjoPz.js +0 -1
  31. package/assets/assets/index-BiCDkOH4.js +0 -210
  32. package/assets/assets/trash-2-gFHWd1A1.js +0 -1
package/dist/cli.js CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  setTelemetrySource,
30
30
  showFirstRunNotice,
31
31
  trackEvent
32
- } from "./chunk-ZHWWSU7H.js";
32
+ } from "./chunk-QR5U2K3O.js";
33
33
  import {
34
34
  CliError,
35
35
  EXIT_SYSTEM_ERROR,
@@ -46,7 +46,7 @@ import {
46
46
  saveConfig,
47
47
  saveConfigPatch,
48
48
  usageError
49
- } from "./chunk-IHRW6WWV.js";
49
+ } from "./chunk-WIALMCXM.js";
50
50
  import {
51
51
  apiKeys,
52
52
  createClient,
@@ -54,7 +54,7 @@ import {
54
54
  projects,
55
55
  queries,
56
56
  renderReportHtml
57
- } from "./chunk-EF67Y6CI.js";
57
+ } from "./chunk-5XU6WEMK.js";
58
58
  import {
59
59
  AdsOperationKinds,
60
60
  AdsOperationStates,
@@ -66,8 +66,10 @@ import {
66
66
  CitationStates,
67
67
  READ_ONLY_SCOPE,
68
68
  REPORT_PERIOD_OPTIONS,
69
+ ResearchRunStatuses,
69
70
  RunStatuses,
70
71
  TrafficEventKinds,
72
+ TrafficSeriesGranularities,
71
73
  adsActivateTreeRequestSchema,
72
74
  adsActivationGrantCreateRequestSchema,
73
75
  adsAdCreateRequestSchema,
@@ -95,7 +97,7 @@ import {
95
97
  providerQuotaPolicySchema,
96
98
  resolveProviderInput,
97
99
  winnabilityClassSchema
98
- } from "./chunk-BLSHHRRU.js";
100
+ } from "./chunk-NVRJZU6V.js";
99
101
 
100
102
  // src/cli.ts
101
103
  import { pathToFileURL } from "url";
@@ -2573,6 +2575,254 @@ var DISCOVER_CLI_COMMANDS = [
2573
2575
  }
2574
2576
  ];
2575
2577
 
2578
+ // src/commands/research.ts
2579
+ var TERMINAL_RESEARCH_STATUSES = /* @__PURE__ */ new Set([
2580
+ ResearchRunStatuses.completed,
2581
+ ResearchRunStatuses.partial,
2582
+ ResearchRunStatuses.failed
2583
+ ]);
2584
+ var POLL_INTERVAL_MS3 = 2e3;
2585
+ var POLL_TIMEOUT_MS2 = 15 * 60 * 1e3;
2586
+ function getClient5() {
2587
+ return createApiClient();
2588
+ }
2589
+ async function researchRun(project, opts) {
2590
+ const client = getClient5();
2591
+ const request = {
2592
+ queries: opts.queries,
2593
+ provider: opts.provider,
2594
+ model: opts.model,
2595
+ location: opts.location,
2596
+ idempotencyKey: opts.idempotencyKey
2597
+ };
2598
+ const started = await client.startResearchRun(project, request);
2599
+ if (!opts.wait) {
2600
+ if (opts.format === "jsonl") {
2601
+ emitJsonl([{ project, ...started }]);
2602
+ return;
2603
+ }
2604
+ if (opts.format === "json") {
2605
+ console.log(JSON.stringify(started, null, 2));
2606
+ return;
2607
+ }
2608
+ printStarted(project, started);
2609
+ return;
2610
+ }
2611
+ const detail = await pollResearchRun(client, project, started.id, isMachineFormat(opts.format));
2612
+ printDetail(project, detail, opts.format);
2613
+ }
2614
+ async function researchList(project, opts) {
2615
+ const client = getClient5();
2616
+ const { runs } = await client.listResearchRuns(project, opts.limit === void 0 ? void 0 : { limit: opts.limit });
2617
+ if (opts.format === "json") {
2618
+ console.log(JSON.stringify({ runs }, null, 2));
2619
+ return;
2620
+ }
2621
+ if (opts.format === "jsonl") {
2622
+ emitJsonl(runs.map((run) => ({ project, ...run })));
2623
+ return;
2624
+ }
2625
+ if (runs.length === 0) {
2626
+ console.log(`No saved research runs for "${project}".`);
2627
+ return;
2628
+ }
2629
+ console.log(`Research history for "${project}" (${runs.length}):
2630
+ `);
2631
+ console.log(" ID STATUS QUERIES PROVIDER / MODEL CREATED");
2632
+ console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
2633
+ for (const run of runs) {
2634
+ const model = run.resolvedModel ? `${run.provider} / ${run.resolvedModel}` : run.provider;
2635
+ console.log(` ${run.id.padEnd(36)} ${run.status.padEnd(10)} ${String(run.totalQueries).padStart(7)} ${model.slice(0, 32).padEnd(32)} ${run.createdAt}`);
2636
+ }
2637
+ }
2638
+ async function researchShow(project, runId, opts) {
2639
+ const detail = await getClient5().getResearchRun(project, runId);
2640
+ printDetail(project, detail, opts.format);
2641
+ }
2642
+ async function pollResearchRun(client, project, runId, quiet) {
2643
+ if (!quiet) process.stderr.write(`Waiting for research run ${runId}`);
2644
+ const deadline = Date.now() + POLL_TIMEOUT_MS2;
2645
+ for (; ; ) {
2646
+ await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS3));
2647
+ if (Date.now() > deadline) {
2648
+ throw new CliError({
2649
+ code: "RESEARCH_TIMEOUT",
2650
+ message: `Timed out waiting for research run ${runId} after ${POLL_TIMEOUT_MS2 / 1e3}s`
2651
+ });
2652
+ }
2653
+ const detail = await client.getResearchRun(project, runId);
2654
+ if (!quiet) process.stderr.write(".");
2655
+ if (TERMINAL_RESEARCH_STATUSES.has(detail.status)) {
2656
+ if (!quiet) process.stderr.write("\n");
2657
+ return detail;
2658
+ }
2659
+ }
2660
+ }
2661
+ function printStarted(project, run) {
2662
+ console.log(`Research run saved: ${run.id}`);
2663
+ console.log(` Status: ${run.status}`);
2664
+ console.log(` Queries: ${run.totalQueries}`);
2665
+ console.log(` Provider: ${run.provider}${run.resolvedModel ? ` / ${run.resolvedModel}` : ""}`);
2666
+ console.log(` Inspect: canonry research show ${project} ${run.id}`);
2667
+ console.log(" Nothing was added to tracked queries.");
2668
+ }
2669
+ function printDetail(project, detail, format) {
2670
+ if (format === "json") {
2671
+ console.log(JSON.stringify(detail, null, 2));
2672
+ return;
2673
+ }
2674
+ if (format === "jsonl") {
2675
+ emitJsonl(detail.queries.map((query) => ({ project, runId: detail.id, ...query })));
2676
+ return;
2677
+ }
2678
+ console.log(`Research run: ${detail.id}`);
2679
+ console.log(` Status: ${detail.status}`);
2680
+ console.log(` Provider: ${detail.provider}${detail.resolvedModel ? ` / ${detail.resolvedModel}` : ""}`);
2681
+ if (detail.location) console.log(` Location: ${detail.location.label}`);
2682
+ console.log(` Results: ${detail.completedQueries} completed, ${detail.failedQueries} failed, ${detail.totalQueries} total`);
2683
+ if (detail.error) console.log(` Error: ${detail.error}`);
2684
+ console.log(" Nothing was added to tracked queries.");
2685
+ if (detail.queries.length === 0) return;
2686
+ console.log("\n QUERY STATUS CITED MENTIONED");
2687
+ for (const query of detail.queries) {
2688
+ const cited = query.citationState === CitationStates.cited ? "yes" : query.citationState ? "no" : "\u2013";
2689
+ const mentioned = query.answerMentioned === null ? "\u2013" : query.answerMentioned ? "yes" : "no";
2690
+ console.log(` ${query.query.slice(0, 58).padEnd(58)} ${query.status.padEnd(10)} ${cited.padEnd(5)} ${mentioned}`);
2691
+ if (query.error) console.log(` Error: ${query.error}`);
2692
+ if (query.answerText) console.log(` Answer: ${query.answerText}`);
2693
+ if (query.groundingSources.length > 0) {
2694
+ console.log(" Sources:");
2695
+ for (const source of query.groundingSources) {
2696
+ console.log(` - ${source.title ? `${source.title}: ` : ""}${source.uri}`);
2697
+ }
2698
+ }
2699
+ }
2700
+ }
2701
+
2702
+ // src/cli-commands/research.ts
2703
+ var RUN_USAGE = "canonry research run <project> <query...> [--query <text>] [--provider <name>] [--model <id>] [--location <label>|--no-location] [--idempotency-key <key>] [--wait] [--format json|jsonl]";
2704
+ function normalizeQueries(input, usage) {
2705
+ const positional = input.positionals.slice(1);
2706
+ const flagged = getStringArray(input.values, "query") ?? [];
2707
+ const seen = /* @__PURE__ */ new Set();
2708
+ const queries2 = [];
2709
+ for (const raw of [...positional, ...flagged]) {
2710
+ const query = raw.trim();
2711
+ const key = query.toLocaleLowerCase();
2712
+ if (query && !seen.has(key)) {
2713
+ seen.add(key);
2714
+ queries2.push(query);
2715
+ }
2716
+ }
2717
+ if (queries2.length === 0) {
2718
+ throw usageError(`Error: at least one research query is required
2719
+ Usage: ${usage}`, {
2720
+ message: "at least one research query is required",
2721
+ details: { command: "research.run", usage }
2722
+ });
2723
+ }
2724
+ if (queries2.length > 50) {
2725
+ throw usageError(`Error: at most 50 research queries are allowed
2726
+ Usage: ${usage}`, {
2727
+ message: "at most 50 research queries are allowed",
2728
+ details: { command: "research.run", usage, queryCount: queries2.length }
2729
+ });
2730
+ }
2731
+ return queries2;
2732
+ }
2733
+ function parseResearchLimit(input, usage) {
2734
+ const limit = parseIntegerOption(input, "limit", {
2735
+ command: "research.list",
2736
+ usage,
2737
+ message: "--limit must be an integer"
2738
+ });
2739
+ if (limit === void 0) return void 0;
2740
+ if (limit >= 1 && limit <= 100) return limit;
2741
+ throw usageError(`Error: --limit must be between 1 and 100
2742
+ Usage: ${usage}`, {
2743
+ message: "--limit must be between 1 and 100",
2744
+ details: { command: "research.list", usage, option: "limit", value: limit }
2745
+ });
2746
+ }
2747
+ async function resolveLocation(project, label, noLocation, usage) {
2748
+ if (label && noLocation) {
2749
+ throw usageError(`Error: --location and --no-location cannot be used together
2750
+ Usage: ${usage}`, {
2751
+ message: "--location and --no-location cannot be used together",
2752
+ details: { command: "research.run", usage }
2753
+ });
2754
+ }
2755
+ if (noLocation) return null;
2756
+ if (!label) return void 0;
2757
+ const configured = await createApiClient().getProject(project);
2758
+ const location = configured.locations.find((candidate) => candidate.label === label);
2759
+ if (location) return location;
2760
+ throw usageError(`Error: location "${label}" is not configured for project "${project}"
2761
+ Usage: ${usage}`, {
2762
+ message: `location "${label}" is not configured for project "${project}"`,
2763
+ details: { command: "research.run", usage, location: label, project }
2764
+ });
2765
+ }
2766
+ var RESEARCH_CLI_COMMANDS = [
2767
+ {
2768
+ path: ["research", "run"],
2769
+ usage: RUN_USAGE,
2770
+ options: {
2771
+ query: multiStringOption(),
2772
+ provider: stringOption(),
2773
+ model: stringOption(),
2774
+ location: stringOption(),
2775
+ "no-location": { type: "boolean", default: false },
2776
+ "idempotency-key": stringOption(),
2777
+ wait: { type: "boolean", default: false }
2778
+ },
2779
+ run: async (input) => {
2780
+ const project = requireProject(input, "research.run", RUN_USAGE);
2781
+ const provider = getString(input.values, "provider")?.trim() || void 0;
2782
+ const model = getString(input.values, "model")?.trim() || void 0;
2783
+ if (model && !provider) {
2784
+ throw usageError(`Error: --model requires --provider
2785
+ Usage: ${RUN_USAGE}`, {
2786
+ message: "--model requires --provider",
2787
+ details: { command: "research.run", usage: RUN_USAGE }
2788
+ });
2789
+ }
2790
+ await researchRun(project, {
2791
+ queries: normalizeQueries(input, RUN_USAGE),
2792
+ provider,
2793
+ model,
2794
+ location: await resolveLocation(project, getString(input.values, "location"), getBoolean(input.values, "no-location"), RUN_USAGE),
2795
+ idempotencyKey: getString(input.values, "idempotency-key")?.trim() || void 0,
2796
+ wait: getBoolean(input.values, "wait"),
2797
+ format: input.format
2798
+ });
2799
+ }
2800
+ },
2801
+ {
2802
+ path: ["research", "list"],
2803
+ usage: "canonry research list <project> [--limit <n>] [--format json|jsonl]",
2804
+ options: { limit: stringOption() },
2805
+ run: async (input) => {
2806
+ const usage = "canonry research list <project> [--limit <n>] [--format json|jsonl]";
2807
+ const project = requireProject(input, "research.list", usage);
2808
+ await researchList(project, {
2809
+ limit: parseResearchLimit(input, usage),
2810
+ format: input.format
2811
+ });
2812
+ }
2813
+ },
2814
+ {
2815
+ path: ["research", "show"],
2816
+ usage: "canonry research show <project> <run-id> [--format json|jsonl]",
2817
+ run: async (input) => {
2818
+ const usage = "canonry research show <project> <run-id> [--format json|jsonl]";
2819
+ const project = requireProject(input, "research.show", usage);
2820
+ const runId = requirePositional(input, 1, { command: "research.show", usage, message: "research run ID is required" });
2821
+ await researchShow(project, runId, { format: input.format });
2822
+ }
2823
+ }
2824
+ ];
2825
+
2576
2826
  // src/commands/doctor.ts
2577
2827
  async function doctorCommand(opts) {
2578
2828
  if (opts.all) {
@@ -2729,7 +2979,7 @@ var DOCTOR_CLI_COMMANDS = [
2729
2979
 
2730
2980
  // src/commands/ads.ts
2731
2981
  import fs3 from "fs";
2732
- function getClient5() {
2982
+ function getClient6() {
2733
2983
  return createApiClient();
2734
2984
  }
2735
2985
  function readRequest(inputPath, schema) {
@@ -2823,7 +3073,7 @@ async function adsConnect(project, opts) {
2823
3073
  details: { project }
2824
3074
  });
2825
3075
  }
2826
- const client = getClient5();
3076
+ const client = getClient6();
2827
3077
  const result = await client.adsConnect(project, { apiKey: opts.apiKey });
2828
3078
  if (isMachineFormat(opts.format)) {
2829
3079
  console.log(JSON.stringify(result, null, 2));
@@ -2834,7 +3084,7 @@ async function adsConnect(project, opts) {
2834
3084
  console.log("Schedule daily syncs with: canonry schedule set " + project + " --kind ads-sync --preset daily");
2835
3085
  }
2836
3086
  async function adsDisconnect(project, opts) {
2837
- const client = getClient5();
3087
+ const client = getClient6();
2838
3088
  const result = await client.adsDisconnect(project);
2839
3089
  if (isMachineFormat(opts?.format)) {
2840
3090
  console.log(JSON.stringify(result, null, 2));
@@ -2843,7 +3093,7 @@ async function adsDisconnect(project, opts) {
2843
3093
  console.log(result.disconnected ? `Disconnected the ads connection for ${project}.` : "No ads connection to remove.");
2844
3094
  }
2845
3095
  async function adsStatus(project, opts) {
2846
- const client = getClient5();
3096
+ const client = getClient6();
2847
3097
  const result = await client.getAdsStatus(project);
2848
3098
  if (isMachineFormat(opts?.format)) {
2849
3099
  console.log(JSON.stringify(result, null, 2));
@@ -2855,7 +3105,7 @@ async function adsStatus(project, opts) {
2855
3105
  }
2856
3106
  }
2857
3107
  async function adsAccount(project, opts) {
2858
- const result = await getClient5().getAdsAccount(project);
3108
+ const result = await getClient6().getAdsAccount(project);
2859
3109
  if (isMachineFormat(opts?.format)) {
2860
3110
  console.log(JSON.stringify(result, null, 2));
2861
3111
  return;
@@ -2884,7 +3134,7 @@ async function adsGeoSearch(project, opts) {
2884
3134
  });
2885
3135
  }
2886
3136
  const query = parsed.data;
2887
- const result = await getClient5().searchAdsGeo(project, query);
3137
+ const result = await getClient6().searchAdsGeo(project, query);
2888
3138
  if (opts.format === "jsonl") {
2889
3139
  emitJsonl(result.results.map((location) => ({ project, query: result.query, ...location })));
2890
3140
  return;
@@ -2903,7 +3153,7 @@ async function adsGeoSearch(project, opts) {
2903
3153
  }
2904
3154
  }
2905
3155
  async function adsConversionPixels(project, opts) {
2906
- const result = await getClient5().getAdsConversionPixels(project);
3156
+ const result = await getClient6().getAdsConversionPixels(project);
2907
3157
  if (opts?.format === "jsonl") {
2908
3158
  emitJsonl(result.pixels.map((pixel) => ({ project, ...pixel })));
2909
3159
  return;
@@ -2924,7 +3174,7 @@ async function adsConversionPixels(project, opts) {
2924
3174
  }
2925
3175
  }
2926
3176
  async function adsConversionEventSettings(project, opts) {
2927
- const result = await getClient5().getAdsConversionEventSettings(project);
3177
+ const result = await getClient6().getAdsConversionEventSettings(project);
2928
3178
  if (opts?.format === "jsonl") {
2929
3179
  emitJsonl(result.eventSettings.map((eventSetting) => ({ project, ...eventSetting })));
2930
3180
  return;
@@ -2949,7 +3199,7 @@ async function adsConversionEventSettings(project, opts) {
2949
3199
  }
2950
3200
  }
2951
3201
  async function adsOperationGet(project, opts) {
2952
- printOperation(await getClient5().getAdsOperation(project, opts.operationKey), opts.format);
3202
+ printOperation(await getClient6().getAdsOperation(project, opts.operationKey), opts.format);
2953
3203
  }
2954
3204
  async function adsOperationsUnresolved(project, opts) {
2955
3205
  const query = {
@@ -2957,7 +3207,7 @@ async function adsOperationsUnresolved(project, opts) {
2957
3207
  limit: opts?.limit,
2958
3208
  cursor: opts?.cursor
2959
3209
  };
2960
- const client = getClient5();
3210
+ const client = getClient6();
2961
3211
  const result = Object.values(query).some((value) => value !== void 0) ? await client.getUnresolvedAdsOperations(project, query) : await client.getUnresolvedAdsOperations(project);
2962
3212
  if (opts?.format === "jsonl") {
2963
3213
  emitJsonl(result.operations.map((operation) => ({ project, ...operation })));
@@ -2979,13 +3229,13 @@ async function adsOperationsUnresolved(project, opts) {
2979
3229
  }
2980
3230
  async function adsOperationReconcile(project, opts) {
2981
3231
  printReconciliation(
2982
- await getClient5().reconcileAdsOperation(project, opts.operationKey),
3232
+ await getClient6().reconcileAdsOperation(project, opts.operationKey),
2983
3233
  opts.format
2984
3234
  );
2985
3235
  }
2986
3236
  async function adsOperationResumeActivation(project, opts) {
2987
3237
  printActivation(
2988
- await getClient5().resumeAdsActivation(project, opts.operationKey),
3238
+ await getClient6().resumeAdsActivation(project, opts.operationKey),
2989
3239
  opts.format
2990
3240
  );
2991
3241
  }
@@ -2994,61 +3244,61 @@ async function adsActivationGrantCreate(project, opts) {
2994
3244
  opts.input,
2995
3245
  adsActivationGrantCreateRequestSchema
2996
3246
  );
2997
- printActivationGrant(await getClient5().createAdsActivationGrant(project, request), "Approved", opts.format);
3247
+ printActivationGrant(await getClient6().createAdsActivationGrant(project, request), "Approved", opts.format);
2998
3248
  }
2999
3249
  async function adsActivationGrantRevoke(project, grantId, opts) {
3000
3250
  printActivationGrant(
3001
- await getClient5().revokeAdsActivationGrant(project, grantId),
3251
+ await getClient6().revokeAdsActivationGrant(project, grantId),
3002
3252
  "Revoked",
3003
3253
  opts?.format
3004
3254
  );
3005
3255
  }
3006
3256
  async function adsImageUpload(project, opts) {
3007
3257
  const request = readRequest(opts.input, adsImageUploadRequestSchema);
3008
- printOperation(await getClient5().uploadAdsImage(project, request), opts.format);
3258
+ printOperation(await getClient6().uploadAdsImage(project, request), opts.format);
3009
3259
  }
3010
3260
  async function adsCampaignCreate(project, opts) {
3011
3261
  const request = readRequest(opts.input, adsCampaignCreateRequestSchema);
3012
- printOperation(await getClient5().createAdsCampaign(project, request), opts.format);
3262
+ printOperation(await getClient6().createAdsCampaign(project, request), opts.format);
3013
3263
  }
3014
3264
  async function adsCampaignUpdate(project, campaignId, opts) {
3015
3265
  const request = readRequest(opts.input, adsCampaignUpdateRequestSchema);
3016
- printOperation(await getClient5().updateAdsCampaign(project, campaignId, request), opts.format);
3266
+ printOperation(await getClient6().updateAdsCampaign(project, campaignId, request), opts.format);
3017
3267
  }
3018
3268
  async function adsCampaignPause(project, campaignId, opts) {
3019
3269
  const request = readRequest(opts.input, adsPauseRequestSchema);
3020
- printOperation(await getClient5().pauseAdsCampaign(project, campaignId, request), opts.format);
3270
+ printOperation(await getClient6().pauseAdsCampaign(project, campaignId, request), opts.format);
3021
3271
  }
3022
3272
  async function adsCampaignActivateTree(project, campaignId, opts) {
3023
3273
  const request = readRequest(opts.input, adsActivateTreeRequestSchema);
3024
- printActivation(await getClient5().activateAdsCampaignTree(project, campaignId, request), opts.format);
3274
+ printActivation(await getClient6().activateAdsCampaignTree(project, campaignId, request), opts.format);
3025
3275
  }
3026
3276
  async function adsAdGroupCreate(project, opts) {
3027
3277
  const request = readRequest(opts.input, adsAdGroupCreateRequestSchema);
3028
- printOperation(await getClient5().createAdsAdGroup(project, request), opts.format);
3278
+ printOperation(await getClient6().createAdsAdGroup(project, request), opts.format);
3029
3279
  }
3030
3280
  async function adsAdGroupUpdate(project, adGroupId, opts) {
3031
3281
  const request = readRequest(opts.input, adsAdGroupUpdateRequestSchema);
3032
- printOperation(await getClient5().updateAdsAdGroup(project, adGroupId, request), opts.format);
3282
+ printOperation(await getClient6().updateAdsAdGroup(project, adGroupId, request), opts.format);
3033
3283
  }
3034
3284
  async function adsAdGroupPause(project, adGroupId, opts) {
3035
3285
  const request = readRequest(opts.input, adsPauseRequestSchema);
3036
- printOperation(await getClient5().pauseAdsAdGroup(project, adGroupId, request), opts.format);
3286
+ printOperation(await getClient6().pauseAdsAdGroup(project, adGroupId, request), opts.format);
3037
3287
  }
3038
3288
  async function adsAdCreate(project, opts) {
3039
3289
  const request = readRequest(opts.input, adsAdCreateRequestSchema);
3040
- printOperation(await getClient5().createAdsAd(project, request), opts.format);
3290
+ printOperation(await getClient6().createAdsAd(project, request), opts.format);
3041
3291
  }
3042
3292
  async function adsAdUpdate(project, adId, opts) {
3043
3293
  const request = readRequest(opts.input, adsAdUpdateRequestSchema);
3044
- printOperation(await getClient5().updateAdsAd(project, adId, request), opts.format);
3294
+ printOperation(await getClient6().updateAdsAd(project, adId, request), opts.format);
3045
3295
  }
3046
3296
  async function adsAdPause(project, adId, opts) {
3047
3297
  const request = readRequest(opts.input, adsPauseRequestSchema);
3048
- printOperation(await getClient5().pauseAdsAd(project, adId, request), opts.format);
3298
+ printOperation(await getClient6().pauseAdsAd(project, adId, request), opts.format);
3049
3299
  }
3050
3300
  async function adsSync(project, opts) {
3051
- const client = getClient5();
3301
+ const client = getClient6();
3052
3302
  const result = await client.triggerAdsSync(project);
3053
3303
  if (isMachineFormat(opts?.format)) {
3054
3304
  console.log(JSON.stringify(result, null, 2));
@@ -3057,7 +3307,7 @@ async function adsSync(project, opts) {
3057
3307
  console.log(`Ads sync queued (run ${result.runId}). Check progress with: canonry runs get ${result.runId}`);
3058
3308
  }
3059
3309
  async function adsCampaigns(project, opts) {
3060
- const client = getClient5();
3310
+ const client = getClient6();
3061
3311
  const result = await client.getAdsCampaigns(project);
3062
3312
  if (opts?.format === "jsonl") {
3063
3313
  emitJsonl(result.campaigns.map((campaign) => ({ project, ...campaign })));
@@ -3084,7 +3334,7 @@ async function adsCampaigns(project, opts) {
3084
3334
  }
3085
3335
  }
3086
3336
  async function adsInsights(project, opts) {
3087
- const client = getClient5();
3337
+ const client = getClient6();
3088
3338
  const result = await client.getAdsInsights(project, {
3089
3339
  level: opts?.level,
3090
3340
  entityId: opts?.entity,
@@ -3113,7 +3363,7 @@ async function adsInsights(project, opts) {
3113
3363
  }
3114
3364
  }
3115
3365
  async function adsSummary(project, opts) {
3116
- const client = getClient5();
3366
+ const client = getClient6();
3117
3367
  const result = await client.getAdsSummary(project);
3118
3368
  if (isMachineFormat(opts?.format)) {
3119
3369
  console.log(JSON.stringify(result, null, 2));
@@ -3490,7 +3740,7 @@ Usage: ${usage}`, {
3490
3740
  ];
3491
3741
 
3492
3742
  // src/commands/ga.ts
3493
- function getClient6() {
3743
+ function getClient7() {
3494
3744
  return createApiClient();
3495
3745
  }
3496
3746
  async function gaConnect(project, opts) {
@@ -3523,7 +3773,7 @@ async function gaConnect(project, opts) {
3523
3773
  } else if (opts.keyJson) {
3524
3774
  body.keyJson = opts.keyJson;
3525
3775
  }
3526
- const client = getClient6();
3776
+ const client = getClient7();
3527
3777
  const result = await client.gaConnect(project, body);
3528
3778
  if (isMachineFormat(opts.format)) {
3529
3779
  console.log(JSON.stringify(result, null, 2));
@@ -3538,7 +3788,7 @@ async function gaConnect(project, opts) {
3538
3788
  }
3539
3789
  }
3540
3790
  async function gaDisconnect(project, format) {
3541
- const client = getClient6();
3791
+ const client = getClient7();
3542
3792
  await client.gaDisconnect(project);
3543
3793
  if (isMachineFormat(format)) {
3544
3794
  console.log(JSON.stringify({ project, disconnected: true }, null, 2));
@@ -3547,7 +3797,7 @@ async function gaDisconnect(project, format) {
3547
3797
  console.log(`GA4 disconnected from project "${project}".`);
3548
3798
  }
3549
3799
  async function gaStatus(project, format) {
3550
- const client = getClient6();
3800
+ const client = getClient7();
3551
3801
  const result = await client.gaStatus(project);
3552
3802
  if (isMachineFormat(format)) {
3553
3803
  console.log(JSON.stringify(result, null, 2));
@@ -3573,7 +3823,7 @@ async function gaStatus(project, format) {
3573
3823
  console.log(` Connected: ${result.createdAt ?? "unknown"}`);
3574
3824
  }
3575
3825
  async function gaSync(project, opts) {
3576
- const client = getClient6();
3826
+ const client = getClient7();
3577
3827
  const body = {};
3578
3828
  if (opts?.days) body.days = opts.days;
3579
3829
  if (opts?.only) body.only = opts.only;
@@ -3593,7 +3843,7 @@ async function gaSync(project, opts) {
3593
3843
  console.log(` Synced at: ${result.syncedAt}`);
3594
3844
  }
3595
3845
  async function gaTraffic(project, opts) {
3596
- const client = getClient6();
3846
+ const client = getClient7();
3597
3847
  const params = {};
3598
3848
  if (opts?.limit) params.limit = String(opts.limit);
3599
3849
  if (opts?.window) params.window = opts.window;
@@ -3688,7 +3938,7 @@ async function gaTraffic(project, opts) {
3688
3938
  }
3689
3939
  }
3690
3940
  async function gaAiReferralHistory(project, opts) {
3691
- const client = getClient6();
3941
+ const client = getClient7();
3692
3942
  const result = await client.gaAiReferralHistory(project, opts?.window ? { window: opts.window } : void 0);
3693
3943
  if (opts?.format === "json") {
3694
3944
  console.log(JSON.stringify(result, null, 2));
@@ -3716,7 +3966,7 @@ async function gaAiReferralHistory(project, opts) {
3716
3966
  }
3717
3967
  }
3718
3968
  async function gaSocialReferralHistory(project, opts) {
3719
- const client = getClient6();
3969
+ const client = getClient7();
3720
3970
  const result = await client.gaSocialReferralHistory(project, opts?.window ? { window: opts.window } : void 0);
3721
3971
  if (opts?.format === "json") {
3722
3972
  console.log(JSON.stringify(result, null, 2));
@@ -3744,7 +3994,7 @@ async function gaSocialReferralHistory(project, opts) {
3744
3994
  }
3745
3995
  }
3746
3996
  async function gaSessionHistory(project, opts) {
3747
- const client = getClient6();
3997
+ const client = getClient7();
3748
3998
  const result = await client.gaSessionHistory(project, opts?.window ? { window: opts.window } : void 0);
3749
3999
  if (opts?.format === "json") {
3750
4000
  console.log(JSON.stringify(result, null, 2));
@@ -3775,7 +4025,7 @@ async function gaSessionHistory(project, opts) {
3775
4025
  }
3776
4026
  }
3777
4027
  async function gaCoverage(project, format) {
3778
- const client = getClient6();
4028
+ const client = getClient7();
3779
4029
  const result = await client.gaCoverage(project);
3780
4030
  if (format === "json") {
3781
4031
  console.log(JSON.stringify(result, null, 2));
@@ -3801,7 +4051,7 @@ async function gaCoverage(project, format) {
3801
4051
  }
3802
4052
  }
3803
4053
  async function gaSocialReferralSummary(project, opts) {
3804
- const client = getClient6();
4054
+ const client = getClient7();
3805
4055
  const traffic = await client.gaTraffic(project);
3806
4056
  if (opts?.trend) {
3807
4057
  const trend = await client.gaSocialReferralTrend(project);
@@ -3862,7 +4112,7 @@ async function gaSocialReferralSummary(project, opts) {
3862
4112
  }
3863
4113
  }
3864
4114
  async function gaAttribution(project, opts) {
3865
- const client = getClient6();
4115
+ const client = getClient7();
3866
4116
  const traffic = await client.gaTraffic(project);
3867
4117
  const fmtTrend = (pct4) => pct4 === null ? "n/a" : `${pct4 >= 0 ? "+" : ""}${pct4}%`;
3868
4118
  if (opts?.trend) {
@@ -4228,7 +4478,7 @@ var GA_CLI_COMMANDS = [
4228
4478
  ];
4229
4479
 
4230
4480
  // src/commands/gbp.ts
4231
- function getClient7() {
4481
+ function getClient8() {
4232
4482
  return createApiClient();
4233
4483
  }
4234
4484
  function formatLocationsTable(response) {
@@ -4246,7 +4496,7 @@ function formatLocationsTable(response) {
4246
4496
  return lines.join("\n");
4247
4497
  }
4248
4498
  async function gbpConnect(project, opts) {
4249
- const client = getClient7();
4499
+ const client = getClient8();
4250
4500
  const { authUrl, redirectUri } = await client.googleConnect(project, {
4251
4501
  type: "gbp",
4252
4502
  publicUrl: opts.publicUrl
@@ -4265,7 +4515,7 @@ async function gbpConnect(project, opts) {
4265
4515
  console.log("After authorizing, run `canonry gbp locations discover <project>` to fetch your locations.");
4266
4516
  }
4267
4517
  async function gbpDisconnect(project, opts) {
4268
- const client = getClient7();
4518
+ const client = getClient8();
4269
4519
  await client.disconnectGbp(project);
4270
4520
  if (isMachineFormat(opts.format)) {
4271
4521
  console.log(JSON.stringify({ project, disconnected: true }, null, 2));
@@ -4274,7 +4524,7 @@ async function gbpDisconnect(project, opts) {
4274
4524
  console.log(`Disconnected GBP from project "${project}" and removed all discovered locations.`);
4275
4525
  }
4276
4526
  async function gbpLocationsList(project, opts) {
4277
- const client = getClient7();
4527
+ const client = getClient8();
4278
4528
  const response = await client.listGbpLocations(
4279
4529
  project,
4280
4530
  opts.selectedOnly ? { selected: true } : void 0
@@ -4286,7 +4536,7 @@ async function gbpLocationsList(project, opts) {
4286
4536
  console.log(formatLocationsTable(response));
4287
4537
  }
4288
4538
  async function gbpAccounts(project, opts) {
4289
- const client = getClient7();
4539
+ const client = getClient8();
4290
4540
  const response = await client.listGbpAccounts(project);
4291
4541
  if (isMachineFormat(opts.format)) {
4292
4542
  console.log(JSON.stringify(response, null, 2));
@@ -4311,7 +4561,7 @@ function formatAccountsTable(response) {
4311
4561
  return lines.join("\n");
4312
4562
  }
4313
4563
  async function gbpLocationsDiscover(project, opts) {
4314
- const client = getClient7();
4564
+ const client = getClient8();
4315
4565
  const hasBody = opts.selectAllNew !== void 0 || opts.account !== void 0 || opts.switchAccount;
4316
4566
  const body = hasBody ? {
4317
4567
  ...opts.selectAllNew === void 0 ? {} : { selectAllNew: opts.selectAllNew },
@@ -4328,7 +4578,7 @@ Discovered ${response.totalDiscovered} location(s); ${response.totalSelected} se
4328
4578
  console.log(formatLocationsTable(response));
4329
4579
  }
4330
4580
  async function gbpLocationSelect(project, opts) {
4331
- const client = getClient7();
4581
+ const client = getClient8();
4332
4582
  const updated = await client.setGbpLocationSelection(project, opts.location, true);
4333
4583
  if (isMachineFormat(opts.format)) {
4334
4584
  console.log(JSON.stringify(updated, null, 2));
@@ -4337,7 +4587,7 @@ async function gbpLocationSelect(project, opts) {
4337
4587
  console.log(`Selected ${opts.location} ("${updated.displayName}") for sync.`);
4338
4588
  }
4339
4589
  async function gbpLocationDeselect(project, opts) {
4340
- const client = getClient7();
4590
+ const client = getClient8();
4341
4591
  const updated = await client.setGbpLocationSelection(project, opts.location, false);
4342
4592
  if (isMachineFormat(opts.format)) {
4343
4593
  console.log(JSON.stringify(updated, null, 2));
@@ -4346,7 +4596,7 @@ async function gbpLocationDeselect(project, opts) {
4346
4596
  console.log(`Deselected ${opts.location} ("${updated.displayName}"). Future syncs will skip this location.`);
4347
4597
  }
4348
4598
  async function gbpSync(project, opts) {
4349
- const client = getClient7();
4599
+ const client = getClient8();
4350
4600
  const { runId, status } = await client.triggerGbpSync(project, {
4351
4601
  locationNames: opts.location ? [opts.location] : void 0,
4352
4602
  daysOfMetrics: opts.days,
@@ -4382,7 +4632,7 @@ async function gbpSync(project, opts) {
4382
4632
  console.log(`GBP sync ${final} (run ${runId}).`);
4383
4633
  }
4384
4634
  async function gbpMetrics(project, opts) {
4385
- const client = getClient7();
4635
+ const client = getClient8();
4386
4636
  const response = await client.listGbpMetrics(project, { locationName: opts.location, metric: opts.metric });
4387
4637
  if (isMachineFormat(opts.format)) {
4388
4638
  console.log(JSON.stringify(response, null, 2));
@@ -4400,7 +4650,7 @@ async function gbpMetrics(project, opts) {
4400
4650
  }
4401
4651
  }
4402
4652
  async function gbpKeywords(project, opts) {
4403
- const client = getClient7();
4653
+ const client = getClient8();
4404
4654
  const response = await client.listGbpKeywords(project, { locationName: opts.location });
4405
4655
  if (isMachineFormat(opts.format)) {
4406
4656
  console.log(JSON.stringify(response, null, 2));
@@ -4417,7 +4667,7 @@ async function gbpKeywords(project, opts) {
4417
4667
  }
4418
4668
  }
4419
4669
  async function gbpPlaceActions(project, opts) {
4420
- const client = getClient7();
4670
+ const client = getClient8();
4421
4671
  const response = await client.listGbpPlaceActions(project, { locationName: opts.location });
4422
4672
  if (isMachineFormat(opts.format)) {
4423
4673
  console.log(JSON.stringify(response, null, 2));
@@ -4434,7 +4684,7 @@ async function gbpPlaceActions(project, opts) {
4434
4684
  }
4435
4685
  }
4436
4686
  async function gbpLodging(project, opts) {
4437
- const client = getClient7();
4687
+ const client = getClient8();
4438
4688
  const response = await client.listGbpLodging(project, { locationName: opts.location });
4439
4689
  if (isMachineFormat(opts.format)) {
4440
4690
  console.log(JSON.stringify(response, null, 2));
@@ -4451,7 +4701,7 @@ async function gbpLodging(project, opts) {
4451
4701
  }
4452
4702
  }
4453
4703
  async function gbpAttributes(project, opts) {
4454
- const client = getClient7();
4704
+ const client = getClient8();
4455
4705
  const response = await client.listGbpAttributes(project, { locationName: opts.location });
4456
4706
  if (isMachineFormat(opts.format)) {
4457
4707
  console.log(JSON.stringify(response, null, 2));
@@ -4476,7 +4726,7 @@ async function gbpAttributes(project, opts) {
4476
4726
  }
4477
4727
  }
4478
4728
  async function gbpPlaces(project, opts) {
4479
- const client = getClient7();
4729
+ const client = getClient8();
4480
4730
  const response = await client.listGbpPlaces(project, { locationName: opts.location });
4481
4731
  if (isMachineFormat(opts.format)) {
4482
4732
  console.log(JSON.stringify(response, null, 2));
@@ -4497,7 +4747,7 @@ function fmtDelta(pct4) {
4497
4747
  return `${pct4 >= 0 ? "+" : ""}${pct4}%`;
4498
4748
  }
4499
4749
  async function gbpSummary(project, opts) {
4500
- const client = getClient7();
4750
+ const client = getClient8();
4501
4751
  const s = await client.getGbpSummary(project, { locationName: opts.location });
4502
4752
  if (isMachineFormat(opts.format)) {
4503
4753
  console.log(JSON.stringify(s, null, 2));
@@ -4828,7 +5078,7 @@ var GET_CLI_COMMANDS = [
4828
5078
  ];
4829
5079
 
4830
5080
  // src/commands/traffic.ts
4831
- function getClient8() {
5081
+ function getClient9() {
4832
5082
  return createApiClient();
4833
5083
  }
4834
5084
  function configString(value, fallback = "(unset)") {
@@ -4882,7 +5132,7 @@ async function trafficConnectWordpress(project, opts) {
4882
5132
  details: { project }
4883
5133
  });
4884
5134
  }
4885
- const client = getClient8();
5135
+ const client = getClient9();
4886
5136
  const result = await client.trafficConnectWordpress(project, {
4887
5137
  baseUrl: opts.url,
4888
5138
  username: opts.username,
@@ -4933,7 +5183,7 @@ async function trafficConnectCloudRun(project, opts) {
4933
5183
  details: { project, keyFile: opts.serviceAccountKey }
4934
5184
  });
4935
5185
  }
4936
- const client = getClient8();
5186
+ const client = getClient9();
4937
5187
  const result = await client.trafficConnectCloudRun(project, {
4938
5188
  gcpProjectId: opts.gcpProject,
4939
5189
  serviceName: opts.service,
@@ -5011,7 +5261,7 @@ async function trafficConnectVercel(project, opts) {
5011
5261
  details: { project, environment: opts.environment }
5012
5262
  });
5013
5263
  }
5014
- const client = getClient8();
5264
+ const client = getClient9();
5015
5265
  const result = await client.trafficConnectVercel(project, {
5016
5266
  projectId: opts.projectId,
5017
5267
  teamId: opts.teamId,
@@ -5042,7 +5292,7 @@ async function trafficBackfill(project, opts) {
5042
5292
  details: { project }
5043
5293
  });
5044
5294
  }
5045
- const client = getClient8();
5295
+ const client = getClient9();
5046
5296
  const submitted = await client.trafficBackfill(project, opts.source, {
5047
5297
  days: opts.days
5048
5298
  });
@@ -5111,7 +5361,7 @@ async function trafficSync(project, opts) {
5111
5361
  details: { project }
5112
5362
  });
5113
5363
  }
5114
- const client = getClient8();
5364
+ const client = getClient9();
5115
5365
  const result = await client.trafficSync(project, opts.source, {
5116
5366
  sinceMinutes: opts.sinceMinutes
5117
5367
  });
@@ -5149,7 +5399,7 @@ async function trafficReset(project, opts) {
5149
5399
  details: { project, source: opts.source }
5150
5400
  });
5151
5401
  }
5152
- const client = getClient8();
5402
+ const client = getClient9();
5153
5403
  const updated = await client.trafficReset(project, opts.source);
5154
5404
  if (isMachineFormat(opts.format)) {
5155
5405
  console.log(JSON.stringify(updated, null, 2));
@@ -5276,10 +5526,19 @@ async function trafficEvents(project, opts) {
5276
5526
  details: { project, kind: opts.kind }
5277
5527
  });
5278
5528
  }
5529
+ if (opts.granularity && opts.granularity !== TrafficSeriesGranularities.hour && opts.granularity !== TrafficSeriesGranularities.day) {
5530
+ throw new CliError({
5531
+ code: "TRAFFIC_INVALID_GRANULARITY",
5532
+ message: `--granularity must be one of: ${TrafficSeriesGranularities.hour}, ${TrafficSeriesGranularities.day}`,
5533
+ displayMessage: `Error: --granularity must be "${TrafficSeriesGranularities.hour}" or "${TrafficSeriesGranularities.day}"`,
5534
+ details: { project, granularity: opts.granularity }
5535
+ });
5536
+ }
5279
5537
  const params = {};
5280
5538
  if (opts.kind && opts.kind !== "all") params.kind = opts.kind;
5281
5539
  if (opts.source) params.sourceId = opts.source;
5282
5540
  if (opts.limit !== void 0) params.limit = opts.limit;
5541
+ if (opts.granularity) params.granularity = opts.granularity;
5283
5542
  if (opts.sinceMinutes !== void 0) {
5284
5543
  const since = new Date(Date.now() - opts.sinceMinutes * 6e4).toISOString();
5285
5544
  params.since = since;
@@ -5531,14 +5790,15 @@ var TRAFFIC_CLI_COMMANDS = [
5531
5790
  },
5532
5791
  {
5533
5792
  path: ["traffic", "events"],
5534
- usage: "canonry traffic events <project> [--kind crawler|ai-referral|all] [--source <id>] [--since-minutes 1440] [--since <iso>] [--until <iso>] [--limit 500] [--format json]",
5793
+ usage: "canonry traffic events <project> [--kind crawler|ai-referral|all] [--source <id>] [--since-minutes 1440] [--since <iso>] [--until <iso>] [--limit 500] [--granularity hour|day] [--format json]",
5535
5794
  options: {
5536
5795
  kind: stringOption(),
5537
5796
  source: stringOption(),
5538
5797
  "since-minutes": stringOption(),
5539
5798
  since: stringOption(),
5540
5799
  until: stringOption(),
5541
- limit: stringOption()
5800
+ limit: stringOption(),
5801
+ granularity: stringOption()
5542
5802
  },
5543
5803
  run: async (input) => {
5544
5804
  const project = requireProject(
@@ -5559,6 +5819,7 @@ var TRAFFIC_CLI_COMMANDS = [
5559
5819
  await trafficEvents(project, {
5560
5820
  kind: getString(input.values, "kind"),
5561
5821
  source: getString(input.values, "source"),
5822
+ granularity: getString(input.values, "granularity"),
5562
5823
  sinceMinutes,
5563
5824
  since: getString(input.values, "since"),
5564
5825
  until: getString(input.values, "until"),
@@ -5581,11 +5842,11 @@ var TRAFFIC_CLI_COMMANDS = [
5581
5842
  ];
5582
5843
 
5583
5844
  // src/commands/competitor.ts
5584
- function getClient9() {
5845
+ function getClient10() {
5585
5846
  return createApiClient();
5586
5847
  }
5587
5848
  async function addCompetitors(project, domains, format) {
5588
- const client = getClient9();
5849
+ const client = getClient10();
5589
5850
  const existing = await client.listCompetitors(project);
5590
5851
  const existingDomains = existing.map((c) => c.domain);
5591
5852
  const existingSet = new Set(existingDomains);
@@ -5609,7 +5870,7 @@ async function addCompetitors(project, domains, format) {
5609
5870
  }
5610
5871
  }
5611
5872
  async function removeCompetitors(project, domains, format) {
5612
- const client = getClient9();
5873
+ const client = getClient10();
5613
5874
  const existing = await client.listCompetitors(project);
5614
5875
  const existingDomains = existing.map((c) => c.domain);
5615
5876
  const requested = new Set(uniqueStrings(domains));
@@ -5638,7 +5899,7 @@ function uniqueStrings(values) {
5638
5899
  return result;
5639
5900
  }
5640
5901
  async function listCompetitors(project, format) {
5641
- const client = getClient9();
5902
+ const client = getClient10();
5642
5903
  const comps = await client.listCompetitors(project);
5643
5904
  if (format === "json") {
5644
5905
  console.log(JSON.stringify(comps, null, 2));
@@ -5737,7 +5998,7 @@ var COMPETITOR_CLI_COMMANDS = [
5737
5998
 
5738
5999
  // src/commands/google.ts
5739
6000
  var INDEXING_API_SCOPE_NOTICE = "Note: Google's Indexing API officially supports only pages with JobPosting or BroadcastEvent (livestream VideoObject) structured data. For other URL types, submissions are accepted (HTTP 200) but not guaranteed to be prioritized for crawling. For general pages, submit a sitemap and use URL Inspection to monitor status.";
5740
- function getClient10() {
6001
+ function getClient11() {
5741
6002
  return createApiClient();
5742
6003
  }
5743
6004
  async function waitForRunStatus2(client, runId, config) {
@@ -5777,7 +6038,7 @@ async function waitForRunStatus2(client, runId, config) {
5777
6038
  });
5778
6039
  }
5779
6040
  async function googleConnect(project, opts) {
5780
- const client = getClient10();
6041
+ const client = getClient11();
5781
6042
  const { authUrl, redirectUri } = await client.googleConnect(project, {
5782
6043
  type: opts.type,
5783
6044
  publicUrl: opts.publicUrl
@@ -5811,7 +6072,7 @@ Open this URL in your browser to authorize Google ${opts.type.toUpperCase()} acc
5811
6072
  }
5812
6073
  }
5813
6074
  async function googleDisconnect(project, opts) {
5814
- const client = getClient10();
6075
+ const client = getClient11();
5815
6076
  await client.googleDisconnect(project, opts.type);
5816
6077
  if (isMachineFormat(opts.format)) {
5817
6078
  console.log(JSON.stringify({ project, type: opts.type, disconnected: true }, null, 2));
@@ -5820,7 +6081,7 @@ async function googleDisconnect(project, opts) {
5820
6081
  console.log(`Disconnected Google ${opts.type.toUpperCase()} from project "${project}".`);
5821
6082
  }
5822
6083
  async function googleStatus(project, format) {
5823
- const client = getClient10();
6084
+ const client = getClient11();
5824
6085
  const connections = await client.googleConnections(project);
5825
6086
  if (format === "json") {
5826
6087
  console.log(JSON.stringify({ connections }, null, 2));
@@ -5847,7 +6108,7 @@ async function googleStatus(project, format) {
5847
6108
  }
5848
6109
  }
5849
6110
  async function googleProperties(project, format) {
5850
- const client = getClient10();
6111
+ const client = getClient11();
5851
6112
  const { sites } = await client.googleProperties(project);
5852
6113
  if (format === "json") {
5853
6114
  console.log(JSON.stringify({ sites }, null, 2));
@@ -5871,7 +6132,7 @@ async function googleProperties(project, format) {
5871
6132
  Use "canonry google set-property <project> <siteUrl>" to select a property.`);
5872
6133
  }
5873
6134
  async function googleSetProperty(project, propertyUrl, format) {
5874
- const client = getClient10();
6135
+ const client = getClient11();
5875
6136
  await client.googleSetProperty(project, "gsc", propertyUrl);
5876
6137
  if (isMachineFormat(format)) {
5877
6138
  console.log(JSON.stringify({ project, type: "gsc", propertyUrl }, null, 2));
@@ -5880,7 +6141,7 @@ async function googleSetProperty(project, propertyUrl, format) {
5880
6141
  console.log(`GSC property set to "${propertyUrl}" for project "${project}".`);
5881
6142
  }
5882
6143
  async function googleSync(project, opts) {
5883
- const client = getClient10();
6144
+ const client = getClient11();
5884
6145
  const run = await client.gscSync(project, { days: opts.days, full: opts.full });
5885
6146
  if (!opts.wait && isMachineFormat(opts.format)) {
5886
6147
  console.log(JSON.stringify(run, null, 2));
@@ -5910,7 +6171,7 @@ async function googleSync(project, opts) {
5910
6171
  }
5911
6172
  }
5912
6173
  async function googlePerformanceDaily(project, opts) {
5913
- const client = getClient10();
6174
+ const client = getClient11();
5914
6175
  const params = {};
5915
6176
  if (opts.window) params.window = opts.window;
5916
6177
  if (opts.startDate) params.startDate = opts.startDate;
@@ -5943,7 +6204,7 @@ async function googlePerformanceDaily(project, opts) {
5943
6204
  }
5944
6205
  }
5945
6206
  async function googlePerformance(project, opts) {
5946
- const client = getClient10();
6207
+ const client = getClient11();
5947
6208
  const params = {};
5948
6209
  if (opts.days) {
5949
6210
  const end = /* @__PURE__ */ new Date();
@@ -5982,7 +6243,7 @@ async function googlePerformance(project, opts) {
5982
6243
  }
5983
6244
  }
5984
6245
  async function googleInspect(project, url, format) {
5985
- const client = getClient10();
6246
+ const client = getClient11();
5986
6247
  const result = await client.gscInspect(project, url);
5987
6248
  if (isMachineFormat(format)) {
5988
6249
  console.log(JSON.stringify(result, null, 2));
@@ -6002,7 +6263,7 @@ URL Inspection: ${result.url}
6002
6263
  console.log(` Inspected At: ${result.inspectedAt}`);
6003
6264
  }
6004
6265
  async function googleInspections(project, opts) {
6005
- const client = getClient10();
6266
+ const client = getClient11();
6006
6267
  const params = {};
6007
6268
  if (opts.url) params.url = opts.url;
6008
6269
  const rows = await client.gscInspections(project, Object.keys(params).length > 0 ? params : void 0);
@@ -6030,7 +6291,7 @@ async function googleInspections(project, opts) {
6030
6291
  }
6031
6292
  }
6032
6293
  async function googleCoverage(project, format) {
6033
- const client = getClient10();
6294
+ const client = getClient11();
6034
6295
  const result = await client.gscCoverage(project);
6035
6296
  if (isMachineFormat(format)) {
6036
6297
  console.log(JSON.stringify(result, null, 2));
@@ -6076,7 +6337,7 @@ Index Coverage for "${project}"
6076
6337
  }
6077
6338
  }
6078
6339
  async function googleSetSitemap(project, sitemapUrl, format) {
6079
- const client = getClient10();
6340
+ const client = getClient11();
6080
6341
  await client.googleSetSitemap(project, "gsc", sitemapUrl);
6081
6342
  if (isMachineFormat(format)) {
6082
6343
  console.log(JSON.stringify({ project, type: "gsc", sitemapUrl }, null, 2));
@@ -6085,7 +6346,7 @@ async function googleSetSitemap(project, sitemapUrl, format) {
6085
6346
  console.log(`GSC sitemap URL set to "${sitemapUrl}" for project "${project}".`);
6086
6347
  }
6087
6348
  async function googleListSitemaps(project, opts) {
6088
- const client = getClient10();
6349
+ const client = getClient11();
6089
6350
  const result = await client.gscSitemaps(project);
6090
6351
  if (opts.format === "json") {
6091
6352
  console.log(JSON.stringify(result, null, 2));
@@ -6110,7 +6371,7 @@ Sitemaps for project "${project}":
6110
6371
  }
6111
6372
  }
6112
6373
  async function googleInspectSitemap(project, opts) {
6113
- const client = getClient10();
6374
+ const client = getClient11();
6114
6375
  const run = await client.gscInspectSitemap(project, {
6115
6376
  sitemapUrl: opts.sitemapUrl
6116
6377
  });
@@ -6146,7 +6407,7 @@ async function googleInspectSitemap(project, opts) {
6146
6407
  }
6147
6408
  }
6148
6409
  async function googleCoverageHistory(project, opts) {
6149
- const client = getClient10();
6410
+ const client = getClient11();
6150
6411
  const rows = await client.gscCoverageHistory(project, { limit: opts.limit });
6151
6412
  if (opts.format === "json") {
6152
6413
  console.log(JSON.stringify(rows, null, 2));
@@ -6171,7 +6432,7 @@ GSC Coverage History for "${project}" (${rows.length} snapshots):
6171
6432
  }
6172
6433
  }
6173
6434
  async function googleDiscoverSitemaps(project, opts) {
6174
- const client = getClient10();
6435
+ const client = getClient11();
6175
6436
  const result = await client.gscDiscoverSitemaps(project);
6176
6437
  if (!opts.wait && isMachineFormat(opts.format)) {
6177
6438
  console.log(JSON.stringify(result, null, 2));
@@ -6223,7 +6484,7 @@ Primary sitemap: ${result.primarySitemapUrl}`);
6223
6484
  }
6224
6485
  }
6225
6486
  async function googleRequestIndexing(project, opts) {
6226
- const client = getClient10();
6487
+ const client = getClient11();
6227
6488
  const body = { urls: [] };
6228
6489
  if (opts.allUnindexed) {
6229
6490
  body.allUnindexed = true;
@@ -6318,7 +6579,7 @@ async function googleRequestIndexing(project, opts) {
6318
6579
  }
6319
6580
  }
6320
6581
  async function googleRefresh(project, format) {
6321
- const client = getClient10();
6582
+ const client = getClient11();
6322
6583
  const run = await client.gscSync(project, {});
6323
6584
  if (!isMachineFormat(format)) {
6324
6585
  process.stderr.write("Refreshing GSC coverage data");
@@ -6341,7 +6602,7 @@ async function googleRefresh(project, format) {
6341
6602
  await googleCoverage(project, format);
6342
6603
  }
6343
6604
  async function googleDeindexed(project, format) {
6344
- const client = getClient10();
6605
+ const client = getClient11();
6345
6606
  const rows = await client.gscDeindexed(project);
6346
6607
  if (format === "json") {
6347
6608
  console.log(JSON.stringify(rows, null, 2));
@@ -6650,14 +6911,14 @@ var GOOGLE_CLI_COMMANDS = [
6650
6911
  ];
6651
6912
 
6652
6913
  // src/commands/keys.ts
6653
- function getClient11() {
6914
+ function getClient12() {
6654
6915
  return createApiClient();
6655
6916
  }
6656
6917
  function keyStatus(key) {
6657
6918
  return key.revokedAt ? "revoked" : "active";
6658
6919
  }
6659
6920
  async function listApiKeys(format) {
6660
- const client = getClient11();
6921
+ const client = getClient12();
6661
6922
  const { keys } = await client.listApiKeys();
6662
6923
  if (format === "json") {
6663
6924
  console.log(JSON.stringify({ keys }, null, 2));
@@ -6690,7 +6951,7 @@ async function createApiKey(opts) {
6690
6951
  displayMessage: 'Error: --read-only cannot be combined with --scope (it already implies the "read" scope).'
6691
6952
  });
6692
6953
  }
6693
- const client = getClient11();
6954
+ const client = getClient12();
6694
6955
  const body = { name: opts.name };
6695
6956
  const scopes = opts.readOnly ? [READ_ONLY_SCOPE] : explicitScopes;
6696
6957
  if (scopes) body.scopes = scopes;
@@ -6713,7 +6974,7 @@ async function createApiKey(opts) {
6713
6974
  console.log("\nSave this now \u2014 it will not be shown again.");
6714
6975
  }
6715
6976
  async function showApiKeySelf(format) {
6716
- const client = getClient11();
6977
+ const client = getClient12();
6717
6978
  const key = await client.getApiKeySelf();
6718
6979
  if (isMachineFormat(format)) {
6719
6980
  console.log(JSON.stringify(key, null, 2));
@@ -6725,7 +6986,7 @@ async function showApiKeySelf(format) {
6725
6986
  console.log(` Status: ${keyStatus(key)}`);
6726
6987
  }
6727
6988
  async function revokeApiKey(id, format) {
6728
- const client = getClient11();
6989
+ const client = getClient12();
6729
6990
  const key = await client.revokeApiKey(id);
6730
6991
  if (isMachineFormat(format)) {
6731
6992
  console.log(JSON.stringify(key, null, 2));
@@ -6803,11 +7064,11 @@ var KEYS_CLI_COMMANDS = [
6803
7064
 
6804
7065
  // src/commands/keyword.ts
6805
7066
  import fs4 from "fs";
6806
- function getClient12() {
7067
+ function getClient13() {
6807
7068
  return createApiClient();
6808
7069
  }
6809
7070
  async function addKeywords(project, keywords, format) {
6810
- const client = getClient12();
7071
+ const client = getClient13();
6811
7072
  await client.appendKeywords(project, keywords);
6812
7073
  if (isMachineFormat(format)) {
6813
7074
  console.log(JSON.stringify({
@@ -6820,7 +7081,7 @@ async function addKeywords(project, keywords, format) {
6820
7081
  console.log(`Added ${keywords.length} key phrase(s) to "${project}".`);
6821
7082
  }
6822
7083
  async function replaceKeywords(project, keywords, format) {
6823
- const client = getClient12();
7084
+ const client = getClient13();
6824
7085
  await client.putKeywords(project, keywords);
6825
7086
  if (isMachineFormat(format)) {
6826
7087
  console.log(JSON.stringify({
@@ -6833,7 +7094,7 @@ async function replaceKeywords(project, keywords, format) {
6833
7094
  console.log(`Set ${keywords.length} key phrase(s) for "${project}".`);
6834
7095
  }
6835
7096
  async function removeKeywords(project, keywords, format) {
6836
- const client = getClient12();
7097
+ const client = getClient13();
6837
7098
  const existing = await client.listKeywords(project);
6838
7099
  const existingSet = new Set(existing.map((k) => k.keyword));
6839
7100
  const removedKeywords = keywords.filter((k) => existingSet.has(k));
@@ -6850,7 +7111,7 @@ async function removeKeywords(project, keywords, format) {
6850
7111
  console.log(`Removed ${removedKeywords.length} key phrase(s) from "${project}".`);
6851
7112
  }
6852
7113
  async function listKeywords(project, format) {
6853
- const client = getClient12();
7114
+ const client = getClient13();
6854
7115
  const kws = await client.listKeywords(project);
6855
7116
  if (format === "json") {
6856
7117
  console.log(JSON.stringify(kws, null, 2));
@@ -6896,7 +7157,7 @@ async function importKeywords(project, filePath, format) {
6896
7157
  console.log("No key phrases found in file.");
6897
7158
  return;
6898
7159
  }
6899
- const client = getClient12();
7160
+ const client = getClient13();
6900
7161
  await client.appendKeywords(project, keywords);
6901
7162
  if (isMachineFormat(format)) {
6902
7163
  console.log(JSON.stringify({
@@ -6910,7 +7171,7 @@ async function importKeywords(project, filePath, format) {
6910
7171
  console.log(`Imported ${keywords.length} key phrase(s) to "${project}".`);
6911
7172
  }
6912
7173
  async function generateKeywords(project, provider, opts) {
6913
- const client = getClient12();
7174
+ const client = getClient13();
6914
7175
  const result = await client.generateKeywords(project, provider, opts.count);
6915
7176
  const saved = Boolean(opts.save && result.keywords.length > 0);
6916
7177
  if (!isMachineFormat(opts.format)) {
@@ -7083,11 +7344,11 @@ var KEYWORD_CLI_COMMANDS = [
7083
7344
 
7084
7345
  // src/commands/query.ts
7085
7346
  import fs5 from "fs";
7086
- function getClient13() {
7347
+ function getClient14() {
7087
7348
  return createApiClient();
7088
7349
  }
7089
7350
  async function addQueries(project, queries2, format) {
7090
- const client = getClient13();
7351
+ const client = getClient14();
7091
7352
  await client.appendQueries(project, queries2);
7092
7353
  if (isMachineFormat(format)) {
7093
7354
  console.log(JSON.stringify({
@@ -7100,7 +7361,7 @@ async function addQueries(project, queries2, format) {
7100
7361
  console.log(`Added ${queries2.length} ${queries2.length === 1 ? "query" : "queries"} to "${project}".`);
7101
7362
  }
7102
7363
  async function replaceQueries(project, queries2, opts) {
7103
- const client = getClient13();
7364
+ const client = getClient14();
7104
7365
  const isJson = isMachineFormat(opts?.format);
7105
7366
  if (opts?.dryRun) {
7106
7367
  const preview = await client.previewReplaceQueries(project, queries2);
@@ -7136,7 +7397,7 @@ async function replaceQueries(project, queries2, opts) {
7136
7397
  console.log(`Set ${queries2.length} ${queries2.length === 1 ? "query" : "queries"} for "${project}".`);
7137
7398
  }
7138
7399
  async function removeQueries(project, queries2, format) {
7139
- const client = getClient13();
7400
+ const client = getClient14();
7140
7401
  const existing = await client.listQueries(project);
7141
7402
  const existingSet = new Set(existing.map((q) => q.query));
7142
7403
  const removedQueries = queries2.filter((q) => existingSet.has(q));
@@ -7153,7 +7414,7 @@ async function removeQueries(project, queries2, format) {
7153
7414
  console.log(`Removed ${removedQueries.length} ${removedQueries.length === 1 ? "query" : "queries"} from "${project}".`);
7154
7415
  }
7155
7416
  async function listQueries(project, format) {
7156
- const client = getClient13();
7417
+ const client = getClient14();
7157
7418
  const qs = await client.listQueries(project);
7158
7419
  if (format === "json") {
7159
7420
  console.log(JSON.stringify(qs, null, 2));
@@ -7199,7 +7460,7 @@ async function importQueries(project, filePath, format) {
7199
7460
  console.log("No queries found in file.");
7200
7461
  return;
7201
7462
  }
7202
- const client = getClient13();
7463
+ const client = getClient14();
7203
7464
  await client.appendQueries(project, queries2);
7204
7465
  if (isMachineFormat(format)) {
7205
7466
  console.log(JSON.stringify({
@@ -7213,7 +7474,7 @@ async function importQueries(project, filePath, format) {
7213
7474
  console.log(`Imported ${queries2.length} ${queries2.length === 1 ? "query" : "queries"} to "${project}".`);
7214
7475
  }
7215
7476
  async function generateQueries(project, provider, opts) {
7216
- const client = getClient13();
7477
+ const client = getClient14();
7217
7478
  const result = await client.generateQueries(project, provider, opts.count);
7218
7479
  const saved = Boolean(opts.save && result.queries.length > 0);
7219
7480
  if (!isMachineFormat(opts.format)) {
@@ -7708,11 +7969,11 @@ var MCP_CLI_COMMANDS = [
7708
7969
  ];
7709
7970
 
7710
7971
  // src/commands/notify.ts
7711
- function getClient14() {
7972
+ function getClient15() {
7712
7973
  return createApiClient();
7713
7974
  }
7714
7975
  async function addNotification(project, opts) {
7715
- const client = getClient14();
7976
+ const client = getClient15();
7716
7977
  const result = await client.createNotification(project, {
7717
7978
  channel: "webhook",
7718
7979
  url: opts.webhook,
@@ -7726,7 +7987,7 @@ async function addNotification(project, opts) {
7726
7987
  printNotification(result);
7727
7988
  }
7728
7989
  async function listNotifications(project, format) {
7729
- const client = getClient14();
7990
+ const client = getClient15();
7730
7991
  const results = await client.listNotifications(project);
7731
7992
  if (format === "json") {
7732
7993
  console.log(JSON.stringify(results, null, 2));
@@ -7747,7 +8008,7 @@ async function listNotifications(project, format) {
7747
8008
  }
7748
8009
  }
7749
8010
  async function removeNotification(project, id, format) {
7750
- const client = getClient14();
8011
+ const client = getClient15();
7751
8012
  await client.deleteNotification(project, id);
7752
8013
  if (isMachineFormat(format)) {
7753
8014
  console.log(JSON.stringify({ project, id, removed: true }, null, 2));
@@ -7756,7 +8017,7 @@ async function removeNotification(project, id, format) {
7756
8017
  console.log(`Notification ${id} removed from "${project}"`);
7757
8018
  }
7758
8019
  async function testNotification(project, id, format) {
7759
- const client = getClient14();
8020
+ const client = getClient15();
7760
8021
  const result = await client.testNotification(project, id);
7761
8022
  if (isMachineFormat(format)) {
7762
8023
  console.log(JSON.stringify({ project, id, ...result }, null, 2));
@@ -7951,11 +8212,11 @@ async function applyConfigs(filePaths, format) {
7951
8212
  }
7952
8213
 
7953
8214
  // src/commands/analytics.ts
7954
- function getClient15() {
8215
+ function getClient16() {
7955
8216
  return createApiClient();
7956
8217
  }
7957
8218
  async function showAnalytics(project, options) {
7958
- const client = getClient15();
8219
+ const client = getClient16();
7959
8220
  const features = options.feature ? [options.feature] : ["metrics", "gaps", "sources"];
7960
8221
  const results = {};
7961
8222
  for (const feature of features) {
@@ -8158,7 +8419,7 @@ Source Origin Breakdown`);
8158
8419
  }
8159
8420
 
8160
8421
  // src/commands/sources.ts
8161
- function getClient16() {
8422
+ function getClient17() {
8162
8423
  return createApiClient();
8163
8424
  }
8164
8425
  var pct = (n) => `${(n * 100).toFixed(1)}%`;
@@ -8169,7 +8430,7 @@ async function showSources(project, options) {
8169
8430
  details: { command: "sources", option: "limit", value: options.limit }
8170
8431
  });
8171
8432
  }
8172
- const client = getClient16();
8433
+ const client = getClient17();
8173
8434
  const data = await client.getAnalyticsSources(project, { window: options.window, limit: options.limit });
8174
8435
  if (options.format === "jsonl") {
8175
8436
  emitJsonl(data.ranked.entries.map((e) => ({ project, ...e })));
@@ -8220,11 +8481,11 @@ function printRankedEntries(list, indent = "") {
8220
8481
  }
8221
8482
 
8222
8483
  // src/commands/evidence.ts
8223
- function getClient17() {
8484
+ function getClient18() {
8224
8485
  return createApiClient();
8225
8486
  }
8226
8487
  async function showEvidence(project, format) {
8227
- const client = getClient17();
8488
+ const client = getClient18();
8228
8489
  const timeline = await client.getTimeline(project);
8229
8490
  if (format === "json") {
8230
8491
  const enriched = timeline.map((entry) => ({
@@ -8307,7 +8568,7 @@ async function exportResults(project, opts) {
8307
8568
  }
8308
8569
 
8309
8570
  // src/commands/history.ts
8310
- function getClient18() {
8571
+ function getClient19() {
8311
8572
  return createApiClient();
8312
8573
  }
8313
8574
  function originLabel(entry) {
@@ -8318,7 +8579,7 @@ function originLabel(entry) {
8318
8579
  return entry.actor;
8319
8580
  }
8320
8581
  async function showHistory(project, format, opts = {}) {
8321
- const client = getClient18();
8582
+ const client = getClient19();
8322
8583
  try {
8323
8584
  const entries = project ? await client.getHistory(project, opts) : await client.getGlobalHistory(opts);
8324
8585
  if (format === "json") {
@@ -8359,11 +8620,11 @@ async function showHistory(project, format, opts = {}) {
8359
8620
  }
8360
8621
 
8361
8622
  // src/commands/status.ts
8362
- function getClient19() {
8623
+ function getClient20() {
8363
8624
  return createApiClient();
8364
8625
  }
8365
8626
  async function showStatus(project, format) {
8366
- const client = getClient19();
8627
+ const client = getClient20();
8367
8628
  const projectData = await client.getProject(project);
8368
8629
  const latest = await getLatestRunSummary(client, project);
8369
8630
  if (isMachineFormat(format)) {
@@ -8562,11 +8823,11 @@ var OPERATOR_CLI_COMMANDS = [
8562
8823
  ];
8563
8824
 
8564
8825
  // src/commands/project.ts
8565
- function getClient20() {
8826
+ function getClient21() {
8566
8827
  return createApiClient();
8567
8828
  }
8568
8829
  async function createProject(name, opts) {
8569
- const client = getClient20();
8830
+ const client = getClient21();
8570
8831
  const result = await client.putProject(name, {
8571
8832
  displayName: opts.displayName,
8572
8833
  canonicalDomain: opts.domain,
@@ -8584,7 +8845,7 @@ async function createProject(name, opts) {
8584
8845
  console.log(`Project created: ${result.name} (${result.id})`);
8585
8846
  }
8586
8847
  async function listProjects(format) {
8587
- const client = getClient20();
8848
+ const client = getClient21();
8588
8849
  const projects2 = await client.listProjects();
8589
8850
  if (format === "json") {
8590
8851
  console.log(JSON.stringify(projects2, null, 2));
@@ -8616,7 +8877,7 @@ async function listProjects(format) {
8616
8877
  }
8617
8878
  }
8618
8879
  async function showProject(name, format) {
8619
- const client = getClient20();
8880
+ const client = getClient21();
8620
8881
  const project = await client.getProject(name);
8621
8882
  if (isMachineFormat(format)) {
8622
8883
  console.log(JSON.stringify(project, null, 2));
@@ -8648,7 +8909,7 @@ async function showProject(name, format) {
8648
8909
  if (project.updatedAt) console.log(` Updated: ${project.updatedAt}`);
8649
8910
  }
8650
8911
  async function updateProjectSettings(name, opts) {
8651
- const client = getClient20();
8912
+ const client = getClient21();
8652
8913
  const project = await client.getProject(name);
8653
8914
  let ownedDomains = opts.ownedDomains ?? project.ownedDomains ?? [];
8654
8915
  if (opts.addOwnedDomain) {
@@ -8711,7 +8972,7 @@ async function updateProjectSettings(name, opts) {
8711
8972
  }
8712
8973
  }
8713
8974
  async function deleteProject(name, opts) {
8714
- const client = getClient20();
8975
+ const client = getClient21();
8715
8976
  const isJson = isMachineFormat(opts?.format);
8716
8977
  if (opts?.dryRun) {
8717
8978
  const preview = await client.previewProjectDelete(name);
@@ -8741,7 +9002,7 @@ async function deleteProject(name, opts) {
8741
9002
  console.log(`Project deleted: ${name}`);
8742
9003
  }
8743
9004
  async function addLocation(project, opts) {
8744
- const client = getClient20();
9005
+ const client = getClient21();
8745
9006
  const location = await client.addLocation(project, {
8746
9007
  label: opts.label,
8747
9008
  city: opts.city,
@@ -8756,7 +9017,7 @@ async function addLocation(project, opts) {
8756
9017
  console.log(`Location added: ${opts.label} (${opts.city}, ${opts.region}, ${opts.country})`);
8757
9018
  }
8758
9019
  async function listLocations(project, format) {
8759
- const client = getClient20();
9020
+ const client = getClient21();
8760
9021
  const result = await client.listLocations(project);
8761
9022
  if (format === "json") {
8762
9023
  console.log(JSON.stringify(result, null, 2));
@@ -8790,7 +9051,7 @@ async function listLocations(project, format) {
8790
9051
  }
8791
9052
  }
8792
9053
  async function removeLocation(project, label, format) {
8793
- const client = getClient20();
9054
+ const client = getClient21();
8794
9055
  await client.removeLocation(project, label);
8795
9056
  if (isMachineFormat(format)) {
8796
9057
  console.log(JSON.stringify({ project, label, removed: true }, null, 2));
@@ -8799,7 +9060,7 @@ async function removeLocation(project, label, format) {
8799
9060
  console.log(`Location removed: ${label}`);
8800
9061
  }
8801
9062
  async function setDefaultLocation(project, label, format) {
8802
- const client = getClient20();
9063
+ const client = getClient21();
8803
9064
  const result = await client.setDefaultLocation(project, label);
8804
9065
  if (isMachineFormat(format)) {
8805
9066
  console.log(JSON.stringify({ project, ...result }, null, 2));
@@ -9083,12 +9344,12 @@ var REPORT_CLI_COMMANDS = [
9083
9344
  ];
9084
9345
 
9085
9346
  // src/commands/run.ts
9086
- function getClient21() {
9347
+ function getClient22() {
9087
9348
  return createApiClient();
9088
9349
  }
9089
9350
  var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["completed", "partial", "failed", "cancelled"]);
9090
9351
  async function triggerRun(project, opts) {
9091
- const client = getClient21();
9352
+ const client = getClient22();
9092
9353
  const body = {};
9093
9354
  if (opts?.provider) {
9094
9355
  const providerInputs = opts.provider.split(",").map((s) => s.trim()).filter(Boolean);
@@ -9190,7 +9451,7 @@ async function triggerRun(project, opts) {
9190
9451
  }
9191
9452
  }
9192
9453
  async function triggerRunAll(opts) {
9193
- const client = getClient21();
9454
+ const client = getClient22();
9194
9455
  const projects2 = await client.listProjects();
9195
9456
  if (projects2.length === 0) {
9196
9457
  if (isMachineFormat(opts?.format)) {
@@ -9273,7 +9534,7 @@ async function triggerRunAll(opts) {
9273
9534
  }
9274
9535
  }
9275
9536
  async function cancelRun(project, runId, format) {
9276
- const client = getClient21();
9537
+ const client = getClient22();
9277
9538
  let targetId = runId;
9278
9539
  if (!targetId) {
9279
9540
  const runs = await client.listRuns(project);
@@ -9305,7 +9566,7 @@ To cancel by ID : canonry run cancel ${project} <run-id>`,
9305
9566
  console.log(`Run ${result.id} cancelled.`);
9306
9567
  }
9307
9568
  async function showRun(id, format) {
9308
- const client = getClient21();
9569
+ const client = getClient22();
9309
9570
  const run = await client.getRun(id);
9310
9571
  if (isMachineFormat(format)) {
9311
9572
  console.log(JSON.stringify(run, null, 2));
@@ -9314,7 +9575,7 @@ async function showRun(id, format) {
9314
9575
  printRunDetail(run);
9315
9576
  }
9316
9577
  async function listRuns(project, opts) {
9317
- const client = getClient21();
9578
+ const client = getClient22();
9318
9579
  const runs = await client.listRuns(project, opts?.limit, opts?.kind);
9319
9580
  if (opts?.format === "json") {
9320
9581
  console.log(JSON.stringify(runs, null, 2));
@@ -9337,13 +9598,13 @@ async function listRuns(project, opts) {
9337
9598
  );
9338
9599
  }
9339
9600
  }
9340
- var POLL_TIMEOUT_MS2 = 10 * 60 * 1e3;
9601
+ var POLL_TIMEOUT_MS3 = 10 * 60 * 1e3;
9341
9602
  async function pollRun2(client, runId) {
9342
- const deadline = Date.now() + POLL_TIMEOUT_MS2;
9603
+ const deadline = Date.now() + POLL_TIMEOUT_MS3;
9343
9604
  for (; ; ) {
9344
9605
  await new Promise((r) => setTimeout(r, 2e3));
9345
9606
  if (Date.now() > deadline) {
9346
- throw new Error(`Timed out waiting for run ${runId} after ${POLL_TIMEOUT_MS2 / 1e3}s`);
9607
+ throw new Error(`Timed out waiting for run ${runId} after ${POLL_TIMEOUT_MS3 / 1e3}s`);
9347
9608
  }
9348
9609
  const run = await client.getRun(runId);
9349
9610
  process.stderr.write(".");
@@ -9489,11 +9750,11 @@ var RUN_CLI_COMMANDS = [
9489
9750
  ];
9490
9751
 
9491
9752
  // src/commands/schedule.ts
9492
- function getClient22() {
9753
+ function getClient23() {
9493
9754
  return createApiClient();
9494
9755
  }
9495
9756
  async function setSchedule(project, opts) {
9496
- const client = getClient22();
9757
+ const client = getClient23();
9497
9758
  const body = {};
9498
9759
  if (opts.kind) body.kind = opts.kind;
9499
9760
  if (opts.sourceId) body.sourceId = opts.sourceId;
@@ -9510,7 +9771,7 @@ async function setSchedule(project, opts) {
9510
9771
  printSchedule(result);
9511
9772
  }
9512
9773
  async function showSchedule(project, format, kind) {
9513
- const client = getClient22();
9774
+ const client = getClient23();
9514
9775
  const result = await client.getSchedule(project, kind);
9515
9776
  if (isMachineFormat(format)) {
9516
9777
  console.log(JSON.stringify(result, null, 2));
@@ -9519,7 +9780,7 @@ async function showSchedule(project, format, kind) {
9519
9780
  printSchedule(result);
9520
9781
  }
9521
9782
  async function enableSchedule(project, format, kind) {
9522
- const client = getClient22();
9783
+ const client = getClient23();
9523
9784
  const current = await client.getSchedule(project, kind);
9524
9785
  const body = { kind: current.kind, timezone: current.timezone, enabled: true };
9525
9786
  if (current.preset) body.preset = current.preset;
@@ -9534,7 +9795,7 @@ async function enableSchedule(project, format, kind) {
9534
9795
  console.log(`Schedule enabled for "${project}" (kind: ${result.kind})`);
9535
9796
  }
9536
9797
  async function disableSchedule(project, format, kind) {
9537
- const client = getClient22();
9798
+ const client = getClient23();
9538
9799
  const current = await client.getSchedule(project, kind);
9539
9800
  const body = { kind: current.kind, timezone: current.timezone, enabled: false };
9540
9801
  if (current.preset) body.preset = current.preset;
@@ -9549,7 +9810,7 @@ async function disableSchedule(project, format, kind) {
9549
9810
  console.log(`Schedule disabled for "${project}" (kind: ${result.kind})`);
9550
9811
  }
9551
9812
  async function removeSchedule(project, format, kind) {
9552
- const client = getClient22();
9813
+ const client = getClient23();
9553
9814
  await client.deleteSchedule(project, kind);
9554
9815
  const resolvedKind = kind ?? "answer-visibility";
9555
9816
  if (isMachineFormat(format)) {
@@ -9667,11 +9928,11 @@ var SCHEDULE_CLI_COMMANDS = [
9667
9928
  ];
9668
9929
 
9669
9930
  // src/commands/settings.ts
9670
- function getClient23() {
9931
+ function getClient24() {
9671
9932
  return createApiClient();
9672
9933
  }
9673
9934
  async function setProvider(name, opts) {
9674
- const client = getClient23();
9935
+ const client = getClient24();
9675
9936
  const { format, ...payload } = opts;
9676
9937
  const result = await client.updateProvider(name, payload);
9677
9938
  if (isMachineFormat(format)) {
@@ -9687,7 +9948,7 @@ async function setProvider(name, opts) {
9687
9948
  }
9688
9949
  }
9689
9950
  async function showSettings(format) {
9690
- const client = getClient23();
9951
+ const client = getClient24();
9691
9952
  const config = loadConfig();
9692
9953
  const settings = await client.getSettings();
9693
9954
  if (isMachineFormat(format)) {
@@ -10237,7 +10498,7 @@ function wrapText(font, text, size, maxWidth) {
10237
10498
  }
10238
10499
 
10239
10500
  // src/commands/snapshot.ts
10240
- function getClient24() {
10501
+ function getClient25() {
10241
10502
  return createApiClient();
10242
10503
  }
10243
10504
  function slugify(value) {
@@ -10248,7 +10509,7 @@ function autoOutputPath(companyName, ext) {
10248
10509
  return `${slugify(companyName)}-snapshot-${date}.${ext}`;
10249
10510
  }
10250
10511
  async function createSnapshotReport(companyName, opts) {
10251
- const client = getClient24();
10512
+ const client = getClient25();
10252
10513
  const report = await client.createSnapshot({
10253
10514
  companyName,
10254
10515
  domain: opts.domain,
@@ -12587,11 +12848,11 @@ var SYSTEM_CLI_COMMANDS = [
12587
12848
  ];
12588
12849
 
12589
12850
  // src/commands/technical-aeo.ts
12590
- function getClient25() {
12851
+ function getClient26() {
12591
12852
  return createApiClient();
12592
12853
  }
12593
12854
  async function technicalAeoScore(project, opts) {
12594
- const client = getClient25();
12855
+ const client = getClient26();
12595
12856
  const score = await client.getTechnicalAeoScore(project, { runId: opts.runId });
12596
12857
  if (isMachineFormat(opts.format)) {
12597
12858
  console.log(JSON.stringify(score, null, 2));
@@ -12627,7 +12888,7 @@ async function technicalAeoScore(project, opts) {
12627
12888
  console.log(lines.join("\n"));
12628
12889
  }
12629
12890
  async function technicalAeoPages(project, opts) {
12630
- const client = getClient25();
12891
+ const client = getClient26();
12631
12892
  const status = opts.status === "success" || opts.status === "error" ? opts.status : void 0;
12632
12893
  const res = await client.getTechnicalAeoPages(project, { runId: opts.runId, status, sort: opts.sort, limit: opts.limit });
12633
12894
  if (opts.format === "jsonl") {
@@ -12653,7 +12914,7 @@ async function technicalAeoPages(project, opts) {
12653
12914
  console.log(lines.join("\n"));
12654
12915
  }
12655
12916
  async function technicalAeoTrend(project, opts) {
12656
- const client = getClient25();
12917
+ const client = getClient26();
12657
12918
  const res = await client.getTechnicalAeoTrend(project, { limit: opts.limit });
12658
12919
  if (opts.format === "jsonl") {
12659
12920
  emitJsonl(res.points.map((p) => ({ project, ...p })));
@@ -12675,7 +12936,7 @@ async function technicalAeoTrend(project, opts) {
12675
12936
  console.log(lines.join("\n"));
12676
12937
  }
12677
12938
  async function technicalAeoRun(project, opts) {
12678
- const client = getClient25();
12939
+ const client = getClient26();
12679
12940
  const { runId, status } = await client.triggerSiteAudit(project, {
12680
12941
  sitemapUrl: opts.sitemapUrl,
12681
12942
  limit: opts.limit
@@ -13034,7 +13295,7 @@ var VISIBILITY_STATS_CLI_COMMANDS = [
13034
13295
  import fs15 from "fs";
13035
13296
 
13036
13297
  // src/commands/wordpress.ts
13037
- function getClient26() {
13298
+ function getClient27() {
13038
13299
  return createApiClient();
13039
13300
  }
13040
13301
  async function loadYamlModule() {
@@ -13184,7 +13445,7 @@ async function wordpressConnect(project, opts) {
13184
13445
  details: { project }
13185
13446
  });
13186
13447
  }
13187
- const client = getClient26();
13448
+ const client = getClient27();
13188
13449
  const result = await client.wordpressConnect(project, {
13189
13450
  url: opts.url,
13190
13451
  stagingUrl: opts.stagingUrl,
@@ -13201,7 +13462,7 @@ async function wordpressConnect(project, opts) {
13201
13462
  printWordpressStatus(project, result);
13202
13463
  }
13203
13464
  async function wordpressDisconnect(project, format) {
13204
- const client = getClient26();
13465
+ const client = getClient27();
13205
13466
  await client.wordpressDisconnect(project);
13206
13467
  if (isMachineFormat(format)) {
13207
13468
  printJson2({ project, disconnected: true });
@@ -13210,7 +13471,7 @@ async function wordpressDisconnect(project, format) {
13210
13471
  console.log(`WordPress disconnected from project "${project}".`);
13211
13472
  }
13212
13473
  async function wordpressStatus(project, format) {
13213
- const client = getClient26();
13474
+ const client = getClient27();
13214
13475
  const result = await client.wordpressStatus(project);
13215
13476
  if (isMachineFormat(format)) {
13216
13477
  printJson2(result);
@@ -13219,7 +13480,7 @@ async function wordpressStatus(project, format) {
13219
13480
  printWordpressStatus(project, result);
13220
13481
  }
13221
13482
  async function wordpressPages(project, opts) {
13222
- const client = getClient26();
13483
+ const client = getClient27();
13223
13484
  const result = await client.wordpressPages(project, opts.env);
13224
13485
  if (isMachineFormat(opts.format)) {
13225
13486
  printJson2(result);
@@ -13228,7 +13489,7 @@ async function wordpressPages(project, opts) {
13228
13489
  printPages(project, result.env, result.pages);
13229
13490
  }
13230
13491
  async function wordpressPage(project, slug, opts) {
13231
- const client = getClient26();
13492
+ const client = getClient27();
13232
13493
  const result = await client.wordpressPage(project, slug, opts.env);
13233
13494
  if (isMachineFormat(opts.format)) {
13234
13495
  printJson2(result);
@@ -13237,7 +13498,7 @@ async function wordpressPage(project, slug, opts) {
13237
13498
  printPageDetail(result);
13238
13499
  }
13239
13500
  async function wordpressCreatePage(project, body) {
13240
- const client = getClient26();
13501
+ const client = getClient27();
13241
13502
  const result = await client.wordpressCreatePage(project, body);
13242
13503
  if (isMachineFormat(body.format)) {
13243
13504
  printJson2(result);
@@ -13248,7 +13509,7 @@ async function wordpressCreatePage(project, body) {
13248
13509
  printPageDetail(result);
13249
13510
  }
13250
13511
  async function wordpressUpdatePage(project, body) {
13251
- const client = getClient26();
13512
+ const client = getClient27();
13252
13513
  const result = await client.wordpressUpdatePage(project, body);
13253
13514
  if (isMachineFormat(body.format)) {
13254
13515
  printJson2(result);
@@ -13259,7 +13520,7 @@ async function wordpressUpdatePage(project, body) {
13259
13520
  printPageDetail(result);
13260
13521
  }
13261
13522
  async function wordpressSetMeta(project, body) {
13262
- const client = getClient26();
13523
+ const client = getClient27();
13263
13524
  const result = await client.wordpressSetMeta(project, body);
13264
13525
  if (isMachineFormat(body.format)) {
13265
13526
  printJson2(result);
@@ -13309,7 +13570,7 @@ async function wordpressBulkSetMeta(project, opts) {
13309
13570
  details: { path: filePath }
13310
13571
  });
13311
13572
  }
13312
- const client = getClient26();
13573
+ const client = getClient27();
13313
13574
  const result = await client.wordpressBulkSetMeta(project, { entries, env: opts.env });
13314
13575
  if (isMachineFormat(opts.format)) {
13315
13576
  printJson2(result);
@@ -13352,7 +13613,7 @@ async function wordpressBulkSetMeta(project, opts) {
13352
13613
  Total: ${applied.length} applied, ${skipped.length} skipped, ${manual.length} manual`);
13353
13614
  }
13354
13615
  async function wordpressSchema(project, slug, opts) {
13355
- const client = getClient26();
13616
+ const client = getClient27();
13356
13617
  const result = await client.wordpressSchema(project, slug, opts.env);
13357
13618
  if (isMachineFormat(opts.format)) {
13358
13619
  printJson2(result);
@@ -13363,7 +13624,7 @@ async function wordpressSchema(project, slug, opts) {
13363
13624
  printSchemaBlocks(result.blocks);
13364
13625
  }
13365
13626
  async function wordpressSetSchema(project, body) {
13366
- const client = getClient26();
13627
+ const client = getClient27();
13367
13628
  const result = await client.wordpressSetSchema(project, body);
13368
13629
  if (isMachineFormat(body.format)) {
13369
13630
  printJson2(result);
@@ -13411,7 +13672,7 @@ async function wordpressSchemaDeploy(project, opts) {
13411
13672
  details: { path: filePath }
13412
13673
  });
13413
13674
  }
13414
- const client = getClient26();
13675
+ const client = getClient27();
13415
13676
  const result = await client.wordpressSchemaDeploy(project, { profile: parsed, env: opts.env });
13416
13677
  if (isMachineFormat(opts.format)) {
13417
13678
  printJson2(result);
@@ -13450,7 +13711,7 @@ async function wordpressSchemaDeploy(project, opts) {
13450
13711
  Total: ${deployed} deployed, ${stripped} stripped, ${skipped} skipped, ${failed} failed`);
13451
13712
  }
13452
13713
  async function wordpressSchemaStatus(project, opts) {
13453
- const client = getClient26();
13714
+ const client = getClient27();
13454
13715
  const result = await client.wordpressSchemaStatus(project, opts.env);
13455
13716
  if (isMachineFormat(opts.format)) {
13456
13717
  printJson2(result);
@@ -13509,7 +13770,7 @@ async function wordpressOnboard(project, opts) {
13509
13770
  });
13510
13771
  }
13511
13772
  }
13512
- const client = getClient26();
13773
+ const client = getClient27();
13513
13774
  const result = await client.wordpressOnboard(project, {
13514
13775
  url: opts.url,
13515
13776
  username: opts.user,
@@ -13534,7 +13795,7 @@ async function wordpressOnboard(project, opts) {
13534
13795
  }
13535
13796
  }
13536
13797
  async function wordpressLlmsTxt(project, opts) {
13537
- const client = getClient26();
13798
+ const client = getClient27();
13538
13799
  const result = await client.wordpressLlmsTxt(project, opts.env);
13539
13800
  if (isMachineFormat(opts.format)) {
13540
13801
  printJson2(result);
@@ -13545,7 +13806,7 @@ async function wordpressLlmsTxt(project, opts) {
13545
13806
  console.log(result.content ?? "(not found)");
13546
13807
  }
13547
13808
  async function wordpressSetLlmsTxt(project, body) {
13548
- const client = getClient26();
13809
+ const client = getClient27();
13549
13810
  const result = await client.wordpressSetLlmsTxt(project, body);
13550
13811
  if (isMachineFormat(body.format)) {
13551
13812
  printJson2(result);
@@ -13554,7 +13815,7 @@ async function wordpressSetLlmsTxt(project, body) {
13554
13815
  printManualAssist(`llms.txt update for "${project}"`, result);
13555
13816
  }
13556
13817
  async function wordpressAudit(project, opts) {
13557
- const client = getClient26();
13818
+ const client = getClient27();
13558
13819
  const result = await client.wordpressAudit(project, opts.env);
13559
13820
  if (isMachineFormat(opts.format)) {
13560
13821
  printJson2(result);
@@ -13568,7 +13829,7 @@ async function wordpressAudit(project, opts) {
13568
13829
  printAuditIssues(result.issues);
13569
13830
  }
13570
13831
  async function wordpressDiff(project, slug, format) {
13571
- const client = getClient26();
13832
+ const client = getClient27();
13572
13833
  const result = await client.wordpressDiff(project, slug);
13573
13834
  if (isMachineFormat(format)) {
13574
13835
  printJson2(result);
@@ -13577,7 +13838,7 @@ async function wordpressDiff(project, slug, format) {
13577
13838
  printDiff(result);
13578
13839
  }
13579
13840
  async function wordpressStagingStatus(project, format) {
13580
- const client = getClient26();
13841
+ const client = getClient27();
13581
13842
  const result = await client.wordpressStagingStatus(project);
13582
13843
  if (isMachineFormat(format)) {
13583
13844
  printJson2(result);
@@ -13591,7 +13852,7 @@ async function wordpressStagingStatus(project, format) {
13591
13852
  console.log(` Admin URL: ${result.adminUrl}`);
13592
13853
  }
13593
13854
  async function wordpressStagingPush(project, format) {
13594
- const client = getClient26();
13855
+ const client = getClient27();
13595
13856
  const result = await client.wordpressStagingPush(project);
13596
13857
  if (isMachineFormat(format)) {
13597
13858
  printJson2(result);
@@ -14634,6 +14895,7 @@ var REGISTERED_CLI_COMMANDS = [
14634
14895
  ...CONTENT_CLI_COMMANDS,
14635
14896
  ...AGENT_CLI_COMMANDS,
14636
14897
  ...DISCOVER_CLI_COMMANDS,
14898
+ ...RESEARCH_CLI_COMMANDS,
14637
14899
  ...TECHNICAL_AEO_CLI_COMMANDS,
14638
14900
  ...DOCTOR_CLI_COMMANDS,
14639
14901
  ...GET_CLI_COMMANDS,