@sentry/junior 0.275.0 → 0.276.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-dE2BiWP_.js → adapter-DoPR2jS-.js} +1 -1
- package/dist/{admin-CkPaAYuZ.js → admin-BJTT-kXb.js} +1 -1
- package/dist/{agent-invocations-C1RNOCs8.js → agent-invocations-CUWrrzkc.js} +1 -0
- package/dist/{agent-runner-bE7aH7ew.js → agent-runner-sMpA5qGM.js} +266 -202
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +3 -3
- package/dist/api.d.ts +1 -1
- package/dist/api.js +75 -66
- package/dist/{app-CgkquhZ8.d.ts → app-DTj-yAQt.d.ts} +10 -2
- package/dist/app.d.ts +1 -1
- package/dist/app.js +192 -86
- package/dist/{assistant-reply-CjRU9Z59.js → assistant-reply-DbxKnBQF.js} +1 -1
- package/dist/{automation-BGrd03QO.js → automation-B8_mC68r.js} +42 -13
- package/dist/{background-compaction-queue-BYuOt3qK.js → background-compaction-queue-Bywqo1WJ.js} +2 -2
- package/dist/{briefs-6xUvmGos.js → briefs-IL7QnCCR.js} +4 -4
- package/dist/{catalog-runtime-DcJ5NHDW.js → catalog-runtime--sC2CYLQ.js} +1 -1
- package/dist/cli/chat.js +14 -14
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-gnKpkpqP.js → client-7diKvInp.js} +2 -2
- package/dist/{config-D0GKc9sC.js → config-Cb--cuv-.js} +2 -2
- package/dist/{connections-DLqP5Bp1.js → connections-C4-4fxaE.js} +14 -14
- package/dist/{conversation-BjTo9ZFL.js → conversation-DppJ83Hw.js} +32 -7
- package/dist/{conversation-privacy-BCXFshP9.js → conversation-privacy-DTwdT3Pi.js} +1 -1
- package/dist/{credential-sync-BjihXFF2.js → credential-sync-Sl5RQCkS.js} +13 -13
- package/dist/{db-BMZhoYKj.d.ts → db-Ck6TXQIx.d.ts} +1 -1
- package/dist/{executor-j8VMt-To.js → executor-BFKmqxYe.js} +3 -3
- package/dist/instrumentation.d.ts +14 -0
- package/dist/instrumentation.js +29 -6
- package/dist/{logging-CFHIO4Vs.js → logging-B04X_eCB.js} +1 -1
- package/dist/{message-DH0cqFRS.js → message-DQMFyyE-.js} +9 -9
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-BgU4EZsJ.js → oauth-callback-server-BGq0_vQI.js} +2 -2
- package/dist/{projection-CTvLSwcm.js → projection-6dXaN0n-.js} +99 -17
- package/dist/{prompt-JEWUUpLW.js → prompt-B4fQKGZR.js} +1 -1
- package/dist/{registry-OsyWR4GO.js → registry-CEqKR_ld.js} +1 -1
- package/dist/{resolve-DCrKjmVP.js → resolve-8I5DkrfI.js} +3 -3
- package/dist/{result-Btdt5bSl.js → result-BgAW90IM.js} +9 -9
- package/dist/{runner-C1AwS93W.js → runner-CSKDr_19.js} +12 -12
- package/dist/{sandbox-egress-signals-C-5i7Zxm.js → sandbox-egress-signals-BxAT276e.js} +1 -1
- package/dist/{schema-DfdHlBnb.d.ts → schema-CaUWl2EV.d.ts} +74 -6
- package/dist/{schema-CX9XGKCm.js → schema-Cal-EFdi.js} +9 -7
- package/dist/{service-account-CQIW6At4.js → service-account-CUuVJCKT.js} +3 -3
- package/dist/{service-account-DZX1KlQl.js → service-account-CtOab1Xz.js} +3 -3
- package/dist/{session-stop-DjIyORJw.js → session-stop-DK8LuPZW.js} +155 -54
- package/dist/{skills-BEfAAT6p.js → skills-Bc0D7BGy.js} +2 -2
- package/dist/{spawn-Dgj4xxvO.js → spawn-DF_GUcd8.js} +2 -2
- package/dist/{stop-DomyNvuv.js → stop-DthSy-z8.js} +130 -81
- package/dist/{store-Dp3RMEQd.js → store-BgH2P3X9.js} +3 -3
- package/dist/{store-B7Z6zIc7.js → store-C5uVTx2G.js} +11 -9
- package/dist/{task-queue-CVQ9cWnC.js → task-queue-C6ROM_XJ.js} +3 -3
- package/dist/{task-runner-DHBG47gS.js → task-runner-BwAkjjVE.js} +6 -6
- package/dist/{thread-state-BF8VwIxd.js → thread-state-BXjgk1pW.js} +4 -4
- package/dist/{turn-failure-response-Di7TbgsF.js → turn-failure-response-CVI57qKL.js} +7 -7
- package/dist/{turn-lifecycle-DzXwXmLg.js → turn-lifecycle-CF6ibonp.js} +6 -1
- package/dist/{turn-session-routing-CIWhXKeT.js → turn-session-routing-DddybdNu.js} +17 -16
- package/dist/{validation-BRmwRaXc.js → validation-BxF1nQbC.js} +1 -1
- package/dist/{version-DBVMsgvA.js → version-CTzSbCmR.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-BFADRGP8.js → viewer-CQwBszc7.js} +10 -7
- package/dist/{work-DDaoxZAw.js → work-BHlShEQ6.js} +30 -12
- package/dist/{worker-Bub0fDtW.js → worker-DhY9MnsH.js} +6 -6
- package/migrations/0073_conversation_quick_question.sql +1 -0
- package/migrations/meta/0073_snapshot.json +4070 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +6 -5
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-nwUcYXjP.js";
|
|
2
|
-
import { $ as loadTurnCheckpoint, $
|
|
3
|
-
import { S as resolveGatewayCredential, _ as findProviderError, a as completeText, b as isProviderRetryError, c as resolveGatewayModel, d as isCompactionSummaryText, f as renderCurrentInstruction, g as createProviderError, h as ProviderError, i as completeObject, l as COMPACTION_SUMMARY_PREFIX, m as escapeXml, n as GEN_AI_SERVER_ADDRESS, p as unwrapCurrentInstruction, t as GEN_AI_PROVIDER_NAME, u as hasCompactedConversationContext, v as getProviderErrorAttributes, x as getGatewayApiKey } from "./client-
|
|
4
|
-
import { _ as normalizeSlackEmojiName, n as botConfig } from "./config-
|
|
5
|
-
import { C as summarizeMessageText, E as withSpan, H as isRecord$4, R as runWithLogAttributes, S as setTags, T as withLogContext, V as normalizeIdentityEmail, W as toOptionalString, _ as runBestEffort, a as extractGenAiUsageSummary, b as setSpanAttributes, f as logError, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, l as getLogContextAttributesForSpan, m as logInfo, p as logException, u as getTracePropagationHeaders, v as serializeGenAiAttribute, x as setSpanStatus } from "./logging-
|
|
2
|
+
import { $ as loadTurnCheckpoint, $i as isConversationScopedChannel, $r as postSlackMessage, Ai as STOP_WATCHING_TOOL_NAME, An as getOAuthAccountProviders, Ar as hash, B as createPluginEgress, Bn as getPlugins, Bt as TurnSliceLimitExceededError, Ca as SANDBOX_WORKSPACE_ROOT, Ci as tryWorkspaceRepoCheckoutPath, Cn as getAgentContextInputLimitTokens, Cr as updateWorkspace, D as fallbackShortTitle, Di as RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS, Dn as createUserTokenStore, Dr as setWorkspaceSnapshot, Ea as sandboxSkillPathResolution, Ei as getSlackToolContext, Er as loadSnapshotsForProfile, Fi as createWatch, G as AuthorizationFlowDisabledError, Gr as slackMention, Gt as CODEMODE_TOOL_NAME, H as createPluginAuthOrchestration, Ii as deliverWatch, Ir as deliverOAuthAuthorization, J as canReusePendingAuthLink, Ji as SlackActionError, Jr as deleteSlackMessage, Jt as getPiMessageRole, K as AuthorizationPauseError, Li as findMatchingWatches, Ln as getPluginSystemPromptContributions, Lr as formatProviderLabel, Mi as cancelWatch, Mr as ensureDockerDaemon, Nn as createPluginHookRunner, Nr as getSandboxProvider, O as resolveTaskTitle, Oi as RESOURCE_SUBSCRIPTION_MAX_TTL_MS, On as findLegacyWebActorUserId, Or as setWorkspaceSnapshotBuild, Pi as createTimerWatch, Q as continuableMessages, Qa as createPluginAnnotations, Qi as getSlackClient, Qn as insertReviewItem, Qt as hasRuntimeTurnContext, Ri as getWatch, Rn as getPluginTools, Rt as TURN_LIMIT_WRAP_UP_MESSAGE, Sa as SANDBOX_SKILLS_ROOT, Si as SANDBOX_RUNTIME, Sn as getAgentContextCompactionTriggerTokens, Ta as sandboxSkillFile, Ti as resolveChannelCapabilities, Tn as isExperimentalFeatureEnabled, Tr as invalidateReadySnapshot, U as authorizationId, Ur as normalizeSlackReplyMarkdown, Ut as createTurnLimitGate, V as PluginCredentialFailureError, Vr as escapeSlackMrkdwnText, Vt as TurnToolCallLimitExceededError, W as AuthPausePersistenceError, Wt as isTurnExecutionLimitExceededError, Xi as getFilePermalink, Xn as getOpenReviewItemByDedupeKey, Xr as openSlackDirectMessage, Xt as getUserMessageInstructionText, Yi as downloadPrivateSlackFile, Yn as dismissOpenReviewItems, Yr as getSlackMessagePermalink, Yt as getTerminalAssistantMessages, Za as saveObjectAnnotations, Zn as getReviewItem, Zt as hasCurrentInstruction, _a as runNonInteractiveCommand, _r as createWorkspace, a as loadLastModelProfile, ai as isAbortError, an as normalizeToolNameFromResult, ba as SANDBOX_JUNIOR_ROOT, bi as resolveSandboxCommandEnvironment, bn as estimateTextTokens, br as getWorkspaceByName, c as loadTurnRoute, ca as getDashboardConversationLink, ci as wrapSandboxSetupError, cn as trimTrailingAssistantMessages, co as piMessageFromHistoryItem, d as recordAttachmentsDelivered, da as getDashboardTaskLink, di as isWorkspaceSnapshotNotReadyError, dn as TURN_CONTEXT_TAG, do as conversationNoteEvent, dr as requireReviewItemLinks, en as isAssistantMessage, et as saveTurnCheckpoint, fi as workspaceSnapshotNotReadyUserMessage, fo as getConfigDefaults, g as recordMcpProviderConnected, ga as buildNonInteractiveShellScript, gi as createSandboxEgressCredentialToken, gr as resolveAssignees, h as recordGuardianActionReviewed, ha as buildCommandScript, hi as consumeSandboxEgressPermissionDeniedSignal, hr as resolveAssignee, i as loadConversationProjection, ia as sleep, in as isToolResultMessage, ir as PLUGIN_REVIEW_ITEM_KEY_PREFIX, ji as cancelSubscriptions, jr as isStale, ki as RESOURCE_WATCH_TOOL_SOURCE, kr as create, l as openConversationProjection, li as WorkspaceSnapshotNotReadyError, ln as REQUEST_CONTEXT_SECTION_TAG, lo as projectConversationEvents, lr as readReviewItemAgentScope, m as recordAuthorizationRequested, ma as PluginToolDeniedError, mi as consumeSandboxEgressAuthRequiredSignal, mr as automationCreatorUserId, na as runWithSlackInstallationToken, ni as uploadFilesToConversation, nn as isStandaloneRuntimeContextMessage, no as resolveUserTimezone, oi as isAlreadyExistsError, on as retainRuntimeTurnContext, or as canAgentChangeReviewItem, pa as ToolInputError, pi as clearSandboxEgressSignals, pn as buildDeterministicTurnId, pr as EVERYONE_ASSIGNEE, q as abandonReplacedPendingAuth, qa as matchSlackAttachments, qn as closeReviewItem, qr as addReactionToMessage, qt as extractAssistantText, r as loadConnectedMcpProviders, ra as withSlackRetries, rn as isToolResultError, rr as updateReviewItemContent, si as throwSandboxOperationError, sn as stripRuntimeTurnContext, so as historyItemFromPiMessage, sr as canReadReviewItem, ta as normalizeSlackConversationId, ti as updateSlackMessage, tn as isContinuablePiBoundary, to as defaultTimezone, tr as searchReviewItems, u as recordAgentsInstructionsUpdated, ua as getDashboardReviewItemLink, ui as getWorkspaceSnapshotNotReadyError, un as SESSION_CONTEXT_SECTION_TAG, uo as JUNIOR_NATIVE_EVENT_NAMESPACE, ur as requireReviewItemAssignees, v as recordToolExecutionStarted, va as SANDBOX_COMMAND_PATH, vn as calculateContextCompactionTargetTokens, vr as deleteWorkspace, wa as sandboxSkillDir, wi as workspaceRepoCheckoutPath, wr as WorkspaceValidationError, xa as SANDBOX_REPOS_ROOT, xn as getAgentBackgroundCompactionMarkTokens, xr as listWorkspaces, y as recordTurnRoute, ya as SANDBOX_DATA_ROOT, yi as buildSandboxEgressNetworkPolicy, yn as estimateRequestOverheadTokens, yr as getWorkspace, zi as listWatches, zn as getPluginUserPromptContributions, zr as resolveBaseUrl, zt as TurnBudgetExceededError } from "./projection-6dXaN0n-.js";
|
|
3
|
+
import { S as resolveGatewayCredential, _ as findProviderError, a as completeText, b as isProviderRetryError, c as resolveGatewayModel, d as isCompactionSummaryText, f as renderCurrentInstruction, g as createProviderError, h as ProviderError, i as completeObject, l as COMPACTION_SUMMARY_PREFIX, m as escapeXml, n as GEN_AI_SERVER_ADDRESS, p as unwrapCurrentInstruction, t as GEN_AI_PROVIDER_NAME, u as hasCompactedConversationContext, v as getProviderErrorAttributes, x as getGatewayApiKey } from "./client-7diKvInp.js";
|
|
4
|
+
import { _ as normalizeSlackEmojiName, n as botConfig } from "./config-Cb--cuv-.js";
|
|
5
|
+
import { C as summarizeMessageText, E as withSpan, H as isRecord$4, R as runWithLogAttributes, S as setTags, T as withLogContext, V as normalizeIdentityEmail, W as toOptionalString, _ as runBestEffort, a as extractGenAiUsageSummary, b as setSpanAttributes, f as logError, g as normalizeGenAiFinishReason, h as logWarn, i as extractGenAiUsageAttributes, l as getLogContextAttributesForSpan, m as logInfo, p as logException, u as getTracePropagationHeaders, v as serializeGenAiAttribute, x as setSpanStatus } from "./logging-B04X_eCB.js";
|
|
6
6
|
import { g as withActiveSpan, i as getActiveSpan, m as startInactiveSpan } from "./sentry-MDkYAVPV.js";
|
|
7
|
-
import { a as toCanonicalInputMessage, c as toGenAiPayloadMetadata, i as runWithConversationPrivacy, l as toGenAiPayloadTraceAttributes, o as toCanonicalOutputMessage, r as resolveConversationPrivacy, s as toGenAiMessagesTraceAttributes, t as canExposeConversationPayload } from "./conversation-privacy-
|
|
7
|
+
import { a as toCanonicalInputMessage, c as toGenAiPayloadMetadata, i as runWithConversationPrivacy, l as toGenAiPayloadTraceAttributes, o as toCanonicalOutputMessage, r as resolveConversationPrivacy, s as toGenAiMessagesTraceAttributes, t as canExposeConversationPayload } from "./conversation-privacy-DTwdT3Pi.js";
|
|
8
8
|
import { a as formatModelProfile, c as modelProfileSchema, l as profileConfig, n as ModelProfileNotConfiguredError, o as formatModelProfiles, r as boundProfile, s as modelIdForProfile, u as TURN_REASONING_LEVELS } from "./model-profile-B998sjVd.js";
|
|
9
9
|
import { d as parseSlackChannelReferenceId, f as parseSlackTeamId, h as parseSlackMessageTs, n as createSlackActor, o as isUserActor, p as parseSlackUserId, u as parseSlackChannelId } from "./actor-B4DYygOB.js";
|
|
10
|
-
import { $ as sameDestination, C as getSqlExecutor, G as agentTurnCostUsd, J as hasAgentTurnUsage, M as SYSTEM_IDENTITY_ID, N as resolveActorIdentityId, S as getDb, W as addAgentTurnUsage, Z as parseDestination, a as readActorIdentityFromSql, b as getConversationMessageSearchStore, f as identityAvatarUrl, h as readUserAvatarUrls, i as readActorIdentity, x as getConversationStore, y as getConversationEventStore } from "./viewer-
|
|
11
|
-
import { a as juniorAgentInvocations, c as juniorIdentities, d as juniorDestinations, i as juniorAgentBindings, l as juniorUsers, s as juniorConversations } from "./agent-invocations-
|
|
12
|
-
import { E as juniorArtifacts, S as juniorConversationAnnotations, T as juniorAttachments, _ as juniorConversationBriefs, d as juniorAutomations, f as juniorStats, l as juniorAutomationRuns, s as juniorReviewItemSlackCards } from "./executor-
|
|
10
|
+
import { $ as sameDestination, C as getSqlExecutor, G as agentTurnCostUsd, J as hasAgentTurnUsage, M as SYSTEM_IDENTITY_ID, N as resolveActorIdentityId, S as getDb, W as addAgentTurnUsage, Z as parseDestination, a as readActorIdentityFromSql, b as getConversationMessageSearchStore, f as identityAvatarUrl, h as readUserAvatarUrls, i as readActorIdentity, x as getConversationStore, y as getConversationEventStore } from "./viewer-CQwBszc7.js";
|
|
11
|
+
import { a as juniorAgentInvocations, c as juniorIdentities, d as juniorDestinations, i as juniorAgentBindings, l as juniorUsers, s as juniorConversations } from "./agent-invocations-CUWrrzkc.js";
|
|
12
|
+
import { E as juniorArtifacts, S as juniorConversationAnnotations, T as juniorAttachments, _ as juniorConversationBriefs, d as juniorAutomations, f as juniorStats, l as juniorAutomationRuns, s as juniorReviewItemSlackCards } from "./executor-BFKmqxYe.js";
|
|
13
13
|
import { _ as sameActorIdentity, g as instructionProvenanceFor, h as instructionActors, i as KNOWN_CONVERSATION_EVENT_TYPES, m as contextProvenance, n as detectImageMediaType, p as agentInstructionProvenance, r as isVisionImageMediaType } from "./media-DstkkoNP.js";
|
|
14
14
|
import { a as listReferenceFiles, c as soulPathCandidates, l as worldPathCandidates } from "./package-discovery-DJBompdd.js";
|
|
15
|
-
import { c as fetchWithBoundedOAuthErrorBodies, d as actorLogContext, f as credentialContextForActor, g as credentialUserSubjectId, i as resolvePluginHeaderEnvRefs, l as getOAuthProviderErrorAttributes, s as OAuthProviderError } from "./registry-
|
|
16
|
-
import { n as pluginCatalogRuntime } from "./catalog-runtime
|
|
17
|
-
import { a as parseSkillInvocation, i as parseSkillFile, n as findSkillByName, r as loadSkillsByName, t as discoverSkills } from "./skills-
|
|
15
|
+
import { c as fetchWithBoundedOAuthErrorBodies, d as actorLogContext, f as credentialContextForActor, g as credentialUserSubjectId, i as resolvePluginHeaderEnvRefs, l as getOAuthProviderErrorAttributes, s as OAuthProviderError } from "./registry-CEqKR_ld.js";
|
|
16
|
+
import { n as pluginCatalogRuntime } from "./catalog-runtime--sC2CYLQ.js";
|
|
17
|
+
import { a as parseSkillInvocation, i as parseSkillFile, n as findSkillByName, r as loadSkillsByName, t as discoverSkills } from "./skills-Bc0D7BGy.js";
|
|
18
18
|
import { a as withLock, i as fenceLock } from "./locks-D-0h111u.js";
|
|
19
|
-
import { r as getStateAdapter } from "./adapter-
|
|
19
|
+
import { r as getStateAdapter } from "./adapter-DoPR2jS-.js";
|
|
20
20
|
import { i as isValidTimeZone, r as getZonedDateTimeParts, t as getFirstRunAtMs } from "./cadence-R7Em4RjE.js";
|
|
21
|
-
import {
|
|
22
|
-
import { r as EVENT_AUTHOR_ID } from "./prompt-
|
|
23
|
-
import { A as
|
|
24
|
-
import { a as isNoReplyMarker, i as NO_REPLY_MARKER, n as getAssistantReplyText, r as sanitizeAssistantText, t as decideReply } from "./assistant-reply-
|
|
25
|
-
import {
|
|
21
|
+
import { H as removedCardSchema, J as briefLinkSchema, X as conversationBriefSchema, Y as briefOutcomeStatusSchema } from "./conversation-DppJ83Hw.js";
|
|
22
|
+
import { r as EVENT_AUTHOR_ID } from "./prompt-B4fQKGZR.js";
|
|
23
|
+
import { A as AgentInvocationLimitError, G as TurnInputCommitLostError, H as formatAgentTypes, I as CHILD_AGENT_RESULTS, L as PARENT_AGENT_TARGET, M as AgentMessageQueueFullError, N as AgentMessageTargetError, P as AgentNameInUseError, R as agentNameSchema, W as CooperativeTurnYieldError, Y as isTurnInputCommitLostError, _ as getLatestAgentInvocationForConversation, d as getAgentInvocationIdForResult, f as getAgentInvocationMessageId, g as getChildAgentLockName, j as AgentMessagePausedError, n as NON_TERMINAL_AGENT_INVOCATION_STATUSES, v as invocationFromRow, y as isTerminalAgentInvocation, z as AGENT_TYPES } from "./store-C5uVTx2G.js";
|
|
24
|
+
import { a as isNoReplyMarker, i as NO_REPLY_MARKER, n as getAssistantReplyText, r as sanitizeAssistantText, t as decideReply } from "./assistant-reply-DbxKnBQF.js";
|
|
25
|
+
import { B as remindMissingAutomationResult, F as automationResultSchema$1, O as resolveSlackReplyTarget, P as FINISH_AUTOMATION_RUN_TOOL_NAME, _ as slackChannelMessageTrigger, a as EVENT_WAIT_MS, b as workspaceSnapshotFinishedEvent, d as getEventCatalog, n as markConversationsStopped, o as enqueueEventNotification, p as requireSlackChannelMessageScope, t as getConversationStoppedAtMs, v as WORKSPACE_SNAPSHOT_FAILED_EVENT, x as workspaceSnapshotWatch, y as WORKSPACE_SNAPSHOT_READY_EVENT, z as readAutomationResult } from "./session-stop-DK8LuPZW.js";
|
|
26
26
|
import { C as userCustomizationTextSchema, b as webMessageId, g as formatUserInputAnswer, h as buttonUserInputField, m as USER_INPUT_NOTE, p as USER_INPUT_LIMITS, s as sumUtcHoursIntoSixHours, v as normalizeUserInputAnswer, x as USER_CUSTOMIZATION_MAX_CHARS, y as userInputRequestSchema } from "./reporting-window-DgHgwQB3.js";
|
|
27
|
-
import { a as setSnapshotSpanAttributes, i as postinstall, n as resolve$1, r as dependencies, s as getSandboxResources } from "./resolve-
|
|
28
|
-
import { f as QUEUE_SIGNATURE_MAX_AGE_MS, g as getTurnRequestDeadline, l as getVercelConversationWorkQueue, n as backgroundCompactionId, o as sendNextWorkspaceSnapshotJob, s as sendWorkspaceSnapshotJob } from "./background-compaction-queue-
|
|
29
|
-
import { D as stopConversationWork, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage } from "./store-
|
|
30
|
-
import { $ as saveEventAutomation, A as readAutomationRuns, B as readScheduledAutomation, C as readAutomationExecutionByConversationId, Ct as requireEventIdentifier, D as readAutomationExecutionStatusHours, E as readAutomationExecutionStatusDays, I as createScheduledAutomation, J as deleteEventAutomation, L as deleteScheduledAutomation, O as readAutomationExecutionSummaries, Q as parseEventAutomationRow, St as registeredResourceTypeSchema, T as readAutomationExecutionHours, V as saveScheduledAutomation, X as getEventAutomation, Z as listDeletedEventAutomationsCreatedBy, _t as eventWatchUnavailable, at as listAutomationVersions, bt as registeredEventTriggerProblems, c as getDispatchIdForConversation, et as setEventAutomationStatus, ft as automationEventCatalog, gt as eventNamespaceSchema, k as readAutomationExecutions, l as getDispatchInputMessageId, lt as automationRevision, ot as readAutomationVersion, pt as describeRegisteredEventTrigger, q as createEventAutomation, rt as automationDefinition, st as sameDefinitionValue, t as resolveConversationRouting, u as getDispatchRecord, ut as requireAutomationRevision, vt as hasEventCatalogEntries, w as readAutomationExecutionDays, wt as requireValidEventTrigger, x as emptyAutomationRunWindows, xt as registeredEventTypeSchema, yt as registeredEventMatchSchema, z as parseScheduledAutomationRow } from "./turn-session-routing-
|
|
31
|
-
import { _ as getMcpProviderErrorAttributes, a as serviceAccountOnly, c as createMcpServiceAccountClientProvider, d as PluginMcpClient, f as McpProviderError, g as getMcpAwareTelemetryMessage, h as getMcpAwareErrorType, i as serviceAccountAllows, l as getMcpServiceAccountCredentials, m as McpToolError, p as McpServiceAccountRequiredError, u as McpAuthorizationRequiredError, v as toMcpProviderError } from "./service-account-
|
|
32
|
-
import { A as SCHEDULED_AUTOMATION_SYSTEM_ACTOR, D as taskOutcomeInputSchema, E as automationTitleSchema, F as
|
|
27
|
+
import { a as setSnapshotSpanAttributes, i as postinstall, n as resolve$1, r as dependencies, s as getSandboxResources } from "./resolve-8I5DkrfI.js";
|
|
28
|
+
import { f as QUEUE_SIGNATURE_MAX_AGE_MS, g as getTurnRequestDeadline, l as getVercelConversationWorkQueue, n as backgroundCompactionId, o as sendNextWorkspaceSnapshotJob, s as sendWorkspaceSnapshotJob } from "./background-compaction-queue-Bywqo1WJ.js";
|
|
29
|
+
import { D as stopConversationWork, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage } from "./store-BgH2P3X9.js";
|
|
30
|
+
import { $ as saveEventAutomation, A as readAutomationRuns, B as readScheduledAutomation, C as readAutomationExecutionByConversationId, Ct as requireEventIdentifier, D as readAutomationExecutionStatusHours, E as readAutomationExecutionStatusDays, I as createScheduledAutomation, J as deleteEventAutomation, L as deleteScheduledAutomation, O as readAutomationExecutionSummaries, Q as parseEventAutomationRow, St as registeredResourceTypeSchema, T as readAutomationExecutionHours, V as saveScheduledAutomation, X as getEventAutomation, Z as listDeletedEventAutomationsCreatedBy, _t as eventWatchUnavailable, at as listAutomationVersions, bt as registeredEventTriggerProblems, c as getDispatchIdForConversation, et as setEventAutomationStatus, ft as automationEventCatalog, gt as eventNamespaceSchema, k as readAutomationExecutions, l as getDispatchInputMessageId, lt as automationRevision, ot as readAutomationVersion, pt as describeRegisteredEventTrigger, q as createEventAutomation, rt as automationDefinition, st as sameDefinitionValue, t as resolveConversationRouting, u as getDispatchRecord, ut as requireAutomationRevision, vt as hasEventCatalogEntries, w as readAutomationExecutionDays, wt as requireValidEventTrigger, x as emptyAutomationRunWindows, xt as registeredEventTypeSchema, yt as registeredEventMatchSchema, z as parseScheduledAutomationRow } from "./turn-session-routing-DddybdNu.js";
|
|
31
|
+
import { _ as getMcpProviderErrorAttributes, a as serviceAccountOnly, c as createMcpServiceAccountClientProvider, d as PluginMcpClient, f as McpProviderError, g as getMcpAwareTelemetryMessage, h as getMcpAwareErrorType, i as serviceAccountAllows, l as getMcpServiceAccountCredentials, m as McpToolError, p as McpServiceAccountRequiredError, u as McpAuthorizationRequiredError, v as toMcpProviderError } from "./service-account-CUuVJCKT.js";
|
|
32
|
+
import { A as SCHEDULED_AUTOMATION_SYSTEM_ACTOR, D as taskOutcomeInputSchema, E as automationTitleSchema, F as scheduleIntentFromTool, I as toolScheduleIntentSchema, L as weekdaySchema, N as ScheduleIntentError, P as compileScheduleIntent, T as automationInstructionToolSchema, k as eventAutomationTriggerSchema, l as automationListQuerySchema } from "./automation-B8_mC68r.js";
|
|
33
33
|
import { n as privateTraceResultAttributes } from "./private-trace-result-CE7_lEdq.js";
|
|
34
34
|
import { streamSimple } from "@earendil-works/pi-ai/compat";
|
|
35
35
|
import { createGatewayProvider } from "@ai-sdk/gateway";
|
|
@@ -40,9 +40,9 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
40
40
|
import { createHash, randomBytes, randomInt, randomUUID } from "node:crypto";
|
|
41
41
|
import { z } from "zod";
|
|
42
42
|
import { and, asc, count, desc, eq, exists, gt, gte, inArray, isNotNull, isNull, lt, lte, ne, notExists, notInArray, or, sql } from "drizzle-orm";
|
|
43
|
-
import { PluginToolInputError,
|
|
43
|
+
import { PluginToolInputError, agentEventKeys, agentEventMatchKey, agentEventMatchSchema, createWebSource, declaredEventKeys, eventMatchFieldSchema, eventSchema, eventTriggerText, localDestinationSchema, missingToolAnnotationKeys, ownedObjectAnnotationSchema, sourceSchema, stableEventMatchKey, watchResultSchema } from "@sentry/junior-plugin-api";
|
|
44
44
|
import { alias } from "drizzle-orm/pg-core";
|
|
45
|
-
import { Agent, estimateContextTokens } from "@earendil-works/pi-agent-core";
|
|
45
|
+
import { Agent, estimateContextTokens, estimateTokens } from "@earendil-works/pi-agent-core";
|
|
46
46
|
import fs from "node:fs/promises";
|
|
47
47
|
import fs$1 from "node:fs";
|
|
48
48
|
import http from "node:http";
|
|
@@ -1703,7 +1703,7 @@ const SAFETY_RULES = [
|
|
|
1703
1703
|
const TOOL_POLICY_RULES = [
|
|
1704
1704
|
"- Do not use tools to rediscover content already present in the current conversation. For drafting or rewriting with no referenced retrievable source, do not search unrelated memory, history, files, or providers. Put a clear placeholder where a fact that only the person knows goes, and ask for those facts with one `addReviewItem` item.",
|
|
1705
1705
|
"- Resolve provider action targets before calls: explicit target wins; ambient `<configuration>` fills omitted targets. Treat non-target links/references as context.",
|
|
1706
|
-
"- When a tool result includes a subscription, those events are already watched; do not call watchEvents for them. When a tool result includes a subscribable resource with
|
|
1706
|
+
"- When a tool result includes a subscription, those events are already watched; do not call watchEvents for them. When a tool result includes a subscribable resource with suggested_events, use watchEvents only for those remaining events that serve the current intent. If suggested_events is empty or omitted, do not invent a watch. Do not create scheduled polling tasks for events a watch can deliver. Write a concise intent summary. Stop only the requested watch by id unless the user explicitly asks to stop every watch in the thread.",
|
|
1707
1707
|
"- Scheduled and event automations use their creator's connected credentials by default when the requested work needs them. Do not ask for separate confirmation merely to use those credentials.",
|
|
1708
1708
|
"- Before loading a skill or starting substantial work, decide whether `handoff` or `spawnAgent` fits better than inline work."
|
|
1709
1709
|
];
|
|
@@ -4690,7 +4690,10 @@ function firstChangedLine(oldLines, newLines) {
|
|
|
4690
4690
|
const count = Math.max(oldLines.length, newLines.length);
|
|
4691
4691
|
for (let index = 0; index < count; index += 1) if (oldLines[index] !== newLines[index]) return index + 1;
|
|
4692
4692
|
}
|
|
4693
|
-
/**
|
|
4693
|
+
/**
|
|
4694
|
+
* Accept common exact-edit argument variants, such as the camelCase keys that
|
|
4695
|
+
* models often send, before schema validation.
|
|
4696
|
+
*/
|
|
4694
4697
|
function prepareTextReplacementArguments(input) {
|
|
4695
4698
|
if (!input || typeof input !== "object") return input;
|
|
4696
4699
|
const raw = { ...input };
|
|
@@ -4700,20 +4703,20 @@ function prepareTextReplacementArguments(input) {
|
|
|
4700
4703
|
return raw;
|
|
4701
4704
|
}
|
|
4702
4705
|
const edits = Array.isArray(raw.edits) ? [...raw.edits] : [];
|
|
4703
|
-
const oldText = raw.
|
|
4704
|
-
const newText = raw.
|
|
4706
|
+
const oldText = raw.old_text ?? raw.oldText;
|
|
4707
|
+
const newText = raw.new_text ?? raw.newText;
|
|
4705
4708
|
if (typeof oldText === "string" && typeof newText === "string") edits.push({
|
|
4706
|
-
oldText,
|
|
4707
|
-
newText
|
|
4709
|
+
old_text: oldText,
|
|
4710
|
+
new_text: newText
|
|
4708
4711
|
});
|
|
4709
4712
|
if (edits.length > 0) raw.edits = edits.map((edit) => {
|
|
4710
4713
|
if (!edit || typeof edit !== "object") return edit;
|
|
4711
4714
|
const record = edit;
|
|
4712
|
-
const {
|
|
4715
|
+
const { oldText, newText, ...rest } = record;
|
|
4713
4716
|
return {
|
|
4714
4717
|
...rest,
|
|
4715
|
-
|
|
4716
|
-
|
|
4718
|
+
old_text: record.old_text ?? oldText,
|
|
4719
|
+
new_text: record.new_text ?? newText
|
|
4717
4720
|
};
|
|
4718
4721
|
});
|
|
4719
4722
|
delete raw.oldText;
|
|
@@ -4767,19 +4770,19 @@ function buildCompactDiff(oldContent, newContent) {
|
|
|
4767
4770
|
function validateAndApplyTextEdits(content, edits, targetName) {
|
|
4768
4771
|
if (!Array.isArray(edits) || edits.length === 0) throw new ToolInputError(`${targetName} requires at least one edit.`);
|
|
4769
4772
|
const normalizedEdits = edits.map((edit, index) => {
|
|
4770
|
-
if (typeof edit.
|
|
4771
|
-
if (typeof edit.
|
|
4773
|
+
if (typeof edit.old_text !== "string" || edit.old_text.length === 0) throw new ToolInputError(`edits[${index}].old_text must not be empty in ${targetName}.`);
|
|
4774
|
+
if (typeof edit.new_text !== "string") throw new ToolInputError(`edits[${index}].new_text must be a string in ${targetName}.`);
|
|
4772
4775
|
return {
|
|
4773
|
-
oldText: normalizeToLf$1(edit.
|
|
4774
|
-
newText: normalizeToLf$1(edit.
|
|
4776
|
+
oldText: normalizeToLf$1(edit.old_text),
|
|
4777
|
+
newText: normalizeToLf$1(edit.new_text)
|
|
4775
4778
|
};
|
|
4776
4779
|
});
|
|
4777
4780
|
const matchedEdits = [];
|
|
4778
4781
|
for (const [index, edit] of normalizedEdits.entries()) {
|
|
4779
4782
|
const matchIndex = content.indexOf(edit.oldText);
|
|
4780
|
-
if (matchIndex === -1) throw new ToolInputError(`Could not find edits[${index}] in ${targetName}.
|
|
4783
|
+
if (matchIndex === -1) throw new ToolInputError(`Could not find edits[${index}] in ${targetName}. old_text must match exactly including whitespace and newlines.`);
|
|
4781
4784
|
const occurrences = countOccurrences(content, edit.oldText);
|
|
4782
|
-
if (occurrences > 1) throw new ToolInputError(`Found ${occurrences} occurrences of edits[${index}] in ${targetName}. Each
|
|
4785
|
+
if (occurrences > 1) throw new ToolInputError(`Found ${occurrences} occurrences of edits[${index}] in ${targetName}. Each old_text must be unique.`);
|
|
4783
4786
|
matchedEdits.push({
|
|
4784
4787
|
editIndex: index,
|
|
4785
4788
|
matchIndex,
|
|
@@ -4888,8 +4891,8 @@ async function editFile(params) {
|
|
|
4888
4891
|
});
|
|
4889
4892
|
}
|
|
4890
4893
|
const editReplacementSchema$1 = z.object({
|
|
4891
|
-
|
|
4892
|
-
|
|
4894
|
+
old_text: z.string().min(1).describe("Exact text to replace. It must be unique in the original file and must not overlap another edit."),
|
|
4895
|
+
new_text: z.string().describe("Replacement text for this edit.")
|
|
4893
4896
|
});
|
|
4894
4897
|
/** Create the sandbox edit tool definition exposed to the agent. */
|
|
4895
4898
|
function createEditFileTool() {
|
|
@@ -4900,7 +4903,7 @@ function createEditFileTool() {
|
|
|
4900
4903
|
openWorldHint: false,
|
|
4901
4904
|
readOnlyHint: false
|
|
4902
4905
|
},
|
|
4903
|
-
description: "Edit one sandbox workspace file with exact text replacements. Use for precise changes to existing files; prefer this over writeFile for targeted changes. Each
|
|
4906
|
+
description: "Edit one sandbox workspace file with exact text replacements. Use for precise changes to existing files; prefer this over writeFile for targeted changes. Each old_text must match exactly, be unique, and not overlap another edit. Returns a diff. Multiple changes to the same file: use one edits[] call.",
|
|
4904
4907
|
prepareArguments: prepareEditFileArguments,
|
|
4905
4908
|
executionMode: "sequential",
|
|
4906
4909
|
inputSchema: z.object({
|
|
@@ -5327,7 +5330,7 @@ function createGrepTool() {
|
|
|
5327
5330
|
pattern: z.string().min(1).describe("Regex pattern or literal text to search for."),
|
|
5328
5331
|
path: z.string().min(1).describe("Directory or file path in the sandbox workspace. Defaults to the workspace root.").optional(),
|
|
5329
5332
|
glob: z.string().min(1).describe("Optional glob filter such as '*.ts' or '**/*.test.ts'.").optional(),
|
|
5330
|
-
|
|
5333
|
+
ignore_case: booleanInput$2("Whether matching should ignore case.").optional(),
|
|
5331
5334
|
literal: booleanInput$2("Treat pattern as literal text instead of regex.").optional(),
|
|
5332
5335
|
context: z.coerce.number().int().min(0).describe("Number of surrounding context lines to include.").optional(),
|
|
5333
5336
|
limit: z.coerce.number().int().min(1).describe("Maximum matches to return. Defaults to 100.").optional()
|
|
@@ -5962,13 +5965,13 @@ const SANDBOX_ARTIFACTS_DIR = "/tmp/junior/artifacts";
|
|
|
5962
5965
|
const sandboxFileReferenceSchema = z.object({
|
|
5963
5966
|
path: z.string().min(1).describe("Exact source path of an existing sandbox file. Preserve paths returned by other tools unchanged; do not move or rewrite them before sending."),
|
|
5964
5967
|
filename: z.string().min(1).nullable().optional().describe("Optional filename override shown to the recipient. Null is treated as omitted."),
|
|
5965
|
-
|
|
5968
|
+
mime_type: z.string().min(1).nullable().optional().describe("Optional MIME type override. Null is treated as omitted."),
|
|
5966
5969
|
bytes: z.number().int().nonnegative().nullable().optional().describe("Optional known file size returned by a producing tool. Null is treated as omitted; sending tools validate the file contents directly.")
|
|
5967
5970
|
});
|
|
5968
5971
|
/** Generated file reference whose path and metadata can be passed directly to sendFiles. */
|
|
5969
5972
|
const generatedArtifactFileRefSchema = sandboxFileReferenceSchema.extend({
|
|
5970
5973
|
filename: z.string().min(1),
|
|
5971
|
-
|
|
5974
|
+
mime_type: z.string().min(1).optional(),
|
|
5972
5975
|
bytes: z.number().int().nonnegative()
|
|
5973
5976
|
}).strict();
|
|
5974
5977
|
const MIME_BY_EXTENSION = {
|
|
@@ -6046,7 +6049,7 @@ async function readSandboxFileUpload(workspace, input) {
|
|
|
6046
6049
|
if (fileBuffer.byteLength > 10485760) throw new ToolInputError(`file exceeds ${MAX_SANDBOX_FILE_UPLOAD_BYTES} bytes: ${targetPath} (${fileBuffer.byteLength} bytes)`);
|
|
6047
6050
|
const resolvedFilename = sanitizeFilename(input.filename, targetPath);
|
|
6048
6051
|
const detectedMimeType = await detectMimeType(workspace, targetPath);
|
|
6049
|
-
const resolvedMimeType = inferMimeType(resolvedFilename, input.
|
|
6052
|
+
const resolvedMimeType = inferMimeType(resolvedFilename, input.mime_type ?? detectedMimeType);
|
|
6050
6053
|
return {
|
|
6051
6054
|
bytes: fileBuffer.byteLength,
|
|
6052
6055
|
data: fileBuffer,
|
|
@@ -6076,7 +6079,7 @@ async function writeSandboxGeneratedArtifacts(workspace, files) {
|
|
|
6076
6079
|
ref: {
|
|
6077
6080
|
bytes: content.byteLength,
|
|
6078
6081
|
filename: file.filename,
|
|
6079
|
-
|
|
6082
|
+
mime_type: file.mimeType,
|
|
6080
6083
|
path: artifactPath
|
|
6081
6084
|
}
|
|
6082
6085
|
};
|
|
@@ -6767,7 +6770,7 @@ function createBashTool() {
|
|
|
6767
6770
|
inputSchema: z.object({
|
|
6768
6771
|
command: z.string().min(1).describe("Bash command to run inside the sandbox."),
|
|
6769
6772
|
cwd: z.string().min(1).describe("Optional working directory for this command only.").optional(),
|
|
6770
|
-
|
|
6773
|
+
timeout_ms: z.coerce.number().int().min(1e3).describe("Optional command timeout in milliseconds. Use for commands that may hang.").optional()
|
|
6771
6774
|
}),
|
|
6772
6775
|
outputSchema: juniorToolOutputSchema,
|
|
6773
6776
|
executionMode: "sequential",
|
|
@@ -6813,7 +6816,7 @@ const resizedImageSchema = z.object({
|
|
|
6813
6816
|
const imageGenerateOutputSchema = juniorToolOutputSchema.extend({
|
|
6814
6817
|
model: z.string(),
|
|
6815
6818
|
prompt: z.string(),
|
|
6816
|
-
|
|
6819
|
+
enriched_prompt: z.string(),
|
|
6817
6820
|
image_count: z.number().int().nonnegative(),
|
|
6818
6821
|
images: z.array(generatedArtifactFileRefSchema),
|
|
6819
6822
|
delivery: z.string(),
|
|
@@ -6970,7 +6973,7 @@ function createImageGenerateTool(hooks, options, deps = {}) {
|
|
|
6970
6973
|
return {
|
|
6971
6974
|
model,
|
|
6972
6975
|
prompt,
|
|
6973
|
-
enrichedPrompt,
|
|
6976
|
+
enriched_prompt: enrichedPrompt,
|
|
6974
6977
|
image_count: artifactRefs.length,
|
|
6975
6978
|
images: artifactRefs,
|
|
6976
6979
|
...resizeResult,
|
|
@@ -6980,7 +6983,7 @@ function createImageGenerateTool(hooks, options, deps = {}) {
|
|
|
6980
6983
|
return {
|
|
6981
6984
|
model,
|
|
6982
6985
|
prompt,
|
|
6983
|
-
enrichedPrompt,
|
|
6986
|
+
enriched_prompt: enrichedPrompt,
|
|
6984
6987
|
image_count: 0,
|
|
6985
6988
|
images: [],
|
|
6986
6989
|
...resizeResult,
|
|
@@ -8409,14 +8412,16 @@ function acceptsWebMessages(conversationId, destination) {
|
|
|
8409
8412
|
if (destination?.platform === "slack") return true;
|
|
8410
8413
|
return destination?.platform === "local" && conversationId.startsWith("local:web:");
|
|
8411
8414
|
}
|
|
8412
|
-
/**
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
+
/**
|
|
8416
|
+
* Build the web Actor for one signed-in User. Junior is the web provider,
|
|
8417
|
+
* so the provider-scoped Actor id is the User id.
|
|
8418
|
+
*/
|
|
8419
|
+
function webActorFromUser(user, profile) {
|
|
8415
8420
|
return {
|
|
8416
8421
|
platform: "web",
|
|
8417
|
-
userId:
|
|
8418
|
-
email:
|
|
8419
|
-
...
|
|
8422
|
+
userId: user.id,
|
|
8423
|
+
email: normalizeEmail(user.email),
|
|
8424
|
+
...user.displayName ? { fullName: user.displayName } : void 0,
|
|
8420
8425
|
...profile?.userName ? { userName: profile.userName } : void 0
|
|
8421
8426
|
};
|
|
8422
8427
|
}
|
|
@@ -8441,6 +8446,7 @@ function buildWebInboundMessage(args) {
|
|
|
8441
8446
|
...args.authorIdentityId ? { authorIdentityId: args.authorIdentityId } : void 0,
|
|
8442
8447
|
text,
|
|
8443
8448
|
...args.attachments?.length ? { attachments: args.attachments } : void 0,
|
|
8449
|
+
...args.reviewItemChange ? { reviewItemChange: args.reviewItemChange } : void 0,
|
|
8444
8450
|
metadata: {
|
|
8445
8451
|
authorEmail: normalizeEmail(args.actor.email),
|
|
8446
8452
|
...args.actor.fullName && { authorFullName: args.actor.fullName },
|
|
@@ -8526,7 +8532,8 @@ async function appendAndEnqueueWebMessage(input, options) {
|
|
|
8526
8532
|
message: text,
|
|
8527
8533
|
attachments,
|
|
8528
8534
|
messageId,
|
|
8529
|
-
nowMs
|
|
8535
|
+
nowMs,
|
|
8536
|
+
...input.reviewItemChange && { reviewItemChange: input.reviewItemChange }
|
|
8530
8537
|
}),
|
|
8531
8538
|
conversationStore: options.conversationStore,
|
|
8532
8539
|
nowMs,
|
|
@@ -8541,6 +8548,16 @@ async function appendAndEnqueueWebMessage(input, options) {
|
|
|
8541
8548
|
};
|
|
8542
8549
|
}
|
|
8543
8550
|
// src/chat/review-items/messages.ts
|
|
8551
|
+
/**
|
|
8552
|
+
* Return the record that a message about a person change carries. A reply or
|
|
8553
|
+
* an agent close is not a person change, so it has no record.
|
|
8554
|
+
*/
|
|
8555
|
+
function reviewItemChangeRecord(item, change) {
|
|
8556
|
+
return "user" in change ? {
|
|
8557
|
+
kind: change.kind,
|
|
8558
|
+
reviewItemId: item.id
|
|
8559
|
+
} : void 0;
|
|
8560
|
+
}
|
|
8544
8561
|
function personName$1(user) {
|
|
8545
8562
|
return user.displayName ? `${user.displayName} (${user.email})` : user.email;
|
|
8546
8563
|
}
|
|
@@ -8594,14 +8611,16 @@ function eventMessageText(text, change) {
|
|
|
8594
8611
|
}
|
|
8595
8612
|
async function sendOne(args) {
|
|
8596
8613
|
const key = messageKey(args.item, args.change);
|
|
8614
|
+
const record = reviewItemChangeRecord(args.item, args.change);
|
|
8597
8615
|
if ("user" in args.change) {
|
|
8598
8616
|
const conversation = await getConversationStore().get({ conversationId: args.conversationId });
|
|
8599
8617
|
if (acceptsWebMessages(args.conversationId, conversation?.destination)) {
|
|
8600
8618
|
await appendAndEnqueueWebMessage({
|
|
8601
|
-
actor:
|
|
8619
|
+
actor: webActorFromUser(args.change.user),
|
|
8602
8620
|
conversationId: args.conversationId,
|
|
8603
8621
|
idempotencyKey: key,
|
|
8604
|
-
message: args.text
|
|
8622
|
+
message: args.text,
|
|
8623
|
+
reviewItemChange: record
|
|
8605
8624
|
}, {
|
|
8606
8625
|
nowMs: args.nowMs,
|
|
8607
8626
|
queue: args.queue
|
|
@@ -8629,6 +8648,7 @@ async function sendOne(args) {
|
|
|
8629
8648
|
authorId: EVENT_AUTHOR_ID,
|
|
8630
8649
|
authorIdentityId: SYSTEM_IDENTITY_ID,
|
|
8631
8650
|
metadata,
|
|
8651
|
+
...record ? { reviewItemChange: record } : void 0,
|
|
8632
8652
|
text: eventMessageText(args.text, args.change)
|
|
8633
8653
|
},
|
|
8634
8654
|
receivedAtMs: args.nowMs,
|
|
@@ -9080,14 +9100,14 @@ const listedResourceWatchSchema = z.object({
|
|
|
9080
9100
|
label: z.string().min(1),
|
|
9081
9101
|
identifier: z.string().min(1),
|
|
9082
9102
|
namespace: z.string().min(1),
|
|
9083
|
-
|
|
9103
|
+
resource_type: z.string().min(1),
|
|
9084
9104
|
events: z.array(z.string().min(1)).min(1),
|
|
9085
9105
|
match: z.record(z.string(), z.unknown()).optional(),
|
|
9086
9106
|
intent: z.string().min(1),
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9107
|
+
expires_at: z.string().datetime(),
|
|
9108
|
+
fires_at: z.string().datetime().optional(),
|
|
9109
|
+
child_agent: z.object({
|
|
9110
|
+
conversation_id: z.string().min(1),
|
|
9091
9111
|
name: z.string().min(1).optional()
|
|
9092
9112
|
}).strict().optional()
|
|
9093
9113
|
}).strict();
|
|
@@ -9105,7 +9125,7 @@ function createListWatchesTool(context) {
|
|
|
9105
9125
|
openWorldHint: false,
|
|
9106
9126
|
readOnlyHint: true
|
|
9107
9127
|
},
|
|
9108
|
-
description: "List active watches for the current conversation and for every child agent below it. A watch with
|
|
9128
|
+
description: "List active watches for the current conversation and for every child agent below it. A watch with child_agent belongs to that child agent; one without belongs to the current conversation.",
|
|
9109
9129
|
exposure: "deferred",
|
|
9110
9130
|
source: RESOURCE_WATCH_TOOL_SOURCE,
|
|
9111
9131
|
inputSchema: z.object({}).strict(),
|
|
@@ -9116,13 +9136,16 @@ function createListWatchesTool(context) {
|
|
|
9116
9136
|
label: subscription.label,
|
|
9117
9137
|
identifier: subscription.identifier,
|
|
9118
9138
|
namespace: subscription.namespace,
|
|
9119
|
-
|
|
9139
|
+
resource_type: subscription.resourceType,
|
|
9120
9140
|
events: subscription.events,
|
|
9121
|
-
...subscription.match ? { match: subscription.match } : void 0,
|
|
9141
|
+
...subscription.match ? { match: agentEventKeys(subscription.match) } : void 0,
|
|
9122
9142
|
intent: subscription.intent,
|
|
9123
|
-
|
|
9124
|
-
firesAtMs: subscription.firesAtMs,
|
|
9125
|
-
...childAgent ? {
|
|
9143
|
+
expires_at: new Date(subscription.expiresAtMs).toISOString(),
|
|
9144
|
+
...subscription.firesAtMs !== void 0 ? { fires_at: new Date(subscription.firesAtMs).toISOString() } : void 0,
|
|
9145
|
+
...childAgent ? { child_agent: {
|
|
9146
|
+
conversation_id: childAgent.conversationId,
|
|
9147
|
+
...childAgent.name ? { name: childAgent.name } : void 0
|
|
9148
|
+
} } : void 0
|
|
9126
9149
|
})) };
|
|
9127
9150
|
}
|
|
9128
9151
|
});
|
|
@@ -9133,20 +9156,27 @@ const MAX_SEARCH_RESULTS = 20;
|
|
|
9133
9156
|
const searchedResourceTypeSchema = z.object({
|
|
9134
9157
|
namespace: z.string(),
|
|
9135
9158
|
type: z.string(),
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
9159
|
+
identifier_format: z.string().optional(),
|
|
9160
|
+
supported_events: z.array(z.string()),
|
|
9161
|
+
suggested_events: z.array(z.string()).optional(),
|
|
9162
|
+
match_fields: z.record(z.string(), eventMatchFieldSchema).optional()
|
|
9140
9163
|
}).strict();
|
|
9141
9164
|
const searchedNamespaceSchema = z.object({
|
|
9142
9165
|
namespace: z.string(),
|
|
9143
|
-
reach: z.record(z.string(),
|
|
9166
|
+
reach: z.record(z.string(), z.union([
|
|
9167
|
+
z.literal("all"),
|
|
9168
|
+
z.literal("resource"),
|
|
9169
|
+
z.object({ any_of: z.array(z.string()).min(1) }).strict()
|
|
9170
|
+
]))
|
|
9144
9171
|
}).strict();
|
|
9172
|
+
function agentReach(reach) {
|
|
9173
|
+
return typeof reach === "string" ? reach : { any_of: reach.anyOf.map(agentEventMatchKey) };
|
|
9174
|
+
}
|
|
9145
9175
|
const outputSchema$4 = juniorToolOutputSchema.extend({
|
|
9146
9176
|
query: z.string().nullable(),
|
|
9147
9177
|
namespace: z.string().nullable(),
|
|
9148
|
-
|
|
9149
|
-
|
|
9178
|
+
total_matches: z.number().int().nonnegative(),
|
|
9179
|
+
resource_types: z.array(searchedResourceTypeSchema),
|
|
9150
9180
|
namespaces: z.array(searchedNamespaceSchema)
|
|
9151
9181
|
}).strict();
|
|
9152
9182
|
function normalizeSearchText(value) {
|
|
@@ -9156,14 +9186,14 @@ function namespaceReach(catalog, resourceTypes) {
|
|
|
9156
9186
|
const events = /* @__PURE__ */ new Map();
|
|
9157
9187
|
for (const resourceType of resourceTypes) {
|
|
9158
9188
|
const set = events.get(resourceType.namespace) ?? /* @__PURE__ */ new Set();
|
|
9159
|
-
for (const eventType of resourceType.
|
|
9189
|
+
for (const eventType of resourceType.supported_events) set.add(eventType);
|
|
9160
9190
|
events.set(resourceType.namespace, set);
|
|
9161
9191
|
}
|
|
9162
9192
|
return [...events].map(([namespace, eventTypes]) => ({
|
|
9163
9193
|
namespace,
|
|
9164
9194
|
reach: Object.fromEntries([...eventTypes].sort().flatMap((eventType) => {
|
|
9165
9195
|
const reach = catalog[namespace]?.events[eventType]?.reach;
|
|
9166
|
-
return reach ? [[eventType, reach]] : [];
|
|
9196
|
+
return reach ? [[eventType, agentReach(reach)]] : [];
|
|
9167
9197
|
}))
|
|
9168
9198
|
}));
|
|
9169
9199
|
}
|
|
@@ -9171,10 +9201,10 @@ function searchableResourceTypes(catalog) {
|
|
|
9171
9201
|
return Object.entries(catalog).flatMap(([namespace, registration]) => registration.resourceTypes.map((resourceType) => ({
|
|
9172
9202
|
namespace,
|
|
9173
9203
|
type: resourceType.type,
|
|
9174
|
-
...resourceType.identifier ? {
|
|
9175
|
-
|
|
9176
|
-
...resourceType.suggestedEvents ? {
|
|
9177
|
-
...resourceType.matchFields ? {
|
|
9204
|
+
...resourceType.identifier ? { identifier_format: resourceType.identifier.format } : void 0,
|
|
9205
|
+
supported_events: [...resourceType.supportedEvents].sort(),
|
|
9206
|
+
...resourceType.suggestedEvents ? { suggested_events: [...resourceType.suggestedEvents].sort() } : void 0,
|
|
9207
|
+
...resourceType.matchFields ? { match_fields: agentEventKeys(resourceType.matchFields) } : void 0
|
|
9178
9208
|
}))).sort((left, right) => left.namespace.localeCompare(right.namespace) || left.type.localeCompare(right.type));
|
|
9179
9209
|
}
|
|
9180
9210
|
/** Create the read-only tool that searches enabled event types. */
|
|
@@ -9186,23 +9216,23 @@ function createSearchEventTypesTool(catalog) {
|
|
|
9186
9216
|
openWorldHint: false,
|
|
9187
9217
|
readOnlyHint: true
|
|
9188
9218
|
},
|
|
9189
|
-
description: "Search the event types currently enabled without creating anything. Use only when the user asks what events are supported or the required resource type or event name is unclear. Includes plugin resources and core Workspace snapshot events. namespaces gives the reach of each event. An event automation selects its events with match filters from the
|
|
9219
|
+
description: "Search the event types currently enabled without creating anything. Use only when the user asks what events are supported or the required resource type or event name is unclear. Includes plugin resources and core Workspace snapshot events. namespaces gives the reach of each event. An event automation selects its events with match filters from the match_fields of its namespace. With reach \"all\", match can be left out to run for every resource. With { any_of }, match must set at least one of those filters. With reach \"resource\", only watchEvents can use the event. Use watchEvents for temporary updates in the current conversation; use createAutomation with an event trigger for durable automation. This tool does not watch a resource, create an automation, or list concrete resources.",
|
|
9190
9220
|
inputSchema: z.object({
|
|
9191
9221
|
query: z.string().nullable().describe("Optional terms matching a namespace, resource type, or event name. Resource types that match more terms come first. Empty lists all enabled event types.").optional(),
|
|
9192
9222
|
namespace: eventNamespaceSchema(catalog).nullable().describe("Optional enabled plugin namespace to search within.").optional(),
|
|
9193
|
-
|
|
9223
|
+
max_results: z.number().int().min(1).max(MAX_SEARCH_RESULTS).nullable().describe("Maximum matching resource types to return.").optional()
|
|
9194
9224
|
}).strict(),
|
|
9195
9225
|
outputSchema: outputSchema$4,
|
|
9196
|
-
async execute({ query, namespace, maxResults }) {
|
|
9226
|
+
async execute({ query, namespace, max_results: maxResults }) {
|
|
9197
9227
|
const terms = normalizeSearchText(query ?? "").split(/\s+/).filter(Boolean);
|
|
9198
9228
|
const candidates = searchableResourceTypes(catalog).filter((resourceType) => !namespace || resourceType.namespace === namespace);
|
|
9199
9229
|
const matches = terms.length === 0 ? candidates : candidates.map((resourceType) => {
|
|
9200
9230
|
const text = normalizeSearchText([
|
|
9201
9231
|
resourceType.namespace,
|
|
9202
9232
|
resourceType.type,
|
|
9203
|
-
...resourceType.
|
|
9204
|
-
...resourceType.
|
|
9205
|
-
...Object.keys(resourceType.
|
|
9233
|
+
...resourceType.supported_events,
|
|
9234
|
+
...resourceType.suggested_events ?? [],
|
|
9235
|
+
...Object.keys(resourceType.match_fields ?? {})
|
|
9206
9236
|
].join(" "));
|
|
9207
9237
|
return {
|
|
9208
9238
|
resourceType,
|
|
@@ -9213,8 +9243,8 @@ function createSearchEventTypesTool(catalog) {
|
|
|
9213
9243
|
return {
|
|
9214
9244
|
query: query ?? null,
|
|
9215
9245
|
namespace: namespace ?? null,
|
|
9216
|
-
|
|
9217
|
-
resourceTypes,
|
|
9246
|
+
total_matches: matches.length,
|
|
9247
|
+
resource_types: resourceTypes,
|
|
9218
9248
|
namespaces: namespaceReach(catalog, resourceTypes)
|
|
9219
9249
|
};
|
|
9220
9250
|
}
|
|
@@ -9223,7 +9253,7 @@ function createSearchEventTypesTool(catalog) {
|
|
|
9223
9253
|
// src/chat/tools/stop-watches.ts
|
|
9224
9254
|
const resultDataSchema$1 = z.object({
|
|
9225
9255
|
watching_status: z.literal("stopped"),
|
|
9226
|
-
|
|
9256
|
+
stopped_ids: z.array(z.string().min(1))
|
|
9227
9257
|
}).strict();
|
|
9228
9258
|
const outputSchema$3 = juniorToolOutputSchema.merge(resultDataSchema$1);
|
|
9229
9259
|
/**
|
|
@@ -9271,7 +9301,7 @@ function createStopWatchingResourcesTool(context) {
|
|
|
9271
9301
|
}
|
|
9272
9302
|
return {
|
|
9273
9303
|
watching_status: "stopped",
|
|
9274
|
-
stoppedIds
|
|
9304
|
+
stopped_ids: stoppedIds
|
|
9275
9305
|
};
|
|
9276
9306
|
}
|
|
9277
9307
|
});
|
|
@@ -9288,25 +9318,26 @@ function createWatchTimerTool(context) {
|
|
|
9288
9318
|
},
|
|
9289
9319
|
description: "Wake this conversation once after a delay so you can check back later. Returns immediately. Timing is approximate. Use watchEvents instead when you can watch for the event.",
|
|
9290
9320
|
inputSchema: z.object({
|
|
9291
|
-
|
|
9321
|
+
after_ms: z.number().int().positive().max(RESOURCE_SUBSCRIPTION_MAX_TTL_MS - 864e5).describe("Delay in milliseconds, up to 29 days."),
|
|
9292
9322
|
intent: z.string().trim().min(1).max(1e3).describe("What to do when the timer fires.")
|
|
9293
9323
|
}).strict(),
|
|
9294
9324
|
outputSchema: z.object({
|
|
9295
9325
|
id: z.string(),
|
|
9296
|
-
|
|
9326
|
+
fires_at: z.string().datetime()
|
|
9297
9327
|
}).strict(),
|
|
9298
9328
|
async execute(input, options) {
|
|
9299
9329
|
if (!options.toolCallId) throw new Error("Timer creation requires a tool-call identity");
|
|
9300
9330
|
const creatorUserId = context.actor && context.actor.platform !== "system" ? context.actor.userId : void 0;
|
|
9301
9331
|
const watch = await createTimerWatch({
|
|
9302
|
-
|
|
9332
|
+
afterMs: input.after_ms,
|
|
9333
|
+
intent: input.intent,
|
|
9303
9334
|
conversationId: context.conversationId,
|
|
9304
9335
|
...creatorUserId ? { creatorUserId } : void 0,
|
|
9305
9336
|
toolCallId: options.toolCallId
|
|
9306
9337
|
});
|
|
9307
9338
|
return {
|
|
9308
9339
|
id: watch.id,
|
|
9309
|
-
|
|
9340
|
+
fires_at: new Date(watch.firesAtMs).toISOString()
|
|
9310
9341
|
};
|
|
9311
9342
|
}
|
|
9312
9343
|
});
|
|
@@ -9316,12 +9347,12 @@ function inputSchema(catalog) {
|
|
|
9316
9347
|
return z.object({
|
|
9317
9348
|
identifier: z.string().trim().min(1).describe("Plugin-defined resource identifier."),
|
|
9318
9349
|
namespace: eventNamespaceSchema(catalog).describe("Enabled plugin namespace for this resource."),
|
|
9319
|
-
|
|
9350
|
+
resource_type: registeredResourceTypeSchema(catalog).describe("Plugin-defined resource type."),
|
|
9320
9351
|
label: z.string().trim().min(1).max(500).describe("Human-readable resource label."),
|
|
9321
9352
|
events: z.array(registeredEventTypeSchema(catalog)).min(1).describe("High-signal event names to deliver to this conversation when they occur."),
|
|
9322
9353
|
match: registeredEventMatchSchema(),
|
|
9323
9354
|
intent: z.string().trim().min(1).max(4e3).describe("Concise reason this conversation wants these events, used when an event arrives."),
|
|
9324
|
-
|
|
9355
|
+
ttl_ms: z.coerce.number().describe("How long to keep the subscription active. Defaults to 14 days and must not exceed 30 days.").optional()
|
|
9325
9356
|
}).strict();
|
|
9326
9357
|
}
|
|
9327
9358
|
const stopWatchingActionSchema = z.object({
|
|
@@ -9341,7 +9372,7 @@ const resultDataSchema = z.object({
|
|
|
9341
9372
|
identifier: z.string().min(1),
|
|
9342
9373
|
events: z.array(z.string().min(1)).min(1),
|
|
9343
9374
|
match: z.record(z.string(), z.unknown()).optional(),
|
|
9344
|
-
|
|
9375
|
+
expires_at: z.string().datetime(),
|
|
9345
9376
|
stop_watching: stopWatchingActionSchema
|
|
9346
9377
|
}).strict();
|
|
9347
9378
|
const outputSchema$2 = juniorToolOutputSchema.merge(resultDataSchema);
|
|
@@ -9349,10 +9380,10 @@ function cleanStrings(values) {
|
|
|
9349
9380
|
return [...new Set(values.map((value) => value.trim()).filter(Boolean))];
|
|
9350
9381
|
}
|
|
9351
9382
|
function ttlMs(input) {
|
|
9352
|
-
if (input.
|
|
9353
|
-
if (!Number.isFinite(input.
|
|
9354
|
-
if (input.
|
|
9355
|
-
return input.
|
|
9383
|
+
if (input.ttl_ms === void 0) return RESOURCE_SUBSCRIPTION_DEFAULT_TTL_MS;
|
|
9384
|
+
if (!Number.isFinite(input.ttl_ms) || input.ttl_ms <= 0) throw new ToolInputError("ttl_ms must be a positive finite number");
|
|
9385
|
+
if (input.ttl_ms > 2592e6) throw new ToolInputError("Watches cannot exceed 30 days");
|
|
9386
|
+
return input.ttl_ms;
|
|
9356
9387
|
}
|
|
9357
9388
|
/** Create the tool that temporarily watches events in one conversation. */
|
|
9358
9389
|
function createWatchEventsTool(context, catalog) {
|
|
@@ -9367,16 +9398,16 @@ function createWatchEventsTool(context, catalog) {
|
|
|
9367
9398
|
inputSchema: inputSchema(catalog),
|
|
9368
9399
|
outputSchema: outputSchema$2,
|
|
9369
9400
|
async execute(input) {
|
|
9370
|
-
const unavailable = eventWatchUnavailable(catalog, input.namespace, input.
|
|
9401
|
+
const unavailable = eventWatchUnavailable(catalog, input.namespace, input.resource_type);
|
|
9371
9402
|
if (unavailable) throw new ToolInputError(unavailable);
|
|
9372
9403
|
const events = cleanStrings(input.events);
|
|
9373
9404
|
const intent = input.intent.trim();
|
|
9374
9405
|
if (!intent) throw new ToolInputError("intent is required");
|
|
9375
9406
|
const match = requireValidEventTrigger(catalog, {
|
|
9376
9407
|
events,
|
|
9377
|
-
match: input.match,
|
|
9408
|
+
match: input.match ? declaredEventKeys(input.match) : void 0,
|
|
9378
9409
|
namespace: input.namespace,
|
|
9379
|
-
resourceType: input.
|
|
9410
|
+
resourceType: input.resource_type
|
|
9380
9411
|
}, "watch");
|
|
9381
9412
|
const nowMs = Date.now();
|
|
9382
9413
|
const subscription = await createWatch({
|
|
@@ -9387,16 +9418,19 @@ function createWatchEventsTool(context, catalog) {
|
|
|
9387
9418
|
label: input.label.trim(),
|
|
9388
9419
|
...match ? { match } : void 0,
|
|
9389
9420
|
namespace: input.namespace.trim(),
|
|
9390
|
-
identifier: requireEventIdentifier(catalog,
|
|
9391
|
-
|
|
9421
|
+
identifier: requireEventIdentifier(catalog, {
|
|
9422
|
+
...input,
|
|
9423
|
+
resourceType: input.resource_type
|
|
9424
|
+
}),
|
|
9425
|
+
resourceType: input.resource_type.trim()
|
|
9392
9426
|
});
|
|
9393
9427
|
return {
|
|
9394
9428
|
id: subscription.id,
|
|
9395
9429
|
subscription_status: subscription.status,
|
|
9396
9430
|
identifier: subscription.identifier,
|
|
9397
9431
|
events: subscription.events,
|
|
9398
|
-
...subscription.match ? { match: subscription.match } : void 0,
|
|
9399
|
-
|
|
9432
|
+
...subscription.match ? { match: agentEventKeys(subscription.match) } : void 0,
|
|
9433
|
+
expires_at: new Date(subscription.expiresAtMs).toISOString(),
|
|
9400
9434
|
stop_watching: {
|
|
9401
9435
|
execution_tool: "executeTool",
|
|
9402
9436
|
execution_example: {
|
|
@@ -9670,14 +9704,14 @@ const compactEventAutomationResultSchema = z.object({
|
|
|
9670
9704
|
"paused",
|
|
9671
9705
|
"deleted"
|
|
9672
9706
|
]),
|
|
9673
|
-
|
|
9707
|
+
status_reason: z.string().nullable(),
|
|
9674
9708
|
title: z.string().min(1).nullable(),
|
|
9675
|
-
|
|
9709
|
+
dashboard_url: z.string().url().nullable(),
|
|
9676
9710
|
instruction: z.string().min(1),
|
|
9677
9711
|
trigger: z.object({
|
|
9678
9712
|
namespace: z.string().min(1),
|
|
9679
9713
|
identifier: z.string().min(1).nullable(),
|
|
9680
|
-
|
|
9714
|
+
resource_type: z.string().min(1).nullable(),
|
|
9681
9715
|
label: z.string().min(1),
|
|
9682
9716
|
events: z.array(z.string().min(1)).min(1),
|
|
9683
9717
|
match: z.record(z.string(), z.unknown()).optional(),
|
|
@@ -9689,8 +9723,8 @@ const compactEventAutomationResultSchema = z.object({
|
|
|
9689
9723
|
channel: z.string().min(1),
|
|
9690
9724
|
thread: z.string().min(1).nullable()
|
|
9691
9725
|
}).strict(),
|
|
9692
|
-
|
|
9693
|
-
|
|
9726
|
+
credential_mode: z.enum(["system", "creator"]),
|
|
9727
|
+
is_creator: z.boolean(),
|
|
9694
9728
|
outcomes: z.array(z.object({
|
|
9695
9729
|
action: z.literal("send_message"),
|
|
9696
9730
|
destination: z.object({
|
|
@@ -9698,7 +9732,7 @@ const compactEventAutomationResultSchema = z.object({
|
|
|
9698
9732
|
thread: z.string().min(1).nullable()
|
|
9699
9733
|
}).strict()
|
|
9700
9734
|
}).strict()).max(5),
|
|
9701
|
-
|
|
9735
|
+
created_by: z.object({
|
|
9702
9736
|
name: z.string().min(1).nullable(),
|
|
9703
9737
|
username: z.string().min(1).nullable()
|
|
9704
9738
|
}).strict()
|
|
@@ -9710,7 +9744,7 @@ function registeredEventAutomationTriggerSchema(catalog) {
|
|
|
9710
9744
|
namespace: eventNamespaceSchema(plugins),
|
|
9711
9745
|
label: z.string().trim().min(1).max(500),
|
|
9712
9746
|
events: z.array(registeredEventTypeSchema(plugins)).min(1),
|
|
9713
|
-
match: registeredEventMatchSchema().describe("Filters that select the events, from the
|
|
9747
|
+
match: registeredEventMatchSchema().describe("Filters that select the events, from the match_fields of the namespace. Use the match of a subscribable tool result to select one resource, such as { repo, pull_request } for one pull request. Leave it out to run for every resource, when the reach of each event allows that. A single value must equal the event data. A list means the event value may be any one entry. For a field with list: true, the event value is a list, and it matches when it includes the value or any entry.")
|
|
9714
9748
|
}).strict();
|
|
9715
9749
|
}
|
|
9716
9750
|
/**
|
|
@@ -9718,7 +9752,7 @@ function registeredEventAutomationTriggerSchema(catalog) {
|
|
|
9718
9752
|
* A filter that is left out keeps its saved value, so an update cannot make
|
|
9719
9753
|
* a trigger broader by leaving out a filter.
|
|
9720
9754
|
*/
|
|
9721
|
-
const eventMatchChangesSchema = z.record(
|
|
9755
|
+
const eventMatchChangesSchema = z.record(agentEventMatchSchema.keyType, z.union([agentEventMatchSchema.valueType, z.null()])).optional().describe("Filter changes, from the match_fields of the namespace. A value sets the filter, null removes it, and a filter that is left out keeps its saved value. When the namespace changes, the saved filters are dropped.");
|
|
9722
9756
|
/** Build the event trigger that the update tool accepts. */
|
|
9723
9757
|
function registeredEventAutomationTriggerChangesSchema(catalog) {
|
|
9724
9758
|
return registeredEventAutomationTriggerSchema(catalog).extend({ match: eventMatchChangesSchema });
|
|
@@ -9739,7 +9773,7 @@ function changedEventMatch(saved, namespace, changes) {
|
|
|
9739
9773
|
* The identifier gets its plugin's convention. Events and list values lose
|
|
9740
9774
|
* repeats.
|
|
9741
9775
|
*/
|
|
9742
|
-
function requireEventAutomationTrigger(catalog, input) {
|
|
9776
|
+
function requireEventAutomationTrigger(catalog, input, options) {
|
|
9743
9777
|
const identifier = input.identifier ?? void 0;
|
|
9744
9778
|
const resourceType = input.resourceType ?? void 0;
|
|
9745
9779
|
if (identifier === void 0 !== (resourceType === void 0)) throw new ToolInputError("Set both resourceType and identifier for one resource, or leave out both to run for every resource.");
|
|
@@ -9749,7 +9783,7 @@ function requireEventAutomationTrigger(catalog, input) {
|
|
|
9749
9783
|
resourceType,
|
|
9750
9784
|
events,
|
|
9751
9785
|
match: input.match
|
|
9752
|
-
}, "event_automation");
|
|
9786
|
+
}, "event_automation", options);
|
|
9753
9787
|
return {
|
|
9754
9788
|
namespace: input.namespace,
|
|
9755
9789
|
...identifier !== void 0 && resourceType !== void 0 ? {
|
|
@@ -9776,22 +9810,22 @@ function describeEventAutomationTrigger(trigger, catalog) {
|
|
|
9776
9810
|
}
|
|
9777
9811
|
/** Project an event automation into the bounded tool-result shape. */
|
|
9778
9812
|
function compactEventAutomation(task, catalog, isCreator) {
|
|
9779
|
-
const
|
|
9813
|
+
const problems = registeredEventTriggerProblems(automationEventCatalog(catalog), task.trigger, { inputKeys: true }).map((problem) => problem.message);
|
|
9780
9814
|
return compactEventAutomationResultSchema.parse({
|
|
9781
9815
|
type: "event",
|
|
9782
9816
|
id: task.id,
|
|
9783
9817
|
status: task.status,
|
|
9784
|
-
|
|
9818
|
+
status_reason: task.statusReason ?? null,
|
|
9785
9819
|
title: task.title?.trim() || null,
|
|
9786
|
-
|
|
9820
|
+
dashboard_url: getDashboardTaskLink(task.id) ?? null,
|
|
9787
9821
|
instruction: task.task.text,
|
|
9788
9822
|
trigger: {
|
|
9789
9823
|
namespace: task.trigger.namespace,
|
|
9790
9824
|
identifier: task.trigger.identifier ?? null,
|
|
9791
|
-
|
|
9825
|
+
resource_type: task.trigger.resourceType ?? null,
|
|
9792
9826
|
label: task.trigger.label,
|
|
9793
9827
|
events: task.trigger.events,
|
|
9794
|
-
...task.trigger.match ? { match: task.trigger.match } : void 0,
|
|
9828
|
+
...task.trigger.match ? { match: agentEventKeys(task.trigger.match) } : void 0,
|
|
9795
9829
|
available: problems.length === 0,
|
|
9796
9830
|
...problems.length > 0 ? { problems } : void 0
|
|
9797
9831
|
},
|
|
@@ -9800,8 +9834,8 @@ function compactEventAutomation(task, catalog, isCreator) {
|
|
|
9800
9834
|
channel: task.destination.channelId,
|
|
9801
9835
|
thread: null
|
|
9802
9836
|
},
|
|
9803
|
-
|
|
9804
|
-
isCreator,
|
|
9837
|
+
credential_mode: task.credentialMode,
|
|
9838
|
+
is_creator: isCreator,
|
|
9805
9839
|
outcomes: effectiveTaskOutcomes(task.outcomes, task.destination).map((outcome) => ({
|
|
9806
9840
|
action: outcome.action,
|
|
9807
9841
|
destination: {
|
|
@@ -9809,7 +9843,7 @@ function compactEventAutomation(task, catalog, isCreator) {
|
|
|
9809
9843
|
thread: outcome.destination.threadTs ?? null
|
|
9810
9844
|
}
|
|
9811
9845
|
})),
|
|
9812
|
-
|
|
9846
|
+
created_by: {
|
|
9813
9847
|
name: task.createdBy.fullName ?? null,
|
|
9814
9848
|
username: task.createdBy.userName ?? null
|
|
9815
9849
|
}
|
|
@@ -9828,7 +9862,7 @@ async function eventAutomationToolResult(conversationId, task, catalog, isCreato
|
|
|
9828
9862
|
label: title,
|
|
9829
9863
|
key: task.id,
|
|
9830
9864
|
title,
|
|
9831
|
-
url: automation.
|
|
9865
|
+
url: automation.dashboard_url,
|
|
9832
9866
|
description: task.task.text,
|
|
9833
9867
|
status: description.problems.length === 0 ? "ready" : "unavailable",
|
|
9834
9868
|
trigger: eventTriggerText(task.trigger.label, description),
|
|
@@ -9843,12 +9877,12 @@ function changesEventAutomationTrigger(current, next) {
|
|
|
9843
9877
|
return current.namespace !== next.namespace || current.identifier !== next.identifier || currentEvents.length !== nextEvents.length || currentEvents.some((event, index) => event !== nextEvents[index]) || stableEventMatchKey(current.match) !== stableEventMatchKey(next.match);
|
|
9844
9878
|
}
|
|
9845
9879
|
/** Build a validated edit while retaining an unchanged, possibly unavailable trigger. */
|
|
9846
|
-
async function editEventAutomation(current, input, isCreator, catalog) {
|
|
9880
|
+
async function editEventAutomation(current, input, isCreator, catalog, options) {
|
|
9847
9881
|
let trigger = current.trigger;
|
|
9848
9882
|
if (input.trigger !== void 0) {
|
|
9849
9883
|
const inputTrigger = slackChannelMessageTrigger(input.trigger, current.destination.channelId);
|
|
9850
9884
|
if (changesEventAutomationTrigger(current.trigger, inputTrigger) || current.trigger.resourceType !== inputTrigger.resourceType) try {
|
|
9851
|
-
trigger = requireEventAutomationTrigger(catalog, inputTrigger);
|
|
9885
|
+
trigger = requireEventAutomationTrigger(catalog, inputTrigger, options);
|
|
9852
9886
|
} catch (error) {
|
|
9853
9887
|
if (error instanceof ToolInputError) throw new AutomationEditError(error.message, "trigger");
|
|
9854
9888
|
throw error;
|
|
@@ -10445,7 +10479,7 @@ async function saveViewerEdit(user, current, input, restored) {
|
|
|
10445
10479
|
}, isCreator);
|
|
10446
10480
|
}
|
|
10447
10481
|
if (input.kind === "event" && current.kind === "event") {
|
|
10448
|
-
const next = await editEventAutomation(current.task, input, isCreator, getEventCatalog());
|
|
10482
|
+
const next = await editEventAutomation(current.task, input, isCreator, getEventCatalog(), { inputKeys: false });
|
|
10449
10483
|
const task = await saveEventAutomation(getDb(), restored ? {
|
|
10450
10484
|
...next,
|
|
10451
10485
|
title: restored.title
|
|
@@ -10827,21 +10861,21 @@ const compactTaskResultSchema = z.object({
|
|
|
10827
10861
|
"completed",
|
|
10828
10862
|
"deleted"
|
|
10829
10863
|
]),
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
|
|
10833
|
-
|
|
10864
|
+
status_reason: z.string().nullable(),
|
|
10865
|
+
created_at: z.string().datetime(),
|
|
10866
|
+
updated_at: z.string().datetime(),
|
|
10867
|
+
original_request: z.string().nullable(),
|
|
10834
10868
|
instruction: z.string(),
|
|
10835
10869
|
schedule: z.string(),
|
|
10836
10870
|
timezone: z.string(),
|
|
10837
10871
|
recurrence: z.unknown().nullable(),
|
|
10838
|
-
|
|
10872
|
+
next_run_at: z.string().nullable(),
|
|
10839
10873
|
destination: z.object({
|
|
10840
10874
|
id: z.string().min(1),
|
|
10841
10875
|
channel: z.string().min(1),
|
|
10842
10876
|
thread: z.string().min(1).nullable()
|
|
10843
10877
|
}).strict(),
|
|
10844
|
-
|
|
10878
|
+
conversation_access: z.object({
|
|
10845
10879
|
audience: z.enum([
|
|
10846
10880
|
"direct",
|
|
10847
10881
|
"group",
|
|
@@ -10849,9 +10883,9 @@ const compactTaskResultSchema = z.object({
|
|
|
10849
10883
|
]),
|
|
10850
10884
|
visibility: z.enum(["private", "public"])
|
|
10851
10885
|
}).strict(),
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10886
|
+
credential_mode: z.enum(["system", "creator"]),
|
|
10887
|
+
is_creator: z.boolean(),
|
|
10888
|
+
created_by: z.object({
|
|
10855
10889
|
name: z.string().min(1).nullable(),
|
|
10856
10890
|
username: z.string().min(1).nullable()
|
|
10857
10891
|
}).strict(),
|
|
@@ -10862,9 +10896,9 @@ const compactTaskResultSchema = z.object({
|
|
|
10862
10896
|
thread: z.string().min(1).nullable()
|
|
10863
10897
|
}).strict()
|
|
10864
10898
|
}).strict()).max(5),
|
|
10865
|
-
|
|
10866
|
-
|
|
10867
|
-
|
|
10899
|
+
dashboard_url: z.string().url().nullable(),
|
|
10900
|
+
last_run_at: z.string().nullable(),
|
|
10901
|
+
run_now_at: z.string().nullable()
|
|
10868
10902
|
}).strict();
|
|
10869
10903
|
/**
|
|
10870
10904
|
* Return the access class of a Destination. A DM is direct and a group DM is
|
|
@@ -10891,32 +10925,32 @@ function compactTask(task, isCreator) {
|
|
|
10891
10925
|
id: task.id,
|
|
10892
10926
|
title: task.title?.trim() || null,
|
|
10893
10927
|
status: task.status,
|
|
10894
|
-
|
|
10895
|
-
|
|
10896
|
-
|
|
10897
|
-
|
|
10928
|
+
status_reason: task.statusReason ?? null,
|
|
10929
|
+
created_at: new Date(task.createdAtMs).toISOString(),
|
|
10930
|
+
updated_at: new Date(task.updatedAtMs).toISOString(),
|
|
10931
|
+
original_request: task.originalRequest ?? null,
|
|
10898
10932
|
instruction: task.task.text,
|
|
10899
10933
|
schedule: task.schedule.description,
|
|
10900
10934
|
timezone: task.schedule.timezone,
|
|
10901
10935
|
recurrence: task.schedule.recurrence ? {
|
|
10902
10936
|
frequency: task.schedule.recurrence.frequency,
|
|
10903
10937
|
interval: task.schedule.recurrence.interval,
|
|
10904
|
-
|
|
10938
|
+
start_date: task.schedule.recurrence.startDate,
|
|
10905
10939
|
time: task.schedule.recurrence.time,
|
|
10906
10940
|
weekdays: task.schedule.recurrence.weekdays,
|
|
10907
10941
|
month: task.schedule.recurrence.month,
|
|
10908
|
-
|
|
10942
|
+
day_of_month: task.schedule.recurrence.dayOfMonth
|
|
10909
10943
|
} : null,
|
|
10910
|
-
|
|
10944
|
+
next_run_at: task.nextRunAtMs ? new Date(task.nextRunAtMs).toISOString() : null,
|
|
10911
10945
|
destination: {
|
|
10912
10946
|
id: destinationFilterValue(task.destination),
|
|
10913
10947
|
channel: task.destination.channelId,
|
|
10914
10948
|
thread: null
|
|
10915
10949
|
},
|
|
10916
|
-
|
|
10917
|
-
|
|
10918
|
-
isCreator,
|
|
10919
|
-
|
|
10950
|
+
conversation_access: task.conversationAccess,
|
|
10951
|
+
credential_mode: task.credentialMode,
|
|
10952
|
+
is_creator: isCreator,
|
|
10953
|
+
created_by: {
|
|
10920
10954
|
name: task.createdBy.fullName ?? null,
|
|
10921
10955
|
username: task.createdBy.userName ?? null
|
|
10922
10956
|
},
|
|
@@ -10927,9 +10961,9 @@ function compactTask(task, isCreator) {
|
|
|
10927
10961
|
thread: outcome.destination.threadTs ?? null
|
|
10928
10962
|
}
|
|
10929
10963
|
})),
|
|
10930
|
-
|
|
10931
|
-
|
|
10932
|
-
|
|
10964
|
+
dashboard_url: getDashboardTaskLink(task.id) ?? null,
|
|
10965
|
+
last_run_at: task.lastRunAtMs ? new Date(task.lastRunAtMs).toISOString() : null,
|
|
10966
|
+
run_now_at: task.runNowAtMs ? new Date(task.runNowAtMs).toISOString() : null
|
|
10933
10967
|
});
|
|
10934
10968
|
}
|
|
10935
10969
|
/** Build the result of a tool that changed one scheduled automation, with its card. */
|
|
@@ -10942,7 +10976,7 @@ async function scheduleAutomationToolResult(conversationId, task, isCreator) {
|
|
|
10942
10976
|
label: title,
|
|
10943
10977
|
key: task.id,
|
|
10944
10978
|
title,
|
|
10945
|
-
url: automation.
|
|
10979
|
+
url: automation.dashboard_url,
|
|
10946
10980
|
description: automation.instruction,
|
|
10947
10981
|
status: automation.status,
|
|
10948
10982
|
trigger: task.schedule.kind === "one_off" && task.nextRunAtMs !== void 0 ? `${new Intl.DateTimeFormat("en-US", {
|
|
@@ -10950,7 +10984,7 @@ async function scheduleAutomationToolResult(conversationId, task, isCreator) {
|
|
|
10950
10984
|
timeStyle: "short",
|
|
10951
10985
|
timeZone: task.schedule.timezone
|
|
10952
10986
|
}).format(task.nextRunAtMs)} · ${task.schedule.timezone}` : automation.schedule,
|
|
10953
|
-
warning: automation.status === "blocked" ? automation.
|
|
10987
|
+
warning: automation.status === "blocked" ? automation.status_reason ?? "This automation is blocked." : automation.status === "completed" ? "This automation has completed." : void 0
|
|
10954
10988
|
};
|
|
10955
10989
|
return {
|
|
10956
10990
|
automation,
|
|
@@ -10972,7 +11006,7 @@ const automationSearchResultSchema = juniorToolOutputSchema.extend({
|
|
|
10972
11006
|
}).strict();
|
|
10973
11007
|
const scheduleTriggerSchema = z.object({
|
|
10974
11008
|
type: z.literal("schedule"),
|
|
10975
|
-
schedule:
|
|
11009
|
+
schedule: toolScheduleIntentSchema.describe("When the automation runs. The scheduler computes the exact next run from this intent and the server clock.")
|
|
10976
11010
|
}).strict();
|
|
10977
11011
|
/**
|
|
10978
11012
|
* Build the trigger input of the create tool: a schedule, or the events of an
|
|
@@ -11071,7 +11105,7 @@ async function compileSchedule(caller, creator, destination, trigger, nowMs) {
|
|
|
11071
11105
|
try {
|
|
11072
11106
|
return compileScheduleIntent({
|
|
11073
11107
|
defaultTimezone: timezone,
|
|
11074
|
-
intent: trigger.schedule,
|
|
11108
|
+
intent: scheduleIntentFromTool(trigger.schedule),
|
|
11075
11109
|
nowMs
|
|
11076
11110
|
});
|
|
11077
11111
|
} catch (error) {
|
|
@@ -11161,12 +11195,12 @@ function createAutomationTool(context, catalog) {
|
|
|
11161
11195
|
title: z.string().trim().min(1).max(60).nullable().describe("Optional short display title. Omit or use null to generate one from the instruction.").optional(),
|
|
11162
11196
|
trigger,
|
|
11163
11197
|
outcomes: z.array(taskOutcomeInputSchema).max(5).describe("Successful work is silent by default. Omit this field or use an empty list when the Automation should act through tools without a status message. Add send_message only when the user asks for a reminder, notification, post, digest, summary, or other visible result.").optional(),
|
|
11164
|
-
|
|
11198
|
+
credential_mode: z.enum(["creator", "system"]).nullable().describe("Use creator to make the creator's connected credentials available, or system when the creator says not to use them. Omit or use null for the creator default.").optional()
|
|
11165
11199
|
}).strict(),
|
|
11166
11200
|
prepareArguments(args) {
|
|
11167
11201
|
const prepared = { ...args };
|
|
11168
11202
|
if (prepared.title == null) delete prepared.title;
|
|
11169
|
-
if (prepared.
|
|
11203
|
+
if (prepared.credential_mode === "creator" || prepared.credential_mode === null) delete prepared.credential_mode;
|
|
11170
11204
|
return prepared;
|
|
11171
11205
|
},
|
|
11172
11206
|
outputSchema: automationToolResultSchema,
|
|
@@ -11180,7 +11214,10 @@ function createAutomationTool(context, catalog) {
|
|
|
11180
11214
|
creator: createdBy,
|
|
11181
11215
|
destinationChannelId: destination.channelId
|
|
11182
11216
|
});
|
|
11183
|
-
const eventTrigger = input.trigger.type === "event" ? requireEventAutomationTrigger(catalog, slackChannelMessageTrigger(
|
|
11217
|
+
const eventTrigger = input.trigger.type === "event" ? requireEventAutomationTrigger(catalog, slackChannelMessageTrigger({
|
|
11218
|
+
...input.trigger,
|
|
11219
|
+
match: input.trigger.match ? declaredEventKeys(input.trigger.match) : void 0
|
|
11220
|
+
}, destination.channelId)) : void 0;
|
|
11184
11221
|
const toolCallId = options.toolCallId?.trim();
|
|
11185
11222
|
if (!toolCallId) throw new Error("Automation creation requires a tool-call identity.");
|
|
11186
11223
|
const id = automationIdForToolCall({
|
|
@@ -11203,7 +11240,7 @@ function createAutomationTool(context, catalog) {
|
|
|
11203
11240
|
id,
|
|
11204
11241
|
instruction: input.instruction,
|
|
11205
11242
|
nowMs,
|
|
11206
|
-
credentialMode: input.
|
|
11243
|
+
credentialMode: input.credential_mode ?? "creator",
|
|
11207
11244
|
outcomes: await resolveTaskOutcomes(input.outcomes, destination, createdBy.slackUserId),
|
|
11208
11245
|
title: await resolveTaskTitle({
|
|
11209
11246
|
signal: options.signal,
|
|
@@ -11229,9 +11266,9 @@ function createDeleteAutomationTool(context, catalog) {
|
|
|
11229
11266
|
},
|
|
11230
11267
|
executionMode: "sequential",
|
|
11231
11268
|
description: "Delete one scheduled or event automation. Anyone in the workspace can delete an automation in a public channel. Automations in private channels and DMs can be deleted from there or by their creator.",
|
|
11232
|
-
inputSchema: z.object({
|
|
11269
|
+
inputSchema: z.object({ automation_id: z.string().min(1).describe("ID of the automation to delete, from searchAutomations or its dashboard URL.") }).strict(),
|
|
11233
11270
|
outputSchema: automationToolResultSchema.omit({ objectCards: true }).extend({ removedCards: z.array(removedCardSchema) }),
|
|
11234
|
-
async execute({ automationId }) {
|
|
11271
|
+
async execute({ automation_id: automationId }) {
|
|
11235
11272
|
const current = await requireToolAutomation(await requireToolCaller(context), automationId);
|
|
11236
11273
|
return {
|
|
11237
11274
|
automation: compactAutomation(await deleteToolAutomation(context.conversationId, current), catalog),
|
|
@@ -11256,9 +11293,9 @@ function createRunAutomationNowTool(context, catalog) {
|
|
|
11256
11293
|
},
|
|
11257
11294
|
executionMode: "sequential",
|
|
11258
11295
|
description: "Queue an existing active scheduled automation to run as soon as possible, without changing its schedule. Use when the user asks to run it now. Anyone who can manage the automation can run it. When it uses its creator's credentials, only the creator can run it now. Event automations run only when a matching event arrives, so they cannot run now.",
|
|
11259
|
-
inputSchema: z.object({
|
|
11296
|
+
inputSchema: z.object({ automation_id: z.string().min(1).describe("ID of the active scheduled automation to run now, from searchAutomations or its dashboard URL.") }).strict(),
|
|
11260
11297
|
outputSchema: automationToolResultSchema.omit({ objectCards: true }),
|
|
11261
|
-
async execute({ automationId }) {
|
|
11298
|
+
async execute({ automation_id: automationId }) {
|
|
11262
11299
|
const current = await requireToolAutomation(await requireToolCaller(context), automationId);
|
|
11263
11300
|
if (current.kind !== "scheduled") throw new ToolInputError("Only scheduled automations can run now. Event automations run when a matching event arrives.");
|
|
11264
11301
|
const { task, ownedByViewer } = current;
|
|
@@ -11292,7 +11329,7 @@ function createSearchAutomationsTool(context, catalog) {
|
|
|
11292
11329
|
openWorldHint: false,
|
|
11293
11330
|
readOnlyHint: true
|
|
11294
11331
|
},
|
|
11295
|
-
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 has its type and says whether the requester is the creator (
|
|
11332
|
+
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 has its type and 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.",
|
|
11296
11333
|
inputSchema: automationSearchInputSchema,
|
|
11297
11334
|
outputSchema: automationSearchResultSchema,
|
|
11298
11335
|
async execute(input) {
|
|
@@ -11589,13 +11626,13 @@ async function updateScheduled(context, current, input, editor) {
|
|
|
11589
11626
|
const target = input.destination ? await requireMoveDestination(context, input.destination) : void 0;
|
|
11590
11627
|
const destination = target?.destination;
|
|
11591
11628
|
const moving = destination !== void 0 && !sameDestination(task.destination, destination);
|
|
11592
|
-
if (destination && !moving && Object.keys(input).every((key) => key === "destination" || key === "
|
|
11629
|
+
if (destination && !moving && Object.keys(input).every((key) => key === "destination" || key === "credential_mode" && input.credential_mode === task.credentialMode)) return current;
|
|
11593
11630
|
if (moving) await requireNoIncompleteRun(task.id);
|
|
11594
11631
|
const next = await editScheduledAutomation(task, {
|
|
11595
11632
|
title: input.title,
|
|
11596
11633
|
instruction: input.instruction,
|
|
11597
|
-
schedule: input.trigger?.type === "schedule" ? input.trigger.schedule : void 0,
|
|
11598
|
-
credentialMode: input.
|
|
11634
|
+
schedule: input.trigger?.type === "schedule" ? scheduleIntentFromTool(input.trigger.schedule) : void 0,
|
|
11635
|
+
credentialMode: input.credential_mode,
|
|
11599
11636
|
outcomes: moving ? void 0 : input.outcomes
|
|
11600
11637
|
}, isCreator, context.now?.() ?? Date.now());
|
|
11601
11638
|
if (moving) {
|
|
@@ -11624,10 +11661,10 @@ async function updateEvent(current, input, editor, catalog) {
|
|
|
11624
11661
|
identifier: task.trigger.identifier,
|
|
11625
11662
|
resourceType: task.trigger.resourceType
|
|
11626
11663
|
} : void 0,
|
|
11627
|
-
match: changedEventMatch(task.trigger, trigger.namespace, trigger.match)
|
|
11664
|
+
match: changedEventMatch(task.trigger, trigger.namespace, trigger.match ? declaredEventKeys(trigger.match) : void 0)
|
|
11628
11665
|
} : void 0,
|
|
11629
11666
|
outcomes: input.outcomes,
|
|
11630
|
-
credentialMode: input.
|
|
11667
|
+
credentialMode: input.credential_mode
|
|
11631
11668
|
}, current.ownedByViewer, catalog);
|
|
11632
11669
|
const saved = await saveEventAutomation(getDb(), next, automationRevision(task), editor);
|
|
11633
11670
|
if (!saved) throw new ToolInputError("Automation was not found.");
|
|
@@ -11650,12 +11687,12 @@ function createUpdateAutomationTool(context, catalog) {
|
|
|
11650
11687
|
executionMode: "sequential",
|
|
11651
11688
|
description: "Update the title, instruction, trigger, outcomes, credential use, or status of a scheduled or event automation. Anyone in the workspace can update anything on an automation in a public channel, including its outcomes and destination. Automations in private channels and DMs can be updated from there or by their creator, and only their creator can move them. Only the creator can enable creator credentials. A non-creator who changes the instruction, trigger, outcomes, or destination switches it to system credentials. The trigger type cannot change. Set destination to move a scheduled automation to this conversation or to a public channel.",
|
|
11652
11689
|
inputSchema: z.object({
|
|
11653
|
-
|
|
11690
|
+
automation_id: z.string().min(1).describe("ID of the automation, from searchAutomations or its dashboard URL."),
|
|
11654
11691
|
title: automationTitleSchema.optional(),
|
|
11655
11692
|
instruction: automationInstructionToolSchema.nullable().optional(),
|
|
11656
11693
|
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(),
|
|
11657
11694
|
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(),
|
|
11658
|
-
|
|
11695
|
+
credential_mode: z.enum(["system", "creator"]).nullable().describe("Set creator to make the automation creator's credentials available, or system to disable them. Creator always means the automation's createdBy actor, never the current requester. Only that creator may enable creator mode. Omit or use null to leave unchanged.").optional(),
|
|
11659
11696
|
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(),
|
|
11660
11697
|
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()
|
|
11661
11698
|
}).strict(),
|
|
@@ -11663,11 +11700,11 @@ function createUpdateAutomationTool(context, catalog) {
|
|
|
11663
11700
|
return Object.fromEntries(Object.entries(args).filter(([, value]) => value != null));
|
|
11664
11701
|
},
|
|
11665
11702
|
outputSchema: automationToolResultSchema,
|
|
11666
|
-
async execute({
|
|
11703
|
+
async execute({ automation_id, status: requestedStatus, ...fields }) {
|
|
11667
11704
|
const input = fields;
|
|
11668
11705
|
const status = requestedStatus ?? void 0;
|
|
11669
11706
|
const caller = await requireToolCaller(context);
|
|
11670
|
-
const current = await requireToolAutomation(caller,
|
|
11707
|
+
const current = await requireToolAutomation(caller, automation_id);
|
|
11671
11708
|
if (input.trigger && triggerKind(input.trigger) !== current.kind) throw new ToolInputError(`This automation runs on ${current.kind === "scheduled" ? "a schedule" : "events"}. The trigger type cannot change. Create a new automation instead.`);
|
|
11672
11709
|
if (Object.keys(input).length === 0 && status === void 0) throw new ToolInputError("Automation update requires a change.");
|
|
11673
11710
|
if (current.kind === "scheduled" && current.task.status === "completed") throw new ToolInputError("Completed scheduled automations cannot be updated. Create a new automation instead.");
|
|
@@ -12284,6 +12321,10 @@ const slackSearchFileWireSchema = z.object({
|
|
|
12284
12321
|
...value.content ?? value.preview ? { content: value.content ?? value.preview } : void 0
|
|
12285
12322
|
};
|
|
12286
12323
|
});
|
|
12324
|
+
/** Read the channel ID from a Slack archive permalink such as `/archives/C123`. */
|
|
12325
|
+
function channelIdFromPermalink(permalink) {
|
|
12326
|
+
return permalink?.match(/\/archives\/([A-Z0-9]+)(?:[/?#]|$)/)?.[1];
|
|
12327
|
+
}
|
|
12287
12328
|
/** Slack wire shape for one search channel. */
|
|
12288
12329
|
const slackSearchChannelWireSchema = z.object({
|
|
12289
12330
|
id: optionalWireString,
|
|
@@ -12296,7 +12337,7 @@ const slackSearchChannelWireSchema = z.object({
|
|
|
12296
12337
|
purpose: optionalWireString,
|
|
12297
12338
|
permalink: optionalWireUrl
|
|
12298
12339
|
}).transform((value) => {
|
|
12299
|
-
const channelId = value.channel_id ?? value.id;
|
|
12340
|
+
const channelId = value.channel_id ?? value.id ?? channelIdFromPermalink(value.permalink);
|
|
12300
12341
|
if (!channelId) return;
|
|
12301
12342
|
return {
|
|
12302
12343
|
channel_id: channelId,
|
|
@@ -12973,7 +13014,7 @@ function normalizeFiles(files) {
|
|
|
12973
13014
|
return files.map((file) => ({
|
|
12974
13015
|
path: file.path,
|
|
12975
13016
|
...file.filename ? { filename: file.filename } : void 0,
|
|
12976
|
-
...file.
|
|
13017
|
+
...file.mime_type ? { mime_type: file.mime_type } : void 0
|
|
12977
13018
|
}));
|
|
12978
13019
|
}
|
|
12979
13020
|
/** Include file bytes in idempotency so rewritten paths can be sent again. */
|
|
@@ -13420,8 +13461,8 @@ function prepareCanvasEditArguments(input) {
|
|
|
13420
13461
|
return prepareTextReplacementArguments(input);
|
|
13421
13462
|
}
|
|
13422
13463
|
const editReplacementSchema = z.object({
|
|
13423
|
-
|
|
13424
|
-
|
|
13464
|
+
old_text: z.string().min(1).describe("Exact Canvas markdown to replace. It must be unique in the current Canvas body and must not overlap another edit."),
|
|
13465
|
+
new_text: z.string().describe("Replacement Canvas markdown for this edit.")
|
|
13425
13466
|
});
|
|
13426
13467
|
const slackCanvasEditOutputSchema = juniorToolOutputSchema.extend({
|
|
13427
13468
|
canvas_id: z.string().optional(),
|
|
@@ -14212,7 +14253,7 @@ function sanitizeMessage(msg, attachmentIdsBySlackFileId) {
|
|
|
14212
14253
|
const attachmentText = renderAttachmentText(msg.attachments);
|
|
14213
14254
|
const files = collectMessageFiles(msg);
|
|
14214
14255
|
return {
|
|
14215
|
-
|
|
14256
|
+
slack_ts: msg.ts,
|
|
14216
14257
|
user: msg.user,
|
|
14217
14258
|
text: msg.text,
|
|
14218
14259
|
thread_ts: msg.thread_ts,
|
|
@@ -14284,12 +14325,12 @@ function createSlackThreadReadTool(context, attachmentDeps) {
|
|
|
14284
14325
|
inputSchema: z.object({
|
|
14285
14326
|
url: z.string().min(1).describe("Slack message archive URL.").nullable().optional(),
|
|
14286
14327
|
channel_id: slackChannelRefParam.nullable().optional(),
|
|
14287
|
-
|
|
14328
|
+
slack_ts: slackTimestampParam("Slack message timestamp. May be the thread root or any message in the thread.").nullable().optional(),
|
|
14288
14329
|
limit: z.coerce.number().int().min(1).max(1e3).describe("Maximum number of thread messages to fetch.").nullable().optional(),
|
|
14289
14330
|
max_pages: z.coerce.number().int().min(1).max(10).describe("Maximum number of Slack API pages to traverse.").nullable().optional()
|
|
14290
14331
|
}),
|
|
14291
14332
|
outputSchema: juniorToolOutputSchema,
|
|
14292
|
-
execute: async ({ url, channel_id,
|
|
14333
|
+
execute: async ({ url, channel_id, slack_ts, limit, max_pages }) => {
|
|
14293
14334
|
let channelId;
|
|
14294
14335
|
let messageTs;
|
|
14295
14336
|
let threadTs;
|
|
@@ -14299,8 +14340,8 @@ function createSlackThreadReadTool(context, attachmentDeps) {
|
|
|
14299
14340
|
channelId = parsed.reference.channelId;
|
|
14300
14341
|
messageTs = parsed.reference.messageTs;
|
|
14301
14342
|
threadTs = parsed.reference.threadTs;
|
|
14302
|
-
} else if (channel_id &&
|
|
14303
|
-
const parsedTs = parseRequiredSlackTimestampParam("
|
|
14343
|
+
} else if (channel_id && slack_ts) {
|
|
14344
|
+
const parsedTs = parseRequiredSlackTimestampParam("slack_ts", slack_ts);
|
|
14304
14345
|
if (!parsedTs.ok) throw new ToolInputError(parsedTs.error);
|
|
14305
14346
|
channelId = (await resolveSlackChannelRef({
|
|
14306
14347
|
field: "channel_id",
|
|
@@ -14308,7 +14349,7 @@ function createSlackThreadReadTool(context, attachmentDeps) {
|
|
|
14308
14349
|
teamId: context.teamId
|
|
14309
14350
|
})).channelId;
|
|
14310
14351
|
messageTs = parsedTs.value;
|
|
14311
|
-
} else throw new ToolInputError("Provide either a Slack message `url` or both `channel_id` and `
|
|
14352
|
+
} else throw new ToolInputError("Provide either a Slack message `url` or both `channel_id` and `slack_ts`.");
|
|
14312
14353
|
const access = await checkSlackChannelReadAccess({
|
|
14313
14354
|
currentChannelIds: [context.destinationChannelId, context.locationChannelId],
|
|
14314
14355
|
targetChannelId: channelId,
|
|
@@ -14676,7 +14717,7 @@ function createUserLookupTool(teamId, providers) {
|
|
|
14676
14717
|
// src/chat/tools/system-time.ts
|
|
14677
14718
|
const systemTimeInputSchema = z.object({ timezone: z.string().trim().min(1).optional().describe("Optional IANA timezone, for example America/Los_Angeles. When set, iso_local and timezone_offset_minutes are for that zone.") });
|
|
14678
14719
|
const systemTimeOutputSchema = juniorToolOutputSchema.extend({
|
|
14679
|
-
unix_ms: z.number(),
|
|
14720
|
+
unix_ms: z.number().describe("Current time in epoch milliseconds, for millisecond inputs."),
|
|
14680
14721
|
iso_utc: z.string(),
|
|
14681
14722
|
iso_local: z.string(),
|
|
14682
14723
|
timezone: z.string().nullable(),
|
|
@@ -15462,6 +15503,7 @@ async function searchConversationBriefs(db, args) {
|
|
|
15462
15503
|
const conditions = [
|
|
15463
15504
|
notExists(db.select({ one: sql`1` }).from(newer).where(and(eq(newer.conversationId, briefs.conversationId), gt(newer.version, briefs.version)))),
|
|
15464
15505
|
isNull(juniorConversations.parentConversationId),
|
|
15506
|
+
isNull(juniorConversations.quickQuestionAt),
|
|
15465
15507
|
ne(juniorConversations.conversationId, args.currentConversationId),
|
|
15466
15508
|
eq(juniorDestinations.visibility, "public")
|
|
15467
15509
|
];
|
|
@@ -16790,7 +16832,7 @@ function buildSandboxInput(toolName, params) {
|
|
|
16790
16832
|
command: String(params.command ?? ""),
|
|
16791
16833
|
...typeof params.cwd === "string" ? { cwd: params.cwd } : void 0,
|
|
16792
16834
|
...params.env && typeof params.env === "object" && !Array.isArray(params.env) ? { env: params.env } : void 0,
|
|
16793
|
-
...optionalNumber(params.
|
|
16835
|
+
...optionalNumber(params.timeout_ms) ? { timeoutMs: optionalNumber(params.timeout_ms) } : void 0
|
|
16794
16836
|
};
|
|
16795
16837
|
if (toolName === "readFile") return {
|
|
16796
16838
|
path: String(params.path ?? ""),
|
|
@@ -16805,7 +16847,7 @@ function buildSandboxInput(toolName, params) {
|
|
|
16805
16847
|
pattern: String(params.pattern ?? ""),
|
|
16806
16848
|
...typeof params.path === "string" ? { path: params.path } : void 0,
|
|
16807
16849
|
...typeof params.glob === "string" ? { glob: params.glob } : void 0,
|
|
16808
|
-
...typeof params.
|
|
16850
|
+
...typeof params.ignore_case === "boolean" ? { ignoreCase: params.ignore_case } : void 0,
|
|
16809
16851
|
...typeof params.literal === "boolean" ? { literal: params.literal } : void 0,
|
|
16810
16852
|
...optionalNumber(params.context) ? { context: optionalNumber(params.context) } : void 0,
|
|
16811
16853
|
...optionalNumber(params.limit) ? { limit: optionalNumber(params.limit) } : void 0
|
|
@@ -18787,13 +18829,26 @@ async function deleteMcpAuthSessionsForUserProvider(userId, provider) {
|
|
|
18787
18829
|
await stateAdapter.delete(indexKey);
|
|
18788
18830
|
}
|
|
18789
18831
|
async function getMcpStoredOAuthCredentials(userId, provider) {
|
|
18790
|
-
|
|
18832
|
+
const stateAdapter = await getConnectedStateAdapter();
|
|
18833
|
+
const stored = parseStoredCredentials(await stateAdapter.get(credentialsKey(userId, provider)));
|
|
18834
|
+
if (stored) return stored;
|
|
18835
|
+
const legacyUserId = await findLegacyWebActorUserId(userId);
|
|
18836
|
+
if (!legacyUserId) return void 0;
|
|
18837
|
+
const legacyKey = credentialsKey(legacyUserId, provider);
|
|
18838
|
+
const legacy = parseStoredCredentials(await stateAdapter.get(legacyKey));
|
|
18839
|
+
if (!legacy) return void 0;
|
|
18840
|
+
await putMcpStoredOAuthCredentials(userId, provider, legacy);
|
|
18841
|
+
await stateAdapter.delete(legacyKey);
|
|
18842
|
+
return legacy;
|
|
18791
18843
|
}
|
|
18792
18844
|
async function putMcpStoredOAuthCredentials(userId, provider, value, ttlMs = MCP_AUTH_CREDENTIALS_TTL_MS) {
|
|
18793
18845
|
await (await getConnectedStateAdapter()).set(credentialsKey(userId, provider), JSON.stringify(value), ttlMs);
|
|
18794
18846
|
}
|
|
18795
18847
|
async function deleteMcpStoredOAuthCredentials(userId, provider) {
|
|
18796
|
-
|
|
18848
|
+
const stateAdapter = await getConnectedStateAdapter();
|
|
18849
|
+
await stateAdapter.delete(credentialsKey(userId, provider));
|
|
18850
|
+
const legacyUserId = await findLegacyWebActorUserId(userId);
|
|
18851
|
+
if (legacyUserId) await stateAdapter.delete(credentialsKey(legacyUserId, provider));
|
|
18797
18852
|
}
|
|
18798
18853
|
async function getMcpServerSessionId(userId, provider) {
|
|
18799
18854
|
return parseServerSession(await (await getConnectedStateAdapter()).get(serverSessionKey(userId, provider)))?.sessionId;
|
|
@@ -20724,6 +20779,14 @@ function renderCompactionSummary(summary) {
|
|
|
20724
20779
|
function estimateHistoryTokens(messages) {
|
|
20725
20780
|
return estimateContextTokens(messages).tokens;
|
|
20726
20781
|
}
|
|
20782
|
+
/**
|
|
20783
|
+
* Estimate a replacement request from each message's own size. A kept
|
|
20784
|
+
* assistant message holds provider usage for the whole request before the
|
|
20785
|
+
* replacement, so usage is ignored here.
|
|
20786
|
+
*/
|
|
20787
|
+
function estimateReplacementTokens(messages, requestOverheadTokens = 0) {
|
|
20788
|
+
return messages.reduce((total, message) => total + estimateTokens(message), requestOverheadTokens);
|
|
20789
|
+
}
|
|
20727
20790
|
async function loadLastInstruction(conversationId) {
|
|
20728
20791
|
const event = await getConversationEventStore().loadLatestInstruction(conversationId);
|
|
20729
20792
|
if (!event) return void 0;
|
|
@@ -20857,7 +20920,7 @@ async function compactActiveAboveThreshold(args, summarize, source, triggerToken
|
|
|
20857
20920
|
];
|
|
20858
20921
|
const retainedMessageCount = retainedUserMessages.length + instructionMessages.length;
|
|
20859
20922
|
const messages = replacement.map((entry) => entry.message);
|
|
20860
|
-
const replacementInputTokens =
|
|
20923
|
+
const replacementInputTokens = estimateReplacementTokens(messages, args.requestOverheadTokens);
|
|
20861
20924
|
if (replacementInputTokens >= inputLimitTokens) throw new ContextInputLimitExceededError(replacementInputTokens, inputLimitTokens);
|
|
20862
20925
|
args.signal?.throwIfAborted();
|
|
20863
20926
|
await getConversationEventStore().replaceHistory(args.conversationId, {
|
|
@@ -21119,14 +21182,14 @@ async function applyPreparedSummary(args, prepared, budget) {
|
|
|
21119
21182
|
...pendingMessages
|
|
21120
21183
|
];
|
|
21121
21184
|
const messages = replacement.map((entry) => entry.message);
|
|
21122
|
-
const replacementTokens =
|
|
21185
|
+
const replacementTokens = estimateReplacementTokens(messages, args.requestOverheadTokens);
|
|
21123
21186
|
const targetTokens = calculateContextCompactionTargetTokens(budget.triggerTokens);
|
|
21124
21187
|
setSpanAttributes({
|
|
21125
21188
|
"app.compaction.input.estimate": budget.estimatedTokens,
|
|
21126
21189
|
"app.compaction.replacement.estimate": replacementTokens,
|
|
21127
21190
|
"app.compaction.threshold": budget.triggerTokens,
|
|
21128
21191
|
"app.compaction.carried_messages": kept.length,
|
|
21129
|
-
"app.compaction.carried.estimate":
|
|
21192
|
+
"app.compaction.carried.estimate": estimateReplacementTokens(trimmedEntries.map((entry) => entry.message)),
|
|
21130
21193
|
"app.compaction.trimmed_results": trimming.trimmedResults,
|
|
21131
21194
|
"app.compaction.trimmed_chars": trimming.removedChars
|
|
21132
21195
|
});
|
|
@@ -22228,6 +22291,7 @@ async function executeAgentRunInPrivacyContext(run, conversationPrivacy, runLogC
|
|
|
22228
22291
|
pendingMessages,
|
|
22229
22292
|
mode,
|
|
22230
22293
|
piMessages: messages,
|
|
22294
|
+
requestOverheadTokens: estimateRequestOverheadTokens(agent.state.systemPrompt, agent.state.tools),
|
|
22231
22295
|
...pairPendingRuntimeContext && pendingMessages ? { runtimeContextMessages: [...messages, ...pendingMessages.map((entry) => entry.message)] } : void 0,
|
|
22232
22296
|
signal: hookSignal,
|
|
22233
22297
|
turnStartMessageIndex: runResume.turnStartMessageIndex
|
|
@@ -22757,4 +22821,4 @@ function createAgentRunner(execute, options) {
|
|
|
22757
22821
|
return await execute(nextRun, streamFn);
|
|
22758
22822
|
} };
|
|
22759
22823
|
}
|
|
22760
|
-
export { readViewerAutomations as $, runWithSlackInstallation as A,
|
|
22824
|
+
export { readViewerAutomations as $, runWithSlackInstallation as A, withoutSavedSteeringMessages as At, logScheduledAutomationRunSkipped as B, readSlackReviewItemCardConversationId as C, listChildAgents as Ct, parseSlackReviewItemClick as D, processWorkspaceSnapshotJob as Dt, buildSlackReviewItemModal as E, conversationSubtreeColumns as Et, resolveSlackChannelIdFromThreadId as F, toolInvocationDestination as Ft, readViewerAutomationEdit as G, activateViewerAutomationVersion as H, getConversationInfo as I, readBlockedReport as It, readConversationSourceTask as J, updateViewerAutomation as K, joinPublicChannel as L, shouldEmitDevAgentTrace as Lt, parseSlackThreadId as M, saveUserCustomization as Mt, readSlackRawMessageContext as N, RetryableDeliveryError as Nt, parseSlackReviewItemFormTarget as O, ingestEvent as Ot, resolveSlackChannelIdFromMessage as P, actorFromRun as Pt, readViewerAutomationVersions as Q, listThreadReplies as R, createSlackReviewItemShow as S, recordSubagentStarted as St, SLACK_REVIEW_ITEM_VIEW_ID as T, conversationSubtree as Tt, changeViewerAutomationLifecycle as U, scheduledAutomationRunAttributes as V, deleteViewerTask as W, readViewerAutomationRuns as X, readViewerAutomationExecutions as Y, readViewerAutomationSummary as Z, readPublicArtifact as _, requestAttachmentDeletion as _t, buildAuthPauseResponse as a, reviewItemChangeRecord as at, renderAttachmentText as b, stopConversationSession as bt, deleteMcpAuthSessionsForUserProvider as c, conversationTurnIdForMessage as ct, getMcpAuthSession as d, recordWebConversationActivity as dt, AutomationEditError as et, getMcpStoredOAuthCredentials as f, webActorFromUser as ft, publicArtifactHeaders as g, readLiveAttachment as gt, readStats as h, collectAttachmentGarbage as ht, measureTurnCompactionWait as i, renderReviewItemMessage as it, verifySlackSignature as j, readUserCustomization as jt, parseSlackUserInputSubmission as k, buildSteeringPiMessage as kt, deleteMcpServerSessionId as l, createAndEnqueueConversation as lt, latestProgressStatus as m, decodeInputImages as mt, executeAgentRun as n, listOwnedWatches as nt, finalizeMcpAuthorization as o, acceptsWebMessages as ot, putMcpStoredOAuthCredentials as p, resolveConversationDestination as pt, ViewerTaskNotFoundError as q, processBackgroundCompaction as r, deliverReviewItemChange as rt, deleteMcpAuthSession as s, appendAndEnqueueWebMessage as st, createAgentRunner as t, effectiveTaskOutcomes as tt, deleteMcpStoredOAuthCredentials as u, createConversationId as ut, unpublishedArtifactHeaders as v, storeAttachment as vt, syncReviewItemSlackCards as w, listUnreportedSiblingAgents as wt, renderBlockText as x, recordSubagentEnded as xt, lookupSlackUserProfile as y, stopChildAgentsOf as yt, resolveDestinationVisibility as z };
|