@sentry/junior 0.306.0 → 0.307.1
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-context-CnY-i32r.js → adapter-context-HrBTD8rJ.js} +2 -2
- package/dist/{admin-BLLdLnXh.js → admin-B78_KmfR.js} +2 -2
- package/dist/{agent-runner-BaLjEjPR.js → agent-runner-DxivxUYd.js} +226 -137
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +4 -4
- package/dist/api.d.ts +1 -1
- package/dist/api.js +328 -298
- package/dist/{app-DvYbM9UD.d.ts → app-EZur8cVC.d.ts} +12 -3
- package/dist/app.d.ts +2 -2
- package/dist/app.js +84 -44
- package/dist/background-compaction-queue-HlljT9ql.js +231 -0
- package/dist/{briefs-DvyzXfrF.js → briefs-DR8mp-TK.js} +2 -2
- package/dist/{catalog-runtime-B1R-nHd3.js → catalog-runtime-Se9idiDR.js} +1 -1
- package/dist/cli/chat.d.ts +1 -1
- package/dist/cli/chat.js +17 -16
- package/dist/cli/check.js +58 -48
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.d.ts +1 -1
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +5 -5
- package/dist/cli/upgrade.d.ts +2 -2
- package/dist/cli/upgrade.js +3 -8
- package/dist/{config-DUD-zMvp.js → config-DY5c1E0l.js} +74 -38
- package/dist/{connections-CDhsqPcC.js → connections-C-SqzubG.js} +10 -8
- package/dist/{continue-in-slack-BXQizz9o.js → continue-in-slack-DNkrrWuQ.js} +5 -5
- package/dist/{conversation-privacy-YE54gMN8.js → conversation-privacy-CVj9vSrP.js} +1 -1
- package/dist/{conversation-turn-BzdmrHb0.js → conversation-turn-CkzrIfJ2.js} +19 -47
- package/dist/{credential-sync-Cdm-e1vJ.js → credential-sync-B9CIkgOT.js} +28 -28
- package/dist/{db-DV2ZUb1Y.js → db-C21CyyTE.js} +140 -11
- package/dist/{db-pH357Dkt.d.ts → db-C41UgdBj.d.ts} +1 -1
- package/dist/{executor-CjNhwwnj.js → executor-DfNoVVGd.js} +93 -32
- package/dist/{install-DbD7C5td.js → install-lYZs8UCL.js} +2 -2
- package/dist/instrumentation.js +2 -2
- package/dist/{lineage-BFdIPb3o.js → lineage-BJTSY53A.js} +2 -2
- package/dist/{logging-oYpJYr-S.js → logging-DjW7LjgJ.js} +1 -1
- package/dist/{message-BBPcMKJY.js → message-BPPZpdoZ.js} +8 -8
- package/dist/{model-input-DYYF3a8B.js → model-input-DKqiLFGa.js} +3 -3
- package/dist/nitro.d.ts +2 -2
- package/dist/nitro.js +12 -5
- package/dist/{oauth-callback-server-C7Q987su.js → oauth-callback-server-OJP8Y4Ca.js} +2 -2
- package/dist/{oauth-relay-DAmfVmJu.js → oauth-relay-KwDz41Z3.js} +1 -1
- package/dist/{plugins-B_0Cr0MO.d.ts → plugins-fBrz8PCV.d.ts} +2 -0
- package/dist/{projection-CWXDE0f6.js → projection-D47mlszd.js} +1112 -693
- package/dist/{prompt-P3eRqO8C.js → prompt-DuWH_YIb.js} +3 -3
- package/dist/{registry-1pzXmplY.js → registry-yht0oxq6.js} +19 -9
- package/dist/{resolve-n87oXY-d.js → resolve-gZ-hVMYl.js} +3 -3
- package/dist/{result-BmF9v9bv.js → result-CP99Ok0_.js} +13 -11
- package/dist/{runner-4j7ZsxP5.js → runner-eVlnUkY7.js} +9 -9
- package/dist/{sandbox-egress-signals-BRQI8HvT.js → sandbox-egress-signals-DZL_0lnG.js} +1 -1
- package/dist/{schedule-CHPWQn-x.js → schedule-BG1tEbRF.js} +34 -4
- package/dist/{schema-CVbIjrF3.d.ts → schema-CRXcj4fj.d.ts} +350 -143
- package/dist/{schema-D7iIEh6t.js → schema-D4jdesIu.js} +12 -4
- package/dist/{service-account-DzQiOmqa.js → service-account-CZneZHh7.js} +8 -6
- package/dist/{service-account-BDQ9xzta.js → service-account-tI3LBg2_.js} +3 -3
- package/dist/{session-stop-BQxgHR4X.js → session-stop-D3S7mSkX.js} +36 -23
- package/dist/{skills-CPf4vNuC.js → skills-Bm6uSO9V.js} +32 -28
- package/dist/{slack-conversation-unfurl-B1KEptUg.js → slack-conversation-unfurl-BeBvg3xU.js} +10 -10
- package/dist/{spawn-CjGddiAU.js → spawn-vhMAmLuh.js} +6 -6
- package/dist/{state-9wfj6aSD.js → state-3Yiy2FvP.js} +4 -4
- package/dist/{stop-CsQGuN5n.js → stop-Bh53GUoX.js} +146 -158
- package/dist/{store-Dz3YZ7gQ.js → store-BZJdHYR7.js} +5 -5
- package/dist/{background-compaction-queue-D2wzxtGU.js → task-queue-BEl5G38v.js} +164 -180
- package/dist/{task-runner-frzlUvFD.js → task-runner-C6Bujc6h.js} +11 -8
- package/dist/{thread-context-C4QuZlM8.js → thread-context-DxMQGGd_.js} +6 -6
- package/dist/{turn-session-routing-BXaubz2w.js → turn-session-routing-CmQY0T60.js} +24 -5
- package/dist/{turn-user-message-DNC0eRZ7.js → turn-user-message-Dfbr3Ud9.js} +3 -3
- package/dist/{users-XCCKn3xW.js → users-6rSdqXXk.js} +1 -1
- package/dist/{validation-L5fdjmFX.js → validation--hsjOLRL.js} +1 -1
- package/dist/{version-BFmuwgxP.js → version-9iMT25Hq.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-DKOeHpv3.js → viewer-De1vmuEA.js} +3 -3
- package/dist/{warmup-mTMIatCV.js → warmup-C0IblNtf.js} +596 -281
- package/dist/{web-message-id-CUaSiGme.js → web-message-id-BT8Mg8LL.js} +1 -1
- package/dist/{worker-Bz4KNxjI.js → worker-CiyRr2q7.js} +8 -7
- package/migrations/0115_automation_creator_slack_index.sql +1 -0
- package/migrations/0116_conversation_event_search.sql +25 -0
- package/migrations/0117_automation_last_run.sql +46 -0
- package/migrations/0118_automation_last_run_index.sql +1 -0
- package/migrations/0119_money_micro_usd.sql +29 -0
- package/migrations/0120_conversation_cost_micro_usd.sql +8 -0
- package/migrations/meta/0115_snapshot.json +5225 -0
- package/migrations/meta/0116_snapshot.json +5388 -0
- package/migrations/meta/0117_snapshot.json +5413 -0
- package/migrations/meta/0118_snapshot.json +5428 -0
- package/migrations/meta/0119_snapshot.json +5441 -0
- package/migrations/meta/0120_snapshot.json +5441 -0
- package/migrations/meta/_journal.json +42 -0
- package/package.json +10 -9
- package/dist/queue-7FSijgqG.js +0 -115
- package/dist/secrets-DHaJ5TTn.js +0 -18
- package/dist/task-queue-CFlrJguF.js +0 -89
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { $ as pauseLostWorkerTurn, $a as
|
|
2
|
-
import { F as textCharsForTokens, P as estimateTextTokens, V as escapeXml, c as getSlackClientSecret, i as getChatConfig, k as resolveGatewayModel, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, ot as isProviderRetryError, s as getSlackClientId, y as normalizeSlackEmojiName } from "./config-
|
|
3
|
-
import { E as withSpan, G as normalizeIdentityEmail, J as toOptionalString, K as isRecord, S as setTags, T as withLogContext, b as setSpanAttributes, f as logError, h as logWarn, m as logInfo, n as createChatSdkLogger, o as getActiveTraceContext, p as logException, q as toOptionalNumber, s as getActiveTraceId, t as buildTurnFailureResponse, y as setSentryUser } from "./logging-
|
|
1
|
+
import { $ as pauseLostWorkerTurn, $a as viewerMarksFromParticipant, $t as buildTurnErrorResponse, A as normalizeConversationText, As as streamPrivateSlackFile, B as PluginCredentialFailureError, Bo as lookupSlackUserNames, Br as takeReviewItem, Bt as releaseInboundMessage, Co as storeAttachment, Cs as getHeaderString, D as isHumanConversationMessage, Ds as isSlackRequestTimeout, E as getConversationMessageSlackTs, Es as isDmChannel, Fo as listConversationAnnotationsById, Fs as SLACK_USER_MENTION_RE, Ga as canAddConversationMessages, Hs as wrapBareSlackUserIds, Ir as listReplyActionItems, J as clearPendingAuth, Ja as conversationHasParticipantUser, Jo as getDispatchInputMessageId, Ka as createConversationAccessReader, Ko as getDispatchConversationId, Kr as canUserReadReviewItem, Lr as listWaitingConversations, M as trimConversationMessages, N as turnHasReply, Nn as getPlugins, O as latestConversationMessageSeq, Os as normalizeSlackConversationId, P as upsertConversationMessage, Po as listConversationAnnotations, Pr as getReviewItem, Q as lostWorkerBeforeFirstSave, Qa as conversationViewerMarks, Qo as isTerminalDispatchStatus, Qr as reviewItemNeedsSomeone, S as resolveConversationTitle, T as estimateConversationMessagesTokens, Ua as createPluginLogger, Uo as claimDispatchMailboxAppend, Ur as canActOnReviewItem, Us as truncateStatusText, Vs as slackMentionedUserIds, W as AuthorizationFlowDisabledError, Wo as confirmDispatchMailboxAppend, Xa as conversationIsNotUnsubscribedRoot, Xn as storedMessageJson, Xo as getDispatchTurnId, Ya as conversationIsMemberRoot, Yo as getDispatchRecord, Z as loadTurnCheckpoint, Za as conversationPinnedForUser, _o as slackAttachmentsVersionQuery, a as loadProjection, al as fallbackShortTitle, ao as readConversationEventPageAround, at as getTurnRecord, b as persistConversationMessages, bn as createUserTokenStore, bs as SlackActionError, cc as parseDashboardConversationLink, cn as getAssistantReplyText, co as buildSentryConversationUrl, d as recordAuthorizationCompleted, do as notInheritedByForkChild, ec as getDashboardConversationLink, es as markDispatchAwaitingResume, et as saveTurnCheckpoint, fl as configValueSchema, fo as getSlackFileId, fr as trimTrailingAssistantMessages, go as recordSlackAttachment, h as recordSubscribedReplyRoute, i as loadConversationProjection, io as readConversationEventPageAfter, is as markDispatchRunning, j as recordDeliveredAssistantMessage, js as withSlackRetries, k as markConversationMessage, kr as closeReviewItem, lc as parseDashboardPersonLink, ml as piMessageFromHistoryItem, mo as readAttachmentVisionSummary, n as commitMessages, nl as readAutomationTitlesByConversationId, no as readLatestConversationBrief, ns as markDispatchCompleted, nt as completeTurnRecord, o as loadTurnProjection, os as addReactionToMessage, ot as listTurnSummaries, pi as cancelSubscriptions, ps as removeReactionFromMessage, qa as readConversationAccessFromSql, qo as getDispatchIdForConversation, qr as isOnlyAssignee, ra as resolveBaseUrl, rc as getDashboardPersonLink, ro as readConversationEventPage, rs as markDispatchFailed, rt as failTurnRecord, sc as isDashboardLink, st as recordTurnSummary, t as commitAcceptedReply, tc as getDashboardLinkFilter, ts as markDispatchBlocked, tt as abandonTurnRecord, ul as createPluginCache, v as hydrateConversationMessages, vn as persistWithRetry, w as buildConversationContext, wn as applyPluginFormatMarkdown, ws as getSlackClient, xs as downloadPrivateSlackFile, y as persistConversationMessageWindow, yo as isFileAttachment, z as createPluginEgress, zo as lookupSlackUser, zs as normalizeSlackStatusText } from "./projection-D47mlszd.js";
|
|
2
|
+
import { F as textCharsForTokens, P as estimateTextTokens, V as escapeXml, c as getSlackClientSecret, i as getChatConfig, k as resolveGatewayModel, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, ot as isProviderRetryError, s as getSlackClientId, y as normalizeSlackEmojiName } from "./config-DY5c1E0l.js";
|
|
3
|
+
import { E as withSpan, G as normalizeIdentityEmail, J as toOptionalString, K as isRecord, S as setTags, T as withLogContext, b as setSpanAttributes, f as logError, h as logWarn, m as logInfo, n as createChatSdkLogger, o as getActiveTraceContext, p as logException, q as toOptionalNumber, s as getActiveTraceId, t as buildTurnFailureResponse, y as setSentryUser } from "./logging-DjW7LjgJ.js";
|
|
4
4
|
import { h as startSpan } from "./sentry-CPbZjomA.js";
|
|
5
|
-
import { t as JUNIOR_VERSION } from "./version-
|
|
5
|
+
import { t as JUNIOR_VERSION } from "./version-9iMT25Hq.js";
|
|
6
6
|
import { f as parseSlackTeamId, i as isActorUserId, n as createSlackActor, o as isUserActor, r as createSlackResumeActor, s as parseActorUserId, t as createActor, u as parseSlackChannelId, v as parseSlackMessageTs } from "./actor-D2iXzvlN.js";
|
|
7
|
-
import { $ as getStateAdapter, A as conversationKindFromRow, D as postsRunNotices, E as isTopLevelKind, I as resolveActorIdentityId, L as saveActorAvatar, X as createCache, Y as readCachedUserByEmail, _ as readConversationTrees,
|
|
8
|
-
import { A as
|
|
7
|
+
import { $ as getStateAdapter, A as conversationKindFromRow, D as postsRunNotices, E as isTopLevelKind, Et as createSlackDestination, I as resolveActorIdentityId, L as saveActorAvatar, Ot as requireSlackDestination, X as createCache, Y as readCachedUserByEmail, _ as readConversationTrees, a as getConversationStore, b as lastMessageAtSql, bt as hasAgentTurnUsage, ct as parseSessionSource, et as getStateValues, f as copyMessageLinks, gt as addAgentTurnUsage, h as conversationAncestors, j as locationFromRow, k as turnBehavior, m as withConversationEventLock, o as getDb, r as getConversationEventStore, rt as acquireActiveLock, s as getSqlExecutor, tt as setStateValues, v as setArchivedAt, w as deliversFinalText, wt as nextDetailVersion, xt as resolveRootConversationId, y as loadConversationSlackTenantIds, yt as agentTurnUsageSchema } from "./db-C21CyyTE.js";
|
|
8
|
+
import { A as juniorConversationEvents, B as juniorUsers, E as juniorConversationBriefs, I as juniorAttachments, L as juniorMessageAttachments, M as juniorConversationAnnotations, N as juniorCodeChanges, R as juniorConversations, V as juniorDestinations, f as juniorReviewItems, n as isPostgresErrorCode, u as juniorReviewItemConversations, x as juniorConversationParticipants, y as juniorAgentInvocations, z as juniorIdentities } from "./executor-DfNoVVGd.js";
|
|
9
9
|
import { d as contextProvenance, p as instructionProvenanceFor, t as KNOWN_CONVERSATION_EVENT_TYPES } from "./history-N7IVbUom.js";
|
|
10
|
-
import {
|
|
11
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
12
|
-
import {
|
|
13
|
-
import { d as PluginMcpClient, u as McpAuthorizationRequiredError, v as getMcpStoredOAuthCredentials } from "./service-account-
|
|
14
|
-
import { i as webActorUserIds } from "./state-
|
|
15
|
-
import { a as EVENT_SYSTEM_ACTOR, d as completeText, l as completeDecision, s as isEventConversationMessage } from "./prompt-
|
|
10
|
+
import { f as actorLogContext, p as credentialContextForActor } from "./registry-yht0oxq6.js";
|
|
11
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-Se9idiDR.js";
|
|
12
|
+
import { B as shouldEmitDevAgentTrace, D as canPauseConversationDelivery, L as finalizeFailedTurnReplyWithEvent, P as RetryableDeliveryError, R as getAgentTurnDiagnosticsAttributes, T as safeLinkUrl, _ as createSlackReviewItemShow, a as buildAuthPauseResponse, c as createClientMetadata, l as readMcpClientInformation, m as resolveDestinationVisibility, n as executeAgentRun, s as getMcpOAuthCallbackPath, t as createAgentRunner, u as latestProgressStatus, z as requireTurnFailureEventId } from "./agent-runner-DxivxUYd.js";
|
|
13
|
+
import { d as PluginMcpClient, u as McpAuthorizationRequiredError, v as getMcpStoredOAuthCredentials } from "./service-account-CZneZHh7.js";
|
|
14
|
+
import { i as webActorUserIds } from "./state-3Yiy2FvP.js";
|
|
15
|
+
import { a as EVENT_SYSTEM_ACTOR, d as completeText, l as completeDecision, s as isEventConversationMessage } from "./prompt-DuWH_YIb.js";
|
|
16
16
|
import { Z as MAX_ATTACHMENT_BYTES, f as conversationEventPageSchema, tt as readMessageAttachments, u as conversationDetailReportSchema } from "./conversation--f85g4zL.js";
|
|
17
|
-
import { f as identityAvatarUrl, g as userAvatarUrlsFromIdentities, h as readUserAvatarUrls } from "./viewer-
|
|
18
|
-
import {
|
|
19
|
-
import { P as legacyWebMailboxMetadataSchema, Q as maybePostAutomatedTurnLimitNotice, c as loadReviewItemInput, et as resolveSlackReplyTarget, f as buildSteeringPiMessage, ft as isExperimentalFeatureEnabled, g as withoutSavedSteeringMessages, j as resolveMailboxTurnWork, l as savedInputInstruction, lt as conversationSubtree, o as skipInputAfterConversationStop, p as instructionActorFor, r as markConversationsStopped, st as recordFinishedTurnForAutomatedLimit, tt as sendSlackReply, ut as conversationSubtreeColumns } from "./session-stop-
|
|
20
|
-
import { Ai as
|
|
21
|
-
import { h as isVisionImageMediaType, l as isEmptyUserInputAnswer, m as detectImageMediaType, t as webMessageId, u as normalizeUserInputAnswer } from "./web-message-id-
|
|
22
|
-
import { L as buildDeterministicAssistantMessageId, R as buildDeterministicTurnId, a as ConversationTurnBoundaryError, c as TurnInputDeferredError, d as isTurnInputCommitLostError, f as isTurnInputDeferredError, g as startActiveTurn, h as markTurnFailed, i as getTurnUserSlackMessageTs, l as getConversationTurnBoundaryError, m as markTurnCompleted, o as CooperativeTurnYieldError, p as markTurnClosed, r as getTurnUserReplyAttachmentContext, s as TurnInputCommitLostError, t as getTurnUserMessage, u as isCooperativeTurnYieldError, v as getTurnLifecycle } from "./turn-user-message-
|
|
23
|
-
import {
|
|
24
|
-
import { D as stopConversationWork, E as steerWebPendingMessages, _ as getConversationWorkState, a as cancelHumanFacingPendingMessages, g as getConversation, h as ensureConversationWake, r as appendAndEnqueueInboundMessage, s as claimInboundMessage } from "./store-
|
|
25
|
-
import { a as getPersistedThreadState, c as coerceThreadConversationState, i as getPersistedSandboxState, n as
|
|
26
|
-
import { t as runWithSlackInstallation } from "./adapter-context-
|
|
17
|
+
import { f as identityAvatarUrl, g as userAvatarUrlsFromIdentities, h as readUserAvatarUrls } from "./viewer-De1vmuEA.js";
|
|
18
|
+
import { d as readJuniorSecret, g as getTurnRequestDeadline, s as sendVercelPluginTask } from "./task-queue-BEl5G38v.js";
|
|
19
|
+
import { P as legacyWebMailboxMetadataSchema, Q as maybePostAutomatedTurnLimitNotice, c as loadReviewItemInput, et as resolveSlackReplyTarget, f as buildSteeringPiMessage, ft as isExperimentalFeatureEnabled, g as withoutSavedSteeringMessages, j as resolveMailboxTurnWork, l as savedInputInstruction, lt as conversationSubtree, o as skipInputAfterConversationStop, p as instructionActorFor, r as markConversationsStopped, st as recordFinishedTurnForAutomatedLimit, tt as sendSlackReply, ut as conversationSubtreeColumns } from "./session-stop-D3S7mSkX.js";
|
|
20
|
+
import { Ai as MINUTE_MS, An as recordFailedDispatchTurn, At as verifyAttachmentUploads, Bn as getWebAuthorization, Ct as createConversationId, Dn as supersedeTurnForInput, Dt as AttachmentUploadError, Fn as canShareTurn, Hn as executeTurn, Ht as getChildAgentLabel, Mi as NO_REPLY_GAP_MS, Ni as gapSegment, Nn as getTurnAuthorization, On as createPausedTurns, Pn as canJoinTurn, St as createAndEnqueueConversation, Tt as webActorFromUser, Vn as AgentRunError, Xn as renderBlockText, Yn as renderAttachmentText, Zn as parseSlackMessageReference, _r as isPublicSlackChannel, bt as appendAndEnqueueWebMessage, c as isConversationWorkDone, cr as resolveSlackChannelIdFromMessage, ct as readLastUserMessageAtByConversation, d as addHistoryPeriod, f as firstLiveSavingsDate, fn as dropOwnUnreadLoopReplies, gr as isConversationMember, gt as deliverReviewItemChange, hn as cancelSignInWait, hr as getConversationInfo, i as GLOBAL_GAPS_TTL_MS, kn as getPausedTurnRequest, l as listConversationWork, li as readConversationSourceTask, m as replaceHistorySavings, mn as stopChildAgentsOf, mr as getChannelMessage, n as CONVERSATION_STATE_TTL_MS, o as segmentGapsKey, or as parseSlackThreadId, p as idlePeriodSavings, pn as stopChildAgentsBelow, qn as throwApiError, r as GLOBAL_GAPS_MAX, sr as readSlackRawMessageContext, t as ANSWER_TOOL_ENDINGS, ut as conversationReadPositionQuery, v as connectedState, wt as recordWebConversationActivity, y as providerCacheTtlMs, yr as listThreadReplies, yt as acceptsWebMessages } from "./warmup-C0IblNtf.js";
|
|
21
|
+
import { h as isVisionImageMediaType, l as isEmptyUserInputAnswer, m as detectImageMediaType, t as webMessageId, u as normalizeUserInputAnswer } from "./web-message-id-BT8Mg8LL.js";
|
|
22
|
+
import { L as buildDeterministicAssistantMessageId, R as buildDeterministicTurnId, a as ConversationTurnBoundaryError, c as TurnInputDeferredError, d as isTurnInputCommitLostError, f as isTurnInputDeferredError, g as startActiveTurn, h as markTurnFailed, i as getTurnUserSlackMessageTs, l as getConversationTurnBoundaryError, m as markTurnCompleted, o as CooperativeTurnYieldError, p as markTurnClosed, r as getTurnUserReplyAttachmentContext, s as TurnInputCommitLostError, t as getTurnUserMessage, u as isCooperativeTurnYieldError, v as getTurnLifecycle } from "./turn-user-message-Dfbr3Ud9.js";
|
|
23
|
+
import { m as getVercelConversationWorkQueue } from "./background-compaction-queue-HlljT9ql.js";
|
|
24
|
+
import { D as stopConversationWork, E as steerWebPendingMessages, _ as getConversationWorkState, a as cancelHumanFacingPendingMessages, g as getConversation, h as ensureConversationWake, r as appendAndEnqueueInboundMessage, s as claimInboundMessage } from "./store-BZJdHYR7.js";
|
|
25
|
+
import { a as getPersistedThreadState, c as coerceThreadConversationState, i as getPersistedSandboxState, n as resolveTurnResumeRouting, o as persistThreadRuntimeState, r as getLocationConfigurationService, s as persistThreadStateById, t as resolveConversationRouting } from "./turn-session-routing-CmQY0T60.js";
|
|
26
|
+
import { t as runWithSlackInstallation } from "./adapter-context-HrBTD8rJ.js";
|
|
27
27
|
import { D as personObjectCard, E as messageObjectCard, O as webPageObjectCard, T as conversationObjectCard, m as healthReportSchema, r as conversationFeedSchema, t as conversationFeedBriefSchema, u as conversationPendingMessagesReportSchema } from "./conversation-feed-BNs9KiqC.js";
|
|
28
|
-
import {
|
|
29
|
-
import { n as buildStoredAttachmentPromptText } from "./model-input-
|
|
30
|
-
import { i as enqueueAgentInvocationResult, n as createDeliverToParent, s as withAgentInvocationResultActors, t as createChildConversationWorker } from "./result-
|
|
31
|
-
import { t as bindMessageAgent } from "./message-
|
|
32
|
-
import { t as readConversationLineage } from "./lineage-
|
|
33
|
-
import { t as bindSpawnAgent } from "./spawn-
|
|
34
|
-
import { a as buildDeliveredTurnStatePatch, i as persistAuthPauseTurnState, n as loadThreadContextTrimFloor, o as loadPendingMessageCards, r as completeAuthPauseTurn, t as buildTurnThreadContext } from "./thread-context-
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import
|
|
28
|
+
import { a as withTurnSpan, i as turnInputTelemetry, n as createConversationTurnWorker, r as getTurnInputSpanAttributes } from "./conversation-turn-CkzrIfJ2.js";
|
|
29
|
+
import { n as buildStoredAttachmentPromptText } from "./model-input-DKqiLFGa.js";
|
|
30
|
+
import { i as enqueueAgentInvocationResult, n as createDeliverToParent, s as withAgentInvocationResultActors, t as createChildConversationWorker } from "./result-CP99Ok0_.js";
|
|
31
|
+
import { t as bindMessageAgent } from "./message-BPPZpdoZ.js";
|
|
32
|
+
import { t as readConversationLineage } from "./lineage-BJTSY53A.js";
|
|
33
|
+
import { t as bindSpawnAgent } from "./spawn-vhMAmLuh.js";
|
|
34
|
+
import { a as buildDeliveredTurnStatePatch, i as persistAuthPauseTurnState, n as loadThreadContextTrimFloor, o as loadPendingMessageCards, r as completeAuthPauseTurn, t as buildTurnThreadContext } from "./thread-context-DxMQGGd_.js";
|
|
35
|
+
import { n as scheduleSessionCompletedPluginTasks } from "./task-runner-C6Bujc6h.js";
|
|
36
|
+
import { r as canContinueInSlack } from "./continue-in-slack-DNkrrWuQ.js";
|
|
37
|
+
import pLimit from "p-limit";
|
|
38
38
|
import * as z from "zod";
|
|
39
39
|
import { createHash, createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
40
40
|
import { and, asc, count, desc, eq, gt, gte, inArray, isNotNull, isNull, lte, ne, not, or, sql } from "drizzle-orm";
|
|
@@ -1685,17 +1685,17 @@ function createSlackTurnRuntime(deps) {
|
|
|
1685
1685
|
await args.ack?.();
|
|
1686
1686
|
};
|
|
1687
1687
|
const selectAcceptedSteeringMessages = async (args) => {
|
|
1688
|
-
const
|
|
1689
|
-
|
|
1688
|
+
const limit = pLimit(8);
|
|
1689
|
+
const selected = await Promise.all(args.messages.map((candidate) => limit(async () => {
|
|
1690
1690
|
const decision = await decideSteeringMessage(args.thread, candidate, args.conversationContext, args.conversationId);
|
|
1691
|
-
|
|
1691
|
+
return {
|
|
1692
1692
|
context: decision.context,
|
|
1693
1693
|
decision: decision.decision,
|
|
1694
1694
|
inboundMessageId: candidate.inboundMessageId,
|
|
1695
1695
|
message: candidate.message,
|
|
1696
1696
|
text: decision.text
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1697
|
+
};
|
|
1698
|
+
})));
|
|
1699
1699
|
if (selected.some((message) => message.decision.shouldUnsubscribe)) return {
|
|
1700
1700
|
accepted: [],
|
|
1701
1701
|
skipped: selected.map((message) => message.decision.shouldReply ? {
|
|
@@ -3544,7 +3544,8 @@ function createSlackTurn(deps) {
|
|
|
3544
3544
|
};
|
|
3545
3545
|
let activeTurnId = preparedState.conversation.processing.activeTurnId;
|
|
3546
3546
|
const resolveSteeringMessages = async (queuedMessages) => {
|
|
3547
|
-
|
|
3547
|
+
const limit = pLimit(8);
|
|
3548
|
+
return await Promise.all(queuedMessages.map((queued) => limit(async () => {
|
|
3548
3549
|
const attachments = queued.message.attachments;
|
|
3549
3550
|
const reviewItemInput = await loadReviewItemInput(getMessageReviewItemChange(queued.message));
|
|
3550
3551
|
return {
|
|
@@ -3564,7 +3565,7 @@ function createSlackTurn(deps) {
|
|
|
3564
3565
|
messageTs: getMessageTimestamp(queued.message)
|
|
3565
3566
|
})
|
|
3566
3567
|
};
|
|
3567
|
-
}));
|
|
3568
|
+
})));
|
|
3568
3569
|
};
|
|
3569
3570
|
/** Save new messages before completing the mailbox delivery. */
|
|
3570
3571
|
const saveMessagesForPausedTurn = async (pausedTurnId) => {
|
|
@@ -4620,17 +4621,17 @@ async function readDispatchTurnResult(dispatch) {
|
|
|
4620
4621
|
outcome: "completed",
|
|
4621
4622
|
resultMessageTs
|
|
4622
4623
|
};
|
|
4623
|
-
if (!session) return {};
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
outcome: "
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
}
|
|
4624
|
+
if (!session) return { outcome: "not_started" };
|
|
4625
|
+
switch (session.state) {
|
|
4626
|
+
case "paused": return { outcome: "awaiting_resume" };
|
|
4627
|
+
case "running": return { outcome: "still_running" };
|
|
4628
|
+
case "completed": return { outcome: "completed" };
|
|
4629
|
+
case "abandoned":
|
|
4630
|
+
case "failed": return {
|
|
4631
|
+
...errorMessage ? { errorMessage } : void 0,
|
|
4632
|
+
outcome: "retryable"
|
|
4633
|
+
};
|
|
4634
|
+
}
|
|
4634
4635
|
}
|
|
4635
4636
|
async function projectDispatchTurnResult(dispatchId, result) {
|
|
4636
4637
|
switch (result.outcome) {
|
|
@@ -4646,7 +4647,7 @@ async function projectDispatchTurnResult(dispatchId, result) {
|
|
|
4646
4647
|
case "completed":
|
|
4647
4648
|
await markDispatchCompleted(dispatchId, result.resultMessageTs);
|
|
4648
4649
|
break;
|
|
4649
|
-
case
|
|
4650
|
+
case "not_started": await markDispatchFailed(dispatchId, "Dispatch turn record is missing");
|
|
4650
4651
|
}
|
|
4651
4652
|
}
|
|
4652
4653
|
function getDispatchBlockingError(error) {
|
|
@@ -4714,7 +4715,7 @@ function createAgentDispatchConversationWorker(options) {
|
|
|
4714
4715
|
return { status: "completed" };
|
|
4715
4716
|
}
|
|
4716
4717
|
try {
|
|
4717
|
-
const resumesDurableTurn = durableResult.
|
|
4718
|
+
const resumesDurableTurn = durableResult.outcome === "awaiting_resume" || durableResult.outcome === "still_running";
|
|
4718
4719
|
if (resumesDurableTurn && context.attempt.messages.length > 0) await acknowledge();
|
|
4719
4720
|
let result;
|
|
4720
4721
|
if (resumesDurableTurn) {
|
|
@@ -4723,20 +4724,15 @@ function createAgentDispatchConversationWorker(options) {
|
|
|
4723
4724
|
checkIn: context.checkIn
|
|
4724
4725
|
});
|
|
4725
4726
|
result = await readDispatchTurnResult(dispatch);
|
|
4726
|
-
} else {
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
...runtimeResult,
|
|
4734
|
-
...await readDispatchTurnResult(dispatch)
|
|
4735
|
-
};
|
|
4736
|
-
}
|
|
4737
|
-
if (!result.outcome) throw new Error(`Dispatch turn ${dispatch.id} returned without a durable outcome`);
|
|
4727
|
+
} else result = await options.runTurn(dispatch, {
|
|
4728
|
+
ack: acknowledge,
|
|
4729
|
+
shouldYield: context.shouldYield,
|
|
4730
|
+
checkIn: context.checkIn
|
|
4731
|
+
}) ?? await readDispatchTurnResult(dispatch);
|
|
4732
|
+
if (result.outcome === "still_running") throw new Error(`Dispatch turn ${dispatch.id} is still running after its attempt`);
|
|
4733
|
+
if (result.outcome === "retryable") throw new Error(result.errorMessage ?? `Dispatch turn ${dispatch.id} failed`);
|
|
4738
4734
|
await projectDispatchTurnResult(dispatch.id, result);
|
|
4739
|
-
if (
|
|
4735
|
+
if (!acknowledged) await acknowledge();
|
|
4740
4736
|
return result.outcome === "awaiting_resume" && context.shouldYield() ? { status: "yielded" } : { status: "completed" };
|
|
4741
4737
|
} catch (error) {
|
|
4742
4738
|
if (isCooperativeTurnYieldError(error)) {
|
|
@@ -4823,7 +4819,6 @@ function createSlackDispatchTurnRunner(options) {
|
|
|
4823
4819
|
isSubscribedContext: true
|
|
4824
4820
|
});
|
|
4825
4821
|
let outcome;
|
|
4826
|
-
let errorMessage;
|
|
4827
4822
|
let resultMessageTs;
|
|
4828
4823
|
const routing = buildDispatchRoutingContext(dispatch);
|
|
4829
4824
|
await options.executeSlackTurn(thread, message, {
|
|
@@ -4844,18 +4839,17 @@ function createSlackDispatchTurnRunner(options) {
|
|
|
4844
4839
|
resultMessageTs = messageId;
|
|
4845
4840
|
},
|
|
4846
4841
|
onTurnOutcome: (result) => {
|
|
4847
|
-
outcome = result
|
|
4848
|
-
errorMessage = result.errorMessage;
|
|
4842
|
+
outcome = result;
|
|
4849
4843
|
},
|
|
4850
4844
|
shouldYield: hooks.shouldYield,
|
|
4851
4845
|
checkIn: hooks.checkIn,
|
|
4852
4846
|
skipBackfill: true
|
|
4853
4847
|
});
|
|
4854
|
-
return {
|
|
4855
|
-
...
|
|
4856
|
-
|
|
4857
|
-
...resultMessageTs ? { resultMessageTs } : void 0
|
|
4848
|
+
if (resultMessageTs && (outcome?.outcome === "blocked" || outcome?.outcome === "completed" || outcome?.outcome === "failed")) return {
|
|
4849
|
+
...outcome,
|
|
4850
|
+
resultMessageTs
|
|
4858
4851
|
};
|
|
4852
|
+
return outcome;
|
|
4859
4853
|
};
|
|
4860
4854
|
}
|
|
4861
4855
|
// src/chat/app/factory.ts
|
|
@@ -4975,7 +4969,6 @@ function createJuniorSlackAdapter(config) {
|
|
|
4975
4969
|
return createSlackAdapter(config);
|
|
4976
4970
|
}
|
|
4977
4971
|
// src/chat/ingress/message-router.ts
|
|
4978
|
-
/** Derive canonical Slack thread IDs from the raw event payload. */
|
|
4979
4972
|
/** Rebuild a Message onto a normalized Slack thread id. */
|
|
4980
4973
|
function withNormalizedThreadId(message, threadId) {
|
|
4981
4974
|
if (message.threadId === threadId) return message;
|
|
@@ -4992,6 +4985,7 @@ function withNormalizedThreadId(message, threadId) {
|
|
|
4992
4985
|
threadId
|
|
4993
4986
|
});
|
|
4994
4987
|
}
|
|
4988
|
+
/** Derive canonical Slack thread IDs from the raw event payload. */
|
|
4995
4989
|
function normalizeIncomingSlackThreadId(threadId, message) {
|
|
4996
4990
|
if (!threadId.startsWith("slack:")) return threadId;
|
|
4997
4991
|
if (!message || typeof message !== "object") return threadId;
|
|
@@ -5015,6 +5009,7 @@ function rehydrateAttachmentFetchers(message) {
|
|
|
5015
5009
|
for (const attachment of message.attachments) if (!attachment.fetchData && attachment.url) attachment.fetchData = () => downloadPrivateSlackFile(attachment.url);
|
|
5016
5010
|
}
|
|
5017
5011
|
// src/chat/task-execution/slack-work.ts
|
|
5012
|
+
const SLACK_AUTHOR_LOOKUP_CONCURRENCY = 5;
|
|
5018
5013
|
const slackConversationRouteSchema = z.enum(["mention", "subscribed"]);
|
|
5019
5014
|
function hasSteeringOverride(text) {
|
|
5020
5015
|
return stripLeadingSteeringOverride(text) !== text;
|
|
@@ -5300,14 +5295,15 @@ async function bindSlackActorIdentities(args) {
|
|
|
5300
5295
|
const authorId = requireSlackAuthorId(message);
|
|
5301
5296
|
byAuthorId.set(authorId, [...byAuthorId.get(authorId) ?? [], message]);
|
|
5302
5297
|
}
|
|
5303
|
-
|
|
5298
|
+
const limit = pLimit(SLACK_AUTHOR_LOOKUP_CONCURRENCY);
|
|
5299
|
+
await Promise.all([...byAuthorId].map(([authorId, messages]) => limit(async () => {
|
|
5304
5300
|
const profile = await lookupSlackUser(args.teamId, authorId);
|
|
5305
5301
|
await Promise.all(messages.map((message) => ensureSlackMessageActorIdentity(message, args.teamId, async () => profile)));
|
|
5306
5302
|
if (profile && messages.some(getMessageAuthorIdentityId)) await resolveActorIdentityId(getSqlExecutor(), createSlackActor(args.teamId, authorId, {
|
|
5307
5303
|
fullName: profile.fullName,
|
|
5308
5304
|
userName: profile.userName
|
|
5309
5305
|
}));
|
|
5310
|
-
}));
|
|
5306
|
+
})));
|
|
5311
5307
|
}
|
|
5312
5308
|
function restoreThread(args) {
|
|
5313
5309
|
const threadId = normalizeIncomingSlackThreadId(args.threadJson.id, args.message);
|
|
@@ -6196,25 +6192,7 @@ async function failPausedTurn(args) {
|
|
|
6196
6192
|
errorMessage: args.errorMessage
|
|
6197
6193
|
});
|
|
6198
6194
|
if (!failed) return;
|
|
6199
|
-
|
|
6200
|
-
const routing = await resolveTurnSessionRouting({ conversationId: args.conversationId });
|
|
6201
|
-
await recordTurnSummary({
|
|
6202
|
-
conversationId: args.conversationId,
|
|
6203
|
-
destination: routing.destination,
|
|
6204
|
-
dispatchId: failed.dispatchId,
|
|
6205
|
-
dispatchOutcome: "failed",
|
|
6206
|
-
turnId: failed.turnId,
|
|
6207
|
-
sliceId: failed.sliceId,
|
|
6208
|
-
source: routing.source,
|
|
6209
|
-
state: "failed",
|
|
6210
|
-
surface: failed.surface
|
|
6211
|
-
});
|
|
6212
|
-
} catch (error) {
|
|
6213
|
-
logException(error, "agent.continue.dispatch_failure_summary.failed", {
|
|
6214
|
-
"app.ai.conversation_id": args.conversationId,
|
|
6215
|
-
"app.ai.session_id": args.summary.turnId
|
|
6216
|
-
});
|
|
6217
|
-
}
|
|
6195
|
+
await recordFailedDispatchTurn(failed);
|
|
6218
6196
|
}
|
|
6219
6197
|
/**
|
|
6220
6198
|
* Continue one paused Slack agent run from durable conversation state.
|
|
@@ -6312,7 +6290,10 @@ async function runPausedTurnInContext(payload, options, runOptions) {
|
|
|
6312
6290
|
}
|
|
6313
6291
|
const locationConfiguration = getLocationConfigurationService(destination);
|
|
6314
6292
|
const sandboxRef = getPersistedSandboxState(currentState);
|
|
6315
|
-
const routing = await
|
|
6293
|
+
const routing = await resolveTurnResumeRouting({
|
|
6294
|
+
conversationId: payload.conversationId,
|
|
6295
|
+
dispatchId
|
|
6296
|
+
});
|
|
6316
6297
|
const source = routing.source;
|
|
6317
6298
|
const routingDestination = routing.destination;
|
|
6318
6299
|
const turnMessages = activeTurn.turnStartMessageIndex === void 0 ? [] : activeTurn.piMessages.slice(activeTurn.turnStartMessageIndex);
|
|
@@ -6482,7 +6463,10 @@ async function failStrandedTurnWithFallback(args) {
|
|
|
6482
6463
|
}
|
|
6483
6464
|
let routing;
|
|
6484
6465
|
try {
|
|
6485
|
-
routing = await
|
|
6466
|
+
routing = await resolveTurnResumeRouting({
|
|
6467
|
+
conversationId: args.conversationId,
|
|
6468
|
+
dispatchId: failed.dispatchId
|
|
6469
|
+
});
|
|
6486
6470
|
} catch (error) {
|
|
6487
6471
|
logException(error, "agent.turn.stranded_session.routing_unavailable", {
|
|
6488
6472
|
"app.ai.conversation_id": args.conversationId,
|
|
@@ -6896,6 +6880,11 @@ async function resolveSlackTeamDomains(teamIds) {
|
|
|
6896
6880
|
return new Map(resolved.filter((entry) => entry !== void 0));
|
|
6897
6881
|
}
|
|
6898
6882
|
// src/api/objects/slack-message.ts
|
|
6883
|
+
/**
|
|
6884
|
+
* Slack message permalinks as cards. Junior has no Slack token of the
|
|
6885
|
+
* viewer, so the bot reads the message, and the card shows only what the
|
|
6886
|
+
* viewer's own linked Slack account can see in that workspace.
|
|
6887
|
+
*/
|
|
6899
6888
|
/** Slack permalinks, such as `acme.slack.com/archives/C123/p1712345000000100`. */
|
|
6900
6889
|
const SLACK_MESSAGE_LINK_FILTER = {
|
|
6901
6890
|
host: "*.slack.com",
|
|
@@ -6960,32 +6949,37 @@ async function readMessageCard(args) {
|
|
|
6960
6949
|
async function resolveSlackMessageLink(viewer, url) {
|
|
6961
6950
|
const parsed = parseSlackMessageReference(url.href);
|
|
6962
6951
|
if (!parsed.ok) return void 0;
|
|
6963
|
-
|
|
6952
|
+
const limit = pLimit(8);
|
|
6953
|
+
const workspace = (await Promise.all(viewer.identities.map(async (identity) => {
|
|
6964
6954
|
const teamId = parseSlackTeamId(identity.providerTenantId);
|
|
6965
|
-
if (identity.provider !== "slack" || !teamId)
|
|
6955
|
+
if (identity.provider !== "slack" || !teamId) return void 0;
|
|
6966
6956
|
const run = (task) => runWithSlackInstallation({
|
|
6967
6957
|
adapter: getProductionSlackAdapter(),
|
|
6968
6958
|
installation: { teamId },
|
|
6969
6959
|
task
|
|
6970
6960
|
});
|
|
6971
|
-
let domain;
|
|
6972
6961
|
try {
|
|
6973
|
-
|
|
6962
|
+
return {
|
|
6963
|
+
domain: await limit(() => run(() => resolveSlackTeamDomain(teamId))),
|
|
6964
|
+
identity,
|
|
6965
|
+
run,
|
|
6966
|
+
teamId
|
|
6967
|
+
};
|
|
6974
6968
|
} catch (error) {
|
|
6975
6969
|
logWarn("object_link.slack_team.unavailable", {
|
|
6976
6970
|
"app.slack.team_id": teamId,
|
|
6977
6971
|
"exception.message": error instanceof Error ? error.message : String(error)
|
|
6978
6972
|
});
|
|
6979
|
-
|
|
6973
|
+
return;
|
|
6980
6974
|
}
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
}
|
|
6975
|
+
}))).find((candidate) => candidate?.domain && url.hostname === `${candidate.domain}.slack.com`);
|
|
6976
|
+
if (!workspace) return void 0;
|
|
6977
|
+
return await workspace.run(() => readMessageCard({
|
|
6978
|
+
reference: parsed.reference,
|
|
6979
|
+
slackUserId: workspace.identity.providerSubjectId,
|
|
6980
|
+
teamId: workspace.teamId,
|
|
6981
|
+
url
|
|
6982
|
+
}));
|
|
6989
6983
|
}
|
|
6990
6984
|
// src/net/public-address.ts
|
|
6991
6985
|
/**
|
|
@@ -7669,7 +7663,8 @@ async function resolveObjectLinkNow(viewer, url) {
|
|
|
7669
7663
|
async function resolveObjectLinks(viewer, urls) {
|
|
7670
7664
|
const linkTypes = readObjectLinkTypes();
|
|
7671
7665
|
const cache = createCache(getStateAdapter(), "object-links");
|
|
7672
|
-
|
|
7666
|
+
const limit = pLimit(8);
|
|
7667
|
+
return (await Promise.all([...new Set(urls)].map((url) => limit(async () => {
|
|
7673
7668
|
const parsed = URL.canParse(url) ? new URL(url) : void 0;
|
|
7674
7669
|
const linkType = parsed && findObjectLinkType(linkTypes, parsed);
|
|
7675
7670
|
if (!parsed || !linkType) return [];
|
|
@@ -7688,7 +7683,7 @@ async function resolveObjectLinks(viewer, urls) {
|
|
|
7688
7683
|
logException(error, "object_link.resolve.failed", { "app.plugin.name": linkType.owner });
|
|
7689
7684
|
return [];
|
|
7690
7685
|
}
|
|
7691
|
-
}))).flat();
|
|
7686
|
+
})))).flat();
|
|
7692
7687
|
}
|
|
7693
7688
|
// src/handlers/health.ts
|
|
7694
7689
|
/** Build Junior's process health value for HTTP and reporting consumers. */
|
|
@@ -7736,9 +7731,6 @@ const BACKFILL_DONE_TTL_MS = GLOBAL_GAPS_TTL_MS;
|
|
|
7736
7731
|
const CONVERSATION_BATCH_SIZE = 10;
|
|
7737
7732
|
const CONVERSATION_PAGE_SIZE = 500;
|
|
7738
7733
|
const QUERY_CANCELED = "57014";
|
|
7739
|
-
const NUL_ESCAPE = String.raw`\u0000`;
|
|
7740
|
-
const NUL_ESCAPE_PATTERN = String.raw`(?<!\\)((?:\\\\)*)\\u0000`;
|
|
7741
|
-
const NUL_ESCAPE_REPLACEMENT = String.raw`\1`;
|
|
7742
7734
|
/**
|
|
7743
7735
|
* Scan time of one backfill run. The heartbeat gives no deadline. This leaves
|
|
7744
7736
|
* most of its function time for the writes and the other heartbeat work.
|
|
@@ -7785,8 +7777,7 @@ async function loadEvents(conversationIds) {
|
|
|
7785
7777
|
WHEN ${events.type} NOT IN ('assistant_message', 'tool_result') THEN NULL
|
|
7786
7778
|
WHEN ${events.schemaVersion} < 2 THEN ${events.payload}
|
|
7787
7779
|
WHEN (${events.payload}->'timestamp') IS NOT NULL THEN ${events.payload}
|
|
7788
|
-
|
|
7789
|
-
ELSE regexp_replace(${messageText}, ${NUL_ESCAPE_PATTERN}, ${NUL_ESCAPE_REPLACEMENT}, 'g')::jsonb
|
|
7780
|
+
ELSE ${storedMessageJson(messageText)}
|
|
7790
7781
|
END`;
|
|
7791
7782
|
return await getDb().select({
|
|
7792
7783
|
conversationId: events.conversationId,
|
|
@@ -7911,15 +7902,6 @@ function byConversation(rows) {
|
|
|
7911
7902
|
}
|
|
7912
7903
|
return grouped;
|
|
7913
7904
|
}
|
|
7914
|
-
function isQueryCanceled(error) {
|
|
7915
|
-
let current = error;
|
|
7916
|
-
for (let depth = 0; current && depth < 6; depth += 1) {
|
|
7917
|
-
if (typeof current !== "object") return false;
|
|
7918
|
-
if (current.code === QUERY_CANCELED) return true;
|
|
7919
|
-
current = current.cause;
|
|
7920
|
-
}
|
|
7921
|
-
return false;
|
|
7922
|
-
}
|
|
7923
7905
|
async function replayConversations(conversations, args) {
|
|
7924
7906
|
const { windowStartMs, nowMs, budgetMs } = args;
|
|
7925
7907
|
const startedAt = performance.now();
|
|
@@ -7942,7 +7924,7 @@ async function replayConversations(conversations, args) {
|
|
|
7942
7924
|
const ids = batch.map((row) => row.conversationId);
|
|
7943
7925
|
[rows, children] = await Promise.all([loadEvents(ids), loadChildAgents(ids)]);
|
|
7944
7926
|
} catch (error) {
|
|
7945
|
-
if (!
|
|
7927
|
+
if (!isPostgresErrorCode(error, QUERY_CANCELED)) throw error;
|
|
7946
7928
|
canceledBatches += 1;
|
|
7947
7929
|
continue;
|
|
7948
7930
|
}
|
|
@@ -8014,8 +7996,10 @@ async function backfillCacheWarmingGaps(args) {
|
|
|
8014
7996
|
await state.connect();
|
|
8015
7997
|
if (!await state.setIfNotExists(BACKFILL_KEY, "running", BACKFILL_CLAIM_TTL_MS)) return;
|
|
8016
7998
|
await withSpan("cache_warming.backfill", "cache_warming.backfill", {}, async (setSpanAttributes) => {
|
|
8017
|
-
const
|
|
8018
|
-
|
|
7999
|
+
const limit = pLimit(8);
|
|
8000
|
+
const segments = [...BACKFILL_SEGMENTS];
|
|
8001
|
+
const gapCounts = await Promise.all(segments.map((segment) => limit(async () => (await state.getList(segmentGapsKey(segment))).length)));
|
|
8002
|
+
const emptySegments = new Set(segments.filter((_segment, index) => gapCounts[index] === 0));
|
|
8019
8003
|
const { periods, scanned, canceledBatches, budgetExceeded } = await scanIdlePeriods({
|
|
8020
8004
|
windowStartMs: args.nowMs - GLOBAL_GAPS_TTL_MS,
|
|
8021
8005
|
nowMs: args.nowMs,
|
|
@@ -8080,7 +8064,7 @@ async function backfillCacheWarmingGaps(args) {
|
|
|
8080
8064
|
* job whose lease expires, because its slices stopped or kept failing, is
|
|
8081
8065
|
* failed, and an admin can start a new one.
|
|
8082
8066
|
*/
|
|
8083
|
-
const JOB_KEY = "junior:cache_warming:savings_refill:
|
|
8067
|
+
const JOB_KEY = "junior:cache_warming:savings_refill:v2";
|
|
8084
8068
|
const SLICE_LOCK_KEY = "junior:cache_warming:savings_refill:v1:slice";
|
|
8085
8069
|
const SLICE_LOCK_TTL_MS = 5 * MINUTE_MS;
|
|
8086
8070
|
const START_LOCK_KEY = "junior:cache_warming:savings_refill:v1:start";
|
|
@@ -8450,15 +8434,16 @@ async function selectDoneRoots(rootIds, cutoffMs) {
|
|
|
8450
8434
|
}, cutoffMs));
|
|
8451
8435
|
}
|
|
8452
8436
|
/**
|
|
8453
|
-
* Archive
|
|
8454
|
-
* user.
|
|
8437
|
+
* Archive roots for everyone when they are still archivable for the run's
|
|
8438
|
+
* user, in one statement, and count the archived roots.
|
|
8455
8439
|
*/
|
|
8456
|
-
async function
|
|
8457
|
-
|
|
8440
|
+
async function archiveRoots(run, rootConversationIds) {
|
|
8441
|
+
if (rootConversationIds.length === 0) return 0;
|
|
8442
|
+
const archivable = getDb().select({ userId: juniorConversationParticipants.userId }).from(juniorConversationParticipants).innerJoin(juniorUsers, eq(juniorUsers.id, juniorConversationParticipants.userId)).where(and(eq(juniorConversationParticipants.rootConversationId, juniorConversations.conversationId), archivableRow(run)));
|
|
8458
8443
|
return (await getDb().update(juniorConversations).set({
|
|
8459
8444
|
archivedAt: run.now,
|
|
8460
8445
|
detailVersion: nextDetailVersion
|
|
8461
|
-
}).where(and(
|
|
8446
|
+
}).where(and(inArray(juniorConversations.conversationId, rootConversationIds), isNull(juniorConversations.archivedAt), sql`exists (${archivable})`)).returning({ conversationId: juniorConversations.conversationId })).length;
|
|
8462
8447
|
}
|
|
8463
8448
|
/** Archive every done conversation of one user and count the rows. */
|
|
8464
8449
|
async function archiveUserDoneConversations(run) {
|
|
@@ -8471,7 +8456,7 @@ async function archiveUserDoneConversations(run) {
|
|
|
8471
8456
|
if (rows.length === 0) break;
|
|
8472
8457
|
scanned += rows.length;
|
|
8473
8458
|
const rootIds = rows.map((row) => row.rootConversationId);
|
|
8474
|
-
|
|
8459
|
+
archived += await archiveRoots(run, await selectDoneRoots(rootIds, cutoffMs));
|
|
8475
8460
|
if (rows.length < AUTO_ARCHIVE_PAGE_SIZE) break;
|
|
8476
8461
|
after = rows.at(-1);
|
|
8477
8462
|
}
|
|
@@ -8605,11 +8590,11 @@ async function matchReplyToReviewItems(args) {
|
|
|
8605
8590
|
].join("\n")
|
|
8606
8591
|
});
|
|
8607
8592
|
const matched = /* @__PURE__ */ new Set();
|
|
8608
|
-
args.items.
|
|
8593
|
+
for (const [index, item] of args.items.entries()) {
|
|
8609
8594
|
const answer = result.answers[keys[index]];
|
|
8610
|
-
if (answer?.choice !== "answers")
|
|
8595
|
+
if (answer?.choice !== "answers") continue;
|
|
8611
8596
|
if ((answer.probabilities?.answers ?? 1) >= MATCH_CONFIDENCE_THRESHOLD) matched.add(item.id);
|
|
8612
|
-
}
|
|
8597
|
+
}
|
|
8613
8598
|
return matched;
|
|
8614
8599
|
}
|
|
8615
8600
|
// src/chat/review-items/actions.ts
|
|
@@ -8908,12 +8893,12 @@ function mentionedSlackUserIds(texts) {
|
|
|
8908
8893
|
async function resolveMentions(executor, sources) {
|
|
8909
8894
|
const idsBySource = sources.map((source) => mentionedSlackUserIds(source.texts));
|
|
8910
8895
|
const idsByTenant = /* @__PURE__ */ new Map();
|
|
8911
|
-
sources.
|
|
8912
|
-
if (idsBySource[index].length === 0)
|
|
8896
|
+
for (const [index, source] of sources.entries()) {
|
|
8897
|
+
if (idsBySource[index].length === 0) continue;
|
|
8913
8898
|
const ids = idsByTenant.get(source.tenantId) ?? /* @__PURE__ */ new Set();
|
|
8914
8899
|
for (const id of idsBySource[index]) ids.add(id);
|
|
8915
8900
|
idsByTenant.set(source.tenantId, ids);
|
|
8916
|
-
}
|
|
8901
|
+
}
|
|
8917
8902
|
const peopleByTenant = new Map(await Promise.all([...idsByTenant].map(async ([tenantId, ids]) => [tenantId, await readMentionedPeople(executor, tenantId, [...ids])])));
|
|
8918
8903
|
return sources.map((source, index) => {
|
|
8919
8904
|
const people = peopleByTenant.get(source.tenantId);
|
|
@@ -9093,13 +9078,10 @@ async function attachPendingMentions(conversationId, messages) {
|
|
|
9093
9078
|
}
|
|
9094
9079
|
/** Read the viewer's pending authorization, also one saved before a deploy. */
|
|
9095
9080
|
async function findViewerWebAuthorization(conversationId, viewer) {
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
});
|
|
9101
|
-
if (authorization) return authorization;
|
|
9102
|
-
}
|
|
9081
|
+
return (await Promise.all(webActorUserIds(viewer).map((actorId) => getWebAuthorization({
|
|
9082
|
+
actorId,
|
|
9083
|
+
conversationId
|
|
9084
|
+
})))).find((authorization) => authorization !== void 0);
|
|
9103
9085
|
}
|
|
9104
9086
|
/**
|
|
9105
9087
|
* Read accepted mailbox messages that have not reached durable history yet.
|
|
@@ -9339,9 +9321,10 @@ async function listConversationSidebarAnnotations(conversationIds, annotationsBy
|
|
|
9339
9321
|
});
|
|
9340
9322
|
if (objects.length) selected[conversationId] = objects;
|
|
9341
9323
|
}
|
|
9342
|
-
|
|
9324
|
+
const limit = pLimit(8);
|
|
9325
|
+
const results = await Promise.all(plugins.map((plugin) => limit(async () => {
|
|
9343
9326
|
const hook = plugin.hooks?.conversationSidebar;
|
|
9344
|
-
if (!hook)
|
|
9327
|
+
if (!hook) return [];
|
|
9345
9328
|
const annotationsByConversationId = Object.fromEntries(conversationIds.flatMap((conversationId) => {
|
|
9346
9329
|
const annotations = (annotationsByConversation.get(conversationId) ?? []).filter((annotation) => annotation.plugin === plugin.manifest.name);
|
|
9347
9330
|
return annotations.length > 0 ? [[conversationId, annotations]] : [];
|
|
@@ -9355,19 +9338,23 @@ async function listConversationSidebarAnnotations(conversationIds, annotationsBy
|
|
|
9355
9338
|
plugin: { name: plugin.manifest.name },
|
|
9356
9339
|
cache: createPluginCache(plugin.manifest.name)
|
|
9357
9340
|
});
|
|
9358
|
-
|
|
9359
|
-
if (!candidates.has(conversationId))
|
|
9341
|
+
return Object.entries(result.annotationsByConversationId).flatMap(([conversationId, annotations]) => {
|
|
9342
|
+
if (!candidates.has(conversationId)) return [];
|
|
9360
9343
|
const parsed = conversationSidebarAnnotationSchema.array().safeParse(annotations);
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9344
|
+
return parsed.success && parsed.data.length > 0 ? [{
|
|
9345
|
+
annotations: parsed.data,
|
|
9346
|
+
conversationId
|
|
9347
|
+
}] : [];
|
|
9348
|
+
});
|
|
9364
9349
|
} catch (error) {
|
|
9365
9350
|
logWarn("plugin.conversation_sidebar.hook.failed", {
|
|
9366
9351
|
"app.plugin.name": plugin.manifest.name,
|
|
9367
9352
|
"exception.message": error instanceof Error ? error.message : String(error)
|
|
9368
9353
|
});
|
|
9354
|
+
return [];
|
|
9369
9355
|
}
|
|
9370
|
-
}
|
|
9356
|
+
})));
|
|
9357
|
+
for (const { annotations, conversationId } of results.flat()) selected[conversationId] = [...selected[conversationId] ?? [], ...annotations];
|
|
9371
9358
|
return selected;
|
|
9372
9359
|
}
|
|
9373
9360
|
// src/chat/conversations/fork.ts
|
|
@@ -9849,7 +9836,8 @@ async function readConversationAgentTree(conversation, readAccess) {
|
|
|
9849
9836
|
readAutomationTitlesByConversationId(root ? [root] : []),
|
|
9850
9837
|
readFirstHumanMessageTexts(getDb(), root ? [root] : [])
|
|
9851
9838
|
]);
|
|
9852
|
-
|
|
9839
|
+
const limit = pLimit(8);
|
|
9840
|
+
return await Promise.all(ids.map((id) => limit(async () => {
|
|
9853
9841
|
const itemAccess = access.get(id);
|
|
9854
9842
|
if (root?.conversationId === id) return {
|
|
9855
9843
|
conversationId: id,
|
|
@@ -9876,7 +9864,7 @@ async function readConversationAgentTree(conversation, readAccess) {
|
|
|
9876
9864
|
...agent?.agentType ? { agentType: agent.agentType } : void 0,
|
|
9877
9865
|
...agent?.fork ? { fork: true } : void 0
|
|
9878
9866
|
};
|
|
9879
|
-
}));
|
|
9867
|
+
})));
|
|
9880
9868
|
}
|
|
9881
9869
|
// src/api/conversations/display-markdown.ts
|
|
9882
9870
|
function format(text, provider) {
|