@sentry/junior 0.294.0 → 0.295.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.
Files changed (77) hide show
  1. package/dist/{admin-vt8aSiCD.js → admin-ifgjyfpF.js} +2 -2
  2. package/dist/{agent-runner-DJu7w6mI.js → agent-runner-DjMTPWEO.js} +147 -90
  3. package/dist/api/schema.d.ts +2 -2
  4. package/dist/api/schema.js +5 -5
  5. package/dist/api.d.ts +1 -1
  6. package/dist/api.js +52 -28
  7. package/dist/{app--a5RLOrr.d.ts → app-uiTzRbvq.d.ts} +3 -3
  8. package/dist/app.d.ts +2 -2
  9. package/dist/app.js +33 -34
  10. package/dist/{automation-BM-OBsKW.js → automation-yJX3C7i3.js} +3 -3
  11. package/dist/{background-compaction-queue-D2j-0XkH.js → background-compaction-queue-DUkHZjmL.js} +7 -9
  12. package/dist/{briefs-JOAoCb6d.js → briefs-CbNYM-q2.js} +3 -3
  13. package/dist/{catalog-runtime-CLMA9AXd.js → catalog-runtime-DgouZKZm.js} +1 -1
  14. package/dist/cli/chat.d.ts +1 -1
  15. package/dist/cli/chat.js +15 -15
  16. package/dist/cli/check.js +3 -3
  17. package/dist/cli/init.js +2 -0
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.d.ts +1 -1
  20. package/dist/cli/plugins.js +4 -4
  21. package/dist/cli/snapshot-create.js +4 -4
  22. package/dist/cli/upgrade.d.ts +2 -2
  23. package/dist/cli/upgrade.js +3 -3
  24. package/dist/{config-mIZeGEWv.js → config-DvnTPCfp.js} +43 -2
  25. package/dist/{connections-XhdVg7OR.js → connections-CWaIVl_1.js} +6 -6
  26. package/dist/{conversation-CDWejM4R.js → conversation-CMkSmi02.js} +2 -11
  27. package/dist/{conversation-pending-messages-Dh2tfbaw.js → conversation-feed-BVAOga0H.js} +27 -2
  28. package/dist/{conversation-privacy-C6h-X2cZ.js → conversation-privacy-DPjv4SnA.js} +1 -1
  29. package/dist/{credential-sync-zigBlXS3.js → credential-sync-BhbaZfmO.js} +16 -15
  30. package/dist/{db-DV5AbcGM.d.ts → db-CCUqQe0E.d.ts} +6 -1
  31. package/dist/{db--xuNV7g6.js → db-Dts2XvLu.js} +54 -10
  32. package/dist/{executor-BItuRqAR.js → executor-Ck73J0wP.js} +8 -3
  33. package/dist/instrumentation.js +2 -2
  34. package/dist/{logging-Cb6MGvdt.js → logging-9OAq-fdg.js} +2 -1
  35. package/dist/{message-BTGgSmaH.js → message-CtaPzC7m.js} +9 -9
  36. package/dist/nitro.d.ts +2 -2
  37. package/dist/nitro.js +2 -2
  38. package/dist/{oauth-callback-server-Dvh1aOIi.js → oauth-callback-server-C_LXY1d4.js} +2 -2
  39. package/dist/{oauth-relay-D6xxVywK.js → oauth-relay-CsfIazeF.js} +2 -1
  40. package/dist/{plugins-DtmjkTza.d.ts → plugins-B_0Cr0MO.d.ts} +0 -1
  41. package/dist/{projection-DLQgfO5N.js → projection-BzJQncZV.js} +248 -77
  42. package/dist/{prompt-qp_LdxLX.js → prompt-Cbq5b4SO.js} +4 -4
  43. package/dist/{registry-MtwokaqW.js → registry-cbpOxO4M.js} +3 -13
  44. package/dist/{resolve-BnJA0UNE.js → resolve-t-pmRdwS.js} +3 -3
  45. package/dist/{result-ChL-1KyW.js → result-DhgjR3nQ.js} +8 -8
  46. package/dist/{runner-BONN7Dp2.js → runner-CHv9X9TH.js} +8 -8
  47. package/dist/{sandbox-egress-signals-nmlmI5Ab.js → sandbox-egress-signals-Yy3fSCbg.js} +1 -1
  48. package/dist/{schema-yr0ccDni.js → schema-BhneuGYv.js} +13 -6
  49. package/dist/{schema-DgvcyJ1y.d.ts → schema-TSEisVJR.d.ts} +50 -14
  50. package/dist/secrets-DebYU866.js +18 -0
  51. package/dist/{service-account-Bd0lBaGr.js → service-account-C4rBP8ne.js} +3 -3
  52. package/dist/{service-account-kio5nXSD.js → service-account-DjPIwCMj.js} +42 -26
  53. package/dist/{session-stop-CeCXL3j9.js → session-stop-DkxI5vc3.js} +20 -775
  54. package/dist/{skills-e3DDNlKO.js → skills-BZE2DP8I.js} +2 -2
  55. package/dist/{spawn--cRxITWQ.js → spawn-BvULxIiu.js} +5 -5
  56. package/dist/{adapter-DxLhJEnO.js → state-CO9ETDzk.js} +132 -2
  57. package/dist/{stop-Iai5N2PU.js → stop-CL-rdtQb.js} +84 -30
  58. package/dist/{store-C8LsaJwS.js → store-DgD78_NK.js} +3 -3
  59. package/dist/{task-runner-Dw7exu0-.js → task-runner-CKOj6xla.js} +11 -11
  60. package/dist/{turn-failure-response-BqTTx3XG.js → turn-failure-response-BTSo6SMJ.js} +8 -8
  61. package/dist/{validation-BrGahtnv.js → validation-CXeYgBzq.js} +1 -1
  62. package/dist/{version-Bdqhx8Qh.js → version-AQa7Fr2H.js} +1 -1
  63. package/dist/version.js +1 -1
  64. package/dist/{viewer-CjRFHR5U.js → viewer-Bqkb678l.js} +3 -3
  65. package/dist/warmup-h6u1e9n0.js +1869 -0
  66. package/dist/{work-BWBG1EGV.js → work-yN_GAuXY.js} +11 -11
  67. package/dist/{worker-DAnBIVMs.js → worker-Hl7N292I.js} +6 -6
  68. package/migrations/0098_review_item_plugin_actions.sql +5 -0
  69. package/migrations/0099_conversation_last_message_at.sql +1 -0
  70. package/migrations/0100_automation_task_kind_repair.sql +48 -0
  71. package/migrations/meta/0098_snapshot.json +4490 -0
  72. package/migrations/meta/0099_snapshot.json +4720 -0
  73. package/migrations/meta/0100_snapshot.json +4496 -0
  74. package/migrations/meta/_journal.json +21 -0
  75. package/package.json +5 -5
  76. package/dist/assistant-reply-iTtEdDyc.js +0 -58
  77. package/dist/warmup-DuxCtzKC.js +0 -1039
@@ -1,7 +1,7 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { h as logWarn } from "./logging-Cb6MGvdt.js";
2
+ import { h as logWarn } from "./logging-9OAq-fdg.js";
3
3
  import { s as skillRoots } from "./package-discovery-DJhGdS4c.js";
4
- import { n as pluginCatalogRuntime } from "./catalog-runtime-CLMA9AXd.js";
4
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-DgouZKZm.js";
5
5
  import path from "node:path";
6
6
  import * as z from "zod";
7
7
  import fs from "node:fs/promises";
@@ -1,9 +1,9 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { n as botConfig } from "./config-mIZeGEWv.js";
3
- import { E as conversationKindFromRow, o as getDb } from "./db--xuNV7g6.js";
4
- import { A as juniorConversations } from "./executor-BItuRqAR.js";
5
- import { en as AgentDepthLimitError, hn as toolInvocationDestination, mn as actorFromRun } from "./agent-runner-DJu7w6mI.js";
6
- import { n as createAndEnqueueAgentInvocation } from "./work-BWBG1EGV.js";
2
+ import { n as botConfig } from "./config-DvnTPCfp.js";
3
+ import { O as conversationKindFromRow, o as getDb } from "./db-Dts2XvLu.js";
4
+ import { A as juniorConversations } from "./executor-Ck73J0wP.js";
5
+ import { en as AgentDepthLimitError, hn as toolInvocationDestination, mn as actorFromRun } from "./agent-runner-DjMTPWEO.js";
6
+ import { n as createAndEnqueueAgentInvocation } from "./work-yN_GAuXY.js";
7
7
  import { desc, eq, sql } from "drizzle-orm";
8
8
  // src/chat/conversations/lineage.ts
9
9
  /**
@@ -1,5 +1,7 @@
1
- import { i as getChatConfig } from "./config-mIZeGEWv.js";
1
+ import { i as getChatConfig } from "./config-DvnTPCfp.js";
2
+ import { h as logWarn } from "./logging-9OAq-fdg.js";
2
3
  import { t as ACTIVE_LOCK_TTL_MS } from "./locks-D-0h111u.js";
4
+ import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
3
5
  import { createMemoryState } from "@chat-adapter/state-memory";
4
6
  import { createRedisState } from "@chat-adapter/state-redis";
5
7
  // src/chat/state/adapter.ts
@@ -253,4 +255,132 @@ async function disconnectStateAdapter() {
253
255
  redisStateAdapter = void 0;
254
256
  }
255
257
  }
256
- export { setStateValues as a, getStateValues as i, getDefaultRedisStateAdapterFor as n, getStateAdapter as r, disconnectStateAdapter as t };
258
+ // src/chat/encryption/secret.ts
259
+ /**
260
+ * Encrypt secrets that Junior keeps at rest, such as provider credentials.
261
+ *
262
+ * AES-256-GCM with keys from `JUNIOR_ENCRYPTION_KEYS` (see `keyring.ts`).
263
+ * Each value is bound to a context, usually its storage key, and to its key
264
+ * id as additional authenticated data. A value copied to another key does not
265
+ * decrypt.
266
+ *
267
+ * New values use the active key. Any listed key decrypts. A value from a key
268
+ * that is not active reports `stale`, so its owner can save it again with the
269
+ * active key. A value that cannot be decrypted gives `UnreadableSecretError`:
270
+ * `unknown_key` when its key id is not listed, `invalid` when it is malformed,
271
+ * altered, or bound to another context.
272
+ *
273
+ * There is no per-value salt. The keys are random, not passwords, and each
274
+ * value has a random IV. The storage key in the AAD already names the
275
+ * identity that owns the value.
276
+ *
277
+ * Envelope: `jenc:v1:<keyId>:<iv>.<ciphertext>.<tag>` (base64url parts).
278
+ */
279
+ const ENVELOPE_PREFIX = "jenc:v1:";
280
+ const ALGORITHM = "aes-256-gcm";
281
+ const IV_BYTES = 12;
282
+ const TAG_BYTES = 16;
283
+ /** A stored secret that cannot be decrypted with the configured keys. */
284
+ var UnreadableSecretError = class extends Error {
285
+ reason;
286
+ constructor(reason) {
287
+ super(reason === "unknown_key" ? "Stored secret was encrypted with a key that is not configured" : "Stored secret is malformed or failed authentication");
288
+ this.name = "UnreadableSecretError";
289
+ this.reason = reason;
290
+ }
291
+ };
292
+ function additionalData(keyId, context) {
293
+ return Buffer.from(`${ENVELOPE_PREFIX}${keyId}\0${context}`, "utf8");
294
+ }
295
+ /** Check whether a stored value is an encryption envelope. */
296
+ function isEncryptedSecret(value) {
297
+ return typeof value === "string" && value.startsWith(ENVELOPE_PREFIX);
298
+ }
299
+ /** Encrypt one secret with the active key and bind it to `context`. */
300
+ function encryptSecret(plaintext, context, keyring = getChatConfig().encryption) {
301
+ const { id, key } = keyring.active;
302
+ const iv = randomBytes(IV_BYTES);
303
+ const cipher = createCipheriv(ALGORITHM, key, iv, { authTagLength: TAG_BYTES });
304
+ cipher.setAAD(additionalData(id, context));
305
+ const parts = [
306
+ iv,
307
+ Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]),
308
+ cipher.getAuthTag()
309
+ ].map((part) => part.toString("base64url"));
310
+ return `${ENVELOPE_PREFIX}${id}:${parts.join(".")}`;
311
+ }
312
+ /** Decrypt an `encryptSecret` envelope with the same `context`. */
313
+ function decryptSecret(envelope, context, keyring = getChatConfig().encryption) {
314
+ if (!isEncryptedSecret(envelope)) throw new Error("Stored secret is not an encryption envelope");
315
+ const [keyId, payload] = envelope.slice(8).split(":");
316
+ const [iv, ciphertext, tag] = (payload ?? "").split(".").map((part) => Buffer.from(part, "base64url"));
317
+ if (!keyId || !iv || iv.length !== IV_BYTES || !ciphertext || !tag || tag.length !== TAG_BYTES) throw new UnreadableSecretError("invalid");
318
+ const match = keyring.keys.find((candidate) => candidate.id === keyId);
319
+ if (!match) throw new UnreadableSecretError("unknown_key");
320
+ const decipher = createDecipheriv(ALGORITHM, match.key, iv, { authTagLength: TAG_BYTES });
321
+ decipher.setAAD(additionalData(keyId, context));
322
+ decipher.setAuthTag(tag);
323
+ let text;
324
+ try {
325
+ text = Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
326
+ } catch {
327
+ throw new UnreadableSecretError("invalid");
328
+ }
329
+ return {
330
+ stale: match.id !== keyring.active.id,
331
+ text
332
+ };
333
+ }
334
+ // src/chat/encryption/state.ts
335
+ /**
336
+ * Decrypt one stored envelope. The storage key is the encryption context.
337
+ * A value that cannot be decrypted, such as one from a key that is no longer
338
+ * configured or one that was altered, reads as missing. The owner then asks
339
+ * for the credential again and saves it with the active key.
340
+ */
341
+ function decode(key, envelope) {
342
+ let decrypted;
343
+ try {
344
+ decrypted = decryptSecret(envelope, key);
345
+ } catch (error) {
346
+ if (!(error instanceof UnreadableSecretError)) throw error;
347
+ logWarn("encryption.secret_unreadable", { "error.type": error.reason });
348
+ return;
349
+ }
350
+ return {
351
+ stale: decrypted.stale,
352
+ value: JSON.parse(decrypted.text)
353
+ };
354
+ }
355
+ /**
356
+ * Wrap a state adapter so values are JSON-encoded and encrypted before they
357
+ * reach storage. Keys and TTLs stay readable. Use it for credentials and
358
+ * other secrets; delete, lock, and keep plain state on the base adapter.
359
+ */
360
+ function createEncryptedState(state) {
361
+ return {
362
+ async get(key) {
363
+ const stored = await state.get(key);
364
+ if (!isEncryptedSecret(stored)) return void 0;
365
+ return decode(key, stored)?.value;
366
+ },
367
+ async set(key, value, ttlMs) {
368
+ await state.set(key, encryptSecret(JSON.stringify(value), key), ttlMs);
369
+ }
370
+ };
371
+ }
372
+ /**
373
+ * Read a value and report whether it is stale: encrypted with a key that is
374
+ * not active, or saved before encryption. Long-lived owners save stale values
375
+ * again, so they move to the active key.
376
+ */
377
+ async function readEncryptedState(state, key) {
378
+ const stored = await state.get(key);
379
+ if (stored === null || stored === void 0) return void 0;
380
+ if (!isEncryptedSecret(stored)) return {
381
+ stale: true,
382
+ value: stored
383
+ };
384
+ return decode(key, stored);
385
+ }
386
+ export { getStateAdapter as a, getDefaultRedisStateAdapterFor as i, readEncryptedState as n, getStateValues as o, disconnectStateAdapter as r, setStateValues as s, createEncryptedState as t };
@@ -1,35 +1,35 @@
1
1
  import { h as startSpan } from "./sentry-BRTJqumy.js";
2
- import { $ as loadTurnCheckpoint, $a as createConversationAccessReader, A as latestConversationMessageSeq, Ao as lookupSlackUser, Bi as normalizeSlackStatusText, Bn as getPlugins, D as estimateConversationMessagesTokens, Do as listConversationAnnotationsById, E as buildConversationContext, En as createUserTokenStore, Eo as listConversationAnnotations, F as turnHasReply, Gi as getSlackMessagePermalink, H as PluginCredentialFailureError, Hi as truncateStatusText, I as upsertConversationMessage, Io as piMessageFromHistoryItem, Jt as buildTurnErrorResponse, K as AuthorizationFlowDisabledError, Li as escapeSlackMrkdwnText, M as normalizeConversationText, Mo as createPluginCache, N as recordDeliveredAssistantMessage, Nt as moveIdleConversationDestination, O as getConversationMessageSlackTs, On as webActorUserIds, P as trimConversationMessages, Po as configValueSchema, Qa as canAddConversationMessages, Qt as persistWithRetry, Ri as formatSlackLink, Rt as releaseInboundMessage, S as resolveConversationTitle, So as slackAttachmentsVersionQuery, Ui as addReactionToMessage, Wi as deleteSlackMessage, X as clearPendingAuth, Xa as createPluginLogger, Xi as removeReactionFromMessage, Yi as postSlackMessage, _o as notInheritedByForkChild, a as loadProjection, aa as getHeaderString, ao as conversationViewerMarks, at as failTurnRecord, b as persistConversationMessages, bo as readAttachmentVisionSummary, br as isOnlyAssignee, ca as isDmChannel, ct as recordTurnSummary, d as recordAuthorizationCompleted, da as withSlackRetries, do as readConversationEventPageAfter, eo as readConversationAccessFromSql, et as lostWorkerBeforeFirstSave, fo as readConversationEventPageAround, gr as canActOnReviewItem, h as recordSubscribedReplyRoute, ho as buildSentryConversationUrl, i as loadConversationProjection, io as conversationPinnedForUser, it as completeTurnRecord, j as markConversationMessage, jo as lookupSlackUserNames, k as isHumanConversationMessage, la as normalizeSlackConversationId, lo as readLatestConversationBrief, lr as listReplyActionItems, mn as trimTrailingAssistantMessages, n as commitMessages, na as SlackActionError, no as conversationIsMemberRoot, nt as saveTurnCheckpoint, o as loadTurnProjection, oa as getSlackClient, oo as viewerMarksFromParticipant, ot as getTurnRecord, pr as takeReviewItem, ra as downloadPrivateSlackFile, ri as getDashboardConversationLink, ro as conversationIsNotUnsubscribedRoot, rr as closeReviewItem, rt as abandonTurnRecord, sr as getReviewItem, st as listTurnSummaries, t as commitAcceptedReply, to as conversationHasParticipantUser, tt as pauseLostWorkerTurn, uo as readConversationEventPage, ur as listWaitingConversations, v as hydrateConversationMessages, vo as getSlackFileId, w as fallbackShortTitle, wr as reviewItemNeedsSomeone, xo as recordSlackAttachment, y as persistConversationMessageWindow, yr as canUserReadReviewItem, zr as cancelSubscriptions } from "./projection-DLQgfO5N.js";
3
- import { A as estimateTextTokens, E as resolveGatewayModel, K as isProviderRetryError, L as escapeXml, c as getSlackClientSecret, i as getChatConfig, j as textCharsForTokens, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, v as normalizeSlackEmojiName } from "./config-mIZeGEWv.js";
4
- import { E as withSpan, G as isRecord, K as toOptionalNumber, S as setTags, T as withLogContext, b as setSpanAttributes, f as logError, h as logWarn, m as logInfo, n as createChatSdkLogger, o as getActiveTraceContext, p as logException, q as toOptionalString, s as getActiveTraceId, t as buildTurnFailureResponse, y as setSentryUser } from "./logging-Cb6MGvdt.js";
5
- import { t as JUNIOR_VERSION } from "./version-Bdqhx8Qh.js";
2
+ import { $ as loadTurnCheckpoint, $a as createConversationAccessReader, A as latestConversationMessageSeq, Ao as lookupSlackUser, Bi as normalizeSlackStatusText, Bn as getPlugins, D as estimateConversationMessagesTokens, Do as listConversationAnnotationsById, E as buildConversationContext, En as createUserTokenStore, Eo as listConversationAnnotations, F as turnHasReply, Gi as getSlackMessagePermalink, H as PluginCredentialFailureError, Hi as truncateStatusText, I as upsertConversationMessage, Io as configValueSchema, Jt as buildTurnErrorResponse, K as AuthorizationFlowDisabledError, Li as escapeSlackMrkdwnText, M as normalizeConversationText, N as recordDeliveredAssistantMessage, Nt as moveIdleConversationDestination, O as getConversationMessageSlackTs, On as webActorUserIds, P as trimConversationMessages, Po as createPluginCache, Qa as canAddConversationMessages, Qt as persistWithRetry, Ri as formatSlackLink, Ro as piMessageFromHistoryItem, Rt as releaseInboundMessage, S as resolveConversationTitle, So as slackAttachmentsVersionQuery, Ui as addReactionToMessage, Wi as deleteSlackMessage, X as clearPendingAuth, Xa as createPluginLogger, Xi as removeReactionFromMessage, Yi as postSlackMessage, _o as notInheritedByForkChild, a as loadProjection, aa as getHeaderString, ao as conversationViewerMarks, at as failTurnRecord, b as persistConversationMessages, bo as readAttachmentVisionSummary, br as isOnlyAssignee, ca as isDmChannel, ct as recordTurnSummary, d as recordAuthorizationCompleted, da as withSlackRetries, do as readConversationEventPageAfter, eo as readConversationAccessFromSql, et as lostWorkerBeforeFirstSave, fo as readConversationEventPageAround, gr as canActOnReviewItem, h as recordSubscribedReplyRoute, ho as buildSentryConversationUrl, i as loadConversationProjection, io as conversationPinnedForUser, it as completeTurnRecord, j as markConversationMessage, jo as lookupSlackUserNames, k as isHumanConversationMessage, la as normalizeSlackConversationId, lo as readLatestConversationBrief, lr as listReplyActionItems, mn as trimTrailingAssistantMessages, n as commitMessages, na as SlackActionError, no as conversationIsMemberRoot, nt as saveTurnCheckpoint, o as loadTurnProjection, oa as getSlackClient, oo as viewerMarksFromParticipant, ot as getTurnRecord, pr as takeReviewItem, ra as downloadPrivateSlackFile, ri as getDashboardConversationLink, ro as conversationIsNotUnsubscribedRoot, rr as closeReviewItem, rt as abandonTurnRecord, sr as getReviewItem, st as listTurnSummaries, t as commitAcceptedReply, to as conversationHasParticipantUser, tt as pauseLostWorkerTurn, uo as readConversationEventPage, ur as listWaitingConversations, v as hydrateConversationMessages, vo as getSlackFileId, w as fallbackShortTitle, wr as reviewItemNeedsSomeone, xo as recordSlackAttachment, y as persistConversationMessageWindow, yr as canUserReadReviewItem, zr as cancelSubscriptions } from "./projection-BzJQncZV.js";
3
+ import { A as estimateTextTokens, E as resolveGatewayModel, K as isProviderRetryError, L as escapeXml, c as getSlackClientSecret, i as getChatConfig, j as textCharsForTokens, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, v as normalizeSlackEmojiName } from "./config-DvnTPCfp.js";
4
+ import { E as withSpan, G as isRecord, K as toOptionalNumber, S as setTags, T as withLogContext, b as setSpanAttributes, f as logError, h as logWarn, m as logInfo, n as createChatSdkLogger, o as getActiveTraceContext, p as logException, q as toOptionalString, s as getActiveTraceId, t as buildTurnFailureResponse, y as setSentryUser } from "./logging-9OAq-fdg.js";
5
+ import { t as JUNIOR_VERSION } from "./version-AQa7Fr2H.js";
6
6
  import { f as parseSlackTeamId, h as parseSlackMessageTs, i as isActorUserId, n as createSlackActor, o as isUserActor, r as createSlackResumeActor, s as parseActorUserId, t as createActor, u as parseSlackChannelId } from "./actor-6jsm_v96.js";
7
- import { $ as nextDetailVersion, C as isTopLevelKind, D as locationFromRow, E as conversationKindFromRow, G as addAgentTurnUsage, H as claimProviderConversation, J as agentTurnUsageSchema, M as resolveActorIdentityId, N as saveActorAvatar, O as setFirstConversationLocation, U as getConversationIdByProviderConversation, W as parseSessionSource, X as resolveRootConversationId, Y as hasAgentTurnUsage, _ as setArchivedAt, a as getConversationStore, b as withConversationMutationLock, g as readConversationTrees, m as conversationAncestors, o as getDb, p as withConversationEventLock, r as getConversationEventStore, rt as requireSlackDestination, s as getSqlExecutor, tt as createSlackDestination, v as loadConversationSlackTenantIds, w as postsRunNotices, x as deliversFinalText } from "./db--xuNV7g6.js";
8
- import { A as juniorConversations, D as juniorCodeChanges, E as juniorConversationAnnotations, M as juniorUsers, N as juniorDestinations, _ as juniorConversationReadPositions, b as juniorConversationBriefs, j as juniorIdentities, l as juniorReviewItems, s as juniorReviewItemConversations, v as juniorConversationParticipants, w as juniorConversationEvents } from "./executor-BItuRqAR.js";
7
+ import { A as setFirstConversationLocation, C as deliversFinalText, E as postsRunNotices, F as saveActorAvatar, G as getConversationIdByProviderConversation, K as parseSessionSource, O as conversationKindFromRow, P as resolveActorIdentityId, Q as resolveRootConversationId, S as withConversationMutationLock, T as isTopLevelKind, W as claimProviderConversation, X as agentTurnUsageSchema, Z as hasAgentTurnUsage, _ as setArchivedAt, a as getConversationStore, at as requireSlackDestination, g as readConversationTrees, k as locationFromRow, m as conversationAncestors, o as getDb, p as withConversationEventLock, q as addAgentTurnUsage, r as getConversationEventStore, rt as createSlackDestination, s as getSqlExecutor, tt as nextDetailVersion, v as loadConversationSlackTenantIds, y as lastMessageAtSql } from "./db-Dts2XvLu.js";
8
+ import { A as juniorConversations, D as juniorCodeChanges, E as juniorConversationAnnotations, M as juniorUsers, N as juniorDestinations, _ as juniorConversationReadPositions, b as juniorConversationBriefs, j as juniorIdentities, l as juniorReviewItems, s as juniorReviewItemConversations, v as juniorConversationParticipants, w as juniorConversationEvents } from "./executor-Ck73J0wP.js";
9
9
  import { _ as instructionProvenanceFor, a as KNOWN_CONVERSATION_EVENT_TYPES, h as contextProvenance, i as isVisionImageMediaType, r as detectImageMediaType } from "./media-BepyEUNm.js";
10
- import { d as actorLogContext, f as credentialContextForActor } from "./registry-MtwokaqW.js";
11
- import { A as runWithSlackInstallation, At as cancelSignInWait, B as listThreadReplies, Bt as canShareTurn, Dt as stopChildAgentsOf, Et as stopChildAgentsBelow, F as resolveSlackChannelIdFromThreadId, Ft as getPausedTurnRequest, I as checkSlackChannelReadAccess, Jt as withTurnSpan, Kt as getTurnInputSpanAttributes, L as joinPublicChannelForRead, Lt as wakePausedTurn, M as parseSlackThreadId, N as readSlackRawMessageContext, Nt as supersedeTurnForInput, P as resolveSlackChannelIdFromMessage, Pt as createPausedTurns, R as getConversationInfo, Rt as getTurnAuthorization, S as createSlackReviewItemShow, St as markConversationRead, Tt as throwApiError, Ut as AgentRunError, V as resolveDestinationVisibility, Wt as executeTurn, X as readConversationSourceTask, Xt as getWebAuthorization, Zt as canPauseConversationDelivery, at as deliverReviewItemChange, b as renderAttachmentText, ct as acceptsWebMessages, dt as createAndEnqueueConversation, ft as createConversationId, gn as shouldEmitDevAgentTrace, ht as decodeInputImages, i as buildAuthPauseResponse, jt as createConversationTurnWorker, lt as appendAndEnqueueWebMessage, mt as webActorFromUser, n as executeAgentRun, on as listedConversation, p as latestProgressStatus, pn as RetryableDeliveryError, pt as recordWebConversationActivity, qt as turnInputTelemetry, t as createAgentRunner, x as renderBlockText, xt as conversationReadPositionQuery, yt as storeAttachment, zt as canJoinTurn } from "./agent-runner-DJu7w6mI.js";
12
- import { a as EVENT_SYSTEM_ACTOR, c as completeDecision, o as isEventConversationMessage, u as completeText } from "./prompt-qp_LdxLX.js";
10
+ import { d as actorLogContext, f as credentialContextForActor } from "./registry-cbpOxO4M.js";
11
+ import { A as runWithSlackInstallation, At as cancelSignInWait, B as listThreadReplies, Bt as canShareTurn, Dt as stopChildAgentsOf, Et as stopChildAgentsBelow, F as resolveSlackChannelIdFromThreadId, Ft as getPausedTurnRequest, I as checkSlackChannelReadAccess, Jt as withTurnSpan, Kt as getTurnInputSpanAttributes, L as joinPublicChannelForRead, Lt as wakePausedTurn, M as parseSlackThreadId, N as readSlackRawMessageContext, Nt as supersedeTurnForInput, P as resolveSlackChannelIdFromMessage, Pt as createPausedTurns, R as getConversationInfo, Rt as getTurnAuthorization, S as createSlackReviewItemShow, St as markConversationRead, Tt as throwApiError, Ut as AgentRunError, V as resolveDestinationVisibility, Wt as executeTurn, X as readConversationSourceTask, Xt as getWebAuthorization, Zt as canPauseConversationDelivery, at as deliverReviewItemChange, b as renderAttachmentText, ct as acceptsWebMessages, dt as createAndEnqueueConversation, ft as createConversationId, gn as shouldEmitDevAgentTrace, ht as decodeInputImages, i as buildAuthPauseResponse, jt as createConversationTurnWorker, lt as appendAndEnqueueWebMessage, mt as webActorFromUser, n as executeAgentRun, on as listedConversation, p as latestProgressStatus, pn as RetryableDeliveryError, pt as recordWebConversationActivity, qt as turnInputTelemetry, t as createAgentRunner, x as renderBlockText, xt as conversationReadPositionQuery, yt as storeAttachment, zt as canJoinTurn } from "./agent-runner-DjMTPWEO.js";
12
+ import { a as EVENT_SYSTEM_ACTOR, c as completeDecision, o as isEventConversationMessage, u as completeText } from "./prompt-Cbq5b4SO.js";
13
13
  import { r as acquireActiveLock } from "./locks-D-0h111u.js";
14
- import { f as identityAvatarUrl, h as readUserAvatarUrls } from "./viewer-CjRFHR5U.js";
15
- import { a as setStateValues, i as getStateValues, r as getStateAdapter } from "./adapter-DxLhJEnO.js";
16
- import { W as readMessageAttachments, d as conversationEventPageSchema, l as conversationDetailReportSchema, m as conversationFeedSchema } from "./conversation-CDWejM4R.js";
17
- import { c as listConversationWork, l as readLastUserMessageAtByConversation, s as isConversationWorkDone } from "./warmup-DuxCtzKC.js";
18
- import { g as getVercelConversationWorkQueue, k as getTurnRequestDeadline } from "./background-compaction-queue-D2j-0XkH.js";
19
- import { a as persistAuthPauseTurnState, at as getConversationTurnBoundaryError, b as getChildAgentLabel, c as getTurnUserSlackMessageTs, ct as isTurnInputDeferredError, d as loadThreadContextTrimFloor, dt as markTurnFailed, ft as startActiveTurn, i as completeAuthPauseTurn, it as TurnInputDeferredError, l as buildDeliveredTurnStatePatch, lt as markTurnClosed, m as loadPendingMessageCards, mt as buildDeterministicTurnId, n as getAgentTurnDiagnosticsAttributes, nt as CooperativeTurnYieldError, o as getTurnUserMessage, ot as isCooperativeTurnYieldError, p as getTurnLifecycle, pt as buildDeterministicAssistantMessageId, r as requireTurnFailureEventId, rt as TurnInputCommitLostError, s as getTurnUserReplyAttachmentContext, st as isTurnInputCommitLostError, t as finalizeFailedTurnReplyWithEvent, tt as ConversationTurnBoundaryError, u as buildTurnThreadContext, ut as markTurnCompleted } from "./turn-failure-response-BqTTx3XG.js";
20
- import { n as getAssistantReplyText } from "./assistant-reply-iTtEdDyc.js";
21
- import { $ as withoutSavedSteeringMessages, B as maybePostAutomatedTurnLimitNotice, H as resolveSlackReplyTarget, K as recordFinishedTurnForAutomatedLimit, U as sendSlackReply, X as buildSteeringPiMessage, b as conversationSubtree, c as loadReviewItemInput, dt as finishedRunReply, g as resolveMailboxTurnWork, l as savedInputInstruction, mt as runDispatchOutcome, o as skipInputAfterConversationStop, r as markConversationsStopped, rt as isExperimentalFeatureEnabled, x as conversationSubtreeColumns, y as legacyWebMailboxMetadataSchema } from "./session-stop-CeCXL3j9.js";
14
+ import { f as identityAvatarUrl, h as readUserAvatarUrls } from "./viewer-Bqkb678l.js";
15
+ import { a as getStateAdapter, o as getStateValues, s as setStateValues } from "./state-CO9ETDzk.js";
16
+ import { U as readMessageAttachments, d as conversationEventPageSchema, l as conversationDetailReportSchema } from "./conversation-CMkSmi02.js";
17
+ import { t as readJuniorSecret } from "./secrets-DebYU866.js";
18
+ import { D as getAssistantReplyText, S as finishedRunReply, T as runDispatchOutcome, c as listConversationWork, l as readLastUserMessageAtByConversation, s as isConversationWorkDone } from "./warmup-h6u1e9n0.js";
19
+ import { g as getVercelConversationWorkQueue, k as getTurnRequestDeadline } from "./background-compaction-queue-DUkHZjmL.js";
20
+ import { a as persistAuthPauseTurnState, at as getConversationTurnBoundaryError, b as getChildAgentLabel, c as getTurnUserSlackMessageTs, ct as isTurnInputDeferredError, d as loadThreadContextTrimFloor, dt as markTurnFailed, ft as startActiveTurn, i as completeAuthPauseTurn, it as TurnInputDeferredError, l as buildDeliveredTurnStatePatch, lt as markTurnClosed, m as loadPendingMessageCards, mt as buildDeterministicTurnId, n as getAgentTurnDiagnosticsAttributes, nt as CooperativeTurnYieldError, o as getTurnUserMessage, ot as isCooperativeTurnYieldError, p as getTurnLifecycle, pt as buildDeterministicAssistantMessageId, r as requireTurnFailureEventId, rt as TurnInputCommitLostError, s as getTurnUserReplyAttachmentContext, st as isTurnInputCommitLostError, t as finalizeFailedTurnReplyWithEvent, tt as ConversationTurnBoundaryError, u as buildTurnThreadContext, ut as markTurnCompleted } from "./turn-failure-response-BTSo6SMJ.js";
21
+ import { $ as withoutSavedSteeringMessages, B as maybePostAutomatedTurnLimitNotice, H as resolveSlackReplyTarget, K as recordFinishedTurnForAutomatedLimit, U as sendSlackReply, X as buildSteeringPiMessage, b as conversationSubtree, c as loadReviewItemInput, g as resolveMailboxTurnWork, l as savedInputInstruction, o as skipInputAfterConversationStop, r as markConversationsStopped, rt as isExperimentalFeatureEnabled, x as conversationSubtreeColumns, y as legacyWebMailboxMetadataSchema } from "./session-stop-DkxI5vc3.js";
22
22
  import { b as normalizeUserInputAnswer, p as webMessageId, y as isEmptyUserInputAnswer } from "./reporting-window-B3Ze-Qnt.js";
23
- import { T as stopConversationWork, a as cancelHumanFacingPendingMessages, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, r as appendAndEnqueueInboundMessage, s as claimInboundMessage, w as steerWebPendingMessages } from "./store-C8LsaJwS.js";
24
- import { _ as markDispatchBlocked, a as claimDispatchMailboxAppend, at as readAutomationTitlesByConversationId, b as markDispatchRunning, c as getDispatchConversationId, d as getDispatchRecord, dt as getLocationConfigurationService, f as getDispatchTurnId, ft as getPersistedSandboxState, g as markDispatchAwaitingResume, gt as coerceThreadConversationState, ht as persistThreadStateById, lt as resolveConversationRouting, m as isTerminalDispatchStatus, mt as persistThreadRuntimeState, n as scheduleSessionCompletedPluginTasks, o as confirmDispatchMailboxAppend, pt as getPersistedThreadState, u as getDispatchInputMessageId, ut as resolveTurnSessionRouting, v as markDispatchCompleted, y as markDispatchFailed } from "./task-runner-Dw7exu0-.js";
25
- import { d as healthReportSchema, s as conversationPendingMessagesReportSchema } from "./conversation-pending-messages-Dh2tfbaw.js";
26
- import { r as endActiveAgentInvocations, s as resolveThreadTurnWork } from "./work-BWBG1EGV.js";
27
- import { a as withAgentInvocationResultActors, n as enqueueAgentInvocationResult, t as createChildConversationWorker } from "./result-ChL-1KyW.js";
28
- import { t as bindMessageAgent } from "./message-BTGgSmaH.js";
29
- import { r as readConversationLineage, t as bindSpawnAgent } from "./spawn--cRxITWQ.js";
23
+ import { T as stopConversationWork, a as cancelHumanFacingPendingMessages, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, r as appendAndEnqueueInboundMessage, s as claimInboundMessage, w as steerWebPendingMessages } from "./store-DgD78_NK.js";
24
+ import { _ as markDispatchBlocked, a as claimDispatchMailboxAppend, at as readAutomationTitlesByConversationId, b as markDispatchRunning, c as getDispatchConversationId, d as getDispatchRecord, dt as getLocationConfigurationService, f as getDispatchTurnId, ft as getPersistedSandboxState, g as markDispatchAwaitingResume, gt as coerceThreadConversationState, ht as persistThreadStateById, lt as resolveConversationRouting, m as isTerminalDispatchStatus, mt as persistThreadRuntimeState, n as scheduleSessionCompletedPluginTasks, o as confirmDispatchMailboxAppend, pt as getPersistedThreadState, u as getDispatchInputMessageId, ut as resolveTurnSessionRouting, v as markDispatchCompleted, y as markDispatchFailed } from "./task-runner-CKOj6xla.js";
25
+ import { l as conversationPendingMessagesReportSchema, n as conversationFeedSchema, p as healthReportSchema, t as conversationFeedBriefSchema } from "./conversation-feed-BVAOga0H.js";
26
+ import { r as endActiveAgentInvocations, s as resolveThreadTurnWork } from "./work-yN_GAuXY.js";
27
+ import { a as withAgentInvocationResultActors, n as enqueueAgentInvocationResult, t as createChildConversationWorker } from "./result-DhgjR3nQ.js";
28
+ import { t as bindMessageAgent } from "./message-CtaPzC7m.js";
29
+ import { r as readConversationLineage, t as bindSpawnAgent } from "./spawn-BvULxIiu.js";
30
30
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
31
31
  import * as z from "zod";
32
- import { and, asc, desc, eq, gt, inArray, isNotNull, isNull, lte, max, ne, or, sql } from "drizzle-orm";
32
+ import { and, asc, count, desc, eq, gt, inArray, isNotNull, isNull, lte, max, ne, or, sql } from "drizzle-orm";
33
33
  import { conversationSidebarAnnotationSchema, createSlackSource, objectTypeSchema } from "@sentry/junior-plugin-api";
34
34
  import { alias } from "drizzle-orm/pg-core";
35
35
  import { Message, ThreadImpl, stringifyMarkdown } from "chat";
@@ -55,6 +55,10 @@ const agentDispatchMailboxMetadataSchema = z.object({
55
55
  kind: z.literal("agent_dispatch")
56
56
  }).strict();
57
57
  const AGENT_DISPATCH_MAX_AGE_MS = 864e5;
58
+ /** Return whether a dispatch is a Scheduled or Event automation run. */
59
+ function isAutomationRun(dispatch) {
60
+ return dispatch.source.kind === "scheduled_automation" || dispatch.source.kind === "event_automation";
61
+ }
58
62
  /** Restore the exact actor, credential, and dispatch routing for every slice. */
59
63
  function buildDispatchRoutingContext(dispatch) {
60
64
  return {
@@ -68,7 +72,7 @@ function buildDispatchRoutingContext(dispatch) {
68
72
  replyAttribution: dispatch.replyAttribution,
69
73
  outcomes: dispatch.outcomes,
70
74
  ...dispatch.skill ? { skill: dispatch.skill } : void 0,
71
- ...dispatch.source.kind === "scheduled_automation" || dispatch.source.kind === "event_automation" ? { declaresResult: true } : void 0
75
+ ...isAutomationRun(dispatch) ? { declaresResult: true } : void 0
72
76
  },
73
77
  surface: "api"
74
78
  };
@@ -102,6 +106,7 @@ async function enqueueAgentDispatch(dispatch, options) {
102
106
  activityAtMs: claimedDispatch.createdAtMs,
103
107
  conversationId: getDispatchConversationId(claimedDispatch),
104
108
  destination: claimedDispatch.destination,
109
+ kind: isAutomationRun(claimedDispatch) ? "automation" : "root",
105
110
  nowMs,
106
111
  source: "plugin",
107
112
  sessionSource: claimedDispatch.source,
@@ -7153,7 +7158,7 @@ const conversationCursorPayloadSchema = z.object({
7153
7158
  version: z.literal(1)
7154
7159
  }).strict();
7155
7160
  function cursorSecret() {
7156
- const secret = process.env.JUNIOR_SECRET?.trim();
7161
+ const secret = readJuniorSecret();
7157
7162
  if (!secret) throw new Error("Cannot sign conversation cursor without JUNIOR_SECRET");
7158
7163
  return secret;
7159
7164
  }
@@ -9225,7 +9230,26 @@ async function readConversationDetail(conversationId, options = {}) {
9225
9230
  async function pinConversation(viewer, conversationId, body) {
9226
9231
  if (!(await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId)?.isParticipant) throwApiError(404, "Conversation not found.");
9227
9232
  const executor = getSqlExecutor();
9228
- return await executor.transaction(() => setPin(executor.db(), viewer, conversationId, body.pinned));
9233
+ return await executor.transaction(async () => {
9234
+ const db = executor.db();
9235
+ const result = await setPin(db, viewer, conversationId, body.pinned);
9236
+ recordPinUsage(body.pinned ? "pin" : "unpin", await countViewerPins(db, viewer));
9237
+ return result;
9238
+ });
9239
+ }
9240
+ /**
9241
+ * Tag the request span with a pin change and the viewer's pin count after
9242
+ * it. Pins stay manual; this shows how much people use them.
9243
+ */
9244
+ function recordPinUsage(action, pinnedCount) {
9245
+ setSpanAttributes({
9246
+ "app.conversation.pin.action": action,
9247
+ "app.conversation.pin.count": pinnedCount
9248
+ });
9249
+ }
9250
+ async function countViewerPins(db, viewer) {
9251
+ const [row] = await db.select({ pins: count() }).from(juniorConversationParticipants).where(and(eq(juniorConversationParticipants.userId, viewer.id), isNotNull(juniorConversationParticipants.pinnedAt)));
9252
+ return row?.pins ?? 0;
9229
9253
  }
9230
9254
  async function setPin(db, viewer, conversationId, pinned) {
9231
9255
  const [conversation] = await db.select({
@@ -9271,6 +9295,7 @@ async function reorderPinnedConversations(viewer, body) {
9271
9295
  const participants = juniorConversationParticipants;
9272
9296
  const positions = sql.join(ids.map((id, index) => sql`when ${id} then ${index}::integer`), sql` `);
9273
9297
  const updated = await getDb().update(participants).set({ pinPosition: sql`case ${participants.rootConversationId} ${positions} else ${participants.pinPosition} + ${ids.length}::integer end` }).where(and(eq(participants.userId, viewer.id), isNotNull(participants.pinnedAt))).returning({ rootConversationId: participants.rootConversationId });
9298
+ recordPinUsage("reorder", updated.length);
9274
9299
  const updatedIds = new Set(updated.map((row) => row.rootConversationId));
9275
9300
  return { conversationIds: ids.filter((id) => updatedIds.has(id)) };
9276
9301
  }
@@ -9410,6 +9435,29 @@ async function readConversationActivityPreviews(db, conversationIds) {
9410
9435
  }
9411
9436
  return previews;
9412
9437
  }
9438
+ // src/api/conversations/feed-brief.ts
9439
+ /**
9440
+ * Read the latest Brief version of each Conversation on a feed page, in one
9441
+ * query. A lateral limit reads one row per Conversation from the
9442
+ * (conversation, version) key, so long Brief histories do not slow the feed.
9443
+ * Callers show the result only when the viewer can see private content.
9444
+ */
9445
+ async function readConversationFeedBriefs(db, conversationIds) {
9446
+ if (conversationIds.length === 0) return /* @__PURE__ */ new Map();
9447
+ const content = juniorConversationBriefs.content;
9448
+ const latest = db.select({
9449
+ intent: sql`${content}->>'intent'`.as("intent"),
9450
+ status: sql`${content}->'outcome'->>'status'`.as("status"),
9451
+ summary: sql`${content}->>'summary'`.as("summary")
9452
+ }).from(juniorConversationBriefs).where(eq(juniorConversationBriefs.conversationId, juniorConversations.conversationId)).orderBy(desc(juniorConversationBriefs.version)).limit(1).as("latest_brief");
9453
+ const rows = await db.select({
9454
+ conversationId: juniorConversations.conversationId,
9455
+ intent: latest.intent,
9456
+ status: latest.status,
9457
+ summary: latest.summary
9458
+ }).from(juniorConversations).innerJoinLateral(latest, sql`true`).where(inArray(juniorConversations.conversationId, conversationIds));
9459
+ return new Map(rows.map(({ conversationId, ...brief }) => [conversationId, conversationFeedBriefSchema.parse(brief)]));
9460
+ }
9413
9461
  // src/api/conversations/list.ts
9414
9462
  const CONVERSATION_FEED_LIMIT = 50;
9415
9463
  function feedMember(filter) {
@@ -9439,6 +9487,7 @@ function conversationCodeRepositoryFilter(repositoryId, viewerUserId) {
9439
9487
  async function conversationRows(db, { codeRepository, conversationIds, filter, includePrivateBriefs = false, limit, query, status }) {
9440
9488
  return db.select({
9441
9489
  ...conversationRecordColumns,
9490
+ lastMessageAt: sql`coalesce(${juniorConversations.lastMessageAt}, ${lastMessageAtSql(db)})`.mapWith(juniorConversations.lastMessageAt),
9442
9491
  awaitingAuthorization: treeAwaitsAuthorization(juniorConversations.conversationId)
9443
9492
  }).from(juniorConversations).leftJoin(juniorDestinations, conversationRecordJoins.location).leftJoin(juniorIdentities, conversationRecordJoins.identity).leftJoin(juniorUsers, conversationRecordJoins.user).where(and(listedConversation(), conversationFeedMembershipFilter(status, filter), conversationIds ? inArray(juniorConversations.conversationId, conversationIds) : void 0, codeRepository ? conversationCodeRepositoryFilter(codeRepository.id, codeRepository.viewerUserId) : void 0, query ? or(sql`strpos(lower(coalesce(${juniorConversations.title}, '')), ${query}) > 0`, sql`exists (
9444
9493
  select 1
@@ -9456,7 +9505,7 @@ async function conversationRows(db, { codeRepository, conversationIds, filter, i
9456
9505
  }
9457
9506
  /**
9458
9507
  * Read the viewer's active conversations that wait on them but fall outside
9459
- * the newest page. Needs attention shows every conversation that waits on the
9508
+ * the newest page. Needs you shows every conversation that waits on the
9460
9509
  * viewer, so an old one must come back to the feed.
9461
9510
  */
9462
9511
  async function waitingRowsOutsidePage(db, filter, page) {
@@ -9587,7 +9636,7 @@ async function readConversationFeedFromSql(options = {}) {
9587
9636
  if (filter?.kind === "viewer" && status === "active") rows.push(...await waitingRowsOutsidePage(db, filter, rows));
9588
9637
  const conversations = rows.map((row) => conversationFromRecordRow(row));
9589
9638
  const conversationIds = conversations.map((conversation) => conversation.conversationId);
9590
- const [accessByConversation, viewerMarksByConversation, annotationsByConversation, auxiliaryCostsByRoot, metricsByRoot, participantsByConversation, teamDomainByTeamId, { work: conversationWork, lastUserMessageAt: lastUserMessageAtByConversation }, activityPreviewByConversation, automationTitleByConversation, firstHumanMessageTextByConversation, unreadConversationIds] = await Promise.all([
9639
+ const [accessByConversation, viewerMarksByConversation, annotationsByConversation, auxiliaryCostsByRoot, metricsByRoot, participantsByConversation, teamDomainByTeamId, { work: conversationWork, lastUserMessageAt: lastUserMessageAtByConversation }, activityPreviewByConversation, briefByConversation, automationTitleByConversation, firstHumanMessageTextByConversation, unreadConversationIds] = await Promise.all([
9591
9640
  readConversationAccessFromSql(db, conversationIds, options.viewer),
9592
9641
  conversationViewerMarks(db, conversationIds, filter ? feedMember(filter) : void 0),
9593
9642
  listConversationAnnotationsById(db, conversationIds),
@@ -9600,6 +9649,7 @@ async function readConversationFeedFromSql(options = {}) {
9600
9649
  lastUserMessageAt: await readLastUserMessageAtByConversation(db, work.assignedIds.filter((conversationId) => work.finishedAtById[conversationId]))
9601
9650
  })),
9602
9651
  readConversationActivityPreviews(db, conversationIds),
9652
+ readConversationFeedBriefs(db, conversationIds),
9603
9653
  readAutomationTitlesByConversationId(conversations),
9604
9654
  readFirstHumanMessageTexts(db, conversations),
9605
9655
  filter?.kind === "viewer" ? readUnreadConversationIds(db, conversationIds, filter.userId) : /* @__PURE__ */ new Set()
@@ -9640,15 +9690,19 @@ async function readConversationFeedFromSql(options = {}) {
9640
9690
  };
9641
9691
  const annotations = access?.canViewPrivateContent ? annotationsByConversation.get(conversation.conversationId) ?? [] : [];
9642
9692
  const activityPreview = visibleActivityPreviews.get(conversation.conversationId);
9693
+ const brief = access?.canViewPrivateContent ? briefByConversation.get(conversation.conversationId) : void 0;
9643
9694
  const participants = access?.canViewPrivateContent ? participantsByConversation.get(conversation.conversationId) : void 0;
9644
9695
  const threads = threadsByRoot.get(conversation.conversationId);
9696
+ const lastMessageAt = row.lastMessageAt?.toISOString();
9645
9697
  return {
9646
9698
  ...summary,
9647
9699
  ...work,
9648
9700
  ...row.awaitingAuthorization ? { awaitingAuthorization: true } : void 0,
9701
+ ...lastMessageAt ? { lastMessageAt } : void 0,
9649
9702
  ...threads ? { threads } : void 0,
9650
9703
  ...participants && participants.length > 0 ? { participants } : void 0,
9651
9704
  ...activityPreview ? { activityPreview } : void 0,
9705
+ ...brief ? { brief } : void 0,
9652
9706
  ...annotations.length > 0 ? { annotations } : void 0,
9653
9707
  ...sidebarAnnotationsByConversation[conversation.conversationId] ? { sidebarAnnotations: sidebarAnnotationsByConversation[conversation.conversationId] } : void 0,
9654
9708
  isPriority: isConversationPriority({
@@ -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-DLQgfO5N.js";
2
- import { a as getConversationStore } from "./db--xuNV7g6.js";
3
- import "./background-compaction-queue-D2j-0XkH.js";
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-BzJQncZV.js";
2
+ import { a as getConversationStore } from "./db-Dts2XvLu.js";
3
+ import "./background-compaction-queue-DUkHZjmL.js";
4
4
  // src/chat/task-execution/store.ts
5
5
  function metadataStore(options) {
6
6
  return options.conversationStore ?? getConversationStore();
@@ -1,16 +1,16 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { Bn as getPlugins, Ia as createPluginEmbedder, Ki as openSlackDirectMessage, La as createPluginModel, Li as escapeSlackMrkdwnText, Mo as createPluginCache, No as createDurableLocationConfigurationService, 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-DLQgfO5N.js";
3
- import { n as botConfig } from "./config-mIZeGEWv.js";
4
- import { E as withSpan, G as isRecord$1, K as toOptionalNumber, _ as runBestEffort, h as logWarn, q as toOptionalString } from "./logging-Cb6MGvdt.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-BzJQncZV.js";
3
+ import { n as botConfig } from "./config-DvnTPCfp.js";
4
+ import { E as withSpan, G as isRecord$1, K as toOptionalNumber, _ as runBestEffort, h as logWarn, q as toOptionalString } from "./logging-9OAq-fdg.js";
5
5
  import { h as parseSlackMessageTs } from "./actor-6jsm_v96.js";
6
- import { K as agentTurnCostUsd, a as getConversationStore, o as getDb, q as agentTurnTotalTokens } from "./db--xuNV7g6.js";
7
- import { A as juniorConversations, d as juniorAutomationVersions, f as juniorAutomations, u as juniorAutomationRuns } from "./executor-BItuRqAR.js";
6
+ import { J as agentTurnCostUsd, Y as agentTurnTotalTokens, a as getConversationStore, o as getDb } from "./db-Dts2XvLu.js";
7
+ import { A as juniorConversations, d as juniorAutomationVersions, f as juniorAutomations, u as juniorAutomationRuns } from "./executor-Ck73J0wP.js";
8
8
  import { v as sameActorIdentity } from "./media-BepyEUNm.js";
9
- import { h as credentialSubjectSchema } from "./registry-MtwokaqW.js";
10
- import { i as readActorIdentity } from "./viewer-CjRFHR5U.js";
11
- import { r as getStateAdapter } from "./adapter-DxLhJEnO.js";
12
- import { c as pluginTaskParamsSchema, d as sendVercelPluginTask, s as pluginTaskId } from "./background-compaction-queue-D2j-0XkH.js";
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-BM-OBsKW.js";
9
+ import { h as credentialSubjectSchema } from "./registry-cbpOxO4M.js";
10
+ import { i as readActorIdentity } from "./viewer-Bqkb678l.js";
11
+ import { a as getStateAdapter } from "./state-CO9ETDzk.js";
12
+ import { c as pluginTaskParamsSchema, d as sendVercelPluginTask, s as pluginTaskId } from "./background-compaction-queue-DUkHZjmL.js";
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";
16
16
  import { and, asc, count, desc, eq, gte, inArray, isNotNull, isNull, lte, max, ne, or, sql } from "drizzle-orm";
@@ -349,7 +349,7 @@ function slackSourceForDestination(args) {
349
349
  * Reads parent Conversations when this Conversation has no Destination.
350
350
  */
351
351
  async function resolveConversationRouting(args) {
352
- const conversationStore = args.conversationStore ?? (await import("./db--xuNV7g6.js").then((n) => n.n)).getConversationStore();
352
+ const conversationStore = args.conversationStore ?? (await import("./db-Dts2XvLu.js").then((n) => n.n)).getConversationStore();
353
353
  const chain = await loadConversationChain(args.conversationId, conversationStore);
354
354
  let destination;
355
355
  let source;
@@ -1,13 +1,13 @@
1
- import { E as buildConversationContext, Eo as listConversationAnnotations, X as clearPendingAuth, j as markConversationMessage, v as hydrateConversationMessages } from "./projection-DLQgfO5N.js";
2
- import { H as findProviderError, U as getProviderErrorAttributes, W as getProviderErrorUserMessage, g as TURN_REASONING_LEVELS, z as ProviderError } from "./config-mIZeGEWv.js";
3
- import { G as isRecord, b as setSpanAttributes, t as buildTurnFailureResponse } from "./logging-Cb6MGvdt.js";
1
+ import { E as buildConversationContext, Eo as listConversationAnnotations, X as clearPendingAuth, j as markConversationMessage, v as hydrateConversationMessages } from "./projection-BzJQncZV.js";
2
+ import { H as findProviderError, U as getProviderErrorAttributes, W as getProviderErrorUserMessage, g as TURN_REASONING_LEVELS, z as ProviderError } from "./config-DvnTPCfp.js";
3
+ import { G as isRecord, b as setSpanAttributes, t as buildTurnFailureResponse } from "./logging-9OAq-fdg.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--xuNV7g6.js";
6
- import { g as juniorAgentInvocations } from "./executor-BItuRqAR.js";
7
- import { p as credentialContextSchema } from "./registry-MtwokaqW.js";
8
- import { B as resolveMessageCards, R as readMessageCardRefs, z as removedCardSchema } from "./conversation-CDWejM4R.js";
5
+ import { o as getDb, r as getConversationEventStore, s as getSqlExecutor } from "./db-Dts2XvLu.js";
6
+ import { g as juniorAgentInvocations } from "./executor-Ck73J0wP.js";
7
+ import { p as credentialContextSchema } from "./registry-cbpOxO4M.js";
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 { gt as coerceThreadConversationState, ht as persistThreadStateById, pt as getPersistedThreadState } from "./task-runner-Dw7exu0-.js";
10
+ import { gt as coerceThreadConversationState, ht as persistThreadStateById, pt as getPersistedThreadState } from "./task-runner-CKOj6xla.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";
@@ -1,5 +1,5 @@
1
1
  import { v as __exportAll } from "./sentry-BRTJqumy.js";
2
- import { n as pluginCatalogRuntime } from "./catalog-runtime-CLMA9AXd.js";
2
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-DgouZKZm.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.294.0";
2
+ var version = "0.295.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-Bdqhx8Qh.js";
1
+ export { t as JUNIOR_VERSION } from "./version-AQa7Fr2H.js";
@@ -1,6 +1,6 @@
1
- import { H as GOOGLE_IDENTITY_PROVIDER, W as normalizeIdentityEmail, h as logWarn } from "./logging-Cb6MGvdt.js";
2
- import { j as findActorIdentityId, o as getDb } from "./db--xuNV7g6.js";
3
- import { M as juniorUsers, j as juniorIdentities } from "./executor-BItuRqAR.js";
1
+ import { H as GOOGLE_IDENTITY_PROVIDER, W as normalizeIdentityEmail, h as logWarn } from "./logging-9OAq-fdg.js";
2
+ import { N as findActorIdentityId, o as getDb } from "./db-Dts2XvLu.js";
3
+ import { M as juniorUsers, j as juniorIdentities } from "./executor-Ck73J0wP.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";