@sentry/junior 0.294.0 → 0.295.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{admin-vt8aSiCD.js → admin-ifgjyfpF.js} +2 -2
- package/dist/{agent-runner-DJu7w6mI.js → agent-runner-DjMTPWEO.js} +147 -90
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +5 -5
- package/dist/api.d.ts +1 -1
- package/dist/api.js +52 -28
- package/dist/{app--a5RLOrr.d.ts → app-uiTzRbvq.d.ts} +3 -3
- package/dist/app.d.ts +2 -2
- package/dist/app.js +33 -34
- package/dist/{automation-BM-OBsKW.js → automation-yJX3C7i3.js} +3 -3
- package/dist/{background-compaction-queue-D2j-0XkH.js → background-compaction-queue-DUkHZjmL.js} +7 -9
- package/dist/{briefs-JOAoCb6d.js → briefs-CbNYM-q2.js} +3 -3
- package/dist/{catalog-runtime-CLMA9AXd.js → catalog-runtime-DgouZKZm.js} +1 -1
- package/dist/cli/chat.d.ts +1 -1
- package/dist/cli/chat.js +15 -15
- package/dist/cli/check.js +3 -3
- package/dist/cli/init.js +2 -0
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.d.ts +1 -1
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +2 -2
- package/dist/cli/upgrade.js +3 -3
- package/dist/{config-mIZeGEWv.js → config-DvnTPCfp.js} +43 -2
- package/dist/{connections-XhdVg7OR.js → connections-CWaIVl_1.js} +6 -6
- package/dist/{conversation-CDWejM4R.js → conversation-CMkSmi02.js} +2 -11
- package/dist/{conversation-pending-messages-Dh2tfbaw.js → conversation-feed-BVAOga0H.js} +27 -2
- package/dist/{conversation-privacy-C6h-X2cZ.js → conversation-privacy-DPjv4SnA.js} +1 -1
- package/dist/{credential-sync-zigBlXS3.js → credential-sync-BhbaZfmO.js} +16 -15
- package/dist/{db-DV5AbcGM.d.ts → db-CCUqQe0E.d.ts} +6 -1
- package/dist/{db--xuNV7g6.js → db-Dts2XvLu.js} +54 -10
- package/dist/{executor-BItuRqAR.js → executor-Ck73J0wP.js} +8 -3
- package/dist/instrumentation.js +2 -2
- package/dist/{logging-Cb6MGvdt.js → logging-9OAq-fdg.js} +2 -1
- package/dist/{message-BTGgSmaH.js → message-CtaPzC7m.js} +9 -9
- package/dist/nitro.d.ts +2 -2
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-Dvh1aOIi.js → oauth-callback-server-C_LXY1d4.js} +2 -2
- package/dist/{oauth-relay-D6xxVywK.js → oauth-relay-CsfIazeF.js} +2 -1
- package/dist/{plugins-DtmjkTza.d.ts → plugins-B_0Cr0MO.d.ts} +0 -1
- package/dist/{projection-DLQgfO5N.js → projection-BzJQncZV.js} +248 -77
- package/dist/{prompt-qp_LdxLX.js → prompt-Cbq5b4SO.js} +4 -4
- package/dist/{registry-MtwokaqW.js → registry-cbpOxO4M.js} +3 -13
- package/dist/{resolve-BnJA0UNE.js → resolve-t-pmRdwS.js} +3 -3
- package/dist/{result-ChL-1KyW.js → result-DhgjR3nQ.js} +8 -8
- package/dist/{runner-BONN7Dp2.js → runner-CHv9X9TH.js} +8 -8
- package/dist/{sandbox-egress-signals-nmlmI5Ab.js → sandbox-egress-signals-Yy3fSCbg.js} +1 -1
- package/dist/{schema-yr0ccDni.js → schema-BhneuGYv.js} +13 -6
- package/dist/{schema-DgvcyJ1y.d.ts → schema-TSEisVJR.d.ts} +50 -14
- package/dist/secrets-DebYU866.js +18 -0
- package/dist/{service-account-Bd0lBaGr.js → service-account-C4rBP8ne.js} +3 -3
- package/dist/{service-account-kio5nXSD.js → service-account-DjPIwCMj.js} +42 -26
- package/dist/{session-stop-CeCXL3j9.js → session-stop-DkxI5vc3.js} +20 -775
- package/dist/{skills-e3DDNlKO.js → skills-BZE2DP8I.js} +2 -2
- package/dist/{spawn--cRxITWQ.js → spawn-BvULxIiu.js} +5 -5
- package/dist/{adapter-DxLhJEnO.js → state-CO9ETDzk.js} +132 -2
- package/dist/{stop-Iai5N2PU.js → stop-CL-rdtQb.js} +84 -30
- package/dist/{store-C8LsaJwS.js → store-DgD78_NK.js} +3 -3
- package/dist/{task-runner-Dw7exu0-.js → task-runner-CKOj6xla.js} +11 -11
- package/dist/{turn-failure-response-BqTTx3XG.js → turn-failure-response-BTSo6SMJ.js} +8 -8
- package/dist/{validation-BrGahtnv.js → validation-CXeYgBzq.js} +1 -1
- package/dist/{version-Bdqhx8Qh.js → version-AQa7Fr2H.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-CjRFHR5U.js → viewer-Bqkb678l.js} +3 -3
- package/dist/warmup-h6u1e9n0.js +1869 -0
- package/dist/{work-BWBG1EGV.js → work-yN_GAuXY.js} +11 -11
- package/dist/{worker-DAnBIVMs.js → worker-Hl7N292I.js} +6 -6
- package/migrations/0098_review_item_plugin_actions.sql +5 -0
- package/migrations/0099_conversation_last_message_at.sql +1 -0
- package/migrations/0100_automation_task_kind_repair.sql +48 -0
- package/migrations/meta/0098_snapshot.json +4490 -0
- package/migrations/meta/0099_snapshot.json +4720 -0
- package/migrations/meta/0100_snapshot.json +4496 -0
- package/migrations/meta/_journal.json +21 -0
- package/package.json +5 -5
- package/dist/assistant-reply-iTtEdDyc.js +0 -58
- package/dist/warmup-DuxCtzKC.js +0 -1039
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as getDb } from "./db
|
|
2
|
-
import { r as listAdminUsersFromSql, u as setUserAdminFromSql } from "./viewer-
|
|
1
|
+
import { o as getDb } from "./db-Dts2XvLu.js";
|
|
2
|
+
import { r as listAdminUsersFromSql, u as setUserAdminFromSql } from "./viewer-Bqkb678l.js";
|
|
3
3
|
import { CLI_USAGE } from "./cli/run.js";
|
|
4
4
|
// src/cli/admin.ts
|
|
5
5
|
/**
|
|
@@ -1,33 +1,32 @@
|
|
|
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, $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,
|
|
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-
|
|
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-
|
|
5
|
-
import { a as toCanonicalInputMessage, c as toGenAiPayloadMetadata, i as runWithConversationPrivacy, l as toGenAiPayloadTraceAttributes, o as toCanonicalOutputMessage, r as resolveConversationPrivacy, s as toGenAiMessagesTraceAttributes } from "./conversation-privacy-
|
|
2
|
+
import { $ as loadTurnCheckpoint, $i as uploadFilesToConversation, $t as extractAssistantText, A as latestConversationMessageSeq, Ar as automationCreatorUserId, B as getAgentContextInputLimitTokens, Ba as SANDBOX_REPOS_ROOT, Bn as getPlugins, Bo as getConfigDefaults, 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, 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, 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 historyItemFromPiMessage, Lr as RESOURCE_WATCH_TOOL_SOURCE, M as normalizeConversationText, Ma as sleep, Mi as deliverOAuthAuthorization, Mo as credentialAuditAttributes, Mr as resolveAssignees, N as recordDeliveredAssistantMessage, Na as tryWorkspaceRepoCheckoutPath, Ni as formatProviderLabel, Nn as createPluginHookRunner, No as credentialAuditSource, 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 piMessageFromHistoryItem, 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, zo as projectConversationEvents } from "./projection-BzJQncZV.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-DvnTPCfp.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-9OAq-fdg.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-DPjv4SnA.js";
|
|
6
6
|
import { d as parseSlackChannelReferenceId, f as parseSlackTeamId, h as parseSlackMessageTs, n as createSlackActor, o as isUserActor, p as parseSlackUserId, u as parseSlackChannelId } from "./actor-6jsm_v96.js";
|
|
7
|
-
import {
|
|
8
|
-
import { A as juniorConversations, 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-
|
|
7
|
+
import { D as turnBehavior, J as agentTurnCostUsd, M as SYSTEM_IDENTITY_ID, O as conversationKindFromRow, P as resolveActorIdentityId, Q as resolveRootConversationId$1, T as isTopLevelKind, Z as hasAgentTurnUsage, _ as setArchivedAt, a as getConversationStore, c as conversationIdsWithAnnotation, et as conversationDetailTouch, g as readConversationTrees, h as conversationDescendants, i as getConversationMessageSearchStore, it as parseDestination, l as hasAnnotationKey, m as conversationAncestors, nt as touchConversationDetail, o as getDb, ot as sameDestination, q as addAgentTurnUsage, r as getConversationEventStore, s as getSqlExecutor, tt as nextDetailVersion, u as treeHasAnnotationKey, w as isPersonInput } from "./db-Dts2XvLu.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-Ck73J0wP.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-
|
|
12
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
13
|
-
import { a as parseSkillInvocation, i as parseSkillFile, n as findSkillByName, r as loadSkillsByName, t as discoverSkills } from "./skills-
|
|
14
|
-
import { l as completeObject, o as isEventConversationMessage, r as EVENT_AUTHOR_ID, u as completeText } from "./prompt-
|
|
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-cbpOxO4M.js";
|
|
12
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-DgouZKZm.js";
|
|
13
|
+
import { a as parseSkillInvocation, i as parseSkillFile, n as findSkillByName, r as loadSkillsByName, t as discoverSkills } from "./skills-BZE2DP8I.js";
|
|
14
|
+
import { l as completeObject, o as isEventConversationMessage, r as EVENT_AUTHOR_ID, u as completeText } from "./prompt-Cbq5b4SO.js";
|
|
15
15
|
import { a as withLock, i as fenceLock } from "./locks-D-0h111u.js";
|
|
16
|
-
import { a as readActorIdentityFromSql, f as identityAvatarUrl, h as readUserAvatarUrls, i as readActorIdentity } from "./viewer-
|
|
17
|
-
import {
|
|
16
|
+
import { a as readActorIdentityFromSql, f as identityAvatarUrl, h as readUserAvatarUrls, i as readActorIdentity } from "./viewer-Bqkb678l.js";
|
|
17
|
+
import { a as getStateAdapter, n as readEncryptedState, t as createEncryptedState } from "./state-CO9ETDzk.js";
|
|
18
18
|
import { i as getFirstRunAtMs, o as getZonedDateTimeParts, s as isValidTimeZone } from "./schedule-cP0AACm1.js";
|
|
19
|
-
import {
|
|
20
|
-
import { i as createCacheWarmingRecorder, l as readLastUserMessageAtByConversation } from "./warmup-
|
|
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-
|
|
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-
|
|
23
|
-
import {
|
|
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";
|
|
19
|
+
import { G as briefLinkSchema, K as briefOutcomeStatusSchema, R as removedCardSchema, U as readMessageAttachments, X as parseStoredBrief } from "./conversation-CMkSmi02.js";
|
|
20
|
+
import { A as findLegacyNoReplyMarker, C as readAutomationResult, D as getAssistantReplyText, E as decideReply, M as readNoReply, N as REPORT_BLOCKED_TOOL_NAME, O as sanitizeAssistantText, P as readBlockedReport, b as FINISH_AUTOMATION_RUN_TOOL_NAME, i as createCacheWarmingRecorder, j as isLegacyNoReplyMarker, k as NO_REPLY_TOOL_NAME, l as readLastUserMessageAtByConversation, v as JUNIOR_PERSONALITY, w as remindMissingAutomationResult, x as automationResultSchema$1 } from "./warmup-h6u1e9n0.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-DUkHZjmL.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-BTSo6SMJ.js";
|
|
23
|
+
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, d as getAuthPausedConversationTurnId, f as getEventBatchDelayMs, p as listActiveMailboxTurns, r as markConversationsStopped, rt as isExperimentalFeatureEnabled, s as eventReviewItemInputs, t as getConversationStoppedAtMs, tt as saveUserCustomization, v as turnInputFactsFromConversationMessage, w as eventBatchMessageMeta, x as conversationSubtreeColumns, y as legacyWebMailboxMetadataSchema } from "./session-stop-DkxI5vc3.js";
|
|
25
24
|
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-
|
|
27
|
-
import { S as requestConversationWork, T as stopConversationWork, g as getConversationWorkState, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage } from "./store-
|
|
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-
|
|
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-
|
|
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-
|
|
25
|
+
import { a as setSnapshotSpanAttributes, i as postinstall, n as resolve$1, r as dependencies, s as getSandboxResources } from "./resolve-t-pmRdwS.js";
|
|
26
|
+
import { S as requestConversationWork, T as stopConversationWork, g as getConversationWorkState, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage } from "./store-DgD78_NK.js";
|
|
27
|
+
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-CKOj6xla.js";
|
|
28
|
+
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-DjPIwCMj.js";
|
|
29
|
+
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-yJX3C7i3.js";
|
|
31
30
|
import { n as privateTraceResultAttributes } from "./private-trace-result-CE7_lEdq.js";
|
|
32
31
|
import { streamSimple } from "@earendil-works/pi-ai/compat";
|
|
33
32
|
import { createGatewayProvider } from "@ai-sdk/gateway";
|
|
@@ -3662,6 +3661,7 @@ function createSandbox(options) {
|
|
|
3662
3661
|
conversationId: options.conversationId,
|
|
3663
3662
|
credentials: credentialEgress,
|
|
3664
3663
|
egressId,
|
|
3664
|
+
source: options.credentialAuditSource,
|
|
3665
3665
|
ttlMs: sandboxEgressTokenTtlMs
|
|
3666
3666
|
});
|
|
3667
3667
|
sandboxEgressCredentialTokens.set(egressId, {
|
|
@@ -4181,9 +4181,29 @@ function accountText(value) {
|
|
|
4181
4181
|
if (!label) return;
|
|
4182
4182
|
return id && id !== label ? `${label} (${id})` : label;
|
|
4183
4183
|
}
|
|
4184
|
-
function
|
|
4184
|
+
function policyDeniedText(value, signal) {
|
|
4185
|
+
const message = stringField(signal, "message");
|
|
4186
|
+
const method = stringField(signal, "method");
|
|
4187
|
+
const upstreamHost = stringField(signal, "upstreamHost");
|
|
4188
|
+
const upstreamPath = stringField(signal, "upstreamPath");
|
|
4189
|
+
if (!message || !method || !upstreamHost || !upstreamPath) return;
|
|
4190
|
+
const command = stringField(value, "command");
|
|
4191
|
+
const stderr = stringField(value, "stderr").trim();
|
|
4192
|
+
return [
|
|
4193
|
+
"The runtime egress policy denied the request. It did not reach the provider.",
|
|
4194
|
+
message,
|
|
4195
|
+
"",
|
|
4196
|
+
`Request: ${method} ${upstreamHost}${upstreamPath}`,
|
|
4197
|
+
...command ? [`Command: ${command}`] : [],
|
|
4198
|
+
"",
|
|
4199
|
+
"Do not retry the same request, and do not ask for more permissions or a new credential. Follow the policy message.",
|
|
4200
|
+
...stderr ? ["", `stderr:\n${stderr}`] : []
|
|
4201
|
+
].join("\n");
|
|
4202
|
+
}
|
|
4203
|
+
function permissionDeniedText(value) {
|
|
4185
4204
|
if (!isRecord$1(value) || !isRecord$1(value.permission_denied)) return;
|
|
4186
4205
|
const signal = value.permission_denied;
|
|
4206
|
+
if (signal.source === "policy") return policyDeniedText(value, signal);
|
|
4187
4207
|
if (signal.source !== "upstream") return;
|
|
4188
4208
|
const provider = stringField(signal, "provider");
|
|
4189
4209
|
const message = stringField(signal, "message");
|
|
@@ -4234,7 +4254,7 @@ function normalizeToolResult(result, options = {}) {
|
|
|
4234
4254
|
const unwrapped = result;
|
|
4235
4255
|
if (isStructuredToolExecutionResult(unwrapped)) {
|
|
4236
4256
|
const normalized = normalizeDetails(unwrapped.details, options);
|
|
4237
|
-
const permissionText =
|
|
4257
|
+
const permissionText = permissionDeniedText(normalized.details);
|
|
4238
4258
|
if (!permissionText && normalized.details === unwrapped.details) return unwrapped;
|
|
4239
4259
|
return {
|
|
4240
4260
|
content: permissionText || normalized.replaceEnvelopeText ? replaceGeneratedTextContent(unwrapped.content, permissionText ?? toToolContentText(normalized.details)) : unwrapped.content,
|
|
@@ -4252,7 +4272,7 @@ function normalizeToolResult(result, options = {}) {
|
|
|
4252
4272
|
return {
|
|
4253
4273
|
content: [{
|
|
4254
4274
|
type: "text",
|
|
4255
|
-
text:
|
|
4275
|
+
text: permissionDeniedText(normalized.details) ?? toToolContentText(normalized.details)
|
|
4256
4276
|
}],
|
|
4257
4277
|
details: normalized.details
|
|
4258
4278
|
};
|
|
@@ -4326,6 +4346,7 @@ function createAgentSandbox(options) {
|
|
|
4326
4346
|
egressSignals: options.egressSignals,
|
|
4327
4347
|
conversationId: options.conversationId,
|
|
4328
4348
|
credentialEgress: options.credentialEgress,
|
|
4349
|
+
credentialAuditSource: options.credentialAuditSource,
|
|
4329
4350
|
prepare: options.prepareSandbox,
|
|
4330
4351
|
prepareWorkspace: options.prepareWorkspace,
|
|
4331
4352
|
onSandboxRefChanged: async (sandboxRef) => {
|
|
@@ -4630,12 +4651,13 @@ var McpToolManager = class {
|
|
|
4630
4651
|
return actorClient;
|
|
4631
4652
|
}
|
|
4632
4653
|
/**
|
|
4633
|
-
* Record a completed call
|
|
4654
|
+
* Record a completed tool call, with the account that made it.
|
|
4634
4655
|
* Arguments stay out: the conversation history keeps them.
|
|
4635
4656
|
*/
|
|
4636
4657
|
logToolCallAudit(plugin, toolName, attributes) {
|
|
4637
4658
|
const usedServiceAccount = this.serviceAccountProviders.has(plugin.manifest.name) && serviceAccountAllows(plugin.manifest, { tool: toolName });
|
|
4638
4659
|
logAudit("mcp.tool_call.completed", {
|
|
4660
|
+
...this.options.auditAttributes,
|
|
4639
4661
|
...attributes,
|
|
4640
4662
|
"mcp.method.name": "tools/call",
|
|
4641
4663
|
"app.plugin.name": plugin.manifest.name,
|
|
@@ -4678,7 +4700,7 @@ var McpToolManager = class {
|
|
|
4678
4700
|
try {
|
|
4679
4701
|
const result = await (await this.clientForTool(plugin, client, tool.name)).callTool(tool.name, resolvedArgs, options?.signal);
|
|
4680
4702
|
if ("isError" in result && result.isError) throw new McpToolError(extractMcpErrorMessage(result));
|
|
4681
|
-
|
|
4703
|
+
this.logToolCallAudit(plugin, tool.name, {
|
|
4682
4704
|
"gen_ai.tool.name": managedToolName,
|
|
4683
4705
|
...options?.toolCallId ? { "gen_ai.tool.call.id": options.toolCallId } : void 0
|
|
4684
4706
|
});
|
|
@@ -4723,7 +4745,10 @@ var McpToolManager = class {
|
|
|
4723
4745
|
"exception.message": getMcpAwareTelemetryMessage(error, conversationPrivacy)
|
|
4724
4746
|
};
|
|
4725
4747
|
setSpanAttributes(errorAttributes);
|
|
4726
|
-
if (error instanceof McpToolError) logWarn("mcp.tool_call.failed",
|
|
4748
|
+
if (error instanceof McpToolError) logWarn("mcp.tool_call.failed", {
|
|
4749
|
+
...this.options.auditAttributes,
|
|
4750
|
+
...errorAttributes
|
|
4751
|
+
});
|
|
4727
4752
|
throw error;
|
|
4728
4753
|
}
|
|
4729
4754
|
}, {
|
|
@@ -9555,6 +9580,58 @@ async function editAutomationFields(current, input, isCreator, changesExecution)
|
|
|
9555
9580
|
outcomes
|
|
9556
9581
|
};
|
|
9557
9582
|
}
|
|
9583
|
+
// src/chat/automations/instruction-references.ts
|
|
9584
|
+
function namesPerson(text, name) {
|
|
9585
|
+
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
9586
|
+
return new RegExp(`(?<![\\p{L}\\p{N}])${escaped}(?![\\p{L}\\p{N}])`, "iu").test(text);
|
|
9587
|
+
}
|
|
9588
|
+
const CONVERSATION_REFERENCE = /\bthis (?:channel|conversation|thread)\b/i;
|
|
9589
|
+
function refersTo(text, person) {
|
|
9590
|
+
return text.includes(slackMention(person.slackUserId)) || !!person.fullName && namesPerson(text, person.fullName);
|
|
9591
|
+
}
|
|
9592
|
+
/**
|
|
9593
|
+
* Return why the text cannot run later, or undefined.
|
|
9594
|
+
*
|
|
9595
|
+
* An Automation runs later without the request. So "this channel" means
|
|
9596
|
+
* nothing to the run. Its outcomes already say where it posts, so the text
|
|
9597
|
+
* names the channel only where the run reads or acts on it. Each run reads
|
|
9598
|
+
* "the Automation creator" as its creator, so the text calls the creator
|
|
9599
|
+
* that. Every other requester needs their Slack mention, because a display
|
|
9600
|
+
* name does not notify the person and it can match another person. A run
|
|
9601
|
+
* ends with a declared result, so a legacy no-reply marker does nothing. A
|
|
9602
|
+
* problem that the previous text already had stays allowed, so an edit does
|
|
9603
|
+
* not have to rewrite text that the requester did not change.
|
|
9604
|
+
*/
|
|
9605
|
+
function taskTextProblem(text, references) {
|
|
9606
|
+
const { creator, requester, previousText, label } = references;
|
|
9607
|
+
const conversationReference = CONVERSATION_REFERENCE.exec(text)?.[0];
|
|
9608
|
+
if (conversationReference && !CONVERSATION_REFERENCE.test(previousText)) return `The run does not see this conversation, and its outcomes already set where it posts. Remove "${conversationReference}" and do not say where to post. Where the run reads or changes a channel, name it with a channel mention.`;
|
|
9609
|
+
const marker = findLegacyNoReplyMarker(text);
|
|
9610
|
+
if (marker && !previousText.includes(marker)) return `Remove "${marker}". Say when the run posts nothing; it then ends without a message.`;
|
|
9611
|
+
if (refersTo(text, creator) && !refersTo(previousText, creator)) return `The ${label} names ${creator.fullName ?? slackMention(creator.slackUserId)}, the Automation creator. Write "the Automation creator" for this person; each run knows who that is.`;
|
|
9612
|
+
if (!requester?.fullName || requester.slackUserId === creator.slackUserId) return;
|
|
9613
|
+
const mention = slackMention(requester.slackUserId);
|
|
9614
|
+
if (text.includes(mention) || !namesPerson(text, requester.fullName)) return;
|
|
9615
|
+
return `The ${label} names ${requester.fullName} without a Slack mention. Write ${mention} for this person.`;
|
|
9616
|
+
}
|
|
9617
|
+
/**
|
|
9618
|
+
* Reject task text that a later run cannot use. The Automation tools and the
|
|
9619
|
+
* dashboard edit API call this. Restoring a saved version does not, because
|
|
9620
|
+
* that text was accepted when it was saved. Text that the current task
|
|
9621
|
+
* already had is not checked again.
|
|
9622
|
+
*/
|
|
9623
|
+
function requireAutomationTaskText(task, references) {
|
|
9624
|
+
const text = automationTaskText(task);
|
|
9625
|
+
const previousText = (references.current && automationTaskText(references.current)) ?? "";
|
|
9626
|
+
if (text === void 0 || text === previousText) return;
|
|
9627
|
+
const label = task.kind === "instruction" ? "instruction" : "context";
|
|
9628
|
+
const problem = taskTextProblem(text, {
|
|
9629
|
+
...references,
|
|
9630
|
+
previousText,
|
|
9631
|
+
label
|
|
9632
|
+
});
|
|
9633
|
+
if (problem) throw new AutomationEditError(problem, `task.${label}`);
|
|
9634
|
+
}
|
|
9558
9635
|
// src/chat/event-automations/tool-support.ts
|
|
9559
9636
|
/** Model-facing shape of one event automation. */
|
|
9560
9637
|
const compactEventAutomationResultSchema = z.object({
|
|
@@ -10291,6 +10368,11 @@ async function updateViewerAutomation(user, id, input) {
|
|
|
10291
10368
|
const current = await requireEditableAutomation(user, id);
|
|
10292
10369
|
if (input.kind !== current.kind) throw new AutomationEditError("The trigger type cannot change.", "kind");
|
|
10293
10370
|
requireAutomationRevision(current.task, input.revision);
|
|
10371
|
+
if (input.task) requireAutomationTaskText(input.task, {
|
|
10372
|
+
creator: current.task.createdBy,
|
|
10373
|
+
requester: automationEditor(user, current),
|
|
10374
|
+
current: current.task.task
|
|
10375
|
+
});
|
|
10294
10376
|
return saveViewerEdit(user, current, input);
|
|
10295
10377
|
}
|
|
10296
10378
|
/** `restored` carries version values that edit input cannot express, such as a cleared title. */
|
|
@@ -10647,39 +10729,6 @@ async function searchToolAutomations(context, caller, input) {
|
|
|
10647
10729
|
truncated: total > rows.length
|
|
10648
10730
|
};
|
|
10649
10731
|
}
|
|
10650
|
-
// src/chat/automations/instruction-references.ts
|
|
10651
|
-
function namesPerson(text, name) {
|
|
10652
|
-
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
10653
|
-
return new RegExp(`(?<![\\p{L}\\p{N}])${escaped}(?![\\p{L}\\p{N}])`, "iu").test(text);
|
|
10654
|
-
}
|
|
10655
|
-
const CONVERSATION_REFERENCE = /\bthis (?:channel|conversation|thread)\b/i;
|
|
10656
|
-
function refersTo(text, person) {
|
|
10657
|
-
return text.includes(slackMention(person.slackUserId)) || !!person.fullName && namesPerson(text, person.fullName);
|
|
10658
|
-
}
|
|
10659
|
-
/**
|
|
10660
|
-
* Reject an instruction with a reference that the run cannot use.
|
|
10661
|
-
*
|
|
10662
|
-
* An Automation runs later without the request. So "this channel" means
|
|
10663
|
-
* nothing to the run; the instruction names the channel instead. Each run
|
|
10664
|
-
* reads "the Automation creator" as its creator, so the instruction calls the
|
|
10665
|
-
* creator that. Every other requester needs their Slack mention, because a
|
|
10666
|
-
* display name does not notify the person and it can match another person. A
|
|
10667
|
-
* reference that the previous instruction already had stays allowed, so an
|
|
10668
|
-
* edit does not have to rewrite text that the requester did not change.
|
|
10669
|
-
*/
|
|
10670
|
-
function requireInstructionReferences(instruction, references) {
|
|
10671
|
-
const { creator, destinationChannelId, requester, previousInstruction = "" } = references;
|
|
10672
|
-
const conversationReference = CONVERSATION_REFERENCE.exec(instruction)?.[0];
|
|
10673
|
-
if (conversationReference && !CONVERSATION_REFERENCE.test(previousInstruction)) throw new ToolInputError(`The run does not see this conversation. Write <#${destinationChannelId}> instead of "${conversationReference}".`);
|
|
10674
|
-
if (refersTo(instruction, creator) && !refersTo(previousInstruction, creator)) {
|
|
10675
|
-
const reference = creator.fullName ?? slackMention(creator.slackUserId);
|
|
10676
|
-
throw new ToolInputError(`The instruction names ${reference}, the Automation creator. Write "the Automation creator" for this person; each run knows who that is.`);
|
|
10677
|
-
}
|
|
10678
|
-
if (!requester?.fullName || requester.slackUserId === creator.slackUserId) return;
|
|
10679
|
-
const mention = slackMention(requester.slackUserId);
|
|
10680
|
-
if (instruction.includes(mention)) return;
|
|
10681
|
-
if (namesPerson(instruction, requester.fullName)) throw new ToolInputError(`The instruction names ${requester.fullName} without a Slack mention. Write ${mention} for this person.`);
|
|
10682
|
-
}
|
|
10683
10732
|
// src/chat/scheduled-automations/tool-support.ts
|
|
10684
10733
|
/** Model-facing shape of one scheduled automation. */
|
|
10685
10734
|
const compactTaskResultSchema = z.object({
|
|
@@ -11074,7 +11123,7 @@ function createAutomationTool(context, catalog, skills = []) {
|
|
|
11074
11123
|
readOnlyHint: false
|
|
11075
11124
|
},
|
|
11076
11125
|
executionMode: "sequential",
|
|
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.",
|
|
11126
|
+
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. When an installed skill does the work, set skill; do not write an instruction that names the skill. 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.",
|
|
11078
11127
|
inputSchema: z.object({
|
|
11079
11128
|
instruction: automationInstructionToolSchema.nullable().optional(),
|
|
11080
11129
|
skill: automationSkillToolSchema(skills).nullable().optional(),
|
|
@@ -11082,7 +11131,7 @@ function createAutomationTool(context, catalog, skills = []) {
|
|
|
11082
11131
|
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(),
|
|
11083
11132
|
trigger,
|
|
11084
11133
|
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(),
|
|
11085
|
-
credential_mode: z.enum(["creator", "system"]).nullable().describe("
|
|
11134
|
+
credential_mode: z.enum(["creator", "system"]).nullable().describe("Omit or use null for the system default: runs use your own credentials. Use creator only when the creator asks for their connected credentials to be available to the runs.").optional()
|
|
11086
11135
|
}).strict(),
|
|
11087
11136
|
prepareArguments(args) {
|
|
11088
11137
|
const prepared = { ...args };
|
|
@@ -11090,7 +11139,7 @@ function createAutomationTool(context, catalog, skills = []) {
|
|
|
11090
11139
|
if (prepared.instruction == null) delete prepared.instruction;
|
|
11091
11140
|
if (prepared.skill == null) delete prepared.skill;
|
|
11092
11141
|
if (prepared.context == null) delete prepared.context;
|
|
11093
|
-
if (prepared.credential_mode ===
|
|
11142
|
+
if (prepared.credential_mode === null) delete prepared.credential_mode;
|
|
11094
11143
|
return prepared;
|
|
11095
11144
|
},
|
|
11096
11145
|
outputSchema: automationToolResultSchema,
|
|
@@ -11106,11 +11155,7 @@ function createAutomationTool(context, catalog, skills = []) {
|
|
|
11106
11155
|
context: input.context ?? void 0
|
|
11107
11156
|
});
|
|
11108
11157
|
await requireAutomationSkill(task, void 0);
|
|
11109
|
-
|
|
11110
|
-
if (text) requireInstructionReferences(text, {
|
|
11111
|
-
creator: createdBy,
|
|
11112
|
-
destinationChannelId: destination.channelId
|
|
11113
|
-
});
|
|
11158
|
+
requireAutomationTaskText(task, { creator: createdBy });
|
|
11114
11159
|
const eventTrigger = input.trigger.type === "event" ? requireEventAutomationTrigger(catalog, slackChannelMessageTrigger({
|
|
11115
11160
|
...input.trigger,
|
|
11116
11161
|
match: input.trigger.match ? declaredEventKeys(input.trigger.match) : void 0
|
|
@@ -11137,7 +11182,7 @@ function createAutomationTool(context, catalog, skills = []) {
|
|
|
11137
11182
|
id,
|
|
11138
11183
|
nowMs,
|
|
11139
11184
|
task,
|
|
11140
|
-
credentialMode: input.credential_mode ?? "
|
|
11185
|
+
credentialMode: input.credential_mode ?? "system",
|
|
11141
11186
|
outcomes: await resolveTaskOutcomes(input.outcomes, destination, createdBy.slackUserId),
|
|
11142
11187
|
title: await resolveTaskTitle({
|
|
11143
11188
|
signal: options.signal,
|
|
@@ -11624,13 +11669,10 @@ function createUpdateAutomationTool(context, catalog, skills = []) {
|
|
|
11624
11669
|
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.");
|
|
11625
11670
|
const editor = automationEditor(caller.viewer, current);
|
|
11626
11671
|
const editedTask = editedAutomationTask(current.task.task, input);
|
|
11627
|
-
|
|
11628
|
-
const text = editedTask && automationTaskText(editedTask);
|
|
11629
|
-
if (text !== void 0 && text !== previousText) requireInstructionReferences(text, {
|
|
11672
|
+
if (editedTask) requireAutomationTaskText(editedTask, {
|
|
11630
11673
|
creator: current.task.createdBy,
|
|
11631
|
-
destinationChannelId: current.task.destination.channelId,
|
|
11632
11674
|
requester: editor,
|
|
11633
|
-
|
|
11675
|
+
current: current.task.task
|
|
11634
11676
|
});
|
|
11635
11677
|
let saved = current;
|
|
11636
11678
|
if (Object.keys(input).length > 0) saved = current.kind === "scheduled" ? await updateScheduled(context, current, input, editedTask, editor) : await updateEvent(current, input, editedTask, editor, catalog);
|
|
@@ -18730,10 +18772,9 @@ function parseSessionIndex(value) {
|
|
|
18730
18772
|
}
|
|
18731
18773
|
}
|
|
18732
18774
|
function parseMcpAuthSession(value) {
|
|
18733
|
-
if (
|
|
18775
|
+
if (!isRecord$4(value)) return;
|
|
18734
18776
|
try {
|
|
18735
|
-
const parsed =
|
|
18736
|
-
if (!isRecord$4(parsed)) return;
|
|
18777
|
+
const parsed = value;
|
|
18737
18778
|
if (parsed.schemaVersion !== 2 || typeof parsed.authSessionId !== "string" || typeof parsed.provider !== "string" || typeof parsed.userId !== "string" || typeof parsed.conversationId !== "string" || typeof parsed.sessionId !== "string" || typeof parsed.userMessage !== "string" || typeof parsed.createdAtMs !== "number" || typeof parsed.updatedAtMs !== "number") return;
|
|
18738
18779
|
const destination = parsed.destination === void 0 ? void 0 : parseDestination(parsed.destination);
|
|
18739
18780
|
if (parsed.destination !== void 0 && !destination) return;
|
|
@@ -18776,9 +18817,8 @@ function parseServerSession(value) {
|
|
|
18776
18817
|
}
|
|
18777
18818
|
}
|
|
18778
18819
|
function parseStoredCredentials(value) {
|
|
18779
|
-
if (typeof value !== "string") return;
|
|
18780
18820
|
try {
|
|
18781
|
-
const parsed = JSON.parse(value);
|
|
18821
|
+
const parsed = typeof value === "string" ? JSON.parse(value) : value;
|
|
18782
18822
|
if (!isRecord$4(parsed)) return;
|
|
18783
18823
|
return {
|
|
18784
18824
|
...isRecord$4(parsed.clientInformation) ? { clientInformation: parsed.clientInformation } : void 0,
|
|
@@ -18789,17 +18829,26 @@ function parseStoredCredentials(value) {
|
|
|
18789
18829
|
return;
|
|
18790
18830
|
}
|
|
18791
18831
|
}
|
|
18832
|
+
async function readMcpAuthSession(stateAdapter, authSessionId) {
|
|
18833
|
+
const stored = await readEncryptedState(stateAdapter, sessionKey(authSessionId));
|
|
18834
|
+
if (stored?.stale && typeof stored.value === "string") try {
|
|
18835
|
+
return JSON.parse(stored.value);
|
|
18836
|
+
} catch {
|
|
18837
|
+
return;
|
|
18838
|
+
}
|
|
18839
|
+
return stored?.value;
|
|
18840
|
+
}
|
|
18792
18841
|
async function getConnectedStateAdapter() {
|
|
18793
18842
|
const stateAdapter = getStateAdapter();
|
|
18794
18843
|
await stateAdapter.connect();
|
|
18795
18844
|
return stateAdapter;
|
|
18796
18845
|
}
|
|
18797
18846
|
async function getMcpAuthSession(authSessionId) {
|
|
18798
|
-
return parseMcpAuthSession(await (await getConnectedStateAdapter()
|
|
18847
|
+
return parseMcpAuthSession(await readMcpAuthSession(await getConnectedStateAdapter(), authSessionId));
|
|
18799
18848
|
}
|
|
18800
18849
|
async function putMcpAuthSession(session, ttlMs = MCP_AUTH_SESSION_TTL_MS) {
|
|
18801
18850
|
const stateAdapter = await getConnectedStateAdapter();
|
|
18802
|
-
await stateAdapter.set(sessionKey(session.authSessionId),
|
|
18851
|
+
await createEncryptedState(stateAdapter).set(sessionKey(session.authSessionId), session, ttlMs);
|
|
18803
18852
|
const nextIndex = parseSessionIndex(await stateAdapter.get(sessionIndexKey(session.userId, session.provider)));
|
|
18804
18853
|
if (!nextIndex.includes(session.authSessionId)) nextIndex.push(session.authSessionId);
|
|
18805
18854
|
await stateAdapter.set(sessionIndexKey(session.userId, session.provider), JSON.stringify(nextIndex), ttlMs);
|
|
@@ -18826,7 +18875,7 @@ async function patchMcpAuthSession(authSessionId, patch) {
|
|
|
18826
18875
|
}
|
|
18827
18876
|
async function deleteMcpAuthSession(authSessionId) {
|
|
18828
18877
|
const stateAdapter = await getConnectedStateAdapter();
|
|
18829
|
-
const current = parseMcpAuthSession(await stateAdapter
|
|
18878
|
+
const current = parseMcpAuthSession(await readMcpAuthSession(stateAdapter, authSessionId));
|
|
18830
18879
|
await stateAdapter.delete(sessionKey(authSessionId));
|
|
18831
18880
|
if (!current) return;
|
|
18832
18881
|
const nextIndex = parseSessionIndex(await stateAdapter.get(sessionIndexKey(current.userId, current.provider))).filter((id) => id !== authSessionId);
|
|
@@ -18845,19 +18894,20 @@ async function deleteMcpAuthSessionsForUserProvider(userId, provider) {
|
|
|
18845
18894
|
}
|
|
18846
18895
|
async function getMcpStoredOAuthCredentials(userId, provider) {
|
|
18847
18896
|
const stateAdapter = await getConnectedStateAdapter();
|
|
18848
|
-
const stored = parseStoredCredentials(await stateAdapter
|
|
18897
|
+
const stored = parseStoredCredentials((await readEncryptedState(stateAdapter, credentialsKey(userId, provider)))?.value);
|
|
18849
18898
|
if (stored) return stored;
|
|
18850
18899
|
const legacyUserId = await findLegacyWebActorUserId(userId);
|
|
18851
18900
|
if (!legacyUserId) return void 0;
|
|
18852
18901
|
const legacyKey = credentialsKey(legacyUserId, provider);
|
|
18853
|
-
const legacy = parseStoredCredentials(await stateAdapter
|
|
18902
|
+
const legacy = parseStoredCredentials((await readEncryptedState(stateAdapter, legacyKey))?.value);
|
|
18854
18903
|
if (!legacy) return void 0;
|
|
18855
18904
|
await putMcpStoredOAuthCredentials(userId, provider, legacy);
|
|
18856
18905
|
await stateAdapter.delete(legacyKey);
|
|
18857
18906
|
return legacy;
|
|
18858
18907
|
}
|
|
18859
18908
|
async function putMcpStoredOAuthCredentials(userId, provider, value, ttlMs = MCP_AUTH_CREDENTIALS_TTL_MS) {
|
|
18860
|
-
|
|
18909
|
+
const stateAdapter = await getConnectedStateAdapter();
|
|
18910
|
+
await createEncryptedState(stateAdapter).set(credentialsKey(userId, provider), value, ttlMs);
|
|
18861
18911
|
}
|
|
18862
18912
|
async function deleteMcpStoredOAuthCredentials(userId, provider) {
|
|
18863
18913
|
const stateAdapter = await getConnectedStateAdapter();
|
|
@@ -19381,7 +19431,7 @@ ${renderRules("deny")}
|
|
|
19381
19431
|
- A user-requested read, query, or upload to a trusted destination is not data exposure. Using an existing credential to authenticate a user-requested action is not credential probing.
|
|
19382
19432
|
- A tool that is external, multi-field, open-world, uses connected credentials, has plugin or catalog identity, or carries a destructive annotation does not match a rule by those facts alone. Judge actual side effects, not tool names or annotations.
|
|
19383
19433
|
- For a scheduled automation or event automation, a request by the current actor for scoped work that needs their connected service access authorizes routine service-native reads and posting the requested result to the task's stored Slack destination. It does not authorize exposing credential values, broad data dumps, or delivery to another destination.
|
|
19384
|
-
- A current actor's request
|
|
19434
|
+
- A new automation uses system mode unless the creator asks for creator mode. System mode does not delegate personal credentials, so it needs no credential confirmation. A current actor's request to make their connected service access available for scoped work authorizes routine creator credential use required for that work; tools enforce whether they are the original creator. Creator mode that the current actor denied matches \`withheld_step\`. An automation's credential mode applies to its later runs. The credential-authority fields describe only the current action, so a difference between the two is expected.
|
|
19385
19435
|
|
|
19386
19436
|
# Output
|
|
19387
19437
|
- Rate risk and user authorization first.
|
|
@@ -19891,6 +19941,7 @@ async function createRunSandbox(args) {
|
|
|
19891
19941
|
egressSignals: args.run.environment?.sandboxEgressSignals,
|
|
19892
19942
|
conversationId: args.run.conversationId,
|
|
19893
19943
|
credentialEgress: args.run.credentialContext,
|
|
19944
|
+
credentialAuditSource: credentialAuditSource(args.run.source),
|
|
19894
19945
|
actor: args.currentActor,
|
|
19895
19946
|
locationConfiguration: args.run.environment?.locationConfiguration,
|
|
19896
19947
|
configurationValues: args.configurationValues,
|
|
@@ -19974,6 +20025,7 @@ function resolveToolRuntimeRoute(args) {
|
|
|
19974
20025
|
/** Wire sandbox tools, auth orchestration, MCP restoration, and Pi tool surfaces for one slice. */
|
|
19975
20026
|
async function wireAgentTools(args) {
|
|
19976
20027
|
const runSource = args.run.source;
|
|
20028
|
+
const auditSource = credentialAuditSource(runSource);
|
|
19977
20029
|
const credentialUserId = args.run.credentialContext ? credentialUserSubjectId(args.run.credentialContext) : void 0;
|
|
19978
20030
|
const userTokenStore = createUserTokenStore();
|
|
19979
20031
|
const { agentSandbox, pluginHooks } = args.sandbox;
|
|
@@ -20013,6 +20065,7 @@ async function wireAgentTools(args) {
|
|
|
20013
20065
|
authorization: args.authorization
|
|
20014
20066
|
});
|
|
20015
20067
|
const mcpToolManager = new McpToolManager(pluginCatalogRuntime.getMcpProviders(), {
|
|
20068
|
+
auditAttributes: credentialAuditAttributes(auditSource),
|
|
20016
20069
|
authProviderFactory: mcpAuth.authProviderFactory,
|
|
20017
20070
|
serviceAccountProviderFactory: mcpAuth.serviceAccountProviderFactory,
|
|
20018
20071
|
onAuthorizationRequired: (provider, _error, context) => mcpAuth.onAuthorizationRequired(provider, context),
|
|
@@ -20037,6 +20090,7 @@ async function wireAgentTools(args) {
|
|
|
20037
20090
|
userText: args.userInput,
|
|
20038
20091
|
configuration: args.configurationValues,
|
|
20039
20092
|
egress: createPluginEgress({
|
|
20093
|
+
credentialAuditSource: auditSource,
|
|
20040
20094
|
credentialContext: args.run.credentialContext,
|
|
20041
20095
|
pluginAuth: { async handleAuthRequired(signal) {
|
|
20042
20096
|
await pluginAuth.maybeHandleAuthSignal({ auth_required: {
|
|
@@ -22065,7 +22119,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
22065
22119
|
};
|
|
22066
22120
|
if (initialRepositoryInstructions) await recordAgentsTransition(initialRepositoryInstructions);
|
|
22067
22121
|
const getPendingAuthPause = wiring.getPendingAuthPause;
|
|
22068
|
-
const { baseInstructions: assembledBaseInstructions, contextContentParts: promptContextContentParts, inputMessages, inputMessagesAttribute, promptTimestamp: restoredPromptTimestamp, promptHistoryMessages, shouldPromptAgent, turnContexts, userContentParts: promptUserContentParts } = await assemblePrompt({
|
|
22122
|
+
const { baseInstructions: assembledBaseInstructions, contextContentParts: promptContextContentParts, inputMessages, inputMessagesAttribute, platform: promptPlatform, promptTimestamp: restoredPromptTimestamp, promptHistoryMessages, shouldPromptAgent, turnContexts, userContentParts: promptUserContentParts } = await assemblePrompt({
|
|
22069
22123
|
activeMcpCatalogs: wiring.activeMcpCatalogs,
|
|
22070
22124
|
promptMode: behavior.promptMode,
|
|
22071
22125
|
currentActor: actor,
|
|
@@ -22216,7 +22270,10 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
22216
22270
|
}
|
|
22217
22271
|
return acceptedMessages;
|
|
22218
22272
|
};
|
|
22219
|
-
const cacheWarming = createCacheWarmingRecorder(conversationId, isUserActor(actor) && conversationKind !== "task"
|
|
22273
|
+
const cacheWarming = createCacheWarmingRecorder(conversationId, isUserActor(actor) && conversationKind !== "task", {
|
|
22274
|
+
platform: promptPlatform,
|
|
22275
|
+
mode: behavior.promptMode
|
|
22276
|
+
});
|
|
22220
22277
|
const toolBatchStats = createToolBatchStats();
|
|
22221
22278
|
let setAgentSpanAttributes;
|
|
22222
22279
|
agent = new Agent({
|