@sentry/junior 0.188.0 → 0.190.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 (115) hide show
  1. package/dist/{agent-hooks-5RQEVLQD.js → agent-hooks-3IG2FQW2.js} +11 -11
  2. package/dist/api/acp/conversations.d.ts +2 -2
  3. package/dist/api/conversations/list.d.ts +7 -0
  4. package/dist/api/people/shared.d.ts +54 -0
  5. package/dist/api.js +44 -55
  6. package/dist/app.d.ts +1 -1
  7. package/dist/app.js +1025 -349
  8. package/dist/{catalog-runtime-L4A6BJ3U.js → catalog-runtime-2OT7S3ZC.js} +4 -4
  9. package/dist/chat/actor.d.ts +7 -2
  10. package/dist/chat/agent/resume.d.ts +0 -2
  11. package/dist/chat/agent/types.d.ts +8 -9
  12. package/dist/chat/agent-dispatch/work.d.ts +1 -10
  13. package/dist/chat/agent-invocations/spawn.d.ts +1 -1
  14. package/dist/chat/agent-invocations/types.d.ts +44 -108
  15. package/dist/chat/app/conversation-work.d.ts +16 -8
  16. package/dist/chat/conversation-privacy.d.ts +7 -7
  17. package/dist/chat/conversations/destination.d.ts +12 -0
  18. package/dist/chat/conversations/projection.d.ts +2 -2
  19. package/dist/chat/conversations/sql/location.d.ts +13 -4
  20. package/dist/chat/{api-turns → conversations}/stop.d.ts +2 -2
  21. package/dist/chat/conversations/store.d.ts +4 -4
  22. package/dist/chat/conversations/structured-events.d.ts +1 -1
  23. package/dist/chat/{api-turns/authorization.d.ts → conversations/web-authorization.d.ts} +1 -0
  24. package/dist/chat/conversations/web-input.d.ts +98 -0
  25. package/dist/chat/conversations/web-mailbox.d.ts +12 -0
  26. package/dist/chat/event-tasks/tool-support.d.ts +1 -7
  27. package/dist/chat/providers/slack/runtime.d.ts +1 -0
  28. package/dist/chat/providers/slack/system-turn.d.ts +8 -0
  29. package/dist/chat/resource-events/actor.d.ts +13 -12
  30. package/dist/chat/resource-events/notification.d.ts +1 -1
  31. package/dist/chat/services/guardian-action-policy.d.ts +1 -1
  32. package/dist/chat/services/turn-session-routing.d.ts +2 -2
  33. package/dist/chat/source.d.ts +3 -3
  34. package/dist/chat/task-execution/assistant-message.d.ts +32 -0
  35. package/dist/chat/task-execution/conversation-turn.d.ts +8 -0
  36. package/dist/chat/{api-turns → task-execution}/mailbox-input.d.ts +1 -2
  37. package/dist/chat/task-execution/mailbox-turn.d.ts +52 -0
  38. package/dist/chat/task-execution/paused-turn.d.ts +1 -1
  39. package/dist/chat/task-execution/slack-work.d.ts +0 -2
  40. package/dist/chat/task-execution/state.d.ts +2 -2
  41. package/dist/chat/task-execution/store.d.ts +1 -1
  42. package/dist/chat/task-execution/turn-cursor.d.ts +10 -1
  43. package/dist/chat/tools/types.d.ts +9 -2
  44. package/dist/{chunk-XJIPMHKI.js → chunk-2MKHYSYL.js} +3 -3
  45. package/dist/{chunk-QCGNHSMA.js → chunk-2MRF22J4.js} +25 -10
  46. package/dist/{chunk-HCIVBCP5.js → chunk-3J3BCB4J.js} +1 -1
  47. package/dist/chunk-4BLFIYVK.js +703 -0
  48. package/dist/{chunk-NZLZ4KYZ.js → chunk-4PKEJK5B.js} +1 -1
  49. package/dist/{chunk-VFZAUQ5V.js → chunk-62DRKZQU.js} +5 -183
  50. package/dist/{chunk-QIOUTXTZ.js → chunk-663DQH5W.js} +1 -1
  51. package/dist/{chunk-Z5SKZE5B.js → chunk-67MMSYSE.js} +4 -12
  52. package/dist/{chunk-ZX7RSBQ6.js → chunk-6BXUSF7J.js} +1 -1
  53. package/dist/{chunk-W42ENMJW.js → chunk-6H7YU6XH.js} +1 -1
  54. package/dist/{chunk-WGZJ5SU4.js → chunk-7UJ6IJCK.js} +1 -1
  55. package/dist/{chunk-QDHJTKPE.js → chunk-7Y7XMI6P.js} +8 -6
  56. package/dist/{chunk-6YGFBU3A.js → chunk-BGOLRC36.js} +62 -336
  57. package/dist/{chunk-CVBDVIF4.js → chunk-BUJU6C2J.js} +1 -1
  58. package/dist/{chunk-XI4PVY2T.js → chunk-CZXZKTAI.js} +5 -5
  59. package/dist/chunk-DA2KGZZI.js +13 -0
  60. package/dist/{chunk-RMB7CERI.js → chunk-DJZGQ7OL.js} +311 -137
  61. package/dist/{chunk-FIUCHYT6.js → chunk-DVX6U6GI.js} +1 -1
  62. package/dist/{chunk-AW77HH54.js → chunk-ECOR3OXY.js} +19 -299
  63. package/dist/{chunk-WW2Y7JIA.js → chunk-F3K2267N.js} +51 -50
  64. package/dist/{chunk-W2DDJCPS.js → chunk-FVFJ57RK.js} +8 -8
  65. package/dist/{chunk-UVUXFRYN.js → chunk-GWCFXTB6.js} +211 -7
  66. package/dist/{chunk-X55FOVZO.js → chunk-HI5KXE3C.js} +3 -3
  67. package/dist/{chunk-ERZMACYA.js → chunk-IRQ3RSX3.js} +3 -3
  68. package/dist/{chunk-32XSSFZV.js → chunk-JV7U4665.js} +1 -1
  69. package/dist/chunk-MNHJ4WLE.js +285 -0
  70. package/dist/{chunk-SC67CH3C.js → chunk-OJFX2FP7.js} +14 -17
  71. package/dist/{chunk-IUUQWIG2.js → chunk-OKAHLUSU.js} +70 -19
  72. package/dist/{chunk-PSHMPRIU.js → chunk-OON4IQHH.js} +2 -2
  73. package/dist/{chunk-6JZGXLL2.js → chunk-OYCOLHCR.js} +5 -7
  74. package/dist/{chunk-3HEZWDS5.js → chunk-REVH4BZU.js} +2 -2
  75. package/dist/{chunk-CDSLOYOR.js → chunk-RLYJYEIY.js} +6 -6
  76. package/dist/{chunk-CZRWU4ZM.js → chunk-T66GV7A3.js} +2 -5
  77. package/dist/{chunk-Q7O74WOO.js → chunk-VWNIDTFR.js} +2 -2
  78. package/dist/{chunk-CIG6WI7Q.js → chunk-W2C4TPLB.js} +5 -5
  79. package/dist/{chunk-QIMN3FXL.js → chunk-Y4WL4OYD.js} +1 -1
  80. package/dist/{chunk-MQDIIFZM.js → chunk-YFU4DGZY.js} +12 -5
  81. package/dist/chunk-YKIAUKYH.js +311 -0
  82. package/dist/{chunk-QVH6FW3T.js → chunk-ZFCO2TMB.js} +7 -3
  83. package/dist/cli/chat.js +34 -33
  84. package/dist/cli/check.js +5 -5
  85. package/dist/cli/plugins.js +12 -12
  86. package/dist/cli/snapshot-create.js +9 -9
  87. package/dist/cli/upgrade.js +6 -6
  88. package/dist/db/schema/agent-invocations.d.ts +18 -42
  89. package/dist/db/schema/conversations.d.ts +62 -0
  90. package/dist/db/schema.d.ts +49 -42
  91. package/dist/{db-YPRZAA2T.js → db-2IFDMDDY.js} +6 -6
  92. package/dist/instrumentation.js +3 -3
  93. package/dist/nitro.js +6 -6
  94. package/dist/{oauth-callback-server-DBBIR3XG.js → oauth-callback-server-SZSS2KH6.js} +30 -28
  95. package/dist/{runner-FKVFFPLO.js → runner-2N4QU77X.js} +25 -21
  96. package/dist/{skills-4RBAZEMV.js → skills-VU2LZAKX.js} +5 -5
  97. package/dist/spawn-3K7RV4T5.js +42 -0
  98. package/dist/task-runner-52DYFHW3.js +36 -0
  99. package/dist/{validation-E6Z5LHZM.js → validation-IJGHK7NI.js} +5 -5
  100. package/dist/version.js +1 -1
  101. package/dist/{work-OFTXWOK4.js → work-DI45MLRL.js} +22 -21
  102. package/dist/{worker-OMWNOKTJ.js → worker-FY7KWG2M.js} +10 -10
  103. package/migrations/0037_conversation_location.sql +23 -0
  104. package/migrations/meta/0037_snapshot.json +3192 -0
  105. package/migrations/meta/_journal.json +7 -0
  106. package/package.json +4 -4
  107. package/dist/chat/api-turns/assistant-message.d.ts +0 -12
  108. package/dist/chat/api-turns/cancellation.d.ts +0 -24
  109. package/dist/chat/api-turns/routing.d.ts +0 -51
  110. package/dist/chat/api-turns/work.d.ts +0 -99
  111. package/dist/chat/task-execution/slack-resource-event.d.ts +0 -55
  112. package/dist/chunk-6FGN7ZEG.js +0 -221
  113. package/dist/chunk-LODJKINF.js +0 -1502
  114. package/dist/spawn-CO7QFCNJ.js +0 -41
  115. package/dist/task-runner-DUGZGI7V.js +0 -34
@@ -1,14 +1,10 @@
1
1
  import {
2
2
  relayLocalOAuthCallback
3
3
  } from "./chunk-FA6POGLH.js";
4
- import {
5
- buildSentryConversationUrl,
6
- deleteWebAuthorization
7
- } from "./chunk-PSHMPRIU.js";
8
4
  import {
9
5
  AgentRunError,
10
6
  executeTurn
11
- } from "./chunk-ERZMACYA.js";
7
+ } from "./chunk-IRQ3RSX3.js";
12
8
  import {
13
9
  buildDeliveredTurnStatePatch,
14
10
  finalizeFailedTurnReplyWithEvent,
@@ -19,14 +15,14 @@ import {
19
15
  getTurnUserSlackMessageTs,
20
16
  persistAuthPauseTurnState,
21
17
  requireTurnFailureEventId
22
- } from "./chunk-QDHJTKPE.js";
18
+ } from "./chunk-7Y7XMI6P.js";
23
19
  import {
24
20
  resolveTurnSessionRouting,
25
21
  scheduleSessionCompletedPluginTasks
26
- } from "./chunk-AW77HH54.js";
22
+ } from "./chunk-ECOR3OXY.js";
27
23
  import {
28
24
  getTurnLifecycle
29
- } from "./chunk-W42ENMJW.js";
25
+ } from "./chunk-6H7YU6XH.js";
30
26
  import {
31
27
  coerceThreadConversationState,
32
28
  configValueSchema,
@@ -34,7 +30,11 @@ import {
34
30
  getPersistedSandboxState,
35
31
  getPersistedThreadState,
36
32
  persistThreadStateById
37
- } from "./chunk-CIG6WI7Q.js";
33
+ } from "./chunk-W2C4TPLB.js";
34
+ import {
35
+ buildSentryConversationUrl,
36
+ deleteWebAuthorization
37
+ } from "./chunk-OON4IQHH.js";
38
38
  import {
39
39
  createUserTokenStore,
40
40
  deleteMcpAuthSession,
@@ -44,8 +44,9 @@ import {
44
44
  getMcpStoredOAuthCredentials,
45
45
  lookupSlackUserProfile,
46
46
  resolvePluginOAuthAccount
47
- } from "./chunk-W2DDJCPS.js";
47
+ } from "./chunk-FVFJ57RK.js";
48
48
  import {
49
+ RetryableDeliveryError,
49
50
  addReactionToMessage,
50
51
  escapeSlackMrkdwnText,
51
52
  formatProviderLabel,
@@ -57,20 +58,7 @@ import {
57
58
  removeReactionFromMessage,
58
59
  resolveBaseUrl,
59
60
  truncateStatusText
60
- } from "./chunk-UVUXFRYN.js";
61
- import {
62
- parseSlackThreadId,
63
- readSlackRawMessageContext,
64
- resolveSlackChannelIdFromMessage,
65
- resolveSlackChannelIdFromThreadId
66
- } from "./chunk-CVBDVIF4.js";
67
- import {
68
- RetryableDeliveryError
69
- } from "./chunk-6FGN7ZEG.js";
70
- import {
71
- ensureConversationWake,
72
- requestConversationWork
73
- } from "./chunk-MQDIIFZM.js";
61
+ } from "./chunk-GWCFXTB6.js";
74
62
  import {
75
63
  CooperativeTurnYieldError,
76
64
  clearPendingAuth,
@@ -79,7 +67,7 @@ import {
79
67
  isCooperativeTurnYieldError,
80
68
  isPendingAuthLatestRequest,
81
69
  markTurnFailed
82
- } from "./chunk-Z5SKZE5B.js";
70
+ } from "./chunk-67MMSYSE.js";
83
71
  import {
84
72
  TurnSliceLimitExceededError,
85
73
  abandonTurnRecord,
@@ -99,13 +87,23 @@ import {
99
87
  recordTurnSummary,
100
88
  saveTurnCheckpoint,
101
89
  turnHasReply
102
- } from "./chunk-6YGFBU3A.js";
90
+ } from "./chunk-BGOLRC36.js";
103
91
  import {
104
- getVercelConversationWorkQueue
105
- } from "./chunk-DKIJ2RP5.js";
92
+ parseSlackThreadId,
93
+ readSlackRawMessageContext,
94
+ resolveSlackChannelIdFromMessage,
95
+ resolveSlackChannelIdFromThreadId
96
+ } from "./chunk-BUJU6C2J.js";
97
+ import {
98
+ ensureConversationWake,
99
+ requestConversationWork
100
+ } from "./chunk-YFU4DGZY.js";
106
101
  import {
107
102
  getTurnRequestDeadline
108
- } from "./chunk-WGZJ5SU4.js";
103
+ } from "./chunk-7UJ6IJCK.js";
104
+ import {
105
+ getVercelConversationWorkQueue
106
+ } from "./chunk-DKIJ2RP5.js";
109
107
  import {
110
108
  SlackActionError,
111
109
  getDashboardConversationLink,
@@ -114,38 +112,39 @@ import {
114
112
  getSlackClient,
115
113
  isDmChannel,
116
114
  normalizeSlackConversationId
117
- } from "./chunk-QCGNHSMA.js";
115
+ } from "./chunk-2MRF22J4.js";
118
116
  import {
117
+ getConversationStore,
119
118
  getSqlExecutor,
120
119
  requireSlackDestination,
121
120
  upsertIdentity,
122
121
  upsertLinkedIdentity
123
- } from "./chunk-IUUQWIG2.js";
122
+ } from "./chunk-OKAHLUSU.js";
124
123
  import {
125
124
  acquireActiveLock,
126
125
  getStateAdapter
127
- } from "./chunk-ZX7RSBQ6.js";
126
+ } from "./chunk-6BXUSF7J.js";
128
127
  import {
129
128
  botConfig,
130
129
  escapeXml,
131
130
  getChatConfig,
132
131
  getRuntimeMetadata,
133
132
  normalizeSlackEmojiName
134
- } from "./chunk-Q7O74WOO.js";
133
+ } from "./chunk-VWNIDTFR.js";
135
134
  import {
136
135
  defaultModelId
137
136
  } from "./chunk-D4YV5TDV.js";
138
137
  import {
139
138
  discoverSkills
140
- } from "./chunk-3HEZWDS5.js";
139
+ } from "./chunk-REVH4BZU.js";
141
140
  import {
142
141
  pluginCatalogRuntime
143
- } from "./chunk-NZLZ4KYZ.js";
142
+ } from "./chunk-4PKEJK5B.js";
144
143
  import {
145
144
  buildOAuthTokenRequest,
146
145
  hasRequiredOAuthScope,
147
146
  parseOAuthTokenResponse
148
- } from "./chunk-QIOUTXTZ.js";
147
+ } from "./chunk-663DQH5W.js";
149
148
  import {
150
149
  createSlackResumeActor,
151
150
  isUserActor,
@@ -164,7 +163,7 @@ import {
164
163
  setTags,
165
164
  toOptionalString,
166
165
  withLogContext
167
- } from "./chunk-QIMN3FXL.js";
166
+ } from "./chunk-Y4WL4OYD.js";
168
167
 
169
168
  // src/chat/slack/assistant-thread/status-render.ts
170
169
  var DEFAULT_STATUS_CONTEXTS = {
@@ -1269,7 +1268,7 @@ function buildResumedRun(args, statusSession, delivery) {
1269
1268
  ...savedRun.instruction ?? { text: args.messageText },
1270
1269
  text: args.messageText
1271
1270
  },
1272
- source: source.platform === "slack" ? {
1271
+ source: source.kind === "slack" ? {
1273
1272
  ...source,
1274
1273
  channelId: args.channelId,
1275
1274
  ...args.threadTs ? { threadTs: args.threadTs } : void 0
@@ -1374,6 +1373,7 @@ async function resumeSlackTurnInContext(args) {
1374
1373
  }
1375
1374
  status.update(runArgs.initialStatus);
1376
1375
  const conversationId = runArgs.conversationId;
1376
+ const visibility = (await getConversationStore().get({ conversationId }))?.visibility;
1377
1377
  const visibleConversationId = lockKey;
1378
1378
  const sessionId = runArgs.turnId;
1379
1379
  let deliveryConversation;
@@ -1481,7 +1481,7 @@ async function resumeSlackTurnInContext(args) {
1481
1481
  () => recordTurnSummary({
1482
1482
  conversationId: runArgs.conversationId,
1483
1483
  destination: savedRun.destination,
1484
- destinationVisibility: savedRun.destinationVisibility,
1484
+ destinationVisibility: visibility,
1485
1485
  dispatchId,
1486
1486
  resultMessageId: messageTs,
1487
1487
  turnId: runArgs.turnId,
@@ -1502,10 +1502,7 @@ async function resumeSlackTurnInContext(args) {
1502
1502
  deliveryState.conversation,
1503
1503
  sessionId
1504
1504
  );
1505
- const run = buildResumedRun(runArgs, status, {
1506
- ...runArgs.run?.publishExternally !== false && runArgs.run?.source.location ? { location: runArgs.run.source.location } : void 0,
1507
- send: deliverAssistantMessage
1508
- });
1505
+ const run = buildResumedRun(runArgs, status, deliverAssistantMessage);
1509
1506
  if (runArgs.inputMessageIds?.length) {
1510
1507
  await turnLifecycle.start({
1511
1508
  conversationId: runArgs.conversationId,
@@ -1540,7 +1537,7 @@ async function resumeSlackTurnInContext(args) {
1540
1537
  durationMs: reply.diagnostics.durationMs,
1541
1538
  usage: reply.diagnostics.usage,
1542
1539
  destination: run.destination,
1543
- destinationVisibility: run.destinationVisibility,
1540
+ destinationVisibility: visibility,
1544
1541
  dispatchId: run.dispatch?.id,
1545
1542
  dispatchOutcome: reply.diagnostics.outcome === "success" ? "completed" : "failed",
1546
1543
  ...dispatchErrorMessage ? { errorMessage: dispatchErrorMessage } : void 0,
@@ -1554,7 +1551,7 @@ async function resumeSlackTurnInContext(args) {
1554
1551
  await recordTurnSummary({
1555
1552
  conversationId: runArgs.conversationId,
1556
1553
  destination: run.destination,
1557
- destinationVisibility: run.destinationVisibility,
1554
+ destinationVisibility: visibility,
1558
1555
  dispatchId: run.dispatch?.id,
1559
1556
  dispatchOutcome: reply.diagnostics.outcome === "success" ? "completed" : "failed",
1560
1557
  ...acceptedDeliveryId ? { resultMessageId: acceptedDeliveryId } : void 0,
@@ -2036,6 +2033,7 @@ async function resumeAuthorizedMcpTurn(args) {
2036
2033
  let actor;
2037
2034
  try {
2038
2035
  actor = createSlackResumeActor({
2036
+ actor: lockedSessionRecord.actor,
2039
2037
  teamId: destination.teamId,
2040
2038
  userId: authSession.userId
2041
2039
  });
@@ -2092,6 +2090,7 @@ async function resumeAuthorizedMcpTurn(args) {
2092
2090
  },
2093
2091
  actor,
2094
2092
  destination,
2093
+ ...routing.location ? { location: routing.location } : void 0,
2095
2094
  source: routing.source,
2096
2095
  toolChannelId: authSession.toolChannelId ?? authSession.channelId,
2097
2096
  environment: {
@@ -2180,7 +2179,7 @@ async function isCurrentMcpAuthorizationAttempt(authSession, provider) {
2180
2179
  return pendingAuth?.authSessionId === authSession.authSessionId && pendingAuth.sessionId === authSession.sessionId;
2181
2180
  }
2182
2181
  function mcpConversationId(authSession) {
2183
- if (authSession.destination?.platform === "local" || authSession.source?.platform === "web") {
2182
+ if (authSession.destination?.platform === "local" || authSession.source?.kind === "web") {
2184
2183
  return authSession.conversationId;
2185
2184
  }
2186
2185
  if (authSession.channelId && authSession.threadTs) {
@@ -2276,7 +2275,7 @@ async function GET(request, provider, waitUntil, options) {
2276
2275
  "app.credential.provider": provider
2277
2276
  });
2278
2277
  }
2279
- if (authSession.source?.platform === "web" && authSession.destination) {
2278
+ if (authSession.source?.kind === "web" && authSession.destination) {
2280
2279
  waitUntil(async () => {
2281
2280
  const turn = await getTurnRecord(
2282
2281
  authSession.conversationId,
@@ -2321,7 +2320,7 @@ async function GET(request, provider, waitUntil, options) {
2321
2320
  return htmlResponse("success", {
2322
2321
  // Web roots keep a local destination for conversation-only delivery.
2323
2322
  // Only the CLI path should get the local-client success copy.
2324
- local: authSession.destination?.platform === "local" && authSession.source?.platform !== "web"
2323
+ local: authSession.destination?.platform === "local" && authSession.source?.kind !== "web"
2325
2324
  });
2326
2325
  } catch (callbackError) {
2327
2326
  if (callbackError instanceof McpOAuthAttemptExpiredError) {
@@ -2696,6 +2695,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
2696
2695
  let actor;
2697
2696
  try {
2698
2697
  actor = createSlackResumeActor({
2698
+ actor: lockedSessionRecord.actor,
2699
2699
  teamId: destination.teamId,
2700
2700
  userId: lockedUserMessage.author.userId
2701
2701
  });
@@ -2757,6 +2757,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
2757
2757
  },
2758
2758
  actor,
2759
2759
  destination,
2760
+ ...routing.location ? { location: routing.location } : void 0,
2760
2761
  source: routing.source,
2761
2762
  toolChannelId: stored.channelId,
2762
2763
  environment: {
@@ -3046,7 +3047,7 @@ async function GET2(request, provider, waitUntil, options) {
3046
3047
  { "app.credential.provider": provider }
3047
3048
  );
3048
3049
  }
3049
- if (stored.destination?.platform !== "local" && stored.source?.platform !== "web") {
3050
+ if (stored.destination?.platform !== "local" && stored.source?.kind !== "web") {
3050
3051
  waitUntil(async () => {
3051
3052
  try {
3052
3053
  await publishAppHomeView(
@@ -3059,7 +3060,7 @@ async function GET2(request, provider, waitUntil, options) {
3059
3060
  });
3060
3061
  }
3061
3062
  const resumesWebTurn = Boolean(
3062
- stored.source?.platform === "web" && stored.destination && stored.resumeConversationId && stored.resumeSessionId
3063
+ stored.source?.kind === "web" && stored.destination && stored.resumeConversationId && stored.resumeSessionId
3063
3064
  );
3064
3065
  const resumesAgentTurn = Boolean(
3065
3066
  stored.destination?.platform !== "local" && stored.resumeConversationId && stored.resumeSessionId
@@ -1,32 +1,32 @@
1
1
  import {
2
2
  resolveBaseUrl
3
- } from "./chunk-UVUXFRYN.js";
3
+ } from "./chunk-GWCFXTB6.js";
4
4
  import {
5
5
  createPluginLogger,
6
6
  getPlugins,
7
7
  getSlackClient,
8
8
  withSlackRetries
9
- } from "./chunk-QCGNHSMA.js";
9
+ } from "./chunk-2MRF22J4.js";
10
10
  import {
11
11
  getDb,
12
12
  parseDestination
13
- } from "./chunk-IUUQWIG2.js";
13
+ } from "./chunk-OKAHLUSU.js";
14
14
  import {
15
15
  sleep
16
- } from "./chunk-X55FOVZO.js";
16
+ } from "./chunk-HI5KXE3C.js";
17
17
  import {
18
18
  acquireActiveLock,
19
19
  getStateAdapter
20
- } from "./chunk-ZX7RSBQ6.js";
20
+ } from "./chunk-6BXUSF7J.js";
21
21
  import {
22
22
  pluginCatalogRuntime
23
- } from "./chunk-NZLZ4KYZ.js";
23
+ } from "./chunk-4PKEJK5B.js";
24
24
  import {
25
25
  fetchWithBoundedOAuthErrorBodies
26
- } from "./chunk-QIOUTXTZ.js";
26
+ } from "./chunk-663DQH5W.js";
27
27
  import {
28
28
  isRecord
29
- } from "./chunk-QIMN3FXL.js";
29
+ } from "./chunk-Y4WL4OYD.js";
30
30
 
31
31
  // src/chat/capabilities/router.ts
32
32
  var ProviderCredentialRouter = class {
@@ -1,3 +1,6 @@
1
+ import {
2
+ isExperimentalFeatureEnabled
3
+ } from "./chunk-2LYHWMR4.js";
1
4
  import {
2
5
  SlackActionError,
3
6
  applyPluginFormatMarkdown,
@@ -5,19 +8,19 @@ import {
5
8
  isDmChannel,
6
9
  normalizeSlackConversationId,
7
10
  withSlackRetries
8
- } from "./chunk-QCGNHSMA.js";
11
+ } from "./chunk-2MRF22J4.js";
9
12
  import {
10
13
  parseDestination
11
- } from "./chunk-IUUQWIG2.js";
14
+ } from "./chunk-OKAHLUSU.js";
12
15
  import {
13
16
  getStateAdapter
14
- } from "./chunk-ZX7RSBQ6.js";
17
+ } from "./chunk-6BXUSF7J.js";
15
18
  import {
16
19
  normalizeSlackEmojiName
17
- } from "./chunk-Q7O74WOO.js";
20
+ } from "./chunk-VWNIDTFR.js";
18
21
  import {
19
22
  pluginCatalogRuntime
20
- } from "./chunk-NZLZ4KYZ.js";
23
+ } from "./chunk-4PKEJK5B.js";
21
24
  import {
22
25
  parseSlackMessageTs,
23
26
  parseSlackUserId
@@ -26,7 +29,200 @@ import {
26
29
  isRecord,
27
30
  logInfo,
28
31
  logWarn
29
- } from "./chunk-QIMN3FXL.js";
32
+ } from "./chunk-Y4WL4OYD.js";
33
+
34
+ // src/chat/agent/types.ts
35
+ var RetryableDeliveryError = class extends Error {
36
+ constructor(cause) {
37
+ super("Assistant delivery was transient or ambiguous", { cause });
38
+ this.name = "RetryableDeliveryError";
39
+ }
40
+ };
41
+ function isAgentRunFeatureDisabled(disabledFeatures, feature) {
42
+ return disabledFeatures?.includes(feature) ?? false;
43
+ }
44
+ function actorFromRun(run) {
45
+ if (run.dispatch?.actor) {
46
+ return run.dispatch.actor;
47
+ }
48
+ if (run.actor) {
49
+ return run.actor;
50
+ }
51
+ if (run.credentialContext && !("type" in run.credentialContext.actor)) {
52
+ return run.credentialContext.actor;
53
+ }
54
+ return void 0;
55
+ }
56
+ function assertRunConsistency(run) {
57
+ const { destination, source } = run;
58
+ switch (source.kind) {
59
+ case "slack": {
60
+ if (destination.platform !== "slack") {
61
+ throw new TypeError(
62
+ "Run source and destination platforms do not match"
63
+ );
64
+ }
65
+ if (source.teamId !== destination.teamId) {
66
+ throw new TypeError("Slack source and destination teams do not match");
67
+ }
68
+ break;
69
+ }
70
+ case "local": {
71
+ if (destination.platform !== "local") {
72
+ throw new TypeError(
73
+ "Run source and destination platforms do not match"
74
+ );
75
+ }
76
+ if (source.conversationId !== destination.conversationId) {
77
+ throw new TypeError(
78
+ "Source and destination conversation IDs do not match"
79
+ );
80
+ }
81
+ if (run.surface !== "internal" && destination.conversationId !== run.conversationId) {
82
+ throw new TypeError(
83
+ "Source, destination, and run conversation IDs do not match"
84
+ );
85
+ }
86
+ break;
87
+ }
88
+ case "web": {
89
+ if (run.surface !== "internal" && source.conversationId !== run.conversationId) {
90
+ throw new TypeError("Web source and run conversation IDs do not match");
91
+ }
92
+ switch (destination.platform) {
93
+ case "local": {
94
+ if (source.conversationId !== destination.conversationId) {
95
+ throw new TypeError(
96
+ "Source and destination conversation IDs do not match"
97
+ );
98
+ }
99
+ if (run.surface !== "internal" && destination.conversationId !== run.conversationId) {
100
+ throw new TypeError(
101
+ "Source, destination, and run conversation IDs do not match"
102
+ );
103
+ }
104
+ break;
105
+ }
106
+ case "slack":
107
+ break;
108
+ }
109
+ break;
110
+ }
111
+ case "resource_event":
112
+ break;
113
+ }
114
+ const actor = run.dispatch?.actor ?? run.actor;
115
+ if (!actor || actor.platform === "system") {
116
+ return;
117
+ }
118
+ if (actor.platform !== source.kind) {
119
+ throw new TypeError(
120
+ `Actor platform "${actor.platform}" does not match Source kind "${source.kind}"`
121
+ );
122
+ }
123
+ if (actor.platform === "slack" && source.kind === "slack" && actor.teamId !== source.teamId) {
124
+ throw new TypeError("Slack Actor team does not match Source team");
125
+ }
126
+ }
127
+ function toolInvocationDestination(run) {
128
+ if (run.destination.platform !== "slack" || !run.toolChannelId) {
129
+ return run.destination;
130
+ }
131
+ return {
132
+ platform: "slack",
133
+ teamId: run.destination.teamId,
134
+ channelId: run.toolChannelId
135
+ };
136
+ }
137
+ function surfaceFromRun(run) {
138
+ if (run.surface) {
139
+ return run.surface;
140
+ }
141
+ if (run.source.kind === "slack") {
142
+ return "slack";
143
+ }
144
+ if (run.source.kind === "web") {
145
+ return "api";
146
+ }
147
+ return "internal";
148
+ }
149
+
150
+ // src/chat/runtime/agent-runner.ts
151
+ var AGENT_ABORT_SETTLE_GRACE_MS = 5e3;
152
+ function createAgentRunner(execute, options) {
153
+ const attachmentStorage = options?.attachmentStorage;
154
+ const streamFn = options?.streamFn;
155
+ const tracePropagation = options?.tracePropagation;
156
+ const bindSpawnAgent = options?.bindSpawnAgent;
157
+ const canBindSpawn = Boolean(bindSpawnAgent) && isExperimentalFeatureEnabled("subagents");
158
+ return {
159
+ run: async (run) => {
160
+ const spawnAgent = bindSpawnAgent && canBindSpawn && !isAgentRunFeatureDisabled(run.disabledFeatures, "subagents") ? bindSpawnAgent(run) : void 0;
161
+ const nextRun = {
162
+ ...run,
163
+ environment: {
164
+ ...run.environment,
165
+ attachmentStorage: run.environment?.attachmentStorage ?? attachmentStorage,
166
+ sandboxTracePropagation: run.environment?.sandboxTracePropagation ?? tracePropagation
167
+ },
168
+ ...spawnAgent ? {
169
+ durability: {
170
+ ...run.durability,
171
+ spawnAgent
172
+ }
173
+ } : void 0
174
+ };
175
+ return await execute(nextRun, streamFn);
176
+ }
177
+ };
178
+ }
179
+ async function waitForAgentSettlement(runPromise) {
180
+ let timeoutId;
181
+ const settleGrace = new Promise((resolve) => {
182
+ timeoutId = setTimeout(resolve, AGENT_ABORT_SETTLE_GRACE_MS);
183
+ timeoutId.unref?.();
184
+ });
185
+ await Promise.race([
186
+ runPromise.then(
187
+ () => void 0,
188
+ () => void 0
189
+ ),
190
+ settleGrace
191
+ ]);
192
+ if (timeoutId) {
193
+ clearTimeout(timeoutId);
194
+ }
195
+ }
196
+ async function runAgentWithTimeout(agentRunner, run, timeoutMs) {
197
+ if (typeof timeoutMs !== "number") {
198
+ return await agentRunner.run(run);
199
+ }
200
+ const timeoutError = new Error(
201
+ `executeAgentRun timed out after ${timeoutMs}ms`
202
+ );
203
+ const abortController = new AbortController();
204
+ const signal = run.signal ? AbortSignal.any([run.signal, abortController.signal]) : abortController.signal;
205
+ const runPromise = agentRunner.run({ ...run, signal });
206
+ let timeoutId;
207
+ const timeoutPromise = new Promise((_, reject) => {
208
+ timeoutId = setTimeout(() => {
209
+ abortController.abort(timeoutError);
210
+ reject(timeoutError);
211
+ }, timeoutMs);
212
+ });
213
+ try {
214
+ return await Promise.race([runPromise, timeoutPromise]);
215
+ } catch (error) {
216
+ if (abortController.signal.aborted) {
217
+ await waitForAgentSettlement(runPromise);
218
+ }
219
+ throw error;
220
+ } finally {
221
+ if (timeoutId) {
222
+ clearTimeout(timeoutId);
223
+ }
224
+ }
225
+ }
30
226
 
31
227
  // src/chat/slack/outbound.ts
32
228
  var MAX_SLACK_MESSAGE_TEXT_CHARS = 4e4;
@@ -705,6 +901,12 @@ async function startOAuthFlow(provider, input) {
705
901
  }
706
902
 
707
903
  export {
904
+ RetryableDeliveryError,
905
+ isAgentRunFeatureDisabled,
906
+ actorFromRun,
907
+ assertRunConsistency,
908
+ toolInvocationDestination,
909
+ surfaceFromRun,
708
910
  getSlackMessagePermalink,
709
911
  postSlackMessage,
710
912
  uploadFilesToConversation,
@@ -719,5 +921,7 @@ export {
719
921
  formatProviderLabel,
720
922
  resolveBaseUrl,
721
923
  deliverOAuthAuthorization,
722
- startOAuthFlow
924
+ startOAuthFlow,
925
+ createAgentRunner,
926
+ runAgentWithTimeout
723
927
  };
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  toOptionalTrimmed
3
- } from "./chunk-Q7O74WOO.js";
3
+ } from "./chunk-VWNIDTFR.js";
4
4
  import {
5
5
  pluginCatalogRuntime
6
- } from "./chunk-NZLZ4KYZ.js";
6
+ } from "./chunk-4PKEJK5B.js";
7
7
  import {
8
8
  setSpanAttributes,
9
9
  setSpanStatus
10
- } from "./chunk-QIMN3FXL.js";
10
+ } from "./chunk-Y4WL4OYD.js";
11
11
 
12
12
  // src/chat/sandbox/paths.ts
13
13
  function normalizeWorkspaceRoot(input) {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  ConversationTurnLifecycleService
3
- } from "./chunk-W42ENMJW.js";
3
+ } from "./chunk-6H7YU6XH.js";
4
4
  import {
5
5
  runAgentWithTimeout
6
- } from "./chunk-6FGN7ZEG.js";
6
+ } from "./chunk-GWCFXTB6.js";
7
7
  import {
8
8
  getConversationEventStore
9
- } from "./chunk-IUUQWIG2.js";
9
+ } from "./chunk-OKAHLUSU.js";
10
10
 
11
11
  // src/chat/runtime/turn-execution.ts
12
12
  var AgentRunError = class extends Error {
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@sentry/junior",
4
- version: "0.188.0",
4
+ version: "0.190.0",
5
5
  private: false,
6
6
  publishConfig: {
7
7
  access: "public"