@debugbundle/mcp 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.cjs CHANGED
@@ -14475,6 +14475,7 @@ var AlertSchema = external_exports.object({
14475
14475
  channel: AlertChannelSchema,
14476
14476
  condition_type: AlertConditionTypeSchema,
14477
14477
  severity_min: external_exports.enum(["low", "medium", "high", "critical"]).nullable(),
14478
+ cooldown_seconds: external_exports.number().int().min(0),
14478
14479
  config: external_exports.record(external_exports.string(), external_exports.unknown()),
14479
14480
  is_enabled: external_exports.boolean(),
14480
14481
  created_at: external_exports.string(),
@@ -14561,6 +14562,9 @@ function createAlertApi(client) {
14561
14562
  if (input.severityMin !== void 0) {
14562
14563
  body.severity_min = input.severityMin;
14563
14564
  }
14565
+ if (input.cooldownSeconds !== void 0) {
14566
+ body.cooldown_seconds = input.cooldownSeconds;
14567
+ }
14564
14568
  if (input.isEnabled !== void 0) {
14565
14569
  body.is_enabled = input.isEnabled;
14566
14570
  }
@@ -14587,6 +14591,9 @@ function createAlertApi(client) {
14587
14591
  if (input.severityMin !== void 0) {
14588
14592
  body.severity_min = input.severityMin;
14589
14593
  }
14594
+ if (input.cooldownSeconds !== void 0) {
14595
+ body.cooldown_seconds = input.cooldownSeconds;
14596
+ }
14590
14597
  if (input.config !== void 0) {
14591
14598
  body.config = input.config;
14592
14599
  }
@@ -14621,8 +14628,22 @@ var BillingUsageMetricSchema = external_exports.object({
14621
14628
  used: external_exports.number().int().nonnegative(),
14622
14629
  limit: external_exports.number().int().nonnegative()
14623
14630
  }).strict();
14631
+ var BillingStateSchema = external_exports.enum(["active", "past_due", "canceled", "unpaid", "incomplete", "admin_override", "trialing", "trial_expired"]).nullable();
14632
+ var BillingTrialPlanSchema = external_exports.enum(["solo", "team"]);
14633
+ var BillingTrialSummarySchema = external_exports.object({
14634
+ available: external_exports.boolean(),
14635
+ active: external_exports.boolean(),
14636
+ plan: BillingTrialPlanSchema.nullable(),
14637
+ started_at: external_exports.string().nullable(),
14638
+ ends_at: external_exports.string().nullable(),
14639
+ used_at: external_exports.string().nullable(),
14640
+ converted_at: external_exports.string().nullable(),
14641
+ expired_at: external_exports.string().nullable(),
14642
+ days_remaining: external_exports.number().int().nullable()
14643
+ }).strict();
14624
14644
  var BillingSummarySchema = external_exports.object({
14625
14645
  plan: external_exports.enum(["free", "solo", "team"]),
14646
+ billing_state: BillingStateSchema,
14626
14647
  stripe_customer_id: external_exports.string().nullable(),
14627
14648
  active_projects: external_exports.number().int().nonnegative(),
14628
14649
  capacity_units: external_exports.object({
@@ -14646,7 +14667,8 @@ var BillingSummarySchema = external_exports.object({
14646
14667
  monthly_remote_activations: BillingUsageMetricSchema,
14647
14668
  monthly_alert_deliveries: BillingUsageMetricSchema,
14648
14669
  monthly_webhook_deliveries: BillingUsageMetricSchema
14649
- }).strict()
14670
+ }).strict(),
14671
+ trial: BillingTrialSummarySchema
14650
14672
  }).strict();
14651
14673
  var BillingSummaryResponseSchema = external_exports.object({
14652
14674
  billing: BillingSummarySchema
@@ -14692,6 +14714,18 @@ function createBillingApi(client) {
14692
14714
  })
14693
14715
  );
14694
14716
  },
14717
+ async startTrial(input) {
14718
+ return expectBilling(
14719
+ client.request({
14720
+ method: "POST",
14721
+ path: "/v1/billing/trial/start",
14722
+ bearerToken: input.bearerToken,
14723
+ body: {
14724
+ target_plan: input.targetPlan
14725
+ }
14726
+ })
14727
+ );
14728
+ },
14695
14729
  async increaseCapacity(input) {
14696
14730
  return expectBilling(
14697
14731
  client.request({
@@ -17117,8 +17151,24 @@ var BrowserExceptionEventSchema = external_exports.object({
17117
17151
  column_number: external_exports.number().int().nonnegative().nullable(),
17118
17152
  target: external_exports.object({
17119
17153
  tag_name: external_exports.string().nullable(),
17120
- source_url: external_exports.string().nullable()
17121
- }).nullable(),
17154
+ source_url: external_exports.string().nullable(),
17155
+ attributes: external_exports.object({
17156
+ rel: external_exports.string().optional(),
17157
+ as: external_exports.string().optional(),
17158
+ type: external_exports.string().optional(),
17159
+ media: external_exports.string().optional(),
17160
+ cross_origin: external_exports.string().optional(),
17161
+ async: external_exports.boolean().optional(),
17162
+ defer: external_exports.boolean().optional(),
17163
+ integrity_present: external_exports.boolean().optional()
17164
+ }).strict().optional()
17165
+ }).strict().nullable(),
17166
+ page: external_exports.object({
17167
+ url: external_exports.string().nullable(),
17168
+ referrer: external_exports.string().nullable(),
17169
+ ready_state: external_exports.enum(["loading", "interactive", "complete"]).nullable(),
17170
+ visibility_state: external_exports.enum(["visible", "hidden", "prerender", "unloaded"]).nullable()
17171
+ }).strict().optional(),
17122
17172
  opaque: external_exports.boolean()
17123
17173
  }).strict();
17124
17174
  var FrontendExceptionPayloadSchema = external_exports.object({
@@ -17546,10 +17596,11 @@ function buildSkill() {
17546
17596
  "When the user reports a bug, runtime failure, production incident, regression, broken deploy, or unknown error, start here before reading arbitrary source files.",
17547
17597
  "",
17548
17598
  "1. Run `debugbundle doctor --json` to learn whether the project is local-only or connected and whether the local scaffold is healthy.",
17549
- "2. List actionable failures with `debugbundle incidents --source local --status open --json` for local data, or `debugbundle incidents --source cloud --status open --json` when the issue came from a hosted environment.",
17550
- "3. Inspect the chosen incident with `debugbundle inspect <incident-id> --source <local|cloud> --json` and `debugbundle explain <incident-id> --source <local|cloud> --json`.",
17551
- "4. Fetch evidence before editing code: `debugbundle bundle <incident-id> --source <local|cloud> --json` and `debugbundle reproduce <incident-id> --source <local|cloud> --json`.",
17552
- "5. If local SDK or relay events have landed but no bundle exists yet, run `debugbundle process --preset <minimal|balanced|investigative> --json` and then list incidents again.",
17599
+ "2. If `debugbundle doctor --json` reports `mode=local-only`, start with `debugbundle incidents --source local --status open --json`.",
17600
+ "3. If `debugbundle doctor --json` reports `mode=connected` and the target environment is cloud-enabled, check both `debugbundle incidents --source local --status open --json` and `debugbundle incidents --source cloud --status open --json` unless the user explicitly scoped the issue to local-only development. For user-reported production incidents, check cloud incidents after local incidents and explicitly report whether each source had matches.",
17601
+ "4. Inspect the chosen incident with `debugbundle inspect <incident-id> --source <local|cloud> --json` and `debugbundle explain <incident-id> --source <local|cloud> --json`.",
17602
+ "5. Fetch evidence before editing code: `debugbundle bundle <incident-id> --source <local|cloud> --json` and `debugbundle reproduce <incident-id> --source <local|cloud> --json`.",
17603
+ "6. If local SDK or relay events have landed but no bundle exists yet, run `debugbundle process --preset <minimal|balanced|investigative> --json` and then list incidents again.",
17553
17604
  "",
17554
17605
  "Key local paths:",
17555
17606
  "- `.debugbundle/profile.json` \u2014 project map, service paths, and validation state",
@@ -17834,7 +17885,8 @@ function buildSkillEvals() {
17834
17885
  name: "connected_incident_fetch",
17835
17886
  prompt: "The user says a production incident fired in the hosted DebugBundle project. Confirm the skill points the agent to the cloud retrieval path.",
17836
17887
  expected_behavior: [
17837
- "List cloud open incidents or use MCP list_incidents with source cloud.",
17888
+ "Check both local and cloud incident sources when the project is connected and the environment is cloud-enabled.",
17889
+ "Explicitly report whether the local source, the cloud source, or both had matches.",
17838
17890
  "Fetch inspect, context, bundle, and reproduction artifacts before editing code."
17839
17891
  ]
17840
17892
  }
@@ -20046,7 +20098,7 @@ var DEFAULT_PROCESSING_TIMEOUT_MS = 5 * 60 * 1e3;
20046
20098
  // ../../packages/storage/src/schema-migrations.ts
20047
20099
  var import_node_crypto3 = require("node:crypto");
20048
20100
 
20049
- // ../../packages/storage/src/migrations.ts
20101
+ // ../../packages/storage/src/storage-bootstrap-statements.ts
20050
20102
  var STORAGE_BOOTSTRAP_STATEMENTS = [
20051
20103
  `
20052
20104
  CREATE TABLE users (
@@ -20078,7 +20130,22 @@ var STORAGE_BOOTSTRAP_STATEMENTS = [
20078
20130
  billing_period_ends_at timestamptz,
20079
20131
  last_billing_sync_at timestamptz,
20080
20132
  last_billing_event_id text,
20081
- billing_period_starts_at timestamptz
20133
+ billing_period_starts_at timestamptz,
20134
+ trial_plan text CHECK (trial_plan IN ('solo', 'team') OR trial_plan IS NULL),
20135
+ trial_started_at timestamptz,
20136
+ trial_ends_at timestamptz,
20137
+ trial_used_at timestamptz,
20138
+ trial_converted_at timestamptz,
20139
+ trial_expired_at timestamptz,
20140
+ CONSTRAINT organizations_trial_window_check CHECK (
20141
+ trial_started_at IS NULL
20142
+ OR trial_ends_at IS NULL
20143
+ OR trial_ends_at > trial_started_at
20144
+ ),
20145
+ CONSTRAINT organizations_trial_started_requires_plan_check CHECK (
20146
+ trial_started_at IS NULL
20147
+ OR trial_plan IS NOT NULL
20148
+ )
20082
20149
  )
20083
20150
  `,
20084
20151
  `
@@ -20638,6 +20705,7 @@ var STORAGE_BOOTSTRAP_STATEMENTS = [
20638
20705
  channel text NOT NULL,
20639
20706
  condition_type text NOT NULL,
20640
20707
  severity_min text,
20708
+ cooldown_seconds integer NOT NULL DEFAULT 0,
20641
20709
  config jsonb NOT NULL DEFAULT '{}'::jsonb,
20642
20710
  is_enabled boolean NOT NULL DEFAULT true,
20643
20711
  created_at timestamptz NOT NULL DEFAULT now(),
@@ -20676,6 +20744,7 @@ var STORAGE_BOOTSTRAP_STATEMENTS = [
20676
20744
  incident_id uuid NOT NULL REFERENCES incidents(id) ON DELETE CASCADE,
20677
20745
  condition_type text NOT NULL,
20678
20746
  dedupe_key text NOT NULL,
20747
+ notification_key text NOT NULL DEFAULT '',
20679
20748
  channel text NOT NULL,
20680
20749
  status text NOT NULL,
20681
20750
  payload jsonb NOT NULL,
@@ -20690,6 +20759,10 @@ var STORAGE_BOOTSTRAP_STATEMENTS = [
20690
20759
  CREATE INDEX alert_deliveries_project_status_idx
20691
20760
  ON alert_deliveries (project_id, status, created_at DESC)
20692
20761
  `,
20762
+ `
20763
+ CREATE INDEX alert_deliveries_alert_notification_idx
20764
+ ON alert_deliveries (alert_id, notification_key, created_at DESC)
20765
+ `,
20693
20766
  `
20694
20767
  CREATE TABLE alert_email_digests (
20695
20768
  id uuid PRIMARY KEY,
@@ -20722,6 +20795,7 @@ var STORAGE_BOOTSTRAP_STATEMENTS = [
20722
20795
  incident_id uuid NOT NULL REFERENCES incidents(id) ON DELETE CASCADE,
20723
20796
  condition_type text NOT NULL,
20724
20797
  dedupe_key text NOT NULL,
20798
+ notification_key text NOT NULL DEFAULT '',
20725
20799
  payload jsonb NOT NULL,
20726
20800
  created_at timestamptz NOT NULL DEFAULT now(),
20727
20801
  UNIQUE (alert_id, incident_id, dedupe_key)
@@ -20731,6 +20805,10 @@ var STORAGE_BOOTSTRAP_STATEMENTS = [
20731
20805
  CREATE INDEX alert_email_digest_items_digest_created_idx
20732
20806
  ON alert_email_digest_items (digest_id, created_at ASC)
20733
20807
  `,
20808
+ `
20809
+ CREATE INDEX alert_email_digest_items_alert_notification_idx
20810
+ ON alert_email_digest_items (alert_id, notification_key, created_at DESC)
20811
+ `,
20734
20812
  `
20735
20813
  CREATE TABLE agent_webhooks (
20736
20814
  id uuid PRIMARY KEY,
@@ -20782,6 +20860,19 @@ var STORAGE_BOOTSTRAP_STATEMENTS = [
20782
20860
  processed_at timestamptz NOT NULL DEFAULT now()
20783
20861
  )
20784
20862
  `,
20863
+ `
20864
+ CREATE TABLE processed_github_marketplace_events (
20865
+ delivery_id text PRIMARY KEY,
20866
+ event_name text NOT NULL,
20867
+ marketplace_account_id bigint,
20868
+ action text,
20869
+ processed_at timestamptz NOT NULL DEFAULT now()
20870
+ )
20871
+ `,
20872
+ `
20873
+ CREATE INDEX processed_github_marketplace_events_account_idx
20874
+ ON processed_github_marketplace_events (marketplace_account_id, processed_at DESC)
20875
+ `,
20785
20876
  `
20786
20877
  CREATE TABLE github_installations (
20787
20878
  id uuid PRIMARY KEY,
@@ -20799,6 +20890,41 @@ var STORAGE_BOOTSTRAP_STATEMENTS = [
20799
20890
  CREATE INDEX github_installations_status_idx
20800
20891
  ON github_installations (status)
20801
20892
  `,
20893
+ `
20894
+ CREATE TABLE github_marketplace_accounts (
20895
+ id uuid PRIMARY KEY,
20896
+ organization_id uuid REFERENCES organizations(id) ON DELETE SET NULL,
20897
+ marketplace_account_id bigint NOT NULL UNIQUE,
20898
+ marketplace_account_login text NOT NULL,
20899
+ marketplace_account_type text NOT NULL CHECK (marketplace_account_type IN ('Organization', 'User')),
20900
+ marketplace_account_node_id text,
20901
+ marketplace_listing_plan_id bigint NOT NULL,
20902
+ marketplace_listing_plan_name text NOT NULL,
20903
+ marketplace_plan_price_model text,
20904
+ billing_cycle text CHECK (billing_cycle IN ('monthly', 'yearly')),
20905
+ unit_count integer,
20906
+ on_free_trial boolean NOT NULL DEFAULT false,
20907
+ free_trial_ends_on timestamptz,
20908
+ next_billing_date timestamptz,
20909
+ effective_date timestamptz NOT NULL,
20910
+ installation_id bigint,
20911
+ marketplace_purchase_status text NOT NULL
20912
+ CHECK (marketplace_purchase_status IN ('purchased', 'cancelled', 'pending_change', 'pending_change_cancelled', 'changed')),
20913
+ last_event_id text NOT NULL,
20914
+ last_event_action text NOT NULL,
20915
+ created_at timestamptz NOT NULL DEFAULT now(),
20916
+ updated_at timestamptz NOT NULL DEFAULT now()
20917
+ )
20918
+ `,
20919
+ `
20920
+ CREATE INDEX github_marketplace_accounts_org_idx
20921
+ ON github_marketplace_accounts (organization_id, updated_at DESC)
20922
+ `,
20923
+ `
20924
+ CREATE UNIQUE INDEX github_marketplace_accounts_installation_idx
20925
+ ON github_marketplace_accounts (installation_id)
20926
+ WHERE installation_id IS NOT NULL
20927
+ `,
20802
20928
  `
20803
20929
  CREATE TABLE project_github_repos (
20804
20930
  id uuid PRIMARY KEY,
@@ -20883,9 +21009,18 @@ var STORAGE_BOOTSTRAP_STATEMENTS = [
20883
21009
  CREATE TABLE operational_email_deliveries (
20884
21010
  id uuid PRIMARY KEY,
20885
21011
  organization_id uuid NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
20886
- project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
21012
+ project_id uuid REFERENCES projects(id) ON DELETE CASCADE,
20887
21013
  kind text NOT NULL
20888
- CHECK (kind IN ('webhook_auto_disabled', 'allowance_warning_80', 'allowance_limit_reached', 'retention_rotation_notice')),
21014
+ CHECK (kind IN (
21015
+ 'webhook_auto_disabled',
21016
+ 'allowance_warning_80',
21017
+ 'allowance_limit_reached',
21018
+ 'retention_rotation_notice',
21019
+ 'trial_started',
21020
+ 'trial_ending_soon',
21021
+ 'trial_expired',
21022
+ 'trial_converted'
21023
+ )),
20889
21024
  dedupe_key text NOT NULL,
20890
21025
  payload jsonb NOT NULL DEFAULT '{}'::jsonb,
20891
21026
  status text NOT NULL DEFAULT 'pending'
@@ -20902,8 +21037,24 @@ var STORAGE_BOOTSTRAP_STATEMENTS = [
20902
21037
  `
20903
21038
  CREATE INDEX operational_email_deliveries_status_next_attempt_idx
20904
21039
  ON operational_email_deliveries (status, next_attempt_at, created_at)
21040
+ `,
21041
+ `
21042
+ CREATE TABLE trial_lifecycle_events (
21043
+ id uuid PRIMARY KEY,
21044
+ organization_id uuid NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
21045
+ event_type text NOT NULL,
21046
+ dedupe_key text NOT NULL,
21047
+ created_at timestamptz NOT NULL DEFAULT now(),
21048
+ UNIQUE (organization_id, event_type, dedupe_key)
21049
+ )
21050
+ `,
21051
+ `
21052
+ CREATE INDEX trial_lifecycle_events_org_event_created_idx
21053
+ ON trial_lifecycle_events (organization_id, event_type, created_at DESC)
20905
21054
  `
20906
21055
  ];
21056
+
21057
+ // ../../packages/storage/src/migrations.ts
20907
21058
  var STORAGE_BOOTSTRAP_SQL = STORAGE_BOOTSTRAP_STATEMENTS.join(";\n\n");
20908
21059
 
20909
21060
  // ../../packages/storage/src/schema-migrations.ts
@@ -20959,9 +21110,7 @@ var STORAGE_SCHEMA_MIGRATIONS = [
20959
21110
  defineStorageSchemaMigration({
20960
21111
  id: "202605130001_allow_synthetic_webhook_test_deliveries_without_incident_fk",
20961
21112
  description: "Allow webhook test deliveries to persist without requiring a backing incidents row.",
20962
- statements: [
20963
- "ALTER TABLE webhook_deliveries ALTER COLUMN incident_id DROP NOT NULL"
20964
- ]
21113
+ statements: ["ALTER TABLE webhook_deliveries ALTER COLUMN incident_id DROP NOT NULL"]
20965
21114
  }),
20966
21115
  defineStorageSchemaMigration({
20967
21116
  id: "202605130002_add_slack_destinations",
@@ -21398,6 +21547,161 @@ var STORAGE_SCHEMA_MIGRATIONS = [
21398
21547
  ON capture_rules (project_id, updated_at DESC)
21399
21548
  `
21400
21549
  ]
21550
+ }),
21551
+ defineStorageSchemaMigration({
21552
+ id: "202606020001_add_github_marketplace_tracking",
21553
+ description: "Add GitHub Marketplace purchase tracking tables and webhook idempotency ledger.",
21554
+ statements: [
21555
+ `
21556
+ CREATE TABLE IF NOT EXISTS processed_github_marketplace_events (
21557
+ delivery_id text PRIMARY KEY,
21558
+ event_name text NOT NULL,
21559
+ marketplace_account_id bigint,
21560
+ action text,
21561
+ processed_at timestamptz NOT NULL DEFAULT now()
21562
+ )
21563
+ `,
21564
+ `
21565
+ CREATE INDEX IF NOT EXISTS processed_github_marketplace_events_account_idx
21566
+ ON processed_github_marketplace_events (marketplace_account_id, processed_at DESC)
21567
+ `,
21568
+ `
21569
+ CREATE TABLE IF NOT EXISTS github_marketplace_accounts (
21570
+ id uuid PRIMARY KEY,
21571
+ organization_id uuid REFERENCES organizations(id) ON DELETE SET NULL,
21572
+ marketplace_account_id bigint NOT NULL UNIQUE,
21573
+ marketplace_account_login text NOT NULL,
21574
+ marketplace_account_type text NOT NULL CHECK (marketplace_account_type IN ('Organization', 'User')),
21575
+ marketplace_account_node_id text,
21576
+ marketplace_listing_plan_id bigint NOT NULL,
21577
+ marketplace_listing_plan_name text NOT NULL,
21578
+ marketplace_plan_price_model text,
21579
+ billing_cycle text CHECK (billing_cycle IN ('monthly', 'yearly')),
21580
+ unit_count integer,
21581
+ on_free_trial boolean NOT NULL DEFAULT false,
21582
+ free_trial_ends_on timestamptz,
21583
+ next_billing_date timestamptz,
21584
+ effective_date timestamptz NOT NULL,
21585
+ installation_id bigint,
21586
+ marketplace_purchase_status text NOT NULL
21587
+ CHECK (marketplace_purchase_status IN ('purchased', 'cancelled', 'pending_change', 'pending_change_cancelled', 'changed')),
21588
+ last_event_id text NOT NULL,
21589
+ last_event_action text NOT NULL,
21590
+ created_at timestamptz NOT NULL DEFAULT now(),
21591
+ updated_at timestamptz NOT NULL DEFAULT now()
21592
+ )
21593
+ `,
21594
+ `
21595
+ CREATE INDEX IF NOT EXISTS github_marketplace_accounts_org_idx
21596
+ ON github_marketplace_accounts (organization_id, updated_at DESC)
21597
+ `,
21598
+ `
21599
+ CREATE UNIQUE INDEX IF NOT EXISTS github_marketplace_accounts_installation_idx
21600
+ ON github_marketplace_accounts (installation_id)
21601
+ WHERE installation_id IS NOT NULL
21602
+ `
21603
+ ]
21604
+ }),
21605
+ defineStorageSchemaMigration({
21606
+ id: "202606030001_add_alert_notification_cooldowns_and_rule_window",
21607
+ description: "Add configurable alert cooldown windows and notification keys for cross-incident suppression.",
21608
+ statements: [
21609
+ "ALTER TABLE alert_rules ADD COLUMN IF NOT EXISTS cooldown_seconds integer",
21610
+ "UPDATE alert_rules SET cooldown_seconds = 0 WHERE cooldown_seconds IS NULL",
21611
+ "ALTER TABLE alert_rules ALTER COLUMN cooldown_seconds SET DEFAULT 0",
21612
+ "ALTER TABLE alert_rules ALTER COLUMN cooldown_seconds SET NOT NULL",
21613
+ "ALTER TABLE alert_deliveries ADD COLUMN IF NOT EXISTS notification_key text",
21614
+ "UPDATE alert_deliveries SET notification_key = dedupe_key WHERE notification_key IS NULL",
21615
+ "ALTER TABLE alert_deliveries ALTER COLUMN notification_key SET DEFAULT ''",
21616
+ "ALTER TABLE alert_deliveries ALTER COLUMN notification_key SET NOT NULL",
21617
+ `
21618
+ CREATE INDEX IF NOT EXISTS alert_deliveries_alert_notification_idx
21619
+ ON alert_deliveries (alert_id, notification_key, created_at DESC)
21620
+ `,
21621
+ "ALTER TABLE alert_email_digest_items ADD COLUMN IF NOT EXISTS notification_key text",
21622
+ "UPDATE alert_email_digest_items SET notification_key = dedupe_key WHERE notification_key IS NULL",
21623
+ "ALTER TABLE alert_email_digest_items ALTER COLUMN notification_key SET DEFAULT ''",
21624
+ "ALTER TABLE alert_email_digest_items ALTER COLUMN notification_key SET NOT NULL",
21625
+ `
21626
+ CREATE INDEX IF NOT EXISTS alert_email_digest_items_alert_notification_idx
21627
+ ON alert_email_digest_items (alert_id, notification_key, created_at DESC)
21628
+ `
21629
+ ]
21630
+ }),
21631
+ defineStorageSchemaMigration({
21632
+ id: "202606040001_add_no_card_trial_billing_state",
21633
+ description: "Add organization no-card trial metadata and the lifecycle event ledger.",
21634
+ statements: [
21635
+ "ALTER TABLE organizations ADD COLUMN IF NOT EXISTS trial_plan text",
21636
+ "ALTER TABLE organizations ADD COLUMN IF NOT EXISTS trial_started_at timestamptz",
21637
+ "ALTER TABLE organizations ADD COLUMN IF NOT EXISTS trial_ends_at timestamptz",
21638
+ "ALTER TABLE organizations ADD COLUMN IF NOT EXISTS trial_used_at timestamptz",
21639
+ "ALTER TABLE organizations ADD COLUMN IF NOT EXISTS trial_converted_at timestamptz",
21640
+ "ALTER TABLE organizations ADD COLUMN IF NOT EXISTS trial_expired_at timestamptz",
21641
+ "ALTER TABLE organizations DROP CONSTRAINT IF EXISTS organizations_trial_plan_check",
21642
+ `
21643
+ ALTER TABLE organizations
21644
+ ADD CONSTRAINT organizations_trial_plan_check
21645
+ CHECK (trial_plan IN ('solo', 'team') OR trial_plan IS NULL)
21646
+ `,
21647
+ "ALTER TABLE organizations DROP CONSTRAINT IF EXISTS organizations_trial_window_check",
21648
+ `
21649
+ ALTER TABLE organizations
21650
+ ADD CONSTRAINT organizations_trial_window_check
21651
+ CHECK (
21652
+ trial_started_at IS NULL
21653
+ OR trial_ends_at IS NULL
21654
+ OR trial_ends_at > trial_started_at
21655
+ )
21656
+ `,
21657
+ "ALTER TABLE organizations DROP CONSTRAINT IF EXISTS organizations_trial_started_requires_plan_check",
21658
+ `
21659
+ ALTER TABLE organizations
21660
+ ADD CONSTRAINT organizations_trial_started_requires_plan_check
21661
+ CHECK (
21662
+ trial_started_at IS NULL
21663
+ OR trial_plan IS NOT NULL
21664
+ )
21665
+ `,
21666
+ `
21667
+ CREATE TABLE IF NOT EXISTS trial_lifecycle_events (
21668
+ id uuid PRIMARY KEY,
21669
+ organization_id uuid NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
21670
+ event_type text NOT NULL,
21671
+ dedupe_key text NOT NULL,
21672
+ created_at timestamptz NOT NULL DEFAULT now(),
21673
+ UNIQUE (organization_id, event_type, dedupe_key)
21674
+ )
21675
+ `,
21676
+ `
21677
+ CREATE INDEX IF NOT EXISTS trial_lifecycle_events_org_event_created_idx
21678
+ ON trial_lifecycle_events (organization_id, event_type, created_at DESC)
21679
+ `
21680
+ ]
21681
+ }),
21682
+ defineStorageSchemaMigration({
21683
+ id: "202606040002_expand_operational_emails_for_trial_lifecycle",
21684
+ description: "Allow operational email deliveries without a project and add no-card trial email kinds.",
21685
+ statements: [
21686
+ "ALTER TABLE operational_email_deliveries ALTER COLUMN project_id DROP NOT NULL",
21687
+ "ALTER TABLE operational_email_deliveries DROP CONSTRAINT IF EXISTS operational_email_deliveries_kind_check",
21688
+ `
21689
+ ALTER TABLE operational_email_deliveries
21690
+ ADD CONSTRAINT operational_email_deliveries_kind_check
21691
+ CHECK (
21692
+ kind IN (
21693
+ 'webhook_auto_disabled',
21694
+ 'allowance_warning_80',
21695
+ 'allowance_limit_reached',
21696
+ 'retention_rotation_notice',
21697
+ 'trial_started',
21698
+ 'trial_ending_soon',
21699
+ 'trial_expired',
21700
+ 'trial_converted'
21701
+ )
21702
+ )
21703
+ `
21704
+ ]
21401
21705
  })
21402
21706
  ];
21403
21707
 
@@ -21521,7 +21825,8 @@ function normalizeRouteTemplate(path) {
21521
21825
  return normalizedSegments.length === 0 ? "/" : `/${normalizedSegments.join("/")}`;
21522
21826
  }
21523
21827
  function isBrowserSdkFallbackFrame(frame) {
21524
- return frame.includes("debugbundle-browser-sdk") && frame.includes("onError");
21828
+ const normalizedFrame = frame.toLowerCase();
21829
+ return normalizedFrame.includes("onerror") && (normalizedFrame.includes("debugbundle-browser-sdk") || normalizedFrame.includes("debugbundle-browser.js") || normalizedFrame.includes("wp-content/plugins/debugbundle/"));
21525
21830
  }
21526
21831
  function deriveFirstApplicationFrame(errorContext) {
21527
21832
  const firstFrame = errorContext?.top_frames[0];
@@ -21566,6 +21871,20 @@ function isOpaqueBrowserError(errorContext, browserEvent) {
21566
21871
  const firstFrame = errorContext?.top_frames[0];
21567
21872
  return errorContext?.message === "Window error" && firstFrame !== void 0 && isBrowserSdkFallbackFrame(firstFrame);
21568
21873
  }
21874
+ function stableJson2(value) {
21875
+ if (value === null || typeof value !== "object") {
21876
+ return JSON.stringify(value);
21877
+ }
21878
+ if (Array.isArray(value)) {
21879
+ return `[${value.map((entry) => stableJson2(entry)).join(",")}]`;
21880
+ }
21881
+ const record = value;
21882
+ const keys = Object.keys(record).sort();
21883
+ return `{${keys.map((key) => `${JSON.stringify(key)}:${stableJson2(record[key])}`).join(",")}}`;
21884
+ }
21885
+ function buildFrontendBreadcrumbKey(input) {
21886
+ return `${input.breadcrumb_type}:${input.ts}:${input.route ?? ""}:${stableJson2(input.data)}`;
21887
+ }
21569
21888
  function buildErrorContext(envelopes, incident, primarySignalEnvelope) {
21570
21889
  if (primarySignalEnvelope !== null && isBackendExceptionEnvelope(primarySignalEnvelope)) {
21571
21890
  return {
@@ -21827,6 +22146,7 @@ function buildLogsContext(envelopes) {
21827
22146
  };
21828
22147
  }
21829
22148
  function buildFrontendContext(envelopes) {
22149
+ const breadcrumbs = /* @__PURE__ */ new Map();
21830
22150
  const routeChanges = [];
21831
22151
  const clicks = [];
21832
22152
  const formSubmissions = [];
@@ -21835,54 +22155,24 @@ function buildFrontendContext(envelopes) {
21835
22155
  const exceptions = [];
21836
22156
  for (const envelope of envelopes) {
21837
22157
  if (isFrontendBreadcrumbEnvelope(envelope)) {
21838
- const timestamp = toIsoTimestamp(envelope.occurred_at);
21839
- if (envelope.payload.breadcrumb_type === "route_change") {
21840
- const from = typeof envelope.payload.data["from"] === "string" ? envelope.payload.data["from"] : "unknown";
21841
- const to = typeof envelope.payload.data["to"] === "string" ? envelope.payload.data["to"] : envelope.payload.route ?? "unknown";
21842
- routeChanges.push({ from, to, ts: timestamp });
21843
- }
21844
- if (envelope.payload.breadcrumb_type === "click") {
21845
- clicks.push({
21846
- selector: typeof envelope.payload.data["selector"] === "string" ? envelope.payload.data["selector"] : "unknown",
21847
- label: typeof envelope.payload.data["label"] === "string" ? envelope.payload.data["label"] : "unknown",
21848
- ts: timestamp
21849
- });
21850
- }
21851
- if (envelope.payload.breadcrumb_type === "form_submit") {
21852
- formSubmissions.push({
21853
- form: typeof envelope.payload.data["form"] === "string" ? envelope.payload.data["form"] : "unknown",
21854
- fields: envelope.payload.data["fields"] !== null && typeof envelope.payload.data["fields"] === "object" ? envelope.payload.data["fields"] : {},
21855
- ts: timestamp
21856
- });
21857
- }
21858
- if (envelope.payload.breadcrumb_type === "console_log") {
21859
- consoleLogs.push({
21860
- ts: timestamp,
21861
- ...envelope.payload.data
21862
- });
21863
- }
21864
- if (envelope.payload.breadcrumb_type === "network_request") {
21865
- const d = envelope.payload.data;
22158
+ const entry = {
22159
+ breadcrumb_type: envelope.payload.breadcrumb_type,
22160
+ route: envelope.payload.route,
22161
+ data: envelope.payload.data,
22162
+ ts: toIsoTimestamp(envelope.occurred_at)
22163
+ };
22164
+ breadcrumbs.set(buildFrontendBreadcrumbKey(entry), entry);
22165
+ }
22166
+ if (isFrontendExceptionEnvelope(envelope)) {
22167
+ for (const breadcrumb of envelope.payload.breadcrumbs ?? []) {
21866
22168
  const entry = {
21867
- method: typeof d["method"] === "string" ? d["method"] : "GET",
21868
- url: typeof d["url"] === "string" ? d["url"] : "unknown",
21869
- status: typeof d["status_code"] === "number" && Number.isInteger(d["status_code"]) ? d["status_code"] : typeof d["status"] === "number" && Number.isInteger(d["status"]) ? d["status"] : 0,
21870
- ts: timestamp
22169
+ breadcrumb_type: breadcrumb.breadcrumb_type,
22170
+ route: breadcrumb.route,
22171
+ data: breadcrumb.data,
22172
+ ts: toIsoTimestamp(breadcrumb.ts)
21871
22173
  };
21872
- if (typeof d["duration_ms"] === "number") entry.duration_ms = d["duration_ms"];
21873
- if (Array.isArray(d["caller_trace"])) entry.caller_trace = d["caller_trace"];
21874
- if (d["response_body"] !== void 0) entry.response_body = d["response_body"];
21875
- if (d["request_body"] !== void 0) entry.request_body = d["request_body"];
21876
- if (typeof d["response_headers"] === "object" && d["response_headers"] !== null) {
21877
- entry.response_headers = d["response_headers"];
21878
- }
21879
- if (typeof d["response_content_length"] === "number") {
21880
- entry.response_content_length = d["response_content_length"];
21881
- }
21882
- networkRequests.push(entry);
22174
+ breadcrumbs.set(buildFrontendBreadcrumbKey(entry), entry);
21883
22175
  }
21884
- }
21885
- if (isFrontendExceptionEnvelope(envelope)) {
21886
22176
  exceptions.push({
21887
22177
  name: envelope.payload.name,
21888
22178
  message: envelope.payload.message,
@@ -21893,6 +22183,59 @@ function buildFrontendContext(envelopes) {
21893
22183
  });
21894
22184
  }
21895
22185
  }
22186
+ const sortedBreadcrumbs = [...breadcrumbs.values()].sort((left, right) => {
22187
+ const timestampComparison = left.ts.localeCompare(right.ts);
22188
+ if (timestampComparison !== 0) {
22189
+ return timestampComparison;
22190
+ }
22191
+ return buildFrontendBreadcrumbKey(left).localeCompare(buildFrontendBreadcrumbKey(right));
22192
+ });
22193
+ for (const breadcrumb of sortedBreadcrumbs) {
22194
+ if (breadcrumb.breadcrumb_type === "route_change") {
22195
+ const from = typeof breadcrumb.data["from"] === "string" ? breadcrumb.data["from"] : "unknown";
22196
+ const to = typeof breadcrumb.data["to"] === "string" ? breadcrumb.data["to"] : breadcrumb.route ?? "unknown";
22197
+ routeChanges.push({ from, to, ts: breadcrumb.ts });
22198
+ }
22199
+ if (breadcrumb.breadcrumb_type === "click") {
22200
+ clicks.push({
22201
+ selector: typeof breadcrumb.data["selector"] === "string" ? breadcrumb.data["selector"] : "unknown",
22202
+ label: typeof breadcrumb.data["label"] === "string" ? breadcrumb.data["label"] : "unknown",
22203
+ ts: breadcrumb.ts
22204
+ });
22205
+ }
22206
+ if (breadcrumb.breadcrumb_type === "form_submit") {
22207
+ formSubmissions.push({
22208
+ form: typeof breadcrumb.data["form"] === "string" ? breadcrumb.data["form"] : "unknown",
22209
+ fields: breadcrumb.data["fields"] !== null && typeof breadcrumb.data["fields"] === "object" ? breadcrumb.data["fields"] : {},
22210
+ ts: breadcrumb.ts
22211
+ });
22212
+ }
22213
+ if (breadcrumb.breadcrumb_type === "console_log") {
22214
+ consoleLogs.push({
22215
+ ts: breadcrumb.ts,
22216
+ ...breadcrumb.data
22217
+ });
22218
+ }
22219
+ if (breadcrumb.breadcrumb_type === "network_request") {
22220
+ const entry = {
22221
+ method: typeof breadcrumb.data["method"] === "string" ? breadcrumb.data["method"] : "GET",
22222
+ url: typeof breadcrumb.data["url"] === "string" ? breadcrumb.data["url"] : "unknown",
22223
+ status: typeof breadcrumb.data["status_code"] === "number" && Number.isInteger(breadcrumb.data["status_code"]) ? breadcrumb.data["status_code"] : typeof breadcrumb.data["status"] === "number" && Number.isInteger(breadcrumb.data["status"]) ? breadcrumb.data["status"] : 0,
22224
+ ts: breadcrumb.ts
22225
+ };
22226
+ if (typeof breadcrumb.data["duration_ms"] === "number") entry.duration_ms = breadcrumb.data["duration_ms"];
22227
+ if (Array.isArray(breadcrumb.data["caller_trace"])) entry.caller_trace = breadcrumb.data["caller_trace"];
22228
+ if (breadcrumb.data["response_body"] !== void 0) entry.response_body = breadcrumb.data["response_body"];
22229
+ if (breadcrumb.data["request_body"] !== void 0) entry.request_body = breadcrumb.data["request_body"];
22230
+ if (typeof breadcrumb.data["response_headers"] === "object" && breadcrumb.data["response_headers"] !== null) {
22231
+ entry.response_headers = breadcrumb.data["response_headers"];
22232
+ }
22233
+ if (typeof breadcrumb.data["response_content_length"] === "number") {
22234
+ entry.response_content_length = breadcrumb.data["response_content_length"];
22235
+ }
22236
+ networkRequests.push(entry);
22237
+ }
22238
+ }
21896
22239
  const latestFrontendException = selectLatestEnvelopeByType(envelopes, isFrontendExceptionEnvelope);
21897
22240
  const domContext = latestFrontendException?.payload.dom_context ?? null;
21898
22241
  if (routeChanges.length === 0 && clicks.length === 0 && formSubmissions.length === 0 && consoleLogs.length === 0 && networkRequests.length === 0 && exceptions.length === 0 && domContext === null) {
@@ -22042,7 +22385,7 @@ function buildBundle(input) {
22042
22385
  const serviceRuntime = input.incident.service_runtime ?? selectLatestEnvelope(sourceEnvelopes, (envelope) => envelope.event_type !== "probe_event")?.service.runtime ?? null;
22043
22386
  const serviceFramework = input.incident.service_framework ?? selectLatestEnvelope(sourceEnvelopes, (envelope) => envelope.event_type !== "probe_event")?.service.framework ?? null;
22044
22387
  const customerVisible = frontendContext !== null;
22045
- const firstApplicationFrame = deriveFirstApplicationFrame(errorContext);
22388
+ const firstApplicationFrame = opaqueBrowserError ? null : deriveFirstApplicationFrame(errorContext);
22046
22389
  const summaryGuidance = buildSummaryGuidance({
22047
22390
  errorContext,
22048
22391
  requestContext,
@@ -22575,20 +22918,20 @@ function mergeSourceEvents(existingEvents, nextEvents) {
22575
22918
  }
22576
22919
  return [...merged.values()].sort(compareEventEnvelopes);
22577
22920
  }
22578
- function stableJson2(value) {
22921
+ function stableJson3(value) {
22579
22922
  if (value === null || typeof value !== "object") {
22580
22923
  return JSON.stringify(value);
22581
22924
  }
22582
22925
  if (Array.isArray(value)) {
22583
- return `[${value.map((entry) => stableJson2(entry)).join(",")}]`;
22926
+ return `[${value.map((entry) => stableJson3(entry)).join(",")}]`;
22584
22927
  }
22585
22928
  const record = value;
22586
22929
  const keys = Object.keys(record).sort();
22587
- return `{${keys.map((key) => `${JSON.stringify(key)}:${stableJson2(record[key])}`).join(",")}}`;
22930
+ return `{${keys.map((key) => `${JSON.stringify(key)}:${stableJson3(record[key])}`).join(",")}}`;
22588
22931
  }
22589
22932
  function buildRequestAnomalyFingerprint(input) {
22590
22933
  return (0, import_node_crypto4.createHash)("sha256").update(
22591
- stableJson2({
22934
+ stableJson3({
22592
22935
  kind: "request_status_anomaly",
22593
22936
  project_id: input.projectId,
22594
22937
  service_name: input.serviceName,
@@ -24682,6 +25025,9 @@ function createAlertMcpTools(api) {
24682
25025
  if (typeof input["severityMin"] === "string") {
24683
25026
  requestInput.severityMin = input["severityMin"];
24684
25027
  }
25028
+ if (typeof input["cooldownSeconds"] === "number") {
25029
+ requestInput.cooldownSeconds = input["cooldownSeconds"];
25030
+ }
24685
25031
  if (typeof input["isEnabled"] === "boolean") {
24686
25032
  requestInput.isEnabled = input["isEnabled"];
24687
25033
  }
@@ -24713,6 +25059,9 @@ function createAlertMcpTools(api) {
24713
25059
  } else if (input["severityMin"] === null) {
24714
25060
  requestInput.severityMin = null;
24715
25061
  }
25062
+ if (typeof input["cooldownSeconds"] === "number") {
25063
+ requestInput.cooldownSeconds = input["cooldownSeconds"];
25064
+ }
24716
25065
  if (typeof input["config"] === "object") {
24717
25066
  requestInput.config = input["config"];
24718
25067
  }
@@ -24778,6 +25127,9 @@ function mapMcpError3(error) {
24778
25127
  if (error instanceof BillingApiError) {
24779
25128
  throw new Error(`mcp_tool_error:${error.code}`);
24780
25129
  }
25130
+ if (error instanceof Error && error.message.startsWith("mcp_tool_error:")) {
25131
+ throw error;
25132
+ }
24781
25133
  throw new Error("mcp_tool_error:unknown_error");
24782
25134
  }
24783
25135
  function createBillingMcpTools(api) {
@@ -24793,6 +25145,22 @@ function createBillingMcpTools(api) {
24793
25145
  mapMcpError3(error);
24794
25146
  }
24795
25147
  },
25148
+ async start_trial(input) {
25149
+ try {
25150
+ const targetPlan = input["targetPlan"] ?? input["target_plan"];
25151
+ if (targetPlan !== "solo" && targetPlan !== "team") {
25152
+ throw new Error("mcp_tool_error:invalid_arguments");
25153
+ }
25154
+ return {
25155
+ billing: await api.startTrial({
25156
+ bearerToken: String(input["bearerToken"]),
25157
+ targetPlan
25158
+ })
25159
+ };
25160
+ } catch (error) {
25161
+ mapMcpError3(error);
25162
+ }
25163
+ },
24796
25164
  async increase_capacity(input) {
24797
25165
  try {
24798
25166
  return {
@@ -27898,7 +28266,7 @@ var zodToJsonSchema = (schema, options) => {
27898
28266
  var package_default = {
27899
28267
  name: "@debugbundle/mcp",
27900
28268
  mcpName: "com.debugbundle/mcp",
27901
- version: "1.0.1",
28269
+ version: "1.1.0",
27902
28270
  private: false,
27903
28271
  description: "Model Context Protocol server for DebugBundle",
27904
28272
  license: "AGPL-3.0-only",
@@ -28488,6 +28856,7 @@ var MCP_TOOL_CATALOG = [
28488
28856
  channel: external_exports.string(),
28489
28857
  conditionType: external_exports.string(),
28490
28858
  severityMin: external_exports.string().optional(),
28859
+ cooldownSeconds: external_exports.number().int().min(0).max(604800).optional(),
28491
28860
  config: jsonObjectSchema,
28492
28861
  isEnabled: external_exports.boolean().optional()
28493
28862
  })
@@ -28504,6 +28873,7 @@ var MCP_TOOL_CATALOG = [
28504
28873
  channel: external_exports.string().optional(),
28505
28874
  conditionType: external_exports.string().optional(),
28506
28875
  severityMin: external_exports.string().nullable().optional(),
28876
+ cooldownSeconds: external_exports.number().int().min(0).max(604800).optional(),
28507
28877
  config: jsonObjectSchema.nullable().optional(),
28508
28878
  isEnabled: external_exports.boolean().optional()
28509
28879
  })
@@ -28707,6 +29077,15 @@ var MCP_TOOL_CATALOG = [
28707
29077
  bearerToken: external_exports.string()
28708
29078
  })
28709
29079
  },
29080
+ {
29081
+ name: "start_trial",
29082
+ group: "billing",
29083
+ description: "Start an eligible no-card trial for the organization.",
29084
+ inputSchema: external_exports.object({
29085
+ bearerToken: external_exports.string(),
29086
+ targetPlan: external_exports.enum(["solo", "team"])
29087
+ })
29088
+ },
28710
29089
  {
28711
29090
  name: "increase_capacity",
28712
29091
  group: "billing",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@debugbundle/mcp",
3
3
  "mcpName": "com.debugbundle/mcp",
4
- "version": "1.0.1",
4
+ "version": "1.1.0",
5
5
  "private": false,
6
6
  "description": "Model Context Protocol server for DebugBundle",
7
7
  "license": "AGPL-3.0-only",
package/server.json CHANGED
@@ -8,13 +8,13 @@
8
8
  "source": "github",
9
9
  "subfolder": "apps/mcp"
10
10
  },
11
- "version": "1.0.1",
11
+ "version": "1.1.0",
12
12
  "packages": [
13
13
  {
14
14
  "registryType": "npm",
15
15
  "registryBaseUrl": "https://registry.npmjs.org",
16
16
  "identifier": "@debugbundle/mcp",
17
- "version": "1.0.1",
17
+ "version": "1.1.0",
18
18
  "transport": {
19
19
  "type": "stdio"
20
20
  },