@sentry/junior 0.279.0 → 0.281.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/{actor-B4DYygOB.js → actor-6jsm_v96.js} +1 -1
- package/dist/{adapter-phTTgw7H.js → adapter-RVQGEa98.js} +1 -1
- package/dist/{admin-PcpJDugZ.js → admin-DQpHx6Og.js} +1 -1
- package/dist/{agent-runner-DwvT1BY0.js → agent-runner-B229gXUY.js} +1002 -980
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +7 -7
- package/dist/api.d.ts +3 -3
- package/dist/api.js +188 -86
- package/dist/{app-DVs6noo7.d.ts → app-BQ9RZS43.d.ts} +4 -4
- package/dist/app.d.ts +1 -1
- package/dist/app.js +45 -38
- package/dist/{assistant-reply-BXfxczd7.js → assistant-reply-DQbtwc6j.js} +1 -1
- package/dist/{automation-BehArCcq.js → automation-sIsmIXH7.js} +2 -2
- package/dist/{background-compaction-queue-CcbuLJrZ.js → background-compaction-queue-oegyrxSe.js} +3 -3
- package/dist/{briefs-Dd_ezwED.js → briefs-BwzGWJgR.js} +5 -9
- package/dist/{catalog-runtime-BWVMeZhW.js → catalog-runtime-ClKzLvbN.js} +1 -1
- package/dist/cli/chat.js +15 -15
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-Bpxe4vKa.js → client-DkG0Tj53.js} +2 -2
- package/dist/{config-C_bmRhrJ.js → config-3AZ11aSM.js} +2 -2
- package/dist/{connections-B2rHe5W5.js → connections-C0ut_6RW.js} +11 -11
- package/dist/{conversation-CIiJtx5q.js → conversation-DNtcULyX.js} +45 -14
- package/dist/{conversation-pending-messages-CnBvE6-6.js → conversation-pending-messages-LlFnr9-m.js} +11 -3
- package/dist/{conversation-privacy-CzOfcz0U.js → conversation-privacy-DAgeBGLN.js} +1 -1
- package/dist/{credential-sync-Dal_unpv.js → credential-sync-Bg8NPuvj.js} +16 -16
- package/dist/{db-CyLrV9C7.d.ts → db-BCFM0CUX.d.ts} +2 -2
- package/dist/{executor-BfYH-Wws.js → executor-DLKnzP6S.js} +149 -6
- package/dist/instrumentation.js +2 -2
- package/dist/{logging-CkT3_Xxp.js → logging-DHzrobea.js} +1 -1
- package/dist/{media-DTAA8Qs_.js → media-Dq9_svfQ.js} +1 -1
- package/dist/{message-Q5dkgaJ5.js → message-LR8z5jXJ.js} +9 -9
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-BDRaqe8O.js → oauth-callback-server-EWdpj0_y.js} +2 -2
- package/dist/{oauth-relay-D0G3T16m.js → oauth-relay-D6xxVywK.js} +1 -1
- package/dist/{projection-DWxX7pb1.js → projection-Bhz1tp0G.js} +194 -119
- package/dist/{prompt--dwus7Y-.js → prompt-DI6KCtwb.js} +6 -27
- package/dist/{queue-C37RbDVc.d.ts → queue-CZyYgPF0.d.ts} +1 -1
- package/dist/{registry-DnrdeO4s.js → registry-EjhulgQW.js} +3 -3
- package/dist/{reporting-window-DgHgwQB3.js → reporting-window-B-QP9zX1.js} +28 -2
- package/dist/{resolve-C_QXfqD_.js → resolve-Cw6OW4Fj.js} +4 -4
- package/dist/{result-DNmOxT-N.js → result-BoD0jevy.js} +11 -11
- package/dist/{runner-zd_noJ1l.js → runner-D22bsBDS.js} +11 -11
- package/dist/{sandbox-egress-signals-DQjv-nbG.js → sandbox-egress-signals-BG5GYacQ.js} +1 -1
- package/dist/{schema-CNJNzvr8.js → schema-BN34Jy-U.js} +30 -7
- package/dist/{schema-e90H5FIN.d.ts → schema-CsqJzkP5.d.ts} +95 -13
- package/dist/{service-account-CCH2Hv4h.js → service-account-Dd1nnAQZ.js} +3 -3
- package/dist/{service-account-BK26XlHo.js → service-account-xo-CeMqI.js} +3 -3
- package/dist/{session-stop-6Tf--T7G.js → session-stop-CHSYB2uw.js} +13 -14
- package/dist/{skills-BNrk8gi4.js → skills-BGJr6xtW.js} +3 -3
- package/dist/{spawn-C75hAB9l.js → spawn-Cl8WS7zi.js} +2 -2
- package/dist/{stop-RYbf7PWi.js → stop-C9lHWpvl.js} +332 -149
- package/dist/{store-G3h2djJU.js → store-C4z8gOgZ.js} +3 -3
- package/dist/{store-CO5vGjwD.js → store-DeTnwVJt.js} +6 -6
- package/dist/{task-queue-DlN58XeM.js → task-queue-BBos68l0.js} +4 -4
- package/dist/{task-runner-B-Bdm23d.js → task-runner-BSF9zO-H.js} +8 -8
- package/dist/{thread-state-Cj_7Slru.js → thread-state-DGq1o5JX.js} +4 -4
- package/dist/{turn-failure-response-CE7gaoC7.js → turn-failure-response--9bA4uLP.js} +8 -8
- package/dist/{turn-lifecycle-7sXwXLJ6.js → turn-lifecycle-t5fimxwQ.js} +1 -1
- package/dist/{turn-session-routing-FBdaH1zf.js → turn-session-routing-RBtUe-3y.js} +10 -11
- package/dist/{validation-DLWxEzWW.js → validation-DrR0leBT.js} +1 -1
- package/dist/{version-DtQ8WFIZ.js → version-D_HFt_Dq.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-vsM8_90o.js → viewer-DWlpSFdj.js} +9 -8
- package/dist/{work-DsoFRO_0.js → work-pPoqtRea.js} +12 -12
- package/dist/{worker-6kZEsCXs.js → worker-CoVKgJ-O.js} +6 -6
- package/package.json +5 -5
- package/dist/agent-invocations-CUg_SODU.js +0 -181
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { i as getActiveSpan, r as continueTrace } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { $ as completeTurnRecord, $a as
|
|
3
|
-
import { a as completeText, c as resolveGatewayModel, m as escapeXml, r as completeDecision, x as isProviderRetryError } from "./client-
|
|
4
|
-
import { c as getSlackClientSecret, i as getChatConfig, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, v as normalizeSlackEmojiName, y as createS3AttachmentStorage } from "./config-
|
|
5
|
-
import { E as withSpan, G as toOptionalNumber, K as toOptionalString, S as setTags, T as withLogContext, W as isRecord, b as setSpanAttributes, f as logError, h as logWarn, m as logInfo, n as createChatSdkLogger, o as getActiveTraceContext, p as logException, s as getActiveTraceId, t as buildTurnFailureResponse, y as setSentryUser } from "./logging-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { g as instructionProvenanceFor, m as contextProvenance, n as detectImageMediaType, r as isVisionImageMediaType } from "./media-
|
|
11
|
-
import { d as actorLogContext, f as credentialContextForActor } from "./registry-
|
|
12
|
-
import { A as runWithSlackInstallation, At as withoutSavedSteeringMessages, Et as conversationSubtreeColumns, F as resolveSlackChannelIdFromThreadId, I as getConversationInfo, J as readConversationSourceTask, Lt as shouldEmitDevAgentTrace, M as parseSlackThreadId, N as readSlackRawMessageContext, Nt as RetryableDeliveryError, P as resolveSlackChannelIdFromMessage, R as listThreadReplies, S as createSlackReviewItemShow, Tt as conversationSubtree, a as buildAuthPauseResponse, b as renderAttachmentText, dt as recordWebConversationActivity, ft as webActorFromUser, i as measureTurnCompactionWait, kt as buildSteeringPiMessage, lt as createAndEnqueueConversation, m as latestProgressStatus, mt as decodeInputImages, n as executeAgentRun, ot as acceptsWebMessages, pt as resolveConversationDestination, rt as deliverReviewItemChange, st as appendAndEnqueueWebMessage, t as createAgentRunner, ut as createConversationId, vt as storeAttachment, x as renderBlockText, z as resolveDestinationVisibility } from "./agent-runner-
|
|
1
|
+
import { h as startSpan, i as getActiveSpan, r as continueTrace } from "./sentry-BRTJqumy.js";
|
|
2
|
+
import { $ as completeTurnRecord, $a as notInheritedByForkChild, $n as takeReviewItem, A as getConversationMessageSlackTs, Aa as createPluginLogger, Ai as removeReactionFromMessage, Ba as conversationViewerMarks, Ci as addReactionToMessage, D as buildConversationContext, E as appendThreadContextMessages, En as webActorUserIds, F as turnHasReply, Fa as conversationHasParticipantUser, Fi as SlackActionError, Ga as readLatestConversationBrief, H as AuthorizationFlowDisabledError, Ha as viewerConversationMembership, Hi as normalizeSlackConversationId, I as upsertConversationMessage, Ia as conversationIsMemberRoot, Ii as downloadPrivateSlackFile, J as wasPendingAuthStopped, Ja as readConversationEventPageAround, Jn as getReviewItem, K as clearPendingAuth, Ka as readConversationEventPage, La as conversationNotArchivedForEmail, Ln as getPlugins, Lr as verifyTimerWatchCredentialSubject, M as markConversationMessage, Ma as readConversationAccessFromSql, N as normalizeConversationText, Na as conversationArchivedForEmail, O as createConversationMemoryService, P as recordDeliveredAssistantMessage, Pa as conversationArchivedForUser, Q as abandonTurnRecord, R as PluginCredentialFailureError, Ra as conversationNotArchivedForUser, Ri as getHeaderString, Rr as JUNIOR_THREAD_STATE_TTL_MS, S as resolveConversationTitle, Si as truncateStatusText, Sn as isExperimentalFeatureEnabled, Ut as persistWithRetry, Va as readConversationViewerMarks, Vi as isDmChannel, Wi as withSlackRetries, Wn as closeReviewItem, X as loadTurnCheckpoint, Xn as listReplyActionItems, Z as saveTurnCheckpoint, Za as buildSentryConversationUrl, Zn as listWaitingConversations, _o as piMessageFromHistoryItem, a as loadProjection, an as trimTrailingAssistantMessages, ar as isOnlyAssignee, bi as normalizeSlackStatusText, co as listConversationAnnotations, d as recordAuthorizationCompleted, eo as getSlackFileId, et as failTurnRecord, fn as decideSubscribedThreadReply, fo as lookupSlackUser, h as recordSubscribedReplyRoute, ho as configValueSchema, i as loadConversationProjection, io as recordSlackAttachment, ir as canReadReviewItem, j as isHumanConversationMessage, k as estimateConversationContextTokens, ln as buildDeterministicAssistantMessageId, lo as listConversationAnnotationsById, lr as reviewItemNeedsUser, mn as getThreadStopDecision, n as commitMessages, no as readAttachmentVisionSummary, nr as canActOnReviewItem, nt as listTurnSummaries, o as loadTurnProjection, pn as getSubscribedReplyPreflightDecision, po as createPluginCache, qa as readConversationEventPageAfter, ro as readSlackAttachmentsVersion, rt as recordTurnSummary, t as commitAcceptedReply, tt as getTurnRecord, un as buildDeterministicTurnId, ur as reviewItemReaderForUser, v as hydrateConversationMessages, w as fallbackShortTitle, wn as createUserTokenStore, x as persistConversationMessageSummaries, xr as cancelSubscriptions, y as persistConversationMessages, za as conversationPinnedForUser, zi as getSlackClient, zt as buildTurnErrorResponse } from "./projection-Bhz1tp0G.js";
|
|
3
|
+
import { a as completeText, c as resolveGatewayModel, m as escapeXml, r as completeDecision, x as isProviderRetryError } from "./client-DkG0Tj53.js";
|
|
4
|
+
import { c as getSlackClientSecret, i as getChatConfig, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, v as normalizeSlackEmojiName, y as createS3AttachmentStorage } from "./config-3AZ11aSM.js";
|
|
5
|
+
import { E as withSpan, G as toOptionalNumber, K as toOptionalString, S as setTags, T as withLogContext, W as isRecord, b as setSpanAttributes, f as logError, h as logWarn, m as logInfo, n as createChatSdkLogger, o as getActiveTraceContext, p as logException, s as getActiveTraceId, t as buildTurnFailureResponse, y as setSentryUser } from "./logging-DHzrobea.js";
|
|
6
|
+
import { t as JUNIOR_VERSION } from "./version-D_HFt_Dq.js";
|
|
7
|
+
import { f as parseSlackTeamId, h as parseSlackMessageTs, i as isActorUserId, n as createSlackActor, o as isUserActor, r as createSlackResumeActor, s as parseActorUserId, t as createActor, u as parseSlackChannelId } from "./actor-6jsm_v96.js";
|
|
8
|
+
import { $ as agentTurnUsageSchema, A as loadConversationSlackTenantIds, C as getSqlExecutor, I as resolveActorIdentityId, J as nextDetailVersion, K as parseSessionSource, L as saveActorAvatar, N as locationFromRow, S as getDb, X as addAgentTurnUsage, et as hasAgentTurnUsage, f as identityAvatarUrl, h as readUserAvatarUrls, it as requireSlackDestination, k as withConversationEventLock, nt as createSlackDestination, q as conversationDetailTouch, tt as resolveRootConversationId, x as getConversationStore, y as getConversationEventStore } from "./viewer-DWlpSFdj.js";
|
|
9
|
+
import { A as juniorIdentities, M as juniorDestinations, O as conversationReadColumns, S as juniorConversationEvents, T as juniorCodeChanges, _ as juniorConversationParticipants, c as juniorReviewItems, g as juniorConversationReadPositions, j as juniorUsers, k as juniorConversations, o as juniorReviewItemConversations, y as juniorConversationBriefs } from "./executor-DLKnzP6S.js";
|
|
10
|
+
import { g as instructionProvenanceFor, m as contextProvenance, n as detectImageMediaType, r as isVisionImageMediaType } from "./media-Dq9_svfQ.js";
|
|
11
|
+
import { d as actorLogContext, f as credentialContextForActor } from "./registry-EjhulgQW.js";
|
|
12
|
+
import { A as runWithSlackInstallation, At as withoutSavedSteeringMessages, Et as conversationSubtreeColumns, F as resolveSlackChannelIdFromThreadId, I as getConversationInfo, J as readConversationSourceTask, Lt as shouldEmitDevAgentTrace, M as parseSlackThreadId, N as readSlackRawMessageContext, Nt as RetryableDeliveryError, P as resolveSlackChannelIdFromMessage, R as listThreadReplies, S as createSlackReviewItemShow, Tt as conversationSubtree, a as buildAuthPauseResponse, b as renderAttachmentText, dt as recordWebConversationActivity, ft as webActorFromUser, i as measureTurnCompactionWait, kt as buildSteeringPiMessage, lt as createAndEnqueueConversation, m as latestProgressStatus, mt as decodeInputImages, n as executeAgentRun, ot as acceptsWebMessages, pt as resolveConversationDestination, rt as deliverReviewItemChange, st as appendAndEnqueueWebMessage, t as createAgentRunner, ut as createConversationId, vt as storeAttachment, x as renderBlockText, z as resolveDestinationVisibility } from "./agent-runner-B229gXUY.js";
|
|
13
13
|
import { a as withLock, n as MUTATION_LOCK_TTL_MS, r as acquireActiveLock } from "./locks-D-0h111u.js";
|
|
14
|
-
import { r as getStateAdapter } from "./adapter-
|
|
15
|
-
import { R as readMessageAttachments, c as conversationDetailReportSchema, p as conversationFeedSchema, u as conversationEventPageSchema } from "./conversation-
|
|
16
|
-
import { a as EVENT_SYSTEM_ACTOR, o as isEventConversationMessage } from "./prompt
|
|
17
|
-
import { $ as markTurnFailed, G as TurnInputCommitLostError, J as isCooperativeTurnYieldError, K as TurnInputDeferredError, Q as markTurnCompleted, U as ConversationTurnBoundaryError, W as CooperativeTurnYieldError, X as isTurnInputDeferredError, Y as isTurnInputCommitLostError, Z as markTurnClosed, et as startActiveTurn, h as getChildAgentLabel, q as getConversationTurnBoundaryError } from "./store-
|
|
18
|
-
import { n as getAssistantReplyText, t as decideReply } from "./assistant-reply-
|
|
19
|
-
import { C as savedTurnInputMessages, E as maybePostAutomatedTurnLimitNotice, I as deliversFinalText, L as finishedRunReply, M as recordFinishedTurnForAutomatedLimit, O as resolveSlackReplyTarget, R as postsRunNotices, S as joinMailboxText, V as runDispatchOutcome, c as isEventMailboxMetadata, i as skipInputBeforeConversationStop, k as sendSlackReply, l as renderEventBatchText, s as eventBatchMessageMeta, u as timerWatchCredentialSubject, w as webConversationMessage } from "./session-stop-
|
|
20
|
-
import { _ as isEmptyUserInputAnswer, b as webMessageId, v as normalizeUserInputAnswer } from "./reporting-window-
|
|
21
|
-
import { g as getTurnRequestDeadline, l as getVercelConversationWorkQueue } from "./background-compaction-queue-
|
|
22
|
-
import { D as stopConversationWork, E as steerWebPendingMessages, a as cancelHumanFacingPendingMessages, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, r as appendAndEnqueueInboundMessage, w as requestConversationWork } from "./store-
|
|
23
|
-
import { _ as markDispatchCompleted, a as confirmDispatchMailboxAppend, d as getDispatchTurnId, g as markDispatchBlocked, h as markDispatchAwaitingResume, i as claimDispatchMailboxAppend, j as readAutomationTitlesByConversationId, l as getDispatchInputMessageId, n as resolveTurnSessionRouting, p as isTerminalDispatchStatus, s as getDispatchConversationId, t as resolveConversationRouting, u as getDispatchRecord, v as markDispatchFailed, y as markDispatchRunning } from "./turn-session-routing-
|
|
24
|
-
import { d as
|
|
25
|
-
import { a as withAgentInvocationResultActors, c as listActiveMailboxTurns, d as turnInputFactsFromConversationMessage, f as legacyWebMailboxMetadataSchema, l as resolveMailboxTurnWork, n as enqueueAgentInvocationResult, o as getAuthPausedConversationTurnId, s as getEventBatchDelayMs, t as createChildConversationWorker, u as sourceFromTurnInput } from "./result-
|
|
26
|
-
import { n as getTurnLifecycle, t as ConversationTurnLifecycleService } from "./turn-lifecycle-
|
|
27
|
-
import { o as AgentRunError, s as executeTurn } from "./work-
|
|
28
|
-
import { a as persistThreadStateById, i as persistThreadRuntimeState, n as getPersistedSandboxState, o as coerceThreadConversationState, r as getPersistedThreadState, t as getLocationConfigurationService } from "./thread-state-
|
|
29
|
-
import { c as deleteWebAuthorization, d as createPausedTurns, f as getPausedTurnRequest, h as getTurnAuthorization, l as getWebAuthorization, m as wakePausedTurn, s as createWebAuthorization } from "./connections-
|
|
30
|
-
import { t as bindMessageAgent } from "./message-
|
|
31
|
-
import { t as bindSpawnAgent } from "./spawn-
|
|
32
|
-
import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-
|
|
33
|
-
import { a as persistAuthPauseTurnState, c as getTurnUserSlackMessageTs, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, n as getAgentTurnDiagnosticsAttributes, o as getTurnUserMessage, r as requireTurnFailureEventId, s as getTurnUserReplyAttachmentContext, t as finalizeFailedTurnReplyWithEvent, u as loadPendingMessageCards } from "./turn-failure-response
|
|
14
|
+
import { r as getStateAdapter } from "./adapter-RVQGEa98.js";
|
|
15
|
+
import { R as readMessageAttachments, c as conversationDetailReportSchema, p as conversationFeedSchema, u as conversationEventPageSchema } from "./conversation-DNtcULyX.js";
|
|
16
|
+
import { a as EVENT_SYSTEM_ACTOR, o as isEventConversationMessage } from "./prompt-DI6KCtwb.js";
|
|
17
|
+
import { $ as markTurnFailed, G as TurnInputCommitLostError, J as isCooperativeTurnYieldError, K as TurnInputDeferredError, Q as markTurnCompleted, U as ConversationTurnBoundaryError, W as CooperativeTurnYieldError, X as isTurnInputDeferredError, Y as isTurnInputCommitLostError, Z as markTurnClosed, et as startActiveTurn, h as getChildAgentLabel, q as getConversationTurnBoundaryError } from "./store-DeTnwVJt.js";
|
|
18
|
+
import { n as getAssistantReplyText, t as decideReply } from "./assistant-reply-DQbtwc6j.js";
|
|
19
|
+
import { C as savedTurnInputMessages, E as maybePostAutomatedTurnLimitNotice, I as deliversFinalText, L as finishedRunReply, M as recordFinishedTurnForAutomatedLimit, O as resolveSlackReplyTarget, R as postsRunNotices, S as joinMailboxText, V as runDispatchOutcome, c as isEventMailboxMetadata, i as skipInputBeforeConversationStop, k as sendSlackReply, l as renderEventBatchText, s as eventBatchMessageMeta, u as timerWatchCredentialSubject, w as webConversationMessage } from "./session-stop-CHSYB2uw.js";
|
|
20
|
+
import { _ as isEmptyUserInputAnswer, b as webMessageId, v as normalizeUserInputAnswer } from "./reporting-window-B-QP9zX1.js";
|
|
21
|
+
import { g as getTurnRequestDeadline, l as getVercelConversationWorkQueue } from "./background-compaction-queue-oegyrxSe.js";
|
|
22
|
+
import { D as stopConversationWork, E as steerWebPendingMessages, a as cancelHumanFacingPendingMessages, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, r as appendAndEnqueueInboundMessage, w as requestConversationWork } from "./store-C4z8gOgZ.js";
|
|
23
|
+
import { _ as markDispatchCompleted, a as confirmDispatchMailboxAppend, d as getDispatchTurnId, g as markDispatchBlocked, h as markDispatchAwaitingResume, i as claimDispatchMailboxAppend, j as readAutomationTitlesByConversationId, l as getDispatchInputMessageId, n as resolveTurnSessionRouting, p as isTerminalDispatchStatus, s as getDispatchConversationId, t as resolveConversationRouting, u as getDispatchRecord, v as markDispatchFailed, y as markDispatchRunning } from "./turn-session-routing-RBtUe-3y.js";
|
|
24
|
+
import { d as apiErrorSchema, f as healthReportSchema, s as conversationPendingMessagesReportSchema } from "./conversation-pending-messages-LlFnr9-m.js";
|
|
25
|
+
import { a as withAgentInvocationResultActors, c as listActiveMailboxTurns, d as turnInputFactsFromConversationMessage, f as legacyWebMailboxMetadataSchema, l as resolveMailboxTurnWork, n as enqueueAgentInvocationResult, o as getAuthPausedConversationTurnId, s as getEventBatchDelayMs, t as createChildConversationWorker, u as sourceFromTurnInput } from "./result-BoD0jevy.js";
|
|
26
|
+
import { n as getTurnLifecycle, t as ConversationTurnLifecycleService } from "./turn-lifecycle-t5fimxwQ.js";
|
|
27
|
+
import { o as AgentRunError, s as executeTurn } from "./work-pPoqtRea.js";
|
|
28
|
+
import { a as persistThreadStateById, i as persistThreadRuntimeState, n as getPersistedSandboxState, o as coerceThreadConversationState, r as getPersistedThreadState, t as getLocationConfigurationService } from "./thread-state-DGq1o5JX.js";
|
|
29
|
+
import { c as deleteWebAuthorization, d as createPausedTurns, f as getPausedTurnRequest, h as getTurnAuthorization, l as getWebAuthorization, m as wakePausedTurn, s as createWebAuthorization } from "./connections-C0ut_6RW.js";
|
|
30
|
+
import { t as bindMessageAgent } from "./message-LR8z5jXJ.js";
|
|
31
|
+
import { t as bindSpawnAgent } from "./spawn-Cl8WS7zi.js";
|
|
32
|
+
import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-BSF9zO-H.js";
|
|
33
|
+
import { a as persistAuthPauseTurnState, c as getTurnUserSlackMessageTs, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, n as getAgentTurnDiagnosticsAttributes, o as getTurnUserMessage, r as requireTurnFailureEventId, s as getTurnUserReplyAttachmentContext, t as finalizeFailedTurnReplyWithEvent, u as loadPendingMessageCards } from "./turn-failure-response--9bA4uLP.js";
|
|
34
34
|
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
35
|
-
import
|
|
35
|
+
import * as z from "zod";
|
|
36
36
|
import { and, asc, desc, eq, gt, inArray, isNotNull, isNull, lte, max, ne, or, sql } from "drizzle-orm";
|
|
37
37
|
import { conversationSidebarAnnotationSchema, createSlackSource, objectTypeSchema } from "@sentry/junior-plugin-api";
|
|
38
38
|
import { alias } from "drizzle-orm/pg-core";
|
|
@@ -449,7 +449,27 @@ function noStoreInit(init) {
|
|
|
449
449
|
}
|
|
450
450
|
/** Serialize a REST response only after it satisfies its declared schema. */
|
|
451
451
|
function jsonResponse(schema, value, init) {
|
|
452
|
-
return
|
|
452
|
+
return startSpan({
|
|
453
|
+
name: "Write API response",
|
|
454
|
+
op: "serialize"
|
|
455
|
+
}, (span) => {
|
|
456
|
+
const startedAt = performance.now();
|
|
457
|
+
const parsed = schema.parse(value);
|
|
458
|
+
const parsedAt = performance.now();
|
|
459
|
+
const body = JSON.stringify(parsed);
|
|
460
|
+
span.setAttributes({
|
|
461
|
+
"app.api.response.chars": body.length,
|
|
462
|
+
"app.api.response.json_stringify_ms": Math.round(performance.now() - parsedAt),
|
|
463
|
+
"app.api.response.schema_parse_ms": Math.round(parsedAt - startedAt)
|
|
464
|
+
});
|
|
465
|
+
const responseInit = noStoreInit(init);
|
|
466
|
+
const headers = new Headers(responseInit.headers);
|
|
467
|
+
if (!headers.has("content-type")) headers.set("content-type", "application/json");
|
|
468
|
+
return new Response(body, {
|
|
469
|
+
...responseInit,
|
|
470
|
+
headers
|
|
471
|
+
});
|
|
472
|
+
});
|
|
453
473
|
}
|
|
454
474
|
/** Return an empty personalized API response with no-store caching. */
|
|
455
475
|
function emptyResponse(status = 204) {
|
|
@@ -7397,6 +7417,8 @@ const CURSOR_CONTEXT = "junior-conversation-report-cursor";
|
|
|
7397
7417
|
const conversationCursorPayloadSchema = z.object({
|
|
7398
7418
|
conversationId: z.string().min(1),
|
|
7399
7419
|
seq: z.number().int().min(-1),
|
|
7420
|
+
/** Transcript version of the detail that issued an `appendCursor`. */
|
|
7421
|
+
transcript: z.string().min(1).optional(),
|
|
7400
7422
|
version: z.literal(1)
|
|
7401
7423
|
}).strict();
|
|
7402
7424
|
function cursorSecret() {
|
|
@@ -7426,7 +7448,10 @@ function decodeConversationCursor(args) {
|
|
|
7426
7448
|
try {
|
|
7427
7449
|
const parsed = conversationCursorPayloadSchema.parse(JSON.parse(Buffer.from(encoded, "base64url").toString("utf8")));
|
|
7428
7450
|
if (parsed.conversationId !== args.conversationId) return;
|
|
7429
|
-
return {
|
|
7451
|
+
return {
|
|
7452
|
+
seq: parsed.seq,
|
|
7453
|
+
...parsed.transcript ? { transcript: parsed.transcript } : void 0
|
|
7454
|
+
};
|
|
7430
7455
|
} catch {
|
|
7431
7456
|
return;
|
|
7432
7457
|
}
|
|
@@ -8119,7 +8144,6 @@ function briefMentionTexts(brief) {
|
|
|
8119
8144
|
brief.intent,
|
|
8120
8145
|
brief.outcome.text,
|
|
8121
8146
|
...brief.decisions.flatMap((decision) => [decision.text, decision.by]),
|
|
8122
|
-
...brief.openDecisions.flatMap((decision) => [decision.text, decision.owner]),
|
|
8123
8147
|
...brief.facts
|
|
8124
8148
|
];
|
|
8125
8149
|
}
|
|
@@ -8857,31 +8881,27 @@ async function readConversationFeed(options = {}) {
|
|
|
8857
8881
|
return conversationFeedSchema.parse(await readConversationFeedFromSql(options));
|
|
8858
8882
|
}
|
|
8859
8883
|
// src/api/conversations/event-list.ts
|
|
8860
|
-
/** Read one bounded page of reporting events before, after, or around a
|
|
8884
|
+
/** Read one bounded page of reporting events before, after, or around a boundary. */
|
|
8861
8885
|
async function readConversationEvents(conversationId, boundary, options = {}) {
|
|
8862
8886
|
const record = await readConversationRecordFromSql(conversationId);
|
|
8863
8887
|
if (!record) return void 0;
|
|
8864
|
-
const
|
|
8865
|
-
conversationId,
|
|
8866
|
-
cursor: "after" in boundary ? boundary.after : "around" in boundary ? boundary.around : boundary.before
|
|
8867
|
-
});
|
|
8868
|
-
if (!cursor) throwApiError(400, "Invalid conversation cursor.");
|
|
8888
|
+
const position = await boundaryPosition(conversationId, boundary);
|
|
8869
8889
|
const canExposePayload = (await readConversationAccessFromSql(getDb(), [conversationId], options.viewer)).get(conversationId)?.canViewPrivateContent ?? false;
|
|
8870
8890
|
const transcriptPurgedAtMs = record.conversation.transcriptPurgedAtMs;
|
|
8871
8891
|
const pageArgs = {
|
|
8872
8892
|
canExposePayload,
|
|
8873
8893
|
conversationId,
|
|
8874
|
-
limit: options.limit ??
|
|
8894
|
+
limit: options.limit ?? 150
|
|
8875
8895
|
};
|
|
8876
|
-
const page = transcriptPurgedAtMs !== void 0 ? { events: [] } : "after"
|
|
8896
|
+
const page = transcriptPurgedAtMs !== void 0 ? { events: [] } : position.direction === "after" ? await readConversationEventPageAfter(getSqlExecutor(), {
|
|
8877
8897
|
...pageArgs,
|
|
8878
|
-
afterSeq:
|
|
8879
|
-
}) : "around"
|
|
8898
|
+
afterSeq: position.seq
|
|
8899
|
+
}) : position.direction === "around" ? await readConversationEventPageAround(getSqlExecutor(), {
|
|
8880
8900
|
...pageArgs,
|
|
8881
|
-
seq:
|
|
8901
|
+
seq: position.seq
|
|
8882
8902
|
}) : await readConversationEventPage(getSqlExecutor(), {
|
|
8883
8903
|
...pageArgs,
|
|
8884
|
-
beforeSeq:
|
|
8904
|
+
beforeSeq: position.seq
|
|
8885
8905
|
});
|
|
8886
8906
|
return conversationEventPageSchema.parse(await conversationEventPageReport(getSqlExecutor(), {
|
|
8887
8907
|
conversationId,
|
|
@@ -8892,6 +8912,39 @@ async function readConversationEvents(conversationId, boundary, options = {}) {
|
|
|
8892
8912
|
page
|
|
8893
8913
|
}));
|
|
8894
8914
|
}
|
|
8915
|
+
/** Resolve a page boundary to a direction and an event seq. */
|
|
8916
|
+
async function boundaryPosition(conversationId, boundary) {
|
|
8917
|
+
if ("event" in boundary) return {
|
|
8918
|
+
direction: "around",
|
|
8919
|
+
seq: boundary.event
|
|
8920
|
+
};
|
|
8921
|
+
if ("turn" in boundary) {
|
|
8922
|
+
const seq = await readTurnStartedSeq(conversationId, boundary.turn);
|
|
8923
|
+
if (seq === void 0) throwApiError(404, "Turn not found.");
|
|
8924
|
+
return {
|
|
8925
|
+
direction: "around",
|
|
8926
|
+
seq
|
|
8927
|
+
};
|
|
8928
|
+
}
|
|
8929
|
+
const [direction, value] = "after" in boundary ? ["after", boundary.after] : "around" in boundary ? ["around", boundary.around] : ["before", boundary.before];
|
|
8930
|
+
const cursor = decodeConversationCursor({
|
|
8931
|
+
conversationId,
|
|
8932
|
+
cursor: value
|
|
8933
|
+
});
|
|
8934
|
+
if (!cursor) throwApiError(400, "Invalid conversation cursor.");
|
|
8935
|
+
return {
|
|
8936
|
+
direction,
|
|
8937
|
+
seq: cursor.seq
|
|
8938
|
+
};
|
|
8939
|
+
}
|
|
8940
|
+
/**
|
|
8941
|
+
* Find the event that started a Turn. The `(conversation_id, type, seq)`
|
|
8942
|
+
* index reads only this Conversation's `turn_started` rows.
|
|
8943
|
+
*/
|
|
8944
|
+
async function readTurnStartedSeq(conversationId, turnId) {
|
|
8945
|
+
const [row] = await getDb().select({ seq: juniorConversationEvents.seq }).from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, conversationId), eq(juniorConversationEvents.type, "turn_started"), sql`${juniorConversationEvents.payload}->>'turnId' = ${turnId}`)).limit(1);
|
|
8946
|
+
return row?.seq;
|
|
8947
|
+
}
|
|
8895
8948
|
/** Attach mentions and signed cursors to one bounded page of events. */
|
|
8896
8949
|
async function conversationEventPageReport(executor, args) {
|
|
8897
8950
|
const { conversationId, page } = args;
|
|
@@ -8907,6 +8960,57 @@ async function conversationEventPageReport(executor, args) {
|
|
|
8907
8960
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8908
8961
|
};
|
|
8909
8962
|
}
|
|
8963
|
+
// src/api/conversations/agent-tree.ts
|
|
8964
|
+
/** Bound the parent chain that one agent tree reads. */
|
|
8965
|
+
const MAX_AGENT_TREE_DEPTH = 16;
|
|
8966
|
+
const CHILD_LABEL = "Subagent";
|
|
8967
|
+
async function readParentConversationId(conversationId) {
|
|
8968
|
+
const [row] = await getDb().select({ parentId: juniorConversations.parentConversationId }).from(juniorConversations).where(eq(juniorConversations.conversationId, conversationId));
|
|
8969
|
+
return row?.parentId ?? void 0;
|
|
8970
|
+
}
|
|
8971
|
+
/**
|
|
8972
|
+
* Read the agent tree of a child Conversation: its parent chain, root first,
|
|
8973
|
+
* with the child last. Returns undefined for a root Conversation. Each
|
|
8974
|
+
* Conversation has its own access check, so a viewer sees a label only where
|
|
8975
|
+
* they can see private content.
|
|
8976
|
+
*/
|
|
8977
|
+
async function readConversationAgentTree(conversationId, viewer) {
|
|
8978
|
+
const ids = [conversationId];
|
|
8979
|
+
let parentId = await readParentConversationId(conversationId);
|
|
8980
|
+
while (parentId && !ids.includes(parentId) && ids.length < MAX_AGENT_TREE_DEPTH) {
|
|
8981
|
+
ids.unshift(parentId);
|
|
8982
|
+
parentId = await readParentConversationId(parentId);
|
|
8983
|
+
}
|
|
8984
|
+
if (ids.length < 2) return;
|
|
8985
|
+
const root = parentId ? void 0 : await getConversationStore().get({ conversationId: ids[0] });
|
|
8986
|
+
const [access, automationTitleByConversation, firstHumanMessageTextByConversation] = await Promise.all([
|
|
8987
|
+
readConversationAccessFromSql(getDb(), ids, viewer),
|
|
8988
|
+
readAutomationTitlesByConversationId(root ? [root] : []),
|
|
8989
|
+
readFirstHumanMessageTexts(getDb(), root ? [root] : [])
|
|
8990
|
+
]);
|
|
8991
|
+
return await Promise.all(ids.map(async (id) => {
|
|
8992
|
+
const itemAccess = access.get(id);
|
|
8993
|
+
if (root?.conversationId === id) return {
|
|
8994
|
+
conversationId: id,
|
|
8995
|
+
label: conversationSummaryFromStoredConversation({
|
|
8996
|
+
access: itemAccess,
|
|
8997
|
+
automationTitle: automationTitleByConversation.get(id),
|
|
8998
|
+
conversation: root,
|
|
8999
|
+
durationMs: 0,
|
|
9000
|
+
firstHumanMessageText: firstHumanMessageTextByConversation.get(id)
|
|
9001
|
+
}).displayTitle
|
|
9002
|
+
};
|
|
9003
|
+
if (!itemAccess?.canViewPrivateContent) return {
|
|
9004
|
+
conversationId: id,
|
|
9005
|
+
label: CHILD_LABEL
|
|
9006
|
+
};
|
|
9007
|
+
const agent = await getChildAgentLabel(id);
|
|
9008
|
+
return {
|
|
9009
|
+
conversationId: id,
|
|
9010
|
+
label: agent?.title ?? agent?.agentName ?? CHILD_LABEL
|
|
9011
|
+
};
|
|
9012
|
+
}));
|
|
9013
|
+
}
|
|
8910
9014
|
// src/api/conversations/fork.ts
|
|
8911
9015
|
/** Fork a Conversation that the viewer can read into a new root they own. */
|
|
8912
9016
|
async function forkConversationForViewer(viewer, sourceConversationId, body) {
|
|
@@ -8964,63 +9068,21 @@ async function readConversationForks(conversationId, viewer) {
|
|
|
8964
9068
|
}
|
|
8965
9069
|
return result;
|
|
8966
9070
|
}
|
|
8967
|
-
// src/api/conversations/
|
|
8968
|
-
/** Bound the parent chain that one agent tree reads. */
|
|
8969
|
-
const MAX_AGENT_TREE_DEPTH = 16;
|
|
8970
|
-
const CHILD_LABEL = "Subagent";
|
|
8971
|
-
async function readParentConversationId(conversationId) {
|
|
8972
|
-
const [row] = await getDb().select({ parentId: juniorConversations.parentConversationId }).from(juniorConversations).where(eq(juniorConversations.conversationId, conversationId));
|
|
8973
|
-
return row?.parentId ?? void 0;
|
|
8974
|
-
}
|
|
9071
|
+
// src/api/conversations/read-position.ts
|
|
8975
9072
|
/**
|
|
8976
|
-
* Read the
|
|
8977
|
-
*
|
|
8978
|
-
*
|
|
8979
|
-
*
|
|
9073
|
+
* Read how far the viewer has read one Conversation, if they have read it.
|
|
9074
|
+
*
|
|
9075
|
+
* The viewer saw every Message up to one they wrote, also one sent from
|
|
9076
|
+
* Slack, so the position is at least their latest Message.
|
|
8980
9077
|
*/
|
|
8981
|
-
async function readConversationAgentTree(conversationId, viewer) {
|
|
8982
|
-
const ids = [conversationId];
|
|
8983
|
-
let parentId = await readParentConversationId(conversationId);
|
|
8984
|
-
while (parentId && !ids.includes(parentId) && ids.length < MAX_AGENT_TREE_DEPTH) {
|
|
8985
|
-
ids.unshift(parentId);
|
|
8986
|
-
parentId = await readParentConversationId(parentId);
|
|
8987
|
-
}
|
|
8988
|
-
if (ids.length < 2) return;
|
|
8989
|
-
const root = parentId ? void 0 : await getConversationStore().get({ conversationId: ids[0] });
|
|
8990
|
-
const [access, automationTitleByConversation, firstHumanMessageTextByConversation] = await Promise.all([
|
|
8991
|
-
readConversationAccessFromSql(getDb(), ids, viewer),
|
|
8992
|
-
readAutomationTitlesByConversationId(root ? [root] : []),
|
|
8993
|
-
readFirstHumanMessageTexts(getDb(), root ? [root] : [])
|
|
8994
|
-
]);
|
|
8995
|
-
return await Promise.all(ids.map(async (id) => {
|
|
8996
|
-
const itemAccess = access.get(id);
|
|
8997
|
-
if (root?.conversationId === id) return {
|
|
8998
|
-
conversationId: id,
|
|
8999
|
-
label: conversationSummaryFromStoredConversation({
|
|
9000
|
-
access: itemAccess,
|
|
9001
|
-
automationTitle: automationTitleByConversation.get(id),
|
|
9002
|
-
conversation: root,
|
|
9003
|
-
durationMs: 0,
|
|
9004
|
-
firstHumanMessageText: firstHumanMessageTextByConversation.get(id)
|
|
9005
|
-
}).displayTitle
|
|
9006
|
-
};
|
|
9007
|
-
if (!itemAccess?.canViewPrivateContent) return {
|
|
9008
|
-
conversationId: id,
|
|
9009
|
-
label: CHILD_LABEL
|
|
9010
|
-
};
|
|
9011
|
-
const agent = await getChildAgentLabel(id);
|
|
9012
|
-
return {
|
|
9013
|
-
conversationId: id,
|
|
9014
|
-
label: agent?.title ?? agent?.agentName ?? CHILD_LABEL
|
|
9015
|
-
};
|
|
9016
|
-
}));
|
|
9017
|
-
}
|
|
9018
|
-
// src/api/conversations/read-position.ts
|
|
9019
|
-
/** Read how far the viewer has read one Conversation, if they have read it. */
|
|
9020
9078
|
async function readConversationReadPosition(viewer, conversationId) {
|
|
9021
|
-
const [row] = await getDb().select({ lastReadSeq: juniorConversationReadPositions.lastReadSeq }).from(juniorConversationReadPositions).where(and(eq(juniorConversationReadPositions.userId, viewer.id), eq(juniorConversationReadPositions.conversationId, conversationId))).limit(1);
|
|
9079
|
+
const [row] = await getDb().select({ lastReadSeq: sql`greatest(${juniorConversationReadPositions.lastReadSeq}, (${latestViewerMessageSeq(viewer, conversationId)}))` }).from(juniorConversationReadPositions).where(and(eq(juniorConversationReadPositions.userId, viewer.id), eq(juniorConversationReadPositions.conversationId, conversationId))).limit(1);
|
|
9022
9080
|
return row;
|
|
9023
9081
|
}
|
|
9082
|
+
/** The seq of the latest Message that one of the viewer's Identities wrote. */
|
|
9083
|
+
function latestViewerMessageSeq(viewer, conversationId) {
|
|
9084
|
+
return getDb().select({ seq: max(juniorConversationEvents.seq) }).from(juniorConversationEvents).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversationEvents.actorIdentityId)).where(and(eq(juniorConversationEvents.conversationId, conversationId), eq(juniorConversationEvents.type, "message"), eq(juniorIdentities.userId, viewer.id)));
|
|
9085
|
+
}
|
|
9024
9086
|
/**
|
|
9025
9087
|
* Move the viewer's read position forward.
|
|
9026
9088
|
*
|
|
@@ -9032,7 +9094,7 @@ async function markConversationRead(viewer, conversationId, body) {
|
|
|
9032
9094
|
const db = getDb();
|
|
9033
9095
|
const [conversation] = await db.select({ lastSeq: max(juniorConversationEvents.seq) }).from(juniorConversations).leftJoin(juniorConversationEvents, eq(juniorConversationEvents.conversationId, juniorConversations.conversationId)).where(eq(juniorConversations.conversationId, conversationId)).groupBy(juniorConversations.conversationId);
|
|
9034
9096
|
if (!conversation) throwApiError(404, "Conversation not found.");
|
|
9035
|
-
|
|
9097
|
+
await db.insert(juniorConversationReadPositions).values({
|
|
9036
9098
|
conversationId,
|
|
9037
9099
|
lastReadSeq: Math.min(body.lastReadSeq, conversation.lastSeq ?? 0),
|
|
9038
9100
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
@@ -9043,8 +9105,83 @@ async function markConversationRead(viewer, conversationId, body) {
|
|
|
9043
9105
|
lastReadSeq: sql`greatest(${juniorConversationReadPositions.lastReadSeq}, excluded.last_read_seq)`,
|
|
9044
9106
|
updatedAt: sql`excluded.updated_at`
|
|
9045
9107
|
}
|
|
9046
|
-
})
|
|
9047
|
-
return
|
|
9108
|
+
});
|
|
9109
|
+
return await readConversationReadPosition(viewer, conversationId);
|
|
9110
|
+
}
|
|
9111
|
+
// src/api/conversations/detail-etag.ts
|
|
9112
|
+
/**
|
|
9113
|
+
* Sum the detail versions of a Conversation and its child agents. Child
|
|
9114
|
+
* writes bump only their own row, and the row count changes when a child
|
|
9115
|
+
* starts, so the parent needs no bump of its own.
|
|
9116
|
+
*/
|
|
9117
|
+
async function readSubtreeDetailVersion(conversationId) {
|
|
9118
|
+
const [row] = await getDb().select({
|
|
9119
|
+
conversations: sql`count(*)::int`,
|
|
9120
|
+
version: sql`coalesce(sum(${juniorConversations.detailVersion}), 0)::text`
|
|
9121
|
+
}).from(juniorConversations).innerJoin(conversationSubtree([conversationId]), eq(conversationSubtreeColumns.conversationId, juniorConversations.conversationId));
|
|
9122
|
+
return row ?? {
|
|
9123
|
+
conversations: 0,
|
|
9124
|
+
version: "0"
|
|
9125
|
+
};
|
|
9126
|
+
}
|
|
9127
|
+
/** Read the detail state that the ETag hashes and the report shows. */
|
|
9128
|
+
async function readConversationDetailState(conversationId, viewer) {
|
|
9129
|
+
const [accessById, viewerMarks, forks, agentTree, readPosition, autoArchive, attachmentsVersion] = await Promise.all([
|
|
9130
|
+
readConversationAccessFromSql(getDb(), [conversationId], viewer),
|
|
9131
|
+
viewer ? readConversationViewerMarks(viewer, conversationId) : void 0,
|
|
9132
|
+
readConversationForks(conversationId, viewer),
|
|
9133
|
+
readConversationAgentTree(conversationId, viewer),
|
|
9134
|
+
viewer ? readConversationReadPosition(viewer, conversationId) : void 0,
|
|
9135
|
+
viewer ? readConversationAutoArchive(viewer, conversationId) : void 0,
|
|
9136
|
+
readSlackAttachmentsVersion(getSqlExecutor(), conversationId)
|
|
9137
|
+
]);
|
|
9138
|
+
const access = accessById.get(conversationId);
|
|
9139
|
+
return {
|
|
9140
|
+
access,
|
|
9141
|
+
agentTree,
|
|
9142
|
+
autoArchive,
|
|
9143
|
+
forks,
|
|
9144
|
+
readPosition,
|
|
9145
|
+
transcriptVersion: createHash("sha256").update(JSON.stringify({
|
|
9146
|
+
attachments: attachmentsVersion,
|
|
9147
|
+
canViewPrivateContent: access?.canViewPrivateContent ?? false,
|
|
9148
|
+
junior: JUNIOR_VERSION
|
|
9149
|
+
})).digest("base64url"),
|
|
9150
|
+
viewerMarks
|
|
9151
|
+
};
|
|
9152
|
+
}
|
|
9153
|
+
/**
|
|
9154
|
+
* Return the detail ETag without building the report, or undefined for a
|
|
9155
|
+
* missing Conversation. The state comes back too, so the report reuses it
|
|
9156
|
+
* and matches the ETag.
|
|
9157
|
+
*
|
|
9158
|
+
* Shared content is covered by `detail_version`. The detail state is cheap,
|
|
9159
|
+
* so it is read on each request. Names, avatars, Automation titles, and
|
|
9160
|
+
* plugin sidebar labels are not covered: they refresh with the next detail
|
|
9161
|
+
* change or a reload.
|
|
9162
|
+
*
|
|
9163
|
+
* The read position is not hashed. The dashboard writes it as the reader
|
|
9164
|
+
* scrolls and puts the stored value in its cached detail, so a poll after a
|
|
9165
|
+
* read can answer 304. Other tabs and devices get it with the next detail
|
|
9166
|
+
* change or a reload.
|
|
9167
|
+
*/
|
|
9168
|
+
async function readConversationDetailEtag(conversationId, options) {
|
|
9169
|
+
const [subtree, state] = await Promise.all([readSubtreeDetailVersion(conversationId), readConversationDetailState(conversationId, options.viewer)]);
|
|
9170
|
+
if (subtree.conversations === 0) return void 0;
|
|
9171
|
+
const basis = JSON.stringify({
|
|
9172
|
+
access: state.access ?? null,
|
|
9173
|
+
agentTree: state.agentTree ?? null,
|
|
9174
|
+
autoArchive: state.autoArchive ?? null,
|
|
9175
|
+
forks: state.forks,
|
|
9176
|
+
junior: JUNIOR_VERSION,
|
|
9177
|
+
limit: options.limit ?? null,
|
|
9178
|
+
subtree,
|
|
9179
|
+
viewerMarks: state.viewerMarks ?? null
|
|
9180
|
+
});
|
|
9181
|
+
return {
|
|
9182
|
+
etag: createHash("sha256").update(basis).digest("hex"),
|
|
9183
|
+
state
|
|
9184
|
+
};
|
|
9048
9185
|
}
|
|
9049
9186
|
// src/api/conversations/detail.ts
|
|
9050
9187
|
/** Project stored metadata and a bounded event page into a signed history cursor. */
|
|
@@ -9074,6 +9211,8 @@ function projectConversationDetail(args) {
|
|
|
9074
9211
|
sidebarAnnotations: canExposePayload ? args.sidebarAnnotations : void 0,
|
|
9075
9212
|
...canExposePayload && args.brief ? { brief: args.brief } : void 0,
|
|
9076
9213
|
events: args.events,
|
|
9214
|
+
...args.appended ? { appended: true } : void 0,
|
|
9215
|
+
...args.appendCursor ? { appendCursor: args.appendCursor } : void 0,
|
|
9077
9216
|
...canExposePayload && args.participants.length > 0 ? {
|
|
9078
9217
|
authors: args.authors,
|
|
9079
9218
|
participants: args.participants
|
|
@@ -9099,58 +9238,91 @@ function projectConversationDetail(args) {
|
|
|
9099
9238
|
};
|
|
9100
9239
|
}
|
|
9101
9240
|
async function readConversationDetailFromSql(conversationId, options) {
|
|
9102
|
-
const record = await readConversationRecordFromSql(conversationId);
|
|
9241
|
+
const [record, state] = await Promise.all([readConversationRecordFromSql(conversationId), options.state ?? readConversationDetailState(conversationId, options.viewer)]);
|
|
9103
9242
|
if (!record) return void 0;
|
|
9104
|
-
const
|
|
9243
|
+
const { access, readPosition } = state;
|
|
9244
|
+
const canExposePayload = access?.canViewPrivateContent ?? false;
|
|
9105
9245
|
const executor = getSqlExecutor();
|
|
9106
|
-
const
|
|
9107
|
-
|
|
9246
|
+
const isPurged = record.conversation.transcriptPurgedAtMs !== void 0;
|
|
9247
|
+
const after = options.after && !options.unreadPage && !isPurged ? decodeConversationCursor({
|
|
9248
|
+
conversationId,
|
|
9249
|
+
cursor: options.after
|
|
9250
|
+
}) : void 0;
|
|
9251
|
+
const afterSeq = after && after.transcript === state.transcriptVersion ? after.seq : void 0;
|
|
9252
|
+
const readPage = async () => {
|
|
9253
|
+
if (isPurged) return { events: [] };
|
|
9254
|
+
if (afterSeq !== void 0) {
|
|
9255
|
+
const newer = await readConversationEventPageAfter(executor, {
|
|
9256
|
+
afterSeq,
|
|
9257
|
+
canExposePayload,
|
|
9258
|
+
conversationId,
|
|
9259
|
+
limit: options.limit
|
|
9260
|
+
});
|
|
9261
|
+
if (newer.nextSeq === void 0) return {
|
|
9262
|
+
appended: true,
|
|
9263
|
+
events: newer.events
|
|
9264
|
+
};
|
|
9265
|
+
}
|
|
9266
|
+
return readConversationEventPage(executor, {
|
|
9267
|
+
canExposePayload,
|
|
9268
|
+
conversationId,
|
|
9269
|
+
latestTurns: options.latestTurns,
|
|
9270
|
+
limit: options.limit
|
|
9271
|
+
});
|
|
9272
|
+
};
|
|
9273
|
+
const [annotations, automationTitleByConversation, auxiliaryCostsByConversation, briefVersion, firstHumanMessageTextByConversation, modelUsage, metricsByConversation, people, sourceTask, teamDomainByTeamId, page] = await Promise.all([
|
|
9108
9274
|
listConversationAnnotations(getDb(), conversationId),
|
|
9109
9275
|
readAutomationTitlesByConversationId([record.conversation]),
|
|
9110
9276
|
readConversationAuxiliaryCostsFromSql(getDb(), [conversationId]),
|
|
9111
9277
|
readLatestConversationBrief(getDb(), conversationId),
|
|
9112
9278
|
readFirstHumanMessageTexts(getDb(), [record.conversation]),
|
|
9113
|
-
|
|
9279
|
+
isPurged ? Promise.resolve([]) : readConversationModelUsageFromSql(executor, { conversationId }),
|
|
9114
9280
|
readConversationTreeMetricsFromSql(getDb(), [conversationId]),
|
|
9115
9281
|
readConversationAuthors(getDb(), conversationId),
|
|
9116
|
-
options.viewer ? readConversationReadPosition(options.viewer, conversationId) : void 0,
|
|
9117
9282
|
readConversationSourceTask({
|
|
9118
9283
|
conversationId,
|
|
9119
9284
|
...options.viewer ? { viewer: options.viewer } : void 0
|
|
9120
9285
|
}),
|
|
9121
|
-
resolveSlackTeamDomains(record.conversation.location?.provider === "slack" ? [record.conversation.location.teamId] : [])
|
|
9286
|
+
resolveSlackTeamDomains(record.conversation.location?.provider === "slack" ? [record.conversation.location.teamId] : []),
|
|
9287
|
+
readPage()
|
|
9122
9288
|
]);
|
|
9123
|
-
const access = accessByConversation.get(conversationId);
|
|
9124
|
-
const sidebarAnnotations = access?.canViewPrivateContent ? (await listConversationSidebarAnnotations([conversationId], /* @__PURE__ */ new Map([[conversationId, annotations]])))[conversationId] : void 0;
|
|
9125
|
-
const canExposePayload = access?.canViewPrivateContent ?? false;
|
|
9126
|
-
const page = record.conversation.transcriptPurgedAtMs === void 0 ? await readConversationEventPage(executor, {
|
|
9127
|
-
canExposePayload,
|
|
9128
|
-
conversationId,
|
|
9129
|
-
limit: options.limit
|
|
9130
|
-
}) : { events: [] };
|
|
9131
9289
|
const firstSeq = page.events[0]?.seq;
|
|
9132
9290
|
const unreadAfterSeq = readPosition !== void 0 && page.previousSeq !== void 0 && firstSeq !== void 0 && readPosition.lastReadSeq + 1 < firstSeq ? readPosition.lastReadSeq : void 0;
|
|
9133
|
-
const brief =
|
|
9134
|
-
const [{ briefMentions, events }, unreadPage] = await Promise.all([
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
9140
|
-
|
|
9141
|
-
|
|
9142
|
-
|
|
9143
|
-
|
|
9144
|
-
|
|
9145
|
-
|
|
9146
|
-
|
|
9291
|
+
const brief = canExposePayload ? briefVersion?.content : void 0;
|
|
9292
|
+
const [{ briefMentions, events }, unreadPage, sidebarAnnotations] = await Promise.all([
|
|
9293
|
+
startSpan({
|
|
9294
|
+
name: "Attach conversation mentions",
|
|
9295
|
+
op: "function"
|
|
9296
|
+
}, () => attachConversationMentions(executor, conversationId, {
|
|
9297
|
+
...brief ? { brief } : void 0,
|
|
9298
|
+
events: page.events
|
|
9299
|
+
})),
|
|
9300
|
+
options.unreadPage && unreadAfterSeq !== void 0 ? readConversationEventPageAround(executor, {
|
|
9301
|
+
canExposePayload,
|
|
9302
|
+
conversationId,
|
|
9303
|
+
limit: options.limit,
|
|
9304
|
+
seq: unreadAfterSeq
|
|
9305
|
+
}).then((around) => conversationEventPageReport(executor, {
|
|
9306
|
+
conversationId,
|
|
9307
|
+
eventHistory: conversationEventHistory({ canExposePayload }),
|
|
9308
|
+
page: around
|
|
9309
|
+
})).catch(() => void 0) : void 0,
|
|
9310
|
+
canExposePayload ? listConversationSidebarAnnotations([conversationId], /* @__PURE__ */ new Map([[conversationId, annotations]])).then((byConversation) => byConversation[conversationId]) : void 0
|
|
9311
|
+
]);
|
|
9312
|
+
const appendedAfterSeq = page.appended ? afterSeq : void 0;
|
|
9147
9313
|
const metrics = metricsByConversation.get(conversationId);
|
|
9148
9314
|
const auxiliaryCosts = auxiliaryCostsByConversation.get(conversationId);
|
|
9149
9315
|
const childAgentTotals = childAgentTotalsReport(metrics, auxiliaryCosts);
|
|
9150
|
-
|
|
9316
|
+
const detail = {
|
|
9151
9317
|
...record,
|
|
9152
9318
|
access,
|
|
9153
|
-
...
|
|
9319
|
+
...page.appended ? { appended: true } : void 0,
|
|
9320
|
+
...isPurged ? void 0 : { appendCursor: encodeConversationCursor({
|
|
9321
|
+
conversationId,
|
|
9322
|
+
seq: page.events.at(-1)?.seq ?? appendedAfterSeq ?? -1,
|
|
9323
|
+
transcript: state.transcriptVersion
|
|
9324
|
+
}) },
|
|
9325
|
+
...state.viewerMarks,
|
|
9154
9326
|
automationTitle: automationTitleByConversation.get(conversationId),
|
|
9155
9327
|
annotations,
|
|
9156
9328
|
sidebarAnnotations,
|
|
@@ -9175,26 +9347,37 @@ async function readConversationDetailFromSql(conversationId, options) {
|
|
|
9175
9347
|
...unreadAfterSeq === void 0 ? void 0 : { unreadAfterSeq },
|
|
9176
9348
|
...unreadPage ? { unreadPage } : void 0,
|
|
9177
9349
|
usage: metrics?.usage ?? record.usage ?? void 0
|
|
9178
|
-
}
|
|
9350
|
+
};
|
|
9351
|
+
const report = startSpan({
|
|
9352
|
+
name: "Project conversation detail",
|
|
9353
|
+
op: "function"
|
|
9354
|
+
}, () => projectConversationDetail(detail));
|
|
9355
|
+
return {
|
|
9356
|
+
...report,
|
|
9357
|
+
...state.forks,
|
|
9358
|
+
...state.agentTree ? { agentTree: state.agentTree } : void 0,
|
|
9359
|
+
...report.isParticipant && state.autoArchive !== void 0 ? { autoArchive: state.autoArchive } : void 0
|
|
9360
|
+
};
|
|
9179
9361
|
}
|
|
9180
|
-
/**
|
|
9362
|
+
/** Turns in the default page: enough to read the latest exchange in context. */
|
|
9363
|
+
const DETAIL_LATEST_TURNS = 3;
|
|
9364
|
+
/**
|
|
9365
|
+
* Load one conversation from its canonical event history. Without `limit`,
|
|
9366
|
+
* events hold the latest Turns, up to the default limit.
|
|
9367
|
+
*/
|
|
9181
9368
|
async function readConversationDetail(conversationId, options = {}) {
|
|
9182
9369
|
const report = await readConversationDetailFromSql(conversationId, {
|
|
9183
9370
|
...options,
|
|
9184
|
-
|
|
9371
|
+
...options.limit === void 0 ? {
|
|
9372
|
+
latestTurns: DETAIL_LATEST_TURNS,
|
|
9373
|
+
limit: 150
|
|
9374
|
+
} : { limit: options.limit }
|
|
9185
9375
|
});
|
|
9186
9376
|
if (!report) return void 0;
|
|
9187
|
-
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
|
|
9191
|
-
]);
|
|
9192
|
-
return conversationDetailReportSchema.parse({
|
|
9193
|
-
...report,
|
|
9194
|
-
...forks,
|
|
9195
|
-
...agentTree ? { agentTree } : void 0,
|
|
9196
|
-
...autoArchive === void 0 ? void 0 : { autoArchive }
|
|
9197
|
-
});
|
|
9377
|
+
return startSpan({
|
|
9378
|
+
name: "Validate conversation detail",
|
|
9379
|
+
op: "function"
|
|
9380
|
+
}, () => conversationDetailReportSchema.parse(report));
|
|
9198
9381
|
}
|
|
9199
9382
|
// src/api/conversations/pin.ts
|
|
9200
9383
|
/**
|
|
@@ -9303,4 +9486,4 @@ function viewerWebMessages(messages, viewer) {
|
|
|
9303
9486
|
}] : [];
|
|
9304
9487
|
});
|
|
9305
9488
|
}
|
|
9306
|
-
export {
|
|
9489
|
+
export { DEFAULT_AUTO_ARCHIVE_SETTINGS as $, assertNoLegacyAllowedDomains as A, normalizeIncomingSlackThreadId as B, requireConversationPendingMessages as C, createProductionSlackWebhookServices as D, createProductionConversationWorkOptions as E, recordSkippedConversationMessage as F, startProcessingReaction as G, stopConversationTurn as H, buildSlackInboundMessage as I, ReviewItemActionError as J, stripLeadingBotMention as K, clearSlackPendingReactions as L, isAllowedSignInEmail as M, readEnvList as N, getProductionSlackAdapter as O, resolveAllowedDomains as P, reviewItemChange as Q, isSlackMessageStopped as R, readConversationPendingMessages as S, archiveConversation as T, THREAD_OPTOUT_ACK as U, withNormalizedThreadId as V, bindMessageAuthorIdentityId as W, closeReviewItemsAnsweredByReply as X, actOnReviewItem as Y, readReviewItemForUser as Z, appendConversationMessageForViewer as _, readConversationDetailEtag as a, emptyResponse as at, encodeConversationCursor as b, keepQuickQuestionForViewer as c, getAttachmentStorage as ct, readConversationRecordFromSql as d, GET as dt, archiveViewerDoneConversations as et, readConversationAuxiliaryCostsFromSql as f, readHealthReport as ft, readFirstHumanMessageTexts as g, conversationSummaryFromStoredConversation as h, readConversationDetail as i, updateUserAutoArchiveSettings as it, isAllowedDomain as j, createSlackWebApiStatusSender as k, readConversationEvents as l, AGENT_DISPATCH_MAX_AGE_MS as lt, readConversationTreeMetricsFromSql as m, steerConversationPendingMessagesForViewer as n, runAutoArchiveSweep as nt, markConversationRead as o, jsonResponse as ot, childAgentTotalsReport as p, parseContent as q, pinConversation as r, setConversationAutoArchive as rt, forkConversationForViewer as s, throwApiError as st, stopConversationTurnForViewer as t, readUserAutoArchiveSettings as tt, readConversationFeed as u, enqueueAgentDispatch as ut, createConversationForViewer as v, resolveMentions as w, cancelConversationPendingMessagesForViewer as x, decodeConversationCursor as y, stopSlackThread as z };
|