@sentry/junior 0.316.0 → 0.318.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/{admin-QYiDMnsu.js → admin-UOHix_5P.js} +1 -1
- package/dist/{agent-runner-Cr5Fhjf-.js → agent-runner-DeYymwh2.js} +13494 -13135
- package/dist/{reporting-window-C4dbzDiR.js → agent-status-BA5x3Xtp.js} +33 -1
- package/dist/{agent-update-delivery-BY13DPSD.js → agent-update-delivery-DH8bx7jU.js} +5 -5
- package/dist/api/schema.d.ts +600 -130
- package/dist/api/schema.js +6 -6
- package/dist/api.js +228 -214
- package/dist/{app-BhvzRD__.d.ts → app-DKAOuaoC.d.ts} +33 -18
- package/dist/app.d.ts +1 -1
- package/dist/app.js +193 -177
- package/dist/{thread-context-fiMNylbg.js → auth-pause-state-f9hJM_zO.js} +6 -59
- package/dist/catalog-runtime-BfdAnztW.js +6 -0
- package/dist/{change-record-Bqsa5ZXE.d.ts → change-record-BzJgLsv7.d.ts} +60 -1
- package/dist/{adapter-context-Bref7aPI.js → channel-access-A0de5lRv.js} +2 -42
- package/dist/{chat-core-engine-3dtlMku3.js → chat-core-engine-D3Wd7f5n.js} +6 -5
- package/dist/{child-message--2G3Ft26.js → child-message-peFWLcCZ.js} +2 -6
- package/dist/cli/chat.js +38 -30
- package/dist/cli/check.js +5 -5
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.js +5 -4
- package/dist/cli/snapshot-create.js +4 -2
- package/dist/cli/upgrade.js +5 -3
- package/dist/context-BKF_5zzI.js +1833 -0
- package/dist/{continue-in-slack-DbQUFe_F.js → continue-in-slack-YxwMQVeR.js} +3 -3
- package/dist/{conversation-feed-B84pMjHo.js → conversation-feed-Cj7IuBtM.js} +3 -3
- package/dist/{proxy-path-BTmXDjfx.js → conversation-privacy-Cr_dNW1p.js} +2 -16
- package/dist/{conversation-turn-DzEpTIaf.js → conversation-turn-Bru4w_FD.js} +196 -80
- package/dist/{create-DUJBXr6E.js → create-Btl1y1rq.js} +12 -11
- package/dist/{credential-sync-JH_K9Adg.js → credential-sync-DTarZ63K.js} +20 -15
- package/dist/{db-DhzvUY23.js → db-of6e3sGt.js} +20724 -27256
- package/dist/{deployment-BhvrhQeh.js → deployment-C0qXa0FD.js} +17 -15
- package/dist/{engine-context-C9Nal48K.js → engine-context-C_QL_bMQ.js} +304 -56
- package/dist/{html-B_12WjKT.js → html-9_pS9SjY.js} +6 -2
- package/dist/instrumentation.js +15 -7
- package/dist/{job-runner-DO8nslyY.js → job-runner-B2XEvpif.js} +392 -26
- package/dist/{lineage-D3AZAJVe.js → lineage-nh4z9iQN.js} +1 -1
- package/dist/{list-B0zsb5Cp.js → list-HRP3TIRl.js} +238 -550
- package/dist/{logging-B8KEJegM.js → logging-BnOG0qz2.js} +4 -50
- package/dist/{session-stop-DponjDUZ.js → mailbox-turn-Byrry9o1.js} +4807 -7102
- package/dist/{list-mkB_GU8R.js → markers-CTTtJqYn.js} +171 -124
- package/dist/{message-B5fKDYzz.js → message-BRUuLgrY.js} +13 -24
- package/dist/{model-input-CuMWy37l.js → model-input-CFC62mf-.js} +3 -3
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +21 -7
- package/dist/{oauth-callback-server-B3Vvlydo.js → oauth-callback-server-CjnnUr4o.js} +2 -2
- package/dist/{oauth-relay-6ERrGPbA.js → oauth-relay-BvHFH0fV.js} +2 -2
- package/dist/{package-discovery-BI6T_RkD.js → package-discovery-DD9vencX.js} +1 -50
- package/dist/{plugins-BXMdNdyA.js → plugins-D_Ru4CWc.js} +1 -1
- package/dist/profile-iHw1uu32.js +4657 -0
- package/dist/{transcript-CCi7323k.js → prompt-DEkStuxG.js} +92 -98
- package/dist/proxy-path-BHYoKZdq.js +15 -0
- package/dist/registry-Cl7Labpe.js +3279 -0
- package/dist/reports-C1d9azyV.js +195 -0
- package/dist/{resolve-D5JVvv6A.js → resolve-DC6zBuDV.js} +9 -29
- package/dist/{result-CS_7mo8a.js → result-DxewDuXb.js} +27 -118
- package/dist/run-conversation-Cz2ubZK-.js +337 -0
- package/dist/{runner-BzAES5W3.js → runner-99YxVN_r.js} +10 -18
- package/dist/{sandbox-egress-signals-Dwhk2Q5F.js → sandbox-egress-signals-CgoX5CTI.js} +1 -1
- package/dist/{schema-z5-wA6N4.js → schema-BTojNBr5.js} +48 -86
- package/dist/sender-actors-77zTQbSG.js +84 -0
- package/dist/{service-account-D6AsAtc1.js → service-account-YDCPSByj.js} +3 -1
- package/dist/{skills-DgJ9GBPR.js → skills-CleC0Hze.js} +6 -5
- package/dist/{slack-conversation-unfurl-Dq71EkhM.js → slack-conversation-unfurl-BNQLC12R.js} +7 -6
- package/dist/{spawn-BJWpdwhQ.js → spawn-DuZfodPa.js} +5 -5
- package/dist/{system-prompt-table-iIgpmslr.js → system-prompt-table-Ci6Ck4gk.js} +88 -69
- package/dist/{task-runner-BJae4JwE.js → task-runner-BJ9Up3bG.js} +30 -53
- package/dist/topics-BoCkoPJJ.js +21 -0
- package/dist/turn-membership-VT7XZh-L.js +856 -0
- package/dist/{turn-wake-BjDW7x-5.js → turn-wake-C7HeLHAM.js} +3 -4
- package/dist/{media-BebquhET.js → types-DCzTAA63.js} +629 -593
- package/dist/user-customization-CvfuY9Eo.js +93 -0
- package/dist/users-Cb9c1k9q.js +181 -0
- package/dist/{validation-D5WmmmhX.js → validation-BiUmWPhy.js} +1 -1
- package/dist/{version-CBQoanXb.js → version-VEXiEcZu.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{worker-Cyb4kF17.js → worker-ChWYQdhm.js} +5 -4
- package/migrations/20261126025226_drop_agent_invocations/migration.sql +6 -0
- package/migrations/20261126025226_drop_agent_invocations/snapshot.json +9 -0
- package/migrations/20261126033000_space_conversations_lead_children/migration.sql +155 -0
- package/migrations/20261126033000_space_conversations_lead_children/snapshot.json +9 -0
- package/migrations/20261126144620_drop_user_message_time_index/migration.sql +1 -0
- package/migrations/20261126144620_drop_user_message_time_index/snapshot.json +38 -0
- package/migrations/20261126153100_inbox_item_subjects/migration.sql +140 -0
- package/migrations/20261126153100_inbox_item_subjects/snapshot.json +9 -0
- package/migrations/20261126153103_inbox_item_subjects_not_null/migration.sql +12 -0
- package/migrations/20261126153103_inbox_item_subjects_not_null/snapshot.json +9 -0
- package/migrations/20261126153105_inbox_item_subject_indexes/migration.sql +1 -0
- package/migrations/20261126153105_inbox_item_subject_indexes/snapshot.json +9 -0
- package/migrations/20261126153108_automation_run_conversation_index/migration.sql +1 -0
- package/migrations/20261126153108_automation_run_conversation_index/snapshot.json +9 -0
- package/migrations/20261126153159_inbox_item_subjects_schema/migration.sql +4 -0
- package/migrations/20261126153159_inbox_item_subjects_schema/snapshot.json +437 -0
- package/migrations/20261126153259_inbox_questions/migration.sql +76 -0
- package/migrations/20261126153259_inbox_questions/snapshot.json +9 -0
- package/migrations/20261126153301_inbox_questions_valid/migration.sql +3 -0
- package/migrations/20261126153301_inbox_questions_valid/snapshot.json +9 -0
- package/migrations/20261126153343_inbox_questions_schema/migration.sql +5 -0
- package/migrations/20261126153343_inbox_questions_schema/snapshot.json +407 -0
- package/migrations/20261126154025_inbox_item_owners/migration.sql +74 -0
- package/migrations/20261126154025_inbox_item_owners/snapshot.json +9 -0
- package/migrations/20261126154048_inbox_item_open_subject_key_index/migration.sql +1 -0
- package/migrations/20261126154048_inbox_item_open_subject_key_index/snapshot.json +9 -0
- package/migrations/20261126154051_drop_inbox_item_owner_indexes/migration.sql +7 -0
- package/migrations/20261126154051_drop_inbox_item_owner_indexes/snapshot.json +9 -0
- package/migrations/20261126154121_inbox_item_owners_schema/migration.sql +8 -0
- package/migrations/20261126154121_inbox_item_owners_schema/snapshot.json +311 -0
- package/migrations/20261126175601_conversation_event_turn/migration.sql +5 -0
- package/migrations/20261126175601_conversation_event_turn/snapshot.json +103 -0
- package/migrations/20261126175614_conversation_event_turn_index/migration.sql +1 -0
- package/migrations/20261126175614_conversation_event_turn_index/snapshot.json +62 -0
- package/migrations/20261126230028_merge_leaves/migration.sql +2 -0
- package/migrations/20261126230028_merge_leaves/snapshot.json +12 -0
- package/migrations/20261126231932_space_lead_holds_name/migration.sql +46 -0
- package/migrations/20261126231932_space_lead_holds_name/snapshot.json +58 -0
- package/migrations/20261127001022_merge_leaves/migration.sql +2 -0
- package/migrations/20261127001022_merge_leaves/snapshot.json +12 -0
- package/migrations/20261127002500_turn_discarded_usage/migration.sql +2 -0
- package/migrations/20261127002500_turn_discarded_usage/snapshot.json +73 -0
- package/package.json +5 -5
- package/dist/people-CUtFApfL.js +0 -81
- package/dist/start-conversation-B-LIqqNi.js +0 -162
- package/dist/turn-session-routing-D15orfwy.js +0 -1309
- package/dist/user-customization-B27StpVQ.js +0 -9
- package/dist/web-message-id-C6P83ans.js +0 -10
|
@@ -1,37 +1,42 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { G as
|
|
3
|
-
import {
|
|
1
|
+
import { $ as resolveGatewayModel, B as getSlackBotToken, C as acquireActiveLock, E as parseSlackChannelId, H as getSlackClientSecret, J as normalizeSlackEmojiName, L as botConfig, O as parseSlackTeamId, P as parseSlackMessageTs, R as getChatConfig, U as getSlackSigningSecret, V as getSlackClientId, b as getStateValues, c as createSlackActor, f as isUserActor, l as createSlackResumeActor, n as credentialContextForActor, p as parseActorUserId, s as createActor, t as actorLogContext, u as isActorUserId, x as setStateValues, y as getStateAdapter } from "./context-BKF_5zzI.js";
|
|
2
|
+
import { $a as fallbackShortTitle, $d as juniorConversationParticipants, $r as resolveTurnResumeRouting, Ai as SLACK_USER_MENTION_RE, An as canJoinTurn, Ar as readMemberParticipants, Bi as createPluginState, Bn as pushInboxSnoozeWakes, Bo as verifyEventAutomationCredentialSubject, Bs as withSlackRetries, Bt as setTodoStatusByUser, C as conversationSlackTenantId, Ca as admitEventAutomationRun, Cc as listReplyActionItems, Co as cancelSubscriptions, Cr as leaveEndsAccess, Ct as getPlugins, Dd as listedConversation, Dl as deliversFinalText, Dr as conversationIsMemberRoot, Du as completeText, Ea as automationVersionOf, Ec as takeInboxItem, Ed as spaceLeadIds, Fd as juniorTodos, Fi as slackMentionedUserIds, Fl as postsRunNotices, Fs as isDmChannel, G as conversationTurnFailedSql, Gl as isEventConversationMessage, H as conversationIsActiveSql, Hc as userAvatarUrlsFromIdentities, Hi as createPluginEmbedder, Hl as EVENT_SYSTEM_ACTOR, Ho as verifySlackDirectCredentialSubject, Ic as subjectTodo, Ii as wrapBareSlackUserIds, Io as bindEventAutomationCredentialSubject, Is as isSlackRequestTimeout, J as conversationKindFromRow, K as conversationWaitsOnUserSql, Kl as CORE_EVENT_NAMESPACE, Kt as cancelHumanFacingPendingMessages, L as parseSessionSource, Lc as hasUserPhoto, Li as applyPluginFormatMarkdown, Lo as bindScheduledAutomationCredentialSubject, Ls as normalizeSlackConversationId, Mc as INBOX_SUBJECT_KINDS, Ml as isThread, Mo as listConversationsWithWatches, Mr as viewerMarksFromParticipant, Ms as getSlackClient, Ni as normalizeSlackStatusText, Nl as isTopLevel, Nr as getVercelConversationWorkQueue, Oc as inboxItemAnswer, Or as conversationIsNotUnsubscribedRoot, Os as SlackActionError, Pa as existingConversationId, Pi as slackMention, Q as canActOnInboxItem, Qn as sendSlackReply, Qo as canPauseConversationDelivery, Qr as resolveConversationRouting, R as conversationCostOf, Rc as identityAvatarUrl, Rd as juniorQuestions, Rl as turnBehavior, Rn as createInboxItemShow, Ro as bindSlackDirectCredentialSubject, Ru as createCache, S as setArchivedAt, Sd as requireSlackDestination, Sf as juniorDestinations, Sr as createConversationAccessReader, T as lastMessageAtSql, Td as rootSpaceIdSql, Ti as removeReactionFromMessage, To as collectEventMatchKeys, Tr as readConversationAccessRows, Tu as completeDecision, Ua as readAutomationTitlesByConversationId, Uc as userAvatarUrlsFromJoinedPhotos, Uu as estimateTextTokens, Vd as juniorAutomationRuns, Vo as verifyScheduledAutomationCredentialSubject, W as conversationStatusSql, Wa as recordAutomationExecution, Wc as SNOOZE_TIMER_EVENT_TYPE, Wd as juniorAutomations, Wo as updateTimerIndex, Wr as buildSentryConversationUrl, Ws as createPluginUsers, Wu as textCharsForTokens, X as hasUnexpiredAuthorizationRequest, Xa as AUTOMATION_ALERT_STEPS, Xr as runWithSlackInstallation, Y as awaitsAuthorizationFrom, Yc as listFiringInboxSnoozeTriggers, Yd as juniorInboxItems, Yl as eventGuidance, Yn as safeLinkUrl, Z as treeAwaitsAuthorization, Za as AUTOMATION_ALERT_STEP_FIELD_ID, Zc as settleInboxSnoozes, Zn as resolveSlackReplyTarget, _a as findMatchingEventAutomations, _i as notifyAutomationBlocked, a as getDb, ad as JUNIOR_NATIVE_EVENT_NAMESPACE, an as getConversationWorkState, as as listConversationAnnotationsById, at as inboxItemForUser, bc as getInboxItem, bs as lookupSlackUser, ci as getDispatchTurnId, cl as isDashboardLink, cr as sendVercelPluginTask, cs as conversationSubtreeColumns, ct as inboxItemPlugin, do as slackChannelMessageReplyThreadTs, dr as createPluginCodeChanges, ea as createPluginCache, ec as resolveActorIdentityId, ei as buildDispatchId, er as createPluginEventPublisher, et as canAnswerInboxItem, fo as slackChannelMessageRunsAutomation, fs as isPublicConversation, ft as isAutomationAlertItem, gd as resolveRootConversationId, gr as createPluginInboxItems, hc as closeHandledReplyNotices, hf as juniorConversations, hr as PLUGIN_CHOICE_FIELD_ID, ht as isPluginInboxItem, i as getConversationStore, if as juniorConversationEvents, ii as getDispatchConversationId, il as getDashboardPersonLink, in as getConversation, is as listConversationAnnotations, it as inboxItemAddedByAutomation, jc as itemQuestion, jn as canShareTurn, jr as rootVisibleToViewer, js as getHeaderString, k as locationFromRow, kc as inboxItemRequest, ko as findMatchingWatches, kr as conversationPinnedForUser, ks as downloadPrivateSlackFile, li as getPluginDispatchProjection, ll as parseDashboardConversationLink, ls as conversationSearchVector, ma as collectEventAutomationMatchKeys, mc as waitingConversationIdsQuery, md as hasAgentTurnUsage, mf as juniorMessageAttachments, mr as createPluginConversationChanges, mt as isOnlyAssignee, n as getConversationEventStore, na as truncateStatusText, nt as canUserReadInboxItem, o as getSqlExecutor, oi as getDispatchInputMessageId, os as conversationAncestorsOrSelf, ot as inboxItemNeedsInput, p as copyMessageLinks, pa as blockEventAutomation, pd as agentTurnUsageSchema, pf as juniorAttachments, pt as isInboxItemForEveryone, q as executionIsActive, qi as basePluginContext, qo as readSubjectLinks, rd as isProviderRetryError, ri as createOrGetDispatch, rl as getDashboardLinkFilter, rr as createPluginTaskStarter, rs as createPluginAnnotations, sf as juniorConversationAnnotations, si as getDispatchRecord, so as getEventCatalog, ss as conversationSubtree, st as inboxItemOwnedByConversation, tc as saveActorAvatar, tl as getDashboardConversationLink, u as isPostgresErrorCode, uc as readCachedUserByEmail, ud as addAgentTurnUsage, uf as juniorCodeChanges, ui as isTerminalDispatchStatus, ul as parseDashboardPersonLink, ur as getTurnRequestDeadline, uu as indexEndedTurnEvents, v as withConversationEventLock, vc as closeInboxItem, vf as juniorIdentities, vi as addReactionToMessage, vr as canAddConversationMessages, w as loadConversationSlackTenantIds, wa as eventAutomationRunLimitReason, wc as ownerConversationId, wr as readConversationAccessFromSql, x as readConversationTrees, xd as createSlackDestination, xf as juniorUsers, xr as conversationAccessFromRows, xs as lookupSlackUserNames, y as conversationAncestors, yc as dismissOpenInboxItems, yd as nextDetailVersion, yr as canInviteToConversation, yu as storedMessageJson, zs as streamPrivateSlackFile } from "./db-of6e3sGt.js";
|
|
3
|
+
import { $ as activityPreviewText, Kt as MAX_ATTACHMENT_BYTES, Lt as conversationTreeStateSchema, On as automationTaskText, St as contextProvenance, Xt as readMessageAttachments, Y as conversationReportStatusSchema, Z as conversationSurfaceSchema, at as KNOWN_CONVERSATION_EVENT_TYPES, bn as normalizeUserInputAnswer, fn as inboxItemQuestion, gn as answeredChoices, t as OPEN_TODO_STATUSES, wt as instructionProvenanceFor, yn as isEmptyUserInputAnswer, yt as piMessageFromHistoryItem } from "./types-DCzTAA63.js";
|
|
4
|
+
import { A as toOptionalString, T as withSpan, a as getActiveTraceContext, d as logError, f as logException, k as normalizeIdentityEmail, m as logWarn, o as getActiveTraceId, p as logInfo, t as createChatSdkLogger, v as setSentryUser, w as withLogContext, x as setTags, y as setSpanAttributes } from "./logging-BnOG0qz2.js";
|
|
4
5
|
import { h as startSpan, n as captureMessage } from "./sentry-CPbZjomA.js";
|
|
5
|
-
import { t as JUNIOR_VERSION } from "./version-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { a as
|
|
17
|
-
import {
|
|
18
|
-
import { c as
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import { r as
|
|
6
|
+
import { t as JUNIOR_VERSION } from "./version-VEXiEcZu.js";
|
|
7
|
+
import { G as mapBounded, M as trimTrailingAssistantMessages, h as createPluginLogger } from "./prompt-DEkStuxG.js";
|
|
8
|
+
import { n as webMessageId } from "./agent-status-BA5x3Xtp.js";
|
|
9
|
+
import { $ as ConversationTurnBoundaryError, At as instructionActorFor, B as resolveEventAuthor, Bn as estimateConversationMessagesTokens, Bt as buildDeterministicAssistantMessageId, D as notInheritedByForkChild, En as recordAuthorizationCompleted, Et as loadThreadContextTrimFloor, F as eventAuthorText, Fn as persistConversationMessageWindow, Fr as buildTurnFailureResponse, Gn as normalizeConversationText, Hn as isHumanConversationMessage, In as persistConversationMessages, It as renderTaskInput, Jn as trimConversationMessages, Kn as recordDeliveredAssistantMessage, Ln as resolveConversationTitle, Lr as finalizeFailedTurnReplyWithEvent, Mr as buildTurnErrorResponse, Pn as hydrateConversationMessages, Pt as withoutSavedSteeringMessages, Q as getTurnUserSlackMessageTs, Rr as getAgentTurnDiagnosticsAttributes, Sn as loadTurnProjection, Sr as recordTurnSummary, St as savedInputInstruction, Tr as loadTurnStart, Un as latestConversationMessageSeq, V as resolveBotSlackTeamId, Vn as getConversationMessageSlackTs, Vt as buildDeterministicTurnId, W as resumeForPersonInput, Wn as markConversationMessage, Xn as upsertConversationMessage, Y as getTurnUserMessage, Yn as turnHasReply, Z as getTurnUserReplyAttachmentContext, _n as commitAcceptedReply, _r as abandonTurnRecord, at as isTurnInputCommitLostError, bn as loadConversationProjection, br as getTurnRecord, c as legacyWebMailboxMetadataSchema, ci as configValueSchema, ct as markTurnCompleted, dt as getLocationConfigurationService, ei as persistWithRetry, et as CooperativeTurnYieldError, ft as getPersistedSandboxState, gr as saveTurnCheckpoint, gt as coerceThreadConversationState, hr as pauseLostWorkerTurn, ht as persistThreadStateById, it as isCooperativeTurnYieldError, jn as recordSubscribedReplyRoute, kt as buildSteeringPiMessage, lt as markTurnFailed, mr as lostWorkerBeforeFirstSave, mt as persistThreadRuntimeState, nr as PluginCredentialFailureError, nt as TurnInputDeferredError, or as AuthorizationFlowDisabledError, ot as isTurnInputDeferredError, pr as loadTurnCheckpoint, pt as getPersistedThreadState, rn as isExperimentalFeatureEnabled, rt as getConversationTurnBoundaryError, st as markTurnClosed, tr as createPluginEgress, tt as TurnInputCommitLostError, ur as clearPendingAuth, ut as startActiveTurn, vn as commitMessages, vr as completeTurnRecord, wr as getTurnLifecycle, wt as withHeldInput, xr as listTurnSummaries, xt as loadInboxItemInput, yr as failTurnRecord, yt as getWebAuthorization, zr as requireTurnFailureEventId } from "./mailbox-turn-Byrry9o1.js";
|
|
10
|
+
import { o as ingestEvent } from "./job-runner-B2XEvpif.js";
|
|
11
|
+
import { $ as requireSpaceForWork, $t as AutomationEditError, At as parseSlackThreadId, B as archiveConversation, C as CONVERSATION_STATE_TTL_MS, Ct as setConversationSubscription, D as isConversationWorkDone, Dt as renderAttachmentText, E as segmentGapsKey, Et as throwApiError, Ht as takeViewerAutomationAlertStep, It as createPluginConversationWatches, J as stopChildAgentsOf, K as stopConversation, Kt as readConversationSourceTask, Mt as resolveSlackChannelIdFromMessage, O as listConversationWork, Ot as renderBlockText, S as ANSWER_TOOL_ENDINGS, Sn as resolveConversationConfiguration, St as leaveConversation, T as GLOBAL_GAPS_TTL_MS, Tt as jsonResponse, U as conversationReadPositionQuery, W as markConversationRead, Wt as ViewerTaskNotFoundError, Y as deliverInboxItemChange, a as getMcpOAuthCallbackPath, an as addHistoryPeriod, bn as NO_REPLY_GAP_MS, bt as setConversationTitle, cn as historyPeriodSavings, ct as appendAndEnqueueWebMessage, dt as createConversationId, en as findAutomationSkill, et as setConversationSpaceForViewer, ft as recordWebConversationActivity, gn as providerCacheTtlMs, hn as connectedState, ht as AttachmentUploadError, jt as readSlackRawMessageContext, kt as parseSlackMessageReference, l as latestProgressStatus, ln as replaceHistorySavings, n as executeAgentRun, nn as effectiveTaskOutcomes, nt as getSpaceLead, o as createClientMetadata, on as addHistoryWarmupCost, pt as webActorFromUser, r as buildAuthPauseResponse, s as readMcpClientInformation, sn as firstLiveSavingsDate, st as acceptsWebMessages, t as createAgentRunner, tn as missingAutomationSkillReason, tt as readSpaceRefs, u as resolveDestinationVisibility, ut as createAndEnqueueConversation, vn as MINUTE_MS, vt as verifyAttachmentUploads, w as GLOBAL_GAPS_MAX, x as shouldEmitDevAgentTrace, xn as gapSegment, y as RetryableDeliveryError, z as readLastUserMessageAtByConversation } from "./agent-runner-DeYymwh2.js";
|
|
12
|
+
import { N as webActorUserIds, T as getMcpStoredOAuthCredentials, _ as McpAuthorizationRequiredError, v as PluginMcpClient } from "./registry-Cl7Labpe.js";
|
|
13
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-BfdAnztW.js";
|
|
14
|
+
import { A as createUserTokenStore } from "./profile-iHw1uu32.js";
|
|
15
|
+
import { h as getAssistantReplyText } from "./system-prompt-table-Ci6Ck4gk.js";
|
|
16
|
+
import { o as detectImageMediaType, s as isVisionImageMediaType } from "./user-customization-CvfuY9Eo.js";
|
|
17
|
+
import { a as readAttachmentVisionSummary, c as slackAttachmentsVersionQuery, m as storeAttachment, n as savedTurnMessages, r as getSlackFileId, s as recordSlackAttachment, u as isFileAttachment } from "./turn-membership-VT7XZh-L.js";
|
|
18
|
+
import { a as isConversationMember, i as getConversationInfo, l as listThreadReplies, o as isPublicSlackChannel, r as getChannelMessage } from "./channel-access-A0de5lRv.js";
|
|
19
|
+
import { C as cancelConversationPendingMessagesBodySchema, D as conversationPendingMessageDeliverySchema, G as messageObjectCard, K as personObjectCard, N as healthReportSchema, S as conversationAutoArchiveSchema, W as conversationObjectCard, b as archiveConversationResponseSchema, c as conversationSubscriptionResponseSchema, g as pinConversationResponseSchema, h as pinConversationBodySchema, l as setConversationSpaceBodySchema, m as renameConversationResponseSchema, o as conversationLeaveResponseSchema, p as renameConversationBodySchema, q as webPageObjectCard, r as stopConversationTurnResponseSchema, s as conversationSubscriptionBodySchema, u as setConversationSpaceResponseSchema, w as cancelConversationPendingMessagesResponseSchema, x as archiveDoneConversationsResponseSchema, y as archiveConversationBodySchema } from "./conversation-feed-Cj7IuBtM.js";
|
|
20
|
+
import { a as buildTurnThreadContext, c as AgentRunError, d as turnInputTelemetry, f as withTurnSpan, i as buildConversationContext, l as executeTurn, n as createConversationTurnWorker, o as stopAtAutomatedTurnLimit, r as supersedeTurnForInput, s as recordFinishedTurnForAutomatedLimit, u as getTurnInputSpanAttributes } from "./conversation-turn-Bru4w_FD.js";
|
|
21
|
+
import { n as attachmentFactLines, r as buildStoredAttachmentPromptText } from "./model-input-CFC62mf-.js";
|
|
22
|
+
import { a as getChildAgentLabel } from "./result-DxewDuXb.js";
|
|
23
|
+
import { t as bindMessageAgent } from "./message-BRUuLgrY.js";
|
|
24
|
+
import { t as readConversationLineage } from "./lineage-nh4z9iQN.js";
|
|
25
|
+
import { t as bindSpawnAgent } from "./spawn-DuZfodPa.js";
|
|
26
|
+
import { i as loadPendingMessageCards, n as persistAuthPauseTurnState, r as buildDeliveredTurnStatePatch, t as completeAuthPauseTurn } from "./auth-pause-state-f9hJM_zO.js";
|
|
27
|
+
import { c as readConversationEventPageAround, n as scheduleSessionCompletedPluginTasks, o as readConversationEventPage, s as readConversationEventPageAfter } from "./task-runner-BJ9Up3bG.js";
|
|
28
|
+
import { a as createAgentDispatchConversationWorker, i as buildDispatchRoutingContext, o as enqueueAgentDispatch, s as failStoppedDispatch, t as runConversation } from "./run-conversation-Cz2ubZK-.js";
|
|
29
|
+
import { n as getPausedTurnRequest, o as getTurnAuthorization, r as recordFailedDispatchTurn, t as createPausedTurns } from "./turn-wake-C7HeLHAM.js";
|
|
30
|
+
import { r as canContinueInSlack } from "./continue-in-slack-YxwMQVeR.js";
|
|
26
31
|
import * as z from "zod";
|
|
27
|
-
import
|
|
28
|
-
import { createHash, createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
29
|
-
import { EVENT_SUMMARY_MAX_LENGTH, EVENT_TEXT_MAX_LENGTH, conversationSidebarAnnotationSchema, createSlackSource, dispatchOptionsSchema, encodeObjectImageRef, escapeTagText, escapeTagTextAndQuotes, eventMatches, eventSchema, isSlackDestination, objectAnnotationSchema, objectLinkFilterMatches, objectLinkFilterSpecificity, objectTypeSchema, ownedObjectAnnotationSchema, renderEmptyTag, renderTag } from "@sentry/junior-plugin-api";
|
|
30
|
-
import { and, asc, count, desc, eq, exists, gt, gte, inArray, isNotNull, isNull, like, lt, lte, min, ne, not, or, sql } from "drizzle-orm";
|
|
32
|
+
import { and, asc, count, desc, eq, gt, gte, inArray, isNotNull, isNull, lt, lte, min, ne, not, notInArray, or, sql } from "drizzle-orm";
|
|
31
33
|
import { alias } from "drizzle-orm/pg-core";
|
|
34
|
+
import { EVENT_SUMMARY_MAX_LENGTH, EVENT_TEXT_MAX_LENGTH, conversationSidebarAnnotationSchema, createSlackSource, dispatchOptionsSchema, encodeObjectImageRef, escapeTagText, escapeTagTextAndQuotes, eventMatches, eventSchema, isSlackDestination, objectAnnotationSchema, objectLinkFilterMatches, objectLinkFilterSpecificity, objectTypeSchema, ownedObjectAnnotationSchema, renderEmptyTag, renderTag } from "@sentry/junior-plugin-api";
|
|
35
|
+
import { createHash, createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
36
|
+
import pLimit from "p-limit";
|
|
37
|
+
import { performance } from "node:perf_hooks";
|
|
32
38
|
import { Message, ThreadImpl, stringifyMarkdown } from "chat";
|
|
33
39
|
import net from "node:net";
|
|
34
|
-
import { performance } from "node:perf_hooks";
|
|
35
40
|
import https from "node:https";
|
|
36
41
|
import { SlackFormatConverter, createSlackAdapter } from "@chat-adapter/slack";
|
|
37
42
|
import dns from "node:dns";
|
|
@@ -60,7 +65,7 @@ const imageIdPayloadSchema = z.object({
|
|
|
60
65
|
source: z.string().min(1)
|
|
61
66
|
}).strict();
|
|
62
67
|
function signature$1(payload) {
|
|
63
|
-
const secret =
|
|
68
|
+
const secret = getChatConfig().secrets.juniorSecret;
|
|
64
69
|
if (!secret) throw new Error("Cannot sign image ids without JUNIOR_SECRET");
|
|
65
70
|
return createHmac("sha256", secret).update(`${IMAGE_ID_CONTEXT}:${payload}`).digest("base64url");
|
|
66
71
|
}
|
|
@@ -98,7 +103,7 @@ function imagePath(image, width, version) {
|
|
|
98
103
|
// src/chat/mcp/viewer.ts
|
|
99
104
|
function viewerAuthProvider(plugin, userId) {
|
|
100
105
|
const provider = plugin.manifest.name;
|
|
101
|
-
const baseUrl =
|
|
106
|
+
const baseUrl = getChatConfig().deployment.baseUrl;
|
|
102
107
|
if (!baseUrl) throw new Error("Cannot determine base URL (set JUNIOR_BASE_URL or deploy to Vercel)");
|
|
103
108
|
const callbackUrl = `${baseUrl}${getMcpOAuthCallbackPath(provider)}`;
|
|
104
109
|
return {
|
|
@@ -577,7 +582,8 @@ const conversationRecordColumns = () => ({
|
|
|
577
582
|
identityProvider: juniorIdentities.provider,
|
|
578
583
|
identitySubjectId: juniorIdentities.providerSubjectId,
|
|
579
584
|
identityTenantId: juniorIdentities.providerTenantId,
|
|
580
|
-
userDisplayName: juniorUsers.displayName
|
|
585
|
+
userDisplayName: juniorUsers.displayName,
|
|
586
|
+
spaceId: rootSpaceIdSql(juniorConversations)
|
|
581
587
|
});
|
|
582
588
|
/** Left-join conditions from a Conversation to its record tables. */
|
|
583
589
|
const conversationRecordJoins = {
|
|
@@ -620,7 +626,7 @@ function conversationFromRecordRow(row) {
|
|
|
620
626
|
...value.executionUpdatedAt ? { updatedAtMs: value.executionUpdatedAt.getTime() } : void 0
|
|
621
627
|
},
|
|
622
628
|
...value.parentConversationId ? { parentConversationId: value.parentConversationId } : void 0,
|
|
623
|
-
...
|
|
629
|
+
...row.spaceId ? { spaceId: row.spaceId } : void 0,
|
|
624
630
|
...value.archivedAt ? { archivedAtMs: value.archivedAt.getTime() } : void 0,
|
|
625
631
|
...actor ? { actor } : void 0,
|
|
626
632
|
...location ? { location } : void 0,
|
|
@@ -4046,7 +4052,11 @@ function createSlackTurn(deps) {
|
|
|
4046
4052
|
...activeInstructionAuthorName ? { authorName: activeInstructionAuthorName } : void 0,
|
|
4047
4053
|
...slackMessageTs ? { slackTs: slackMessageTs } : void 0
|
|
4048
4054
|
},
|
|
4049
|
-
...
|
|
4055
|
+
...await withHeldInput({
|
|
4056
|
+
conversation: preparedState.conversation,
|
|
4057
|
+
conversationId,
|
|
4058
|
+
turnId
|
|
4059
|
+
}, savedInput),
|
|
4050
4060
|
context: promptConversationContext,
|
|
4051
4061
|
inboundAttachmentCount: turnAttachments.length,
|
|
4052
4062
|
omittedImageAttachmentCount,
|
|
@@ -4599,297 +4609,6 @@ function createPrepareTurnState(deps) {
|
|
|
4599
4609
|
};
|
|
4600
4610
|
};
|
|
4601
4611
|
}
|
|
4602
|
-
// src/chat/agent-dispatch/work.ts
|
|
4603
|
-
const agentDispatchMailboxMetadataSchema = z.object({
|
|
4604
|
-
dispatchId: z.string().min(1),
|
|
4605
|
-
kind: z.literal("agent_dispatch")
|
|
4606
|
-
}).strict();
|
|
4607
|
-
const AGENT_DISPATCH_MAX_AGE_MS = 864e5;
|
|
4608
|
-
/** Return whether a dispatch is a Scheduled or Event automation run. */
|
|
4609
|
-
function isAutomationRun(dispatch) {
|
|
4610
|
-
return dispatch.source.kind === "scheduled_automation" || dispatch.source.kind === "event_automation";
|
|
4611
|
-
}
|
|
4612
|
-
/** Restore the exact actor, credential, and dispatch routing for every slice. */
|
|
4613
|
-
function buildDispatchRoutingContext(dispatch) {
|
|
4614
|
-
return {
|
|
4615
|
-
actor: dispatch.actor,
|
|
4616
|
-
credentialContext: credentialContextForActor(dispatch.actor, dispatch.credentialSubject),
|
|
4617
|
-
dispatch: {
|
|
4618
|
-
actor: dispatch.actor,
|
|
4619
|
-
id: dispatch.id,
|
|
4620
|
-
metadata: dispatch.metadata,
|
|
4621
|
-
plugin: dispatch.plugin,
|
|
4622
|
-
replyAttribution: dispatch.replyAttribution,
|
|
4623
|
-
outcomes: dispatch.outcomes,
|
|
4624
|
-
...dispatch.skill ? { skill: dispatch.skill } : void 0,
|
|
4625
|
-
...isAutomationRun(dispatch) ? { declaresResult: true } : void 0
|
|
4626
|
-
},
|
|
4627
|
-
surface: "api"
|
|
4628
|
-
};
|
|
4629
|
-
}
|
|
4630
|
-
/** Build the stable mailbox work item for one agent dispatch. */
|
|
4631
|
-
function buildAgentDispatchInboundMessage(dispatch, nowMs = Date.now(), authorIdentityId) {
|
|
4632
|
-
return {
|
|
4633
|
-
conversationId: getDispatchConversationId(dispatch),
|
|
4634
|
-
createdAtMs: dispatch.createdAtMs,
|
|
4635
|
-
delivery: "defer",
|
|
4636
|
-
destination: dispatch.destination,
|
|
4637
|
-
inboundMessageId: getDispatchInputMessageId(dispatch.id),
|
|
4638
|
-
input: {
|
|
4639
|
-
text: "[plugin dispatch]",
|
|
4640
|
-
...authorIdentityId ? { authorIdentityId } : void 0,
|
|
4641
|
-
metadata: {
|
|
4642
|
-
dispatchId: dispatch.id,
|
|
4643
|
-
kind: "agent_dispatch"
|
|
4644
|
-
}
|
|
4645
|
-
},
|
|
4646
|
-
receivedAtMs: nowMs,
|
|
4647
|
-
source: "plugin"
|
|
4648
|
-
};
|
|
4649
|
-
}
|
|
4650
|
-
/** Persist dispatch mailbox work before sending its conversation wake-up. */
|
|
4651
|
-
async function enqueueAgentDispatch(dispatch, options) {
|
|
4652
|
-
const nowMs = options.nowMs ?? Date.now();
|
|
4653
|
-
const claimedDispatch = await claimDispatchMailboxAppend(dispatch.id);
|
|
4654
|
-
if (!claimedDispatch) return;
|
|
4655
|
-
const conversationStore = options.conversationStore ?? getConversationStore();
|
|
4656
|
-
const conversationId = getDispatchConversationId(claimedDispatch);
|
|
4657
|
-
const destination = claimedDispatch.destination;
|
|
4658
|
-
await conversationStore.recordActivity({
|
|
4659
|
-
activityAtMs: claimedDispatch.createdAtMs,
|
|
4660
|
-
conversationId,
|
|
4661
|
-
destination,
|
|
4662
|
-
kind: isAutomationRun(claimedDispatch) ? "automation" : "thread",
|
|
4663
|
-
nowMs,
|
|
4664
|
-
source: "plugin",
|
|
4665
|
-
sessionSource: claimedDispatch.source,
|
|
4666
|
-
...claimedDispatch.title ? { title: claimedDispatch.title } : void 0
|
|
4667
|
-
});
|
|
4668
|
-
if (destination.platform === "slack" && destination.threadTs) await conversationStore.claimProviderConversation({
|
|
4669
|
-
atMs: nowMs,
|
|
4670
|
-
conversationId,
|
|
4671
|
-
provider: "slack",
|
|
4672
|
-
providerDestinationId: destination.channelId,
|
|
4673
|
-
providerTenantId: destination.teamId,
|
|
4674
|
-
providerConversationId: destination.threadTs
|
|
4675
|
-
});
|
|
4676
|
-
await appendAndEnqueueInboundMessage({
|
|
4677
|
-
message: buildAgentDispatchInboundMessage(claimedDispatch, nowMs, await resolveActorIdentityId(getSqlExecutor(), claimedDispatch.actor)),
|
|
4678
|
-
conversationStore: options.conversationStore,
|
|
4679
|
-
nowMs,
|
|
4680
|
-
queue: options.queue,
|
|
4681
|
-
state: options.state
|
|
4682
|
-
});
|
|
4683
|
-
await confirmDispatchMailboxAppend(claimedDispatch.id);
|
|
4684
|
-
}
|
|
4685
|
-
/** Parse dispatch routing metadata from a durable mailbox message. */
|
|
4686
|
-
function dispatchIdFromMessages(messages) {
|
|
4687
|
-
if (messages.length === 0) return;
|
|
4688
|
-
const parsed = messages.map((message) => agentDispatchMailboxMetadataSchema.safeParse(message.input.metadata));
|
|
4689
|
-
if (parsed.every((result) => !result.success)) return;
|
|
4690
|
-
if (parsed.some((result) => !result.success)) throw new Error("Conversation mailbox mixes dispatch and provider input");
|
|
4691
|
-
const ids = new Set(parsed.map((result) => {
|
|
4692
|
-
if (!result.success) throw new Error("Dispatch mailbox metadata failed validation");
|
|
4693
|
-
return result.data.dispatchId;
|
|
4694
|
-
}));
|
|
4695
|
-
if (ids.size !== 1) throw new Error("Conversation mailbox contains multiple dispatches");
|
|
4696
|
-
return ids.values().next().value;
|
|
4697
|
-
}
|
|
4698
|
-
/**
|
|
4699
|
-
* Resolve a dispatch from concrete mailbox metadata or the active turn.
|
|
4700
|
-
*
|
|
4701
|
-
* Provider source and conversation-id conventions are deliberately not
|
|
4702
|
-
* execution routing authority.
|
|
4703
|
-
*/
|
|
4704
|
-
async function resolveAgentDispatchId(context) {
|
|
4705
|
-
const mailboxDispatchId = dispatchIdFromMessages(context.attempt.messages);
|
|
4706
|
-
if (mailboxDispatchId) return mailboxDispatchId;
|
|
4707
|
-
if (context.attempt.messages.length > 0) return;
|
|
4708
|
-
const summaries = await listTurnSummaries(context.conversationId);
|
|
4709
|
-
const activeDispatchIds = new Set(summaries.filter((summary) => (summary.state === "paused" || summary.state === "running") && Boolean(summary.dispatchId)).map((summary) => summary.dispatchId).filter((id) => Boolean(id)));
|
|
4710
|
-
if (activeDispatchIds.size > 1) throw new Error(`Conversation ${context.conversationId} has multiple active dispatches`);
|
|
4711
|
-
const activeDispatchId = activeDispatchIds.values().next().value;
|
|
4712
|
-
if (activeDispatchId) return activeDispatchId;
|
|
4713
|
-
const durableDispatchIds = new Set(summaries.map((summary) => summary.dispatchId).filter((id) => Boolean(id)));
|
|
4714
|
-
if (durableDispatchIds.size > 1) throw new Error(`Conversation ${context.conversationId} has multiple dispatch sessions`);
|
|
4715
|
-
const durableDispatchId = durableDispatchIds.values().next().value;
|
|
4716
|
-
if (!durableDispatchId) return;
|
|
4717
|
-
const dispatch = await getDispatchRecord(durableDispatchId);
|
|
4718
|
-
return dispatch && !isTerminalDispatchStatus(dispatch.status) ? durableDispatchId : void 0;
|
|
4719
|
-
}
|
|
4720
|
-
async function readDispatchTurnResult(dispatch) {
|
|
4721
|
-
const conversationId = getDispatchConversationId(dispatch);
|
|
4722
|
-
const turnId = getDispatchTurnId(dispatch.id);
|
|
4723
|
-
const storedSession = await getTurnRecord(conversationId, turnId);
|
|
4724
|
-
const summary = (await listTurnSummaries(conversationId)).find((candidate) => candidate.turnId === turnId);
|
|
4725
|
-
const session = storedSession ?? summary;
|
|
4726
|
-
const dispatchOutcome = summary?.dispatchOutcome ?? storedSession?.dispatchOutcome;
|
|
4727
|
-
const resultMessageTs = summary?.resultMessageId ?? storedSession?.resultMessageId;
|
|
4728
|
-
const errorMessage = storedSession?.errorMessage;
|
|
4729
|
-
if (dispatchOutcome) return {
|
|
4730
|
-
...errorMessage ? { errorMessage } : void 0,
|
|
4731
|
-
outcome: dispatchOutcome,
|
|
4732
|
-
...resultMessageTs ? { resultMessageTs } : void 0
|
|
4733
|
-
};
|
|
4734
|
-
if (resultMessageTs) return {
|
|
4735
|
-
outcome: "completed",
|
|
4736
|
-
resultMessageTs
|
|
4737
|
-
};
|
|
4738
|
-
if (!session) return { outcome: "not_started" };
|
|
4739
|
-
switch (session.state) {
|
|
4740
|
-
case "paused": return { outcome: "awaiting_resume" };
|
|
4741
|
-
case "running": return { outcome: "still_running" };
|
|
4742
|
-
case "completed": return { outcome: "completed" };
|
|
4743
|
-
case "abandoned":
|
|
4744
|
-
case "failed": return {
|
|
4745
|
-
...errorMessage ? { errorMessage } : void 0,
|
|
4746
|
-
outcome: "retryable"
|
|
4747
|
-
};
|
|
4748
|
-
}
|
|
4749
|
-
}
|
|
4750
|
-
async function projectDispatchTurnResult(dispatchId, result) {
|
|
4751
|
-
switch (result.outcome) {
|
|
4752
|
-
case "awaiting_resume":
|
|
4753
|
-
await markDispatchAwaitingResume(dispatchId);
|
|
4754
|
-
break;
|
|
4755
|
-
case "blocked":
|
|
4756
|
-
await markDispatchBlocked(dispatchId, result.errorMessage ?? "Dispatch requires authorization that is unavailable for background work", result.resultMessageTs);
|
|
4757
|
-
break;
|
|
4758
|
-
case "failed":
|
|
4759
|
-
await markDispatchFailed(dispatchId, result.errorMessage ?? "Agent turn failed", result.resultMessageTs);
|
|
4760
|
-
break;
|
|
4761
|
-
case "completed":
|
|
4762
|
-
await markDispatchCompleted(dispatchId, result.resultMessageTs);
|
|
4763
|
-
break;
|
|
4764
|
-
case "not_started": await markDispatchFailed(dispatchId, "Dispatch turn record is missing");
|
|
4765
|
-
}
|
|
4766
|
-
}
|
|
4767
|
-
function getDispatchBlockingError(error) {
|
|
4768
|
-
const cause = getConversationTurnBoundaryError(error)?.cause ?? error;
|
|
4769
|
-
return cause instanceof AuthorizationFlowDisabledError || cause instanceof PluginCredentialFailureError ? cause : void 0;
|
|
4770
|
-
}
|
|
4771
|
-
function missingAuthorizationReason(dispatch, provider) {
|
|
4772
|
-
return dispatch.credentialSubject ? `This run needs a connected ${provider} account.` : `This run uses system credentials, which have no ${provider} access. Switch it to creator credentials and connect a ${provider} account.`;
|
|
4773
|
-
}
|
|
4774
|
-
async function persistBlockedDispatchTurn(dispatch, error) {
|
|
4775
|
-
const conversationId = getDispatchConversationId(dispatch);
|
|
4776
|
-
const sessionId = getDispatchTurnId(dispatch.id);
|
|
4777
|
-
const session = await getTurnRecord(conversationId, sessionId);
|
|
4778
|
-
await recordTurnSummary({
|
|
4779
|
-
actor: dispatch.actor,
|
|
4780
|
-
conversationId,
|
|
4781
|
-
destination: dispatch.destination,
|
|
4782
|
-
dispatchId: dispatch.id,
|
|
4783
|
-
dispatchOutcome: "blocked",
|
|
4784
|
-
turnId: sessionId,
|
|
4785
|
-
sliceId: session?.sliceId ?? 1,
|
|
4786
|
-
source: dispatch.source,
|
|
4787
|
-
state: "failed",
|
|
4788
|
-
surface: "api"
|
|
4789
|
-
});
|
|
4790
|
-
await markDispatchBlocked(dispatch.id, error instanceof AuthorizationFlowDisabledError ? missingAuthorizationReason(dispatch, error.provider) : error.message);
|
|
4791
|
-
}
|
|
4792
|
-
/** Run one dispatch start or resume under the owning conversation lease. */
|
|
4793
|
-
function createAgentDispatchConversationWorker(options) {
|
|
4794
|
-
return async (context, dispatchId) => {
|
|
4795
|
-
const dispatch = await getDispatchRecord(dispatchId);
|
|
4796
|
-
if (!dispatch) throw new Error(`Dispatch record is missing for ${dispatchId}`);
|
|
4797
|
-
const expectedConversationId = getDispatchConversationId(dispatch);
|
|
4798
|
-
if (context.conversationId !== expectedConversationId) throw new Error(`Dispatch ${dispatch.id} belongs to ${expectedConversationId}, not ${context.conversationId}`);
|
|
4799
|
-
if (!context.destination || context.destination.platform !== dispatch.destination.platform || context.destination.teamId !== dispatch.destination.teamId || context.destination.channelId !== dispatch.destination.channelId) throw new Error(`Dispatch ${dispatch.id} destination does not match its conversation lease`);
|
|
4800
|
-
let acknowledged = context.attempt.messages.length === 0;
|
|
4801
|
-
const acknowledge = async () => {
|
|
4802
|
-
if (acknowledged) return;
|
|
4803
|
-
try {
|
|
4804
|
-
await context.attempt.ack();
|
|
4805
|
-
} catch {
|
|
4806
|
-
throw new TurnInputCommitLostError(`Conversation work lease lost before dispatch inbox ack for ${context.conversationId}`);
|
|
4807
|
-
}
|
|
4808
|
-
acknowledged = true;
|
|
4809
|
-
};
|
|
4810
|
-
if (isTerminalDispatchStatus(dispatch.status)) {
|
|
4811
|
-
await acknowledge();
|
|
4812
|
-
return { status: "completed" };
|
|
4813
|
-
}
|
|
4814
|
-
const durableResult = await readDispatchTurnResult(dispatch);
|
|
4815
|
-
if (durableResult.outcome === "blocked" || durableResult.outcome === "completed" || durableResult.outcome === "failed") {
|
|
4816
|
-
await projectDispatchTurnResult(dispatch.id, durableResult);
|
|
4817
|
-
await acknowledge();
|
|
4818
|
-
return { status: "completed" };
|
|
4819
|
-
}
|
|
4820
|
-
if (Date.now() - dispatch.createdAtMs > 864e5) {
|
|
4821
|
-
await markDispatchFailed(dispatch.id, "Dispatch exceeded its maximum processing age");
|
|
4822
|
-
await acknowledge();
|
|
4823
|
-
return { status: "completed" };
|
|
4824
|
-
}
|
|
4825
|
-
const runningDispatch = await markDispatchRunning(dispatch.id);
|
|
4826
|
-
if (!runningDispatch) throw new Error(`Dispatch record disappeared for ${dispatch.id}`);
|
|
4827
|
-
if (isTerminalDispatchStatus(runningDispatch.status)) {
|
|
4828
|
-
await acknowledge();
|
|
4829
|
-
return { status: "completed" };
|
|
4830
|
-
}
|
|
4831
|
-
try {
|
|
4832
|
-
const resumesDurableTurn = durableResult.outcome === "awaiting_resume" || durableResult.outcome === "still_running";
|
|
4833
|
-
if (resumesDurableTurn && context.attempt.messages.length > 0) await acknowledge();
|
|
4834
|
-
let result;
|
|
4835
|
-
if (resumesDurableTurn) {
|
|
4836
|
-
await options.resumeTurn(dispatch, {
|
|
4837
|
-
shouldYield: context.shouldYield,
|
|
4838
|
-
checkIn: context.checkIn
|
|
4839
|
-
});
|
|
4840
|
-
result = await readDispatchTurnResult(dispatch);
|
|
4841
|
-
} else result = await options.runTurn(dispatch, {
|
|
4842
|
-
ack: acknowledge,
|
|
4843
|
-
shouldYield: context.shouldYield,
|
|
4844
|
-
checkIn: context.checkIn
|
|
4845
|
-
}) ?? await readDispatchTurnResult(dispatch);
|
|
4846
|
-
if (result.outcome === "still_running") throw new Error(`Dispatch turn ${dispatch.id} is still running after its attempt`);
|
|
4847
|
-
if (result.outcome === "retryable") throw new Error(result.errorMessage ?? `Dispatch turn ${dispatch.id} failed`);
|
|
4848
|
-
await projectDispatchTurnResult(dispatch.id, result);
|
|
4849
|
-
if (!acknowledged) await acknowledge();
|
|
4850
|
-
return result.outcome === "awaiting_resume" && context.shouldYield() ? { status: "yielded" } : { status: "completed" };
|
|
4851
|
-
} catch (error) {
|
|
4852
|
-
if (isCooperativeTurnYieldError(error)) {
|
|
4853
|
-
await markDispatchAwaitingResume(dispatch.id);
|
|
4854
|
-
return { status: "yielded" };
|
|
4855
|
-
}
|
|
4856
|
-
if (isTurnInputCommitLostError(error)) {
|
|
4857
|
-
logWarn("agent.dispatch.lost_lease", {
|
|
4858
|
-
"app.dispatch.id": dispatch.id,
|
|
4859
|
-
"error.type": error.name,
|
|
4860
|
-
"exception.message": error.message
|
|
4861
|
-
});
|
|
4862
|
-
return { status: "lost_lease" };
|
|
4863
|
-
}
|
|
4864
|
-
const blockingError = getDispatchBlockingError(error);
|
|
4865
|
-
if (blockingError) {
|
|
4866
|
-
await persistBlockedDispatchTurn(dispatch, blockingError);
|
|
4867
|
-
await indexEndedTurnEvents({
|
|
4868
|
-
conversationId: context.conversationId,
|
|
4869
|
-
turnId: getDispatchTurnId(dispatch.id)
|
|
4870
|
-
});
|
|
4871
|
-
await acknowledge();
|
|
4872
|
-
return { status: "completed" };
|
|
4873
|
-
}
|
|
4874
|
-
if (!context.attempt.isFinalAttempt) throw error;
|
|
4875
|
-
await markDispatchFailed(dispatch.id, error instanceof Error ? error.message : "Dispatch turn failed");
|
|
4876
|
-
await indexEndedTurnEvents({
|
|
4877
|
-
conversationId: context.conversationId,
|
|
4878
|
-
turnId: getDispatchTurnId(dispatch.id)
|
|
4879
|
-
});
|
|
4880
|
-
await acknowledge();
|
|
4881
|
-
return { status: "completed" };
|
|
4882
|
-
}
|
|
4883
|
-
};
|
|
4884
|
-
}
|
|
4885
|
-
/**
|
|
4886
|
-
* Fail the dispatch of stopped Conversation work, so the Automation run that
|
|
4887
|
-
* waits on it settles instead of blocking later runs.
|
|
4888
|
-
*/
|
|
4889
|
-
async function failStoppedDispatch(conversationId) {
|
|
4890
|
-
const dispatchId = getDispatchIdForConversation(conversationId);
|
|
4891
|
-
if (dispatchId) await markDispatchFailed(dispatchId, "Dispatch work stopped after repeated failed attempts.");
|
|
4892
|
-
}
|
|
4893
4612
|
// src/chat/slack/dispatch-turn.ts
|
|
4894
4613
|
/** Build the Slack provider adapter for agent-dispatched conversation turns. */
|
|
4895
4614
|
function createSlackDispatchTurnRunner(options) {
|
|
@@ -6473,12 +6192,16 @@ async function runPausedTurnInContext(payload, options, runOptions) {
|
|
|
6473
6192
|
instruction: {
|
|
6474
6193
|
...instructionActor ? { actor: instructionActor } : void 0,
|
|
6475
6194
|
...getTurnUserReplyAttachmentContext(userMessage),
|
|
6476
|
-
...await
|
|
6195
|
+
...await withHeldInput({
|
|
6196
|
+
conversation,
|
|
6197
|
+
conversationId: payload.conversationId,
|
|
6198
|
+
turnId: payload.turnId
|
|
6199
|
+
}, await savedInputInstruction({
|
|
6477
6200
|
runtime: Boolean(dispatchId) || isEventConversationMessage(userMessage),
|
|
6478
6201
|
requestText: userMessage.meta?.requestText,
|
|
6479
6202
|
reviewItemChange: userMessage.meta?.reviewItemChanges?.[0],
|
|
6480
6203
|
text: userMessage.text
|
|
6481
|
-
})
|
|
6204
|
+
}))
|
|
6482
6205
|
},
|
|
6483
6206
|
history: dispatchId ? {
|
|
6484
6207
|
messages: activeTurn.piMessages,
|
|
@@ -6827,32 +6550,7 @@ function createConversationWork(options) {
|
|
|
6827
6550
|
queue: options.queue,
|
|
6828
6551
|
state: options.state
|
|
6829
6552
|
});
|
|
6830
|
-
const
|
|
6831
|
-
runTurn: conversationTurnWorker,
|
|
6832
|
-
state: options.state
|
|
6833
|
-
});
|
|
6834
|
-
const destinationWorker = async (context) => {
|
|
6835
|
-
const destination = context.destination;
|
|
6836
|
-
if (!destination) throw new Error(`Conversation ${context.conversationId} is missing a destination`);
|
|
6837
|
-
if (destination.platform === "slack") return await slackWorker(context);
|
|
6838
|
-
throw new Error(`Conversation ${context.conversationId} has a ${destination.platform} destination but no matching conversation worker`);
|
|
6839
|
-
};
|
|
6840
|
-
const runRoot = async (context) => {
|
|
6841
|
-
const mailboxTurn = await resolveMailboxTurnWork(context);
|
|
6842
|
-
if (mailboxTurn) {
|
|
6843
|
-
const work = await withAgentInvocationResultActors(mailboxTurn);
|
|
6844
|
-
if (!work) {
|
|
6845
|
-
await context.attempt.ack();
|
|
6846
|
-
return { status: "completed" };
|
|
6847
|
-
}
|
|
6848
|
-
return await conversationTurnWorker(context, work);
|
|
6849
|
-
}
|
|
6850
|
-
const dispatchId = await resolveAgentDispatchId(context);
|
|
6851
|
-
if (dispatchId) return await dispatchWorker(context, dispatchId);
|
|
6852
|
-
return await destinationWorker(context);
|
|
6853
|
-
};
|
|
6854
|
-
const runByKind = async (context, topLevel) => {
|
|
6855
|
-
const worker = topLevel ? runRoot : childWorker;
|
|
6553
|
+
const runWithStopCascade = async (context) => {
|
|
6856
6554
|
const readStopSignal = context.stopSignal;
|
|
6857
6555
|
let stopSignal;
|
|
6858
6556
|
const stopLateChildAgents = async () => {
|
|
@@ -6860,9 +6558,14 @@ function createConversationWork(options) {
|
|
|
6860
6558
|
};
|
|
6861
6559
|
let result;
|
|
6862
6560
|
try {
|
|
6863
|
-
result = await
|
|
6561
|
+
result = await runConversation({
|
|
6864
6562
|
...context,
|
|
6865
6563
|
stopSignal: readStopSignal ? () => stopSignal = readStopSignal() : void 0
|
|
6564
|
+
}, {
|
|
6565
|
+
destinations: { slack: slackWorker },
|
|
6566
|
+
runDispatch: dispatchWorker,
|
|
6567
|
+
runTurn: conversationTurnWorker,
|
|
6568
|
+
state: options.state
|
|
6866
6569
|
});
|
|
6867
6570
|
} catch (error) {
|
|
6868
6571
|
await stopLateChildAgents().catch((cascadeError) => {
|
|
@@ -6877,7 +6580,7 @@ function createConversationWork(options) {
|
|
|
6877
6580
|
await resumeForPersonInput(context.conversationId, context.attempt.messages);
|
|
6878
6581
|
const conversation = await options.conversationStore.get({ conversationId: context.conversationId });
|
|
6879
6582
|
const topLevel = !conversation || isTopLevel(conversation);
|
|
6880
|
-
return await withLogContext({ rootConversationId: conversation?.rootConversationId ?? (topLevel ? context.conversationId : void 0) }, () =>
|
|
6583
|
+
return await withLogContext({ rootConversationId: conversation?.rootConversationId ?? (topLevel ? context.conversationId : void 0) }, () => runWithStopCascade(context));
|
|
6881
6584
|
};
|
|
6882
6585
|
return {
|
|
6883
6586
|
beforeWorkStops: failStoppedDispatch,
|
|
@@ -8505,10 +8208,14 @@ const INBOX_SNOOZE_TIMER_INDEX = {
|
|
|
8505
8208
|
async function resolvedTodos(db, resolved) {
|
|
8506
8209
|
if (resolved.length === 0) return [];
|
|
8507
8210
|
const items = await db.select({
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8211
|
+
id: juniorInboxItems.id,
|
|
8212
|
+
subjectId: juniorInboxItems.subjectId,
|
|
8213
|
+
subjectKind: juniorInboxItems.subjectKind
|
|
8214
|
+
}).from(juniorInboxItems).where(and(inArray(juniorInboxItems.id, resolved.map((row) => row.inboxItemId)), eq(juniorInboxItems.subjectKind, INBOX_SUBJECT_KINDS.todo)));
|
|
8215
|
+
const todoOf = new Map(items.map((item) => [item.id, subjectTodo({
|
|
8216
|
+
id: item.subjectId,
|
|
8217
|
+
kind: item.subjectKind
|
|
8218
|
+
})]));
|
|
8512
8219
|
return resolved.flatMap((row) => {
|
|
8513
8220
|
const todo = todoOf.get(row.inboxItemId);
|
|
8514
8221
|
return todo ? [{
|
|
@@ -8521,7 +8228,7 @@ async function resolvedTodos(db, resolved) {
|
|
|
8521
8228
|
* Fire the snooze triggers that one Event matches. A `resolve` trigger
|
|
8522
8229
|
* cancels the snooze and closes the item: it dismisses it, or marks the
|
|
8523
8230
|
* To-do of a To-do item done for the person who snoozed it, so the agent
|
|
8524
|
-
* sees the change in its next
|
|
8231
|
+
* sees the change in its next To-do delta. A `wake` trigger ends the
|
|
8525
8232
|
* snooze, which records `reason`. When one Event fires both on a snooze,
|
|
8526
8233
|
* `resolve` wins. A snooze that already ended ignores the Event. Each
|
|
8527
8234
|
* woken snooze pushes to its User. Returns the number of items woken.
|
|
@@ -8764,6 +8471,7 @@ function createHeartbeatContext(args) {
|
|
|
8764
8471
|
send: args.sendPluginTask,
|
|
8765
8472
|
tasks: typeof args.plugin === "string" ? void 0 : args.plugin.tasks
|
|
8766
8473
|
}),
|
|
8474
|
+
users: createPluginUsers(pluginName),
|
|
8767
8475
|
log: createPluginLogger(pluginName),
|
|
8768
8476
|
agent: {
|
|
8769
8477
|
async dispatch(options) {
|
|
@@ -8793,9 +8501,14 @@ function createHeartbeatContext(args) {
|
|
|
8793
8501
|
}
|
|
8794
8502
|
};
|
|
8795
8503
|
}
|
|
8504
|
+
const EVENT_AUTOMATION_PLUGIN = "junior";
|
|
8505
|
+
/** The dispatch id of an event automation run, which is also its run id. */
|
|
8506
|
+
function eventAutomationDispatchId(idempotencyKey) {
|
|
8507
|
+
return buildDispatchId(EVENT_AUTOMATION_PLUGIN, idempotencyKey);
|
|
8508
|
+
}
|
|
8796
8509
|
/** Create and enqueue one core-owned event automation dispatch. */
|
|
8797
8510
|
async function dispatchEventAutomation(args) {
|
|
8798
|
-
const plugin =
|
|
8511
|
+
const plugin = EVENT_AUTOMATION_PLUGIN;
|
|
8799
8512
|
const { credentialSubject, outcomes, skill, ...unboundOptions } = args.options;
|
|
8800
8513
|
validateDispatchOptions({ ...unboundOptions });
|
|
8801
8514
|
const boundSubject = credentialSubject ? bindEventAutomationCredentialSubject({
|
|
@@ -8811,7 +8524,7 @@ async function dispatchEventAutomation(args) {
|
|
|
8811
8524
|
source: {
|
|
8812
8525
|
kind: "event_automation",
|
|
8813
8526
|
automationId: args.automationId,
|
|
8814
|
-
automationRunId:
|
|
8527
|
+
automationRunId: eventAutomationDispatchId(unboundOptions.idempotencyKey)
|
|
8815
8528
|
}
|
|
8816
8529
|
};
|
|
8817
8530
|
return await dispatch({
|
|
@@ -8856,12 +8569,25 @@ async function getScheduledAutomationDispatch(id) {
|
|
|
8856
8569
|
id
|
|
8857
8570
|
});
|
|
8858
8571
|
}
|
|
8572
|
+
// src/chat/inbox-items/automation-questions.ts
|
|
8573
|
+
const OPEN_AUTOMATION_QUESTION_LIMIT = 20;
|
|
8574
|
+
/**
|
|
8575
|
+
* List the open questions that the runs of one Automation asked, oldest
|
|
8576
|
+
* first, by item id and title. A later run of the Automation gets them in
|
|
8577
|
+
* its task, so it changes one by its id instead of asking it again.
|
|
8578
|
+
*/
|
|
8579
|
+
async function listOpenAutomationQuestions(db, automationId) {
|
|
8580
|
+
return await db.select({
|
|
8581
|
+
id: juniorInboxItems.id,
|
|
8582
|
+
title: juniorQuestions.title
|
|
8583
|
+
}).from(juniorInboxItems).innerJoin(juniorQuestions, itemQuestion).where(and(eq(juniorInboxItems.status, "open"), inboxItemAddedByAutomation(automationId))).orderBy(asc(juniorInboxItems.createdAt), asc(juniorInboxItems.id)).limit(OPEN_AUTOMATION_QUESTION_LIMIT);
|
|
8584
|
+
}
|
|
8859
8585
|
// src/chat/event-automations/runs.ts
|
|
8860
8586
|
/**
|
|
8861
|
-
* Record
|
|
8862
|
-
*
|
|
8863
|
-
*
|
|
8864
|
-
*
|
|
8587
|
+
* Record an event automation run with the Automation version it runs, before
|
|
8588
|
+
* its dispatch, so the dispatch can link the run's Conversation as soon as it
|
|
8589
|
+
* exists. A retry of the same Event keeps the row it has. A run whose
|
|
8590
|
+
* dispatch is never stored fails when the heartbeat settles it.
|
|
8865
8591
|
*/
|
|
8866
8592
|
async function recordEventAutomationRunStarted(db, args) {
|
|
8867
8593
|
const conversationId = getDispatchConversationId({ id: args.dispatchId });
|
|
@@ -8875,18 +8601,21 @@ async function recordEventAutomationRunStarted(db, args) {
|
|
|
8875
8601
|
status: "running"
|
|
8876
8602
|
}).onConflictDoNothing({ target: juniorAutomationRuns.id });
|
|
8877
8603
|
}
|
|
8604
|
+
const MISSING_DISPATCH_GRACE_MS = 3e5;
|
|
8878
8605
|
/**
|
|
8879
8606
|
* Settle running event automation runs whose dispatch has ended. A run whose
|
|
8880
|
-
* dispatch record is
|
|
8607
|
+
* dispatch record is still missing after a short grace fails.
|
|
8881
8608
|
*/
|
|
8882
8609
|
async function settleEventAutomationRuns(db, nowMs) {
|
|
8883
8610
|
const runs = await db.select({
|
|
8884
8611
|
automationId: juniorAutomationRuns.automationId,
|
|
8885
|
-
id: juniorAutomationRuns.id
|
|
8612
|
+
id: juniorAutomationRuns.id,
|
|
8613
|
+
startedAtMs: juniorAutomationRuns.startedAtMs
|
|
8886
8614
|
}).from(juniorAutomationRuns).innerJoin(juniorAutomations, eq(juniorAutomations.id, juniorAutomationRuns.automationId)).where(and(eq(juniorAutomations.kind, "event"), eq(juniorAutomationRuns.status, "running")));
|
|
8887
8615
|
const dispatches = await mapBounded(runs, (run) => getDispatchRecord(run.id));
|
|
8888
8616
|
for (const [index, run] of runs.entries()) {
|
|
8889
8617
|
const dispatch = dispatches[index];
|
|
8618
|
+
if (!dispatch && (run.startedAtMs ?? 0) > nowMs - MISSING_DISPATCH_GRACE_MS) continue;
|
|
8890
8619
|
const status = dispatch?.status ?? "failed";
|
|
8891
8620
|
if (status !== "blocked" && status !== "completed" && status !== "failed") continue;
|
|
8892
8621
|
await recordAutomationExecution(run.automationId, {
|
|
@@ -9149,8 +8878,11 @@ async function answerAutomationAlert(args) {
|
|
|
9149
8878
|
function eventAutomationDispatchKey(taskId, namespace, eventKey) {
|
|
9150
8879
|
return `event-automation:${createHash("sha256").update(`${taskId}\0${namespace}\0${eventKey}`).digest("hex").slice(0, 32)}`;
|
|
9151
8880
|
}
|
|
9152
|
-
/**
|
|
9153
|
-
|
|
8881
|
+
/**
|
|
8882
|
+
* Render plain agent input for one matching event automation, with the open
|
|
8883
|
+
* questions of its earlier runs.
|
|
8884
|
+
*/
|
|
8885
|
+
function eventInput(task, event, outcomes, catalog, author, openQuestions) {
|
|
9154
8886
|
const guidance = eventGuidance(catalog, event.namespace, event.eventType);
|
|
9155
8887
|
return renderTaskInput({
|
|
9156
8888
|
about: task.trigger.label,
|
|
@@ -9159,6 +8891,7 @@ function eventInput(task, event, outcomes, catalog, author) {
|
|
|
9159
8891
|
creator: slackMention(task.createdBy.slackUserId),
|
|
9160
8892
|
instructions: automationTaskText(task.task),
|
|
9161
8893
|
...task.task.kind === "skill" ? { skill: task.task.skill } : void 0,
|
|
8894
|
+
openQuestions,
|
|
9162
8895
|
outcomes,
|
|
9163
8896
|
guidance,
|
|
9164
8897
|
trustedSummary: event.trustedSummary,
|
|
@@ -9246,7 +8979,12 @@ async function ingestEventAutomations(input, options) {
|
|
|
9246
8979
|
allowedWhen: "event-automation",
|
|
9247
8980
|
taskId: task.id
|
|
9248
8981
|
} : void 0;
|
|
9249
|
-
|
|
8982
|
+
await recordEventAutomationRunStarted(db, {
|
|
8983
|
+
automation: task,
|
|
8984
|
+
dispatchId: eventAutomationDispatchId(idempotencyKey),
|
|
8985
|
+
nowMs
|
|
8986
|
+
});
|
|
8987
|
+
if ((await dispatchEventAutomation({
|
|
9250
8988
|
automationId: task.id,
|
|
9251
8989
|
conversationWorkQueue: options.queue,
|
|
9252
8990
|
nowMs,
|
|
@@ -9255,19 +8993,13 @@ async function ingestEventAutomations(input, options) {
|
|
|
9255
8993
|
...credentialSubject ? { credentialSubject } : void 0,
|
|
9256
8994
|
destination,
|
|
9257
8995
|
destinationVisibility: task.destinationVisibility,
|
|
9258
|
-
input: eventInput(task, event, outcomes, catalog, author),
|
|
8996
|
+
input: eventInput(task, event, outcomes, catalog, author, await listOpenAutomationQuestions(db, task.id)),
|
|
9259
8997
|
...skill ? { skill } : void 0,
|
|
9260
8998
|
metadata: { eventAutomationId: task.id },
|
|
9261
8999
|
replyAttribution: automationReplyAttribution(task.title),
|
|
9262
9000
|
outcomes
|
|
9263
9001
|
}
|
|
9264
|
-
});
|
|
9265
|
-
await recordEventAutomationRunStarted(db, {
|
|
9266
|
-
automation: task,
|
|
9267
|
-
dispatchId: dispatch.id,
|
|
9268
|
-
nowMs
|
|
9269
|
-
});
|
|
9270
|
-
if (dispatch.status === "created") dispatched += 1;
|
|
9002
|
+
})).status === "created") dispatched += 1;
|
|
9271
9003
|
} catch (error) {
|
|
9272
9004
|
errors.push(error);
|
|
9273
9005
|
}
|
|
@@ -9352,7 +9084,7 @@ function createEventAppPublisher(args) {
|
|
|
9352
9084
|
*/
|
|
9353
9085
|
async function answerPluginInboxItem(args) {
|
|
9354
9086
|
const { item } = args;
|
|
9355
|
-
const pluginName = inboxItemPlugin(item
|
|
9087
|
+
const pluginName = inboxItemPlugin(item);
|
|
9356
9088
|
const choice = item.answer?.values[PLUGIN_CHOICE_FIELD_ID]?.[0];
|
|
9357
9089
|
const conversationId = ownerConversationId(item);
|
|
9358
9090
|
if (!pluginName || !choice || !conversationId) return;
|
|
@@ -9365,7 +9097,10 @@ async function answerPluginInboxItem(args) {
|
|
|
9365
9097
|
choice,
|
|
9366
9098
|
codeChanges: createPluginCodeChanges(pluginName),
|
|
9367
9099
|
conversationId,
|
|
9368
|
-
|
|
9100
|
+
subject: {
|
|
9101
|
+
id: item.subject.id,
|
|
9102
|
+
kind: item.subject.kind.slice(pluginName.length + 1)
|
|
9103
|
+
},
|
|
9369
9104
|
events: createPluginEventPublisher(plugin, events),
|
|
9370
9105
|
itemId: item.id,
|
|
9371
9106
|
nowMs: args.nowMs,
|
|
@@ -9383,11 +9118,12 @@ const MATCH_CONFIDENCE_THRESHOLD = .7;
|
|
|
9383
9118
|
/** A slow decision keeps the items open instead of delaying the close. */
|
|
9384
9119
|
const MATCH_TIMEOUT_MS = 1e4;
|
|
9385
9120
|
function describeItem(item) {
|
|
9386
|
-
const
|
|
9121
|
+
const request = inboxItemQuestion(item.request);
|
|
9122
|
+
const fields = (request?.fields ?? []).map((field) => "options" in field ? `- ${field.label}: ${field.options.map((option) => option.label).join(" / ")}` : `- ${field.label}: free text`);
|
|
9387
9123
|
return [
|
|
9388
9124
|
`Title: ${item.title}`,
|
|
9389
9125
|
`Details: ${item.body}`,
|
|
9390
|
-
...
|
|
9126
|
+
...request ? [`Question: ${request.question}`] : [],
|
|
9391
9127
|
...fields.length ? ["Fields:", ...fields] : []
|
|
9392
9128
|
].join("\n");
|
|
9393
9129
|
}
|
|
@@ -9483,8 +9219,9 @@ function isSameClose(item, action, user) {
|
|
|
9483
9219
|
return item.closeReason !== "Replied in thread" && item.closedBy?.userId === user.id && item.status === closedStatus(action) && action === "submit" === Boolean(item.answer);
|
|
9484
9220
|
}
|
|
9485
9221
|
function submittedAnswer(item, answer) {
|
|
9486
|
-
|
|
9487
|
-
|
|
9222
|
+
const question = inboxItemQuestion(item.request);
|
|
9223
|
+
if (item.kind !== "action" || !question) throw new InboxItemActionError("invalid", "Only an action item takes an answer.");
|
|
9224
|
+
const normalized = normalizeUserInputAnswer(question, {
|
|
9488
9225
|
other: answer?.other,
|
|
9489
9226
|
requestId: item.id,
|
|
9490
9227
|
values: answer?.values ?? {}
|
|
@@ -9503,16 +9240,24 @@ function submittedAnswer(item, answer) {
|
|
|
9503
9240
|
* `exceptConversationId` is the Conversation where the person acted. It gets
|
|
9504
9241
|
* the person's input from its own surface, so it gets no message here.
|
|
9505
9242
|
* `delivery` shows the change and sends the messages; see
|
|
9506
|
-
* `deliverInboxItemChange`.
|
|
9243
|
+
* `deliverInboxItemChange`. A submit, dismiss, or done also closes the
|
|
9244
|
+
* person's reply notices in the item's Conversations: the item had their
|
|
9245
|
+
* attention.
|
|
9507
9246
|
*/
|
|
9508
9247
|
async function actOnInboxItem(args) {
|
|
9509
9248
|
const { action, user } = args;
|
|
9510
9249
|
const nowMs = args.nowMs ?? Date.now();
|
|
9511
9250
|
const db = getDb();
|
|
9512
9251
|
const item = await readInboxItemForUser(user, args.id);
|
|
9513
|
-
if (
|
|
9252
|
+
if (subjectTodo(item.subject)) {
|
|
9514
9253
|
if (action !== "done" && action !== "dismiss") throw new InboxItemActionError("invalid", "A To-do item takes only Done or Dismiss.");
|
|
9515
|
-
|
|
9254
|
+
const closed = await closeTodoItem(item, user, nowMs, action);
|
|
9255
|
+
await closeHandledReplyNotices(db, {
|
|
9256
|
+
item: closed,
|
|
9257
|
+
nowMs,
|
|
9258
|
+
userId: user.id
|
|
9259
|
+
});
|
|
9260
|
+
return closed;
|
|
9516
9261
|
}
|
|
9517
9262
|
if (action === "done") throw new InboxItemActionError("invalid", "Only a To-do item can be marked done.");
|
|
9518
9263
|
if (action === "take") {
|
|
@@ -9548,6 +9293,11 @@ async function actOnInboxItem(args) {
|
|
|
9548
9293
|
closed = await readInboxItemForUser(user, item.id);
|
|
9549
9294
|
}
|
|
9550
9295
|
if (args.firstCloseOnly ? !closedNow : !isSameClose(closed, action, user)) throw new InboxItemActionError("conflict", "Inbox item is closed.");
|
|
9296
|
+
await closeHandledReplyNotices(db, {
|
|
9297
|
+
item: closed,
|
|
9298
|
+
nowMs,
|
|
9299
|
+
userId: user.id
|
|
9300
|
+
});
|
|
9551
9301
|
if (action === "submit" && isPluginInboxItem(closed)) await answerPluginInboxItem({
|
|
9552
9302
|
delivery: args.delivery,
|
|
9553
9303
|
item: closed,
|
|
@@ -9576,11 +9326,11 @@ async function actOnInboxItem(args) {
|
|
|
9576
9326
|
* Close a To-do item for its assignee through its To-do: Done marks the
|
|
9577
9327
|
* To-do done, and Dismiss drops it. The To-do change closes the item as
|
|
9578
9328
|
* done or dismissed (`syncTodoInboxItems`), and the agent sees it in its
|
|
9579
|
-
* next
|
|
9329
|
+
* next To-do delta, so it sends no message and starts no Turn. A retry
|
|
9580
9330
|
* after the item closed the same way by the same person succeeds.
|
|
9581
9331
|
*/
|
|
9582
9332
|
async function closeTodoItem(item, user, nowMs, action) {
|
|
9583
|
-
const todo =
|
|
9333
|
+
const todo = subjectTodo(item.subject);
|
|
9584
9334
|
if (item.status === "open") {
|
|
9585
9335
|
if (!canActOnInboxItem(item, user.id)) throw new InboxItemActionError("forbidden", "Only an assignee can act on this item.");
|
|
9586
9336
|
await setTodoStatusByUser(getSqlExecutor(), {
|
|
@@ -9607,8 +9357,9 @@ function replyAnswers(item, user) {
|
|
|
9607
9357
|
}
|
|
9608
9358
|
/** Return the answer that the text of a person's message gives to an item. */
|
|
9609
9359
|
function messageAnswer(item, text) {
|
|
9610
|
-
|
|
9611
|
-
|
|
9360
|
+
const question = inboxItemQuestion(item.request);
|
|
9361
|
+
if (!question) return void 0;
|
|
9362
|
+
const answer = normalizeUserInputAnswer(question, {
|
|
9612
9363
|
other: text,
|
|
9613
9364
|
requestId: item.id,
|
|
9614
9365
|
values: {}
|
|
@@ -10253,24 +10004,6 @@ async function reorderPinnedConversations(viewer, body) {
|
|
|
10253
10004
|
const updatedIds = new Set(updated.map((row) => row.rootConversationId));
|
|
10254
10005
|
return { conversationIds: ids.filter((id) => updatedIds.has(id)) };
|
|
10255
10006
|
}
|
|
10256
|
-
// src/chat/conversations/sql/title.ts
|
|
10257
|
-
/**
|
|
10258
|
-
* Replace one Conversation's title. Returns the stored title, or undefined
|
|
10259
|
-
* when the Conversation does not exist.
|
|
10260
|
-
*
|
|
10261
|
-
* recordActivity reads the title and writes it back under the mutation lock,
|
|
10262
|
-
* so this write takes the same lock. A concurrent Turn cannot restore the old
|
|
10263
|
-
* title.
|
|
10264
|
-
*/
|
|
10265
|
-
async function setConversationTitle(executor, conversationId, title) {
|
|
10266
|
-
return await withConversationMutationLock(executor, conversationId, async () => {
|
|
10267
|
-
const [row] = await executor.db().update(juniorConversations).set({
|
|
10268
|
-
detailVersion: nextDetailVersion,
|
|
10269
|
-
title
|
|
10270
|
-
}).where(eq(juniorConversations.conversationId, conversationId)).returning({ title: juniorConversations.title });
|
|
10271
|
-
return row?.title ?? void 0;
|
|
10272
|
-
});
|
|
10273
|
-
}
|
|
10274
10007
|
// src/api/conversations/rename.ts
|
|
10275
10008
|
/**
|
|
10276
10009
|
* Rename one conversation. The title is shared, so only a participant can
|
|
@@ -10348,12 +10081,12 @@ const writeAnnotations = {
|
|
|
10348
10081
|
const archiveConversationOperation = defineApiOperation({
|
|
10349
10082
|
name: "archiveConversation",
|
|
10350
10083
|
title: "Archive conversation",
|
|
10351
|
-
description: "Archive one of your conversations, or restore it, for everyone in it. Archiving a conversation hides it and its child conversations. A restore fails while a conversation above it is archived. A new message from a person restores the conversation and the archived conversations above it.",
|
|
10084
|
+
description: "Archive one of your conversations, or restore it, for everyone in it. Archiving a conversation hides it and its child conversations and stops their running work. A restore fails while a conversation above it is archived. A new message from a person restores the conversation and the archived conversations above it.",
|
|
10352
10085
|
scope: "conversations:manage",
|
|
10353
10086
|
input: archiveConversationBodySchema.extend(conversationIdInput),
|
|
10354
10087
|
output: archiveConversationResponseSchema,
|
|
10355
10088
|
annotations: writeAnnotations,
|
|
10356
|
-
run: (viewer, { conversationId, ...body }) => archiveConversation(viewer, conversationId, body)
|
|
10089
|
+
run: (viewer, { conversationId, ...body }, services) => archiveConversation(viewer, conversationId, body, services)
|
|
10357
10090
|
});
|
|
10358
10091
|
/** Archive every done Conversation of the viewer once. */
|
|
10359
10092
|
const archiveDoneConversationsOperation = defineApiOperation({
|
|
@@ -10486,7 +10219,7 @@ const conversationCursorPayloadSchema = z.object({
|
|
|
10486
10219
|
version: z.literal(1)
|
|
10487
10220
|
}).strict();
|
|
10488
10221
|
function cursorSecret() {
|
|
10489
|
-
const secret =
|
|
10222
|
+
const secret = getChatConfig().secrets.juniorSecret;
|
|
10490
10223
|
if (!secret) throw new Error("Cannot sign conversation cursor without JUNIOR_SECRET");
|
|
10491
10224
|
return secret;
|
|
10492
10225
|
}
|
|
@@ -10550,8 +10283,7 @@ async function requireWebMessageConversation(viewer, conversationId, idempotency
|
|
|
10550
10283
|
if (!conversation) throwApiError(404, "Conversation not found.");
|
|
10551
10284
|
if (!acceptsWebMessages(conversation)) throwApiError(409, "Conversation does not accept web messages.");
|
|
10552
10285
|
const access = await readConversationAccessFromSql(getDb(), [conversationId], viewer);
|
|
10553
|
-
if (!canAddConversationMessages(access.get(conversationId))) throwApiError(403, "Only participants can add messages
|
|
10554
|
-
if (messagesNeedSpaceMembership(conversation.kind) && conversation.spaceId) await requireSpaceForWork(viewer, conversation.spaceId);
|
|
10286
|
+
if (!canAddConversationMessages(access.get(conversationId))) throwApiError(403, "Only participants can add messages. Join the conversation first.");
|
|
10555
10287
|
return conversationId;
|
|
10556
10288
|
}
|
|
10557
10289
|
function actorFromViewer(viewer) {
|
|
@@ -10563,6 +10295,7 @@ async function createConversationForViewer(viewer, body, services) {
|
|
|
10563
10295
|
const space = body.spaceId ? await requireSpaceForWork(viewer, body.spaceId) : void 0;
|
|
10564
10296
|
if (space && body.visibility && body.visibility !== space.visibility) throwApiError(400, `A conversation in this Space is ${space.visibility}.`);
|
|
10565
10297
|
const visibility = space?.visibility ?? body.visibility;
|
|
10298
|
+
const lead = space ? await getSpaceLead(space.id) : void 0;
|
|
10566
10299
|
const uploads = await verifyUploads({
|
|
10567
10300
|
conversationId: await requireWebMessageConversation(viewer, void 0, body.idempotencyKey),
|
|
10568
10301
|
idempotencyKey: body.idempotencyKey,
|
|
@@ -10577,7 +10310,7 @@ async function createConversationForViewer(viewer, body, services) {
|
|
|
10577
10310
|
uploads,
|
|
10578
10311
|
...body.title ? { title: body.title } : void 0,
|
|
10579
10312
|
...visibility ? { visibility } : void 0,
|
|
10580
|
-
...
|
|
10313
|
+
...lead ? { leadConversationId: lead.conversationId } : void 0
|
|
10581
10314
|
}, {
|
|
10582
10315
|
conversationStore: getConversationStore(),
|
|
10583
10316
|
attachmentStorage: services.attachmentStorage,
|
|
@@ -10586,7 +10319,6 @@ async function createConversationForViewer(viewer, body, services) {
|
|
|
10586
10319
|
} catch (error) {
|
|
10587
10320
|
throwApiError(500, "Unable to create conversation.", error);
|
|
10588
10321
|
}
|
|
10589
|
-
await inviteMentionedPeople(viewer, accepted.conversationId, body.message);
|
|
10590
10322
|
return accepted;
|
|
10591
10323
|
}
|
|
10592
10324
|
/** Append one viewer message to an existing conversation. */
|
|
@@ -10611,7 +10343,6 @@ async function appendConversationMessageForViewer(viewer, conversationId, body,
|
|
|
10611
10343
|
queue: services.queue
|
|
10612
10344
|
});
|
|
10613
10345
|
const applyAccepted = async () => {
|
|
10614
|
-
await inviteMentionedPeople(viewer, conversationId, body.message);
|
|
10615
10346
|
await closeInboxItemsAnsweredByReply({
|
|
10616
10347
|
conversationId,
|
|
10617
10348
|
delivery: {
|
|
@@ -11511,11 +11242,12 @@ function viewerStateVersion(db, conversationId, viewerId) {
|
|
|
11511
11242
|
const versionSpaceConversation = alias(juniorConversations, "version_space_conversation");
|
|
11512
11243
|
const versionSpaceRoot = alias(juniorConversations, "version_space_root");
|
|
11513
11244
|
/**
|
|
11514
|
-
* Hash the root's Space. A move
|
|
11515
|
-
*
|
|
11245
|
+
* Hash the root's Space. A move and a rename write only the root, the Lead
|
|
11246
|
+
* whose title is the Space's name, so a child's token reads both through
|
|
11247
|
+
* its root.
|
|
11516
11248
|
*/
|
|
11517
11249
|
function rootSpaceVersion(db, conversationId) {
|
|
11518
|
-
const space = db.select({ state: sql`md5(concat_ws(':', ${versionSpaceRoot.spaceId}, ${
|
|
11250
|
+
const space = db.select({ state: sql`md5(concat_ws(':', ${versionSpaceRoot.spaceId}, ${versionSpaceRoot.title}))` }).from(versionSpaceConversation).innerJoin(versionSpaceRoot, eq(versionSpaceRoot.conversationId, sql`coalesce(${versionSpaceConversation.rootConversationId}, ${versionSpaceConversation.conversationId})`)).where(eq(versionSpaceConversation.conversationId, conversationId));
|
|
11519
11251
|
return sql`coalesce((${space}), '')`;
|
|
11520
11252
|
}
|
|
11521
11253
|
/**
|
|
@@ -11568,11 +11300,11 @@ async function readDetailStateRow(conversationId, viewer) {
|
|
|
11568
11300
|
pinnedAt: juniorConversationParticipants.pinnedAt,
|
|
11569
11301
|
pinPosition: juniorConversationParticipants.pinPosition,
|
|
11570
11302
|
rootConversationId,
|
|
11571
|
-
spaceId:
|
|
11572
|
-
spaceName:
|
|
11303
|
+
spaceId: spaceRoot.spaceId,
|
|
11304
|
+
spaceName: spaceRoot.title,
|
|
11573
11305
|
unsubscribedAt: juniorConversationParticipants.unsubscribedAt,
|
|
11574
11306
|
version: sql`(${conversationVersionQuery(db, conversationId, viewer?.id)})`
|
|
11575
|
-
}).from(juniorConversations).leftJoin(juniorDestinations, conversationRecordJoins.location).leftJoin(juniorIdentities, conversationRecordJoins.identity).leftJoin(juniorUsers, conversationRecordJoins.user).leftJoin(forkSource, eq(forkSource.conversationId, juniorConversations.forkedFromConversationId)).leftJoin(spaceRoot, eq(spaceRoot.conversationId, rootConversationId)).leftJoin(
|
|
11307
|
+
}).from(juniorConversations).leftJoin(juniorDestinations, conversationRecordJoins.location).leftJoin(juniorIdentities, conversationRecordJoins.identity).leftJoin(juniorUsers, conversationRecordJoins.user).leftJoin(forkSource, eq(forkSource.conversationId, juniorConversations.forkedFromConversationId)).leftJoin(spaceRoot, eq(spaceRoot.conversationId, rootConversationId)).leftJoin(juniorConversationParticipants, viewerParticipant).leftJoin(detailViewer, viewer ? eq(detailViewer.id, viewer.id) : sql`false`).where(eq(juniorConversations.conversationId, conversationId));
|
|
11576
11308
|
return row;
|
|
11577
11309
|
}
|
|
11578
11310
|
async function readDetailState(conversationId, viewer, readAccess) {
|
|
@@ -11604,7 +11336,7 @@ async function readDetailState(conversationId, viewer, readAccess) {
|
|
|
11604
11336
|
...viewer ? { autoArchive: row?.autoArchive ?? row?.autoArchiveDefault ?? false } : void 0,
|
|
11605
11337
|
forks,
|
|
11606
11338
|
...row?.lastReadSeq != null ? { readPosition: { lastReadSeq: row.lastReadSeq } } : void 0,
|
|
11607
|
-
space: row?.spaceId && row.spaceName &&
|
|
11339
|
+
space: row?.spaceId && row.spaceName && access?.canViewPrivateContent ? {
|
|
11608
11340
|
id: row.spaceId,
|
|
11609
11341
|
name: row.spaceName
|
|
11610
11342
|
} : null,
|
|
@@ -11986,11 +11718,10 @@ function needsUserSql(userId) {
|
|
|
11986
11718
|
* Conversation and every child Conversation at any depth. When more than
|
|
11987
11719
|
* one applies:
|
|
11988
11720
|
*
|
|
11989
|
-
* - `needs_you`: the tree's `needs_input` includes the viewer.
|
|
11990
|
-
* item
|
|
11991
|
-
*
|
|
11992
|
-
*
|
|
11993
|
-
* shown.
|
|
11721
|
+
* - `needs_you`: the tree's `needs_input` includes the viewer. An Inbox
|
|
11722
|
+
* item, a sign-in wait, or a wait on the starter anywhere in the tree
|
|
11723
|
+
* counts when it waits on the viewer. Input that waits on another person
|
|
11724
|
+
* is not shown.
|
|
11994
11725
|
* - `working`: a Turn is queued or running anywhere in the tree.
|
|
11995
11726
|
* - `done`: anything else.
|
|
11996
11727
|
*
|
|
@@ -12010,7 +11741,7 @@ function needsUserSql(userId) {
|
|
|
12010
11741
|
async function readConversationTreeStates(db, conversationIds, viewerUserId) {
|
|
12011
11742
|
if (conversationIds.length === 0) return /* @__PURE__ */ new Map();
|
|
12012
11743
|
const scopeId = conversationSubtreeColumns.scopeConversationId;
|
|
12013
|
-
const needsViewer = viewerUserId ? sql`bool_or(${needsUserSql(viewerUserId)} or
|
|
11744
|
+
const needsViewer = viewerUserId ? sql`bool_or(${needsUserSql(viewerUserId)} or ${conversationWaitsOnUserSql(juniorConversations, viewerUserId)})` : sql`false`;
|
|
12014
11745
|
const rows = await db.select({
|
|
12015
11746
|
conversationId: scopeId,
|
|
12016
11747
|
needsViewer,
|
|
@@ -12201,16 +11932,17 @@ async function readConversationDetailFromSql(conversationId, options) {
|
|
|
12201
11932
|
name: "Project conversation detail",
|
|
12202
11933
|
op: "function"
|
|
12203
11934
|
}, () => projectConversationDetail(detail));
|
|
11935
|
+
const isRoot = access?.rootConversationId === conversationId;
|
|
12204
11936
|
return {
|
|
12205
11937
|
...report,
|
|
12206
11938
|
...state.forks,
|
|
12207
11939
|
...treeStateByConversation.get(conversationId),
|
|
12208
11940
|
...agentTree ? { agentTree } : void 0,
|
|
12209
11941
|
...report.isParticipant && state.autoArchive !== void 0 ? { autoArchive: state.autoArchive } : void 0,
|
|
12210
|
-
...report.isParticipant
|
|
11942
|
+
...isRoot && (report.isParticipant ? state.subscribed !== void 0 : access?.visibility === "public") ? { subscribed: report.isParticipant && state.subscribed === true } : void 0,
|
|
12211
11943
|
...canContinueInSlack(record.conversation, access) ? { canContinueInSlack: true } : void 0,
|
|
12212
11944
|
...canInviteToConversation(access) ? { canInvite: true } : void 0,
|
|
12213
|
-
...leaveEndsAccess(access) ? { leaveEndsAccess: true } : void 0,
|
|
11945
|
+
...isRoot && leaveEndsAccess(access) ? { leaveEndsAccess: true } : void 0,
|
|
12214
11946
|
...report.isParticipant && canPauseConversationDelivery(record.conversation) ? { deliveryPaused: record.conversation.deliveryPausedAtMs !== void 0 } : void 0
|
|
12215
11947
|
};
|
|
12216
11948
|
}
|
|
@@ -12229,54 +11961,65 @@ async function readConversationDetail(conversationId, options = {}) {
|
|
|
12229
11961
|
} : { limit: options.limit }
|
|
12230
11962
|
});
|
|
12231
11963
|
}
|
|
12232
|
-
// src/
|
|
12233
|
-
/**
|
|
12234
|
-
*
|
|
12235
|
-
*
|
|
12236
|
-
|
|
12237
|
-
|
|
12238
|
-
|
|
12239
|
-
|
|
12240
|
-
|
|
12241
|
-
|
|
12242
|
-
|
|
12243
|
-
|
|
12244
|
-
|
|
12245
|
-
|
|
12246
|
-
|
|
11964
|
+
// src/api/inbox-items/resolve-subjects.ts
|
|
11965
|
+
/**
|
|
11966
|
+
* Read the link and card of each item subject that has a link, such as a
|
|
11967
|
+
* pull request, for one viewer and one page of items, by `subjectKey`. A
|
|
11968
|
+
* link type that can read many objects at once reads the page with one
|
|
11969
|
+
* call, such as one GitHub GraphQL query. A subject whose card cannot be
|
|
11970
|
+
* read, such as when its provider is down, has only its link: the Inbox
|
|
11971
|
+
* then shows the item's own title and the label of its kind.
|
|
11972
|
+
*/
|
|
11973
|
+
async function resolveInboxItemSubjects(viewer, items) {
|
|
11974
|
+
const links = await readSubjectLinks(getDb(), items);
|
|
11975
|
+
if (links.size === 0) return /* @__PURE__ */ new Map();
|
|
11976
|
+
const cards = new Map((await resolveObjectLinks(viewer, [...new Set(links.values())])).map(({ object, url }) => [url, object]));
|
|
11977
|
+
return new Map([...links].map(([key, url]) => {
|
|
11978
|
+
const object = cards.get(url);
|
|
11979
|
+
return [key, {
|
|
11980
|
+
url,
|
|
11981
|
+
...object ? { object } : void 0
|
|
11982
|
+
}];
|
|
11983
|
+
}));
|
|
12247
11984
|
}
|
|
12248
11985
|
// src/api/conversations/threads.ts
|
|
12249
11986
|
/**
|
|
12250
|
-
* Find where a Thread nests: its nearest ancestor that is a listed
|
|
12251
|
-
* Thread. A Thread under a Task moves up.
|
|
12252
|
-
* is archived, because an archive hides
|
|
11987
|
+
* Find where a Thread nests: its nearest ancestor that is a listed row or a
|
|
11988
|
+
* Thread, and the listed row above it. A Thread under a Task moves up.
|
|
11989
|
+
* Returns undefined when an ancestor is archived, because an archive hides
|
|
11990
|
+
* its whole subtree.
|
|
12253
11991
|
*/
|
|
12254
11992
|
function findThreadPlacement(threadId, tree, rootIds) {
|
|
12255
11993
|
let placement;
|
|
12256
11994
|
for (const ancestor of conversationAncestors(tree, threadId)) {
|
|
12257
|
-
if (rootIds.has(ancestor.conversationId)) return
|
|
11995
|
+
if (rootIds.has(ancestor.conversationId)) return {
|
|
11996
|
+
listedId: ancestor.conversationId,
|
|
11997
|
+
parentId: placement ?? ancestor.conversationId
|
|
11998
|
+
};
|
|
12258
11999
|
if (ancestor.archivedAt) return void 0;
|
|
12259
12000
|
if (isThread(ancestor)) placement ??= ancestor.conversationId;
|
|
12260
12001
|
}
|
|
12261
12002
|
}
|
|
12262
12003
|
/**
|
|
12263
|
-
* Read the stored Threads
|
|
12264
|
-
* read-time titles
|
|
12265
|
-
* feed reads. The caller passes only unarchived roots, so a root archive
|
|
12004
|
+
* Read the stored Threads under the listed rows for the feed, with their
|
|
12005
|
+
* read-time titles and each Thread's tree state for the viewer. It needs
|
|
12006
|
+
* no access, so it can start with the other feed reads. The caller passes only unarchived roots, so a root archive
|
|
12266
12007
|
* hides its tree with no writes to the children.
|
|
12267
12008
|
*/
|
|
12268
|
-
async function readFeedThreadRecords(db, rootIds) {
|
|
12009
|
+
async function readFeedThreadRecords(db, rootIds, viewerUserId) {
|
|
12269
12010
|
if (rootIds.length === 0) return void 0;
|
|
12270
|
-
const rows = await selectConversationRecords(db).
|
|
12011
|
+
const rows = await selectConversationRecords(db).innerJoin(conversationSubtree(rootIds), eq(conversationSubtreeColumns.conversationId, juniorConversations.conversationId)).where(and(eq(juniorConversations.kind, "thread"), isNotNull(juniorConversations.parentConversationId), notInArray(juniorConversations.conversationId, rootIds), isNull(juniorConversations.archivedAt))).orderBy(desc(juniorConversations.lastActivityAt), asc(juniorConversations.conversationId));
|
|
12271
12012
|
if (rows.length === 0) return void 0;
|
|
12272
12013
|
const threads = rows.map((row) => ({
|
|
12273
12014
|
conversation: conversationFromRecordRow(row),
|
|
12274
12015
|
row
|
|
12275
12016
|
}));
|
|
12017
|
+
const [firstHumanMessageTexts, treeStates] = await Promise.all([readFirstHumanMessageTexts(db, threads.map(({ conversation }) => conversation)), readConversationTreeStates(db, threads.map(({ conversation }) => conversation.conversationId), viewerUserId)]);
|
|
12276
12018
|
return {
|
|
12277
|
-
firstHumanMessageTexts
|
|
12019
|
+
firstHumanMessageTexts,
|
|
12278
12020
|
rootIds: new Set(rootIds),
|
|
12279
|
-
threads
|
|
12021
|
+
threads,
|
|
12022
|
+
treeStates
|
|
12280
12023
|
};
|
|
12281
12024
|
}
|
|
12282
12025
|
/**
|
|
@@ -12289,16 +12032,16 @@ async function readFeedThreadRecords(db, rootIds) {
|
|
|
12289
12032
|
*/
|
|
12290
12033
|
function nestFeedThreads(records, tree, accessByRoot) {
|
|
12291
12034
|
if (!records) return /* @__PURE__ */ new Map();
|
|
12292
|
-
const { firstHumanMessageTexts, rootIds, threads } = records;
|
|
12035
|
+
const { firstHumanMessageTexts, rootIds, threads, treeStates } = records;
|
|
12293
12036
|
const childrenByParent = /* @__PURE__ */ new Map();
|
|
12294
12037
|
const placedByRoot = /* @__PURE__ */ new Map();
|
|
12295
12038
|
for (const { conversation, row } of threads) {
|
|
12296
|
-
const
|
|
12297
|
-
if (!
|
|
12298
|
-
const
|
|
12299
|
-
|
|
12039
|
+
const placement = findThreadPlacement(conversation.conversationId, tree, rootIds);
|
|
12040
|
+
if (!placement) continue;
|
|
12041
|
+
const { listedId, parentId } = placement;
|
|
12042
|
+
placedByRoot.set(listedId, (placedByRoot.get(listedId) ?? 0) + 1);
|
|
12300
12043
|
const summary = conversationSummaryFromStoredConversation({
|
|
12301
|
-
access:
|
|
12044
|
+
access: accessByRoot.get(listedId),
|
|
12302
12045
|
conversation,
|
|
12303
12046
|
durationMs: row.conversation.durationMs,
|
|
12304
12047
|
firstHumanMessageText: firstHumanMessageTexts.get(conversation.conversationId),
|
|
@@ -12306,7 +12049,10 @@ function nestFeedThreads(records, tree, accessByRoot) {
|
|
|
12306
12049
|
...row.conversation.usage ? { usage: row.conversation.usage } : void 0
|
|
12307
12050
|
});
|
|
12308
12051
|
const siblings = childrenByParent.get(parentId) ?? [];
|
|
12309
|
-
siblings.push(
|
|
12052
|
+
siblings.push({
|
|
12053
|
+
...summary,
|
|
12054
|
+
...treeStates.get(conversation.conversationId)
|
|
12055
|
+
});
|
|
12310
12056
|
childrenByParent.set(parentId, siblings);
|
|
12311
12057
|
}
|
|
12312
12058
|
const nest = (items, budget) => items.flatMap((item) => {
|
|
@@ -12331,59 +12077,6 @@ function nestFeedThreads(records, tree, accessByRoot) {
|
|
|
12331
12077
|
}]];
|
|
12332
12078
|
}));
|
|
12333
12079
|
}
|
|
12334
|
-
// src/chat/inbox-items/waiting.ts
|
|
12335
|
-
const waitingRootId = sql`coalesce(${juniorConversations.rootConversationId}, ${juniorInboxItemConversations.conversationId})`.as("waiting_root_id");
|
|
12336
|
-
const waitingTodoRootId = sql`coalesce(${juniorConversations.rootConversationId}, ${juniorInboxItems.ownerId})`.as("waiting_root_id");
|
|
12337
|
-
/** Open items that need the User now, with the root where each one waits. */
|
|
12338
|
-
function waitingItemsQuery(db, userId) {
|
|
12339
|
-
const columns = {
|
|
12340
|
-
createdAt: juniorInboxItems.createdAt,
|
|
12341
|
-
dedupeKey: juniorInboxItems.dedupeKey,
|
|
12342
|
-
itemId: juniorInboxItems.id,
|
|
12343
|
-
title: juniorInboxItems.title
|
|
12344
|
-
};
|
|
12345
|
-
return db.select({
|
|
12346
|
-
conversationId: waitingRootId,
|
|
12347
|
-
...columns
|
|
12348
|
-
}).from(juniorInboxItemConversations).innerJoin(juniorInboxItems, eq(juniorInboxItems.id, juniorInboxItemConversations.itemId)).leftJoin(juniorConversations, eq(juniorConversations.conversationId, juniorInboxItemConversations.conversationId)).where(inboxItemNeedsUserNow(userId)).union(db.select({
|
|
12349
|
-
conversationId: waitingTodoRootId,
|
|
12350
|
-
...columns
|
|
12351
|
-
}).from(juniorInboxItems).leftJoin(juniorConversations, eq(juniorConversations.conversationId, juniorInboxItems.ownerId)).where(and(inboxItemNeedsUserNow(userId), eq(juniorInboxItems.ownerKind, "conversation"), like(juniorInboxItems.dedupeKey, `${TODO_INBOX_ITEM_KEY_PREFIX}%`))));
|
|
12352
|
-
}
|
|
12353
|
-
/**
|
|
12354
|
-
* Return a query for the ids of the root Conversations that wait on a User,
|
|
12355
|
-
* as `listWaitingConversations` lists them, to filter another query by.
|
|
12356
|
-
*/
|
|
12357
|
-
function waitingConversationIdsQuery(db, userId) {
|
|
12358
|
-
const items = waitingItemsQuery(db, userId).as("waiting_items");
|
|
12359
|
-
return db.select({ conversationId: items.conversationId }).from(items);
|
|
12360
|
-
}
|
|
12361
|
-
/**
|
|
12362
|
-
* List the root Conversations that wait on a User: each root or one of its
|
|
12363
|
-
* child conversations is linked to, or owns a To-do's, open item that needs
|
|
12364
|
-
* the User now (`inboxItemNeedsUserNow`), so a snoozed item leaves it out.
|
|
12365
|
-
*/
|
|
12366
|
-
async function listWaitingConversations(db, userId) {
|
|
12367
|
-
const rows = (await waitingItemsQuery(db, userId)).sort((left, right) => right.createdAt.getTime() - left.createdAt.getTime() || right.itemId.localeCompare(left.itemId));
|
|
12368
|
-
const waiting = /* @__PURE__ */ new Map();
|
|
12369
|
-
for (const row of rows) {
|
|
12370
|
-
const plugin = inboxItemPlugin(row.dedupeKey);
|
|
12371
|
-
const item = {
|
|
12372
|
-
title: row.title,
|
|
12373
|
-
...plugin ? { plugin } : void 0
|
|
12374
|
-
};
|
|
12375
|
-
const current = waiting.get(row.conversationId);
|
|
12376
|
-
if (current) {
|
|
12377
|
-
current.items.push(item);
|
|
12378
|
-
current.waitingSince = row.createdAt.toISOString();
|
|
12379
|
-
} else waiting.set(row.conversationId, {
|
|
12380
|
-
conversationId: row.conversationId,
|
|
12381
|
-
items: [item],
|
|
12382
|
-
waitingSince: row.createdAt.toISOString()
|
|
12383
|
-
});
|
|
12384
|
-
}
|
|
12385
|
-
return [...waiting.values()].sort((left, right) => left.conversationId.localeCompare(right.conversationId));
|
|
12386
|
-
}
|
|
12387
12080
|
// src/api/conversations/priority.ts
|
|
12388
12081
|
/** Conversations with no known work leave Priority after this idle window. */
|
|
12389
12082
|
const UNASSIGNED_PRIORITY_WINDOW_MS = 108e5;
|
|
@@ -12533,7 +12226,7 @@ function feedMediaSql(db) {
|
|
|
12533
12226
|
* closed since.
|
|
12534
12227
|
*/
|
|
12535
12228
|
function feedViewerAnswerSql(db, userId) {
|
|
12536
|
-
const latest = db.select({ answer: sql`jsonb_build_object('answer', ${
|
|
12229
|
+
const latest = db.select({ answer: sql`jsonb_build_object('answer', ${inboxItemAnswer}, 'closedAt', ${juniorInboxItems.closedAt}, 'request', ${inboxItemRequest})` }).from(juniorInboxItems).leftJoin(juniorQuestions, itemQuestion).where(and(inboxItemOwnedByConversation(juniorConversations.conversationId), eq(juniorInboxItems.closedByUserId, userId), isNotNull(inboxItemAnswer), isNotNull(inboxItemRequest))).orderBy(desc(juniorInboxItems.closedAt), desc(juniorInboxItems.id)).limit(1);
|
|
12537
12230
|
return sql`(${latest})`;
|
|
12538
12231
|
}
|
|
12539
12232
|
/**
|
|
@@ -12590,30 +12283,25 @@ function feedMember(filter) {
|
|
|
12590
12283
|
function conversationFeedMembershipFilter(status, filter) {
|
|
12591
12284
|
if (!filter) return status === "archived" ? sql`false` : void 0;
|
|
12592
12285
|
const member = feedMember(filter);
|
|
12593
|
-
return and(conversationIsMemberRoot(member),
|
|
12286
|
+
return and(conversationIsMemberRoot(member), status === "archived" ? isNotNull(juniorConversations.archivedAt) : status === "all" ? void 0 : and(isNull(juniorConversations.archivedAt), conversationIsNotUnsubscribedRoot(member)));
|
|
12594
12287
|
}
|
|
12595
12288
|
/**
|
|
12596
|
-
* Keep
|
|
12597
|
-
* link a child conversation, so linked ids resolve to their
|
|
12598
|
-
* roots stay visible only to
|
|
12289
|
+
* Keep top-level conversations linked to one code repository. A code change
|
|
12290
|
+
* can link a child conversation, so linked ids resolve to their ancestors,
|
|
12291
|
+
* and the list keeps the top-level one. Private roots stay visible only to
|
|
12292
|
+
* their members.
|
|
12599
12293
|
*/
|
|
12600
12294
|
function conversationCodeRepositoryFilter(repositoryId, viewerUserId) {
|
|
12601
|
-
return and(sql`${juniorConversations.conversationId} IN (
|
|
12602
|
-
SELECT coalesce(linked.root_conversation_id, linked.conversation_id)
|
|
12603
|
-
FROM ${juniorConversations} AS linked
|
|
12604
|
-
WHERE linked.conversation_id IN (
|
|
12605
|
-
SELECT unnest(${juniorCodeChanges.conversationIds})
|
|
12295
|
+
return and(sql`${juniorConversations.conversationId} IN ${conversationAncestorsOrSelf(sql`SELECT unnest(${juniorCodeChanges.conversationIds})
|
|
12606
12296
|
FROM ${juniorCodeChanges}
|
|
12607
|
-
WHERE ${juniorCodeChanges.repositoryId} = ${repositoryId}
|
|
12608
|
-
)
|
|
12609
|
-
)`, rootVisibleToViewer(viewerUserId));
|
|
12297
|
+
WHERE ${juniorCodeChanges.repositoryId} = ${repositoryId}`)}`, rootVisibleToViewer(viewerUserId));
|
|
12610
12298
|
}
|
|
12611
12299
|
/**
|
|
12612
|
-
* Keep the
|
|
12613
|
-
* private Space shows its
|
|
12300
|
+
* Keep the Lead's children in one Space with the status that the viewer may
|
|
12301
|
+
* find. A private Space shows its work only to its members.
|
|
12614
12302
|
*/
|
|
12615
12303
|
function conversationSpaceFilter(spaceId, status, viewerUserId) {
|
|
12616
|
-
return and(
|
|
12304
|
+
return and(inArray(juniorConversations.parentConversationId, spaceLeadIds(spaceId)), status === "archived" ? isNotNull(juniorConversations.archivedAt) : status === "active" ? isNull(juniorConversations.archivedAt) : void 0, rootVisibleToViewer(viewerUserId));
|
|
12617
12305
|
}
|
|
12618
12306
|
async function conversationRows(db, { codeRepository, conversationIds, cursor, filter, include = [], includePrivateMatches = false, limit, pinnedForUserId, query, space, status, waitingForUserId }) {
|
|
12619
12307
|
const rows = db.select({
|
|
@@ -12625,19 +12313,18 @@ async function conversationRows(db, { codeRepository, conversationIds, cursor, f
|
|
|
12625
12313
|
links: include.includes("links") ? feedLinksSql(db) : sql`null`,
|
|
12626
12314
|
media: include.includes("media") ? feedMediaSql(db) : sql`null`,
|
|
12627
12315
|
viewerAnswer: filter?.kind === "viewer" ? feedViewerAnswerSql(db, filter.userId) : sql`null`
|
|
12628
|
-
}).from(juniorConversations).leftJoin(juniorDestinations, conversationRecordJoins.location).leftJoin(juniorIdentities, conversationRecordJoins.identity).leftJoin(juniorUsers, conversationRecordJoins.user).where(and(
|
|
12316
|
+
}).from(juniorConversations).leftJoin(juniorDestinations, conversationRecordJoins.location).leftJoin(juniorIdentities, conversationRecordJoins.identity).leftJoin(juniorUsers, conversationRecordJoins.user).where(and(space ? conversationSpaceFilter(space.id, status, space.viewerUserId) : and(listedConversation(), conversationFeedMembershipFilter(status, filter)), conversationIds ? inArray(juniorConversations.conversationId, conversationIds) : void 0, waitingForUserId ? inArray(juniorConversations.conversationId, waitingConversationIdsQuery(db, waitingForUserId)) : void 0, pinnedForUserId ? pinnedForUserId.pinned ? conversationPinnedForUser(pinnedForUserId.userId) : not(conversationPinnedForUser(pinnedForUserId.userId)) : void 0, cursor ? sql`(${juniorConversations.lastActivityAt} < ${cursor.at}::timestamptz or (${juniorConversations.lastActivityAt} = ${cursor.at}::timestamptz and ${juniorConversations.conversationId} > ${cursor.conversationId}))` : void 0, codeRepository ? conversationCodeRepositoryFilter(codeRepository.id, codeRepository.viewerUserId) : void 0, query ? or(sql`strpos(lower(coalesce(${juniorConversations.title}, '')), ${query}) > 0`, and(includePrivateMatches ? void 0 : isPublicConversation(juniorConversations), sql`${conversationSearchVector} @@ websearch_to_tsquery('english', ${query})`), annotationMatch(db, query, includePrivateMatches)) : void 0)).orderBy(desc(juniorConversations.lastActivityAt), asc(juniorConversations.conversationId)).$dynamic();
|
|
12629
12317
|
return limit === void 0 ? rows : rows.limit(limit);
|
|
12630
12318
|
}
|
|
12631
|
-
const searchAnnotated = alias(juniorConversations, "search_annotated");
|
|
12632
12319
|
/**
|
|
12633
|
-
* Match a
|
|
12634
|
-
* title, such as `getsentry/roach#12`. The feed shows the
|
|
12635
|
-
* the whole tree, so search reads the same rows. Private
|
|
12636
|
-
* only where the feed shows them.
|
|
12320
|
+
* Match a top-level Conversation whose tree has an Annotation with the text
|
|
12321
|
+
* in its label or title, such as `getsentry/roach#12`. The feed shows the
|
|
12322
|
+
* annotations of the whole tree, so search reads the same rows. Private
|
|
12323
|
+
* annotations match only where the feed shows them.
|
|
12637
12324
|
*/
|
|
12638
12325
|
function annotationMatch(db, query, includePrivate) {
|
|
12639
12326
|
const annotation = juniorConversationAnnotations.annotation;
|
|
12640
|
-
return
|
|
12327
|
+
return and(includePrivate ? void 0 : isPublicConversation(juniorConversations), sql`${juniorConversations.conversationId} IN ${conversationAncestorsOrSelf(sql`${db.select({ conversationId: juniorConversationAnnotations.conversationId }).from(juniorConversationAnnotations).where(sql`strpos(lower(concat_ws(' ', ${annotation}->>'label', ${annotation}->>'title')), ${query}) > 0`)}`)}`);
|
|
12641
12328
|
}
|
|
12642
12329
|
/**
|
|
12643
12330
|
* Feed rows show last activity only as an age in whole minutes. A running
|
|
@@ -12687,6 +12374,7 @@ function conversationFeedVersionQuery(db, userId) {
|
|
|
12687
12374
|
then concat('active:', ${ownedItemsVersion(row.conversationId)})
|
|
12688
12375
|
else ${row.detailVersion}::text
|
|
12689
12376
|
end`;
|
|
12377
|
+
const feedRowTreeRoot = sql`coalesce(${juniorConversations.rootConversationId}, ${conversationId})`;
|
|
12690
12378
|
const child = sql`${feedTree.conversationId} <> ${conversationId}`;
|
|
12691
12379
|
const active = conversationIsActiveSql(feedTree);
|
|
12692
12380
|
const tree = db.select({ version: sql`concat_ws(':',
|
|
@@ -12701,8 +12389,8 @@ function conversationFeedVersionQuery(db, userId) {
|
|
|
12701
12389
|
where ${child} and ${active} and ${feedTree.kind} = 'thread'
|
|
12702
12390
|
)),
|
|
12703
12391
|
count(*) filter (where ${hasUnexpiredAuthorizationRequest(feedTree.conversationId)})
|
|
12704
|
-
)` }).from(feedTree).where(or(eq(feedTree.conversationId, conversationId), eq(feedTree.rootConversationId,
|
|
12705
|
-
const annotations = db.select({ version: sql`concat_ws(':', count(*), max(${juniorConversationAnnotations.updatedAt}))` }).from(juniorConversationAnnotations).innerJoin(feedAnnotated, eq(feedAnnotated.conversationId, juniorConversationAnnotations.conversationId)).where(eq(feedAnnotated.rootConversationId,
|
|
12392
|
+
)` }).from(feedTree).where(or(eq(feedTree.conversationId, conversationId), eq(feedTree.rootConversationId, feedRowTreeRoot)));
|
|
12393
|
+
const annotations = db.select({ version: sql`concat_ws(':', count(*), max(${juniorConversationAnnotations.updatedAt}))` }).from(juniorConversationAnnotations).innerJoin(feedAnnotated, eq(feedAnnotated.conversationId, juniorConversationAnnotations.conversationId)).where(eq(feedAnnotated.rootConversationId, feedRowTreeRoot));
|
|
12706
12394
|
const page = db.select({
|
|
12707
12395
|
conversationId,
|
|
12708
12396
|
channelName: juniorConversations.channelName,
|
|
@@ -12827,11 +12515,12 @@ async function readConversationFeedFromSql(options = {}) {
|
|
|
12827
12515
|
}
|
|
12828
12516
|
const conversations = rows.map((row) => conversationFromRecordRow(row));
|
|
12829
12517
|
const conversationIds = conversations.map((conversation) => conversation.conversationId);
|
|
12518
|
+
const rootConversationIds = [...new Set(conversations.map((conversation) => conversation.rootConversationId ?? conversation.conversationId))];
|
|
12830
12519
|
const conversationTrees = readConversationTrees(db, conversationIds);
|
|
12831
12520
|
const [accessRows, tree, participantsByRoot, annotationsByConversation, auxiliaryCostsByRoot, metricsByRoot, participantsByConversation, teamDomainByTeamId, { work: conversationWork, lastUserMessageAt: lastUserMessageAtByConversation }, activityPreviewByConversation, automationTitleByConversation, firstHumanMessageTextByConversation, treeStateByConversation, threadRecords, spaceRefs] = await Promise.all([
|
|
12832
12521
|
readConversationAccessRows(db, conversationIds),
|
|
12833
12522
|
conversationTrees,
|
|
12834
|
-
readMemberParticipants(db,
|
|
12523
|
+
readMemberParticipants(db, rootConversationIds, options.viewer ? { userId: options.viewer.id } : filter ? feedMember(filter) : void 0),
|
|
12835
12524
|
listConversationAnnotationsById(db, conversationIds),
|
|
12836
12525
|
readConversationAuxiliaryCostsFromSql(db, conversationIds),
|
|
12837
12526
|
readConversationTreeMetricsFromSql(db, conversationIds),
|
|
@@ -12845,11 +12534,10 @@ async function readConversationFeedFromSql(options = {}) {
|
|
|
12845
12534
|
readAutomationTitlesByConversationId(conversations),
|
|
12846
12535
|
readFirstHumanMessageTexts(db, conversations),
|
|
12847
12536
|
readConversationTreeStates(db, conversationIds, options.viewer?.id),
|
|
12848
|
-
readFeedThreadRecords(db, conversations.filter((conversation) => conversation.archivedAtMs === void 0).map(({ conversationId }) => conversationId)),
|
|
12537
|
+
readFeedThreadRecords(db, conversations.filter((conversation) => conversation.archivedAtMs === void 0).map(({ conversationId }) => conversationId), options.viewer?.id),
|
|
12849
12538
|
readSpaceRefs(db, conversations.flatMap(({ spaceId }) => spaceId ? [spaceId] : []))
|
|
12850
12539
|
]);
|
|
12851
|
-
const
|
|
12852
|
-
const accessByConversation = conversationAccessFromRows(accessRows, options.viewer ? new Set(participantsByRoot.keys()) : /* @__PURE__ */ new Set(), memberSpaceIds);
|
|
12540
|
+
const accessByConversation = conversationAccessFromRows(accessRows, options.viewer ? new Set(participantsByRoot.keys()) : /* @__PURE__ */ new Set());
|
|
12853
12541
|
const tenantByConversation = new Map(rows.flatMap((row) => {
|
|
12854
12542
|
const tenantId = conversationSlackTenantId({
|
|
12855
12543
|
provider: row.location?.provider,
|
|
@@ -12876,7 +12564,7 @@ async function readConversationFeedFromSql(options = {}) {
|
|
|
12876
12564
|
automationTitle: automationTitleByConversation.get(conversation.conversationId),
|
|
12877
12565
|
conversation,
|
|
12878
12566
|
access,
|
|
12879
|
-
space: conversation.spaceId &&
|
|
12567
|
+
space: conversation.spaceId && access?.canViewPrivateContent ? spaceRefs.get(conversation.spaceId) ?? null : null,
|
|
12880
12568
|
auxiliaryCosts: auxiliaryCosts?.total,
|
|
12881
12569
|
...childAgentTotals ? { childAgentTotals } : void 0,
|
|
12882
12570
|
durationMs: metrics?.durationMs ?? row.conversation.durationMs,
|
|
@@ -12940,4 +12628,4 @@ async function readConversationFeedFromSql(options = {}) {
|
|
|
12940
12628
|
async function readConversationFeed(options = {}) {
|
|
12941
12629
|
return readConversationFeedFromSql(options);
|
|
12942
12630
|
}
|
|
12943
|
-
export {
|
|
12631
|
+
export { reviewItemChange as $, setConversationSubscriptionOperation as A, createProductionSlackWebhookServices as At, mcpIdempotencyKeySchema as B, startProcessingReaction as Bt, cancelQueuedMessagesOperation as C, resolveObjectLinkNow as Ct, renameConversationOperation as D, isPublicAddress as Dt, pinConversationOperation as E, guardedFetch as Et, mcpAuthorizationSchema as F, normalizeIncomingSlackThreadId as Ft, readMcpPendingWork as G, resolvePersonLink as Gt, mcpMessageTextSchema as H, parseContent as Ht, mcpConversation as I, withNormalizedThreadId as It, resolveMentions as J, readFirstHumanMessageTexts as Jt, readMcpPendingWorkAfterSend as K, readConversationRecordFromSql as Kt, mcpConversationIdSchema as L, recordSkippedConversationMessage as Lt, reorderPinnedConversations as M, buildSlackInboundMessage as Mt, apiOperationHandler as N, clearSlackPendingReactions as Nt, setConversationAutoArchiveOperation as O, publicAddressLookup as Ot, mcpAcceptedMessageSchema as P, slackInboundMessageId as Pt, readInboxItemForUser as Q, mcpConversationSchema as R, createSlackWebApiStatusSender as Rt, archiveDoneConversationsOperation as S, readObjectLinkTypes as St, leaveConversationOperation as T, viewerCanViewPluginLink as Tt, mcpMessages as U, SubscribedReplyReason as Ut, mcpMessageSchema as V, stripLeadingBotMention as Vt, mcpPendingMessagesSchema as W, getThreadStopDecision as Wt, actOnInboxItem as X, IMAGE_WIDTHS as Xt, InboxItemActionError as Y, createViewerMcp as Yt, closeInboxItemsAnsweredByReply as Z, decodeImageId as Zt, createConversationForViewer as _, backfillCacheWarmingGaps as _t, resolveInboxItemSubjects as a, updateUserSettings as at, encodeConversationCursor as b, OBJECT_LINK_TTL_MS as bt, readConversationAuxiliaryCostsFromSql as c, listOpenAutomationQuestions as ct, conversationVersionsQuery as d, getScheduledAutomationDispatch as dt, createEventAppPublisher as et, readConversationDetailEtag as f, runInboxSnoozeTimers as ft, appendConversationMessageForViewer as g, startSavingsRefill as gt, readConversationEvents as h, runSavingsRefillSlice as ht, encodePageCursor as i, readUserSettings as it, stopConversationOperation as j, getProductionSlackAdapter as jt, setConversationSpaceOperation as k, createProductionConversationWorkOptions as kt, childAgentTotalsReport as l, createHeartbeatContext as lt, keepQuickQuestionForViewer as m, readSavingsRefill as mt, readConversationFeed as n, runAutoArchiveSweep as nt, readConversationDetail as o, automationReplyAttribution as ot, forkConversationForViewer as p, scheduleInboxSnoozeTimer as pt, requireConversationPendingMessages as q, conversationSummaryFromStoredConversation as qt, decodePageCursor as r, DEFAULT_USER_SETTINGS as rt, readConversationTreeStates as s, settleEventAutomationRuns as st, conversationFeedVersionQuery as t, ingestEventAutomations as tt, readConversationTreeMetricsFromSql as u, dispatchScheduledAutomation as ut, requireWebMessageConversation as v, GET as vt, conversationOperations as w, resolveObjectLinks as wt, archiveConversationOperation as x, readLinkObjectType as xt, decodeConversationCursor as y, readHealthReport as yt, mcpCursorSchema as z, bindMessageAuthorIdentityId as zt };
|