@sentry/junior 0.189.0 → 0.191.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 (86) hide show
  1. package/dist/{agent-hooks-6QRYH6PX.js → agent-hooks-HIWWBBKO.js} +11 -11
  2. package/dist/api.js +27 -27
  3. package/dist/app.js +134 -152
  4. package/dist/{catalog-runtime-IETJLJFG.js → catalog-runtime-4OKH4265.js} +4 -4
  5. package/dist/chat/actor.d.ts +7 -2
  6. package/dist/chat/agent/resume.d.ts +0 -1
  7. package/dist/chat/agent/types.d.ts +0 -1
  8. package/dist/chat/agent-invocations/types.d.ts +44 -308
  9. package/dist/chat/event-tasks/tool-support.d.ts +1 -1
  10. package/dist/chat/providers/slack/runtime.d.ts +1 -2
  11. package/dist/chat/providers/slack/system-turn.d.ts +9 -4
  12. package/dist/chat/providers/slack/turn.d.ts +0 -1
  13. package/dist/chat/resource-events/actor.d.ts +2 -2
  14. package/dist/chat/services/turn-router.d.ts +1 -1
  15. package/dist/chat/slack/dispatch-turn.d.ts +0 -1
  16. package/dist/chat/slack/timestamp-param.d.ts +1 -1
  17. package/dist/chat/source.d.ts +3 -3
  18. package/dist/chat/task-execution/assistant-message.d.ts +7 -7
  19. package/dist/chat/task-execution/checkpoint.d.ts +0 -1
  20. package/dist/chat/task-execution/conversation-turn.d.ts +2 -2
  21. package/dist/chat/task-execution/mailbox-turn.d.ts +16 -6
  22. package/dist/chat/task-execution/state.d.ts +2 -5
  23. package/dist/chat/task-execution/store.d.ts +1 -2
  24. package/dist/chat/task-execution/turn-cursor.d.ts +10 -3
  25. package/dist/chat/task-execution/worker.d.ts +0 -1
  26. package/dist/chat/tools/types.d.ts +9 -2
  27. package/dist/{chunk-BYBSI5TI.js → chunk-2JAWOTUT.js} +2 -2
  28. package/dist/{chunk-WN6VLHOU.js → chunk-3PDR63SX.js} +30 -9
  29. package/dist/{chunk-SR6OMO5C.js → chunk-5IMKUVMS.js} +8 -11
  30. package/dist/{chunk-YYSEH2WC.js → chunk-6KISW5UY.js} +2 -2
  31. package/dist/{chunk-WDHPN2GH.js → chunk-7PYCRKQL.js} +3 -3
  32. package/dist/{chunk-YNZPOFF3.js → chunk-AWFSSFAX.js} +9 -11
  33. package/dist/{chunk-OEIITG5F.js → chunk-BVWC5DBM.js} +1 -1
  34. package/dist/{chunk-DYXVAO2E.js → chunk-BVYUIVXE.js} +1 -1
  35. package/dist/{chunk-WYDF6PGK.js → chunk-CCPOZMS4.js} +3 -3
  36. package/dist/{chunk-YYZNESC3.js → chunk-CECRMPXJ.js} +9 -8
  37. package/dist/{chunk-6AUR6PWR.js → chunk-CUUE5MGF.js} +3 -3
  38. package/dist/{chunk-MVPLEPSI.js → chunk-DP6H3U2X.js} +1 -1
  39. package/dist/{chunk-E3PDZPGV.js → chunk-EQZUBYRF.js} +1 -1
  40. package/dist/{chunk-PCPSX4ES.js → chunk-GQN4REF5.js} +14 -12
  41. package/dist/{chunk-AC7MDOJW.js → chunk-HNMRX2EN.js} +5 -5
  42. package/dist/{chunk-7R5JRPCY.js → chunk-K2NKG42A.js} +5 -5
  43. package/dist/{chunk-MFSET7Q7.js → chunk-KTW62MG5.js} +31 -13
  44. package/dist/{chunk-PY3EIEAF.js → chunk-L4JLLS6C.js} +1 -1
  45. package/dist/{chunk-CMWIMFM6.js → chunk-LOYTPSAK.js} +5 -5
  46. package/dist/{chunk-S3SGZUOI.js → chunk-MFZOIKET.js} +1 -1
  47. package/dist/{chunk-MI6ZBDTS.js → chunk-NK3UEKAW.js} +25 -10
  48. package/dist/{chunk-QNIOBNOY.js → chunk-NY5SJGJZ.js} +52 -46
  49. package/dist/{chunk-4RHJ3CXR.js → chunk-Q32BSFN4.js} +13 -12
  50. package/dist/{chunk-ZV6PFUA4.js → chunk-QRNJO7DZ.js} +1 -1
  51. package/dist/{chunk-KN32OWL2.js → chunk-RZS4F5K4.js} +3 -3
  52. package/dist/{chunk-CUYFCI4G.js → chunk-S7NSFCCW.js} +16 -13
  53. package/dist/{chunk-5VWAY27R.js → chunk-SEIZ2XLD.js} +1 -1
  54. package/dist/{chunk-MRXMFB4L.js → chunk-SGRL7NV6.js} +5 -5
  55. package/dist/{chunk-WWYUYKKV.js → chunk-TH6LMEOW.js} +1 -1
  56. package/dist/{chunk-WMUAKAIF.js → chunk-VGYZ3YZM.js} +85 -41
  57. package/dist/{chunk-ZUPDSJUE.js → chunk-WBNQYVCM.js} +2 -2
  58. package/dist/{chunk-GP32KD2J.js → chunk-WCSXTDOL.js} +1 -1
  59. package/dist/{chunk-O35GZCKL.js → chunk-WNIVCR74.js} +2 -2
  60. package/dist/{chunk-UCWO5MKP.js → chunk-X6PQKQTY.js} +5 -7
  61. package/dist/{chunk-5CXCGDIL.js → chunk-YNRLCUCB.js} +1 -1
  62. package/dist/{chunk-LHKZKAZ4.js → chunk-ZJRGWZZ2.js} +3 -3
  63. package/dist/{chunk-NY2F7BZA.js → chunk-ZNFNGDT7.js} +1 -1
  64. package/dist/{chunk-VKQWU4PO.js → chunk-ZRN3OS7M.js} +1 -1
  65. package/dist/cli/chat.js +33 -33
  66. package/dist/cli/check.js +5 -5
  67. package/dist/cli/plugins.js +12 -12
  68. package/dist/cli/snapshot-create.js +9 -9
  69. package/dist/cli/upgrade.js +6 -6
  70. package/dist/db/schema/agent-invocations.d.ts +18 -6
  71. package/dist/db/schema.d.ts +18 -6
  72. package/dist/{db-LPJKR2EO.js → db-LG4ZEWA3.js} +6 -6
  73. package/dist/instrumentation.js +3 -3
  74. package/dist/nitro.js +6 -6
  75. package/dist/{oauth-callback-server-DMXF4TTQ.js → oauth-callback-server-KI7ZRTOG.js} +29 -29
  76. package/dist/{runner-L5DPVYCN.js → runner-K2EOSAZQ.js} +21 -21
  77. package/dist/{skills-NXG3LBCK.js → skills-JTRDFKMA.js} +5 -5
  78. package/dist/spawn-SRBETYCF.js +42 -0
  79. package/dist/task-runner-INQIQ4VF.js +36 -0
  80. package/dist/{validation-CH36LTOS.js → validation-NBWURHAP.js} +5 -5
  81. package/dist/version.js +1 -1
  82. package/dist/{work-HBC5Y5VZ.js → work-35TBEAUI.js} +21 -21
  83. package/dist/{worker-5RDZHLXH.js → worker-F762M6XM.js} +10 -10
  84. package/package.json +6 -6
  85. package/dist/spawn-VRUIGKWW.js +0 -42
  86. package/dist/task-runner-7YTBSPXW.js +0 -36
package/dist/app.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  processConversationWork
3
- } from "./chunk-UCWO5MKP.js";
3
+ } from "./chunk-X6PQKQTY.js";
4
4
  import {
5
5
  bindSpawnAgent
6
- } from "./chunk-ZUPDSJUE.js";
6
+ } from "./chunk-WBNQYVCM.js";
7
7
  import {
8
8
  createAgentInvocationWorker,
9
9
  enqueueAgentInvocation,
10
10
  listPendingAgentInvocationMailboxAppends,
11
11
  resolveAgentInvocationId
12
- } from "./chunk-YNZPOFF3.js";
12
+ } from "./chunk-AWFSSFAX.js";
13
13
  import {
14
14
  GET as GET2,
15
15
  GET2 as GET3,
@@ -37,12 +37,12 @@ import {
37
37
  startProcessingReaction,
38
38
  stripLeadingBotMention,
39
39
  wakePausedTurn
40
- } from "./chunk-WMUAKAIF.js";
40
+ } from "./chunk-VGYZ3YZM.js";
41
41
  import "./chunk-FA6POGLH.js";
42
42
  import {
43
43
  AgentRunError,
44
44
  executeTurn
45
- } from "./chunk-WYDF6PGK.js";
45
+ } from "./chunk-CCPOZMS4.js";
46
46
  import {
47
47
  buildDeliveredTurnStatePatch,
48
48
  completeAuthPauseTurn,
@@ -53,7 +53,7 @@ import {
53
53
  getTurnUserSlackMessageTs,
54
54
  persistAuthPauseTurnState,
55
55
  requireTurnFailureEventId
56
- } from "./chunk-7R5JRPCY.js";
56
+ } from "./chunk-K2NKG42A.js";
57
57
  import {
58
58
  claimDispatchMailboxAppend,
59
59
  confirmDispatchMailboxAppend,
@@ -73,11 +73,11 @@ import {
73
73
  processPluginTask,
74
74
  resolveTurnSessionRouting,
75
75
  scheduleSessionCompletedPluginTasks
76
- } from "./chunk-4RHJ3CXR.js";
76
+ } from "./chunk-Q32BSFN4.js";
77
77
  import {
78
78
  ConversationTurnLifecycleService,
79
79
  getTurnLifecycle
80
- } from "./chunk-WWYUYKKV.js";
80
+ } from "./chunk-TH6LMEOW.js";
81
81
  import {
82
82
  coerceThreadConversationState,
83
83
  getLocationConfigurationService,
@@ -86,7 +86,7 @@ import {
86
86
  persistThreadRuntimeState,
87
87
  persistThreadState,
88
88
  persistThreadStateById
89
- } from "./chunk-MRXMFB4L.js";
89
+ } from "./chunk-SGRL7NV6.js";
90
90
  import {
91
91
  GET,
92
92
  appendAndEnqueueWebMessage,
@@ -101,24 +101,24 @@ import {
101
101
  resolveSlackChannelTypeFromMessage,
102
102
  resolveSlackConversationContext,
103
103
  webActorFromEmail
104
- } from "./chunk-SR6OMO5C.js";
104
+ } from "./chunk-5IMKUVMS.js";
105
105
  import {
106
106
  createWebAuthorization,
107
107
  deleteWebAuthorization
108
- } from "./chunk-VKQWU4PO.js";
108
+ } from "./chunk-ZRN3OS7M.js";
109
109
  import {
110
110
  recordTaskExecution
111
- } from "./chunk-LHKZKAZ4.js";
111
+ } from "./chunk-ZJRGWZZ2.js";
112
112
  import "./chunk-UTL3MHPC.js";
113
113
  import {
114
114
  createVercelPluginTaskCallback,
115
115
  queueCallback,
116
116
  registerVercelPluginTaskDevConsumer
117
- } from "./chunk-KN32OWL2.js";
117
+ } from "./chunk-RZS4F5K4.js";
118
118
  import {
119
119
  validatePluginEgressCredentialHooks,
120
120
  validatePluginRegistrations
121
- } from "./chunk-OEIITG5F.js";
121
+ } from "./chunk-BVWC5DBM.js";
122
122
  import {
123
123
  defineJuniorPlugins,
124
124
  pluginCatalogConfigFromEnv,
@@ -158,11 +158,11 @@ import {
158
158
  shouldEmitDevAgentTrace,
159
159
  shouldPropagateSandboxEgressTrace,
160
160
  unpublishedArtifactHeaders
161
- } from "./chunk-QNIOBNOY.js";
161
+ } from "./chunk-NY5SJGJZ.js";
162
162
  import {
163
163
  AuthorizationFlowDisabledError,
164
164
  PluginCredentialFailureError
165
- } from "./chunk-AC7MDOJW.js";
165
+ } from "./chunk-HNMRX2EN.js";
166
166
  import "./chunk-6Y5B5PEX.js";
167
167
  import "./chunk-DIB4GX3G.js";
168
168
  import {
@@ -170,14 +170,14 @@ import {
170
170
  deleteMcpAuthSessionsForUserProvider,
171
171
  deleteMcpServerSessionId,
172
172
  deleteMcpStoredOAuthCredentials
173
- } from "./chunk-YYZNESC3.js";
173
+ } from "./chunk-CECRMPXJ.js";
174
174
  import {
175
175
  RetryableDeliveryError,
176
176
  createAgentRunner,
177
177
  formatProviderLabel,
178
178
  postSlackMessage,
179
179
  startOAuthFlow
180
- } from "./chunk-PCPSX4ES.js";
180
+ } from "./chunk-GQN4REF5.js";
181
181
  import {
182
182
  ConversationTurnBoundaryError,
183
183
  CooperativeTurnYieldError,
@@ -193,7 +193,7 @@ import {
193
193
  markTurnCompleted,
194
194
  markTurnFailed,
195
195
  startActiveTurn
196
- } from "./chunk-GP32KD2J.js";
196
+ } from "./chunk-WCSXTDOL.js";
197
197
  import {
198
198
  abandonTurnRecord,
199
199
  appendThreadContextMessages,
@@ -229,7 +229,7 @@ import {
229
229
  trimTrailingAssistantMessages,
230
230
  turnHasReply,
231
231
  upsertConversationMessage
232
- } from "./chunk-MFSET7Q7.js";
232
+ } from "./chunk-KTW62MG5.js";
233
233
  import {
234
234
  getExperimentalFeatures,
235
235
  isExperimentalFeatureEnabled,
@@ -249,10 +249,10 @@ import {
249
249
  scheduledRunId,
250
250
  scheduledRunSchema,
251
251
  withScheduledTaskLock
252
- } from "./chunk-CMWIMFM6.js";
252
+ } from "./chunk-LOYTPSAK.js";
253
253
  import {
254
254
  parseSlackThreadId
255
- } from "./chunk-MVPLEPSI.js";
255
+ } from "./chunk-DP6H3U2X.js";
256
256
  import {
257
257
  CONVERSATION_WORK_STALE_ENQUEUE_MS,
258
258
  appendAndEnqueueInboundMessage,
@@ -267,16 +267,16 @@ import {
267
267
  removeActiveConversation,
268
268
  requestConversationWork,
269
269
  stopConversationWork
270
- } from "./chunk-WN6VLHOU.js";
270
+ } from "./chunk-3PDR63SX.js";
271
271
  import {
272
272
  buildDeterministicAssistantMessageId,
273
273
  buildDeterministicTurnId
274
274
  } from "./chunk-DA2KGZZI.js";
275
- import "./chunk-O35GZCKL.js";
275
+ import "./chunk-WNIVCR74.js";
276
276
  import {
277
277
  getSandboxResourceConfig,
278
278
  setSandboxResourceConfig
279
- } from "./chunk-6AUR6PWR.js";
279
+ } from "./chunk-CUUE5MGF.js";
280
280
  import "./chunk-PDO5BLNM.js";
281
281
  import "./chunk-UIE3R5XU.js";
282
282
  import {
@@ -285,7 +285,7 @@ import {
285
285
  } from "./chunk-X6GDDWQH.js";
286
286
  import {
287
287
  getTurnRequestDeadline
288
- } from "./chunk-S3SGZUOI.js";
288
+ } from "./chunk-MFZOIKET.js";
289
289
  import {
290
290
  getVercelConversationWorkQueue,
291
291
  resolveConversationWorkQueueTopic,
@@ -321,7 +321,7 @@ import {
321
321
  verifyEventTaskCredentialSubject,
322
322
  verifyScheduledTaskCredentialSubject,
323
323
  verifySlackDirectCredentialSubject
324
- } from "./chunk-MI6ZBDTS.js";
324
+ } from "./chunk-NK3UEKAW.js";
325
325
  import "./chunk-3Y47VMHV.js";
326
326
  import {
327
327
  createSlackDestination,
@@ -333,7 +333,7 @@ import {
333
333
  requireSlackDestination,
334
334
  withConversationEventLock,
335
335
  withConversationMutationLock
336
- } from "./chunk-CUYFCI4G.js";
336
+ } from "./chunk-S7NSFCCW.js";
337
337
  import {
338
338
  juniorAgentBindings,
339
339
  juniorAgentInvocations,
@@ -341,13 +341,13 @@ import {
341
341
  juniorConversations,
342
342
  juniorSchedulerRuns,
343
343
  juniorSchedulerTasks
344
- } from "./chunk-5VWAY27R.js";
345
- import "./chunk-WDHPN2GH.js";
344
+ } from "./chunk-SEIZ2XLD.js";
345
+ import "./chunk-7PYCRKQL.js";
346
346
  import {
347
347
  acquireActiveLock,
348
348
  getStateAdapter,
349
349
  withActiveLock
350
- } from "./chunk-5CXCGDIL.js";
350
+ } from "./chunk-YNRLCUCB.js";
351
351
  import {
352
352
  instructionProvenanceFor
353
353
  } from "./chunk-GFBR4S3Q.js";
@@ -369,17 +369,17 @@ import {
369
369
  isProviderRetryError,
370
370
  setProfiles,
371
371
  setSlackReactionConfig
372
- } from "./chunk-BYBSI5TI.js";
372
+ } from "./chunk-2JAWOTUT.js";
373
373
  import {
374
374
  defaultModelId,
375
375
  modelIdForProfile
376
376
  } from "./chunk-D4YV5TDV.js";
377
- import "./chunk-DYXVAO2E.js";
378
- import "./chunk-YYSEH2WC.js";
377
+ import "./chunk-BVYUIVXE.js";
378
+ import "./chunk-6KISW5UY.js";
379
379
  import {
380
380
  pluginCatalogRuntime
381
- } from "./chunk-E3PDZPGV.js";
382
- import "./chunk-ZV6PFUA4.js";
381
+ } from "./chunk-EQZUBYRF.js";
382
+ import "./chunk-QRNJO7DZ.js";
383
383
  import {
384
384
  credentialContextForActor
385
385
  } from "./chunk-CEMMLV5L.js";
@@ -415,13 +415,13 @@ import {
415
415
  withContext,
416
416
  withLogContext,
417
417
  withSpan
418
- } from "./chunk-PY3EIEAF.js";
418
+ } from "./chunk-L4JLLS6C.js";
419
419
  import {
420
420
  continueTrace
421
421
  } from "./chunk-PEQXYSSE.js";
422
422
  import {
423
423
  JUNIOR_VERSION
424
- } from "./chunk-NY2F7BZA.js";
424
+ } from "./chunk-ZNFNGDT7.js";
425
425
 
426
426
  // src/app.ts
427
427
  import { createRequire } from "module";
@@ -597,7 +597,6 @@ function buildAgentDispatchInboundMessage(dispatch2, nowMs = Date.now()) {
597
597
  }
598
598
  },
599
599
  receivedAtMs: nowMs,
600
- publishExternally: true,
601
600
  source: "plugin"
602
601
  };
603
602
  }
@@ -942,7 +941,7 @@ function dispatchOptionsErrorMessage(issues) {
942
941
  return "Dispatch source must not include unknown fields";
943
942
  }
944
943
  if (hasIssueAtPath(issues, ["source"])) {
945
- return "Dispatch source platform is required";
944
+ return "Dispatch Source kind is required";
946
945
  }
947
946
  if (hasIssueUnderPath(issues, ["source", "teamId"])) {
948
947
  return "Dispatch source teamId must be a Slack team id";
@@ -3277,7 +3276,6 @@ function createSlackConversationWorker(options) {
3277
3276
  if (!latestRecord) {
3278
3277
  return { status: "completed" };
3279
3278
  }
3280
- const publishExternally = latestRecord.publishExternally ?? context.publishExternally;
3281
3279
  const latestMetadata = parseSlackMetadata(latestRecord.input.metadata);
3282
3280
  if (!latestMetadata) {
3283
3281
  throw new Error(
@@ -3341,9 +3339,7 @@ function createSlackConversationWorker(options) {
3341
3339
  };
3342
3340
  const drainSteeringMessages = async (accept) => {
3343
3341
  await context.attempt.drain(async (pendingRecords) => {
3344
- const candidates = pendingRecords.filter(
3345
- (record) => record.publishExternally === publishExternally
3346
- ).map((record) => ({
3342
+ const candidates = pendingRecords.map((record) => ({
3347
3343
  inboundMessageId: record.inboundMessageId,
3348
3344
  message: restoreMessage({
3349
3345
  adapter,
@@ -3360,7 +3356,6 @@ function createSlackConversationWorker(options) {
3360
3356
  await options.runtime.handleNewMention(thread, latestMessage, {
3361
3357
  conversationId: context.conversationId,
3362
3358
  destination,
3363
- publishExternally,
3364
3359
  messageContext,
3365
3360
  drainSteeringMessages,
3366
3361
  ack,
@@ -3374,7 +3369,6 @@ function createSlackConversationWorker(options) {
3374
3369
  {
3375
3370
  conversationId: context.conversationId,
3376
3371
  destination,
3377
- publishExternally,
3378
3372
  messageContext,
3379
3373
  drainSteeringMessages,
3380
3374
  ack,
@@ -3426,7 +3420,6 @@ function buildSlackInboundMessage(args) {
3426
3420
  source: "slack",
3427
3421
  createdAtMs: args.message.metadata.dateSent.getTime(),
3428
3422
  receivedAtMs: args.receivedAtMs,
3429
- publishExternally: true,
3430
3423
  input: {
3431
3424
  text: args.message.text || " ",
3432
3425
  authorId,
@@ -3694,7 +3687,8 @@ async function handleUnlink(event, actorId, provider) {
3694
3687
  await postEphemeral(event, `Unknown provider: \`${provider}\``);
3695
3688
  return;
3696
3689
  }
3697
- if (!pluginCatalogRuntime.getOAuthConfig(provider)) {
3690
+ const supportsUnlink = Boolean(pluginCatalogRuntime.getOAuthConfig(provider)) || Boolean(pluginCatalogRuntime.getDefinition(provider)?.manifest.mcp);
3691
+ if (!supportsUnlink) {
3698
3692
  await postEphemeral(
3699
3693
  event,
3700
3694
  `${formatProviderLabel(provider)} doesn't support account unlinking.`
@@ -4978,9 +4972,6 @@ function buildLogContext(deps, args) {
4978
4972
  function actorUserName(message) {
4979
4973
  return getMessageActorIdentity(message)?.userName;
4980
4974
  }
4981
- function shouldPublishExternally(publishExternally) {
4982
- return publishExternally !== false;
4983
- }
4984
4975
  function createSlackTurnRuntime(deps) {
4985
4976
  const turnLifecycle = getTurnLifecycle();
4986
4977
  const logContext = (args) => buildLogContext(deps, args);
@@ -5295,7 +5286,6 @@ function createSlackTurnRuntime(deps) {
5295
5286
  conversationId: hooks.conversationId,
5296
5287
  destination: hooks.destination,
5297
5288
  queuedMessages,
5298
- publishExternally: shouldPublishExternally(hooks.publishExternally),
5299
5289
  ack,
5300
5290
  onToolInvocation: toolInvocationHook,
5301
5291
  onTurnCompleted,
@@ -5353,13 +5343,11 @@ function createSlackTurnRuntime(deps) {
5353
5343
  lifecycleError = error2;
5354
5344
  }
5355
5345
  await hooks.beforeFirstResponsePost?.();
5356
- if (shouldPublishExternally(hooks.publishExternally)) {
5357
- await postFallbackErrorReplyWithLogging({
5358
- thread,
5359
- eventId,
5360
- postFailureEventName: "mention.handler.failure_reply_post.failed"
5361
- });
5362
- }
5346
+ await postFallbackErrorReplyWithLogging({
5347
+ thread,
5348
+ eventId,
5349
+ postFailureEventName: "mention.handler.failure_reply_post.failed"
5350
+ });
5363
5351
  if (lifecycleError) throw lifecycleError;
5364
5352
  } finally {
5365
5353
  if (completed) {
@@ -5584,7 +5572,6 @@ function createSlackTurnRuntime(deps) {
5584
5572
  conversationId: hooks.conversationId,
5585
5573
  destination: hooks.destination,
5586
5574
  preparedState,
5587
- publishExternally: shouldPublishExternally(hooks.publishExternally),
5588
5575
  beforeFirstResponsePost: hooks.beforeFirstResponsePost,
5589
5576
  queuedMessages,
5590
5577
  ack,
@@ -5644,13 +5631,11 @@ function createSlackTurnRuntime(deps) {
5644
5631
  lifecycleError = error2;
5645
5632
  }
5646
5633
  await hooks.beforeFirstResponsePost?.();
5647
- if (shouldPublishExternally(hooks.publishExternally)) {
5648
- await postFallbackErrorReplyWithLogging({
5649
- thread,
5650
- eventId,
5651
- postFailureEventName: "subscribed_message.handler.failure_reply_post.failed"
5652
- });
5653
- }
5634
+ await postFallbackErrorReplyWithLogging({
5635
+ thread,
5636
+ eventId,
5637
+ postFailureEventName: "subscribed_message.handler.failure_reply_post.failed"
5638
+ });
5654
5639
  if (lifecycleError) throw lifecycleError;
5655
5640
  } finally {
5656
5641
  if (completed) {
@@ -6478,9 +6463,6 @@ async function loadPiMessagesForTurn(args) {
6478
6463
  }
6479
6464
  return {};
6480
6465
  }
6481
- function shouldPublishExternally2(publishExternally) {
6482
- return publishExternally !== false;
6483
- }
6484
6466
  function createSlackTurn(deps) {
6485
6467
  const turnLifecycle = getTurnLifecycle();
6486
6468
  return async function executeSlackTurn(thread, message, options) {
@@ -6624,9 +6606,6 @@ function createSlackTurn(deps) {
6624
6606
  );
6625
6607
  try {
6626
6608
  await beforeFirstResponsePost();
6627
- if (!shouldPublishExternally2(options.publishExternally)) {
6628
- return;
6629
- }
6630
6609
  if (channelId && threadTs) {
6631
6610
  await sendSlackReply({
6632
6611
  channelId,
@@ -6781,9 +6760,7 @@ function createSlackTurn(deps) {
6781
6760
  });
6782
6761
  if (configReply) {
6783
6762
  await beforeFirstResponsePost();
6784
- if (shouldPublishExternally2(options.publishExternally)) {
6785
- await thread.post(buildSlackOutputMessage(configReply.text));
6786
- }
6763
+ await thread.post(buildSlackOutputMessage(configReply.text));
6787
6764
  markConversationMessage(
6788
6765
  preparedState.conversation,
6789
6766
  preparedState.userMessageId,
@@ -6949,21 +6926,19 @@ function createSlackTurn(deps) {
6949
6926
  let slackMessageTs2 = [];
6950
6927
  await beforeFirstResponsePost();
6951
6928
  try {
6952
- if (shouldPublishExternally2(options.publishExternally)) {
6953
- if (channelId && thread.adapter.name === "slack") {
6954
- slackMessageTs2 = await sendSlackReply({
6955
- channelId,
6956
- conversationId,
6957
- replyAttribution: options.execution?.dispatch?.replyAttribution,
6958
- text,
6959
- ...threadTs ? { threadTs } : void 0
6960
- });
6961
- } else {
6962
- for (const part of splitSlackReplyText(text)) {
6963
- const postedMessageTs = (await thread.post(buildSlackOutputMessage(part))).id;
6964
- if (postedMessageTs) {
6965
- slackMessageTs2.push(postedMessageTs);
6966
- }
6929
+ if (channelId && thread.adapter.name === "slack") {
6930
+ slackMessageTs2 = await sendSlackReply({
6931
+ channelId,
6932
+ conversationId,
6933
+ replyAttribution: options.execution?.dispatch?.replyAttribution,
6934
+ text,
6935
+ ...threadTs ? { threadTs } : void 0
6936
+ });
6937
+ } else {
6938
+ for (const part of splitSlackReplyText(text)) {
6939
+ const postedMessageTs = (await thread.post(buildSlackOutputMessage(part))).id;
6940
+ if (postedMessageTs) {
6941
+ slackMessageTs2.push(postedMessageTs);
6967
6942
  }
6968
6943
  }
6969
6944
  }
@@ -7172,9 +7147,6 @@ function createSlackTurn(deps) {
7172
7147
  source,
7173
7148
  ...location ? { location } : void 0,
7174
7149
  destination,
7175
- publishExternally: shouldPublishExternally2(
7176
- options.publishExternally
7177
- ),
7178
7150
  surface: options.execution?.surface ?? "slack",
7179
7151
  dispatch: options.execution?.dispatch,
7180
7152
  toolChannelId,
@@ -7865,7 +7837,6 @@ function createSlackDispatchTurnRunner(options) {
7865
7837
  ack: hooks.ack,
7866
7838
  conversationId,
7867
7839
  destination: dispatch2.destination,
7868
- publishExternally: true,
7869
7840
  execution: {
7870
7841
  disabledFeatures: ["interactive-auth"],
7871
7842
  locationConfiguration: options.getLocationConfiguration(
@@ -8186,10 +8157,10 @@ async function resolveSlackResumeUserActor(args) {
8186
8157
  async function resolveResumeExecutionIdentity(args) {
8187
8158
  const routing = args.routingContext;
8188
8159
  if (routing?.credentialContext) {
8189
- const actor2 = routing.dispatch?.actor ?? routing.actor ?? (!("type" in routing.credentialContext.actor) ? routing.credentialContext.actor : void 0);
8160
+ const actor2 = args.actor ?? routing.dispatch?.actor ?? routing.actor ?? (!("type" in routing.credentialContext.actor) ? routing.credentialContext.actor : void 0);
8190
8161
  return actor2 ? { actor: actor2, credentialContext: routing.credentialContext } : void 0;
8191
8162
  }
8192
- let actor = routing?.actor;
8163
+ let actor = args.actor ?? routing?.actor;
8193
8164
  if (!actor && isResourceEventConversationMessage(args.userMessage)) {
8194
8165
  actor = RESOURCE_EVENT_SYSTEM_ACTOR;
8195
8166
  }
@@ -8305,6 +8276,7 @@ async function runPausedTurnInContext(payload, options, runOptions) {
8305
8276
  return false;
8306
8277
  }
8307
8278
  const identity = await resolveResumeExecutionIdentity({
8279
+ actor: activeTurn.actor,
8308
8280
  conversationId: payload.conversationId,
8309
8281
  routingContext: options.routingContext,
8310
8282
  teamId: destination.teamId,
@@ -8370,11 +8342,6 @@ async function runPausedTurnInContext(payload, options, runOptions) {
8370
8342
  destination: routingDestination,
8371
8343
  ...dispatch2 ? { dispatch: dispatch2 } : void 0,
8372
8344
  ...routing.location ? { location: routing.location } : void 0,
8373
- // Slack resume publishes unless the checkpoint opted out.
8374
- // Missing means legacy/in-flight Slack turns still post.
8375
- // TODO(dcramer): Remove this missing-as-publish fallback after no
8376
- // stored Turn checkpoint can omit publishExternally.
8377
- publishExternally: activeTurn.publishExternally !== false,
8378
8345
  source,
8379
8346
  ...surface ? { surface } : void 0,
8380
8347
  toolChannelId: destination.channelId,
@@ -8602,9 +8569,9 @@ async function commitAssistantMessage(args) {
8602
8569
  text: args.text,
8603
8570
  userMessageId: args.userMessageId
8604
8571
  });
8605
- if (args.publishedMessage?.providerMessageId) {
8572
+ if (args.deliveryResult?.providerMessageId) {
8606
8573
  markConversationMessage(args.conversation, conversationMessageId, {
8607
- slackTs: args.publishedMessage.providerMessageId
8574
+ slackTs: args.deliveryResult.providerMessageId
8608
8575
  });
8609
8576
  }
8610
8577
  try {
@@ -8614,7 +8581,7 @@ async function commitAssistantMessage(args) {
8614
8581
  conversation: args.conversation,
8615
8582
  conversationMessageId,
8616
8583
  conversationId: args.conversationId,
8617
- providerConversationBindings: args.publishedMessage?.providerConversationBindings
8584
+ providerConversationBindings: args.deliveryResult?.providerConversationBindings
8618
8585
  })
8619
8586
  );
8620
8587
  } catch (error) {
@@ -8630,18 +8597,24 @@ async function commitAssistantMessage(args) {
8630
8597
 
8631
8598
  // src/chat/task-execution/mailbox-turn.ts
8632
8599
  import {
8600
+ createResourceEventSource,
8633
8601
  createLocalSource,
8634
8602
  createWebSource
8635
8603
  } from "@sentry/junior-plugin-api";
8636
- function turnInputFactsFromConversationMessage(message) {
8604
+ function turnInputFactsFromConversationMessage(message, args) {
8637
8605
  if (isResourceEventConversationMessage(message)) {
8638
8606
  return {
8639
- actor: RESOURCE_EVENT_SYSTEM_ACTOR,
8607
+ actor: args.savedActor ?? RESOURCE_EVENT_SYSTEM_ACTOR,
8640
8608
  author: message.author ?? RESOURCE_EVENT_MESSAGE_AUTHOR,
8641
- source: "resource_event"
8609
+ // Stored Turns written before Source was saved can only restore the old
8610
+ // provider stand-in from the Conversation.
8611
+ source: args.savedSource ?? (args.location ? createWebSource(
8612
+ args.conversationId,
8613
+ args.visibility === "private" ? "private" : "public"
8614
+ ) : createLocalSource(args.conversationId))
8642
8615
  };
8643
8616
  }
8644
- const actor = createActor(message.author, {
8617
+ const actor = args.savedActor ?? createActor(message.author, {
8645
8618
  platform: "web",
8646
8619
  userId: message.author?.userId
8647
8620
  });
@@ -8651,22 +8624,20 @@ function turnInputFactsFromConversationMessage(message) {
8651
8624
  return {
8652
8625
  actor,
8653
8626
  author: message.author ?? { userId: actor.userId },
8654
- source: "web"
8627
+ source: args.savedSource?.kind === "web" ? args.savedSource : createWebSource(
8628
+ args.conversationId,
8629
+ args.visibility === "private" ? "private" : "public"
8630
+ )
8655
8631
  };
8656
8632
  }
8657
8633
  function sourceFromTurnInput(args) {
8658
- switch (args.source) {
8659
- case "resource_event":
8660
- return args.location ? createWebSource(
8661
- args.conversationId,
8662
- args.visibility === "private" ? "private" : "public"
8663
- ) : createLocalSource(args.conversationId);
8664
- case "web":
8665
- return createWebSource(
8666
- args.conversationId,
8667
- args.visibility === "private" ? "private" : "public"
8668
- );
8634
+ if (args.source.kind === "web") {
8635
+ return createWebSource(
8636
+ args.conversationId,
8637
+ args.visibility === "private" ? "private" : "public"
8638
+ );
8669
8639
  }
8640
+ return args.source;
8670
8641
  }
8671
8642
  function hasResourceEventActor(actors) {
8672
8643
  return Boolean(
@@ -8688,7 +8659,7 @@ async function getActiveConversationTurnId(conversationId) {
8688
8659
  const turnId = active[0]?.turnId;
8689
8660
  if (!turnId) return void 0;
8690
8661
  const record = await getTurnRecord(conversationId, turnId);
8691
- return record && record.surface === "api" && !record.dispatchId && (record.state === "paused" || record.state === "running") ? turnId : void 0;
8662
+ return record && (record.source?.kind === "web" || !record.source && record.surface === "api") && !record.dispatchId && (record.state === "paused" || record.state === "running") ? turnId : void 0;
8692
8663
  }
8693
8664
  async function getActiveMailboxTurnId(conversationId) {
8694
8665
  const summaries = await listTurnSummaries(conversationId);
@@ -8697,7 +8668,7 @@ async function getActiveMailboxTurnId(conversationId) {
8697
8668
  (summary) => !summary.dispatchId && (summary.state === "paused" || summary.state === "running")
8698
8669
  ).map((summary) => getTurnRecord(conversationId, summary.turnId))
8699
8670
  )).filter(
8700
- (record) => record && !record.dispatchId && (record.surface === "api" || hasResourceEventActor(record.actors)) && (record.state === "paused" || record.state === "running")
8671
+ (record) => record && !record.dispatchId && (record.source?.kind === "web" || record.source?.kind === "resource_event" || !record.source && (record.surface === "api" || hasResourceEventActor(record.actors))) && (record.state === "paused" || record.state === "running")
8701
8672
  );
8702
8673
  if (active.length > 1) {
8703
8674
  throw new Error(
@@ -8747,7 +8718,7 @@ function parseWebMessages(messages) {
8747
8718
  ...actor.userName ? { userName: actor.userName } : void 0
8748
8719
  },
8749
8720
  message: entry.message,
8750
- source: "web"
8721
+ source: createWebSource(entry.message.conversationId)
8751
8722
  };
8752
8723
  });
8753
8724
  }
@@ -8768,7 +8739,12 @@ function parseResourceEventMessages(messages) {
8768
8739
  actor: RESOURCE_EVENT_SYSTEM_ACTOR,
8769
8740
  author: RESOURCE_EVENT_MESSAGE_AUTHOR,
8770
8741
  message,
8771
- source: "resource_event"
8742
+ source: createResourceEventSource({
8743
+ eventKey: message.input.metadata.resourceEvent.eventKey,
8744
+ eventType: message.input.metadata.resourceEvent.eventType,
8745
+ identifier: message.input.metadata.resourceEvent.identifier,
8746
+ namespace: message.input.metadata.resourceEvent.namespace
8747
+ })
8772
8748
  };
8773
8749
  });
8774
8750
  }
@@ -8850,7 +8826,7 @@ async function completeCancelledConversationTurn(args) {
8850
8826
  });
8851
8827
  await args.acknowledge();
8852
8828
  }
8853
- function createConversationTurnWorker(agentRunner, publishMessage) {
8829
+ function createConversationTurnWorker(agentRunner, deliverMessage) {
8854
8830
  return async (context, resolved) => {
8855
8831
  const lifecycle = new ConversationTurnLifecycleService(
8856
8832
  getConversationEventStore()
@@ -8889,6 +8865,8 @@ function createConversationTurnWorker(agentRunner, publishMessage) {
8889
8865
  conversation,
8890
8866
  conversationId: context.conversationId
8891
8867
  });
8868
+ const savedTurn = isResume ? await getTurnRecord(context.conversationId, turnId) : void 0;
8869
+ let savedMessageIsResourceEvent = false;
8892
8870
  if (isResume) {
8893
8871
  const userMessage = getTurnUserMessage(conversation, turnId);
8894
8872
  if (!userMessage) {
@@ -8896,7 +8874,14 @@ function createConversationTurnWorker(agentRunner, publishMessage) {
8896
8874
  `Unable to locate the persisted user message for Turn "${turnId}"`
8897
8875
  );
8898
8876
  }
8899
- turnInputFacts = turnInputFactsFromConversationMessage(userMessage);
8877
+ savedMessageIsResourceEvent = isResourceEventConversationMessage(userMessage);
8878
+ turnInputFacts = turnInputFactsFromConversationMessage(userMessage, {
8879
+ conversationId: context.conversationId,
8880
+ location: storedConversation?.location,
8881
+ savedActor: savedTurn?.actor,
8882
+ savedSource: savedTurn?.source,
8883
+ visibility: storedConversation?.visibility
8884
+ });
8900
8885
  userMessageId = userMessage.id;
8901
8886
  text = userMessage.text;
8902
8887
  startedAtMs = userMessage.createdAtMs;
@@ -8910,14 +8895,13 @@ function createConversationTurnWorker(agentRunner, publishMessage) {
8910
8895
  const { actor, author } = turnInputFacts;
8911
8896
  const source = sourceFromTurnInput({
8912
8897
  conversationId: context.conversationId,
8913
- location: storedConversation?.location,
8914
8898
  source: turnInputFacts.source,
8915
8899
  visibility: storedConversation?.visibility
8916
8900
  });
8917
8901
  const webActor = actor.platform === "web" ? actor : void 0;
8918
- const savedTurn = isResume ? await getTurnRecord(context.conversationId, turnId) : void 0;
8919
- const publish = turnInputFacts.source === "resource_event" && storedConversation?.location ? savedTurn?.publishExternally ?? true : false;
8920
- const surface = publish ? "slack" : "api";
8902
+ const conversationLocation = storedConversation?.location;
8903
+ const deliverToProvider = Boolean(conversationLocation) && (source.kind === "resource_event" || savedMessageIsResourceEvent);
8904
+ const surface = deliverToProvider ? "slack" : "api";
8921
8905
  return await withLogContext(
8922
8906
  {
8923
8907
  conversationId: context.conversationId,
@@ -8977,7 +8961,7 @@ function createConversationTurnWorker(agentRunner, publishMessage) {
8977
8961
  meta: {
8978
8962
  explicitMention: true,
8979
8963
  replied: false,
8980
- ...turnInputFacts.source === "web" ? { source: "web" } : void 0
8964
+ ...source.kind === "web" ? { source: "web" } : void 0
8981
8965
  }
8982
8966
  });
8983
8967
  await persistConversationMessages({
@@ -9012,24 +8996,26 @@ function createConversationTurnWorker(agentRunner, publishMessage) {
9012
8996
  return;
9013
8997
  }
9014
8998
  failureCode = "delivery_failed";
9015
- const location = storedConversation?.location;
9016
- if (publish && (!location || !publishMessage)) {
9017
- throw new Error(
9018
- `Conversation ${context.conversationId} cannot publish its system Turn`
9019
- );
8999
+ let deliveryResult;
9000
+ if (deliverToProvider) {
9001
+ if (!conversationLocation || !deliverMessage) {
9002
+ throw new Error(
9003
+ `Conversation ${context.conversationId} cannot deliver to its Location`
9004
+ );
9005
+ }
9006
+ deliveryResult = await deliverMessage({
9007
+ conversationId: context.conversationId,
9008
+ location: conversationLocation,
9009
+ text: replyText
9010
+ });
9020
9011
  }
9021
- const publishedMessage = publish && location && publishMessage ? await publishMessage({
9022
- conversationId: context.conversationId,
9023
- location,
9024
- text: replyText
9025
- }) : void 0;
9026
9012
  await commitAssistantMessage({
9027
9013
  ...agentMessage ? { agentMessage } : void 0,
9028
9014
  conversation,
9029
9015
  conversationId: context.conversationId,
9030
- ...publishedMessage ? { publishedMessage } : void 0,
9016
+ ...deliveryResult ? { deliveryResult } : void 0,
9031
9017
  sessionId: turnId,
9032
- ...publishedMessage ? { source: "slack" } : turnInputFacts.source === "web" ? { source: "web" } : void 0,
9018
+ ...deliveryResult ? { source: "slack" } : source.kind === "web" ? { source: "web" } : void 0,
9033
9019
  text: replyText,
9034
9020
  userMessageId
9035
9021
  });
@@ -9097,11 +9083,8 @@ function createConversationTurnWorker(agentRunner, publishMessage) {
9097
9083
  // TODO(dcramer): Remove AgentRun.destination after agent and tool
9098
9084
  // code reads AgentRun.location and no Run consumer needs it.
9099
9085
  destination,
9100
- // TODO(dcramer): Remove AgentRun.publishExternally after the
9101
- // saved Turn publish choice controls optional Delivery.
9102
- publishExternally: publish,
9103
9086
  source,
9104
- ...storedConversation?.location ? { location: storedConversation.location } : void 0,
9087
+ ...conversationLocation ? { location: conversationLocation } : void 0,
9105
9088
  surface,
9106
9089
  ...stopSignal ? { signal: stopSignal } : void 0,
9107
9090
  ...webActor ? {
@@ -9175,7 +9158,6 @@ function createConversationTurnWorker(agentRunner, publishMessage) {
9175
9158
  // TODO(dcramer): Remove checkpoint Destination after resume
9176
9159
  // reads the Conversation Location.
9177
9160
  destination,
9178
- publishExternally: publish,
9179
9161
  source,
9180
9162
  actor,
9181
9163
  surface
@@ -9304,11 +9286,11 @@ function createConversationTurnWorker(agentRunner, publishMessage) {
9304
9286
  }
9305
9287
 
9306
9288
  // src/chat/providers/slack/system-turn.ts
9307
- function createSlackSystemTurnPublisher(args) {
9289
+ function createSlackSystemTurnDelivery(args) {
9308
9290
  return async ({ conversationId, location, text }) => {
9309
9291
  if (location.provider !== "slack") {
9310
9292
  throw new Error(
9311
- `Slack system Turn cannot publish to ${location.provider} Location`
9293
+ `Slack system Turn cannot deliver to ${location.provider} Location`
9312
9294
  );
9313
9295
  }
9314
9296
  let messageIds;
@@ -9405,7 +9387,7 @@ function createConversationWork(options) {
9405
9387
  const invocationWorker = createAgentInvocationWorker(options.agentRunner);
9406
9388
  const conversationTurnWorker = createConversationTurnWorker(
9407
9389
  options.agentRunner,
9408
- createSlackSystemTurnPublisher({
9390
+ createSlackSystemTurnDelivery({
9409
9391
  getSlackAdapter: options.getSlackAdapter,
9410
9392
  state: options.state
9411
9393
  })