@sentry/junior 0.296.0 → 0.297.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 (82) hide show
  1. package/dist/{admin-z_lgDi-z.js → admin-tmGIw4KS.js} +2 -2
  2. package/dist/{agent-runner-HoQiUKLL.js → agent-runner-CneTquAE.js} +378 -1919
  3. package/dist/api/schema.d.ts +2 -2
  4. package/dist/api/schema.js +7 -7
  5. package/dist/api.d.ts +1 -1
  6. package/dist/api.js +38 -267
  7. package/dist/{app-C75Ft-A_.d.ts → app-BJojZ7HL.d.ts} +7 -2
  8. package/dist/app.d.ts +1 -1
  9. package/dist/app.js +64 -44
  10. package/dist/attempt-selection-ClP3MMPr.js +61 -0
  11. package/dist/{automation-yJX3C7i3.js → automation-BrP6ImrC.js} +1 -1
  12. package/dist/{background-compaction-queue-Cre1wFt9.js → background-compaction-queue-CwfJy3Cd.js} +4 -88
  13. package/dist/{briefs-BXECHduJ.js → briefs-uFTuhMqA.js} +3 -3
  14. package/dist/{catalog-runtime-CpCmlD9L.js → catalog-runtime-0kuQqYL4.js} +1 -1
  15. package/dist/cli/chat.js +19 -15
  16. package/dist/cli/check.js +3 -3
  17. package/dist/cli/main.js +3 -3
  18. package/dist/cli/plugins.js +4 -4
  19. package/dist/cli/snapshot-create.js +4 -4
  20. package/dist/cli/upgrade.d.ts +1 -1
  21. package/dist/cli/upgrade.js +3 -3
  22. package/dist/{config-CCPHvTqx.js → config-Dj9M_nqB.js} +2 -2
  23. package/dist/{connections-B5pWh8e2.js → connections-B96JUM5o.js} +6 -6
  24. package/dist/{conversation-CMkSmi02.js → conversation-CvcBU1z2.js} +2 -16
  25. package/dist/{conversation-feed-BVAOga0H.js → conversation-feed-BSMlGZnS.js} +1 -1
  26. package/dist/{conversation-privacy-CZD5soDW.js → conversation-privacy-DI29jbZV.js} +1 -1
  27. package/dist/conversation-turn-CZWBr091.js +805 -0
  28. package/dist/{credential-sync-DwLkIvXI.js → credential-sync-Blhx4_xf.js} +14 -13
  29. package/dist/{db-C1M1y-bh.js → db-Br0tfAo7.js} +43 -15
  30. package/dist/{db-B3iyr_Or.d.ts → db-CrtyFRz7.d.ts} +13 -1
  31. package/dist/{executor-DUSEwXaO.js → executor-BMPipFVA.js} +14 -6
  32. package/dist/instrumentation.js +2 -2
  33. package/dist/{logging-D0svFM8r.js → logging-CQjlDQYX.js} +1 -1
  34. package/dist/{message-BFnIwKpx.js → message-BOZEIuxy.js} +15 -13
  35. package/dist/nitro.d.ts +1 -1
  36. package/dist/nitro.js +3 -2
  37. package/dist/{session-stop-hYNTNpVf.js → notification-gusCgdQ6.js} +11 -930
  38. package/dist/{oauth-callback-server-BXRtD6Fk.js → oauth-callback-server-V_DuMuNX.js} +2 -2
  39. package/dist/{projection-B6VS7kbo.js → projection-B08mfi0u.js} +333 -106
  40. package/dist/{prompt-CD11tfG8.js → prompt-BlutWLNt.js} +4 -4
  41. package/dist/prompt-input-Dxn8cDC0.js +1424 -0
  42. package/dist/{registry-CHewwYEo.js → registry-BDWgCJDf.js} +1 -1
  43. package/dist/reporting-window-DopzcOHh.js +137 -0
  44. package/dist/{resolve-1owMH4qo.js → resolve-2Z_o_SsI.js} +3 -3
  45. package/dist/result-CAujiaci.js +463 -0
  46. package/dist/{runner-BtWvJslp.js → runner-D2Chc02N.js} +9 -8
  47. package/dist/{sandbox-egress-signals-ByftwJVt.js → sandbox-egress-signals-CFoJduFj.js} +1 -1
  48. package/dist/{schema-D2iGyYIp.js → schema-Bqa5NbcP.js} +11 -48
  49. package/dist/{schema-Ct1Zf2xy.d.ts → schema-Ce2XCS7O.d.ts} +8 -107
  50. package/dist/{service-account-DLoeoHww.js → service-account-C9kRQEb_.js} +3 -3
  51. package/dist/{service-account-BZEuMKdo.js → service-account-CERfXEVU.js} +3 -3
  52. package/dist/session-stop-B-I1rAS1.js +181 -0
  53. package/dist/{skills-DXgd5Inh.js → skills-B0m1nZ_j.js} +2 -2
  54. package/dist/{spawn-YeqlNDv8.js → spawn-CwMjRRtn.js} +6 -5
  55. package/dist/{state-C3CbtD_m.js → state-DFnmLmfn.js} +2 -2
  56. package/dist/{stop-Cze_pEL8.js → stop-BCH9VNGf.js} +63 -158
  57. package/dist/{store-CZ9vqR4P.js → store-B59rOYbS.js} +11 -4
  58. package/dist/{task-runner-CMiNGsER.js → store-m5bmdmsP.js} +939 -1593
  59. package/dist/task-queue-N0kuCknH.js +89 -0
  60. package/dist/task-runner-COOwR8qm.js +291 -0
  61. package/dist/thread-context-Cd44z_W5.js +248 -0
  62. package/dist/turn-cancel-DDu8TOwt.js +201 -0
  63. package/dist/turn-session-routing-BlCtVFRN.js +380 -0
  64. package/dist/{turn-failure-response-pXhZ2wMK.js → turn-user-message-ygLG3ylQ.js} +183 -361
  65. package/dist/turn-wake-DmQec4AG.js +161 -0
  66. package/dist/{reporting-window-B3Ze-Qnt.js → user-input-request-CXNIov9n.js} +24 -143
  67. package/dist/{validation-Du7NdkOR.js → validation-Ba2OcUse.js} +1 -1
  68. package/dist/{version-EN3Wnq-R.js → version-KNDzIAh6.js} +1 -1
  69. package/dist/version.js +1 -1
  70. package/dist/{viewer-Agxi_o5c.js → viewer-BPpuN2f9.js} +3 -3
  71. package/dist/warmup-Bskrwmk1.js +2697 -0
  72. package/dist/{worker-BALVdWbv.js → worker-B1skZlit.js} +20 -8
  73. package/migrations/0102_code_change_last_activity.sql +1 -0
  74. package/migrations/0103_agent_invocation_fork.sql +8 -0
  75. package/migrations/meta/0102_snapshot.json +4502 -0
  76. package/migrations/meta/0103_snapshot.json +4509 -0
  77. package/migrations/meta/_journal.json +14 -0
  78. package/package.json +4 -4
  79. package/dist/result-CEqQFrEf.js +0 -305
  80. package/dist/result-event-type-DD6BAgT7.js +0 -11
  81. package/dist/warmup-CY2ArYag.js +0 -2017
  82. package/dist/work-EA98F0ia.js +0 -768
@@ -1,35 +1,44 @@
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 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-B6VS7kbo.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-CCPHvTqx.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-D0svFM8r.js";
5
- import { t as JUNIOR_VERSION } from "./version-EN3Wnq-R.js";
2
+ import { $ as loadTurnCheckpoint, $i as escapeSlackMrkdwnText, $o as configValueSchema, A as latestConversationMessageSeq, An as trimTrailingAssistantMessages, Br as reviewItemNeedsSomeone, Cr as getReviewItem, D as estimateConversationMessagesTokens, Da as withSlackRetries, Do as readConversationEventPageAfter, E as buildConversationContext, Eo as readConversationEventPage, Er as listWaitingConversations, F as turnHasReply, Fo as getSlackFileId, Fr as canUserReadReviewItem, H as PluginCredentialFailureError, Hn as createUserTokenStore, I as upsertConversationMessage, Ir as isOnlyAssignee, Jo as lookupSlackUserNames, K as AuthorizationFlowDisabledError, Lo as readAttachmentVisionSummary, M as normalizeConversationText, Mr as canActOnReviewItem, N as recordDeliveredAssistantMessage, O as getConversationMessageSlackTs, Oo as readConversationEventPageAround, P as trimConversationMessages, Po as notInheritedByForkChild, Pt as moveIdleConversationDestination, Ro as recordSlackAttachment, S as resolveConversationTitle, Sa as getSlackClient, So as viewerMarksFromParticipant, Ta as normalizeSlackConversationId, To as readLatestConversationBrief, Tr as listReplyActionItems, Uo as listConversationAnnotations, Wn as webActorUserIds, Wo as listConversationAnnotationsById, X as clearPendingAuth, Xt as buildTurnErrorResponse, Zo as createPluginCache, _o as conversationHasParticipantUser, a as loadProjection, aa as addReactionToMessage, an as getAssistantReplyText, at as failTurnRecord, b as persistConversationMessages, bo as conversationPinnedForUser, ct as recordTurnSummary, d as recordAuthorizationCompleted, da as postSlackMessage, ea as formatSlackLink, et as lostWorkerBeforeFirstSave, fa as removeReactionFromMessage, fo as createPluginLogger, go as readConversationAccessFromSql, h as recordSubscribedReplyRoute, ho as createConversationAccessReader, i as loadConversationProjection, ia as truncateStatusText, it as completeTurnRecord, j as markConversationMessage, jo as buildSentryConversationUrl, k as isHumanConversationMessage, kr as takeReviewItem, mn as persistWithRetry, mo as canAddConversationMessages, n as commitMessages, na as normalizeSlackStatusText, nr as getPlugins, nt as saveTurnCheckpoint, o as loadTurnProjection, oa as deleteSlackMessage, ot as getTurnRecord, qo as lookupSlackUser, rt as abandonTurnRecord, sa as getSlackMessagePermalink, st as listTurnSummaries, t as commitAcceptedReply, ti as cancelSubscriptions, ts as piMessageFromHistoryItem, tt as pauseLostWorkerTurn, v as hydrateConversationMessages, va as SlackActionError, vo as conversationIsMemberRoot, w as fallbackShortTitle, wa as isDmChannel, xa as getHeaderString, xo as conversationViewerMarks, y as persistConversationMessageWindow, ya as downloadPrivateSlackFile, yi as getDashboardConversationLink, yo as conversationIsNotUnsubscribedRoot, yr as closeReviewItem, zo as slackAttachmentsVersionQuery, zt as releaseInboundMessage } from "./projection-B08mfi0u.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-Dj9M_nqB.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-CQjlDQYX.js";
5
+ import { t as JUNIOR_VERSION } from "./version-KNDzIAh6.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 { 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-C1M1y-bh.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-DUSEwXaO.js";
7
+ import { A as setFirstConversationLocation, C as deliversFinalText, E as postsRunNotices, F as saveActorAvatar, G as parseSessionSource, K as addAgentTurnUsage, O as conversationKindFromRow, P as resolveActorIdentityId, S as withConversationMutationLock, T as isTopLevelKind, U as claimProviderConversation, W as getConversationIdByProviderConversation, X as hasAgentTurnUsage, Y as agentTurnUsageSchema, Z as resolveRootConversationId, _ as setArchivedAt, a as getConversationStore, et as nextDetailVersion, g as readConversationTrees, it as requireSlackDestination, k as locationFromRow, m as conversationAncestors, nt as createSlackDestination, o as getDb, p as withConversationEventLock, r as getConversationEventStore, s as getSqlExecutor, v as loadConversationSlackTenantIds, y as lastMessageAtSql } from "./db-Br0tfAo7.js";
8
+ import { A as juniorConversations, D as juniorCodeChanges, E as juniorConversationAnnotations, M as juniorUsers, N as juniorDestinations, b as juniorConversationBriefs, j as juniorIdentities, l as juniorReviewItems, s as juniorReviewItemConversations, v as juniorConversationParticipants, w as juniorConversationEvents } from "./executor-BMPipFVA.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-CHewwYEo.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-HoQiUKLL.js";
12
- import { a as EVENT_SYSTEM_ACTOR, c as completeDecision, o as isEventConversationMessage, u as completeText } from "./prompt-CD11tfG8.js";
10
+ import { d as actorLogContext, f as credentialContextForActor } from "./registry-BDWgCJDf.js";
11
+ import { C as createSlackReviewItemShow, Ct as conversationReadPositionQuery, F as resolveSlackChannelIdFromMessage, H as resolveDestinationVisibility, I as resolveSlackChannelIdFromThreadId, L as checkSlackChannelReadAccess, Lt as shouldEmitDevAgentTrace, N as parseSlackThreadId, Ot as throwApiError, P as readSlackRawMessageContext, Pt as RetryableDeliveryError, R as joinPublicChannelForRead, S as renderBlockText, V as listThreadReplies, Z as readConversationSourceTask, _t as decodeInputImages, a as buildAuthPauseResponse, ft as createAndEnqueueConversation, ht as webActorFromUser, j as runWithSlackInstallation, kt as listedConversation, lt as acceptsWebMessages, m as latestProgressStatus, mt as recordWebConversationActivity, n as executeAgentRun, ot as deliverReviewItemChange, pt as createConversationId, t as createAgentRunner, ut as appendAndEnqueueWebMessage, x as renderAttachmentText, xt as storeAttachment, z as getConversationInfo } from "./agent-runner-CneTquAE.js";
12
+ import { a as EVENT_SYSTEM_ACTOR, c as completeDecision, o as isEventConversationMessage, u as completeText } from "./prompt-BlutWLNt.js";
13
13
  import { r as acquireActiveLock } from "./locks-D-0h111u.js";
14
- import { f as identityAvatarUrl, h as readUserAvatarUrls } from "./viewer-Agxi_o5c.js";
15
- import { a as getStateAdapter, o as getStateValues, s as setStateValues } from "./state-C3CbtD_m.js";
16
- import { U as readMessageAttachments, d as conversationEventPageSchema, l as conversationDetailReportSchema } from "./conversation-CMkSmi02.js";
14
+ import { f as identityAvatarUrl, h as readUserAvatarUrls } from "./viewer-BPpuN2f9.js";
15
+ import { a as getStateAdapter, o as getStateValues, s as setStateValues } from "./state-DFnmLmfn.js";
16
+ import { H as readMessageAttachments, d as conversationEventPageSchema, l as conversationDetailReportSchema } from "./conversation-CvcBU1z2.js";
17
17
  import { t as readJuniorSecret } from "./secrets-DebYU866.js";
18
- import { T as getAssistantReplyText, c as listConversationWork, l as readLastUserMessageAtByConversation, s as isConversationWorkDone } from "./warmup-CY2ArYag.js";
19
- import { g as getVercelConversationWorkQueue, k as getTurnRequestDeadline } from "./background-compaction-queue-Cre1wFt9.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-pXhZ2wMK.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-hYNTNpVf.js";
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-CZ9vqR4P.js";
24
- import { D as markDispatchFailed, E as markDispatchCompleted, O as markDispatchRunning, S as isTerminalDispatchStatus, T as markDispatchBlocked, a as resolveTurnSessionRouting, b as getDispatchTurnId, c as getPersistedThreadState, d as coerceThreadConversationState, g as getDispatchConversationId, i as resolveConversationRouting, l as persistThreadRuntimeState, m as confirmDispatchMailboxAppend, mt as readAutomationTitlesByConversationId, n as scheduleSessionCompletedPluginTasks, o as getLocationConfigurationService, p as claimDispatchMailboxAppend, s as getPersistedSandboxState, u as persistThreadStateById, v as getDispatchInputMessageId, w as markDispatchAwaitingResume, y as getDispatchRecord } from "./task-runner-CMiNGsER.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-EA98F0ia.js";
27
- import { a as withAgentInvocationResultActors, n as enqueueAgentInvocationResult, t as createChildConversationWorker } from "./result-CEqQFrEf.js";
28
- import { t as bindMessageAgent } from "./message-BFnIwKpx.js";
29
- import { r as readConversationLineage, t as bindSpawnAgent } from "./spawn-YeqlNDv8.js";
18
+ import { C as legacyWebMailboxMetadataSchema, b as resolveMailboxTurnWork, l as withoutSavedSteeringMessages, n as loadReviewItemInput, o as buildSteeringPiMessage, p as isExperimentalFeatureEnabled, r as savedInputInstruction } from "./prompt-input-Dxn8cDC0.js";
19
+ import { C as dropOwnUnreadLoopReplies, E as stopChildAgentsOf, T as stopChildAgentsBelow, c as listConversationWork, l as readLastUserMessageAtByConversation, s as isConversationWorkDone } from "./warmup-Bskrwmk1.js";
20
+ import { l as getVercelConversationWorkQueue, w as getTurnRequestDeadline } from "./background-compaction-queue-CwfJy3Cd.js";
21
+ import { c as conversationSubtreeColumns, o as skipInputAfterConversationStop, r as markConversationsStopped, s as conversationSubtree } from "./session-stop-B-I1rAS1.js";
22
+ import { T as getChildAgentLabel, a as ConversationTurnBoundaryError, c as TurnInputDeferredError, d as isTurnInputCommitLostError, f as isTurnInputDeferredError, g as startActiveTurn, h as markTurnFailed, i as getTurnUserSlackMessageTs, l as getConversationTurnBoundaryError, m as markTurnCompleted, mt as buildDeterministicTurnId, o as CooperativeTurnYieldError, p as markTurnClosed, pt as buildDeterministicAssistantMessageId, r as getTurnUserReplyAttachmentContext, s as TurnInputCommitLostError, t as getTurnUserMessage, u as isCooperativeTurnYieldError, v as getTurnLifecycle } from "./turn-user-message-ygLG3ylQ.js";
23
+ import { S as sendSlackReply, T as recordFinishedTurnForAutomatedLimit, x as resolveSlackReplyTarget, y as maybePostAutomatedTurnLimitNotice } from "./notification-gusCgdQ6.js";
24
+ import { E as stopConversationWork, T as steerWebPendingMessages, _ as getConversationWorkState, a as cancelHumanFacingPendingMessages, g as getConversation, h as ensureConversationWake, r as appendAndEnqueueInboundMessage, s as claimInboundMessage } from "./store-B59rOYbS.js";
25
+ import { a as getPersistedThreadState, c as coerceThreadConversationState, i as getPersistedSandboxState, n as resolveTurnSessionRouting, o as persistThreadRuntimeState, r as getLocationConfigurationService, s as persistThreadStateById, t as resolveConversationRouting } from "./turn-session-routing-BlCtVFRN.js";
26
+ import { a as isEmptyUserInputAnswer, o as normalizeUserInputAnswer } from "./user-input-request-CXNIov9n.js";
27
+ import { a as AgentRunError, i as supersedeTurnForInput, o as executeTurn, t as cancelSignInWait } from "./turn-cancel-DDu8TOwt.js";
28
+ import { a as getTurnAuthorization, c as getWebAuthorization, i as wakePausedTurn, n as getPausedTurnRequest, t as createPausedTurns } from "./turn-wake-DmQec4AG.js";
29
+ import { n as canShareTurn, t as canJoinTurn } from "./attempt-selection-ClP3MMPr.js";
30
+ import { p as webMessageId } from "./reporting-window-DopzcOHh.js";
31
+ import { D as readAutomationTitlesByConversationId, _ as markDispatchRunning, a as getDispatchConversationId, c as getDispatchRecord, d as isTerminalDispatchStatus, g as markDispatchFailed, h as markDispatchCompleted, l as getDispatchTurnId, m as markDispatchBlocked, n as claimDispatchMailboxAppend, p as markDispatchAwaitingResume, r as confirmDispatchMailboxAppend, s as getDispatchInputMessageId } from "./store-m5bmdmsP.js";
32
+ import { l as conversationPendingMessagesReportSchema, n as conversationFeedSchema, p as healthReportSchema, t as conversationFeedBriefSchema } from "./conversation-feed-BSMlGZnS.js";
33
+ import { i as enqueueAgentInvocationResult, n as createDeliverToParent, s as withAgentInvocationResultActors, t as createChildConversationWorker } from "./result-CAujiaci.js";
34
+ import { a as withTurnSpan, i as turnInputTelemetry, n as createConversationTurnWorker, o as canPauseConversationDelivery, r as getTurnInputSpanAttributes } from "./conversation-turn-CZWBr091.js";
35
+ import { t as bindMessageAgent } from "./message-BOZEIuxy.js";
36
+ import { r as readConversationLineage, t as bindSpawnAgent } from "./spawn-CwMjRRtn.js";
37
+ import { n as scheduleSessionCompletedPluginTasks } from "./task-runner-COOwR8qm.js";
38
+ import { a as requireTurnFailureEventId, c as buildDeliveredTurnStatePatch, i as getAgentTurnDiagnosticsAttributes, l as loadPendingMessageCards, n as loadThreadContextTrimFloor, o as completeAuthPauseTurn, r as finalizeFailedTurnReplyWithEvent, s as persistAuthPauseTurnState, t as buildTurnThreadContext } from "./thread-context-Cd44z_W5.js";
30
39
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
31
40
  import * as z from "zod";
32
- import { and, asc, count, desc, eq, gt, inArray, isNotNull, isNull, lte, max, ne, or, sql } from "drizzle-orm";
41
+ import { and, asc, count, desc, eq, gt, inArray, isNotNull, isNull, lte, ne, or, sql } from "drizzle-orm";
33
42
  import { conversationSidebarAnnotationSchema, createSlackSource, objectTypeSchema } from "@sentry/junior-plugin-api";
34
43
  import { alias } from "drizzle-orm/pg-core";
35
44
  import { Message, ThreadImpl, stringifyMarkdown } from "chat";
@@ -102,16 +111,27 @@ async function enqueueAgentDispatch(dispatch, options) {
102
111
  const nowMs = options.nowMs ?? Date.now();
103
112
  const claimedDispatch = await claimDispatchMailboxAppend(dispatch.id);
104
113
  if (!claimedDispatch) return;
105
- await (options.conversationStore ?? getConversationStore()).recordActivity({
114
+ const conversationStore = options.conversationStore ?? getConversationStore();
115
+ const conversationId = getDispatchConversationId(claimedDispatch);
116
+ const destination = claimedDispatch.destination;
117
+ await conversationStore.recordActivity({
106
118
  activityAtMs: claimedDispatch.createdAtMs,
107
- conversationId: getDispatchConversationId(claimedDispatch),
108
- destination: claimedDispatch.destination,
119
+ conversationId,
120
+ destination,
109
121
  kind: isAutomationRun(claimedDispatch) ? "automation" : "root",
110
122
  nowMs,
111
123
  source: "plugin",
112
124
  sessionSource: claimedDispatch.source,
113
125
  ...claimedDispatch.title ? { title: claimedDispatch.title } : void 0
114
126
  });
127
+ if (destination.platform === "slack" && destination.threadTs) await conversationStore.claimProviderConversation({
128
+ atMs: nowMs,
129
+ conversationId,
130
+ provider: "slack",
131
+ providerDestinationId: destination.channelId,
132
+ providerTenantId: destination.teamId,
133
+ providerConversationId: destination.threadTs
134
+ });
115
135
  await appendAndEnqueueInboundMessage({
116
136
  message: buildAgentDispatchInboundMessage(claimedDispatch, nowMs, await resolveActorIdentityId(getSqlExecutor(), claimedDispatch.actor)),
117
137
  conversationStore: options.conversationStore,
@@ -1701,6 +1721,7 @@ async function stopConversation(args) {
1701
1721
  nowMs: stoppedAtMs,
1702
1722
  state: args.state
1703
1723
  });
1724
+ await dropOwnUnreadLoopReplies(args.conversationId, args.state);
1704
1725
  await cancelSignInWait(args.conversationId);
1705
1726
  const result = await stopConversationWork({
1706
1727
  conversationId: args.conversationId,
@@ -4746,7 +4767,7 @@ function createSlackTurn(deps) {
4746
4767
  slackMessageTs.push(...messageIds);
4747
4768
  messageDestinations.push(...messageIds.map((messageId) => ({
4748
4769
  destination: outcome.destination,
4749
- messageId
4770
+ messageId: outcome.destination.threadTs ?? messageId
4750
4771
  })));
4751
4772
  }
4752
4773
  else {
@@ -6777,16 +6798,20 @@ function createConversationWork(options) {
6777
6798
  queue: options.queue,
6778
6799
  state: options.state
6779
6800
  });
6801
+ const conversationTurnWorker = createConversationTurnWorker(options.agentRunner, createSlackSystemTurnDelivery({
6802
+ getSlackAdapter: options.getSlackAdapter,
6803
+ state: options.state
6804
+ }), createDeliverToParent({
6805
+ queue: options.queue,
6806
+ state: options.state
6807
+ }));
6780
6808
  const childWorker = createChildConversationWorker(options.agentRunner, {
6781
6809
  enqueueResult,
6782
6810
  maxAgentDepth: botConfig.maxAgentDepth,
6783
6811
  queue: options.queue,
6812
+ runTurn: conversationTurnWorker,
6784
6813
  state: options.state
6785
6814
  });
6786
- const conversationTurnWorker = createConversationTurnWorker(options.agentRunner, createSlackSystemTurnDelivery({
6787
- getSlackAdapter: options.getSlackAdapter,
6788
- state: options.state
6789
- }));
6790
6815
  const destinationWorker = async (context) => {
6791
6816
  const destination = context.destination;
6792
6817
  if (!destination) throw new Error(`Conversation ${context.conversationId} is missing a destination`);
@@ -6812,16 +6837,7 @@ function createConversationWork(options) {
6812
6837
  if ("skipped" in stopped) return stopped.skipped;
6813
6838
  const { context } = stopped;
6814
6839
  const conversation = await options.conversationStore.get({ conversationId: context.conversationId });
6815
- if (conversation?.kind === "thread") {
6816
- const threadTurn = await resolveThreadTurnWork(context);
6817
- if (!threadTurn) return await childWorker(context);
6818
- if (threadTurn.kind === "mailbox") await endActiveAgentInvocations(context.conversationId, {
6819
- enqueueResult,
6820
- errorMessage: "A person sent a Message in this Thread, so this task ended without a result. Send messageAgent again if you still need this work."
6821
- });
6822
- return await conversationTurnWorker(context, threadTurn);
6823
- }
6824
- if (conversation?.parentConversationId) return await childWorker(context);
6840
+ if (!isTopLevelKind(conversation?.kind ?? "root")) return await childWorker(context);
6825
6841
  const readStopSignal = context.stopSignal;
6826
6842
  let stopSignal;
6827
6843
  const stopLateChildAgents = async () => {
@@ -8062,7 +8078,6 @@ function conversationSummaryFromStoredConversation(args) {
8062
8078
  const channelName = channelNameFromConversation(conversation, canViewPrivateContent, visibility);
8063
8079
  const channelNameRedacted = channelNameRedactedFromConversation(conversation, canViewPrivateContent);
8064
8080
  const status = statusFromConversation(conversation);
8065
- const unread = (status === "completed" || status === "stopped") && args.unreadReply === true;
8066
8081
  return {
8067
8082
  conversationId: conversation.conversationId,
8068
8083
  cumulativeDurationMs: durationMs,
@@ -8091,7 +8106,6 @@ function conversationSummaryFromStoredConversation(args) {
8091
8106
  archivedAt: conversation.archivedAtMs === void 0 ? null : new Date(conversation.archivedAtMs).toISOString(),
8092
8107
  pinnedAt: args.pinnedAtMs === void 0 ? null : new Date(args.pinnedAtMs).toISOString(),
8093
8108
  ...args.pinPosition === void 0 ? void 0 : { pinPosition: args.pinPosition },
8094
- ...unread ? { unread: true } : void 0,
8095
8109
  ...slackThread ? { channel: slackThread.channelId } : void 0,
8096
8110
  ...channelName ? { channelName } : void 0,
8097
8111
  ...channelNameRedacted ? { channelNameRedacted: true } : void 0,
@@ -8414,103 +8428,6 @@ async function readConversationForks(conversationId, links, readAccess) {
8414
8428
  } : void 0
8415
8429
  };
8416
8430
  }
8417
- // src/api/conversations/unread.ts
8418
- /**
8419
- * Junior's newest reply in the outer Conversation that the transcript shows
8420
- * as its own row. Quiet replies fold into activity, like tools and status
8421
- * events, so they do not count. It walks the message role index from the
8422
- * newest Message, so it stops at the first reply that is not quiet.
8423
- */
8424
- function latestVisibleReply(db, conversationId) {
8425
- return db.select({ seq: juniorConversationEvents.seq }).from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), eq(juniorConversationEvents.type, "message"), sql`${juniorConversationEvents.payload}->>'role' = 'assistant'`, sql`(${juniorConversationEvents.payload}->'meta'->>'quiet') is distinct from 'true'`)).orderBy(desc(juniorConversationEvents.createdAt), desc(juniorConversationEvents.seq)).limit(1);
8426
- }
8427
- /** The seq of the user's latest Message in the outer Conversation. */
8428
- function viewerMessageSeq(db, userId, conversationId) {
8429
- return db.select({ seq: max(juniorConversationEvents.seq) }).from(juniorConversationEvents).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversationEvents.actorIdentityId)).where(and(eq(juniorConversationEvents.conversationId, conversationId), eq(juniorConversationEvents.type, "message"), eq(juniorIdentities.userId, userId)));
8430
- }
8431
- /**
8432
- * Whether Junior's latest visible reply is after the viewer's read position
8433
- * in one outer Conversation. The position is at least the viewer's own
8434
- * latest Message. No reply reads as false.
8435
- */
8436
- function unreadReplySql(db, userId, conversationId, lastReadSeq) {
8437
- return sql`coalesce((${latestVisibleReply(db, conversationId)}) > greatest(coalesce(${lastReadSeq}, -1), coalesce((${viewerMessageSeq(db, userId, conversationId)}), -1)), false)`;
8438
- }
8439
- /**
8440
- * Return the Conversations that have a visible Junior reply after the
8441
- * user's read position. The position is at least the user's own latest
8442
- * Message, so a reply in Slack or the dashboard counts as read.
8443
- *
8444
- * A Conversation with no stored read position counts from its start. The
8445
- * read-position backfill migration gave each root in a user's feed a
8446
- * position at its last event, so only Conversations that start after it
8447
- * have none.
8448
- */
8449
- async function readUnreadConversationIds(db, conversationIds, userId) {
8450
- if (conversationIds.length === 0) return /* @__PURE__ */ new Set();
8451
- const rows = await db.select({ conversationId: juniorConversations.conversationId }).from(juniorConversations).leftJoin(juniorConversationReadPositions, and(eq(juniorConversationReadPositions.conversationId, juniorConversations.conversationId), eq(juniorConversationReadPositions.userId, userId))).where(and(inArray(juniorConversations.conversationId, [...conversationIds]), unreadReplySql(db, userId, juniorConversations.conversationId, juniorConversationReadPositions.lastReadSeq)));
8452
- return new Set(rows.map((row) => row.conversationId));
8453
- }
8454
- /**
8455
- * Store a read report and say whether Junior's latest visible reply is still
8456
- * unread, so the dashboard can clear its unread flag without a refetch.
8457
- *
8458
- * Only a viewer who may read the transcript can report: a participant, or
8459
- * anyone for a public Conversation. Others get the same 404 as a missing
8460
- * Conversation.
8461
- */
8462
- async function reportConversationRead(viewer, conversationId, body) {
8463
- if (!(await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId)?.canViewPrivateContent) throwApiError(404, "Conversation not found.");
8464
- const readPosition = await markConversationRead(viewer, conversationId, body);
8465
- const unread = await readUnreadConversationIds(getDb(), [conversationId], viewer.id);
8466
- return {
8467
- ...readPosition,
8468
- unreadReply: unread.has(conversationId)
8469
- };
8470
- }
8471
- /**
8472
- * Mark one Conversation read or unread for the signed-in viewer. Both write
8473
- * the read position of the root, which the feed reads.
8474
- *
8475
- * Read moves the position to the last event. Unread is the one write that
8476
- * moves it back: to just before Junior's latest visible reply, so the
8477
- * transcript shows that reply as new again. A reply at seq 0 has no seq
8478
- * before it, so unread removes the position and the Conversation counts from
8479
- * its start. The viewer's own latest Message also counts as read, so unread
8480
- * fails when that Message is after the reply.
8481
- */
8482
- async function markConversationUnread(viewer, conversationId, body) {
8483
- if (!(await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId)?.isParticipant) throwApiError(404, "Conversation not found.");
8484
- const rootConversationId = await resolveRootConversationId(getSqlExecutor(), conversationId);
8485
- if (!body.unread) {
8486
- await markConversationRead(viewer, rootConversationId, { lastReadSeq: Number.MAX_SAFE_INTEGER });
8487
- return { unreadReply: false };
8488
- }
8489
- const db = getDb();
8490
- const reply = latestVisibleReply(db, juniorConversations.conversationId).as("latest_visible_reply");
8491
- const [row] = await db.select({
8492
- replySeq: reply.seq,
8493
- viewerSeq: sql`(${viewerMessageSeq(db, viewer.id, juniorConversations.conversationId)})`
8494
- }).from(juniorConversations).innerJoinLateral(reply, sql`true`).where(eq(juniorConversations.conversationId, rootConversationId));
8495
- if (!row || row.viewerSeq !== null && row.viewerSeq >= row.replySeq) throwApiError(409, "Conversation has no reply after your last message.");
8496
- if (row.replySeq === 0) {
8497
- await db.delete(juniorConversationReadPositions).where(and(eq(juniorConversationReadPositions.userId, viewer.id), eq(juniorConversationReadPositions.conversationId, rootConversationId)));
8498
- return { unreadReply: true };
8499
- }
8500
- await db.insert(juniorConversationReadPositions).values({
8501
- conversationId: rootConversationId,
8502
- lastReadSeq: row.replySeq - 1,
8503
- updatedAt: /* @__PURE__ */ new Date(),
8504
- userId: viewer.id
8505
- }).onConflictDoUpdate({
8506
- target: [juniorConversationReadPositions.userId, juniorConversationReadPositions.conversationId],
8507
- set: {
8508
- lastReadSeq: sql`excluded.last_read_seq`,
8509
- updatedAt: sql`excluded.updated_at`
8510
- }
8511
- });
8512
- return { unreadReply: true };
8513
- }
8514
8431
  // src/api/conversations/detail-etag.ts
8515
8432
  const detailViewer = alias(juniorUsers, "detail_viewer");
8516
8433
  const forkSource = alias(juniorConversations, "detail_fork_source");
@@ -8597,7 +8514,6 @@ async function readDetailStateRow(conversationId, viewer) {
8597
8514
  pinnedAt: juniorConversationParticipants.pinnedAt,
8598
8515
  pinPosition: juniorConversationParticipants.pinPosition,
8599
8516
  rootConversationId,
8600
- unreadReply: viewer ? unreadReplySql(db, viewer.id, rootConversationId, sql`(${db.select({ seq: juniorConversationReadPositions.lastReadSeq }).from(juniorConversationReadPositions).where(and(eq(juniorConversationReadPositions.userId, viewer.id), eq(juniorConversationReadPositions.conversationId, rootConversationId)))})`) : sql`false`,
8601
8517
  unsubscribedAt: juniorConversationParticipants.unsubscribedAt,
8602
8518
  version: sql`(${conversationVersionQuery(db, conversationId, viewer?.id)})`
8603
8519
  }).from(juniorConversations).leftJoin(juniorDestinations, conversationRecordJoins.location).leftJoin(juniorIdentities, conversationRecordJoins.identity).leftJoin(juniorUsers, conversationRecordJoins.user).leftJoin(forkSource, eq(forkSource.conversationId, juniorConversations.forkedFromConversationId)).leftJoin(juniorConversationParticipants, viewerParticipant).leftJoin(detailViewer, viewer ? eq(detailViewer.id, viewer.id) : sql`false`).where(eq(juniorConversations.conversationId, conversationId));
@@ -8634,7 +8550,6 @@ async function readDetailState(conversationId, viewer, readAccess) {
8634
8550
  ...row?.lastReadSeq != null ? { readPosition: { lastReadSeq: row.lastReadSeq } } : void 0,
8635
8551
  ...viewer ? { subscribed: !row?.unsubscribedAt } : void 0,
8636
8552
  transcriptVersion,
8637
- ...viewer && row ? { unreadReply: row.unreadReply } : void 0,
8638
8553
  ...viewerMarks ? { viewerMarks } : void 0
8639
8554
  },
8640
8555
  version: row?.version ?? void 0
@@ -8678,7 +8593,6 @@ async function readConversationDetailEtag(conversationId, options) {
8678
8593
  limit: options.limit ?? null,
8679
8594
  subscribed: state.subscribed ?? null,
8680
8595
  version,
8681
- unreadReply: state.unreadReply ?? false,
8682
8596
  viewerMarks: state.viewerMarks ?? null
8683
8597
  });
8684
8598
  return {
@@ -9061,7 +8975,6 @@ function projectConversationDetail(args) {
9061
8975
  ...conversationSummaryFromStoredConversation({
9062
8976
  access: args.access,
9063
8977
  pinnedAtMs: args.pinnedAtMs,
9064
- unreadReply: args.unreadReply,
9065
8978
  automationTitle: args.automationTitle,
9066
8979
  auxiliaryCosts: args.auxiliaryCosts,
9067
8980
  ...args.childAgentTotals ? { childAgentTotals: args.childAgentTotals } : void 0,
@@ -9193,7 +9106,6 @@ async function readConversationDetailFromSql(conversationId, options) {
9193
9106
  transcript: state.transcriptVersion
9194
9107
  }) },
9195
9108
  ...state.viewerMarks,
9196
- unreadReply: state.unreadReply,
9197
9109
  automationTitle: automationTitleByConversation.get(conversationId),
9198
9110
  annotations,
9199
9111
  sidebarAnnotations,
@@ -9585,14 +9497,11 @@ const feedAnnotated = alias(juniorConversations, "feed_annotated");
9585
9497
  * token holds its minute. The end of the Turn moves the status.
9586
9498
  * The rows are in feed order, so a move that reorders them moves the token.
9587
9499
  * The newest Message of each role stands for the preview and participants.
9588
- * The row shows only whether a reply is unread, so a scroll that moves the
9589
- * read position does not move the token.
9590
9500
  * Threads and annotations show from the whole tree. Waiting roots outside
9591
9501
  * the page move the Review items token.
9592
9502
  */
9593
9503
  function conversationFeedVersionQuery(db, userId) {
9594
9504
  const pin = juniorConversationParticipants;
9595
- const read = juniorConversationReadPositions;
9596
9505
  const conversationId = juniorConversations.conversationId;
9597
9506
  const tree = db.select({ version: sql`concat_ws(':',
9598
9507
  count(*) filter (where ${feedTree.archivedAt} is not null),
@@ -9617,10 +9526,9 @@ function conversationFeedVersionQuery(db, userId) {
9617
9526
  activity: shownActivityMinute(juniorConversations.executionStatus, juniorConversations.lastActivityAt).as("activity"),
9618
9527
  assistantSeq: sql`(${latestMessageSeqQuery(db, "assistant", conversationId)})`.as("assistant_seq"),
9619
9528
  userSeq: sql`(${latestMessageSeqQuery(db, "user", conversationId)})`.as("user_seq"),
9620
- unread: unreadReplySql(db, userId, conversationId, read.lastReadSeq).as("unread"),
9621
9529
  threads: sql`(${tree})`.as("threads"),
9622
9530
  annotations: sql`(${annotations})`.as("annotations")
9623
- }).from(juniorConversations).leftJoin(pin, and(eq(pin.rootConversationId, conversationId), eq(pin.userId, userId))).leftJoin(read, and(eq(read.conversationId, conversationId), eq(read.userId, userId))).where(and(listedConversation(), conversationFeedMembershipFilter("active", {
9531
+ }).from(juniorConversations).leftJoin(pin, and(eq(pin.rootConversationId, conversationId), eq(pin.userId, userId))).where(and(listedConversation(), conversationFeedMembershipFilter("active", {
9624
9532
  kind: "viewer",
9625
9533
  userId
9626
9534
  }))).orderBy(desc(isNotNull(pin.pinnedAt)), desc(juniorConversations.lastActivityAt), asc(conversationId)).limit(CONVERSATION_FEED_LIMIT).as("feed_page");
@@ -9632,7 +9540,6 @@ function conversationFeedVersionQuery(db, userId) {
9632
9540
  status: byRow(page.executionStatus, page.stoppedAt),
9633
9541
  activity: byRow(page.activity),
9634
9542
  messages: byRow(page.assistantSeq, page.userSeq),
9635
- unread: byRow(page.unread),
9636
9543
  threads: byRow(page.threads),
9637
9544
  annotations: byRow(page.annotations)
9638
9545
  };
@@ -9678,7 +9585,7 @@ async function readConversationFeedFromSql(options = {}) {
9678
9585
  if (filter?.kind === "viewer" && status === "active") rows.push(...await waitingRowsOutsidePage(db, filter, rows));
9679
9586
  const conversations = rows.map((row) => conversationFromRecordRow(row));
9680
9587
  const conversationIds = conversations.map((conversation) => conversation.conversationId);
9681
- const [accessByConversation, viewerMarksByConversation, annotationsByConversation, auxiliaryCostsByRoot, metricsByRoot, participantsByConversation, teamDomainByTeamId, { work: conversationWork, lastUserMessageAt: lastUserMessageAtByConversation }, activityPreviewByConversation, briefByConversation, automationTitleByConversation, firstHumanMessageTextByConversation, unreadConversationIds] = await Promise.all([
9588
+ const [accessByConversation, viewerMarksByConversation, annotationsByConversation, auxiliaryCostsByRoot, metricsByRoot, participantsByConversation, teamDomainByTeamId, { work: conversationWork, lastUserMessageAt: lastUserMessageAtByConversation }, activityPreviewByConversation, briefByConversation, automationTitleByConversation, firstHumanMessageTextByConversation] = await Promise.all([
9682
9589
  readConversationAccessFromSql(db, conversationIds, options.viewer),
9683
9590
  conversationViewerMarks(db, conversationIds, filter ? feedMember(filter) : void 0),
9684
9591
  listConversationAnnotationsById(db, conversationIds),
@@ -9693,8 +9600,7 @@ async function readConversationFeedFromSql(options = {}) {
9693
9600
  readConversationActivityPreviews(db, conversationIds),
9694
9601
  readConversationFeedBriefs(db, conversationIds),
9695
9602
  readAutomationTitlesByConversationId(conversations),
9696
- readFirstHumanMessageTexts(db, conversations),
9697
- filter?.kind === "viewer" ? readUnreadConversationIds(db, conversationIds, filter.userId) : /* @__PURE__ */ new Set()
9603
+ readFirstHumanMessageTexts(db, conversations)
9698
9604
  ]);
9699
9605
  const visibleActivityPreviews = await attachActivityPreviewMentions(getSqlExecutor(), new Map([...activityPreviewByConversation].filter(([conversationId]) => accessByConversation.get(conversationId)?.canViewPrivateContent)));
9700
9606
  const visibleAnnotationsByConversation = new Map(conversationIds.map((conversationId) => [conversationId, accessByConversation.get(conversationId)?.canViewPrivateContent ? annotationsByConversation.get(conversationId) ?? [] : []]));
@@ -9713,7 +9619,6 @@ async function readConversationFeedFromSql(options = {}) {
9713
9619
  const childAgentTotals = childAgentTotalsReport(metrics, auxiliaryCosts);
9714
9620
  const summary = conversationSummaryFromStoredConversation({
9715
9621
  ...viewerMarksByConversation.get(conversation.conversationId),
9716
- unreadReply: unreadConversationIds.has(conversation.conversationId),
9717
9622
  automationTitle: automationTitleByConversation.get(conversation.conversationId),
9718
9623
  conversation,
9719
9624
  access,
@@ -9841,4 +9746,4 @@ function viewerWebMessages(messages, viewer) {
9841
9746
  }] : [];
9842
9747
  });
9843
9748
  }
9844
- export { actOnReviewItem as $, createProductionConversationWorkOptions as A, clearSlackPendingReactions as B, createConversationForViewer as C, readConversationPendingMessages as D, cancelConversationPendingMessagesForViewer as E, isAllowedSignInEmail as F, createSlackWebApiStatusSender as G, stripLeadingBotMention as H, readEnvList as I, stopConversation as J, SubscribedReplyReason as K, resolveAllowedDomains as L, getProductionSlackAdapter as M, assertNoLegacyAllowedDomains as N, requireConversationPendingMessages as O, isAllowedDomain as P, ReviewItemActionError as Q, startProcessingReaction as R, appendConversationMessageForViewer as S, encodeConversationCursor as T, normalizeIncomingSlackThreadId as U, slackInboundMessageId as V, withNormalizedThreadId as W, recordSkippedConversationMessage as X, parseContent as Y, bindMessageAuthorIdentityId as Z, keepQuickQuestionForViewer as _, pinConversation as a, continueConversationInSlack as at, conversationSummaryFromStoredConversation as b, readConversationParticipants as c, archiveViewerDoneConversations as ct, readConversationTreeMetricsFromSql as d, setConversationAutoArchive as dt, closeReviewItemsAnsweredByReply as et, conversationVersionQuery as f, updateUserAutoArchiveSettings as ft, forkConversationForViewer as g, readHealthReport as gt, reportConversationRead as h, GET as ht, readConversationFeed as i, canContinueInSlack as it, createProductionSlackWebhookServices as j, resolveMentions as k, readConversationAuxiliaryCostsFromSql as l, readUserAutoArchiveSettings as lt, markConversationUnread as m, enqueueAgentDispatch as mt, steerConversationPendingMessagesForViewer as n, reviewItemChange as nt, reorderPinnedConversations as o, isMovableToSlack as ot, readConversationDetailEtag as p, AGENT_DISPATCH_MAX_AGE_MS as pt, getThreadStopDecision as q, conversationFeedVersionQuery as r, alreadyContinuesInSlackMessage as rt, readConversationDetail as s, DEFAULT_AUTO_ARCHIVE_SETTINGS as st, stopConversationTurnForViewer as t, readReviewItemForUser as tt, childAgentTotalsReport as u, runAutoArchiveSweep as ut, readConversationEvents as v, decodeConversationCursor as w, readFirstHumanMessageTexts as x, readConversationRecordFromSql as y, buildSlackInboundMessage as z };
9749
+ export { reviewItemChange as $, assertNoLegacyAllowedDomains as A, normalizeIncomingSlackThreadId as B, cancelConversationPendingMessagesForViewer as C, createProductionConversationWorkOptions as D, resolveMentions as E, startProcessingReaction as F, stopConversation as G, createSlackWebApiStatusSender as H, buildSlackInboundMessage as I, bindMessageAuthorIdentityId as J, parseContent as K, clearSlackPendingReactions as L, isAllowedSignInEmail as M, readEnvList as N, createProductionSlackWebhookServices as O, resolveAllowedDomains as P, readReviewItemForUser as Q, slackInboundMessageId as R, encodeConversationCursor as S, requireConversationPendingMessages as T, SubscribedReplyReason as U, withNormalizedThreadId as V, getThreadStopDecision as W, actOnReviewItem as X, ReviewItemActionError as Y, closeReviewItemsAnsweredByReply as Z, conversationSummaryFromStoredConversation as _, pinConversation as a, archiveViewerDoneConversations as at, createConversationForViewer as b, readConversationAuxiliaryCostsFromSql as c, setConversationAutoArchive as ct, conversationVersionQuery as d, enqueueAgentDispatch as dt, alreadyContinuesInSlackMessage as et, readConversationDetailEtag as f, GET as ft, readConversationRecordFromSql as g, readConversationEvents as h, readConversationFeed as i, DEFAULT_AUTO_ARCHIVE_SETTINGS as it, isAllowedDomain as j, getProductionSlackAdapter as k, childAgentTotalsReport as l, updateUserAutoArchiveSettings as lt, keepQuickQuestionForViewer as m, steerConversationPendingMessagesForViewer as n, continueConversationInSlack as nt, reorderPinnedConversations as o, readUserAutoArchiveSettings as ot, forkConversationForViewer as p, readHealthReport as pt, recordSkippedConversationMessage as q, conversationFeedVersionQuery as r, isMovableToSlack as rt, readConversationDetail as s, runAutoArchiveSweep as st, stopConversationTurnForViewer as t, canContinueInSlack as tt, readConversationTreeMetricsFromSql as u, AGENT_DISPATCH_MAX_AGE_MS as ut, readFirstHumanMessageTexts as v, readConversationPendingMessages as w, decodeConversationCursor as x, appendConversationMessageForViewer as y, stripLeadingBotMention as z };
@@ -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-B6VS7kbo.js";
2
- import { a as getConversationStore } from "./db-C1M1y-bh.js";
3
- import "./background-compaction-queue-Cre1wFt9.js";
1
+ import { Bt as requestAnotherSlice$1, Ct as deadLetterAttempt$1, Dt as getConversationWorkState$1, Et as getConversation$1, Ht as startConversationWork$1, It as recordAttemptFailure$1, Lt as recordConversationRetry$1, Mt as listActiveConversationIds$1, Nt as markConversationWorkEnqueued$1, Rt as releaseConversationWork$1, Tt as dropPendingMessages$1, Ut as steerWebPendingMessages$1, Vt as requestConversationWork$1, Wt as stopConversationWork$1, _t as claimInboundMessage$1, bt as completeConversationStop$1, dt as ackMessages$1, ft as appendExclusiveInboundMessage, gt as checkInConversationWork$1, ht as cancelHumanFacingPendingMessages$1, kt as hasRunnableConversationWork, 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 releaseInboundMessage } from "./projection-B08mfi0u.js";
2
+ import { a as getConversationStore } from "./db-Br0tfAo7.js";
3
+ import "./background-compaction-queue-CwfJy3Cd.js";
4
4
  // src/chat/task-execution/store.ts
5
5
  function metadataStore(options) {
6
6
  return options.conversationStore ?? getConversationStore();
@@ -169,6 +169,7 @@ async function appendAndEnqueueInboundMessage(args) {
169
169
  appendResult: await appendInboundMessage({
170
170
  message: args.message,
171
171
  nowMs,
172
+ renderText: args.renderText,
172
173
  state: args.state
173
174
  }),
174
175
  nowMs
@@ -255,6 +256,12 @@ async function cancelHumanFacingPendingMessages(args) {
255
256
  if (result.cancelledInboundMessageIds.length > 0) await recordExecutionMetadata(args);
256
257
  return result;
257
258
  }
259
+ /** Drop pending mailbox rows by id without requiring a worker lease. */
260
+ async function dropPendingMessages(args) {
261
+ const dropped = await dropPendingMessages$1(args);
262
+ if (dropped.length > 0) await recordExecutionMetadata(args);
263
+ return dropped;
264
+ }
258
265
  /** Mark one author's queued web messages as interrupts. */
259
266
  async function steerWebPendingMessages(args) {
260
267
  return await steerWebPendingMessages$1(args);
@@ -305,4 +312,4 @@ async function clearExpiredConversationLease(args) {
305
312
  async function listActiveConversationIds(args = {}) {
306
313
  return await listActiveConversationIds$1(args);
307
314
  }
308
- export { startConversationWork as C, requestConversationWork as S, stopConversationWork as T, listActiveConversationIds as _, cancelHumanFacingPendingMessages as a, releaseConversationWork as b, clearConsumedConversationWake as c, completeConversationWork as d, deadLetterAttempt as f, getConversationWorkState as g, getConversation as h, beginConversationResume as i, clearExpiredConversationLease as l, ensureConversationWake as m, appendAndEnqueueExclusiveInboundMessage as n, checkInConversationWork as o, drainConversationMailbox as p, appendAndEnqueueInboundMessage as r, claimInboundMessage as s, ackMessages as t, completeConversationStop as u, recordAttemptFailure as v, steerWebPendingMessages as w, requestAnotherSlice as x, recordConversationRetry as y };
315
+ export { requestConversationWork as C, stopConversationWork as E, requestAnotherSlice as S, steerWebPendingMessages as T, getConversationWorkState as _, cancelHumanFacingPendingMessages as a, recordConversationRetry as b, clearConsumedConversationWake as c, completeConversationWork as d, deadLetterAttempt as f, getConversation as g, ensureConversationWake as h, beginConversationResume as i, clearExpiredConversationLease as l, dropPendingMessages as m, appendAndEnqueueExclusiveInboundMessage as n, checkInConversationWork as o, drainConversationMailbox as p, appendAndEnqueueInboundMessage as r, claimInboundMessage as s, ackMessages as t, completeConversationStop as u, listActiveConversationIds as v, startConversationWork as w, releaseConversationWork as x, recordAttemptFailure as y };