@sentry/junior 0.278.0 → 0.280.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 (90) hide show
  1. package/dist/{actor-B4DYygOB.js → actor-6jsm_v96.js} +1 -1
  2. package/dist/{adapter-BXosqTMx.js → adapter-DVN3iwf9.js} +1 -1
  3. package/dist/{admin-Thn7NfOi.js → admin-Q_UI--9W.js} +1 -1
  4. package/dist/{agent-runner-DE-43MPb.js → agent-runner-_PYLv4Qo.js} +79 -39
  5. package/dist/api/schema.d.ts +2 -2
  6. package/dist/api/schema.js +7 -7
  7. package/dist/api.d.ts +3 -3
  8. package/dist/api.js +184 -418
  9. package/dist/{app-CHNS-AX2.d.ts → app-CL2zzzE0.d.ts} +5 -5
  10. package/dist/app.d.ts +1 -1
  11. package/dist/app.js +462 -80
  12. package/dist/{assistant-reply-pauL6qyn.js → assistant-reply-DbebsAxi.js} +1 -1
  13. package/dist/{automation-DphoTRYl.js → automation-CPqRFjIa.js} +2 -2
  14. package/dist/{background-compaction-queue-CAL4A2y7.js → background-compaction-queue-B9lmh8Ml.js} +3 -3
  15. package/dist/{briefs-4fyPJJEu.js → briefs-Dej7V0Bz.js} +11 -10
  16. package/dist/{catalog-runtime-BoOb5oUv.js → catalog-runtime-DpN0sWQ6.js} +2 -2
  17. package/dist/cli/chat.js +16 -16
  18. package/dist/cli/check.js +3 -3
  19. package/dist/cli/main.js +4 -4
  20. package/dist/cli/plugins.js +5 -5
  21. package/dist/cli/snapshot-create.js +4 -4
  22. package/dist/cli/upgrade.d.ts +1 -1
  23. package/dist/cli/upgrade.js +4 -4
  24. package/dist/{client-v_OVYuHZ.js → client-h2A2ZPzY.js} +7 -3
  25. package/dist/{config-o2jLRY5J.js → config-CusBFORe.js} +3 -3
  26. package/dist/{connections-RC4NXAx8.js → connections-C4h6mGha.js} +11 -11
  27. package/dist/{conversation-CZfyQvdm.js → conversation-DExTZw8B.js} +22 -7
  28. package/dist/conversation-pending-messages-Dgz6hrJs.js +173 -0
  29. package/dist/{conversation-privacy-C23M8KaD.js → conversation-privacy-2cm6OpNg.js} +1 -1
  30. package/dist/{credential-sync-Dd0WyNfF.js → credential-sync-DK06Jgt-.js} +17 -17
  31. package/dist/{db-BjLzDJCt.d.ts → db-Dsvk1Tp1.d.ts} +2 -2
  32. package/dist/{executor-CJfsD0VX.js → executor-Cmr0J8W3.js} +152 -7
  33. package/dist/instrumentation.d.ts +12 -0
  34. package/dist/instrumentation.js +56 -23
  35. package/dist/{logging-dFaXvBRK.js → logging-CGnh65_X.js} +2 -2
  36. package/dist/{media-DTAA8Qs_.js → media-Dq9_svfQ.js} +1 -1
  37. package/dist/{message-DSwxIZet.js → message-RpAnqHPY.js} +10 -10
  38. package/dist/nitro.d.ts +1 -1
  39. package/dist/nitro.js +18 -6
  40. package/dist/{oauth-callback-server-CDcuCp27.js → oauth-callback-server-BBnhVKuX.js} +2 -2
  41. package/dist/{oauth-relay-C6ZAyJgf.js → oauth-relay-D6xxVywK.js} +2 -2
  42. package/dist/{package-discovery-DJBompdd.js → package-discovery-DJhGdS4c.js} +1 -1
  43. package/dist/{plugins-DOm9Y6qI.js → plugins-HYh_JOdw.js} +1 -1
  44. package/dist/{projection-BTge9wrH.js → projection-C1MghKyI.js} +257 -137
  45. package/dist/{prompt-DDtCnlHP.js → prompt-BcHg-BMy.js} +2 -2
  46. package/dist/proxy-path-BHYoKZdq.js +15 -0
  47. package/dist/{queue-C37RbDVc.d.ts → queue-CZyYgPF0.d.ts} +1 -1
  48. package/dist/{registry-Cp6CNmtP.js → registry-DR7DjX9H.js} +4 -4
  49. package/dist/{reporting-window-DgHgwQB3.js → reporting-window-B-QP9zX1.js} +28 -2
  50. package/dist/{resolve-B_7h2cXx.js → resolve-0Ful4oDv.js} +4 -4
  51. package/dist/{result-5LBEfnLX.js → result-Dd9kCuQ-.js} +12 -12
  52. package/dist/{runner-C5-S4oq-.js → runner-yiY8gUUu.js} +11 -11
  53. package/dist/{sandbox-egress-signals-B4GehT1L.js → sandbox-egress-signals-BzQVHCMz.js} +1 -1
  54. package/dist/{schema-Tr484cCC.d.ts → schema-BkMmF552.d.ts} +1232 -222
  55. package/dist/{schema-B5fpczDw.js → schema-C5pEgfHc.js} +30 -70
  56. package/dist/sentry-BRTJqumy.js +51 -0
  57. package/dist/sentry-DrKC2NeM.d.ts +1 -0
  58. package/dist/sentry-route-name-BhwWnfqj.js +51 -0
  59. package/dist/{service-account-Cq_dLrZJ.js → service-account-Cu7HFLZQ.js} +3 -3
  60. package/dist/{service-account-BkEv20zf.js → service-account-PIMpWZHF.js} +3 -3
  61. package/dist/{session-stop-BsS4qFS2.js → session-stop-CDEMsNtv.js} +14 -15
  62. package/dist/{skills-M0BA0_s6.js → skills-B2xIoe0f.js} +5 -5
  63. package/dist/{spawn-BO3y7H4d.js → spawn-C0DySQRV.js} +3 -3
  64. package/dist/{stop-D5R82Wla.js → stop-Dj5-nrAo.js} +740 -285
  65. package/dist/{store-BGBzQWNf.js → store-Dlio-o6u.js} +6 -6
  66. package/dist/{store-CGJZTEVz.js → store-QzOfDwKA.js} +3 -3
  67. package/dist/{task-queue-UD27ei2U.js → task-queue-Cp1V_XW3.js} +4 -4
  68. package/dist/{task-runner-noxjOjkM.js → task-runner-CQkkUj3o.js} +23 -11
  69. package/dist/{thread-state-BSu6rM6p.js → thread-state-Bn87cfzE.js} +4 -4
  70. package/dist/{turn-failure-response-wahwyPrZ.js → turn-failure-response-CQebxByj.js} +8 -8
  71. package/dist/{turn-lifecycle-Bo4Trccw.js → turn-lifecycle-CJJsOhXB.js} +1 -1
  72. package/dist/{turn-session-routing-DnSaaEpn.js → turn-session-routing-bmG330Cf.js} +10 -11
  73. package/dist/{validation-B9-8iKyw.js → validation-D1wcf7hp.js} +2 -2
  74. package/dist/{version-C7HejFP2.js → version-BeHSXUK6.js} +1 -1
  75. package/dist/version.js +1 -1
  76. package/dist/{viewer-DLXajQZE.js → viewer-BZ0Hp5Nb.js} +6 -7
  77. package/dist/{work-DRGSlfia.js → work-BTcCIbWu.js} +12 -12
  78. package/dist/{worker-BGh5Dwc6.js → worker-D3fDK6zc.js} +7 -7
  79. package/migrations/0077_drop_agent_invocation_model_profile.sql +1 -0
  80. package/migrations/0078_plugin_conversation_index.sql +20 -0
  81. package/migrations/0079_conversation_event_author_index.sql +20 -0
  82. package/migrations/meta/0077_snapshot.json +4141 -0
  83. package/migrations/meta/0078_snapshot.json +4175 -0
  84. package/migrations/meta/0079_snapshot.json +4203 -0
  85. package/migrations/meta/_journal.json +21 -0
  86. package/package.json +4 -4
  87. package/dist/agent-invocations-D7c4BQGc.js +0 -182
  88. package/dist/common-Eu6sx09c.js +0 -107
  89. package/dist/rolldown-runtime-nwUcYXjP.js +0 -27
  90. package/dist/sentry-MDkYAVPV.js +0 -23
package/dist/app.js CHANGED
@@ -1,43 +1,45 @@
1
- import { Ar as takeDueTimerWatches, C as settleConversationTitleWork, Cn as setExperimentalFeatures, Cr as collectEventMatchKeys, Ct as isInvalidConversationRecordError, Di as openSlackModal, Dr as findMatchingWatches, Fr as verifyScheduledAutomationCredentialSubject, Gi as getWorkspaceTeamId, Gr as createPluginState, Hn as setBriefsConfig, Hr as getDashboardTaskLink, Ir as verifySlackDirectCredentialSubject, Ki as runWithWorkspaceTeamId, Kn as dismissOpenReviewItems, Ln as getPlugins, Mn as getPluginRoutes, Mr as bindScheduledAutomationCredentialSubject, Ni as slackEntitySchema, Nr as bindSlackDirectCredentialSubject, Oi as postSlackEphemeralMessage, Pi as slackExternalRefIdSchema, Pr as verifyEventAutomationCredentialSubject, Qn as searchReviewItems, Rn as setPlugins, Sn as isExperimentalFeatureEnabled, Ur as setDashboardConversationLinkOptions, Vi as isDmChannel, Vr as getDashboardReviewItemLink, Wa as readConversationEventPage, _ as appendConversationMessages, _o as setConfigDefaults, aa as parseSandboxEgressCredentialToken, at as CONVERSATION_WORK_STALE_ENQUEUE_MS, b as projectConversationMessages, co as createPluginCache, di as proxyVercelSandboxEgressRequest, dn as SubscribedReplyReason, eo as resolveRootVisibility, go as getConfigDefaults, ha as createPluginEmbedder, hi as resolveBaseUrl, ja as readConversationAccessFromSql, jn as getPluginApiRoutes, jr as bindEventAutomationCredentialSubject, ka as createPluginLogger, la as normalizeSandboxEgressTracePropagationDomains, mn as getThreadStopDecision, na as consumeSandboxEgressAuthRequiredSignal, nr as canActOnReviewItem, ra as consumeSandboxEgressPermissionDeniedSignal, ro as listConversationAnnotations, ta as clearSandboxEgressSignals, ui as isVercelSandboxEgressRequest, ur as reviewItemReaderForUser, wn as createUserTokenStore, xi as slackMention, xn as getExperimentalFeatures, xt as hasRunnableConversationWork, zi as getSlackClient, zn as validatePlugins, zr as getDashboardConversationLink } from "./projection-BTge9wrH.js";
2
- import { d as restoreRuntimeConfig, f as setBotModelConfig, h as snapshotRuntimeConfig, i as getChatConfig, m as setSlackReactionConfig, n as botConfig, o as getSlackBotToken, p as setRuntimeLimits, u as resetRuntimeConfig } from "./config-o2jLRY5J.js";
3
- import { E as withSpan, I as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, N as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, T as withLogContext, U as normalizeIdentityEmail, V as GOOGLE_IDENTITY_PROVIDER, b as setSpanAttributes, h as logWarn, k as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, m as logInfo, p as logException, r as createRequestContext, w as withContext } from "./logging-dFaXvBRK.js";
4
- import { n as captureMessage } from "./sentry-MDkYAVPV.js";
5
- import { t as JUNIOR_VERSION } from "./version-C7HejFP2.js";
6
- import { _ as slackMessageTsSchema, f as parseSlackTeamId, g as slackMessageTsFromMs, h as parseSlackMessageTs, m as slackChannelIdSchema, n as createSlackActor, p as parseSlackUserId, s as parseActorUserId, u as parseSlackChannelId } from "./actor-B4DYygOB.js";
7
- import { C as getSqlExecutor, H as recordGoogleSignIn, I as resolveActorIdentityId, M as withConversationMutationLock, S as getDb, Y as touchConversationDetail, _ as closeDb, g as createCache, i as readActorIdentity, k as withConversationEventLock, l as resolveViewerUser, p as parseAvatarUrl, x as getConversationStore, y as getConversationEventStore } from "./viewer-DLXajQZE.js";
8
- import { a as juniorAgentInvocations, d as juniorDestinations, i as juniorAgentBindings, s as juniorConversations } from "./agent-invocations-D7c4BQGc.js";
9
- import { _ as juniorConversationBriefs, b as juniorConversationEvents, c as juniorReviewItems, d as juniorAutomations, l as juniorAutomationRuns } from "./executor-CJfsD0VX.js";
10
- import { n as pluginCatalogRuntime } from "./catalog-runtime-BoOb5oUv.js";
11
- import { $ as readViewerAutomations, A as runWithSlackInstallation, B as logScheduledAutomationRunSkipped, C as readSlackReviewItemCardConversationId, D as parseSlackReviewItemClick, Dt as processWorkspaceSnapshotJob, E as buildSlackReviewItemModal, L as joinPublicChannel, M as parseSlackThreadId, O as parseSlackReviewItemFormTarget, Ot as ingestEvent, S as createSlackReviewItemShow, V as scheduledAutomationRunAttributes, Y as readViewerAutomationExecutions, Z as readViewerAutomationSummary, _ as readPublicArtifact, _t as requestAttachmentDeletion, at as reviewItemChangeRecord, bt as stopConversationSession, ct as conversationTurnIdForMessage, dt as recordWebConversationActivity, ft as webActorFromUser, g as publicArtifactHeaders, ht as collectAttachmentGarbage, it as renderReviewItemMessage, j as verifySlackSignature, k as parseSlackUserInputSubmission, n as executeAgentRun, q as ViewerTaskNotFoundError, r as processBackgroundCompaction, rt as deliverReviewItemChange, st as appendAndEnqueueWebMessage, t as createAgentRunner, tt as effectiveTaskOutcomes, v as unpublishedArtifactHeaders, w as syncReviewItemSlackCards, xt as recordSubagentEnded, y as lookupSlackUserProfile } from "./agent-runner-DE-43MPb.js";
1
+ import { n as captureMessage } from "./sentry-BRTJqumy.js";
2
+ import { Aa as createPluginLogger, Ar as takeDueTimerWatches, C as settleConversationTitleWork, Cn as setExperimentalFeatures, Cr as collectEventMatchKeys, Ct as isInvalidConversationRecordError, Di as openSlackModal, Dr as findMatchingWatches, Fr as verifyScheduledAutomationCredentialSubject, Gi as getWorkspaceTeamId, Gr as createPluginState, Hn as setBriefsConfig, Hr as getDashboardTaskLink, Ir as verifySlackDirectCredentialSubject, Ka as readConversationEventPage, Ki as runWithWorkspaceTeamId, Kn as dismissOpenReviewItems, Ln as getPlugins, Ma as readConversationAccessFromSql, Mn as getPluginRoutes, Mr as bindScheduledAutomationCredentialSubject, Ni as slackEntitySchema, Nr as bindSlackDirectCredentialSubject, Oi as postSlackEphemeralMessage, Pi as slackExternalRefIdSchema, Pr as verifyEventAutomationCredentialSubject, Qn as searchReviewItems, Rn as setPlugins, Sn as isExperimentalFeatureEnabled, Ur as setDashboardConversationLinkOptions, Vi as isDmChannel, Vr as getDashboardReviewItemLink, Xa as readConversationMessageEventSeq, Ya as readConversationLastEventSeq, _ as appendConversationMessages, aa as parseSandboxEgressCredentialToken, at as CONVERSATION_WORK_STALE_ENQUEUE_MS, b as projectConversationMessages, bo as getConfigDefaults, di as proxyVercelSandboxEgressRequest, dn as SubscribedReplyReason, fo as createPluginCache, ha as createPluginEmbedder, hi as resolveBaseUrl, io as resolveRootVisibility, jn as getPluginApiRoutes, jr as bindEventAutomationCredentialSubject, la as normalizeSandboxEgressTracePropagationDomains, mn as getThreadStopDecision, na as consumeSandboxEgressAuthRequiredSignal, nr as canActOnReviewItem, qa as readConversationEventPageAfter, ra as consumeSandboxEgressPermissionDeniedSignal, so as listConversationAnnotations, ta as clearSandboxEgressSignals, ui as isVercelSandboxEgressRequest, ur as reviewItemReaderForUser, wn as createUserTokenStore, xi as slackMention, xn as getExperimentalFeatures, xo as setConfigDefaults, xt as hasRunnableConversationWork, zi as getSlackClient, zn as validatePlugins, zr as getDashboardConversationLink } from "./projection-C1MghKyI.js";
3
+ import { d as restoreRuntimeConfig, f as setBotModelConfig, h as snapshotRuntimeConfig, i as getChatConfig, m as setSlackReactionConfig, n as botConfig, o as getSlackBotToken, p as setRuntimeLimits, u as resetRuntimeConfig } from "./config-CusBFORe.js";
4
+ import { E as withSpan, I as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, N as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, T as withLogContext, U as normalizeIdentityEmail, V as GOOGLE_IDENTITY_PROVIDER, b as setSpanAttributes, h as logWarn, k as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, m as logInfo, p as logException, r as createRequestContext, w as withContext } from "./logging-CGnh65_X.js";
5
+ import { t as JUNIOR_VERSION } from "./version-BeHSXUK6.js";
6
+ import { _ as slackMessageTsSchema, f as parseSlackTeamId, g as slackMessageTsFromMs, h as parseSlackMessageTs, m as slackChannelIdSchema, n as createSlackActor, p as parseSlackUserId, s as parseActorUserId, u as parseSlackChannelId } from "./actor-6jsm_v96.js";
7
+ import { C as getSqlExecutor, H as recordGoogleSignIn, I as resolveActorIdentityId, M as withConversationMutationLock, S as getDb, Y as touchConversationDetail, _ as closeDb, g as createCache, i as readActorIdentity, k as withConversationEventLock, l as resolveViewerUser, p as parseAvatarUrl, x as getConversationStore, y as getConversationEventStore } from "./viewer-BZ0Hp5Nb.js";
8
+ import { M as juniorDestinations, S as juniorConversationEvents, c as juniorReviewItems, d as juniorAutomations, h as juniorAgentInvocations, k as juniorConversations, l as juniorAutomationRuns, m as juniorAgentBindings, y as juniorConversationBriefs } from "./executor-Cmr0J8W3.js";
9
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-DpN0sWQ6.js";
10
+ import { $ as readViewerAutomations, A as runWithSlackInstallation, B as logScheduledAutomationRunSkipped, C as readSlackReviewItemCardConversationId, D as parseSlackReviewItemClick, Dt as processWorkspaceSnapshotJob, E as buildSlackReviewItemModal, L as joinPublicChannel, M as parseSlackThreadId, O as parseSlackReviewItemFormTarget, Ot as ingestEvent, S as createSlackReviewItemShow, V as scheduledAutomationRunAttributes, Y as readViewerAutomationExecutions, Z as readViewerAutomationSummary, _ as readPublicArtifact, _t as requestAttachmentDeletion, at as reviewItemChangeRecord, bt as stopConversationSession, ct as conversationTurnIdForMessage, dt as recordWebConversationActivity, ft as webActorFromUser, g as publicArtifactHeaders, ht as collectAttachmentGarbage, it as renderReviewItemMessage, j as verifySlackSignature, k as parseSlackUserInputSubmission, n as executeAgentRun, q as ViewerTaskNotFoundError, r as processBackgroundCompaction, rt as deliverReviewItemChange, st as appendAndEnqueueWebMessage, t as createAgentRunner, tt as effectiveTaskOutcomes, v as unpublishedArtifactHeaders, w as syncReviewItemSlackCards, xt as recordSubagentEnded, y as lookupSlackUserProfile } from "./agent-runner-_PYLv4Qo.js";
12
11
  import { a as withLock, i as fenceLock, n as MUTATION_LOCK_TTL_MS } from "./locks-D-0h111u.js";
13
- import { r as getStateAdapter, t as disconnectStateAdapter } from "./adapter-BXosqTMx.js";
12
+ import { r as getStateAdapter, t as disconnectStateAdapter } from "./adapter-DVN3iwf9.js";
14
13
  import { n as getNextRunAtMs } from "./cadence-R7Em4RjE.js";
15
- import { H as conversationBriefSchema, b as conversationSurfaceSchema, f as conversationFeedQuerySchema, k as annotationCard, v as conversationReportStatusSchema } from "./conversation-CZfyQvdm.js";
16
- import { S as listPendingAgentInvocationResults, x as listPendingAgentInvocationMailboxAppends } from "./store-BGBzQWNf.js";
17
- import { A as renderSlackObjectCard, T as renderTaskInput, d as getEventCatalog, f as SLACK_EVENT_NAMESPACE, g as slackChannelMessageRunsAutomation, h as slackChannelMessageReplyThreadTs, m as slackChannelMessageEvent } from "./session-stop-BsS4qFS2.js";
18
- import { h as buttonUserInputField } from "./reporting-window-DgHgwQB3.js";
19
- import { c as setSandboxResourceConfig, o as getSandboxResourceConfig } from "./resolve-B_7h2cXx.js";
20
- import { a as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, b as isConversationQueueMessageRejectedError, c as verifyWorkspaceSnapshotJobMessage, d as verifyConversationQueueMessage, h as getQueueProvider, i as verifyBackgroundCompactionMessage, l as getVercelConversationWorkQueue, r as vercelBackgroundCompactionQueue, t as BACKGROUND_COMPACTION_QUEUE_TOPIC, u as resolveConversationWorkQueueTopic, y as conversationQueueMessageSchema } from "./background-compaction-queue-CAL4A2y7.js";
21
- import { S as removeActiveConversation, _ as hasRunnableConversationWork$1, c as clearExpiredConversationLease, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, r as appendAndEnqueueInboundMessage, v as listActiveConversationIds } from "./store-CGJZTEVz.js";
22
- import { B as readScheduledAutomation, G as blockEventAutomation, H as saveScheduledAutomationInLock, K as collectEventAutomationMatchKeys, M as recordAutomationExecution, R as listScheduledAutomationsForTeam, S as existingConversationId, U as scheduledRunId, W as withScheduledAutomationLock, Y as findMatchingEventAutomations, a as confirmDispatchMailboxAppend, b as notifyAutomationBlocked, f as getPluginDispatchProjection, ht as eventGuidance, it as automationVersionOf, m as listPendingDispatchMailboxAppends, nt as eventAutomationRunLimitReason, o as createOrGetDispatch, p as isTerminalDispatchStatus, r as buildDispatchId, s as getDispatchConversationId, tt as admitEventAutomationRun, u as getDispatchRecord, v as markDispatchFailed } from "./turn-session-routing-DnSaaEpn.js";
23
- import { M as scheduledRunSchema, l as automationListQuerySchema, s as automationExecutionStatusSchema } from "./automation-DphoTRYl.js";
24
- import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "./validation-B9-8iKyw.js";
25
- import { a as pluginRuntimeRegistrationsFromPluginSet, n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "./plugins-DOm9Y6qI.js";
26
- import { A as recordSkippedConversationMessage, B as startProcessingReaction, C as getProductionSlackAdapter, D as isAllowedSignInEmail, E as isAllowedDomain, F as normalizeIncomingSlackThreadId, G as closeReviewItemsAnsweredByReply, H as parseContent, I as withNormalizedThreadId, K as readReviewItemForUser, L as stopConversationTurn, M as clearSlackPendingReactions, N as isSlackMessageStopped, O as readEnvList, P as stopSlackThread, Q as runAutoArchiveSweep, R as THREAD_OPTOUT_ACK, S as createProductionSlackWebhookServices, T as assertNoLegacyAllowedDomains, U as ReviewItemActionError, V as stripLeadingBotMention, W as actOnReviewItem, b as archiveConversation, d as readConversationRecordFromSql, it as getAttachmentStorage, j as buildSlackInboundMessage, k as resolveAllowedDomains, n as readConversationDetail, ot as enqueueAgentDispatch, q as reviewItemChange, st as GET$4, t as stopConversationTurnForViewer, u as readConversationFeed, v as decodeConversationCursor, w as createSlackWebApiStatusSender, x as createProductionConversationWorkOptions, y as encodeConversationCursor, z as bindMessageAuthorIdentityId } from "./stop-D5R82Wla.js";
27
- import { n as enqueueAgentInvocationResult, o as getAuthPausedConversationTurnId } from "./result-5LBEfnLX.js";
28
- import { i as enqueueAgentInvocation, r as endAgentInvocationsOfStoppedWork } from "./work-DRGSlfia.js";
29
- import { o as coerceThreadConversationState } from "./thread-state-BSu6rM6p.js";
30
- import { o as unlinkProvider } from "./connections-RC4NXAx8.js";
31
- import { a as GET$5, i as publishAppHomeView, r as GET$6, t as receiveLocalOAuthCredential } from "./credential-sync-Dd0WyNfF.js";
32
- import { a as pluginTaskQueueConsumer, c as queueCallback, n as createVercelPluginTaskCallback, o as registerVercelPluginTaskDevConsumer } from "./task-queue-UD27ei2U.js";
33
- import { t as processConversationWork } from "./worker-BGh5Dwc6.js";
34
- import { t as bindMessageAgent } from "./message-DSwxIZet.js";
35
- import { t as bindSpawnAgent } from "./spawn-BO3y7H4d.js";
36
- import { t as processPluginTask } from "./task-runner-noxjOjkM.js";
14
+ import { H as conversationBriefSchema, b as conversationSurfaceSchema, f as conversationFeedQuerySchema, k as annotationCard, v as conversationReportStatusSchema } from "./conversation-DExTZw8B.js";
15
+ import { t as SANDBOX_EGRESS_PROXY_PATH } from "./proxy-path-BHYoKZdq.js";
16
+ import { S as listPendingAgentInvocationResults, x as listPendingAgentInvocationMailboxAppends } from "./store-Dlio-o6u.js";
17
+ import { A as renderSlackObjectCard, T as renderTaskInput, d as getEventCatalog, f as SLACK_EVENT_NAMESPACE, g as slackChannelMessageRunsAutomation, h as slackChannelMessageReplyThreadTs, m as slackChannelMessageEvent } from "./session-stop-CDEMsNtv.js";
18
+ import { h as buttonUserInputField } from "./reporting-window-B-QP9zX1.js";
19
+ import { c as setSandboxResourceConfig, o as getSandboxResourceConfig } from "./resolve-0Ful4oDv.js";
20
+ import { a as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, b as isConversationQueueMessageRejectedError, c as verifyWorkspaceSnapshotJobMessage, d as verifyConversationQueueMessage, h as getQueueProvider, i as verifyBackgroundCompactionMessage, l as getVercelConversationWorkQueue, r as vercelBackgroundCompactionQueue, t as BACKGROUND_COMPACTION_QUEUE_TOPIC, u as resolveConversationWorkQueueTopic, y as conversationQueueMessageSchema } from "./background-compaction-queue-B9lmh8Ml.js";
21
+ import { S as removeActiveConversation, _ as hasRunnableConversationWork$1, c as clearExpiredConversationLease, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, r as appendAndEnqueueInboundMessage, v as listActiveConversationIds } from "./store-QzOfDwKA.js";
22
+ import { B as readScheduledAutomation, G as blockEventAutomation, H as saveScheduledAutomationInLock, K as collectEventAutomationMatchKeys, M as recordAutomationExecution, R as listScheduledAutomationsForTeam, S as existingConversationId, U as scheduledRunId, W as withScheduledAutomationLock, Y as findMatchingEventAutomations, a as confirmDispatchMailboxAppend, b as notifyAutomationBlocked, f as getPluginDispatchProjection, ht as eventGuidance, it as automationVersionOf, m as listPendingDispatchMailboxAppends, nt as eventAutomationRunLimitReason, o as createOrGetDispatch, p as isTerminalDispatchStatus, r as buildDispatchId, s as getDispatchConversationId, tt as admitEventAutomationRun, u as getDispatchRecord, v as markDispatchFailed } from "./turn-session-routing-bmG330Cf.js";
23
+ import { M as scheduledRunSchema, l as automationListQuerySchema, s as automationExecutionStatusSchema } from "./automation-CPqRFjIa.js";
24
+ import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "./validation-D1wcf7hp.js";
25
+ import { a as pluginRuntimeRegistrationsFromPluginSet, n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "./plugins-HYh_JOdw.js";
26
+ import { a as conversationPendingMessageDeliverySchema } from "./conversation-pending-messages-Dgz6hrJs.js";
27
+ import { A as assertNoLegacyAllowedDomains, B as normalizeIncomingSlackThreadId, D as createProductionSlackWebhookServices, E as createProductionConversationWorkOptions, F as recordSkippedConversationMessage, G as startProcessingReaction, H as stopConversationTurn, I as buildSlackInboundMessage, J as ReviewItemActionError, K as stripLeadingBotMention, L as clearSlackPendingReactions, M as isAllowedSignInEmail, N as readEnvList, O as getProductionSlackAdapter, P as resolveAllowedDomains, Q as reviewItemChange, R as isSlackMessageStopped, S as readConversationPendingMessages, T as archiveConversation, U as THREAD_OPTOUT_ACK, V as withNormalizedThreadId, W as bindMessageAuthorIdentityId, X as closeReviewItemsAnsweredByReply, Y as actOnReviewItem, Z as readReviewItemForUser, _ as appendConversationMessageForViewer, b as encodeConversationCursor, ct as getAttachmentStorage, d as readConversationRecordFromSql, dt as GET$4, et as archiveViewerDoneConversations, i as readConversationDetail, j as isAllowedDomain, k as createSlackWebApiStatusSender, n as steerConversationPendingMessagesForViewer, nt as runAutoArchiveSweep, o as markConversationRead, q as parseContent, r as pinConversation, rt as setConversationAutoArchive, t as stopConversationTurnForViewer, u as readConversationFeed, ut as enqueueAgentDispatch, v as createConversationForViewer, x as cancelConversationPendingMessagesForViewer, y as decodeConversationCursor, z as stopSlackThread } from "./stop-Dj5-nrAo.js";
28
+ import { n as enqueueAgentInvocationResult, o as getAuthPausedConversationTurnId } from "./result-Dd9kCuQ-.js";
29
+ import { i as enqueueAgentInvocation, r as endAgentInvocationsOfStoppedWork } from "./work-BTcCIbWu.js";
30
+ import { o as coerceThreadConversationState } from "./thread-state-Bn87cfzE.js";
31
+ import { o as unlinkProvider } from "./connections-C4h6mGha.js";
32
+ import { a as GET$5, i as publishAppHomeView, r as GET$6, t as receiveLocalOAuthCredential } from "./credential-sync-DK06Jgt-.js";
33
+ import { t as nameRequestRoute } from "./sentry-route-name-BhwWnfqj.js";
34
+ import { a as pluginTaskQueueConsumer, c as queueCallback, n as createVercelPluginTaskCallback, o as registerVercelPluginTaskDevConsumer } from "./task-queue-Cp1V_XW3.js";
35
+ import { t as processConversationWork } from "./worker-D3fDK6zc.js";
36
+ import { t as bindMessageAgent } from "./message-RpAnqHPY.js";
37
+ import { t as bindSpawnAgent } from "./spawn-C0DySQRV.js";
38
+ import { t as processPluginTask } from "./task-runner-CQkkUj3o.js";
37
39
  import { createRequire } from "node:module";
38
40
  import { Hono } from "hono";
39
41
  import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
40
- import { z } from "zod";
42
+ import * as z from "zod";
41
43
  import { and, asc, eq, inArray, isNotNull, isNull, lte, ne, or, sql } from "drizzle-orm";
42
44
  import { EVENT_SUMMARY_MAX_LENGTH, EVENT_TEXT_MAX_LENGTH, dispatchOptionsSchema, eventSchema, eventTriggerFiltersText, isSlackDestination, userSchema } from "@sentry/junior-plugin-api";
43
45
  import { pathToFileURL } from "node:url";
@@ -1478,11 +1480,15 @@ function isSandboxEgressRequest(request) {
1478
1480
  return isVercelSandboxEgressRequest(request);
1479
1481
  }
1480
1482
  // src/handlers/sandbox-egress-route.ts
1483
+ const SANDBOX_EGRESS_ROUTE = `${SANDBOX_EGRESS_PROXY_PATH}/<token>`;
1481
1484
  /**
1482
1485
  * Route authenticated sandbox egress proxy traffic before ordinary app routes.
1483
1486
  */
1484
1487
  async function handleSandboxEgressRoute(request, tracePropagationDomains, next) {
1485
- if (isSandboxEgressRequest(request)) return await ALL(request, { tracePropagation: { domains: tracePropagationDomains } });
1488
+ if (isSandboxEgressRequest(request)) {
1489
+ nameRequestRoute(request.method, SANDBOX_EGRESS_ROUTE);
1490
+ return await ALL(request, { tracePropagation: { domains: tracePropagationDomains } });
1491
+ }
1486
1492
  await next();
1487
1493
  }
1488
1494
  // src/handlers/sandbox-egress-signals.ts
@@ -3070,7 +3076,6 @@ async function handleWebhookRequest(request, platform, run) {
3070
3076
  }
3071
3077
  logWarn("webhook.response.unsuccessful", {
3072
3078
  "http.response.status_code": response.status,
3073
- "http.request.header.x_slack_signature": request.headers.get("x-slack-signature") ?? void 0,
3074
3079
  "http.request.header.x_slack_request_timestamp": request.headers.get("x-slack-request-timestamp") ?? void 0,
3075
3080
  ...responseBodySnippet ? { "app.webhook.response_body": responseBodySnippet } : void 0
3076
3081
  });
@@ -5449,8 +5454,10 @@ function renderMcpPage(page) {
5449
5454
  }
5450
5455
  // src/api/mcp/oauth/scopes.ts
5451
5456
  /**
5452
- * Own the MCP OAuth scopes. Each scope unlocks a fixed set of tools. No
5453
- * scope lets a client send a message or start a Turn.
5457
+ * Own the MCP OAuth scopes. Each scope unlocks a fixed set of tools. Only
5458
+ * `conversations:write` lets a client send a message, which starts agent
5459
+ * work as the user. It is a separate scope so a grant without it can never
5460
+ * start a Turn.
5454
5461
  *
5455
5462
  * A grant stores its scopes as one space-separated string (RFC 6749 section
5456
5463
  * 3.3), so grants from before the scope split still parse.
@@ -5459,13 +5466,15 @@ function renderMcpPage(page) {
5459
5466
  const MCP_SCOPES = [
5460
5467
  "conversations:read",
5461
5468
  "conversations:manage",
5469
+ "conversations:write",
5462
5470
  "review_items:read",
5463
5471
  "automations:read"
5464
5472
  ];
5465
5473
  /** What each scope lets the client do, as the consent page says it. */
5466
5474
  const MCP_SCOPE_DESCRIPTIONS = {
5467
5475
  "conversations:read": "List and read the conversations that you started or take part in",
5468
- "conversations:manage": "Archive your conversations and stop a running Turn",
5476
+ "conversations:manage": "Archive, pin, and mark your conversations read, stop a running Turn, and cancel queued messages",
5477
+ "conversations:write": "Start conversations and send messages as you. Junior runs agent work for each message",
5469
5478
  "review_items:read": "List and read your review items",
5470
5479
  "automations:read": "List and read the automations that you can see"
5471
5480
  };
@@ -5496,7 +5505,7 @@ const AUTHORIZATION_TTL_MS = 6e5;
5496
5505
  const STATE_MAX_LENGTH = 1e3;
5497
5506
  const AUTHORIZATION_ID_PATTERN = /^[A-Za-z0-9_-]{43}$/;
5498
5507
  const CODE_CHALLENGE_PATTERN = /^[A-Za-z0-9_-]{43}$/;
5499
- const mcpAuthorizationSchema = z.object({
5508
+ const mcpAuthorizationSchema$1 = z.object({
5500
5509
  clientId: z.string().min(1),
5501
5510
  clientName: z.string().min(1).optional(),
5502
5511
  codeChallenge: z.string().regex(CODE_CHALLENGE_PATTERN),
@@ -5527,7 +5536,7 @@ function claimedKey(authorizationId) {
5527
5536
  */
5528
5537
  async function readMcpAuthorization(state, authorizationId) {
5529
5538
  if (!AUTHORIZATION_ID_PATTERN.test(authorizationId)) return void 0;
5530
- const authorization = await readRecord(state, authorizationKey(authorizationId), mcpAuthorizationSchema);
5539
+ const authorization = await readRecord(state, authorizationKey(authorizationId), mcpAuthorizationSchema$1);
5531
5540
  if (!authorization || authorization.expiresAtMs <= Date.now()) return;
5532
5541
  if (await state.get(claimedKey(authorizationId)) !== null) return void 0;
5533
5542
  return {
@@ -5991,14 +6000,15 @@ async function handleMcpConsentPage(args) {
5991
6000
  const mcpConversationSchema = z.object({
5992
6001
  conversationId: z.string(),
5993
6002
  title: z.string(),
5994
- status: conversationReportStatusSchema,
5995
- surface: conversationSurfaceSchema,
5996
- channelName: z.string().optional(),
5997
- locationUrl: z.string().optional(),
6003
+ status: conversationReportStatusSchema.describe("`active` while work runs, waits to start, or waits on you. `completed` when no work is left. `failed` when the last turn failed."),
6004
+ surface: conversationSurfaceSchema.describe("Where it started: `slack`, `api` (the dashboard or MCP), `scheduler` (an automation), or `internal`."),
6005
+ channelName: z.string().optional().describe("Slack channel name."),
6006
+ locationUrl: z.string().optional().describe("Slack thread link."),
5998
6007
  startedAt: z.string(),
5999
- lastSeenAt: z.string(),
6000
- archivedAt: z.string().optional(),
6001
- url: z.string().optional()
6008
+ lastSeenAt: z.string().describe("Time of the newest activity. archiveConversation takes this value."),
6009
+ archivedAt: z.string().optional().describe("Set when you archived it."),
6010
+ pinnedAt: z.string().optional().describe("Set when you pinned it."),
6011
+ url: z.string().optional().describe("Dashboard link.")
6002
6012
  }).strict();
6003
6013
  /** Map a Conversation summary to its MCP view. */
6004
6014
  function mcpConversation(summary) {
@@ -6012,23 +6022,36 @@ function mcpConversation(summary) {
6012
6022
  startedAt: summary.startedAt,
6013
6023
  lastSeenAt: summary.lastSeenAt,
6014
6024
  archivedAt: summary.archivedAt ?? void 0,
6025
+ pinnedAt: summary.pinnedAt ?? void 0,
6015
6026
  url: getDashboardConversationLink(summary.conversationId)
6016
6027
  };
6017
6028
  }
6018
6029
  /** Conversation id param shared by the conversation tools. */
6019
- const mcpConversationIdSchema = z.string().min(1).describe("Conversation id from searchConversations.");
6030
+ const mcpConversationIdSchema = z.string().min(1).describe("Conversation id from searchConversations or createConversation.");
6031
+ const mcpAttachmentsSchema = z.array(z.object({
6032
+ filename: z.string(),
6033
+ contentType: z.string(),
6034
+ bytes: z.number().int()
6035
+ }).strict()).optional();
6036
+ function mcpAttachments(attachments) {
6037
+ return attachments?.length ? attachments.map(({ bytes, contentType, filename }) => ({
6038
+ bytes,
6039
+ contentType,
6040
+ filename
6041
+ })) : void 0;
6042
+ }
6043
+ function mcpAuthor(identity) {
6044
+ return identity?.fullName ?? identity?.slackUserName ?? identity?.email;
6045
+ }
6020
6046
  /** MCP view of one user or assistant Message. */
6021
6047
  const mcpMessageSchema = z.object({
6022
- seq: z.number().int(),
6048
+ seq: z.number().int().describe("Position in the transcript. markConversationRead takes this value."),
6049
+ messageId: z.string().describe("For a message that you sent, the `messageId` that sendMessage or createConversation returned."),
6023
6050
  createdAt: z.string(),
6024
6051
  role: z.enum(["assistant", "user"]),
6025
6052
  author: z.string().optional(),
6026
6053
  text: z.string(),
6027
- attachments: z.array(z.object({
6028
- filename: z.string(),
6029
- contentType: z.string(),
6030
- bytes: z.number().int()
6031
- }).strict()).optional()
6054
+ attachments: mcpAttachmentsSchema
6032
6055
  }).strict();
6033
6056
  /**
6034
6057
  * Keep the user and assistant Messages of a report event page, in order.
@@ -6039,23 +6062,99 @@ function mcpMessages(events) {
6039
6062
  const data = event.data;
6040
6063
  if (data.type !== "message" || data.role === "system") return [];
6041
6064
  const text = data.text ?? "";
6042
- const attachments = data.attachments?.map(({ bytes, contentType, filename }) => ({
6043
- bytes,
6044
- contentType,
6045
- filename
6046
- }));
6047
- if (!text && !attachments?.length) return [];
6048
- const author = data.actorIdentity?.fullName ?? data.actorIdentity?.slackUserName;
6065
+ const attachments = mcpAttachments(data.attachments);
6066
+ if (!text && !attachments) return [];
6067
+ const author = mcpAuthor(data.actorIdentity);
6049
6068
  return [{
6050
6069
  seq: event.seq,
6070
+ messageId: data.messageId,
6051
6071
  createdAt: event.createdAt,
6052
6072
  role: data.role,
6053
6073
  ...author ? { author } : void 0,
6054
6074
  text,
6055
- ...attachments?.length ? { attachments } : void 0
6075
+ ...attachments ? { attachments } : void 0
6076
+ }];
6077
+ });
6078
+ }
6079
+ /** Message text param shared by the tools that send a message. */
6080
+ const mcpMessageTextSchema = z.string().trim().min(1).max(32e3).describe("Message text.");
6081
+ /**
6082
+ * Idempotency key param shared by the tools that send a message. A retry
6083
+ * with the same key sends nothing new.
6084
+ */
6085
+ const mcpIdempotencyKeySchema = z.string().trim().min(1).max(200).optional().describe("Reuse the same key to retry without sending the message twice. Omit it to send a new message.");
6086
+ /**
6087
+ * MCP view of one accepted user Message that no Turn has read yet. It is not
6088
+ * in the transcript, so it has no `seq`.
6089
+ */
6090
+ const mcpPendingMessageSchema = z.object({
6091
+ messageId: z.string(),
6092
+ createdAt: z.string(),
6093
+ author: z.string().optional(),
6094
+ text: z.string(),
6095
+ attachments: mcpAttachmentsSchema,
6096
+ delivery: conversationPendingMessageDeliverySchema.describe("`defer` waits for the running turn to end. `interrupt` joins the running turn at its next safe step.")
6097
+ }).strict();
6098
+ /** Pending Messages field shared by `getConversation` and the send tools. */
6099
+ const mcpPendingMessagesSchema = z.array(mcpPendingMessageSchema).describe("Accepted messages that no turn has read yet, oldest first. A message leaves this list when a turn reads it.");
6100
+ /** Authorization that a parked Turn waits for. */
6101
+ const mcpAuthorizationSchema = z.object({
6102
+ label: z.string(),
6103
+ url: z.string()
6104
+ }).strict().describe("Set when a turn waits for you to connect an account. Open `url` in a browser to continue.");
6105
+ /**
6106
+ * Read the Messages that wait for a Turn and the authorization that a parked
6107
+ * Turn waits for. The caller must check that `user` is a participant.
6108
+ */
6109
+ async function readMcpPendingWork(user, conversationId) {
6110
+ const report = await readConversationPendingMessages(conversationId, { viewer: user });
6111
+ const pendingMessages = (report?.messages ?? []).flatMap((message) => {
6112
+ if (message.text === void 0) return [];
6113
+ const author = mcpAuthor(message.actorIdentity);
6114
+ const attachments = mcpAttachments(message.attachments);
6115
+ return [{
6116
+ messageId: message.messageId,
6117
+ createdAt: message.createdAt,
6118
+ ...author ? { author } : void 0,
6119
+ text: message.text,
6120
+ ...attachments ? { attachments } : void 0,
6121
+ delivery: message.delivery
6056
6122
  }];
6057
6123
  });
6124
+ const authorization = report?.authorization;
6125
+ return {
6126
+ pendingMessages,
6127
+ ...authorization ? { authorization: {
6128
+ label: authorization.label,
6129
+ url: authorization.authorizationUrl
6130
+ } } : void 0
6131
+ };
6058
6132
  }
6133
+ /**
6134
+ * Read pending work for a send result. The message already landed, so a
6135
+ * failed read drops these optional fields instead of turning the accepted
6136
+ * send into a tool error that a client may retry.
6137
+ */
6138
+ async function readMcpPendingWorkAfterSend(user, conversationId) {
6139
+ try {
6140
+ return await readMcpPendingWork(user, conversationId);
6141
+ } catch (error) {
6142
+ logException(error, "mcp.pending_work.read.failed", { "gen_ai.conversation.id": conversationId });
6143
+ return {};
6144
+ }
6145
+ }
6146
+ /** `cursor` result field shared by getConversation and the send tools. */
6147
+ const mcpCursorSchema = z.string().describe("Pass as `after` to getConversation to read the messages that come after this point.");
6148
+ /** Result of a tool that sends a message. */
6149
+ const mcpAcceptedMessageSchema = {
6150
+ conversationId: z.string(),
6151
+ messageId: z.string().describe("Id of your message in `pendingMessages`, and later in the transcript."),
6152
+ status: z.enum(["accepted", "duplicate"]).describe("`duplicate` when the idempotency key was already used."),
6153
+ pendingMessages: mcpPendingMessagesSchema.optional().describe("Accepted messages that no turn has read yet, oldest first. Missing when the read failed after your message was accepted; use getConversation."),
6154
+ authorization: mcpAuthorizationSchema.optional(),
6155
+ cursor: mcpCursorSchema,
6156
+ url: z.string().optional().describe("Dashboard link.")
6157
+ };
6059
6158
  // src/api/mcp/tool-context.ts
6060
6159
  /**
6061
6160
  * Return one structured tool result. The text block holds the same JSON, as
@@ -6107,7 +6206,7 @@ function registerArchiveConversationTool(server, { user }) {
6107
6206
  archived: z.boolean().default(true).describe("False restores an archived conversation."),
6108
6207
  lastSeenAt: z.string().datetime().describe("`lastSeenAt` from searchConversations or getConversation. The archive fails when the conversation has newer activity.")
6109
6208
  },
6110
- outputSchema: { archivedAt: z.string().nullable() },
6209
+ outputSchema: { archivedAt: z.string().nullable().describe("Null when the conversation is not archived.") },
6111
6210
  annotations: {
6112
6211
  destructiveHint: false,
6113
6212
  idempotentHint: true,
@@ -6125,6 +6224,97 @@ function registerArchiveConversationTool(server, { user }) {
6125
6224
  }
6126
6225
  });
6127
6226
  }
6227
+ // src/api/mcp/tools/archive-done-conversations.ts
6228
+ /**
6229
+ * Register `archiveDoneConversations`, which archives every done
6230
+ * Conversation of the user once.
6231
+ */
6232
+ function registerArchiveDoneConversationsTool(server, { user }) {
6233
+ server.registerTool("archiveDoneConversations", {
6234
+ title: "Archive done conversations",
6235
+ description: "Archive all of your conversations whose work is done, once. It skips pinned conversations, conversations with auto-archive off, and conversations that wait on you. Archiving hides them only for you.",
6236
+ inputSchema: {},
6237
+ outputSchema: { archived: z.number().int().describe("Conversations archived.") },
6238
+ annotations: {
6239
+ destructiveHint: false,
6240
+ idempotentHint: true,
6241
+ openWorldHint: false,
6242
+ readOnlyHint: false
6243
+ }
6244
+ }, async () => mcpToolResult(await archiveViewerDoneConversations(user)));
6245
+ }
6246
+ // src/api/mcp/tools/cancel-queued-messages.ts
6247
+ /**
6248
+ * Register `cancelQueuedMessages`, which drops the messages that wait for
6249
+ * the running Turn and leaves the Turn running.
6250
+ */
6251
+ function registerCancelQueuedMessagesTool(server, { user }) {
6252
+ server.registerTool("cancelQueuedMessages", {
6253
+ title: "Cancel queued messages",
6254
+ description: "Drop every message that waits for the running turn of one of your conversations. The running turn continues.",
6255
+ inputSchema: { conversationId: mcpConversationIdSchema },
6256
+ outputSchema: { cancelledMessages: z.number().int().describe("Messages dropped.") },
6257
+ annotations: {
6258
+ destructiveHint: true,
6259
+ idempotentHint: true,
6260
+ openWorldHint: false,
6261
+ readOnlyHint: false
6262
+ }
6263
+ }, async ({ conversationId }) => {
6264
+ if (!await isConversationParticipant(user, conversationId)) return mcpToolError("Conversation not found.");
6265
+ try {
6266
+ return mcpToolResult({ cancelledMessages: (await cancelConversationPendingMessagesForViewer(user, conversationId)).cancelledCount });
6267
+ } catch (error) {
6268
+ return apiToolError(error);
6269
+ }
6270
+ });
6271
+ }
6272
+ // src/api/mcp/tools/create-conversation.ts
6273
+ /**
6274
+ * Register `createConversation`, which starts a dashboard Conversation with
6275
+ * the user's first message. Junior starts a Turn for it.
6276
+ */
6277
+ function registerCreateConversationTool(server, { attachmentStorage, queue, user }) {
6278
+ server.registerTool("createConversation", {
6279
+ title: "Create conversation",
6280
+ description: "Start a new conversation as you, with a first message. The agent works on it in the background. Returns the messages that no turn has read yet and a `cursor`. Pass the `cursor` as `after` to getConversation to read the reply.",
6281
+ inputSchema: {
6282
+ message: mcpMessageTextSchema,
6283
+ visibility: z.enum(["private", "public"]).default("private").describe("`private` keeps it to its participants. `public` lets people in your workspace find and read it."),
6284
+ idempotencyKey: mcpIdempotencyKeySchema
6285
+ },
6286
+ outputSchema: mcpAcceptedMessageSchema,
6287
+ annotations: {
6288
+ destructiveHint: false,
6289
+ idempotentHint: false,
6290
+ openWorldHint: true,
6291
+ readOnlyHint: false
6292
+ }
6293
+ }, async ({ idempotencyKey, message, visibility }) => {
6294
+ let accepted;
6295
+ try {
6296
+ accepted = await createConversationForViewer(user, {
6297
+ idempotencyKey: idempotencyKey ?? randomUUID(),
6298
+ message,
6299
+ visibility
6300
+ }, {
6301
+ attachmentStorage,
6302
+ queue
6303
+ });
6304
+ } catch (error) {
6305
+ return apiToolError(error);
6306
+ }
6307
+ return mcpToolResult({
6308
+ ...accepted,
6309
+ ...await readMcpPendingWorkAfterSend(user, accepted.conversationId),
6310
+ cursor: encodeConversationCursor({
6311
+ conversationId: accepted.conversationId,
6312
+ seq: -1
6313
+ }),
6314
+ url: getDashboardConversationLink(accepted.conversationId)
6315
+ });
6316
+ });
6317
+ }
6128
6318
  // src/api/mcp/automation.ts
6129
6319
  /** Own the MCP view of one Automation, shared by the automation tools. */
6130
6320
  /** MCP view of one Automation. It omits cost and run-count charts. */
@@ -6240,19 +6430,49 @@ function mcpBrief(brief, updatedAt) {
6240
6430
  };
6241
6431
  }
6242
6432
  const RECENT_EVENT_LIMIT = 100;
6433
+ const AFTER_EVENT_SCAN_LIMIT = 200;
6434
+ const AFTER_MESSAGE_LIMIT = 20;
6435
+ /**
6436
+ * Read the Messages after a transcript position and the position to continue
6437
+ * from. The cursor stops at the last returned Message when more are left.
6438
+ */
6439
+ async function readMessagesAfter(conversationId, afterSeq) {
6440
+ const page = await readConversationEventPageAfter(getSqlExecutor(), {
6441
+ afterSeq,
6442
+ canExposePayload: true,
6443
+ conversationId,
6444
+ limit: AFTER_EVENT_SCAN_LIMIT
6445
+ });
6446
+ const scanned = mcpMessages(page.events);
6447
+ const messages = scanned.slice(0, AFTER_MESSAGE_LIMIT);
6448
+ const cut = scanned.length > messages.length;
6449
+ return {
6450
+ messages,
6451
+ hasMore: cut || page.nextSeq !== void 0,
6452
+ seq: cut ? messages.at(-1).seq : page.events.at(-1)?.seq ?? afterSeq
6453
+ };
6454
+ }
6243
6455
  /**
6244
6456
  * Register `getConversation`. It returns metadata, the Brief, and the last
6245
- * Reply, not the whole transcript.
6457
+ * Reply or the Messages after a cursor, not the whole transcript.
6246
6458
  */
6247
6459
  function registerGetConversationTool(server, { user }) {
6248
6460
  server.registerTool("getConversation", {
6249
6461
  title: "Get conversation",
6250
- description: "Get one conversation: its metadata, its Brief (a summary of intent, outcome, and state), and the last assistant reply. Use listConversationMessages for the full transcript.",
6251
- inputSchema: { conversationId: mcpConversationIdSchema },
6462
+ description: "Get one conversation: its metadata, its Brief (a summary of intent, outcome, and state), the messages that no turn has read yet, and a `cursor`. Without `after`, it returns the last assistant reply. With `after`, it returns the messages after that point instead. To follow a conversation, call it again with the newest `cursor` until `status` is not `active` and `hasMore` is not set. Use listConversationMessages for older messages.",
6463
+ inputSchema: {
6464
+ conversationId: mcpConversationIdSchema,
6465
+ after: z.string().min(1).max(1e3).optional().describe("`cursor` from sendMessage, createConversation, or an earlier getConversation call.")
6466
+ },
6252
6467
  outputSchema: {
6253
6468
  conversation: mcpConversationSchema,
6254
6469
  brief: mcpBriefSchema.optional(),
6255
- lastReply: mcpMessageSchema.optional()
6470
+ lastReply: mcpMessageSchema.optional().describe("Newest assistant message in the recent events. Set only without `after`."),
6471
+ messages: z.array(mcpMessageSchema).optional().describe("User and assistant messages after `after`, oldest first. Set only with `after`."),
6472
+ hasMore: z.boolean().optional().describe("True when more messages already follow `cursor`. Call again now, also when `status` is not `active`."),
6473
+ pendingMessages: mcpPendingMessagesSchema,
6474
+ authorization: mcpAuthorizationSchema.optional(),
6475
+ cursor: mcpCursorSchema
6256
6476
  },
6257
6477
  annotations: {
6258
6478
  destructiveHint: false,
@@ -6260,17 +6480,35 @@ function registerGetConversationTool(server, { user }) {
6260
6480
  openWorldHint: false,
6261
6481
  readOnlyHint: true
6262
6482
  }
6263
- }, async ({ conversationId }) => {
6483
+ }, async ({ after, conversationId }) => {
6484
+ const afterSeq = after ? decodeConversationCursor({
6485
+ conversationId,
6486
+ cursor: after
6487
+ })?.seq : void 0;
6488
+ if (after && afterSeq === void 0) return mcpToolError("The cursor is not valid. Omit `after` to read the current state.");
6264
6489
  const detail = await isConversationParticipant(user, conversationId) ? await readConversationDetail(conversationId, {
6265
6490
  limit: RECENT_EVENT_LIMIT,
6266
6491
  viewer: user
6267
6492
  }) : void 0;
6268
6493
  if (!detail) return mcpToolError("Conversation not found.");
6269
- const lastReply = mcpMessages(detail.events).filter((message) => message.role === "assistant").at(-1);
6494
+ const newer = afterSeq === void 0 ? void 0 : detail.eventHistory.status === "expired" ? {
6495
+ messages: [],
6496
+ hasMore: false,
6497
+ seq: afterSeq
6498
+ } : await readMessagesAfter(conversationId, afterSeq);
6499
+ const lastReply = newer ? void 0 : mcpMessages(detail.events).filter((message) => message.role === "assistant").at(-1);
6500
+ const cursorSeq = newer?.seq ?? detail.events.at(-1)?.seq ?? -1;
6270
6501
  return mcpToolResult({
6271
6502
  conversation: mcpConversation(detail),
6272
6503
  ...detail.brief ? { brief: mcpBrief(detail.brief.content, detail.brief.updatedAt) } : void 0,
6273
- ...lastReply ? { lastReply } : void 0
6504
+ ...lastReply ? { lastReply } : void 0,
6505
+ ...newer ? { messages: newer.messages } : void 0,
6506
+ ...newer?.hasMore ? { hasMore: true } : void 0,
6507
+ ...await readMcpPendingWork(user, conversationId),
6508
+ cursor: encodeConversationCursor({
6509
+ conversationId,
6510
+ seq: cursorSeq
6511
+ })
6274
6512
  });
6275
6513
  });
6276
6514
  }
@@ -6440,6 +6678,57 @@ function registerListConversationMessagesTool(server, { user }) {
6440
6678
  });
6441
6679
  });
6442
6680
  }
6681
+ // src/api/mcp/tools/mark-conversation-read.ts
6682
+ /** Register `markConversationRead`, which moves the user's read position. */
6683
+ function registerMarkConversationReadTool(server, { user }) {
6684
+ server.registerTool("markConversationRead", {
6685
+ title: "Mark conversation read",
6686
+ description: "Mark one of your conversations as read for you. The read position only moves forward.",
6687
+ inputSchema: {
6688
+ conversationId: mcpConversationIdSchema,
6689
+ lastReadSeq: z.number().int().nonnegative().optional().describe("`seq` of the last message read, from listConversationMessages or getConversation. Omit it to mark every message read.")
6690
+ },
6691
+ outputSchema: { lastReadSeq: z.number().int().describe("`seq` of the last message that you read.") },
6692
+ annotations: {
6693
+ destructiveHint: false,
6694
+ idempotentHint: true,
6695
+ openWorldHint: false,
6696
+ readOnlyHint: false
6697
+ }
6698
+ }, async ({ conversationId, lastReadSeq }) => {
6699
+ if (!await isConversationParticipant(user, conversationId)) return mcpToolError("Conversation not found.");
6700
+ try {
6701
+ return mcpToolResult(await markConversationRead(user, conversationId, { lastReadSeq: lastReadSeq ?? Number.MAX_SAFE_INTEGER }));
6702
+ } catch (error) {
6703
+ return apiToolError(error);
6704
+ }
6705
+ });
6706
+ }
6707
+ // src/api/mcp/tools/pin-conversation.ts
6708
+ /** Register `pinConversation`, which pins or unpins for the user. */
6709
+ function registerPinConversationTool(server, { user }) {
6710
+ server.registerTool("pinConversation", {
6711
+ title: "Pin conversation",
6712
+ description: "Pin one of your conversations, or unpin it. A pin applies only to you, restores an archived conversation, and keeps auto-archive from archiving it.",
6713
+ inputSchema: {
6714
+ conversationId: mcpConversationIdSchema,
6715
+ pinned: z.boolean().default(true).describe("False unpins the conversation.")
6716
+ },
6717
+ outputSchema: { pinnedAt: z.string().nullable().describe("Null when the conversation is not pinned.") },
6718
+ annotations: {
6719
+ destructiveHint: false,
6720
+ idempotentHint: true,
6721
+ openWorldHint: false,
6722
+ readOnlyHint: false
6723
+ }
6724
+ }, async ({ conversationId, pinned }) => {
6725
+ try {
6726
+ return mcpToolResult(await pinConversation(user, conversationId, { pinned }));
6727
+ } catch (error) {
6728
+ return apiToolError(error);
6729
+ }
6730
+ });
6731
+ }
6443
6732
  // src/api/mcp/tools/search-conversations.ts
6444
6733
  /** Register `searchConversations`, which searches the Conversations of the user. */
6445
6734
  function registerSearchConversationsTool(server, { user }) {
@@ -6500,6 +6789,88 @@ function registerSearchReviewItemsTool(server, { user }) {
6500
6789
  });
6501
6790
  });
6502
6791
  }
6792
+ // src/api/mcp/tools/send-message.ts
6793
+ /**
6794
+ * Register `sendMessage`, which adds the user's message to a Conversation.
6795
+ * Junior reads it in a new Turn, or after the running Turn.
6796
+ */
6797
+ function registerSendMessageTool(server, { attachmentStorage, queue, user }) {
6798
+ server.registerTool("sendMessage", {
6799
+ title: "Send message",
6800
+ description: "Send a message as you to one of your conversations. The agent answers in the background. When a turn is running, the message waits for it unless `delivery` is `interrupt`. Returns the messages that no turn has read yet and a `cursor`. Pass the `cursor` as `after` to getConversation to read the reply.",
6801
+ inputSchema: {
6802
+ conversationId: mcpConversationIdSchema,
6803
+ message: mcpMessageTextSchema,
6804
+ idempotencyKey: mcpIdempotencyKeySchema,
6805
+ delivery: conversationPendingMessageDeliverySchema.default("defer").describe("`defer` waits for the running turn to end. `interrupt` joins the running turn at its next safe step. Use it to correct or add to the work in progress.")
6806
+ },
6807
+ outputSchema: mcpAcceptedMessageSchema,
6808
+ annotations: {
6809
+ destructiveHint: false,
6810
+ idempotentHint: false,
6811
+ openWorldHint: true,
6812
+ readOnlyHint: false
6813
+ }
6814
+ }, async ({ conversationId, delivery, idempotencyKey, message }) => {
6815
+ if (!await isConversationParticipant(user, conversationId)) return mcpToolError("Conversation not found.");
6816
+ const lastSeq = await readConversationLastEventSeq(getSqlExecutor(), conversationId);
6817
+ let accepted;
6818
+ try {
6819
+ accepted = await appendConversationMessageForViewer(user, conversationId, {
6820
+ idempotencyKey: idempotencyKey ?? randomUUID(),
6821
+ message
6822
+ }, {
6823
+ attachmentStorage,
6824
+ queue
6825
+ });
6826
+ } catch (error) {
6827
+ return apiToolError(error);
6828
+ }
6829
+ if (delivery === "interrupt") try {
6830
+ await steerConversationPendingMessagesForViewer(user, conversationId, { inboundMessageIds: [accepted.messageId] });
6831
+ } catch (error) {
6832
+ logException(error, "mcp.send_message.steer.failed", { "gen_ai.conversation.id": conversationId });
6833
+ }
6834
+ const messageSeq = accepted.status === "duplicate" ? await readConversationMessageEventSeq(getSqlExecutor(), accepted.conversationId, accepted.messageId) : void 0;
6835
+ return mcpToolResult({
6836
+ ...accepted,
6837
+ ...await readMcpPendingWorkAfterSend(user, accepted.conversationId),
6838
+ cursor: encodeConversationCursor({
6839
+ conversationId: accepted.conversationId,
6840
+ seq: messageSeq === void 0 ? lastSeq : messageSeq - 1
6841
+ }),
6842
+ url: getDashboardConversationLink(accepted.conversationId)
6843
+ });
6844
+ });
6845
+ }
6846
+ // src/api/mcp/tools/set-conversation-auto-archive.ts
6847
+ /**
6848
+ * Register `setConversationAutoArchive`, which overrides the user's
6849
+ * auto-archive default for one Conversation.
6850
+ */
6851
+ function registerSetConversationAutoArchiveTool(server, { user }) {
6852
+ server.registerTool("setConversationAutoArchive", {
6853
+ title: "Set conversation auto-archive",
6854
+ description: "Turn auto-archive on or off for one of your conversations. This overrides your default for that conversation only.",
6855
+ inputSchema: {
6856
+ conversationId: mcpConversationIdSchema,
6857
+ autoArchive: z.boolean().describe("True archives the conversation for you after its work is done. False keeps it in your list.")
6858
+ },
6859
+ outputSchema: { autoArchive: z.boolean() },
6860
+ annotations: {
6861
+ destructiveHint: false,
6862
+ idempotentHint: true,
6863
+ openWorldHint: false,
6864
+ readOnlyHint: false
6865
+ }
6866
+ }, async ({ autoArchive, conversationId }) => {
6867
+ try {
6868
+ return mcpToolResult(await setConversationAutoArchive(user, conversationId, autoArchive));
6869
+ } catch (error) {
6870
+ return apiToolError(error);
6871
+ }
6872
+ });
6873
+ }
6503
6874
  // src/api/mcp/tools/stop-conversation.ts
6504
6875
  /** Register `stopConversation`, which stops the active Turn. */
6505
6876
  function registerStopConversationTool(server, { queue, user }) {
@@ -6508,8 +6879,8 @@ function registerStopConversationTool(server, { queue, user }) {
6508
6879
  description: "Stop the running turn of one of your conversations. Messages that wait for the turn are dropped. It starts no new work.",
6509
6880
  inputSchema: { conversationId: mcpConversationIdSchema },
6510
6881
  outputSchema: {
6511
- status: z.enum(["no_work", "requested"]).describe("`no_work` when nothing was running."),
6512
- droppedMessages: z.number().int()
6882
+ status: z.enum(["no_work", "requested"]).describe("`requested` when the running turn was asked to stop. `no_work` when nothing was running."),
6883
+ droppedMessages: z.number().int().describe("Messages that waited for the turn and were dropped.")
6513
6884
  },
6514
6885
  annotations: {
6515
6886
  destructiveHint: true,
@@ -6546,17 +6917,27 @@ const TOOLS_BY_SCOPE = {
6546
6917
  registerGetConversationTool,
6547
6918
  registerListConversationMessagesTool
6548
6919
  ],
6549
- "conversations:manage": [registerArchiveConversationTool, registerStopConversationTool],
6920
+ "conversations:manage": [
6921
+ registerArchiveConversationTool,
6922
+ registerArchiveDoneConversationsTool,
6923
+ registerPinConversationTool,
6924
+ registerSetConversationAutoArchiveTool,
6925
+ registerMarkConversationReadTool,
6926
+ registerStopConversationTool,
6927
+ registerCancelQueuedMessagesTool
6928
+ ],
6929
+ "conversations:write": [registerCreateConversationTool, registerSendMessageTool],
6550
6930
  "review_items:read": [registerSearchReviewItemsTool, registerGetReviewItemTool],
6551
6931
  "automations:read": [registerSearchAutomationsTool, registerGetAutomationTool]
6552
6932
  };
6553
- const INSTRUCTIONS = "Junior is a Slack agent. These tools read your Junior conversations, review items, and automations. They cannot send a message or start agent work. To ask Junior for work or to answer a review item, use the Slack or dashboard link in a result.";
6933
+ const READ_INSTRUCTIONS = "Junior is a Slack agent. These tools read and manage your Junior conversations, and read your review items and automations. They cannot send a message or start agent work. To ask Junior for work or to answer a review item, use the Slack or dashboard link in a result.";
6934
+ const WRITE_INSTRUCTIONS = "Junior is a Slack agent. These tools read and manage your Junior conversations, and read your review items and automations. createConversation and sendMessage send a message as you, and Junior works on it in the background. They return a `cursor`. Call getConversation with `after` set to the newest `cursor` to read the new messages. Repeat until `status` is not `active` and `hasMore` is not set. `authorization` means a turn waits for you to connect an account. To answer a review item, use the dashboard link in a result.";
6554
6935
  /** Build the MCP server for one authenticated user and granted scopes. */
6555
6936
  function createMcpServer(context, scopes) {
6556
6937
  const server = new McpServer({
6557
6938
  name: "junior",
6558
6939
  version: JUNIOR_VERSION
6559
- }, { instructions: INSTRUCTIONS });
6940
+ }, { instructions: scopes.includes("conversations:write") ? WRITE_INSTRUCTIONS : READ_INSTRUCTIONS });
6560
6941
  for (const scope of scopes) for (const register of TOOLS_BY_SCOPE[scope]) register(server, context);
6561
6942
  return server;
6562
6943
  }
@@ -6701,6 +7082,7 @@ function createMcpHttpHandler(options) {
6701
7082
  headers: { allow: "POST" }
6702
7083
  });
6703
7084
  return await handleMcpServerRequest(c.req.raw, {
7085
+ attachmentStorage: options.attachmentStorage,
6704
7086
  queue: options.queue,
6705
7087
  scopes: grant.scopes,
6706
7088
  user
@@ -7042,8 +7424,7 @@ function dashboardHostRoutePaths(dashboard, authenticatedRoutes = []) {
7042
7424
  "/favicon.ico",
7043
7425
  "/_junior/dashboard/avatar.png",
7044
7426
  "/_junior/dashboard/object-icons/*",
7045
- "/_junior/dashboard/client.js",
7046
- "/_junior/dashboard/chunks/*",
7427
+ "/_junior/dashboard/assets/*",
7047
7428
  "/_junior/dashboard/icon-512.png",
7048
7429
  "/_junior/dashboard/manifest.webmanifest",
7049
7430
  loginPath,
@@ -7425,7 +7806,7 @@ async function createApp(options) {
7425
7806
  logException(err, "route.unhandled.exception");
7426
7807
  return c.text("Internal Server Error", 500);
7427
7808
  });
7428
- app.use("*", async (c, next) => {
7809
+ app.use("*", async function sandboxEgress(c, next) {
7429
7810
  return await handleSandboxEgressRoute(c.req.raw, sandboxEgressTracePropagationDomains, next);
7430
7811
  });
7431
7812
  app.on([
@@ -7443,6 +7824,7 @@ async function createApp(options) {
7443
7824
  handleMcpRequest ??= createMcpHttpHandler({
7444
7825
  allowedDomains,
7445
7826
  baseURL: resolvePublicBaseURL(dashboard),
7827
+ attachmentStorage,
7446
7828
  queue: conversationWorkQueue,
7447
7829
  state: getMcpState()
7448
7830
  });