@sentry/junior 0.116.1 → 0.117.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 (67) hide show
  1. package/dist/{agent-hooks-GUAAS3XH.js → agent-hooks-5IK4LPLP.js} +8 -8
  2. package/dist/api/conversations/detail.d.ts +7 -0
  3. package/dist/api/conversations/event-list.d.ts +7 -0
  4. package/dist/api/conversations/events.d.ts +1 -1
  5. package/dist/api/schema/conversation.d.ts +28 -0
  6. package/dist/api/schema.js +1 -1
  7. package/dist/api.js +25 -12
  8. package/dist/app.js +32 -30
  9. package/dist/{catalog-runtime-WMPC4J4U.js → catalog-runtime-MTUYW3AA.js} +5 -5
  10. package/dist/chat/agent/prompt.d.ts +2 -0
  11. package/dist/chat/agent/request.d.ts +2 -1
  12. package/dist/chat/agent/resume.d.ts +2 -0
  13. package/dist/chat/agent/tools.d.ts +1 -0
  14. package/dist/chat/conversations/history.d.ts +22 -1
  15. package/dist/chat/conversations/projection.d.ts +6 -0
  16. package/dist/chat/mcp/client.d.ts +4 -0
  17. package/dist/chat/mcp/errors.d.ts +22 -1
  18. package/dist/chat/oauth-response.d.ts +21 -0
  19. package/dist/chat/plugins/prompt.d.ts +9 -0
  20. package/dist/chat/plugins/types.d.ts +2 -21
  21. package/dist/chat/sandbox/snapshot/install.d.ts +6 -0
  22. package/dist/chat/sandbox/snapshot/profile.d.ts +14 -0
  23. package/dist/chat/sandbox/snapshot/resolve.d.ts +22 -0
  24. package/dist/chat/sandbox/snapshot/span.d.ts +2 -0
  25. package/dist/chat/services/context-compaction-marker.d.ts +1 -0
  26. package/dist/chat/services/turn-session-record.d.ts +2 -0
  27. package/dist/chat/state/turn-session.d.ts +2 -0
  28. package/dist/chat/tools/query-conversation-events.d.ts +1 -1
  29. package/dist/chat/tools/sandbox/view-image.d.ts +11 -0
  30. package/dist/chat/tools/types.d.ts +7 -0
  31. package/dist/{chunk-RYFAVWP3.js → chunk-27KWTFP6.js} +33 -12
  32. package/dist/{chunk-N3C4XCRE.js → chunk-3GE3F4LT.js} +1 -1
  33. package/dist/{chunk-XA3VLFPK.js → chunk-5O3JDQDG.js} +154 -20
  34. package/dist/{chunk-CGXLCMWI.js → chunk-6G45D3YG.js} +114 -10
  35. package/dist/{chunk-F3SWGSPG.js → chunk-72Z3HNTQ.js} +1 -1
  36. package/dist/{chunk-DLLW5ITL.js → chunk-AKG4TZNH.js} +2 -2
  37. package/dist/{chunk-TC4ZEM2D.js → chunk-BFIRIZPH.js} +9 -0
  38. package/dist/{chunk-OY2PQQ4P.js → chunk-CU7HTGNI.js} +1 -1
  39. package/dist/{chunk-CY7NXM32.js → chunk-DS27ZBSP.js} +4 -2
  40. package/dist/{chunk-VBMMMVVQ.js → chunk-FAWBONPC.js} +404 -443
  41. package/dist/{chunk-7CSVG54J.js → chunk-KU6ALEJC.js} +1 -1
  42. package/dist/{chunk-H35BDAUS.js → chunk-LN765Y4N.js} +6 -6
  43. package/dist/{chunk-KNCELO2M.js → chunk-LUMEBOWC.js} +1 -1
  44. package/dist/{chunk-GDAXWEIJ.js → chunk-NHZEUHKH.js} +514 -344
  45. package/dist/{chunk-ZYHLNTC2.js → chunk-STUI6NIL.js} +78 -16
  46. package/dist/{chunk-2YYPXQNQ.js → chunk-W5JEQQEA.js} +1 -1
  47. package/dist/{chunk-JPKGW6L6.js → chunk-WEK3V5RI.js} +73 -32
  48. package/dist/{chunk-WLT72MRP.js → chunk-WUNPRM76.js} +1 -1
  49. package/dist/{chunk-FAEALXEH.js → chunk-YRWJ3KEU.js} +2 -2
  50. package/dist/{chunk-BFYVIOTS.js → chunk-ZRQUQJUV.js} +12 -2
  51. package/dist/cli/chat.js +21 -21
  52. package/dist/cli/check.js +6 -6
  53. package/dist/cli/main.js +1 -1
  54. package/dist/cli/plugins.js +11 -11
  55. package/dist/cli/{snapshot-warmup.js → snapshot-create.js} +17 -19
  56. package/dist/cli/upgrade.js +5 -5
  57. package/dist/{db-FH4R5ZQ4.js → db-J2ITKS63.js} +5 -5
  58. package/dist/handlers/oauth-html.d.ts +4 -2
  59. package/dist/instrumentation.js +2 -2
  60. package/dist/nitro.js +2 -2
  61. package/dist/{oauth-callback-server-C2SSJ3FQ.js → oauth-callback-server-NQYKBT24.js} +15 -15
  62. package/dist/{runner-NAALFIXM.js → runner-53V5GIQM.js} +10 -10
  63. package/dist/{skills-UN2JXYYF.js → skills-BU3ZMLVB.js} +6 -6
  64. package/dist/{validation-EEF4ROHR.js → validation-74EIKKE6.js} +6 -6
  65. package/dist/version.js +1 -1
  66. package/package.json +5 -5
  67. package/dist/chat/sandbox/runtime-dependency-snapshots.d.ts +0 -20
@@ -1,38 +1,41 @@
1
1
  import {
2
2
  getInterruptionMarker
3
- } from "./chunk-RYFAVWP3.js";
3
+ } from "./chunk-27KWTFP6.js";
4
4
  import {
5
5
  createPluginLogger,
6
6
  getPlugins
7
- } from "./chunk-ZYHLNTC2.js";
7
+ } from "./chunk-STUI6NIL.js";
8
8
  import {
9
9
  acquireActiveLock,
10
10
  getStateAdapter
11
- } from "./chunk-7CSVG54J.js";
11
+ } from "./chunk-KU6ALEJC.js";
12
12
  import {
13
13
  SlackActionError,
14
14
  getSlackClient,
15
15
  isDmChannel,
16
16
  normalizeSlackConversationId,
17
17
  withSlackRetries
18
- } from "./chunk-FAEALXEH.js";
18
+ } from "./chunk-YRWJ3KEU.js";
19
19
  import {
20
20
  getDb,
21
21
  parseDestination
22
- } from "./chunk-BFYVIOTS.js";
22
+ } from "./chunk-ZRQUQJUV.js";
23
23
  import {
24
24
  sleep
25
25
  } from "./chunk-4ZNGQH7C.js";
26
26
  import {
27
27
  normalizeSlackEmojiName
28
- } from "./chunk-CY7NXM32.js";
28
+ } from "./chunk-DS27ZBSP.js";
29
29
  import {
30
30
  pluginCatalogRuntime
31
- } from "./chunk-OY2PQQ4P.js";
31
+ } from "./chunk-CU7HTGNI.js";
32
+ import {
33
+ fetchWithBoundedOAuthErrorBodies
34
+ } from "./chunk-5O3JDQDG.js";
32
35
  import {
33
36
  logInfo,
34
37
  logWarn
35
- } from "./chunk-F3SWGSPG.js";
38
+ } from "./chunk-72Z3HNTQ.js";
36
39
  import {
37
40
  isRecord
38
41
  } from "./chunk-OB42YVAE.js";
@@ -903,6 +906,79 @@ async function startOAuthFlow(provider, input) {
903
906
  };
904
907
  }
905
908
 
909
+ // src/chat/mcp/errors.ts
910
+ var McpProviderError = class extends Error {
911
+ phase;
912
+ provider;
913
+ missingSession;
914
+ resourceHost;
915
+ status;
916
+ constructor(details) {
917
+ super(`MCP provider ${details.phase.replace("_", " ")} failed`);
918
+ this.name = "McpProviderError";
919
+ this.phase = details.phase;
920
+ this.provider = details.provider;
921
+ this.missingSession = details.missingSession;
922
+ this.resourceHost = details.resourceHost;
923
+ this.status = details.status;
924
+ }
925
+ };
926
+ function providerStatus(error) {
927
+ if (!error || typeof error !== "object") {
928
+ return void 0;
929
+ }
930
+ const value = error;
931
+ const status = typeof value.status === "number" ? value.status : typeof value.code === "number" ? value.code : void 0;
932
+ return status !== void 0 && status >= 100 && status <= 599 ? status : void 0;
933
+ }
934
+ function toMcpProviderError(error, details) {
935
+ if (error instanceof McpProviderError) {
936
+ return error;
937
+ }
938
+ return new McpProviderError({
939
+ ...details,
940
+ status: details.status ?? providerStatus(error)
941
+ });
942
+ }
943
+ function getMcpProviderErrorAttributes(error) {
944
+ if (!(error instanceof McpProviderError)) {
945
+ return {};
946
+ }
947
+ return {
948
+ "app.credential.provider": error.provider,
949
+ "app.mcp.error.phase": error.phase,
950
+ ...error.status !== void 0 ? { "http.response.status_code": error.status } : {},
951
+ ...error.resourceHost ? { "server.address": error.resourceHost } : {}
952
+ };
953
+ }
954
+ var McpToolError = class extends Error {
955
+ constructor(message) {
956
+ super(message);
957
+ this.name = "McpToolError";
958
+ }
959
+ };
960
+ function getMcpAwareErrorType(error, fallback) {
961
+ if (error instanceof McpToolError) {
962
+ return "tool_error";
963
+ }
964
+ if (error instanceof McpProviderError) {
965
+ return "mcp_provider_error";
966
+ }
967
+ return error instanceof Error ? error.name : fallback;
968
+ }
969
+ function getMcpAwareErrorMessage(error) {
970
+ return error instanceof Error ? error.message : String(error);
971
+ }
972
+ function getMcpAwareTelemetryMessage(error, _privacy) {
973
+ if (error instanceof McpToolError) {
974
+ return "MCP tool call failed";
975
+ }
976
+ if (error instanceof McpProviderError) {
977
+ return error.message;
978
+ }
979
+ return getMcpAwareErrorMessage(error);
980
+ }
981
+
906
982
  // src/chat/mcp/auth-store.ts
907
983
  import {
908
984
  sourceSchema as sourceSchema2
@@ -1414,14 +1490,36 @@ async function finalizeMcpAuthorization(provider, authSessionId, authorizationCo
1414
1490
  if (mcp.headers && Object.keys(mcp.headers).length > 0) {
1415
1491
  requestInit.headers = new Headers(mcp.headers);
1416
1492
  }
1493
+ let providerStatus2;
1417
1494
  const transport = new StreamableHTTPClientTransport(new URL(mcp.url), {
1418
1495
  ...Object.keys(requestInit).length > 0 ? { requestInit } : {},
1419
- authProvider
1496
+ authProvider,
1497
+ fetch: fetchWithBoundedOAuthErrorBodies(void 0, (status) => {
1498
+ providerStatus2 = status;
1499
+ })
1420
1500
  });
1501
+ let failure;
1421
1502
  try {
1422
1503
  await transport.finishAuth(authorizationCode);
1423
- } finally {
1504
+ } catch (error) {
1505
+ failure = toMcpProviderError(error, {
1506
+ phase: "oauth_callback",
1507
+ provider,
1508
+ resourceHost: new URL(mcp.url).hostname,
1509
+ status: providerStatus2
1510
+ });
1511
+ }
1512
+ try {
1424
1513
  await transport.close();
1514
+ } catch (error) {
1515
+ failure ??= toMcpProviderError(error, {
1516
+ phase: "oauth_callback",
1517
+ provider,
1518
+ resourceHost: new URL(mcp.url).hostname
1519
+ });
1520
+ }
1521
+ if (failure) {
1522
+ throw failure;
1425
1523
  }
1426
1524
  const nextSession = await getMcpAuthSession(authSessionId);
1427
1525
  if (!nextSession) {
@@ -1853,6 +1951,12 @@ export {
1853
1951
  resolveBaseUrl,
1854
1952
  deliverOAuthAuthorization,
1855
1953
  startOAuthFlow,
1954
+ McpProviderError,
1955
+ toMcpProviderError,
1956
+ getMcpProviderErrorAttributes,
1957
+ McpToolError,
1958
+ getMcpAwareErrorType,
1959
+ getMcpAwareTelemetryMessage,
1856
1960
  getMcpAuthSession,
1857
1961
  patchMcpAuthSession,
1858
1962
  deleteMcpAuthSession,
@@ -13,7 +13,7 @@ import {
13
13
  } from "./chunk-6GWA276C.js";
14
14
  import {
15
15
  getDeploymentTelemetryAttributes
16
- } from "./chunk-WLT72MRP.js";
16
+ } from "./chunk-WUNPRM76.js";
17
17
 
18
18
  // src/chat/logging.ts
19
19
  import path from "path";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  pluginCatalogRuntime
3
- } from "./chunk-OY2PQQ4P.js";
3
+ } from "./chunk-CU7HTGNI.js";
4
4
  import {
5
5
  logWarn
6
- } from "./chunk-F3SWGSPG.js";
6
+ } from "./chunk-72Z3HNTQ.js";
7
7
  import {
8
8
  skillRoots
9
9
  } from "./chunk-3V7OFJZC.js";
@@ -155,6 +155,14 @@ var conversationReportTurnRoutedEventDataSchema = z2.object({
155
155
  confidence: z2.number().min(0).max(1).optional(),
156
156
  source: z2.enum(["configured", "inherited", "router"])
157
157
  }).strict();
158
+ var conversationReportTurnContextEventDataSchema = z2.object({
159
+ type: z2.literal("turn_context"),
160
+ turnId: z2.string().min(1),
161
+ pluginName: z2.string().min(1),
162
+ kind: z2.string().min(1),
163
+ version: z2.number().int().positive(),
164
+ content: z2.record(z2.string(), z2.unknown())
165
+ }).strict();
158
166
  var conversationReportCompactionEventDataSchema = z2.object({
159
167
  type: z2.literal("compaction"),
160
168
  modelProfile: z2.string().min(1).optional(),
@@ -193,6 +201,7 @@ var conversationReportEventDataSchema = z2.discriminatedUnion("type", [
193
201
  conversationReportMessageHandledEventDataSchema,
194
202
  conversationReportToolCallsEventDataSchema,
195
203
  conversationReportTurnLifecycleEventDataSchema,
204
+ conversationReportTurnContextEventDataSchema,
196
205
  conversationReportTurnRoutedEventDataSchema,
197
206
  conversationReportCompactionEventDataSchema,
198
207
  conversationReportHandoffEventDataSchema,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createPluginCatalogRuntime
3
- } from "./chunk-XA3VLFPK.js";
3
+ } from "./chunk-5O3JDQDG.js";
4
4
 
5
5
  // src/chat/plugins/catalog-runtime.ts
6
6
  var pluginCatalogRuntime = createPluginCatalogRuntime();
@@ -12,7 +12,7 @@ import {
12
12
  normalizeGenAiFinishReason,
13
13
  serializeGenAiAttribute,
14
14
  withSpan
15
- } from "./chunk-F3SWGSPG.js";
15
+ } from "./chunk-72Z3HNTQ.js";
16
16
 
17
17
  // src/chat/config.ts
18
18
  import { getModel as getModel2 } from "@earendil-works/pi-ai/compat";
@@ -272,10 +272,11 @@ function unwrapCurrentInstruction(text) {
272
272
 
273
273
  // src/chat/services/context-compaction-marker.ts
274
274
  var COMPACTION_SUMMARY_PREFIX = "Context compaction summary for future Junior turns:";
275
+ var ACTIVE_TURN_COMPACTION_SUMMARY_PREFIX = "Active-turn context checkpoint. If no newer user instruction follows this checkpoint, continue the same unfinished task now using the authoritative instructions above and this summary as internal continuation state. If a newer user instruction follows, treat this checkpoint as prior context and follow that newer instruction. Do not reply with a plan or summary solely because this checkpoint appeared:";
275
276
  var MODEL_HANDOFF_SUMMARY_PREFIX = "Model handoff checkpoint. Continue the outstanding request now using this summary as the complete prior context:";
276
277
  function isCompactionSummaryText(text) {
277
278
  const normalized = (unwrapCurrentInstruction(text) ?? text).trimStart();
278
- return normalized.startsWith(COMPACTION_SUMMARY_PREFIX) || normalized.startsWith(MODEL_HANDOFF_SUMMARY_PREFIX);
279
+ return normalized.startsWith(COMPACTION_SUMMARY_PREFIX) || normalized.startsWith(ACTIVE_TURN_COMPACTION_SUMMARY_PREFIX) || normalized.startsWith(MODEL_HANDOFF_SUMMARY_PREFIX);
279
280
  }
280
281
  function hasCompactedConversationContext(messages) {
281
282
  return messages.some((message) => {
@@ -934,6 +935,7 @@ export {
934
935
  renderCurrentInstruction,
935
936
  unwrapCurrentInstruction,
936
937
  COMPACTION_SUMMARY_PREFIX,
938
+ ACTIVE_TURN_COMPACTION_SUMMARY_PREFIX,
937
939
  MODEL_HANDOFF_SUMMARY_PREFIX,
938
940
  isCompactionSummaryText,
939
941
  hasCompactedConversationContext,