@sentry/junior 0.292.0 → 0.294.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.
Files changed (74) hide show
  1. package/dist/{adapter-Cigb1MTr.js → adapter-DxLhJEnO.js} +1 -1
  2. package/dist/{admin-BO9V7vnn.js → admin-vt8aSiCD.js} +2 -2
  3. package/dist/{agent-runner-BuH7EHrX.js → agent-runner-DJu7w6mI.js} +318 -162
  4. package/dist/api/schema.d.ts +2 -2
  5. package/dist/api/schema.js +5 -5
  6. package/dist/api.d.ts +1 -1
  7. package/dist/api.js +65 -40
  8. package/dist/{app-C47PT68y.d.ts → app--a5RLOrr.d.ts} +4 -2
  9. package/dist/app.d.ts +1 -1
  10. package/dist/app.js +454 -435
  11. package/dist/{assistant-reply-ZjLRGHm2.js → assistant-reply-iTtEdDyc.js} +1 -1
  12. package/dist/{automation-CrsYnvdV.js → automation-BM-OBsKW.js} +72 -23
  13. package/dist/{background-compaction-queue-CqZBPe9g.js → background-compaction-queue-D2j-0XkH.js} +4 -4
  14. package/dist/{briefs-DZrhXJss.js → briefs-JOAoCb6d.js} +3 -3
  15. package/dist/{catalog-runtime-Cj9I0dco.js → catalog-runtime-CLMA9AXd.js} +1 -1
  16. package/dist/cli/chat.js +15 -15
  17. package/dist/cli/check.js +3 -3
  18. package/dist/cli/main.js +3 -3
  19. package/dist/cli/plugins.js +4 -4
  20. package/dist/cli/snapshot-create.js +4 -4
  21. package/dist/cli/upgrade.d.ts +1 -1
  22. package/dist/cli/upgrade.js +7 -74
  23. package/dist/{config-BerMjSVL.js → config-mIZeGEWv.js} +17 -7
  24. package/dist/{connections-BWmTOVPB.js → connections-XhdVg7OR.js} +6 -6
  25. package/dist/{conversation-CtjR1Zcx.js → conversation-CDWejM4R.js} +1 -0
  26. package/dist/{conversation-pending-messages-Cd7ShwBs.js → conversation-pending-messages-Dh2tfbaw.js} +5 -2
  27. package/dist/{conversation-privacy-BMfbOUCo.js → conversation-privacy-C6h-X2cZ.js} +1 -1
  28. package/dist/{credential-sync-DZDij2CU.js → credential-sync-zigBlXS3.js} +13 -13
  29. package/dist/{db-BlfjuqzW.js → db--xuNV7g6.js} +99 -6
  30. package/dist/{db-7glZCI18.d.ts → db-DV5AbcGM.d.ts} +8 -6
  31. package/dist/{executor-ikZvFaMD.js → executor-BItuRqAR.js} +87 -21
  32. package/dist/instrumentation.js +2 -2
  33. package/dist/{logging-CTCH5jOy.js → logging-Cb6MGvdt.js} +1 -1
  34. package/dist/{message-C1ID1tKi.js → message-BTGgSmaH.js} +9 -9
  35. package/dist/nitro.d.ts +1 -1
  36. package/dist/nitro.js +2 -2
  37. package/dist/{oauth-callback-server-CStBgDU7.js → oauth-callback-server-Dvh1aOIi.js} +2 -2
  38. package/dist/{projection-DY93nCfX.js → projection-DLQgfO5N.js} +61 -52
  39. package/dist/{prompt-exicBZeb.js → prompt-qp_LdxLX.js} +5 -6
  40. package/dist/{registry-X_xdFY9L.js → registry-MtwokaqW.js} +1 -1
  41. package/dist/{resolve-B9dYN-nS.js → resolve-BnJA0UNE.js} +3 -3
  42. package/dist/{result-CC8bV8Fl.js → result-ChL-1KyW.js} +8 -8
  43. package/dist/{runner-D44qp4rc.js → runner-BONN7Dp2.js} +8 -8
  44. package/dist/{sandbox-egress-signals-BrH6DWkt.js → sandbox-egress-signals-nmlmI5Ab.js} +1 -1
  45. package/dist/{schema-CC2RxDAV.d.ts → schema-DgvcyJ1y.d.ts} +283 -45
  46. package/dist/{schema-CVV5r-qP.js → schema-yr0ccDni.js} +29 -4
  47. package/dist/{service-account-DoNZuJb-.js → service-account-Bd0lBaGr.js} +3 -3
  48. package/dist/{service-account-89JZHWCE.js → service-account-kio5nXSD.js} +3 -3
  49. package/dist/{session-stop-DNucbmPf.js → session-stop-CeCXL3j9.js} +20 -41
  50. package/dist/{skills-BeUfmYXL.js → skills-e3DDNlKO.js} +10 -9
  51. package/dist/{spawn-CIAcfcvZ.js → spawn--cRxITWQ.js} +5 -5
  52. package/dist/{stop-Ckd3735h.js → stop-Iai5N2PU.js} +34 -29
  53. package/dist/{store-CS0xoqXW.js → store-C8LsaJwS.js} +3 -3
  54. package/dist/{task-runner-DjjHCX_m.js → task-runner-Dw7exu0-.js} +65 -90
  55. package/dist/{turn-failure-response-D0bwI462.js → turn-failure-response-BqTTx3XG.js} +8 -8
  56. package/dist/{validation-Cvx_AupF.js → validation-BrGahtnv.js} +1 -1
  57. package/dist/{version-BrDx4Fzc.js → version-Bdqhx8Qh.js} +1 -1
  58. package/dist/version.js +1 -1
  59. package/dist/{viewer-4CxdwLLQ.js → viewer-CjRFHR5U.js} +3 -3
  60. package/dist/{warmup-B62hd4lD.js → warmup-DuxCtzKC.js} +104 -26
  61. package/dist/{work-Cu315oJl.js → work-BWBG1EGV.js} +11 -11
  62. package/dist/{worker-4ClZu6ry.js → worker-DAnBIVMs.js} +6 -6
  63. package/migrations/0062_plugin_report_index.sql +1 -20
  64. package/migrations/0078_plugin_conversation_index.sql +1 -20
  65. package/migrations/0079_conversation_event_author_index.sql +1 -20
  66. package/migrations/0080_conversation_event_latest_message_indexes.sql +2 -27
  67. package/migrations/0090_guardian_review_time_index.sql +1 -20
  68. package/migrations/0091_conversation_participant_unsubscribed_index.sql +1 -20
  69. package/migrations/0096_automation_task_kind.sql +75 -0
  70. package/migrations/0097_conversation_kind_automation.sql +6 -0
  71. package/migrations/meta/0096_snapshot.json +4490 -0
  72. package/migrations/meta/0097_snapshot.json +4490 -0
  73. package/migrations/meta/_journal.json +14 -0
  74. package/package.json +5 -5
@@ -1,33 +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 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-DY93nCfX.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-BerMjSVL.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-CTCH5jOy.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-BMfbOUCo.js";
2
+ import { $ as loadTurnCheckpoint, $i as uploadFilesToConversation, $t as extractAssistantText, A as latestConversationMessageSeq, Ar as automationCreatorUserId, B as getAgentContextInputLimitTokens, Ba as SANDBOX_REPOS_ROOT, Bn as getPlugins, Br as cancelWatch, Ca as consumeSandboxEgressAuthRequiredSignal, Ci as setWorkspaceSnapshot, Cr as requireReviewItemLinks, Di as isStale, Dn as findLegacyWebActorUserId, Ei as hash, En as createUserTokenStore, Fa as PluginToolDeniedError, Fi as resolveBaseUrl, Fo as historyItemFromPiMessage, Fr as RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS, G as AuthPausePersistenceError, Ga as sandboxSkillPathResolution, Gi as getSlackMessagePermalink, Gr as findMatchingWatches, Gt as TurnBudgetExceededError, H as PluginCredentialFailureError, Ha as SANDBOX_WORKSPACE_ROOT, Hr as createTimerWatch, I as upsertConversationMessage, Io as piMessageFromHistoryItem, Ir as RESOURCE_SUBSCRIPTION_MAX_TTL_MS, J as abandonReplacedPendingAuth, Ja as runNonInteractiveCommand, K as AuthorizationFlowDisabledError, Ka as buildCommandScript, Ki as openSlackDirectMessage, Kr as getWatch, Kt as TurnSliceLimitExceededError, L as calculateContextCompactionTargetTokens, Li as escapeSlackMrkdwnText, Lo as projectConversationEvents, Lr as RESOURCE_WATCH_TOOL_SOURCE, M as normalizeConversationText, Ma as sleep, Mi as deliverOAuthAuthorization, Mr as resolveAssignees, N as recordDeliveredAssistantMessage, Na as tryWorkspaceRepoCheckoutPath, Ni as formatProviderLabel, Nn as createPluginHookRunner, Nr as resolveChannelCapabilities, Oa as buildSandboxEgressNetworkPolicy, Oi as ensureDockerDaemon, Oo as defaultTimezone, Or as EVERYONE_ASSIGNEE, Pa as workspaceRepoCheckoutPath, Pr as getSlackToolContext, Q as continuableMessages, Qi as updateSlackMessage, Qt as persistWithRetry, R as getAgentBackgroundCompactionMarkTokens, Ra as SANDBOX_COMMAND_PATH, Rn as getPluginTools, Ro as getConfigDefaults, Rr as STOP_WATCHING_TOOL_NAME, Sa as clearSandboxEgressSignals, Si as loadSnapshotsForProfile, Sr as requireReviewItemAssignees, T as resolveTaskTitle, Ta as createSandboxEgressCredentialToken, Ti as create, To as createPluginAnnotations, U as createPluginAuthOrchestration, Ua as sandboxSkillDir, Ui as addReactionToMessage, Ur as createWatch, V as createPluginEgress, Va as SANDBOX_SKILLS_ROOT, Vi as slackMention, W as authorizationId, Wa as sandboxSkillFile, Wi as deleteSlackMessage, Wr as deliverWatch, Wt as TURN_LIMIT_WRAP_UP_MESSAGE, X as clearPendingAuth, Xt as isTurnExecutionLimitExceededError, Y as canReusePendingAuthLink, Yi as postSlackMessage, Yt as createTurnLimitGate, Za as canAccessConversation, Zt as CODEMODE_TOOL_NAME, _a as wrapSandboxSetupError, _i as listWorkspaces, _n as TURN_CONTEXT_TAG, _r as canAgentChangeReviewItem, a as loadProjection, ai as getDashboardReviewItemLink, ar as dismissOpenReviewItems, at as failTurnRecord, b as persistConversationMessages, ba as isWorkspaceSnapshotNotReadyError, bi as WorkspaceValidationError, bn as readParentAgentTask, c as recordAgentsInstructionsUpdated, cn as isStandaloneRuntimeContextMessage, cr as insertReviewItem, da as withSlackRetries, dn as normalizeToolNameFromResult, en as getPiMessageRole, eo as readConversationAccessFromSql, f as recordAuthorizationRequested, fi as renderToolResultNudge, fn as retainRuntimeTurnContext, fr as searchReviewItems, g as recordToolExecutionStarted, ga as throwSandboxOperationError, gi as getWorkspaceByName, ha as isAlreadyExistsError, hi as getWorkspace, hn as REQUEST_CONTEXT_SECTION_TAG, hr as PLUGIN_REVIEW_ITEM_KEY_PREFIX, i as loadConversationProjection, ia as getFilePermalink, in as hasTurnInput, j as markConversationMessage, ja as SANDBOX_RUNTIME, jr as resolveAssignee, ka as resolveSandboxCommandEnvironment, ki as getSandboxProvider, kn as getOAuthAccountProviders, ko as resolveUserTimezone, kr as activeParticipantUserIds, l as recordAttachmentsDelivered, la as normalizeSlackConversationId, ln as isToolResultError, m as recordMcpProviderConnected, ma as isAbortError, mi as deleteWorkspace, mn as trimTrailingAssistantMessages, mr as updateReviewItemContent, na as SlackActionError, nn as getUserMessageInstructionText, nt as saveTurnCheckpoint, oa as getSlackClient, on as isAssistantMessage, or as getOpenReviewItemByDedupeKey, ot as getTurnRecord, p as recordGuardianActionReviewed, pi as createWorkspace, pn as stripRuntimeTurnContext, q as AuthorizationPauseError, qa as buildNonInteractiveShellScript, qr as listWatches, qt as TurnToolCallLimitExceededError, r as loadConnectedMcpProviders, ra as downloadPrivateSlackFile, ri as getDashboardConversationLink, rr as closeReviewItem, rt as abandonTurnRecord, sa as isConversationScopedChannel, si as getDashboardTaskLink, sn as isContinuablePiBoundary, sr as getReviewItem, t as commitAcceptedReply, ti as verifyTimerWatchCredentialSubject, tn as getTerminalAssistantMessages, ua as runWithSlackInstallationToken, ui as ToolInputError, un as isToolResultMessage, v as hydrateConversationMessages, va as WorkspaceSnapshotNotReadyError, vr as canReadReviewItem, w as fallbackShortTitle, wa as consumeSandboxEgressPermissionDeniedSignal, wi as setWorkspaceSnapshotBuild, wo as saveObjectAnnotations, xa as workspaceSnapshotNotReadyUserMessage, xi as invalidateReadySnapshot, xr as readReviewItemAgentScope, ya as getWorkspaceSnapshotNotReadyError, yi as updateWorkspace, yo as matchSlackAttachments, z as getAgentContextCompactionTriggerTokens, za as SANDBOX_DATA_ROOT, zi as normalizeSlackReplyMarkdown } from "./projection-DLQgfO5N.js";
3
+ import { A as estimateTextTokens, B as createAssistantProviderError, D as requestPrefixAttributes, E as resolveGatewayModel, G as isProviderRefusal, H as findProviderError, I as unwrapCurrentInstruction, J as resolveGatewayCredential, K as isProviderRetryError, L as escapeXml, M as COMPACTION_SUMMARY_PREFIX, N as hasCompactedConversationContext, O as estimateMessagesTokens, P as isCompactionSummaryText, U as getProviderErrorAttributes, V as createProviderError, _ as toPiReasoningLevel, b as GEN_AI_SERVER_ADDRESS, g as TURN_REASONING_LEVELS, j as textCharsForTokens, k as estimateRequestOverheadTokens, n as botConfig, q as getGatewayApiKey, v as normalizeSlackEmojiName, y as GEN_AI_PROVIDER_NAME, z as ProviderError } from "./config-mIZeGEWv.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-Cb6MGvdt.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-C6h-X2cZ.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 { $ 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-BlfjuqzW.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-ikZvFaMD.js";
7
+ import { $ as nextDetailVersion, A as SYSTEM_IDENTITY_ID, C as isTopLevelKind, E as conversationKindFromRow, G as addAgentTurnUsage, K as agentTurnCostUsd, M as resolveActorIdentityId, Q as conversationDetailTouch, S as isPersonInput, T as turnBehavior, X as resolveRootConversationId$1, Y as hasAgentTurnUsage, _ as setArchivedAt, a as getConversationStore, c as conversationIdsWithAnnotation, et as touchConversationDetail, g as readConversationTrees, h as conversationDescendants, i as getConversationMessageSearchStore, it as sameDestination, l as hasAnnotationKey, m as conversationAncestors, nt as parseDestination, o as getDb, r as getConversationEventStore, s as getSqlExecutor, u as treeHasAnnotationKey } from "./db--xuNV7g6.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-BItuRqAR.js";
9
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-X_xdFY9L.js";
12
- import { n as pluginCatalogRuntime } from "./catalog-runtime-Cj9I0dco.js";
13
- import { a as parseSkillInvocation, i as parseSkillFile, n as findSkillByName, r as loadSkillsByName, t as discoverSkills } from "./skills-BeUfmYXL.js";
14
- import { l as completeObject, o as isEventConversationMessage, r as EVENT_AUTHOR_ID, u as completeText } from "./prompt-exicBZeb.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-MtwokaqW.js";
12
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-CLMA9AXd.js";
13
+ import { a as parseSkillInvocation, i as parseSkillFile, n as findSkillByName, r as loadSkillsByName, t as discoverSkills } from "./skills-e3DDNlKO.js";
14
+ import { l as completeObject, o as isEventConversationMessage, r as EVENT_AUTHOR_ID, u as completeText } from "./prompt-qp_LdxLX.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-4CxdwLLQ.js";
17
- import { r as getStateAdapter } from "./adapter-Cigb1MTr.js";
16
+ import { a as readActorIdentityFromSql, f as identityAvatarUrl, h as readUserAvatarUrls, i as readActorIdentity } from "./viewer-CjRFHR5U.js";
17
+ import { r as getStateAdapter } from "./adapter-DxLhJEnO.js";
18
18
  import { i as getFirstRunAtMs, o as getZonedDateTimeParts, s as isValidTimeZone } from "./schedule-cP0AACm1.js";
19
- import { K as briefLinkSchema, W as readMessageAttachments, Z as parseStoredBrief, q as briefOutcomeStatusSchema, z as removedCardSchema } from "./conversation-CtjR1Zcx.js";
20
- import { i as createCacheWarmingRecorder, l as readLastUserMessageAtByConversation } from "./warmup-B62hd4lD.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-CqZBPe9g.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-D0bwI462.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-ZjLRGHm2.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-DNucbmPf.js";
19
+ import { K as briefLinkSchema, W as readMessageAttachments, Z as parseStoredBrief, q as briefOutcomeStatusSchema, z as removedCardSchema } from "./conversation-CDWejM4R.js";
20
+ import { i as createCacheWarmingRecorder, l as readLastUserMessageAtByConversation } from "./warmup-DuxCtzKC.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-D2j-0XkH.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-BqTTx3XG.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-iTtEdDyc.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, ft as readAutomationResult, lt as FINISH_AUTOMATION_RUN_TOOL_NAME, ot as JUNIOR_PERSONALITY, p as listActiveMailboxTurns, pt as remindMissingAutomationResult, 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-CeCXL3j9.js";
25
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";
26
- import { a as setSnapshotSpanAttributes, i as postinstall, n as resolve$1, r as dependencies, s as getSandboxResources } from "./resolve-B9dYN-nS.js";
27
- import { S as requestConversationWork, T as stopConversationWork, g as getConversationWorkState, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage } from "./store-CS0xoqXW.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-DjjHCX_m.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-89JZHWCE.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-CrsYnvdV.js";
26
+ import { a as setSnapshotSpanAttributes, i as postinstall, n as resolve$1, r as dependencies, s as getSandboxResources } from "./resolve-BnJA0UNE.js";
27
+ import { S as requestConversationWork, T as stopConversationWork, g as getConversationWorkState, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage } from "./store-C8LsaJwS.js";
28
+ import { $ as readAutomationExecutionByConversationId, At as requireValidEventTrigger, B as setEventAutomationStatus, C as deleteScheduledAutomation, Ct as eventWatchUnavailable, D as saveScheduledAutomation, Dt as registeredEventTypeSchema, E as readScheduledAutomation, Et as registeredEventTriggerProblems, G as listAutomationVersions, I as getEventAutomation, K as readAutomationVersion, L as listDeletedEventAutomationsCreatedBy, N as createEventAutomation, Ot as registeredResourceTypeSchema, P as deleteEventAutomation, R as parseEventAutomationRow, S as createScheduledAutomation, St as eventNamespaceSchema, T as parseScheduledAutomationRow, Tt as registeredEventMatchSchema, U as automationDefinition, X as requireAutomationRevision, Y as automationRevision, Z as emptyAutomationRunWindows, d as getDispatchRecord, et as readAutomationExecutionStatusDays, ft as getPersistedSandboxState, gt as coerceThreadConversationState, ht as persistThreadStateById, it as readAutomationRuns, kt as requireEventIdentifier, l as getDispatchIdForConversation, lt as resolveConversationRouting, n as scheduleSessionCompletedPluginTasks, nt as readAutomationExecutionSummaries, pt as getPersistedThreadState, q as sameDefinitionValue, rt as readAutomationExecutions, t as processPluginTask, tt as readAutomationExecutionStatusHours, u as getDispatchInputMessageId, ut as resolveTurnSessionRouting, vt as automationEventCatalog, wt as hasEventCatalogEntries, yt as describeRegisteredEventTrigger, z as saveEventAutomation } from "./task-runner-Dw7exu0-.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-kio5nXSD.js";
30
+ import { A as eventAutomationTriggerSchema, D as automationTitleSchema, E as automationInstructionToolSchema, F as compileScheduleIntent, H as automationTaskSchema, I as scheduleIntentFromTool, L as toolScheduleIntentSchema, O as taskOutcomeInputSchema, P as ScheduleIntentError, R as weekdaySchema, T as automationContextToolSchema, U as automationTaskText, V as automationTaskDescription, j as SCHEDULED_AUTOMATION_SYSTEM_ACTOR, l as automationListQuerySchema, z as automationSkillNameSchema } from "./automation-BM-OBsKW.js";
31
31
  import { n as privateTraceResultAttributes } from "./private-trace-result-CE7_lEdq.js";
32
32
  import { streamSimple } from "@earendil-works/pi-ai/compat";
33
33
  import { createGatewayProvider } from "@ai-sdk/gateway";
@@ -37,7 +37,7 @@ import { isDeepStrictEqual } from "node:util";
37
37
  import { AsyncLocalStorage } from "node:async_hooks";
38
38
  import { createHash, randomBytes, randomInt, randomUUID } from "node:crypto";
39
39
  import * as z from "zod";
40
- import { and, asc, count, desc, eq, exists, gt, gte, ilike, inArray, isNotNull, isNull, lt, lte, max, ne, notExists, notInArray, or, sql } from "drizzle-orm";
40
+ import { and, asc, count, desc, eq, gt, gte, ilike, inArray, isNotNull, isNull, lt, lte, max, ne, notExists, notInArray, or, sql } from "drizzle-orm";
41
41
  import { PluginToolInputError, agentEventKeys, agentEventMatchKey, agentEventMatchSchema, createWebSource, declaredEventKeys, eventMatchFieldSchema, eventSchema, eventTriggerText, localDestinationSchema, missingToolAnnotationKeys, ownedObjectAnnotationSchema, sourceSchema, stableEventMatchKey, watchResultSchema } from "@sentry/junior-plugin-api";
42
42
  import { alias } from "drizzle-orm/pg-core";
43
43
  import { Agent, estimateContextTokens } from "@earendil-works/pi-agent-core";
@@ -704,7 +704,7 @@ function buildChatEndAttributes(message, mode) {
704
704
  if (message.model) attributes["gen_ai.response.model"] = message.model;
705
705
  if (message.responseId) attributes["gen_ai.response.id"] = message.responseId;
706
706
  if (message.stopReason === "error") {
707
- const providerError = createProviderError(message.errorMessage ?? "");
707
+ const providerError = createAssistantProviderError(message);
708
708
  Object.assign(attributes, getProviderErrorAttributes(providerError));
709
709
  attributes["error.type"] = providerError.kind;
710
710
  }
@@ -917,6 +917,7 @@ function buildTurnResult(input) {
917
917
  }
918
918
  function buildDiagnostics(input, result) {
919
919
  const { outcome, errorMessage, lastAssistant } = result;
920
+ const assistant = isAssistantMessage(lastAssistant) ? lastAssistant : void 0;
920
921
  const toolResults = input.newMessages.filter(isToolResultMessage);
921
922
  return {
922
923
  outcome,
@@ -931,9 +932,12 @@ function buildDiagnostics(input, result) {
931
932
  usage: input.usage,
932
933
  stopReason: result.stopReason,
933
934
  errorMessage,
934
- providerError: outcome === "provider_error" && errorMessage ? createProviderError(errorMessage, {
935
+ providerError: outcome === "provider_error" && errorMessage ? createAssistantProviderError({
936
+ errorMessage,
937
+ rawStopReason: assistant?.rawStopReason
938
+ }, {
935
939
  modelId: input.modelId,
936
- retryable: isAssistantMessage(lastAssistant) && isRetryableAssistantError(lastAssistant)
940
+ retryable: assistant ? isRetryableAssistantError(assistant) : false
937
941
  }) : void 0
938
942
  };
939
943
  }
@@ -991,6 +995,20 @@ function nextProviderRetry(args) {
991
995
  providerError
992
996
  };
993
997
  }
998
+ /**
999
+ * Return the messages to send to the refusal fallback model, or undefined
1000
+ * when the failure is not a provider refusal or no fallback model is set.
1001
+ */
1002
+ function nextRefusalFallback(args) {
1003
+ if (!args.fallbackModelId || !args.failure || args.failure.stopReason !== "error" || !isProviderRefusal(args.failure)) return;
1004
+ const messages = trimTrailingAssistantMessages(args.messages);
1005
+ const tailRole = getPiMessageRole(messages.at(-1));
1006
+ if (messages.length === args.messages.length || tailRole !== "user" && tailRole !== "toolResult") return;
1007
+ return {
1008
+ messages,
1009
+ modelId: args.fallbackModelId
1010
+ };
1011
+ }
994
1012
  // src/chat/services/empty-output-continuation.ts
995
1013
  /**
996
1014
  * Decide whether empty assistant output gets one continuation after a
@@ -1370,6 +1388,19 @@ async function loadRunSkill(args) {
1370
1388
  if (loadedSkill) upsertActiveSkill(args.activeSkills, loadedSkill);
1371
1389
  return loadedSkill;
1372
1390
  }
1391
+ // src/chat/automations/skill.ts
1392
+ /**
1393
+ * Skills that an Automation can run. Any discovered skill can run, also a
1394
+ * skill with `disable-model-invocation`, because the Automation names it.
1395
+ */
1396
+ /** Find an installed skill by name. */
1397
+ async function findAutomationSkill(name) {
1398
+ return (await discoverSkills()).find((skill) => skill.name === name);
1399
+ }
1400
+ /** Say why an Automation whose skill is gone cannot run. */
1401
+ function missingAutomationSkillReason(name) {
1402
+ return `The skill ${name} is no longer installed. Choose another skill or switch to an instruction.`;
1403
+ }
1373
1404
  // src/chat/capabilities/jr-rpc-command.ts
1374
1405
  function commandResult(input) {
1375
1406
  let stdout = "";
@@ -5969,7 +6000,7 @@ function createSpawnAgentTool(spawnAgent, titleCost) {
5969
6000
  // src/chat/conversations/delivery-pause.ts
5970
6001
  /** True when the Conversation is a root that delivers to a Location. */
5971
6002
  function canPauseConversationDelivery(conversation) {
5972
- return conversation.kind === "root" && conversation.location !== void 0;
6003
+ return isTopLevelKind(conversation.kind) && conversation.location !== void 0;
5973
6004
  }
5974
6005
  const rootConversation = (conversationId) => and(eq(juniorConversations.conversationId, conversationId), isNull(juniorConversations.parentConversationId));
5975
6006
  /**
@@ -6348,7 +6379,7 @@ async function wakePausedTurn(request, options = {}) {
6348
6379
  const conversation = await (options.conversationStore ?? getConversationStore()).get({ conversationId: request.conversationId });
6349
6380
  await requestConversationWork({
6350
6381
  conversationId: request.conversationId,
6351
- destination: conversation && conversation.kind !== "root" ? void 0 : request.destination,
6382
+ destination: conversation && !isTopLevelKind(conversation.kind) ? void 0 : request.destination,
6352
6383
  nowMs,
6353
6384
  state: options.state
6354
6385
  });
@@ -6779,10 +6810,14 @@ function createConversationTurnWorker(agentRunner, deliverMessage) {
6779
6810
  visibility
6780
6811
  });
6781
6812
  const webActor = actor.platform === "web" ? actor : void 0;
6782
- const disabledFeatures = [...webActor ? [] : ["interactive-auth"], ...isThread ? ["subagents"] : []];
6813
+ const disabledFeatures = webActor ? [] : ["interactive-auth"];
6783
6814
  const conversationLocation = storedConversation?.location;
6784
6815
  const isEventTurn = source.kind === "event" || savedMessageIsEvent;
6785
- const deliverToProvider = Boolean(conversationLocation) && isEventTurn && storedConversation?.kind === "root";
6816
+ const deliverToProvider = Boolean(conversationLocation) && isEventTurn && turnBehavior({
6817
+ kind: storedConversation?.kind ?? "root",
6818
+ personInput: false,
6819
+ automationRun: false
6820
+ }).delivery === "location";
6786
6821
  const surface = deliverToProvider ? "slack" : "api";
6787
6822
  const inputTelemetry = resolved.kind === "mailbox" ? turnInputTelemetry(resolved.batch.map((entry) => entry.message)) : void 0;
6788
6823
  const turnTrace = inputTelemetry ?? (savedTurn?.traceContext ? { traceContexts: [savedTurn.traceContext] } : void 0);
@@ -8148,7 +8183,7 @@ function storedActorFromWeb(actor) {
8148
8183
  * Conversation: a dashboard Conversation, a Slack thread, or a Thread.
8149
8184
  */
8150
8185
  function acceptsWebMessages(conversation) {
8151
- if (conversation.kind !== "root") return conversation.kind === "thread";
8186
+ if (!isTopLevelKind(conversation.kind)) return conversation.kind === "thread";
8152
8187
  const { conversationId, destination } = conversation;
8153
8188
  if (destination?.platform === "slack") return true;
8154
8189
  return destination?.platform === "local" && conversationId.startsWith("local:web:");
@@ -8224,7 +8259,7 @@ async function recordWebConversationActivity(args) {
8224
8259
  ...isNewRoot && args.rootTitle ? { title: args.rootTitle } : void 0,
8225
8260
  ...isNewRoot ? { visibility } : void 0
8226
8261
  });
8227
- return existing && existing.kind !== "root" ? void 0 : destination;
8262
+ return existing && !isTopLevelKind(existing.kind) ? void 0 : destination;
8228
8263
  }
8229
8264
  /** Create a Conversation from web input and enqueue its first Message. */
8230
8265
  async function createAndEnqueueConversation(input, options) {
@@ -9350,7 +9385,9 @@ function viewerAutomationCollection(viewer) {
9350
9385
  destination: sql`${automation.teamId} || ':' || ${automation.channelId}`.as("destination"),
9351
9386
  destinationLabel: sql`coalesce(nullif(${destination.displayName}, ''), ${automation.channelId})`.as("destination_label"),
9352
9387
  isPublic: publicDestination.as("is_public"),
9353
- instruction: automation.instruction
9388
+ instruction: automation.instruction,
9389
+ skill: automation.skill,
9390
+ task: sql`${automation.record}->'task'`.as("task")
9354
9391
  }).from(automation).leftJoin(destination, and(eq(destination.provider, "slack"), eq(destination.providerTenantId, automation.teamId), eq(destination.providerDestinationId, automation.channelId))).where(and(ne(automation.status, "deleted"), or(owned, sharedToViewer))).as("accessible_automations");
9355
9392
  }
9356
9393
  /**
@@ -9375,7 +9412,7 @@ async function readAutomationCollection(viewer, input) {
9375
9412
  const unavailableIds = await unavailableEventAutomationIds(collection);
9376
9413
  const unavailable = unavailableIds.length > 0 ? inArray(collection.id, unavailableIds) : sql`false`;
9377
9414
  const attention = and(notInArray(collection.state, ["paused", "completed"]), or(eq(collection.state, "blocked"), unavailable, eq(collection.lastRunNeedsAttention, true)));
9378
- const where = and(input.scope === "mine" ? eq(collection.owned, true) : input.scope === "public" ? eq(collection.isPublic, true) : input.scope === "attention" ? attention : void 0, input.type === "all" ? void 0 : eq(collection.kind, input.type), input.state === "all" ? void 0 : input.state === "unavailable" ? unavailable : eq(collection.state, input.state), input.creator ? eq(collection.creator, input.creator) : void 0, input.destination ? eq(collection.destination, input.destination) : void 0, input.q ? sql`(strpos(lower(concat_ws(' ', ${collection.title}, ${collection.instruction}, ${collection.resource})), ${input.q.toLowerCase()}) > 0 or strpos(${input.q.toLowerCase()}, lower(${collection.id})) > 0)` : void 0);
9415
+ const where = and(input.scope === "mine" ? eq(collection.owned, true) : input.scope === "public" ? eq(collection.isPublic, true) : input.scope === "attention" ? attention : void 0, input.type === "all" ? void 0 : eq(collection.kind, input.type), input.state === "all" ? void 0 : input.state === "unavailable" ? unavailable : eq(collection.state, input.state), input.creator ? eq(collection.creator, input.creator) : void 0, input.destination ? eq(collection.destination, input.destination) : void 0, input.skill ? eq(collection.skill, input.skill) : void 0, input.q ? sql`(strpos(lower(concat_ws(' ', ${collection.title}, ${collection.instruction}, ${collection.skill}, ${collection.resource})), ${input.q.toLowerCase()}) > 0 or strpos(${input.q.toLowerCase()}, lower(${collection.id})) > 0)` : void 0);
9379
9416
  const [totals, counts, creators, destinations] = await Promise.all([
9380
9417
  db.select({ total: count() }).from(collection).where(where),
9381
9418
  db.select({
@@ -9395,7 +9432,7 @@ async function readAutomationCollection(viewer, input) {
9395
9432
  ]);
9396
9433
  const total = totals[0].total;
9397
9434
  const page = Math.min(input.page, Math.max(1, Math.ceil(total / input.pageSize)));
9398
- const order = input.sort === "oldest" ? asc(collection.createdAtMs) : input.sort === "title" ? asc(sql`lower(coalesce(nullif(trim(${collection.title}), ''), ${collection.instruction}))`) : desc(collection.createdAtMs);
9435
+ const order = input.sort === "oldest" ? asc(collection.createdAtMs) : input.sort === "title" ? asc(sql`lower(coalesce(nullif(trim(${collection.title}), ''), ${collection.instruction}, ${collection.skill}))`) : desc(collection.createdAtMs);
9399
9436
  return {
9400
9437
  rows: await db.select({
9401
9438
  id: collection.id,
@@ -9470,8 +9507,23 @@ function requireCredentialStart(automation, isCreator) {
9470
9507
  if (isCreator || automation.credentialMode !== "creator") return;
9471
9508
  throw new AutomationEditError(`This ${"schedule" in automation ? "scheduled" : "event"} automation uses its creator's credentials. Only the creator can resume it or run it now. Switch it to system credentials first.`, "credentialMode");
9472
9509
  }
9510
+ /** Return true when an edit changes what a run does. */
9511
+ function changesAutomationTask(current, input) {
9512
+ return input.task !== void 0 && !isDeepStrictEqual(input.task, current);
9513
+ }
9473
9514
  /**
9474
- * Apply shared title, instruction, outcome, and creator credential rules.
9515
+ * Require a newly selected skill to be installed. A kept skill that is gone
9516
+ * stays, so other fields can still be saved; its runs block until someone
9517
+ * picks another skill.
9518
+ */
9519
+ async function requireAutomationSkill(task, current) {
9520
+ if (task.kind !== "skill") return;
9521
+ if (current?.kind === "skill" && current.skill === task.skill) return;
9522
+ if (await findAutomationSkill(task.skill)) return;
9523
+ throw new AutomationEditError(`The skill ${task.skill} is not installed. Choose an installed skill.`, "task.skill");
9524
+ }
9525
+ /**
9526
+ * Apply shared title, task, outcome, and creator credential rules.
9475
9527
  * Anyone who can manage the Automation can change any field except turning on
9476
9528
  * creator credentials. A non-creator change to execution or outcomes switches
9477
9529
  * it to system credentials, so creator credential output stays where the
@@ -9493,10 +9545,12 @@ async function editAutomationFields(current, input, isCreator, changesExecution)
9493
9545
  destination: outcome.destination
9494
9546
  });
9495
9547
  }
9548
+ const task = input.task ?? current.task;
9549
+ await requireAutomationSkill(task, current.task);
9496
9550
  const changesOutcomes = !isDeepStrictEqual(outcomes, current.outcomes);
9497
9551
  return {
9498
9552
  title: input.title ?? current.title,
9499
- task: { text: input.instruction ?? current.task.text },
9553
+ task,
9500
9554
  credentialMode: (changesExecution || changesOutcomes) && !isCreator ? "system" : input.credentialMode ?? current.credentialMode,
9501
9555
  outcomes
9502
9556
  };
@@ -9515,7 +9569,7 @@ const compactEventAutomationResultSchema = z.object({
9515
9569
  status_reason: z.string().nullable(),
9516
9570
  title: z.string().min(1).nullable(),
9517
9571
  dashboard_url: z.string().url().nullable(),
9518
- instruction: z.string().min(1),
9572
+ task: automationTaskSchema,
9519
9573
  trigger: z.object({
9520
9574
  namespace: z.string().min(1),
9521
9575
  identifier: z.string().min(1).nullable(),
@@ -9626,7 +9680,7 @@ function compactEventAutomation(task, catalog, isCreator) {
9626
9680
  status_reason: task.statusReason ?? null,
9627
9681
  title: task.title?.trim() || null,
9628
9682
  dashboard_url: getDashboardTaskLink(task.id) ?? null,
9629
- instruction: task.task.text,
9683
+ task: task.task,
9630
9684
  trigger: {
9631
9685
  namespace: task.trigger.namespace,
9632
9686
  identifier: task.trigger.identifier ?? null,
@@ -9661,7 +9715,8 @@ function compactEventAutomation(task, catalog, isCreator) {
9661
9715
  async function eventAutomationToolResult(conversationId, task, catalog, isCreator) {
9662
9716
  const automation = compactEventAutomation(task, catalog, isCreator);
9663
9717
  const description = describeEventAutomationTrigger(task.trigger, catalog);
9664
- const title = automation.title ?? fallbackShortTitle(task.task.text, "Event automation");
9718
+ const taskDescription = automationTaskDescription(task.task);
9719
+ const title = automation.title ?? fallbackShortTitle(taskDescription, "Event automation");
9665
9720
  return {
9666
9721
  automation,
9667
9722
  objectCards: await saveObjectAnnotations(conversationId, "junior", [{
@@ -9671,7 +9726,7 @@ async function eventAutomationToolResult(conversationId, task, catalog, isCreato
9671
9726
  key: task.id,
9672
9727
  title,
9673
9728
  url: automation.dashboard_url,
9674
- description: task.task.text,
9729
+ description: taskDescription,
9675
9730
  status: description.problems.length === 0 ? "ready" : "unavailable",
9676
9731
  trigger: eventTriggerText(task.trigger.label, description),
9677
9732
  warning: description.problems.length > 0 ? ["Trigger unavailable.", ...description.problems].join(" ") : void 0
@@ -9700,7 +9755,7 @@ async function editEventAutomation(current, input, isCreator, catalog, options)
9700
9755
  label: inputTrigger.label
9701
9756
  };
9702
9757
  }
9703
- const changesExecution = input.instruction !== void 0 && input.instruction !== current.task.text || changesEventAutomationTrigger(current.trigger, trigger);
9758
+ const changesExecution = changesAutomationTask(current.task, input) || changesEventAutomationTrigger(current.trigger, trigger);
9704
9759
  const next = {
9705
9760
  ...current,
9706
9761
  ...await editAutomationFields(current, input, isCreator, changesExecution),
@@ -9728,7 +9783,7 @@ async function editScheduledAutomation(current, input, isCreator, nowMs) {
9728
9783
  if (error instanceof ScheduleIntentError) throw new AutomationEditError(error.message, "schedule");
9729
9784
  throw error;
9730
9785
  }
9731
- const fields = await editAutomationFields(current, input, isCreator, input.instruction !== void 0 && input.instruction !== current.task.text || compiled !== void 0 && !isDeepStrictEqual(compiled.schedule, current.schedule));
9786
+ const fields = await editAutomationFields(current, input, isCreator, changesAutomationTask(current.task, input) || compiled !== void 0 && !isDeepStrictEqual(compiled.schedule, current.schedule));
9732
9787
  return {
9733
9788
  ...current,
9734
9789
  ...fields,
@@ -9808,14 +9863,16 @@ function executionSummaryFields(stats) {
9808
9863
  ...stats?.lastConversationId ? { lastConversationId: stats.lastConversationId } : void 0,
9809
9864
  ...stats?.lastExecutedAtMs ? { lastRunAt: new Date(stats.lastExecutedAtMs).toISOString() } : void 0,
9810
9865
  costUsd: stats?.costUsd ?? emptyAutomationRunWindows(),
9866
+ recentRuns: stats?.recentRuns ?? [],
9811
9867
  runs: stats?.runs ?? emptyAutomationRunWindows(),
9868
+ totalCostUsd: stats?.totalCostUsd ?? 0,
9812
9869
  totalRuns: stats?.totalRuns ?? 0
9813
9870
  };
9814
9871
  }
9815
9872
  function scheduledAutomationSummary(task, ownedByViewer, destination, stats, creator) {
9816
9873
  if (task.status === "deleted") throw new Error("Deleted scheduled automations cannot enter the Automations view");
9817
9874
  const nextRunAtMs = task.status === "active" ? task.runNowAtMs ?? task.nextRunAtMs : void 0;
9818
- const instruction = displayText(task.task.text, "Untitled scheduled automation");
9875
+ const description = displayText(automationTaskDescription(task.task), "Untitled scheduled automation");
9819
9876
  return {
9820
9877
  createdAt: new Date(task.createdAtMs).toISOString(),
9821
9878
  createdBy: creatorLabel(task.createdBy),
@@ -9828,7 +9885,7 @@ function scheduledAutomationSummary(task, ownedByViewer, destination, stats, cre
9828
9885
  visibility: destination.visibility
9829
9886
  },
9830
9887
  id: task.id,
9831
- instruction,
9888
+ task: task.task,
9832
9889
  kind: "scheduled",
9833
9890
  ...executionSummaryFields(stats),
9834
9891
  ...nextRunAtMs !== void 0 ? { nextRunAt: new Date(nextRunAtMs).toISOString() } : void 0,
@@ -9839,11 +9896,11 @@ function scheduledAutomationSummary(task, ownedByViewer, destination, stats, cre
9839
9896
  timezone: task.schedule.timezone,
9840
9897
  credentialMode: task.credentialMode,
9841
9898
  outcomes: effectiveTaskOutcomes(task.outcomes, task.destination),
9842
- title: taskDisplayTitle(task.title, instruction, "Untitled scheduled automation")
9899
+ title: taskDisplayTitle(task.title, description, "Untitled scheduled automation")
9843
9900
  };
9844
9901
  }
9845
9902
  function eventAutomationSummary(task, ownedByViewer, destination, stats, creator) {
9846
- const instruction = task.task.text;
9903
+ const description = automationTaskDescription(task.task);
9847
9904
  const catalog = getEventCatalog();
9848
9905
  return {
9849
9906
  createdAt: new Date(task.createdAtMs).toISOString(),
@@ -9857,7 +9914,7 @@ function eventAutomationSummary(task, ownedByViewer, destination, stats, creator
9857
9914
  visibility: destination.visibility
9858
9915
  },
9859
9916
  id: task.id,
9860
- instruction,
9917
+ task: task.task,
9861
9918
  kind: "event",
9862
9919
  ...executionSummaryFields(stats),
9863
9920
  ownedByViewer,
@@ -9865,7 +9922,7 @@ function eventAutomationSummary(task, ownedByViewer, destination, stats, creator
9865
9922
  source: task.trigger.namespace,
9866
9923
  credentialMode: task.credentialMode,
9867
9924
  outcomes: effectiveTaskOutcomes(task.outcomes, task.destination),
9868
- title: taskDisplayTitle(task.title, instruction, "Untitled event automation"),
9925
+ title: taskDisplayTitle(task.title, description, "Untitled event automation"),
9869
9926
  status: task.status === "deleted" ? "active" : task.status,
9870
9927
  statusReason: task.statusReason,
9871
9928
  trigger: describeEventAutomationTrigger(task.trigger, catalog)
@@ -9929,29 +9986,15 @@ async function automationSummaryForCandidate(candidate) {
9929
9986
  if (candidate.kind === "scheduled") return scheduledAutomationSummary(candidate.task, candidate.ownedByViewer, destination, stats.get(candidate.task.id), creator);
9930
9987
  return eventAutomationSummary(candidate.task, candidate.ownedByViewer, destination, stats.get(candidate.task.id), creator);
9931
9988
  }
9932
- function emptyAutomationExecutionDay(date) {
9933
- return {
9934
- costUsd: 0,
9935
- date,
9936
- event: 0,
9937
- scheduled: 0
9938
- };
9939
- }
9940
9989
  function emptyAutomationExecutionStatusDay(date) {
9941
9990
  return {
9942
9991
  blocked: 0,
9943
9992
  completed: 0,
9993
+ costUsd: 0,
9944
9994
  date,
9945
9995
  failed: 0
9946
9996
  };
9947
9997
  }
9948
- function automationExecutionSixHours(hours, nowMs = Date.now()) {
9949
- return sumUtcHoursIntoSixHours({
9950
- empty: emptyAutomationExecutionDay,
9951
- hours,
9952
- nowMs
9953
- });
9954
- }
9955
9998
  function automationExecutionStatusSixHours(hours, nowMs = Date.now()) {
9956
9999
  return sumUtcHoursIntoSixHours({
9957
10000
  empty: emptyAutomationExecutionStatusDay,
@@ -9995,27 +10038,17 @@ async function readViewerAutomations(user, input = automationListQuerySchema.par
9995
10038
  const selected = await readTaskCandidates(user, ids);
9996
10039
  const [destinations, creators] = await Promise.all([destinationDetails(selected.map(({ task }) => task.destination)), creatorProfiles(selected)]);
9997
10040
  const visible = selected.filter((candidate) => candidate.ownedByViewer || destinations.get(destinationKey(candidate.task.destination))?.visibility === "public");
9998
- const collection = viewerAutomationCollection(user);
9999
- const access = exists(getDb().select({ id: collection.id }).from(collection).where(eq(collection.id, juniorAutomationRuns.automationId)));
10000
- const [executionDays, executionHours, stats] = await Promise.all([
10001
- readAutomationExecutionDays(90, { access }),
10002
- readAutomationExecutionHours(168, { access }),
10003
- readAutomationExecutionSummaries(ids)
10004
- ]);
10005
- const automations = visible.map((candidate) => {
10006
- const destination = destinations.get(destinationKey(candidate.task.destination)) ?? {
10007
- label: `Channel ${candidate.task.destination.channelId}`,
10008
- visibility: "private"
10009
- };
10010
- const creator = creators.get(creatorKey(candidate.task.destination.teamId, candidate.task.createdBy.slackUserId));
10011
- if (candidate.kind === "scheduled") return scheduledAutomationSummary(candidate.task, candidate.ownedByViewer, destination, stats.get(candidate.task.id), creator);
10012
- return eventAutomationSummary(candidate.task, candidate.ownedByViewer, destination, stats.get(candidate.task.id), creator);
10013
- });
10041
+ const stats = await readAutomationExecutionSummaries(ids);
10014
10042
  return {
10015
- executionDays,
10016
- executionHours,
10017
- executionSixHours: automationExecutionSixHours(executionHours),
10018
- automations,
10043
+ automations: visible.map((candidate) => {
10044
+ const destination = destinations.get(destinationKey(candidate.task.destination)) ?? {
10045
+ label: `Channel ${candidate.task.destination.channelId}`,
10046
+ visibility: "private"
10047
+ };
10048
+ const creator = creators.get(creatorKey(candidate.task.destination.teamId, candidate.task.createdBy.slackUserId));
10049
+ if (candidate.kind === "scheduled") return scheduledAutomationSummary(candidate.task, candidate.ownedByViewer, destination, stats.get(candidate.task.id), creator);
10050
+ return eventAutomationSummary(candidate.task, candidate.ownedByViewer, destination, stats.get(candidate.task.id), creator);
10051
+ }),
10019
10052
  ...page
10020
10053
  };
10021
10054
  }
@@ -10055,14 +10088,14 @@ async function readViewerAutomationRuns(user) {
10055
10088
  const automationTitles = /* @__PURE__ */ new Map();
10056
10089
  const automations = [];
10057
10090
  for (const task of taskList) {
10058
- automationTitles.set(`${task.kind}:${task.id}`, taskDisplayTitle(task.title ?? void 0, task.instruction, `Untitled ${task.kind} automation`));
10091
+ automationTitles.set(`${task.kind}:${task.id}`, taskDisplayTitle(task.title ?? void 0, automationTaskDescription(automationTaskSchema.parse(task.task)), `Untitled ${task.kind} automation`));
10059
10092
  automations.push({
10060
10093
  kind: task.kind,
10061
10094
  automationId: task.id
10062
10095
  });
10063
10096
  }
10064
10097
  for (const task of deletedScheduled) {
10065
- const instruction = displayText(task.task.text, "Untitled scheduled automation");
10098
+ const instruction = displayText(automationTaskDescription(task.task), "Untitled scheduled automation");
10066
10099
  addDeletedAutomationRun({
10067
10100
  kind: "scheduled",
10068
10101
  automationId: task.id,
@@ -10070,7 +10103,7 @@ async function readViewerAutomationRuns(user) {
10070
10103
  }, automationTitles, automations);
10071
10104
  }
10072
10105
  for (const task of deletedEvent) {
10073
- const instruction = displayText(task.task.text, "Untitled event automation");
10106
+ const instruction = displayText(automationTaskDescription(task.task), "Untitled event automation");
10074
10107
  addDeletedAutomationRun({
10075
10108
  kind: "event",
10076
10109
  automationId: task.id,
@@ -10168,7 +10201,7 @@ async function readConversationSourceTask(args) {
10168
10201
  if (!candidate) return base;
10169
10202
  const credential = await readRunCredential(dispatchId, candidate.task.createdBy);
10170
10203
  if (candidate.kind === "scheduled") {
10171
- const instruction = displayText(candidate.task.task.text, "Untitled scheduled automation");
10204
+ const instruction = displayText(automationTaskDescription(candidate.task.task), "Untitled scheduled automation");
10172
10205
  const schedule = candidate.task.schedule.description.trim();
10173
10206
  return {
10174
10207
  ...base,
@@ -10180,7 +10213,7 @@ async function readConversationSourceTask(args) {
10180
10213
  ...schedule ? { triggerLabel: schedule } : void 0
10181
10214
  };
10182
10215
  }
10183
- const instruction = displayText(candidate.task.task.text, "Untitled event automation");
10216
+ const instruction = displayText(automationTaskDescription(candidate.task.task), "Untitled event automation");
10184
10217
  const { events, label } = candidate.task.trigger;
10185
10218
  return {
10186
10219
  ...base,
@@ -10224,7 +10257,7 @@ function editView(automation, ownedByViewer) {
10224
10257
  id: task.id,
10225
10258
  revision: automationRevision(task),
10226
10259
  title: task.title ?? null,
10227
- instruction: task.task.text,
10260
+ task: task.task,
10228
10261
  credentialMode: task.credentialMode,
10229
10262
  outcomes: task.outcomes,
10230
10263
  destination: task.destination,
@@ -10350,7 +10383,7 @@ async function activateViewerAutomationVersion(user, id, input) {
10350
10383
  if (sameDefinitionValue(definition, automationDefinition(current.task))) return editView(current, current.ownedByViewer);
10351
10384
  if (!sameDefinitionValue(definition.destination, current.task.destination)) throw new AutomationEditError("This version delivers to another Destination. Move the automation from Slack instead.", "destination");
10352
10385
  const fields = {};
10353
- if (definition.instruction !== current.task.task.text) fields.instruction = definition.instruction;
10386
+ if (!sameDefinitionValue(definition.task, current.task.task)) fields.task = definition.task;
10354
10387
  if (definition.credentialMode !== current.task.credentialMode) fields.credentialMode = definition.credentialMode;
10355
10388
  if (!sameDefinitionValue(definition.outcomes, current.task.outcomes)) fields.outcomes = await restorableOutcomes(current, definition.outcomes);
10356
10389
  const title = definition.title ?? void 0;
@@ -10466,6 +10499,7 @@ async function deleteAutomation(current) {
10466
10499
  });
10467
10500
  }
10468
10501
  // src/chat/automations/tool-access.ts
10502
+ /** Automation access for the Automation tools. */
10469
10503
  /**
10470
10504
  * Return the Actor when that person started this Turn from any surface.
10471
10505
  * Automation runs, Events, plugin dispatch, and Agent invocations act for no
@@ -10580,13 +10614,14 @@ const MAX_SEARCHED_AUTOMATIONS = 50;
10580
10614
  /** Model-facing input of the Automation search tool. */
10581
10615
  const automationSearchInputSchema = z.object({
10582
10616
  type: z.enum(["scheduled", "event"]).nullable().describe("scheduled: only automations with a schedule. event: only automations that run on events. Omit to find both.").optional(),
10583
- query: z.string().trim().min(1).max(200).nullable().describe("Text in the title or instruction, an automation ID, or a dashboard URL.").optional(),
10617
+ query: z.string().trim().min(1).max(200).nullable().describe("Text in the title, instruction, or skill name, an automation ID, or a dashboard URL.").optional(),
10584
10618
  scope: z.enum([
10585
10619
  "all",
10586
10620
  "current_conversation",
10587
10621
  "mine"
10588
10622
  ]).nullable().describe("Omit to search everything the requester can find. Set current_conversation (only automations that deliver to this conversation) or mine (only automations the requester created) only when the user limits the search that way.").optional(),
10589
- destination: z.string().trim().min(1).max(300).nullable().describe("Limit results to automations that deliver to this destination. Use destination.id from an earlier result.").optional()
10623
+ destination: z.string().trim().min(1).max(300).nullable().describe("Limit results to automations that deliver to this destination. Use destination.id from an earlier result.").optional(),
10624
+ skill: automationSkillNameSchema.nullable().describe("Only automations that run this skill, by exact name.").optional()
10590
10625
  }).strict();
10591
10626
  /**
10592
10627
  * Search Automations with the dashboard Automations search, as the tool
@@ -10604,6 +10639,7 @@ async function searchToolAutomations(context, caller, input) {
10604
10639
  scope: input.scope === "mine" ? "mine" : "all",
10605
10640
  type: input.type ?? "all",
10606
10641
  destination,
10642
+ skill: input.skill ?? void 0,
10607
10643
  pageSize: MAX_SEARCHED_AUTOMATIONS
10608
10644
  }));
10609
10645
  return {
@@ -10661,7 +10697,7 @@ const compactTaskResultSchema = z.object({
10661
10697
  created_at: z.string().datetime(),
10662
10698
  updated_at: z.string().datetime(),
10663
10699
  original_request: z.string().nullable(),
10664
- instruction: z.string(),
10700
+ task: automationTaskSchema,
10665
10701
  schedule: z.string(),
10666
10702
  timezone: z.string(),
10667
10703
  recurrence: z.unknown().nullable(),
@@ -10725,7 +10761,7 @@ function compactTask(task, isCreator) {
10725
10761
  created_at: new Date(task.createdAtMs).toISOString(),
10726
10762
  updated_at: new Date(task.updatedAtMs).toISOString(),
10727
10763
  original_request: task.originalRequest ?? null,
10728
- instruction: task.task.text,
10764
+ task: task.task,
10729
10765
  schedule: task.schedule.description,
10730
10766
  timezone: task.schedule.timezone,
10731
10767
  recurrence: task.schedule.recurrence ? {
@@ -10765,7 +10801,8 @@ function compactTask(task, isCreator) {
10765
10801
  /** Build the result of a tool that changed one scheduled automation, with its card. */
10766
10802
  async function scheduleAutomationToolResult(conversationId, task, isCreator) {
10767
10803
  const automation = compactTask(task, isCreator);
10768
- const title = automation.title ?? fallbackShortTitle(automation.instruction, "Scheduled automation");
10804
+ const description = automationTaskDescription(task.task);
10805
+ const title = automation.title ?? fallbackShortTitle(description, "Scheduled automation");
10769
10806
  const annotation = {
10770
10807
  kind: "object",
10771
10808
  objectType: "automation",
@@ -10773,7 +10810,7 @@ async function scheduleAutomationToolResult(conversationId, task, isCreator) {
10773
10810
  key: task.id,
10774
10811
  title,
10775
10812
  url: automation.dashboard_url,
10776
- description: automation.instruction,
10813
+ description,
10777
10814
  status: automation.status,
10778
10815
  trigger: task.schedule.kind === "one_off" && task.nextRunAtMs !== void 0 ? `${new Intl.DateTimeFormat("en-US", {
10779
10816
  dateStyle: "medium",
@@ -10818,6 +10855,50 @@ function automationTriggerSchema(catalog) {
10818
10855
  function automationTriggerChangesSchema(catalog) {
10819
10856
  return z.discriminatedUnion("type", [scheduleTriggerSchema, registeredEventAutomationTriggerChangesSchema(catalog).extend({ type: z.literal("event") })]);
10820
10857
  }
10858
+ /**
10859
+ * Build the skill input of the create and update tools. The description
10860
+ * lists every discovered skill, because `<available-skills>` leaves out the
10861
+ * ones with `disable-model-invocation`, and an Automation can run those too.
10862
+ */
10863
+ function automationSkillToolSchema(skills) {
10864
+ const names = skills.map((skill) => skill.disableModelInvocation ? `${skill.name} (manual only)` : skill.name);
10865
+ return automationSkillNameSchema.describe(`Skill that each run invokes instead of a written instruction. Any installed skill works, including manual-only ones. Installed skills: ${names.length > 0 ? names.join(", ") : "none"}.`);
10866
+ }
10867
+ /** Map the task fields of a new Automation to its task. */
10868
+ function newAutomationTask(input) {
10869
+ const task = editedAutomationTask(void 0, input);
10870
+ if (!task) throw new ToolInputError("Set instruction or skill.");
10871
+ return task;
10872
+ }
10873
+ /**
10874
+ * Map the task fields of an update to the saved task, or undefined when they
10875
+ * change nothing. `instruction` switches to an instruction. `skill` switches
10876
+ * to a skill and keeps the current context. `context` needs skill mode.
10877
+ */
10878
+ function editedAutomationTask(current, input) {
10879
+ const { instruction, skill, context } = input;
10880
+ if (instruction !== void 0 && skill !== void 0) throw new ToolInputError("Set instruction or skill, not both.");
10881
+ if (instruction !== void 0) {
10882
+ if (context !== void 0) throw new ToolInputError("Context goes only with a skill. Put everything in the instruction.");
10883
+ return {
10884
+ kind: "instruction",
10885
+ instruction
10886
+ };
10887
+ }
10888
+ const kept = current?.kind === "skill" ? current : void 0;
10889
+ const nextSkill = skill ?? kept?.skill;
10890
+ if (nextSkill === void 0) {
10891
+ if (context === void 0) return void 0;
10892
+ throw new ToolInputError("Context goes only with a skill. Set skill, or change the instruction instead.");
10893
+ }
10894
+ if (skill === void 0 && context === void 0) return void 0;
10895
+ const nextContext = context === void 0 ? kept?.context : context;
10896
+ return {
10897
+ kind: "skill",
10898
+ skill: nextSkill,
10899
+ ...nextContext ? { context: nextContext } : void 0
10900
+ };
10901
+ }
10821
10902
  /** Return the Automation kind of a trigger input. */
10822
10903
  function triggerKind(trigger) {
10823
10904
  return trigger.type === "schedule" ? "scheduled" : "event";
@@ -10932,7 +11013,7 @@ async function createScheduled(context, next, compiled) {
10932
11013
  schedule: compiled.schedule,
10933
11014
  status: "active",
10934
11015
  outcomes: next.outcomes,
10935
- task: { text: next.instruction },
11016
+ task: next.task,
10936
11017
  ...next.title ? { title: next.title } : void 0
10937
11018
  });
10938
11019
  logInfo("scheduled_automation.create.completed", scheduledAutomationAttributes(task));
@@ -10954,7 +11035,7 @@ async function createEvent(context, next, trigger) {
10954
11035
  credentialMode: next.credentialMode,
10955
11036
  destination: next.destination,
10956
11037
  outcomes: next.outcomes,
10957
- task: { text: next.instruction },
11038
+ task: next.task,
10958
11039
  ...next.title ? { title: next.title } : void 0,
10959
11040
  trigger
10960
11041
  })),
@@ -10980,7 +11061,7 @@ async function readReplayedAutomation(kind, id) {
10980
11061
  } : void 0;
10981
11062
  }
10982
11063
  /** Create the tool that stores a scheduled or event Automation. */
10983
- function createAutomationTool(context, catalog) {
11064
+ function createAutomationTool(context, catalog, skills = []) {
10984
11065
  const trigger = automationTriggerSchema(catalog);
10985
11066
  return zodTool({
10986
11067
  exposure: "deferred",
@@ -10993,10 +11074,12 @@ function createAutomationTool(context, catalog) {
10993
11074
  readOnlyHint: false
10994
11075
  },
10995
11076
  executionMode: "sequential",
10996
- description: "Create a durable automation. It belongs to the channel or DM of this conversation, never a thread. Its outcomes set where its messages go. Use trigger type \"schedule\" for one-time or recurring work. Use trigger type \"event\" only when the user explicitly asks for an event automation or durable whenever-this-happens-do-X work; it runs the instruction for every matching event. Ordinary watch, notify, or tell-me-when requests use watchEvents instead. Store the requested future work; do not perform it or check its service access now unless the user also asks for that. When the trigger is known, create it without redundant confirmation.",
11077
+ description: "Create a durable automation. It belongs to the channel or DM of this conversation, never a thread. Its outcomes set where its messages go. Use trigger type \"schedule\" for one-time or recurring work. Use trigger type \"event\" only when the user explicitly asks for an event automation or durable whenever-this-happens-do-X work; it runs for every matching event. Set instruction for written work, or skill to run an installed skill, with context only when the skill needs more. Ordinary watch, notify, or tell-me-when requests use watchEvents instead. Store the requested future work; do not perform it or check its service access now unless the user also asks for that. When the trigger is known, create it without redundant confirmation.",
10997
11078
  inputSchema: z.object({
10998
- instruction: automationInstructionToolSchema,
10999
- title: z.string().trim().min(1).max(60).nullable().describe("Optional short display title. Omit or use null to generate one from the instruction.").optional(),
11079
+ instruction: automationInstructionToolSchema.nullable().optional(),
11080
+ skill: automationSkillToolSchema(skills).nullable().optional(),
11081
+ context: automationContextToolSchema.nullable().optional(),
11082
+ title: z.string().trim().min(1).max(60).nullable().describe("Optional short display title. Omit or use null to generate one from the instruction or skill.").optional(),
11000
11083
  trigger,
11001
11084
  outcomes: z.array(taskOutcomeInputSchema).max(5).describe("Successful work is silent by default. Omit this field or use an empty list when the Automation should act through tools without a status message. Add send_message only when the user asks for a reminder, notification, post, digest, summary, or other visible result.").optional(),
11002
11085
  credential_mode: z.enum(["creator", "system"]).nullable().describe("Use creator to make the creator's connected credentials available, or system when the creator says not to use them. Omit or use null for the creator default.").optional()
@@ -11004,6 +11087,9 @@ function createAutomationTool(context, catalog) {
11004
11087
  prepareArguments(args) {
11005
11088
  const prepared = { ...args };
11006
11089
  if (prepared.title == null) delete prepared.title;
11090
+ if (prepared.instruction == null) delete prepared.instruction;
11091
+ if (prepared.skill == null) delete prepared.skill;
11092
+ if (prepared.context == null) delete prepared.context;
11007
11093
  if (prepared.credential_mode === "creator" || prepared.credential_mode === null) delete prepared.credential_mode;
11008
11094
  return prepared;
11009
11095
  },
@@ -11014,7 +11100,14 @@ function createAutomationTool(context, catalog) {
11014
11100
  const caller = await requireToolCaller(context);
11015
11101
  const creator = requireToolCreator(caller, destination, kind);
11016
11102
  const { createdBy } = creator;
11017
- requireInstructionReferences(input.instruction, {
11103
+ const task = newAutomationTask({
11104
+ instruction: input.instruction ?? void 0,
11105
+ skill: input.skill ?? void 0,
11106
+ context: input.context ?? void 0
11107
+ });
11108
+ await requireAutomationSkill(task, void 0);
11109
+ const text = automationTaskText(task);
11110
+ if (text) requireInstructionReferences(text, {
11018
11111
  creator: createdBy,
11019
11112
  destinationChannelId: destination.channelId
11020
11113
  });
@@ -11042,15 +11135,15 @@ function createAutomationTool(context, catalog) {
11042
11135
  creator,
11043
11136
  destination,
11044
11137
  id,
11045
- instruction: input.instruction,
11046
11138
  nowMs,
11139
+ task,
11047
11140
  credentialMode: input.credential_mode ?? "creator",
11048
11141
  outcomes: await resolveTaskOutcomes(input.outcomes, destination, createdBy.slackUserId),
11049
11142
  title: await resolveTaskTitle({
11050
11143
  signal: options.signal,
11051
11144
  completeText,
11052
11145
  cost: { conversationId: context.conversationId },
11053
- instruction: input.instruction,
11146
+ instruction: automationTaskDescription(task),
11054
11147
  title: input.title
11055
11148
  })
11056
11149
  };
@@ -11434,7 +11527,7 @@ async function requireMoveDestination(context, value) {
11434
11527
  };
11435
11528
  }
11436
11529
  /** Edit and save a scheduled Automation, including a move to a new Destination. */
11437
- async function updateScheduled(context, current, input, editor) {
11530
+ async function updateScheduled(context, current, input, editedTask, editor) {
11438
11531
  const { task, ownedByViewer: isCreator } = current;
11439
11532
  const target = input.destination ? await requireMoveDestination(context, input.destination) : void 0;
11440
11533
  const destination = target?.destination;
@@ -11443,7 +11536,7 @@ async function updateScheduled(context, current, input, editor) {
11443
11536
  if (moving) await requireNoIncompleteRun(task.id);
11444
11537
  const next = await editScheduledAutomation(task, {
11445
11538
  title: input.title,
11446
- instruction: input.instruction,
11539
+ task: editedTask,
11447
11540
  schedule: input.trigger?.type === "schedule" ? scheduleIntentFromTool(input.trigger.schedule) : void 0,
11448
11541
  credentialMode: input.credential_mode,
11449
11542
  outcomes: moving ? void 0 : input.outcomes
@@ -11462,12 +11555,12 @@ async function updateScheduled(context, current, input, editor) {
11462
11555
  };
11463
11556
  }
11464
11557
  /** Edit and save an event Automation. */
11465
- async function updateEvent(current, input, editor, catalog) {
11558
+ async function updateEvent(current, input, editedTask, editor, catalog) {
11466
11559
  const { task } = current;
11467
11560
  const trigger = input.trigger?.type === "event" ? input.trigger : void 0;
11468
11561
  const next = await editEventAutomation(task, {
11469
11562
  title: input.title,
11470
- instruction: input.instruction,
11563
+ task: editedTask,
11471
11564
  trigger: trigger ? {
11472
11565
  ...trigger,
11473
11566
  ...trigger.namespace === task.trigger.namespace ? {
@@ -11487,12 +11580,15 @@ async function updateEvent(current, input, editor, catalog) {
11487
11580
  };
11488
11581
  }
11489
11582
  /** Create the tool that edits, pauses, resumes, or moves one Automation. */
11490
- function createUpdateAutomationTool(context, catalog) {
11583
+ function createUpdateAutomationTool(context, catalog, skills = []) {
11491
11584
  const trigger = automationTriggerChangesSchema(catalog);
11585
+ const skill = automationSkillToolSchema(skills);
11492
11586
  const inputSchema = z.object({
11493
11587
  automation_id: z.string().min(1).describe("ID of the automation, from searchAutomations or its dashboard URL."),
11494
11588
  title: automationTitleSchema.optional(),
11495
- instruction: automationInstructionToolSchema.nullable().optional(),
11589
+ instruction: automationInstructionToolSchema.nullable().describe(`${automationInstructionToolSchema.description} Setting it switches a skill Automation to this instruction and drops its context. Omit or use null to keep the current task.`).optional(),
11590
+ skill: skill.nullable().describe(`${skill.description} Setting it switches an instruction Automation to this skill, or changes the skill and keeps its context. Omit or use null to keep the current task.`).optional(),
11591
+ context: automationContextToolSchema.nullable().describe(`${automationContextToolSchema.description} Only for a skill Automation, or with skill. Use null to remove the context. Omit to keep it.`).optional(),
11496
11592
  trigger: trigger.nullable().describe("Replacement trigger of the same type. For an event trigger, match changes only the filters that it names. Omit or use null to keep the trigger.").optional(),
11497
11593
  outcomes: z.array(taskOutcomeInputSchema).max(5).nullable().describe("Replacement messages to send after successful work. Use an empty list to send nothing. Omit or use null to leave unchanged.").optional(),
11498
11594
  credential_mode: z.enum(["system", "creator"]).nullable().describe("Set creator to make the automation creator's credentials available, or system to disable them. Creator always means the automation's createdBy actor, never the current requester. Only that creator may enable creator mode. Omit or use null to leave unchanged.").optional(),
@@ -11510,10 +11606,10 @@ function createUpdateAutomationTool(context, catalog) {
11510
11606
  readOnlyHint: false
11511
11607
  },
11512
11608
  executionMode: "sequential",
11513
- description: "Update the title, instruction, trigger, outcomes, credential use, or status of a scheduled or event automation. Anyone in the workspace can update anything on an automation in a public channel, including its outcomes and destination. Automations in private channels and DMs can be updated from there or by their creator, and only their creator can move them. Only the creator can enable creator credentials. A non-creator who changes the instruction, trigger, outcomes, or destination switches it to system credentials. The trigger type cannot change. Set destination to move a scheduled automation to this conversation or to a public channel.",
11609
+ description: "Update the title, instruction or skill and its context, trigger, outcomes, credential use, or status of a scheduled or event automation. Anyone in the workspace can update anything on an automation in a public channel, including its outcomes and destination. Automations in private channels and DMs can be updated from there or by their creator, and only their creator can move them. Only the creator can enable creator credentials. A non-creator who changes the instruction, skill, context, trigger, outcomes, or destination switches it to system credentials. The trigger type cannot change. Set destination to move a scheduled automation to this conversation or to a public channel.",
11514
11610
  inputSchema,
11515
11611
  prepareArguments(args) {
11516
- return Object.fromEntries(Object.entries(args).filter(([, value]) => value != null));
11612
+ return Object.fromEntries(Object.entries(args).filter(([key, value]) => value !== void 0 && (value !== null || key === "context")));
11517
11613
  },
11518
11614
  outputSchema: automationToolResultSchema,
11519
11615
  async execute({ automation_id, status: requestedStatus, ...fields }) {
@@ -11527,14 +11623,17 @@ function createUpdateAutomationTool(context, catalog) {
11527
11623
  if (input.destination && current.kind === "event") throw new ToolInputError("Event automations cannot move. Create a new event automation in this conversation instead.");
11528
11624
  if (input.destination && !current.ownedByViewer && await resolveDestinationVisibility({ destination: current.task.destination }) !== "public") throw new ToolInputError("Only the creator can move an automation out of a private channel or DM.");
11529
11625
  const editor = automationEditor(caller.viewer, current);
11530
- if (input.instruction !== void 0 && input.instruction !== current.task.task.text) requireInstructionReferences(input.instruction, {
11626
+ const editedTask = editedAutomationTask(current.task.task, input);
11627
+ const previousText = automationTaskText(current.task.task);
11628
+ const text = editedTask && automationTaskText(editedTask);
11629
+ if (text !== void 0 && text !== previousText) requireInstructionReferences(text, {
11531
11630
  creator: current.task.createdBy,
11532
11631
  destinationChannelId: current.task.destination.channelId,
11533
11632
  requester: editor,
11534
- previousInstruction: current.task.task.text
11633
+ previousInstruction: previousText ?? ""
11535
11634
  });
11536
11635
  let saved = current;
11537
- if (Object.keys(input).length > 0) saved = current.kind === "scheduled" ? await updateScheduled(context, current, input, editor) : await updateEvent(current, input, editor, catalog);
11636
+ if (Object.keys(input).length > 0) saved = current.kind === "scheduled" ? await updateScheduled(context, current, input, editedTask, editor) : await updateEvent(current, input, editedTask, editor, catalog);
11538
11637
  if (status !== void 0 && status !== saved.task.status) saved = await changeAutomationLifecycle(saved, {
11539
11638
  action: status === "paused" ? "pause" : "resume",
11540
11639
  revision: automationRevision(saved.task)
@@ -11567,12 +11666,12 @@ function disableTools(tools, reason) {
11567
11666
  }
11568
11667
  // src/chat/tools/automations.ts
11569
11668
  /** Build the Automation tools. A Turn that no person started cannot use them. */
11570
- function createAutomationTools(context, catalog) {
11669
+ function createAutomationTools(context, catalog, skills) {
11571
11670
  const automationContext = automationToolContext(context);
11572
11671
  return disableTools({
11573
- createAutomation: createAutomationTool(automationContext, catalog),
11672
+ createAutomation: createAutomationTool(automationContext, catalog, skills),
11574
11673
  searchAutomations: createSearchAutomationsTool(automationContext, catalog),
11575
- updateAutomation: createUpdateAutomationTool(automationContext, catalog),
11674
+ updateAutomation: createUpdateAutomationTool(automationContext, catalog, skills),
11576
11675
  deleteAutomation: createDeleteAutomationTool(automationContext, catalog),
11577
11676
  runAutomationNow: createRunAutomationNowTool(automationContext, catalog)
11578
11677
  }, automationToolsDisabledReason(context));
@@ -14756,7 +14855,7 @@ const USER_CUSTOMIZATION_TOOL_SOURCE = {
14756
14855
  */
14757
14856
  function createUserCustomizationTools(context) {
14758
14857
  if (!isExperimentalFeatureEnabled("user-customization")) return {};
14759
- if (context.agentInvocationId) return {};
14858
+ if (!context.turnTools.userCustomization) return {};
14760
14859
  return { updateUserCustomization: zodTool({
14761
14860
  exposure: "deferred",
14762
14861
  source: USER_CUSTOMIZATION_TOOL_SOURCE,
@@ -14882,7 +14981,7 @@ const CONVERSATION_SUBSCRIPTION_TOOL_SOURCE = {
14882
14981
  * its input. Contract: `api/conversations/subscription.ts`.
14883
14982
  */
14884
14983
  function createConversationSubscriptionTools(context) {
14885
- if (context.agentInvocationId) return {};
14984
+ if (!context.turnTools.subscriptions) return {};
14886
14985
  return { setConversationSubscription: zodTool({
14887
14986
  exposure: "deferred",
14888
14987
  source: CONVERSATION_SUBSCRIPTION_TOOL_SOURCE,
@@ -16446,6 +16545,7 @@ function createToolState() {
16446
16545
  */
16447
16546
  function createTools(availableSkills, hooks = {}, context, options = {}) {
16448
16547
  const state = createToolState();
16548
+ const turnTools = context.turnTools;
16449
16549
  const slackContext = getSlackToolContext(context);
16450
16550
  const slackLocationCapabilities = slackContext ? resolveChannelCapabilities(slackContext.locationChannelId) : void 0;
16451
16551
  const canSendFilesToActiveConversation = Boolean(slackContext ? slackLocationCapabilities?.canSendFiles : context.attachmentStorage);
@@ -16466,7 +16566,7 @@ function createTools(availableSkills, hooks = {}, context, options = {}) {
16466
16566
  webSearch: createWebSearchTool(botConfig.webSearchModelId, hooks.toolOverrides?.webSearch),
16467
16567
  webFetch: createWebFetchTool(hooks, { canSendFilesToActiveConversation }),
16468
16568
  ...createEventTools(context, eventCatalog),
16469
- ...createAutomationTools(context, eventCatalog),
16569
+ ...createAutomationTools(context, eventCatalog, options.automationSkills ?? []),
16470
16570
  ...createWorkspaceTools(context),
16471
16571
  ...createOperatorTools(context),
16472
16572
  ...createUserCustomizationTools(context),
@@ -16517,9 +16617,9 @@ function createTools(availableSkills, hooks = {}, context, options = {}) {
16517
16617
  parentConversationId: context.parentConversationId
16518
16618
  });
16519
16619
  if (context.messageAgent) tools.messageAgent = createMessageAgentTool(context.messageAgent);
16520
- if (context.agentInvocationId) tools[REPORT_BLOCKED_TOOL_NAME] = createReportBlockedTool();
16620
+ if (turnTools.reportBlocked) tools[REPORT_BLOCKED_TOOL_NAME] = createReportBlockedTool();
16521
16621
  if (context.automation) tools[FINISH_AUTOMATION_RUN_TOOL_NAME] = createFinishAutomationRunTool(context.automation);
16522
- else tools[NO_REPLY_TOOL_NAME] = createNoReplyTool();
16622
+ if (turnTools.noReply) tools[NO_REPLY_TOOL_NAME] = createNoReplyTool();
16523
16623
  if (context.mcpToolManager) {
16524
16624
  tools.searchMcpTools = createSearchMcpToolsTool(context.mcpToolManager);
16525
16625
  tools.callMcpTool = createCallMcpToolTool(context.mcpToolManager);
@@ -16558,7 +16658,7 @@ function createTools(availableSkills, hooks = {}, context, options = {}) {
16558
16658
  addReviewItem: createAddReviewItemTool(context, reviewItemServices),
16559
16659
  searchReviewItems: createSearchReviewItemsTool(context, reviewItemServices),
16560
16660
  updateReviewItem: createUpdateReviewItemTool(context, reviewItemServices)
16561
- }, context.agentInvocationId ? `A child agent cannot use the review desk. Use ${REPORT_BLOCKED_TOOL_NAME} to tell the parent agent what needs a person.` : void 0));
16661
+ }, !turnTools.reviewDesk ? `A child agent cannot use the review desk. Use ${REPORT_BLOCKED_TOOL_NAME} to tell the parent agent what needs a person.` : void 0));
16562
16662
  for (const [name, pluginTool] of Object.entries(getPluginTools(context, options.pluginSandbox))) {
16563
16663
  if (tools[name]) throw new Error(`Plugin tool "${name}" conflicts with a core tool`);
16564
16664
  tools[name] = pluginTool;
@@ -19382,7 +19482,6 @@ function createGuardianActionReviewer(options) {
19382
19482
  system: GUARDIAN_ACTION_POLICY,
19383
19483
  prompt: guardianPrompt(proposal),
19384
19484
  maxTokens: GUARDIAN_REVIEW_MAX_TOKENS,
19385
- temperature: 0,
19386
19485
  operation: "guardian_action_review",
19387
19486
  cost: { owner: "caller" },
19388
19487
  signal,
@@ -19928,7 +20027,7 @@ async function wireAgentTools(args) {
19928
20027
  const commonToolRuntimeContext = {
19929
20028
  conversationId: args.run.conversationId,
19930
20029
  turnId: args.run.turnId,
19931
- ...args.run.agentInvocationId ? { agentInvocationId: args.run.agentInvocationId } : void 0,
20030
+ turnTools: args.behavior.tools,
19932
20031
  ...args.run.parentConversationId ? { parentConversationId: args.run.parentConversationId } : void 0,
19933
20032
  ...args.run.location ? {
19934
20033
  location: args.run.location,
@@ -19955,9 +20054,8 @@ async function wireAgentTools(args) {
19955
20054
  supportsImageInput: args.supportsImageInput,
19956
20055
  surface: args.surface,
19957
20056
  ...args.currentActor ? { resolveActorIdentity: async () => await readActorIdentity(args.currentActor) } : void 0,
19958
- ...args.durability.spawnAgent ? { spawnAgent: args.durability.spawnAgent } : void 0,
19959
- ...args.durability.messageAgent ? { messageAgent: args.durability.messageAgent } : void 0,
19960
- ...args.run.dispatch?.declaresResult ? { automation: { sendsMessage: args.run.dispatch.outcomes?.length !== 0 } } : void 0
20057
+ ...bindAgentTools(args.run, args.behavior.tools.agents),
20058
+ ...args.behavior.tools.finishAutomationRun ? { automation: { sendsMessage: args.run.dispatch?.outcomes?.length !== 0 } } : void 0
19961
20059
  };
19962
20060
  const toolRoute = resolveToolRuntimeRoute({
19963
20061
  actor: args.currentActor,
@@ -20016,7 +20114,10 @@ async function wireAgentTools(args) {
20016
20114
  upsertActiveSkill(args.activeSkills, effective);
20017
20115
  await tryRecordSkillLoadStat(effective);
20018
20116
  }
20019
- }, toolRuntimeContext, { pluginSandbox: createPluginToolSandbox(agentSandbox, { handleAuthSignal: pluginAuth.maybeHandleAuthSignal }) });
20117
+ }, toolRuntimeContext, {
20118
+ automationSkills: args.availableSkills,
20119
+ pluginSandbox: createPluginToolSandbox(agentSandbox, { handleAuthSignal: pluginAuth.maybeHandleAuthSignal })
20120
+ });
20020
20121
  const plannedToolExposure = planToolExposure(tools);
20021
20122
  const disabledTools = Object.entries(tools).flatMap(([name, definition]) => definition.disabledReason ? [{
20022
20123
  name,
@@ -20100,6 +20201,17 @@ async function wireAgentTools(args) {
20100
20201
  toolRuntimeContext
20101
20202
  };
20102
20203
  }
20204
+ /** Bind the agent tools that the Turn's behavior gives it. */
20205
+ function bindAgentTools(run, agents) {
20206
+ const { bindSpawnAgent, bindMessageAgent } = run.environment ?? {};
20207
+ if (agents === "none" || !bindSpawnAgent) return {};
20208
+ const spawnAgent = isAgentRunFeatureDisabled(run.disabledFeatures, "subagents") ? void 0 : bindSpawnAgent(run);
20209
+ const messageAgent = spawnAgent || agents === "children_and_parent" ? bindMessageAgent?.(run, agents) : void 0;
20210
+ return {
20211
+ ...spawnAgent ? { spawnAgent } : void 0,
20212
+ ...messageAgent ? { messageAgent } : void 0
20213
+ };
20214
+ }
20103
20215
  // src/chat/agent/resume.ts
20104
20216
  function extractSliceUsage(messages, beforeMessageCount) {
20105
20217
  const usage = extractGenAiUsageSummary(...messages.slice(beforeMessageCount).filter(isAssistantMessage));
@@ -21546,20 +21658,35 @@ function exclusiveToolName(toolCalls) {
21546
21658
  for (const name of EXCLUSIVE_TOOL_NAMES) if (toolCalls.some((call) => call.name === name)) return name;
21547
21659
  }
21548
21660
  // src/chat/agent/tool-batch.ts
21661
+ /** Start the batch counts for one Run. */
21662
+ function createToolBatchStats() {
21663
+ return {
21664
+ count: 0,
21665
+ sequentialCount: 0,
21666
+ sequentialCallCount: 0,
21667
+ sequentialToolNames: /* @__PURE__ */ new Set()
21668
+ };
21669
+ }
21549
21670
  /**
21550
- * Record how Pi runs the tool calls of one assistant message. Pi runs them
21551
- * in parallel unless one of their tools is `sequential`; then it runs all of
21552
- * them one at a time.
21671
+ * Count one batch of tool calls. Pi runs them in parallel unless one of their
21672
+ * tools is `sequential`; then it runs all of them one at a time.
21553
21673
  */
21554
- function logToolBatch(toolCalls, tools) {
21555
- const names = toolCalls.map((call) => call.name);
21556
- const sequentialTools = [...new Set(names)].filter((name) => tools.find((tool) => tool.name === name)?.executionMode === "sequential").sort();
21557
- logInfo("agent.tool_batch.started", {
21558
- "app.tool_batch.size": toolCalls.length,
21559
- "app.tool_batch.execution": sequentialTools.length > 0 ? "sequential" : "parallel",
21560
- "app.tool_batch.tool_names": names,
21561
- "app.tool_batch.sequential_tool_names": sequentialTools
21562
- });
21674
+ function recordToolBatch(stats, toolCalls, tools) {
21675
+ const sequentialTools = toolCalls.map((call) => call.name).filter((name) => tools.find((tool) => tool.name === name)?.executionMode === "sequential");
21676
+ stats.count += 1;
21677
+ if (sequentialTools.length === 0) return;
21678
+ stats.sequentialCount += 1;
21679
+ stats.sequentialCallCount += toolCalls.length;
21680
+ for (const name of sequentialTools) stats.sequentialToolNames.add(name);
21681
+ }
21682
+ /** Span attributes for the batch counts of one Run. */
21683
+ function toolBatchSpanAttributes(stats) {
21684
+ return {
21685
+ "app.tool_batch.count": stats.count,
21686
+ "app.tool_batch.sequential_count": stats.sequentialCount,
21687
+ "app.tool_batch.sequential_call_count": stats.sequentialCallCount,
21688
+ "app.tool_batch.sequential_tool_names": [...stats.sequentialToolNames].sort().join(",")
21689
+ };
21563
21690
  }
21564
21691
  // src/chat/agent/index.ts
21565
21692
  /**
@@ -21618,6 +21745,7 @@ function waitForAbortSettlement(promise, timeoutMs) {
21618
21745
  async function executeAgentRun(run, streamFn) {
21619
21746
  if (!run.destination) throw new TypeError("Assistant reply generation requires a destination");
21620
21747
  const conversation = await getConversationStore().get({ conversationId: run.conversationId });
21748
+ if (!conversation && run.parentConversationId) throw new Error(`Child Conversation ${run.conversationId} has no Conversation row`);
21621
21749
  const visibility = conversation?.visibility;
21622
21750
  const conversationPrivacy = resolveConversationPrivacy({ visibility });
21623
21751
  const actor = actorFromRun(run);
@@ -21630,12 +21758,17 @@ async function executeAgentRun(run, streamFn) {
21630
21758
  runId: run.runId,
21631
21759
  assistantUserName: botConfig.userName
21632
21760
  };
21633
- return withLogContext(runLogContext, () => runWithConversationPrivacy(conversationPrivacy, () => executeAgentRunInPrivacyContext(run, conversation?.kind, conversationPrivacy, runLogContext, streamFn)));
21761
+ return withLogContext(runLogContext, () => runWithConversationPrivacy(conversationPrivacy, () => executeAgentRunInPrivacyContext(run, conversation?.kind ?? "root", conversationPrivacy, runLogContext, streamFn)));
21634
21762
  }
21635
21763
  async function executeAgentRunInPrivacyContext(run, conversationKind, conversationPrivacy, runLogContext, streamFn) {
21636
21764
  const conversationId = run.conversationId;
21637
21765
  const turnId = run.turnId;
21638
- const requireAutomationResult = run.dispatch?.declaresResult === true;
21766
+ const behavior = turnBehavior({
21767
+ kind: conversationKind,
21768
+ personInput: isPersonInput(run.source.kind),
21769
+ automationRun: run.dispatch?.declaresResult === true
21770
+ });
21771
+ const requireAutomationResult = behavior.gated;
21639
21772
  const input = {
21640
21773
  actor: run.instruction.actor,
21641
21774
  messageText: run.instruction.text,
@@ -21717,7 +21850,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
21717
21850
  let shouldTrace = false;
21718
21851
  let getSandboxRef;
21719
21852
  const reasoningLevel = policy.reasoningLevel ?? botConfig.reasoningLevel;
21720
- const activeModelId = botConfig.modelId;
21853
+ let activeModelId = botConfig.modelId;
21721
21854
  const actor = actorFromRun(run);
21722
21855
  const surface = surfaceFromRun(run);
21723
21856
  const runSource = routing.source;
@@ -21756,8 +21889,10 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
21756
21889
  "messaging.message.id": slackSource?.messageTs ?? ""
21757
21890
  });
21758
21891
  }
21759
- const skillInvocation = parseSkillInvocation(userInput, availableSkills);
21892
+ const dispatchSkill = run.dispatch?.skill;
21893
+ const skillInvocation = dispatchSkill ? { skillName: dispatchSkill } : parseSkillInvocation(userInput, availableSkills);
21760
21894
  const invokedSkill = skillInvocation ? findSkillByName(skillInvocation.skillName, availableSkills) : null;
21895
+ if (dispatchSkill && !invokedSkill) throw new Error(missingAutomationSkillReason(dispatchSkill));
21761
21896
  const activeSkills = [];
21762
21897
  const skillSandbox = new SkillSandbox(availableSkills, activeSkills);
21763
21898
  const checkpoint = await loadTurnCheckpoint({
@@ -21883,6 +22018,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
21883
22018
  const wiring = await wireAgentTools({
21884
22019
  abortAgent: () => agent?.abort(),
21885
22020
  activeSkills,
22021
+ behavior,
21886
22022
  currentActor: actor,
21887
22023
  currentAgentMessages,
21888
22024
  currentTurnMessages,
@@ -21931,6 +22067,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
21931
22067
  const getPendingAuthPause = wiring.getPendingAuthPause;
21932
22068
  const { baseInstructions: assembledBaseInstructions, contextContentParts: promptContextContentParts, inputMessages, inputMessagesAttribute, promptTimestamp: restoredPromptTimestamp, promptHistoryMessages, shouldPromptAgent, turnContexts, userContentParts: promptUserContentParts } = await assemblePrompt({
21933
22069
  activeMcpCatalogs: wiring.activeMcpCatalogs,
22070
+ promptMode: behavior.promptMode,
21934
22071
  currentActor: actor,
21935
22072
  availableSkills,
21936
22073
  configurationValues,
@@ -22080,6 +22217,8 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
22080
22217
  return acceptedMessages;
22081
22218
  };
22082
22219
  const cacheWarming = createCacheWarmingRecorder(conversationId, isUserActor(actor) && conversationKind !== "task");
22220
+ const toolBatchStats = createToolBatchStats();
22221
+ let setAgentSpanAttributes;
22083
22222
  agent = new Agent({
22084
22223
  getApiKey: getGatewayApiKey,
22085
22224
  sessionId: conversationId,
@@ -22090,7 +22229,10 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
22090
22229
  steeringMode: "all",
22091
22230
  beforeToolCall: async ({ assistantMessage, context, toolCall }) => {
22092
22231
  const toolCalls = assistantMessage.content.filter((part) => part.type === "toolCall");
22093
- if (toolCalls.length > 1 && toolCall.id === toolCalls[0].id) logToolBatch(toolCalls, context.tools ?? []);
22232
+ if (toolCalls.length > 1 && toolCall.id === toolCalls[0].id) {
22233
+ recordToolBatch(toolBatchStats, toolCalls, context.tools ?? []);
22234
+ setAgentSpanAttributes?.(toolBatchSpanAttributes(toolBatchStats));
22235
+ }
22094
22236
  const exclusiveTool = exclusiveToolName(toolCalls);
22095
22237
  if (exclusiveTool && toolCalls.length !== 1) return {
22096
22238
  block: true,
@@ -22191,7 +22333,8 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
22191
22333
  } else if (promptHistoryMessages.length > 0) agent.state.messages = [...promptHistoryMessages];
22192
22334
  runResume.setBeforeMessageCount(agent.state.messages.length);
22193
22335
  if (shouldPromptAgent) runResume.setTurnStartMessageIndex(agent.state.messages.length);
22194
- const authPauseOutcome = await withSpan(`invoke_agent ${botConfig.userName}`, "gen_ai.invoke_agent", spanContext, async () => {
22336
+ const authPauseOutcome = await withSpan(`invoke_agent ${botConfig.userName}`, "gen_ai.invoke_agent", spanContext, async (setInvokeAgentSpanAttributes) => {
22337
+ setAgentSpanAttributes = setInvokeAgentSpanAttributes;
22195
22338
  if (requireAutomationResult && readAutomationResult(agent.state.messages)) return;
22196
22339
  const promptTimestamp = restoredPromptTimestamp ?? Date.now();
22197
22340
  const contextMessage = shouldPromptAgent && promptContextContentParts.length > 0 ? {
@@ -22299,6 +22442,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
22299
22442
  let actionConfirmationRetryUsed = false;
22300
22443
  let automationResultReminderUsed = !requireAutomationResult;
22301
22444
  let providerRetryAttempt = 0;
22445
+ let refusalFallbackUsed = false;
22302
22446
  let emptyOutputAttempt = 0;
22303
22447
  const prepareRetry = async (messages) => {
22304
22448
  discardedRetryUsage = addAgentTurnUsage(discardedRetryUsage, getDiscardedRetryUsage(agent.state.messages, messages));
@@ -22364,7 +22508,24 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
22364
22508
  failure: lastAssistant,
22365
22509
  messages: agent.state.messages
22366
22510
  });
22367
- if (!providerRetry) break;
22511
+ if (!providerRetry) {
22512
+ const refusalFallback = refusalFallbackUsed ? void 0 : nextRefusalFallback({
22513
+ failure: lastAssistant,
22514
+ fallbackModelId: botConfig.refusalFallbackModelId,
22515
+ messages: agent.state.messages
22516
+ });
22517
+ if (!refusalFallback) break;
22518
+ refusalFallbackUsed = true;
22519
+ await prepareRetry(refusalFallback.messages);
22520
+ logWarn("agent.turn.refusal_fallback", {
22521
+ "gen_ai.request.model": activeModelId,
22522
+ "app.ai.refusal_fallback.model": refusalFallback.modelId
22523
+ });
22524
+ activeModelId = refusalFallback.modelId;
22525
+ agent.state.model = resolveGatewayModel(activeModelId);
22526
+ run = agent.continue();
22527
+ continue;
22528
+ }
22368
22529
  providerRetryAttempt += 1;
22369
22530
  await prepareRetry(providerRetry.messages);
22370
22531
  logWarn("agent.turn.provider.retrying", {
@@ -22494,8 +22655,6 @@ function createAgentRunner(execute, options) {
22494
22655
  const bindSpawnAgent = options?.bindSpawnAgent;
22495
22656
  const bindMessageAgent = options?.bindMessageAgent;
22496
22657
  return { run: async (run) => {
22497
- const spawnAgent = bindSpawnAgent && !isAgentRunFeatureDisabled(run.disabledFeatures, "subagents") ? bindSpawnAgent(run) : void 0;
22498
- const messageAgent = bindMessageAgent && bindSpawnAgent && (spawnAgent || run.agentInvocationId) ? bindMessageAgent(run) : void 0;
22499
22658
  const nextRun = {
22500
22659
  ...run,
22501
22660
  environment: {
@@ -22503,13 +22662,10 @@ function createAgentRunner(execute, options) {
22503
22662
  attachmentStorage: run.environment?.attachmentStorage ?? attachmentStorage,
22504
22663
  backgroundCompactionQueue: run.environment?.backgroundCompactionQueue ?? backgroundCompactionQueue,
22505
22664
  conversationWorkQueue: run.environment?.conversationWorkQueue ?? conversationWorkQueue,
22506
- sandboxTracePropagation: run.environment?.sandboxTracePropagation ?? tracePropagation
22507
- },
22508
- ...spawnAgent || messageAgent ? { durability: {
22509
- ...run.durability,
22510
- ...spawnAgent ? { spawnAgent } : void 0,
22511
- ...messageAgent ? { messageAgent } : void 0
22512
- } } : void 0
22665
+ sandboxTracePropagation: run.environment?.sandboxTracePropagation ?? tracePropagation,
22666
+ ...bindSpawnAgent ? { bindSpawnAgent } : void 0,
22667
+ ...bindSpawnAgent && bindMessageAgent ? { bindMessageAgent } : void 0
22668
+ }
22513
22669
  };
22514
22670
  const loadStoredImages = async (attachments) => {
22515
22671
  const { loadInputImages } = await Promise.resolve().then(() => images_exports);
@@ -22536,4 +22692,4 @@ function createAgentRunner(execute, options) {
22536
22692
  return await execute(nextRun, streamFn);
22537
22693
  } };
22538
22694
  }
22539
- 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, listUnreportedSiblingAgents as cn, acceptsWebMessages as ct, getMcpStoredOAuthCredentials as d, RetryableDeliveryError as dn, createAndEnqueueConversation as dt, AgentDepthLimitError as en, readViewerAutomationVersions as et, putMcpStoredOAuthCredentials as f, actorFromRun 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, processWorkspaceSnapshotJob as ln, appendAndEnqueueWebMessage as lt, readStats as m, shouldEmitDevAgentTrace as mn, webActorFromUser as mt, executeAgentRun as n, AgentMessagePausedError as nn, AutomationEditError as nt, deleteMcpAuthSession as o, listedConversation as on, renderReviewItemMessage as ot, latestProgressStatus as p, toolInvocationDestination as pn, recordWebConversationActivity as pt, readViewerAutomationEdit as q, turnInputTelemetry as qt, processBackgroundCompaction as r, AgentMessageQueueFullError as rn, effectiveTaskOutcomes as rt, deleteMcpAuthSessionsForUserProvider as s, listChildAgents as sn, reviewItemChangeRecord as st, createAgentRunner as t, AgentInvocationLimitError as tn, readViewerAutomations as tt, getMcpAuthSession as u, ingestEvent 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 };
22695
+ 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, listUnreportedSiblingAgents as cn, acceptsWebMessages as ct, getMcpStoredOAuthCredentials as d, findAutomationSkill as dn, createAndEnqueueConversation as dt, AgentDepthLimitError as en, readViewerAutomationVersions as et, putMcpStoredOAuthCredentials as f, missingAutomationSkillReason as fn, createConversationId as ft, readPublicArtifact as g, shouldEmitDevAgentTrace as gn, collectAttachmentGarbage as gt, publicArtifactHeaders as h, toolInvocationDestination as hn, 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, processWorkspaceSnapshotJob as ln, appendAndEnqueueWebMessage as lt, readStats as m, actorFromRun as mn, webActorFromUser as mt, executeAgentRun as n, AgentMessagePausedError as nn, AutomationEditError as nt, deleteMcpAuthSession as o, listedConversation as on, renderReviewItemMessage as ot, latestProgressStatus as p, RetryableDeliveryError as pn, recordWebConversationActivity as pt, readViewerAutomationEdit as q, turnInputTelemetry as qt, processBackgroundCompaction as r, AgentMessageQueueFullError as rn, effectiveTaskOutcomes as rt, deleteMcpAuthSessionsForUserProvider as s, listChildAgents as sn, reviewItemChangeRecord as st, createAgentRunner as t, AgentInvocationLimitError as tn, readViewerAutomations as tt, getMcpAuthSession as u, ingestEvent 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 };