@sentry/junior 0.284.0 → 0.286.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 (84) hide show
  1. package/dist/{adapter-CW5UW7vL.js → adapter-JQZaJ-B_.js} +37 -3
  2. package/dist/{admin-DUWN8zZX.js → admin-Dm2bimJ-.js} +1 -1
  3. package/dist/{agent-runner-Cqr21pOU.js → agent-runner-DGCwOEyL.js} +2180 -2735
  4. package/dist/api/schema.d.ts +2 -2
  5. package/dist/api/schema.js +8 -7
  6. package/dist/api.d.ts +1 -1
  7. package/dist/api.js +166 -90
  8. package/dist/{app-CvGalMxi.d.ts → app-BKq0JzWx.d.ts} +2 -3
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +225 -188
  11. package/dist/{assistant-reply-CFE-OZMS.js → assistant-reply-CAPafcUY.js} +1 -1
  12. package/dist/{automation-Zvx_I9Z5.js → automation-B-jJN_gM.js} +1 -1
  13. package/dist/{background-compaction-queue-CHFzrQbS.js → background-compaction-queue-Btu2oab_.js} +137 -3
  14. package/dist/{briefs-Cx7mkfSk.js → briefs-UMeYehUe.js} +5 -5
  15. package/dist/{catalog-runtime-dKOVbR7l.js → catalog-runtime-Bym8GVdh.js} +1 -1
  16. package/dist/cli/chat.js +19 -16
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/init.js +3 -0
  19. package/dist/cli/main.js +3 -3
  20. package/dist/cli/plugins.js +4 -4
  21. package/dist/cli/snapshot-create.js +5 -6
  22. package/dist/cli/upgrade.d.ts +1 -1
  23. package/dist/cli/upgrade.js +12 -17
  24. package/dist/{client-CMyH5rDz.js → client-B0aAs7wC.js} +2 -2
  25. package/dist/{config-Dt3CpG17.js → config-B9f9Lqo5.js} +1 -1
  26. package/dist/{connections-CCHPybZP.js → connections-CQ7p0aNJ.js} +16 -50
  27. package/dist/{conversation-DdT7SNar.js → conversation-BusI2uzj.js} +68 -7
  28. package/dist/{conversation-pending-messages-Dct5pheX.js → conversation-pending-messages-DwehU0Fd.js} +1 -1
  29. package/dist/{conversation-privacy-BpHHhEVp.js → conversation-privacy-Cd_nZZBM.js} +1 -1
  30. package/dist/{credential-sync-BBPw8dam.js → credential-sync-DmiJi_At.js} +13 -13
  31. package/dist/{db-D7CCwAo8.d.ts → db-C5zi4ecs.d.ts} +18 -2
  32. package/dist/{executor-CyIwHz9r.js → executor-Dipi2Ixl.js} +19 -17
  33. package/dist/instrumentation.js +2 -2
  34. package/dist/{logging-Qo-7xGp1.js → logging-CMFhLLj4.js} +1 -1
  35. package/dist/{media-Bu9C6lz0.js → media-B-BpXo41.js} +14 -2
  36. package/dist/{message-DFbtOWqv.js → message-D1xLljUF.js} +13 -23
  37. package/dist/nitro.d.ts +1 -1
  38. package/dist/nitro.js +2 -3
  39. package/dist/{oauth-callback-server-BB1gixWo.js → oauth-callback-server-DCAFIUQr.js} +2 -2
  40. package/dist/{projection-0UcUeuzn.js → projection-CoeMNxJ4.js} +545 -262
  41. package/dist/{prompt-CCtaGgbI.js → prompt-C9OQEfan.js} +8 -6
  42. package/dist/{registry-DOnPkI8g.js → registry-u-sFYtx_.js} +1 -1
  43. package/dist/{reporting-window-B-QP9zX1.js → reporting-window-B4TwyuJo.js} +14 -14
  44. package/dist/{resolve-Di3omymY.js → resolve-DYqgL3Eo.js} +3 -3
  45. package/dist/result-CescSwAw.js +299 -0
  46. package/dist/result-event-type-DD6BAgT7.js +11 -0
  47. package/dist/{runner-CnX_dTKw.js → runner-Cr67a8TB.js} +16 -12
  48. package/dist/{sandbox-egress-signals-CtxLJmmg.js → sandbox-egress-signals-DLOazy5W.js} +1 -1
  49. package/dist/{schema-Bn3miEd_.js → schema-BUSi3sgv.js} +63 -5
  50. package/dist/{schema-B017enNE.d.ts → schema-Ih60j59-.d.ts} +194 -220
  51. package/dist/{service-account-KhZIqXRi.js → service-account-CGEqz9wG.js} +3 -3
  52. package/dist/{service-account-ewDAx4Mx.js → service-account-CsKxktLk.js} +3 -3
  53. package/dist/session-stop-CGz5DByb.js +2926 -0
  54. package/dist/{skills-CKyotM4g.js → skills-COCqf61f.js} +2 -2
  55. package/dist/{spawn-D5D2MQdz.js → spawn-C8F_iXWO.js} +13 -2
  56. package/dist/{stop-BSKRTaRS.js → stop-GyFZkHuQ.js} +7730 -7818
  57. package/dist/{store-ymkEUWe4.js → store-D0-8plWp.js} +30 -5
  58. package/dist/{turn-session-routing-D_GXfcAG.js → task-runner-xPuQmEot.js} +1440 -994
  59. package/dist/{store-G3S0kWSD.js → turn-failure-response-BOviBdT-.js} +404 -311
  60. package/dist/{validation-DJG_wrg2.js → validation-DZDKorGz.js} +1 -1
  61. package/dist/{version-i1An1eTS.js → version-BTIz7fGi.js} +1 -1
  62. package/dist/version.js +1 -1
  63. package/dist/{viewer-BlpnzZZa.js → viewer-CH-ASQzh.js} +208 -68
  64. package/dist/{work-BgCW3FDC.js → work-C75_IM5e.js} +311 -100
  65. package/dist/{worker-BJz1mwYt.js → worker-Dl47I729.js} +6 -6
  66. package/migrations/0083_conversation_kind.sql +11 -0
  67. package/migrations/0084_read_position_backfill.sql +25 -0
  68. package/migrations/0085_child_archived_at.sql +1 -0
  69. package/migrations/0086_shared_archive.sql +31 -0
  70. package/migrations/0087_child_location.sql +64 -0
  71. package/migrations/meta/0083_snapshot.json +4388 -0
  72. package/migrations/meta/0084_snapshot.json +4388 -0
  73. package/migrations/meta/0085_snapshot.json +4394 -0
  74. package/migrations/meta/0086_snapshot.json +4366 -0
  75. package/migrations/meta/0087_snapshot.json +4366 -0
  76. package/migrations/meta/_journal.json +35 -0
  77. package/package.json +5 -4
  78. package/dist/result-NvndYzCb.js +0 -483
  79. package/dist/session-stop-D_1SysjC.js +0 -1438
  80. package/dist/task-queue-BcOHzXxe.js +0 -139
  81. package/dist/task-runner-B65cDumh.js +0 -290
  82. package/dist/thread-state-D6rNGQu9.js +0 -173
  83. package/dist/turn-failure-response-BlO4nuDJ.js +0 -224
  84. package/dist/turn-lifecycle-BQ8ETk63.js +0 -58
package/dist/api.js CHANGED
@@ -1,32 +1,32 @@
1
- import { $n as countReviewItemsNeedingUser, Co as createPluginCache, Gn as resolveNotificationTimezone, Ha as readConversationAccessFromSql, Jn as readNotificationSchedule, Kn as deletePushSubscription, Ln as getPlugins, Sa as workspaceRepoCheckoutPath, Sn as isExperimentalFeatureEnabled, Un as readWebPushConfig, Wn as sendPushNotificationToUser, Xn as savePushSubscription, Xr as getDashboardSettingsLink, Yn as saveNotificationSchedule, ar as listWaitingConversations, ci as updateWorkspace, eo as readConversationBriefThrough, hi as hash, ii as getWorkspace, li as WorkspaceValidationError, mi as create, ni as createWorkspace, no as readConversationEventPage, oi as listWorkspaces, or as searchReviewItems, pr as isOnlyAssignee, qn as listPushSubscriptions, ri as deleteWorkspace, si as listWorkspacesByRepository, ur as canActOnReviewItem, vr as reviewItemReaderForUser, wn as createUserTokenStore, ya as SANDBOX_RUNTIME, za as createPluginLogger } from "./projection-0UcUeuzn.js";
2
- import { a as completeText, m as escapeXml } from "./client-CMyH5rDz.js";
3
- import { n as botConfig, y as getAttachmentStorage } from "./config-Dt3CpG17.js";
4
- import { m as logInfo, p as logException } from "./logging-Qo-7xGp1.js";
5
- import { C as getSqlExecutor, S as getDb, c as readViewerAvatarUrl, d as updateViewerDisplayName, l as resolveViewerUser, m as readAvatarImage, t as findUserByEmail, x as getConversationStore } from "./viewer-BlpnzZZa.js";
6
- import { D as juniorCodeChanges, M as juniorIdentities, N as juniorUsers, O as juniorCodeRepositories, P as juniorDestinations, S as juniorConversationMetrics, T as juniorApiTokens, j as juniorConversations, w as juniorConversationEvents } from "./executor-CyIwHz9r.js";
7
- import { n as INPUT_IMAGE_TYPES, t as INLINE_VIDEO_TYPES } from "./media-Bu9C6lz0.js";
8
- import { n as pluginCatalogRuntime } from "./catalog-runtime-dKOVbR7l.js";
9
- import { $ as readViewerAutomations, Ct as listChildAgents, G as readViewerAutomationEdit, H as activateViewerAutomationVersion, K as updateViewerAutomation, Mt as saveUserCustomization, Q as readViewerAutomationVersions, S as createSlackReviewItemShow, U as changeViewerAutomationLifecycle, W as deleteViewerTask, X as readViewerAutomationRuns, Y as readViewerAutomationExecutions, Z as readViewerAutomationSummary, et as AutomationEditError, ft as webActorFromUser, gt as readLiveAttachment, h as readStats, jt as readUserCustomization, nt as listOwnedWatches, q as ViewerTaskNotFoundError } from "./agent-runner-Cqr21pOU.js";
10
- import { r as getStateAdapter } from "./adapter-CW5UW7vL.js";
1
+ import { $a as createConversationAccessReader, Cr as canActOnReviewItem, Di as create, Er as isOnlyAssignee, Fa as workspaceRepoCheckoutPath, In as createUserTokenStore, Ma as SANDBOX_RUNTIME, Mo as createPluginCache, Oi as hash, Pn as isExperimentalFeatureEnabled, Si as WorkspaceValidationError, Yn as getPlugins, Za as createPluginLogger, _i as getWorkspace, _r as listWaitingConversations, ar as listPushSubscriptions, bi as listWorkspacesByRepository, co as readConversationBriefThrough, cr as savePushSubscription, dr as countReviewItemsNeedingUser, eo as readConversationAccessFromSql, gi as deleteWorkspace, hi as createWorkspace, ir as deletePushSubscription, jr as reviewItemReaderForUser, li as getDashboardSettingsLink, nr as sendPushNotificationToUser, or as readNotificationSchedule, rr as resolveNotificationTimezone, sr as saveNotificationSchedule, tr as readWebPushConfig, uo as readConversationEventPage, vr as reviewItemsNeedingUserVersionQuery, xi as updateWorkspace, yi as listWorkspaces, yr as searchReviewItems } from "./projection-CoeMNxJ4.js";
2
+ import { a as completeText, m as escapeXml } from "./client-B0aAs7wC.js";
3
+ import { n as botConfig, y as getAttachmentStorage } from "./config-B9f9Lqo5.js";
4
+ import { m as logInfo, p as logException } from "./logging-CMFhLLj4.js";
5
+ import { C as getSqlExecutor, I as withConversationMutationLock, L as conversationKindFromRow, S as getDb, c as readViewerAvatarUrl, d as updateViewerDisplayName, et as nextDetailVersion, l as resolveViewerUser, m as readAvatarImage, t as findUserByEmail, x as getConversationStore } from "./viewer-CH-ASQzh.js";
6
+ import { A as juniorConversations, D as juniorCodeChanges, M as juniorUsers, N as juniorDestinations, O as juniorCodeRepositories, S as juniorConversationMetrics, T as juniorApiTokens, j as juniorIdentities, w as juniorConversationEvents } from "./executor-Dipi2Ixl.js";
7
+ import { n as INPUT_IMAGE_TYPES, t as INLINE_VIDEO_TYPES } from "./media-B-BpXo41.js";
8
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-Bym8GVdh.js";
9
+ import { $ as readViewerAutomationSummary, Bt as listChildAgents, G as changeViewerAutomationLifecycle, J as updateViewerAutomation, K as deleteViewerTask, Q as readViewerAutomationRuns, S as createSlackReviewItemShow, W as activateViewerAutomationVersion, Y as ViewerTaskNotFoundError, Z as readViewerAutomationExecutions, _t as readLiveAttachment, et as readViewerAutomationVersions, h as readStats, it as listOwnedWatches, mt as webActorFromUser, nt as AutomationEditError, q as readViewerAutomationEdit, tt as readViewerAutomations } from "./agent-runner-DGCwOEyL.js";
10
+ import { r as getStateAdapter } from "./adapter-JQZaJ-B_.js";
11
11
  import { r as notificationScheduleSchema } from "./schedule-BTp__wrw.js";
12
- import { C as createConversationMessageBodySchema, D as conversationReadPositionSchema, S as createConversationBodySchema, T as forkConversationResponseSchema, a as conversationAttachmentParamsSchema, c as conversationDetailReportSchema, d as conversationEventsQuerySchema, f as conversationFeedQuerySchema, m as conversationParamsSchema, n as acceptedConversationMessageSchema, p as conversationFeedSchema, s as conversationDetailQuerySchema, t as CONVERSATION_DETAIL_VERSION_HEADER, u as conversationEventPageSchema, w as forkConversationBodySchema } from "./conversation-DdT7SNar.js";
13
- import { n as briefEntriesFromReportEvents } from "./prompt-CCtaGgbI.js";
14
- import { d as getEventCatalog } from "./session-stop-D_1SysjC.js";
15
- import { T as userCustomizationSchema, a as fillUtcSixHours, c as trailingUtcDayWindow, d as utcDayKey, f as utcHourKey, i as fillUtcHours, l as trailingUtcHourWindow, n as HOUR_MS$1, o as startOfUtcHour, r as fillUtcDays, s as sumUtcHoursIntoSixHours, t as DAY_MS$1, u as trailingUtcSixHourWindow } from "./reporting-window-B-QP9zX1.js";
16
- import { s as getSandboxResources, t as getCachedSnapshot } from "./resolve-Di3omymY.js";
17
- import { l as getVercelConversationWorkQueue } from "./background-compaction-queue-CHFzrQbS.js";
18
- import { F as conversationRangeColumns, N as conversationActiveDaysColumn, P as conversationAggregateColumns, ct as AutomationConflictError, ft as automationEventCatalog, j as readAutomationTitlesByConversationId } from "./turn-session-routing-D_GXfcAG.js";
19
- import { n as finishServiceAccountSignIn, o as serviceAccountPlugins, r as getServiceAccountStatus, s as startServiceAccountSignIn, t as disconnectServiceAccount } from "./service-account-KhZIqXRi.js";
20
- import { N as ScheduleIntentError, P as compileScheduleIntent, _ as automationSummarySchema, b as automationVersionListSchema, c as automationLifecycleSchema, d as automationParamsSchema, f as automationRunListSchema, g as automationSchedulePreviewSchema, h as automationScheduleIntentSchema, i as automationExecutionListSchema, l as automationListQuerySchema, n as automationEditSchema, r as automationEventCatalogSchema, t as automationEditErrorSchema, u as automationListSchema, v as automationUpdateSchema, x as automationVersionParamsSchema, y as automationVersionActivateSchema } from "./automation-Zvx_I9Z5.js";
21
- import { c as conversationUnchangedDetailWithMailboxSchema, d as apiErrorSchema, f as healthReportSchema, l as steerConversationPendingMessagesBodySchema, n as cancelConversationPendingMessagesResponseSchema, p as pluginOperationalReportFeedSchema, r as conversationDetailWithMailboxReportSchema, s as conversationPendingMessagesReportSchema, t as cancelConversationPendingMessagesBodySchema, u as steerConversationPendingMessagesResponseSchema, v as pluginsSchema, x as skillReportsSchema, y as runtimeInfoReportSchema } from "./conversation-pending-messages-Dct5pheX.js";
22
- import { E as archiveConversation, N as isAllowedSignInEmail, Q as readReviewItemForUser, S as cancelConversationPendingMessagesForViewer, T as resolveMentions, X as actOnReviewItem, Y as ReviewItemActionError, _ as readFirstHumanMessageTexts, a as readConversationDetail, at as updateUserAutoArchiveSettings, c as forkConversationForViewer, ct as throwApiError, d as readConversationFeed, et as DEFAULT_AUTO_ARCHIVE_SETTINGS, ft as readHealthReport, g as conversationSummaryFromStoredConversation, h as readConversationTreeMetricsFromSql, i as reorderPinnedConversations, it as setConversationAutoArchive, k as getProductionSlackAdapter, l as keepQuickQuestionForViewer, m as childAgentTotalsReport, n as steerConversationPendingMessagesForViewer, nt as readUserAutoArchiveSettings, o as readConversationDetailEtag, ot as emptyResponse, p as readConversationAuxiliaryCostsFromSql, r as pinConversation, s as markConversationRead, st as jsonResponse, t as stopConversationTurnForViewer, tt as archiveViewerDoneConversations, u as readConversationEvents, v as appendConversationMessageForViewer, w as requireConversationPendingMessages, y as createConversationForViewer } from "./stop-BSKRTaRS.js";
23
- import { a as startConnection, n as isConnectableProvider, r as listConnections, t as disconnectConnection, u as htmlCallbackResponse } from "./connections-CCHPybZP.js";
24
- import { $ as codeOverviewReportSchema, A as avatarParamsSchema, C as createdPersonalTokenSchema, D as revokePersonalTokenResponseSchema, E as personalTokenParamsSchema, F as locationDirectoryReportSchema, G as connectionListSchema, H as pushSubscriptionBodySchema, I as locationParamsSchema, J as disconnectConnectionResponseSchema, K as connectionParamsSchema, L as activityDays$1, M as personalSpendReportSchema, O as actorDirectoryReportSchema, P as locationDetailReportSchema, R as activityHours$1, S as createPersonalTokenBodySchema, U as pushSubscriptionDeleteBodySchema, V as notificationSettingsSchema, W as testNotificationResponseSchema, Y as startConnectionResponseSchema, _ as disconnectServiceAccountResponseSchema, _t as reorderPinnedConversationsResponseSchema, a as workspaceBodySchema, at as conversationWatchesReportSchema, ct as stopConversationTurnResponseSchema, d as reviewItemCountSchema, dt as archiveConversationResponseSchema, et as codePersonReportSchema, f as reviewItemListQuerySchema, ft as archiveDoneConversationsResponseSchema, g as reviewItemWaitingConversationsSchema, gt as reorderPinnedConversationsBodySchema, h as reviewItemSchema, ht as pinConversationResponseSchema, i as deleteWorkspaceResponseSchema, j as personParamsSchema, k as actorProfileReportSchema, l as workspaceSchema, lt as conversationStatsReportSchema, m as reviewItemParamsSchema, mt as pinConversationBodySchema, n as statsReportSchema, nt as codeRepositoryReportSchema, o as workspaceListSchema, p as reviewItemListSchema, pt as conversationAutoArchiveSchema, s as workspaceParamsSchema, st as conversationChildAgentsReportSchema, tt as codeRepositoryParamsSchema, u as reviewItemActionSchema, ut as archiveConversationBodySchema, v as serviceAccountListSchema, vt as conversationCatchUpBodySchema, w as personalTokenListSchema, x as startServiceAccountSignInResponseSchema, y as serviceAccountParamsSchema, yt as conversationCatchUpSchema, z as activitySixHours$1 } from "./schema-Bn3miEd_.js";
12
+ import { C as createConversationBodySchema, E as forkConversationResponseSchema, O as conversationReadPositionSchema, T as forkConversationBodySchema, c as conversationDetailQuerySchema, d as conversationEventPageSchema, f as conversationEventsQuerySchema, h as conversationParamsSchema, k as conversationReadReportSchema, l as conversationDetailReportSchema, m as conversationFeedSchema, n as CONVERSATION_VERSION_HEADER, o as conversationAttachmentParamsSchema, p as conversationFeedQuerySchema, r as acceptedConversationMessageSchema, t as CONVERSATION_DETAIL_VERSION_HEADER, w as createConversationMessageBodySchema } from "./conversation-BusI2uzj.js";
13
+ import { n as briefEntriesFromReportEvents } from "./prompt-C9OQEfan.js";
14
+ import { O as getEventCatalog, et as readUserCustomization, tt as saveUserCustomization } from "./session-stop-CGz5DByb.js";
15
+ import { T as userCustomizationSchema, a as fillUtcSixHours, c as trailingUtcDayWindow, d as utcDayKey, f as utcHourKey, i as fillUtcHours, l as trailingUtcHourWindow, n as HOUR_MS$1, o as startOfUtcHour, r as fillUtcDays, s as sumUtcHoursIntoSixHours, t as DAY_MS$1, u as trailingUtcSixHourWindow } from "./reporting-window-B4TwyuJo.js";
16
+ import { s as getSandboxResources, t as getCachedSnapshot } from "./resolve-DYqgL3Eo.js";
17
+ import { _ as getVercelConversationWorkQueue } from "./background-compaction-queue-Btu2oab_.js";
18
+ import { J as AutomationConflictError, St as automationEventCatalog, dt as conversationRangeColumns, ft as conversationUsageCostExpr, lt as conversationActiveDaysColumn, st as readAutomationTitlesByConversationId, ut as conversationAggregateColumns } from "./task-runner-xPuQmEot.js";
19
+ import { n as finishServiceAccountSignIn, o as serviceAccountPlugins, r as getServiceAccountStatus, s as startServiceAccountSignIn, t as disconnectServiceAccount } from "./service-account-CGEqz9wG.js";
20
+ import { N as ScheduleIntentError, P as compileScheduleIntent, _ as automationSummarySchema, b as automationVersionListSchema, c as automationLifecycleSchema, d as automationParamsSchema, f as automationRunListSchema, g as automationSchedulePreviewSchema, h as automationScheduleIntentSchema, i as automationExecutionListSchema, l as automationListQuerySchema, n as automationEditSchema, r as automationEventCatalogSchema, t as automationEditErrorSchema, u as automationListSchema, v as automationUpdateSchema, x as automationVersionParamsSchema, y as automationVersionActivateSchema } from "./automation-B-jJN_gM.js";
21
+ import { c as conversationUnchangedDetailWithMailboxSchema, d as apiErrorSchema, f as healthReportSchema, l as steerConversationPendingMessagesBodySchema, n as cancelConversationPendingMessagesResponseSchema, p as pluginOperationalReportFeedSchema, r as conversationDetailWithMailboxReportSchema, s as conversationPendingMessagesReportSchema, t as cancelConversationPendingMessagesBodySchema, u as steerConversationPendingMessagesResponseSchema, v as pluginsSchema, x as skillReportsSchema, y as runtimeInfoReportSchema } from "./conversation-pending-messages-DwehU0Fd.js";
22
+ import { $ as actOnReviewItem, A as archiveConversation, C as createConversationForViewer, E as cancelConversationPendingMessagesForViewer, L as isAllowedSignInEmail, O as requireConversationPendingMessages, P as getProductionSlackAdapter, Q as ReviewItemActionError, S as appendConversationMessageForViewer, _ as keepQuickQuestionForViewer, a as pinConversation, at as readUserAutoArchiveSettings, c as continueConversationInSlackForViewer, ct as updateUserAutoArchiveSettings, d as readConversationTreeMetricsFromSql, dt as throwApiError, f as conversationVersionQuery, g as forkConversationForViewer, h as reportConversationRead, ht as readHealthReport, i as readConversationFeed, it as archiveViewerDoneConversations, k as resolveMentions, l as readConversationAuxiliaryCostsFromSql, lt as emptyResponse, m as markConversationUnread, n as steerConversationPendingMessagesForViewer, o as reorderPinnedConversations, p as readConversationDetailEtag, r as conversationFeedVersionQuery, rt as DEFAULT_AUTO_ARCHIVE_SETTINGS, s as readConversationDetail, st as setConversationAutoArchive, t as stopConversationTurnForViewer, tt as readReviewItemForUser, u as childAgentTotalsReport, ut as jsonResponse, v as readConversationEvents, x as readFirstHumanMessageTexts, y as conversationSummaryFromStoredConversation } from "./stop-GyFZkHuQ.js";
23
+ import { a as startConnection, n as isConnectableProvider, r as listConnections, s as htmlCallbackResponse, t as disconnectConnection } from "./connections-CQ7p0aNJ.js";
24
+ import { A as actorDirectoryReportSchema, B as activityHours$1, C as startServiceAccountSignInResponseSchema, Ct as pinConversationBodySchema, Dt as conversationCatchUpBodySchema, E as personalTokenListSchema, Et as reorderPinnedConversationsResponseSchema, G as pushSubscriptionDeleteBodySchema, I as locationDetailReportSchema, J as connectionParamsSchema, K as testNotificationResponseSchema, L as locationDirectoryReportSchema, M as avatarParamsSchema, N as personParamsSchema, O as personalTokenParamsSchema, Ot as conversationCatchUpSchema, P as personalSpendReportSchema, R as locationParamsSchema, St as markConversationUnreadBodySchema, T as createdPersonalTokenSchema, Tt as reorderPinnedConversationsBodySchema, U as notificationSettingsSchema, V as activitySixHours$1, W as pushSubscriptionBodySchema, X as disconnectConnectionResponseSchema, Z as startConnectionResponseSchema, _ as reviewItemSchema, _t as archiveConversationBodySchema, b as serviceAccountListSchema, bt as conversationAutoArchiveSchema, c as workspaceListSchema, d as workspaceSchema, dt as continueConversationInSlackResponseSchema, f as reviewItemActionSchema, ft as stopConversationTurnResponseSchema, g as reviewItemParamsSchema, gt as renameConversationResponseSchema, h as reviewItemListSchema, ht as renameConversationBodySchema, i as statsReportSchema, it as codeRepositoryReportSchema, j as actorProfileReportSchema, k as revokePersonalTokenResponseSchema, l as workspaceParamsSchema, lt as conversationChildAgentsReportSchema, m as reviewItemListQuerySchema, n as versionsSchema, nt as codePersonReportSchema, o as deleteWorkspaceResponseSchema, p as reviewItemCountSchema, pt as conversationStatsReportSchema, q as connectionListSchema, rt as codeRepositoryParamsSchema, s as workspaceBodySchema, st as conversationWatchesReportSchema, t as versionsQuerySchema, tt as codeOverviewReportSchema, ut as continueConversationInSlackBodySchema, v as reviewItemWaitingConversationsSchema, vt as archiveConversationResponseSchema, w as createPersonalTokenBodySchema, wt as pinConversationResponseSchema, x as serviceAccountParamsSchema, xt as conversationUnreadSchema, y as disconnectServiceAccountResponseSchema, yt as archiveDoneConversationsResponseSchema, z as activityDays$1 } from "./schema-BUSi3sgv.js";
25
25
  import { Hono } from "hono";
26
26
  import path from "node:path";
27
27
  import { createHash, randomBytes, randomUUID } from "node:crypto";
28
28
  import * as z from "zod";
29
- import { and, asc, desc, eq, gt, gte, isNull, lte, notExists, or, sql } from "drizzle-orm";
29
+ import { and, asc, desc, eq, gt, gte, inArray, isNull, lte, notExists, or, sql } from "drizzle-orm";
30
30
  import { pluginUserPageContentSchema, pluginUserPageCursorSchema, pluginUserPageFilterSchema, pluginUserPageLinksSchema, pluginUserPageQuerySchema } from "@sentry/junior-plugin-api";
31
31
  import { alias } from "drizzle-orm/pg-core";
32
32
  import { readFileSync } from "node:fs";
@@ -193,11 +193,56 @@ async function catchUpOnConversation(viewer, conversationId, range) {
193
193
  ...conversation.title ? { title: conversation.title } : void 0
194
194
  });
195
195
  }
196
+ // src/chat/conversations/sql/title.ts
197
+ /**
198
+ * Replace one Conversation's title. Returns the stored title, or undefined
199
+ * when the Conversation does not exist.
200
+ *
201
+ * recordActivity reads the title and writes it back under the mutation lock,
202
+ * so this write takes the same lock. A concurrent Turn cannot restore the old
203
+ * title.
204
+ */
205
+ async function setConversationTitle(executor, conversationId, title) {
206
+ return await withConversationMutationLock(executor, conversationId, async () => {
207
+ const [row] = await executor.db().update(juniorConversations).set({
208
+ detailVersion: nextDetailVersion,
209
+ title
210
+ }).where(eq(juniorConversations.conversationId, conversationId)).returning({ title: juniorConversations.title });
211
+ return row?.title ?? void 0;
212
+ });
213
+ }
214
+ // src/api/conversations/rename.ts
215
+ /**
216
+ * Rename one conversation. The title is shared, so only a participant can
217
+ * change it, the same as pin and archive. Automatic titles are set once, so a
218
+ * later Turn keeps this title.
219
+ */
220
+ async function renameConversation(viewer, conversationId, body) {
221
+ if (!(await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId)?.isParticipant) throwApiError(404, "Conversation not found.");
222
+ const title = await setConversationTitle(getSqlExecutor(), conversationId, body.title);
223
+ if (!title) throwApiError(404, "Conversation not found.");
224
+ return { title };
225
+ }
196
226
  // src/api/conversations/child-agents.ts
227
+ /** Read the kind and archive of each child Conversation. */
228
+ async function readChildKinds(db, childIds) {
229
+ if (childIds.length === 0) return /* @__PURE__ */ new Map();
230
+ const rows = await db.select({
231
+ conversationId: juniorConversations.conversationId,
232
+ kind: juniorConversations.kind,
233
+ archivedAt: juniorConversations.archivedAt,
234
+ parentConversationId: juniorConversations.parentConversationId
235
+ }).from(juniorConversations).where(inArray(juniorConversations.conversationId, [...childIds]));
236
+ return new Map(rows.map((row) => [row.conversationId, {
237
+ archivedAt: row.archivedAt?.toISOString() ?? null,
238
+ kind: conversationKindFromRow(row) === "thread" ? "thread" : "task"
239
+ }]));
240
+ }
197
241
  /**
198
242
  * Load the direct child agents of one Conversation, or throw a standard API
199
243
  * not-found error. Viewers who cannot see private content get only the status,
200
- * time, and usage of each child agent.
244
+ * time, and usage of each child agent. Archived children stay in the report,
245
+ * so the dashboard can show and restore them.
201
246
  */
202
247
  async function requireConversationChildAgents(conversationId, options = {}) {
203
248
  if (!await getConversationStore().get({ conversationId })) throwApiError(404, "Conversation not found.");
@@ -205,7 +250,11 @@ async function requireConversationChildAgents(conversationId, options = {}) {
205
250
  const [accessByConversation, children] = await Promise.all([readConversationAccessFromSql(db, [conversationId], options.viewer), listChildAgents(conversationId)]);
206
251
  const canExposePayload = accessByConversation.get(conversationId)?.canViewPrivateContent ?? false;
207
252
  const childIds = children.map((agent) => agent.childConversationId);
208
- const [metricsByChild, auxiliaryCostsByChild] = await Promise.all([readConversationTreeMetricsFromSql(db, childIds), readConversationAuxiliaryCostsFromSql(db, childIds)]);
253
+ const [metricsByChild, auxiliaryCostsByChild, kindByChild] = await Promise.all([
254
+ readConversationTreeMetricsFromSql(db, childIds),
255
+ readConversationAuxiliaryCostsFromSql(db, childIds),
256
+ readChildKinds(db, childIds)
257
+ ]);
209
258
  const agents = children.map((agent) => {
210
259
  const metrics = metricsByChild.get(agent.childConversationId);
211
260
  const auxiliaryCosts = auxiliaryCostsByChild.get(agent.childConversationId);
@@ -216,6 +265,10 @@ async function requireConversationChildAgents(conversationId, options = {}) {
216
265
  ...metrics?.usage ? { cumulativeUsage: metrics.usage } : void 0,
217
266
  ...auxiliaryCosts ? { auxiliaryCosts: auxiliaryCosts.total } : void 0,
218
267
  ...childAgentTotals ? { childAgentTotals } : void 0,
268
+ ...kindByChild.get(agent.childConversationId) ?? {
269
+ archivedAt: null,
270
+ kind: "task"
271
+ },
219
272
  status: agent.status,
220
273
  updatedAt: new Date(agent.updatedAtMs).toISOString(),
221
274
  ...canExposePayload ? {
@@ -747,6 +800,7 @@ function createConversationRoutes(options) {
747
800
  const { conversationId } = context.req.valid("param");
748
801
  return jsonResponse(stopConversationTurnResponseSchema, await stopConversationTurnForViewer(viewer, conversationId, options));
749
802
  });
803
+ app.post("/:conversationId/continue-in-slack", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", continueConversationInSlackBodySchema, "Invalid request body."), async (context) => jsonResponse(continueConversationInSlackResponseSchema, await continueConversationInSlackForViewer(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json"))));
750
804
  app.post("/:conversationId/forks", requireViewer, bodyLimit({ maxSize: 32768 }), validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", forkConversationBodySchema, "Invalid request body."), async (context) => jsonResponse(forkConversationResponseSchema, await forkConversationForViewer(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json"))));
751
805
  app.post("/:conversationId/quick-question/keep", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), async (context) => jsonResponse(forkConversationResponseSchema, await keepQuickQuestionForViewer(context.get("viewer"), context.req.valid("param").conversationId)));
752
806
  app.patch("/:conversationId/archive", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", archiveConversationBodySchema, "Invalid request body."), async (context) => {
@@ -756,11 +810,13 @@ function createConversationRoutes(options) {
756
810
  return jsonResponse(archiveConversationResponseSchema, await archiveConversation(viewer, conversationId, body));
757
811
  });
758
812
  app.patch("/:conversationId/pin", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", pinConversationBodySchema, "Invalid request body."), async (context) => jsonResponse(pinConversationResponseSchema, await pinConversation(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json"))));
813
+ app.patch("/:conversationId/unread", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", markConversationUnreadBodySchema, "Invalid request body."), async (context) => jsonResponse(conversationUnreadSchema, await markConversationUnread(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json"))));
814
+ app.patch("/:conversationId/title", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", renameConversationBodySchema, "Invalid request body."), async (context) => jsonResponse(renameConversationResponseSchema, await renameConversation(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json"))));
759
815
  app.put("/:conversationId/read-position", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", conversationReadPositionSchema, "Invalid request body."), async (context) => {
760
816
  const viewer = context.get("viewer");
761
817
  const { conversationId } = context.req.valid("param");
762
818
  const body = context.req.valid("json");
763
- return jsonResponse(conversationReadPositionSchema, await markConversationRead(viewer, conversationId, body));
819
+ return jsonResponse(conversationReadReportSchema, await reportConversationRead(viewer, conversationId, body));
764
820
  });
765
821
  app.put("/pin-order", requireViewer, validateRequest("json", reorderPinnedConversationsBodySchema, "Invalid request body."), async (context) => jsonResponse(reorderPinnedConversationsResponseSchema, await reorderPinnedConversations(context.get("viewer"), context.req.valid("json"))));
766
822
  app.post("/archive-done", requireViewer, async (context) => jsonResponse(archiveDoneConversationsResponseSchema, await archiveViewerDoneConversations(context.get("viewer"))));
@@ -826,15 +882,21 @@ function createConversationRoutes(options) {
826
882
  const viewer = context.get("viewer");
827
883
  const viewerOptions = viewer ? { viewer } : void 0;
828
884
  const sentVersion = context.req.header(CONVERSATION_DETAIL_VERSION_HEADER);
829
- const readMailbox = () => requireConversationPendingMessages(conversationId, viewerOptions);
885
+ const readAccess = createConversationAccessReader(getDb(), viewer);
886
+ const readMailbox = () => requireConversationPendingMessages(conversationId, {
887
+ readAccess,
888
+ ...viewerOptions
889
+ });
830
890
  const readVersion = () => readConversationDetailEtag(conversationId, {
831
891
  limit: query.limit,
892
+ readAccess,
832
893
  ...viewerOptions
833
894
  });
834
895
  const [mailbox, version] = withMailbox && sentVersion ? [await readMailbox(), await readVersion()] : await Promise.all([withMailbox ? readMailbox() : void 0, readVersion()]);
835
896
  const headers = version ? {
836
897
  "cache-control": "private, no-store",
837
- [CONVERSATION_DETAIL_VERSION_HEADER]: version.etag
898
+ [CONVERSATION_DETAIL_VERSION_HEADER]: version.etag,
899
+ [CONVERSATION_VERSION_HEADER]: version.version
838
900
  } : void 0;
839
901
  if (version && sentVersion === version.etag) return mailbox ? jsonResponse(conversationUnchangedDetailWithMailboxSchema, {
840
902
  mailbox,
@@ -1467,6 +1529,7 @@ function summaryFromRow(row, options = {}) {
1467
1529
  const conversation = {
1468
1530
  conversationId: row.conversationId,
1469
1531
  createdAtMs: row.createdAt.getTime(),
1532
+ kind: conversationKindFromRow(row),
1470
1533
  lastActivityAtMs: row.lastActivityAt.getTime(),
1471
1534
  updatedAtMs: row.updatedAt.getTime(),
1472
1535
  execution: {
@@ -1475,7 +1538,10 @@ function summaryFromRow(row, options = {}) {
1475
1538
  },
1476
1539
  ...actor ? { actor } : void 0,
1477
1540
  ...row.channelName ? { channelName: row.channelName } : void 0,
1541
+ ...row.parentConversationId ? { parentConversationId: row.parentConversationId } : void 0,
1542
+ ...row.archivedAt ? { archivedAtMs: row.archivedAt.getTime() } : void 0,
1478
1543
  ...row.source ? { source: row.source } : void 0,
1544
+ ...row.stoppedAt ? { stoppedAtMs: row.stoppedAt.getTime() } : void 0,
1479
1545
  ...row.title ? { title: row.title } : void 0
1480
1546
  };
1481
1547
  return conversationSummaryFromStoredConversation({
@@ -1690,8 +1756,12 @@ async function recentLocationRows(db, locationId) {
1690
1756
  ${juniorIdentities.email}
1691
1757
  )`,
1692
1758
  executionStatus: juniorConversations.executionStatus,
1759
+ stoppedAt: juniorConversations.stoppedAt,
1693
1760
  executionUpdatedAt: juniorConversations.executionUpdatedAt,
1694
1761
  fullName: juniorUsers.displayName,
1762
+ kind: juniorConversations.kind,
1763
+ parentConversationId: juniorConversations.parentConversationId,
1764
+ archivedAt: juniorConversations.archivedAt,
1695
1765
  handle: juniorIdentities.handle,
1696
1766
  lastActivityAt: juniorConversations.lastActivityAt,
1697
1767
  providerSubjectId: sql`CASE
@@ -1965,8 +2035,12 @@ async function recentActorRows(email) {
1965
2035
  durationMs: juniorConversations.durationMs,
1966
2036
  email: juniorUsers.primaryEmailNormalized,
1967
2037
  executionStatus: juniorConversations.executionStatus,
2038
+ stoppedAt: juniorConversations.stoppedAt,
1968
2039
  executionUpdatedAt: juniorConversations.executionUpdatedAt,
1969
2040
  fullName: juniorUsers.displayName,
2041
+ kind: juniorConversations.kind,
2042
+ parentConversationId: juniorConversations.parentConversationId,
2043
+ archivedAt: juniorConversations.archivedAt,
1970
2044
  handle: sql`CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.handle} END`,
1971
2045
  lastActivityAt: juniorConversations.lastActivityAt,
1972
2046
  providerSubjectId: sql`CASE WHEN ${juniorIdentities.provider} = 'slack' THEN ${juniorIdentities.providerSubjectId} END`,
@@ -2198,7 +2272,7 @@ async function readPeoplePluginReports(args) {
2198
2272
  reports: [],
2199
2273
  source: "plugins"
2200
2274
  });
2201
- const { getPluginProfileReports } = await import("./projection-0UcUeuzn.js").then((n) => n.kn);
2275
+ const { getPluginProfileReports } = await import("./projection-CoeMNxJ4.js").then((n) => n.Vn);
2202
2276
  return pluginOperationalReportFeedSchema.parse({
2203
2277
  generatedAt: new Date(nowMs).toISOString(),
2204
2278
  reports: await getPluginProfileReports({
@@ -2407,36 +2481,48 @@ function spendWindow(nowMs) {
2407
2481
  thirtyDayStart
2408
2482
  };
2409
2483
  }
2410
- /**
2411
- * Read a cheap change marker for one viewer's spend window.
2412
- *
2413
- * Writes that record Conversation metrics also move `updated_at` forward, so
2414
- * the marker changes when spend can change. The spend cache TTL bounds changes
2415
- * that the marker misses, such as a day that leaves the window.
2416
- */
2417
- async function readPersonalSpendVersion(email, nowMs = Date.now()) {
2484
+ /** Match the viewer's own Conversations with activity in the spend window. */
2485
+ function viewerWindowWhere(email, nowMs) {
2418
2486
  const normalizedEmail = normalizeEmail$1(email);
2419
- if (!normalizedEmail) return "";
2420
2487
  const { end, thirtyDayStart } = spendWindow(nowMs);
2421
- const [row] = await getDb().select({
2422
- conversations: sql`count(*)::int`,
2423
- updatedAt: sql`max(${juniorConversations.updatedAt})::text`
2424
- }).from(juniorConversations).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversations.actorIdentityId)).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(and(verifiedActorWhere(normalizedEmail), gte(juniorConversations.lastActivityAt, thirtyDayStart), lte(juniorConversations.lastActivityAt, end)));
2425
- return `${row?.conversations ?? 0}:${row?.updatedAt ?? ""}`;
2488
+ return normalizedEmail ? and(verifiedActorWhere(normalizedEmail), gte(juniorConversations.lastActivityAt, thirtyDayStart), lte(juniorConversations.lastActivityAt, end)) : sql`false`;
2426
2489
  }
2427
- /** Read one viewer's rolling model spend with one bounded aggregate query. */
2428
- async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
2429
- const normalizedEmail = normalizeEmail$1(email);
2430
- const { end, sevenDayStart, thirtyDayStart } = spendWindow(nowMs);
2490
+ /** Return a query for one viewer's model spend for each UTC day in the window. */
2491
+ function personalSpendDaysQuery(db, email, nowMs) {
2431
2492
  const activityDate = sql`TO_CHAR(
2432
2493
  ${juniorConversations.lastActivityAt} AT TIME ZONE 'UTC',
2433
2494
  'YYYY-MM-DD'
2434
2495
  )`;
2435
- const metricsJoin = peopleTreeMetricsJoin();
2436
- const rows = normalizedEmail ? await getDb().select({
2496
+ return db.select({
2437
2497
  costUsd: peopleTreeAggregateColumns.costUsd,
2438
2498
  date: activityDate
2439
- }).from(juniorConversations).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversations.actorIdentityId)).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, metricsJoin).where(and(verifiedActorWhere(normalizedEmail), gte(juniorConversations.lastActivityAt, thirtyDayStart), lte(juniorConversations.lastActivityAt, end))).groupBy(activityDate) : [];
2499
+ }).from(juniorConversations).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversations.actorIdentityId)).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).leftJoin(peopleTreeConversation, peopleTreeMetricsJoin()).where(viewerWindowWhere(email, nowMs)).groupBy(activityDate);
2500
+ }
2501
+ /**
2502
+ * Return a query for a change marker of one viewer's spend window.
2503
+ *
2504
+ * It reads only the viewer's own rows, without the tree join of the spend
2505
+ * read, so it costs about as much as a count. It sums each row's own cost
2506
+ * and the UTC day of its last activity, so a recorded cost, or a
2507
+ * Conversation that moves to a new day, moves it. Other writes do not. A
2508
+ * Task that another person's Turn started under the viewer's root is not
2509
+ * the viewer's row, so its cost shows on the next spend read: a page load,
2510
+ * a tab focus, or the viewer's next own cost. The window start moves it at
2511
+ * UTC midnight.
2512
+ */
2513
+ function personalSpendVersionQuery(db, email, nowMs) {
2514
+ const { thirtyDayStart } = spendWindow(nowMs);
2515
+ return db.select({ version: sql`concat_ws(':',
2516
+ ${thirtyDayStart.toISOString().slice(0, 10)}::text,
2517
+ count(*),
2518
+ sum(${conversationUsageCostExpr(juniorConversations.usage)}),
2519
+ sum(extract(epoch from date_trunc('day', ${juniorConversations.lastActivityAt} at time zone 'UTC')))
2520
+ )` }).from(juniorConversations).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversations.actorIdentityId)).innerJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(viewerWindowWhere(email, nowMs));
2521
+ }
2522
+ /** Read one viewer's rolling model spend with one bounded aggregate query. */
2523
+ async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
2524
+ const { end, sevenDayStart, thirtyDayStart } = spendWindow(nowMs);
2525
+ const rows = await personalSpendDaysQuery(getDb(), email, nowMs);
2440
2526
  const sevenDayStartDate = sevenDayStart.toISOString().slice(0, 10);
2441
2527
  let sevenDaysUsd = 0;
2442
2528
  let thirtyDaysUsd = 0;
@@ -2454,45 +2540,11 @@ async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
2454
2540
  windowStart: thirtyDayStart.toISOString()
2455
2541
  };
2456
2542
  }
2457
- // src/api/people/spend.ts
2458
- const PERSONAL_SPEND_CACHE_TTL_MS = 3e5;
2459
- /**
2460
- * Create an app-scoped personal-spend reader.
2461
- *
2462
- * A cached report stays valid for five minutes, or until the viewer's spend
2463
- * version changes. The dashboard can poll often and still see a finished Turn
2464
- * without a full aggregate query on every poll.
2465
- */
2466
- function createPersonalSpendReader() {
2467
- const cache = /* @__PURE__ */ new Map();
2468
- return async function readPersonalSpend(email) {
2469
- const normalizedEmail = email.trim().toLowerCase();
2470
- const nowMs = Date.now();
2471
- const version = await readPersonalSpendVersion(normalizedEmail, nowMs);
2472
- const cached = cache.get(normalizedEmail);
2473
- if (cached && cached.expiresAtMs > nowMs && cached.version === version) return cached.report;
2474
- cache.delete(normalizedEmail);
2475
- const report = readPersonalSpendFromSql(normalizedEmail, nowMs);
2476
- const entry = {
2477
- expiresAtMs: nowMs + PERSONAL_SPEND_CACHE_TTL_MS,
2478
- report,
2479
- version
2480
- };
2481
- cache.set(normalizedEmail, entry);
2482
- try {
2483
- return await report;
2484
- } catch (error) {
2485
- if (cache.get(normalizedEmail) === entry) cache.delete(normalizedEmail);
2486
- throw error;
2487
- }
2488
- };
2489
- }
2490
2543
  // src/api/people/routes.ts
2491
2544
  const AVATAR_IMMUTABLE_CACHE_CONTROL = "private, max-age=31536000, immutable";
2492
2545
  /** Create the HTTP routes owned by the People API. */
2493
2546
  function createPeopleRoutes() {
2494
2547
  const app = new Hono();
2495
- const readPersonalSpend = createPersonalSpendReader();
2496
2548
  app.get("/avatars/:identityId", requireViewer, validateRequest("param", avatarParamsSchema, "Invalid route parameters."), async (context) => {
2497
2549
  const { identityId } = context.req.valid("param");
2498
2550
  const avatar = await readAvatarImage(getDb(), getStateAdapter(), identityId);
@@ -2515,7 +2567,7 @@ function createPeopleRoutes() {
2515
2567
  });
2516
2568
  app.get("/me/spend", requireViewer, async (context) => {
2517
2569
  const viewer = context.get("viewer");
2518
- return jsonResponse(personalSpendReportSchema, await readPersonalSpend(viewer.email));
2570
+ return jsonResponse(personalSpendReportSchema, await readPersonalSpendFromSql(viewer.email));
2519
2571
  });
2520
2572
  app.get("/", async () => jsonResponse(actorDirectoryReportSchema, await readPeopleList()));
2521
2573
  app.get("/:email/plugin-reports", requireViewer, validateRequest("param", personParamsSchema, "Invalid route parameters."), async (context) => {
@@ -3216,6 +3268,29 @@ async function readStatsReport() {
3216
3268
  windowStart: start
3217
3269
  });
3218
3270
  }
3271
+ // src/api/versions.ts
3272
+ /**
3273
+ * Read the change tokens of the dashboard reads in one statement, so one
3274
+ * cheap poll can tell which reads to refresh. The real endpoints still check
3275
+ * access. The Conversation token shows no more than its detail report does:
3276
+ * that report answers any viewer, with private content redacted.
3277
+ */
3278
+ async function readVersions(viewer, options = {}) {
3279
+ const db = getDb();
3280
+ const [row] = await db.select({
3281
+ conversation: options.conversationId ? sql`(${conversationVersionQuery(db, options.conversationId, viewer.id)})` : sql`null`,
3282
+ conversations: sql`(${conversationFeedVersionQuery(db, viewer.id)})`,
3283
+ reviewItems: sql`(${reviewItemsNeedingUserVersionQuery(db, viewer.id)})`,
3284
+ spend: sql`(${personalSpendVersionQuery(db, viewer.email, Date.now())})`
3285
+ }).from(juniorUsers).where(eq(juniorUsers.id, viewer.id));
3286
+ if (!row) throw new Error("Viewer user row is missing");
3287
+ return {
3288
+ ...row.conversation ? { conversation: row.conversation } : void 0,
3289
+ conversations: row.conversations,
3290
+ reviewItems: row.reviewItems,
3291
+ spend: row.spend
3292
+ };
3293
+ }
3219
3294
  // src/reporting.ts
3220
3295
  function readDescriptionText(home) {
3221
3296
  try {
@@ -3226,7 +3301,7 @@ function readDescriptionText(home) {
3226
3301
  }
3227
3302
  /** Read discovered skill names for authenticated runtime diagnostics. */
3228
3303
  async function readSkillReports() {
3229
- const { discoverSkills } = await import("./skills-CKyotM4g.js").then((n) => n.o);
3304
+ const { discoverSkills } = await import("./skills-COCqf61f.js").then((n) => n.o);
3230
3305
  const skills = await discoverSkills();
3231
3306
  return skillReportsSchema.parse(skills.map((skill) => ({
3232
3307
  name: skill.name,
@@ -3235,7 +3310,7 @@ async function readSkillReports() {
3235
3310
  }
3236
3311
  /** Read safe configured plugin metadata for authenticated runtime diagnostics. */
3237
3312
  async function readPlugins() {
3238
- const { pluginCatalogRuntime } = await import("./catalog-runtime-dKOVbR7l.js").then((n) => n.t);
3313
+ const { pluginCatalogRuntime } = await import("./catalog-runtime-Bym8GVdh.js").then((n) => n.t);
3239
3314
  return pluginsSchema.parse(pluginCatalogRuntime.getProviders().map((plugin) => ({
3240
3315
  configKeys: plugin.manifest.configKeys ?? [],
3241
3316
  description: plugin.manifest.description,
@@ -3247,7 +3322,7 @@ async function readPlugins() {
3247
3322
  async function readRuntimeInfoReport() {
3248
3323
  const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
3249
3324
  import("./package-discovery-DJhGdS4c.js").then((n) => n.r),
3250
- import("./catalog-runtime-dKOVbR7l.js").then((n) => n.t),
3325
+ import("./catalog-runtime-Bym8GVdh.js").then((n) => n.t),
3251
3326
  readPlugins(),
3252
3327
  readSkillReports()
3253
3328
  ]);
@@ -3264,7 +3339,7 @@ async function readRuntimeInfoReport() {
3264
3339
  /** Read sanitized operational summaries contributed by plugins. */
3265
3340
  async function readPluginOperationalReportFeed() {
3266
3341
  const nowMs = Date.now();
3267
- const { getPluginOperationalReports } = await import("./projection-0UcUeuzn.js").then((n) => n.kn);
3342
+ const { getPluginOperationalReports } = await import("./projection-CoeMNxJ4.js").then((n) => n.Vn);
3268
3343
  return pluginOperationalReportFeedSchema.parse({
3269
3344
  source: "plugins",
3270
3345
  generatedAt: new Date(nowMs).toISOString(),
@@ -3281,6 +3356,7 @@ function createJuniorApi(options = {}) {
3281
3356
  app.get("/api/skills", async () => jsonResponse(skillReportsSchema, await readSkillReports()));
3282
3357
  app.get("/api/plugin-reports", async () => jsonResponse(pluginOperationalReportFeedSchema, await readPluginOperationalReportFeed()));
3283
3358
  app.get("/api/stats", async () => jsonResponse(statsReportSchema, await readStatsReport()));
3359
+ app.get("/api/versions", requireViewer, validateRequest("query", versionsQuerySchema, "Invalid query parameters."), async (context) => jsonResponse(versionsSchema, await readVersions(context.get("viewer"), context.req.valid("query")), { headers: { "cache-control": "private, no-store" } }));
3284
3360
  const queue = options.conversationWorkQueue ?? getVercelConversationWorkQueue();
3285
3361
  app.route("/api/conversations", createConversationRoutes({
3286
3362
  attachmentStorage: getAttachmentStorage(),
@@ -1,6 +1,6 @@
1
1
  import { n as ConversationWorkQueue, t as ConversationQueueMessage } from "./queue-CZyYgPF0.js";
2
- import { t as ConversationStore } from "./db-D7CCwAo8.js";
3
- import "./schema-B017enNE.js";
2
+ import { t as ConversationStore } from "./db-C5zi4ecs.js";
3
+ import "./schema-Ih60j59-.js";
4
4
  import { n as JuniorPluginSet } from "./plugins-DtmjkTza.js";
5
5
  import "./sentry-DrKC2NeM.js";
6
6
  import { Hono } from "hono";
@@ -121,7 +121,6 @@ declare const inboundMessageSchema: z.ZodObject<{
121
121
  conversationId: z.ZodString;
122
122
  }, z.core.$strict>], "platform">>;
123
123
  inboundMessageId: z.ZodString;
124
- injectedAtMs: z.ZodOptional<z.ZodNumber>;
125
124
  input: z.ZodObject<{
126
125
  attachments: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
127
126
  authorId: z.ZodOptional<z.ZodString>;
package/dist/app.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as JuniorDashboardOptions, n as JuniorAppOptions, r as createApp, t as JuniorApp } from "./app-CvGalMxi.js";
1
+ import { i as JuniorDashboardOptions, n as JuniorAppOptions, r as createApp, t as JuniorApp } from "./app-BKq0JzWx.js";
2
2
  import { i as defineJuniorPlugins, n as JuniorPluginSet, r as JuniorPluginSetOptions, t as JuniorPluginInput } from "./plugins-DtmjkTza.js";
3
3
  import { t as JUNIOR_VERSION } from "./version-Cc2OFd9G.js";
4
4
  export { JUNIOR_VERSION, JuniorApp, JuniorAppOptions, type JuniorDashboardOptions, type JuniorPluginInput, type JuniorPluginSet, type JuniorPluginSetOptions, createApp, defineJuniorPlugins };