@sentry/mcp-server 0.26.0 → 0.28.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 (56) hide show
  1. package/dist/cli/parse.cjs +1 -1
  2. package/dist/cli/parse.d.cts +1 -1
  3. package/dist/cli/parse.d.cts.map +1 -1
  4. package/dist/cli/parse.d.ts +1 -1
  5. package/dist/cli/parse.d.ts.map +1 -1
  6. package/dist/cli/parse.js +1 -1
  7. package/dist/cli/resolve.cjs +1 -1
  8. package/dist/cli/resolve.d.cts +1 -1
  9. package/dist/cli/resolve.d.ts +1 -1
  10. package/dist/cli/resolve.js +1 -1
  11. package/dist/cli/types.d.cts +1 -1
  12. package/dist/cli/types.d.ts +1 -1
  13. package/dist/cli/usage.cjs +1 -1
  14. package/dist/cli/usage.js +1 -1
  15. package/dist/{config-BoFBjXRq-CGHqlnJ9.cjs → config-CEjP2CYO-CZKUamRu.cjs} +2 -2
  16. package/dist/{config-BoFBjXRq-CGHqlnJ9.cjs.map → config-CEjP2CYO-CZKUamRu.cjs.map} +1 -1
  17. package/dist/{config-BoFBjXRq-CMdBQOkQ.js → config-CEjP2CYO-DNCUeo0R.js} +2 -2
  18. package/dist/{config-BoFBjXRq-CMdBQOkQ.js.map → config-CEjP2CYO-DNCUeo0R.js.map} +1 -1
  19. package/dist/config-CwE3_vz4.cjs +7 -0
  20. package/dist/{config-BEgU9ylR.js → config-HqPAzoGg.js} +1 -1
  21. package/dist/index.cjs +1910 -145
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.js +1908 -143
  24. package/dist/index.js.map +1 -1
  25. package/dist/{parse-46t_fITC.js → parse-B9o4fVyT.js} +12 -1
  26. package/dist/parse-B9o4fVyT.js.map +1 -0
  27. package/dist/{parse-BjIH83SX.cjs → parse-c_3eNB2Z.cjs} +12 -1
  28. package/dist/parse-c_3eNB2Z.cjs.map +1 -0
  29. package/dist/{resolve-CdTP9riu.cjs → resolve-DFUPLqHE.cjs} +11 -1
  30. package/dist/resolve-DFUPLqHE.cjs.map +1 -0
  31. package/dist/{resolve-Cg3SH2zt.js → resolve-DpUhCbfh.js} +11 -1
  32. package/dist/resolve-DpUhCbfh.js.map +1 -0
  33. package/dist/{stdio-C47PFfCl.js → stdio-By-q6V_4.js} +3 -3
  34. package/dist/{stdio-C47PFfCl.js.map → stdio-By-q6V_4.js.map} +1 -1
  35. package/dist/{stdio-DFfz0_Ua.cjs → stdio-CjpLGbyD.cjs} +3 -3
  36. package/dist/{stdio-DFfz0_Ua.cjs.map → stdio-CjpLGbyD.cjs.map} +1 -1
  37. package/dist/transports/stdio.cjs +1 -1
  38. package/dist/transports/stdio.js +1 -1
  39. package/dist/{types-D5f00mg9.d.ts → types--Ysz5ZMd.d.cts} +12 -1
  40. package/dist/types--Ysz5ZMd.d.cts.map +1 -0
  41. package/dist/{types-DpmAC3S8.d.cts → types-BlGRNCea.d.ts} +12 -1
  42. package/dist/types-BlGRNCea.d.ts.map +1 -0
  43. package/dist/{usage-DD58xBe3.cjs → usage-D9Tpyb5N.cjs} +15 -5
  44. package/dist/usage-D9Tpyb5N.cjs.map +1 -0
  45. package/dist/{usage-BzYvqaru.js → usage-DR57Krum.js} +15 -5
  46. package/dist/usage-DR57Krum.js.map +1 -0
  47. package/package.json +6 -6
  48. package/dist/config-rZ982IEm.cjs +0 -7
  49. package/dist/parse-46t_fITC.js.map +0 -1
  50. package/dist/parse-BjIH83SX.cjs.map +0 -1
  51. package/dist/resolve-CdTP9riu.cjs.map +0 -1
  52. package/dist/resolve-Cg3SH2zt.js.map +0 -1
  53. package/dist/types-D5f00mg9.d.ts.map +0 -1
  54. package/dist/types-DpmAC3S8.d.cts.map +0 -1
  55. package/dist/usage-BzYvqaru.js.map +0 -1
  56. package/dist/usage-DD58xBe3.cjs.map +0 -1
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { ALL_SKILLS, SKILLS, finalize, getIssueUrl, getIssuesSearchUrl, getTraceUrl, isEnabledBySkills, isSentryHost } from "./resolve-Cg3SH2zt.js";
3
- import { LIB_VERSION, USER_AGENT, startStdio } from "./stdio-C47PFfCl.js";
4
- import { RECOMMENDED_FIELDS, systemPrompt } from "./config-BoFBjXRq-CMdBQOkQ.js";
5
- import { buildUsage } from "./usage-BzYvqaru.js";
6
- import { merge, parseArgv, parseEnv } from "./parse-46t_fITC.js";
2
+ import { ALL_SKILLS, SKILLS, finalize, getIssueUrl, getIssuesSearchUrl, getTraceUrl, isEnabledBySkills, isSentryHost } from "./resolve-DpUhCbfh.js";
3
+ import { LIB_VERSION, USER_AGENT, startStdio } from "./stdio-By-q6V_4.js";
4
+ import { RECOMMENDED_FIELDS, systemPrompt } from "./config-CEjP2CYO-DNCUeo0R.js";
5
+ import { buildUsage } from "./usage-DR57Krum.js";
6
+ import { merge, parseArgv, parseEnv } from "./parse-B9o4fVyT.js";
7
7
  import { z } from "zod";
8
8
  import util from "node:util";
9
9
  import { captureException, captureMessage, getActiveSpan, logger, setTag, setUser, withScope, wrapMcpServerWithSentry } from "@sentry/core";
@@ -1783,7 +1783,7 @@ function logIssue(error, contextsOrOptions, attachmentsArg) {
1783
1783
  }
1784
1784
 
1785
1785
  //#endregion
1786
- //#region ../mcp-core/dist/schema-BO1YtJIJ.js
1786
+ //#region ../mcp-core/dist/schema-VoUcElu5.js
1787
1787
  /**
1788
1788
  * Schema for Sentry API error responses.
1789
1789
  *
@@ -2206,6 +2206,31 @@ const EventAttachmentSchema = z.object({
2206
2206
  });
2207
2207
  const EventAttachmentListSchema = z.array(EventAttachmentSchema);
2208
2208
  /**
2209
+ * Schema for individual tag values within an issue's tag distribution.
2210
+ *
2211
+ * Represents a single value's occurrence count and percentage within a tag.
2212
+ */
2213
+ const IssueTagValueSchema = z.object({
2214
+ key: z.string().nullable().optional(),
2215
+ name: z.string().nullable().optional(),
2216
+ value: z.string().nullable(),
2217
+ count: z.number(),
2218
+ lastSeen: z.string().datetime().nullable().optional(),
2219
+ firstSeen: z.string().datetime().nullable().optional()
2220
+ });
2221
+ /**
2222
+ * Schema for Sentry issue tag values response.
2223
+ *
2224
+ * Contains aggregate counts of unique tag values for an issue,
2225
+ * useful for understanding the distribution of tags like URL, browser, etc.
2226
+ */
2227
+ const IssueTagValuesSchema = z.object({
2228
+ key: z.string(),
2229
+ name: z.string(),
2230
+ totalValues: z.number(),
2231
+ topValues: z.array(IssueTagValueSchema)
2232
+ });
2233
+ /**
2209
2234
  * Schema for Sentry trace metadata response.
2210
2235
  *
2211
2236
  * Contains high-level statistics about a trace including span counts,
@@ -2495,7 +2520,7 @@ function createApiError(message, status, detail, responseBody) {
2495
2520
  }
2496
2521
 
2497
2522
  //#endregion
2498
- //#region ../mcp-core/dist/client-EbNZG3Z_.js
2523
+ //#region ../mcp-core/dist/client-B2nQcl5S.js
2499
2524
  /**
2500
2525
  * Mapping of common network error codes to user-friendly messages.
2501
2526
  * These help users understand and resolve connection issues.
@@ -2593,6 +2618,27 @@ var SentryApiService = class {
2593
2618
  return isSentryHost(this.host);
2594
2619
  }
2595
2620
  /**
2621
+ * Validates and applies time parameters to a URLSearchParams object.
2622
+ *
2623
+ * Enforces mutual exclusivity between relative (statsPeriod) and
2624
+ * absolute (start/end) time ranges, and ensures start/end are paired.
2625
+ *
2626
+ * @param queryParams The URLSearchParams to modify
2627
+ * @param statsPeriod Relative time period (e.g., "24h", "7d")
2628
+ * @param start Absolute start time (ISO 8601)
2629
+ * @param end Absolute end time (ISO 8601)
2630
+ * @throws {ApiValidationError} If time parameters are invalid
2631
+ */
2632
+ applyTimeParams(queryParams, statsPeriod, start, end) {
2633
+ if (statsPeriod && (start || end)) throw new ApiValidationError("Cannot use both statsPeriod and start/end parameters. Use either statsPeriod for relative time or start/end for absolute time.");
2634
+ if (start && !end || !start && end) throw new ApiValidationError("Both start and end parameters must be provided together for absolute time ranges.");
2635
+ if (statsPeriod) queryParams.set("statsPeriod", statsPeriod);
2636
+ else if (start && end) {
2637
+ queryParams.set("start", start);
2638
+ queryParams.set("end", end);
2639
+ }
2640
+ }
2641
+ /**
2596
2642
  * Internal method for making authenticated requests to Sentry API.
2597
2643
  *
2598
2644
  * Handles:
@@ -3187,13 +3233,7 @@ var SentryApiService = class {
3187
3233
  const searchQuery = new URLSearchParams();
3188
3234
  if (dataset) searchQuery.set("dataset", dataset);
3189
3235
  if (project) searchQuery.set("project", project);
3190
- if (statsPeriod && (start || end)) throw new ApiValidationError("Cannot use both statsPeriod and start/end parameters. Use either statsPeriod for relative time or start/end for absolute time.");
3191
- if (start && !end || !start && end) throw new ApiValidationError("Both start and end parameters must be provided together for absolute time ranges.");
3192
- if (statsPeriod) searchQuery.set("statsPeriod", statsPeriod);
3193
- else if (start && end) {
3194
- searchQuery.set("start", start);
3195
- searchQuery.set("end", end);
3196
- }
3236
+ this.applyTimeParams(searchQuery, statsPeriod, start, end);
3197
3237
  if (useCache !== void 0) searchQuery.set("useCache", useCache ? "1" : "0");
3198
3238
  if (useFlagsBackend !== void 0) searchQuery.set("useFlagsBackend", useFlagsBackend ? "1" : "0");
3199
3239
  const body = await this.requestJSON(searchQuery.toString() ? `/organizations/${organizationSlug}/tags/?${searchQuery.toString()}` : `/organizations/${organizationSlug}/tags/`, void 0, opts);
@@ -3233,13 +3273,7 @@ var SentryApiService = class {
3233
3273
  queryParams.set("itemType", itemType);
3234
3274
  queryParams.set("attributeType", attributeType);
3235
3275
  if (project) queryParams.set("project", project);
3236
- if (statsPeriod && (start || end)) throw new ApiValidationError("Cannot use both statsPeriod and start/end parameters. Use either statsPeriod for relative time or start/end for absolute time.");
3237
- if (start && !end || !start && end) throw new ApiValidationError("Both start and end parameters must be provided together for absolute time ranges.");
3238
- if (statsPeriod) queryParams.set("statsPeriod", statsPeriod);
3239
- else if (start && end) {
3240
- queryParams.set("start", start);
3241
- queryParams.set("end", end);
3242
- }
3276
+ this.applyTimeParams(queryParams, statsPeriod, start, end);
3243
3277
  const url = `/organizations/${organizationSlug}/trace-items/attributes/?${queryParams.toString()}`;
3244
3278
  const body = await this.requestJSON(url, void 0, opts);
3245
3279
  return Array.isArray(body) ? body : [];
@@ -3293,6 +3327,35 @@ var SentryApiService = class {
3293
3327
  const body = await this.requestJSON(`/organizations/${organizationSlug}/issues/${issueId}/`, void 0, opts);
3294
3328
  return IssueSchema.parse(body);
3295
3329
  }
3330
+ /**
3331
+ * Retrieves tag value distribution for a specific issue.
3332
+ *
3333
+ * Returns aggregate counts of unique tag values, useful for understanding
3334
+ * how an issue is distributed across different tag values (e.g., URLs,
3335
+ * browsers, environments).
3336
+ *
3337
+ * @param params Query parameters
3338
+ * @param params.organizationSlug Organization identifier
3339
+ * @param params.issueId Issue identifier (short ID or numeric ID)
3340
+ * @param params.tagKey Tag key to get values for (e.g., "url", "browser", "environment")
3341
+ * @param opts Request options
3342
+ * @returns Tag value distribution with counts and percentages
3343
+ *
3344
+ * @example
3345
+ * ```typescript
3346
+ * const tagValues = await apiService.getIssueTagValues({
3347
+ * organizationSlug: "my-org",
3348
+ * issueId: "PROJECT-123",
3349
+ * tagKey: "url"
3350
+ * });
3351
+ * console.log(`Total unique values: ${tagValues.totalValues}`);
3352
+ * tagValues.topValues.forEach(v => console.log(`${v.value}: ${v.count}`));
3353
+ * ```
3354
+ */
3355
+ async getIssueTagValues({ organizationSlug, issueId, tagKey }, opts) {
3356
+ const body = await this.requestJSON(`/organizations/${organizationSlug}/issues/${issueId}/tags/${tagKey}/`, void 0, opts);
3357
+ return IssueTagValuesSchema.parse(body);
3358
+ }
3296
3359
  async getEventForIssue({ organizationSlug, issueId, eventId }, opts) {
3297
3360
  const body = await this.requestJSON(`/organizations/${organizationSlug}/issues/${issueId}/events/${eventId}/`, void 0, opts);
3298
3361
  const parseResult = EventSchema.safeParse(body);
@@ -3433,13 +3496,7 @@ var SentryApiService = class {
3433
3496
  queryParams.set("per_page", params.limit.toString());
3434
3497
  queryParams.set("query", params.query);
3435
3498
  queryParams.set("dataset", "errors");
3436
- if (params.statsPeriod && (params.start || params.end)) throw new ApiValidationError("Cannot use both statsPeriod and start/end parameters. Use either statsPeriod for relative time or start/end for absolute time.");
3437
- if (params.start && !params.end || !params.start && params.end) throw new ApiValidationError("Both start and end parameters must be provided together for absolute time ranges.");
3438
- if (params.statsPeriod) queryParams.set("statsPeriod", params.statsPeriod);
3439
- else if (params.start && params.end) {
3440
- queryParams.set("start", params.start);
3441
- queryParams.set("end", params.end);
3442
- }
3499
+ this.applyTimeParams(queryParams, params.statsPeriod, params.start, params.end);
3443
3500
  if (params.projectId) queryParams.set("project", params.projectId);
3444
3501
  let apiSort = params.sort;
3445
3502
  if (params.sort?.includes("(") && !params.sort?.includes("equation|")) {
@@ -3467,13 +3524,7 @@ var SentryApiService = class {
3467
3524
  queryParams.set("per_page", params.limit.toString());
3468
3525
  queryParams.set("query", params.query);
3469
3526
  queryParams.set("dataset", params.dataset);
3470
- if (params.statsPeriod && (params.start || params.end)) throw new ApiValidationError("Cannot use both statsPeriod and start/end parameters. Use either statsPeriod for relative time or start/end for absolute time.");
3471
- if (params.start && !params.end || !params.start && params.end) throw new ApiValidationError("Both start and end parameters must be provided together for absolute time ranges.");
3472
- if (params.statsPeriod) queryParams.set("statsPeriod", params.statsPeriod);
3473
- else if (params.start && params.end) {
3474
- queryParams.set("start", params.start);
3475
- queryParams.set("end", params.end);
3476
- }
3527
+ this.applyTimeParams(queryParams, params.statsPeriod, params.start, params.end);
3477
3528
  if (params.projectId) queryParams.set("project", params.projectId);
3478
3529
  if (params.dataset === "spans") queryParams.set("sampling", "NORMAL");
3479
3530
  let apiSort = params.sort;
@@ -3636,7 +3687,7 @@ function validateRegionUrl(regionUrl, baseHost) {
3636
3687
  }
3637
3688
 
3638
3689
  //#endregion
3639
- //#region ../mcp-core/dist/api-C4iLorVN.js
3690
+ //#region ../mcp-core/dist/api-DVbaHIM5.js
3640
3691
  /**
3641
3692
  * Create a Sentry API service from server context with optional region override
3642
3693
  * @param context - Server context containing host and access token
@@ -3657,7 +3708,7 @@ function apiServiceFromContext(context$1, opts = {}) {
3657
3708
  }
3658
3709
 
3659
3710
  //#endregion
3660
- //#region ../mcp-core/dist/whoami-4TjhUF9I.js
3711
+ //#region ../mcp-core/dist/whoami-CEHtgXJv.js
3661
3712
  var whoami_default = defineTool({
3662
3713
  name: "whoami",
3663
3714
  description: [
@@ -3690,7 +3741,7 @@ var whoami_default = defineTool({
3690
3741
  });
3691
3742
 
3692
3743
  //#endregion
3693
- //#region ../mcp-core/dist/find-organizations-CY_CprTd.js
3744
+ //#region ../mcp-core/dist/find-organizations-Bs2wsqQ7.js
3694
3745
  const RESULT_LIMIT$2 = 25;
3695
3746
  var find_organizations_default = defineTool({
3696
3747
  name: "find_organizations",
@@ -3742,7 +3793,7 @@ var find_organizations_default = defineTool({
3742
3793
  });
3743
3794
 
3744
3795
  //#endregion
3745
- //#region ../mcp-core/dist/find-teams-D20sronT.js
3796
+ //#region ../mcp-core/dist/find-teams-CgsSmQ8X.js
3746
3797
  const RESULT_LIMIT$1 = 25;
3747
3798
  var find_teams_default = defineTool({
3748
3799
  name: "find_teams",
@@ -3790,7 +3841,7 @@ var find_teams_default = defineTool({
3790
3841
  });
3791
3842
 
3792
3843
  //#endregion
3793
- //#region ../mcp-core/dist/find-projects-BIbLskbP.js
3844
+ //#region ../mcp-core/dist/find-projects-Cxw1nnPQ.js
3794
3845
  const RESULT_LIMIT = 25;
3795
3846
  var find_projects_default = defineTool({
3796
3847
  name: "find_projects",
@@ -3834,7 +3885,7 @@ var find_projects_default = defineTool({
3834
3885
  });
3835
3886
 
3836
3887
  //#endregion
3837
- //#region ../mcp-core/dist/find-releases-DddLqSmt.js
3888
+ //#region ../mcp-core/dist/find-releases-zWgFsagR.js
3838
3889
  var find_releases_default = defineTool({
3839
3890
  name: "find_releases",
3840
3891
  skills: ["inspect"],
@@ -5079,7 +5130,7 @@ function enhanceNotFoundError(error, params) {
5079
5130
  }
5080
5131
 
5081
5132
  //#endregion
5082
- //#region ../mcp-core/dist/get-issue-details-Dv2HsHlt.js
5133
+ //#region ../mcp-core/dist/get-issue-details-CsNkINzN.js
5083
5134
  var get_issue_details_default = defineTool({
5084
5135
  name: "get_issue_details",
5085
5136
  skills: [
@@ -5260,7 +5311,122 @@ function shouldFetchTraceForEvent(event) {
5260
5311
  }
5261
5312
 
5262
5313
  //#endregion
5263
- //#region ../mcp-core/dist/get-trace-details-QaT2N9BA.js
5314
+ //#region ../mcp-core/dist/get-issue-tag-values-B4lzlivL.js
5315
+ var get_issue_tag_values_default = defineTool({
5316
+ name: "get_issue_tag_values",
5317
+ skills: ["inspect"],
5318
+ requiredScopes: ["event:read"],
5319
+ description: [
5320
+ "Get tag value distribution for a specific Sentry issue.",
5321
+ "",
5322
+ "Use this tool when you need to:",
5323
+ "- Understand how an issue is distributed across different tag values",
5324
+ "- Get aggregate counts of unique tag values (e.g., 'how many unique URLs are affected')",
5325
+ "- Analyze which browsers, environments, or URLs are most impacted by an issue",
5326
+ "- View the tag distributions page data programmatically",
5327
+ "",
5328
+ "Common tag keys:",
5329
+ "- `url`: Request URLs affected by the issue",
5330
+ "- `browser`: Browser types and versions",
5331
+ "- `browser.name`: Browser names only",
5332
+ "- `os`: Operating systems",
5333
+ "- `environment`: Deployment environments (production, staging, etc.)",
5334
+ "- `release`: Software releases",
5335
+ "- `device`: Device types",
5336
+ "- `user`: Affected users",
5337
+ "",
5338
+ "<examples>",
5339
+ "### Get URL distribution for an issue",
5340
+ "```",
5341
+ "get_issue_tag_values(organizationSlug='my-organization', issueId='PROJECT-123', tagKey='url')",
5342
+ "```",
5343
+ "",
5344
+ "### Get browser distribution using issue URL",
5345
+ "```",
5346
+ "get_issue_tag_values(issueUrl='https://sentry.io/issues/PROJECT-123/', tagKey='browser')",
5347
+ "```",
5348
+ "",
5349
+ "### Get environment distribution",
5350
+ "```",
5351
+ "get_issue_tag_values(organizationSlug='my-organization', issueId='PROJECT-123', tagKey='environment')",
5352
+ "```",
5353
+ "</examples>",
5354
+ "",
5355
+ "<hints>",
5356
+ "- If user provides a Sentry URL, pass the ENTIRE URL to issueUrl parameter unchanged",
5357
+ "- Common tag keys: url, browser, browser.name, os, environment, release, device, user",
5358
+ "- Tag keys are case-sensitive",
5359
+ "</hints>"
5360
+ ].join("\n"),
5361
+ inputSchema: {
5362
+ organizationSlug: ParamOrganizationSlug.optional(),
5363
+ regionUrl: ParamRegionUrl.nullable().default(null),
5364
+ issueId: ParamIssueShortId.optional(),
5365
+ issueUrl: ParamIssueUrl.optional(),
5366
+ tagKey: z.string().trim().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/, "Tag key must contain only alphanumeric characters, dots, hyphens, and underscores, and must start with an alphanumeric character").describe("The tag key to get values for (e.g., 'url', 'browser', 'environment', 'release').")
5367
+ },
5368
+ annotations: {
5369
+ readOnlyHint: true,
5370
+ openWorldHint: true
5371
+ },
5372
+ async handler(params, context$1) {
5373
+ const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
5374
+ if (!params.issueUrl && !params.issueId) throw new UserInputError("Either `issueId` or `issueUrl` must be provided");
5375
+ if (!params.issueUrl && !params.organizationSlug) throw new UserInputError("`organizationSlug` is required when providing `issueId`");
5376
+ if (!params.tagKey) throw new UserInputError("`tagKey` is required. Common values: url, browser, environment, release, os, device, user");
5377
+ const { organizationSlug: orgSlug, issueId: parsedIssueId } = parseIssueParams$1({
5378
+ organizationSlug: params.organizationSlug,
5379
+ issueId: params.issueId,
5380
+ issueUrl: params.issueUrl
5381
+ });
5382
+ setTag("organization.slug", orgSlug);
5383
+ let tagValues;
5384
+ try {
5385
+ tagValues = await apiService.getIssueTagValues({
5386
+ organizationSlug: orgSlug,
5387
+ issueId: parsedIssueId,
5388
+ tagKey: params.tagKey
5389
+ });
5390
+ } catch (error) {
5391
+ if (error instanceof ApiNotFoundError) throw enhanceNotFoundError(error, {
5392
+ organizationSlug: orgSlug,
5393
+ issueId: parsedIssueId,
5394
+ tagKey: params.tagKey
5395
+ });
5396
+ throw error;
5397
+ }
5398
+ let output = `# Tag Distribution: ${tagValues.name}\n\n`;
5399
+ output += `**Issue**: ${parsedIssueId}\n`;
5400
+ output += `**Tag Key**: \`${tagValues.key}\`\n`;
5401
+ output += `**Total Unique Values**: ${tagValues.totalValues}\n\n`;
5402
+ if (tagValues.topValues.length === 0) {
5403
+ output += "No values found for this tag.\n";
5404
+ return output;
5405
+ }
5406
+ output += "## Top Values\n\n";
5407
+ output += "| Value | Count | First Seen | Last Seen |\n";
5408
+ output += "|-------|-------|------------|----------|\n";
5409
+ for (const value of tagValues.topValues) {
5410
+ const firstSeen = value.firstSeen ? new Date(value.firstSeen).toISOString().split("T")[0] : "-";
5411
+ const lastSeen = value.lastSeen ? new Date(value.lastSeen).toISOString().split("T")[0] : "-";
5412
+ const rawValue = value.value ?? "(null)";
5413
+ let displayValue = rawValue.length > 60 ? `${rawValue.substring(0, 57)}...` : rawValue;
5414
+ displayValue = displayValue.replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/`/g, "\\`").replace(/\n/g, " ");
5415
+ output += `| \`${displayValue}\` | ${value.count} | ${firstSeen} | ${lastSeen} |\n`;
5416
+ }
5417
+ if (tagValues.topValues.length > 0 && tagValues.totalValues > 0) {
5418
+ const shownCount = tagValues.topValues.length;
5419
+ output += `\n*Showing top ${shownCount} of ${tagValues.totalValues} unique values*\n`;
5420
+ }
5421
+ output += "\n## Using this information\n\n";
5422
+ output += `- Use \`get_issue_details(organizationSlug='${orgSlug}', issueId='${parsedIssueId}')\` to see the full issue details\n`;
5423
+ output += `- Try other tag keys like: url, browser, environment, release, os, device, user\n`;
5424
+ return output;
5425
+ }
5426
+ });
5427
+
5428
+ //#endregion
5429
+ //#region ../mcp-core/dist/get-trace-details-DAPondqS.js
5264
5430
  const MAX_DEPTH = 2;
5265
5431
  const MINIMUM_DURATION_THRESHOLD_MS = 10;
5266
5432
  const MIN_MEANINGFUL_CHILD_DURATION = 5;
@@ -5559,7 +5725,7 @@ function formatTraceOutput({ organizationSlug, traceId, traceMeta, trace: trace$
5559
5725
  }
5560
5726
 
5561
5727
  //#endregion
5562
- //#region ../mcp-core/dist/get-event-attachment-DdhoqwCO.js
5728
+ //#region ../mcp-core/dist/get-event-attachment-C-huGpTH.js
5563
5729
  var get_event_attachment_default = defineTool({
5564
5730
  name: "get_event_attachment",
5565
5731
  skills: ["inspect"],
@@ -5695,7 +5861,7 @@ var get_event_attachment_default = defineTool({
5695
5861
  });
5696
5862
 
5697
5863
  //#endregion
5698
- //#region ../mcp-core/dist/formatting-DJFcfTJG.js
5864
+ //#region ../mcp-core/dist/formatting-CIwRyNGU.js
5699
5865
  /**
5700
5866
  * Helper function to format assignedTo field for display
5701
5867
  */
@@ -5707,7 +5873,7 @@ function formatAssignedTo(assignedTo) {
5707
5873
  }
5708
5874
 
5709
5875
  //#endregion
5710
- //#region ../mcp-core/dist/update-issue-JybAx8DT.js
5876
+ //#region ../mcp-core/dist/update-issue-BArI_SjL.js
5711
5877
  var update_issue_default = defineTool({
5712
5878
  name: "update_issue",
5713
5879
  skills: ["triage"],
@@ -6004,6 +6170,20 @@ var name10$1 = "AI_NoSuchModelError";
6004
6170
  var marker11$1 = `vercel.ai.error.${name10$1}`;
6005
6171
  var symbol11$1 = Symbol.for(marker11$1);
6006
6172
  var _a11$1;
6173
+ var NoSuchModelError = class extends AISDKError {
6174
+ constructor({ errorName = name10$1, modelId, modelType, message = `No such ${modelType}: ${modelId}` }) {
6175
+ super({
6176
+ name: errorName,
6177
+ message
6178
+ });
6179
+ this[_a11$1] = true;
6180
+ this.modelId = modelId;
6181
+ this.modelType = modelType;
6182
+ }
6183
+ static isInstance(error) {
6184
+ return AISDKError.hasMarker(error, marker11$1);
6185
+ }
6186
+ };
6007
6187
  _a11$1 = symbol11$1;
6008
6188
  var name11$1 = "AI_TooManyEmbeddingValuesForCallError";
6009
6189
  var marker12$1 = `vercel.ai.error.${name11$1}`;
@@ -6539,6 +6719,10 @@ var postToApi = async ({ url, headers = {}, body, successfulResponseHandler, fai
6539
6719
  throw error;
6540
6720
  }
6541
6721
  };
6722
+ async function resolve(value) {
6723
+ if (typeof value === "function") value = value();
6724
+ return Promise.resolve(value);
6725
+ }
6542
6726
  var createJsonErrorResponseHandler = ({ errorSchema, errorToMessage, isRetryable }) => async ({ response, url, requestBodyValues }) => {
6543
6727
  const responseBody = await response.text();
6544
6728
  const responseHeaders = extractResponseHeaders(response);
@@ -6854,7 +7038,7 @@ function getResponseMetadata({ id, model, created }) {
6854
7038
  timestamp: created != null ? /* @__PURE__ */ new Date(created * 1e3) : void 0
6855
7039
  };
6856
7040
  }
6857
- function prepareTools({ mode, useLegacyFunctionCalling = false, structuredOutputs }) {
7041
+ function prepareTools$1({ mode, useLegacyFunctionCalling = false, structuredOutputs }) {
6858
7042
  var _a$2;
6859
7043
  const tools = ((_a$2 = mode.tools) == null ? void 0 : _a$2.length) ? mode.tools : void 0;
6860
7044
  const toolWarnings = [];
@@ -7082,7 +7266,7 @@ var OpenAIChatLanguageModel = class {
7082
7266
  }
7083
7267
  switch (type) {
7084
7268
  case "regular": {
7085
- const { tools, tool_choice, functions, function_call, toolWarnings } = prepareTools({
7269
+ const { tools, tool_choice, functions, function_call, toolWarnings } = prepareTools$1({
7086
7270
  mode,
7087
7271
  useLegacyFunctionCalling,
7088
7272
  structuredOutputs: this.supportsStructuredOutputs
@@ -8977,49 +9161,1278 @@ function createOpenAI(options = {}) {
8977
9161
  provider.tools = openaiTools;
8978
9162
  return provider;
8979
9163
  }
8980
- var openai = createOpenAI({ compatibility: "strict" });
9164
+ var openai = createOpenAI({ compatibility: "strict" });
9165
+
9166
+ //#endregion
9167
+ //#region ../mcp-core/dist/openai-provider-Cc13TpEA.js
9168
+ const DEFAULT_OPENAI_MODEL = "gpt-5";
9169
+ let configuredBaseUrl$1;
9170
+ /**
9171
+ * Configure the OpenAI base URL (CLI flag only, not environment variable).
9172
+ * This must be called explicitly - it cannot be set via environment variables for security.
9173
+ */
9174
+ function setOpenAIBaseUrl(baseUrl) {
9175
+ configuredBaseUrl$1 = baseUrl;
9176
+ }
9177
+ /**
9178
+ * Retrieve an OpenAI language model configured from environment variables and explicit config.
9179
+ *
9180
+ * Works with:
9181
+ * - OpenAI API directly (default)
9182
+ * - Any OpenAI-compatible API via custom base URL (Vercel AI Gateway, Azure OpenAI, etc.)
9183
+ *
9184
+ * Configuration:
9185
+ * - OPENAI_API_KEY: API key for authentication (required)
9186
+ * - OPENAI_MODEL: Model to use (default: "gpt-5") - env var OK
9187
+ * - Base URL: Must be set via setOpenAIBaseUrl() - NOT from env vars (security risk)
9188
+ *
9189
+ * Note: Model name format depends on your provider:
9190
+ * - Direct OpenAI: "gpt-4o", "gpt-4-turbo", etc.
9191
+ * - Vercel AI Gateway: "openai/gpt-4o", "anthropic/claude-sonnet-4.5", etc.
9192
+ * - Other providers: Check their documentation
9193
+ */
9194
+ function getOpenAIModel(model) {
9195
+ const defaultModel = process.env.OPENAI_MODEL || DEFAULT_OPENAI_MODEL;
9196
+ const factory = createOpenAI({
9197
+ ...configuredBaseUrl$1 && { baseURL: configuredBaseUrl$1 },
9198
+ headers: { "User-Agent": USER_AGENT }
9199
+ });
9200
+ return factory(model ?? defaultModel);
9201
+ }
9202
+
9203
+ //#endregion
9204
+ //#region ../../node_modules/.pnpm/@ai-sdk+anthropic@1.2.12_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.mjs
9205
+ var anthropicErrorDataSchema = z.object({
9206
+ type: z.literal("error"),
9207
+ error: z.object({
9208
+ type: z.string(),
9209
+ message: z.string()
9210
+ })
9211
+ });
9212
+ var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
9213
+ errorSchema: anthropicErrorDataSchema,
9214
+ errorToMessage: (data) => data.error.message
9215
+ });
9216
+ function prepareTools(mode) {
9217
+ var _a$2;
9218
+ const tools = ((_a$2 = mode.tools) == null ? void 0 : _a$2.length) ? mode.tools : void 0;
9219
+ const toolWarnings = [];
9220
+ const betas = /* @__PURE__ */ new Set();
9221
+ if (tools == null) return {
9222
+ tools: void 0,
9223
+ tool_choice: void 0,
9224
+ toolWarnings,
9225
+ betas
9226
+ };
9227
+ const anthropicTools2 = [];
9228
+ for (const tool$1 of tools) switch (tool$1.type) {
9229
+ case "function":
9230
+ anthropicTools2.push({
9231
+ name: tool$1.name,
9232
+ description: tool$1.description,
9233
+ input_schema: tool$1.parameters
9234
+ });
9235
+ break;
9236
+ case "provider-defined":
9237
+ switch (tool$1.id) {
9238
+ case "anthropic.computer_20250124":
9239
+ betas.add("computer-use-2025-01-24");
9240
+ anthropicTools2.push({
9241
+ name: tool$1.name,
9242
+ type: "computer_20250124",
9243
+ display_width_px: tool$1.args.displayWidthPx,
9244
+ display_height_px: tool$1.args.displayHeightPx,
9245
+ display_number: tool$1.args.displayNumber
9246
+ });
9247
+ break;
9248
+ case "anthropic.computer_20241022":
9249
+ betas.add("computer-use-2024-10-22");
9250
+ anthropicTools2.push({
9251
+ name: tool$1.name,
9252
+ type: "computer_20241022",
9253
+ display_width_px: tool$1.args.displayWidthPx,
9254
+ display_height_px: tool$1.args.displayHeightPx,
9255
+ display_number: tool$1.args.displayNumber
9256
+ });
9257
+ break;
9258
+ case "anthropic.text_editor_20250124":
9259
+ betas.add("computer-use-2025-01-24");
9260
+ anthropicTools2.push({
9261
+ name: tool$1.name,
9262
+ type: "text_editor_20250124"
9263
+ });
9264
+ break;
9265
+ case "anthropic.text_editor_20241022":
9266
+ betas.add("computer-use-2024-10-22");
9267
+ anthropicTools2.push({
9268
+ name: tool$1.name,
9269
+ type: "text_editor_20241022"
9270
+ });
9271
+ break;
9272
+ case "anthropic.bash_20250124":
9273
+ betas.add("computer-use-2025-01-24");
9274
+ anthropicTools2.push({
9275
+ name: tool$1.name,
9276
+ type: "bash_20250124"
9277
+ });
9278
+ break;
9279
+ case "anthropic.bash_20241022":
9280
+ betas.add("computer-use-2024-10-22");
9281
+ anthropicTools2.push({
9282
+ name: tool$1.name,
9283
+ type: "bash_20241022"
9284
+ });
9285
+ break;
9286
+ default:
9287
+ toolWarnings.push({
9288
+ type: "unsupported-tool",
9289
+ tool: tool$1
9290
+ });
9291
+ break;
9292
+ }
9293
+ break;
9294
+ default:
9295
+ toolWarnings.push({
9296
+ type: "unsupported-tool",
9297
+ tool: tool$1
9298
+ });
9299
+ break;
9300
+ }
9301
+ const toolChoice = mode.toolChoice;
9302
+ if (toolChoice == null) return {
9303
+ tools: anthropicTools2,
9304
+ tool_choice: void 0,
9305
+ toolWarnings,
9306
+ betas
9307
+ };
9308
+ const type = toolChoice.type;
9309
+ switch (type) {
9310
+ case "auto": return {
9311
+ tools: anthropicTools2,
9312
+ tool_choice: { type: "auto" },
9313
+ toolWarnings,
9314
+ betas
9315
+ };
9316
+ case "required": return {
9317
+ tools: anthropicTools2,
9318
+ tool_choice: { type: "any" },
9319
+ toolWarnings,
9320
+ betas
9321
+ };
9322
+ case "none": return {
9323
+ tools: void 0,
9324
+ tool_choice: void 0,
9325
+ toolWarnings,
9326
+ betas
9327
+ };
9328
+ case "tool": return {
9329
+ tools: anthropicTools2,
9330
+ tool_choice: {
9331
+ type: "tool",
9332
+ name: toolChoice.toolName
9333
+ },
9334
+ toolWarnings,
9335
+ betas
9336
+ };
9337
+ default: {
9338
+ const _exhaustiveCheck = type;
9339
+ throw new UnsupportedFunctionalityError({ functionality: `Unsupported tool choice type: ${_exhaustiveCheck}` });
9340
+ }
9341
+ }
9342
+ }
9343
+ function convertToAnthropicMessagesPrompt({ prompt, sendReasoning, warnings }) {
9344
+ var _a$2, _b, _c, _d;
9345
+ const betas = /* @__PURE__ */ new Set();
9346
+ const blocks = groupIntoBlocks(prompt);
9347
+ let system = void 0;
9348
+ const messages = [];
9349
+ function getCacheControl(providerMetadata) {
9350
+ var _a2$2;
9351
+ const anthropic2 = providerMetadata == null ? void 0 : providerMetadata.anthropic;
9352
+ const cacheControlValue = (_a2$2 = anthropic2 == null ? void 0 : anthropic2.cacheControl) != null ? _a2$2 : anthropic2 == null ? void 0 : anthropic2.cache_control;
9353
+ return cacheControlValue;
9354
+ }
9355
+ for (let i = 0; i < blocks.length; i++) {
9356
+ const block = blocks[i];
9357
+ const isLastBlock = i === blocks.length - 1;
9358
+ const type = block.type;
9359
+ switch (type) {
9360
+ case "system": {
9361
+ if (system != null) throw new UnsupportedFunctionalityError({ functionality: "Multiple system messages that are separated by user/assistant messages" });
9362
+ system = block.messages.map(({ content, providerMetadata }) => ({
9363
+ type: "text",
9364
+ text: content,
9365
+ cache_control: getCacheControl(providerMetadata)
9366
+ }));
9367
+ break;
9368
+ }
9369
+ case "user": {
9370
+ const anthropicContent = [];
9371
+ for (const message of block.messages) {
9372
+ const { role, content } = message;
9373
+ switch (role) {
9374
+ case "user": {
9375
+ for (let j = 0; j < content.length; j++) {
9376
+ const part = content[j];
9377
+ const isLastPart = j === content.length - 1;
9378
+ const cacheControl = (_a$2 = getCacheControl(part.providerMetadata)) != null ? _a$2 : isLastPart ? getCacheControl(message.providerMetadata) : void 0;
9379
+ switch (part.type) {
9380
+ case "text": {
9381
+ anthropicContent.push({
9382
+ type: "text",
9383
+ text: part.text,
9384
+ cache_control: cacheControl
9385
+ });
9386
+ break;
9387
+ }
9388
+ case "image": {
9389
+ anthropicContent.push({
9390
+ type: "image",
9391
+ source: part.image instanceof URL ? {
9392
+ type: "url",
9393
+ url: part.image.toString()
9394
+ } : {
9395
+ type: "base64",
9396
+ media_type: (_b = part.mimeType) != null ? _b : "image/jpeg",
9397
+ data: convertUint8ArrayToBase64(part.image)
9398
+ },
9399
+ cache_control: cacheControl
9400
+ });
9401
+ break;
9402
+ }
9403
+ case "file": {
9404
+ if (part.mimeType !== "application/pdf") throw new UnsupportedFunctionalityError({ functionality: "Non-PDF files in user messages" });
9405
+ betas.add("pdfs-2024-09-25");
9406
+ anthropicContent.push({
9407
+ type: "document",
9408
+ source: part.data instanceof URL ? {
9409
+ type: "url",
9410
+ url: part.data.toString()
9411
+ } : {
9412
+ type: "base64",
9413
+ media_type: "application/pdf",
9414
+ data: part.data
9415
+ },
9416
+ cache_control: cacheControl
9417
+ });
9418
+ break;
9419
+ }
9420
+ }
9421
+ }
9422
+ break;
9423
+ }
9424
+ case "tool": {
9425
+ for (let i2 = 0; i2 < content.length; i2++) {
9426
+ const part = content[i2];
9427
+ const isLastPart = i2 === content.length - 1;
9428
+ const cacheControl = (_c = getCacheControl(part.providerMetadata)) != null ? _c : isLastPart ? getCacheControl(message.providerMetadata) : void 0;
9429
+ const toolResultContent = part.content != null ? part.content.map((part2) => {
9430
+ var _a2$2;
9431
+ switch (part2.type) {
9432
+ case "text": return {
9433
+ type: "text",
9434
+ text: part2.text,
9435
+ cache_control: void 0
9436
+ };
9437
+ case "image": return {
9438
+ type: "image",
9439
+ source: {
9440
+ type: "base64",
9441
+ media_type: (_a2$2 = part2.mimeType) != null ? _a2$2 : "image/jpeg",
9442
+ data: part2.data
9443
+ },
9444
+ cache_control: void 0
9445
+ };
9446
+ }
9447
+ }) : JSON.stringify(part.result);
9448
+ anthropicContent.push({
9449
+ type: "tool_result",
9450
+ tool_use_id: part.toolCallId,
9451
+ content: toolResultContent,
9452
+ is_error: part.isError,
9453
+ cache_control: cacheControl
9454
+ });
9455
+ }
9456
+ break;
9457
+ }
9458
+ default: {
9459
+ const _exhaustiveCheck = role;
9460
+ throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
9461
+ }
9462
+ }
9463
+ }
9464
+ messages.push({
9465
+ role: "user",
9466
+ content: anthropicContent
9467
+ });
9468
+ break;
9469
+ }
9470
+ case "assistant": {
9471
+ const anthropicContent = [];
9472
+ for (let j = 0; j < block.messages.length; j++) {
9473
+ const message = block.messages[j];
9474
+ const isLastMessage = j === block.messages.length - 1;
9475
+ const { content } = message;
9476
+ for (let k = 0; k < content.length; k++) {
9477
+ const part = content[k];
9478
+ const isLastContentPart = k === content.length - 1;
9479
+ const cacheControl = (_d = getCacheControl(part.providerMetadata)) != null ? _d : isLastContentPart ? getCacheControl(message.providerMetadata) : void 0;
9480
+ switch (part.type) {
9481
+ case "text": {
9482
+ anthropicContent.push({
9483
+ type: "text",
9484
+ text: isLastBlock && isLastMessage && isLastContentPart ? part.text.trim() : part.text,
9485
+ cache_control: cacheControl
9486
+ });
9487
+ break;
9488
+ }
9489
+ case "reasoning": {
9490
+ if (sendReasoning) anthropicContent.push({
9491
+ type: "thinking",
9492
+ thinking: part.text,
9493
+ signature: part.signature,
9494
+ cache_control: cacheControl
9495
+ });
9496
+ else warnings.push({
9497
+ type: "other",
9498
+ message: "sending reasoning content is disabled for this model"
9499
+ });
9500
+ break;
9501
+ }
9502
+ case "redacted-reasoning": {
9503
+ anthropicContent.push({
9504
+ type: "redacted_thinking",
9505
+ data: part.data,
9506
+ cache_control: cacheControl
9507
+ });
9508
+ break;
9509
+ }
9510
+ case "tool-call": {
9511
+ anthropicContent.push({
9512
+ type: "tool_use",
9513
+ id: part.toolCallId,
9514
+ name: part.toolName,
9515
+ input: part.args,
9516
+ cache_control: cacheControl
9517
+ });
9518
+ break;
9519
+ }
9520
+ }
9521
+ }
9522
+ }
9523
+ messages.push({
9524
+ role: "assistant",
9525
+ content: anthropicContent
9526
+ });
9527
+ break;
9528
+ }
9529
+ default: {
9530
+ const _exhaustiveCheck = type;
9531
+ throw new Error(`Unsupported type: ${_exhaustiveCheck}`);
9532
+ }
9533
+ }
9534
+ }
9535
+ return {
9536
+ prompt: {
9537
+ system,
9538
+ messages
9539
+ },
9540
+ betas
9541
+ };
9542
+ }
9543
+ function groupIntoBlocks(prompt) {
9544
+ const blocks = [];
9545
+ let currentBlock = void 0;
9546
+ for (const message of prompt) {
9547
+ const { role } = message;
9548
+ switch (role) {
9549
+ case "system": {
9550
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "system") {
9551
+ currentBlock = {
9552
+ type: "system",
9553
+ messages: []
9554
+ };
9555
+ blocks.push(currentBlock);
9556
+ }
9557
+ currentBlock.messages.push(message);
9558
+ break;
9559
+ }
9560
+ case "assistant": {
9561
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "assistant") {
9562
+ currentBlock = {
9563
+ type: "assistant",
9564
+ messages: []
9565
+ };
9566
+ blocks.push(currentBlock);
9567
+ }
9568
+ currentBlock.messages.push(message);
9569
+ break;
9570
+ }
9571
+ case "user": {
9572
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "user") {
9573
+ currentBlock = {
9574
+ type: "user",
9575
+ messages: []
9576
+ };
9577
+ blocks.push(currentBlock);
9578
+ }
9579
+ currentBlock.messages.push(message);
9580
+ break;
9581
+ }
9582
+ case "tool": {
9583
+ if ((currentBlock == null ? void 0 : currentBlock.type) !== "user") {
9584
+ currentBlock = {
9585
+ type: "user",
9586
+ messages: []
9587
+ };
9588
+ blocks.push(currentBlock);
9589
+ }
9590
+ currentBlock.messages.push(message);
9591
+ break;
9592
+ }
9593
+ default: {
9594
+ const _exhaustiveCheck = role;
9595
+ throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
9596
+ }
9597
+ }
9598
+ }
9599
+ return blocks;
9600
+ }
9601
+ function mapAnthropicStopReason(finishReason) {
9602
+ switch (finishReason) {
9603
+ case "end_turn":
9604
+ case "stop_sequence": return "stop";
9605
+ case "tool_use": return "tool-calls";
9606
+ case "max_tokens": return "length";
9607
+ default: return "unknown";
9608
+ }
9609
+ }
9610
+ var AnthropicMessagesLanguageModel = class {
9611
+ constructor(modelId, settings, config) {
9612
+ this.specificationVersion = "v1";
9613
+ this.defaultObjectGenerationMode = "tool";
9614
+ this.modelId = modelId;
9615
+ this.settings = settings;
9616
+ this.config = config;
9617
+ }
9618
+ supportsUrl(url) {
9619
+ return url.protocol === "https:";
9620
+ }
9621
+ get provider() {
9622
+ return this.config.provider;
9623
+ }
9624
+ get supportsImageUrls() {
9625
+ return this.config.supportsImageUrls;
9626
+ }
9627
+ async getArgs({ mode, prompt, maxTokens = 4096, temperature, topP, topK, frequencyPenalty, presencePenalty, stopSequences, responseFormat, seed, providerMetadata: providerOptions }) {
9628
+ var _a$2, _b, _c;
9629
+ const type = mode.type;
9630
+ const warnings = [];
9631
+ if (frequencyPenalty != null) warnings.push({
9632
+ type: "unsupported-setting",
9633
+ setting: "frequencyPenalty"
9634
+ });
9635
+ if (presencePenalty != null) warnings.push({
9636
+ type: "unsupported-setting",
9637
+ setting: "presencePenalty"
9638
+ });
9639
+ if (seed != null) warnings.push({
9640
+ type: "unsupported-setting",
9641
+ setting: "seed"
9642
+ });
9643
+ if (responseFormat != null && responseFormat.type !== "text") warnings.push({
9644
+ type: "unsupported-setting",
9645
+ setting: "responseFormat",
9646
+ details: "JSON response format is not supported."
9647
+ });
9648
+ const { prompt: messagesPrompt, betas: messagesBetas } = convertToAnthropicMessagesPrompt({
9649
+ prompt,
9650
+ sendReasoning: (_a$2 = this.settings.sendReasoning) != null ? _a$2 : true,
9651
+ warnings
9652
+ });
9653
+ const anthropicOptions = parseProviderOptions({
9654
+ provider: "anthropic",
9655
+ providerOptions,
9656
+ schema: anthropicProviderOptionsSchema
9657
+ });
9658
+ const isThinking = ((_b = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _b.type) === "enabled";
9659
+ const thinkingBudget = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.budgetTokens;
9660
+ const baseArgs = {
9661
+ model: this.modelId,
9662
+ max_tokens: maxTokens,
9663
+ temperature,
9664
+ top_k: topK,
9665
+ top_p: topP,
9666
+ stop_sequences: stopSequences,
9667
+ ...isThinking && { thinking: {
9668
+ type: "enabled",
9669
+ budget_tokens: thinkingBudget
9670
+ } },
9671
+ system: messagesPrompt.system,
9672
+ messages: messagesPrompt.messages
9673
+ };
9674
+ if (isThinking) {
9675
+ if (thinkingBudget == null) throw new UnsupportedFunctionalityError({ functionality: "thinking requires a budget" });
9676
+ if (baseArgs.temperature != null) {
9677
+ baseArgs.temperature = void 0;
9678
+ warnings.push({
9679
+ type: "unsupported-setting",
9680
+ setting: "temperature",
9681
+ details: "temperature is not supported when thinking is enabled"
9682
+ });
9683
+ }
9684
+ if (topK != null) {
9685
+ baseArgs.top_k = void 0;
9686
+ warnings.push({
9687
+ type: "unsupported-setting",
9688
+ setting: "topK",
9689
+ details: "topK is not supported when thinking is enabled"
9690
+ });
9691
+ }
9692
+ if (topP != null) {
9693
+ baseArgs.top_p = void 0;
9694
+ warnings.push({
9695
+ type: "unsupported-setting",
9696
+ setting: "topP",
9697
+ details: "topP is not supported when thinking is enabled"
9698
+ });
9699
+ }
9700
+ baseArgs.max_tokens = maxTokens + thinkingBudget;
9701
+ }
9702
+ switch (type) {
9703
+ case "regular": {
9704
+ const { tools, tool_choice, toolWarnings, betas: toolsBetas } = prepareTools(mode);
9705
+ return {
9706
+ args: {
9707
+ ...baseArgs,
9708
+ tools,
9709
+ tool_choice
9710
+ },
9711
+ warnings: [...warnings, ...toolWarnings],
9712
+ betas: /* @__PURE__ */ new Set([...messagesBetas, ...toolsBetas])
9713
+ };
9714
+ }
9715
+ case "object-json": throw new UnsupportedFunctionalityError({ functionality: "json-mode object generation" });
9716
+ case "object-tool": {
9717
+ const { name: name$2, description: description$73, parameters } = mode.tool;
9718
+ return {
9719
+ args: {
9720
+ ...baseArgs,
9721
+ tools: [{
9722
+ name: name$2,
9723
+ description: description$73,
9724
+ input_schema: parameters
9725
+ }],
9726
+ tool_choice: {
9727
+ type: "tool",
9728
+ name: name$2
9729
+ }
9730
+ },
9731
+ warnings,
9732
+ betas: messagesBetas
9733
+ };
9734
+ }
9735
+ default: {
9736
+ const _exhaustiveCheck = type;
9737
+ throw new Error(`Unsupported type: ${_exhaustiveCheck}`);
9738
+ }
9739
+ }
9740
+ }
9741
+ async getHeaders({ betas, headers }) {
9742
+ return combineHeaders(await resolve(this.config.headers), betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}, headers);
9743
+ }
9744
+ buildRequestUrl(isStreaming) {
9745
+ var _a$2, _b, _c;
9746
+ return (_c = (_b = (_a$2 = this.config).buildRequestUrl) == null ? void 0 : _b.call(_a$2, this.config.baseURL, isStreaming)) != null ? _c : `${this.config.baseURL}/messages`;
9747
+ }
9748
+ transformRequestBody(args) {
9749
+ var _a$2, _b, _c;
9750
+ return (_c = (_b = (_a$2 = this.config).transformRequestBody) == null ? void 0 : _b.call(_a$2, args)) != null ? _c : args;
9751
+ }
9752
+ async doGenerate(options) {
9753
+ var _a$2, _b, _c, _d;
9754
+ const { args, warnings, betas } = await this.getArgs(options);
9755
+ const { responseHeaders, value: response, rawValue: rawResponse } = await postJsonToApi({
9756
+ url: this.buildRequestUrl(false),
9757
+ headers: await this.getHeaders({
9758
+ betas,
9759
+ headers: options.headers
9760
+ }),
9761
+ body: this.transformRequestBody(args),
9762
+ failedResponseHandler: anthropicFailedResponseHandler,
9763
+ successfulResponseHandler: createJsonResponseHandler(anthropicMessagesResponseSchema),
9764
+ abortSignal: options.abortSignal,
9765
+ fetch: this.config.fetch
9766
+ });
9767
+ const { messages: rawPrompt,...rawSettings } = args;
9768
+ let text$1 = "";
9769
+ for (const content of response.content) if (content.type === "text") text$1 += content.text;
9770
+ let toolCalls = void 0;
9771
+ if (response.content.some((content) => content.type === "tool_use")) {
9772
+ toolCalls = [];
9773
+ for (const content of response.content) if (content.type === "tool_use") toolCalls.push({
9774
+ toolCallType: "function",
9775
+ toolCallId: content.id,
9776
+ toolName: content.name,
9777
+ args: JSON.stringify(content.input)
9778
+ });
9779
+ }
9780
+ const reasoning = response.content.filter((content) => content.type === "redacted_thinking" || content.type === "thinking").map((content) => content.type === "thinking" ? {
9781
+ type: "text",
9782
+ text: content.thinking,
9783
+ signature: content.signature
9784
+ } : {
9785
+ type: "redacted",
9786
+ data: content.data
9787
+ });
9788
+ return {
9789
+ text: text$1,
9790
+ reasoning: reasoning.length > 0 ? reasoning : void 0,
9791
+ toolCalls,
9792
+ finishReason: mapAnthropicStopReason(response.stop_reason),
9793
+ usage: {
9794
+ promptTokens: response.usage.input_tokens,
9795
+ completionTokens: response.usage.output_tokens
9796
+ },
9797
+ rawCall: {
9798
+ rawPrompt,
9799
+ rawSettings
9800
+ },
9801
+ rawResponse: {
9802
+ headers: responseHeaders,
9803
+ body: rawResponse
9804
+ },
9805
+ response: {
9806
+ id: (_a$2 = response.id) != null ? _a$2 : void 0,
9807
+ modelId: (_b = response.model) != null ? _b : void 0
9808
+ },
9809
+ warnings,
9810
+ providerMetadata: { anthropic: {
9811
+ cacheCreationInputTokens: (_c = response.usage.cache_creation_input_tokens) != null ? _c : null,
9812
+ cacheReadInputTokens: (_d = response.usage.cache_read_input_tokens) != null ? _d : null
9813
+ } },
9814
+ request: { body: JSON.stringify(args) }
9815
+ };
9816
+ }
9817
+ async doStream(options) {
9818
+ const { args, warnings, betas } = await this.getArgs(options);
9819
+ const body = {
9820
+ ...args,
9821
+ stream: true
9822
+ };
9823
+ const { responseHeaders, value: response } = await postJsonToApi({
9824
+ url: this.buildRequestUrl(true),
9825
+ headers: await this.getHeaders({
9826
+ betas,
9827
+ headers: options.headers
9828
+ }),
9829
+ body: this.transformRequestBody(body),
9830
+ failedResponseHandler: anthropicFailedResponseHandler,
9831
+ successfulResponseHandler: createEventSourceResponseHandler(anthropicMessagesChunkSchema),
9832
+ abortSignal: options.abortSignal,
9833
+ fetch: this.config.fetch
9834
+ });
9835
+ const { messages: rawPrompt,...rawSettings } = args;
9836
+ let finishReason = "unknown";
9837
+ const usage = {
9838
+ promptTokens: NaN,
9839
+ completionTokens: NaN
9840
+ };
9841
+ const toolCallContentBlocks = {};
9842
+ let providerMetadata = void 0;
9843
+ let blockType = void 0;
9844
+ return {
9845
+ stream: response.pipeThrough(new TransformStream({ transform(chunk, controller) {
9846
+ var _a$2, _b, _c, _d;
9847
+ if (!chunk.success) {
9848
+ controller.enqueue({
9849
+ type: "error",
9850
+ error: chunk.error
9851
+ });
9852
+ return;
9853
+ }
9854
+ const value = chunk.value;
9855
+ switch (value.type) {
9856
+ case "ping": return;
9857
+ case "content_block_start": {
9858
+ const contentBlockType = value.content_block.type;
9859
+ blockType = contentBlockType;
9860
+ switch (contentBlockType) {
9861
+ case "text":
9862
+ case "thinking": return;
9863
+ case "redacted_thinking": {
9864
+ controller.enqueue({
9865
+ type: "redacted-reasoning",
9866
+ data: value.content_block.data
9867
+ });
9868
+ return;
9869
+ }
9870
+ case "tool_use": {
9871
+ toolCallContentBlocks[value.index] = {
9872
+ toolCallId: value.content_block.id,
9873
+ toolName: value.content_block.name,
9874
+ jsonText: ""
9875
+ };
9876
+ return;
9877
+ }
9878
+ default: {
9879
+ const _exhaustiveCheck = contentBlockType;
9880
+ throw new Error(`Unsupported content block type: ${_exhaustiveCheck}`);
9881
+ }
9882
+ }
9883
+ }
9884
+ case "content_block_stop": {
9885
+ if (toolCallContentBlocks[value.index] != null) {
9886
+ const contentBlock = toolCallContentBlocks[value.index];
9887
+ controller.enqueue({
9888
+ type: "tool-call",
9889
+ toolCallType: "function",
9890
+ toolCallId: contentBlock.toolCallId,
9891
+ toolName: contentBlock.toolName,
9892
+ args: contentBlock.jsonText
9893
+ });
9894
+ delete toolCallContentBlocks[value.index];
9895
+ }
9896
+ blockType = void 0;
9897
+ return;
9898
+ }
9899
+ case "content_block_delta": {
9900
+ const deltaType = value.delta.type;
9901
+ switch (deltaType) {
9902
+ case "text_delta": {
9903
+ controller.enqueue({
9904
+ type: "text-delta",
9905
+ textDelta: value.delta.text
9906
+ });
9907
+ return;
9908
+ }
9909
+ case "thinking_delta": {
9910
+ controller.enqueue({
9911
+ type: "reasoning",
9912
+ textDelta: value.delta.thinking
9913
+ });
9914
+ return;
9915
+ }
9916
+ case "signature_delta": {
9917
+ if (blockType === "thinking") controller.enqueue({
9918
+ type: "reasoning-signature",
9919
+ signature: value.delta.signature
9920
+ });
9921
+ return;
9922
+ }
9923
+ case "input_json_delta": {
9924
+ const contentBlock = toolCallContentBlocks[value.index];
9925
+ controller.enqueue({
9926
+ type: "tool-call-delta",
9927
+ toolCallType: "function",
9928
+ toolCallId: contentBlock.toolCallId,
9929
+ toolName: contentBlock.toolName,
9930
+ argsTextDelta: value.delta.partial_json
9931
+ });
9932
+ contentBlock.jsonText += value.delta.partial_json;
9933
+ return;
9934
+ }
9935
+ default: {
9936
+ const _exhaustiveCheck = deltaType;
9937
+ throw new Error(`Unsupported delta type: ${_exhaustiveCheck}`);
9938
+ }
9939
+ }
9940
+ }
9941
+ case "message_start": {
9942
+ usage.promptTokens = value.message.usage.input_tokens;
9943
+ usage.completionTokens = value.message.usage.output_tokens;
9944
+ providerMetadata = { anthropic: {
9945
+ cacheCreationInputTokens: (_a$2 = value.message.usage.cache_creation_input_tokens) != null ? _a$2 : null,
9946
+ cacheReadInputTokens: (_b = value.message.usage.cache_read_input_tokens) != null ? _b : null
9947
+ } };
9948
+ controller.enqueue({
9949
+ type: "response-metadata",
9950
+ id: (_c = value.message.id) != null ? _c : void 0,
9951
+ modelId: (_d = value.message.model) != null ? _d : void 0
9952
+ });
9953
+ return;
9954
+ }
9955
+ case "message_delta": {
9956
+ usage.completionTokens = value.usage.output_tokens;
9957
+ finishReason = mapAnthropicStopReason(value.delta.stop_reason);
9958
+ return;
9959
+ }
9960
+ case "message_stop": {
9961
+ controller.enqueue({
9962
+ type: "finish",
9963
+ finishReason,
9964
+ usage,
9965
+ providerMetadata
9966
+ });
9967
+ return;
9968
+ }
9969
+ case "error": {
9970
+ controller.enqueue({
9971
+ type: "error",
9972
+ error: value.error
9973
+ });
9974
+ return;
9975
+ }
9976
+ default: {
9977
+ const _exhaustiveCheck = value;
9978
+ throw new Error(`Unsupported chunk type: ${_exhaustiveCheck}`);
9979
+ }
9980
+ }
9981
+ } })),
9982
+ rawCall: {
9983
+ rawPrompt,
9984
+ rawSettings
9985
+ },
9986
+ rawResponse: { headers: responseHeaders },
9987
+ warnings,
9988
+ request: { body: JSON.stringify(body) }
9989
+ };
9990
+ }
9991
+ };
9992
+ var anthropicMessagesResponseSchema = z.object({
9993
+ type: z.literal("message"),
9994
+ id: z.string().nullish(),
9995
+ model: z.string().nullish(),
9996
+ content: z.array(z.discriminatedUnion("type", [
9997
+ z.object({
9998
+ type: z.literal("text"),
9999
+ text: z.string()
10000
+ }),
10001
+ z.object({
10002
+ type: z.literal("thinking"),
10003
+ thinking: z.string(),
10004
+ signature: z.string()
10005
+ }),
10006
+ z.object({
10007
+ type: z.literal("redacted_thinking"),
10008
+ data: z.string()
10009
+ }),
10010
+ z.object({
10011
+ type: z.literal("tool_use"),
10012
+ id: z.string(),
10013
+ name: z.string(),
10014
+ input: z.unknown()
10015
+ })
10016
+ ])),
10017
+ stop_reason: z.string().nullish(),
10018
+ usage: z.object({
10019
+ input_tokens: z.number(),
10020
+ output_tokens: z.number(),
10021
+ cache_creation_input_tokens: z.number().nullish(),
10022
+ cache_read_input_tokens: z.number().nullish()
10023
+ })
10024
+ });
10025
+ var anthropicMessagesChunkSchema = z.discriminatedUnion("type", [
10026
+ z.object({
10027
+ type: z.literal("message_start"),
10028
+ message: z.object({
10029
+ id: z.string().nullish(),
10030
+ model: z.string().nullish(),
10031
+ usage: z.object({
10032
+ input_tokens: z.number(),
10033
+ output_tokens: z.number(),
10034
+ cache_creation_input_tokens: z.number().nullish(),
10035
+ cache_read_input_tokens: z.number().nullish()
10036
+ })
10037
+ })
10038
+ }),
10039
+ z.object({
10040
+ type: z.literal("content_block_start"),
10041
+ index: z.number(),
10042
+ content_block: z.discriminatedUnion("type", [
10043
+ z.object({
10044
+ type: z.literal("text"),
10045
+ text: z.string()
10046
+ }),
10047
+ z.object({
10048
+ type: z.literal("thinking"),
10049
+ thinking: z.string()
10050
+ }),
10051
+ z.object({
10052
+ type: z.literal("tool_use"),
10053
+ id: z.string(),
10054
+ name: z.string()
10055
+ }),
10056
+ z.object({
10057
+ type: z.literal("redacted_thinking"),
10058
+ data: z.string()
10059
+ })
10060
+ ])
10061
+ }),
10062
+ z.object({
10063
+ type: z.literal("content_block_delta"),
10064
+ index: z.number(),
10065
+ delta: z.discriminatedUnion("type", [
10066
+ z.object({
10067
+ type: z.literal("input_json_delta"),
10068
+ partial_json: z.string()
10069
+ }),
10070
+ z.object({
10071
+ type: z.literal("text_delta"),
10072
+ text: z.string()
10073
+ }),
10074
+ z.object({
10075
+ type: z.literal("thinking_delta"),
10076
+ thinking: z.string()
10077
+ }),
10078
+ z.object({
10079
+ type: z.literal("signature_delta"),
10080
+ signature: z.string()
10081
+ })
10082
+ ])
10083
+ }),
10084
+ z.object({
10085
+ type: z.literal("content_block_stop"),
10086
+ index: z.number()
10087
+ }),
10088
+ z.object({
10089
+ type: z.literal("error"),
10090
+ error: z.object({
10091
+ type: z.string(),
10092
+ message: z.string()
10093
+ })
10094
+ }),
10095
+ z.object({
10096
+ type: z.literal("message_delta"),
10097
+ delta: z.object({ stop_reason: z.string().nullish() }),
10098
+ usage: z.object({ output_tokens: z.number() })
10099
+ }),
10100
+ z.object({ type: z.literal("message_stop") }),
10101
+ z.object({ type: z.literal("ping") })
10102
+ ]);
10103
+ var anthropicProviderOptionsSchema = z.object({ thinking: z.object({
10104
+ type: z.union([z.literal("enabled"), z.literal("disabled")]),
10105
+ budgetTokens: z.number().optional()
10106
+ }).optional() });
10107
+ var Bash20241022Parameters = z.object({
10108
+ command: z.string(),
10109
+ restart: z.boolean().optional()
10110
+ });
10111
+ function bashTool_20241022(options = {}) {
10112
+ return {
10113
+ type: "provider-defined",
10114
+ id: "anthropic.bash_20241022",
10115
+ args: {},
10116
+ parameters: Bash20241022Parameters,
10117
+ execute: options.execute,
10118
+ experimental_toToolResultContent: options.experimental_toToolResultContent
10119
+ };
10120
+ }
10121
+ var Bash20250124Parameters = z.object({
10122
+ command: z.string(),
10123
+ restart: z.boolean().optional()
10124
+ });
10125
+ function bashTool_20250124(options = {}) {
10126
+ return {
10127
+ type: "provider-defined",
10128
+ id: "anthropic.bash_20250124",
10129
+ args: {},
10130
+ parameters: Bash20250124Parameters,
10131
+ execute: options.execute,
10132
+ experimental_toToolResultContent: options.experimental_toToolResultContent
10133
+ };
10134
+ }
10135
+ var TextEditor20241022Parameters = z.object({
10136
+ command: z.enum([
10137
+ "view",
10138
+ "create",
10139
+ "str_replace",
10140
+ "insert",
10141
+ "undo_edit"
10142
+ ]),
10143
+ path: z.string(),
10144
+ file_text: z.string().optional(),
10145
+ insert_line: z.number().int().optional(),
10146
+ new_str: z.string().optional(),
10147
+ old_str: z.string().optional(),
10148
+ view_range: z.array(z.number().int()).optional()
10149
+ });
10150
+ function textEditorTool_20241022(options = {}) {
10151
+ return {
10152
+ type: "provider-defined",
10153
+ id: "anthropic.text_editor_20241022",
10154
+ args: {},
10155
+ parameters: TextEditor20241022Parameters,
10156
+ execute: options.execute,
10157
+ experimental_toToolResultContent: options.experimental_toToolResultContent
10158
+ };
10159
+ }
10160
+ var TextEditor20250124Parameters = z.object({
10161
+ command: z.enum([
10162
+ "view",
10163
+ "create",
10164
+ "str_replace",
10165
+ "insert",
10166
+ "undo_edit"
10167
+ ]),
10168
+ path: z.string(),
10169
+ file_text: z.string().optional(),
10170
+ insert_line: z.number().int().optional(),
10171
+ new_str: z.string().optional(),
10172
+ old_str: z.string().optional(),
10173
+ view_range: z.array(z.number().int()).optional()
10174
+ });
10175
+ function textEditorTool_20250124(options = {}) {
10176
+ return {
10177
+ type: "provider-defined",
10178
+ id: "anthropic.text_editor_20250124",
10179
+ args: {},
10180
+ parameters: TextEditor20250124Parameters,
10181
+ execute: options.execute,
10182
+ experimental_toToolResultContent: options.experimental_toToolResultContent
10183
+ };
10184
+ }
10185
+ var Computer20241022Parameters = z.object({
10186
+ action: z.enum([
10187
+ "key",
10188
+ "type",
10189
+ "mouse_move",
10190
+ "left_click",
10191
+ "left_click_drag",
10192
+ "right_click",
10193
+ "middle_click",
10194
+ "double_click",
10195
+ "screenshot",
10196
+ "cursor_position"
10197
+ ]),
10198
+ coordinate: z.array(z.number().int()).optional(),
10199
+ text: z.string().optional()
10200
+ });
10201
+ function computerTool_20241022(options) {
10202
+ return {
10203
+ type: "provider-defined",
10204
+ id: "anthropic.computer_20241022",
10205
+ args: {
10206
+ displayWidthPx: options.displayWidthPx,
10207
+ displayHeightPx: options.displayHeightPx,
10208
+ displayNumber: options.displayNumber
10209
+ },
10210
+ parameters: Computer20241022Parameters,
10211
+ execute: options.execute,
10212
+ experimental_toToolResultContent: options.experimental_toToolResultContent
10213
+ };
10214
+ }
10215
+ var Computer20250124Parameters = z.object({
10216
+ action: z.enum([
10217
+ "key",
10218
+ "hold_key",
10219
+ "type",
10220
+ "cursor_position",
10221
+ "mouse_move",
10222
+ "left_mouse_down",
10223
+ "left_mouse_up",
10224
+ "left_click",
10225
+ "left_click_drag",
10226
+ "right_click",
10227
+ "middle_click",
10228
+ "double_click",
10229
+ "triple_click",
10230
+ "scroll",
10231
+ "wait",
10232
+ "screenshot"
10233
+ ]),
10234
+ coordinate: z.tuple([z.number().int(), z.number().int()]).optional(),
10235
+ duration: z.number().optional(),
10236
+ scroll_amount: z.number().optional(),
10237
+ scroll_direction: z.enum([
10238
+ "up",
10239
+ "down",
10240
+ "left",
10241
+ "right"
10242
+ ]).optional(),
10243
+ start_coordinate: z.tuple([z.number().int(), z.number().int()]).optional(),
10244
+ text: z.string().optional()
10245
+ });
10246
+ function computerTool_20250124(options) {
10247
+ return {
10248
+ type: "provider-defined",
10249
+ id: "anthropic.computer_20250124",
10250
+ args: {
10251
+ displayWidthPx: options.displayWidthPx,
10252
+ displayHeightPx: options.displayHeightPx,
10253
+ displayNumber: options.displayNumber
10254
+ },
10255
+ parameters: Computer20250124Parameters,
10256
+ execute: options.execute,
10257
+ experimental_toToolResultContent: options.experimental_toToolResultContent
10258
+ };
10259
+ }
10260
+ var anthropicTools = {
10261
+ bash_20241022: bashTool_20241022,
10262
+ bash_20250124: bashTool_20250124,
10263
+ textEditor_20241022: textEditorTool_20241022,
10264
+ textEditor_20250124: textEditorTool_20250124,
10265
+ computer_20241022: computerTool_20241022,
10266
+ computer_20250124: computerTool_20250124
10267
+ };
10268
+ function createAnthropic(options = {}) {
10269
+ var _a$2;
10270
+ const baseURL = (_a$2 = withoutTrailingSlash(options.baseURL)) != null ? _a$2 : "https://api.anthropic.com/v1";
10271
+ const getHeaders = () => ({
10272
+ "anthropic-version": "2023-06-01",
10273
+ "x-api-key": loadApiKey({
10274
+ apiKey: options.apiKey,
10275
+ environmentVariableName: "ANTHROPIC_API_KEY",
10276
+ description: "Anthropic"
10277
+ }),
10278
+ ...options.headers
10279
+ });
10280
+ const createChatModel = (modelId, settings = {}) => new AnthropicMessagesLanguageModel(modelId, settings, {
10281
+ provider: "anthropic.messages",
10282
+ baseURL,
10283
+ headers: getHeaders,
10284
+ fetch: options.fetch,
10285
+ supportsImageUrls: true
10286
+ });
10287
+ const provider = function(modelId, settings) {
10288
+ if (new.target) throw new Error("The Anthropic model function cannot be called with the new keyword.");
10289
+ return createChatModel(modelId, settings);
10290
+ };
10291
+ provider.languageModel = createChatModel;
10292
+ provider.chat = createChatModel;
10293
+ provider.messages = createChatModel;
10294
+ provider.textEmbeddingModel = (modelId) => {
10295
+ throw new NoSuchModelError({
10296
+ modelId,
10297
+ modelType: "textEmbeddingModel"
10298
+ });
10299
+ };
10300
+ provider.tools = anthropicTools;
10301
+ return provider;
10302
+ }
10303
+ var anthropic = createAnthropic();
8981
10304
 
8982
10305
  //#endregion
8983
- //#region ../mcp-core/dist/openai-provider-BIuidJl6.js
8984
- const DEFAULT_OPENAI_MODEL = "gpt-5";
8985
- const VALID_REASONING_EFFORTS = [
8986
- "low",
8987
- "medium",
8988
- "high"
8989
- ];
8990
- const DEFAULT_REASONING_EFFORT = "low";
10306
+ //#region ../mcp-core/dist/anthropic-provider-DOE-j9k3.js
10307
+ const DEFAULT_ANTHROPIC_MODEL = "claude-sonnet-4-5";
8991
10308
  let configuredBaseUrl;
8992
10309
  /**
8993
- * Configure the OpenAI base URL (CLI flag only, not environment variable).
10310
+ * Configure the Anthropic base URL (CLI flag only, not environment variable).
8994
10311
  * This must be called explicitly - it cannot be set via environment variables for security.
8995
10312
  */
8996
- function setOpenAIBaseUrl(baseUrl) {
10313
+ function setAnthropicBaseUrl(baseUrl) {
8997
10314
  configuredBaseUrl = baseUrl;
8998
10315
  }
8999
10316
  /**
9000
- * Retrieve an OpenAI language model configured from environment variables and explicit config.
10317
+ * Retrieve an Anthropic language model configured from environment variables and explicit config.
9001
10318
  *
9002
10319
  * Configuration:
9003
- * - OPENAI_MODEL: Model to use (default: "gpt-5") - env var OK
9004
- * - OPENAI_REASONING_EFFORT: Reasoning effort for o1 models: "low", "medium", "high", or "" to disable (default: "low") - env var OK
9005
- * - Base URL: Must be set via setOpenAIBaseUrl() - NOT from env vars (security risk)
10320
+ * - ANTHROPIC_API_KEY: API key for authentication (required)
10321
+ * - ANTHROPIC_MODEL: Model to use (default: "claude-sonnet-4-5") - env var OK
10322
+ * - Base URL: Must be set via setAnthropicBaseUrl() - NOT from env vars (security risk)
9006
10323
  */
9007
- function getOpenAIModel(model) {
9008
- const defaultModel = process.env.OPENAI_MODEL || DEFAULT_OPENAI_MODEL;
9009
- const envReasoningEffort = process.env.OPENAI_REASONING_EFFORT;
9010
- let reasoningEffort;
9011
- if (envReasoningEffort === "") reasoningEffort = void 0;
9012
- else if (envReasoningEffort === void 0) reasoningEffort = DEFAULT_REASONING_EFFORT;
9013
- else if (VALID_REASONING_EFFORTS.includes(envReasoningEffort)) reasoningEffort = envReasoningEffort;
9014
- else {
9015
- const validValues = VALID_REASONING_EFFORTS.map((v) => `"${v}"`).join(", ");
9016
- throw new Error(`Invalid OPENAI_REASONING_EFFORT value: "${envReasoningEffort}". Must be one of: ${validValues}, or "" (empty string to disable). Default is "${DEFAULT_REASONING_EFFORT}".`);
9017
- }
9018
- const factory = createOpenAI({
10324
+ function getAnthropicModel(model) {
10325
+ const defaultModel = process.env.ANTHROPIC_MODEL || DEFAULT_ANTHROPIC_MODEL;
10326
+ const factory = createAnthropic({
9019
10327
  ...configuredBaseUrl && { baseURL: configuredBaseUrl },
9020
10328
  headers: { "User-Agent": USER_AGENT }
9021
10329
  });
9022
- return factory(model ?? defaultModel, { ...reasoningEffort && { reasoningEffort } });
10330
+ return factory(model ?? defaultModel);
10331
+ }
10332
+
10333
+ //#endregion
10334
+ //#region ../mcp-core/dist/provider-factory-BPN0JlR3.js
10335
+ let configuredProvider;
10336
+ /**
10337
+ * Configure the embedded agent provider explicitly.
10338
+ * Call this from CLI to override auto-detection.
10339
+ */
10340
+ function setAgentProvider(provider) {
10341
+ configuredProvider = provider;
10342
+ }
10343
+ /**
10344
+ * Configure base URLs for providers (called from CLI).
10345
+ */
10346
+ function setProviderBaseUrls(config) {
10347
+ if (config.openaiBaseUrl) setOpenAIBaseUrl(config.openaiBaseUrl);
10348
+ if (config.anthropicBaseUrl) setAnthropicBaseUrl(config.anthropicBaseUrl);
10349
+ }
10350
+ /**
10351
+ * Check if the API key exists for a given provider type.
10352
+ */
10353
+ function hasApiKeyForProvider(type) {
10354
+ switch (type) {
10355
+ case "anthropic": return Boolean(process.env.ANTHROPIC_API_KEY);
10356
+ case "openai": return Boolean(process.env.OPENAI_API_KEY);
10357
+ }
10358
+ }
10359
+ /**
10360
+ * Get the expected API key name for a provider type.
10361
+ */
10362
+ function getApiKeyName(type) {
10363
+ switch (type) {
10364
+ case "anthropic": return "ANTHROPIC_API_KEY";
10365
+ case "openai": return "OPENAI_API_KEY";
10366
+ }
10367
+ }
10368
+ /**
10369
+ * Build a provider instance for the given type.
10370
+ */
10371
+ function buildProvider(type) {
10372
+ switch (type) {
10373
+ case "anthropic": return {
10374
+ type: "anthropic",
10375
+ getModel: getAnthropicModel,
10376
+ getProviderOptions: () => ({}),
10377
+ getTemperature: () => void 0
10378
+ };
10379
+ case "openai": return {
10380
+ type: "openai",
10381
+ getModel: getOpenAIModel,
10382
+ getProviderOptions: () => ({ openai: {
10383
+ structuredOutputs: false,
10384
+ strictJsonSchema: false
10385
+ } }),
10386
+ getTemperature: () => 1
10387
+ };
10388
+ }
10389
+ }
10390
+ /**
10391
+ * Get the current agent provider based on configuration.
10392
+ *
10393
+ * Resolution order:
10394
+ * 1. Explicit configuration via setAgentProvider()
10395
+ * 2. EMBEDDED_AGENT_PROVIDER environment variable
10396
+ * 3. Auto-detect: check ANTHROPIC_API_KEY, then OPENAI_API_KEY
10397
+ * 4. Throw ConfigurationError if no provider available
10398
+ */
10399
+ function getAgentProvider() {
10400
+ let providerType = configuredProvider;
10401
+ if (!providerType) {
10402
+ const envProvider = process.env.EMBEDDED_AGENT_PROVIDER?.toLowerCase();
10403
+ if (envProvider === "openai" || envProvider === "anthropic") providerType = envProvider;
10404
+ }
10405
+ if (providerType && !hasApiKeyForProvider(providerType)) throw new ConfigurationError(`Provider "${providerType}" is configured but ${getApiKeyName(providerType)} is not set. Please set the API key environment variable.`);
10406
+ if (!providerType) {
10407
+ if (process.env.ANTHROPIC_API_KEY) providerType = "anthropic";
10408
+ else if (process.env.OPENAI_API_KEY) providerType = "openai";
10409
+ }
10410
+ if (!providerType) throw new ConfigurationError("No embedded agent provider configured. Set OPENAI_API_KEY or ANTHROPIC_API_KEY environment variable, or use --agent-provider flag to specify a provider.");
10411
+ return buildProvider(providerType);
10412
+ }
10413
+ /**
10414
+ * Check if an embedded agent provider is available.
10415
+ * Returns true if getAgentProvider() would succeed.
10416
+ */
10417
+ function hasAgentProvider() {
10418
+ try {
10419
+ getAgentProvider();
10420
+ return true;
10421
+ } catch {
10422
+ return false;
10423
+ }
10424
+ }
10425
+ /**
10426
+ * Get the resolved provider type without throwing.
10427
+ * Returns undefined if no provider is available or API key is missing.
10428
+ */
10429
+ function getResolvedProviderType() {
10430
+ if (configuredProvider) return hasApiKeyForProvider(configuredProvider) ? configuredProvider : void 0;
10431
+ const envProvider = process.env.EMBEDDED_AGENT_PROVIDER?.toLowerCase();
10432
+ if (envProvider === "openai" || envProvider === "anthropic") return hasApiKeyForProvider(envProvider) ? envProvider : void 0;
10433
+ if (process.env.ANTHROPIC_API_KEY) return "anthropic";
10434
+ if (process.env.OPENAI_API_KEY) return "openai";
10435
+ return void 0;
9023
10436
  }
9024
10437
 
9025
10438
  //#endregion
@@ -13874,8 +15287,8 @@ var SseMCPTransport = class {
13874
15287
  this.headers = headers;
13875
15288
  }
13876
15289
  async start() {
13877
- return new Promise((resolve, reject) => {
13878
- if (this.connected) return resolve();
15290
+ return new Promise((resolve$1, reject) => {
15291
+ if (this.connected) return resolve$1();
13879
15292
  this.abortController = new AbortController();
13880
15293
  const establishConnection = async () => {
13881
15294
  var _a17, _b, _c;
@@ -13910,7 +15323,7 @@ var SseMCPTransport = class {
13910
15323
  this.endpoint = new URL(data, this.url);
13911
15324
  if (this.endpoint.origin !== this.url.origin) throw new MCPClientError({ message: `MCP SSE Transport Error: Endpoint origin does not match connection origin: ${this.endpoint.origin}` });
13912
15325
  this.connected = true;
13913
- resolve();
15326
+ resolve$1();
13914
15327
  } else if (event === "message") try {
13915
15328
  const message = JSONRPCMessageSchema.parse(JSON.parse(data));
13916
15329
  (_a18 = this.onmessage) == null || _a18.call(this, message);
@@ -14049,7 +15462,7 @@ var MCPClient = class {
14049
15462
  }
14050
15463
  }
14051
15464
  async request({ request, resultSchema, options }) {
14052
- return new Promise((resolve, reject) => {
15465
+ return new Promise((resolve$1, reject) => {
14053
15466
  if (this.isClosed) return reject(new MCPClientError({ message: "Attempted to send a request from a closed client" }));
14054
15467
  this.assertCapability(request.method);
14055
15468
  const signal = options == null ? void 0 : options.signal;
@@ -14071,7 +15484,7 @@ var MCPClient = class {
14071
15484
  if (response instanceof Error) return reject(response);
14072
15485
  try {
14073
15486
  const result = resultSchema.parse(response.result);
14074
- resolve(result);
15487
+ resolve$1(result);
14075
15488
  } catch (error) {
14076
15489
  const parseError = new MCPClientError({
14077
15490
  message: "Failed to parse server response",
@@ -14298,7 +15711,7 @@ function trimStartOfStream() {
14298
15711
  var HANGING_STREAM_WARNING_TIME_MS = 15 * 1e3;
14299
15712
 
14300
15713
  //#endregion
14301
- //#region ../mcp-core/dist/callEmbeddedAgent-wn0PIM50.js
15714
+ //#region ../mcp-core/dist/callEmbeddedAgent-BoQGUoqc.js
14302
15715
  /**
14303
15716
  * Call an embedded agent with tool call capture
14304
15717
  * This is the standard way to call embedded AI agents within MCP tools
@@ -14309,22 +15722,20 @@ var HANGING_STREAM_WARNING_TIME_MS = 15 * 1e3;
14309
15722
  */
14310
15723
  async function callEmbeddedAgent({ system, prompt, tools, schema }) {
14311
15724
  const capturedToolCalls = [];
15725
+ const provider = getAgentProvider();
14312
15726
  const result = await generateText({
14313
- model: getOpenAIModel(),
15727
+ model: provider.getModel(),
14314
15728
  system,
14315
15729
  prompt,
14316
15730
  tools,
14317
15731
  maxSteps: 5,
14318
- temperature: 1,
15732
+ ...provider.getTemperature() !== void 0 && { temperature: provider.getTemperature() },
14319
15733
  experimental_output: output_exports.object({ schema }),
14320
15734
  experimental_telemetry: {
14321
15735
  isEnabled: true,
14322
15736
  functionId: "callEmbeddedAgent"
14323
15737
  },
14324
- providerOptions: { openai: {
14325
- structuredOutputs: false,
14326
- strictJsonSchema: false
14327
- } },
15738
+ providerOptions: provider.getProviderOptions(),
14328
15739
  onStepFinish: (event) => {
14329
15740
  if (event.toolCalls && event.toolCalls.length > 0) for (const toolCall of event.toolCalls) capturedToolCalls.push({
14330
15741
  toolName: toolCall.toolName,
@@ -14344,7 +15755,7 @@ async function callEmbeddedAgent({ system, prompt, tools, schema }) {
14344
15755
  }
14345
15756
 
14346
15757
  //#endregion
14347
- //#region ../mcp-core/dist/utils-wepw5Cmn.js
15758
+ //#region ../mcp-core/dist/utils-BhgZ4dUB.js
14348
15759
  /**
14349
15760
  * Standard response schema for all embedded agent tools.
14350
15761
  * Tools return either an error message or the result data, never both.
@@ -14426,7 +15837,7 @@ function agentTool(config) {
14426
15837
  }
14427
15838
 
14428
15839
  //#endregion
14429
- //#region ../mcp-core/dist/otel-semantics-ji8CZiqz.js
15840
+ //#region ../mcp-core/dist/otel-semantics-B5qAIqUa.js
14430
15841
  var namespace$72 = "android";
14431
15842
  var description$72 = "The Android platform on which the Android application is running.\n";
14432
15843
  var attributes$72 = {
@@ -19272,7 +20683,7 @@ function createOtelLookupTool(options) {
19272
20683
  }
19273
20684
 
19274
20685
  //#endregion
19275
- //#region ../mcp-core/dist/whoami-B-N3_K3B.js
20686
+ //#region ../mcp-core/dist/whoami-CnHpsyv0.js
19276
20687
  /**
19277
20688
  * Get the current authenticated user's information from Sentry API
19278
20689
  */
@@ -19301,7 +20712,7 @@ function createWhoamiTool(options) {
19301
20712
  }
19302
20713
 
19303
20714
  //#endregion
19304
- //#region ../mcp-core/dist/utils-Dehfm_qW.js
20715
+ //#region ../mcp-core/dist/utils-CRDu-UNV.js
19305
20716
  function getStringValue(event, key, defaultValue = "") {
19306
20717
  const value = event[key];
19307
20718
  return typeof value === "string" ? value : defaultValue;
@@ -19354,7 +20765,7 @@ function createDatasetAttributesTool(options) {
19354
20765
  "logs"
19355
20766
  ]).describe("The dataset to query attributes for") }),
19356
20767
  execute: async ({ dataset }) => {
19357
- const { BASE_COMMON_FIELDS, DATASET_FIELDS, RECOMMENDED_FIELDS: RECOMMENDED_FIELDS$2, NUMERIC_FIELDS, DATASET_EXAMPLES } = await import("./config-BEgU9ylR.js");
20768
+ const { BASE_COMMON_FIELDS, DATASET_FIELDS, RECOMMENDED_FIELDS: RECOMMENDED_FIELDS$2, NUMERIC_FIELDS, DATASET_EXAMPLES } = await import("./config-HqPAzoGg.js");
19358
20769
  const { attributes: customAttributes, fieldTypes } = await fetchCustomAttributes(apiService, organizationSlug, dataset, projectId);
19359
20770
  const allFields = {
19360
20771
  ...BASE_COMMON_FIELDS,
@@ -19389,7 +20800,7 @@ Use these examples as patterns for constructing your query.`;
19389
20800
  }
19390
20801
 
19391
20802
  //#endregion
19392
- //#region ../mcp-core/dist/agent-C_Z02GOk.js
20803
+ //#region ../mcp-core/dist/agent-ChQa0if8.js
19393
20804
  const searchEventsAgentOutputSchema = z.object({
19394
20805
  dataset: z.enum([
19395
20806
  "spans",
@@ -19418,7 +20829,6 @@ const searchEventsAgentOutputSchema = z.object({
19418
20829
  * This returns both the translated query result AND the tool calls made by the agent
19419
20830
  */
19420
20831
  async function searchEventsAgent(options) {
19421
- if (!process.env.OPENAI_API_KEY) throw new ConfigurationError("OPENAI_API_KEY environment variable is required for semantic search");
19422
20832
  const datasetAttributesTool = createDatasetAttributesTool({
19423
20833
  apiService: options.apiService,
19424
20834
  organizationSlug: options.organizationSlug,
@@ -19443,7 +20853,7 @@ async function searchEventsAgent(options) {
19443
20853
  }
19444
20854
 
19445
20855
  //#endregion
19446
- //#region ../mcp-core/dist/formatters-CBiThZnb.js
20856
+ //#region ../mcp-core/dist/formatters-CJK-ciCF.js
19447
20857
  /**
19448
20858
  * Format an explanation for how a natural language query was translated
19449
20859
  */
@@ -19661,7 +21071,7 @@ function formatSpanResults(params) {
19661
21071
  }
19662
21072
 
19663
21073
  //#endregion
19664
- //#region ../mcp-core/dist/handler-DFWcpIpC.js
21074
+ //#region ../mcp-core/dist/handler-DdfFan0E.js
19665
21075
  var handler_default = defineTool({
19666
21076
  name: "search_events",
19667
21077
  skills: [
@@ -19802,7 +21212,7 @@ var handler_default = defineTool({
19802
21212
  });
19803
21213
 
19804
21214
  //#endregion
19805
- //#region ../mcp-core/dist/create-team-JXD-4yd1.js
21215
+ //#region ../mcp-core/dist/create-team-ybunuUI_.js
19806
21216
  var create_team_default = defineTool({
19807
21217
  name: "create_team",
19808
21218
  skills: ["project-management"],
@@ -19857,7 +21267,7 @@ var create_team_default = defineTool({
19857
21267
  });
19858
21268
 
19859
21269
  //#endregion
19860
- //#region ../mcp-core/dist/create-project-B1g-3-yc.js
21270
+ //#region ../mcp-core/dist/create-project-BozSQ6GO.js
19861
21271
  var create_project_default = defineTool({
19862
21272
  name: "create_project",
19863
21273
  skills: ["project-management"],
@@ -19934,7 +21344,7 @@ var create_project_default = defineTool({
19934
21344
  });
19935
21345
 
19936
21346
  //#endregion
19937
- //#region ../mcp-core/dist/update-project-sPir9pn7.js
21347
+ //#region ../mcp-core/dist/update-project-CSbOMuOW.js
19938
21348
  var update_project_default = defineTool({
19939
21349
  name: "update_project",
19940
21350
  skills: ["project-management"],
@@ -20052,7 +21462,7 @@ var update_project_default = defineTool({
20052
21462
  });
20053
21463
 
20054
21464
  //#endregion
20055
- //#region ../mcp-core/dist/create-dsn-Co1eIXE3.js
21465
+ //#region ../mcp-core/dist/create-dsn-BymieFiV.js
20056
21466
  var create_dsn_default = defineTool({
20057
21467
  name: "create_dsn",
20058
21468
  skills: ["project-management"],
@@ -20112,7 +21522,7 @@ var create_dsn_default = defineTool({
20112
21522
  });
20113
21523
 
20114
21524
  //#endregion
20115
- //#region ../mcp-core/dist/find-dsns-o0QsNJv8.js
21525
+ //#region ../mcp-core/dist/find-dsns-_H3b8I5-.js
20116
21526
  var find_dsns_default = defineTool({
20117
21527
  name: "find_dsns",
20118
21528
  skills: ["project-management"],
@@ -20163,7 +21573,7 @@ var find_dsns_default = defineTool({
20163
21573
  });
20164
21574
 
20165
21575
  //#endregion
20166
- //#region ../mcp-core/dist/fetch-utils-C6qSgZai.js
21576
+ //#region ../mcp-core/dist/fetch-utils-LjUGSOvJ.js
20167
21577
  /**
20168
21578
  * Fetch with timeout using AbortController
20169
21579
  * @param url - The URL to fetch
@@ -20206,14 +21616,14 @@ async function retryWithBackoff(fn, { maxRetries = 3, initialDelay = 1e3, should
20206
21616
  } catch (error) {
20207
21617
  lastError = error;
20208
21618
  if (attempt === maxRetries || !shouldRetry(error)) throw error;
20209
- await new Promise((resolve) => setTimeout(resolve, delay$1));
21619
+ await new Promise((resolve$1) => setTimeout(resolve$1, delay$1));
20210
21620
  delay$1 = Math.min(delay$1 * 2, 3e4);
20211
21621
  }
20212
21622
  throw lastError;
20213
21623
  }
20214
21624
 
20215
21625
  //#endregion
20216
- //#region ../mcp-core/dist/analyze-issue-with-seer-DLMG61CB.js
21626
+ //#region ../mcp-core/dist/analyze-issue-with-seer-C6Ke4lsw.js
20217
21627
  var analyze_issue_with_seer_default = defineTool({
20218
21628
  name: "analyze_issue_with_seer",
20219
21629
  skills: ["seer"],
@@ -20298,7 +21708,7 @@ var analyze_issue_with_seer_default = defineTool({
20298
21708
  instruction: params.instruction
20299
21709
  });
20300
21710
  output += `Analysis started with Run ID: ${startResult.run_id}\n\n`;
20301
- await new Promise((resolve) => setTimeout(resolve, 1e3));
21711
+ await new Promise((resolve$1) => setTimeout(resolve$1, 1e3));
20302
21712
  autofixState = await retryWithBackoff(() => apiService.getAutofixState({
20303
21713
  organizationSlug: orgSlug,
20304
21714
  issueId: parsedIssueId
@@ -20355,7 +21765,7 @@ var analyze_issue_with_seer_default = defineTool({
20355
21765
  if (activeStep) output += `Processing: ${activeStep.title}...\n`;
20356
21766
  lastStatus = status;
20357
21767
  }
20358
- await new Promise((resolve) => setTimeout(resolve, SEER_POLLING_INTERVAL));
21768
+ await new Promise((resolve$1) => setTimeout(resolve$1, SEER_POLLING_INTERVAL));
20359
21769
  try {
20360
21770
  autofixState = await retryWithBackoff(() => apiService.getAutofixState({
20361
21771
  organizationSlug: orgSlug,
@@ -20401,7 +21811,7 @@ var analyze_issue_with_seer_default = defineTool({
20401
21811
  });
20402
21812
 
20403
21813
  //#endregion
20404
- //#region ../mcp-core/dist/search-docs-BzvTE9Na.js
21814
+ //#region ../mcp-core/dist/search-docs-yQc8o0ap.js
20405
21815
  var search_docs_default = defineTool({
20406
21816
  name: "search_docs",
20407
21817
  skills: ["docs"],
@@ -20484,7 +21894,7 @@ var search_docs_default = defineTool({
20484
21894
  });
20485
21895
 
20486
21896
  //#endregion
20487
- //#region ../mcp-core/dist/get-doc-B2M_KGrK.js
21897
+ //#region ../mcp-core/dist/get-doc-Ce6QYANY.js
20488
21898
  var get_doc_default = defineTool({
20489
21899
  name: "get_doc",
20490
21900
  skills: ["docs"],
@@ -20561,7 +21971,7 @@ var get_doc_default = defineTool({
20561
21971
  });
20562
21972
 
20563
21973
  //#endregion
20564
- //#region ../mcp-core/dist/dataset-fields-nvbboMpe.js
21974
+ //#region ../mcp-core/dist/dataset-fields-ClLuCTh4.js
20565
21975
  /**
20566
21976
  * Discover available fields for a dataset by querying Sentry's tags API
20567
21977
  */
@@ -20711,7 +22121,7 @@ function getCommonPatterns(dataset) {
20711
22121
  }
20712
22122
 
20713
22123
  //#endregion
20714
- //#region ../mcp-core/dist/config-BFaJp4hW.js
22124
+ //#region ../mcp-core/dist/config-C3fctASk.js
20715
22125
  /**
20716
22126
  * Configuration for the search-issues agent
20717
22127
  */
@@ -20729,13 +22139,16 @@ BUILT-IN FIELDS:
20729
22139
  - level: Severity level (error, warning, info, debug, fatal)
20730
22140
  IMPORTANT: Almost NEVER use this field. Terms like "critical", "important", "severe" refer to IMPACT not level.
20731
22141
  Only use if user explicitly says "error level", "warning level", etc.
22142
+ - issueCategory: Issue classification (error, performance, metric, feedback)
22143
+ IMPORTANT: User feedback from the User Feedback Widget is stored as issues with issueCategory:feedback
22144
+ Use this field when users ask about "user feedback", "feedback submissions", "user reports", etc.
20732
22145
  - environment: Deployment environment (production, staging, development)
20733
22146
  - release: Version/release identifier
20734
22147
  - firstSeen: When the issue was FIRST encountered (use for "new issues", "started", "began")
20735
22148
  WARNING: Excludes ongoing issues that started before the time window
20736
22149
  - lastSeen: When the issue was LAST encountered (use for "from the last", "recent", "active")
20737
22150
  This includes ALL issues seen during the time window, regardless of when they started
20738
- - assigned: Issues explicitly assigned to a user (email or "me")
22151
+ - assigned: Issues explicitly assigned to a user (email or "me")
20739
22152
  - assignedOrSuggested: Issues assigned to OR suggested for a user (broader match)
20740
22153
  - userCount: Number of unique users affected
20741
22154
  - eventCount: Total number of events
@@ -20747,6 +22160,9 @@ COMMON QUERY PATTERNS:
20747
22160
  - New issues: firstSeen:-7d
20748
22161
  - High impact: userCount:>100
20749
22162
  - My work: assignedOrSuggested:me
22163
+ - User feedback: issueCategory:feedback
22164
+ - Recent feedback: issueCategory:feedback lastSeen:-7d
22165
+ - Feedback from production: issueCategory:feedback environment:production
20750
22166
 
20751
22167
  SORTING RULES:
20752
22168
  1. CRITICAL: Sort MUST go in the separate "sort" field, NEVER in the "query" field
@@ -20770,6 +22186,8 @@ EXAMPLES:
20770
22186
  "critical bugs" → query: "level:error is:unresolved", sort: "date"
20771
22187
  "worst issues affecting the most users" → query: "is:unresolved", sort: "user"
20772
22188
  "assigned to john@example.com" → query: "assignedOrSuggested:john@example.com", sort: "date"
22189
+ "show me user feedback" → query: "issueCategory:feedback", sort: "date"
22190
+ "feedback from the last week" → query: "issueCategory:feedback lastSeen:-7d", sort: "date"
20773
22191
 
20774
22192
  NEVER: query: "is:unresolved sort:user" ← Sort goes in separate field!
20775
22193
 
@@ -20783,7 +22201,7 @@ Always use the issueFields tool to discover available fields when needed.
20783
22201
  Use the whoami tool when you need to resolve 'me' references.`;
20784
22202
 
20785
22203
  //#endregion
20786
- //#region ../mcp-core/dist/agent-Jg5_CT7U.js
22204
+ //#region ../mcp-core/dist/agent-qJanDgXA.js
20787
22205
  const searchIssuesAgentOutputSchema = z.object({
20788
22206
  query: z.string().describe("The Sentry issue search query"),
20789
22207
  sort: z.enum([
@@ -20799,7 +22217,6 @@ const searchIssuesAgentOutputSchema = z.object({
20799
22217
  * This returns both the translated query result AND the tool calls made by the agent
20800
22218
  */
20801
22219
  async function searchIssuesAgent(options) {
20802
- if (!process.env.OPENAI_API_KEY) throw new ConfigurationError("OPENAI_API_KEY environment variable is required for semantic search");
20803
22220
  return await callEmbeddedAgent({
20804
22221
  system: systemPrompt$3,
20805
22222
  prompt: options.query,
@@ -20817,7 +22234,7 @@ async function searchIssuesAgent(options) {
20817
22234
  }
20818
22235
 
20819
22236
  //#endregion
20820
- //#region ../mcp-core/dist/formatters-W4LF85x9.js
22237
+ //#region ../mcp-core/dist/formatters-BcLCXcro.js
20821
22238
  /**
20822
22239
  * Format an explanation for how a natural language query was translated
20823
22240
  */
@@ -20860,6 +22277,7 @@ function formatIssueResults(params) {
20860
22277
  output += `## ${index + 1}. [${issue.shortId}](${issueUrl})\n\n`;
20861
22278
  output += `**${issue.title}**\n\n`;
20862
22279
  output += `- **Status**: ${issue.status}\n`;
22280
+ if (issue.issueCategory && issue.issueCategory !== "error") output += `- **Category**: ${issue.issueCategory}\n`;
20863
22281
  output += `- **Users**: ${issue.userCount || 0}\n`;
20864
22282
  output += `- **Events**: ${issue.count || 0}\n`;
20865
22283
  if (issue.assignedTo) {
@@ -20876,6 +22294,8 @@ function formatIssueResults(params) {
20876
22294
  output += "- Get more details about a specific issue: Use the Issue ID with get_issue_details\n";
20877
22295
  output += "- Update issue status: Use update_issue to resolve or assign issues\n";
20878
22296
  output += "- View event counts: Use search_events for aggregated statistics\n";
22297
+ const hasFeedback = issues.some((i) => i.issueCategory === "feedback");
22298
+ if (hasFeedback) output += "- View feedback details: Use get_issue_details to see full feedback content and linked error events\n";
20879
22299
  return output;
20880
22300
  }
20881
22301
  /**
@@ -20894,11 +22314,11 @@ function formatDate(dateString) {
20894
22314
  if (diffHours < 24) return `${diffHours} hour${diffHours === 1 ? "" : "s"} ago`;
20895
22315
  const diffDays = Math.floor(diffHours / 24);
20896
22316
  if (diffDays < 30) return `${diffDays} day${diffDays === 1 ? "" : "s"} ago`;
20897
- return date.toLocaleDateString();
22317
+ return date.toISOString().split("T")[0];
20898
22318
  }
20899
22319
 
20900
22320
  //#endregion
20901
- //#region ../mcp-core/dist/handler-rR_VkT5b.js
22321
+ //#region ../mcp-core/dist/handler-DriMefmS.js
20902
22322
  var handler_default$1 = defineTool({
20903
22323
  name: "search_issues",
20904
22324
  skills: [
@@ -20918,6 +22338,7 @@ var handler_default$1 = defineTool({
20918
22338
  "- Filtered issue lists: 'unresolved issues', 'critical bugs'",
20919
22339
  "- Issues by impact: 'errors affecting more than 100 users'",
20920
22340
  "- Issues by assignment: 'issues assigned to me'",
22341
+ "- User feedback: 'show me user feedback', 'feedback from last week'",
20921
22342
  "",
20922
22343
  "DO NOT USE FOR COUNTS/AGGREGATIONS:",
20923
22344
  "- 'how many errors' → use search_events",
@@ -20935,6 +22356,7 @@ var handler_default$1 = defineTool({
20935
22356
  "search_issues(organizationSlug='my-org', naturalLanguageQuery='critical bugs from last week')",
20936
22357
  "search_issues(organizationSlug='my-org', naturalLanguageQuery='unhandled errors affecting 100+ users')",
20937
22358
  "search_issues(organizationSlug='my-org', naturalLanguageQuery='issues assigned to me')",
22359
+ "search_issues(organizationSlug='my-org', naturalLanguageQuery='user feedback from production')",
20938
22360
  "</examples>",
20939
22361
  "",
20940
22362
  "<hints>",
@@ -21019,7 +22441,7 @@ var handler_default$1 = defineTool({
21019
22441
  });
21020
22442
 
21021
22443
  //#endregion
21022
- //#region ../mcp-core/dist/config-DbfMHS7d.js
22444
+ //#region ../mcp-core/dist/config-mlP4H0sA.js
21023
22445
  const systemPrompt$2 = `You are a Sentry issue event filter translator. Your job is to:
21024
22446
  1. Translate natural language queries into Sentry tag filters for events within a SPECIFIC issue
21025
22447
  2. Select appropriate fields to return in the results
@@ -21354,7 +22776,7 @@ const EXAMPLE_QUERIES = [
21354
22776
  ];
21355
22777
 
21356
22778
  //#endregion
21357
- //#region ../mcp-core/dist/utils-jBgE1HtJ.js
22779
+ //#region ../mcp-core/dist/utils-D8xperPO.js
21358
22780
  /**
21359
22781
  * Create a tool for the agent to query available tags and fields for issue events
21360
22782
  * The tool is pre-bound with the API service and organization configured for the appropriate region
@@ -21431,7 +22853,7 @@ Received: ${params.issueUrl}`);
21431
22853
  }
21432
22854
 
21433
22855
  //#endregion
21434
- //#region ../mcp-core/dist/agent-CuQeP0Og.js
22856
+ //#region ../mcp-core/dist/agent-BGV8TUGG.js
21435
22857
  const searchIssueEventsAgentOutputSchema = z.object({
21436
22858
  query: z.string().describe("Sentry query filters for tags/fields (NOT including issue: prefix - handler adds that)"),
21437
22859
  fields: z.array(z.string()).describe("Array of field names to return in results"),
@@ -21455,7 +22877,6 @@ const searchIssueEventsAgentOutputSchema = z.object({
21455
22877
  * Returns both the translated query result AND the tool calls made by the agent
21456
22878
  */
21457
22879
  async function searchIssueEventsAgent(options) {
21458
- if (!process.env.OPENAI_API_KEY) throw new ConfigurationError("OPENAI_API_KEY environment variable is required for natural language query translation");
21459
22880
  const issueEventFieldsTool = createIssueEventFieldsTool({
21460
22881
  apiService: options.apiService,
21461
22882
  organizationSlug: options.organizationSlug,
@@ -21474,7 +22895,7 @@ async function searchIssueEventsAgent(options) {
21474
22895
  }
21475
22896
 
21476
22897
  //#endregion
21477
- //#region ../mcp-core/dist/handler-Ca256WDv.js
22898
+ //#region ../mcp-core/dist/handler-dNZGGGFd.js
21478
22899
  var handler_default$2 = defineTool({
21479
22900
  name: "search_issue_events",
21480
22901
  skills: ["inspect", "triage"],
@@ -21576,7 +22997,7 @@ var handler_default$2 = defineTool({
21576
22997
  });
21577
22998
 
21578
22999
  //#endregion
21579
- //#region ../mcp-core/dist/config-eV2du5VJ.js
23000
+ //#region ../mcp-core/dist/config-BJzhfINu.js
21580
23001
  /**
21581
23002
  * Configuration for the use_sentry embedded agent.
21582
23003
  *
@@ -21595,7 +23016,7 @@ The user may include various parameters to pass to those tools in their prompt.
21595
23016
  You MUST return tool results directly without interpreting them.`;
21596
23017
 
21597
23018
  //#endregion
21598
- //#region ../mcp-core/dist/agent-DfZ797Yi.js
23019
+ //#region ../mcp-core/dist/agent-2JRDh9Lm.js
21599
23020
  /**
21600
23021
  * Output schema for the embedded agent.
21601
23022
  * The agent returns the final result string directly from its tool calls.
@@ -21606,7 +23027,6 @@ const outputSchema = z.object({ result: z.string().describe("The final result fr
21606
23027
  * This returns the final result AND the tool calls made by the agent
21607
23028
  */
21608
23029
  async function useSentryAgent(options) {
21609
- if (!process.env.OPENAI_API_KEY) throw new ConfigurationError("OPENAI_API_KEY environment variable is required for use_sentry tool");
21610
23030
  const prompt = options.request;
21611
23031
  return await callEmbeddedAgent({
21612
23032
  system: systemPrompt$1,
@@ -21617,7 +23037,296 @@ async function useSentryAgent(options) {
21617
23037
  }
21618
23038
 
21619
23039
  //#endregion
21620
- //#region ../mcp-core/dist/error-handling-DrvyGci6.js
23040
+ //#region ../mcp-core/dist/list-issues-DpmIWiEG.js
23041
+ var list_issues_default = defineTool({
23042
+ name: "list_issues",
23043
+ skills: [
23044
+ "inspect",
23045
+ "triage",
23046
+ "seer"
23047
+ ],
23048
+ requiredScopes: ["event:read"],
23049
+ description: [
23050
+ "List issues using Sentry query syntax directly (no AI/LLM required).",
23051
+ "",
23052
+ "Use this tool when:",
23053
+ "- You know Sentry query syntax already",
23054
+ "- AI-powered search is unavailable (no OPENAI_API_KEY or ANTHROPIC_API_KEY)",
23055
+ "- You want precise control over the query",
23056
+ "",
23057
+ "For natural language queries, use search_issues instead.",
23058
+ "",
23059
+ "Common Query Syntax:",
23060
+ "- is:unresolved - Show unresolved issues only",
23061
+ "- is:unassigned - Show unassigned issues",
23062
+ "- level:error - Filter by error level",
23063
+ "- firstSeen:-24h - First seen in last 24 hours",
23064
+ "- lastSeen:-1h - Last seen in last hour",
23065
+ "- has:user - Issues with user context",
23066
+ "- user.email:user@example.com - Filter by user email",
23067
+ "- environment:production - Filter by environment",
23068
+ "- release:1.0.0 - Filter by release version",
23069
+ "",
23070
+ "Combine queries: is:unresolved is:unassigned level:error",
23071
+ "",
23072
+ "<examples>",
23073
+ "list_issues(organizationSlug='my-org', query='is:unresolved is:unassigned')",
23074
+ "list_issues(organizationSlug='my-org', query='level:error firstSeen:-24h', sort='freq')",
23075
+ "list_issues(organizationSlug='my-org', projectSlugOrId='my-project', query='is:unresolved')",
23076
+ "</examples>",
23077
+ "",
23078
+ "<hints>",
23079
+ "- If the user passes a parameter in the form of name/otherName, it's likely in the format of <organizationSlug>/<projectSlugOrId>.",
23080
+ "- The projectSlugOrId parameter accepts both project slugs (e.g., 'my-project') and numeric IDs (e.g., '123456').",
23081
+ "</hints>"
23082
+ ].join("\n"),
23083
+ inputSchema: {
23084
+ organizationSlug: ParamOrganizationSlug,
23085
+ query: z.string().trim().default("is:unresolved").describe("Sentry issue search query syntax"),
23086
+ projectSlugOrId: z.string().toLowerCase().trim().superRefine(validateSlugOrId).nullable().default(null).describe("Filter by project slug or numeric ID (optional)"),
23087
+ sort: z.enum([
23088
+ "date",
23089
+ "freq",
23090
+ "new",
23091
+ "user"
23092
+ ]).default("date").describe("Sort order: date (last seen), freq (frequency), new (first seen), user (user count)"),
23093
+ limit: z.number().min(1).max(100).default(10).describe("Maximum number of issues to return (1-100)"),
23094
+ regionUrl: ParamRegionUrl.nullable().default(null)
23095
+ },
23096
+ annotations: {
23097
+ readOnlyHint: true,
23098
+ openWorldHint: true
23099
+ },
23100
+ async handler(params, context$1) {
23101
+ const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
23102
+ setTag("organization.slug", params.organizationSlug);
23103
+ if (params.projectSlugOrId) if (isNumericId(params.projectSlugOrId)) setTag("project.id", params.projectSlugOrId);
23104
+ else setTag("project.slug", params.projectSlugOrId);
23105
+ const issues = await apiService.listIssues({
23106
+ organizationSlug: params.organizationSlug,
23107
+ projectSlug: params.projectSlugOrId ?? void 0,
23108
+ query: params.query,
23109
+ sortBy: params.sort,
23110
+ limit: params.limit
23111
+ });
23112
+ return formatIssueResults({
23113
+ issues,
23114
+ organizationSlug: params.organizationSlug,
23115
+ projectSlugOrId: params.projectSlugOrId ?? void 0,
23116
+ query: params.query,
23117
+ regionUrl: params.regionUrl ?? void 0
23118
+ });
23119
+ }
23120
+ });
23121
+
23122
+ //#endregion
23123
+ //#region ../mcp-core/dist/list-events-BCMaD3UM.js
23124
+ const DEFAULT_FIELDS = {
23125
+ errors: RECOMMENDED_FIELDS.errors.basic,
23126
+ logs: RECOMMENDED_FIELDS.logs.basic,
23127
+ spans: RECOMMENDED_FIELDS.spans.basic
23128
+ };
23129
+ var list_events_default = defineTool({
23130
+ name: "list_events",
23131
+ skills: [
23132
+ "inspect",
23133
+ "triage",
23134
+ "seer"
23135
+ ],
23136
+ requiredScopes: ["event:read"],
23137
+ description: [
23138
+ "Search events using Sentry query syntax directly (no AI/LLM required).",
23139
+ "",
23140
+ "Use this tool when:",
23141
+ "- You know Sentry query syntax already",
23142
+ "- AI-powered search is unavailable (no OPENAI_API_KEY or ANTHROPIC_API_KEY)",
23143
+ "- You want precise control over the query",
23144
+ "",
23145
+ "For natural language queries, use search_events instead.",
23146
+ "",
23147
+ "Datasets:",
23148
+ "- errors: Exception/crash events",
23149
+ "- logs: Log entries",
23150
+ "- spans: Performance data, traces, AI/LLM calls",
23151
+ "",
23152
+ "Query Syntax Examples:",
23153
+ "- message:\"connection timeout\"",
23154
+ "- level:error",
23155
+ "- span.op:http.client span.status_code:500",
23156
+ "- log.level:error",
23157
+ "- transaction:/api/users",
23158
+ "",
23159
+ "<examples>",
23160
+ "list_events(organizationSlug='my-org', dataset='errors', query='level:error')",
23161
+ "list_events(organizationSlug='my-org', dataset='spans', query='span.op:db')",
23162
+ "list_events(organizationSlug='my-org', dataset='logs', query='severity:error')",
23163
+ "list_events(organizationSlug='my-org', dataset='errors', fields=['issue', 'count()'], sort='-count()')",
23164
+ "</examples>",
23165
+ "",
23166
+ "<hints>",
23167
+ "- If the user passes a parameter in the form of name/otherName, it's likely in the format of <organizationSlug>/<projectSlug>.",
23168
+ "- Use fields with aggregate functions like count(), avg(), sum() for statistics",
23169
+ "- Sort by -count() for most common, -timestamp for newest",
23170
+ "</hints>"
23171
+ ].join("\n"),
23172
+ inputSchema: {
23173
+ organizationSlug: ParamOrganizationSlug,
23174
+ dataset: z.enum([
23175
+ "errors",
23176
+ "logs",
23177
+ "spans"
23178
+ ]).default("errors").describe("Dataset to query: errors (exceptions), logs, or spans (traces)"),
23179
+ query: z.string().trim().default("").describe("Sentry event search query syntax (empty for all events)"),
23180
+ fields: z.array(z.string()).nullable().default(null).describe("Fields to return. If not specified, uses sensible defaults. Include aggregate functions like count(), avg() for statistics."),
23181
+ sort: z.string().default("-timestamp").describe("Sort field (prefix with - for descending). Use -count() for aggregations."),
23182
+ projectSlug: ParamProjectSlug.nullable().default(null),
23183
+ statsPeriod: z.string().default("14d").describe("Time period: 1h, 24h, 7d, 14d, 30d, etc."),
23184
+ limit: z.number().min(1).max(100).default(10).describe("Maximum number of results to return (1-100)"),
23185
+ regionUrl: ParamRegionUrl.nullable().default(null)
23186
+ },
23187
+ annotations: {
23188
+ readOnlyHint: true,
23189
+ openWorldHint: true
23190
+ },
23191
+ async handler(params, context$1) {
23192
+ const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
23193
+ setTag("organization.slug", params.organizationSlug);
23194
+ if (params.projectSlug) setTag("project.slug", params.projectSlug);
23195
+ let projectId;
23196
+ if (params.projectSlug) {
23197
+ const project = await apiService.getProject({
23198
+ organizationSlug: params.organizationSlug,
23199
+ projectSlugOrId: params.projectSlug
23200
+ });
23201
+ projectId = String(project.id);
23202
+ }
23203
+ const fields = params.fields ?? DEFAULT_FIELDS[params.dataset];
23204
+ const eventsResponse = await apiService.searchEvents({
23205
+ organizationSlug: params.organizationSlug,
23206
+ query: params.query,
23207
+ fields,
23208
+ limit: params.limit,
23209
+ projectId,
23210
+ dataset: params.dataset,
23211
+ sort: params.sort,
23212
+ statsPeriod: params.statsPeriod
23213
+ });
23214
+ function isValidResponse(response) {
23215
+ return typeof response === "object" && response !== null;
23216
+ }
23217
+ function isValidEventArray(data) {
23218
+ return Array.isArray(data) && data.every((item) => typeof item === "object" && item !== null);
23219
+ }
23220
+ if (!isValidResponse(eventsResponse)) throw new Error("Invalid response format from Sentry API");
23221
+ const eventData = eventsResponse.data;
23222
+ if (!isValidEventArray(eventData)) throw new Error("Invalid event data format from Sentry API");
23223
+ const aggregateFunctions = fields.filter((field) => field.includes("(") && field.includes(")"));
23224
+ const groupByFields = fields.filter((field) => !field.includes("(") && !field.includes(")"));
23225
+ const explorerUrl = apiService.getEventsExplorerUrl(params.organizationSlug, params.query, projectId, params.dataset, fields, params.sort, aggregateFunctions, groupByFields, params.statsPeriod);
23226
+ const formatParams = {
23227
+ eventData,
23228
+ naturalLanguageQuery: params.query || `${params.dataset} events`,
23229
+ includeExplanation: false,
23230
+ apiService,
23231
+ organizationSlug: params.organizationSlug,
23232
+ explorerUrl,
23233
+ sentryQuery: params.query,
23234
+ fields
23235
+ };
23236
+ switch (params.dataset) {
23237
+ case "errors": return formatErrorResults(formatParams);
23238
+ case "logs": return formatLogResults(formatParams);
23239
+ case "spans": return formatSpanResults(formatParams);
23240
+ }
23241
+ }
23242
+ });
23243
+
23244
+ //#endregion
23245
+ //#region ../mcp-core/dist/list-issue-events-D2EcLe8P.js
23246
+ var list_issue_events_default = defineTool({
23247
+ name: "list_issue_events",
23248
+ skills: ["inspect", "triage"],
23249
+ requiredScopes: ["event:read"],
23250
+ description: [
23251
+ "List events within a specific issue using Sentry query syntax (no AI/LLM required).",
23252
+ "",
23253
+ "Use this tool when:",
23254
+ "- You know Sentry query syntax already",
23255
+ "- AI-powered search is unavailable (no OPENAI_API_KEY or ANTHROPIC_API_KEY)",
23256
+ "- You want precise control over the query",
23257
+ "",
23258
+ "For natural language queries, use search_issue_events instead.",
23259
+ "",
23260
+ "Common Query Filters:",
23261
+ "- environment:production - Filter by environment",
23262
+ "- release:1.0.0 - Filter by release version",
23263
+ "- user.email:alice@example.com - Filter by user email",
23264
+ "- timestamp:>2024-01-01 - Filter by timestamp",
23265
+ "",
23266
+ "<examples>",
23267
+ "list_issue_events(issueUrl='https://sentry.io/organizations/my-org/issues/123/', query='environment:production')",
23268
+ "list_issue_events(issueId='MCP-41', organizationSlug='my-org', query='release:v1.0.0')",
23269
+ "list_issue_events(issueId='PROJECT-123', organizationSlug='my-org', statsPeriod='1h')",
23270
+ "</examples>",
23271
+ "",
23272
+ "<hints>",
23273
+ "- Use issueUrl for convenience (includes org + issue ID)",
23274
+ "- Or provide both issueId and organizationSlug",
23275
+ "- The query filters events WITHIN the issue, no need for issue: prefix",
23276
+ "</hints>"
23277
+ ].join("\n"),
23278
+ inputSchema: {
23279
+ organizationSlug: ParamOrganizationSlug.nullable().default(null).describe("Organization slug. Required when using issueId. Not needed when using issueUrl."),
23280
+ issueId: z.string().optional().describe("Issue ID (e.g., 'MCP-41', 'PROJECT-123'). Requires organizationSlug."),
23281
+ issueUrl: z.string().url().optional().describe("Full Sentry issue URL. Includes both organization and issue ID."),
23282
+ query: z.string().trim().default("").describe("Sentry event search query syntax (empty for all events)"),
23283
+ sort: z.string().default("-timestamp").describe("Sort field (prefix with - for descending). Default: -timestamp"),
23284
+ statsPeriod: z.string().default("14d").describe("Time period: 1h, 24h, 7d, 14d, 30d, etc."),
23285
+ limit: z.number().min(1).max(100).default(50).describe("Maximum number of events to return (1-100)"),
23286
+ regionUrl: ParamRegionUrl.nullable().default(null)
23287
+ },
23288
+ annotations: {
23289
+ readOnlyHint: true,
23290
+ openWorldHint: true
23291
+ },
23292
+ async handler(params, context$1) {
23293
+ const { organizationSlug, issueId } = parseIssueParams({
23294
+ organizationSlug: params.organizationSlug,
23295
+ issueId: params.issueId,
23296
+ issueUrl: params.issueUrl
23297
+ });
23298
+ const apiService = apiServiceFromContext(context$1, { regionUrl: params.regionUrl ?? void 0 });
23299
+ setTag("organization.slug", organizationSlug);
23300
+ setTag("issue.id", issueId);
23301
+ const eventsResponse = await apiService.listEventsForIssue({
23302
+ organizationSlug,
23303
+ issueId,
23304
+ query: params.query,
23305
+ limit: params.limit,
23306
+ sort: params.sort,
23307
+ statsPeriod: params.statsPeriod
23308
+ });
23309
+ function isValidEventArray(data) {
23310
+ return Array.isArray(data) && data.every((item) => typeof item === "object" && item !== null);
23311
+ }
23312
+ if (!isValidEventArray(eventsResponse)) throw new Error("Invalid event data format from Sentry API: expected array of objects");
23313
+ const explorerQuery = params.query ? `issue:${issueId} ${params.query}` : `issue:${issueId}`;
23314
+ const explorerUrl = apiService.getEventsExplorerUrl(organizationSlug, explorerQuery, void 0, "errors", RECOMMENDED_FIELDS$1, params.sort, [], [], params.statsPeriod);
23315
+ return formatErrorResults({
23316
+ eventData: eventsResponse,
23317
+ naturalLanguageQuery: `Events in issue ${issueId}`,
23318
+ includeExplanation: false,
23319
+ apiService,
23320
+ organizationSlug,
23321
+ explorerUrl,
23322
+ sentryQuery: explorerQuery,
23323
+ fields: RECOMMENDED_FIELDS$1
23324
+ });
23325
+ }
23326
+ });
23327
+
23328
+ //#endregion
23329
+ //#region ../mcp-core/dist/error-handling-DFJ-iOAP.js
21621
23330
  /**
21622
23331
  * Type guard to identify user input validation errors.
21623
23332
  */
@@ -21708,7 +23417,7 @@ async function formatErrorForUser(error) {
21708
23417
  }
21709
23418
 
21710
23419
  //#endregion
21711
- //#region ../mcp-core/dist/constraint-helpers-CCO6wSRb.js
23420
+ //#region ../mcp-core/dist/constraint-helpers-D80X658i.js
21712
23421
  /**
21713
23422
  * Determines which tool parameter keys should be filtered out of the schema
21714
23423
  * because they will be injected from constraints.
@@ -21770,7 +23479,7 @@ function getConstraintParametersToInject(constraints, toolInputSchema) {
21770
23479
  }
21771
23480
 
21772
23481
  //#endregion
21773
- //#region ../mcp-core/dist/server-CAslpEs0.js
23482
+ //#region ../mcp-core/dist/server-CbkVklfg.js
21774
23483
  /**
21775
23484
  * Format tool calls into a readable trace
21776
23485
  */
@@ -21832,7 +23541,8 @@ var handler_default$3 = defineTool({
21832
23541
  },
21833
23542
  async handler(params, context$1) {
21834
23543
  const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
21835
- const { use_sentry,...toolsForAgent } = tools_default;
23544
+ const toolsToExclude = new Set(["use_sentry", ...SIMPLE_REPLACEMENT_TOOLS]);
23545
+ const toolsForAgent = Object.fromEntries(Object.entries(tools_default).filter(([key]) => !toolsToExclude.has(key)));
21836
23546
  const server$1 = buildServer({
21837
23547
  context: context$1,
21838
23548
  tools: toolsForAgent
@@ -21860,6 +23570,25 @@ var handler_default$3 = defineTool({
21860
23570
  }
21861
23571
  }
21862
23572
  });
23573
+ /**
23574
+ * Tools that require an embedded agent provider (LLM-powered).
23575
+ * These are excluded when no agent provider is configured.
23576
+ * Note: use_sentry is handled separately via agentMode.
23577
+ */
23578
+ const AGENT_DEPENDENT_TOOLS = [
23579
+ "search_events",
23580
+ "search_issues",
23581
+ "search_issue_events"
23582
+ ];
23583
+ /**
23584
+ * Simple tools that replace agent-dependent tools when no provider is available.
23585
+ * These are excluded when an agent provider IS configured.
23586
+ */
23587
+ const SIMPLE_REPLACEMENT_TOOLS = [
23588
+ "list_issues",
23589
+ "list_events",
23590
+ "list_issue_events"
23591
+ ];
21863
23592
  var tools_default = {
21864
23593
  whoami: whoami_default,
21865
23594
  find_organizations: find_organizations_default,
@@ -21867,6 +23596,7 @@ var tools_default = {
21867
23596
  find_projects: find_projects_default,
21868
23597
  find_releases: find_releases_default,
21869
23598
  get_issue_details: get_issue_details_default,
23599
+ get_issue_tag_values: get_issue_tag_values_default,
21870
23600
  get_trace_details: get_trace_details_default,
21871
23601
  get_event_attachment: get_event_attachment_default,
21872
23602
  update_issue: update_issue_default,
@@ -21881,7 +23611,10 @@ var tools_default = {
21881
23611
  get_doc: get_doc_default,
21882
23612
  search_issues: handler_default$1,
21883
23613
  search_issue_events: handler_default$2,
21884
- use_sentry: handler_default$3
23614
+ use_sentry: handler_default$3,
23615
+ list_issues: list_issues_default,
23616
+ list_events: list_events_default,
23617
+ list_issue_events: list_issue_events_default
21885
23618
  };
21886
23619
  /**
21887
23620
  * Creates and configures a complete MCP server with Sentry instrumentation.
@@ -21942,7 +23675,12 @@ function buildServer({ context: context$1, agentMode = false, tools: customTools
21942
23675
  * In agent mode, only the use_sentry tool is registered, bypassing authorization checks.
21943
23676
  */
21944
23677
  function configureServer({ server: server$1, context: context$1, agentMode = false, tools: customTools }) {
21945
- const toolsToRegister = agentMode ? { use_sentry: tools_default.use_sentry } : customTools ?? tools_default;
23678
+ let toolsToRegister = agentMode ? { use_sentry: tools_default.use_sentry } : customTools ?? tools_default;
23679
+ if (!agentMode && !customTools) {
23680
+ const hasAgent = hasAgentProvider();
23681
+ const toolsToExclude = new Set(hasAgent ? SIMPLE_REPLACEMENT_TOOLS : AGENT_DEPENDENT_TOOLS);
23682
+ toolsToRegister = Object.fromEntries(Object.entries(toolsToRegister).filter(([key]) => !toolsToExclude.has(key)));
23683
+ }
21946
23684
  const grantedSkills = context$1.grantedSkills ? new Set(context$1.grantedSkills) : void 0;
21947
23685
  server$1.server.onerror = (error) => {
21948
23686
  const transportLogOptions = {
@@ -22023,7 +23761,7 @@ function configureServer({ server: server$1, context: context$1, agentMode = fal
22023
23761
  }
22024
23762
 
22025
23763
  //#endregion
22026
- //#region ../mcp-core/dist/sentry-Cfj4OGMQ.js
23764
+ //#region ../mcp-core/dist/sentry-CTKJG5Bs.js
22027
23765
  const SCRUB_PATTERNS = [
22028
23766
  {
22029
23767
  pattern: /\bsk-[a-zA-Z0-9]{48}\b/g,
@@ -22114,8 +23852,11 @@ function scrubValue(value, depth = 0) {
22114
23852
  }
22115
23853
  /**
22116
23854
  * Sentry beforeSend hook that scrubs sensitive data from events
23855
+ * and applies custom fingerprinting for specific error types.
22117
23856
  */
22118
23857
  function sentryBeforeSend(event, hint) {
23858
+ const firstException = event?.exception?.values?.[0];
23859
+ if (firstException?.type === "AI_APICallError" && firstException.value) event.fingerprint = ["AI_APICallError", firstException.value];
22119
23860
  const [scrubbedEvent, didScrub, descriptions] = scrubValue(event);
22120
23861
  if (didScrub) {
22121
23862
  const uniqueDescriptions = [...new Set(descriptions)];
@@ -22156,16 +23897,21 @@ const cfg = (() => {
22156
23897
  die(err instanceof Error ? err.message : String(err));
22157
23898
  }
22158
23899
  })();
22159
- if (!process.env.OPENAI_API_KEY) {
22160
- console.warn("Warning: OPENAI_API_KEY environment variable is not set.");
23900
+ if (cfg.agentProvider) setAgentProvider(cfg.agentProvider);
23901
+ setProviderBaseUrls({
23902
+ openaiBaseUrl: cfg.openaiBaseUrl,
23903
+ anthropicBaseUrl: cfg.anthropicBaseUrl
23904
+ });
23905
+ if (cfg.openaiModel) process.env.OPENAI_MODEL = cfg.openaiModel;
23906
+ if (cfg.anthropicModel) process.env.ANTHROPIC_MODEL = cfg.anthropicModel;
23907
+ const resolvedProvider = getResolvedProviderType();
23908
+ if (!resolvedProvider) {
23909
+ console.warn("Warning: No LLM API key found (OPENAI_API_KEY or ANTHROPIC_API_KEY).");
22161
23910
  console.warn("The following AI-powered search tools will be unavailable:");
22162
- console.warn(" - search_events (natural language event search)");
22163
- console.warn(" - search_issues (natural language issue search)");
22164
- console.warn("All other tools will function normally. To enable AI-powered search, set OPENAI_API_KEY.");
23911
+ console.warn(" - search_events, search_issues, search_issue_events, use_sentry");
23912
+ console.warn("Use list_issues and list_events for direct Sentry query syntax instead.");
22165
23913
  console.warn("");
22166
- }
22167
- setOpenAIBaseUrl(cfg.openaiBaseUrl);
22168
- if (cfg.openaiModel) process.env.OPENAI_MODEL = cfg.openaiModel;
23914
+ } else console.warn(`Using ${resolvedProvider} for AI-powered search tools.`);
22169
23915
  Sentry.init({
22170
23916
  dsn: cfg.sentryDsn,
22171
23917
  sendDefaultPii: true,
@@ -22195,6 +23941,25 @@ if (cli.agent) {
22195
23941
  console.warn("");
22196
23942
  }
22197
23943
  const SENTRY_TIMEOUT = 5e3;
23944
+ async function shutdown(signal) {
23945
+ console.error(`${signal} received, shutting down...`);
23946
+ await Sentry.flush(SENTRY_TIMEOUT);
23947
+ process.exit(0);
23948
+ }
23949
+ process.on("SIGTERM", () => shutdown("SIGTERM"));
23950
+ process.on("SIGINT", () => shutdown("SIGINT"));
23951
+ process.on("uncaughtException", async (error) => {
23952
+ console.error("Uncaught exception:", error);
23953
+ Sentry.captureException(error);
23954
+ await Sentry.flush(SENTRY_TIMEOUT);
23955
+ process.exit(1);
23956
+ });
23957
+ process.on("unhandledRejection", async (reason) => {
23958
+ console.error("Unhandled rejection:", reason);
23959
+ Sentry.captureException(reason);
23960
+ await Sentry.flush(SENTRY_TIMEOUT);
23961
+ process.exit(1);
23962
+ });
22198
23963
  const context = {
22199
23964
  accessToken: cfg.accessToken,
22200
23965
  grantedSkills: cfg.finalSkills,
@@ -22210,12 +23975,12 @@ const server = buildServer({
22210
23975
  context,
22211
23976
  agentMode: cli.agent
22212
23977
  });
22213
- startStdio(server, context).catch((err) => {
23978
+ startStdio(server, context).catch(async (err) => {
22214
23979
  console.error("Server error:", err);
22215
- Sentry.flush(SENTRY_TIMEOUT);
23980
+ Sentry.captureException(err);
23981
+ await Sentry.flush(SENTRY_TIMEOUT);
22216
23982
  process.exit(1);
22217
23983
  });
22218
- Sentry.flush(SENTRY_TIMEOUT);
22219
23984
 
22220
23985
  //#endregion
22221
23986
  //# sourceMappingURL=index.js.map