@sentry/junior 0.288.0 → 0.290.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-Cikcqdty.js → adapter-CHMVy-j0.js} +1 -1
- package/dist/{admin-BcSxHuTB.js → admin-C45Ap5Tn.js} +2 -2
- package/dist/{agent-runner-9MXyWUL8.js → agent-runner-CZjf6MOQ.js} +343 -103
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +6 -7
- package/dist/api.d.ts +1 -1
- package/dist/api.js +281 -254
- package/dist/{app-BUklJVBe.d.ts → app-BB1j2krL.d.ts} +2 -4
- package/dist/app.d.ts +1 -1
- package/dist/app.js +92 -64
- package/dist/assistant-reply-BtIV0hq6.js +58 -0
- package/dist/{automation-DDXwHQs5.js → automation-DWbjJltM.js} +1 -1
- package/dist/{background-compaction-queue-CjllSPir.js → background-compaction-queue-2gKhjRD3.js} +4 -4
- package/dist/{briefs-DW9iuolG.js → briefs-BGke_Cz5.js} +3 -4
- package/dist/{catalog-runtime-B3gfH58M.js → catalog-runtime-BSOlVfXi.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 +4 -4
- package/dist/{config-CLJcyYEF.js → config-DHDub41t.js} +4 -41
- package/dist/{connections-BtdJftow.js → connections-BAb0fedk.js} +7 -129
- package/dist/{conversation-DhoqHtQ7.js → conversation-CwC8K3RZ.js} +8 -8
- package/dist/{conversation-pending-messages-DHV0S4uF.js → conversation-pending-messages-B0cuLReP.js} +1 -1
- package/dist/{conversation-privacy-BPirIVlX.js → conversation-privacy-QRdLPH-9.js} +1 -1
- package/dist/{credential-sync-Co8Q2xRW.js → credential-sync-YIMGiRk7.js} +13 -13
- package/dist/{db-Co7DTYYh.js → db-DBHig2sI.js} +56 -31
- package/dist/{db-zIs8-Ba3.d.ts → db-DCSmv9tz.d.ts} +6 -2
- package/dist/{executor-m0kIN71Q.js → executor-DKrtH0k_.js} +62 -13
- package/dist/instrumentation.js +2 -2
- package/dist/{logging-DbD-dErY.js → logging-f24cZPEj.js} +2 -2
- package/dist/{history-IjdmO_r6.js → media-BepyEUNm.js} +85 -1
- package/dist/{message-DKTdTYm-.js → message-BbBOajiX.js} +9 -9
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-CpbepSbp.js → oauth-callback-server-rHJYjFoz.js} +2 -2
- package/dist/{projection-BViECfYu.js → projection-D-9aVaHj.js} +153 -119
- package/dist/{prompt-KT6MaDHN.js → prompt-C7SZhNDy.js} +183 -3
- package/dist/{registry-D-Acyjhh.js → registry-CwA-kSjW.js} +1 -1
- package/dist/{resolve-gkT2R66z.js → resolve-B5WJgt9k.js} +3 -3
- package/dist/{result-DHmCFEt8.js → result-B2sCVIwl.js} +16 -10
- package/dist/{runner-DBKjGjH-.js → runner-CZq7wyIh.js} +8 -8
- package/dist/{sandbox-egress-signals-9n8hqx29.js → sandbox-egress-signals-C4d6Pa9a.js} +1 -1
- package/dist/{schema-DxicIQbc.js → schema-Bptz19Ja.js} +14 -9
- package/dist/{schema-B_6aOcx5.d.ts → schema-DQaFSkZZ.d.ts} +13 -5
- package/dist/{service-account-CDlC9ssy.js → service-account-B6OJtplS.js} +3 -3
- package/dist/{service-account-Bi0HsY6w.js → service-account-BC73M8rj.js} +3 -3
- package/dist/{session-stop-BWOsuo8p.js → session-stop-1cku9Vm3.js} +41 -30
- package/dist/{skills-DO5K68Rq.js → skills-BFopj5ID.js} +2 -2
- package/dist/{spawn-BBqZDcPa.js → spawn-B-1JlJwH.js} +5 -5
- package/dist/{stop-WC97cmHz.js → stop-CJweYiOH.js} +123 -213
- package/dist/{store-ByR1Lr7e.js → store-CK869JpC.js} +3 -3
- package/dist/{task-runner-B-Ewf8TX.js → task-runner-XmXL9E-k.js} +13 -17
- package/dist/{turn-failure-response-CpdPoZSl.js → turn-failure-response-hhpek6Fn.js} +8 -8
- package/dist/{validation-B4sbIoES.js → validation-DHQjCRFx.js} +1 -1
- package/dist/{version-D6lpuAgL.js → version-DQgCf4FE.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-CeP27tC3.js → viewer-DG97nzP4.js} +4 -4
- package/dist/{warmup-P_GJCL1c.js → warmup-C00-jOoN.js} +272 -78
- package/dist/{work-DI7x1Slm.js → work-Ch3EWO6u.js} +14 -14
- package/dist/{worker-CYPTOT4j.js → worker-B8kyM1fB.js} +6 -30
- package/migrations/0091_conversation_participant_unsubscribed_index.sql +20 -0
- package/migrations/0092_turn_metric_actor.sql +12 -0
- package/migrations/0093_participant_root_actor_backfill.sql +18 -0
- package/migrations/0094_conversation_delivery_paused_at.sql +1 -0
- package/migrations/meta/0091_snapshot.json +4410 -0
- package/migrations/meta/0092_snapshot.json +4446 -0
- package/migrations/meta/0093_snapshot.json +4446 -0
- package/migrations/meta/0094_snapshot.json +4452 -0
- package/migrations/meta/_journal.json +28 -0
- package/package.json +5 -5
- package/dist/assistant-reply-mj47jMRV.js +0 -65
- package/dist/core-model-BTt5E5b0.js +0 -182
- package/dist/media-BAHvgkok.js +0 -85
|
@@ -1,35 +1,33 @@
|
|
|
1
1
|
import { g as withActiveSpan, h as startSpan, i as getActiveSpan, m as startInactiveSpan, r as continueTrace, v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { $ as
|
|
3
|
-
import { A as
|
|
4
|
-
import { C as summarizeMessageText, E as withSpan, G as
|
|
5
|
-
import { a as toCanonicalInputMessage, c as toGenAiPayloadMetadata, i as runWithConversationPrivacy, l as toGenAiPayloadTraceAttributes, o as toCanonicalOutputMessage, r as resolveConversationPrivacy, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-
|
|
2
|
+
import { $ as loadTurnCheckpoint, $a as readConversationAccessFromSql, $t as extractAssistantText, A as latestConversationMessageSeq, Aa as SANDBOX_RUNTIME, Ar as resolveAssignee, B as getAgentContextInputLimitTokens, Ba as SANDBOX_SKILLS_ROOT, Bi as slackMention, Ca as consumeSandboxEgressPermissionDeniedSignal, Ci as setWorkspaceSnapshotBuild, Co as saveObjectAnnotations, Da as buildSandboxEgressNetworkPolicy, Di as ensureDockerDaemon, Dn as findLegacyWebActorUserId, Do as defaultTimezone, Dr as EVERYONE_ASSIGNEE, Ei as isStale, En as createUserTokenStore, Fo as piMessageFromHistoryItem, Fr as RESOURCE_SUBSCRIPTION_MAX_TTL_MS, G as AuthPausePersistenceError, Ga as buildCommandScript, Gi as openSlackDirectMessage, Gr as getWatch, Gt as TurnBudgetExceededError, H as PluginCredentialFailureError, Ha as sandboxSkillDir, Hi as addReactionToMessage, Hr as createWatch, I as upsertConversationMessage, Ii as escapeSlackMrkdwnText, Io as projectConversationEvents, Ir as RESOURCE_WATCH_TOOL_SOURCE, J as abandonReplacedPendingAuth, Ji as postSlackMessage, K as AuthorizationFlowDisabledError, Ka as buildNonInteractiveShellScript, Kr as listWatches, Kt as TurnSliceLimitExceededError, L as calculateContextCompactionTargetTokens, La as SANDBOX_COMMAND_PATH, Ln as getPluginTools, Lo as getConfigDefaults, Lr as STOP_WATCHING_TOOL_NAME, M as normalizeConversationText, Ma as tryWorkspaceRepoCheckoutPath, Mi as formatProviderLabel, Mn as createPluginHookRunner, Mr as resolveChannelCapabilities, N as recordDeliveredAssistantMessage, Na as workspaceRepoCheckoutPath, Nr as getSlackToolContext, Oa as resolveSandboxCommandEnvironment, Oi as getSandboxProvider, Oo as resolveUserTimezone, Or as activeParticipantUserIds, Pa as PluginToolDeniedError, Pi as resolveBaseUrl, Po as historyItemFromPiMessage, Pr as RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS, Q as continuableMessages, Qi as uploadFilesToConversation, Qt as persistWithRetry, R as getAgentBackgroundCompactionMarkTokens, Ra as SANDBOX_DATA_ROOT, Ri as normalizeSlackReplyMarkdown, Sa as consumeSandboxEgressAuthRequiredSignal, Si as setWorkspaceSnapshot, Sr as requireReviewItemLinks, T as resolveTaskTitle, Ti as hash, U as createPluginAuthOrchestration, Ua as sandboxSkillFile, Ui as deleteSlackMessage, Ur as deliverWatch, V as createPluginEgress, Va as SANDBOX_WORKSPACE_ROOT, Vr as createTimerWatch, W as authorizationId, Wa as sandboxSkillPathResolution, Wi as getSlackMessagePermalink, Wr as findMatchingWatches, Wt as TURN_LIMIT_WRAP_UP_MESSAGE, X as clearPendingAuth, Xa as canAccessConversation, Xt as isTurnExecutionLimitExceededError, Y as canReusePendingAuthLink, Yt as createTurnLimitGate, Zi as updateSlackMessage, Zt as CODEMODE_TOOL_NAME, _a as WorkspaceSnapshotNotReadyError, _n as TURN_CONTEXT_TAG, _r as canReadReviewItem, a as loadProjection, aa as getSlackClient, ar as getOpenReviewItemByDedupeKey, at as failTurnRecord, b as persistConversationMessages, ba as workspaceSnapshotNotReadyUserMessage, bi as invalidateReadySnapshot, bn as readParentAgentTask, br as readReviewItemAgentScope, c as recordAgentsInstructionsUpdated, ca as normalizeSlackConversationId, cn as isStandaloneRuntimeContextMessage, di as renderToolResultNudge, dn as normalizeToolNameFromResult, dr as searchReviewItems, ei as verifyTimerWatchCredentialSubject, en as getPiMessageRole, f as recordAuthorizationRequested, fi as createWorkspace, fn as retainRuntimeTurnContext, g as recordToolExecutionStarted, ga as wrapSandboxSetupError, gi as listWorkspaces, gr as canAgentChangeReviewItem, ha as throwSandboxOperationError, hi as getWorkspaceByName, hn as REQUEST_CONTEXT_SECTION_TAG, i as loadConversationProjection, ii as getDashboardReviewItemLink, in as hasTurnInput, ir as dismissOpenReviewItems, j as markConversationMessage, ja as sleep, ji as deliverOAuthAuthorization, jr as resolveAssignees, kn as getOAuthAccountProviders, kr as automationCreatorUserId, l as recordAttachmentsDelivered, la as runWithSlackInstallationToken, li as ToolInputError, ln as isToolResultError, m as recordMcpProviderConnected, ma as isAlreadyExistsError, mi as getWorkspace, mn as trimTrailingAssistantMessages, mr as PLUGIN_REVIEW_ITEM_KEY_PREFIX, na as downloadPrivateSlackFile, ni as getDashboardConversationLink, nn as getUserMessageInstructionText, nr as closeReviewItem, nt as saveTurnCheckpoint, oa as isConversationScopedChannel, oi as getDashboardTaskLink, on as isAssistantMessage, or as getReviewItem, ot as getTurnRecord, p as recordGuardianActionReviewed, pa as isAbortError, pi as deleteWorkspace, pn as stripRuntimeTurnContext, pr as updateReviewItemContent, q as AuthorizationPauseError, qa as runNonInteractiveCommand, qt as TurnToolCallLimitExceededError, r as loadConnectedMcpProviders, ra as getFilePermalink, rt as abandonTurnRecord, sn as isContinuablePiBoundary, sr as insertReviewItem, t as commitAcceptedReply, ta as SlackActionError, tn as getTerminalAssistantMessages, ua as withSlackRetries, un as isToolResultMessage, v as hydrateConversationMessages, va as getWorkspaceSnapshotNotReadyError, vi as updateWorkspace, vo as matchSlackAttachments, w as fallbackShortTitle, wa as createSandboxEgressCredentialToken, wi as create, wo as createPluginAnnotations, xa as clearSandboxEgressSignals, xi as loadSnapshotsForProfile, xr as requireReviewItemAssignees, ya as isWorkspaceSnapshotNotReadyError, yi as WorkspaceValidationError, z as getAgentContextCompactionTriggerTokens, za as SANDBOX_REPOS_ROOT, zn as getPlugins, zr as cancelWatch } from "./projection-D-9aVaHj.js";
|
|
3
|
+
import { A as estimateTextTokens, B as createProviderError, D as requestPrefixAttributes, E as resolveGatewayModel, G as getGatewayApiKey, H as getProviderErrorAttributes, I as unwrapCurrentInstruction, K as resolveGatewayCredential, L as escapeXml, M as COMPACTION_SUMMARY_PREFIX, N as hasCompactedConversationContext, O as estimateMessagesTokens, P as isCompactionSummaryText, V as findProviderError, W as isProviderRetryError, _ as toPiReasoningLevel, b as GEN_AI_SERVER_ADDRESS, g as TURN_REASONING_LEVELS, j as textCharsForTokens, k as estimateRequestOverheadTokens, n as botConfig, v as normalizeSlackEmojiName, y as GEN_AI_PROVIDER_NAME, z as ProviderError } from "./config-DHDub41t.js";
|
|
4
|
+
import { C as summarizeMessageText, E as withSpan, G as isRecord$4, S as setTags, T as withLogContext, V as runWithLogAttributes, W as normalizeIdentityEmail, _ as runBestEffort, a as extractGenAiUsageSummary, b as setSpanAttributes, d as logAudit, f as logError, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, l as getLogContextAttributesForSpan, m as logInfo, o as getActiveTraceContext, p as logException, q as toOptionalString, u as getTracePropagationHeaders, v as serializeGenAiAttribute, x as setSpanStatus } from "./logging-f24cZPEj.js";
|
|
5
|
+
import { a as toCanonicalInputMessage, c as toGenAiPayloadMetadata, i as runWithConversationPrivacy, l as toGenAiPayloadTraceAttributes, o as toCanonicalOutputMessage, r as resolveConversationPrivacy, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-QRdLPH-9.js";
|
|
6
6
|
import { d as parseSlackChannelReferenceId, f as parseSlackTeamId, h as parseSlackMessageTs, n as createSlackActor, o as isUserActor, p as parseSlackUserId, u as parseSlackChannelId } from "./actor-6jsm_v96.js";
|
|
7
|
-
import {
|
|
8
|
-
import { A as juniorConversations,
|
|
9
|
-
import {
|
|
7
|
+
import { $ as sameDestination, B as addAgentTurnUsage, D as resolveActorIdentityId, G as resolveRootConversationId$1, J as nextDetailVersion, T as SYSTEM_IDENTITY_ID, V as agentTurnCostUsd, W as hasAgentTurnUsage, Y as touchConversationDetail, Z as parseDestination, _ as setArchivedAt, a as getConversationStore, c as conversationIdsWithAnnotation, g as readConversationTrees, h as conversationDescendants, i as getConversationMessageSearchStore, l as hasAnnotationKey, m as conversationAncestors, o as getDb, q as conversationDetailTouch, r as getConversationEventStore, s as getSqlExecutor, u as treeHasAnnotationKey, x as conversationKindFromRow } from "./db-DBHig2sI.js";
|
|
8
|
+
import { A as juniorConversations, M as juniorUsers, N as juniorDestinations, P as juniorArtifacts, _ as juniorConversationReadPositions, b as juniorConversationBriefs, c as juniorReviewItemSlackCards, f as juniorAutomations, g as juniorAgentInvocations, h as juniorAgentBindings, j as juniorIdentities, k as juniorAttachments, p as juniorStats, u as juniorAutomationRuns, v as juniorConversationParticipants, w as juniorConversationEvents } from "./executor-DKrtH0k_.js";
|
|
9
|
+
import { _ as instructionProvenanceFor, a as KNOWN_CONVERSATION_EVENT_TYPES, g as instructionActors, h as contextProvenance, r as detectImageMediaType, v as sameActorIdentity } from "./media-BepyEUNm.js";
|
|
10
10
|
import { a as listReferenceFiles } from "./package-discovery-DJhGdS4c.js";
|
|
11
|
-
import { c as fetchWithBoundedOAuthErrorBodies, d as actorLogContext, f as credentialContextForActor, g as credentialUserSubjectId, i as resolvePluginHeaderEnvRefs, l as getOAuthProviderErrorAttributes, s as OAuthProviderError } from "./registry-
|
|
12
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
13
|
-
import { a as parseSkillInvocation, i as parseSkillFile, n as findSkillByName, r as loadSkillsByName, t as discoverSkills } from "./skills-
|
|
14
|
-
import {
|
|
11
|
+
import { c as fetchWithBoundedOAuthErrorBodies, d as actorLogContext, f as credentialContextForActor, g as credentialUserSubjectId, i as resolvePluginHeaderEnvRefs, l as getOAuthProviderErrorAttributes, s as OAuthProviderError } from "./registry-CwA-kSjW.js";
|
|
12
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-BSOlVfXi.js";
|
|
13
|
+
import { a as parseSkillInvocation, i as parseSkillFile, n as findSkillByName, r as loadSkillsByName, t as discoverSkills } from "./skills-BFopj5ID.js";
|
|
14
|
+
import { l as completeObject, o as isEventConversationMessage, r as EVENT_AUTHOR_ID, u as completeText } from "./prompt-C7SZhNDy.js";
|
|
15
15
|
import { a as withLock, i as fenceLock } from "./locks-D-0h111u.js";
|
|
16
|
-
import { a as readActorIdentityFromSql, f as identityAvatarUrl, h as readUserAvatarUrls, i as readActorIdentity } from "./viewer-
|
|
17
|
-
import { r as getStateAdapter } from "./adapter-
|
|
16
|
+
import { a as readActorIdentityFromSql, f as identityAvatarUrl, h as readUserAvatarUrls, i as readActorIdentity } from "./viewer-DG97nzP4.js";
|
|
17
|
+
import { r as getStateAdapter } from "./adapter-CHMVy-j0.js";
|
|
18
18
|
import { i as getFirstRunAtMs, o as getZonedDateTimeParts, s as isValidTimeZone } from "./schedule-cP0AACm1.js";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { i as
|
|
23
|
-
import {
|
|
24
|
-
import { B as
|
|
25
|
-
import { i as NO_REPLY_MARKER, n as getAssistantReplyText, o as isNoReplyMarker, r as sanitizeAssistantText, t as decideReply } from "./assistant-reply-mj47jMRV.js";
|
|
26
|
-
import { $ as withoutSavedSteeringMessages, A as requireSlackChannelMessageScope, B as maybePostAutomatedTurnLimitNotice, C as enqueueEventNotification, D as timerWatchCredentialSubject, E as renderEventBatchInputs, F as WORKSPACE_SNAPSHOT_FAILED_EVENT, H as resolveSlackReplyTarget, I as WORKSPACE_SNAPSHOT_READY_EVENT, J as assemblePrompt, K as recordFinishedTurnForAutomatedLimit, L as workspaceSnapshotFinishedEvent, O as getEventCatalog, P as slackChannelMessageTrigger, Q as loadPromptTurnContext, R as workspaceSnapshotWatch, S as EVENT_WAIT_MS, T as isEventMailboxMetadata, X as buildSteeringPiMessage, Y as buildPromptInput, Z as instructionForInputs, _ as sourceFromTurnInput, at as addConversationNote, b as conversationSubtree, c as loadReviewItemInput, ct as readBlockedReport, d as getAuthPausedConversationTurnId, f as getEventBatchDelayMs, ht as remindMissingAutomationResult, lt as FINISH_AUTOMATION_RUN_TOOL_NAME, mt as readAutomationResult, ot as JUNIOR_PERSONALITY, p as listActiveMailboxTurns, r as markConversationsStopped, rt as isExperimentalFeatureEnabled, s as eventReviewItemInputs, st as REPORT_BLOCKED_TOOL_NAME, t as getConversationStoppedAtMs, tt as saveUserCustomization, ut as automationResultSchema$1, v as turnInputFactsFromConversationMessage, w as eventBatchMessageMeta, x as conversationSubtreeColumns, y as legacyWebMailboxMetadataSchema } from "./session-stop-BWOsuo8p.js";
|
|
19
|
+
import { K as briefLinkSchema, W as readMessageAttachments, Z as parseStoredBrief, q as briefOutcomeStatusSchema, z as removedCardSchema } from "./conversation-CwC8K3RZ.js";
|
|
20
|
+
import { i as createCacheWarmingRecorder, l as readLastUserMessageAtByConversation } from "./warmup-C00-jOoN.js";
|
|
21
|
+
import { D as QUEUE_SIGNATURE_MAX_AGE_MS, g as getVercelConversationWorkQueue, k as getTurnRequestDeadline, m as sendWorkspaceSnapshotJob, n as backgroundCompactionId, p as sendNextWorkspaceSnapshotJob } from "./background-compaction-queue-2gKhjRD3.js";
|
|
22
|
+
import { B as AGENT_TYPES, C as isTerminalAgentInvocation, F as CHILD_AGENT_RESULTS, I as PARENT_AGENT_TARGET, J as getAgentInvocationMessageId, P as CHILD_AGENT_KINDS, R as agentNameSchema, S as invocationFromRow, T as listOpenAgentInvocations, U as formatAgentTypes, Z as getChildAgentLockName, at as getConversationTurnBoundaryError, dt as markTurnFailed, et as parseAgentInvocationResultMessageId, f as ConversationTurnLifecycleService, ft as startActiveTurn, g as NON_TERMINAL_AGENT_INVOCATION_STATUSES, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, lt as markTurnClosed, m as loadPendingMessageCards, mt as buildDeterministicTurnId, nt as CooperativeTurnYieldError, o as getTurnUserMessage, q as getAgentInvocationIdForResult, rt as TurnInputCommitLostError, st as isTurnInputCommitLostError, t as finalizeFailedTurnReplyWithEvent, u as buildTurnThreadContext, w as listAgentInvocationsForConversation, x as getLatestAgentInvocationForConversation } from "./turn-failure-response-hhpek6Fn.js";
|
|
23
|
+
import { a as isLegacyNoReplyMarker, i as NO_REPLY_TOOL_NAME, n as getAssistantReplyText, o as readNoReply, r as sanitizeAssistantText, t as decideReply } from "./assistant-reply-BtIV0hq6.js";
|
|
24
|
+
import { $ as withoutSavedSteeringMessages, A as requireSlackChannelMessageScope, B as maybePostAutomatedTurnLimitNotice, C as enqueueEventNotification, D as timerWatchCredentialSubject, E as renderEventBatchInputs, F as WORKSPACE_SNAPSHOT_FAILED_EVENT, H as resolveSlackReplyTarget, I as WORKSPACE_SNAPSHOT_READY_EVENT, J as assemblePrompt, K as recordFinishedTurnForAutomatedLimit, L as workspaceSnapshotFinishedEvent, O as getEventCatalog, P as slackChannelMessageTrigger, Q as loadPromptTurnContext, R as workspaceSnapshotWatch, S as EVENT_WAIT_MS, T as isEventMailboxMetadata, X as buildSteeringPiMessage, Y as buildPromptInput, Z as instructionForInputs, _ as sourceFromTurnInput, at as addConversationNote, b as conversationSubtree, c as loadReviewItemInput, ct as readBlockedReport, d as getAuthPausedConversationTurnId, f as getEventBatchDelayMs, ht as remindMissingAutomationResult, lt as FINISH_AUTOMATION_RUN_TOOL_NAME, mt as readAutomationResult, ot as JUNIOR_PERSONALITY, p as listActiveMailboxTurns, r as markConversationsStopped, rt as isExperimentalFeatureEnabled, s as eventReviewItemInputs, st as REPORT_BLOCKED_TOOL_NAME, t as getConversationStoppedAtMs, tt as saveUserCustomization, ut as automationResultSchema$1, v as turnInputFactsFromConversationMessage, w as eventBatchMessageMeta, x as conversationSubtreeColumns, y as legacyWebMailboxMetadataSchema } from "./session-stop-1cku9Vm3.js";
|
|
27
25
|
import { D as userCustomizationTextSchema, T as USER_CUSTOMIZATION_MAX_CHARS, _ as buttonUserInputField, b as normalizeUserInputAnswer, g as USER_INPUT_NOTE, h as USER_INPUT_LIMITS, m as apiErrorSchema, p as webMessageId, s as sumUtcHoursIntoSixHours, v as formatUserInputAnswer, w as AGENT_INVOCATION_STATUSES, x as userInputRequestSchema } from "./reporting-window-B3Ze-Qnt.js";
|
|
28
|
-
import { a as setSnapshotSpanAttributes, i as postinstall, n as resolve$1, r as dependencies, s as getSandboxResources } from "./resolve-
|
|
29
|
-
import { T as stopConversationWork, g as getConversationWorkState, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage } from "./store-
|
|
30
|
-
import { $ as readAutomationExecutionByConversationId, At as
|
|
31
|
-
import { _ as getMcpProviderErrorAttributes, a as serviceAccountOnly, c as createMcpServiceAccountClientProvider, d as PluginMcpClient, f as McpProviderError, g as getMcpAwareTelemetryMessage, h as getMcpAwareErrorType, i as serviceAccountAllows, l as getMcpServiceAccountCredentials, m as McpToolError, p as McpServiceAccountRequiredError, u as McpAuthorizationRequiredError, v as toMcpProviderError } from "./service-account-
|
|
32
|
-
import { A as SCHEDULED_AUTOMATION_SYSTEM_ACTOR, D as taskOutcomeInputSchema, E as automationTitleSchema, F as scheduleIntentFromTool, I as toolScheduleIntentSchema, L as weekdaySchema, N as ScheduleIntentError, P as compileScheduleIntent, T as automationInstructionToolSchema, k as eventAutomationTriggerSchema, l as automationListQuerySchema } from "./automation-
|
|
26
|
+
import { a as setSnapshotSpanAttributes, i as postinstall, n as resolve$1, r as dependencies, s as getSandboxResources } from "./resolve-B5WJgt9k.js";
|
|
27
|
+
import { S as requestConversationWork, T as stopConversationWork, g as getConversationWorkState, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage } from "./store-CK869JpC.js";
|
|
28
|
+
import { $ as readAutomationExecutionByConversationId, At as registeredResourceTypeSchema, B as setEventAutomationStatus, C as deleteScheduledAutomation, D as saveScheduledAutomation, Dt as registeredEventMatchSchema, E as readScheduledAutomation, Et as hasEventCatalogEntries, G as listAutomationVersions, I as getEventAutomation, K as readAutomationVersion, L as listDeletedEventAutomationsCreatedBy, Mt as requireValidEventTrigger, N as createEventAutomation, Ot as registeredEventTriggerProblems, P as deleteEventAutomation, R as parseEventAutomationRow, S as createScheduledAutomation, T as parseScheduledAutomationRow, Tt as eventWatchUnavailable, U as automationDefinition, X as requireAutomationRevision, Y as automationRevision, Z as emptyAutomationRunWindows, _t as persistThreadStateById, at as readAutomationExecutions, bt as automationEventCatalog, d as getDispatchRecord, dt as resolveConversationRouting, et as readAutomationExecutionDays, ft as resolveTurnSessionRouting, ht as getPersistedThreadState, it as readAutomationExecutionSummaries, jt as requireEventIdentifier, kt as registeredEventTypeSchema, l as getDispatchIdForConversation, mt as getPersistedSandboxState, n as scheduleSessionCompletedPluginTasks, nt as readAutomationExecutionStatusDays, ot as readAutomationRuns, q as sameDefinitionValue, rt as readAutomationExecutionStatusHours, t as processPluginTask, tt as readAutomationExecutionHours, u as getDispatchInputMessageId, vt as coerceThreadConversationState, wt as eventNamespaceSchema, xt as describeRegisteredEventTrigger, z as saveEventAutomation } from "./task-runner-XmXL9E-k.js";
|
|
29
|
+
import { _ as getMcpProviderErrorAttributes, a as serviceAccountOnly, c as createMcpServiceAccountClientProvider, d as PluginMcpClient, f as McpProviderError, g as getMcpAwareTelemetryMessage, h as getMcpAwareErrorType, i as serviceAccountAllows, l as getMcpServiceAccountCredentials, m as McpToolError, p as McpServiceAccountRequiredError, u as McpAuthorizationRequiredError, v as toMcpProviderError } from "./service-account-B6OJtplS.js";
|
|
30
|
+
import { A as SCHEDULED_AUTOMATION_SYSTEM_ACTOR, D as taskOutcomeInputSchema, E as automationTitleSchema, F as scheduleIntentFromTool, I as toolScheduleIntentSchema, L as weekdaySchema, N as ScheduleIntentError, P as compileScheduleIntent, T as automationInstructionToolSchema, k as eventAutomationTriggerSchema, l as automationListQuerySchema } from "./automation-DWbjJltM.js";
|
|
33
31
|
import { n as privateTraceResultAttributes } from "./private-trace-result-CE7_lEdq.js";
|
|
34
32
|
import { streamSimple } from "@earendil-works/pi-ai/compat";
|
|
35
33
|
import { createGatewayProvider } from "@ai-sdk/gateway";
|
|
@@ -868,7 +866,9 @@ function buildTurnResult(input) {
|
|
|
868
866
|
const rawPrimaryText = sanitizeAssistantText(terminalAssistantMessages.map((message) => extractAssistantText(message)).join("\n\n")).trim();
|
|
869
867
|
const primaryText = terminalAssistantMessages.map((message) => decideReply(message)).filter((output) => output.kind === "deliver").map((output) => output.text).join("\n\n");
|
|
870
868
|
const terminalTexts = terminalAssistantMessages.map((message) => sanitizeAssistantText(extractAssistantText(message)));
|
|
871
|
-
const
|
|
869
|
+
const legacyMarkerOnly = terminalTexts.some((text) => isLegacyNoReplyMarker(text)) && terminalTexts.every((text) => !text || isLegacyNoReplyMarker(text));
|
|
870
|
+
const noReply = primaryText ? void 0 : readNoReply(newMessages) ?? (legacyMarkerOnly ? {} : void 0);
|
|
871
|
+
const noReplyRequested = Boolean(noReply);
|
|
872
872
|
const toolErrorCount = toolResults.filter((result) => result.isError).length;
|
|
873
873
|
const reactionPerformed = toolResults.some((result) => !isToolResultError(result) && normalizeToolNameFromResult(result) === "addReaction");
|
|
874
874
|
const completedWithoutTerminalText = noReplyRequested;
|
|
@@ -876,14 +876,10 @@ function buildTurnResult(input) {
|
|
|
876
876
|
const stopReason = typeof lastAssistant?.stopReason === "string" ? lastAssistant.stopReason : void 0;
|
|
877
877
|
const errorMessage = typeof lastAssistant?.errorMessage === "string" ? lastAssistant.errorMessage : void 0;
|
|
878
878
|
const isProviderError = stopReason === "error";
|
|
879
|
-
if (noReplyRequested) {
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
"app.ai.no_reply_marker_accepted": !isProviderError
|
|
884
|
-
};
|
|
885
|
-
if (!isProviderError) logInfo("ai.no_reply_marker.accepted", markerAttributes);
|
|
886
|
-
}
|
|
879
|
+
if (noReplyRequested && !isProviderError) logInfo("ai.no_reply.accepted", {
|
|
880
|
+
"app.ai.no_reply.category": reactionPerformed ? "reaction" : "none",
|
|
881
|
+
"app.ai.no_reply.legacy_marker": legacyMarkerOnly
|
|
882
|
+
});
|
|
887
883
|
if (!primaryText && !completedWithoutTerminalText && !blocked && !isProviderError) logWarn("ai.model_response.empty", {
|
|
888
884
|
"app.ai.tool_results": toolResults.length,
|
|
889
885
|
"app.ai.tool_error_results": toolErrorCount,
|
|
@@ -907,6 +903,7 @@ function buildTurnResult(input) {
|
|
|
907
903
|
return {
|
|
908
904
|
text: primaryText,
|
|
909
905
|
...blocked ? { blocked } : void 0,
|
|
906
|
+
...noReply ? { noReply } : void 0,
|
|
910
907
|
sandboxRef,
|
|
911
908
|
piMessages: input.piMessages,
|
|
912
909
|
diagnostics: buildDiagnostics(input, {
|
|
@@ -5899,9 +5896,9 @@ const spawnAgentOutputSchema = juniorToolOutputSchema.extend({
|
|
|
5899
5896
|
function createSpawnAgentTool(spawnAgent, titleCost) {
|
|
5900
5897
|
return zodTool({
|
|
5901
5898
|
description: [
|
|
5902
|
-
"Start a new asynchronous child agent
|
|
5903
|
-
"Delegate when: the request splits into independent tracks that each need real investigation, such as several repos, services, sources, or items (start every track in the same message); an answer needs reading across many files, logs, or sources and you need the conclusion, not the raw output; a side task does not block your main answer; or you want a second opinion that is not anchored on your analysis (give it the evidence, not your conclusion).",
|
|
5904
|
-
"Do it yourself when: the work fits in a handful of tool calls; you already know the file, symbol, or value to look up; or the job is one modest task that you would only split into pieces. Each child rebuilds its context and its result arrives in a later turn, so when in doubt, do not spawn.",
|
|
5899
|
+
"Start a new asynchronous child agent. A child agent has its own sandbox and tool budget, runs at the same time as you, and sends back only its result. Its kind is a Thread for one discrete work item that people will own and talk to, or a Task for work that you delegate. Use Tasks to run independent work in parallel and to keep long investigations out of your context.",
|
|
5900
|
+
"Delegate a Task when: the request splits into independent tracks that each need real investigation, such as several repos, services, sources, or items (start every track in the same message); an answer needs reading across many files, logs, or sources and you need the conclusion, not the raw output; a side task does not block your main answer; or you want a second opinion that is not anchored on your analysis (give it the evidence, not your conclusion).",
|
|
5901
|
+
"Do it yourself instead of a Task when: the work fits in a handful of tool calls; you already know the file, symbol, or value to look up; or the job is one modest task that you would only split into pieces. Each child rebuilds its context and its result arrives in a later turn, so when in doubt, do not spawn a Task.",
|
|
5905
5902
|
`Pick agent_type when one fits; omit it for a fresh general-purpose child with your tools:\n${formatAgentTypes()}`,
|
|
5906
5903
|
"After you delegate, do not do the same work yourself. End your turn with a short status. You know nothing about a child's findings until its result arrives: do not predict them, do not wait or poll, and if the user asks before then, give status.",
|
|
5907
5904
|
"Give a child a name when you may send it more work later. To give more work to a child agent that already exists, use messageAgent instead.",
|
|
@@ -5920,7 +5917,7 @@ function createSpawnAgentTool(spawnAgent, titleCost) {
|
|
|
5920
5917
|
task: z.string().trim().min(1).describe("Self-contained brief. Unless its agent type starts with this conversation's history, the child has not seen this thread, so this is its only context. Brief it like a capable peer who just joined: the goal and why it matters; target repos, refs, paths, and URLs; facts you already verified and what you ruled out; constraints, including which remote side effects are allowed (scratch work in its sandbox is always fine); what counts as done; and the shape and length of the result to return. Do the synthesis yourself: name the exact question, files, or change instead of writing 'based on your findings, fix it'. If you cannot write a clear brief, you do not understand the task well enough to delegate it. Summarize thread facts instead of pasting the thread."),
|
|
5921
5918
|
title: z.string().trim().min(1).max(60).nullable().optional().describe("Optional short display title of the child and its Conversation. Pass one to skip title generation; omit it to generate one from the task."),
|
|
5922
5919
|
name: agentNameSchema.refine((name) => name !== PARENT_AGENT_TARGET, { message: `"${PARENT_AGENT_TARGET}" is reserved` }).nullable().optional().describe("New child-agent name that messageAgent can address, or omit for a one-off agent"),
|
|
5923
|
-
kind: z.enum(CHILD_AGENT_KINDS).nullable().optional().describe("thread: people can open
|
|
5920
|
+
kind: z.enum(CHILD_AGENT_KINDS).nullable().optional().describe("thread: one discrete work item, about the size of one issue or code change, that people can open, message, and steer directly, like a conversation of its own. A request to create or start a thread means this kind, not a Slack thread. Also pick it for long-lived work that people will follow or steer. Share its dashboard_url so people can find it. task (default; omit or pass null): background work that only you message."),
|
|
5924
5921
|
agent_type: z.enum(AGENT_TYPES).nullable().optional().describe("Child agent type from the list in this tool's description. Omit or pass null for a fresh general-purpose child."),
|
|
5925
5922
|
reasoning_level: z.enum(TURN_REASONING_LEVELS).nullable().optional().describe("Optional reasoning level for this delegated task only")
|
|
5926
5923
|
}).strict(),
|
|
@@ -5961,10 +5958,38 @@ function createSpawnAgentTool(spawnAgent, titleCost) {
|
|
|
5961
5958
|
}
|
|
5962
5959
|
});
|
|
5963
5960
|
}
|
|
5961
|
+
// src/chat/conversations/delivery-pause.ts
|
|
5962
|
+
/** True when the Conversation is a root that delivers to a Location. */
|
|
5963
|
+
function canPauseConversationDelivery(conversation) {
|
|
5964
|
+
return conversation.kind === "root" && conversation.location !== void 0;
|
|
5965
|
+
}
|
|
5966
|
+
const rootConversation = (conversationId) => and(eq(juniorConversations.conversationId, conversationId), isNull(juniorConversations.parentConversationId));
|
|
5967
|
+
/**
|
|
5968
|
+
* Stop Delivery of a root's Event Turn replies to its Location. Returns false
|
|
5969
|
+
* when Delivery was already paused or the root does not exist.
|
|
5970
|
+
*/
|
|
5971
|
+
async function pauseConversationDelivery(conversationId) {
|
|
5972
|
+
return (await getSqlExecutor().db().update(juniorConversations).set({
|
|
5973
|
+
deliveryPausedAt: /* @__PURE__ */ new Date(),
|
|
5974
|
+
detailVersion: nextDetailVersion
|
|
5975
|
+
}).where(and(rootConversation(conversationId), isNull(juniorConversations.deliveryPausedAt))).returning({ conversationId: juniorConversations.conversationId })).length > 0;
|
|
5976
|
+
}
|
|
5977
|
+
/** Deliver a root's Event Turn replies to its Location again. */
|
|
5978
|
+
async function resumeConversationDelivery(conversationId) {
|
|
5979
|
+
await getSqlExecutor().db().update(juniorConversations).set({
|
|
5980
|
+
deliveryPausedAt: null,
|
|
5981
|
+
detailVersion: nextDetailVersion
|
|
5982
|
+
}).where(and(rootConversation(conversationId), isNotNull(juniorConversations.deliveryPausedAt)));
|
|
5983
|
+
}
|
|
5984
|
+
/** True while a root's Event Turn replies stay out of its Location. */
|
|
5985
|
+
async function isConversationDeliveryPaused(conversationId) {
|
|
5986
|
+
const [row] = await getSqlExecutor().db().select({ pausedAt: juniorConversations.deliveryPausedAt }).from(juniorConversations).where(eq(juniorConversations.conversationId, conversationId)).limit(1);
|
|
5987
|
+
return Boolean(row?.pausedAt);
|
|
5988
|
+
}
|
|
5964
5989
|
// src/chat/conversations/web-authorization.ts
|
|
5965
5990
|
const WEB_AUTHORIZATION_PREFIX = "junior:web_authorization:v1";
|
|
5966
5991
|
const WEB_AUTHORIZATION_TTL_MS = 864e5;
|
|
5967
|
-
function authorizationKey(conversationId, actorId) {
|
|
5992
|
+
function authorizationKey$1(conversationId, actorId) {
|
|
5968
5993
|
return `${WEB_AUTHORIZATION_PREFIX}:${conversationId}:${actorId}`;
|
|
5969
5994
|
}
|
|
5970
5995
|
/** Build authorization delivery for one web turn. */
|
|
@@ -5972,7 +5997,7 @@ function createWebAuthorization(args) {
|
|
|
5972
5997
|
return {
|
|
5973
5998
|
createState: async () => randomUUID(),
|
|
5974
5999
|
deliver: async (request) => {
|
|
5975
|
-
await getStateAdapter().set(authorizationKey(args.conversationId, args.actorId), JSON.stringify({
|
|
6000
|
+
await getStateAdapter().set(authorizationKey$1(args.conversationId, args.actorId), JSON.stringify({
|
|
5976
6001
|
...request,
|
|
5977
6002
|
...args
|
|
5978
6003
|
}), WEB_AUTHORIZATION_TTL_MS);
|
|
@@ -5981,7 +6006,7 @@ function createWebAuthorization(args) {
|
|
|
5981
6006
|
}
|
|
5982
6007
|
/** Read the pending authorization request for one web actor. */
|
|
5983
6008
|
async function getWebAuthorization(args) {
|
|
5984
|
-
const value = await getStateAdapter().get(authorizationKey(args.conversationId, args.actorId));
|
|
6009
|
+
const value = await getStateAdapter().get(authorizationKey$1(args.conversationId, args.actorId));
|
|
5985
6010
|
if (typeof value !== "string") return void 0;
|
|
5986
6011
|
try {
|
|
5987
6012
|
const parsed = JSON.parse(value);
|
|
@@ -5993,7 +6018,7 @@ async function getWebAuthorization(args) {
|
|
|
5993
6018
|
}
|
|
5994
6019
|
/** Remove a web authorization request after the parked turn continues. */
|
|
5995
6020
|
async function deleteWebAuthorization(args) {
|
|
5996
|
-
await getStateAdapter().delete(authorizationKey(args.conversationId, args.actorId));
|
|
6021
|
+
await getStateAdapter().delete(authorizationKey$1(args.conversationId, args.actorId));
|
|
5997
6022
|
}
|
|
5998
6023
|
// src/chat/task-execution/assistant-message.ts
|
|
5999
6024
|
/** Store one assistant Message and its Agent history. */
|
|
@@ -6172,6 +6197,183 @@ async function finishTurn(conversationId, turnId, saved) {
|
|
|
6172
6197
|
outcome: saved.outcome
|
|
6173
6198
|
});
|
|
6174
6199
|
}
|
|
6200
|
+
// src/chat/task-execution/attempt-selection.ts
|
|
6201
|
+
function inputOwner(message) {
|
|
6202
|
+
return {
|
|
6203
|
+
authorId: message.input.authorId,
|
|
6204
|
+
identityId: message.input.authorIdentityId,
|
|
6205
|
+
source: message.source
|
|
6206
|
+
};
|
|
6207
|
+
}
|
|
6208
|
+
function turnOwner(turn) {
|
|
6209
|
+
return {
|
|
6210
|
+
authorId: isUserActor(turn.actor) ? turn.actor.userId : void 0,
|
|
6211
|
+
identityId: turn.actorIdentityId,
|
|
6212
|
+
source: turn.source?.kind
|
|
6213
|
+
};
|
|
6214
|
+
}
|
|
6215
|
+
/**
|
|
6216
|
+
* One Turn has one Actor and one Source: it runs with that Actor's
|
|
6217
|
+
* credentials, so input from anyone else must not join it. Every value that
|
|
6218
|
+
* both sides know must match, and they must share an Identity id or an author
|
|
6219
|
+
* id. Input with no known author matches nothing.
|
|
6220
|
+
*/
|
|
6221
|
+
function hasSameOwner(a, b) {
|
|
6222
|
+
if (a.source && b.source && a.source !== b.source) return false;
|
|
6223
|
+
const sameIdentity = a.identityId && b.identityId ? a.identityId === b.identityId : void 0;
|
|
6224
|
+
const sameAuthor = a.authorId && b.authorId ? a.authorId === b.authorId : void 0;
|
|
6225
|
+
return sameIdentity !== false && sameAuthor !== false && (sameIdentity ?? sameAuthor) === true;
|
|
6226
|
+
}
|
|
6227
|
+
/** True when two Inbound messages may share one Turn. */
|
|
6228
|
+
function canShareTurn(a, b) {
|
|
6229
|
+
return hasSameOwner(inputOwner(a), inputOwner(b));
|
|
6230
|
+
}
|
|
6231
|
+
/** True when an Inbound message may join `turn`. */
|
|
6232
|
+
function canJoinTurn(turn, message) {
|
|
6233
|
+
return hasSameOwner(turnOwner(turn), inputOwner(message));
|
|
6234
|
+
}
|
|
6235
|
+
function selectContiguousTurnBatch(messages) {
|
|
6236
|
+
const first = messages[0];
|
|
6237
|
+
if (!first) return [];
|
|
6238
|
+
const nextTurnIndex = messages.findIndex((message, index) => index > 0 && !canShareTurn(first, message));
|
|
6239
|
+
return messages.slice(0, nextTurnIndex === -1 ? messages.length : nextTurnIndex);
|
|
6240
|
+
}
|
|
6241
|
+
/**
|
|
6242
|
+
* True when an interrupt can start its own attempt.
|
|
6243
|
+
*
|
|
6244
|
+
* A steered web message must not start a second Turn while a yielded Turn
|
|
6245
|
+
* waits to resume. It stays pending for that Turn's drain or the next attempt.
|
|
6246
|
+
*/
|
|
6247
|
+
function isAttemptInterrupt(message, work) {
|
|
6248
|
+
return message.delivery === "interrupt" && !(work.execution.status === "paused" && message.source === "web");
|
|
6249
|
+
}
|
|
6250
|
+
/** Prioritize interrupts while keeping each attempt to one Actor and Source. */
|
|
6251
|
+
function selectAttemptMessages(work) {
|
|
6252
|
+
const messages = work.messages;
|
|
6253
|
+
const interrupts = messages.filter((message) => isAttemptInterrupt(message, work));
|
|
6254
|
+
if (interrupts.length > 0) return selectContiguousTurnBatch(interrupts);
|
|
6255
|
+
if (work.execution.status === "paused") return [];
|
|
6256
|
+
const nonEventMessages = messages.filter((message) => message.source !== "event");
|
|
6257
|
+
return selectContiguousTurnBatch(nonEventMessages.length > 0 ? nonEventMessages : messages);
|
|
6258
|
+
}
|
|
6259
|
+
// src/chat/task-execution/authorized-turn.ts
|
|
6260
|
+
/**
|
|
6261
|
+
* OAuth callbacks save readiness, not agent history. The conversation worker
|
|
6262
|
+
* consumes this event under its lease before it resumes the paused Turn.
|
|
6263
|
+
*/
|
|
6264
|
+
const authorizationSchema = z.object({
|
|
6265
|
+
kind: z.enum(["mcp", "plugin"]),
|
|
6266
|
+
provider: z.string().min(1),
|
|
6267
|
+
actorId: z.string().min(1),
|
|
6268
|
+
authorizationId: z.string().min(1),
|
|
6269
|
+
authSessionId: z.string().optional(),
|
|
6270
|
+
scope: z.string().optional(),
|
|
6271
|
+
configuration: z.record(z.string(), z.unknown()).optional(),
|
|
6272
|
+
toolChannelId: z.string().optional()
|
|
6273
|
+
});
|
|
6274
|
+
function authorizationKey(turn) {
|
|
6275
|
+
return `turn:${turn.turnId}:authorization:${turn.version}`;
|
|
6276
|
+
}
|
|
6277
|
+
/** Save authorization for this parked boundary without changing model history. */
|
|
6278
|
+
async function recordTurnAuthorization(args) {
|
|
6279
|
+
const turn = await getTurnRecord(args.conversationId, args.turnId);
|
|
6280
|
+
if (!turn || turn.state !== "paused" || turn.resumeReason !== "auth") return;
|
|
6281
|
+
await getConversationEventStore().append(args.conversationId, [{
|
|
6282
|
+
idempotencyKey: authorizationKey(turn),
|
|
6283
|
+
createdAtMs: Date.now(),
|
|
6284
|
+
data: {
|
|
6285
|
+
type: "structured_event",
|
|
6286
|
+
namespace: "junior",
|
|
6287
|
+
name: "turn_authorized",
|
|
6288
|
+
version: 1,
|
|
6289
|
+
turnId: turn.turnId,
|
|
6290
|
+
content: authorizationSchema.parse(args)
|
|
6291
|
+
}
|
|
6292
|
+
}], { activity: "preserve" });
|
|
6293
|
+
return {
|
|
6294
|
+
conversationId: args.conversationId,
|
|
6295
|
+
destination: args.destination,
|
|
6296
|
+
turnId: turn.turnId,
|
|
6297
|
+
expectedVersion: turn.version
|
|
6298
|
+
};
|
|
6299
|
+
}
|
|
6300
|
+
/** Read authorization for the exact pause; a later auth pause needs its own callback. */
|
|
6301
|
+
async function getTurnAuthorization(turn) {
|
|
6302
|
+
const event = await getConversationEventStore().loadByIdempotencyKey(turn.conversationId, authorizationKey(turn));
|
|
6303
|
+
if (event?.data.type !== "structured_event") return void 0;
|
|
6304
|
+
return authorizationSchema.parse(event.data.content);
|
|
6305
|
+
}
|
|
6306
|
+
// src/chat/task-execution/turn-wake.ts
|
|
6307
|
+
/** Build the worker input for a paused turn. */
|
|
6308
|
+
async function getPausedTurnRequest(args) {
|
|
6309
|
+
const turn = (await loadTurnCheckpoint({
|
|
6310
|
+
conversationId: args.conversationId,
|
|
6311
|
+
turnId: args.turnId
|
|
6312
|
+
})).record;
|
|
6313
|
+
if (!turn || turn.state !== "paused" || turn.resumeReason !== "timeout" && turn.resumeReason !== "yield" && turn.resumeReason !== "retry" && !(turn.resumeReason === "auth" && await getTurnAuthorization(turn)) || turn.resumeReason === "timeout" && turn.sliceId < 2) return;
|
|
6314
|
+
let routing;
|
|
6315
|
+
try {
|
|
6316
|
+
routing = await resolveTurnSessionRouting({
|
|
6317
|
+
conversationId: args.conversationId,
|
|
6318
|
+
conversationStore: args.conversationStore
|
|
6319
|
+
});
|
|
6320
|
+
} catch (error) {
|
|
6321
|
+
await failTurnRecord({
|
|
6322
|
+
conversationId: args.conversationId,
|
|
6323
|
+
expectedVersion: turn.version,
|
|
6324
|
+
turnId: args.turnId,
|
|
6325
|
+
errorMessage: error instanceof Error ? error.message : String(error)
|
|
6326
|
+
});
|
|
6327
|
+
return;
|
|
6328
|
+
}
|
|
6329
|
+
return {
|
|
6330
|
+
conversationId: args.conversationId,
|
|
6331
|
+
destination: routing.destination,
|
|
6332
|
+
turnId: args.turnId,
|
|
6333
|
+
expectedVersion: turn.version,
|
|
6334
|
+
traceContext: turn.traceContext
|
|
6335
|
+
};
|
|
6336
|
+
}
|
|
6337
|
+
/** Wake the conversation worker for a paused turn. */
|
|
6338
|
+
async function wakePausedTurn(request, options = {}) {
|
|
6339
|
+
const nowMs = options.nowMs ?? Date.now();
|
|
6340
|
+
const conversation = await (options.conversationStore ?? getConversationStore()).get({ conversationId: request.conversationId });
|
|
6341
|
+
await requestConversationWork({
|
|
6342
|
+
conversationId: request.conversationId,
|
|
6343
|
+
destination: conversation && conversation.kind !== "root" ? void 0 : request.destination,
|
|
6344
|
+
nowMs,
|
|
6345
|
+
state: options.state
|
|
6346
|
+
});
|
|
6347
|
+
const queue = options.queue ?? getVercelConversationWorkQueue();
|
|
6348
|
+
await ensureConversationWake({
|
|
6349
|
+
conversationId: request.conversationId,
|
|
6350
|
+
idempotencyKey: [
|
|
6351
|
+
"agent-continue",
|
|
6352
|
+
request.conversationId,
|
|
6353
|
+
request.turnId,
|
|
6354
|
+
request.expectedVersion,
|
|
6355
|
+
nowMs
|
|
6356
|
+
].join(":"),
|
|
6357
|
+
nowMs,
|
|
6358
|
+
queue,
|
|
6359
|
+
state: options.state
|
|
6360
|
+
});
|
|
6361
|
+
}
|
|
6362
|
+
/** Create paused Turn operations for one app. */
|
|
6363
|
+
function createPausedTurns(options = {}) {
|
|
6364
|
+
return {
|
|
6365
|
+
get: (args) => getPausedTurnRequest({
|
|
6366
|
+
...args,
|
|
6367
|
+
conversationStore: options.conversationStore
|
|
6368
|
+
}),
|
|
6369
|
+
wake: (request) => wakePausedTurn(request, options)
|
|
6370
|
+
};
|
|
6371
|
+
}
|
|
6372
|
+
/** Record completed authorization and wake the sole execution owner. */
|
|
6373
|
+
async function wakeAuthorizedTurn(args, queue) {
|
|
6374
|
+
const request = await recordTurnAuthorization(args);
|
|
6375
|
+
if (request) await wakePausedTurn(request, { queue });
|
|
6376
|
+
}
|
|
6175
6377
|
// src/chat/task-execution/supersede-turns.ts
|
|
6176
6378
|
/**
|
|
6177
6379
|
* End every open mailbox Turn other than `keepTurnId`, so new input runs in
|
|
@@ -6181,27 +6383,68 @@ async function finishTurn(conversationId, turnId, saved) {
|
|
|
6181
6383
|
* true first.
|
|
6182
6384
|
*/
|
|
6183
6385
|
async function supersedeOpenMailboxTurns(args) {
|
|
6386
|
+
return await supersedeTurns({
|
|
6387
|
+
...args,
|
|
6388
|
+
turns: (await listActiveMailboxTurns(args.conversationId)).filter((record) => record.turnId !== args.keepTurnId)
|
|
6389
|
+
});
|
|
6390
|
+
}
|
|
6391
|
+
/**
|
|
6392
|
+
* End open Turns that new input replaces. A late resume or OAuth callback
|
|
6393
|
+
* for an ended Turn is a no-op. The caller persists `conversation`. Returns
|
|
6394
|
+
* false when `isStopped` turns true first.
|
|
6395
|
+
*/
|
|
6396
|
+
async function supersedeTurns(args) {
|
|
6184
6397
|
const pendingAuthorizationActorId = args.conversation.processing.pendingAuth?.actorId;
|
|
6185
|
-
const
|
|
6186
|
-
for (const stale of superseded) {
|
|
6398
|
+
for (const stale of args.turns) {
|
|
6187
6399
|
if (args.isStopped?.()) return false;
|
|
6188
6400
|
await abandonTurnRecord({
|
|
6189
6401
|
conversationId: args.conversationId,
|
|
6190
6402
|
turnId: stale.turnId,
|
|
6191
6403
|
errorMessage: "Turn superseded by new input"
|
|
6192
6404
|
});
|
|
6405
|
+
await new ConversationTurnLifecycleService(getConversationEventStore()).complete({
|
|
6406
|
+
conversationId: args.conversationId,
|
|
6407
|
+
createdAtMs: Date.now(),
|
|
6408
|
+
outcome: "cancelled",
|
|
6409
|
+
turnId: stale.turnId
|
|
6410
|
+
});
|
|
6193
6411
|
markTurnClosed({
|
|
6194
6412
|
conversation: args.conversation,
|
|
6195
6413
|
nowMs: Date.now(),
|
|
6196
6414
|
sessionId: stale.turnId
|
|
6197
6415
|
});
|
|
6198
6416
|
}
|
|
6199
|
-
if (
|
|
6417
|
+
if (args.turns.some((record) => record.state === "paused" && record.resumeReason === "auth") && pendingAuthorizationActorId) await deleteWebAuthorization({
|
|
6200
6418
|
actorId: pendingAuthorizationActorId,
|
|
6201
6419
|
conversationId: args.conversationId
|
|
6202
6420
|
});
|
|
6203
6421
|
return true;
|
|
6204
6422
|
}
|
|
6423
|
+
/**
|
|
6424
|
+
* End the Turn that waits for its next Run when `message` cannot join it, so
|
|
6425
|
+
* the message starts its own Turn instead of running with that Turn's Actor.
|
|
6426
|
+
* A stored legacy Turn without an Actor keeps taking the input.
|
|
6427
|
+
*/
|
|
6428
|
+
async function supersedeTurnForInput(args) {
|
|
6429
|
+
const conversation = coerceThreadConversationState(await getPersistedThreadState(args.conversationId));
|
|
6430
|
+
const turnId = conversation.processing.activeTurnId;
|
|
6431
|
+
if (!turnId || !await getPausedTurnRequest({
|
|
6432
|
+
conversationId: args.conversationId,
|
|
6433
|
+
turnId
|
|
6434
|
+
})) return;
|
|
6435
|
+
const turn = await getTurnRecord(args.conversationId, turnId);
|
|
6436
|
+
if (!turn?.actor || canJoinTurn(turn, args.message)) return;
|
|
6437
|
+
await hydrateConversationMessages({
|
|
6438
|
+
conversation,
|
|
6439
|
+
conversationId: args.conversationId
|
|
6440
|
+
});
|
|
6441
|
+
await supersedeTurns({
|
|
6442
|
+
conversation,
|
|
6443
|
+
conversationId: args.conversationId,
|
|
6444
|
+
turns: [turn]
|
|
6445
|
+
});
|
|
6446
|
+
await persistThreadStateById(args.conversationId, { conversation });
|
|
6447
|
+
}
|
|
6205
6448
|
// src/chat/task-execution/mailbox-input.ts
|
|
6206
6449
|
/**
|
|
6207
6450
|
* Return the Turn inputs of web Messages, one per non-empty Message, in
|
|
@@ -6621,16 +6864,15 @@ function createConversationTurnWorker(agentRunner, deliverMessage) {
|
|
|
6621
6864
|
let modelFailureEventId;
|
|
6622
6865
|
let modelFailureCaptureAttempted = false;
|
|
6623
6866
|
let completedSuccessfully = false;
|
|
6624
|
-
const deliverAssistantMessage = async (value) => {
|
|
6867
|
+
const deliverAssistantMessage = async (value, options) => {
|
|
6625
6868
|
const agentMessage = typeof value === "string" ? void 0 : value;
|
|
6626
|
-
const
|
|
6627
|
-
const replyText = typeof value === "string" ? value : decision?.kind === "deliver" ? decision.text : void 0;
|
|
6869
|
+
const replyText = typeof value === "string" ? value : getAssistantReplyText(value);
|
|
6628
6870
|
if (!replyText?.trim()) return;
|
|
6629
6871
|
failureCode = "delivery_failed";
|
|
6630
6872
|
const cards = await loadPendingMessageCards(context.conversationId);
|
|
6631
|
-
const quiet =
|
|
6873
|
+
const quiet = options?.quiet === true && isEventTurn && cards.length === 0;
|
|
6632
6874
|
let deliveryResult;
|
|
6633
|
-
if (deliverToProvider && !quiet) {
|
|
6875
|
+
if (deliverToProvider && !quiet && !await isConversationDeliveryPaused(context.conversationId)) {
|
|
6634
6876
|
if (!conversationLocation || !deliverMessage) throw new Error(`Conversation ${context.conversationId} cannot deliver to its Location`);
|
|
6635
6877
|
deliveryResult = await deliverMessage({
|
|
6636
6878
|
cards,
|
|
@@ -6738,6 +6980,7 @@ function createConversationTurnWorker(agentRunner, deliverMessage) {
|
|
|
6738
6980
|
const reply = finalized.reply;
|
|
6739
6981
|
modelFailureEventId = finalized.eventId;
|
|
6740
6982
|
if (reply.diagnostics.outcome !== "success") await deliverAssistantMessage(reply.text);
|
|
6983
|
+
else if (reply.noReply?.note && isEventTurn) await deliverAssistantMessage(reply.noReply.note, { quiet: true });
|
|
6741
6984
|
const completedState = buildDeliveredTurnStatePatch({
|
|
6742
6985
|
conversation,
|
|
6743
6986
|
reply,
|
|
@@ -6898,9 +7141,11 @@ const SUBAGENT_KIND = "agent";
|
|
|
6898
7141
|
* pairs the parent event with `subagent_ended` to show the child and its
|
|
6899
7142
|
* status. It must be written before the child mailbox append, so the child
|
|
6900
7143
|
* cannot end first. An agent wrote the input, not a person, so the message
|
|
6901
|
-
* names its agent invocation instead of an author.
|
|
7144
|
+
* names its agent invocation instead of an author. Input from Events, such as
|
|
7145
|
+
* the child's own Watch Events, passes their Event fields, so the dashboard
|
|
7146
|
+
* shows it as an Event, as on a root.
|
|
6902
7147
|
*/
|
|
6903
|
-
async function recordSubagentStarted(invocation) {
|
|
7148
|
+
async function recordSubagentStarted(invocation, eventMeta) {
|
|
6904
7149
|
const eventStore = getConversationEventStore();
|
|
6905
7150
|
const messageId = getAgentInvocationMessageId(invocation.invocationId);
|
|
6906
7151
|
await eventStore.append(invocation.childConversationId, [{
|
|
@@ -6910,7 +7155,10 @@ async function recordSubagentStarted(invocation) {
|
|
|
6910
7155
|
messageId,
|
|
6911
7156
|
role: "user",
|
|
6912
7157
|
text: invocation.input,
|
|
6913
|
-
meta: {
|
|
7158
|
+
meta: {
|
|
7159
|
+
...eventMeta,
|
|
7160
|
+
agentInvocationId: invocation.invocationId
|
|
7161
|
+
}
|
|
6914
7162
|
},
|
|
6915
7163
|
createdAtMs: invocation.createdAtMs
|
|
6916
7164
|
}]);
|
|
@@ -7370,35 +7618,6 @@ async function archiveConversation(viewer, conversationId, body) {
|
|
|
7370
7618
|
case "archived_ancestor": throwApiError(409, `Conversation ${result.archivedAncestorId} above this one is archived. Restore it first.`);
|
|
7371
7619
|
}
|
|
7372
7620
|
}
|
|
7373
|
-
// src/api/conversations/user-message-activity.ts
|
|
7374
|
-
/**
|
|
7375
|
-
* The newest event of one type in the outer Conversation that matches the
|
|
7376
|
-
* filter. It walks the message role or user message time index from the
|
|
7377
|
-
* newest event. The user message index has only matching entries, so that
|
|
7378
|
-
* read stops at the first one.
|
|
7379
|
-
*/
|
|
7380
|
-
function latestEventAt(db, type, filter) {
|
|
7381
|
-
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}`);
|
|
7382
|
-
}
|
|
7383
|
-
/** Read the latest true user message time for each selected conversation. */
|
|
7384
|
-
async function readLastUserMessageAtByConversation(db, conversationIds) {
|
|
7385
|
-
if (conversationIds.length === 0) return /* @__PURE__ */ new Map();
|
|
7386
|
-
const payload = juniorConversationEvents.payload;
|
|
7387
|
-
const instruction = latestEventAt(db, "user_message", isUserInstruction(payload));
|
|
7388
|
-
const authorKind = sql`(${db.select({ kind: juniorIdentities.kind }).from(juniorIdentities).where(eq(juniorIdentities.id, juniorConversationEvents.actorIdentityId))})`;
|
|
7389
|
-
const message = latestEventAt(db, "message", sql`${payload}->>'role' = 'user' and ${authorKind} = 'user'`);
|
|
7390
|
-
const rows = await db.select({
|
|
7391
|
-
conversationId: juniorConversations.conversationId,
|
|
7392
|
-
instructionAt: instruction.createdAt,
|
|
7393
|
-
messageAt: message.createdAt
|
|
7394
|
-
}).from(juniorConversations).leftJoinLateral(instruction, sql`true`).leftJoinLateral(message, sql`true`).where(inArray(juniorConversations.conversationId, conversationIds));
|
|
7395
|
-
const result = /* @__PURE__ */ new Map();
|
|
7396
|
-
for (const { conversationId, instructionAt, messageAt } of rows) {
|
|
7397
|
-
const times = [instructionAt, messageAt].flatMap((at) => at ? [at.getTime()] : []);
|
|
7398
|
-
if (times.length > 0) result.set(conversationId, new Date(Math.max(...times)).toISOString());
|
|
7399
|
-
}
|
|
7400
|
-
return result;
|
|
7401
|
-
}
|
|
7402
7621
|
// src/chat/tools/runtime/archive-agent.ts
|
|
7403
7622
|
const archiveAgentOutputSchema = juniorToolOutputSchema.extend({
|
|
7404
7623
|
conversation_id: z.string().min(1).describe("Archived Thread ID"),
|
|
@@ -7490,13 +7709,30 @@ function createFinishAutomationRunTool(options) {
|
|
|
7490
7709
|
execute: async (input) => {
|
|
7491
7710
|
const parsed = automationResultSchema$1.safeParse(input);
|
|
7492
7711
|
if (!parsed.success) throw new ToolInputError(input.result === "send_message" ? "send_message requires a non-empty message." : `${input.result} requires a non-empty reason.`);
|
|
7493
|
-
return parsed.data.result === "send_message" &&
|
|
7712
|
+
return parsed.data.result === "send_message" && isLegacyNoReplyMarker(parsed.data.message) ? {
|
|
7494
7713
|
result: "no_action",
|
|
7495
7714
|
reason: "The message was the no-reply marker."
|
|
7496
7715
|
} : parsed.data;
|
|
7497
7716
|
}
|
|
7498
7717
|
});
|
|
7499
7718
|
}
|
|
7719
|
+
// src/chat/tools/runtime/no-reply.ts
|
|
7720
|
+
/** Create the tool that ends a Turn with no reply. */
|
|
7721
|
+
function createNoReplyTool() {
|
|
7722
|
+
return zodTool({
|
|
7723
|
+
annotations: {
|
|
7724
|
+
destructiveHint: false,
|
|
7725
|
+
idempotentHint: true,
|
|
7726
|
+
openWorldHint: false,
|
|
7727
|
+
readOnlyHint: true
|
|
7728
|
+
},
|
|
7729
|
+
description: "End the Turn without a reply. Nothing is posted and nobody is notified.",
|
|
7730
|
+
exposure: "modelOnly",
|
|
7731
|
+
inputSchema: z.object({ note: z.string().trim().min(1).nullable().optional().describe("Outcome to keep in the conversation without notifying anyone, such as a routine fix that worked. Omit it when a person asked for no reply. Null is the same as omitted.") }).strict(),
|
|
7732
|
+
outputSchema: juniorToolOutputSchema.extend({ note: z.string().optional() }),
|
|
7733
|
+
execute: async (input) => input.note ? { note: input.note } : {}
|
|
7734
|
+
});
|
|
7735
|
+
}
|
|
7500
7736
|
// src/chat/tools/runtime/report-blocked.ts
|
|
7501
7737
|
/** Create the tool that ends a child agent run as blocked. */
|
|
7502
7738
|
function createReportBlockedTool() {
|
|
@@ -8286,15 +8522,21 @@ const titleSchema = z.string().trim().min(1).max(200);
|
|
|
8286
8522
|
const bodySchema = z.string().trim().min(1).max(4e3).describe("Markdown details for the person.");
|
|
8287
8523
|
/**
|
|
8288
8524
|
* Pick the assignees of a new item when the agent names none: the User of
|
|
8289
|
-
* the Actor, or else the creator of the Automation of this run. A
|
|
8290
|
-
*
|
|
8291
|
-
*
|
|
8525
|
+
* the Actor, or else the creator of the Automation of this run. A Turn with
|
|
8526
|
+
* a system Actor, such as an event Turn, falls back to the active
|
|
8527
|
+
* Participants of the Conversation. A Slack Actor without a Junior User gets
|
|
8528
|
+
* an item with no assignees, so that the agent can still ask; any person in
|
|
8529
|
+
* the thread can then answer it.
|
|
8292
8530
|
*/
|
|
8293
|
-
async function defaultAssignees(scope) {
|
|
8531
|
+
async function defaultAssignees(scope, conversationId) {
|
|
8294
8532
|
const userId = scope.user?.id ?? (scope.reader.automationId ? await automationCreatorUserId(getDb(), scope.reader.automationId) : void 0);
|
|
8533
|
+
if (userId) return {
|
|
8534
|
+
everyone: false,
|
|
8535
|
+
userIds: [userId]
|
|
8536
|
+
};
|
|
8295
8537
|
return {
|
|
8296
8538
|
everyone: false,
|
|
8297
|
-
userIds:
|
|
8539
|
+
userIds: scope.actorIsPerson ? [] : await activeParticipantUserIds(getDb(), conversationId)
|
|
8298
8540
|
};
|
|
8299
8541
|
}
|
|
8300
8542
|
function delivery(services) {
|
|
@@ -8347,7 +8589,7 @@ function subjectInput(subject) {
|
|
|
8347
8589
|
/** Create the tool that adds a Review item or updates the open one. */
|
|
8348
8590
|
function createAddReviewItemTool(context, services) {
|
|
8349
8591
|
return zodTool({
|
|
8350
|
-
description: `Ask a person for input, or tell them about work that needs them. This is how you ask a person anything: the item goes on the review desk, and in a Slack thread it also shows as a card with buttons. Write the question so it stands alone: a person who sees only the card must understand it. Put the option that you recommend first, set \`recommended: true\` on it, and say why in its description. Use kind \`action\` with a \`request\` to ask: a question and 1-4 fields. Each field is \`choice\` (pick one), \`multi_choice\` (pick any), or \`text\` (a short answer). For a simple decision, use one \`choice\` field. Ask for related input in one item. Use kind \`notice\` only to tell a person something. Assignees default to the person in this Turn,
|
|
8592
|
+
description: `Ask a person for input, or tell them about work that needs them. This is how you ask a person anything: the item goes on the review desk, and in a Slack thread it also shows as a card with buttons. Write the question so it stands alone: a person who sees only the card must understand it. Put the option that you recommend first, set \`recommended: true\` on it, and say why in its description. Use kind \`action\` with a \`request\` to ask: a question and 1-4 fields. Each field is \`choice\` (pick one), \`multi_choice\` (pick any), or \`text\` (a short answer). For a simple decision, use one \`choice\` field. Ask for related input in one item. Use kind \`notice\` only to tell a person something. Assignees default to the person in this Turn, to the Automation creator in an Automation run, or else to the people still subscribed to the Conversation. The current Conversation is always linked. The answer arrives later as a \`<review-item-answer>\` with the item id, or a \`<review-item-dismissed>\` when the person dismisses it. A reply that the assignee types in the thread also closes the item when the reply answers it. If your next step needs the answer, end the Turn now: the card is your reply, so do not write text: call \`${NO_REPLY_TOOL_NAME}\`, or finish the Automation run. If other work does not need the answer, continue with it. If an open item has the same \`dedupe_key\`, this updates that item instead of adding another.`,
|
|
8351
8593
|
annotations: {
|
|
8352
8594
|
destructiveHint: false,
|
|
8353
8595
|
idempotentHint: true,
|
|
@@ -8389,7 +8631,8 @@ function createAddReviewItemTool(context, services) {
|
|
|
8389
8631
|
const assignees = input.assignees ? await resolveAssignees(db, input.assignees, existing ? existing.tenant : scope.tenant, services.findMentionedUserId) : existing ? {
|
|
8390
8632
|
everyone: existing.assignedToEveryone,
|
|
8391
8633
|
userIds: existing.assignees.map((assignee) => assignee.userId)
|
|
8392
|
-
} : await defaultAssignees(scope);
|
|
8634
|
+
} : await defaultAssignees(scope, context.conversationId);
|
|
8635
|
+
if (!assignees.everyone && assignees.userIds.length === 0 && !scope.actorIsPerson) throw new ToolInputError("No person would see this item: no default assignee has a Junior user, and this Turn has no person. Set `assignees`.");
|
|
8393
8636
|
await requireReviewItemAssignees({
|
|
8394
8637
|
assignees,
|
|
8395
8638
|
automationId: existing ? existing.automationId : scope.reader.automationId,
|
|
@@ -9946,7 +10189,7 @@ async function readConversationSourceTask(args) {
|
|
|
9946
10189
|
* Web edits and lifecycle actions. Anyone who can read an Automation can
|
|
9947
10190
|
* manage it. Creator credential rules still apply.
|
|
9948
10191
|
*/
|
|
9949
|
-
/**
|
|
10192
|
+
/** Creators and public Destination readers can manage. Others get not found. */
|
|
9950
10193
|
async function requireEditableAutomation(user, id) {
|
|
9951
10194
|
const candidate = await resolveViewerTaskCandidate(user, id);
|
|
9952
10195
|
if (!candidate) throw new ViewerTaskNotFoundError();
|
|
@@ -12068,7 +12311,7 @@ function createSlackMessageAddReactionTool(context, state) {
|
|
|
12068
12311
|
openWorldHint: true,
|
|
12069
12312
|
readOnlyHint: false
|
|
12070
12313
|
},
|
|
12071
|
-
description: `Add an emoji reaction to the current inbound Slack message. The person sees the reaction on their message. When the reaction is the whole reply, do not report it in text: end the Turn with
|
|
12314
|
+
description: `Add an emoji reaction to the current inbound Slack message. The person sees the reaction on their message. When the reaction is the whole reply, do not report it in text: end the Turn with \`${NO_REPLY_TOOL_NAME}\`.`,
|
|
12072
12315
|
inputSchema: z.object({ emoji: z.string().min(1).max(64).describe("Slack emoji alias name to react with (for example `thumbsup`, `white_check_mark`, or `thumbsup::skin-tone-6`). Optional surrounding colons are allowed.") }),
|
|
12073
12316
|
outputSchema: juniorToolOutputSchema,
|
|
12074
12317
|
execute: async ({ emoji }) => {
|
|
@@ -14590,15 +14833,10 @@ async function updateConversationSubscription(person, conversationId, subscribed
|
|
|
14590
14833
|
};
|
|
14591
14834
|
});
|
|
14592
14835
|
}
|
|
14593
|
-
/**
|
|
14594
|
-
* True when someone still has the root in their feed: a participant who did
|
|
14595
|
-
* not unsubscribe, or the root actor before they have a participant row.
|
|
14596
|
-
*/
|
|
14836
|
+
/** True when an active Participant still has the root in their feed. */
|
|
14597
14837
|
async function hasSubscriber(db, rootConversationId) {
|
|
14598
14838
|
const [subscriber] = await db.select({ userId: juniorConversationParticipants.userId }).from(juniorConversationParticipants).where(and(eq(juniorConversationParticipants.rootConversationId, rootConversationId), isNull(juniorConversationParticipants.unsubscribedAt))).limit(1);
|
|
14599
|
-
|
|
14600
|
-
const [rowlessActor] = await db.select({ userId: juniorIdentities.userId }).from(juniorConversations).innerJoin(juniorIdentities, eq(juniorIdentities.id, juniorConversations.actorIdentityId)).where(and(eq(juniorConversations.conversationId, rootConversationId), isNotNull(juniorIdentities.userId), notExists(db.select({ userId: juniorConversationParticipants.userId }).from(juniorConversationParticipants).where(and(eq(juniorConversationParticipants.rootConversationId, rootConversationId), eq(juniorConversationParticipants.userId, juniorIdentities.userId)))))).limit(1);
|
|
14601
|
-
return Boolean(rowlessActor);
|
|
14839
|
+
return Boolean(subscriber);
|
|
14602
14840
|
}
|
|
14603
14841
|
/**
|
|
14604
14842
|
* Archive the root and each descendant that is not archived. Descendants
|
|
@@ -16274,6 +16512,7 @@ function createTools(availableSkills, hooks = {}, context, options = {}) {
|
|
|
16274
16512
|
if (context.messageAgent) tools.messageAgent = createMessageAgentTool(context.messageAgent);
|
|
16275
16513
|
if (context.agentInvocationId) tools[REPORT_BLOCKED_TOOL_NAME] = createReportBlockedTool();
|
|
16276
16514
|
if (context.automation) tools[FINISH_AUTOMATION_RUN_TOOL_NAME] = createFinishAutomationRunTool(context.automation);
|
|
16515
|
+
else tools[NO_REPLY_TOOL_NAME] = createNoReplyTool();
|
|
16277
16516
|
if (context.mcpToolManager) {
|
|
16278
16517
|
tools.searchMcpTools = createSearchMcpToolsTool(context.mcpToolManager);
|
|
16279
16518
|
tools.callMcpTool = createCallMcpToolTool(context.mcpToolManager);
|
|
@@ -21292,7 +21531,8 @@ async function applyPreparedSummary(args, prepared, budget) {
|
|
|
21292
21531
|
const EXCLUSIVE_TOOL_NAMES = [
|
|
21293
21532
|
"switchWorkspace",
|
|
21294
21533
|
FINISH_AUTOMATION_RUN_TOOL_NAME,
|
|
21295
|
-
REPORT_BLOCKED_TOOL_NAME
|
|
21534
|
+
REPORT_BLOCKED_TOOL_NAME,
|
|
21535
|
+
NO_REPLY_TOOL_NAME
|
|
21296
21536
|
];
|
|
21297
21537
|
/** Return the exclusive tool name when one is present among the calls. */
|
|
21298
21538
|
function exclusiveToolName(toolCalls) {
|
|
@@ -21881,7 +22121,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
21881
22121
|
const sourceResult = timedOutResult ?? result;
|
|
21882
22122
|
const projectedResult = wiring.projectActionReviewResult(toolCall.id, sourceResult);
|
|
21883
22123
|
const override = timedOutResult || projectedResult !== result ? projectedResult : void 0;
|
|
21884
|
-
if ((toolCall.name === "finishAutomationRun" || toolCall.name === "reportBlocked") && !isError && !override) return { terminate: true };
|
|
22124
|
+
if ((toolCall.name === "finishAutomationRun" || toolCall.name === "reportBlocked" || toolCall.name === "noReply") && !isError && !override) return { terminate: true };
|
|
21885
22125
|
return override;
|
|
21886
22126
|
},
|
|
21887
22127
|
prepareNextTurnWithContext: async (nextTurn, hookSignal) => {
|
|
@@ -22289,4 +22529,4 @@ function createAgentRunner(execute, options) {
|
|
|
22289
22529
|
return await execute(nextRun, streamFn);
|
|
22290
22530
|
} };
|
|
22291
22531
|
}
|
|
22292
|
-
export { readViewerAutomationSummary as $,
|
|
22532
|
+
export { readViewerAutomationSummary as $, resumeConversationDelivery as $t, runWithSlackInstallation as A, cancelSignInWait as At, listThreadReplies as B, canShareTurn as Bt, readSlackReviewItemCardConversationId as C, emptyResponse as Ct, parseSlackReviewItemClick as D, stopChildAgentsOf as Dt, buildSlackReviewItemModal as E, stopChildAgentsBelow as Et, resolveSlackChannelIdFromThreadId as F, getPausedTurnRequest as Ft, changeViewerAutomationLifecycle as G, finishTurn as Gt, logScheduledAutomationRunSkipped as H, selectAttemptMessages as Ht, checkSlackChannelReadAccess as I, wakeAuthorizedTurn as It, updateViewerAutomation as J, withTurnSpan as Jt, deleteViewerTask as K, getTurnInputSpanAttributes as Kt, joinPublicChannelForRead as L, wakePausedTurn as Lt, parseSlackThreadId as M, supersedeOpenMailboxTurns as Mt, readSlackRawMessageContext as N, supersedeTurnForInput as Nt, parseSlackReviewItemFormTarget as O, recordSubagentEnded as Ot, resolveSlackChannelIdFromMessage as P, createPausedTurns as Pt, readViewerAutomationRuns as Q, pauseConversationDelivery as Qt, getConversationInfo as R, getTurnAuthorization as Rt, createSlackReviewItemShow as S, markConversationRead as St, SLACK_REVIEW_ITEM_VIEW_ID as T, throwApiError as Tt, scheduledAutomationRunAttributes as U, AgentRunError as Ut, resolveDestinationVisibility as V, isAttemptInterrupt as Vt, activateViewerAutomationVersion as W, executeTurn as Wt, readConversationSourceTask as X, getWebAuthorization as Xt, ViewerTaskNotFoundError as Y, deleteWebAuthorization as Yt, readViewerAutomationExecutions as Z, canPauseConversationDelivery as Zt, unpublishedArtifactHeaders as _, readLiveAttachment as _t, finalizeMcpAuthorization as a, AgentNameInUseError as an, deliverReviewItemChange as at, renderAttachmentText as b, archiveConversation as bt, deleteMcpServerSessionId as c, processWorkspaceSnapshotJob as cn, acceptsWebMessages as ct, getMcpStoredOAuthCredentials as d, actorFromRun as dn, createAndEnqueueConversation as dt, AgentDepthLimitError as en, readViewerAutomationVersions as et, putMcpStoredOAuthCredentials as f, toolInvocationDestination as fn, createConversationId as ft, readPublicArtifact as g, collectAttachmentGarbage as gt, publicArtifactHeaders as h, decodeInputImages as ht, buildAuthPauseResponse as i, AgentMessageTargetError as in, listOwnedWatches as it, verifySlackSignature as j, createConversationTurnWorker as jt, parseSlackUserInputSubmission as k, recordSubagentStarted as kt, deleteMcpStoredOAuthCredentials as l, ingestEvent as ln, appendAndEnqueueWebMessage as lt, readStats as m, webActorFromUser as mt, executeAgentRun as n, AgentMessagePausedError as nn, AutomationEditError as nt, deleteMcpAuthSession as o, listChildAgents as on, renderReviewItemMessage as ot, latestProgressStatus as p, shouldEmitDevAgentTrace as pn, recordWebConversationActivity as pt, readViewerAutomationEdit as q, turnInputTelemetry as qt, processBackgroundCompaction as r, AgentMessageQueueFullError as rn, effectiveTaskOutcomes as rt, deleteMcpAuthSessionsForUserProvider as s, listUnreportedSiblingAgents as sn, reviewItemChangeRecord as st, createAgentRunner as t, AgentInvocationLimitError as tn, readViewerAutomations as tt, getMcpAuthSession as u, RetryableDeliveryError as un, conversationTurnIdForMessage as ut, setConversationSubscription as v, requestAttachmentDeletion as vt, syncReviewItemSlackCards as w, jsonResponse as wt, renderBlockText as x, conversationReadPositionQuery as xt, lookupSlackUserProfile as y, storeAttachment as yt, joinPublicChannel as z, canJoinTurn as zt };
|