@sentry/junior 0.144.0 → 0.145.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-GCUTGKY3.js → agent-hooks-L7D2BDVV.js} +10 -10
- package/dist/api/conversations/detail.d.ts +1 -0
- package/dist/api/schema/conversation.d.ts +2 -0
- package/dist/api/schema.js +1 -1
- package/dist/api.js +40 -22
- package/dist/app.js +335 -409
- package/dist/{catalog-runtime-DWVYKDC6.js → catalog-runtime-QLAC4Q3W.js} +5 -5
- package/dist/chat/agent/request.d.ts +1 -1
- package/dist/chat/agent/resume.d.ts +6 -15
- package/dist/chat/agent/tools.d.ts +1 -1
- package/dist/chat/agent-dispatch/types.d.ts +1 -1
- package/dist/chat/app/conversation-work.d.ts +24 -0
- package/dist/chat/conversations/projection.d.ts +11 -3
- package/dist/chat/conversations/store.d.ts +1 -1
- package/dist/chat/runtime/agent-run-outcome.d.ts +1 -1
- package/dist/chat/runtime/reply-executor.d.ts +5 -5
- package/dist/chat/runtime/slack-resume.d.ts +12 -4
- package/dist/chat/state/locks.d.ts +28 -0
- package/dist/chat/task-execution/checkpoint.d.ts +86 -0
- package/dist/chat/task-execution/paused-turn.d.ts +29 -0
- package/dist/chat/task-execution/queue-signing.d.ts +1 -0
- package/dist/chat/task-execution/queue.d.ts +7 -1
- package/dist/chat/task-execution/slack-work.d.ts +1 -1
- package/dist/chat/task-execution/state.d.ts +4 -4
- package/dist/chat/task-execution/store.d.ts +2 -2
- package/dist/chat/task-execution/turn-cursor-keys.d.ts +6 -0
- package/dist/chat/{state/turn-session.d.ts → task-execution/turn-cursor.d.ts} +52 -42
- package/dist/chat/task-execution/turn-wake.d.ts +29 -0
- package/dist/chat/tools/types.d.ts +1 -1
- package/dist/{chunk-HNO2E5WB.js → chunk-27TEJTZO.js} +1 -1
- package/dist/{chunk-RIFJUJSI.js → chunk-2LWPFSB4.js} +1 -1
- package/dist/{chunk-SBZP2J5Q.js → chunk-2UH3JI64.js} +10 -9
- package/dist/{chunk-QUZJDAQQ.js → chunk-2XET6PKP.js} +93 -89
- package/dist/{chunk-SUK7NC5A.js → chunk-5PNPQYTO.js} +2 -2
- package/dist/{chunk-SSDTQDYQ.js → chunk-64SBYW2O.js} +132 -127
- package/dist/{chunk-DVO5VKYQ.js → chunk-B46ZMVOV.js} +5 -5
- package/dist/{chunk-A67GZN73.js → chunk-CD2XFGYQ.js} +1 -1
- package/dist/{chunk-WTX2RFJG.js → chunk-DS3J6WGY.js} +1 -1
- package/dist/{chunk-PKH6762I.js → chunk-DXEQAIUV.js} +1 -1
- package/dist/{chunk-WSOLZJJS.js → chunk-EIX2LQ6L.js} +3 -3
- package/dist/{chunk-KQBXT5B7.js → chunk-FUBRJA5F.js} +6 -6
- package/dist/{chunk-I44JB7HQ.js → chunk-GDV5LXRA.js} +1 -1
- package/dist/{chunk-7KAW7UF4.js → chunk-GUWLDMGF.js} +4 -4
- package/dist/{chunk-PELZ2ZSY.js → chunk-HISR3DTV.js} +33 -61
- package/dist/{chunk-HD6BHR25.js → chunk-HLOUZC5C.js} +32 -34
- package/dist/{chunk-BBCWYXHB.js → chunk-I47UGQPJ.js} +7 -7
- package/dist/{chunk-IUFM5JWV.js → chunk-JAL3CH4G.js} +3 -0
- package/dist/{chunk-E7HCWOHG.js → chunk-JLMVCNXL.js} +2 -1
- package/dist/{chunk-STFCL3K4.js → chunk-JTGS3ZZE.js} +1 -1
- package/dist/{chunk-GKA74DRA.js → chunk-LVVSIMBB.js} +1 -1
- package/dist/{chunk-SHEEZSLY.js → chunk-PJ4NMVQB.js} +2 -2
- package/dist/{chunk-W7JFV5SB.js → chunk-QJBDABQA.js} +14 -17
- package/dist/{chunk-UDQMY6RS.js → chunk-QUG4JSZK.js} +43 -1
- package/dist/{chunk-4X5KM7Z6.js → chunk-RUSS62EN.js} +14 -14
- package/dist/{chunk-ZF3N3JD6.js → chunk-SIN3MXH6.js} +1 -1
- package/dist/{chunk-QE3TICD4.js → chunk-TZRXYWRE.js} +2 -2
- package/dist/{chunk-CNTWB2SM.js → chunk-VTDMB7XX.js} +1 -1
- package/dist/{chunk-LDWNYCZ6.js → chunk-WF5HVH3M.js} +1 -1
- package/dist/{chunk-KCBZSJRU.js → chunk-WR76IVA5.js} +5 -2
- package/dist/{chunk-3GU4PWA3.js → chunk-XFKIRN3Q.js} +29 -29
- package/dist/{chunk-ZZCTGAIT.js → chunk-YD54Q45G.js} +4 -4
- package/dist/{chunk-BEGGFVFR.js → chunk-ZIAMN2UW.js} +407 -523
- package/dist/{chunk-44RJWAND.js → chunk-ZIMRGFYL.js} +6 -6
- package/dist/{chunk-54JMYQYS.js → chunk-ZYAJMESY.js} +2 -2
- package/dist/cli/chat.js +32 -32
- package/dist/cli/check.js +6 -6
- package/dist/cli/plugins.js +13 -13
- package/dist/cli/snapshot-create.js +9 -9
- package/dist/cli/upgrade.js +7 -7
- package/dist/{db-EFLHTBU6.js → db-62PW6LM3.js} +7 -7
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +4 -4
- package/dist/{oauth-callback-server-RO3IQKWM.js → oauth-callback-server-6NZNHJAM.js} +25 -25
- package/dist/{runner-LOWW7JKA.js → runner-GCRPG3GQ.js} +19 -18
- package/dist/{skills-ZLMUG7AE.js → skills-2S3MDFIQ.js} +6 -6
- package/dist/spawn-7WK37BTD.js +39 -0
- package/dist/{validation-MAKEZNTS.js → validation-HAOLCJ5A.js} +6 -6
- package/dist/version.js +1 -1
- package/dist/{work-5OAGC3I4.js → work-R4XYKMUW.js} +17 -16
- package/dist/worker-U2UCVR7M.js +24 -0
- package/package.json +4 -4
- package/dist/chat/agent/session.d.ts +0 -19
- package/dist/chat/runtime/agent-continue-runner.d.ts +0 -37
- package/dist/chat/services/agent-continue.d.ts +0 -29
- package/dist/chat/services/turn-session-record.d.ts +0 -164
- package/dist/chat/state/turn-session-keys.d.ts +0 -6
- package/dist/spawn-R3LUV6RF.js +0 -38
- package/dist/worker-KTGGRTTP.js +0 -24
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
ensureConversationWake,
|
|
6
6
|
requestConversationWork
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-HLOUZC5C.js";
|
|
8
8
|
import {
|
|
9
9
|
buildConversationContext,
|
|
10
10
|
buildDeliveredTurnStatePatch,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
resolveTurnSessionRouting,
|
|
22
22
|
scheduleSessionCompletedPluginTasks,
|
|
23
23
|
turnHasReply
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-QJBDABQA.js";
|
|
25
25
|
import {
|
|
26
26
|
ConversationTurnLifecycleService
|
|
27
27
|
} from "./chunk-Q6QZTTLS.js";
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
} from "./chunk-4CODA7P5.js";
|
|
31
31
|
import {
|
|
32
32
|
getVercelConversationWorkQueue
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-WR76IVA5.js";
|
|
34
34
|
import {
|
|
35
35
|
createUserTokenStore,
|
|
36
36
|
deleteMcpAuthSession,
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
getMcpProviderErrorAttributes,
|
|
40
40
|
getMcpStoredOAuthCredentials,
|
|
41
41
|
resolvePluginOAuthAccount
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-I47UGQPJ.js";
|
|
43
43
|
import {
|
|
44
44
|
RetryableDeliveryError
|
|
45
45
|
} from "./chunk-R776HKPK.js";
|
|
@@ -55,58 +55,59 @@ import {
|
|
|
55
55
|
removeReactionFromMessage,
|
|
56
56
|
resolveBaseUrl,
|
|
57
57
|
truncateStatusText
|
|
58
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-FUBRJA5F.js";
|
|
59
59
|
import {
|
|
60
60
|
TurnSliceLimitExceededError,
|
|
61
|
-
|
|
61
|
+
abandonTurnRecord,
|
|
62
62
|
buildTurnLimitResponse,
|
|
63
63
|
clearPendingAuth,
|
|
64
64
|
coerceThreadArtifactsState,
|
|
65
65
|
coerceThreadConversationState,
|
|
66
66
|
commitAcceptedReply,
|
|
67
|
-
|
|
68
|
-
getAgentTurnSessionRecord,
|
|
67
|
+
failTurnRecord,
|
|
69
68
|
getAssistantReplyText,
|
|
70
69
|
getChannelConfigurationServiceById,
|
|
71
70
|
getConversationPendingAuth,
|
|
72
71
|
getPersistedSandboxState,
|
|
73
72
|
getPersistedThreadState,
|
|
73
|
+
getTurnRecord,
|
|
74
74
|
hydrateConversationMessages,
|
|
75
75
|
isPendingAuthLatestRequest,
|
|
76
76
|
loadProjection,
|
|
77
|
+
loadTurnCheckpoint,
|
|
77
78
|
markTurnFailed,
|
|
78
|
-
persistCompletedSessionRecord,
|
|
79
79
|
persistThreadStateById,
|
|
80
80
|
persistWithRetry,
|
|
81
|
-
recordAgentTurnSessionSummary,
|
|
82
81
|
recordAuthenticationLinked,
|
|
83
|
-
recordAuthorizationCompleted
|
|
84
|
-
|
|
82
|
+
recordAuthorizationCompleted,
|
|
83
|
+
recordTurnSummary,
|
|
84
|
+
saveTurnCheckpoint
|
|
85
|
+
} from "./chunk-ZIAMN2UW.js";
|
|
85
86
|
import {
|
|
86
87
|
parseSlackThreadId,
|
|
87
88
|
readSlackRawMessageContext,
|
|
88
89
|
resolveSlackChannelIdFromMessage,
|
|
89
90
|
resolveSlackChannelIdFromThreadId
|
|
90
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-DXEQAIUV.js";
|
|
91
92
|
import {
|
|
92
93
|
getDashboardConversationLink,
|
|
93
94
|
getPluginSlackConversationLink
|
|
94
|
-
} from "./chunk-
|
|
95
|
+
} from "./chunk-ZIMRGFYL.js";
|
|
95
96
|
import {
|
|
96
97
|
SlackActionError,
|
|
97
98
|
getHeaderString,
|
|
98
99
|
getSlackClient,
|
|
99
100
|
isDmChannel,
|
|
100
101
|
normalizeSlackConversationId
|
|
101
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-TZRXYWRE.js";
|
|
102
103
|
import {
|
|
103
104
|
getConversationEventStore,
|
|
104
105
|
requireSlackDestination
|
|
105
|
-
} from "./chunk-
|
|
106
|
+
} from "./chunk-2UH3JI64.js";
|
|
106
107
|
import {
|
|
107
108
|
acquireActiveLock,
|
|
108
109
|
getStateAdapter
|
|
109
|
-
} from "./chunk-
|
|
110
|
+
} from "./chunk-QUG4JSZK.js";
|
|
110
111
|
import {
|
|
111
112
|
FUNCTION_TIMEOUT_BUFFER_SECONDS,
|
|
112
113
|
botConfig,
|
|
@@ -115,18 +116,18 @@ import {
|
|
|
115
116
|
getRuntimeMetadata,
|
|
116
117
|
normalizeSlackEmojiName,
|
|
117
118
|
standardModelId
|
|
118
|
-
} from "./chunk-
|
|
119
|
+
} from "./chunk-XFKIRN3Q.js";
|
|
119
120
|
import {
|
|
120
121
|
discoverSkills
|
|
121
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-5PNPQYTO.js";
|
|
122
123
|
import {
|
|
123
124
|
pluginCatalogRuntime
|
|
124
|
-
} from "./chunk-
|
|
125
|
+
} from "./chunk-SIN3MXH6.js";
|
|
125
126
|
import {
|
|
126
127
|
buildOAuthTokenRequest,
|
|
127
128
|
hasRequiredOAuthScope,
|
|
128
129
|
parseOAuthTokenResponse
|
|
129
|
-
} from "./chunk-
|
|
130
|
+
} from "./chunk-CD2XFGYQ.js";
|
|
130
131
|
import {
|
|
131
132
|
createSlackResumeActor,
|
|
132
133
|
isUserActor
|
|
@@ -142,7 +143,7 @@ import {
|
|
|
142
143
|
setTags,
|
|
143
144
|
toOptionalString,
|
|
144
145
|
withLogContext
|
|
145
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-2LWPFSB4.js";
|
|
146
147
|
import {
|
|
147
148
|
homeDir
|
|
148
149
|
} from "./chunk-H4HBKISO.js";
|
|
@@ -1319,8 +1320,8 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1319
1320
|
const stateAdapter = getStateAdapter();
|
|
1320
1321
|
await stateAdapter.connect();
|
|
1321
1322
|
const lockKey = args.lockKey ?? getDefaultLockKey(args.channelId, args.threadTs);
|
|
1322
|
-
const lock = await acquireActiveLock(stateAdapter, lockKey);
|
|
1323
|
-
if (!lock) {
|
|
1323
|
+
const lock = args.ownsConversationLease ? void 0 : await acquireActiveLock(stateAdapter, lockKey);
|
|
1324
|
+
if (!args.ownsConversationLease && !lock) {
|
|
1324
1325
|
throw new ResumeTurnBusyError(lockKey);
|
|
1325
1326
|
}
|
|
1326
1327
|
const status = createSlackWebApiAssistantStatusSession({
|
|
@@ -1490,13 +1491,13 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1490
1491
|
if (messageTs && dispatchId && routing) {
|
|
1491
1492
|
try {
|
|
1492
1493
|
await persistWithRetry(
|
|
1493
|
-
() =>
|
|
1494
|
+
() => recordTurnSummary({
|
|
1494
1495
|
conversationId: runArgs.conversationId,
|
|
1495
1496
|
destination: routing.destination,
|
|
1496
1497
|
destinationVisibility: routing.destinationVisibility,
|
|
1497
1498
|
dispatchId,
|
|
1498
1499
|
resultMessageId: messageTs,
|
|
1499
|
-
|
|
1500
|
+
turnId: runArgs.turnId,
|
|
1500
1501
|
sliceId: runArgs.sliceId ?? 1,
|
|
1501
1502
|
source: routing.source,
|
|
1502
1503
|
state: "running",
|
|
@@ -1591,13 +1592,14 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1591
1592
|
await status.clear();
|
|
1592
1593
|
failureCode = "persistence_failed";
|
|
1593
1594
|
if (reply.piMessages?.length) {
|
|
1594
|
-
await
|
|
1595
|
+
await saveTurnCheckpoint({
|
|
1596
|
+
mode: "completed",
|
|
1595
1597
|
conversationId: runArgs.conversationId,
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
+
turnId: runArgs.turnId,
|
|
1599
|
+
messages: reply.piMessages,
|
|
1598
1600
|
modelId: reply.diagnostics.modelId,
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
+
durationMs: reply.diagnostics.durationMs,
|
|
1602
|
+
usage: reply.diagnostics.usage,
|
|
1601
1603
|
destination: replyContext.routing.destination,
|
|
1602
1604
|
destinationVisibility: replyContext.routing.destinationVisibility,
|
|
1603
1605
|
dispatchId: replyContext.routing.dispatch?.id,
|
|
@@ -1610,14 +1612,14 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1610
1612
|
sliceId: runArgs.sliceId
|
|
1611
1613
|
});
|
|
1612
1614
|
} else if (replyContext.routing.dispatch?.id) {
|
|
1613
|
-
await
|
|
1615
|
+
await recordTurnSummary({
|
|
1614
1616
|
conversationId: runArgs.conversationId,
|
|
1615
1617
|
destination: replyContext.routing.destination,
|
|
1616
1618
|
destinationVisibility: replyContext.routing.destinationVisibility,
|
|
1617
1619
|
dispatchId: replyContext.routing.dispatch?.id,
|
|
1618
1620
|
dispatchOutcome: reply.diagnostics.outcome === "success" ? "completed" : "failed",
|
|
1619
1621
|
...acceptedDeliveryId ? { resultMessageId: acceptedDeliveryId } : {},
|
|
1620
|
-
|
|
1622
|
+
turnId: runArgs.turnId,
|
|
1621
1623
|
sliceId: runArgs.sliceId ?? 1,
|
|
1622
1624
|
source: replyContext.routing.source,
|
|
1623
1625
|
state: reply.diagnostics.outcome === "success" ? "completed" : "failed",
|
|
@@ -1691,7 +1693,9 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1691
1693
|
} else {
|
|
1692
1694
|
await processingReaction?.stop();
|
|
1693
1695
|
}
|
|
1694
|
-
|
|
1696
|
+
if (lock) {
|
|
1697
|
+
await stateAdapter.releaseLock(lock);
|
|
1698
|
+
}
|
|
1695
1699
|
}
|
|
1696
1700
|
if (postDeliveryCommitError) {
|
|
1697
1701
|
const eventId = logException(
|
|
@@ -1743,13 +1747,14 @@ async function resumeSlackTurnInContext(args) {
|
|
|
1743
1747
|
return true;
|
|
1744
1748
|
}
|
|
1745
1749
|
|
|
1746
|
-
// src/chat/
|
|
1747
|
-
async function
|
|
1748
|
-
const
|
|
1749
|
-
args.conversationId,
|
|
1750
|
-
args.
|
|
1751
|
-
);
|
|
1752
|
-
|
|
1750
|
+
// src/chat/task-execution/turn-wake.ts
|
|
1751
|
+
async function getPausedTurnRequest(args) {
|
|
1752
|
+
const checkpoint = await loadTurnCheckpoint({
|
|
1753
|
+
conversationId: args.conversationId,
|
|
1754
|
+
turnId: args.turnId
|
|
1755
|
+
});
|
|
1756
|
+
const turn = checkpoint.record;
|
|
1757
|
+
if (!turn || turn.state !== "paused" || turn.resumeReason !== "timeout" && turn.resumeReason !== "yield" && turn.resumeReason !== "retry" || turn.resumeReason === "timeout" && turn.sliceId < 2) {
|
|
1753
1758
|
return void 0;
|
|
1754
1759
|
}
|
|
1755
1760
|
let routing;
|
|
@@ -1759,10 +1764,10 @@ async function getAwaitingAgentContinueRequest(args) {
|
|
|
1759
1764
|
conversationStore: args.conversationStore
|
|
1760
1765
|
});
|
|
1761
1766
|
} catch (error) {
|
|
1762
|
-
await
|
|
1767
|
+
await failTurnRecord({
|
|
1763
1768
|
conversationId: args.conversationId,
|
|
1764
|
-
expectedVersion:
|
|
1765
|
-
|
|
1769
|
+
expectedVersion: turn.version,
|
|
1770
|
+
turnId: args.turnId,
|
|
1766
1771
|
errorMessage: error instanceof Error ? error.message : String(error)
|
|
1767
1772
|
});
|
|
1768
1773
|
return void 0;
|
|
@@ -1770,11 +1775,11 @@ async function getAwaitingAgentContinueRequest(args) {
|
|
|
1770
1775
|
return {
|
|
1771
1776
|
conversationId: args.conversationId,
|
|
1772
1777
|
destination: routing.destination,
|
|
1773
|
-
|
|
1774
|
-
expectedVersion:
|
|
1778
|
+
turnId: args.turnId,
|
|
1779
|
+
expectedVersion: turn.version
|
|
1775
1780
|
};
|
|
1776
1781
|
}
|
|
1777
|
-
async function
|
|
1782
|
+
async function wakePausedTurn(request, options = {}) {
|
|
1778
1783
|
const nowMs = options.nowMs ?? Date.now();
|
|
1779
1784
|
await requestConversationWork({
|
|
1780
1785
|
conversationId: request.conversationId,
|
|
@@ -1788,7 +1793,7 @@ async function scheduleAgentContinue(request, options = {}) {
|
|
|
1788
1793
|
idempotencyKey: [
|
|
1789
1794
|
"agent-continue",
|
|
1790
1795
|
request.conversationId,
|
|
1791
|
-
request.
|
|
1796
|
+
request.turnId,
|
|
1792
1797
|
request.expectedVersion,
|
|
1793
1798
|
nowMs
|
|
1794
1799
|
].join(":"),
|
|
@@ -1896,9 +1901,9 @@ async function persistCompletedReplyState(channelId, threadTs, sessionId, reply)
|
|
|
1896
1901
|
}
|
|
1897
1902
|
async function failSessionRecordBestEffort(args) {
|
|
1898
1903
|
try {
|
|
1899
|
-
await
|
|
1904
|
+
await failTurnRecord({
|
|
1900
1905
|
conversationId: args.conversationId,
|
|
1901
|
-
|
|
1906
|
+
turnId: args.turnId,
|
|
1902
1907
|
errorMessage: args.errorMessage,
|
|
1903
1908
|
expectedVersion: args.expectedVersion
|
|
1904
1909
|
});
|
|
@@ -1908,7 +1913,7 @@ async function failSessionRecordBestEffort(args) {
|
|
|
1908
1913
|
"mcp.oauth_callback.session_record.failure_persistence.failed",
|
|
1909
1914
|
{
|
|
1910
1915
|
"app.ai.conversation_id": args.conversationId,
|
|
1911
|
-
"app.ai.session_id": args.
|
|
1916
|
+
"app.ai.session_id": args.turnId
|
|
1912
1917
|
}
|
|
1913
1918
|
);
|
|
1914
1919
|
}
|
|
@@ -1928,7 +1933,7 @@ async function persistFailedReplyState(channelId, threadTs, sessionId, expectedV
|
|
|
1928
1933
|
});
|
|
1929
1934
|
await failSessionRecordBestEffort({
|
|
1930
1935
|
conversationId: threadId,
|
|
1931
|
-
sessionId,
|
|
1936
|
+
turnId: sessionId,
|
|
1932
1937
|
errorMessage: "OAuth-resumed MCP turn failed",
|
|
1933
1938
|
expectedVersion
|
|
1934
1939
|
});
|
|
@@ -1963,9 +1968,9 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
1963
1968
|
if (!isPendingAuthLatestRequest(conversation, pendingAuth)) {
|
|
1964
1969
|
clearPendingAuth(conversation, pendingAuth.sessionId);
|
|
1965
1970
|
await persistThreadStateById(threadId, { conversation });
|
|
1966
|
-
await
|
|
1971
|
+
await abandonTurnRecord({
|
|
1967
1972
|
conversationId: authSession.conversationId,
|
|
1968
|
-
|
|
1973
|
+
turnId: pendingAuth.sessionId,
|
|
1969
1974
|
errorMessage: "Auth completed after a newer thread message abandoned this blocked request."
|
|
1970
1975
|
});
|
|
1971
1976
|
return;
|
|
@@ -2009,9 +2014,9 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
2009
2014
|
await persistThreadStateById(threadId, {
|
|
2010
2015
|
conversation: lockedConversation
|
|
2011
2016
|
});
|
|
2012
|
-
await
|
|
2017
|
+
await abandonTurnRecord({
|
|
2013
2018
|
conversationId: authSession.conversationId,
|
|
2014
|
-
|
|
2019
|
+
turnId: lockedPendingAuth.sessionId,
|
|
2015
2020
|
errorMessage: "Auth completed after a newer thread message abandoned this blocked request."
|
|
2016
2021
|
});
|
|
2017
2022
|
return false;
|
|
@@ -2023,11 +2028,11 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
2023
2028
|
if (!lockedUserMessage) {
|
|
2024
2029
|
return false;
|
|
2025
2030
|
}
|
|
2026
|
-
const lockedSessionRecord = await
|
|
2031
|
+
const lockedSessionRecord = await getTurnRecord(
|
|
2027
2032
|
authSession.conversationId,
|
|
2028
2033
|
lockedSessionId
|
|
2029
2034
|
);
|
|
2030
|
-
if (!lockedSessionRecord || lockedSessionRecord.state !== "
|
|
2035
|
+
if (!lockedSessionRecord || lockedSessionRecord.state !== "paused" || lockedSessionRecord.resumeReason !== "auth") {
|
|
2031
2036
|
return false;
|
|
2032
2037
|
}
|
|
2033
2038
|
const lockedConversationContext = buildConversationContext(
|
|
@@ -2046,10 +2051,10 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
2046
2051
|
userId: authSession.userId
|
|
2047
2052
|
});
|
|
2048
2053
|
} catch {
|
|
2049
|
-
await
|
|
2054
|
+
await failTurnRecord({
|
|
2050
2055
|
conversationId: authSession.conversationId,
|
|
2051
2056
|
expectedVersion: lockedSessionRecord.version,
|
|
2052
|
-
|
|
2057
|
+
turnId: lockedSessionId,
|
|
2053
2058
|
errorMessage: "Unable to rebuild Slack actor for OAuth resume"
|
|
2054
2059
|
});
|
|
2055
2060
|
return false;
|
|
@@ -2060,10 +2065,10 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
2060
2065
|
conversationId: authSession.conversationId
|
|
2061
2066
|
});
|
|
2062
2067
|
} catch (error) {
|
|
2063
|
-
await
|
|
2068
|
+
await failTurnRecord({
|
|
2064
2069
|
conversationId: authSession.conversationId,
|
|
2065
2070
|
expectedVersion: lockedSessionRecord.version,
|
|
2066
|
-
|
|
2071
|
+
turnId: lockedSessionId,
|
|
2067
2072
|
errorMessage: error instanceof Error ? error.message : String(error)
|
|
2068
2073
|
});
|
|
2069
2074
|
return false;
|
|
@@ -2128,10 +2133,10 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
2128
2133
|
);
|
|
2129
2134
|
},
|
|
2130
2135
|
onPostDeliveryCommitFailure: async () => {
|
|
2131
|
-
await
|
|
2136
|
+
await failTurnRecord({
|
|
2132
2137
|
conversationId: authSession.conversationId,
|
|
2133
2138
|
expectedVersion: lockedSessionRecord.version,
|
|
2134
|
-
|
|
2139
|
+
turnId: lockedSessionId,
|
|
2135
2140
|
errorMessage: "OAuth-resumed MCP reply was delivered but completion state did not persist"
|
|
2136
2141
|
});
|
|
2137
2142
|
},
|
|
@@ -2161,10 +2166,10 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
2161
2166
|
});
|
|
2162
2167
|
},
|
|
2163
2168
|
onSuspend: async (resumeVersion) => {
|
|
2164
|
-
await
|
|
2169
|
+
await wakePausedTurn({
|
|
2165
2170
|
conversationId: authSession.conversationId,
|
|
2166
2171
|
destination,
|
|
2167
|
-
|
|
2172
|
+
turnId: lockedSessionId,
|
|
2168
2173
|
expectedVersion: resumeVersion
|
|
2169
2174
|
});
|
|
2170
2175
|
}
|
|
@@ -2501,10 +2506,10 @@ function pluginAuthorizationId(args) {
|
|
|
2501
2506
|
}
|
|
2502
2507
|
async function failSessionRecordBestEffort2(args) {
|
|
2503
2508
|
try {
|
|
2504
|
-
await
|
|
2509
|
+
await failTurnRecord({
|
|
2505
2510
|
conversationId: args.conversationId,
|
|
2506
2511
|
expectedVersion: args.expectedVersion,
|
|
2507
|
-
|
|
2512
|
+
turnId: args.turnId,
|
|
2508
2513
|
errorMessage: args.errorMessage
|
|
2509
2514
|
});
|
|
2510
2515
|
} catch (error) {
|
|
@@ -2513,7 +2518,7 @@ async function failSessionRecordBestEffort2(args) {
|
|
|
2513
2518
|
"oauth.callback.session_record.failure_persistence.failed",
|
|
2514
2519
|
{
|
|
2515
2520
|
"app.ai.conversation_id": args.conversationId,
|
|
2516
|
-
"app.ai.session_id": args.
|
|
2521
|
+
"app.ai.session_id": args.turnId
|
|
2517
2522
|
}
|
|
2518
2523
|
);
|
|
2519
2524
|
}
|
|
@@ -2536,7 +2541,7 @@ async function persistFailedOAuthReplyState(args) {
|
|
|
2536
2541
|
await failSessionRecordBestEffort2({
|
|
2537
2542
|
conversationId: args.conversationId,
|
|
2538
2543
|
expectedVersion: args.expectedVersion,
|
|
2539
|
-
|
|
2544
|
+
turnId: args.sessionId,
|
|
2540
2545
|
errorMessage: "OAuth-resumed turn failed"
|
|
2541
2546
|
});
|
|
2542
2547
|
await persistThreadStateById(args.conversationId, {
|
|
@@ -2574,15 +2579,15 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
2574
2579
|
await persistThreadStateById(stored.resumeConversationId, {
|
|
2575
2580
|
conversation
|
|
2576
2581
|
});
|
|
2577
|
-
await
|
|
2582
|
+
await abandonTurnRecord({
|
|
2578
2583
|
conversationId: stored.resumeConversationId,
|
|
2579
|
-
|
|
2584
|
+
turnId: pendingAuth.sessionId,
|
|
2580
2585
|
errorMessage: "Auth completed after a newer thread message abandoned this blocked request."
|
|
2581
2586
|
});
|
|
2582
2587
|
return;
|
|
2583
2588
|
}
|
|
2584
2589
|
}
|
|
2585
|
-
const sessionRecord = await
|
|
2590
|
+
const sessionRecord = await getTurnRecord(
|
|
2586
2591
|
stored.resumeConversationId,
|
|
2587
2592
|
resolvedSessionId
|
|
2588
2593
|
);
|
|
@@ -2592,7 +2597,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
2592
2597
|
if (sessionRecord.state === "completed" || sessionRecord.state === "failed" || sessionRecord.state === "abandoned") {
|
|
2593
2598
|
return;
|
|
2594
2599
|
}
|
|
2595
|
-
if (sessionRecord.state !== "
|
|
2600
|
+
if (sessionRecord.state !== "paused" || sessionRecord.resumeReason !== "auth") {
|
|
2596
2601
|
return;
|
|
2597
2602
|
}
|
|
2598
2603
|
if (!userMessage?.author?.userId) {
|
|
@@ -2632,11 +2637,11 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
2632
2637
|
if (lockedSessionId !== resolvedSessionId) {
|
|
2633
2638
|
return false;
|
|
2634
2639
|
}
|
|
2635
|
-
const lockedSessionRecord = await
|
|
2640
|
+
const lockedSessionRecord = await getTurnRecord(
|
|
2636
2641
|
stored.resumeConversationId,
|
|
2637
2642
|
lockedSessionId
|
|
2638
2643
|
);
|
|
2639
|
-
if (!lockedSessionRecord || lockedSessionRecord.state !== "
|
|
2644
|
+
if (!lockedSessionRecord || lockedSessionRecord.state !== "paused" || lockedSessionRecord.resumeReason !== "auth") {
|
|
2640
2645
|
return false;
|
|
2641
2646
|
}
|
|
2642
2647
|
if (lockedPendingAuth) {
|
|
@@ -2645,9 +2650,9 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
2645
2650
|
await persistThreadStateById(stored.resumeConversationId, {
|
|
2646
2651
|
conversation: lockedConversation
|
|
2647
2652
|
});
|
|
2648
|
-
await
|
|
2653
|
+
await abandonTurnRecord({
|
|
2649
2654
|
conversationId: stored.resumeConversationId,
|
|
2650
|
-
|
|
2655
|
+
turnId: lockedPendingAuth.sessionId,
|
|
2651
2656
|
errorMessage: "Auth completed after a newer thread message abandoned this blocked request."
|
|
2652
2657
|
});
|
|
2653
2658
|
return false;
|
|
@@ -2678,10 +2683,10 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
2678
2683
|
userId: lockedUserMessage.author.userId
|
|
2679
2684
|
});
|
|
2680
2685
|
} catch {
|
|
2681
|
-
await
|
|
2686
|
+
await failTurnRecord({
|
|
2682
2687
|
conversationId: stored.resumeConversationId,
|
|
2683
2688
|
expectedVersion: lockedSessionRecord.version,
|
|
2684
|
-
|
|
2689
|
+
turnId: lockedSessionId,
|
|
2685
2690
|
errorMessage: "Unable to rebuild Slack actor for OAuth resume"
|
|
2686
2691
|
});
|
|
2687
2692
|
return false;
|
|
@@ -2692,10 +2697,10 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
2692
2697
|
conversationId: stored.resumeConversationId
|
|
2693
2698
|
});
|
|
2694
2699
|
} catch (error) {
|
|
2695
|
-
await
|
|
2700
|
+
await failTurnRecord({
|
|
2696
2701
|
conversationId: stored.resumeConversationId,
|
|
2697
2702
|
expectedVersion: lockedSessionRecord.version,
|
|
2698
|
-
|
|
2703
|
+
turnId: lockedSessionId,
|
|
2699
2704
|
errorMessage: error instanceof Error ? error.message : String(error)
|
|
2700
2705
|
});
|
|
2701
2706
|
return false;
|
|
@@ -2768,10 +2773,10 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
2768
2773
|
});
|
|
2769
2774
|
},
|
|
2770
2775
|
onPostDeliveryCommitFailure: async () => {
|
|
2771
|
-
await
|
|
2776
|
+
await failTurnRecord({
|
|
2772
2777
|
conversationId: stored.resumeConversationId,
|
|
2773
2778
|
expectedVersion: lockedSessionRecord.version,
|
|
2774
|
-
|
|
2779
|
+
turnId: lockedSessionId,
|
|
2775
2780
|
errorMessage: "OAuth-resumed reply was delivered but completion state did not persist"
|
|
2776
2781
|
});
|
|
2777
2782
|
},
|
|
@@ -2789,10 +2794,10 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
2789
2794
|
});
|
|
2790
2795
|
},
|
|
2791
2796
|
onSuspend: async (resumeVersion) => {
|
|
2792
|
-
await
|
|
2797
|
+
await wakePausedTurn({
|
|
2793
2798
|
conversationId: stored.resumeConversationId,
|
|
2794
2799
|
destination,
|
|
2795
|
-
|
|
2800
|
+
turnId: lockedSessionId,
|
|
2796
2801
|
expectedVersion: resumeVersion
|
|
2797
2802
|
});
|
|
2798
2803
|
}
|
|
@@ -3153,10 +3158,9 @@ export {
|
|
|
3153
3158
|
buildAuthPauseResponse,
|
|
3154
3159
|
getTurnRequestDeadline,
|
|
3155
3160
|
runWithTurnRequestDeadline,
|
|
3156
|
-
ResumeTurnBusyError,
|
|
3157
3161
|
resumeSlackTurn,
|
|
3158
|
-
|
|
3159
|
-
|
|
3162
|
+
getPausedTurnRequest,
|
|
3163
|
+
wakePausedTurn,
|
|
3160
3164
|
GET,
|
|
3161
3165
|
publishAppHomeView,
|
|
3162
3166
|
GET2,
|