@sentry/junior 0.305.0 → 0.307.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-context-BpvbUki8.js → adapter-context-B69WPn6b.js} +2 -2
- package/dist/{admin-CoDt35ny.js → admin-nCJXMgkp.js} +2 -2
- package/dist/{agent-runner-C5d6rY5g.js → agent-runner-DdFcxAxG.js} +463 -303
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +7 -8
- package/dist/api.d.ts +19 -4
- package/dist/api.js +437 -310
- package/dist/{app-Cs157Zc5.d.ts → app-EZur8cVC.d.ts} +12 -3
- package/dist/app.d.ts +2 -2
- package/dist/app.js +532 -439
- package/dist/background-compaction-queue-BhEe4UfU.js +231 -0
- package/dist/{briefs-BRdznF7c.js → briefs-Dl9lxi7J.js} +3 -3
- package/dist/{catalog-runtime-J52Tej47.js → catalog-runtime-OXrv2Ewn.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-CBZp0udd.js → config-362yMSIz.js} +183 -49
- package/dist/{connections-BYmuJ6Vm.js → connections-BJv3EjmB.js} +10 -8
- package/dist/{continue-in-slack-Cvot6S38.js → continue-in-slack-CFEevC7z.js} +5 -5
- package/dist/{conversation-BOqdRtUx.js → conversation--f85g4zL.js} +132 -132
- package/dist/{conversation-feed-CgpgP7yi.js → conversation-feed-BNs9KiqC.js} +1 -1
- package/dist/{conversation-privacy-D2pOzBNl.js → conversation-privacy-Tjj5P2W6.js} +1 -1
- package/dist/{conversation-turn-CI8WDpnK.js → conversation-turn-DU0_WDAr.js} +26 -72
- package/dist/{credential-sync-COqnZ1Dx.js → credential-sync-D6aFARKE.js} +28 -27
- package/dist/{db-DU84dCVu.js → db-Bcbd9zQc.js} +226 -18
- package/dist/{db-zbN5ZV_o.d.ts → db-C41UgdBj.d.ts} +1 -1
- package/dist/{executor-CFyrgOu1.js → executor-DBMBrpNV.js} +137 -33
- package/dist/{history-m2-ceTTX.js → history-N7IVbUom.js} +5 -1
- package/dist/{install-CQ76CfRw.js → install-CgoAbzfF.js} +2 -2
- package/dist/instrumentation.js +2 -2
- package/dist/{lineage-DLd2UxVP.js → lineage-CsZDmz3e.js} +2 -2
- package/dist/{logging-BPNTQVFu.js → logging-CHCuQ5iz.js} +1 -1
- package/dist/{message-BWJLeQ5e.js → message-B8vCbZZB.js} +8 -8
- package/dist/{model-input-DoM9Ht-d.js → model-input-Xluiy-1W.js} +3 -3
- package/dist/nitro.d.ts +2 -2
- package/dist/nitro.js +3 -4
- package/dist/{oauth-callback-server-DeHbnAQl.js → oauth-callback-server-BUuNvfvu.js} +2 -2
- package/dist/{oauth-relay-DAmfVmJu.js → oauth-relay-DGAZzg9m.js} +1 -1
- package/dist/{plugins-B_0Cr0MO.d.ts → plugins-fBrz8PCV.d.ts} +2 -0
- package/dist/{projection-CcFBVFUo.js → projection-xPpvqexa.js} +13423 -11432
- package/dist/{prompt-C5LREK2p.js → prompt-D8u4jFs_.js} +15 -7
- package/dist/{registry-BjZZqKqi.js → registry-D20hG3r6.js} +19 -9
- package/dist/{resolve-CeJgXuH1.js → resolve-BhCySRCW.js} +3 -3
- package/dist/{result-icDrueyB.js → result-DddO63S9.js} +13 -11
- package/dist/{runner-nVfMkMMB.js → runner-DQR9vYce.js} +13 -15
- package/dist/{sandbox-egress-signals-H9vQ5qRf.js → sandbox-egress-signals-DFlNUOnK.js} +1 -1
- package/dist/{automation-CuA3yEcD.js → schedule-BG1tEbRF.js} +380 -8
- package/dist/{schema-CKcu-IK6.d.ts → schema-CRXcj4fj.d.ts} +420 -143
- package/dist/{schema-Bx0Mlo32.js → schema-D4jdesIu.js} +62 -8
- package/dist/{service-account-DU5865XA.js → service-account-Bv5QwrEq.js} +8 -6
- package/dist/{service-account-Dw06p3zm.js → service-account-CNfycv0z.js} +3 -3
- package/dist/{session-stop-uotLtp4g.js → session-stop-BDdwyZaa.js} +878 -171
- package/dist/{skills-Bex1EaO5.js → skills-63i1Bcv1.js} +32 -28
- package/dist/{slack-conversation-unfurl-EPG3riWF.js → slack-conversation-unfurl-DtpBUlUu.js} +10 -9
- package/dist/{spawn-CoD3vDuS.js → spawn-mwimEY9_.js} +6 -6
- package/dist/{state-nCR4Muhn.js → state-BBn9L6gC.js} +4 -4
- package/dist/{stop-BFVd0P0m.js → stop-Da-Ug7tg.js} +172 -239
- package/dist/{store-Ca6G962n.js → store-CdWg2r2L.js} +5 -5
- package/dist/{background-compaction-queue-BTqMIfTA.js → task-queue-BcjAYWyB.js} +164 -180
- package/dist/{task-runner-xsOPIxCZ.js → task-runner-CoXmMlsW.js} +13 -11
- package/dist/{thread-context-BOvZhsKK.js → thread-context-ZPGqOjW7.js} +8 -91
- package/dist/turn-session-routing-DFYak28Q.js +263 -0
- package/dist/{turn-user-message-BrhuyYrH.js → turn-user-message-B1S8nOnG.js} +3 -3
- package/dist/users-DDbENg-I.js +181 -0
- package/dist/{validation-BnY9K5WB.js → validation-fl21ps-k.js} +1 -1
- package/dist/{version-qROlRQGF.js → version-DCdMMx_0.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-CxUiOraX.js → viewer-DN_xzVKj.js} +3 -3
- package/dist/{warmup--Gkz7iB-.js → warmup-CxhEhm71.js} +842 -532
- package/dist/{web-message-id-lNodcCOI.js → web-message-id-BT8Mg8LL.js} +16 -1
- package/dist/{worker-DJ8d9fmD.js → worker-Btb1SB5h.js} +8 -7
- package/migrations/0114_plan_items.sql +22 -0
- 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/0114_snapshot.json +5203 -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 +49 -0
- package/package.json +10 -9
- package/dist/queue-B2AAL3ym.js +0 -115
- package/dist/schedule-cP0AACm1.js +0 -344
- package/dist/secrets-DHaJ5TTn.js +0 -18
- package/dist/task-queue-BLPZU6kC.js +0 -89
- package/dist/turn-session-routing-2bW2qfeb.js +0 -1792
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { F as textCharsForTokens, P as estimateTextTokens, V as escapeXml,
|
|
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-xPpvqexa.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-362yMSIz.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-CHCuQ5iz.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-DCdMMx_0.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 { A as conversationKindFromRow, D as postsRunNotices, E as isTopLevelKind,
|
|
8
|
-
import {
|
|
9
|
-
import { d as contextProvenance, p as instructionProvenanceFor, t as KNOWN_CONVERSATION_EVENT_TYPES } from "./history-
|
|
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,
|
|
16
|
-
import { f as
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { An as
|
|
21
|
-
import {
|
|
22
|
-
import { h as
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import { t as runWithSlackInstallation } from "./adapter-context-
|
|
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-
|
|
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
|
|
35
|
-
import { n as scheduleSessionCompletedPluginTasks } from "./task-runner-
|
|
36
|
-
import { r as canContinueInSlack } from "./continue-in-slack-
|
|
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-Bcbd9zQc.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-DBMBrpNV.js";
|
|
9
|
+
import { d as contextProvenance, p as instructionProvenanceFor, t as KNOWN_CONVERSATION_EVENT_TYPES } from "./history-N7IVbUom.js";
|
|
10
|
+
import { f as actorLogContext, p as credentialContextForActor } from "./registry-D20hG3r6.js";
|
|
11
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-OXrv2Ewn.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-DdFcxAxG.js";
|
|
13
|
+
import { d as PluginMcpClient, u as McpAuthorizationRequiredError, v as getMcpStoredOAuthCredentials } from "./service-account-Bv5QwrEq.js";
|
|
14
|
+
import { i as webActorUserIds } from "./state-BBn9L6gC.js";
|
|
15
|
+
import { a as EVENT_SYSTEM_ACTOR, d as completeText, l as completeDecision, s as isEventConversationMessage } from "./prompt-D8u4jFs_.js";
|
|
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-DN_xzVKj.js";
|
|
18
|
+
import { d as readJuniorSecret, g as getTurnRequestDeadline, s as sendVercelPluginTask } from "./task-queue-BcjAYWyB.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-BDdwyZaa.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-CxhEhm71.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-B1S8nOnG.js";
|
|
23
|
+
import { m as getVercelConversationWorkQueue } from "./background-compaction-queue-BhEe4UfU.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-CdWg2r2L.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-DFYak28Q.js";
|
|
26
|
+
import { t as runWithSlackInstallation } from "./adapter-context-B69WPn6b.js";
|
|
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 { a as withTurnSpan, i as turnInputTelemetry, n as createConversationTurnWorker, r as getTurnInputSpanAttributes } from "./conversation-turn-DU0_WDAr.js";
|
|
29
|
+
import { n as buildStoredAttachmentPromptText } from "./model-input-Xluiy-1W.js";
|
|
30
|
+
import { i as enqueueAgentInvocationResult, n as createDeliverToParent, s as withAgentInvocationResultActors, t as createChildConversationWorker } from "./result-DddO63S9.js";
|
|
31
|
+
import { t as bindMessageAgent } from "./message-B8vCbZZB.js";
|
|
32
|
+
import { t as readConversationLineage } from "./lineage-CsZDmz3e.js";
|
|
33
|
+
import { t as bindSpawnAgent } from "./spawn-mwimEY9_.js";
|
|
34
|
+
import { a as buildDeliveredTurnStatePatch, i as persistAuthPauseTurnState, n as loadThreadContextTrimFloor, o as loadPendingMessageCards, r as completeAuthPauseTurn, t as buildTurnThreadContext } from "./thread-context-ZPGqOjW7.js";
|
|
35
|
+
import { n as scheduleSessionCompletedPluginTasks } from "./task-runner-CoXmMlsW.js";
|
|
36
|
+
import { r as canContinueInSlack } from "./continue-in-slack-CFEevC7z.js";
|
|
37
|
+
import pLimit from "p-limit";
|
|
37
38
|
import * as z from "zod";
|
|
38
39
|
import { createHash, createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
39
40
|
import { and, asc, count, desc, eq, gt, gte, inArray, isNotNull, isNull, lte, ne, not, or, sql } from "drizzle-orm";
|
|
@@ -1684,17 +1685,17 @@ function createSlackTurnRuntime(deps) {
|
|
|
1684
1685
|
await args.ack?.();
|
|
1685
1686
|
};
|
|
1686
1687
|
const selectAcceptedSteeringMessages = async (args) => {
|
|
1687
|
-
const
|
|
1688
|
-
|
|
1688
|
+
const limit = pLimit(8);
|
|
1689
|
+
const selected = await Promise.all(args.messages.map((candidate) => limit(async () => {
|
|
1689
1690
|
const decision = await decideSteeringMessage(args.thread, candidate, args.conversationContext, args.conversationId);
|
|
1690
|
-
|
|
1691
|
+
return {
|
|
1691
1692
|
context: decision.context,
|
|
1692
1693
|
decision: decision.decision,
|
|
1693
1694
|
inboundMessageId: candidate.inboundMessageId,
|
|
1694
1695
|
message: candidate.message,
|
|
1695
1696
|
text: decision.text
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1697
|
+
};
|
|
1698
|
+
})));
|
|
1698
1699
|
if (selected.some((message) => message.decision.shouldUnsubscribe)) return {
|
|
1699
1700
|
accepted: [],
|
|
1700
1701
|
skipped: selected.map((message) => message.decision.shouldReply ? {
|
|
@@ -3059,7 +3060,6 @@ function createSlackAdapterStatusSender(args) {
|
|
|
3059
3060
|
* `loading_messages` while `status` stays fixed and generic.
|
|
3060
3061
|
*/
|
|
3061
3062
|
function createSlackWebApiStatusSender(args) {
|
|
3062
|
-
const getClient = args.getSlackClient ?? getSlackClient;
|
|
3063
3063
|
return async (text, loadingMessages) => {
|
|
3064
3064
|
const channelId = args.channelId;
|
|
3065
3065
|
const threadTs = args.threadTs;
|
|
@@ -3068,7 +3068,7 @@ function createSlackWebApiStatusSender(args) {
|
|
|
3068
3068
|
if (!normalizedChannelId) return;
|
|
3069
3069
|
const nextLoadingMessages = text ? loadingMessages ?? [text] : void 0;
|
|
3070
3070
|
try {
|
|
3071
|
-
await withSetStatusSpan(() =>
|
|
3071
|
+
await withSetStatusSpan(() => getSlackClient().assistant.threads.setStatus({
|
|
3072
3072
|
channel_id: normalizedChannelId,
|
|
3073
3073
|
thread_ts: threadTs,
|
|
3074
3074
|
status: text ? SLACK_ASSISTANT_ACTIVE_STATUS : "",
|
|
@@ -3143,8 +3143,7 @@ function createSlackWebApiAssistantStatusSession(args) {
|
|
|
3143
3143
|
return createAssistantStatusScheduler({
|
|
3144
3144
|
sendStatus: createSlackWebApiStatusSender({
|
|
3145
3145
|
channelId: args.channelId,
|
|
3146
|
-
threadTs: args.threadTs
|
|
3147
|
-
getSlackClient: args.getSlackClient
|
|
3146
|
+
threadTs: args.threadTs
|
|
3148
3147
|
}),
|
|
3149
3148
|
loadingMessages: args.loadingMessages ?? botConfig.loadingMessages,
|
|
3150
3149
|
now: args.now,
|
|
@@ -3545,7 +3544,8 @@ function createSlackTurn(deps) {
|
|
|
3545
3544
|
};
|
|
3546
3545
|
let activeTurnId = preparedState.conversation.processing.activeTurnId;
|
|
3547
3546
|
const resolveSteeringMessages = async (queuedMessages) => {
|
|
3548
|
-
|
|
3547
|
+
const limit = pLimit(8);
|
|
3548
|
+
return await Promise.all(queuedMessages.map((queued) => limit(async () => {
|
|
3549
3549
|
const attachments = queued.message.attachments;
|
|
3550
3550
|
const reviewItemInput = await loadReviewItemInput(getMessageReviewItemChange(queued.message));
|
|
3551
3551
|
return {
|
|
@@ -3565,7 +3565,7 @@ function createSlackTurn(deps) {
|
|
|
3565
3565
|
messageTs: getMessageTimestamp(queued.message)
|
|
3566
3566
|
})
|
|
3567
3567
|
};
|
|
3568
|
-
}));
|
|
3568
|
+
})));
|
|
3569
3569
|
};
|
|
3570
3570
|
/** Save new messages before completing the mailbox delivery. */
|
|
3571
3571
|
const saveMessagesForPausedTurn = async (pausedTurnId) => {
|
|
@@ -4017,10 +4017,7 @@ function createSlackTurn(deps) {
|
|
|
4017
4017
|
let failureEventId;
|
|
4018
4018
|
let failureReason;
|
|
4019
4019
|
if (finalResult.diagnostics.outcome !== "success") {
|
|
4020
|
-
const finalized = finalizeFailedTurnReplyWithEvent({
|
|
4021
|
-
reply: finalResult,
|
|
4022
|
-
logException
|
|
4023
|
-
});
|
|
4020
|
+
const finalized = finalizeFailedTurnReplyWithEvent({ reply: finalResult });
|
|
4024
4021
|
finalResult = finalized.reply;
|
|
4025
4022
|
failureEventId = finalized.eventId;
|
|
4026
4023
|
failureReason = finalized.failureReason;
|
|
@@ -4177,7 +4174,7 @@ function createSlackTurn(deps) {
|
|
|
4177
4174
|
await scheduleSessionCompletedPluginTasks({
|
|
4178
4175
|
conversationId,
|
|
4179
4176
|
sessionId: turnId
|
|
4180
|
-
}, deps.sendPluginTask
|
|
4177
|
+
}, deps.sendPluginTask);
|
|
4181
4178
|
} catch (error) {
|
|
4182
4179
|
logException(error, "plugin.session.completed_task_schedule.failed");
|
|
4183
4180
|
}
|
|
@@ -4624,17 +4621,17 @@ async function readDispatchTurnResult(dispatch) {
|
|
|
4624
4621
|
outcome: "completed",
|
|
4625
4622
|
resultMessageTs
|
|
4626
4623
|
};
|
|
4627
|
-
if (!session) return {};
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
outcome: "
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
}
|
|
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
|
+
}
|
|
4638
4635
|
}
|
|
4639
4636
|
async function projectDispatchTurnResult(dispatchId, result) {
|
|
4640
4637
|
switch (result.outcome) {
|
|
@@ -4650,7 +4647,7 @@ async function projectDispatchTurnResult(dispatchId, result) {
|
|
|
4650
4647
|
case "completed":
|
|
4651
4648
|
await markDispatchCompleted(dispatchId, result.resultMessageTs);
|
|
4652
4649
|
break;
|
|
4653
|
-
case
|
|
4650
|
+
case "not_started": await markDispatchFailed(dispatchId, "Dispatch turn record is missing");
|
|
4654
4651
|
}
|
|
4655
4652
|
}
|
|
4656
4653
|
function getDispatchBlockingError(error) {
|
|
@@ -4718,7 +4715,7 @@ function createAgentDispatchConversationWorker(options) {
|
|
|
4718
4715
|
return { status: "completed" };
|
|
4719
4716
|
}
|
|
4720
4717
|
try {
|
|
4721
|
-
const resumesDurableTurn = durableResult.
|
|
4718
|
+
const resumesDurableTurn = durableResult.outcome === "awaiting_resume" || durableResult.outcome === "still_running";
|
|
4722
4719
|
if (resumesDurableTurn && context.attempt.messages.length > 0) await acknowledge();
|
|
4723
4720
|
let result;
|
|
4724
4721
|
if (resumesDurableTurn) {
|
|
@@ -4727,20 +4724,15 @@ function createAgentDispatchConversationWorker(options) {
|
|
|
4727
4724
|
checkIn: context.checkIn
|
|
4728
4725
|
});
|
|
4729
4726
|
result = await readDispatchTurnResult(dispatch);
|
|
4730
|
-
} else {
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
...runtimeResult,
|
|
4738
|
-
...await readDispatchTurnResult(dispatch)
|
|
4739
|
-
};
|
|
4740
|
-
}
|
|
4741
|
-
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`);
|
|
4742
4734
|
await projectDispatchTurnResult(dispatch.id, result);
|
|
4743
|
-
if (
|
|
4735
|
+
if (!acknowledged) await acknowledge();
|
|
4744
4736
|
return result.outcome === "awaiting_resume" && context.shouldYield() ? { status: "yielded" } : { status: "completed" };
|
|
4745
4737
|
} catch (error) {
|
|
4746
4738
|
if (isCooperativeTurnYieldError(error)) {
|
|
@@ -4827,7 +4819,6 @@ function createSlackDispatchTurnRunner(options) {
|
|
|
4827
4819
|
isSubscribedContext: true
|
|
4828
4820
|
});
|
|
4829
4821
|
let outcome;
|
|
4830
|
-
let errorMessage;
|
|
4831
4822
|
let resultMessageTs;
|
|
4832
4823
|
const routing = buildDispatchRoutingContext(dispatch);
|
|
4833
4824
|
await options.executeSlackTurn(thread, message, {
|
|
@@ -4848,18 +4839,17 @@ function createSlackDispatchTurnRunner(options) {
|
|
|
4848
4839
|
resultMessageTs = messageId;
|
|
4849
4840
|
},
|
|
4850
4841
|
onTurnOutcome: (result) => {
|
|
4851
|
-
outcome = result
|
|
4852
|
-
errorMessage = result.errorMessage;
|
|
4842
|
+
outcome = result;
|
|
4853
4843
|
},
|
|
4854
4844
|
shouldYield: hooks.shouldYield,
|
|
4855
4845
|
checkIn: hooks.checkIn,
|
|
4856
4846
|
skipBackfill: true
|
|
4857
4847
|
});
|
|
4858
|
-
return {
|
|
4859
|
-
...
|
|
4860
|
-
|
|
4861
|
-
...resultMessageTs ? { resultMessageTs } : void 0
|
|
4848
|
+
if (resultMessageTs && (outcome?.outcome === "blocked" || outcome?.outcome === "completed" || outcome?.outcome === "failed")) return {
|
|
4849
|
+
...outcome,
|
|
4850
|
+
resultMessageTs
|
|
4862
4851
|
};
|
|
4852
|
+
return outcome;
|
|
4863
4853
|
};
|
|
4864
4854
|
}
|
|
4865
4855
|
// src/chat/app/factory.ts
|
|
@@ -4979,7 +4969,6 @@ function createJuniorSlackAdapter(config) {
|
|
|
4979
4969
|
return createSlackAdapter(config);
|
|
4980
4970
|
}
|
|
4981
4971
|
// src/chat/ingress/message-router.ts
|
|
4982
|
-
/** Derive canonical Slack thread IDs from the raw event payload. */
|
|
4983
4972
|
/** Rebuild a Message onto a normalized Slack thread id. */
|
|
4984
4973
|
function withNormalizedThreadId(message, threadId) {
|
|
4985
4974
|
if (message.threadId === threadId) return message;
|
|
@@ -4996,6 +4985,7 @@ function withNormalizedThreadId(message, threadId) {
|
|
|
4996
4985
|
threadId
|
|
4997
4986
|
});
|
|
4998
4987
|
}
|
|
4988
|
+
/** Derive canonical Slack thread IDs from the raw event payload. */
|
|
4999
4989
|
function normalizeIncomingSlackThreadId(threadId, message) {
|
|
5000
4990
|
if (!threadId.startsWith("slack:")) return threadId;
|
|
5001
4991
|
if (!message || typeof message !== "object") return threadId;
|
|
@@ -5015,10 +5005,11 @@ function nonEmptyString(value) {
|
|
|
5015
5005
|
* Restore Slack private-file fetchers on message attachments that crossed a
|
|
5016
5006
|
* serialization boundary.
|
|
5017
5007
|
*/
|
|
5018
|
-
function rehydrateAttachmentFetchers(message
|
|
5019
|
-
for (const attachment of message.attachments) if (!attachment.fetchData && attachment.url) attachment.fetchData = () => downloadPrivateSlackFile
|
|
5008
|
+
function rehydrateAttachmentFetchers(message) {
|
|
5009
|
+
for (const attachment of message.attachments) if (!attachment.fetchData && attachment.url) attachment.fetchData = () => downloadPrivateSlackFile(attachment.url);
|
|
5020
5010
|
}
|
|
5021
5011
|
// src/chat/task-execution/slack-work.ts
|
|
5012
|
+
const SLACK_AUTHOR_LOOKUP_CONCURRENCY = 5;
|
|
5022
5013
|
const slackConversationRouteSchema = z.enum(["mention", "subscribed"]);
|
|
5023
5014
|
function hasSteeringOverride(text) {
|
|
5024
5015
|
return stripLeadingSteeringOverride(text) !== text;
|
|
@@ -5304,14 +5295,15 @@ async function bindSlackActorIdentities(args) {
|
|
|
5304
5295
|
const authorId = requireSlackAuthorId(message);
|
|
5305
5296
|
byAuthorId.set(authorId, [...byAuthorId.get(authorId) ?? [], message]);
|
|
5306
5297
|
}
|
|
5307
|
-
|
|
5308
|
-
|
|
5298
|
+
const limit = pLimit(SLACK_AUTHOR_LOOKUP_CONCURRENCY);
|
|
5299
|
+
await Promise.all([...byAuthorId].map(([authorId, messages]) => limit(async () => {
|
|
5300
|
+
const profile = await lookupSlackUser(args.teamId, authorId);
|
|
5309
5301
|
await Promise.all(messages.map((message) => ensureSlackMessageActorIdentity(message, args.teamId, async () => profile)));
|
|
5310
5302
|
if (profile && messages.some(getMessageAuthorIdentityId)) await resolveActorIdentityId(getSqlExecutor(), createSlackActor(args.teamId, authorId, {
|
|
5311
5303
|
fullName: profile.fullName,
|
|
5312
5304
|
userName: profile.userName
|
|
5313
5305
|
}));
|
|
5314
|
-
}));
|
|
5306
|
+
})));
|
|
5315
5307
|
}
|
|
5316
5308
|
function restoreThread(args) {
|
|
5317
5309
|
const threadId = normalizeIncomingSlackThreadId(args.threadJson.id, args.message);
|
|
@@ -5343,7 +5335,6 @@ function getPendingRecords(work) {
|
|
|
5343
5335
|
function createSlackConversationWorker(options) {
|
|
5344
5336
|
return async (context) => {
|
|
5345
5337
|
const adapter = options.getSlackAdapter();
|
|
5346
|
-
const actorLookup = options.lookupSlackUser ?? lookupSlackUser;
|
|
5347
5338
|
const state = getConnectedState(options.state);
|
|
5348
5339
|
await state.connect();
|
|
5349
5340
|
const records = getPendingRecords({ execution: { pendingMessages: [...context.attempt.messages] } });
|
|
@@ -5399,7 +5390,6 @@ function createSlackConversationWorker(options) {
|
|
|
5399
5390
|
record
|
|
5400
5391
|
}));
|
|
5401
5392
|
await bindSlackActorIdentities({
|
|
5402
|
-
lookupSlackUser: actorLookup,
|
|
5403
5393
|
messages,
|
|
5404
5394
|
teamId: destination.teamId
|
|
5405
5395
|
});
|
|
@@ -5875,10 +5865,7 @@ async function resumeSlackTurnInContext(args) {
|
|
|
5875
5865
|
});
|
|
5876
5866
|
const outcome = await runArgs.executeTurn(run, async (result) => {
|
|
5877
5867
|
run.signal?.throwIfAborted();
|
|
5878
|
-
const finalized = finalizeFailedTurnReplyWithEvent({
|
|
5879
|
-
reply: result,
|
|
5880
|
-
logException
|
|
5881
|
-
});
|
|
5868
|
+
const finalized = finalizeFailedTurnReplyWithEvent({ reply: result });
|
|
5882
5869
|
const reply = finalized.reply;
|
|
5883
5870
|
setSpanAttributes(getAgentTurnDiagnosticsAttributes(reply));
|
|
5884
5871
|
const dispatchResult = runDispatchOutcome(reply);
|
|
@@ -5969,7 +5956,7 @@ async function resumeSlackTurnInContext(args) {
|
|
|
5969
5956
|
conversationId: runArgs.conversationId,
|
|
5970
5957
|
sessionId: runArgs.turnId
|
|
5971
5958
|
};
|
|
5972
|
-
await (runArgs.
|
|
5959
|
+
await scheduleSessionCompletedPluginTasks(params, runArgs.sendPluginTask);
|
|
5973
5960
|
} catch (scheduleError) {
|
|
5974
5961
|
logException(scheduleError, "plugin.session.completed_task_schedule.failed");
|
|
5975
5962
|
}
|
|
@@ -6205,25 +6192,7 @@ async function failPausedTurn(args) {
|
|
|
6205
6192
|
errorMessage: args.errorMessage
|
|
6206
6193
|
});
|
|
6207
6194
|
if (!failed) return;
|
|
6208
|
-
|
|
6209
|
-
const routing = await resolveTurnSessionRouting({ conversationId: args.conversationId });
|
|
6210
|
-
await recordTurnSummary({
|
|
6211
|
-
conversationId: args.conversationId,
|
|
6212
|
-
destination: routing.destination,
|
|
6213
|
-
dispatchId: failed.dispatchId,
|
|
6214
|
-
dispatchOutcome: "failed",
|
|
6215
|
-
turnId: failed.turnId,
|
|
6216
|
-
sliceId: failed.sliceId,
|
|
6217
|
-
source: routing.source,
|
|
6218
|
-
state: "failed",
|
|
6219
|
-
surface: failed.surface
|
|
6220
|
-
});
|
|
6221
|
-
} catch (error) {
|
|
6222
|
-
logException(error, "agent.continue.dispatch_failure_summary.failed", {
|
|
6223
|
-
"app.ai.conversation_id": args.conversationId,
|
|
6224
|
-
"app.ai.session_id": args.summary.turnId
|
|
6225
|
-
});
|
|
6226
|
-
}
|
|
6195
|
+
await recordFailedDispatchTurn(failed);
|
|
6227
6196
|
}
|
|
6228
6197
|
/**
|
|
6229
6198
|
* Continue one paused Slack agent run from durable conversation state.
|
|
@@ -6235,7 +6204,6 @@ async function runPausedTurn(payload, options, runOptions = {}) {
|
|
|
6235
6204
|
}
|
|
6236
6205
|
async function runPausedTurnInContext(payload, options, runOptions) {
|
|
6237
6206
|
const destination = requireSlackDestination(payload.destination, "Paused turn");
|
|
6238
|
-
const wakePausedTurn$1 = options.wakePausedTurn ?? wakePausedTurn;
|
|
6239
6207
|
const routing = await resolveConversationRouting({ conversationId: payload.conversationId });
|
|
6240
6208
|
const pausedTurn = await getTurnRecord(payload.conversationId, payload.turnId);
|
|
6241
6209
|
const target = resolveSlackReplyTarget({
|
|
@@ -6251,7 +6219,7 @@ async function runPausedTurnInContext(payload, options, runOptions) {
|
|
|
6251
6219
|
channelId: target.channelId,
|
|
6252
6220
|
...target.threadTs ? { threadTs: target.threadTs } : void 0,
|
|
6253
6221
|
executeTurn: async (run, saveResult) => await executeTurn(options.agentRunner, run, saveResult),
|
|
6254
|
-
|
|
6222
|
+
sendPluginTask: options.sendPluginTask,
|
|
6255
6223
|
beforeStart: async () => {
|
|
6256
6224
|
let turn;
|
|
6257
6225
|
try {
|
|
@@ -6322,7 +6290,10 @@ async function runPausedTurnInContext(payload, options, runOptions) {
|
|
|
6322
6290
|
}
|
|
6323
6291
|
const locationConfiguration = getLocationConfigurationService(destination);
|
|
6324
6292
|
const sandboxRef = getPersistedSandboxState(currentState);
|
|
6325
|
-
const routing = await
|
|
6293
|
+
const routing = await resolveTurnResumeRouting({
|
|
6294
|
+
conversationId: payload.conversationId,
|
|
6295
|
+
dispatchId
|
|
6296
|
+
});
|
|
6326
6297
|
const source = routing.source;
|
|
6327
6298
|
const routingDestination = routing.destination;
|
|
6328
6299
|
const turnMessages = activeTurn.turnStartMessageIndex === void 0 ? [] : activeTurn.piMessages.slice(activeTurn.turnStartMessageIndex);
|
|
@@ -6420,7 +6391,7 @@ async function runPausedTurnInContext(payload, options, runOptions) {
|
|
|
6420
6391
|
});
|
|
6421
6392
|
},
|
|
6422
6393
|
onSuspend: async (resumeVersion) => {
|
|
6423
|
-
await
|
|
6394
|
+
await options.pausedTurns.wake({
|
|
6424
6395
|
conversationId: payload.conversationId,
|
|
6425
6396
|
destination: payload.destination,
|
|
6426
6397
|
turnId: payload.turnId,
|
|
@@ -6492,7 +6463,10 @@ async function failStrandedTurnWithFallback(args) {
|
|
|
6492
6463
|
}
|
|
6493
6464
|
let routing;
|
|
6494
6465
|
try {
|
|
6495
|
-
routing = await
|
|
6466
|
+
routing = await resolveTurnResumeRouting({
|
|
6467
|
+
conversationId: args.conversationId,
|
|
6468
|
+
dispatchId: failed.dispatchId
|
|
6469
|
+
});
|
|
6496
6470
|
} catch (error) {
|
|
6497
6471
|
logException(error, "agent.turn.stranded_session.routing_unavailable", {
|
|
6498
6472
|
"app.ai.conversation_id": args.conversationId,
|
|
@@ -6658,7 +6632,7 @@ function createConversationWork(options) {
|
|
|
6658
6632
|
const baseRuntime = createSlackRuntime({
|
|
6659
6633
|
getSlackAdapter: options.getSlackAdapter,
|
|
6660
6634
|
pausedTurns,
|
|
6661
|
-
|
|
6635
|
+
sendPluginTask: options.sendPluginTask,
|
|
6662
6636
|
services: {
|
|
6663
6637
|
...options.services,
|
|
6664
6638
|
agentRunner: options.agentRunner
|
|
@@ -6666,13 +6640,12 @@ function createConversationWork(options) {
|
|
|
6666
6640
|
waitUntil: options.waitUntil
|
|
6667
6641
|
});
|
|
6668
6642
|
const runtime = options.wrapRuntime?.(baseRuntime) ?? baseRuntime;
|
|
6669
|
-
const scheduleCompletedPluginTasks = options.sendPluginTask ? async (params) => await scheduleSessionCompletedPluginTasks(params, { send: options.sendPluginTask }) : void 0;
|
|
6670
6643
|
const slackWorker = createSlackConversationWorker({
|
|
6671
6644
|
getSlackAdapter: options.getSlackAdapter,
|
|
6672
6645
|
runNextPausedTurn: async (conversationId, runOptions) => await runNextPausedTurn(conversationId, {
|
|
6673
6646
|
agentRunner: options.agentRunner,
|
|
6674
|
-
|
|
6675
|
-
|
|
6647
|
+
pausedTurns,
|
|
6648
|
+
sendPluginTask: options.sendPluginTask
|
|
6676
6649
|
}, runOptions),
|
|
6677
6650
|
runtime,
|
|
6678
6651
|
state: options.state
|
|
@@ -6683,8 +6656,8 @@ function createConversationWork(options) {
|
|
|
6683
6656
|
agentRunner: options.agentRunner,
|
|
6684
6657
|
inputMessageIds: [getDispatchInputMessageId(dispatch.id)],
|
|
6685
6658
|
routingContext: buildDispatchRoutingContext(dispatch),
|
|
6686
|
-
|
|
6687
|
-
|
|
6659
|
+
pausedTurns,
|
|
6660
|
+
sendPluginTask: options.sendPluginTask
|
|
6688
6661
|
}, {
|
|
6689
6662
|
checkIn: hooks.checkIn,
|
|
6690
6663
|
shouldYield: hooks.shouldYield
|
|
@@ -6796,6 +6769,7 @@ function createProductionSlackWebhookServices(options) {
|
|
|
6796
6769
|
const conversationStore = getProductionConversationStore();
|
|
6797
6770
|
const runtime = createSlackRuntime({
|
|
6798
6771
|
getSlackAdapter: getProductionSlackAdapter,
|
|
6772
|
+
sendPluginTask: sendVercelPluginTask,
|
|
6799
6773
|
services: options?.services
|
|
6800
6774
|
});
|
|
6801
6775
|
return {
|
|
@@ -6906,6 +6880,11 @@ async function resolveSlackTeamDomains(teamIds) {
|
|
|
6906
6880
|
return new Map(resolved.filter((entry) => entry !== void 0));
|
|
6907
6881
|
}
|
|
6908
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
|
+
*/
|
|
6909
6888
|
/** Slack permalinks, such as `acme.slack.com/archives/C123/p1712345000000100`. */
|
|
6910
6889
|
const SLACK_MESSAGE_LINK_FILTER = {
|
|
6911
6890
|
host: "*.slack.com",
|
|
@@ -6970,32 +6949,37 @@ async function readMessageCard(args) {
|
|
|
6970
6949
|
async function resolveSlackMessageLink(viewer, url) {
|
|
6971
6950
|
const parsed = parseSlackMessageReference(url.href);
|
|
6972
6951
|
if (!parsed.ok) return void 0;
|
|
6973
|
-
|
|
6952
|
+
const limit = pLimit(8);
|
|
6953
|
+
const workspace = (await Promise.all(viewer.identities.map(async (identity) => {
|
|
6974
6954
|
const teamId = parseSlackTeamId(identity.providerTenantId);
|
|
6975
|
-
if (identity.provider !== "slack" || !teamId)
|
|
6955
|
+
if (identity.provider !== "slack" || !teamId) return void 0;
|
|
6976
6956
|
const run = (task) => runWithSlackInstallation({
|
|
6977
6957
|
adapter: getProductionSlackAdapter(),
|
|
6978
6958
|
installation: { teamId },
|
|
6979
6959
|
task
|
|
6980
6960
|
});
|
|
6981
|
-
let domain;
|
|
6982
6961
|
try {
|
|
6983
|
-
|
|
6962
|
+
return {
|
|
6963
|
+
domain: await limit(() => run(() => resolveSlackTeamDomain(teamId))),
|
|
6964
|
+
identity,
|
|
6965
|
+
run,
|
|
6966
|
+
teamId
|
|
6967
|
+
};
|
|
6984
6968
|
} catch (error) {
|
|
6985
6969
|
logWarn("object_link.slack_team.unavailable", {
|
|
6986
6970
|
"app.slack.team_id": teamId,
|
|
6987
6971
|
"exception.message": error instanceof Error ? error.message : String(error)
|
|
6988
6972
|
});
|
|
6989
|
-
|
|
6973
|
+
return;
|
|
6990
6974
|
}
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
}
|
|
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
|
+
}));
|
|
6999
6983
|
}
|
|
7000
6984
|
// src/net/public-address.ts
|
|
7001
6985
|
/**
|
|
@@ -7679,7 +7663,8 @@ async function resolveObjectLinkNow(viewer, url) {
|
|
|
7679
7663
|
async function resolveObjectLinks(viewer, urls) {
|
|
7680
7664
|
const linkTypes = readObjectLinkTypes();
|
|
7681
7665
|
const cache = createCache(getStateAdapter(), "object-links");
|
|
7682
|
-
|
|
7666
|
+
const limit = pLimit(8);
|
|
7667
|
+
return (await Promise.all([...new Set(urls)].map((url) => limit(async () => {
|
|
7683
7668
|
const parsed = URL.canParse(url) ? new URL(url) : void 0;
|
|
7684
7669
|
const linkType = parsed && findObjectLinkType(linkTypes, parsed);
|
|
7685
7670
|
if (!parsed || !linkType) return [];
|
|
@@ -7698,7 +7683,7 @@ async function resolveObjectLinks(viewer, urls) {
|
|
|
7698
7683
|
logException(error, "object_link.resolve.failed", { "app.plugin.name": linkType.owner });
|
|
7699
7684
|
return [];
|
|
7700
7685
|
}
|
|
7701
|
-
}))).flat();
|
|
7686
|
+
})))).flat();
|
|
7702
7687
|
}
|
|
7703
7688
|
// src/handlers/health.ts
|
|
7704
7689
|
/** Build Junior's process health value for HTTP and reporting consumers. */
|
|
@@ -7787,10 +7772,12 @@ async function loadEvents(conversationIds) {
|
|
|
7787
7772
|
const events = juniorConversationEvents;
|
|
7788
7773
|
const isUserMessage = sql`${events.type} = 'user_message'`;
|
|
7789
7774
|
const isToolResult = sql`${events.type} = 'tool_result'`;
|
|
7775
|
+
const messageText = sql`${events.payload}->>'message'`;
|
|
7790
7776
|
const message = sql`CASE
|
|
7791
7777
|
WHEN ${events.type} NOT IN ('assistant_message', 'tool_result') THEN NULL
|
|
7792
|
-
WHEN ${events.schemaVersion}
|
|
7793
|
-
|
|
7778
|
+
WHEN ${events.schemaVersion} < 2 THEN ${events.payload}
|
|
7779
|
+
WHEN (${events.payload}->'timestamp') IS NOT NULL THEN ${events.payload}
|
|
7780
|
+
ELSE ${storedMessageJson(messageText)}
|
|
7794
7781
|
END`;
|
|
7795
7782
|
return await getDb().select({
|
|
7796
7783
|
conversationId: events.conversationId,
|
|
@@ -7799,7 +7786,7 @@ async function loadEvents(conversationIds) {
|
|
|
7799
7786
|
stopReason: sql`(${message})->>'stopReason'`,
|
|
7800
7787
|
toolName: sql`(${message})->>'toolName'`,
|
|
7801
7788
|
startedAtMs: sql`(${message})->>'timestamp'`,
|
|
7802
|
-
modelId: sql
|
|
7789
|
+
modelId: sql`${events.payload}->>'model'`,
|
|
7803
7790
|
cacheRead: sql`${events.payload}->'usage'->>'cacheRead'`,
|
|
7804
7791
|
cacheWrite: sql`${events.payload}->'usage'->>'cacheWrite'`
|
|
7805
7792
|
}).from(events).innerJoin(juniorConversations, eq(juniorConversations.conversationId, events.conversationId)).where(and(inArray(events.conversationId, conversationIds), or(eq(events.type, "assistant_message"), and(isToolResult, inArray(sql`(${message})->>'toolName'`, Object.keys(ANSWER_TOOL_ENDINGS)), sql`(${message})->>'isError' IS DISTINCT FROM 'true'`), and(isUserMessage, sql`(${events.payload}->'provenance'->>'authority') = 'instruction'`)), gte(events.createdAt, juniorConversations.createdAt))).orderBy(events.conversationId, events.seq);
|
|
@@ -7888,7 +7875,7 @@ function replayConversation(kind, events, children, nowMs) {
|
|
|
7888
7875
|
const waitsOnPendingWork = turnBehavior({
|
|
7889
7876
|
kind,
|
|
7890
7877
|
personInput: userActor
|
|
7891
|
-
}).
|
|
7878
|
+
}).idleNeedsPendingWork;
|
|
7892
7879
|
idle = {
|
|
7893
7880
|
sinceMs: startedAtMs,
|
|
7894
7881
|
segment: historySegment(userActor, endedTurns),
|
|
@@ -7915,15 +7902,6 @@ function byConversation(rows) {
|
|
|
7915
7902
|
}
|
|
7916
7903
|
return grouped;
|
|
7917
7904
|
}
|
|
7918
|
-
function isQueryCanceled(error) {
|
|
7919
|
-
let current = error;
|
|
7920
|
-
for (let depth = 0; current && depth < 6; depth += 1) {
|
|
7921
|
-
if (typeof current !== "object") return false;
|
|
7922
|
-
if (current.code === QUERY_CANCELED) return true;
|
|
7923
|
-
current = current.cause;
|
|
7924
|
-
}
|
|
7925
|
-
return false;
|
|
7926
|
-
}
|
|
7927
7905
|
async function replayConversations(conversations, args) {
|
|
7928
7906
|
const { windowStartMs, nowMs, budgetMs } = args;
|
|
7929
7907
|
const startedAt = performance.now();
|
|
@@ -7946,7 +7924,7 @@ async function replayConversations(conversations, args) {
|
|
|
7946
7924
|
const ids = batch.map((row) => row.conversationId);
|
|
7947
7925
|
[rows, children] = await Promise.all([loadEvents(ids), loadChildAgents(ids)]);
|
|
7948
7926
|
} catch (error) {
|
|
7949
|
-
if (!
|
|
7927
|
+
if (!isPostgresErrorCode(error, QUERY_CANCELED)) throw error;
|
|
7950
7928
|
canceledBatches += 1;
|
|
7951
7929
|
continue;
|
|
7952
7930
|
}
|
|
@@ -8018,8 +7996,10 @@ async function backfillCacheWarmingGaps(args) {
|
|
|
8018
7996
|
await state.connect();
|
|
8019
7997
|
if (!await state.setIfNotExists(BACKFILL_KEY, "running", BACKFILL_CLAIM_TTL_MS)) return;
|
|
8020
7998
|
await withSpan("cache_warming.backfill", "cache_warming.backfill", {}, async (setSpanAttributes) => {
|
|
8021
|
-
const
|
|
8022
|
-
|
|
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));
|
|
8023
8003
|
const { periods, scanned, canceledBatches, budgetExceeded } = await scanIdlePeriods({
|
|
8024
8004
|
windowStartMs: args.nowMs - GLOBAL_GAPS_TTL_MS,
|
|
8025
8005
|
nowMs: args.nowMs,
|
|
@@ -8084,7 +8064,7 @@ async function backfillCacheWarmingGaps(args) {
|
|
|
8084
8064
|
* job whose lease expires, because its slices stopped or kept failing, is
|
|
8085
8065
|
* failed, and an admin can start a new one.
|
|
8086
8066
|
*/
|
|
8087
|
-
const JOB_KEY = "junior:cache_warming:savings_refill:
|
|
8067
|
+
const JOB_KEY = "junior:cache_warming:savings_refill:v2";
|
|
8088
8068
|
const SLICE_LOCK_KEY = "junior:cache_warming:savings_refill:v1:slice";
|
|
8089
8069
|
const SLICE_LOCK_TTL_MS = 5 * MINUTE_MS;
|
|
8090
8070
|
const START_LOCK_KEY = "junior:cache_warming:savings_refill:v1:start";
|
|
@@ -8454,15 +8434,16 @@ async function selectDoneRoots(rootIds, cutoffMs) {
|
|
|
8454
8434
|
}, cutoffMs));
|
|
8455
8435
|
}
|
|
8456
8436
|
/**
|
|
8457
|
-
* Archive
|
|
8458
|
-
* 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.
|
|
8459
8439
|
*/
|
|
8460
|
-
async function
|
|
8461
|
-
|
|
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)));
|
|
8462
8443
|
return (await getDb().update(juniorConversations).set({
|
|
8463
8444
|
archivedAt: run.now,
|
|
8464
8445
|
detailVersion: nextDetailVersion
|
|
8465
|
-
}).where(and(
|
|
8446
|
+
}).where(and(inArray(juniorConversations.conversationId, rootConversationIds), isNull(juniorConversations.archivedAt), sql`exists (${archivable})`)).returning({ conversationId: juniorConversations.conversationId })).length;
|
|
8466
8447
|
}
|
|
8467
8448
|
/** Archive every done conversation of one user and count the rows. */
|
|
8468
8449
|
async function archiveUserDoneConversations(run) {
|
|
@@ -8475,7 +8456,7 @@ async function archiveUserDoneConversations(run) {
|
|
|
8475
8456
|
if (rows.length === 0) break;
|
|
8476
8457
|
scanned += rows.length;
|
|
8477
8458
|
const rootIds = rows.map((row) => row.rootConversationId);
|
|
8478
|
-
|
|
8459
|
+
archived += await archiveRoots(run, await selectDoneRoots(rootIds, cutoffMs));
|
|
8479
8460
|
if (rows.length < AUTO_ARCHIVE_PAGE_SIZE) break;
|
|
8480
8461
|
after = rows.at(-1);
|
|
8481
8462
|
}
|
|
@@ -8609,11 +8590,11 @@ async function matchReplyToReviewItems(args) {
|
|
|
8609
8590
|
].join("\n")
|
|
8610
8591
|
});
|
|
8611
8592
|
const matched = /* @__PURE__ */ new Set();
|
|
8612
|
-
args.items.
|
|
8593
|
+
for (const [index, item] of args.items.entries()) {
|
|
8613
8594
|
const answer = result.answers[keys[index]];
|
|
8614
|
-
if (answer?.choice !== "answers")
|
|
8595
|
+
if (answer?.choice !== "answers") continue;
|
|
8615
8596
|
if ((answer.probabilities?.answers ?? 1) >= MATCH_CONFIDENCE_THRESHOLD) matched.add(item.id);
|
|
8616
|
-
}
|
|
8597
|
+
}
|
|
8617
8598
|
return matched;
|
|
8618
8599
|
}
|
|
8619
8600
|
// src/chat/review-items/actions.ts
|
|
@@ -8898,57 +8879,6 @@ async function stopConversation(args) {
|
|
|
8898
8879
|
throw error;
|
|
8899
8880
|
}
|
|
8900
8881
|
}
|
|
8901
|
-
// src/chat/sign-in/allowlist.ts
|
|
8902
|
-
/**
|
|
8903
|
-
* Domains that may use Junior. Slack authors must have a Slack profile email
|
|
8904
|
-
* on one of them, and dashboard Google sign-ins must come from a Google
|
|
8905
|
-
* Workspace account whose `hd` claim is one of them. Slack and the dashboard
|
|
8906
|
-
* share one list.
|
|
8907
|
-
*/
|
|
8908
|
-
/** Read a list env var: a JSON string array or comma-separated values. */
|
|
8909
|
-
function readEnvList(name) {
|
|
8910
|
-
const value = process.env[name]?.trim();
|
|
8911
|
-
if (!value) return void 0;
|
|
8912
|
-
if (!value.startsWith("[")) return value.split(",");
|
|
8913
|
-
let parsed;
|
|
8914
|
-
try {
|
|
8915
|
-
parsed = JSON.parse(value);
|
|
8916
|
-
} catch (error) {
|
|
8917
|
-
throw new Error(`${name} must be a JSON string array`, { cause: error });
|
|
8918
|
-
}
|
|
8919
|
-
const list = z.array(z.string()).safeParse(parsed);
|
|
8920
|
-
if (!list.success) throw new Error(`${name} must be a JSON string array`);
|
|
8921
|
-
return list.data;
|
|
8922
|
-
}
|
|
8923
|
-
/**
|
|
8924
|
-
* Resolve the allowed domains: the `createApp` option when set, else
|
|
8925
|
-
* `JUNIOR_ALLOWED_DOMAINS`. An empty list allows every domain.
|
|
8926
|
-
*/
|
|
8927
|
-
function resolveAllowedDomains(allowedDomains) {
|
|
8928
|
-
return [...new Set((allowedDomains ?? readEnvList("JUNIOR_ALLOWED_DOMAINS") ?? []).map((value) => value.trim().toLowerCase()).filter(Boolean))];
|
|
8929
|
-
}
|
|
8930
|
-
/**
|
|
8931
|
-
* Fail startup on the removed Google-specific names. Ignoring them would
|
|
8932
|
-
* leave the list empty, which lets every Slack workspace member in.
|
|
8933
|
-
*/
|
|
8934
|
-
function assertNoLegacyAllowedDomains(dashboardOptionKeys) {
|
|
8935
|
-
if (dashboardOptionKeys.includes("allowedGoogleDomains")) throw new Error("dashboard.allowedGoogleDomains was removed; set createApp({ allowedDomains }) instead");
|
|
8936
|
-
if (process.env["JUNIOR_DASHBOARD_GOOGLE_DOMAINS"]?.trim()) throw new Error("JUNIOR_DASHBOARD_GOOGLE_DOMAINS was removed; set JUNIOR_ALLOWED_DOMAINS instead");
|
|
8937
|
-
}
|
|
8938
|
-
/** Return whether a verified domain may use Junior. An empty list allows all. */
|
|
8939
|
-
function isAllowedDomain(domain, allowedDomains) {
|
|
8940
|
-
if (allowedDomains.length === 0) return true;
|
|
8941
|
-
return Boolean(domain && allowedDomains.includes(domain.toLowerCase()));
|
|
8942
|
-
}
|
|
8943
|
-
/**
|
|
8944
|
-
* Return whether a verified sign-in email is on an allowed domain. Sign-in
|
|
8945
|
-
* needs a configured list, so an empty list allows no email.
|
|
8946
|
-
*/
|
|
8947
|
-
function isAllowedSignInEmail(email, allowedDomains) {
|
|
8948
|
-
const normalized = email.trim().toLowerCase();
|
|
8949
|
-
const separator = normalized.lastIndexOf("@");
|
|
8950
|
-
return allowedDomains.length > 0 && separator > 0 && isAllowedDomain(normalized.slice(separator + 1), allowedDomains);
|
|
8951
|
-
}
|
|
8952
8882
|
// src/api/mentions.ts
|
|
8953
8883
|
function mentionedSlackUserIds(texts) {
|
|
8954
8884
|
const ids = texts.flatMap((text) => text ? slackMentionedUserIds(text) : []);
|
|
@@ -8963,12 +8893,12 @@ function mentionedSlackUserIds(texts) {
|
|
|
8963
8893
|
async function resolveMentions(executor, sources) {
|
|
8964
8894
|
const idsBySource = sources.map((source) => mentionedSlackUserIds(source.texts));
|
|
8965
8895
|
const idsByTenant = /* @__PURE__ */ new Map();
|
|
8966
|
-
sources.
|
|
8967
|
-
if (idsBySource[index].length === 0)
|
|
8896
|
+
for (const [index, source] of sources.entries()) {
|
|
8897
|
+
if (idsBySource[index].length === 0) continue;
|
|
8968
8898
|
const ids = idsByTenant.get(source.tenantId) ?? /* @__PURE__ */ new Set();
|
|
8969
8899
|
for (const id of idsBySource[index]) ids.add(id);
|
|
8970
8900
|
idsByTenant.set(source.tenantId, ids);
|
|
8971
|
-
}
|
|
8901
|
+
}
|
|
8972
8902
|
const peopleByTenant = new Map(await Promise.all([...idsByTenant].map(async ([tenantId, ids]) => [tenantId, await readMentionedPeople(executor, tenantId, [...ids])])));
|
|
8973
8903
|
return sources.map((source, index) => {
|
|
8974
8904
|
const people = peopleByTenant.get(source.tenantId);
|
|
@@ -9148,13 +9078,10 @@ async function attachPendingMentions(conversationId, messages) {
|
|
|
9148
9078
|
}
|
|
9149
9079
|
/** Read the viewer's pending authorization, also one saved before a deploy. */
|
|
9150
9080
|
async function findViewerWebAuthorization(conversationId, viewer) {
|
|
9151
|
-
|
|
9152
|
-
|
|
9153
|
-
|
|
9154
|
-
|
|
9155
|
-
});
|
|
9156
|
-
if (authorization) return authorization;
|
|
9157
|
-
}
|
|
9081
|
+
return (await Promise.all(webActorUserIds(viewer).map((actorId) => getWebAuthorization({
|
|
9082
|
+
actorId,
|
|
9083
|
+
conversationId
|
|
9084
|
+
})))).find((authorization) => authorization !== void 0);
|
|
9158
9085
|
}
|
|
9159
9086
|
/**
|
|
9160
9087
|
* Read accepted mailbox messages that have not reached durable history yet.
|
|
@@ -9394,9 +9321,10 @@ async function listConversationSidebarAnnotations(conversationIds, annotationsBy
|
|
|
9394
9321
|
});
|
|
9395
9322
|
if (objects.length) selected[conversationId] = objects;
|
|
9396
9323
|
}
|
|
9397
|
-
|
|
9324
|
+
const limit = pLimit(8);
|
|
9325
|
+
const results = await Promise.all(plugins.map((plugin) => limit(async () => {
|
|
9398
9326
|
const hook = plugin.hooks?.conversationSidebar;
|
|
9399
|
-
if (!hook)
|
|
9327
|
+
if (!hook) return [];
|
|
9400
9328
|
const annotationsByConversationId = Object.fromEntries(conversationIds.flatMap((conversationId) => {
|
|
9401
9329
|
const annotations = (annotationsByConversation.get(conversationId) ?? []).filter((annotation) => annotation.plugin === plugin.manifest.name);
|
|
9402
9330
|
return annotations.length > 0 ? [[conversationId, annotations]] : [];
|
|
@@ -9410,19 +9338,23 @@ async function listConversationSidebarAnnotations(conversationIds, annotationsBy
|
|
|
9410
9338
|
plugin: { name: plugin.manifest.name },
|
|
9411
9339
|
cache: createPluginCache(plugin.manifest.name)
|
|
9412
9340
|
});
|
|
9413
|
-
|
|
9414
|
-
if (!candidates.has(conversationId))
|
|
9341
|
+
return Object.entries(result.annotationsByConversationId).flatMap(([conversationId, annotations]) => {
|
|
9342
|
+
if (!candidates.has(conversationId)) return [];
|
|
9415
9343
|
const parsed = conversationSidebarAnnotationSchema.array().safeParse(annotations);
|
|
9416
|
-
|
|
9417
|
-
|
|
9418
|
-
|
|
9344
|
+
return parsed.success && parsed.data.length > 0 ? [{
|
|
9345
|
+
annotations: parsed.data,
|
|
9346
|
+
conversationId
|
|
9347
|
+
}] : [];
|
|
9348
|
+
});
|
|
9419
9349
|
} catch (error) {
|
|
9420
9350
|
logWarn("plugin.conversation_sidebar.hook.failed", {
|
|
9421
9351
|
"app.plugin.name": plugin.manifest.name,
|
|
9422
9352
|
"exception.message": error instanceof Error ? error.message : String(error)
|
|
9423
9353
|
});
|
|
9354
|
+
return [];
|
|
9424
9355
|
}
|
|
9425
|
-
}
|
|
9356
|
+
})));
|
|
9357
|
+
for (const { annotations, conversationId } of results.flat()) selected[conversationId] = [...selected[conversationId] ?? [], ...annotations];
|
|
9426
9358
|
return selected;
|
|
9427
9359
|
}
|
|
9428
9360
|
// src/chat/conversations/fork.ts
|
|
@@ -9904,7 +9836,8 @@ async function readConversationAgentTree(conversation, readAccess) {
|
|
|
9904
9836
|
readAutomationTitlesByConversationId(root ? [root] : []),
|
|
9905
9837
|
readFirstHumanMessageTexts(getDb(), root ? [root] : [])
|
|
9906
9838
|
]);
|
|
9907
|
-
|
|
9839
|
+
const limit = pLimit(8);
|
|
9840
|
+
return await Promise.all(ids.map((id) => limit(async () => {
|
|
9908
9841
|
const itemAccess = access.get(id);
|
|
9909
9842
|
if (root?.conversationId === id) return {
|
|
9910
9843
|
conversationId: id,
|
|
@@ -9931,7 +9864,7 @@ async function readConversationAgentTree(conversation, readAccess) {
|
|
|
9931
9864
|
...agent?.agentType ? { agentType: agent.agentType } : void 0,
|
|
9932
9865
|
...agent?.fork ? { fork: true } : void 0
|
|
9933
9866
|
};
|
|
9934
|
-
}));
|
|
9867
|
+
})));
|
|
9935
9868
|
}
|
|
9936
9869
|
// src/api/conversations/display-markdown.ts
|
|
9937
9870
|
function format(text, provider) {
|
|
@@ -11663,4 +11596,4 @@ function viewerWebMessages(messages, viewer) {
|
|
|
11663
11596
|
}] : [];
|
|
11664
11597
|
});
|
|
11665
11598
|
}
|
|
11666
|
-
export {
|
|
11599
|
+
export { publicAddressLookup as $, actOnReviewItem as A, readSavingsRefill as B, encodeConversationCursor as C, decodeImageId as Ct, resolveMentions as D, requireConversationPendingMessages as E, runAutoArchiveSweep as F, readHealthReport as G, startSavingsRefill as H, setConversationAutoArchive as I, readObjectLinkTypes as J, OBJECT_LINK_TTL_MS as K, DEFAULT_USER_SETTINGS as L, readReviewItemForUser as M, reviewItemChange as N, stopConversation as O, archiveViewerDoneConversations as P, isPublicAddress as Q, readUserSettings as R, decodeConversationCursor as S, IMAGE_WIDTHS as St, readConversationPendingMessages as T, backfillCacheWarmingGaps as U, runSavingsRefillSlice as V, GET as W, resolveObjectLinks as X, resolveObjectLinkNow as Y, guardedFetch as Z, readConversationEvents as _, SubscribedReplyReason as _t, decodePageCursor as a, slackInboundMessageId as at, createConversationForViewer as b, readFirstHumanMessageTexts as bt, reorderPinnedConversations as c, AGENT_DISPATCH_MAX_AGE_MS as ct, childAgentTotalsReport as d, recordSkippedConversationMessage as dt, createProductionConversationWorkOptions as et, readConversationTreeMetricsFromSql as f, createSlackWebApiStatusSender as ft, keepQuickQuestionForViewer as g, parseContent as gt, forkConversationForViewer as h, stripLeadingBotMention as ht, readConversationFeed as i, clearSlackPendingReactions as it, closeReviewItemsAnsweredByReply as j, ReviewItemActionError as k, readConversationDetail as l, enqueueAgentDispatch as lt, readConversationDetailEtag as m, startProcessingReaction as mt, steerConversationPendingMessagesForViewer as n, getProductionSlackAdapter as nt, encodePageCursor as o, normalizeIncomingSlackThreadId as ot, conversationVersionQuery as p, bindMessageAuthorIdentityId as pt, readLinkObjectType as q, conversationFeedVersionQuery as r, buildSlackInboundMessage as rt, pinConversation as s, withNormalizedThreadId as st, stopConversationTurnForViewer as t, createProductionSlackWebhookServices as tt, readConversationAuxiliaryCostsFromSql as u, failStoppedDispatch as ut, readConversationRecordFromSql as v, getThreadStopDecision as vt, cancelConversationPendingMessagesForViewer as w, requireWebMessageConversation as x, createViewerMcp as xt, appendConversationMessageForViewer as y, conversationSummaryFromStoredConversation as yt, updateUserSettings as z };
|