@sentry/junior 0.315.0 → 0.316.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-context-BlSGE44V.js → adapter-context-Bref7aPI.js} +1 -1
- package/dist/{admin-5jUYY46p.js → admin-QYiDMnsu.js} +1 -1
- package/dist/{agent-runner-C7GNLRB6.js → agent-runner-Cr5Fhjf-.js} +2298 -1866
- package/dist/{agent-update-delivery-BNEYQsAf.js → agent-update-delivery-BY13DPSD.js} +10 -37
- package/dist/api/schema.d.ts +69 -20
- package/dist/api/schema.js +4 -4
- package/dist/api.js +202 -315
- package/dist/{app-D_bAXRDe.d.ts → app-BhvzRD__.d.ts} +18 -14
- package/dist/app.d.ts +1 -1
- package/dist/app.js +34 -34
- package/dist/{chat-core-engine-CxkwRpn9.js → chat-core-engine-3dtlMku3.js} +3 -3
- package/dist/cli/chat.js +17 -17
- package/dist/cli/check.js +4 -4
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.js +3 -3
- package/dist/cli/snapshot-create.js +2 -2
- package/dist/cli/upgrade.js +23 -3
- package/dist/{continue-in-slack-BGKjIdFp.js → continue-in-slack-DbQUFe_F.js} +3 -3
- package/dist/{conversation-feed-Sl8lKKmR.js → conversation-feed-B84pMjHo.js} +8 -3
- package/dist/{conversation-turn-BoLK9i6g.js → conversation-turn-DzEpTIaf.js} +16 -109
- package/dist/{create-BOycVH9h.js → create-DUJBXr6E.js} +4 -5
- package/dist/{credential-sync-Mn4OdkEh.js → credential-sync-JH_K9Adg.js} +9 -9
- package/dist/{db-DXTOYRzR.js → db-DhzvUY23.js} +343 -179
- package/dist/{deployment-CG3TchWh.js → deployment-BhvrhQeh.js} +1 -1
- package/dist/{engine-context-dyWlfNdD.js → engine-context-C9Nal48K.js} +9 -12
- package/dist/{html-CfXEwl_h.js → html-B_12WjKT.js} +2 -2
- package/dist/instrumentation.js +2 -2
- package/dist/{job-runner-CySgpi9v.js → job-runner-DO8nslyY.js} +17 -9
- package/dist/{lineage-tRTOcrsL.js → lineage-D3AZAJVe.js} +1 -1
- package/dist/{list-DXBz8SYL.js → list-B0zsb5Cp.js} +64 -182
- package/dist/{parent-result-Dg6P6roR.js → list-mkB_GU8R.js} +80 -108
- package/dist/{logging-czs0nqLC.js → logging-B8KEJegM.js} +1 -1
- package/dist/{media-Cr9pGkzr.js → media-BebquhET.js} +15 -3
- package/dist/{message-BTox2Cmb.js → message-B5fKDYzz.js} +8 -8
- package/dist/{model-input-IRGa98V7.js → model-input-CuMWy37l.js} +3 -3
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-NXK7AlBp.js → oauth-callback-server-B3Vvlydo.js} +2 -2
- package/dist/{oauth-relay-6NBPSpFE.js → oauth-relay-6ERrGPbA.js} +1 -1
- package/dist/{people-Cegp1Iwq.js → people-CUtFApfL.js} +2 -2
- package/dist/{proxy-path-Dc-0jXGi.js → proxy-path-BTmXDjfx.js} +1 -1
- package/dist/{resolve-BUFkmxkT.js → resolve-D5JVvv6A.js} +3 -3
- package/dist/{result-DfATzX77.js → result-CS_7mo8a.js} +30 -14
- package/dist/{runner-CmKP3inb.js → runner-BzAES5W3.js} +7 -7
- package/dist/{sandbox-egress-signals-DYo5BsM7.js → sandbox-egress-signals-Dwhk2Q5F.js} +1 -1
- package/dist/{schema-DrBMdPmv.js → schema-z5-wA6N4.js} +34 -13
- package/dist/{service-account-CxTX7nnR.js → service-account-D6AsAtc1.js} +1 -1
- package/dist/{mailbox-turn-79Nv1JXv.js → session-stop-DponjDUZ.js} +3075 -3092
- package/dist/{skills-BlHUDj7k.js → skills-DgJ9GBPR.js} +3 -3
- package/dist/{slack-conversation-unfurl-Dhe3lB1U.js → slack-conversation-unfurl-Dq71EkhM.js} +6 -6
- package/dist/{spawn-CfvlFdfz.js → spawn-BJWpdwhQ.js} +4 -4
- package/dist/{start-conversation-Uh8Sk1EF.js → start-conversation-B-LIqqNi.js} +2 -2
- package/dist/{system-prompt-table-CDCYVwqN.js → system-prompt-table-iIgpmslr.js} +6 -4
- package/dist/{task-runner-DcdQJd9e.js → task-runner-BJae4JwE.js} +23 -11
- package/dist/{thread-context-DF5uDcWN.js → thread-context-fiMNylbg.js} +5 -5
- package/dist/{transcript-BHhJVY0P.js → transcript-CCi7323k.js} +1 -1
- package/dist/{turn-session-routing-GtetHsdO.js → turn-session-routing-D15orfwy.js} +7 -7
- package/dist/{turn-wake-um5Ubd4m.js → turn-wake-BjDW7x-5.js} +4 -4
- package/dist/{validation-CJyuOPD2.js → validation-D5WmmmhX.js} +1 -1
- package/dist/{version-Bhe7RPIe.js → version-CBQoanXb.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{worker-D8PRgUqr.js → worker-Cyb4kF17.js} +3 -3
- package/migrations/20261125171254_conversation_visibility/migration.sql +4 -0
- package/migrations/20261125171254_conversation_visibility/snapshot.json +67 -0
- package/migrations/20261125171257_conversation_visibility_backfill/migration.sql +25 -0
- package/migrations/20261125171257_conversation_visibility_backfill/snapshot.json +9 -0
- package/migrations/20261125213232_drop_versions_notify/migration.sql +19 -0
- package/migrations/20261125213232_drop_versions_notify/snapshot.json +9 -0
- package/migrations/20261125225138_conversation_kind_root_thread/migration.sql +23 -0
- package/migrations/20261125225138_conversation_kind_root_thread/snapshot.json +55 -0
- package/migrations/20261125225142_conversation_kind_root_thread_backfill/migration.sql +7 -0
- package/migrations/20261125225142_conversation_kind_root_thread_backfill/snapshot.json +9 -0
- package/migrations/20261126000151_conversation_event_message_role_seq_index/migration.sql +1 -0
- package/migrations/20261126000151_conversation_event_message_role_seq_index/snapshot.json +69 -0
- package/migrations/20261126012917_merge_leaves/migration.sql +2 -0
- package/migrations/20261126012917_merge_leaves/snapshot.json +12 -0
- package/package.json +5 -5
- package/skills/jr-rpc/SKILL.md +3 -5
- package/dist/direct-url-BYgYfuIy.js +0 -22
- package/dist/markers-CE0HMXWT.js +0 -67
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { G as mapBounded } from "./transcript-
|
|
3
|
-
import { g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, p as logException, v as serializeGenAiAttribute } from "./logging-
|
|
4
|
-
import { h as SERVICE_INSTANCE_ID } from "./deployment-
|
|
5
|
-
import { a as resolveConversationPrivacy, c as toCanonicalOutputMessage, l as toGenAiMessagesTraceAttributes, s as toCanonicalInputMessage } from "./proxy-path-
|
|
6
|
-
import { bt as instructionProvenanceFor, vt as contextProvenance } from "./media-
|
|
7
|
-
import {
|
|
8
|
-
import { d as createReadFileTool, g as createBashTool, l as createWriteFileTool, p as createEditFileTool, s as createSystemTimeTool } from "./job-runner-
|
|
9
|
-
import { F as createAgentSandbox, I as normalizeToolResult, c as buildSandboxInput } from "./agent-runner-
|
|
1
|
+
import { $f as resolveGatewayModel, E as locationSchema, Gl as juniorTurns, Op as getGatewayApiKey, Pn as getWorkspace, Rl as resolveRootVisibility, Tu as juniorConversations, Ul as juniorTurnOutbox, Wl as juniorTurnInbox, a as getDb, aa as QUEUE_SIGNATURE_MAX_AGE_MS, ca as getQueueProvider, d as eventFromRow, gp as gatewayRoutingAttributes, hu as juniorConversationEvents, lp as requestPrefixAttributes, m as withConversationEventLock, o as getSqlExecutor, oa as signQueueMessage, of as credentialContextForActor, sa as verifyQueueMessage, u as createSqlConversationEventStore } from "./db-DhzvUY23.js";
|
|
2
|
+
import { G as mapBounded } from "./transcript-CCi7323k.js";
|
|
3
|
+
import { g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, p as logException, v as serializeGenAiAttribute } from "./logging-B8KEJegM.js";
|
|
4
|
+
import { h as SERVICE_INSTANCE_ID } from "./deployment-BhvrhQeh.js";
|
|
5
|
+
import { a as resolveConversationPrivacy, c as toCanonicalOutputMessage, l as toGenAiMessagesTraceAttributes, s as toCanonicalInputMessage } from "./proxy-path-BTmXDjfx.js";
|
|
6
|
+
import { bt as instructionProvenanceFor, vt as contextProvenance } from "./media-BebquhET.js";
|
|
7
|
+
import { $i as piMessageFromHistoryItem, In as buildDeploymentSystemPrompt, Qi as historyItemFromPiMessage, ea as projectConversationEvents, it as persistThreadRuntimeState, nt as getPersistedSandboxState, rt as getPersistedThreadState } from "./session-stop-DponjDUZ.js";
|
|
8
|
+
import { d as createReadFileTool, g as createBashTool, l as createWriteFileTool, p as createEditFileTool, s as createSystemTimeTool } from "./job-runner-DO8nslyY.js";
|
|
9
|
+
import { F as createAgentSandbox, I as normalizeToolResult, c as buildSandboxInput } from "./agent-runner-Cr5Fhjf-.js";
|
|
10
10
|
import { n as TURN_STEP_TOPIC, t as DELIVERY_TOPIC } from "./topic-CRYYBYp-.js";
|
|
11
11
|
import * as z from "zod";
|
|
12
12
|
import { streamSimple } from "@earendil-works/pi-ai/compat";
|
|
@@ -1784,9 +1784,6 @@ async function turnTools(turn, inputs) {
|
|
|
1784
1784
|
traceContext: { conversationId: turn.conversationId },
|
|
1785
1785
|
conversationId: turn.conversationId,
|
|
1786
1786
|
credentialEgress: credentialContextForActor(actor),
|
|
1787
|
-
actor,
|
|
1788
|
-
configurationValues: {},
|
|
1789
|
-
getActiveSkill: () => null,
|
|
1790
1787
|
prepareSandbox: () => {},
|
|
1791
1788
|
onSandboxRefChanged: () => {},
|
|
1792
1789
|
persistSandboxRef: (sandboxRef) => persistThreadRuntimeState(turn.conversationId, { sandboxRef })
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { G as mapBounded } from "./transcript-
|
|
1
|
+
import { Hr as hasRequiredOAuthScope, Jr as deleteMcpAuthSessionsForUserProvider, Pf as botConfig, Xr as deleteMcpStoredOAuthCredentials, Yr as deleteMcpServerSessionId, dl as deleteProviderIdentityForUser, ir as startOAuthFlow, jr as pluginCatalogRuntime, o as getSqlExecutor, ul as deleteProviderIdentityForSlackUser } from "./db-DhzvUY23.js";
|
|
2
|
+
import { G as mapBounded } from "./transcript-CCi7323k.js";
|
|
3
3
|
import { randomBytes } from "node:crypto";
|
|
4
4
|
// src/handlers/oauth-html.ts
|
|
5
5
|
/** Build pre-escaped callback HTML with the shared response security policy. */
|
package/dist/instrumentation.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as getClient, c as init, i as getActiveSpan, o as getGlobalScope, p as spanToJSON, s as getTraceData } from "./sentry-CPbZjomA.js";
|
|
2
|
-
import { i as getCurrentConversationPrivacy, n as redactSandboxEgressProxyPath } from "./proxy-path-
|
|
2
|
+
import { i as getCurrentConversationPrivacy, n as redactSandboxEgressProxyPath } from "./proxy-path-BTmXDjfx.js";
|
|
3
3
|
import { n as isPushServiceHost } from "./push-endpoint-CO-nomUd.js";
|
|
4
4
|
import { n as promoteHttpRouteName, r as routeNameMiddleware, t as nameRequestRoute } from "./sentry-route-name-C6EIzAGP.js";
|
|
5
5
|
import { t as consumePrivateTraceResultMarker } from "./private-trace-result-CE7_lEdq.js";
|
|
6
|
-
import { _ as getDeploymentServiceVersion, v as getDeploymentTelemetryAttributes } from "./deployment-
|
|
6
|
+
import { _ as getDeploymentServiceVersion, v as getDeploymentTelemetryAttributes } from "./deployment-BhvrhQeh.js";
|
|
7
7
|
import { performance } from "node:perf_hooks";
|
|
8
8
|
import { subscribe, unsubscribe } from "node:diagnostics_channel";
|
|
9
9
|
// src/chat/pi/gateway-request-timing.ts
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { $i as getVercelConversationWorkQueue,
|
|
1
|
+
import { $i as getVercelConversationWorkQueue, Dr as buildSandboxEgressNetworkPolicy, Eu as juniorSpaceConfigurations, Gn as create, Gu as workspaceSnapshotFinishedEvent, Hn as loadSnapshotsForProfile, Pd as sleep, Pn as getWorkspace, Tu as juniorConversations, Un as setWorkspaceSnapshot, V as slackMention, Vn as invalidateReadySnapshot, Wn as setWorkspaceSnapshotBuild, Xn as getSandboxProvider, Zd as ToolInputError, a as getDb, aa as QUEUE_SIGNATURE_MAX_AGE_MS, br as createSandboxEgressCredentialToken, ca as getQueueProvider, cp as withLock, dr as WorkspaceSnapshotNotReadyError, id as findMatchingWatches, nf as getStateAdapter, oa as signQueueMessage, od as isQuietEvent, of as credentialContextForActor, pr as isWorkspaceSnapshotNotReadyError, q as createPluginHookRunner, qn as isStale, rd as deliverWatch, sa as verifyQueueMessage, sp as fenceLock, sr as isAbortError, xn as getTurnRequestDeadline, yi as SANDBOX_RUNTIME } from "./db-DhzvUY23.js";
|
|
2
2
|
import { h as WORKSPACE_SNAPSHOT_JOB_QUEUE_TOPIC } from "./package-discovery-BI6T_RkD.js";
|
|
3
|
-
import { M as SANDBOX_WORKSPACE_ROOT, k as SANDBOX_REPOS_ROOT } from "./transcript-
|
|
4
|
-
import { m as logInfo, p as logException } from "./logging-
|
|
5
|
-
import { cn as isValidTimeZone, sn as getZonedDateTimeParts } from "./media-
|
|
6
|
-
import {
|
|
7
|
-
import { B as zodToolDefinition, H as juniorToolOutputSchema, z as zodTool } from "./turn-session-routing-
|
|
8
|
-
import { t as resolveEventMentions } from "./people-
|
|
9
|
-
import { i as postinstall, r as dependencies, s as getSandboxResources } from "./resolve-
|
|
3
|
+
import { M as SANDBOX_WORKSPACE_ROOT, k as SANDBOX_REPOS_ROOT } from "./transcript-CCi7323k.js";
|
|
4
|
+
import { m as logInfo, p as logException } from "./logging-B8KEJegM.js";
|
|
5
|
+
import { cn as isValidTimeZone, sn as getZonedDateTimeParts } from "./media-BebquhET.js";
|
|
6
|
+
import { ln as enqueueEventNotification, na as validateConfigValue, ra as configValueSchema, sn as addQuietEventNote, ta as validateConfigKey, yn as resolveEventAuthor } from "./session-stop-DponjDUZ.js";
|
|
7
|
+
import { B as zodToolDefinition, H as juniorToolOutputSchema, z as zodTool } from "./turn-session-routing-D15orfwy.js";
|
|
8
|
+
import { t as resolveEventMentions } from "./people-CUtFApfL.js";
|
|
9
|
+
import { i as postinstall, r as dependencies, s as getSandboxResources } from "./resolve-D5JVvv6A.js";
|
|
10
10
|
import * as z from "zod";
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -59,6 +59,14 @@ async function unsetSpaceConfiguration(spaceId, key) {
|
|
|
59
59
|
await getDb().delete(juniorSpaceConfigurations).where(and(eq(juniorSpaceConfigurations.spaceId, spaceId), eq(juniorSpaceConfigurations.key, key)));
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
+
* Return the id of the Space that a Conversation's root is in, if any. A
|
|
63
|
+
* child is in the Space of its root.
|
|
64
|
+
*/
|
|
65
|
+
async function readConversationSpaceId(conversationId) {
|
|
66
|
+
const [row] = await getDb().select({ spaceId: rootConversation.spaceId }).from(juniorConversations).innerJoin(rootConversation, eq(rootConversation.conversationId, sql`coalesce(${juniorConversations.rootConversationId}, ${juniorConversations.conversationId})`)).where(eq(juniorConversations.conversationId, conversationId)).limit(1);
|
|
67
|
+
return row?.spaceId ?? void 0;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
62
70
|
* Return the configuration of the Space that a Conversation's root is in. A
|
|
63
71
|
* child is in the Space of its root. A Conversation outside a Space has none.
|
|
64
72
|
*/
|
|
@@ -1128,4 +1136,4 @@ async function ensureWorkspaceSnapshotBuild(input) {
|
|
|
1128
1136
|
else await sendWorkspaceSnapshotJob(message);
|
|
1129
1137
|
return "building";
|
|
1130
1138
|
}
|
|
1131
|
-
export {
|
|
1139
|
+
export { setSpaceConfiguration as A, isMissingPathError as C, listSpaceConfiguration as D, resolveWorkspacePath as E, readConversationSpaceConfiguration as O, validateAndApplyTextEdits as S, positiveInteger as T, buildCompactDiff as _, prepareWorkspaceSnapshot as a, restoreLineEndings as b, systemTimeToolDefinition as c, createReadFileTool as d, readFileToolDefinition as f, createBashTool as g, bashToolDefinition as h, requireReadyWorkspaceSnapshot as i, unsetSpaceConfiguration as j, readConversationSpaceId as k, createWriteFileTool as l, editFileToolDefinition as m, processWorkspaceSnapshotJob as n, ingestEvent as o, createEditFileTool as p, verifyWorkspaceSnapshotJobMessage as r, createSystemTimeTool as s, ensureWorkspaceSnapshotBuild as t, writeFileToolDefinition as u, detectLineEnding as v, normalizeToLf as w, stripBom as x, prepareTextReplacementArguments as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ds as conversationKindFromRow,
|
|
1
|
+
import { Ds as conversationKindFromRow, Tu as juniorConversations, a as getDb } from "./db-DhzvUY23.js";
|
|
2
2
|
import { desc, eq, sql } from "drizzle-orm";
|
|
3
3
|
// src/chat/conversations/lineage.ts
|
|
4
4
|
/**
|
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
import { $ as getPlugins, $
|
|
2
|
-
import { G as mapBounded, I as createPluginLogger, _ as trimTrailingAssistantMessages } from "./transcript-
|
|
3
|
-
import { D as buildSentryConversationUrl, E as withSpan, N as normalizeIdentityEmail, P as toOptionalString, S as setTags, T as withLogContext, b as setSpanAttributes, f as logError, h as logWarn, m as logInfo, n as createChatSdkLogger, o as getActiveTraceContext, p as logException, s as getActiveTraceId, t as buildTurnFailureResponse, y as setSentryUser } from "./logging-
|
|
1
|
+
import { $ as getPlugins, $f as resolveGatewayModel, $i as getVercelConversationWorkQueue, $o as existingConversationId, $r as getMcpStoredOAuthCredentials, A as resolveRootConversationId, Aa as createPluginCache, Ac as inboxItemTodo, Ai as conversationSearchVector, Al as conversationIsMemberRoot, An as createPluginState, Ao as parseDashboardPersonLink, As as treeAwaitsAuthorization, B as normalizeSlackStatusText, Ba as getDispatchTurnId, Bf as getSlackSigningSecret, Bn as isPostgresErrorCode, Bs as dismissOpenInboxItems, Bu as slackChannelMessageReplyThreadTs, C as locationFromRow, Cc as canUserReadInboxItem, Cf as parseSlackChannelId, Ci as createPluginEmbedder, Cl as createConversationAccessReader, Co as getDashboardLinkFilter, Cs as conversationStatusSql, Cu as juniorAttachments, Dc as inboxItemPlugin, Dd as isDmChannel, Dl as readPrivateSpaceMemberships, Dp as isProviderRetryError, Ds as conversationKindFromRow, Ec as inboxItemOwnedByConversation, El as readConversationAccessRows, Es as executionIsActive, F as SLACK_USER_MENTION_RE, Fa as createOrGetDispatch, Fc as isPluginInboxItem, Ff as getChatConfig, Fl as rootVisibleToViewer, G as applyPluginFormatMarkdown, Ga as markDispatchBlocked, Go as automationVersionOf, Gr as McpAuthorizationRequiredError, Gt as isThread, H as slackMentionedUserIds, Ha as isTerminalDispatchStatus, Ho as admitEventAutomationRun, Ia as getDispatchConversationId, Il as viewerMarksFromParticipant, Io as findMatchingEventAutomations, Iu as getEventCatalog, Ja as markDispatchRunning, Js as ownerConversationId, Jt as postsRunNotices, K as createPluginEventPublisher, Ka as markDispatchCompleted, Kr as PluginMcpClient, Kt as isTopLevel, La as getDispatchIdForConversation, Ld as updateTimerIndex, Lf as getSlackBotToken, Li as completeDecision, Ll as isPublicConversation, M as conversationSlackTenantId, Ma as buildDispatchId, Mc as isAutomationAlertItem, Md as streamPrivateSlackFile, Ml as conversationPinnedForUser, Mo as blockEventAutomation, Ms as AUTOMATION_ALERT_STEP_FIELD_ID, Mu as juniorUsers, N as loadConversationSlackTenantIds, Na as claimDispatchMailboxAppend, Nc as isInboxItemForEveryone, Nd as withSlackRetries, Nl as readMemberParticipants, No as collectEventAutomationMatchKeys, Nu as juniorDestinations, Od as isSlackRequestTimeout, Oo as isDashboardLink, Os as awaitsAuthorizationFrom, Ou as juniorSpaces, P as parseSessionSource, Pa as confirmDispatchMailboxAppend, Pc as isOnlyAssignee, Pf as botConfig, Pl as rootSpaceReadableBy, Ps as fallbackShortTitle, Qi as createPluginInboxItems, Qu as cancelSubscriptions, Ra as getDispatchInputMessageId, Rd as CORE_EVENT_NAMESPACE, Rf as getSlackClientId, Rs as closeInboxItem, S as withConversationMutationLock, Sd as downloadPrivateSlackFile, Sl as conversationAccessFromRows, Sn as createPluginCodeChanges, Ss as conversationIsActiveSql, Tc as inboxItemNeedsInput, Td as getSlackClient, Tf as parseSlackTeamId, Tl as readConversationAccessFromSql, Tn as createPluginConversationWatches, To as getDashboardPersonLink, Ts as conversationWaitsOnUserSql, Tu as juniorConversations, U as wrapBareSlackUserIds, Uo as eventAutomationRunLimitReason, Us as inboxItemNeedsUserNow, V as slackMention, Va as getPluginDispatchProjection, Vd as eventGuidance, Vl as nextDetailVersion, Vs as getInboxItem, Vt as deliversFinalText, Vu as slackChannelMessageRunsAutomation, Wa as markDispatchAwaitingResume, Wi as JUNIOR_NATIVE_EVENT_NAMESPACE, Xa as addReactionToMessage, Xf as normalizeSlackEmojiName, Xi as createPluginConversationChanges, Xs as takeInboxItem, Xt as turnBehavior, Ya as notifyAutomationBlocked, Zi as PLUGIN_CHOICE_FIELD_ID, _ as readConversationTrees, _l as readCachedUserByEmail, _u as juniorConversationAnnotations, a as getDb, af as actorLogContext, al as userAvatarUrlsFromIdentities, au as juniorAutomations, bl as canInviteToConversation, bo as getDashboardConversationLink, bu as juniorCodeChanges, cl as resolveActorIdentityId, cs as recordAutomationExecution, da as listConversationAnnotationsById, dc as settleInboxSnoozes, dd as bindEventAutomationCredentialSubject, df as createSlackActor, ed as collectEventMatchKeys, el as hasUserPhoto, eu as juniorInboxItemConversations, f as copyMessageLinks, fd as bindScheduledAutomationCredentialSubject, ff as createSlackResumeActor, fs as agentTurnUsageSchema, ga as lookupSlackUserNames, gd as verifySlackDirectCredentialSubject, h as conversationAncestors, ha as lookupSlackUser, hc as PLUGIN_INBOX_ITEM_KEY_PREFIX, hd as verifyScheduledAutomationCredentialSubject, hf as parseActorUserId, hu as juniorConversationEvents, i as getConversationStore, ic as SNOOZE_TIMER_EVENT_TYPE, id as findMatchingWatches, if as setStateValues, ii as webActorUserIds, ip as createCache, jf as parseSlackMessageTs, jl as conversationIsNotUnsubscribedRoot, jr as pluginCatalogRuntime, js as AUTOMATION_ALERT_STEPS, kd as normalizeSlackConversationId, ko as parseDashboardConversationLink, ks as hasUnexpiredAuthorizationRequest, ku as juniorIdentities, la as createPluginAnnotations, lc as listFiringInboxSnoozeTriggers, ll as saveActorAvatar, m as withConversationEventLock, md as verifyEventAutomationCredentialSubject, mf as isUserActor, mn as createPluginTaskStarter, mp as textCharsForTokens, ms as conversationCostOf, n as getConversationEventStore, nf as getStateAdapter, nu as juniorInboxItems, o as getSqlExecutor, of as credentialContextForActor, ol as userAvatarUrlsFromJoinedPhotos, op as acquireActiveLock, ou as juniorAutomationRuns, pd as bindSlackDirectCredentialSubject, pf as isActorUserId, pp as estimateTextTokens, ps as hasAgentTurnUsage, qa as markDispatchFailed, ql as juniorTodos, qs as listReplyActionItems, qt as messagesNeedSpaceMembership, rf as getStateValues, ro as removeReactionFromMessage, rr as resolveBaseUrl, sd as listConversationsWithWatches, ss as readAutomationTitlesByConversationId, tl as identityAvatarUrl, tn as indexEndedTurnEvents, ua as listConversationAnnotations, uf as createActor, un as storedMessageJson, us as addAgentTurnUsage, uu as juniorConversationParticipants, v as setArchivedAt, vc as TODO_INBOX_ITEM_KEY_PREFIX, vd as readJuniorSecret, vf as truncateStatusText, wa as basePluginContext, wc as inboxItemForUser, wd as getHeaderString, wl as leaveEndsAccess, wr as createUserTokenStore, ws as conversationTurnFailedSql, wu as juniorMessageAttachments, xc as canAnswerInboxItem, xd as SlackActionError, xf as requireSlackDestination, xn as getTurnRequestDeadline, y as lastMessageAtSql, yc as canActOnInboxItem, yf as createSlackDestination, yl as canAddConversationMessages, yn as sendVercelPluginTask, za as getDispatchRecord, zf as getSlackClientSecret, zi as completeText } from "./db-DhzvUY23.js";
|
|
2
|
+
import { G as mapBounded, I as createPluginLogger, _ as trimTrailingAssistantMessages } from "./transcript-CCi7323k.js";
|
|
3
|
+
import { D as buildSentryConversationUrl, E as withSpan, N as normalizeIdentityEmail, P as toOptionalString, S as setTags, T as withLogContext, 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-B8KEJegM.js";
|
|
4
4
|
import { h as startSpan, n as captureMessage } from "./sentry-CPbZjomA.js";
|
|
5
|
-
import { t as JUNIOR_VERSION } from "./version-
|
|
6
|
-
import { Cn as isEmptyUserInputAnswer, Fn as automationTaskText, Ht as MAX_ATTACHMENT_BYTES, Kt as readMessageAttachments, Nt as conversationTreeStateSchema, Q as conversationReportStatusSchema, bn as answeredChoices, bt as instructionProvenanceFor, ct as KNOWN_CONVERSATION_EVENT_TYPES, et as conversationSurfaceSchema, i as isVisionImageMediaType, nt as activityPreviewText, r as detectImageMediaType, un as OPEN_TODO_STATUSES, vt as contextProvenance, wn as normalizeUserInputAnswer } from "./media-
|
|
7
|
-
import { $
|
|
8
|
-
import { o as ingestEvent } from "./job-runner-
|
|
9
|
-
import { $t as
|
|
10
|
-
import { p as getAssistantReplyText } from "./system-prompt-table-
|
|
11
|
-
import {
|
|
12
|
-
import { a as getChannelMessage, c as isPublicSlackChannel, d as listThreadReplies, o as getConversationInfo, s as isConversationMember, t as runWithSlackInstallation } from "./adapter-context-
|
|
13
|
-
import { a as readAttachmentVisionSummary, c as slackAttachmentsVersionQuery, r as getSlackFileId, s as recordSlackAttachment } from "./start-conversation-
|
|
14
|
-
import { i as getChildAgentLabel } from "./parent-result-Dg6P6roR.js";
|
|
5
|
+
import { t as JUNIOR_VERSION } from "./version-CBQoanXb.js";
|
|
6
|
+
import { Cn as isEmptyUserInputAnswer, Fn as automationTaskText, Ht as MAX_ATTACHMENT_BYTES, Kt as readMessageAttachments, Nt as conversationTreeStateSchema, Q as conversationReportStatusSchema, bn as answeredChoices, bt as instructionProvenanceFor, ct as KNOWN_CONVERSATION_EVENT_TYPES, et as conversationSurfaceSchema, i as isVisionImageMediaType, nt as activityPreviewText, r as detectImageMediaType, un as OPEN_TODO_STATUSES, vt as contextProvenance, wn as normalizeUserInputAnswer } from "./media-BebquhET.js";
|
|
7
|
+
import { $ as buildDeterministicAssistantMessageId, $i as piMessageFromHistoryItem, $r as completeTurnRecord, Ai as buildTurnErrorResponse, At as pushInboxSnoozeWakes, B as getTurnUserSlackMessageTs, Ci as getTurnLifecycle, Cn as renderTaskInput, Cr as normalizeConversationText, Dr as upsertConversationMessage, Er as turnHasReply, Fi as getAgentTurnDiagnosticsAttributes, Ft as appendAndEnqueueInboundMessage, G as getConversationTurnBoundaryError, Gr as clearPendingAuth, H as CooperativeTurnYieldError, I as notInheritedByForkChild, Ii as requireTurnFailureEventId, Ir as createPluginEgress, J as isTurnInputDeferredError, Jr as loadTurnCheckpoint, K as isCooperativeTurnYieldError, L as getTurnUserMessage, Lr as PluginCredentialFailureError, Lt as cancelHumanFacingPendingMessages, Ot as setTodoStatusByUser, Pi as finalizeFailedTurnReplyWithEvent, Pn as isExperimentalFeatureEnabled, Q as startActiveTurn, Qn as loadConversationProjection, Qr as abandonTurnRecord, Sr as markConversationMessage, Tr as trimConversationMessages, U as TurnInputCommitLostError, V as ConversationTurnBoundaryError, Vr as AuthorizationFlowDisabledError, W as TurnInputDeferredError, X as markTurnCompleted, Xn as commitMessages, Xr as pauseLostWorkerTurn, Xt as getConversationWorkState, Y as markTurnClosed, Yn as commitAcceptedReply, Yr as lostWorkerBeforeFirstSave, Yt as getConversation, Z as markTurnFailed, Zi as persistWithRetry, Zr as saveTurnCheckpoint, _ as legacyWebMailboxMetadataSchema, _i as canJoinTurn, _r as buildConversationContext, at as persistThreadStateById, br as isHumanConversationMessage, bt as withoutSavedSteeringMessages, c as conversationSubtreeColumns, dt as loadInboxItemInput, ei as failTurnRecord, er as loadTurnProjection, et as buildDeterministicTurnId, fr as hydrateConversationMessages, ft as savedInputInstruction, gt as instructionActorFor, hr as resolveConversationTitle, ht as buildSteeringPiMessage, ir as recordAuthorizationCompleted, it as persistThreadRuntimeState, jr as isEventConversationMessage, kr as EVENT_SYSTEM_ACTOR, lr as recordSubscribedReplyRoute, lt as getWebAuthorization, m as resolveMailboxTurnWork, mn as eventAuthorText, mr as persistConversationMessages, ni as listTurnSummaries, nt as getPersistedSandboxState, ot as coerceThreadConversationState, pr as persistConversationMessageWindow, q as isTurnInputCommitLostError, r as resumeForPersonInput, ra as configValueSchema, ri as recordTurnSummary, rt as getPersistedThreadState, s as conversationSubtree, ti as getTurnRecord, tt as getLocationConfigurationService, vi as canShareTurn, vr as estimateConversationMessagesTokens, wi as loadTurnStart, wr as recordDeliveredAssistantMessage, xn as resolveBotSlackTeamId, xr as latestConversationMessageSeq, yn as resolveEventAuthor, yr as getConversationMessageSlackTs, z as getTurnUserReplyAttachmentContext } from "./session-stop-DponjDUZ.js";
|
|
8
|
+
import { o as ingestEvent } from "./job-runner-DO8nslyY.js";
|
|
9
|
+
import { $t as missingAutomationSkillReason, At as renderAttachmentText, B as ANSWER_TOOL_ENDINGS, Bt as takeViewerAutomationAlertStep, C as resolveSlackReplyTarget, Ct as inviteMentionedPeople, Et as setConversationSubscription, Ft as resolveSlackChannelIdFromMessage, G as isConversationWorkDone, H as GLOBAL_GAPS_MAX, Ht as ViewerTaskNotFoundError, K as listConversationWork, L as RetryableDeliveryError, Mt as parseSlackMessageReference, Nt as parseSlackThreadId, O as canPauseConversationDelivery, Ot as jsonResponse, Pt as readSlackRawMessageContext, Qt as findAutomationSkill, St as stopChildAgentsOf, Tt as leaveConversation, U as GLOBAL_GAPS_TTL_MS, V as CONVERSATION_STATE_TTL_MS, W as segmentGapsKey, Wt as readConversationSourceTask, Zt as AutomationEditError, _t as setConversationSpaceForViewer, a as getMcpOAuthCallbackPath, an as firstLiveSavingsDate, bn as resolveConversationConfiguration, bt as stopConversation, ct as archiveConversation, en as effectiveTaskOutcomes, ft as deliverInboxItemChange, gn as MINUTE_MS, gt as requireSpaceForWork, in as addHistoryWarmupCost, jt as renderBlockText, kt as throwApiError, l as latestProgressStatus, lt as conversationReadPositionQuery, mn as providerCacheTtlMs, n as executeAgentRun, o as createClientMetadata, on as historyPeriodSavings, p as createInboxItemShow, pn as connectedState, r as buildAuthPauseResponse, rn as addHistoryPeriod, s as readMcpClientInformation, sn as replaceHistorySavings, st as readLastUserMessageAtByConversation, t as createAgentRunner, u as resolveDestinationVisibility, ut as markConversationRead, vn as NO_REPLY_GAP_MS, vt as readSpaceRefs, w as sendSlackReply, x as safeLinkUrl, yn as gapSegment, z as shouldEmitDevAgentTrace } from "./agent-runner-Cr5Fhjf-.js";
|
|
10
|
+
import { p as getAssistantReplyText } from "./system-prompt-table-iIgpmslr.js";
|
|
11
|
+
import { P as storeAttachment, _ as AttachmentUploadError, b as verifyAttachmentUploads, f as createAndEnqueueConversation, h as webActorFromUser, i as savedTurnMessages, j as isFileAttachment, l as acceptsWebMessages, m as recordWebConversationActivity, n as resolveTurnResumeRouting, p as createConversationId, t as resolveConversationRouting, u as appendAndEnqueueWebMessage } from "./turn-session-routing-D15orfwy.js";
|
|
12
|
+
import { a as getChannelMessage, c as isPublicSlackChannel, d as listThreadReplies, o as getConversationInfo, s as isConversationMember, t as runWithSlackInstallation } from "./adapter-context-Bref7aPI.js";
|
|
13
|
+
import { a as readAttachmentVisionSummary, c as slackAttachmentsVersionQuery, r as getSlackFileId, s as recordSlackAttachment } from "./start-conversation-B-LIqqNi.js";
|
|
15
14
|
import { t as webMessageId } from "./web-message-id-C6P83ans.js";
|
|
16
|
-
import { C as
|
|
17
|
-
import { a as
|
|
18
|
-
import { n as attachmentFactLines, r as buildStoredAttachmentPromptText } from "./model-input-
|
|
19
|
-
import {
|
|
20
|
-
import { t as bindMessageAgent } from "./message-
|
|
21
|
-
import { t as readConversationLineage } from "./lineage-
|
|
22
|
-
import { t as bindSpawnAgent } from "./spawn-
|
|
23
|
-
import { a as buildDeliveredTurnStatePatch, i as persistAuthPauseTurnState, n as loadThreadContextTrimFloor, o as loadPendingMessageCards, r as completeAuthPauseTurn, t as buildTurnThreadContext } from "./thread-context-
|
|
24
|
-
import { d as readConversationEventPageAround, l as readConversationEventPage, n as scheduleSessionCompletedPluginTasks, u as readConversationEventPageAfter } from "./task-runner-
|
|
25
|
-
import { n as getPausedTurnRequest, o as getTurnAuthorization, r as recordFailedDispatchTurn, t as createPausedTurns } from "./turn-wake-
|
|
26
|
-
import { r as canContinueInSlack } from "./continue-in-slack-
|
|
15
|
+
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-B84pMjHo.js";
|
|
16
|
+
import { a as recordFinishedTurnForAutomatedLimit, c as getTurnInputSpanAttributes, i as stopAtAutomatedTurnLimit, l as turnInputTelemetry, n as createConversationTurnWorker, o as AgentRunError, r as supersedeTurnForInput, s as executeTurn, u as withTurnSpan } from "./conversation-turn-DzEpTIaf.js";
|
|
17
|
+
import { n as attachmentFactLines, r as buildStoredAttachmentPromptText } from "./model-input-CuMWy37l.js";
|
|
18
|
+
import { c as withAgentInvocationResultActors, s as getChildAgentLabel, t as createChildConversationWorker } from "./result-CS_7mo8a.js";
|
|
19
|
+
import { t as bindMessageAgent } from "./message-B5fKDYzz.js";
|
|
20
|
+
import { t as readConversationLineage } from "./lineage-D3AZAJVe.js";
|
|
21
|
+
import { t as bindSpawnAgent } from "./spawn-BJWpdwhQ.js";
|
|
22
|
+
import { a as buildDeliveredTurnStatePatch, i as persistAuthPauseTurnState, n as loadThreadContextTrimFloor, o as loadPendingMessageCards, r as completeAuthPauseTurn, t as buildTurnThreadContext } from "./thread-context-fiMNylbg.js";
|
|
23
|
+
import { d as readConversationEventPageAround, l as readConversationEventPage, n as scheduleSessionCompletedPluginTasks, u as readConversationEventPageAfter } from "./task-runner-BJae4JwE.js";
|
|
24
|
+
import { n as getPausedTurnRequest, o as getTurnAuthorization, r as recordFailedDispatchTurn, t as createPausedTurns } from "./turn-wake-BjDW7x-5.js";
|
|
25
|
+
import { r as canContinueInSlack } from "./continue-in-slack-DbQUFe_F.js";
|
|
27
26
|
import * as z from "zod";
|
|
28
27
|
import pLimit from "p-limit";
|
|
29
28
|
import { createHash, createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
@@ -4059,6 +4058,7 @@ function createSlackTurn(deps) {
|
|
|
4059
4058
|
} : void 0,
|
|
4060
4059
|
credentialContext,
|
|
4061
4060
|
actor: executionActor,
|
|
4061
|
+
...!options.execution && message.author.isBot === true ? { actorIsApp: true } : void 0,
|
|
4062
4062
|
slackConversation,
|
|
4063
4063
|
source,
|
|
4064
4064
|
...location ? { location } : void 0,
|
|
@@ -4659,7 +4659,7 @@ async function enqueueAgentDispatch(dispatch, options) {
|
|
|
4659
4659
|
activityAtMs: claimedDispatch.createdAtMs,
|
|
4660
4660
|
conversationId,
|
|
4661
4661
|
destination,
|
|
4662
|
-
kind: isAutomationRun(claimedDispatch) ? "automation" : "
|
|
4662
|
+
kind: isAutomationRun(claimedDispatch) ? "automation" : "thread",
|
|
4663
4663
|
nowMs,
|
|
4664
4664
|
source: "plugin",
|
|
4665
4665
|
sessionSource: claimedDispatch.source,
|
|
@@ -6485,6 +6485,7 @@ async function runPausedTurnInContext(payload, options, runOptions) {
|
|
|
6485
6485
|
seqs: activeTurn.piMessageSeqs
|
|
6486
6486
|
} : await loadConversationProjection({ conversationId: payload.conversationId }),
|
|
6487
6487
|
actor,
|
|
6488
|
+
...!dispatchId && !isEventConversationMessage(userMessage) && userMessage.author?.isBot === true ? { actorIsApp: true } : void 0,
|
|
6488
6489
|
credentialContext,
|
|
6489
6490
|
destination: routingDestination,
|
|
6490
6491
|
...dispatch ? { dispatch } : void 0,
|
|
@@ -8026,7 +8027,7 @@ async function loadChildAgents(conversationIds) {
|
|
|
8026
8027
|
* `timestamp` of the stored assistant message, which Pi sets when it starts
|
|
8027
8028
|
* the request. That is the closest stored time to the recorder's clock.
|
|
8028
8029
|
*/
|
|
8029
|
-
function replayConversation(
|
|
8030
|
+
function replayConversation(conversation, events, children, nowMs) {
|
|
8030
8031
|
const periods = [];
|
|
8031
8032
|
const toolWaits = [];
|
|
8032
8033
|
const warmupTimes = events.flatMap((event) => event.type === "warmup" ? [Number(event.warmupAtMs)] : []);
|
|
@@ -8062,7 +8063,7 @@ function replayConversation(kind, events, children, nowMs) {
|
|
|
8062
8063
|
if (event.type === "tool_result" || event.type === "warmup") continue;
|
|
8063
8064
|
if (event.type === "user_message") {
|
|
8064
8065
|
if (!inTurn) {
|
|
8065
|
-
userActor = event.personInstruction === true && kind !== "task";
|
|
8066
|
+
userActor = event.personInstruction === true && conversation.kind !== "task";
|
|
8066
8067
|
inTurn = true;
|
|
8067
8068
|
}
|
|
8068
8069
|
continue;
|
|
@@ -8095,7 +8096,7 @@ function replayConversation(kind, events, children, nowMs) {
|
|
|
8095
8096
|
lastCallMs = startedAtMs;
|
|
8096
8097
|
if (turnEnding) {
|
|
8097
8098
|
const waitsOnPendingWork = turnBehavior({
|
|
8098
|
-
|
|
8099
|
+
...conversation,
|
|
8099
8100
|
personInput: userActor
|
|
8100
8101
|
}).idleNeedsPendingWork;
|
|
8101
8102
|
idle = {
|
|
@@ -8153,7 +8154,10 @@ async function replayConversations(conversations, args) {
|
|
|
8153
8154
|
const events = byConversation(rows);
|
|
8154
8155
|
const childrenByParent = byConversation(children);
|
|
8155
8156
|
for (const conversation of batch) {
|
|
8156
|
-
const replayed = replayConversation(
|
|
8157
|
+
const replayed = replayConversation({
|
|
8158
|
+
kind: conversationKindFromRow(conversation),
|
|
8159
|
+
hasParent: !isTopLevel({ parentConversationId: conversation.parentConversationId ?? void 0 })
|
|
8160
|
+
}, events.get(conversation.conversationId) ?? [], childrenByParent.get(conversation.conversationId) ?? [], nowMs);
|
|
8157
8161
|
const inScanWindow = (period) => period.sinceMs >= windowStartMs;
|
|
8158
8162
|
periods.push(...replayed.periods.filter(inScanWindow));
|
|
8159
8163
|
toolWaits.push(...replayed.toolWaits.filter(inScanWindow));
|
|
@@ -10279,148 +10283,6 @@ async function renameConversation(viewer, conversationId, body) {
|
|
|
10279
10283
|
if (!title) throwApiError(404, "Conversation not found.");
|
|
10280
10284
|
return { title };
|
|
10281
10285
|
}
|
|
10282
|
-
// src/chat/spaces/conversations.ts
|
|
10283
|
-
/**
|
|
10284
|
-
* Conversations in a Space (`design/spaces.md`). Only a root stores its
|
|
10285
|
-
* Space. A child is in the Space of its root, so the two never disagree.
|
|
10286
|
-
*/
|
|
10287
|
-
const spaceRoot$1 = alias(juniorConversations, "space_root");
|
|
10288
|
-
/** Read the id and name of each Space, by id. A missing id has no entry. */
|
|
10289
|
-
async function readSpaceRefs(db, spaceIds) {
|
|
10290
|
-
const ids = [...new Set(spaceIds)];
|
|
10291
|
-
if (ids.length === 0) return /* @__PURE__ */ new Map();
|
|
10292
|
-
const rows = await db.select({
|
|
10293
|
-
id: juniorSpaces.id,
|
|
10294
|
-
name: juniorSpaces.name
|
|
10295
|
-
}).from(juniorSpaces).where(inArray(juniorSpaces.id, ids));
|
|
10296
|
-
return new Map(rows.map((row) => [row.id, row]));
|
|
10297
|
-
}
|
|
10298
|
-
/**
|
|
10299
|
-
* Put one root in a Space, or take it out of every Space with null. The root
|
|
10300
|
-
* gets the Space's visibility on its own Location. The caller checks who may
|
|
10301
|
-
* move it out of `fromSpaceId`, the Space that it read before the move.
|
|
10302
|
-
*/
|
|
10303
|
-
async function setConversationSpace(conversationId, spaceId, fromSpaceId) {
|
|
10304
|
-
const executor = getSqlExecutor();
|
|
10305
|
-
return await executor.transaction(async () => {
|
|
10306
|
-
const db = executor.db();
|
|
10307
|
-
const [root] = await db.select({
|
|
10308
|
-
locationId: juniorConversations.destinationId,
|
|
10309
|
-
provider: juniorDestinations.provider,
|
|
10310
|
-
spaceId: juniorConversations.spaceId
|
|
10311
|
-
}).from(juniorConversations).leftJoin(juniorDestinations, eq(juniorDestinations.id, juniorConversations.destinationId)).where(and(eq(juniorConversations.conversationId, conversationId), isNull(juniorConversations.parentConversationId))).limit(1).for("update", { of: juniorConversations });
|
|
10312
|
-
if (!root) return "not_found";
|
|
10313
|
-
if (root.spaceId !== fromSpaceId) return "moved";
|
|
10314
|
-
const spaceIds = [root.spaceId, spaceId].filter((id) => id !== null);
|
|
10315
|
-
const spaces = spaceIds.length > 0 ? await db.select({
|
|
10316
|
-
id: juniorSpaces.id,
|
|
10317
|
-
visibility: juniorSpaces.visibility
|
|
10318
|
-
}).from(juniorSpaces).where(inArray(juniorSpaces.id, spaceIds)) : [];
|
|
10319
|
-
if (spaces.find((space) => space.id === root.spaceId)?.visibility === "private") return "leaves_private";
|
|
10320
|
-
if (spaces.find((space) => space.id === spaceId)?.visibility === "private") {
|
|
10321
|
-
if (root.provider !== "local" || !root.locationId) return "shared_location";
|
|
10322
|
-
await db.update(juniorDestinations).set({
|
|
10323
|
-
visibility: "private",
|
|
10324
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
10325
|
-
}).where(eq(juniorDestinations.id, root.locationId));
|
|
10326
|
-
}
|
|
10327
|
-
await db.update(juniorConversations).set({
|
|
10328
|
-
spaceId,
|
|
10329
|
-
detailVersion: nextDetailVersion
|
|
10330
|
-
}).where(eq(juniorConversations.conversationId, conversationId));
|
|
10331
|
-
});
|
|
10332
|
-
}
|
|
10333
|
-
/**
|
|
10334
|
-
* Every Conversation in the Space, at any depth. A root from before
|
|
10335
|
-
* `root_conversation_id` was set matches by its own id.
|
|
10336
|
-
*/
|
|
10337
|
-
function inSpaceTrees(db, spaceId) {
|
|
10338
|
-
const roots = db.select({ id: spaceRoot$1.conversationId }).from(spaceRoot$1).where(eq(spaceRoot$1.spaceId, spaceId));
|
|
10339
|
-
return or(inArray(juniorConversations.rootConversationId, roots), inArray(juniorConversations.conversationId, roots));
|
|
10340
|
-
}
|
|
10341
|
-
/**
|
|
10342
|
-
* Archive or restore a Space with its Conversations.
|
|
10343
|
-
*
|
|
10344
|
-
* Archive writes one time to the Space and to each unarchived Conversation
|
|
10345
|
-
* in it, at any depth. Then it stops each root that is not stopped, with the
|
|
10346
|
-
* child agents below it, so no work in the Space keeps running. A retry
|
|
10347
|
-
* stops what an earlier try left running.
|
|
10348
|
-
*
|
|
10349
|
-
* Restore clears the Space and the Conversations that its archive wrote. A
|
|
10350
|
-
* Conversation that was archived on its own stays archived. Restore starts
|
|
10351
|
-
* no work.
|
|
10352
|
-
*/
|
|
10353
|
-
async function setSpaceArchive(args) {
|
|
10354
|
-
const executor = getSqlExecutor();
|
|
10355
|
-
await executor.transaction(async () => {
|
|
10356
|
-
const db = executor.db();
|
|
10357
|
-
const [space] = await db.select({ archivedAt: juniorSpaces.archivedAt }).from(juniorSpaces).where(eq(juniorSpaces.id, args.spaceId)).limit(1).for("update");
|
|
10358
|
-
if (!space) return;
|
|
10359
|
-
const now = /* @__PURE__ */ new Date();
|
|
10360
|
-
if (args.archived) {
|
|
10361
|
-
if (space.archivedAt) return;
|
|
10362
|
-
await db.update(juniorSpaces).set({
|
|
10363
|
-
archivedAt: now,
|
|
10364
|
-
updatedAt: now
|
|
10365
|
-
}).where(eq(juniorSpaces.id, args.spaceId));
|
|
10366
|
-
await setArchivedAt(db, inSpaceTrees(db, args.spaceId), now, isNull(juniorConversations.archivedAt));
|
|
10367
|
-
return;
|
|
10368
|
-
}
|
|
10369
|
-
if (!space.archivedAt) return;
|
|
10370
|
-
await db.update(juniorSpaces).set({
|
|
10371
|
-
archivedAt: null,
|
|
10372
|
-
updatedAt: now
|
|
10373
|
-
}).where(eq(juniorSpaces.id, args.spaceId));
|
|
10374
|
-
await setArchivedAt(db, inSpaceTrees(db, args.spaceId), null, eq(juniorConversations.archivedAt, space.archivedAt));
|
|
10375
|
-
});
|
|
10376
|
-
if (!args.archived) return;
|
|
10377
|
-
const running = await getDb().select({ conversationId: juniorConversations.conversationId }).from(juniorConversations).where(and(eq(juniorConversations.spaceId, args.spaceId), isNull(juniorConversations.stoppedAt)));
|
|
10378
|
-
await mapBounded(running, ({ conversationId }) => stopConversation({
|
|
10379
|
-
conversationId,
|
|
10380
|
-
queue: args.queue
|
|
10381
|
-
}));
|
|
10382
|
-
}
|
|
10383
|
-
// src/api/conversations/space.ts
|
|
10384
|
-
/**
|
|
10385
|
-
* Return the Space that the viewer puts work in. Only a member starts or
|
|
10386
|
-
* moves work into a Space, and an archived Space takes no new work.
|
|
10387
|
-
*/
|
|
10388
|
-
async function requireSpaceForWork(viewer, spaceId) {
|
|
10389
|
-
const space = await readSpace(viewer.id, spaceId);
|
|
10390
|
-
if (!space) throwApiError(404, "Space was not found.");
|
|
10391
|
-
if (space.archivedAt) throwApiError(409, "Restore the Space before you add work to it.");
|
|
10392
|
-
if (!space.viewerIsMember) throwApiError(403, "Join the Space to add work to it.");
|
|
10393
|
-
return space;
|
|
10394
|
-
}
|
|
10395
|
-
/**
|
|
10396
|
-
* Put one root Conversation in a Space, or make it a one-off with null.
|
|
10397
|
-
* Only a participant moves it. They must be a member of the Space that it
|
|
10398
|
-
* leaves and of the Space that it joins. Only a public root joins a Space.
|
|
10399
|
-
* A root in a private Space stays there, so its data stays with the members.
|
|
10400
|
-
*/
|
|
10401
|
-
async function setConversationSpaceForViewer(viewer, conversationId, body) {
|
|
10402
|
-
const [conversation, access] = await Promise.all([getConversationStore().get({ conversationId }), readConversationAccessFromSql(getDb(), [conversationId], viewer).then((byId) => byId.get(conversationId))]);
|
|
10403
|
-
if (!conversation || !access?.isParticipant) throwApiError(404, "Conversation not found.");
|
|
10404
|
-
if (!canMoveToSpace(conversation)) throwApiError(409, "Only a top-level conversation moves. A child is in the Space of its root.");
|
|
10405
|
-
const currentSpaceId = conversation.spaceId ?? null;
|
|
10406
|
-
const target = body.spaceId ? await requireSpaceForWork(viewer, body.spaceId) : void 0;
|
|
10407
|
-
const response = { space: target ? {
|
|
10408
|
-
id: target.id,
|
|
10409
|
-
name: target.name
|
|
10410
|
-
} : null };
|
|
10411
|
-
if (body.spaceId === currentSpaceId) return response;
|
|
10412
|
-
if (currentSpaceId) {
|
|
10413
|
-
const source = await readSpace(viewer.id, currentSpaceId);
|
|
10414
|
-
if (source && !source.viewerIsMember) throwApiError(403, "Join the Space that it is in to move it.");
|
|
10415
|
-
}
|
|
10416
|
-
if (target && access.visibility !== "public") throwApiError(409, "Only a public conversation can join a Space.");
|
|
10417
|
-
const refusal = await setConversationSpace(conversationId, body.spaceId, currentSpaceId);
|
|
10418
|
-
if (refusal === "not_found") throwApiError(404, "Conversation not found.");
|
|
10419
|
-
if (refusal === "moved") throwApiError(409, "It moved to another Space. Reload and try again.");
|
|
10420
|
-
if (refusal === "leaves_private") throwApiError(409, "A conversation in a private Space stays in it.");
|
|
10421
|
-
if (refusal === "shared_location") throwApiError(409, "A Slack conversation can't join a private Space.");
|
|
10422
|
-
return response;
|
|
10423
|
-
}
|
|
10424
10286
|
// src/api/conversations/stop.ts
|
|
10425
10287
|
/**
|
|
10426
10288
|
* Stop one Conversation for a participant: its active Turn, its session, and
|
|
@@ -10548,6 +10410,20 @@ const setConversationAutoArchiveOperation = defineApiOperation({
|
|
|
10548
10410
|
annotations: writeAnnotations,
|
|
10549
10411
|
run: (viewer, { autoArchive, conversationId }) => setConversationAutoArchive(viewer, conversationId, autoArchive)
|
|
10550
10412
|
});
|
|
10413
|
+
/** The viewer leaves a Conversation. Nobody removes another person. */
|
|
10414
|
+
const leaveConversationOperation = defineApiOperation({
|
|
10415
|
+
name: "leaveConversation",
|
|
10416
|
+
title: "Leave conversation",
|
|
10417
|
+
description: "Leave one of your conversations. It leaves your feed and clears your pin. In a private conversation you also lose access, and only another participant can invite you back. A public one stays readable, and you can subscribe again. When nobody else is subscribed, it archives the conversation for everyone.",
|
|
10418
|
+
scope: "conversations:manage",
|
|
10419
|
+
input: z.object(conversationIdInput).strict(),
|
|
10420
|
+
output: conversationLeaveResponseSchema,
|
|
10421
|
+
annotations: {
|
|
10422
|
+
...writeAnnotations,
|
|
10423
|
+
destructiveHint: true
|
|
10424
|
+
},
|
|
10425
|
+
run: (viewer, { conversationId }) => leaveConversation(viewer, conversationId)
|
|
10426
|
+
});
|
|
10551
10427
|
/** Subscribe or unsubscribe the viewer. It never changes another person. */
|
|
10552
10428
|
const setConversationSubscriptionOperation = defineApiOperation({
|
|
10553
10429
|
name: "setConversationSubscription",
|
|
@@ -10592,6 +10468,7 @@ const conversationOperations = [
|
|
|
10592
10468
|
cancelQueuedMessagesOperation,
|
|
10593
10469
|
archiveConversationOperation,
|
|
10594
10470
|
archiveDoneConversationsOperation,
|
|
10471
|
+
leaveConversationOperation,
|
|
10595
10472
|
pinConversationOperation,
|
|
10596
10473
|
renameConversationOperation,
|
|
10597
10474
|
setConversationAutoArchiveOperation,
|
|
@@ -11303,18 +11180,21 @@ async function readConversationAgentTree(conversation, readAccess) {
|
|
|
11303
11180
|
]);
|
|
11304
11181
|
return await mapBounded(ids, async (id) => {
|
|
11305
11182
|
const itemAccess = access.get(id);
|
|
11306
|
-
if (rootRecord && root?.conversationId === id)
|
|
11307
|
-
|
|
11308
|
-
kind: "root",
|
|
11309
|
-
label: conversationSummaryFromStoredConversation({
|
|
11183
|
+
if (rootRecord && root?.conversationId === id) {
|
|
11184
|
+
const summary = conversationSummaryFromStoredConversation({
|
|
11310
11185
|
access: itemAccess,
|
|
11311
11186
|
automationTitle: automationTitleByConversation.get(id),
|
|
11312
11187
|
conversation: root,
|
|
11313
11188
|
durationMs: 0,
|
|
11314
11189
|
firstHumanMessageText: firstHumanMessageTextByConversation.get(id),
|
|
11315
11190
|
status: rootRecord.status
|
|
11316
|
-
})
|
|
11317
|
-
|
|
11191
|
+
});
|
|
11192
|
+
return {
|
|
11193
|
+
conversationId: id,
|
|
11194
|
+
kind: root.kind,
|
|
11195
|
+
label: summary.displayTitle
|
|
11196
|
+
};
|
|
11197
|
+
}
|
|
11318
11198
|
const kind = kindById.get(id);
|
|
11319
11199
|
if (!itemAccess?.canViewPrivateContent) return {
|
|
11320
11200
|
conversationId: id,
|
|
@@ -12329,6 +12209,8 @@ async function readConversationDetailFromSql(conversationId, options) {
|
|
|
12329
12209
|
...report.isParticipant && state.autoArchive !== void 0 ? { autoArchive: state.autoArchive } : void 0,
|
|
12330
12210
|
...report.isParticipant && state.subscribed !== void 0 ? { subscribed: state.subscribed } : void 0,
|
|
12331
12211
|
...canContinueInSlack(record.conversation, access) ? { canContinueInSlack: true } : void 0,
|
|
12212
|
+
...canInviteToConversation(access) ? { canInvite: true } : void 0,
|
|
12213
|
+
...leaveEndsAccess(access) ? { leaveEndsAccess: true } : void 0,
|
|
12332
12214
|
...report.isParticipant && canPauseConversationDelivery(record.conversation) ? { deliveryPaused: record.conversation.deliveryPausedAtMs !== void 0 } : void 0
|
|
12333
12215
|
};
|
|
12334
12216
|
}
|
|
@@ -12374,7 +12256,7 @@ function findThreadPlacement(threadId, tree, rootIds) {
|
|
|
12374
12256
|
for (const ancestor of conversationAncestors(tree, threadId)) {
|
|
12375
12257
|
if (rootIds.has(ancestor.conversationId)) return placement ?? ancestor.conversationId;
|
|
12376
12258
|
if (ancestor.archivedAt) return void 0;
|
|
12377
|
-
if (ancestor
|
|
12259
|
+
if (isThread(ancestor)) placement ??= ancestor.conversationId;
|
|
12378
12260
|
}
|
|
12379
12261
|
}
|
|
12380
12262
|
/**
|
|
@@ -12385,7 +12267,7 @@ function findThreadPlacement(threadId, tree, rootIds) {
|
|
|
12385
12267
|
*/
|
|
12386
12268
|
async function readFeedThreadRecords(db, rootIds) {
|
|
12387
12269
|
if (rootIds.length === 0) return void 0;
|
|
12388
|
-
const rows = await selectConversationRecords(db).where(and(inArray(juniorConversations.rootConversationId, rootIds), eq(juniorConversations.kind, "thread"), isNull(juniorConversations.archivedAt))).orderBy(desc(juniorConversations.lastActivityAt), asc(juniorConversations.conversationId));
|
|
12270
|
+
const rows = await selectConversationRecords(db).where(and(inArray(juniorConversations.rootConversationId, rootIds), eq(juniorConversations.kind, "thread"), isNotNull(juniorConversations.parentConversationId), isNull(juniorConversations.archivedAt))).orderBy(desc(juniorConversations.lastActivityAt), asc(juniorConversations.conversationId));
|
|
12389
12271
|
if (rows.length === 0) return void 0;
|
|
12390
12272
|
const threads = rows.map((row) => ({
|
|
12391
12273
|
conversation: conversationFromRecordRow(row),
|
|
@@ -12743,7 +12625,7 @@ async function conversationRows(db, { codeRepository, conversationIds, cursor, f
|
|
|
12743
12625
|
links: include.includes("links") ? feedLinksSql(db) : sql`null`,
|
|
12744
12626
|
media: include.includes("media") ? feedMediaSql(db) : sql`null`,
|
|
12745
12627
|
viewerAnswer: filter?.kind === "viewer" ? feedViewerAnswerSql(db, filter.userId) : sql`null`
|
|
12746
|
-
}).from(juniorConversations).leftJoin(juniorDestinations, conversationRecordJoins.location).leftJoin(juniorIdentities, conversationRecordJoins.identity).leftJoin(juniorUsers, conversationRecordJoins.user).where(and(listedConversation(), space ? conversationSpaceFilter(space.id, status, space.viewerUserId) : 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 :
|
|
12628
|
+
}).from(juniorConversations).leftJoin(juniorDestinations, conversationRecordJoins.location).leftJoin(juniorIdentities, conversationRecordJoins.identity).leftJoin(juniorUsers, conversationRecordJoins.user).where(and(listedConversation(), space ? conversationSpaceFilter(space.id, status, space.viewerUserId) : 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();
|
|
12747
12629
|
return limit === void 0 ? rows : rows.limit(limit);
|
|
12748
12630
|
}
|
|
12749
12631
|
const searchAnnotated = alias(juniorConversations, "search_annotated");
|
|
@@ -12755,7 +12637,7 @@ const searchAnnotated = alias(juniorConversations, "search_annotated");
|
|
|
12755
12637
|
*/
|
|
12756
12638
|
function annotationMatch(db, query, includePrivate) {
|
|
12757
12639
|
const annotation = juniorConversationAnnotations.annotation;
|
|
12758
|
-
return exists(db.select({ one: sql`1` }).from(juniorConversationAnnotations).innerJoin(searchAnnotated, eq(searchAnnotated.conversationId, juniorConversationAnnotations.conversationId)).where(and(eq(searchAnnotated.rootConversationId, juniorConversations.conversationId), includePrivate ? void 0 :
|
|
12640
|
+
return exists(db.select({ one: sql`1` }).from(juniorConversationAnnotations).innerJoin(searchAnnotated, eq(searchAnnotated.conversationId, juniorConversationAnnotations.conversationId)).where(and(eq(searchAnnotated.rootConversationId, juniorConversations.conversationId), includePrivate ? void 0 : isPublicConversation(juniorConversations), sql`strpos(lower(concat_ws(' ', ${annotation}->>'label', ${annotation}->>'title')), ${query}) > 0`)));
|
|
12759
12641
|
}
|
|
12760
12642
|
/**
|
|
12761
12643
|
* Feed rows show last activity only as an age in whole minutes. A running
|
|
@@ -13058,4 +12940,4 @@ async function readConversationFeedFromSql(options = {}) {
|
|
|
13058
12940
|
async function readConversationFeed(options = {}) {
|
|
13059
12941
|
return readConversationFeedFromSql(options);
|
|
13060
12942
|
}
|
|
13061
|
-
export {
|
|
12943
|
+
export { closeInboxItemsAnsweredByReply as $, createViewerMcp as $t, setConversationAutoArchiveOperation as A, createProductionConversationWorkOptions as At, mcpConversationSchema as B, failStoppedDispatch as Bt, archiveConversationOperation as C, readObjectLinkTypes as Ct, leaveConversationOperation as D, guardedFetch as Dt, conversationOperations as E, viewerCanViewPluginLink as Et, apiOperationHandler as F, slackInboundMessageId as Ft, mcpMessages as G, stripLeadingBotMention as Gt, mcpIdempotencyKeySchema as H, createSlackWebApiStatusSender as Ht, mcpAcceptedMessageSchema as I, normalizeIncomingSlackThreadId as It, readMcpPendingWorkAfterSend as J, getThreadStopDecision as Jt, mcpPendingMessagesSchema as K, parseContent as Kt, mcpAuthorizationSchema as L, withNormalizedThreadId as Lt, setConversationSubscriptionOperation as M, getProductionSlackAdapter as Mt, stopConversationOperation as N, buildSlackInboundMessage as Nt, pinConversationOperation as O, isPublicAddress as Ot, reorderPinnedConversations as P, clearSlackPendingReactions as Pt, actOnInboxItem as Q, readFirstHumanMessageTexts as Qt, mcpConversation as R, AGENT_DISPATCH_MAX_AGE_MS as Rt, encodeConversationCursor as S, readLinkObjectType as St, cancelQueuedMessagesOperation as T, resolveObjectLinks as Tt, mcpMessageSchema as U, bindMessageAuthorIdentityId as Ut, mcpCursorSchema as V, recordSkippedConversationMessage as Vt, mcpMessageTextSchema as W, startProcessingReaction as Wt, resolveMentions as X, readConversationRecordFromSql as Xt, requireConversationPendingMessages as Y, resolvePersonLink as Yt, InboxItemActionError as Z, conversationSummaryFromStoredConversation as Zt, readConversationEvents as _, startSavingsRefill as _t, listWaitingConversations as a, DEFAULT_USER_SETTINGS as at, requireWebMessageConversation as b, readHealthReport as bt, readConversationDetail as c, automationReplyAttribution as ct, childAgentTotalsReport as d, dispatchScheduledAutomation as dt, IMAGE_WIDTHS as en, readInboxItemForUser as et, readConversationTreeMetricsFromSql as f, getScheduledAutomationDispatch as ft, keepQuickQuestionForViewer as g, runSavingsRefillSlice as gt, forkConversationForViewer as h, readSavingsRefill as ht, encodePageCursor as i, runAutoArchiveSweep as it, setConversationSpaceOperation as j, createProductionSlackWebhookServices as jt, renameConversationOperation as k, publicAddressLookup as kt, readConversationTreeStates as l, settleEventAutomationRuns as lt, readConversationDetailEtag as m, scheduleInboxSnoozeTimer as mt, readConversationFeed as n, createEventAppPublisher as nt, listedConversation as o, readUserSettings as ot, conversationVersionsQuery as p, runInboxSnoozeTimers as pt, readMcpPendingWork as q, SubscribedReplyReason as qt, decodePageCursor as r, ingestEventAutomations as rt, notLeadConversation as s, updateUserSettings as st, conversationFeedVersionQuery as t, decodeImageId as tn, reviewItemChange as tt, readConversationAuxiliaryCostsFromSql as u, createHeartbeatContext as ut, appendConversationMessageForViewer as v, backfillCacheWarmingGaps as vt, archiveDoneConversationsOperation as w, resolveObjectLinkNow as wt, decodeConversationCursor as x, OBJECT_LINK_TTL_MS as xt, createConversationForViewer as y, GET as yt, mcpConversationIdSchema as z, enqueueAgentDispatch as zt };
|