@sentry/junior 0.277.0 → 0.278.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-BtfBHVM5.js → adapter-BXosqTMx.js} +1 -1
- package/dist/{admin-DzAKbZsm.js → admin-Thn7NfOi.js} +1 -1
- package/dist/{agent-invocations-Crs3XHhg.js → agent-invocations-D7c4BQGc.js} +1 -1
- package/dist/{agent-runner-BsYAbniN.js → agent-runner-DE-43MPb.js} +268 -835
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +5 -5
- package/dist/api.d.ts +1 -1
- package/dist/api.js +38 -76
- package/dist/{app-BjEQwNVP.d.ts → app-CHNS-AX2.d.ts} +5 -26
- package/dist/app.d.ts +2 -2
- package/dist/app.js +30 -31
- package/dist/{assistant-reply-NebRGG4G.js → assistant-reply-pauL6qyn.js} +28 -6
- package/dist/{automation-Cql9h2vO.js → automation-DphoTRYl.js} +1 -1
- package/dist/{background-compaction-queue-hh18yCeU.js → background-compaction-queue-CAL4A2y7.js} +2 -2
- package/dist/{briefs-BBo0Eimi.js → briefs-4fyPJJEu.js} +5 -6
- package/dist/{catalog-runtime-DE-F4Awo.js → catalog-runtime-BoOb5oUv.js} +1 -1
- package/dist/cli/chat.js +14 -14
- package/dist/cli/check.js +3 -3
- package/dist/cli/init.js +0 -2
- 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-DZ8HTnYH.js → client-v_OVYuHZ.js} +3 -3
- package/dist/{config-D5uUtrCP.js → config-o2jLRY5J.js} +24 -99
- package/dist/{connections-Do24CGP5.js → connections-RC4NXAx8.js} +10 -10
- package/dist/{conversation-SsASlWL7.js → conversation-CZfyQvdm.js} +51 -104
- package/dist/{conversation-privacy-VuylvlKr.js → conversation-privacy-C23M8KaD.js} +1 -1
- package/dist/{credential-sync-BGQK3pOa.js → credential-sync-Dd0WyNfF.js} +13 -13
- package/dist/{db-DEiwO5Sh.d.ts → db-BjLzDJCt.d.ts} +1 -1
- package/dist/{executor-hPfFTH0C.js → executor-CJfsD0VX.js} +3 -3
- package/dist/instrumentation.js +2 -2
- package/dist/{logging-cI3T1dNc.js → logging-dFaXvBRK.js} +1 -1
- package/dist/{media-DstkkoNP.js → media-DTAA8Qs_.js} +21 -23
- package/dist/{message-DBwsAl7O.js → message-DSwxIZet.js} +22 -28
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-DXrnbplb.js → oauth-callback-server-CDcuCp27.js} +2 -2
- package/dist/{projection-7EFIqzuj.js → projection-BTge9wrH.js} +106 -108
- package/dist/{prompt-oRfGsxd3.js → prompt-DDtCnlHP.js} +1 -1
- package/dist/{registry-Bzefs7kT.js → registry-Cp6CNmtP.js} +1 -1
- package/dist/{resolve-CuiEY_2u.js → resolve-B_7h2cXx.js} +3 -3
- package/dist/{result-DrcUtFaD.js → result-5LBEfnLX.js} +9 -9
- package/dist/{runner-CDE4CZ52.js → runner-C5-S4oq-.js} +11 -11
- package/dist/{sandbox-egress-signals-0tcmGd13.js → sandbox-egress-signals-B4GehT1L.js} +1 -1
- package/dist/{schema-Dzi3lkdP.js → schema-B5fpczDw.js} +67 -4
- package/dist/{schema-B6N2nc6v.d.ts → schema-Tr484cCC.d.ts} +909 -687
- package/dist/{service-account-DIyz_9Uh.js → service-account-BkEv20zf.js} +3 -3
- package/dist/{service-account-BOz9pqOE.js → service-account-Cq_dLrZJ.js} +3 -3
- package/dist/{session-stop-0juF_BP0.js → session-stop-BsS4qFS2.js} +22 -15
- package/dist/{skills-CU5Is147.js → skills-M0BA0_s6.js} +2 -2
- package/dist/{spawn-6C9jHH4b.js → spawn-BO3y7H4d.js} +2 -3
- package/dist/{stop-6FVG1c-r.js → stop-D5R82Wla.js} +255 -64
- package/dist/{store-DtHZviJ1.js → store-BGBzQWNf.js} +9 -16
- package/dist/{store-DKs1WwdB.js → store-CGJZTEVz.js} +3 -3
- package/dist/{task-queue-CcvFQE_p.js → task-queue-UD27ei2U.js} +3 -3
- package/dist/{task-runner-DBkNejLl.js → task-runner-noxjOjkM.js} +7 -7
- package/dist/{thread-state-4hjEIkIq.js → thread-state-BSu6rM6p.js} +4 -4
- package/dist/{turn-failure-response-BZNLydC3.js → turn-failure-response-wahwyPrZ.js} +7 -7
- package/dist/{turn-lifecycle-BhqYjaa4.js → turn-lifecycle-Bo4Trccw.js} +1 -1
- package/dist/{turn-session-routing-jnLOfBHJ.js → turn-session-routing-DnSaaEpn.js} +10 -10
- package/dist/{validation-BUFmsnKs.js → validation-B9-8iKyw.js} +1 -1
- package/dist/{version-DJTk0ZCE.js → version-C7HejFP2.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-WY0RYE4E.js → viewer-DLXajQZE.js} +52 -21
- package/dist/{work-C5AKvXJV.js → work-DRGSlfia.js} +12 -17
- package/dist/{worker-BcYVDVUy.js → worker-BGh5Dwc6.js} +6 -6
- package/migrations/meta/0075_snapshot.json +98 -314
- package/migrations/meta/0076_snapshot.json +98 -314
- package/migrations/meta/_journal.json +1 -1
- package/package.json +4 -4
- package/dist/model-profile-B998sjVd.js +0 -67
|
@@ -1,37 +1,36 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { a as completeText, b as isProviderRetryError, c as resolveGatewayModel, m as escapeXml, r as completeDecision } from "./client-
|
|
3
|
-
import {
|
|
4
|
-
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-
|
|
1
|
+
import { $ as completeTurnRecord, $a as recordSlackAttachment, $n as takeReviewItem, A as getConversationMessageSlackTs, Ai as removeReactionFromMessage, Ba as readConversationViewerMarks, Ci as addReactionToMessage, D as buildConversationContext, E as appendThreadContextMessages, En as webActorUserIds, F as turnHasReply, Fa as conversationIsMemberRoot, Fi as SlackActionError, Ga as readConversationEventPageAfter, H as AuthorizationFlowDisabledError, Hi as normalizeSlackConversationId, I as upsertConversationMessage, Ia as conversationNotArchivedForEmail, Ii as downloadPrivateSlackFile, J as wasPendingAuthStopped, Jn as getReviewItem, K as clearPendingAuth, Ka as readConversationEventPageAround, La as conversationNotArchivedForUser, Ln as getPlugins, Lr as verifyTimerWatchCredentialSubject, M as markConversationMessage, Ma as conversationArchivedForEmail, N as normalizeConversationText, Na as conversationArchivedForUser, O as createConversationMemoryService, P as recordDeliveredAssistantMessage, Pa as conversationHasParticipantUser, Q as abandonTurnRecord, Qa as readAttachmentVisionSummary, R as PluginCredentialFailureError, Ra as conversationPinnedForUser, Ri as getHeaderString, Rr as JUNIOR_THREAD_STATE_TTL_MS, S as resolveConversationTitle, Si as truncateStatusText, Sn as isExperimentalFeatureEnabled, Ua as readLatestConversationBrief, Ut as persistWithRetry, Va as viewerConversationMembership, Vi as isDmChannel, Wa as readConversationEventPage, Wi as withSlackRetries, Wn as closeReviewItem, X as loadTurnCheckpoint, Xa as getSlackFileId, Xn as listReplyActionItems, Ya as notInheritedByForkChild, Z as saveTurnCheckpoint, Zn as listWaitingConversations, a as loadProjection, an as trimTrailingAssistantMessages, ar as isOnlyAssignee, bi as normalizeSlackStatusText, co as createPluginCache, d as recordAuthorizationCompleted, et as failTurnRecord, fn as decideSubscribedThreadReply, fo as piMessageFromHistoryItem, h as recordSubscribedReplyRoute, i as loadConversationProjection, io as listConversationAnnotationsById, ir as canReadReviewItem, j as isHumanConversationMessage, ja as readConversationAccessFromSql, k as estimateConversationContextTokens, ka as createPluginLogger, ln as buildDeterministicAssistantMessageId, lr as reviewItemNeedsUser, mn as getThreadStopDecision, n as commitMessages, nr as canActOnReviewItem, nt as listTurnSummaries, o as loadTurnProjection, pn as getSubscribedReplyPreflightDecision, qa as buildSentryConversationUrl, ro as listConversationAnnotations, rt as recordTurnSummary, so as lookupSlackUser, t as commitAcceptedReply, tt as getTurnRecord, un as buildDeterministicTurnId, uo as configValueSchema, ur as reviewItemReaderForUser, v as hydrateConversationMessages, w as fallbackShortTitle, wn as createUserTokenStore, x as persistConversationMessageSummaries, xr as cancelSubscriptions, y as persistConversationMessages, za as conversationViewerMarks, zi as getSlackClient, zt as buildTurnErrorResponse } from "./projection-BTge9wrH.js";
|
|
2
|
+
import { a as completeText, b as isProviderRetryError, c as resolveGatewayModel, m as escapeXml, r as completeDecision } from "./client-v_OVYuHZ.js";
|
|
3
|
+
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-o2jLRY5J.js";
|
|
4
|
+
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-dFaXvBRK.js";
|
|
5
5
|
import { i as getActiveSpan, r as continueTrace } from "./sentry-MDkYAVPV.js";
|
|
6
|
-
import { i as defaultModelId } from "./model-profile-B998sjVd.js";
|
|
7
6
|
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-B4DYygOB.js";
|
|
8
|
-
import { $ as
|
|
9
|
-
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-
|
|
10
|
-
import { C as juniorCodeChanges, _ as juniorConversationBriefs, b as juniorConversationEvents, c as juniorReviewItems, h as juniorConversationParticipants, m as juniorConversationReadPositions, o as juniorReviewItemConversations } from "./executor-
|
|
11
|
-
import { g as instructionProvenanceFor, m as contextProvenance, n as detectImageMediaType, r as isVisionImageMediaType } from "./media-
|
|
12
|
-
import { d as actorLogContext, f as credentialContextForActor } from "./registry-
|
|
13
|
-
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, Tt as conversationSubtree, a as buildAuthPauseResponse, b as renderAttachmentText, dt as recordWebConversationActivity, ft as webActorFromUser, i as measureTurnCompactionWait, kt as buildSteeringPiMessage, m as latestProgressStatus, n as executeAgentRun, pt as resolveConversationDestination, rt as deliverReviewItemChange, t as createAgentRunner, ut as createConversationId, vt as storeAttachment, x as renderBlockText, z as resolveDestinationVisibility } from "./agent-runner-
|
|
7
|
+
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-DLXajQZE.js";
|
|
8
|
+
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-D7c4BQGc.js";
|
|
9
|
+
import { C as juniorCodeChanges, _ as juniorConversationBriefs, b as juniorConversationEvents, c as juniorReviewItems, h as juniorConversationParticipants, m as juniorConversationReadPositions, o as juniorReviewItemConversations } from "./executor-CJfsD0VX.js";
|
|
10
|
+
import { g as instructionProvenanceFor, m as contextProvenance, n as detectImageMediaType, r as isVisionImageMediaType } from "./media-DTAA8Qs_.js";
|
|
11
|
+
import { d as actorLogContext, f as credentialContextForActor } from "./registry-Cp6CNmtP.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, Tt as conversationSubtree, a as buildAuthPauseResponse, b as renderAttachmentText, dt as recordWebConversationActivity, ft as webActorFromUser, i as measureTurnCompactionWait, kt as buildSteeringPiMessage, m as latestProgressStatus, n as executeAgentRun, pt as resolveConversationDestination, rt as deliverReviewItemChange, t as createAgentRunner, ut as createConversationId, vt as storeAttachment, x as renderBlockText, z as resolveDestinationVisibility } from "./agent-runner-DE-43MPb.js";
|
|
14
13
|
import { a as withLock, n as MUTATION_LOCK_TTL_MS, r as acquireActiveLock } from "./locks-D-0h111u.js";
|
|
15
|
-
import { r as getStateAdapter } from "./adapter-
|
|
16
|
-
import {
|
|
17
|
-
import { a as EVENT_SYSTEM_ACTOR, o as isEventConversationMessage } from "./prompt-
|
|
18
|
-
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-
|
|
19
|
-
import { n as getAssistantReplyText } from "./assistant-reply-
|
|
20
|
-
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-
|
|
14
|
+
import { r as getStateAdapter } from "./adapter-BXosqTMx.js";
|
|
15
|
+
import { R as readMessageAttachments, c as conversationDetailReportSchema, p as conversationFeedSchema, u as conversationEventPageSchema } from "./conversation-CZfyQvdm.js";
|
|
16
|
+
import { a as EVENT_SYSTEM_ACTOR, o as isEventConversationMessage } from "./prompt-DDtCnlHP.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-BGBzQWNf.js";
|
|
18
|
+
import { n as getAssistantReplyText, t as decideReply } from "./assistant-reply-pauL6qyn.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-BsS4qFS2.js";
|
|
21
20
|
import { _ as isEmptyUserInputAnswer, v as normalizeUserInputAnswer } from "./reporting-window-DgHgwQB3.js";
|
|
22
|
-
import { g as getTurnRequestDeadline, l as getVercelConversationWorkQueue } from "./background-compaction-queue-
|
|
23
|
-
import { D as stopConversationWork, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, r as appendAndEnqueueInboundMessage, w as requestConversationWork } from "./store-
|
|
24
|
-
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-
|
|
21
|
+
import { g as getTurnRequestDeadline, l as getVercelConversationWorkQueue } from "./background-compaction-queue-CAL4A2y7.js";
|
|
22
|
+
import { D as stopConversationWork, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, r as appendAndEnqueueInboundMessage, w as requestConversationWork } from "./store-CGJZTEVz.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-DnSaaEpn.js";
|
|
25
24
|
import { n as healthReportSchema, t as apiErrorSchema } from "./common-Eu6sx09c.js";
|
|
26
|
-
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-
|
|
27
|
-
import { n as getTurnLifecycle, t as ConversationTurnLifecycleService } from "./turn-lifecycle-
|
|
28
|
-
import { o as AgentRunError, s as executeTurn } from "./work-
|
|
29
|
-
import { a as persistThreadStateById, i as persistThreadRuntimeState, n as getPersistedSandboxState, o as coerceThreadConversationState, r as getPersistedThreadState, t as getLocationConfigurationService } from "./thread-state-
|
|
30
|
-
import { c as deleteWebAuthorization, d as createPausedTurns, f as getPausedTurnRequest, h as getTurnAuthorization, m as wakePausedTurn, s as createWebAuthorization } from "./connections-
|
|
31
|
-
import { t as bindMessageAgent } from "./message-
|
|
32
|
-
import { t as bindSpawnAgent } from "./spawn-
|
|
33
|
-
import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-
|
|
34
|
-
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-
|
|
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-5LBEfnLX.js";
|
|
26
|
+
import { n as getTurnLifecycle, t as ConversationTurnLifecycleService } from "./turn-lifecycle-Bo4Trccw.js";
|
|
27
|
+
import { o as AgentRunError, s as executeTurn } from "./work-DRGSlfia.js";
|
|
28
|
+
import { a as persistThreadStateById, i as persistThreadRuntimeState, n as getPersistedSandboxState, o as coerceThreadConversationState, r as getPersistedThreadState, t as getLocationConfigurationService } from "./thread-state-BSu6rM6p.js";
|
|
29
|
+
import { c as deleteWebAuthorization, d as createPausedTurns, f as getPausedTurnRequest, h as getTurnAuthorization, m as wakePausedTurn, s as createWebAuthorization } from "./connections-RC4NXAx8.js";
|
|
30
|
+
import { t as bindMessageAgent } from "./message-DSwxIZet.js";
|
|
31
|
+
import { t as bindSpawnAgent } from "./spawn-BO3y7H4d.js";
|
|
32
|
+
import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-noxjOjkM.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-wahwyPrZ.js";
|
|
35
34
|
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
36
35
|
import { z } from "zod";
|
|
37
36
|
import { and, asc, desc, eq, gt, inArray, isNotNull, isNull, lte, max, ne, or, sql } from "drizzle-orm";
|
|
@@ -2775,17 +2774,13 @@ function countPotentialImageAttachments(attachments) {
|
|
|
2775
2774
|
function isVisionEnabled() {
|
|
2776
2775
|
return Boolean(botConfig.visionModelId);
|
|
2777
2776
|
}
|
|
2778
|
-
/**
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
* read them.
|
|
2782
|
-
*/
|
|
2783
|
-
function profileModelsAcceptImages() {
|
|
2784
|
-
return Object.values(botConfig.profiles).every((profile) => resolveGatewayModel(profile.modelId).input.includes("image"));
|
|
2777
|
+
/** Report whether the main agent model accepts image input. */
|
|
2778
|
+
function agentModelAcceptsImages() {
|
|
2779
|
+
return resolveGatewayModel(botConfig.modelId).input.includes("image");
|
|
2785
2780
|
}
|
|
2786
2781
|
/** Report whether the agent can read current-message images by any path. */
|
|
2787
2782
|
function canReadImages() {
|
|
2788
|
-
return isVisionEnabled() ||
|
|
2783
|
+
return isVisionEnabled() || agentModelAcceptsImages();
|
|
2789
2784
|
}
|
|
2790
2785
|
var ImageAttachmentProcessingError = class extends Error {
|
|
2791
2786
|
constructor(message) {
|
|
@@ -2954,7 +2949,7 @@ async function resolveUserAttachmentsWithDeps(attachments, context, deps) {
|
|
|
2954
2949
|
}
|
|
2955
2950
|
continue;
|
|
2956
2951
|
}
|
|
2957
|
-
const nativeImageMediaType = isImageAttachment &&
|
|
2952
|
+
const nativeImageMediaType = isImageAttachment && agentModelAcceptsImages() ? detectImageMediaType(data) : void 0;
|
|
2958
2953
|
if (nativeImageMediaType) {
|
|
2959
2954
|
nextCachedImageSummaryIndex += 1;
|
|
2960
2955
|
resolvedAttachment.mediaType = nativeImageMediaType;
|
|
@@ -4026,7 +4021,7 @@ function createSlackTurn(deps) {
|
|
|
4026
4021
|
destinationName: channelId,
|
|
4027
4022
|
runId,
|
|
4028
4023
|
assistantUserName: botConfig.userName,
|
|
4029
|
-
modelId:
|
|
4024
|
+
modelId: botConfig.modelId
|
|
4030
4025
|
}, async () => {
|
|
4031
4026
|
await getConversationStore().recordActivity({
|
|
4032
4027
|
activityAtMs: message.metadata.dateSent.getTime(),
|
|
@@ -5158,7 +5153,7 @@ function createSlackRuntime(options) {
|
|
|
5158
5153
|
assistantUserName: botConfig.userName,
|
|
5159
5154
|
cancelWatches: cancelSubscriptions,
|
|
5160
5155
|
getBotUserId: () => options.getSlackAdapter().botUserId,
|
|
5161
|
-
modelId:
|
|
5156
|
+
modelId: botConfig.modelId,
|
|
5162
5157
|
now: options.now ?? (() => Date.now()),
|
|
5163
5158
|
prepareTurnState,
|
|
5164
5159
|
persistPreparedState: async ({ conversationId, preparedState }) => {
|
|
@@ -5304,7 +5299,7 @@ function getResumeLogContext(args) {
|
|
|
5304
5299
|
...actorLogContext(args.run?.actor, args.run?.credentialContext),
|
|
5305
5300
|
destinationName: args.channelId,
|
|
5306
5301
|
assistantUserName: botConfig.userName,
|
|
5307
|
-
modelId:
|
|
5302
|
+
modelId: botConfig.modelId
|
|
5308
5303
|
};
|
|
5309
5304
|
}
|
|
5310
5305
|
async function handleResumeFailure(args) {
|
|
@@ -6335,6 +6330,7 @@ async function commitAssistantMessage(args) {
|
|
|
6335
6330
|
const conversationMessageId = recordDeliveredAssistantMessage({
|
|
6336
6331
|
cards: args.cards,
|
|
6337
6332
|
conversation: args.conversation,
|
|
6333
|
+
...args.quiet ? { quiet: args.quiet } : void 0,
|
|
6338
6334
|
sessionId: args.sessionId,
|
|
6339
6335
|
source: args.source,
|
|
6340
6336
|
text: args.text,
|
|
@@ -6550,7 +6546,8 @@ function createConversationTurnWorker(agentRunner, deliverMessage) {
|
|
|
6550
6546
|
});
|
|
6551
6547
|
const webActor = actor.platform === "web" ? actor : void 0;
|
|
6552
6548
|
const conversationLocation = storedConversation?.location;
|
|
6553
|
-
const
|
|
6549
|
+
const isEventTurn = source.kind === "event" || savedMessageIsEvent;
|
|
6550
|
+
const deliverToProvider = Boolean(conversationLocation) && isEventTurn;
|
|
6554
6551
|
const surface = deliverToProvider ? "slack" : "api";
|
|
6555
6552
|
return await withLogContext({
|
|
6556
6553
|
conversationId: context.conversationId,
|
|
@@ -6638,12 +6635,14 @@ function createConversationTurnWorker(agentRunner, deliverMessage) {
|
|
|
6638
6635
|
let completedSuccessfully = false;
|
|
6639
6636
|
const deliverAssistantMessage = async (value) => {
|
|
6640
6637
|
const agentMessage = typeof value === "string" ? void 0 : value;
|
|
6641
|
-
const
|
|
6638
|
+
const decision = agentMessage ? decideReply(agentMessage) : void 0;
|
|
6639
|
+
const replyText = typeof value === "string" ? value : decision?.kind === "deliver" ? decision.text : void 0;
|
|
6642
6640
|
if (!replyText?.trim()) return;
|
|
6643
6641
|
failureCode = "delivery_failed";
|
|
6644
6642
|
const cards = await loadPendingMessageCards(context.conversationId);
|
|
6643
|
+
const quiet = decision?.kind === "deliver" && decision.quiet === true && isEventTurn && cards.length === 0;
|
|
6645
6644
|
let deliveryResult;
|
|
6646
|
-
if (deliverToProvider) {
|
|
6645
|
+
if (deliverToProvider && !quiet) {
|
|
6647
6646
|
if (!conversationLocation || !deliverMessage) throw new Error(`Conversation ${context.conversationId} cannot deliver to its Location`);
|
|
6648
6647
|
deliveryResult = await deliverMessage({
|
|
6649
6648
|
cards,
|
|
@@ -6658,6 +6657,7 @@ function createConversationTurnWorker(agentRunner, deliverMessage) {
|
|
|
6658
6657
|
conversation,
|
|
6659
6658
|
conversationId: context.conversationId,
|
|
6660
6659
|
...deliveryResult ? { deliveryResult } : void 0,
|
|
6660
|
+
...quiet ? { quiet } : void 0,
|
|
6661
6661
|
sessionId: turnId,
|
|
6662
6662
|
...deliveryResult ? { source: "slack" } : source.kind === "web" ? { source: "web" } : void 0,
|
|
6663
6663
|
text: replyText,
|
|
@@ -7501,6 +7501,26 @@ function messageTotalTokens(args) {
|
|
|
7501
7501
|
function definedNumber(value) {
|
|
7502
7502
|
return value === null ? void 0 : value;
|
|
7503
7503
|
}
|
|
7504
|
+
const modelUsageSumsSchema = z.object({
|
|
7505
|
+
inputTokens: z.number().nullable(),
|
|
7506
|
+
outputTokens: z.number().nullable(),
|
|
7507
|
+
cachedInputTokens: z.number().nullable(),
|
|
7508
|
+
cacheCreationTokens: z.number().nullable(),
|
|
7509
|
+
reasoningTokens: z.number().nullable(),
|
|
7510
|
+
totalTokens: z.number().nullable(),
|
|
7511
|
+
costInput: z.number().nullable(),
|
|
7512
|
+
costOutput: z.number().nullable(),
|
|
7513
|
+
costCacheRead: z.number().nullable(),
|
|
7514
|
+
costCacheWrite: z.number().nullable(),
|
|
7515
|
+
costTotal: z.number().nullable()
|
|
7516
|
+
});
|
|
7517
|
+
const COST_FIELDS = /* @__PURE__ */ new Set([
|
|
7518
|
+
"costInput",
|
|
7519
|
+
"costOutput",
|
|
7520
|
+
"costCacheRead",
|
|
7521
|
+
"costCacheWrite",
|
|
7522
|
+
"costTotal"
|
|
7523
|
+
]);
|
|
7504
7524
|
function usageFromRow(row) {
|
|
7505
7525
|
const components = {
|
|
7506
7526
|
inputTokens: definedNumber(row.inputTokens),
|
|
@@ -7524,12 +7544,8 @@ function usageFromRow(row) {
|
|
|
7524
7544
|
};
|
|
7525
7545
|
return hasAgentTurnUsage(result) ? agentTurnUsageSchema.parse(result) : void 0;
|
|
7526
7546
|
}
|
|
7527
|
-
/**
|
|
7528
|
-
|
|
7529
|
-
* Conversation and all its child agents at any depth. Replayed history is not
|
|
7530
|
-
* another call; its tokens appear in the next call's input usage.
|
|
7531
|
-
*/
|
|
7532
|
-
async function readConversationModelUsageFromSql(executor, options) {
|
|
7547
|
+
/** Sum assistant calls by model id, in the given seq range of each Conversation. */
|
|
7548
|
+
async function sumModelUsage(executor, ranges) {
|
|
7533
7549
|
const modelText = sql`(${model} #>> '{}')`;
|
|
7534
7550
|
const modelId = sql`case
|
|
7535
7551
|
when position('/' in coalesce(${modelText}, '')) > 0
|
|
@@ -7540,7 +7556,8 @@ async function readConversationModelUsageFromSql(executor, options) {
|
|
|
7540
7556
|
const outputTokens = token("output", "outputTokens");
|
|
7541
7557
|
const cachedInputTokens = token("cacheRead", "cachedInputTokens");
|
|
7542
7558
|
const cacheCreationTokens = token("cacheWrite", "cacheCreationTokens");
|
|
7543
|
-
|
|
7559
|
+
const rangeRows = sql.join(ranges.map((range) => sql`(${range.conversationId}::text, ${range.fromSeq}::integer, ${range.toSeq}::integer)`), sql`, `);
|
|
7560
|
+
return await executor.db().select({
|
|
7544
7561
|
modelId,
|
|
7545
7562
|
inputTokens: summed(inputTokens),
|
|
7546
7563
|
outputTokens: summed(outputTokens),
|
|
@@ -7558,10 +7575,114 @@ async function readConversationModelUsageFromSql(executor, options) {
|
|
|
7558
7575
|
costCacheRead: summedCost(nonnegativeNumber(cost, "cacheRead")),
|
|
7559
7576
|
costCacheWrite: summedCost(nonnegativeNumber(cost, "cacheWrite")),
|
|
7560
7577
|
costTotal: summedCost(nonnegativeNumber(cost, "total"))
|
|
7561
|
-
}).from(juniorConversationEvents).innerJoin(
|
|
7562
|
-
|
|
7578
|
+
}).from(juniorConversationEvents).innerJoin(sql`(values ${rangeRows}) as seq_range(conversation_id, from_seq, to_seq)`, sql`seq_range.conversation_id = ${juniorConversationEvents.conversationId}
|
|
7579
|
+
and ${juniorConversationEvents.seq} > seq_range.from_seq
|
|
7580
|
+
and ${juniorConversationEvents.seq} <= seq_range.to_seq`).crossJoinLateral(assistantCall).where(and(eq(juniorConversationEvents.type, "assistant_message"), notCopiedByFork(), notInheritedByForkChild(), sql`jsonb_typeof(${provider}) = 'string'`, sql`jsonb_typeof(${model}) = 'string'`, sql`coalesce(${provider} #>> '{}', '') <> ''`, sql`coalesce(${modelText}, '') <> ''`)).groupBy(modelId);
|
|
7581
|
+
}
|
|
7582
|
+
/**
|
|
7583
|
+
* The last event seq of each Conversation in a subtree, and the creation time
|
|
7584
|
+
* of its first event. A purged Conversation can get new events under the same
|
|
7585
|
+
* id, with seq starting again at 0; the first event time tells them apart.
|
|
7586
|
+
*/
|
|
7587
|
+
async function readEventWatermarks(executor, conversationId) {
|
|
7588
|
+
const conversation = juniorConversations.conversationId;
|
|
7589
|
+
return await executor.db().select({
|
|
7590
|
+
conversationId: conversation,
|
|
7591
|
+
seq: sql`(
|
|
7592
|
+
select max(watermark.seq) from junior_conversation_events watermark
|
|
7593
|
+
where watermark.conversation_id = ${conversation}
|
|
7594
|
+
)`,
|
|
7595
|
+
originMs: sql`(
|
|
7596
|
+
select (extract(epoch from origin.created_at) * 1000)::double precision
|
|
7597
|
+
from junior_conversation_events origin
|
|
7598
|
+
where origin.conversation_id = ${conversation}
|
|
7599
|
+
order by origin.seq
|
|
7600
|
+
limit 1
|
|
7601
|
+
)`
|
|
7602
|
+
}).from(juniorConversations).innerJoin(conversationSubtree([conversationId]), eq(conversationSubtreeColumns.conversationId, conversation));
|
|
7603
|
+
}
|
|
7604
|
+
const modelUsageCacheSchema = z.object({
|
|
7605
|
+
conversations: z.record(z.string(), z.object({
|
|
7606
|
+
seq: z.number().int(),
|
|
7607
|
+
originMs: z.number()
|
|
7608
|
+
})),
|
|
7609
|
+
models: z.record(z.string(), modelUsageSumsSchema)
|
|
7610
|
+
});
|
|
7611
|
+
const EMPTY_MODEL_USAGE_CACHE = {
|
|
7612
|
+
conversations: {},
|
|
7613
|
+
models: {}
|
|
7614
|
+
};
|
|
7615
|
+
const MODEL_USAGE_CACHE_TTL_MS = 2592e6;
|
|
7616
|
+
function modelUsageCacheKey(conversationId) {
|
|
7617
|
+
return `conversation-model-usage:${conversationId}`;
|
|
7618
|
+
}
|
|
7619
|
+
function addSums(field, left, right) {
|
|
7620
|
+
if (left === null) return right;
|
|
7621
|
+
if (right === null) return left;
|
|
7622
|
+
return COST_FIELDS.has(field) ? Number((left + right).toFixed(12)) : left + right;
|
|
7623
|
+
}
|
|
7624
|
+
function mergeSums(left, right) {
|
|
7625
|
+
if (!left) return right;
|
|
7626
|
+
const merged = { ...right };
|
|
7627
|
+
for (const field of modelUsageSumsSchema.keyof().options) merged[field] = addSums(field, left[field], right[field]);
|
|
7628
|
+
return merged;
|
|
7629
|
+
}
|
|
7630
|
+
/**
|
|
7631
|
+
* Aggregate real assistant calls by provider/model in SQL, for one
|
|
7632
|
+
* Conversation and all its child agents at any depth. Replayed history is not
|
|
7633
|
+
* another call; its tokens appear in the next call's input usage.
|
|
7634
|
+
*
|
|
7635
|
+
* Reading assistant payloads is slow on long Conversations, so the sums are
|
|
7636
|
+
* cached with the last seq that each Conversation in the subtree added. A read
|
|
7637
|
+
* sums only later events. This is correct because a row at or below a seen
|
|
7638
|
+
* seq never changes and never changes whether it counts:
|
|
7639
|
+
* - Events are append-only. The per-Conversation event lock serializes
|
|
7640
|
+
* appends and is held to commit, so when seq N is visible, lower seqs are.
|
|
7641
|
+
* - `notInheritedByForkChild` reads only lower seqs of the same Conversation.
|
|
7642
|
+
* - `notCopiedByFork` reads a later fork note, but a fork commits its copied
|
|
7643
|
+
* events and the note in one transaction.
|
|
7644
|
+
* Concurrent reads can overwrite each other's entry. Each entry is correct
|
|
7645
|
+
* at its own seqs, so the last write wins safely.
|
|
7646
|
+
*/
|
|
7647
|
+
async function readConversationModelUsageFromSql(executor, options) {
|
|
7648
|
+
const state = getStateAdapter();
|
|
7649
|
+
const key = modelUsageCacheKey(options.conversationId);
|
|
7650
|
+
const [stored, watermarks] = await Promise.all([state.get(key), readEventWatermarks(executor, options.conversationId)]);
|
|
7651
|
+
const cached = modelUsageCacheSchema.safeParse(stored).data;
|
|
7652
|
+
const purged = watermarks.some(({ conversationId, seq, originMs }) => {
|
|
7653
|
+
const seen = cached?.conversations[conversationId];
|
|
7654
|
+
return seen && (seq === null || seq < seen.seq || originMs !== seen.originMs);
|
|
7655
|
+
});
|
|
7656
|
+
const base = cached && !purged ? cached : EMPTY_MODEL_USAGE_CACHE;
|
|
7657
|
+
const ranges = [];
|
|
7658
|
+
const conversations = {};
|
|
7659
|
+
for (const { conversationId, seq, originMs } of watermarks) {
|
|
7660
|
+
if (seq === null || originMs === null) continue;
|
|
7661
|
+
conversations[conversationId] = {
|
|
7662
|
+
seq,
|
|
7663
|
+
originMs
|
|
7664
|
+
};
|
|
7665
|
+
const fromSeq = base.conversations[conversationId]?.seq ?? -1;
|
|
7666
|
+
if (seq > fromSeq) ranges.push({
|
|
7667
|
+
conversationId,
|
|
7668
|
+
fromSeq,
|
|
7669
|
+
toSeq: seq
|
|
7670
|
+
});
|
|
7671
|
+
}
|
|
7672
|
+
let models = base.models;
|
|
7673
|
+
if (ranges.length > 0 || base !== cached) {
|
|
7674
|
+
const deltas = ranges.length > 0 ? await sumModelUsage(executor, ranges) : [];
|
|
7675
|
+
models = { ...base.models };
|
|
7676
|
+
for (const { modelId, ...sums } of deltas) models[modelId] = mergeSums(models[modelId], sums);
|
|
7677
|
+
await state.set(key, {
|
|
7678
|
+
conversations,
|
|
7679
|
+
models
|
|
7680
|
+
}, MODEL_USAGE_CACHE_TTL_MS);
|
|
7681
|
+
}
|
|
7682
|
+
return Object.entries(models).sort(([left], [right]) => left < right ? -1 : 1).flatMap(([modelId, sums]) => {
|
|
7683
|
+
const modelUsage = usageFromRow(sums);
|
|
7563
7684
|
return modelUsage ? [{
|
|
7564
|
-
modelId
|
|
7685
|
+
modelId,
|
|
7565
7686
|
usage: modelUsage
|
|
7566
7687
|
}] : [];
|
|
7567
7688
|
});
|
|
@@ -7705,8 +7826,7 @@ function eventMentionTexts(data) {
|
|
|
7705
7826
|
...(data.events ?? []).map((event) => event.trustedSummary)
|
|
7706
7827
|
];
|
|
7707
7828
|
case "assistant_message": return data.parts.map((part) => part.text);
|
|
7708
|
-
case "compaction":
|
|
7709
|
-
case "handoff": return [data.summary];
|
|
7829
|
+
case "compaction": return [data.summary];
|
|
7710
7830
|
case "structured_event": return [data.presentation.preview, ...(data.presentation.details ?? []).map((detail) => detail.description)];
|
|
7711
7831
|
default: return [];
|
|
7712
7832
|
}
|
|
@@ -8447,6 +8567,57 @@ async function readConversationFeedFromSql(options = {}) {
|
|
|
8447
8567
|
async function readConversationFeed(options = {}) {
|
|
8448
8568
|
return conversationFeedSchema.parse(await readConversationFeedFromSql(options));
|
|
8449
8569
|
}
|
|
8570
|
+
// src/api/conversations/event-list.ts
|
|
8571
|
+
/** Read one bounded page of reporting events before, after, or around a signed cursor. */
|
|
8572
|
+
async function readConversationEvents(conversationId, boundary, options = {}) {
|
|
8573
|
+
const record = await readConversationRecordFromSql(conversationId);
|
|
8574
|
+
if (!record) return void 0;
|
|
8575
|
+
const cursor = decodeConversationCursor({
|
|
8576
|
+
conversationId,
|
|
8577
|
+
cursor: "after" in boundary ? boundary.after : "around" in boundary ? boundary.around : boundary.before
|
|
8578
|
+
});
|
|
8579
|
+
if (!cursor) throwApiError(400, "Invalid conversation cursor.");
|
|
8580
|
+
const canExposePayload = (await readConversationAccessFromSql(getDb(), [conversationId], options.viewer)).get(conversationId)?.canViewPrivateContent ?? false;
|
|
8581
|
+
const transcriptPurgedAtMs = record.conversation.transcriptPurgedAtMs;
|
|
8582
|
+
const pageArgs = {
|
|
8583
|
+
canExposePayload,
|
|
8584
|
+
conversationId,
|
|
8585
|
+
limit: options.limit ?? 500
|
|
8586
|
+
};
|
|
8587
|
+
const page = transcriptPurgedAtMs !== void 0 ? { events: [] } : "after" in boundary ? await readConversationEventPageAfter(getSqlExecutor(), {
|
|
8588
|
+
...pageArgs,
|
|
8589
|
+
afterSeq: cursor.seq
|
|
8590
|
+
}) : "around" in boundary ? await readConversationEventPageAround(getSqlExecutor(), {
|
|
8591
|
+
...pageArgs,
|
|
8592
|
+
seq: cursor.seq
|
|
8593
|
+
}) : await readConversationEventPage(getSqlExecutor(), {
|
|
8594
|
+
...pageArgs,
|
|
8595
|
+
beforeSeq: cursor.seq
|
|
8596
|
+
});
|
|
8597
|
+
return conversationEventPageSchema.parse(await conversationEventPageReport(getSqlExecutor(), {
|
|
8598
|
+
conversationId,
|
|
8599
|
+
eventHistory: conversationEventHistory({
|
|
8600
|
+
canExposePayload,
|
|
8601
|
+
...transcriptPurgedAtMs === void 0 ? void 0 : { transcriptPurgedAtMs }
|
|
8602
|
+
}),
|
|
8603
|
+
page
|
|
8604
|
+
}));
|
|
8605
|
+
}
|
|
8606
|
+
/** Attach mentions and signed cursors to one bounded page of events. */
|
|
8607
|
+
async function conversationEventPageReport(executor, args) {
|
|
8608
|
+
const { conversationId, page } = args;
|
|
8609
|
+
const cursorAt = (seq) => encodeConversationCursor({
|
|
8610
|
+
conversationId,
|
|
8611
|
+
seq
|
|
8612
|
+
});
|
|
8613
|
+
return {
|
|
8614
|
+
events: (await attachConversationMentions(executor, conversationId, { events: page.events })).events,
|
|
8615
|
+
eventHistory: args.eventHistory,
|
|
8616
|
+
...page.previousSeq === void 0 ? void 0 : { previousCursor: cursorAt(page.previousSeq) },
|
|
8617
|
+
...page.nextSeq === void 0 ? void 0 : { nextCursor: cursorAt(page.nextSeq) },
|
|
8618
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8619
|
+
};
|
|
8620
|
+
}
|
|
8450
8621
|
// src/api/conversations/fork.ts
|
|
8451
8622
|
/** Fork a Conversation that the viewer can read into a new root they own. */
|
|
8452
8623
|
async function forkConversationForViewer(viewer, sourceConversationId, body) {
|
|
@@ -8627,6 +8798,12 @@ function projectConversationDetail(args) {
|
|
|
8627
8798
|
canExposePayload,
|
|
8628
8799
|
...transcriptPurgedAtMs === void 0 ? void 0 : { transcriptPurgedAtMs }
|
|
8629
8800
|
}),
|
|
8801
|
+
...args.readPosition ? { readPosition: args.readPosition } : void 0,
|
|
8802
|
+
...args.unreadAfterSeq !== void 0 ? { unreadCursor: encodeConversationCursor({
|
|
8803
|
+
conversationId,
|
|
8804
|
+
seq: args.unreadAfterSeq
|
|
8805
|
+
}) } : void 0,
|
|
8806
|
+
...args.unreadPage ? { unreadPage: args.unreadPage } : void 0,
|
|
8630
8807
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8631
8808
|
...sentryConversationUrl ? { sentryConversationUrl } : void 0,
|
|
8632
8809
|
...args.sourceTask ? { sourceTask: args.sourceTask } : void 0
|
|
@@ -8637,7 +8814,7 @@ async function readConversationDetailFromSql(conversationId, options) {
|
|
|
8637
8814
|
if (!record) return void 0;
|
|
8638
8815
|
const viewerMarks = options.viewer ? await readConversationViewerMarks(options.viewer, conversationId) : void 0;
|
|
8639
8816
|
const executor = getSqlExecutor();
|
|
8640
|
-
const [accessByConversation, annotations, automationTitleByConversation, auxiliaryCostsByConversation, briefVersion, firstHumanMessageTextByConversation, modelUsage, metricsByConversation, people, sourceTask, teamDomainByTeamId] = await Promise.all([
|
|
8817
|
+
const [accessByConversation, annotations, automationTitleByConversation, auxiliaryCostsByConversation, briefVersion, firstHumanMessageTextByConversation, modelUsage, metricsByConversation, people, readPosition, sourceTask, teamDomainByTeamId] = await Promise.all([
|
|
8641
8818
|
readConversationAccessFromSql(getDb(), [conversationId], options.viewer),
|
|
8642
8819
|
listConversationAnnotations(getDb(), conversationId),
|
|
8643
8820
|
readAutomationTitlesByConversationId([record.conversation]),
|
|
@@ -8647,6 +8824,7 @@ async function readConversationDetailFromSql(conversationId, options) {
|
|
|
8647
8824
|
record.conversation.transcriptPurgedAtMs === void 0 ? readConversationModelUsageFromSql(executor, { conversationId }) : Promise.resolve([]),
|
|
8648
8825
|
readConversationTreeMetricsFromSql(getDb(), [conversationId]),
|
|
8649
8826
|
readConversationAuthors(getDb(), conversationId),
|
|
8827
|
+
options.viewer ? readConversationReadPosition(options.viewer, conversationId) : void 0,
|
|
8650
8828
|
readConversationSourceTask({
|
|
8651
8829
|
conversationId,
|
|
8652
8830
|
...options.viewer ? { viewer: options.viewer } : void 0
|
|
@@ -8655,16 +8833,28 @@ async function readConversationDetailFromSql(conversationId, options) {
|
|
|
8655
8833
|
]);
|
|
8656
8834
|
const access = accessByConversation.get(conversationId);
|
|
8657
8835
|
const sidebarAnnotations = access?.canViewPrivateContent ? (await listConversationSidebarAnnotations([conversationId], /* @__PURE__ */ new Map([[conversationId, annotations]])))[conversationId] : void 0;
|
|
8836
|
+
const canExposePayload = access?.canViewPrivateContent ?? false;
|
|
8658
8837
|
const page = record.conversation.transcriptPurgedAtMs === void 0 ? await readConversationEventPage(executor, {
|
|
8659
|
-
canExposePayload
|
|
8838
|
+
canExposePayload,
|
|
8660
8839
|
conversationId,
|
|
8661
8840
|
limit: options.limit
|
|
8662
8841
|
}) : { events: [] };
|
|
8842
|
+
const firstSeq = page.events[0]?.seq;
|
|
8843
|
+
const unreadAfterSeq = readPosition !== void 0 && page.previousSeq !== void 0 && firstSeq !== void 0 && readPosition.lastReadSeq + 1 < firstSeq ? readPosition.lastReadSeq : void 0;
|
|
8663
8844
|
const brief = access?.canViewPrivateContent ? briefVersion?.content : void 0;
|
|
8664
|
-
const { briefMentions, events } = await attachConversationMentions(executor, conversationId, {
|
|
8845
|
+
const [{ briefMentions, events }, unreadPage] = await Promise.all([attachConversationMentions(executor, conversationId, {
|
|
8665
8846
|
...brief ? { brief } : void 0,
|
|
8666
8847
|
events: page.events
|
|
8667
|
-
})
|
|
8848
|
+
}), options.unreadPage && unreadAfterSeq !== void 0 ? readConversationEventPageAround(executor, {
|
|
8849
|
+
canExposePayload,
|
|
8850
|
+
conversationId,
|
|
8851
|
+
limit: options.limit,
|
|
8852
|
+
seq: unreadAfterSeq
|
|
8853
|
+
}).then((around) => conversationEventPageReport(executor, {
|
|
8854
|
+
conversationId,
|
|
8855
|
+
eventHistory: conversationEventHistory({ canExposePayload }),
|
|
8856
|
+
page: around
|
|
8857
|
+
})).catch(() => void 0) : void 0]);
|
|
8668
8858
|
const metrics = metricsByConversation.get(conversationId);
|
|
8669
8859
|
const auxiliaryCosts = auxiliaryCostsByConversation.get(conversationId);
|
|
8670
8860
|
const childAgentTotals = childAgentTotalsReport(metrics, auxiliaryCosts);
|
|
@@ -8692,6 +8882,9 @@ async function readConversationDetailFromSql(conversationId, options) {
|
|
|
8692
8882
|
...sourceTask ? { sourceTask } : void 0,
|
|
8693
8883
|
teamDomainByTeamId,
|
|
8694
8884
|
...page.previousSeq === void 0 ? void 0 : { previousSeq: page.previousSeq },
|
|
8885
|
+
...readPosition ? { readPosition } : void 0,
|
|
8886
|
+
...unreadAfterSeq === void 0 ? void 0 : { unreadAfterSeq },
|
|
8887
|
+
...unreadPage ? { unreadPage } : void 0,
|
|
8695
8888
|
usage: metrics?.usage ?? record.usage ?? void 0
|
|
8696
8889
|
});
|
|
8697
8890
|
}
|
|
@@ -8702,17 +8895,15 @@ async function readConversationDetail(conversationId, options = {}) {
|
|
|
8702
8895
|
limit: options.limit ?? 500
|
|
8703
8896
|
});
|
|
8704
8897
|
if (!report) return void 0;
|
|
8705
|
-
const [forks, agentTree,
|
|
8898
|
+
const [forks, agentTree, autoArchive] = await Promise.all([
|
|
8706
8899
|
readConversationForks(conversationId, options.viewer),
|
|
8707
8900
|
readConversationAgentTree(conversationId, options.viewer),
|
|
8708
|
-
options.viewer ? readConversationReadPosition(options.viewer, conversationId) : void 0,
|
|
8709
8901
|
options.viewer && report.isParticipant ? readConversationAutoArchive(options.viewer, conversationId) : void 0
|
|
8710
8902
|
]);
|
|
8711
8903
|
return conversationDetailReportSchema.parse({
|
|
8712
8904
|
...report,
|
|
8713
8905
|
...forks,
|
|
8714
8906
|
...agentTree ? { agentTree } : void 0,
|
|
8715
|
-
...readPosition ? { readPosition } : void 0,
|
|
8716
8907
|
...autoArchive === void 0 ? void 0 : { autoArchive }
|
|
8717
8908
|
});
|
|
8718
8909
|
}
|
|
@@ -8768,4 +8959,4 @@ function viewerWebMessages(messages, viewer) {
|
|
|
8768
8959
|
}] : [];
|
|
8769
8960
|
});
|
|
8770
8961
|
}
|
|
8771
|
-
export {
|
|
8962
|
+
export { setConversationAutoArchive as $, recordSkippedConversationMessage as A, startProcessingReaction as B, getProductionSlackAdapter as C, isAllowedSignInEmail as D, isAllowedDomain as E, normalizeIncomingSlackThreadId as F, closeReviewItemsAnsweredByReply as G, parseContent as H, withNormalizedThreadId as I, DEFAULT_AUTO_ARCHIVE_SETTINGS as J, readReviewItemForUser as K, stopConversationTurn as L, clearSlackPendingReactions as M, isSlackMessageStopped as N, readEnvList as O, stopSlackThread as P, runAutoArchiveSweep as Q, THREAD_OPTOUT_ACK as R, createProductionSlackWebhookServices as S, assertNoLegacyAllowedDomains as T, ReviewItemActionError as U, stripLeadingBotMention as V, actOnReviewItem as W, readConversationAutoArchive as X, archiveViewerDoneConversations as Y, readUserAutoArchiveSettings as Z, readFirstHumanMessageTexts as _, readConversationAgentTree as a, AGENT_DISPATCH_MAX_AGE_MS as at, archiveConversation as b, readConversationForks as c, readHealthReport as ct, readConversationRecordFromSql as d, updateUserAutoArchiveSettings as et, readConversationAuxiliaryCostsFromSql as f, resolveMentions as g, conversationSummaryFromStoredConversation as h, readConversationReadPosition as i, getAttachmentStorage as it, buildSlackInboundMessage as j, resolveAllowedDomains as k, readConversationEvents as l, readConversationTreeMetricsFromSql as m, readConversationDetail as n, jsonResponse as nt, forkConversationForViewer as o, enqueueAgentDispatch as ot, childAgentTotalsReport as p, reviewItemChange as q, markConversationRead as r, throwApiError as rt, keepQuickQuestionForViewer as s, GET as st, stopConversationTurnForViewer as t, emptyResponse as tt, readConversationFeed as u, decodeConversationCursor as v, createSlackWebApiStatusSender as w, createProductionConversationWorkOptions as x, encodeConversationCursor as y, bindMessageAuthorIdentityId as z };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as getSqlExecutor, x as getConversationStore } from "./viewer-
|
|
3
|
-
import { a as juniorAgentInvocations, i as juniorAgentBindings, n as AGENT_INVOCATION_PARENT_MAILBOX_STATUSES, t as AGENT_INVOCATION_MAILBOX_STATUSES } from "./agent-invocations-
|
|
4
|
-
import "./executor-
|
|
5
|
-
import { p as credentialContextSchema } from "./registry-
|
|
1
|
+
import { g as TURN_REASONING_LEVELS } from "./config-o2jLRY5J.js";
|
|
2
|
+
import { C as getSqlExecutor, x as getConversationStore } from "./viewer-DLXajQZE.js";
|
|
3
|
+
import { a as juniorAgentInvocations, i as juniorAgentBindings, n as AGENT_INVOCATION_PARENT_MAILBOX_STATUSES, t as AGENT_INVOCATION_MAILBOX_STATUSES } from "./agent-invocations-D7c4BQGc.js";
|
|
4
|
+
import "./executor-CJfsD0VX.js";
|
|
5
|
+
import { p as credentialContextSchema } from "./registry-Cp6CNmtP.js";
|
|
6
6
|
import { createHash } from "node:crypto";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import { and, asc, count, countDistinct, desc, eq, inArray, lt, ne, or, sql } from "drizzle-orm";
|
|
@@ -105,8 +105,7 @@ function markTurnFailed(args) {
|
|
|
105
105
|
* code reads only these fields, never a type name, so types can later come
|
|
106
106
|
* from configuration. Types do not limit tools: Guardian reviews each child
|
|
107
107
|
* action against the root user's messages, as for any child. A child keeps its
|
|
108
|
-
* type for later agent invocations
|
|
109
|
-
* a type starts fresh.
|
|
108
|
+
* type for later agent invocations. A child without a type starts fresh.
|
|
110
109
|
*/
|
|
111
110
|
const AGENT_TYPES = [
|
|
112
111
|
"fork",
|
|
@@ -114,8 +113,8 @@ const AGENT_TYPES = [
|
|
|
114
113
|
"reviewer"
|
|
115
114
|
];
|
|
116
115
|
/**
|
|
117
|
-
* Stored name of a child agent type.
|
|
118
|
-
*
|
|
116
|
+
* Stored name of a child agent type. A stored name stays readable after its
|
|
117
|
+
* type is removed; the runtime then treats the child as a
|
|
119
118
|
* child without a type.
|
|
120
119
|
*/
|
|
121
120
|
const agentTypeSchema = z.string().regex(/^[a-z][a-z0-9_-]*$/);
|
|
@@ -179,7 +178,6 @@ const agentInvocationBaseSchema = z.object({
|
|
|
179
178
|
parentConversationId: exactStringSchema,
|
|
180
179
|
parentToolCallId: exactStringSchema.optional(),
|
|
181
180
|
agentType: agentTypeSchema.optional(),
|
|
182
|
-
modelProfile: modelProfileSchema.optional(),
|
|
183
181
|
reasoningLevel: z.enum(TURN_REASONING_LEVELS).optional(),
|
|
184
182
|
source: sourceSchema,
|
|
185
183
|
title: exactStringSchema.optional(),
|
|
@@ -218,7 +216,6 @@ const createAgentInvocationSchema = z.object({
|
|
|
218
216
|
parentConversationId: exactStringSchema,
|
|
219
217
|
parentToolCallId: exactStringSchema.optional(),
|
|
220
218
|
agentType: agentTypeSchema.optional(),
|
|
221
|
-
modelProfile: modelProfileSchema.optional(),
|
|
222
219
|
reasoningLevel: z.enum(TURN_REASONING_LEVELS).optional(),
|
|
223
220
|
title: exactStringSchema.optional()
|
|
224
221
|
}).strict();
|
|
@@ -385,7 +382,6 @@ function invocationFromRow(row) {
|
|
|
385
382
|
...row.parentMailboxStatus ? { parentMailboxStatus: row.parentMailboxStatus } : void 0,
|
|
386
383
|
...row.parentToolCallId ? { parentToolCallId: row.parentToolCallId } : void 0,
|
|
387
384
|
...row.agentType ? { agentType: row.agentType } : void 0,
|
|
388
|
-
...row.modelProfile ? { modelProfile: row.modelProfile } : void 0,
|
|
389
385
|
...row.reasoningLevel ? { reasoningLevel: row.reasoningLevel } : void 0,
|
|
390
386
|
...row.result !== null ? { result: row.result } : void 0,
|
|
391
387
|
source: row.source,
|
|
@@ -401,7 +397,7 @@ function invocationFromRow(row) {
|
|
|
401
397
|
* stored title wins.
|
|
402
398
|
*/
|
|
403
399
|
function sameCreateInput(invocation, input) {
|
|
404
|
-
return invocation.parentConversationId === input.parentConversationId && invocation.agentName === input.agentName && invocation.input === input.input && invocation.agentType === input.agentType && invocation.
|
|
400
|
+
return invocation.parentConversationId === input.parentConversationId && invocation.agentName === input.agentName && invocation.input === input.input && invocation.agentType === input.agentType && invocation.reasoningLevel === input.reasoningLevel && JSON.stringify(invocation.actor) === JSON.stringify(input.actor) && JSON.stringify(invocation.credentialContext) === JSON.stringify(input.credentialContext) && JSON.stringify(invocation.destination) === JSON.stringify(input.destination);
|
|
405
401
|
}
|
|
406
402
|
/** Read one durable agent invocation. */
|
|
407
403
|
async function getAgentInvocation(invocationId) {
|
|
@@ -503,7 +499,6 @@ async function createAgentInvocation(rawInput, nowMs = Date.now()) {
|
|
|
503
499
|
source: { kind: "agent_invocation" },
|
|
504
500
|
destination: input.destination,
|
|
505
501
|
agentType: input.agentType ?? null,
|
|
506
|
-
modelProfile: input.modelProfile ?? null,
|
|
507
502
|
reasoningLevel: input.reasoningLevel ?? null,
|
|
508
503
|
parentToolCallId: input.parentToolCallId ?? null,
|
|
509
504
|
status: "pending",
|
|
@@ -538,7 +533,6 @@ async function createAgentInvocationFromLatest(args, nowMs = Date.now()) {
|
|
|
538
533
|
source: args.runAs?.source ?? { kind: "agent_invocation" },
|
|
539
534
|
destination: args.latest.destination,
|
|
540
535
|
agentType: args.latest.agentType ?? null,
|
|
541
|
-
modelProfile: args.latest.modelProfile ?? null,
|
|
542
536
|
reasoningLevel: args.latest.reasoningLevel ?? null,
|
|
543
537
|
status: "pending",
|
|
544
538
|
mailboxStatus: "pending",
|
|
@@ -593,7 +587,6 @@ async function createAgentInvocationForMessage(input, nowMs = Date.now()) {
|
|
|
593
587
|
source: { kind: "agent_invocation" },
|
|
594
588
|
destination: input.destination,
|
|
595
589
|
agentType: latest.agentType ?? null,
|
|
596
|
-
modelProfile: latest.modelProfile ?? null,
|
|
597
590
|
reasoningLevel: latest.reasoningLevel ?? null,
|
|
598
591
|
parentToolCallId: input.parentToolCallId,
|
|
599
592
|
status: "pending",
|