@sentry/junior 0.299.0 → 0.301.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 (78) hide show
  1. package/dist/{adapter-AgCNqqsG.js → adapter-CNjGEJO9.js} +5 -4
  2. package/dist/{admin-1VwEXztm.js → admin-CRJHvCGg.js} +2 -2
  3. package/dist/{agent-runner-Ciet8_nn.js → agent-runner-H4YhvNBj.js} +514 -270
  4. package/dist/api/schema.d.ts +2 -2
  5. package/dist/api/schema.js +6 -7
  6. package/dist/api.d.ts +1 -1
  7. package/dist/api.js +327 -61
  8. package/dist/{app--ky-Eu33.d.ts → app-HDZglaIu.d.ts} +14 -3
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +60 -220
  11. package/dist/{automation-M3RFJUBf.js → automation-Cva5ZOwW.js} +2 -2
  12. package/dist/{background-compaction-queue-CnimvRdk.js → background-compaction-queue-CNrZ3QcU.js} +8 -4
  13. package/dist/{briefs-CwzvgdCa.js → briefs-x6Mzwxmg.js} +3 -3
  14. package/dist/{catalog-runtime-DaBaHY7u.js → catalog-runtime-BEY6EGRi.js} +1 -1
  15. package/dist/cli/chat.js +16 -16
  16. package/dist/cli/check.js +3 -3
  17. package/dist/cli/main.js +3 -3
  18. package/dist/cli/plugins.js +5 -5
  19. package/dist/cli/snapshot-create.js +4 -4
  20. package/dist/cli/upgrade.d.ts +1 -1
  21. package/dist/cli/upgrade.js +4 -4
  22. package/dist/{config-CAXIpWQb.js → config-CmjhyqgB.js} +39 -8
  23. package/dist/{connections-Dy0hPdUq.js → connections-CfIRm0xv.js} +6 -6
  24. package/dist/{continue-in-slack-DIOjFj76.js → continue-in-slack-DPoABVkB.js} +6 -6
  25. package/dist/{conversation-fCWD9Az3.js → conversation-BNXfq6Lb.js} +30 -9
  26. package/dist/{conversation-feed-BPK8vkkZ.js → conversation-feed-CfpyFMHP.js} +23 -2
  27. package/dist/{conversation-privacy-DUgtRkf8.js → conversation-privacy-0CM0V2qK.js} +1 -1
  28. package/dist/{conversation-turn-DkJB6yMF.js → conversation-turn-C0sxyvS-.js} +17 -17
  29. package/dist/{credential-sync-RX24Y8aY.js → credential-sync-tEMKZ_8M.js} +15 -15
  30. package/dist/{db-B07FtU9g.d.ts → db-BdUHQhrC.d.ts} +1 -1
  31. package/dist/{db-COYOGzYS.js → db-Czra10QW.js} +13 -8
  32. package/dist/{executor-BWmAgSyi.js → executor-D_023K0H.js} +9 -4
  33. package/dist/instrumentation.js +14 -5
  34. package/dist/{lineage-D-5jm_oj.js → lineage-DmMIE0VL.js} +2 -2
  35. package/dist/{logging-DPLEa8Bn.js → logging-DcjLDDqi.js} +1 -1
  36. package/dist/{message-BIHR1yRk.js → message-C0JY9RJP.js} +8 -8
  37. package/dist/{model-input-BPZYH8Nd.js → model-input-CBp-p24N.js} +4 -4
  38. package/dist/nitro.d.ts +1 -1
  39. package/dist/nitro.js +4 -4
  40. package/dist/{oauth-callback-server-R7qvSzFG.js → oauth-callback-server-BRq9QNhU.js} +2 -2
  41. package/dist/{plugins-CBW2Prb_.js → plugins-BBX07Jzt.js} +1 -1
  42. package/dist/{projection-DEdP1q6f.js → projection-CQNDOi82.js} +911 -671
  43. package/dist/{prompt-4M98h_tC.js → prompt-DLUB5m72.js} +4 -4
  44. package/dist/{registry-BTKmKM-r.js → registry-Dj377ADs.js} +2 -2
  45. package/dist/{resolve-B8hXNVZ3.js → resolve-DJkh9Fky.js} +3 -3
  46. package/dist/{result-g-XAaOj6.js → result-C8iIpDl1.js} +9 -9
  47. package/dist/{runner-BlPSA5A8.js → runner-DZqrOy8C.js} +9 -9
  48. package/dist/{sandbox-egress-signals-Pai-MzEY.js → sandbox-egress-signals-CGwH86S9.js} +1 -1
  49. package/dist/{schema-DbuWR-DN.d.ts → schema-CdZFn7Qd.d.ts} +248 -6
  50. package/dist/{schema-BNnY_trV.js → schema-DyHXiQKI.js} +28 -16
  51. package/dist/{service-account-BYGZ08DQ.js → service-account-D6jGR4a1.js} +3 -3
  52. package/dist/{service-account-9OLNQMyz.js → service-account-suY004dx.js} +4 -4
  53. package/dist/{session-stop-2XJrcNCy.js → session-stop-BLmfFI3d.js} +121 -46
  54. package/dist/{skills-DpBQoeHV.js → skills-CmNG0dHb.js} +2 -2
  55. package/dist/{slack-conversation-unfurl-BcDIWo67.js → slack-conversation-unfurl-Bty-DlHe.js} +7 -7
  56. package/dist/{spawn-09GssFod.js → spawn-CNjkpXpk.js} +6 -6
  57. package/dist/{state-Cufq0_rH.js → state-CEbZuZD6.js} +2 -2
  58. package/dist/{statuses-B8mUfghF.js → statuses-Hn-HsOph.js} +86 -2
  59. package/dist/{stop-U7iUrR1g.js → stop-Bjy2-K4H.js} +967 -93
  60. package/dist/{store-BHiaHCQu.js → store-DmV4CoNr.js} +5 -5
  61. package/dist/{store-CSgUTMdv.js → store-Epv6t4vV.js} +9 -9
  62. package/dist/{task-queue-bMNq0clp.js → task-queue-AhG1tSXR.js} +3 -3
  63. package/dist/{task-runner-B__rxwxU.js → task-runner-BMxZI3o7.js} +8 -8
  64. package/dist/{thread-context-d0ceWbVT.js → thread-context-CXLnbg7g.js} +8 -8
  65. package/dist/{turn-session-routing-BVZHBFCF.js → turn-session-routing-BD3-jJl7.js} +5 -5
  66. package/dist/{turn-user-message-BEw7acTP.js → turn-user-message-DsUZi9gn.js} +3 -3
  67. package/dist/{users-BK3dbxZL.js → users-BxvYclQg.js} +3 -3
  68. package/dist/{validation-BDVJjO2E.js → validation-DOz8X9BU.js} +1 -1
  69. package/dist/{version-DQgZoQ3D.js → version-CGMRmMPK.js} +1 -1
  70. package/dist/version.js +1 -1
  71. package/dist/{viewer-CAWfFo29.js → viewer-H3EsMWtJ.js} +16 -114
  72. package/dist/{warmup-9ySPacF9.js → warmup-CdU5hR49.js} +51 -27
  73. package/dist/{worker-D8jJO-WO.js → worker-ClphajjD.js} +24 -20
  74. package/migrations/0107_attachment_deferred_download.sql +2 -0
  75. package/migrations/meta/0107_snapshot.json +4617 -0
  76. package/migrations/meta/_journal.json +7 -0
  77. package/package.json +10 -8
  78. package/dist/media-BAHvgkok.js +0 -85
package/dist/api.js CHANGED
@@ -1,40 +1,40 @@
1
- import { $i as hash, Bi as createWorkspace, Bo as readConversationBriefThrough, Cr as saveNotificationSchedule, Fr as listWaitingConversations, Gi as listWorkspacesByRepository, Gr as isOnlyAssignee, Hi as getWorkspace, Ho as readConversationEventPage, Ir as reviewItemsNeedingUserVersionQuery, Ki as updateWorkspace, Lr as searchReviewItems, Mo as readConversationAccessFromSql, Ni as getDashboardSettingsLink, Oo as createPluginLogger, Qi as create, Sr as readNotificationSchedule, Tr as isPausedBySlack, Vi as deleteWorkspace, Vr as canActOnReviewItem, Wi as listWorkspaces, Xr as reviewItemReaderForUser, Zn as createUserTokenStore, Zr as reviewItemReaderForUserInConversation, _r as readWebPushConfig, br as deletePushSubscription, dr as getPlugins, jo as createConversationAccessReader, kr as countReviewItemsNeedingUser, ps as createPluginCache, qi as WorkspaceValidationError, so as SANDBOX_RUNTIME, uo as workspaceRepoCheckoutPath, vr as sendPushNotificationToUser, wr as savePushSubscription, xr as listPushSubscriptions, yr as resolveNotificationTimezone } from "./projection-DEdP1q6f.js";
2
- import { L as escapeXml, Y as getAttachmentStorage, n as botConfig } from "./config-CAXIpWQb.js";
3
- import { m as logInfo, p as logException } from "./logging-DPLEa8Bn.js";
1
+ import { $a as workspaceRepoCheckoutPath, Ar as countReviewItemsNeedingUser, Cr as readNotificationSchedule, Er as isPausedBySlack, Hi as createWorkspace, Hr as canActOnReviewItem, Ir as listWaitingConversations, Ji as updateWorkspace, Ki as listWorkspaces, Kr as isOnlyAssignee, Lr as reviewItemsNeedingUserVersionQuery, Pi as getDashboardSettingsLink, Qr as reviewItemReaderForUserInConversation, Rr as searchReviewItems, Sr as listPushSubscriptions, Tr as savePushSubscription, Ui as deleteWorkspace, Uo as readSlackAttachmentSource, V as createPluginEgress, Wi as getWorkspace, Yi as WorkspaceValidationError, Za as SANDBOX_RUNTIME, Zn as createUserTokenStore, Zr as reviewItemReaderForUser, _o as createPluginLogger, bo as createConversationAccessReader, br as resolveNotificationTimezone, ds as listConversationAnnotations, ea as create, fr as getPlugins, jo as readConversationEventPage, ko as readConversationBriefThrough, qi as listWorkspacesByRepository, ta as hash, us as createPluginAnnotations, vr as readWebPushConfig, wr as saveNotificationSchedule, xo as readConversationAccessFromSql, xr as deletePushSubscription, yr as sendPushNotificationToUser, ys as createPluginCache } from "./projection-CQNDOi82.js";
2
+ import { R as escapeXml, Z as getAttachmentStorage, n as botConfig } from "./config-CmjhyqgB.js";
3
+ import { h as logWarn, m as logInfo, p as logException } from "./logging-DcjLDDqi.js";
4
4
  import { f as parseSlackTeamId, u as parseSlackChannelId } from "./actor-D2iXzvlN.js";
5
- import { D as conversationKindFromRow, _ as loadConversationSlackTenantIds, a as getConversationStore, nt as nextDetailVersion, o as getDb, s as getSqlExecutor, x as withConversationMutationLock } from "./db-COYOGzYS.js";
6
- import { D as juniorCodeChanges, M as juniorIdentities, N as juniorUsers, O as juniorCodeRepositories, P as juniorDestinations, S as juniorConversationMetrics, T as juniorApiTokens, b as juniorConversationBriefs, j as juniorConversations, w as juniorConversationEvents } from "./executor-BWmAgSyi.js";
7
- import { r as getStateAdapter } from "./adapter-AgCNqqsG.js";
8
- import { n as pluginCatalogRuntime } from "./catalog-runtime-DaBaHY7u.js";
9
- import { B as deleteViewerTask, C as createSlackReviewItemShow, Ct as emptyResponse, Et as previewOriginBelongsTo, G as readViewerAutomationExecutions, H as updateViewerAutomation, J as readViewerAutomationVersions, K as readViewerAutomationRuns, Q as listOwnedWatches, R as activateViewerAutomationVersion, St as reportConversationRead, Tt as throwApiError, U as ViewerTaskNotFoundError, V as readViewerAutomationEdit, X as AutomationEditError, Y as readViewerAutomations, ct as webActorFromUser, ft as createAttachmentUpload, gt as readLiveAttachment, h as readStats, mt as writeAttachmentUpload, q as readViewerAutomationSummary, ut as AttachmentUploadError, wt as jsonResponse, y as setConversationSubscription, yt as archiveConversation, z as changeViewerAutomationLifecycle } from "./agent-runner-Ciet8_nn.js";
10
- import { n as briefEntriesFromReportEvents, u as completeText } from "./prompt-4M98h_tC.js";
5
+ import { D as conversationKindFromRow, W as createCache, _ as loadConversationSlackTenantIds, a as getConversationStore, nt as nextDetailVersion, o as getDb, s as getSqlExecutor, x as withConversationMutationLock } from "./db-Czra10QW.js";
6
+ import { D as juniorCodeChanges, M as juniorIdentities, N as juniorUsers, O as juniorCodeRepositories, P as juniorDestinations, S as juniorConversationMetrics, T as juniorApiTokens, b as juniorConversationBriefs, j as juniorConversations, w as juniorConversationEvents } from "./executor-D_023K0H.js";
7
+ import { r as getStateAdapter } from "./adapter-CNjGEJO9.js";
8
+ import { f as credentialContextForActor } from "./registry-Dj377ADs.js";
9
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-BEY6EGRi.js";
10
+ import { B as activateViewerAutomationVersion, Dt as throwApiError, Et as jsonResponse, G as ViewerTaskNotFoundError, H as deleteViewerTask, J as readViewerAutomationRuns, Ot as previewOriginBelongsTo, Q as AutomationEditError, T as createSlackReviewItemShow, Tt as emptyResponse, U as readViewerAutomationEdit, V as changeViewerAutomationLifecycle, W as updateViewerAutomation, X as readViewerAutomationVersions, Y as readViewerAutomationSummary, Z as readViewerAutomations, _ as readAttachmentContent, et as listOwnedWatches, ft as AttachmentUploadError, g as AttachmentDownloadError, gt as writeAttachmentUpload, h as readStats, it as acceptsWebMessages, mt as createAttachmentUpload, q as readViewerAutomationExecutions, ut as webActorFromUser, vt as readLiveAttachment, wt as reportConversationRead, x as setConversationSubscription, xt as archiveConversation } from "./agent-runner-H4YhvNBj.js";
11
+ import { n as briefEntriesFromReportEvents, u as completeText } from "./prompt-DLUB5m72.js";
11
12
  import { r as notificationScheduleSchema } from "./schedule-cP0AACm1.js";
12
- import { n as INPUT_IMAGE_TYPES, t as INLINE_VIDEO_TYPES } from "./media-BAHvgkok.js";
13
- import { c as readViewerAvatarUrl, d as updateViewerDisplayName, l as resolveViewerUser, m as readAvatarImage, t as findUserByEmail } from "./viewer-CAWfFo29.js";
14
- import { C as createConversationMessageBodySchema, F as renameConversationResponseSchema, G as MAX_INPUT_ATTACHMENT_BYTES, I as conversationReadPositionSchema, P as renameConversationBodySchema, S as createConversationBodySchema, T as forkConversationResponseSchema, c as conversationDetailQuerySchema, d as conversationEventPageSchema, f as conversationEventsQuerySchema, l as conversationDetailReportSchema, m as conversationParamsSchema, n as CONVERSATION_VERSION_HEADER, o as conversationAttachmentParamsSchema, p as conversationFeedQuerySchema, r as acceptedConversationMessageSchema, t as CONVERSATION_DETAIL_VERSION_HEADER, w as forkConversationBodySchema } from "./conversation-fCWD9Az3.js";
15
- import { R as getEventCatalog, _ as readUserCustomization, b as isExperimentalFeatureEnabled, v as saveUserCustomization } from "./session-stop-2XJrcNCy.js";
16
- import { Dt as GAP_SEGMENTS, Mt as gapHistogramReport, a as segmentGapsKey, d as listChildAgents } from "./warmup-9ySPacF9.js";
17
- import { l as getVercelConversationWorkQueue } from "./background-compaction-queue-CnimvRdk.js";
18
- import { u as automationEventCatalog } from "./turn-session-routing-BVZHBFCF.js";
19
- import { f as userCustomizationSchema } from "./statuses-B8mUfghF.js";
20
- import { s as getSandboxResources, t as getCachedSnapshot } from "./resolve-B8hXNVZ3.js";
21
- import { n as finishServiceAccountSignIn, o as serviceAccountPlugins, r as getServiceAccountStatus, s as startServiceAccountSignIn, t as disconnectServiceAccount } from "./service-account-9OLNQMyz.js";
13
+ import { c as readViewerAvatarUrl, d as updateViewerDisplayName, l as resolveViewerUser, m as readAvatarFetch, t as findUserByEmail } from "./viewer-H3EsMWtJ.js";
14
+ import { C as createConversationBodySchema, E as forkConversationResponseSchema, F as renameConversationBodySchema, G as MAX_ATTACHMENT_BYTES, I as renameConversationResponseSchema, L as conversationReadPositionSchema, T as forkConversationBodySchema, f as conversationEventPageSchema, h as conversationParamsSchema, l as conversationDetailQuerySchema, m as conversationFeedQuerySchema, n as CONVERSATION_VERSION_HEADER, o as conversationAttachmentParamsSchema, p as conversationEventsQuerySchema, r as acceptedConversationMessageSchema, s as conversationAttachmentQuerySchema, t as CONVERSATION_DETAIL_VERSION_HEADER, u as conversationDetailReportSchema, w as createConversationMessageBodySchema } from "./conversation-BNXfq6Lb.js";
15
+ import { R as getEventCatalog, S as addConversationNote, _ as readUserCustomization, b as isExperimentalFeatureEnabled, v as saveUserCustomization } from "./session-stop-BLmfFI3d.js";
16
+ import { At as GAP_SEGMENTS, Dt as breakerStates, Ft as gapHistogramReport, Ot as closeBreaker, a as segmentGapsKey, d as listChildAgents, kt as connectedState } from "./warmup-CdU5hR49.js";
17
+ import { l as getVercelConversationWorkQueue } from "./background-compaction-queue-CNrZ3QcU.js";
18
+ import { u as automationEventCatalog } from "./turn-session-routing-BD3-jJl7.js";
19
+ import { d as INLINE_VIDEO_TYPES, f as INPUT_IMAGE_TYPES, g as userCustomizationSchema, p as detectImageMediaType } from "./statuses-Hn-HsOph.js";
20
+ import { s as getSandboxResources, t as getCachedSnapshot } from "./resolve-DJkh9Fky.js";
21
+ import { n as finishServiceAccountSignIn, o as serviceAccountPlugins, r as getServiceAccountStatus, s as startServiceAccountSignIn, t as disconnectServiceAccount } from "./service-account-suY004dx.js";
22
22
  import { a as fillUtcSixHours, c as trailingUtcDayWindow, d as utcDayKey, f as utcHourKey, i as fillUtcHours, l as trailingUtcHourWindow, m as apiErrorSchema, 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-DopzcOHh.js";
23
- import { F as compileScheduleIntent, P as ScheduleIntentError, U as automationTaskText, _ 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-M3RFJUBf.js";
24
- import { A as conversationRangeColumns, D as readAutomationTitlesByConversationId, at as AutomationConflictError, j as conversationUsageCostExpr, k as conversationAggregateColumns } from "./store-CSgUTMdv.js";
25
- import { a as runWithSlackInstallation } from "./users-BK3dbxZL.js";
26
- import { F as readReviewItemForUser, G as OBJECT_LINK_TTL_MS, H as updateUserAutoArchiveSettings, L as DEFAULT_AUTO_ARCHIVE_SETTINGS, M as ReviewItemActionError, N as actOnReviewItem, O as isAllowedSignInEmail, R as archiveViewerDoneConversations, S as cancelConversationPendingMessagesForViewer, T as resolveMentions, V as setConversationAutoArchive, W as readHealthReport, X as getProductionSlackAdapter, _ as appendConversationMessageForViewer, a as pinConversation, c as readConversationAuxiliaryCostsFromSql, d as conversationVersionQuery, f as readConversationDetailEtag, ft as conversationSummaryFromStoredConversation, h as readConversationEvents, i as readConversationFeed, l as childAgentTotalsReport, m as keepQuickQuestionForViewer, n as steerConversationPendingMessagesForViewer, o as reorderPinnedConversations, p as forkConversationForViewer, pt as readFirstHumanMessageTexts, q as resolveObjectLinks, r as conversationFeedVersionQuery, s as readConversationDetail, t as stopConversationTurnForViewer, u as readConversationTreeMetricsFromSql, v as createConversationForViewer, w as requireConversationPendingMessages, y as requireWebMessageConversation, z as readUserAutoArchiveSettings } from "./stop-U7iUrR1g.js";
27
- import { C as skillReportsSchema, a as conversationDetailWithMailboxReportSchema, b as runtimeInfoReportSchema, d as steerConversationPendingMessagesBodySchema, f as steerConversationPendingMessagesResponseSchema, i as cancelConversationPendingMessagesResponseSchema, l as conversationPendingMessagesReportSchema, m as pluginOperationalReportFeedSchema, n as conversationFeedSchema, p as healthReportSchema, r as cancelConversationPendingMessagesBodySchema, u as conversationUnchangedDetailWithMailboxSchema, x as skillDetailReportSchema, y as pluginsSchema } from "./conversation-feed-BPK8vkkZ.js";
28
- import { a as resumeConversationDelivery, i as pauseConversationDelivery, r as canPauseConversationDelivery } from "./conversation-turn-DkJB6yMF.js";
29
- import { a as startConnection, n as isConnectableProvider, r as listConnections, s as htmlCallbackResponse, t as disconnectConnection } from "./connections-Dy0hPdUq.js";
30
- import { i as continueConversationInSlack, r as canContinueInSlack, t as BUSY } from "./continue-in-slack-DIOjFj76.js";
31
- import { A as revokePersonalTokenResponseSchema, At as reorderPinnedConversationsBodySchema, B as activityDays$1, Ct as conversationAutoArchiveSchema, D as personalTokenListSchema, Dt as conversationDeliveryResponseSchema, E as createdPersonalTokenSchema, Et as conversationDeliveryBodySchema, F as personalSpendReportSchema, Ft as attachmentUploadSchema, G as objectLinksQuerySchema, H as activitySixHours$1, It as createAttachmentUploadBodySchema, J as pushSubscriptionBodySchema, K as objectLinksReportSchema, L as locationDetailReportSchema, M as actorProfileReportSchema, Mt as conversationCatchUpBodySchema, N as avatarParamsSchema, Nt as conversationCatchUpSchema, Ot as pinConversationBodySchema, P as personParamsSchema, Pt as attachmentUploadParamsSchema, Q as connectionParamsSchema, R as locationDirectoryReportSchema, S as serviceAccountParamsSchema, St as archiveDoneConversationsResponseSchema, T as createPersonalTokenBodySchema, Tt as conversationSubscriptionResponseSchema, V as activityHours$1, X as testNotificationResponseSchema, Y as pushSubscriptionDeleteBodySchema, Z as connectionListSchema, _ as reviewItemParamsSchema, _t as conversationStatsReportSchema, a as replyTimeSegmentsReportSchema, at as codeOverviewReportSchema, b as disconnectServiceAccountResponseSchema, bt as archiveConversationBodySchema, c as workspaceBodySchema, ct as codeRepositoryReportSchema, dt as conversationWatchesReportSchema, et as disconnectConnectionResponseSchema, f as workspaceSchema, g as reviewItemListSchema, gt as stopConversationTurnResponseSchema, h as reviewItemListQuerySchema, ht as continueConversationInSlackResponseSchema, i as statsReportSchema, j as actorDirectoryReportSchema, jt as reorderPinnedConversationsResponseSchema, k as personalTokenParamsSchema, kt as pinConversationResponseSchema, l as workspaceListSchema, m as reviewItemCountSchema, mt as continueConversationInSlackBodySchema, n as versionsSchema, ot as codePersonReportSchema, p as reviewItemActionSchema, pt as conversationChildAgentsReportSchema, q as notificationSettingsSchema, s as deleteWorkspaceResponseSchema, st as codeRepositoryParamsSchema, t as versionsQuerySchema, tt as startConnectionResponseSchema, u as workspaceParamsSchema, v as reviewItemSchema, w as startServiceAccountSignInResponseSchema, wt as conversationSubscriptionBodySchema, x as serviceAccountListSchema, xt as archiveConversationResponseSchema, y as reviewItemWaitingConversationsSchema, yt as conversationOutlineSchema, z as locationParamsSchema } from "./schema-BNnY_trV.js";
23
+ import { F as compileScheduleIntent, P as ScheduleIntentError, U as automationTaskText, _ 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-Cva5ZOwW.js";
24
+ import { A as conversationRangeColumns, D as readAutomationTitlesByConversationId, at as AutomationConflictError, j as conversationUsageCostExpr, k as conversationAggregateColumns } from "./store-Epv6t4vV.js";
25
+ import { a as runWithSlackInstallation } from "./users-BxvYclQg.js";
26
+ import { $ as decodeImageId, F as readReviewItemForUser, G as OBJECT_LINK_TTL_MS, H as updateUserAutoArchiveSettings, J as resolveObjectLinks, L as DEFAULT_AUTO_ARCHIVE_SETTINGS, M as ReviewItemActionError, N as actOnReviewItem, O as isAllowedSignInEmail, Q as IMAGE_WIDTHS, R as archiveViewerDoneConversations, S as cancelConversationPendingMessagesForViewer, T as resolveMentions, V as setConversationAutoArchive, W as readHealthReport, Y as guardedFetch, _ as appendConversationMessageForViewer, a as pinConversation, bt as readFirstHumanMessageTexts, c as readConversationAuxiliaryCostsFromSql, d as conversationVersionQuery, f as readConversationDetailEtag, h as readConversationEvents, i as readConversationFeed, l as childAgentTotalsReport, m as keepQuickQuestionForViewer, n as steerConversationPendingMessagesForViewer, nt as getProductionSlackAdapter, o as reorderPinnedConversations, p as forkConversationForViewer, q as resolveObjectLinkNow, r as conversationFeedVersionQuery, s as readConversationDetail, t as stopConversationTurnForViewer, u as readConversationTreeMetricsFromSql, v as createConversationForViewer, w as requireConversationPendingMessages, y as requireWebMessageConversation, yt as conversationSummaryFromStoredConversation, z as readUserAutoArchiveSettings } from "./stop-Bjy2-K4H.js";
27
+ import { C as skillReportsSchema, a as conversationDetailWithMailboxReportSchema, b as runtimeInfoReportSchema, d as steerConversationPendingMessagesBodySchema, f as steerConversationPendingMessagesResponseSchema, i as cancelConversationPendingMessagesResponseSchema, l as conversationPendingMessagesReportSchema, m as pluginOperationalReportFeedSchema, n as conversationFeedSchema, p as healthReportSchema, r as cancelConversationPendingMessagesBodySchema, u as conversationUnchangedDetailWithMailboxSchema, x as skillDetailReportSchema, y as pluginsSchema } from "./conversation-feed-CfpyFMHP.js";
28
+ import { a as resumeConversationDelivery, i as pauseConversationDelivery, r as canPauseConversationDelivery } from "./conversation-turn-C0sxyvS-.js";
29
+ import { a as startConnection, n as isConnectableProvider, r as listConnections, s as htmlCallbackResponse, t as disconnectConnection } from "./connections-CfIRm0xv.js";
30
+ import { i as continueConversationInSlack, r as canContinueInSlack, t as BUSY } from "./continue-in-slack-DPoABVkB.js";
31
+ import { A as personalTokenListSchema, At as conversationSubscriptionResponseSchema, B as locationDetailReportSchema, Bt as attachmentUploadSchema, C as disconnectServiceAccountResponseSchema, D as startServiceAccountSignInResponseSchema, Dt as archiveDoneConversationsResponseSchema, Et as archiveConversationResponseSchema, F as actorProfileReportSchema, Ft as reorderPinnedConversationsBodySchema, G as activitySixHours$1, H as locationParamsSchema, I as avatarParamsSchema, It as reorderPinnedConversationsResponseSchema, J as pushSubscriptionBodySchema, L as personParamsSchema, Lt as conversationCatchUpBodySchema, M as personalTokenParamsSchema, Mt as conversationDeliveryResponseSchema, N as revokePersonalTokenResponseSchema, Nt as pinConversationBodySchema, O as createPersonalTokenBodySchema, Ot as conversationAutoArchiveSchema, P as actorDirectoryReportSchema, Pt as pinConversationResponseSchema, Q as connectionParamsSchema, R as personalSpendReportSchema, Rt as conversationCatchUpSchema, S as closeCacheWarmingBreakerResponseSchema, St as conversationStatsReportSchema, T as serviceAccountParamsSchema, Tt as archiveConversationBodySchema, U as activityDays$1, V as locationDirectoryReportSchema, Vt as createAttachmentUploadBodySchema, W as activityHours$1, X as testNotificationResponseSchema, Y as pushSubscriptionDeleteBodySchema, Z as connectionListSchema, _ as reviewItemParamsSchema, _t as attachObjectLinkBodySchema, a as replyTimeSegmentsReportSchema, at as codeOverviewReportSchema, b as cacheWarmingBreakerListSchema, bt as objectLinksReportSchema, c as workspaceBodySchema, ct as codeRepositoryReportSchema, dt as conversationWatchesReportSchema, et as disconnectConnectionResponseSchema, f as workspaceSchema, g as reviewItemListSchema, h as reviewItemListQuerySchema, ht as continueConversationInSlackResponseSchema, i as statsReportSchema, jt as conversationDeliveryBodySchema, k as createdPersonalTokenSchema, kt as conversationSubscriptionBodySchema, l as workspaceListSchema, m as reviewItemCountSchema, mt as continueConversationInSlackBodySchema, n as versionsSchema, ot as codePersonReportSchema, p as reviewItemActionSchema, pt as conversationChildAgentsReportSchema, q as notificationSettingsSchema, s as deleteWorkspaceResponseSchema, st as codeRepositoryParamsSchema, t as versionsQuerySchema, tt as startConnectionResponseSchema, u as workspaceParamsSchema, v as reviewItemSchema, vt as attachObjectLinkResponseSchema, w as serviceAccountListSchema, wt as conversationOutlineSchema, x as cacheWarmingBreakerParamsSchema, xt as stopConversationTurnResponseSchema, y as reviewItemWaitingConversationsSchema, yt as objectLinksQuerySchema, zt as attachmentUploadParamsSchema } from "./schema-DyHXiQKI.js";
32
32
  import { Hono } from "hono";
33
33
  import * as z from "zod";
34
34
  import path from "node:path";
35
35
  import { createHash, randomBytes, randomUUID } from "node:crypto";
36
36
  import { and, asc, countDistinct, desc, eq, gt, gte, inArray, isNull, lte, notExists, or, sql } from "drizzle-orm";
37
- import { pluginUserPageContentSchema, pluginUserPageCursorSchema, pluginUserPageFilterSchema, pluginUserPageLinksSchema, pluginUserPageQuerySchema } from "@sentry/junior-plugin-api";
37
+ import { objectPresentation, pluginUserPageContentSchema, pluginUserPageCursorSchema, pluginUserPageFilterSchema, pluginUserPageLinksSchema, pluginUserPageQuerySchema } from "@sentry/junior-plugin-api";
38
38
  import { alias } from "drizzle-orm/pg-core";
39
39
  import fs from "node:fs/promises";
40
40
  import { readFileSync } from "node:fs";
@@ -42,6 +42,52 @@ import { HTTPException } from "hono/http-exception";
42
42
  import { bodyLimit } from "hono/body-limit";
43
43
  import { zValidator } from "@hono/zod-validator";
44
44
  import { createMiddleware } from "hono/factory";
45
+ // src/api/objects/attach.ts
46
+ function sameLink(left, right) {
47
+ const key = (url) => url.replace(/\/+$/, "");
48
+ return key(left) === key(right);
49
+ }
50
+ /**
51
+ * Attach a linked object to a Conversation for one participant. The
52
+ * Annotation and the Conversation note save no title. The note tells the
53
+ * next Turn the type and the read tool of the object, so the agent reads it
54
+ * live. Nothing is attached when the viewer cannot write to the
55
+ * Conversation, the Conversation takes no web input from people (a Task),
56
+ * or the viewer cannot see the object now.
57
+ */
58
+ async function attachObjectLink(viewer, conversationId, url) {
59
+ const db = getDb();
60
+ if (!(await readConversationAccessFromSql(db, [conversationId], viewer)).get(conversationId)?.isParticipant) throwApiError(404, "Conversation not found.");
61
+ const conversation = await getConversationStore().get({ conversationId });
62
+ if (!conversation || !acceptsWebMessages(conversation)) throwApiError(409, "Conversation does not accept attached objects.");
63
+ const parsed = URL.canParse(url) ? new URL(url) : void 0;
64
+ const resolved = parsed && await resolveObjectLinkNow(viewer, parsed);
65
+ if (!parsed || !resolved || resolved.object.objectType === "person") throwApiError(404, "Object not found.");
66
+ const { linkType, object } = resolved;
67
+ const link = object.url ?? parsed.href;
68
+ if ((await listConversationAnnotations(db, conversationId)).some((annotation) => annotation.url && sameLink(annotation.url, link) || annotation.plugin === linkType.owner && annotation.key === object.key)) return { status: "unchanged" };
69
+ const type = object.displayType ?? objectPresentation(object).label;
70
+ const article = /^[aeiou]/i.test(type) ? "an" : "a";
71
+ const { readTool } = linkType;
72
+ await addConversationNote({
73
+ conversationId,
74
+ createdAtMs: Date.now(),
75
+ key: `object_attached:${linkType.owner}:${object.key}`,
76
+ text: [`${viewer.displayName ?? viewer.email} attached ${article} ${type} (${link}) to this Conversation.`, readTool ? `Read it live with \`${readTool}\` when the work needs its content.` : ""].filter(Boolean).join(" ")
77
+ });
78
+ await createPluginAnnotations({
79
+ conversationId,
80
+ db,
81
+ plugin: linkType.owner
82
+ }).upsert({
83
+ kind: "resource_link",
84
+ key: object.key,
85
+ label: link.slice(0, 256),
86
+ objectType: object.objectType,
87
+ url: link
88
+ });
89
+ return { status: "attached" };
90
+ }
45
91
  // src/api/validation.ts
46
92
  /** Validate one request input and use Junior's stable JSON error contract. */
47
93
  function validateRequest(target, schema, message) {
@@ -331,8 +377,8 @@ async function continueConversationInSlackForViewer(viewer, conversationId, body
331
377
  }
332
378
  // src/api/conversations/attachments.ts
333
379
  const INLINE_TYPES = [...INPUT_IMAGE_TYPES, ...INLINE_VIDEO_TYPES];
334
- function contentDisposition(filename, contentType) {
335
- return `${INLINE_TYPES.includes(contentType) ? "inline" : "attachment"}; filename="${filename.replace(/[^\x20-\x7e]|["\\]/g, "_")}"; filename*=UTF-8''${encodeURIComponent(filename)}`;
380
+ function contentDisposition(filename, contentType, download) {
381
+ return `${!download && INLINE_TYPES.includes(contentType) ? "inline" : "attachment"}; filename="${filename.replace(/[^\x20-\x7e]|["\\]/g, "_")}"; filename*=UTF-8''${encodeURIComponent(filename)}`;
336
382
  }
337
383
  /**
338
384
  * Read one `Range` request header against an object size.
@@ -363,20 +409,71 @@ function parseRangeHeader(header, size) {
363
409
  };
364
410
  }
365
411
  /**
412
+ * Stream a large Slack file that Junior never stored, from Slack through the
413
+ * host, with the conversation's Slack installation. A HEAD request checks
414
+ * that Slack still has the file without downloading it. Ranges are not
415
+ * supported, so media players cannot seek in these files.
416
+ */
417
+ async function slackFileResponse(args) {
418
+ const { attachment, teamId } = args;
419
+ const read = async () => {
420
+ const content = await readAttachmentContent({
421
+ attachment,
422
+ ...teamId ? { readAttachmentSource: readSlackAttachmentSource } : void 0,
423
+ storage: args.storage
424
+ });
425
+ return {
426
+ body: args.headOnly ? null : await content.open(),
427
+ bytes: content.bytes
428
+ };
429
+ };
430
+ let file;
431
+ try {
432
+ file = teamId ? await runWithSlackInstallation({
433
+ adapter: getProductionSlackAdapter(),
434
+ installation: { teamId },
435
+ task: read
436
+ }) : await read();
437
+ } catch (error) {
438
+ if (error instanceof AttachmentDownloadError) throwApiError(409, error.message, error);
439
+ throw error;
440
+ }
441
+ return new Response(file.body, { headers: {
442
+ "cache-control": "private, no-store",
443
+ "content-disposition": contentDisposition(attachment.filename, attachment.contentType, args.download),
444
+ "content-length": String(file.bytes),
445
+ "content-type": attachment.contentType,
446
+ "x-content-type-options": "nosniff"
447
+ } });
448
+ }
449
+ /**
366
450
  * Answer one attachment read for an authorized viewer, with one byte range
367
451
  * when the request asks for it. Media players need ranges to play and seek.
368
452
  *
369
453
  * Missing conversations, missing attachments, purge-marked rows, and viewers
370
- * without private-content access all answer 404.
454
+ * without private-content access all answer 404. A large Slack file that
455
+ * Junior never stored also needs a signed-in viewer. The row lookup is scoped to
456
+ * the conversation, so a Slack download only ever starts from a row that
457
+ * ingest created there.
371
458
  */
372
459
  async function conversationAttachmentResponse(args) {
373
- if (!(await readConversationAccessFromSql(getDb(), [args.conversationId], args.viewer)).get(args.conversationId)?.canViewPrivateContent) notFound();
460
+ const access = await requireAttachmentAccess(args.conversationId, args.viewer);
374
461
  const attachment = await readLiveAttachment({
375
462
  attachmentId: args.attachmentId,
376
463
  conversationId: args.conversationId,
377
464
  db: getSqlExecutor()
378
465
  });
379
466
  if (!attachment || attachment.storageProvider !== args.storage.provider) notFound();
467
+ if (attachment.storageKey === null) {
468
+ if (!args.viewer) throwApiError(401, "Authentication required.");
469
+ return await slackFileResponse({
470
+ attachment,
471
+ download: args.download,
472
+ headOnly: args.headOnly,
473
+ storage: args.storage,
474
+ teamId: access.tenant?.provider === "slack" ? parseSlackTeamId(access.tenant.providerTenantId) : void 0
475
+ });
476
+ }
380
477
  const headers = new Headers({
381
478
  "accept-ranges": "bytes",
382
479
  "cache-control": "private, no-store",
@@ -392,7 +489,7 @@ async function conversationAttachmentResponse(args) {
392
489
  }
393
490
  const body = await args.storage.get(attachment.storageKey, range);
394
491
  if (!body) notFound();
395
- headers.set("content-disposition", contentDisposition(attachment.filename, attachment.contentType));
492
+ headers.set("content-disposition", contentDisposition(attachment.filename, attachment.contentType, args.download));
396
493
  headers.set("content-type", attachment.contentType);
397
494
  if (!range) {
398
495
  headers.set("content-length", String(attachment.bytes));
@@ -405,6 +502,11 @@ async function conversationAttachmentResponse(args) {
405
502
  status: 206
406
503
  });
407
504
  }
505
+ async function requireAttachmentAccess(conversationId, viewer) {
506
+ const access = (await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId);
507
+ if (!access?.canViewPrivateContent) notFound();
508
+ return access;
509
+ }
408
510
  function notFound() {
409
511
  throwApiError(404, "Attachment not found.");
410
512
  }
@@ -1060,9 +1162,9 @@ function createConversationRoutes(options) {
1060
1162
  });
1061
1163
  app.post("/attachment-uploads", requireViewer, bodyLimit({ maxSize: 8192 }), validateRequest("json", createAttachmentUploadBodySchema, "Invalid request body."), async (context) => jsonResponse(attachmentUploadSchema, await createAttachmentUploadForViewer(context.get("viewer"), context.req.valid("json"), options.attachmentStorage)));
1062
1164
  app.put("/attachment-uploads/:uploadId", requireViewer, bodyLimit({
1063
- maxSize: MAX_INPUT_ATTACHMENT_BYTES,
1165
+ maxSize: MAX_ATTACHMENT_BYTES,
1064
1166
  onError: () => {
1065
- throwApiError(413, "Files must be 25 MB or less.");
1167
+ throwApiError(413, `Files must be ${MAX_ATTACHMENT_BYTES / 1024 / 1024} MB or less.`);
1066
1168
  }
1067
1169
  }), validateRequest("param", attachmentUploadParamsSchema, "Invalid route parameters."), async (context) => {
1068
1170
  await writeAttachmentUploadForViewer({
@@ -1097,6 +1199,7 @@ function createConversationRoutes(options) {
1097
1199
  app.patch("/:conversationId/delivery", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", conversationDeliveryBodySchema, "Invalid request body."), async (context) => jsonResponse(conversationDeliveryResponseSchema, await setConversationDeliveryForViewer(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json"))));
1098
1200
  app.patch("/:conversationId/subscription", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", conversationSubscriptionBodySchema, "Invalid request body."), async (context) => jsonResponse(conversationSubscriptionResponseSchema, await setConversationSubscription(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json"))));
1099
1201
  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"))));
1202
+ app.post("/:conversationId/annotations", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", attachObjectLinkBodySchema, "Invalid request body."), async (context) => jsonResponse(attachObjectLinkResponseSchema, await attachObjectLink(context.get("viewer"), context.req.valid("param").conversationId, context.req.valid("json").url)));
1100
1203
  app.put("/:conversationId/read-position", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", conversationReadPositionSchema, "Invalid request body."), async (context) => {
1101
1204
  const viewer = context.get("viewer");
1102
1205
  const { conversationId } = context.req.valid("param");
@@ -1157,12 +1260,15 @@ function createConversationRoutes(options) {
1157
1260
  const body = context.req.valid("json");
1158
1261
  return jsonResponse(cancelConversationPendingMessagesResponseSchema, await cancelConversationPendingMessagesForViewer(viewer, conversationId, body));
1159
1262
  });
1160
- app.get("/:conversationId/attachments/:attachmentId", validateRequest("param", conversationAttachmentParamsSchema, "Invalid route parameters."), async (context) => {
1263
+ app.get("/:conversationId/attachments/:attachmentId", validateRequest("param", conversationAttachmentParamsSchema, "Invalid route parameters."), validateRequest("query", conversationAttachmentQuerySchema, "Invalid query parameters."), async (context) => {
1161
1264
  const { attachmentId, conversationId } = context.req.valid("param");
1265
+ const { download } = context.req.valid("query");
1162
1266
  const viewer = context.get("viewer");
1163
1267
  return await conversationAttachmentResponse({
1164
1268
  attachmentId,
1165
1269
  conversationId,
1270
+ download: download === true,
1271
+ headOnly: context.req.method === "HEAD",
1166
1272
  range: context.req.header("range"),
1167
1273
  storage: options.attachmentStorage,
1168
1274
  ...viewer ? { viewer } : void 0
@@ -2050,6 +2156,158 @@ function createLocationRoutes() {
2050
2156
  });
2051
2157
  return app;
2052
2158
  }
2159
+ // src/chat/images/fetch.ts
2160
+ /** The largest image that Junior fetches. */
2161
+ const MAX_IMAGE_BYTES = 5242880;
2162
+ const FETCH_TIMEOUT_MS = 5e3;
2163
+ /**
2164
+ * Fetch one image through the address guard. Accept only bytes of a known
2165
+ * image format.
2166
+ */
2167
+ async function fetchImage(image) {
2168
+ const { location, ...request } = image;
2169
+ const url = location ? await location() : request.url;
2170
+ if (!url) return { failure: "not_found" };
2171
+ const fetched = await guardedFetch({
2172
+ ...location ? {
2173
+ hosts: request.hosts,
2174
+ url
2175
+ } : request,
2176
+ accept: "image/*",
2177
+ maxBytes: MAX_IMAGE_BYTES,
2178
+ timeoutMs: FETCH_TIMEOUT_MS
2179
+ });
2180
+ if ("failure" in fetched) return fetched;
2181
+ const contentType = detectImageMediaType(fetched.bytes);
2182
+ return contentType ? {
2183
+ bytes: fetched.bytes,
2184
+ contentType
2185
+ } : { failure: "not_an_image" };
2186
+ }
2187
+ // src/chat/images/read.ts
2188
+ /**
2189
+ * Serve external images from Junior. Each source checks that the viewer may
2190
+ * see an image and names its address. Junior fetches the image once, scales
2191
+ * it to the asked width as WebP, and keeps each width in the state cache.
2192
+ */
2193
+ const IMAGE_CACHE_TTL_MS = 864e5;
2194
+ const IMAGE_FAILURE_TTL_MS = 3e5;
2195
+ const IMAGE_SYSTEM_ACTOR = {
2196
+ platform: "system",
2197
+ name: "image"
2198
+ };
2199
+ const CORE_SOURCES = {
2200
+ avatar: (_viewer, identityId) => readAvatarFetch(getDb(), identityId),
2201
+ public: async (_viewer, url) => ({ url })
2202
+ };
2203
+ function pluginSource(plugin) {
2204
+ const images = plugin.images;
2205
+ if (!images) return void 0;
2206
+ const name = plugin.manifest.name;
2207
+ return (viewer, ref) => images.resolve({
2208
+ cache: createPluginCache(name),
2209
+ db: getDb(),
2210
+ egress: createPluginEgress({
2211
+ credentialContext: credentialContextForActor(IMAGE_SYSTEM_ACTOR),
2212
+ pluginAuth: { async handleAuthRequired() {} }
2213
+ }),
2214
+ log: createPluginLogger(name),
2215
+ plugin: { name },
2216
+ viewer
2217
+ }, ref);
2218
+ }
2219
+ function findSource(source) {
2220
+ if (Object.hasOwn(CORE_SOURCES, source)) return CORE_SOURCES[source];
2221
+ const plugin = getPlugins().find((candidate) => candidate.manifest.name === source);
2222
+ return plugin && pluginSource(plugin);
2223
+ }
2224
+ async function scaleImage(bytes, contentType, width, host) {
2225
+ try {
2226
+ const { default: sharp } = await import("sharp");
2227
+ return {
2228
+ contentType: "image/webp",
2229
+ data: (await sharp(bytes).rotate().resize({
2230
+ width,
2231
+ withoutEnlargement: true
2232
+ }).webp({ quality: 80 }).toBuffer()).toString("base64")
2233
+ };
2234
+ } catch (error) {
2235
+ logWarn("image.resize.failed", {
2236
+ "server.address": host,
2237
+ "exception.message": error instanceof Error ? error.message : String(error)
2238
+ });
2239
+ return {
2240
+ contentType,
2241
+ data: bytes.toString("base64")
2242
+ };
2243
+ }
2244
+ }
2245
+ /**
2246
+ * Read one image at one width for a viewer. Return nothing when the source
2247
+ * is unknown, the viewer may not see the image, or the fetch fails.
2248
+ */
2249
+ async function readImage(viewer, image, width) {
2250
+ const source = findSource(image.source);
2251
+ const request = source && await source(viewer, image.ref);
2252
+ if (!request || !URL.canParse(request.url)) return void 0;
2253
+ const host = new URL(request.url).hostname;
2254
+ const key = `image:${image.source}:${width}:${createHash("sha256").update(request.url).digest("hex")}`;
2255
+ return await createCache(getStateAdapter(), "core").getOrLoad(key, async () => {
2256
+ const fetched = await fetchImage(request);
2257
+ if ("failure" in fetched) {
2258
+ logWarn("image.fetch.failed", {
2259
+ "app.reason": fetched.failure,
2260
+ "server.address": host
2261
+ });
2262
+ return {
2263
+ value: null,
2264
+ ttlMs: IMAGE_FAILURE_TTL_MS
2265
+ };
2266
+ }
2267
+ return {
2268
+ value: await scaleImage(fetched.bytes, fetched.contentType, width, host),
2269
+ ttlMs: IMAGE_CACHE_TTL_MS
2270
+ };
2271
+ }) ?? void 0;
2272
+ }
2273
+ // src/api/images/response.ts
2274
+ const VERSIONED_CACHE_CONTROL = "private, max-age=31536000, immutable";
2275
+ const UNVERSIONED_CACHE_CONTROL = "private, max-age=86400";
2276
+ /** Send one served image with the headers of every Junior image route. */
2277
+ function imageResponse(served, versioned) {
2278
+ return new Response(Buffer.from(served.data, "base64"), { headers: {
2279
+ "cache-control": versioned ? VERSIONED_CACHE_CONTROL : UNVERSIONED_CACHE_CONTROL,
2280
+ "content-security-policy": "default-src 'none'; sandbox",
2281
+ "content-type": served.contentType,
2282
+ vary: "Authorization, Cookie",
2283
+ "x-content-type-options": "nosniff"
2284
+ } });
2285
+ }
2286
+ // src/api/schema/image.ts
2287
+ /** Route parameters for one image. */
2288
+ const imageParamsSchema = z.object({ id: z.string().min(1).max(4e3) }).strict();
2289
+ /** The width of one image, from the fixed set, and its optional version. */
2290
+ const imageQuerySchema = z.object({
2291
+ v: z.string().min(1).max(64).optional(),
2292
+ w: z.string().transform(Number).refine((width) => IMAGE_WIDTHS.some((allowed) => allowed === width))
2293
+ }).strict();
2294
+ // src/api/images/routes.ts
2295
+ /**
2296
+ * Create the route that serves external images from Junior, so browsers
2297
+ * never load them from another host. The path has a signed id, never the
2298
+ * address of the image.
2299
+ */
2300
+ function createImageRoutes() {
2301
+ const app = new Hono();
2302
+ app.get("/:id", requireViewer, validateRequest("param", imageParamsSchema, "Invalid route parameters."), validateRequest("query", imageQuerySchema, "Invalid image width."), async (context) => {
2303
+ const image = decodeImageId(context.req.valid("param").id);
2304
+ const { v, w } = context.req.valid("query");
2305
+ const served = image && await readImage(context.get("viewer"), image, w);
2306
+ if (!served) throwApiError(404, "Image not found.");
2307
+ return imageResponse(served, Boolean(v));
2308
+ });
2309
+ return app;
2310
+ }
2053
2311
  // src/api/people/code.ts
2054
2312
  /** Read person-scoped native code activity for one People profile. */
2055
2313
  async function readPeopleCode(email) {
@@ -2482,7 +2740,7 @@ async function readPeoplePluginReports(args) {
2482
2740
  reports: [],
2483
2741
  source: "plugins"
2484
2742
  });
2485
- const { getPluginProfileReports } = await import("./projection-DEdP1q6f.js").then((n) => n.nr);
2743
+ const { getPluginProfileReports } = await import("./projection-CQNDOi82.js").then((n) => n.nr);
2486
2744
  return pluginOperationalReportFeedSchema.parse({
2487
2745
  generatedAt: new Date(nowMs).toISOString(),
2488
2746
  reports: await getPluginProfileReports({
@@ -2732,29 +2990,17 @@ async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
2732
2990
  };
2733
2991
  }
2734
2992
  // src/api/people/routes.ts
2735
- const AVATAR_IMMUTABLE_CACHE_CONTROL = "private, max-age=31536000, immutable";
2736
2993
  /** Create the HTTP routes owned by the People API. */
2737
2994
  function createPeopleRoutes() {
2738
2995
  const app = new Hono();
2739
2996
  app.get("/avatars/:identityId", requireViewer, validateRequest("param", avatarParamsSchema, "Invalid route parameters."), async (context) => {
2740
2997
  const { identityId } = context.req.valid("param");
2741
- const avatar = await readAvatarImage(getDb(), getStateAdapter(), identityId);
2742
- if (!avatar) throwApiError(404, "Avatar not found.");
2743
- const etag = `"${avatar.version}"`;
2744
- const headers = {
2745
- "cache-control": context.req.query("v") === avatar.version ? AVATAR_IMMUTABLE_CACHE_CONTROL : "private, no-cache",
2746
- etag
2747
- };
2748
- if (context.req.header("if-none-match") === etag) return new Response(null, {
2749
- headers,
2750
- status: 304
2751
- });
2752
- return new Response(Buffer.from(avatar.image.data, "base64"), { headers: {
2753
- ...headers,
2754
- "content-security-policy": "default-src 'none'; sandbox",
2755
- "content-type": avatar.image.contentType,
2756
- "x-content-type-options": "nosniff"
2757
- } });
2998
+ const served = await readImage(context.get("viewer"), {
2999
+ ref: identityId,
3000
+ source: "avatar"
3001
+ }, 128);
3002
+ if (!served) throwApiError(404, "Avatar not found.");
3003
+ return imageResponse(served, context.req.query("v") !== void 0);
2758
3004
  });
2759
3005
  app.get("/me/spend", requireViewer, async (context) => {
2760
3006
  const viewer = context.get("viewer");
@@ -2932,6 +3178,24 @@ function createServiceAccountRoutes() {
2932
3178
  });
2933
3179
  return app;
2934
3180
  }
3181
+ // src/api/cache-warming/routes.ts
3182
+ /**
3183
+ * Create admin-only routes that show and close the cache warming breakers.
3184
+ *
3185
+ * A breaker stops warming for every Conversation, so only a Junior admin can
3186
+ * close one before it closes by itself.
3187
+ */
3188
+ function createCacheWarmingRoutes() {
3189
+ const app = new Hono();
3190
+ app.get("/breakers", requireAdmin, async () => jsonResponse(cacheWarmingBreakerListSchema, { breakers: await breakerStates(await connectedState()) }));
3191
+ app.delete("/breakers/:provider", requireAdmin, validateRequest("param", cacheWarmingBreakerParamsSchema, "Invalid provider."), async (context) => {
3192
+ const { provider } = context.req.valid("param");
3193
+ if (!await closeBreaker(await connectedState(), provider)) throwApiError(404, "Breaker not found.");
3194
+ logInfo("dashboard.cache_warming.breaker_closed", { "app.cache_warming.provider": provider });
3195
+ return jsonResponse(closeCacheWarmingBreakerResponseSchema, { closed: true });
3196
+ });
3197
+ return app;
3198
+ }
2935
3199
  // src/chat/plugins/user-pages.ts
2936
3200
  /**
2937
3201
  * Runtime ownership for plugin user pages.
@@ -3515,7 +3779,7 @@ function readDescriptionText(home) {
3515
3779
  }
3516
3780
  /** Read discovered skills for runtime diagnostics and the Automation editor. */
3517
3781
  async function readSkillReports() {
3518
- const { discoverSkills } = await import("./skills-DpBQoeHV.js").then((n) => n.o);
3782
+ const { discoverSkills } = await import("./skills-CmNG0dHb.js").then((n) => n.o);
3519
3783
  const skills = await discoverSkills();
3520
3784
  return skillReportsSchema.parse(skills.map((skill) => ({
3521
3785
  name: skill.name,
@@ -3529,7 +3793,7 @@ async function readSkillReports() {
3529
3793
  * what the skill tells Junior. Returns null when no skill has that name.
3530
3794
  */
3531
3795
  async function readSkillDetailReport(name) {
3532
- const { discoverSkills, findSkillByName, parseSkillFile } = await import("./skills-DpBQoeHV.js").then((n) => n.o);
3796
+ const { discoverSkills, findSkillByName, parseSkillFile } = await import("./skills-CmNG0dHb.js").then((n) => n.o);
3533
3797
  const skill = findSkillByName(name, await discoverSkills());
3534
3798
  if (!skill) return null;
3535
3799
  const parsed = parseSkillFile(await fs.readFile(path.join(skill.skillPath, "SKILL.md"), "utf8"), skill.name);
@@ -3544,7 +3808,7 @@ async function readSkillDetailReport(name) {
3544
3808
  }
3545
3809
  /** Read safe configured plugin metadata for authenticated runtime diagnostics. */
3546
3810
  async function readPlugins() {
3547
- const { pluginCatalogRuntime } = await import("./catalog-runtime-DaBaHY7u.js").then((n) => n.t);
3811
+ const { pluginCatalogRuntime } = await import("./catalog-runtime-BEY6EGRi.js").then((n) => n.t);
3548
3812
  return pluginsSchema.parse(pluginCatalogRuntime.getProviders().map((plugin) => ({
3549
3813
  configKeys: plugin.manifest.configKeys ?? [],
3550
3814
  description: plugin.manifest.description,
@@ -3556,7 +3820,7 @@ async function readPlugins() {
3556
3820
  async function readRuntimeInfoReport() {
3557
3821
  const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
3558
3822
  import("./package-discovery-DJhGdS4c.js").then((n) => n.r),
3559
- import("./catalog-runtime-DaBaHY7u.js").then((n) => n.t),
3823
+ import("./catalog-runtime-BEY6EGRi.js").then((n) => n.t),
3560
3824
  readPlugins(),
3561
3825
  readSkillReports()
3562
3826
  ]);
@@ -3573,7 +3837,7 @@ async function readRuntimeInfoReport() {
3573
3837
  /** Read sanitized operational summaries contributed by plugins. */
3574
3838
  async function readPluginOperationalReportFeed() {
3575
3839
  const nowMs = Date.now();
3576
- const { getPluginOperationalReports } = await import("./projection-DEdP1q6f.js").then((n) => n.nr);
3840
+ const { getPluginOperationalReports } = await import("./projection-CQNDOi82.js").then((n) => n.nr);
3577
3841
  return pluginOperationalReportFeedSchema.parse({
3578
3842
  source: "plugins",
3579
3843
  generatedAt: new Date(nowMs).toISOString(),
@@ -3611,6 +3875,8 @@ function createJuniorApi(options = {}) {
3611
3875
  app.route("/api/notifications", createNotificationRoutes());
3612
3876
  app.route("/api/personal-tokens", createPersonalTokenRoutes());
3613
3877
  app.route("/api/service-accounts", createServiceAccountRoutes());
3878
+ app.route("/api/cache-warming", createCacheWarmingRoutes());
3879
+ app.route("/api/images", createImageRoutes());
3614
3880
  app.route("/api/objects", createObjectRoutes());
3615
3881
  app.route("/api/people", createPeopleRoutes());
3616
3882
  app.route("/api/locations", createLocationRoutes());
@@ -1,6 +1,6 @@
1
1
  import { n as ConversationWorkQueue, t as ConversationQueueMessage } from "./queue-CZyYgPF0.js";
2
- import { t as ConversationStore } from "./db-B07FtU9g.js";
3
- import "./schema-DbuWR-DN.js";
2
+ import { t as ConversationStore } from "./db-BdUHQhrC.js";
3
+ import "./schema-CdZFn7Qd.js";
4
4
  import { n as JuniorPluginSet } from "./plugins-B_0Cr0MO.js";
5
5
  import "./sentry-DrKC2NeM.js";
6
6
  import { Hono } from "hono";
@@ -11,12 +11,12 @@ import "ai";
11
11
  import "drizzle-orm";
12
12
  import { Destination, OwnedObjectAnnotation, PluginRegistration, Source, User } from "@sentry/junior-plugin-api";
13
13
  import "@earendil-works/pi-agent-core";
14
+ import { Message, StateAdapter } from "chat";
14
15
  import "@earendil-works/pi-ai";
15
16
  import "@modelcontextprotocol/sdk/client/auth.js";
16
17
  import { Client } from "@modelcontextprotocol/sdk/client";
17
18
  import "@sinclair/typebox";
18
19
  import { SlackAdapter } from "@chat-adapter/slack";
19
- import { Message, StateAdapter } from "chat";
20
20
  interface BotModelConfig {
21
21
  /** Model that runs every agent Turn. */
22
22
  modelId?: string;
@@ -155,6 +155,11 @@ declare const inboundMessageSchema: z.ZodObject<{
155
155
  }, z.core.$strip>>>;
156
156
  }, z.core.$strict>;
157
157
  type InboundMessage = z.output<typeof inboundMessageSchema>;
158
+ /**
159
+ * Ends what a conversation owns before its work stops for good. It runs
160
+ * under the conversation lock, before the stop is written.
161
+ */
162
+ type BeforeWorkStops = (conversationId: string, inboundMessageIds: readonly string[]) => Promise<void>;
158
163
  interface ConversationWorkerContext {
159
164
  attempt: InboxAttempt;
160
165
  checkIn(): Promise<boolean>;
@@ -197,6 +202,7 @@ interface ConversationWorkerResult {
197
202
  delayMs?: number;
198
203
  }
199
204
  interface ProcessConversationQueueMessageOptions {
205
+ beforeWorkStops?: BeforeWorkStops;
200
206
  checkInIntervalMs?: number;
201
207
  conversationStore?: ConversationStore;
202
208
  /** Slack installation lookup for work that runs after the Run ends. */
@@ -235,6 +241,11 @@ interface JuniorDashboardOptions {
235
241
  trustedOrigins?: string[];
236
242
  }
237
243
  interface JuniorAppOptions extends BotModelConfig {
244
+ /**
245
+ * Name Junior uses for itself, such as its Slack bot username. Defaults to
246
+ * `JUNIOR_BOT_NAME`, then `junior`.
247
+ */
248
+ botName?: string;
238
249
  /**
239
250
  * Generate a durable Brief after each completed Turn. This costs one
240
251
  * default-model call per completed Turn. Disabled by default.
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--ky-Eu33.js";
1
+ import { i as JuniorDashboardOptions, n as JuniorAppOptions, r as createApp, t as JuniorApp } from "./app-HDZglaIu.js";
2
2
  import { i as defineJuniorPlugins, n as JuniorPluginSet, r as JuniorPluginSetOptions, t as JuniorPluginInput } from "./plugins-B_0Cr0MO.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 };