@sentry/junior 0.299.0 → 0.300.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapter-AgCNqqsG.js → adapter-S5UkjNK3.js} +5 -4
- package/dist/{admin-1VwEXztm.js → admin-UrTniSPO.js} +2 -2
- package/dist/{agent-runner-Ciet8_nn.js → agent-runner-bY4_0UPm.js} +508 -203
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +6 -7
- package/dist/api.d.ts +1 -1
- package/dist/api.js +293 -61
- package/dist/{app--ky-Eu33.d.ts → app-D-AcIcCV.d.ts} +13 -2
- package/dist/app.d.ts +1 -1
- package/dist/app.js +57 -219
- package/dist/{automation-M3RFJUBf.js → automation-Dw82oQ-h.js} +2 -2
- package/dist/{background-compaction-queue-CnimvRdk.js → background-compaction-queue-B6U3060-.js} +8 -4
- package/dist/{briefs-CwzvgdCa.js → briefs-DqiwWu-n.js} +3 -3
- package/dist/{catalog-runtime-DaBaHY7u.js → catalog-runtime-D1oYNv04.js} +1 -1
- package/dist/cli/chat.js +16 -16
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +5 -5
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +4 -4
- package/dist/{config-CAXIpWQb.js → config-9nHoFiJP.js} +39 -8
- package/dist/{connections-Dy0hPdUq.js → connections-DZjTN3JC.js} +6 -6
- package/dist/{continue-in-slack-DIOjFj76.js → continue-in-slack-Dtv7_U42.js} +6 -6
- package/dist/{conversation-fCWD9Az3.js → conversation-Dyjq2CZ8.js} +19 -8
- package/dist/{conversation-feed-BPK8vkkZ.js → conversation-feed-CcDxlrlQ.js} +23 -2
- package/dist/{conversation-privacy-DUgtRkf8.js → conversation-privacy-D-5HTXjS.js} +1 -1
- package/dist/{conversation-turn-DkJB6yMF.js → conversation-turn-Cxl8WZD7.js} +17 -17
- package/dist/{credential-sync-RX24Y8aY.js → credential-sync-C49ClwDX.js} +15 -15
- package/dist/{db-B07FtU9g.d.ts → db-2resqBh1.d.ts} +1 -1
- package/dist/{db-COYOGzYS.js → db-BJNo6fK5.js} +13 -8
- package/dist/{executor-BWmAgSyi.js → executor-DBIaOeJ_.js} +9 -4
- package/dist/instrumentation.js +14 -5
- package/dist/{lineage-D-5jm_oj.js → lineage-0dereG7H.js} +2 -2
- package/dist/{logging-DPLEa8Bn.js → logging-BIclibct.js} +1 -1
- package/dist/{message-BIHR1yRk.js → message-dkOl-Iii.js} +8 -8
- package/dist/{model-input-BPZYH8Nd.js → model-input-CLo9TaUd.js} +4 -4
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +4 -4
- package/dist/{oauth-callback-server-R7qvSzFG.js → oauth-callback-server-WmpjfJgQ.js} +2 -2
- package/dist/{plugins-CBW2Prb_.js → plugins-BBX07Jzt.js} +1 -1
- package/dist/{projection-DEdP1q6f.js → projection-w_X-zi7v.js} +3742 -3624
- package/dist/{prompt-4M98h_tC.js → prompt-B1Xw46-S.js} +4 -4
- package/dist/{registry-BTKmKM-r.js → registry-BmP5vnlj.js} +2 -2
- package/dist/{resolve-B8hXNVZ3.js → resolve-goo34bJK.js} +3 -3
- package/dist/{result-g-XAaOj6.js → result-PVBeU0Wf.js} +9 -9
- package/dist/{runner-BlPSA5A8.js → runner-DKrfvNV6.js} +9 -9
- package/dist/{sandbox-egress-signals-Pai-MzEY.js → sandbox-egress-signals-DsUcqrI0.js} +1 -1
- package/dist/{schema-BNnY_trV.js → schema-C9iNFz5n.js} +20 -16
- package/dist/{schema-DbuWR-DN.d.ts → schema-Dns-sTas.d.ts} +219 -6
- package/dist/{service-account-BYGZ08DQ.js → service-account-CMAAloAL.js} +3 -3
- package/dist/{service-account-9OLNQMyz.js → service-account-CmowamcB.js} +4 -4
- package/dist/{session-stop-2XJrcNCy.js → session-stop-BcAXze8a.js} +15 -41
- package/dist/{skills-DpBQoeHV.js → skills-DfsazET6.js} +2 -2
- package/dist/{slack-conversation-unfurl-BcDIWo67.js → slack-conversation-unfurl-CzQonuWz.js} +7 -7
- package/dist/{spawn-09GssFod.js → spawn-C7o0FDDp.js} +6 -6
- package/dist/{state-Cufq0_rH.js → state-zSilNpbi.js} +2 -2
- package/dist/{statuses-B8mUfghF.js → statuses-Hn-HsOph.js} +86 -2
- package/dist/{stop-U7iUrR1g.js → stop-CFOujp8C.js} +2938 -76
- package/dist/{store-CSgUTMdv.js → store-Dkeis_8o.js} +9 -9
- package/dist/{store-BHiaHCQu.js → store-E3x2Fg_F.js} +5 -5
- package/dist/{task-queue-bMNq0clp.js → task-queue-D-hCqdZW.js} +3 -3
- package/dist/{task-runner-B__rxwxU.js → task-runner-vohUPLHe.js} +8 -8
- package/dist/{thread-context-d0ceWbVT.js → thread-context-BzvdkgI9.js} +8 -8
- package/dist/{turn-session-routing-BVZHBFCF.js → turn-session-routing-Bo_LxFum.js} +5 -5
- package/dist/{turn-user-message-BEw7acTP.js → turn-user-message-D5RnVmxQ.js} +3 -3
- package/dist/{users-BK3dbxZL.js → users-2bggndVg.js} +3 -3
- package/dist/{validation-BDVJjO2E.js → validation-BbWikeSa.js} +1 -1
- package/dist/{version-DQgZoQ3D.js → version-GVBMW2jA.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-CAWfFo29.js → viewer-BpxRliyO.js} +16 -114
- package/dist/{warmup-9ySPacF9.js → warmup-BW2qwnal.js} +18 -16
- package/dist/{worker-D8jJO-WO.js → worker-Cbd-iuwZ.js} +24 -20
- package/migrations/0107_attachment_deferred_download.sql +2 -0
- package/migrations/meta/0107_snapshot.json +4617 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +10 -8
- package/dist/media-BAHvgkok.js +0 -85
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
import { g as withActiveSpan, h as startSpan, i as getActiveSpan, m as startInactiveSpan } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { $ as loadTurnCheckpoint, $a as
|
|
3
|
-
import { A 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, $a as isToolInputError, $i as create, $r as activeParticipantUserIds, $t as TurnSliceLimitExceededError, An as isStandaloneRuntimeContextMessage, Ar as dismissOpenReviewItems, B as getAgentContextInputLimitTokens, Ba as clearSandboxEgressSignals, Bi as renderToolResultNudge, Bn as SCRIPT_TOOLS_SECTION_TAG, Br as PLUGIN_REVIEW_ITEM_KEY_PREFIX, Cn as getTerminalAssistantMessages, Cs as getConfigDefaults, En as hasTurnInput, Fa as wrapSandboxSetupError, Fn as retainRuntimeTurnContext, G as AuthPausePersistenceError, Gi as listWorkspaces, Gn as readParentAgentTask, Go as downloadPrivateSlackFile, H as PluginCredentialFailureError, Ha as consumeSandboxEgressPermissionDeniedSignal, Hi as deleteWorkspace, Hn as TURN_CONTEXT_TAG, Hr as canAgentChangeReviewItem, Ia as WorkspaceSnapshotNotReadyError, In as stripRuntimeTurnContext, J as abandonReplacedPendingAuth, Ji as WorkspaceValidationError, Jo as getSlackClient, Jr as requireReviewItemLinks, K as AuthorizationFlowDisabledError, Ka as buildSandboxEgressNetworkPolicy, Ko as getFilePermalink, Kr as readReviewItemAgentScope, L as calculateContextCompactionTargetTokens, La as getWorkspaceSnapshotNotReadyError, Ln as trimTrailingAssistantMessages, Lr as searchReviewItems, Ma as isAbortError, Mi as getDashboardReviewItemLink, Mn as isToolResultMessage, Mr as getReviewItem, Na as isAlreadyExistsError, Nn as latestTurnContextSection, Nr as insertReviewItem, Oa as updateSlackMessage, Oi as getDashboardConversationLink, On as isAssistantMessage, Or as closeReviewItem, Pa as throwSandboxOperationError, Pi as getDashboardTaskLink, Pn as normalizeToolNameFromResult, Q as continuableMessages, Qa as ToolInputError, Qi as setWorkspaceSnapshotBuild, Qn as findLegacyWebActorUserId, Qo as normalizeSlackConversationId, Qr as EVERYONE_ASSIGNEE, Qt as TurnBudgetExceededError, R as getAgentBackgroundCompactionMarkTokens, Ra as isWorkspaceSnapshotNotReadyError, Rn as CAPABILITY_SECTION_TAG, Sa as openSlackDirectMessage, Sn as getPiMessageRole, Ss as projectConversationEvents, T as resolveTaskTitle, Ta as postSlackMessage, U as createPluginAuthOrchestration, Ua as createSandboxEgressCredentialToken, Ui as getWorkspace, Ur as canReadReviewItem, V as createPluginEgress, Va as consumeSandboxEgressAuthRequiredSignal, Vi as createWorkspace, Vo as readSlackAttachmentSource, W as authorizationId, Wi as getWorkspaceByName, Wo as SlackActionError, Xa as tryWorkspaceRepoCheckoutPath, Xi as loadSnapshotsForProfile, Xt as GATED_TURN_LIMIT_WRAP_UP_MESSAGE, Y as canReusePendingAuthLink, Ya as SANDBOX_RUNTIME, Yi as invalidateReadySnapshot, Yo as isConversationScopedChannel, Za as workspaceRepoCheckoutPath, Zi as setWorkspaceSnapshot, Zn as createUserTokenStore, Zt as TURN_LIMIT_WRAP_UP_MESSAGE, _i as getWatch, _n as CODE_MODE_CALL_STATUS_TEXT, ai as getSlackToolContext, an as isAnswerToolName, ao as SANDBOX_REPOS_ROOT, as as AttachmentSourceUnavailableError, ba as deleteSlackMessage, bs as historyItemFromPiMessage, c as recordAgentsInstructionsUpdated, ci as RESOURCE_WATCH_TOOL_SOURCE, cn as replyTextSchema, co as sandboxSkillDir, cs as createPluginAnnotations, di as cancelWatch, dn as sanitizeAssistantText, do as buildCommandScript, dr as getPlugins, ds as defaultTimezone, ea as hash, ei as automationCreatorUserId, en as TurnToolCallLimitExceededError, eo as PluginToolDeniedError, er as getOAuthAccountProviders, f as recordAuthorizationRequested, fa as escapeSlackMrkdwnText, fn as NO_REPLY_TOOL_NAME, fo as buildNonInteractiveShellScript, fs as resolveUserTimezone, g as recordToolExecutionStarted, ga as slackMention, gi as findMatchingWatches, gn as CODEMODE_TOOL_NAME, go as canAccessConversation, gs as credentialAuditSource, hi as deliverWatch, hn as readNoReply, hs as credentialAuditAttributes, i as loadConversationProjection, ii as resolveChannelCapabilities, in as REPLY_TOOL_NAME, io as SANDBOX_DATA_ROOT, ir as createPluginHookRunner, jn as isToolResultError, jr as getOpenReviewItemByDedupeKey, ka as uploadFilesToConversation, kn as isContinuablePiBoundary, l as recordAttachmentsDelivered, la as resolveBaseUrl, li as STOP_WATCHING_TOOL_NAME, ln as decideReply, lo as sandboxSkillFile, lr as getPluginTools, m as recordMcpProviderConnected, ma as normalizeSlackReplyMarkdown, mi as createWatch, mn as isLegacyNoReplyMarker, na as ensureDockerDaemon, ni as resolveAssignees, nn as createTurnLimitGate, ns as sleep, nt as saveTurnCheckpoint, oa as deliverOAuthAuthorization, oi as RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS, on as readTurnAnswer, oo as SANDBOX_SKILLS_ROOT, p as recordGuardianActionReviewed, pi as createTimerWatch, pn as findLegacyNoReplyMarker, po as runNonInteractiveCommand, q as AuthorizationPauseError, qa as resolveSandboxCommandEnvironment, qi as updateWorkspace, qr as requireReviewItemAssignees, r as loadConnectedMcpProviders, ra as getSandboxProvider, rn as isTurnExecutionLimitExceededError, ro as SANDBOX_COMMAND_PATH, sa as formatProviderLabel, si as RESOURCE_SUBSCRIPTION_MAX_TTL_MS, sn as remindMissingAnswer, so as SANDBOX_WORKSPACE_ROOT, ss as saveObjectAnnotations, ta as isStale, ti as resolveAssignee, ts as withSlackRetries, un as getAssistantReplyText, uo as sandboxSkillPathResolution, vi as listWatches, vn as REPORT_BLOCKED_TOOL_NAME, w as fallbackShortTitle, wn as getUserMessageInstructionText, xa as getSlackMessagePermalink, xn as extractAssistantText, xs as piMessageFromHistoryItem, ya as addReactionToMessage, yn as readBlockedReport, yo as readConversationAccessFromSql, z as getAgentContextCompactionTriggerTokens, za as workspaceSnapshotNotReadyUserMessage, zn as REQUEST_CONTEXT_SECTION_TAG, zo as matchSlackAttachments, zr as updateReviewItemContent } from "./projection-w_X-zi7v.js";
|
|
3
|
+
import { A as estimateRequestOverheadTokens, B as ProviderError, D as resolveGatewayModel, F as isCompactionSummaryText, H as createProviderError, J as getGatewayApiKey, K as isProviderRefusal, L as unwrapCurrentInstruction, M as textCharsForTokens, N as COMPACTION_SUMMARY_PREFIX, O as requestPrefixAttributes, P as hasCompactedConversationContext, R as escapeXml, U as findProviderError, V as createAssistantProviderError, W as getProviderErrorAttributes, X as bufferBody, Y as resolveGatewayCredential, _ as TURN_REASONING_LEVELS, b as GEN_AI_PROVIDER_NAME, j as estimateTextTokens, k as estimateMessagesTokens, n as botConfig, q as isProviderRetryError, v as toPiReasoningLevel, x as GEN_AI_SERVER_ADDRESS, y as normalizeSlackEmojiName, z as escapeXmlText } from "./config-9nHoFiJP.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-BIclibct.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-D-5HTXjS.js";
|
|
6
6
|
import { d as parseSlackChannelReferenceId, f as parseSlackTeamId, n as createSlackActor, o as isUserActor, p as parseSlackUserId, u as parseSlackChannelId, v as parseSlackMessageTs } from "./actor-D2iXzvlN.js";
|
|
7
|
-
import { $ as resolveRootConversationId, C as isPersonInput, E as turnBehavior, J as addAgentTurnUsage, N as resolveActorIdentityId, Q as hasAgentTurnUsage, Y as agentTurnCostUsd, a as getConversationStore, at as parseDestination, c as hasAnnotationKey, g as setArchivedAt, h as readConversationTrees, i as getConversationMessageSearchStore, j as SYSTEM_IDENTITY_ID, l as treeHasAnnotationKey, m as conversationDescendants, nt as nextDetailVersion, o as getDb, p as conversationAncestors, r as getConversationEventStore, rt as touchConversationDetail, s as getSqlExecutor, st as sameDestination, tt as conversationDetailTouch, w as isTopLevelKind } from "./db-
|
|
8
|
-
import { A as juniorAttachments, F as juniorArtifacts, M as juniorIdentities, N as juniorUsers, P as juniorDestinations, _ as juniorConversationReadPositions, b as juniorConversationBriefs, c as juniorReviewItemSlackCards, f as juniorAutomations, j as juniorConversations, k as juniorAttachmentUploads, p as juniorStats, u as juniorAutomationRuns, v as juniorConversationParticipants, w as juniorConversationEvents } from "./executor-
|
|
7
|
+
import { $ as resolveRootConversationId, C as isPersonInput, E as turnBehavior, J as addAgentTurnUsage, N as resolveActorIdentityId, Q as hasAgentTurnUsage, Y as agentTurnCostUsd, a as getConversationStore, at as parseDestination, c as hasAnnotationKey, g as setArchivedAt, h as readConversationTrees, i as getConversationMessageSearchStore, j as SYSTEM_IDENTITY_ID, l as treeHasAnnotationKey, m as conversationDescendants, nt as nextDetailVersion, o as getDb, p as conversationAncestors, r as getConversationEventStore, rt as touchConversationDetail, s as getSqlExecutor, st as sameDestination, tt as conversationDetailTouch, w as isTopLevelKind } from "./db-BJNo6fK5.js";
|
|
8
|
+
import { A as juniorAttachments, F as juniorArtifacts, M as juniorIdentities, N as juniorUsers, P as juniorDestinations, _ as juniorConversationReadPositions, b as juniorConversationBriefs, c as juniorReviewItemSlackCards, f as juniorAutomations, j as juniorConversations, k as juniorAttachmentUploads, p as juniorStats, u as juniorAutomationRuns, v as juniorConversationParticipants, w as juniorConversationEvents } from "./executor-DBIaOeJ_.js";
|
|
9
9
|
import { d as contextProvenance, f as instructionActors, m as sameActorIdentity, p as instructionProvenanceFor, t as KNOWN_CONVERSATION_EVENT_TYPES } from "./history-IjdmO_r6.js";
|
|
10
|
-
import { c as fenceLock, l as withLock, r as getStateAdapter } from "./adapter-
|
|
10
|
+
import { c as fenceLock, l as withLock, r as getStateAdapter } from "./adapter-S5UkjNK3.js";
|
|
11
11
|
import { a as listReferenceFiles } from "./package-discovery-DJhGdS4c.js";
|
|
12
|
-
import { c as fetchWithBoundedOAuthErrorBodies, d as actorLogContext, f as credentialContextForActor, g as credentialUserSubjectId, i as resolvePluginHeaderEnvRefs, l as getOAuthProviderErrorAttributes, s as OAuthProviderError } from "./registry-
|
|
13
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime-
|
|
14
|
-
import { a as parseSkillInvocation, n as findSkillByName, r as loadSkillsByName, t as discoverSkills } from "./skills-
|
|
15
|
-
import { l as completeObject, r as EVENT_AUTHOR_ID, u as completeText } from "./prompt-
|
|
12
|
+
import { c as fetchWithBoundedOAuthErrorBodies, d as actorLogContext, f as credentialContextForActor, g as credentialUserSubjectId, i as resolvePluginHeaderEnvRefs, l as getOAuthProviderErrorAttributes, s as OAuthProviderError } from "./registry-BmP5vnlj.js";
|
|
13
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime-D1oYNv04.js";
|
|
14
|
+
import { a as parseSkillInvocation, n as findSkillByName, r as loadSkillsByName, t as discoverSkills } from "./skills-DfsazET6.js";
|
|
15
|
+
import { l as completeObject, r as EVENT_AUTHOR_ID, u as completeText } from "./prompt-B1Xw46-S.js";
|
|
16
16
|
import { i as getFirstRunAtMs, o as getZonedDateTimeParts, s as isValidTimeZone } from "./schedule-cP0AACm1.js";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import { a as
|
|
28
|
-
import { a as
|
|
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-9OLNQMyz.js";
|
|
17
|
+
import { a as readActorIdentityFromSql, f as identityAvatarUrl, h as readUserAvatarUrls, i as readActorIdentity } from "./viewer-BpxRliyO.js";
|
|
18
|
+
import { G as MAX_ATTACHMENT_BYTES, M as formatAgentTypes, Q as briefOutcomeStatusSchema, U as removedCardSchema, Z as briefLinkSchema, k as AGENT_TYPES, nt as parseStoredBrief } from "./conversation-Dyjq2CZ8.js";
|
|
19
|
+
import { n as readEncryptedState, t as createEncryptedState } from "./state-zSilNpbi.js";
|
|
20
|
+
import { B as requireSlackChannelMessageScope, G as WORKSPACE_SNAPSHOT_FAILED_EVENT, J as workspaceSnapshotWatch, K as WORKSPACE_SNAPSHOT_READY_EVENT, M as EVENT_WAIT_MS, N as enqueueEventNotification, Q as resolveSlackReplyTarget, R as getEventCatalog, S as addConversationNote, W as slackChannelMessageTrigger, b as isExperimentalFeatureEnabled, ct as JUNIOR_PERSONALITY, d as buildPromptInput, dt as buildAgentsInstructionsMessage, f as buildSteeringPiMessage, ft as findVisibleAgentsInstructions, h as loadPromptTurnContext, ht as showsAgentsInstructions, lt as AGENTS_REMOVAL_NOTICE, mt as renderAgentsInstructions, pt as readRepositoryInstructions, q as workspaceSnapshotFinishedEvent, u as assemblePrompt, ut as AGENTS_REPLACEMENT_NOTICE, v as saveUserCustomization } from "./session-stop-BcAXze8a.js";
|
|
21
|
+
import { $ as AgentDepthLimitError, G as stopChildAgent, I as readLastParentMessageAtMs, N as isParentMessageMeta, S as listOpenAgentInvocations, ct as CHILD_AGENT_RESULTS, et as AgentInvocationLimitError, f as listDescendantAgents, i as createCacheWarmingRecorder, it as AgentNameInUseError, l as readLastUserMessageAtByConversation, lt as PARENT_AGENT_TARGET, nt as AgentMessageQueueFullError, rt as AgentMessageTargetError, st as CHILD_AGENT_KINDS, tt as AgentMessagePausedError, u as listAgentRelatives, ut as agentNameSchema, x as listAgentInvocationsForConversation, y as getLatestAgentInvocationForConversation } from "./warmup-BW2qwnal.js";
|
|
22
|
+
import { T as getTurnRequestDeadline, l as getVercelConversationWorkQueue, n as backgroundCompactionId, o as sendNextWorkspaceSnapshotJob, s as sendWorkspaceSnapshotJob, x as QUEUE_SIGNATURE_MAX_AGE_MS } from "./background-compaction-queue-B6U3060-.js";
|
|
23
|
+
import { R as buildDeterministicTurnId, d as isTurnInputCommitLostError, o as CooperativeTurnYieldError, s as TurnInputCommitLostError } from "./turn-user-message-D5RnVmxQ.js";
|
|
24
|
+
import { n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage } from "./store-E3x2Fg_F.js";
|
|
25
|
+
import { S as requireValidEventTrigger, _ as registeredEventMatchSchema, b as registeredResourceTypeSchema, d as describeRegisteredEventTrigger, g as hasEventCatalogEntries, h as eventWatchUnavailable, m as eventNamespaceSchema, t as resolveConversationRouting, u as automationEventCatalog, v as registeredEventTriggerProblems, x as requireEventIdentifier, y as registeredEventTypeSchema } from "./turn-session-routing-Bo_LxFum.js";
|
|
26
|
+
import { _ as userCustomizationTextSchema, a as USER_INPUT_NOTE, h as USER_CUSTOMIZATION_MAX_CHARS, i as USER_INPUT_LIMITS, l as normalizeUserInputAnswer, m as isVisionImageMediaType, o as buttonUserInputField, p as detectImageMediaType, r as AGENT_INVOCATION_STATUSES, s as formatUserInputAnswer, u as userInputRequestSchema } from "./statuses-Hn-HsOph.js";
|
|
27
|
+
import { a as setSnapshotSpanAttributes, i as postinstall, n as resolve$1, r as dependencies, s as getSandboxResources } from "./resolve-goo34bJK.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-CmowamcB.js";
|
|
30
29
|
import { m as apiErrorSchema, p as webMessageId, s as sumUtcHoursIntoSixHours } from "./reporting-window-DopzcOHh.js";
|
|
31
|
-
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-
|
|
32
|
-
import { C as readAutomationExecutionStatusHours, E as readAutomationRuns, G as deleteEventAutomation, I as parseScheduledAutomationRow, J as listDeletedEventAutomationsCreatedBy, L as readScheduledAutomation, N as createScheduledAutomation, P as deleteScheduledAutomation, R as saveScheduledAutomation, S as readAutomationExecutionStatusDays, T as readAutomationExecutions, W as createEventAutomation, X as saveEventAutomation, Y as parseEventAutomationRow, Z as setEventAutomationStatus, c as getDispatchRecord, et as automationDefinition, it as sameDefinitionValue, nt as listAutomationVersions, o as getDispatchIdForConversation, ot as automationRevision, q as getEventAutomation, rt as readAutomationVersion, s as getDispatchInputMessageId, st as requireAutomationRevision, w as readAutomationExecutionSummaries, x as readAutomationExecutionByConversationId, y as emptyAutomationRunWindows } from "./store-
|
|
33
|
-
import { a as runWithSlackInstallation, c as joinPublicChannelForRead, h as listThreadReplies, i as searchSlackUsers, m as listChannelMessages, n as lookupSlackUserByEmail, p as joinPublicChannel, r as lookupSlackUserProfile, s as checkSlackChannelReadAccess } from "./users-
|
|
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-Dw82oQ-h.js";
|
|
31
|
+
import { C as readAutomationExecutionStatusHours, E as readAutomationRuns, G as deleteEventAutomation, I as parseScheduledAutomationRow, J as listDeletedEventAutomationsCreatedBy, L as readScheduledAutomation, N as createScheduledAutomation, P as deleteScheduledAutomation, R as saveScheduledAutomation, S as readAutomationExecutionStatusDays, T as readAutomationExecutions, W as createEventAutomation, X as saveEventAutomation, Y as parseEventAutomationRow, Z as setEventAutomationStatus, c as getDispatchRecord, et as automationDefinition, it as sameDefinitionValue, nt as listAutomationVersions, o as getDispatchIdForConversation, ot as automationRevision, q as getEventAutomation, rt as readAutomationVersion, s as getDispatchInputMessageId, st as requireAutomationRevision, w as readAutomationExecutionSummaries, x as readAutomationExecutionByConversationId, y as emptyAutomationRunWindows } from "./store-Dkeis_8o.js";
|
|
32
|
+
import { a as runWithSlackInstallation, c as joinPublicChannelForRead, h as listThreadReplies, i as searchSlackUsers, m as listChannelMessages, n as lookupSlackUserByEmail, p as joinPublicChannel, r as lookupSlackUserProfile, s as checkSlackChannelReadAccess } from "./users-2bggndVg.js";
|
|
34
33
|
import { n as privateTraceResultAttributes } from "./private-trace-result-CE7_lEdq.js";
|
|
35
34
|
import * as z from "zod";
|
|
36
35
|
import { streamSimple } from "@earendil-works/pi-ai/compat";
|
|
@@ -207,6 +206,36 @@ var SkillSandbox = class {
|
|
|
207
206
|
throw new Error("No active skill is loaded. Call loadSkill first or pass skill_name explicitly.");
|
|
208
207
|
}
|
|
209
208
|
};
|
|
209
|
+
// src/chat/pi/agent-history.ts
|
|
210
|
+
function isSystemMessage(message) {
|
|
211
|
+
return message.role === "system";
|
|
212
|
+
}
|
|
213
|
+
/** Return Junior history: the messages without Pi's system messages. */
|
|
214
|
+
function readAgentHistory(messages) {
|
|
215
|
+
return messages.filter((message) => !isSystemMessage(message));
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Return the message list that replaces `current` with `history`. The leading
|
|
219
|
+
* system message of `current` stays first. System messages in `history` are
|
|
220
|
+
* dropped.
|
|
221
|
+
*/
|
|
222
|
+
function writeAgentHistory(current, history) {
|
|
223
|
+
const leading = current[0];
|
|
224
|
+
const messages = readAgentHistory(history);
|
|
225
|
+
return leading && isSystemMessage(leading) ? [leading, ...messages] : messages;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Give the stream path Junior's own system prompt and tools, with Junior
|
|
229
|
+
* history as the messages. The traced stream and cache warming then read the
|
|
230
|
+
* same request on every Pi version, without Pi's system messages.
|
|
231
|
+
*/
|
|
232
|
+
function withAgentRequest(base, request) {
|
|
233
|
+
return (model, context, options) => base(model, {
|
|
234
|
+
systemPrompt: request.systemPrompt,
|
|
235
|
+
messages: readAgentHistory(context.messages),
|
|
236
|
+
tools: request.tools
|
|
237
|
+
}, options);
|
|
238
|
+
}
|
|
210
239
|
// src/chat/agent/repository-context.ts
|
|
211
240
|
function findRestoredInstructions(messages, provenance) {
|
|
212
241
|
const restoredContext = messages?.map((message, index) => ({
|
|
@@ -222,15 +251,19 @@ function createRepositoryInstructionsContext(options) {
|
|
|
222
251
|
content: options.promptContextContentParts
|
|
223
252
|
}]) : findRestoredInstructions(options.restoredMessages, options.restoredProvenance);
|
|
224
253
|
return {
|
|
225
|
-
/**
|
|
226
|
-
|
|
227
|
-
|
|
254
|
+
/**
|
|
255
|
+
* Re-read AGENTS.md and append a context message to `messages` when it
|
|
256
|
+
* changed. Returns whether it set new messages.
|
|
257
|
+
*/
|
|
258
|
+
async applyUpdate(messages) {
|
|
259
|
+
if (!options.hasSandbox()) return false;
|
|
228
260
|
return await withSpan("agent.repository_instructions.refresh", "agent.repository_instructions.refresh", {}, async (setSpanAttributes) => {
|
|
229
261
|
const instructions = await options.capture();
|
|
230
262
|
const outcome = refreshOutcome(instructions);
|
|
231
263
|
setSpanAttributes({ "app.repository_instructions.outcome": outcome });
|
|
232
|
-
if (outcome === "unchanged" || outcome === "none") return;
|
|
233
|
-
|
|
264
|
+
if (outcome === "unchanged" || outcome === "none") return false;
|
|
265
|
+
await appendUpdate(instructions, messages);
|
|
266
|
+
return true;
|
|
234
267
|
});
|
|
235
268
|
} };
|
|
236
269
|
function refreshOutcome(instructions) {
|
|
@@ -239,12 +272,12 @@ async applyUpdate(currentContext) {
|
|
|
239
272
|
if (!instructionsVisible) return "added";
|
|
240
273
|
return showsAgentsInstructions(visibleInstructions, instructions) ? "unchanged" : "updated";
|
|
241
274
|
}
|
|
242
|
-
async function appendUpdate(instructions,
|
|
275
|
+
async function appendUpdate(instructions, currentMessages) {
|
|
243
276
|
const message = instructions ? buildAgentsInstructionsMessage({
|
|
244
277
|
directory: instructions.directory,
|
|
245
278
|
text: visibleInstructions?.active === true ? `${AGENTS_REPLACEMENT_NOTICE}\n\n${instructions.text}` : instructions.text
|
|
246
279
|
}) : buildAgentsInstructionsMessage({ text: AGENTS_REMOVAL_NOTICE });
|
|
247
|
-
const messages = [...
|
|
280
|
+
const messages = [...currentMessages, message];
|
|
248
281
|
options.setMessages(messages);
|
|
249
282
|
await options.commit(messages);
|
|
250
283
|
visibleInstructions = instructions ? {
|
|
@@ -253,10 +286,6 @@ async applyUpdate(currentContext) {
|
|
|
253
286
|
text: instructions.text
|
|
254
287
|
} : { active: false };
|
|
255
288
|
await options.onTransition?.(instructions);
|
|
256
|
-
return { context: {
|
|
257
|
-
...currentContext,
|
|
258
|
-
messages
|
|
259
|
-
} };
|
|
260
289
|
}
|
|
261
290
|
}
|
|
262
291
|
// src/chat/pi/traced-stream.ts
|
|
@@ -3038,7 +3067,7 @@ function createEditFileTool() {
|
|
|
3038
3067
|
openWorldHint: false,
|
|
3039
3068
|
readOnlyHint: false
|
|
3040
3069
|
},
|
|
3041
|
-
description: "Edit one sandbox workspace file with exact text replacements. Use for precise changes to existing files; prefer this over writeFile for targeted changes.
|
|
3070
|
+
description: "Edit one sandbox workspace file with exact text replacements. Use for precise changes to existing files; prefer this over writeFile for targeted changes. Returns a diff. Multiple changes to the same file: use one edits[] call.",
|
|
3042
3071
|
prepareArguments: prepareEditFileArguments,
|
|
3043
3072
|
executionMode: "sequential",
|
|
3044
3073
|
inputSchema: z.object({
|
|
@@ -4793,10 +4822,10 @@ function createCallMcpToolTool(mcpToolManager) {
|
|
|
4793
4822
|
openWorldHint: true,
|
|
4794
4823
|
readOnlyHint: false
|
|
4795
4824
|
},
|
|
4796
|
-
description: "Call an active MCP tool by exact
|
|
4825
|
+
description: "Call an active MCP tool by its exact name. Use searchMcpTools to discover tool names and schemas; copy required provider fields into arguments. Authorization is handled by the runtime when required.",
|
|
4797
4826
|
inputSchema: z.object({
|
|
4798
4827
|
tool_name: z.string().min(1).describe("Exact MCP tool_name from searchMcpTools."),
|
|
4799
|
-
arguments: z.record(z.string(), z.unknown()).describe("Arguments matching the disclosed MCP tool schema, for example { \"query\": \"...\" } when searchMcpTools shows query is required.").optional(),
|
|
4828
|
+
arguments: z.record(z.string(), z.unknown()).describe("Arguments matching the disclosed MCP tool schema, for example { \"query\": \"...\" } when searchMcpTools shows query is required. Omit only when the discovered tool has no arguments.").optional(),
|
|
4800
4829
|
intent: z.string().min(1).describe("Optional short purpose to show the user if this call needs them to connect their account, for example \"search Notion for the Q3 offsite doc\".").optional()
|
|
4801
4830
|
}).passthrough(),
|
|
4802
4831
|
resolveApprovalMetadata: ({ tool_name }) => {
|
|
@@ -5273,7 +5302,7 @@ const messageAgentOutputSchema = juniorToolOutputSchema.extend({
|
|
|
5273
5302
|
*/
|
|
5274
5303
|
function createMessageAgentTool(messageAgent) {
|
|
5275
5304
|
return zodTool({
|
|
5276
|
-
description: `Send a message to your parent agent or to a child agent that this conversation started. Use it to give an existing child agent more work, an answer, or a correction, and to send your parent agent a finding or a question while you keep working. A message to a child continues its history. If the child is still working, it reads the message at its next step or after its current work. A child replies when it has something to report. Its reply arrives later as a new task in this conversation; do not wait or poll for it.
|
|
5305
|
+
description: `Send a message to your parent agent or to a child agent that this conversation started. Use it to give an existing child agent more work, an answer, or a correction, and to send your parent agent a finding or a question while you keep working. A message to a child continues its history. If the child is still working, it reads the message at its next step or after its current work. A child replies when it has something to report. Its reply arrives later as a new task in this conversation; do not wait or poll for it. Make sure people know what is going on, but post only updates that matter to them. A message to your parent does not end your task. A top-level agent (its conversation is not a child agent, such as a Slack thread) can also message another top-level agent. Both conversations must be public, or both must be private conversations in the same place, such as one private channel or DM. The target runs the message as its own task and sends no result. Use spawnAgent only to start a new child agent.`,
|
|
5277
5306
|
exposure: "modelOnly",
|
|
5278
5307
|
approvalMode: "auto",
|
|
5279
5308
|
annotations: {
|
|
@@ -5283,8 +5312,8 @@ function createMessageAgentTool(messageAgent) {
|
|
|
5283
5312
|
readOnlyHint: false
|
|
5284
5313
|
},
|
|
5285
5314
|
inputSchema: z.object({
|
|
5286
|
-
to: z.string().trim().min(1).describe(`"${PARENT_AGENT_TARGET}" for your parent agent, the name or conversation_id of a child agent from spawnAgent or listAgents, or the conversation_id of another top-level agent`),
|
|
5287
|
-
text: z.string().trim().min(1).max(MESSAGE_AGENT_TEXT_MAX_LENGTH).describe("Message text. Include all context the target needs.")
|
|
5315
|
+
to: z.string().trim().min(1).describe(`"${PARENT_AGENT_TARGET}" for your parent agent, the name or conversation_id of a child agent from spawnAgent or listAgents, or the conversation_id of another top-level agent, such as one from searchConversations or slackThreadRead`),
|
|
5316
|
+
text: z.string().trim().min(1).max(MESSAGE_AGENT_TEXT_MAX_LENGTH).describe("Message text. Include all context the target needs. Text to a child agent is its instruction. Its action review judges the child's actions against that text, so name only actions that your own conversation backs, with the exact target.")
|
|
5288
5317
|
}).strict(),
|
|
5289
5318
|
outputSchema: messageAgentOutputSchema,
|
|
5290
5319
|
execute: async (input, options) => {
|
|
@@ -5324,8 +5353,8 @@ function createSpawnAgentTool(spawnAgent, titleCost) {
|
|
|
5324
5353
|
"Start a new asynchronous child agent. A child agent has its own sandbox and tool budget, runs at the same time as you, and replies when it has something to report. Its kind is a Thread for one discrete work item that people will own and talk to, or a Task for work that you delegate. Use Tasks to run independent work in parallel and to keep long investigations out of your context.",
|
|
5325
5354
|
"Delegate a Task when: the request splits into independent tracks that each need real investigation, such as several repos, services, sources, or items (start every track in the same message); an answer needs reading across many files, logs, or sources and you need the conclusion, not the raw output; a side task does not block your main answer; or you want a second opinion that is not anchored on your analysis (give it the evidence, not your conclusion).",
|
|
5326
5355
|
"Do it yourself instead of a Task when: the work fits in a handful of tool calls; you already know the file, symbol, or value to look up; or the job is one modest task that you would only split into pieces. Each child rebuilds its context and its result arrives in a later turn, so when in doubt, do not spawn a Task.",
|
|
5327
|
-
`
|
|
5328
|
-
|
|
5356
|
+
`Child agent types:\n${formatAgentTypes()}`,
|
|
5357
|
+
"After you delegate, do not do the same work yourself. Make sure people know what is going on, but post only updates that matter to them. Share a Thread's dashboard_url so people can find it.",
|
|
5329
5358
|
"You know nothing about a child's findings until its result arrives: do not predict them, do not wait or poll, and if the user asks before then, give status.",
|
|
5330
5359
|
"Give a child a name when you may send it more work later. To give more work to a child agent that already exists, use messageAgent instead.",
|
|
5331
5360
|
"A child keeps its type and kind when it receives more work through messageAgent.",
|
|
@@ -5340,12 +5369,12 @@ function createSpawnAgentTool(spawnAgent, titleCost) {
|
|
|
5340
5369
|
readOnlyHint: false
|
|
5341
5370
|
},
|
|
5342
5371
|
inputSchema: z.object({
|
|
5343
|
-
task: z.string().trim().min(1).describe("Self-contained brief. Unless fork is true, the child has not seen this thread, so this is its only context. Brief it like a capable peer who just joined: the goal and why it matters; target repos, refs, paths, and URLs; facts you already verified and what you ruled out; constraints, including which remote side effects are allowed (scratch work in its sandbox is always fine); what counts as done; and the shape and length of the result to return. Do the synthesis yourself: name the exact question, files, or change instead of writing 'based on your findings, fix it'. If you cannot write a clear brief, you do not understand the task well enough to delegate it. Summarize thread facts instead of pasting the thread."),
|
|
5372
|
+
task: z.string().trim().min(1).describe("Self-contained brief. Unless fork is true, the child has not seen this thread, so this is its only context. Brief it like a capable peer who just joined: the goal and why it matters; target repos, refs, paths, and URLs; facts you already verified and what you ruled out; constraints, including which remote side effects are allowed (scratch work in its sandbox is always fine); what counts as done; and the shape and length of the result to return. Do the synthesis yourself: name the exact question, files, or change instead of writing 'based on your findings, fix it'. If you cannot write a clear brief, you do not understand the task well enough to delegate it. Summarize thread facts instead of pasting the thread. When fork is true, the task is a directive: say what to do and what is in or out of scope; do not re-explain the background."),
|
|
5344
5373
|
title: z.string().trim().min(1).max(60).nullable().optional().describe("Optional short display title of the child and its Conversation. Pass one to skip title generation; omit it to generate one from the task."),
|
|
5345
5374
|
name: agentNameSchema.refine((name) => name !== PARENT_AGENT_TARGET, { message: `"${PARENT_AGENT_TARGET}" is reserved` }).nullable().optional().describe("New child-agent name that messageAgent can address, or omit for a one-off agent"),
|
|
5346
|
-
kind: z.enum(CHILD_AGENT_KINDS).nullable().optional().describe("thread: one
|
|
5347
|
-
agent_type: z.enum(AGENT_TYPES).nullable().optional().describe("Child agent type from the list in this tool's description. Omit or pass null for a general-purpose child."),
|
|
5348
|
-
fork: z.boolean().nullable().optional().describe("true: the child
|
|
5375
|
+
kind: z.enum(CHILD_AGENT_KINDS).nullable().optional().describe("thread: one work item about the size of one issue or code change, or long-lived work, that people open, message, follow, and steer. A request to create or start a thread means this kind, not a Slack thread. task (default): background work only you message."),
|
|
5376
|
+
agent_type: z.enum(AGENT_TYPES).nullable().optional().describe("Child agent type from the list in this tool's description. Pick one when it fits. Omit or pass null for a general-purpose child with your tools."),
|
|
5377
|
+
fork: z.boolean().nullable().optional().describe("true: the child gets a copy of this conversation's history, which adds cost and noise. Pass true only when the child needs most of this conversation, such as its discussion and decisions, so that a brief would repeat most of it. Works with any agent_type."),
|
|
5349
5378
|
reasoning_level: z.enum(TURN_REASONING_LEVELS).nullable().optional().describe("Optional reasoning level for this delegated task only")
|
|
5350
5379
|
}).strict(),
|
|
5351
5380
|
outputSchema: spawnAgentOutputSchema,
|
|
@@ -5759,19 +5788,26 @@ const DAY_MS = 864e5;
|
|
|
5759
5788
|
const ATTACHMENT_GC_BATCH_LIMIT = 200;
|
|
5760
5789
|
/** Time that Junior keeps attachment bytes after the file is stored. */
|
|
5761
5790
|
const ATTACHMENT_RETENTION_MS = 30 * DAY_MS;
|
|
5762
|
-
function
|
|
5763
|
-
return createHash("sha256").update(file.data).digest("hex");
|
|
5791
|
+
function attachmentIdentity(file) {
|
|
5792
|
+
if ("data" in file) return file.source ?? { sha256: createHash("sha256").update(file.data).digest("hex") };
|
|
5793
|
+
return file.source;
|
|
5764
5794
|
}
|
|
5765
|
-
/** Stable conversation-owned id for one file
|
|
5795
|
+
/** Stable conversation-owned id for one file and its presentation metadata. */
|
|
5766
5796
|
function attachmentId(args) {
|
|
5767
|
-
const identity = [
|
|
5797
|
+
const identity = "sha256" in args.identity ? [
|
|
5768
5798
|
args.conversationId,
|
|
5769
5799
|
args.storageProvider,
|
|
5770
|
-
args.sha256,
|
|
5800
|
+
args.identity.sha256,
|
|
5771
5801
|
args.filename,
|
|
5772
5802
|
args.contentType
|
|
5803
|
+
] : [
|
|
5804
|
+
args.conversationId,
|
|
5805
|
+
args.storageProvider,
|
|
5806
|
+
args.filename,
|
|
5807
|
+
args.contentType,
|
|
5808
|
+
args.identity.provider,
|
|
5809
|
+
args.identity.id
|
|
5773
5810
|
];
|
|
5774
|
-
if (args.source) identity.push(args.source.provider, args.source.id);
|
|
5775
5811
|
return createHash("sha256").update(identity.join("\0")).digest("hex");
|
|
5776
5812
|
}
|
|
5777
5813
|
/**
|
|
@@ -5784,11 +5820,66 @@ function attachmentId(args) {
|
|
|
5784
5820
|
function attachmentKey(args) {
|
|
5785
5821
|
return `conversations/${args.conversationId}/attachments/${args.attachmentId}/${args.writeId}/${args.filename}`;
|
|
5786
5822
|
}
|
|
5823
|
+
/** A source whose bytes do not match its declared size. A retry cannot fix it. */
|
|
5824
|
+
var AttachmentSizeError = class extends Error {
|
|
5825
|
+
constructor(bytes, expected, options) {
|
|
5826
|
+
super(`Attachment body does not match its declared ${expected} bytes (read ${bytes})`, options);
|
|
5827
|
+
this.name = "AttachmentSizeError";
|
|
5828
|
+
}
|
|
5829
|
+
};
|
|
5830
|
+
/** Tries for one object write, each with a freshly opened body. */
|
|
5831
|
+
const WRITE_ATTEMPTS = 3;
|
|
5787
5832
|
async function bestEffortDelete(storage, key) {
|
|
5833
|
+
if (key === null) return;
|
|
5788
5834
|
try {
|
|
5789
5835
|
await storage.delete([key]);
|
|
5790
5836
|
} catch {}
|
|
5791
5837
|
}
|
|
5838
|
+
/**
|
|
5839
|
+
* Stream one file to a fresh key, and return its size and digest.
|
|
5840
|
+
*
|
|
5841
|
+
* The digest is taken while the bytes stream, so the body is never held
|
|
5842
|
+
* whole. A body that does not match its declared size is not kept.
|
|
5843
|
+
*/
|
|
5844
|
+
async function writeAttachmentObject(args) {
|
|
5845
|
+
for (let attempt = 1;; attempt += 1) try {
|
|
5846
|
+
return await writeAttachmentObjectOnce(args);
|
|
5847
|
+
} catch (error) {
|
|
5848
|
+
if (error instanceof AttachmentSizeError || attempt >= WRITE_ATTEMPTS) {
|
|
5849
|
+
await bestEffortDelete(args.storage, args.key);
|
|
5850
|
+
throw error;
|
|
5851
|
+
}
|
|
5852
|
+
}
|
|
5853
|
+
}
|
|
5854
|
+
async function writeAttachmentObjectOnce(args) {
|
|
5855
|
+
const { file } = args;
|
|
5856
|
+
const expected = "data" in file ? file.data.byteLength : file.bytes;
|
|
5857
|
+
const source = "data" in file ? bufferBody(file.data) : await file.open();
|
|
5858
|
+
const hash = createHash("sha256");
|
|
5859
|
+
let bytes = 0;
|
|
5860
|
+
const body = source.pipeThrough(new TransformStream({ transform(chunk, controller) {
|
|
5861
|
+
bytes += chunk.byteLength;
|
|
5862
|
+
if (bytes > expected) throw new AttachmentSizeError(bytes, expected);
|
|
5863
|
+
hash.update(chunk);
|
|
5864
|
+
controller.enqueue(chunk);
|
|
5865
|
+
} }));
|
|
5866
|
+
try {
|
|
5867
|
+
await args.storage.put({
|
|
5868
|
+
body,
|
|
5869
|
+
bytes: expected,
|
|
5870
|
+
contentType: file.mimeType,
|
|
5871
|
+
key: args.key
|
|
5872
|
+
});
|
|
5873
|
+
} catch (error) {
|
|
5874
|
+
if (bytes > expected) throw new AttachmentSizeError(bytes, expected, { cause: error });
|
|
5875
|
+
throw error;
|
|
5876
|
+
}
|
|
5877
|
+
if (bytes !== expected) throw new AttachmentSizeError(bytes, expected);
|
|
5878
|
+
return {
|
|
5879
|
+
bytes,
|
|
5880
|
+
sha256: hash.digest("hex")
|
|
5881
|
+
};
|
|
5882
|
+
}
|
|
5792
5883
|
async function isConversationPurged(db, conversationId) {
|
|
5793
5884
|
const [row] = await db.db().select({ transcriptPurgedAt: juniorConversations.transcriptPurgedAt }).from(juniorConversations).where(eq(juniorConversations.conversationId, conversationId));
|
|
5794
5885
|
return row?.transcriptPurgedAt != null;
|
|
@@ -5821,7 +5912,8 @@ async function reuseLiveAttachment(args) {
|
|
|
5821
5912
|
/**
|
|
5822
5913
|
* Persist one conversation-owned file.
|
|
5823
5914
|
*
|
|
5824
|
-
* Identity is
|
|
5915
|
+
* Identity is stable under the conversation: it comes from the file's source
|
|
5916
|
+
* when it has one, and from its digest otherwise. Object storage is written
|
|
5825
5917
|
* first under a unique key; the SQL row is created only after that write
|
|
5826
5918
|
* succeeds. A row means the attachment is durable. Retries reuse an existing
|
|
5827
5919
|
* live row. A purge-marked row is revived by writing a new object and pointing
|
|
@@ -5832,14 +5924,14 @@ async function reuseLiveAttachment(args) {
|
|
|
5832
5924
|
*/
|
|
5833
5925
|
async function storeAttachment(args) {
|
|
5834
5926
|
const now = new Date(args.nowMs ?? Date.now());
|
|
5835
|
-
const
|
|
5927
|
+
const identity = attachmentIdentity(args.file);
|
|
5928
|
+
const source = args.file.source;
|
|
5836
5929
|
const id = attachmentId({
|
|
5837
5930
|
conversationId: args.conversationId,
|
|
5838
5931
|
contentType: args.file.mimeType,
|
|
5839
5932
|
filename: args.file.filename,
|
|
5840
|
-
|
|
5841
|
-
storageProvider: args.storage.provider
|
|
5842
|
-
sha256
|
|
5933
|
+
identity,
|
|
5934
|
+
storageProvider: args.storage.provider
|
|
5843
5935
|
});
|
|
5844
5936
|
const [existing] = await args.db.db().select({
|
|
5845
5937
|
contentType: juniorAttachments.contentType,
|
|
@@ -5854,24 +5946,33 @@ async function storeAttachment(args) {
|
|
|
5854
5946
|
storageKey: juniorAttachments.storageKey
|
|
5855
5947
|
}).from(juniorAttachments).where(eq(juniorAttachments.id, id));
|
|
5856
5948
|
if (existing) {
|
|
5857
|
-
if (existing.contentType !== args.file.mimeType || existing.conversationId !== args.conversationId || existing.filename !== args.file.filename || existing.provider !== (
|
|
5949
|
+
if (existing.contentType !== args.file.mimeType || existing.conversationId !== args.conversationId || existing.filename !== args.file.filename || existing.provider !== (source?.provider ?? null) || existing.providerId !== (source?.id ?? null) || existing.storageProvider !== args.storage.provider || "sha256" in identity && existing.sha256 !== identity.sha256) throw new Error(`Attachment write conflicts with ${existing.id}`);
|
|
5858
5950
|
if (existing.deleteRequestedAt === null) {
|
|
5859
5951
|
await assertConversationNotPurged(args.db, args.conversationId);
|
|
5860
5952
|
return { id: existing.id };
|
|
5861
5953
|
}
|
|
5862
5954
|
}
|
|
5863
5955
|
await assertConversationNotPurged(args.db, args.conversationId);
|
|
5864
|
-
const
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5956
|
+
const { file } = args;
|
|
5957
|
+
let storageKey = null;
|
|
5958
|
+
let written;
|
|
5959
|
+
if ("deferred" in file) written = {
|
|
5960
|
+
bytes: file.bytes,
|
|
5961
|
+
sha256: null
|
|
5962
|
+
};
|
|
5963
|
+
else {
|
|
5964
|
+
storageKey = attachmentKey({
|
|
5965
|
+
attachmentId: id,
|
|
5966
|
+
conversationId: args.conversationId,
|
|
5967
|
+
filename: file.filename,
|
|
5968
|
+
writeId: randomUUID()
|
|
5969
|
+
});
|
|
5970
|
+
written = await writeAttachmentObject({
|
|
5971
|
+
file,
|
|
5972
|
+
key: storageKey,
|
|
5973
|
+
storage: args.storage
|
|
5974
|
+
});
|
|
5975
|
+
}
|
|
5875
5976
|
if (existing?.deleteRequestedAt != null) {
|
|
5876
5977
|
if (await isConversationPurged(args.db, args.conversationId)) {
|
|
5877
5978
|
await bestEffortDelete(args.storage, storageKey);
|
|
@@ -5879,6 +5980,7 @@ async function storeAttachment(args) {
|
|
|
5879
5980
|
}
|
|
5880
5981
|
const oldStorageKey = existing.storageKey;
|
|
5881
5982
|
if ((await args.db.db().with(conversationDetailTouch(args.db.db(), [args.conversationId])).update(juniorAttachments).set({
|
|
5983
|
+
...written,
|
|
5882
5984
|
deleteRequestedAt: null,
|
|
5883
5985
|
storageKey
|
|
5884
5986
|
}).where(and(eq(juniorAttachments.id, id), isNotNull(juniorAttachments.deleteRequestedAt))).returning({ id: juniorAttachments.id })).length > 0) {
|
|
@@ -5913,12 +6015,11 @@ async function storeAttachment(args) {
|
|
|
5913
6015
|
conversationId: args.conversationId,
|
|
5914
6016
|
storageProvider: args.storage.provider,
|
|
5915
6017
|
storageKey,
|
|
5916
|
-
provider:
|
|
5917
|
-
providerId:
|
|
6018
|
+
provider: source?.provider,
|
|
6019
|
+
providerId: source?.id,
|
|
5918
6020
|
filename: args.file.filename,
|
|
5919
6021
|
contentType: args.file.mimeType,
|
|
5920
|
-
|
|
5921
|
-
sha256,
|
|
6022
|
+
...written,
|
|
5922
6023
|
createdAt: now
|
|
5923
6024
|
}).onConflictDoNothing({ target: juniorAttachments.id }).returning({ id: juniorAttachments.id });
|
|
5924
6025
|
} catch (error) {
|
|
@@ -5957,6 +6058,7 @@ async function storeAttachment(args) {
|
|
|
5957
6058
|
throw purgedConversationError(args.conversationId);
|
|
5958
6059
|
}
|
|
5959
6060
|
if ((await args.db.db().with(conversationDetailTouch(args.db.db(), [args.conversationId])).update(juniorAttachments).set({
|
|
6061
|
+
...written,
|
|
5960
6062
|
deleteRequestedAt: null,
|
|
5961
6063
|
storageKey
|
|
5962
6064
|
}).where(and(eq(juniorAttachments.id, id), isNotNull(juniorAttachments.deleteRequestedAt))).returning({ id: juniorAttachments.id })).length > 0) {
|
|
@@ -6017,6 +6119,8 @@ async function readLiveAttachment(args) {
|
|
|
6017
6119
|
deleteRequestedAt: juniorAttachments.deleteRequestedAt,
|
|
6018
6120
|
filename: juniorAttachments.filename,
|
|
6019
6121
|
id: juniorAttachments.id,
|
|
6122
|
+
provider: juniorAttachments.provider,
|
|
6123
|
+
providerId: juniorAttachments.providerId,
|
|
6020
6124
|
storageProvider: juniorAttachments.storageProvider,
|
|
6021
6125
|
storageKey: juniorAttachments.storageKey
|
|
6022
6126
|
}).from(juniorAttachments).where(and(eq(juniorAttachments.id, args.attachmentId), eq(juniorAttachments.conversationId, args.conversationId), isNull(juniorAttachments.deleteRequestedAt)));
|
|
@@ -6028,6 +6132,10 @@ async function readLiveAttachment(args) {
|
|
|
6028
6132
|
conversationId: row.conversationId,
|
|
6029
6133
|
filename: row.filename,
|
|
6030
6134
|
id: row.id,
|
|
6135
|
+
source: row.provider && row.providerId ? {
|
|
6136
|
+
id: row.providerId,
|
|
6137
|
+
provider: row.provider
|
|
6138
|
+
} : null,
|
|
6031
6139
|
storageKey: row.storageKey,
|
|
6032
6140
|
storageProvider: row.storageProvider
|
|
6033
6141
|
};
|
|
@@ -6038,7 +6146,11 @@ async function storeAttachments(args) {
|
|
|
6038
6146
|
for (const file of args.files) stored.push(await storeAttachment({
|
|
6039
6147
|
conversationId: args.conversationId,
|
|
6040
6148
|
db: args.db,
|
|
6041
|
-
file
|
|
6149
|
+
file: {
|
|
6150
|
+
data: file.data,
|
|
6151
|
+
filename: file.filename,
|
|
6152
|
+
mimeType: file.mimeType
|
|
6153
|
+
},
|
|
6042
6154
|
...args.nowMs !== void 0 ? { nowMs: args.nowMs } : void 0,
|
|
6043
6155
|
storage: args.storage
|
|
6044
6156
|
}));
|
|
@@ -6064,7 +6176,8 @@ async function collectAttachmentGarbage(args) {
|
|
|
6064
6176
|
storageKey: juniorAttachments.storageKey
|
|
6065
6177
|
}).from(juniorAttachments).innerJoin(juniorConversations, eq(juniorAttachments.conversationId, juniorConversations.conversationId)).where(and(eq(juniorAttachments.storageProvider, args.storage.provider), or(lte(juniorAttachments.createdAt, expiresBefore), isNotNull(juniorAttachments.deleteRequestedAt), isNotNull(juniorConversations.transcriptPurgedAt)))).orderBy(asc(juniorAttachments.createdAt), asc(juniorAttachments.id)).limit(args.limit ?? ATTACHMENT_GC_BATCH_LIMIT);
|
|
6066
6178
|
if (rows.length === 0) return { deleted: 0 };
|
|
6067
|
-
|
|
6179
|
+
const keys = rows.flatMap((row) => row.storageKey ? [row.storageKey] : []);
|
|
6180
|
+
if (keys.length > 0) await args.storage.delete(keys);
|
|
6068
6181
|
const stillEligible = await args.db.db().select({ id: juniorAttachments.id }).from(juniorAttachments).innerJoin(juniorConversations, eq(juniorAttachments.conversationId, juniorConversations.conversationId)).where(and(inArray(juniorAttachments.id, rows.map((row) => row.id)), or(lte(juniorAttachments.createdAt, expiresBefore), isNotNull(juniorAttachments.deleteRequestedAt), isNotNull(juniorConversations.transcriptPurgedAt))));
|
|
6069
6182
|
if (stillEligible.length === 0) return { deleted: 0 };
|
|
6070
6183
|
const removed = await args.db.db().delete(juniorAttachments).where(inArray(juniorAttachments.id, stillEligible.map((row) => row.id))).returning({ conversationId: juniorAttachments.conversationId });
|
|
@@ -6138,7 +6251,8 @@ async function writeAttachmentUpload(args) {
|
|
|
6138
6251
|
})) throw new AttachmentUploadError("Upload was already sent.");
|
|
6139
6252
|
if (args.body.byteLength !== row.bytes) throw new AttachmentUploadError("Upload size does not match the file.");
|
|
6140
6253
|
await args.storage.put({
|
|
6141
|
-
body: args.body,
|
|
6254
|
+
body: bufferBody(args.body),
|
|
6255
|
+
bytes: row.bytes,
|
|
6142
6256
|
contentType: row.contentType,
|
|
6143
6257
|
key: row.storageKey
|
|
6144
6258
|
});
|
|
@@ -6774,7 +6888,7 @@ function subjectInput(subject) {
|
|
|
6774
6888
|
/** Create the tool that adds a Review item or updates the open one. */
|
|
6775
6889
|
function createAddReviewItemTool(context, services) {
|
|
6776
6890
|
return zodTool({
|
|
6777
|
-
description: `Ask a person for input, or tell them about work that needs them. This is how you ask a person anything: the item goes on the review desk
|
|
6891
|
+
description: `Ask a person for input, or tell them about work that needs them. This is how you ask a person anything: the item goes on the review desk and, in a Slack thread, shows as a card with buttons. The answer arrives later as a \`<review-item-answer>\` with the item id. A dismiss sends you nothing. An assignee's thread reply that answers the item also closes it. If your next step needs the answer, end the Turn now with \`${NO_REPLY_TOOL_NAME}\` and no text: the card is your reply. Continue other work that does not need the answer.`,
|
|
6778
6892
|
annotations: {
|
|
6779
6893
|
destructiveHint: false,
|
|
6780
6894
|
idempotentHint: true,
|
|
@@ -6782,14 +6896,14 @@ function createAddReviewItemTool(context, services) {
|
|
|
6782
6896
|
readOnlyHint: false
|
|
6783
6897
|
},
|
|
6784
6898
|
inputSchema: z.object({
|
|
6785
|
-
kind: z.enum(["notice", "action"]),
|
|
6899
|
+
kind: z.enum(["notice", "action"]).describe("Use `action` with a `request` to ask. Use `notice` only to tell a person something."),
|
|
6786
6900
|
title: titleSchema,
|
|
6787
6901
|
body: bodySchema,
|
|
6788
|
-
assignees: assigneesSchema.nullable().optional().describe("Who can act on the item. Omit
|
|
6789
|
-
dedupe_key: z.string().trim().min(1).max(200).nullable().optional().describe("Stable key for what the item is about, such as `fair-source:entry:acme`. Use the same key on each run. Omit for a one-time question."),
|
|
6790
|
-
request: userInputRequestSchema.nullable().optional().describe("Required for an action item. Not allowed for a notice."),
|
|
6902
|
+
assignees: assigneesSchema.nullable().optional().describe("Who can act on the item. Omit for the person in this Turn, else the Automation creator in an Automation run, else the people still subscribed to the Conversation."),
|
|
6903
|
+
dedupe_key: z.string().trim().min(1).max(200).nullable().optional().describe("Stable key for what the item is about, such as `fair-source:entry:acme`. If an open item has this key, the call updates that item instead of adding another. Use the same key on each run. Omit for a one-time question."),
|
|
6904
|
+
request: userInputRequestSchema.nullable().optional().describe("Required for an action item. Not allowed for a notice. Ask for related input in one item. Write the question so it stands alone: a person who sees only the card must understand it."),
|
|
6791
6905
|
subject: subjectSchema.nullable().optional(),
|
|
6792
|
-
conversation_ids: conversationIdsSchema.nullable().optional().describe("Other Conversations to link.")
|
|
6906
|
+
conversation_ids: conversationIdsSchema.nullable().optional().describe("Other Conversations to link. The current Conversation is always linked.")
|
|
6793
6907
|
}).strict(),
|
|
6794
6908
|
outputSchema: juniorToolOutputSchema,
|
|
6795
6909
|
execute: async (input, options) => {
|
|
@@ -6882,7 +6996,7 @@ function createAddReviewItemTool(context, services) {
|
|
|
6882
6996
|
*/
|
|
6883
6997
|
function createUpdateReviewItemTool(context, services) {
|
|
6884
6998
|
return zodTool({
|
|
6885
|
-
description: "Change an open review desk item, or close it.
|
|
6999
|
+
description: "Change an open review desk item, or close it. An item also closes when a person answers or dismisses it, when a person's reply in its thread answers it, when its Conversation is purged, when its Automation is deleted, or when the plugin that added it closes it. You cannot submit the answer to an action item: only an assignee can.",
|
|
6886
7000
|
exposure: "deferred",
|
|
6887
7001
|
source: REVIEW_DESK_TOOL_SOURCE,
|
|
6888
7002
|
annotations: {
|
|
@@ -6897,7 +7011,7 @@ function createUpdateReviewItemTool(context, services) {
|
|
|
6897
7011
|
body: bodySchema.nullable().optional(),
|
|
6898
7012
|
assignees: assigneesSchema.nullable().optional().describe("Replaces every assignee."),
|
|
6899
7013
|
conversation_ids: conversationIdsSchema.nullable().optional().describe("Replaces every other linked Conversation. The Conversation that added the item stays linked."),
|
|
6900
|
-
status: z.enum(["done", "dismissed"]).nullable().optional(),
|
|
7014
|
+
status: z.enum(["done", "dismissed"]).nullable().optional().describe("Close the item, for example when its pull request merged."),
|
|
6901
7015
|
reason: z.string().trim().min(1).max(500).nullable().optional().describe("Why the item closed. Required with `status`.")
|
|
6902
7016
|
}).strict(),
|
|
6903
7017
|
outputSchema: juniorToolOutputSchema,
|
|
@@ -9241,14 +9355,14 @@ function createAutomationTool(context, catalog, skills = []) {
|
|
|
9241
9355
|
readOnlyHint: false
|
|
9242
9356
|
},
|
|
9243
9357
|
executionMode: "sequential",
|
|
9244
|
-
description: "Create a durable automation. It belongs to the channel or DM of this conversation, never a thread.
|
|
9358
|
+
description: "Create a durable automation. It belongs to the channel or DM of this conversation, never a thread. When an installed skill does the work, have the automation run that 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.",
|
|
9245
9359
|
inputSchema: z.object({
|
|
9246
9360
|
instruction: automationInstructionToolSchema.nullable().optional(),
|
|
9247
9361
|
skill: automationSkillToolSchema(skills).nullable().optional(),
|
|
9248
9362
|
context: automationContextToolSchema.nullable().optional(),
|
|
9249
9363
|
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(),
|
|
9250
|
-
trigger,
|
|
9251
|
-
outcomes: z.array(taskOutcomeInputSchema).max(5).describe("Successful work is silent by default
|
|
9364
|
+
trigger: trigger.describe("Use type \"schedule\" for one-time or recurring work. Use 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."),
|
|
9365
|
+
outcomes: z.array(taskOutcomeInputSchema).max(5).describe("Successful work is silent by default: omit this or use an empty list when the Automation acts 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(),
|
|
9252
9366
|
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()
|
|
9253
9367
|
}).strict(),
|
|
9254
9368
|
prepareArguments(args) {
|
|
@@ -9396,7 +9510,7 @@ function createSearchAutomationsTool(context, catalog) {
|
|
|
9396
9510
|
openWorldHint: false,
|
|
9397
9511
|
readOnlyHint: true
|
|
9398
9512
|
},
|
|
9399
|
-
description: "Search scheduled and event automations. It finds the requester's automations, automations in public channels, and automations that deliver to this conversation. Each result
|
|
9513
|
+
description: "Search scheduled and event automations. It finds the requester's automations, automations in public channels, and automations that deliver to this conversation. Each result says whether the requester is the creator (is_creator); only the creator can change its credential use. For an event automation, warn when trigger.available is false and explain trigger.problems: the automation stays stored, but a plugin no longer supports its resource type, an event, or a filter. Update the trigger to fix it.",
|
|
9400
9514
|
inputSchema: automationSearchInputSchema,
|
|
9401
9515
|
outputSchema: automationSearchResultSchema,
|
|
9402
9516
|
async execute(input) {
|
|
@@ -9576,7 +9690,7 @@ function createUpdateAutomationTool(context, catalog, skills = []) {
|
|
|
9576
9690
|
context: automationContextToolSchema.nullable().describe(`${automationContextToolSchema.description} Only for a skill Automation, or with skill. Use null to remove the context. Omit to keep it.`).optional(),
|
|
9577
9691
|
trigger: trigger.nullable().describe("Replacement trigger of the same type. For an event trigger, match changes only the filters that it names. Omit or use null to keep the trigger.").optional(),
|
|
9578
9692
|
outcomes: z.array(taskOutcomeInputSchema).max(5).nullable().describe("Replacement messages to send after successful work. Use an empty list to send nothing. Omit or use null to leave unchanged.").optional(),
|
|
9579
|
-
credential_mode: z.enum(["system", "creator"]).nullable().describe("Set creator to make the automation creator's credentials available, or system to disable them. Creator always means the automation's createdBy actor, never the current requester. Only that creator may enable creator mode. Omit or
|
|
9693
|
+
credential_mode: z.enum(["system", "creator"]).nullable().describe("Set creator to make the automation creator's credentials available, or system to disable them. Creator always means the automation's createdBy actor, never the current requester. Only that creator may enable creator mode. Omit or null leaves it unchanged.").optional(),
|
|
9580
9694
|
status: z.enum(["active", "paused"]).nullable().describe("Set active to resume a paused or blocked automation, or paused to stop it. When it uses its creator's credentials, only the creator can resume it. Omit or use null to leave unchanged.").optional(),
|
|
9581
9695
|
destination: slackChannelRefParam.nullable().describe("Where to move a scheduled automation. Set \"current_conversation\" for the channel or DM of this conversation, or name a public Slack channel by id, mention, or known name. Omit to keep its destination.").optional()
|
|
9582
9696
|
}).strict();
|
|
@@ -9591,7 +9705,7 @@ function createUpdateAutomationTool(context, catalog, skills = []) {
|
|
|
9591
9705
|
readOnlyHint: false
|
|
9592
9706
|
},
|
|
9593
9707
|
executionMode: "sequential",
|
|
9594
|
-
description: "Update the title, instruction or skill and its context, trigger, outcomes, credential use, or status of a scheduled or event automation. Anyone in the workspace can update anything on an automation in a public channel, including its outcomes and destination. Automations in private channels and DMs can be updated from there or by their creator
|
|
9708
|
+
description: "Update the title, instruction or skill and its context, trigger, outcomes, credential use, or status of a scheduled or event automation. Anyone in the workspace can update anything on an automation in a public channel, including its outcomes and destination. Automations in private channels and DMs can be updated from there or by their creator; only their creator can move them. A non-creator who changes the instruction, skill, context, trigger, outcomes, or destination switches it to system credentials.",
|
|
9595
9709
|
inputSchema,
|
|
9596
9710
|
prepareArguments(args) {
|
|
9597
9711
|
return Object.fromEntries(Object.entries(args).filter(([key, value]) => value !== void 0 && (value !== null || key === "context")));
|
|
@@ -9839,7 +9953,7 @@ function normalizeRangeTimestamp(field, value, targetChannelId) {
|
|
|
9839
9953
|
/** Create the channel history tool with optional cross-channel targets. */
|
|
9840
9954
|
function createSlackChannelListMessagesTool(context) {
|
|
9841
9955
|
return zodTool({
|
|
9842
|
-
description: "List messages from Slack channel history.
|
|
9956
|
+
description: "List messages from Slack channel history.",
|
|
9843
9957
|
annotations: {
|
|
9844
9958
|
destructiveHint: false,
|
|
9845
9959
|
idempotentHint: true,
|
|
@@ -9847,7 +9961,7 @@ function createSlackChannelListMessagesTool(context) {
|
|
|
9847
9961
|
readOnlyHint: true
|
|
9848
9962
|
},
|
|
9849
9963
|
inputSchema: z.object({
|
|
9850
|
-
channel_id: slackChannelRefParam.nullable().optional(),
|
|
9964
|
+
channel_id: slackChannelRefParam.nullable().describe("Omit to read the active channel. Another channel must be public.").optional(),
|
|
9851
9965
|
limit: z.coerce.number().int().min(1).max(1e3).describe("Maximum number of messages to return across pages.").nullable().optional(),
|
|
9852
9966
|
cursor: z.string().min(1).describe("Cursor from `next_cursor` in a prior result. Use null or omit it for the first page; never invent a cursor.").nullable().optional(),
|
|
9853
9967
|
oldest: slackTimestampParam("Oldest message timestamp (Slack ts) for range filtering.").nullable().optional(),
|
|
@@ -10127,7 +10241,7 @@ function createSearchConversationsTool(context) {
|
|
|
10127
10241
|
return zodTool({
|
|
10128
10242
|
exposure: "deferred",
|
|
10129
10243
|
source: CONVERSATIONS_TOOL_SOURCE,
|
|
10130
|
-
description: "Search other conversations for past or current work, with the summary, outcome, and links of their latest Brief. Finds conversations in public channels and in the same private channel or DM.
|
|
10244
|
+
description: "Search other conversations for past or current work, with the summary, outcome, and links of their latest Brief. Finds conversations in public channels and in the same private channel or DM. A root Brief covers the work of its child agents. Briefs remain after transcripts are purged.",
|
|
10131
10245
|
annotations: {
|
|
10132
10246
|
destructiveHint: false,
|
|
10133
10247
|
idempotentHint: true,
|
|
@@ -12692,7 +12806,7 @@ async function resolveStoredProvider(teamId, provider, query) {
|
|
|
12692
12806
|
/** Create the tool that resolves people by identity provider and query. */
|
|
12693
12807
|
function createUserLookupTool(teamId, providers) {
|
|
12694
12808
|
return zodTool({
|
|
12695
|
-
description: "Look up people by identity provider and query.
|
|
12809
|
+
description: "Look up people by identity provider and query. Name search can miss people in large workspaces. Returns Slack `mention` values (`<@U…>`) for the current workspace. Slack results also list `linked_identities`: verified handles of other accounts the person linked to you, such as `github`. Use a mention or handle only when one person clearly matches; otherwise ask which person the user means.",
|
|
12696
12810
|
annotations: {
|
|
12697
12811
|
destructiveHint: false,
|
|
12698
12812
|
idempotentHint: true,
|
|
@@ -12701,7 +12815,7 @@ function createUserLookupTool(teamId, providers) {
|
|
|
12701
12815
|
},
|
|
12702
12816
|
inputSchema: z.object({
|
|
12703
12817
|
provider: z.enum(providers).describe("Enabled identity provider to query."),
|
|
12704
|
-
query: z.string().trim().min(1).describe("Provider subject ID, handle, Slack email, or Slack name.
|
|
12818
|
+
query: z.string().trim().min(1).describe("Provider subject ID, handle, Slack email, or Slack name. For Slack, pass the user ID (`U…`) whenever the conversation shows one, such as the requester's `author_id`, a participant's `actor_id`, or a `<@U…>` mention. Search by name only with no known ID.")
|
|
12705
12819
|
}).strict(),
|
|
12706
12820
|
outputSchema: juniorToolOutputSchema,
|
|
12707
12821
|
execute: async ({ provider, query }) => {
|
|
@@ -13090,7 +13204,8 @@ async function publishImage(args) {
|
|
|
13090
13204
|
const id = existing?.id ?? randomUUID();
|
|
13091
13205
|
const storageKey = artifactKey(`${id}.${extension}`);
|
|
13092
13206
|
await args.storage.put({
|
|
13093
|
-
body: args.body,
|
|
13207
|
+
body: bufferBody(args.body),
|
|
13208
|
+
bytes: args.body.byteLength,
|
|
13094
13209
|
contentType,
|
|
13095
13210
|
key: storageKey
|
|
13096
13211
|
});
|
|
@@ -13248,29 +13363,138 @@ function createUnpublishImageTool(args) {
|
|
|
13248
13363
|
}
|
|
13249
13364
|
});
|
|
13250
13365
|
}
|
|
13366
|
+
// src/chat/attachments/download.ts
|
|
13367
|
+
/** Refusal for a file over `MAX_ATTACHMENT_BYTES`. */
|
|
13368
|
+
const ATTACHMENT_TOO_LARGE_MESSAGE = `Attachment is larger than the ${MAX_ATTACHMENT_BYTES / 1024 / 1024} MB file limit.`;
|
|
13369
|
+
/** An attachment whose bytes cannot be read. The message is safe to show. */
|
|
13370
|
+
var AttachmentDownloadError = class extends Error {
|
|
13371
|
+
constructor(message, options) {
|
|
13372
|
+
super(message, options);
|
|
13373
|
+
this.name = "AttachmentDownloadError";
|
|
13374
|
+
}
|
|
13375
|
+
};
|
|
13376
|
+
/**
|
|
13377
|
+
* Find where the bytes of one attachment row are, without reading them.
|
|
13378
|
+
*
|
|
13379
|
+
* A stored file reads from storage. A large Slack file is never stored, so
|
|
13380
|
+
* each `open` downloads it from its source. The source reports the current
|
|
13381
|
+
* size, and the size check runs before any download. Errors that the person
|
|
13382
|
+
* should see are `AttachmentDownloadError`, from here or from `open`.
|
|
13383
|
+
*
|
|
13384
|
+
* The row must come from a lookup scoped to the caller's conversation. The
|
|
13385
|
+
* source id comes from that row only, never from a request.
|
|
13386
|
+
*/
|
|
13387
|
+
async function readAttachmentContent(args) {
|
|
13388
|
+
const { attachment, storage } = args;
|
|
13389
|
+
const { storageKey } = attachment;
|
|
13390
|
+
if (storageKey !== null) return {
|
|
13391
|
+
bytes: attachment.bytes,
|
|
13392
|
+
open: async () => {
|
|
13393
|
+
const body = await storage.get(storageKey);
|
|
13394
|
+
if (!body) throw new AttachmentDownloadError("Stored attachment contents are unavailable.");
|
|
13395
|
+
return body;
|
|
13396
|
+
}
|
|
13397
|
+
};
|
|
13398
|
+
const { source } = attachment;
|
|
13399
|
+
if (!source || !args.readAttachmentSource) throw new AttachmentDownloadError("Attachment cannot be downloaded from this conversation.");
|
|
13400
|
+
const unavailable = (error) => error instanceof AttachmentSourceUnavailableError ? new AttachmentDownloadError(`${attachment.filename} is no longer available: ${error.message}`, { cause: error }) : error;
|
|
13401
|
+
let file;
|
|
13402
|
+
try {
|
|
13403
|
+
file = await args.readAttachmentSource(source);
|
|
13404
|
+
} catch (error) {
|
|
13405
|
+
throw unavailable(error);
|
|
13406
|
+
}
|
|
13407
|
+
if (file.bytes > 262144e3) throw new AttachmentDownloadError(ATTACHMENT_TOO_LARGE_MESSAGE);
|
|
13408
|
+
return {
|
|
13409
|
+
bytes: file.bytes,
|
|
13410
|
+
open: async () => {
|
|
13411
|
+
try {
|
|
13412
|
+
return await file.open();
|
|
13413
|
+
} catch (error) {
|
|
13414
|
+
throw unavailable(error);
|
|
13415
|
+
}
|
|
13416
|
+
}
|
|
13417
|
+
};
|
|
13418
|
+
}
|
|
13251
13419
|
// src/chat/tools/load-attachment.ts
|
|
13252
13420
|
const ATTACHMENT_DIR = ".junior/attachments";
|
|
13253
|
-
|
|
13254
|
-
|
|
13255
|
-
|
|
13256
|
-
|
|
13257
|
-
|
|
13258
|
-
|
|
13259
|
-
|
|
13421
|
+
/** Bytes held in memory and sent to the sandbox in one write. */
|
|
13422
|
+
const PART_BYTES = 8388608;
|
|
13423
|
+
const JOIN_PARTS_SCRIPT = "set -eu; out=$1; shift; cat -- \"$@\" > \"$out\"";
|
|
13424
|
+
/** Turn a read failure that the model can relay into a tool error. */
|
|
13425
|
+
function toolError(error) {
|
|
13426
|
+
return error instanceof AttachmentDownloadError ? new ToolInputError(error.message, { cause: error }) : error;
|
|
13427
|
+
}
|
|
13428
|
+
/** Run one sandbox command, and return its stdout. Throw when it fails. */
|
|
13429
|
+
async function runChecked(workspace, action, input) {
|
|
13430
|
+
const result = await workspace.runCommand(input);
|
|
13431
|
+
if (result.exitCode !== 0) throw new Error(`Failed to ${action}: ${result.stderr}`);
|
|
13432
|
+
return result.stdout;
|
|
13433
|
+
}
|
|
13434
|
+
/**
|
|
13435
|
+
* Write an attachment body to the sandbox in parts of at most `PART_BYTES`.
|
|
13436
|
+
*
|
|
13437
|
+
* The sandbox SDK writes only whole buffers, so this keeps one part in
|
|
13438
|
+
* memory, not the file. Returns the part paths in order.
|
|
13439
|
+
*/
|
|
13440
|
+
async function writeParts(args) {
|
|
13441
|
+
const parts = [];
|
|
13442
|
+
let pending = [];
|
|
13443
|
+
let pendingBytes = 0;
|
|
13444
|
+
let total = 0;
|
|
13445
|
+
const flush = async () => {
|
|
13446
|
+
const partPath = path.posix.join(args.partsDir, String(parts.length).padStart(4, "0"));
|
|
13447
|
+
await args.workspace.writeFiles([{
|
|
13448
|
+
content: Buffer.concat(pending),
|
|
13449
|
+
path: partPath
|
|
13450
|
+
}]);
|
|
13451
|
+
parts.push(partPath);
|
|
13452
|
+
pending = [];
|
|
13453
|
+
pendingBytes = 0;
|
|
13454
|
+
};
|
|
13455
|
+
const reader = args.body.getReader();
|
|
13456
|
+
try {
|
|
13457
|
+
for (;;) {
|
|
13458
|
+
const { done, value } = await reader.read();
|
|
13459
|
+
if (done) break;
|
|
13460
|
+
total += value.byteLength;
|
|
13461
|
+
if (total > args.expectedBytes) break;
|
|
13462
|
+
let chunk = value;
|
|
13463
|
+
while (pendingBytes + chunk.byteLength >= PART_BYTES) {
|
|
13464
|
+
const take = PART_BYTES - pendingBytes;
|
|
13465
|
+
pending.push(chunk.subarray(0, take));
|
|
13466
|
+
pendingBytes += take;
|
|
13467
|
+
await flush();
|
|
13468
|
+
chunk = chunk.subarray(take);
|
|
13469
|
+
}
|
|
13470
|
+
if (chunk.byteLength > 0) {
|
|
13471
|
+
pending.push(chunk);
|
|
13472
|
+
pendingBytes += chunk.byteLength;
|
|
13473
|
+
}
|
|
13474
|
+
}
|
|
13475
|
+
} finally {
|
|
13476
|
+
await reader.cancel().catch(() => void 0);
|
|
13260
13477
|
}
|
|
13261
|
-
|
|
13478
|
+
if (total !== args.expectedBytes) throw new Error(`Attachment ${args.attachmentId} read ${total} bytes, expected ${args.expectedBytes}.`);
|
|
13479
|
+
if (pendingBytes > 0 || parts.length === 0) await flush();
|
|
13480
|
+
return parts;
|
|
13262
13481
|
}
|
|
13263
|
-
/**
|
|
13482
|
+
/**
|
|
13483
|
+
* Create a tool that restores one conversation attachment to the sandbox.
|
|
13484
|
+
*
|
|
13485
|
+
* A large Slack file is never stored: each load streams it from Slack
|
|
13486
|
+
* through the host. The sandbox never gets a Slack URL or token.
|
|
13487
|
+
*/
|
|
13264
13488
|
function createLoadAttachmentTool(args) {
|
|
13265
13489
|
return zodTool({
|
|
13266
|
-
description: "Load a stored attachment for this conversation into the sandbox.
|
|
13490
|
+
description: "Load a stored attachment for this conversation into the sandbox.",
|
|
13267
13491
|
annotations: {
|
|
13268
13492
|
destructiveHint: false,
|
|
13269
13493
|
idempotentHint: true,
|
|
13270
|
-
openWorldHint:
|
|
13494
|
+
openWorldHint: true,
|
|
13271
13495
|
readOnlyHint: false
|
|
13272
13496
|
},
|
|
13273
|
-
inputSchema: z.object({ attachment_id: z.string().min(1).describe("Stored attachment ID.") }),
|
|
13497
|
+
inputSchema: z.object({ attachment_id: z.string().min(1).describe("Stored attachment ID, as shown in attachment context or Slack read results.") }),
|
|
13274
13498
|
outputSchema: juniorToolOutputSchema,
|
|
13275
13499
|
execute: async ({ attachment_id }) => {
|
|
13276
13500
|
const attachment = await readLiveAttachment({
|
|
@@ -13279,26 +13503,92 @@ function createLoadAttachmentTool(args) {
|
|
|
13279
13503
|
db: args.db
|
|
13280
13504
|
});
|
|
13281
13505
|
if (!attachment || attachment.storageProvider !== args.storage.provider) throw new ToolInputError("Attachment not found in this conversation.");
|
|
13282
|
-
|
|
13283
|
-
|
|
13284
|
-
|
|
13285
|
-
|
|
13506
|
+
if (attachment.bytes > 262144e3) throw new ToolInputError(ATTACHMENT_TOO_LARGE_MESSAGE);
|
|
13507
|
+
let content;
|
|
13508
|
+
try {
|
|
13509
|
+
content = await readAttachmentContent({
|
|
13510
|
+
attachment,
|
|
13511
|
+
readAttachmentSource: args.readAttachmentSource,
|
|
13512
|
+
storage: args.storage
|
|
13513
|
+
});
|
|
13514
|
+
} catch (error) {
|
|
13515
|
+
throw toolError(error);
|
|
13516
|
+
}
|
|
13286
13517
|
const attachmentDir = path.posix.join(ATTACHMENT_DIR, attachment.id);
|
|
13518
|
+
const partsDir = `${attachmentDir}.parts`;
|
|
13287
13519
|
const sandboxPath = path.posix.join(attachmentDir, path.posix.basename(attachment.filename));
|
|
13288
|
-
|
|
13520
|
+
await runChecked(args.workspace, "create attachment directory", {
|
|
13289
13521
|
cmd: "mkdir",
|
|
13290
|
-
args: [
|
|
13522
|
+
args: [
|
|
13523
|
+
"-p",
|
|
13524
|
+
"--",
|
|
13525
|
+
attachmentDir,
|
|
13526
|
+
partsDir
|
|
13527
|
+
]
|
|
13528
|
+
});
|
|
13529
|
+
const joinedPath = path.posix.join(partsDir, "joined");
|
|
13530
|
+
try {
|
|
13531
|
+
const parts = await writeParts({
|
|
13532
|
+
attachmentId: attachment.id,
|
|
13533
|
+
body: await content.open(),
|
|
13534
|
+
expectedBytes: content.bytes,
|
|
13535
|
+
partsDir,
|
|
13536
|
+
workspace: args.workspace
|
|
13537
|
+
});
|
|
13538
|
+
await runChecked(args.workspace, "join attachment parts", {
|
|
13539
|
+
cmd: "sh",
|
|
13540
|
+
args: [
|
|
13541
|
+
"-c",
|
|
13542
|
+
JOIN_PARTS_SCRIPT,
|
|
13543
|
+
"sh",
|
|
13544
|
+
joinedPath,
|
|
13545
|
+
...parts
|
|
13546
|
+
]
|
|
13547
|
+
});
|
|
13548
|
+
const size = await runChecked(args.workspace, "read attachment size", {
|
|
13549
|
+
cmd: "stat",
|
|
13550
|
+
args: [
|
|
13551
|
+
"-c",
|
|
13552
|
+
"%s",
|
|
13553
|
+
"--",
|
|
13554
|
+
joinedPath
|
|
13555
|
+
]
|
|
13556
|
+
});
|
|
13557
|
+
const written = Number(size.trim());
|
|
13558
|
+
if (written !== content.bytes) throw new Error(`Attachment ${attachment.id} wrote ${written} bytes to the sandbox, expected ${content.bytes}.`);
|
|
13559
|
+
await runChecked(args.workspace, "move attachment into place", {
|
|
13560
|
+
cmd: "mv",
|
|
13561
|
+
args: [
|
|
13562
|
+
"-f",
|
|
13563
|
+
"--",
|
|
13564
|
+
joinedPath,
|
|
13565
|
+
sandboxPath
|
|
13566
|
+
]
|
|
13567
|
+
});
|
|
13568
|
+
} catch (error) {
|
|
13569
|
+
await args.workspace.runCommand({
|
|
13570
|
+
cmd: "rm",
|
|
13571
|
+
args: [
|
|
13572
|
+
"-rf",
|
|
13573
|
+
"--",
|
|
13574
|
+
partsDir
|
|
13575
|
+
]
|
|
13576
|
+
}).catch(() => void 0);
|
|
13577
|
+
throw toolError(error);
|
|
13578
|
+
}
|
|
13579
|
+
await runChecked(args.workspace, "remove attachment parts", {
|
|
13580
|
+
cmd: "rm",
|
|
13581
|
+
args: [
|
|
13582
|
+
"-rf",
|
|
13583
|
+
"--",
|
|
13584
|
+
partsDir
|
|
13585
|
+
]
|
|
13291
13586
|
});
|
|
13292
|
-
if (mkdir.exitCode !== 0) throw new Error(`Failed to create attachment directory: ${mkdir.stderr}`);
|
|
13293
|
-
await args.workspace.writeFiles([{
|
|
13294
|
-
content: data,
|
|
13295
|
-
path: sandboxPath
|
|
13296
|
-
}]);
|
|
13297
13587
|
return {
|
|
13298
13588
|
path: sandboxPath,
|
|
13299
13589
|
filename: attachment.filename,
|
|
13300
13590
|
mime_type: attachment.contentType,
|
|
13301
|
-
bytes:
|
|
13591
|
+
bytes: content.bytes
|
|
13302
13592
|
};
|
|
13303
13593
|
}
|
|
13304
13594
|
});
|
|
@@ -14437,6 +14727,7 @@ function createTools(availableSkills, hooks = {}, context, options = {}) {
|
|
|
14437
14727
|
tools.loadAttachment = createLoadAttachmentTool({
|
|
14438
14728
|
conversationId: context.conversationId,
|
|
14439
14729
|
db: getSqlExecutor(),
|
|
14730
|
+
...slackContext ? { readAttachmentSource: readSlackAttachmentSource } : void 0,
|
|
14440
14731
|
storage: context.attachmentStorage,
|
|
14441
14732
|
workspace: context.workspace
|
|
14442
14733
|
});
|
|
@@ -15203,7 +15494,7 @@ function createExecuteToolTool() {
|
|
|
15203
15494
|
openWorldHint: true,
|
|
15204
15495
|
readOnlyHint: false
|
|
15205
15496
|
},
|
|
15206
|
-
description: "Execute a catalog tool by exact
|
|
15497
|
+
description: "Execute a catalog tool by its exact name. Use it for a tool that is not in your tool list: one that searchTools returned, or one that a skill, tool result, or error names. Put tool-specific parameters inside arguments.",
|
|
15207
15498
|
executionMode: "sequential",
|
|
15208
15499
|
exposure: "modelOnly",
|
|
15209
15500
|
inputSchema: z.object({
|
|
@@ -16277,9 +16568,8 @@ function renderScriptTools(tools) {
|
|
|
16277
16568
|
].join("\n");
|
|
16278
16569
|
}
|
|
16279
16570
|
const DESCRIPTION = [
|
|
16280
|
-
"Run a JavaScript script that calls other tools, and get back only what the script returns or prints.
|
|
16571
|
+
"Run a JavaScript script that calls other tools, and get back only what the script returns or prints.",
|
|
16281
16572
|
"",
|
|
16282
|
-
"The code is the body of an async function: top-level `await` and `return` work. It runs in a QuickJS VM with no Node, file system, network, or timers.",
|
|
16283
16573
|
"- `await tools.<name>(args)` runs one tool through the normal tool path, including action review. It resolves to the tool result, and rejects with an Error when the call fails or action review rejects it.",
|
|
16284
16574
|
"- Arguments and results must be JSON-serializable.",
|
|
16285
16575
|
"- Run calls at the same time (`Promise.all`) only when they do not depend on each other. Await a call before a call that needs its result. Run calls that change the same thing one after another.",
|
|
@@ -16321,7 +16611,7 @@ function createCodeModeTool(options) {
|
|
|
16321
16611
|
description: DESCRIPTION,
|
|
16322
16612
|
executionMode: "sequential",
|
|
16323
16613
|
exposure: "modelOnly",
|
|
16324
|
-
inputSchema: z.object({ code: z.string().min(1).describe("JavaScript source: the body of an async function. Raw code, not JSON and not in a code fence.") }).strict(),
|
|
16614
|
+
inputSchema: z.object({ code: z.string().min(1).describe("JavaScript source: the body of an async function, so top-level `await` and `return` work. Raw code, not JSON and not in a code fence. It runs in a QuickJS VM with no Node, file system, network, or timers.") }).strict(),
|
|
16325
16615
|
outputSchema: juniorToolOutputSchema,
|
|
16326
16616
|
execute: async ({ code }, { signal, toolCallId }) => {
|
|
16327
16617
|
if (!toolCallId) throw new Error("codemode requires a tool call id.");
|
|
@@ -18900,7 +19190,7 @@ function waitsForUse(event, nowMs) {
|
|
|
18900
19190
|
*/
|
|
18901
19191
|
async function requestBackgroundCompaction(args) {
|
|
18902
19192
|
if (!args.queue) return;
|
|
18903
|
-
const inputSize = lastRequestInputSize(args.agent.state.messages);
|
|
19193
|
+
const inputSize = lastRequestInputSize(readAgentHistory(args.agent.state.messages));
|
|
18904
19194
|
if (inputSize === void 0 || inputSize < getAgentBackgroundCompactionMarkTokens(args.modelId)) return;
|
|
18905
19195
|
try {
|
|
18906
19196
|
await requestAboveMark({
|
|
@@ -20284,7 +20574,10 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20284
20574
|
const terminatingToolCallIds = /* @__PURE__ */ new Set();
|
|
20285
20575
|
let discardedRetryUsage;
|
|
20286
20576
|
const turnLimitGate = createTurnLimitGate(runResume.turnLimitWrappedUp);
|
|
20287
|
-
const currentAgentMessages = () => agent ?
|
|
20577
|
+
const currentAgentMessages = () => agent ? readAgentHistory(agent.state.messages) : [];
|
|
20578
|
+
const setAgentHistory = (messages) => {
|
|
20579
|
+
agent.state.messages = writeAgentHistory(agent.state.messages, messages);
|
|
20580
|
+
};
|
|
20288
20581
|
const usageSinceCurrentBoundary = (messages) => {
|
|
20289
20582
|
const usage = extractGenAiUsageSummary(...messages.slice(runResume.beforeMessageCount).filter(isAssistantMessage));
|
|
20290
20583
|
return hasAgentTurnUsage(usage) ? usage : void 0;
|
|
@@ -20379,7 +20672,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20379
20672
|
restoredMessages: existingSessionRecord?.piMessages,
|
|
20380
20673
|
restoredProvenance: existingSessionRecord?.piMessageProvenance,
|
|
20381
20674
|
setMessages(messages) {
|
|
20382
|
-
|
|
20675
|
+
setAgentHistory(messages);
|
|
20383
20676
|
},
|
|
20384
20677
|
shouldPromptAgent
|
|
20385
20678
|
});
|
|
@@ -20390,7 +20683,10 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20390
20683
|
...streamFn ? { base: streamFn } : void 0
|
|
20391
20684
|
});
|
|
20392
20685
|
const nextInputAfterReplacement = createNextInputTracker();
|
|
20393
|
-
/**
|
|
20686
|
+
/**
|
|
20687
|
+
* Commit and adopt an active capacity replacement. True when it replaced
|
|
20688
|
+
* history.
|
|
20689
|
+
*/
|
|
20394
20690
|
const applyActiveContextCompaction = async (messages, hookSignal, pendingMessages, clearSteeringQueueOnCommit = false, pairPendingRuntimeContext = false, mode = "active") => {
|
|
20395
20691
|
const compaction = await compactWithPreparedSummary({
|
|
20396
20692
|
conversationId,
|
|
@@ -20404,7 +20700,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20404
20700
|
signal: hookSignal,
|
|
20405
20701
|
turnStartMessageIndex: runResume.turnStartMessageIndex
|
|
20406
20702
|
}, async (summaryMessages, summarySignal) => await requestContextSummary(await buildAgentModelRequest(agent, summaryMessages, summarySignal), summaryStreamFn));
|
|
20407
|
-
if (!compaction.compacted || !compaction.piMessages) return;
|
|
20703
|
+
if (!compaction.compacted || !compaction.piMessages) return false;
|
|
20408
20704
|
priorPhaseUsage = addAgentTurnUsage(priorPhaseUsage, usageSinceCurrentBoundary(messages));
|
|
20409
20705
|
const replacement = [...compaction.piMessages];
|
|
20410
20706
|
const previousTurnStartMessageIndex = runResume.turnStartMessageIndex;
|
|
@@ -20415,16 +20711,12 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20415
20711
|
runResume.setTurnStartMessageIndex(previousTurnStartMessageIndex);
|
|
20416
20712
|
throw error;
|
|
20417
20713
|
}
|
|
20418
|
-
|
|
20714
|
+
setAgentHistory(replacement);
|
|
20419
20715
|
nextInputAfterReplacement.replaced(mode, getAgentContextCompactionTriggerTokens(activeModelId));
|
|
20420
20716
|
runResume.setBeforeMessageCount(replacement.length);
|
|
20421
20717
|
runResume.adoptCommittedBoundary(replacement);
|
|
20422
20718
|
if (clearSteeringQueueOnCommit && pendingMessages?.length) agent.clearSteeringQueue();
|
|
20423
|
-
return
|
|
20424
|
-
systemPrompt: baseInstructions,
|
|
20425
|
-
messages: replacement,
|
|
20426
|
-
tools: agent.state.tools
|
|
20427
|
-
} };
|
|
20719
|
+
return true;
|
|
20428
20720
|
};
|
|
20429
20721
|
/**
|
|
20430
20722
|
* Request a background summary when the model call that just ended was at
|
|
@@ -20459,7 +20751,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20459
20751
|
await durability.drainSteeringMessages(async (messages) => {
|
|
20460
20752
|
const piMessages = messages.map(buildSteeringPiMessage);
|
|
20461
20753
|
if (piMessages.length === 0) return;
|
|
20462
|
-
await runResume.requireDurableInputCheckpoint([...
|
|
20754
|
+
await runResume.requireDurableInputCheckpoint([...currentAgentMessages(), ...piMessages], messages.map((message) => message.provenance));
|
|
20463
20755
|
committedInstructionProvenance.push(...messages.map((message) => message.provenance));
|
|
20464
20756
|
for (const message of messages) {
|
|
20465
20757
|
const text = message.text.trim();
|
|
@@ -20485,13 +20777,52 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20485
20777
|
});
|
|
20486
20778
|
const toolBatchStats = createToolBatchStats();
|
|
20487
20779
|
let setAgentSpanAttributes;
|
|
20780
|
+
let messagesChanged = false;
|
|
20781
|
+
/**
|
|
20782
|
+
* Do Junior's work after a model call and its tool batch, before Pi polls
|
|
20783
|
+
* steering. Pi awaits this listener after every model call. Pi turns its
|
|
20784
|
+
* errors into error turns, so the caller keeps them for the step.
|
|
20785
|
+
*/
|
|
20786
|
+
const finishModelStep = async (event, runSignal) => {
|
|
20787
|
+
if (event.toolResults.length > 0) {
|
|
20788
|
+
cacheWarming.toolsReturned();
|
|
20789
|
+
await requireConversationLease("save");
|
|
20790
|
+
await runResume.persistSafeBoundary(currentAgentMessages());
|
|
20791
|
+
}
|
|
20792
|
+
if (runSignal?.aborted || isAssistantMessage(event.message) && (event.message.stopReason === "error" || event.message.stopReason === "aborted")) return;
|
|
20793
|
+
await durability.checkStop?.();
|
|
20794
|
+
signal?.throwIfAborted();
|
|
20795
|
+
const boundary = await withSpan("agent.step.prepare", "agent.step.prepare", {}, async () => {
|
|
20796
|
+
const contextUpdated = await repositoryInstructionsContext.applyUpdate(currentAgentMessages());
|
|
20797
|
+
const pendingMessages = await drainSteeringMessages();
|
|
20798
|
+
const runEnded = pendingMessages.length === 0 && event.toolResults.every((result) => terminatingToolCallIds.has(result.toolCallId));
|
|
20799
|
+
if (runEnded) await requestBackgroundCompactionAfterModelCall();
|
|
20800
|
+
return {
|
|
20801
|
+
contextUpdated,
|
|
20802
|
+
pendingMessages,
|
|
20803
|
+
runEnded
|
|
20804
|
+
};
|
|
20805
|
+
});
|
|
20806
|
+
messagesChanged = boundary.contextUpdated;
|
|
20807
|
+
const yieldError = runResume.prepareYieldIfDue(currentAgentMessages());
|
|
20808
|
+
if (yieldError) throw yieldError;
|
|
20809
|
+
if (boundary.runEnded) return;
|
|
20810
|
+
if (await applyActiveContextCompaction(currentAgentMessages(), runSignal, boundary.pendingMessages, true)) {
|
|
20811
|
+
messagesChanged = true;
|
|
20812
|
+
return;
|
|
20813
|
+
}
|
|
20814
|
+
await requestBackgroundCompactionAfterModelCall();
|
|
20815
|
+
};
|
|
20488
20816
|
agent = new Agent({
|
|
20489
20817
|
getApiKey: getGatewayApiKey,
|
|
20490
20818
|
sessionId: conversationId,
|
|
20491
|
-
streamFn: createTracedStreamFn({
|
|
20819
|
+
streamFn: withAgentRequest(createTracedStreamFn({
|
|
20492
20820
|
conversationPrivacy,
|
|
20493
20821
|
base: cacheWarming.wrap(streamFn),
|
|
20494
20822
|
endAttributes: (message) => nextInputAfterReplacement.attributes(lastRequestInputSize([message]))
|
|
20823
|
+
}), {
|
|
20824
|
+
systemPrompt: baseInstructions,
|
|
20825
|
+
tools: wiring.agentTools
|
|
20495
20826
|
}),
|
|
20496
20827
|
steeringMode: "all",
|
|
20497
20828
|
beforeToolCall: async ({ assistantMessage, context, toolCall }) => {
|
|
@@ -20557,32 +20888,13 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20557
20888
|
}
|
|
20558
20889
|
return override;
|
|
20559
20890
|
},
|
|
20560
|
-
prepareNextTurnWithContext: async (nextTurn
|
|
20561
|
-
|
|
20562
|
-
|
|
20563
|
-
|
|
20564
|
-
|
|
20565
|
-
|
|
20566
|
-
|
|
20567
|
-
const pendingMessages = await drainSteeringMessages();
|
|
20568
|
-
if (nextTurn.toolResults.every((result) => terminatingToolCallIds.has(result.toolCallId)) && pendingMessages.length === 0) {
|
|
20569
|
-
await requestBackgroundCompactionAfterModelCall();
|
|
20570
|
-
return contextUpdate;
|
|
20571
|
-
}
|
|
20572
|
-
const capacityUpdate = await applyActiveContextCompaction(contextUpdate ? currentAgentMessages() : nextTurn.context.messages, hookSignal, pendingMessages, true);
|
|
20573
|
-
if (!capacityUpdate) await requestBackgroundCompactionAfterModelCall();
|
|
20574
|
-
return capacityUpdate ? {
|
|
20575
|
-
...contextUpdate,
|
|
20576
|
-
...capacityUpdate
|
|
20577
|
-
} : contextUpdate;
|
|
20578
|
-
});
|
|
20579
|
-
const yieldError = runResume.prepareYieldIfDue(currentAgentMessages());
|
|
20580
|
-
if (yieldError) throw yieldError;
|
|
20581
|
-
return stepUpdate;
|
|
20582
|
-
} catch (error) {
|
|
20583
|
-
pendingPiHookError ??= error instanceof Error ? error : new Error(String(error));
|
|
20584
|
-
throw error;
|
|
20585
|
-
}
|
|
20891
|
+
prepareNextTurnWithContext: async (nextTurn) => {
|
|
20892
|
+
if (!messagesChanged) return;
|
|
20893
|
+
messagesChanged = false;
|
|
20894
|
+
return { context: {
|
|
20895
|
+
...nextTurn.context,
|
|
20896
|
+
messages: writeAgentHistory(nextTurn.context.messages, currentAgentMessages())
|
|
20897
|
+
} };
|
|
20586
20898
|
},
|
|
20587
20899
|
initialState: {
|
|
20588
20900
|
systemPrompt: baseInstructions,
|
|
@@ -20591,15 +20903,12 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20591
20903
|
tools: wiring.agentTools
|
|
20592
20904
|
}
|
|
20593
20905
|
});
|
|
20594
|
-
const unsubscribe = agent.subscribe((event) => {
|
|
20906
|
+
const unsubscribe = agent.subscribe((event, runSignal) => {
|
|
20595
20907
|
if (event.type === "tool_execution_start") return recordParentToolExecutionStart(event);
|
|
20596
|
-
if (event.type === "turn_end"
|
|
20597
|
-
|
|
20598
|
-
|
|
20599
|
-
|
|
20600
|
-
throw error;
|
|
20601
|
-
});
|
|
20602
|
-
}
|
|
20908
|
+
if (event.type === "turn_end") return finishModelStep(event, runSignal).catch((error) => {
|
|
20909
|
+
pendingPiHookError ??= error instanceof Error ? error : new Error(String(error));
|
|
20910
|
+
throw error;
|
|
20911
|
+
});
|
|
20603
20912
|
if (event.type === "message_end" && isAssistantMessage(event.message)) {
|
|
20604
20913
|
const message = event.message;
|
|
20605
20914
|
const delivery = message.stopReason === "error" || message.stopReason === "aborted" ? void 0 : deliverAssistantMessage(message);
|
|
@@ -20611,15 +20920,15 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20611
20920
|
});
|
|
20612
20921
|
let newMessages = [];
|
|
20613
20922
|
const turnStartIndex = () => existingSessionRecord?.turnStartMessageIndex ?? runResume.turnStartMessageIndex ?? runResume.beforeMessageCount;
|
|
20614
|
-
const turnMessages = () =>
|
|
20923
|
+
const turnMessages = () => currentAgentMessages().slice(turnStartIndex());
|
|
20615
20924
|
try {
|
|
20616
20925
|
if (resumedFromSessionRecord) {
|
|
20617
|
-
|
|
20926
|
+
setAgentHistory(shouldPromptAgent ? promptHistoryMessages : existingSessionRecord.piMessages);
|
|
20618
20927
|
runResume.setTurnStartMessageIndex(existingSessionRecord.turnStartMessageIndex);
|
|
20619
|
-
runResume.adoptCommittedBoundary(
|
|
20620
|
-
} else if (promptHistoryMessages.length > 0)
|
|
20621
|
-
runResume.setBeforeMessageCount(
|
|
20622
|
-
if (shouldPromptAgent) runResume.setTurnStartMessageIndex(
|
|
20928
|
+
runResume.adoptCommittedBoundary(currentAgentMessages());
|
|
20929
|
+
} else if (promptHistoryMessages.length > 0) setAgentHistory(promptHistoryMessages);
|
|
20930
|
+
runResume.setBeforeMessageCount(currentAgentMessages().length);
|
|
20931
|
+
if (shouldPromptAgent) runResume.setTurnStartMessageIndex(currentAgentMessages().length);
|
|
20623
20932
|
const authPauseOutcome = await withSpan(`invoke_agent ${botConfig.userName}`, "gen_ai.invoke_agent", spanContext, async (setInvokeAgentSpanAttributes) => {
|
|
20624
20933
|
setAgentSpanAttributes = setInvokeAgentSpanAttributes;
|
|
20625
20934
|
if (behavior.gated && readTurnAnswer(turnMessages())) return;
|
|
@@ -20636,17 +20945,13 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20636
20945
|
};
|
|
20637
20946
|
if (shouldPromptAgent) {
|
|
20638
20947
|
if (await runResume.requireDurableInputCheckpoint([
|
|
20639
|
-
...
|
|
20948
|
+
...currentAgentMessages(),
|
|
20640
20949
|
...contextMessage ? [contextMessage] : [],
|
|
20641
20950
|
freshPromptMessage
|
|
20642
20951
|
], [turnStartProvenance])) await runResume.commitInput();
|
|
20643
20952
|
}
|
|
20644
|
-
if (contextMessage)
|
|
20645
|
-
if (!shouldPromptAgent) await repositoryInstructionsContext.applyUpdate(
|
|
20646
|
-
messages: agent.state.messages,
|
|
20647
|
-
systemPrompt: agent.state.systemPrompt,
|
|
20648
|
-
tools: agent.state.tools
|
|
20649
|
-
});
|
|
20953
|
+
if (contextMessage) setAgentHistory([...currentAgentMessages(), contextMessage]);
|
|
20954
|
+
if (!shouldPromptAgent) await repositoryInstructionsContext.applyUpdate(currentAgentMessages());
|
|
20650
20955
|
/** Race one provider operation against the turn deadline and abort its owner. */
|
|
20651
20956
|
const runAgentStep = async (run, abortRun = () => agent.abort()) => {
|
|
20652
20957
|
let timeoutId;
|
|
@@ -20720,11 +21025,11 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20720
21025
|
};
|
|
20721
21026
|
let run;
|
|
20722
21027
|
const compactionAbortController = new AbortController();
|
|
20723
|
-
const
|
|
21028
|
+
const compacted = await runAgentStep(applyActiveContextCompaction(currentAgentMessages(), compactionAbortController.signal, shouldPromptAgent ? [{
|
|
20724
21029
|
message: freshPromptMessage,
|
|
20725
21030
|
provenance: turnStartProvenance
|
|
20726
21031
|
}] : void 0, false, Boolean(contextMessage), "blocking"), () => compactionAbortController.abort());
|
|
20727
|
-
run = shouldPromptAgent && !
|
|
21032
|
+
run = shouldPromptAgent && !compacted ? agent.prompt(freshPromptMessage) : agent.continue();
|
|
20728
21033
|
discardedRetryUsage = void 0;
|
|
20729
21034
|
let actionConfirmationRetryUsed = false;
|
|
20730
21035
|
let answerReminderUsed = !behavior.gated;
|
|
@@ -20732,8 +21037,8 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20732
21037
|
let refusalFallbackUsed = false;
|
|
20733
21038
|
let emptyOutputAttempt = 0;
|
|
20734
21039
|
const prepareRetry = async (messages) => {
|
|
20735
|
-
discardedRetryUsage = addAgentTurnUsage(discardedRetryUsage, getDiscardedRetryUsage(
|
|
20736
|
-
|
|
21040
|
+
discardedRetryUsage = addAgentTurnUsage(discardedRetryUsage, getDiscardedRetryUsage(currentAgentMessages(), messages));
|
|
21041
|
+
setAgentHistory(messages);
|
|
20737
21042
|
await runResume.persistSafeBoundary(messages);
|
|
20738
21043
|
signal?.throwIfAborted();
|
|
20739
21044
|
};
|
|
@@ -20742,7 +21047,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20742
21047
|
await runAgentStep(run);
|
|
20743
21048
|
if (assistantMessageDeliveryError) throw assistantMessageDeliveryError;
|
|
20744
21049
|
signal?.throwIfAborted();
|
|
20745
|
-
newMessages =
|
|
21050
|
+
newMessages = currentAgentMessages().slice(runResume.beforeMessageCount);
|
|
20746
21051
|
const outputMessages = newMessages.filter(isAssistantMessage);
|
|
20747
21052
|
const outputMessagesAttribute = serializeGenAiAttribute(conversationPrivacy === "public" ? outputMessages.map(toCanonicalOutputMessage) : void 0);
|
|
20748
21053
|
const lastAssistant = outputMessages.at(-1);
|
|
@@ -20761,17 +21066,17 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20761
21066
|
runResume.captureResumeSnapshot(runResume.getResumeSnapshot(currentAgentMessages()));
|
|
20762
21067
|
throw pendingAuthPause;
|
|
20763
21068
|
}
|
|
20764
|
-
const confirmationRetry = actionConfirmationRetryUsed ? void 0 : actionConfirmationRetryMessages(
|
|
21069
|
+
const confirmationRetry = actionConfirmationRetryUsed ? void 0 : actionConfirmationRetryMessages(currentAgentMessages());
|
|
20765
21070
|
if (confirmationRetry) {
|
|
20766
21071
|
actionConfirmationRetryUsed = true;
|
|
20767
21072
|
await prepareRetry(confirmationRetry);
|
|
20768
21073
|
run = agent.continue();
|
|
20769
21074
|
continue;
|
|
20770
21075
|
}
|
|
20771
|
-
const answerReminder = answerReminderUsed || failedAnswerCallsPastLimit >= MAX_FAILED_ANSWER_CALLS_PAST_LIMIT ? void 0 : remindMissingAnswer(
|
|
21076
|
+
const answerReminder = answerReminderUsed || failedAnswerCallsPastLimit >= MAX_FAILED_ANSWER_CALLS_PAST_LIMIT ? void 0 : remindMissingAnswer(currentAgentMessages(), turnStartIndex());
|
|
20772
21077
|
if (answerReminder) {
|
|
20773
21078
|
answerReminderUsed = true;
|
|
20774
|
-
|
|
21079
|
+
setAgentHistory(answerReminder);
|
|
20775
21080
|
await runResume.persistSafeBoundary(answerReminder);
|
|
20776
21081
|
logWarn("agent.turn.answer.reminded", {});
|
|
20777
21082
|
run = agent.continue();
|
|
@@ -20780,7 +21085,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20780
21085
|
const emptyOutputContinuation = nextEmptyOutputContinuation({
|
|
20781
21086
|
attempt: emptyOutputAttempt,
|
|
20782
21087
|
lastAssistant,
|
|
20783
|
-
messages:
|
|
21088
|
+
messages: currentAgentMessages()
|
|
20784
21089
|
});
|
|
20785
21090
|
if (emptyOutputContinuation.kind === "retry") {
|
|
20786
21091
|
emptyOutputAttempt += 1;
|
|
@@ -20793,13 +21098,13 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20793
21098
|
const providerRetry = nextProviderRetry({
|
|
20794
21099
|
attempt: providerRetryAttempt,
|
|
20795
21100
|
failure: lastAssistant,
|
|
20796
|
-
messages:
|
|
21101
|
+
messages: currentAgentMessages()
|
|
20797
21102
|
});
|
|
20798
21103
|
if (!providerRetry) {
|
|
20799
21104
|
const refusalFallback = refusalFallbackUsed ? void 0 : nextRefusalFallback({
|
|
20800
21105
|
failure: lastAssistant,
|
|
20801
21106
|
fallbackModelId: botConfig.refusalFallbackModelId,
|
|
20802
|
-
messages:
|
|
21107
|
+
messages: currentAgentMessages()
|
|
20803
21108
|
});
|
|
20804
21109
|
if (!refusalFallback) break;
|
|
20805
21110
|
refusalFallbackUsed = true;
|
|
@@ -20852,7 +21157,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20852
21157
|
userInput,
|
|
20853
21158
|
toolCalls,
|
|
20854
21159
|
sandboxRef: wiring.getSandboxRef(),
|
|
20855
|
-
piMessages:
|
|
21160
|
+
piMessages: currentAgentMessages(),
|
|
20856
21161
|
durationMs: Date.now() - replyStartedAtMs,
|
|
20857
21162
|
generatedFileCount: generatedFiles.length,
|
|
20858
21163
|
shouldTrace,
|
|
@@ -20875,7 +21180,7 @@ async function executeAgentRunInPrivacyContext(run, conversationKind, conversati
|
|
|
20875
21180
|
if (resume?.timedOut && acceptedToolFreeAssistant && agent) {
|
|
20876
21181
|
await requireConversationLease("save");
|
|
20877
21182
|
await recordActiveMcpProviders();
|
|
20878
|
-
const piMessages =
|
|
21183
|
+
const piMessages = readAgentHistory(agent.state.messages);
|
|
20879
21184
|
return {
|
|
20880
21185
|
status: "completed",
|
|
20881
21186
|
result: buildTurnResult({
|
|
@@ -20960,7 +21265,7 @@ function createAgentRunner(execute, options) {
|
|
|
20960
21265
|
}
|
|
20961
21266
|
};
|
|
20962
21267
|
const loadStoredAttachments = async (attachments) => {
|
|
20963
|
-
const { loadInputAttachments } = await import("./model-input-
|
|
21268
|
+
const { loadInputAttachments } = await import("./model-input-CLo9TaUd.js").then((n) => n.r);
|
|
20964
21269
|
const storage = nextRun.environment?.attachmentStorage;
|
|
20965
21270
|
if (!storage) throw new Error("Attachment storage is unavailable.");
|
|
20966
21271
|
return await loadInputAttachments({
|
|
@@ -20984,4 +21289,4 @@ function createAgentRunner(execute, options) {
|
|
|
20984
21289
|
return await execute(nextRun, streamFn);
|
|
20985
21290
|
} };
|
|
20986
21291
|
}
|
|
20987
|
-
export {
|
|
21292
|
+
export { effectiveTaskOutcomes as $, parseSlackReviewItemClick as A, ingestEvent as At, activateViewerAutomationVersion as B, renderBlockText as C, markConversationRead as Ct, syncReviewItemSlackCards as D, throwApiError as Dt, readSlackReviewItemCardConversationId as E, jsonResponse as Et, resolveSlackChannelIdFromMessage as F, toolInvocationDestination as Ft, ViewerTaskNotFoundError as G, deleteViewerTask as H, resolveSlackChannelIdFromThreadId as I, shouldEmitDevAgentTrace as It, readViewerAutomationRuns as J, readConversationSourceTask as K, resolveDestinationVisibility as L, parseSlackUserInputSubmission as M, missingAutomationSkillReason as Mt, parseSlackThreadId as N, RetryableDeliveryError as Nt, SLACK_REVIEW_ITEM_VIEW_ID as O, previewOriginBelongsTo as Ot, readSlackRawMessageContext as P, actorFromRun as Pt, AutomationEditError as Q, logScheduledAutomationRunSkipped as R, renderAttachmentText as S, conversationReadPositionQuery as St, createSlackReviewItemShow as T, emptyResponse as Tt, readViewerAutomationEdit as U, changeViewerAutomationLifecycle as V, updateViewerAutomation as W, readViewerAutomationVersions as X, readViewerAutomationSummary as Y, readViewerAutomations as Z, readAttachmentContent as _, collectAttachmentGarbage as _t, buildAuthPauseResponse as a, appendAndEnqueueWebMessage as at, unpublishedArtifactHeaders as b, storeAttachment as bt, deleteMcpAuthSessionsForUserProvider as c, createConversationId as ct, getMcpAuthSession as d, resolveConversationDestination as dt, listOwnedWatches as et, getMcpStoredOAuthCredentials as f, AttachmentUploadError as ft, AttachmentDownloadError as g, writeAttachmentUpload as gt, readStats as h, verifyAttachmentUploads as ht, measureTurnCompactionWait as i, acceptsWebMessages as it, parseSlackReviewItemFormTarget as j, findAutomationSkill as jt, buildSlackReviewItemModal as k, processWorkspaceSnapshotJob as kt, deleteMcpServerSessionId as l, recordWebConversationActivity as lt, latestProgressStatus as m, createAttachmentUpload as mt, executeAgentRun as n, renderReviewItemMessage as nt, finalizeMcpAuthorization as o, conversationTurnIdForMessage as ot, putMcpStoredOAuthCredentials as p, collectAttachmentUploadGarbage as pt, readViewerAutomationExecutions as q, processBackgroundCompaction as r, reviewItemChangeRecord as rt, deleteMcpAuthSession as s, createAndEnqueueConversation as st, createAgentRunner as t, deliverReviewItemChange as tt, deleteMcpStoredOAuthCredentials as u, webActorFromUser as ut, publicArtifactHeaders as v, readLiveAttachment as vt, parseSlackMessageReference as w, reportConversationRead as wt, setConversationSubscription as x, archiveConversation as xt, readPublicArtifact as y, requestAttachmentDeletion as yt, scheduledAutomationRunAttributes as z };
|