@sentry/junior 0.298.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 (95) hide show
  1. package/dist/{actor-6jsm_v96.js → actor-D2iXzvlN.js} +2 -1
  2. package/dist/{state-CSuA2J1V.js → adapter-S5UkjNK3.js} +53 -136
  3. package/dist/{admin-BF3DbYGf.js → admin-UrTniSPO.js} +2 -2
  4. package/dist/{agent-runner-Q9GkoerG.js → agent-runner-bY4_0UPm.js} +1444 -1478
  5. package/dist/api/schema.d.ts +2 -2
  6. package/dist/api/schema.js +7 -7
  7. package/dist/api.d.ts +1 -1
  8. package/dist/api.js +382 -68
  9. package/dist/{app-DOg_mCtV.d.ts → app-D-AcIcCV.d.ts} +17 -4
  10. package/dist/app.d.ts +1 -1
  11. package/dist/app.js +148 -483
  12. package/dist/{automation-Cn8qmbdr.js → automation-Dw82oQ-h.js} +2 -2
  13. package/dist/{background-compaction-queue-BZhGFOK6.js → background-compaction-queue-B6U3060-.js} +9 -5
  14. package/dist/{briefs-CQrCRF6-.js → briefs-DqiwWu-n.js} +4 -4
  15. package/dist/{catalog-runtime-DZeD2WbL.js → catalog-runtime-D1oYNv04.js} +1 -1
  16. package/dist/cli/chat.js +17 -17
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.js +5 -5
  20. package/dist/cli/snapshot-create.js +4 -4
  21. package/dist/cli/upgrade.d.ts +1 -1
  22. package/dist/cli/upgrade.js +4 -4
  23. package/dist/{config-BOByVnxe.js → config-9nHoFiJP.js} +117 -12
  24. package/dist/{connections-BNN5cJam.js → connections-DZjTN3JC.js} +6 -6
  25. package/dist/continue-in-slack-Dtv7_U42.js +176 -0
  26. package/dist/{conversation-DCkzvxqB.js → conversation-Dyjq2CZ8.js} +36 -13
  27. package/dist/{conversation-feed-CMA12Rjs.js → conversation-feed-CcDxlrlQ.js} +109 -3
  28. package/dist/{conversation-privacy-C0eRxsgb.js → conversation-privacy-D-5HTXjS.js} +1 -1
  29. package/dist/{conversation-turn-D9qvcDX6.js → conversation-turn-Cxl8WZD7.js} +85 -68
  30. package/dist/{credential-sync-B_iUpxGL.js → credential-sync-C49ClwDX.js} +18 -18
  31. package/dist/{db-DoMcnYol.d.ts → db-2resqBh1.d.ts} +1 -1
  32. package/dist/{db-CoMNr2Zm.js → db-BJNo6fK5.js} +176 -12
  33. package/dist/{executor-C-m8VrzX.js → executor-DBIaOeJ_.js} +47 -13
  34. package/dist/{media-BepyEUNm.js → history-IjdmO_r6.js} +1 -85
  35. package/dist/instrumentation.js +14 -5
  36. package/dist/lineage-0dereG7H.js +37 -0
  37. package/dist/{logging-CJTi5niy.js → logging-BIclibct.js} +1 -1
  38. package/dist/{message-Q6_5DAWR.js → message-dkOl-Iii.js} +9 -10
  39. package/dist/model-input-CLo9TaUd.js +82 -0
  40. package/dist/nitro.d.ts +1 -1
  41. package/dist/nitro.js +17 -9
  42. package/dist/{oauth-callback-server-CH5XAyo-.js → oauth-callback-server-WmpjfJgQ.js} +2 -2
  43. package/dist/{plugins-HYh_JOdw.js → plugins-BBX07Jzt.js} +1 -1
  44. package/dist/{projection-BgwEE36_.js → projection-w_X-zi7v.js} +1035 -692
  45. package/dist/{prompt-DXc9DYT9.js → prompt-B1Xw46-S.js} +4 -4
  46. package/dist/{registry-9XwqSnM-.js → registry-BmP5vnlj.js} +4 -4
  47. package/dist/{resolve-DUIAbcRL.js → resolve-goo34bJK.js} +3 -3
  48. package/dist/{result-C2Vn8QGn.js → result-PVBeU0Wf.js} +158 -69
  49. package/dist/{runner-CXGtw-Mc.js → runner-DKrfvNV6.js} +9 -9
  50. package/dist/{sandbox-egress-signals-Di3S_dO7.js → sandbox-egress-signals-DsUcqrI0.js} +1 -1
  51. package/dist/{schema-Dyp7racy.js → schema-C9iNFz5n.js} +51 -7
  52. package/dist/{schema-BnbZ-rKv.d.ts → schema-Dns-sTas.d.ts} +1285 -761
  53. package/dist/{service-account-DM3KBBeG.js → service-account-CMAAloAL.js} +3 -3
  54. package/dist/{service-account-GzAMUQ8a.js → service-account-CmowamcB.js} +4 -4
  55. package/dist/session-stop-BcAXze8a.js +3330 -0
  56. package/dist/{skills-DCK9SD_l.js → skills-DfsazET6.js} +3 -3
  57. package/dist/slack-conversation-unfurl-CzQonuWz.js +370 -0
  58. package/dist/spawn-C7o0FDDp.js +73 -0
  59. package/dist/state-zSilNpbi.js +132 -0
  60. package/dist/{user-input-request-CXNIov9n.js → statuses-Hn-HsOph.js} +115 -26
  61. package/dist/{stop-Dh2DfwpK.js → stop-CFOujp8C.js} +9105 -6007
  62. package/dist/{store-DrA17Fbz.js → store-Dkeis_8o.js} +10 -10
  63. package/dist/{store-B1zepKG8.js → store-E3x2Fg_F.js} +24 -4
  64. package/dist/{task-queue-D1rXWfFN.js → task-queue-D-hCqdZW.js} +4 -4
  65. package/dist/{task-runner-CT4M8oDz.js → task-runner-vohUPLHe.js} +10 -10
  66. package/dist/{thread-context-DnqUkbzN.js → thread-context-BzvdkgI9.js} +18 -18
  67. package/dist/{turn-session-routing-VXDVXLRl.js → turn-session-routing-Bo_LxFum.js} +5 -5
  68. package/dist/turn-user-message-D5RnVmxQ.js +355 -0
  69. package/dist/users-2bggndVg.js +424 -0
  70. package/dist/{validation-zxAJBDDy.js → validation-BbWikeSa.js} +1 -1
  71. package/dist/{version-DcZ40a0g.js → version-GVBMW2jA.js} +1 -1
  72. package/dist/version.js +1 -1
  73. package/dist/{viewer-CgiGjW10.js → viewer-BpxRliyO.js} +36 -163
  74. package/dist/{warmup-CwKbxQLl.js → warmup-BW2qwnal.js} +1140 -145
  75. package/dist/{worker-CbDUzaBA.js → worker-Cbd-iuwZ.js} +25 -20
  76. package/migrations/0104_code_change_draft.sql +1 -0
  77. package/migrations/0105_attachment_uploads.sql +14 -0
  78. package/migrations/0106_conversation_agent_config.sql +1 -0
  79. package/migrations/0107_attachment_deferred_download.sql +2 -0
  80. package/migrations/meta/0104_snapshot.json +4516 -0
  81. package/migrations/meta/0105_snapshot.json +4611 -0
  82. package/migrations/meta/0106_snapshot.json +4617 -0
  83. package/migrations/meta/0107_snapshot.json +4617 -0
  84. package/migrations/meta/_journal.json +28 -0
  85. package/package.json +10 -8
  86. package/dist/attempt-selection-ClP3MMPr.js +0 -61
  87. package/dist/locks-D-0h111u.js +0 -48
  88. package/dist/notification-Bv25xbj0.js +0 -1284
  89. package/dist/prompt-input-BUr4J9RO.js +0 -1424
  90. package/dist/session-stop-D4i7e6iT.js +0 -181
  91. package/dist/spawn-6cX6xE9G.js +0 -80
  92. package/dist/turn-cancel-l460pfGW.js +0 -201
  93. package/dist/turn-user-message-BSPmkm7X.js +0 -608
  94. package/dist/turn-wake-DVFVXyhX.js +0 -161
  95. package/dist/{oauth-relay-CsfIazeF.js → oauth-relay-DRzq73b6.js} +1 -1
package/dist/app.js CHANGED
@@ -1,49 +1,48 @@
1
1
  import { i as getActiveSpan, n as captureMessage, u as sentry_exports } from "./sentry-BRTJqumy.js";
2
- import { $i as escapeSlackMrkdwnText, Ao as readConversationMessageEventSeq, Ba as consumeSandboxEgressPermissionDeniedSignal, Bo as resolveRootVisibility, C as settleConversationTitleWork, Ci as getDashboardTaskLink, Di as createPluginState, Do as readConversationEventPageAfter, Eo as readConversationEventPage, Ft as pruneActiveConversation, Ha as parseSandboxEgressCredentialToken, Hn as createUserTokenStore, Ho as createPluginAnnotations, Hr as reviewItemReaderForUserInConversation, Jn as createPluginEventPublisher, Jr as createCodeChangePublisher, Ka as normalizeSandboxEgressTracePropagationDomains, Ki as isVercelSandboxEgressRequest, Mr as canActOnReviewItem, Oa as getWorkspaceTeamId, Or as searchReviewItems, Qa as createPluginEmbedder, Ra as clearSandboxEgressSignals, Sa as getSlackClient, Ti as setDashboardConversationLinkOptions, To as readLatestConversationBrief, Uo as listConversationAnnotations, Vr as reviewItemReaderForUser, Xn as getPluginApiRoutes, Zi as resolveBaseUrl, Zn as getPluginRoutes, Zo as createPluginCache, _ as appendConversationMessages, _a as slackExternalRefIdSchema, _r as projectConversationMessages, di as bindEventAutomationCredentialSubject, ea as formatSlackLink, fi as bindScheduledAutomationCredentialSubject, fo as createPluginLogger, ga as slackEntitySchema, gi as verifySlackDirectCredentialSubject, go as readConversationAccessFromSql, hi as verifyScheduledAutomationCredentialSubject, ir as validatePlugins, is as setConfigDefaults, jt as isInvalidConversationRecordError, ka as runWithWorkspaceTeamId, ko as readConversationLastEventSeq, kt as hasRunnableConversationWork, la as openSlackModal, mi as verifyEventAutomationCredentialSubject, nr as getPlugins, pa as unfurlSlackLinks, pi as bindSlackDirectCredentialSubject, qi as proxyVercelSandboxEgressRequest, ra as slackMention, ri as collectEventMatchKeys, rr as setPlugins, rs as getConfigDefaults, si as findMatchingWatches, sr as setBriefsConfig, ua as postSlackEphemeralMessage, ui as takeDueTimerWatches, ut as CONVERSATION_WORK_STALE_ENQUEUE_MS, wa as isDmChannel, wi as parseDashboardConversationLink, xi as getDashboardReviewItemLink, xr as dismissOpenReviewItems, yi as getDashboardConversationLink, za as consumeSandboxEgressAuthRequiredSignal } from "./projection-BgwEE36_.js";
3
- import { Y as getAttachmentStorage, 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-BOByVnxe.js";
4
- import { A as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, E as withSpan, H as GOOGLE_IDENTITY_PROVIDER, L as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, P as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, T as withLogContext, W as normalizeIdentityEmail, b as setSpanAttributes, h as logWarn, k as JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE, m as logInfo, p as logException, r as createRequestContext, w as withContext } from "./logging-CJTi5niy.js";
5
- import { t as JUNIOR_VERSION } from "./version-DcZ40a0g.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 { B as recordGoogleSignIn, O as conversationKindFromRow, P as resolveActorIdentityId, S as withConversationMutationLock, W as getConversationIdByProviderConversation, a as getConversationStore, nt as createSlackDestination, o as getDb, p as withConversationEventLock, r as getConversationEventStore, s as getSqlExecutor, t as closeDb, tt as touchConversationDetail } from "./db-CoMNr2Zm.js";
8
- import { A as juniorConversations, N as juniorDestinations, b as juniorConversationBriefs, f as juniorAutomations, g as juniorAgentInvocations, h as juniorAgentBindings, l as juniorReviewItems, u as juniorAutomationRuns, w as juniorConversationEvents } from "./executor-C-m8VrzX.js";
9
- import { n as pluginCatalogRuntime } from "./catalog-runtime-DZeD2WbL.js";
10
- import { A as parseSlackUserInputSubmission, At as processWorkspaceSnapshotJob, B as joinPublicChannel, C as createSlackReviewItemShow, D as buildSlackReviewItemModal, L as checkSlackChannelReadAccess, M as verifySlackSignature, Mt as findAutomationSkill, N as parseSlackThreadId, Nt as missingAutomationSkillReason, O as parseSlackReviewItemClick, Q as readViewerAutomationExecutions, St as archiveConversation, T as syncReviewItemSlackCards, U as logScheduledAutomationRunSkipped, W as scheduledAutomationRunAttributes, X as ViewerTaskNotFoundError, _ as readPublicArtifact, b as lookupSlackUserProfile, bt as requestAttachmentDeletion, ct as reviewItemChangeRecord, dt as conversationTurnIdForMessage, et as readViewerAutomationSummary, g as publicArtifactHeaders, ht as webActorFromUser, it as effectiveTaskOutcomes, j as runWithSlackInstallation, jt as ingestEvent, k as parseSlackReviewItemFormTarget, mt as recordWebConversationActivity, n as executeAgentRun, nt as readViewerAutomations, ot as deliverReviewItemChange, r as processBackgroundCompaction, st as renderReviewItemMessage, t as createAgentRunner, ut as appendAndEnqueueWebMessage, v as unpublishedArtifactHeaders, vt as collectAttachmentGarbage, w as readSlackReviewItemCardConversationId, wt as markConversationRead, y as setConversationSubscription } from "./agent-runner-Q9GkoerG.js";
11
- import { a as withLock, i as fenceLock, n as MUTATION_LOCK_TTL_MS } from "./locks-D-0h111u.js";
12
- import { g as createCache, i as readActorIdentity, l as resolveViewerUser, p as parseAvatarUrl } from "./viewer-CgiGjW10.js";
13
- import { a as getStateAdapter, r as disconnectStateAdapter } from "./state-CSuA2J1V.js";
2
+ import { Aa as slackEntitySchema, Ao as readConversationEventPageAfter, Ar as dismissOpenReviewItems, Ba as clearSandboxEgressSignals, C as settleConversationTitleWork, Ca as openSlackModal, Ci as verifyEventAutomationCredentialSubject, Cs as getConfigDefaults, Er as projectConversationMessages, Ha as consumeSandboxEgressPermissionDeniedSignal, Ja as normalizeSandboxEgressTracePropagationDomains, Jo as getSlackClient, Lr as searchReviewItems, Mi as getDashboardReviewItemLink, Mo as readConversationLastEventSeq, Mt as hasRunnableConversationWork, No as readConversationMessageEventSeq, Oi as getDashboardConversationLink, Pi as getDashboardTaskLink, Pt as isInvalidConversationRecordError, Ri as setDashboardConversationLinkOptions, Rt as pruneActiveConversation, Si as bindSlackDirectCredentialSubject, Ti as verifySlackDirectCredentialSubject, Va as consumeSandboxEgressAuthRequiredSignal, Vr as canActOnReviewItem, Wa as parseSandboxEgressCredentialToken, Xo as isDmChannel, Xr as reviewItemReaderForUser, Zn as createUserTokenStore, Zr as reviewItemReaderForUserInConversation, _ as appendConversationMessages, _s as createPluginCache, aa as proxyVercelSandboxEgressRequest, ar as getPluginApiRoutes, bi as bindEventAutomationCredentialSubject, cs as createPluginAnnotations, dr as getPlugins, dt as CONVERSATION_WORK_STALE_ENQUEUE_MS, fi as collectEventMatchKeys, fr as setPlugins, ga as slackMention, gi as findMatchingWatches, gr as setBriefsConfig, ho as createPluginLogger, ia as isVercelSandboxEgressRequest, is as runWithWorkspaceTeamId, ja as slackExternalRefIdSchema, ko as readConversationEventPage, la as resolveBaseUrl, ls as listConversationAnnotations, or as getPluginRoutes, os as resolveRootVisibility, pr as validatePlugins, ri as createCodeChangePublisher, rr as createPluginEventPublisher, rs as getWorkspaceTeamId, to as createPluginEmbedder, wa as postSlackEphemeralMessage, wi as verifyScheduledAutomationCredentialSubject, ws as setConfigDefaults, xi as bindScheduledAutomationCredentialSubject, yi as takeDueTimerWatches, yo as readConversationAccessFromSql, zi as createPluginState } from "./projection-w_X-zi7v.js";
3
+ import { Z as getAttachmentStorage, d as restoreRuntimeConfig, f as setBotModelConfig, g as snapshotRuntimeConfig, h as setSlackReactionConfig, i as getChatConfig, m as setRuntimeLimits, n as botConfig, o as getSlackBotToken, p as setBotName, u as resetRuntimeConfig } from "./config-9nHoFiJP.js";
4
+ import { A as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, E as withSpan, H as GOOGLE_IDENTITY_PROVIDER, L as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, O as JUNIOR_AUTO_ARCHIVE_ROUTE, P as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, T as withLogContext, W as normalizeIdentityEmail, b as setSpanAttributes, h as logWarn, k as JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE, m as logInfo, p as logException, r as createRequestContext, w as withContext } from "./logging-BIclibct.js";
5
+ import { t as JUNIOR_VERSION } from "./version-GVBMW2jA.js";
6
+ import { b as slackMessageTsSchema, g as slackTeamIdSchema, h as slackChannelIdSchema, n as createSlackActor, p as parseSlackUserId, s as parseActorUserId, u as parseSlackChannelId, v as parseSlackMessageTs, y as slackMessageTsFromMs } from "./actor-D2iXzvlN.js";
7
+ import { D as conversationKindFromRow, N as resolveActorIdentityId, W as createCache, a as getConversationStore, f as withConversationEventLock, it as createSlackDestination, o as getDb, r as getConversationEventStore, rt as touchConversationDetail, s as getSqlExecutor, t as closeDb, x as withConversationMutationLock, z as recordGoogleSignIn } from "./db-BJNo6fK5.js";
8
+ import { P as juniorDestinations, b as juniorConversationBriefs, f as juniorAutomations, g as juniorAgentInvocations, h as juniorAgentBindings, j as juniorConversations, l as juniorReviewItems, u as juniorAutomationRuns, w as juniorConversationEvents } from "./executor-DBIaOeJ_.js";
9
+ import { c as fenceLock, l as withLock, o as MUTATION_LOCK_TTL_MS, r as getStateAdapter, t as disconnectStateAdapter } from "./adapter-S5UkjNK3.js";
10
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-D1oYNv04.js";
11
+ import { $ as effectiveTaskOutcomes, A as parseSlackReviewItemClick, At as ingestEvent, Ct as markConversationRead, D as syncReviewItemSlackCards, E as readSlackReviewItemCardConversationId, G as ViewerTaskNotFoundError, M as parseSlackUserInputSubmission, Mt as missingAutomationSkillReason, N as parseSlackThreadId, R as logScheduledAutomationRunSkipped, T as createSlackReviewItemShow, Y as readViewerAutomationSummary, Z as readViewerAutomations, _t as collectAttachmentGarbage, at as appendAndEnqueueWebMessage, b as unpublishedArtifactHeaders, j as parseSlackReviewItemFormTarget, jt as findAutomationSkill, k as buildSlackReviewItemModal, kt as processWorkspaceSnapshotJob, lt as recordWebConversationActivity, n as executeAgentRun, nt as renderReviewItemMessage, ot as conversationTurnIdForMessage, pt as collectAttachmentUploadGarbage, q as readViewerAutomationExecutions, r as processBackgroundCompaction, rt as reviewItemChangeRecord, t as createAgentRunner, tt as deliverReviewItemChange, ut as webActorFromUser, v as publicArtifactHeaders, x as setConversationSubscription, xt as archiveConversation, y as readPublicArtifact, yt as requestAttachmentDeletion, z as scheduledAutomationRunAttributes } from "./agent-runner-bY4_0UPm.js";
14
12
  import { a as getNextRunAtMs } from "./schedule-cP0AACm1.js";
15
- import { L as annotationCard, M as conversationTitleSchema, Z as conversationBriefSchema, b as conversationSurfaceSchema, p as conversationFeedQuerySchema, v as conversationReportStatusSchema } from "./conversation-DCkzvxqB.js";
13
+ import { i as readActorIdentity, l as resolveViewerUser, p as parseAvatarUrl } from "./viewer-BpxRliyO.js";
14
+ import { P as conversationTitleSchema, et as conversationBriefSchema, m as conversationFeedQuerySchema, x as conversationSurfaceSchema, y as conversationReportStatusSchema, z as annotationCard } from "./conversation-Dyjq2CZ8.js";
16
15
  import { t as SANDBOX_EGRESS_PROXY_PATH } from "./proxy-path-BHYoKZdq.js";
17
16
  import { n as readSchedulerSecret, r as readSignInSecret } from "./secrets-DebYU866.js";
18
- import { f as getExperimentalFeatures, g as getAuthPausedConversationTurnId, m as setExperimentalFeatures, p as isExperimentalFeatureEnabled } from "./prompt-input-BUr4J9RO.js";
19
- import { B as MIN_WARMUP_PREFIX_TOKENS, D as recordSubagentEnded, U as gapSegment, V as NO_REPLY_GAP_MS, a as segmentGapsKey, n as GLOBAL_GAPS_MAX, r as GLOBAL_GAPS_TTL_MS, t as CONVERSATION_STATE_TTL_MS, x as enqueueAgentInvocation, z as MINUTE_MS } from "./warmup-CwKbxQLl.js";
20
- import { C as queueCallback, T as getQueueProvider, _ as createVercelCacheWarmupCallback, a as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, c as verifyWorkspaceSnapshotJobMessage, d as verifyConversationQueueMessage, g as cacheWarmupQueueConsumer, i as verifyBackgroundCompactionMessage, l as getVercelConversationWorkQueue, m as isConversationQueueMessageRejectedError, p as conversationQueueMessageSchema, r as vercelBackgroundCompactionQueue, t as BACKGROUND_COMPACTION_QUEUE_TOPIC, u as resolveConversationWorkQueueTopic, v as registerVercelCacheWarmupDevConsumer } from "./background-compaction-queue-BZhGFOK6.js";
21
- import { M as listPendingAgentInvocationMailboxAppends, N as listPendingAgentInvocationResults } from "./turn-user-message-BSPmkm7X.js";
22
- import { C as renderSlackObjectCard, c as SLACK_EVENT_NAMESPACE, d as slackChannelMessageReplyThreadTs, f as slackChannelMessageRunsAutomation, s as getEventCatalog, u as slackChannelMessageEvent, v as renderTaskInput } from "./notification-Bv25xbj0.js";
23
- import { _ as getConversationWorkState, g as getConversation, h as ensureConversationWake, l as clearExpiredConversationLease, r as appendAndEnqueueInboundMessage, v as listActiveConversationIds } from "./store-B1zepKG8.js";
24
- import { c as coerceThreadConversationState, p as eventGuidance } from "./turn-session-routing-VXDVXLRl.js";
25
- import { r as buttonUserInputField } from "./user-input-request-CXNIov9n.js";
26
- import { c as setSandboxResourceConfig, o as getSandboxResourceConfig } from "./resolve-DUIAbcRL.js";
27
- import { H as automationTaskSchema, N as scheduledRunSchema, U as automationTaskText, l as automationListQuerySchema, s as automationExecutionStatusSchema } from "./automation-Cn8qmbdr.js";
28
- import { $ as eventAutomationRunLimitReason, B as scheduledRunId, F as listScheduledAutomationsForTeam, H as blockEventAutomation, K as findMatchingEventAutomations, L as readScheduledAutomation, O as recordAutomationExecution, Q as admitEventAutomationRun, U as collectEventAutomationMatchKeys, V as withScheduledAutomationLock, a as getDispatchConversationId, b as existingConversationId, c as getDispatchRecord, d as isTerminalDispatchStatus, f as listPendingDispatchMailboxAppends, g as markDispatchFailed, i as createOrGetDispatch, r as confirmDispatchMailboxAppend, t as buildDispatchId, tt as automationVersionOf, u as getPluginDispatchProjection, v as notifyAutomationBlocked, z as saveScheduledAutomationInLock } from "./store-DrA17Fbz.js";
29
- import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "./validation-zxAJBDDy.js";
30
- import { a as pluginRuntimeRegistrationsFromPluginSet, n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "./plugins-HYh_JOdw.js";
31
- import { s as conversationPendingMessageDeliverySchema } from "./conversation-feed-CMA12Rjs.js";
32
- import { $ as reviewItemChange, A as assertNoLegacyAllowedDomains, B as normalizeIncomingSlackThreadId, C as cancelConversationPendingMessagesForViewer, D as createProductionConversationWorkOptions, F as startProcessingReaction, G as stopConversation, H as createSlackWebApiStatusSender, I as buildSlackInboundMessage, J as bindMessageAuthorIdentityId, K as parseContent, L as clearSlackPendingReactions, M as isAllowedSignInEmail, N as readEnvList, O as createProductionSlackWebhookServices, P as resolveAllowedDomains, Q as readReviewItemForUser, R as slackInboundMessageId, S as encodeConversationCursor, U as SubscribedReplyReason, V as withNormalizedThreadId, W as getThreadStopDecision, X as actOnReviewItem, Y as ReviewItemActionError, Z as closeReviewItemsAnsweredByReply, a as pinConversation, at as archiveViewerDoneConversations, b as createConversationForViewer, ct as setConversationAutoArchive, dt as enqueueAgentDispatch, et as alreadyContinuesInSlackMessage, ft as GET$4, g as readConversationRecordFromSql, i as readConversationFeed, j as isAllowedDomain, k as getProductionSlackAdapter, n as steerConversationPendingMessagesForViewer, nt as continueConversationInSlack, q as recordSkippedConversationMessage, rt as isMovableToSlack, s as readConversationDetail, st as runAutoArchiveSweep, t as stopConversationTurnForViewer, tt as canContinueInSlack, w as readConversationPendingMessages, x as decodeConversationCursor, y as appendConversationMessageForViewer, z as stripLeadingBotMention } from "./stop-Dh2DfwpK.js";
33
- import { i as enqueueAgentInvocationResult, r as createEndStoppedChildWork } from "./result-C2Vn8QGn.js";
34
- import { o as unlinkProvider } from "./connections-BNN5cJam.js";
35
- import { a as GET$5, i as publishAppHomeView, r as GET$6, t as receiveLocalOAuthCredential } from "./credential-sync-B_iUpxGL.js";
17
+ import { C as getAuthPausedConversationTurnId, H as slackChannelMessageReplyThreadTs, R as getEventCatalog, U as slackChannelMessageRunsAutomation, V as slackChannelMessageEvent, Y as renderTaskInput, b as isExperimentalFeatureEnabled, et as renderSlackObjectCard, x as setExperimentalFeatures, y as getExperimentalFeatures, z as SLACK_EVENT_NAMESPACE } from "./session-stop-BcAXze8a.js";
18
+ import { At as MIN_WARMUP_PREFIX_TOKENS, C as listPendingAgentInvocationMailboxAppends, H as enqueueAgentInvocation, Nt as gapSegment, X as recordSubagentEnded, a as segmentGapsKey, jt as NO_REPLY_GAP_MS, kt as MINUTE_MS, n as GLOBAL_GAPS_MAX, r as GLOBAL_GAPS_TTL_MS, t as CONVERSATION_STATE_TTL_MS, w as listPendingAgentInvocationResults } from "./warmup-BW2qwnal.js";
19
+ import { E as getQueueProvider, _ as cacheWarmupQueueConsumer, a as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC, c as verifyWorkspaceSnapshotJobMessage, d as verifyConversationQueueMessage, i as verifyBackgroundCompactionMessage, l as getVercelConversationWorkQueue, m as isConversationQueueMessageRejectedError, p as conversationQueueMessageSchema, r as vercelBackgroundCompactionQueue, t as BACKGROUND_COMPACTION_QUEUE_TOPIC, u as resolveConversationWorkQueueTopic, v as createVercelCacheWarmupCallback, w as queueCallback, y as registerVercelCacheWarmupDevConsumer } from "./background-compaction-queue-B6U3060-.js";
20
+ import { _ as getConversationWorkState, g as getConversation, h as ensureConversationWake, l as clearExpiredConversationLease, r as appendAndEnqueueInboundMessage, y as listActiveConversationIds } from "./store-E3x2Fg_F.js";
21
+ import { c as coerceThreadConversationState, p as eventGuidance } from "./turn-session-routing-Bo_LxFum.js";
22
+ import { o as buttonUserInputField } from "./statuses-Hn-HsOph.js";
23
+ import { c as setSandboxResourceConfig, o as getSandboxResourceConfig } from "./resolve-goo34bJK.js";
24
+ import { H as automationTaskSchema, N as scheduledRunSchema, U as automationTaskText, l as automationListQuerySchema, s as automationExecutionStatusSchema } from "./automation-Dw82oQ-h.js";
25
+ import { $ as eventAutomationRunLimitReason, B as scheduledRunId, F as listScheduledAutomationsForTeam, H as blockEventAutomation, K as findMatchingEventAutomations, L as readScheduledAutomation, O as recordAutomationExecution, Q as admitEventAutomationRun, U as collectEventAutomationMatchKeys, V as withScheduledAutomationLock, a as getDispatchConversationId, b as existingConversationId, c as getDispatchRecord, d as isTerminalDispatchStatus, f as listPendingDispatchMailboxAppends, g as markDispatchFailed, i as createOrGetDispatch, r as confirmDispatchMailboxAppend, t as buildDispatchId, tt as automationVersionOf, u as getPluginDispatchProjection, v as notifyAutomationBlocked, z as saveScheduledAutomationInLock } from "./store-Dkeis_8o.js";
26
+ import { a as runWithSlackInstallation, o as verifySlackSignature, p as joinPublicChannel, r as lookupSlackUserProfile } from "./users-2bggndVg.js";
27
+ import { A as resolveAllowedDomains, B as runAutoArchiveSweep, C as readConversationPendingMessages, D as isAllowedDomain, E as assertNoLegacyAllowedDomains, F as readReviewItemForUser, I as reviewItemChange, K as readObjectLinkTypes, M as ReviewItemActionError, N as actOnReviewItem, O as isAllowedSignInEmail, P as closeReviewItemsAnsweredByReply, R as archiveViewerDoneConversations, S as cancelConversationPendingMessagesForViewer, U as GET$4, V as setConversationAutoArchive, X as isPublicAddress, Z as publicAddressLookup, _ as appendConversationMessageForViewer, _t as SubscribedReplyReason, a as pinConversation, at as slackInboundMessageId, b as decodeConversationCursor, dt as recordSkippedConversationMessage, et as createProductionConversationWorkOptions, ft as createSlackWebApiStatusSender, g as readConversationRecordFromSql, gt as parseContent, ht as stripLeadingBotMention, i as readConversationFeed, it as clearSlackPendingReactions, j as stopConversation, k as readEnvList, lt as enqueueAgentDispatch, mt as startProcessingReaction, n as steerConversationPendingMessagesForViewer, nt as getProductionSlackAdapter, ot as normalizeIncomingSlackThreadId, pt as bindMessageAuthorIdentityId, rt as buildSlackInboundMessage, s as readConversationDetail, st as withNormalizedThreadId, t as stopConversationTurnForViewer, tt as createProductionSlackWebhookServices, ut as failStoppedDispatch, v as createConversationForViewer, vt as getThreadStopDecision, x as encodeConversationCursor } from "./stop-CFOujp8C.js";
28
+ import { s as conversationPendingMessageDeliverySchema } from "./conversation-feed-CcDxlrlQ.js";
29
+ import { a as resumeConversationDelivery } from "./conversation-turn-Cxl8WZD7.js";
30
+ import { i as enqueueAgentInvocationResult, r as createEndStoppedChildWork } from "./result-PVBeU0Wf.js";
31
+ import { t as bindMessageAgent } from "./message-dkOl-Iii.js";
32
+ import { t as bindSpawnAgent } from "./spawn-C7o0FDDp.js";
33
+ import { a as pluginTaskQueueConsumer, n as createVercelPluginTaskCallback, o as registerVercelPluginTaskDevConsumer } from "./task-queue-D-hCqdZW.js";
34
+ import { t as processPluginTask } from "./task-runner-vohUPLHe.js";
35
+ import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "./validation-BbWikeSa.js";
36
+ import { a as pluginRuntimeRegistrationsFromPluginSet, n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "./plugins-BBX07Jzt.js";
37
+ import { o as unlinkProvider } from "./connections-DZjTN3JC.js";
38
+ import { a as GET$5, i as publishAppHomeView, r as GET$6, t as receiveLocalOAuthCredential } from "./credential-sync-C49ClwDX.js";
36
39
  import { t as nameRequestRoute } from "./sentry-route-name-BhwWnfqj.js";
37
- import { c as resumeConversationDelivery } from "./conversation-turn-D9qvcDX6.js";
38
- import { t as processConversationWork } from "./worker-CbDUzaBA.js";
39
- import { t as bindMessageAgent } from "./message-Q6_5DAWR.js";
40
- import { t as bindSpawnAgent } from "./spawn-6cX6xE9G.js";
41
- import { a as pluginTaskQueueConsumer, n as createVercelPluginTaskCallback, o as registerVercelPluginTaskDevConsumer } from "./task-queue-D1rXWfFN.js";
42
- import { t as processPluginTask } from "./task-runner-CT4M8oDz.js";
40
+ import { a as resolveSlackActingUser, i as unfurlDashboardConversationLinks, n as handleSlackContinueHereClick, o as isSlackWorkspaceMember, s as slackWorkspaceBotId, t as SLACK_CONTINUE_HERE_ACTION_ID } from "./slack-conversation-unfurl-CzQonuWz.js";
41
+ import { t as processConversationWork } from "./worker-Cbd-iuwZ.js";
43
42
  import { createRequire } from "node:module";
44
43
  import { Hono } from "hono";
45
- import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
46
44
  import * as z from "zod";
45
+ import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
47
46
  import { and, asc, desc, eq, gte, inArray, isNotNull, isNull, lte, ne, or, sql } from "drizzle-orm";
48
47
  import { EVENT_SUMMARY_MAX_LENGTH, EVENT_TEXT_MAX_LENGTH, dispatchOptionsSchema, eventSchema, eventTriggerFiltersText, isSlackDestination, userSchema } from "@sentry/junior-plugin-api";
49
48
  import { pathToFileURL } from "node:url";
@@ -55,7 +54,6 @@ import { HTTPException } from "hono/http-exception";
55
54
  import https from "node:https";
56
55
  import { Message, ThreadImpl } from "chat";
57
56
  import * as acp from "@agentclientprotocol/sdk";
58
- import dns from "node:dns";
59
57
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
60
58
  import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
61
59
  import { bodyLimit } from "hono/body-limit";
@@ -1377,7 +1375,17 @@ async function runScheduledAutomationHeartbeat(args) {
1377
1375
  dispatch,
1378
1376
  nowMs: args.nowMs,
1379
1377
  run
1380
- })) processedCount += 1;
1378
+ })) {
1379
+ processedCount += 1;
1380
+ continue;
1381
+ }
1382
+ if (!isTerminalDispatchStatus(dispatch.status) && args.nowMs - (run.startedAtMs ?? run.claimedAtMs) > 864e5) await finishClaimedRun({
1383
+ db,
1384
+ errorMessage: "Scheduled automation run did not finish within 24 hours.",
1385
+ nowMs: args.nowMs,
1386
+ run,
1387
+ status: "failed"
1388
+ });
1381
1389
  }
1382
1390
  for (let index = processedCount; index < SCHEDULED_AUTOMATION_HEARTBEAT_LIMIT; index += 1) {
1383
1391
  const run = await claimDueScheduledRun(db, { nowMs: args.nowMs });
@@ -1569,8 +1577,12 @@ async function recoverPendingAgentInvocationResults(args) {
1569
1577
  async function runHeartbeat(args) {
1570
1578
  const queue = args.conversationWorkQueue ?? getVercelConversationWorkQueue();
1571
1579
  const events = args.events ?? createEventAppPublisher({ conversationWork: () => ({ queue }) });
1580
+ const endStoppedChildWork = createEndStoppedChildWork({ queue });
1572
1581
  await recoverConversationWork({
1573
- beforeWorkStops: createEndStoppedChildWork({ queue }),
1582
+ beforeWorkStops: async (conversationId, inboundMessageIds) => {
1583
+ await endStoppedChildWork(conversationId, inboundMessageIds);
1584
+ await failStoppedDispatch(conversationId);
1585
+ },
1574
1586
  nowMs: args.nowMs,
1575
1587
  queue
1576
1588
  });
@@ -1884,8 +1896,14 @@ async function runRetentionPurge(executor, args) {
1884
1896
  nowMs: args.nowMs,
1885
1897
  storage: args.attachmentStorage
1886
1898
  }) : { deleted: 0 };
1899
+ const uploadResult = args.attachmentStorage ? await collectAttachmentUploadGarbage({
1900
+ db: executor,
1901
+ nowMs: args.nowMs,
1902
+ storage: args.attachmentStorage
1903
+ }) : { deleted: 0 };
1887
1904
  logInfo("retention.purge.completed", {
1888
1905
  "app.retention.attachments": attachmentResult.deleted,
1906
+ "app.retention.attachment_uploads": uploadResult.deleted,
1889
1907
  "app.retention.scanned": roots.length,
1890
1908
  "app.retention.purged": purged,
1891
1909
  "app.retention.failed": failed,
@@ -2131,6 +2149,8 @@ const slackEventSchema = z.looseObject({
2131
2149
  const slackEventEnvelopeSchema = z.object({
2132
2150
  event_id: z.unknown().optional(),
2133
2151
  is_ext_shared_channel: z.unknown().optional(),
2152
+ context_enterprise_id: z.unknown().optional(),
2153
+ context_team_id: z.unknown().optional(),
2134
2154
  enterprise_id: z.string().optional(),
2135
2155
  event: slackEventSchema.optional(),
2136
2156
  is_enterprise_install: z.boolean().optional(),
@@ -2138,6 +2158,22 @@ const slackEventEnvelopeSchema = z.object({
2138
2158
  type: z.string(),
2139
2159
  challenge: z.string().optional()
2140
2160
  });
2161
+ const workspaceChannelSchema = z.object({
2162
+ context_enterprise_id: z.string().nullish(),
2163
+ context_team_id: slackTeamIdSchema,
2164
+ enterprise_id: z.string().optional(),
2165
+ is_ext_shared_channel: z.literal(false),
2166
+ team_id: slackTeamIdSchema
2167
+ });
2168
+ /** Read the channel scope of an event from its envelope. */
2169
+ function slackChannelScope(body) {
2170
+ if (body.is_ext_shared_channel === true) return "external";
2171
+ const parsed = workspaceChannelSchema.safeParse(body);
2172
+ if (!parsed.success || parsed.data.context_team_id !== parsed.data.team_id) return "unknown";
2173
+ const enterpriseId = parsed.data.context_enterprise_id;
2174
+ if (enterpriseId == null) return "workspace";
2175
+ return enterpriseId === parsed.data.enterprise_id ? "enterprise" : "unknown";
2176
+ }
2141
2177
  const slackViewStateValueSchema = z.object({
2142
2178
  selected_option: z.object({ value: z.string().optional() }).nullish(),
2143
2179
  selected_options: z.array(z.object({ value: z.string().optional() })).nullish(),
@@ -2169,248 +2205,6 @@ const slackInteractivePayloadSchema = z.object({
2169
2205
  state: z.object({ values: z.record(z.string(), z.record(z.string(), slackViewStateValueSchema)) }).optional()
2170
2206
  }).nullish()
2171
2207
  });
2172
- // src/chat/ingress/workspace-membership.ts
2173
- const MEMBER_TTL_MS = 3e5;
2174
- const NON_MEMBER_TTL_MS = 3e4;
2175
- const authorTeamSchema = z.object({
2176
- user_team: z.string().optional(),
2177
- source_team: z.string().optional(),
2178
- user: z.unknown().optional()
2179
- });
2180
- /** Accept only verified workspace authors, reusing recent membership lookups. */
2181
- async function isSlackWorkspaceMember(raw, state) {
2182
- const workspaceTeamId = getWorkspaceTeamId();
2183
- if (!workspaceTeamId) return false;
2184
- const parsed = authorTeamSchema.safeParse(raw);
2185
- if (!parsed.success) return false;
2186
- const event = parsed.data;
2187
- const userId = parseSlackUserId(event.user);
2188
- if (!userId) return false;
2189
- const cache = createCache(state, "core");
2190
- const key = `slack:membership:${workspaceTeamId}:${userId}`;
2191
- const authorTeam = parseSlackTeamId(event.user_team);
2192
- if (authorTeam === workspaceTeamId) return true;
2193
- if (event.user_team !== void 0 && !authorTeam && !/^E[A-Z0-9]+$/.test(event.user_team)) return false;
2194
- if (authorTeam !== void 0) return await cache.getOrLoad(key, async () => ({
2195
- value: false,
2196
- ttlMs: NON_MEMBER_TTL_MS
2197
- }), { refresh: true });
2198
- return await cache.getOrLoad(key, async () => {
2199
- const user = await lookupSlackUserProfile(userId);
2200
- const authorTeam = parseSlackTeamId(user.team_id);
2201
- if (user.id !== userId || !authorTeam) return { value: false };
2202
- const member = authorTeam === workspaceTeamId && !user.is_deleted;
2203
- return {
2204
- value: member,
2205
- ttlMs: member ? MEMBER_TTL_MS : NON_MEMBER_TTL_MS
2206
- };
2207
- });
2208
- }
2209
- // src/chat/ingress/slack-acting-user.ts
2210
- /**
2211
- * Resolve the Junior User of the person who clicked a Slack control. The
2212
- * click acts as that person, so it needs the same workspace and allowed
2213
- * domain checks as a Slack mention. A person Junior does not know yet gets
2214
- * a note to sign in.
2215
- */
2216
- async function resolveSlackActingUser(args) {
2217
- const { payload } = args;
2218
- const slackUserId = parseActorUserId(payload.user?.id);
2219
- const teamId = parseSlackTeamId(payload.team?.id ?? payload.user?.team_id);
2220
- if (!slackUserId || !teamId) throw new Error("Slack interaction payload is missing a user or team");
2221
- if (!await isSlackWorkspaceMember({
2222
- user: slackUserId,
2223
- user_team: payload.user?.team_id
2224
- }, args.state) || !await args.isAuthorAllowed(slackUserId)) return;
2225
- const user = (await readActorIdentity(createSlackActor(teamId, slackUserId, void 0)))?.user;
2226
- if (!user) {
2227
- await args.tell(slackUserId, "Junior does not know your account yet. Sign in to the Junior dashboard, then try again.");
2228
- return;
2229
- }
2230
- return {
2231
- slackUserId,
2232
- teamId,
2233
- user
2234
- };
2235
- }
2236
- // src/chat/ingress/slack-conversation-unfurl.ts
2237
- /** Action id of the "Continue here" button on a dashboard link preview. */
2238
- const SLACK_CONTINUE_HERE_ACTION_ID = "junior_continue_here";
2239
- const MAX_LINKS = 5;
2240
- const MAX_SUMMARY_CHARS = 300;
2241
- const linkSharedEventSchema = z.object({
2242
- channel: z.string(),
2243
- links: z.array(z.object({ url: z.string() })),
2244
- message_ts: z.string(),
2245
- source: z.string().optional(),
2246
- thread_ts: slackMessageTsSchema.optional(),
2247
- unfurl_id: z.string().min(1).optional()
2248
- });
2249
- const continueHereValueSchema = z.object({
2250
- conversationId: z.string().min(1),
2251
- messageTs: slackMessageTsSchema,
2252
- threadTs: slackMessageTsSchema,
2253
- url: z.string().min(1)
2254
- });
2255
- function parseContinueHereValue(raw) {
2256
- try {
2257
- return continueHereValueSchema.parse(JSON.parse(raw ?? ""));
2258
- } catch {
2259
- return;
2260
- }
2261
- }
2262
- async function previewBlocks(args) {
2263
- const title = args.conversation.title ?? "Junior conversation";
2264
- const summary = (await readLatestConversationBrief(getDb(), args.conversation.conversationId))?.content.summary.trim();
2265
- const shortSummary = summary && summary.length > MAX_SUMMARY_CHARS ? `${summary.slice(0, 299)}…` : summary;
2266
- return [{
2267
- type: "section",
2268
- text: {
2269
- type: "mrkdwn",
2270
- text: [`*${formatSlackLink(args.url, title)}*`, ...shortSummary ? [escapeSlackMrkdwnText(shortSummary)] : []].join("\n")
2271
- }
2272
- }, ...args.footer ? [args.footer] : []];
2273
- }
2274
- function continueHereButton(value) {
2275
- return {
2276
- type: "actions",
2277
- elements: [{
2278
- type: "button",
2279
- action_id: SLACK_CONTINUE_HERE_ACTION_ID,
2280
- text: {
2281
- type: "plain_text",
2282
- text: "Continue here"
2283
- },
2284
- value: JSON.stringify(value)
2285
- }]
2286
- };
2287
- }
2288
- async function readPublicConversation(conversationId) {
2289
- const conversation = await getConversationStore().get({ conversationId });
2290
- if (!conversation || conversation.parentConversationId) return void 0;
2291
- return (await readConversationAccessFromSql(getDb(), [conversationId])).get(conversationId)?.visibility === "public" ? conversation : void 0;
2292
- }
2293
- /** Whether a thread in this channel can take a moved Conversation. */
2294
- async function canReceiveConversation(teamId, channelId, threadTs) {
2295
- return !await getConversationIdByProviderConversation(getSqlExecutor(), {
2296
- provider: "slack",
2297
- providerDestinationId: channelId,
2298
- providerTenantId: teamId,
2299
- providerConversationId: threadTs
2300
- }) && await isPublicChannel(teamId, channelId);
2301
- }
2302
- async function isPublicChannel(teamId, channelId) {
2303
- const access = await checkSlackChannelReadAccess({
2304
- currentChannelIds: [],
2305
- targetChannelId: channelId,
2306
- teamId
2307
- });
2308
- return access.allowed && access.isPublic === true;
2309
- }
2310
- /**
2311
- * Preview dashboard conversation links that a workspace member posted.
2312
- *
2313
- * Only public root Conversations get a preview, and only in channels that are
2314
- * not shared with other organizations. A public dashboard Conversation that
2315
- * can still move gets a "Continue here" button when the channel is public.
2316
- */
2317
- async function unfurlDashboardConversationLinks(args) {
2318
- const parsed = linkSharedEventSchema.safeParse(args.event);
2319
- const teamId = parseSlackTeamId(args.teamId);
2320
- if (!parsed.success || !teamId || parsed.data.source === "composer" || args.isExtSharedChannel || !await isSlackWorkspaceMember(args.event, args.state)) return;
2321
- const event = parsed.data;
2322
- const channelId = parseSlackChannelId(event.channel);
2323
- const messageTs = slackMessageTsSchema.safeParse(event.message_ts);
2324
- if (!channelId || !messageTs.success) return;
2325
- const threadTs = event.thread_ts ?? messageTs.data;
2326
- const unfurls = {};
2327
- let canReceive;
2328
- const urls = [...new Set(event.links.map((link) => link.url))];
2329
- for (const url of urls.slice(0, MAX_LINKS)) {
2330
- const conversationId = parseDashboardConversationLink(url);
2331
- const conversation = conversationId ? await readPublicConversation(conversationId) : void 0;
2332
- if (!conversation) continue;
2333
- unfurls[url] = { blocks: await previewBlocks({
2334
- conversation,
2335
- url,
2336
- ...isMovableToSlack(conversation) && await (canReceive ??= canReceiveConversation(teamId, channelId, threadTs)) ? { footer: continueHereButton({
2337
- conversationId: conversation.conversationId,
2338
- messageTs: messageTs.data,
2339
- threadTs,
2340
- url
2341
- }) } : void 0
2342
- }) };
2343
- }
2344
- if (Object.keys(unfurls).length === 0) return;
2345
- await unfurlSlackLinks({
2346
- channelId,
2347
- messageTs: messageTs.data,
2348
- ...event.unfurl_id ? { unfurlId: event.unfurl_id } : void 0,
2349
- unfurls
2350
- });
2351
- }
2352
- /**
2353
- * Move a dashboard Conversation into the thread of the message that shared
2354
- * its link, as the participant who clicked "Continue here".
2355
- */
2356
- async function handleSlackContinueHereClick(args) {
2357
- const target = parseContinueHereValue(args.value);
2358
- const channelId = parseSlackChannelId(args.payload.channel?.id);
2359
- if (!target || !channelId) throw new Error("Slack Continue here payload is incomplete");
2360
- const tellPerson = (userId, text) => postSlackEphemeralMessage({
2361
- channelId,
2362
- text,
2363
- ...target.threadTs !== target.messageTs ? { threadTs: target.threadTs } : void 0,
2364
- userId
2365
- });
2366
- const actor = await resolveSlackActingUser({
2367
- isAuthorAllowed: args.isAuthorAllowed,
2368
- payload: args.payload,
2369
- state: args.state,
2370
- tell: tellPerson
2371
- });
2372
- if (!actor) return;
2373
- const { teamId, user } = actor;
2374
- const tell = (text) => tellPerson(actor.slackUserId, text);
2375
- const conversation = await getConversationStore().get({ conversationId: target.conversationId });
2376
- const access = conversation ? (await readConversationAccessFromSql(getDb(), [target.conversationId], user)).get(target.conversationId) : void 0;
2377
- if (!conversation || !access?.isParticipant) {
2378
- await tell("Only people in this conversation can move it here.");
2379
- return;
2380
- }
2381
- if (!canContinueInSlack(conversation, access)) {
2382
- await tell(conversation.location ? await alreadyContinuesInSlackMessage(conversation) : "This conversation can no longer move to Slack.");
2383
- return;
2384
- }
2385
- const result = await continueConversationInSlack({
2386
- actorName: user.displayName ?? user.email,
2387
- channel: {
2388
- channelId,
2389
- teamId
2390
- },
2391
- conversation,
2392
- threadTs: target.threadTs
2393
- });
2394
- if (result.status === "refused") {
2395
- await tell(result.message);
2396
- return;
2397
- }
2398
- await unfurlSlackLinks({
2399
- channelId,
2400
- messageTs: target.messageTs,
2401
- unfurls: { [target.url]: { blocks: await previewBlocks({
2402
- conversation,
2403
- footer: {
2404
- type: "context",
2405
- elements: [{
2406
- type: "mrkdwn",
2407
- text: result.locationUrl ? `Continues in ${formatSlackLink(result.locationUrl, "this thread")}.` : "Continues in this thread."
2408
- }]
2409
- },
2410
- url: target.url
2411
- }) } }
2412
- });
2413
- }
2414
2208
  // src/chat/ingress/slack-interaction-input.ts
2415
2209
  /**
2416
2210
  * Build the Slack input that a click or form makes in a thread, as a
@@ -2975,6 +2769,13 @@ function textMentionsBot(text, botUserId) {
2975
2769
  const id = escapeRegExp(botUserId);
2976
2770
  return new RegExp(`<@${id}(?:\\|[^>]+)?>`).test(outside);
2977
2771
  }
2772
+ /**
2773
+ * Return true when a Slack message mentions the bot in its text or in a
2774
+ * section block, outside code.
2775
+ */
2776
+ function eventMentionsBot(event, botUserId) {
2777
+ return Boolean(botUserId && (textMentionsBot(event.text ?? "", botUserId) || event.blocks?.some((block) => block.type === "section" && typeof block.text === "object" && block.text.type === "mrkdwn" && textMentionsBot(block.text.text, botUserId))));
2778
+ }
2978
2779
  // src/chat/ingress/slack-allowed-domain.ts
2979
2780
  const ALLOWED_TTL_MS = 3e5;
2980
2781
  const NOT_ALLOWED_TTL_MS = 3e4;
@@ -3023,6 +2824,8 @@ function slackMessageAttributes(body) {
3023
2824
  "app.slack.user_team": field(event?.user_team, teamId),
3024
2825
  "app.slack.source_team": field(event?.source_team, teamId),
3025
2826
  "app.slack.event_team": field(event?.team, teamId),
2827
+ "app.slack.context_team_id": field(body.context_team_id, /^T[A-Z0-9]+$/),
2828
+ "app.slack.context_enterprise_id": body.context_enterprise_id === null ? "none" : field(body.context_enterprise_id, /^E[A-Z0-9]+$/),
3026
2829
  "app.slack.is_ext_shared_channel": typeof body.is_ext_shared_channel === "boolean" ? body.is_ext_shared_channel : body.is_ext_shared_channel === void 0 ? "missing" : "invalid"
3027
2830
  };
3028
2831
  }
@@ -3301,29 +3104,20 @@ async function routeParsedMessage(args) {
3301
3104
  const normalized = normalizeMessageThreadId(args.message);
3302
3105
  const message = normalized.message;
3303
3106
  const canonicalThreadId = normalized.threadId;
3304
- const botUserId = args.adapter.botUserId;
3305
- const isMention = Boolean(botUserId && (textMentionsBot(args.event.text ?? "", botUserId) || args.event.blocks?.some((block) => block.type === "section" && typeof block.text === "object" && block.text.type === "mrkdwn" && textMentionsBot(block.text.text, botUserId))));
3107
+ const isMention = eventMentionsBot(args.event, args.adapter.botUserId);
3306
3108
  if (isMention) message.isMention = true;
3307
3109
  const isDirectMessage = isDmEvent(args.event);
3308
3110
  const isSubscribed = !isDirectMessage && !isMention && await args.state.isSubscribed(canonicalThreadId);
3309
3111
  const route = isDirectMessage || isMention ? "mention" : isSubscribed ? "subscribed" : void 0;
3310
3112
  if (!route) {
3311
- const channelMessage = args.event.type === "message" && args.event.channel && args.event.ts ? slackChannelMessageEvent({
3312
- botId: args.event.bot_id,
3313
- channelId: args.event.channel,
3314
- subtype: args.event.subtype,
3315
- text: args.event.text,
3316
- threadTs: args.event.thread_ts,
3317
- ts: args.event.ts,
3318
- userId: message.author.userId
3319
- }) : void 0;
3320
- const teamId = args.installation.teamId;
3321
- if (channelMessage && teamId) await ingestEventAutomations({
3322
- ...channelMessage,
3323
- namespace: SLACK_EVENT_NAMESPACE
3324
- }, {
3113
+ await ingestChannelMessage({
3114
+ author: {
3115
+ kind: "user",
3116
+ userId: message.author.userId
3117
+ },
3118
+ event: args.event,
3325
3119
  queue: args.queue,
3326
- teamId
3120
+ teamId: args.installation.teamId
3327
3121
  });
3328
3122
  return;
3329
3123
  }
@@ -3423,6 +3217,31 @@ async function routeParsedMessage(args) {
3423
3217
  }
3424
3218
  args.runAfterUnlock(closeAnswered);
3425
3219
  }
3220
+ /**
3221
+ * Run the channel-message automations of the channel for a new message or
3222
+ * thread reply.
3223
+ */
3224
+ async function ingestChannelMessage(args) {
3225
+ const { event } = args;
3226
+ if (event.type !== "message" || !event.channel || !event.ts || !args.teamId) return;
3227
+ const channelMessage = slackChannelMessageEvent({
3228
+ author: args.author,
3229
+ botId: event.bot_id,
3230
+ channelId: event.channel,
3231
+ subtype: event.subtype,
3232
+ text: event.text,
3233
+ threadTs: event.thread_ts,
3234
+ ts: event.ts
3235
+ });
3236
+ if (!channelMessage) return;
3237
+ await ingestEventAutomations({
3238
+ ...channelMessage,
3239
+ namespace: SLACK_EVENT_NAMESPACE
3240
+ }, {
3241
+ queue: args.queue,
3242
+ teamId: args.teamId
3243
+ });
3244
+ }
3426
3245
  async function handleSlackEvent(args) {
3427
3246
  const event = args.body.event;
3428
3247
  if (!event) return;
@@ -3430,6 +3249,7 @@ async function handleSlackEvent(args) {
3430
3249
  const state = args.services.state ?? getStateAdapter();
3431
3250
  await state.connect();
3432
3251
  const installation = installationFromEnvelope(args.body);
3252
+ const channelScope = slackChannelScope(args.body);
3433
3253
  const receivedAtMs = Date.now();
3434
3254
  async function publishAppHomeViewBestEffort(userId) {
3435
3255
  await withLogContext({
@@ -3475,7 +3295,7 @@ async function handleSlackEvent(args) {
3475
3295
  if (event.type === "link_shared") {
3476
3296
  await unfurlDashboardConversationLinks({
3477
3297
  event,
3478
- isExtSharedChannel: args.body.is_ext_shared_channel === true,
3298
+ channelScope,
3479
3299
  state,
3480
3300
  teamId: installation.teamId
3481
3301
  });
@@ -3521,6 +3341,21 @@ async function handleSlackEvent(args) {
3521
3341
  return;
3522
3342
  }
3523
3343
  if ((event.type === "message" || event.type === "app_mention") && !shouldIgnoreMessageSubtype(event) && event.channel && event.ts) {
3344
+ if (event.user === void 0 && event.bot_id !== void 0) {
3345
+ const botId = await slackWorkspaceBotId(event, channelScope, state);
3346
+ setSpanAttributes({ "app.slack.membership": botId ? "verified" : "unverified" });
3347
+ if (!botId || eventMentionsBot(event, adapter.botUserId)) return;
3348
+ await ingestChannelMessage({
3349
+ author: {
3350
+ kind: "bot",
3351
+ botId
3352
+ },
3353
+ event,
3354
+ queue: args.services.queue,
3355
+ teamId: installation.teamId
3356
+ });
3357
+ return;
3358
+ }
3524
3359
  const member = await isSlackWorkspaceMember(event, state);
3525
3360
  setSpanAttributes({ "app.slack.membership": member ? "verified" : "unverified" });
3526
3361
  if (!member) return;
@@ -3737,8 +3572,10 @@ async function processConversationQueueMessage(message, options, metadata) {
3737
3572
  return await withSpan("conversation.work.process", "queue.process", { conversationId: parsed.conversationId }, async (setSpanAttributes) => {
3738
3573
  try {
3739
3574
  const result = await processConversationWork(parsed, {
3575
+ beforeWorkStops: options.beforeWorkStops,
3740
3576
  checkInIntervalMs: options.checkInIntervalMs,
3741
3577
  conversationStore: options.conversationStore,
3578
+ getSlackAdapter: options.getSlackAdapter,
3742
3579
  nowMs: options.nowMs,
3743
3580
  queue: options.queue ?? getVercelConversationWorkQueue(),
3744
3581
  run: options.run,
@@ -4055,7 +3892,7 @@ const LOOPBACK_HOSTNAMES = [
4055
3892
  function resolvePublicOrigin(request, configured) {
4056
3893
  const value = configured?.trim();
4057
3894
  let origin;
4058
- if (value) origin = /^https?:\/\//.test(value) ? value : `https://${value}`;
3895
+ if (value) origin = value.startsWith("https://") || value.startsWith("http://") ? value : `https://${value}`;
4059
3896
  else {
4060
3897
  const requestURL = new URL(request.url);
4061
3898
  if (!LOOPBACK_HOSTNAMES.includes(requestURL.hostname)) return void 0;
@@ -5651,184 +5488,6 @@ ${page.bodyHtml}
5651
5488
  }
5652
5489
  });
5653
5490
  }
5654
- // src/net/public-address.ts
5655
- /**
5656
- * Own the public-address rule for fetches of URLs that any person can submit.
5657
- *
5658
- * Such a fetch must not reach loopback, private, link-local, cloud metadata,
5659
- * or other special addresses. The lookup checks every resolved address at
5660
- * connect time, so a second DNS answer cannot move the request to a blocked
5661
- * address.
5662
- */
5663
- /** Special-use ranges from RFC 6890 and the IANA special-purpose registries. */
5664
- const BLOCKED_SUBNETS = [
5665
- [
5666
- "0.0.0.0",
5667
- 8,
5668
- "ipv4"
5669
- ],
5670
- [
5671
- "10.0.0.0",
5672
- 8,
5673
- "ipv4"
5674
- ],
5675
- [
5676
- "100.64.0.0",
5677
- 10,
5678
- "ipv4"
5679
- ],
5680
- [
5681
- "127.0.0.0",
5682
- 8,
5683
- "ipv4"
5684
- ],
5685
- [
5686
- "169.254.0.0",
5687
- 16,
5688
- "ipv4"
5689
- ],
5690
- [
5691
- "172.16.0.0",
5692
- 12,
5693
- "ipv4"
5694
- ],
5695
- [
5696
- "192.0.0.0",
5697
- 24,
5698
- "ipv4"
5699
- ],
5700
- [
5701
- "192.0.2.0",
5702
- 24,
5703
- "ipv4"
5704
- ],
5705
- [
5706
- "192.168.0.0",
5707
- 16,
5708
- "ipv4"
5709
- ],
5710
- [
5711
- "198.18.0.0",
5712
- 15,
5713
- "ipv4"
5714
- ],
5715
- [
5716
- "198.51.100.0",
5717
- 24,
5718
- "ipv4"
5719
- ],
5720
- [
5721
- "203.0.113.0",
5722
- 24,
5723
- "ipv4"
5724
- ],
5725
- [
5726
- "224.0.0.0",
5727
- 4,
5728
- "ipv4"
5729
- ],
5730
- [
5731
- "240.0.0.0",
5732
- 4,
5733
- "ipv4"
5734
- ],
5735
- [
5736
- "::",
5737
- 96,
5738
- "ipv6"
5739
- ],
5740
- [
5741
- "64:ff9b::",
5742
- 96,
5743
- "ipv6"
5744
- ],
5745
- [
5746
- "64:ff9b:1::",
5747
- 48,
5748
- "ipv6"
5749
- ],
5750
- [
5751
- "100::",
5752
- 64,
5753
- "ipv6"
5754
- ],
5755
- [
5756
- "2001::",
5757
- 32,
5758
- "ipv6"
5759
- ],
5760
- [
5761
- "2001:db8::",
5762
- 32,
5763
- "ipv6"
5764
- ],
5765
- [
5766
- "2002::",
5767
- 16,
5768
- "ipv6"
5769
- ],
5770
- [
5771
- "fc00::",
5772
- 7,
5773
- "ipv6"
5774
- ],
5775
- [
5776
- "fe80::",
5777
- 10,
5778
- "ipv6"
5779
- ],
5780
- [
5781
- "fec0::",
5782
- 10,
5783
- "ipv6"
5784
- ],
5785
- [
5786
- "ff00::",
5787
- 8,
5788
- "ipv6"
5789
- ]
5790
- ];
5791
- function blockedAddressList() {
5792
- const list = new net.BlockList();
5793
- for (const [network, prefix, family] of BLOCKED_SUBNETS) list.addSubnet(network, prefix, family);
5794
- return list;
5795
- }
5796
- const blockedAddresses = blockedAddressList();
5797
- /** Return true only for an IP address outside every blocked range. */
5798
- function isPublicAddress(address) {
5799
- const family = net.isIP(address);
5800
- if (family === 0) return false;
5801
- return !blockedAddresses.check(address, family === 4 ? "ipv4" : "ipv6");
5802
- }
5803
- function blockedAddressError(hostname) {
5804
- return Object.assign(/* @__PURE__ */ new Error(`${hostname} does not resolve to a public address`), { code: "EADDRNOTPUBLIC" });
5805
- }
5806
- /**
5807
- * Resolve a hostname for an outbound socket. Fail when any answer is not a
5808
- * public address.
5809
- */
5810
- const publicAddressLookup = (hostname, options, callback) => {
5811
- dns.lookup(hostname, {
5812
- all: true,
5813
- verbatim: true
5814
- }, (error, addresses) => {
5815
- if (error) {
5816
- callback(error, "", 0);
5817
- return;
5818
- }
5819
- const allowed = addresses.filter((entry) => !options.family || entry.family === options.family || `IPv${entry.family}` === options.family);
5820
- const first = allowed[0];
5821
- if (!first || !addresses.every((entry) => isPublicAddress(entry.address))) {
5822
- callback(blockedAddressError(hostname), "", 0);
5823
- return;
5824
- }
5825
- if (options.all) {
5826
- callback(null, allowed);
5827
- return;
5828
- }
5829
- callback(null, first.address, first.family);
5830
- });
5831
- };
5832
5491
  // src/api/mcp/oauth/state.ts
5833
5492
  /** Return the SHA-256 hex digest of a secret or unbounded value. */
5834
5493
  function sha256Hex(value) {
@@ -7790,7 +7449,7 @@ function trimSlashes(value, leading) {
7790
7449
  return value.slice(start, end);
7791
7450
  }
7792
7451
  function withHttps(host) {
7793
- return /^https?:\/\//.test(host) ? host : `https://${host}`;
7452
+ return host.startsWith("https://") || host.startsWith("http://") ? host : `https://${host}`;
7794
7453
  }
7795
7454
  /** Resolve sign-in settings from dashboard options and environment. */
7796
7455
  function resolveSignInAuthConfig(agentName, allowedDomains, options = {}) {
@@ -8030,6 +7689,8 @@ function dashboardHostRoutePaths(dashboard, authenticatedRoutes = []) {
8030
7689
  "/api/connections/*",
8031
7690
  "/api/notifications",
8032
7691
  "/api/notifications/*",
7692
+ "/api/images/*",
7693
+ "/api/objects",
8033
7694
  "/api/stats",
8034
7695
  "/api/reply-times",
8035
7696
  "/api/versions",
@@ -8124,7 +7785,7 @@ function resolvePublicBaseURL(dashboard) {
8124
7785
  if (configured) return configured;
8125
7786
  const vercelURL = process.env.VERCEL_PROJECT_PRODUCTION_URL?.trim() || process.env.VERCEL_URL?.trim();
8126
7787
  if (!vercelURL) return void 0;
8127
- return /^https?:\/\//.test(vercelURL) ? vercelURL : `https://${vercelURL}`;
7788
+ return vercelURL.startsWith("https://") || vercelURL.startsWith("http://") ? vercelURL : `https://${vercelURL}`;
8128
7789
  }
8129
7790
  /** Build a `WaitUntilFn`, preferring Vercel's lifetime extension when available. */
8130
7791
  async function defaultWaitUntil() {
@@ -8261,6 +7922,7 @@ async function createApp(options) {
8261
7922
  warnUnregisteredConfigDefaults(options?.configDefaults);
8262
7923
  resetRuntimeConfig(virtualConfig?.functionMaxDurationSeconds);
8263
7924
  setBotModelConfig(options ?? {});
7925
+ setBotName(options?.botName);
8264
7926
  setRuntimeLimits(options?.limits);
8265
7927
  setSlackReactionConfig(options?.slack ?? {});
8266
7928
  assertNoLegacyAllowedDomains(Object.keys(dashboard ?? {}));
@@ -8276,7 +7938,10 @@ async function createApp(options) {
8276
7938
  events,
8277
7939
  showReviewItem: createSlackReviewItemShow(getProductionSlackAdapter)
8278
7940
  });
8279
- if (dashboard && !dashboard.disabled) pluginApiRoutes = getPluginApiRoutes();
7941
+ if (dashboard && !dashboard.disabled) {
7942
+ pluginApiRoutes = getPluginApiRoutes();
7943
+ readObjectLinkTypes(plugins);
7944
+ }
8280
7945
  } catch (error) {
8281
7946
  restoreRuntimeConfig$1();
8282
7947
  throw error;