@sentry/junior 0.286.0 → 0.287.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapter-JQZaJ-B_.js → adapter-CL-HUKgd.js} +1 -1
- package/dist/{admin-Dm2bimJ-.js → admin-C9urXVfi.js} +2 -1
- package/dist/{agent-runner-DGCwOEyL.js → agent-runner-Bfnw551N.js} +644 -312
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +7 -7
- package/dist/api.d.ts +1 -1
- package/dist/api.js +36 -53
- package/dist/{app-BKq0JzWx.d.ts → app-DBY5TnfY.d.ts} +2 -2
- package/dist/app.d.ts +1 -1
- package/dist/app.js +62 -29
- package/dist/{assistant-reply-CAPafcUY.js → assistant-reply-u_PRYzuz.js} +1 -1
- package/dist/{automation-B-jJN_gM.js → automation-DksGNDRO.js} +3 -6
- package/dist/{background-compaction-queue-Btu2oab_.js → background-compaction-queue-CYI909P5.js} +3 -3
- package/dist/{briefs-UMeYehUe.js → briefs-DaXiMWzT.js} +6 -5
- package/dist/{catalog-runtime-Bym8GVdh.js → catalog-runtime-BCIuBe4d.js} +1 -1
- package/dist/cli/chat.js +14 -14
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-B0aAs7wC.js → config-CkHcUMN7.js} +580 -3
- package/dist/{connections-CQ7p0aNJ.js → connections-BnIj0wtx.js} +9 -9
- package/dist/{conversation-BusI2uzj.js → conversation-E7ZPJx2H.js} +8 -1
- package/dist/{conversation-pending-messages-DwehU0Fd.js → conversation-pending-messages-DVch6YQw.js} +2 -5
- package/dist/{conversation-privacy-Cd_nZZBM.js → conversation-privacy-DF1hW0ja.js} +1 -1
- package/dist/{credential-sync-DmiJi_At.js → credential-sync-CzMar9hq.js} +13 -13
- package/dist/{viewer-CH-ASQzh.js → db-DJ11eZqq.js} +37 -343
- package/dist/{db-C5zi4ecs.d.ts → db-YDKKDxlh.d.ts} +1 -1
- package/dist/{executor-Dipi2Ixl.js → executor-BY9TB31g.js} +11 -4
- package/dist/instrumentation.js +2 -2
- package/dist/{logging-CMFhLLj4.js → logging-BO5zU6Mt.js} +1 -1
- package/dist/{media-B-BpXo41.js → media-Cz1ZiV1U.js} +2 -2
- package/dist/{message-D1xLljUF.js → message-CsUbuEc8.js} +10 -10
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-DCAFIUQr.js → oauth-callback-server-hiDKK0_n.js} +2 -2
- package/dist/{projection-CoeMNxJ4.js → projection-CL_YWeGf.js} +82 -160
- package/dist/{prompt-C9OQEfan.js → prompt-BHOEQSmf.js} +182 -2
- package/dist/{registry-u-sFYtx_.js → registry-BriFLnaJ.js} +1 -1
- package/dist/{reporting-window-B4TwyuJo.js → reporting-window-B3Ze-Qnt.js} +4 -1
- package/dist/{resolve-DYqgL3Eo.js → resolve-Bt6GgAiA.js} +3 -3
- package/dist/{result-CescSwAw.js → result-Bo1TZu0Q.js} +8 -8
- package/dist/{runner-Cr67a8TB.js → runner-D3YeCQgt.js} +8 -8
- package/dist/{sandbox-egress-signals-DLOazy5W.js → sandbox-egress-signals-CcnSPP4S.js} +1 -1
- package/dist/{schema-BUSi3sgv.js → schema-BWE3RJEB.js} +17 -5
- package/dist/{schema-Ih60j59-.d.ts → schema-C6fsEwjo.d.ts} +46 -1
- package/dist/{service-account-CGEqz9wG.js → service-account-DiQQuuw7.js} +3 -3
- package/dist/{service-account-CsKxktLk.js → service-account-r6fl0b-9.js} +3 -3
- package/dist/{session-stop-CGz5DByb.js → session-stop-B2Nut40V.js} +18 -18
- package/dist/{skills-COCqf61f.js → skills-CD5aJdzg.js} +2 -2
- package/dist/spawn-CalgZQiu.js +79 -0
- package/dist/{stop-GyFZkHuQ.js → stop-kujZLbi0.js} +56 -240
- package/dist/{store-D0-8plWp.js → store-DdIEUL1q.js} +3 -3
- package/dist/{task-runner-xPuQmEot.js → task-runner-D_RDr2Hu.js} +12 -11
- package/dist/{turn-failure-response-BOviBdT-.js → turn-failure-response-B5nV1Er-.js} +16 -11
- package/dist/{validation-DZDKorGz.js → validation-K4pqwoVZ.js} +1 -1
- package/dist/{version-BTIz7fGi.js → version-DBvhk1X9.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/viewer-DrMmFUul.js +337 -0
- package/dist/{work-C75_IM5e.js → work-ljRoODGu.js} +30 -19
- package/dist/{worker-Dl47I729.js → worker-CYO1Q0Js.js} +5 -6
- package/migrations/0088_conversation_unsubscribe.sql +1 -0
- package/migrations/meta/0088_snapshot.json +4372 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +4 -4
- package/dist/config-B9f9Lqo5.js +0 -579
- package/dist/spawn-C8F_iXWO.js +0 -42
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
import { h as startSpan } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { $ as pauseLostWorkerTurn, $a as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as JUNIOR_VERSION } from "./version-BTIz7fGi.js";
|
|
2
|
+
import { $ as pauseLostWorkerTurn, $a as createPluginLogger, $i as postSlackMessage, A as isHumanConversationMessage, Ao as listConversationAnnotationsById, At as moveIdleConversationDestination, Bn as webActorUserIds, C as resolveConversationTitle, Cn as buildDeterministicTurnId, Co as readAttachmentVisionSummary, D as buildConversationContext, Dn as getThreadStopDecision, Dr as canReadReviewItem, En as getSubscribedReplyPreflightDecision, F as trimConversationMessages, Fo as createPluginCache, Gt as buildTurnErrorResponse, Hi as formatSlackLink, I as turnHasReply, In as isExperimentalFeatureEnabled, Ji as deleteSlackMessage, Ki as truncateStatusText, L as upsertConversationMessage, Lo as configValueSchema, M as markConversationMessage, Mr as reviewItemNeedsSomeone, N as normalizeConversationText, No as lookupSlackUser, Nr as reviewItemReaderForUser, O as estimateConversationMessagesTokens, Or as isOnlyAssignee, P as recordDeliveredAssistantMessage, Po as lookupSlackUserNames, Pt as releaseInboundMessage, Q as lostWorkerBeforeFirstSave, Rn as createUserTokenStore, Sn as buildDeterministicAssistantMessageId, Sr as takeReviewItem, T as fallbackShortTitle, Tn as decideSubscribedThreadReply, To as slackAttachmentsVersionQuery, Tr as canActOnReviewItem, U as AuthorizationFlowDisabledError, Vi as escapeSlackMrkdwnText, Wi as normalizeSlackStatusText, Wr as cancelSubscriptions, Y as wasPendingAuthStopped, Yt as persistWithRetry, Z as loadTurnCheckpoint, Zn as getPlugins, a as loadProjection, aa as SlackActionError, ao as conversationIsNotUnsubscribedRoot, at as listTurnSummaries, b as persistConversationMessages, bo as notInheritedByForkChild, ca as getHeaderString, ci as getDashboardConversationLink, co as viewerConversationMembership, d as recordAuthorizationCompleted, da as isDmChannel, dn as trimTrailingAssistantMessages, ea as removeReactionFromMessage, et as saveTurnCheckpoint, fa as normalizeSlackConversationId, fo as readLatestConversationBrief, fr as closeReviewItem, gr as getReviewItem, h as recordSubscribedReplyRoute, ho as readConversationEventPageAround, i as loadConversationProjection, io as conversationIsMemberRoot, it as getTurnRecord, j as latestConversationMessageSeq, k as getConversationMessageSlackTs, ko as listConversationAnnotations, la as getSlackClient, lo as viewerMarksFromParticipant, ma as withSlackRetries, mo as readConversationEventPageAfter, n as commitMessages, no as readConversationAccessFromSql, nt as completeTurnRecord, o as loadTurnProjection, oa as downloadPrivateSlackFile, oo as conversationPinnedForUser, ot as recordTurnSummary, po as readConversationEventPage, q as clearPendingAuth, qi as addReactionToMessage, ro as conversationHasParticipantUser, rt as failTurnRecord, so as conversationViewerMarks, t as commitAcceptedReply, to as createConversationAccessReader, tt as abandonTurnRecord, v as hydrateConversationMessages, vo as buildSentryConversationUrl, vr as listReplyActionItems, wo as recordSlackAttachment, xo as getSlackFileId, y as persistConversationMessageWindow, yr as listWaitingConversations, z as PluginCredentialFailureError, zo as piMessageFromHistoryItem } from "./projection-CL_YWeGf.js";
|
|
3
|
+
import { E as resolveGatewayModel, M as escapeXml, c as getSlackClientSecret, i as getChatConfig, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, v as normalizeSlackEmojiName, z as isProviderRetryError } from "./config-CkHcUMN7.js";
|
|
4
|
+
import { E as withSpan, G as toOptionalNumber, K as toOptionalString, S as setTags, T as withLogContext, W as isRecord, b as setSpanAttributes, f as logError, h as logWarn, m as logInfo, n as createChatSdkLogger, o as getActiveTraceContext, p as logException, s as getActiveTraceId, t as buildTurnFailureResponse, y as setSentryUser } from "./logging-BO5zU6Mt.js";
|
|
5
|
+
import { t as JUNIOR_VERSION } from "./version-DBvhk1X9.js";
|
|
7
6
|
import { f as parseSlackTeamId, h as parseSlackMessageTs, i as isActorUserId, n as createSlackActor, o as isUserActor, r as createSlackResumeActor, s as parseActorUserId, t as createActor, u as parseSlackChannelId } from "./actor-6jsm_v96.js";
|
|
8
|
-
import {
|
|
9
|
-
import { A as juniorConversations,
|
|
10
|
-
import { _ as instructionProvenanceFor, h as contextProvenance, i as isVisionImageMediaType, r as detectImageMediaType } from "./media-
|
|
11
|
-
import { d as actorLogContext, f as credentialContextForActor } from "./registry-
|
|
12
|
-
import { A as runWithSlackInstallation,
|
|
7
|
+
import { C as setFirstConversationLocation, D as resolveActorIdentityId, G as hasAgentTurnUsage, I as bindProviderConversation, K as resolveRootConversationId, L as parseSessionSource, O as saveActorAvatar, S as locationFromRow, V as addAgentTurnUsage, W as agentTurnUsageSchema, Y as requireSlackDestination, _ as setArchivedAt, a as getConversationStore, b as withConversationMutationLock, g as readConversationTrees, m as conversationAncestors, o as getDb, p as withConversationEventLock, q as createSlackDestination, r as getConversationEventStore, s as getSqlExecutor, v as loadConversationSlackTenantIds, x as conversationKindFromRow, z as nextDetailVersion } from "./db-DJ11eZqq.js";
|
|
8
|
+
import { A as juniorConversations, D as juniorCodeChanges, E as juniorConversationAnnotations, M as juniorUsers, N as juniorDestinations, _ as juniorConversationReadPositions, b as juniorConversationBriefs, j as juniorIdentities, l as juniorReviewItems, s as juniorReviewItemConversations, v as juniorConversationParticipants, w as juniorConversationEvents } from "./executor-BY9TB31g.js";
|
|
9
|
+
import { _ as instructionProvenanceFor, h as contextProvenance, i as isVisionImageMediaType, r as detectImageMediaType } from "./media-Cz1ZiV1U.js";
|
|
10
|
+
import { d as actorLogContext, f as credentialContextForActor } from "./registry-BriFLnaJ.js";
|
|
11
|
+
import { A as runWithSlackInstallation, B as listThreadReplies, Bt as getWebAuthorization, Ct as markConversationRead, Dt as stopChildAgentsBelow, Et as throwApiError, F as resolveSlackChannelIdFromThreadId, I as checkSlackChannelReadAccess, It as getTurnInputSpanAttributes, L as joinPublicChannelForRead, Lt as turnInputTelemetry, M as parseSlackThreadId, N as readSlackRawMessageContext, Nt as AgentRunError, Ot as stopChildAgentsOf, P as resolveSlackChannelIdFromMessage, Pt as executeTurn, R as getConversationInfo, Rt as withTurnSpan, S as createSlackReviewItemShow, St as conversationReadPositionQuery, V as resolveDestinationVisibility, X as readConversationSourceTask, Zt as RetryableDeliveryError, at as deliverReviewItemChange, b as renderAttachmentText, bt as readLastUserMessageAtByConversation, ct as acceptsWebMessages, dt as createAndEnqueueConversation, en as shouldEmitDevAgentTrace, ft as createConversationId, ht as decodeInputImages, i as buildAuthPauseResponse, jt as createConversationTurnWorker, lt as appendAndEnqueueWebMessage, mt as webActorFromUser, n as executeAgentRun, p as latestProgressStatus, pt as recordWebConversationActivity, t as createAgentRunner, x as renderBlockText, yt as storeAttachment } from "./agent-runner-Bfnw551N.js";
|
|
12
|
+
import { a as EVENT_SYSTEM_ACTOR, c as completeDecision, o as isEventConversationMessage, u as completeText } from "./prompt-BHOEQSmf.js";
|
|
13
13
|
import { r as acquireActiveLock } from "./locks-D-0h111u.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { a as persistAuthPauseTurnState, at as
|
|
18
|
-
import { n as getAssistantReplyText } from "./assistant-reply-
|
|
19
|
-
import { $ as withoutSavedSteeringMessages, B as maybePostAutomatedTurnLimitNotice, H as resolveSlackReplyTarget, K as recordFinishedTurnForAutomatedLimit, U as sendSlackReply, X as buildSteeringPiMessage, b as conversationSubtree, c as loadReviewItemInput, ct as deliversFinalText, d as getAuthPausedConversationTurnId, g as resolveMailboxTurnWork, l as savedInputInstruction, lt as finishedRunReply, o as skipInputAfterConversationStop, pt as runDispatchOutcome, r as markConversationsStopped, ut as postsRunNotices, x as conversationSubtreeColumns, y as legacyWebMailboxMetadataSchema } from "./session-stop-
|
|
20
|
-
import {
|
|
21
|
-
import { S as getTurnRequestDeadline, _ as getVercelConversationWorkQueue } from "./background-compaction-queue-
|
|
22
|
-
import { D as steerWebPendingMessages, O as stopConversationWork, T as requestConversationWork, _ as getConversationWorkState, a as cancelHumanFacingPendingMessages, g as getConversation, h as ensureConversationWake, r as appendAndEnqueueInboundMessage, s as claimInboundMessage } from "./store-
|
|
23
|
-
import { _ as markDispatchBlocked, _t as getPersistedThreadState, a as claimDispatchMailboxAppend, b as markDispatchRunning, bt as coerceThreadConversationState, c as getDispatchConversationId, d as getDispatchRecord, f as getDispatchTurnId, g as markDispatchAwaitingResume, gt as getPersistedSandboxState, ht as getLocationConfigurationService, m as isTerminalDispatchStatus, mt as resolveTurnSessionRouting, n as scheduleSessionCompletedPluginTasks, o as confirmDispatchMailboxAppend, pt as resolveConversationRouting, st as readAutomationTitlesByConversationId, u as getDispatchInputMessageId, v as markDispatchCompleted, vt as persistThreadRuntimeState, y as markDispatchFailed, yt as persistThreadStateById } from "./task-runner-
|
|
24
|
-
import { d as
|
|
25
|
-
import { r as endActiveAgentInvocations, s as resolveThreadTurnWork } from "./work-
|
|
26
|
-
import { a as withAgentInvocationResultActors, n as enqueueAgentInvocationResult, t as createChildConversationWorker } from "./result-
|
|
27
|
-
import { c as createPausedTurns, d as wakePausedTurn, f as getTurnAuthorization, l as getPausedTurnRequest } from "./connections-
|
|
28
|
-
import { t as bindMessageAgent } from "./message-
|
|
29
|
-
import { t as bindSpawnAgent } from "./spawn-
|
|
14
|
+
import { f as identityAvatarUrl, h as readUserAvatarUrls } from "./viewer-DrMmFUul.js";
|
|
15
|
+
import { a as setStateValues, i as getStateValues, r as getStateAdapter } from "./adapter-CL-HUKgd.js";
|
|
16
|
+
import { B as readMessageAttachments, d as conversationEventPageSchema, l as conversationDetailReportSchema, m as conversationFeedSchema } from "./conversation-E7ZPJx2H.js";
|
|
17
|
+
import { a as persistAuthPauseTurnState, at as getConversationTurnBoundaryError, b as getChildAgentLabel, c as getTurnUserSlackMessageTs, ct as isTurnInputDeferredError, d as loadThreadContextTrimFloor, dt as markTurnFailed, ft as startActiveTurn, i as completeAuthPauseTurn, it as TurnInputDeferredError, l as buildDeliveredTurnStatePatch, lt as markTurnClosed, m as loadPendingMessageCards, n as getAgentTurnDiagnosticsAttributes, nt as CooperativeTurnYieldError, o as getTurnUserMessage, ot as isCooperativeTurnYieldError, p as getTurnLifecycle, r as requireTurnFailureEventId, rt as TurnInputCommitLostError, s as getTurnUserReplyAttachmentContext, st as isTurnInputCommitLostError, t as finalizeFailedTurnReplyWithEvent, tt as ConversationTurnBoundaryError, u as buildTurnThreadContext, ut as markTurnCompleted } from "./turn-failure-response-B5nV1Er-.js";
|
|
18
|
+
import { n as getAssistantReplyText } from "./assistant-reply-u_PRYzuz.js";
|
|
19
|
+
import { $ as withoutSavedSteeringMessages, B as maybePostAutomatedTurnLimitNotice, H as resolveSlackReplyTarget, K as recordFinishedTurnForAutomatedLimit, U as sendSlackReply, X as buildSteeringPiMessage, b as conversationSubtree, c as loadReviewItemInput, ct as deliversFinalText, d as getAuthPausedConversationTurnId, g as resolveMailboxTurnWork, l as savedInputInstruction, lt as finishedRunReply, o as skipInputAfterConversationStop, pt as runDispatchOutcome, r as markConversationsStopped, ut as postsRunNotices, x as conversationSubtreeColumns, y as legacyWebMailboxMetadataSchema } from "./session-stop-B2Nut40V.js";
|
|
20
|
+
import { b as normalizeUserInputAnswer, p as webMessageId, y as isEmptyUserInputAnswer } from "./reporting-window-B3Ze-Qnt.js";
|
|
21
|
+
import { S as getTurnRequestDeadline, _ as getVercelConversationWorkQueue } from "./background-compaction-queue-CYI909P5.js";
|
|
22
|
+
import { D as steerWebPendingMessages, O as stopConversationWork, T as requestConversationWork, _ as getConversationWorkState, a as cancelHumanFacingPendingMessages, g as getConversation, h as ensureConversationWake, r as appendAndEnqueueInboundMessage, s as claimInboundMessage } from "./store-DdIEUL1q.js";
|
|
23
|
+
import { _ as markDispatchBlocked, _t as getPersistedThreadState, a as claimDispatchMailboxAppend, b as markDispatchRunning, bt as coerceThreadConversationState, c as getDispatchConversationId, d as getDispatchRecord, f as getDispatchTurnId, g as markDispatchAwaitingResume, gt as getPersistedSandboxState, ht as getLocationConfigurationService, m as isTerminalDispatchStatus, mt as resolveTurnSessionRouting, n as scheduleSessionCompletedPluginTasks, o as confirmDispatchMailboxAppend, pt as resolveConversationRouting, st as readAutomationTitlesByConversationId, u as getDispatchInputMessageId, v as markDispatchCompleted, vt as persistThreadRuntimeState, y as markDispatchFailed, yt as persistThreadStateById } from "./task-runner-D_RDr2Hu.js";
|
|
24
|
+
import { d as healthReportSchema, s as conversationPendingMessagesReportSchema } from "./conversation-pending-messages-DVch6YQw.js";
|
|
25
|
+
import { r as endActiveAgentInvocations, s as resolveThreadTurnWork } from "./work-ljRoODGu.js";
|
|
26
|
+
import { a as withAgentInvocationResultActors, n as enqueueAgentInvocationResult, t as createChildConversationWorker } from "./result-Bo1TZu0Q.js";
|
|
27
|
+
import { c as createPausedTurns, d as wakePausedTurn, f as getTurnAuthorization, l as getPausedTurnRequest } from "./connections-BnIj0wtx.js";
|
|
28
|
+
import { t as bindMessageAgent } from "./message-CsUbuEc8.js";
|
|
29
|
+
import { r as readConversationLineage, t as bindSpawnAgent } from "./spawn-CalgZQiu.js";
|
|
30
30
|
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
31
31
|
import * as z from "zod";
|
|
32
32
|
import { and, asc, desc, eq, gt, inArray, isNotNull, isNull, lte, max, ne, or, sql } from "drizzle-orm";
|
|
33
33
|
import { conversationSidebarAnnotationSchema, createSlackSource, objectTypeSchema } from "@sentry/junior-plugin-api";
|
|
34
34
|
import { alias } from "drizzle-orm/pg-core";
|
|
35
|
-
import { HTTPException } from "hono/http-exception";
|
|
36
35
|
import { Message, ThreadImpl, stringifyMarkdown } from "chat";
|
|
37
36
|
import { SlackFormatConverter, createSlackAdapter } from "@chat-adapter/slack";
|
|
38
37
|
// src/handlers/health.ts
|
|
@@ -382,83 +381,6 @@ async function listConversationWork(conversationIds) {
|
|
|
382
381
|
unfinishedIds: conversationIds.filter((conversationId) => unfinished.has(conversationId))
|
|
383
382
|
};
|
|
384
383
|
}
|
|
385
|
-
// src/api/http.ts
|
|
386
|
-
const NO_STORE_HEADERS = { "cache-control": "no-store" };
|
|
387
|
-
/** Build response init that keeps personalized API payloads out of shared caches. */
|
|
388
|
-
function noStoreInit(init) {
|
|
389
|
-
if (!init) return { headers: NO_STORE_HEADERS };
|
|
390
|
-
const headers = new Headers(init.headers);
|
|
391
|
-
if (!headers.has("cache-control")) headers.set("cache-control", "no-store");
|
|
392
|
-
return {
|
|
393
|
-
...init,
|
|
394
|
-
headers
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
/** Serialize a REST response only after it satisfies its declared schema. */
|
|
398
|
-
function jsonResponse(schema, value, init) {
|
|
399
|
-
return startSpan({
|
|
400
|
-
name: "Write API response",
|
|
401
|
-
op: "serialize"
|
|
402
|
-
}, (span) => {
|
|
403
|
-
const startedAt = performance.now();
|
|
404
|
-
const parsed = schema.parse(value);
|
|
405
|
-
const parsedAt = performance.now();
|
|
406
|
-
const body = JSON.stringify(parsed);
|
|
407
|
-
span.setAttributes({
|
|
408
|
-
"app.api.response.chars": body.length,
|
|
409
|
-
"app.api.response.json_stringify_ms": Math.round(performance.now() - parsedAt),
|
|
410
|
-
"app.api.response.schema_parse_ms": Math.round(parsedAt - startedAt)
|
|
411
|
-
});
|
|
412
|
-
const responseInit = noStoreInit(init);
|
|
413
|
-
const headers = new Headers(responseInit.headers);
|
|
414
|
-
if (!headers.has("content-type")) headers.set("content-type", "application/json");
|
|
415
|
-
return new Response(body, {
|
|
416
|
-
...responseInit,
|
|
417
|
-
headers
|
|
418
|
-
});
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
/** Return an empty personalized API response with no-store caching. */
|
|
422
|
-
function emptyResponse(status = 204) {
|
|
423
|
-
return new Response(null, noStoreInit({ status }));
|
|
424
|
-
}
|
|
425
|
-
/** Stop a request with Junior's stable JSON error contract. */
|
|
426
|
-
function throwApiError(status, message, cause) {
|
|
427
|
-
throw new HTTPException(status, {
|
|
428
|
-
...cause === void 0 ? void 0 : { cause },
|
|
429
|
-
message,
|
|
430
|
-
res: jsonResponse(apiErrorSchema, { error: message }, { status })
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
// src/api/conversations/user-message-activity.ts
|
|
434
|
-
/**
|
|
435
|
-
* The newest event of one type in the outer Conversation that matches the
|
|
436
|
-
* filter. It walks the message role or user message time index from the
|
|
437
|
-
* newest event. The user message index has only matching entries, so that
|
|
438
|
-
* read stops at the first one.
|
|
439
|
-
*/
|
|
440
|
-
function latestEventAt(db, type, filter) {
|
|
441
|
-
return db.select({ createdAt: juniorConversationEvents.createdAt }).from(juniorConversationEvents).where(and(eq(juniorConversationEvents.conversationId, juniorConversations.conversationId), eq(juniorConversationEvents.type, type), filter)).orderBy(desc(juniorConversationEvents.createdAt), desc(juniorConversationEvents.seq)).limit(1).as(`latest_${type}`);
|
|
442
|
-
}
|
|
443
|
-
/** Read the latest true user message time for each selected conversation. */
|
|
444
|
-
async function readLastUserMessageAtByConversation(db, conversationIds) {
|
|
445
|
-
if (conversationIds.length === 0) return /* @__PURE__ */ new Map();
|
|
446
|
-
const payload = juniorConversationEvents.payload;
|
|
447
|
-
const instruction = latestEventAt(db, "user_message", isUserInstruction(payload));
|
|
448
|
-
const authorKind = sql`(${db.select({ kind: juniorIdentities.kind }).from(juniorIdentities).where(eq(juniorIdentities.id, juniorConversationEvents.actorIdentityId))})`;
|
|
449
|
-
const message = latestEventAt(db, "message", sql`${payload}->>'role' = 'user' and ${authorKind} = 'user'`);
|
|
450
|
-
const rows = await db.select({
|
|
451
|
-
conversationId: juniorConversations.conversationId,
|
|
452
|
-
instructionAt: instruction.createdAt,
|
|
453
|
-
messageAt: message.createdAt
|
|
454
|
-
}).from(juniorConversations).leftJoinLateral(instruction, sql`true`).leftJoinLateral(message, sql`true`).where(inArray(juniorConversations.conversationId, conversationIds));
|
|
455
|
-
const result = /* @__PURE__ */ new Map();
|
|
456
|
-
for (const { conversationId, instructionAt, messageAt } of rows) {
|
|
457
|
-
const times = [instructionAt, messageAt].flatMap((at) => at ? [at.getTime()] : []);
|
|
458
|
-
if (times.length > 0) result.set(conversationId, new Date(Math.max(...times)).toISOString());
|
|
459
|
-
}
|
|
460
|
-
return result;
|
|
461
|
-
}
|
|
462
384
|
// src/api/conversations/auto-archive.ts
|
|
463
385
|
const HOUR_MS = 36e5;
|
|
464
386
|
/** Participant rows checked per page. A run reads pages until none remain. */
|
|
@@ -507,13 +429,14 @@ function notWaitingOnAnyone() {
|
|
|
507
429
|
return sql`not exists (${waiting})`;
|
|
508
430
|
}
|
|
509
431
|
/**
|
|
510
|
-
* True when no participant of the row's root pinned it or turned
|
|
432
|
+
* True when no subscribed participant of the row's root pinned it or turned
|
|
511
433
|
* auto-archive off for it. Archive applies to everyone, so one person's run
|
|
512
|
-
* must not undo another person's pin or manual restore.
|
|
434
|
+
* must not undo another person's pin or manual restore. A person who
|
|
435
|
+
* unsubscribed no longer keeps it.
|
|
513
436
|
*/
|
|
514
437
|
function noParticipantKeepsRoot() {
|
|
515
438
|
const keeper = alias(juniorConversationParticipants, "keeping_participant");
|
|
516
|
-
const keeping = getDb().select({ userId: keeper.userId }).from(keeper).where(and(eq(keeper.rootConversationId, juniorConversationParticipants.rootConversationId), or(isNotNull(keeper.pinnedAt), eq(keeper.autoArchive, false))));
|
|
439
|
+
const keeping = getDb().select({ userId: keeper.userId }).from(keeper).where(and(eq(keeper.rootConversationId, juniorConversationParticipants.rootConversationId), isNull(keeper.unsubscribedAt), or(isNotNull(keeper.pinnedAt), eq(keeper.autoArchive, false))));
|
|
517
440
|
return sql`not exists (${keeping})`;
|
|
518
441
|
}
|
|
519
442
|
/** True when the participant row's root is not archived. */
|
|
@@ -528,7 +451,7 @@ function rootIsUnarchived() {
|
|
|
528
451
|
* changed setting wins over a stale read.
|
|
529
452
|
*/
|
|
530
453
|
function archivableRow(run) {
|
|
531
|
-
return and(eq(juniorConversationParticipants.userId, run.userId), rootIsUnarchived(), noParticipantKeepsRoot(), lte(juniorConversationParticipants.lastMessageAt, runCutoff(run)), runOptsIn(run), run.kind === "scheduled" ? sql`${juniorUsers.autoArchiveGraceHours} <= ${run.graceHours}` : void 0, treeIsQuiet(runCutoff(run)), notWaitingOnAnyone());
|
|
454
|
+
return and(eq(juniorConversationParticipants.userId, run.userId), isNull(juniorConversationParticipants.unsubscribedAt), rootIsUnarchived(), noParticipantKeepsRoot(), lte(juniorConversationParticipants.lastMessageAt, runCutoff(run)), runOptsIn(run), run.kind === "scheduled" ? sql`${juniorUsers.autoArchiveGraceHours} <= ${run.graceHours}` : void 0, treeIsQuiet(runCutoff(run)), notWaitingOnAnyone());
|
|
532
455
|
}
|
|
533
456
|
/**
|
|
534
457
|
* One page of the user's participant rows on unarchived roots that may be
|
|
@@ -727,7 +650,8 @@ async function matchReplyToReviewItems(args) {
|
|
|
727
650
|
modelId: botConfig.decisionModelId
|
|
728
651
|
},
|
|
729
652
|
modelId: botConfig.decisionModelId,
|
|
730
|
-
|
|
653
|
+
operation: "review_item_reply_match",
|
|
654
|
+
cost: { conversationId: args.conversationId },
|
|
731
655
|
questions: Object.fromEntries(args.items.map((item, index) => [keys[index], matchQuestion(item)])),
|
|
732
656
|
signal: AbortSignal.timeout(MATCH_TIMEOUT_MS),
|
|
733
657
|
state: [
|
|
@@ -1098,6 +1022,9 @@ function buildAttachmentResolutionFailurePromptText(args) {
|
|
|
1098
1022
|
"</attachment>"
|
|
1099
1023
|
].join("\n");
|
|
1100
1024
|
}
|
|
1025
|
+
function visionCost(conversationId) {
|
|
1026
|
+
return conversationId ? { conversationId } : { owner: "none" };
|
|
1027
|
+
}
|
|
1101
1028
|
async function summarizeImageWithVision(args) {
|
|
1102
1029
|
const visionModelId = botConfig.visionModelId;
|
|
1103
1030
|
if (!visionModelId) return;
|
|
@@ -1105,7 +1032,8 @@ async function summarizeImageWithVision(args) {
|
|
|
1105
1032
|
modelId: visionModelId,
|
|
1106
1033
|
temperature: 0,
|
|
1107
1034
|
maxTokens: args.maxTokens,
|
|
1108
|
-
|
|
1035
|
+
operation: "vision_summary",
|
|
1036
|
+
cost: args.cost,
|
|
1109
1037
|
messages: [{
|
|
1110
1038
|
role: "user",
|
|
1111
1039
|
content: [{
|
|
@@ -1252,6 +1180,7 @@ async function resolveUserAttachmentsWithDeps(attachments, context, deps) {
|
|
|
1252
1180
|
try {
|
|
1253
1181
|
const summary = await summarizeImageWithVision({
|
|
1254
1182
|
completeText: deps.completeText,
|
|
1183
|
+
cost: visionCost(context.conversationId),
|
|
1255
1184
|
imageData: data,
|
|
1256
1185
|
mimeType: mediaType,
|
|
1257
1186
|
maxTokens: 220,
|
|
@@ -1315,6 +1244,7 @@ async function summarizeConversationImage(args, deps) {
|
|
|
1315
1244
|
try {
|
|
1316
1245
|
const summary = await summarizeImageWithVision({
|
|
1317
1246
|
completeText: deps.completeText,
|
|
1247
|
+
cost: visionCost(args.context.conversationId),
|
|
1318
1248
|
imageData: args.imageData,
|
|
1319
1249
|
mimeType: args.mimeType,
|
|
1320
1250
|
maxTokens: 220,
|
|
@@ -4936,6 +4866,7 @@ function createPrepareTurnState(deps) {
|
|
|
4936
4866
|
const shouldHydrateVisionContext = !conversation.vision.backfillCompletedAtMs || messageHasPotentialImageAttachment || hasPendingImageHydration(conversation);
|
|
4937
4867
|
if (isVisionEnabled() && shouldHydrateVisionContext) {
|
|
4938
4868
|
await deps.hydrateConversationVisionContext(conversation, {
|
|
4869
|
+
conversationId,
|
|
4939
4870
|
threadId: args.context.threadId,
|
|
4940
4871
|
channelId: args.context.channelId,
|
|
4941
4872
|
actorId: args.context.actorId,
|
|
@@ -6445,129 +6376,6 @@ function createProductionConversationWorkOptions(options) {
|
|
|
6445
6376
|
waitUntil: options.waitUntil
|
|
6446
6377
|
});
|
|
6447
6378
|
}
|
|
6448
|
-
// src/api/conversations/read-position.ts
|
|
6449
|
-
/**
|
|
6450
|
-
* Read how far the viewer has read one Conversation, if they have read it.
|
|
6451
|
-
*
|
|
6452
|
-
* The viewer saw every Message up to one they wrote, also one sent from
|
|
6453
|
-
* Slack, so the position is at least their latest Message.
|
|
6454
|
-
*/
|
|
6455
|
-
async function readConversationReadPosition(viewer, conversationId) {
|
|
6456
|
-
const [row] = await conversationReadPositionQuery(viewer, conversationId);
|
|
6457
|
-
return row;
|
|
6458
|
-
}
|
|
6459
|
-
/** Select the viewer's read position, so other reads can embed it. */
|
|
6460
|
-
function conversationReadPositionQuery(viewer, conversationId) {
|
|
6461
|
-
return getDb().select({ lastReadSeq: sql`greatest(${juniorConversationReadPositions.lastReadSeq}, (${latestViewerMessageSeq(viewer, conversationId)}))` }).from(juniorConversationReadPositions).where(and(eq(juniorConversationReadPositions.userId, viewer.id), eq(juniorConversationReadPositions.conversationId, conversationId))).limit(1);
|
|
6462
|
-
}
|
|
6463
|
-
/** The seq of the latest Message that one of the viewer's Identities wrote. */
|
|
6464
|
-
function latestViewerMessageSeq(viewer, conversationId) {
|
|
6465
|
-
return getDb().select({ seq: max(juniorConversationEvents.seq) }).from(juniorConversationEvents).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversationEvents.actorIdentityId)).where(and(eq(juniorConversationEvents.conversationId, conversationId), eq(juniorConversationEvents.type, "message"), eq(juniorIdentities.userId, viewer.id)));
|
|
6466
|
-
}
|
|
6467
|
-
/**
|
|
6468
|
-
* Move the viewer's read position forward.
|
|
6469
|
-
*
|
|
6470
|
-
* The stored value never goes back, so devices can report in any order. A
|
|
6471
|
-
* value past the last event is cut to the last event, so a bad client cannot
|
|
6472
|
-
* hide messages that arrive later.
|
|
6473
|
-
*/
|
|
6474
|
-
async function markConversationRead(viewer, conversationId, body) {
|
|
6475
|
-
const db = getDb();
|
|
6476
|
-
const [conversation] = await db.select({ lastSeq: max(juniorConversationEvents.seq) }).from(juniorConversations).leftJoin(juniorConversationEvents, eq(juniorConversationEvents.conversationId, juniorConversations.conversationId)).where(eq(juniorConversations.conversationId, conversationId)).groupBy(juniorConversations.conversationId);
|
|
6477
|
-
if (!conversation) throwApiError(404, "Conversation not found.");
|
|
6478
|
-
await db.insert(juniorConversationReadPositions).values({
|
|
6479
|
-
conversationId,
|
|
6480
|
-
lastReadSeq: Math.min(body.lastReadSeq, conversation.lastSeq ?? 0),
|
|
6481
|
-
updatedAt: /* @__PURE__ */ new Date(),
|
|
6482
|
-
userId: viewer.id
|
|
6483
|
-
}).onConflictDoUpdate({
|
|
6484
|
-
target: [juniorConversationReadPositions.userId, juniorConversationReadPositions.conversationId],
|
|
6485
|
-
set: {
|
|
6486
|
-
lastReadSeq: sql`greatest(${juniorConversationReadPositions.lastReadSeq}, excluded.last_read_seq)`,
|
|
6487
|
-
updatedAt: sql`excluded.updated_at`
|
|
6488
|
-
}
|
|
6489
|
-
});
|
|
6490
|
-
return await readConversationReadPosition(viewer, conversationId);
|
|
6491
|
-
}
|
|
6492
|
-
// src/api/conversations/archive.ts
|
|
6493
|
-
/**
|
|
6494
|
-
* Archive or restore one Conversation, root or child, for everyone. Archive
|
|
6495
|
-
* refuses while any descendant is unarchived, unless `applyToChildren`
|
|
6496
|
-
* archives them too. Restore changes only this Conversation unless
|
|
6497
|
-
* `applyToChildren` also restores the descendants archived with it, and it
|
|
6498
|
-
* refuses while an ancestor is archived.
|
|
6499
|
-
*/
|
|
6500
|
-
async function setArchive(args) {
|
|
6501
|
-
const executor = getSqlExecutor();
|
|
6502
|
-
return await executor.transaction(async () => {
|
|
6503
|
-
const db = executor.db();
|
|
6504
|
-
const [target] = await db.select({
|
|
6505
|
-
lastActivityAt: juniorConversations.lastActivityAt,
|
|
6506
|
-
rootConversationId: juniorConversations.rootConversationId
|
|
6507
|
-
}).from(juniorConversations).where(eq(juniorConversations.conversationId, args.conversationId)).limit(1).for("update");
|
|
6508
|
-
if (!target) return { status: "missing" };
|
|
6509
|
-
if (args.archived && target.lastActivityAt.getTime() !== Date.parse(args.lastSeenAt)) return { status: "conflict" };
|
|
6510
|
-
const rootConversationId = target.rootConversationId ?? args.conversationId;
|
|
6511
|
-
const tree = await readConversationTrees(db, [rootConversationId]);
|
|
6512
|
-
const descendants = conversationDescendants(tree, args.conversationId);
|
|
6513
|
-
if (args.archived) {
|
|
6514
|
-
const unarchived = descendants.filter((node) => !node.archivedAt);
|
|
6515
|
-
if (unarchived.length > 0 && !args.applyToChildren) return {
|
|
6516
|
-
status: "unarchived_children",
|
|
6517
|
-
unarchivedChildCount: unarchived.length
|
|
6518
|
-
};
|
|
6519
|
-
const archivedAt = /* @__PURE__ */ new Date();
|
|
6520
|
-
await setArchivedAt(db, [args.conversationId, ...unarchived.map((node) => node.conversationId)], archivedAt);
|
|
6521
|
-
return {
|
|
6522
|
-
archivedAt: archivedAt.toISOString(),
|
|
6523
|
-
status: "updated"
|
|
6524
|
-
};
|
|
6525
|
-
}
|
|
6526
|
-
const archivedAncestor = conversationAncestors(tree, args.conversationId).filter((node) => node.archivedAt).at(-1);
|
|
6527
|
-
if (archivedAncestor) return {
|
|
6528
|
-
archivedAncestorId: archivedAncestor.conversationId,
|
|
6529
|
-
status: "archived_ancestor"
|
|
6530
|
-
};
|
|
6531
|
-
const archivedAt = tree.get(args.conversationId)?.archivedAt?.getTime();
|
|
6532
|
-
await setArchivedAt(db, [args.conversationId, ...args.applyToChildren && archivedAt !== void 0 ? descendants.filter((node) => node.archivedAt?.getTime() === archivedAt).map((node) => node.conversationId) : []], null);
|
|
6533
|
-
if (args.conversationId === rootConversationId) await db.insert(juniorConversationParticipants).values({
|
|
6534
|
-
autoArchive: false,
|
|
6535
|
-
lastMessageAt: target.lastActivityAt,
|
|
6536
|
-
rootConversationId,
|
|
6537
|
-
userId: args.userId
|
|
6538
|
-
}).onConflictDoUpdate({
|
|
6539
|
-
target: [juniorConversationParticipants.userId, juniorConversationParticipants.rootConversationId],
|
|
6540
|
-
set: { autoArchive: false }
|
|
6541
|
-
});
|
|
6542
|
-
return {
|
|
6543
|
-
archivedAt: null,
|
|
6544
|
-
status: "updated"
|
|
6545
|
-
};
|
|
6546
|
-
});
|
|
6547
|
-
}
|
|
6548
|
-
/**
|
|
6549
|
-
* Archive or restore one Conversation for everyone. Only a participant may
|
|
6550
|
-
* do it. The rules are those of `setArchive`.
|
|
6551
|
-
*/
|
|
6552
|
-
async function archiveConversation(viewer, conversationId, body) {
|
|
6553
|
-
if (!(await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId)?.isParticipant) throwApiError(404, "Conversation not found.");
|
|
6554
|
-
const result = await setArchive({
|
|
6555
|
-
applyToChildren: body.applyToChildren ?? false,
|
|
6556
|
-
archived: body.archived,
|
|
6557
|
-
conversationId,
|
|
6558
|
-
lastSeenAt: body.lastSeenAt,
|
|
6559
|
-
userId: viewer.id
|
|
6560
|
-
});
|
|
6561
|
-
switch (result.status) {
|
|
6562
|
-
case "updated":
|
|
6563
|
-
if (body.archived) await markConversationRead(viewer, conversationId, { lastReadSeq: Number.MAX_SAFE_INTEGER });
|
|
6564
|
-
return { archivedAt: result.archivedAt };
|
|
6565
|
-
case "missing": throwApiError(404, "Conversation not found.");
|
|
6566
|
-
case "conflict": throwApiError(409, "Conversation received new activity.");
|
|
6567
|
-
case "unarchived_children": throwApiError(409, result.unarchivedChildCount === 1 ? "1 child conversation is not archived. Pass applyToChildren to archive it too." : `${result.unarchivedChildCount} child conversations are not archived. Pass applyToChildren to archive them too.`);
|
|
6568
|
-
case "archived_ancestor": throwApiError(409, `Conversation ${result.archivedAncestorId} above this one is archived. Restore it first.`);
|
|
6569
|
-
}
|
|
6570
|
-
}
|
|
6571
6379
|
// src/api/mentions.ts
|
|
6572
6380
|
const SLACK_USER_MENTION_RE = /<@([UW][A-Z0-9]+)(?:\|[^<>]*)?>/g;
|
|
6573
6381
|
function mentionedSlackUserIds(texts) {
|
|
@@ -8168,7 +7976,7 @@ const versionUser = alias(juniorUsers, "version_user");
|
|
|
8168
7976
|
*/
|
|
8169
7977
|
function viewerStateVersion(db, conversationId, viewerId) {
|
|
8170
7978
|
const root = db.select({ id: sql`coalesce(${versionConversation.rootConversationId}, ${versionConversation.conversationId})` }).from(versionConversation).where(eq(versionConversation.conversationId, conversationId));
|
|
8171
|
-
const participant = db.select({ state: sql`row(${versionParticipant.pinnedAt}, ${versionParticipant.pinPosition}, ${versionParticipant.autoArchive})::text` }).from(versionParticipant).where(and(eq(versionParticipant.userId, viewerId), eq(versionParticipant.rootConversationId, sql`(${root})`)));
|
|
7979
|
+
const participant = db.select({ state: sql`row(${versionParticipant.pinnedAt}, ${versionParticipant.pinPosition}, ${versionParticipant.autoArchive}, ${versionParticipant.unsubscribedAt})::text` }).from(versionParticipant).where(and(eq(versionParticipant.userId, viewerId), eq(versionParticipant.rootConversationId, sql`(${root})`)));
|
|
8172
7980
|
const autoArchiveDefault = db.select({ value: versionUser.autoArchiveDefault }).from(versionUser).where(eq(versionUser.id, viewerId));
|
|
8173
7981
|
const forks = db.select({ ids: sql`string_agg(${versionFork.conversationId}, ',' order by ${versionFork.conversationId})` }).from(versionFork).where(and(eq(versionFork.forkedFromConversationId, conversationId), isNull(versionFork.quickQuestionAt)));
|
|
8174
7982
|
return sql`md5(concat_ws('|',
|
|
@@ -8212,6 +8020,7 @@ async function readDetailStateRow(conversationId, viewer) {
|
|
|
8212
8020
|
pinnedAt: juniorConversationParticipants.pinnedAt,
|
|
8213
8021
|
pinPosition: juniorConversationParticipants.pinPosition,
|
|
8214
8022
|
rootConversationId: sql`${rootConversationId}`,
|
|
8023
|
+
unsubscribedAt: juniorConversationParticipants.unsubscribedAt,
|
|
8215
8024
|
version: sql`(${conversationVersionQuery(db, conversationId, viewer?.id)})`
|
|
8216
8025
|
}).from(detailConversation).leftJoin(forkSource, eq(forkSource.conversationId, detailConversation.forkedFromConversationId)).leftJoin(juniorConversationParticipants, viewerParticipant).leftJoin(juniorUsers, viewer ? eq(juniorUsers.id, viewer.id) : sql`false`).where(eq(detailConversation.conversationId, conversationId));
|
|
8217
8026
|
return row;
|
|
@@ -8249,6 +8058,7 @@ async function readDetailState(conversationId, viewer, readAccess) {
|
|
|
8249
8058
|
...viewer ? { autoArchive: row?.autoArchive ?? row?.autoArchiveDefault ?? false } : void 0,
|
|
8250
8059
|
forks,
|
|
8251
8060
|
...row?.lastReadSeq != null ? { readPosition: { lastReadSeq: row.lastReadSeq } } : void 0,
|
|
8061
|
+
...viewer ? { subscribed: !row?.unsubscribedAt } : void 0,
|
|
8252
8062
|
transcriptVersion,
|
|
8253
8063
|
...viewer && row ? { unreadReply: unreadIds.has(row.rootConversationId) } : void 0,
|
|
8254
8064
|
...viewerMarks ? { viewerMarks } : void 0
|
|
@@ -8285,6 +8095,7 @@ async function readConversationDetailEtag(conversationId, options) {
|
|
|
8285
8095
|
forks: state.forks,
|
|
8286
8096
|
junior: JUNIOR_VERSION,
|
|
8287
8097
|
limit: options.limit ?? null,
|
|
8098
|
+
subscribed: state.subscribed ?? null,
|
|
8288
8099
|
version,
|
|
8289
8100
|
unreadReply: state.unreadReply ?? false,
|
|
8290
8101
|
viewerMarks: state.viewerMarks ?? null
|
|
@@ -8973,6 +8784,7 @@ async function readConversationDetailFromSql(conversationId, options) {
|
|
|
8973
8784
|
...state.forks,
|
|
8974
8785
|
...state.agentTree ? { agentTree: state.agentTree } : void 0,
|
|
8975
8786
|
...report.isParticipant && state.autoArchive !== void 0 ? { autoArchive: state.autoArchive } : void 0,
|
|
8787
|
+
...report.isParticipant && state.subscribed !== void 0 ? { subscribed: state.subscribed } : void 0,
|
|
8976
8788
|
...canContinueInSlack(record.conversation, access) ? { canContinueInSlack: true } : void 0
|
|
8977
8789
|
};
|
|
8978
8790
|
}
|
|
@@ -9010,17 +8822,20 @@ async function readConversationDetail(conversationId, options = {}) {
|
|
|
9010
8822
|
*/
|
|
9011
8823
|
async function pinConversation(viewer, conversationId, body) {
|
|
9012
8824
|
if (!(await readConversationAccessFromSql(getDb(), [conversationId], viewer)).get(conversationId)?.isParticipant) throwApiError(404, "Conversation not found.");
|
|
9013
|
-
const
|
|
8825
|
+
const executor = getSqlExecutor();
|
|
8826
|
+
return await executor.transaction(() => setPin(executor.db(), viewer, conversationId, body.pinned));
|
|
8827
|
+
}
|
|
8828
|
+
async function setPin(db, viewer, conversationId, pinned) {
|
|
9014
8829
|
const [conversation] = await db.select({
|
|
9015
8830
|
archivedAt: juniorConversations.archivedAt,
|
|
9016
8831
|
kind: juniorConversations.kind,
|
|
9017
8832
|
lastActivityAt: juniorConversations.lastActivityAt,
|
|
9018
8833
|
parentConversationId: juniorConversations.parentConversationId,
|
|
9019
8834
|
rootConversationId: juniorConversations.rootConversationId
|
|
9020
|
-
}).from(juniorConversations).where(eq(juniorConversations.conversationId, conversationId)).limit(1);
|
|
8835
|
+
}).from(juniorConversations).where(eq(juniorConversations.conversationId, conversationId)).limit(1).for("no key update");
|
|
9021
8836
|
if (!conversation) throwApiError(404, "Conversation not found.");
|
|
9022
8837
|
if (conversationKindFromRow(conversation) !== "root") throwApiError(409, `A child conversation cannot be pinned or unpinned. It uses its root's pin: ${conversation.rootConversationId ?? conversation.parentConversationId}.`);
|
|
9023
|
-
if (!
|
|
8838
|
+
if (!pinned) {
|
|
9024
8839
|
await db.update(juniorConversationParticipants).set({
|
|
9025
8840
|
pinnedAt: null,
|
|
9026
8841
|
pinPosition: null
|
|
@@ -9038,7 +8853,8 @@ async function pinConversation(viewer, conversationId, body) {
|
|
|
9038
8853
|
target: [juniorConversationParticipants.userId, juniorConversationParticipants.rootConversationId],
|
|
9039
8854
|
set: {
|
|
9040
8855
|
pinnedAt,
|
|
9041
|
-
pinPosition: null
|
|
8856
|
+
pinPosition: null,
|
|
8857
|
+
unsubscribedAt: null
|
|
9042
8858
|
}
|
|
9043
8859
|
});
|
|
9044
8860
|
return { pinnedAt: pinnedAt.toISOString() };
|
|
@@ -9191,7 +9007,7 @@ function feedMember(filter) {
|
|
|
9191
9007
|
function conversationFeedMembershipFilter(status, filter) {
|
|
9192
9008
|
if (!filter) return status === "archived" ? sql`false` : void 0;
|
|
9193
9009
|
const member = feedMember(filter);
|
|
9194
|
-
return and(conversationIsMemberRoot(member), status === "archived" ? isNotNull(juniorConversations.archivedAt) : status === "all" ? void 0 : isNull(juniorConversations.archivedAt));
|
|
9010
|
+
return and(conversationIsMemberRoot(member), status === "archived" ? isNotNull(juniorConversations.archivedAt) : status === "all" ? void 0 : and(isNull(juniorConversations.archivedAt), conversationIsNotUnsubscribedRoot(member)));
|
|
9195
9011
|
}
|
|
9196
9012
|
/**
|
|
9197
9013
|
* Keep root conversations linked to one code repository. A code change can
|
|
@@ -9493,4 +9309,4 @@ function viewerWebMessages(messages, viewer) {
|
|
|
9493
9309
|
}] : [];
|
|
9494
9310
|
});
|
|
9495
9311
|
}
|
|
9496
|
-
export {
|
|
9312
|
+
export { readReviewItemForUser as $, createProductionConversationWorkOptions as A, clearSlackPendingReactions as B, createConversationForViewer as C, readConversationPendingMessages as D, cancelConversationPendingMessagesForViewer as E, isAllowedSignInEmail as F, createSlackWebApiStatusSender as G, stripLeadingBotMention as H, readEnvList as I, recordSkippedConversationMessage as J, stopConversation as K, resolveAllowedDomains as L, getProductionSlackAdapter as M, assertNoLegacyAllowedDomains as N, requireConversationPendingMessages as O, isAllowedDomain as P, closeReviewItemsAnsweredByReply as Q, startProcessingReaction as R, appendConversationMessageForViewer as S, encodeConversationCursor as T, normalizeIncomingSlackThreadId as U, slackInboundMessageId as V, withNormalizedThreadId as W, ReviewItemActionError as X, bindMessageAuthorIdentityId as Y, actOnReviewItem as Z, keepQuickQuestionForViewer as _, pinConversation as a, setConversationAutoArchive as at, readConversationRecordFromSql as b, continueConversationInSlackForViewer as c, enqueueAgentDispatch as ct, readConversationTreeMetricsFromSql as d, reviewItemChange as et, conversationVersionQuery as f, forkConversationForViewer as g, reportConversationRead as h, readConversationFeed as i, runAutoArchiveSweep as it, createProductionSlackWebhookServices as j, resolveMentions as k, readConversationAuxiliaryCostsFromSql as l, GET as lt, markConversationUnread as m, steerConversationPendingMessagesForViewer as n, archiveViewerDoneConversations as nt, reorderPinnedConversations as o, updateUserAutoArchiveSettings as ot, readConversationDetailEtag as p, parseContent as q, conversationFeedVersionQuery as r, readUserAutoArchiveSettings as rt, readConversationDetail as s, AGENT_DISPATCH_MAX_AGE_MS as st, stopConversationTurnForViewer as t, DEFAULT_AUTO_ARCHIVE_SETTINGS as tt, childAgentTotalsReport as u, readHealthReport as ut, readConversationEvents as v, decodeConversationCursor as w, readFirstHumanMessageTexts as x, conversationSummaryFromStoredConversation as y, buildSlackInboundMessage as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Bt as stopConversationWork$1, Ct as getConversationWorkState$1, Ft as removeActiveConversation$1, It as requestAnotherSlice$1, Lt as requestConversationWork$1, Mt as recordConversationRetry$1, Nt as releaseConversationWork$1, Ot as listActiveConversationIds$1, Pt as releaseInboundMessage, Rt as startConversationWork$1, St as getConversation$1, _t as clearExpiredConversationLease$1, bt as deadLetterAttempt$1, dt as appendInboundMessage, ft as beginConversationResume$1, gt as clearConsumedConversationWake$1, ht as claimInboundMessage$1, jt as recordAttemptFailure$1, kt as markConversationWorkEnqueued$1, lt as ackMessages$1, mt as checkInConversationWork$1, pt as cancelHumanFacingPendingMessages$1, ut as appendExclusiveInboundMessage, vt as completeConversationStop$1, xt as drainConversationMailbox$1, yt as completeConversationWork$1, zt as steerWebPendingMessages$1 } from "./projection-
|
|
2
|
-
import {
|
|
3
|
-
import "./background-compaction-queue-
|
|
1
|
+
import { Bt as stopConversationWork$1, Ct as getConversationWorkState$1, Ft as removeActiveConversation$1, It as requestAnotherSlice$1, Lt as requestConversationWork$1, Mt as recordConversationRetry$1, Nt as releaseConversationWork$1, Ot as listActiveConversationIds$1, Pt as releaseInboundMessage, Rt as startConversationWork$1, St as getConversation$1, _t as clearExpiredConversationLease$1, bt as deadLetterAttempt$1, dt as appendInboundMessage, ft as beginConversationResume$1, gt as clearConsumedConversationWake$1, ht as claimInboundMessage$1, jt as recordAttemptFailure$1, kt as markConversationWorkEnqueued$1, lt as ackMessages$1, mt as checkInConversationWork$1, pt as cancelHumanFacingPendingMessages$1, ut as appendExclusiveInboundMessage, vt as completeConversationStop$1, xt as drainConversationMailbox$1, yt as completeConversationWork$1, zt as steerWebPendingMessages$1 } from "./projection-CL_YWeGf.js";
|
|
2
|
+
import { a as getConversationStore } from "./db-DJ11eZqq.js";
|
|
3
|
+
import "./background-compaction-queue-CYI909P5.js";
|
|
4
4
|
// src/chat/task-execution/store.ts
|
|
5
5
|
function metadataStore(options) {
|
|
6
6
|
return options.conversationStore ?? getConversationStore();
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as botConfig } from "./config-
|
|
4
|
-
import { E as withSpan, G as toOptionalNumber, K as toOptionalString, W as isRecord$1, _ as runBestEffort, h as logWarn } from "./logging-
|
|
2
|
+
import { $a as createPluginLogger, $i as postSlackMessage, Ba as createPluginModel, Fo as createPluginCache, Hi as formatSlackLink, Io as createDurableLocationConfigurationService, Qa as createPluginModelCostRecorder, T as fallbackShortTitle, Vi as escapeSlackMrkdwnText, Xi as openSlackDirectMessage, Zn as getPlugins, Zt as getPiMessageRole, b as persistConversationMessages, cn as normalizeToolNameFromResult, er as coreTaskRegistrations, fi as getDashboardTaskLink, hi as createPluginState, it as getTurnRecord, mi as ToolInputError, nn as instructionTextForProjection, on as isToolResultError, si as JUNIOR_THREAD_STATE_TTL_MS, sn as isToolResultMessage, un as stripRuntimeTurnContext, uo as createPluginConversationEvents, v as hydrateConversationMessages, za as createPluginEmbedder } from "./projection-CL_YWeGf.js";
|
|
3
|
+
import { n as botConfig } from "./config-CkHcUMN7.js";
|
|
4
|
+
import { E as withSpan, G as toOptionalNumber, K as toOptionalString, W as isRecord$1, _ as runBestEffort, h as logWarn } from "./logging-BO5zU6Mt.js";
|
|
5
5
|
import { h as parseSlackMessageTs } from "./actor-6jsm_v96.js";
|
|
6
|
-
import {
|
|
7
|
-
import { A as juniorConversations, d as juniorAutomationVersions, f as juniorAutomations, u as juniorAutomationRuns } from "./executor-
|
|
8
|
-
import { v as sameActorIdentity } from "./media-
|
|
9
|
-
import { h as credentialSubjectSchema } from "./registry-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
6
|
+
import { H as agentTurnCostUsd, U as agentTurnTotalTokens, a as getConversationStore, o as getDb } from "./db-DJ11eZqq.js";
|
|
7
|
+
import { A as juniorConversations, d as juniorAutomationVersions, f as juniorAutomations, u as juniorAutomationRuns } from "./executor-BY9TB31g.js";
|
|
8
|
+
import { v as sameActorIdentity } from "./media-Cz1ZiV1U.js";
|
|
9
|
+
import { h as credentialSubjectSchema } from "./registry-BriFLnaJ.js";
|
|
10
|
+
import { i as readActorIdentity } from "./viewer-DrMmFUul.js";
|
|
11
|
+
import { r as getStateAdapter } from "./adapter-CL-HUKgd.js";
|
|
12
|
+
import { c as pluginTaskParamsSchema, d as sendVercelPluginTask, s as pluginTaskId } from "./background-compaction-queue-CYI909P5.js";
|
|
13
|
+
import { O as eventAutomationSchema, S as automationVersionSchema, j as scheduledAutomationSchema } from "./automation-DksGNDRO.js";
|
|
13
14
|
import { createHash } from "node:crypto";
|
|
14
15
|
import * as z from "zod";
|
|
15
16
|
import { and, asc, count, desc, eq, gte, inArray, isNotNull, isNull, lte, max, ne, or, sql } from "drizzle-orm";
|
|
@@ -348,7 +349,7 @@ function slackSourceForDestination(args) {
|
|
|
348
349
|
* Reads parent Conversations when this Conversation has no Destination.
|
|
349
350
|
*/
|
|
350
351
|
async function resolveConversationRouting(args) {
|
|
351
|
-
const conversationStore = args.conversationStore ?? (await import("./
|
|
352
|
+
const conversationStore = args.conversationStore ?? (await import("./db-DJ11eZqq.js").then((n) => n.n)).getConversationStore();
|
|
352
353
|
const chain = await loadConversationChain(args.conversationId, conversationStore);
|
|
353
354
|
let destination;
|
|
354
355
|
let source;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { W as isRecord, b as setSpanAttributes, t as buildTurnFailureResponse } from "./logging-CMFhLLj4.js";
|
|
1
|
+
import { Cn as buildDeterministicTurnId, D as buildConversationContext, M as markConversationMessage, ko as listConversationAnnotations, q as clearPendingAuth, v as hydrateConversationMessages } from "./projection-CL_YWeGf.js";
|
|
2
|
+
import { I as findProviderError, L as getProviderErrorAttributes, P as ProviderError, R as getProviderErrorUserMessage, g as TURN_REASONING_LEVELS } from "./config-CkHcUMN7.js";
|
|
3
|
+
import { W as isRecord, b as setSpanAttributes, t as buildTurnFailureResponse } from "./logging-BO5zU6Mt.js";
|
|
5
4
|
import { h as parseSlackMessageTs } from "./actor-6jsm_v96.js";
|
|
6
|
-
import {
|
|
7
|
-
import { g as juniorAgentInvocations } from "./executor-
|
|
8
|
-
import { p as credentialContextSchema } from "./registry-
|
|
9
|
-
import { F as removedCardSchema, I as resolveMessageCards, P as readMessageCardRefs } from "./conversation-
|
|
10
|
-
import {
|
|
11
|
-
import { _t as getPersistedThreadState, bt as coerceThreadConversationState, yt as persistThreadStateById } from "./task-runner-
|
|
5
|
+
import { o as getDb, r as getConversationEventStore, s as getSqlExecutor } from "./db-DJ11eZqq.js";
|
|
6
|
+
import { g as juniorAgentInvocations } from "./executor-BY9TB31g.js";
|
|
7
|
+
import { p as credentialContextSchema } from "./registry-BriFLnaJ.js";
|
|
8
|
+
import { F as removedCardSchema, I as resolveMessageCards, P as readMessageCardRefs } from "./conversation-E7ZPJx2H.js";
|
|
9
|
+
import { C as AGENT_INVOCATION_PARENT_MAILBOX_STATUSES, S as AGENT_INVOCATION_MAILBOX_STATUSES } from "./reporting-window-B3Ze-Qnt.js";
|
|
10
|
+
import { _t as getPersistedThreadState, bt as coerceThreadConversationState, yt as persistThreadStateById } from "./task-runner-D_RDr2Hu.js";
|
|
12
11
|
import { createHash } from "node:crypto";
|
|
13
12
|
import * as z from "zod";
|
|
14
13
|
import { and, asc, desc, eq, inArray, or, sql } from "drizzle-orm";
|
|
@@ -227,6 +226,11 @@ function agentTypeInstructions(type) {
|
|
|
227
226
|
// src/chat/agent-invocations/types.ts
|
|
228
227
|
const exactStringSchema = z.string().min(1).refine((value) => value === value.trim());
|
|
229
228
|
const agentNameSchema = exactStringSchema.max(64);
|
|
229
|
+
/**
|
|
230
|
+
* Kind of a new child Conversation. A Thread is a child that people can
|
|
231
|
+
* message; a Task is one that only its parent messages.
|
|
232
|
+
*/
|
|
233
|
+
const CHILD_AGENT_KINDS = ["thread", "task"];
|
|
230
234
|
/** `messageAgent` target for the parent of a child agent. */
|
|
231
235
|
const PARENT_AGENT_TARGET = "parent";
|
|
232
236
|
const agentInvocationMailboxStatusSchema = z.enum(AGENT_INVOCATION_MAILBOX_STATUSES);
|
|
@@ -284,6 +288,7 @@ const createAgentInvocationSchema = z.object({
|
|
|
284
288
|
destination: destinationSchema,
|
|
285
289
|
idempotencyKey: exactStringSchema,
|
|
286
290
|
input: exactStringSchema,
|
|
291
|
+
kind: z.enum(CHILD_AGENT_KINDS).default("task"),
|
|
287
292
|
parentConversationId: exactStringSchema,
|
|
288
293
|
parentToolCallId: exactStringSchema.optional(),
|
|
289
294
|
agentType: agentTypeSchema.optional(),
|
|
@@ -799,4 +804,4 @@ function finalizeFailedTurnReplyWithEvent(args) {
|
|
|
799
804
|
}
|
|
800
805
|
};
|
|
801
806
|
}
|
|
802
|
-
export {
|
|
807
|
+
export { getUnnamedAgentConversationId as $, markAgentInvocationPaused as A, AGENT_TYPES as B, isTerminalAgentInvocation as C, listPendingAgentInvocationResults as D, listPendingAgentInvocationMailboxAppends as E, CHILD_AGENT_RESULTS as F, getAgentInvocationIdForEvents as G, agentTypeStartsWithParentHistory as H, PARENT_AGENT_TARGET as I, getAgentInvocationMessageId as J, getAgentInvocationIdForMessage as K, agentBindingSchema as L, markAgentInvocationSteered as M, reportReplacedAgentInvocation as N, markAgentInvocationMailboxAppended as O, CHILD_AGENT_KINDS as P, getNamedAgentConversationId as Q, agentNameSchema as R, invocationFromRow as S, listOpenAgentInvocations as T, formatAgentTypes as U, agentTypeInstructions as V, getAgentInvocationId as W, getAgentInvocationTurnId as X, getAgentInvocationResultMessageId as Y, getChildAgentLockName as Z, completeAgentInvocation as _, persistAuthPauseTurnState as a, getConversationTurnBoundaryError as at, getChildAgentLabel as b, getTurnUserSlackMessageTs as c, isTurnInputDeferredError as ct, loadThreadContextTrimFloor as d, markTurnFailed as dt, parseAgentInvocationResultMessageId as et, ConversationTurnLifecycleService as f, startActiveTurn as ft, NON_TERMINAL_AGENT_INVOCATION_STATUSES as g, ACTIVE_AGENT_INVOCATION_STATUSES as h, completeAuthPauseTurn as i, TurnInputDeferredError as it, markAgentInvocationRunning as j, markAgentInvocationParentMailboxAppended as k, buildDeliveredTurnStatePatch as l, markTurnClosed as lt, loadPendingMessageCards as m, getAgentTurnDiagnosticsAttributes as n, CooperativeTurnYieldError as nt, getTurnUserMessage as o, isCooperativeTurnYieldError as ot, getTurnLifecycle as p, getAgentInvocationIdForResult as q, requireTurnFailureEventId as r, TurnInputCommitLostError as rt, getTurnUserReplyAttachmentContext as s, isTurnInputCommitLostError as st, finalizeFailedTurnReplyWithEvent as t, ConversationTurnBoundaryError as tt, buildTurnThreadContext as u, markTurnCompleted as ut, getActiveAgentInvocationForConversation as v, listAgentInvocationsForConversation as w, getLatestAgentInvocationForConversation as x, getAgentInvocation as y, createAgentInvocationSchema as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
2
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-BCIuBe4d.js";
|
|
3
3
|
import { isDeepStrictEqual } from "node:util";
|
|
4
4
|
// src/chat/plugins/validation.ts
|
|
5
5
|
var validation_exports = /* @__PURE__ */ __exportAll({
|