@sentry/junior 0.112.0 → 0.113.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 (49) hide show
  1. package/dist/{agent-hooks-6MVTPKP4.js → agent-hooks-BKEMWR3Z.js} +8 -8
  2. package/dist/api/conversations/cursor.d.ts +17 -0
  3. package/dist/api/conversations/detail.d.ts +16 -18
  4. package/dist/api/conversations/event-list.d.ts +91 -0
  5. package/dist/api/conversations/event-page.d.ts +18 -0
  6. package/dist/api/conversations/events.d.ts +5 -1
  7. package/dist/api/conversations/projection.d.ts +6 -1
  8. package/dist/api/schema/conversation.d.ts +132 -51
  9. package/dist/api/schema.d.ts +2 -2
  10. package/dist/api/schema.js +7 -1
  11. package/dist/api.js +444 -138
  12. package/dist/app.js +20 -20
  13. package/dist/{catalog-runtime-UEO25P2J.js → catalog-runtime-6XYOUVRZ.js} +5 -5
  14. package/dist/chat/pi/transcript.d.ts +2 -0
  15. package/dist/chat/services/provider-error.d.ts +39 -0
  16. package/dist/chat/services/provider-retry.d.ts +3 -6
  17. package/dist/chat/task-execution/state.d.ts +2 -2
  18. package/dist/chat/task-execution/store.d.ts +1 -1
  19. package/dist/{chunk-CSS7JHEM.js → chunk-36UJA3OD.js} +1 -1
  20. package/dist/{chunk-4EJO4HIC.js → chunk-3CTIAKSS.js} +1 -1
  21. package/dist/{chunk-66IP6WED.js → chunk-4VKFQPCW.js} +4 -4
  22. package/dist/{chunk-GJG67YFS.js → chunk-4WZ7YKDF.js} +2 -2
  23. package/dist/{chunk-SKEMI4IF.js → chunk-DXRPHBOU.js} +132 -23
  24. package/dist/{chunk-GR4IB6OQ.js → chunk-H5ON7XTE.js} +73 -28
  25. package/dist/{chunk-X3SP5RDW.js → chunk-HMRVILWZ.js} +1 -1
  26. package/dist/{chunk-2FJ6WEYV.js → chunk-K5BXPM74.js} +1 -1
  27. package/dist/{chunk-QIALGHRN.js → chunk-LLKDNPYV.js} +2 -2
  28. package/dist/{chunk-ZHP4KNF7.js → chunk-LR2SKL5Y.js} +1 -1
  29. package/dist/{chunk-AU2JVUDF.js → chunk-NP7TYFYR.js} +1 -1
  30. package/dist/{chunk-TZU3R5OC.js → chunk-OXE5ZUTS.js} +1 -1
  31. package/dist/{chunk-NDQL4ESR.js → chunk-QTS66GMR.js} +2 -2
  32. package/dist/{chunk-PK4ETCUQ.js → chunk-RCBUZGIT.js} +217 -199
  33. package/dist/{chunk-JE23YR3X.js → chunk-UKGNSJQQ.js} +50 -42
  34. package/dist/{chunk-AWNDKI5K.js → chunk-WBB22ANL.js} +20 -15
  35. package/dist/{chunk-VBSVNOLA.js → chunk-YJ44UT7D.js} +5 -5
  36. package/dist/{chunk-IV2O4HQJ.js → chunk-ZRSUCJGA.js} +1 -1
  37. package/dist/cli/chat.js +19 -19
  38. package/dist/cli/check.js +6 -6
  39. package/dist/cli/plugins.js +11 -11
  40. package/dist/cli/snapshot-warmup.js +8 -8
  41. package/dist/cli/upgrade.js +5 -5
  42. package/dist/{db-P5H5RVQV.js → db-2ASK6MV6.js} +5 -5
  43. package/dist/instrumentation.js +2 -2
  44. package/dist/nitro.js +2 -2
  45. package/dist/{runner-B4ZDUO3R.js → runner-L363K62Z.js} +12 -13
  46. package/dist/{skills-GWTOZ3XV.js → skills-VCPG3NOO.js} +6 -6
  47. package/dist/{validation-QFIC6XH6.js → validation-GY7AJBLC.js} +6 -6
  48. package/dist/version.js +1 -1
  49. package/package.json +6 -6
@@ -1,18 +1,28 @@
1
1
  import {
2
2
  CooperativeTurnYieldError,
3
3
  JUNIOR_THREAD_STATE_TTL_MS,
4
+ TURN_CONTEXT_TAG,
4
5
  TurnInputCommitLostError,
5
6
  TurnSliceLimitExceededError,
6
7
  abandonReplacedPendingAuth,
7
8
  canReusePendingAuthLink,
8
9
  estimateTextTokens,
10
+ extractAssistantText,
9
11
  getAgentContextCompactionTriggerTokens,
10
12
  getInterruptionMarker,
13
+ getPiMessageRole,
14
+ getTerminalAssistantMessages,
15
+ hasRuntimeTurnContext,
16
+ isAssistantMessage,
17
+ isContinuablePiBoundary,
18
+ isToolResultError,
19
+ isToolResultMessage,
11
20
  isTurnInputCommitLostError,
12
21
  loadConnectedMcpProviders,
13
22
  loadConversationProjection,
14
23
  loadTurnSessionRecord,
15
24
  mergeArtifactsState,
25
+ normalizeToolNameFromResult,
16
26
  openConversationProjection,
17
27
  persistAuthPauseSessionRecord,
18
28
  persistContinuationSessionRecord,
@@ -21,8 +31,11 @@ import {
21
31
  recordAuthorizationRequested,
22
32
  recordMcpProviderConnected,
23
33
  recordToolExecutionStarted,
34
+ retainRuntimeTurnContext,
35
+ stripRuntimeTurnContext,
36
+ trimTrailingAssistantMessages,
24
37
  updateConversationStats
25
- } from "./chunk-SKEMI4IF.js";
38
+ } from "./chunk-DXRPHBOU.js";
26
39
  import {
27
40
  buildNonInteractiveShellScript,
28
41
  createSandboxSession,
@@ -39,7 +52,7 @@ import {
39
52
  runNonInteractiveCommand,
40
53
  throwSandboxOperationError,
41
54
  wrapSandboxSetupError
42
- } from "./chunk-66IP6WED.js";
55
+ } from "./chunk-4VKFQPCW.js";
43
56
  import {
44
57
  addAgentTurnUsage,
45
58
  hasAgentTurnUsage
@@ -56,7 +69,7 @@ import {
56
69
  getPlugins,
57
70
  getSlackToolContext,
58
71
  resolveChannelCapabilities
59
- } from "./chunk-VBSVNOLA.js";
72
+ } from "./chunk-YJ44UT7D.js";
60
73
  import {
61
74
  SANDBOX_DATA_ROOT,
62
75
  SANDBOX_SKILLS_ROOT,
@@ -65,7 +78,7 @@ import {
65
78
  getStateAdapter,
66
79
  sandboxSkillDir,
67
80
  sandboxSkillFile
68
- } from "./chunk-X3SP5RDW.js";
81
+ } from "./chunk-HMRVILWZ.js";
69
82
  import {
70
83
  SlackActionError,
71
84
  downloadPrivateSlackFile,
@@ -75,7 +88,7 @@ import {
75
88
  isDmChannel,
76
89
  normalizeSlackConversationId,
77
90
  withSlackRetries
78
- } from "./chunk-NDQL4ESR.js";
91
+ } from "./chunk-QTS66GMR.js";
79
92
  import {
80
93
  contextProvenance,
81
94
  getConversationEventStore,
@@ -85,7 +98,7 @@ import {
85
98
  instructionActors,
86
99
  instructionProvenanceFor,
87
100
  parseDestination
88
- } from "./chunk-QIALGHRN.js";
101
+ } from "./chunk-LLKDNPYV.js";
89
102
  import {
90
103
  sleep
91
104
  } from "./chunk-4ZNGQH7C.js";
@@ -99,36 +112,25 @@ import {
99
112
  MODEL_HANDOFF_SUMMARY_PREFIX,
100
113
  ModelProfileNotConfiguredError,
101
114
  STANDARD_MODEL_PROFILE,
102
- TURN_CONTEXT_TAG,
103
115
  TURN_REASONING_LEVELS,
104
116
  botConfig,
105
117
  completeObject,
106
118
  completeText,
119
+ createProviderError,
107
120
  escapeXml,
108
- extractAssistantText,
109
121
  getGatewayApiKey,
110
122
  getPiGatewayApiKey,
111
- getTerminalAssistantMessages,
112
123
  hasCompactedConversationContext,
113
- hasRuntimeTurnContext,
114
- isAssistantMessage,
115
124
  isCompactionSummaryText,
116
125
  isProviderRetryError,
117
- isToolResultError,
118
- isToolResultMessage,
119
126
  modelIdForProfile,
120
127
  modelProfileSchema,
121
- nextProviderRetry,
122
128
  normalizeSlackEmojiName,
123
- normalizeToolNameFromResult,
124
129
  profileConfig,
125
130
  renderCurrentInstruction,
126
131
  resolveGatewayModel,
127
- retainRuntimeTurnContext,
128
- stripRuntimeTurnContext,
129
- trimTrailingAssistantMessages,
130
132
  unwrapCurrentInstruction
131
- } from "./chunk-PK4ETCUQ.js";
133
+ } from "./chunk-RCBUZGIT.js";
132
134
  import {
133
135
  parseSlackThreadId,
134
136
  resolveConversationPrivacy,
@@ -144,17 +146,17 @@ import {
144
146
  findSkillByName,
145
147
  loadSkillsByName,
146
148
  parseSkillInvocation
147
- } from "./chunk-GJG67YFS.js";
149
+ } from "./chunk-4WZ7YKDF.js";
148
150
  import {
149
151
  pluginCatalogRuntime
150
- } from "./chunk-ZHP4KNF7.js";
152
+ } from "./chunk-LR2SKL5Y.js";
151
153
  import {
152
154
  CredentialUnavailableError,
153
155
  credentialContextSchema,
154
156
  credentialUserSubjectId,
155
157
  resolveAuthTokenPlaceholder,
156
158
  resolvePluginCommandEnv
157
- } from "./chunk-TZU3R5OC.js";
159
+ } from "./chunk-OXE5ZUTS.js";
158
160
  import {
159
161
  isUserActor
160
162
  } from "./chunk-C4MZ3GP5.js";
@@ -175,7 +177,7 @@ import {
175
177
  summarizeMessageText,
176
178
  withLogContext,
177
179
  withSpan
178
- } from "./chunk-CSS7JHEM.js";
180
+ } from "./chunk-36UJA3OD.js";
179
181
  import {
180
182
  isRecord,
181
183
  parseSlackChannelId,
@@ -274,7 +276,6 @@ function shouldPropagateSandboxEgressTrace(host, config = {}) {
274
276
 
275
277
  // src/chat/agent/index.ts
276
278
  import { Agent } from "@earendil-works/pi-agent-core";
277
- import { isRetryableAssistantError } from "@earendil-works/pi-ai";
278
279
 
279
280
  // src/chat/sandbox/skill-sandbox.ts
280
281
  import fs from "fs/promises";
@@ -613,6 +614,9 @@ function shouldEmitDevAgentTrace() {
613
614
  return process.env.NODE_ENV === "development";
614
615
  }
615
616
 
617
+ // src/chat/services/turn-result.ts
618
+ import { isRetryableAssistantError } from "@earendil-works/pi-ai";
619
+
616
620
  // src/chat/no-reply.ts
617
621
  var NO_REPLY_MARKER = "[[NO_REPLY]]";
618
622
  function isNoReplyMarker(text) {
@@ -827,7 +831,10 @@ function buildTurnResult(input) {
827
831
  usage,
828
832
  stopReason,
829
833
  errorMessage,
830
- providerError: void 0
834
+ providerError: resolvedOutcome === "provider_error" && errorMessage ? createProviderError(errorMessage, {
835
+ modelId,
836
+ retryable: lastAssistant !== void 0 && isAssistantMessage(lastAssistant) && isRetryableAssistantError(lastAssistant)
837
+ }) : void 0
831
838
  };
832
839
  return {
833
840
  text: primaryText,
@@ -838,6 +845,40 @@ function buildTurnResult(input) {
838
845
  };
839
846
  }
840
847
 
848
+ // src/chat/services/provider-retry.ts
849
+ import {
850
+ isRetryableAssistantError as isRetryableAssistantError2
851
+ } from "@earendil-works/pi-ai";
852
+ var PROVIDER_RETRY_DELAYS_MS = [2e3, 4e3, 8e3];
853
+ var MAX_PROVIDER_RETRY_DELAY_MS = 6e4;
854
+ function nextProviderRetry(args) {
855
+ const backoffMs = PROVIDER_RETRY_DELAYS_MS[args.attempt];
856
+ const errorMessage = args.failure?.errorMessage;
857
+ if (backoffMs === void 0 || !args.failure || !errorMessage) {
858
+ return void 0;
859
+ }
860
+ const providerError = createProviderError(errorMessage, {
861
+ retryable: true
862
+ });
863
+ const hasRetrySignal = isRetryableAssistantError2(args.failure) || providerError.status === 408;
864
+ if (!hasRetrySignal || !providerError.retryable) {
865
+ return void 0;
866
+ }
867
+ const delayMs = Math.min(
868
+ MAX_PROVIDER_RETRY_DELAY_MS,
869
+ Math.max(backoffMs, providerError.retryAfterMs ?? 0)
870
+ );
871
+ const messages = trimTrailingAssistantMessages(args.messages);
872
+ if (messages.length === args.messages.length) {
873
+ return void 0;
874
+ }
875
+ const tailRole = getPiMessageRole(messages.at(-1));
876
+ if (tailRole !== "user" && tailRole !== "toolResult") {
877
+ return void 0;
878
+ }
879
+ return { delayMs, messages };
880
+ }
881
+
841
882
  // src/chat/tool-support/structured-result.ts
842
883
  import { z } from "zod";
843
884
  var juniorToolContinuationSchema = z.object({
@@ -14716,7 +14757,11 @@ function createResumeState(args) {
14716
14757
  if (!args.durability.shouldYield?.()) {
14717
14758
  return void 0;
14718
14759
  }
14719
- resumeMessages = this.getResumeSnapshot(currentMessages);
14760
+ const nextResumeMessages = this.getResumeSnapshot(currentMessages);
14761
+ if (!isContinuablePiBoundary(nextResumeMessages)) {
14762
+ return void 0;
14763
+ }
14764
+ resumeMessages = nextResumeMessages;
14720
14765
  return new CooperativeTurnYieldError(
14721
14766
  `Agent turn yielded at a safe boundary after ${currentDurationMs()}ms`
14722
14767
  );
@@ -15931,8 +15976,8 @@ async function executeAgentRunInPrivacyContext(request, conversationPrivacy, run
15931
15976
  }
15932
15977
  const providerRetry = nextProviderRetry({
15933
15978
  attempt,
15934
- messages: agent.state.messages,
15935
- retryableFailure: lastAssistant !== void 0 && isRetryableAssistantError(lastAssistant)
15979
+ failure: lastAssistant,
15980
+ messages: agent.state.messages
15936
15981
  });
15937
15982
  if (!providerRetry) {
15938
15983
  break;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getChatConfig
3
- } from "./chunk-PK4ETCUQ.js";
3
+ } from "./chunk-RCBUZGIT.js";
4
4
 
5
5
  // src/chat/state/adapter.ts
6
6
  import { createMemoryState } from "@chat-adapter/state-memory";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-2ZTTXTSZ.js";
4
4
  import {
5
5
  normalizeSlackConversationId
6
- } from "./chunk-NDQL4ESR.js";
6
+ } from "./chunk-QTS66GMR.js";
7
7
  import {
8
8
  parseSlackThreadId
9
9
  } from "./chunk-6Y5L4BOM.js";
@@ -8,13 +8,13 @@ import {
8
8
  import {
9
9
  getChatConfig,
10
10
  modelProfileSchema
11
- } from "./chunk-PK4ETCUQ.js";
11
+ } from "./chunk-RCBUZGIT.js";
12
12
  import {
13
13
  juniorDestinations
14
14
  } from "./chunk-VFUK3X5B.js";
15
15
  import {
16
16
  normalizeIdentityEmail
17
- } from "./chunk-CSS7JHEM.js";
17
+ } from "./chunk-36UJA3OD.js";
18
18
  import {
19
19
  parseSlackChannelReferenceId,
20
20
  parseSlackTeamId
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createPluginCatalogRuntime
3
- } from "./chunk-TZU3R5OC.js";
3
+ } from "./chunk-OXE5ZUTS.js";
4
4
 
5
5
  // src/chat/plugins/catalog-runtime.ts
6
6
  var pluginCatalogRuntime = createPluginCatalogRuntime();
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  JUNIOR_VERSION
3
- } from "./chunk-IV2O4HQJ.js";
3
+ } from "./chunk-ZRSUCJGA.js";
4
4
 
5
5
  // src/deployment.ts
6
6
  var JUNIOR_HEARTBEAT_ROUTE = "/api/internal/heartbeat";
@@ -5,7 +5,7 @@ import {
5
5
  logInfo,
6
6
  logWarn,
7
7
  setSpanAttributes
8
- } from "./chunk-CSS7JHEM.js";
8
+ } from "./chunk-36UJA3OD.js";
9
9
  import {
10
10
  discoverInstalledPluginPackageContent,
11
11
  normalizePluginPackageNames
@@ -3,13 +3,13 @@ import {
3
3
  } from "./chunk-4ZNGQH7C.js";
4
4
  import {
5
5
  getSlackBotToken
6
- } from "./chunk-PK4ETCUQ.js";
6
+ } from "./chunk-RCBUZGIT.js";
7
7
  import {
8
8
  logWarn,
9
9
  setSpanAttributes,
10
10
  setSpanStatus,
11
11
  withSpan
12
- } from "./chunk-CSS7JHEM.js";
12
+ } from "./chunk-36UJA3OD.js";
13
13
  import {
14
14
  parseSlackChannelReferenceId
15
15
  } from "./chunk-42WRQLJ6.js";