@sentry/junior 0.148.0 → 0.150.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-VAUYT6PD.js → agent-hooks-SEOGOGKX.js} +10 -10
- package/dist/api/conversations/aggregate.d.ts +2 -0
- package/dist/api/conversations/create.d.ts +1 -1
- package/dist/api/conversations/pending-messages.d.ts +15 -0
- package/dist/api/people/shared.d.ts +2 -0
- package/dist/api/schema/conversation.d.ts +78 -4
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +7 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +186 -35
- package/dist/app.js +152 -186
- package/dist/{catalog-runtime-WADOZVTB.js → catalog-runtime-HA7RIWYT.js} +5 -5
- package/dist/chat/agent/index.d.ts +5 -4
- package/dist/chat/agent/prompt.d.ts +8 -5
- package/dist/chat/agent/resume.d.ts +2 -2
- package/dist/chat/agent/tools.d.ts +4 -7
- package/dist/chat/agent/{request.d.ts → types.d.ts} +138 -129
- package/dist/chat/agent-dispatch/types.d.ts +2 -2
- package/dist/chat/agent-invocations/spawn.d.ts +2 -2
- package/dist/chat/api-turns/work.d.ts +6 -1
- package/dist/chat/app/services.d.ts +1 -1
- package/dist/chat/plugins/viewer.d.ts +4 -0
- package/dist/chat/runtime/agent-runner.d.ts +7 -5
- package/dist/chat/runtime/reply-executor.d.ts +0 -2
- package/dist/chat/runtime/slack-resume.d.ts +3 -3
- package/dist/chat/services/conversation-memory.d.ts +2 -2
- package/dist/chat/services/conversation-title.d.ts +20 -0
- package/dist/chat/slack/assistant-thread/title.d.ts +10 -27
- package/dist/chat/state/conversation.d.ts +1 -0
- package/dist/chat/task-execution/paused-turn.d.ts +2 -2
- package/dist/chat/tools/types.d.ts +1 -1
- package/dist/{chunk-QOWHHM3F.js → chunk-3GL327SC.js} +1 -1
- package/dist/{chunk-45LOR4PU.js → chunk-3JVUWLR7.js} +45 -1
- package/dist/{chunk-4GXJUYJV.js → chunk-3ZMKDHCT.js} +2 -2
- package/dist/{chunk-DUY5CDAM.js → chunk-4KAYAIBV.js} +1 -1
- package/dist/{chunk-ULAU5ZGU.js → chunk-4VH7KLGC.js} +106 -113
- package/dist/{chunk-V2FXMOEA.js → chunk-64K7GKRW.js} +2 -2
- package/dist/{chunk-2B3PT3V2.js → chunk-6PFDWAK2.js} +1 -1
- package/dist/{chunk-LNVEIJ2L.js → chunk-7D4GNUV2.js} +5 -5
- package/dist/{chunk-ZPL2RR7F.js → chunk-7GOP6VFJ.js} +40 -36
- package/dist/{chunk-HWQGBIH7.js → chunk-7NLW2NF5.js} +1 -1
- package/dist/{chunk-55F4QU2V.js → chunk-7QB2CKCW.js} +1 -1
- package/dist/{chunk-WCN4YSH7.js → chunk-DWETNV66.js} +6 -6
- package/dist/{chunk-D3WPMGEX.js → chunk-F5NMSEBL.js} +1 -1
- package/dist/{chunk-IL4EDBMV.js → chunk-FEFEIA3Z.js} +5 -5
- package/dist/{chunk-WOONT5ZP.js → chunk-H2RLIJ7G.js} +1 -1
- package/dist/{chunk-VRHTNBA6.js → chunk-ILYL6YFD.js} +3 -3
- package/dist/{chunk-VCYSOXON.js → chunk-IPGNWXA3.js} +545 -7
- package/dist/{chunk-LAZGHEYU.js → chunk-IZRSLANA.js} +1 -1
- package/dist/{chunk-EAI67NTM.js → chunk-JQXJ2E53.js} +1 -1
- package/dist/{chunk-HLPLT3NY.js → chunk-M5OZSVJI.js} +8 -4
- package/dist/{chunk-XJ42NBP5.js → chunk-MCNP7A7T.js} +8 -8
- package/dist/{chunk-OJCP3C3J.js → chunk-NCGVQXX5.js} +22 -26
- package/dist/{chunk-4AQZYNHM.js → chunk-NNOCRVQO.js} +2 -2
- package/dist/{chunk-GXYDVZKM.js → chunk-P43QM7JY.js} +5 -5
- package/dist/{chunk-EINWQFXI.js → chunk-QPIPYVGE.js} +5 -5
- package/dist/{chunk-GDFF3BQG.js → chunk-RF6J3DIO.js} +34 -36
- package/dist/{chunk-D6YX4NNN.js → chunk-SH6ZKJFZ.js} +4 -4
- package/dist/{chunk-LE5H7LMT.js → chunk-SHDREBGC.js} +1 -1
- package/dist/{chunk-VMNRXKAH.js → chunk-TZLYAO2J.js} +191 -134
- package/dist/{chunk-RRJV5UR5.js → chunk-UIMBNY6O.js} +11 -337
- package/dist/{chunk-ZCHIC2GM.js → chunk-UOFQEVR5.js} +15 -6
- package/dist/{chunk-7OEIXFC3.js → chunk-Y2VZ54CQ.js} +12 -12
- package/dist/{chunk-VY6W3T43.js → chunk-ZBOGYZ53.js} +4 -4
- package/dist/{chunk-POSZWRGL.js → chunk-ZUQT35YC.js} +1 -1
- package/dist/cli/chat.js +31 -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-XUKZRFFK.js → db-HUW75QG7.js} +7 -7
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-LPZMMGFI.js → oauth-callback-server-DP7NIZPQ.js} +24 -25
- package/dist/{runner-DGKUTMPX.js → runner-AINV7K3M.js} +47 -45
- package/dist/{skills-P7YUFSXM.js → skills-PKS37E6B.js} +6 -6
- package/dist/spawn-NJCDEPPL.js +38 -0
- package/dist/{validation-S7U5M5NR.js → validation-PDC3MVMM.js} +6 -6
- package/dist/version.js +1 -1
- package/dist/{work-GAA7TVAD.js → work-KJLJRPXS.js} +17 -17
- package/dist/{worker-JXPJH3QB.js → worker-TYQ7YVIR.js} +11 -11
- package/package.json +5 -5
- package/dist/chunk-4EA2SFK2.js +0 -137
- package/dist/spawn-DSK3ZEVD.js +0 -38
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
coerceThreadConversationState,
|
|
3
3
|
getPersistedThreadState
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-FEFEIA3Z.js";
|
|
5
5
|
import {
|
|
6
6
|
pluginTaskId,
|
|
7
7
|
pluginTaskParamsSchema,
|
|
8
8
|
sendVercelPluginTask
|
|
9
9
|
} from "./chunk-5I6ORJUY.js";
|
|
10
|
-
import {
|
|
11
|
-
calculateContextCompactionTargetTokens,
|
|
12
|
-
estimateTextTokens,
|
|
13
|
-
fallbackShortTitle,
|
|
14
|
-
generateShortTitle,
|
|
15
|
-
getConversationContextCompactionTriggerTokens
|
|
16
|
-
} from "./chunk-4EA2SFK2.js";
|
|
17
10
|
import {
|
|
18
11
|
buildDeterministicTurnId,
|
|
19
12
|
clearPendingAuth,
|
|
@@ -23,10 +16,11 @@ import {
|
|
|
23
16
|
instructionTextForProjection,
|
|
24
17
|
isToolResultError,
|
|
25
18
|
isToolResultMessage,
|
|
19
|
+
markConversationMessage,
|
|
26
20
|
markTurnCompleted,
|
|
27
21
|
normalizeToolNameFromResult,
|
|
28
22
|
stripRuntimeTurnContext
|
|
29
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-IPGNWXA3.js";
|
|
30
24
|
import {
|
|
31
25
|
JUNIOR_THREAD_STATE_TTL_MS
|
|
32
26
|
} from "./chunk-3Y47VMHV.js";
|
|
@@ -37,27 +31,25 @@ import {
|
|
|
37
31
|
createPluginModel,
|
|
38
32
|
createPluginState,
|
|
39
33
|
getPlugins
|
|
40
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-UOFQEVR5.js";
|
|
41
35
|
import {
|
|
42
36
|
getConversationStore,
|
|
43
37
|
getDb,
|
|
44
38
|
sameActorIdentity
|
|
45
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-ILYL6YFD.js";
|
|
46
40
|
import {
|
|
47
41
|
juniorConversations,
|
|
48
42
|
juniorTaskExecutions
|
|
49
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-F5NMSEBL.js";
|
|
50
44
|
import {
|
|
51
45
|
getStateAdapter
|
|
52
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-6PFDWAK2.js";
|
|
53
47
|
import {
|
|
54
48
|
ProviderError,
|
|
55
|
-
botConfig,
|
|
56
|
-
escapeXml,
|
|
57
49
|
findProviderError,
|
|
58
50
|
getProviderErrorAttributes,
|
|
59
51
|
getProviderErrorUserMessage
|
|
60
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-3ZMKDHCT.js";
|
|
61
53
|
import {
|
|
62
54
|
credentialSubjectSchema
|
|
63
55
|
} from "./chunk-RUIXF3YQ.js";
|
|
@@ -66,315 +58,8 @@ import {
|
|
|
66
58
|
} from "./chunk-F3B2YJ76.js";
|
|
67
59
|
import {
|
|
68
60
|
buildTurnFailureResponse,
|
|
69
|
-
logWarn
|
|
70
|
-
|
|
71
|
-
} from "./chunk-EAI67NTM.js";
|
|
72
|
-
|
|
73
|
-
// src/chat/services/conversation-memory.ts
|
|
74
|
-
var CONTEXT_MIN_LIVE_MESSAGES = 12;
|
|
75
|
-
var CONTEXT_COMPACTION_BATCH_SIZE = 24;
|
|
76
|
-
var CONTEXT_MAX_COMPACTIONS = 16;
|
|
77
|
-
var CONTEXT_MAX_MESSAGE_CHARS = 3200;
|
|
78
|
-
var SLACK_USER_ID_DISPLAY_PATTERN = /^[UW][A-Z0-9]{5,}$/;
|
|
79
|
-
function generateConversationId(prefix) {
|
|
80
|
-
return `${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
81
|
-
}
|
|
82
|
-
function normalizeConversationText(text) {
|
|
83
|
-
return text.replace(/\r\n?/g, "\n").trim();
|
|
84
|
-
}
|
|
85
|
-
function buildImageContextSuffix(message, conversation) {
|
|
86
|
-
const byFileId = conversation?.vision.byFileId;
|
|
87
|
-
const imageFileIds = message.meta?.imageFileIds ?? [];
|
|
88
|
-
if (!byFileId || imageFileIds.length === 0) {
|
|
89
|
-
return "";
|
|
90
|
-
}
|
|
91
|
-
const summaries = imageFileIds.map((fileId) => byFileId[fileId]?.summary?.trim()).filter((summary) => Boolean(summary));
|
|
92
|
-
if (summaries.length === 0) {
|
|
93
|
-
return "";
|
|
94
|
-
}
|
|
95
|
-
return ` [image context: ${summaries.join(" | ")}]`;
|
|
96
|
-
}
|
|
97
|
-
function renderConversationMessageLine(message, conversation) {
|
|
98
|
-
const displayName = conversationAuthorDisplayName(message);
|
|
99
|
-
const text = message.text.replace(/\s+/g, " ").slice(0, CONTEXT_MAX_MESSAGE_CHARS);
|
|
100
|
-
const markers = [];
|
|
101
|
-
if (message.meta?.replied === false) {
|
|
102
|
-
markers.push(
|
|
103
|
-
`assistant skipped: ${message.meta?.skippedReason ?? "no-reply route"}`
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
if (message.meta?.explicitMention) {
|
|
107
|
-
markers.push("explicit mention");
|
|
108
|
-
}
|
|
109
|
-
const markerSuffix = markers.length > 0 ? ` (${markers.join("; ")})` : "";
|
|
110
|
-
const imageContext = buildImageContextSuffix(message, conversation);
|
|
111
|
-
return `[${message.role}] ${displayName}: ${text}${imageContext}${markerSuffix}`;
|
|
112
|
-
}
|
|
113
|
-
function conversationAuthorDisplayName(message) {
|
|
114
|
-
const author = message.author;
|
|
115
|
-
const fullName = authorDisplayField(author?.fullName, author?.userId);
|
|
116
|
-
const userName = authorDisplayField(author?.userName, author?.userId);
|
|
117
|
-
return fullName ?? userName ?? (message.role === "assistant" ? botConfig.userName : message.role);
|
|
118
|
-
}
|
|
119
|
-
function authorDisplayField(value, userId) {
|
|
120
|
-
if (!value || value === userId || SLACK_USER_ID_DISPLAY_PATTERN.test(value)) {
|
|
121
|
-
return void 0;
|
|
122
|
-
}
|
|
123
|
-
return value;
|
|
124
|
-
}
|
|
125
|
-
function estimateConversationContextTokens(conversation) {
|
|
126
|
-
return estimateTextTokens(buildConversationContext(conversation) ?? "");
|
|
127
|
-
}
|
|
128
|
-
function upsertConversationMessage(conversation, message) {
|
|
129
|
-
const existingIndex = conversation.messages.findIndex(
|
|
130
|
-
(entry) => entry.id === message.id
|
|
131
|
-
);
|
|
132
|
-
if (existingIndex >= 0) {
|
|
133
|
-
conversation.messages[existingIndex] = {
|
|
134
|
-
...conversation.messages[existingIndex],
|
|
135
|
-
...message,
|
|
136
|
-
meta: {
|
|
137
|
-
...conversation.messages[existingIndex]?.meta,
|
|
138
|
-
...message.meta
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
return message.id;
|
|
142
|
-
}
|
|
143
|
-
conversation.messages.push(message);
|
|
144
|
-
return message.id;
|
|
145
|
-
}
|
|
146
|
-
function recordDeliveredAssistantMessage(args) {
|
|
147
|
-
const prefix = `${args.sessionId}:assistant:`;
|
|
148
|
-
const ordinal = args.conversation.messages.filter(
|
|
149
|
-
(message) => message.id.startsWith(prefix)
|
|
150
|
-
).length + 1;
|
|
151
|
-
const messageId = `${prefix}${ordinal}`;
|
|
152
|
-
markConversationMessage(args.conversation, args.userMessageId, {
|
|
153
|
-
replied: true,
|
|
154
|
-
skippedReason: void 0
|
|
155
|
-
});
|
|
156
|
-
upsertConversationMessage(args.conversation, {
|
|
157
|
-
id: messageId,
|
|
158
|
-
role: "assistant",
|
|
159
|
-
text: normalizeConversationText(args.text),
|
|
160
|
-
createdAtMs: Date.now(),
|
|
161
|
-
author: {
|
|
162
|
-
userName: botConfig.userName,
|
|
163
|
-
isBot: true
|
|
164
|
-
},
|
|
165
|
-
meta: {
|
|
166
|
-
replied: true
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
return messageId;
|
|
170
|
-
}
|
|
171
|
-
function turnHasReply(conversation, turnId) {
|
|
172
|
-
const assistantPrefix = `${turnId}:assistant:`;
|
|
173
|
-
return conversation.messages.some(
|
|
174
|
-
(message) => message.role === "assistant" && message.id.startsWith(assistantPrefix)
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
function markConversationMessage(conversation, messageId, patch) {
|
|
178
|
-
if (!messageId) return;
|
|
179
|
-
const messageIndex = conversation.messages.findIndex(
|
|
180
|
-
(entry) => entry.id === messageId
|
|
181
|
-
);
|
|
182
|
-
if (messageIndex < 0) return;
|
|
183
|
-
const current = conversation.messages[messageIndex];
|
|
184
|
-
conversation.messages[messageIndex] = {
|
|
185
|
-
...current,
|
|
186
|
-
meta: {
|
|
187
|
-
...current.meta ?? {},
|
|
188
|
-
...patch
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
function buildConversationContext(conversation, options = {}) {
|
|
193
|
-
const messages = conversation.messages.filter(
|
|
194
|
-
(entry) => entry.id !== options.excludeMessageId
|
|
195
|
-
);
|
|
196
|
-
if (messages.length === 0 && conversation.compactions.length === 0) {
|
|
197
|
-
return void 0;
|
|
198
|
-
}
|
|
199
|
-
const lines = [];
|
|
200
|
-
if (conversation.compactions.length > 0) {
|
|
201
|
-
lines.push("<thread-compactions>");
|
|
202
|
-
for (const [index, compaction] of conversation.compactions.entries()) {
|
|
203
|
-
lines.push(
|
|
204
|
-
` <compaction index="${index + 1}" covered_messages="${compaction.coveredMessageCount}" created_at="${new Date(compaction.createdAtMs).toISOString()}">`,
|
|
205
|
-
compaction.summary,
|
|
206
|
-
" </compaction>"
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
lines.push("</thread-compactions>");
|
|
210
|
-
}
|
|
211
|
-
if (messages.length > 0) {
|
|
212
|
-
if (lines.length > 0) {
|
|
213
|
-
lines.push("");
|
|
214
|
-
}
|
|
215
|
-
lines.push("<thread-transcript>");
|
|
216
|
-
for (const [index, message] of messages.entries()) {
|
|
217
|
-
const author = escapeXml(conversationAuthorDisplayName(message));
|
|
218
|
-
const actorIdAttr = message.author?.userId ? ` actor_id="${escapeXml(message.author.userId)}"` : "";
|
|
219
|
-
const ts = new Date(message.createdAtMs).toISOString();
|
|
220
|
-
const slackTsAttr = message.meta?.slackTs ? ` slack_ts="${escapeXml(message.meta.slackTs)}"` : "";
|
|
221
|
-
lines.push(
|
|
222
|
-
` <message index="${index + 1}" ts="${ts}" role="${message.role}" author="${author}"${actorIdAttr}${slackTsAttr}>`,
|
|
223
|
-
renderConversationMessageLine(message, conversation),
|
|
224
|
-
" </message>"
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
lines.push("</thread-transcript>");
|
|
228
|
-
}
|
|
229
|
-
return lines.join("\n");
|
|
230
|
-
}
|
|
231
|
-
function pruneCompactions(compactions) {
|
|
232
|
-
if (compactions.length <= CONTEXT_MAX_COMPACTIONS) {
|
|
233
|
-
return compactions;
|
|
234
|
-
}
|
|
235
|
-
const overflowCount = compactions.length - CONTEXT_MAX_COMPACTIONS + 1;
|
|
236
|
-
const merged = compactions.slice(0, overflowCount);
|
|
237
|
-
const mergedSummary = merged.map((entry) => entry.summary).join("\n").slice(0, 3500);
|
|
238
|
-
const coveredMessageCount = merged.reduce(
|
|
239
|
-
(count2, entry) => count2 + entry.coveredMessageCount,
|
|
240
|
-
0
|
|
241
|
-
);
|
|
242
|
-
const compacted = {
|
|
243
|
-
id: generateConversationId("compaction"),
|
|
244
|
-
createdAtMs: Date.now(),
|
|
245
|
-
summary: mergedSummary,
|
|
246
|
-
coveredMessageCount
|
|
247
|
-
};
|
|
248
|
-
return [compacted, ...compactions.slice(overflowCount)];
|
|
249
|
-
}
|
|
250
|
-
async function summarizeConversationChunk(messages, conversation, context, deps) {
|
|
251
|
-
const transcript = messages.map((message) => renderConversationMessageLine(message, conversation)).join("\n");
|
|
252
|
-
try {
|
|
253
|
-
const result = await deps.completeText({
|
|
254
|
-
modelId: botConfig.fastModelId,
|
|
255
|
-
temperature: 0,
|
|
256
|
-
promptName: "junior.thread_compaction",
|
|
257
|
-
messages: [
|
|
258
|
-
{
|
|
259
|
-
role: "user",
|
|
260
|
-
content: [
|
|
261
|
-
"Summarize the following older Slack thread transcript segment for future assistant turns.",
|
|
262
|
-
"Keep the summary factual and concise. Do not invent details.",
|
|
263
|
-
"",
|
|
264
|
-
"Output exactly three XML sections in this order:",
|
|
265
|
-
"<active-asks> one bullet per outstanding user ask that has not been narrowed, answered, or replaced by a later turn. Omit the section body if none. </active-asks>",
|
|
266
|
-
"<resolved-or-replaced-asks> one bullet per ask that has been replaced, narrowed, answered, or already acted on in this segment. Include the replacement/outcome inline. Omit the section body if none. </resolved-or-replaced-asks>",
|
|
267
|
-
"<facts> one bullet per durable fact useful regardless of scope: names, ids, URLs, decisions, locations, preferences, constraints that remain true. Omit the section body if none. </facts>",
|
|
268
|
-
"",
|
|
269
|
-
"Do not output any text outside the three sections.",
|
|
270
|
-
"",
|
|
271
|
-
transcript
|
|
272
|
-
].join("\n"),
|
|
273
|
-
timestamp: Date.now()
|
|
274
|
-
}
|
|
275
|
-
],
|
|
276
|
-
metadata: {
|
|
277
|
-
modelId: botConfig.fastModelId,
|
|
278
|
-
threadId: context.threadId ?? "",
|
|
279
|
-
channelId: context.channelId ?? "",
|
|
280
|
-
actorId: context.actorId ?? "",
|
|
281
|
-
runId: context.runId ?? ""
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
const summary = result.text.trim();
|
|
285
|
-
if (summary.length > 0) {
|
|
286
|
-
return summary.slice(0, 3500);
|
|
287
|
-
}
|
|
288
|
-
} catch (error) {
|
|
289
|
-
logWarn("conversation.compaction.summary.failed", {
|
|
290
|
-
"exception.message": error instanceof Error ? error.message : String(error),
|
|
291
|
-
"app.compaction_messages_covered": messages.length
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
return transcript.slice(0, 2800);
|
|
295
|
-
}
|
|
296
|
-
async function generateThreadTitleWithDeps(sourceText, deps) {
|
|
297
|
-
const title = await generateShortTitle({
|
|
298
|
-
completeText: deps.completeText,
|
|
299
|
-
kind: "conversation",
|
|
300
|
-
sourceText
|
|
301
|
-
});
|
|
302
|
-
return title ?? fallbackShortTitle(sourceText, "Conversation");
|
|
303
|
-
}
|
|
304
|
-
function getThreadTitleSourceMessage(conversation) {
|
|
305
|
-
let firstMessage;
|
|
306
|
-
for (const message of conversation.messages) {
|
|
307
|
-
if (!isHumanConversationMessage(message)) {
|
|
308
|
-
continue;
|
|
309
|
-
}
|
|
310
|
-
if (!firstMessage) {
|
|
311
|
-
firstMessage = message;
|
|
312
|
-
continue;
|
|
313
|
-
}
|
|
314
|
-
if (message.createdAtMs < firstMessage.createdAtMs) {
|
|
315
|
-
firstMessage = message;
|
|
316
|
-
continue;
|
|
317
|
-
}
|
|
318
|
-
if (message.createdAtMs === firstMessage.createdAtMs && message.id < firstMessage.id) {
|
|
319
|
-
firstMessage = message;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
return firstMessage;
|
|
323
|
-
}
|
|
324
|
-
async function compactConversationIfNeededWithDeps(conversation, context, deps) {
|
|
325
|
-
let estimatedTokens = estimateConversationContextTokens(conversation);
|
|
326
|
-
setSpanAttributes({
|
|
327
|
-
"app.context_tokens_estimated": estimatedTokens
|
|
328
|
-
});
|
|
329
|
-
const triggerTokens = getConversationContextCompactionTriggerTokens();
|
|
330
|
-
const targetTokens = calculateContextCompactionTargetTokens(triggerTokens);
|
|
331
|
-
while (estimatedTokens > triggerTokens && conversation.messages.length > CONTEXT_MIN_LIVE_MESSAGES) {
|
|
332
|
-
const compactCount = Math.min(
|
|
333
|
-
CONTEXT_COMPACTION_BATCH_SIZE,
|
|
334
|
-
conversation.messages.length - CONTEXT_MIN_LIVE_MESSAGES
|
|
335
|
-
);
|
|
336
|
-
if (compactCount <= 0) {
|
|
337
|
-
break;
|
|
338
|
-
}
|
|
339
|
-
const compactedChunk = conversation.messages.slice(0, compactCount);
|
|
340
|
-
const summary = await summarizeConversationChunk(
|
|
341
|
-
compactedChunk,
|
|
342
|
-
conversation,
|
|
343
|
-
context,
|
|
344
|
-
deps
|
|
345
|
-
);
|
|
346
|
-
conversation.compactions.push({
|
|
347
|
-
id: generateConversationId("compaction"),
|
|
348
|
-
createdAtMs: Date.now(),
|
|
349
|
-
summary,
|
|
350
|
-
coveredMessageCount: compactedChunk.length
|
|
351
|
-
});
|
|
352
|
-
conversation.compactions = pruneCompactions(conversation.compactions);
|
|
353
|
-
conversation.messages = conversation.messages.slice(compactCount);
|
|
354
|
-
estimatedTokens = estimateConversationContextTokens(conversation);
|
|
355
|
-
setSpanAttributes({
|
|
356
|
-
"app.compaction_messages_covered": compactCount,
|
|
357
|
-
"app.compaction.trigger_tokens": triggerTokens,
|
|
358
|
-
"app.compaction.target_tokens": targetTokens,
|
|
359
|
-
"app.context_tokens_estimated": estimatedTokens
|
|
360
|
-
});
|
|
361
|
-
if (estimatedTokens <= targetTokens) {
|
|
362
|
-
break;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
function createConversationMemoryService(deps) {
|
|
367
|
-
return {
|
|
368
|
-
compactConversationIfNeeded: async (conversation, context) => await compactConversationIfNeededWithDeps(conversation, context, deps),
|
|
369
|
-
generateThreadTitle: async (sourceText) => await generateThreadTitleWithDeps(sourceText, deps)
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
function isHumanConversationMessage(message) {
|
|
373
|
-
return message.role === "user" && message.author?.isBot !== true;
|
|
374
|
-
}
|
|
375
|
-
function getConversationMessageSlackTs(message) {
|
|
376
|
-
return parseSlackMessageTs(message.meta?.slackTs);
|
|
377
|
-
}
|
|
61
|
+
logWarn
|
|
62
|
+
} from "./chunk-JQXJ2E53.js";
|
|
378
63
|
|
|
379
64
|
// src/chat/runtime/delivered-turn-state.ts
|
|
380
65
|
function buildDeliveredTurnStatePatch(args) {
|
|
@@ -400,7 +85,7 @@ import { pluginRunContextSchema } from "@sentry/junior-plugin-api";
|
|
|
400
85
|
|
|
401
86
|
// src/chat/services/turn-session-routing.ts
|
|
402
87
|
async function resolveTurnSessionRouting(args) {
|
|
403
|
-
const conversationStore = args.conversationStore ?? (await import("./db-
|
|
88
|
+
const conversationStore = args.conversationStore ?? (await import("./db-HUW75QG7.js")).getConversationStore();
|
|
404
89
|
const conversation = await conversationStore.get({
|
|
405
90
|
conversationId: args.conversationId
|
|
406
91
|
});
|
|
@@ -1522,17 +1207,6 @@ export {
|
|
|
1522
1207
|
listPendingDispatchMailboxAppends,
|
|
1523
1208
|
claimDispatchMailboxAppend,
|
|
1524
1209
|
getPluginDispatchProjection,
|
|
1525
|
-
normalizeConversationText,
|
|
1526
|
-
estimateConversationContextTokens,
|
|
1527
|
-
upsertConversationMessage,
|
|
1528
|
-
recordDeliveredAssistantMessage,
|
|
1529
|
-
turnHasReply,
|
|
1530
|
-
markConversationMessage,
|
|
1531
|
-
buildConversationContext,
|
|
1532
|
-
getThreadTitleSourceMessage,
|
|
1533
|
-
createConversationMemoryService,
|
|
1534
|
-
isHumanConversationMessage,
|
|
1535
|
-
getConversationMessageSlackTs,
|
|
1536
1210
|
buildDeliveredTurnStatePatch,
|
|
1537
1211
|
getTurnUserMessage,
|
|
1538
1212
|
getTurnUserMessageId,
|
|
@@ -4,30 +4,30 @@ import {
|
|
|
4
4
|
isConversationScopedChannel,
|
|
5
5
|
isDmChannel,
|
|
6
6
|
normalizeSlackConversationId
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-64K7GKRW.js";
|
|
8
8
|
import {
|
|
9
9
|
getConversationEventStore,
|
|
10
10
|
getDb
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ILYL6YFD.js";
|
|
12
12
|
import {
|
|
13
13
|
juniorConversationAnnotations,
|
|
14
14
|
juniorConversationEvents,
|
|
15
15
|
juniorIdentities,
|
|
16
16
|
juniorUsers
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-F5NMSEBL.js";
|
|
18
18
|
import {
|
|
19
19
|
SANDBOX_WORKSPACE_ROOT
|
|
20
20
|
} from "./chunk-EM225ITJ.js";
|
|
21
21
|
import {
|
|
22
22
|
getStateAdapter
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-6PFDWAK2.js";
|
|
24
24
|
import {
|
|
25
25
|
botConfig,
|
|
26
26
|
completeObject,
|
|
27
27
|
embedTexts,
|
|
28
28
|
getSlackBotToken,
|
|
29
29
|
standardModelId
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-3ZMKDHCT.js";
|
|
31
31
|
import {
|
|
32
32
|
isActorUserId,
|
|
33
33
|
parseActorUserId
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
logInfo,
|
|
43
43
|
logWarn,
|
|
44
44
|
normalizeIdentityEmail
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-JQXJ2E53.js";
|
|
46
46
|
|
|
47
47
|
// src/chat/plugins/agent-hooks.ts
|
|
48
48
|
import {
|
|
@@ -543,6 +543,14 @@ async function resolveViewerUserFromSql(db, email) {
|
|
|
543
543
|
async function resolveViewerUser(email) {
|
|
544
544
|
return await resolveViewerUserFromSql(getDb(), email);
|
|
545
545
|
}
|
|
546
|
+
async function updateViewerDisplayNameFromSql(db, userId, displayName) {
|
|
547
|
+
const rows = await db.update(juniorUsers).set({ displayName, updatedAt: /* @__PURE__ */ new Date() }).where(eq3(juniorUsers.id, userId)).returning();
|
|
548
|
+
const userRow = rows[0];
|
|
549
|
+
return userRow ? await readUserById(db, userRow) : void 0;
|
|
550
|
+
}
|
|
551
|
+
async function updateViewerDisplayName(userId, displayName) {
|
|
552
|
+
return await updateViewerDisplayNameFromSql(getDb(), userId, displayName);
|
|
553
|
+
}
|
|
546
554
|
async function readActorIdentityFromSql(db, actor) {
|
|
547
555
|
if (actor.platform === "system") return void 0;
|
|
548
556
|
const providerTenantId = actor.platform === "slack" ? actor.teamId : "";
|
|
@@ -1833,6 +1841,7 @@ export {
|
|
|
1833
1841
|
createResourceEventTeamIdResolver,
|
|
1834
1842
|
getSlackToolContext,
|
|
1835
1843
|
resolveViewerUser,
|
|
1844
|
+
updateViewerDisplayName,
|
|
1836
1845
|
readActorIdentity,
|
|
1837
1846
|
bindSlackDirectCredentialSubject,
|
|
1838
1847
|
verifySlackDirectCredentialSubject,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAndEnqueueAgentInvocation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NCGVQXX5.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
actorFromRun,
|
|
6
6
|
toolInvocationDestination
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-RF6J3DIO.js";
|
|
8
8
|
|
|
9
9
|
// src/chat/agent-invocations/spawn.ts
|
|
10
|
-
function bindSpawnAgent(
|
|
11
|
-
const actor =
|
|
10
|
+
function bindSpawnAgent(run, options) {
|
|
11
|
+
const actor = actorFromRun(run);
|
|
12
12
|
if (!actor) {
|
|
13
13
|
return void 0;
|
|
14
14
|
}
|
|
@@ -19,16 +19,16 @@ function bindSpawnAgent(request, options) {
|
|
|
19
19
|
{
|
|
20
20
|
actor,
|
|
21
21
|
...input.name ? { agentName: input.name } : {},
|
|
22
|
-
...
|
|
23
|
-
destination: toolInvocationDestination(
|
|
24
|
-
...
|
|
25
|
-
destinationVisibility:
|
|
22
|
+
...run.credentialContext ? { credentialContext: run.credentialContext } : {},
|
|
23
|
+
destination: toolInvocationDestination(run),
|
|
24
|
+
...run.destinationVisibility ? {
|
|
25
|
+
destinationVisibility: run.destinationVisibility
|
|
26
26
|
} : {},
|
|
27
|
-
idempotencyKey: `${
|
|
27
|
+
idempotencyKey: `${run.turnId}:${call.toolCallId}`,
|
|
28
28
|
input: input.task,
|
|
29
|
-
parentConversationId:
|
|
29
|
+
parentConversationId: run.conversationId,
|
|
30
30
|
...input.reasoningLevel ? { reasoningLevel: input.reasoningLevel } : {},
|
|
31
|
-
source:
|
|
31
|
+
source: run.source
|
|
32
32
|
},
|
|
33
33
|
{ ...options, queue }
|
|
34
34
|
);
|
|
@@ -4,18 +4,18 @@ import {
|
|
|
4
4
|
} from "./chunk-EM225ITJ.js";
|
|
5
5
|
import {
|
|
6
6
|
getStateAdapter
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-6PFDWAK2.js";
|
|
8
8
|
import {
|
|
9
9
|
toOptionalTrimmed
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-3ZMKDHCT.js";
|
|
11
11
|
import {
|
|
12
12
|
pluginCatalogRuntime
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-7NLW2NF5.js";
|
|
14
14
|
import {
|
|
15
15
|
setSpanAttributes,
|
|
16
16
|
setSpanStatus,
|
|
17
17
|
withSpan
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-JQXJ2E53.js";
|
|
19
19
|
|
|
20
20
|
// src/chat/sandbox/resources.ts
|
|
21
21
|
var configuredResources;
|
package/dist/cli/chat.js
CHANGED
|
@@ -1,46 +1,45 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAgentRunner,
|
|
3
3
|
executeAgentRun
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-TZLYAO2J.js";
|
|
5
|
+
import "../chunk-QPIPYVGE.js";
|
|
6
6
|
import "../chunk-DIB4GX3G.js";
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-MCNP7A7T.js";
|
|
8
|
+
import "../chunk-RF6J3DIO.js";
|
|
9
|
+
import "../chunk-DWETNV66.js";
|
|
10
10
|
import "../chunk-HUO3UTAQ.js";
|
|
11
11
|
import "../chunk-5IDFPCON.js";
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
16
|
-
import "../chunk-VCYSOXON.js";
|
|
12
|
+
import "../chunk-ZBOGYZ53.js";
|
|
13
|
+
import "../chunk-P43QM7JY.js";
|
|
14
|
+
import "../chunk-H2RLIJ7G.js";
|
|
15
|
+
import "../chunk-IPGNWXA3.js";
|
|
17
16
|
import "../chunk-3Y47VMHV.js";
|
|
18
17
|
import "../chunk-PDO5BLNM.js";
|
|
19
18
|
import "../chunk-UIE3R5XU.js";
|
|
20
19
|
import {
|
|
21
20
|
loadAppPluginSet
|
|
22
21
|
} from "../chunk-Y2CM7HXH.js";
|
|
23
|
-
import "../chunk-
|
|
24
|
-
import "../chunk-
|
|
25
|
-
import "../chunk-
|
|
26
|
-
import "../chunk-
|
|
22
|
+
import "../chunk-UOFQEVR5.js";
|
|
23
|
+
import "../chunk-64K7GKRW.js";
|
|
24
|
+
import "../chunk-ILYL6YFD.js";
|
|
25
|
+
import "../chunk-F5NMSEBL.js";
|
|
27
26
|
import "../chunk-EM225ITJ.js";
|
|
28
|
-
import "../chunk-
|
|
29
|
-
import "../chunk-
|
|
27
|
+
import "../chunk-6PFDWAK2.js";
|
|
28
|
+
import "../chunk-3ZMKDHCT.js";
|
|
30
29
|
import "../chunk-VFUK3X5B.js";
|
|
31
|
-
import "../chunk-
|
|
32
|
-
import "../chunk-
|
|
33
|
-
import "../chunk-
|
|
34
|
-
import "../chunk-
|
|
30
|
+
import "../chunk-SHDREBGC.js";
|
|
31
|
+
import "../chunk-NNOCRVQO.js";
|
|
32
|
+
import "../chunk-7NLW2NF5.js";
|
|
33
|
+
import "../chunk-ZUQT35YC.js";
|
|
35
34
|
import "../chunk-RUIXF3YQ.js";
|
|
36
35
|
import "../chunk-HZF5P5UN.js";
|
|
37
36
|
import "../chunk-F3B2YJ76.js";
|
|
38
|
-
import "../chunk-
|
|
37
|
+
import "../chunk-JQXJ2E53.js";
|
|
39
38
|
import "../chunk-6GWA276C.js";
|
|
40
39
|
import "../chunk-OOUNJNMR.js";
|
|
41
40
|
import "../chunk-H4HBKISO.js";
|
|
42
|
-
import "../chunk-
|
|
43
|
-
import "../chunk-
|
|
41
|
+
import "../chunk-IZRSLANA.js";
|
|
42
|
+
import "../chunk-7QB2CKCW.js";
|
|
44
43
|
import "../chunk-MLKGABMK.js";
|
|
45
44
|
|
|
46
45
|
// src/cli/chat.ts
|
|
@@ -163,10 +162,10 @@ async function configureLocalChatPlugins(pluginSet) {
|
|
|
163
162
|
databaseModule
|
|
164
163
|
] = await Promise.all([
|
|
165
164
|
import("../plugins-HW4VWW6G.js"),
|
|
166
|
-
import("../agent-hooks-
|
|
167
|
-
import("../catalog-runtime-
|
|
168
|
-
import("../validation-
|
|
169
|
-
import("../db-
|
|
165
|
+
import("../agent-hooks-SEOGOGKX.js"),
|
|
166
|
+
import("../catalog-runtime-HA7RIWYT.js"),
|
|
167
|
+
import("../validation-PDC3MVMM.js"),
|
|
168
|
+
import("../db-HUW75QG7.js")
|
|
170
169
|
]);
|
|
171
170
|
const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
|
|
172
171
|
const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
|
|
@@ -232,14 +231,14 @@ async function prepareLocalChatRun(io, pluginSet) {
|
|
|
232
231
|
await configureLocalChatPlugins(pluginSet);
|
|
233
232
|
const { setExperimentalFeatures } = await import("../experimental-HH6OM6UH.js");
|
|
234
233
|
setExperimentalFeatures({ subagents: true });
|
|
235
|
-
const { runLocalAgentTurn } = await import("../runner-
|
|
236
|
-
const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-
|
|
234
|
+
const { runLocalAgentTurn } = await import("../runner-AINV7K3M.js");
|
|
235
|
+
const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-DP7NIZPQ.js");
|
|
237
236
|
const { createLocalOAuthState } = await import("../oauth-relay-3ZU72UGL.js");
|
|
238
237
|
const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-EKPAVWQL.js");
|
|
239
|
-
const { bindSpawnAgent } = await import("../spawn-
|
|
240
|
-
const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-
|
|
238
|
+
const { bindSpawnAgent } = await import("../spawn-NJCDEPPL.js");
|
|
239
|
+
const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-KJLJRPXS.js");
|
|
241
240
|
const { createLocalConversationWork } = await import("../conversation-work-KATFHLG3.js");
|
|
242
|
-
const { processConversationWork } = await import("../worker-
|
|
241
|
+
const { processConversationWork } = await import("../worker-TYQ7YVIR.js");
|
|
243
242
|
let agentRunner;
|
|
244
243
|
const localConversationWork = createLocalConversationWork(async (message) => {
|
|
245
244
|
if (!agentRunner) {
|