@sentry/junior 0.278.0 → 0.279.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-BXosqTMx.js → adapter-phTTgw7H.js} +1 -1
- package/dist/{admin-Thn7NfOi.js → admin-PcpJDugZ.js} +1 -1
- package/dist/{agent-invocations-D7c4BQGc.js → agent-invocations-CUg_SODU.js} +0 -1
- package/dist/{agent-runner-DE-43MPb.js → agent-runner-DwvT1BY0.js} +76 -35
- 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 +37 -367
- package/dist/{app-CHNS-AX2.d.ts → app-DVs6noo7.d.ts} +3 -3
- package/dist/app.d.ts +1 -1
- package/dist/app.js +460 -77
- package/dist/{assistant-reply-pauL6qyn.js → assistant-reply-BXfxczd7.js} +1 -1
- package/dist/{automation-DphoTRYl.js → automation-BehArCcq.js} +1 -1
- package/dist/{background-compaction-queue-CAL4A2y7.js → background-compaction-queue-CcbuLJrZ.js} +2 -2
- package/dist/{briefs-4fyPJJEu.js → briefs-Dd_ezwED.js} +10 -9
- package/dist/{catalog-runtime-BoOb5oUv.js → catalog-runtime-BWVMeZhW.js} +2 -2
- package/dist/cli/chat.js +16 -16
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +4 -4
- package/dist/cli/plugins.js +5 -5
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +4 -4
- package/dist/{client-v_OVYuHZ.js → client-Bpxe4vKa.js} +7 -3
- package/dist/{config-o2jLRY5J.js → config-C_bmRhrJ.js} +2 -2
- package/dist/{connections-RC4NXAx8.js → connections-B2rHe5W5.js} +10 -10
- package/dist/{conversation-CZfyQvdm.js → conversation-CIiJtx5q.js} +6 -1
- package/dist/conversation-pending-messages-CnBvE6-6.js +173 -0
- package/dist/{conversation-privacy-C23M8KaD.js → conversation-privacy-CzOfcz0U.js} +1 -1
- package/dist/{credential-sync-Dd0WyNfF.js → credential-sync-Dal_unpv.js} +15 -15
- package/dist/{db-BjLzDJCt.d.ts → db-CyLrV9C7.d.ts} +1 -1
- package/dist/{executor-CJfsD0VX.js → executor-BfYH-Wws.js} +6 -4
- package/dist/instrumentation.d.ts +12 -0
- package/dist/instrumentation.js +56 -23
- package/dist/{logging-dFaXvBRK.js → logging-CkT3_Xxp.js} +2 -2
- package/dist/{message-DSwxIZet.js → message-Q5dkgaJ5.js} +10 -10
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +18 -6
- package/dist/{oauth-callback-server-CDcuCp27.js → oauth-callback-server-BDRaqe8O.js} +2 -2
- package/dist/{oauth-relay-C6ZAyJgf.js → oauth-relay-D0G3T16m.js} +1 -1
- package/dist/{package-discovery-DJBompdd.js → package-discovery-DJhGdS4c.js} +1 -1
- package/dist/{plugins-DOm9Y6qI.js → plugins-HYh_JOdw.js} +1 -1
- package/dist/{projection-BTge9wrH.js → projection-DWxX7pb1.js} +122 -44
- package/dist/{prompt-DDtCnlHP.js → prompt--dwus7Y-.js} +1 -1
- package/dist/proxy-path-BHYoKZdq.js +15 -0
- package/dist/{registry-Cp6CNmtP.js → registry-DnrdeO4s.js} +2 -2
- package/dist/{resolve-B_7h2cXx.js → resolve-C_QXfqD_.js} +3 -3
- package/dist/{result-5LBEfnLX.js → result-DNmOxT-N.js} +10 -10
- package/dist/{runner-C5-S4oq-.js → runner-zd_noJ1l.js} +11 -11
- package/dist/{sandbox-egress-signals-B4GehT1L.js → sandbox-egress-signals-DQjv-nbG.js} +1 -1
- package/dist/{schema-B5fpczDw.js → schema-CNJNzvr8.js} +5 -68
- package/dist/{schema-Tr484cCC.d.ts → schema-e90H5FIN.d.ts} +988 -1
- package/dist/sentry-BRTJqumy.js +51 -0
- package/dist/sentry-DrKC2NeM.d.ts +1 -0
- package/dist/sentry-route-name-BhwWnfqj.js +51 -0
- package/dist/{service-account-Cq_dLrZJ.js → service-account-BK26XlHo.js} +3 -3
- package/dist/{service-account-BkEv20zf.js → service-account-CCH2Hv4h.js} +3 -3
- package/dist/{session-stop-BsS4qFS2.js → session-stop-6Tf--T7G.js} +14 -14
- package/dist/{skills-M0BA0_s6.js → skills-BNrk8gi4.js} +4 -4
- package/dist/{spawn-BO3y7H4d.js → spawn-C75hAB9l.js} +3 -3
- package/dist/{stop-D5R82Wla.js → stop-RYbf7PWi.js} +516 -172
- package/dist/{store-BGBzQWNf.js → store-CO5vGjwD.js} +5 -5
- package/dist/{store-CGJZTEVz.js → store-G3h2djJU.js} +3 -3
- package/dist/{task-queue-UD27ei2U.js → task-queue-DlN58XeM.js} +3 -3
- package/dist/{task-runner-noxjOjkM.js → task-runner-B-Bdm23d.js} +21 -9
- package/dist/{thread-state-BSu6rM6p.js → thread-state-Cj_7Slru.js} +4 -4
- package/dist/{turn-failure-response-wahwyPrZ.js → turn-failure-response-CE7gaoC7.js} +7 -7
- package/dist/{turn-lifecycle-Bo4Trccw.js → turn-lifecycle-7sXwXLJ6.js} +1 -1
- package/dist/{turn-session-routing-DnSaaEpn.js → turn-session-routing-FBdaH1zf.js} +10 -10
- package/dist/{validation-B9-8iKyw.js → validation-DLWxEzWW.js} +2 -2
- package/dist/{version-C7HejFP2.js → version-DtQ8WFIZ.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-DLXajQZE.js → viewer-vsM8_90o.js} +5 -5
- package/dist/{work-DRGSlfia.js → work-DsoFRO_0.js} +10 -10
- package/dist/{worker-BGh5Dwc6.js → worker-6kZEsCXs.js} +7 -7
- package/migrations/0077_drop_agent_invocation_model_profile.sql +1 -0
- package/migrations/0078_plugin_conversation_index.sql +20 -0
- package/migrations/0079_conversation_event_author_index.sql +20 -0
- package/migrations/meta/0077_snapshot.json +4141 -0
- package/migrations/meta/0078_snapshot.json +4175 -0
- package/migrations/meta/0079_snapshot.json +4203 -0
- package/migrations/meta/_journal.json +21 -0
- package/package.json +5 -5
- package/dist/common-Eu6sx09c.js +0 -107
- package/dist/rolldown-runtime-nwUcYXjP.js +0 -27
- package/dist/sentry-MDkYAVPV.js +0 -23
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { i as getActiveSpan, r as continueTrace } from "./sentry-BRTJqumy.js";
|
|
2
|
+
import { $ as completeTurnRecord, $a as getSlackFileId, $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 readConversationEventPage, H as AuthorizationFlowDisabledError, Ha as viewerConversationMembership, Hi as normalizeSlackConversationId, I as upsertConversationMessage, Ia as conversationIsMemberRoot, Ii as downloadPrivateSlackFile, J as wasPendingAuthStopped, Jn as getReviewItem, K as clearPendingAuth, Ka as readConversationEventPageAfter, 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, Qa as notInheritedByForkChild, 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, Wa as readLatestConversationBrief, Wi as withSlackRetries, Wn as closeReviewItem, X as loadTurnCheckpoint, Xa as buildSentryConversationUrl, Xn as listReplyActionItems, Z as saveTurnCheckpoint, Zn as listWaitingConversations, a as loadProjection, an as trimTrailingAssistantMessages, ar as isOnlyAssignee, bi as normalizeSlackStatusText, d as recordAuthorizationCompleted, do as createPluginCache, et as failTurnRecord, fn as decideSubscribedThreadReply, h as recordSubscribedReplyRoute, ho as piMessageFromHistoryItem, i as loadConversationProjection, ir as canReadReviewItem, j as isHumanConversationMessage, k as estimateConversationContextTokens, ln as buildDeterministicAssistantMessageId, lr as reviewItemNeedsUser, mn as getThreadStopDecision, n as commitMessages, no as recordSlackAttachment, nr as canActOnReviewItem, nt as listTurnSummaries, o as loadTurnProjection, oo as listConversationAnnotations, pn as getSubscribedReplyPreflightDecision, po as configValueSchema, qa as readConversationEventPageAround, rt as recordTurnSummary, so as listConversationAnnotationsById, t as commitAcceptedReply, to as readAttachmentVisionSummary, tt as getTurnRecord, un as buildDeterministicTurnId, uo as lookupSlackUser, 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-DWxX7pb1.js";
|
|
3
|
+
import { a as completeText, c as resolveGatewayModel, m as escapeXml, r as completeDecision, x as isProviderRetryError } from "./client-Bpxe4vKa.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-C_bmRhrJ.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-CkT3_Xxp.js";
|
|
6
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";
|
|
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-
|
|
8
|
-
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-
|
|
9
|
-
import { C as juniorCodeChanges, _ as juniorConversationBriefs, b as juniorConversationEvents, c as juniorReviewItems, h as juniorConversationParticipants, m as juniorConversationReadPositions, o as juniorReviewItemConversations } from "./executor-
|
|
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-vsM8_90o.js";
|
|
8
|
+
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers, o as conversationReadColumns, s as juniorConversations } from "./agent-invocations-CUg_SODU.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-BfYH-Wws.js";
|
|
10
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-
|
|
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-
|
|
11
|
+
import { d as actorLogContext, f as credentialContextForActor } from "./registry-DnrdeO4s.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-DwvT1BY0.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, v as normalizeUserInputAnswer } from "./reporting-window-DgHgwQB3.js";
|
|
21
|
-
import { g as getTurnRequestDeadline, l as getVercelConversationWorkQueue } from "./background-compaction-queue-
|
|
22
|
-
import { D as stopConversationWork, 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 {
|
|
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, 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-phTTgw7H.js";
|
|
15
|
+
import { R as readMessageAttachments, c as conversationDetailReportSchema, p as conversationFeedSchema, u as conversationEventPageSchema } from "./conversation-CIiJtx5q.js";
|
|
16
|
+
import { a as EVENT_SYSTEM_ACTOR, o as isEventConversationMessage } from "./prompt--dwus7Y-.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-CO5vGjwD.js";
|
|
18
|
+
import { n as getAssistantReplyText, t as decideReply } from "./assistant-reply-BXfxczd7.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-6Tf--T7G.js";
|
|
20
|
+
import { _ as isEmptyUserInputAnswer, b as webMessageId, v as normalizeUserInputAnswer } from "./reporting-window-DgHgwQB3.js";
|
|
21
|
+
import { g as getTurnRequestDeadline, l as getVercelConversationWorkQueue } from "./background-compaction-queue-CcbuLJrZ.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-G3h2djJU.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-FBdaH1zf.js";
|
|
24
|
+
import { d as healthReportSchema, s as conversationPendingMessagesReportSchema, u as apiErrorSchema } from "./conversation-pending-messages-CnBvE6-6.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-DNmOxT-N.js";
|
|
26
|
+
import { n as getTurnLifecycle, t as ConversationTurnLifecycleService } from "./turn-lifecycle-7sXwXLJ6.js";
|
|
27
|
+
import { o as AgentRunError, s as executeTurn } from "./work-DsoFRO_0.js";
|
|
28
|
+
import { a as persistThreadStateById, i as persistThreadRuntimeState, n as getPersistedSandboxState, o as coerceThreadConversationState, r as getPersistedThreadState, t as getLocationConfigurationService } from "./thread-state-Cj_7Slru.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-B2rHe5W5.js";
|
|
30
|
+
import { t as bindMessageAgent } from "./message-Q5dkgaJ5.js";
|
|
31
|
+
import { t as bindSpawnAgent } from "./spawn-C75hAB9l.js";
|
|
32
|
+
import { n as scheduleSessionCompletedPluginTasks, t as processPluginTask } from "./task-runner-B-Bdm23d.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-CE7gaoC7.js";
|
|
34
34
|
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
35
35
|
import { z } from "zod";
|
|
36
36
|
import { and, asc, desc, eq, gt, inArray, isNotNull, isNull, lte, max, ne, or, sql } from "drizzle-orm";
|
|
@@ -3774,10 +3774,14 @@ function resolveSlackConversationContext(input) {
|
|
|
3774
3774
|
const type = typeFromSlackChannelType(input.channelType) ?? typeFromChannelId(input.channelId, input.channelName);
|
|
3775
3775
|
if (!type) return void 0;
|
|
3776
3776
|
const name = normalizeConversationName(type, input.channelName);
|
|
3777
|
+
const topic = input.channelTopic?.trim();
|
|
3778
|
+
const description = input.channelDescription?.trim();
|
|
3777
3779
|
const visibility = conversationVisibilityFromSlackChannelType(input.channelType);
|
|
3778
3780
|
return {
|
|
3779
3781
|
type,
|
|
3780
3782
|
...name ? { name } : void 0,
|
|
3783
|
+
...topic ? { topic } : void 0,
|
|
3784
|
+
...description ? { description } : void 0,
|
|
3781
3785
|
...visibility ? { visibility } : void 0,
|
|
3782
3786
|
...input.botUserId ? { botUserId: input.botUserId } : void 0
|
|
3783
3787
|
};
|
|
@@ -3887,33 +3891,30 @@ function inboundMessageProvenance(queued, teamId) {
|
|
|
3887
3891
|
});
|
|
3888
3892
|
return instructionProvenanceFor(author);
|
|
3889
3893
|
}
|
|
3890
|
-
/** Return the Slack channel name when it is available. */
|
|
3891
|
-
async function resolveChannelName(thread) {
|
|
3892
|
-
const existingName = thread.channel.name?.trim();
|
|
3893
|
-
if (existingName) return existingName;
|
|
3894
|
-
try {
|
|
3895
|
-
return (await thread.channel.fetchMetadata()).name?.trim() || void 0;
|
|
3896
|
-
} catch {
|
|
3897
|
-
return;
|
|
3898
|
-
}
|
|
3899
|
-
}
|
|
3900
3894
|
/**
|
|
3901
|
-
* Return the Slack channel type of a message
|
|
3895
|
+
* Return the Slack channel type, name, topic, and description of a message
|
|
3896
|
+
* with one `conversations.info` call.
|
|
3902
3897
|
*
|
|
3903
3898
|
* Slack delivers a channel mention as two events with the same `ts`: `message`
|
|
3904
3899
|
* has `channel_type`, and `app_mention` does not. Junior stores the event that
|
|
3905
|
-
* arrives first. When that event has no `channel_type`,
|
|
3906
|
-
*
|
|
3900
|
+
* arrives first. When that event has no `channel_type`, the live conversation
|
|
3901
|
+
* metadata supplies it, so the turn does not depend on the order of the two
|
|
3902
|
+
* events.
|
|
3907
3903
|
*/
|
|
3908
|
-
async function
|
|
3904
|
+
async function resolveSlackChannelFacts(message, channelId) {
|
|
3909
3905
|
const eventChannelType = resolveSlackChannelTypeFromMessage(message);
|
|
3910
|
-
if (eventChannelType) return eventChannelType;
|
|
3911
3906
|
const slackChannelId = parseSlackChannelId(channelId);
|
|
3912
|
-
if (!slackChannelId) return;
|
|
3907
|
+
if (!slackChannelId) return { channelType: eventChannelType };
|
|
3913
3908
|
try {
|
|
3914
|
-
|
|
3909
|
+
const info = await getConversationInfo(slackChannelId);
|
|
3910
|
+
return {
|
|
3911
|
+
channelType: eventChannelType ?? slackChannelTypeFromConversationInfo(info),
|
|
3912
|
+
name: info.name,
|
|
3913
|
+
topic: info.topic,
|
|
3914
|
+
description: info.description
|
|
3915
|
+
};
|
|
3915
3916
|
} catch (error) {
|
|
3916
|
-
if (error instanceof SlackActionError) return;
|
|
3917
|
+
if (error instanceof SlackActionError) return { channelType: eventChannelType };
|
|
3917
3918
|
throw error;
|
|
3918
3919
|
}
|
|
3919
3920
|
}
|
|
@@ -3982,13 +3983,16 @@ function createSlackTurn(deps) {
|
|
|
3982
3983
|
if (message.author.isMe) return;
|
|
3983
3984
|
const threadId = getThreadId(thread, message);
|
|
3984
3985
|
const channelId = getChannelId(thread, message);
|
|
3985
|
-
const
|
|
3986
|
+
const channelFacts = options.execution ? { channelType: resolveSlackChannelTypeFromMessage(message) } : await resolveSlackChannelFacts(message, channelId);
|
|
3987
|
+
const channelName = channelFacts.name;
|
|
3988
|
+
const slackChannelType = channelFacts.channelType;
|
|
3986
3989
|
const destination = requireSlackDestination(options.destination, "Slack reply execution");
|
|
3987
|
-
const slackChannelType = options.execution ? resolveSlackChannelTypeFromMessage(message) : await resolveSlackChannelType(message, channelId);
|
|
3988
3990
|
const slackConversation = resolveSlackConversationContext({
|
|
3989
3991
|
botUserId: deps.getSlackAdapter().botUserId,
|
|
3990
3992
|
channelId,
|
|
3991
3993
|
channelName,
|
|
3994
|
+
channelTopic: channelFacts.topic,
|
|
3995
|
+
channelDescription: channelFacts.description,
|
|
3992
3996
|
channelType: slackChannelType
|
|
3993
3997
|
});
|
|
3994
3998
|
const destinationVisibility = conversationVisibilityFromSlackChannelType(slackChannelType);
|
|
@@ -7118,6 +7122,398 @@ async function archiveConversation(viewer, conversationId, body) {
|
|
|
7118
7122
|
if (result.status === "missing") throwApiError(404, "Conversation not found.");
|
|
7119
7123
|
throwApiError(409, "Conversation received new activity.");
|
|
7120
7124
|
}
|
|
7125
|
+
// src/api/mentions.ts
|
|
7126
|
+
const SLACK_USER_MENTION_RE = /<@([UW][A-Z0-9]+)(?:\|[^<>]*)?>/g;
|
|
7127
|
+
function mentionedSlackUserIds(texts) {
|
|
7128
|
+
const ids = texts.flatMap((text) => text ? [...text.matchAll(SLACK_USER_MENTION_RE)].map((m) => m[1]) : []);
|
|
7129
|
+
return [...new Set(ids)];
|
|
7130
|
+
}
|
|
7131
|
+
/**
|
|
7132
|
+
* Resolve the people that each source mentions, in source order. Every API
|
|
7133
|
+
* that returns display text uses this, so the dashboard can show the same
|
|
7134
|
+
* names and People links everywhere. It does one identity query per Slack
|
|
7135
|
+
* workspace.
|
|
7136
|
+
*/
|
|
7137
|
+
async function resolveMentions(executor, sources) {
|
|
7138
|
+
const idsBySource = sources.map((source) => mentionedSlackUserIds(source.texts));
|
|
7139
|
+
const idsByTenant = /* @__PURE__ */ new Map();
|
|
7140
|
+
sources.forEach((source, index) => {
|
|
7141
|
+
if (idsBySource[index].length === 0) return;
|
|
7142
|
+
const ids = idsByTenant.get(source.tenantId) ?? /* @__PURE__ */ new Set();
|
|
7143
|
+
for (const id of idsBySource[index]) ids.add(id);
|
|
7144
|
+
idsByTenant.set(source.tenantId, ids);
|
|
7145
|
+
});
|
|
7146
|
+
const peopleByTenant = new Map(await Promise.all([...idsByTenant].map(async ([tenantId, ids]) => [tenantId, await readMentionedPeople(executor, tenantId, [...ids])])));
|
|
7147
|
+
return sources.map((source, index) => {
|
|
7148
|
+
const people = peopleByTenant.get(source.tenantId);
|
|
7149
|
+
return idsBySource[index].flatMap((id) => {
|
|
7150
|
+
const person = people?.get(id);
|
|
7151
|
+
return person ? [person] : [];
|
|
7152
|
+
});
|
|
7153
|
+
});
|
|
7154
|
+
}
|
|
7155
|
+
/**
|
|
7156
|
+
* Read current names for mentioned Slack users. Known Junior identities come
|
|
7157
|
+
* first. The email is set only for a linked, verified Junior user, because
|
|
7158
|
+
* that email is the People profile route.
|
|
7159
|
+
*/
|
|
7160
|
+
async function readMentionedPeople(executor, tenantId, userIds) {
|
|
7161
|
+
const rows = await executor.db().select({
|
|
7162
|
+
displayName: juniorIdentities.displayName,
|
|
7163
|
+
emailVerified: juniorIdentities.emailVerified,
|
|
7164
|
+
handle: juniorIdentities.handle,
|
|
7165
|
+
providerSubjectId: juniorIdentities.providerSubjectId,
|
|
7166
|
+
userDisplayName: juniorUsers.displayName,
|
|
7167
|
+
userEmail: juniorUsers.primaryEmail
|
|
7168
|
+
}).from(juniorIdentities).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(and(eq(juniorIdentities.provider, "slack"), inArray(juniorIdentities.providerSubjectId, userIds), tenantId ? eq(juniorIdentities.providerTenantId, tenantId) : void 0));
|
|
7169
|
+
const people = /* @__PURE__ */ new Map();
|
|
7170
|
+
for (const row of rows) {
|
|
7171
|
+
if (people.has(row.providerSubjectId)) continue;
|
|
7172
|
+
const fullName = row.userDisplayName?.trim() || row.displayName?.trim();
|
|
7173
|
+
const email = row.emailVerified ? row.userEmail?.trim() : void 0;
|
|
7174
|
+
people.set(row.providerSubjectId, {
|
|
7175
|
+
slackUserId: row.providerSubjectId,
|
|
7176
|
+
...fullName ? { fullName } : void 0,
|
|
7177
|
+
...row.handle ? { slackUserName: row.handle } : void 0,
|
|
7178
|
+
...email ? { email } : void 0
|
|
7179
|
+
});
|
|
7180
|
+
}
|
|
7181
|
+
const unnamed = userIds.filter((id) => {
|
|
7182
|
+
const person = people.get(id);
|
|
7183
|
+
return !person?.fullName && !person?.slackUserName;
|
|
7184
|
+
});
|
|
7185
|
+
if (tenantId && unnamed.length > 0) {
|
|
7186
|
+
const profiles = await Promise.all(unnamed.map((id) => lookupSlackUser(tenantId, id)));
|
|
7187
|
+
unnamed.forEach((id, index) => {
|
|
7188
|
+
const profile = profiles[index];
|
|
7189
|
+
if (!profile?.fullName && !profile?.userName) return;
|
|
7190
|
+
people.set(id, {
|
|
7191
|
+
...people.get(id),
|
|
7192
|
+
slackUserId: id,
|
|
7193
|
+
...profile.fullName ? { fullName: profile.fullName } : void 0,
|
|
7194
|
+
...profile.userName ? { slackUserName: profile.userName } : void 0
|
|
7195
|
+
});
|
|
7196
|
+
});
|
|
7197
|
+
}
|
|
7198
|
+
return people;
|
|
7199
|
+
}
|
|
7200
|
+
// src/api/conversations/pending-messages.ts
|
|
7201
|
+
const slackMailboxAuthorSchema = z.object({
|
|
7202
|
+
userId: z.string(),
|
|
7203
|
+
userName: z.string().optional(),
|
|
7204
|
+
fullName: z.string().optional(),
|
|
7205
|
+
isMe: z.boolean().optional()
|
|
7206
|
+
}).passthrough();
|
|
7207
|
+
const slackMailboxMessageSchema = z.object({
|
|
7208
|
+
author: slackMailboxAuthorSchema,
|
|
7209
|
+
id: z.string().min(1),
|
|
7210
|
+
raw: z.unknown().optional()
|
|
7211
|
+
}).passthrough();
|
|
7212
|
+
const slackMailboxMetadataSchema = z.object({
|
|
7213
|
+
message: slackMailboxMessageSchema,
|
|
7214
|
+
platform: z.literal("slack")
|
|
7215
|
+
}).passthrough();
|
|
7216
|
+
/**
|
|
7217
|
+
* Project Slack text the way the Turn stores it in history. The SDK text
|
|
7218
|
+
* turns `<@U123>` into a bare `@U123` or `@name`, which the dashboard
|
|
7219
|
+
* cannot render as a mention.
|
|
7220
|
+
*/
|
|
7221
|
+
function slackDisplayText(message, sdkText) {
|
|
7222
|
+
return parseContent({
|
|
7223
|
+
attachments: [],
|
|
7224
|
+
formatted: {
|
|
7225
|
+
type: "root",
|
|
7226
|
+
children: []
|
|
7227
|
+
},
|
|
7228
|
+
raw: message.raw,
|
|
7229
|
+
text: sdkText
|
|
7230
|
+
}).text;
|
|
7231
|
+
}
|
|
7232
|
+
function isoFromMs(value) {
|
|
7233
|
+
return new Date(value).toISOString();
|
|
7234
|
+
}
|
|
7235
|
+
function actorIdentityFromWebMetadata(metadata) {
|
|
7236
|
+
return {
|
|
7237
|
+
email: metadata.authorEmail.trim().toLowerCase(),
|
|
7238
|
+
...metadata.authorFullName ? { fullName: metadata.authorFullName } : void 0
|
|
7239
|
+
};
|
|
7240
|
+
}
|
|
7241
|
+
async function actorIdentityFromSlackMetadata(metadata, teamId) {
|
|
7242
|
+
if (metadata.message.author.isMe === true) return void 0;
|
|
7243
|
+
const slackUserId = metadata.message.author.userId.trim();
|
|
7244
|
+
if (!slackUserId) return void 0;
|
|
7245
|
+
const profile = teamId ? await lookupSlackUser(teamId, slackUserId) : null;
|
|
7246
|
+
const slackUserName = profile?.userName?.trim() || metadata.message.author.userName?.trim();
|
|
7247
|
+
const fullName = profile?.fullName?.trim() || metadata.message.author.fullName?.trim();
|
|
7248
|
+
const email = profile?.email?.trim().toLowerCase();
|
|
7249
|
+
return {
|
|
7250
|
+
slackUserId,
|
|
7251
|
+
...slackUserName ? { slackUserName } : void 0,
|
|
7252
|
+
...fullName ? { fullName } : void 0,
|
|
7253
|
+
...email ? { email } : void 0
|
|
7254
|
+
};
|
|
7255
|
+
}
|
|
7256
|
+
async function projectPendingMessage(message, canExposePayload) {
|
|
7257
|
+
if (message.source === "web") {
|
|
7258
|
+
const metadata = legacyWebMailboxMetadataSchema.safeParse(message.input.metadata);
|
|
7259
|
+
if (!metadata.success) return void 0;
|
|
7260
|
+
const text = message.input.text.trim();
|
|
7261
|
+
const attachments = readMessageAttachments(message.input.attachments);
|
|
7262
|
+
if (!text && !attachments.length) return void 0;
|
|
7263
|
+
return {
|
|
7264
|
+
createdAt: isoFromMs(message.createdAtMs),
|
|
7265
|
+
delivery: message.delivery,
|
|
7266
|
+
inboundMessageId: message.inboundMessageId,
|
|
7267
|
+
messageId: metadata.data.messageId,
|
|
7268
|
+
receivedAt: isoFromMs(message.receivedAtMs),
|
|
7269
|
+
role: "user",
|
|
7270
|
+
source: "web",
|
|
7271
|
+
...canExposePayload ? {
|
|
7272
|
+
actorIdentity: actorIdentityFromWebMetadata(metadata.data),
|
|
7273
|
+
text,
|
|
7274
|
+
...attachments.length ? { attachments } : void 0,
|
|
7275
|
+
...message.input.reviewItemChange ? { reviewItemChange: message.input.reviewItemChange } : void 0
|
|
7276
|
+
} : { redacted: true }
|
|
7277
|
+
};
|
|
7278
|
+
}
|
|
7279
|
+
if (message.source === "slack") {
|
|
7280
|
+
const metadata = slackMailboxMetadataSchema.safeParse(message.input.metadata);
|
|
7281
|
+
if (!metadata.success) return void 0;
|
|
7282
|
+
if (metadata.data.message.author.isMe === true) return void 0;
|
|
7283
|
+
const text = slackDisplayText(metadata.data.message, message.input.text).trim();
|
|
7284
|
+
if (!text) return void 0;
|
|
7285
|
+
if (!canExposePayload) return {
|
|
7286
|
+
createdAt: isoFromMs(message.createdAtMs),
|
|
7287
|
+
delivery: message.delivery,
|
|
7288
|
+
inboundMessageId: message.inboundMessageId,
|
|
7289
|
+
messageId: metadata.data.message.id,
|
|
7290
|
+
receivedAt: isoFromMs(message.receivedAtMs),
|
|
7291
|
+
redacted: true,
|
|
7292
|
+
role: "user",
|
|
7293
|
+
source: "slack"
|
|
7294
|
+
};
|
|
7295
|
+
const actorIdentity = await actorIdentityFromSlackMetadata(metadata.data, message.destination?.platform === "slack" ? message.destination.teamId : void 0);
|
|
7296
|
+
return {
|
|
7297
|
+
createdAt: isoFromMs(message.createdAtMs),
|
|
7298
|
+
delivery: message.delivery,
|
|
7299
|
+
inboundMessageId: message.inboundMessageId,
|
|
7300
|
+
messageId: metadata.data.message.id,
|
|
7301
|
+
receivedAt: isoFromMs(message.receivedAtMs),
|
|
7302
|
+
role: "user",
|
|
7303
|
+
source: "slack",
|
|
7304
|
+
...actorIdentity ? { actorIdentity } : void 0,
|
|
7305
|
+
...message.input.reviewItemChange ? { reviewItemChange: message.input.reviewItemChange } : void 0,
|
|
7306
|
+
text
|
|
7307
|
+
};
|
|
7308
|
+
}
|
|
7309
|
+
}
|
|
7310
|
+
async function attachPendingMentions(conversationId, messages) {
|
|
7311
|
+
if (!messages.some((message) => message.text?.includes("<@"))) return messages;
|
|
7312
|
+
const executor = getSqlExecutor();
|
|
7313
|
+
const tenantId = (await loadConversationSlackTenantIds(executor, [conversationId])).get(conversationId);
|
|
7314
|
+
const mentions = await resolveMentions(executor, messages.map((message) => ({
|
|
7315
|
+
tenantId,
|
|
7316
|
+
texts: [message.text]
|
|
7317
|
+
})));
|
|
7318
|
+
return messages.map((message, index) => mentions[index].length > 0 ? {
|
|
7319
|
+
...message,
|
|
7320
|
+
mentions: mentions[index]
|
|
7321
|
+
} : message);
|
|
7322
|
+
}
|
|
7323
|
+
/** Read the viewer's pending authorization, also one saved before a deploy. */
|
|
7324
|
+
async function findViewerWebAuthorization(conversationId, viewer) {
|
|
7325
|
+
for (const actorId of webActorUserIds(viewer)) {
|
|
7326
|
+
const authorization = await getWebAuthorization({
|
|
7327
|
+
actorId,
|
|
7328
|
+
conversationId
|
|
7329
|
+
});
|
|
7330
|
+
if (authorization) return authorization;
|
|
7331
|
+
}
|
|
7332
|
+
}
|
|
7333
|
+
/**
|
|
7334
|
+
* Read accepted mailbox messages that have not reached durable history yet.
|
|
7335
|
+
*
|
|
7336
|
+
* Returns only human-facing web and Slack rows. Internal mailbox work stays
|
|
7337
|
+
* hidden from the transcript.
|
|
7338
|
+
*/
|
|
7339
|
+
async function readConversationPendingMessages(conversationId, options = {}) {
|
|
7340
|
+
if (!await getConversationStore().get({ conversationId })) return void 0;
|
|
7341
|
+
const access = (await readConversationAccessFromSql(getDb(), [conversationId], options.viewer)).get(conversationId);
|
|
7342
|
+
const canExposePayload = access?.canViewPrivateContent ?? false;
|
|
7343
|
+
const authorization = (access?.isParticipant ?? false) && options.viewer ? await findViewerWebAuthorization(conversationId, options.viewer) : void 0;
|
|
7344
|
+
const pendingMessages = (await getConversation({ conversationId }))?.execution.pendingMessages ?? [];
|
|
7345
|
+
const messages = await attachPendingMentions(conversationId, (await Promise.all(pendingMessages.map((message) => projectPendingMessage(message, canExposePayload)))).flatMap((message, index) => {
|
|
7346
|
+
if (!message) return [];
|
|
7347
|
+
const actorIdentityId = pendingMessages[index].input.authorIdentityId;
|
|
7348
|
+
return [canExposePayload && actorIdentityId ? {
|
|
7349
|
+
...message,
|
|
7350
|
+
actorIdentityId
|
|
7351
|
+
} : message];
|
|
7352
|
+
}));
|
|
7353
|
+
return conversationPendingMessagesReportSchema.parse({
|
|
7354
|
+
...authorization ? { authorization: {
|
|
7355
|
+
authorizationUrl: authorization.authorizationUrl,
|
|
7356
|
+
completionText: authorization.completionText,
|
|
7357
|
+
label: authorization.label
|
|
7358
|
+
} } : void 0,
|
|
7359
|
+
conversationId,
|
|
7360
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7361
|
+
messages
|
|
7362
|
+
});
|
|
7363
|
+
}
|
|
7364
|
+
/** Load pending mailbox messages or throw a standard API not-found error. */
|
|
7365
|
+
async function requireConversationPendingMessages(conversationId, options = {}) {
|
|
7366
|
+
const report = await readConversationPendingMessages(conversationId, options);
|
|
7367
|
+
if (!report) throwApiError(404, "Conversation not found.");
|
|
7368
|
+
return report;
|
|
7369
|
+
}
|
|
7370
|
+
// src/api/conversations/cancel-pending-messages.ts
|
|
7371
|
+
/** Cancel accepted human-facing mailbox rows for one conversation participant. */
|
|
7372
|
+
async function cancelConversationPendingMessagesForViewer(viewer, conversationId, body = {}) {
|
|
7373
|
+
if (!await getConversationStore().get({ conversationId })) throwApiError(404, "Conversation not found.");
|
|
7374
|
+
if (!(await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId)?.isParticipant) throwApiError(403, "Only conversation participants can cancel queued messages.");
|
|
7375
|
+
try {
|
|
7376
|
+
const result = await cancelHumanFacingPendingMessages({
|
|
7377
|
+
conversationId,
|
|
7378
|
+
...body.inboundMessageIds ? { inboundMessageIds: body.inboundMessageIds } : void 0,
|
|
7379
|
+
...body.receivedBefore ? { receivedBeforeMs: Date.parse(body.receivedBefore) } : void 0,
|
|
7380
|
+
conversationStore: getConversationStore()
|
|
7381
|
+
});
|
|
7382
|
+
await clearSlackPendingReactions({
|
|
7383
|
+
getSlackAdapter: getProductionSlackAdapter,
|
|
7384
|
+
messages: result.cancelledMessages
|
|
7385
|
+
});
|
|
7386
|
+
return {
|
|
7387
|
+
cancelledCount: result.cancelledInboundMessageIds.length,
|
|
7388
|
+
cancelledInboundMessageIds: result.cancelledInboundMessageIds,
|
|
7389
|
+
conversationId
|
|
7390
|
+
};
|
|
7391
|
+
} catch (error) {
|
|
7392
|
+
throwApiError(500, "Unable to cancel queued messages.", error);
|
|
7393
|
+
}
|
|
7394
|
+
}
|
|
7395
|
+
// src/api/conversations/cursor.ts
|
|
7396
|
+
const CURSOR_CONTEXT = "junior-conversation-report-cursor";
|
|
7397
|
+
const conversationCursorPayloadSchema = z.object({
|
|
7398
|
+
conversationId: z.string().min(1),
|
|
7399
|
+
seq: z.number().int().min(-1),
|
|
7400
|
+
version: z.literal(1)
|
|
7401
|
+
}).strict();
|
|
7402
|
+
function cursorSecret() {
|
|
7403
|
+
const secret = process.env.JUNIOR_SECRET?.trim();
|
|
7404
|
+
if (!secret) throw new Error("Cannot sign conversation cursor without JUNIOR_SECRET");
|
|
7405
|
+
return secret;
|
|
7406
|
+
}
|
|
7407
|
+
/** Sign one encoded cursor with the domain-separated server secret. */
|
|
7408
|
+
function signature(payload) {
|
|
7409
|
+
return createHmac("sha256", cursorSecret()).update(`${CURSOR_CONTEXT}:${payload}`).digest("base64url");
|
|
7410
|
+
}
|
|
7411
|
+
/** Encode an authenticated, conversation-bound event position for an API cursor. */
|
|
7412
|
+
function encodeConversationCursor(payload) {
|
|
7413
|
+
const encoded = Buffer.from(JSON.stringify({
|
|
7414
|
+
...payload,
|
|
7415
|
+
version: 1
|
|
7416
|
+
}), "utf8").toString("base64url");
|
|
7417
|
+
return `${encoded}.${signature(encoded)}`;
|
|
7418
|
+
}
|
|
7419
|
+
/** Decode an authenticated reporting cursor for the expected conversation. */
|
|
7420
|
+
function decodeConversationCursor(args) {
|
|
7421
|
+
const [encoded, actualSignature, extra] = args.cursor.split(".");
|
|
7422
|
+
if (!encoded || !actualSignature || extra !== void 0) return void 0;
|
|
7423
|
+
const expected = Buffer.from(signature(encoded));
|
|
7424
|
+
const actual = Buffer.from(actualSignature);
|
|
7425
|
+
if (expected.length !== actual.length || !timingSafeEqual(expected, actual)) return;
|
|
7426
|
+
try {
|
|
7427
|
+
const parsed = conversationCursorPayloadSchema.parse(JSON.parse(Buffer.from(encoded, "base64url").toString("utf8")));
|
|
7428
|
+
if (parsed.conversationId !== args.conversationId) return;
|
|
7429
|
+
return { seq: parsed.seq };
|
|
7430
|
+
} catch {
|
|
7431
|
+
return;
|
|
7432
|
+
}
|
|
7433
|
+
}
|
|
7434
|
+
// src/api/conversations/create.ts
|
|
7435
|
+
/** Turn image validation failures into request errors before accepting work. */
|
|
7436
|
+
function parseImages(images) {
|
|
7437
|
+
try {
|
|
7438
|
+
return decodeInputImages(images ?? []);
|
|
7439
|
+
} catch (error) {
|
|
7440
|
+
throwApiError(400, error instanceof Error ? error.message : "Unable to read images.");
|
|
7441
|
+
}
|
|
7442
|
+
}
|
|
7443
|
+
function actorFromViewer(viewer) {
|
|
7444
|
+
const normalized = viewer.email.trim().toLowerCase();
|
|
7445
|
+
return webActorFromUser(viewer, { userName: normalized.split("@")[0] || normalized });
|
|
7446
|
+
}
|
|
7447
|
+
/** Create a dashboard root conversation and enqueue its first message. */
|
|
7448
|
+
async function createConversationForViewer(viewer, body, services) {
|
|
7449
|
+
const images = parseImages(body.images);
|
|
7450
|
+
try {
|
|
7451
|
+
return await createAndEnqueueConversation({
|
|
7452
|
+
actor: actorFromViewer(viewer),
|
|
7453
|
+
idempotencyKey: body.idempotencyKey,
|
|
7454
|
+
message: body.message,
|
|
7455
|
+
images,
|
|
7456
|
+
...body.visibility ? { visibility: body.visibility } : void 0
|
|
7457
|
+
}, {
|
|
7458
|
+
conversationStore: getConversationStore(),
|
|
7459
|
+
attachmentStorage: services.attachmentStorage,
|
|
7460
|
+
queue: services.queue
|
|
7461
|
+
});
|
|
7462
|
+
} catch (error) {
|
|
7463
|
+
throwApiError(500, "Unable to create conversation.", error);
|
|
7464
|
+
}
|
|
7465
|
+
}
|
|
7466
|
+
/** Append one dashboard message to an existing conversation. */
|
|
7467
|
+
async function appendConversationMessageForViewer(viewer, conversationId, body, services) {
|
|
7468
|
+
const conversation = await getConversationStore().get({ conversationId });
|
|
7469
|
+
if (!conversation) throwApiError(404, "Conversation not found.");
|
|
7470
|
+
if (!acceptsWebMessages(conversationId, conversation.destination)) throwApiError(409, "Conversation does not accept web messages.");
|
|
7471
|
+
if (!(await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId)?.isParticipant) throwApiError(403, "Only conversation participants can add messages.");
|
|
7472
|
+
const images = parseImages(body.images);
|
|
7473
|
+
const actor = actorFromViewer(viewer);
|
|
7474
|
+
const append = () => appendAndEnqueueWebMessage({
|
|
7475
|
+
actor,
|
|
7476
|
+
conversationId,
|
|
7477
|
+
idempotencyKey: body.idempotencyKey,
|
|
7478
|
+
message: body.message,
|
|
7479
|
+
images
|
|
7480
|
+
}, {
|
|
7481
|
+
conversationStore: getConversationStore(),
|
|
7482
|
+
attachmentStorage: services.attachmentStorage,
|
|
7483
|
+
queue: services.queue
|
|
7484
|
+
});
|
|
7485
|
+
const closeAnswered = () => closeReviewItemsAnsweredByReply({
|
|
7486
|
+
conversationId,
|
|
7487
|
+
delivery: {
|
|
7488
|
+
queue: services.queue,
|
|
7489
|
+
show: createSlackReviewItemShow(getProductionSlackAdapter)
|
|
7490
|
+
},
|
|
7491
|
+
resolveUser: async () => viewer,
|
|
7492
|
+
text: body.message
|
|
7493
|
+
});
|
|
7494
|
+
try {
|
|
7495
|
+
let accepted;
|
|
7496
|
+
try {
|
|
7497
|
+
accepted = await append();
|
|
7498
|
+
} catch (error) {
|
|
7499
|
+
const state = getStateAdapter();
|
|
7500
|
+
await state.connect();
|
|
7501
|
+
const [messageId, work] = await Promise.all([webMessageId({
|
|
7502
|
+
conversationId,
|
|
7503
|
+
idempotencyKey: body.idempotencyKey
|
|
7504
|
+
}), getConversationWorkState({
|
|
7505
|
+
conversationId,
|
|
7506
|
+
state
|
|
7507
|
+
})]);
|
|
7508
|
+
if (work?.execution.inboundMessageIds.includes(messageId)) await closeAnswered();
|
|
7509
|
+
throw error;
|
|
7510
|
+
}
|
|
7511
|
+
await closeAnswered();
|
|
7512
|
+
return accepted;
|
|
7513
|
+
} catch (error) {
|
|
7514
|
+
throwApiError(500, "Unable to append message.", error);
|
|
7515
|
+
}
|
|
7516
|
+
}
|
|
7121
7517
|
// src/chat/plugins/conversation-sidebar.ts
|
|
7122
7518
|
/** Show native objects by default and let plugins select compact sidebar labels. */
|
|
7123
7519
|
async function listConversationSidebarAnnotations(conversationIds, annotationsByConversation) {
|
|
@@ -7687,45 +8083,6 @@ async function readConversationModelUsageFromSql(executor, options) {
|
|
|
7687
8083
|
}] : [];
|
|
7688
8084
|
});
|
|
7689
8085
|
}
|
|
7690
|
-
// src/api/conversations/cursor.ts
|
|
7691
|
-
const CURSOR_CONTEXT = "junior-conversation-report-cursor";
|
|
7692
|
-
const conversationCursorPayloadSchema = z.object({
|
|
7693
|
-
conversationId: z.string().min(1),
|
|
7694
|
-
seq: z.number().int().min(-1),
|
|
7695
|
-
version: z.literal(1)
|
|
7696
|
-
}).strict();
|
|
7697
|
-
function cursorSecret() {
|
|
7698
|
-
const secret = process.env.JUNIOR_SECRET?.trim();
|
|
7699
|
-
if (!secret) throw new Error("Cannot sign conversation cursor without JUNIOR_SECRET");
|
|
7700
|
-
return secret;
|
|
7701
|
-
}
|
|
7702
|
-
/** Sign one encoded cursor with the domain-separated server secret. */
|
|
7703
|
-
function signature(payload) {
|
|
7704
|
-
return createHmac("sha256", cursorSecret()).update(`${CURSOR_CONTEXT}:${payload}`).digest("base64url");
|
|
7705
|
-
}
|
|
7706
|
-
/** Encode an authenticated, conversation-bound event position for an API cursor. */
|
|
7707
|
-
function encodeConversationCursor(payload) {
|
|
7708
|
-
const encoded = Buffer.from(JSON.stringify({
|
|
7709
|
-
...payload,
|
|
7710
|
-
version: 1
|
|
7711
|
-
}), "utf8").toString("base64url");
|
|
7712
|
-
return `${encoded}.${signature(encoded)}`;
|
|
7713
|
-
}
|
|
7714
|
-
/** Decode an authenticated reporting cursor for the expected conversation. */
|
|
7715
|
-
function decodeConversationCursor(args) {
|
|
7716
|
-
const [encoded, actualSignature, extra] = args.cursor.split(".");
|
|
7717
|
-
if (!encoded || !actualSignature || extra !== void 0) return void 0;
|
|
7718
|
-
const expected = Buffer.from(signature(encoded));
|
|
7719
|
-
const actual = Buffer.from(actualSignature);
|
|
7720
|
-
if (expected.length !== actual.length || !timingSafeEqual(expected, actual)) return;
|
|
7721
|
-
try {
|
|
7722
|
-
const parsed = conversationCursorPayloadSchema.parse(JSON.parse(Buffer.from(encoded, "base64url").toString("utf8")));
|
|
7723
|
-
if (parsed.conversationId !== args.conversationId) return;
|
|
7724
|
-
return { seq: parsed.seq };
|
|
7725
|
-
} catch {
|
|
7726
|
-
return;
|
|
7727
|
-
}
|
|
7728
|
-
}
|
|
7729
8086
|
// src/api/conversations/first-message.ts
|
|
7730
8087
|
/**
|
|
7731
8088
|
* Read the text of the first human message for each untitled conversation.
|
|
@@ -7741,81 +8098,6 @@ async function readFirstHumanMessageTexts(db, conversations) {
|
|
|
7741
8098
|
}).from(juniorConversationEvents).where(and(inArray(juniorConversationEvents.conversationId, untitledIds), eq(juniorConversationEvents.type, "message"), sql`${juniorConversationEvents.payload}->>'role' = 'user'`, sql`coalesce(${juniorConversationEvents.payload}->'meta'->'author'->>'isBot', 'false') <> 'true'`, isNotNull(sql`nullif(btrim(${text}), '')`))).orderBy(juniorConversationEvents.conversationId, asc(juniorConversationEvents.createdAt), asc(juniorConversationEvents.seq));
|
|
7742
8099
|
return new Map(rows.map((row) => [row.conversationId, row.text]));
|
|
7743
8100
|
}
|
|
7744
|
-
// src/api/mentions.ts
|
|
7745
|
-
const SLACK_USER_MENTION_RE = /<@([UW][A-Z0-9]+)(?:\|[^<>]*)?>/g;
|
|
7746
|
-
function mentionedSlackUserIds(texts) {
|
|
7747
|
-
const ids = texts.flatMap((text) => text ? [...text.matchAll(SLACK_USER_MENTION_RE)].map((m) => m[1]) : []);
|
|
7748
|
-
return [...new Set(ids)];
|
|
7749
|
-
}
|
|
7750
|
-
/**
|
|
7751
|
-
* Resolve the people that each source mentions, in source order. Every API
|
|
7752
|
-
* that returns display text uses this, so the dashboard can show the same
|
|
7753
|
-
* names and People links everywhere. It does one identity query per Slack
|
|
7754
|
-
* workspace.
|
|
7755
|
-
*/
|
|
7756
|
-
async function resolveMentions(executor, sources) {
|
|
7757
|
-
const idsBySource = sources.map((source) => mentionedSlackUserIds(source.texts));
|
|
7758
|
-
const idsByTenant = /* @__PURE__ */ new Map();
|
|
7759
|
-
sources.forEach((source, index) => {
|
|
7760
|
-
if (idsBySource[index].length === 0) return;
|
|
7761
|
-
const ids = idsByTenant.get(source.tenantId) ?? /* @__PURE__ */ new Set();
|
|
7762
|
-
for (const id of idsBySource[index]) ids.add(id);
|
|
7763
|
-
idsByTenant.set(source.tenantId, ids);
|
|
7764
|
-
});
|
|
7765
|
-
const peopleByTenant = new Map(await Promise.all([...idsByTenant].map(async ([tenantId, ids]) => [tenantId, await readMentionedPeople(executor, tenantId, [...ids])])));
|
|
7766
|
-
return sources.map((source, index) => {
|
|
7767
|
-
const people = peopleByTenant.get(source.tenantId);
|
|
7768
|
-
return idsBySource[index].flatMap((id) => {
|
|
7769
|
-
const person = people?.get(id);
|
|
7770
|
-
return person ? [person] : [];
|
|
7771
|
-
});
|
|
7772
|
-
});
|
|
7773
|
-
}
|
|
7774
|
-
/**
|
|
7775
|
-
* Read current names for mentioned Slack users. Known Junior identities come
|
|
7776
|
-
* first. The email is set only for a linked, verified Junior user, because
|
|
7777
|
-
* that email is the People profile route.
|
|
7778
|
-
*/
|
|
7779
|
-
async function readMentionedPeople(executor, tenantId, userIds) {
|
|
7780
|
-
const rows = await executor.db().select({
|
|
7781
|
-
displayName: juniorIdentities.displayName,
|
|
7782
|
-
emailVerified: juniorIdentities.emailVerified,
|
|
7783
|
-
handle: juniorIdentities.handle,
|
|
7784
|
-
providerSubjectId: juniorIdentities.providerSubjectId,
|
|
7785
|
-
userDisplayName: juniorUsers.displayName,
|
|
7786
|
-
userEmail: juniorUsers.primaryEmail
|
|
7787
|
-
}).from(juniorIdentities).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(and(eq(juniorIdentities.provider, "slack"), inArray(juniorIdentities.providerSubjectId, userIds), tenantId ? eq(juniorIdentities.providerTenantId, tenantId) : void 0));
|
|
7788
|
-
const people = /* @__PURE__ */ new Map();
|
|
7789
|
-
for (const row of rows) {
|
|
7790
|
-
if (people.has(row.providerSubjectId)) continue;
|
|
7791
|
-
const fullName = row.userDisplayName?.trim() || row.displayName?.trim();
|
|
7792
|
-
const email = row.emailVerified ? row.userEmail?.trim() : void 0;
|
|
7793
|
-
people.set(row.providerSubjectId, {
|
|
7794
|
-
slackUserId: row.providerSubjectId,
|
|
7795
|
-
...fullName ? { fullName } : void 0,
|
|
7796
|
-
...row.handle ? { slackUserName: row.handle } : void 0,
|
|
7797
|
-
...email ? { email } : void 0
|
|
7798
|
-
});
|
|
7799
|
-
}
|
|
7800
|
-
const unnamed = userIds.filter((id) => {
|
|
7801
|
-
const person = people.get(id);
|
|
7802
|
-
return !person?.fullName && !person?.slackUserName;
|
|
7803
|
-
});
|
|
7804
|
-
if (tenantId && unnamed.length > 0) {
|
|
7805
|
-
const profiles = await Promise.all(unnamed.map((id) => lookupSlackUser(tenantId, id)));
|
|
7806
|
-
unnamed.forEach((id, index) => {
|
|
7807
|
-
const profile = profiles[index];
|
|
7808
|
-
if (!profile?.fullName && !profile?.userName) return;
|
|
7809
|
-
people.set(id, {
|
|
7810
|
-
...people.get(id),
|
|
7811
|
-
slackUserId: id,
|
|
7812
|
-
...profile.fullName ? { fullName: profile.fullName } : void 0,
|
|
7813
|
-
...profile.userName ? { slackUserName: profile.userName } : void 0
|
|
7814
|
-
});
|
|
7815
|
-
});
|
|
7816
|
-
}
|
|
7817
|
-
return people;
|
|
7818
|
-
}
|
|
7819
8101
|
// src/api/conversations/mentions.ts
|
|
7820
8102
|
/** Text in one event that the dashboard renders with mentions. */
|
|
7821
8103
|
function eventMentionTexts(data) {
|
|
@@ -8277,14 +8559,19 @@ function participantKey(row) {
|
|
|
8277
8559
|
return row.userId ? `user:${row.userId}` : `identity:${row.identityId}`;
|
|
8278
8560
|
}
|
|
8279
8561
|
async function readParticipantRows(db, conversationIds) {
|
|
8562
|
+
const authors = db.select({
|
|
8563
|
+
conversationId: juniorConversationEvents.conversationId,
|
|
8564
|
+
actorIdentityId: juniorConversationEvents.actorIdentityId,
|
|
8565
|
+
seq: sql`min(${juniorConversationEvents.seq})`.mapWith(Number).as("first_seq")
|
|
8566
|
+
}).from(juniorConversationEvents).where(and(inArray(juniorConversationEvents.conversationId, [...conversationIds]), isNotNull(juniorConversationEvents.actorIdentityId))).groupBy(juniorConversationEvents.conversationId, juniorConversationEvents.actorIdentityId).as("authors");
|
|
8280
8567
|
const [rootRows, eventRows] = await Promise.all([db.select({
|
|
8281
8568
|
conversationId: juniorConversations.conversationId,
|
|
8282
8569
|
...identityColumns
|
|
8283
|
-
}).from(juniorConversations).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversations.actorIdentityId)).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(inArray(juniorConversations.conversationId, [...conversationIds])), db.
|
|
8284
|
-
conversationId:
|
|
8285
|
-
seq:
|
|
8570
|
+
}).from(juniorConversations).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversations.actorIdentityId)).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).where(inArray(juniorConversations.conversationId, [...conversationIds])), db.select({
|
|
8571
|
+
conversationId: authors.conversationId,
|
|
8572
|
+
seq: authors.seq,
|
|
8286
8573
|
...identityColumns
|
|
8287
|
-
}).from(
|
|
8574
|
+
}).from(authors).innerJoin(juniorIdentities, eq(juniorIdentities.id, authors.actorIdentityId)).leftJoin(juniorUsers, eq(juniorUsers.id, juniorIdentities.userId)).innerJoin(juniorConversations, eq(juniorConversations.conversationId, authors.conversationId)).innerJoin(juniorConversationParticipants, and(eq(juniorConversationParticipants.userId, juniorIdentities.userId), eq(juniorConversationParticipants.rootConversationId, sql`coalesce(${juniorConversations.rootConversationId}, ${juniorConversations.conversationId})`))).where(inArray(juniorConversations.conversationId, [...conversationIds]))]);
|
|
8288
8575
|
return [...rootRows, ...eventRows.sort((left, right) => left.seq - right.seq)];
|
|
8289
8576
|
}
|
|
8290
8577
|
async function groupParticipants(db, rows) {
|
|
@@ -8492,7 +8779,7 @@ async function readConversationFeedFromSql(options = {}) {
|
|
|
8492
8779
|
if (filter?.kind === "viewer" && status === "active") rows.push(...await waitingRowsOutsidePage(db, filter, rows));
|
|
8493
8780
|
const conversations = rows.map((row) => conversationFromRow(row));
|
|
8494
8781
|
const conversationIds = conversations.map((conversation) => conversation.conversationId);
|
|
8495
|
-
const [accessByConversation, viewerMarksByConversation, annotationsByConversation, auxiliaryCostsByRoot, metricsByRoot, participantsByConversation, teamDomainByTeamId, conversationWork, lastUserMessageAtByConversation, activityPreviewByConversation, automationTitleByConversation, firstHumanMessageTextByConversation] = await Promise.all([
|
|
8782
|
+
const [accessByConversation, viewerMarksByConversation, annotationsByConversation, auxiliaryCostsByRoot, metricsByRoot, participantsByConversation, teamDomainByTeamId, { work: conversationWork, lastUserMessageAt: lastUserMessageAtByConversation }, activityPreviewByConversation, automationTitleByConversation, firstHumanMessageTextByConversation] = await Promise.all([
|
|
8496
8783
|
readConversationAccessFromSql(db, conversationIds, options.viewer),
|
|
8497
8784
|
conversationViewerMarks(db, conversationIds, filter?.kind === "viewer" ? { userId: filter.userId } : filter?.kind === "actorEmail" ? { email: filter.email } : void 0),
|
|
8498
8785
|
listConversationAnnotationsById(db, conversationIds),
|
|
@@ -8500,8 +8787,10 @@ async function readConversationFeedFromSql(options = {}) {
|
|
|
8500
8787
|
readConversationTreeMetricsFromSql(db, conversationIds),
|
|
8501
8788
|
readConversationParticipants(db, conversationIds),
|
|
8502
8789
|
resolveSlackTeamDomains(conversations.flatMap((conversation) => conversation.location?.provider === "slack" ? [conversation.location.teamId] : [])),
|
|
8503
|
-
listConversationWork(conversationIds)
|
|
8504
|
-
|
|
8790
|
+
listConversationWork(conversationIds).then(async (work) => ({
|
|
8791
|
+
work,
|
|
8792
|
+
lastUserMessageAt: await readLastUserMessageAtByConversation(db, work.assignedIds.filter((conversationId) => work.finishedAtById[conversationId]))
|
|
8793
|
+
})),
|
|
8505
8794
|
readConversationActivityPreviews(db, conversationIds),
|
|
8506
8795
|
readAutomationTitlesByConversationId(conversations),
|
|
8507
8796
|
readFirstHumanMessageTexts(db, conversations)
|
|
@@ -8907,6 +9196,61 @@ async function readConversationDetail(conversationId, options = {}) {
|
|
|
8907
9196
|
...autoArchive === void 0 ? void 0 : { autoArchive }
|
|
8908
9197
|
});
|
|
8909
9198
|
}
|
|
9199
|
+
// src/api/conversations/pin.ts
|
|
9200
|
+
/**
|
|
9201
|
+
* Pin or unpin one conversation for the signed-in viewer.
|
|
9202
|
+
*
|
|
9203
|
+
* A pin lives on the viewer's participant row, and that row grants send and
|
|
9204
|
+
* control access. So only a participant can pin, the same as archive. The
|
|
9205
|
+
* root actor may have no row yet, so pinning adds it. A pin also restores an
|
|
9206
|
+
* archived conversation, because the Pinned section shows only active
|
|
9207
|
+
* conversations.
|
|
9208
|
+
*/
|
|
9209
|
+
async function pinConversation(viewer, conversationId, body) {
|
|
9210
|
+
if (!(await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId)?.isParticipant) throwApiError(404, "Conversation not found.");
|
|
9211
|
+
const executor = getSqlExecutor();
|
|
9212
|
+
const rootConversationId = await resolveRootConversationId(executor, conversationId);
|
|
9213
|
+
const db = executor.db();
|
|
9214
|
+
if (!body.pinned) {
|
|
9215
|
+
await db.update(juniorConversationParticipants).set({ pinnedAt: null }).where(and(eq(juniorConversationParticipants.userId, viewer.id), eq(juniorConversationParticipants.rootConversationId, rootConversationId)));
|
|
9216
|
+
return { pinnedAt: null };
|
|
9217
|
+
}
|
|
9218
|
+
const [root] = await db.select({ lastActivityAt: juniorConversations.lastActivityAt }).from(juniorConversations).where(eq(juniorConversations.conversationId, rootConversationId)).limit(1);
|
|
9219
|
+
if (!root) throwApiError(404, "Conversation not found.");
|
|
9220
|
+
const pinnedAt = /* @__PURE__ */ new Date();
|
|
9221
|
+
await db.insert(juniorConversationParticipants).values({
|
|
9222
|
+
lastMessageAt: root.lastActivityAt,
|
|
9223
|
+
pinnedAt,
|
|
9224
|
+
rootConversationId,
|
|
9225
|
+
userId: viewer.id
|
|
9226
|
+
}).onConflictDoUpdate({
|
|
9227
|
+
target: [juniorConversationParticipants.userId, juniorConversationParticipants.rootConversationId],
|
|
9228
|
+
set: {
|
|
9229
|
+
archivedAt: null,
|
|
9230
|
+
pinnedAt
|
|
9231
|
+
}
|
|
9232
|
+
});
|
|
9233
|
+
return { pinnedAt: pinnedAt.toISOString() };
|
|
9234
|
+
}
|
|
9235
|
+
// src/api/conversations/steer-pending-messages.ts
|
|
9236
|
+
/**
|
|
9237
|
+
* Steer the viewer's own queued web messages into the conversation now.
|
|
9238
|
+
*
|
|
9239
|
+
* Only the author can steer a message. Ids that are not the viewer's queued
|
|
9240
|
+
* web messages, or that Junior already read, are left out of the result.
|
|
9241
|
+
*/
|
|
9242
|
+
async function steerConversationPendingMessagesForViewer(viewer, conversationId, body) {
|
|
9243
|
+
if (!await getConversationStore().get({ conversationId })) throwApiError(404, "Conversation not found.");
|
|
9244
|
+
if (!(await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId)?.isParticipant) throwApiError(403, "Only conversation participants can steer queued messages.");
|
|
9245
|
+
return {
|
|
9246
|
+
conversationId,
|
|
9247
|
+
steeredInboundMessageIds: (await steerWebPendingMessages({
|
|
9248
|
+
authorIds: webActorUserIds(viewer),
|
|
9249
|
+
conversationId,
|
|
9250
|
+
inboundMessageIds: body.inboundMessageIds
|
|
9251
|
+
})).steeredInboundMessageIds
|
|
9252
|
+
};
|
|
9253
|
+
}
|
|
8910
9254
|
// src/api/conversations/stop.ts
|
|
8911
9255
|
/**
|
|
8912
9256
|
* Stop the active Turn for one conversation participant.
|
|
@@ -8959,4 +9303,4 @@ function viewerWebMessages(messages, viewer) {
|
|
|
8959
9303
|
}] : [];
|
|
8960
9304
|
});
|
|
8961
9305
|
}
|
|
8962
|
-
export {
|
|
9306
|
+
export { readReviewItemForUser as $, getProductionSlackAdapter as A, isSlackMessageStopped as B, cancelConversationPendingMessagesForViewer as C, archiveConversation as D, resolveMentions as E, readEnvList as F, THREAD_OPTOUT_ACK as G, normalizeIncomingSlackThreadId as H, resolveAllowedDomains as I, stripLeadingBotMention as J, bindMessageAuthorIdentityId as K, recordSkippedConversationMessage as L, assertNoLegacyAllowedDomains as M, isAllowedDomain as N, createProductionConversationWorkOptions as O, isAllowedSignInEmail as P, closeReviewItemsAnsweredByReply as Q, buildSlackInboundMessage as R, encodeConversationCursor as S, requireConversationPendingMessages as T, withNormalizedThreadId as U, stopSlackThread as V, stopConversationTurn as W, ReviewItemActionError as X, parseContent as Y, actOnReviewItem as Z, conversationSummaryFromStoredConversation as _, markConversationRead as a, runAutoArchiveSweep as at, createConversationForViewer as b, forkConversationForViewer as c, emptyResponse as ct, readConversationEvents as d, getAttachmentStorage as dt, reviewItemChange as et, readConversationFeed as f, AGENT_DISPATCH_MAX_AGE_MS as ft, readConversationTreeMetricsFromSql as g, childAgentTotalsReport as h, readHealthReport as ht, readConversationDetail as i, readUserAutoArchiveSettings as it, createSlackWebApiStatusSender as j, createProductionSlackWebhookServices as k, keepQuickQuestionForViewer as l, jsonResponse as lt, readConversationAuxiliaryCostsFromSql as m, GET as mt, steerConversationPendingMessagesForViewer as n, archiveViewerDoneConversations as nt, readConversationReadPosition as o, setConversationAutoArchive as ot, readConversationRecordFromSql as p, enqueueAgentDispatch as pt, startProcessingReaction as q, pinConversation as r, readConversationAutoArchive as rt, readConversationAgentTree as s, updateUserAutoArchiveSettings as st, stopConversationTurnForViewer as t, DEFAULT_AUTO_ARCHIVE_SETTINGS as tt, readConversationForks as u, throwApiError as ut, readFirstHumanMessageTexts as v, readConversationPendingMessages as w, decodeConversationCursor as x, appendConversationMessageForViewer as y, clearSlackPendingReactions as z };
|