@sentry/junior 0.293.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-uuecrKuD.js → admin-ifgjyfpF.js} +2 -2
- package/dist/{agent-runner-DHq1pjUg.js → agent-runner-DjMTPWEO.js} +192 -100
- 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 +73 -29
- package/dist/{app-fWzCHFIb.d.ts → app-uiTzRbvq.d.ts} +5 -3
- package/dist/app.d.ts +2 -2
- package/dist/app.js +64 -74
- package/dist/{automation-BE3z19VN.js → automation-yJX3C7i3.js} +3 -3
- package/dist/{background-compaction-queue-D7ncdEa6.js → background-compaction-queue-DUkHZjmL.js} +7 -9
- package/dist/{briefs-NpgMEFh1.js → briefs-CbNYM-q2.js} +3 -3
- package/dist/{catalog-runtime-DwbTyNRD.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 +7 -74
- package/dist/{config-B4b-NXH5.js → config-DvnTPCfp.js} +58 -7
- package/dist/{connections-Dz_AQg5p.js → connections-CWaIVl_1.js} +6 -6
- package/dist/{conversation-CtjR1Zcx.js → conversation-CMkSmi02.js} +3 -11
- package/dist/{conversation-pending-messages-1Kad1Mif.js → conversation-feed-BVAOga0H.js} +27 -2
- package/dist/{conversation-privacy-DRsSgLGO.js → conversation-privacy-DPjv4SnA.js} +1 -1
- package/dist/{credential-sync-ClCnnGVj.js → credential-sync-BhbaZfmO.js} +16 -15
- package/dist/{db-BbpttyKH.d.ts → db-CCUqQe0E.d.ts} +13 -6
- package/dist/{db-CoA7_Xqu.js → db-Dts2XvLu.js} +144 -7
- package/dist/{executor-SWyHhit0.js → executor-Ck73J0wP.js} +64 -10
- package/dist/instrumentation.js +2 -2
- package/dist/{logging-BN5drSEZ.js → logging-9OAq-fdg.js} +2 -1
- package/dist/{message-D4qjpW1C.js → message-CtaPzC7m.js} +9 -9
- package/dist/nitro.d.ts +2 -2
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-Xi-mTLOV.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-DXl4ftyL.js → projection-BzJQncZV.js} +251 -161
- package/dist/{prompt-Dmx6IfWZ.js → prompt-Cbq5b4SO.js} +5 -6
- package/dist/{registry-DosVt9f9.js → registry-cbpOxO4M.js} +3 -13
- package/dist/{resolve-BDjWJC9s.js → resolve-t-pmRdwS.js} +3 -3
- package/dist/{result-CaAFpf4B.js → result-DhgjR3nQ.js} +8 -8
- package/dist/{runner-h96Mkss6.js → runner-CHv9X9TH.js} +8 -8
- package/dist/{sandbox-egress-signals-rK91BW7i.js → sandbox-egress-signals-Yy3fSCbg.js} +1 -1
- package/dist/{schema-C_v8wb80.js → schema-BhneuGYv.js} +39 -7
- package/dist/{schema-CHsBmXIj.d.ts → schema-TSEisVJR.d.ts} +87 -14
- package/dist/secrets-DebYU866.js +18 -0
- package/dist/{service-account-WUMVuqVL.js → service-account-C4rBP8ne.js} +3 -3
- package/dist/{service-account-BpGpScaT.js → service-account-DjPIwCMj.js} +42 -26
- package/dist/{session-stop-xYK15HUu.js → session-stop-DkxI5vc3.js} +20 -775
- package/dist/{skills-DHApyCjj.js → skills-BZE2DP8I.js} +2 -2
- package/dist/{spawn-BQQrwGNe.js → spawn-BvULxIiu.js} +5 -5
- package/dist/{adapter-CMJfmHso.js → state-CO9ETDzk.js} +132 -2
- package/dist/{stop-CBeD6_Gs.js → stop-CL-rdtQb.js} +85 -32
- package/dist/{store-xtibD98L.js → store-DgD78_NK.js} +3 -3
- package/dist/{task-runner-BYPN4BEO.js → task-runner-CKOj6xla.js} +11 -11
- package/dist/{turn-failure-response-jNVl00MD.js → turn-failure-response-BTSo6SMJ.js} +8 -8
- package/dist/{validation-DGeB_moV.js → validation-CXeYgBzq.js} +1 -1
- package/dist/{version-C6nqU3Qc.js → version-AQa7Fr2H.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-9KLQibjn.js → viewer-Bqkb678l.js} +3 -3
- package/dist/warmup-h6u1e9n0.js +1869 -0
- package/dist/{work-xwX6unUE.js → work-yN_GAuXY.js} +11 -11
- package/dist/{worker-CiCCfwd4.js → worker-Hl7N292I.js} +6 -6
- package/migrations/0062_plugin_report_index.sql +1 -20
- package/migrations/0078_plugin_conversation_index.sql +1 -20
- package/migrations/0079_conversation_event_author_index.sql +1 -20
- package/migrations/0080_conversation_event_latest_message_indexes.sql +2 -27
- package/migrations/0090_guardian_review_time_index.sql +1 -20
- package/migrations/0091_conversation_participant_unsubscribed_index.sql +1 -20
- package/migrations/0097_conversation_kind_automation.sql +6 -0
- 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/0097_snapshot.json +4490 -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 +28 -0
- package/package.json +5 -5
- package/dist/assistant-reply-CIApSfor.js +0 -58
- package/dist/warmup-7S6z068f.js +0 -993
|
@@ -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
|
|
3
|
-
import { A as estimateTextTokens, B as
|
|
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-xYK15HUu.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";
|
|
@@ -704,7 +703,7 @@ function buildChatEndAttributes(message, mode) {
|
|
|
704
703
|
if (message.model) attributes["gen_ai.response.model"] = message.model;
|
|
705
704
|
if (message.responseId) attributes["gen_ai.response.id"] = message.responseId;
|
|
706
705
|
if (message.stopReason === "error") {
|
|
707
|
-
const providerError =
|
|
706
|
+
const providerError = createAssistantProviderError(message);
|
|
708
707
|
Object.assign(attributes, getProviderErrorAttributes(providerError));
|
|
709
708
|
attributes["error.type"] = providerError.kind;
|
|
710
709
|
}
|
|
@@ -917,6 +916,7 @@ function buildTurnResult(input) {
|
|
|
917
916
|
}
|
|
918
917
|
function buildDiagnostics(input, result) {
|
|
919
918
|
const { outcome, errorMessage, lastAssistant } = result;
|
|
919
|
+
const assistant = isAssistantMessage(lastAssistant) ? lastAssistant : void 0;
|
|
920
920
|
const toolResults = input.newMessages.filter(isToolResultMessage);
|
|
921
921
|
return {
|
|
922
922
|
outcome,
|
|
@@ -931,9 +931,12 @@ function buildDiagnostics(input, result) {
|
|
|
931
931
|
usage: input.usage,
|
|
932
932
|
stopReason: result.stopReason,
|
|
933
933
|
errorMessage,
|
|
934
|
-
providerError: outcome === "provider_error" && errorMessage ?
|
|
934
|
+
providerError: outcome === "provider_error" && errorMessage ? createAssistantProviderError({
|
|
935
|
+
errorMessage,
|
|
936
|
+
rawStopReason: assistant?.rawStopReason
|
|
937
|
+
}, {
|
|
935
938
|
modelId: input.modelId,
|
|
936
|
-
retryable:
|
|
939
|
+
retryable: assistant ? isRetryableAssistantError(assistant) : false
|
|
937
940
|
}) : void 0
|
|
938
941
|
};
|
|
939
942
|
}
|
|
@@ -991,6 +994,20 @@ function nextProviderRetry(args) {
|
|
|
991
994
|
providerError
|
|
992
995
|
};
|
|
993
996
|
}
|
|
997
|
+
/**
|
|
998
|
+
* Return the messages to send to the refusal fallback model, or undefined
|
|
999
|
+
* when the failure is not a provider refusal or no fallback model is set.
|
|
1000
|
+
*/
|
|
1001
|
+
function nextRefusalFallback(args) {
|
|
1002
|
+
if (!args.fallbackModelId || !args.failure || args.failure.stopReason !== "error" || !isProviderRefusal(args.failure)) return;
|
|
1003
|
+
const messages = trimTrailingAssistantMessages(args.messages);
|
|
1004
|
+
const tailRole = getPiMessageRole(messages.at(-1));
|
|
1005
|
+
if (messages.length === args.messages.length || tailRole !== "user" && tailRole !== "toolResult") return;
|
|
1006
|
+
return {
|
|
1007
|
+
messages,
|
|
1008
|
+
modelId: args.fallbackModelId
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
994
1011
|
// src/chat/services/empty-output-continuation.ts
|
|
995
1012
|
/**
|
|
996
1013
|
* Decide whether empty assistant output gets one continuation after a
|
|
@@ -3644,6 +3661,7 @@ function createSandbox(options) {
|
|
|
3644
3661
|
conversationId: options.conversationId,
|
|
3645
3662
|
credentials: credentialEgress,
|
|
3646
3663
|
egressId,
|
|
3664
|
+
source: options.credentialAuditSource,
|
|
3647
3665
|
ttlMs: sandboxEgressTokenTtlMs
|
|
3648
3666
|
});
|
|
3649
3667
|
sandboxEgressCredentialTokens.set(egressId, {
|
|
@@ -4163,9 +4181,29 @@ function accountText(value) {
|
|
|
4163
4181
|
if (!label) return;
|
|
4164
4182
|
return id && id !== label ? `${label} (${id})` : label;
|
|
4165
4183
|
}
|
|
4166
|
-
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) {
|
|
4167
4204
|
if (!isRecord$1(value) || !isRecord$1(value.permission_denied)) return;
|
|
4168
4205
|
const signal = value.permission_denied;
|
|
4206
|
+
if (signal.source === "policy") return policyDeniedText(value, signal);
|
|
4169
4207
|
if (signal.source !== "upstream") return;
|
|
4170
4208
|
const provider = stringField(signal, "provider");
|
|
4171
4209
|
const message = stringField(signal, "message");
|
|
@@ -4216,7 +4254,7 @@ function normalizeToolResult(result, options = {}) {
|
|
|
4216
4254
|
const unwrapped = result;
|
|
4217
4255
|
if (isStructuredToolExecutionResult(unwrapped)) {
|
|
4218
4256
|
const normalized = normalizeDetails(unwrapped.details, options);
|
|
4219
|
-
const permissionText =
|
|
4257
|
+
const permissionText = permissionDeniedText(normalized.details);
|
|
4220
4258
|
if (!permissionText && normalized.details === unwrapped.details) return unwrapped;
|
|
4221
4259
|
return {
|
|
4222
4260
|
content: permissionText || normalized.replaceEnvelopeText ? replaceGeneratedTextContent(unwrapped.content, permissionText ?? toToolContentText(normalized.details)) : unwrapped.content,
|
|
@@ -4234,7 +4272,7 @@ function normalizeToolResult(result, options = {}) {
|
|
|
4234
4272
|
return {
|
|
4235
4273
|
content: [{
|
|
4236
4274
|
type: "text",
|
|
4237
|
-
text:
|
|
4275
|
+
text: permissionDeniedText(normalized.details) ?? toToolContentText(normalized.details)
|
|
4238
4276
|
}],
|
|
4239
4277
|
details: normalized.details
|
|
4240
4278
|
};
|
|
@@ -4308,6 +4346,7 @@ function createAgentSandbox(options) {
|
|
|
4308
4346
|
egressSignals: options.egressSignals,
|
|
4309
4347
|
conversationId: options.conversationId,
|
|
4310
4348
|
credentialEgress: options.credentialEgress,
|
|
4349
|
+
credentialAuditSource: options.credentialAuditSource,
|
|
4311
4350
|
prepare: options.prepareSandbox,
|
|
4312
4351
|
prepareWorkspace: options.prepareWorkspace,
|
|
4313
4352
|
onSandboxRefChanged: async (sandboxRef) => {
|
|
@@ -4612,12 +4651,13 @@ var McpToolManager = class {
|
|
|
4612
4651
|
return actorClient;
|
|
4613
4652
|
}
|
|
4614
4653
|
/**
|
|
4615
|
-
* Record a completed call
|
|
4654
|
+
* Record a completed tool call, with the account that made it.
|
|
4616
4655
|
* Arguments stay out: the conversation history keeps them.
|
|
4617
4656
|
*/
|
|
4618
4657
|
logToolCallAudit(plugin, toolName, attributes) {
|
|
4619
4658
|
const usedServiceAccount = this.serviceAccountProviders.has(plugin.manifest.name) && serviceAccountAllows(plugin.manifest, { tool: toolName });
|
|
4620
4659
|
logAudit("mcp.tool_call.completed", {
|
|
4660
|
+
...this.options.auditAttributes,
|
|
4621
4661
|
...attributes,
|
|
4622
4662
|
"mcp.method.name": "tools/call",
|
|
4623
4663
|
"app.plugin.name": plugin.manifest.name,
|
|
@@ -4660,7 +4700,7 @@ var McpToolManager = class {
|
|
|
4660
4700
|
try {
|
|
4661
4701
|
const result = await (await this.clientForTool(plugin, client, tool.name)).callTool(tool.name, resolvedArgs, options?.signal);
|
|
4662
4702
|
if ("isError" in result && result.isError) throw new McpToolError(extractMcpErrorMessage(result));
|
|
4663
|
-
|
|
4703
|
+
this.logToolCallAudit(plugin, tool.name, {
|
|
4664
4704
|
"gen_ai.tool.name": managedToolName,
|
|
4665
4705
|
...options?.toolCallId ? { "gen_ai.tool.call.id": options.toolCallId } : void 0
|
|
4666
4706
|
});
|
|
@@ -4705,7 +4745,10 @@ var McpToolManager = class {
|
|
|
4705
4745
|
"exception.message": getMcpAwareTelemetryMessage(error, conversationPrivacy)
|
|
4706
4746
|
};
|
|
4707
4747
|
setSpanAttributes(errorAttributes);
|
|
4708
|
-
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
|
+
});
|
|
4709
4752
|
throw error;
|
|
4710
4753
|
}
|
|
4711
4754
|
}, {
|
|
@@ -5982,7 +6025,7 @@ function createSpawnAgentTool(spawnAgent, titleCost) {
|
|
|
5982
6025
|
// src/chat/conversations/delivery-pause.ts
|
|
5983
6026
|
/** True when the Conversation is a root that delivers to a Location. */
|
|
5984
6027
|
function canPauseConversationDelivery(conversation) {
|
|
5985
|
-
return conversation.kind
|
|
6028
|
+
return isTopLevelKind(conversation.kind) && conversation.location !== void 0;
|
|
5986
6029
|
}
|
|
5987
6030
|
const rootConversation = (conversationId) => and(eq(juniorConversations.conversationId, conversationId), isNull(juniorConversations.parentConversationId));
|
|
5988
6031
|
/**
|
|
@@ -6361,7 +6404,7 @@ async function wakePausedTurn(request, options = {}) {
|
|
|
6361
6404
|
const conversation = await (options.conversationStore ?? getConversationStore()).get({ conversationId: request.conversationId });
|
|
6362
6405
|
await requestConversationWork({
|
|
6363
6406
|
conversationId: request.conversationId,
|
|
6364
|
-
destination: conversation && conversation.kind
|
|
6407
|
+
destination: conversation && !isTopLevelKind(conversation.kind) ? void 0 : request.destination,
|
|
6365
6408
|
nowMs,
|
|
6366
6409
|
state: options.state
|
|
6367
6410
|
});
|
|
@@ -8165,7 +8208,7 @@ function storedActorFromWeb(actor) {
|
|
|
8165
8208
|
* Conversation: a dashboard Conversation, a Slack thread, or a Thread.
|
|
8166
8209
|
*/
|
|
8167
8210
|
function acceptsWebMessages(conversation) {
|
|
8168
|
-
if (conversation.kind
|
|
8211
|
+
if (!isTopLevelKind(conversation.kind)) return conversation.kind === "thread";
|
|
8169
8212
|
const { conversationId, destination } = conversation;
|
|
8170
8213
|
if (destination?.platform === "slack") return true;
|
|
8171
8214
|
return destination?.platform === "local" && conversationId.startsWith("local:web:");
|
|
@@ -8241,7 +8284,7 @@ async function recordWebConversationActivity(args) {
|
|
|
8241
8284
|
...isNewRoot && args.rootTitle ? { title: args.rootTitle } : void 0,
|
|
8242
8285
|
...isNewRoot ? { visibility } : void 0
|
|
8243
8286
|
});
|
|
8244
|
-
return existing && existing.kind
|
|
8287
|
+
return existing && !isTopLevelKind(existing.kind) ? void 0 : destination;
|
|
8245
8288
|
}
|
|
8246
8289
|
/** Create a Conversation from web input and enqueue its first Message. */
|
|
8247
8290
|
async function createAndEnqueueConversation(input, options) {
|
|
@@ -9537,6 +9580,58 @@ async function editAutomationFields(current, input, isCreator, changesExecution)
|
|
|
9537
9580
|
outcomes
|
|
9538
9581
|
};
|
|
9539
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
|
+
}
|
|
9540
9635
|
// src/chat/event-automations/tool-support.ts
|
|
9541
9636
|
/** Model-facing shape of one event automation. */
|
|
9542
9637
|
const compactEventAutomationResultSchema = z.object({
|
|
@@ -10273,6 +10368,11 @@ async function updateViewerAutomation(user, id, input) {
|
|
|
10273
10368
|
const current = await requireEditableAutomation(user, id);
|
|
10274
10369
|
if (input.kind !== current.kind) throw new AutomationEditError("The trigger type cannot change.", "kind");
|
|
10275
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
|
+
});
|
|
10276
10376
|
return saveViewerEdit(user, current, input);
|
|
10277
10377
|
}
|
|
10278
10378
|
/** `restored` carries version values that edit input cannot express, such as a cleared title. */
|
|
@@ -10629,39 +10729,6 @@ async function searchToolAutomations(context, caller, input) {
|
|
|
10629
10729
|
truncated: total > rows.length
|
|
10630
10730
|
};
|
|
10631
10731
|
}
|
|
10632
|
-
// src/chat/automations/instruction-references.ts
|
|
10633
|
-
function namesPerson(text, name) {
|
|
10634
|
-
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
10635
|
-
return new RegExp(`(?<![\\p{L}\\p{N}])${escaped}(?![\\p{L}\\p{N}])`, "iu").test(text);
|
|
10636
|
-
}
|
|
10637
|
-
const CONVERSATION_REFERENCE = /\bthis (?:channel|conversation|thread)\b/i;
|
|
10638
|
-
function refersTo(text, person) {
|
|
10639
|
-
return text.includes(slackMention(person.slackUserId)) || !!person.fullName && namesPerson(text, person.fullName);
|
|
10640
|
-
}
|
|
10641
|
-
/**
|
|
10642
|
-
* Reject an instruction with a reference that the run cannot use.
|
|
10643
|
-
*
|
|
10644
|
-
* An Automation runs later without the request. So "this channel" means
|
|
10645
|
-
* nothing to the run; the instruction names the channel instead. Each run
|
|
10646
|
-
* reads "the Automation creator" as its creator, so the instruction calls the
|
|
10647
|
-
* creator that. Every other requester needs their Slack mention, because a
|
|
10648
|
-
* display name does not notify the person and it can match another person. A
|
|
10649
|
-
* reference that the previous instruction already had stays allowed, so an
|
|
10650
|
-
* edit does not have to rewrite text that the requester did not change.
|
|
10651
|
-
*/
|
|
10652
|
-
function requireInstructionReferences(instruction, references) {
|
|
10653
|
-
const { creator, destinationChannelId, requester, previousInstruction = "" } = references;
|
|
10654
|
-
const conversationReference = CONVERSATION_REFERENCE.exec(instruction)?.[0];
|
|
10655
|
-
if (conversationReference && !CONVERSATION_REFERENCE.test(previousInstruction)) throw new ToolInputError(`The run does not see this conversation. Write <#${destinationChannelId}> instead of "${conversationReference}".`);
|
|
10656
|
-
if (refersTo(instruction, creator) && !refersTo(previousInstruction, creator)) {
|
|
10657
|
-
const reference = creator.fullName ?? slackMention(creator.slackUserId);
|
|
10658
|
-
throw new ToolInputError(`The instruction names ${reference}, the Automation creator. Write "the Automation creator" for this person; each run knows who that is.`);
|
|
10659
|
-
}
|
|
10660
|
-
if (!requester?.fullName || requester.slackUserId === creator.slackUserId) return;
|
|
10661
|
-
const mention = slackMention(requester.slackUserId);
|
|
10662
|
-
if (instruction.includes(mention)) return;
|
|
10663
|
-
if (namesPerson(instruction, requester.fullName)) throw new ToolInputError(`The instruction names ${requester.fullName} without a Slack mention. Write ${mention} for this person.`);
|
|
10664
|
-
}
|
|
10665
10732
|
// src/chat/scheduled-automations/tool-support.ts
|
|
10666
10733
|
/** Model-facing shape of one scheduled automation. */
|
|
10667
10734
|
const compactTaskResultSchema = z.object({
|
|
@@ -11056,7 +11123,7 @@ function createAutomationTool(context, catalog, skills = []) {
|
|
|
11056
11123
|
readOnlyHint: false
|
|
11057
11124
|
},
|
|
11058
11125
|
executionMode: "sequential",
|
|
11059
|
-
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.",
|
|
11060
11127
|
inputSchema: z.object({
|
|
11061
11128
|
instruction: automationInstructionToolSchema.nullable().optional(),
|
|
11062
11129
|
skill: automationSkillToolSchema(skills).nullable().optional(),
|
|
@@ -11064,7 +11131,7 @@ function createAutomationTool(context, catalog, skills = []) {
|
|
|
11064
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(),
|
|
11065
11132
|
trigger,
|
|
11066
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(),
|
|
11067
|
-
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()
|
|
11068
11135
|
}).strict(),
|
|
11069
11136
|
prepareArguments(args) {
|
|
11070
11137
|
const prepared = { ...args };
|
|
@@ -11072,7 +11139,7 @@ function createAutomationTool(context, catalog, skills = []) {
|
|
|
11072
11139
|
if (prepared.instruction == null) delete prepared.instruction;
|
|
11073
11140
|
if (prepared.skill == null) delete prepared.skill;
|
|
11074
11141
|
if (prepared.context == null) delete prepared.context;
|
|
11075
|
-
if (prepared.credential_mode ===
|
|
11142
|
+
if (prepared.credential_mode === null) delete prepared.credential_mode;
|
|
11076
11143
|
return prepared;
|
|
11077
11144
|
},
|
|
11078
11145
|
outputSchema: automationToolResultSchema,
|
|
@@ -11088,11 +11155,7 @@ function createAutomationTool(context, catalog, skills = []) {
|
|
|
11088
11155
|
context: input.context ?? void 0
|
|
11089
11156
|
});
|
|
11090
11157
|
await requireAutomationSkill(task, void 0);
|
|
11091
|
-
|
|
11092
|
-
if (text) requireInstructionReferences(text, {
|
|
11093
|
-
creator: createdBy,
|
|
11094
|
-
destinationChannelId: destination.channelId
|
|
11095
|
-
});
|
|
11158
|
+
requireAutomationTaskText(task, { creator: createdBy });
|
|
11096
11159
|
const eventTrigger = input.trigger.type === "event" ? requireEventAutomationTrigger(catalog, slackChannelMessageTrigger({
|
|
11097
11160
|
...input.trigger,
|
|
11098
11161
|
match: input.trigger.match ? declaredEventKeys(input.trigger.match) : void 0
|
|
@@ -11119,7 +11182,7 @@ function createAutomationTool(context, catalog, skills = []) {
|
|
|
11119
11182
|
id,
|
|
11120
11183
|
nowMs,
|
|
11121
11184
|
task,
|
|
11122
|
-
credentialMode: input.credential_mode ?? "
|
|
11185
|
+
credentialMode: input.credential_mode ?? "system",
|
|
11123
11186
|
outcomes: await resolveTaskOutcomes(input.outcomes, destination, createdBy.slackUserId),
|
|
11124
11187
|
title: await resolveTaskTitle({
|
|
11125
11188
|
signal: options.signal,
|
|
@@ -11606,13 +11669,10 @@ function createUpdateAutomationTool(context, catalog, skills = []) {
|
|
|
11606
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.");
|
|
11607
11670
|
const editor = automationEditor(caller.viewer, current);
|
|
11608
11671
|
const editedTask = editedAutomationTask(current.task.task, input);
|
|
11609
|
-
|
|
11610
|
-
const text = editedTask && automationTaskText(editedTask);
|
|
11611
|
-
if (text !== void 0 && text !== previousText) requireInstructionReferences(text, {
|
|
11672
|
+
if (editedTask) requireAutomationTaskText(editedTask, {
|
|
11612
11673
|
creator: current.task.createdBy,
|
|
11613
|
-
destinationChannelId: current.task.destination.channelId,
|
|
11614
11674
|
requester: editor,
|
|
11615
|
-
|
|
11675
|
+
current: current.task.task
|
|
11616
11676
|
});
|
|
11617
11677
|
let saved = current;
|
|
11618
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);
|
|
@@ -18712,10 +18772,9 @@ function parseSessionIndex(value) {
|
|
|
18712
18772
|
}
|
|
18713
18773
|
}
|
|
18714
18774
|
function parseMcpAuthSession(value) {
|
|
18715
|
-
if (
|
|
18775
|
+
if (!isRecord$4(value)) return;
|
|
18716
18776
|
try {
|
|
18717
|
-
const parsed =
|
|
18718
|
-
if (!isRecord$4(parsed)) return;
|
|
18777
|
+
const parsed = value;
|
|
18719
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;
|
|
18720
18779
|
const destination = parsed.destination === void 0 ? void 0 : parseDestination(parsed.destination);
|
|
18721
18780
|
if (parsed.destination !== void 0 && !destination) return;
|
|
@@ -18758,9 +18817,8 @@ function parseServerSession(value) {
|
|
|
18758
18817
|
}
|
|
18759
18818
|
}
|
|
18760
18819
|
function parseStoredCredentials(value) {
|
|
18761
|
-
if (typeof value !== "string") return;
|
|
18762
18820
|
try {
|
|
18763
|
-
const parsed = JSON.parse(value);
|
|
18821
|
+
const parsed = typeof value === "string" ? JSON.parse(value) : value;
|
|
18764
18822
|
if (!isRecord$4(parsed)) return;
|
|
18765
18823
|
return {
|
|
18766
18824
|
...isRecord$4(parsed.clientInformation) ? { clientInformation: parsed.clientInformation } : void 0,
|
|
@@ -18771,17 +18829,26 @@ function parseStoredCredentials(value) {
|
|
|
18771
18829
|
return;
|
|
18772
18830
|
}
|
|
18773
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
|
+
}
|
|
18774
18841
|
async function getConnectedStateAdapter() {
|
|
18775
18842
|
const stateAdapter = getStateAdapter();
|
|
18776
18843
|
await stateAdapter.connect();
|
|
18777
18844
|
return stateAdapter;
|
|
18778
18845
|
}
|
|
18779
18846
|
async function getMcpAuthSession(authSessionId) {
|
|
18780
|
-
return parseMcpAuthSession(await (await getConnectedStateAdapter()
|
|
18847
|
+
return parseMcpAuthSession(await readMcpAuthSession(await getConnectedStateAdapter(), authSessionId));
|
|
18781
18848
|
}
|
|
18782
18849
|
async function putMcpAuthSession(session, ttlMs = MCP_AUTH_SESSION_TTL_MS) {
|
|
18783
18850
|
const stateAdapter = await getConnectedStateAdapter();
|
|
18784
|
-
await stateAdapter.set(sessionKey(session.authSessionId),
|
|
18851
|
+
await createEncryptedState(stateAdapter).set(sessionKey(session.authSessionId), session, ttlMs);
|
|
18785
18852
|
const nextIndex = parseSessionIndex(await stateAdapter.get(sessionIndexKey(session.userId, session.provider)));
|
|
18786
18853
|
if (!nextIndex.includes(session.authSessionId)) nextIndex.push(session.authSessionId);
|
|
18787
18854
|
await stateAdapter.set(sessionIndexKey(session.userId, session.provider), JSON.stringify(nextIndex), ttlMs);
|
|
@@ -18808,7 +18875,7 @@ async function patchMcpAuthSession(authSessionId, patch) {
|
|
|
18808
18875
|
}
|
|
18809
18876
|
async function deleteMcpAuthSession(authSessionId) {
|
|
18810
18877
|
const stateAdapter = await getConnectedStateAdapter();
|
|
18811
|
-
const current = parseMcpAuthSession(await stateAdapter
|
|
18878
|
+
const current = parseMcpAuthSession(await readMcpAuthSession(stateAdapter, authSessionId));
|
|
18812
18879
|
await stateAdapter.delete(sessionKey(authSessionId));
|
|
18813
18880
|
if (!current) return;
|
|
18814
18881
|
const nextIndex = parseSessionIndex(await stateAdapter.get(sessionIndexKey(current.userId, current.provider))).filter((id) => id !== authSessionId);
|
|
@@ -18827,19 +18894,20 @@ async function deleteMcpAuthSessionsForUserProvider(userId, provider) {
|
|
|
18827
18894
|
}
|
|
18828
18895
|
async function getMcpStoredOAuthCredentials(userId, provider) {
|
|
18829
18896
|
const stateAdapter = await getConnectedStateAdapter();
|
|
18830
|
-
const stored = parseStoredCredentials(await stateAdapter
|
|
18897
|
+
const stored = parseStoredCredentials((await readEncryptedState(stateAdapter, credentialsKey(userId, provider)))?.value);
|
|
18831
18898
|
if (stored) return stored;
|
|
18832
18899
|
const legacyUserId = await findLegacyWebActorUserId(userId);
|
|
18833
18900
|
if (!legacyUserId) return void 0;
|
|
18834
18901
|
const legacyKey = credentialsKey(legacyUserId, provider);
|
|
18835
|
-
const legacy = parseStoredCredentials(await stateAdapter
|
|
18902
|
+
const legacy = parseStoredCredentials((await readEncryptedState(stateAdapter, legacyKey))?.value);
|
|
18836
18903
|
if (!legacy) return void 0;
|
|
18837
18904
|
await putMcpStoredOAuthCredentials(userId, provider, legacy);
|
|
18838
18905
|
await stateAdapter.delete(legacyKey);
|
|
18839
18906
|
return legacy;
|
|
18840
18907
|
}
|
|
18841
18908
|
async function putMcpStoredOAuthCredentials(userId, provider, value, ttlMs = MCP_AUTH_CREDENTIALS_TTL_MS) {
|
|
18842
|
-
|
|
18909
|
+
const stateAdapter = await getConnectedStateAdapter();
|
|
18910
|
+
await createEncryptedState(stateAdapter).set(credentialsKey(userId, provider), value, ttlMs);
|
|
18843
18911
|
}
|
|
18844
18912
|
async function deleteMcpStoredOAuthCredentials(userId, provider) {
|
|
18845
18913
|
const stateAdapter = await getConnectedStateAdapter();
|
|
@@ -19363,7 +19431,7 @@ ${renderRules("deny")}
|
|
|
19363
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.
|
|
19364
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.
|
|
19365
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.
|
|
19366
|
-
- 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.
|
|
19367
19435
|
|
|
19368
19436
|
# Output
|
|
19369
19437
|
- Rate risk and user authorization first.
|
|
@@ -19464,7 +19532,6 @@ function createGuardianActionReviewer(options) {
|
|
|
19464
19532
|
system: GUARDIAN_ACTION_POLICY,
|
|
19465
19533
|
prompt: guardianPrompt(proposal),
|
|
19466
19534
|
maxTokens: GUARDIAN_REVIEW_MAX_TOKENS,
|
|
19467
|
-
temperature: 0,
|
|
19468
19535
|
operation: "guardian_action_review",
|
|
19469
19536
|
cost: { owner: "caller" },
|
|
19470
19537
|
signal,
|
|
@@ -19874,6 +19941,7 @@ async function createRunSandbox(args) {
|
|
|
19874
19941
|
egressSignals: args.run.environment?.sandboxEgressSignals,
|
|
19875
19942
|
conversationId: args.run.conversationId,
|
|
19876
19943
|
credentialEgress: args.run.credentialContext,
|
|
19944
|
+
credentialAuditSource: credentialAuditSource(args.run.source),
|
|
19877
19945
|
actor: args.currentActor,
|
|
19878
19946
|
locationConfiguration: args.run.environment?.locationConfiguration,
|
|
19879
19947
|
configurationValues: args.configurationValues,
|
|
@@ -19957,6 +20025,7 @@ function resolveToolRuntimeRoute(args) {
|
|
|
19957
20025
|
/** Wire sandbox tools, auth orchestration, MCP restoration, and Pi tool surfaces for one slice. */
|
|
19958
20026
|
async function wireAgentTools(args) {
|
|
19959
20027
|
const runSource = args.run.source;
|
|
20028
|
+
const auditSource = credentialAuditSource(runSource);
|
|
19960
20029
|
const credentialUserId = args.run.credentialContext ? credentialUserSubjectId(args.run.credentialContext) : void 0;
|
|
19961
20030
|
const userTokenStore = createUserTokenStore();
|
|
19962
20031
|
const { agentSandbox, pluginHooks } = args.sandbox;
|
|
@@ -19996,6 +20065,7 @@ async function wireAgentTools(args) {
|
|
|
19996
20065
|
authorization: args.authorization
|
|
19997
20066
|
});
|
|
19998
20067
|
const mcpToolManager = new McpToolManager(pluginCatalogRuntime.getMcpProviders(), {
|
|
20068
|
+
auditAttributes: credentialAuditAttributes(auditSource),
|
|
19999
20069
|
authProviderFactory: mcpAuth.authProviderFactory,
|
|
20000
20070
|
serviceAccountProviderFactory: mcpAuth.serviceAccountProviderFactory,
|
|
20001
20071
|
onAuthorizationRequired: (provider, _error, context) => mcpAuth.onAuthorizationRequired(provider, context),
|
|
@@ -20020,6 +20090,7 @@ async function wireAgentTools(args) {
|
|
|
20020
20090
|
userText: args.userInput,
|
|
20021
20091
|
configuration: args.configurationValues,
|
|
20022
20092
|
egress: createPluginEgress({
|
|
20093
|
+
credentialAuditSource: auditSource,
|
|
20023
20094
|
credentialContext: args.run.credentialContext,
|
|
20024
20095
|
pluginAuth: { async handleAuthRequired(signal) {
|
|
20025
20096
|
await pluginAuth.maybeHandleAuthSignal({ auth_required: {
|
|
@@ -21833,7 +21904,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
21833
21904
|
let shouldTrace = false;
|
|
21834
21905
|
let getSandboxRef;
|
|
21835
21906
|
const reasoningLevel = policy.reasoningLevel ?? botConfig.reasoningLevel;
|
|
21836
|
-
|
|
21907
|
+
let activeModelId = botConfig.modelId;
|
|
21837
21908
|
const actor = actorFromRun(run);
|
|
21838
21909
|
const surface = surfaceFromRun(run);
|
|
21839
21910
|
const runSource = routing.source;
|
|
@@ -22048,7 +22119,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
22048
22119
|
};
|
|
22049
22120
|
if (initialRepositoryInstructions) await recordAgentsTransition(initialRepositoryInstructions);
|
|
22050
22121
|
const getPendingAuthPause = wiring.getPendingAuthPause;
|
|
22051
|
-
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({
|
|
22052
22123
|
activeMcpCatalogs: wiring.activeMcpCatalogs,
|
|
22053
22124
|
promptMode: behavior.promptMode,
|
|
22054
22125
|
currentActor: actor,
|
|
@@ -22199,7 +22270,10 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
22199
22270
|
}
|
|
22200
22271
|
return acceptedMessages;
|
|
22201
22272
|
};
|
|
22202
|
-
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
|
+
});
|
|
22203
22277
|
const toolBatchStats = createToolBatchStats();
|
|
22204
22278
|
let setAgentSpanAttributes;
|
|
22205
22279
|
agent = new Agent({
|
|
@@ -22425,6 +22499,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
22425
22499
|
let actionConfirmationRetryUsed = false;
|
|
22426
22500
|
let automationResultReminderUsed = !requireAutomationResult;
|
|
22427
22501
|
let providerRetryAttempt = 0;
|
|
22502
|
+
let refusalFallbackUsed = false;
|
|
22428
22503
|
let emptyOutputAttempt = 0;
|
|
22429
22504
|
const prepareRetry = async (messages) => {
|
|
22430
22505
|
discardedRetryUsage = addAgentTurnUsage(discardedRetryUsage, getDiscardedRetryUsage(agent.state.messages, messages));
|
|
@@ -22490,7 +22565,24 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
22490
22565
|
failure: lastAssistant,
|
|
22491
22566
|
messages: agent.state.messages
|
|
22492
22567
|
});
|
|
22493
|
-
if (!providerRetry)
|
|
22568
|
+
if (!providerRetry) {
|
|
22569
|
+
const refusalFallback = refusalFallbackUsed ? void 0 : nextRefusalFallback({
|
|
22570
|
+
failure: lastAssistant,
|
|
22571
|
+
fallbackModelId: botConfig.refusalFallbackModelId,
|
|
22572
|
+
messages: agent.state.messages
|
|
22573
|
+
});
|
|
22574
|
+
if (!refusalFallback) break;
|
|
22575
|
+
refusalFallbackUsed = true;
|
|
22576
|
+
await prepareRetry(refusalFallback.messages);
|
|
22577
|
+
logWarn("agent.turn.refusal_fallback", {
|
|
22578
|
+
"gen_ai.request.model": activeModelId,
|
|
22579
|
+
"app.ai.refusal_fallback.model": refusalFallback.modelId
|
|
22580
|
+
});
|
|
22581
|
+
activeModelId = refusalFallback.modelId;
|
|
22582
|
+
agent.state.model = resolveGatewayModel(activeModelId);
|
|
22583
|
+
run = agent.continue();
|
|
22584
|
+
continue;
|
|
22585
|
+
}
|
|
22494
22586
|
providerRetryAttempt += 1;
|
|
22495
22587
|
await prepareRetry(providerRetry.messages);
|
|
22496
22588
|
logWarn("agent.turn.provider.retrying", {
|