@debugbundle/cli 1.28.0 → 1.30.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 (2) hide show
  1. package/dist/main.cjs +498 -70
  2. package/package.json +1 -1
package/dist/main.cjs CHANGED
@@ -50971,6 +50971,7 @@ var ProgrammeErrorCodeSchema = external_exports.enum([
50971
50971
  "programme_terms_mismatch",
50972
50972
  "creator_code_unavailable",
50973
50973
  "creator_code_already_claimed",
50974
+ "creator_code_changed",
50974
50975
  "creator_membership_required",
50975
50976
  "invalid_offer_code",
50976
50977
  "offer_ineligible",
@@ -51645,6 +51646,22 @@ var PAYOUT_OPERATIONS = {
51645
51646
  }
51646
51647
  };
51647
51648
 
51649
+ // ../../packages/referrals/src/referral-analytics-contract.ts
51650
+ var ReferralAnalyticsQuerySchema = external_exports.object({ days: external_exports.enum(["7", "30", "90"]).default("30") }).strict();
51651
+ var counts = external_exports.object({
51652
+ visits: external_exports.number().int().nonnegative().nullable().optional(),
51653
+ referred_accounts: external_exports.number().int().nonnegative(),
51654
+ first_paid_referrals: external_exports.number().int().nonnegative(),
51655
+ net_commission_minor: external_exports.number().int()
51656
+ });
51657
+ var ReferralAnalyticsSchema = external_exports.object({
51658
+ as_of: external_exports.iso.datetime(),
51659
+ visit_tracking_started_at: external_exports.iso.datetime().optional(),
51660
+ currency: external_exports.literal("usd"),
51661
+ totals: counts.strict(),
51662
+ daily: external_exports.array(counts.extend({ date: external_exports.iso.date() }).strict()).min(7).max(90)
51663
+ }).strict();
51664
+
51648
51665
  // ../../packages/referrals/src/offer-quote-contracts.ts
51649
51666
  var OfferQuoteSelectionSchema = external_exports.object({
51650
51667
  target_plan: PaidOfferPlanSchema,
@@ -51731,11 +51748,27 @@ var OFFER_OPERATIONS = {
51731
51748
  code: {
51732
51749
  method: "POST",
51733
51750
  path: "/v2/offers/creator/code",
51734
- input: external_exports.object({ code: CreatorCodeSchema }).strict(),
51751
+ input: external_exports.object({ code: CreatorCodeSchema, expected_code: CreatorCodeSchema.optional() }).strict(),
51735
51752
  response: creator,
51736
51753
  read: false,
51737
51754
  operator: false
51738
51755
  },
51756
+ creator_code_status: {
51757
+ method: "GET",
51758
+ path: "/v2/offers/creator/code",
51759
+ input: empty,
51760
+ response: external_exports.object({ can_replace: external_exports.boolean() }).strict(),
51761
+ read: true,
51762
+ operator: false
51763
+ },
51764
+ creator_analytics: {
51765
+ method: "GET",
51766
+ path: "/v2/referrals/analytics",
51767
+ input: ReferralAnalyticsQuerySchema,
51768
+ response: ReferralAnalyticsSchema,
51769
+ read: true,
51770
+ operator: false
51771
+ },
51739
51772
  customer: {
51740
51773
  method: "GET",
51741
51774
  path: "/v2/offers/customer",
@@ -52453,6 +52486,13 @@ function isSensitiveKey(key, sensitiveKeys) {
52453
52486
  }
52454
52487
  return false;
52455
52488
  }
52489
+ function isExactSensitiveKey(key, exactKeys) {
52490
+ if (exactKeys.length === 0) {
52491
+ return false;
52492
+ }
52493
+ const normalized = key.trim().toLowerCase();
52494
+ return exactKeys.some((candidate) => candidate.trim().toLowerCase() === normalized);
52495
+ }
52456
52496
 
52457
52497
  // ../../packages/redaction/src/telemetry-text.ts
52458
52498
  var REDACTED = "[REDACTED]";
@@ -52493,7 +52533,8 @@ function isValidCard(value) {
52493
52533
  }
52494
52534
  return sum % 10 === 0;
52495
52535
  }
52496
- function scrubUrl(raw, keys) {
52536
+ function scrubUrl(raw, additionalKeys, exactKeys) {
52537
+ const broadKeys = [...DEFAULT_SENSITIVE_KEYS, ...additionalKeys];
52497
52538
  try {
52498
52539
  const url2 = new URL(raw);
52499
52540
  if (url2.username || url2.password) {
@@ -52502,10 +52543,10 @@ function scrubUrl(raw, keys) {
52502
52543
  }
52503
52544
  const nextQuery = new URLSearchParams();
52504
52545
  for (const [key, value] of url2.searchParams) {
52505
- if (key.length > 128 || scrubCredentialText(key, keys, false) !== key) continue;
52546
+ if (key.length > 128 || scrubCredentialText(key, additionalKeys, false, exactKeys) !== key) continue;
52506
52547
  nextQuery.append(
52507
52548
  key,
52508
- isSensitiveKey(key, keys) || scrubCredentialText(value, keys, false) !== value ? REDACTED : value
52549
+ isSensitiveKey(key, broadKeys) || isExactSensitiveKey(key, exactKeys) || scrubCredentialText(value, additionalKeys, false, exactKeys) !== value ? REDACTED : value
52509
52550
  );
52510
52551
  }
52511
52552
  url2.search = nextQuery.toString();
@@ -52515,8 +52556,7 @@ function scrubUrl(raw, keys) {
52515
52556
  return REDACTED;
52516
52557
  }
52517
52558
  }
52518
- function scrubCredentialText(input3, additionalKeys, scanUrls = true) {
52519
- const keys = [...DEFAULT_SENSITIVE_KEYS, ...additionalKeys];
52559
+ function scrubCredentialText(input3, additionalKeys, scanUrls = true, exactKeys = []) {
52520
52560
  if (PEM_START.test(input3) && !PEM_COMPLETE.test(input3)) return REDACTED;
52521
52561
  let output3 = input3;
52522
52562
  if (/(?:password|token|secret|authorization|cookie)%3[ad]/i.test(output3)) {
@@ -52539,11 +52579,23 @@ function scrubCredentialText(input3, additionalKeys, scanUrls = true) {
52539
52579
  output3 = output3.replace(named, "$1$2[REDACTED]");
52540
52580
  }
52541
52581
  }
52582
+ if (exactKeys.length > 0) {
52583
+ for (const key of exactKeys) {
52584
+ const trimmed = key.trim();
52585
+ if (trimmed.length === 0) continue;
52586
+ const escaped = trimmed.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
52587
+ const named = new RegExp(
52588
+ `(?<![A-Za-z0-9_-])(${escaped})(?![A-Za-z0-9_-])(["']?\\s*[:=]\\s*)(?:"[^"]*"|'[^']*'|[^\\s&,;]+)`,
52589
+ "gi"
52590
+ );
52591
+ output3 = output3.replace(named, "$1$2[REDACTED]");
52592
+ }
52593
+ }
52542
52594
  output3 = output3.replace(CARD, (candidate) => isValidCard(candidate) ? REDACTED : candidate);
52543
52595
  if (!scanUrls) return output3;
52544
52596
  return output3.replace(URL_TEXT, (matched) => {
52545
52597
  const trailing = matched.match(/[).,;]+$/)?.[0] ?? "";
52546
- return scrubUrl(matched.slice(0, matched.length - trailing.length), keys) + trailing;
52598
+ return scrubUrl(matched.slice(0, matched.length - trailing.length), additionalKeys, exactKeys) + trailing;
52547
52599
  });
52548
52600
  }
52549
52601
 
@@ -52583,7 +52635,7 @@ function sanitizeString(value, state2, allowStructured) {
52583
52635
  if (error62 instanceof BudgetExceeded) throw error62;
52584
52636
  }
52585
52637
  }
52586
- const result = scrubCredentialText(value, state2.extra);
52638
+ const result = scrubCredentialText(value, state2.extra, true, state2.exact);
52587
52639
  if (result !== value) state2.redactionCount += 1;
52588
52640
  if ((value.startsWith("{") || value.startsWith("[")) && result === value && /(?:password|token|secret|authorization|cookie)["']?\s*[:=]/i.test(value)) {
52589
52641
  return mask(state2);
@@ -52622,14 +52674,14 @@ function sanitizeValue(value, state2, depth, allowStructured) {
52622
52674
  }
52623
52675
  state2.textBytes += byteLength(key);
52624
52676
  if (state2.textBytes > state2.maxTotalBytes) throw new BudgetExceeded();
52625
- const safeKey = scrubCredentialText(key, state2.extra);
52677
+ const safeKey = scrubCredentialText(key, state2.extra, true, state2.exact);
52626
52678
  if (safeKey !== key) {
52627
52679
  state2.redactionCount += 1;
52628
52680
  continue;
52629
52681
  }
52630
52682
  const descriptor = Object.getOwnPropertyDescriptor(value, key);
52631
52683
  if (descriptor === void 0 || !("value" in descriptor)) throw new TypeError("unsafe_input");
52632
- const safeValue = isSensitiveKey(key, state2.keys) ? mask(state2) : sanitizeValue(descriptor.value, state2, depth + 1, allowStructured);
52684
+ const safeValue = isSensitiveKey(key, state2.keys) || isExactSensitiveKey(key, state2.exact) ? mask(state2) : sanitizeValue(descriptor.value, state2, depth + 1, allowStructured);
52633
52685
  Object.defineProperty(result, key, {
52634
52686
  value: safeValue,
52635
52687
  enumerable: true,
@@ -52645,7 +52697,8 @@ function sanitizeValue(value, state2, depth, allowStructured) {
52645
52697
  function sanitizeTelemetry(value, options = {}) {
52646
52698
  try {
52647
52699
  const extra = options.additionalKeys ?? [];
52648
- if (extra.length > 128 || extra.some((key) => typeof key !== "string" || key.length > 64 || !key.trim())) {
52700
+ const exact = options.exactKeys ?? [];
52701
+ if (extra.length + exact.length > 128 || extra.some((key) => typeof key !== "string" || key.length > 64 || !key.trim()) || exact.some((key) => typeof key !== "string" || key.length > 64 || !key.trim())) {
52649
52702
  return { ok: false, reason: "unsafe_input" };
52650
52703
  }
52651
52704
  const maxTotalBytes = options.maxTotalBytes ?? MAX_TOTAL_BYTES;
@@ -52659,6 +52712,7 @@ function sanitizeTelemetry(value, options = {}) {
52659
52712
  seen: /* @__PURE__ */ new WeakSet(),
52660
52713
  keys: [...DEFAULT_SENSITIVE_KEYS, ...extra],
52661
52714
  extra,
52715
+ exact,
52662
52716
  maxTotalBytes
52663
52717
  };
52664
52718
  const sanitized = sanitizeValue(value, state2, 0, true);
@@ -52672,7 +52726,7 @@ function sanitizeTelemetry(value, options = {}) {
52672
52726
  }
52673
52727
 
52674
52728
  // ../../packages/redaction/src/index.ts
52675
- function redactInternal(value, path3, sensitiveKeys, replacement, touchedPaths, seen) {
52729
+ function redactInternal(value, path3, sensitiveKeys, exactKeys, replacement, touchedPaths, seen) {
52676
52730
  if (Array.isArray(value)) {
52677
52731
  if (seen.has(value)) {
52678
52732
  return "[Circular]";
@@ -52683,6 +52737,7 @@ function redactInternal(value, path3, sensitiveKeys, replacement, touchedPaths,
52683
52737
  entry,
52684
52738
  path3.length === 0 ? `[${index}]` : `${path3}[${index}]`,
52685
52739
  sensitiveKeys,
52740
+ exactKeys,
52686
52741
  replacement,
52687
52742
  touchedPaths,
52688
52743
  seen
@@ -52701,7 +52756,7 @@ function redactInternal(value, path3, sensitiveKeys, replacement, touchedPaths,
52701
52756
  const output3 = {};
52702
52757
  for (const [key, nestedValue] of Object.entries(value)) {
52703
52758
  const nextPath = path3.length === 0 ? key : `${path3}.${key}`;
52704
- if (isSensitiveKey(key, sensitiveKeys)) {
52759
+ if (isSensitiveKey(key, sensitiveKeys) || isExactSensitiveKey(key, exactKeys)) {
52705
52760
  output3[key] = replacement;
52706
52761
  touchedPaths.push(nextPath);
52707
52762
  continue;
@@ -52710,6 +52765,7 @@ function redactInternal(value, path3, sensitiveKeys, replacement, touchedPaths,
52710
52765
  nestedValue,
52711
52766
  nextPath,
52712
52767
  sensitiveKeys,
52768
+ exactKeys,
52713
52769
  replacement,
52714
52770
  touchedPaths,
52715
52771
  seen
@@ -52722,12 +52778,14 @@ function redact(payload, options) {
52722
52778
  const sensitiveKeys = options?.sensitiveKeys?.map((key) => key.trim().toLowerCase()) ?? [
52723
52779
  ...DEFAULT_SENSITIVE_KEYS
52724
52780
  ];
52781
+ const exactKeys = options?.exactKeys?.map((key) => key.trim().toLowerCase()) ?? [];
52725
52782
  const replacement = options?.replacement ?? "[REDACTED]";
52726
52783
  const touchedPaths = [];
52727
52784
  const redacted = redactInternal(
52728
52785
  payload,
52729
52786
  "",
52730
52787
  sensitiveKeys,
52788
+ exactKeys,
52731
52789
  replacement,
52732
52790
  touchedPaths,
52733
52791
  /* @__PURE__ */ new WeakSet()
@@ -55193,12 +55251,12 @@ function normalizeResourceRoute(value) {
55193
55251
  return route.length <= 1024 ? route : null;
55194
55252
  }
55195
55253
  function summarizeResourceRoutes(routes, occurrenceCount) {
55196
- const counts = /* @__PURE__ */ new Map();
55254
+ const counts2 = /* @__PURE__ */ new Map();
55197
55255
  for (const raw of routes) {
55198
55256
  const route = normalizeResourceRoute(raw);
55199
- if (route !== null) counts.set(route, (counts.get(route) ?? 0) + 1);
55257
+ if (route !== null) counts2.set(route, (counts2.get(route) ?? 0) + 1);
55200
55258
  }
55201
- const items = [...counts].map(([route, occurrences]) => ({ route, occurrences })).sort(
55259
+ const items = [...counts2].map(([route, occurrences]) => ({ route, occurrences })).sort(
55202
55260
  (a, b) => b.occurrences - a.occurrences || (a.route < b.route ? -1 : a.route > b.route ? 1 : 0)
55203
55261
  );
55204
55262
  const recorded = items.reduce((total, item) => total + item.occurrences, 0);
@@ -56124,12 +56182,19 @@ var CAPTURE_RULE_RUNTIME_VALUES = [
56124
56182
  "java",
56125
56183
  "go",
56126
56184
  "ruby",
56185
+ "dotnet",
56186
+ "rust",
56187
+ "android",
56188
+ "swift",
56189
+ "react-native",
56127
56190
  "unknown"
56128
56191
  ];
56129
- var CaptureRuleActionValues = ["demote", "sample", "drop"];
56192
+ var CaptureRuleActionValues = ["demote", "sample", "drop", "threshold", "allow"];
56130
56193
  var CaptureRuleActionSchema = external_exports.enum(CaptureRuleActionValues);
56131
56194
  var CaptureRuleSampleEventClassValues = ["preserve", "context"];
56132
56195
  var CaptureRuleSampleEventClassSchema = external_exports.enum(CaptureRuleSampleEventClassValues);
56196
+ var CaptureRuleThresholdGroupByValues = ["resource", "fingerprint"];
56197
+ var CaptureRuleThresholdGroupBySchema = external_exports.enum(CaptureRuleThresholdGroupByValues);
56133
56198
  var CaptureRuleRuntimeSchema = external_exports.enum(CAPTURE_RULE_RUNTIME_VALUES);
56134
56199
  var CaptureRuleEventTypeSchema = external_exports.enum(CAPTURE_RULE_EVENT_TYPES);
56135
56200
  var BrowserEventKindSchema = external_exports.enum(["window_error", "resource_error"]);
@@ -56211,6 +56276,29 @@ var UrlMatcherSchema = external_exports.object({
56211
56276
  message: "URL matchers must include at least one host or path constraint."
56212
56277
  }
56213
56278
  );
56279
+ var ExactUrlMatcherSchema = external_exports.object({
56280
+ host: external_exports.string().trim().min(1).max(255),
56281
+ path_equals: external_exports.string().trim().min(1).max(1024)
56282
+ }).strict().transform((value) => ({
56283
+ host: value.host.toLowerCase(),
56284
+ path_equals: value.path_equals.startsWith("/") ? value.path_equals : `/${value.path_equals}`
56285
+ }));
56286
+ function normalizeExactUrlMatchers(values) {
56287
+ if (values === void 0) {
56288
+ return void 0;
56289
+ }
56290
+ const seen = /* @__PURE__ */ new Set();
56291
+ const normalized = [];
56292
+ for (const entry of values) {
56293
+ const key = `${entry.host}\0${entry.path_equals}`;
56294
+ if (seen.has(key)) {
56295
+ continue;
56296
+ }
56297
+ seen.add(key);
56298
+ normalized.push(entry);
56299
+ }
56300
+ return normalized;
56301
+ }
56214
56302
  var StatusRangeSchema = external_exports.object({
56215
56303
  start: external_exports.number().int().min(100).max(599),
56216
56304
  end: external_exports.number().int().min(100).max(599)
@@ -56253,6 +56341,7 @@ var CaptureRuleMatcherSchema = external_exports.object({
56253
56341
  client_kind: CaptureRuleClientKindSchema.optional(),
56254
56342
  bot_family: external_exports.string().min(1).max(120).optional(),
56255
56343
  resource_url: UrlMatcherSchema.optional(),
56344
+ resource_urls: external_exports.array(ExactUrlMatcherSchema).min(1).max(10).optional(),
56256
56345
  request_url: UrlMatcherSchema.optional(),
56257
56346
  status_codes: external_exports.array(external_exports.number().int().min(100).max(599)).min(1).optional(),
56258
56347
  status_ranges: external_exports.array(StatusRangeSchema).min(1).optional(),
@@ -56268,6 +56357,7 @@ var CaptureRuleMatcherSchema = external_exports.object({
56268
56357
  const messageEquals = normalizeOptionalTrimmedString(value.message_equals);
56269
56358
  const botFamily = normalizeOptionalTrimmedString(value.bot_family);
56270
56359
  const browserTargetTagName = normalizeOptionalTrimmedString(value.browser_target_tag_name);
56360
+ const resourceUrls = normalizeExactUrlMatchers(value.resource_urls);
56271
56361
  const statusCodes = normalizeNumberArray(value.status_codes);
56272
56362
  if (eventTypes !== void 0) {
56273
56363
  normalized.event_types = eventTypes;
@@ -56320,6 +56410,9 @@ var CaptureRuleMatcherSchema = external_exports.object({
56320
56410
  if (value.resource_url !== void 0) {
56321
56411
  normalized.resource_url = value.resource_url;
56322
56412
  }
56413
+ if (resourceUrls !== void 0) {
56414
+ normalized.resource_urls = resourceUrls;
56415
+ }
56323
56416
  if (value.request_url !== void 0) {
56324
56417
  normalized.request_url = value.request_url;
56325
56418
  }
@@ -56351,6 +56444,7 @@ var CaptureRuleMatcherSchema = external_exports.object({
56351
56444
  "client_kind",
56352
56445
  "bot_family",
56353
56446
  "resource_url",
56447
+ "resource_urls",
56354
56448
  "request_url",
56355
56449
  "status_codes",
56356
56450
  "status_ranges",
@@ -56362,8 +56456,15 @@ var CaptureRuleMatcherSchema = external_exports.object({
56362
56456
  message: "Capture rules must include at least one narrowing field beyond event_types."
56363
56457
  });
56364
56458
  }
56459
+ if (hasValue(value.resource_url) && hasValue(value.resource_urls)) {
56460
+ context.addIssue({
56461
+ code: external_exports.ZodIssueCode.custom,
56462
+ path: ["resource_urls"],
56463
+ message: "Capture rules cannot combine resource_url and resource_urls."
56464
+ });
56465
+ }
56365
56466
  if (value.browser_event_kind === "resource_error") {
56366
- const hasResourceConstraint = hasValue(value.resource_url) || hasValue(value.fingerprint);
56467
+ const hasResourceConstraint = hasValue(value.resource_url) || hasValue(value.resource_urls) || hasValue(value.fingerprint);
56367
56468
  if (!hasResourceConstraint) {
56368
56469
  context.addIssue({
56369
56470
  code: external_exports.ZodIssueCode.custom,
@@ -56380,42 +56481,112 @@ var CaptureRuleCoreObjectSchema = external_exports.object({
56380
56481
  matcher: CaptureRuleMatcherSchema,
56381
56482
  sample_rate: external_exports.number().min(0).max(1).nullable(),
56382
56483
  sample_event_class: CaptureRuleSampleEventClassSchema.nullable(),
56484
+ threshold_count: external_exports.number().int().min(2).max(1e3).nullable().optional(),
56485
+ threshold_window_seconds: external_exports.number().int().min(60).max(86400).nullable().optional(),
56486
+ threshold_group_by: CaptureRuleThresholdGroupBySchema.nullable().optional(),
56383
56487
  created_by_user_id: external_exports.string().min(1).max(120).nullable(),
56384
56488
  created_from_incident_id: external_exports.string().min(1).max(120).nullable(),
56385
56489
  created_from_event_id: external_exports.string().min(1).max(120).nullable(),
56386
56490
  expires_at: external_exports.string().datetime().nullable()
56387
56491
  });
56492
+ function validateResourceThresholdMatcher(matcher, context) {
56493
+ if (matcher === void 0) {
56494
+ return;
56495
+ }
56496
+ const allowsFrontendException = matcher.event_types === void 0 || matcher.event_types.includes("frontend_exception");
56497
+ if (matcher.browser_event_kind !== "resource_error" || !allowsFrontendException) {
56498
+ context.addIssue({
56499
+ code: external_exports.ZodIssueCode.custom,
56500
+ path: ["threshold_group_by"],
56501
+ message: "Resource threshold grouping requires a browser resource_error matcher."
56502
+ });
56503
+ }
56504
+ }
56388
56505
  function addCaptureRuleActionValidation(schema) {
56389
56506
  return schema.superRefine((value, context) => {
56390
- if (value["action"] === "sample") {
56391
- if (value["sample_rate"] === null) {
56507
+ const action = value["action"];
56508
+ const sampleRate = value["sample_rate"];
56509
+ const sampleEventClass = value["sample_event_class"];
56510
+ const thresholdCount = value["threshold_count"];
56511
+ const thresholdWindowSeconds = value["threshold_window_seconds"];
56512
+ const thresholdGroupBy = value["threshold_group_by"];
56513
+ const matcher = value["matcher"];
56514
+ if (action === "sample") {
56515
+ if (sampleRate === null || sampleRate === void 0) {
56392
56516
  context.addIssue({
56393
56517
  code: external_exports.ZodIssueCode.custom,
56394
56518
  path: ["sample_rate"],
56395
56519
  message: "Sample rules require sample_rate."
56396
56520
  });
56397
56521
  }
56398
- if (value["sample_event_class"] === null) {
56522
+ if (sampleEventClass === null || sampleEventClass === void 0) {
56399
56523
  context.addIssue({
56400
56524
  code: external_exports.ZodIssueCode.custom,
56401
56525
  path: ["sample_event_class"],
56402
56526
  message: "Sample rules require sample_event_class."
56403
56527
  });
56404
56528
  }
56529
+ } else {
56530
+ if (hasValue(sampleRate)) {
56531
+ context.addIssue({
56532
+ code: external_exports.ZodIssueCode.custom,
56533
+ path: ["sample_rate"],
56534
+ message: "Only sample rules can set sample_rate."
56535
+ });
56536
+ }
56537
+ if (hasValue(sampleEventClass)) {
56538
+ context.addIssue({
56539
+ code: external_exports.ZodIssueCode.custom,
56540
+ path: ["sample_event_class"],
56541
+ message: "Only sample rules can set sample_event_class."
56542
+ });
56543
+ }
56544
+ }
56545
+ if (action === "threshold") {
56546
+ if (!hasValue(thresholdCount)) {
56547
+ context.addIssue({
56548
+ code: external_exports.ZodIssueCode.custom,
56549
+ path: ["threshold_count"],
56550
+ message: "Threshold rules require threshold_count."
56551
+ });
56552
+ }
56553
+ if (!hasValue(thresholdWindowSeconds)) {
56554
+ context.addIssue({
56555
+ code: external_exports.ZodIssueCode.custom,
56556
+ path: ["threshold_window_seconds"],
56557
+ message: "Threshold rules require threshold_window_seconds."
56558
+ });
56559
+ }
56560
+ if (!hasValue(thresholdGroupBy)) {
56561
+ context.addIssue({
56562
+ code: external_exports.ZodIssueCode.custom,
56563
+ path: ["threshold_group_by"],
56564
+ message: "Threshold rules require threshold_group_by."
56565
+ });
56566
+ } else if (thresholdGroupBy === "resource") {
56567
+ validateResourceThresholdMatcher(matcher, context);
56568
+ }
56405
56569
  return;
56406
56570
  }
56407
- if (value["sample_rate"] !== null) {
56571
+ if (hasValue(thresholdCount)) {
56408
56572
  context.addIssue({
56409
56573
  code: external_exports.ZodIssueCode.custom,
56410
- path: ["sample_rate"],
56411
- message: "Only sample rules can set sample_rate."
56574
+ path: ["threshold_count"],
56575
+ message: "Only threshold rules can set threshold_count."
56412
56576
  });
56413
56577
  }
56414
- if (value["sample_event_class"] !== null) {
56578
+ if (hasValue(thresholdWindowSeconds)) {
56415
56579
  context.addIssue({
56416
56580
  code: external_exports.ZodIssueCode.custom,
56417
- path: ["sample_event_class"],
56418
- message: "Only sample rules can set sample_event_class."
56581
+ path: ["threshold_window_seconds"],
56582
+ message: "Only threshold rules can set threshold_window_seconds."
56583
+ });
56584
+ }
56585
+ if (hasValue(thresholdGroupBy)) {
56586
+ context.addIssue({
56587
+ code: external_exports.ZodIssueCode.custom,
56588
+ path: ["threshold_group_by"],
56589
+ message: "Only threshold rules can set threshold_group_by."
56419
56590
  });
56420
56591
  }
56421
56592
  });
@@ -56440,6 +56611,9 @@ var CaptureRuleCreateSchema = external_exports.object({
56440
56611
  matcher: CaptureRuleMatcherSchema,
56441
56612
  sample_rate: external_exports.number().min(0).max(1).nullable().optional(),
56442
56613
  sample_event_class: CaptureRuleSampleEventClassSchema.nullable().optional(),
56614
+ threshold_count: external_exports.number().int().min(2).max(1e3).nullable().optional(),
56615
+ threshold_window_seconds: external_exports.number().int().min(60).max(86400).nullable().optional(),
56616
+ threshold_group_by: CaptureRuleThresholdGroupBySchema.nullable().optional(),
56443
56617
  created_by_user_id: external_exports.string().min(1).max(120).nullable().default(null),
56444
56618
  created_from_incident_id: external_exports.string().min(1).max(120).nullable().default(null),
56445
56619
  created_from_event_id: external_exports.string().min(1).max(120).nullable().default(null),
@@ -56453,26 +56627,76 @@ var CaptureRuleCreateSchema = external_exports.object({
56453
56627
  message: "Sample rules require sample_rate."
56454
56628
  });
56455
56629
  }
56630
+ } else {
56631
+ if (value.sample_rate !== void 0 && value.sample_rate !== null) {
56632
+ context.addIssue({
56633
+ code: external_exports.ZodIssueCode.custom,
56634
+ path: ["sample_rate"],
56635
+ message: "Only sample rules can set sample_rate."
56636
+ });
56637
+ }
56638
+ if (value.sample_event_class !== void 0 && value.sample_event_class !== null) {
56639
+ context.addIssue({
56640
+ code: external_exports.ZodIssueCode.custom,
56641
+ path: ["sample_event_class"],
56642
+ message: "Only sample rules can set sample_event_class."
56643
+ });
56644
+ }
56645
+ }
56646
+ if (value.action === "threshold") {
56647
+ if (!hasValue(value.threshold_count)) {
56648
+ context.addIssue({
56649
+ code: external_exports.ZodIssueCode.custom,
56650
+ path: ["threshold_count"],
56651
+ message: "Threshold rules require threshold_count."
56652
+ });
56653
+ }
56654
+ if (!hasValue(value.threshold_window_seconds)) {
56655
+ context.addIssue({
56656
+ code: external_exports.ZodIssueCode.custom,
56657
+ path: ["threshold_window_seconds"],
56658
+ message: "Threshold rules require threshold_window_seconds."
56659
+ });
56660
+ }
56661
+ if (!hasValue(value.threshold_group_by)) {
56662
+ context.addIssue({
56663
+ code: external_exports.ZodIssueCode.custom,
56664
+ path: ["threshold_group_by"],
56665
+ message: "Threshold rules require threshold_group_by."
56666
+ });
56667
+ } else if (value.threshold_group_by === "resource") {
56668
+ validateResourceThresholdMatcher(value.matcher, context);
56669
+ }
56456
56670
  return;
56457
56671
  }
56458
- if (value.sample_rate !== void 0 && value.sample_rate !== null) {
56672
+ if (hasValue(value.threshold_count)) {
56459
56673
  context.addIssue({
56460
56674
  code: external_exports.ZodIssueCode.custom,
56461
- path: ["sample_rate"],
56462
- message: "Only sample rules can set sample_rate."
56675
+ path: ["threshold_count"],
56676
+ message: "Only threshold rules can set threshold_count."
56463
56677
  });
56464
56678
  }
56465
- if (value.sample_event_class !== void 0 && value.sample_event_class !== null) {
56679
+ if (hasValue(value.threshold_window_seconds)) {
56466
56680
  context.addIssue({
56467
56681
  code: external_exports.ZodIssueCode.custom,
56468
- path: ["sample_event_class"],
56469
- message: "Only sample rules can set sample_event_class."
56682
+ path: ["threshold_window_seconds"],
56683
+ message: "Only threshold rules can set threshold_window_seconds."
56684
+ });
56685
+ }
56686
+ if (hasValue(value.threshold_group_by)) {
56687
+ context.addIssue({
56688
+ code: external_exports.ZodIssueCode.custom,
56689
+ path: ["threshold_group_by"],
56690
+ message: "Only threshold rules can set threshold_group_by."
56470
56691
  });
56471
56692
  }
56472
56693
  }).transform((value) => ({
56473
56694
  ...value,
56474
56695
  sample_rate: value.action === "sample" ? value.sample_rate : null,
56475
- sample_event_class: value.action === "sample" ? value.sample_event_class ?? "preserve" : null
56696
+ sample_event_class: value.action === "sample" ? value.sample_event_class ?? "preserve" : null,
56697
+ threshold_count: value.action === "threshold" ? value.threshold_count : null,
56698
+ threshold_window_seconds: value.action === "threshold" ? value.threshold_window_seconds : null,
56699
+ threshold_group_by: value.action === "threshold" ? value.threshold_group_by : null
56476
56700
  }));
56477
56701
  var CaptureRuleUpdateSchema = external_exports.object({
56478
56702
  project_scope: external_exports.literal("current_project").optional(),
@@ -56483,6 +56707,9 @@ var CaptureRuleUpdateSchema = external_exports.object({
56483
56707
  matcher: CaptureRuleMatcherSchema.optional(),
56484
56708
  sample_rate: external_exports.number().min(0).max(1).nullable().optional(),
56485
56709
  sample_event_class: CaptureRuleSampleEventClassSchema.nullable().optional(),
56710
+ threshold_count: external_exports.number().int().min(2).max(1e3).nullable().optional(),
56711
+ threshold_window_seconds: external_exports.number().int().min(60).max(86400).nullable().optional(),
56712
+ threshold_group_by: CaptureRuleThresholdGroupBySchema.nullable().optional(),
56486
56713
  expires_at: external_exports.string().datetime().nullable().optional()
56487
56714
  }).superRefine((value, context) => {
56488
56715
  if (Object.keys(value).length === 0) {
@@ -56493,34 +56720,81 @@ var CaptureRuleUpdateSchema = external_exports.object({
56493
56720
  }
56494
56721
  const resolvedAction = value.action;
56495
56722
  if (resolvedAction === "sample") {
56496
- if (!("sample_rate" in value)) {
56723
+ if (!("sample_rate" in value) || value.sample_rate === null) {
56497
56724
  context.addIssue({
56498
56725
  code: external_exports.ZodIssueCode.custom,
56499
56726
  path: ["sample_rate"],
56500
56727
  message: "Sample rule updates must include sample_rate when changing action to sample."
56501
56728
  });
56502
56729
  }
56503
- if (!("sample_event_class" in value)) {
56730
+ if (!("sample_event_class" in value) || value.sample_event_class === null) {
56504
56731
  context.addIssue({
56505
56732
  code: external_exports.ZodIssueCode.custom,
56506
56733
  path: ["sample_event_class"],
56507
56734
  message: "Sample rule updates must include sample_event_class when changing action to sample."
56508
56735
  });
56509
56736
  }
56737
+ } else {
56738
+ if ("sample_rate" in value) {
56739
+ context.addIssue({
56740
+ code: external_exports.ZodIssueCode.custom,
56741
+ path: ["sample_rate"],
56742
+ message: "Sample rule fields can only be updated while setting action to sample."
56743
+ });
56744
+ }
56745
+ if ("sample_event_class" in value) {
56746
+ context.addIssue({
56747
+ code: external_exports.ZodIssueCode.custom,
56748
+ path: ["sample_event_class"],
56749
+ message: "Sample rule fields can only be updated while setting action to sample."
56750
+ });
56751
+ }
56752
+ }
56753
+ if (resolvedAction === "threshold") {
56754
+ if (!("threshold_count" in value) || !hasValue(value.threshold_count)) {
56755
+ context.addIssue({
56756
+ code: external_exports.ZodIssueCode.custom,
56757
+ path: ["threshold_count"],
56758
+ message: "Threshold rule updates must include threshold_count when changing action to threshold."
56759
+ });
56760
+ }
56761
+ if (!("threshold_window_seconds" in value) || !hasValue(value.threshold_window_seconds)) {
56762
+ context.addIssue({
56763
+ code: external_exports.ZodIssueCode.custom,
56764
+ path: ["threshold_window_seconds"],
56765
+ message: "Threshold rule updates must include threshold_window_seconds when changing action to threshold."
56766
+ });
56767
+ }
56768
+ if (!("threshold_group_by" in value) || !hasValue(value.threshold_group_by)) {
56769
+ context.addIssue({
56770
+ code: external_exports.ZodIssueCode.custom,
56771
+ path: ["threshold_group_by"],
56772
+ message: "Threshold rule updates must include threshold_group_by when changing action to threshold."
56773
+ });
56774
+ } else if (value.threshold_group_by === "resource" && value.matcher !== void 0) {
56775
+ validateResourceThresholdMatcher(value.matcher, context);
56776
+ }
56510
56777
  return;
56511
56778
  }
56512
- if ("sample_rate" in value) {
56779
+ if ("threshold_count" in value) {
56513
56780
  context.addIssue({
56514
56781
  code: external_exports.ZodIssueCode.custom,
56515
- path: ["sample_rate"],
56516
- message: "Sample rule fields can only be updated while setting action to sample."
56782
+ path: ["threshold_count"],
56783
+ message: "Threshold rule fields can only be updated while setting action to threshold."
56517
56784
  });
56518
56785
  }
56519
- if ("sample_event_class" in value) {
56786
+ if ("threshold_window_seconds" in value) {
56520
56787
  context.addIssue({
56521
56788
  code: external_exports.ZodIssueCode.custom,
56522
- path: ["sample_event_class"],
56523
- message: "Sample rule fields can only be updated while setting action to sample."
56789
+ path: ["threshold_window_seconds"],
56790
+ message: "Threshold rule fields can only be updated while setting action to threshold."
56791
+ });
56792
+ }
56793
+ if ("threshold_group_by" in value) {
56794
+ context.addIssue({
56795
+ code: external_exports.ZodIssueCode.custom,
56796
+ path: ["threshold_group_by"],
56797
+ message: "Threshold rule fields can only be updated while setting action to threshold."
56524
56798
  });
56525
56799
  }
56526
56800
  });
@@ -56764,7 +57038,7 @@ function browserResourceDiagnosis(resource) {
56764
57038
  return resource?.optional_candidate === true ? "The browser reported that this script failed to load. Possibly blocked by privacy tools; network, CSP or provider failures are also possible. The captured event does not identify the cause." : "The browser reported that this resource failed to load. The captured event does not identify the cause or establish whether application functionality was affected.";
56765
57039
  }
56766
57040
 
56767
- // ../../packages/shared-types/src/capture-rule-evaluation.ts
57041
+ // ../../packages/shared-types/src/capture-rule-evaluation-context.ts
56768
57042
  var CaptureRuleEvaluationUrlSchema = external_exports.object({
56769
57043
  host: external_exports.string().min(1).transform((value) => value.toLowerCase()).optional(),
56770
57044
  path: external_exports.string().min(1).transform((value) => value.startsWith("/") ? value : `/${value}`)
@@ -60691,6 +60965,8 @@ async function handleOfferCommand(parsed, command = offersWithAuthCommand) {
60691
60965
  expectNoUnknownOptions(parsed, [
60692
60966
  "input",
60693
60967
  "code",
60968
+ "expected-code",
60969
+ "days",
60694
60970
  "version",
60695
60971
  "accept-terms-version",
60696
60972
  "organization",
@@ -60718,6 +60994,8 @@ async function handleOfferCommand(parsed, command = offersWithAuthCommand) {
60718
60994
  }
60719
60995
  const fields3 = {
60720
60996
  code: "code",
60997
+ "expected-code": "expected_code",
60998
+ days: "days",
60721
60999
  version: "version_id",
60722
61000
  "accept-terms-version": "terms_version",
60723
61001
  organization: action === "operator_claims" ? "organization_id" : "expected_organization_id",
@@ -62786,10 +63064,12 @@ function buildSkill() {
62786
63064
  "",
62787
63065
  "### Browser resource failures",
62788
63066
  "",
62789
- "- Inspect the primary failure and routes: one resource can span pages, route coverage may be incomplete, and historical incidents stay separate. Related tracker evidence does not explain an application exception.",
62790
- '- If the cause is unknown, say "possibly blocked by privacy tools." Network/CSP/provider failures remain possible; provider recognition proves neither Pi-hole blocking nor optionality.',
63067
+ "- Inspect the primary failure, routes, and passive evidence first: one resource can span pages, route coverage may be incomplete, and historical incidents stay separate. Related tracker evidence does not explain an application exception.",
63068
+ '- Distinguish observed evidence from unknown causes: treat enforced CSP (`disposition: "enforce"`) separately from report-only CSP (`disposition: "report"`, which does not block), check observed resource-timing HTTP status, explicit recovery outcomes, and `visibility_state: "unloaded"` (`pagehide` teardown aborts). When the cause is still unknown, say "possibly blocked by privacy tools." Network/CSP/provider failures remain possible; provider recognition proves neither Pi-hole blocking nor optionality.',
62791
63069
  "- Review exact resource host/path/type, service, environment and opacity, or the returned exact fingerprint when evidence is incomplete; never widen to a whole host. All resource incidents can offer explicit controls. Provider recognition does not establish that a dependency is optional; do not suppress authentication, app assets or unknown dependencies automatically.",
62792
- "- For confirmed optional dependencies, context (demote) retains diagnostics without new incidents/alerts/automation and may remain billable. Drop discards future matches; choose it only when evidence has no diagnostic value. Explain the tradeoff; neither deletes history. Use the returned suggestion ID.",
63070
+ '- For single-visitor transient resource failures or deploy-hashed application assets (such as `/assets/`), prefer an opt-in `threshold` rule (`resource_threshold` suggestion or `--action threshold` with `--threshold-count`, `--threshold-window-seconds`, and `--threshold-group-by <resource|fingerprint>`) over `demote` or `drop`. Events below threshold wait without opening incidents or alerts, while real repeated outages still open one incident with prior-window occurrences and routes backfilled. Pair broader prefix rules with higher-specificity `action: "allow"` carve-outs when critical paths (such as checkout or authentication assets) must still open on the first failure.',
63071
+ "- For confirmed optional dependencies, context (`demote`) retains diagnostics without new incidents/alerts/automation and may remain billable; `drop` discards future matches and should be chosen only when evidence has no diagnostic value. When one confirmed optional dependency loads across primary and fallback CDN addresses, group them in one rule using `matcher.resource_urls` (1\u201310 exact `{ host, path_equals }` entries) instead of widening to a host. Explain the tradeoff; neither deletes history. Use the returned suggestion ID.",
63072
+ "- If legacy resource events show a redacted `tag_name` splitting one resource into per-route incidents, check the app's SDK `redactFields` configuration and recommend moving narrow private domain keys (such as `tag`) to exact-key `redactExactFields` alongside a protected SDK release that preserves schema-validated protocol fields.",
62793
63073
  "- Check existing/disabled rules. Empty suggestions or pending/failed bundles do not justify broader rules. Applying requires user authorization and owner/admin access; preview is read-only. Verify subsequent matching and protected captures before claiming improvement; live tests need authorization.",
62794
63074
  "- The official OpenAI connection cannot suggest or apply rules. When it is the only connection, review returned evidence and hand off through a returned safe dashboard URL; never invent tools or switch credentials.",
62795
63075
  "",
@@ -62900,11 +63180,12 @@ function buildCliReference() {
62900
63180
  "- `debugbundle capture-rule suggest <incident-id> [--auth-file <path>] [--json]`",
62901
63181
  "- `debugbundle capture-rule create-from-suggestion <incident-id> --suggestion-id <id> [--name <name>] [--expires-at <ISO8601>] [--auth-file <path>] [--json]`",
62902
63182
  "- `debugbundle capture-rule list --project-id <id> [--auth-file <path>] [--json]`",
62903
- "- `debugbundle capture-rule create --project-id <id> --name <name> --action <demote|sample|drop> --matcher-json <json> [--auth-file <path>] [--json]`",
63183
+ "- `debugbundle capture-rule create --project-id <id> --name <name> --action <demote|sample|drop|threshold|allow> --matcher-json <json> [--threshold-count <2-1000>] [--threshold-window-seconds <60-86400>] [--threshold-group-by <resource|fingerprint>] [--expires-at <ISO8601>] [--auth-file <path>] [--json]`",
63184
+ "- `debugbundle capture-rule update <rule-id> --project-id <id> [--name <name>] [--action <demote|sample|drop|threshold|allow>] [--matcher-json <json>] [--threshold-count <2-1000>] [--threshold-window-seconds <60-86400>] [--threshold-group-by <resource|fingerprint>] [--enabled <true|false>] [--expires-at <ISO8601|null>] [--auth-file <path>] [--json]`",
62904
63185
  "- `debugbundle capture-policy get [--project <id>] [--json]`",
62905
63186
  "- `debugbundle capture-policy set [--project <id>] --client-error-path-rule <404=/path/*@GET,POST> [--json]`",
62906
63187
  "",
62907
- "Use capture-rule suggestions for repeated operational noise after inspecting an incident bundle. Use capture-policy client-error path rules for route-scoped 4xx incidents instead of promoting all client errors.",
63188
+ "Use capture-rule suggestions for repeated operational noise after inspecting an incident bundle. Prefer `threshold` (`resource_threshold` suggestion) for single-visitor transient resource failures and deploy-hashed assets, pair broader prefix rules with higher-specificity `allow` carve-outs for critical paths, and use `matcher.resource_urls` (1\u201310 exact `{ host, path_equals }` entries) for multi-CDN optional dependencies. Use capture-policy client-error path rules for route-scoped 4xx incidents instead of promoting all client errors.",
62908
63189
  "For browser resource failures, follow the skill's Browser resource failures guidance. Use the current response's suggestion ID, inspect `bundle_status`, `access_mode` and existing-rule state, and review the complete matcher before applying.",
62909
63190
  "",
62910
63191
  "## Probes",
@@ -63045,10 +63326,10 @@ function buildMcpReference() {
63045
63326
  "",
63046
63327
  "- `suggest_capture_rules_from_incident` \u2014 generate deterministic capture-rule suggestions from an incident bundle.",
63047
63328
  "- `create_capture_rule_from_incident_suggestion` \u2014 apply a confirmed suggestion.",
63048
- "- `list_capture_rules`, `create_capture_rule`, `update_capture_rule`, `delete_capture_rule` \u2014 manage project capture rules.",
63329
+ "- `list_capture_rules`, `create_capture_rule`, `update_capture_rule`, `delete_capture_rule` \u2014 manage project capture rules (`demote`, `sample`, `drop`, `threshold` with rolling-window counts, `allow` carve-outs, and bounded `matcher.resource_urls`).",
63049
63330
  "- `get_capture_policy`, `update_capture_policy` \u2014 review or update capture policy, including path-scoped client-error incident rules.",
63050
63331
  "",
63051
- "Use these tools for repeated low-value operational noise only after inspecting incident evidence. Keep frontend suppression scoped by structured browser and client signals, and use path-scoped capture policy for known 4xx routes.",
63332
+ "Use these tools for repeated low-value operational noise only after inspecting incident evidence. Prefer `threshold` (`resource_threshold`) for transient single-visitor or deploy-hashed resource noise, `allow` carve-outs for critical assets, and `resource_urls` for multi-CDN optional dependencies. Keep frontend suppression scoped by structured browser and client signals, and use path-scoped capture policy for known 4xx routes.",
63052
63333
  "For browser resource failures, follow the skill's Browser resource failures guidance and use the suggestion ID returned by the server. These management tools belong to the access-token-authenticated MCP surface; the official OpenAI connection is read-only and cannot suggest or apply capture rules.",
63053
63334
  "",
63054
63335
  "## Product Analytics Tools",
@@ -63273,6 +63554,15 @@ function buildSkillEvals() {
63273
63554
  "Verify the returned rule without claiming historical incidents were removed or live noise reduction was already observed."
63274
63555
  ]
63275
63556
  },
63557
+ {
63558
+ name: "transient_hashed_asset_threshold_review",
63559
+ prompt: "Single-visitor deploy-hashed CSS/JS failures under /assets/ keep opening one-off incidents, while checkout assets under /assets/checkout- must stay immediate. A separate resource incident has a redacted tag_name because the app put tag in redactFields. Explain how to handle both safely.",
63560
+ expected_behavior: [
63561
+ "Inspect bundle evidence first, including passive CSP disposition, resource timing status, recovery observations, and unloaded teardown state.",
63562
+ "Recommend a scoped threshold rule (or resource_threshold suggestion) for transient /assets/ failures instead of broad demote/drop or whole-host suppression, paired with a higher-specificity allow carve-out for /assets/checkout-.",
63563
+ "Recommend moving narrow private domain keys such as tag to exact-key redactExactFields alongside a protected SDK release so protocol fields like tag_name stay intact."
63564
+ ]
63565
+ },
63276
63566
  {
63277
63567
  name: "protected_resource_noise_review",
63278
63568
  prompt: "A checkout TypeError has related GTM evidence. Separate incidents show Google sign-in and an unknown script failing. The user asks whether ignoring all Google or third-party hosts would clean this up.",
@@ -66629,7 +66919,7 @@ async function pruneExpiredArtifactsInDirectory(directoryPath, now, olderThanMs,
66629
66919
  }
66630
66920
  throw error62;
66631
66921
  }
66632
- const counts = await Promise.all(
66922
+ const counts2 = await Promise.all(
66633
66923
  fileNames.map(async (fileName) => {
66634
66924
  if (fileName === "reproductions") {
66635
66925
  return { removed: 0, retained: 0 };
@@ -66656,7 +66946,7 @@ async function pruneExpiredArtifactsInDirectory(directoryPath, now, olderThanMs,
66656
66946
  return { removed: 1, retained: 0 };
66657
66947
  })
66658
66948
  );
66659
- return counts.reduce(
66949
+ return counts2.reduce(
66660
66950
  (summary2, count6) => ({
66661
66951
  removed: summary2.removed + count6.removed,
66662
66952
  retained: summary2.retained + count6.retained
@@ -71431,6 +71721,18 @@ function buildDependenciesContext(incident, errorContext, requestContext) {
71431
71721
  ]
71432
71722
  };
71433
71723
  }
71724
+ function formatPassiveRecoveryNote(recoveryContext) {
71725
+ if (recoveryContext === void 0 || recoveryContext.outcome === "unknown") {
71726
+ return "";
71727
+ }
71728
+ if (recoveryContext.outcome === "recovered") {
71729
+ return " Explicit application recovery was later observed within the failure scope; incident status remains unchanged.";
71730
+ }
71731
+ if (recoveryContext.outcome === "persisted") {
71732
+ return " An explicit persistent-failure observation was later recorded within the failure scope.";
71733
+ }
71734
+ return " Conflicting recovery and persistent-failure observations were recorded within the failure scope.";
71735
+ }
71434
71736
  function buildSummaryGuidance(input3) {
71435
71737
  if (input3.errorContext === null) {
71436
71738
  return {
@@ -71441,10 +71743,11 @@ function buildSummaryGuidance(input3) {
71441
71743
  }
71442
71744
  if (input3.opaqueBrowserError) {
71443
71745
  if (input3.browserEvent?.kind === "resource_error") {
71746
+ const recoveryNote = formatPassiveRecoveryNote(input3.recoveryContext);
71444
71747
  const recoveryFailure = input3.resourceContext?.recovery_failures?.[0];
71445
71748
  if (recoveryFailure !== void 0) {
71446
71749
  return {
71447
- likely_cause: `The browser resource failure was followed by ${recoveryFailure.method} ${recoveryFailure.path} returning HTTP ${recoveryFailure.status_code}. This correlated recovery failure is the most actionable captured signal; it does not establish why the original resource load was interrupted.`,
71750
+ likely_cause: `The browser resource failure was followed by ${recoveryFailure.method} ${recoveryFailure.path} returning HTTP ${recoveryFailure.status_code}. This correlated recovery failure is the most actionable captured signal; it does not establish why the original resource load was interrupted.${recoveryNote}`,
71448
71751
  confidence: 0.65,
71449
71752
  recommended_action: `Inspect the ${recoveryFailure.path} recovery route and its HTTP ${recoveryFailure.status_code} response, including any refresh, retry, or signed-URL handling, before investigating the generic resource error.`
71450
71753
  };
@@ -71452,14 +71755,60 @@ function buildSummaryGuidance(input3) {
71452
71755
  if (input3.resourceContext?.interruption !== void 0) {
71453
71756
  const interruption = input3.resourceContext.interruption;
71454
71757
  return {
71455
- likely_cause: `The browser reported an opaque ${interruption.rel} failure while the page was ${interruption.visibility_state} and ${interruption.ready_state}. This is consistent with a browser-aborted speculative load, but the captured lifecycle state does not prove the cause.`,
71758
+ likely_cause: `The browser reported an opaque ${interruption.rel} failure while the page was ${interruption.visibility_state} and ${interruption.ready_state}. This is consistent with a browser-aborted speculative load, but the captured lifecycle state does not prove the cause.${recoveryNote}`,
71456
71759
  confidence: 0.55,
71457
71760
  recommended_action: "Confirm whether the page was navigating or suspended, then review only lifecycle-scoped demotion if the asset succeeds during active page loads."
71458
71761
  };
71459
71762
  }
71763
+ const observationItems = input3.resourceObservations?.items ?? [];
71764
+ const enforcedCspDirectives = Array.from(
71765
+ new Set(
71766
+ observationItems.flatMap(
71767
+ ({ observation }) => observation.kind === "csp" && observation.disposition === "enforce" ? [observation.effective_directive] : []
71768
+ )
71769
+ )
71770
+ ).sort();
71771
+ if (enforcedCspDirectives.length > 0) {
71772
+ const directiveLabel = enforcedCspDirectives.join(", ");
71773
+ return {
71774
+ likely_cause: `An enforced Content Security Policy observation (${directiveLabel}) was captured alongside this resource failure. Temporal association does not prove causation, and document HTTP status is separate from resource status.${recoveryNote}`,
71775
+ confidence: 0.55,
71776
+ recommended_action: `Review the enforced ${directiveLabel} Content Security Policy directive for the affected resource host and confirm whether the asset should be permitted.`
71777
+ };
71778
+ }
71779
+ const observedFailureStatuses = Array.from(
71780
+ new Set(
71781
+ observationItems.flatMap(
71782
+ ({ observation }) => observation.kind === "timing" && observation.availability === "observed" && observation.response_status !== null && observation.response_status >= 400 ? [observation.response_status] : []
71783
+ )
71784
+ )
71785
+ ).sort((left, right) => left - right);
71786
+ if (observedFailureStatuses.length > 0) {
71787
+ const statusLabel = observedFailureStatuses.map((code) => `HTTP ${code}`).join(", ");
71788
+ return {
71789
+ likely_cause: `Passive resource timing observed ${statusLabel} for a matching resource load around this failure. Association is passive and does not prove the root cause.${recoveryNote}`,
71790
+ confidence: 0.55,
71791
+ recommended_action: `Check server or CDN availability, permissions, and asset deployment for the affected resource returning ${statusLabel}.`
71792
+ };
71793
+ }
71794
+ const reportOnlyCspDirectives = Array.from(
71795
+ new Set(
71796
+ observationItems.flatMap(
71797
+ ({ observation }) => observation.kind === "csp" && observation.disposition === "report" ? [observation.effective_directive] : []
71798
+ )
71799
+ )
71800
+ ).sort();
71460
71801
  const resource = describeBrowserResource(input3.browserEvent);
71802
+ if (reportOnlyCspDirectives.length > 0) {
71803
+ const directiveLabel = reportOnlyCspDirectives.join(", ");
71804
+ return {
71805
+ likely_cause: `A report-only Content Security Policy observation (${directiveLabel}) was captured alongside this resource failure. Report-only policies do not block resource loads, so the cause and application impact remain unknown.${recoveryNote}`,
71806
+ confidence: 0.35,
71807
+ recommended_action: "Check the affected resource and routes, browser network failures, CSP and provider availability." + (resource?.optional_candidate === true ? " If the dependency is optional for your app, review a resource-scoped noise rule." : " Verify whether application functionality is affected.")
71808
+ };
71809
+ }
71461
71810
  return {
71462
- likely_cause: browserResourceDiagnosis(resource),
71811
+ likely_cause: `${browserResourceDiagnosis(resource)}${recoveryNote}`,
71463
71812
  confidence: 0.35,
71464
71813
  recommended_action: "Check the affected resource and routes, browser network failures, CSP and provider availability." + (resource?.optional_candidate === true ? " If the dependency is optional for your app, review a resource-scoped noise rule." : " Verify whether application functionality is affected.")
71465
71814
  };
@@ -71714,7 +72063,8 @@ function buildBundle(input3) {
71714
72063
  const primaryService = primarySignalEnvelope?.event_type === "probe_event" ? void 0 : primarySignalEnvelope?.service;
71715
72064
  const serviceRuntime = primaryService?.runtime ?? input3.incident.service_runtime ?? selectLatestEnvelope(sourceEnvelopes, (envelope) => envelope.event_type !== "probe_event")?.service.runtime ?? null;
71716
72065
  const serviceFramework = primaryService?.framework ?? input3.incident.service_framework ?? selectLatestEnvelope(sourceEnvelopes, (envelope) => envelope.event_type !== "probe_event")?.service.framework ?? null;
71717
- const customerVisible = frontendContext !== null;
72066
+ const hiddenOrUnloadedOpaqueResourceError = opaqueBrowserError && browserEvent?.kind === "resource_error" && (browserEvent.page?.visibility_state === "hidden" || browserEvent.page?.visibility_state === "prerender" || browserEvent.page?.visibility_state === "unloaded");
72067
+ const customerVisible = frontendContext !== null && !hiddenOrUnloadedOpaqueResourceError;
71718
72068
  const firstApplicationFrame = opaqueBrowserError ? null : deriveFirstApplicationFrame(errorContext);
71719
72069
  const summaryGuidance = buildSummaryGuidance({
71720
72070
  errorContext,
@@ -71724,7 +72074,9 @@ function buildBundle(input3) {
71724
72074
  firstApplicationFrame,
71725
72075
  browserEvent,
71726
72076
  opaqueBrowserError,
71727
- resourceContext
72077
+ resourceContext,
72078
+ ...diagnostics.resources === void 0 ? {} : { resourceObservations: diagnostics.resources },
72079
+ ...diagnostics.recovery === void 0 ? {} : { recoveryContext: diagnostics.recovery }
71728
72080
  });
71729
72081
  const candidate = {
71730
72082
  bundle_version: 1,
@@ -72658,7 +73010,7 @@ async function processCommand(input3, dependencies = {}) {
72658
73010
  aggregate.newEvents.push(event);
72659
73011
  aggregate.signalEventTypes.add(event.event_type);
72660
73012
  const traceId = getTraceId(event);
72661
- if (traceId !== null && normalizedEvent.resource_type === void 0) {
73013
+ if (traceId !== null && normalizedEvent.browser_event_kind !== "resource_error") {
72662
73014
  aggregate.traceIds.add(traceId);
72663
73015
  const traceKey = buildTraceCorrelationKey(projectId, event.service.environment, traceId);
72664
73016
  const traceCorrelationGroup = traceCorrelationGroups.get(traceKey) ?? {
@@ -81242,7 +81594,9 @@ var CLI_USAGE_LINES = [
81242
81594
  " debugbundle organization accept-invite|accept-transfer (use the verified email link)",
81243
81595
  " debugbundle offers programmes|creator|customer [--json]",
81244
81596
  " debugbundle offers join --version <uuid> --accept-terms-version <version> [--json]",
81245
- " debugbundle offers code --code <custom-code> [--json]",
81597
+ " debugbundle offers code --code <custom-code> [--expected-code <current-branded-code>] [--json]",
81598
+ " debugbundle offers creator_code_status [--json]",
81599
+ " debugbundle offers creator_analytics [--days <7|30|90>] [--json]",
81246
81600
  " debugbundle offers payout_policy|payout_preferences [--json]",
81247
81601
  " debugbundle offers save_payout_preferences --input <private-0600-json-file> [--json]",
81248
81602
  " debugbundle offers payout_balances|prepare_payout|payout_instructions --input <json-file> [--json] # billing payout operators",
@@ -81290,8 +81644,8 @@ var CLI_USAGE_LINES = [
81290
81644
  " debugbundle capture-rule list --project-id <id> [--auth-file <path>] [--json]",
81291
81645
  " debugbundle capture-rule suggest <incident-id> [--auth-file <path>] [--json]",
81292
81646
  " debugbundle capture-rule create-from-suggestion <incident-id> --suggestion-id <id> [--name <name>] [--description <text>] [--enabled <true|false>] [--expires-at <ISO8601>] [--auth-file <path>] [--json]",
81293
- " debugbundle capture-rule create --project-id <id> --name <name> --action <demote|sample|drop> --matcher-json <json> [--description <text>] [--enabled <true|false>] [--sample-rate <0-1>] [--sample-event-class <preserve|context>] [--expires-at <ISO8601>] [--auth-file <path>] [--json]",
81294
- " debugbundle capture-rule update <rule-id> --project-id <id> [--name <name>] [--description <text>] [--enabled <true|false>] [--action <demote|sample|drop>] [--matcher-json <json>] [--sample-rate <0-1>] [--sample-event-class <preserve|context>] [--expires-at <ISO8601|null>] [--project-scope <current_project>] [--auth-file <path>] [--json]",
81647
+ " debugbundle capture-rule create --project-id <id> --name <name> --action <demote|sample|drop|threshold|allow> --matcher-json <json> [--description <text>] [--enabled <true|false>] [--sample-rate <0-1>] [--sample-event-class <preserve|context>] [--threshold-count <2-1000>] [--threshold-window-seconds <60-86400>] [--threshold-group-by <resource|fingerprint>] [--expires-at <ISO8601>] [--auth-file <path>] [--json]",
81648
+ " debugbundle capture-rule update <rule-id> --project-id <id> [--name <name>] [--description <text>] [--enabled <true|false>] [--action <demote|sample|drop|threshold|allow>] [--matcher-json <json>] [--sample-rate <0-1>] [--sample-event-class <preserve|context>] [--threshold-count <2-1000>] [--threshold-window-seconds <60-86400>] [--threshold-group-by <resource|fingerprint>] [--expires-at <ISO8601|null>] [--project-scope <current_project>] [--auth-file <path>] [--json]",
81295
81649
  " debugbundle capture-rule delete <rule-id> --project-id <id> [--auth-file <path>] [--json]",
81296
81650
  " debugbundle improvements list [--project-id <id>] [--environment <name>] [--service <name>] [--status <status>] [--severity <level>] [--kind <kind>] [--cursor <cursor>] [--limit <n>] [--auth-file <path>] [--json]",
81297
81651
  " debugbundle improvements get <improvement-id> [--auth-file <path>] [--json]",
@@ -87872,7 +88226,7 @@ function createCaptureRuleApi(httpClient) {
87872
88226
  async listCaptureRules(input3) {
87873
88227
  const response = await httpClient.request({
87874
88228
  method: "GET",
87875
- path: `/v1/projects/${encodeURIComponent(input3.projectId)}/capture-rules`,
88229
+ path: `/v1/projects/${encodeURIComponent(input3.projectId)}/capture-rules?rule_schema=2`,
87876
88230
  bearerToken: input3.bearerToken
87877
88231
  });
87878
88232
  if (response.status !== 200) {
@@ -87903,7 +88257,7 @@ function createCaptureRuleApi(httpClient) {
87903
88257
  async suggestCaptureRulesFromIncident(input3) {
87904
88258
  const response = await httpClient.request({
87905
88259
  method: "POST",
87906
- path: `/v1/incidents/${encodeURIComponent(input3.incidentId)}/capture-rule-suggestion`,
88260
+ path: `/v1/incidents/${encodeURIComponent(input3.incidentId)}/capture-rule-suggestion?rule_schema=2`,
87907
88261
  bearerToken: input3.bearerToken
87908
88262
  });
87909
88263
  if (response.status !== 200) {
@@ -87918,12 +88272,16 @@ function createCaptureRuleApi(httpClient) {
87918
88272
  async createCaptureRuleFromIncidentSuggestion(input3) {
87919
88273
  const response = await httpClient.request({
87920
88274
  method: "POST",
87921
- path: `/v1/incidents/${encodeURIComponent(input3.incidentId)}/capture-rules`,
88275
+ path: `/v1/incidents/${encodeURIComponent(input3.incidentId)}/capture-rules?rule_schema=2`,
87922
88276
  bearerToken: input3.bearerToken,
87923
88277
  body: input3.create
87924
88278
  });
87925
88279
  if (response.status !== 200 && response.status !== 201) {
87926
- throw toApiError10(response.status, response.body, "Failed to create capture rule from suggestion.");
88280
+ throw toApiError10(
88281
+ response.status,
88282
+ response.body,
88283
+ "Failed to create capture rule from suggestion."
88284
+ );
87927
88285
  }
87928
88286
  const parsed = CaptureRuleResponseSchema.safeParse(response.body);
87929
88287
  if (!parsed.success) {
@@ -87995,7 +88353,11 @@ function formatMatcherFromValue(matcher) {
87995
88353
  if (matcher.browser_event_opaque !== void 0) {
87996
88354
  parts.push(`browser_event_opaque=${String(matcher.browser_event_opaque)}`);
87997
88355
  }
87998
- for (const key of ["browser_page_visibility_state", "browser_page_ready_state", "browser_target_tag_name"]) {
88356
+ for (const key of [
88357
+ "browser_page_visibility_state",
88358
+ "browser_page_ready_state",
88359
+ "browser_target_tag_name"
88360
+ ]) {
87999
88361
  if (matcher[key] !== void 0) parts.push(`${key}=${matcher[key]}`);
88000
88362
  }
88001
88363
  if (matcher.browser_target_attributes !== void 0) {
@@ -88025,9 +88387,20 @@ function formatMatcherFromValue(matcher) {
88025
88387
  if (matcher.resource_url?.host !== void 0) {
88026
88388
  parts.push(`resource_host=${matcher.resource_url.host}`);
88027
88389
  }
88390
+ if (matcher.resource_url?.host_suffix !== void 0) {
88391
+ parts.push(`resource_host_suffix=${matcher.resource_url.host_suffix}`);
88392
+ }
88028
88393
  if (matcher.resource_url?.path_equals !== void 0) {
88029
88394
  parts.push(`resource_path=${matcher.resource_url.path_equals}`);
88030
88395
  }
88396
+ if (matcher.resource_url?.path_prefix !== void 0) {
88397
+ parts.push(`resource_path_prefix=${matcher.resource_url.path_prefix}`);
88398
+ }
88399
+ if (matcher.resource_urls !== void 0 && matcher.resource_urls.length > 0) {
88400
+ parts.push(
88401
+ `resource_urls=${matcher.resource_urls.map((entry) => `${entry.host}${entry.path_equals}`).join(",")}`
88402
+ );
88403
+ }
88031
88404
  if (matcher.request_url?.path_equals !== void 0) {
88032
88405
  parts.push(`request_path=${matcher.request_url.path_equals}`);
88033
88406
  }
@@ -88043,7 +88416,7 @@ function formatMatcher(rule) {
88043
88416
  return formatMatcherFromValue(rule.matcher);
88044
88417
  }
88045
88418
  function formatRule(rule) {
88046
- const action = rule.action === "sample" ? `${rule.action}:${rule.sample_rate ?? "?"}:${rule.sample_event_class ?? "?"}` : rule.action;
88419
+ const action = rule.action === "sample" ? `${rule.action}:${rule.sample_rate ?? "?"}:${rule.sample_event_class ?? "?"}` : rule.action === "threshold" ? `${rule.action}:${rule.threshold_count ?? "?"}/${rule.threshold_window_seconds ?? "?"}s:${rule.threshold_group_by ?? "?"}` : rule.action;
88047
88420
  return [
88048
88421
  `${rule.enabled ? "enabled" : "disabled"} ${rule.id} ${action} ${rule.name}`,
88049
88422
  formatMatcher(rule)
@@ -88749,6 +89122,9 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
88749
89122
  "matcher-json",
88750
89123
  "sample-rate",
88751
89124
  "sample-event-class",
89125
+ "threshold-count",
89126
+ "threshold-window-seconds",
89127
+ "threshold-group-by",
88752
89128
  "expires-at"
88753
89129
  ]);
88754
89130
  ensureNoExtraPositionals(parsedArgv, 2);
@@ -88764,7 +89140,7 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
88764
89140
  if (actionValue === void 0) {
88765
89141
  throw new CliInputError("Missing required option --action.");
88766
89142
  }
88767
- if (actionValue !== "demote" && actionValue !== "sample" && actionValue !== "drop") {
89143
+ if (actionValue !== "demote" && actionValue !== "sample" && actionValue !== "drop" && actionValue !== "threshold" && actionValue !== "allow") {
88768
89144
  throw new CliInputError("Invalid value for --action.");
88769
89145
  }
88770
89146
  const matcher = readJsonOption(parsedArgv, "matcher-json");
@@ -88782,6 +89158,9 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
88782
89158
  matcher,
88783
89159
  sample_rate: null,
88784
89160
  sample_event_class: null,
89161
+ threshold_count: null,
89162
+ threshold_window_seconds: null,
89163
+ threshold_group_by: null,
88785
89164
  created_by_user_id: null,
88786
89165
  created_from_incident_id: null,
88787
89166
  created_from_event_id: null,
@@ -88802,6 +89181,29 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
88802
89181
  }
88803
89182
  create.sample_event_class = sampleEventClass;
88804
89183
  }
89184
+ const thresholdCount = readStringOption(parsedArgv, "threshold-count");
89185
+ if (thresholdCount !== void 0) {
89186
+ const parsed = Number(thresholdCount);
89187
+ if (!Number.isInteger(parsed)) {
89188
+ throw new CliInputError("Invalid value for --threshold-count.");
89189
+ }
89190
+ create.threshold_count = parsed;
89191
+ }
89192
+ const thresholdWindowSeconds = readStringOption(parsedArgv, "threshold-window-seconds");
89193
+ if (thresholdWindowSeconds !== void 0) {
89194
+ const parsed = Number(thresholdWindowSeconds);
89195
+ if (!Number.isInteger(parsed)) {
89196
+ throw new CliInputError("Invalid value for --threshold-window-seconds.");
89197
+ }
89198
+ create.threshold_window_seconds = parsed;
89199
+ }
89200
+ const thresholdGroupBy = readStringOption(parsedArgv, "threshold-group-by");
89201
+ if (thresholdGroupBy !== void 0) {
89202
+ if (thresholdGroupBy !== "resource" && thresholdGroupBy !== "fingerprint") {
89203
+ throw new CliInputError("Invalid value for --threshold-group-by.");
89204
+ }
89205
+ create.threshold_group_by = thresholdGroupBy;
89206
+ }
88805
89207
  return await (dependencies.createCaptureRuleCommand ?? createCaptureRuleWithAuthCommand)(
88806
89208
  appendCommonAuthOptions(parsedArgv, { projectId, create })
88807
89209
  );
@@ -88818,6 +89220,9 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
88818
89220
  "matcher-json",
88819
89221
  "sample-rate",
88820
89222
  "sample-event-class",
89223
+ "threshold-count",
89224
+ "threshold-window-seconds",
89225
+ "threshold-group-by",
88821
89226
  "expires-at",
88822
89227
  "project-scope"
88823
89228
  ]);
@@ -88847,7 +89252,7 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
88847
89252
  }
88848
89253
  const actionValue = readStringOption(parsedArgv, "action");
88849
89254
  if (actionValue !== void 0) {
88850
- if (actionValue !== "demote" && actionValue !== "sample" && actionValue !== "drop") {
89255
+ if (actionValue !== "demote" && actionValue !== "sample" && actionValue !== "drop" && actionValue !== "threshold" && actionValue !== "allow") {
88851
89256
  throw new CliInputError("Invalid value for --action.");
88852
89257
  }
88853
89258
  update["action"] = actionValue;
@@ -88874,6 +89279,29 @@ async function handleCaptureRuleCommand(parsedArgv, dependencies) {
88874
89279
  }
88875
89280
  update["sample_event_class"] = sampleEventClass;
88876
89281
  }
89282
+ const thresholdCount = readStringOption(parsedArgv, "threshold-count");
89283
+ if (thresholdCount !== void 0) {
89284
+ const parsed = Number(thresholdCount);
89285
+ if (!Number.isInteger(parsed)) {
89286
+ throw new CliInputError("Invalid value for --threshold-count.");
89287
+ }
89288
+ update["threshold_count"] = parsed;
89289
+ }
89290
+ const thresholdWindowSeconds = readStringOption(parsedArgv, "threshold-window-seconds");
89291
+ if (thresholdWindowSeconds !== void 0) {
89292
+ const parsed = Number(thresholdWindowSeconds);
89293
+ if (!Number.isInteger(parsed)) {
89294
+ throw new CliInputError("Invalid value for --threshold-window-seconds.");
89295
+ }
89296
+ update["threshold_window_seconds"] = parsed;
89297
+ }
89298
+ const thresholdGroupBy = readStringOption(parsedArgv, "threshold-group-by");
89299
+ if (thresholdGroupBy !== void 0) {
89300
+ if (thresholdGroupBy !== "resource" && thresholdGroupBy !== "fingerprint") {
89301
+ throw new CliInputError("Invalid value for --threshold-group-by.");
89302
+ }
89303
+ update["threshold_group_by"] = thresholdGroupBy;
89304
+ }
88877
89305
  const expiresAt = readStringOption(parsedArgv, "expires-at");
88878
89306
  if (expiresAt !== void 0) {
88879
89307
  update["expires_at"] = expiresAt === "null" ? null : expiresAt;
@@ -90676,7 +91104,7 @@ async function handleCaptureRuleCommand2(parsedArgv, dependencies) {
90676
91104
  // package.json
90677
91105
  var package_default = {
90678
91106
  name: "@debugbundle/cli",
90679
- version: "1.28.0",
91107
+ version: "1.30.0",
90680
91108
  private: false,
90681
91109
  description: "Command-line interface for DebugBundle",
90682
91110
  license: "Apache-2.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@debugbundle/cli",
3
- "version": "1.28.0",
3
+ "version": "1.30.0",
4
4
  "private": false,
5
5
  "description": "Command-line interface for DebugBundle",
6
6
  "license": "Apache-2.0",