@sentry/junior 0.183.0 → 0.185.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 (122) hide show
  1. package/dist/{agent-hooks-SNRBZYAU.js → agent-hooks-NGZQLL5O.js} +13 -11
  2. package/dist/api/acp/auth.d.ts +46 -0
  3. package/dist/api/acp/authorization-page.d.ts +11 -0
  4. package/dist/api/acp/conversations.d.ts +70 -0
  5. package/dist/api/acp/errors.d.ts +6 -0
  6. package/dist/api/acp/route.d.ts +16 -0
  7. package/dist/api/acp/schema.d.ts +115 -0
  8. package/dist/api/acp/sleep.d.ts +2 -0
  9. package/dist/api/acp/state.d.ts +22 -0
  10. package/dist/api/acp/transport.d.ts +113 -0
  11. package/dist/api/code/overview.d.ts +39 -0
  12. package/dist/api/locations/detail.d.ts +1 -1
  13. package/dist/api/people/code.d.ts +22 -0
  14. package/dist/api/schema/code.d.ts +46 -0
  15. package/dist/api/schema/conversation.d.ts +100 -20
  16. package/dist/api/schema/location.d.ts +1 -1
  17. package/dist/api/schema/person.d.ts +1 -1
  18. package/dist/api/schema.d.ts +4 -4
  19. package/dist/api/schema.js +12 -1
  20. package/dist/api.js +358 -76
  21. package/dist/app.d.ts +0 -4
  22. package/dist/app.js +2450 -493
  23. package/dist/{catalog-runtime-3I3JOIIH.js → catalog-runtime-AAEAO2RL.js} +4 -4
  24. package/dist/chat/api-turns/accepted-reply.d.ts +11 -0
  25. package/dist/chat/api-turns/cancellation.d.ts +3 -5
  26. package/dist/chat/api-turns/work.d.ts +4 -9
  27. package/dist/chat/app/conversation-work.d.ts +1 -1
  28. package/dist/chat/app/factory.d.ts +4 -0
  29. package/dist/chat/app/services.d.ts +4 -3
  30. package/dist/chat/conversations/history.d.ts +83 -9
  31. package/dist/chat/conversations/turn-lifecycle.d.ts +4 -3
  32. package/dist/chat/providers/slack/input.d.ts +32 -0
  33. package/dist/chat/{runtime → providers/slack}/processing-reaction.d.ts +6 -8
  34. package/dist/chat/{runtime/slack-resume.d.ts → providers/slack/resume.d.ts} +16 -19
  35. package/dist/chat/providers/slack/runtime.d.ts +1 -10
  36. package/dist/chat/providers/slack/turn.d.ts +11 -24
  37. package/dist/chat/resource-events/store.d.ts +1 -1
  38. package/dist/chat/resource-events/tool-support.d.ts +0 -5
  39. package/dist/chat/runtime/turn-execution.d.ts +7 -2
  40. package/dist/chat/sandbox/egress/credentials.d.ts +3 -3
  41. package/dist/chat/sandbox/egress/session.d.ts +5 -6
  42. package/dist/chat/scheduled-tasks/tool-support.d.ts +5 -5
  43. package/dist/chat/scheduled-tasks/tools/create.d.ts +2 -2
  44. package/dist/chat/scheduled-tasks/tools/delete.d.ts +2 -2
  45. package/dist/chat/scheduled-tasks/tools/list.d.ts +2 -2
  46. package/dist/chat/scheduled-tasks/tools/run-now.d.ts +2 -2
  47. package/dist/chat/scheduled-tasks/tools/update.d.ts +2 -2
  48. package/dist/chat/scheduled-tasks/types.d.ts +1 -1
  49. package/dist/chat/services/provider-retry.d.ts +2 -0
  50. package/dist/chat/services/turn-failure-response.d.ts +4 -0
  51. package/dist/chat/task-execution/paused-turn.d.ts +0 -2
  52. package/dist/chat/task-execution/state.d.ts +2 -2
  53. package/dist/chat/task-execution/store.d.ts +1 -1
  54. package/dist/chat/task-execution/turn-wake.d.ts +12 -0
  55. package/dist/chat/tool-support/action-review.d.ts +1 -1
  56. package/dist/chat/tools/resource-events.d.ts +1 -1
  57. package/dist/chat/tools/search-conversation-events.d.ts +1 -1
  58. package/dist/chat/tools/types.d.ts +1 -1
  59. package/dist/chat/tools/watch-resource-events.d.ts +2 -2
  60. package/dist/{chunk-2EPYYVJC.js → chunk-4HA36IWS.js} +9 -94
  61. package/dist/{chunk-WVIA7V3M.js → chunk-4K25ODAO.js} +27 -1
  62. package/dist/{chunk-V64JCZUV.js → chunk-4S47VHJR.js} +3 -3
  63. package/dist/{chunk-QZV76CM4.js → chunk-6DOAUXLD.js} +231 -198
  64. package/dist/{chunk-M3QYTBQ6.js → chunk-6Q7YZLCL.js} +2 -1
  65. package/dist/{chunk-W46NIB5H.js → chunk-7GAP2XG4.js} +2 -3
  66. package/dist/{chunk-EENQGEIP.js → chunk-7MHNIGHP.js} +1 -1
  67. package/dist/{chunk-AX3UDIMA.js → chunk-ABAX75GG.js} +10 -384
  68. package/dist/{chunk-KTXOGLNE.js → chunk-ATUWN6Z3.js} +2 -2
  69. package/dist/{chunk-3HJ4F4L7.js → chunk-C6TS47CQ.js} +4 -4
  70. package/dist/chunk-D4YV5TDV.js +45 -0
  71. package/dist/{chunk-HUK5XIZL.js → chunk-D63IUQQE.js} +4 -4
  72. package/dist/{chunk-WOKJRLM2.js → chunk-DAPC2HTM.js} +24 -6
  73. package/dist/{chunk-2ADFGSUS.js → chunk-EIJCPJOY.js} +1 -1
  74. package/dist/{chunk-X52ESOBP.js → chunk-EJYP3NQ4.js} +4 -4
  75. package/dist/{chunk-35PM4YY5.js → chunk-EWEH2PJW.js} +6 -6
  76. package/dist/{chunk-W5JMPEBO.js → chunk-FFHXG2FX.js} +13 -11
  77. package/dist/{chunk-FJMTMGBC.js → chunk-FTVMXDNN.js} +1 -1
  78. package/dist/chunk-GFBR4S3Q.js +406 -0
  79. package/dist/{chunk-E3OBGRHN.js → chunk-GJTIZQGJ.js} +1 -1
  80. package/dist/{chunk-IO6KFXYE.js → chunk-HJPC32TQ.js} +12 -50
  81. package/dist/{chunk-RF6J3DIO.js → chunk-INQHUE72.js} +84 -1
  82. package/dist/{chunk-LMNMMESF.js → chunk-LRI5IRGY.js} +19 -44
  83. package/dist/{chunk-6UXDTPEN.js → chunk-LVK4WJKM.js} +1 -1
  84. package/dist/{chunk-AYW7J6K4.js → chunk-MWOH6CIK.js} +178 -148
  85. package/dist/{chunk-LZBPGX5A.js → chunk-OMQ2J6F6.js} +1 -1
  86. package/dist/{chunk-G2B2XZQW.js → chunk-PNYJOEVV.js} +1 -1
  87. package/dist/{chunk-37IQ6DGU.js → chunk-QCT4226Q.js} +3 -3
  88. package/dist/{chunk-R767Y7QV.js → chunk-QZKHHG3B.js} +34 -8
  89. package/dist/{chunk-VOV3SCM3.js → chunk-TVVAMOLS.js} +2 -2
  90. package/dist/{chunk-56XONJPF.js → chunk-U4CTAVWN.js} +1 -1
  91. package/dist/{chunk-4WGFWHWP.js → chunk-UUULGCKK.js} +1 -1
  92. package/dist/{chunk-AHMWPFIW.js → chunk-VH4IU3UC.js} +928 -984
  93. package/dist/chunk-W7GCLNIV.js +58 -0
  94. package/dist/{chunk-24OJZ5OU.js → chunk-WLKWN4CD.js} +22 -12
  95. package/dist/{chunk-T5MTGX2E.js → chunk-X2SS6BF7.js} +201 -210
  96. package/dist/{chunk-SQHFVIMZ.js → chunk-X7NCJQAA.js} +1 -1
  97. package/dist/{chunk-PLZT45VC.js → chunk-Y5G23T2D.js} +5 -5
  98. package/dist/{chunk-3L7CWDQQ.js → chunk-ZIF2S464.js} +1 -1
  99. package/dist/{chunk-QI5JW5AG.js → chunk-ZKKGFUWM.js} +6 -6
  100. package/dist/cli/chat.js +35 -33
  101. package/dist/cli/check.js +5 -5
  102. package/dist/cli/plugins.js +14 -12
  103. package/dist/cli/snapshot-create.js +10 -9
  104. package/dist/cli/upgrade.js +7 -6
  105. package/dist/{db-K2VMNLHQ.js → db-TRJ77FAU.js} +8 -6
  106. package/dist/instrumentation.js +3 -3
  107. package/dist/nitro.js +7 -6
  108. package/dist/{oauth-callback-server-DZZMTKSS.js → oauth-callback-server-XD5SV3MS.js} +30 -27
  109. package/dist/{runner-IIAKWDXI.js → runner-KFX7NG6D.js} +24 -19
  110. package/dist/{skills-EXIQ7BP5.js → skills-J2AH26CW.js} +5 -5
  111. package/dist/spawn-VU3CSRI6.js +41 -0
  112. package/dist/task-runner-5JG3VIIY.js +34 -0
  113. package/dist/{validation-XUGIWBJF.js → validation-O5J4VOPF.js} +5 -5
  114. package/dist/version.js +1 -1
  115. package/dist/{work-G4RLJ634.js → work-ECPQTG3U.js} +24 -19
  116. package/dist/worker-RS3DXUDO.js +24 -0
  117. package/package.json +5 -6
  118. package/dist/app-adapter.d.ts +0 -85
  119. package/dist/chat/api-turns/adapter-conversations.d.ts +0 -15
  120. package/dist/spawn-ZR6OOEAN.js +0 -37
  121. package/dist/task-runner-C52HYCVD.js +0 -32
  122. package/dist/worker-R2JEHK67.js +0 -22
@@ -4,7 +4,11 @@ import {
4
4
  import {
5
5
  buildSentryConversationUrl,
6
6
  deleteWebAuthorization
7
- } from "./chunk-4WGFWHWP.js";
7
+ } from "./chunk-UUULGCKK.js";
8
+ import {
9
+ AgentRunError,
10
+ executeTurn
11
+ } from "./chunk-W7GCLNIV.js";
8
12
  import {
9
13
  buildDeliveredTurnStatePatch,
10
14
  finalizeFailedTurnReplyWithEvent,
@@ -15,14 +19,14 @@ import {
15
19
  getTurnUserSlackMessageTs,
16
20
  persistAuthPauseTurnState,
17
21
  requireTurnFailureEventId
18
- } from "./chunk-WOKJRLM2.js";
22
+ } from "./chunk-DAPC2HTM.js";
19
23
  import {
20
24
  resolveTurnSessionRouting,
21
25
  scheduleSessionCompletedPluginTasks
22
- } from "./chunk-W5JMPEBO.js";
26
+ } from "./chunk-FFHXG2FX.js";
23
27
  import {
24
28
  ConversationTurnLifecycleService
25
- } from "./chunk-M3QYTBQ6.js";
29
+ } from "./chunk-6Q7YZLCL.js";
26
30
  import {
27
31
  coerceThreadConversationState,
28
32
  configValueSchema,
@@ -30,7 +34,7 @@ import {
30
34
  getPersistedSandboxState,
31
35
  getPersistedThreadState,
32
36
  persistThreadStateById
33
- } from "./chunk-PLZT45VC.js";
37
+ } from "./chunk-Y5G23T2D.js";
34
38
  import {
35
39
  createUserTokenStore,
36
40
  deleteMcpAuthSession,
@@ -39,12 +43,8 @@ import {
39
43
  getMcpProviderErrorAttributes,
40
44
  getMcpStoredOAuthCredentials,
41
45
  lookupSlackUserProfile,
42
- resolvePluginOAuthAccount,
43
- runAgentWithTimeout
44
- } from "./chunk-2EPYYVJC.js";
45
- import {
46
- RetryableDeliveryError
47
- } from "./chunk-RF6J3DIO.js";
46
+ resolvePluginOAuthAccount
47
+ } from "./chunk-4HA36IWS.js";
48
48
  import {
49
49
  addReactionToMessage,
50
50
  escapeSlackMrkdwnText,
@@ -57,17 +57,20 @@ import {
57
57
  removeReactionFromMessage,
58
58
  resolveBaseUrl,
59
59
  truncateStatusText
60
- } from "./chunk-QI5JW5AG.js";
60
+ } from "./chunk-ZKKGFUWM.js";
61
61
  import {
62
62
  parseSlackThreadId,
63
63
  readSlackRawMessageContext,
64
64
  resolveSlackChannelIdFromMessage,
65
65
  resolveSlackChannelIdFromThreadId
66
- } from "./chunk-SQHFVIMZ.js";
66
+ } from "./chunk-X7NCJQAA.js";
67
+ import {
68
+ RetryableDeliveryError
69
+ } from "./chunk-INQHUE72.js";
67
70
  import {
68
71
  ensureConversationWake,
69
72
  requestConversationWork
70
- } from "./chunk-HUK5XIZL.js";
73
+ } from "./chunk-D63IUQQE.js";
71
74
  import {
72
75
  CooperativeTurnYieldError,
73
76
  clearPendingAuth,
@@ -76,7 +79,7 @@ import {
76
79
  isCooperativeTurnYieldError,
77
80
  isPendingAuthLatestRequest,
78
81
  markTurnFailed
79
- } from "./chunk-56XONJPF.js";
82
+ } from "./chunk-U4CTAVWN.js";
80
83
  import {
81
84
  TurnSliceLimitExceededError,
82
85
  abandonTurnRecord,
@@ -96,13 +99,13 @@ import {
96
99
  recordTurnSummary,
97
100
  saveTurnCheckpoint,
98
101
  turnHasReply
99
- } from "./chunk-24OJZ5OU.js";
102
+ } from "./chunk-WLKWN4CD.js";
100
103
  import {
101
104
  getVercelConversationWorkQueue
102
105
  } from "./chunk-DKIJ2RP5.js";
103
106
  import {
104
107
  getTurnRequestDeadline
105
- } from "./chunk-FJMTMGBC.js";
108
+ } from "./chunk-FTVMXDNN.js";
106
109
  import {
107
110
  SlackActionError,
108
111
  getDashboardConversationLink,
@@ -111,37 +114,39 @@ import {
111
114
  getSlackClient,
112
115
  isDmChannel,
113
116
  normalizeSlackConversationId
114
- } from "./chunk-AHMWPFIW.js";
117
+ } from "./chunk-VH4IU3UC.js";
115
118
  import {
116
119
  getConversationEventStore,
117
120
  getSqlExecutor,
118
121
  requireSlackDestination,
119
122
  upsertIdentity,
120
123
  upsertLinkedIdentity
121
- } from "./chunk-AX3UDIMA.js";
124
+ } from "./chunk-ABAX75GG.js";
122
125
  import {
123
126
  acquireActiveLock,
124
127
  getStateAdapter
125
- } from "./chunk-G2B2XZQW.js";
128
+ } from "./chunk-PNYJOEVV.js";
126
129
  import {
127
130
  botConfig,
128
- defaultModelId,
129
131
  escapeXml,
130
132
  getChatConfig,
131
133
  getRuntimeMetadata,
132
134
  normalizeSlackEmojiName
133
- } from "./chunk-LMNMMESF.js";
135
+ } from "./chunk-LRI5IRGY.js";
136
+ import {
137
+ defaultModelId
138
+ } from "./chunk-D4YV5TDV.js";
134
139
  import {
135
140
  discoverSkills
136
- } from "./chunk-KTXOGLNE.js";
141
+ } from "./chunk-ATUWN6Z3.js";
137
142
  import {
138
143
  pluginCatalogRuntime
139
- } from "./chunk-E3OBGRHN.js";
144
+ } from "./chunk-GJTIZQGJ.js";
140
145
  import {
141
146
  buildOAuthTokenRequest,
142
147
  hasRequiredOAuthScope,
143
148
  parseOAuthTokenResponse
144
- } from "./chunk-EENQGEIP.js";
149
+ } from "./chunk-7MHNIGHP.js";
145
150
  import {
146
151
  createSlackResumeActor,
147
152
  isUserActor,
@@ -160,7 +165,7 @@ import {
160
165
  setTags,
161
166
  toOptionalString,
162
167
  withLogContext
163
- } from "./chunk-LZBPGX5A.js";
168
+ } from "./chunk-OMQ2J6F6.js";
164
169
 
165
170
  // src/chat/slack/assistant-thread/status-render.ts
166
171
  var DEFAULT_STATUS_CONTEXTS = {
@@ -789,6 +794,7 @@ async function sendSlackReply(args) {
789
794
  replyAttribution: args.replyAttribution
790
795
  });
791
796
  const messageTs = [];
797
+ let threadTs = args.threadTs;
792
798
  for (const [index, text] of chunks.entries()) {
793
799
  const isFinalChunk = index === chunks.length - 1;
794
800
  const blocks = buildSlackReplyBlocks(
@@ -800,12 +806,13 @@ async function sendSlackReply(args) {
800
806
  ${escapeSlackMrkdwnText(formatReplyAttribution(args.replyAttribution))}` : text;
801
807
  const response = await postSlackMessage({
802
808
  channelId: args.channelId,
803
- threadTs: args.threadTs,
809
+ threadTs,
804
810
  text: fallbackText,
805
811
  ...blocks ? { blocks } : void 0
806
812
  });
807
813
  if (response.ts) {
808
814
  messageTs.push(response.ts);
815
+ threadTs ??= response.ts;
809
816
  }
810
817
  }
811
818
  return messageTs;
@@ -968,7 +975,7 @@ function getMessageTs(message) {
968
975
  return void 0;
969
976
  }
970
977
 
971
- // src/chat/runtime/processing-reaction.ts
978
+ // src/chat/providers/slack/processing-reaction.ts
972
979
  var noProcessingReaction = {
973
980
  complete: async () => void 0,
974
981
  keep: () => void 0,
@@ -980,7 +987,7 @@ function isProcessingReactionEmoji(value) {
980
987
  function shouldKeepProcessingReactionForToolInvocation(input) {
981
988
  return input.toolName === "addReaction" && isProcessingReactionEmoji(input.params.emoji);
982
989
  }
983
- async function startSlackProcessingReaction(args) {
990
+ async function startProcessingReaction(args) {
984
991
  if (args.message.author.isMe) {
985
992
  return noProcessingReaction;
986
993
  }
@@ -989,13 +996,12 @@ async function startSlackProcessingReaction(args) {
989
996
  if (!channelId || !messageTs) {
990
997
  return noProcessingReaction;
991
998
  }
992
- return startSlackProcessingReactionForMessage({
999
+ return startProcessingReactionForMessage({
993
1000
  channelId,
994
- timestamp: messageTs,
995
- logException: args.logException
1001
+ timestamp: messageTs
996
1002
  });
997
1003
  }
998
- async function startSlackProcessingReactionForMessage(args) {
1004
+ async function startProcessingReactionForMessage(args) {
999
1005
  try {
1000
1006
  await addReactionToMessage({
1001
1007
  channelId: args.channelId,
@@ -1003,7 +1009,7 @@ async function startSlackProcessingReactionForMessage(args) {
1003
1009
  emoji: getChatConfig().slack.processingReactionEmoji
1004
1010
  });
1005
1011
  } catch (error) {
1006
- args.logException(error, "slack.processing.reaction_add.failed", {
1012
+ logException(error, "slack.processing.reaction_add.failed", {
1007
1013
  "app.slack.action": "reactions.add",
1008
1014
  "messaging.message.id": args.timestamp,
1009
1015
  ...getSlackErrorObservabilityAttributes(error)
@@ -1023,7 +1029,7 @@ async function startSlackProcessingReactionForMessage(args) {
1023
1029
  });
1024
1030
  return true;
1025
1031
  } catch (error) {
1026
- args.logException(error, "slack.processing.reaction_remove.failed", {
1032
+ logException(error, "slack.processing.reaction_remove.failed", {
1027
1033
  "app.slack.action": "reactions.remove",
1028
1034
  "messaging.message.id": args.timestamp,
1029
1035
  ...getSlackErrorObservabilityAttributes(error)
@@ -1045,7 +1051,7 @@ async function startSlackProcessingReactionForMessage(args) {
1045
1051
  emoji: getChatConfig().slack.completedReactionEmoji
1046
1052
  });
1047
1053
  } catch (error) {
1048
- args.logException(error, "slack.processing.reaction_complete.failed", {
1054
+ logException(error, "slack.processing.reaction_complete.failed", {
1049
1055
  "app.slack.action": "reactions.add",
1050
1056
  "messaging.message.id": args.timestamp,
1051
1057
  ...getSlackErrorObservabilityAttributes(error)
@@ -1084,11 +1090,8 @@ function buildAuthPauseResponse(slackUserId, providerDisplayName, requestText) {
1084
1090
  I sent you a link.`;
1085
1091
  }
1086
1092
 
1087
- // src/chat/runtime/slack-resume.ts
1088
- function resolveReplyTimeoutMs(explicitTimeoutMs) {
1089
- if (typeof explicitTimeoutMs === "number" && explicitTimeoutMs > 0) {
1090
- return explicitTimeoutMs;
1091
- }
1093
+ // src/chat/providers/slack/resume.ts
1094
+ function resolveReplyTimeoutMs() {
1092
1095
  const raw = process.env.EVAL_AGENT_REPLY_TIMEOUT_MS?.trim();
1093
1096
  if (!raw) {
1094
1097
  return void 0;
@@ -1128,7 +1131,7 @@ function createReadOnlyConfigService(rawValues) {
1128
1131
  return {
1129
1132
  get: async (key) => entries.find((entry) => entry.key === key),
1130
1133
  set: async () => {
1131
- throw new Error("Read-only configuration in resumed context");
1134
+ throw new Error("Configuration is read-only for a resumed Run");
1132
1135
  },
1133
1136
  unset: async () => false,
1134
1137
  list: async ({ prefix } = {}) => entries.filter((entry) => !prefix || entry.key.startsWith(prefix)),
@@ -1146,7 +1149,7 @@ function createReadOnlyConfigService(rawValues) {
1146
1149
  }
1147
1150
  var ResumeTurnBusyError = class extends Error {
1148
1151
  constructor(lockKey) {
1149
- super(`A turn already owns resume lock "${lockKey}"`);
1152
+ super(`Another worker is already resuming Slack Turn "${lockKey}"`);
1150
1153
  this.name = "ResumeTurnBusyError";
1151
1154
  }
1152
1155
  };
@@ -1154,7 +1157,7 @@ function getDefaultLockKey(channelId, threadTs) {
1154
1157
  return threadTs ? `slack:${channelId}:${threadTs}` : `slack:${channelId}`;
1155
1158
  }
1156
1159
  function getResumeLogContext(args, lockKey) {
1157
- const actor = args.replyContext?.actor;
1160
+ const actor = args.run?.actor;
1158
1161
  return {
1159
1162
  conversationId: args.conversationId,
1160
1163
  messageConversationId: lockKey,
@@ -1177,7 +1180,7 @@ async function handleResumeFailure(args) {
1177
1180
  const eventId = requireTurnFailureEventId(capturedEventId, args.eventName);
1178
1181
  let failureStatePersistError;
1179
1182
  try {
1180
- await args.resumeArgs.onFailure?.(args.error);
1183
+ await args.resume.onFailure?.(args.error);
1181
1184
  } catch (persistError) {
1182
1185
  const persistEventId = logException(
1183
1186
  persistError,
@@ -1186,8 +1189,8 @@ async function handleResumeFailure(args) {
1186
1189
  );
1187
1190
  try {
1188
1191
  await args.turnLifecycle.fail({
1189
- conversationId: args.resumeArgs.conversationId,
1190
- turnId: args.resumeArgs.turnId,
1192
+ conversationId: args.resume.conversationId,
1193
+ turnId: args.resume.turnId,
1191
1194
  createdAtMs: Date.now(),
1192
1195
  failureCode: "persistence_failed",
1193
1196
  ...persistEventId ? { eventId: persistEventId } : void 0
@@ -1203,8 +1206,8 @@ async function handleResumeFailure(args) {
1203
1206
  }
1204
1207
  try {
1205
1208
  await postResumeFailureReply({
1206
- channelId: args.resumeArgs.channelId,
1207
- threadTs: args.resumeArgs.threadTs,
1209
+ channelId: args.resume.channelId,
1210
+ threadTs: args.resume.threadTs,
1208
1211
  eventId,
1209
1212
  error: args.error
1210
1213
  });
@@ -1216,8 +1219,8 @@ async function handleResumeFailure(args) {
1216
1219
  );
1217
1220
  try {
1218
1221
  await args.turnLifecycle.fail({
1219
- conversationId: args.resumeArgs.conversationId,
1220
- turnId: args.resumeArgs.turnId,
1222
+ conversationId: args.resume.conversationId,
1223
+ turnId: args.resume.turnId,
1221
1224
  createdAtMs: Date.now(),
1222
1225
  failureCode: "delivery_failed",
1223
1226
  ...deliveryEventId ? { eventId: deliveryEventId } : void 0
@@ -1235,35 +1238,35 @@ async function handleResumeFailure(args) {
1235
1238
  throw failureStatePersistError;
1236
1239
  }
1237
1240
  await args.turnLifecycle.fail({
1238
- conversationId: args.resumeArgs.conversationId,
1239
- turnId: args.resumeArgs.turnId,
1241
+ conversationId: args.resume.conversationId,
1242
+ turnId: args.resume.turnId,
1240
1243
  createdAtMs: Date.now(),
1241
1244
  failureCode: args.failureCode,
1242
1245
  eventId
1243
1246
  });
1244
1247
  }
1245
- function createResumeReplyContext(args, statusSession, delivery) {
1246
- const replyContext = args.replyContext;
1247
- if (!replyContext) {
1248
- throw new TypeError("Slack resume requires a reply context");
1248
+ function buildResumedRun(args, statusSession, delivery) {
1249
+ const savedRun = args.run;
1250
+ if (!savedRun) {
1251
+ throw new TypeError("Slack resume requires a saved Run");
1249
1252
  }
1250
- if (!replyContext.source) {
1251
- throw new TypeError("Slack resume requires a reply context source");
1253
+ if (!savedRun.source) {
1254
+ throw new TypeError("Slack resume requires a Run Source");
1252
1255
  }
1253
- const source = replyContext.source;
1254
- if (replyContext.destination.platform !== "slack") {
1255
- throw new TypeError("Slack resume requires a Slack destination");
1256
+ const source = savedRun.source;
1257
+ if (savedRun.destination.platform !== "slack") {
1258
+ throw new TypeError("Slack resume requires a Slack Destination");
1256
1259
  }
1257
1260
  const requestDeadline = getTurnRequestDeadline();
1258
1261
  const threadId = args.lockKey ?? getDefaultLockKey(args.channelId, args.threadTs);
1259
- const persistedLocationConfiguration = replyContext.environment?.locationConfiguration ?? (replyContext.environment?.configuration ? createReadOnlyConfigService(replyContext.environment.configuration) : void 0);
1260
- const priorOnEvent = replyContext.onEvent;
1262
+ const persistedLocationConfiguration = savedRun.environment?.locationConfiguration ?? (savedRun.environment?.configuration ? createReadOnlyConfigService(savedRun.environment.configuration) : void 0);
1263
+ const priorOnEvent = savedRun.onEvent;
1261
1264
  return {
1262
- ...replyContext,
1265
+ ...savedRun,
1263
1266
  conversationId: args.conversationId,
1264
1267
  turnId: args.turnId,
1265
1268
  instruction: {
1266
- ...replyContext.instruction ?? { text: args.messageText },
1269
+ ...savedRun.instruction ?? { text: args.messageText },
1267
1270
  text: args.messageText
1268
1271
  },
1269
1272
  source: source.platform === "slack" ? {
@@ -1271,9 +1274,9 @@ function createResumeReplyContext(args, statusSession, delivery) {
1271
1274
  channelId: args.channelId,
1272
1275
  ...args.threadTs ? { threadTs: args.threadTs } : void 0
1273
1276
  } : source,
1274
- deadlineAtMs: replyContext.deadlineAtMs ?? requestDeadline?.deadlineAtMs,
1277
+ deadlineAtMs: savedRun.deadlineAtMs ?? requestDeadline?.deadlineAtMs,
1275
1278
  environment: {
1276
- ...replyContext.environment,
1279
+ ...savedRun.environment,
1277
1280
  locationConfiguration: persistedLocationConfiguration
1278
1281
  },
1279
1282
  onEvent: async (event) => {
@@ -1284,12 +1287,12 @@ function createResumeReplyContext(args, statusSession, delivery) {
1284
1287
  },
1285
1288
  delivery,
1286
1289
  durability: {
1287
- ...replyContext.durability,
1290
+ ...savedRun.durability,
1288
1291
  onSandboxRefChanged: async (sandboxRef) => {
1289
1292
  await persistThreadStateById(threadId, {
1290
1293
  sandboxRef
1291
1294
  });
1292
- await replyContext.durability?.onSandboxRefChanged?.(sandboxRef);
1295
+ await savedRun.durability?.onSandboxRefChanged?.(sandboxRef);
1293
1296
  }
1294
1297
  }
1295
1298
  };
@@ -1319,8 +1322,11 @@ async function resumeSlackTurnInContext(args) {
1319
1322
  let deferredFailureHandler;
1320
1323
  let runResultHandled = false;
1321
1324
  let assistantMessageDelivered = false;
1325
+ let shouldScheduleCompletedPluginTasks = false;
1322
1326
  let postDeliveryCommitError;
1323
- const turnLifecycle = args.turnLifecycle ?? new ConversationTurnLifecycleService(getConversationEventStore());
1327
+ const turnLifecycle = new ConversationTurnLifecycleService(
1328
+ getConversationEventStore()
1329
+ );
1324
1330
  let failureCode = "agent_run_failed";
1325
1331
  let runArgs = args;
1326
1332
  try {
@@ -1332,36 +1338,33 @@ async function resumeSlackTurnInContext(args) {
1332
1338
  runArgs = { ...args, ...preparedArgs };
1333
1339
  }
1334
1340
  setTags(getResumeLogContext(runArgs, lockKey));
1335
- const activeReplyContext = runArgs.replyContext;
1336
- if (!activeReplyContext) {
1337
- throw new Error("Resumed turn requires replyContext");
1341
+ const savedRun = runArgs.run;
1342
+ if (!savedRun) {
1343
+ throw new Error("Resumed Turn requires a saved Run");
1338
1344
  }
1339
- const credentialContext = activeReplyContext.credentialContext;
1345
+ const credentialContext = savedRun.credentialContext;
1340
1346
  if (!credentialContext) {
1341
- throw new Error("Resumed turn requires replyContext.credentialContext");
1347
+ throw new Error("Resumed Run requires a credential context");
1342
1348
  }
1343
- const routingActor = activeReplyContext.actor;
1349
+ const routingActor = savedRun.actor;
1344
1350
  let resumeActor;
1345
1351
  if ("type" in credentialContext.actor) {
1346
1352
  if (!isUserActor(routingActor) || credentialContext.actor.userId !== routingActor.userId) {
1347
- throw new Error(
1348
- "Resumed turn credential actor must match replyContext.actor.userId"
1349
- );
1353
+ throw new Error("Resumed Run credential actor must match its Actor");
1350
1354
  }
1351
1355
  resumeActor = routingActor;
1352
1356
  } else {
1353
1357
  if (routingActor && (routingActor.platform !== "system" || routingActor.name !== credentialContext.actor.name)) {
1354
1358
  throw new Error(
1355
- "Resumed turn system credential actor must match replyContext.actor"
1359
+ "Resumed Run system credential actor must match its Actor"
1356
1360
  );
1357
1361
  }
1358
1362
  resumeActor = credentialContext.actor;
1359
1363
  }
1360
1364
  if (runArgs.messageTs) {
1361
- processingReaction = await startSlackProcessingReactionForMessage({
1365
+ processingReaction = await startProcessingReactionForMessage({
1362
1366
  channelId: runArgs.channelId,
1363
- timestamp: runArgs.messageTs,
1364
- logException
1367
+ timestamp: runArgs.messageTs
1365
1368
  });
1366
1369
  }
1367
1370
  if (runArgs.initialText) {
@@ -1415,11 +1418,11 @@ async function resumeSlackTurnInContext(args) {
1415
1418
  const deliveryState2 = await getDeliveryConversation();
1416
1419
  let slackMessageTs = [];
1417
1420
  try {
1418
- if (runArgs.replyContext?.publishExternally !== false) {
1421
+ if (runArgs.run?.publishExternally !== false) {
1419
1422
  slackMessageTs = await sendSlackReply({
1420
1423
  channelId: runArgs.channelId,
1421
1424
  conversationId: runArgs.conversationId,
1422
- replyAttribution: runArgs.replyContext?.dispatch?.replyAttribution,
1425
+ replyAttribution: runArgs.run?.dispatch?.replyAttribution,
1423
1426
  text,
1424
1427
  threadTs: runArgs.threadTs
1425
1428
  });
@@ -1446,7 +1449,7 @@ async function resumeSlackTurnInContext(args) {
1446
1449
  });
1447
1450
  }
1448
1451
  try {
1449
- const destination = runArgs.replyContext?.destination;
1452
+ const destination = runArgs.run?.destination;
1450
1453
  const providerConversationIds = runArgs.threadTs ? [runArgs.threadTs] : slackMessageTs;
1451
1454
  await persistWithRetry(
1452
1455
  () => commitAcceptedReply({
@@ -1454,7 +1457,7 @@ async function resumeSlackTurnInContext(args) {
1454
1457
  conversation: deliveryState2.conversation,
1455
1458
  conversationMessageId: recordedMessageId,
1456
1459
  conversationId,
1457
- ...runArgs.replyContext?.dispatch && destination?.platform === "slack" && providerConversationIds.length > 0 ? {
1460
+ ...runArgs.run?.dispatch && destination?.platform === "slack" && providerConversationIds.length > 0 ? {
1458
1461
  providerConversationBindings: providerConversationIds.map(
1459
1462
  (providerConversationId) => ({
1460
1463
  provider: "slack",
@@ -1473,22 +1476,21 @@ async function resumeSlackTurnInContext(args) {
1473
1476
  { "error.type": error instanceof Error ? error.name : typeof error }
1474
1477
  );
1475
1478
  }
1476
- const replyContext2 = runArgs.replyContext;
1477
- const dispatchId = replyContext2?.dispatch?.id;
1478
- if (messageTs && dispatchId && replyContext2) {
1479
+ const dispatchId = savedRun.dispatch?.id;
1480
+ if (messageTs && dispatchId) {
1479
1481
  try {
1480
1482
  await persistWithRetry(
1481
1483
  () => recordTurnSummary({
1482
1484
  conversationId: runArgs.conversationId,
1483
- destination: replyContext2.destination,
1484
- destinationVisibility: replyContext2.destinationVisibility,
1485
+ destination: savedRun.destination,
1486
+ destinationVisibility: savedRun.destinationVisibility,
1485
1487
  dispatchId,
1486
1488
  resultMessageId: messageTs,
1487
1489
  turnId: runArgs.turnId,
1488
1490
  sliceId: runArgs.sliceId ?? 1,
1489
- source: replyContext2.source,
1491
+ source: savedRun.source,
1490
1492
  state: "running",
1491
- surface: replyContext2.surface ?? "slack"
1493
+ surface: savedRun.surface ?? "slack"
1492
1494
  })
1493
1495
  );
1494
1496
  } catch (error) {
@@ -1502,11 +1504,7 @@ async function resumeSlackTurnInContext(args) {
1502
1504
  deliveryState.conversation,
1503
1505
  sessionId
1504
1506
  );
1505
- const replyContext = createResumeReplyContext(
1506
- runArgs,
1507
- status,
1508
- deliverAssistantMessage
1509
- );
1507
+ const run = buildResumedRun(runArgs, status, deliverAssistantMessage);
1510
1508
  if (runArgs.inputMessageIds?.length) {
1511
1509
  await turnLifecycle.start({
1512
1510
  conversationId: runArgs.conversationId,
@@ -1516,10 +1514,70 @@ async function resumeSlackTurnInContext(args) {
1516
1514
  surface: "slack"
1517
1515
  });
1518
1516
  }
1519
- const replyTimeoutMs = resolveReplyTimeoutMs(runArgs.replyTimeoutMs);
1520
- const outcome = await runAgentWithTimeout(
1521
- runArgs.agentRunner,
1522
- replyContext,
1517
+ const replyTimeoutMs = resolveReplyTimeoutMs();
1518
+ const outcome = await runArgs.executeTurn(
1519
+ run,
1520
+ async (result) => {
1521
+ const finalized = finalizeFailedTurnReplyWithEvent({
1522
+ reply: result,
1523
+ logException
1524
+ });
1525
+ const reply = finalized.reply;
1526
+ const dispatchErrorMessage = run.dispatch && reply.diagnostics.outcome !== "success" ? reply.diagnostics.errorMessage ?? `Agent turn ended with ${reply.diagnostics.outcome}.` : void 0;
1527
+ if (reply.diagnostics.outcome !== "success") {
1528
+ await deliverAssistantMessage(reply.text);
1529
+ }
1530
+ runResultHandled = true;
1531
+ await status.clear();
1532
+ failureCode = "persistence_failed";
1533
+ if (reply.piMessages?.length) {
1534
+ await saveTurnCheckpoint({
1535
+ mode: "completed",
1536
+ conversationId: runArgs.conversationId,
1537
+ turnId: runArgs.turnId,
1538
+ messages: reply.piMessages,
1539
+ durationMs: reply.diagnostics.durationMs,
1540
+ usage: reply.diagnostics.usage,
1541
+ destination: run.destination,
1542
+ destinationVisibility: run.destinationVisibility,
1543
+ dispatchId: run.dispatch?.id,
1544
+ dispatchOutcome: reply.diagnostics.outcome === "success" ? "completed" : "failed",
1545
+ ...dispatchErrorMessage ? { errorMessage: dispatchErrorMessage } : void 0,
1546
+ ...acceptedDeliveryId ? { resultMessageId: acceptedDeliveryId } : void 0,
1547
+ source: run.source,
1548
+ actor: resumeActor,
1549
+ surface: run.surface ?? "slack",
1550
+ sliceId: runArgs.sliceId
1551
+ });
1552
+ } else if (run.dispatch?.id) {
1553
+ await recordTurnSummary({
1554
+ conversationId: runArgs.conversationId,
1555
+ destination: run.destination,
1556
+ destinationVisibility: run.destinationVisibility,
1557
+ dispatchId: run.dispatch?.id,
1558
+ dispatchOutcome: reply.diagnostics.outcome === "success" ? "completed" : "failed",
1559
+ ...acceptedDeliveryId ? { resultMessageId: acceptedDeliveryId } : void 0,
1560
+ turnId: runArgs.turnId,
1561
+ sliceId: runArgs.sliceId ?? 1,
1562
+ source: run.source,
1563
+ state: reply.diagnostics.outcome === "success" ? "completed" : "failed",
1564
+ surface: run.surface ?? "slack"
1565
+ });
1566
+ }
1567
+ await runArgs.commitResult?.(reply);
1568
+ if (reply.diagnostics.outcome === "success") {
1569
+ shouldScheduleCompletedPluginTasks = true;
1570
+ return {
1571
+ outcome: assistantMessageDelivered ? "success" : "no_reply"
1572
+ };
1573
+ }
1574
+ return {
1575
+ outcome: "failed",
1576
+ failureCode: "model_execution_failed",
1577
+ ...finalized.eventId ? { eventId: finalized.eventId } : void 0,
1578
+ ...finalized.failureReason ? { failureReason: finalized.failureReason } : void 0
1579
+ };
1580
+ },
1523
1581
  replyTimeoutMs
1524
1582
  );
1525
1583
  if (outcome.status !== "completed") {
@@ -1538,7 +1596,7 @@ async function resumeSlackTurnInContext(args) {
1538
1596
  });
1539
1597
  };
1540
1598
  } else if (outcome.status === "suspended") {
1541
- if (runArgs.ownsConversationLease && (outcome.reason === "timeout" || activeReplyContext.durability?.shouldYield?.())) {
1599
+ if (runArgs.ownsConversationLease && (outcome.reason === "timeout" || savedRun.durability?.shouldYield?.())) {
1542
1600
  throw new CooperativeTurnYieldError();
1543
1601
  }
1544
1602
  if (onSuspend) {
@@ -1548,124 +1606,51 @@ async function resumeSlackTurnInContext(args) {
1548
1606
  } else {
1549
1607
  deferredFailureHandler = async () => {
1550
1608
  await handleResumeFailure({
1551
- body: "Failed to resume Slack turn",
1552
- error: new Error(
1553
- `Resumed run ended suspended without a pause handler`
1554
- ),
1609
+ error: new Error("Resumed Run ended suspended without onSuspend"),
1555
1610
  eventName: "slack.resume.turn.failed",
1556
1611
  failureCode: "agent_run_failed",
1557
1612
  turnLifecycle,
1558
- lockKey,
1559
- resumeArgs: runArgs
1613
+ resume: runArgs
1560
1614
  });
1561
1615
  };
1562
1616
  }
1563
1617
  } else {
1564
1618
  deferredFailureHandler = async () => {
1565
1619
  await handleResumeFailure({
1566
- body: "Failed to resume Slack turn",
1567
1620
  error: new Error(
1568
- `Resumed run ended ${outcome.status} without a pause handler`
1621
+ `Resumed Run ended ${outcome.status} without its required callback`
1569
1622
  ),
1570
1623
  eventName: "slack.resume.turn.failed",
1571
1624
  failureCode: "agent_run_failed",
1572
1625
  turnLifecycle,
1573
- lockKey,
1574
- resumeArgs: runArgs
1626
+ resume: runArgs
1575
1627
  });
1576
1628
  };
1577
1629
  }
1578
- } else {
1579
- const finalized = finalizeFailedTurnReplyWithEvent({
1580
- reply: outcome.result,
1581
- logException
1582
- });
1583
- const reply = finalized.reply;
1584
- const dispatchErrorMessage = replyContext.dispatch && reply.diagnostics.outcome !== "success" ? reply.diagnostics.errorMessage ?? `Agent turn ended with ${reply.diagnostics.outcome}.` : void 0;
1585
- if (reply.diagnostics.outcome !== "success") {
1586
- await deliverAssistantMessage(reply.text);
1587
- }
1588
- runResultHandled = true;
1589
- await status.clear();
1590
- failureCode = "persistence_failed";
1591
- if (reply.piMessages?.length) {
1592
- await saveTurnCheckpoint({
1593
- mode: "completed",
1594
- conversationId: runArgs.conversationId,
1595
- turnId: runArgs.turnId,
1596
- messages: reply.piMessages,
1597
- durationMs: reply.diagnostics.durationMs,
1598
- usage: reply.diagnostics.usage,
1599
- destination: replyContext.destination,
1600
- destinationVisibility: replyContext.destinationVisibility,
1601
- dispatchId: replyContext.dispatch?.id,
1602
- dispatchOutcome: reply.diagnostics.outcome === "success" ? "completed" : "failed",
1603
- ...dispatchErrorMessage ? { errorMessage: dispatchErrorMessage } : void 0,
1604
- ...acceptedDeliveryId ? { resultMessageId: acceptedDeliveryId } : void 0,
1605
- source: replyContext.source,
1606
- actor: resumeActor,
1607
- surface: replyContext.surface ?? "slack",
1608
- sliceId: runArgs.sliceId
1609
- });
1610
- } else if (replyContext.dispatch?.id) {
1611
- await recordTurnSummary({
1612
- conversationId: runArgs.conversationId,
1613
- destination: replyContext.destination,
1614
- destinationVisibility: replyContext.destinationVisibility,
1615
- dispatchId: replyContext.dispatch?.id,
1616
- dispatchOutcome: reply.diagnostics.outcome === "success" ? "completed" : "failed",
1617
- ...acceptedDeliveryId ? { resultMessageId: acceptedDeliveryId } : void 0,
1618
- turnId: runArgs.turnId,
1619
- sliceId: runArgs.sliceId ?? 1,
1620
- source: replyContext.source,
1621
- state: reply.diagnostics.outcome === "success" ? "completed" : "failed",
1622
- surface: replyContext.surface ?? "slack"
1623
- });
1624
- }
1625
- await runArgs.commitResult?.(reply);
1626
- if (reply.diagnostics.outcome === "success") {
1627
- await turnLifecycle.complete({
1628
- conversationId: runArgs.conversationId,
1629
- turnId: runArgs.turnId,
1630
- createdAtMs: Date.now(),
1631
- outcome: assistantMessageDelivered ? "success" : "no_reply"
1632
- });
1633
- } else {
1634
- await turnLifecycle.fail({
1630
+ }
1631
+ if (shouldScheduleCompletedPluginTasks) {
1632
+ try {
1633
+ const params = {
1635
1634
  conversationId: runArgs.conversationId,
1636
- turnId: runArgs.turnId,
1637
- createdAtMs: Date.now(),
1638
- failureCode: "model_execution_failed",
1639
- ...finalized.eventId ? { eventId: finalized.eventId } : void 0
1640
- });
1641
- }
1642
- if (reply.diagnostics.outcome === "success") {
1643
- try {
1644
- const params = {
1645
- conversationId: runArgs.conversationId,
1646
- sessionId: runArgs.turnId
1647
- };
1648
- if (runArgs.scheduleSessionCompletedPluginTasks) {
1649
- await runArgs.scheduleSessionCompletedPluginTasks(params);
1650
- } else {
1651
- await scheduleSessionCompletedPluginTasks(params);
1652
- }
1653
- } catch (scheduleError) {
1654
- logException(
1655
- scheduleError,
1656
- "plugin.session.completed_task_schedule.failed"
1657
- );
1658
- }
1635
+ sessionId: runArgs.turnId
1636
+ };
1637
+ await (runArgs.scheduleSessionCompletedPluginTasks ?? scheduleSessionCompletedPluginTasks)(params);
1638
+ } catch (scheduleError) {
1639
+ logException(
1640
+ scheduleError,
1641
+ "plugin.session.completed_task_schedule.failed"
1642
+ );
1659
1643
  }
1660
1644
  }
1661
1645
  } catch (error) {
1662
1646
  await status.clear();
1663
- if (isCooperativeTurnYieldError(error)) {
1647
+ const runError = error instanceof AgentRunError ? error.cause : error;
1648
+ if (isCooperativeTurnYieldError(runError)) {
1664
1649
  if (lock) {
1665
1650
  await stateAdapter.releaseLock(lock);
1666
1651
  }
1667
1652
  await processingReaction?.stop();
1668
- throw error;
1653
+ throw runError;
1669
1654
  }
1670
1655
  if (runResultHandled) {
1671
1656
  postDeliveryCommitError = error;
@@ -1680,13 +1665,11 @@ async function resumeSlackTurnInContext(args) {
1680
1665
  } else {
1681
1666
  deferredFailureHandler = async () => {
1682
1667
  await handleResumeFailure({
1683
- body: "Failed to resume Slack turn",
1684
- error,
1668
+ error: runError,
1685
1669
  eventName: "slack.resume.turn.failed",
1686
1670
  failureCode,
1687
1671
  turnLifecycle,
1688
- lockKey,
1689
- resumeArgs: runArgs
1672
+ resume: runArgs
1690
1673
  });
1691
1674
  };
1692
1675
  }
@@ -1727,19 +1710,17 @@ async function resumeSlackTurnInContext(args) {
1727
1710
  deferredAuthInfo.requestText
1728
1711
  ),
1729
1712
  runArgs.conversationId,
1730
- runArgs.replyContext?.dispatch?.replyAttribution
1713
+ runArgs.run?.dispatch?.replyAttribution
1731
1714
  );
1732
1715
  }
1733
1716
  return true;
1734
1717
  } catch (pauseError) {
1735
1718
  await handleResumeFailure({
1736
- body: "Failed to handle resumed turn pause",
1737
1719
  error: pauseError,
1738
1720
  eventName: "slack.resume.pause_handler.failed",
1739
1721
  failureCode: "persistence_failed",
1740
1722
  turnLifecycle,
1741
- lockKey,
1742
- resumeArgs: runArgs
1723
+ resume: runArgs
1743
1724
  });
1744
1725
  return true;
1745
1726
  }
@@ -1805,6 +1786,15 @@ async function wakePausedTurn(request, options = {}) {
1805
1786
  state: options.state
1806
1787
  });
1807
1788
  }
1789
+ function createPausedTurns(options = {}) {
1790
+ return {
1791
+ get: (args) => getPausedTurnRequest({
1792
+ ...args,
1793
+ conversationStore: options.conversationStore
1794
+ }),
1795
+ wake: (request) => wakePausedTurn(request, options)
1796
+ };
1797
+ }
1808
1798
 
1809
1799
  // src/handlers/oauth-html.ts
1810
1800
  function htmlCallbackResponse(title, message, status, options = {}) {
@@ -1992,7 +1982,7 @@ async function resumeAuthorizedMcpTurn(args) {
1992
1982
  messageTs: getTurnUserSlackMessageTs(userMessage),
1993
1983
  lockKey: threadId,
1994
1984
  initialText: "",
1995
- agentRunner,
1985
+ executeTurn: async (run, saveResult, timeoutMs) => await executeTurn(agentRunner, run, saveResult, timeoutMs),
1996
1986
  beforeStart: async () => {
1997
1987
  const lockedState = await getPersistedThreadState(threadId);
1998
1988
  const lockedConversation = coerceThreadConversationState(lockedState);
@@ -2091,7 +2081,7 @@ async function resumeAuthorizedMcpTurn(args) {
2091
2081
  sliceId: lockedSessionRecord.sliceId,
2092
2082
  messageTs: lockedMessageTs,
2093
2083
  inputMessageIds: [lockedUserMessage.id],
2094
- replyContext: {
2084
+ run: {
2095
2085
  instruction: {
2096
2086
  text: lockedUserMessage.text,
2097
2087
  context: lockedConversationContext,
@@ -2648,7 +2638,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
2648
2638
  messageTs: getTurnUserSlackMessageTs(userMessage),
2649
2639
  lockKey: stored.resumeConversationId,
2650
2640
  initialText: "",
2651
- agentRunner: options.agentRunner,
2641
+ executeTurn: async (run, saveResult, timeoutMs) => await executeTurn(options.agentRunner, run, saveResult, timeoutMs),
2652
2642
  beforeStart: async () => {
2653
2643
  const lockedState = await getPersistedThreadState(
2654
2644
  stored.resumeConversationId
@@ -2751,7 +2741,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
2751
2741
  sliceId: lockedSessionRecord.sliceId,
2752
2742
  messageTs: lockedMessageTs,
2753
2743
  inputMessageIds: [lockedUserMessage.id],
2754
- replyContext: {
2744
+ run: {
2755
2745
  instruction: {
2756
2746
  text: lockedUserMessage.text,
2757
2747
  context: lockedConversationContext,
@@ -3253,11 +3243,12 @@ export {
3253
3243
  getAssistantThreadContext,
3254
3244
  getMessageTs,
3255
3245
  shouldKeepProcessingReactionForToolInvocation,
3256
- startSlackProcessingReaction,
3246
+ startProcessingReaction,
3257
3247
  buildAuthPauseResponse,
3258
3248
  resumeSlackTurn,
3259
3249
  getPausedTurnRequest,
3260
3250
  wakePausedTurn,
3251
+ createPausedTurns,
3261
3252
  GET,
3262
3253
  publishAppHomeView,
3263
3254
  GET2,