@sentry/junior 0.303.0 → 0.305.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-BdVnSuY5.js → adapter-context-BpvbUki8.js} +2 -2
- package/dist/{admin-AfeAdS3J.js → admin-CoDt35ny.js} +5 -5
- package/dist/{agent-runner-BP8_DLUv.js → agent-runner-C5d6rY5g.js} +600 -389
- package/dist/api/schema.d.ts +1 -1
- package/dist/api/schema.js +5 -5
- package/dist/api.d.ts +1 -1
- package/dist/api.js +59 -61
- package/dist/{app-Dd9v1mNx.d.ts → app-Cs157Zc5.d.ts} +5 -3
- package/dist/app.d.ts +1 -1
- package/dist/app.js +86 -82
- package/dist/{automation-D9MvhOWY.js → automation-CuA3yEcD.js} +1 -1
- package/dist/{background-compaction-queue-xaE05jxH.js → background-compaction-queue-BTqMIfTA.js} +7 -3
- package/dist/{briefs-D8i-dKTp.js → briefs-BRdznF7c.js} +11 -8
- package/dist/{catalog-runtime-d1EM6Z0V.js → catalog-runtime-J52Tej47.js} +1 -1
- package/dist/cli/chat.js +15 -15
- package/dist/cli/check.js +5 -5
- package/dist/cli/init.js +1 -1
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +5 -5
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +4 -4
- package/dist/{config-oGM7KA9M.js → config-CBZp0udd.js} +101 -7
- package/dist/{connections-BlikzEJv.js → connections-BYmuJ6Vm.js} +6 -6
- package/dist/{continue-in-slack-BZnYifiG.js → continue-in-slack-Cvot6S38.js} +8 -8
- package/dist/{conversation-CY1jnBiC.js → conversation-BOqdRtUx.js} +4 -12
- package/dist/{conversation-feed-BZJRk6UV.js → conversation-feed-CgpgP7yi.js} +35 -2
- package/dist/{conversation-privacy-Cx515ddM.js → conversation-privacy-D2pOzBNl.js} +10 -2
- package/dist/{conversation-turn-DAhRdX4m.js → conversation-turn-CI8WDpnK.js} +17 -17
- package/dist/{credential-sync-DfhmWFeo.js → credential-sync-COqnZ1Dx.js} +14 -14
- package/dist/{db-C-2tFxk3.js → db-DU84dCVu.js} +169 -6
- package/dist/{db-DPqcEM9_.d.ts → db-zbN5ZV_o.d.ts} +2 -2
- package/dist/{executor-NVfS8aQ2.js → executor-CFyrgOu1.js} +43 -9
- package/dist/{history-UZ3M2M9r.js → history-m2-ceTTX.js} +8 -2
- package/dist/{install-CHLrpRZc.js → install-CQ76CfRw.js} +2 -2
- package/dist/instrumentation.js +7 -3
- package/dist/{lineage-HGLhd_-N.js → lineage-DLd2UxVP.js} +2 -2
- package/dist/{logging-DiyqRLBx.js → logging-BPNTQVFu.js} +1 -1
- package/dist/{message-CkCOcbFH.js → message-BWJLeQ5e.js} +8 -8
- package/dist/{model-input-DmoPPtPE.js → model-input-DoM9Ht-d.js} +2 -2
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +5 -5
- package/dist/{oauth-callback-server-CIf_6YmA.js → oauth-callback-server-DeHbnAQl.js} +2 -2
- package/dist/{projection-DBq8tsA5.js → projection-CcFBVFUo.js} +552 -63
- package/dist/{prompt-D2KlJopL.js → prompt-C5LREK2p.js} +185 -12
- package/dist/{queue-DFaOscp5.js → queue-B2AAL3ym.js} +4 -4
- package/dist/{registry-Bu0Z9BEO.js → registry-BjZZqKqi.js} +1 -1
- package/dist/{resolve-DXuA3G0g.js → resolve-CeJgXuH1.js} +3 -3
- package/dist/{result-DpiNseDA.js → result-icDrueyB.js} +8 -8
- package/dist/{runner-iu1heRFv.js → runner-nVfMkMMB.js} +9 -9
- package/dist/{sandbox-egress-signals-2HFYDcQf.js → sandbox-egress-signals-H9vQ5qRf.js} +1 -1
- package/dist/{schema-DvfX3Gq_.js → schema-Bx0Mlo32.js} +3 -3
- package/dist/{schema-DHMOaRzC.d.ts → schema-CKcu-IK6.d.ts} +43 -11
- package/dist/{service-account-BcT5LR7V.js → service-account-DU5865XA.js} +6 -5
- package/dist/{service-account-xYkaQTrw.js → service-account-Dw06p3zm.js} +5 -5
- package/dist/{session-stop-BLLp1IP_.js → session-stop-uotLtp4g.js} +181 -59
- package/dist/{skills-CNAGH4ju.js → skills-Bex1EaO5.js} +2 -2
- package/dist/{slack-conversation-unfurl-DYnqe5ci.js → slack-conversation-unfurl-EPG3riWF.js} +12 -11
- package/dist/{spawn-cGasWW33.js → spawn-CoD3vDuS.js} +6 -6
- package/dist/{state-CDS6h_Wv.js → state-nCR4Muhn.js} +4 -4
- package/dist/{stop-DMMA67yT.js → stop-BFVd0P0m.js} +170 -65
- package/dist/{store-Dgs7Oe44.js → store-Ca6G962n.js} +5 -5
- package/dist/{task-queue-DcF0nhhz.js → task-queue-BLPZU6kC.js} +3 -3
- package/dist/{task-runner-BGXF7Fo7.js → task-runner-xsOPIxCZ.js} +7 -7
- package/dist/{thread-context-BPky1KBe.js → thread-context-BOvZhsKK.js} +8 -8
- package/dist/{turn-session-routing-DGvn9MSl.js → turn-session-routing-2bW2qfeb.js} +8 -8
- package/dist/{turn-user-message-19CkuUvM.js → turn-user-message-BrhuyYrH.js} +3 -3
- package/dist/{validation-lu1DgjNQ.js → validation-BnY9K5WB.js} +1 -1
- package/dist/{version-Uo3c94Dx.js → version-qROlRQGF.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-BPQHMx3-.js → viewer-CxUiOraX.js} +3 -3
- package/dist/{warmup-H8uLvW9e.js → warmup--Gkz7iB-.js} +79 -476
- package/dist/{worker-B-pM_-3K.js → worker-DJ8d9fmD.js} +7 -7
- package/migrations/0111_attachment_kinds.sql +14 -0
- package/migrations/0112_attachment_url_fill.sql +51 -0
- package/migrations/0113_attachment_url_index.sql +1 -0
- package/migrations/meta/0099_snapshot.json +102 -326
- package/migrations/meta/0111_snapshot.json +5011 -0
- package/migrations/meta/0112_snapshot.json +5011 -0
- package/migrations/meta/0113_snapshot.json +5033 -0
- package/migrations/meta/_journal.json +21 -0
- package/package.json +7 -7
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { $ as loadTurnCheckpoint,
|
|
2
|
-
import {
|
|
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 loadTurnCheckpoint, $n as applyPluginFormatMarkdown, A as latestConversationMessageSeq, Ai as getDashboardLinkFilter, Ao as readLatestConversationBrief, Bo as getSlackFileId, Co as conversationIsMemberRoot, D as estimateConversationMessagesTokens, Do as viewerMarksFromParticipant, Dr as closeReviewItem, E as buildConversationContext, Eo as conversationViewerMarks, Es as lookupSlackUserNames, F as turnHasReply, Fr as listWaitingConversations, Go as slackAttachmentsVersionQuery, Gr as isOnlyAssignee, H as PluginCredentialFailureError, Ho as readAttachmentVisionSummary, Ht as releaseInboundMessage, I as upsertConversationMessage, Ii as isDashboardLink, In as trimTrailingAssistantMessages, Io as buildSentryConversationUrl, K as AuthorizationFlowDisabledError, Li as parseDashboardConversationLink, M as normalizeConversationText, Mi as getDashboardPersonLink, Mo as readConversationEventPageAfter, Mr as getReviewItem, N as recordDeliveredAssistantMessage, No as readConversationEventPageAround, Ns as piMessageFromHistoryItem, O as getConversationMessageSlackTs, Oa as removeReactionFromMessage, P as trimConversationMessages, Pr as listReplyActionItems, Ri as parseDashboardPersonLink, Rr as takeReviewItem, S as resolveConversationTitle, So as conversationHasParticipantUser, Ss as listConversationAnnotationsById, To as conversationPinnedForUser, Ts as lookupSlackUser, V as createPluginEgress, Vr as canActOnReviewItem, Wo as recordSlackAttachment, Wr as canUserReadReviewItem, X as clearPendingAuth, Xr as reviewItemNeedsSomeone, Yn as createUserTokenStore, Zo as storeAttachment, _o as createPluginLogger, a as loadProjection, at as failTurnRecord, b as persistConversationMessages, ba as truncateStatusText, bn as persistWithRetry, bo as createConversationAccessReader, cr as getPlugins, cs as normalizeSlackConversationId, ct as listTurnSummaries, d as recordAuthorizationCompleted, di as cancelSubscriptions, ds as withSlackRetries, es as SlackActionError, et as lostWorkerBeforeFirstSave, fa as SLACK_USER_MENTION_RE, ga as normalizeSlackStatusText, h as recordSubscribedReplyRoute, i as loadConversationProjection, is as getSlackClient, it as completeTurnRecord, j as markConversationMessage, jo as readConversationEventPage, js as configValueSchema, k as isHumanConversationMessage, ki as getDashboardConversationLink, ks as createPluginCache, lt as recordTurnSummary, n as commitMessages, nt as saveTurnCheckpoint, o as loadTurnProjection, os as isDmChannel, qo as isFileAttachment, rs as getHeaderString, rt as abandonTurnRecord, ss as isSlackRequestTimeout, st as getTurnRecord, t as commitAcceptedReply, tn as buildTurnErrorResponse, ts as downloadPrivateSlackFile, tt as pauseLostWorkerTurn, ua as resolveBaseUrl, un as getAssistantReplyText, us as streamPrivateSlackFile, v as hydrateConversationMessages, va as slackMentionedUserIds, w as fallbackShortTitle, wo as conversationIsNotUnsubscribedRoot, xa as addReactionToMessage, xo as readConversationAccessFromSql, xs as listConversationAnnotations, y as persistConversationMessageWindow, ya as wrapBareSlackUserIds, yo as canAddConversationMessages, zo as notInheritedByForkChild } from "./projection-CcFBVFUo.js";
|
|
2
|
+
import { F as textCharsForTokens, P as estimateTextTokens, V as escapeXml, X as isProviderRetryError, c as getSlackClientSecret, i as getChatConfig, k as resolveGatewayModel, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, y as normalizeSlackEmojiName } from "./config-CBZp0udd.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-BPNTQVFu.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-qROlRQGF.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 {
|
|
8
|
-
import { D as juniorConversationAnnotations, F as juniorDestinations, M as
|
|
9
|
-
import { d as contextProvenance, p as instructionProvenanceFor, t as KNOWN_CONVERSATION_EVENT_TYPES } from "./history-
|
|
10
|
-
import { d as actorLogContext, f as credentialContextForActor } from "./registry-
|
|
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, c as completeDecision, o as isEventConversationMessage, u as completeText } from "./prompt-
|
|
16
|
-
import { f as identityAvatarUrl, g as userAvatarUrlsFromIdentities, h as readUserAvatarUrls } from "./viewer-
|
|
17
|
-
import {
|
|
7
|
+
import { A as conversationKindFromRow, D as postsRunNotices, E as isTopLevelKind, I as resolveActorIdentityId, K as readCachedUserByEmail, L as saveActorAvatar, Q as setStateValues, X as getStateAdapter, Z as getStateValues, _ as readConversationTrees, a as getConversationStore, at as parseSessionSource, b as lastMessageAtSql, dt as resolveRootConversationId, et as acquireActiveLock, f as copyMessageLinks, gt as createSlackDestination, h as conversationAncestors, j as locationFromRow, k as turnBehavior, lt as agentTurnUsageSchema, m as withConversationEventLock, mt as nextDetailVersion, o as getDb, ot as addAgentTurnUsage, q as createCache, r as getConversationEventStore, s as getSqlExecutor, ut as hasAgentTurnUsage, v as setArchivedAt, vt as requireSlackDestination, w as deliversFinalText, y as loadConversationSlackTenantIds } from "./db-DU84dCVu.js";
|
|
8
|
+
import { D as juniorConversationAnnotations, F as juniorUsers, I as juniorDestinations, M as juniorMessageAttachments, N as juniorConversations, O as juniorCodeChanges, P as juniorIdentities, T as juniorConversationEvents, g as juniorAgentInvocations, j as juniorAttachments, l as juniorReviewItems, s as juniorReviewItemConversations, v as juniorConversationParticipants, x as juniorConversationBriefs } from "./executor-CFyrgOu1.js";
|
|
9
|
+
import { d as contextProvenance, p as instructionProvenanceFor, t as KNOWN_CONVERSATION_EVENT_TYPES } from "./history-m2-ceTTX.js";
|
|
10
|
+
import { d as actorLogContext, f as credentialContextForActor } from "./registry-BjZZqKqi.js";
|
|
11
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-J52Tej47.js";
|
|
12
|
+
import { A as RetryableDeliveryError, N as shouldEmitDevAgentTrace, 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 } from "./agent-runner-C5d6rY5g.js";
|
|
13
|
+
import { d as PluginMcpClient, u as McpAuthorizationRequiredError, v as getMcpStoredOAuthCredentials } from "./service-account-DU5865XA.js";
|
|
14
|
+
import { i as webActorUserIds } from "./state-nCR4Muhn.js";
|
|
15
|
+
import { a as EVENT_SYSTEM_ACTOR, c as completeDecision, o as isEventConversationMessage, u as completeText } from "./prompt-C5LREK2p.js";
|
|
16
|
+
import { f as identityAvatarUrl, g as userAvatarUrlsFromIdentities, h as readUserAvatarUrls } from "./viewer-CxUiOraX.js";
|
|
17
|
+
import { J as readMessageAttachments, W as MAX_ATTACHMENT_BYTES, f as conversationEventPageSchema, u as conversationDetailReportSchema } from "./conversation-BOqdRtUx.js";
|
|
18
18
|
import { t as readJuniorSecret } from "./secrets-DHaJ5TTn.js";
|
|
19
|
-
import { G as
|
|
20
|
-
import {
|
|
21
|
-
import { C as markDispatchCompleted, F as readAutomationTitlesByConversationId, S as markDispatchBlocked, T as markDispatchRunning, _ as getDispatchTurnId, a as getPersistedThreadState, c as coerceThreadConversationState, d as confirmDispatchMailboxAppend, g as getDispatchRecord, h as getDispatchInputMessageId, i as getPersistedSandboxState, m as getDispatchIdForConversation, n as resolveTurnSessionRouting, o as persistThreadRuntimeState, p as getDispatchConversationId, r as getLocationConfigurationService, s as persistThreadStateById, t as resolveConversationRouting, u as claimDispatchMailboxAppend, w as markDispatchFailed, x as markDispatchAwaitingResume, y as isTerminalDispatchStatus } from "./turn-session-routing-
|
|
19
|
+
import { G as recordFinishedTurnForAutomatedLimit, I as maybePostAutomatedTurnLimitNotice, J as conversationSubtreeColumns, O as legacyWebMailboxMetadataSchema, R as resolveSlackReplyTarget, T as resolveMailboxTurnWork, X as isExperimentalFeatureEnabled, c as loadReviewItemInput, f as buildSteeringPiMessage, g as withoutSavedSteeringMessages, l as savedInputInstruction, o as skipInputAfterConversationStop, p as instructionActorFor, q as conversationSubtree, r as markConversationsStopped, z as sendSlackReply } from "./session-stop-uotLtp4g.js";
|
|
20
|
+
import { An as createPausedTurns, Dt as webActorFromUser, Et as recordWebConversationActivity, Fn as canJoinTurn, Hn as AgentRunError, In as canShareTurn, Jn as throwApiError, Mi as gapSegment, Mt as verifyAttachmentUploads, Nn as wakePausedTurn, Pn as getTurnAuthorization, Qn as parseSlackMessageReference, St as appendAndEnqueueWebMessage, Tt as createConversationId, Un as executeTurn, Vn as getWebAuthorization, Wt as getChildAgentLabel, Xn as renderAttachmentText, Zn as renderBlockText, _n as cancelSignInWait, _r as isConversationMember, br as listThreadReplies, c as isConversationWorkDone, cr as readSlackRawMessageContext, d as addHistoryPeriod, f as firstLiveSavingsDate, ft as conversationReadPositionQuery, gn as stopChildAgentsOf, gr as getConversationInfo, hn as stopChildAgentsBelow, hr as getChannelMessage, i as GLOBAL_GAPS_TTL_MS, ji as NO_REPLY_GAP_MS, jn as getPausedTurnRequest, ki as MINUTE_MS, kn as supersedeTurnForInput, kt as AttachmentUploadError, l as listConversationWork, li as readConversationSourceTask, lr as resolveSlackChannelIdFromMessage, m as replaceHistorySavings, mn as dropOwnUnreadLoopReplies, n as CONVERSATION_STATE_TTL_MS, o as segmentGapsKey, p as idlePeriodSavings, r as GLOBAL_GAPS_MAX, sr as parseSlackThreadId, t as ANSWER_TOOL_ENDINGS, ut as readLastUserMessageAtByConversation, v as connectedState, vr as isPublicSlackChannel, vt as deliverReviewItemChange, wt as createAndEnqueueConversation, xt as acceptsWebMessages, y as providerCacheTtlMs } from "./warmup--Gkz7iB-.js";
|
|
21
|
+
import { C as markDispatchCompleted, F as readAutomationTitlesByConversationId, S as markDispatchBlocked, T as markDispatchRunning, _ as getDispatchTurnId, a as getPersistedThreadState, c as coerceThreadConversationState, d as confirmDispatchMailboxAppend, g as getDispatchRecord, h as getDispatchInputMessageId, i as getPersistedSandboxState, m as getDispatchIdForConversation, n as resolveTurnSessionRouting, o as persistThreadRuntimeState, p as getDispatchConversationId, r as getLocationConfigurationService, s as persistThreadStateById, t as resolveConversationRouting, u as claimDispatchMailboxAppend, w as markDispatchFailed, x as markDispatchAwaitingResume, y as isTerminalDispatchStatus } from "./turn-session-routing-2bW2qfeb.js";
|
|
22
22
|
import { h as isVisionImageMediaType, l as isEmptyUserInputAnswer, m as detectImageMediaType, t as webMessageId, u as normalizeUserInputAnswer } from "./web-message-id-lNodcCOI.js";
|
|
23
|
-
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-
|
|
24
|
-
import { o as getVercelConversationWorkQueue, p as getTurnRequestDeadline } from "./background-compaction-queue-
|
|
25
|
-
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-
|
|
26
|
-
import { t as runWithSlackInstallation } from "./adapter-context-
|
|
27
|
-
import { D as
|
|
28
|
-
import { c as withTurnSpan, n as createConversationTurnWorker, o as getTurnInputSpanAttributes, r as canPauseConversationDelivery, s as turnInputTelemetry } from "./conversation-turn-
|
|
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 requireTurnFailureEventId, c as buildDeliveredTurnStatePatch, i as getAgentTurnDiagnosticsAttributes, l as loadPendingMessageCards, n as loadThreadContextTrimFloor, o as completeAuthPauseTurn, r as finalizeFailedTurnReplyWithEvent, s as persistAuthPauseTurnState, t as buildTurnThreadContext } from "./thread-context-
|
|
35
|
-
import { n as scheduleSessionCompletedPluginTasks } from "./task-runner-
|
|
36
|
-
import { r as canContinueInSlack } from "./continue-in-slack-
|
|
23
|
+
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-BrhuyYrH.js";
|
|
24
|
+
import { o as getVercelConversationWorkQueue, p as getTurnRequestDeadline } from "./background-compaction-queue-BTqMIfTA.js";
|
|
25
|
+
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-Ca6G962n.js";
|
|
26
|
+
import { t as runWithSlackInstallation } from "./adapter-context-BpvbUki8.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-CgpgP7yi.js";
|
|
28
|
+
import { c as withTurnSpan, n as createConversationTurnWorker, o as getTurnInputSpanAttributes, r as canPauseConversationDelivery, s as turnInputTelemetry } from "./conversation-turn-CI8WDpnK.js";
|
|
29
|
+
import { n as buildStoredAttachmentPromptText } from "./model-input-DoM9Ht-d.js";
|
|
30
|
+
import { i as enqueueAgentInvocationResult, n as createDeliverToParent, s as withAgentInvocationResultActors, t as createChildConversationWorker } from "./result-icDrueyB.js";
|
|
31
|
+
import { t as bindMessageAgent } from "./message-BWJLeQ5e.js";
|
|
32
|
+
import { t as readConversationLineage } from "./lineage-DLd2UxVP.js";
|
|
33
|
+
import { t as bindSpawnAgent } from "./spawn-CoD3vDuS.js";
|
|
34
|
+
import { a as requireTurnFailureEventId, c as buildDeliveredTurnStatePatch, i as getAgentTurnDiagnosticsAttributes, l as loadPendingMessageCards, n as loadThreadContextTrimFloor, o as completeAuthPauseTurn, r as finalizeFailedTurnReplyWithEvent, s as persistAuthPauseTurnState, t as buildTurnThreadContext } from "./thread-context-BOvZhsKK.js";
|
|
35
|
+
import { n as scheduleSessionCompletedPluginTasks } from "./task-runner-xsOPIxCZ.js";
|
|
36
|
+
import { r as canContinueInSlack } from "./continue-in-slack-Cvot6S38.js";
|
|
37
37
|
import * as z from "zod";
|
|
38
38
|
import { createHash, createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
39
39
|
import { and, asc, count, desc, eq, gt, gte, inArray, isNotNull, isNull, lte, ne, not, or, sql } from "drizzle-orm";
|
|
@@ -1055,6 +1055,7 @@ async function decideSubscribedThreadReply(args) {
|
|
|
1055
1055
|
questions: buildSubscribedReplyRouterQuestions(args.botUserName),
|
|
1056
1056
|
metadata: {
|
|
1057
1057
|
modelId: args.modelId,
|
|
1058
|
+
conversationId: args.input.context.conversationId,
|
|
1058
1059
|
threadId: args.input.context.threadId ?? "",
|
|
1059
1060
|
channelId: args.input.context.channelId ?? "",
|
|
1060
1061
|
actorId: args.input.context.actorId ?? "",
|
|
@@ -1256,10 +1257,17 @@ function getRunId(thread, message) {
|
|
|
1256
1257
|
return readOptionalStringField(thread, "runId") ?? readOptionalStringField(message, "runId");
|
|
1257
1258
|
}
|
|
1258
1259
|
function getChannelId(thread, message) {
|
|
1259
|
-
return
|
|
1260
|
+
return normalizeSlackConversationId(toOptionalString(thread.channelId)) ?? resolveSlackChannelIdFromMessage(message);
|
|
1260
1261
|
}
|
|
1261
|
-
|
|
1262
|
-
|
|
1262
|
+
/**
|
|
1263
|
+
* Read the Slack thread timestamp from the raw Slack event of a message:
|
|
1264
|
+
* `thread_ts`, or `ts` for a thread root. Do not parse `Thread.id` or
|
|
1265
|
+
* `Message.threadId`: a top-level dispatched post has a channel-level id with
|
|
1266
|
+
* no timestamp, and the raw event is the Slack source of truth.
|
|
1267
|
+
*/
|
|
1268
|
+
function getThreadTs(message) {
|
|
1269
|
+
const rawContext = readSlackRawMessageContext(message);
|
|
1270
|
+
return rawContext?.threadTs ?? rawContext?.messageTs;
|
|
1263
1271
|
}
|
|
1264
1272
|
/**
|
|
1265
1273
|
* Resolve Slack assistant-thread API context for the current turn.
|
|
@@ -1280,9 +1288,6 @@ function getAssistantThreadContext(message) {
|
|
|
1280
1288
|
threadTs
|
|
1281
1289
|
};
|
|
1282
1290
|
}
|
|
1283
|
-
const parsedThreadId = parseSlackThreadId(readOptionalStringField(message, "threadId"));
|
|
1284
|
-
if (!parsedThreadId || isDmChannel(parsedThreadId.channelId)) return;
|
|
1285
|
-
return parsedThreadId;
|
|
1286
1291
|
}
|
|
1287
1292
|
/** Resolve the native Slack timestamp for a message that can target Slack APIs. */
|
|
1288
1293
|
function getMessageTs(message) {
|
|
@@ -1524,7 +1529,7 @@ function createAcceptedSteeringDrain(hooks, options) {
|
|
|
1524
1529
|
}
|
|
1525
1530
|
function buildLogContext(deps, args) {
|
|
1526
1531
|
return {
|
|
1527
|
-
conversationId: args.
|
|
1532
|
+
conversationId: args.conversationId,
|
|
1528
1533
|
messageConversationId: args.threadId,
|
|
1529
1534
|
userId: args.actorId,
|
|
1530
1535
|
userName: args.actorUserName,
|
|
@@ -1544,7 +1549,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
1544
1549
|
/** Unsubscribe the thread and cancel resource watches for a stop decision. */
|
|
1545
1550
|
const maybeHandleThreadOptOutDecision = async (args) => {
|
|
1546
1551
|
if (!args.decision?.shouldUnsubscribe) return false;
|
|
1547
|
-
await deps.cancelWatches({ conversationId: args.
|
|
1552
|
+
await deps.cancelWatches({ conversationId: args.conversationId });
|
|
1548
1553
|
await args.thread.unsubscribe();
|
|
1549
1554
|
await args.beforeFirstResponsePost?.();
|
|
1550
1555
|
await args.thread.post(THREAD_OPTOUT_ACK);
|
|
@@ -1599,7 +1604,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
1599
1604
|
try {
|
|
1600
1605
|
const channelId = getChannelId(args.thread, args.message);
|
|
1601
1606
|
if (!channelId) throw new Error("Slack fallback error reply requires a channel id");
|
|
1602
|
-
const threadTs = getThreadTs(
|
|
1607
|
+
const threadTs = getThreadTs(args.message);
|
|
1603
1608
|
await sendSlackReply({
|
|
1604
1609
|
channelId,
|
|
1605
1610
|
conversationId: args.conversationId,
|
|
@@ -1615,9 +1620,10 @@ function createSlackTurnRuntime(deps) {
|
|
|
1615
1620
|
throw postError;
|
|
1616
1621
|
}
|
|
1617
1622
|
};
|
|
1618
|
-
const decideSteeringMessage = async (thread, candidate, conversationContext) => {
|
|
1623
|
+
const decideSteeringMessage = async (thread, candidate, conversationContext, conversationId) => {
|
|
1619
1624
|
const { message } = candidate;
|
|
1620
1625
|
const context = {
|
|
1626
|
+
conversationId,
|
|
1621
1627
|
threadId: getThreadId(thread, message),
|
|
1622
1628
|
actorId: message.author.userId,
|
|
1623
1629
|
channelId: getChannelId(thread, message),
|
|
@@ -1647,6 +1653,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
1647
1653
|
};
|
|
1648
1654
|
const logSkippedSubscribedDecision = (args) => {
|
|
1649
1655
|
withLogContext(logContext({
|
|
1656
|
+
conversationId: args.context.conversationId,
|
|
1650
1657
|
threadId: args.context.threadId,
|
|
1651
1658
|
actorId: args.context.actorId,
|
|
1652
1659
|
actorUserName: actorUserName(args.message),
|
|
@@ -1679,7 +1686,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
1679
1686
|
const selectAcceptedSteeringMessages = async (args) => {
|
|
1680
1687
|
const selected = [];
|
|
1681
1688
|
for (const candidate of args.messages) {
|
|
1682
|
-
const decision = await decideSteeringMessage(args.thread, candidate, args.conversationContext);
|
|
1689
|
+
const decision = await decideSteeringMessage(args.thread, candidate, args.conversationContext, args.conversationId);
|
|
1683
1690
|
selected.push({
|
|
1684
1691
|
context: decision.context,
|
|
1685
1692
|
decision: decision.decision,
|
|
@@ -1710,6 +1717,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
1710
1717
|
const handleSkippedSteeringMessages = async (args) => {
|
|
1711
1718
|
for (const skipped of args.skipped) {
|
|
1712
1719
|
await maybeHandleThreadOptOutDecision({
|
|
1720
|
+
conversationId: args.conversationId,
|
|
1713
1721
|
thread: args.thread,
|
|
1714
1722
|
decision: skipped.decision,
|
|
1715
1723
|
beforeFirstResponsePost: args.beforeFirstResponsePost
|
|
@@ -1744,7 +1752,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
1744
1752
|
};
|
|
1745
1753
|
return {
|
|
1746
1754
|
async handleNewMention(thread, message, hooks) {
|
|
1747
|
-
const conversationId = hooks
|
|
1755
|
+
const { conversationId } = hooks;
|
|
1748
1756
|
const processingReactions = createProcessingReactionTracker(thread);
|
|
1749
1757
|
let processingReaction;
|
|
1750
1758
|
const skippedSteeringMessages = [];
|
|
@@ -1756,6 +1764,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
1756
1764
|
conversationId,
|
|
1757
1765
|
pending: skippedSteeringMessages,
|
|
1758
1766
|
context: logContext({
|
|
1767
|
+
conversationId,
|
|
1759
1768
|
threadId: getThreadId(thread, message),
|
|
1760
1769
|
actorId: message.author.userId,
|
|
1761
1770
|
actorUserName: actorUserName(message),
|
|
@@ -1769,6 +1778,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
1769
1778
|
const channelId = getChannelId(thread, message);
|
|
1770
1779
|
const runId = getRunId(thread, message);
|
|
1771
1780
|
const context = logContext({
|
|
1781
|
+
conversationId,
|
|
1772
1782
|
threadId,
|
|
1773
1783
|
channelId,
|
|
1774
1784
|
actorId: message.author.userId,
|
|
@@ -1811,6 +1821,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
1811
1821
|
}),
|
|
1812
1822
|
selectMessages: (messages, drainContext) => selectAcceptedSteeringMessages({
|
|
1813
1823
|
conversationContext: drainContext?.conversationContext,
|
|
1824
|
+
conversationId,
|
|
1814
1825
|
messages,
|
|
1815
1826
|
thread
|
|
1816
1827
|
})
|
|
@@ -1833,6 +1844,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
1833
1844
|
});
|
|
1834
1845
|
} catch (error) {
|
|
1835
1846
|
const failureLogContext = logContext({
|
|
1847
|
+
conversationId,
|
|
1836
1848
|
threadId: getThreadId(thread, message),
|
|
1837
1849
|
actorId: message.author.userId,
|
|
1838
1850
|
actorUserName: actorUserName(message),
|
|
@@ -1881,6 +1893,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
1881
1893
|
conversationId,
|
|
1882
1894
|
pending: skippedSteeringMessages,
|
|
1883
1895
|
context: logContext({
|
|
1896
|
+
conversationId,
|
|
1884
1897
|
threadId: getThreadId(thread, message),
|
|
1885
1898
|
actorId: message.author.userId,
|
|
1886
1899
|
actorUserName: actorUserName(message),
|
|
@@ -1893,7 +1906,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
1893
1906
|
}
|
|
1894
1907
|
},
|
|
1895
1908
|
async handleSubscribedMessage(thread, message, hooks) {
|
|
1896
|
-
const conversationId = hooks
|
|
1909
|
+
const { conversationId } = hooks;
|
|
1897
1910
|
const processingReactions = createProcessingReactionTracker(thread);
|
|
1898
1911
|
let processingReaction;
|
|
1899
1912
|
const skippedSteeringMessages = [];
|
|
@@ -1905,6 +1918,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
1905
1918
|
conversationId,
|
|
1906
1919
|
pending: skippedSteeringMessages,
|
|
1907
1920
|
context: logContext({
|
|
1921
|
+
conversationId,
|
|
1908
1922
|
threadId: getThreadId(thread, message),
|
|
1909
1923
|
actorId: message.author.userId,
|
|
1910
1924
|
actorUserName: actorUserName(message),
|
|
@@ -1919,6 +1933,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
1919
1933
|
const runId = getRunId(thread, message);
|
|
1920
1934
|
const actorId = message.author.userId;
|
|
1921
1935
|
const turnContext = logContext({
|
|
1936
|
+
conversationId,
|
|
1922
1937
|
threadId,
|
|
1923
1938
|
actorId,
|
|
1924
1939
|
actorUserName: actorUserName(message),
|
|
@@ -1966,6 +1981,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
1966
1981
|
reason: stopDecision.reasonDetail ? `${stopDecision.reason}:${stopDecision.reasonDetail}` : stopDecision.reason
|
|
1967
1982
|
};
|
|
1968
1983
|
await maybeHandleThreadOptOutDecision({
|
|
1984
|
+
conversationId,
|
|
1969
1985
|
thread,
|
|
1970
1986
|
decision,
|
|
1971
1987
|
beforeFirstResponsePost: hooks.beforeFirstResponsePost
|
|
@@ -2010,6 +2026,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
2010
2026
|
context: threadContext
|
|
2011
2027
|
});
|
|
2012
2028
|
await maybeHandleThreadOptOutDecision({
|
|
2029
|
+
conversationId,
|
|
2013
2030
|
thread,
|
|
2014
2031
|
decision,
|
|
2015
2032
|
beforeFirstResponsePost: hooks.beforeFirstResponsePost
|
|
@@ -2046,6 +2063,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
2046
2063
|
context: threadContext
|
|
2047
2064
|
});
|
|
2048
2065
|
if (await maybeHandleThreadOptOutDecision({
|
|
2066
|
+
conversationId,
|
|
2049
2067
|
thread,
|
|
2050
2068
|
decision,
|
|
2051
2069
|
beforeFirstResponsePost: hooks.beforeFirstResponsePost
|
|
@@ -2089,6 +2107,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
2089
2107
|
}),
|
|
2090
2108
|
selectMessages: (messages, drainContext) => selectAcceptedSteeringMessages({
|
|
2091
2109
|
conversationContext: drainContext?.conversationContext ?? conversationContext,
|
|
2110
|
+
conversationId,
|
|
2092
2111
|
messages,
|
|
2093
2112
|
thread
|
|
2094
2113
|
})
|
|
@@ -2125,6 +2144,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
2125
2144
|
});
|
|
2126
2145
|
} catch (error) {
|
|
2127
2146
|
const failureLogContext = logContext({
|
|
2147
|
+
conversationId,
|
|
2128
2148
|
threadId: getThreadId(thread, message),
|
|
2129
2149
|
actorId: message.author.userId,
|
|
2130
2150
|
actorUserName: actorUserName(message),
|
|
@@ -2173,6 +2193,7 @@ function createSlackTurnRuntime(deps) {
|
|
|
2173
2193
|
conversationId,
|
|
2174
2194
|
pending: skippedSteeringMessages,
|
|
2175
2195
|
context: logContext({
|
|
2196
|
+
conversationId,
|
|
2176
2197
|
threadId: getThreadId(thread, message),
|
|
2177
2198
|
actorId: message.author.userId,
|
|
2178
2199
|
actorUserName: actorUserName(message),
|
|
@@ -2544,6 +2565,7 @@ async function resolveUserAttachmentsWithDeps(attachments, context, deps) {
|
|
|
2544
2565
|
"Return plain text only."
|
|
2545
2566
|
].join(" "),
|
|
2546
2567
|
metadata: {
|
|
2568
|
+
conversationId: context.conversationId ?? "",
|
|
2547
2569
|
threadId: context.threadId ?? "",
|
|
2548
2570
|
channelId: context.channelId ?? "",
|
|
2549
2571
|
actorId: context.actorId ?? "",
|
|
@@ -2608,6 +2630,7 @@ async function summarizeConversationImage(args, deps) {
|
|
|
2608
2630
|
"Return plain text only."
|
|
2609
2631
|
].join(" "),
|
|
2610
2632
|
metadata: {
|
|
2633
|
+
conversationId: args.context.conversationId ?? "",
|
|
2611
2634
|
threadId: args.context.threadId ?? "",
|
|
2612
2635
|
channelId: args.context.channelId ?? "",
|
|
2613
2636
|
actorId: args.context.actorId ?? "",
|
|
@@ -3412,7 +3435,7 @@ function createSlackTurn(deps) {
|
|
|
3412
3435
|
});
|
|
3413
3436
|
const destinationVisibility = conversationVisibilityFromSlackChannelType(slackChannelType);
|
|
3414
3437
|
const assistantThreadContext = getAssistantThreadContext(message);
|
|
3415
|
-
const threadTs = getThreadTs(
|
|
3438
|
+
const threadTs = getThreadTs(message);
|
|
3416
3439
|
const messageTs = getMessageTs(message);
|
|
3417
3440
|
const teamId = destination.teamId;
|
|
3418
3441
|
const source = options.execution?.source ?? createSlackSource({
|
|
@@ -3431,8 +3454,7 @@ function createSlackTurn(deps) {
|
|
|
3431
3454
|
});
|
|
3432
3455
|
const slackActionToken = readSlackActionToken(message);
|
|
3433
3456
|
const runId = options.execution?.dispatch?.id ?? getRunId(thread, message);
|
|
3434
|
-
const conversationId = options
|
|
3435
|
-
if (!conversationId) throw new Error("Slack reply execution requires a conversation id");
|
|
3457
|
+
const { conversationId } = options;
|
|
3436
3458
|
await withSpan("chat.reply", "chat.reply", {
|
|
3437
3459
|
conversationId,
|
|
3438
3460
|
messageConversationId: threadId,
|
|
@@ -4395,11 +4417,11 @@ async function seedConversationBackfill(thread, conversation, currentTurn, resol
|
|
|
4395
4417
|
/** Build the turn-state preparer from injected conversation services. */
|
|
4396
4418
|
function createPrepareTurnState(deps) {
|
|
4397
4419
|
return async function prepareTurnState(args) {
|
|
4398
|
-
const
|
|
4399
|
-
const existingState =
|
|
4400
|
-
const sandboxRef = getPersistedSandboxState(existingState
|
|
4420
|
+
const { conversationId } = args.context;
|
|
4421
|
+
const existingState = await getPersistedThreadState(conversationId);
|
|
4422
|
+
const sandboxRef = getPersistedSandboxState(existingState);
|
|
4401
4423
|
const conversation = coerceThreadConversationState(existingState);
|
|
4402
|
-
if (
|
|
4424
|
+
if (isVisionEnabled()) conversation.vision = await loadConversationVisionCache(conversationId);
|
|
4403
4425
|
await hydrateConversationMessages({
|
|
4404
4426
|
conversation,
|
|
4405
4427
|
conversationId
|
|
@@ -4434,19 +4456,19 @@ function createPrepareTurnState(deps) {
|
|
|
4434
4456
|
channelId: args.context.channelId,
|
|
4435
4457
|
actorId: args.context.actorId,
|
|
4436
4458
|
runId: args.context.runId,
|
|
4437
|
-
threadTs: getThreadTs(args.
|
|
4459
|
+
threadTs: getThreadTs(args.message)
|
|
4438
4460
|
});
|
|
4439
|
-
|
|
4461
|
+
await persistConversationVisionCache(conversationId, conversation.vision);
|
|
4440
4462
|
}
|
|
4441
4463
|
await persistConversationMessages({
|
|
4442
4464
|
conversation,
|
|
4443
4465
|
conversationId
|
|
4444
4466
|
});
|
|
4445
|
-
|
|
4467
|
+
await hydrateConversationMessages({
|
|
4446
4468
|
conversation,
|
|
4447
4469
|
conversationId
|
|
4448
4470
|
});
|
|
4449
|
-
if (await trimConversationMessages(conversation,
|
|
4471
|
+
if (await trimConversationMessages(conversation, () => loadThreadContextTrimFloor(conversationId)) && conversation.historyFromSeq !== void 0) await persistConversationMessageWindow({
|
|
4450
4472
|
conversationId,
|
|
4451
4473
|
historyFromSeq: conversation.historyFromSeq
|
|
4452
4474
|
});
|
|
@@ -4762,9 +4784,13 @@ function createSlackDispatchTurnRunner(options) {
|
|
|
4762
4784
|
await state.connect();
|
|
4763
4785
|
const conversationId = getDispatchConversationId(dispatch);
|
|
4764
4786
|
const adapter = options.getSlackAdapter();
|
|
4787
|
+
const slackThreadId = adapter.encodeThreadId({
|
|
4788
|
+
channel: dispatch.destination.channelId,
|
|
4789
|
+
threadTs: dispatch.destination.threadTs ?? ""
|
|
4790
|
+
});
|
|
4765
4791
|
const message = new Message({
|
|
4766
4792
|
id: getDispatchInputMessageId(dispatch.id),
|
|
4767
|
-
threadId:
|
|
4793
|
+
threadId: slackThreadId,
|
|
4768
4794
|
text: dispatch.input,
|
|
4769
4795
|
attachments: [],
|
|
4770
4796
|
formatted: {
|
|
@@ -4792,7 +4818,7 @@ function createSlackDispatchTurnRunner(options) {
|
|
|
4792
4818
|
const thread = new ThreadImpl({
|
|
4793
4819
|
adapter,
|
|
4794
4820
|
stateAdapter: state,
|
|
4795
|
-
id:
|
|
4821
|
+
id: slackThreadId,
|
|
4796
4822
|
channelId: dispatch.destination.channelId,
|
|
4797
4823
|
channelVisibility: dispatch.destinationVisibility === "public" ? "workspace" : "private",
|
|
4798
4824
|
currentMessage: message,
|
|
@@ -4875,8 +4901,8 @@ function createSlackRuntime(options) {
|
|
|
4875
4901
|
getPreparedConversationContext: (preparedState) => preparedState.conversationContext,
|
|
4876
4902
|
decideSubscribedReply: async (args) => {
|
|
4877
4903
|
const decision = await services.subscribedReplyPolicy(args);
|
|
4878
|
-
if (decision.costUsd !== void 0 && args.context.
|
|
4879
|
-
conversationId: args.context.
|
|
4904
|
+
if (decision.costUsd !== void 0 && args.context.runId) await recordSubscribedReplyRoute({
|
|
4905
|
+
conversationId: args.context.conversationId,
|
|
4880
4906
|
costUsd: decision.costUsd,
|
|
4881
4907
|
reason: decision.reason,
|
|
4882
4908
|
runId: args.context.runId,
|
|
@@ -6679,7 +6705,6 @@ function createConversationWork(options) {
|
|
|
6679
6705
|
}));
|
|
6680
6706
|
const childWorker = createChildConversationWorker(options.agentRunner, {
|
|
6681
6707
|
enqueueResult,
|
|
6682
|
-
maxAgentDepth: botConfig.maxAgentDepth,
|
|
6683
6708
|
queue: options.queue,
|
|
6684
6709
|
runTurn: conversationTurnWorker,
|
|
6685
6710
|
state: options.state
|
|
@@ -9591,6 +9616,11 @@ async function copyForkEvents(args) {
|
|
|
9591
9616
|
actorIdentityId: e.actorIdentityId,
|
|
9592
9617
|
createdAt: e.createdAt
|
|
9593
9618
|
}).from(e).where(and(eq(e.conversationId, args.sourceConversationId), inArray(e.seq, seqs))));
|
|
9619
|
+
await copyMessageLinks(getSqlExecutor(), {
|
|
9620
|
+
conversationId: args.conversationId,
|
|
9621
|
+
seqs,
|
|
9622
|
+
sourceConversationId: args.sourceConversationId
|
|
9623
|
+
});
|
|
9594
9624
|
}
|
|
9595
9625
|
function hasUnfinishedToolCalls(messages) {
|
|
9596
9626
|
const pending = /* @__PURE__ */ new Set();
|
|
@@ -11154,6 +11184,72 @@ async function readConversationFeedBriefs(db, conversationIds) {
|
|
|
11154
11184
|
}).from(juniorConversations).innerJoinLateral(latest, sql`true`).where(inArray(juniorConversations.conversationId, conversationIds));
|
|
11155
11185
|
return new Map(rows.map(({ conversationId, ...brief }) => [conversationId, conversationFeedBriefSchema.parse(brief)]));
|
|
11156
11186
|
}
|
|
11187
|
+
// src/api/conversations/feed-links.ts
|
|
11188
|
+
const RECENT_USE_LIMIT = 20;
|
|
11189
|
+
const CANDIDATE_LINK_LIMIT = 6;
|
|
11190
|
+
/** The URLs that a row's Annotations already show, as links compare them. */
|
|
11191
|
+
function annotationUrls(annotations) {
|
|
11192
|
+
return new Set((annotations ?? []).flatMap(({ url }) => {
|
|
11193
|
+
const href = safeLinkUrl(url);
|
|
11194
|
+
return href ? [href] : [];
|
|
11195
|
+
}));
|
|
11196
|
+
}
|
|
11197
|
+
/** The links a feed row shows, from its `feedLinksSql` candidates. */
|
|
11198
|
+
function pickFeedLinks(conversationId, urls, shown) {
|
|
11199
|
+
const links = [];
|
|
11200
|
+
for (const link of urls) {
|
|
11201
|
+
const href = safeLinkUrl(link);
|
|
11202
|
+
if (!href || links.includes(href) || shown.has(href) || parseDashboardConversationLink(href) === conversationId) continue;
|
|
11203
|
+
links.push(href);
|
|
11204
|
+
if (links.length >= 3) break;
|
|
11205
|
+
}
|
|
11206
|
+
return links;
|
|
11207
|
+
}
|
|
11208
|
+
/**
|
|
11209
|
+
* A feed row column with the newest distinct links of its Conversation,
|
|
11210
|
+
* newest message first and in text order within a message, or null. It is
|
|
11211
|
+
* a scalar subquery on the row read, so links cost no round trip of their
|
|
11212
|
+
* own. Links are private content: show them only where the viewer sees
|
|
11213
|
+
* private content. Only URLs leave the database, never message text.
|
|
11214
|
+
*/
|
|
11215
|
+
function feedLinksSql(db) {
|
|
11216
|
+
const m = juniorMessageAttachments;
|
|
11217
|
+
const recentUses = db.select({
|
|
11218
|
+
attachmentId: m.attachmentId,
|
|
11219
|
+
position: m.position,
|
|
11220
|
+
seq: m.seq
|
|
11221
|
+
}).from(m).where(eq(m.conversationId, juniorConversations.conversationId)).orderBy(desc(m.seq), asc(m.position)).limit(RECENT_USE_LIMIT).as("recent_uses");
|
|
11222
|
+
const distinctUses = db.selectDistinctOn([recentUses.attachmentId], {
|
|
11223
|
+
attachmentId: recentUses.attachmentId,
|
|
11224
|
+
position: recentUses.position,
|
|
11225
|
+
seq: recentUses.seq
|
|
11226
|
+
}).from(recentUses).orderBy(recentUses.attachmentId, desc(recentUses.seq), asc(recentUses.position)).as("distinct_uses");
|
|
11227
|
+
const candidates = db.select({
|
|
11228
|
+
attachmentId: distinctUses.attachmentId,
|
|
11229
|
+
position: distinctUses.position,
|
|
11230
|
+
seq: distinctUses.seq
|
|
11231
|
+
}).from(distinctUses).orderBy(desc(distinctUses.seq), asc(distinctUses.position)).limit(CANDIDATE_LINK_LIMIT).as("candidate_uses");
|
|
11232
|
+
const urls = db.select({ urls: sql`array_agg(${juniorAttachments.url} order by ${candidates.seq} desc, ${candidates.position})` }).from(candidates).innerJoin(juniorAttachments, and(eq(juniorAttachments.id, candidates.attachmentId), isNotNull(juniorAttachments.url), isNull(juniorAttachments.deleteRequestedAt)));
|
|
11233
|
+
return sql`(${urls})`;
|
|
11234
|
+
}
|
|
11235
|
+
// src/api/conversations/feed-media.ts
|
|
11236
|
+
/**
|
|
11237
|
+
* A feed row column with the newest stored files of its Conversation, or
|
|
11238
|
+
* null when it has none. It is a scalar subquery on the row read, so media
|
|
11239
|
+
* costs no round trip of its own. Files are private content: show them
|
|
11240
|
+
* only where the viewer sees private content. Only file metadata leaves the
|
|
11241
|
+
* database.
|
|
11242
|
+
*/
|
|
11243
|
+
function feedMediaSql(db) {
|
|
11244
|
+
const recentFiles = db.select({
|
|
11245
|
+
contentType: juniorAttachments.contentType,
|
|
11246
|
+
createdAt: juniorAttachments.createdAt,
|
|
11247
|
+
filename: juniorAttachments.title,
|
|
11248
|
+
id: juniorAttachments.id
|
|
11249
|
+
}).from(juniorAttachments).where(and(eq(juniorAttachments.conversationId, juniorConversations.conversationId), isFileAttachment, isNull(juniorAttachments.deleteRequestedAt))).orderBy(desc(juniorAttachments.createdAt), desc(juniorAttachments.id)).limit(3).as("recent_files");
|
|
11250
|
+
const files = db.select({ files: sql`jsonb_agg(jsonb_build_object('contentType', ${recentFiles.contentType}, 'filename', ${recentFiles.filename}, 'id', ${recentFiles.id}) order by ${recentFiles.createdAt} desc, ${recentFiles.id} desc)` }).from(recentFiles);
|
|
11251
|
+
return sql`(${files})`;
|
|
11252
|
+
}
|
|
11157
11253
|
// src/api/page-cursor.ts
|
|
11158
11254
|
/**
|
|
11159
11255
|
* Encode the position after the last row of a page as an opaque `cursor`
|
|
@@ -11215,12 +11311,14 @@ function conversationCodeRepositoryFilter(repositoryId, viewerUserId) {
|
|
|
11215
11311
|
)
|
|
11216
11312
|
)`, or(eq(juniorDestinations.visibility, "public"), viewerUserId ? conversationHasParticipantUser(viewerUserId) : void 0));
|
|
11217
11313
|
}
|
|
11218
|
-
async function conversationRows(db, { codeRepository, conversationIds, cursor, filter, includePrivateBriefs = false, limit, pinnedForUserId, query, status }) {
|
|
11314
|
+
async function conversationRows(db, { codeRepository, conversationIds, cursor, filter, include = [], includePrivateBriefs = false, limit, pinnedForUserId, query, status }) {
|
|
11219
11315
|
const rows = db.select({
|
|
11220
11316
|
...conversationRecordColumns,
|
|
11221
11317
|
activityCursor: sql`to_char(${juniorConversations.lastActivityAt} at time zone 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS.US"Z"')`,
|
|
11222
11318
|
lastMessageAt: sql`coalesce(${juniorConversations.lastMessageAt}, ${lastMessageAtSql(db)})`.mapWith(juniorConversations.lastMessageAt),
|
|
11223
|
-
awaitingAuthorization: treeAwaitsAuthorization(juniorConversations.conversationId)
|
|
11319
|
+
awaitingAuthorization: treeAwaitsAuthorization(juniorConversations.conversationId),
|
|
11320
|
+
links: include.includes("links") ? feedLinksSql(db) : sql`null`,
|
|
11321
|
+
media: include.includes("media") ? feedMediaSql(db) : sql`null`
|
|
11224
11322
|
}).from(juniorConversations).leftJoin(juniorDestinations, conversationRecordJoins.location).leftJoin(juniorIdentities, conversationRecordJoins.identity).leftJoin(juniorUsers, conversationRecordJoins.user).where(and(listedConversation(), conversationFeedMembershipFilter(status, filter), conversationIds ? inArray(juniorConversations.conversationId, conversationIds) : void 0, pinnedForUserId ? pinnedForUserId.pinned ? conversationPinnedForUser(pinnedForUserId.userId) : not(conversationPinnedForUser(pinnedForUserId.userId)) : void 0, cursor ? sql`(${juniorConversations.lastActivityAt} < ${cursor.at}::timestamptz or (${juniorConversations.lastActivityAt} = ${cursor.at}::timestamptz and ${juniorConversations.conversationId} > ${cursor.conversationId}))` : void 0, codeRepository ? conversationCodeRepositoryFilter(codeRepository.id, codeRepository.viewerUserId) : void 0, query ? or(sql`strpos(lower(coalesce(${juniorConversations.title}, '')), ${query}) > 0`, sql`exists (
|
|
11225
11323
|
select 1
|
|
11226
11324
|
from ${juniorConversationBriefs}
|
|
@@ -11241,13 +11339,14 @@ async function conversationRows(db, { codeRepository, conversationIds, cursor, f
|
|
|
11241
11339
|
* the first page. Needs you shows every conversation that waits on the
|
|
11242
11340
|
* viewer, so an old one must come back to the feed.
|
|
11243
11341
|
*/
|
|
11244
|
-
async function waitingRowsOutsidePage(db, filter, page) {
|
|
11342
|
+
async function waitingRowsOutsidePage(db, filter, page, include) {
|
|
11245
11343
|
const loaded = new Set(page.map((row) => row.conversation.conversationId));
|
|
11246
11344
|
const missing = (await listWaitingConversations(db, filter.userId)).map((waiting) => waiting.conversationId).filter((conversationId) => !loaded.has(conversationId));
|
|
11247
11345
|
if (missing.length === 0) return [];
|
|
11248
11346
|
return await conversationRows(db, {
|
|
11249
11347
|
conversationIds: missing,
|
|
11250
11348
|
filter,
|
|
11349
|
+
include,
|
|
11251
11350
|
includePrivateBriefs: true,
|
|
11252
11351
|
limit: missing.length,
|
|
11253
11352
|
status: "active"
|
|
@@ -11362,12 +11461,14 @@ async function readConversationFeedFromSql(options = {}) {
|
|
|
11362
11461
|
const cursor = options.cursor ? decodeConversationFeedCursor(options.cursor) : void 0;
|
|
11363
11462
|
const limit = options.limit ?? CONVERSATION_FEED_LIMIT;
|
|
11364
11463
|
const pinsFirst = filter?.kind === "viewer" && status === "active";
|
|
11464
|
+
const include = options.include ?? [];
|
|
11365
11465
|
const feedQuery = {
|
|
11366
11466
|
...options.codeRepositoryId ? { codeRepository: {
|
|
11367
11467
|
id: options.codeRepositoryId,
|
|
11368
11468
|
...options.viewer ? { viewerUserId: options.viewer.id } : void 0
|
|
11369
11469
|
} } : void 0,
|
|
11370
11470
|
filter,
|
|
11471
|
+
include,
|
|
11371
11472
|
includePrivateBriefs: filter?.kind === "viewer",
|
|
11372
11473
|
query,
|
|
11373
11474
|
status
|
|
@@ -11390,7 +11491,7 @@ async function readConversationFeedFromSql(options = {}) {
|
|
|
11390
11491
|
const page = pageRows.slice(0, limit);
|
|
11391
11492
|
const lastRow = pageRows.length > limit ? page.at(-1) : void 0;
|
|
11392
11493
|
const rows = [...pinnedRows, ...page];
|
|
11393
|
-
if (pinsFirst && !cursor) rows.push(...await waitingRowsOutsidePage(db, filter, rows));
|
|
11494
|
+
if (pinsFirst && !cursor) rows.push(...await waitingRowsOutsidePage(db, filter, rows, include));
|
|
11394
11495
|
const conversations = rows.map((row) => conversationFromRecordRow(row));
|
|
11395
11496
|
const conversationIds = conversations.map((conversation) => conversation.conversationId);
|
|
11396
11497
|
const [accessByConversation, viewerMarksByConversation, annotationsByConversation, auxiliaryCostsByRoot, metricsByRoot, participantsByConversation, teamDomainByTeamId, { work: conversationWork, lastUserMessageAt: lastUserMessageAtByConversation }, activityPreviewByConversation, briefByConversation, automationTitleByConversation, firstHumanMessageTextByConversation] = await Promise.all([
|
|
@@ -11448,6 +11549,8 @@ async function readConversationFeedFromSql(options = {}) {
|
|
|
11448
11549
|
const brief = access?.canViewPrivateContent ? briefByConversation.get(conversation.conversationId) : void 0;
|
|
11449
11550
|
const participants = access?.canViewPrivateContent ? participantsByConversation.get(conversation.conversationId) : void 0;
|
|
11450
11551
|
const threads = threadsByRoot.get(conversation.conversationId);
|
|
11552
|
+
const media = access?.canViewPrivateContent ? row.media : null;
|
|
11553
|
+
const links = access?.canViewPrivateContent && row.links ? pickFeedLinks(conversation.conversationId, row.links, annotationUrls(annotations)) : [];
|
|
11451
11554
|
const lastMessageAt = row.lastMessageAt?.toISOString();
|
|
11452
11555
|
return {
|
|
11453
11556
|
...summary,
|
|
@@ -11458,6 +11561,8 @@ async function readConversationFeedFromSql(options = {}) {
|
|
|
11458
11561
|
...participants && participants.length > 0 ? { participants } : void 0,
|
|
11459
11562
|
...activityPreview ? { activityPreview } : void 0,
|
|
11460
11563
|
...brief ? { brief } : void 0,
|
|
11564
|
+
...media?.length ? { media } : void 0,
|
|
11565
|
+
...links.length > 0 ? { links } : void 0,
|
|
11461
11566
|
...annotations.length > 0 ? { annotations } : void 0,
|
|
11462
11567
|
...sidebarAnnotationsByConversation[conversation.conversationId] ? { sidebarAnnotations: sidebarAnnotationsByConversation[conversation.conversationId] } : void 0,
|
|
11463
11568
|
isPriority: isConversationPriority({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as getConversationStore } from "./db-
|
|
2
|
-
import { p as logException } from "./logging-
|
|
3
|
-
import "./background-compaction-queue-
|
|
4
|
-
import { At as getConversationWorkStates$1, Bt as recordConversationRetry$1, Dt as dropPendingMessages$1, Et as drainConversationMailbox$1, Ft as listActiveConversationIds$1, Gt as startConversationWork$1, Ht as releaseInboundMessage, It as markConversationWorkEnqueued$1, Jt as takeDeferredConversationMove, Kt as steerWebPendingMessages$1, Mt as hasRunnableConversationWork, Ot as getConversation$1, St as completeConversationWork$1, Ut as requestAnotherSlice$1, Vt as releaseConversationWork$1, Wt as requestConversationWork$1, _t as checkInConversationWork$1, bt as clearExpiredConversationLease$1, ft as ackMessages$1, gt as cancelHumanFacingPendingMessages$1, ht as beginConversationResume$1, kt as getConversationWorkState$1, mt as appendInboundMessage, pt as appendExclusiveInboundMessage, qt as stopConversationWork$1, vt as claimInboundMessage$1, wt as deadLetterAttempt$1, xt as completeConversationStop$1, yt as clearConsumedConversationWake$1, zt as recordAttemptFailure$1 } from "./projection-
|
|
1
|
+
import { a as getConversationStore } from "./db-DU84dCVu.js";
|
|
2
|
+
import { p as logException } from "./logging-BPNTQVFu.js";
|
|
3
|
+
import "./background-compaction-queue-BTqMIfTA.js";
|
|
4
|
+
import { At as getConversationWorkStates$1, Bt as recordConversationRetry$1, Dt as dropPendingMessages$1, Et as drainConversationMailbox$1, Ft as listActiveConversationIds$1, Gt as startConversationWork$1, Ht as releaseInboundMessage, It as markConversationWorkEnqueued$1, Jt as takeDeferredConversationMove, Kt as steerWebPendingMessages$1, Mt as hasRunnableConversationWork, Ot as getConversation$1, St as completeConversationWork$1, Ut as requestAnotherSlice$1, Vt as releaseConversationWork$1, Wt as requestConversationWork$1, _t as checkInConversationWork$1, bt as clearExpiredConversationLease$1, ft as ackMessages$1, gt as cancelHumanFacingPendingMessages$1, ht as beginConversationResume$1, kt as getConversationWorkState$1, mt as appendInboundMessage, pt as appendExclusiveInboundMessage, qt as stopConversationWork$1, vt as claimInboundMessage$1, wt as deadLetterAttempt$1, xt as completeConversationStop$1, yt as clearConsumedConversationWake$1, zt as recordAttemptFailure$1 } from "./projection-CcFBVFUo.js";
|
|
5
5
|
// src/chat/task-execution/store.ts
|
|
6
6
|
function metadataStore(options) {
|
|
7
7
|
return options.conversationStore ?? getConversationStore();
|
|
@@ -304,7 +304,7 @@ async function runDeferredMove(args) {
|
|
|
304
304
|
const move = await takeDeferredConversationMove(args);
|
|
305
305
|
if (move === void 0) return;
|
|
306
306
|
try {
|
|
307
|
-
const { continueDeferredSlackClick } = await import("./slack-conversation-unfurl-
|
|
307
|
+
const { continueDeferredSlackClick } = await import("./slack-conversation-unfurl-EPG3riWF.js").then((n) => n.r);
|
|
308
308
|
await continueDeferredSlackClick(move, args.getSlackAdapter);
|
|
309
309
|
} catch (error) {
|
|
310
310
|
logException(error, "slack.continue_here.deferred.failed", { "gen_ai.conversation.id": args.conversationId });
|