@sentry/junior 0.317.0 → 0.319.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.
- package/dist/adapter-8_S6Birm.js +1833 -0
- package/dist/{admin-CAugg87B.js → admin-EsbUON1j.js} +1 -1
- package/dist/{agent-runner-AjrEV6Qe.js → agent-CtzMl32d.js} +19953 -6727
- package/dist/{agent-status-BA5x3Xtp.js → agent-status-Bq_AIpyp.js} +105 -1
- package/dist/{agent-update-delivery-B_YIZcgf.js → agent-update-delivery-pAvsbuGL.js} +4 -5
- package/dist/api/schema.d.ts +85 -51
- package/dist/api/schema.js +4 -4
- package/dist/api.js +81 -94
- package/dist/{app-MoNAsVV5.d.ts → app-tACXxJPI.d.ts} +8 -13
- package/dist/app.d.ts +2 -2
- package/dist/app.js +246 -153
- package/dist/{change-record-BzJgLsv7.d.ts → change-record-K-KsqNhT.d.ts} +9 -5
- package/dist/{channel-access-j-YAVYK4.js → channel-access-DET5hzZM.js} +1 -1
- package/dist/{chat-core-engine-aH85nEHv.js → chat-core-engine-DpM3tMVi.js} +7 -7
- package/dist/cli/chat.d.ts +1 -1
- package/dist/cli/chat.js +38 -30
- package/dist/cli/check.js +5 -5
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.d.ts +1 -1
- package/dist/cli/plugins.js +8 -8
- package/dist/cli/snapshot-create.js +5 -6
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -4
- package/dist/{continue-in-slack-D-FZ8Fin.js → continue-in-slack-CFzDyxkH.js} +3 -2
- package/dist/{conversation-feed--9S0_PXL.js → conversation-feed-DEUdD7mb.js} +2 -106
- package/dist/{conversation-privacy-B1uXn5sf.js → conversation-privacy-C2vYK55O.js} +1 -1
- package/dist/{create-DoDIYgtZ.js → create-Ta3SEIB5.js} +124 -16
- package/dist/{credential-sync-BJOqGnjV.js → credential-sync-DyRqDmY4.js} +17 -20
- package/dist/{db-BFmyYZtJ.js → db-BCaNWl9p.js} +6536 -1920
- package/dist/{deployment-DXq9ZLU4.js → deployment-CfOew1Tm.js} +3 -3
- package/dist/{engine-context-CgQ7mlHt.js → engine-context-CiExoy1B.js} +181 -155
- package/dist/{html-B3VKTGbJ.js → html-Bb2Si1bR.js} +6 -8
- package/dist/instrumentation.js +7 -23
- package/dist/list-wwDcROh9.js +5007 -0
- package/dist/{logging--smS7XRK.js → logging-BRPTXAdf.js} +10 -81
- package/dist/{mailbox-turn-uSXhUFc9.js → markers-9QoqW5ov.js} +1875 -1458
- package/dist/nitro.d.ts +2 -2
- package/dist/nitro.js +7 -8
- package/dist/{oauth-callback-server-CE4soEIY.js → oauth-callback-server-vhL9b-PZ.js} +2 -2
- package/dist/{oauth-relay-C36gX1gH.js → oauth-relay-CH2v7WiB.js} +1 -1
- package/dist/{plugins-fBrz8PCV.d.ts → plugins-DhGXZjlu.d.ts} +1 -0
- package/dist/{profile-BQ-iBDsZ.js → profile-D9LdwmZi.js} +17 -19
- package/dist/{prompt-Dv7gkpD6.js → prompt-3TqxEOtc.js} +10 -10
- package/dist/{reports-WKHfGTsU.js → reports-K-tbtEyx.js} +2 -2
- package/dist/{resolve-tony4ibz.js → resolve-BBV2qf8A.js} +5 -5
- package/dist/{result-Bta_dlWa.js → result-5IdGJP4M.js} +24 -13
- package/dist/{runner-BstDRbD9.js → runner-BK_joPlM.js} +9 -18
- package/dist/{sandbox-egress-signals-oSJMJOnn.js → sandbox-egress-signals-DXgWXXmm.js} +1 -1
- package/dist/{schema-DfqrHACA.js → schema-zWGG6VC1.js} +13 -7
- package/dist/{service-account-CTV_jaNu.js → service-account-CateFyhw.js} +4 -5
- package/dist/{skills-BCEU41zM.js → skills-Ccjw8h2P.js} +10 -9
- package/dist/{slack-conversation-unfurl-DxVmhbGP.js → slack-conversation-unfurl-ZC_TSpc4.js} +7 -7
- package/dist/storage-C9U7R5rM.js +273 -0
- package/dist/{system-prompt-table-CiXy0eNR.js → system-prompt-table-YBTHIFlP.js} +26 -84
- package/dist/topic-B2EWKKBT.js +6 -0
- package/dist/{package-discovery-DD9vencX.js → topics-DxuKurCX.js} +21 -1
- package/dist/{types-C4iC-IMC.js → types-BNHkJrOP.js} +79 -59
- package/dist/{users-ByG5RCEJ.js → users-CCRAqYb_.js} +1 -1
- package/dist/{validation-8gjfR91V.js → validation-BCUpJa8K.js} +4 -4
- package/dist/{version-BeZhWWBE.js → version-BNm0JYj3.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{worker-BqMQQNRk.js → worker-BhgpZ7_b.js} +5 -5
- package/migrations/20261127002500_turn_discarded_usage/migration.sql +2 -0
- package/migrations/20261127002500_turn_discarded_usage/snapshot.json +73 -0
- package/migrations/20261127052408_space_name_nullable/migration.sql +5 -0
- package/migrations/20261127052408_space_name_nullable/snapshot.json +29 -0
- package/migrations/20261127060000_annotation_object_id_index/migration.sql +1 -0
- package/migrations/20261127060000_annotation_object_id_index/snapshot.json +69 -0
- package/migrations/20261127060001_annotation_subjects/migration.sql +78 -0
- package/migrations/20261127060001_annotation_subjects/snapshot.json +104 -0
- package/migrations/20261127060002_annotation_subject_index/migration.sql +1 -0
- package/migrations/20261127060002_annotation_subject_index/snapshot.json +70 -0
- package/migrations/20261127060003_annotation_title_url/migration.sql +84 -0
- package/migrations/20261127060003_annotation_title_url/snapshot.json +73 -0
- package/package.json +9 -7
- package/dist/catalog-runtime-DfSpJZdY.js +0 -6
- package/dist/child-message-DHjQLEd1.js +0 -19
- package/dist/config-CHQ8X251.js +0 -2422
- package/dist/conversation-turn-BUE_7xaN.js +0 -1157
- package/dist/job-runner-A1lCkybD.js +0 -1506
- package/dist/lineage-Bktb0UcV.js +0 -36
- package/dist/list-Bxvg5wXf.js +0 -12623
- package/dist/message-BNenhsmB.js +0 -154
- package/dist/model-input-BReSnwHp.js +0 -82
- package/dist/parent-result-Ck1rFYRQ.js +0 -310
- package/dist/registry-iXMT5Jmh.js +0 -3279
- package/dist/run-conversation-DL6ru7iW.js +0 -336
- package/dist/sender-actors-CPglLd5R.js +0 -83
- package/dist/spawn-frczVPIr.js +0 -48
- package/dist/task-runner-C9Yc2_ae.js +0 -1526
- package/dist/thread-context-CqZDKErp.js +0 -166
- package/dist/topic-CRYYBYp-.js +0 -7
- package/dist/topics-SRN7IVX-.js +0 -24
- package/dist/turn-membership-CENFf3kI.js +0 -856
- package/dist/turn-wake-BhloiI2h.js +0 -151
package/dist/app.js
CHANGED
|
@@ -1,44 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { A as createUserTokenStore, C as clearSandboxEgressSignals, D as parseSandboxEgressCredentialToken, P as normalizeSandboxEgressTracePropagationDomains, T as consumeSandboxEgressPermissionDeniedSignal, c as isVercelSandboxEgressRequest, l as proxyVercelSandboxEgressRequest, w as consumeSandboxEgressAuthRequiredSignal } from "./profile-
|
|
6
|
-
import {
|
|
7
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-DfSpJZdY.js";
|
|
8
|
-
import { $ as reviewItemChange, At as createProductionSlackWebhookServices, B as mcpIdempotencyKeySchema, Bt as startProcessingReaction, Dt as isPublicAddress, F as mcpAuthorizationSchema$1, Ft as normalizeIncomingSlackThreadId, G as readMcpPendingWork, H as mcpMessageTextSchema, Ht as parseContent, I as mcpConversation, It as withNormalizedThreadId, K as readMcpPendingWorkAfterSend, Kt as readConversationRecordFromSql, L as mcpConversationIdSchema, Lt as recordSkippedConversationMessage, Mt as buildSlackInboundMessage, Nt as clearSlackPendingReactions, Ot as publicAddressLookup, P as mcpAcceptedMessageSchema, Pt as slackInboundMessageId, Q as readInboxItemForUser, R as mcpConversationSchema, Rt as createSlackWebApiStatusSender, St as readObjectLinkTypes, U as mcpMessages, Ut as SubscribedReplyReason, V as mcpMessageSchema, Vt as stripLeadingBotMention, W as mcpPendingMessagesSchema, Wt as getThreadStopDecision, X as actOnInboxItem, Y as InboxItemActionError, Z as closeInboxItemsAnsweredByReply, _ as createConversationForViewer, _t as backfillCacheWarmingGaps, a as resolveInboxItemSubjects, b as encodeConversationCursor, ct as listOpenAutomationQuestions, dt as getScheduledAutomationDispatch, et as createEventAppPublisher, ft as runInboxSnoozeTimers, g as appendConversationMessageForViewer, ht as runSavingsRefillSlice, jt as getProductionSlackAdapter, kt as createProductionConversationWorkOptions, lt as createHeartbeatContext, n as readConversationFeed, nt as runAutoArchiveSweep, o as readConversationDetail, ot as automationReplyAttribution, st as settleEventAutomationRuns, tt as ingestEventAutomations, ut as dispatchScheduledAutomation, vt as GET$4, w as conversationOperations, y as decodeConversationCursor, z as mcpCursorSchema, zt as bindMessageAuthorIdentityId } from "./list-Bxvg5wXf.js";
|
|
9
|
-
import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "./validation-8gjfR91V.js";
|
|
1
|
+
import { C as parseActorUserId, E as parseSlackChannelId, F as slackMessageTsFromMs, G as loadConfig, I as slackMessageTsSchema, K as parseEnvList, L as botConfig, M as slackTeamIdSchema, P as parseSlackMessageTs, R as getChatConfig, W as installChatConfig, i as getStateAdapter, j as slackChannelIdSchema, l as fenceLock, s as MUTATION_LOCK_TTL_MS, u as withLock, v as createSlackActor } from "./adapter-8_S6Birm.js";
|
|
2
|
+
import { $ as canActOnInboxItem, $n as sendSlackReply, $r as renderSlackObjectCard, Ap as juniorTurns, Ar as readConversationAccessFromSql, Au as EVENT_INDEX_LOCK_TTL_MS, Ba as existingConversationId, Bi as slackMention, Bn as pushConversationInboxItemsNow, Bo as takeDueTimerWatches, Bp as juniorConversations, Br as resolveConversationWorkTopic, Ci as notifyAutomationBlocked, Cl as getDashboardConversationLink, Cn as hasRunnableConversationWork, Dc as recordGoogleSignIn, Dn as pruneActiveConversation, Dp as juniorConversationEmbeddings, Dt as getRegistrations, Ep as juniorConversationEventEmbeddings, Fd as getAppContext, Fi as slackExternalRefIdSchema, Gc as searchInboxItems, Gf as touchConversationDetail, Gn as findSlackThreadOwnerId, Gu as createConversationEmbedder, Hn as runInboxItemPushTimers, Id as installAppContext, Jn as parseSlackInboxItemClick, Kf as createSlackDestination, Lu as storeConversationEventLexemes, Ma as automationVersionOf, Mu as eventIndexLockKey, O as withConversationMutationLock, Oi as openSlackModal, Ot as validatePlugins, Pd as createAppContext, Pi as slackEntitySchema, Pl as projectConversationMessages, Qt as clearExpiredConversationLease, R as replaceConversationMetrics, Sp as juniorAgentBindings, Tn as isInvalidConversationRecordError, Tp as juniorConversationEventLexemes, Tt as inboxItemVisibility, U as conversationIsActiveSql, Un as resolveSlackInboxItemCardConversationId, Ur as conversationQueueMessageSchema, Uu as isEventEmbeddingsEnabled, Vr as verifyConversationQueueMessage, Wn as syncInboxItemSlackCards, Wr as isConversationQueueMessageRejectedError, Wt as appendAndEnqueueInboundMessage, Wu as backfillConversationEmbeddings, Yn as parseSlackInboxItemFormTarget, Yr as getQueueProvider, Za as refreshAutomationLastRun, Zc as itemQuestion, Zn as parseSlackUserInputSubmission, Zs as getSlackClient, _a as scheduledRunId, _i as listPendingDispatchMailboxAppends, _t as isPluginInboxItem, a as getDb, an as getConversation, at as inboxItemAddedByAnyAutomation, bc as resolveActorIdentityId, bp as juniorInboxItems, bs as listConversationAnnotations, cc as runWithWorkspaceTeamId, ci as confirmDispatchMailboxAppend, cn as listActiveConversationIds, cs as subjectKey, dt as inboxItemReaderForUser, ei as annotationKeyDigest, fa as listScheduledAutomationsForTeam, fc as readActorIdentity, fp as juniorAutomationRuns, ft as inboxItemReaderForUserInConversation, ga as saveScheduledAutomationInLock, gc as resolveViewerUser, gi as isTerminalDispatchStatus, go as slackChannelMessageEvent, hp as juniorAutomations, i as getConversationStore, in as ensureConversationWake, io as syncAutomationAlerts, js as isPublicConversation, ju as embedConversationEvents, ki as postSlackEphemeralMessage, kl as getDashboardTaskLink, kp as juniorConversationEvents, lp as juniorQuestions, lr as sendVercelPluginTask, m as deleteMessageLinks, ma as readScheduledAutomation, ml as deleteExpiredInboxSnoozes, mo as SLACK_EVENT_NAMESPACE, n as getConversationEventStore, ni as runWithSlackInstallation, np as juniorTurnInbox, nr as getPluginApiRoutes, o as getSqlExecutor, on as getConversationWorkState, or as createVercelPluginTaskCallback, pi as getDispatchRecord, qn as buildSlackInboxItemModal, qp as juniorDestinations, ri as verifySlackSignature, rr as getPluginRoutes, sc as getWorkspaceTeamId, sl as parseAvatarUrl, ti as decodeAnnotationRef, tp as juniorTurnOutbox, tr as createPluginEventPublisher, ts as resumeConversationDelivery, tt as canAnswerInboxItem, u as isPostgresErrorCode, ui as getDispatchConversationId, ur as queueCallback, v as withConversationEventLock, va as withScheduledAutomationLock, wl as getDashboardInboxItemLink, wr as canAddConversationMessages, wt as inboxItemOwnerConversationId, xi as markDispatchFailed, yn as CONVERSATION_WORK_STALE_ENQUEUE_MS, z as conversationCostOf, zc as dismissOpenInboxItems, zn as createInboxItemShow, zr as getVercelConversationWorkQueue } from "./db-BCaNWl9p.js";
|
|
3
|
+
import { C as withContext, D as GOOGLE_IDENTITY_PROVIDER, T as withSpan, f as logException, k as normalizeIdentityEmail, m as logWarn, n as createRequestContext, p as logInfo, w as withLogContext, y as setSpanAttributes } from "./logging-BRPTXAdf.js";
|
|
4
|
+
import { $ as slackInboundMessageId, C as verifyWorkspaceSnapshotJobMessage, Cn as recordWebConversationActivity, En as collectAttachmentUploadGarbage, F as markConversationRead, Ft as isPublicAddress, Gn as readPublicArtifact, Hn as requestAttachmentDeletion, It as publicAddressLookup, J as getProductionSlackAdapter, K as createProductionConversationWorkOptions, Kn as unpublishedArtifactHeaders, L as deliverInboxItemChange, Q as clearSlackPendingReactions, R as inboxItemChangeRecord, S as processWorkspaceSnapshotJob, Un as parseSlackThreadId, Ut as readConversationRecordFromSql, Wn as publicArtifactHeaders, Z as buildSlackInboundMessage, _t as recordSkippedConversationMessage, ar as readViewerAutomationSummary, at as enqueueAgentDispatch, b as verifyBackgroundCompactionMessage, bn as conversationTurnIdForMessage, cn as startProcessingReaction, dn as isRetryableSlackPostError, dr as effectiveTaskOutcomes, dt as readConversationEventPage, er as ViewerTaskNotFoundError, et as normalizeIncomingSlackThreadId, fn as SubscribedReplyReason, ft as readConversationEventPageAfter, ht as readConversationMessageEventSeq, i as scheduledAutomationRunAttributes, in as bindMessageAgent, kt as readObjectLinkTypes, ln as stripLeadingBotMention, lr as findAutomationSkill, mt as readConversationLastEventSeq, on as createAgentRunner, ot as failStoppedDispatch, pn as getThreadStopDecision, q as createProductionSlackWebhookServices, r as logScheduledAutomationRunSkipped, rr as readViewerAutomationExecutions, sn as bindMessageAuthorIdentityId, sr as readViewerAutomations, st as processPluginTask, t as executeAgentRun, tn as bindSpawnAgent, tt as withNormalizedThreadId, un as parseContent, ur as missingAutomationSkillReason, v as processBackgroundCompaction, vt as stopConversation, w as ingestEvent, wn as webActorFromUser, wt as readLiveAnnotations, x as createVercelCacheWarmupCallback, xn as createAndEnqueueConversation, y as vercelBackgroundCompactionQueue, yn as appendAndEnqueueWebMessage, yt as createSlackWebApiStatusSender, z as renderInboxItemMessage, zn as collectAttachmentGarbage } from "./agent-CtzMl32d.js";
|
|
5
|
+
import { A as createUserTokenStore, C as clearSandboxEgressSignals, D as parseSandboxEgressCredentialToken, P as normalizeSandboxEgressTracePropagationDomains, T as consumeSandboxEgressPermissionDeniedSignal, c as isVercelSandboxEgressRequest, l as proxyVercelSandboxEgressRequest, w as consumeSandboxEgressAuthRequiredSignal } from "./profile-D9LdwmZi.js";
|
|
6
|
+
import { n as validatePluginRegistrations, t as validatePluginEgressCredentialHooks } from "./validation-BCUpJa8K.js";
|
|
10
7
|
import { a as pluginRuntimeRegistrationsFromPluginSet, n as pluginCatalogConfigFromEnv, r as pluginCatalogConfigFromPluginSet, t as defineJuniorPlugins } from "./plugins-D_Ru4CWc.js";
|
|
11
|
-
import { n as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { t as createEndStoppedChildWork } from "./result-
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
8
|
+
import { $ as reviewItemChange, B as mcpIdempotencyKeySchema, F as mcpAuthorizationSchema$1, G as readMcpPendingWork, H as mcpMessageTextSchema, I as mcpConversation, K as readMcpPendingWorkAfterSend, L as mcpConversationIdSchema, P as mcpAcceptedMessageSchema, Q as readInboxItemForUser, R as mcpConversationSchema, U as mcpMessages, V as mcpMessageSchema, W as mcpPendingMessagesSchema, X as actOnInboxItem, Y as InboxItemActionError, Z as closeInboxItemsAnsweredByReply, _ as createConversationForViewer, _t as backfillCacheWarmingGaps, a as resolveInboxItemSubjects, b as encodeConversationCursor, ct as listOpenAutomationQuestions, dt as getScheduledAutomationDispatch, et as createEventAppPublisher, ft as runInboxSnoozeTimers, g as appendConversationMessageForViewer, ht as runSavingsRefillSlice, lt as createHeartbeatContext, n as readConversationFeed, nt as runAutoArchiveSweep, o as readConversationDetail, ot as automationReplyAttribution, st as settleEventAutomationRuns, tt as ingestEventAutomations, ut as dispatchScheduledAutomation, vt as GET$4, w as conversationOperations, y as decodeConversationCursor, z as mcpCursorSchema } from "./list-wwDcROh9.js";
|
|
9
|
+
import { I as getAuthPausedConversationTurnId, Kn as settleConversationTitleWork, Mt as renderTaskInput, Q as coerceThreadConversationState, Vn as appendConversationMessages, dn as isExperimentalFeatureEnabled, gt as parseEmail, ht as isTrustedSlackAuthor, mt as isAllowedDomain, pt as findTrustedUser, q as getLocationConfigurationService } from "./markers-9QoqW5ov.js";
|
|
10
|
+
import { Bt as annotationCard, Kt as automationCardStatus, On as automationTaskSchema, Pn as getNextRunAtMs, _ as automationListQuerySchema, in as scheduledRunSchema, kn as automationTaskText, p as automationExecutionStatusSchema, pn as inboxItemQuestion, vn as buttonUserInputField } from "./types-BNHkJrOP.js";
|
|
11
|
+
import { t as createEndStoppedChildWork } from "./result-5IdGJP4M.js";
|
|
12
|
+
import { h as createPluginLogger } from "./prompt-3TqxEOtc.js";
|
|
13
|
+
import { n as getAttachmentStorage } from "./storage-C9U7R5rM.js";
|
|
17
14
|
import { i as getActiveSpan, u as sentry_exports } from "./sentry-CPbZjomA.js";
|
|
18
|
-
import { a as GET$5, i as publishAppHomeView, r as GET$6, t as receiveLocalOAuthCredential } from "./credential-sync-
|
|
15
|
+
import { a as GET$5, i as publishAppHomeView, r as GET$6, t as receiveLocalOAuthCredential } from "./credential-sync-DyRqDmY4.js";
|
|
19
16
|
import { t as nameRequestRoute } from "./sentry-route-name-C6EIzAGP.js";
|
|
20
17
|
import { t as SANDBOX_EGRESS_PROXY_PATH } from "./proxy-path-BHYoKZdq.js";
|
|
21
|
-
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-
|
|
22
|
-
import { l as unlinkProvider, n as renderHtmlPage, r as requestHasSameOrigin, t as escapeHtml } from "./html-
|
|
23
|
-
import { s as joinPublicChannel } from "./channel-access-
|
|
24
|
-
import { a as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE,
|
|
25
|
-
import {
|
|
26
|
-
import { t as
|
|
27
|
-
import { t as
|
|
28
|
-
import { t as
|
|
29
|
-
import { l as readConversationLastEventSeq, o as readConversationEventPage, s as readConversationEventPageAfter, t as processPluginTask, u as readConversationMessageEventSeq } from "./task-runner-C9Yc2_ae.js";
|
|
30
|
-
import { c as replyText, d as publishTurnStep, f as countMetric, i as turnStepConsumer, l as createDeliveryConsumer, n as turnTools, o as findStalledTurns, p as withSpan$1, r as createGatewayModelClient, s as findStalledDeliveries, t as createEngineContext, u as publishDelivery } from "./engine-context-CgQ7mlHt.js";
|
|
31
|
-
import { t as JUNIOR_VERSION } from "./version-BeZhWWBE.js";
|
|
32
|
-
import { D as conversationPendingMessageDeliverySchema, f as conversationTitleSchema, t as conversationFeedQuerySchema } from "./conversation-feed--9S0_PXL.js";
|
|
18
|
+
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-ZC_TSpc4.js";
|
|
19
|
+
import { l as unlinkProvider, n as renderHtmlPage, r as requestHasSameOrigin, t as escapeHtml } from "./html-Bb2Si1bR.js";
|
|
20
|
+
import { s as joinPublicChannel } from "./channel-access-DET5hzZM.js";
|
|
21
|
+
import { a as JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, c as JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE, d as JUNIOR_TURN_ENDED_CALLBACK_ROUTE, f as JUNIOR_TURN_STEP_CALLBACK_ROUTE, i as JUNIOR_CONTEXT_COMPACTION_CALLBACK_ROUTE, n as JUNIOR_AUTO_ARCHIVE_ROUTE, p as JUNIOR_WORKSPACE_SNAPSHOT_JOB_CALLBACK_ROUTE, r as JUNIOR_CACHE_WARMUP_CALLBACK_ROUTE } from "./deployment-CfOew1Tm.js";
|
|
22
|
+
import { t as processConversationWork } from "./worker-BhgpZ7_b.js";
|
|
23
|
+
import { a as turnStepConsumer, c as findTurn, d as readTurnEndedMessages, f as publishTurnStep, g as withSpan$1, h as countMetric, i as createGatewayModelClient, l as replyText, m as loadTurnAgentHistory, n as turnTools, p as findTurnActor, r as turnUsage, s as findStalledTurns, t as createEngineContext, u as publishTurnEnded } from "./engine-context-CiExoy1B.js";
|
|
24
|
+
import { t as JUNIOR_VERSION } from "./version-BNm0JYj3.js";
|
|
25
|
+
import { D as conversationPendingMessageDeliverySchema, f as conversationTitleSchema, t as conversationFeedQuerySchema } from "./conversation-feed-DEUdD7mb.js";
|
|
33
26
|
import { t as isMissingVirtualModule } from "./virtual-module-BeKA_EII.js";
|
|
34
27
|
import { createRequire } from "node:module";
|
|
35
28
|
import { Hono } from "hono";
|
|
36
29
|
import * as z from "zod";
|
|
37
|
-
import {
|
|
30
|
+
import { and, asc, desc, eq, gt, gte, inArray, isNotNull, isNull, lt, lte, ne, not, notExists, notInArray, or, sql } from "drizzle-orm";
|
|
31
|
+
import { alias, pgTable, text } from "drizzle-orm/pg-core";
|
|
38
32
|
import { destinationSchema, eventTriggerFiltersText, identityDispatchOptionsSchema, userSchema } from "@sentry/junior-plugin-api";
|
|
39
|
-
import { and, asc, desc, eq, gt, gte, inArray, isNotNull, isNull, lt, lte, ne, not, notExists, or, sql } from "drizzle-orm";
|
|
40
|
-
import { pgTable, text } from "drizzle-orm/pg-core";
|
|
41
33
|
import { pathToFileURL } from "node:url";
|
|
34
|
+
import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
42
35
|
import { Message, ThreadImpl } from "chat";
|
|
43
36
|
import net from "node:net";
|
|
44
37
|
import { decodeJwt } from "jose";
|
|
@@ -111,7 +104,8 @@ async function listActiveConversations(db, args) {
|
|
|
111
104
|
const after = args.after;
|
|
112
105
|
return await withScanTimeout(db, async (tx) => await tx.select({
|
|
113
106
|
at: sql`to_char(${conversations.lastActivityAt} at time zone 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.US"Z"')`,
|
|
114
|
-
conversationId: conversations.conversationId
|
|
107
|
+
conversationId: conversations.conversationId,
|
|
108
|
+
turnActive: conversationIsActiveSql(conversations)
|
|
115
109
|
}).from(conversations).where(and(gte(conversations.lastActivityAt, new Date(args.sinceMs)), after ? or(lt(conversations.lastActivityAt, sql`${after.at}::timestamptz`), and(eq(conversations.lastActivityAt, sql`${after.at}::timestamptz`), gt(conversations.conversationId, after.conversationId))) : void 0)).orderBy(desc(conversations.lastActivityAt), conversations.conversationId).limit(CONVERSATION_PAGE_SIZE));
|
|
116
110
|
}
|
|
117
111
|
async function hasMissingVector(tx, embedder, conversationId) {
|
|
@@ -155,6 +149,7 @@ async function backfillEventSearchIndex(args) {
|
|
|
155
149
|
const run = {
|
|
156
150
|
conversations: 0,
|
|
157
151
|
lexemes: 0,
|
|
152
|
+
running: 0,
|
|
158
153
|
skipped: 0,
|
|
159
154
|
vectors: 0
|
|
160
155
|
};
|
|
@@ -175,7 +170,12 @@ async function backfillEventSearchIndex(args) {
|
|
|
175
170
|
after,
|
|
176
171
|
sinceMs
|
|
177
172
|
});
|
|
178
|
-
for (const conversation of page) {
|
|
173
|
+
for (const { turnActive, ...conversation } of page) {
|
|
174
|
+
if (turnActive) {
|
|
175
|
+
run.running += 1;
|
|
176
|
+
after = conversation;
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
179
|
const lexemeRoom = MAX_LEXEME_EVENTS_PER_RUN - run.lexemes;
|
|
180
180
|
const vectorRoom = MAX_VECTOR_EVENTS_PER_RUN - run.vectors;
|
|
181
181
|
if (Date.now() >= args.deadlineMs || lexemeRoom <= 0 || args.embedder && vectorRoom <= 0) return {
|
|
@@ -243,6 +243,7 @@ async function runEventSearchBackfill(args) {
|
|
|
243
243
|
setSpanAttributes({
|
|
244
244
|
"app.event_search.backfill.conversation.count": result.run.conversations,
|
|
245
245
|
"app.event_search.backfill.skipped.count": result.run.skipped,
|
|
246
|
+
"app.event_search.backfill.running.count": result.run.running,
|
|
246
247
|
"app.event_search.backfill.lexeme.count": result.run.lexemes,
|
|
247
248
|
"app.event_search.backfill.vector.count": result.run.vectors,
|
|
248
249
|
"app.event_search.backfill.pass.conversation.count": result.pass.conversations,
|
|
@@ -1579,7 +1580,7 @@ async function handleSandboxEgressRoute(request, tracePropagationDomains, next)
|
|
|
1579
1580
|
const SANDBOX_EGRESS_TOKEN_HEADER = "x-junior-sandbox-egress-token";
|
|
1580
1581
|
function isLoopbackDevelopmentRequest(request) {
|
|
1581
1582
|
const hostname = new URL(request.url).hostname;
|
|
1582
|
-
return
|
|
1583
|
+
return getChatConfig().development.enabled && (hostname === "127.0.0.1" || hostname === "localhost");
|
|
1583
1584
|
}
|
|
1584
1585
|
/** Clear command-scoped sandbox egress signals through the loopback dev server. */
|
|
1585
1586
|
async function DELETE(request) {
|
|
@@ -1609,7 +1610,10 @@ const eventSchema = z.object({
|
|
|
1609
1610
|
id: slackExternalRefIdSchema
|
|
1610
1611
|
})
|
|
1611
1612
|
});
|
|
1612
|
-
/**
|
|
1613
|
+
/**
|
|
1614
|
+
* Show an annotation's object, as the viewer can read it now, only to a
|
|
1615
|
+
* viewer who can read its Conversation.
|
|
1616
|
+
*/
|
|
1613
1617
|
async function presentSlackAnnotationDetails(event, teamId) {
|
|
1614
1618
|
const triggerId = event["trigger_id"];
|
|
1615
1619
|
if (typeof triggerId !== "string" || !triggerId) return;
|
|
@@ -1651,12 +1655,13 @@ async function presentSlackAnnotationDetails(event, teamId) {
|
|
|
1651
1655
|
await missing();
|
|
1652
1656
|
return;
|
|
1653
1657
|
}
|
|
1654
|
-
const
|
|
1655
|
-
if (!
|
|
1658
|
+
const saved = (await listConversationAnnotations(db, conversationId)).find((item) => annotationKeyDigest(item.plugin, item.key) === keyDigest);
|
|
1659
|
+
if (!saved) {
|
|
1656
1660
|
await missing();
|
|
1657
1661
|
return;
|
|
1658
1662
|
}
|
|
1659
|
-
const
|
|
1663
|
+
const [annotation] = await readLiveAnnotations(identity.user, [saved]);
|
|
1664
|
+
const entity = annotation && renderSlackObjectCard(annotationCard(annotation), conversationId, "details").entity;
|
|
1660
1665
|
if (!entity) {
|
|
1661
1666
|
await missing();
|
|
1662
1667
|
return;
|
|
@@ -3124,7 +3129,7 @@ function resolveConversationWorkVisibilityTimeoutSeconds(functionMaxDurationSeco
|
|
|
3124
3129
|
*/
|
|
3125
3130
|
function queueProcessAttributes(metadata, nowMs) {
|
|
3126
3131
|
return {
|
|
3127
|
-
"messaging.destination.name": metadata?.topicName ??
|
|
3132
|
+
"messaging.destination.name": metadata?.topicName ?? resolveConversationWorkTopic(),
|
|
3128
3133
|
"messaging.system": getQueueProvider().messagingSystem,
|
|
3129
3134
|
...metadata && {
|
|
3130
3135
|
"messaging.message.id": metadata.messageId,
|
|
@@ -3176,7 +3181,7 @@ async function consumeConversationQueueMessage(message, options) {
|
|
|
3176
3181
|
createdAt: new Date(nowMs),
|
|
3177
3182
|
deliveryCount: 1,
|
|
3178
3183
|
messageId: options.messageId,
|
|
3179
|
-
topicName:
|
|
3184
|
+
topicName: resolveConversationWorkTopic(options.topic)
|
|
3180
3185
|
});
|
|
3181
3186
|
}
|
|
3182
3187
|
function logConversationQueueMessageRejected(reason, metadata, error) {
|
|
@@ -3264,7 +3269,7 @@ function backgroundCompactionCallback() {
|
|
|
3264
3269
|
function createVercelBackgroundCompactionCallback() {
|
|
3265
3270
|
return backgroundCompactionCallback().create();
|
|
3266
3271
|
}
|
|
3267
|
-
// src/
|
|
3272
|
+
// src/delivery/deliver.ts
|
|
3268
3273
|
/**
|
|
3269
3274
|
* A send that failed but can work on a later try. The sender sets
|
|
3270
3275
|
* `retryAfterMs` when the provider says when to try again.
|
|
@@ -3284,22 +3289,23 @@ const RETRY_MAX_DELAY_MS = 6e4;
|
|
|
3284
3289
|
const tryLockResultSchema = z.object({ rows: z.tuple([z.object({ locked: z.boolean() })]) });
|
|
3285
3290
|
/**
|
|
3286
3291
|
* Sends the Conversation's pending outbox rows in event order, each to the
|
|
3287
|
-
* Destination stored on its row.
|
|
3292
|
+
* Destination stored on its row. To try again later, it sends the message
|
|
3293
|
+
* that the Turn ended again, with a delay.
|
|
3288
3294
|
*/
|
|
3289
3295
|
async function deliverTurn({ executor, queue }, message, delivery) {
|
|
3290
3296
|
while (true) {
|
|
3291
3297
|
const next = await executor.transaction(() => sendNextRow({ executor }, message.conversationId, delivery));
|
|
3292
3298
|
if (next.kind === "idle") return;
|
|
3293
3299
|
if (next.kind === "later") {
|
|
3294
|
-
await
|
|
3300
|
+
await publishTurnEnded({ queue }, message, { delayMs: next.delayMs });
|
|
3295
3301
|
return;
|
|
3296
3302
|
}
|
|
3297
3303
|
}
|
|
3298
3304
|
}
|
|
3299
3305
|
/**
|
|
3300
3306
|
* Sends the Conversation's first pending row, if this transaction gets the
|
|
3301
|
-
* Conversation's lock
|
|
3302
|
-
* rows after it wait.
|
|
3307
|
+
* Conversation's lock and the row's Turn has ended. A retryable failure
|
|
3308
|
+
* leaves the row pending, so the rows after it wait.
|
|
3303
3309
|
*/
|
|
3304
3310
|
async function sendNextRow({ executor }, conversationId, delivery) {
|
|
3305
3311
|
const db = executor.db();
|
|
@@ -3311,9 +3317,10 @@ async function sendNextRow({ executor }, conversationId, delivery) {
|
|
|
3311
3317
|
id: juniorTurnOutbox.id,
|
|
3312
3318
|
eventSeq: juniorTurnOutbox.eventSeq,
|
|
3313
3319
|
destination: juniorTurnOutbox.destination,
|
|
3314
|
-
attempts: juniorTurnOutbox.attempts
|
|
3315
|
-
|
|
3316
|
-
|
|
3320
|
+
attempts: juniorTurnOutbox.attempts,
|
|
3321
|
+
turnState: juniorTurns.state
|
|
3322
|
+
}).from(juniorTurnOutbox).innerJoin(juniorTurns, eq(juniorTurns.id, juniorTurnOutbox.turnId)).where(and(eq(juniorTurnOutbox.conversationId, conversationId), eq(juniorTurnOutbox.state, "pending"))).orderBy(asc(juniorTurnOutbox.eventSeq)).limit(1);
|
|
3323
|
+
if (!row || row.turnState === "queued" || row.turnState === "running") return { kind: "idle" };
|
|
3317
3324
|
const markFailed = async (error) => {
|
|
3318
3325
|
await db.update(juniorTurnOutbox).set({
|
|
3319
3326
|
state: "failed",
|
|
@@ -3322,7 +3329,12 @@ async function sendNextRow({ executor }, conversationId, delivery) {
|
|
|
3322
3329
|
}).where(eq(juniorTurnOutbox.id, row.id));
|
|
3323
3330
|
return { kind: "settled" };
|
|
3324
3331
|
};
|
|
3325
|
-
const
|
|
3332
|
+
const parsed = destinationSchema.safeParse(row.destination);
|
|
3333
|
+
if (!parsed.success) {
|
|
3334
|
+
logException(parsed.error, "turn.delivery.failed", { "gen_ai.conversation.id": conversationId });
|
|
3335
|
+
return markFailed("The Destination is not valid");
|
|
3336
|
+
}
|
|
3337
|
+
const destination = parsed.data;
|
|
3326
3338
|
const [event] = await db.select().from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), eq(juniorConversationEvents.seq, row.eventSeq)));
|
|
3327
3339
|
const text = event ? replyText(event) : void 0;
|
|
3328
3340
|
if (!text) return markFailed("The event is not a reply");
|
|
@@ -3369,56 +3381,108 @@ async function sendNextRow({ executor }, conversationId, delivery) {
|
|
|
3369
3381
|
function retryDelayMs(error, attempts) {
|
|
3370
3382
|
return Math.min(error.retryAfterMs ?? RETRY_BASE_DELAY_MS * 2 ** (attempts - 1), RETRY_MAX_DELAY_MS);
|
|
3371
3383
|
}
|
|
3372
|
-
// src/
|
|
3384
|
+
// src/delivery/slack.ts
|
|
3373
3385
|
/**
|
|
3374
|
-
*
|
|
3375
|
-
*
|
|
3386
|
+
* Creates the sender of replies to Slack Destinations. A Slack failure that a
|
|
3387
|
+
* later try can fix throws `DeliveryRetryableError`.
|
|
3376
3388
|
*/
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
}
|
|
3389
|
+
function createSlackSender(args) {
|
|
3390
|
+
return async (reply) => {
|
|
3391
|
+
const { channelId, teamId, threadTs } = reply.destination;
|
|
3392
|
+
let messageIds;
|
|
3393
|
+
try {
|
|
3394
|
+
messageIds = await runWithSlackInstallation({
|
|
3395
|
+
adapter: args.getSlackAdapter(),
|
|
3396
|
+
installation: { teamId },
|
|
3397
|
+
task: async () => sendSlackReply({
|
|
3398
|
+
channelId,
|
|
3399
|
+
threadTs,
|
|
3400
|
+
conversationId: reply.conversationId,
|
|
3401
|
+
formatting: {
|
|
3402
|
+
configuration: await getLocationConfigurationService({
|
|
3403
|
+
platform: "slack",
|
|
3404
|
+
teamId,
|
|
3405
|
+
channelId
|
|
3406
|
+
}).resolveValues(),
|
|
3407
|
+
teamId
|
|
3408
|
+
},
|
|
3409
|
+
text: reply.text
|
|
3410
|
+
})
|
|
3411
|
+
});
|
|
3412
|
+
} catch (error) {
|
|
3413
|
+
if (isRetryableSlackPostError(error)) throw new DeliveryRetryableError("Slack did not take the reply", { cause: error });
|
|
3414
|
+
throw error;
|
|
3415
|
+
}
|
|
3416
|
+
const providerMessageId = messageIds.at(-1);
|
|
3417
|
+
return providerMessageId ? { providerMessageId } : {};
|
|
3418
|
+
};
|
|
3419
|
+
}
|
|
3420
|
+
// src/turn-steps/metrics.ts
|
|
3380
3421
|
/**
|
|
3381
|
-
*
|
|
3382
|
-
*
|
|
3422
|
+
* Writes the metrics of an ended Turn. A rerun replaces the same rows, so a
|
|
3423
|
+
* Turn counts once however often its Turn-ended message arrives. A Turn that
|
|
3424
|
+
* never ran or has not ended writes nothing.
|
|
3383
3425
|
*/
|
|
3384
|
-
function
|
|
3385
|
-
|
|
3426
|
+
async function recordTurnMetrics(ctx, message) {
|
|
3427
|
+
const turn = await findTurn(ctx, message.turnId);
|
|
3428
|
+
if (!turn?.startedAt || !turn.endedAt) return;
|
|
3429
|
+
const [history, actorIdentityId] = await Promise.all([loadTurnAgentHistory(ctx, message.turnId), findTurnActor(ctx, message.turnId)]);
|
|
3430
|
+
const usage = await turnUsage(ctx, message.turnId, history);
|
|
3431
|
+
const { startedAt, endedAt } = turn;
|
|
3432
|
+
await withConversationMutationLock(ctx.executor, message.conversationId, () => replaceConversationMetrics(ctx.executor, {
|
|
3433
|
+
actorIdentityId,
|
|
3434
|
+
conversationId: message.conversationId,
|
|
3435
|
+
runId: message.turnId,
|
|
3436
|
+
occurredAtMs: startedAt.getTime(),
|
|
3437
|
+
updatedAtMs: endedAt.getTime(),
|
|
3438
|
+
durationMs: endedAt.getTime() - startedAt.getTime(),
|
|
3439
|
+
usage
|
|
3440
|
+
}));
|
|
3441
|
+
}
|
|
3442
|
+
// src/turn-steps/turn-ended.ts
|
|
3443
|
+
/**
|
|
3444
|
+
* Creates the Delivery of this deployment. It sends replies to Slack
|
|
3445
|
+
* Destinations. Other platforms have no sender yet, so their replies fail.
|
|
3446
|
+
*/
|
|
3447
|
+
function createDeploymentDelivery(args) {
|
|
3448
|
+
const sendToSlack = createSlackSender(args);
|
|
3449
|
+
return { send: async (reply) => {
|
|
3450
|
+
const { destination } = reply;
|
|
3451
|
+
if (destination.platform === "slack") return sendToSlack({
|
|
3452
|
+
...reply,
|
|
3453
|
+
destination
|
|
3454
|
+
});
|
|
3455
|
+
throw new Error(`No sender for ${destination.platform} Destinations`);
|
|
3456
|
+
} };
|
|
3386
3457
|
}
|
|
3387
|
-
// src/core/turn/sweep.ts
|
|
3388
|
-
const STALE_MS = 3e5;
|
|
3389
|
-
const BATCH = 100;
|
|
3390
3458
|
/**
|
|
3391
|
-
*
|
|
3392
|
-
*
|
|
3393
|
-
*
|
|
3459
|
+
* The queue consumer of the messages that a Turn ended. It records the Turn's
|
|
3460
|
+
* metrics, then sends its replies, so a send that waits does not hold back
|
|
3461
|
+
* the spend. The host mounts it on `engineCtx.queue`.
|
|
3394
3462
|
*/
|
|
3463
|
+
function turnEndedConsumer(engineCtx, delivery) {
|
|
3464
|
+
return readTurnEndedMessages(engineCtx, async (message) => {
|
|
3465
|
+
await recordTurnMetrics(engineCtx, message);
|
|
3466
|
+
await deliverTurn(engineCtx, message, delivery);
|
|
3467
|
+
});
|
|
3468
|
+
}
|
|
3469
|
+
// src/core/turn/sweep.ts
|
|
3470
|
+
const STALE_MS$1 = 3e5;
|
|
3471
|
+
const BATCH$1 = 100;
|
|
3472
|
+
/** Sends the step message again for each Turn that no message will reach. */
|
|
3395
3473
|
async function sweepTurns(ctx) {
|
|
3396
3474
|
await withSpan$1("turn.sweep", {}, async (span) => {
|
|
3397
3475
|
const turns = await findStalledTurns(ctx, {
|
|
3398
|
-
staleMs: STALE_MS,
|
|
3399
|
-
limit: BATCH
|
|
3476
|
+
staleMs: STALE_MS$1,
|
|
3477
|
+
limit: BATCH$1
|
|
3400
3478
|
});
|
|
3401
3479
|
for (const turn of turns) {
|
|
3402
3480
|
await publishTurnStep(ctx, turn.turnId);
|
|
3403
3481
|
reportRequeued(turn);
|
|
3404
3482
|
}
|
|
3405
|
-
const deliveries = await findStalledDeliveries(ctx, {
|
|
3406
|
-
staleMs: STALE_MS,
|
|
3407
|
-
limit: BATCH
|
|
3408
|
-
});
|
|
3409
|
-
for (const delivery of deliveries) {
|
|
3410
|
-
await publishDelivery(ctx, {
|
|
3411
|
-
conversationId: delivery.conversationId,
|
|
3412
|
-
turnId: delivery.turnId
|
|
3413
|
-
});
|
|
3414
|
-
reportRequeued({
|
|
3415
|
-
...delivery,
|
|
3416
|
-
reason: "delivery_lost"
|
|
3417
|
-
});
|
|
3418
|
-
}
|
|
3419
3483
|
span.setAttributes({
|
|
3420
|
-
"app.turn.sweep.requeued": turns.length
|
|
3421
|
-
"app.turn.sweep.batch_full": turns.length === BATCH
|
|
3484
|
+
"app.turn.sweep.requeued": turns.length,
|
|
3485
|
+
"app.turn.sweep.batch_full": turns.length === BATCH$1
|
|
3422
3486
|
});
|
|
3423
3487
|
}, { newTrace: true });
|
|
3424
3488
|
}
|
|
@@ -3431,6 +3495,59 @@ function reportRequeued(found) {
|
|
|
3431
3495
|
"app.turn.sweep.stalled_ms": found.stalledMs
|
|
3432
3496
|
});
|
|
3433
3497
|
}
|
|
3498
|
+
// src/delivery/sweep.ts
|
|
3499
|
+
const STALE_MS = 3e5;
|
|
3500
|
+
const BATCH = 100;
|
|
3501
|
+
/**
|
|
3502
|
+
* Sends the message that a Turn ended again for each Conversation whose
|
|
3503
|
+
* replies no message will send.
|
|
3504
|
+
*/
|
|
3505
|
+
async function sweepDeliveries(ctx) {
|
|
3506
|
+
await withSpan$1("delivery.sweep", {}, async (span) => {
|
|
3507
|
+
const stalled = await findStalledDeliveries(ctx, {
|
|
3508
|
+
staleMs: STALE_MS,
|
|
3509
|
+
limit: BATCH
|
|
3510
|
+
});
|
|
3511
|
+
for (const delivery of stalled) {
|
|
3512
|
+
await publishTurnEnded(ctx, {
|
|
3513
|
+
conversationId: delivery.conversationId,
|
|
3514
|
+
turnId: delivery.turnId
|
|
3515
|
+
});
|
|
3516
|
+
countMetric("turn.sweep.requeued", { "app.turn.sweep.reason": "delivery_lost" });
|
|
3517
|
+
logWarn("turn.sweep.requeued", {
|
|
3518
|
+
"app.turn.id": delivery.turnId,
|
|
3519
|
+
"gen_ai.conversation.id": delivery.conversationId,
|
|
3520
|
+
"app.turn.sweep.reason": "delivery_lost",
|
|
3521
|
+
"app.turn.sweep.stalled_ms": delivery.stalledMs
|
|
3522
|
+
});
|
|
3523
|
+
}
|
|
3524
|
+
span.setAttributes({
|
|
3525
|
+
"app.turn.sweep.requeued": stalled.length,
|
|
3526
|
+
"app.turn.sweep.batch_full": stalled.length === BATCH
|
|
3527
|
+
});
|
|
3528
|
+
}, { newTrace: true });
|
|
3529
|
+
}
|
|
3530
|
+
/**
|
|
3531
|
+
* Finds Conversations whose first pending reply belongs to an ended Turn and
|
|
3532
|
+
* has not changed for `staleMs` since the later of its last change and the
|
|
3533
|
+
* Turn's end. A row behind a first row that is still retried waits; it is
|
|
3534
|
+
* not stalled. A row of a running Turn waits for the Turn's end.
|
|
3535
|
+
*/
|
|
3536
|
+
async function findStalledDeliveries({ executor }, { staleMs, limit }) {
|
|
3537
|
+
const staleBefore = sql`now() - make_interval(secs => ${staleMs / 1e3})`;
|
|
3538
|
+
const earlier = alias(juniorTurnOutbox, "earlier");
|
|
3539
|
+
const rows = await executor.db().select({
|
|
3540
|
+
conversationId: juniorTurnOutbox.conversationId,
|
|
3541
|
+
turnId: juniorTurnOutbox.turnId,
|
|
3542
|
+
updatedAt: juniorTurnOutbox.updatedAt
|
|
3543
|
+
}).from(juniorTurnOutbox).innerJoin(juniorTurns, eq(juniorTurns.id, juniorTurnOutbox.turnId)).where(and(eq(juniorTurnOutbox.state, "pending"), lt(juniorTurnOutbox.createdAt, staleBefore), lt(juniorTurnOutbox.updatedAt, staleBefore), notInArray(juniorTurns.state, ["queued", "running"]), lt(juniorTurns.endedAt, staleBefore), notExists(executor.db().select({ one: sql`1` }).from(earlier).where(and(eq(earlier.conversationId, juniorTurnOutbox.conversationId), eq(earlier.state, "pending"), lt(earlier.eventSeq, juniorTurnOutbox.eventSeq)))))).limit(limit);
|
|
3544
|
+
const nowMs = Date.now();
|
|
3545
|
+
return rows.map((row) => ({
|
|
3546
|
+
conversationId: row.conversationId,
|
|
3547
|
+
turnId: row.turnId,
|
|
3548
|
+
stalledMs: Math.max(0, nowMs - row.updatedAt.getTime())
|
|
3549
|
+
}));
|
|
3550
|
+
}
|
|
3434
3551
|
// src/handlers/artifacts.ts
|
|
3435
3552
|
/** Serve one content-addressed public artifact without authentication. */
|
|
3436
3553
|
async function publicArtifactGET(args) {
|
|
@@ -3548,7 +3665,7 @@ function createAcpConversations(options) {
|
|
|
3548
3665
|
},
|
|
3549
3666
|
async prompt({ conversationId, idempotencyKey, text, user }) {
|
|
3550
3667
|
const access = await readAccess(conversationId, user);
|
|
3551
|
-
if (!
|
|
3668
|
+
if (!canAddConversationMessages(access)) return { status: "not_found" };
|
|
3552
3669
|
const currentCursor = await latestEventCursor(options.eventStore, conversationId);
|
|
3553
3670
|
if (await getAuthPausedConversationTurnId(conversationId)) return { status: "active" };
|
|
3554
3671
|
const result = await appendAndEnqueueWebMessage({
|
|
@@ -6705,43 +6822,6 @@ async function handleAcpAuthorizationPage(args) {
|
|
|
6705
6822
|
});
|
|
6706
6823
|
return renderResult(args.agentName, result);
|
|
6707
6824
|
}
|
|
6708
|
-
// src/chat/sign-in/allowlist.ts
|
|
6709
|
-
/**
|
|
6710
|
-
* Read the domain list that may use Junior. Slack authors must have a Slack
|
|
6711
|
-
* profile email on one of them, and dashboard Google sign-ins must come from
|
|
6712
|
-
* a Google Workspace account whose `hd` claim is one of them. Slack and the
|
|
6713
|
-
* dashboard share one list. `chat/identities/trust` decides who matches.
|
|
6714
|
-
*/
|
|
6715
|
-
/** Parse a list env var value: a JSON string array or comma-separated values. */
|
|
6716
|
-
function parseEnvList(name, rawValue) {
|
|
6717
|
-
const value = rawValue?.trim();
|
|
6718
|
-
if (!value) return void 0;
|
|
6719
|
-
if (!value.startsWith("[")) return value.split(",");
|
|
6720
|
-
let parsed;
|
|
6721
|
-
try {
|
|
6722
|
-
parsed = JSON.parse(value);
|
|
6723
|
-
} catch (error) {
|
|
6724
|
-
throw new Error(`${name} must be a JSON string array`, { cause: error });
|
|
6725
|
-
}
|
|
6726
|
-
const list = z.array(z.string()).safeParse(parsed);
|
|
6727
|
-
if (!list.success) throw new Error(`${name} must be a JSON string array`);
|
|
6728
|
-
return list.data;
|
|
6729
|
-
}
|
|
6730
|
-
/**
|
|
6731
|
-
* Resolve the allowed domains: the `createApp` option when set, else
|
|
6732
|
-
* `JUNIOR_ALLOWED_DOMAINS`. An empty list allows every domain.
|
|
6733
|
-
*/
|
|
6734
|
-
function resolveAllowedDomains(allowedDomains) {
|
|
6735
|
-
return [...new Set((allowedDomains ?? parseEnvList("JUNIOR_ALLOWED_DOMAINS", getChatConfig().signIn.allowedDomains) ?? []).map((value) => value.trim().toLowerCase()).filter(Boolean))];
|
|
6736
|
-
}
|
|
6737
|
-
/**
|
|
6738
|
-
* Fail startup on the removed Google-specific option. Ignoring it would
|
|
6739
|
-
* leave the list empty, which lets every Slack workspace member in.
|
|
6740
|
-
* `loadConfig` rejects the removed env var the same way.
|
|
6741
|
-
*/
|
|
6742
|
-
function assertNoLegacyAllowedDomains(dashboardOptionKeys) {
|
|
6743
|
-
if (dashboardOptionKeys.includes("allowedGoogleDomains")) throw new Error("dashboard.allowedGoogleDomains was removed; set createApp({ allowedDomains }) instead");
|
|
6744
|
-
}
|
|
6745
6825
|
// src/chat/sign-in/auth.ts
|
|
6746
6826
|
/**
|
|
6747
6827
|
* Google sign-in session for the dashboard.
|
|
@@ -6915,6 +6995,16 @@ function createSignInAuth(config) {
|
|
|
6915
6995
|
}
|
|
6916
6996
|
};
|
|
6917
6997
|
}
|
|
6998
|
+
// src/chat/sign-in/allowlist.ts
|
|
6999
|
+
/**
|
|
7000
|
+
* Fail startup on the removed Google-specific option. Ignoring it would
|
|
7001
|
+
* leave the allowed domain list empty, which lets every Slack workspace
|
|
7002
|
+
* member in. `loadConfig` resolves the list and rejects the removed env var
|
|
7003
|
+
* the same way.
|
|
7004
|
+
*/
|
|
7005
|
+
function assertNoLegacyAllowedDomains(dashboardOptionKeys) {
|
|
7006
|
+
if (dashboardOptionKeys.includes("allowedGoogleDomains")) throw new Error("dashboard.allowedGoogleDomains was removed; set createApp({ allowedDomains }) instead");
|
|
7007
|
+
}
|
|
6918
7008
|
// src/dashboard-routes.ts
|
|
6919
7009
|
const DASHBOARD_PACKAGE_NAME = "@sentry/junior-dashboard";
|
|
6920
7010
|
/**
|
|
@@ -7179,13 +7269,30 @@ function appConfigInput(options, virtualConfig) {
|
|
|
7179
7269
|
refusalFallbackModelId: options?.refusalFallbackModelId,
|
|
7180
7270
|
userName: virtualConfig?.botName
|
|
7181
7271
|
},
|
|
7272
|
+
configDefaults: options?.configDefaults,
|
|
7273
|
+
dashboard: dashboard && {
|
|
7274
|
+
basePath: dashboard.basePath,
|
|
7275
|
+
baseURL: dashboard.baseURL,
|
|
7276
|
+
disabled: dashboard.disabled
|
|
7277
|
+
},
|
|
7182
7278
|
deployment: { configuredBaseUrl: dashboard?.baseURL?.trim() || void 0 },
|
|
7279
|
+
eventEmbeddings: options?.eventEmbeddings,
|
|
7280
|
+
experimental: options?.experimental,
|
|
7183
7281
|
functionMaxDurationSeconds: virtualConfig?.functionMaxDurationSeconds,
|
|
7184
7282
|
limits: options?.limits,
|
|
7283
|
+
memory: {
|
|
7284
|
+
disableExtraction: options?.memory?.disableExtraction,
|
|
7285
|
+
disableRecall: options?.memory?.disableRecall,
|
|
7286
|
+
modelId: options?.memory?.modelId?.trim() || void 0
|
|
7287
|
+
},
|
|
7185
7288
|
sandbox: { vcpus: options?.sandbox?.vcpus },
|
|
7186
7289
|
slack: {
|
|
7187
7290
|
completedReactionEmoji: options?.slack?.completedReactionEmoji,
|
|
7188
7291
|
processingReactionEmoji: options?.slack?.processingReactionEmoji
|
|
7292
|
+
},
|
|
7293
|
+
trust: {
|
|
7294
|
+
allowedBotUserIds: options?.slack?.allowedBotUserIds,
|
|
7295
|
+
allowedDomains: options?.allowedDomains
|
|
7189
7296
|
}
|
|
7190
7297
|
};
|
|
7191
7298
|
}
|
|
@@ -7194,7 +7301,7 @@ function hasConfiguredPluginCatalog(config) {
|
|
|
7194
7301
|
return Boolean(config.inlineManifests?.length || config.packages?.length || Object.keys(config.manifests ?? {}).length);
|
|
7195
7302
|
}
|
|
7196
7303
|
function warnUnregisteredConfigDefaults(defaults) {
|
|
7197
|
-
for (const key of Object.keys(defaults ?? {})) if (!
|
|
7304
|
+
for (const key of Object.keys(defaults ?? {})) if (!getAppContext().catalog.isConfigKey(key)) logWarn("config.default.unregistered", { "app.config.key": key });
|
|
7198
7305
|
}
|
|
7199
7306
|
function pluginPackageNames(config) {
|
|
7200
7307
|
return config?.packages ?? [];
|
|
@@ -7237,25 +7344,14 @@ async function createApp(options) {
|
|
|
7237
7344
|
validatePlugins(plugins);
|
|
7238
7345
|
getDb();
|
|
7239
7346
|
const shouldValidatePluginCatalog = hasConfiguredPluginCatalog(pluginConfig) || Boolean(configuredPlugins?.registrations.length) || Boolean(Object.keys(options?.configDefaults ?? {}).length);
|
|
7240
|
-
const
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
const previousEventEmbeddingsConfig = setEventEmbeddingsConfig(options?.eventEmbeddings);
|
|
7245
|
-
const previousMemoryConfig = setMemoryConfig(options?.memory);
|
|
7246
|
-
const previousDashboardLinkOptions = setDashboardConversationLinkOptions(dashboard);
|
|
7247
|
-
let previousTrustConfig;
|
|
7347
|
+
const previousAppContext = installAppContext(createAppContext({
|
|
7348
|
+
plugins,
|
|
7349
|
+
pluginConfig
|
|
7350
|
+
}));
|
|
7248
7351
|
let restoreChatConfig;
|
|
7249
7352
|
const restoreRuntimeConfig = () => {
|
|
7250
|
-
|
|
7251
|
-
pluginCatalogRuntime.setConfig(previousPluginCatalogConfig);
|
|
7252
|
-
setPlugins(previousPlugins);
|
|
7253
|
-
setConfigDefaults(previousConfigDefaults);
|
|
7353
|
+
installAppContext(previousAppContext);
|
|
7254
7354
|
restoreChatConfig?.();
|
|
7255
|
-
setExperimentalFeatures(previousExperimentalFeatures);
|
|
7256
|
-
setEventEmbeddingsConfig(previousEventEmbeddingsConfig);
|
|
7257
|
-
setMemoryConfig(previousMemoryConfig);
|
|
7258
|
-
setDashboardConversationLinkOptions(previousDashboardLinkOptions);
|
|
7259
7355
|
};
|
|
7260
7356
|
let pluginRoutes = [];
|
|
7261
7357
|
let pluginApiRoutes = [];
|
|
@@ -7269,25 +7365,19 @@ async function createApp(options) {
|
|
|
7269
7365
|
let dispatchForIdentity;
|
|
7270
7366
|
try {
|
|
7271
7367
|
sandboxEgressTracePropagationDomains = normalizeSandboxEgressTracePropagationDomains(options?.sandbox?.egressTracePropagationDomains);
|
|
7272
|
-
setExperimentalFeatures(options?.experimental);
|
|
7273
|
-
setConfigDefaults(options?.configDefaults);
|
|
7274
|
-
warnUnregisteredConfigDefaults(options?.configDefaults);
|
|
7275
7368
|
const previousChatConfig = installChatConfig(loadConfig({
|
|
7276
7369
|
env: process.env,
|
|
7277
7370
|
options: appConfigInput(options, virtualConfig)
|
|
7278
7371
|
}));
|
|
7279
7372
|
restoreChatConfig = () => installChatConfig(previousChatConfig);
|
|
7373
|
+
warnUnregisteredConfigDefaults(options?.configDefaults);
|
|
7280
7374
|
assertNoLegacyAllowedDomains(Object.keys(dashboard ?? {}));
|
|
7281
|
-
allowedDomains =
|
|
7282
|
-
previousTrustConfig = setTrustConfig({
|
|
7283
|
-
allowedBotUserIds: options?.slack?.allowedBotUserIds ?? [],
|
|
7284
|
-
allowedDomains
|
|
7285
|
-
});
|
|
7375
|
+
allowedDomains = getChatConfig().trust.allowedDomains;
|
|
7286
7376
|
if (allowedDomains.length === 0) logWarn("app.allowed_domains.unset", { "app.reason": "allowedDomains is empty, so any Slack workspace member can use the bot" });
|
|
7287
7377
|
dispatchForIdentity = createIdentityDispatcher({ conversationWorkQueue: () => conversationWorkQueue });
|
|
7288
7378
|
if (dashboard && !dashboard.disabled) signInConfig = resolveSignInAuthConfig(botConfig.userName, allowedDomains, dashboard);
|
|
7289
7379
|
if (shouldValidatePluginCatalog) {
|
|
7290
|
-
|
|
7380
|
+
getAppContext().catalog.getSignature();
|
|
7291
7381
|
validatePluginRegistrations(configuredPlugins?.registrations ?? []);
|
|
7292
7382
|
validatePluginEgressCredentialHooks(configuredPlugins?.registrations ?? []);
|
|
7293
7383
|
}
|
|
@@ -7483,7 +7573,7 @@ async function createApp(options) {
|
|
|
7483
7573
|
let pluginTaskPOST;
|
|
7484
7574
|
const chatConfig = getChatConfig();
|
|
7485
7575
|
const engineCtx = createEngineContext(chatConfig);
|
|
7486
|
-
const
|
|
7576
|
+
const turnEnds = turnEndedConsumer(engineCtx, createDeploymentDelivery({ getSlackAdapter: getProductionSlackAdapter }));
|
|
7487
7577
|
app.post(JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE, (c) => {
|
|
7488
7578
|
agentContinuePOST ??= createVercelConversationWorkCallback(getConversationWorkOptions());
|
|
7489
7579
|
return agentContinuePOST(c.req.raw);
|
|
@@ -7520,10 +7610,10 @@ async function createApp(options) {
|
|
|
7520
7610
|
}));
|
|
7521
7611
|
return turnStepPOST(c.req.raw);
|
|
7522
7612
|
});
|
|
7523
|
-
let
|
|
7524
|
-
app.post(
|
|
7525
|
-
|
|
7526
|
-
return
|
|
7613
|
+
let turnEndedPOST;
|
|
7614
|
+
app.post(JUNIOR_TURN_ENDED_CALLBACK_ROUTE, (c) => {
|
|
7615
|
+
turnEndedPOST ??= engineCtx.queue.createCallback(turnEnds);
|
|
7616
|
+
return turnEndedPOST(c.req.raw);
|
|
7527
7617
|
});
|
|
7528
7618
|
app.get("/api/internal/heartbeat", (c) => {
|
|
7529
7619
|
return GET$3(c.req.raw, waitUntil, {
|
|
@@ -7532,7 +7622,10 @@ async function createApp(options) {
|
|
|
7532
7622
|
events,
|
|
7533
7623
|
sendPluginTask,
|
|
7534
7624
|
showInboxItem: createInboxItemShow(getProductionSlackAdapter),
|
|
7535
|
-
sweepTurns: () =>
|
|
7625
|
+
sweepTurns: async () => {
|
|
7626
|
+
await sweepTurns(engineCtx);
|
|
7627
|
+
await sweepDeliveries(engineCtx);
|
|
7628
|
+
}
|
|
7536
7629
|
});
|
|
7537
7630
|
});
|
|
7538
7631
|
app.get("/api/internal/retention", (c) => {
|