@sentry/junior 0.299.0 → 0.300.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-S5UkjNK3.js} +5 -4
  2. package/dist/{admin-1VwEXztm.js → admin-UrTniSPO.js} +2 -2
  3. package/dist/{agent-runner-Ciet8_nn.js → agent-runner-bY4_0UPm.js} +508 -203
  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 +293 -61
  8. package/dist/{app--ky-Eu33.d.ts → app-D-AcIcCV.d.ts} +13 -2
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +57 -219
  11. package/dist/{automation-M3RFJUBf.js → automation-Dw82oQ-h.js} +2 -2
  12. package/dist/{background-compaction-queue-CnimvRdk.js → background-compaction-queue-B6U3060-.js} +8 -4
  13. package/dist/{briefs-CwzvgdCa.js → briefs-DqiwWu-n.js} +3 -3
  14. package/dist/{catalog-runtime-DaBaHY7u.js → catalog-runtime-D1oYNv04.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-9nHoFiJP.js} +39 -8
  23. package/dist/{connections-Dy0hPdUq.js → connections-DZjTN3JC.js} +6 -6
  24. package/dist/{continue-in-slack-DIOjFj76.js → continue-in-slack-Dtv7_U42.js} +6 -6
  25. package/dist/{conversation-fCWD9Az3.js → conversation-Dyjq2CZ8.js} +19 -8
  26. package/dist/{conversation-feed-BPK8vkkZ.js → conversation-feed-CcDxlrlQ.js} +23 -2
  27. package/dist/{conversation-privacy-DUgtRkf8.js → conversation-privacy-D-5HTXjS.js} +1 -1
  28. package/dist/{conversation-turn-DkJB6yMF.js → conversation-turn-Cxl8WZD7.js} +17 -17
  29. package/dist/{credential-sync-RX24Y8aY.js → credential-sync-C49ClwDX.js} +15 -15
  30. package/dist/{db-B07FtU9g.d.ts → db-2resqBh1.d.ts} +1 -1
  31. package/dist/{db-COYOGzYS.js → db-BJNo6fK5.js} +13 -8
  32. package/dist/{executor-BWmAgSyi.js → executor-DBIaOeJ_.js} +9 -4
  33. package/dist/instrumentation.js +14 -5
  34. package/dist/{lineage-D-5jm_oj.js → lineage-0dereG7H.js} +2 -2
  35. package/dist/{logging-DPLEa8Bn.js → logging-BIclibct.js} +1 -1
  36. package/dist/{message-BIHR1yRk.js → message-dkOl-Iii.js} +8 -8
  37. package/dist/{model-input-BPZYH8Nd.js → model-input-CLo9TaUd.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-WmpjfJgQ.js} +2 -2
  41. package/dist/{plugins-CBW2Prb_.js → plugins-BBX07Jzt.js} +1 -1
  42. package/dist/{projection-DEdP1q6f.js → projection-w_X-zi7v.js} +3742 -3624
  43. package/dist/{prompt-4M98h_tC.js → prompt-B1Xw46-S.js} +4 -4
  44. package/dist/{registry-BTKmKM-r.js → registry-BmP5vnlj.js} +2 -2
  45. package/dist/{resolve-B8hXNVZ3.js → resolve-goo34bJK.js} +3 -3
  46. package/dist/{result-g-XAaOj6.js → result-PVBeU0Wf.js} +9 -9
  47. package/dist/{runner-BlPSA5A8.js → runner-DKrfvNV6.js} +9 -9
  48. package/dist/{sandbox-egress-signals-Pai-MzEY.js → sandbox-egress-signals-DsUcqrI0.js} +1 -1
  49. package/dist/{schema-BNnY_trV.js → schema-C9iNFz5n.js} +20 -16
  50. package/dist/{schema-DbuWR-DN.d.ts → schema-Dns-sTas.d.ts} +219 -6
  51. package/dist/{service-account-BYGZ08DQ.js → service-account-CMAAloAL.js} +3 -3
  52. package/dist/{service-account-9OLNQMyz.js → service-account-CmowamcB.js} +4 -4
  53. package/dist/{session-stop-2XJrcNCy.js → session-stop-BcAXze8a.js} +15 -41
  54. package/dist/{skills-DpBQoeHV.js → skills-DfsazET6.js} +2 -2
  55. package/dist/{slack-conversation-unfurl-BcDIWo67.js → slack-conversation-unfurl-CzQonuWz.js} +7 -7
  56. package/dist/{spawn-09GssFod.js → spawn-C7o0FDDp.js} +6 -6
  57. package/dist/{state-Cufq0_rH.js → state-zSilNpbi.js} +2 -2
  58. package/dist/{statuses-B8mUfghF.js → statuses-Hn-HsOph.js} +86 -2
  59. package/dist/{stop-U7iUrR1g.js → stop-CFOujp8C.js} +2938 -76
  60. package/dist/{store-CSgUTMdv.js → store-Dkeis_8o.js} +9 -9
  61. package/dist/{store-BHiaHCQu.js → store-E3x2Fg_F.js} +5 -5
  62. package/dist/{task-queue-bMNq0clp.js → task-queue-D-hCqdZW.js} +3 -3
  63. package/dist/{task-runner-B__rxwxU.js → task-runner-vohUPLHe.js} +8 -8
  64. package/dist/{thread-context-d0ceWbVT.js → thread-context-BzvdkgI9.js} +8 -8
  65. package/dist/{turn-session-routing-BVZHBFCF.js → turn-session-routing-Bo_LxFum.js} +5 -5
  66. package/dist/{turn-user-message-BEw7acTP.js → turn-user-message-D5RnVmxQ.js} +3 -3
  67. package/dist/{users-BK3dbxZL.js → users-2bggndVg.js} +3 -3
  68. package/dist/{validation-BDVJjO2E.js → validation-BbWikeSa.js} +1 -1
  69. package/dist/{version-DQgZoQ3D.js → version-GVBMW2jA.js} +1 -1
  70. package/dist/version.js +1 -1
  71. package/dist/{viewer-CAWfFo29.js → viewer-BpxRliyO.js} +16 -114
  72. package/dist/{warmup-9ySPacF9.js → warmup-BW2qwnal.js} +18 -16
  73. package/dist/{worker-D8jJO-WO.js → worker-Cbd-iuwZ.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,39 @@
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 { $i as create, Cr as saveNotificationSchedule, Do as readConversationBriefThrough, Fr as listWaitingConversations, Gi as listWorkspaces, Gr as isOnlyAssignee, Hi as deleteWorkspace, Ir as reviewItemsNeedingUserVersionQuery, Ji as WorkspaceValidationError, Ki as listWorkspacesByRepository, Lr as searchReviewItems, Ni as getDashboardSettingsLink, Sr as readNotificationSchedule, Tr as isPausedBySlack, Ui as getWorkspace, Vi as createWorkspace, Vo as readSlackAttachmentSource, Vr as canActOnReviewItem, Xr as reviewItemReaderForUser, Ya as SANDBOX_RUNTIME, Za as workspaceRepoCheckoutPath, Zn as createUserTokenStore, Zr as reviewItemReaderForUserInConversation, _r as readWebPushConfig, _s as createPluginCache, br as deletePushSubscription, cs as createPluginAnnotations, dr as getPlugins, ea as hash, ho as createPluginLogger, ko as readConversationEventPage, kr as countReviewItemsNeedingUser, ls as listConversationAnnotations, qi as updateWorkspace, vo as createConversationAccessReader, vr as sendPushNotificationToUser, wr as savePushSubscription, xr as listPushSubscriptions, yo as readConversationAccessFromSql, yr as resolveNotificationTimezone } from "./projection-w_X-zi7v.js";
2
+ import { R as escapeXml, Z as getAttachmentStorage, n as botConfig } from "./config-9nHoFiJP.js";
3
+ import { h as logWarn, m as logInfo, p as logException } from "./logging-BIclibct.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-BJNo6fK5.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-DBIaOeJ_.js";
7
+ import { r as getStateAdapter } from "./adapter-S5UkjNK3.js";
8
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-D1oYNv04.js";
9
+ 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-bY4_0UPm.js";
10
+ import { n as briefEntriesFromReportEvents, u as completeText } from "./prompt-B1Xw46-S.js";
11
11
  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";
12
+ import { c as readViewerAvatarUrl, d as updateViewerDisplayName, l as resolveViewerUser, m as readAvatarFetch, t as findUserByEmail } from "./viewer-BpxRliyO.js";
13
+ 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-Dyjq2CZ8.js";
14
+ import { R as getEventCatalog, S as addConversationNote, _ as readUserCustomization, b as isExperimentalFeatureEnabled, v as saveUserCustomization } from "./session-stop-BcAXze8a.js";
15
+ import { Dt as GAP_SEGMENTS, Mt as gapHistogramReport, a as segmentGapsKey, d as listChildAgents } from "./warmup-BW2qwnal.js";
16
+ import { l as getVercelConversationWorkQueue } from "./background-compaction-queue-B6U3060-.js";
17
+ import { u as automationEventCatalog } from "./turn-session-routing-Bo_LxFum.js";
18
+ import { d as INLINE_VIDEO_TYPES, f as INPUT_IMAGE_TYPES, g as userCustomizationSchema, p as detectImageMediaType } from "./statuses-Hn-HsOph.js";
19
+ import { s as getSandboxResources, t as getCachedSnapshot } from "./resolve-goo34bJK.js";
20
+ import { n as finishServiceAccountSignIn, o as serviceAccountPlugins, r as getServiceAccountStatus, s as startServiceAccountSignIn, t as disconnectServiceAccount } from "./service-account-CmowamcB.js";
22
21
  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";
22
+ 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-Dw82oQ-h.js";
23
+ import { A as conversationRangeColumns, D as readAutomationTitlesByConversationId, at as AutomationConflictError, j as conversationUsageCostExpr, k as conversationAggregateColumns } from "./store-Dkeis_8o.js";
24
+ import { a as runWithSlackInstallation } from "./users-2bggndVg.js";
25
+ 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-CFOujp8C.js";
26
+ 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-CcDxlrlQ.js";
27
+ import { a as resumeConversationDelivery, i as pauseConversationDelivery, r as canPauseConversationDelivery } from "./conversation-turn-Cxl8WZD7.js";
28
+ import { a as startConnection, n as isConnectableProvider, r as listConnections, s as htmlCallbackResponse, t as disconnectConnection } from "./connections-DZjTN3JC.js";
29
+ import { i as continueConversationInSlack, r as canContinueInSlack, t as BUSY } from "./continue-in-slack-Dtv7_U42.js";
30
+ import { A as revokePersonalTokenResponseSchema, At as pinConversationBodySchema, B as activityDays$1, Ct as archiveConversationResponseSchema, D as personalTokenListSchema, Dt as conversationSubscriptionResponseSchema, E as createdPersonalTokenSchema, Et as conversationSubscriptionBodySchema, F as personalSpendReportSchema, Ft as conversationCatchUpSchema, G as pushSubscriptionBodySchema, H as activitySixHours$1, It as attachmentUploadParamsSchema, J as connectionListSchema, K as pushSubscriptionDeleteBodySchema, L as locationDetailReportSchema, Lt as attachmentUploadSchema, M as actorProfileReportSchema, Mt as reorderPinnedConversationsBodySchema, N as avatarParamsSchema, Nt as reorderPinnedConversationsResponseSchema, Ot as conversationDeliveryBodySchema, P as personParamsSchema, Pt as conversationCatchUpBodySchema, Q as startConnectionResponseSchema, R as locationDirectoryReportSchema, Rt as createAttachmentUploadBodySchema, S as serviceAccountParamsSchema, St as archiveConversationBodySchema, T as createPersonalTokenBodySchema, Tt as conversationAutoArchiveSchema, V as activityHours$1, W as notificationSettingsSchema, Y as connectionParamsSchema, Z as disconnectConnectionResponseSchema, _ as reviewItemParamsSchema, _t as objectLinksReportSchema, a as replyTimeSegmentsReportSchema, at as codeRepositoryReportSchema, b as disconnectServiceAccountResponseSchema, c as workspaceBodySchema, ct as conversationWatchesReportSchema, dt as continueConversationInSlackBodySchema, f as workspaceSchema, ft as continueConversationInSlackResponseSchema, g as reviewItemListSchema, gt as objectLinksQuerySchema, h as reviewItemListQuerySchema, ht as attachObjectLinkResponseSchema, i as statsReportSchema, it as codeRepositoryParamsSchema, j as actorDirectoryReportSchema, jt as pinConversationResponseSchema, k as personalTokenParamsSchema, kt as conversationDeliveryResponseSchema, l as workspaceListSchema, m as reviewItemCountSchema, mt as attachObjectLinkBodySchema, n as versionsSchema, nt as codeOverviewReportSchema, p as reviewItemActionSchema, q as testNotificationResponseSchema, rt as codePersonReportSchema, s as deleteWorkspaceResponseSchema, t as versionsQuerySchema, u as workspaceParamsSchema, ut as conversationChildAgentsReportSchema, v as reviewItemSchema, vt as stopConversationTurnResponseSchema, w as startServiceAccountSignInResponseSchema, wt as archiveDoneConversationsResponseSchema, x as serviceAccountListSchema, xt as conversationOutlineSchema, y as reviewItemWaitingConversationsSchema, yt as conversationStatsReportSchema, z as locationParamsSchema } from "./schema-C9iNFz5n.js";
32
31
  import { Hono } from "hono";
33
32
  import * as z from "zod";
34
33
  import path from "node:path";
35
34
  import { createHash, randomBytes, randomUUID } from "node:crypto";
36
35
  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";
36
+ import { objectPresentation, pluginUserPageContentSchema, pluginUserPageCursorSchema, pluginUserPageFilterSchema, pluginUserPageLinksSchema, pluginUserPageQuerySchema } from "@sentry/junior-plugin-api";
38
37
  import { alias } from "drizzle-orm/pg-core";
39
38
  import fs from "node:fs/promises";
40
39
  import { readFileSync } from "node:fs";
@@ -42,6 +41,52 @@ import { HTTPException } from "hono/http-exception";
42
41
  import { bodyLimit } from "hono/body-limit";
43
42
  import { zValidator } from "@hono/zod-validator";
44
43
  import { createMiddleware } from "hono/factory";
44
+ // src/api/objects/attach.ts
45
+ function sameLink(left, right) {
46
+ const key = (url) => url.replace(/\/+$/, "");
47
+ return key(left) === key(right);
48
+ }
49
+ /**
50
+ * Attach a linked object to a Conversation for one participant. The
51
+ * Annotation and the Conversation note save no title. The note tells the
52
+ * next Turn the type and the read tool of the object, so the agent reads it
53
+ * live. Nothing is attached when the viewer cannot write to the
54
+ * Conversation, the Conversation takes no web input from people (a Task),
55
+ * or the viewer cannot see the object now.
56
+ */
57
+ async function attachObjectLink(viewer, conversationId, url) {
58
+ const db = getDb();
59
+ if (!(await readConversationAccessFromSql(db, [conversationId], viewer)).get(conversationId)?.isParticipant) throwApiError(404, "Conversation not found.");
60
+ const conversation = await getConversationStore().get({ conversationId });
61
+ if (!conversation || !acceptsWebMessages(conversation)) throwApiError(409, "Conversation does not accept attached objects.");
62
+ const parsed = URL.canParse(url) ? new URL(url) : void 0;
63
+ const resolved = parsed && await resolveObjectLinkNow(viewer, parsed);
64
+ if (!parsed || !resolved || resolved.object.objectType === "person") throwApiError(404, "Object not found.");
65
+ const { linkType, object } = resolved;
66
+ const link = object.url ?? parsed.href;
67
+ if ((await listConversationAnnotations(db, conversationId)).some((annotation) => annotation.url && sameLink(annotation.url, link) || annotation.plugin === linkType.owner && annotation.key === object.key)) return { status: "unchanged" };
68
+ const type = object.displayType ?? objectPresentation(object).label;
69
+ const article = /^[aeiou]/i.test(type) ? "an" : "a";
70
+ const { readTool } = linkType;
71
+ await addConversationNote({
72
+ conversationId,
73
+ createdAtMs: Date.now(),
74
+ key: `object_attached:${linkType.owner}:${object.key}`,
75
+ 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(" ")
76
+ });
77
+ await createPluginAnnotations({
78
+ conversationId,
79
+ db,
80
+ plugin: linkType.owner
81
+ }).upsert({
82
+ kind: "resource_link",
83
+ key: object.key,
84
+ label: link.slice(0, 256),
85
+ objectType: object.objectType,
86
+ url: link
87
+ });
88
+ return { status: "attached" };
89
+ }
45
90
  // src/api/validation.ts
46
91
  /** Validate one request input and use Junior's stable JSON error contract. */
47
92
  function validateRequest(target, schema, message) {
@@ -331,8 +376,8 @@ async function continueConversationInSlackForViewer(viewer, conversationId, body
331
376
  }
332
377
  // src/api/conversations/attachments.ts
333
378
  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)}`;
379
+ function contentDisposition(filename, contentType, download) {
380
+ return `${!download && INLINE_TYPES.includes(contentType) ? "inline" : "attachment"}; filename="${filename.replace(/[^\x20-\x7e]|["\\]/g, "_")}"; filename*=UTF-8''${encodeURIComponent(filename)}`;
336
381
  }
337
382
  /**
338
383
  * Read one `Range` request header against an object size.
@@ -363,20 +408,71 @@ function parseRangeHeader(header, size) {
363
408
  };
364
409
  }
365
410
  /**
411
+ * Stream a large Slack file that Junior never stored, from Slack through the
412
+ * host, with the conversation's Slack installation. A HEAD request checks
413
+ * that Slack still has the file without downloading it. Ranges are not
414
+ * supported, so media players cannot seek in these files.
415
+ */
416
+ async function slackFileResponse(args) {
417
+ const { attachment, teamId } = args;
418
+ const read = async () => {
419
+ const content = await readAttachmentContent({
420
+ attachment,
421
+ ...teamId ? { readAttachmentSource: readSlackAttachmentSource } : void 0,
422
+ storage: args.storage
423
+ });
424
+ return {
425
+ body: args.headOnly ? null : await content.open(),
426
+ bytes: content.bytes
427
+ };
428
+ };
429
+ let file;
430
+ try {
431
+ file = teamId ? await runWithSlackInstallation({
432
+ adapter: getProductionSlackAdapter(),
433
+ installation: { teamId },
434
+ task: read
435
+ }) : await read();
436
+ } catch (error) {
437
+ if (error instanceof AttachmentDownloadError) throwApiError(409, error.message, error);
438
+ throw error;
439
+ }
440
+ return new Response(file.body, { headers: {
441
+ "cache-control": "private, no-store",
442
+ "content-disposition": contentDisposition(attachment.filename, attachment.contentType, args.download),
443
+ "content-length": String(file.bytes),
444
+ "content-type": attachment.contentType,
445
+ "x-content-type-options": "nosniff"
446
+ } });
447
+ }
448
+ /**
366
449
  * Answer one attachment read for an authorized viewer, with one byte range
367
450
  * when the request asks for it. Media players need ranges to play and seek.
368
451
  *
369
452
  * Missing conversations, missing attachments, purge-marked rows, and viewers
370
- * without private-content access all answer 404.
453
+ * without private-content access all answer 404. A large Slack file that
454
+ * Junior never stored also needs a signed-in viewer. The row lookup is scoped to
455
+ * the conversation, so a Slack download only ever starts from a row that
456
+ * ingest created there.
371
457
  */
372
458
  async function conversationAttachmentResponse(args) {
373
- if (!(await readConversationAccessFromSql(getDb(), [args.conversationId], args.viewer)).get(args.conversationId)?.canViewPrivateContent) notFound();
459
+ const access = await requireAttachmentAccess(args.conversationId, args.viewer);
374
460
  const attachment = await readLiveAttachment({
375
461
  attachmentId: args.attachmentId,
376
462
  conversationId: args.conversationId,
377
463
  db: getSqlExecutor()
378
464
  });
379
465
  if (!attachment || attachment.storageProvider !== args.storage.provider) notFound();
466
+ if (attachment.storageKey === null) {
467
+ if (!args.viewer) throwApiError(401, "Authentication required.");
468
+ return await slackFileResponse({
469
+ attachment,
470
+ download: args.download,
471
+ headOnly: args.headOnly,
472
+ storage: args.storage,
473
+ teamId: access.tenant?.provider === "slack" ? parseSlackTeamId(access.tenant.providerTenantId) : void 0
474
+ });
475
+ }
380
476
  const headers = new Headers({
381
477
  "accept-ranges": "bytes",
382
478
  "cache-control": "private, no-store",
@@ -392,7 +488,7 @@ async function conversationAttachmentResponse(args) {
392
488
  }
393
489
  const body = await args.storage.get(attachment.storageKey, range);
394
490
  if (!body) notFound();
395
- headers.set("content-disposition", contentDisposition(attachment.filename, attachment.contentType));
491
+ headers.set("content-disposition", contentDisposition(attachment.filename, attachment.contentType, args.download));
396
492
  headers.set("content-type", attachment.contentType);
397
493
  if (!range) {
398
494
  headers.set("content-length", String(attachment.bytes));
@@ -405,6 +501,11 @@ async function conversationAttachmentResponse(args) {
405
501
  status: 206
406
502
  });
407
503
  }
504
+ async function requireAttachmentAccess(conversationId, viewer) {
505
+ const access = (await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId);
506
+ if (!access?.canViewPrivateContent) notFound();
507
+ return access;
508
+ }
408
509
  function notFound() {
409
510
  throwApiError(404, "Attachment not found.");
410
511
  }
@@ -1060,9 +1161,9 @@ function createConversationRoutes(options) {
1060
1161
  });
1061
1162
  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
1163
  app.put("/attachment-uploads/:uploadId", requireViewer, bodyLimit({
1063
- maxSize: MAX_INPUT_ATTACHMENT_BYTES,
1164
+ maxSize: MAX_ATTACHMENT_BYTES,
1064
1165
  onError: () => {
1065
- throwApiError(413, "Files must be 25 MB or less.");
1166
+ throwApiError(413, `Files must be ${MAX_ATTACHMENT_BYTES / 1024 / 1024} MB or less.`);
1066
1167
  }
1067
1168
  }), validateRequest("param", attachmentUploadParamsSchema, "Invalid route parameters."), async (context) => {
1068
1169
  await writeAttachmentUploadForViewer({
@@ -1097,6 +1198,7 @@ function createConversationRoutes(options) {
1097
1198
  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
1199
  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
1200
  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"))));
1201
+ 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
1202
  app.put("/:conversationId/read-position", requireViewer, validateRequest("param", conversationParamsSchema, "Invalid route parameters."), validateRequest("json", conversationReadPositionSchema, "Invalid request body."), async (context) => {
1101
1203
  const viewer = context.get("viewer");
1102
1204
  const { conversationId } = context.req.valid("param");
@@ -1157,12 +1259,15 @@ function createConversationRoutes(options) {
1157
1259
  const body = context.req.valid("json");
1158
1260
  return jsonResponse(cancelConversationPendingMessagesResponseSchema, await cancelConversationPendingMessagesForViewer(viewer, conversationId, body));
1159
1261
  });
1160
- app.get("/:conversationId/attachments/:attachmentId", validateRequest("param", conversationAttachmentParamsSchema, "Invalid route parameters."), async (context) => {
1262
+ app.get("/:conversationId/attachments/:attachmentId", validateRequest("param", conversationAttachmentParamsSchema, "Invalid route parameters."), validateRequest("query", conversationAttachmentQuerySchema, "Invalid query parameters."), async (context) => {
1161
1263
  const { attachmentId, conversationId } = context.req.valid("param");
1264
+ const { download } = context.req.valid("query");
1162
1265
  const viewer = context.get("viewer");
1163
1266
  return await conversationAttachmentResponse({
1164
1267
  attachmentId,
1165
1268
  conversationId,
1269
+ download: download === true,
1270
+ headOnly: context.req.method === "HEAD",
1166
1271
  range: context.req.header("range"),
1167
1272
  storage: options.attachmentStorage,
1168
1273
  ...viewer ? { viewer } : void 0
@@ -2050,6 +2155,144 @@ function createLocationRoutes() {
2050
2155
  });
2051
2156
  return app;
2052
2157
  }
2158
+ // src/chat/images/fetch.ts
2159
+ /** The largest image that Junior fetches. */
2160
+ const MAX_IMAGE_BYTES = 5242880;
2161
+ const FETCH_TIMEOUT_MS = 5e3;
2162
+ /**
2163
+ * Fetch one image through the address guard. Accept only bytes of a known
2164
+ * image format.
2165
+ */
2166
+ async function fetchImage(image) {
2167
+ const fetched = await guardedFetch({
2168
+ ...image,
2169
+ accept: "image/*",
2170
+ maxBytes: MAX_IMAGE_BYTES,
2171
+ timeoutMs: FETCH_TIMEOUT_MS
2172
+ });
2173
+ if ("failure" in fetched) return fetched;
2174
+ const contentType = detectImageMediaType(fetched.bytes);
2175
+ return contentType ? {
2176
+ bytes: fetched.bytes,
2177
+ contentType
2178
+ } : { failure: "not_an_image" };
2179
+ }
2180
+ // src/chat/images/read.ts
2181
+ /**
2182
+ * Serve external images from Junior. Each source checks that the viewer may
2183
+ * see an image and names its address. Junior fetches the image once, scales
2184
+ * it to the asked width as WebP, and keeps each width in the state cache.
2185
+ */
2186
+ const IMAGE_CACHE_TTL_MS = 864e5;
2187
+ const IMAGE_FAILURE_TTL_MS = 3e5;
2188
+ const CORE_SOURCES = {
2189
+ avatar: (_viewer, identityId) => readAvatarFetch(getDb(), identityId),
2190
+ public: async (_viewer, url) => ({ url })
2191
+ };
2192
+ function pluginSource(plugin) {
2193
+ const images = plugin.images;
2194
+ if (!images) return void 0;
2195
+ const name = plugin.manifest.name;
2196
+ return (viewer, ref) => images.resolve({
2197
+ cache: createPluginCache(name),
2198
+ db: getDb(),
2199
+ log: createPluginLogger(name),
2200
+ plugin: { name },
2201
+ viewer
2202
+ }, ref);
2203
+ }
2204
+ function findSource(source) {
2205
+ if (Object.hasOwn(CORE_SOURCES, source)) return CORE_SOURCES[source];
2206
+ const plugin = getPlugins().find((candidate) => candidate.manifest.name === source);
2207
+ return plugin && pluginSource(plugin);
2208
+ }
2209
+ async function scaleImage(bytes, contentType, width, host) {
2210
+ try {
2211
+ const { default: sharp } = await import("sharp");
2212
+ return {
2213
+ contentType: "image/webp",
2214
+ data: (await sharp(bytes).rotate().resize({
2215
+ width,
2216
+ withoutEnlargement: true
2217
+ }).webp({ quality: 80 }).toBuffer()).toString("base64")
2218
+ };
2219
+ } catch (error) {
2220
+ logWarn("image.resize.failed", {
2221
+ "server.address": host,
2222
+ "exception.message": error instanceof Error ? error.message : String(error)
2223
+ });
2224
+ return {
2225
+ contentType,
2226
+ data: bytes.toString("base64")
2227
+ };
2228
+ }
2229
+ }
2230
+ /**
2231
+ * Read one image at one width for a viewer. Return nothing when the source
2232
+ * is unknown, the viewer may not see the image, or the fetch fails.
2233
+ */
2234
+ async function readImage(viewer, image, width) {
2235
+ const source = findSource(image.source);
2236
+ const request = source && await source(viewer, image.ref);
2237
+ if (!request || !URL.canParse(request.url)) return void 0;
2238
+ const host = new URL(request.url).hostname;
2239
+ const key = `image:${image.source}:${width}:${createHash("sha256").update(request.url).digest("hex")}`;
2240
+ return await createCache(getStateAdapter(), "core").getOrLoad(key, async () => {
2241
+ const fetched = await fetchImage(request);
2242
+ if ("failure" in fetched) {
2243
+ logWarn("image.fetch.failed", {
2244
+ "app.reason": fetched.failure,
2245
+ "server.address": host
2246
+ });
2247
+ return {
2248
+ value: null,
2249
+ ttlMs: IMAGE_FAILURE_TTL_MS
2250
+ };
2251
+ }
2252
+ return {
2253
+ value: await scaleImage(fetched.bytes, fetched.contentType, width, host),
2254
+ ttlMs: IMAGE_CACHE_TTL_MS
2255
+ };
2256
+ }) ?? void 0;
2257
+ }
2258
+ // src/api/images/response.ts
2259
+ const VERSIONED_CACHE_CONTROL = "private, max-age=31536000, immutable";
2260
+ const UNVERSIONED_CACHE_CONTROL = "private, max-age=86400";
2261
+ /** Send one served image with the headers of every Junior image route. */
2262
+ function imageResponse(served, versioned) {
2263
+ return new Response(Buffer.from(served.data, "base64"), { headers: {
2264
+ "cache-control": versioned ? VERSIONED_CACHE_CONTROL : UNVERSIONED_CACHE_CONTROL,
2265
+ "content-security-policy": "default-src 'none'; sandbox",
2266
+ "content-type": served.contentType,
2267
+ vary: "Authorization, Cookie",
2268
+ "x-content-type-options": "nosniff"
2269
+ } });
2270
+ }
2271
+ // src/api/schema/image.ts
2272
+ /** Route parameters for one image. */
2273
+ const imageParamsSchema = z.object({ id: z.string().min(1).max(4e3) }).strict();
2274
+ /** The width of one image, from the fixed set, and its optional version. */
2275
+ const imageQuerySchema = z.object({
2276
+ v: z.string().min(1).max(64).optional(),
2277
+ w: z.string().transform(Number).refine((width) => IMAGE_WIDTHS.some((allowed) => allowed === width))
2278
+ }).strict();
2279
+ // src/api/images/routes.ts
2280
+ /**
2281
+ * Create the route that serves external images from Junior, so browsers
2282
+ * never load them from another host. The path has a signed id, never the
2283
+ * address of the image.
2284
+ */
2285
+ function createImageRoutes() {
2286
+ const app = new Hono();
2287
+ app.get("/:id", requireViewer, validateRequest("param", imageParamsSchema, "Invalid route parameters."), validateRequest("query", imageQuerySchema, "Invalid image width."), async (context) => {
2288
+ const image = decodeImageId(context.req.valid("param").id);
2289
+ const { v, w } = context.req.valid("query");
2290
+ const served = image && await readImage(context.get("viewer"), image, w);
2291
+ if (!served) throwApiError(404, "Image not found.");
2292
+ return imageResponse(served, Boolean(v));
2293
+ });
2294
+ return app;
2295
+ }
2053
2296
  // src/api/people/code.ts
2054
2297
  /** Read person-scoped native code activity for one People profile. */
2055
2298
  async function readPeopleCode(email) {
@@ -2482,7 +2725,7 @@ async function readPeoplePluginReports(args) {
2482
2725
  reports: [],
2483
2726
  source: "plugins"
2484
2727
  });
2485
- const { getPluginProfileReports } = await import("./projection-DEdP1q6f.js").then((n) => n.nr);
2728
+ const { getPluginProfileReports } = await import("./projection-w_X-zi7v.js").then((n) => n.nr);
2486
2729
  return pluginOperationalReportFeedSchema.parse({
2487
2730
  generatedAt: new Date(nowMs).toISOString(),
2488
2731
  reports: await getPluginProfileReports({
@@ -2732,29 +2975,17 @@ async function readPersonalSpendFromSql(email, nowMs = Date.now()) {
2732
2975
  };
2733
2976
  }
2734
2977
  // src/api/people/routes.ts
2735
- const AVATAR_IMMUTABLE_CACHE_CONTROL = "private, max-age=31536000, immutable";
2736
2978
  /** Create the HTTP routes owned by the People API. */
2737
2979
  function createPeopleRoutes() {
2738
2980
  const app = new Hono();
2739
2981
  app.get("/avatars/:identityId", requireViewer, validateRequest("param", avatarParamsSchema, "Invalid route parameters."), async (context) => {
2740
2982
  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
- } });
2983
+ const served = await readImage(context.get("viewer"), {
2984
+ ref: identityId,
2985
+ source: "avatar"
2986
+ }, 128);
2987
+ if (!served) throwApiError(404, "Avatar not found.");
2988
+ return imageResponse(served, context.req.query("v") !== void 0);
2758
2989
  });
2759
2990
  app.get("/me/spend", requireViewer, async (context) => {
2760
2991
  const viewer = context.get("viewer");
@@ -3515,7 +3746,7 @@ function readDescriptionText(home) {
3515
3746
  }
3516
3747
  /** Read discovered skills for runtime diagnostics and the Automation editor. */
3517
3748
  async function readSkillReports() {
3518
- const { discoverSkills } = await import("./skills-DpBQoeHV.js").then((n) => n.o);
3749
+ const { discoverSkills } = await import("./skills-DfsazET6.js").then((n) => n.o);
3519
3750
  const skills = await discoverSkills();
3520
3751
  return skillReportsSchema.parse(skills.map((skill) => ({
3521
3752
  name: skill.name,
@@ -3529,7 +3760,7 @@ async function readSkillReports() {
3529
3760
  * what the skill tells Junior. Returns null when no skill has that name.
3530
3761
  */
3531
3762
  async function readSkillDetailReport(name) {
3532
- const { discoverSkills, findSkillByName, parseSkillFile } = await import("./skills-DpBQoeHV.js").then((n) => n.o);
3763
+ const { discoverSkills, findSkillByName, parseSkillFile } = await import("./skills-DfsazET6.js").then((n) => n.o);
3533
3764
  const skill = findSkillByName(name, await discoverSkills());
3534
3765
  if (!skill) return null;
3535
3766
  const parsed = parseSkillFile(await fs.readFile(path.join(skill.skillPath, "SKILL.md"), "utf8"), skill.name);
@@ -3544,7 +3775,7 @@ async function readSkillDetailReport(name) {
3544
3775
  }
3545
3776
  /** Read safe configured plugin metadata for authenticated runtime diagnostics. */
3546
3777
  async function readPlugins() {
3547
- const { pluginCatalogRuntime } = await import("./catalog-runtime-DaBaHY7u.js").then((n) => n.t);
3778
+ const { pluginCatalogRuntime } = await import("./catalog-runtime-D1oYNv04.js").then((n) => n.t);
3548
3779
  return pluginsSchema.parse(pluginCatalogRuntime.getProviders().map((plugin) => ({
3549
3780
  configKeys: plugin.manifest.configKeys ?? [],
3550
3781
  description: plugin.manifest.description,
@@ -3556,7 +3787,7 @@ async function readPlugins() {
3556
3787
  async function readRuntimeInfoReport() {
3557
3788
  const [{ homeDir }, { pluginCatalogRuntime }, plugins, skills] = await Promise.all([
3558
3789
  import("./package-discovery-DJhGdS4c.js").then((n) => n.r),
3559
- import("./catalog-runtime-DaBaHY7u.js").then((n) => n.t),
3790
+ import("./catalog-runtime-D1oYNv04.js").then((n) => n.t),
3560
3791
  readPlugins(),
3561
3792
  readSkillReports()
3562
3793
  ]);
@@ -3573,7 +3804,7 @@ async function readRuntimeInfoReport() {
3573
3804
  /** Read sanitized operational summaries contributed by plugins. */
3574
3805
  async function readPluginOperationalReportFeed() {
3575
3806
  const nowMs = Date.now();
3576
- const { getPluginOperationalReports } = await import("./projection-DEdP1q6f.js").then((n) => n.nr);
3807
+ const { getPluginOperationalReports } = await import("./projection-w_X-zi7v.js").then((n) => n.nr);
3577
3808
  return pluginOperationalReportFeedSchema.parse({
3578
3809
  source: "plugins",
3579
3810
  generatedAt: new Date(nowMs).toISOString(),
@@ -3611,6 +3842,7 @@ function createJuniorApi(options = {}) {
3611
3842
  app.route("/api/notifications", createNotificationRoutes());
3612
3843
  app.route("/api/personal-tokens", createPersonalTokenRoutes());
3613
3844
  app.route("/api/service-accounts", createServiceAccountRoutes());
3845
+ app.route("/api/images", createImageRoutes());
3614
3846
  app.route("/api/objects", createObjectRoutes());
3615
3847
  app.route("/api/people", createPeopleRoutes());
3616
3848
  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-2resqBh1.js";
3
+ import "./schema-Dns-sTas.js";
4
4
  import { n as JuniorPluginSet } from "./plugins-B_0Cr0MO.js";
5
5
  import "./sentry-DrKC2NeM.js";
6
6
  import { Hono } from "hono";
@@ -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-D-AcIcCV.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 };