@ainyc/canonry 4.115.0 → 4.116.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 (24) hide show
  1. package/assets/assets/{BacklinksPage-DhXsZ8Sb.js → BacklinksPage-Dy6Xc-LT.js} +1 -1
  2. package/assets/assets/{ChartPrimitives-Cdj0P8uG.js → ChartPrimitives-CHJh5M8x.js} +1 -1
  3. package/assets/assets/ProjectPage-Bjfa4CI5.js +7 -0
  4. package/assets/assets/{RunRow-GJ_2CEif.js → RunRow-DmvQnWPf.js} +1 -1
  5. package/assets/assets/{RunsPage-upaDiLFK.js → RunsPage-BxkxQEKE.js} +1 -1
  6. package/assets/assets/{SettingsPage-FbmEaN16.js → SettingsPage-DCyqHqDh.js} +1 -1
  7. package/assets/assets/{TrafficPage-Di0H5JRu.js → TrafficPage-BT_ae5aO.js} +1 -1
  8. package/assets/assets/{TrafficSourceDetailPage-Bc2mxXSV.js → TrafficSourceDetailPage-Cps-tSHn.js} +1 -1
  9. package/assets/assets/{arrow-left-yOCIy3_x.js → arrow-left-D8vdqhx4.js} +1 -1
  10. package/assets/assets/{extract-error-message-tCNIzznL.js → extract-error-message-BOY5txUA.js} +1 -1
  11. package/assets/assets/{index-Bb5yUz7k.css → index-B4R1-8hR.css} +1 -1
  12. package/assets/assets/{index-D0ZdnFQf.js → index-DxjY63VC.js} +89 -89
  13. package/assets/assets/{trash-2-gRyTO-PS.js → trash-2-ap_Fa4zA.js} +1 -1
  14. package/assets/index.html +2 -2
  15. package/dist/{chunk-PGVGHGIX.js → chunk-GV665WOU.js} +4 -4
  16. package/dist/{chunk-VEUBAZRG.js → chunk-IQPMK36Y.js} +1352 -1199
  17. package/dist/{chunk-MO7GPMNV.js → chunk-RVH6QPTA.js} +1 -1
  18. package/dist/{chunk-BXNFOGDF.js → chunk-WEAXJ25Y.js} +420 -87
  19. package/dist/cli.js +57 -9
  20. package/dist/index.js +4 -4
  21. package/dist/{intelligence-service-2C7H4C6A.js → intelligence-service-HEN5HLUM.js} +2 -2
  22. package/dist/mcp.js +2 -2
  23. package/package.json +7 -7
  24. package/assets/assets/ProjectPage-DAWtJQ3w.js +0 -7
@@ -2907,29 +2907,189 @@ function calendarMonthBounds(month) {
2907
2907
  }
2908
2908
 
2909
2909
  // ../contracts/src/ga.ts
2910
+ import { z as z22 } from "zod";
2911
+
2912
+ // ../contracts/src/traffic-class.ts
2910
2913
  import { z as z21 } from "zod";
2911
- var ga4ConnectionDtoSchema = z21.object({
2912
- id: z21.string(),
2913
- projectId: z21.string(),
2914
- propertyId: z21.string(),
2915
- clientEmail: z21.string(),
2916
- connected: z21.boolean(),
2917
- createdAt: z21.string(),
2918
- updatedAt: z21.string()
2919
- });
2920
- var ga4TrafficSnapshotDtoSchema = z21.object({
2921
- date: z21.string(),
2922
- landingPage: z21.string(),
2923
- sessions: z21.number(),
2924
- organicSessions: z21.number(),
2925
- users: z21.number()
2926
- });
2927
- var ga4SourceDimensionSchema = z21.enum(["session", "first_user", "manual_utm"]);
2928
- var ga4AiReferralDtoSchema = z21.object({
2929
- source: z21.string(),
2930
- medium: z21.string(),
2931
- sessions: z21.number(),
2932
- users: z21.number(),
2914
+
2915
+ // ../contracts/src/formatting.ts
2916
+ function formatRatio(value) {
2917
+ if (!Number.isFinite(value) || value === 0) return "0%";
2918
+ return `${(value * 100).toFixed(1)}%`;
2919
+ }
2920
+ function formatNumber(value) {
2921
+ if (!Number.isFinite(value)) return "\u2014";
2922
+ if (Math.abs(value) >= 1e6) return `${(value / 1e6).toFixed(1)}M`;
2923
+ if (Math.abs(value) >= 1e3) return `${(value / 1e3).toFixed(1)}K`;
2924
+ return value.toLocaleString("en-US");
2925
+ }
2926
+ function formatDate(iso) {
2927
+ if (!iso) return "\u2014";
2928
+ try {
2929
+ const dateOnly = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso);
2930
+ const options = { month: "short", day: "numeric", year: "numeric" };
2931
+ const d = dateOnly && dateOnly[1] && dateOnly[2] && dateOnly[3] ? new Date(Date.UTC(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3]))) : new Date(iso);
2932
+ if (Number.isNaN(d.getTime())) return iso;
2933
+ return d.toLocaleDateString("en-US", dateOnly ? { ...options, timeZone: "UTC" } : options);
2934
+ } catch {
2935
+ return iso;
2936
+ }
2937
+ }
2938
+ function formatIsoDate(iso) {
2939
+ if (!iso) return "\u2014";
2940
+ try {
2941
+ const d = new Date(iso);
2942
+ if (Number.isNaN(d.getTime())) return iso;
2943
+ const yyyy = d.getUTCFullYear();
2944
+ const mm = String(d.getUTCMonth() + 1).padStart(2, "0");
2945
+ const dd = String(d.getUTCDate()).padStart(2, "0");
2946
+ return `${yyyy}-${mm}-${dd}`;
2947
+ } catch {
2948
+ return iso;
2949
+ }
2950
+ }
2951
+ function formatDateRange(start, end) {
2952
+ if (!start && !end) return "";
2953
+ if (start && end) return `${formatDate(start)} \u2192 ${formatDate(end)}`;
2954
+ return formatDate(start || end);
2955
+ }
2956
+ var DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
2957
+ function parseInclusiveEndMs(iso) {
2958
+ const ms = Date.parse(iso);
2959
+ if (Number.isNaN(ms)) return null;
2960
+ return DATE_ONLY_PATTERN.test(iso) ? ms + 864e5 - 1 : ms;
2961
+ }
2962
+ function deltaPercent(current, prior) {
2963
+ if (prior <= 0) return null;
2964
+ return Math.round((current - prior) / prior * 100);
2965
+ }
2966
+ function deltaTone(deltaPct) {
2967
+ if (deltaPct === null || deltaPct === 0) return "neutral";
2968
+ return deltaPct > 0 ? "positive" : "negative";
2969
+ }
2970
+ function formatDeltaCopy(d, suffix, windowLabel = "vs prior 7 days") {
2971
+ if (d.deltaPct === null) {
2972
+ return d.prior === 0 ? "First baseline week" : "";
2973
+ }
2974
+ if (d.deltaPct > 0) return `Up ${d.deltaPct}% ${windowLabel} (${formatNumber(d.prior)} ${suffix})`;
2975
+ if (d.deltaPct < 0) return `Down ${Math.abs(d.deltaPct)}% ${windowLabel} (${formatNumber(d.prior)} ${suffix})`;
2976
+ return `Flat ${windowLabel} (${formatNumber(d.prior)} ${suffix})`;
2977
+ }
2978
+ var MIN_PCT_BASE = 30;
2979
+ function round1(value) {
2980
+ return Math.round(value * 10) / 10;
2981
+ }
2982
+ function formatAverageDelta(d) {
2983
+ if (d.prior >= MIN_PCT_BASE && d.deltaPct !== null) {
2984
+ const sign2 = d.deltaPct > 0 ? "+" : "";
2985
+ return `${sign2}${d.deltaPct}% vs prior`;
2986
+ }
2987
+ const sign = d.deltaAbs > 0 ? "+" : "";
2988
+ return `${sign}${round1(d.deltaAbs)} vs ${round1(d.prior)}`;
2989
+ }
2990
+ function formatWindowCountDelta(d, countLabel, windowLabel) {
2991
+ if (d.prior >= MIN_PCT_BASE && d.deltaPct !== null) {
2992
+ const sign2 = d.deltaPct > 0 ? "+" : "";
2993
+ return `${sign2}${d.deltaPct}% ${windowLabel}`;
2994
+ }
2995
+ const sign = d.deltaAbs > 0 ? "+" : "";
2996
+ return `${sign}${formatNumber(Math.round(d.deltaAbs))} ${countLabel} ${windowLabel}`;
2997
+ }
2998
+
2999
+ // ../contracts/src/traffic-class.ts
3000
+ var aiReferralTrafficClassSchema = z21.enum(["organic", "paid"]);
3001
+ var AiReferralTrafficClasses = aiReferralTrafficClassSchema.enum;
3002
+ var PAID_CHANNEL_GROUPS = /* @__PURE__ */ new Set([
3003
+ "paid search",
3004
+ "paid social",
3005
+ "paid shopping",
3006
+ "paid video",
3007
+ "paid other",
3008
+ "display",
3009
+ "cross-network"
3010
+ ]);
3011
+ var PAID_SOURCE_OR_MEDIUM_VALUES = /* @__PURE__ */ new Set([
3012
+ "ad",
3013
+ "ads",
3014
+ "cpa",
3015
+ "cpc",
3016
+ "cpm",
3017
+ "cpv",
3018
+ "display",
3019
+ "openai-ads",
3020
+ "openai_ads",
3021
+ "paid",
3022
+ "paid-ai",
3023
+ "paid_ai",
3024
+ "paidai",
3025
+ "ppc",
3026
+ "retargeting",
3027
+ "sponsored"
3028
+ ]);
3029
+ var PAID_QUERY_PARAMS = ["utm_medium", "utm_campaign", "utm_content", "utm_term"];
3030
+ function normalizedTokens(value) {
3031
+ return (value ?? "").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
3032
+ }
3033
+ function hasPaidToken(value) {
3034
+ const normalized = (value ?? "").trim().toLowerCase();
3035
+ if (!normalized) return false;
3036
+ if (PAID_SOURCE_OR_MEDIUM_VALUES.has(normalized)) return true;
3037
+ return normalizedTokens(normalized).some((token) => PAID_SOURCE_OR_MEDIUM_VALUES.has(token));
3038
+ }
3039
+ function hasPaidLandingPageParam(landingPage) {
3040
+ if (!landingPage) return false;
3041
+ try {
3042
+ const url = new URL(landingPage, "https://canonry.local");
3043
+ return PAID_QUERY_PARAMS.some((key) => hasPaidToken(url.searchParams.get(key)));
3044
+ } catch {
3045
+ return false;
3046
+ }
3047
+ }
3048
+ function classifyAiReferralTrafficClass(input) {
3049
+ const channelGroup = (input.channelGroup ?? "").trim().toLowerCase();
3050
+ if (PAID_CHANNEL_GROUPS.has(channelGroup) || channelGroup.startsWith("paid ")) {
3051
+ return AiReferralTrafficClasses.paid;
3052
+ }
3053
+ if (hasPaidToken(input.medium) || hasPaidToken(input.source) || hasPaidLandingPageParam(input.landingPage)) {
3054
+ return AiReferralTrafficClasses.paid;
3055
+ }
3056
+ return AiReferralTrafficClasses.organic;
3057
+ }
3058
+ function aiReferralClassCounts(total, paid, organic) {
3059
+ return { total, paid, organic, unknown: Math.max(0, total - paid - organic) };
3060
+ }
3061
+ function formatAiReferralClassSummary(counts) {
3062
+ const parts = [];
3063
+ if (counts.paid > 0) parts.push(`Paid ${formatNumber(counts.paid)}`);
3064
+ if (counts.organic > 0) parts.push(`Organic ${formatNumber(counts.organic)}`);
3065
+ if (counts.unknown > 0) parts.push(`Unclassified ${formatNumber(counts.unknown)}`);
3066
+ return parts.join(" \xB7 ");
3067
+ }
3068
+
3069
+ // ../contracts/src/ga.ts
3070
+ var ga4ConnectionDtoSchema = z22.object({
3071
+ id: z22.string(),
3072
+ projectId: z22.string(),
3073
+ propertyId: z22.string(),
3074
+ clientEmail: z22.string(),
3075
+ connected: z22.boolean(),
3076
+ createdAt: z22.string(),
3077
+ updatedAt: z22.string()
3078
+ });
3079
+ var ga4TrafficSnapshotDtoSchema = z22.object({
3080
+ date: z22.string(),
3081
+ landingPage: z22.string(),
3082
+ sessions: z22.number(),
3083
+ organicSessions: z22.number(),
3084
+ users: z22.number()
3085
+ });
3086
+ var ga4SourceDimensionSchema = z22.enum(["session", "first_user", "manual_utm"]);
3087
+ var ga4AiReferralDtoSchema = z22.object({
3088
+ source: z22.string(),
3089
+ medium: z22.string(),
3090
+ trafficClass: aiReferralTrafficClassSchema,
3091
+ sessions: z22.number(),
3092
+ users: z22.number(),
2933
3093
  /**
2934
3094
  * The winning attribution dimension for this (source, medium) tuple — the
2935
3095
  * one with the highest session count. GA4 emits one row per dimension
@@ -2939,144 +3099,178 @@ var ga4AiReferralDtoSchema = z21.object({
2939
3099
  */
2940
3100
  sourceDimension: ga4SourceDimensionSchema
2941
3101
  });
2942
- var ga4AiReferralLandingPageDtoSchema = z21.object({
2943
- source: z21.string(),
2944
- medium: z21.string(),
3102
+ var ga4AiReferralLandingPageDtoSchema = z22.object({
3103
+ source: z22.string(),
3104
+ medium: z22.string(),
3105
+ trafficClass: aiReferralTrafficClassSchema,
2945
3106
  /**
2946
3107
  * The winning attribution dimension for this (source, medium, landingPage)
2947
3108
  * tuple — the one with the highest session count.
2948
3109
  */
2949
3110
  sourceDimension: ga4SourceDimensionSchema,
2950
- landingPage: z21.string(),
2951
- sessions: z21.number(),
2952
- users: z21.number()
2953
- });
2954
- var ga4SocialReferralDtoSchema = z21.object({
2955
- source: z21.string(),
2956
- medium: z21.string(),
2957
- sessions: z21.number(),
2958
- users: z21.number(),
3111
+ landingPage: z22.string(),
3112
+ sessions: z22.number(),
3113
+ users: z22.number()
3114
+ });
3115
+ var ga4SocialReferralDtoSchema = z22.object({
3116
+ source: z22.string(),
3117
+ medium: z22.string(),
3118
+ sessions: z22.number(),
3119
+ users: z22.number(),
2959
3120
  /** GA4 default channel group (e.g. 'Organic Social', 'Paid Social') */
2960
- channelGroup: z21.string()
3121
+ channelGroup: z22.string()
2961
3122
  });
2962
- var ga4ChannelBucketDtoSchema = z21.object({
2963
- sessions: z21.number(),
2964
- sharePct: z21.number(),
2965
- sharePctDisplay: z21.string()
3123
+ var ga4ChannelBucketDtoSchema = z22.object({
3124
+ sessions: z22.number(),
3125
+ sharePct: z22.number(),
3126
+ sharePctDisplay: z22.string()
2966
3127
  });
2967
- var ga4ChannelBreakdownDtoSchema = z21.object({
3128
+ var ga4ChannelBreakdownDtoSchema = z22.object({
2968
3129
  organic: ga4ChannelBucketDtoSchema,
2969
3130
  social: ga4ChannelBucketDtoSchema,
2970
3131
  direct: ga4ChannelBucketDtoSchema,
2971
3132
  ai: ga4ChannelBucketDtoSchema,
2972
3133
  other: ga4ChannelBucketDtoSchema
2973
3134
  });
2974
- var ga4TrafficSummaryDtoSchema = z21.object({
2975
- totalSessions: z21.number(),
2976
- totalOrganicSessions: z21.number(),
3135
+ var ga4TrafficSummaryDtoSchema = z22.object({
3136
+ totalSessions: z22.number(),
3137
+ totalOrganicSessions: z22.number(),
2977
3138
  /** Direct-channel sessions (sessions with no source — bookmarks, typed URLs, AI-driven traffic with stripped referrer). 0 for legacy rows from before the column was added. */
2978
- totalDirectSessions: z21.number(),
2979
- totalUsers: z21.number(),
2980
- topPages: z21.array(z21.object({
2981
- landingPage: z21.string(),
2982
- sessions: z21.number(),
2983
- organicSessions: z21.number(),
3139
+ totalDirectSessions: z22.number(),
3140
+ totalUsers: z22.number(),
3141
+ topPages: z22.array(z22.object({
3142
+ landingPage: z22.string(),
3143
+ sessions: z22.number(),
3144
+ organicSessions: z22.number(),
2984
3145
  /** Per-page Direct-channel sessions. 0 for legacy rows. */
2985
- directSessions: z21.number(),
2986
- users: z21.number()
3146
+ directSessions: z22.number(),
3147
+ users: z22.number()
2987
3148
  })),
2988
- aiReferrals: z21.array(ga4AiReferralDtoSchema),
2989
- aiReferralLandingPages: z21.array(ga4AiReferralLandingPageDtoSchema),
3149
+ aiReferrals: z22.array(ga4AiReferralDtoSchema),
3150
+ aiReferralLandingPages: z22.array(ga4AiReferralLandingPageDtoSchema),
2990
3151
  /** Deduped AI session total: MAX(sessions) per date+source+medium across attribution dimensions, then summed. Cross-cutting: can overlap with Direct/Organic/Social via firstUserSource. */
2991
- aiSessionsDeduped: z21.number(),
3152
+ aiSessionsDeduped: z22.number(),
2992
3153
  /** Deduped AI user total: MAX(users) per date+source+medium across attribution dimensions, then summed. */
2993
- aiUsersDeduped: z21.number(),
3154
+ aiUsersDeduped: z22.number(),
3155
+ /** Deduped AI sessions whose attribution carries paid intent. */
3156
+ paidAiSessionsDeduped: z22.number(),
3157
+ /** Deduped users for paid AI sessions. */
3158
+ paidAiUsersDeduped: z22.number(),
3159
+ /** Deduped AI sessions without paid intent evidence. */
3160
+ organicAiSessionsDeduped: z22.number(),
3161
+ /** Deduped users for organic/non-paid AI sessions. */
3162
+ organicAiUsersDeduped: z22.number(),
2994
3163
  /** AI sessions whose CURRENT sessionSource matched an AI engine. Can overlap with raw Organic/Social/Direct totals; `channelBreakdown` removes those overlaps for display. */
2995
- aiSessionsBySession: z21.number(),
3164
+ aiSessionsBySession: z22.number(),
2996
3165
  /** AI users whose CURRENT sessionSource matched an AI engine. Can overlap with raw Organic/Social/Direct totals. */
2997
- aiUsersBySession: z21.number(),
2998
- socialReferrals: z21.array(ga4SocialReferralDtoSchema),
3166
+ aiUsersBySession: z22.number(),
3167
+ /** Session-source-only paid AI sessions. */
3168
+ paidAiSessionsBySession: z22.number(),
3169
+ /** Session-source-only paid AI users. */
3170
+ paidAiUsersBySession: z22.number(),
3171
+ /** Session-source-only organic/non-paid AI sessions. */
3172
+ organicAiSessionsBySession: z22.number(),
3173
+ /** Session-source-only organic/non-paid AI users. */
3174
+ organicAiUsersBySession: z22.number(),
3175
+ socialReferrals: z22.array(ga4SocialReferralDtoSchema),
2999
3176
  /** Total social sessions (session-scoped, no cross-dimension dedup needed). */
3000
- socialSessions: z21.number(),
3177
+ socialSessions: z22.number(),
3001
3178
  /** Total social users (session-scoped, no cross-dimension dedup needed). */
3002
- socialUsers: z21.number(),
3179
+ socialUsers: z22.number(),
3003
3180
  /** Five disjoint buckets used for the channel breakdown. Known AI session-source matches are removed from their native GA4 bucket before shares are computed. */
3004
3181
  channelBreakdown: ga4ChannelBreakdownDtoSchema,
3005
3182
  /** Organic sessions as a percentage of total sessions (0–100, rounded). */
3006
- organicSharePct: z21.number(),
3183
+ organicSharePct: z22.number(),
3007
3184
  /** Deduped AI sessions as a percentage of total sessions (0–100, rounded). Cross-cutting: can overlap with Direct/Organic/Social. */
3008
- aiSharePct: z21.number(),
3185
+ aiSharePct: z22.number(),
3009
3186
  /** Session-source-only AI sessions as a percentage of total sessions (0–100, rounded). Can overlap with raw Organic/Social/Direct totals. */
3010
- aiSharePctBySession: z21.number(),
3187
+ aiSharePctBySession: z22.number(),
3188
+ /** Paid AI sessions as a percentage of total sessions (0–100, rounded). */
3189
+ paidAiSharePct: z22.number(),
3190
+ /** Session-source paid AI sessions as a percentage of total sessions (0–100, rounded). */
3191
+ paidAiSharePctBySession: z22.number(),
3192
+ /** Organic/non-paid AI sessions as a percentage of total sessions (0–100, rounded). */
3193
+ organicAiSharePct: z22.number(),
3194
+ /** Session-source organic/non-paid AI sessions as a percentage of total sessions (0–100, rounded). */
3195
+ organicAiSharePctBySession: z22.number(),
3011
3196
  /** Direct-channel sessions as a percentage of total sessions (0–100, rounded). */
3012
- directSharePct: z21.number(),
3197
+ directSharePct: z22.number(),
3013
3198
  /** Social sessions as a percentage of total sessions (0–100, rounded). */
3014
- socialSharePct: z21.number(),
3199
+ socialSharePct: z22.number(),
3015
3200
  /** Display string for organicSharePct: 'X%', '<1%' for non-zero shares that round below 1, or '—' when sessions exist but total is unknown (partial sync). */
3016
- organicSharePctDisplay: z21.string(),
3201
+ organicSharePctDisplay: z22.string(),
3017
3202
  /** Display string for aiSharePct: 'X%', '<1%' for non-zero shares that round below 1, or '—' when sessions exist but total is unknown (partial sync). */
3018
- aiSharePctDisplay: z21.string(),
3203
+ aiSharePctDisplay: z22.string(),
3019
3204
  /** Display string for aiSharePctBySession: 'X%', '<1%' for non-zero shares that round below 1, or '—' when sessions exist but total is unknown (partial sync). */
3020
- aiSharePctBySessionDisplay: z21.string(),
3205
+ aiSharePctBySessionDisplay: z22.string(),
3206
+ /** Display string for paidAiSharePct. */
3207
+ paidAiSharePctDisplay: z22.string(),
3208
+ /** Display string for paidAiSharePctBySession. */
3209
+ paidAiSharePctBySessionDisplay: z22.string(),
3210
+ /** Display string for organicAiSharePct. */
3211
+ organicAiSharePctDisplay: z22.string(),
3212
+ /** Display string for organicAiSharePctBySession. */
3213
+ organicAiSharePctBySessionDisplay: z22.string(),
3021
3214
  /** Display string for directSharePct: 'X%', '<1%' for non-zero shares that round below 1, or '—' when sessions exist but total is unknown (partial sync). */
3022
- directSharePctDisplay: z21.string(),
3215
+ directSharePctDisplay: z22.string(),
3023
3216
  /** Display string for socialSharePct: 'X%', '<1%' for non-zero shares that round below 1, or '—' when sessions exist but total is unknown (partial sync). */
3024
- socialSharePctDisplay: z21.string(),
3217
+ socialSharePctDisplay: z22.string(),
3025
3218
  /** Sessions not covered by Organic, Social, Direct, or AI (session) channels — e.g. Referral, Email, Paid Search, Display. Always non-negative; clamped to 0 when the four disjoint channels sum above total (rounding edge). */
3026
- otherSessions: z21.number(),
3219
+ otherSessions: z22.number(),
3027
3220
  /** Other sessions as a percentage of total sessions (0–100, rounded). */
3028
- otherSharePct: z21.number(),
3221
+ otherSharePct: z22.number(),
3029
3222
  /** Display string for otherSharePct: 'X%', '<1%' for non-zero shares that round below 1, or '—' when sessions exist but total is unknown (partial sync). */
3030
- otherSharePctDisplay: z21.string(),
3031
- lastSyncedAt: z21.string().nullable()
3032
- });
3033
- var ga4StatusDtoSchema = z21.object({
3034
- connected: z21.boolean(),
3035
- propertyId: z21.string().nullable(),
3036
- clientEmail: z21.string().nullable(),
3037
- authMethod: z21.enum(["service-account", "oauth"]).nullable(),
3038
- lastSyncedAt: z21.string().nullable(),
3039
- createdAt: z21.string().nullable().optional(),
3040
- updatedAt: z21.string().nullable().optional()
3041
- });
3042
- var ga4SyncResponseDtoSchema = z21.object({
3043
- synced: z21.boolean(),
3044
- rowCount: z21.number().int().nonnegative(),
3045
- aiReferralCount: z21.number().int().nonnegative(),
3046
- socialReferralCount: z21.number().int().nonnegative(),
3047
- days: z21.number().int().nonnegative(),
3048
- syncedAt: z21.string(),
3223
+ otherSharePctDisplay: z22.string(),
3224
+ lastSyncedAt: z22.string().nullable()
3225
+ });
3226
+ var ga4StatusDtoSchema = z22.object({
3227
+ connected: z22.boolean(),
3228
+ propertyId: z22.string().nullable(),
3229
+ clientEmail: z22.string().nullable(),
3230
+ authMethod: z22.enum(["service-account", "oauth"]).nullable(),
3231
+ lastSyncedAt: z22.string().nullable(),
3232
+ createdAt: z22.string().nullable().optional(),
3233
+ updatedAt: z22.string().nullable().optional()
3234
+ });
3235
+ var ga4SyncResponseDtoSchema = z22.object({
3236
+ synced: z22.boolean(),
3237
+ rowCount: z22.number().int().nonnegative(),
3238
+ aiReferralCount: z22.number().int().nonnegative(),
3239
+ socialReferralCount: z22.number().int().nonnegative(),
3240
+ days: z22.number().int().nonnegative(),
3241
+ syncedAt: z22.string(),
3049
3242
  /**
3050
3243
  * Components that were written this run. Present when `only` is set.
3051
3244
  * Always includes `traffic` and `summary` (the share denominator) plus
3052
3245
  * the requested channel breakdown — `ai` and/or `social`.
3053
3246
  */
3054
- syncedComponents: z21.array(z21.string()).optional()
3055
- });
3056
- var ga4AiReferralHistoryEntrySchema = z21.object({
3057
- date: z21.string(),
3058
- source: z21.string(),
3059
- medium: z21.string(),
3060
- landingPage: z21.string(),
3061
- sessions: z21.number(),
3062
- users: z21.number(),
3247
+ syncedComponents: z22.array(z22.string()).optional()
3248
+ });
3249
+ var ga4AiReferralHistoryEntrySchema = z22.object({
3250
+ date: z22.string(),
3251
+ source: z22.string(),
3252
+ medium: z22.string(),
3253
+ trafficClass: aiReferralTrafficClassSchema,
3254
+ landingPage: z22.string(),
3255
+ sessions: z22.number(),
3256
+ users: z22.number(),
3063
3257
  /** Which GA4 dimension this row came from: session (sessionSource), first_user (firstUserSource), or manual_utm (utm_source parameter) */
3064
3258
  sourceDimension: ga4SourceDimensionSchema
3065
3259
  });
3066
- var ga4SocialReferralHistoryEntrySchema = z21.object({
3067
- date: z21.string(),
3068
- source: z21.string(),
3069
- medium: z21.string(),
3070
- sessions: z21.number(),
3071
- users: z21.number(),
3260
+ var ga4SocialReferralHistoryEntrySchema = z22.object({
3261
+ date: z22.string(),
3262
+ source: z22.string(),
3263
+ medium: z22.string(),
3264
+ sessions: z22.number(),
3265
+ users: z22.number(),
3072
3266
  /** GA4 default channel group (e.g. 'Organic Social', 'Paid Social') */
3073
- channelGroup: z21.string()
3267
+ channelGroup: z22.string()
3074
3268
  });
3075
- var ga4SessionHistoryEntrySchema = z21.object({
3076
- date: z21.string(),
3077
- sessions: z21.number(),
3078
- organicSessions: z21.number(),
3079
- users: z21.number()
3269
+ var ga4SessionHistoryEntrySchema = z22.object({
3270
+ date: z22.string(),
3271
+ sessions: z22.number(),
3272
+ organicSessions: z22.number(),
3273
+ users: z22.number()
3080
3274
  });
3081
3275
 
3082
3276
  // ../contracts/src/answer-visibility.ts
@@ -3244,50 +3438,50 @@ function escapeRegExp(value) {
3244
3438
  }
3245
3439
 
3246
3440
  // ../contracts/src/agent.ts
3247
- import { z as z22 } from "zod";
3248
- var agentProviderIdSchema = z22.enum(["claude", "openai", "gemini", "zai", "deepinfra"]);
3249
- var agentProviderOptionDtoSchema = z22.object({
3441
+ import { z as z23 } from "zod";
3442
+ var agentProviderIdSchema = z23.enum(["claude", "openai", "gemini", "zai", "deepinfra"]);
3443
+ var agentProviderOptionDtoSchema = z23.object({
3250
3444
  /** Stable identifier — what clients pass back as `provider` on the prompt endpoint. */
3251
3445
  id: agentProviderIdSchema,
3252
3446
  /** Human-readable label for UI pickers, e.g. "Anthropic (Claude)". */
3253
- label: z22.string(),
3447
+ label: z23.string(),
3254
3448
  /** Default model if the caller doesn't pick one. */
3255
- defaultModel: z22.string(),
3449
+ defaultModel: z23.string(),
3256
3450
  /** Whether a usable API key was found (config.yaml or provider env var). */
3257
- configured: z22.boolean(),
3451
+ configured: z23.boolean(),
3258
3452
  /**
3259
3453
  * Where the key resolved from, if any. `null` when `configured === false`.
3260
3454
  * Surfaced so the UI can nudge users toward their preferred source of truth.
3261
3455
  */
3262
- keySource: z22.enum(["config", "env"]).nullable()
3456
+ keySource: z23.enum(["config", "env"]).nullable()
3263
3457
  });
3264
- var agentProvidersResponseDtoSchema = z22.object({
3458
+ var agentProvidersResponseDtoSchema = z23.object({
3265
3459
  /**
3266
3460
  * Every provider Aero knows about. `configured === false` entries are
3267
3461
  * included so the UI can render them disabled with an onboarding hint.
3268
3462
  */
3269
- providers: z22.array(agentProviderOptionDtoSchema).default([]),
3463
+ providers: z23.array(agentProviderOptionDtoSchema).default([]),
3270
3464
  /**
3271
3465
  * Provider Aero auto-picks when no explicit override is passed. Null if
3272
3466
  * nothing is configured (install never exchanged a key).
3273
3467
  */
3274
3468
  defaultProvider: agentProviderIdSchema.nullable()
3275
3469
  });
3276
- var memorySourceSchema = z22.enum(["aero", "user", "compaction"]);
3470
+ var memorySourceSchema = z23.enum(["aero", "user", "compaction"]);
3277
3471
  var MemorySources = memorySourceSchema.enum;
3278
3472
  var AGENT_MEMORY_VALUE_MAX_BYTES = 2 * 1024;
3279
3473
  var AGENT_MEMORY_KEY_MAX_LENGTH = 128;
3280
- var agentMemoryUpsertRequestSchema = z22.object({
3281
- key: z22.string().min(1).max(AGENT_MEMORY_KEY_MAX_LENGTH),
3282
- value: z22.string().min(1)
3474
+ var agentMemoryUpsertRequestSchema = z23.object({
3475
+ key: z23.string().min(1).max(AGENT_MEMORY_KEY_MAX_LENGTH),
3476
+ value: z23.string().min(1)
3283
3477
  });
3284
- var agentMemoryDeleteRequestSchema = z22.object({
3285
- key: z22.string().min(1).max(AGENT_MEMORY_KEY_MAX_LENGTH)
3478
+ var agentMemoryDeleteRequestSchema = z23.object({
3479
+ key: z23.string().min(1).max(AGENT_MEMORY_KEY_MAX_LENGTH)
3286
3480
  });
3287
3481
 
3288
3482
  // ../contracts/src/backlinks.ts
3289
- import { z as z23 } from "zod";
3290
- var backlinkSourceSchema = z23.enum(["commoncrawl", "bing-webmaster"]);
3483
+ import { z as z24 } from "zod";
3484
+ var backlinkSourceSchema = z24.enum(["commoncrawl", "bing-webmaster"]);
3291
3485
  var BacklinkSources = backlinkSourceSchema.enum;
3292
3486
  function computeBacklinkSummaryMetrics(rows) {
3293
3487
  if (rows.length === 0) {
@@ -3303,181 +3497,181 @@ function computeBacklinkSummaryMetrics(rows) {
3303
3497
  top10HostsShare: share.toFixed(6)
3304
3498
  };
3305
3499
  }
3306
- var ccReleaseSyncStatusSchema = z23.enum(["queued", "downloading", "querying", "ready", "failed"]);
3500
+ var ccReleaseSyncStatusSchema = z24.enum(["queued", "downloading", "querying", "ready", "failed"]);
3307
3501
  var CcReleaseSyncStatuses = ccReleaseSyncStatusSchema.enum;
3308
- var ccReleaseSyncDtoSchema = z23.object({
3309
- id: z23.string(),
3310
- release: z23.string(),
3502
+ var ccReleaseSyncDtoSchema = z24.object({
3503
+ id: z24.string(),
3504
+ release: z24.string(),
3311
3505
  status: ccReleaseSyncStatusSchema,
3312
- phaseDetail: z23.string().nullable().optional(),
3313
- vertexPath: z23.string().nullable().optional(),
3314
- edgesPath: z23.string().nullable().optional(),
3315
- vertexSha256: z23.string().nullable().optional(),
3316
- edgesSha256: z23.string().nullable().optional(),
3317
- vertexBytes: z23.number().int().nullable().optional(),
3318
- edgesBytes: z23.number().int().nullable().optional(),
3319
- projectsProcessed: z23.number().int().nullable().optional(),
3320
- domainsDiscovered: z23.number().int().nullable().optional(),
3321
- downloadStartedAt: z23.string().nullable().optional(),
3322
- downloadFinishedAt: z23.string().nullable().optional(),
3323
- queryStartedAt: z23.string().nullable().optional(),
3324
- queryFinishedAt: z23.string().nullable().optional(),
3325
- error: z23.string().nullable().optional(),
3326
- createdAt: z23.string(),
3327
- updatedAt: z23.string()
3328
- });
3329
- var backlinkDomainDtoSchema = z23.object({
3330
- linkingDomain: z23.string(),
3506
+ phaseDetail: z24.string().nullable().optional(),
3507
+ vertexPath: z24.string().nullable().optional(),
3508
+ edgesPath: z24.string().nullable().optional(),
3509
+ vertexSha256: z24.string().nullable().optional(),
3510
+ edgesSha256: z24.string().nullable().optional(),
3511
+ vertexBytes: z24.number().int().nullable().optional(),
3512
+ edgesBytes: z24.number().int().nullable().optional(),
3513
+ projectsProcessed: z24.number().int().nullable().optional(),
3514
+ domainsDiscovered: z24.number().int().nullable().optional(),
3515
+ downloadStartedAt: z24.string().nullable().optional(),
3516
+ downloadFinishedAt: z24.string().nullable().optional(),
3517
+ queryStartedAt: z24.string().nullable().optional(),
3518
+ queryFinishedAt: z24.string().nullable().optional(),
3519
+ error: z24.string().nullable().optional(),
3520
+ createdAt: z24.string(),
3521
+ updatedAt: z24.string()
3522
+ });
3523
+ var backlinkDomainDtoSchema = z24.object({
3524
+ linkingDomain: z24.string(),
3331
3525
  // For Common Crawl this is the count of distinct hosts within the linking
3332
3526
  // domain; for Bing Webmaster it is the count of distinct linking pages (URLs)
3333
3527
  // from that linking host. Read alongside `source` — the unit differs per source.
3334
- numHosts: z23.number().int(),
3528
+ numHosts: z24.number().int(),
3335
3529
  source: backlinkSourceSchema
3336
3530
  });
3337
- var backlinkSummaryDtoSchema = z23.object({
3338
- projectId: z23.string(),
3531
+ var backlinkSummaryDtoSchema = z24.object({
3532
+ projectId: z24.string(),
3339
3533
  // Window identifier. Common Crawl uses the release slug
3340
3534
  // (`cc-main-YYYY-<mon>-<mon>-<mon>`); Bing Webmaster uses a synthetic
3341
3535
  // per-sync-day window (`bing-YYYY-MM-DD`).
3342
- release: z23.string(),
3343
- targetDomain: z23.string(),
3344
- totalLinkingDomains: z23.number().int(),
3345
- totalHosts: z23.number().int(),
3346
- top10HostsShare: z23.string(),
3347
- queriedAt: z23.string(),
3536
+ release: z24.string(),
3537
+ targetDomain: z24.string(),
3538
+ totalLinkingDomains: z24.number().int(),
3539
+ totalHosts: z24.number().int(),
3540
+ top10HostsShare: z24.string(),
3541
+ queriedAt: z24.string(),
3348
3542
  source: backlinkSourceSchema,
3349
3543
  // Populated when the response is filtered (e.g. ?excludeCrawlers=1).
3350
3544
  // Counts the rows omitted from totalLinkingDomains/totalHosts so callers
3351
3545
  // can show "N hidden" hints without re-deriving them.
3352
- excludedLinkingDomains: z23.number().int().optional(),
3353
- excludedHosts: z23.number().int().optional()
3546
+ excludedLinkingDomains: z24.number().int().optional(),
3547
+ excludedHosts: z24.number().int().optional()
3354
3548
  });
3355
- var backlinkListResponseSchema = z23.object({
3549
+ var backlinkListResponseSchema = z24.object({
3356
3550
  // The source this response was filtered to (defaults to commoncrawl when the
3357
3551
  // caller omits `?source`).
3358
3552
  source: backlinkSourceSchema,
3359
3553
  summary: backlinkSummaryDtoSchema.nullable(),
3360
- total: z23.number().int(),
3361
- rows: z23.array(backlinkDomainDtoSchema)
3362
- });
3363
- var backlinkHistoryEntrySchema = z23.object({
3364
- release: z23.string(),
3365
- totalLinkingDomains: z23.number().int(),
3366
- totalHosts: z23.number().int(),
3367
- top10HostsShare: z23.string(),
3368
- queriedAt: z23.string(),
3554
+ total: z24.number().int(),
3555
+ rows: z24.array(backlinkDomainDtoSchema)
3556
+ });
3557
+ var backlinkHistoryEntrySchema = z24.object({
3558
+ release: z24.string(),
3559
+ totalLinkingDomains: z24.number().int(),
3560
+ totalHosts: z24.number().int(),
3561
+ top10HostsShare: z24.string(),
3562
+ queriedAt: z24.string(),
3369
3563
  source: backlinkSourceSchema
3370
3564
  });
3371
- var backlinkSourceAvailabilityDtoSchema = z23.object({
3565
+ var backlinkSourceAvailabilityDtoSchema = z24.object({
3372
3566
  source: backlinkSourceSchema,
3373
3567
  /**
3374
3568
  * The source is set up for this project:
3375
3569
  * - commoncrawl: `autoExtractBacklinks` enabled AND a `ready` release sync exists.
3376
3570
  * - bing-webmaster: a Bing Webmaster connection exists for the project domain.
3377
3571
  */
3378
- connected: z23.boolean(),
3572
+ connected: z24.boolean(),
3379
3573
  /** Backlink rows exist for this project + source. */
3380
- hasData: z23.boolean(),
3574
+ hasData: z24.boolean(),
3381
3575
  /** Latest window id with data for this source, null when none. */
3382
- latestRelease: z23.string().nullable(),
3576
+ latestRelease: z24.string().nullable(),
3383
3577
  /**
3384
3578
  * Linking-domain count in the latest window. Excludes crawler/proxy hosts only
3385
3579
  * when the request sets `?excludeCrawlers=1` (default off, matching the summary
3386
3580
  * and domains endpoints); the dashboard passes it so the switcher pill matches
3387
3581
  * the metric card.
3388
3582
  */
3389
- totalLinkingDomains: z23.number().int(),
3583
+ totalLinkingDomains: z24.number().int(),
3390
3584
  /** Freshness: `queriedAt` of the latest summary for this source, null when none. */
3391
- lastSyncedAt: z23.string().nullable()
3585
+ lastSyncedAt: z24.string().nullable()
3392
3586
  });
3393
- var backlinkSourcesResponseSchema = z23.object({
3394
- projectId: z23.string(),
3395
- targetDomain: z23.string(),
3587
+ var backlinkSourcesResponseSchema = z24.object({
3588
+ projectId: z24.string(),
3589
+ targetDomain: z24.string(),
3396
3590
  /** Availability for every known source, in a stable order. */
3397
- sources: z23.array(backlinkSourceAvailabilityDtoSchema),
3398
- anyConnected: z23.boolean(),
3399
- anyData: z23.boolean()
3400
- });
3401
- var backlinksInstallStatusDtoSchema = z23.object({
3402
- duckdbInstalled: z23.boolean(),
3403
- duckdbVersion: z23.string().nullable().optional(),
3404
- duckdbSpec: z23.string(),
3405
- pluginDir: z23.string()
3406
- });
3407
- var backlinksInstallResultDtoSchema = z23.object({
3408
- installed: z23.boolean(),
3409
- version: z23.string(),
3410
- path: z23.string(),
3411
- alreadyPresent: z23.boolean()
3412
- });
3413
- var ccAvailableReleaseSchema = z23.object({
3414
- release: z23.string(),
3415
- vertexUrl: z23.string(),
3416
- edgesUrl: z23.string(),
3417
- vertexBytes: z23.number().int().nullable(),
3418
- edgesBytes: z23.number().int().nullable(),
3419
- lastModified: z23.string().nullable()
3420
- });
3421
- var ccCachedReleaseSchema = z23.object({
3422
- release: z23.string(),
3591
+ sources: z24.array(backlinkSourceAvailabilityDtoSchema),
3592
+ anyConnected: z24.boolean(),
3593
+ anyData: z24.boolean()
3594
+ });
3595
+ var backlinksInstallStatusDtoSchema = z24.object({
3596
+ duckdbInstalled: z24.boolean(),
3597
+ duckdbVersion: z24.string().nullable().optional(),
3598
+ duckdbSpec: z24.string(),
3599
+ pluginDir: z24.string()
3600
+ });
3601
+ var backlinksInstallResultDtoSchema = z24.object({
3602
+ installed: z24.boolean(),
3603
+ version: z24.string(),
3604
+ path: z24.string(),
3605
+ alreadyPresent: z24.boolean()
3606
+ });
3607
+ var ccAvailableReleaseSchema = z24.object({
3608
+ release: z24.string(),
3609
+ vertexUrl: z24.string(),
3610
+ edgesUrl: z24.string(),
3611
+ vertexBytes: z24.number().int().nullable(),
3612
+ edgesBytes: z24.number().int().nullable(),
3613
+ lastModified: z24.string().nullable()
3614
+ });
3615
+ var ccCachedReleaseSchema = z24.object({
3616
+ release: z24.string(),
3423
3617
  syncStatus: ccReleaseSyncStatusSchema.nullable(),
3424
- bytes: z23.number().int(),
3425
- lastUsedAt: z23.string().nullable()
3618
+ bytes: z24.number().int(),
3619
+ lastUsedAt: z24.string().nullable()
3426
3620
  });
3427
3621
 
3428
3622
  // ../contracts/src/composites.ts
3429
- import { z as z24 } from "zod";
3430
- var metricToneSchema = z24.enum(["positive", "caution", "negative", "neutral"]);
3431
- var scoreSummarySchema = z24.object({
3432
- label: z24.string(),
3433
- value: z24.string(),
3434
- delta: z24.string(),
3623
+ import { z as z25 } from "zod";
3624
+ var metricToneSchema = z25.enum(["positive", "caution", "negative", "neutral"]);
3625
+ var scoreSummarySchema = z25.object({
3626
+ label: z25.string(),
3627
+ value: z25.string(),
3628
+ delta: z25.string(),
3435
3629
  tone: metricToneSchema,
3436
- description: z24.string(),
3437
- tooltip: z24.string().optional(),
3438
- trend: z24.array(z24.number()),
3439
- progress: z24.number().optional(),
3440
- providerCoverage: z24.string().optional()
3630
+ description: z25.string(),
3631
+ tooltip: z25.string().optional(),
3632
+ trend: z25.array(z25.number()),
3633
+ progress: z25.number().optional(),
3634
+ providerCoverage: z25.string().optional()
3441
3635
  });
3442
3636
  var mentionShareSchema = scoreSummarySchema.extend({
3443
- breakdown: z24.object({
3444
- projectMentionSnapshots: z24.number().int().nonnegative(),
3445
- competitorMentionSnapshots: z24.number().int().nonnegative(),
3446
- perCompetitor: z24.array(z24.object({
3447
- domain: z24.string(),
3448
- mentionSnapshots: z24.number().int().nonnegative(),
3449
- shareOfCompetitiveTotal: z24.number()
3637
+ breakdown: z25.object({
3638
+ projectMentionSnapshots: z25.number().int().nonnegative(),
3639
+ competitorMentionSnapshots: z25.number().int().nonnegative(),
3640
+ perCompetitor: z25.array(z25.object({
3641
+ domain: z25.string(),
3642
+ mentionSnapshots: z25.number().int().nonnegative(),
3643
+ shareOfCompetitiveTotal: z25.number()
3450
3644
  })),
3451
- snapshotsWithAnswerText: z24.number().int().nonnegative(),
3452
- snapshotsTotal: z24.number().int().nonnegative()
3645
+ snapshotsWithAnswerText: z25.number().int().nonnegative(),
3646
+ snapshotsTotal: z25.number().int().nonnegative()
3453
3647
  })
3454
3648
  });
3455
- var movementSummarySchema = z24.object({
3456
- gained: z24.number().int().nonnegative(),
3457
- lost: z24.number().int().nonnegative(),
3649
+ var movementSummarySchema = z25.object({
3650
+ gained: z25.number().int().nonnegative(),
3651
+ lost: z25.number().int().nonnegative(),
3458
3652
  tone: metricToneSchema,
3459
- hasPreviousRun: z24.boolean(),
3460
- gainedQueries: z24.array(z24.string()).optional(),
3461
- lostQueries: z24.array(z24.string()).optional()
3462
- });
3463
- var movementComparisonSchema = z24.object({
3464
- hasPreviousRun: z24.boolean(),
3465
- comparable: z24.boolean(),
3466
- querySetChanged: z24.boolean(),
3467
- previousRunAt: z24.string().nullable(),
3468
- currentQueryCount: z24.number().int().nonnegative(),
3469
- previousQueryCount: z24.number().int().nonnegative(),
3470
- comparableQueryCount: z24.number().int().nonnegative(),
3471
- addedQueryCount: z24.number().int().nonnegative(),
3472
- removedQueryCount: z24.number().int().nonnegative(),
3473
- addedQueries: z24.array(z24.string()),
3474
- removedQueries: z24.array(z24.string())
3475
- });
3476
- var projectOverviewInsightSchema = z24.object({
3477
- id: z24.string(),
3478
- projectId: z24.string(),
3479
- runId: z24.string().nullable(),
3480
- type: z24.enum([
3653
+ hasPreviousRun: z25.boolean(),
3654
+ gainedQueries: z25.array(z25.string()).optional(),
3655
+ lostQueries: z25.array(z25.string()).optional()
3656
+ });
3657
+ var movementComparisonSchema = z25.object({
3658
+ hasPreviousRun: z25.boolean(),
3659
+ comparable: z25.boolean(),
3660
+ querySetChanged: z25.boolean(),
3661
+ previousRunAt: z25.string().nullable(),
3662
+ currentQueryCount: z25.number().int().nonnegative(),
3663
+ previousQueryCount: z25.number().int().nonnegative(),
3664
+ comparableQueryCount: z25.number().int().nonnegative(),
3665
+ addedQueryCount: z25.number().int().nonnegative(),
3666
+ removedQueryCount: z25.number().int().nonnegative(),
3667
+ addedQueries: z25.array(z25.string()),
3668
+ removedQueries: z25.array(z25.string())
3669
+ });
3670
+ var projectOverviewInsightSchema = z25.object({
3671
+ id: z25.string(),
3672
+ projectId: z25.string(),
3673
+ runId: z25.string().nullable(),
3674
+ type: z25.enum([
3481
3675
  "regression",
3482
3676
  "gain",
3483
3677
  "opportunity",
@@ -3493,70 +3687,70 @@ var projectOverviewInsightSchema = z24.object({
3493
3687
  "gbp-metric-drop",
3494
3688
  "gbp-keyword-drop"
3495
3689
  ]),
3496
- severity: z24.enum(["critical", "high", "medium", "low"]),
3497
- title: z24.string(),
3498
- query: z24.string(),
3499
- provider: z24.string(),
3500
- recommendation: z24.object({
3501
- action: z24.string(),
3502
- target: z24.string().optional(),
3503
- reason: z24.string()
3690
+ severity: z25.enum(["critical", "high", "medium", "low"]),
3691
+ title: z25.string(),
3692
+ query: z25.string(),
3693
+ provider: z25.string(),
3694
+ recommendation: z25.object({
3695
+ action: z25.string(),
3696
+ target: z25.string().optional(),
3697
+ reason: z25.string()
3504
3698
  }).optional(),
3505
- cause: z24.object({
3506
- cause: z24.string(),
3507
- competitorDomain: z24.string().optional(),
3508
- details: z24.string().optional()
3699
+ cause: z25.object({
3700
+ cause: z25.string(),
3701
+ competitorDomain: z25.string().optional(),
3702
+ details: z25.string().optional()
3509
3703
  }).optional(),
3510
- dismissed: z24.boolean(),
3511
- createdAt: z24.string()
3512
- });
3513
- var projectOverviewHealthSchema = z24.object({
3514
- id: z24.string(),
3515
- projectId: z24.string(),
3516
- runId: z24.string().nullable(),
3517
- overallCitedRate: z24.number(),
3518
- overallMentionRate: z24.number(),
3519
- totalPairs: z24.number().int().nonnegative(),
3520
- citedPairs: z24.number().int().nonnegative(),
3521
- mentionedPairs: z24.number().int().nonnegative(),
3522
- providerBreakdown: z24.record(z24.string(), z24.object({
3523
- citedRate: z24.number(),
3524
- mentionRate: z24.number(),
3525
- cited: z24.number().int().nonnegative(),
3526
- mentioned: z24.number().int().nonnegative(),
3527
- total: z24.number().int().nonnegative()
3704
+ dismissed: z25.boolean(),
3705
+ createdAt: z25.string()
3706
+ });
3707
+ var projectOverviewHealthSchema = z25.object({
3708
+ id: z25.string(),
3709
+ projectId: z25.string(),
3710
+ runId: z25.string().nullable(),
3711
+ overallCitedRate: z25.number(),
3712
+ overallMentionRate: z25.number(),
3713
+ totalPairs: z25.number().int().nonnegative(),
3714
+ citedPairs: z25.number().int().nonnegative(),
3715
+ mentionedPairs: z25.number().int().nonnegative(),
3716
+ providerBreakdown: z25.record(z25.string(), z25.object({
3717
+ citedRate: z25.number(),
3718
+ mentionRate: z25.number(),
3719
+ cited: z25.number().int().nonnegative(),
3720
+ mentioned: z25.number().int().nonnegative(),
3721
+ total: z25.number().int().nonnegative()
3528
3722
  })),
3529
- createdAt: z24.string(),
3530
- status: z24.enum(["ready", "no-data"]),
3531
- reason: z24.literal("no-runs-yet").optional()
3723
+ createdAt: z25.string(),
3724
+ status: z25.enum(["ready", "no-data"]),
3725
+ reason: z25.literal("no-runs-yet").optional()
3532
3726
  });
3533
- var projectOverviewDtoSchema = z24.object({
3727
+ var projectOverviewDtoSchema = z25.object({
3534
3728
  project: projectDtoSchema,
3535
3729
  latestRun: latestProjectRunDtoSchema,
3536
3730
  health: projectOverviewHealthSchema.nullable(),
3537
- topInsights: z24.array(projectOverviewInsightSchema),
3538
- queryCounts: z24.object({
3539
- totalQueries: z24.number().int().nonnegative(),
3540
- citedQueries: z24.number().int().nonnegative(),
3541
- notCitedQueries: z24.number().int().nonnegative(),
3542
- citedRate: z24.number(),
3543
- mentionedQueries: z24.number().int().nonnegative(),
3544
- notMentionedQueries: z24.number().int().nonnegative(),
3545
- mentionRate: z24.number()
3731
+ topInsights: z25.array(projectOverviewInsightSchema),
3732
+ queryCounts: z25.object({
3733
+ totalQueries: z25.number().int().nonnegative(),
3734
+ citedQueries: z25.number().int().nonnegative(),
3735
+ notCitedQueries: z25.number().int().nonnegative(),
3736
+ citedRate: z25.number(),
3737
+ mentionedQueries: z25.number().int().nonnegative(),
3738
+ notMentionedQueries: z25.number().int().nonnegative(),
3739
+ mentionRate: z25.number()
3546
3740
  }),
3547
- providers: z24.array(z24.object({
3548
- provider: z24.string(),
3549
- citedRate: z24.number(),
3550
- cited: z24.number().int().nonnegative(),
3551
- total: z24.number().int().nonnegative()
3741
+ providers: z25.array(z25.object({
3742
+ provider: z25.string(),
3743
+ citedRate: z25.number(),
3744
+ cited: z25.number().int().nonnegative(),
3745
+ total: z25.number().int().nonnegative()
3552
3746
  })),
3553
- transitions: z24.object({
3554
- since: z24.string().nullable(),
3555
- gained: z24.number().int().nonnegative(),
3556
- lost: z24.number().int().nonnegative(),
3557
- emerging: z24.number().int().nonnegative()
3747
+ transitions: z25.object({
3748
+ since: z25.string().nullable(),
3749
+ gained: z25.number().int().nonnegative(),
3750
+ lost: z25.number().int().nonnegative(),
3751
+ emerging: z25.number().int().nonnegative()
3558
3752
  }),
3559
- scores: z24.object({
3753
+ scores: z25.object({
3560
3754
  mention: scoreSummarySchema,
3561
3755
  visibility: scoreSummarySchema,
3562
3756
  mentionShare: mentionShareSchema,
@@ -3570,72 +3764,72 @@ var projectOverviewDtoSchema = z24.object({
3570
3764
  citationMovement: movementSummarySchema,
3571
3765
  mentionMovement: movementSummarySchema,
3572
3766
  movementComparison: movementComparisonSchema,
3573
- competitors: z24.array(z24.object({
3574
- id: z24.string(),
3575
- domain: z24.string(),
3576
- citationCount: z24.number().int().nonnegative(),
3577
- totalQueries: z24.number().int().nonnegative(),
3578
- pressureLabel: z24.enum(["None", "Low", "Moderate", "High"]),
3579
- citedQueries: z24.array(z24.string())
3767
+ competitors: z25.array(z25.object({
3768
+ id: z25.string(),
3769
+ domain: z25.string(),
3770
+ citationCount: z25.number().int().nonnegative(),
3771
+ totalQueries: z25.number().int().nonnegative(),
3772
+ pressureLabel: z25.enum(["None", "Low", "Moderate", "High"]),
3773
+ citedQueries: z25.array(z25.string())
3580
3774
  })),
3581
- providerScores: z24.array(z24.object({
3582
- provider: z24.string(),
3583
- model: z24.string().nullable(),
3584
- score: z24.number(),
3585
- cited: z24.number().int().nonnegative(),
3586
- total: z24.number().int().nonnegative(),
3587
- trend: z24.array(z24.number()).optional()
3775
+ providerScores: z25.array(z25.object({
3776
+ provider: z25.string(),
3777
+ model: z25.string().nullable(),
3778
+ score: z25.number(),
3779
+ cited: z25.number().int().nonnegative(),
3780
+ total: z25.number().int().nonnegative(),
3781
+ trend: z25.array(z25.number()).optional()
3588
3782
  })),
3589
- attentionItems: z24.array(z24.object({
3590
- id: z24.string(),
3783
+ attentionItems: z25.array(z25.object({
3784
+ id: z25.string(),
3591
3785
  tone: metricToneSchema,
3592
- title: z24.string(),
3593
- detail: z24.string(),
3594
- actionLabel: z24.string(),
3595
- href: z24.string()
3786
+ title: z25.string(),
3787
+ detail: z25.string(),
3788
+ actionLabel: z25.string(),
3789
+ href: z25.string()
3596
3790
  })),
3597
- runHistory: z24.array(z24.object({
3598
- runId: z24.string(),
3599
- createdAt: z24.string(),
3600
- citedCount: z24.number().int().nonnegative(),
3601
- totalCount: z24.number().int().nonnegative(),
3602
- citationRate: z24.number(),
3603
- mentionedCount: z24.number().int().nonnegative(),
3604
- mentionRate: z24.number(),
3605
- status: z24.string()
3791
+ runHistory: z25.array(z25.object({
3792
+ runId: z25.string(),
3793
+ createdAt: z25.string(),
3794
+ citedCount: z25.number().int().nonnegative(),
3795
+ totalCount: z25.number().int().nonnegative(),
3796
+ citationRate: z25.number(),
3797
+ mentionedCount: z25.number().int().nonnegative(),
3798
+ mentionRate: z25.number(),
3799
+ status: z25.string()
3606
3800
  })),
3607
- suggestedQueries: z24.object({
3608
- rows: z24.array(z24.object({
3609
- query: z24.string(),
3610
- impressions: z24.number(),
3611
- clicks: z24.number(),
3612
- avgPosition: z24.number(),
3613
- reason: z24.string()
3801
+ suggestedQueries: z25.object({
3802
+ rows: z25.array(z25.object({
3803
+ query: z25.string(),
3804
+ impressions: z25.number(),
3805
+ clicks: z25.number(),
3806
+ avgPosition: z25.number(),
3807
+ reason: z25.string()
3614
3808
  })),
3615
- totalCandidates: z24.number().int().nonnegative(),
3616
- skippedAlreadyTracked: z24.number().int().nonnegative()
3809
+ totalCandidates: z25.number().int().nonnegative(),
3810
+ skippedAlreadyTracked: z25.number().int().nonnegative()
3617
3811
  }),
3618
- dateRangeLabel: z24.string(),
3619
- contextLabel: z24.string()
3620
- });
3621
- var searchHitKindSchema = z24.enum(["snapshot", "insight"]);
3622
- var projectSearchSnapshotHitSchema = z24.object({
3623
- kind: z24.literal("snapshot"),
3624
- id: z24.string(),
3625
- runId: z24.string(),
3626
- query: z24.string(),
3627
- provider: z24.string(),
3628
- model: z24.string().nullable(),
3812
+ dateRangeLabel: z25.string(),
3813
+ contextLabel: z25.string()
3814
+ });
3815
+ var searchHitKindSchema = z25.enum(["snapshot", "insight"]);
3816
+ var projectSearchSnapshotHitSchema = z25.object({
3817
+ kind: z25.literal("snapshot"),
3818
+ id: z25.string(),
3819
+ runId: z25.string(),
3820
+ query: z25.string(),
3821
+ provider: z25.string(),
3822
+ model: z25.string().nullable(),
3629
3823
  citationState: citationStateSchema,
3630
- matchedField: z24.enum(["answerText", "citedDomains", "searchQueries", "query"]),
3631
- snippet: z24.string(),
3632
- createdAt: z24.string()
3633
- });
3634
- var projectSearchInsightHitSchema = z24.object({
3635
- kind: z24.literal("insight"),
3636
- id: z24.string(),
3637
- runId: z24.string().nullable(),
3638
- type: z24.enum([
3824
+ matchedField: z25.enum(["answerText", "citedDomains", "searchQueries", "query"]),
3825
+ snippet: z25.string(),
3826
+ createdAt: z25.string()
3827
+ });
3828
+ var projectSearchInsightHitSchema = z25.object({
3829
+ kind: z25.literal("insight"),
3830
+ id: z25.string(),
3831
+ runId: z25.string().nullable(),
3832
+ type: z25.enum([
3639
3833
  "regression",
3640
3834
  "gain",
3641
3835
  "opportunity",
@@ -3652,29 +3846,29 @@ var projectSearchInsightHitSchema = z24.object({
3652
3846
  "gbp-metric-drop",
3653
3847
  "gbp-keyword-drop"
3654
3848
  ]),
3655
- severity: z24.enum(["critical", "high", "medium", "low"]),
3656
- title: z24.string(),
3657
- query: z24.string(),
3658
- provider: z24.string(),
3659
- matchedField: z24.enum(["title", "query", "recommendation", "cause"]),
3660
- snippet: z24.string(),
3661
- dismissed: z24.boolean(),
3662
- createdAt: z24.string()
3663
- });
3664
- var projectSearchHitSchema = z24.discriminatedUnion("kind", [
3849
+ severity: z25.enum(["critical", "high", "medium", "low"]),
3850
+ title: z25.string(),
3851
+ query: z25.string(),
3852
+ provider: z25.string(),
3853
+ matchedField: z25.enum(["title", "query", "recommendation", "cause"]),
3854
+ snippet: z25.string(),
3855
+ dismissed: z25.boolean(),
3856
+ createdAt: z25.string()
3857
+ });
3858
+ var projectSearchHitSchema = z25.discriminatedUnion("kind", [
3665
3859
  projectSearchSnapshotHitSchema,
3666
3860
  projectSearchInsightHitSchema
3667
3861
  ]);
3668
- var projectSearchResponseSchema = z24.object({
3669
- query: z24.string(),
3670
- totalHits: z24.number().int().nonnegative(),
3671
- truncated: z24.boolean(),
3672
- hits: z24.array(projectSearchHitSchema)
3862
+ var projectSearchResponseSchema = z25.object({
3863
+ query: z25.string(),
3864
+ totalHits: z25.number().int().nonnegative(),
3865
+ truncated: z25.boolean(),
3866
+ hits: z25.array(projectSearchHitSchema)
3673
3867
  });
3674
3868
 
3675
3869
  // ../contracts/src/content.ts
3676
- import { z as z25 } from "zod";
3677
- var contentActionSchema = z25.enum(["create", "expand", "refresh", "add-schema"]);
3870
+ import { z as z26 } from "zod";
3871
+ var contentActionSchema = z26.enum(["create", "expand", "refresh", "add-schema"]);
3678
3872
  var ContentActions = contentActionSchema.enum;
3679
3873
  function contentActionLabel(action) {
3680
3874
  switch (action) {
@@ -3688,9 +3882,9 @@ function contentActionLabel(action) {
3688
3882
  return "Add schema";
3689
3883
  }
3690
3884
  }
3691
- var demandSourceSchema = z25.enum(["gsc", "competitor-evidence", "both"]);
3885
+ var demandSourceSchema = z26.enum(["gsc", "competitor-evidence", "both"]);
3692
3886
  var DemandSources = demandSourceSchema.enum;
3693
- var actionConfidenceSchema = z25.enum(["high", "medium", "low"]);
3887
+ var actionConfidenceSchema = z26.enum(["high", "medium", "low"]);
3694
3888
  var ActionConfidences = actionConfidenceSchema.enum;
3695
3889
  function actionConfidenceLabel(confidence) {
3696
3890
  switch (confidence) {
@@ -3702,7 +3896,7 @@ function actionConfidenceLabel(confidence) {
3702
3896
  return "Low";
3703
3897
  }
3704
3898
  }
3705
- var pageTypeSchema = z25.enum([
3899
+ var pageTypeSchema = z26.enum([
3706
3900
  "blog-post",
3707
3901
  "comparison",
3708
3902
  "listicle",
@@ -3711,7 +3905,7 @@ var pageTypeSchema = z25.enum([
3711
3905
  "glossary"
3712
3906
  ]);
3713
3907
  var PageTypes = pageTypeSchema.enum;
3714
- var contentActionStateSchema = z25.enum([
3908
+ var contentActionStateSchema = z26.enum([
3715
3909
  "proposed",
3716
3910
  "briefed",
3717
3911
  "payload-generated",
@@ -3721,7 +3915,7 @@ var contentActionStateSchema = z25.enum([
3721
3915
  "dismissed"
3722
3916
  ]);
3723
3917
  var ContentActionStates = contentActionStateSchema.enum;
3724
- var winnabilityClassSchema = z25.enum(["ownable", "ceded"]);
3918
+ var winnabilityClassSchema = z26.enum(["ownable", "ceded"]);
3725
3919
  var WinnabilityClasses = winnabilityClassSchema.enum;
3726
3920
  function winnabilityClassLabel(winnabilityClass) {
3727
3921
  switch (winnabilityClass) {
@@ -3756,40 +3950,40 @@ function deriveWinnabilityClass(citedSurfaceDomains, surfaceClasses, threshold =
3756
3950
  winnability
3757
3951
  };
3758
3952
  }
3759
- var ourBestPageSchema = z25.object({
3760
- url: z25.string(),
3761
- gscImpressions: z25.number().nonnegative(),
3762
- gscClicks: z25.number().nonnegative(),
3953
+ var ourBestPageSchema = z26.object({
3954
+ url: z26.string(),
3955
+ gscImpressions: z26.number().nonnegative(),
3956
+ gscClicks: z26.number().nonnegative(),
3763
3957
  // Null when the page came from the inventory fallback (no GSC ranking data).
3764
- gscAvgPosition: z25.number().nonnegative().nullable(),
3765
- organicSessions: z25.number().nonnegative()
3958
+ gscAvgPosition: z26.number().nonnegative().nullable(),
3959
+ organicSessions: z26.number().nonnegative()
3766
3960
  });
3767
- var winningCompetitorSchema = z25.object({
3768
- domain: z25.string(),
3769
- url: z25.string(),
3770
- title: z25.string(),
3771
- citationCount: z25.number().int().nonnegative()
3961
+ var winningCompetitorSchema = z26.object({
3962
+ domain: z26.string(),
3963
+ url: z26.string(),
3964
+ title: z26.string(),
3965
+ citationCount: z26.number().int().nonnegative()
3772
3966
  });
3773
- var scoreBreakdownSchema = z25.object({
3774
- demand: z25.number(),
3775
- competitor: z25.number(),
3776
- absence: z25.number(),
3777
- gapSeverity: z25.number()
3967
+ var scoreBreakdownSchema = z26.object({
3968
+ demand: z26.number(),
3969
+ competitor: z26.number(),
3970
+ absence: z26.number(),
3971
+ gapSeverity: z26.number()
3778
3972
  });
3779
- var existingActionRefSchema = z25.object({
3780
- actionId: z25.string(),
3973
+ var existingActionRefSchema = z26.object({
3974
+ actionId: z26.string(),
3781
3975
  state: contentActionStateSchema,
3782
- lastUpdated: z25.string()
3976
+ lastUpdated: z26.string()
3783
3977
  });
3784
- var contentTargetRowDtoSchema = z25.object({
3785
- targetRef: z25.string(),
3786
- query: z25.string(),
3978
+ var contentTargetRowDtoSchema = z26.object({
3979
+ targetRef: z26.string(),
3980
+ query: z26.string(),
3787
3981
  action: contentActionSchema,
3788
3982
  ourBestPage: ourBestPageSchema.nullable(),
3789
3983
  winningCompetitor: winningCompetitorSchema.nullable(),
3790
- score: z25.number(),
3984
+ score: z26.number(),
3791
3985
  scoreBreakdown: scoreBreakdownSchema,
3792
- drivers: z25.array(z25.string()),
3986
+ drivers: z26.array(z26.string()),
3793
3987
  demandSource: demandSourceSchema,
3794
3988
  actionConfidence: actionConfidenceSchema,
3795
3989
  existingAction: existingActionRefSchema.nullable(),
@@ -3804,134 +3998,134 @@ var contentTargetRowDtoSchema = z25.object({
3804
3998
  * `[0, 1]`. `null` when the gate failed open (no classification coverage for
3805
3999
  * the cited surface) — distinct from a computed `1.0`.
3806
4000
  */
3807
- winnability: z25.number().min(0).max(1).nullable()
3808
- });
3809
- var contentTargetsResponseDtoSchema = z25.object({
3810
- targets: z25.array(contentTargetRowDtoSchema),
3811
- contextMetrics: z25.object({
3812
- totalAiReferralSessions: z25.number().int().nonnegative(),
3813
- latestRunId: z25.string(),
3814
- runTimestamp: z25.string()
4001
+ winnability: z26.number().min(0).max(1).nullable()
4002
+ });
4003
+ var contentTargetsResponseDtoSchema = z26.object({
4004
+ targets: z26.array(contentTargetRowDtoSchema),
4005
+ contextMetrics: z26.object({
4006
+ totalAiReferralSessions: z26.number().int().nonnegative(),
4007
+ latestRunId: z26.string(),
4008
+ runTimestamp: z26.string()
3815
4009
  })
3816
4010
  });
3817
- var contentTargetDismissalDtoSchema = z25.object({
3818
- targetRef: z25.string(),
3819
- addressedUrl: z25.string().nullable(),
3820
- note: z25.string().nullable(),
3821
- dismissedAt: z25.string()
4011
+ var contentTargetDismissalDtoSchema = z26.object({
4012
+ targetRef: z26.string(),
4013
+ addressedUrl: z26.string().nullable(),
4014
+ note: z26.string().nullable(),
4015
+ dismissedAt: z26.string()
3822
4016
  });
3823
- var contentTargetDismissalsResponseDtoSchema = z25.object({
3824
- dismissals: z25.array(contentTargetDismissalDtoSchema)
4017
+ var contentTargetDismissalsResponseDtoSchema = z26.object({
4018
+ dismissals: z26.array(contentTargetDismissalDtoSchema)
3825
4019
  });
3826
- var contentTargetDismissRequestSchema = z25.object({
3827
- targetRef: z25.string().min(1),
4020
+ var contentTargetDismissRequestSchema = z26.object({
4021
+ targetRef: z26.string().min(1),
3828
4022
  /** URL of the page the user wrote that addresses this recommendation. Stored verbatim for the audit trail; not currently used to suppress the slug-token matcher. */
3829
- addressedUrl: z25.string().url().optional(),
4023
+ addressedUrl: z26.string().url().optional(),
3830
4024
  /** Free-form note (e.g. "covered in our Q1 content sprint"). 500 char cap is the API surface limit; the DB column is unbounded. */
3831
- note: z25.string().max(500).optional()
4025
+ note: z26.string().max(500).optional()
3832
4026
  });
3833
- var recommendationExplanationDtoSchema = z25.object({
3834
- targetRef: z25.string(),
4027
+ var recommendationExplanationDtoSchema = z26.object({
4028
+ targetRef: z26.string(),
3835
4029
  /** Version of the prompt template used. Bumping the version invalidates the cache forward without touching the table. */
3836
- promptVersion: z25.string(),
4030
+ promptVersion: z26.string(),
3837
4031
  /** Provider that produced the explanation (e.g. "claude", "gemini"). */
3838
- provider: z25.string(),
4032
+ provider: z26.string(),
3839
4033
  /** Model id within that provider (e.g. "claude-sonnet-4-6"). */
3840
- model: z25.string(),
4034
+ model: z26.string(),
3841
4035
  /** Markdown-formatted rationale + recommended next steps. */
3842
- responseText: z25.string(),
4036
+ responseText: z26.string(),
3843
4037
  /** Estimated cost in millicents (1/100 of a cent). 0 when unknown. */
3844
- costMillicents: z25.number().int().nonnegative(),
3845
- generatedAt: z25.string()
4038
+ costMillicents: z26.number().int().nonnegative(),
4039
+ generatedAt: z26.string()
3846
4040
  });
3847
- var recommendationExplainRequestSchema = z25.object({
4041
+ var recommendationExplainRequestSchema = z26.object({
3848
4042
  /**
3849
4043
  * Optional provider override (e.g. "claude" to force Claude even if
3850
4044
  * the project's default is Gemini). Falls through to project default
3851
4045
  * → auto-detect when omitted.
3852
4046
  */
3853
- provider: z25.string().optional(),
4047
+ provider: z26.string().optional(),
3854
4048
  /**
3855
4049
  * Optional model override within the chosen provider. Falls through to
3856
4050
  * the `analyze`-tier default model when omitted.
3857
4051
  */
3858
- model: z25.string().optional(),
4052
+ model: z26.string().optional(),
3859
4053
  /**
3860
4054
  * Force a fresh LLM call even if a cached explanation exists for the
3861
4055
  * current prompt version. Use sparingly — defeats the cache.
3862
4056
  */
3863
- forceRefresh: z25.boolean().optional()
4057
+ forceRefresh: z26.boolean().optional()
3864
4058
  });
3865
- var contentBriefDtoSchema = z25.object({
4059
+ var contentBriefDtoSchema = z26.object({
3866
4060
  /** The query the brief is for (echoed from the recommendation). */
3867
- targetQuery: z25.string().trim().min(1),
4061
+ targetQuery: z26.string().trim().min(1),
3868
4062
  /** Always `ownable` in practice — the gate rejects `ceded` before synthesis. */
3869
4063
  winnabilityClass: winnabilityClassSchema,
3870
4064
  /** The differentiated content angle to take. */
3871
- angle: z25.string().trim().min(1),
4065
+ angle: z26.string().trim().min(1),
3872
4066
  /** Why this query is winnable, citing the cited-surface signal. */
3873
- whyWinnable: z25.string().trim().min(1),
4067
+ whyWinnable: z26.string().trim().min(1),
3874
4068
  /** The schema.org type or markup to add or extend. */
3875
- schemaHookup: z25.string().trim().min(1),
4069
+ schemaHookup: z26.string().trim().min(1),
3876
4070
  /** Why the cited surface is controllable (the ownable-vs-ceded reasoning). */
3877
- controllableSurfaceRationale: z25.string().trim().min(1)
4071
+ controllableSurfaceRationale: z26.string().trim().min(1)
3878
4072
  });
3879
- var recommendationBriefDtoSchema = z25.object({
3880
- targetRef: z25.string(),
4073
+ var recommendationBriefDtoSchema = z26.object({
4074
+ targetRef: z26.string(),
3881
4075
  /** Version of the brief prompt template; bumping invalidates the cache forward. */
3882
- promptVersion: z25.string(),
3883
- provider: z25.string(),
3884
- model: z25.string(),
4076
+ promptVersion: z26.string(),
4077
+ provider: z26.string(),
4078
+ model: z26.string(),
3885
4079
  brief: contentBriefDtoSchema,
3886
4080
  /** Estimated cost in millicents (1/100 of a cent). 0 when unknown. */
3887
- costMillicents: z25.number().int().nonnegative(),
3888
- generatedAt: z25.string()
4081
+ costMillicents: z26.number().int().nonnegative(),
4082
+ generatedAt: z26.string()
3889
4083
  });
3890
- var domainClassificationDtoSchema = z25.object({
3891
- domain: z25.string(),
4084
+ var domainClassificationDtoSchema = z26.object({
4085
+ domain: z26.string(),
3892
4086
  competitorType: discoveryCompetitorTypeSchema,
3893
- hits: z25.number().int().nonnegative(),
3894
- updatedAt: z25.string()
3895
- });
3896
- var domainClassificationsResponseDtoSchema = z25.object({
3897
- classifications: z25.array(domainClassificationDtoSchema)
3898
- });
3899
- var contentGroundingSourceSchema = z25.object({
3900
- uri: z25.string(),
3901
- title: z25.string(),
3902
- domain: z25.string(),
3903
- isOurDomain: z25.boolean(),
3904
- isCompetitor: z25.boolean(),
3905
- citationCount: z25.number().int().nonnegative(),
3906
- providers: z25.array(providerNameSchema)
4087
+ hits: z26.number().int().nonnegative(),
4088
+ updatedAt: z26.string()
3907
4089
  });
3908
- var contentSourceRowDtoSchema = z25.object({
3909
- query: z25.string(),
3910
- groundingSources: z25.array(contentGroundingSourceSchema)
3911
- });
3912
- var contentSourcesResponseDtoSchema = z25.object({
3913
- sources: z25.array(contentSourceRowDtoSchema),
3914
- latestRunId: z25.string()
4090
+ var domainClassificationsResponseDtoSchema = z26.object({
4091
+ classifications: z26.array(domainClassificationDtoSchema)
3915
4092
  });
3916
- var contentGapRowDtoSchema = z25.object({
3917
- query: z25.string(),
3918
- competitorDomains: z25.array(z25.string()),
3919
- competitorCount: z25.number().int().nonnegative(),
3920
- missRate: z25.number().min(0).max(1),
3921
- lastSeenInRunId: z25.string()
3922
- });
3923
- var contentGapsResponseDtoSchema = z25.object({
3924
- gaps: z25.array(contentGapRowDtoSchema),
3925
- latestRunId: z25.string()
4093
+ var contentGroundingSourceSchema = z26.object({
4094
+ uri: z26.string(),
4095
+ title: z26.string(),
4096
+ domain: z26.string(),
4097
+ isOurDomain: z26.boolean(),
4098
+ isCompetitor: z26.boolean(),
4099
+ citationCount: z26.number().int().nonnegative(),
4100
+ providers: z26.array(providerNameSchema)
4101
+ });
4102
+ var contentSourceRowDtoSchema = z26.object({
4103
+ query: z26.string(),
4104
+ groundingSources: z26.array(contentGroundingSourceSchema)
4105
+ });
4106
+ var contentSourcesResponseDtoSchema = z26.object({
4107
+ sources: z26.array(contentSourceRowDtoSchema),
4108
+ latestRunId: z26.string()
4109
+ });
4110
+ var contentGapRowDtoSchema = z26.object({
4111
+ query: z26.string(),
4112
+ competitorDomains: z26.array(z26.string()),
4113
+ competitorCount: z26.number().int().nonnegative(),
4114
+ missRate: z26.number().min(0).max(1),
4115
+ lastSeenInRunId: z26.string()
4116
+ });
4117
+ var contentGapsResponseDtoSchema = z26.object({
4118
+ gaps: z26.array(contentGapRowDtoSchema),
4119
+ latestRunId: z26.string()
3926
4120
  });
3927
4121
 
3928
4122
  // ../contracts/src/doctor.ts
3929
- import { z as z26 } from "zod";
3930
- var checkStatusSchema = z26.enum(["ok", "warn", "fail", "skipped"]);
4123
+ import { z as z27 } from "zod";
4124
+ var checkStatusSchema = z27.enum(["ok", "warn", "fail", "skipped"]);
3931
4125
  var CheckStatuses = checkStatusSchema.enum;
3932
- var checkScopeSchema = z26.enum(["global", "project"]);
4126
+ var checkScopeSchema = z27.enum(["global", "project"]);
3933
4127
  var CheckScopes = checkScopeSchema.enum;
3934
- var checkCategorySchema = z26.enum([
4128
+ var checkCategorySchema = z27.enum([
3935
4129
  "auth",
3936
4130
  "config",
3937
4131
  "providers",
@@ -3942,31 +4136,31 @@ var checkCategorySchema = z26.enum([
3942
4136
  "agent"
3943
4137
  ]);
3944
4138
  var CheckCategories = checkCategorySchema.enum;
3945
- var checkResultSchema = z26.object({
3946
- id: z26.string(),
4139
+ var checkResultSchema = z27.object({
4140
+ id: z27.string(),
3947
4141
  category: checkCategorySchema,
3948
4142
  scope: checkScopeSchema,
3949
- title: z26.string(),
4143
+ title: z27.string(),
3950
4144
  status: checkStatusSchema,
3951
- code: z26.string().describe('Stable machine-readable code (e.g. "google.token.refresh-failed"). Use this for filtering and remediation logic.'),
3952
- summary: z26.string(),
3953
- remediation: z26.string().nullable().optional().describe('Operator-facing next step. Null when status is "ok" or no specific remediation applies.'),
3954
- details: z26.record(z26.string(), z26.unknown()).optional().describe("Structured context \u2014 principal email, redirect URI, missing scopes, etc. Stable per check id."),
3955
- durationMs: z26.number().int().nonnegative().describe("How long the check took to execute.")
4145
+ code: z27.string().describe('Stable machine-readable code (e.g. "google.token.refresh-failed"). Use this for filtering and remediation logic.'),
4146
+ summary: z27.string(),
4147
+ remediation: z27.string().nullable().optional().describe('Operator-facing next step. Null when status is "ok" or no specific remediation applies.'),
4148
+ details: z27.record(z27.string(), z27.unknown()).optional().describe("Structured context \u2014 principal email, redirect URI, missing scopes, etc. Stable per check id."),
4149
+ durationMs: z27.number().int().nonnegative().describe("How long the check took to execute.")
3956
4150
  });
3957
- var doctorReportSchema = z26.object({
4151
+ var doctorReportSchema = z27.object({
3958
4152
  scope: checkScopeSchema,
3959
- project: z26.string().nullable().describe('Project name when scope is "project", null otherwise.'),
3960
- generatedAt: z26.string().describe("ISO-8601 timestamp when this doctor run started."),
3961
- durationMs: z26.number().int().nonnegative(),
3962
- summary: z26.object({
3963
- total: z26.number().int().nonnegative(),
3964
- ok: z26.number().int().nonnegative(),
3965
- warn: z26.number().int().nonnegative(),
3966
- fail: z26.number().int().nonnegative(),
3967
- skipped: z26.number().int().nonnegative()
4153
+ project: z27.string().nullable().describe('Project name when scope is "project", null otherwise.'),
4154
+ generatedAt: z27.string().describe("ISO-8601 timestamp when this doctor run started."),
4155
+ durationMs: z27.number().int().nonnegative(),
4156
+ summary: z27.object({
4157
+ total: z27.number().int().nonnegative(),
4158
+ ok: z27.number().int().nonnegative(),
4159
+ warn: z27.number().int().nonnegative(),
4160
+ fail: z27.number().int().nonnegative(),
4161
+ skipped: z27.number().int().nonnegative()
3968
4162
  }),
3969
- checks: z26.array(checkResultSchema)
4163
+ checks: z27.array(checkResultSchema)
3970
4164
  });
3971
4165
  function summarizeCheckResults(results) {
3972
4166
  const summary = { total: results.length, ok: 0, warn: 0, fail: 0, skipped: 0 };
@@ -3995,52 +4189,52 @@ function normalizeQueryText(value) {
3995
4189
  }
3996
4190
 
3997
4191
  // ../contracts/src/citations.ts
3998
- import { z as z27 } from "zod";
3999
- var citationCoverageProviderSchema = z27.object({
4000
- provider: z27.string(),
4192
+ import { z as z28 } from "zod";
4193
+ var citationCoverageProviderSchema = z28.object({
4194
+ provider: z28.string(),
4001
4195
  citationState: citationStateSchema,
4002
- cited: z27.boolean(),
4003
- mentioned: z27.boolean(),
4004
- runId: z27.string(),
4005
- runCreatedAt: z27.string()
4006
- });
4007
- var citationCoverageRowSchema = z27.object({
4008
- queryId: z27.string(),
4009
- query: z27.string(),
4010
- providers: z27.array(citationCoverageProviderSchema),
4011
- citedCount: z27.number().int().nonnegative(),
4012
- mentionedCount: z27.number().int().nonnegative(),
4013
- totalProviders: z27.number().int().nonnegative()
4014
- });
4015
- var competitorGapRowSchema = z27.object({
4016
- queryId: z27.string(),
4017
- query: z27.string(),
4018
- provider: z27.string(),
4019
- citingCompetitors: z27.array(z27.string()),
4020
- runId: z27.string(),
4021
- runCreatedAt: z27.string()
4022
- });
4023
- var citationVisibilitySummarySchema = z27.object({
4024
- providersConfigured: z27.number().int().nonnegative(),
4025
- providersCiting: z27.number().int().nonnegative(),
4026
- providersMentioning: z27.number().int().nonnegative(),
4027
- totalQueries: z27.number().int().nonnegative(),
4196
+ cited: z28.boolean(),
4197
+ mentioned: z28.boolean(),
4198
+ runId: z28.string(),
4199
+ runCreatedAt: z28.string()
4200
+ });
4201
+ var citationCoverageRowSchema = z28.object({
4202
+ queryId: z28.string(),
4203
+ query: z28.string(),
4204
+ providers: z28.array(citationCoverageProviderSchema),
4205
+ citedCount: z28.number().int().nonnegative(),
4206
+ mentionedCount: z28.number().int().nonnegative(),
4207
+ totalProviders: z28.number().int().nonnegative()
4208
+ });
4209
+ var competitorGapRowSchema = z28.object({
4210
+ queryId: z28.string(),
4211
+ query: z28.string(),
4212
+ provider: z28.string(),
4213
+ citingCompetitors: z28.array(z28.string()),
4214
+ runId: z28.string(),
4215
+ runCreatedAt: z28.string()
4216
+ });
4217
+ var citationVisibilitySummarySchema = z28.object({
4218
+ providersConfigured: z28.number().int().nonnegative(),
4219
+ providersCiting: z28.number().int().nonnegative(),
4220
+ providersMentioning: z28.number().int().nonnegative(),
4221
+ totalQueries: z28.number().int().nonnegative(),
4028
4222
  // Cross-tab buckets — each tracked query with at least one snapshot lands
4029
4223
  // in exactly one of these. Queries with zero snapshots are not counted in
4030
4224
  // any bucket; (sum of buckets) ≤ totalQueries.
4031
- queriesCitedAndMentioned: z27.number().int().nonnegative(),
4032
- queriesCitedOnly: z27.number().int().nonnegative(),
4033
- queriesMentionedOnly: z27.number().int().nonnegative(),
4034
- queriesInvisible: z27.number().int().nonnegative(),
4035
- latestRunId: z27.string().nullable(),
4036
- latestRunAt: z27.string().nullable()
4037
- });
4038
- var citationVisibilityResponseSchema = z27.object({
4225
+ queriesCitedAndMentioned: z28.number().int().nonnegative(),
4226
+ queriesCitedOnly: z28.number().int().nonnegative(),
4227
+ queriesMentionedOnly: z28.number().int().nonnegative(),
4228
+ queriesInvisible: z28.number().int().nonnegative(),
4229
+ latestRunId: z28.string().nullable(),
4230
+ latestRunAt: z28.string().nullable()
4231
+ });
4232
+ var citationVisibilityResponseSchema = z28.object({
4039
4233
  summary: citationVisibilitySummarySchema,
4040
- byQuery: z27.array(citationCoverageRowSchema),
4041
- competitorGaps: z27.array(competitorGapRowSchema),
4042
- status: z27.enum(["ready", "no-data"]),
4043
- reason: z27.enum(["no-runs-yet", "no-queries"]).optional()
4234
+ byQuery: z28.array(citationCoverageRowSchema),
4235
+ competitorGaps: z28.array(competitorGapRowSchema),
4236
+ status: z28.enum(["ready", "no-data"]),
4237
+ reason: z28.enum(["no-runs-yet", "no-queries"]).optional()
4044
4238
  });
4045
4239
  function emptyCitationVisibility(reason) {
4046
4240
  return {
@@ -4067,10 +4261,10 @@ function citationStateToCited(state) {
4067
4261
  }
4068
4262
 
4069
4263
  // ../contracts/src/report.ts
4070
- import { z as z28 } from "zod";
4264
+ import { z as z29 } from "zod";
4071
4265
  var REPORT_PERIOD_OPTIONS = [7, 14, 30, 90];
4072
4266
  var REPORT_DEFAULT_PERIOD_DAYS = 30;
4073
- var reportPeriodSchema = z28.union([z28.literal(7), z28.literal(14), z28.literal(30), z28.literal(90)]).describe("Report window in days (7, 14, 30, or 90). Defaults to 30 when omitted.");
4267
+ var reportPeriodSchema = z29.union([z29.literal(7), z29.literal(14), z29.literal(30), z29.literal(90)]).describe("Report window in days (7, 14, 30, or 90). Defaults to 30 when omitted.");
4074
4268
  function isReportPeriodDays(n) {
4075
4269
  return REPORT_PERIOD_OPTIONS.includes(n);
4076
4270
  }
@@ -4085,45 +4279,45 @@ function parseReportPeriodDays(value) {
4085
4279
  function reportComparisonWindowDays(periodDays) {
4086
4280
  return Math.max(1, Math.floor(periodDays / 2));
4087
4281
  }
4088
- var providerLocationTreatmentSchema = z28.enum([
4282
+ var providerLocationTreatmentSchema = z29.enum([
4089
4283
  "prompt",
4090
4284
  "request-param",
4091
4285
  "browser-geo",
4092
4286
  "ignored"
4093
4287
  ]);
4094
- var reportMetaLocationSchema = z28.object({
4288
+ var reportMetaLocationSchema = z29.object({
4095
4289
  /** Human-readable label as configured on the project (e.g. "michigan"). */
4096
- label: z28.string(),
4290
+ label: z29.string(),
4097
4291
  /** Resolved city/region/country from the project's `LocationContext`. */
4098
- city: z28.string(),
4099
- region: z28.string(),
4100
- country: z28.string(),
4292
+ city: z29.string(),
4293
+ region: z29.string(),
4294
+ country: z29.string(),
4101
4295
  /**
4102
4296
  * Other locations configured on the project that did NOT power this report.
4103
4297
  * When non-empty, callers should make clear that the report is location-scoped:
4104
4298
  * a separate sweep is needed to see how AI engines respond from each one.
4105
4299
  */
4106
- otherConfiguredLabels: z28.array(z28.string())
4300
+ otherConfiguredLabels: z29.array(z29.string())
4107
4301
  });
4108
- var reportProviderLocationHandlingSchema = z28.object({
4302
+ var reportProviderLocationHandlingSchema = z29.object({
4109
4303
  /** Provider name (matches `query_snapshots.provider`). */
4110
- provider: z28.string(),
4304
+ provider: z29.string(),
4111
4305
  /** How this provider applied the configured location during this run. */
4112
4306
  treatment: providerLocationTreatmentSchema,
4113
4307
  /** One-sentence explanation suitable for the report. */
4114
- description: z28.string()
4308
+ description: z29.string()
4115
4309
  });
4116
- var reportMetaSchema = z28.object({
4310
+ var reportMetaSchema = z29.object({
4117
4311
  /** ISO timestamp the report was generated (server clock). */
4118
- generatedAt: z28.string(),
4312
+ generatedAt: z29.string(),
4119
4313
  /** Project the report covers. */
4120
- project: z28.object({
4121
- id: z28.string(),
4122
- name: z28.string(),
4123
- displayName: z28.string(),
4124
- canonicalDomain: z28.string(),
4125
- country: z28.string(),
4126
- language: z28.string()
4314
+ project: z29.object({
4315
+ id: z29.string(),
4316
+ name: z29.string(),
4317
+ displayName: z29.string(),
4318
+ canonicalDomain: z29.string(),
4319
+ country: z29.string(),
4320
+ language: z29.string()
4127
4321
  }),
4128
4322
  /**
4129
4323
  * The location that powered the latest visibility run, when one was set.
@@ -4138,31 +4332,31 @@ var reportMetaSchema = z28.object({
4138
4332
  * each provider's answer — some providers append it to the prompt, some
4139
4333
  * pass it as a structured request field, and some (CDP) ignore it.
4140
4334
  */
4141
- providerLocationHandling: z28.array(reportProviderLocationHandlingSchema),
4335
+ providerLocationHandling: z29.array(reportProviderLocationHandlingSchema),
4142
4336
  /** Earliest data point referenced by the report (ISO date). */
4143
- periodStart: z28.string().nullable(),
4337
+ periodStart: z29.string().nullable(),
4144
4338
  /** Latest data point referenced by the report (ISO date). */
4145
- periodEnd: z28.string().nullable(),
4339
+ periodEnd: z29.string().nullable(),
4146
4340
  /**
4147
4341
  * The selected report window, in days (one of `REPORT_PERIOD_OPTIONS`).
4148
4342
  * Every time-windowed section scopes to this many days; renderers read it to
4149
4343
  * label the window ("Last 30 days", "(30d)"). Defaults to
4150
4344
  * `REPORT_DEFAULT_PERIOD_DAYS` when no `period` is requested.
4151
4345
  */
4152
- periodDays: z28.number().int().positive()
4346
+ periodDays: z29.number().int().positive()
4153
4347
  });
4154
- var reportExecutiveSummarySchema = z28.object({
4348
+ var reportExecutiveSummarySchema = z29.object({
4155
4349
  /**
4156
4350
  * 0..100 — share of tracked queries that were cited by at least one
4157
4351
  * provider in the latest run. "Cited" means the project's domain appeared
4158
4352
  * in the source list / grounding the AI used to answer. Computed per-query
4159
4353
  * (not per-(query × provider)) so the rate is invariant to provider count.
4160
4354
  */
4161
- citationRate: z28.number(),
4355
+ citationRate: z29.number(),
4162
4356
  /** Numerator of `citationRate` — distinct tracked queries cited by ≥1 provider in the latest run. */
4163
- citedQueryCount: z28.number(),
4357
+ citedQueryCount: z29.number(),
4164
4358
  /** Denominator of `citationRate` — total tracked queries. */
4165
- totalQueryCount: z28.number(),
4359
+ totalQueryCount: z29.number(),
4166
4360
  /**
4167
4361
  * 0..100 — share of tracked queries where the project's brand or domain
4168
4362
  * appeared in at least one provider's answer text in the latest run.
@@ -4170,71 +4364,71 @@ var reportExecutiveSummarySchema = z28.object({
4170
4364
  * the prose without citing your domain in its sources, and vice versa.
4171
4365
  * Same per-query denominator as `citationRate` for consistency.
4172
4366
  */
4173
- mentionRate: z28.number(),
4367
+ mentionRate: z29.number(),
4174
4368
  /** Numerator of `mentionRate` — distinct tracked queries mentioned in ≥1 provider's answer text. */
4175
- mentionedQueryCount: z28.number(),
4369
+ mentionedQueryCount: z29.number(),
4176
4370
  /** Compared to the previous run: 'up' | 'down' | 'flat' | 'unknown' (no prior run). */
4177
- trend: z28.enum(["up", "down", "flat", "unknown"]),
4371
+ trend: z29.enum(["up", "down", "flat", "unknown"]),
4178
4372
  /** Total tracked queries. */
4179
- queryCount: z28.number(),
4373
+ queryCount: z29.number(),
4180
4374
  /** Total tracked competitors. */
4181
- competitorCount: z28.number(),
4375
+ competitorCount: z29.number(),
4182
4376
  /** Number of providers in the latest run. */
4183
- providerCount: z28.number(),
4377
+ providerCount: z29.number(),
4184
4378
  /** GSC totals across the most-recent sync window. Null when GSC is not connected. */
4185
- gsc: z28.object({
4186
- clicks: z28.number(),
4187
- impressions: z28.number(),
4188
- ctr: z28.number(),
4189
- avgPosition: z28.number(),
4190
- periodStart: z28.string(),
4191
- periodEnd: z28.string()
4379
+ gsc: z29.object({
4380
+ clicks: z29.number(),
4381
+ impressions: z29.number(),
4382
+ ctr: z29.number(),
4383
+ avgPosition: z29.number(),
4384
+ periodStart: z29.string(),
4385
+ periodEnd: z29.string()
4192
4386
  }).nullable(),
4193
4387
  /** GA4 totals across the most-recent sync period. Null when GA4 is not connected. */
4194
- ga: z28.object({
4195
- sessions: z28.number(),
4196
- users: z28.number(),
4197
- periodStart: z28.string(),
4198
- periodEnd: z28.string()
4388
+ ga: z29.object({
4389
+ sessions: z29.number(),
4390
+ users: z29.number(),
4391
+ periodStart: z29.string(),
4392
+ periodEnd: z29.string()
4199
4393
  }).nullable(),
4200
4394
  /** Top 3-5 findings, each rendered as a single-sentence narrative. */
4201
- findings: z28.array(z28.object({
4202
- title: z28.string(),
4203
- detail: z28.string(),
4204
- tone: z28.enum(["positive", "caution", "negative", "neutral"])
4395
+ findings: z29.array(z29.object({
4396
+ title: z29.string(),
4397
+ detail: z29.string(),
4398
+ tone: z29.enum(["positive", "caution", "negative", "neutral"])
4205
4399
  }))
4206
4400
  });
4207
- var citationCellSchema = z28.object({
4208
- citationState: z28.enum(["cited", "not-cited", "pending"]),
4209
- answerMentioned: z28.boolean().nullable(),
4210
- model: z28.string().nullable()
4401
+ var citationCellSchema = z29.object({
4402
+ citationState: z29.enum(["cited", "not-cited", "pending"]),
4403
+ answerMentioned: z29.boolean().nullable(),
4404
+ model: z29.string().nullable()
4211
4405
  });
4212
- var citationScorecardSchema = z28.object({
4213
- queries: z28.array(z28.string()),
4214
- providers: z28.array(z28.string()),
4406
+ var citationScorecardSchema = z29.object({
4407
+ queries: z29.array(z29.string()),
4408
+ providers: z29.array(z29.string()),
4215
4409
  /** matrix[queryIndex][providerIndex] — null when no snapshot exists for the pair. */
4216
- matrix: z28.array(z28.array(citationCellSchema.nullable())),
4410
+ matrix: z29.array(z29.array(citationCellSchema.nullable())),
4217
4411
  /** Per-provider citation + mention rates (0..100). */
4218
- providerRates: z28.array(z28.object({
4219
- provider: z28.string(),
4220
- citedCount: z28.number(),
4412
+ providerRates: z29.array(z29.object({
4413
+ provider: z29.string(),
4414
+ citedCount: z29.number(),
4221
4415
  /** Number of snapshots for this provider where the answer text mentioned the project. */
4222
- mentionedCount: z28.number(),
4223
- totalCount: z28.number(),
4224
- citationRate: z28.number(),
4225
- mentionRate: z28.number()
4416
+ mentionedCount: z29.number(),
4417
+ totalCount: z29.number(),
4418
+ citationRate: z29.number(),
4419
+ mentionRate: z29.number()
4226
4420
  }))
4227
4421
  });
4228
- var competitorRowSchema = z28.object({
4229
- domain: z28.string(),
4422
+ var competitorRowSchema = z29.object({
4423
+ domain: z29.string(),
4230
4424
  /** Number of (query × provider) pairs that cited this competitor. */
4231
- citationCount: z28.number(),
4425
+ citationCount: z29.number(),
4232
4426
  /** Out-of count for the same denominator. */
4233
- totalCount: z28.number(),
4427
+ totalCount: z29.number(),
4234
4428
  /** 'High' | 'Moderate' | 'Low' | 'None' — from buildPortfolioProject pressure logic. */
4235
- pressureLabel: z28.enum(["High", "Moderate", "Low", "None"]),
4429
+ pressureLabel: z29.enum(["High", "Moderate", "Low", "None"]),
4236
4430
  /** Distinct queries on which this competitor was cited. */
4237
- citedQueries: z28.array(z28.string()),
4431
+ citedQueries: z29.array(z29.string()),
4238
4432
  /**
4239
4433
  * Citation share 0..100. Numerator = this competitor's `citationCount`.
4240
4434
  * Denominator = sum of `citationCount` across all competitors plus the
@@ -4242,30 +4436,30 @@ var competitorRowSchema = z28.object({
4242
4436
  * slots in the snapshot. Distinct from the project-level Mention Share
4243
4437
  * gauge — that one is brand-in-answer-text, this one is domain-in-source-list.
4244
4438
  */
4245
- sharePct: z28.number(),
4439
+ sharePct: z29.number(),
4246
4440
  /**
4247
4441
  * URLs from the latest run's grounding sources whose host matches this
4248
4442
  * competitor's domain, with the queries each URL was cited for. Empty
4249
4443
  * when no grounding-source data is available (e.g. no `rawResponse` JSON
4250
4444
  * stored for the snapshots).
4251
4445
  */
4252
- theirCitedPages: z28.array(z28.object({ url: z28.string(), citedFor: z28.array(z28.string()) }))
4446
+ theirCitedPages: z29.array(z29.object({ url: z29.string(), citedFor: z29.array(z29.string()) }))
4253
4447
  });
4254
- var competitorLandscapeSchema = z28.object({
4448
+ var competitorLandscapeSchema = z29.object({
4255
4449
  /** Project's own citation count (for the bar chart comparing project vs competitors). */
4256
- projectCitationCount: z28.number(),
4257
- competitors: z28.array(competitorRowSchema)
4450
+ projectCitationCount: z29.number(),
4451
+ competitors: z29.array(competitorRowSchema)
4258
4452
  });
4259
- var mentionRowSchema = z28.object({
4260
- domain: z28.string(),
4453
+ var mentionRowSchema = z29.object({
4454
+ domain: z29.string(),
4261
4455
  /** Number of (query × provider) pairs whose answer text mentioned this competitor's brand or domain. */
4262
- mentionCount: z28.number(),
4456
+ mentionCount: z29.number(),
4263
4457
  /** Out-of count for the same denominator (snapshots that had answer text). */
4264
- totalCount: z28.number(),
4458
+ totalCount: z29.number(),
4265
4459
  /** 'High' | 'Moderate' | 'Low' | 'None' — mention frequency tier (mirrors CompetitorRow.pressureLabel). */
4266
- pressureLabel: z28.enum(["High", "Moderate", "Low", "None"]),
4460
+ pressureLabel: z29.enum(["High", "Moderate", "Low", "None"]),
4267
4461
  /** Distinct queries on which this competitor was mentioned. */
4268
- mentionedQueries: z28.array(z28.string()),
4462
+ mentionedQueries: z29.array(z29.string()),
4269
4463
  /**
4270
4464
  * Mention share 0..100. Numerator = this competitor's `mentionCount`.
4271
4465
  * Denominator = sum of `mentionCount` across all competitors plus the
@@ -4273,129 +4467,135 @@ var mentionRowSchema = z28.object({
4273
4467
  * mention. Per-competitor split of the same head-to-head measure the
4274
4468
  * project's hero `MentionShareDto` gauge headlines.
4275
4469
  */
4276
- sharePct: z28.number()
4470
+ sharePct: z29.number()
4277
4471
  });
4278
- var mentionLandscapeSchema = z28.object({
4472
+ var mentionLandscapeSchema = z29.object({
4279
4473
  /** Project's own mention count (for the bar chart comparing project vs competitors). */
4280
- projectMentionCount: z28.number(),
4474
+ projectMentionCount: z29.number(),
4281
4475
  /** Snapshots considered — those with non-empty answerText. Drives the totalCount denominator. */
4282
- totalAnswerSnapshots: z28.number(),
4283
- competitors: z28.array(mentionRowSchema)
4476
+ totalAnswerSnapshots: z29.number(),
4477
+ competitors: z29.array(mentionRowSchema)
4284
4478
  });
4285
- var aiSourceCategoryBucketSchema = z28.object({
4479
+ var aiSourceCategoryBucketSchema = z29.object({
4286
4480
  /** Category slug from packages/contracts/src/source-categories. */
4287
- category: z28.string(),
4481
+ category: z29.string(),
4288
4482
  /** Display label. */
4289
- label: z28.string(),
4483
+ label: z29.string(),
4290
4484
  /** Number of citations falling in this category. */
4291
- count: z28.number(),
4485
+ count: z29.number(),
4292
4486
  /** 0..100 share of total citations. */
4293
- sharePct: z28.number()
4487
+ sharePct: z29.number()
4294
4488
  });
4295
- var aiSourceOriginSchema = z28.object({
4296
- categories: z28.array(aiSourceCategoryBucketSchema),
4489
+ var aiSourceOriginSchema = z29.object({
4490
+ categories: z29.array(aiSourceCategoryBucketSchema),
4297
4491
  /** Top 20 source domains by citation count (excluding the project's own domain). */
4298
- topDomains: z28.array(z28.object({
4299
- domain: z28.string(),
4300
- count: z28.number(),
4492
+ topDomains: z29.array(z29.object({
4493
+ domain: z29.string(),
4494
+ count: z29.number(),
4301
4495
  /** True when the domain is one of the project's tracked competitors. */
4302
- isCompetitor: z28.boolean()
4496
+ isCompetitor: z29.boolean()
4303
4497
  }))
4304
4498
  });
4305
- var gscQueryRowSchema = z28.object({
4306
- query: z28.string(),
4307
- clicks: z28.number(),
4308
- impressions: z28.number(),
4309
- ctr: z28.number(),
4310
- avgPosition: z28.number(),
4499
+ var gscQueryRowSchema = z29.object({
4500
+ query: z29.string(),
4501
+ clicks: z29.number(),
4502
+ impressions: z29.number(),
4503
+ ctr: z29.number(),
4504
+ avgPosition: z29.number(),
4311
4505
  /** Heuristic categorization: 'brand' | 'lead-gen' | 'industry' | 'other'. */
4312
- category: z28.enum(["brand", "lead-gen", "industry", "other"])
4313
- });
4314
- var gscSectionSchema = z28.object({
4315
- periodStart: z28.string(),
4316
- periodEnd: z28.string(),
4317
- totalClicks: z28.number(),
4318
- totalImpressions: z28.number(),
4319
- ctr: z28.number(),
4320
- avgPosition: z28.number(),
4321
- topQueries: z28.array(gscQueryRowSchema),
4322
- categoryBreakdown: z28.array(z28.object({
4323
- category: z28.enum(["brand", "lead-gen", "industry", "other"]),
4324
- clicks: z28.number(),
4325
- impressions: z28.number(),
4326
- sharePct: z28.number()
4506
+ category: z29.enum(["brand", "lead-gen", "industry", "other"])
4507
+ });
4508
+ var gscSectionSchema = z29.object({
4509
+ periodStart: z29.string(),
4510
+ periodEnd: z29.string(),
4511
+ totalClicks: z29.number(),
4512
+ totalImpressions: z29.number(),
4513
+ ctr: z29.number(),
4514
+ avgPosition: z29.number(),
4515
+ topQueries: z29.array(gscQueryRowSchema),
4516
+ categoryBreakdown: z29.array(z29.object({
4517
+ category: z29.enum(["brand", "lead-gen", "industry", "other"]),
4518
+ clicks: z29.number(),
4519
+ impressions: z29.number(),
4520
+ sharePct: z29.number()
4327
4521
  })),
4328
- trend: z28.array(z28.object({ date: z28.string(), clicks: z28.number(), impressions: z28.number() })),
4522
+ trend: z29.array(z29.object({ date: z29.string(), clicks: z29.number(), impressions: z29.number() })),
4329
4523
  /**
4330
4524
  * Tracked AEO queries that have no GSC impressions in the report window.
4331
4525
  * Surfaces queries that may not represent real search demand.
4332
4526
  */
4333
- trackedButNoGsc: z28.array(z28.string()),
4527
+ trackedButNoGsc: z29.array(z29.string()),
4334
4528
  /**
4335
4529
  * GSC top queries (sorted by impressions desc) that are not tracked as
4336
4530
  * AEO queries — the candidate set for adding to the AEO project.
4337
4531
  */
4338
- gscButNotTracked: z28.array(z28.string())
4339
- });
4340
- var gaTrafficSectionSchema = z28.object({
4341
- totalSessions: z28.number(),
4342
- totalUsers: z28.number(),
4343
- totalOrganicSessions: z28.number(),
4344
- periodStart: z28.string(),
4345
- periodEnd: z28.string(),
4346
- topLandingPages: z28.array(z28.object({
4347
- page: z28.string(),
4348
- sessions: z28.number(),
4349
- users: z28.number(),
4350
- organicSessions: z28.number()
4532
+ gscButNotTracked: z29.array(z29.string())
4533
+ });
4534
+ var gaTrafficSectionSchema = z29.object({
4535
+ totalSessions: z29.number(),
4536
+ totalUsers: z29.number(),
4537
+ totalOrganicSessions: z29.number(),
4538
+ periodStart: z29.string(),
4539
+ periodEnd: z29.string(),
4540
+ topLandingPages: z29.array(z29.object({
4541
+ page: z29.string(),
4542
+ sessions: z29.number(),
4543
+ users: z29.number(),
4544
+ organicSessions: z29.number()
4351
4545
  })),
4352
- channelBreakdown: z28.array(z28.object({
4353
- channel: z28.string(),
4354
- sessions: z28.number(),
4355
- sharePct: z28.number()
4546
+ channelBreakdown: z29.array(z29.object({
4547
+ channel: z29.string(),
4548
+ sessions: z29.number(),
4549
+ sharePct: z29.number()
4356
4550
  }))
4357
4551
  });
4358
- var socialReferralSectionSchema = z28.object({
4359
- totalSessions: z28.number(),
4360
- organicSessions: z28.number(),
4361
- paidSessions: z28.number(),
4362
- channels: z28.array(z28.object({
4363
- channelGroup: z28.string(),
4364
- sessions: z28.number(),
4365
- sharePct: z28.number()
4552
+ var socialReferralSectionSchema = z29.object({
4553
+ totalSessions: z29.number(),
4554
+ organicSessions: z29.number(),
4555
+ paidSessions: z29.number(),
4556
+ channels: z29.array(z29.object({
4557
+ channelGroup: z29.string(),
4558
+ sessions: z29.number(),
4559
+ sharePct: z29.number()
4366
4560
  })),
4367
- topCampaigns: z28.array(z28.object({
4368
- source: z28.string(),
4369
- medium: z28.string(),
4370
- sessions: z28.number()
4561
+ topCampaigns: z29.array(z29.object({
4562
+ source: z29.string(),
4563
+ medium: z29.string(),
4564
+ sessions: z29.number()
4371
4565
  }))
4372
4566
  });
4373
- var aiReferralSectionSchema = z28.object({
4374
- totalSessions: z28.number(),
4375
- totalUsers: z28.number(),
4376
- bySource: z28.array(z28.object({
4377
- source: z28.string(),
4378
- sessions: z28.number(),
4379
- users: z28.number(),
4380
- sharePct: z28.number()
4567
+ var aiReferralSectionSchema = z29.object({
4568
+ totalSessions: z29.number(),
4569
+ totalUsers: z29.number(),
4570
+ paidSessions: z29.number(),
4571
+ paidUsers: z29.number(),
4572
+ organicSessions: z29.number(),
4573
+ organicUsers: z29.number(),
4574
+ bySource: z29.array(z29.object({
4575
+ source: z29.string(),
4576
+ sessions: z29.number(),
4577
+ users: z29.number(),
4578
+ paidSessions: z29.number(),
4579
+ organicSessions: z29.number(),
4580
+ sharePct: z29.number()
4381
4581
  })),
4382
- trend: z28.array(z28.object({ date: z28.string(), sessions: z28.number() })),
4383
- topLandingPages: z28.array(z28.object({
4384
- page: z28.string(),
4385
- sessions: z28.number(),
4386
- users: z28.number()
4582
+ trend: z29.array(z29.object({ date: z29.string(), sessions: z29.number() })),
4583
+ topLandingPages: z29.array(z29.object({
4584
+ page: z29.string(),
4585
+ sessions: z29.number(),
4586
+ users: z29.number()
4387
4587
  }))
4388
4588
  });
4389
- var serverActivitySectionSchema = z28.object({
4589
+ var serverActivitySectionSchema = z29.object({
4390
4590
  /** ISO8601 inclusive lower bound of the report window (default: 7 days). */
4391
- windowStart: z28.string(),
4591
+ windowStart: z29.string(),
4392
4592
  /** ISO8601 inclusive upper bound. */
4393
- windowEnd: z28.string(),
4394
- hasData: z28.boolean(),
4593
+ windowEnd: z29.string(),
4594
+ hasData: z29.boolean(),
4395
4595
  /** Last-7d total verified crawler hits, with prior 7d for delta. */
4396
- verifiedCrawlerHits: z28.object({ current: z28.number(), prior: z28.number(), deltaPct: z28.number().nullable() }),
4596
+ verifiedCrawlerHits: z29.object({ current: z29.number(), prior: z29.number(), deltaPct: z29.number().nullable() }),
4397
4597
  /** Last-7d total unverified crawler hits, separated from verified trust metrics. */
4398
- unverifiedCrawlerHits: z28.object({ current: z28.number(), prior: z28.number(), deltaPct: z28.number().nullable() }),
4598
+ unverifiedCrawlerHits: z29.object({ current: z29.number(), prior: z29.number(), deltaPct: z29.number().nullable() }),
4399
4599
  /**
4400
4600
  * Last-7d on-demand per-user fetches from AI surfaces (ChatGPT-User,
4401
4601
  * Perplexity-User, MistralAI-User). Disjoint from `verifiedCrawlerHits` /
@@ -4404,19 +4604,34 @@ var serverActivitySectionSchema = z28.object({
4404
4604
  * because the operational question for user-fetch is "is this happening?"
4405
4605
  * not "is this a confirmed bot identity?"
4406
4606
  */
4407
- aiUserFetchHits: z28.object({ current: z28.number(), prior: z28.number(), deltaPct: z28.number().nullable() }),
4408
- /** Last-7d AI-referral sessions (sessionized from server-side request evidence). */
4409
- referralArrivals: z28.object({ current: z28.number(), prior: z28.number(), deltaPct: z28.number().nullable() }),
4607
+ aiUserFetchHits: z29.object({ current: z29.number(), prior: z29.number(), deltaPct: z29.number().nullable() }),
4608
+ /** Last-7d AI-referral sessions (sessionized from server-side request evidence). Paid + organic + unclassified. */
4609
+ referralArrivals: z29.object({ current: z29.number(), prior: z29.number(), deltaPct: z29.number().nullable() }),
4610
+ /**
4611
+ * `referralArrivals` split by traffic class. The three buckets sum to it.
4612
+ *
4613
+ * `unclassified` counts sessions ingested before the classifier shipped: the
4614
+ * UTM tags that carry paid-ness were never persisted, so those sessions can
4615
+ * never be resolved. Reporting them as organic would overstate earned AI
4616
+ * traffic by exactly a client's ad volume.
4617
+ */
4618
+ referralArrivalsByClass: z29.object({
4619
+ paid: z29.object({ current: z29.number(), prior: z29.number(), deltaPct: z29.number().nullable() }),
4620
+ organic: z29.object({ current: z29.number(), prior: z29.number(), deltaPct: z29.number().nullable() }),
4621
+ unclassified: z29.object({ current: z29.number(), prior: z29.number(), deltaPct: z29.number().nullable() })
4622
+ }),
4623
+ /** Pre-rendered one-line breakdown, e.g. "Paid 1,200 · Organic 24". Empty when there is nothing to split. */
4624
+ referralArrivalsClassSummary: z29.string(),
4410
4625
  /** Per-AI-operator breakdown (OpenAI, Anthropic, Google AI, Perplexity, …). */
4411
- byOperator: z28.array(z28.object({
4412
- operator: z28.string(),
4413
- verifiedHits: z28.number(),
4626
+ byOperator: z29.array(z29.object({
4627
+ operator: z29.string(),
4628
+ verifiedHits: z29.number(),
4414
4629
  /** Shown to agency audience only: claimed-bot UA, source IP not in a published range. */
4415
- unverifiedHits: z28.number(),
4630
+ unverifiedHits: z29.number(),
4416
4631
  /** Per-user fetches from this operator's AI surface (ChatGPT-User, …). */
4417
- userFetchHits: z28.number(),
4418
- referralArrivals: z28.number(),
4419
- deltaPct: z28.number().nullable()
4632
+ userFetchHits: z29.number(),
4633
+ referralArrivals: z29.number(),
4634
+ deltaPct: z29.number().nullable()
4420
4635
  })),
4421
4636
  /**
4422
4637
  * Top crawled paths (verified only, last-7d). Path-level citation cross-reference
@@ -4426,88 +4641,88 @@ var serverActivitySectionSchema = z28.object({
4426
4641
  * citation evidence can extend this entry with a `citationState` field without
4427
4642
  * breaking the contract.
4428
4643
  */
4429
- topCrawledPaths: z28.array(z28.object({
4430
- path: z28.string(),
4431
- verifiedHits: z28.number(),
4644
+ topCrawledPaths: z29.array(z29.object({
4645
+ path: z29.string(),
4646
+ verifiedHits: z29.number(),
4432
4647
  /** How many distinct AI operators crawled this path in the window. */
4433
- distinctOperators: z28.number()
4648
+ distinctOperators: z29.number()
4434
4649
  })),
4435
4650
  /** AI products that sent ≥1 session in the window (referral by destination). */
4436
- referralProducts: z28.array(z28.object({
4437
- product: z28.string(),
4438
- arrivals: z28.number(),
4439
- distinctLandingPaths: z28.number()
4651
+ referralProducts: z29.array(z29.object({
4652
+ product: z29.string(),
4653
+ arrivals: z29.number(),
4654
+ distinctLandingPaths: z29.number()
4440
4655
  })),
4441
4656
  /** Daily trend, last 14d for sparkline / chart rendering. */
4442
- dailyTrend: z28.array(z28.object({
4443
- date: z28.string(),
4444
- verifiedCrawlerHits: z28.number(),
4445
- userFetchHits: z28.number(),
4446
- referralArrivals: z28.number()
4657
+ dailyTrend: z29.array(z29.object({
4658
+ date: z29.string(),
4659
+ verifiedCrawlerHits: z29.number(),
4660
+ userFetchHits: z29.number(),
4661
+ referralArrivals: z29.number()
4447
4662
  })),
4448
4663
  /**
4449
4664
  * Top landing paths for AI-referral sessions (last-7d).
4450
4665
  * Complements `topCrawledPaths` (what bots fetch) with what humans actually land on.
4451
4666
  */
4452
- topReferralLandingPaths: z28.array(z28.object({
4453
- path: z28.string(),
4454
- arrivals: z28.number(),
4455
- distinctProducts: z28.number()
4667
+ topReferralLandingPaths: z29.array(z29.object({
4668
+ path: z29.string(),
4669
+ arrivals: z29.number(),
4670
+ distinctProducts: z29.number()
4456
4671
  }))
4457
4672
  });
4458
- var indexingHealthSectionSchema = z28.object({
4673
+ var indexingHealthSectionSchema = z29.object({
4459
4674
  /** Source: 'google' | 'bing' | null when neither is connected. */
4460
- provider: z28.enum(["google", "bing"]).nullable(),
4461
- total: z28.number(),
4462
- indexed: z28.number(),
4463
- notIndexed: z28.number(),
4675
+ provider: z29.enum(["google", "bing"]).nullable(),
4676
+ total: z29.number(),
4677
+ indexed: z29.number(),
4678
+ notIndexed: z29.number(),
4464
4679
  /** Google-only — pages explicitly marked as deindexed. Bing reports 'unknown' instead. */
4465
- deindexed: z28.number(),
4680
+ deindexed: z29.number(),
4466
4681
  /** Bing-only — pages with no inspection data yet. */
4467
- unknown: z28.number(),
4682
+ unknown: z29.number(),
4468
4683
  /** 0..100. */
4469
- indexedPct: z28.number()
4684
+ indexedPct: z29.number()
4470
4685
  });
4471
- var citationsTrendPointSchema = z28.object({
4686
+ var citationsTrendPointSchema = z29.object({
4472
4687
  /** Run ID — anchor for cross-section linking. */
4473
- runId: z28.string(),
4688
+ runId: z29.string(),
4474
4689
  /** ISO timestamp when the run finished (or createdAt fallback). */
4475
- date: z28.string(),
4690
+ date: z29.string(),
4476
4691
  /**
4477
4692
  * 0..100 — same per-query unique-cited definition as
4478
4693
  * `ReportExecutiveSummary.citationRate`. Stable across runs with different
4479
4694
  * provider counts so the trend line measures real movement rather than
4480
4695
  * provider-count variance.
4481
4696
  */
4482
- citationRate: z28.number(),
4697
+ citationRate: z29.number(),
4483
4698
  /** Numerator of `citationRate` for this run. */
4484
- citedQueryCount: z28.number(),
4699
+ citedQueryCount: z29.number(),
4485
4700
  /** Denominator of `citationRate` for this run. */
4486
- totalQueryCount: z28.number(),
4701
+ totalQueryCount: z29.number(),
4487
4702
  /** 0..100 — same per-query unique-mentioned definition as `ReportExecutiveSummary.mentionRate`. */
4488
- mentionRate: z28.number(),
4703
+ mentionRate: z29.number(),
4489
4704
  /** Numerator of `mentionRate` for this run. */
4490
- mentionedQueryCount: z28.number(),
4705
+ mentionedQueryCount: z29.number(),
4491
4706
  /**
4492
4707
  * Per-provider rates for the same run. Each provider's rate is per-pair
4493
4708
  * within that provider (`cited / scanned`), so it remains comparable
4494
4709
  * between providers in the same run.
4495
4710
  */
4496
- providerRates: z28.array(z28.object({
4497
- provider: z28.string(),
4498
- citationRate: z28.number(),
4499
- mentionRate: z28.number()
4711
+ providerRates: z29.array(z29.object({
4712
+ provider: z29.string(),
4713
+ citationRate: z29.number(),
4714
+ mentionRate: z29.number()
4500
4715
  }))
4501
4716
  });
4502
- var reportInsightSchema = z28.object({
4503
- id: z28.string(),
4504
- type: z28.enum(["regression", "gain", "opportunity"]),
4505
- severity: z28.enum(["critical", "high", "medium", "low"]),
4506
- title: z28.string(),
4507
- query: z28.string(),
4508
- provider: z28.string(),
4509
- recommendation: z28.string().nullable(),
4510
- createdAt: z28.string(),
4717
+ var reportInsightSchema = z29.object({
4718
+ id: z29.string(),
4719
+ type: z29.enum(["regression", "gain", "opportunity"]),
4720
+ severity: z29.enum(["critical", "high", "medium", "low"]),
4721
+ title: z29.string(),
4722
+ query: z29.string(),
4723
+ provider: z29.string(),
4724
+ recommendation: z29.string().nullable(),
4725
+ createdAt: z29.string(),
4511
4726
  /**
4512
4727
  * How many times this insight fired across recent runs for the same
4513
4728
  * `(query, provider, type)` tuple. Always ≥ 1. Insights returned by the
@@ -4515,64 +4730,64 @@ var reportInsightSchema = z28.object({
4515
4730
  * surfacing the multiplicity. Use it directly instead of grouping again
4516
4731
  * client-side — counts derived from raw insight rows will overcount.
4517
4732
  */
4518
- instanceCount: z28.number()
4733
+ instanceCount: z29.number()
4519
4734
  });
4520
- var recommendedNextStepSchema = z28.object({
4735
+ var recommendedNextStepSchema = z29.object({
4521
4736
  /** 'immediate' | 'short-term' | 'medium-term' — bucketed by severity heuristic. */
4522
- horizon: z28.enum(["immediate", "short-term", "medium-term"]),
4523
- title: z28.string(),
4524
- rationale: z28.string()
4737
+ horizon: z29.enum(["immediate", "short-term", "medium-term"]),
4738
+ title: z29.string(),
4739
+ rationale: z29.string()
4525
4740
  });
4526
- var reportRateDeltaSchema = z28.object({
4741
+ var reportRateDeltaSchema = z29.object({
4527
4742
  /** Current value (0..100 for rates, raw count otherwise). When `window`
4528
4743
  * is present this is the average over the last `window` checks. */
4529
- current: z28.number(),
4744
+ current: z29.number(),
4530
4745
  /** Prior value compared against. When `window` is present this is the
4531
4746
  * average over the prior `window` checks before that. */
4532
- prior: z28.number(),
4747
+ prior: z29.number(),
4533
4748
  /** Absolute delta (current − prior). Negative = decrease. */
4534
- deltaAbs: z28.number(),
4749
+ deltaAbs: z29.number(),
4535
4750
  /**
4536
4751
  * Signed percent change vs `prior`, rounded to a whole number. Null when
4537
4752
  * `prior <= 0` (percentage undefined). Renderers route count/traffic tiles
4538
4753
  * through the "smart %" rule — percentage when the prior base is large
4539
4754
  * enough (`MIN_PCT_BASE`), otherwise a rounded raw delta.
4540
4755
  */
4541
- deltaPct: z28.number().nullable(),
4756
+ deltaPct: z29.number().nullable(),
4542
4757
  /**
4543
4758
  * Direction tag for tone mapping. Threshold is metric-specific (3pp for
4544
4759
  * rates, 0.5 for counts) so small noise lands as 'flat' rather than
4545
4760
  * flipping up/down each run.
4546
4761
  */
4547
- direction: z28.enum(["up", "down", "flat"]),
4762
+ direction: z29.enum(["up", "down", "flat"]),
4548
4763
  /**
4549
4764
  * How many points went into each side of the average. Omitted (or 1)
4550
4765
  * means point-to-point (legacy "since last check"). Higher values mean
4551
4766
  * a rolling-average comparison — renderers should label it as
4552
4767
  * "vs prior N checks" when this is ≥ 2.
4553
4768
  */
4554
- window: z28.number().optional()
4769
+ window: z29.number().optional()
4555
4770
  });
4556
- var reportProviderMovementSchema = z28.object({
4557
- provider: z28.string(),
4558
- current: z28.number(),
4559
- prior: z28.number(),
4560
- deltaAbs: z28.number(),
4561
- direction: z28.enum(["up", "down", "flat"])
4771
+ var reportProviderMovementSchema = z29.object({
4772
+ provider: z29.string(),
4773
+ current: z29.number(),
4774
+ prior: z29.number(),
4775
+ deltaAbs: z29.number(),
4776
+ direction: z29.enum(["up", "down", "flat"])
4562
4777
  });
4563
- var whatsChangedSectionSchema = z28.object({
4778
+ var whatsChangedSectionSchema = z29.object({
4564
4779
  /**
4565
4780
  * False when there's no prior run (or fewer than the trend baseline),
4566
4781
  * meaning all per-metric deltas will be null. Renderers use this to swap
4567
4782
  * in a "establishing baseline" fallback rather than rendering empty
4568
4783
  * delta tiles.
4569
4784
  */
4570
- enoughHistory: z28.boolean(),
4785
+ enoughHistory: z29.boolean(),
4571
4786
  /**
4572
4787
  * One-sentence narrative summary suitable as a section subtitle.
4573
4788
  * Always present — even on baseline, narrates whatever signal exists.
4574
4789
  */
4575
- headline: z28.string(),
4790
+ headline: z29.string(),
4576
4791
  /** Citation rate delta vs the prior completed run. Null when no prior run. */
4577
4792
  citationRate: reportRateDeltaSchema.nullable(),
4578
4793
  /** Mention rate delta vs the prior completed run. Null when no prior run. */
@@ -4600,30 +4815,30 @@ var whatsChangedSectionSchema = z28.object({
4600
4815
  * deltas "vs prior {comparisonWindowDays} days" off this single value so the
4601
4816
  * SPA and HTML stay verbatim-identical.
4602
4817
  */
4603
- comparisonWindowDays: z28.number().int().positive(),
4818
+ comparisonWindowDays: z29.number().int().positive(),
4604
4819
  /**
4605
4820
  * Per-provider citation rate movements (latest run vs prior run). Empty
4606
4821
  * when no prior run. Sorted by |deltaAbs| desc — providers with the
4607
4822
  * biggest swing first.
4608
4823
  */
4609
- providerMovements: z28.array(reportProviderMovementSchema),
4824
+ providerMovements: z29.array(reportProviderMovementSchema),
4610
4825
  /**
4611
4826
  * Top wins this period — gains surfaced by the intelligence engine.
4612
4827
  * Capped at 5; sourced from `insights` filtered to `type: 'gain'`.
4613
4828
  */
4614
- wins: z28.array(reportInsightSchema),
4829
+ wins: z29.array(reportInsightSchema),
4615
4830
  /**
4616
4831
  * Top regressions this period — citations or mentions lost. Capped at 5;
4617
4832
  * sourced from `insights` filtered to `type: 'regression'`.
4618
4833
  */
4619
- regressions: z28.array(reportInsightSchema)
4620
- });
4621
- var reportAudienceSchema = z28.enum(["agency", "client"]);
4622
- var reportActionAudienceSchema = z28.enum(["agency", "client", "both"]);
4623
- var reportActionHorizonSchema = z28.enum(["immediate", "short-term", "medium-term"]);
4624
- var reportActionConfidenceSchema = z28.enum(["high", "medium", "low"]);
4625
- var reportToneSchema = z28.enum(["positive", "caution", "negative", "neutral"]);
4626
- var reportActionCategorySchema = z28.enum([
4834
+ regressions: z29.array(reportInsightSchema)
4835
+ });
4836
+ var reportAudienceSchema = z29.enum(["agency", "client"]);
4837
+ var reportActionAudienceSchema = z29.enum(["agency", "client", "both"]);
4838
+ var reportActionHorizonSchema = z29.enum(["immediate", "short-term", "medium-term"]);
4839
+ var reportActionConfidenceSchema = z29.enum(["high", "medium", "low"]);
4840
+ var reportToneSchema = z29.enum(["positive", "caution", "negative", "neutral"]);
4841
+ var reportActionCategorySchema = z29.enum([
4627
4842
  "content",
4628
4843
  "competitors",
4629
4844
  "provider",
@@ -4632,23 +4847,23 @@ var reportActionCategorySchema = z28.enum([
4632
4847
  "location",
4633
4848
  "monitoring"
4634
4849
  ]);
4635
- var reportActionPlanItemSchema = z28.object({
4850
+ var reportActionPlanItemSchema = z29.object({
4636
4851
  /** Which report audience should see this action. `both` renders in both modes. */
4637
4852
  audience: reportActionAudienceSchema,
4638
4853
  /** Stable sort priority. Lower numbers render earlier. */
4639
- priority: z28.number(),
4854
+ priority: z29.number(),
4640
4855
  /** When this should be tackled. */
4641
4856
  horizon: reportActionHorizonSchema,
4642
4857
  category: reportActionCategorySchema,
4643
- title: z28.string(),
4858
+ title: z29.string(),
4644
4859
  /** Direct next step written as an operator/client-friendly imperative. */
4645
- action: z28.string(),
4860
+ action: z29.string(),
4646
4861
  /** Why this matters. Keep each entry concise and evidence-backed. */
4647
- why: z28.array(z28.string()),
4862
+ why: z29.array(z29.string()),
4648
4863
  /** Specific observations that justify the action. */
4649
- evidence: z28.array(z28.string()),
4864
+ evidence: z29.array(z29.string()),
4650
4865
  /** What should move if the action worked. */
4651
- successMetric: z28.string(),
4866
+ successMetric: z29.string(),
4652
4867
  /** Confidence in the recommendation based on the available evidence. */
4653
4868
  confidence: reportActionConfidenceSchema,
4654
4869
  /**
@@ -4660,23 +4875,23 @@ var reportActionPlanItemSchema = z28.object({
4660
4875
  * load. Actions sourced from other signals (competitor gaps, indexing
4661
4876
  * issues, etc.) omit this and use their own dismiss flows.
4662
4877
  */
4663
- targetRef: z28.string().optional()
4878
+ targetRef: z29.string().optional()
4664
4879
  });
4665
- var reportClientSummarySchema = z28.object({
4666
- headline: z28.string(),
4667
- overview: z28.string(),
4668
- actionItems: z28.array(reportActionPlanItemSchema),
4669
- confidenceNotes: z28.array(z28.string())
4880
+ var reportClientSummarySchema = z29.object({
4881
+ headline: z29.string(),
4882
+ overview: z29.string(),
4883
+ actionItems: z29.array(reportActionPlanItemSchema),
4884
+ confidenceNotes: z29.array(z29.string())
4670
4885
  });
4671
- var reportAgencyDiagnosticSchema = z28.object({
4672
- title: z28.string(),
4673
- detail: z28.string(),
4674
- severity: z28.enum(["positive", "caution", "negative", "neutral"]),
4675
- evidence: z28.array(z28.string())
4886
+ var reportAgencyDiagnosticSchema = z29.object({
4887
+ title: z29.string(),
4888
+ detail: z29.string(),
4889
+ severity: z29.enum(["positive", "caution", "negative", "neutral"]),
4890
+ evidence: z29.array(z29.string())
4676
4891
  });
4677
- var reportAgencyDiagnosticsSchema = z28.object({
4678
- priorities: z28.array(reportActionPlanItemSchema),
4679
- diagnostics: z28.array(reportAgencyDiagnosticSchema)
4892
+ var reportAgencyDiagnosticsSchema = z29.object({
4893
+ priorities: z29.array(reportActionPlanItemSchema),
4894
+ diagnostics: z29.array(reportAgencyDiagnosticSchema)
4680
4895
  });
4681
4896
  function reportActionTone(action) {
4682
4897
  if (action.horizon === "immediate") return "negative";
@@ -4734,7 +4949,7 @@ function reportConfidenceLabel(confidence) {
4734
4949
  return "Low";
4735
4950
  }
4736
4951
  }
4737
- var projectReportDtoSchema = z28.object({
4952
+ var projectReportDtoSchema = z29.object({
4738
4953
  meta: reportMetaSchema,
4739
4954
  executiveSummary: reportExecutiveSummarySchema,
4740
4955
  citationScorecard: citationScorecardSchema,
@@ -4748,16 +4963,16 @@ var projectReportDtoSchema = z28.object({
4748
4963
  /** Server-side log-evidence visibility (crawls + click-through sessions). Null when no traffic source connected. */
4749
4964
  serverActivity: serverActivitySectionSchema.nullable(),
4750
4965
  indexingHealth: indexingHealthSectionSchema.nullable(),
4751
- citationsTrend: z28.array(citationsTrendPointSchema),
4966
+ citationsTrend: z29.array(citationsTrendPointSchema),
4752
4967
  /**
4753
4968
  * Trend-focused "what's changed" summary for the report's act 2. Always
4754
4969
  * present; renderers gate empty/baseline states via `enoughHistory`.
4755
4970
  */
4756
4971
  whatsChanged: whatsChangedSectionSchema,
4757
- insights: z28.array(reportInsightSchema),
4758
- recommendedNextSteps: z28.array(recommendedNextStepSchema),
4972
+ insights: z29.array(reportInsightSchema),
4973
+ recommendedNextSteps: z29.array(recommendedNextStepSchema),
4759
4974
  /** Canonical structured actions shared by the client and agency render modes. */
4760
- actionPlan: z28.array(reportActionPlanItemSchema),
4975
+ actionPlan: z29.array(reportActionPlanItemSchema),
4761
4976
  /** Polished client-facing summary and action shortlist. */
4762
4977
  clientSummary: reportClientSummarySchema,
4763
4978
  /** Technical, evidence-oriented operator diagnostics for agency mode. */
@@ -4767,17 +4982,17 @@ var projectReportDtoSchema = z28.object({
4767
4982
  * intelligence layer (`buildContentTargetRows`). Empty when no run has
4768
4983
  * produced candidate queries with demand or competitor signal.
4769
4984
  */
4770
- contentOpportunities: z28.array(contentTargetRowDtoSchema),
4985
+ contentOpportunities: z29.array(contentTargetRowDtoSchema),
4771
4986
  /**
4772
4987
  * Queries where competitors were cited but the project was not. Sourced
4773
4988
  * from `buildContentGapRows`. Empty until the first answer-visibility run.
4774
4989
  */
4775
- contentGaps: z28.array(contentGapRowDtoSchema),
4990
+ contentGaps: z29.array(contentGapRowDtoSchema),
4776
4991
  /**
4777
4992
  * Per-query grounding source map (own + competitor cited URLs). Sourced
4778
4993
  * from `buildContentSourceRows`. Empty until the first answer-visibility run.
4779
4994
  */
4780
- groundingSources: z28.array(contentSourceRowDtoSchema)
4995
+ groundingSources: z29.array(contentSourceRowDtoSchema)
4781
4996
  });
4782
4997
 
4783
4998
  // ../contracts/src/report-dedup.ts
@@ -4848,10 +5063,10 @@ function dedupeReportOpportunities(report) {
4848
5063
  }
4849
5064
 
4850
5065
  // ../contracts/src/skills.ts
4851
- import { z as z29 } from "zod";
4852
- var codingAgentSchema = z29.enum(["claude", "codex"]);
5066
+ import { z as z30 } from "zod";
5067
+ var codingAgentSchema = z30.enum(["claude", "codex"]);
4853
5068
  var CodingAgents = codingAgentSchema.enum;
4854
- var skillsClientSchema = z29.enum(["claude", "codex", "all"]);
5069
+ var skillsClientSchema = z30.enum(["claude", "codex", "all"]);
4855
5070
  var SkillsClients = skillsClientSchema.enum;
4856
5071
  var SKILL_MANIFEST_FILENAME = ".canonry-skill-manifest.json";
4857
5072
  function classifySkillFile(params) {
@@ -4869,22 +5084,22 @@ function coerceSkillManifest(parsed) {
4869
5084
  }
4870
5085
 
4871
5086
  // ../contracts/src/traffic.ts
4872
- import { z as z30 } from "zod";
4873
- var trafficCrawlerSegmentsSchema = z30.object({
4874
- content: z30.number().int().nonnegative(),
4875
- sitemap: z30.number().int().nonnegative(),
4876
- robots: z30.number().int().nonnegative(),
4877
- asset: z30.number().int().nonnegative(),
4878
- other: z30.number().int().nonnegative()
4879
- });
4880
- var trafficPathClassSchema = z30.enum([
5087
+ import { z as z31 } from "zod";
5088
+ var trafficCrawlerSegmentsSchema = z31.object({
5089
+ content: z31.number().int().nonnegative(),
5090
+ sitemap: z31.number().int().nonnegative(),
5091
+ robots: z31.number().int().nonnegative(),
5092
+ asset: z31.number().int().nonnegative(),
5093
+ other: z31.number().int().nonnegative()
5094
+ });
5095
+ var trafficPathClassSchema = z31.enum([
4881
5096
  "content",
4882
5097
  "sitemap",
4883
5098
  "robots",
4884
5099
  "asset",
4885
5100
  "other"
4886
5101
  ]);
4887
- var trafficSourceTypeSchema = z30.enum([
5102
+ var trafficSourceTypeSchema = z31.enum([
4888
5103
  "cloud-run",
4889
5104
  "wordpress",
4890
5105
  "cloudflare",
@@ -4892,7 +5107,7 @@ var trafficSourceTypeSchema = z30.enum([
4892
5107
  "generic-log"
4893
5108
  ]);
4894
5109
  var TrafficSourceTypes = trafficSourceTypeSchema.enum;
4895
- var trafficAdapterCapabilitySchema = z30.enum([
5110
+ var trafficAdapterCapabilitySchema = z31.enum([
4896
5111
  "raw-request-events",
4897
5112
  "aggregate-request-metrics",
4898
5113
  "request-url",
@@ -4903,234 +5118,252 @@ var trafficAdapterCapabilitySchema = z30.enum([
4903
5118
  "cursor-pull"
4904
5119
  ]);
4905
5120
  var TrafficAdapterCapabilities = trafficAdapterCapabilitySchema.enum;
4906
- var trafficEvidenceKindSchema = z30.enum(["raw-request", "aggregate-bucket"]);
5121
+ var trafficEvidenceKindSchema = z31.enum(["raw-request", "aggregate-bucket"]);
4907
5122
  var TrafficEvidenceKinds = trafficEvidenceKindSchema.enum;
4908
- var trafficEventConfidenceSchema = z30.enum(["observed", "provider-aggregated", "inferred"]);
5123
+ var trafficEventConfidenceSchema = z31.enum(["observed", "provider-aggregated", "inferred"]);
4909
5124
  var TrafficEventConfidences = trafficEventConfidenceSchema.enum;
4910
- var trafficProviderResourceSchema = z30.object({
4911
- type: z30.string().nullable(),
4912
- labels: z30.record(z30.string(), z30.string())
5125
+ var trafficProviderResourceSchema = z31.object({
5126
+ type: z31.string().nullable(),
5127
+ labels: z31.record(z31.string(), z31.string())
4913
5128
  });
4914
- var normalizedTrafficRequestSchema = z30.object({
5129
+ var normalizedTrafficRequestSchema = z31.object({
4915
5130
  sourceType: trafficSourceTypeSchema,
4916
- evidenceKind: z30.literal(TrafficEvidenceKinds["raw-request"]),
4917
- confidence: z30.literal(TrafficEventConfidences.observed),
4918
- eventId: z30.string().min(1),
4919
- observedAt: z30.string().min(1),
4920
- method: z30.string().nullable(),
4921
- requestUrl: z30.string().nullable(),
4922
- host: z30.string().nullable(),
4923
- path: z30.string().min(1),
4924
- queryString: z30.string().nullable(),
4925
- status: z30.number().int().nullable(),
4926
- userAgent: z30.string().nullable(),
4927
- remoteIp: z30.string().nullable(),
4928
- referer: z30.string().nullable(),
4929
- latencyMs: z30.number().nullable(),
4930
- requestSizeBytes: z30.number().int().nullable(),
4931
- responseSizeBytes: z30.number().int().nullable(),
5131
+ evidenceKind: z31.literal(TrafficEvidenceKinds["raw-request"]),
5132
+ confidence: z31.literal(TrafficEventConfidences.observed),
5133
+ eventId: z31.string().min(1),
5134
+ observedAt: z31.string().min(1),
5135
+ method: z31.string().nullable(),
5136
+ requestUrl: z31.string().nullable(),
5137
+ host: z31.string().nullable(),
5138
+ path: z31.string().min(1),
5139
+ queryString: z31.string().nullable(),
5140
+ status: z31.number().int().nullable(),
5141
+ userAgent: z31.string().nullable(),
5142
+ remoteIp: z31.string().nullable(),
5143
+ referer: z31.string().nullable(),
5144
+ latencyMs: z31.number().nullable(),
5145
+ requestSizeBytes: z31.number().int().nullable(),
5146
+ responseSizeBytes: z31.number().int().nullable(),
4932
5147
  providerResource: trafficProviderResourceSchema,
4933
- providerLabels: z30.record(z30.string(), z30.string())
5148
+ providerLabels: z31.record(z31.string(), z31.string())
4934
5149
  });
4935
- var normalizedTrafficPullPageSchema = z30.object({
4936
- events: z30.array(normalizedTrafficRequestSchema),
4937
- rawEntryCount: z30.number().int().nonnegative(),
4938
- skippedEntryCount: z30.number().int().nonnegative(),
4939
- nextPageToken: z30.string().optional(),
4940
- filter: z30.string()
5150
+ var normalizedTrafficPullPageSchema = z31.object({
5151
+ events: z31.array(normalizedTrafficRequestSchema),
5152
+ rawEntryCount: z31.number().int().nonnegative(),
5153
+ skippedEntryCount: z31.number().int().nonnegative(),
5154
+ nextPageToken: z31.string().optional(),
5155
+ filter: z31.string()
4941
5156
  });
4942
- var trafficSourceStatusSchema = z30.enum(["connected", "paused", "error", "archived"]);
5157
+ var trafficSourceStatusSchema = z31.enum(["connected", "paused", "error", "archived"]);
4943
5158
  var TrafficSourceStatuses = trafficSourceStatusSchema.enum;
4944
- var trafficSourceAuthModeSchema = z30.enum(["oauth", "service-account"]);
5159
+ var trafficSourceAuthModeSchema = z31.enum(["oauth", "service-account"]);
4945
5160
  var TrafficSourceAuthModes = trafficSourceAuthModeSchema.enum;
4946
- var verificationStatusSchema = z30.enum(["verified", "claimed_unverified", "unknown_ai_like"]);
5161
+ var verificationStatusSchema = z31.enum(["verified", "claimed_unverified", "unknown_ai_like"]);
4947
5162
  var VerificationStatuses = verificationStatusSchema.enum;
4948
- var cloudRunSourceConfigSchema = z30.object({
4949
- gcpProjectId: z30.string().min(1),
4950
- serviceName: z30.string().nullable().optional(),
4951
- location: z30.string().nullable().optional(),
5163
+ var cloudRunSourceConfigSchema = z31.object({
5164
+ gcpProjectId: z31.string().min(1),
5165
+ serviceName: z31.string().nullable().optional(),
5166
+ location: z31.string().nullable().optional(),
4952
5167
  authMode: trafficSourceAuthModeSchema
4953
5168
  });
4954
- var wordpressTrafficSourceConfigSchema = z30.object({
4955
- baseUrl: z30.string().url(),
4956
- username: z30.string().min(1)
5169
+ var wordpressTrafficSourceConfigSchema = z31.object({
5170
+ baseUrl: z31.string().url(),
5171
+ username: z31.string().min(1)
4957
5172
  });
4958
- var vercelTrafficEnvironmentSchema = z30.enum(["production", "preview"]);
5173
+ var vercelTrafficEnvironmentSchema = z31.enum(["production", "preview"]);
4959
5174
  var VercelTrafficEnvironments = vercelTrafficEnvironmentSchema.enum;
4960
- var vercelTrafficSourceConfigSchema = z30.object({
5175
+ var vercelTrafficSourceConfigSchema = z31.object({
4961
5176
  /** Vercel project id (e.g. `prj_...`). */
4962
- projectId: z30.string().min(1),
5177
+ projectId: z31.string().min(1),
4963
5178
  /** Vercel team or account id: the org that owns the project. */
4964
- teamId: z30.string().min(1),
5179
+ teamId: z31.string().min(1),
4965
5180
  environment: vercelTrafficEnvironmentSchema
4966
5181
  });
4967
- var trafficSourceDtoSchema = z30.object({
4968
- id: z30.string(),
4969
- projectId: z30.string(),
5182
+ var trafficSourceDtoSchema = z31.object({
5183
+ id: z31.string(),
5184
+ projectId: z31.string(),
4970
5185
  sourceType: trafficSourceTypeSchema,
4971
- displayName: z30.string(),
5186
+ displayName: z31.string(),
4972
5187
  status: trafficSourceStatusSchema,
4973
- lastSyncedAt: z30.string().nullable(),
4974
- lastCursor: z30.string().nullable(),
4975
- lastError: z30.string().nullable(),
4976
- archivedAt: z30.string().nullable(),
4977
- config: z30.record(z30.string(), z30.unknown()),
4978
- createdAt: z30.string(),
4979
- updatedAt: z30.string()
4980
- });
4981
- var trafficConnectCloudRunRequestSchema = z30.object({
4982
- gcpProjectId: z30.string().min(1),
4983
- serviceName: z30.string().min(1).optional(),
4984
- location: z30.string().min(1).optional(),
4985
- displayName: z30.string().min(1).optional(),
5188
+ lastSyncedAt: z31.string().nullable(),
5189
+ lastCursor: z31.string().nullable(),
5190
+ lastError: z31.string().nullable(),
5191
+ archivedAt: z31.string().nullable(),
5192
+ config: z31.record(z31.string(), z31.unknown()),
5193
+ createdAt: z31.string(),
5194
+ updatedAt: z31.string()
5195
+ });
5196
+ var trafficConnectCloudRunRequestSchema = z31.object({
5197
+ gcpProjectId: z31.string().min(1),
5198
+ serviceName: z31.string().min(1).optional(),
5199
+ location: z31.string().min(1).optional(),
5200
+ displayName: z31.string().min(1).optional(),
4986
5201
  /** Service-account JSON content (string). When omitted, defaults to OAuth via `canonry google connect <project> --type ga4` flow. */
4987
- keyJson: z30.string().optional()
5202
+ keyJson: z31.string().optional()
4988
5203
  });
4989
- var trafficConnectWordpressRequestSchema = z30.object({
4990
- baseUrl: z30.string().url(),
4991
- username: z30.string().min(1),
5204
+ var trafficConnectWordpressRequestSchema = z31.object({
5205
+ baseUrl: z31.string().url(),
5206
+ username: z31.string().min(1),
4992
5207
  /** WordPress Application Password (the same auth used by the content client). */
4993
- applicationPassword: z30.string().min(1),
4994
- displayName: z30.string().min(1).optional()
5208
+ applicationPassword: z31.string().min(1),
5209
+ displayName: z31.string().min(1).optional()
4995
5210
  });
4996
- var trafficConnectVercelRequestSchema = z30.object({
5211
+ var trafficConnectVercelRequestSchema = z31.object({
4997
5212
  /** Vercel project id (e.g. `prj_...`) — from the Vercel dashboard or `.vercel/project.json`. */
4998
- projectId: z30.string().min(1),
5213
+ projectId: z31.string().min(1),
4999
5214
  /** Vercel team or account id: the org that owns the project ("orgId" in .vercel/project.json). */
5000
- teamId: z30.string().min(1),
5215
+ teamId: z31.string().min(1),
5001
5216
  /** Vercel personal access token. Stored in `~/.canonry/config.yaml`, never the DB. */
5002
- token: z30.string().min(1),
5217
+ token: z31.string().min(1),
5003
5218
  /** Which deployment environment's request logs to pull. Default: `production`. */
5004
5219
  environment: vercelTrafficEnvironmentSchema.optional(),
5005
- displayName: z30.string().min(1).optional()
5220
+ displayName: z31.string().min(1).optional()
5006
5221
  });
5007
- var trafficSyncResponseSchema = z30.object({
5008
- sourceId: z30.string(),
5009
- runId: z30.string(),
5010
- syncedAt: z30.string(),
5011
- pulledEvents: z30.number().int().nonnegative(),
5222
+ var trafficSyncResponseSchema = z31.object({
5223
+ sourceId: z31.string(),
5224
+ runId: z31.string(),
5225
+ syncedAt: z31.string(),
5226
+ pulledEvents: z31.number().int().nonnegative(),
5012
5227
  /** Self-traffic events (Canonry's own tooling) dropped before rollup. */
5013
- selfTrafficExcluded: z30.number().int().nonnegative(),
5014
- crawlerHits: z30.number().int().nonnegative(),
5015
- aiUserFetchHits: z30.number().int().nonnegative(),
5016
- aiReferralHits: z30.number().int().nonnegative(),
5017
- unknownHits: z30.number().int().nonnegative(),
5018
- crawlerBucketRows: z30.number().int().nonnegative(),
5019
- aiUserFetchBucketRows: z30.number().int().nonnegative(),
5020
- aiReferralBucketRows: z30.number().int().nonnegative(),
5021
- sampleRows: z30.number().int().nonnegative(),
5022
- windowStart: z30.string(),
5023
- windowEnd: z30.string()
5024
- });
5025
- var trafficBackfillRequestSchema = z30.object({
5228
+ selfTrafficExcluded: z31.number().int().nonnegative(),
5229
+ crawlerHits: z31.number().int().nonnegative(),
5230
+ aiUserFetchHits: z31.number().int().nonnegative(),
5231
+ aiReferralHits: z31.number().int().nonnegative(),
5232
+ unknownHits: z31.number().int().nonnegative(),
5233
+ crawlerBucketRows: z31.number().int().nonnegative(),
5234
+ aiUserFetchBucketRows: z31.number().int().nonnegative(),
5235
+ aiReferralBucketRows: z31.number().int().nonnegative(),
5236
+ sampleRows: z31.number().int().nonnegative(),
5237
+ windowStart: z31.string(),
5238
+ windowEnd: z31.string()
5239
+ });
5240
+ var trafficBackfillRequestSchema = z31.object({
5026
5241
  /** Lookback window in days. Capped server-side at the upstream log retention ceiling (Cloud Logging _Default = 30d). Default: 30. */
5027
- days: z30.number().int().positive().optional()
5242
+ days: z31.number().int().positive().optional()
5028
5243
  });
5029
- var trafficResetRequestSchema = z30.object({
5030
- advanceToNow: z30.literal(true)
5244
+ var trafficResetRequestSchema = z31.object({
5245
+ advanceToNow: z31.literal(true)
5031
5246
  });
5032
- var trafficBackfillResponseSchema = z30.object({
5033
- sourceId: z30.string(),
5034
- runId: z30.string(),
5247
+ var trafficBackfillResponseSchema = z31.object({
5248
+ sourceId: z31.string(),
5249
+ runId: z31.string(),
5035
5250
  status: runStatusSchema,
5036
- windowStart: z30.string(),
5037
- windowEnd: z30.string(),
5251
+ windowStart: z31.string(),
5252
+ windowEnd: z31.string(),
5038
5253
  /** Days actually used after server-side clamping (≤ requested). */
5039
- daysRequested: z30.number().int().positive(),
5040
- daysApplied: z30.number().int().positive()
5254
+ daysRequested: z31.number().int().positive(),
5255
+ daysApplied: z31.number().int().positive()
5041
5256
  });
5042
- var trafficSourceTotalsSchema = z30.object({
5257
+ var trafficSourceTotalsSchema = z31.object({
5043
5258
  /**
5044
5259
  * Total classified-crawler hits in the window. UNCHANGED contract — still the
5045
5260
  * full count across every path class. Use `crawlerContentHits` for the
5046
5261
  * "content was actually crawled" signal.
5047
5262
  */
5048
- crawlerHits: z30.number().int().nonnegative(),
5263
+ crawlerHits: z31.number().int().nonnegative(),
5049
5264
  /** Crawler hits against content/document paths only (= `crawlerSegments.content`). */
5050
- crawlerContentHits: z30.number().int().nonnegative(),
5265
+ crawlerContentHits: z31.number().int().nonnegative(),
5051
5266
  /** Infrastructure crawler hits — sitemap + robots + asset fetches (`crawlerSegments.{sitemap,robots,asset}`). */
5052
- crawlerInfraHits: z30.number().int().nonnegative(),
5267
+ crawlerInfraHits: z31.number().int().nonnegative(),
5053
5268
  /** Full per-class crawler-hit breakdown; the five buckets sum to `crawlerHits`. */
5054
5269
  crawlerSegments: trafficCrawlerSegmentsSchema,
5055
- aiUserFetchHits: z30.number().int().nonnegative(),
5056
- aiReferralHits: z30.number().int().nonnegative(),
5057
- sampleCount: z30.number().int().nonnegative()
5270
+ aiUserFetchHits: z31.number().int().nonnegative(),
5271
+ aiReferralHits: z31.number().int().nonnegative(),
5272
+ sampleCount: z31.number().int().nonnegative()
5058
5273
  });
5059
- var trafficSourceListResponseSchema = z30.object({
5060
- sources: z30.array(trafficSourceDtoSchema)
5274
+ var trafficSourceListResponseSchema = z31.object({
5275
+ sources: z31.array(trafficSourceDtoSchema)
5061
5276
  });
5062
5277
  var trafficSourceDetailDtoSchema = trafficSourceDtoSchema.extend({
5063
5278
  totals24h: trafficSourceTotalsSchema,
5064
- latestRun: z30.object({
5065
- runId: z30.string(),
5279
+ latestRun: z31.object({
5280
+ runId: z31.string(),
5066
5281
  status: runStatusSchema,
5067
- startedAt: z30.string().nullable(),
5068
- finishedAt: z30.string().nullable(),
5069
- error: z30.string().nullable()
5282
+ startedAt: z31.string().nullable(),
5283
+ finishedAt: z31.string().nullable(),
5284
+ error: z31.string().nullable()
5070
5285
  }).nullable()
5071
5286
  });
5072
- var trafficStatusResponseSchema = z30.object({
5073
- sources: z30.array(trafficSourceDetailDtoSchema)
5287
+ var trafficStatusResponseSchema = z31.object({
5288
+ sources: z31.array(trafficSourceDetailDtoSchema)
5074
5289
  });
5075
- var trafficEventKindSchema = z30.enum(["crawler", "ai-user-fetch", "ai-referral"]);
5290
+ var trafficEventKindSchema = z31.enum(["crawler", "ai-user-fetch", "ai-referral"]);
5076
5291
  var TrafficEventKinds = trafficEventKindSchema.enum;
5077
- var trafficCrawlerEventEntrySchema = z30.object({
5078
- kind: z30.literal(TrafficEventKinds.crawler),
5079
- sourceId: z30.string(),
5080
- tsHour: z30.string(),
5081
- botId: z30.string(),
5082
- operator: z30.string(),
5083
- verificationStatus: z30.string(),
5084
- pathNormalized: z30.string(),
5292
+ var trafficCrawlerEventEntrySchema = z31.object({
5293
+ kind: z31.literal(TrafficEventKinds.crawler),
5294
+ sourceId: z31.string(),
5295
+ tsHour: z31.string(),
5296
+ botId: z31.string(),
5297
+ operator: z31.string(),
5298
+ verificationStatus: z31.string(),
5299
+ pathNormalized: z31.string(),
5085
5300
  /** Coarse class of the fetched path — lets the UI split content crawls from sitemap/robots/asset polling. */
5086
5301
  pathClass: trafficPathClassSchema,
5087
- status: z30.number().int(),
5088
- hits: z30.number().int().nonnegative()
5089
- });
5090
- var trafficAiUserFetchEventEntrySchema = z30.object({
5091
- kind: z30.literal(TrafficEventKinds["ai-user-fetch"]),
5092
- sourceId: z30.string(),
5093
- tsHour: z30.string(),
5094
- botId: z30.string(),
5095
- operator: z30.string(),
5096
- verificationStatus: z30.string(),
5097
- pathNormalized: z30.string(),
5098
- status: z30.number().int(),
5099
- hits: z30.number().int().nonnegative()
5100
- });
5101
- var trafficAiReferralEventEntrySchema = z30.object({
5102
- kind: z30.literal(TrafficEventKinds["ai-referral"]),
5103
- sourceId: z30.string(),
5104
- tsHour: z30.string(),
5105
- product: z30.string(),
5106
- operator: z30.string(),
5107
- sourceDomain: z30.string(),
5108
- evidenceType: z30.string(),
5109
- landingPathNormalized: z30.string(),
5110
- status: z30.number().int(),
5111
- hits: z30.number().int().nonnegative()
5112
- });
5113
- var trafficEventEntrySchema = z30.discriminatedUnion("kind", [
5302
+ status: z31.number().int(),
5303
+ hits: z31.number().int().nonnegative()
5304
+ });
5305
+ var trafficAiUserFetchEventEntrySchema = z31.object({
5306
+ kind: z31.literal(TrafficEventKinds["ai-user-fetch"]),
5307
+ sourceId: z31.string(),
5308
+ tsHour: z31.string(),
5309
+ botId: z31.string(),
5310
+ operator: z31.string(),
5311
+ verificationStatus: z31.string(),
5312
+ pathNormalized: z31.string(),
5313
+ status: z31.number().int(),
5314
+ hits: z31.number().int().nonnegative()
5315
+ });
5316
+ var trafficAiReferralEventEntrySchema = z31.object({
5317
+ kind: z31.literal(TrafficEventKinds["ai-referral"]),
5318
+ sourceId: z31.string(),
5319
+ tsHour: z31.string(),
5320
+ product: z31.string(),
5321
+ operator: z31.string(),
5322
+ sourceDomain: z31.string(),
5323
+ evidenceType: z31.string(),
5324
+ landingPathNormalized: z31.string(),
5325
+ status: z31.number().int(),
5326
+ /** Total AI-referral sessions in the bucket. `paidHits + organicHits + unknownHits === hits`. */
5327
+ hits: z31.number().int().nonnegative(),
5328
+ /** Sessions carrying paid-attribution UTM evidence (`utm_medium=cpc`, …). */
5329
+ paidHits: z31.number().int().nonnegative(),
5330
+ /** Sessions with no paid-attribution evidence. Not proof the click was unpaid — an untagged ad click is indistinguishable. */
5331
+ organicHits: z31.number().int().nonnegative(),
5332
+ /**
5333
+ * Sessions ingested before the classifier shipped. Their UTM tags were never
5334
+ * persisted, so they can never be resolved to paid or organic. Never fold
5335
+ * these into `organicHits`.
5336
+ */
5337
+ unknownHits: z31.number().int().nonnegative()
5338
+ });
5339
+ var trafficEventEntrySchema = z31.discriminatedUnion("kind", [
5114
5340
  trafficCrawlerEventEntrySchema,
5115
5341
  trafficAiUserFetchEventEntrySchema,
5116
5342
  trafficAiReferralEventEntrySchema
5117
5343
  ]);
5118
- var trafficEventsResponseSchema = z30.object({
5119
- windowStart: z30.string(),
5120
- windowEnd: z30.string(),
5121
- totals: z30.object({
5344
+ var trafficEventsResponseSchema = z31.object({
5345
+ windowStart: z31.string(),
5346
+ windowEnd: z31.string(),
5347
+ totals: z31.object({
5122
5348
  /** Total classified-crawler hits across the window. UNCHANGED contract. */
5123
- crawlerHits: z30.number().int().nonnegative(),
5349
+ crawlerHits: z31.number().int().nonnegative(),
5124
5350
  /** Crawler hits against content/document paths only (= `crawlerSegments.content`). */
5125
- crawlerContentHits: z30.number().int().nonnegative(),
5351
+ crawlerContentHits: z31.number().int().nonnegative(),
5126
5352
  /** Infrastructure crawler hits — sitemap + robots + asset fetches. */
5127
- crawlerInfraHits: z30.number().int().nonnegative(),
5353
+ crawlerInfraHits: z31.number().int().nonnegative(),
5128
5354
  /** Full per-class crawler-hit breakdown; the five buckets sum to `crawlerHits`. */
5129
5355
  crawlerSegments: trafficCrawlerSegmentsSchema,
5130
- aiUserFetchHits: z30.number().int().nonnegative(),
5131
- aiReferralHits: z30.number().int().nonnegative()
5356
+ aiUserFetchHits: z31.number().int().nonnegative(),
5357
+ /** Total AI-referral sessions. The three class buckets below sum to it. */
5358
+ aiReferralHits: z31.number().int().nonnegative(),
5359
+ /** AI-referral sessions carrying paid-attribution UTM evidence. */
5360
+ aiReferralPaidHits: z31.number().int().nonnegative(),
5361
+ /** AI-referral sessions with no paid-attribution evidence. */
5362
+ aiReferralOrganicHits: z31.number().int().nonnegative(),
5363
+ /** AI-referral sessions ingested before the classifier shipped; unresolvable, never organic. */
5364
+ aiReferralUnknownHits: z31.number().int().nonnegative()
5132
5365
  }),
5133
- events: z30.array(trafficEventEntrySchema)
5366
+ events: z31.array(trafficEventEntrySchema)
5134
5367
  });
5135
5368
 
5136
5369
  // ../contracts/src/traffic-path.ts
@@ -5268,199 +5501,115 @@ function sumInfraHits(segments) {
5268
5501
  return segments.sitemap + segments.robots + segments.asset;
5269
5502
  }
5270
5503
 
5271
- // ../contracts/src/formatting.ts
5272
- function formatRatio(value) {
5273
- if (!Number.isFinite(value) || value === 0) return "0%";
5274
- return `${(value * 100).toFixed(1)}%`;
5275
- }
5276
- function formatNumber(value) {
5277
- if (!Number.isFinite(value)) return "\u2014";
5278
- if (Math.abs(value) >= 1e6) return `${(value / 1e6).toFixed(1)}M`;
5279
- if (Math.abs(value) >= 1e3) return `${(value / 1e3).toFixed(1)}K`;
5280
- return value.toLocaleString("en-US");
5281
- }
5282
- function formatDate(iso) {
5283
- if (!iso) return "\u2014";
5284
- try {
5285
- const dateOnly = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso);
5286
- const options = { month: "short", day: "numeric", year: "numeric" };
5287
- const d = dateOnly && dateOnly[1] && dateOnly[2] && dateOnly[3] ? new Date(Date.UTC(Number(dateOnly[1]), Number(dateOnly[2]) - 1, Number(dateOnly[3]))) : new Date(iso);
5288
- if (Number.isNaN(d.getTime())) return iso;
5289
- return d.toLocaleDateString("en-US", dateOnly ? { ...options, timeZone: "UTC" } : options);
5290
- } catch {
5291
- return iso;
5292
- }
5293
- }
5294
- function formatIsoDate(iso) {
5295
- if (!iso) return "\u2014";
5296
- try {
5297
- const d = new Date(iso);
5298
- if (Number.isNaN(d.getTime())) return iso;
5299
- const yyyy = d.getUTCFullYear();
5300
- const mm = String(d.getUTCMonth() + 1).padStart(2, "0");
5301
- const dd = String(d.getUTCDate()).padStart(2, "0");
5302
- return `${yyyy}-${mm}-${dd}`;
5303
- } catch {
5304
- return iso;
5305
- }
5306
- }
5307
- function formatDateRange(start, end) {
5308
- if (!start && !end) return "";
5309
- if (start && end) return `${formatDate(start)} \u2192 ${formatDate(end)}`;
5310
- return formatDate(start || end);
5311
- }
5312
- var DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
5313
- function parseInclusiveEndMs(iso) {
5314
- const ms = Date.parse(iso);
5315
- if (Number.isNaN(ms)) return null;
5316
- return DATE_ONLY_PATTERN.test(iso) ? ms + 864e5 - 1 : ms;
5317
- }
5318
- function deltaPercent(current, prior) {
5319
- if (prior <= 0) return null;
5320
- return Math.round((current - prior) / prior * 100);
5321
- }
5322
- function deltaTone(deltaPct) {
5323
- if (deltaPct === null || deltaPct === 0) return "neutral";
5324
- return deltaPct > 0 ? "positive" : "negative";
5325
- }
5326
- function formatDeltaCopy(d, suffix, windowLabel = "vs prior 7 days") {
5327
- if (d.deltaPct === null) {
5328
- return d.prior === 0 ? "First baseline week" : "";
5329
- }
5330
- if (d.deltaPct > 0) return `Up ${d.deltaPct}% ${windowLabel} (${formatNumber(d.prior)} ${suffix})`;
5331
- if (d.deltaPct < 0) return `Down ${Math.abs(d.deltaPct)}% ${windowLabel} (${formatNumber(d.prior)} ${suffix})`;
5332
- return `Flat ${windowLabel} (${formatNumber(d.prior)} ${suffix})`;
5333
- }
5334
- var MIN_PCT_BASE = 30;
5335
- function round1(value) {
5336
- return Math.round(value * 10) / 10;
5337
- }
5338
- function formatAverageDelta(d) {
5339
- if (d.prior >= MIN_PCT_BASE && d.deltaPct !== null) {
5340
- const sign2 = d.deltaPct > 0 ? "+" : "";
5341
- return `${sign2}${d.deltaPct}% vs prior`;
5342
- }
5343
- const sign = d.deltaAbs > 0 ? "+" : "";
5344
- return `${sign}${round1(d.deltaAbs)} vs ${round1(d.prior)}`;
5345
- }
5346
- function formatWindowCountDelta(d, countLabel, windowLabel) {
5347
- if (d.prior >= MIN_PCT_BASE && d.deltaPct !== null) {
5348
- const sign2 = d.deltaPct > 0 ? "+" : "";
5349
- return `${sign2}${d.deltaPct}% ${windowLabel}`;
5350
- }
5351
- const sign = d.deltaAbs > 0 ? "+" : "";
5352
- return `${sign}${formatNumber(Math.round(d.deltaAbs))} ${countLabel} ${windowLabel}`;
5353
- }
5354
-
5355
5504
  // ../contracts/src/ads.ts
5356
- import { z as z31 } from "zod";
5357
- var adsConnectRequestSchema = z31.object({
5505
+ import { z as z32 } from "zod";
5506
+ var adsConnectRequestSchema = z32.object({
5358
5507
  /** Ads Manager "SDK key" scoped to one ad account. Stored in config.yaml, never the DB. */
5359
- apiKey: z31.string().min(1)
5360
- });
5361
- var adsConnectionStatusDtoSchema = z31.object({
5362
- connected: z31.boolean(),
5363
- adAccountId: z31.string().nullable().optional(),
5364
- displayName: z31.string().nullable().optional(),
5365
- currencyCode: z31.string().nullable().optional(),
5366
- timezone: z31.string().nullable().optional(),
5367
- status: z31.string().nullable().optional(),
5368
- lastSyncedAt: z31.string().nullable().optional(),
5508
+ apiKey: z32.string().min(1)
5509
+ });
5510
+ var adsConnectionStatusDtoSchema = z32.object({
5511
+ connected: z32.boolean(),
5512
+ adAccountId: z32.string().nullable().optional(),
5513
+ displayName: z32.string().nullable().optional(),
5514
+ currencyCode: z32.string().nullable().optional(),
5515
+ timezone: z32.string().nullable().optional(),
5516
+ status: z32.string().nullable().optional(),
5517
+ lastSyncedAt: z32.string().nullable().optional(),
5369
5518
  /** Whether the ad account has OpenAI conversion tracking (pixel or CAPI) configured,
5370
5519
  * detected from synced campaigns carrying conversion_event_setting_ids. Optional:
5371
5520
  * only present when connected. */
5372
- conversionTrackingConfigured: z31.boolean().optional()
5373
- });
5374
- var adsDisconnectResponseSchema = z31.object({
5375
- disconnected: z31.boolean()
5376
- });
5377
- var adsSyncResponseSchema = z31.object({
5378
- runId: z31.string(),
5379
- status: z31.string()
5380
- });
5381
- var adsCreativeDtoSchema = z31.object({
5382
- type: z31.string().nullable().optional(),
5383
- title: z31.string().nullable().optional(),
5384
- body: z31.string().nullable().optional(),
5385
- targetUrl: z31.string().nullable().optional()
5386
- });
5387
- var adsAdDtoSchema = z31.object({
5388
- id: z31.string(),
5389
- adGroupId: z31.string(),
5390
- name: z31.string(),
5391
- status: z31.string(),
5392
- reviewStatus: z31.string().nullable().optional(),
5521
+ conversionTrackingConfigured: z32.boolean().optional()
5522
+ });
5523
+ var adsDisconnectResponseSchema = z32.object({
5524
+ disconnected: z32.boolean()
5525
+ });
5526
+ var adsSyncResponseSchema = z32.object({
5527
+ runId: z32.string(),
5528
+ status: z32.string()
5529
+ });
5530
+ var adsCreativeDtoSchema = z32.object({
5531
+ type: z32.string().nullable().optional(),
5532
+ title: z32.string().nullable().optional(),
5533
+ body: z32.string().nullable().optional(),
5534
+ targetUrl: z32.string().nullable().optional()
5535
+ });
5536
+ var adsAdDtoSchema = z32.object({
5537
+ id: z32.string(),
5538
+ adGroupId: z32.string(),
5539
+ name: z32.string(),
5540
+ status: z32.string(),
5541
+ reviewStatus: z32.string().nullable().optional(),
5393
5542
  creative: adsCreativeDtoSchema.nullable().optional()
5394
5543
  });
5395
- var adsAdGroupDtoSchema = z31.object({
5396
- id: z31.string(),
5397
- campaignId: z31.string(),
5398
- name: z31.string(),
5399
- status: z31.string(),
5400
- billingEventType: z31.string().nullable().optional(),
5401
- maxBidMicros: z31.number().int().nullable().optional(),
5544
+ var adsAdGroupDtoSchema = z32.object({
5545
+ id: z32.string(),
5546
+ campaignId: z32.string(),
5547
+ name: z32.string(),
5548
+ status: z32.string(),
5549
+ billingEventType: z32.string().nullable().optional(),
5550
+ maxBidMicros: z32.number().int().nullable().optional(),
5402
5551
  /**
5403
5552
  * The targeting primitive: entries are multi-line strings of
5404
5553
  * newline-separated example queries (the live Ads Manager format).
5405
5554
  */
5406
- contextHints: z31.array(z31.string()).default([]),
5407
- ads: z31.array(adsAdDtoSchema).default([])
5408
- });
5409
- var adsCampaignDtoSchema = z31.object({
5410
- id: z31.string(),
5411
- name: z31.string(),
5412
- status: z31.string(),
5413
- biddingType: z31.string().nullable().optional(),
5414
- dailySpendLimitMicros: z31.number().int().nullable().optional(),
5415
- lifetimeSpendLimitMicros: z31.number().int().nullable().optional(),
5416
- adGroups: z31.array(adsAdGroupDtoSchema).default([])
5417
- });
5418
- var adsCampaignListResponseSchema = z31.object({
5419
- campaigns: z31.array(adsCampaignDtoSchema)
5420
- });
5421
- var adsInsightLevelSchema = z31.enum(["campaign", "ad_group"]);
5555
+ contextHints: z32.array(z32.string()).default([]),
5556
+ ads: z32.array(adsAdDtoSchema).default([])
5557
+ });
5558
+ var adsCampaignDtoSchema = z32.object({
5559
+ id: z32.string(),
5560
+ name: z32.string(),
5561
+ status: z32.string(),
5562
+ biddingType: z32.string().nullable().optional(),
5563
+ dailySpendLimitMicros: z32.number().int().nullable().optional(),
5564
+ lifetimeSpendLimitMicros: z32.number().int().nullable().optional(),
5565
+ adGroups: z32.array(adsAdGroupDtoSchema).default([])
5566
+ });
5567
+ var adsCampaignListResponseSchema = z32.object({
5568
+ campaigns: z32.array(adsCampaignDtoSchema)
5569
+ });
5570
+ var adsInsightLevelSchema = z32.enum(["campaign", "ad_group"]);
5422
5571
  var AdsInsightLevels = adsInsightLevelSchema.enum;
5423
- var adsInsightRowDtoSchema = z31.object({
5572
+ var adsInsightRowDtoSchema = z32.object({
5424
5573
  level: adsInsightLevelSchema,
5425
- entityId: z31.string(),
5426
- date: z31.string(),
5427
- impressions: z31.number().int(),
5428
- clicks: z31.number().int(),
5429
- spendMicros: z31.number().int(),
5574
+ entityId: z32.string(),
5575
+ date: z32.string(),
5576
+ impressions: z32.number().int(),
5577
+ clicks: z32.number().int(),
5578
+ spendMicros: z32.number().int(),
5430
5579
  /** Conversion count for the row. 0 when conversion tracking is not configured.
5431
5580
  * Conversion VALUE (for ROAS) is a deliberate follow-up: the upstream value
5432
5581
  * field is not yet captured against a live conversion-tracking account. */
5433
- conversions: z31.number().int(),
5582
+ conversions: z32.number().int(),
5434
5583
  /** clicks / impressions; null when impressions is 0. */
5435
- ctr: z31.number().nullable(),
5584
+ ctr: z32.number().nullable(),
5436
5585
  /** spendMicros / clicks, rounded to integer micros; null when clicks is 0. */
5437
- cpcMicros: z31.number().int().nullable()
5586
+ cpcMicros: z32.number().int().nullable()
5438
5587
  });
5439
- var adsInsightsResponseSchema = z31.object({
5440
- rows: z31.array(adsInsightRowDtoSchema),
5588
+ var adsInsightsResponseSchema = z32.object({
5589
+ rows: z32.array(adsInsightRowDtoSchema),
5441
5590
  /** Account currency for rendering spend/cpc; null before the first sync. */
5442
- currencyCode: z31.string().nullable().optional()
5443
- });
5444
- var adsTotalsDtoSchema = z31.object({
5445
- impressions: z31.number().int(),
5446
- clicks: z31.number().int(),
5447
- spendMicros: z31.number().int(),
5448
- conversions: z31.number().int(),
5449
- ctr: z31.number().nullable(),
5450
- cpcMicros: z31.number().int().nullable()
5451
- });
5452
- var adsSummaryDtoSchema = z31.object({
5453
- connected: z31.boolean(),
5454
- displayName: z31.string().nullable().optional(),
5455
- currencyCode: z31.string().nullable().optional(),
5456
- lastSyncedAt: z31.string().nullable().optional(),
5457
- campaignCount: z31.number().int(),
5458
- adGroupCount: z31.number().int(),
5459
- adCount: z31.number().int(),
5591
+ currencyCode: z32.string().nullable().optional()
5592
+ });
5593
+ var adsTotalsDtoSchema = z32.object({
5594
+ impressions: z32.number().int(),
5595
+ clicks: z32.number().int(),
5596
+ spendMicros: z32.number().int(),
5597
+ conversions: z32.number().int(),
5598
+ ctr: z32.number().nullable(),
5599
+ cpcMicros: z32.number().int().nullable()
5600
+ });
5601
+ var adsSummaryDtoSchema = z32.object({
5602
+ connected: z32.boolean(),
5603
+ displayName: z32.string().nullable().optional(),
5604
+ currencyCode: z32.string().nullable().optional(),
5605
+ lastSyncedAt: z32.string().nullable().optional(),
5606
+ campaignCount: z32.number().int(),
5607
+ adGroupCount: z32.number().int(),
5608
+ adCount: z32.number().int(),
5460
5609
  /** Date range the totals cover (oldest/newest rollup date), null when empty. */
5461
- window: z31.object({
5462
- from: z31.string().nullable(),
5463
- to: z31.string().nullable()
5610
+ window: z32.object({
5611
+ from: z32.string().nullable(),
5612
+ to: z32.string().nullable()
5464
5613
  }),
5465
5614
  /** Campaign-level rollup totals over the window (levels are not summed across). */
5466
5615
  totals: adsTotalsDtoSchema
@@ -5836,6 +5985,21 @@ export {
5836
5985
  windowCutoff,
5837
5986
  visibilityStatsDtoSchema,
5838
5987
  calendarMonthBounds,
5988
+ formatRatio,
5989
+ formatNumber,
5990
+ formatDate,
5991
+ formatIsoDate,
5992
+ formatDateRange,
5993
+ parseInclusiveEndMs,
5994
+ deltaPercent,
5995
+ deltaTone,
5996
+ formatDeltaCopy,
5997
+ formatAverageDelta,
5998
+ formatWindowCountDelta,
5999
+ AiReferralTrafficClasses,
6000
+ classifyAiReferralTrafficClass,
6001
+ aiReferralClassCounts,
6002
+ formatAiReferralClassSummary,
5839
6003
  ga4StatusDtoSchema,
5840
6004
  ga4SyncResponseDtoSchema,
5841
6005
  ga4AiReferralHistoryEntrySchema,
@@ -5933,17 +6097,6 @@ export {
5933
6097
  classifyTrafficPath,
5934
6098
  segmentCrawlerHits,
5935
6099
  sumInfraHits,
5936
- formatRatio,
5937
- formatNumber,
5938
- formatDate,
5939
- formatIsoDate,
5940
- formatDateRange,
5941
- parseInclusiveEndMs,
5942
- deltaPercent,
5943
- deltaTone,
5944
- formatDeltaCopy,
5945
- formatAverageDelta,
5946
- formatWindowCountDelta,
5947
6100
  adsConnectRequestSchema,
5948
6101
  adsConnectionStatusDtoSchema,
5949
6102
  adsDisconnectResponseSchema,