@canonry/canonry 7.23.0 → 7.24.1

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 (30) hide show
  1. package/assets/assets/{AuditHistoryPanel-J8AR3x5F.js → AuditHistoryPanel-DK3zE9dO.js} +1 -1
  2. package/assets/assets/{BacklinksPage-CRDPutGA.js → BacklinksPage-WYFDcXpX.js} +1 -1
  3. package/assets/assets/{HistoryPage-C5taVW3t.js → HistoryPage-CSlndAeS.js} +1 -1
  4. package/assets/assets/{MeasurementPropertyPage-txucmLuz.js → MeasurementPropertyPage-CivoZOGQ.js} +1 -1
  5. package/assets/assets/{ProjectPage-C4FaBoWI.js → ProjectPage-zidnYv65.js} +1 -1
  6. package/assets/assets/{RunsPage-D-3XKUhh.js → RunsPage-BGMAZ_mA.js} +1 -1
  7. package/assets/assets/{SettingsPage-Cq_SJRj_.js → SettingsPage-ndSVVJcE.js} +1 -1
  8. package/assets/assets/{SiteHealthSection-Cn_IZVO1.js → SiteHealthSection-C7-RrsKk.js} +3 -3
  9. package/assets/assets/{TrafficPage-BMdFZs3X.js → TrafficPage-2ANBE9Lc.js} +1 -1
  10. package/assets/assets/{TrafficSourceDetailPage-BmrIOc-2.js → TrafficSourceDetailPage-CLYVB4Uq.js} +1 -1
  11. package/assets/assets/{extract-error-message-HlQy5L7O.js → extract-error-message-BzPoRYiA.js} +1 -1
  12. package/assets/assets/index-CjowCLs3.js +86 -0
  13. package/assets/assets/{react-sigma_core.esm.min-CogAr1i4.js → react-sigma_core.esm.min-BmKqjMGN.js} +1 -1
  14. package/assets/assets/{v2-overview-adapter-tps7TUxq.js → v2-overview-adapter-C7eI2iBf.js} +1 -1
  15. package/assets/index.html +1 -1
  16. package/dist/{chunk-5IXQAOVK.js → chunk-332IBSJJ.js} +15 -6
  17. package/dist/{chunk-3OPV5XBY.js → chunk-35IRQYDW.js} +5709 -4588
  18. package/dist/{chunk-222NAFTY.js → chunk-43FZZFOK.js} +2 -2
  19. package/dist/{chunk-UF7MH6TU.js → chunk-5ITYNLS3.js} +2 -2
  20. package/dist/{chunk-MRKV43TV.js → chunk-656KW4RB.js} +566 -206
  21. package/dist/{chunk-46JZR2IV.js → chunk-H7UNFLYH.js} +1306 -505
  22. package/dist/{chunk-KWBFKTOA.js → chunk-OAWFZAAJ.js} +3 -3
  23. package/dist/cli.js +199 -49
  24. package/dist/{demo-server-32PU7BM6.js → demo-server-NLD6B4WH.js} +4 -4
  25. package/dist/index.d.ts +2 -0
  26. package/dist/index.js +6 -6
  27. package/dist/{intelligence-service-256DQBVR.js → intelligence-service-JFHM2EAY.js} +2 -2
  28. package/dist/mcp.js +4 -4
  29. package/package.json +11 -11
  30. package/assets/assets/index-BJcjB5XW.js +0 -86
@@ -31,6 +31,7 @@ var providerQuotaPolicySchema = z2.object({
31
31
  maxRequestsPerMinute: z2.number().int().positive(),
32
32
  maxRequestsPerDay: z2.number().int().positive()
33
33
  });
34
+ var PROVIDER_NAMES = ["gemini", "openai", "claude", "perplexity", "muse", "local", "cdp:chatgpt"];
34
35
  var ProviderNames = {
35
36
  gemini: "gemini",
36
37
  openai: "openai",
@@ -13581,14 +13582,20 @@ function breakdownShares(parts) {
13581
13582
  const total = parts.reduce((sum, part) => sum + Math.max(0, part), 0);
13582
13583
  return parts.map((part) => shareOf(part, total) ?? 0);
13583
13584
  }
13584
- function wilsonInterval(successes, n, z75 = 1.96) {
13585
+ function median(values) {
13586
+ const sorted = values.filter((value) => Number.isFinite(value)).sort((left, right) => left - right);
13587
+ if (sorted.length === 0) return null;
13588
+ const middle = Math.floor(sorted.length / 2);
13589
+ return sorted.length % 2 === 1 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
13590
+ }
13591
+ function wilsonInterval(successes, n, z76 = 1.96) {
13585
13592
  if (!Number.isFinite(n) || n <= 0) return null;
13586
13593
  const s = Math.max(0, Math.min(successes, n));
13587
13594
  const p = s / n;
13588
- const z210 = z75 * z75;
13595
+ const z210 = z76 * z76;
13589
13596
  const denom = 1 + z210 / n;
13590
13597
  const center = (p + z210 / (2 * n)) / denom;
13591
- const margin = z75 / denom * Math.sqrt(p * (1 - p) / n + z210 / (4 * n * n));
13598
+ const margin = z76 / denom * Math.sqrt(p * (1 - p) / n + z210 / (4 * n * n));
13592
13599
  return {
13593
13600
  low: round(Math.max(0, center - margin)),
13594
13601
  high: round(Math.min(1, center + margin))
@@ -21755,8 +21762,342 @@ function detectAgentRuntime(env) {
21755
21762
  return AGENT_NONE;
21756
21763
  }
21757
21764
 
21758
- // ../contracts/src/ui-telemetry.ts
21765
+ // ../contracts/src/outcome-telemetry.ts
21759
21766
  import { z as z68 } from "zod";
21767
+ var OUTCOME_SURFACES = ["cli", "mcp-stdio", "mcp-http", "aero", "api", "dashboard", "system"];
21768
+ var outcomeSurfaceSchema = z68.enum(OUTCOME_SURFACES);
21769
+ var OutcomeSurfaces = outcomeSurfaceSchema.enum;
21770
+ var INTEGRATION_NAMES = [
21771
+ "provider",
21772
+ "gsc",
21773
+ "ga4",
21774
+ "bing",
21775
+ "gbp",
21776
+ "google_ads",
21777
+ "gtm",
21778
+ "openai_ads",
21779
+ "traffic_cloudflare",
21780
+ "traffic_vercel",
21781
+ "traffic_cloud_run",
21782
+ "wordpress",
21783
+ "backlinks",
21784
+ "webhook",
21785
+ "agent_webhook",
21786
+ "cdp",
21787
+ /** The WordPress traffic-logger plugin source, apart from the WordPress publishing connection. */
21788
+ "traffic_wordpress"
21789
+ ];
21790
+ var integrationNameSchema = z68.enum(INTEGRATION_NAMES);
21791
+ var IntegrationNames = integrationNameSchema.enum;
21792
+ var CONNECTION_ACTIONS = ["connect", "disconnect", "test", "reauth", "select"];
21793
+ var connectionActionSchema = z68.enum(CONNECTION_ACTIONS);
21794
+ var ConnectionActions = connectionActionSchema.enum;
21795
+ var CONNECTION_STATUSES = ["started", "succeeded", "failed", "cancelled"];
21796
+ var connectionStatusSchema = z68.enum(CONNECTION_STATUSES);
21797
+ var ConnectionStatuses = connectionStatusSchema.enum;
21798
+ var OUTCOME_STATUSES = ["succeeded", "partial", "failed", "skipped", "cancelled"];
21799
+ var outcomeStatusSchema = z68.enum(OUTCOME_STATUSES);
21800
+ var OutcomeStatuses = outcomeStatusSchema.enum;
21801
+ var OUTCOME_TRIGGERS = ["manual", "scheduled", "agent", "startup", "retry", "push"];
21802
+ var outcomeTriggerSchema = z68.enum(OUTCOME_TRIGGERS);
21803
+ var OutcomeTriggers = outcomeTriggerSchema.enum;
21804
+ var OUTCOME_REASON_CODES = [
21805
+ "AUTH_DENIED",
21806
+ "OAUTH_CANCELLED",
21807
+ "OAUTH_STATE_INVALID",
21808
+ "INVALID_CREDENTIALS",
21809
+ "PERMISSION_MISSING",
21810
+ "NOT_CONNECTED",
21811
+ "ALREADY_CONNECTED",
21812
+ "NOT_FOUND",
21813
+ "ACCOUNT_NOT_FOUND",
21814
+ "PROPERTY_NOT_FOUND",
21815
+ "QUOTA_EXCEEDED",
21816
+ "RATE_LIMITED",
21817
+ "BILLING",
21818
+ "NETWORK",
21819
+ "TIMEOUT",
21820
+ "HTTP_4XX",
21821
+ "HTTP_5XX",
21822
+ "BLOCKED_UNSAFE_URL",
21823
+ "VALIDATION",
21824
+ "UNSUPPORTED",
21825
+ "NO_DATA",
21826
+ "NOT_DUE",
21827
+ "GATE_REFUSED",
21828
+ "OPERATION_IN_PROGRESS",
21829
+ "QUARANTINED",
21830
+ "CANCELLED_BY_USER",
21831
+ "SERVER_RESTARTED",
21832
+ "INTERNAL",
21833
+ "UNKNOWN",
21834
+ "PORT_IN_USE",
21835
+ "MIGRATION_FAILED",
21836
+ "UNCAUGHT_EXCEPTION",
21837
+ "UNHANDLED_REJECTION"
21838
+ ];
21839
+ var outcomeReasonCodeSchema = z68.enum(OUTCOME_REASON_CODES);
21840
+ var OutcomeReasonCodes = outcomeReasonCodeSchema.enum;
21841
+ var FEATURE_OPERATIONS = {
21842
+ search_console: ["sync", "inspect", "sitemap_submit"],
21843
+ ga4: ["sync"],
21844
+ bing: ["sync", "inspect"],
21845
+ gbp: ["sync", "reviews"],
21846
+ google_ads: ["sync"],
21847
+ gtm: ["sync"],
21848
+ openai_ads: ["sync", "operation", "activation", "reconcile"],
21849
+ server_traffic: ["sync", "ingest", "backfill", "reset"],
21850
+ backlinks: ["install", "sync", "extract"],
21851
+ content: ["analyze", "brief"],
21852
+ research: ["run"],
21853
+ discovery: ["run"],
21854
+ sentiment: ["run"],
21855
+ aero: ["turn"],
21856
+ webhooks: ["deliver", "test"],
21857
+ schedules: ["slot"],
21858
+ exports: ["export"],
21859
+ providers: ["reload"],
21860
+ wordpress: ["schema_deploy", "llms_txt", "meta_write", "publish"],
21861
+ measurement: ["publish"],
21862
+ insights: ["generate"],
21863
+ site_liveness: ["check"],
21864
+ reports: ["download"],
21865
+ data_refresh: ["refresh"],
21866
+ server: ["start", "crash"]
21867
+ };
21868
+ var FEATURE_NAMES = Object.keys(FEATURE_OPERATIONS);
21869
+ var featureNameSchema = z68.enum(FEATURE_NAMES);
21870
+ var FeatureNames = featureNameSchema.enum;
21871
+ var OUTCOME_COUNT_KEYS = [
21872
+ "rows",
21873
+ "pages",
21874
+ "urls",
21875
+ "links",
21876
+ "domains",
21877
+ "reviews",
21878
+ "events",
21879
+ "crawlerHits",
21880
+ "aiReferralHits",
21881
+ "aiUserFetchHits",
21882
+ "campaigns",
21883
+ "operations",
21884
+ "queries",
21885
+ "snapshots",
21886
+ "briefs",
21887
+ "gaps",
21888
+ "targets",
21889
+ "insights",
21890
+ "toolCalls",
21891
+ "toolErrors",
21892
+ "modelCalls",
21893
+ "inputTokens",
21894
+ "outputTokens",
21895
+ "cachedTokens",
21896
+ "costMicros",
21897
+ "attempts",
21898
+ "deliveries",
21899
+ "failures",
21900
+ "skipped",
21901
+ "providers",
21902
+ "items",
21903
+ "bytes"
21904
+ ];
21905
+ var COUNT_KEY_SET = new Set(OUTCOME_COUNT_KEYS);
21906
+ var MAX_COUNT = 1e12;
21907
+ var countValueSchema = z68.number().int().min(0).max(MAX_COUNT);
21908
+ var countsSchema = z68.record(z68.string(), countValueSchema).refine((obj) => Object.keys(obj).length > 0 && Object.keys(obj).length <= 12, "counts must have 1 to 12 keys").refine((obj) => Object.keys(obj).every((k) => COUNT_KEY_SET.has(k)), "unknown count key");
21909
+ var WEBHOOK_TARGETS = ["first_party", "slack", "discord"];
21910
+ var webhookTargetSchema = z68.enum(WEBHOOK_TARGETS);
21911
+ var WebhookTargets = webhookTargetSchema.enum;
21912
+ var STATUS_CLASSES = ["2xx", "3xx", "4xx", "5xx", "timeout", "network", "blocked"];
21913
+ var statusClassSchema = z68.enum(STATUS_CLASSES);
21914
+ var StatusClasses = statusClassSchema.enum;
21915
+ var DURATION_BUCKETS = ["under_1s", "1s_to_10s", "10s_to_1m", "1m_to_5m", "5m_to_30m", "30m_or_more"];
21916
+ var durationBucketSchema = z68.enum(DURATION_BUCKETS);
21917
+ var DurationBuckets = durationBucketSchema.enum;
21918
+ function bucketDuration(durationMs) {
21919
+ const duration = Number.isFinite(durationMs) ? Math.max(0, durationMs) : 0;
21920
+ if (duration < 1e3) return "under_1s";
21921
+ if (duration < 1e4) return "1s_to_10s";
21922
+ if (duration < 6e4) return "10s_to_1m";
21923
+ if (duration < 3e5) return "1m_to_5m";
21924
+ if (duration < 18e5) return "5m_to_30m";
21925
+ return "30m_or_more";
21926
+ }
21927
+ var errorNameSchema = z68.string().regex(/^[A-Z_$][\w$]{0,39}$/i);
21928
+ var agentSlugSchema = z68.string().regex(/^[a-z0-9][a-z0-9._-]{0,39}$/);
21929
+ var providerNameSchema2 = z68.enum(PROVIDER_NAMES);
21930
+ var modelIdSchema2 = z68.string().regex(/^[A-Z0-9][\w.:/@-]{0,99}$/i).refine((v) => !v.includes("://"), "a model id is never a URL");
21931
+ var slugSchema = z68.string().regex(/^[a-z0-9][a-z0-9._-]{0,31}$/);
21932
+ var integrationConnectionPropertiesSchema = z68.object({
21933
+ integration: integrationNameSchema,
21934
+ provider: providerNameSchema2.optional(),
21935
+ action: connectionActionSchema,
21936
+ status: connectionStatusSchema,
21937
+ reasonCode: outcomeReasonCodeSchema.optional(),
21938
+ errorName: errorNameSchema.optional(),
21939
+ target: webhookTargetSchema.optional(),
21940
+ surface: outcomeSurfaceSchema.optional(),
21941
+ agent: agentSlugSchema.optional(),
21942
+ durationBucket: durationBucketSchema.optional(),
21943
+ attempt: z68.number().int().min(1).max(1e6).optional(),
21944
+ /** The install's first success of this kind; set by the helpers, never by callers. */
21945
+ first: z68.literal(true).optional()
21946
+ }).strict().refine(
21947
+ (p) => p.integration === IntegrationNames.provider === (p.provider !== void 0),
21948
+ "provider is required for, and only for, integration provider"
21949
+ ).refine(
21950
+ (p) => p.status === ConnectionStatuses.succeeded || p.status === ConnectionStatuses.started || p.reasonCode !== void 0,
21951
+ "a failed or cancelled attempt needs a reasonCode"
21952
+ );
21953
+ var featureCompletedPropertiesSchema = z68.object({
21954
+ feature: featureNameSchema,
21955
+ operation: z68.string().regex(/^[a-z][a-z_]{0,31}$/),
21956
+ status: outcomeStatusSchema,
21957
+ trigger: outcomeTriggerSchema.optional(),
21958
+ surface: outcomeSurfaceSchema.optional(),
21959
+ agent: agentSlugSchema.optional(),
21960
+ reasonCode: outcomeReasonCodeSchema.optional(),
21961
+ errorName: errorNameSchema.optional(),
21962
+ durationBucket: durationBucketSchema.optional(),
21963
+ counts: countsSchema.optional(),
21964
+ target: webhookTargetSchema.optional(),
21965
+ eventType: notificationEventSchema.optional(),
21966
+ statusClass: statusClassSchema.optional(),
21967
+ provider: providerNameSchema2.optional(),
21968
+ model: modelIdSchema2.optional(),
21969
+ modelProvider: slugSchema.optional(),
21970
+ sampleRate: z68.number().int().min(1).max(1e6).optional(),
21971
+ droppedBefore: z68.number().int().min(0).max(MAX_COUNT).optional(),
21972
+ domainHash: z68.string().regex(/^[0-9a-f]{64}$/).optional(),
21973
+ first: z68.literal(true).optional()
21974
+ }).strict().refine(
21975
+ (p) => FEATURE_OPERATIONS[p.feature].includes(p.operation),
21976
+ "operation is not one this feature reports"
21977
+ ).refine((p) => p.status === OutcomeStatuses.succeeded || p.reasonCode !== void 0, "a non-succeeded outcome needs a reasonCode");
21978
+ var INSTALL_SOURCES = ["npm", "homebrew", "docker", "source"];
21979
+ var installSourceSchema = z68.enum(INSTALL_SOURCES);
21980
+ var installRefSchema = z68.string().regex(/^[a-z0-9][a-z0-9-]{0,31}$/);
21981
+ function normalizeInstallRef(value) {
21982
+ const ref = value?.trim().toLowerCase();
21983
+ return ref && installRefSchema.safeParse(ref).success ? ref : void 0;
21984
+ }
21985
+ var INSTALL_STATE_COUNT_KEYS = [
21986
+ "projects",
21987
+ "queries",
21988
+ "competitors",
21989
+ "locations",
21990
+ "schedules",
21991
+ "webhooks",
21992
+ "agentWebhooks",
21993
+ "trafficSources",
21994
+ "googleConnections",
21995
+ "bingConnections",
21996
+ "backlinkSources",
21997
+ "adsAccounts"
21998
+ ];
21999
+ var INSTALL_STATE_USAGE_KEYS = [
22000
+ "sweeps",
22001
+ "audits",
22002
+ "providerCalls",
22003
+ "inputTokens",
22004
+ "outputTokens",
22005
+ "costMicros",
22006
+ "aeroTurns",
22007
+ "aeroModelCalls",
22008
+ "aeroInputTokens",
22009
+ "aeroOutputTokens",
22010
+ "aeroCostMicros",
22011
+ "webhookDeliveries"
22012
+ ];
22013
+ var fixedKeyCounts = (keys) => {
22014
+ const allowed = new Set(keys);
22015
+ return z68.record(z68.string(), countValueSchema).refine((obj) => Object.keys(obj).every((k) => allowed.has(k)), "unknown key");
22016
+ };
22017
+ var installStatePropertiesSchema = z68.object({
22018
+ providers: z68.array(providerNameSchema2).max(PROVIDER_NAMES.length),
22019
+ integrations: z68.array(integrationNameSchema.exclude([IntegrationNames.provider])).max(INTEGRATION_NAMES.length),
22020
+ counts: fixedKeyCounts(INSTALL_STATE_COUNT_KEYS),
22021
+ usage24h: fixedKeyCounts(INSTALL_STATE_USAGE_KEYS),
22022
+ providerCalls24h: fixedKeyCounts(PROVIDER_NAMES).optional(),
22023
+ agentProvider: slugSchema.optional(),
22024
+ agentModel: modelIdSchema2.optional(),
22025
+ uptimeBucket: durationBucketSchema.optional(),
22026
+ installSource: installSourceSchema.optional(),
22027
+ installRef: installRefSchema.optional()
22028
+ }).strict();
22029
+ function statusClassOf(status) {
22030
+ if (status === void 0 || status === null || status === 0) return "network";
22031
+ if (status >= 500) return "5xx";
22032
+ if (status >= 400) return "4xx";
22033
+ if (status >= 300) return "3xx";
22034
+ return "2xx";
22035
+ }
22036
+ var NETWORK_CODES = /* @__PURE__ */ new Set(["ECONNREFUSED", "ECONNRESET", "ENOTFOUND", "EAI_AGAIN", "EHOSTUNREACH", "ENETUNREACH", "EPIPE", "UND_ERR_SOCKET"]);
22037
+ var TIMEOUT_CODES = /* @__PURE__ */ new Set(["ETIMEDOUT", "ESOCKETTIMEDOUT", "UND_ERR_CONNECT_TIMEOUT", "UND_ERR_HEADERS_TIMEOUT", "UND_ERR_BODY_TIMEOUT"]);
22038
+ function httpStatusOf(err) {
22039
+ for (const value of [err.status, err.statusCode, err.response?.status, err.details?.httpStatus]) {
22040
+ if (typeof value === "number" && value >= 100 && value <= 599) return value;
22041
+ }
22042
+ return void 0;
22043
+ }
22044
+ function classifyOutcomeError(err) {
22045
+ if (!err || typeof err !== "object") return { reasonCode: "UNKNOWN" };
22046
+ const e = err;
22047
+ const rawName = typeof e.name === "string" ? e.name : err.constructor?.name;
22048
+ const errorName = typeof rawName === "string" && errorNameSchema.safeParse(rawName).success ? rawName : void 0;
22049
+ const code = typeof e.code === "string" ? e.code : void 0;
22050
+ const known = code && OUTCOME_REASON_CODES.includes(code) ? code : void 0;
22051
+ if (known) return { reasonCode: known, errorName };
22052
+ const cause = e.cause && typeof e.cause === "object" ? e.cause : void 0;
22053
+ const causeCode = typeof cause?.code === "string" ? cause.code : void 0;
22054
+ const causeName = typeof cause?.name === "string" ? cause.name : void 0;
22055
+ if (errorName === "AbortError" || errorName === "TimeoutError" || causeName === "TimeoutError" || code && TIMEOUT_CODES.has(code) || causeCode && TIMEOUT_CODES.has(causeCode)) return { reasonCode: "TIMEOUT", errorName };
22056
+ if (code && NETWORK_CODES.has(code) || causeCode && NETWORK_CODES.has(causeCode)) return { reasonCode: "NETWORK", errorName };
22057
+ if (errorName === "TypeError" && e.message === "fetch failed") return { reasonCode: "NETWORK", errorName };
22058
+ if (code === "PROVIDER_AUTH" || code === "AUTH_INVALID" || code === "AUTH_REQUIRED") return { reasonCode: "INVALID_CREDENTIALS", errorName };
22059
+ if (code === "FORBIDDEN") return { reasonCode: "PERMISSION_MISSING", errorName };
22060
+ if (code === "PROVIDER_BILLING") return { reasonCode: "BILLING", errorName };
22061
+ if (code === "NOT_FOUND") return { reasonCode: "NOT_FOUND", errorName };
22062
+ if (code === "VALIDATION_ERROR") return { reasonCode: "VALIDATION", errorName };
22063
+ if (code === "RUN_CANCELLED") return { reasonCode: "CANCELLED_BY_USER", errorName };
22064
+ const status = httpStatusOf(e);
22065
+ if (status === 401) return { reasonCode: "INVALID_CREDENTIALS", errorName };
22066
+ if (status === 403) return { reasonCode: "PERMISSION_MISSING", errorName };
22067
+ if (status === 404) return { reasonCode: "NOT_FOUND", errorName };
22068
+ if (status === 429) return { reasonCode: "RATE_LIMITED", errorName };
22069
+ if (status !== void 0 && status >= 500) return { reasonCode: "HTTP_5XX", errorName };
22070
+ if (status !== void 0 && status >= 400) return { reasonCode: "HTTP_4XX", errorName };
22071
+ return { reasonCode: "UNKNOWN", errorName };
22072
+ }
22073
+ function providerErrorOutcomeReason(code) {
22074
+ switch (code) {
22075
+ case "PROVIDER_AUTH":
22076
+ return "INVALID_CREDENTIALS";
22077
+ case "PROVIDER_BILLING":
22078
+ return "BILLING";
22079
+ case "RATE_LIMITED":
22080
+ return "RATE_LIMITED";
22081
+ case "PROVIDER_UNAVAILABLE":
22082
+ return "HTTP_5XX";
22083
+ case "TIMEOUT":
22084
+ return "TIMEOUT";
22085
+ case "NETWORK":
22086
+ return "NETWORK";
22087
+ case "PARSE_ERROR":
22088
+ return "UNKNOWN";
22089
+ case "UNKNOWN":
22090
+ return "UNKNOWN";
22091
+ }
22092
+ }
22093
+ function classifyProviderOutcomeError(err) {
22094
+ const classified = classifyOutcomeError(err);
22095
+ if (classified.reasonCode !== "UNKNOWN") return classified;
22096
+ return { ...classified, reasonCode: providerErrorOutcomeReason(classifyProviderErrorMessage(describeError(err))) };
22097
+ }
22098
+
22099
+ // ../contracts/src/ui-telemetry.ts
22100
+ import { z as z69 } from "zod";
21760
22101
  var UI_PAGES = [
21761
22102
  "/",
21762
22103
  "/projects",
@@ -21784,7 +22125,7 @@ var UI_PAGES = [
21784
22125
  "not-found",
21785
22126
  "other"
21786
22127
  ];
21787
- var uiPageSchema = z68.enum(UI_PAGES);
22128
+ var uiPageSchema = z69.enum(UI_PAGES);
21788
22129
  var UI_PROJECT_TABS = [
21789
22130
  "overview",
21790
22131
  "portfolio",
@@ -21802,7 +22143,7 @@ var UI_PROJECT_TABS = [
21802
22143
  "settings",
21803
22144
  "other"
21804
22145
  ];
21805
- var uiProjectTabSchema = z68.enum(UI_PROJECT_TABS);
22146
+ var uiProjectTabSchema = z69.enum(UI_PROJECT_TABS);
21806
22147
  var UI_ACTIONS = [
21807
22148
  "sweep.launch",
21808
22149
  "sweep.cancel",
@@ -21842,7 +22183,7 @@ var UI_ACTIONS = [
21842
22183
  /** A table search settled on a non-empty query (debounced or Enter; the text is never sent). */
21843
22184
  "search.submit"
21844
22185
  ];
21845
- var uiActionSchema = z68.enum(UI_ACTIONS);
22186
+ var uiActionSchema = z69.enum(UI_ACTIONS);
21846
22187
  var UI_INTEGRATIONS = [
21847
22188
  "google",
21848
22189
  "gsc",
@@ -21858,9 +22199,9 @@ var UI_INTEGRATIONS = [
21858
22199
  "traffic_cloud_run",
21859
22200
  "traffic_wordpress"
21860
22201
  ];
21861
- var uiIntegrationSchema = z68.enum(UI_INTEGRATIONS);
22202
+ var uiIntegrationSchema = z69.enum(UI_INTEGRATIONS);
21862
22203
  var UI_FILTERS = ["provider", "model", "location", "window", "query_class", "other"];
21863
- var uiFilterSchema = z68.enum(UI_FILTERS);
22204
+ var uiFilterSchema = z69.enum(UI_FILTERS);
21864
22205
  var UI_EXPORT_FORMATS = ["csv", "json", "html"];
21865
22206
  var UI_ERROR_KINDS = ["render", "unhandled", "api"];
21866
22207
  var UI_STATUS_CLASSES = ["4xx", "5xx", "network"];
@@ -21945,44 +22286,45 @@ function isUiApiRouteTemplate(route) {
21945
22286
  return PARAM_SEGMENT.test(segment) || UI_ROUTE_FIXED_CHILDREN.has(`${previous}/${segment}`);
21946
22287
  });
21947
22288
  }
21948
- var uiEventBaseSchema = z68.object({
21949
- eventId: z68.string().uuid(),
21950
- uiSessionId: z68.string().uuid(),
22289
+ var uiEventBaseSchema = z69.object({
22290
+ eventId: z69.string().uuid(),
22291
+ uiSessionId: z69.string().uuid(),
21951
22292
  page: uiPageSchema
21952
22293
  });
21953
- var uiTelemetryEventSchema = z68.discriminatedUnion("event", [
22294
+ var uiTelemetryEventSchema = z69.discriminatedUnion("event", [
21954
22295
  uiEventBaseSchema.extend({
21955
- event: z68.literal("ui.page_viewed"),
22296
+ event: z69.literal("ui.page_viewed"),
21956
22297
  tab: uiProjectTabSchema.optional()
21957
22298
  }).strict(),
21958
22299
  uiEventBaseSchema.extend({
21959
- event: z68.literal("ui.action"),
22300
+ event: z69.literal("ui.action"),
21960
22301
  action: uiActionSchema,
21961
22302
  tab: uiProjectTabSchema.optional(),
21962
22303
  integration: uiIntegrationSchema.optional(),
21963
- format: z68.enum(UI_EXPORT_FORMATS).optional(),
22304
+ format: z69.enum(UI_EXPORT_FORMATS).optional(),
21964
22305
  filter: uiFilterSchema.optional()
21965
22306
  }).strict(),
21966
22307
  uiEventBaseSchema.extend({
21967
- event: z68.literal("ui.error"),
21968
- kind: z68.enum(UI_ERROR_KINDS),
22308
+ event: z69.literal("ui.error"),
22309
+ kind: z69.enum(UI_ERROR_KINDS),
21969
22310
  tab: uiProjectTabSchema.optional(),
21970
- component: z68.string().regex(UI_COMPONENT_PATTERN).optional(),
21971
- errorName: z68.string().regex(UI_ERROR_NAME_PATTERN).optional(),
21972
- route: z68.string().max(UI_API_ROUTE_MAX_LENGTH).refine(isUiApiRouteTemplate, "route must be a route template").optional(),
21973
- method: z68.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).optional(),
21974
- statusClass: z68.enum(UI_STATUS_CLASSES).optional(),
21975
- status: z68.number().int().min(400).max(599).optional()
22311
+ component: z69.string().regex(UI_COMPONENT_PATTERN).optional(),
22312
+ errorName: z69.string().regex(UI_ERROR_NAME_PATTERN).optional(),
22313
+ route: z69.string().max(UI_API_ROUTE_MAX_LENGTH).refine(isUiApiRouteTemplate, "route must be a route template").optional(),
22314
+ method: z69.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).optional(),
22315
+ statusClass: z69.enum(UI_STATUS_CLASSES).optional(),
22316
+ status: z69.number().int().min(400).max(599).optional()
21976
22317
  }).strict(),
21977
22318
  uiEventBaseSchema.extend({
21978
- event: z68.literal("ui.vitals"),
21979
- metric: z68.enum(UI_VITAL_METRICS),
21980
- rating: z68.enum(UI_VITAL_RATINGS)
22319
+ event: z69.literal("ui.vitals"),
22320
+ metric: z69.enum(UI_VITAL_METRICS),
22321
+ rating: z69.enum(UI_VITAL_RATINGS),
22322
+ tab: uiProjectTabSchema.optional()
21981
22323
  }).strict()
21982
22324
  ]);
21983
22325
 
21984
22326
  // ../contracts/src/feedback.ts
21985
- import { z as z69 } from "zod";
22327
+ import { z as z70 } from "zod";
21986
22328
 
21987
22329
  // ../contracts/src/log-redaction.ts
21988
22330
  var REDACTED = "[REDACTED]";
@@ -22134,7 +22476,7 @@ function redactEmbeddedUrls(value) {
22134
22476
 
22135
22477
  // ../contracts/src/feedback.ts
22136
22478
  var FEEDBACK_KINDS = ["struggle", "bug", "improvement", "other"];
22137
- var feedbackKindSchema = z69.enum(FEEDBACK_KINDS);
22479
+ var feedbackKindSchema = z70.enum(FEEDBACK_KINDS);
22138
22480
  var FEEDBACK_LIMITS = {
22139
22481
  summary: 500,
22140
22482
  details: 4e3,
@@ -22142,17 +22484,17 @@ var FEEDBACK_LIMITS = {
22142
22484
  command: 120,
22143
22485
  errorCode: 40
22144
22486
  };
22145
- var feedbackSubmissionSchema = z69.object({
22487
+ var feedbackSubmissionSchema = z70.object({
22146
22488
  kind: feedbackKindSchema,
22147
- summary: z69.string().trim().min(1).max(FEEDBACK_LIMITS.summary),
22148
- details: z69.string().trim().min(1).max(FEEDBACK_LIMITS.details).optional(),
22149
- area: z69.string().trim().min(1).max(FEEDBACK_LIMITS.area).optional(),
22150
- command: z69.string().trim().min(1).max(FEEDBACK_LIMITS.command).optional(),
22151
- errorCode: z69.string().trim().min(1).max(FEEDBACK_LIMITS.errorCode).optional()
22489
+ summary: z70.string().trim().min(1).max(FEEDBACK_LIMITS.summary),
22490
+ details: z70.string().trim().min(1).max(FEEDBACK_LIMITS.details).optional(),
22491
+ area: z70.string().trim().min(1).max(FEEDBACK_LIMITS.area).optional(),
22492
+ command: z70.string().trim().min(1).max(FEEDBACK_LIMITS.command).optional(),
22493
+ errorCode: z70.string().trim().min(1).max(FEEDBACK_LIMITS.errorCode).optional()
22152
22494
  }).strict();
22153
- var feedbackAcceptedDtoSchema = z69.object({
22154
- accepted: z69.boolean(),
22155
- id: z69.string()
22495
+ var feedbackAcceptedDtoSchema = z70.object({
22496
+ accepted: z70.boolean(),
22497
+ id: z70.string()
22156
22498
  });
22157
22499
  function redactFeedbackText(value, limit) {
22158
22500
  return truncateUtf16(
@@ -22169,90 +22511,90 @@ var SECRET_FLAG_VALUE = /(?<=^|[ \t])(--?(?:[a-z\d]+-)*(?:key|token|secret|passw
22169
22511
  var BARE_CREDENTIAL = /\b(?:sk-[\w-]{16,}|AIza[\w-]{30,}|pplx-[A-Za-z0-9]{16,}|gh[pousr]_[A-Za-z0-9]{20,}|github_pat_\w{20,}|cnry_[\w-]{16,})/g;
22170
22512
 
22171
22513
  // ../contracts/src/operational-logs.ts
22172
- import { z as z70 } from "zod";
22173
- var operationalLogLevelSchema = z70.enum(["trace", "debug", "info", "warn", "error", "fatal"]);
22174
- var diagnosticContextSchema = z70.object({
22175
- runId: z70.string().min(1).max(256).optional(),
22176
- projectId: z70.string().min(1).max(256).optional(),
22177
- requestId: z70.string().min(1).max(256).optional(),
22178
- actor: z70.string().min(1).max(512).optional(),
22179
- credentialId: z70.string().min(1).max(512).optional(),
22180
- userAgent: z70.string().min(1).max(512).optional(),
22181
- actorSession: z70.string().min(1).max(512).optional(),
22182
- method: z70.string().min(1).max(16).optional(),
22183
- route: z70.string().min(1).max(256).optional(),
22184
- operationId: z70.string().min(1).max(256).optional(),
22185
- jobId: z70.string().min(1).max(256).optional(),
22186
- taskId: z70.string().min(1).max(256).optional(),
22187
- traceId: z70.string().min(1).max(256).optional(),
22188
- provider: z70.string().min(1).max(256).optional(),
22189
- errorCode: z70.string().min(1).max(128).optional(),
22190
- attempt: z70.number().finite().optional(),
22191
- count: z70.number().finite().optional(),
22192
- total: z70.number().finite().optional(),
22193
- progress: z70.number().finite().optional(),
22194
- httpStatus: z70.number().finite().optional(),
22195
- statusCode: z70.number().finite().optional(),
22196
- durationMs: z70.number().finite().optional(),
22197
- bytes: z70.number().finite().optional(),
22198
- retryAfterMs: z70.number().finite().optional(),
22199
- retriable: z70.boolean().optional(),
22200
- retrying: z70.boolean().optional(),
22201
- cancelled: z70.boolean().optional(),
22202
- success: z70.boolean().optional()
22203
- }).strict();
22204
- var operationalLogEntryDtoSchema = z70.object({
22205
- cursor: z70.string().min(1).max(512),
22206
- ts: z70.string().datetime(),
22514
+ import { z as z71 } from "zod";
22515
+ var operationalLogLevelSchema = z71.enum(["trace", "debug", "info", "warn", "error", "fatal"]);
22516
+ var diagnosticContextSchema = z71.object({
22517
+ runId: z71.string().min(1).max(256).optional(),
22518
+ projectId: z71.string().min(1).max(256).optional(),
22519
+ requestId: z71.string().min(1).max(256).optional(),
22520
+ actor: z71.string().min(1).max(512).optional(),
22521
+ credentialId: z71.string().min(1).max(512).optional(),
22522
+ userAgent: z71.string().min(1).max(512).optional(),
22523
+ actorSession: z71.string().min(1).max(512).optional(),
22524
+ method: z71.string().min(1).max(16).optional(),
22525
+ route: z71.string().min(1).max(256).optional(),
22526
+ operationId: z71.string().min(1).max(256).optional(),
22527
+ jobId: z71.string().min(1).max(256).optional(),
22528
+ taskId: z71.string().min(1).max(256).optional(),
22529
+ traceId: z71.string().min(1).max(256).optional(),
22530
+ provider: z71.string().min(1).max(256).optional(),
22531
+ errorCode: z71.string().min(1).max(128).optional(),
22532
+ attempt: z71.number().finite().optional(),
22533
+ count: z71.number().finite().optional(),
22534
+ total: z71.number().finite().optional(),
22535
+ progress: z71.number().finite().optional(),
22536
+ httpStatus: z71.number().finite().optional(),
22537
+ statusCode: z71.number().finite().optional(),
22538
+ durationMs: z71.number().finite().optional(),
22539
+ bytes: z71.number().finite().optional(),
22540
+ retryAfterMs: z71.number().finite().optional(),
22541
+ retriable: z71.boolean().optional(),
22542
+ retrying: z71.boolean().optional(),
22543
+ cancelled: z71.boolean().optional(),
22544
+ success: z71.boolean().optional()
22545
+ }).strict();
22546
+ var operationalLogEntryDtoSchema = z71.object({
22547
+ cursor: z71.string().min(1).max(512),
22548
+ ts: z71.string().datetime(),
22207
22549
  level: operationalLogLevelSchema,
22208
- module: z70.string().min(1).max(256),
22209
- action: z70.string().min(1).max(256),
22210
- message: z70.string().max(4096).optional(),
22211
- runId: z70.string().min(1).max(256).optional(),
22212
- projectId: z70.string().min(1).max(256).optional(),
22550
+ module: z71.string().min(1).max(256),
22551
+ action: z71.string().min(1).max(256),
22552
+ message: z71.string().max(4096).optional(),
22553
+ runId: z71.string().min(1).max(256).optional(),
22554
+ projectId: z71.string().min(1).max(256).optional(),
22213
22555
  context: diagnosticContextSchema
22214
22556
  }).strict();
22215
- var logQuerySchema = z70.object({
22557
+ var logQuerySchema = z71.object({
22216
22558
  level: operationalLogLevelSchema.optional(),
22217
- module: z70.string().trim().min(1).max(256).optional(),
22218
- runId: z70.string().trim().min(1).max(256).optional(),
22219
- projectId: z70.string().trim().min(1).max(256).optional(),
22220
- actor: z70.string().trim().min(1).max(512).optional(),
22221
- requestId: z70.string().trim().min(1).max(256).optional(),
22222
- since: z70.string().datetime().optional(),
22223
- until: z70.string().datetime().optional(),
22224
- limit: z70.coerce.number().int().min(1).max(200).default(100),
22225
- cursor: z70.string().trim().min(1).max(512).optional()
22559
+ module: z71.string().trim().min(1).max(256).optional(),
22560
+ runId: z71.string().trim().min(1).max(256).optional(),
22561
+ projectId: z71.string().trim().min(1).max(256).optional(),
22562
+ actor: z71.string().trim().min(1).max(512).optional(),
22563
+ requestId: z71.string().trim().min(1).max(256).optional(),
22564
+ since: z71.string().datetime().optional(),
22565
+ until: z71.string().datetime().optional(),
22566
+ limit: z71.coerce.number().int().min(1).max(200).default(100),
22567
+ cursor: z71.string().trim().min(1).max(512).optional()
22226
22568
  }).strict().superRefine((query, ctx) => {
22227
22569
  if (query.since && query.until && Date.parse(query.since) > Date.parse(query.until)) {
22228
- ctx.addIssue({ code: z70.ZodIssueCode.custom, path: ["until"], message: '"until" must be on or after "since".' });
22570
+ ctx.addIssue({ code: z71.ZodIssueCode.custom, path: ["until"], message: '"until" must be on or after "since".' });
22229
22571
  }
22230
22572
  });
22231
- var retentionPolicySchema = z70.object({
22232
- maxEntries: z70.number().int().positive(),
22233
- maxAgeSeconds: z70.number().int().positive()
22573
+ var retentionPolicySchema = z71.object({
22574
+ maxEntries: z71.number().int().positive(),
22575
+ maxAgeSeconds: z71.number().int().positive()
22234
22576
  }).strict();
22235
- var operationalLogListDtoSchema = z70.object({
22236
- entries: z70.array(operationalLogEntryDtoSchema),
22237
- nextCursor: z70.string().min(1).max(512).nullable(),
22577
+ var operationalLogListDtoSchema = z71.object({
22578
+ entries: z71.array(operationalLogEntryDtoSchema),
22579
+ nextCursor: z71.string().min(1).max(512).nullable(),
22238
22580
  /** Matching entries left after this page. */
22239
- truncated: z70.number().int().nonnegative(),
22581
+ truncated: z71.number().int().nonnegative(),
22240
22582
  /** Entries evicted by the active retention policy. */
22241
- dropped: z70.number().int().nonnegative(),
22242
- retention: z70.enum(["process", "durable"]),
22583
+ dropped: z71.number().int().nonnegative(),
22584
+ retention: z71.enum(["process", "durable"]),
22243
22585
  retentionPolicy: retentionPolicySchema.optional(),
22244
22586
  /** Best-effort persistence failures observed by this store. */
22245
- captureErrors: z70.number().int().nonnegative().optional(),
22246
- observedAt: z70.string().datetime()
22587
+ captureErrors: z71.number().int().nonnegative().optional(),
22588
+ observedAt: z71.string().datetime()
22247
22589
  }).strict();
22248
22590
  var OPERATIONAL_LOG_FIELDS_HEADER = "x-canonry-log-fields";
22249
22591
  var OPERATIONAL_LOG_OPT_IN_CONTEXT_FIELDS = ["provider"];
22250
- var diagnosticContextReadSchema = z70.object(diagnosticContextSchema.shape);
22251
- var operationalLogEntryReadSchema = z70.object({ ...operationalLogEntryDtoSchema.shape, context: diagnosticContextReadSchema });
22252
- var operationalLogListReadSchema = z70.object({
22592
+ var diagnosticContextReadSchema = z71.object(diagnosticContextSchema.shape);
22593
+ var operationalLogEntryReadSchema = z71.object({ ...operationalLogEntryDtoSchema.shape, context: diagnosticContextReadSchema });
22594
+ var operationalLogListReadSchema = z71.object({
22253
22595
  ...operationalLogListDtoSchema.shape,
22254
- entries: z70.array(operationalLogEntryReadSchema),
22255
- retentionPolicy: z70.object(retentionPolicySchema.shape).optional()
22596
+ entries: z71.array(operationalLogEntryReadSchema),
22597
+ retentionPolicy: z71.object(retentionPolicySchema.shape).optional()
22256
22598
  });
22257
22599
 
22258
22600
  // ../contracts/src/semver.ts
@@ -22318,81 +22660,81 @@ function asRecord(value) {
22318
22660
  }
22319
22661
 
22320
22662
  // ../contracts/src/referral-assessment.ts
22321
- import { z as z71 } from "zod";
22322
- var referralAssessmentQuerySchema = z71.object({
22663
+ import { z as z72 } from "zod";
22664
+ var referralAssessmentQuerySchema = z72.object({
22323
22665
  startDate: calendarDateSchema,
22324
22666
  endDate: calendarDateSchema,
22325
- sourceId: z71.string().trim().min(1).optional(),
22326
- burstThreshold: z71.number().int().min(1).max(1e6).optional(),
22327
- ratioThreshold: z71.number().min(1).max(1e3).optional(),
22328
- limit: z71.number().int().min(1).max(500).optional()
22329
- }).strict();
22330
- var countsSchema = z71.object({
22331
- total: z71.number().int().nonnegative(),
22332
- paid: z71.number().int().nonnegative(),
22333
- organic: z71.number().int().nonnegative(),
22334
- unknown: z71.number().int().nonnegative()
22335
- });
22336
- var referralAssessmentSchema = z71.object({
22337
- scope: z71.object({
22338
- project: z71.string(),
22339
- sourceId: z71.string().nullable(),
22340
- attribution: z71.literal("project-source-only"),
22341
- unavailableDimensions: z71.array(z71.enum(["property", "target", "market"]))
22667
+ sourceId: z72.string().trim().min(1).optional(),
22668
+ burstThreshold: z72.number().int().min(1).max(1e6).optional(),
22669
+ ratioThreshold: z72.number().min(1).max(1e3).optional(),
22670
+ limit: z72.number().int().min(1).max(500).optional()
22671
+ }).strict();
22672
+ var countsSchema2 = z72.object({
22673
+ total: z72.number().int().nonnegative(),
22674
+ paid: z72.number().int().nonnegative(),
22675
+ organic: z72.number().int().nonnegative(),
22676
+ unknown: z72.number().int().nonnegative()
22677
+ });
22678
+ var referralAssessmentSchema = z72.object({
22679
+ scope: z72.object({
22680
+ project: z72.string(),
22681
+ sourceId: z72.string().nullable(),
22682
+ attribution: z72.literal("project-source-only"),
22683
+ unavailableDimensions: z72.array(z72.enum(["property", "target", "market"]))
22342
22684
  }),
22343
- window: z71.object({ startDate: calendarDateSchema, endDate: calendarDateSchema, timeZone: z71.literal("UTC") }),
22344
- rule: z71.object({
22345
- version: z71.literal("hourly-normalized-path-v1"),
22346
- burstThreshold: z71.number().int().positive(),
22347
- ratioThreshold: z71.number().positive(),
22348
- calibration: z71.enum(["uncalibrated-default", "request-override"]),
22349
- grouping: z71.array(z71.string()),
22350
- confirmsAutomation: z71.literal(false)
22685
+ window: z72.object({ startDate: calendarDateSchema, endDate: calendarDateSchema, timeZone: z72.literal("UTC") }),
22686
+ rule: z72.object({
22687
+ version: z72.literal("hourly-normalized-path-v1"),
22688
+ burstThreshold: z72.number().int().positive(),
22689
+ ratioThreshold: z72.number().positive(),
22690
+ calibration: z72.enum(["uncalibrated-default", "request-override"]),
22691
+ grouping: z72.array(z72.string()),
22692
+ confirmsAutomation: z72.literal(false)
22351
22693
  }),
22352
- totals: z71.object({
22353
- raw: countsSchema,
22354
- redirects: countsSchema,
22355
- subresources: countsSchema,
22356
- countable: countsSchema,
22357
- suspected: countsSchema,
22358
- adjustedEstimate: countsSchema
22694
+ totals: z72.object({
22695
+ raw: countsSchema2,
22696
+ redirects: countsSchema2,
22697
+ subresources: countsSchema2,
22698
+ countable: countsSchema2,
22699
+ suspected: countsSchema2,
22700
+ adjustedEstimate: countsSchema2
22359
22701
  }),
22360
- bursts: z71.array(z71.object({
22361
- sourceId: z71.string(),
22362
- product: z71.string(),
22363
- landingPathNormalized: z71.string(),
22364
- tsHour: z71.string(),
22365
- counts: countsSchema
22702
+ bursts: z72.array(z72.object({
22703
+ sourceId: z72.string(),
22704
+ product: z72.string(),
22705
+ landingPathNormalized: z72.string(),
22706
+ tsHour: z72.string(),
22707
+ counts: countsSchema2
22366
22708
  })),
22367
- evidence: z71.object({ total: z71.number().int().nonnegative(), returned: z71.number().int().nonnegative(), truncated: z71.boolean() }),
22368
- comparison: z71.object({
22369
- status: z71.literal("unavailable"),
22370
- serverCountable: z71.number().int().nonnegative(),
22371
- serverObservation: z71.enum(["missing", "observed-zero", "observed-positive"]),
22709
+ evidence: z72.object({ total: z72.number().int().nonnegative(), returned: z72.number().int().nonnegative(), truncated: z72.boolean() }),
22710
+ comparison: z72.object({
22711
+ status: z72.literal("unavailable"),
22712
+ serverCountable: z72.number().int().nonnegative(),
22713
+ serverObservation: z72.enum(["missing", "observed-zero", "observed-positive"]),
22372
22714
  /**
22373
22715
  * Dimension-deduplicated GA AI sessions. With no stored AI row in the
22374
22716
  * window: `0` (`observed-zero`) when the latest GA sync queried the whole
22375
22717
  * window (GA4 omits zero rows), else `null` (`missing`).
22376
22718
  */
22377
- gaSessions: z71.number().int().nonnegative().nullable(),
22378
- gaObservation: z71.enum(["missing", "observed-zero", "observed-positive"]),
22719
+ gaSessions: z72.number().int().nonnegative().nullable(),
22720
+ gaObservation: z72.enum(["missing", "observed-zero", "observed-positive"]),
22379
22721
  /**
22380
22722
  * Descriptive quotient only (`serverCountable / gaSessions`, a multiplier
22381
22723
  * where 3 is three times as many, never a percent), rounded to 2
22382
22724
  * decimals. Not a matched, coverage-complete comparison.
22383
22725
  */
22384
- observedRatio: z71.number().nonnegative().nullable(),
22726
+ observedRatio: z72.number().nonnegative().nullable(),
22385
22727
  /** Compares the rounded `observedRatio` with `rule.ratioThreshold`. */
22386
- observedRatioAboveThreshold: z71.boolean().nullable(),
22387
- ratio: z71.null(),
22388
- reasons: z71.array(z71.string()),
22389
- gaScope: z71.literal("project")
22728
+ observedRatioAboveThreshold: z72.boolean().nullable(),
22729
+ ratio: z72.null(),
22730
+ reasons: z72.array(z72.string()),
22731
+ gaScope: z72.literal("project")
22390
22732
  }),
22391
- caveats: z71.array(z71.string())
22733
+ caveats: z72.array(z72.string())
22392
22734
  });
22393
22735
 
22394
22736
  // ../contracts/src/tolerant-read.ts
22395
- import { z as z72 } from "zod";
22737
+ import { z as z73 } from "zod";
22396
22738
  var WRAPPER_TYPES = /* @__PURE__ */ new Set(["optional", "nullable", "default", "prefault", "readonly", "catch", "nonoptional"]);
22397
22739
  var DEPTH_LIMIT = 64;
22398
22740
  function defOf(schema) {
@@ -22403,9 +22745,9 @@ function cloneWith(schema, changes) {
22403
22745
  }
22404
22746
  function openPrimitive(values) {
22405
22747
  if (values.length === 0) return void 0;
22406
- if (values.every((value) => typeof value === "string")) return z72.string();
22407
- if (values.every((value) => typeof value === "number")) return z72.number();
22408
- if (values.every((value) => typeof value === "boolean")) return z72.boolean();
22748
+ if (values.every((value) => typeof value === "string")) return z73.string();
22749
+ if (values.every((value) => typeof value === "number")) return z73.number();
22750
+ if (values.every((value) => typeof value === "boolean")) return z73.boolean();
22409
22751
  return void 0;
22410
22752
  }
22411
22753
  function walk2(schema, open, memo, depth) {
@@ -22419,7 +22761,7 @@ function walk2(schema, open, memo, depth) {
22419
22761
  const shape = Object.fromEntries(Object.entries(schema.shape).map(([key, child]) => [key, next(child)]));
22420
22762
  const declared = def.catchall;
22421
22763
  const catchall = open.get(schema) ?? (declared && defOf(declared).type !== "never" ? next(declared) : void 0);
22422
- result = catchall ? z72.object(shape).catchall(catchall) : z72.object(shape);
22764
+ result = catchall ? z73.object(shape).catchall(catchall) : z73.object(shape);
22423
22765
  } else if (WRAPPER_TYPES.has(def.type)) {
22424
22766
  const inner = def.innerType;
22425
22767
  const mapped = next(inner);
@@ -22436,10 +22778,10 @@ function walk2(schema, open, memo, depth) {
22436
22778
  const options = def.options;
22437
22779
  const mapped = options.map(next);
22438
22780
  const changed = mapped.some((option, index) => option !== options[index]);
22439
- result = !changed ? schema : def.discriminator ? z72.union(mapped) : cloneWith(schema, { options: mapped });
22781
+ result = !changed ? schema : def.discriminator ? z73.union(mapped) : cloneWith(schema, { options: mapped });
22440
22782
  } else if (def.type === "record") {
22441
22783
  const keyType = def.keyType, valueType = def.valueType;
22442
- const mappedKey = defOf(keyType).type === "enum" ? z72.string() : keyType;
22784
+ const mappedKey = defOf(keyType).type === "enum" ? z73.string() : keyType;
22443
22785
  const mappedValue = next(valueType);
22444
22786
  result = mappedKey === keyType && mappedValue === valueType ? schema : cloneWith(schema, { keyType: mappedKey, valueType: mappedValue });
22445
22787
  } else if (def.type === "intersection") {
@@ -22455,7 +22797,7 @@ function walk2(schema, open, memo, depth) {
22455
22797
  result = changed ? cloneWith(schema, { items: mappedItems, rest: mappedRest }) : schema;
22456
22798
  } else if (def.type === "lazy") {
22457
22799
  const getter = def.getter;
22458
- result = z72.lazy(() => next(getter()));
22800
+ result = z73.lazy(() => next(getter()));
22459
22801
  } else if (def.type === "enum") {
22460
22802
  result = openPrimitive(Object.values(def.entries)) ?? schema;
22461
22803
  } else if (def.type === "literal") {
@@ -22470,8 +22812,8 @@ function tolerantReadSchema(schema, options = {}) {
22470
22812
  }
22471
22813
 
22472
22814
  // ../contracts/src/sentiment-read.ts
22473
- import { z as z73 } from "zod";
22474
- var OPEN_COUNTS = { openKeys: [[sentimentCountsSchema, z73.number().int().nonnegative()]] };
22815
+ import { z as z74 } from "zod";
22816
+ var OPEN_COUNTS = { openKeys: [[sentimentCountsSchema, z74.number().int().nonnegative()]] };
22475
22817
  var sentimentSettingsReadSchema = tolerantReadSchema(sentimentSettingsSchema, OPEN_COUNTS);
22476
22818
  var sentimentSummaryReadSchema = tolerantReadSchema(sentimentSummarySchema, OPEN_COUNTS);
22477
22819
  var sentimentEvidencePageReadSchema = tolerantReadSchema(sentimentEvidencePageSchema, OPEN_COUNTS);
@@ -22481,10 +22823,10 @@ var sentimentJobReadSchema = tolerantReadSchema(sentimentJobSchema, OPEN_COUNTS)
22481
22823
  var sentimentJobsReadSchema = tolerantReadSchema(sentimentJobsSchema, OPEN_COUNTS);
22482
22824
 
22483
22825
  // ../contracts/src/traffic-analytics.ts
22484
- import { z as z74 } from "zod";
22826
+ import { z as z75 } from "zod";
22485
22827
  var TRAFFIC_ANALYTICS_PERIOD_OPTIONS = [7, 14, 30, 90];
22486
22828
  var TRAFFIC_ANALYTICS_DEFAULT_PERIOD_DAYS = 30;
22487
- var trafficAnalyticsPeriodSchema = z74.union([z74.literal(7), z74.literal(14), z74.literal(30), z74.literal(90)]).describe("Traffic activity window in days (7, 14, 30, or 90). Defaults to 30 when omitted.");
22829
+ var trafficAnalyticsPeriodSchema = z75.union([z75.literal(7), z75.literal(14), z75.literal(30), z75.literal(90)]).describe("Traffic activity window in days (7, 14, 30, or 90). Defaults to 30 when omitted.");
22488
22830
  function parseTrafficAnalyticsPeriod(value) {
22489
22831
  if (value === void 0 || value === null || value === "") return TRAFFIC_ANALYTICS_DEFAULT_PERIOD_DAYS;
22490
22832
  const parsed = typeof value === "number" ? value : Number(value);
@@ -22494,17 +22836,17 @@ function parseTrafficAnalyticsPeriod(value) {
22494
22836
  }
22495
22837
  return result.data;
22496
22838
  }
22497
- var trafficActivityCountSchema = z74.object({ current: z74.number(), prior: z74.number(), deltaPct: percent().nullable() });
22498
- var trafficActivitySummarySchema = z74.object({
22839
+ var trafficActivityCountSchema = z75.object({ current: z75.number(), prior: z75.number(), deltaPct: percent().nullable() });
22840
+ var trafficActivitySummarySchema = z75.object({
22499
22841
  /** ISO8601 inclusive lower bound of the selected window (default: 30 days). */
22500
- windowStart: z74.string(),
22842
+ windowStart: z75.string(),
22501
22843
  /** ISO8601 inclusive upper bound. */
22502
- windowEnd: z74.string(),
22844
+ windowEnd: z75.string(),
22503
22845
  /** Earliest stored project observation across crawler, user-fetch and referral hourly rows; not window-bound. */
22504
- coverageStart: z74.string().nullable(),
22846
+ coverageStart: z75.string().nullable(),
22505
22847
  /** Recording began on or before the prior window start. This does not establish uninterrupted ingestion. */
22506
- priorWindowComplete: z74.boolean(),
22507
- hasData: z74.boolean().describe("True when the selected or prior window has stored crawler, user-fetch, countable referral or operator evidence, or the selected window has referral redirects. False means no qualifying stored evidence; it can occur with no, paused, errored or never-synced ingestion and out-of-window observations. It does not establish measured zero traffic or source health."),
22848
+ priorWindowComplete: z75.boolean(),
22849
+ hasData: z75.boolean().describe("True when the selected or prior window has stored crawler, user-fetch, countable referral or operator evidence, or the selected window has referral redirects. False means no qualifying stored evidence; it can occur with no, paused, errored or never-synced ingestion and out-of-window observations. It does not establish measured zero traffic or source health."),
22508
22850
  /** Verified crawler hits during the selected period and the equal preceding period. */
22509
22851
  verifiedCrawlerHits: trafficActivityCountSchema,
22510
22852
  /** Unverified crawler hits during the selected period, separate from verified hits. */
@@ -22533,7 +22875,7 @@ var trafficActivitySummarySchema = z74.object({
22533
22875
  * is exactly the thing to fix, so the summary must show it rather
22534
22876
  * than render an empty section.
22535
22877
  */
22536
- referralRedirects: z74.number().int().nonnegative(),
22878
+ referralRedirects: z75.number().int().nonnegative(),
22537
22879
  /**
22538
22880
  * `referralArrivals` split by traffic class. The three buckets sum to it.
22539
22881
  *
@@ -22542,31 +22884,31 @@ var trafficActivitySummarySchema = z74.object({
22542
22884
  * never be resolved. Reporting them as organic would overstate earned AI
22543
22885
  * traffic by exactly a client's ad volume.
22544
22886
  */
22545
- referralArrivalsByClass: z74.object({
22887
+ referralArrivalsByClass: z75.object({
22546
22888
  paid: trafficActivityCountSchema,
22547
22889
  organic: trafficActivityCountSchema,
22548
22890
  unclassified: trafficActivityCountSchema
22549
22891
  }),
22550
22892
  /** Pre-rendered one-line breakdown, e.g. "Paid 1,200 · Organic 24". Empty when there is nothing to split. */
22551
- referralArrivalsClassSummary: z74.string(),
22893
+ referralArrivalsClassSummary: z75.string(),
22552
22894
  /** Per-AI-operator breakdown (OpenAI, Anthropic, Google AI, Perplexity, …). */
22553
- byOperator: z74.array(z74.object({
22554
- operator: z74.string(),
22555
- verifiedHits: z74.number(),
22895
+ byOperator: z75.array(z75.object({
22896
+ operator: z75.string(),
22897
+ verifiedHits: z75.number(),
22556
22898
  /** claimed-bot UA, source IP not in a published range. */
22557
- unverifiedHits: z74.number(),
22899
+ unverifiedHits: z75.number(),
22558
22900
  /** Per-user fetches from this operator's AI surface (ChatGPT-User, …). */
22559
- userFetchHits: z74.number(),
22560
- referralArrivals: z74.number(),
22901
+ userFetchHits: z75.number(),
22902
+ referralArrivals: z75.number(),
22561
22903
  deltaPct: percent().nullable()
22562
22904
  })),
22563
22905
  /**
22564
22906
  * Top crawled paths during the selected period, with both verified and
22565
22907
  * unverified crawler hits. These are request counts, not citation evidence.
22566
22908
  */
22567
- topCrawledPaths: z74.array(z74.object({
22568
- path: z74.string(),
22569
- verifiedHits: z74.number(),
22909
+ topCrawledPaths: z75.array(z75.object({
22910
+ path: z75.string(),
22911
+ verifiedHits: z75.number(),
22570
22912
  /**
22571
22913
  * Hits from a crawler that identified itself but whose source IP could not
22572
22914
  * be matched against the operator's published ranges. Additive, not an
@@ -22574,36 +22916,36 @@ var trafficActivitySummarySchema = z74.object({
22574
22916
  * logs, for one), so for those projects every hit lands here and a
22575
22917
  * verified-only view reports zero against real crawl activity.
22576
22918
  */
22577
- unverifiedHits: z74.number().default(0),
22919
+ unverifiedHits: z75.number().default(0),
22578
22920
  /** How many distinct AI operators crawled this path in the window. */
22579
- distinctOperators: z74.number()
22921
+ distinctOperators: z75.number()
22580
22922
  })),
22581
22923
  /** AI products that sent ≥1 session in the window (referral by destination). */
22582
- referralProducts: z74.array(z74.object({
22583
- product: z74.string(),
22584
- arrivals: z74.number(),
22585
- distinctLandingPaths: z74.number()
22924
+ referralProducts: z75.array(z75.object({
22925
+ product: z75.string(),
22926
+ arrivals: z75.number(),
22927
+ distinctLandingPaths: z75.number()
22586
22928
  })),
22587
22929
  /** Daily request counts during the selected period. */
22588
- dailyTrend: z74.array(z74.object({
22589
- date: z74.string(),
22590
- verifiedCrawlerHits: z74.number(),
22930
+ dailyTrend: z75.array(z75.object({
22931
+ date: z75.string(),
22932
+ verifiedCrawlerHits: z75.number(),
22591
22933
  /** See topCrawledPaths.unverifiedHits. Plotted alongside, never instead. */
22592
- unverifiedCrawlerHits: z74.number().default(0),
22593
- userFetchHits: z74.number(),
22594
- referralArrivals: z74.number()
22934
+ unverifiedCrawlerHits: z75.number().default(0),
22935
+ userFetchHits: z75.number(),
22936
+ referralArrivals: z75.number()
22595
22937
  })),
22596
22938
  /**
22597
22939
  * Top landing paths for AI-referral sessions during the selected period.
22598
22940
  * Complements crawler paths with server-observed referral arrivals.
22599
22941
  */
22600
- topReferralLandingPaths: z74.array(z74.object({
22601
- path: z74.string(),
22602
- arrivals: z74.number(),
22603
- distinctProducts: z74.number()
22942
+ topReferralLandingPaths: z75.array(z75.object({
22943
+ path: z75.string(),
22944
+ arrivals: z75.number(),
22945
+ distinctProducts: z75.number()
22604
22946
  }))
22605
22947
  });
22606
- var trafficAnalyticsResponseSchema = z74.object({
22948
+ var trafficAnalyticsResponseSchema = z75.object({
22607
22949
  /** Null when no non-archived traffic source is connected. Connected sources without events return zero counts. */
22608
22950
  activity: trafficActivitySummarySchema.nullable()
22609
22951
  });
@@ -22651,6 +22993,7 @@ export {
22651
22993
  RetrievalStatuses,
22652
22994
  RetrievalContracts,
22653
22995
  providerQuotaPolicySchema,
22996
+ PROVIDER_NAMES,
22654
22997
  ProviderNames,
22655
22998
  API_PROVIDER_NAMES,
22656
22999
  isBrowserProvider,
@@ -23147,6 +23490,7 @@ export {
23147
23490
  buildModelChangeNotice,
23148
23491
  shareOf,
23149
23492
  breakdownShares,
23493
+ median,
23150
23494
  wilsonInterval,
23151
23495
  linearTrend,
23152
23496
  googleConnectionDtoSchema,
@@ -23621,6 +23965,22 @@ export {
23621
23965
  AGENT_NONE,
23622
23966
  normalizeAgentSlug,
23623
23967
  detectAgentRuntime,
23968
+ outcomeSurfaceSchema,
23969
+ OutcomeSurfaces,
23970
+ INTEGRATION_NAMES,
23971
+ IntegrationNames,
23972
+ OutcomeStatuses,
23973
+ OutcomeTriggers,
23974
+ OutcomeReasonCodes,
23975
+ FeatureNames,
23976
+ bucketDuration,
23977
+ integrationConnectionPropertiesSchema,
23978
+ featureCompletedPropertiesSchema,
23979
+ normalizeInstallRef,
23980
+ installStatePropertiesSchema,
23981
+ statusClassOf,
23982
+ classifyOutcomeError,
23983
+ classifyProviderOutcomeError,
23624
23984
  uiTelemetryEventSchema,
23625
23985
  isSensitiveDiagnosticQueryKey,
23626
23986
  redactLogValue,