@sentry/junior 0.295.0 → 0.296.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/{admin-ifgjyfpF.js → admin-z_lgDi-z.js} +2 -2
  2. package/dist/{agent-runner-DjMTPWEO.js → agent-runner-HoQiUKLL.js} +194 -132
  3. package/dist/api/schema.d.ts +1 -1
  4. package/dist/api/schema.js +1 -1
  5. package/dist/api.d.ts +1 -1
  6. package/dist/api.js +294 -328
  7. package/dist/{app-uiTzRbvq.d.ts → app-C75Ft-A_.d.ts} +2 -2
  8. package/dist/app.d.ts +1 -1
  9. package/dist/app.js +26 -26
  10. package/dist/{background-compaction-queue-DUkHZjmL.js → background-compaction-queue-Cre1wFt9.js} +4 -4
  11. package/dist/{briefs-CbNYM-q2.js → briefs-BXECHduJ.js} +2 -2
  12. package/dist/{catalog-runtime-DgouZKZm.js → catalog-runtime-CpCmlD9L.js} +1 -1
  13. package/dist/cli/chat.js +14 -14
  14. package/dist/cli/check.js +3 -3
  15. package/dist/cli/main.js +3 -3
  16. package/dist/cli/plugins.js +4 -4
  17. package/dist/cli/snapshot-create.js +4 -4
  18. package/dist/cli/upgrade.d.ts +1 -1
  19. package/dist/cli/upgrade.js +3 -3
  20. package/dist/{config-DvnTPCfp.js → config-CCPHvTqx.js} +18 -2
  21. package/dist/{connections-CWaIVl_1.js → connections-B5pWh8e2.js} +6 -6
  22. package/dist/{conversation-privacy-DPjv4SnA.js → conversation-privacy-CZD5soDW.js} +1 -1
  23. package/dist/{credential-sync-BhbaZfmO.js → credential-sync-DwLkIvXI.js} +13 -13
  24. package/dist/{db-CCUqQe0E.d.ts → db-B3iyr_Or.d.ts} +1 -1
  25. package/dist/{db-Dts2XvLu.js → db-C1M1y-bh.js} +17 -23
  26. package/dist/{executor-Ck73J0wP.js → executor-DUSEwXaO.js} +10 -4
  27. package/dist/instrumentation.js +19 -2
  28. package/dist/{logging-9OAq-fdg.js → logging-D0svFM8r.js} +1 -1
  29. package/dist/{message-CtaPzC7m.js → message-BFnIwKpx.js} +9 -9
  30. package/dist/nitro.d.ts +1 -1
  31. package/dist/nitro.js +2 -2
  32. package/dist/{oauth-callback-server-C_LXY1d4.js → oauth-callback-server-BXRtD6Fk.js} +2 -2
  33. package/dist/{projection-BzJQncZV.js → projection-B6VS7kbo.js} +156 -49
  34. package/dist/{prompt-Cbq5b4SO.js → prompt-CD11tfG8.js} +3 -3
  35. package/dist/{registry-cbpOxO4M.js → registry-CHewwYEo.js} +1 -1
  36. package/dist/{resolve-t-pmRdwS.js → resolve-1owMH4qo.js} +3 -3
  37. package/dist/{result-DhgjR3nQ.js → result-CEqQFrEf.js} +8 -8
  38. package/dist/{runner-CHv9X9TH.js → runner-BtWvJslp.js} +7 -7
  39. package/dist/{sandbox-egress-signals-Yy3fSCbg.js → sandbox-egress-signals-ByftwJVt.js} +1 -1
  40. package/dist/{schema-TSEisVJR.d.ts → schema-Ct1Zf2xy.d.ts} +16 -0
  41. package/dist/{schema-BhneuGYv.js → schema-D2iGyYIp.js} +11 -0
  42. package/dist/{service-account-C4rBP8ne.js → service-account-BZEuMKdo.js} +3 -3
  43. package/dist/{service-account-DjPIwCMj.js → service-account-DLoeoHww.js} +3 -3
  44. package/dist/{session-stop-DkxI5vc3.js → session-stop-hYNTNpVf.js} +14 -14
  45. package/dist/{skills-BZE2DP8I.js → skills-DXgd5Inh.js} +3 -3
  46. package/dist/{spawn-BvULxIiu.js → spawn-YeqlNDv8.js} +5 -5
  47. package/dist/{state-CO9ETDzk.js → state-C3CbtD_m.js} +2 -2
  48. package/dist/{stop-CL-rdtQb.js → stop-Cze_pEL8.js} +288 -246
  49. package/dist/{store-DgD78_NK.js → store-CZ9vqR4P.js} +3 -3
  50. package/dist/{task-runner-CKOj6xla.js → task-runner-CMiNGsER.js} +274 -250
  51. package/dist/{turn-failure-response-BTSo6SMJ.js → turn-failure-response-pXhZ2wMK.js} +11 -8
  52. package/dist/{validation-CXeYgBzq.js → validation-Du7NdkOR.js} +1 -1
  53. package/dist/{version-AQa7Fr2H.js → version-EN3Wnq-R.js} +1 -1
  54. package/dist/version.js +1 -1
  55. package/dist/{viewer-Bqkb678l.js → viewer-Agxi_o5c.js} +3 -3
  56. package/dist/{warmup-h6u1e9n0.js → warmup-CY2ArYag.js} +251 -103
  57. package/dist/{work-yN_GAuXY.js → work-EA98F0ia.js} +11 -11
  58. package/dist/{worker-Hl7N292I.js → worker-BALVdWbv.js} +6 -6
  59. package/migrations/0101_drop_legacy_columns.sql +12 -0
  60. package/migrations/meta/0101_snapshot.json +4496 -0
  61. package/migrations/meta/_journal.json +7 -0
  62. package/package.json +5 -4
@@ -1,32 +1,32 @@
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-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";
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";
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-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";
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";
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-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";
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";
13
13
  import { r as acquireActiveLock } from "./locks-D-0h111u.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";
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
16
  import { U as readMessageAttachments, d as conversationEventPageSchema, l as conversationDetailReportSchema } from "./conversation-CMkSmi02.js";
17
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";
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
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-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";
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
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";
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";
30
30
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
31
31
  import * as z from "zod";
32
32
  import { and, asc, count, desc, eq, gt, inArray, isNotNull, isNull, lte, max, ne, or, sql } from "drizzle-orm";
@@ -4232,6 +4232,32 @@ async function maybeApplyProviderDefaultConfigRequest(args) {
4232
4232
  });
4233
4233
  return { text: `Default GitHub repo set to \`${repo}\`.` };
4234
4234
  }
4235
+ // src/chat/automation-result.ts
4236
+ /**
4237
+ * Return the text to post after a run ends, if any. A chat Turn already
4238
+ * delivered a successful reply, so it posts only its failure reply. An
4239
+ * Automation run posts only its `reply` text. It never posts a failure
4240
+ * reply to its outcomes. The failed execution shows on the Automation.
4241
+ */
4242
+ function finishedRunReply(result, dispatch) {
4243
+ if (!dispatch?.declaresResult) return result.diagnostics.outcome === "success" ? void 0 : result.text;
4244
+ return result.diagnostics.outcome === "success" && dispatch.outcomes?.length !== 0 ? result.reply?.text : void 0;
4245
+ }
4246
+ /**
4247
+ * Map one finished agent run to its dispatch outcome. A blocked report
4248
+ * becomes a blocked dispatch with the reported reason.
4249
+ */
4250
+ function runDispatchOutcome(result) {
4251
+ if (result.diagnostics.outcome !== "success") return {
4252
+ errorMessage: result.diagnostics.errorMessage ?? `Agent turn ended with ${result.diagnostics.outcome}.`,
4253
+ outcome: "failed"
4254
+ };
4255
+ if (result.blocked) return {
4256
+ errorMessage: result.blocked.missing,
4257
+ outcome: "blocked"
4258
+ };
4259
+ return { outcome: "completed" };
4260
+ }
4235
4261
  // src/chat/providers/slack/input.ts
4236
4262
  /** Return the actor stored with one inbound Slack message. */
4237
4263
  function inboundMessageActor(queued) {
@@ -7619,21 +7645,18 @@ async function copyForkEvents(args) {
7619
7645
  } else if ((row.type === "message_updated" || row.type === "message_handled") && messageIds.has(row.messageId) || (row.type === "turn_completed" || row.type === "turn_failed") && turnIds.has(row.turnId)) seqs.push(row.seq);
7620
7646
  }
7621
7647
  if (!seqs.length) return;
7622
- await getSqlExecutor().db().execute(sql`insert into ${e} (${sql.join([
7623
- e.conversationId,
7624
- e.seq,
7625
- e.historyVersion,
7626
- e.schemaVersion,
7627
- e.idempotencyKey,
7628
- e.type,
7629
- e.payload,
7630
- e.actorIdentityId,
7631
- e.createdAt
7632
- ].map((column) => sql.identifier(column.name)), sql`, `)})
7633
- select ${args.conversationId}, ${e.seq}, least(${e.historyVersion}, ${historyVersion}), ${e.schemaVersion}, ${e.idempotencyKey}, ${e.type}, ${e.payload}, ${e.actorIdentityId}, ${e.createdAt}
7634
- from ${e}
7635
- where ${e.conversationId} = ${args.sourceConversationId}
7636
- and ${inArray(e.seq, seqs)}`);
7648
+ const db = getSqlExecutor().db();
7649
+ await db.insert(e).select(db.select({
7650
+ conversationId: sql`${args.conversationId}`.as("conversation_id"),
7651
+ seq: e.seq,
7652
+ historyVersion: sql`least(${e.historyVersion}, ${historyVersion})`.as("history_version"),
7653
+ schemaVersion: e.schemaVersion,
7654
+ idempotencyKey: e.idempotencyKey,
7655
+ type: e.type,
7656
+ payload: e.payload,
7657
+ actorIdentityId: e.actorIdentityId,
7658
+ createdAt: e.createdAt
7659
+ }).from(e).where(and(eq(e.conversationId, args.sourceConversationId), inArray(e.seq, seqs))));
7637
7660
  }
7638
7661
  function hasUnfinishedToolCalls(messages) {
7639
7662
  const pending = /* @__PURE__ */ new Set();
@@ -7909,146 +7932,6 @@ async function readFirstHumanMessageTexts(db, conversations) {
7909
7932
  }).from(juniorConversationEvents).where(and(inArray(juniorConversationEvents.conversationId, untitledIds), eq(juniorConversationEvents.type, "message"), sql`${juniorConversationEvents.payload}->>'role' = 'user'`, sql`coalesce(${juniorConversationEvents.payload}->'meta'->'author'->>'isBot', 'false') <> 'true'`, isNotNull(sql`nullif(btrim(${text}), '')`))).orderBy(juniorConversationEvents.conversationId, asc(juniorConversationEvents.createdAt), asc(juniorConversationEvents.seq));
7910
7933
  return new Map(rows.map((row) => [row.conversationId, row.text]));
7911
7934
  }
7912
- // src/api/conversations/mentions.ts
7913
- /** Text in one event that the dashboard renders with mentions. */
7914
- function eventMentionTexts(data) {
7915
- switch (data.type) {
7916
- case "message": return data.redacted ? [] : [
7917
- data.text,
7918
- data.trustedSummary,
7919
- ...(data.events ?? []).map((event) => event.trustedSummary)
7920
- ];
7921
- case "assistant_message": return data.parts.map((part) => part.text);
7922
- case "compaction": return [data.summary];
7923
- case "structured_event": return [data.presentation.preview, ...(data.presentation.details ?? []).map((detail) => detail.description)];
7924
- default: return [];
7925
- }
7926
- }
7927
- function briefMentionTexts(brief) {
7928
- return [
7929
- brief.summary,
7930
- brief.intent,
7931
- brief.outcome.text,
7932
- ...brief.decisions.flatMap((decision) => [decision.text, decision.by]),
7933
- ...brief.facts
7934
- ];
7935
- }
7936
- function withMentions(value, mentions) {
7937
- return mentions.length > 0 ? {
7938
- ...value,
7939
- mentions
7940
- } : value;
7941
- }
7942
- /**
7943
- * Attach the people that each event and the Brief of one conversation
7944
- * mention, resolved at read time.
7945
- */
7946
- async function attachConversationMentions(executor, conversationId, content) {
7947
- const tenantId = (await loadConversationSlackTenantIds(executor, [conversationId])).get(conversationId);
7948
- const sources = content.events.map((event) => ({
7949
- tenantId,
7950
- texts: eventMentionTexts(event.data)
7951
- }));
7952
- if (content.brief) sources.push({
7953
- tenantId,
7954
- texts: briefMentionTexts(content.brief)
7955
- });
7956
- const mentions = await resolveMentions(executor, sources);
7957
- return {
7958
- briefMentions: content.brief ? mentions.at(-1) : [],
7959
- events: content.events.map((event, index) => withMentions(event, mentions[index]))
7960
- };
7961
- }
7962
- /** Attach the people that each activity preview mentions, resolved at read time. */
7963
- async function attachActivityPreviewMentions(executor, previews) {
7964
- const entries = [...previews];
7965
- const tenants = await loadConversationSlackTenantIds(executor, entries.map(([conversationId]) => conversationId));
7966
- const mentions = await resolveMentions(executor, entries.map(([conversationId, preview]) => ({
7967
- tenantId: tenants.get(conversationId),
7968
- texts: [preview.text]
7969
- })));
7970
- return new Map(entries.map(([conversationId, preview], index) => [conversationId, withMentions(preview, mentions[index])]));
7971
- }
7972
- // src/api/conversations/record.ts
7973
- /** The columns of one Conversation record, for `selectConversationRecords`. */
7974
- const conversationRecordColumns = {
7975
- conversation: juniorConversations,
7976
- location: juniorDestinations,
7977
- identityDisplayName: juniorIdentities.displayName,
7978
- identityEmail: juniorIdentities.email,
7979
- identityHandle: juniorIdentities.handle,
7980
- identityProvider: juniorIdentities.provider,
7981
- identitySubjectId: juniorIdentities.providerSubjectId,
7982
- identityTenantId: juniorIdentities.providerTenantId,
7983
- userDisplayName: juniorUsers.displayName
7984
- };
7985
- /** Left-join conditions from a Conversation to its record tables. */
7986
- const conversationRecordJoins = {
7987
- location: eq(juniorDestinations.id, juniorConversations.destinationId),
7988
- identity: eq(juniorIdentities.id, juniorConversations.actorIdentityId),
7989
- user: eq(juniorUsers.id, juniorIdentities.userId)
7990
- };
7991
- /**
7992
- * Select Conversation rows with their Location and Actor names. Callers add
7993
- * the filter, order, and limit.
7994
- */
7995
- function selectConversationRecords(db) {
7996
- return db.select(conversationRecordColumns).from(juniorConversations).leftJoin(juniorDestinations, conversationRecordJoins.location).leftJoin(juniorIdentities, conversationRecordJoins.identity).leftJoin(juniorUsers, conversationRecordJoins.user);
7997
- }
7998
- /** Decode a conversation row with the linked user name and identity-scoped provider fields. */
7999
- function conversationFromRecordRow(row) {
8000
- const value = row.conversation;
8001
- const legacySessionSource = value.sessionSource === null ? void 0 : parseSessionSource(value.sessionSource);
8002
- if (value.sessionSource !== null && !legacySessionSource) throw new Error("Conversation legacy source_json is invalid");
8003
- const actorFullName = row.userDisplayName?.trim() ? row.userDisplayName : row.identityDisplayName;
8004
- const actor = row.identityProvider === "slack" ? {
8005
- platform: "slack",
8006
- ...row.identityEmail ? { email: row.identityEmail } : void 0,
8007
- ...actorFullName ? { fullName: actorFullName } : void 0,
8008
- ...row.identitySubjectId ? { slackUserId: row.identitySubjectId } : void 0,
8009
- ...row.identityHandle ? { slackUserName: row.identityHandle } : void 0,
8010
- ...row.identityTenantId ? { teamId: row.identityTenantId } : void 0
8011
- } : void 0;
8012
- const location = locationFromRow(value.location, row.location, legacySessionSource);
8013
- return {
8014
- schemaVersion: 1,
8015
- conversationId: value.conversationId,
8016
- createdAtMs: value.createdAt.getTime(),
8017
- kind: conversationKindFromRow(value),
8018
- lastActivityAtMs: value.lastActivityAt.getTime(),
8019
- updatedAtMs: value.updatedAt.getTime(),
8020
- execution: {
8021
- status: value.executionStatus,
8022
- ...value.runId ? { runId: value.runId } : void 0,
8023
- ...value.executionUpdatedAt ? { updatedAtMs: value.executionUpdatedAt.getTime() } : void 0
8024
- },
8025
- ...value.parentConversationId ? { parentConversationId: value.parentConversationId } : void 0,
8026
- ...value.archivedAt ? { archivedAtMs: value.archivedAt.getTime() } : void 0,
8027
- ...actor ? { actor } : void 0,
8028
- ...location ? { location } : void 0,
8029
- ...value.channelName ? { channelName: value.channelName } : void 0,
8030
- ...value.source ? { source: value.source } : void 0,
8031
- ...value.title ? { title: value.title } : void 0,
8032
- ...value.transcriptPurgedAt ? { transcriptPurgedAtMs: value.transcriptPurgedAt.getTime() } : void 0,
8033
- ...value.stoppedAt ? { stoppedAtMs: value.stoppedAt.getTime() } : void 0,
8034
- ...value.deliveryPausedAt ? { deliveryPausedAtMs: value.deliveryPausedAt.getTime() } : void 0
8035
- };
8036
- }
8037
- /** Decode one `selectConversationRecords` row into a Conversation record. */
8038
- function conversationRecordFromRow(row) {
8039
- return {
8040
- conversation: conversationFromRecordRow(row),
8041
- durationMs: row.conversation.durationMs,
8042
- ...row.location?.visibility === "public" ? { locationId: row.location.id } : void 0,
8043
- usage: row.conversation.usage,
8044
- rootConversationId: row.conversation.rootConversationId
8045
- };
8046
- }
8047
- /** Read one normalized conversation record directly from its SQL row. */
8048
- async function readConversationRecordFromSql(conversationId) {
8049
- const row = (await selectConversationRecords(getDb()).where(eq(juniorConversations.conversationId, conversationId)).limit(1))[0];
8050
- return row ? conversationRecordFromRow(row) : void 0;
8051
- }
8052
7935
  // src/api/conversations/shared.ts
8053
7936
  /** Format a Slack destination without exposing private channel names. */
8054
7937
  function slackStatsLocationLabel(input) {
@@ -8215,6 +8098,196 @@ function conversationSummaryFromStoredConversation(args) {
8215
8098
  ...args.locationId && !channelNameRedacted ? { locationId: args.locationId } : void 0
8216
8099
  };
8217
8100
  }
8101
+ // src/api/conversations/agent-tree.ts
8102
+ /** Name a child the viewer cannot read, or one with no agent label. */
8103
+ function childLabel(kind) {
8104
+ return kind === "thread" ? "Thread" : "Task";
8105
+ }
8106
+ /**
8107
+ * Read the agent tree of a child Conversation: its parent chain, root first,
8108
+ * with the child last. Returns undefined for a root Conversation. Each
8109
+ * Conversation has its own access check, so a viewer sees a label only where
8110
+ * they can see private content.
8111
+ */
8112
+ async function readConversationAgentTree(conversation, readAccess) {
8113
+ if (!conversation.parentConversationId) return;
8114
+ const lineage = (await readConversationLineage(conversation.conversationId)).slice(-16);
8115
+ if (lineage.length < 2) return;
8116
+ const ids = lineage.map((entry) => entry.conversationId);
8117
+ const kindById = new Map(lineage.map((entry) => [entry.conversationId, entry.kind]));
8118
+ const root = lineage[0].parentConversationId ? void 0 : await getConversationStore().get({ conversationId: ids[0] });
8119
+ const [access, automationTitleByConversation, firstHumanMessageTextByConversation] = await Promise.all([
8120
+ readAccess(ids),
8121
+ readAutomationTitlesByConversationId(root ? [root] : []),
8122
+ readFirstHumanMessageTexts(getDb(), root ? [root] : [])
8123
+ ]);
8124
+ return await Promise.all(ids.map(async (id) => {
8125
+ const itemAccess = access.get(id);
8126
+ if (root?.conversationId === id) return {
8127
+ conversationId: id,
8128
+ kind: "root",
8129
+ label: conversationSummaryFromStoredConversation({
8130
+ access: itemAccess,
8131
+ automationTitle: automationTitleByConversation.get(id),
8132
+ conversation: root,
8133
+ durationMs: 0,
8134
+ firstHumanMessageText: firstHumanMessageTextByConversation.get(id)
8135
+ }).displayTitle
8136
+ };
8137
+ const kind = kindById.get(id);
8138
+ if (!itemAccess?.canViewPrivateContent) return {
8139
+ conversationId: id,
8140
+ kind,
8141
+ label: childLabel(kind)
8142
+ };
8143
+ const agent = await getChildAgentLabel(id);
8144
+ return {
8145
+ conversationId: id,
8146
+ kind,
8147
+ label: agent?.title ?? agent?.agentName ?? childLabel(kind)
8148
+ };
8149
+ }));
8150
+ }
8151
+ // src/api/conversations/mentions.ts
8152
+ /** Text in one event that the dashboard renders with mentions. */
8153
+ function eventMentionTexts(data) {
8154
+ switch (data.type) {
8155
+ case "message": return data.redacted ? [] : [
8156
+ data.text,
8157
+ data.trustedSummary,
8158
+ ...(data.events ?? []).map((event) => event.trustedSummary)
8159
+ ];
8160
+ case "assistant_message": return data.parts.map((part) => part.text);
8161
+ case "compaction": return [data.summary];
8162
+ case "structured_event": return [data.presentation.preview, ...(data.presentation.details ?? []).map((detail) => detail.description)];
8163
+ default: return [];
8164
+ }
8165
+ }
8166
+ function briefMentionTexts(brief) {
8167
+ return [
8168
+ brief.summary,
8169
+ brief.intent,
8170
+ brief.outcome.text,
8171
+ ...brief.decisions.flatMap((decision) => [decision.text, decision.by]),
8172
+ ...brief.facts
8173
+ ];
8174
+ }
8175
+ function withMentions(value, mentions) {
8176
+ return mentions.length > 0 ? {
8177
+ ...value,
8178
+ mentions
8179
+ } : value;
8180
+ }
8181
+ /**
8182
+ * Attach the people that each event and the Brief of one conversation
8183
+ * mention, resolved at read time.
8184
+ */
8185
+ async function attachConversationMentions(executor, conversationId, content) {
8186
+ const tenantId = (await loadConversationSlackTenantIds(executor, [conversationId])).get(conversationId);
8187
+ const sources = content.events.map((event) => ({
8188
+ tenantId,
8189
+ texts: eventMentionTexts(event.data)
8190
+ }));
8191
+ if (content.brief) sources.push({
8192
+ tenantId,
8193
+ texts: briefMentionTexts(content.brief)
8194
+ });
8195
+ const mentions = await resolveMentions(executor, sources);
8196
+ return {
8197
+ briefMentions: content.brief ? mentions.at(-1) : [],
8198
+ events: content.events.map((event, index) => withMentions(event, mentions[index]))
8199
+ };
8200
+ }
8201
+ /** Attach the people that each activity preview mentions, resolved at read time. */
8202
+ async function attachActivityPreviewMentions(executor, previews) {
8203
+ const entries = [...previews];
8204
+ const tenants = await loadConversationSlackTenantIds(executor, entries.map(([conversationId]) => conversationId));
8205
+ const mentions = await resolveMentions(executor, entries.map(([conversationId, preview]) => ({
8206
+ tenantId: tenants.get(conversationId),
8207
+ texts: [preview.text]
8208
+ })));
8209
+ return new Map(entries.map(([conversationId, preview], index) => [conversationId, withMentions(preview, mentions[index])]));
8210
+ }
8211
+ // src/api/conversations/record.ts
8212
+ /** The columns of one Conversation record, for `selectConversationRecords`. */
8213
+ const conversationRecordColumns = {
8214
+ conversation: juniorConversations,
8215
+ location: juniorDestinations,
8216
+ identityDisplayName: juniorIdentities.displayName,
8217
+ identityEmail: juniorIdentities.email,
8218
+ identityHandle: juniorIdentities.handle,
8219
+ identityProvider: juniorIdentities.provider,
8220
+ identitySubjectId: juniorIdentities.providerSubjectId,
8221
+ identityTenantId: juniorIdentities.providerTenantId,
8222
+ userDisplayName: juniorUsers.displayName
8223
+ };
8224
+ /** Left-join conditions from a Conversation to its record tables. */
8225
+ const conversationRecordJoins = {
8226
+ location: eq(juniorDestinations.id, juniorConversations.destinationId),
8227
+ identity: eq(juniorIdentities.id, juniorConversations.actorIdentityId),
8228
+ user: eq(juniorUsers.id, juniorIdentities.userId)
8229
+ };
8230
+ /**
8231
+ * Select Conversation rows with their Location and Actor names. Callers add
8232
+ * the filter, order, and limit.
8233
+ */
8234
+ function selectConversationRecords(db) {
8235
+ return db.select(conversationRecordColumns).from(juniorConversations).leftJoin(juniorDestinations, conversationRecordJoins.location).leftJoin(juniorIdentities, conversationRecordJoins.identity).leftJoin(juniorUsers, conversationRecordJoins.user);
8236
+ }
8237
+ /** Decode a conversation row with the linked user name and identity-scoped provider fields. */
8238
+ function conversationFromRecordRow(row) {
8239
+ const value = row.conversation;
8240
+ const legacySessionSource = value.sessionSource === null ? void 0 : parseSessionSource(value.sessionSource);
8241
+ if (value.sessionSource !== null && !legacySessionSource) throw new Error("Conversation legacy source_json is invalid");
8242
+ const actorFullName = row.userDisplayName?.trim() ? row.userDisplayName : row.identityDisplayName;
8243
+ const actor = row.identityProvider === "slack" ? {
8244
+ platform: "slack",
8245
+ ...row.identityEmail ? { email: row.identityEmail } : void 0,
8246
+ ...actorFullName ? { fullName: actorFullName } : void 0,
8247
+ ...row.identitySubjectId ? { slackUserId: row.identitySubjectId } : void 0,
8248
+ ...row.identityHandle ? { slackUserName: row.identityHandle } : void 0,
8249
+ ...row.identityTenantId ? { teamId: row.identityTenantId } : void 0
8250
+ } : void 0;
8251
+ const location = locationFromRow(value.location, row.location, legacySessionSource);
8252
+ return {
8253
+ schemaVersion: 1,
8254
+ conversationId: value.conversationId,
8255
+ createdAtMs: value.createdAt.getTime(),
8256
+ kind: conversationKindFromRow(value),
8257
+ lastActivityAtMs: value.lastActivityAt.getTime(),
8258
+ updatedAtMs: value.updatedAt.getTime(),
8259
+ execution: {
8260
+ status: value.executionStatus,
8261
+ ...value.runId ? { runId: value.runId } : void 0,
8262
+ ...value.executionUpdatedAt ? { updatedAtMs: value.executionUpdatedAt.getTime() } : void 0
8263
+ },
8264
+ ...value.parentConversationId ? { parentConversationId: value.parentConversationId } : void 0,
8265
+ ...value.archivedAt ? { archivedAtMs: value.archivedAt.getTime() } : void 0,
8266
+ ...actor ? { actor } : void 0,
8267
+ ...location ? { location } : void 0,
8268
+ ...value.channelName ? { channelName: value.channelName } : void 0,
8269
+ ...value.source ? { source: value.source } : void 0,
8270
+ ...value.title ? { title: value.title } : void 0,
8271
+ ...value.transcriptPurgedAt ? { transcriptPurgedAtMs: value.transcriptPurgedAt.getTime() } : void 0,
8272
+ ...value.stoppedAt ? { stoppedAtMs: value.stoppedAt.getTime() } : void 0,
8273
+ ...value.deliveryPausedAt ? { deliveryPausedAtMs: value.deliveryPausedAt.getTime() } : void 0
8274
+ };
8275
+ }
8276
+ /** Decode one `selectConversationRecords` row into a Conversation record. */
8277
+ function conversationRecordFromRow(row) {
8278
+ return {
8279
+ conversation: conversationFromRecordRow(row),
8280
+ durationMs: row.conversation.durationMs,
8281
+ ...row.location?.visibility === "public" ? { locationId: row.location.id } : void 0,
8282
+ usage: row.conversation.usage,
8283
+ rootConversationId: row.conversation.rootConversationId
8284
+ };
8285
+ }
8286
+ /** Read one normalized conversation record directly from its SQL row. */
8287
+ async function readConversationRecordFromSql(conversationId) {
8288
+ const row = (await selectConversationRecords(getDb()).where(eq(juniorConversations.conversationId, conversationId)).limit(1))[0];
8289
+ return row ? conversationRecordFromRow(row) : void 0;
8290
+ }
8218
8291
  // src/api/conversations/event-list.ts
8219
8292
  /** Read one bounded page of reporting events before, after, or around a boundary. */
8220
8293
  async function readConversationEvents(conversationId, boundary, options = {}) {
@@ -8295,56 +8368,6 @@ async function conversationEventPageReport(executor, args) {
8295
8368
  generatedAt: (/* @__PURE__ */ new Date()).toISOString()
8296
8369
  };
8297
8370
  }
8298
- // src/api/conversations/agent-tree.ts
8299
- /** Name a child the viewer cannot read, or one with no agent label. */
8300
- function childLabel(kind) {
8301
- return kind === "thread" ? "Thread" : "Task";
8302
- }
8303
- /**
8304
- * Read the agent tree of a child Conversation: its parent chain, root first,
8305
- * with the child last. Returns undefined for a root Conversation. Each
8306
- * Conversation has its own access check, so a viewer sees a label only where
8307
- * they can see private content.
8308
- */
8309
- async function readConversationAgentTree(conversation, readAccess) {
8310
- if (!conversation.parentConversationId) return;
8311
- const lineage = (await readConversationLineage(conversation.conversationId)).slice(-16);
8312
- if (lineage.length < 2) return;
8313
- const ids = lineage.map((entry) => entry.conversationId);
8314
- const kindById = new Map(lineage.map((entry) => [entry.conversationId, entry.kind]));
8315
- const root = lineage[0].parentConversationId ? void 0 : await getConversationStore().get({ conversationId: ids[0] });
8316
- const [access, automationTitleByConversation, firstHumanMessageTextByConversation] = await Promise.all([
8317
- readAccess(ids),
8318
- readAutomationTitlesByConversationId(root ? [root] : []),
8319
- readFirstHumanMessageTexts(getDb(), root ? [root] : [])
8320
- ]);
8321
- return await Promise.all(ids.map(async (id) => {
8322
- const itemAccess = access.get(id);
8323
- if (root?.conversationId === id) return {
8324
- conversationId: id,
8325
- kind: "root",
8326
- label: conversationSummaryFromStoredConversation({
8327
- access: itemAccess,
8328
- automationTitle: automationTitleByConversation.get(id),
8329
- conversation: root,
8330
- durationMs: 0,
8331
- firstHumanMessageText: firstHumanMessageTextByConversation.get(id)
8332
- }).displayTitle
8333
- };
8334
- const kind = kindById.get(id);
8335
- if (!itemAccess?.canViewPrivateContent) return {
8336
- conversationId: id,
8337
- kind,
8338
- label: childLabel(kind)
8339
- };
8340
- const agent = await getChildAgentLabel(id);
8341
- return {
8342
- conversationId: id,
8343
- kind,
8344
- label: agent?.title ?? agent?.agentName ?? childLabel(kind)
8345
- };
8346
- }));
8347
- }
8348
8371
  // src/api/conversations/fork.ts
8349
8372
  /** Fork a Conversation that the viewer can read into a new root they own. */
8350
8373
  async function forkConversationForViewer(viewer, sourceConversationId, body) {
@@ -8492,6 +8515,18 @@ async function markConversationUnread(viewer, conversationId, body) {
8492
8515
  const detailViewer = alias(juniorUsers, "detail_viewer");
8493
8516
  const forkSource = alias(juniorConversations, "detail_fork_source");
8494
8517
  const fork = alias(juniorConversations, "detail_fork");
8518
+ const agentTreeRoot = alias(juniorConversations, "detail_agent_tree_root");
8519
+ /**
8520
+ * Return the root fields that label the agent tree of a child: its title and
8521
+ * channel name. The other labels cannot change once the child exists. An
8522
+ * agent invocation keeps its title and agent name after insert, and only the
8523
+ * spawn sets a title. Access to each node comes from the shared root, so the
8524
+ * viewer's access covers it. This keeps the recursive lineage read out of
8525
+ * every poll.
8526
+ */
8527
+ function agentTreeRootLabel(db, rootConversationId) {
8528
+ return db.select({ label: sql`row(${agentTreeRoot.title}, ${agentTreeRoot.channelName})::text` }).from(agentTreeRoot).where(eq(agentTreeRoot.conversationId, rootConversationId));
8529
+ }
8495
8530
  /**
8496
8531
  * Sum the detail versions of a Conversation and its child agents. Child
8497
8532
  * writes bump only their own row, and the row count changes when a child
@@ -8551,6 +8586,7 @@ async function readDetailStateRow(conversationId, viewer) {
8551
8586
  const viewerParticipant = viewer ? and(eq(juniorConversationParticipants.userId, viewer.id), eq(juniorConversationParticipants.rootConversationId, rootConversationId)) : sql`false`;
8552
8587
  const [row] = await db.select({
8553
8588
  ...conversationRecordColumns,
8589
+ agentTreeRootLabel: sql`case when ${juniorConversations.parentConversationId} is null then null else (${agentTreeRootLabel(db, rootConversationId)}) end`,
8554
8590
  attachmentsVersion: sql`(${slackAttachmentsVersionQuery(db, conversationId)})`,
8555
8591
  autoArchive: juniorConversationParticipants.autoArchive,
8556
8592
  autoArchiveDefault: detailViewer.autoArchiveDefault,
@@ -8569,7 +8605,7 @@ async function readDetailStateRow(conversationId, viewer) {
8569
8605
  }
8570
8606
  async function readDetailState(conversationId, viewer, readAccess) {
8571
8607
  const rowRead = readDetailStateRow(conversationId, viewer);
8572
- const [accessById, row, forks, agentTree] = await Promise.all([
8608
+ const [accessById, row, forks] = await Promise.all([
8573
8609
  readAccess([conversationId]),
8574
8610
  rowRead,
8575
8611
  rowRead.then((stored) => readConversationForks(conversationId, {
@@ -8579,10 +8615,6 @@ async function readDetailState(conversationId, viewer, readAccess) {
8579
8615
  title: stored.forkSourceTitle
8580
8616
  } } : void 0,
8581
8617
  isChild: Boolean(stored?.conversation.parentConversationId)
8582
- }, readAccess)),
8583
- rowRead.then((stored) => readConversationAgentTree({
8584
- conversationId,
8585
- ...stored?.conversation.parentConversationId ? { parentConversationId: stored.conversation.parentConversationId } : void 0
8586
8618
  }, readAccess))
8587
8619
  ]);
8588
8620
  const access = accessById.get(conversationId);
@@ -8593,10 +8625,10 @@ async function readDetailState(conversationId, viewer, readAccess) {
8593
8625
  })).digest("base64url");
8594
8626
  const viewerMarks = row ? viewerMarksFromParticipant(row) : void 0;
8595
8627
  return {
8628
+ agentTreeRootLabel: row?.agentTreeRootLabel ?? void 0,
8596
8629
  record: row ? conversationRecordFromRow(row) : void 0,
8597
8630
  state: {
8598
8631
  access,
8599
- agentTree,
8600
8632
  ...viewer ? { autoArchive: row?.autoArchive ?? row?.autoArchiveDefault ?? false } : void 0,
8601
8633
  forks,
8602
8634
  ...row?.lastReadSeq != null ? { readPosition: { lastReadSeq: row.lastReadSeq } } : void 0,
@@ -8635,11 +8667,11 @@ async function readConversationDetailState(conversationId, viewer, readAccess) {
8635
8667
  * change or a reload.
8636
8668
  */
8637
8669
  async function readConversationDetailEtag(conversationId, options) {
8638
- const { record, state, version } = await readDetailState(conversationId, options.viewer, options.readAccess);
8670
+ const { agentTreeRootLabel, record, state, version } = await readDetailState(conversationId, options.viewer, options.readAccess);
8639
8671
  if (!version) return void 0;
8640
8672
  const basis = JSON.stringify({
8641
8673
  access: state.access ?? null,
8642
- agentTree: state.agentTree ?? null,
8674
+ agentTree: agentTreeRootLabel ?? null,
8643
8675
  autoArchive: state.autoArchive ?? null,
8644
8676
  forks: state.forks,
8645
8677
  junior: JUNIOR_VERSION,
@@ -9071,7 +9103,8 @@ function projectConversationDetail(args) {
9071
9103
  };
9072
9104
  }
9073
9105
  async function readConversationDetailFromSql(conversationId, options) {
9074
- const { record, state } = options.stored ?? await readConversationDetailState(conversationId, options.viewer, createConversationAccessReader(getDb(), options.viewer));
9106
+ const readAccess = createConversationAccessReader(getDb(), options.viewer);
9107
+ const { record, state } = options.stored ?? await readConversationDetailState(conversationId, options.viewer, readAccess);
9075
9108
  if (!record) return void 0;
9076
9109
  const { access, readPosition } = state;
9077
9110
  const canExposePayload = access?.canViewPrivateContent ?? false;
@@ -9103,7 +9136,11 @@ async function readConversationDetailFromSql(conversationId, options) {
9103
9136
  limit: options.limit
9104
9137
  });
9105
9138
  };
9106
- const [annotations, automationTitleByConversation, auxiliaryCostsByConversation, briefVersion, firstHumanMessageTextByConversation, modelUsage, metricsByConversation, people, sourceTask, teamDomainByTeamId, page] = await Promise.all([
9139
+ const [agentTree, annotations, automationTitleByConversation, auxiliaryCostsByConversation, briefVersion, firstHumanMessageTextByConversation, modelUsage, metricsByConversation, people, sourceTask, teamDomainByTeamId, page] = await Promise.all([
9140
+ readConversationAgentTree({
9141
+ conversationId,
9142
+ ...record.conversation.parentConversationId ? { parentConversationId: record.conversation.parentConversationId } : void 0
9143
+ }, readAccess),
9107
9144
  listConversationAnnotations(getDb(), conversationId),
9108
9145
  readAutomationTitlesByConversationId([record.conversation]),
9109
9146
  readConversationAuxiliaryCostsFromSql(getDb(), [conversationId]),
@@ -9189,7 +9226,7 @@ async function readConversationDetailFromSql(conversationId, options) {
9189
9226
  return {
9190
9227
  ...report,
9191
9228
  ...state.forks,
9192
- ...state.agentTree ? { agentTree: state.agentTree } : void 0,
9229
+ ...agentTree ? { agentTree } : void 0,
9193
9230
  ...report.isParticipant && state.autoArchive !== void 0 ? { autoArchive: state.autoArchive } : void 0,
9194
9231
  ...report.isParticipant && state.subscribed !== void 0 ? { subscribed: state.subscribed } : void 0,
9195
9232
  ...canContinueInSlack(record.conversation, access) ? { canContinueInSlack: true } : void 0,
@@ -9520,9 +9557,17 @@ async function waitingRowsOutsidePage(db, filter, page) {
9520
9557
  status: "active"
9521
9558
  });
9522
9559
  }
9523
- /** Feed rows show last activity only as an age in whole minutes. */
9524
- function shownActivityMinute(lastActivityAt) {
9525
- return sql`date_trunc('minute', ${lastActivityAt})`;
9560
+ /**
9561
+ * Feed rows show last activity only as an age in whole minutes. A running
9562
+ * row shows its running state in place of the age, so it shows no activity.
9563
+ * Every status but `idle` and `failed` shows as running, as in
9564
+ * `statusFromConversation`.
9565
+ */
9566
+ function shownActivityMinute(executionStatus, lastActivityAt) {
9567
+ return sql`case
9568
+ when ${executionStatus} in ('idle', 'failed')
9569
+ then date_trunc('minute', ${lastActivityAt})
9570
+ end`;
9526
9571
  }
9527
9572
  const feedTree = alias(juniorConversations, "feed_tree");
9528
9573
  const feedAnnotated = alias(juniorConversations, "feed_annotated");
@@ -9554,7 +9599,7 @@ function conversationFeedVersionQuery(db, userId) {
9554
9599
  string_agg(concat_ws('/',
9555
9600
  ${feedTree.conversationId}, ${feedTree.title},
9556
9601
  ${feedTree.executionStatus}, ${feedTree.stoppedAt},
9557
- ${shownActivityMinute(feedTree.lastActivityAt)}
9602
+ ${shownActivityMinute(feedTree.executionStatus, feedTree.lastActivityAt)}
9558
9603
  ), ',' order by ${feedTree.conversationId}) filter (
9559
9604
  where ${feedTree.kind} = 'thread' and ${feedTree.archivedAt} is null
9560
9605
  )
@@ -9569,10 +9614,7 @@ function conversationFeedVersionQuery(db, userId) {
9569
9614
  pinPosition: pin.pinPosition,
9570
9615
  stoppedAt: juniorConversations.stoppedAt,
9571
9616
  title: juniorConversations.title,
9572
- activity: sql`case
9573
- when ${juniorConversations.executionStatus} in ('idle', 'failed')
9574
- then ${shownActivityMinute(juniorConversations.lastActivityAt)}
9575
- end`.as("activity"),
9617
+ activity: shownActivityMinute(juniorConversations.executionStatus, juniorConversations.lastActivityAt).as("activity"),
9576
9618
  assistantSeq: sql`(${latestMessageSeqQuery(db, "assistant", conversationId)})`.as("assistant_seq"),
9577
9619
  userSeq: sql`(${latestMessageSeqQuery(db, "user", conversationId)})`.as("user_seq"),
9578
9620
  unread: unreadReplySql(db, userId, conversationId, read.lastReadSeq).as("unread"),
@@ -9799,4 +9841,4 @@ function viewerWebMessages(messages, viewer) {
9799
9841
  }] : [];
9800
9842
  });
9801
9843
  }
9802
- 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, readConversationRecordFromSql 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, conversationSummaryFromStoredConversation as y, buildSlackInboundMessage as z };
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 };