@sentry/junior 0.120.0 → 0.122.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-5DDPWRYO.js → agent-hooks-HJMLQLCB.js} +8 -8
- package/dist/api.js +14 -14
- package/dist/app.js +604 -997
- package/dist/{catalog-runtime-5KR5XBMJ.js → catalog-runtime-CYPZUYJD.js} +5 -5
- package/dist/chat/agent/index.d.ts +19 -2
- package/dist/chat/agent/request.d.ts +8 -8
- package/dist/chat/agent/resume.d.ts +1 -3
- package/dist/chat/agent/retry-usage.d.ts +8 -0
- package/dist/chat/agent/skills.d.ts +0 -9
- package/dist/chat/conversations/messages.d.ts +7 -0
- package/dist/chat/conversations/projection.d.ts +16 -0
- package/dist/chat/logging.d.ts +46 -13
- package/dist/chat/runtime/processing-reaction.d.ts +2 -4
- package/dist/chat/runtime/slack-runtime.d.ts +2 -2
- package/dist/chat/sandbox/noninteractive-command.d.ts +1 -0
- package/dist/chat/sandbox/session.d.ts +2 -2
- package/dist/chat/sandbox/snapshot/install.d.ts +2 -2
- package/dist/chat/sandbox/snapshot/resolve.d.ts +1 -0
- package/dist/chat/sandbox/workspace.d.ts +3 -1
- package/dist/chat/services/assistant-reply.d.ts +16 -0
- package/dist/chat/services/empty-output-continuation.d.ts +20 -0
- package/dist/chat/services/turn-failure-response.d.ts +1 -3
- package/dist/chat/services/turn-result.d.ts +0 -5
- package/dist/chat/services/turn-session-record.d.ts +0 -11
- package/dist/chat/tool-support/zod-tool.d.ts +11 -6
- package/dist/chat/tools/execute-tool.d.ts +1 -33
- package/dist/chat/tools/execution/tool-error-handler.d.ts +2 -2
- package/dist/chat/tools/query-conversation-events.d.ts +3 -1
- package/dist/chat/tools/sandbox/bash.d.ts +1 -33
- package/dist/chat/tools/sandbox/edit-file.d.ts +1 -33
- package/dist/chat/tools/sandbox/find-files.d.ts +1 -33
- package/dist/chat/tools/sandbox/grep.d.ts +1 -33
- package/dist/chat/tools/sandbox/list-dir.d.ts +1 -33
- package/dist/chat/tools/sandbox/read-file.d.ts +1 -33
- package/dist/chat/tools/sandbox/write-file.d.ts +1 -33
- package/dist/{chunk-VURFJVFH.js → chunk-2RFM7STT.js} +11 -22
- package/dist/{chunk-6WX5SPI3.js → chunk-32FPGM2V.js} +1 -1
- package/dist/{chunk-ALYQOZG7.js → chunk-4SPRQJOW.js} +37 -45
- package/dist/{chunk-QOQPPRFS.js → chunk-4TGVC42X.js} +133 -206
- package/dist/{chunk-Q3RL6A4E.js → chunk-BDE5RZVF.js} +2 -2
- package/dist/{chunk-DJDGDJDF.js → chunk-CYW4M6IV.js} +44 -23
- package/dist/{chunk-M243JMZH.js → chunk-DOB5RVMH.js} +2 -2
- package/dist/{chunk-EIVE6GL4.js → chunk-E5SRLZQV.js} +14 -29
- package/dist/{chunk-YEAOUT5W.js → chunk-GFTZKOTP.js} +1 -1
- package/dist/{chunk-XAI2HNAY.js → chunk-GN6WW7WR.js} +16 -31
- package/dist/{chunk-DMKHRBI6.js → chunk-ISQYBTPG.js} +3 -3
- package/dist/{chunk-DWOH57FW.js → chunk-L2KJ2GNL.js} +1 -1
- package/dist/{chunk-ERYVNWNE.js → chunk-NIJG6G6X.js} +621 -735
- package/dist/{chunk-JQWP6V22.js → chunk-NNGYYGX5.js} +2061 -2015
- package/dist/{chunk-GNNV3UTY.js → chunk-OKUZIXQM.js} +1 -1
- package/dist/{chunk-HDFGNU5E.js → chunk-S7G34U75.js} +3 -1
- package/dist/{chunk-ALAKN7LR.js → chunk-TZVZCIYL.js} +1 -1
- package/dist/{chunk-24B5R6OU.js → chunk-USKP7IM2.js} +49 -92
- package/dist/{chunk-BHXW734F.js → chunk-V6XPIKYA.js} +13 -19
- package/dist/{chunk-TKUCRFNX.js → chunk-VCC7XFX2.js} +22 -45
- package/dist/cli/chat.js +22 -22
- package/dist/cli/check.js +6 -6
- package/dist/cli/plugins.js +11 -11
- package/dist/cli/snapshot-create.js +9 -9
- package/dist/cli/upgrade.js +6 -6
- package/dist/{db-T4ZY64PB.js → db-E6O2DXUQ.js} +6 -6
- package/dist/instrumentation.js +3 -3
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-LQ6DFI26.js → oauth-callback-server-6SCPUFFD.js} +15 -15
- package/dist/{runner-D3ZU6TJH.js → runner-JFKCMVVY.js} +62 -51
- package/dist/{skills-JMXY7LIY.js → skills-RD66F2OB.js} +6 -6
- package/dist/{validation-OEPJS7JX.js → validation-XVRNX6IU.js} +6 -6
- package/dist/version.js +1 -1
- package/package.json +8 -8
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
persistAuthPauseTurnState,
|
|
14
14
|
requireTurnFailureEventId,
|
|
15
15
|
scheduleSessionCompletedPluginTasks
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-V6XPIKYA.js";
|
|
17
17
|
import {
|
|
18
18
|
buildSentryConversationUrl
|
|
19
19
|
} from "./chunk-4CODA7P5.js";
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
resolveBaseUrl,
|
|
41
41
|
resolvePluginOAuthAccount,
|
|
42
42
|
truncateStatusText
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-VCC7XFX2.js";
|
|
44
44
|
import {
|
|
45
45
|
JUNIOR_THREAD_STATE_TTL_MS,
|
|
46
46
|
TurnSliceLimitExceededError,
|
|
@@ -50,8 +50,10 @@ import {
|
|
|
50
50
|
clearPendingAuth,
|
|
51
51
|
coerceThreadArtifactsState,
|
|
52
52
|
coerceThreadConversationState,
|
|
53
|
+
commitAcceptedReply,
|
|
53
54
|
failAgentTurnSessionRecord,
|
|
54
55
|
getAgentTurnSessionRecord,
|
|
56
|
+
getAssistantReplyText,
|
|
55
57
|
getChannelConfigurationServiceById,
|
|
56
58
|
getConversationPendingAuth,
|
|
57
59
|
getPersistedSandboxState,
|
|
@@ -70,7 +72,7 @@ import {
|
|
|
70
72
|
recordDeliveredAssistantMessage,
|
|
71
73
|
turnHasReply,
|
|
72
74
|
updateConversationStats
|
|
73
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-NNGYYGX5.js";
|
|
74
76
|
import {
|
|
75
77
|
SlackActionError,
|
|
76
78
|
getDashboardConversationLink,
|
|
@@ -79,19 +81,19 @@ import {
|
|
|
79
81
|
getSlackClient,
|
|
80
82
|
isDmChannel,
|
|
81
83
|
normalizeSlackConversationId
|
|
82
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-USKP7IM2.js";
|
|
83
85
|
import {
|
|
84
86
|
getConversationEventStore,
|
|
85
87
|
getConversationStore,
|
|
86
88
|
parseDestination,
|
|
87
89
|
requireSlackDestination,
|
|
88
90
|
sameDestination
|
|
89
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-DOB5RVMH.js";
|
|
90
92
|
import {
|
|
91
93
|
acquireActiveLock,
|
|
92
94
|
getDefaultRedisStateAdapterFor,
|
|
93
95
|
getStateAdapter
|
|
94
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-TZVZCIYL.js";
|
|
95
97
|
import {
|
|
96
98
|
FUNCTION_TIMEOUT_BUFFER_SECONDS,
|
|
97
99
|
botConfig,
|
|
@@ -100,24 +102,24 @@ import {
|
|
|
100
102
|
getRuntimeMetadata,
|
|
101
103
|
normalizeSlackEmojiName,
|
|
102
104
|
standardModelId
|
|
103
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-2RFM7STT.js";
|
|
104
106
|
import {
|
|
105
107
|
parseSlackThreadId,
|
|
106
108
|
readSlackRawMessageContext,
|
|
107
109
|
resolveSlackChannelIdFromMessage,
|
|
108
110
|
resolveSlackChannelIdFromThreadId
|
|
109
|
-
} from "./chunk-
|
|
111
|
+
} from "./chunk-S7G34U75.js";
|
|
110
112
|
import {
|
|
111
113
|
discoverSkills
|
|
112
|
-
} from "./chunk-
|
|
114
|
+
} from "./chunk-E5SRLZQV.js";
|
|
113
115
|
import {
|
|
114
116
|
pluginCatalogRuntime
|
|
115
|
-
} from "./chunk-
|
|
117
|
+
} from "./chunk-OKUZIXQM.js";
|
|
116
118
|
import {
|
|
117
119
|
buildOAuthTokenRequest,
|
|
118
120
|
hasRequiredOAuthScope,
|
|
119
121
|
parseOAuthTokenResponse
|
|
120
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-GN6WW7WR.js";
|
|
121
123
|
import {
|
|
122
124
|
createSlackResumeActor,
|
|
123
125
|
isUserActor,
|
|
@@ -127,8 +129,10 @@ import {
|
|
|
127
129
|
buildTurnFailureResponse,
|
|
128
130
|
logException,
|
|
129
131
|
logInfo,
|
|
130
|
-
logWarn
|
|
131
|
-
|
|
132
|
+
logWarn,
|
|
133
|
+
setTags,
|
|
134
|
+
withLogContext
|
|
135
|
+
} from "./chunk-4SPRQJOW.js";
|
|
132
136
|
import {
|
|
133
137
|
isRecord,
|
|
134
138
|
toOptionalNumber,
|
|
@@ -463,18 +467,13 @@ async function runWithBoundSlackToken(adapter, token, task) {
|
|
|
463
467
|
return await adapter.withBotToken(token, task);
|
|
464
468
|
}
|
|
465
469
|
function logAssistantStatusFailure(args) {
|
|
466
|
-
logWarn(
|
|
467
|
-
"
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
"app.slack.thread_ts": args.threadTs,
|
|
474
|
-
"exception.message": args.error instanceof Error ? args.error.message : String(args.error)
|
|
475
|
-
},
|
|
476
|
-
`Failed to update assistant status channel=${args.normalizedChannelId} raw=${args.channelId} thread=${args.threadTs}`
|
|
477
|
-
);
|
|
470
|
+
logWarn("assistant.status.update.failed", {
|
|
471
|
+
"app.slack.status_text": args.status || "(clear)",
|
|
472
|
+
"app.slack.channel_id_raw": args.channelId,
|
|
473
|
+
"app.slack.channel_id": args.normalizedChannelId,
|
|
474
|
+
"app.slack.thread_ts": args.threadTs,
|
|
475
|
+
"exception.message": args.error instanceof Error ? args.error.message : String(args.error)
|
|
476
|
+
});
|
|
478
477
|
}
|
|
479
478
|
|
|
480
479
|
// src/chat/slack/assistant-thread/status.ts
|
|
@@ -954,8 +953,7 @@ async function startSlackProcessingReaction(args) {
|
|
|
954
953
|
return startSlackProcessingReactionForMessage({
|
|
955
954
|
channelId,
|
|
956
955
|
timestamp: messageTs,
|
|
957
|
-
logException: args.logException
|
|
958
|
-
logContext: args.logContext
|
|
956
|
+
logException: args.logException
|
|
959
957
|
});
|
|
960
958
|
}
|
|
961
959
|
async function startSlackProcessingReactionForMessage(args) {
|
|
@@ -966,17 +964,11 @@ async function startSlackProcessingReactionForMessage(args) {
|
|
|
966
964
|
emoji: getChatConfig().slack.processingReactionEmoji
|
|
967
965
|
});
|
|
968
966
|
} catch (error) {
|
|
969
|
-
args.logException(
|
|
970
|
-
|
|
971
|
-
"
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
"app.slack.action": "reactions.add",
|
|
975
|
-
"messaging.message.id": args.timestamp,
|
|
976
|
-
...getSlackErrorObservabilityAttributes(error)
|
|
977
|
-
},
|
|
978
|
-
"Failed to add Slack processing reaction"
|
|
979
|
-
);
|
|
967
|
+
args.logException(error, "slack.processing.reaction_add.failed", {
|
|
968
|
+
"app.slack.action": "reactions.add",
|
|
969
|
+
"messaging.message.id": args.timestamp,
|
|
970
|
+
...getSlackErrorObservabilityAttributes(error)
|
|
971
|
+
});
|
|
980
972
|
return noProcessingReaction;
|
|
981
973
|
}
|
|
982
974
|
let shouldRemove = true;
|
|
@@ -992,17 +984,11 @@ async function startSlackProcessingReactionForMessage(args) {
|
|
|
992
984
|
});
|
|
993
985
|
return true;
|
|
994
986
|
} catch (error) {
|
|
995
|
-
args.logException(
|
|
996
|
-
|
|
997
|
-
"
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
"app.slack.action": "reactions.remove",
|
|
1001
|
-
"messaging.message.id": args.timestamp,
|
|
1002
|
-
...getSlackErrorObservabilityAttributes(error)
|
|
1003
|
-
},
|
|
1004
|
-
"Failed to remove Slack processing reaction"
|
|
1005
|
-
);
|
|
987
|
+
args.logException(error, "slack.processing.reaction_remove.failed", {
|
|
988
|
+
"app.slack.action": "reactions.remove",
|
|
989
|
+
"messaging.message.id": args.timestamp,
|
|
990
|
+
...getSlackErrorObservabilityAttributes(error)
|
|
991
|
+
});
|
|
1006
992
|
return false;
|
|
1007
993
|
}
|
|
1008
994
|
};
|
|
@@ -1020,17 +1006,11 @@ async function startSlackProcessingReactionForMessage(args) {
|
|
|
1020
1006
|
emoji: getChatConfig().slack.completedReactionEmoji
|
|
1021
1007
|
});
|
|
1022
1008
|
} catch (error) {
|
|
1023
|
-
args.logException(
|
|
1024
|
-
|
|
1025
|
-
"
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
"app.slack.action": "reactions.add",
|
|
1029
|
-
"messaging.message.id": args.timestamp,
|
|
1030
|
-
...getSlackErrorObservabilityAttributes(error)
|
|
1031
|
-
},
|
|
1032
|
-
"Failed to add Slack completed reaction"
|
|
1033
|
-
);
|
|
1009
|
+
args.logException(error, "slack.processing.reaction_complete.failed", {
|
|
1010
|
+
"app.slack.action": "reactions.add",
|
|
1011
|
+
"messaging.message.id": args.timestamp,
|
|
1012
|
+
...getSlackErrorObservabilityAttributes(error)
|
|
1013
|
+
});
|
|
1034
1014
|
}
|
|
1035
1015
|
},
|
|
1036
1016
|
keep: () => {
|
|
@@ -1175,14 +1155,7 @@ async function postResumeFailureReply(args) {
|
|
|
1175
1155
|
});
|
|
1176
1156
|
}
|
|
1177
1157
|
async function handleResumeFailure(args) {
|
|
1178
|
-
const
|
|
1179
|
-
const capturedEventId = logException(
|
|
1180
|
-
args.error,
|
|
1181
|
-
args.eventName,
|
|
1182
|
-
logContext,
|
|
1183
|
-
{},
|
|
1184
|
-
args.body
|
|
1185
|
-
);
|
|
1158
|
+
const capturedEventId = logException(args.error, args.eventName);
|
|
1186
1159
|
const eventId = requireTurnFailureEventId(capturedEventId, args.eventName);
|
|
1187
1160
|
let failureStatePersistError;
|
|
1188
1161
|
try {
|
|
@@ -1190,10 +1163,8 @@ async function handleResumeFailure(args) {
|
|
|
1190
1163
|
} catch (persistError) {
|
|
1191
1164
|
const persistEventId = logException(
|
|
1192
1165
|
persistError,
|
|
1193
|
-
"
|
|
1194
|
-
|
|
1195
|
-
{ "app.error.original_event_id": eventId },
|
|
1196
|
-
"Failed to persist resumed turn failure state"
|
|
1166
|
+
"slack.resume.failure_state_persist.failed",
|
|
1167
|
+
{ "app.error.original_event_id": eventId }
|
|
1197
1168
|
);
|
|
1198
1169
|
try {
|
|
1199
1170
|
await args.turnLifecycle.fail({
|
|
@@ -1206,10 +1177,8 @@ async function handleResumeFailure(args) {
|
|
|
1206
1177
|
} catch (lifecycleError) {
|
|
1207
1178
|
logException(
|
|
1208
1179
|
lifecycleError,
|
|
1209
|
-
"
|
|
1210
|
-
|
|
1211
|
-
{ "app.error.original_event_id": eventId },
|
|
1212
|
-
"Failed to record resumed turn persistence failure"
|
|
1180
|
+
"slack.resume.failure_lifecycle_persist.failed",
|
|
1181
|
+
{ "app.error.original_event_id": eventId }
|
|
1213
1182
|
);
|
|
1214
1183
|
}
|
|
1215
1184
|
failureStatePersistError = persistError;
|
|
@@ -1224,10 +1193,8 @@ async function handleResumeFailure(args) {
|
|
|
1224
1193
|
} catch (deliveryError) {
|
|
1225
1194
|
const deliveryEventId = logException(
|
|
1226
1195
|
deliveryError,
|
|
1227
|
-
"
|
|
1228
|
-
|
|
1229
|
-
{ "app.error.original_event_id": eventId },
|
|
1230
|
-
"Failed to deliver resumed turn failure state"
|
|
1196
|
+
"slack.resume.failure_delivery.failed",
|
|
1197
|
+
{ "app.error.original_event_id": eventId }
|
|
1231
1198
|
);
|
|
1232
1199
|
try {
|
|
1233
1200
|
await args.turnLifecycle.fail({
|
|
@@ -1240,10 +1207,8 @@ async function handleResumeFailure(args) {
|
|
|
1240
1207
|
} catch (lifecycleError) {
|
|
1241
1208
|
logException(
|
|
1242
1209
|
lifecycleError,
|
|
1243
|
-
"
|
|
1244
|
-
|
|
1245
|
-
{ "app.error.original_event_id": eventId },
|
|
1246
|
-
"Failed to record resumed turn delivery failure"
|
|
1210
|
+
"slack.resume.failure_lifecycle_persist.failed",
|
|
1211
|
+
{ "app.error.original_event_id": eventId }
|
|
1247
1212
|
);
|
|
1248
1213
|
}
|
|
1249
1214
|
throw deliveryError;
|
|
@@ -1319,6 +1284,13 @@ function createResumeReplyContext(args, statusSession, delivery) {
|
|
|
1319
1284
|
};
|
|
1320
1285
|
}
|
|
1321
1286
|
async function resumeSlackTurn(args) {
|
|
1287
|
+
const lockKey = args.lockKey ?? getDefaultLockKey(args.channelId, args.threadTs);
|
|
1288
|
+
return withLogContext(
|
|
1289
|
+
getResumeLogContext(args, lockKey),
|
|
1290
|
+
() => resumeSlackTurnInContext(args)
|
|
1291
|
+
);
|
|
1292
|
+
}
|
|
1293
|
+
async function resumeSlackTurnInContext(args) {
|
|
1322
1294
|
const stateAdapter = getStateAdapter();
|
|
1323
1295
|
await stateAdapter.connect();
|
|
1324
1296
|
const lockKey = args.lockKey ?? getDefaultLockKey(args.channelId, args.threadTs);
|
|
@@ -1348,6 +1320,7 @@ async function resumeSlackTurn(args) {
|
|
|
1348
1320
|
if (preparedArgs) {
|
|
1349
1321
|
runArgs = { ...args, ...preparedArgs };
|
|
1350
1322
|
}
|
|
1323
|
+
setTags(getResumeLogContext(runArgs, lockKey));
|
|
1351
1324
|
const activeReplyContext = runArgs.replyContext;
|
|
1352
1325
|
if (!activeReplyContext) {
|
|
1353
1326
|
throw new Error("Resumed turn requires replyContext");
|
|
@@ -1377,8 +1350,7 @@ async function resumeSlackTurn(args) {
|
|
|
1377
1350
|
processingReaction = await startSlackProcessingReactionForMessage({
|
|
1378
1351
|
channelId: runArgs.channelId,
|
|
1379
1352
|
timestamp: runArgs.messageTs,
|
|
1380
|
-
logException
|
|
1381
|
-
logContext: { ...getResumeLogContext(runArgs, lockKey) }
|
|
1353
|
+
logException
|
|
1382
1354
|
});
|
|
1383
1355
|
}
|
|
1384
1356
|
if (runArgs.initialText) {
|
|
@@ -1422,8 +1394,10 @@ async function resumeSlackTurn(args) {
|
|
|
1422
1394
|
...userMessageId ? { userMessageId } : {}
|
|
1423
1395
|
};
|
|
1424
1396
|
};
|
|
1425
|
-
const deliverAssistantMessage = async (
|
|
1426
|
-
|
|
1397
|
+
const deliverAssistantMessage = async (reply) => {
|
|
1398
|
+
const message = typeof reply === "string" ? void 0 : reply;
|
|
1399
|
+
const text = typeof reply === "string" ? reply : getAssistantReplyText(reply);
|
|
1400
|
+
if (!text?.trim()) {
|
|
1427
1401
|
return;
|
|
1428
1402
|
}
|
|
1429
1403
|
failureCode = "delivery_failed";
|
|
@@ -1433,7 +1407,7 @@ async function resumeSlackTurn(args) {
|
|
|
1433
1407
|
messageTs = await sendSlackReply({
|
|
1434
1408
|
channelId: runArgs.channelId,
|
|
1435
1409
|
conversationId: runArgs.conversationId,
|
|
1436
|
-
text
|
|
1410
|
+
text,
|
|
1437
1411
|
threadTs: runArgs.threadTs
|
|
1438
1412
|
});
|
|
1439
1413
|
} catch (error) {
|
|
@@ -1447,7 +1421,7 @@ async function resumeSlackTurn(args) {
|
|
|
1447
1421
|
const recordedMessageId = recordDeliveredAssistantMessage({
|
|
1448
1422
|
conversation: deliveryState2.conversation,
|
|
1449
1423
|
sessionId: deliveryState2.sessionId,
|
|
1450
|
-
text
|
|
1424
|
+
text,
|
|
1451
1425
|
userMessageId: deliveryState2.userMessageId
|
|
1452
1426
|
});
|
|
1453
1427
|
if (messageTs) {
|
|
@@ -1457,7 +1431,12 @@ async function resumeSlackTurn(args) {
|
|
|
1457
1431
|
}
|
|
1458
1432
|
try {
|
|
1459
1433
|
await persistWithRetry(
|
|
1460
|
-
() =>
|
|
1434
|
+
() => message ? commitAcceptedReply({
|
|
1435
|
+
agentMessage: message,
|
|
1436
|
+
conversation: deliveryState2.conversation,
|
|
1437
|
+
conversationMessageId: recordedMessageId,
|
|
1438
|
+
conversationId
|
|
1439
|
+
}) : persistConversationMessages({
|
|
1461
1440
|
conversation: deliveryState2.conversation,
|
|
1462
1441
|
conversationId
|
|
1463
1442
|
})
|
|
@@ -1465,10 +1444,8 @@ async function resumeSlackTurn(args) {
|
|
|
1465
1444
|
} catch (error) {
|
|
1466
1445
|
logException(
|
|
1467
1446
|
new Error("Accepted assistant message persistence failed"),
|
|
1468
|
-
"
|
|
1469
|
-
|
|
1470
|
-
{ "error.type": error instanceof Error ? error.name : typeof error },
|
|
1471
|
-
"Failed to persist an accepted resumed assistant message"
|
|
1447
|
+
"slack.resume.assistant_message_post_delivery_persist.failed",
|
|
1448
|
+
{ "error.type": error instanceof Error ? error.name : typeof error }
|
|
1472
1449
|
);
|
|
1473
1450
|
}
|
|
1474
1451
|
const routing = runArgs.replyContext?.routing;
|
|
@@ -1490,13 +1467,7 @@ async function resumeSlackTurn(args) {
|
|
|
1490
1467
|
})
|
|
1491
1468
|
);
|
|
1492
1469
|
} catch (error) {
|
|
1493
|
-
logException(
|
|
1494
|
-
error,
|
|
1495
|
-
"agent_turn_delivery_receipt_persist_failed",
|
|
1496
|
-
getResumeLogContext(runArgs, lockKey),
|
|
1497
|
-
{},
|
|
1498
|
-
"Failed to persist accepted resumed turn delivery receipt"
|
|
1499
|
-
);
|
|
1470
|
+
logException(error, "agent.turn.delivery_receipt_persist.failed");
|
|
1500
1471
|
}
|
|
1501
1472
|
}
|
|
1502
1473
|
failureCode = "agent_run_failed";
|
|
@@ -1506,9 +1477,11 @@ async function resumeSlackTurn(args) {
|
|
|
1506
1477
|
deliveryState.conversation,
|
|
1507
1478
|
sessionId
|
|
1508
1479
|
);
|
|
1509
|
-
const replyContext = createResumeReplyContext(
|
|
1510
|
-
|
|
1511
|
-
|
|
1480
|
+
const replyContext = createResumeReplyContext(
|
|
1481
|
+
runArgs,
|
|
1482
|
+
status,
|
|
1483
|
+
deliverAssistantMessage
|
|
1484
|
+
);
|
|
1512
1485
|
if (runArgs.inputMessageIds?.length) {
|
|
1513
1486
|
await turnLifecycle.start({
|
|
1514
1487
|
conversationId: runArgs.conversationId,
|
|
@@ -1559,7 +1532,7 @@ async function resumeSlackTurn(args) {
|
|
|
1559
1532
|
error: new Error(
|
|
1560
1533
|
`Resumed run ended ${outcome.status} without a pause handler`
|
|
1561
1534
|
),
|
|
1562
|
-
eventName: "
|
|
1535
|
+
eventName: "slack.resume.turn.failed",
|
|
1563
1536
|
failureCode: "agent_run_failed",
|
|
1564
1537
|
turnLifecycle,
|
|
1565
1538
|
lockKey,
|
|
@@ -1570,13 +1543,12 @@ async function resumeSlackTurn(args) {
|
|
|
1570
1543
|
} else {
|
|
1571
1544
|
const finalized = finalizeFailedTurnReplyWithEvent({
|
|
1572
1545
|
reply: outcome.result,
|
|
1573
|
-
logException
|
|
1574
|
-
context: getResumeLogContext(runArgs, lockKey)
|
|
1546
|
+
logException
|
|
1575
1547
|
});
|
|
1576
1548
|
const reply = finalized.reply;
|
|
1577
1549
|
const dispatchErrorMessage = replyContext.routing.dispatch && reply.diagnostics.outcome !== "success" ? reply.diagnostics.errorMessage ?? `Agent turn ended with ${reply.diagnostics.outcome}.` : void 0;
|
|
1578
1550
|
if (reply.diagnostics.outcome !== "success") {
|
|
1579
|
-
await deliverAssistantMessage(
|
|
1551
|
+
await deliverAssistantMessage(reply.text);
|
|
1580
1552
|
}
|
|
1581
1553
|
runResultHandled = true;
|
|
1582
1554
|
await status.clear();
|
|
@@ -1646,10 +1618,7 @@ async function resumeSlackTurn(args) {
|
|
|
1646
1618
|
} catch (scheduleError) {
|
|
1647
1619
|
logException(
|
|
1648
1620
|
scheduleError,
|
|
1649
|
-
"
|
|
1650
|
-
getResumeLogContext(runArgs, lockKey),
|
|
1651
|
-
{},
|
|
1652
|
-
"Plugin session.completed task scheduling failed"
|
|
1621
|
+
"plugin.session.completed_task_schedule.failed"
|
|
1653
1622
|
);
|
|
1654
1623
|
}
|
|
1655
1624
|
}
|
|
@@ -1663,10 +1632,7 @@ async function resumeSlackTurn(args) {
|
|
|
1663
1632
|
} catch (terminalizeError) {
|
|
1664
1633
|
logException(
|
|
1665
1634
|
terminalizeError,
|
|
1666
|
-
"
|
|
1667
|
-
getResumeLogContext(runArgs, lockKey),
|
|
1668
|
-
{},
|
|
1669
|
-
"Failed to terminalize resumed turn after post-delivery commit failure"
|
|
1635
|
+
"slack.resume.post_delivery_terminalize.failed"
|
|
1670
1636
|
);
|
|
1671
1637
|
}
|
|
1672
1638
|
} else {
|
|
@@ -1674,7 +1640,7 @@ async function resumeSlackTurn(args) {
|
|
|
1674
1640
|
await handleResumeFailure({
|
|
1675
1641
|
body: "Failed to resume Slack turn",
|
|
1676
1642
|
error,
|
|
1677
|
-
eventName: "
|
|
1643
|
+
eventName: "slack.resume.turn.failed",
|
|
1678
1644
|
failureCode,
|
|
1679
1645
|
turnLifecycle,
|
|
1680
1646
|
lockKey,
|
|
@@ -1693,10 +1659,7 @@ async function resumeSlackTurn(args) {
|
|
|
1693
1659
|
if (postDeliveryCommitError) {
|
|
1694
1660
|
const eventId = logException(
|
|
1695
1661
|
postDeliveryCommitError,
|
|
1696
|
-
"
|
|
1697
|
-
getResumeLogContext(runArgs, lockKey),
|
|
1698
|
-
{},
|
|
1699
|
-
"Failed to persist resumed turn state after assistant output handling"
|
|
1662
|
+
"slack.resume.success_handler.failed"
|
|
1700
1663
|
);
|
|
1701
1664
|
await turnLifecycle.fail({
|
|
1702
1665
|
conversationId: runArgs.conversationId,
|
|
@@ -1727,7 +1690,7 @@ async function resumeSlackTurn(args) {
|
|
|
1727
1690
|
await handleResumeFailure({
|
|
1728
1691
|
body: "Failed to handle resumed turn pause",
|
|
1729
1692
|
error: pauseError,
|
|
1730
|
-
eventName: "
|
|
1693
|
+
eventName: "slack.resume.pause_handler.failed",
|
|
1731
1694
|
failureCode: "persistence_failed",
|
|
1732
1695
|
turnLifecycle,
|
|
1733
1696
|
lockKey,
|
|
@@ -3296,13 +3259,11 @@ async function failSessionRecordBestEffort(args) {
|
|
|
3296
3259
|
} catch (error) {
|
|
3297
3260
|
logException(
|
|
3298
3261
|
error,
|
|
3299
|
-
"
|
|
3300
|
-
{},
|
|
3262
|
+
"mcp.oauth_callback.session_record.failure_persistence.failed",
|
|
3301
3263
|
{
|
|
3302
3264
|
"app.ai.conversation_id": args.conversationId,
|
|
3303
3265
|
"app.ai.session_id": args.sessionId
|
|
3304
|
-
}
|
|
3305
|
-
"Failed to mark MCP OAuth-resumed turn session record failed"
|
|
3266
|
+
}
|
|
3306
3267
|
);
|
|
3307
3268
|
}
|
|
3308
3269
|
}
|
|
@@ -3536,10 +3497,8 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
3536
3497
|
} catch (persistError) {
|
|
3537
3498
|
logException(
|
|
3538
3499
|
persistError,
|
|
3539
|
-
"
|
|
3540
|
-
{}
|
|
3541
|
-
{ "app.credential.provider": provider },
|
|
3542
|
-
"Failed to persist failed MCP resume state"
|
|
3500
|
+
"mcp.oauth_callback.resume_failure_persist.failed",
|
|
3501
|
+
{ "app.credential.provider": provider }
|
|
3543
3502
|
);
|
|
3544
3503
|
}
|
|
3545
3504
|
},
|
|
@@ -3548,12 +3507,9 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
3548
3507
|
sessionId: lockedSessionId,
|
|
3549
3508
|
threadStateId: threadId
|
|
3550
3509
|
});
|
|
3551
|
-
logWarn(
|
|
3552
|
-
"
|
|
3553
|
-
|
|
3554
|
-
{ "app.credential.provider": provider },
|
|
3555
|
-
"Resumed MCP turn requested another authorization flow"
|
|
3556
|
-
);
|
|
3510
|
+
logWarn("mcp.oauth_callback.resume.reparked_for_auth", {
|
|
3511
|
+
"app.credential.provider": provider
|
|
3512
|
+
});
|
|
3557
3513
|
},
|
|
3558
3514
|
onSuspend: async (resumeVersion) => {
|
|
3559
3515
|
await scheduleAgentContinue({
|
|
@@ -3652,13 +3608,9 @@ async function GET(request, provider, waitUntil, options) {
|
|
|
3652
3608
|
try {
|
|
3653
3609
|
await deleteMcpAuthSession(authSession.authSessionId);
|
|
3654
3610
|
} catch (cleanupError) {
|
|
3655
|
-
logException(
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
{},
|
|
3659
|
-
{ "app.credential.provider": provider },
|
|
3660
|
-
"Failed to delete completed MCP auth session"
|
|
3661
|
-
);
|
|
3611
|
+
logException(cleanupError, "mcp.oauth_callback.session_cleanup.failed", {
|
|
3612
|
+
"app.credential.provider": provider
|
|
3613
|
+
});
|
|
3662
3614
|
}
|
|
3663
3615
|
if (authSession.destination?.platform !== "local") {
|
|
3664
3616
|
waitUntil(
|
|
@@ -3677,16 +3629,10 @@ async function GET(request, provider, waitUntil, options) {
|
|
|
3677
3629
|
await deleteMcpAuthSession(state);
|
|
3678
3630
|
return htmlResponse("expired");
|
|
3679
3631
|
}
|
|
3680
|
-
logException(
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
{
|
|
3685
|
-
"app.credential.provider": provider,
|
|
3686
|
-
...getMcpProviderErrorAttributes(callbackError)
|
|
3687
|
-
},
|
|
3688
|
-
"Failed to process MCP OAuth callback"
|
|
3689
|
-
);
|
|
3632
|
+
logException(callbackError, "mcp.oauth_callback.failed", {
|
|
3633
|
+
"app.credential.provider": provider,
|
|
3634
|
+
...getMcpProviderErrorAttributes(callbackError)
|
|
3635
|
+
});
|
|
3690
3636
|
return htmlResponse("failure");
|
|
3691
3637
|
}
|
|
3692
3638
|
}
|
|
@@ -3892,13 +3838,11 @@ async function failSessionRecordBestEffort2(args) {
|
|
|
3892
3838
|
} catch (error) {
|
|
3893
3839
|
logException(
|
|
3894
3840
|
error,
|
|
3895
|
-
"
|
|
3896
|
-
{},
|
|
3841
|
+
"oauth.callback.session_record.failure_persistence.failed",
|
|
3897
3842
|
{
|
|
3898
3843
|
"app.ai.conversation_id": args.conversationId,
|
|
3899
3844
|
"app.ai.session_id": args.sessionId
|
|
3900
|
-
}
|
|
3901
|
-
"Failed to mark OAuth-resumed turn session record failed"
|
|
3845
|
+
}
|
|
3902
3846
|
);
|
|
3903
3847
|
}
|
|
3904
3848
|
}
|
|
@@ -4137,16 +4081,11 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
4137
4081
|
}
|
|
4138
4082
|
},
|
|
4139
4083
|
commitResult: async (reply) => {
|
|
4140
|
-
logInfo(
|
|
4141
|
-
"
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
"app.ai.outcome": reply.diagnostics.outcome,
|
|
4146
|
-
"app.ai.tool_calls": reply.diagnostics.toolCalls.length
|
|
4147
|
-
},
|
|
4148
|
-
"OAuth callback auto-resumed session record finished replying"
|
|
4149
|
-
);
|
|
4084
|
+
logInfo("oauth.callback.resume.completed", {
|
|
4085
|
+
"app.credential.provider": stored.provider,
|
|
4086
|
+
"app.ai.outcome": reply.diagnostics.outcome,
|
|
4087
|
+
"app.ai.tool_calls": reply.diagnostics.toolCalls.length
|
|
4088
|
+
});
|
|
4150
4089
|
await persistCompletedOAuthReplyState({
|
|
4151
4090
|
conversationId: stored.resumeConversationId,
|
|
4152
4091
|
sessionId: lockedSessionId,
|
|
@@ -4286,10 +4225,8 @@ async function GET2(request, provider, waitUntil, options) {
|
|
|
4286
4225
|
});
|
|
4287
4226
|
} catch {
|
|
4288
4227
|
logWarn(
|
|
4289
|
-
"
|
|
4290
|
-
|
|
4291
|
-
oauthTokenErrorAttributes(provider, providerConfig.tokenEndpoint),
|
|
4292
|
-
"OAuth token exchange request failed"
|
|
4228
|
+
"oauth.token_exchange.failed",
|
|
4229
|
+
oauthTokenErrorAttributes(provider, providerConfig.tokenEndpoint)
|
|
4293
4230
|
);
|
|
4294
4231
|
return htmlErrorResponse(
|
|
4295
4232
|
"Connection failed",
|
|
@@ -4299,14 +4236,12 @@ async function GET2(request, provider, waitUntil, options) {
|
|
|
4299
4236
|
}
|
|
4300
4237
|
if (!tokenResponse.ok) {
|
|
4301
4238
|
logWarn(
|
|
4302
|
-
"
|
|
4303
|
-
{},
|
|
4239
|
+
"oauth.token_exchange.failed",
|
|
4304
4240
|
oauthTokenErrorAttributes(
|
|
4305
4241
|
provider,
|
|
4306
4242
|
providerConfig.tokenEndpoint,
|
|
4307
4243
|
tokenResponse.status
|
|
4308
|
-
)
|
|
4309
|
-
"OAuth token exchange was rejected"
|
|
4244
|
+
)
|
|
4310
4245
|
);
|
|
4311
4246
|
return htmlErrorResponse(
|
|
4312
4247
|
"Connection failed",
|
|
@@ -4322,14 +4257,12 @@ async function GET2(request, provider, waitUntil, options) {
|
|
|
4322
4257
|
});
|
|
4323
4258
|
} catch {
|
|
4324
4259
|
logWarn(
|
|
4325
|
-
"
|
|
4326
|
-
{},
|
|
4260
|
+
"oauth.token_exchange.failed",
|
|
4327
4261
|
oauthTokenErrorAttributes(
|
|
4328
4262
|
provider,
|
|
4329
4263
|
providerConfig.tokenEndpoint,
|
|
4330
4264
|
tokenResponse.status
|
|
4331
|
-
)
|
|
4332
|
-
"OAuth token exchange returned an invalid response"
|
|
4265
|
+
)
|
|
4333
4266
|
);
|
|
4334
4267
|
return htmlErrorResponse(
|
|
4335
4268
|
"Connection failed",
|
|
@@ -4378,33 +4311,27 @@ async function GET2(request, provider, waitUntil, options) {
|
|
|
4378
4311
|
stored.destination?.platform !== "local" && stored.resumeConversationId && stored.resumeSessionId
|
|
4379
4312
|
);
|
|
4380
4313
|
if (resumesAgentTurn) {
|
|
4381
|
-
waitUntil(
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
{
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
}
|
|
4400
|
-
},
|
|
4401
|
-
"OAuth callback resume was busy; user must send another message to continue"
|
|
4402
|
-
);
|
|
4403
|
-
return;
|
|
4314
|
+
waitUntil(
|
|
4315
|
+
() => withLogContext(
|
|
4316
|
+
{ conversationId: stored.resumeConversationId },
|
|
4317
|
+
async () => {
|
|
4318
|
+
try {
|
|
4319
|
+
await resumeOAuthSessionRecordTurn(stored, options);
|
|
4320
|
+
} catch (error) {
|
|
4321
|
+
if (error instanceof ResumeTurnBusyError) {
|
|
4322
|
+
logWarn("oauth.callback.resume.busy", {
|
|
4323
|
+
"app.credential.provider": stored.provider,
|
|
4324
|
+
...stored.resumeSessionId && {
|
|
4325
|
+
"app.ai.session_id": stored.resumeSessionId
|
|
4326
|
+
}
|
|
4327
|
+
});
|
|
4328
|
+
return;
|
|
4329
|
+
}
|
|
4330
|
+
throw error;
|
|
4331
|
+
}
|
|
4404
4332
|
}
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
});
|
|
4333
|
+
)
|
|
4334
|
+
);
|
|
4408
4335
|
} else if (stored.channelId && stored.threadTs) {
|
|
4409
4336
|
const { channelId, threadTs } = stored;
|
|
4410
4337
|
waitUntil(
|