@debugbundle/mcp 0.1.1 → 0.1.2

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 +348 -63
  2. package/package.json +1 -1
package/dist/main.cjs CHANGED
@@ -14551,7 +14551,8 @@ function createAlertApi(client) {
14551
14551
  const body = {
14552
14552
  project_id: input.projectId,
14553
14553
  channel: input.channel,
14554
- condition_type: input.conditionType
14554
+ condition_type: input.conditionType,
14555
+ config: input.config
14555
14556
  };
14556
14557
  if (input.serviceId !== void 0) {
14557
14558
  body.service_id = input.serviceId;
@@ -14559,9 +14560,6 @@ function createAlertApi(client) {
14559
14560
  if (input.severityMin !== void 0) {
14560
14561
  body.severity_min = input.severityMin;
14561
14562
  }
14562
- if (input.config !== void 0) {
14563
- body.config = input.config;
14564
- }
14565
14563
  if (input.isEnabled !== void 0) {
14566
14564
  body.is_enabled = input.isEnabled;
14567
14565
  }
@@ -16225,6 +16223,26 @@ var InlineProbeDataSchema = external_exports.object({
16225
16223
  version: external_exports.literal(1),
16226
16224
  items: external_exports.array(InlineProbeDataItemSchema)
16227
16225
  }).strict();
16226
+ var RuntimeMemoryStatsSchema = external_exports.object({
16227
+ rss: external_exports.number().nonnegative().nullable(),
16228
+ heap_total: external_exports.number().nonnegative().nullable(),
16229
+ heap_used: external_exports.number().nonnegative().nullable(),
16230
+ external: external_exports.number().nonnegative().nullable(),
16231
+ peak: external_exports.number().nonnegative().nullable()
16232
+ }).strict();
16233
+ var BackendRuntimePayloadSchema = external_exports.object({
16234
+ version: external_exports.string().min(1),
16235
+ platform: external_exports.string().min(1).nullable().optional(),
16236
+ arch: external_exports.string().min(1).nullable().optional(),
16237
+ pid: external_exports.number().int().nonnegative().nullable().optional(),
16238
+ cwd: external_exports.string().min(1).nullable().optional(),
16239
+ uptime_sec: external_exports.number().nonnegative().nullable().optional(),
16240
+ hostname: external_exports.string().min(1).nullable().optional(),
16241
+ thread_id: external_exports.union([external_exports.string(), external_exports.number()]).nullable().optional(),
16242
+ framework_version: external_exports.string().min(1).nullable().optional(),
16243
+ memory: RuntimeMemoryStatsSchema.nullable().optional(),
16244
+ framework_extras: external_exports.record(external_exports.string(), external_exports.unknown()).nullable().optional()
16245
+ }).strict();
16228
16246
  var BackendExceptionPayloadSchema = external_exports.object({
16229
16247
  name: external_exports.string().min(1),
16230
16248
  message: external_exports.string().min(1),
@@ -16242,9 +16260,7 @@ var BackendExceptionPayloadSchema = external_exports.object({
16242
16260
  headers: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
16243
16261
  body: external_exports.unknown().optional()
16244
16262
  }),
16245
- runtime: external_exports.object({
16246
- version: external_exports.string().min(1)
16247
- }),
16263
+ runtime: BackendRuntimePayloadSchema,
16248
16264
  probe_data: InlineProbeDataSchema.optional()
16249
16265
  }).strict();
16250
16266
  var RequestEventPayloadSchema = external_exports.object({
@@ -16515,13 +16531,7 @@ var ContextDeploySchema = external_exports.object({
16515
16531
  deployed_at: external_exports.string().datetime().nullable(),
16516
16532
  regression_window: external_exports.boolean().nullable()
16517
16533
  });
16518
- var MemoryStatsSchema = external_exports.object({
16519
- rss: external_exports.number().nonnegative().nullable(),
16520
- heap_total: external_exports.number().nonnegative().nullable(),
16521
- heap_used: external_exports.number().nonnegative().nullable(),
16522
- external: external_exports.number().nonnegative().nullable(),
16523
- peak: external_exports.number().nonnegative().nullable()
16524
- });
16534
+ var MemoryStatsSchema = RuntimeMemoryStatsSchema;
16525
16535
  var ContextRuntimeSchema = external_exports.object({
16526
16536
  version: external_exports.literal(1),
16527
16537
  name: external_exports.string().min(1),
@@ -17929,7 +17939,7 @@ var RELAY_SPOOL_DELIVERED_MARKER_SUFFIX = ".delivered";
17929
17939
  var RELAY_SPOOL_EVENT_SUFFIX = ".events.json";
17930
17940
  var SUGGESTED_ACTIONS = [
17931
17941
  "Run debugbundle setup if local scaffold files are missing.",
17932
- "Run debugbundle login to create ~/.debugbundle/auth.json.",
17942
+ "Run debugbundle login to choose an auth flow, or use debugbundle login --github, debugbundle login --github-device, or debugbundle login <dbundle_mem_...> to create ~/.debugbundle/auth.json.",
17933
17943
  "Review .debugbundle/profile.json when architecture changes or the profile becomes stale."
17934
17944
  ];
17935
17945
  async function pathExists3(path, stat) {
@@ -18695,9 +18705,11 @@ function deriveIncidentReasonFromSourceEventTypes(eventTypes) {
18695
18705
  return null;
18696
18706
  }
18697
18707
 
18698
- // ../../packages/auth/src/index.ts
18708
+ // ../../packages/auth/src/primitives.ts
18699
18709
  var import_argon2 = require("@node-rs/argon2");
18700
- var DEFAULT_SESSION_LIFETIME_MS = 1e3 * 60 * 60 * 4;
18710
+
18711
+ // ../../packages/auth/src/web-session-auth.ts
18712
+ var DEFAULT_SESSION_LIFETIME_MS = 1e3 * 60 * 60 * 24 * 7;
18701
18713
  var DEFAULT_EMAIL_AUTH_CODE_LIFETIME_MS = 1e3 * 60 * 10;
18702
18714
  var DEFAULT_GITHUB_OAUTH_STATE_LIFETIME_MS = 1e3 * 60 * 10;
18703
18715
 
@@ -18736,6 +18748,37 @@ var STORAGE_SCHEMA_MIGRATIONS = [
18736
18748
  "ALTER TABLE organizations ADD COLUMN IF NOT EXISTS suspended_at timestamptz",
18737
18749
  "ALTER TABLE organization_members ADD COLUMN IF NOT EXISTS suspended_at timestamptz"
18738
18750
  ]
18751
+ }),
18752
+ defineStorageSchemaMigration({
18753
+ id: "202605120001_add_github_device_authorizations",
18754
+ description: "Add persisted GitHub CLI bootstrap state for device-flow login.",
18755
+ statements: [
18756
+ `
18757
+ CREATE TABLE IF NOT EXISTS github_device_authorizations (
18758
+ id uuid PRIMARY KEY,
18759
+ device_code text NOT NULL UNIQUE,
18760
+ user_code text NOT NULL,
18761
+ verification_uri text NOT NULL,
18762
+ interval_seconds integer NOT NULL,
18763
+ expires_at timestamptz NOT NULL,
18764
+ accepted_terms_at timestamptz,
18765
+ created_at timestamptz NOT NULL DEFAULT now(),
18766
+ completed_at timestamptz,
18767
+ claimed_at timestamptz,
18768
+ terminal_error text,
18769
+ user_id uuid REFERENCES users(id) ON DELETE SET NULL,
18770
+ organization_id uuid REFERENCES organizations(id) ON DELETE SET NULL
18771
+ )
18772
+ `,
18773
+ `
18774
+ CREATE INDEX IF NOT EXISTS github_device_authorizations_user_code_idx
18775
+ ON github_device_authorizations (user_code, created_at DESC)
18776
+ `,
18777
+ `
18778
+ CREATE INDEX IF NOT EXISTS github_device_authorizations_expires_at_idx
18779
+ ON github_device_authorizations (expires_at)
18780
+ `
18781
+ ]
18739
18782
  })
18740
18783
  ];
18741
18784
 
@@ -18749,6 +18792,7 @@ var import_promises5 = require("node:fs/promises");
18749
18792
  var import_node_path6 = require("node:path");
18750
18793
 
18751
18794
  // ../../packages/bundle-engine/src/index.ts
18795
+ var DYNAMIC_SEGMENT_PATTERN2 = /^(?:\d+|[0-9a-f]{8}-[0-9a-f-]{27}|[A-Za-z0-9_-]{24,})$/;
18752
18796
  function toIsoTimestamp(value) {
18753
18797
  return new Date(value).toISOString();
18754
18798
  }
@@ -18822,6 +18866,41 @@ function inferSignalTypeFromSourceEventTypes(sourceEventTypes) {
18822
18866
  function extractTopFrames(stack) {
18823
18867
  return stack.split("\n").map((line) => line.trim()).filter((line) => line.startsWith("at ")).slice(0, 3);
18824
18868
  }
18869
+ function decodeRouteSegment2(segment) {
18870
+ try {
18871
+ return decodeURIComponent(segment);
18872
+ } catch {
18873
+ return segment.replace(
18874
+ /%([0-9A-Fa-f]{2})/g,
18875
+ (_match, hexByte) => String.fromCharCode(parseInt(hexByte, 16))
18876
+ );
18877
+ }
18878
+ }
18879
+ function isDynamicRouteSegment2(segment) {
18880
+ if (DYNAMIC_SEGMENT_PATTERN2.test(segment)) {
18881
+ return true;
18882
+ }
18883
+ const decodedSegment = decodeRouteSegment2(segment);
18884
+ if (decodedSegment.includes("/")) {
18885
+ return true;
18886
+ }
18887
+ if (decodedSegment !== segment && DYNAMIC_SEGMENT_PATTERN2.test(decodedSegment)) {
18888
+ return true;
18889
+ }
18890
+ const strippedMalformedPercent = decodedSegment.replace(/%+/g, "");
18891
+ return strippedMalformedPercent !== decodedSegment && DYNAMIC_SEGMENT_PATTERN2.test(strippedMalformedPercent);
18892
+ }
18893
+ function normalizeRouteTemplate(path) {
18894
+ if (path === null || path.length === 0) {
18895
+ return null;
18896
+ }
18897
+ const pathWithoutQueryOrFragment = path.split(/[?#]/, 1)[0] ?? "";
18898
+ if (pathWithoutQueryOrFragment.length === 0) {
18899
+ return "/";
18900
+ }
18901
+ const normalizedSegments = pathWithoutQueryOrFragment.split("/").filter((segment) => segment.length > 0).map((segment) => isDynamicRouteSegment2(segment) ? "{param}" : segment);
18902
+ return normalizedSegments.length === 0 ? "/" : `/${normalizedSegments.join("/")}`;
18903
+ }
18825
18904
  function deriveFirstApplicationFrame(errorContext) {
18826
18905
  const firstFrame = errorContext?.top_frames[0];
18827
18906
  if (firstFrame === void 0) {
@@ -18915,13 +18994,135 @@ function buildRequestContext(envelopes) {
18915
18994
  version: 1,
18916
18995
  method: exceptionEvent.payload.request.method,
18917
18996
  path: exceptionEvent.payload.request.path,
18918
- route_template: null,
18997
+ route_template: normalizeRouteTemplate(exceptionEvent.payload.request.path),
18919
18998
  query: exceptionEvent.payload.request.query,
18920
18999
  headers: exceptionEvent.payload.request.headers,
18921
19000
  body: exceptionEvent.payload.request.body ?? null,
18922
19001
  request_id: exceptionEvent.correlation?.request_id ?? null
18923
19002
  };
18924
19003
  }
19004
+ function titleCaseWord(value) {
19005
+ if (value.toLowerCase() === "github") {
19006
+ return "GitHub";
19007
+ }
19008
+ if (value.toLowerCase() === "api") {
19009
+ return "API";
19010
+ }
19011
+ return `${value.slice(0, 1).toUpperCase()}${value.slice(1)}`;
19012
+ }
19013
+ function formatDependencyName(name) {
19014
+ return name.split("_").filter((part) => part.length > 0).map(titleCaseWord).join(" ");
19015
+ }
19016
+ function inferDependencyName(text) {
19017
+ const match = /\b([a-z][a-z0-9]*_api)_(?:invalid_response|error|failure|failed|unavailable|timeout)\b/.exec(text);
19018
+ return match?.[1] ?? null;
19019
+ }
19020
+ function buildDependenciesContext(incident, errorContext, requestContext) {
19021
+ if (errorContext === null) {
19022
+ return null;
19023
+ }
19024
+ const text = `${incident.title} ${errorContext.name} ${errorContext.message}`.toLowerCase();
19025
+ const dependencyName = inferDependencyName(text);
19026
+ if (dependencyName === null) {
19027
+ return null;
19028
+ }
19029
+ const displayName = formatDependencyName(dependencyName);
19030
+ const route = requestContext?.route_template ?? requestContext?.path ?? null;
19031
+ const requestDescription = requestContext !== null ? `${requestContext.method} ${route ?? requestContext.path}` : "the failing request";
19032
+ const invalidResponse = text.includes("invalid_response");
19033
+ return {
19034
+ version: 1,
19035
+ items: [
19036
+ {
19037
+ name: dependencyName,
19038
+ status: "failed",
19039
+ notes: invalidResponse ? `${displayName} returned an unexpected response shape while handling ${requestDescription}.` : `${displayName} failed while handling ${requestDescription}.`
19040
+ }
19041
+ ]
19042
+ };
19043
+ }
19044
+ function buildSummaryGuidance(input) {
19045
+ if (input.errorContext === null) {
19046
+ return {
19047
+ likely_cause: null,
19048
+ confidence: 0,
19049
+ recommended_action: null
19050
+ };
19051
+ }
19052
+ const route = input.requestContext?.route_template ?? input.requestContext?.path ?? null;
19053
+ const requestDescription = input.requestContext !== null ? `${input.requestContext.method} ${route ?? input.requestContext.path}` : null;
19054
+ const firstDependency = input.dependenciesContext?.items[0] ?? null;
19055
+ const dependencyDisplayName = firstDependency !== null ? formatDependencyName(firstDependency.name) : null;
19056
+ const firstFrame = input.firstApplicationFrame;
19057
+ const frameDescription = firstFrame?.file !== null && firstFrame?.file !== void 0 ? ` in ${firstFrame.file}` : "";
19058
+ const invalidResponse = input.errorContext.message.toLowerCase().includes("invalid_response");
19059
+ let likelyCause = null;
19060
+ let recommendedAction = null;
19061
+ if (firstDependency !== null && dependencyDisplayName !== null && requestDescription !== null && invalidResponse) {
19062
+ likelyCause = `${dependencyDisplayName} returned a response that did not match the expected schema while handling ${requestDescription}.`;
19063
+ recommendedAction = `Inspect the ${dependencyDisplayName} response handling${frameDescription}, including schema validation and sanitized upstream response shape.`;
19064
+ } else if (firstDependency !== null && dependencyDisplayName !== null && requestDescription !== null) {
19065
+ likelyCause = `${dependencyDisplayName} failed while handling ${requestDescription}.`;
19066
+ recommendedAction = `Inspect the ${dependencyDisplayName} call path${frameDescription} and compare the captured dependency notes with upstream status.`;
19067
+ } else if (requestDescription !== null) {
19068
+ likelyCause = `${input.errorContext.name} occurred while handling ${requestDescription}${frameDescription}.`;
19069
+ recommendedAction = `Inspect the first application frame${frameDescription} and the captured request/response context.`;
19070
+ } else if (firstFrame !== null) {
19071
+ likelyCause = `${input.errorContext.name} originated from the first captured application frame${frameDescription}.`;
19072
+ recommendedAction = `Inspect the first application frame${frameDescription} and surrounding error handling.`;
19073
+ }
19074
+ if (likelyCause === null || recommendedAction === null) {
19075
+ return {
19076
+ likely_cause: null,
19077
+ confidence: 0,
19078
+ recommended_action: null
19079
+ };
19080
+ }
19081
+ let confidence = 0.25;
19082
+ if (input.requestContext !== null) confidence += 0.15;
19083
+ if (input.responseContext !== null) confidence += 0.1;
19084
+ if (firstFrame !== null && firstFrame.file !== null) confidence += 0.1;
19085
+ if (firstDependency !== null) confidence += 0.1;
19086
+ if (input.errorContext.message.length > 0) confidence += 0.05;
19087
+ return {
19088
+ likely_cause: likelyCause,
19089
+ confidence: Math.min(0.8, Number(confidence.toFixed(2))),
19090
+ recommended_action: recommendedAction
19091
+ };
19092
+ }
19093
+ function normalizeBaseUrl3(value) {
19094
+ const trimmed = value?.trim();
19095
+ if (trimmed === void 0 || trimmed.length === 0) {
19096
+ return null;
19097
+ }
19098
+ return trimmed.replace(/\/+$/, "");
19099
+ }
19100
+ function buildLinks(incident, linkBaseUrls) {
19101
+ const apiBaseUrl = normalizeBaseUrl3(linkBaseUrls?.api);
19102
+ const appBaseUrl = normalizeBaseUrl3(linkBaseUrls?.app);
19103
+ const docsBaseUrl = normalizeBaseUrl3(linkBaseUrls?.docs);
19104
+ const incidentPath = `/v1/incidents/${encodeURIComponent(incident.incident_id)}`;
19105
+ const appIncidentPath = `/incidents/${encodeURIComponent(incident.incident_id)}`;
19106
+ const appProjectPath = `/projects/${encodeURIComponent(incident.project_id)}`;
19107
+ return {
19108
+ self: apiBaseUrl !== null ? `${apiBaseUrl}${incidentPath}/bundle` : null,
19109
+ reproduction: apiBaseUrl !== null ? `${apiBaseUrl}${incidentPath}/reproduction` : null,
19110
+ incident: appBaseUrl !== null ? `${appBaseUrl}${appIncidentPath}` : null,
19111
+ project: appBaseUrl !== null ? `${appBaseUrl}${appProjectPath}` : null,
19112
+ docs: docsBaseUrl !== null ? `${docsBaseUrl}/bundles` : null
19113
+ };
19114
+ }
19115
+ function applyBundleRedaction(candidate) {
19116
+ const redactionResult = redact(candidate);
19117
+ const fields = [...new Set(redactionResult.redacted_fields)].sort();
19118
+ const redactedBundle = redactionResult.redacted;
19119
+ redactedBundle["redaction"] = {
19120
+ redacted: true,
19121
+ fields,
19122
+ notes: fields.length > 0 ? "Sensitive bundle fields were redacted before storage." : null
19123
+ };
19124
+ return redactedBundle;
19125
+ }
18925
19126
  function buildResponseContext(envelopes) {
18926
19127
  const requestEvent = selectLatestEnvelopeByType(envelopes, isRequestEventEnvelope);
18927
19128
  if (requestEvent !== null) {
@@ -19054,17 +19255,31 @@ function buildFrontendContext(envelopes) {
19054
19255
  dom_context: domContext
19055
19256
  };
19056
19257
  }
19057
- function buildDeployContext(envelopes, trigger) {
19258
+ function buildDeployContext(envelopes, trigger, configuredDeploy) {
19058
19259
  const envelope = selectLatestEnvelopeByType(envelopes, isDeployMetadataEnvelope);
19059
- if (envelope === null) {
19260
+ if (envelope !== null) {
19261
+ return {
19262
+ version: 1,
19263
+ commit_sha: envelope.payload.commit_sha,
19264
+ deploy_version: envelope.payload.version,
19265
+ branch: envelope.payload.branch,
19266
+ deployed_at: toIsoTimestamp(envelope.payload.deployed_at),
19267
+ regression_window: trigger === "regression_reopen"
19268
+ };
19269
+ }
19270
+ const commitSha = configuredDeploy?.commit_sha ?? null;
19271
+ const deployVersion = configuredDeploy?.deploy_version ?? null;
19272
+ const branch = configuredDeploy?.branch ?? null;
19273
+ const deployedAt = configuredDeploy?.deployed_at ?? null;
19274
+ if (commitSha === null && deployVersion === null && branch === null && deployedAt === null) {
19060
19275
  return null;
19061
19276
  }
19062
19277
  return {
19063
19278
  version: 1,
19064
- commit_sha: envelope.payload.commit_sha,
19065
- deploy_version: envelope.payload.version,
19066
- branch: envelope.payload.branch,
19067
- deployed_at: toIsoTimestamp(envelope.payload.deployed_at),
19279
+ commit_sha: commitSha,
19280
+ deploy_version: deployVersion,
19281
+ branch,
19282
+ deployed_at: deployedAt === null ? null : toIsoTimestamp(deployedAt),
19068
19283
  regression_window: trigger === "regression_reopen"
19069
19284
  };
19070
19285
  }
@@ -19073,34 +19288,49 @@ function buildRuntimeContext(envelopes) {
19073
19288
  if (backendException === null) {
19074
19289
  return null;
19075
19290
  }
19291
+ const runtime = backendException.payload.runtime;
19076
19292
  return {
19077
19293
  version: 1,
19078
19294
  name: backendException.service.runtime ?? "unknown",
19079
- runtime_version: backendException.payload.runtime.version,
19080
- platform: null,
19081
- arch: null,
19082
- pid: null,
19083
- cwd: null,
19084
- uptime_sec: null,
19085
- hostname: null,
19086
- thread_id: null,
19295
+ runtime_version: runtime.version,
19296
+ platform: runtime.platform ?? null,
19297
+ arch: runtime.arch ?? null,
19298
+ pid: runtime.pid ?? null,
19299
+ cwd: runtime.cwd ?? null,
19300
+ uptime_sec: runtime.uptime_sec ?? null,
19301
+ hostname: runtime.hostname ?? null,
19302
+ thread_id: runtime.thread_id ?? null,
19087
19303
  framework: backendException.service.framework ?? null,
19088
- framework_version: null,
19089
- memory: null,
19090
- framework_extras: null
19304
+ framework_version: runtime.framework_version ?? null,
19305
+ memory: runtime.memory ?? null,
19306
+ framework_extras: runtime.framework_extras ?? null
19091
19307
  };
19092
19308
  }
19093
- function buildGitContext(envelopes) {
19309
+ function buildGitContext(envelopes, configuredDeploy) {
19094
19310
  const deployEnvelope = selectLatestEnvelopeByType(envelopes, isDeployMetadataEnvelope);
19095
19311
  if (deployEnvelope === null) {
19096
- return null;
19312
+ const commit = configuredDeploy?.commit_sha ?? null;
19313
+ const branch = configuredDeploy?.branch ?? null;
19314
+ const repo = configuredDeploy?.repo ?? null;
19315
+ if (commit === null && branch === null && repo === null) {
19316
+ return null;
19317
+ }
19318
+ return {
19319
+ version: 1,
19320
+ commit,
19321
+ commit_short: commit === null ? null : commit.slice(0, 7),
19322
+ branch,
19323
+ repo,
19324
+ dirty: false,
19325
+ source: "env"
19326
+ };
19097
19327
  }
19098
19328
  return {
19099
19329
  version: 1,
19100
19330
  commit: deployEnvelope.payload.commit_sha,
19101
19331
  commit_short: deployEnvelope.payload.commit_sha.slice(0, 7),
19102
19332
  branch: deployEnvelope.payload.branch,
19103
- repo: null,
19333
+ repo: configuredDeploy?.repo ?? null,
19104
19334
  dirty: false,
19105
19335
  source: "env"
19106
19336
  };
@@ -19143,10 +19373,11 @@ function buildBundle(input) {
19143
19373
  const responseContext = buildResponseContext(sourceEnvelopes);
19144
19374
  const logsContext = buildLogsContext(sourceEnvelopes);
19145
19375
  const frontendContext = buildFrontendContext(sourceEnvelopes);
19146
- const deployContext = buildDeployContext(sourceEnvelopes, input.job.trigger);
19376
+ const deployContext = buildDeployContext(sourceEnvelopes, input.job.trigger, input.configuredDeploy);
19147
19377
  const runtimeContext = buildRuntimeContext(sourceEnvelopes);
19148
- const gitContext = buildGitContext(sourceEnvelopes);
19378
+ const gitContext = buildGitContext(sourceEnvelopes, input.configuredDeploy);
19149
19379
  const deviceContext = buildDeviceContext(sourceEnvelopes);
19380
+ const dependenciesContext = buildDependenciesContext(input.incident, errorContext, requestContext);
19150
19381
  const primarySignalType = primarySignalEnvelope !== null ? mapSignalType(primarySignalEnvelope.event_type) : inferSignalTypeFromSourceEventTypes(sourceEventTypes);
19151
19382
  const primarySourceEvent = errorContext?.name ?? sourceEventTypes[0] ?? "backend_exception";
19152
19383
  const firstSeenAt = new Date(input.incident.first_seen_at).toISOString();
@@ -19155,7 +19386,15 @@ function buildBundle(input) {
19155
19386
  const serviceRuntime = input.incident.service_runtime ?? selectLatestEnvelope(sourceEnvelopes, (envelope) => envelope.event_type !== "probe_event")?.service.runtime ?? null;
19156
19387
  const serviceFramework = input.incident.service_framework ?? selectLatestEnvelope(sourceEnvelopes, (envelope) => envelope.event_type !== "probe_event")?.service.framework ?? null;
19157
19388
  const customerVisible = frontendContext !== null;
19158
- return BundleV1Schema.parse({
19389
+ const firstApplicationFrame = deriveFirstApplicationFrame(errorContext);
19390
+ const summaryGuidance = buildSummaryGuidance({
19391
+ errorContext,
19392
+ requestContext,
19393
+ responseContext,
19394
+ dependenciesContext,
19395
+ firstApplicationFrame
19396
+ });
19397
+ const candidate = {
19159
19398
  bundle_version: 1,
19160
19399
  bundle_id: `bnd_${input.incident.incident_id}`,
19161
19400
  bundle_type: "failure",
@@ -19190,13 +19429,13 @@ function buildBundle(input) {
19190
19429
  summary: {
19191
19430
  title: input.incident.title,
19192
19431
  description: `Deterministic bundle generated from ${input.job.trigger}`,
19193
- likely_cause: null,
19194
- confidence: 0,
19195
- recommended_action: null,
19432
+ likely_cause: summaryGuidance.likely_cause,
19433
+ confidence: summaryGuidance.confidence,
19434
+ recommended_action: summaryGuidance.recommended_action,
19196
19435
  severity: input.incident.severity,
19197
19436
  error_type: primarySourceEvent,
19198
19437
  error_message: errorContext?.message ?? input.incident.title,
19199
- first_application_frame: deriveFirstApplicationFrame(errorContext),
19438
+ first_application_frame: firstApplicationFrame,
19200
19439
  primary_signal: primarySignalType,
19201
19440
  signals: {
19202
19441
  new_deploy: input.job.trigger === "deploy_metadata",
@@ -19221,7 +19460,7 @@ function buildBundle(input) {
19221
19460
  deploy: deployContext,
19222
19461
  runtime: runtimeContext,
19223
19462
  git: gitContext,
19224
- dependencies: null,
19463
+ dependencies: dependenciesContext,
19225
19464
  probe_data: {
19226
19465
  version: 1,
19227
19466
  items: input.probeDataItems
@@ -19242,11 +19481,7 @@ function buildBundle(input) {
19242
19481
  production_verified: false
19243
19482
  },
19244
19483
  links: {
19245
- self: null,
19246
- reproduction: null,
19247
- incident: null,
19248
- project: null,
19249
- docs: null
19484
+ ...buildLinks(input.incident, input.linkBaseUrls)
19250
19485
  },
19251
19486
  redaction: {
19252
19487
  redacted: true,
@@ -19259,7 +19494,8 @@ function buildBundle(input) {
19259
19494
  generator_version: "worker-build-bundle-v2",
19260
19495
  generation_number: input.bundleMetadata.generation_number
19261
19496
  }
19262
- });
19497
+ };
19498
+ return BundleV1Schema.parse(applyBundleRedaction(candidate));
19263
19499
  }
19264
19500
 
19265
19501
  // ../../packages/repro-engine/src/index.ts
@@ -19279,6 +19515,44 @@ function shellQuote(value) {
19279
19515
  function sortRecordEntries(record) {
19280
19516
  return Object.entries(record).sort(([left], [right]) => left.localeCompare(right));
19281
19517
  }
19518
+ var REPLAY_HEADER_PRIORITY = [
19519
+ "authorization",
19520
+ "cookie",
19521
+ "accept",
19522
+ "content-type",
19523
+ "origin",
19524
+ "accept-language",
19525
+ "access-control-request-method",
19526
+ "access-control-request-headers",
19527
+ "x-request-id",
19528
+ "x-correlation-id",
19529
+ "x-debugbundle-trace-id"
19530
+ ];
19531
+ var DROPPED_REPLAY_HEADERS = /* @__PURE__ */ new Set([
19532
+ "host",
19533
+ "x-forwarded-host",
19534
+ "x-forwarded-proto",
19535
+ "connection",
19536
+ "keep-alive",
19537
+ "transfer-encoding",
19538
+ "upgrade",
19539
+ "te",
19540
+ "trailer",
19541
+ "proxy-connection",
19542
+ "accept-encoding",
19543
+ "content-length",
19544
+ "cache-control",
19545
+ "pragma",
19546
+ "priority",
19547
+ "sec-ch-ua",
19548
+ "sec-ch-ua-mobile",
19549
+ "sec-ch-ua-platform",
19550
+ "sec-fetch-dest",
19551
+ "sec-fetch-mode",
19552
+ "sec-fetch-site",
19553
+ "sec-fetch-user",
19554
+ "user-agent"
19555
+ ]);
19282
19556
  function serializeScalarValue(value) {
19283
19557
  if (typeof value === "string") {
19284
19558
  return value;
@@ -19357,12 +19631,25 @@ function buildStructuredReplayQuery(query) {
19357
19631
  return hasStructuredQueryAmbiguity(normalizedQuery) ? normalizedQuery : void 0;
19358
19632
  }
19359
19633
  function buildReplayHeaders(headers) {
19360
- return Object.fromEntries(
19361
- sortRecordEntries(headers).filter(([headerName]) => !["host", "x-forwarded-host", "x-forwarded-proto"].includes(headerName.toLowerCase())).map(([headerName, headerValue]) => [headerName, normalizeHeaderValue(headerValue)])
19362
- );
19634
+ const entries = sortRecordEntries(headers).filter(([headerName]) => !DROPPED_REPLAY_HEADERS.has(headerName.toLowerCase())).map(([headerName, headerValue]) => [headerName, normalizeHeaderValue(headerValue)]);
19635
+ entries.sort(([left], [right]) => {
19636
+ const leftPriority = REPLAY_HEADER_PRIORITY.indexOf(left.toLowerCase());
19637
+ const rightPriority = REPLAY_HEADER_PRIORITY.indexOf(right.toLowerCase());
19638
+ if (leftPriority !== -1 || rightPriority !== -1) {
19639
+ if (leftPriority === -1) {
19640
+ return 1;
19641
+ }
19642
+ if (rightPriority === -1) {
19643
+ return -1;
19644
+ }
19645
+ return leftPriority - rightPriority;
19646
+ }
19647
+ return left.localeCompare(right);
19648
+ });
19649
+ return Object.fromEntries(entries);
19363
19650
  }
19364
19651
  function expandHeaderValues(headers) {
19365
- return sortRecordEntries(headers).flatMap(([headerName, headerValue]) => {
19652
+ return Object.entries(headers).flatMap(([headerName, headerValue]) => {
19366
19653
  if (Array.isArray(headerValue)) {
19367
19654
  return headerValue.map((item) => [headerName, serializeScalarValue(item)]);
19368
19655
  }
@@ -20472,7 +20759,7 @@ function buildCloudSuggestedActions(status, incidentId, mode = "passive_recent_i
20472
20759
  ];
20473
20760
  }
20474
20761
  return [
20475
- "Run debugbundle login to create ~/.debugbundle/auth.json before verifying cloud traffic.",
20762
+ "Run debugbundle login to choose an auth flow, or use debugbundle login --github, debugbundle login --github-device, or debugbundle login <dbundle_mem_...> to create ~/.debugbundle/auth.json before verifying cloud traffic.",
20476
20763
  "Generate a live cloud request, then re-run debugbundle verify cloud with the correct project and service filters."
20477
20764
  ];
20478
20765
  }
@@ -21359,7 +21646,8 @@ function createAlertMcpTools(api) {
21359
21646
  bearerToken: String(input["bearerToken"]),
21360
21647
  projectId: String(input["projectId"]),
21361
21648
  channel: String(input["channel"]),
21362
- conditionType: String(input["conditionType"])
21649
+ conditionType: String(input["conditionType"]),
21650
+ config: input["config"]
21363
21651
  };
21364
21652
  if (typeof input["serviceId"] === "string") {
21365
21653
  requestInput.serviceId = input["serviceId"];
@@ -21367,9 +21655,6 @@ function createAlertMcpTools(api) {
21367
21655
  if (typeof input["severityMin"] === "string") {
21368
21656
  requestInput.severityMin = input["severityMin"];
21369
21657
  }
21370
- if (typeof input["config"] === "object" && input["config"] !== null) {
21371
- requestInput.config = input["config"];
21372
- }
21373
21658
  if (typeof input["isEnabled"] === "boolean") {
21374
21659
  requestInput.isEnabled = input["isEnabled"];
21375
21660
  }
@@ -24726,7 +25011,7 @@ var MCP_TOOL_CATALOG = [
24726
25011
  channel: external_exports.string(),
24727
25012
  conditionType: external_exports.string(),
24728
25013
  severityMin: external_exports.string().optional(),
24729
- config: jsonObjectSchema.optional(),
25014
+ config: jsonObjectSchema,
24730
25015
  isEnabled: external_exports.boolean().optional()
24731
25016
  })
24732
25017
  },
@@ -25030,7 +25315,7 @@ function createMcpServer(input) {
25030
25315
  },
25031
25316
  serverInfo: {
25032
25317
  name: "@debugbundle/mcp",
25033
- version: "0.1.1"
25318
+ version: "0.1.2"
25034
25319
  }
25035
25320
  }
25036
25321
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@debugbundle/mcp",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "description": "Model Context Protocol server for DebugBundle",
6
6
  "license": "AGPL-3.0-only",