@sentry/junior 0.91.0 → 0.92.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-MXAF7RQL.js → agent-hooks-BYSSWCNW.js} +7 -7
- package/dist/api/people/list.d.ts +3 -3
- package/dist/api/people/list.js +15 -15
- package/dist/api/people/list.query.d.ts +2 -2
- package/dist/api/people/profile.d.ts +3 -3
- package/dist/api/people/profile.js +12 -12
- package/dist/api/people/profile.query.d.ts +2 -2
- package/dist/api/people/shared.d.ts +13 -13
- package/dist/api/people/types.d.ts +12 -12
- package/dist/api-reference.d.ts +1 -1
- package/dist/app.js +334 -263
- package/dist/{catalog-runtime-DXE6NXHT.js → catalog-runtime-NZHMSMYC.js} +2 -2
- package/dist/chat/actor.d.ts +75 -0
- package/dist/chat/agent/prompt.d.ts +2 -2
- package/dist/chat/agent/request.d.ts +13 -13
- package/dist/chat/agent/resume.d.ts +5 -4
- package/dist/chat/agent/tools.d.ts +2 -2
- package/dist/chat/capabilities/jr-rpc-command.d.ts +1 -1
- package/dist/chat/conversation-privacy.d.ts +11 -0
- package/dist/chat/conversations/sql/migrations.d.ts +1 -1
- package/dist/chat/conversations/sql/schema/conversations.d.ts +2 -19
- package/dist/chat/conversations/sql/schema.d.ts +2 -19
- package/dist/chat/conversations/sql/store.d.ts +3 -3
- package/dist/chat/conversations/store.d.ts +4 -4
- package/dist/chat/credentials/context.d.ts +4 -4
- package/dist/chat/logging.d.ts +2 -2
- package/dist/chat/no-reply.d.ts +1 -1
- package/dist/chat/oauth-flow.d.ts +1 -1
- package/dist/chat/pi/messages.d.ts +2 -2
- package/dist/chat/pi/transcript.d.ts +15 -0
- package/dist/chat/plugins/agent-hooks.d.ts +3 -3
- package/dist/chat/plugins/credential-hooks.d.ts +2 -8
- package/dist/chat/prompt.d.ts +3 -6
- package/dist/chat/runtime/reply-executor.d.ts +1 -1
- package/dist/chat/runtime/turn-input.d.ts +1 -1
- package/dist/chat/sandbox/egress/schemas.d.ts +2 -2
- package/dist/chat/sandbox/egress/session.d.ts +1 -1
- package/dist/chat/services/context-compaction.d.ts +1 -1
- package/dist/chat/services/conversation-memory.d.ts +1 -1
- package/dist/chat/services/mcp-auth-orchestration.d.ts +1 -1
- package/dist/chat/services/message-actor-identity.d.ts +4 -4
- package/dist/chat/services/pending-auth.d.ts +2 -2
- package/dist/chat/services/plugin-auth-orchestration.d.ts +1 -1
- package/dist/chat/services/provider-default-config.d.ts +1 -1
- package/dist/chat/services/subscribed-decision.d.ts +1 -1
- package/dist/chat/services/turn-result.d.ts +1 -1
- package/dist/chat/services/turn-session-record.d.ts +11 -8
- package/dist/chat/services/turn-thinking-level.d.ts +1 -1
- package/dist/chat/slack/assistant-thread/title.d.ts +1 -1
- package/dist/chat/slack/tools/canvas/create.d.ts +41 -1
- package/dist/chat/slack/tools/canvas/edit.d.ts +60 -1
- package/dist/chat/slack/tools/canvas/read.d.ts +60 -1
- package/dist/chat/slack/tools/canvas/write.d.ts +41 -1
- package/dist/chat/slack/tools/channel-list-messages.d.ts +45 -1
- package/dist/chat/slack/tools/context.d.ts +3 -3
- package/dist/chat/slack/tools/list/add-items.d.ts +42 -1
- package/dist/chat/slack/tools/list/create.d.ts +40 -1
- package/dist/chat/slack/tools/list/get-items.d.ts +40 -1
- package/dist/chat/slack/tools/list/update-item.d.ts +46 -1
- package/dist/chat/slack/tools/message-add-reaction.d.ts +40 -1
- package/dist/chat/slack/tools/send-message.d.ts +45 -1
- package/dist/chat/slack/tools/thread-read.d.ts +44 -1
- package/dist/chat/slack/tools/user-lookup.d.ts +45 -1
- package/dist/chat/slack/user.d.ts +3 -3
- package/dist/chat/slack/vision-context.d.ts +2 -2
- package/dist/chat/sql/schema.d.ts +2 -19
- package/dist/chat/state/conversation-details.d.ts +4 -4
- package/dist/chat/state/conversation.d.ts +1 -1
- package/dist/chat/state/session-log.d.ts +140 -26
- package/dist/chat/state/turn-session.d.ts +18 -5
- package/dist/chat/task-execution/slack-work.d.ts +2 -2
- package/dist/chat/task-execution/state.d.ts +4 -4
- package/dist/chat/tool-support/zod-tool.d.ts +16 -4
- package/dist/chat/tools/advisor/tool.d.ts +41 -1
- package/dist/chat/tools/definition.d.ts +10 -0
- package/dist/chat/tools/execute-tool.d.ts +41 -1
- package/dist/chat/tools/resource-events.d.ts +124 -3
- package/dist/chat/tools/runtime/report-progress.d.ts +40 -1
- package/dist/chat/tools/sandbox/bash.d.ts +41 -1
- package/dist/chat/tools/sandbox/edit-file.d.ts +44 -1
- package/dist/chat/tools/sandbox/find-files.d.ts +42 -1
- package/dist/chat/tools/sandbox/grep.d.ts +46 -1
- package/dist/chat/tools/sandbox/list-dir.d.ts +41 -1
- package/dist/chat/tools/sandbox/read-file.d.ts +42 -1
- package/dist/chat/tools/sandbox/write-file.d.ts +41 -1
- package/dist/chat/tools/search-tools.d.ts +102 -1
- package/dist/chat/tools/skill/call-mcp-tool.d.ts +10 -1
- package/dist/chat/tools/skill/load-skill.d.ts +40 -1
- package/dist/chat/tools/skill/search-mcp-tools.d.ts +100 -1
- package/dist/chat/tools/system-time.d.ts +38 -1
- package/dist/chat/tools/types.d.ts +4 -4
- package/dist/chat/tools/web/fetch-tool.d.ts +41 -1
- package/dist/chat/tools/web/image-generate.d.ts +62 -1
- package/dist/chat/tools/web/search.d.ts +41 -1
- package/dist/{chunk-HXL2ZV74.js → chunk-3F54A3YM.js} +82 -11
- package/dist/{chunk-ZGDTBSQ7.js → chunk-7DVIELX3.js} +405 -136
- package/dist/{chunk-GCWD2VHP.js → chunk-7FS3K243.js} +284 -124
- package/dist/{chunk-AOISHLSF.js → chunk-ACJENBVF.js} +143 -20
- package/dist/{chunk-IRRMABQD.js → chunk-APIVR44P.js} +10 -10
- package/dist/{chunk-PIB4EOW6.js → chunk-BMQ5DXHV.js} +19 -72
- package/dist/{chunk-XP7F4LYB.js → chunk-BTH37NCU.js} +4 -4
- package/dist/{chunk-5GBUZI6M.js → chunk-H7KUZAMZ.js} +4 -4
- package/dist/{chunk-TYUXD3FN.js → chunk-MC4ZZE4Q.js} +1 -1
- package/dist/{chunk-QCKGI74V.js → chunk-N25HRI6B.js} +10 -10
- package/dist/{chunk-2S7M37HY.js → chunk-NIFONS4W.js} +86 -47
- package/dist/{chunk-ONFOWI2D.js → chunk-OJP53WIU.js} +16 -15
- package/dist/{chunk-NW7AXDA5.js → chunk-OZJXGX4U.js} +2 -2
- package/dist/{chunk-KC42JAAQ.js → chunk-PFXC67GJ.js} +3 -3
- package/dist/{chunk-ZUK7BL63.js → chunk-S6QKIGRM.js} +66 -54
- package/dist/{chunk-IX76WFJV.js → chunk-TF5VLGA7.js} +10 -10
- package/dist/{chunk-DACFZ5CI.js → chunk-VY7TVOIK.js} +16 -12
- package/dist/{chunk-AN2437E3.js → chunk-YTNPU7I2.js} +2 -2
- package/dist/{chunk-3MPOMK3K.js → chunk-YYBX2BD5.js} +61 -3
- package/dist/{chunk-RS6ANWVT.js → chunk-ZATRYQLR.js} +1 -1
- package/dist/cli/chat.js +20 -20
- package/dist/cli/check.js +3 -3
- package/dist/cli/plugins.js +9 -9
- package/dist/cli/snapshot-warmup.js +6 -6
- package/dist/cli/upgrade.js +9 -9
- package/dist/{db-CXI7PR5U.js → db-GCK43OO3.js} +4 -4
- package/dist/instrumentation.js +1 -1
- package/dist/reporting/conversations.d.ts +3 -3
- package/dist/reporting.d.ts +1 -1
- package/dist/reporting.js +48 -50
- package/dist/{runner-FKL3RAHA.js → runner-XWTFA26U.js} +20 -18
- package/dist/{validation-I7GD2YWS.js → validation-KYAWETI4.js} +3 -3
- package/package.json +6 -6
- package/dist/chat/requester.d.ts +0 -68
package/dist/app.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
scheduleSessionCompletedPluginTasks,
|
|
18
18
|
updateConversationStats,
|
|
19
19
|
upsertConversationMessage
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-ACJENBVF.js";
|
|
21
21
|
import {
|
|
22
22
|
CONVERSATION_WORK_CHECK_IN_INTERVAL_MS,
|
|
23
23
|
CONVERSATION_WORK_STALE_ENQUEUE_MS,
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
requestConversationContinuation,
|
|
42
42
|
requestConversationWork,
|
|
43
43
|
startConversationWork
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-TF5VLGA7.js";
|
|
45
45
|
import {
|
|
46
46
|
getVercelConversationWorkQueue,
|
|
47
47
|
resolveConversationWorkQueueTopic,
|
|
@@ -60,11 +60,11 @@ import {
|
|
|
60
60
|
resolveSlackChannelTypeFromMessage,
|
|
61
61
|
resolveSlackConversationContext,
|
|
62
62
|
setConversationTitle
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-N25HRI6B.js";
|
|
64
64
|
import {
|
|
65
65
|
validatePluginEgressCredentialHooks,
|
|
66
66
|
validatePluginRegistrations
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-MC4ZZE4Q.js";
|
|
68
68
|
import {
|
|
69
69
|
defineJuniorPlugins,
|
|
70
70
|
pluginCatalogConfigFromEnv,
|
|
@@ -104,7 +104,7 @@ import {
|
|
|
104
104
|
shouldPropagateSandboxEgressTrace,
|
|
105
105
|
startOAuthFlow,
|
|
106
106
|
unlinkProvider
|
|
107
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-7DVIELX3.js";
|
|
108
108
|
import {
|
|
109
109
|
CooperativeTurnYieldError,
|
|
110
110
|
TurnInputCommitLostError,
|
|
@@ -131,32 +131,33 @@ import {
|
|
|
131
131
|
persistThreadStateById,
|
|
132
132
|
persistYieldSessionRecord,
|
|
133
133
|
startActiveTurn
|
|
134
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-OJP53WIU.js";
|
|
135
135
|
import {
|
|
136
136
|
JUNIOR_THREAD_STATE_TTL_MS,
|
|
137
137
|
coerceThreadConversationState
|
|
138
|
-
} from "./chunk-
|
|
139
|
-
import "./chunk-
|
|
138
|
+
} from "./chunk-PFXC67GJ.js";
|
|
139
|
+
import "./chunk-H7KUZAMZ.js";
|
|
140
140
|
import {
|
|
141
141
|
buildSlackOutputMessage,
|
|
142
142
|
escapeSlackMrkdwnText,
|
|
143
143
|
formatSlackLink,
|
|
144
144
|
normalizeSlackStatusText,
|
|
145
145
|
splitSlackReplyText,
|
|
146
|
-
truncateStatusText
|
|
147
|
-
|
|
148
|
-
} from "./chunk-PIB4EOW6.js";
|
|
146
|
+
truncateStatusText
|
|
147
|
+
} from "./chunk-BMQ5DXHV.js";
|
|
149
148
|
import {
|
|
150
149
|
abandonAgentTurnSessionRecord,
|
|
151
150
|
commitMessages,
|
|
152
|
-
|
|
151
|
+
contextProvenance,
|
|
153
152
|
failAgentTurnSessionRecord,
|
|
154
153
|
getAgentTurnSessionRecord,
|
|
154
|
+
instructionProvenanceFor,
|
|
155
155
|
listAgentTurnSessionSummariesForConversation,
|
|
156
156
|
loadProjection,
|
|
157
|
+
loadProjectionWithProvenance,
|
|
157
158
|
recordAgentTurnSessionSummary,
|
|
158
159
|
recordAuthorizationCompleted
|
|
159
|
-
} from "./chunk-
|
|
160
|
+
} from "./chunk-7FS3K243.js";
|
|
160
161
|
import {
|
|
161
162
|
SlackActionError,
|
|
162
163
|
bindSlackDirectCredentialSubject,
|
|
@@ -175,25 +176,26 @@ import {
|
|
|
175
176
|
setPlugins,
|
|
176
177
|
validatePlugins,
|
|
177
178
|
verifySlackDirectCredentialSubject
|
|
178
|
-
} from "./chunk-
|
|
179
|
+
} from "./chunk-VY7TVOIK.js";
|
|
179
180
|
import {
|
|
180
181
|
createPluginLogger,
|
|
181
182
|
createPluginState
|
|
182
|
-
} from "./chunk-
|
|
183
|
+
} from "./chunk-OZJXGX4U.js";
|
|
183
184
|
import "./chunk-G3E7SCME.js";
|
|
184
185
|
import {
|
|
185
186
|
acquireActiveLock,
|
|
186
187
|
getStateAdapter
|
|
187
|
-
} from "./chunk-
|
|
188
|
+
} from "./chunk-ZATRYQLR.js";
|
|
188
189
|
import {
|
|
189
190
|
getConversationStore,
|
|
190
191
|
getDb
|
|
191
|
-
} from "./chunk-
|
|
192
|
+
} from "./chunk-NIFONS4W.js";
|
|
192
193
|
import {
|
|
193
194
|
FUNCTION_TIMEOUT_BUFFER_SECONDS,
|
|
194
195
|
botConfig,
|
|
195
196
|
completeObject,
|
|
196
197
|
completeText,
|
|
198
|
+
escapeXml,
|
|
197
199
|
getChatConfig,
|
|
198
200
|
getRuntimeMetadata,
|
|
199
201
|
getSlackBotToken,
|
|
@@ -205,14 +207,15 @@ import {
|
|
|
205
207
|
normalizeSlackEmojiName,
|
|
206
208
|
setSlackReactionConfig,
|
|
207
209
|
stripRuntimeTurnContext,
|
|
208
|
-
trimTrailingAssistantMessages
|
|
209
|
-
|
|
210
|
+
trimTrailingAssistantMessages,
|
|
211
|
+
unwrapCurrentInstruction
|
|
212
|
+
} from "./chunk-3F54A3YM.js";
|
|
210
213
|
import {
|
|
211
214
|
parseSlackThreadId,
|
|
212
215
|
readSlackRawMessageContext,
|
|
213
216
|
resolveSlackChannelIdFromMessage,
|
|
214
217
|
resolveSlackChannelIdFromThreadId
|
|
215
|
-
} from "./chunk-
|
|
218
|
+
} from "./chunk-YYBX2BD5.js";
|
|
216
219
|
import {
|
|
217
220
|
createSlackDestination,
|
|
218
221
|
destinationKey,
|
|
@@ -222,22 +225,23 @@ import {
|
|
|
222
225
|
} from "./chunk-GHGPTPBL.js";
|
|
223
226
|
import {
|
|
224
227
|
discoverSkills
|
|
225
|
-
} from "./chunk-
|
|
228
|
+
} from "./chunk-YTNPU7I2.js";
|
|
226
229
|
import {
|
|
227
230
|
buildOAuthTokenRequest,
|
|
228
231
|
hasRequiredOAuthScope,
|
|
229
232
|
parseOAuthTokenResponse,
|
|
230
233
|
pluginCatalogRuntime
|
|
231
|
-
} from "./chunk-
|
|
234
|
+
} from "./chunk-BTH37NCU.js";
|
|
232
235
|
import {
|
|
233
236
|
buildTurnFailureResponse,
|
|
237
|
+
createActor,
|
|
234
238
|
createChatSdkLogger,
|
|
235
239
|
createRequestContext,
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
createSlackResumeRequester,
|
|
240
|
+
createSlackActor,
|
|
241
|
+
createSlackResumeActor,
|
|
239
242
|
getActiveTraceId,
|
|
240
243
|
isActorUserId,
|
|
244
|
+
isUserActor,
|
|
241
245
|
logError,
|
|
242
246
|
logException,
|
|
243
247
|
logInfo,
|
|
@@ -247,10 +251,10 @@ import {
|
|
|
247
251
|
setSpanAttributes,
|
|
248
252
|
setSpanStatus,
|
|
249
253
|
setTags,
|
|
250
|
-
|
|
254
|
+
toStoredSlackActor,
|
|
251
255
|
withContext,
|
|
252
256
|
withSpan
|
|
253
|
-
} from "./chunk-
|
|
257
|
+
} from "./chunk-S6QKIGRM.js";
|
|
254
258
|
import {
|
|
255
259
|
toOptionalString
|
|
256
260
|
} from "./chunk-OB42YVAE.js";
|
|
@@ -584,8 +588,8 @@ var dispatchStatusSchema = z.enum([
|
|
|
584
588
|
"blocked"
|
|
585
589
|
]);
|
|
586
590
|
var dispatchActorSchema = z.object({
|
|
587
|
-
|
|
588
|
-
|
|
591
|
+
platform: z.literal("system"),
|
|
592
|
+
name: nonEmptyExactStringSchema
|
|
589
593
|
}).strict();
|
|
590
594
|
var credentialSubjectBindingSchema = z.object({
|
|
591
595
|
type: z.literal("slack-direct-conversation"),
|
|
@@ -772,7 +776,7 @@ async function createOrGetDispatch(args) {
|
|
|
772
776
|
}
|
|
773
777
|
const metadata = normalizeMetadata(args.options.metadata);
|
|
774
778
|
const record = {
|
|
775
|
-
actor: {
|
|
779
|
+
actor: { platform: "system", name: args.plugin },
|
|
776
780
|
attempt: 0,
|
|
777
781
|
createdAtMs: args.nowMs,
|
|
778
782
|
...args.options.credentialSubject ? { credentialSubject: args.options.credentialSubject } : {},
|
|
@@ -850,7 +854,7 @@ function upsertDispatchUserMessage(args) {
|
|
|
850
854
|
),
|
|
851
855
|
createdAtMs: args.nowMs,
|
|
852
856
|
author: {
|
|
853
|
-
userName: `system:${args.dispatch.actor.
|
|
857
|
+
userName: `system:${args.dispatch.actor.name}`,
|
|
854
858
|
isBot: true
|
|
855
859
|
},
|
|
856
860
|
meta: {
|
|
@@ -923,8 +927,8 @@ async function runAgentDispatchSlice(callback, deps) {
|
|
|
923
927
|
slackThreadId: conversationId,
|
|
924
928
|
slackChannelId: dispatch.destination.channelId,
|
|
925
929
|
runId: dispatch.id,
|
|
926
|
-
actorType: dispatch.actor.
|
|
927
|
-
actorId: dispatch.actor.
|
|
930
|
+
actorType: dispatch.actor.platform,
|
|
931
|
+
actorId: dispatch.actor.name,
|
|
928
932
|
assistantUserName: botConfig.userName
|
|
929
933
|
};
|
|
930
934
|
const destinationLockId = getDispatchDestinationLockId(dispatch.destination);
|
|
@@ -1143,6 +1147,7 @@ async function runAgentDispatchSlice(callback, deps) {
|
|
|
1143
1147
|
usage: reply.diagnostics.usage,
|
|
1144
1148
|
destination: dispatch.destination,
|
|
1145
1149
|
source: dispatch.source,
|
|
1150
|
+
actor: dispatch.actor,
|
|
1146
1151
|
surface: "api",
|
|
1147
1152
|
logContext: {
|
|
1148
1153
|
threadId: conversationId,
|
|
@@ -1276,7 +1281,7 @@ async function recordExecutionMetadata(args) {
|
|
|
1276
1281
|
updatedAtMs: conversation.execution.updatedAtMs
|
|
1277
1282
|
},
|
|
1278
1283
|
lastActivityAtMs: conversation.lastActivityAtMs,
|
|
1279
|
-
|
|
1284
|
+
actor: conversation.actor,
|
|
1280
1285
|
source: conversation.source,
|
|
1281
1286
|
title: conversation.title,
|
|
1282
1287
|
updatedAtMs: conversation.updatedAtMs
|
|
@@ -1573,53 +1578,51 @@ async function runWithSlackInstallation(args) {
|
|
|
1573
1578
|
|
|
1574
1579
|
// src/chat/services/message-actor-identity.ts
|
|
1575
1580
|
var messageActors = /* @__PURE__ */ new WeakMap();
|
|
1576
|
-
function canonicalUserId(author,
|
|
1581
|
+
function canonicalUserId(author, actor) {
|
|
1577
1582
|
const authorUserId = parseActorUserId(author.userId);
|
|
1578
|
-
if (authorUserId && authorUserId !==
|
|
1579
|
-
throw new Error("Message
|
|
1583
|
+
if (authorUserId && authorUserId !== actor.userId) {
|
|
1584
|
+
throw new Error("Message actor user id mismatch");
|
|
1580
1585
|
}
|
|
1581
|
-
const userId = authorUserId ??
|
|
1586
|
+
const userId = authorUserId ?? actor.userId;
|
|
1582
1587
|
if (!userId) {
|
|
1583
|
-
throw new Error("Message
|
|
1588
|
+
throw new Error("Message actor requires a user id");
|
|
1584
1589
|
}
|
|
1585
1590
|
return userId;
|
|
1586
1591
|
}
|
|
1587
|
-
function
|
|
1592
|
+
function actorFromAuthor(author) {
|
|
1588
1593
|
const userId = parseActorUserId(author.userId);
|
|
1589
1594
|
return userId ? { userId } : void 0;
|
|
1590
1595
|
}
|
|
1591
|
-
function
|
|
1592
|
-
if (!isActorUserId(
|
|
1593
|
-
throw new Error("Message
|
|
1596
|
+
function applyActorToAuthor(author, actor) {
|
|
1597
|
+
if (!isActorUserId(actor.userId)) {
|
|
1598
|
+
throw new Error("Message actor requires a user id");
|
|
1594
1599
|
}
|
|
1595
|
-
author.userId =
|
|
1596
|
-
author.userName =
|
|
1597
|
-
author.fullName =
|
|
1600
|
+
author.userId = actor.userId;
|
|
1601
|
+
author.userName = actor.userName ?? "";
|
|
1602
|
+
author.fullName = actor.fullName ?? "";
|
|
1598
1603
|
}
|
|
1599
|
-
function bindMessageActorIdentity(message,
|
|
1600
|
-
const userId = canonicalUserId(message.author,
|
|
1601
|
-
const
|
|
1602
|
-
platform:
|
|
1603
|
-
...
|
|
1604
|
+
function bindMessageActorIdentity(message, actor) {
|
|
1605
|
+
const userId = canonicalUserId(message.author, actor);
|
|
1606
|
+
const currentActor = createActor(actor, {
|
|
1607
|
+
platform: actor.platform,
|
|
1608
|
+
...actor.platform === "slack" ? { teamId: actor.teamId } : {},
|
|
1604
1609
|
userId
|
|
1605
1610
|
});
|
|
1606
|
-
if (!
|
|
1607
|
-
throw new Error("Message
|
|
1611
|
+
if (!currentActor) {
|
|
1612
|
+
throw new Error("Message actor requires a user id");
|
|
1608
1613
|
}
|
|
1609
|
-
messageActors.set(message,
|
|
1610
|
-
|
|
1611
|
-
return
|
|
1614
|
+
messageActors.set(message, currentActor);
|
|
1615
|
+
applyActorToAuthor(message.author, currentActor);
|
|
1616
|
+
return currentActor;
|
|
1612
1617
|
}
|
|
1613
1618
|
function getMessageActorIdentity(message) {
|
|
1614
|
-
return messageActors.get(message) ??
|
|
1619
|
+
return messageActors.get(message) ?? actorFromAuthor(message.author);
|
|
1615
1620
|
}
|
|
1616
1621
|
async function ensureSlackMessageActorIdentity(message, teamId, lookupSlackUser2) {
|
|
1617
1622
|
const existing = messageActors.get(message);
|
|
1618
1623
|
if (existing) {
|
|
1619
1624
|
if (existing.platform !== "slack") {
|
|
1620
|
-
throw new Error(
|
|
1621
|
-
"Slack message actor identity requires a Slack requester"
|
|
1622
|
-
);
|
|
1625
|
+
throw new Error("Slack message actor identity requires a Slack actor");
|
|
1623
1626
|
}
|
|
1624
1627
|
return existing;
|
|
1625
1628
|
}
|
|
@@ -1627,14 +1630,14 @@ async function ensureSlackMessageActorIdentity(message, teamId, lookupSlackUser2
|
|
|
1627
1630
|
if (!userId) {
|
|
1628
1631
|
throw new Error("Slack message actor identity requires a user id");
|
|
1629
1632
|
}
|
|
1630
|
-
const
|
|
1633
|
+
const actor = bindMessageActorIdentity(
|
|
1631
1634
|
message,
|
|
1632
|
-
|
|
1635
|
+
createSlackActor(teamId, userId, await lookupSlackUser2(teamId, userId))
|
|
1633
1636
|
);
|
|
1634
|
-
if (
|
|
1635
|
-
throw new Error("Slack message actor identity requires a Slack
|
|
1637
|
+
if (actor.platform !== "slack") {
|
|
1638
|
+
throw new Error("Slack message actor identity requires a Slack actor");
|
|
1636
1639
|
}
|
|
1637
|
-
return
|
|
1640
|
+
return actor;
|
|
1638
1641
|
}
|
|
1639
1642
|
|
|
1640
1643
|
// src/chat/slack/user.ts
|
|
@@ -1719,8 +1722,8 @@ async function lookupSlackUser(teamId, userId) {
|
|
|
1719
1722
|
return null;
|
|
1720
1723
|
}
|
|
1721
1724
|
}
|
|
1722
|
-
async function
|
|
1723
|
-
return
|
|
1725
|
+
async function lookupSlackActor(teamId, userId) {
|
|
1726
|
+
return createSlackActor(
|
|
1724
1727
|
teamId,
|
|
1725
1728
|
userId,
|
|
1726
1729
|
await lookupSlackUser(teamId, userId)
|
|
@@ -3772,8 +3775,8 @@ function getResumeLogContext(args, lockKey) {
|
|
|
3772
3775
|
return {
|
|
3773
3776
|
conversationId: routing?.correlation?.conversationId ?? lockKey,
|
|
3774
3777
|
slackThreadId: routing?.correlation?.threadId ?? lockKey,
|
|
3775
|
-
slackUserId: routing?.
|
|
3776
|
-
slackUserName: routing?.
|
|
3778
|
+
slackUserId: isUserActor(routing?.actor) ? routing.actor.userId : routing?.correlation?.actorId,
|
|
3779
|
+
slackUserName: isUserActor(routing?.actor) ? routing.actor.userName : void 0,
|
|
3777
3780
|
slackChannelId: args.channelId,
|
|
3778
3781
|
runId: routing?.correlation?.runId,
|
|
3779
3782
|
assistantUserName: botConfig.userName,
|
|
@@ -3849,7 +3852,7 @@ function createResumeReplyContext(args, statusSession) {
|
|
|
3849
3852
|
threadId: replyContext.routing.correlation?.threadId ?? threadId,
|
|
3850
3853
|
channelId: replyContext.routing.correlation?.channelId ?? args.channelId,
|
|
3851
3854
|
threadTs: replyContext.routing.correlation?.threadTs ?? args.threadTs,
|
|
3852
|
-
|
|
3855
|
+
actorId: replyContext.routing.correlation?.actorId ?? (isUserActor(replyContext.routing.actor) ? replyContext.routing.actor.userId : void 0)
|
|
3853
3856
|
}
|
|
3854
3857
|
},
|
|
3855
3858
|
policy: {
|
|
@@ -3909,18 +3912,25 @@ async function resumeSlackTurn(args) {
|
|
|
3909
3912
|
if (preparedArgs) {
|
|
3910
3913
|
runArgs = { ...args, ...preparedArgs };
|
|
3911
3914
|
}
|
|
3912
|
-
|
|
3915
|
+
const activeReplyContext = runArgs.replyContext;
|
|
3916
|
+
if (!activeReplyContext) {
|
|
3913
3917
|
throw new Error(
|
|
3914
|
-
"Resumed turn requires replyContext.routing.
|
|
3918
|
+
"Resumed turn requires replyContext.routing.actor.userId"
|
|
3915
3919
|
);
|
|
3916
3920
|
}
|
|
3917
|
-
const
|
|
3921
|
+
const resumeActor = activeReplyContext.routing.actor;
|
|
3922
|
+
if (!isUserActor(resumeActor)) {
|
|
3923
|
+
throw new Error(
|
|
3924
|
+
"Resumed turn requires replyContext.routing.actor.userId"
|
|
3925
|
+
);
|
|
3926
|
+
}
|
|
3927
|
+
const credentialContext = activeReplyContext.routing.credentialContext;
|
|
3918
3928
|
if (!credentialContext) {
|
|
3919
3929
|
throw new Error("Resumed turn requires replyContext.credentialContext");
|
|
3920
3930
|
}
|
|
3921
|
-
if (credentialContext.actor
|
|
3931
|
+
if (!("type" in credentialContext.actor) || credentialContext.actor.userId !== resumeActor.userId) {
|
|
3922
3932
|
throw new Error(
|
|
3923
|
-
"Resumed turn credential actor must match replyContext.routing.
|
|
3933
|
+
"Resumed turn credential actor must match replyContext.routing.actor.userId"
|
|
3924
3934
|
);
|
|
3925
3935
|
}
|
|
3926
3936
|
if (runArgs.messageTs) {
|
|
@@ -3963,7 +3973,7 @@ async function resumeSlackTurn(args) {
|
|
|
3963
3973
|
deferredPauseKind = "auth";
|
|
3964
3974
|
deferredAuthInfo = {
|
|
3965
3975
|
providerDisplayName: outcome.providerDisplayName,
|
|
3966
|
-
|
|
3976
|
+
actorId: resumeActor.userId
|
|
3967
3977
|
};
|
|
3968
3978
|
deferredPauseHandler = async () => {
|
|
3969
3979
|
await onAuthPause({
|
|
@@ -4015,11 +4025,11 @@ async function resumeSlackTurn(args) {
|
|
|
4015
4025
|
currentUsage: reply.diagnostics.usage,
|
|
4016
4026
|
destination: replyContext.routing.destination,
|
|
4017
4027
|
source: replyContext.routing.source,
|
|
4018
|
-
|
|
4028
|
+
actor: replyContext.routing.actor,
|
|
4019
4029
|
surface: "slack",
|
|
4020
4030
|
logContext: {
|
|
4021
4031
|
threadId: replyContext.routing.correlation.threadId,
|
|
4022
|
-
|
|
4032
|
+
actorId: isUserActor(replyContext.routing.actor) ? replyContext.routing.actor.userId : void 0,
|
|
4023
4033
|
channelId: runArgs.channelId,
|
|
4024
4034
|
runId: replyContext.routing.correlation.runId,
|
|
4025
4035
|
assistantUserName: botConfig.userName,
|
|
@@ -4105,7 +4115,7 @@ async function resumeSlackTurn(args) {
|
|
|
4105
4115
|
runArgs.channelId,
|
|
4106
4116
|
runArgs.threadTs,
|
|
4107
4117
|
buildAuthPauseResponse(
|
|
4108
|
-
deferredAuthInfo.
|
|
4118
|
+
deferredAuthInfo.actorId,
|
|
4109
4119
|
deferredAuthInfo.providerDisplayName
|
|
4110
4120
|
),
|
|
4111
4121
|
footer
|
|
@@ -4349,7 +4359,7 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
4349
4359
|
conversation,
|
|
4350
4360
|
kind: "mcp",
|
|
4351
4361
|
provider,
|
|
4352
|
-
|
|
4362
|
+
actorId: authSession.userId
|
|
4353
4363
|
});
|
|
4354
4364
|
const resolvedSessionId = pendingAuth?.sessionId ?? authSession.sessionId;
|
|
4355
4365
|
const userMessage2 = getTurnUserMessage(conversation, resolvedSessionId);
|
|
@@ -4386,7 +4396,7 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
4386
4396
|
conversation: lockedConversation,
|
|
4387
4397
|
kind: "mcp",
|
|
4388
4398
|
provider,
|
|
4389
|
-
|
|
4399
|
+
actorId: authSession.userId
|
|
4390
4400
|
});
|
|
4391
4401
|
const lockedSessionId = lockedPendingAuth?.sessionId ?? authSession.sessionId;
|
|
4392
4402
|
if (lockedSessionId !== resolvedSessionId) {
|
|
@@ -4431,10 +4441,10 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
4431
4441
|
const lockedChannelConfiguration = getChannelConfigurationServiceById(
|
|
4432
4442
|
authSession.channelId
|
|
4433
4443
|
);
|
|
4434
|
-
let
|
|
4444
|
+
let actor;
|
|
4435
4445
|
try {
|
|
4436
|
-
|
|
4437
|
-
|
|
4446
|
+
actor = createSlackResumeActor({
|
|
4447
|
+
actor: isUserActor(lockedSessionRecord.actor) ? lockedSessionRecord.actor : void 0,
|
|
4438
4448
|
teamId: destination.teamId,
|
|
4439
4449
|
userId: authSession.userId
|
|
4440
4450
|
});
|
|
@@ -4443,7 +4453,7 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
4443
4453
|
conversationId: authSession.conversationId,
|
|
4444
4454
|
expectedVersion: lockedSessionRecord.version,
|
|
4445
4455
|
sessionId: lockedSessionId,
|
|
4446
|
-
errorMessage: "Stored Slack
|
|
4456
|
+
errorMessage: "Stored Slack actor identity did not match OAuth actor"
|
|
4447
4457
|
});
|
|
4448
4458
|
return false;
|
|
4449
4459
|
}
|
|
@@ -4460,7 +4470,7 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
4460
4470
|
conversationId: authSession.conversationId,
|
|
4461
4471
|
kind: "mcp",
|
|
4462
4472
|
provider,
|
|
4463
|
-
|
|
4473
|
+
actorId: authSession.userId,
|
|
4464
4474
|
authorizationId: mcpAuthorizationId({
|
|
4465
4475
|
provider,
|
|
4466
4476
|
sessionId: lockedSessionId
|
|
@@ -4479,9 +4489,9 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
4479
4489
|
},
|
|
4480
4490
|
routing: {
|
|
4481
4491
|
credentialContext: {
|
|
4482
|
-
actor: { type: "user", userId:
|
|
4492
|
+
actor: { type: "user", userId: actor.userId }
|
|
4483
4493
|
},
|
|
4484
|
-
|
|
4494
|
+
actor,
|
|
4485
4495
|
destination,
|
|
4486
4496
|
source: lockedSessionRecord.source,
|
|
4487
4497
|
correlation: {
|
|
@@ -4489,7 +4499,7 @@ async function resumeAuthorizedMcpTurn(args) {
|
|
|
4489
4499
|
turnId: lockedSessionId,
|
|
4490
4500
|
channelId: authSession.channelId,
|
|
4491
4501
|
threadTs: authSession.threadTs,
|
|
4492
|
-
|
|
4502
|
+
actorId: actor.userId
|
|
4493
4503
|
},
|
|
4494
4504
|
toolChannelId: authSession.toolChannelId ?? lockedArtifacts.assistantContextChannelId ?? authSession.channelId
|
|
4495
4505
|
},
|
|
@@ -4860,7 +4870,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
4860
4870
|
conversation,
|
|
4861
4871
|
kind: "plugin",
|
|
4862
4872
|
provider: stored.provider,
|
|
4863
|
-
|
|
4873
|
+
actorId: stored.userId,
|
|
4864
4874
|
...stored.scope ? { scope: stored.scope } : {}
|
|
4865
4875
|
});
|
|
4866
4876
|
const resolvedSessionId = pendingAuth?.sessionId ?? stored.resumeSessionId;
|
|
@@ -4916,7 +4926,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
4916
4926
|
conversation: lockedConversation,
|
|
4917
4927
|
kind: "plugin",
|
|
4918
4928
|
provider: stored.provider,
|
|
4919
|
-
|
|
4929
|
+
actorId: stored.userId,
|
|
4920
4930
|
...stored.scope ? { scope: stored.scope } : {}
|
|
4921
4931
|
});
|
|
4922
4932
|
const lockedSessionId = lockedPendingAuth?.sessionId ?? stored.resumeSessionId;
|
|
@@ -4962,10 +4972,10 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
4962
4972
|
const lockedChannelConfiguration = getChannelConfigurationServiceById(
|
|
4963
4973
|
stored.channelId
|
|
4964
4974
|
);
|
|
4965
|
-
let
|
|
4975
|
+
let actor;
|
|
4966
4976
|
try {
|
|
4967
|
-
|
|
4968
|
-
|
|
4977
|
+
actor = createSlackResumeActor({
|
|
4978
|
+
actor: isUserActor(lockedSessionRecord.actor) ? lockedSessionRecord.actor : void 0,
|
|
4969
4979
|
teamId: destination.teamId,
|
|
4970
4980
|
userId: lockedUserMessage.author.userId
|
|
4971
4981
|
});
|
|
@@ -4974,7 +4984,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
4974
4984
|
conversationId: stored.resumeConversationId,
|
|
4975
4985
|
expectedVersion: lockedSessionRecord.version,
|
|
4976
4986
|
sessionId: lockedSessionId,
|
|
4977
|
-
errorMessage: "Stored Slack
|
|
4987
|
+
errorMessage: "Stored Slack actor identity did not match OAuth actor"
|
|
4978
4988
|
});
|
|
4979
4989
|
return false;
|
|
4980
4990
|
}
|
|
@@ -4991,7 +5001,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
4991
5001
|
conversationId: stored.resumeConversationId,
|
|
4992
5002
|
kind: "plugin",
|
|
4993
5003
|
provider: stored.provider,
|
|
4994
|
-
|
|
5004
|
+
actorId: stored.userId,
|
|
4995
5005
|
authorizationId: pluginAuthorizationId({
|
|
4996
5006
|
provider: stored.provider,
|
|
4997
5007
|
sessionId: lockedSessionId
|
|
@@ -5012,10 +5022,10 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
5012
5022
|
credentialContext: {
|
|
5013
5023
|
actor: {
|
|
5014
5024
|
type: "user",
|
|
5015
|
-
userId:
|
|
5025
|
+
userId: actor.userId
|
|
5016
5026
|
}
|
|
5017
5027
|
},
|
|
5018
|
-
|
|
5028
|
+
actor,
|
|
5019
5029
|
destination,
|
|
5020
5030
|
source: lockedSessionRecord.source,
|
|
5021
5031
|
correlation: {
|
|
@@ -5023,7 +5033,7 @@ async function resumeOAuthSessionRecordTurn(stored, options) {
|
|
|
5023
5033
|
turnId: lockedSessionId,
|
|
5024
5034
|
channelId: stored.channelId,
|
|
5025
5035
|
threadTs: stored.threadTs,
|
|
5026
|
-
|
|
5036
|
+
actorId: actor.userId
|
|
5027
5037
|
},
|
|
5028
5038
|
toolChannelId: lockedArtifacts.assistantContextChannelId ?? stored.channelId
|
|
5029
5039
|
},
|
|
@@ -5116,10 +5126,7 @@ async function resumePendingOAuthMessage(stored, options) {
|
|
|
5116
5126
|
stored.destination,
|
|
5117
5127
|
"OAuth pending message resume"
|
|
5118
5128
|
);
|
|
5119
|
-
const
|
|
5120
|
-
destination.teamId,
|
|
5121
|
-
stored.userId
|
|
5122
|
-
);
|
|
5129
|
+
const actor = await lookupSlackActor(destination.teamId, stored.userId);
|
|
5123
5130
|
const messageTs = getTurnUserSlackMessageTs(latestUserMessage);
|
|
5124
5131
|
await resumeAuthorizedRequest({
|
|
5125
5132
|
messageText: stored.pendingMessage,
|
|
@@ -5137,14 +5144,14 @@ async function resumePendingOAuthMessage(stored, options) {
|
|
|
5137
5144
|
credentialContext: {
|
|
5138
5145
|
actor: { type: "user", userId: stored.userId }
|
|
5139
5146
|
},
|
|
5140
|
-
|
|
5147
|
+
actor,
|
|
5141
5148
|
destination: stored.destination,
|
|
5142
5149
|
source,
|
|
5143
5150
|
correlation: {
|
|
5144
5151
|
conversationId: threadId,
|
|
5145
5152
|
channelId: stored.channelId,
|
|
5146
5153
|
threadTs: stored.threadTs,
|
|
5147
|
-
|
|
5154
|
+
actorId: stored.userId
|
|
5148
5155
|
}
|
|
5149
5156
|
},
|
|
5150
5157
|
policy: {
|
|
@@ -5836,17 +5843,17 @@ function isExternalSlackUser(raw) {
|
|
|
5836
5843
|
async function postEphemeral(event, text) {
|
|
5837
5844
|
await event.channel.postEphemeral(event.user, text, { fallbackToDM: false });
|
|
5838
5845
|
}
|
|
5839
|
-
function
|
|
5846
|
+
function requireActorId(event) {
|
|
5840
5847
|
const userId = parseActorUserId(event.user.userId);
|
|
5841
5848
|
if (!userId) {
|
|
5842
|
-
throw new Error("Slack slash command requires a
|
|
5849
|
+
throw new Error("Slack slash command requires a actor user id");
|
|
5843
5850
|
}
|
|
5844
5851
|
return userId;
|
|
5845
5852
|
}
|
|
5846
5853
|
function getCommandName() {
|
|
5847
5854
|
return getChatConfig().slack.slashCommand;
|
|
5848
5855
|
}
|
|
5849
|
-
async function handleLink(event,
|
|
5856
|
+
async function handleLink(event, actorId, provider) {
|
|
5850
5857
|
if (!pluginCatalogRuntime.isProvider(provider)) {
|
|
5851
5858
|
await postEphemeral(event, `Unknown provider: \`${provider}\``);
|
|
5852
5859
|
return;
|
|
@@ -5860,7 +5867,7 @@ async function handleLink(event, requesterId, provider) {
|
|
|
5860
5867
|
}
|
|
5861
5868
|
const raw = event.raw;
|
|
5862
5869
|
const result = await startOAuthFlow(provider, {
|
|
5863
|
-
|
|
5870
|
+
actorId,
|
|
5864
5871
|
channelId: raw.channel_id
|
|
5865
5872
|
});
|
|
5866
5873
|
if (!result.ok) {
|
|
@@ -5879,7 +5886,7 @@ async function handleLink(event, requesterId, provider) {
|
|
|
5879
5886
|
);
|
|
5880
5887
|
}
|
|
5881
5888
|
}
|
|
5882
|
-
async function handleUnlink(event,
|
|
5889
|
+
async function handleUnlink(event, actorId, provider) {
|
|
5883
5890
|
if (!pluginCatalogRuntime.isProvider(provider)) {
|
|
5884
5891
|
await postEphemeral(event, `Unknown provider: \`${provider}\``);
|
|
5885
5892
|
return;
|
|
@@ -5892,10 +5899,10 @@ async function handleUnlink(event, requesterId, provider) {
|
|
|
5892
5899
|
return;
|
|
5893
5900
|
}
|
|
5894
5901
|
const tokenStore = createUserTokenStore();
|
|
5895
|
-
await tokenStore.delete(
|
|
5902
|
+
await tokenStore.delete(actorId, provider);
|
|
5896
5903
|
logInfo(
|
|
5897
5904
|
"slash_command_unlink",
|
|
5898
|
-
{ slackUserId:
|
|
5905
|
+
{ slackUserId: actorId },
|
|
5899
5906
|
{ "app.credential.provider": provider },
|
|
5900
5907
|
`Unlinked ${formatProviderLabel(provider)} account via ${getCommandName()} slash command`
|
|
5901
5908
|
);
|
|
@@ -5921,11 +5928,11 @@ async function handleSlashCommand(event) {
|
|
|
5921
5928
|
return;
|
|
5922
5929
|
}
|
|
5923
5930
|
const normalized = provider.toLowerCase();
|
|
5924
|
-
const
|
|
5931
|
+
const actorId = requireActorId(event);
|
|
5925
5932
|
if (subcommand === "link") {
|
|
5926
|
-
await handleLink(event,
|
|
5933
|
+
await handleLink(event, actorId, normalized);
|
|
5927
5934
|
} else {
|
|
5928
|
-
await handleUnlink(event,
|
|
5935
|
+
await handleUnlink(event, actorId, normalized);
|
|
5929
5936
|
}
|
|
5930
5937
|
}
|
|
5931
5938
|
|
|
@@ -6202,7 +6209,7 @@ async function handleSlashCommandForm(args) {
|
|
|
6202
6209
|
"Slack slash command payload"
|
|
6203
6210
|
);
|
|
6204
6211
|
const teamId = args.params.get("team_id") ?? void 0;
|
|
6205
|
-
const userIdentity =
|
|
6212
|
+
const userIdentity = createActor(
|
|
6206
6213
|
{
|
|
6207
6214
|
platform: "slack",
|
|
6208
6215
|
teamId,
|
|
@@ -7424,7 +7431,7 @@ async function decideSubscribedThreadReply(args) {
|
|
|
7424
7431
|
modelId: args.modelId,
|
|
7425
7432
|
threadId: args.input.context.threadId ?? "",
|
|
7426
7433
|
channelId: args.input.context.channelId ?? "",
|
|
7427
|
-
|
|
7434
|
+
actorId: args.input.context.actorId ?? "",
|
|
7428
7435
|
runId: args.input.context.runId ?? ""
|
|
7429
7436
|
}
|
|
7430
7437
|
});
|
|
@@ -7558,15 +7565,15 @@ function buildLogContext(deps, args) {
|
|
|
7558
7565
|
return {
|
|
7559
7566
|
conversationId: args.threadId ?? args.runId,
|
|
7560
7567
|
slackThreadId: args.threadId,
|
|
7561
|
-
slackUserId: args.
|
|
7562
|
-
slackUserName: args.
|
|
7568
|
+
slackUserId: args.actorId,
|
|
7569
|
+
slackUserName: args.actorUserName,
|
|
7563
7570
|
slackChannelId: args.channelId,
|
|
7564
7571
|
runId: args.runId,
|
|
7565
7572
|
assistantUserName: deps.assistantUserName,
|
|
7566
7573
|
modelId: deps.modelId
|
|
7567
7574
|
};
|
|
7568
7575
|
}
|
|
7569
|
-
function
|
|
7576
|
+
function actorUserName(message) {
|
|
7570
7577
|
return getMessageActorIdentity(message)?.userName;
|
|
7571
7578
|
}
|
|
7572
7579
|
function isResourceEventNotificationMessage2(message) {
|
|
@@ -7643,7 +7650,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
7643
7650
|
const { message } = candidate;
|
|
7644
7651
|
const context = {
|
|
7645
7652
|
threadId: deps.getThreadId(thread, message),
|
|
7646
|
-
|
|
7653
|
+
actorId: message.author.userId,
|
|
7647
7654
|
channelId: deps.getChannelId(thread, message),
|
|
7648
7655
|
runId: deps.getRunId(thread, message)
|
|
7649
7656
|
};
|
|
@@ -7676,8 +7683,8 @@ function createSlackTurnRuntime(deps) {
|
|
|
7676
7683
|
"subscribed_message_reply_skipped",
|
|
7677
7684
|
logContext({
|
|
7678
7685
|
threadId: args.context.threadId,
|
|
7679
|
-
|
|
7680
|
-
|
|
7686
|
+
actorId: args.context.actorId,
|
|
7687
|
+
actorUserName: actorUserName(args.message),
|
|
7681
7688
|
channelId: args.context.channelId,
|
|
7682
7689
|
runId: args.context.runId
|
|
7683
7690
|
}),
|
|
@@ -7801,8 +7808,8 @@ function createSlackTurnRuntime(deps) {
|
|
|
7801
7808
|
pending: skippedSteeringMessages,
|
|
7802
7809
|
context: logContext({
|
|
7803
7810
|
threadId: deps.getThreadId(thread, message),
|
|
7804
|
-
|
|
7805
|
-
|
|
7811
|
+
actorId: message.author.userId,
|
|
7812
|
+
actorUserName: actorUserName(message),
|
|
7806
7813
|
channelId: deps.getChannelId(thread, message),
|
|
7807
7814
|
runId: deps.getRunId(thread, message)
|
|
7808
7815
|
})
|
|
@@ -7815,8 +7822,8 @@ function createSlackTurnRuntime(deps) {
|
|
|
7815
7822
|
const context = logContext({
|
|
7816
7823
|
threadId,
|
|
7817
7824
|
channelId,
|
|
7818
|
-
|
|
7819
|
-
|
|
7825
|
+
actorId: message.author.userId,
|
|
7826
|
+
actorUserName: actorUserName(message),
|
|
7820
7827
|
runId
|
|
7821
7828
|
});
|
|
7822
7829
|
processingReaction = await processingReactions.start(context, message);
|
|
@@ -7888,8 +7895,8 @@ function createSlackTurnRuntime(deps) {
|
|
|
7888
7895
|
}
|
|
7889
7896
|
const errorContext = logContext({
|
|
7890
7897
|
threadId: deps.getThreadId(thread, message),
|
|
7891
|
-
|
|
7892
|
-
|
|
7898
|
+
actorId: message.author.userId,
|
|
7899
|
+
actorUserName: actorUserName(message),
|
|
7893
7900
|
channelId: deps.getChannelId(thread, message),
|
|
7894
7901
|
runId: deps.getRunId(thread, message)
|
|
7895
7902
|
});
|
|
@@ -7901,8 +7908,8 @@ function createSlackTurnRuntime(deps) {
|
|
|
7901
7908
|
"mention_handler_read_only_channel",
|
|
7902
7909
|
logContext({
|
|
7903
7910
|
threadId: deps.getThreadId(thread, message),
|
|
7904
|
-
|
|
7905
|
-
|
|
7911
|
+
actorId: message.author.userId,
|
|
7912
|
+
actorUserName: actorUserName(message),
|
|
7906
7913
|
channelId: deps.getChannelId(thread, message),
|
|
7907
7914
|
runId: deps.getRunId(thread, message)
|
|
7908
7915
|
}),
|
|
@@ -7943,8 +7950,8 @@ function createSlackTurnRuntime(deps) {
|
|
|
7943
7950
|
pending: skippedSteeringMessages,
|
|
7944
7951
|
context: logContext({
|
|
7945
7952
|
threadId: deps.getThreadId(thread, message),
|
|
7946
|
-
|
|
7947
|
-
|
|
7953
|
+
actorId: message.author.userId,
|
|
7954
|
+
actorUserName: actorUserName(message),
|
|
7948
7955
|
channelId: deps.getChannelId(thread, message),
|
|
7949
7956
|
runId: deps.getRunId(thread, message)
|
|
7950
7957
|
})
|
|
@@ -7966,8 +7973,8 @@ function createSlackTurnRuntime(deps) {
|
|
|
7966
7973
|
pending: skippedSteeringMessages,
|
|
7967
7974
|
context: logContext({
|
|
7968
7975
|
threadId: deps.getThreadId(thread, message),
|
|
7969
|
-
|
|
7970
|
-
|
|
7976
|
+
actorId: message.author.userId,
|
|
7977
|
+
actorUserName: actorUserName(message),
|
|
7971
7978
|
channelId: deps.getChannelId(thread, message),
|
|
7972
7979
|
runId: deps.getRunId(thread, message)
|
|
7973
7980
|
})
|
|
@@ -7978,11 +7985,11 @@ function createSlackTurnRuntime(deps) {
|
|
|
7978
7985
|
const channelId = deps.getChannelId(thread, message);
|
|
7979
7986
|
const runId = deps.getRunId(thread, message);
|
|
7980
7987
|
const isResourceEventNotification = isResourceEventNotificationMessage2(message);
|
|
7981
|
-
const
|
|
7988
|
+
const actorId = isResourceEventNotification ? void 0 : message.author.userId;
|
|
7982
7989
|
const turnContext = logContext({
|
|
7983
7990
|
threadId,
|
|
7984
|
-
|
|
7985
|
-
|
|
7991
|
+
actorId,
|
|
7992
|
+
actorUserName: actorUserName(message),
|
|
7986
7993
|
channelId,
|
|
7987
7994
|
runId
|
|
7988
7995
|
});
|
|
@@ -8002,7 +8009,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
8002
8009
|
};
|
|
8003
8010
|
const threadContext = {
|
|
8004
8011
|
threadId,
|
|
8005
|
-
|
|
8012
|
+
actorId,
|
|
8006
8013
|
channelId,
|
|
8007
8014
|
runId
|
|
8008
8015
|
};
|
|
@@ -8148,8 +8155,8 @@ function createSlackTurnRuntime(deps) {
|
|
|
8148
8155
|
}
|
|
8149
8156
|
const errorContext = logContext({
|
|
8150
8157
|
threadId: deps.getThreadId(thread, message),
|
|
8151
|
-
|
|
8152
|
-
|
|
8158
|
+
actorId: message.author.userId,
|
|
8159
|
+
actorUserName: actorUserName(message),
|
|
8153
8160
|
channelId: deps.getChannelId(thread, message),
|
|
8154
8161
|
runId: deps.getRunId(thread, message)
|
|
8155
8162
|
});
|
|
@@ -8161,8 +8168,8 @@ function createSlackTurnRuntime(deps) {
|
|
|
8161
8168
|
"subscribed_message_handler_read_only_channel",
|
|
8162
8169
|
logContext({
|
|
8163
8170
|
threadId: deps.getThreadId(thread, message),
|
|
8164
|
-
|
|
8165
|
-
|
|
8171
|
+
actorId: message.author.userId,
|
|
8172
|
+
actorUserName: actorUserName(message),
|
|
8166
8173
|
channelId: deps.getChannelId(thread, message),
|
|
8167
8174
|
runId: deps.getRunId(thread, message)
|
|
8168
8175
|
}),
|
|
@@ -8203,8 +8210,8 @@ function createSlackTurnRuntime(deps) {
|
|
|
8203
8210
|
pending: skippedSteeringMessages,
|
|
8204
8211
|
context: logContext({
|
|
8205
8212
|
threadId: deps.getThreadId(thread, message),
|
|
8206
|
-
|
|
8207
|
-
|
|
8213
|
+
actorId: message.author.userId,
|
|
8214
|
+
actorUserName: actorUserName(message),
|
|
8208
8215
|
channelId: deps.getChannelId(thread, message),
|
|
8209
8216
|
runId: deps.getRunId(thread, message)
|
|
8210
8217
|
})
|
|
@@ -8323,12 +8330,13 @@ function userMessage(text) {
|
|
|
8323
8330
|
timestamp: Date.now()
|
|
8324
8331
|
};
|
|
8325
8332
|
}
|
|
8326
|
-
function
|
|
8327
|
-
const stripped = stripRuntimeTurnContext(messages);
|
|
8333
|
+
function selectRetainedUserMessageEntries(messages, maxTokens = RETAINED_USER_MESSAGE_TOKENS) {
|
|
8328
8334
|
const selected = [];
|
|
8329
8335
|
let remaining = maxTokens;
|
|
8330
|
-
for (
|
|
8331
|
-
|
|
8336
|
+
for (let sourceIndex = messages.length - 1; sourceIndex >= 0; sourceIndex -= 1) {
|
|
8337
|
+
const stripped = stripRuntimeTurnContext([messages[sourceIndex]]);
|
|
8338
|
+
const message = stripped[0];
|
|
8339
|
+
if (!message || message.role !== "user" || remaining <= 0) {
|
|
8332
8340
|
continue;
|
|
8333
8341
|
}
|
|
8334
8342
|
const text = sanitizeText(messageText(message));
|
|
@@ -8337,17 +8345,17 @@ function selectRetainedUserMessages(messages, maxTokens = RETAINED_USER_MESSAGE_
|
|
|
8337
8345
|
}
|
|
8338
8346
|
const tokens = estimateTextTokens(text);
|
|
8339
8347
|
if (tokens <= remaining) {
|
|
8340
|
-
selected.push(text);
|
|
8348
|
+
selected.push({ message: userMessage(text), sourceIndex });
|
|
8341
8349
|
remaining -= tokens;
|
|
8342
8350
|
continue;
|
|
8343
8351
|
}
|
|
8344
8352
|
const truncated = truncateToTokenBudget(text, remaining);
|
|
8345
8353
|
if (truncated) {
|
|
8346
|
-
selected.push(truncated);
|
|
8354
|
+
selected.push({ message: userMessage(truncated), sourceIndex });
|
|
8347
8355
|
}
|
|
8348
8356
|
break;
|
|
8349
8357
|
}
|
|
8350
|
-
return selected.reverse()
|
|
8358
|
+
return selected.reverse();
|
|
8351
8359
|
}
|
|
8352
8360
|
function renderMessageForSummary(message) {
|
|
8353
8361
|
const role = message.role;
|
|
@@ -8424,7 +8432,7 @@ async function summarizeContext(args, deps) {
|
|
|
8424
8432
|
modelId: botConfig.fastModelId,
|
|
8425
8433
|
threadId: args.metadata?.threadId ?? "",
|
|
8426
8434
|
channelId: args.metadata?.channelId ?? "",
|
|
8427
|
-
|
|
8435
|
+
actorId: args.metadata?.actorId ?? "",
|
|
8428
8436
|
runId: args.metadata?.runId ?? ""
|
|
8429
8437
|
}
|
|
8430
8438
|
});
|
|
@@ -8443,11 +8451,12 @@ function estimateHistoryTokens(messages) {
|
|
|
8443
8451
|
);
|
|
8444
8452
|
return Math.max(usageEstimate, structuralEstimate);
|
|
8445
8453
|
}
|
|
8446
|
-
function
|
|
8454
|
+
function buildReplacementProvenance(args) {
|
|
8447
8455
|
return [
|
|
8448
|
-
...
|
|
8449
|
-
|
|
8450
|
-
|
|
8456
|
+
...args.retained.map(
|
|
8457
|
+
(entry) => args.sourceProvenance[entry.sourceIndex] ?? contextProvenance
|
|
8458
|
+
),
|
|
8459
|
+
contextProvenance
|
|
8451
8460
|
];
|
|
8452
8461
|
}
|
|
8453
8462
|
function loadCompactionSource(messages) {
|
|
@@ -8484,7 +8493,7 @@ async function maybeCompactWithDeps(args, deps) {
|
|
|
8484
8493
|
"context_compaction_summary_failed",
|
|
8485
8494
|
{
|
|
8486
8495
|
slackThreadId: args.metadata?.threadId,
|
|
8487
|
-
slackUserId: args.metadata?.
|
|
8496
|
+
slackUserId: args.metadata?.actorId,
|
|
8488
8497
|
slackChannelId: args.metadata?.channelId,
|
|
8489
8498
|
runId: args.metadata?.runId,
|
|
8490
8499
|
assistantUserName: botConfig.userName,
|
|
@@ -8503,13 +8512,24 @@ async function maybeCompactWithDeps(args, deps) {
|
|
|
8503
8512
|
});
|
|
8504
8513
|
}
|
|
8505
8514
|
async function writeCompactedThreadContext(args, sourceMessages, summary, context) {
|
|
8506
|
-
const
|
|
8507
|
-
|
|
8508
|
-
summary
|
|
8515
|
+
const sourceProjection = await loadProjectionWithProvenance({
|
|
8516
|
+
conversationId: args.conversationId
|
|
8509
8517
|
});
|
|
8518
|
+
const retained = selectRetainedUserMessageEntries(
|
|
8519
|
+
trimTrailingAssistantMessages(sourceProjection.messages)
|
|
8520
|
+
);
|
|
8521
|
+
const replacement = [
|
|
8522
|
+
...retained.map((entry) => entry.message),
|
|
8523
|
+
userMessage(`${COMPACTION_SUMMARY_PREFIX}
|
|
8524
|
+
${summary}`)
|
|
8525
|
+
];
|
|
8510
8526
|
await commitMessages({
|
|
8511
8527
|
conversationId: args.conversationId,
|
|
8512
8528
|
messages: replacement,
|
|
8529
|
+
provenance: buildReplacementProvenance({
|
|
8530
|
+
retained,
|
|
8531
|
+
sourceProvenance: sourceProjection.provenance
|
|
8532
|
+
}),
|
|
8513
8533
|
ttlMs: THREAD_STATE_TTL_MS3
|
|
8514
8534
|
});
|
|
8515
8535
|
updateConversationStats(args.conversation);
|
|
@@ -8544,7 +8564,7 @@ function createSubscribedReplyPolicy(deps) {
|
|
|
8544
8564
|
"subscribed_message_classifier_failed",
|
|
8545
8565
|
{
|
|
8546
8566
|
slackThreadId: input.context.threadId,
|
|
8547
|
-
slackUserId: input.context.
|
|
8567
|
+
slackUserId: input.context.actorId,
|
|
8548
8568
|
slackChannelId: input.context.channelId,
|
|
8549
8569
|
runId: input.context.runId,
|
|
8550
8570
|
assistantUserName: botConfig.userName,
|
|
@@ -8725,7 +8745,7 @@ async function resolveUserAttachmentsWithDeps(attachments, context, deps) {
|
|
|
8725
8745
|
metadata: {
|
|
8726
8746
|
threadId: context.threadId ?? "",
|
|
8727
8747
|
channelId: context.channelId ?? "",
|
|
8728
|
-
|
|
8748
|
+
actorId: context.actorId ?? "",
|
|
8729
8749
|
runId: context.runId ?? "",
|
|
8730
8750
|
filename: attachment.name ?? ""
|
|
8731
8751
|
}
|
|
@@ -8755,7 +8775,7 @@ async function resolveUserAttachmentsWithDeps(attachments, context, deps) {
|
|
|
8755
8775
|
"attachment_skipped_size_limit",
|
|
8756
8776
|
{
|
|
8757
8777
|
slackThreadId: context.threadId,
|
|
8758
|
-
slackUserId: context.
|
|
8778
|
+
slackUserId: context.actorId,
|
|
8759
8779
|
slackChannelId: context.channelId,
|
|
8760
8780
|
runId: context.runId,
|
|
8761
8781
|
assistantUserName: botConfig.userName,
|
|
@@ -8780,7 +8800,7 @@ async function resolveUserAttachmentsWithDeps(attachments, context, deps) {
|
|
|
8780
8800
|
"image_attachment_processing_failed",
|
|
8781
8801
|
{
|
|
8782
8802
|
slackThreadId: context.threadId,
|
|
8783
|
-
slackUserId: context.
|
|
8803
|
+
slackUserId: context.actorId,
|
|
8784
8804
|
slackChannelId: context.channelId,
|
|
8785
8805
|
runId: context.runId,
|
|
8786
8806
|
assistantUserName: botConfig.userName,
|
|
@@ -8799,7 +8819,7 @@ async function resolveUserAttachmentsWithDeps(attachments, context, deps) {
|
|
|
8799
8819
|
"attachment_resolution_failed",
|
|
8800
8820
|
{
|
|
8801
8821
|
slackThreadId: context.threadId,
|
|
8802
|
-
slackUserId: context.
|
|
8822
|
+
slackUserId: context.actorId,
|
|
8803
8823
|
slackChannelId: context.channelId,
|
|
8804
8824
|
runId: context.runId,
|
|
8805
8825
|
assistantUserName: botConfig.userName,
|
|
@@ -8835,7 +8855,7 @@ async function summarizeConversationImage(args, deps) {
|
|
|
8835
8855
|
metadata: {
|
|
8836
8856
|
threadId: args.context.threadId ?? "",
|
|
8837
8857
|
channelId: args.context.channelId ?? "",
|
|
8838
|
-
|
|
8858
|
+
actorId: args.context.actorId ?? "",
|
|
8839
8859
|
runId: args.context.runId ?? "",
|
|
8840
8860
|
fileId: args.fileId
|
|
8841
8861
|
}
|
|
@@ -8849,7 +8869,7 @@ async function summarizeConversationImage(args, deps) {
|
|
|
8849
8869
|
"conversation_image_vision_failed",
|
|
8850
8870
|
{
|
|
8851
8871
|
slackThreadId: args.context.threadId,
|
|
8852
|
-
slackUserId: args.context.
|
|
8872
|
+
slackUserId: args.context.actorId,
|
|
8853
8873
|
slackChannelId: args.context.channelId,
|
|
8854
8874
|
runId: args.context.runId,
|
|
8855
8875
|
assistantUserName: botConfig.userName,
|
|
@@ -8905,7 +8925,7 @@ async function hydrateConversationVisionContextWithDeps(conversation, context, d
|
|
|
8905
8925
|
"conversation_image_replies_fetch_failed",
|
|
8906
8926
|
{
|
|
8907
8927
|
slackThreadId: context.threadId,
|
|
8908
|
-
slackUserId: context.
|
|
8928
|
+
slackUserId: context.actorId,
|
|
8909
8929
|
slackChannelId: context.channelId,
|
|
8910
8930
|
runId: context.runId,
|
|
8911
8931
|
assistantUserName: botConfig.userName,
|
|
@@ -8972,7 +8992,7 @@ async function hydrateConversationVisionContextWithDeps(conversation, context, d
|
|
|
8972
8992
|
"conversation_image_skipped_size_limit",
|
|
8973
8993
|
{
|
|
8974
8994
|
slackThreadId: context.threadId,
|
|
8975
|
-
slackUserId: context.
|
|
8995
|
+
slackUserId: context.actorId,
|
|
8976
8996
|
slackChannelId: context.channelId,
|
|
8977
8997
|
runId: context.runId,
|
|
8978
8998
|
assistantUserName: botConfig.userName,
|
|
@@ -8999,7 +9019,7 @@ async function hydrateConversationVisionContextWithDeps(conversation, context, d
|
|
|
8999
9019
|
"conversation_image_download_failed",
|
|
9000
9020
|
{
|
|
9001
9021
|
slackThreadId: context.threadId,
|
|
9002
|
-
slackUserId: context.
|
|
9022
|
+
slackUserId: context.actorId,
|
|
9003
9023
|
slackChannelId: context.channelId,
|
|
9004
9024
|
runId: context.runId,
|
|
9005
9025
|
assistantUserName: botConfig.userName,
|
|
@@ -9019,7 +9039,7 @@ async function hydrateConversationVisionContextWithDeps(conversation, context, d
|
|
|
9019
9039
|
"conversation_image_skipped_size_limit",
|
|
9020
9040
|
{
|
|
9021
9041
|
slackThreadId: context.threadId,
|
|
9022
|
-
slackUserId: context.
|
|
9042
|
+
slackUserId: context.actorId,
|
|
9023
9043
|
slackChannelId: context.channelId,
|
|
9024
9044
|
runId: context.runId,
|
|
9025
9045
|
assistantUserName: botConfig.userName,
|
|
@@ -9062,7 +9082,7 @@ async function hydrateConversationVisionContextWithDeps(conversation, context, d
|
|
|
9062
9082
|
"conversation_image_context_hydrated",
|
|
9063
9083
|
{
|
|
9064
9084
|
slackThreadId: context.threadId,
|
|
9065
|
-
slackUserId: context.
|
|
9085
|
+
slackUserId: context.actorId,
|
|
9066
9086
|
slackChannelId: context.channelId,
|
|
9067
9087
|
runId: context.runId,
|
|
9068
9088
|
assistantUserName: botConfig.userName,
|
|
@@ -9168,7 +9188,7 @@ function maybeUpdateAssistantTitle(args) {
|
|
|
9168
9188
|
"thread_title_generation_failed",
|
|
9169
9189
|
{
|
|
9170
9190
|
slackThreadId: args.threadId,
|
|
9171
|
-
slackUserId: args.
|
|
9191
|
+
slackUserId: args.actorId,
|
|
9172
9192
|
slackChannelId: args.channelId,
|
|
9173
9193
|
runId: args.runId,
|
|
9174
9194
|
assistantUserName: args.assistantUserName,
|
|
@@ -9202,7 +9222,7 @@ function maybeUpdateAssistantTitle(args) {
|
|
|
9202
9222
|
"thread_title_generation_permission_denied",
|
|
9203
9223
|
{
|
|
9204
9224
|
slackThreadId: args.threadId,
|
|
9205
|
-
slackUserId: args.
|
|
9225
|
+
slackUserId: args.actorId,
|
|
9206
9226
|
slackChannelId: args.channelId,
|
|
9207
9227
|
runId: args.runId,
|
|
9208
9228
|
assistantUserName: args.assistantUserName,
|
|
@@ -9216,7 +9236,7 @@ function maybeUpdateAssistantTitle(args) {
|
|
|
9216
9236
|
"thread_title_slack_update_failed",
|
|
9217
9237
|
{
|
|
9218
9238
|
slackThreadId: args.threadId,
|
|
9219
|
-
slackUserId: args.
|
|
9239
|
+
slackUserId: args.actorId,
|
|
9220
9240
|
slackChannelId: args.channelId,
|
|
9221
9241
|
runId: args.runId,
|
|
9222
9242
|
assistantUserName: args.assistantUserName,
|
|
@@ -9249,7 +9269,7 @@ async function maybeApplyProviderDefaultConfigRequest(args) {
|
|
|
9249
9269
|
await args.channelConfiguration.set({
|
|
9250
9270
|
key: "github.repo",
|
|
9251
9271
|
value: repo,
|
|
9252
|
-
updatedBy: args.
|
|
9272
|
+
updatedBy: args.actorId,
|
|
9253
9273
|
source: "provider-default-config"
|
|
9254
9274
|
});
|
|
9255
9275
|
return {
|
|
@@ -9269,8 +9289,8 @@ function collectCanvasUrls(artifacts) {
|
|
|
9269
9289
|
].filter((url) => typeof url === "string" && url !== "")
|
|
9270
9290
|
);
|
|
9271
9291
|
}
|
|
9272
|
-
function
|
|
9273
|
-
return
|
|
9292
|
+
function turnActor(actor) {
|
|
9293
|
+
return toStoredSlackActor(actor);
|
|
9274
9294
|
}
|
|
9275
9295
|
function parkedInputKey(message) {
|
|
9276
9296
|
if (message.role !== "user") {
|
|
@@ -9330,12 +9350,27 @@ function queuedInstructionActor(queued) {
|
|
|
9330
9350
|
...slackTs ? { slackTs } : {}
|
|
9331
9351
|
};
|
|
9332
9352
|
}
|
|
9353
|
+
function queuedInstructionProvenance(queued, teamId) {
|
|
9354
|
+
if (isResourceEventMessage(queued.message)) {
|
|
9355
|
+
return contextProvenance;
|
|
9356
|
+
}
|
|
9357
|
+
const identity = getMessageActorIdentity(queued.message);
|
|
9358
|
+
const author = identity && "platform" in identity ? identity : createActor(
|
|
9359
|
+
{ userId: parseActorUserId(queued.message.author.userId) },
|
|
9360
|
+
{
|
|
9361
|
+
platform: "slack",
|
|
9362
|
+
teamId,
|
|
9363
|
+
userId: parseActorUserId(queued.message.author.userId)
|
|
9364
|
+
}
|
|
9365
|
+
);
|
|
9366
|
+
return instructionProvenanceFor(author);
|
|
9367
|
+
}
|
|
9333
9368
|
function isResourceEventMessage(message) {
|
|
9334
9369
|
const raw = message.raw && typeof message.raw === "object" ? message.raw : void 0;
|
|
9335
9370
|
return raw?.event_type === "resource_event";
|
|
9336
9371
|
}
|
|
9337
9372
|
function resourceEventCredentialContext(message) {
|
|
9338
|
-
return isResourceEventMessage(message) ? { actor: {
|
|
9373
|
+
return isResourceEventMessage(message) ? { actor: { platform: "system", name: "resource-event" } } : void 0;
|
|
9339
9374
|
}
|
|
9340
9375
|
async function resolveChannelName(thread) {
|
|
9341
9376
|
const existingName = thread.channel.name?.trim();
|
|
@@ -9466,13 +9501,14 @@ function createReplyToThread(deps) {
|
|
|
9466
9501
|
const credentialContext = resourceEventCredentialContext(message) ?? {
|
|
9467
9502
|
actor: { type: "user", userId: message.author.userId }
|
|
9468
9503
|
};
|
|
9469
|
-
const
|
|
9504
|
+
const actor = "type" in credentialContext.actor ? await ensureSlackMessageActorIdentity(
|
|
9470
9505
|
message,
|
|
9471
9506
|
teamId,
|
|
9472
9507
|
deps.services.lookupSlackUser
|
|
9473
9508
|
) : void 0;
|
|
9474
|
-
const
|
|
9475
|
-
const
|
|
9509
|
+
const executionActor = "type" in credentialContext.actor ? actor : credentialContext.actor;
|
|
9510
|
+
const storedActor = actor ? turnActor(actor) : void 0;
|
|
9511
|
+
const slackActorId = actor?.userId;
|
|
9476
9512
|
const preparedState = options.preparedState ?? await deps.prepareTurnState({
|
|
9477
9513
|
thread,
|
|
9478
9514
|
message,
|
|
@@ -9483,7 +9519,7 @@ function createReplyToThread(deps) {
|
|
|
9483
9519
|
queuedMessages: options.queuedMessages,
|
|
9484
9520
|
context: {
|
|
9485
9521
|
threadId,
|
|
9486
|
-
|
|
9522
|
+
actorId: slackActorId,
|
|
9487
9523
|
channelId,
|
|
9488
9524
|
runId
|
|
9489
9525
|
}
|
|
@@ -9508,11 +9544,11 @@ function createReplyToThread(deps) {
|
|
|
9508
9544
|
await options.beforeFirstResponsePost?.();
|
|
9509
9545
|
};
|
|
9510
9546
|
const postAuthPauseNotice = async (providerDisplayName) => {
|
|
9511
|
-
if (!
|
|
9512
|
-
throw new Error("Slack auth pause notice requires
|
|
9547
|
+
if (!actor) {
|
|
9548
|
+
throw new Error("Slack auth pause notice requires an actor");
|
|
9513
9549
|
}
|
|
9514
9550
|
const text = buildAuthPauseResponse(
|
|
9515
|
-
|
|
9551
|
+
actor.userId,
|
|
9516
9552
|
providerDisplayName
|
|
9517
9553
|
);
|
|
9518
9554
|
const footer = buildSlackReplyFooter({ conversationId });
|
|
@@ -9555,6 +9591,7 @@ function createReplyToThread(deps) {
|
|
|
9555
9591
|
const attachments = queued.message.attachments;
|
|
9556
9592
|
return {
|
|
9557
9593
|
actor: queuedInstructionActor(queued),
|
|
9594
|
+
provenance: queuedInstructionProvenance(queued, teamId),
|
|
9558
9595
|
text: queued.userText,
|
|
9559
9596
|
timestampMs: queued.message.metadata.dateSent.getTime(),
|
|
9560
9597
|
omittedImageAttachmentCount: !isVisionEnabled() && hasPotentialImageAttachment(attachments) ? countPotentialImageAttachments(attachments) : 0,
|
|
@@ -9562,7 +9599,7 @@ function createReplyToThread(deps) {
|
|
|
9562
9599
|
attachments,
|
|
9563
9600
|
{
|
|
9564
9601
|
threadId,
|
|
9565
|
-
|
|
9602
|
+
actorId: isResourceEventMessage(queued.message) ? void 0 : queued.message.author.userId,
|
|
9566
9603
|
channelId,
|
|
9567
9604
|
runId,
|
|
9568
9605
|
conversation: preparedState.conversation,
|
|
@@ -9573,26 +9610,8 @@ function createReplyToThread(deps) {
|
|
|
9573
9610
|
})
|
|
9574
9611
|
);
|
|
9575
9612
|
};
|
|
9576
|
-
const
|
|
9577
|
-
if (!conversationId) {
|
|
9578
|
-
return true;
|
|
9579
|
-
}
|
|
9580
|
-
const parkedMessages = [
|
|
9581
|
-
...options.queuedMessages ?? [],
|
|
9582
|
-
{
|
|
9583
|
-
explicitMention: Boolean(
|
|
9584
|
-
options.explicitMention || message.isMention
|
|
9585
|
-
),
|
|
9586
|
-
message,
|
|
9587
|
-
rawText: currentText.rawText,
|
|
9588
|
-
userText: currentText.userText
|
|
9589
|
-
}
|
|
9590
|
-
].filter(
|
|
9591
|
-
// Redelivery of the parked turn's own message must not duplicate
|
|
9592
|
-
// the prompt that already started the session.
|
|
9593
|
-
(queued) => buildDeterministicTurnId(queued.message.id) !== parkedSessionId
|
|
9594
|
-
);
|
|
9595
|
-
if (parkedMessages.length === 0) {
|
|
9613
|
+
const drainParkedInputToSessionLog = async (pairs) => {
|
|
9614
|
+
if (!conversationId || pairs.length === 0) {
|
|
9596
9615
|
return true;
|
|
9597
9616
|
}
|
|
9598
9617
|
const stateAdapter = getStateAdapter();
|
|
@@ -9602,13 +9621,14 @@ function createReplyToThread(deps) {
|
|
|
9602
9621
|
return false;
|
|
9603
9622
|
}
|
|
9604
9623
|
try {
|
|
9605
|
-
const
|
|
9606
|
-
|
|
9624
|
+
const projection = await loadProjectionWithProvenance({
|
|
9625
|
+
conversationId
|
|
9626
|
+
});
|
|
9607
9627
|
const appendedKeys = new Set(
|
|
9608
|
-
projection.map(parkedInputKey).filter((key) => key !== void 0)
|
|
9628
|
+
projection.messages.map(parkedInputKey).filter((key) => key !== void 0)
|
|
9609
9629
|
);
|
|
9610
|
-
const missing =
|
|
9611
|
-
const key = parkedInputKey(
|
|
9630
|
+
const missing = pairs.filter((pair) => {
|
|
9631
|
+
const key = parkedInputKey(pair.message);
|
|
9612
9632
|
return key === void 0 || !appendedKeys.has(key);
|
|
9613
9633
|
});
|
|
9614
9634
|
if (missing.length === 0) {
|
|
@@ -9616,8 +9636,14 @@ function createReplyToThread(deps) {
|
|
|
9616
9636
|
}
|
|
9617
9637
|
await commitMessages({
|
|
9618
9638
|
conversationId,
|
|
9619
|
-
messages: [
|
|
9620
|
-
|
|
9639
|
+
messages: [
|
|
9640
|
+
...projection.messages,
|
|
9641
|
+
...missing.map((pair) => pair.message)
|
|
9642
|
+
],
|
|
9643
|
+
provenance: [
|
|
9644
|
+
...projection.provenance,
|
|
9645
|
+
...missing.map((pair) => pair.provenance)
|
|
9646
|
+
],
|
|
9621
9647
|
ttlMs: THREAD_STATE_TTL_MS4
|
|
9622
9648
|
});
|
|
9623
9649
|
return true;
|
|
@@ -9625,6 +9651,34 @@ function createReplyToThread(deps) {
|
|
|
9625
9651
|
await stateAdapter.releaseLock(lock);
|
|
9626
9652
|
}
|
|
9627
9653
|
};
|
|
9654
|
+
const appendParkedTurnInput = async (parkedSessionId) => {
|
|
9655
|
+
if (!conversationId) {
|
|
9656
|
+
return true;
|
|
9657
|
+
}
|
|
9658
|
+
const parkedMessages = [
|
|
9659
|
+
...options.queuedMessages ?? [],
|
|
9660
|
+
{
|
|
9661
|
+
explicitMention: Boolean(
|
|
9662
|
+
options.explicitMention || message.isMention
|
|
9663
|
+
),
|
|
9664
|
+
message,
|
|
9665
|
+
rawText: currentText.rawText,
|
|
9666
|
+
userText: currentText.userText
|
|
9667
|
+
}
|
|
9668
|
+
].filter(
|
|
9669
|
+
// Redelivery of the parked turn's own message must not duplicate
|
|
9670
|
+
// the prompt that already started the session.
|
|
9671
|
+
(queued) => buildDeterministicTurnId(queued.message.id) !== parkedSessionId
|
|
9672
|
+
);
|
|
9673
|
+
if (parkedMessages.length === 0) {
|
|
9674
|
+
return true;
|
|
9675
|
+
}
|
|
9676
|
+
const parkedPairs = (await resolveSteeringMessages(parkedMessages)).map((steering) => ({
|
|
9677
|
+
message: buildSteeringPiMessage(steering),
|
|
9678
|
+
provenance: steering.provenance
|
|
9679
|
+
}));
|
|
9680
|
+
return drainParkedInputToSessionLog(parkedPairs);
|
|
9681
|
+
};
|
|
9628
9682
|
if (preparedState.userMessageAlreadyReplied) {
|
|
9629
9683
|
await persistThreadState(thread, {
|
|
9630
9684
|
conversation: preparedState.conversation
|
|
@@ -9704,7 +9758,7 @@ function createReplyToThread(deps) {
|
|
|
9704
9758
|
}
|
|
9705
9759
|
const configReply = await maybeApplyProviderDefaultConfigRequest({
|
|
9706
9760
|
channelConfiguration: preparedState.channelConfiguration,
|
|
9707
|
-
|
|
9761
|
+
actorId: actor?.userId,
|
|
9708
9762
|
text: effectiveUserText
|
|
9709
9763
|
});
|
|
9710
9764
|
if (configReply) {
|
|
@@ -9753,7 +9807,7 @@ function createReplyToThread(deps) {
|
|
|
9753
9807
|
startedAtMs: turnStartedAtMs,
|
|
9754
9808
|
state: "running",
|
|
9755
9809
|
surface: "slack",
|
|
9756
|
-
|
|
9810
|
+
actor,
|
|
9757
9811
|
destination,
|
|
9758
9812
|
destinationVisibility,
|
|
9759
9813
|
source,
|
|
@@ -9770,7 +9824,7 @@ function createReplyToThread(deps) {
|
|
|
9770
9824
|
void initConversationContext(conversationId, {
|
|
9771
9825
|
channelName,
|
|
9772
9826
|
originSurface: "slack",
|
|
9773
|
-
|
|
9827
|
+
originActor: storedActor,
|
|
9774
9828
|
startedAtMs: turnStartedAtMs
|
|
9775
9829
|
}).catch((error) => {
|
|
9776
9830
|
logException(
|
|
@@ -9817,15 +9871,15 @@ function createReplyToThread(deps) {
|
|
|
9817
9871
|
conversation: preparedState.conversation
|
|
9818
9872
|
});
|
|
9819
9873
|
await options.onTurnStatePersisted?.();
|
|
9820
|
-
if (
|
|
9874
|
+
if (actor) {
|
|
9821
9875
|
setSentryUser({
|
|
9822
|
-
id:
|
|
9823
|
-
...
|
|
9824
|
-
...
|
|
9876
|
+
id: actor.userId,
|
|
9877
|
+
...actor.userName ? { username: actor.userName } : {},
|
|
9878
|
+
...actor.email ? { email: actor.email } : {}
|
|
9825
9879
|
});
|
|
9826
9880
|
}
|
|
9827
|
-
if (
|
|
9828
|
-
setTags({ slackUserName:
|
|
9881
|
+
if (actor?.userName) {
|
|
9882
|
+
setTags({ slackUserName: actor.userName });
|
|
9829
9883
|
}
|
|
9830
9884
|
const turnAttachments = collectTurnAttachments(
|
|
9831
9885
|
message,
|
|
@@ -9835,7 +9889,7 @@ function createReplyToThread(deps) {
|
|
|
9835
9889
|
turnAttachments,
|
|
9836
9890
|
{
|
|
9837
9891
|
threadId,
|
|
9838
|
-
|
|
9892
|
+
actorId: slackActorId,
|
|
9839
9893
|
channelId,
|
|
9840
9894
|
runId,
|
|
9841
9895
|
conversation: preparedState.conversation,
|
|
@@ -9891,7 +9945,7 @@ function createReplyToThread(deps) {
|
|
|
9891
9945
|
conversationId,
|
|
9892
9946
|
metadata: {
|
|
9893
9947
|
threadId,
|
|
9894
|
-
|
|
9948
|
+
actorId: slackActorId,
|
|
9895
9949
|
channelId,
|
|
9896
9950
|
runId
|
|
9897
9951
|
},
|
|
@@ -9906,16 +9960,29 @@ function createReplyToThread(deps) {
|
|
|
9906
9960
|
}
|
|
9907
9961
|
}
|
|
9908
9962
|
const hasDurablePromptHistory = Boolean(piMessages?.length);
|
|
9909
|
-
const
|
|
9963
|
+
const batchedInstructions = (await resolveSteeringMessages(
|
|
9910
9964
|
(options.queuedMessages ?? []).filter(
|
|
9911
9965
|
(queued) => queued.explicitMention
|
|
9912
9966
|
)
|
|
9913
|
-
)).map(
|
|
9914
|
-
|
|
9915
|
-
|
|
9916
|
-
|
|
9917
|
-
|
|
9918
|
-
|
|
9967
|
+
)).map((steering) => ({
|
|
9968
|
+
message: buildSteeringPiMessage(steering),
|
|
9969
|
+
provenance: steering.provenance
|
|
9970
|
+
}));
|
|
9971
|
+
if (!await drainParkedInputToSessionLog(batchedInstructions)) {
|
|
9972
|
+
shouldPersistFailureState = false;
|
|
9973
|
+
throw new TurnInputDeferredError();
|
|
9974
|
+
}
|
|
9975
|
+
if (batchedInstructions.length > 0) {
|
|
9976
|
+
const presentKeys = new Set(
|
|
9977
|
+
(piMessages ?? []).map(parkedInputKey).filter((key) => key !== void 0)
|
|
9978
|
+
);
|
|
9979
|
+
const newlyBatched = batchedInstructions.map((entry) => entry.message).filter((batchedMessage) => {
|
|
9980
|
+
const key = parkedInputKey(batchedMessage);
|
|
9981
|
+
return key === void 0 || !presentKeys.has(key);
|
|
9982
|
+
});
|
|
9983
|
+
if (newlyBatched.length > 0) {
|
|
9984
|
+
piMessages = [...piMessages ?? [], ...newlyBatched];
|
|
9985
|
+
}
|
|
9919
9986
|
}
|
|
9920
9987
|
status.start();
|
|
9921
9988
|
const assistantTitleTask = maybeUpdateAssistantTitle({
|
|
@@ -9927,7 +9994,7 @@ function createReplyToThread(deps) {
|
|
|
9927
9994
|
generateThreadTitle: deps.services.generateThreadTitle,
|
|
9928
9995
|
getSlackAdapter: deps.getSlackAdapter,
|
|
9929
9996
|
modelId: botConfig.fastModelId,
|
|
9930
|
-
|
|
9997
|
+
actorId: slackActorId,
|
|
9931
9998
|
runId,
|
|
9932
9999
|
threadId
|
|
9933
10000
|
});
|
|
@@ -9980,8 +10047,8 @@ function createReplyToThread(deps) {
|
|
|
9980
10047
|
);
|
|
9981
10048
|
});
|
|
9982
10049
|
const toolChannelId = preparedState.artifacts.assistantContextChannelId ?? channelId;
|
|
9983
|
-
const activeInstructionAuthorId =
|
|
9984
|
-
const activeInstructionAuthorName =
|
|
10050
|
+
const activeInstructionAuthorId = actor?.userId ?? parseActorUserId(message.author.userId);
|
|
10051
|
+
const activeInstructionAuthorName = actor?.fullName ?? actor?.userName;
|
|
9985
10052
|
const promptConversationContext = appendRecentThreadMessagesToContext(
|
|
9986
10053
|
preparedState.conversationContext,
|
|
9987
10054
|
options.queuedMessages ?? []
|
|
@@ -10014,7 +10081,7 @@ function createReplyToThread(deps) {
|
|
|
10014
10081
|
},
|
|
10015
10082
|
routing: {
|
|
10016
10083
|
credentialContext,
|
|
10017
|
-
|
|
10084
|
+
actor,
|
|
10018
10085
|
slackConversation,
|
|
10019
10086
|
source,
|
|
10020
10087
|
destination,
|
|
@@ -10029,7 +10096,7 @@ function createReplyToThread(deps) {
|
|
|
10029
10096
|
runId,
|
|
10030
10097
|
channelId,
|
|
10031
10098
|
channelName,
|
|
10032
|
-
|
|
10099
|
+
actorId: slackActorId
|
|
10033
10100
|
},
|
|
10034
10101
|
toolChannelId
|
|
10035
10102
|
},
|
|
@@ -10083,7 +10150,7 @@ function createReplyToThread(deps) {
|
|
|
10083
10150
|
}
|
|
10084
10151
|
});
|
|
10085
10152
|
if (outcome.status === "awaiting_auth") {
|
|
10086
|
-
if (!
|
|
10153
|
+
if (!actor) {
|
|
10087
10154
|
const text = `I could not act on this subscribed event because ${outcome.providerDisplayName} needs user authorization. Ask me in this thread to connect ${outcome.providerDisplayName} before retrying.`;
|
|
10088
10155
|
await postThreadReply(
|
|
10089
10156
|
buildSlackOutputMessage(text),
|
|
@@ -10277,13 +10344,13 @@ function createReplyToThread(deps) {
|
|
|
10277
10344
|
messages: reply.piMessages,
|
|
10278
10345
|
logContext: {
|
|
10279
10346
|
threadId,
|
|
10280
|
-
|
|
10347
|
+
actorId: slackActorId,
|
|
10281
10348
|
channelId,
|
|
10282
10349
|
runId,
|
|
10283
10350
|
assistantUserName: botConfig.userName,
|
|
10284
10351
|
modelId: reply.diagnostics.modelId
|
|
10285
10352
|
},
|
|
10286
|
-
|
|
10353
|
+
actor: executionActor,
|
|
10287
10354
|
surface: "slack"
|
|
10288
10355
|
});
|
|
10289
10356
|
} else if (conversationId) {
|
|
@@ -10296,7 +10363,7 @@ function createReplyToThread(deps) {
|
|
|
10296
10363
|
sliceId: 1,
|
|
10297
10364
|
startedAtMs: message.metadata.dateSent.getTime(),
|
|
10298
10365
|
state: "completed",
|
|
10299
|
-
|
|
10366
|
+
actor: executionActor,
|
|
10300
10367
|
destination,
|
|
10301
10368
|
destinationVisibility,
|
|
10302
10369
|
source,
|
|
@@ -10367,6 +10434,10 @@ function createReplyToThread(deps) {
|
|
|
10367
10434
|
shouldPersistFailureState = false;
|
|
10368
10435
|
throw error;
|
|
10369
10436
|
}
|
|
10437
|
+
if (error instanceof TurnInputDeferredError) {
|
|
10438
|
+
shouldPersistFailureState = false;
|
|
10439
|
+
throw error;
|
|
10440
|
+
}
|
|
10370
10441
|
if (error === agentContinueScheduleError) {
|
|
10371
10442
|
shouldPersistFailureState = true;
|
|
10372
10443
|
throw error;
|
|
@@ -10449,7 +10520,7 @@ function createReplyToThread(deps) {
|
|
|
10449
10520
|
sliceId: 1,
|
|
10450
10521
|
startedAtMs: message.metadata.dateSent.getTime(),
|
|
10451
10522
|
state: "failed",
|
|
10452
|
-
|
|
10523
|
+
actor,
|
|
10453
10524
|
destination,
|
|
10454
10525
|
destinationVisibility,
|
|
10455
10526
|
source,
|
|
@@ -10685,7 +10756,7 @@ function createPrepareTurnState(deps) {
|
|
|
10685
10756
|
await deps.hydrateConversationVisionContext(conversation, {
|
|
10686
10757
|
threadId: args.context.threadId,
|
|
10687
10758
|
channelId: args.context.channelId,
|
|
10688
|
-
|
|
10759
|
+
actorId: args.context.actorId,
|
|
10689
10760
|
runId: args.context.runId,
|
|
10690
10761
|
threadTs: getThreadTs(args.context.threadId)
|
|
10691
10762
|
});
|
|
@@ -10693,7 +10764,7 @@ function createPrepareTurnState(deps) {
|
|
|
10693
10764
|
await deps.compactConversationIfNeeded(conversation, {
|
|
10694
10765
|
threadId: args.context.threadId,
|
|
10695
10766
|
channelId: args.context.channelId,
|
|
10696
|
-
|
|
10767
|
+
actorId: args.context.actorId,
|
|
10697
10768
|
runId: args.context.runId
|
|
10698
10769
|
});
|
|
10699
10770
|
const conversationContext = buildConversationContext(conversation, {
|
|
@@ -10977,11 +11048,11 @@ async function failContinuationStartup(args) {
|
|
|
10977
11048
|
);
|
|
10978
11049
|
}
|
|
10979
11050
|
}
|
|
10980
|
-
async function
|
|
10981
|
-
const stored = args.
|
|
11051
|
+
async function resolveContinuationActor(args) {
|
|
11052
|
+
const stored = args.sessionRecordActor;
|
|
10982
11053
|
if (stored?.platform === "slack" && stored.teamId === args.teamId && stored.userId === args.userId) {
|
|
10983
|
-
return
|
|
10984
|
-
|
|
11054
|
+
return createSlackResumeActor({
|
|
11055
|
+
actor: stored,
|
|
10985
11056
|
teamId: args.teamId,
|
|
10986
11057
|
userId: args.userId
|
|
10987
11058
|
});
|
|
@@ -10989,12 +11060,12 @@ async function resolveContinuationRequester(args) {
|
|
|
10989
11060
|
const work = await getConversationWorkState2({
|
|
10990
11061
|
conversationId: args.conversationId
|
|
10991
11062
|
});
|
|
10992
|
-
const
|
|
10993
|
-
if (
|
|
10994
|
-
return
|
|
10995
|
-
email:
|
|
10996
|
-
fullName:
|
|
10997
|
-
userName:
|
|
11063
|
+
const workActor = work?.actor;
|
|
11064
|
+
if (workActor && workActor.teamId === args.teamId && workActor.slackUserId === args.userId) {
|
|
11065
|
+
return createSlackActor(args.teamId, args.userId, {
|
|
11066
|
+
email: workActor.email,
|
|
11067
|
+
fullName: workActor.fullName,
|
|
11068
|
+
userName: workActor.slackUserName
|
|
10998
11069
|
});
|
|
10999
11070
|
}
|
|
11000
11071
|
return void 0;
|
|
@@ -11062,16 +11133,16 @@ async function continueSlackAgentRun(payload, options) {
|
|
|
11062
11133
|
payload.destination,
|
|
11063
11134
|
"Slack continuation"
|
|
11064
11135
|
);
|
|
11065
|
-
const
|
|
11136
|
+
const actor = await resolveContinuationActor({
|
|
11066
11137
|
conversationId: payload.conversationId,
|
|
11067
|
-
|
|
11138
|
+
sessionRecordActor: activeSessionRecord.actor,
|
|
11068
11139
|
teamId: destination.teamId,
|
|
11069
11140
|
userId: userMessage2.author.userId
|
|
11070
11141
|
});
|
|
11071
|
-
if (!
|
|
11142
|
+
if (!actor) {
|
|
11072
11143
|
await failStrandedSessionWithFallback({
|
|
11073
11144
|
conversationId: payload.conversationId,
|
|
11074
|
-
errorMessage: "Stored Slack
|
|
11145
|
+
errorMessage: "Stored Slack actor missing for continuation",
|
|
11075
11146
|
sessionRecord: activeSessionRecord
|
|
11076
11147
|
});
|
|
11077
11148
|
return false;
|
|
@@ -11098,10 +11169,10 @@ async function continueSlackAgentRun(payload, options) {
|
|
|
11098
11169
|
credentialContext: {
|
|
11099
11170
|
actor: {
|
|
11100
11171
|
type: "user",
|
|
11101
|
-
userId:
|
|
11172
|
+
userId: actor.userId
|
|
11102
11173
|
}
|
|
11103
11174
|
},
|
|
11104
|
-
|
|
11175
|
+
actor,
|
|
11105
11176
|
destination: payload.destination,
|
|
11106
11177
|
source: activeSessionRecord.source,
|
|
11107
11178
|
correlation: {
|
|
@@ -11109,7 +11180,7 @@ async function continueSlackAgentRun(payload, options) {
|
|
|
11109
11180
|
turnId: payload.sessionId,
|
|
11110
11181
|
channelId: thread.channelId,
|
|
11111
11182
|
threadTs: thread.threadTs,
|
|
11112
|
-
|
|
11183
|
+
actorId: actor.userId
|
|
11113
11184
|
},
|
|
11114
11185
|
toolChannelId: artifacts.assistantContextChannelId ?? thread.channelId
|
|
11115
11186
|
},
|
|
@@ -11255,7 +11326,7 @@ async function recoverStrandedRunningSession(args) {
|
|
|
11255
11326
|
messages: sessionRecord.piMessages,
|
|
11256
11327
|
errorMessage: "Recovered running session after hard worker death",
|
|
11257
11328
|
logContext: { modelId: botConfig.modelId },
|
|
11258
|
-
|
|
11329
|
+
actor: sessionRecord.actor,
|
|
11259
11330
|
surface: sessionRecord.surface
|
|
11260
11331
|
});
|
|
11261
11332
|
if (!parked) {
|