@sentry/junior 0.184.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.
- package/dist/{agent-hooks-XTZVALGQ.js → agent-hooks-NGZQLL5O.js} +13 -11
- package/dist/api/acp/schema.d.ts +20 -2
- package/dist/api/code/overview.d.ts +39 -0
- package/dist/api/locations/detail.d.ts +1 -1
- package/dist/api/people/code.d.ts +22 -0
- package/dist/api/schema/code.d.ts +46 -0
- package/dist/api/schema/conversation.d.ts +100 -20
- package/dist/api/schema/location.d.ts +1 -1
- package/dist/api/schema/person.d.ts +1 -1
- package/dist/api/schema.d.ts +4 -4
- package/dist/api/schema.js +12 -1
- package/dist/api.js +358 -76
- package/dist/app.js +406 -377
- package/dist/{catalog-runtime-5357XR4F.js → catalog-runtime-AAEAO2RL.js} +4 -4
- package/dist/chat/api-turns/accepted-reply.d.ts +11 -0
- package/dist/chat/api-turns/cancellation.d.ts +3 -5
- package/dist/chat/api-turns/work.d.ts +4 -9
- package/dist/chat/app/conversation-work.d.ts +1 -1
- package/dist/chat/app/factory.d.ts +4 -0
- package/dist/chat/app/services.d.ts +4 -3
- package/dist/chat/conversations/history.d.ts +83 -9
- package/dist/chat/conversations/turn-lifecycle.d.ts +4 -3
- package/dist/chat/providers/slack/input.d.ts +32 -0
- package/dist/chat/{runtime → providers/slack}/processing-reaction.d.ts +6 -8
- package/dist/chat/{runtime/slack-resume.d.ts → providers/slack/resume.d.ts} +16 -19
- package/dist/chat/providers/slack/runtime.d.ts +1 -10
- package/dist/chat/providers/slack/turn.d.ts +11 -24
- package/dist/chat/resource-events/store.d.ts +1 -1
- package/dist/chat/resource-events/tool-support.d.ts +0 -5
- package/dist/chat/runtime/turn-execution.d.ts +7 -2
- package/dist/chat/sandbox/egress/credentials.d.ts +3 -3
- package/dist/chat/sandbox/egress/session.d.ts +5 -6
- package/dist/chat/scheduled-tasks/tool-support.d.ts +5 -5
- package/dist/chat/scheduled-tasks/tools/create.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/delete.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/list.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/run-now.d.ts +2 -2
- package/dist/chat/scheduled-tasks/tools/update.d.ts +2 -2
- package/dist/chat/scheduled-tasks/types.d.ts +1 -1
- package/dist/chat/services/provider-retry.d.ts +2 -0
- package/dist/chat/services/turn-failure-response.d.ts +4 -0
- package/dist/chat/task-execution/paused-turn.d.ts +0 -2
- package/dist/chat/task-execution/state.d.ts +2 -2
- package/dist/chat/task-execution/store.d.ts +1 -1
- package/dist/chat/task-execution/turn-wake.d.ts +12 -0
- package/dist/chat/tool-support/action-review.d.ts +1 -1
- package/dist/chat/tools/resource-events.d.ts +1 -1
- package/dist/chat/tools/search-conversation-events.d.ts +1 -1
- package/dist/chat/tools/types.d.ts +1 -1
- package/dist/chat/tools/watch-resource-events.d.ts +2 -2
- package/dist/{chunk-FKEZZMXS.js → chunk-4HA36IWS.js} +9 -94
- package/dist/{chunk-WVIA7V3M.js → chunk-4K25ODAO.js} +27 -1
- package/dist/{chunk-UF6BUA5W.js → chunk-4S47VHJR.js} +3 -3
- package/dist/{chunk-JNO2GUDS.js → chunk-6DOAUXLD.js} +231 -198
- package/dist/{chunk-M3QYTBQ6.js → chunk-6Q7YZLCL.js} +2 -1
- package/dist/{chunk-6VOYP4M6.js → chunk-7GAP2XG4.js} +1 -1
- package/dist/{chunk-LHXIZLFF.js → chunk-7MHNIGHP.js} +1 -1
- package/dist/{chunk-IZDYYYGP.js → chunk-ABAX75GG.js} +10 -384
- package/dist/{chunk-WQFEWULF.js → chunk-ATUWN6Z3.js} +2 -2
- package/dist/{chunk-4RONS3WR.js → chunk-C6TS47CQ.js} +4 -4
- package/dist/chunk-D4YV5TDV.js +45 -0
- package/dist/{chunk-Z3QAXJR7.js → chunk-D63IUQQE.js} +4 -4
- package/dist/{chunk-M5YWNMTE.js → chunk-DAPC2HTM.js} +24 -6
- package/dist/{chunk-BHYRYYLY.js → chunk-EIJCPJOY.js} +1 -1
- package/dist/{chunk-SHJK75Z2.js → chunk-EJYP3NQ4.js} +4 -4
- package/dist/{chunk-K7VDC2QW.js → chunk-EWEH2PJW.js} +6 -6
- package/dist/{chunk-6WGC3SO4.js → chunk-FFHXG2FX.js} +13 -11
- package/dist/{chunk-MLSQX2EX.js → chunk-FTVMXDNN.js} +1 -1
- package/dist/chunk-GFBR4S3Q.js +406 -0
- package/dist/{chunk-PJPRXO2T.js → chunk-GJTIZQGJ.js} +1 -1
- package/dist/{chunk-BT53RIGJ.js → chunk-HJPC32TQ.js} +12 -50
- package/dist/{chunk-RF6J3DIO.js → chunk-INQHUE72.js} +84 -1
- package/dist/{chunk-6UDPINOX.js → chunk-LRI5IRGY.js} +19 -44
- package/dist/{chunk-BCHYQS4B.js → chunk-LVK4WJKM.js} +1 -1
- package/dist/{chunk-UBOIHNTH.js → chunk-MWOH6CIK.js} +178 -148
- package/dist/{chunk-3S7ULUWW.js → chunk-OMQ2J6F6.js} +1 -1
- package/dist/{chunk-DUKIDPF6.js → chunk-PNYJOEVV.js} +1 -1
- package/dist/{chunk-MAPJFUMV.js → chunk-QCT4226Q.js} +3 -3
- package/dist/{chunk-HIPUIPJM.js → chunk-QZKHHG3B.js} +34 -8
- package/dist/{chunk-QABCY33S.js → chunk-TVVAMOLS.js} +2 -2
- package/dist/{chunk-JA43DV4Y.js → chunk-U4CTAVWN.js} +1 -1
- package/dist/{chunk-LCP4EDKR.js → chunk-UUULGCKK.js} +1 -1
- package/dist/{chunk-4CNDGK25.js → chunk-VH4IU3UC.js} +928 -984
- package/dist/chunk-W7GCLNIV.js +58 -0
- package/dist/{chunk-2ZQPVX7C.js → chunk-WLKWN4CD.js} +22 -12
- package/dist/{chunk-ACPDVEJO.js → chunk-X2SS6BF7.js} +198 -209
- package/dist/{chunk-YKX6MTLU.js → chunk-X7NCJQAA.js} +1 -1
- package/dist/{chunk-E57WPXWY.js → chunk-Y5G23T2D.js} +5 -5
- package/dist/{chunk-HUXFMDBZ.js → chunk-ZIF2S464.js} +1 -1
- package/dist/{chunk-JM2COLGC.js → chunk-ZKKGFUWM.js} +6 -6
- package/dist/cli/chat.js +35 -33
- package/dist/cli/check.js +5 -5
- package/dist/cli/plugins.js +14 -12
- package/dist/cli/snapshot-create.js +10 -9
- package/dist/cli/upgrade.js +7 -6
- package/dist/{db-MA52H62H.js → db-TRJ77FAU.js} +8 -6
- package/dist/instrumentation.js +3 -3
- package/dist/nitro.js +7 -6
- package/dist/{oauth-callback-server-DXGHKN6S.js → oauth-callback-server-XD5SV3MS.js} +30 -27
- package/dist/{runner-4IXUAQNK.js → runner-KFX7NG6D.js} +24 -19
- package/dist/{skills-X3DY7AXO.js → skills-J2AH26CW.js} +5 -5
- package/dist/spawn-VU3CSRI6.js +41 -0
- package/dist/task-runner-5JG3VIIY.js +34 -0
- package/dist/{validation-Z6JXSTJS.js → validation-O5J4VOPF.js} +5 -5
- package/dist/version.js +1 -1
- package/dist/{work-OKWRFBDW.js → work-ECPQTG3U.js} +24 -19
- package/dist/worker-RS3DXUDO.js +24 -0
- package/package.json +4 -4
- package/dist/spawn-43WGS6CH.js +0 -37
- package/dist/task-runner-VDRKITPV.js +0 -32
- package/dist/worker-B236AE72.js +0 -22
|
@@ -4,7 +4,11 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
buildSentryConversationUrl,
|
|
6
6
|
deleteWebAuthorization
|
|
7
|
-
} from "./chunk-
|
|
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-
|
|
22
|
+
} from "./chunk-DAPC2HTM.js";
|
|
19
23
|
import {
|
|
20
24
|
resolveTurnSessionRouting,
|
|
21
25
|
scheduleSessionCompletedPluginTasks
|
|
22
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-FFHXG2FX.js";
|
|
23
27
|
import {
|
|
24
28
|
ConversationTurnLifecycleService
|
|
25
|
-
} from "./chunk-
|
|
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-
|
|
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
|
-
|
|
44
|
-
} from "./chunk-FKEZZMXS.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-
|
|
60
|
+
} from "./chunk-ZKKGFUWM.js";
|
|
61
61
|
import {
|
|
62
62
|
parseSlackThreadId,
|
|
63
63
|
readSlackRawMessageContext,
|
|
64
64
|
resolveSlackChannelIdFromMessage,
|
|
65
65
|
resolveSlackChannelIdFromThreadId
|
|
66
|
-
} from "./chunk-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
124
|
+
} from "./chunk-ABAX75GG.js";
|
|
122
125
|
import {
|
|
123
126
|
acquireActiveLock,
|
|
124
127
|
getStateAdapter
|
|
125
|
-
} from "./chunk-
|
|
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-
|
|
135
|
+
} from "./chunk-LRI5IRGY.js";
|
|
136
|
+
import {
|
|
137
|
+
defaultModelId
|
|
138
|
+
} from "./chunk-D4YV5TDV.js";
|
|
134
139
|
import {
|
|
135
140
|
discoverSkills
|
|
136
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-ATUWN6Z3.js";
|
|
137
142
|
import {
|
|
138
143
|
pluginCatalogRuntime
|
|
139
|
-
} from "./chunk-
|
|
144
|
+
} from "./chunk-GJTIZQGJ.js";
|
|
140
145
|
import {
|
|
141
146
|
buildOAuthTokenRequest,
|
|
142
147
|
hasRequiredOAuthScope,
|
|
143
148
|
parseOAuthTokenResponse
|
|
144
|
-
} from "./chunk-
|
|
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-
|
|
168
|
+
} from "./chunk-OMQ2J6F6.js";
|
|
164
169
|
|
|
165
170
|
// src/chat/slack/assistant-thread/status-render.ts
|
|
166
171
|
var DEFAULT_STATUS_CONTEXTS = {
|
|
@@ -970,7 +975,7 @@ function getMessageTs(message) {
|
|
|
970
975
|
return void 0;
|
|
971
976
|
}
|
|
972
977
|
|
|
973
|
-
// src/chat/
|
|
978
|
+
// src/chat/providers/slack/processing-reaction.ts
|
|
974
979
|
var noProcessingReaction = {
|
|
975
980
|
complete: async () => void 0,
|
|
976
981
|
keep: () => void 0,
|
|
@@ -982,7 +987,7 @@ function isProcessingReactionEmoji(value) {
|
|
|
982
987
|
function shouldKeepProcessingReactionForToolInvocation(input) {
|
|
983
988
|
return input.toolName === "addReaction" && isProcessingReactionEmoji(input.params.emoji);
|
|
984
989
|
}
|
|
985
|
-
async function
|
|
990
|
+
async function startProcessingReaction(args) {
|
|
986
991
|
if (args.message.author.isMe) {
|
|
987
992
|
return noProcessingReaction;
|
|
988
993
|
}
|
|
@@ -991,13 +996,12 @@ async function startSlackProcessingReaction(args) {
|
|
|
991
996
|
if (!channelId || !messageTs) {
|
|
992
997
|
return noProcessingReaction;
|
|
993
998
|
}
|
|
994
|
-
return
|
|
999
|
+
return startProcessingReactionForMessage({
|
|
995
1000
|
channelId,
|
|
996
|
-
timestamp: messageTs
|
|
997
|
-
logException: args.logException
|
|
1001
|
+
timestamp: messageTs
|
|
998
1002
|
});
|
|
999
1003
|
}
|
|
1000
|
-
async function
|
|
1004
|
+
async function startProcessingReactionForMessage(args) {
|
|
1001
1005
|
try {
|
|
1002
1006
|
await addReactionToMessage({
|
|
1003
1007
|
channelId: args.channelId,
|
|
@@ -1005,7 +1009,7 @@ async function startSlackProcessingReactionForMessage(args) {
|
|
|
1005
1009
|
emoji: getChatConfig().slack.processingReactionEmoji
|
|
1006
1010
|
});
|
|
1007
1011
|
} catch (error) {
|
|
1008
|
-
|
|
1012
|
+
logException(error, "slack.processing.reaction_add.failed", {
|
|
1009
1013
|
"app.slack.action": "reactions.add",
|
|
1010
1014
|
"messaging.message.id": args.timestamp,
|
|
1011
1015
|
...getSlackErrorObservabilityAttributes(error)
|
|
@@ -1025,7 +1029,7 @@ async function startSlackProcessingReactionForMessage(args) {
|
|
|
1025
1029
|
});
|
|
1026
1030
|
return true;
|
|
1027
1031
|
} catch (error) {
|
|
1028
|
-
|
|
1032
|
+
logException(error, "slack.processing.reaction_remove.failed", {
|
|
1029
1033
|
"app.slack.action": "reactions.remove",
|
|
1030
1034
|
"messaging.message.id": args.timestamp,
|
|
1031
1035
|
...getSlackErrorObservabilityAttributes(error)
|
|
@@ -1047,7 +1051,7 @@ async function startSlackProcessingReactionForMessage(args) {
|
|
|
1047
1051
|
emoji: getChatConfig().slack.completedReactionEmoji
|
|
1048
1052
|
});
|
|
1049
1053
|
} catch (error) {
|
|
1050
|
-
|
|
1054
|
+
logException(error, "slack.processing.reaction_complete.failed", {
|
|
1051
1055
|
"app.slack.action": "reactions.add",
|
|
1052
1056
|
"messaging.message.id": args.timestamp,
|
|
1053
1057
|
...getSlackErrorObservabilityAttributes(error)
|
|
@@ -1086,11 +1090,8 @@ function buildAuthPauseResponse(slackUserId, providerDisplayName, requestText) {
|
|
|
1086
1090
|
I sent you a link.`;
|
|
1087
1091
|
}
|
|
1088
1092
|
|
|
1089
|
-
// src/chat/
|
|
1090
|
-
function resolveReplyTimeoutMs(
|
|
1091
|
-
if (typeof explicitTimeoutMs === "number" && explicitTimeoutMs > 0) {
|
|
1092
|
-
return explicitTimeoutMs;
|
|
1093
|
-
}
|
|
1093
|
+
// src/chat/providers/slack/resume.ts
|
|
1094
|
+
function resolveReplyTimeoutMs() {
|
|
1094
1095
|
const raw = process.env.EVAL_AGENT_REPLY_TIMEOUT_MS?.trim();
|
|
1095
1096
|
if (!raw) {
|
|
1096
1097
|
return void 0;
|
|
@@ -1130,7 +1131,7 @@ function createReadOnlyConfigService(rawValues) {
|
|
|
1130
1131
|
return {
|
|
1131
1132
|
get: async (key) => entries.find((entry) => entry.key === key),
|
|
1132
1133
|
set: async () => {
|
|
1133
|
-
throw new Error("
|
|
1134
|
+
throw new Error("Configuration is read-only for a resumed Run");
|
|
1134
1135
|
},
|
|
1135
1136
|
unset: async () => false,
|
|
1136
1137
|
list: async ({ prefix } = {}) => entries.filter((entry) => !prefix || entry.key.startsWith(prefix)),
|
|
@@ -1148,7 +1149,7 @@ function createReadOnlyConfigService(rawValues) {
|
|
|
1148
1149
|
}
|
|
1149
1150
|
var ResumeTurnBusyError = class extends Error {
|
|
1150
1151
|
constructor(lockKey) {
|
|
1151
|
-
super(`
|
|
1152
|
+
super(`Another worker is already resuming Slack Turn "${lockKey}"`);
|
|
1152
1153
|
this.name = "ResumeTurnBusyError";
|
|
1153
1154
|
}
|
|
1154
1155
|
};
|
|
@@ -1156,7 +1157,7 @@ function getDefaultLockKey(channelId, threadTs) {
|
|
|
1156
1157
|
return threadTs ? `slack:${channelId}:${threadTs}` : `slack:${channelId}`;
|
|
1157
1158
|
}
|
|
1158
1159
|
function getResumeLogContext(args, lockKey) {
|
|
1159
|
-
const actor = args.
|
|
1160
|
+
const actor = args.run?.actor;
|
|
1160
1161
|
return {
|
|
1161
1162
|
conversationId: args.conversationId,
|
|
1162
1163
|
messageConversationId: lockKey,
|
|
@@ -1179,7 +1180,7 @@ async function handleResumeFailure(args) {
|
|
|
1179
1180
|
const eventId = requireTurnFailureEventId(capturedEventId, args.eventName);
|
|
1180
1181
|
let failureStatePersistError;
|
|
1181
1182
|
try {
|
|
1182
|
-
await args.
|
|
1183
|
+
await args.resume.onFailure?.(args.error);
|
|
1183
1184
|
} catch (persistError) {
|
|
1184
1185
|
const persistEventId = logException(
|
|
1185
1186
|
persistError,
|
|
@@ -1188,8 +1189,8 @@ async function handleResumeFailure(args) {
|
|
|
1188
1189
|
);
|
|
1189
1190
|
try {
|
|
1190
1191
|
await args.turnLifecycle.fail({
|
|
1191
|
-
conversationId: args.
|
|
1192
|
-
turnId: args.
|
|
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.
|
|
1209
|
-
threadTs: args.
|
|
1209
|
+
channelId: args.resume.channelId,
|
|
1210
|
+
threadTs: args.resume.threadTs,
|
|
1210
1211
|
eventId,
|
|
1211
1212
|
error: args.error
|
|
1212
1213
|
});
|
|
@@ -1218,8 +1219,8 @@ async function handleResumeFailure(args) {
|
|
|
1218
1219
|
);
|
|
1219
1220
|
try {
|
|
1220
1221
|
await args.turnLifecycle.fail({
|
|
1221
|
-
conversationId: args.
|
|
1222
|
-
turnId: args.
|
|
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
|
|
@@ -1237,35 +1238,35 @@ async function handleResumeFailure(args) {
|
|
|
1237
1238
|
throw failureStatePersistError;
|
|
1238
1239
|
}
|
|
1239
1240
|
await args.turnLifecycle.fail({
|
|
1240
|
-
conversationId: args.
|
|
1241
|
-
turnId: args.
|
|
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
|
|
1248
|
-
const
|
|
1249
|
-
if (!
|
|
1250
|
-
throw new TypeError("Slack resume requires a
|
|
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 (!
|
|
1253
|
-
throw new TypeError("Slack resume requires a
|
|
1253
|
+
if (!savedRun.source) {
|
|
1254
|
+
throw new TypeError("Slack resume requires a Run Source");
|
|
1254
1255
|
}
|
|
1255
|
-
const source =
|
|
1256
|
-
if (
|
|
1257
|
-
throw new TypeError("Slack resume requires a Slack
|
|
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 =
|
|
1262
|
-
const priorOnEvent =
|
|
1262
|
+
const persistedLocationConfiguration = savedRun.environment?.locationConfiguration ?? (savedRun.environment?.configuration ? createReadOnlyConfigService(savedRun.environment.configuration) : void 0);
|
|
1263
|
+
const priorOnEvent = savedRun.onEvent;
|
|
1263
1264
|
return {
|
|
1264
|
-
...
|
|
1265
|
+
...savedRun,
|
|
1265
1266
|
conversationId: args.conversationId,
|
|
1266
1267
|
turnId: args.turnId,
|
|
1267
1268
|
instruction: {
|
|
1268
|
-
...
|
|
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:
|
|
1277
|
+
deadlineAtMs: savedRun.deadlineAtMs ?? requestDeadline?.deadlineAtMs,
|
|
1277
1278
|
environment: {
|
|
1278
|
-
...
|
|
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
|
-
...
|
|
1290
|
+
...savedRun.durability,
|
|
1290
1291
|
onSandboxRefChanged: async (sandboxRef) => {
|
|
1291
1292
|
await persistThreadStateById(threadId, {
|
|
1292
1293
|
sandboxRef
|
|
1293
1294
|
});
|
|
1294
|
-
await
|
|
1295
|
+
await savedRun.durability?.onSandboxRefChanged?.(sandboxRef);
|
|
1295
1296
|
}
|
|
1296
1297
|
}
|
|
1297
1298
|
};
|
|
@@ -1321,8 +1322,11 @@ 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 =
|
|
1327
|
+
const turnLifecycle = new ConversationTurnLifecycleService(
|
|
1328
|
+
getConversationEventStore()
|
|
1329
|
+
);
|
|
1326
1330
|
let failureCode = "agent_run_failed";
|
|
1327
1331
|
let runArgs = args;
|
|
1328
1332
|
try {
|
|
@@ -1334,36 +1338,33 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1334
1338
|
runArgs = { ...args, ...preparedArgs };
|
|
1335
1339
|
}
|
|
1336
1340
|
setTags(getResumeLogContext(runArgs, lockKey));
|
|
1337
|
-
const
|
|
1338
|
-
if (!
|
|
1339
|
-
throw new Error("Resumed
|
|
1341
|
+
const savedRun = runArgs.run;
|
|
1342
|
+
if (!savedRun) {
|
|
1343
|
+
throw new Error("Resumed Turn requires a saved Run");
|
|
1340
1344
|
}
|
|
1341
|
-
const credentialContext =
|
|
1345
|
+
const credentialContext = savedRun.credentialContext;
|
|
1342
1346
|
if (!credentialContext) {
|
|
1343
|
-
throw new Error("Resumed
|
|
1347
|
+
throw new Error("Resumed Run requires a credential context");
|
|
1344
1348
|
}
|
|
1345
|
-
const routingActor =
|
|
1349
|
+
const routingActor = savedRun.actor;
|
|
1346
1350
|
let resumeActor;
|
|
1347
1351
|
if ("type" in credentialContext.actor) {
|
|
1348
1352
|
if (!isUserActor(routingActor) || credentialContext.actor.userId !== routingActor.userId) {
|
|
1349
|
-
throw new Error(
|
|
1350
|
-
"Resumed turn credential actor must match replyContext.actor.userId"
|
|
1351
|
-
);
|
|
1353
|
+
throw new Error("Resumed Run credential actor must match its Actor");
|
|
1352
1354
|
}
|
|
1353
1355
|
resumeActor = routingActor;
|
|
1354
1356
|
} else {
|
|
1355
1357
|
if (routingActor && (routingActor.platform !== "system" || routingActor.name !== credentialContext.actor.name)) {
|
|
1356
1358
|
throw new Error(
|
|
1357
|
-
"Resumed
|
|
1359
|
+
"Resumed Run system credential actor must match its Actor"
|
|
1358
1360
|
);
|
|
1359
1361
|
}
|
|
1360
1362
|
resumeActor = credentialContext.actor;
|
|
1361
1363
|
}
|
|
1362
1364
|
if (runArgs.messageTs) {
|
|
1363
|
-
processingReaction = await
|
|
1365
|
+
processingReaction = await startProcessingReactionForMessage({
|
|
1364
1366
|
channelId: runArgs.channelId,
|
|
1365
|
-
timestamp: runArgs.messageTs
|
|
1366
|
-
logException
|
|
1367
|
+
timestamp: runArgs.messageTs
|
|
1367
1368
|
});
|
|
1368
1369
|
}
|
|
1369
1370
|
if (runArgs.initialText) {
|
|
@@ -1417,11 +1418,11 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1417
1418
|
const deliveryState2 = await getDeliveryConversation();
|
|
1418
1419
|
let slackMessageTs = [];
|
|
1419
1420
|
try {
|
|
1420
|
-
if (runArgs.
|
|
1421
|
+
if (runArgs.run?.publishExternally !== false) {
|
|
1421
1422
|
slackMessageTs = await sendSlackReply({
|
|
1422
1423
|
channelId: runArgs.channelId,
|
|
1423
1424
|
conversationId: runArgs.conversationId,
|
|
1424
|
-
replyAttribution: runArgs.
|
|
1425
|
+
replyAttribution: runArgs.run?.dispatch?.replyAttribution,
|
|
1425
1426
|
text,
|
|
1426
1427
|
threadTs: runArgs.threadTs
|
|
1427
1428
|
});
|
|
@@ -1448,7 +1449,7 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1448
1449
|
});
|
|
1449
1450
|
}
|
|
1450
1451
|
try {
|
|
1451
|
-
const destination = runArgs.
|
|
1452
|
+
const destination = runArgs.run?.destination;
|
|
1452
1453
|
const providerConversationIds = runArgs.threadTs ? [runArgs.threadTs] : slackMessageTs;
|
|
1453
1454
|
await persistWithRetry(
|
|
1454
1455
|
() => commitAcceptedReply({
|
|
@@ -1456,7 +1457,7 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1456
1457
|
conversation: deliveryState2.conversation,
|
|
1457
1458
|
conversationMessageId: recordedMessageId,
|
|
1458
1459
|
conversationId,
|
|
1459
|
-
...runArgs.
|
|
1460
|
+
...runArgs.run?.dispatch && destination?.platform === "slack" && providerConversationIds.length > 0 ? {
|
|
1460
1461
|
providerConversationBindings: providerConversationIds.map(
|
|
1461
1462
|
(providerConversationId) => ({
|
|
1462
1463
|
provider: "slack",
|
|
@@ -1475,22 +1476,21 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1475
1476
|
{ "error.type": error instanceof Error ? error.name : typeof error }
|
|
1476
1477
|
);
|
|
1477
1478
|
}
|
|
1478
|
-
const
|
|
1479
|
-
|
|
1480
|
-
if (messageTs && dispatchId && replyContext2) {
|
|
1479
|
+
const dispatchId = savedRun.dispatch?.id;
|
|
1480
|
+
if (messageTs && dispatchId) {
|
|
1481
1481
|
try {
|
|
1482
1482
|
await persistWithRetry(
|
|
1483
1483
|
() => recordTurnSummary({
|
|
1484
1484
|
conversationId: runArgs.conversationId,
|
|
1485
|
-
destination:
|
|
1486
|
-
destinationVisibility:
|
|
1485
|
+
destination: savedRun.destination,
|
|
1486
|
+
destinationVisibility: savedRun.destinationVisibility,
|
|
1487
1487
|
dispatchId,
|
|
1488
1488
|
resultMessageId: messageTs,
|
|
1489
1489
|
turnId: runArgs.turnId,
|
|
1490
1490
|
sliceId: runArgs.sliceId ?? 1,
|
|
1491
|
-
source:
|
|
1491
|
+
source: savedRun.source,
|
|
1492
1492
|
state: "running",
|
|
1493
|
-
surface:
|
|
1493
|
+
surface: savedRun.surface ?? "slack"
|
|
1494
1494
|
})
|
|
1495
1495
|
);
|
|
1496
1496
|
} catch (error) {
|
|
@@ -1504,11 +1504,7 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1504
1504
|
deliveryState.conversation,
|
|
1505
1505
|
sessionId
|
|
1506
1506
|
);
|
|
1507
|
-
const
|
|
1508
|
-
runArgs,
|
|
1509
|
-
status,
|
|
1510
|
-
deliverAssistantMessage
|
|
1511
|
-
);
|
|
1507
|
+
const run = buildResumedRun(runArgs, status, deliverAssistantMessage);
|
|
1512
1508
|
if (runArgs.inputMessageIds?.length) {
|
|
1513
1509
|
await turnLifecycle.start({
|
|
1514
1510
|
conversationId: runArgs.conversationId,
|
|
@@ -1518,10 +1514,70 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1518
1514
|
surface: "slack"
|
|
1519
1515
|
});
|
|
1520
1516
|
}
|
|
1521
|
-
const replyTimeoutMs = resolveReplyTimeoutMs(
|
|
1522
|
-
const outcome = await
|
|
1523
|
-
|
|
1524
|
-
|
|
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
|
+
},
|
|
1525
1581
|
replyTimeoutMs
|
|
1526
1582
|
);
|
|
1527
1583
|
if (outcome.status !== "completed") {
|
|
@@ -1540,7 +1596,7 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1540
1596
|
});
|
|
1541
1597
|
};
|
|
1542
1598
|
} else if (outcome.status === "suspended") {
|
|
1543
|
-
if (runArgs.ownsConversationLease && (outcome.reason === "timeout" ||
|
|
1599
|
+
if (runArgs.ownsConversationLease && (outcome.reason === "timeout" || savedRun.durability?.shouldYield?.())) {
|
|
1544
1600
|
throw new CooperativeTurnYieldError();
|
|
1545
1601
|
}
|
|
1546
1602
|
if (onSuspend) {
|
|
@@ -1550,124 +1606,51 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1550
1606
|
} else {
|
|
1551
1607
|
deferredFailureHandler = async () => {
|
|
1552
1608
|
await handleResumeFailure({
|
|
1553
|
-
|
|
1554
|
-
error: new Error(
|
|
1555
|
-
`Resumed run ended suspended without a pause handler`
|
|
1556
|
-
),
|
|
1609
|
+
error: new Error("Resumed Run ended suspended without onSuspend"),
|
|
1557
1610
|
eventName: "slack.resume.turn.failed",
|
|
1558
1611
|
failureCode: "agent_run_failed",
|
|
1559
1612
|
turnLifecycle,
|
|
1560
|
-
|
|
1561
|
-
resumeArgs: runArgs
|
|
1613
|
+
resume: runArgs
|
|
1562
1614
|
});
|
|
1563
1615
|
};
|
|
1564
1616
|
}
|
|
1565
1617
|
} else {
|
|
1566
1618
|
deferredFailureHandler = async () => {
|
|
1567
1619
|
await handleResumeFailure({
|
|
1568
|
-
body: "Failed to resume Slack turn",
|
|
1569
1620
|
error: new Error(
|
|
1570
|
-
`Resumed
|
|
1621
|
+
`Resumed Run ended ${outcome.status} without its required callback`
|
|
1571
1622
|
),
|
|
1572
1623
|
eventName: "slack.resume.turn.failed",
|
|
1573
1624
|
failureCode: "agent_run_failed",
|
|
1574
1625
|
turnLifecycle,
|
|
1575
|
-
|
|
1576
|
-
resumeArgs: runArgs
|
|
1626
|
+
resume: runArgs
|
|
1577
1627
|
});
|
|
1578
1628
|
};
|
|
1579
1629
|
}
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
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({
|
|
1630
|
+
}
|
|
1631
|
+
if (shouldScheduleCompletedPluginTasks) {
|
|
1632
|
+
try {
|
|
1633
|
+
const params = {
|
|
1637
1634
|
conversationId: runArgs.conversationId,
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
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
|
-
}
|
|
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
|
+
);
|
|
1661
1643
|
}
|
|
1662
1644
|
}
|
|
1663
1645
|
} catch (error) {
|
|
1664
1646
|
await status.clear();
|
|
1665
|
-
|
|
1647
|
+
const runError = error instanceof AgentRunError ? error.cause : error;
|
|
1648
|
+
if (isCooperativeTurnYieldError(runError)) {
|
|
1666
1649
|
if (lock) {
|
|
1667
1650
|
await stateAdapter.releaseLock(lock);
|
|
1668
1651
|
}
|
|
1669
1652
|
await processingReaction?.stop();
|
|
1670
|
-
throw
|
|
1653
|
+
throw runError;
|
|
1671
1654
|
}
|
|
1672
1655
|
if (runResultHandled) {
|
|
1673
1656
|
postDeliveryCommitError = error;
|
|
@@ -1682,13 +1665,11 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1682
1665
|
} else {
|
|
1683
1666
|
deferredFailureHandler = async () => {
|
|
1684
1667
|
await handleResumeFailure({
|
|
1685
|
-
|
|
1686
|
-
error,
|
|
1668
|
+
error: runError,
|
|
1687
1669
|
eventName: "slack.resume.turn.failed",
|
|
1688
1670
|
failureCode,
|
|
1689
1671
|
turnLifecycle,
|
|
1690
|
-
|
|
1691
|
-
resumeArgs: runArgs
|
|
1672
|
+
resume: runArgs
|
|
1692
1673
|
});
|
|
1693
1674
|
};
|
|
1694
1675
|
}
|
|
@@ -1729,19 +1710,17 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1729
1710
|
deferredAuthInfo.requestText
|
|
1730
1711
|
),
|
|
1731
1712
|
runArgs.conversationId,
|
|
1732
|
-
runArgs.
|
|
1713
|
+
runArgs.run?.dispatch?.replyAttribution
|
|
1733
1714
|
);
|
|
1734
1715
|
}
|
|
1735
1716
|
return true;
|
|
1736
1717
|
} catch (pauseError) {
|
|
1737
1718
|
await handleResumeFailure({
|
|
1738
|
-
body: "Failed to handle resumed turn pause",
|
|
1739
1719
|
error: pauseError,
|
|
1740
1720
|
eventName: "slack.resume.pause_handler.failed",
|
|
1741
1721
|
failureCode: "persistence_failed",
|
|
1742
1722
|
turnLifecycle,
|
|
1743
|
-
|
|
1744
|
-
resumeArgs: runArgs
|
|
1723
|
+
resume: runArgs
|
|
1745
1724
|
});
|
|
1746
1725
|
return true;
|
|
1747
1726
|
}
|
|
@@ -1807,6 +1786,15 @@ async function wakePausedTurn(request, options = {}) {
|
|
|
1807
1786
|
state: options.state
|
|
1808
1787
|
});
|
|
1809
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
|
+
}
|
|
1810
1798
|
|
|
1811
1799
|
// src/handlers/oauth-html.ts
|
|
1812
1800
|
function htmlCallbackResponse(title, message, status, options = {}) {
|
|
@@ -1994,7 +1982,7 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
1994
1982
|
messageTs: getTurnUserSlackMessageTs(userMessage),
|
|
1995
1983
|
lockKey: threadId,
|
|
1996
1984
|
initialText: "",
|
|
1997
|
-
agentRunner,
|
|
1985
|
+
executeTurn: async (run, saveResult, timeoutMs) => await executeTurn(agentRunner, run, saveResult, timeoutMs),
|
|
1998
1986
|
beforeStart: async () => {
|
|
1999
1987
|
const lockedState = await getPersistedThreadState(threadId);
|
|
2000
1988
|
const lockedConversation = coerceThreadConversationState(lockedState);
|
|
@@ -2093,7 +2081,7 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
2093
2081
|
sliceId: lockedSessionRecord.sliceId,
|
|
2094
2082
|
messageTs: lockedMessageTs,
|
|
2095
2083
|
inputMessageIds: [lockedUserMessage.id],
|
|
2096
|
-
|
|
2084
|
+
run: {
|
|
2097
2085
|
instruction: {
|
|
2098
2086
|
text: lockedUserMessage.text,
|
|
2099
2087
|
context: lockedConversationContext,
|
|
@@ -2650,7 +2638,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
2650
2638
|
messageTs: getTurnUserSlackMessageTs(userMessage),
|
|
2651
2639
|
lockKey: stored.resumeConversationId,
|
|
2652
2640
|
initialText: "",
|
|
2653
|
-
|
|
2641
|
+
executeTurn: async (run, saveResult, timeoutMs) => await executeTurn(options.agentRunner, run, saveResult, timeoutMs),
|
|
2654
2642
|
beforeStart: async () => {
|
|
2655
2643
|
const lockedState = await getPersistedThreadState(
|
|
2656
2644
|
stored.resumeConversationId
|
|
@@ -2753,7 +2741,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
2753
2741
|
sliceId: lockedSessionRecord.sliceId,
|
|
2754
2742
|
messageTs: lockedMessageTs,
|
|
2755
2743
|
inputMessageIds: [lockedUserMessage.id],
|
|
2756
|
-
|
|
2744
|
+
run: {
|
|
2757
2745
|
instruction: {
|
|
2758
2746
|
text: lockedUserMessage.text,
|
|
2759
2747
|
context: lockedConversationContext,
|
|
@@ -3255,11 +3243,12 @@ export {
|
|
|
3255
3243
|
getAssistantThreadContext,
|
|
3256
3244
|
getMessageTs,
|
|
3257
3245
|
shouldKeepProcessingReactionForToolInvocation,
|
|
3258
|
-
|
|
3246
|
+
startProcessingReaction,
|
|
3259
3247
|
buildAuthPauseResponse,
|
|
3260
3248
|
resumeSlackTurn,
|
|
3261
3249
|
getPausedTurnRequest,
|
|
3262
3250
|
wakePausedTurn,
|
|
3251
|
+
createPausedTurns,
|
|
3263
3252
|
GET,
|
|
3264
3253
|
publishAppHomeView,
|
|
3265
3254
|
GET2,
|