@canonry/canonry 6.1.5 → 6.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/assets/agent-workspace/skills/canonry/references/canonry-cli.md +13 -1
  2. package/assets/assets/{AuditHistoryPanel-D-W_kwEY.js → AuditHistoryPanel-BUYWIjlG.js} +1 -1
  3. package/assets/assets/{BacklinksPage-BeqCFRO3.js → BacklinksPage-aBcxpN_9.js} +1 -1
  4. package/assets/assets/{HistoryPage-wAPbY0z4.js → HistoryPage-PoBuxiY_.js} +1 -1
  5. package/assets/assets/{MeasurementPropertyPage-BSOrkHCB.js → MeasurementPropertyPage-DyjyqHac.js} +1 -1
  6. package/assets/assets/{ProjectPage-v0C7CwyA.js → ProjectPage-Mmv5YW-K.js} +1 -1
  7. package/assets/assets/{RunsPage-CxolaIps.js → RunsPage-CHHxOpzo.js} +1 -1
  8. package/assets/assets/{SettingsPage-BQqJz0Ms.js → SettingsPage-CNKnrLXC.js} +1 -1
  9. package/assets/assets/{SiteHealthSection-C56kNcQQ.js → SiteHealthSection-C9RivT7G.js} +3 -3
  10. package/assets/assets/{TrafficPage-BDmWdYWf.js → TrafficPage-CY-ibXnb.js} +1 -1
  11. package/assets/assets/{TrafficSourceDetailPage-DZl3YNBs.js → TrafficSourceDetailPage-BgiPXubs.js} +1 -1
  12. package/assets/assets/{extract-error-message-D0mBVEGn.js → extract-error-message-H1dzzfBP.js} +1 -1
  13. package/assets/assets/{index-DZ__RzGa.js → index-DSCun3I9.js} +22 -22
  14. package/assets/assets/{react-sigma_core.esm.min-BQNp33-g.js → react-sigma_core.esm.min-uiYtR_DU.js} +1 -1
  15. package/assets/assets/{v2-overview-adapter-XZbD7swG.js → v2-overview-adapter-BQokN2eb.js} +1 -1
  16. package/assets/index.html +1 -1
  17. package/dist/{chunk-PAYC6TQ2.js → chunk-5GY5WBAF.js} +3 -3
  18. package/dist/{chunk-5QH72CTN.js → chunk-DERWXLHX.js} +15 -1
  19. package/dist/{chunk-J7LV4CS2.js → chunk-EV5G5QRR.js} +335 -280
  20. package/dist/{chunk-MSFBNFTI.js → chunk-FSRVG2H7.js} +2 -2
  21. package/dist/{chunk-4UEX44C3.js → chunk-OTROA7CN.js} +395 -173
  22. package/dist/{chunk-MTEVU6KG.js → chunk-QVGG76UW.js} +79 -24
  23. package/dist/{chunk-FRBKYQN7.js → chunk-ZZEPF3A5.js} +24 -4
  24. package/dist/cli.js +55 -10
  25. package/dist/{demo-server-UGILQVEC.js → demo-server-5MNLI6GC.js} +4 -4
  26. package/dist/index.js +6 -6
  27. package/dist/{intelligence-service-JYGP6LME.js → intelligence-service-5J36RBEM.js} +2 -2
  28. package/dist/mcp.js +4 -4
  29. package/package.json +11 -11
@@ -9775,14 +9775,14 @@ function breakdownShares(parts) {
9775
9775
  const total = parts.reduce((sum, part) => sum + Math.max(0, part), 0);
9776
9776
  return parts.map((part) => shareOf(part, total) ?? 0);
9777
9777
  }
9778
- function wilsonInterval(successes, n, z71 = 1.96) {
9778
+ function wilsonInterval(successes, n, z72 = 1.96) {
9779
9779
  if (!Number.isFinite(n) || n <= 0) return null;
9780
9780
  const s = Math.max(0, Math.min(successes, n));
9781
9781
  const p = s / n;
9782
- const z210 = z71 * z71;
9782
+ const z210 = z72 * z72;
9783
9783
  const denom = 1 + z210 / n;
9784
9784
  const center = (p + z210 / (2 * n)) / denom;
9785
- const margin = z71 / denom * Math.sqrt(p * (1 - p) / n + z210 / (4 * n * n));
9785
+ const margin = z72 / denom * Math.sqrt(p * (1 - p) / n + z210 / (4 * n * n));
9786
9786
  return {
9787
9787
  low: round(Math.max(0, center - margin)),
9788
9788
  high: round(Math.min(1, center + margin))
@@ -19859,6 +19859,7 @@ function serializeForInlineScript(value) {
19859
19859
  var PROVIDER_ERROR_PRIORITY = [
19860
19860
  "PROVIDER_AUTH",
19861
19861
  "RATE_LIMITED",
19862
+ "PROVIDER_UNAVAILABLE",
19862
19863
  "TIMEOUT",
19863
19864
  "NETWORK",
19864
19865
  "PARSE_ERROR",
@@ -19871,6 +19872,10 @@ function classifyProviderErrorMessage(message) {
19871
19872
  if (/\b429\b|rate[_ -]?limit|too many requests|quota[_ -]?exceeded/i.test(message)) {
19872
19873
  return "RATE_LIMITED";
19873
19874
  }
19875
+ const status = extractProviderHttpStatus(message);
19876
+ if (status !== void 0 && status >= 500 || /overloaded|service unavailable|bad gateway|internal server error/i.test(message)) {
19877
+ return "PROVIDER_UNAVAILABLE";
19878
+ }
19874
19879
  if (/timeout|timed out|ETIMEDOUT/i.test(message)) {
19875
19880
  return "TIMEOUT";
19876
19881
  }
@@ -19892,6 +19897,11 @@ function classifyProviderErrorMessages(messages) {
19892
19897
  }
19893
19898
  return "UNKNOWN";
19894
19899
  }
19900
+ function extractProviderHttpStatus(message) {
19901
+ const text = message.replace(/^(?:\[[^\]]+\]\s*)+/, "");
19902
+ const match = /^([1-5]\d\d)\b/.exec(text) ?? /\b(?:status(?: code)?|http)[:=]?\s*([1-5]\d\d)\b/i.exec(text) ?? /"(?:code|status)"\s*:\s*([1-5]\d\d)\b/.exec(text);
19903
+ return match ? Number(match[1]) : void 0;
19904
+ }
19895
19905
 
19896
19906
  // ../contracts/src/telemetry.ts
19897
19907
  import { z as z65 } from "zod";
@@ -20095,6 +20105,193 @@ function detectAgentRuntime(env) {
20095
20105
  return AGENT_NONE;
20096
20106
  }
20097
20107
 
20108
+ // ../contracts/src/feedback.ts
20109
+ import { z as z66 } from "zod";
20110
+
20111
+ // ../contracts/src/log-redaction.ts
20112
+ var REDACTED = "[REDACTED]";
20113
+ var TRUNCATED = "[TRUNCATED]";
20114
+ var CIRCULAR = "[CIRCULAR]";
20115
+ var UNREADABLE = "[UNREADABLE]";
20116
+ var OMITTED = "[OMITTED]";
20117
+ var MAX_DEPTH = 6;
20118
+ var MAX_ARRAY_ITEMS = 50;
20119
+ var MAX_OBJECT_KEYS = 100;
20120
+ var MAX_STRING_LENGTH = 4096;
20121
+ var secretKey = /api[ _-]?key|authorization|auth(?:entication)?|cookie|password|secret|token|credential/i;
20122
+ var escapedSecretAssignment = /\\+["'][\w -]*(?:api[ _-]?key|auth|cookie|password|secret|token|credential)[\w -]*\\+["']\s*:/i;
20123
+ var unsafeGraphKey = /^(?:req|res|request|reply|raw|socket|headers?|body|responsebody|apiresponse|rawresponse|providerbody|providerresponse)$/i;
20124
+ var providerNameKey = /^provider$/i;
20125
+ function isSensitiveDiagnosticQueryKey(key) {
20126
+ return secretKey.test(key) || /^key$/i.test(key);
20127
+ }
20128
+ function redactLogValue(value) {
20129
+ try {
20130
+ return redactValue(value, 0, /* @__PURE__ */ new WeakSet());
20131
+ } catch {
20132
+ return UNREADABLE;
20133
+ }
20134
+ }
20135
+ function redactLogString(value) {
20136
+ try {
20137
+ const clipped = value.length > MAX_STRING_LENGTH ? `${value.slice(0, MAX_STRING_LENGTH)}${TRUNCATED}` : value;
20138
+ if (escapedSecretAssignment.test(clipped)) return REDACTED;
20139
+ return redactEmbeddedUrls(clipped).replace(/\b((?:set-cookie|cookie)\s*[:=]\s*)[^\r\n]*(?:\r?\n[ \t][^\r\n]*)*/gi, `$1${REDACTED}`).replace(
20140
+ /(["']?[\w-]*(?:api[ _-]?key|auth|cookie|password|secret|token|credential)[\w-]*["']?\s*[=:]\s*)(?:"(?:\\.|[^"\\])*(?:"|$)|'(?:\\.|[^'\\])*(?:'|$))/gi,
20141
+ `$1${REDACTED}`
20142
+ ).replace(/\b(Bearer|Basic)\s+[^\s,;]+/gi, (_match, scheme) => `${scheme} ${REDACTED}`).replace(
20143
+ /(api[ _-]?key|authorization|auth(?:entication)?|cookie|password|secret|token|credential)\s*([=:])\s*(?!\[REDACTED\])[^\s&,'")\]}]+/gi,
20144
+ `$1$2${REDACTED}`
20145
+ ).slice(0, MAX_STRING_LENGTH);
20146
+ } catch {
20147
+ return UNREADABLE;
20148
+ }
20149
+ }
20150
+ function redactValue(value, depth, seen, key) {
20151
+ if (key && diagnosticIdentity(key, value) !== void 0) return value;
20152
+ if (key && secretKey.test(key)) return REDACTED;
20153
+ if (key && unsafeGraphKey.test(key)) return OMITTED;
20154
+ if (key && providerNameKey.test(key) && typeof value === "object" && value !== null) return OMITTED;
20155
+ if (value === null || typeof value === "boolean") return value;
20156
+ if (typeof value === "number") return Number.isFinite(value) ? value : String(value);
20157
+ if (typeof value === "string") return redactLogString(value);
20158
+ if (typeof value === "bigint") return value.toString();
20159
+ if (typeof value === "undefined") return void 0;
20160
+ if (typeof value === "symbol" || typeof value === "function") return `[${typeof value}]`;
20161
+ if (depth >= MAX_DEPTH) return TRUNCATED;
20162
+ if (typeof value !== "object") return UNREADABLE;
20163
+ if (seen.has(value)) return CIRCULAR;
20164
+ seen.add(value);
20165
+ try {
20166
+ if (value instanceof Error) return redactError(value, depth, seen);
20167
+ if (Array.isArray(value)) {
20168
+ const output2 = [];
20169
+ const length = safeArrayLength(value);
20170
+ for (let index = 0; index < Math.min(length, MAX_ARRAY_ITEMS); index++) {
20171
+ output2.push(redactValue(safeProperty(value, String(index)), depth + 1, seen));
20172
+ }
20173
+ if (length > MAX_ARRAY_ITEMS) output2.push(TRUNCATED);
20174
+ return output2;
20175
+ }
20176
+ const output = {};
20177
+ const keys = safeKeys(value);
20178
+ for (const nestedKey of keys.slice(0, MAX_OBJECT_KEYS)) {
20179
+ output[nestedKey] = redactValue(safeProperty(value, nestedKey), depth + 1, seen, nestedKey);
20180
+ }
20181
+ if (keys.length > MAX_OBJECT_KEYS) output.__truncated = true;
20182
+ return output;
20183
+ } catch {
20184
+ return UNREADABLE;
20185
+ } finally {
20186
+ seen.delete(value);
20187
+ }
20188
+ }
20189
+ function diagnosticIdentity(key, value) {
20190
+ if (typeof value !== "string") return void 0;
20191
+ if (key === "actor" && /^(?:api-key|user):[\w.-]{1,256}$/.test(value)) return value;
20192
+ if (key === "credentialId" && /^[\w.-]{1,256}$/.test(value)) return value;
20193
+ return void 0;
20194
+ }
20195
+ function redactError(error, depth, seen) {
20196
+ const output = {
20197
+ name: redactLogString(safeErrorString(error, "name")),
20198
+ message: redactLogString(safeErrorString(error, "message"))
20199
+ };
20200
+ const stack = safeErrorString(error, "stack");
20201
+ if (stack) output.stack = redactLogString(stack);
20202
+ for (const key of safeKeys(error).slice(0, MAX_OBJECT_KEYS)) {
20203
+ output[key] = redactValue(safeProperty(error, key), depth + 1, seen, key);
20204
+ }
20205
+ return output;
20206
+ }
20207
+ function safeKeys(value) {
20208
+ try {
20209
+ return Object.keys(value);
20210
+ } catch {
20211
+ return [];
20212
+ }
20213
+ }
20214
+ function safeArrayLength(value) {
20215
+ try {
20216
+ return Number.isSafeInteger(value.length) && value.length >= 0 ? value.length : 0;
20217
+ } catch {
20218
+ return 0;
20219
+ }
20220
+ }
20221
+ function safeProperty(value, key) {
20222
+ try {
20223
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
20224
+ if (!descriptor || !("value" in descriptor)) return UNREADABLE;
20225
+ return descriptor.value;
20226
+ } catch {
20227
+ return UNREADABLE;
20228
+ }
20229
+ }
20230
+ function safeErrorString(error, key) {
20231
+ try {
20232
+ const value = error[key];
20233
+ return typeof value === "string" ? value : "";
20234
+ } catch {
20235
+ return UNREADABLE;
20236
+ }
20237
+ }
20238
+ function redactEmbeddedUrls(value) {
20239
+ return value.replace(/https?:\/\/[^\s<>"']+/gi, (candidate) => {
20240
+ if (candidate.includes(TRUNCATED)) return "[TRUNCATED_URL]";
20241
+ const suffix = candidate.match(/[),.;!?\]}]+$/)?.[0] ?? "";
20242
+ const rawUrl = suffix ? candidate.slice(0, -suffix.length) : candidate;
20243
+ try {
20244
+ const url = new URL(rawUrl);
20245
+ if (url.username || url.password) {
20246
+ url.username = REDACTED;
20247
+ url.password = REDACTED;
20248
+ }
20249
+ for (const key of [...url.searchParams.keys()]) {
20250
+ if (isSensitiveDiagnosticQueryKey(key)) url.searchParams.set(key, REDACTED);
20251
+ }
20252
+ return `${url.toString()}${suffix}`;
20253
+ } catch {
20254
+ return `[REDACTED_URL]${suffix}`;
20255
+ }
20256
+ });
20257
+ }
20258
+
20259
+ // ../contracts/src/feedback.ts
20260
+ var FEEDBACK_KINDS = ["struggle", "bug", "improvement", "other"];
20261
+ var feedbackKindSchema = z66.enum(FEEDBACK_KINDS);
20262
+ var FEEDBACK_LIMITS = {
20263
+ summary: 500,
20264
+ details: 4e3,
20265
+ area: 40,
20266
+ command: 120,
20267
+ errorCode: 40
20268
+ };
20269
+ var feedbackSubmissionSchema = z66.object({
20270
+ kind: feedbackKindSchema,
20271
+ summary: z66.string().trim().min(1).max(FEEDBACK_LIMITS.summary),
20272
+ details: z66.string().trim().min(1).max(FEEDBACK_LIMITS.details).optional(),
20273
+ area: z66.string().trim().min(1).max(FEEDBACK_LIMITS.area).optional(),
20274
+ command: z66.string().trim().min(1).max(FEEDBACK_LIMITS.command).optional(),
20275
+ errorCode: z66.string().trim().min(1).max(FEEDBACK_LIMITS.errorCode).optional()
20276
+ }).strict();
20277
+ var feedbackAcceptedDtoSchema = z66.object({
20278
+ accepted: z66.boolean(),
20279
+ id: z66.string()
20280
+ });
20281
+ function redactFeedbackText(value, limit) {
20282
+ return truncateUtf16(
20283
+ redactLogString(value).replace(SECRET_FLAG_VALUE, "$1 [REDACTED]").replace(BARE_CREDENTIAL, "[REDACTED]"),
20284
+ limit
20285
+ );
20286
+ }
20287
+ function truncateUtf16(value, limit) {
20288
+ if (value.length <= limit) return value;
20289
+ const cut = value.slice(0, limit);
20290
+ return /[\uD800-\uDBFF]$/.test(cut) ? cut.slice(0, -1) : cut;
20291
+ }
20292
+ var SECRET_FLAG_VALUE = /(?<=^|[ \t])(--?(?:[a-z\d]+-)*(?:key|token|secret|password|passwd|credential|credentials|auth|authorization|bearer)(?:-[a-z\d]+)*)(?:[ \t]*=[ \t]*|[ \t]+)(?!\[REDACTED\])(?:"[^"\n]*"|'[^'\n]*'|\S+)/gim;
20293
+ 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;
20294
+
20098
20295
  // ../contracts/src/trend-stability.ts
20099
20296
  var MIN_TREND_POINTS = 4;
20100
20297
  function isTrendBaseline(points) {
@@ -20102,14 +20299,14 @@ function isTrendBaseline(points) {
20102
20299
  }
20103
20300
 
20104
20301
  // ../contracts/src/report-sections.ts
20105
- import { z as z66 } from "zod";
20302
+ import { z as z67 } from "zod";
20106
20303
  var CLIENT_AUDIENCE = reportAudienceSchema.enum.client;
20107
20304
  var BOTH_AUDIENCES = reportActionAudienceSchema.enum.both;
20108
20305
  var ADVANCED_MODE = visibilityReportResolvedModeSchema.enum.advanced;
20109
20306
  function pluralize(count2, singular, plural = `${singular}s`) {
20110
20307
  return count2 === 1 ? singular : plural;
20111
20308
  }
20112
- var reportSectionIdSchema = z66.enum([
20309
+ var reportSectionIdSchema = z67.enum([
20113
20310
  "client-summary",
20114
20311
  "executive-summary",
20115
20312
  "share-of-voice",
@@ -20832,240 +21029,92 @@ var REPORT_SECTION_COPY = {
20832
21029
  };
20833
21030
 
20834
21031
  // ../contracts/src/operational-logs.ts
20835
- import { z as z67 } from "zod";
20836
- var operationalLogLevelSchema = z67.enum(["trace", "debug", "info", "warn", "error", "fatal"]);
20837
- var diagnosticContextSchema = z67.object({
20838
- runId: z67.string().min(1).max(256).optional(),
20839
- projectId: z67.string().min(1).max(256).optional(),
20840
- requestId: z67.string().min(1).max(256).optional(),
20841
- actor: z67.string().min(1).max(512).optional(),
20842
- credentialId: z67.string().min(1).max(512).optional(),
20843
- userAgent: z67.string().min(1).max(512).optional(),
20844
- actorSession: z67.string().min(1).max(512).optional(),
20845
- method: z67.string().min(1).max(16).optional(),
20846
- route: z67.string().min(1).max(256).optional(),
20847
- operationId: z67.string().min(1).max(256).optional(),
20848
- jobId: z67.string().min(1).max(256).optional(),
20849
- taskId: z67.string().min(1).max(256).optional(),
20850
- traceId: z67.string().min(1).max(256).optional(),
20851
- provider: z67.string().min(1).max(256).optional(),
20852
- errorCode: z67.string().min(1).max(128).optional(),
20853
- attempt: z67.number().finite().optional(),
20854
- count: z67.number().finite().optional(),
20855
- total: z67.number().finite().optional(),
20856
- progress: z67.number().finite().optional(),
20857
- httpStatus: z67.number().finite().optional(),
20858
- statusCode: z67.number().finite().optional(),
20859
- durationMs: z67.number().finite().optional(),
20860
- bytes: z67.number().finite().optional(),
20861
- retryAfterMs: z67.number().finite().optional(),
20862
- retriable: z67.boolean().optional(),
20863
- retrying: z67.boolean().optional(),
20864
- cancelled: z67.boolean().optional(),
20865
- success: z67.boolean().optional()
20866
- }).strict();
20867
- var operationalLogEntryDtoSchema = z67.object({
20868
- cursor: z67.string().min(1).max(512),
20869
- ts: z67.string().datetime(),
21032
+ import { z as z68 } from "zod";
21033
+ var operationalLogLevelSchema = z68.enum(["trace", "debug", "info", "warn", "error", "fatal"]);
21034
+ var diagnosticContextSchema = z68.object({
21035
+ runId: z68.string().min(1).max(256).optional(),
21036
+ projectId: z68.string().min(1).max(256).optional(),
21037
+ requestId: z68.string().min(1).max(256).optional(),
21038
+ actor: z68.string().min(1).max(512).optional(),
21039
+ credentialId: z68.string().min(1).max(512).optional(),
21040
+ userAgent: z68.string().min(1).max(512).optional(),
21041
+ actorSession: z68.string().min(1).max(512).optional(),
21042
+ method: z68.string().min(1).max(16).optional(),
21043
+ route: z68.string().min(1).max(256).optional(),
21044
+ operationId: z68.string().min(1).max(256).optional(),
21045
+ jobId: z68.string().min(1).max(256).optional(),
21046
+ taskId: z68.string().min(1).max(256).optional(),
21047
+ traceId: z68.string().min(1).max(256).optional(),
21048
+ provider: z68.string().min(1).max(256).optional(),
21049
+ errorCode: z68.string().min(1).max(128).optional(),
21050
+ attempt: z68.number().finite().optional(),
21051
+ count: z68.number().finite().optional(),
21052
+ total: z68.number().finite().optional(),
21053
+ progress: z68.number().finite().optional(),
21054
+ httpStatus: z68.number().finite().optional(),
21055
+ statusCode: z68.number().finite().optional(),
21056
+ durationMs: z68.number().finite().optional(),
21057
+ bytes: z68.number().finite().optional(),
21058
+ retryAfterMs: z68.number().finite().optional(),
21059
+ retriable: z68.boolean().optional(),
21060
+ retrying: z68.boolean().optional(),
21061
+ cancelled: z68.boolean().optional(),
21062
+ success: z68.boolean().optional()
21063
+ }).strict();
21064
+ var operationalLogEntryDtoSchema = z68.object({
21065
+ cursor: z68.string().min(1).max(512),
21066
+ ts: z68.string().datetime(),
20870
21067
  level: operationalLogLevelSchema,
20871
- module: z67.string().min(1).max(256),
20872
- action: z67.string().min(1).max(256),
20873
- message: z67.string().max(4096).optional(),
20874
- runId: z67.string().min(1).max(256).optional(),
20875
- projectId: z67.string().min(1).max(256).optional(),
21068
+ module: z68.string().min(1).max(256),
21069
+ action: z68.string().min(1).max(256),
21070
+ message: z68.string().max(4096).optional(),
21071
+ runId: z68.string().min(1).max(256).optional(),
21072
+ projectId: z68.string().min(1).max(256).optional(),
20876
21073
  context: diagnosticContextSchema
20877
21074
  }).strict();
20878
- var logQuerySchema = z67.object({
21075
+ var logQuerySchema = z68.object({
20879
21076
  level: operationalLogLevelSchema.optional(),
20880
- module: z67.string().trim().min(1).max(256).optional(),
20881
- runId: z67.string().trim().min(1).max(256).optional(),
20882
- projectId: z67.string().trim().min(1).max(256).optional(),
20883
- actor: z67.string().trim().min(1).max(512).optional(),
20884
- requestId: z67.string().trim().min(1).max(256).optional(),
20885
- since: z67.string().datetime().optional(),
20886
- until: z67.string().datetime().optional(),
20887
- limit: z67.coerce.number().int().min(1).max(200).default(100),
20888
- cursor: z67.string().trim().min(1).max(512).optional()
21077
+ module: z68.string().trim().min(1).max(256).optional(),
21078
+ runId: z68.string().trim().min(1).max(256).optional(),
21079
+ projectId: z68.string().trim().min(1).max(256).optional(),
21080
+ actor: z68.string().trim().min(1).max(512).optional(),
21081
+ requestId: z68.string().trim().min(1).max(256).optional(),
21082
+ since: z68.string().datetime().optional(),
21083
+ until: z68.string().datetime().optional(),
21084
+ limit: z68.coerce.number().int().min(1).max(200).default(100),
21085
+ cursor: z68.string().trim().min(1).max(512).optional()
20889
21086
  }).strict().superRefine((query, ctx) => {
20890
21087
  if (query.since && query.until && Date.parse(query.since) > Date.parse(query.until)) {
20891
- ctx.addIssue({ code: z67.ZodIssueCode.custom, path: ["until"], message: '"until" must be on or after "since".' });
21088
+ ctx.addIssue({ code: z68.ZodIssueCode.custom, path: ["until"], message: '"until" must be on or after "since".' });
20892
21089
  }
20893
21090
  });
20894
- var retentionPolicySchema = z67.object({
20895
- maxEntries: z67.number().int().positive(),
20896
- maxAgeSeconds: z67.number().int().positive()
21091
+ var retentionPolicySchema = z68.object({
21092
+ maxEntries: z68.number().int().positive(),
21093
+ maxAgeSeconds: z68.number().int().positive()
20897
21094
  }).strict();
20898
- var operationalLogListDtoSchema = z67.object({
20899
- entries: z67.array(operationalLogEntryDtoSchema),
20900
- nextCursor: z67.string().min(1).max(512).nullable(),
21095
+ var operationalLogListDtoSchema = z68.object({
21096
+ entries: z68.array(operationalLogEntryDtoSchema),
21097
+ nextCursor: z68.string().min(1).max(512).nullable(),
20901
21098
  /** Matching entries left after this page. */
20902
- truncated: z67.number().int().nonnegative(),
21099
+ truncated: z68.number().int().nonnegative(),
20903
21100
  /** Entries evicted by the active retention policy. */
20904
- dropped: z67.number().int().nonnegative(),
20905
- retention: z67.enum(["process", "durable"]),
21101
+ dropped: z68.number().int().nonnegative(),
21102
+ retention: z68.enum(["process", "durable"]),
20906
21103
  retentionPolicy: retentionPolicySchema.optional(),
20907
21104
  /** Best-effort persistence failures observed by this store. */
20908
- captureErrors: z67.number().int().nonnegative().optional(),
20909
- observedAt: z67.string().datetime()
21105
+ captureErrors: z68.number().int().nonnegative().optional(),
21106
+ observedAt: z68.string().datetime()
20910
21107
  }).strict();
20911
21108
  var OPERATIONAL_LOG_FIELDS_HEADER = "x-canonry-log-fields";
20912
21109
  var OPERATIONAL_LOG_OPT_IN_CONTEXT_FIELDS = ["provider"];
20913
- var diagnosticContextReadSchema = z67.object(diagnosticContextSchema.shape);
20914
- var operationalLogEntryReadSchema = z67.object({ ...operationalLogEntryDtoSchema.shape, context: diagnosticContextReadSchema });
20915
- var operationalLogListReadSchema = z67.object({
21110
+ var diagnosticContextReadSchema = z68.object(diagnosticContextSchema.shape);
21111
+ var operationalLogEntryReadSchema = z68.object({ ...operationalLogEntryDtoSchema.shape, context: diagnosticContextReadSchema });
21112
+ var operationalLogListReadSchema = z68.object({
20916
21113
  ...operationalLogListDtoSchema.shape,
20917
- entries: z67.array(operationalLogEntryReadSchema),
20918
- retentionPolicy: z67.object(retentionPolicySchema.shape).optional()
21114
+ entries: z68.array(operationalLogEntryReadSchema),
21115
+ retentionPolicy: z68.object(retentionPolicySchema.shape).optional()
20919
21116
  });
20920
21117
 
20921
- // ../contracts/src/log-redaction.ts
20922
- var REDACTED = "[REDACTED]";
20923
- var TRUNCATED = "[TRUNCATED]";
20924
- var CIRCULAR = "[CIRCULAR]";
20925
- var UNREADABLE = "[UNREADABLE]";
20926
- var OMITTED = "[OMITTED]";
20927
- var MAX_DEPTH = 6;
20928
- var MAX_ARRAY_ITEMS = 50;
20929
- var MAX_OBJECT_KEYS = 100;
20930
- var MAX_STRING_LENGTH = 4096;
20931
- var secretKey = /api[ _-]?key|authorization|auth(?:entication)?|cookie|password|secret|token|credential/i;
20932
- var escapedSecretAssignment = /\\+["'][\w -]*(?:api[ _-]?key|auth|cookie|password|secret|token|credential)[\w -]*\\+["']\s*:/i;
20933
- var unsafeGraphKey = /^(?:req|res|request|reply|raw|socket|headers?|body|responsebody|apiresponse|rawresponse|providerbody|providerresponse)$/i;
20934
- var providerNameKey = /^provider$/i;
20935
- function isSensitiveDiagnosticQueryKey(key) {
20936
- return secretKey.test(key) || /^key$/i.test(key);
20937
- }
20938
- function redactLogValue(value) {
20939
- try {
20940
- return redactValue(value, 0, /* @__PURE__ */ new WeakSet());
20941
- } catch {
20942
- return UNREADABLE;
20943
- }
20944
- }
20945
- function redactLogString(value) {
20946
- try {
20947
- const clipped = value.length > MAX_STRING_LENGTH ? `${value.slice(0, MAX_STRING_LENGTH)}${TRUNCATED}` : value;
20948
- if (escapedSecretAssignment.test(clipped)) return REDACTED;
20949
- return redactEmbeddedUrls(clipped).replace(/\b((?:set-cookie|cookie)\s*[:=]\s*)[^\r\n]*(?:\r?\n[ \t][^\r\n]*)*/gi, `$1${REDACTED}`).replace(
20950
- /(["']?[\w-]*(?:api[ _-]?key|auth|cookie|password|secret|token|credential)[\w-]*["']?\s*[=:]\s*)(?:"(?:\\.|[^"\\])*(?:"|$)|'(?:\\.|[^'\\])*(?:'|$))/gi,
20951
- `$1${REDACTED}`
20952
- ).replace(/\b(Bearer|Basic)\s+[^\s,;]+/gi, (_match, scheme) => `${scheme} ${REDACTED}`).replace(
20953
- /(api[ _-]?key|authorization|auth(?:entication)?|cookie|password|secret|token|credential)\s*([=:])\s*(?!\[REDACTED\])[^\s&,'")\]}]+/gi,
20954
- `$1$2${REDACTED}`
20955
- ).slice(0, MAX_STRING_LENGTH);
20956
- } catch {
20957
- return UNREADABLE;
20958
- }
20959
- }
20960
- function redactValue(value, depth, seen, key) {
20961
- if (key && diagnosticIdentity(key, value) !== void 0) return value;
20962
- if (key && secretKey.test(key)) return REDACTED;
20963
- if (key && unsafeGraphKey.test(key)) return OMITTED;
20964
- if (key && providerNameKey.test(key) && typeof value === "object" && value !== null) return OMITTED;
20965
- if (value === null || typeof value === "boolean") return value;
20966
- if (typeof value === "number") return Number.isFinite(value) ? value : String(value);
20967
- if (typeof value === "string") return redactLogString(value);
20968
- if (typeof value === "bigint") return value.toString();
20969
- if (typeof value === "undefined") return void 0;
20970
- if (typeof value === "symbol" || typeof value === "function") return `[${typeof value}]`;
20971
- if (depth >= MAX_DEPTH) return TRUNCATED;
20972
- if (typeof value !== "object") return UNREADABLE;
20973
- if (seen.has(value)) return CIRCULAR;
20974
- seen.add(value);
20975
- try {
20976
- if (value instanceof Error) return redactError(value, depth, seen);
20977
- if (Array.isArray(value)) {
20978
- const output2 = [];
20979
- const length = safeArrayLength(value);
20980
- for (let index = 0; index < Math.min(length, MAX_ARRAY_ITEMS); index++) {
20981
- output2.push(redactValue(safeProperty(value, String(index)), depth + 1, seen));
20982
- }
20983
- if (length > MAX_ARRAY_ITEMS) output2.push(TRUNCATED);
20984
- return output2;
20985
- }
20986
- const output = {};
20987
- const keys = safeKeys(value);
20988
- for (const nestedKey of keys.slice(0, MAX_OBJECT_KEYS)) {
20989
- output[nestedKey] = redactValue(safeProperty(value, nestedKey), depth + 1, seen, nestedKey);
20990
- }
20991
- if (keys.length > MAX_OBJECT_KEYS) output.__truncated = true;
20992
- return output;
20993
- } catch {
20994
- return UNREADABLE;
20995
- } finally {
20996
- seen.delete(value);
20997
- }
20998
- }
20999
- function diagnosticIdentity(key, value) {
21000
- if (typeof value !== "string") return void 0;
21001
- if (key === "actor" && /^(?:api-key|user):[\w.-]{1,256}$/.test(value)) return value;
21002
- if (key === "credentialId" && /^[\w.-]{1,256}$/.test(value)) return value;
21003
- return void 0;
21004
- }
21005
- function redactError(error, depth, seen) {
21006
- const output = {
21007
- name: redactLogString(safeErrorString(error, "name")),
21008
- message: redactLogString(safeErrorString(error, "message"))
21009
- };
21010
- const stack = safeErrorString(error, "stack");
21011
- if (stack) output.stack = redactLogString(stack);
21012
- for (const key of safeKeys(error).slice(0, MAX_OBJECT_KEYS)) {
21013
- output[key] = redactValue(safeProperty(error, key), depth + 1, seen, key);
21014
- }
21015
- return output;
21016
- }
21017
- function safeKeys(value) {
21018
- try {
21019
- return Object.keys(value);
21020
- } catch {
21021
- return [];
21022
- }
21023
- }
21024
- function safeArrayLength(value) {
21025
- try {
21026
- return Number.isSafeInteger(value.length) && value.length >= 0 ? value.length : 0;
21027
- } catch {
21028
- return 0;
21029
- }
21030
- }
21031
- function safeProperty(value, key) {
21032
- try {
21033
- const descriptor = Object.getOwnPropertyDescriptor(value, key);
21034
- if (!descriptor || !("value" in descriptor)) return UNREADABLE;
21035
- return descriptor.value;
21036
- } catch {
21037
- return UNREADABLE;
21038
- }
21039
- }
21040
- function safeErrorString(error, key) {
21041
- try {
21042
- const value = error[key];
21043
- return typeof value === "string" ? value : "";
21044
- } catch {
21045
- return UNREADABLE;
21046
- }
21047
- }
21048
- function redactEmbeddedUrls(value) {
21049
- return value.replace(/https?:\/\/[^\s<>"']+/gi, (candidate) => {
21050
- if (candidate.includes(TRUNCATED)) return "[TRUNCATED_URL]";
21051
- const suffix = candidate.match(/[),.;!?\]}]+$/)?.[0] ?? "";
21052
- const rawUrl = suffix ? candidate.slice(0, -suffix.length) : candidate;
21053
- try {
21054
- const url = new URL(rawUrl);
21055
- if (url.username || url.password) {
21056
- url.username = REDACTED;
21057
- url.password = REDACTED;
21058
- }
21059
- for (const key of [...url.searchParams.keys()]) {
21060
- if (isSensitiveDiagnosticQueryKey(key)) url.searchParams.set(key, REDACTED);
21061
- }
21062
- return `${url.toString()}${suffix}`;
21063
- } catch {
21064
- return `[REDACTED_URL]${suffix}`;
21065
- }
21066
- });
21067
- }
21068
-
21069
21118
  // ../contracts/src/semver.ts
21070
21119
  var STRICT_SEMVER = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?$/i;
21071
21120
  var MAX_SEMVER_LENGTH = 128;
@@ -21129,38 +21178,38 @@ function asRecord(value) {
21129
21178
  }
21130
21179
 
21131
21180
  // ../contracts/src/referral-assessment.ts
21132
- import { z as z68 } from "zod";
21133
- var referralAssessmentQuerySchema = z68.object({
21181
+ import { z as z69 } from "zod";
21182
+ var referralAssessmentQuerySchema = z69.object({
21134
21183
  startDate: calendarDateSchema,
21135
21184
  endDate: calendarDateSchema,
21136
- sourceId: z68.string().trim().min(1).optional(),
21137
- burstThreshold: z68.number().int().min(1).max(1e6).optional(),
21138
- ratioThreshold: z68.number().min(1).max(1e3).optional(),
21139
- limit: z68.number().int().min(1).max(500).optional()
21140
- }).strict();
21141
- var countsSchema = z68.object({
21142
- total: z68.number().int().nonnegative(),
21143
- paid: z68.number().int().nonnegative(),
21144
- organic: z68.number().int().nonnegative(),
21145
- unknown: z68.number().int().nonnegative()
21146
- });
21147
- var referralAssessmentSchema = z68.object({
21148
- scope: z68.object({
21149
- project: z68.string(),
21150
- sourceId: z68.string().nullable(),
21151
- attribution: z68.literal("project-source-only"),
21152
- unavailableDimensions: z68.array(z68.enum(["property", "target", "market"]))
21185
+ sourceId: z69.string().trim().min(1).optional(),
21186
+ burstThreshold: z69.number().int().min(1).max(1e6).optional(),
21187
+ ratioThreshold: z69.number().min(1).max(1e3).optional(),
21188
+ limit: z69.number().int().min(1).max(500).optional()
21189
+ }).strict();
21190
+ var countsSchema = z69.object({
21191
+ total: z69.number().int().nonnegative(),
21192
+ paid: z69.number().int().nonnegative(),
21193
+ organic: z69.number().int().nonnegative(),
21194
+ unknown: z69.number().int().nonnegative()
21195
+ });
21196
+ var referralAssessmentSchema = z69.object({
21197
+ scope: z69.object({
21198
+ project: z69.string(),
21199
+ sourceId: z69.string().nullable(),
21200
+ attribution: z69.literal("project-source-only"),
21201
+ unavailableDimensions: z69.array(z69.enum(["property", "target", "market"]))
21153
21202
  }),
21154
- window: z68.object({ startDate: calendarDateSchema, endDate: calendarDateSchema, timeZone: z68.literal("UTC") }),
21155
- rule: z68.object({
21156
- version: z68.literal("hourly-normalized-path-v1"),
21157
- burstThreshold: z68.number().int().positive(),
21158
- ratioThreshold: z68.number().positive(),
21159
- calibration: z68.enum(["uncalibrated-default", "request-override"]),
21160
- grouping: z68.array(z68.string()),
21161
- confirmsAutomation: z68.literal(false)
21203
+ window: z69.object({ startDate: calendarDateSchema, endDate: calendarDateSchema, timeZone: z69.literal("UTC") }),
21204
+ rule: z69.object({
21205
+ version: z69.literal("hourly-normalized-path-v1"),
21206
+ burstThreshold: z69.number().int().positive(),
21207
+ ratioThreshold: z69.number().positive(),
21208
+ calibration: z69.enum(["uncalibrated-default", "request-override"]),
21209
+ grouping: z69.array(z69.string()),
21210
+ confirmsAutomation: z69.literal(false)
21162
21211
  }),
21163
- totals: z68.object({
21212
+ totals: z69.object({
21164
21213
  raw: countsSchema,
21165
21214
  redirects: countsSchema,
21166
21215
  subresources: countsSchema,
@@ -21168,42 +21217,42 @@ var referralAssessmentSchema = z68.object({
21168
21217
  suspected: countsSchema,
21169
21218
  adjustedEstimate: countsSchema
21170
21219
  }),
21171
- bursts: z68.array(z68.object({
21172
- sourceId: z68.string(),
21173
- product: z68.string(),
21174
- landingPathNormalized: z68.string(),
21175
- tsHour: z68.string(),
21220
+ bursts: z69.array(z69.object({
21221
+ sourceId: z69.string(),
21222
+ product: z69.string(),
21223
+ landingPathNormalized: z69.string(),
21224
+ tsHour: z69.string(),
21176
21225
  counts: countsSchema
21177
21226
  })),
21178
- evidence: z68.object({ total: z68.number().int().nonnegative(), returned: z68.number().int().nonnegative(), truncated: z68.boolean() }),
21179
- comparison: z68.object({
21180
- status: z68.literal("unavailable"),
21181
- serverCountable: z68.number().int().nonnegative(),
21182
- serverObservation: z68.enum(["missing", "observed-zero", "observed-positive"]),
21227
+ evidence: z69.object({ total: z69.number().int().nonnegative(), returned: z69.number().int().nonnegative(), truncated: z69.boolean() }),
21228
+ comparison: z69.object({
21229
+ status: z69.literal("unavailable"),
21230
+ serverCountable: z69.number().int().nonnegative(),
21231
+ serverObservation: z69.enum(["missing", "observed-zero", "observed-positive"]),
21183
21232
  /**
21184
21233
  * Dimension-deduplicated GA AI sessions. With no stored AI row in the
21185
21234
  * window: `0` (`observed-zero`) when the latest GA sync queried the whole
21186
21235
  * window (GA4 omits zero rows), else `null` (`missing`).
21187
21236
  */
21188
- gaSessions: z68.number().int().nonnegative().nullable(),
21189
- gaObservation: z68.enum(["missing", "observed-zero", "observed-positive"]),
21237
+ gaSessions: z69.number().int().nonnegative().nullable(),
21238
+ gaObservation: z69.enum(["missing", "observed-zero", "observed-positive"]),
21190
21239
  /**
21191
21240
  * Descriptive quotient only (`serverCountable / gaSessions`, a multiplier
21192
21241
  * where 3 is three times as many, never a percent), rounded to 2
21193
21242
  * decimals. Not a matched, coverage-complete comparison.
21194
21243
  */
21195
- observedRatio: z68.number().nonnegative().nullable(),
21244
+ observedRatio: z69.number().nonnegative().nullable(),
21196
21245
  /** Compares the rounded `observedRatio` with `rule.ratioThreshold`. */
21197
- observedRatioAboveThreshold: z68.boolean().nullable(),
21198
- ratio: z68.null(),
21199
- reasons: z68.array(z68.string()),
21200
- gaScope: z68.literal("project")
21246
+ observedRatioAboveThreshold: z69.boolean().nullable(),
21247
+ ratio: z69.null(),
21248
+ reasons: z69.array(z69.string()),
21249
+ gaScope: z69.literal("project")
21201
21250
  }),
21202
- caveats: z68.array(z68.string())
21251
+ caveats: z69.array(z69.string())
21203
21252
  });
21204
21253
 
21205
21254
  // ../contracts/src/tolerant-read.ts
21206
- import { z as z69 } from "zod";
21255
+ import { z as z70 } from "zod";
21207
21256
  var WRAPPER_TYPES = /* @__PURE__ */ new Set(["optional", "nullable", "default", "prefault", "readonly", "catch", "nonoptional"]);
21208
21257
  var DEPTH_LIMIT = 64;
21209
21258
  function defOf(schema) {
@@ -21214,9 +21263,9 @@ function cloneWith(schema, changes) {
21214
21263
  }
21215
21264
  function openPrimitive(values) {
21216
21265
  if (values.length === 0) return void 0;
21217
- if (values.every((value) => typeof value === "string")) return z69.string();
21218
- if (values.every((value) => typeof value === "number")) return z69.number();
21219
- if (values.every((value) => typeof value === "boolean")) return z69.boolean();
21266
+ if (values.every((value) => typeof value === "string")) return z70.string();
21267
+ if (values.every((value) => typeof value === "number")) return z70.number();
21268
+ if (values.every((value) => typeof value === "boolean")) return z70.boolean();
21220
21269
  return void 0;
21221
21270
  }
21222
21271
  function walk2(schema, open, memo, depth) {
@@ -21230,7 +21279,7 @@ function walk2(schema, open, memo, depth) {
21230
21279
  const shape = Object.fromEntries(Object.entries(schema.shape).map(([key, child]) => [key, next(child)]));
21231
21280
  const declared = def.catchall;
21232
21281
  const catchall = open.get(schema) ?? (declared && defOf(declared).type !== "never" ? next(declared) : void 0);
21233
- result = catchall ? z69.object(shape).catchall(catchall) : z69.object(shape);
21282
+ result = catchall ? z70.object(shape).catchall(catchall) : z70.object(shape);
21234
21283
  } else if (WRAPPER_TYPES.has(def.type)) {
21235
21284
  const inner = def.innerType;
21236
21285
  const mapped = next(inner);
@@ -21247,10 +21296,10 @@ function walk2(schema, open, memo, depth) {
21247
21296
  const options = def.options;
21248
21297
  const mapped = options.map(next);
21249
21298
  const changed = mapped.some((option, index) => option !== options[index]);
21250
- result = !changed ? schema : def.discriminator ? z69.union(mapped) : cloneWith(schema, { options: mapped });
21299
+ result = !changed ? schema : def.discriminator ? z70.union(mapped) : cloneWith(schema, { options: mapped });
21251
21300
  } else if (def.type === "record") {
21252
21301
  const keyType = def.keyType, valueType = def.valueType;
21253
- const mappedKey = defOf(keyType).type === "enum" ? z69.string() : keyType;
21302
+ const mappedKey = defOf(keyType).type === "enum" ? z70.string() : keyType;
21254
21303
  const mappedValue = next(valueType);
21255
21304
  result = mappedKey === keyType && mappedValue === valueType ? schema : cloneWith(schema, { keyType: mappedKey, valueType: mappedValue });
21256
21305
  } else if (def.type === "intersection") {
@@ -21266,7 +21315,7 @@ function walk2(schema, open, memo, depth) {
21266
21315
  result = changed ? cloneWith(schema, { items: mappedItems, rest: mappedRest }) : schema;
21267
21316
  } else if (def.type === "lazy") {
21268
21317
  const getter = def.getter;
21269
- result = z69.lazy(() => next(getter()));
21318
+ result = z70.lazy(() => next(getter()));
21270
21319
  } else if (def.type === "enum") {
21271
21320
  result = openPrimitive(Object.values(def.entries)) ?? schema;
21272
21321
  } else if (def.type === "literal") {
@@ -21281,8 +21330,8 @@ function tolerantReadSchema(schema, options = {}) {
21281
21330
  }
21282
21331
 
21283
21332
  // ../contracts/src/sentiment-read.ts
21284
- import { z as z70 } from "zod";
21285
- var OPEN_COUNTS = { openKeys: [[sentimentCountsSchema, z70.number().int().nonnegative()]] };
21333
+ import { z as z71 } from "zod";
21334
+ var OPEN_COUNTS = { openKeys: [[sentimentCountsSchema, z71.number().int().nonnegative()]] };
21286
21335
  var sentimentSettingsReadSchema = tolerantReadSchema(sentimentSettingsSchema, OPEN_COUNTS);
21287
21336
  var sentimentSummaryReadSchema = tolerantReadSchema(sentimentSummarySchema, OPEN_COUNTS);
21288
21337
  var sentimentEvidencePageReadSchema = tolerantReadSchema(sentimentEvidencePageSchema, OPEN_COUNTS);
@@ -22203,6 +22252,7 @@ export {
22203
22252
  serializeForInlineScript,
22204
22253
  classifyProviderErrorMessage,
22205
22254
  classifyProviderErrorMessages,
22255
+ extractProviderHttpStatus,
22206
22256
  telemetryStatusDtoSchema,
22207
22257
  normalizeTelemetryStatus,
22208
22258
  maskTelemetryAnonymousId,
@@ -22217,6 +22267,15 @@ export {
22217
22267
  AGENT_NONE,
22218
22268
  normalizeAgentSlug,
22219
22269
  detectAgentRuntime,
22270
+ isSensitiveDiagnosticQueryKey,
22271
+ redactLogValue,
22272
+ redactLogString,
22273
+ diagnosticIdentity,
22274
+ FEEDBACK_KINDS,
22275
+ FEEDBACK_LIMITS,
22276
+ feedbackSubmissionSchema,
22277
+ feedbackAcceptedDtoSchema,
22278
+ redactFeedbackText,
22220
22279
  MIN_TREND_POINTS,
22221
22280
  isTrendBaseline,
22222
22281
  ReportSectionIds,
@@ -22284,10 +22343,6 @@ export {
22284
22343
  OPERATIONAL_LOG_FIELDS_HEADER,
22285
22344
  OPERATIONAL_LOG_OPT_IN_CONTEXT_FIELDS,
22286
22345
  operationalLogListReadSchema,
22287
- isSensitiveDiagnosticQueryKey,
22288
- redactLogValue,
22289
- redactLogString,
22290
- diagnosticIdentity,
22291
22346
  isStrictSemver,
22292
22347
  compareSemver,
22293
22348
  CANONRY_NPM_PACKAGE_URL,