@canonry/canonry 7.23.0 → 7.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/assets/{AuditHistoryPanel-J8AR3x5F.js → AuditHistoryPanel-DKKnX8IT.js} +1 -1
- package/assets/assets/{BacklinksPage-CRDPutGA.js → BacklinksPage-DNbur8am.js} +1 -1
- package/assets/assets/{HistoryPage-C5taVW3t.js → HistoryPage-DahtHlpM.js} +1 -1
- package/assets/assets/{MeasurementPropertyPage-txucmLuz.js → MeasurementPropertyPage-BoNDtLfp.js} +1 -1
- package/assets/assets/{ProjectPage-C4FaBoWI.js → ProjectPage--ZlpQduH.js} +1 -1
- package/assets/assets/{RunsPage-D-3XKUhh.js → RunsPage-DKB2CHTM.js} +1 -1
- package/assets/assets/{SettingsPage-Cq_SJRj_.js → SettingsPage-lnmMZzEj.js} +1 -1
- package/assets/assets/{SiteHealthSection-Cn_IZVO1.js → SiteHealthSection-BBjucRed.js} +3 -3
- package/assets/assets/{TrafficPage-BMdFZs3X.js → TrafficPage-DNyTmPLd.js} +1 -1
- package/assets/assets/{TrafficSourceDetailPage-BmrIOc-2.js → TrafficSourceDetailPage-D1zKZHSh.js} +1 -1
- package/assets/assets/{extract-error-message-HlQy5L7O.js → extract-error-message-v0b8P-wc.js} +1 -1
- package/assets/assets/index-CfaBRiBG.js +86 -0
- package/assets/assets/{react-sigma_core.esm.min-CogAr1i4.js → react-sigma_core.esm.min-BZSJoRrV.js} +1 -1
- package/assets/assets/{v2-overview-adapter-tps7TUxq.js → v2-overview-adapter-DXAl-O_h.js} +1 -1
- package/assets/index.html +1 -1
- package/dist/{chunk-222NAFTY.js → chunk-7Q7QCBJ3.js} +2 -2
- package/dist/{chunk-5IXQAOVK.js → chunk-DS2ZKB3T.js} +15 -6
- package/dist/{chunk-MRKV43TV.js → chunk-IM2BFAAT.js} +565 -206
- package/dist/{chunk-UF7MH6TU.js → chunk-JJBVYL45.js} +2 -2
- package/dist/{chunk-46JZR2IV.js → chunk-O5UMRQVN.js} +1303 -504
- package/dist/{chunk-3OPV5XBY.js → chunk-SG3MPCDL.js} +5709 -4588
- package/dist/{chunk-KWBFKTOA.js → chunk-YCPTP2NC.js} +3 -3
- package/dist/cli.js +199 -49
- package/dist/{demo-server-32PU7BM6.js → demo-server-C7UGXXN7.js} +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -6
- package/dist/{intelligence-service-256DQBVR.js → intelligence-service-37TX4YV7.js} +2 -2
- package/dist/mcp.js +4 -4
- package/package.json +12 -12
- 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
|
|
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 =
|
|
13595
|
+
const z210 = z76 * z76;
|
|
13589
13596
|
const denom = 1 + z210 / n;
|
|
13590
13597
|
const center = (p + z210 / (2 * n)) / denom;
|
|
13591
|
-
const margin =
|
|
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/
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
22202
|
+
var uiIntegrationSchema = z69.enum(UI_INTEGRATIONS);
|
|
21862
22203
|
var UI_FILTERS = ["provider", "model", "location", "window", "query_class", "other"];
|
|
21863
|
-
var uiFilterSchema =
|
|
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,44 @@ function isUiApiRouteTemplate(route) {
|
|
|
21945
22286
|
return PARAM_SEGMENT.test(segment) || UI_ROUTE_FIXED_CHILDREN.has(`${previous}/${segment}`);
|
|
21946
22287
|
});
|
|
21947
22288
|
}
|
|
21948
|
-
var uiEventBaseSchema =
|
|
21949
|
-
eventId:
|
|
21950
|
-
uiSessionId:
|
|
22289
|
+
var uiEventBaseSchema = z69.object({
|
|
22290
|
+
eventId: z69.string().uuid(),
|
|
22291
|
+
uiSessionId: z69.string().uuid(),
|
|
21951
22292
|
page: uiPageSchema
|
|
21952
22293
|
});
|
|
21953
|
-
var uiTelemetryEventSchema =
|
|
22294
|
+
var uiTelemetryEventSchema = z69.discriminatedUnion("event", [
|
|
21954
22295
|
uiEventBaseSchema.extend({
|
|
21955
|
-
event:
|
|
22296
|
+
event: z69.literal("ui.page_viewed"),
|
|
21956
22297
|
tab: uiProjectTabSchema.optional()
|
|
21957
22298
|
}).strict(),
|
|
21958
22299
|
uiEventBaseSchema.extend({
|
|
21959
|
-
event:
|
|
22300
|
+
event: z69.literal("ui.action"),
|
|
21960
22301
|
action: uiActionSchema,
|
|
21961
22302
|
tab: uiProjectTabSchema.optional(),
|
|
21962
22303
|
integration: uiIntegrationSchema.optional(),
|
|
21963
|
-
format:
|
|
22304
|
+
format: z69.enum(UI_EXPORT_FORMATS).optional(),
|
|
21964
22305
|
filter: uiFilterSchema.optional()
|
|
21965
22306
|
}).strict(),
|
|
21966
22307
|
uiEventBaseSchema.extend({
|
|
21967
|
-
event:
|
|
21968
|
-
kind:
|
|
22308
|
+
event: z69.literal("ui.error"),
|
|
22309
|
+
kind: z69.enum(UI_ERROR_KINDS),
|
|
21969
22310
|
tab: uiProjectTabSchema.optional(),
|
|
21970
|
-
component:
|
|
21971
|
-
errorName:
|
|
21972
|
-
route:
|
|
21973
|
-
method:
|
|
21974
|
-
statusClass:
|
|
21975
|
-
status:
|
|
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:
|
|
21979
|
-
metric:
|
|
21980
|
-
rating:
|
|
22319
|
+
event: z69.literal("ui.vitals"),
|
|
22320
|
+
metric: z69.enum(UI_VITAL_METRICS),
|
|
22321
|
+
rating: z69.enum(UI_VITAL_RATINGS)
|
|
21981
22322
|
}).strict()
|
|
21982
22323
|
]);
|
|
21983
22324
|
|
|
21984
22325
|
// ../contracts/src/feedback.ts
|
|
21985
|
-
import { z as
|
|
22326
|
+
import { z as z70 } from "zod";
|
|
21986
22327
|
|
|
21987
22328
|
// ../contracts/src/log-redaction.ts
|
|
21988
22329
|
var REDACTED = "[REDACTED]";
|
|
@@ -22134,7 +22475,7 @@ function redactEmbeddedUrls(value) {
|
|
|
22134
22475
|
|
|
22135
22476
|
// ../contracts/src/feedback.ts
|
|
22136
22477
|
var FEEDBACK_KINDS = ["struggle", "bug", "improvement", "other"];
|
|
22137
|
-
var feedbackKindSchema =
|
|
22478
|
+
var feedbackKindSchema = z70.enum(FEEDBACK_KINDS);
|
|
22138
22479
|
var FEEDBACK_LIMITS = {
|
|
22139
22480
|
summary: 500,
|
|
22140
22481
|
details: 4e3,
|
|
@@ -22142,17 +22483,17 @@ var FEEDBACK_LIMITS = {
|
|
|
22142
22483
|
command: 120,
|
|
22143
22484
|
errorCode: 40
|
|
22144
22485
|
};
|
|
22145
|
-
var feedbackSubmissionSchema =
|
|
22486
|
+
var feedbackSubmissionSchema = z70.object({
|
|
22146
22487
|
kind: feedbackKindSchema,
|
|
22147
|
-
summary:
|
|
22148
|
-
details:
|
|
22149
|
-
area:
|
|
22150
|
-
command:
|
|
22151
|
-
errorCode:
|
|
22488
|
+
summary: z70.string().trim().min(1).max(FEEDBACK_LIMITS.summary),
|
|
22489
|
+
details: z70.string().trim().min(1).max(FEEDBACK_LIMITS.details).optional(),
|
|
22490
|
+
area: z70.string().trim().min(1).max(FEEDBACK_LIMITS.area).optional(),
|
|
22491
|
+
command: z70.string().trim().min(1).max(FEEDBACK_LIMITS.command).optional(),
|
|
22492
|
+
errorCode: z70.string().trim().min(1).max(FEEDBACK_LIMITS.errorCode).optional()
|
|
22152
22493
|
}).strict();
|
|
22153
|
-
var feedbackAcceptedDtoSchema =
|
|
22154
|
-
accepted:
|
|
22155
|
-
id:
|
|
22494
|
+
var feedbackAcceptedDtoSchema = z70.object({
|
|
22495
|
+
accepted: z70.boolean(),
|
|
22496
|
+
id: z70.string()
|
|
22156
22497
|
});
|
|
22157
22498
|
function redactFeedbackText(value, limit) {
|
|
22158
22499
|
return truncateUtf16(
|
|
@@ -22169,90 +22510,90 @@ var SECRET_FLAG_VALUE = /(?<=^|[ \t])(--?(?:[a-z\d]+-)*(?:key|token|secret|passw
|
|
|
22169
22510
|
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
22511
|
|
|
22171
22512
|
// ../contracts/src/operational-logs.ts
|
|
22172
|
-
import { z as
|
|
22173
|
-
var operationalLogLevelSchema =
|
|
22174
|
-
var diagnosticContextSchema =
|
|
22175
|
-
runId:
|
|
22176
|
-
projectId:
|
|
22177
|
-
requestId:
|
|
22178
|
-
actor:
|
|
22179
|
-
credentialId:
|
|
22180
|
-
userAgent:
|
|
22181
|
-
actorSession:
|
|
22182
|
-
method:
|
|
22183
|
-
route:
|
|
22184
|
-
operationId:
|
|
22185
|
-
jobId:
|
|
22186
|
-
taskId:
|
|
22187
|
-
traceId:
|
|
22188
|
-
provider:
|
|
22189
|
-
errorCode:
|
|
22190
|
-
attempt:
|
|
22191
|
-
count:
|
|
22192
|
-
total:
|
|
22193
|
-
progress:
|
|
22194
|
-
httpStatus:
|
|
22195
|
-
statusCode:
|
|
22196
|
-
durationMs:
|
|
22197
|
-
bytes:
|
|
22198
|
-
retryAfterMs:
|
|
22199
|
-
retriable:
|
|
22200
|
-
retrying:
|
|
22201
|
-
cancelled:
|
|
22202
|
-
success:
|
|
22203
|
-
}).strict();
|
|
22204
|
-
var operationalLogEntryDtoSchema =
|
|
22205
|
-
cursor:
|
|
22206
|
-
ts:
|
|
22513
|
+
import { z as z71 } from "zod";
|
|
22514
|
+
var operationalLogLevelSchema = z71.enum(["trace", "debug", "info", "warn", "error", "fatal"]);
|
|
22515
|
+
var diagnosticContextSchema = z71.object({
|
|
22516
|
+
runId: z71.string().min(1).max(256).optional(),
|
|
22517
|
+
projectId: z71.string().min(1).max(256).optional(),
|
|
22518
|
+
requestId: z71.string().min(1).max(256).optional(),
|
|
22519
|
+
actor: z71.string().min(1).max(512).optional(),
|
|
22520
|
+
credentialId: z71.string().min(1).max(512).optional(),
|
|
22521
|
+
userAgent: z71.string().min(1).max(512).optional(),
|
|
22522
|
+
actorSession: z71.string().min(1).max(512).optional(),
|
|
22523
|
+
method: z71.string().min(1).max(16).optional(),
|
|
22524
|
+
route: z71.string().min(1).max(256).optional(),
|
|
22525
|
+
operationId: z71.string().min(1).max(256).optional(),
|
|
22526
|
+
jobId: z71.string().min(1).max(256).optional(),
|
|
22527
|
+
taskId: z71.string().min(1).max(256).optional(),
|
|
22528
|
+
traceId: z71.string().min(1).max(256).optional(),
|
|
22529
|
+
provider: z71.string().min(1).max(256).optional(),
|
|
22530
|
+
errorCode: z71.string().min(1).max(128).optional(),
|
|
22531
|
+
attempt: z71.number().finite().optional(),
|
|
22532
|
+
count: z71.number().finite().optional(),
|
|
22533
|
+
total: z71.number().finite().optional(),
|
|
22534
|
+
progress: z71.number().finite().optional(),
|
|
22535
|
+
httpStatus: z71.number().finite().optional(),
|
|
22536
|
+
statusCode: z71.number().finite().optional(),
|
|
22537
|
+
durationMs: z71.number().finite().optional(),
|
|
22538
|
+
bytes: z71.number().finite().optional(),
|
|
22539
|
+
retryAfterMs: z71.number().finite().optional(),
|
|
22540
|
+
retriable: z71.boolean().optional(),
|
|
22541
|
+
retrying: z71.boolean().optional(),
|
|
22542
|
+
cancelled: z71.boolean().optional(),
|
|
22543
|
+
success: z71.boolean().optional()
|
|
22544
|
+
}).strict();
|
|
22545
|
+
var operationalLogEntryDtoSchema = z71.object({
|
|
22546
|
+
cursor: z71.string().min(1).max(512),
|
|
22547
|
+
ts: z71.string().datetime(),
|
|
22207
22548
|
level: operationalLogLevelSchema,
|
|
22208
|
-
module:
|
|
22209
|
-
action:
|
|
22210
|
-
message:
|
|
22211
|
-
runId:
|
|
22212
|
-
projectId:
|
|
22549
|
+
module: z71.string().min(1).max(256),
|
|
22550
|
+
action: z71.string().min(1).max(256),
|
|
22551
|
+
message: z71.string().max(4096).optional(),
|
|
22552
|
+
runId: z71.string().min(1).max(256).optional(),
|
|
22553
|
+
projectId: z71.string().min(1).max(256).optional(),
|
|
22213
22554
|
context: diagnosticContextSchema
|
|
22214
22555
|
}).strict();
|
|
22215
|
-
var logQuerySchema =
|
|
22556
|
+
var logQuerySchema = z71.object({
|
|
22216
22557
|
level: operationalLogLevelSchema.optional(),
|
|
22217
|
-
module:
|
|
22218
|
-
runId:
|
|
22219
|
-
projectId:
|
|
22220
|
-
actor:
|
|
22221
|
-
requestId:
|
|
22222
|
-
since:
|
|
22223
|
-
until:
|
|
22224
|
-
limit:
|
|
22225
|
-
cursor:
|
|
22558
|
+
module: z71.string().trim().min(1).max(256).optional(),
|
|
22559
|
+
runId: z71.string().trim().min(1).max(256).optional(),
|
|
22560
|
+
projectId: z71.string().trim().min(1).max(256).optional(),
|
|
22561
|
+
actor: z71.string().trim().min(1).max(512).optional(),
|
|
22562
|
+
requestId: z71.string().trim().min(1).max(256).optional(),
|
|
22563
|
+
since: z71.string().datetime().optional(),
|
|
22564
|
+
until: z71.string().datetime().optional(),
|
|
22565
|
+
limit: z71.coerce.number().int().min(1).max(200).default(100),
|
|
22566
|
+
cursor: z71.string().trim().min(1).max(512).optional()
|
|
22226
22567
|
}).strict().superRefine((query, ctx) => {
|
|
22227
22568
|
if (query.since && query.until && Date.parse(query.since) > Date.parse(query.until)) {
|
|
22228
|
-
ctx.addIssue({ code:
|
|
22569
|
+
ctx.addIssue({ code: z71.ZodIssueCode.custom, path: ["until"], message: '"until" must be on or after "since".' });
|
|
22229
22570
|
}
|
|
22230
22571
|
});
|
|
22231
|
-
var retentionPolicySchema =
|
|
22232
|
-
maxEntries:
|
|
22233
|
-
maxAgeSeconds:
|
|
22572
|
+
var retentionPolicySchema = z71.object({
|
|
22573
|
+
maxEntries: z71.number().int().positive(),
|
|
22574
|
+
maxAgeSeconds: z71.number().int().positive()
|
|
22234
22575
|
}).strict();
|
|
22235
|
-
var operationalLogListDtoSchema =
|
|
22236
|
-
entries:
|
|
22237
|
-
nextCursor:
|
|
22576
|
+
var operationalLogListDtoSchema = z71.object({
|
|
22577
|
+
entries: z71.array(operationalLogEntryDtoSchema),
|
|
22578
|
+
nextCursor: z71.string().min(1).max(512).nullable(),
|
|
22238
22579
|
/** Matching entries left after this page. */
|
|
22239
|
-
truncated:
|
|
22580
|
+
truncated: z71.number().int().nonnegative(),
|
|
22240
22581
|
/** Entries evicted by the active retention policy. */
|
|
22241
|
-
dropped:
|
|
22242
|
-
retention:
|
|
22582
|
+
dropped: z71.number().int().nonnegative(),
|
|
22583
|
+
retention: z71.enum(["process", "durable"]),
|
|
22243
22584
|
retentionPolicy: retentionPolicySchema.optional(),
|
|
22244
22585
|
/** Best-effort persistence failures observed by this store. */
|
|
22245
|
-
captureErrors:
|
|
22246
|
-
observedAt:
|
|
22586
|
+
captureErrors: z71.number().int().nonnegative().optional(),
|
|
22587
|
+
observedAt: z71.string().datetime()
|
|
22247
22588
|
}).strict();
|
|
22248
22589
|
var OPERATIONAL_LOG_FIELDS_HEADER = "x-canonry-log-fields";
|
|
22249
22590
|
var OPERATIONAL_LOG_OPT_IN_CONTEXT_FIELDS = ["provider"];
|
|
22250
|
-
var diagnosticContextReadSchema =
|
|
22251
|
-
var operationalLogEntryReadSchema =
|
|
22252
|
-
var operationalLogListReadSchema =
|
|
22591
|
+
var diagnosticContextReadSchema = z71.object(diagnosticContextSchema.shape);
|
|
22592
|
+
var operationalLogEntryReadSchema = z71.object({ ...operationalLogEntryDtoSchema.shape, context: diagnosticContextReadSchema });
|
|
22593
|
+
var operationalLogListReadSchema = z71.object({
|
|
22253
22594
|
...operationalLogListDtoSchema.shape,
|
|
22254
|
-
entries:
|
|
22255
|
-
retentionPolicy:
|
|
22595
|
+
entries: z71.array(operationalLogEntryReadSchema),
|
|
22596
|
+
retentionPolicy: z71.object(retentionPolicySchema.shape).optional()
|
|
22256
22597
|
});
|
|
22257
22598
|
|
|
22258
22599
|
// ../contracts/src/semver.ts
|
|
@@ -22318,81 +22659,81 @@ function asRecord(value) {
|
|
|
22318
22659
|
}
|
|
22319
22660
|
|
|
22320
22661
|
// ../contracts/src/referral-assessment.ts
|
|
22321
|
-
import { z as
|
|
22322
|
-
var referralAssessmentQuerySchema =
|
|
22662
|
+
import { z as z72 } from "zod";
|
|
22663
|
+
var referralAssessmentQuerySchema = z72.object({
|
|
22323
22664
|
startDate: calendarDateSchema,
|
|
22324
22665
|
endDate: calendarDateSchema,
|
|
22325
|
-
sourceId:
|
|
22326
|
-
burstThreshold:
|
|
22327
|
-
ratioThreshold:
|
|
22328
|
-
limit:
|
|
22329
|
-
}).strict();
|
|
22330
|
-
var
|
|
22331
|
-
total:
|
|
22332
|
-
paid:
|
|
22333
|
-
organic:
|
|
22334
|
-
unknown:
|
|
22335
|
-
});
|
|
22336
|
-
var referralAssessmentSchema =
|
|
22337
|
-
scope:
|
|
22338
|
-
project:
|
|
22339
|
-
sourceId:
|
|
22340
|
-
attribution:
|
|
22341
|
-
unavailableDimensions:
|
|
22666
|
+
sourceId: z72.string().trim().min(1).optional(),
|
|
22667
|
+
burstThreshold: z72.number().int().min(1).max(1e6).optional(),
|
|
22668
|
+
ratioThreshold: z72.number().min(1).max(1e3).optional(),
|
|
22669
|
+
limit: z72.number().int().min(1).max(500).optional()
|
|
22670
|
+
}).strict();
|
|
22671
|
+
var countsSchema2 = z72.object({
|
|
22672
|
+
total: z72.number().int().nonnegative(),
|
|
22673
|
+
paid: z72.number().int().nonnegative(),
|
|
22674
|
+
organic: z72.number().int().nonnegative(),
|
|
22675
|
+
unknown: z72.number().int().nonnegative()
|
|
22676
|
+
});
|
|
22677
|
+
var referralAssessmentSchema = z72.object({
|
|
22678
|
+
scope: z72.object({
|
|
22679
|
+
project: z72.string(),
|
|
22680
|
+
sourceId: z72.string().nullable(),
|
|
22681
|
+
attribution: z72.literal("project-source-only"),
|
|
22682
|
+
unavailableDimensions: z72.array(z72.enum(["property", "target", "market"]))
|
|
22342
22683
|
}),
|
|
22343
|
-
window:
|
|
22344
|
-
rule:
|
|
22345
|
-
version:
|
|
22346
|
-
burstThreshold:
|
|
22347
|
-
ratioThreshold:
|
|
22348
|
-
calibration:
|
|
22349
|
-
grouping:
|
|
22350
|
-
confirmsAutomation:
|
|
22684
|
+
window: z72.object({ startDate: calendarDateSchema, endDate: calendarDateSchema, timeZone: z72.literal("UTC") }),
|
|
22685
|
+
rule: z72.object({
|
|
22686
|
+
version: z72.literal("hourly-normalized-path-v1"),
|
|
22687
|
+
burstThreshold: z72.number().int().positive(),
|
|
22688
|
+
ratioThreshold: z72.number().positive(),
|
|
22689
|
+
calibration: z72.enum(["uncalibrated-default", "request-override"]),
|
|
22690
|
+
grouping: z72.array(z72.string()),
|
|
22691
|
+
confirmsAutomation: z72.literal(false)
|
|
22351
22692
|
}),
|
|
22352
|
-
totals:
|
|
22353
|
-
raw:
|
|
22354
|
-
redirects:
|
|
22355
|
-
subresources:
|
|
22356
|
-
countable:
|
|
22357
|
-
suspected:
|
|
22358
|
-
adjustedEstimate:
|
|
22693
|
+
totals: z72.object({
|
|
22694
|
+
raw: countsSchema2,
|
|
22695
|
+
redirects: countsSchema2,
|
|
22696
|
+
subresources: countsSchema2,
|
|
22697
|
+
countable: countsSchema2,
|
|
22698
|
+
suspected: countsSchema2,
|
|
22699
|
+
adjustedEstimate: countsSchema2
|
|
22359
22700
|
}),
|
|
22360
|
-
bursts:
|
|
22361
|
-
sourceId:
|
|
22362
|
-
product:
|
|
22363
|
-
landingPathNormalized:
|
|
22364
|
-
tsHour:
|
|
22365
|
-
counts:
|
|
22701
|
+
bursts: z72.array(z72.object({
|
|
22702
|
+
sourceId: z72.string(),
|
|
22703
|
+
product: z72.string(),
|
|
22704
|
+
landingPathNormalized: z72.string(),
|
|
22705
|
+
tsHour: z72.string(),
|
|
22706
|
+
counts: countsSchema2
|
|
22366
22707
|
})),
|
|
22367
|
-
evidence:
|
|
22368
|
-
comparison:
|
|
22369
|
-
status:
|
|
22370
|
-
serverCountable:
|
|
22371
|
-
serverObservation:
|
|
22708
|
+
evidence: z72.object({ total: z72.number().int().nonnegative(), returned: z72.number().int().nonnegative(), truncated: z72.boolean() }),
|
|
22709
|
+
comparison: z72.object({
|
|
22710
|
+
status: z72.literal("unavailable"),
|
|
22711
|
+
serverCountable: z72.number().int().nonnegative(),
|
|
22712
|
+
serverObservation: z72.enum(["missing", "observed-zero", "observed-positive"]),
|
|
22372
22713
|
/**
|
|
22373
22714
|
* Dimension-deduplicated GA AI sessions. With no stored AI row in the
|
|
22374
22715
|
* window: `0` (`observed-zero`) when the latest GA sync queried the whole
|
|
22375
22716
|
* window (GA4 omits zero rows), else `null` (`missing`).
|
|
22376
22717
|
*/
|
|
22377
|
-
gaSessions:
|
|
22378
|
-
gaObservation:
|
|
22718
|
+
gaSessions: z72.number().int().nonnegative().nullable(),
|
|
22719
|
+
gaObservation: z72.enum(["missing", "observed-zero", "observed-positive"]),
|
|
22379
22720
|
/**
|
|
22380
22721
|
* Descriptive quotient only (`serverCountable / gaSessions`, a multiplier
|
|
22381
22722
|
* where 3 is three times as many, never a percent), rounded to 2
|
|
22382
22723
|
* decimals. Not a matched, coverage-complete comparison.
|
|
22383
22724
|
*/
|
|
22384
|
-
observedRatio:
|
|
22725
|
+
observedRatio: z72.number().nonnegative().nullable(),
|
|
22385
22726
|
/** Compares the rounded `observedRatio` with `rule.ratioThreshold`. */
|
|
22386
|
-
observedRatioAboveThreshold:
|
|
22387
|
-
ratio:
|
|
22388
|
-
reasons:
|
|
22389
|
-
gaScope:
|
|
22727
|
+
observedRatioAboveThreshold: z72.boolean().nullable(),
|
|
22728
|
+
ratio: z72.null(),
|
|
22729
|
+
reasons: z72.array(z72.string()),
|
|
22730
|
+
gaScope: z72.literal("project")
|
|
22390
22731
|
}),
|
|
22391
|
-
caveats:
|
|
22732
|
+
caveats: z72.array(z72.string())
|
|
22392
22733
|
});
|
|
22393
22734
|
|
|
22394
22735
|
// ../contracts/src/tolerant-read.ts
|
|
22395
|
-
import { z as
|
|
22736
|
+
import { z as z73 } from "zod";
|
|
22396
22737
|
var WRAPPER_TYPES = /* @__PURE__ */ new Set(["optional", "nullable", "default", "prefault", "readonly", "catch", "nonoptional"]);
|
|
22397
22738
|
var DEPTH_LIMIT = 64;
|
|
22398
22739
|
function defOf(schema) {
|
|
@@ -22403,9 +22744,9 @@ function cloneWith(schema, changes) {
|
|
|
22403
22744
|
}
|
|
22404
22745
|
function openPrimitive(values) {
|
|
22405
22746
|
if (values.length === 0) return void 0;
|
|
22406
|
-
if (values.every((value) => typeof value === "string")) return
|
|
22407
|
-
if (values.every((value) => typeof value === "number")) return
|
|
22408
|
-
if (values.every((value) => typeof value === "boolean")) return
|
|
22747
|
+
if (values.every((value) => typeof value === "string")) return z73.string();
|
|
22748
|
+
if (values.every((value) => typeof value === "number")) return z73.number();
|
|
22749
|
+
if (values.every((value) => typeof value === "boolean")) return z73.boolean();
|
|
22409
22750
|
return void 0;
|
|
22410
22751
|
}
|
|
22411
22752
|
function walk2(schema, open, memo, depth) {
|
|
@@ -22419,7 +22760,7 @@ function walk2(schema, open, memo, depth) {
|
|
|
22419
22760
|
const shape = Object.fromEntries(Object.entries(schema.shape).map(([key, child]) => [key, next(child)]));
|
|
22420
22761
|
const declared = def.catchall;
|
|
22421
22762
|
const catchall = open.get(schema) ?? (declared && defOf(declared).type !== "never" ? next(declared) : void 0);
|
|
22422
|
-
result = catchall ?
|
|
22763
|
+
result = catchall ? z73.object(shape).catchall(catchall) : z73.object(shape);
|
|
22423
22764
|
} else if (WRAPPER_TYPES.has(def.type)) {
|
|
22424
22765
|
const inner = def.innerType;
|
|
22425
22766
|
const mapped = next(inner);
|
|
@@ -22436,10 +22777,10 @@ function walk2(schema, open, memo, depth) {
|
|
|
22436
22777
|
const options = def.options;
|
|
22437
22778
|
const mapped = options.map(next);
|
|
22438
22779
|
const changed = mapped.some((option, index) => option !== options[index]);
|
|
22439
|
-
result = !changed ? schema : def.discriminator ?
|
|
22780
|
+
result = !changed ? schema : def.discriminator ? z73.union(mapped) : cloneWith(schema, { options: mapped });
|
|
22440
22781
|
} else if (def.type === "record") {
|
|
22441
22782
|
const keyType = def.keyType, valueType = def.valueType;
|
|
22442
|
-
const mappedKey = defOf(keyType).type === "enum" ?
|
|
22783
|
+
const mappedKey = defOf(keyType).type === "enum" ? z73.string() : keyType;
|
|
22443
22784
|
const mappedValue = next(valueType);
|
|
22444
22785
|
result = mappedKey === keyType && mappedValue === valueType ? schema : cloneWith(schema, { keyType: mappedKey, valueType: mappedValue });
|
|
22445
22786
|
} else if (def.type === "intersection") {
|
|
@@ -22455,7 +22796,7 @@ function walk2(schema, open, memo, depth) {
|
|
|
22455
22796
|
result = changed ? cloneWith(schema, { items: mappedItems, rest: mappedRest }) : schema;
|
|
22456
22797
|
} else if (def.type === "lazy") {
|
|
22457
22798
|
const getter = def.getter;
|
|
22458
|
-
result =
|
|
22799
|
+
result = z73.lazy(() => next(getter()));
|
|
22459
22800
|
} else if (def.type === "enum") {
|
|
22460
22801
|
result = openPrimitive(Object.values(def.entries)) ?? schema;
|
|
22461
22802
|
} else if (def.type === "literal") {
|
|
@@ -22470,8 +22811,8 @@ function tolerantReadSchema(schema, options = {}) {
|
|
|
22470
22811
|
}
|
|
22471
22812
|
|
|
22472
22813
|
// ../contracts/src/sentiment-read.ts
|
|
22473
|
-
import { z as
|
|
22474
|
-
var OPEN_COUNTS = { openKeys: [[sentimentCountsSchema,
|
|
22814
|
+
import { z as z74 } from "zod";
|
|
22815
|
+
var OPEN_COUNTS = { openKeys: [[sentimentCountsSchema, z74.number().int().nonnegative()]] };
|
|
22475
22816
|
var sentimentSettingsReadSchema = tolerantReadSchema(sentimentSettingsSchema, OPEN_COUNTS);
|
|
22476
22817
|
var sentimentSummaryReadSchema = tolerantReadSchema(sentimentSummarySchema, OPEN_COUNTS);
|
|
22477
22818
|
var sentimentEvidencePageReadSchema = tolerantReadSchema(sentimentEvidencePageSchema, OPEN_COUNTS);
|
|
@@ -22481,10 +22822,10 @@ var sentimentJobReadSchema = tolerantReadSchema(sentimentJobSchema, OPEN_COUNTS)
|
|
|
22481
22822
|
var sentimentJobsReadSchema = tolerantReadSchema(sentimentJobsSchema, OPEN_COUNTS);
|
|
22482
22823
|
|
|
22483
22824
|
// ../contracts/src/traffic-analytics.ts
|
|
22484
|
-
import { z as
|
|
22825
|
+
import { z as z75 } from "zod";
|
|
22485
22826
|
var TRAFFIC_ANALYTICS_PERIOD_OPTIONS = [7, 14, 30, 90];
|
|
22486
22827
|
var TRAFFIC_ANALYTICS_DEFAULT_PERIOD_DAYS = 30;
|
|
22487
|
-
var trafficAnalyticsPeriodSchema =
|
|
22828
|
+
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
22829
|
function parseTrafficAnalyticsPeriod(value) {
|
|
22489
22830
|
if (value === void 0 || value === null || value === "") return TRAFFIC_ANALYTICS_DEFAULT_PERIOD_DAYS;
|
|
22490
22831
|
const parsed = typeof value === "number" ? value : Number(value);
|
|
@@ -22494,17 +22835,17 @@ function parseTrafficAnalyticsPeriod(value) {
|
|
|
22494
22835
|
}
|
|
22495
22836
|
return result.data;
|
|
22496
22837
|
}
|
|
22497
|
-
var trafficActivityCountSchema =
|
|
22498
|
-
var trafficActivitySummarySchema =
|
|
22838
|
+
var trafficActivityCountSchema = z75.object({ current: z75.number(), prior: z75.number(), deltaPct: percent().nullable() });
|
|
22839
|
+
var trafficActivitySummarySchema = z75.object({
|
|
22499
22840
|
/** ISO8601 inclusive lower bound of the selected window (default: 30 days). */
|
|
22500
|
-
windowStart:
|
|
22841
|
+
windowStart: z75.string(),
|
|
22501
22842
|
/** ISO8601 inclusive upper bound. */
|
|
22502
|
-
windowEnd:
|
|
22843
|
+
windowEnd: z75.string(),
|
|
22503
22844
|
/** Earliest stored project observation across crawler, user-fetch and referral hourly rows; not window-bound. */
|
|
22504
|
-
coverageStart:
|
|
22845
|
+
coverageStart: z75.string().nullable(),
|
|
22505
22846
|
/** Recording began on or before the prior window start. This does not establish uninterrupted ingestion. */
|
|
22506
|
-
priorWindowComplete:
|
|
22507
|
-
hasData:
|
|
22847
|
+
priorWindowComplete: z75.boolean(),
|
|
22848
|
+
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
22849
|
/** Verified crawler hits during the selected period and the equal preceding period. */
|
|
22509
22850
|
verifiedCrawlerHits: trafficActivityCountSchema,
|
|
22510
22851
|
/** Unverified crawler hits during the selected period, separate from verified hits. */
|
|
@@ -22533,7 +22874,7 @@ var trafficActivitySummarySchema = z74.object({
|
|
|
22533
22874
|
* is exactly the thing to fix, so the summary must show it rather
|
|
22534
22875
|
* than render an empty section.
|
|
22535
22876
|
*/
|
|
22536
|
-
referralRedirects:
|
|
22877
|
+
referralRedirects: z75.number().int().nonnegative(),
|
|
22537
22878
|
/**
|
|
22538
22879
|
* `referralArrivals` split by traffic class. The three buckets sum to it.
|
|
22539
22880
|
*
|
|
@@ -22542,31 +22883,31 @@ var trafficActivitySummarySchema = z74.object({
|
|
|
22542
22883
|
* never be resolved. Reporting them as organic would overstate earned AI
|
|
22543
22884
|
* traffic by exactly a client's ad volume.
|
|
22544
22885
|
*/
|
|
22545
|
-
referralArrivalsByClass:
|
|
22886
|
+
referralArrivalsByClass: z75.object({
|
|
22546
22887
|
paid: trafficActivityCountSchema,
|
|
22547
22888
|
organic: trafficActivityCountSchema,
|
|
22548
22889
|
unclassified: trafficActivityCountSchema
|
|
22549
22890
|
}),
|
|
22550
22891
|
/** Pre-rendered one-line breakdown, e.g. "Paid 1,200 · Organic 24". Empty when there is nothing to split. */
|
|
22551
|
-
referralArrivalsClassSummary:
|
|
22892
|
+
referralArrivalsClassSummary: z75.string(),
|
|
22552
22893
|
/** Per-AI-operator breakdown (OpenAI, Anthropic, Google AI, Perplexity, …). */
|
|
22553
|
-
byOperator:
|
|
22554
|
-
operator:
|
|
22555
|
-
verifiedHits:
|
|
22894
|
+
byOperator: z75.array(z75.object({
|
|
22895
|
+
operator: z75.string(),
|
|
22896
|
+
verifiedHits: z75.number(),
|
|
22556
22897
|
/** claimed-bot UA, source IP not in a published range. */
|
|
22557
|
-
unverifiedHits:
|
|
22898
|
+
unverifiedHits: z75.number(),
|
|
22558
22899
|
/** Per-user fetches from this operator's AI surface (ChatGPT-User, …). */
|
|
22559
|
-
userFetchHits:
|
|
22560
|
-
referralArrivals:
|
|
22900
|
+
userFetchHits: z75.number(),
|
|
22901
|
+
referralArrivals: z75.number(),
|
|
22561
22902
|
deltaPct: percent().nullable()
|
|
22562
22903
|
})),
|
|
22563
22904
|
/**
|
|
22564
22905
|
* Top crawled paths during the selected period, with both verified and
|
|
22565
22906
|
* unverified crawler hits. These are request counts, not citation evidence.
|
|
22566
22907
|
*/
|
|
22567
|
-
topCrawledPaths:
|
|
22568
|
-
path:
|
|
22569
|
-
verifiedHits:
|
|
22908
|
+
topCrawledPaths: z75.array(z75.object({
|
|
22909
|
+
path: z75.string(),
|
|
22910
|
+
verifiedHits: z75.number(),
|
|
22570
22911
|
/**
|
|
22571
22912
|
* Hits from a crawler that identified itself but whose source IP could not
|
|
22572
22913
|
* be matched against the operator's published ranges. Additive, not an
|
|
@@ -22574,36 +22915,36 @@ var trafficActivitySummarySchema = z74.object({
|
|
|
22574
22915
|
* logs, for one), so for those projects every hit lands here and a
|
|
22575
22916
|
* verified-only view reports zero against real crawl activity.
|
|
22576
22917
|
*/
|
|
22577
|
-
unverifiedHits:
|
|
22918
|
+
unverifiedHits: z75.number().default(0),
|
|
22578
22919
|
/** How many distinct AI operators crawled this path in the window. */
|
|
22579
|
-
distinctOperators:
|
|
22920
|
+
distinctOperators: z75.number()
|
|
22580
22921
|
})),
|
|
22581
22922
|
/** AI products that sent ≥1 session in the window (referral by destination). */
|
|
22582
|
-
referralProducts:
|
|
22583
|
-
product:
|
|
22584
|
-
arrivals:
|
|
22585
|
-
distinctLandingPaths:
|
|
22923
|
+
referralProducts: z75.array(z75.object({
|
|
22924
|
+
product: z75.string(),
|
|
22925
|
+
arrivals: z75.number(),
|
|
22926
|
+
distinctLandingPaths: z75.number()
|
|
22586
22927
|
})),
|
|
22587
22928
|
/** Daily request counts during the selected period. */
|
|
22588
|
-
dailyTrend:
|
|
22589
|
-
date:
|
|
22590
|
-
verifiedCrawlerHits:
|
|
22929
|
+
dailyTrend: z75.array(z75.object({
|
|
22930
|
+
date: z75.string(),
|
|
22931
|
+
verifiedCrawlerHits: z75.number(),
|
|
22591
22932
|
/** See topCrawledPaths.unverifiedHits. Plotted alongside, never instead. */
|
|
22592
|
-
unverifiedCrawlerHits:
|
|
22593
|
-
userFetchHits:
|
|
22594
|
-
referralArrivals:
|
|
22933
|
+
unverifiedCrawlerHits: z75.number().default(0),
|
|
22934
|
+
userFetchHits: z75.number(),
|
|
22935
|
+
referralArrivals: z75.number()
|
|
22595
22936
|
})),
|
|
22596
22937
|
/**
|
|
22597
22938
|
* Top landing paths for AI-referral sessions during the selected period.
|
|
22598
22939
|
* Complements crawler paths with server-observed referral arrivals.
|
|
22599
22940
|
*/
|
|
22600
|
-
topReferralLandingPaths:
|
|
22601
|
-
path:
|
|
22602
|
-
arrivals:
|
|
22603
|
-
distinctProducts:
|
|
22941
|
+
topReferralLandingPaths: z75.array(z75.object({
|
|
22942
|
+
path: z75.string(),
|
|
22943
|
+
arrivals: z75.number(),
|
|
22944
|
+
distinctProducts: z75.number()
|
|
22604
22945
|
}))
|
|
22605
22946
|
});
|
|
22606
|
-
var trafficAnalyticsResponseSchema =
|
|
22947
|
+
var trafficAnalyticsResponseSchema = z75.object({
|
|
22607
22948
|
/** Null when no non-archived traffic source is connected. Connected sources without events return zero counts. */
|
|
22608
22949
|
activity: trafficActivitySummarySchema.nullable()
|
|
22609
22950
|
});
|
|
@@ -22651,6 +22992,7 @@ export {
|
|
|
22651
22992
|
RetrievalStatuses,
|
|
22652
22993
|
RetrievalContracts,
|
|
22653
22994
|
providerQuotaPolicySchema,
|
|
22995
|
+
PROVIDER_NAMES,
|
|
22654
22996
|
ProviderNames,
|
|
22655
22997
|
API_PROVIDER_NAMES,
|
|
22656
22998
|
isBrowserProvider,
|
|
@@ -23147,6 +23489,7 @@ export {
|
|
|
23147
23489
|
buildModelChangeNotice,
|
|
23148
23490
|
shareOf,
|
|
23149
23491
|
breakdownShares,
|
|
23492
|
+
median,
|
|
23150
23493
|
wilsonInterval,
|
|
23151
23494
|
linearTrend,
|
|
23152
23495
|
googleConnectionDtoSchema,
|
|
@@ -23621,6 +23964,22 @@ export {
|
|
|
23621
23964
|
AGENT_NONE,
|
|
23622
23965
|
normalizeAgentSlug,
|
|
23623
23966
|
detectAgentRuntime,
|
|
23967
|
+
outcomeSurfaceSchema,
|
|
23968
|
+
OutcomeSurfaces,
|
|
23969
|
+
INTEGRATION_NAMES,
|
|
23970
|
+
IntegrationNames,
|
|
23971
|
+
OutcomeStatuses,
|
|
23972
|
+
OutcomeTriggers,
|
|
23973
|
+
OutcomeReasonCodes,
|
|
23974
|
+
FeatureNames,
|
|
23975
|
+
bucketDuration,
|
|
23976
|
+
integrationConnectionPropertiesSchema,
|
|
23977
|
+
featureCompletedPropertiesSchema,
|
|
23978
|
+
normalizeInstallRef,
|
|
23979
|
+
installStatePropertiesSchema,
|
|
23980
|
+
statusClassOf,
|
|
23981
|
+
classifyOutcomeError,
|
|
23982
|
+
classifyProviderOutcomeError,
|
|
23624
23983
|
uiTelemetryEventSchema,
|
|
23625
23984
|
isSensitiveDiagnosticQueryKey,
|
|
23626
23985
|
redactLogValue,
|