@sentry/junior 0.184.0 → 0.186.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 (129) hide show
  1. package/dist/{agent-hooks-XTZVALGQ.js → agent-hooks-4B3Z4WRK.js} +13 -11
  2. package/dist/api/acp/schema.d.ts +20 -2
  3. package/dist/api/code/overview.d.ts +39 -0
  4. package/dist/api/locations/detail.d.ts +1 -1
  5. package/dist/api/people/code.d.ts +22 -0
  6. package/dist/api/schema/code.d.ts +46 -0
  7. package/dist/api/schema/conversation.d.ts +108 -20
  8. package/dist/api/schema/location.d.ts +1 -1
  9. package/dist/api/schema/person.d.ts +1 -1
  10. package/dist/api/schema.d.ts +4 -4
  11. package/dist/api/schema.js +12 -1
  12. package/dist/api.js +368 -78
  13. package/dist/app.js +1412 -538
  14. package/dist/{catalog-runtime-5357XR4F.js → catalog-runtime-AFJCAOHC.js} +4 -4
  15. package/dist/chat/api-turns/accepted-reply.d.ts +11 -0
  16. package/dist/chat/api-turns/cancellation.d.ts +3 -5
  17. package/dist/chat/api-turns/mailbox-input.d.ts +7 -0
  18. package/dist/chat/api-turns/routing.d.ts +18 -3
  19. package/dist/chat/api-turns/work.d.ts +4 -9
  20. package/dist/chat/app/conversation-work.d.ts +1 -1
  21. package/dist/chat/app/factory.d.ts +4 -0
  22. package/dist/chat/app/services.d.ts +4 -3
  23. package/dist/chat/conversations/history.d.ts +83 -9
  24. package/dist/chat/conversations/turn-lifecycle.d.ts +6 -3
  25. package/dist/chat/providers/slack/input.d.ts +32 -0
  26. package/dist/chat/{runtime → providers/slack}/processing-reaction.d.ts +6 -8
  27. package/dist/chat/{runtime/slack-resume.d.ts → providers/slack/resume.d.ts} +16 -19
  28. package/dist/chat/providers/slack/runtime.d.ts +1 -12
  29. package/dist/chat/providers/slack/turn.d.ts +10 -25
  30. package/dist/chat/resource-events/actor.d.ts +7 -2
  31. package/dist/chat/resource-events/app-publisher.d.ts +18 -0
  32. package/dist/chat/resource-events/catalog.d.ts +19 -0
  33. package/dist/chat/resource-events/ingest.d.ts +0 -1
  34. package/dist/chat/resource-events/notification.d.ts +28 -3
  35. package/dist/chat/resource-events/runtime-catalog.d.ts +7 -2
  36. package/dist/chat/resource-events/store.d.ts +2 -14
  37. package/dist/chat/resource-events/tool-support.d.ts +0 -5
  38. package/dist/chat/resource-events/workspace.d.ts +7 -3
  39. package/dist/chat/runtime/turn-execution.d.ts +7 -2
  40. package/dist/chat/sandbox/egress/credentials.d.ts +5 -4
  41. package/dist/chat/sandbox/egress/session.d.ts +10 -11
  42. package/dist/chat/sandbox/errors.d.ts +1 -1
  43. package/dist/chat/sandbox/ref.d.ts +1 -1
  44. package/dist/chat/sandbox/snapshot/events.d.ts +8 -1
  45. package/dist/chat/sandbox/snapshot/not-ready-error.d.ts +6 -1
  46. package/dist/chat/scheduled-tasks/tool-support.d.ts +5 -5
  47. package/dist/chat/scheduled-tasks/tools/create.d.ts +2 -2
  48. package/dist/chat/scheduled-tasks/tools/delete.d.ts +2 -2
  49. package/dist/chat/scheduled-tasks/tools/list.d.ts +2 -2
  50. package/dist/chat/scheduled-tasks/tools/run-now.d.ts +2 -2
  51. package/dist/chat/scheduled-tasks/tools/update.d.ts +2 -2
  52. package/dist/chat/scheduled-tasks/types.d.ts +1 -1
  53. package/dist/chat/sentry-links.d.ts +2 -0
  54. package/dist/chat/services/provider-retry.d.ts +2 -0
  55. package/dist/chat/services/turn-failure-response.d.ts +4 -0
  56. package/dist/chat/services/turn-session-routing.d.ts +20 -5
  57. package/dist/chat/task-execution/paused-turn.d.ts +0 -2
  58. package/dist/chat/task-execution/slack-resource-event.d.ts +47 -0
  59. package/dist/chat/task-execution/slack-work.d.ts +0 -21
  60. package/dist/chat/task-execution/state.d.ts +2 -2
  61. package/dist/chat/task-execution/store.d.ts +1 -1
  62. package/dist/chat/task-execution/turn-wake.d.ts +12 -0
  63. package/dist/chat/tool-support/action-review.d.ts +1 -1
  64. package/dist/chat/tools/event-tasks.d.ts +1 -1
  65. package/dist/chat/tools/resource-events.d.ts +2 -2
  66. package/dist/chat/tools/search-conversation-events.d.ts +1 -1
  67. package/dist/chat/tools/types.d.ts +1 -1
  68. package/dist/chat/tools/watch-resource-events.d.ts +2 -2
  69. package/dist/{chunk-Z3QAXJR7.js → chunk-2IBDVE62.js} +12 -9
  70. package/dist/{chunk-4RONS3WR.js → chunk-2U7EPTRZ.js} +11 -5
  71. package/dist/{chunk-3S7ULUWW.js → chunk-3CVEE6LA.js} +1 -1
  72. package/dist/{chunk-IZDYYYGP.js → chunk-43LODHJM.js} +24 -384
  73. package/dist/{chunk-LHXIZLFF.js → chunk-64WF2GQ3.js} +1 -1
  74. package/dist/{chunk-YKX6MTLU.js → chunk-7EOWT62G.js} +1 -1
  75. package/dist/{chunk-UBOIHNTH.js → chunk-7EU4YSZ4.js} +362 -188
  76. package/dist/{chunk-UF6BUA5W.js → chunk-ACGWTJ74.js} +3 -3
  77. package/dist/{chunk-6UDPINOX.js → chunk-AD64YMEC.js} +19 -44
  78. package/dist/{chunk-MLSQX2EX.js → chunk-BRKB5R7P.js} +1 -1
  79. package/dist/{chunk-E57WPXWY.js → chunk-CM6RTYSO.js} +5 -5
  80. package/dist/{chunk-MAPJFUMV.js → chunk-CV5CPRVG.js} +3 -3
  81. package/dist/chunk-D4YV5TDV.js +45 -0
  82. package/dist/{chunk-HIPUIPJM.js → chunk-DHYZ4VKG.js} +383 -254
  83. package/dist/{chunk-DUKIDPF6.js → chunk-DOP3FIQC.js} +1 -1
  84. package/dist/{chunk-BT53RIGJ.js → chunk-EWRPUXE3.js} +12 -50
  85. package/dist/{chunk-BHYRYYLY.js → chunk-FFYDRLXW.js} +1 -1
  86. package/dist/chunk-GFBR4S3Q.js +406 -0
  87. package/dist/chunk-GQMQCY7H.js +58 -0
  88. package/dist/{chunk-JNO2GUDS.js → chunk-GSB3NTNS.js} +926 -1856
  89. package/dist/{chunk-2ZQPVX7C.js → chunk-H7X2G2KS.js} +25 -12
  90. package/dist/{chunk-WQFEWULF.js → chunk-HKFLRIBD.js} +2 -2
  91. package/dist/{chunk-SHJK75Z2.js → chunk-HWXP6RHG.js} +38 -4
  92. package/dist/{chunk-RF6J3DIO.js → chunk-INQHUE72.js} +84 -1
  93. package/dist/{chunk-4CNDGK25.js → chunk-JFPY6XFF.js} +911 -993
  94. package/dist/{chunk-6WGC3SO4.js → chunk-MCLWOBPN.js} +80 -18
  95. package/dist/{chunk-PJPRXO2T.js → chunk-NRMAOGRS.js} +1 -1
  96. package/dist/{chunk-ACPDVEJO.js → chunk-O6GQO7VP.js} +201 -218
  97. package/dist/{chunk-M5YWNMTE.js → chunk-OZG7E22Y.js} +24 -6
  98. package/dist/{chunk-WVIA7V3M.js → chunk-PFAZSRGR.js} +29 -1
  99. package/dist/{chunk-LCP4EDKR.js → chunk-PZZOGHVR.js} +14 -4
  100. package/dist/{chunk-QABCY33S.js → chunk-QBL2AVFF.js} +2 -2
  101. package/dist/{chunk-FKEZZMXS.js → chunk-QU3URVWG.js} +9 -94
  102. package/dist/{chunk-M3QYTBQ6.js → chunk-STOCCPWH.js} +11 -2
  103. package/dist/{chunk-K7VDC2QW.js → chunk-TXLBLGNQ.js} +6 -6
  104. package/dist/{chunk-JA43DV4Y.js → chunk-VOGOTEW7.js} +1 -1
  105. package/dist/{chunk-HUXFMDBZ.js → chunk-VQIWBJOP.js} +1 -1
  106. package/dist/{chunk-JM2COLGC.js → chunk-VQZYIVYN.js} +6 -6
  107. package/dist/{chunk-BCHYQS4B.js → chunk-VXL2LBPK.js} +1 -1
  108. package/dist/{chunk-6VOYP4M6.js → chunk-YXSBZRP7.js} +1 -1
  109. package/dist/cli/chat.js +35 -33
  110. package/dist/cli/check.js +5 -5
  111. package/dist/cli/plugins.js +14 -12
  112. package/dist/cli/snapshot-create.js +10 -9
  113. package/dist/cli/upgrade.js +7 -6
  114. package/dist/{db-MA52H62H.js → db-7XL4UPAE.js} +8 -6
  115. package/dist/instrumentation.js +3 -3
  116. package/dist/nitro.js +7 -6
  117. package/dist/{oauth-callback-server-DXGHKN6S.js → oauth-callback-server-RAOYHWDI.js} +30 -27
  118. package/dist/{runner-4IXUAQNK.js → runner-KMPBWRPM.js} +24 -19
  119. package/dist/{skills-X3DY7AXO.js → skills-IPCALGLQ.js} +5 -5
  120. package/dist/spawn-OSOWTMBG.js +41 -0
  121. package/dist/task-runner-IQNBA3RY.js +34 -0
  122. package/dist/{validation-Z6JXSTJS.js → validation-BSRCCX6N.js} +5 -5
  123. package/dist/version.js +1 -1
  124. package/dist/{work-OKWRFBDW.js → work-T6UFTOJY.js} +24 -19
  125. package/dist/worker-L35OG7VA.js +24 -0
  126. package/package.json +5 -5
  127. package/dist/spawn-43WGS6CH.js +0 -37
  128. package/dist/task-runner-VDRKITPV.js +0 -32
  129. package/dist/worker-B236AE72.js +0 -22
@@ -4,7 +4,11 @@ import {
4
4
  import {
5
5
  buildSentryConversationUrl,
6
6
  deleteWebAuthorization
7
- } from "./chunk-LCP4EDKR.js";
7
+ } from "./chunk-PZZOGHVR.js";
8
+ import {
9
+ AgentRunError,
10
+ executeTurn
11
+ } from "./chunk-GQMQCY7H.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-M5YWNMTE.js";
22
+ } from "./chunk-OZG7E22Y.js";
19
23
  import {
20
24
  resolveTurnSessionRouting,
21
25
  scheduleSessionCompletedPluginTasks
22
- } from "./chunk-6WGC3SO4.js";
26
+ } from "./chunk-MCLWOBPN.js";
23
27
  import {
24
- ConversationTurnLifecycleService
25
- } from "./chunk-M3QYTBQ6.js";
28
+ getTurnLifecycle
29
+ } from "./chunk-STOCCPWH.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-E57WPXWY.js";
37
+ } from "./chunk-CM6RTYSO.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-FKEZZMXS.js";
45
- import {
46
- RetryableDeliveryError
47
- } from "./chunk-RF6J3DIO.js";
46
+ resolvePluginOAuthAccount
47
+ } from "./chunk-QU3URVWG.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-JM2COLGC.js";
60
+ } from "./chunk-VQZYIVYN.js";
61
61
  import {
62
62
  parseSlackThreadId,
63
63
  readSlackRawMessageContext,
64
64
  resolveSlackChannelIdFromMessage,
65
65
  resolveSlackChannelIdFromThreadId
66
- } from "./chunk-YKX6MTLU.js";
66
+ } from "./chunk-7EOWT62G.js";
67
+ import {
68
+ RetryableDeliveryError
69
+ } from "./chunk-INQHUE72.js";
67
70
  import {
68
71
  ensureConversationWake,
69
72
  requestConversationWork
70
- } from "./chunk-Z3QAXJR7.js";
73
+ } from "./chunk-2IBDVE62.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-JA43DV4Y.js";
82
+ } from "./chunk-VOGOTEW7.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-2ZQPVX7C.js";
102
+ } from "./chunk-H7X2G2KS.js";
100
103
  import {
101
104
  getVercelConversationWorkQueue
102
105
  } from "./chunk-DKIJ2RP5.js";
103
106
  import {
104
107
  getTurnRequestDeadline
105
- } from "./chunk-MLSQX2EX.js";
108
+ } from "./chunk-BRKB5R7P.js";
106
109
  import {
107
110
  SlackActionError,
108
111
  getDashboardConversationLink,
@@ -111,37 +114,38 @@ import {
111
114
  getSlackClient,
112
115
  isDmChannel,
113
116
  normalizeSlackConversationId
114
- } from "./chunk-4CNDGK25.js";
117
+ } from "./chunk-JFPY6XFF.js";
115
118
  import {
116
- getConversationEventStore,
117
119
  getSqlExecutor,
118
120
  requireSlackDestination,
119
121
  upsertIdentity,
120
122
  upsertLinkedIdentity
121
- } from "./chunk-IZDYYYGP.js";
123
+ } from "./chunk-43LODHJM.js";
122
124
  import {
123
125
  acquireActiveLock,
124
126
  getStateAdapter
125
- } from "./chunk-DUKIDPF6.js";
127
+ } from "./chunk-DOP3FIQC.js";
126
128
  import {
127
129
  botConfig,
128
- defaultModelId,
129
130
  escapeXml,
130
131
  getChatConfig,
131
132
  getRuntimeMetadata,
132
133
  normalizeSlackEmojiName
133
- } from "./chunk-6UDPINOX.js";
134
+ } from "./chunk-AD64YMEC.js";
135
+ import {
136
+ defaultModelId
137
+ } from "./chunk-D4YV5TDV.js";
134
138
  import {
135
139
  discoverSkills
136
- } from "./chunk-WQFEWULF.js";
140
+ } from "./chunk-HKFLRIBD.js";
137
141
  import {
138
142
  pluginCatalogRuntime
139
- } from "./chunk-PJPRXO2T.js";
143
+ } from "./chunk-NRMAOGRS.js";
140
144
  import {
141
145
  buildOAuthTokenRequest,
142
146
  hasRequiredOAuthScope,
143
147
  parseOAuthTokenResponse
144
- } from "./chunk-LHXIZLFF.js";
148
+ } from "./chunk-64WF2GQ3.js";
145
149
  import {
146
150
  createSlackResumeActor,
147
151
  isUserActor,
@@ -160,7 +164,7 @@ import {
160
164
  setTags,
161
165
  toOptionalString,
162
166
  withLogContext
163
- } from "./chunk-3S7ULUWW.js";
167
+ } from "./chunk-3CVEE6LA.js";
164
168
 
165
169
  // src/chat/slack/assistant-thread/status-render.ts
166
170
  var DEFAULT_STATUS_CONTEXTS = {
@@ -970,7 +974,7 @@ function getMessageTs(message) {
970
974
  return void 0;
971
975
  }
972
976
 
973
- // src/chat/runtime/processing-reaction.ts
977
+ // src/chat/providers/slack/processing-reaction.ts
974
978
  var noProcessingReaction = {
975
979
  complete: async () => void 0,
976
980
  keep: () => void 0,
@@ -982,7 +986,7 @@ function isProcessingReactionEmoji(value) {
982
986
  function shouldKeepProcessingReactionForToolInvocation(input) {
983
987
  return input.toolName === "addReaction" && isProcessingReactionEmoji(input.params.emoji);
984
988
  }
985
- async function startSlackProcessingReaction(args) {
989
+ async function startProcessingReaction(args) {
986
990
  if (args.message.author.isMe) {
987
991
  return noProcessingReaction;
988
992
  }
@@ -991,13 +995,12 @@ async function startSlackProcessingReaction(args) {
991
995
  if (!channelId || !messageTs) {
992
996
  return noProcessingReaction;
993
997
  }
994
- return startSlackProcessingReactionForMessage({
998
+ return startProcessingReactionForMessage({
995
999
  channelId,
996
- timestamp: messageTs,
997
- logException: args.logException
1000
+ timestamp: messageTs
998
1001
  });
999
1002
  }
1000
- async function startSlackProcessingReactionForMessage(args) {
1003
+ async function startProcessingReactionForMessage(args) {
1001
1004
  try {
1002
1005
  await addReactionToMessage({
1003
1006
  channelId: args.channelId,
@@ -1005,7 +1008,7 @@ async function startSlackProcessingReactionForMessage(args) {
1005
1008
  emoji: getChatConfig().slack.processingReactionEmoji
1006
1009
  });
1007
1010
  } catch (error) {
1008
- args.logException(error, "slack.processing.reaction_add.failed", {
1011
+ logException(error, "slack.processing.reaction_add.failed", {
1009
1012
  "app.slack.action": "reactions.add",
1010
1013
  "messaging.message.id": args.timestamp,
1011
1014
  ...getSlackErrorObservabilityAttributes(error)
@@ -1025,7 +1028,7 @@ async function startSlackProcessingReactionForMessage(args) {
1025
1028
  });
1026
1029
  return true;
1027
1030
  } catch (error) {
1028
- args.logException(error, "slack.processing.reaction_remove.failed", {
1031
+ logException(error, "slack.processing.reaction_remove.failed", {
1029
1032
  "app.slack.action": "reactions.remove",
1030
1033
  "messaging.message.id": args.timestamp,
1031
1034
  ...getSlackErrorObservabilityAttributes(error)
@@ -1047,7 +1050,7 @@ async function startSlackProcessingReactionForMessage(args) {
1047
1050
  emoji: getChatConfig().slack.completedReactionEmoji
1048
1051
  });
1049
1052
  } catch (error) {
1050
- args.logException(error, "slack.processing.reaction_complete.failed", {
1053
+ logException(error, "slack.processing.reaction_complete.failed", {
1051
1054
  "app.slack.action": "reactions.add",
1052
1055
  "messaging.message.id": args.timestamp,
1053
1056
  ...getSlackErrorObservabilityAttributes(error)
@@ -1086,11 +1089,8 @@ function buildAuthPauseResponse(slackUserId, providerDisplayName, requestText) {
1086
1089
  I sent you a link.`;
1087
1090
  }
1088
1091
 
1089
- // src/chat/runtime/slack-resume.ts
1090
- function resolveReplyTimeoutMs(explicitTimeoutMs) {
1091
- if (typeof explicitTimeoutMs === "number" && explicitTimeoutMs > 0) {
1092
- return explicitTimeoutMs;
1093
- }
1092
+ // src/chat/providers/slack/resume.ts
1093
+ function resolveReplyTimeoutMs() {
1094
1094
  const raw = process.env.EVAL_AGENT_REPLY_TIMEOUT_MS?.trim();
1095
1095
  if (!raw) {
1096
1096
  return void 0;
@@ -1130,7 +1130,7 @@ function createReadOnlyConfigService(rawValues) {
1130
1130
  return {
1131
1131
  get: async (key) => entries.find((entry) => entry.key === key),
1132
1132
  set: async () => {
1133
- throw new Error("Read-only configuration in resumed context");
1133
+ throw new Error("Configuration is read-only for a resumed Run");
1134
1134
  },
1135
1135
  unset: async () => false,
1136
1136
  list: async ({ prefix } = {}) => entries.filter((entry) => !prefix || entry.key.startsWith(prefix)),
@@ -1148,7 +1148,7 @@ function createReadOnlyConfigService(rawValues) {
1148
1148
  }
1149
1149
  var ResumeTurnBusyError = class extends Error {
1150
1150
  constructor(lockKey) {
1151
- super(`A turn already owns resume lock "${lockKey}"`);
1151
+ super(`Another worker is already resuming Slack Turn "${lockKey}"`);
1152
1152
  this.name = "ResumeTurnBusyError";
1153
1153
  }
1154
1154
  };
@@ -1156,7 +1156,7 @@ function getDefaultLockKey(channelId, threadTs) {
1156
1156
  return threadTs ? `slack:${channelId}:${threadTs}` : `slack:${channelId}`;
1157
1157
  }
1158
1158
  function getResumeLogContext(args, lockKey) {
1159
- const actor = args.replyContext?.actor;
1159
+ const actor = args.run?.actor;
1160
1160
  return {
1161
1161
  conversationId: args.conversationId,
1162
1162
  messageConversationId: lockKey,
@@ -1175,11 +1175,12 @@ async function postResumeFailureReply(args) {
1175
1175
  });
1176
1176
  }
1177
1177
  async function handleResumeFailure(args) {
1178
+ const turnLifecycle = getTurnLifecycle();
1178
1179
  const capturedEventId = logException(args.error, args.eventName);
1179
1180
  const eventId = requireTurnFailureEventId(capturedEventId, args.eventName);
1180
1181
  let failureStatePersistError;
1181
1182
  try {
1182
- await args.resumeArgs.onFailure?.(args.error);
1183
+ await args.resume.onFailure?.(args.error);
1183
1184
  } catch (persistError) {
1184
1185
  const persistEventId = logException(
1185
1186
  persistError,
@@ -1187,9 +1188,9 @@ async function handleResumeFailure(args) {
1187
1188
  { "app.error.original_event_id": eventId }
1188
1189
  );
1189
1190
  try {
1190
- await args.turnLifecycle.fail({
1191
- conversationId: args.resumeArgs.conversationId,
1192
- turnId: args.resumeArgs.turnId,
1191
+ await turnLifecycle.fail({
1192
+ conversationId: args.resume.conversationId,
1193
+ turnId: args.resume.turnId,
1193
1194
  createdAtMs: Date.now(),
1194
1195
  failureCode: "persistence_failed",
1195
1196
  ...persistEventId ? { eventId: persistEventId } : void 0
@@ -1205,8 +1206,8 @@ async function handleResumeFailure(args) {
1205
1206
  }
1206
1207
  try {
1207
1208
  await postResumeFailureReply({
1208
- channelId: args.resumeArgs.channelId,
1209
- threadTs: args.resumeArgs.threadTs,
1209
+ channelId: args.resume.channelId,
1210
+ threadTs: args.resume.threadTs,
1210
1211
  eventId,
1211
1212
  error: args.error
1212
1213
  });
@@ -1217,9 +1218,9 @@ async function handleResumeFailure(args) {
1217
1218
  { "app.error.original_event_id": eventId }
1218
1219
  );
1219
1220
  try {
1220
- await args.turnLifecycle.fail({
1221
- conversationId: args.resumeArgs.conversationId,
1222
- turnId: args.resumeArgs.turnId,
1221
+ await turnLifecycle.fail({
1222
+ conversationId: args.resume.conversationId,
1223
+ turnId: args.resume.turnId,
1223
1224
  createdAtMs: Date.now(),
1224
1225
  failureCode: "delivery_failed",
1225
1226
  ...deliveryEventId ? { eventId: deliveryEventId } : void 0
@@ -1236,36 +1237,36 @@ async function handleResumeFailure(args) {
1236
1237
  if (failureStatePersistError) {
1237
1238
  throw failureStatePersistError;
1238
1239
  }
1239
- await args.turnLifecycle.fail({
1240
- conversationId: args.resumeArgs.conversationId,
1241
- turnId: args.resumeArgs.turnId,
1240
+ await turnLifecycle.fail({
1241
+ conversationId: args.resume.conversationId,
1242
+ turnId: args.resume.turnId,
1242
1243
  createdAtMs: Date.now(),
1243
1244
  failureCode: args.failureCode,
1244
1245
  eventId
1245
1246
  });
1246
1247
  }
1247
- function createResumeReplyContext(args, statusSession, delivery) {
1248
- const replyContext = args.replyContext;
1249
- if (!replyContext) {
1250
- 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");
1251
1252
  }
1252
- if (!replyContext.source) {
1253
- throw new TypeError("Slack resume requires a reply context source");
1253
+ if (!savedRun.source) {
1254
+ throw new TypeError("Slack resume requires a Run Source");
1254
1255
  }
1255
- const source = replyContext.source;
1256
- if (replyContext.destination.platform !== "slack") {
1257
- 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");
1258
1259
  }
1259
1260
  const requestDeadline = getTurnRequestDeadline();
1260
1261
  const threadId = args.lockKey ?? getDefaultLockKey(args.channelId, args.threadTs);
1261
- const persistedLocationConfiguration = replyContext.environment?.locationConfiguration ?? (replyContext.environment?.configuration ? createReadOnlyConfigService(replyContext.environment.configuration) : void 0);
1262
- const priorOnEvent = replyContext.onEvent;
1262
+ const persistedLocationConfiguration = savedRun.environment?.locationConfiguration ?? (savedRun.environment?.configuration ? createReadOnlyConfigService(savedRun.environment.configuration) : void 0);
1263
+ const priorOnEvent = savedRun.onEvent;
1263
1264
  return {
1264
- ...replyContext,
1265
+ ...savedRun,
1265
1266
  conversationId: args.conversationId,
1266
1267
  turnId: args.turnId,
1267
1268
  instruction: {
1268
- ...replyContext.instruction ?? { text: args.messageText },
1269
+ ...savedRun.instruction ?? { text: args.messageText },
1269
1270
  text: args.messageText
1270
1271
  },
1271
1272
  source: source.platform === "slack" ? {
@@ -1273,9 +1274,9 @@ function createResumeReplyContext(args, statusSession, delivery) {
1273
1274
  channelId: args.channelId,
1274
1275
  ...args.threadTs ? { threadTs: args.threadTs } : void 0
1275
1276
  } : source,
1276
- deadlineAtMs: replyContext.deadlineAtMs ?? requestDeadline?.deadlineAtMs,
1277
+ deadlineAtMs: savedRun.deadlineAtMs ?? requestDeadline?.deadlineAtMs,
1277
1278
  environment: {
1278
- ...replyContext.environment,
1279
+ ...savedRun.environment,
1279
1280
  locationConfiguration: persistedLocationConfiguration
1280
1281
  },
1281
1282
  onEvent: async (event) => {
@@ -1286,12 +1287,12 @@ function createResumeReplyContext(args, statusSession, delivery) {
1286
1287
  },
1287
1288
  delivery,
1288
1289
  durability: {
1289
- ...replyContext.durability,
1290
+ ...savedRun.durability,
1290
1291
  onSandboxRefChanged: async (sandboxRef) => {
1291
1292
  await persistThreadStateById(threadId, {
1292
1293
  sandboxRef
1293
1294
  });
1294
- await replyContext.durability?.onSandboxRefChanged?.(sandboxRef);
1295
+ await savedRun.durability?.onSandboxRefChanged?.(sandboxRef);
1295
1296
  }
1296
1297
  }
1297
1298
  };
@@ -1321,8 +1322,9 @@ async function resumeSlackTurnInContext(args) {
1321
1322
  let deferredFailureHandler;
1322
1323
  let runResultHandled = false;
1323
1324
  let assistantMessageDelivered = false;
1325
+ let shouldScheduleCompletedPluginTasks = false;
1324
1326
  let postDeliveryCommitError;
1325
- const turnLifecycle = args.turnLifecycle ?? new ConversationTurnLifecycleService(getConversationEventStore());
1327
+ const turnLifecycle = getTurnLifecycle();
1326
1328
  let failureCode = "agent_run_failed";
1327
1329
  let runArgs = args;
1328
1330
  try {
@@ -1334,36 +1336,33 @@ async function resumeSlackTurnInContext(args) {
1334
1336
  runArgs = { ...args, ...preparedArgs };
1335
1337
  }
1336
1338
  setTags(getResumeLogContext(runArgs, lockKey));
1337
- const activeReplyContext = runArgs.replyContext;
1338
- if (!activeReplyContext) {
1339
- throw new Error("Resumed turn requires replyContext");
1339
+ const savedRun = runArgs.run;
1340
+ if (!savedRun) {
1341
+ throw new Error("Resumed Turn requires a saved Run");
1340
1342
  }
1341
- const credentialContext = activeReplyContext.credentialContext;
1343
+ const credentialContext = savedRun.credentialContext;
1342
1344
  if (!credentialContext) {
1343
- throw new Error("Resumed turn requires replyContext.credentialContext");
1345
+ throw new Error("Resumed Run requires a credential context");
1344
1346
  }
1345
- const routingActor = activeReplyContext.actor;
1347
+ const routingActor = savedRun.actor;
1346
1348
  let resumeActor;
1347
1349
  if ("type" in credentialContext.actor) {
1348
1350
  if (!isUserActor(routingActor) || credentialContext.actor.userId !== routingActor.userId) {
1349
- throw new Error(
1350
- "Resumed turn credential actor must match replyContext.actor.userId"
1351
- );
1351
+ throw new Error("Resumed Run credential actor must match its Actor");
1352
1352
  }
1353
1353
  resumeActor = routingActor;
1354
1354
  } else {
1355
1355
  if (routingActor && (routingActor.platform !== "system" || routingActor.name !== credentialContext.actor.name)) {
1356
1356
  throw new Error(
1357
- "Resumed turn system credential actor must match replyContext.actor"
1357
+ "Resumed Run system credential actor must match its Actor"
1358
1358
  );
1359
1359
  }
1360
1360
  resumeActor = credentialContext.actor;
1361
1361
  }
1362
1362
  if (runArgs.messageTs) {
1363
- processingReaction = await startSlackProcessingReactionForMessage({
1363
+ processingReaction = await startProcessingReactionForMessage({
1364
1364
  channelId: runArgs.channelId,
1365
- timestamp: runArgs.messageTs,
1366
- logException
1365
+ timestamp: runArgs.messageTs
1367
1366
  });
1368
1367
  }
1369
1368
  if (runArgs.initialText) {
@@ -1417,11 +1416,11 @@ async function resumeSlackTurnInContext(args) {
1417
1416
  const deliveryState2 = await getDeliveryConversation();
1418
1417
  let slackMessageTs = [];
1419
1418
  try {
1420
- if (runArgs.replyContext?.publishExternally !== false) {
1419
+ if (runArgs.run?.publishExternally !== false) {
1421
1420
  slackMessageTs = await sendSlackReply({
1422
1421
  channelId: runArgs.channelId,
1423
1422
  conversationId: runArgs.conversationId,
1424
- replyAttribution: runArgs.replyContext?.dispatch?.replyAttribution,
1423
+ replyAttribution: runArgs.run?.dispatch?.replyAttribution,
1425
1424
  text,
1426
1425
  threadTs: runArgs.threadTs
1427
1426
  });
@@ -1448,7 +1447,7 @@ async function resumeSlackTurnInContext(args) {
1448
1447
  });
1449
1448
  }
1450
1449
  try {
1451
- const destination = runArgs.replyContext?.destination;
1450
+ const destination = runArgs.run?.destination;
1452
1451
  const providerConversationIds = runArgs.threadTs ? [runArgs.threadTs] : slackMessageTs;
1453
1452
  await persistWithRetry(
1454
1453
  () => commitAcceptedReply({
@@ -1456,7 +1455,7 @@ async function resumeSlackTurnInContext(args) {
1456
1455
  conversation: deliveryState2.conversation,
1457
1456
  conversationMessageId: recordedMessageId,
1458
1457
  conversationId,
1459
- ...runArgs.replyContext?.dispatch && destination?.platform === "slack" && providerConversationIds.length > 0 ? {
1458
+ ...runArgs.run?.dispatch && destination?.platform === "slack" && providerConversationIds.length > 0 ? {
1460
1459
  providerConversationBindings: providerConversationIds.map(
1461
1460
  (providerConversationId) => ({
1462
1461
  provider: "slack",
@@ -1475,22 +1474,21 @@ async function resumeSlackTurnInContext(args) {
1475
1474
  { "error.type": error instanceof Error ? error.name : typeof error }
1476
1475
  );
1477
1476
  }
1478
- const replyContext2 = runArgs.replyContext;
1479
- const dispatchId = replyContext2?.dispatch?.id;
1480
- if (messageTs && dispatchId && replyContext2) {
1477
+ const dispatchId = savedRun.dispatch?.id;
1478
+ if (messageTs && dispatchId) {
1481
1479
  try {
1482
1480
  await persistWithRetry(
1483
1481
  () => recordTurnSummary({
1484
1482
  conversationId: runArgs.conversationId,
1485
- destination: replyContext2.destination,
1486
- destinationVisibility: replyContext2.destinationVisibility,
1483
+ destination: savedRun.destination,
1484
+ destinationVisibility: savedRun.destinationVisibility,
1487
1485
  dispatchId,
1488
1486
  resultMessageId: messageTs,
1489
1487
  turnId: runArgs.turnId,
1490
1488
  sliceId: runArgs.sliceId ?? 1,
1491
- source: replyContext2.source,
1489
+ source: savedRun.source,
1492
1490
  state: "running",
1493
- surface: replyContext2.surface ?? "slack"
1491
+ surface: savedRun.surface ?? "slack"
1494
1492
  })
1495
1493
  );
1496
1494
  } catch (error) {
@@ -1504,11 +1502,7 @@ async function resumeSlackTurnInContext(args) {
1504
1502
  deliveryState.conversation,
1505
1503
  sessionId
1506
1504
  );
1507
- const replyContext = createResumeReplyContext(
1508
- runArgs,
1509
- status,
1510
- deliverAssistantMessage
1511
- );
1505
+ const run = buildResumedRun(runArgs, status, deliverAssistantMessage);
1512
1506
  if (runArgs.inputMessageIds?.length) {
1513
1507
  await turnLifecycle.start({
1514
1508
  conversationId: runArgs.conversationId,
@@ -1518,10 +1512,70 @@ async function resumeSlackTurnInContext(args) {
1518
1512
  surface: "slack"
1519
1513
  });
1520
1514
  }
1521
- const replyTimeoutMs = resolveReplyTimeoutMs(runArgs.replyTimeoutMs);
1522
- const outcome = await runAgentWithTimeout(
1523
- runArgs.agentRunner,
1524
- replyContext,
1515
+ const replyTimeoutMs = resolveReplyTimeoutMs();
1516
+ const outcome = await runArgs.executeTurn(
1517
+ run,
1518
+ async (result) => {
1519
+ const finalized = finalizeFailedTurnReplyWithEvent({
1520
+ reply: result,
1521
+ logException
1522
+ });
1523
+ const reply = finalized.reply;
1524
+ const dispatchErrorMessage = run.dispatch && reply.diagnostics.outcome !== "success" ? reply.diagnostics.errorMessage ?? `Agent turn ended with ${reply.diagnostics.outcome}.` : void 0;
1525
+ if (reply.diagnostics.outcome !== "success") {
1526
+ await deliverAssistantMessage(reply.text);
1527
+ }
1528
+ runResultHandled = true;
1529
+ await status.clear();
1530
+ failureCode = "persistence_failed";
1531
+ if (reply.piMessages?.length) {
1532
+ await saveTurnCheckpoint({
1533
+ mode: "completed",
1534
+ conversationId: runArgs.conversationId,
1535
+ turnId: runArgs.turnId,
1536
+ messages: reply.piMessages,
1537
+ durationMs: reply.diagnostics.durationMs,
1538
+ usage: reply.diagnostics.usage,
1539
+ destination: run.destination,
1540
+ destinationVisibility: run.destinationVisibility,
1541
+ dispatchId: run.dispatch?.id,
1542
+ dispatchOutcome: reply.diagnostics.outcome === "success" ? "completed" : "failed",
1543
+ ...dispatchErrorMessage ? { errorMessage: dispatchErrorMessage } : void 0,
1544
+ ...acceptedDeliveryId ? { resultMessageId: acceptedDeliveryId } : void 0,
1545
+ source: run.source,
1546
+ actor: resumeActor,
1547
+ surface: run.surface ?? "slack",
1548
+ sliceId: runArgs.sliceId
1549
+ });
1550
+ } else if (run.dispatch?.id) {
1551
+ await recordTurnSummary({
1552
+ conversationId: runArgs.conversationId,
1553
+ destination: run.destination,
1554
+ destinationVisibility: run.destinationVisibility,
1555
+ dispatchId: run.dispatch?.id,
1556
+ dispatchOutcome: reply.diagnostics.outcome === "success" ? "completed" : "failed",
1557
+ ...acceptedDeliveryId ? { resultMessageId: acceptedDeliveryId } : void 0,
1558
+ turnId: runArgs.turnId,
1559
+ sliceId: runArgs.sliceId ?? 1,
1560
+ source: run.source,
1561
+ state: reply.diagnostics.outcome === "success" ? "completed" : "failed",
1562
+ surface: run.surface ?? "slack"
1563
+ });
1564
+ }
1565
+ await runArgs.commitResult?.(reply);
1566
+ if (reply.diagnostics.outcome === "success") {
1567
+ shouldScheduleCompletedPluginTasks = true;
1568
+ return {
1569
+ outcome: assistantMessageDelivered ? "success" : "no_reply"
1570
+ };
1571
+ }
1572
+ return {
1573
+ outcome: "failed",
1574
+ failureCode: "model_execution_failed",
1575
+ ...finalized.eventId ? { eventId: finalized.eventId } : void 0,
1576
+ ...finalized.failureReason ? { failureReason: finalized.failureReason } : void 0
1577
+ };
1578
+ },
1525
1579
  replyTimeoutMs
1526
1580
  );
1527
1581
  if (outcome.status !== "completed") {
@@ -1540,7 +1594,7 @@ async function resumeSlackTurnInContext(args) {
1540
1594
  });
1541
1595
  };
1542
1596
  } else if (outcome.status === "suspended") {
1543
- if (runArgs.ownsConversationLease && (outcome.reason === "timeout" || activeReplyContext.durability?.shouldYield?.())) {
1597
+ if (runArgs.ownsConversationLease && (outcome.reason === "timeout" || savedRun.durability?.shouldYield?.())) {
1544
1598
  throw new CooperativeTurnYieldError();
1545
1599
  }
1546
1600
  if (onSuspend) {
@@ -1550,124 +1604,49 @@ async function resumeSlackTurnInContext(args) {
1550
1604
  } else {
1551
1605
  deferredFailureHandler = async () => {
1552
1606
  await handleResumeFailure({
1553
- body: "Failed to resume Slack turn",
1554
- error: new Error(
1555
- `Resumed run ended suspended without a pause handler`
1556
- ),
1607
+ error: new Error("Resumed Run ended suspended without onSuspend"),
1557
1608
  eventName: "slack.resume.turn.failed",
1558
1609
  failureCode: "agent_run_failed",
1559
- turnLifecycle,
1560
- lockKey,
1561
- resumeArgs: runArgs
1610
+ resume: runArgs
1562
1611
  });
1563
1612
  };
1564
1613
  }
1565
1614
  } else {
1566
1615
  deferredFailureHandler = async () => {
1567
1616
  await handleResumeFailure({
1568
- body: "Failed to resume Slack turn",
1569
1617
  error: new Error(
1570
- `Resumed run ended ${outcome.status} without a pause handler`
1618
+ `Resumed Run ended ${outcome.status} without its required callback`
1571
1619
  ),
1572
1620
  eventName: "slack.resume.turn.failed",
1573
1621
  failureCode: "agent_run_failed",
1574
- turnLifecycle,
1575
- lockKey,
1576
- resumeArgs: runArgs
1622
+ resume: runArgs
1577
1623
  });
1578
1624
  };
1579
1625
  }
1580
- } else {
1581
- const finalized = finalizeFailedTurnReplyWithEvent({
1582
- reply: outcome.result,
1583
- logException
1584
- });
1585
- const reply = finalized.reply;
1586
- const dispatchErrorMessage = replyContext.dispatch && reply.diagnostics.outcome !== "success" ? reply.diagnostics.errorMessage ?? `Agent turn ended with ${reply.diagnostics.outcome}.` : void 0;
1587
- if (reply.diagnostics.outcome !== "success") {
1588
- await deliverAssistantMessage(reply.text);
1589
- }
1590
- runResultHandled = true;
1591
- await status.clear();
1592
- failureCode = "persistence_failed";
1593
- if (reply.piMessages?.length) {
1594
- await saveTurnCheckpoint({
1595
- mode: "completed",
1596
- conversationId: runArgs.conversationId,
1597
- turnId: runArgs.turnId,
1598
- messages: reply.piMessages,
1599
- durationMs: reply.diagnostics.durationMs,
1600
- usage: reply.diagnostics.usage,
1601
- destination: replyContext.destination,
1602
- destinationVisibility: replyContext.destinationVisibility,
1603
- dispatchId: replyContext.dispatch?.id,
1604
- dispatchOutcome: reply.diagnostics.outcome === "success" ? "completed" : "failed",
1605
- ...dispatchErrorMessage ? { errorMessage: dispatchErrorMessage } : void 0,
1606
- ...acceptedDeliveryId ? { resultMessageId: acceptedDeliveryId } : void 0,
1607
- source: replyContext.source,
1608
- actor: resumeActor,
1609
- surface: replyContext.surface ?? "slack",
1610
- sliceId: runArgs.sliceId
1611
- });
1612
- } else if (replyContext.dispatch?.id) {
1613
- await recordTurnSummary({
1614
- conversationId: runArgs.conversationId,
1615
- destination: replyContext.destination,
1616
- destinationVisibility: replyContext.destinationVisibility,
1617
- dispatchId: replyContext.dispatch?.id,
1618
- dispatchOutcome: reply.diagnostics.outcome === "success" ? "completed" : "failed",
1619
- ...acceptedDeliveryId ? { resultMessageId: acceptedDeliveryId } : void 0,
1620
- turnId: runArgs.turnId,
1621
- sliceId: runArgs.sliceId ?? 1,
1622
- source: replyContext.source,
1623
- state: reply.diagnostics.outcome === "success" ? "completed" : "failed",
1624
- surface: replyContext.surface ?? "slack"
1625
- });
1626
- }
1627
- await runArgs.commitResult?.(reply);
1628
- if (reply.diagnostics.outcome === "success") {
1629
- await turnLifecycle.complete({
1630
- conversationId: runArgs.conversationId,
1631
- turnId: runArgs.turnId,
1632
- createdAtMs: Date.now(),
1633
- outcome: assistantMessageDelivered ? "success" : "no_reply"
1634
- });
1635
- } else {
1636
- await turnLifecycle.fail({
1626
+ }
1627
+ if (shouldScheduleCompletedPluginTasks) {
1628
+ try {
1629
+ const params = {
1637
1630
  conversationId: runArgs.conversationId,
1638
- turnId: runArgs.turnId,
1639
- createdAtMs: Date.now(),
1640
- failureCode: "model_execution_failed",
1641
- ...finalized.eventId ? { eventId: finalized.eventId } : void 0
1642
- });
1643
- }
1644
- if (reply.diagnostics.outcome === "success") {
1645
- try {
1646
- const params = {
1647
- conversationId: runArgs.conversationId,
1648
- sessionId: runArgs.turnId
1649
- };
1650
- if (runArgs.scheduleSessionCompletedPluginTasks) {
1651
- await runArgs.scheduleSessionCompletedPluginTasks(params);
1652
- } else {
1653
- await scheduleSessionCompletedPluginTasks(params);
1654
- }
1655
- } catch (scheduleError) {
1656
- logException(
1657
- scheduleError,
1658
- "plugin.session.completed_task_schedule.failed"
1659
- );
1660
- }
1631
+ sessionId: runArgs.turnId
1632
+ };
1633
+ await (runArgs.scheduleSessionCompletedPluginTasks ?? scheduleSessionCompletedPluginTasks)(params);
1634
+ } catch (scheduleError) {
1635
+ logException(
1636
+ scheduleError,
1637
+ "plugin.session.completed_task_schedule.failed"
1638
+ );
1661
1639
  }
1662
1640
  }
1663
1641
  } catch (error) {
1664
1642
  await status.clear();
1665
- if (isCooperativeTurnYieldError(error)) {
1643
+ const runError = error instanceof AgentRunError ? error.cause : error;
1644
+ if (isCooperativeTurnYieldError(runError)) {
1666
1645
  if (lock) {
1667
1646
  await stateAdapter.releaseLock(lock);
1668
1647
  }
1669
1648
  await processingReaction?.stop();
1670
- throw error;
1649
+ throw runError;
1671
1650
  }
1672
1651
  if (runResultHandled) {
1673
1652
  postDeliveryCommitError = error;
@@ -1682,13 +1661,10 @@ async function resumeSlackTurnInContext(args) {
1682
1661
  } else {
1683
1662
  deferredFailureHandler = async () => {
1684
1663
  await handleResumeFailure({
1685
- body: "Failed to resume Slack turn",
1686
- error,
1664
+ error: runError,
1687
1665
  eventName: "slack.resume.turn.failed",
1688
1666
  failureCode,
1689
- turnLifecycle,
1690
- lockKey,
1691
- resumeArgs: runArgs
1667
+ resume: runArgs
1692
1668
  });
1693
1669
  };
1694
1670
  }
@@ -1729,19 +1705,16 @@ async function resumeSlackTurnInContext(args) {
1729
1705
  deferredAuthInfo.requestText
1730
1706
  ),
1731
1707
  runArgs.conversationId,
1732
- runArgs.replyContext?.dispatch?.replyAttribution
1708
+ runArgs.run?.dispatch?.replyAttribution
1733
1709
  );
1734
1710
  }
1735
1711
  return true;
1736
1712
  } catch (pauseError) {
1737
1713
  await handleResumeFailure({
1738
- body: "Failed to handle resumed turn pause",
1739
1714
  error: pauseError,
1740
1715
  eventName: "slack.resume.pause_handler.failed",
1741
1716
  failureCode: "persistence_failed",
1742
- turnLifecycle,
1743
- lockKey,
1744
- resumeArgs: runArgs
1717
+ resume: runArgs
1745
1718
  });
1746
1719
  return true;
1747
1720
  }
@@ -1807,6 +1780,15 @@ async function wakePausedTurn(request, options = {}) {
1807
1780
  state: options.state
1808
1781
  });
1809
1782
  }
1783
+ function createPausedTurns(options = {}) {
1784
+ return {
1785
+ get: (args) => getPausedTurnRequest({
1786
+ ...args,
1787
+ conversationStore: options.conversationStore
1788
+ }),
1789
+ wake: (request) => wakePausedTurn(request, options)
1790
+ };
1791
+ }
1810
1792
 
1811
1793
  // src/handlers/oauth-html.ts
1812
1794
  function htmlCallbackResponse(title, message, status, options = {}) {
@@ -1994,7 +1976,7 @@ async function resumeAuthorizedMcpTurn(args) {
1994
1976
  messageTs: getTurnUserSlackMessageTs(userMessage),
1995
1977
  lockKey: threadId,
1996
1978
  initialText: "",
1997
- agentRunner,
1979
+ executeTurn: async (run, saveResult, timeoutMs) => await executeTurn(agentRunner, run, saveResult, timeoutMs),
1998
1980
  beforeStart: async () => {
1999
1981
  const lockedState = await getPersistedThreadState(threadId);
2000
1982
  const lockedConversation = coerceThreadConversationState(lockedState);
@@ -2093,7 +2075,7 @@ async function resumeAuthorizedMcpTurn(args) {
2093
2075
  sliceId: lockedSessionRecord.sliceId,
2094
2076
  messageTs: lockedMessageTs,
2095
2077
  inputMessageIds: [lockedUserMessage.id],
2096
- replyContext: {
2078
+ run: {
2097
2079
  instruction: {
2098
2080
  text: lockedUserMessage.text,
2099
2081
  context: lockedConversationContext,
@@ -2650,7 +2632,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
2650
2632
  messageTs: getTurnUserSlackMessageTs(userMessage),
2651
2633
  lockKey: stored.resumeConversationId,
2652
2634
  initialText: "",
2653
- agentRunner: options.agentRunner,
2635
+ executeTurn: async (run, saveResult, timeoutMs) => await executeTurn(options.agentRunner, run, saveResult, timeoutMs),
2654
2636
  beforeStart: async () => {
2655
2637
  const lockedState = await getPersistedThreadState(
2656
2638
  stored.resumeConversationId
@@ -2753,7 +2735,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
2753
2735
  sliceId: lockedSessionRecord.sliceId,
2754
2736
  messageTs: lockedMessageTs,
2755
2737
  inputMessageIds: [lockedUserMessage.id],
2756
- replyContext: {
2738
+ run: {
2757
2739
  instruction: {
2758
2740
  text: lockedUserMessage.text,
2759
2741
  context: lockedConversationContext,
@@ -3255,11 +3237,12 @@ export {
3255
3237
  getAssistantThreadContext,
3256
3238
  getMessageTs,
3257
3239
  shouldKeepProcessingReactionForToolInvocation,
3258
- startSlackProcessingReaction,
3240
+ startProcessingReaction,
3259
3241
  buildAuthPauseResponse,
3260
3242
  resumeSlackTurn,
3261
3243
  getPausedTurnRequest,
3262
3244
  wakePausedTurn,
3245
+ createPausedTurns,
3263
3246
  GET,
3264
3247
  publishAppHomeView,
3265
3248
  GET2,