@sentry/junior 0.295.0 → 0.296.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/{admin-ifgjyfpF.js → admin-z_lgDi-z.js} +2 -2
- package/dist/{agent-runner-DjMTPWEO.js → agent-runner-HoQiUKLL.js} +194 -132
- package/dist/api/schema.d.ts +1 -1
- package/dist/api/schema.js +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +294 -328
- package/dist/{app-uiTzRbvq.d.ts → app-C75Ft-A_.d.ts} +2 -2
- package/dist/app.d.ts +1 -1
- package/dist/app.js +26 -26
- package/dist/{background-compaction-queue-DUkHZjmL.js → background-compaction-queue-Cre1wFt9.js} +4 -4
- package/dist/{briefs-CbNYM-q2.js → briefs-BXECHduJ.js} +2 -2
- package/dist/{catalog-runtime-DgouZKZm.js → catalog-runtime-CpCmlD9L.js} +1 -1
- package/dist/cli/chat.js +14 -14
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{config-DvnTPCfp.js → config-CCPHvTqx.js} +18 -2
- package/dist/{connections-CWaIVl_1.js → connections-B5pWh8e2.js} +6 -6
- package/dist/{conversation-privacy-DPjv4SnA.js → conversation-privacy-CZD5soDW.js} +1 -1
- package/dist/{credential-sync-BhbaZfmO.js → credential-sync-DwLkIvXI.js} +13 -13
- package/dist/{db-CCUqQe0E.d.ts → db-B3iyr_Or.d.ts} +1 -1
- package/dist/{db-Dts2XvLu.js → db-C1M1y-bh.js} +17 -23
- package/dist/{executor-Ck73J0wP.js → executor-DUSEwXaO.js} +10 -4
- package/dist/instrumentation.js +19 -2
- package/dist/{logging-9OAq-fdg.js → logging-D0svFM8r.js} +1 -1
- package/dist/{message-CtaPzC7m.js → message-BFnIwKpx.js} +9 -9
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-C_LXY1d4.js → oauth-callback-server-BXRtD6Fk.js} +2 -2
- package/dist/{projection-BzJQncZV.js → projection-B6VS7kbo.js} +156 -49
- package/dist/{prompt-Cbq5b4SO.js → prompt-CD11tfG8.js} +3 -3
- package/dist/{registry-cbpOxO4M.js → registry-CHewwYEo.js} +1 -1
- package/dist/{resolve-t-pmRdwS.js → resolve-1owMH4qo.js} +3 -3
- package/dist/{result-DhgjR3nQ.js → result-CEqQFrEf.js} +8 -8
- package/dist/{runner-CHv9X9TH.js → runner-BtWvJslp.js} +7 -7
- package/dist/{sandbox-egress-signals-Yy3fSCbg.js → sandbox-egress-signals-ByftwJVt.js} +1 -1
- package/dist/{schema-TSEisVJR.d.ts → schema-Ct1Zf2xy.d.ts} +16 -0
- package/dist/{schema-BhneuGYv.js → schema-D2iGyYIp.js} +11 -0
- package/dist/{service-account-C4rBP8ne.js → service-account-BZEuMKdo.js} +3 -3
- package/dist/{service-account-DjPIwCMj.js → service-account-DLoeoHww.js} +3 -3
- package/dist/{session-stop-DkxI5vc3.js → session-stop-hYNTNpVf.js} +14 -14
- package/dist/{skills-BZE2DP8I.js → skills-DXgd5Inh.js} +3 -3
- package/dist/{spawn-BvULxIiu.js → spawn-YeqlNDv8.js} +5 -5
- package/dist/{state-CO9ETDzk.js → state-C3CbtD_m.js} +2 -2
- package/dist/{stop-CL-rdtQb.js → stop-Cze_pEL8.js} +288 -246
- package/dist/{store-DgD78_NK.js → store-CZ9vqR4P.js} +3 -3
- package/dist/{task-runner-CKOj6xla.js → task-runner-CMiNGsER.js} +274 -250
- package/dist/{turn-failure-response-BTSo6SMJ.js → turn-failure-response-pXhZ2wMK.js} +11 -8
- package/dist/{validation-CXeYgBzq.js → validation-Du7NdkOR.js} +1 -1
- package/dist/{version-AQa7Fr2H.js → version-EN3Wnq-R.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-Bqkb678l.js → viewer-Agxi_o5c.js} +3 -3
- package/dist/{warmup-h6u1e9n0.js → warmup-CY2ArYag.js} +251 -103
- package/dist/{work-yN_GAuXY.js → work-EA98F0ia.js} +11 -11
- package/dist/{worker-Hl7N292I.js → worker-BALVdWbv.js} +6 -6
- package/migrations/0101_drop_legacy_columns.sql +12 -0
- package/migrations/meta/0101_snapshot.json +4496 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +5 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Bt as requestConversationWork$1, Ct as deadLetterAttempt$1, Et as getConversationWorkState$1, Ft as recordAttemptFailure$1, Ht as steerWebPendingMessages$1, It as recordConversationRetry$1, Lt as releaseConversationWork$1, Mt as markConversationWorkEnqueued$1, Ot as hasRunnableConversationWork, Rt as releaseInboundMessage, Tt as getConversation$1, Ut as stopConversationWork$1, Vt as startConversationWork$1, _t as claimInboundMessage$1, bt as completeConversationStop$1, dt as ackMessages$1, ft as appendExclusiveInboundMessage, gt as checkInConversationWork$1, ht as cancelHumanFacingPendingMessages$1, jt as listActiveConversationIds$1, mt as beginConversationResume$1, pt as appendInboundMessage, vt as clearConsumedConversationWake$1, wt as drainConversationMailbox$1, xt as completeConversationWork$1, yt as clearExpiredConversationLease$1, zt as requestAnotherSlice$1 } from "./projection-
|
|
2
|
-
import { a as getConversationStore } from "./db-
|
|
3
|
-
import "./background-compaction-queue-
|
|
1
|
+
import { Bt as requestConversationWork$1, Ct as deadLetterAttempt$1, Et as getConversationWorkState$1, Ft as recordAttemptFailure$1, Ht as steerWebPendingMessages$1, It as recordConversationRetry$1, Lt as releaseConversationWork$1, Mt as markConversationWorkEnqueued$1, Ot as hasRunnableConversationWork, Rt as releaseInboundMessage, Tt as getConversation$1, Ut as stopConversationWork$1, Vt as startConversationWork$1, _t as claimInboundMessage$1, bt as completeConversationStop$1, dt as ackMessages$1, ft as appendExclusiveInboundMessage, gt as checkInConversationWork$1, ht as cancelHumanFacingPendingMessages$1, jt as listActiveConversationIds$1, mt as beginConversationResume$1, pt as appendInboundMessage, vt as clearConsumedConversationWake$1, wt as drainConversationMailbox$1, xt as completeConversationWork$1, yt as clearExpiredConversationLease$1, zt as requestAnotherSlice$1 } from "./projection-B6VS7kbo.js";
|
|
2
|
+
import { a as getConversationStore } from "./db-C1M1y-bh.js";
|
|
3
|
+
import "./background-compaction-queue-Cre1wFt9.js";
|
|
4
4
|
// src/chat/task-execution/store.ts
|
|
5
5
|
function metadataStore(options) {
|
|
6
6
|
return options.conversationStore ?? getConversationStore();
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { Bn as getPlugins, Fo as createDurableLocationConfigurationService, Ia as createPluginEmbedder, Ki as openSlackDirectMessage, La as createPluginModel, Li as escapeSlackMrkdwnText, Po as createPluginCache, Ri as formatSlackLink, Un as coreTaskRegistrations, Xa as createPluginLogger, Ya as createPluginModelCostRecorder, Yi as postSlackMessage, an as instructionTextForProjection, b as persistConversationMessages, di as createPluginState, dn as normalizeToolNameFromResult, en as getPiMessageRole, ln as isToolResultError, ni as JUNIOR_THREAD_STATE_TTL_MS, ot as getTurnRecord, pn as stripRuntimeTurnContext, si as getDashboardTaskLink, so as createPluginConversationEvents, ui as ToolInputError, un as isToolResultMessage, v as hydrateConversationMessages, w as fallbackShortTitle } from "./projection-
|
|
3
|
-
import { n as botConfig } from "./config-
|
|
4
|
-
import { E as withSpan, G as isRecord$1, K as toOptionalNumber, _ as runBestEffort, h as logWarn, q as toOptionalString } from "./logging-
|
|
2
|
+
import { Bn as getPlugins, Fo as createDurableLocationConfigurationService, Ia as createPluginEmbedder, Ki as openSlackDirectMessage, La as createPluginModel, Li as escapeSlackMrkdwnText, Po as createPluginCache, Ri as formatSlackLink, Un as coreTaskRegistrations, Xa as createPluginLogger, Ya as createPluginModelCostRecorder, Yi as postSlackMessage, an as instructionTextForProjection, b as persistConversationMessages, di as createPluginState, dn as normalizeToolNameFromResult, en as getPiMessageRole, ln as isToolResultError, ni as JUNIOR_THREAD_STATE_TTL_MS, ot as getTurnRecord, pn as stripRuntimeTurnContext, si as getDashboardTaskLink, so as createPluginConversationEvents, ui as ToolInputError, un as isToolResultMessage, v as hydrateConversationMessages, w as fallbackShortTitle } from "./projection-B6VS7kbo.js";
|
|
3
|
+
import { n as botConfig } from "./config-CCPHvTqx.js";
|
|
4
|
+
import { E as withSpan, G as isRecord$1, K as toOptionalNumber, _ as runBestEffort, h as logWarn, q as toOptionalString } from "./logging-D0svFM8r.js";
|
|
5
5
|
import { h as parseSlackMessageTs } from "./actor-6jsm_v96.js";
|
|
6
|
-
import { J as agentTurnCostUsd, Y as agentTurnTotalTokens, a as getConversationStore, o as getDb } from "./db-
|
|
7
|
-
import { A as juniorConversations, d as juniorAutomationVersions, f as juniorAutomations, u as juniorAutomationRuns } from "./executor-
|
|
6
|
+
import { J as agentTurnCostUsd, Y as agentTurnTotalTokens, a as getConversationStore, o as getDb } from "./db-C1M1y-bh.js";
|
|
7
|
+
import { A as juniorConversations, d as juniorAutomationVersions, f as juniorAutomations, u as juniorAutomationRuns } from "./executor-DUSEwXaO.js";
|
|
8
8
|
import { v as sameActorIdentity } from "./media-BepyEUNm.js";
|
|
9
|
-
import { h as credentialSubjectSchema } from "./registry-
|
|
10
|
-
import { i as readActorIdentity } from "./viewer-
|
|
11
|
-
import { a as getStateAdapter } from "./state-
|
|
12
|
-
import { c as pluginTaskParamsSchema, d as sendVercelPluginTask, s as pluginTaskId } from "./background-compaction-queue-
|
|
9
|
+
import { h as credentialSubjectSchema } from "./registry-CHewwYEo.js";
|
|
10
|
+
import { i as readActorIdentity } from "./viewer-Agxi_o5c.js";
|
|
11
|
+
import { a as getStateAdapter } from "./state-C3CbtD_m.js";
|
|
12
|
+
import { c as pluginTaskParamsSchema, d as sendVercelPluginTask, s as pluginTaskId } from "./background-compaction-queue-Cre1wFt9.js";
|
|
13
13
|
import { B as automationTaskColumns, H as automationTaskSchema, M as scheduledAutomationSchema, S as automationVersionSchema, V as automationTaskDescription, k as eventAutomationSchema, z as automationSkillNameSchema } from "./automation-yJX3C7i3.js";
|
|
14
14
|
import { createHash } from "node:crypto";
|
|
15
15
|
import * as z from "zod";
|
|
@@ -148,246 +148,6 @@ function requireEventIdentifier(catalog, input) {
|
|
|
148
148
|
const fitting = resourceTypes.filter(fits).map((candidate) => candidate.type);
|
|
149
149
|
throw new ToolInputError([`Identifier "${identifier}" does not fit resource_type "${input.resourceType}" in namespace "${input.namespace}". Expected format: "${resourceType.identifier.format}".`, ...fitting.length > 0 ? [`If the identifier is correct, use one of these resource_type values: ${fitting.map((type) => `"${type}"`).join(", ")}.`] : []].join(" "));
|
|
150
150
|
}
|
|
151
|
-
// src/chat/state/conversation.ts
|
|
152
|
-
function defaultConversationState() {
|
|
153
|
-
return {
|
|
154
|
-
schemaVersion: 1,
|
|
155
|
-
messages: [],
|
|
156
|
-
processing: {},
|
|
157
|
-
vision: { byFileId: {} }
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
function coercePendingAuthState(value) {
|
|
161
|
-
if (!isRecord$1(value)) return;
|
|
162
|
-
const kind = value.kind;
|
|
163
|
-
const provider = toOptionalString(value.provider);
|
|
164
|
-
const actorId = toOptionalString(value.actorId);
|
|
165
|
-
const authSessionId = toOptionalString(value.authSessionId);
|
|
166
|
-
const scope = toOptionalString(value.scope);
|
|
167
|
-
const sessionId = toOptionalString(value.sessionId);
|
|
168
|
-
const linkSentAtMs = toOptionalNumber(value.linkSentAtMs);
|
|
169
|
-
if (kind !== "mcp" && kind !== "plugin" || !provider || !actorId || kind === "mcp" && !authSessionId || !sessionId || typeof linkSentAtMs !== "number") return;
|
|
170
|
-
const base = {
|
|
171
|
-
provider,
|
|
172
|
-
actorId,
|
|
173
|
-
...scope ? { scope } : void 0,
|
|
174
|
-
sessionId,
|
|
175
|
-
linkSentAtMs
|
|
176
|
-
};
|
|
177
|
-
return kind === "mcp" ? {
|
|
178
|
-
...base,
|
|
179
|
-
authSessionId,
|
|
180
|
-
kind
|
|
181
|
-
} : {
|
|
182
|
-
...base,
|
|
183
|
-
kind
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
/** Safely coerce an unknown persisted value into a ThreadConversationState. */
|
|
187
|
-
function coerceThreadConversationState(value) {
|
|
188
|
-
if (!isRecord$1(value)) return defaultConversationState();
|
|
189
|
-
const root = value;
|
|
190
|
-
const rawConversation = isRecord$1(root.conversation) ? root.conversation : {};
|
|
191
|
-
const messages = [];
|
|
192
|
-
const rawProcessing = isRecord$1(rawConversation.processing) ? rawConversation.processing : {};
|
|
193
|
-
const processing = {
|
|
194
|
-
activeTurnId: toOptionalString(rawProcessing.activeTurnId),
|
|
195
|
-
lastCompletedAtMs: toOptionalNumber(rawProcessing.lastCompletedAtMs),
|
|
196
|
-
pendingAuth: coercePendingAuthState(rawProcessing.pendingAuth)
|
|
197
|
-
};
|
|
198
|
-
const rawVision = isRecord$1(rawConversation.vision) ? rawConversation.vision : {};
|
|
199
|
-
const rawVisionByFileId = isRecord$1(rawVision.byFileId) ? rawVision.byFileId : {};
|
|
200
|
-
const byFileId = {};
|
|
201
|
-
for (const [fileId, value] of Object.entries(rawVisionByFileId)) {
|
|
202
|
-
if (typeof fileId !== "string" || fileId.trim().length === 0) continue;
|
|
203
|
-
if (!isRecord$1(value)) continue;
|
|
204
|
-
const summary = toOptionalString(value.summary);
|
|
205
|
-
const analyzedAtMs = toOptionalNumber(value.analyzedAtMs);
|
|
206
|
-
if (!summary || !analyzedAtMs) continue;
|
|
207
|
-
byFileId[fileId] = {
|
|
208
|
-
summary,
|
|
209
|
-
analyzedAtMs
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
return {
|
|
213
|
-
schemaVersion: 1,
|
|
214
|
-
messages,
|
|
215
|
-
processing,
|
|
216
|
-
vision: {
|
|
217
|
-
backfillCompletedAtMs: toOptionalNumber(rawVision.backfillCompletedAtMs),
|
|
218
|
-
byFileId
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Wrap active conversation control into the thread scratch envelope.
|
|
224
|
-
*
|
|
225
|
-
* Visible history lives in SQL. Image summaries use a separate disposable
|
|
226
|
-
* cache, so thread scratch does not retain them.
|
|
227
|
-
*/
|
|
228
|
-
function buildConversationStatePatch(conversation) {
|
|
229
|
-
return { conversation: {
|
|
230
|
-
schemaVersion: 1,
|
|
231
|
-
processing: { ...conversation.processing }
|
|
232
|
-
} };
|
|
233
|
-
}
|
|
234
|
-
// src/chat/runtime/thread-state.ts
|
|
235
|
-
function threadStateKey(threadId) {
|
|
236
|
-
return `thread-state:${threadId}`;
|
|
237
|
-
}
|
|
238
|
-
function channelStateKey(channelId) {
|
|
239
|
-
return `channel-state:${channelId}`;
|
|
240
|
-
}
|
|
241
|
-
function buildThreadStatePayload(patch) {
|
|
242
|
-
const payload = {};
|
|
243
|
-
if (patch.conversation) Object.assign(payload, buildConversationStatePatch(patch.conversation));
|
|
244
|
-
if (patch.sandboxRef !== void 0) {
|
|
245
|
-
payload.app_sandbox_id = patch.sandboxRef?.id ?? "";
|
|
246
|
-
payload.app_sandbox_dependency_profile_hash = patch.sandboxRef?.profileHash ?? "";
|
|
247
|
-
payload.app_sandbox_workspace_id = patch.sandboxRef?.workspaceId ?? "";
|
|
248
|
-
}
|
|
249
|
-
return payload;
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Merge a payload into thread scratch with Junior's TTL.
|
|
253
|
-
*
|
|
254
|
-
* Chat SDK state writes hardcode a 30-day TTL. This boundary owns Junior's
|
|
255
|
-
* shorter retention policy for the same scratch keys.
|
|
256
|
-
*/
|
|
257
|
-
async function mergePersistedState(key, payload) {
|
|
258
|
-
if (Object.keys(payload).length === 0) return;
|
|
259
|
-
const stateAdapter = getStateAdapter();
|
|
260
|
-
await stateAdapter.connect();
|
|
261
|
-
const existing = await stateAdapter.get(key) ?? {};
|
|
262
|
-
await stateAdapter.set(key, {
|
|
263
|
-
...existing,
|
|
264
|
-
...payload
|
|
265
|
-
}, JUNIOR_THREAD_STATE_TTL_MS);
|
|
266
|
-
}
|
|
267
|
-
/** Extract persisted sandbox metadata from thread state payload. */
|
|
268
|
-
function getPersistedSandboxState(state) {
|
|
269
|
-
const id = toOptionalString(state.app_sandbox_id);
|
|
270
|
-
if (!id) return;
|
|
271
|
-
const profileHash = toOptionalString(state.app_sandbox_dependency_profile_hash);
|
|
272
|
-
const workspaceId = toOptionalString(state.app_sandbox_workspace_id);
|
|
273
|
-
return {
|
|
274
|
-
id,
|
|
275
|
-
...profileHash ? { profileHash } : void 0,
|
|
276
|
-
...workspaceId ? { workspaceId } : void 0
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
/** Persist only the Redis-backed runtime scratch in a thread-state patch. */
|
|
280
|
-
async function persistThreadRuntimeState(conversationId, patch) {
|
|
281
|
-
await mergePersistedState(threadStateKey(conversationId), buildThreadStatePayload(patch));
|
|
282
|
-
}
|
|
283
|
-
/** Load the persisted state payload for a thread without requiring a Chat singleton. */
|
|
284
|
-
async function getPersistedThreadState(threadId) {
|
|
285
|
-
const stateAdapter = getStateAdapter();
|
|
286
|
-
await stateAdapter.connect();
|
|
287
|
-
return await stateAdapter.get(threadStateKey(threadId)) ?? {};
|
|
288
|
-
}
|
|
289
|
-
/** Persist a thread-state patch by thread id without constructing a Chat thread. */
|
|
290
|
-
async function persistThreadStateById(threadId, patch) {
|
|
291
|
-
if (patch.conversation) await persistConversationMessages({
|
|
292
|
-
conversation: patch.conversation,
|
|
293
|
-
conversationId: threadId
|
|
294
|
-
});
|
|
295
|
-
await mergePersistedState(threadStateKey(threadId), buildThreadStatePayload(patch));
|
|
296
|
-
}
|
|
297
|
-
/** Load legacy Redis-backed channel state during the SQL cutover. */
|
|
298
|
-
async function getLegacyChannelState(channelId) {
|
|
299
|
-
const stateAdapter = getStateAdapter();
|
|
300
|
-
await stateAdapter.connect();
|
|
301
|
-
return await stateAdapter.get(channelStateKey(channelId)) ?? {};
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Resolve durable location configuration.
|
|
305
|
-
*
|
|
306
|
-
* Slack still reads the old channel-id Redis bag once during cutover.
|
|
307
|
-
*/
|
|
308
|
-
function getLocationConfigurationService(destination) {
|
|
309
|
-
if (destination.platform !== "slack") throw new Error("Location configuration requires a Slack Location");
|
|
310
|
-
return createDurableLocationConfigurationService({
|
|
311
|
-
destination,
|
|
312
|
-
db: getDb(),
|
|
313
|
-
loadLegacy: async () => await getLegacyChannelState(destination.channelId)
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
// src/chat/services/turn-session-routing.ts
|
|
317
|
-
async function loadConversationChain(conversationId, conversationStore) {
|
|
318
|
-
const chain = [];
|
|
319
|
-
const seen = /* @__PURE__ */ new Set();
|
|
320
|
-
let cursor = conversationId;
|
|
321
|
-
while (cursor && !seen.has(cursor)) {
|
|
322
|
-
seen.add(cursor);
|
|
323
|
-
const conversation = await conversationStore.get({ conversationId: cursor });
|
|
324
|
-
if (!conversation) break;
|
|
325
|
-
chain.push(conversation);
|
|
326
|
-
cursor = conversation.parentConversationId;
|
|
327
|
-
}
|
|
328
|
-
return chain;
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Normalize a stored Slack session source against the conversation destination.
|
|
332
|
-
*
|
|
333
|
-
* Does not create channel or thread values from the conversation id.
|
|
334
|
-
*/
|
|
335
|
-
function slackSourceForDestination(args) {
|
|
336
|
-
if (args.source?.kind !== "slack" || args.source.channelId !== args.destination.channelId) return;
|
|
337
|
-
const threadTs = args.source.threadTs?.trim();
|
|
338
|
-
return {
|
|
339
|
-
kind: "slack",
|
|
340
|
-
visibility: args.source.visibility ?? "public",
|
|
341
|
-
teamId: args.source.teamId?.trim() || args.destination.teamId,
|
|
342
|
-
channelId: args.source.channelId,
|
|
343
|
-
...threadTs ? { threadTs } : void 0
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Resolve the Conversation Location, Destination, and session Source.
|
|
348
|
-
*
|
|
349
|
-
* Reads parent Conversations when this Conversation has no Destination.
|
|
350
|
-
*/
|
|
351
|
-
async function resolveConversationRouting(args) {
|
|
352
|
-
const conversationStore = args.conversationStore ?? (await import("./db-Dts2XvLu.js").then((n) => n.n)).getConversationStore();
|
|
353
|
-
const chain = await loadConversationChain(args.conversationId, conversationStore);
|
|
354
|
-
let destination;
|
|
355
|
-
let source;
|
|
356
|
-
let location;
|
|
357
|
-
for (const conversation of chain) {
|
|
358
|
-
destination ??= conversation.destination;
|
|
359
|
-
source ??= conversation.sessionSource;
|
|
360
|
-
location ??= conversation.location;
|
|
361
|
-
if (destination && source) break;
|
|
362
|
-
}
|
|
363
|
-
if (!destination) return;
|
|
364
|
-
if (destination.platform === "slack") {
|
|
365
|
-
const slackSource = slackSourceForDestination({
|
|
366
|
-
destination,
|
|
367
|
-
source
|
|
368
|
-
});
|
|
369
|
-
return {
|
|
370
|
-
destination,
|
|
371
|
-
...location ? { location } : void 0,
|
|
372
|
-
...slackSource ? { source: slackSource } : void 0
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
return {
|
|
376
|
-
destination,
|
|
377
|
-
...location ? { location } : void 0,
|
|
378
|
-
...source ? { source } : void 0
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
/** Require the Conversation Destination and Source from SQL. */
|
|
382
|
-
async function resolveTurnSessionRouting(args) {
|
|
383
|
-
const routing = await resolveConversationRouting(args);
|
|
384
|
-
if (!routing?.destination || !routing.source) throw new Error(`Conversation ${args.conversationId} is missing durable routing metadata`);
|
|
385
|
-
return {
|
|
386
|
-
destination: routing.destination,
|
|
387
|
-
...routing.location ? { location: routing.location } : void 0,
|
|
388
|
-
source: routing.source
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
151
|
// src/api/conversations/aggregate.ts
|
|
392
152
|
function usageTokenValue(source, field) {
|
|
393
153
|
return sql`CASE
|
|
@@ -1411,6 +1171,30 @@ async function deleteScheduledAutomation(db, id, nowMs = Date.now()) {
|
|
|
1411
1171
|
return deleted;
|
|
1412
1172
|
});
|
|
1413
1173
|
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Block a Scheduled automation outside the settle step of a run, such as from
|
|
1176
|
+
* a Watch Event Turn of its run. An active automation becomes blocked. A
|
|
1177
|
+
* paused automation stays paused and keeps the reason, so resume returns it
|
|
1178
|
+
* to blocked. Returns true only when this call set it to blocked.
|
|
1179
|
+
*/
|
|
1180
|
+
async function blockScheduledAutomation(db, id, reason, nowMs = Date.now()) {
|
|
1181
|
+
return await withScheduledAutomationLock(db, id, async (tx) => {
|
|
1182
|
+
const current = await readScheduledAutomation(tx, id);
|
|
1183
|
+
if (current?.status !== "active" && current?.status !== "paused") return false;
|
|
1184
|
+
const blocked = current.status === "active";
|
|
1185
|
+
await writeScheduledAutomation(tx, requireStoredTask({
|
|
1186
|
+
...current,
|
|
1187
|
+
...blocked ? {
|
|
1188
|
+
nextRunAtMs: void 0,
|
|
1189
|
+
runNowAtMs: void 0,
|
|
1190
|
+
status: "blocked"
|
|
1191
|
+
} : void 0,
|
|
1192
|
+
statusReason: reason,
|
|
1193
|
+
updatedAtMs: nowMs
|
|
1194
|
+
}), current);
|
|
1195
|
+
return blocked;
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1414
1198
|
// src/chat/automations/blocked-notice.ts
|
|
1415
1199
|
function buildBlockedNoticeText(automationId, title, reason) {
|
|
1416
1200
|
const url = getDashboardTaskLink(automationId);
|
|
@@ -1771,6 +1555,246 @@ async function getPluginDispatchProjection(args) {
|
|
|
1771
1555
|
if (!record || record.plugin !== args.plugin) return;
|
|
1772
1556
|
return toDispatchProjection(record);
|
|
1773
1557
|
}
|
|
1558
|
+
// src/chat/state/conversation.ts
|
|
1559
|
+
function defaultConversationState() {
|
|
1560
|
+
return {
|
|
1561
|
+
schemaVersion: 1,
|
|
1562
|
+
messages: [],
|
|
1563
|
+
processing: {},
|
|
1564
|
+
vision: { byFileId: {} }
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
function coercePendingAuthState(value) {
|
|
1568
|
+
if (!isRecord$1(value)) return;
|
|
1569
|
+
const kind = value.kind;
|
|
1570
|
+
const provider = toOptionalString(value.provider);
|
|
1571
|
+
const actorId = toOptionalString(value.actorId);
|
|
1572
|
+
const authSessionId = toOptionalString(value.authSessionId);
|
|
1573
|
+
const scope = toOptionalString(value.scope);
|
|
1574
|
+
const sessionId = toOptionalString(value.sessionId);
|
|
1575
|
+
const linkSentAtMs = toOptionalNumber(value.linkSentAtMs);
|
|
1576
|
+
if (kind !== "mcp" && kind !== "plugin" || !provider || !actorId || kind === "mcp" && !authSessionId || !sessionId || typeof linkSentAtMs !== "number") return;
|
|
1577
|
+
const base = {
|
|
1578
|
+
provider,
|
|
1579
|
+
actorId,
|
|
1580
|
+
...scope ? { scope } : void 0,
|
|
1581
|
+
sessionId,
|
|
1582
|
+
linkSentAtMs
|
|
1583
|
+
};
|
|
1584
|
+
return kind === "mcp" ? {
|
|
1585
|
+
...base,
|
|
1586
|
+
authSessionId,
|
|
1587
|
+
kind
|
|
1588
|
+
} : {
|
|
1589
|
+
...base,
|
|
1590
|
+
kind
|
|
1591
|
+
};
|
|
1592
|
+
}
|
|
1593
|
+
/** Safely coerce an unknown persisted value into a ThreadConversationState. */
|
|
1594
|
+
function coerceThreadConversationState(value) {
|
|
1595
|
+
if (!isRecord$1(value)) return defaultConversationState();
|
|
1596
|
+
const root = value;
|
|
1597
|
+
const rawConversation = isRecord$1(root.conversation) ? root.conversation : {};
|
|
1598
|
+
const messages = [];
|
|
1599
|
+
const rawProcessing = isRecord$1(rawConversation.processing) ? rawConversation.processing : {};
|
|
1600
|
+
const processing = {
|
|
1601
|
+
activeTurnId: toOptionalString(rawProcessing.activeTurnId),
|
|
1602
|
+
lastCompletedAtMs: toOptionalNumber(rawProcessing.lastCompletedAtMs),
|
|
1603
|
+
pendingAuth: coercePendingAuthState(rawProcessing.pendingAuth)
|
|
1604
|
+
};
|
|
1605
|
+
const rawVision = isRecord$1(rawConversation.vision) ? rawConversation.vision : {};
|
|
1606
|
+
const rawVisionByFileId = isRecord$1(rawVision.byFileId) ? rawVision.byFileId : {};
|
|
1607
|
+
const byFileId = {};
|
|
1608
|
+
for (const [fileId, value] of Object.entries(rawVisionByFileId)) {
|
|
1609
|
+
if (typeof fileId !== "string" || fileId.trim().length === 0) continue;
|
|
1610
|
+
if (!isRecord$1(value)) continue;
|
|
1611
|
+
const summary = toOptionalString(value.summary);
|
|
1612
|
+
const analyzedAtMs = toOptionalNumber(value.analyzedAtMs);
|
|
1613
|
+
if (!summary || !analyzedAtMs) continue;
|
|
1614
|
+
byFileId[fileId] = {
|
|
1615
|
+
summary,
|
|
1616
|
+
analyzedAtMs
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
return {
|
|
1620
|
+
schemaVersion: 1,
|
|
1621
|
+
messages,
|
|
1622
|
+
processing,
|
|
1623
|
+
vision: {
|
|
1624
|
+
backfillCompletedAtMs: toOptionalNumber(rawVision.backfillCompletedAtMs),
|
|
1625
|
+
byFileId
|
|
1626
|
+
}
|
|
1627
|
+
};
|
|
1628
|
+
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Wrap active conversation control into the thread scratch envelope.
|
|
1631
|
+
*
|
|
1632
|
+
* Visible history lives in SQL. Image summaries use a separate disposable
|
|
1633
|
+
* cache, so thread scratch does not retain them.
|
|
1634
|
+
*/
|
|
1635
|
+
function buildConversationStatePatch(conversation) {
|
|
1636
|
+
return { conversation: {
|
|
1637
|
+
schemaVersion: 1,
|
|
1638
|
+
processing: { ...conversation.processing }
|
|
1639
|
+
} };
|
|
1640
|
+
}
|
|
1641
|
+
// src/chat/runtime/thread-state.ts
|
|
1642
|
+
function threadStateKey(threadId) {
|
|
1643
|
+
return `thread-state:${threadId}`;
|
|
1644
|
+
}
|
|
1645
|
+
function channelStateKey(channelId) {
|
|
1646
|
+
return `channel-state:${channelId}`;
|
|
1647
|
+
}
|
|
1648
|
+
function buildThreadStatePayload(patch) {
|
|
1649
|
+
const payload = {};
|
|
1650
|
+
if (patch.conversation) Object.assign(payload, buildConversationStatePatch(patch.conversation));
|
|
1651
|
+
if (patch.sandboxRef !== void 0) {
|
|
1652
|
+
payload.app_sandbox_id = patch.sandboxRef?.id ?? "";
|
|
1653
|
+
payload.app_sandbox_dependency_profile_hash = patch.sandboxRef?.profileHash ?? "";
|
|
1654
|
+
payload.app_sandbox_workspace_id = patch.sandboxRef?.workspaceId ?? "";
|
|
1655
|
+
}
|
|
1656
|
+
return payload;
|
|
1657
|
+
}
|
|
1658
|
+
/**
|
|
1659
|
+
* Merge a payload into thread scratch with Junior's TTL.
|
|
1660
|
+
*
|
|
1661
|
+
* Chat SDK state writes hardcode a 30-day TTL. This boundary owns Junior's
|
|
1662
|
+
* shorter retention policy for the same scratch keys.
|
|
1663
|
+
*/
|
|
1664
|
+
async function mergePersistedState(key, payload) {
|
|
1665
|
+
if (Object.keys(payload).length === 0) return;
|
|
1666
|
+
const stateAdapter = getStateAdapter();
|
|
1667
|
+
await stateAdapter.connect();
|
|
1668
|
+
const existing = await stateAdapter.get(key) ?? {};
|
|
1669
|
+
await stateAdapter.set(key, {
|
|
1670
|
+
...existing,
|
|
1671
|
+
...payload
|
|
1672
|
+
}, JUNIOR_THREAD_STATE_TTL_MS);
|
|
1673
|
+
}
|
|
1674
|
+
/** Extract persisted sandbox metadata from thread state payload. */
|
|
1675
|
+
function getPersistedSandboxState(state) {
|
|
1676
|
+
const id = toOptionalString(state.app_sandbox_id);
|
|
1677
|
+
if (!id) return;
|
|
1678
|
+
const profileHash = toOptionalString(state.app_sandbox_dependency_profile_hash);
|
|
1679
|
+
const workspaceId = toOptionalString(state.app_sandbox_workspace_id);
|
|
1680
|
+
return {
|
|
1681
|
+
id,
|
|
1682
|
+
...profileHash ? { profileHash } : void 0,
|
|
1683
|
+
...workspaceId ? { workspaceId } : void 0
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
/** Persist only the Redis-backed runtime scratch in a thread-state patch. */
|
|
1687
|
+
async function persistThreadRuntimeState(conversationId, patch) {
|
|
1688
|
+
await mergePersistedState(threadStateKey(conversationId), buildThreadStatePayload(patch));
|
|
1689
|
+
}
|
|
1690
|
+
/** Load the persisted state payload for a thread without requiring a Chat singleton. */
|
|
1691
|
+
async function getPersistedThreadState(threadId) {
|
|
1692
|
+
const stateAdapter = getStateAdapter();
|
|
1693
|
+
await stateAdapter.connect();
|
|
1694
|
+
return await stateAdapter.get(threadStateKey(threadId)) ?? {};
|
|
1695
|
+
}
|
|
1696
|
+
/** Persist a thread-state patch by thread id without constructing a Chat thread. */
|
|
1697
|
+
async function persistThreadStateById(threadId, patch) {
|
|
1698
|
+
if (patch.conversation) await persistConversationMessages({
|
|
1699
|
+
conversation: patch.conversation,
|
|
1700
|
+
conversationId: threadId
|
|
1701
|
+
});
|
|
1702
|
+
await mergePersistedState(threadStateKey(threadId), buildThreadStatePayload(patch));
|
|
1703
|
+
}
|
|
1704
|
+
/** Load legacy Redis-backed channel state during the SQL cutover. */
|
|
1705
|
+
async function getLegacyChannelState(channelId) {
|
|
1706
|
+
const stateAdapter = getStateAdapter();
|
|
1707
|
+
await stateAdapter.connect();
|
|
1708
|
+
return await stateAdapter.get(channelStateKey(channelId)) ?? {};
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* Resolve durable location configuration.
|
|
1712
|
+
*
|
|
1713
|
+
* Slack still reads the old channel-id Redis bag once during cutover.
|
|
1714
|
+
*/
|
|
1715
|
+
function getLocationConfigurationService(destination) {
|
|
1716
|
+
if (destination.platform !== "slack") throw new Error("Location configuration requires a Slack Location");
|
|
1717
|
+
return createDurableLocationConfigurationService({
|
|
1718
|
+
destination,
|
|
1719
|
+
db: getDb(),
|
|
1720
|
+
loadLegacy: async () => await getLegacyChannelState(destination.channelId)
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1723
|
+
// src/chat/services/turn-session-routing.ts
|
|
1724
|
+
async function loadConversationChain(conversationId, conversationStore) {
|
|
1725
|
+
const chain = [];
|
|
1726
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1727
|
+
let cursor = conversationId;
|
|
1728
|
+
while (cursor && !seen.has(cursor)) {
|
|
1729
|
+
seen.add(cursor);
|
|
1730
|
+
const conversation = await conversationStore.get({ conversationId: cursor });
|
|
1731
|
+
if (!conversation) break;
|
|
1732
|
+
chain.push(conversation);
|
|
1733
|
+
cursor = conversation.parentConversationId;
|
|
1734
|
+
}
|
|
1735
|
+
return chain;
|
|
1736
|
+
}
|
|
1737
|
+
/**
|
|
1738
|
+
* Normalize a stored Slack session source against the conversation destination.
|
|
1739
|
+
*
|
|
1740
|
+
* Does not create channel or thread values from the conversation id.
|
|
1741
|
+
*/
|
|
1742
|
+
function slackSourceForDestination(args) {
|
|
1743
|
+
if (args.source?.kind !== "slack" || args.source.channelId !== args.destination.channelId) return;
|
|
1744
|
+
const threadTs = args.source.threadTs?.trim();
|
|
1745
|
+
return {
|
|
1746
|
+
kind: "slack",
|
|
1747
|
+
visibility: args.source.visibility ?? "public",
|
|
1748
|
+
teamId: args.source.teamId?.trim() || args.destination.teamId,
|
|
1749
|
+
channelId: args.source.channelId,
|
|
1750
|
+
...threadTs ? { threadTs } : void 0
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
/**
|
|
1754
|
+
* Resolve the Conversation Location, Destination, and session Source.
|
|
1755
|
+
*
|
|
1756
|
+
* Reads parent Conversations when this Conversation has no Destination.
|
|
1757
|
+
*/
|
|
1758
|
+
async function resolveConversationRouting(args) {
|
|
1759
|
+
const conversationStore = args.conversationStore ?? (await import("./db-C1M1y-bh.js").then((n) => n.n)).getConversationStore();
|
|
1760
|
+
const chain = await loadConversationChain(args.conversationId, conversationStore);
|
|
1761
|
+
let destination;
|
|
1762
|
+
let source;
|
|
1763
|
+
let location;
|
|
1764
|
+
for (const conversation of chain) {
|
|
1765
|
+
destination ??= conversation.destination;
|
|
1766
|
+
source ??= conversation.sessionSource;
|
|
1767
|
+
location ??= conversation.location;
|
|
1768
|
+
if (destination && source) break;
|
|
1769
|
+
}
|
|
1770
|
+
if (!destination) return;
|
|
1771
|
+
if (destination.platform === "slack") {
|
|
1772
|
+
const slackSource = slackSourceForDestination({
|
|
1773
|
+
destination,
|
|
1774
|
+
source
|
|
1775
|
+
});
|
|
1776
|
+
return {
|
|
1777
|
+
destination,
|
|
1778
|
+
...location ? { location } : void 0,
|
|
1779
|
+
...slackSource ? { source: slackSource } : void 0
|
|
1780
|
+
};
|
|
1781
|
+
}
|
|
1782
|
+
return {
|
|
1783
|
+
destination,
|
|
1784
|
+
...location ? { location } : void 0,
|
|
1785
|
+
...source ? { source } : void 0
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
/** Require the Conversation Destination and Source from SQL. */
|
|
1789
|
+
async function resolveTurnSessionRouting(args) {
|
|
1790
|
+
const routing = await resolveConversationRouting(args);
|
|
1791
|
+
if (!routing?.destination || !routing.source) throw new Error(`Conversation ${args.conversationId} is missing durable routing metadata`);
|
|
1792
|
+
return {
|
|
1793
|
+
destination: routing.destination,
|
|
1794
|
+
...routing.location ? { location: routing.location } : void 0,
|
|
1795
|
+
source: routing.source
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1774
1798
|
// src/chat/plugins/task-runner.ts
|
|
1775
1799
|
/**
|
|
1776
1800
|
* Plugin background-task orchestration.
|
|
@@ -2048,4 +2072,4 @@ async function processPluginTask(message, options = {}) {
|
|
|
2048
2072
|
"app.plugin.task": message.name
|
|
2049
2073
|
});
|
|
2050
2074
|
}
|
|
2051
|
-
export {
|
|
2075
|
+
export { automationVersionOf as $, blockScheduledAutomation as A, registeredResourceTypeSchema as At, blockEventAutomation as B, listPendingDispatchMailboxAppends as C, eventGuidance as Ct, markDispatchFailed as D, registeredEventMatchSchema as Dt, markDispatchCompleted as E, hasEventCatalogEntries as Et, readScheduledAutomation as F, getEventAutomation as G, createEventAutomation as H, saveScheduledAutomation as I, saveEventAutomation as J, listDeletedEventAutomationsCreatedBy as K, saveScheduledAutomationInLock as L, deleteScheduledAutomation as M, requireValidEventTrigger as Mt, listScheduledAutomationsForTeam as N, markDispatchRunning as O, registeredEventTriggerProblems as Ot, parseScheduledAutomationRow as P, automationDefinition as Q, scheduledRunId as R, isTerminalDispatchStatus as S, eventCatalogEntry as St, markDispatchBlocked as T, eventWatchUnavailable as Tt, deleteEventAutomation as U, collectEventAutomationMatchKeys as V, findMatchingEventAutomations as W, admitEventAutomationRun as X, setEventAutomationStatus as Y, eventAutomationRunLimitReason as Z, getDispatchIdForConversation as _, conversationRangeColumns as _t, resolveTurnSessionRouting as a, requireAutomationRevision as at, getDispatchTurnId as b, automationEventCatalog as bt, getPersistedThreadState as c, readAutomationExecutionByConversationId as ct, coerceThreadConversationState as d, readAutomationExecutionSummaries as dt, listAutomationVersions as et, buildDispatchId as f, readAutomationExecutions as ft, getDispatchConversationId as g, conversationAggregateColumns as gt, createOrGetDispatch as h, recordAutomationExecution as ht, resolveConversationRouting as i, automationRevision as it, createScheduledAutomation as j, requireEventIdentifier as jt, notifyAutomationBlocked as k, registeredEventTypeSchema as kt, persistThreadRuntimeState as l, readAutomationExecutionStatusDays as lt, confirmDispatchMailboxAppend as m, readAutomationTitlesByConversationId as mt, scheduleSessionCompletedPluginTasks as n, sameDefinitionValue as nt, getLocationConfigurationService as o, emptyAutomationRunWindows as ot, claimDispatchMailboxAppend as p, readAutomationRuns as pt, parseEventAutomationRow as q, task_runner_exports as r, AutomationConflictError as rt, getPersistedSandboxState as s, existingConversationId as st, processPluginTask as t, readAutomationVersion as tt, persistThreadStateById as u, readAutomationExecutionStatusHours as ut, getDispatchInputMessageId as v, conversationUsageCostExpr as vt, markDispatchAwaitingResume as w, eventNamespaceSchema as wt, getPluginDispatchProjection as x, describeRegisteredEventTrigger as xt, getDispatchRecord as y, CORE_EVENT_NAMESPACE as yt, withScheduledAutomationLock as z };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { E as buildConversationContext, Eo as listConversationAnnotations, X as clearPendingAuth, j as markConversationMessage, v as hydrateConversationMessages } from "./projection-
|
|
2
|
-
import { H as findProviderError, U as getProviderErrorAttributes, W as getProviderErrorUserMessage, g as TURN_REASONING_LEVELS, z as ProviderError } from "./config-
|
|
3
|
-
import { G as isRecord, b as setSpanAttributes, t as buildTurnFailureResponse } from "./logging-
|
|
1
|
+
import { E as buildConversationContext, Eo as listConversationAnnotations, X as clearPendingAuth, j as markConversationMessage, v as hydrateConversationMessages } from "./projection-B6VS7kbo.js";
|
|
2
|
+
import { H as findProviderError, U as getProviderErrorAttributes, W as getProviderErrorUserMessage, g as TURN_REASONING_LEVELS, z as ProviderError } from "./config-CCPHvTqx.js";
|
|
3
|
+
import { G as isRecord, b as setSpanAttributes, t as buildTurnFailureResponse } from "./logging-D0svFM8r.js";
|
|
4
4
|
import { h as parseSlackMessageTs } from "./actor-6jsm_v96.js";
|
|
5
|
-
import { o as getDb, r as getConversationEventStore, s as getSqlExecutor } from "./db-
|
|
6
|
-
import { g as juniorAgentInvocations } from "./executor-
|
|
7
|
-
import { p as credentialContextSchema } from "./registry-
|
|
5
|
+
import { o as getDb, r as getConversationEventStore, s as getSqlExecutor } from "./db-C1M1y-bh.js";
|
|
6
|
+
import { g as juniorAgentInvocations } from "./executor-DUSEwXaO.js";
|
|
7
|
+
import { p as credentialContextSchema } from "./registry-CHewwYEo.js";
|
|
8
8
|
import { L as readMessageCardRefs, R as removedCardSchema, z as resolveMessageCards } from "./conversation-CMkSmi02.js";
|
|
9
9
|
import { C as AGENT_INVOCATION_PARENT_MAILBOX_STATUSES, S as AGENT_INVOCATION_MAILBOX_STATUSES } from "./reporting-window-B3Ze-Qnt.js";
|
|
10
|
-
import {
|
|
10
|
+
import { c as getPersistedThreadState, d as coerceThreadConversationState, u as persistThreadStateById } from "./task-runner-CMiNGsER.js";
|
|
11
11
|
import { createHash } from "node:crypto";
|
|
12
12
|
import * as z from "zod";
|
|
13
13
|
import { and, asc, desc, eq, inArray, or, sql } from "drizzle-orm";
|
|
@@ -639,6 +639,10 @@ async function loadThreadContextTrimFloor(conversationId) {
|
|
|
639
639
|
/**
|
|
640
640
|
* Build the thread context of one Turn prompt. With agent history, show only
|
|
641
641
|
* the thread Messages saved after the cursor of the previous Turn.
|
|
642
|
+
*
|
|
643
|
+
* Sets `app.thread_context.*` on the active span: `chat.reply` in a Slack
|
|
644
|
+
* Turn, `chat.turn` in a web or Event Turn. Cursor `missing` means that the
|
|
645
|
+
* previous Turn ran before cursors existed.
|
|
642
646
|
*/
|
|
643
647
|
async function buildTurnThreadContext(args) {
|
|
644
648
|
const afterSeq = args.hasHistory ? await loadThreadContextCursor({
|
|
@@ -784,7 +788,6 @@ function getAgentTurnDiagnosticsAttributes(reply) {
|
|
|
784
788
|
"app.ai.tool_error_results": reply.diagnostics.toolErrorCount,
|
|
785
789
|
"app.ai.tool_call_count": reply.diagnostics.toolCalls.length,
|
|
786
790
|
"app.ai.used_primary_text": reply.diagnostics.usedPrimaryText,
|
|
787
|
-
...reply.automation ? { "app.automation.result": reply.automation.result } : void 0,
|
|
788
791
|
...reply.diagnostics.reasoningLevel ? { "gen_ai.request.reasoning.level": reply.diagnostics.reasoningLevel } : void 0,
|
|
789
792
|
...reply.diagnostics.stopReason ? { "gen_ai.response.finish_reasons": [reply.diagnostics.stopReason] } : void 0,
|
|
790
793
|
...reply.diagnostics.errorMessage && reply.diagnostics.outcome !== "provider_error" ? { "exception.message": reply.diagnostics.errorMessage } : void 0
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
2
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-CpCmlD9L.js";
|
|
3
3
|
import { isDeepStrictEqual } from "node:util";
|
|
4
4
|
// src/chat/plugins/validation.ts
|
|
5
5
|
var validation_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.296.0";
|
|
3
3
|
// src/version.ts
|
|
4
4
|
/** Installed Junior package version, or `unknown` when package metadata is unavailable. */
|
|
5
5
|
const JUNIOR_VERSION = typeof version === "string" && version.trim() ? version : "unknown";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as JUNIOR_VERSION } from "./version-
|
|
1
|
+
export { t as JUNIOR_VERSION } from "./version-EN3Wnq-R.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as GOOGLE_IDENTITY_PROVIDER, W as normalizeIdentityEmail, h as logWarn } from "./logging-
|
|
2
|
-
import { N as findActorIdentityId, o as getDb } from "./db-
|
|
3
|
-
import { M as juniorUsers, j as juniorIdentities } from "./executor-
|
|
1
|
+
import { H as GOOGLE_IDENTITY_PROVIDER, W as normalizeIdentityEmail, h as logWarn } from "./logging-D0svFM8r.js";
|
|
2
|
+
import { N as findActorIdentityId, o as getDb } from "./db-C1M1y-bh.js";
|
|
3
|
+
import { M as juniorUsers, j as juniorIdentities } from "./executor-DUSEwXaO.js";
|
|
4
4
|
import { r as detectImageMediaType } from "./media-BepyEUNm.js";
|
|
5
5
|
import { a as withLock } from "./locks-D-0h111u.js";
|
|
6
6
|
import { createHash, randomUUID } from "node:crypto";
|