@sentry/junior 0.251.0 → 0.252.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{admin-Dth5-1lw.js → admin-C_-XEdym.js} +1 -1
- package/dist/{agent-hooks-Ctw_jKaS.js → agent-hooks-DcoKnnxn.js} +8 -8
- package/dist/{agent-runner-dgQdPoGH.js → agent-runner-B-7S_DCS.js} +19 -19
- package/dist/api/schema.d.ts +32 -32
- package/dist/api.js +22 -22
- package/dist/app.js +38 -29
- package/dist/{assistant-reply-DBFRnZRx.js → assistant-reply-DbPLvsnL.js} +1 -1
- package/dist/{briefs-SDwPKduW.js → briefs-D4SMqc-r.js} +2 -2
- package/dist/{catalog-runtime-ulFceOA-.js → catalog-runtime-BQQiwwA7.js} +1 -1
- package/dist/cli/chat.js +15 -15
- package/dist/cli/check.js +3 -3
- package/dist/cli/main.js +2 -2
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +3 -3
- package/dist/cli/upgrade.js +3 -3
- package/dist/{client-DMt9kArs.js → client-ROZeVjq0.js} +2 -2
- package/dist/{config-iEOq080E.js → config-DNNkxfGS.js} +2 -2
- package/dist/{connections-BFU6GarA.js → connections-DJV6mLrH.js} +9 -9
- package/dist/{conversation-privacy-yZhQHnBe.js → conversation-privacy-B19umzIL.js} +1 -1
- package/dist/{credential-sync-GW0Rj57H.js → credential-sync-CEd2F5PS.js} +14 -14
- package/dist/{executor-BeH9LDKI.js → executor-_4bdoCxe.js} +59 -19
- package/dist/{images-hIXWwpRg.js → images-BAN7DHuO.js} +2 -2
- package/dist/instrumentation.js +2 -2
- package/dist/{job-queue-Bxlao6zL.js → job-queue-DSQx1qFY.js} +1 -1
- package/dist/{logging-BkI10z0D.js → logging-COUsTFIL.js} +1 -1
- package/dist/{message-BUcVfXmK.js → message-CtDDEwwV.js} +3 -3
- package/dist/nitro.js +3 -3
- package/dist/{oauth-callback-server-CYSEV35l.js → oauth-callback-server-CCiKrS0s.js} +2 -2
- package/dist/{pending-auth-h0B3FQEo.js → pending-auth-DDx3EU4M.js} +2 -2
- package/dist/{profile-AsD2uz0m.js → profile-DP4LKL6V.js} +4 -4
- package/dist/{registry-CN2Nie72.js → registry-CeEpPna6.js} +1 -1
- package/dist/{resolve-CrgwPWTS.js → resolve-B5ma3igH.js} +2 -2
- package/dist/{result-Cokw_MYC.js → result-Da0RVuWG.js} +6 -6
- package/dist/{runner-D-VZlBb_.js → runner-se1W_jGZ.js} +9 -9
- package/dist/{sandbox-egress-signals-Sie51RW0.js → sandbox-egress-signals-CS959-wm.js} +1 -1
- package/dist/{session-stop-DD0k0BXI.js → session-stop-DlRDisF5.js} +10 -10
- package/dist/{skills-CpyJJyqH.js → skills-CSzgs0EC.js} +2 -2
- package/dist/{spawn-DX3YjDtm.js → spawn-DT9fMjtd.js} +2 -2
- package/dist/{store-D-n2b2cI.js → store-Dx1U69mm.js} +6 -6
- package/dist/{task-queue-Bj2hFpjr.js → task-queue-BX9YrIsw.js} +3 -3
- package/dist/{task-runner-B3g16wjr.js → task-runner-CO55Olal.js} +14 -16
- package/dist/{tasks-DDzBxMio.js → tasks-DwGlFX9i.js} +129 -200
- package/dist/{thread-state-BlD6loX7.js → thread-state-Ces6tXmB.js} +6 -6
- package/dist/{turn-failure-response-BRlfATgu.js → turn-failure-response-B4VCvEQf.js} +7 -7
- package/dist/{turn-lifecycle-hMCbr_Ah.js → turn-lifecycle-B1VV58Yo.js} +1 -1
- package/dist/{turn-session-routing-DLb6eQMT.js → turn-session-routing-Dw2Kamg9.js} +1 -1
- package/dist/{validation-C2lG6yVH.js → validation-yJF9LKOv.js} +1 -1
- package/dist/{version-CyJ_kMe8.js → version-CZYqvIFh.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-C8u1HAdN.js → viewer-D96vo_42.js} +3 -3
- package/dist/{web-input-DHgIfSwj.js → web-input-5mls-41-.js} +65 -98
- package/dist/{work-hoPN8qjl.js → work-D2M2-zCO.js} +9 -9
- package/dist/{worker-CavJZxi8.js → worker-BwCpf8tB.js} +5 -5
- package/migrations/0055_automations.sql +125 -0
- package/migrations/meta/0055_snapshot.json +3948 -0
- package/migrations/meta/_journal.json +8 -1
- package/package.json +4 -4
|
@@ -1,44 +1,43 @@
|
|
|
1
|
-
import { A as resolveSlackChannelIdFromMessage, B as effectiveTaskOutcomes, Bt as RetryableDeliveryError, C as renderBlockText, D as storeAttachment, Gt as shouldEmitDevAgentTrace, Lt as createUserTokenStore, M as getConversationInfo, N as listThreadReplies, O as parseSlackThreadId, Rt as buildSteeringPiMessage, S as renderAttachmentText, Ut as AuthorizationFlowDisabledError, a as buildAuthPauseResponse, h as latestProgressStatus, j as resolveSlackChannelIdFromThreadId, k as readSlackRawMessageContext, m as PluginCredentialFailureError, n as executeAgentRun, r as createContextCompactor, t as createAgentRunner, z as eventAutomationTriggerAvailable, zt as withoutSavedSteeringMessages } from "./agent-runner-
|
|
2
|
-
import { f as escapeXml, i as completeText, r as completeObject, v as isProviderRetryError } from "./client-
|
|
3
|
-
import { C as withLogContext, I as isRecord, L as toOptionalNumber, R as toOptionalString, _ as setSentryUser, b as setTags, d as logException, f as logInfo, n as createChatSdkLogger, o as getActiveTraceId, p as logWarn, t as buildTurnFailureResponse, u as logError, v as setSpanAttributes, w as withSpan } from "./logging-
|
|
4
|
-
import { c as getSlackClientSecret, i as getChatConfig, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, v as normalizeSlackEmojiName } from "./config-
|
|
1
|
+
import { A as resolveSlackChannelIdFromMessage, B as effectiveTaskOutcomes, Bt as RetryableDeliveryError, C as renderBlockText, D as storeAttachment, Gt as shouldEmitDevAgentTrace, Lt as createUserTokenStore, M as getConversationInfo, N as listThreadReplies, O as parseSlackThreadId, Rt as buildSteeringPiMessage, S as renderAttachmentText, Ut as AuthorizationFlowDisabledError, a as buildAuthPauseResponse, h as latestProgressStatus, j as resolveSlackChannelIdFromThreadId, k as readSlackRawMessageContext, m as PluginCredentialFailureError, n as executeAgentRun, r as createContextCompactor, t as createAgentRunner, z as eventAutomationTriggerAvailable, zt as withoutSavedSteeringMessages } from "./agent-runner-B-7S_DCS.js";
|
|
2
|
+
import { f as escapeXml, i as completeText, r as completeObject, v as isProviderRetryError } from "./client-ROZeVjq0.js";
|
|
3
|
+
import { C as withLogContext, I as isRecord, L as toOptionalNumber, R as toOptionalString, _ as setSentryUser, b as setTags, d as logException, f as logInfo, n as createChatSdkLogger, o as getActiveTraceId, p as logWarn, t as buildTurnFailureResponse, u as logError, v as setSpanAttributes, w as withSpan } from "./logging-COUsTFIL.js";
|
|
4
|
+
import { c as getSlackClientSecret, i as getChatConfig, l as getSlackSigningSecret, n as botConfig, o as getSlackBotToken, s as getSlackClientId, v as normalizeSlackEmojiName } from "./config-DNNkxfGS.js";
|
|
5
5
|
import { o as modelIdForProfile, r as defaultModelId } from "./model-profile-BwU8mqwD.js";
|
|
6
6
|
import { a as isUserActor, g as parseSlackMessageTs, i as isActorUserId, l as parseSlackChannelId, n as createSlackActor, o as parseActorUserId, r as createSlackResumeActor, t as createActor } from "./actor-BTtLaeWy.js";
|
|
7
|
-
import { M as createSlackDestination, P as requireSlackDestination, c as getConversationEventStore, d as getDb, f as getSqlExecutor, u as getConversationStore } from "./viewer-
|
|
7
|
+
import { M as createSlackDestination, P as requireSlackDestination, c as getConversationEventStore, d as getDb, f as getSqlExecutor, u as getConversationStore } from "./viewer-D96vo_42.js";
|
|
8
8
|
import { c as juniorIdentities, d as juniorDestinations, l as juniorUsers } from "./agent-invocations-D_YoNnAn.js";
|
|
9
|
-
import { c as juniorAutomationExecutions,
|
|
9
|
+
import { c as juniorAutomationExecutions, s as juniorAutomations } from "./executor-_4bdoCxe.js";
|
|
10
10
|
import { p as instructionProvenanceFor } from "./history-9pO1Zd4Y.js";
|
|
11
|
-
import { d as credentialContextForActor } from "./registry-
|
|
12
|
-
import { $ as listTurnSummaries, $t as appendThreadContextMessages, At as loadProjection, D as sameDefinitionValue, Et as commitMessages, Gt as hydrateConversationMessages, H as removeReactionFromMessage, I as truncateStatusText, J as saveTurnCheckpoint, Jt as persistConversationMessageSummaries, Kt as persistConversationMessages, L as addReactionToMessage, Lt as recordAuthorizationCompleted, M as formatSlackLink, N as normalizeSlackReplyMarkdown, Ot as loadConversationProjection, P as normalizeSlackStatusText, Q as getTurnRecord, St as trimTrailingAssistantMessages, T as listAutomationVersions, Tt as commitAcceptedReply, V as postSlackMessage, Vt as recordSubscribedReplyRoute, X as completeTurnRecord, Y as abandonTurnRecord, Yt as resolveConversationTitle, Z as failTurnRecord, Zt as fallbackShortTitle, _ as listDeletedEventAutomationsCreatedBy, a as readScheduledAutomation, an as markConversationMessage, cn as turnHasReply, en as buildConversationContext, et as recordTurnSummary, g as getEventAutomation, i as parseScheduledAutomationRow, in as isHumanConversationMessage, j as escapeSlackMrkdwnText, l as withScheduledAutomationLock, ln as upsertConversationMessage, m as eventAutomationBelongsToUser, nn as estimateConversationContextTokens, on as normalizeConversationText, ot as buildTurnErrorResponse, p as deleteEventAutomation, q as loadTurnCheckpoint, rn as getConversationMessageSlackTs, s as saveScheduledAutomationInLock, sn as recordDeliveredAssistantMessage, tn as createConversationMemoryService, tt as persistWithRetry, w as automationDefinition, y as parseEventAutomationRow } from "./tasks-
|
|
13
|
-
import { Et as getSlackFileId, Gt as normalizeSlackConversationId, Ht as getSlackClient, Kt as runWithSlackInstallationToken, Lt as lookupSlackUser, Ot as readAttachmentVisionSummary, Rt as SlackActionError, Tt as buildSentryConversationUrl, V as cancelSubscriptions, Vt as getHeaderString, Wt as isDmChannel, at as getDashboardConversationLink, it as JUNIOR_THREAD_STATE_TTL_MS, kt as recordSlackAttachment, o as getPluginSlackConversationLink, ot as getDashboardObjectIconLink, rt as verifyTimerWatchCredentialSubject, zt as downloadPrivateSlackFile } from "./agent-hooks-
|
|
11
|
+
import { d as credentialContextForActor } from "./registry-CeEpPna6.js";
|
|
12
|
+
import { $ as listTurnSummaries, $t as appendThreadContextMessages, At as loadProjection, D as sameDefinitionValue, Et as commitMessages, Gt as hydrateConversationMessages, H as removeReactionFromMessage, I as truncateStatusText, J as saveTurnCheckpoint, Jt as persistConversationMessageSummaries, Kt as persistConversationMessages, L as addReactionToMessage, Lt as recordAuthorizationCompleted, M as formatSlackLink, N as normalizeSlackReplyMarkdown, Ot as loadConversationProjection, P as normalizeSlackStatusText, Q as getTurnRecord, St as trimTrailingAssistantMessages, T as listAutomationVersions, Tt as commitAcceptedReply, V as postSlackMessage, Vt as recordSubscribedReplyRoute, X as completeTurnRecord, Y as abandonTurnRecord, Yt as resolveConversationTitle, Z as failTurnRecord, Zt as fallbackShortTitle, _ as listDeletedEventAutomationsCreatedBy, a as readScheduledAutomation, an as markConversationMessage, cn as turnHasReply, en as buildConversationContext, et as recordTurnSummary, g as getEventAutomation, i as parseScheduledAutomationRow, in as isHumanConversationMessage, j as escapeSlackMrkdwnText, l as withScheduledAutomationLock, ln as upsertConversationMessage, m as eventAutomationBelongsToUser, nn as estimateConversationContextTokens, on as normalizeConversationText, ot as buildTurnErrorResponse, p as deleteEventAutomation, q as loadTurnCheckpoint, rn as getConversationMessageSlackTs, s as saveScheduledAutomationInLock, sn as recordDeliveredAssistantMessage, tn as createConversationMemoryService, tt as persistWithRetry, w as automationDefinition, y as parseEventAutomationRow } from "./tasks-DwGlFX9i.js";
|
|
13
|
+
import { Et as getSlackFileId, Gt as normalizeSlackConversationId, Ht as getSlackClient, Kt as runWithSlackInstallationToken, Lt as lookupSlackUser, Ot as readAttachmentVisionSummary, Rt as SlackActionError, Tt as buildSentryConversationUrl, V as cancelSubscriptions, Vt as getHeaderString, Wt as isDmChannel, at as getDashboardConversationLink, it as JUNIOR_THREAD_STATE_TTL_MS, kt as recordSlackAttachment, o as getPluginSlackConversationLink, ot as getDashboardObjectIconLink, rt as verifyTimerWatchCredentialSubject, zt as downloadPrivateSlackFile } from "./agent-hooks-DcoKnnxn.js";
|
|
14
14
|
import { F as readMessageAttachments, R as isVisionImageMediaType } from "./conversation-T18Xlkx9.js";
|
|
15
|
-
import { E as acquireActiveLock, O as withLock, T as MUTATION_LOCK_TTL_MS, w as getStateAdapter } from "./profile-
|
|
16
|
-
import { a as wasPendingAuthStopped, c as getThreadStopDecision, l as buildDeterministicAssistantMessageId, o as decideSubscribedThreadReply, r as clearPendingAuth, s as getSubscribedReplyPreflightDecision, u as buildDeterministicTurnId } from "./pending-auth-
|
|
15
|
+
import { E as acquireActiveLock, O as withLock, T as MUTATION_LOCK_TTL_MS, w as getStateAdapter } from "./profile-DP4LKL6V.js";
|
|
16
|
+
import { a as wasPendingAuthStopped, c as getThreadStopDecision, l as buildDeterministicAssistantMessageId, o as decideSubscribedThreadReply, r as clearPendingAuth, s as getSubscribedReplyPreflightDecision, u as buildDeterministicTurnId } from "./pending-auth-DDx3EU4M.js";
|
|
17
17
|
import { a as TurnInputDeferredError, c as isTurnInputCommitLostError, d as markTurnCompleted, f as markTurnFailed, i as TurnInputCommitLostError, l as isTurnInputDeferredError, n as ConversationTurnBoundaryError, o as getConversationTurnBoundaryError, p as startActiveTurn, r as CooperativeTurnYieldError, s as isCooperativeTurnYieldError, u as markTurnClosed } from "./oauth-authorization-BA4Dt6a7.js";
|
|
18
|
-
import { n as getAssistantReplyText } from "./assistant-reply-
|
|
19
|
-
import { A as recordFinishedTurnForAutomatedLimit, F as finishedRunReply, P as deliversFinalText, R as runDispatchOutcome, c as timerWatchCredentialSubject, i as skipInputBeforeConversationStop, k as maybePostAutomatedTurnLimitNotice, l as getEventCatalog, s as isEventMailboxMetadata, v as automationEventCatalog } from "./session-stop-
|
|
18
|
+
import { n as getAssistantReplyText } from "./assistant-reply-DbPLvsnL.js";
|
|
19
|
+
import { A as recordFinishedTurnForAutomatedLimit, F as finishedRunReply, P as deliversFinalText, R as runDispatchOutcome, c as timerWatchCredentialSubject, i as skipInputBeforeConversationStop, k as maybePostAutomatedTurnLimitNotice, l as getEventCatalog, s as isEventMailboxMetadata, v as automationEventCatalog } from "./session-stop-DlRDisF5.js";
|
|
20
20
|
import { a as EVENT_SYSTEM_ACTOR, o as isEventConversationMessage } from "./prompt-C04mP1hu.js";
|
|
21
|
-
import { a as getVercelConversationWorkQueue, f as getTurnRequestDeadline } from "./job-queue-
|
|
22
|
-
import { E as stopConversationWork, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage, w as requestConversationWork } from "./store-
|
|
21
|
+
import { a as getVercelConversationWorkQueue, f as getTurnRequestDeadline } from "./job-queue-DSQx1qFY.js";
|
|
22
|
+
import { E as stopConversationWork, g as getConversationWorkState, h as getConversation, m as ensureConversationWake, n as appendAndEnqueueExclusiveInboundMessage, r as appendAndEnqueueInboundMessage, w as requestConversationWork } from "./store-Dx1U69mm.js";
|
|
23
23
|
import { l as automationListQuerySchema } from "./automation-gznOMaQ2.js";
|
|
24
24
|
import { r as isExperimentalFeatureEnabled } from "./experimental-Qn9rKLgx.js";
|
|
25
25
|
import { c as sumUtcHoursIntoSixHours, m as healthReportSchema, t as webMessageId } from "./web-message-id-xPI_EFSC.js";
|
|
26
|
-
import { C as readAutomationExecutionDays, D as readAutomationExecutionSummaries, E as readAutomationExecutionStatusHours, O as readAutomationExecutions, S as readAutomationExecutionByConversationId, T as readAutomationExecutionStatusDays, _ as markDispatchCompleted, a as confirmDispatchMailboxAppend, c as getDispatchIdForConversation, d as getDispatchTurnId, g as markDispatchBlocked, h as markDispatchAwaitingResume, i as claimDispatchMailboxAppend, k as readAutomationRuns, l as getDispatchInputMessageId, n as scheduleSessionCompletedPluginTasks, p as isTerminalDispatchStatus, s as getDispatchConversationId, t as processPluginTask, u as getDispatchRecord, v as markDispatchFailed, w as readAutomationExecutionHours, x as emptyAutomationRunWindows, y as markDispatchRunning } from "./task-runner-
|
|
27
|
-
import { a as withAgentInvocationResultActors, c as resolveMailboxTurnWork, f as joinMailboxText, i as startAgentInvocationsForChildInput, l as sourceFromTurnInput, o as getAuthPausedConversationTurnId, s as getEventBatchDelayMs, t as enqueueAgentInvocationResult, u as turnInputFactsFromConversationMessage } from "./result-
|
|
28
|
-
import { n as getTurnLifecycle, t as ConversationTurnLifecycleService } from "./turn-lifecycle-
|
|
29
|
-
import { i as resolveAgentInvocationId, o as AgentRunError, s as executeTurn, t as createAgentInvocationWorker } from "./work-
|
|
30
|
-
import { a as persistThreadState, c as configValueSchema, i as persistThreadRuntimeState, n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState, t as getLocationConfigurationService } from "./thread-state-
|
|
31
|
-
import { c as deleteWebAuthorization, d as getPausedTurnRequest, m as getTurnAuthorization, p as wakePausedTurn, s as createWebAuthorization, u as createPausedTurns } from "./connections-
|
|
32
|
-
import { n as resolveTurnSessionRouting } from "./turn-session-routing-
|
|
33
|
-
import { t as bindMessageAgent } from "./message-
|
|
34
|
-
import { t as bindSpawnAgent } from "./spawn-
|
|
35
|
-
import { a as persistAuthPauseTurnState, c as getTurnUserSlackMessageTs, d as loadPendingMessageCards, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, n as getAgentTurnDiagnosticsAttributes, o as getTurnUserMessage, r as requireTurnFailureEventId, s as getTurnUserReplyAttachmentContext, t as finalizeFailedTurnReplyWithEvent, u as getInterruptionMarker } from "./turn-failure-response-
|
|
36
|
-
import { r as storeInputImages } from "./images-
|
|
26
|
+
import { C as readAutomationExecutionDays, D as readAutomationExecutionSummaries, E as readAutomationExecutionStatusHours, O as readAutomationExecutions, S as readAutomationExecutionByConversationId, T as readAutomationExecutionStatusDays, _ as markDispatchCompleted, a as confirmDispatchMailboxAppend, c as getDispatchIdForConversation, d as getDispatchTurnId, g as markDispatchBlocked, h as markDispatchAwaitingResume, i as claimDispatchMailboxAppend, k as readAutomationRuns, l as getDispatchInputMessageId, n as scheduleSessionCompletedPluginTasks, p as isTerminalDispatchStatus, s as getDispatchConversationId, t as processPluginTask, u as getDispatchRecord, v as markDispatchFailed, w as readAutomationExecutionHours, x as emptyAutomationRunWindows, y as markDispatchRunning } from "./task-runner-CO55Olal.js";
|
|
27
|
+
import { a as withAgentInvocationResultActors, c as resolveMailboxTurnWork, f as joinMailboxText, i as startAgentInvocationsForChildInput, l as sourceFromTurnInput, o as getAuthPausedConversationTurnId, s as getEventBatchDelayMs, t as enqueueAgentInvocationResult, u as turnInputFactsFromConversationMessage } from "./result-Da0RVuWG.js";
|
|
28
|
+
import { n as getTurnLifecycle, t as ConversationTurnLifecycleService } from "./turn-lifecycle-B1VV58Yo.js";
|
|
29
|
+
import { i as resolveAgentInvocationId, o as AgentRunError, s as executeTurn, t as createAgentInvocationWorker } from "./work-D2M2-zCO.js";
|
|
30
|
+
import { a as persistThreadState, c as configValueSchema, i as persistThreadRuntimeState, n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState, s as coerceThreadConversationState, t as getLocationConfigurationService } from "./thread-state-Ces6tXmB.js";
|
|
31
|
+
import { c as deleteWebAuthorization, d as getPausedTurnRequest, m as getTurnAuthorization, p as wakePausedTurn, s as createWebAuthorization, u as createPausedTurns } from "./connections-DJV6mLrH.js";
|
|
32
|
+
import { n as resolveTurnSessionRouting } from "./turn-session-routing-Dw2Kamg9.js";
|
|
33
|
+
import { t as bindMessageAgent } from "./message-CtDDEwwV.js";
|
|
34
|
+
import { t as bindSpawnAgent } from "./spawn-DT9fMjtd.js";
|
|
35
|
+
import { a as persistAuthPauseTurnState, c as getTurnUserSlackMessageTs, d as loadPendingMessageCards, i as completeAuthPauseTurn, l as buildDeliveredTurnStatePatch, n as getAgentTurnDiagnosticsAttributes, o as getTurnUserMessage, r as requireTurnFailureEventId, s as getTurnUserReplyAttachmentContext, t as finalizeFailedTurnReplyWithEvent, u as getInterruptionMarker } from "./turn-failure-response-B4VCvEQf.js";
|
|
36
|
+
import { r as storeInputImages } from "./images-BAN7DHuO.js";
|
|
37
37
|
import { z } from "zod";
|
|
38
38
|
import { createHash } from "node:crypto";
|
|
39
39
|
import { and, asc, count, desc, eq, exists, inArray, ne, or, sql } from "drizzle-orm";
|
|
40
40
|
import { createSlackSource, createWebSource, localDestinationSchema, objectFactFields, objectPresentation, objectTypeSchema } from "@sentry/junior-plugin-api";
|
|
41
|
-
import { unionAll } from "drizzle-orm/pg-core";
|
|
42
41
|
import { del, get, put } from "@vercel/blob";
|
|
43
42
|
import { Message, ThreadImpl, stringifyMarkdown } from "chat";
|
|
44
43
|
import { SlackFormatConverter, createSlackAdapter } from "@chat-adapter/slack";
|
|
@@ -2741,65 +2740,37 @@ function viewerAutomationCollection(user) {
|
|
|
2741
2740
|
const db = getDb();
|
|
2742
2741
|
const identities = user.identities.filter((identity) => identity.provider === "slack");
|
|
2743
2742
|
const teamIds = identities.flatMap((identity) => identity.providerTenantId ? [identity.providerTenantId] : []);
|
|
2744
|
-
const
|
|
2745
|
-
const event = juniorEventAutomations;
|
|
2743
|
+
const automation = juniorAutomations;
|
|
2746
2744
|
const destination = juniorDestinations;
|
|
2747
|
-
const
|
|
2748
|
-
const
|
|
2745
|
+
const isScheduled = eq(automation.kind, "scheduled");
|
|
2746
|
+
const owned = or(and(isScheduled, inArray(automation.creatorIdentityId, user.identities.map((identity) => identity.id))), ...identities.map((identity) => and(eq(automation.kind, "event"), eq(automation.teamId, identity.providerTenantId ?? ""), eq(automation.creatorSlackUserId, identity.providerSubjectId)))) ?? sql`false`;
|
|
2749
2747
|
const publicDestination = sql`coalesce(${destination.visibility} = 'public', false)`;
|
|
2750
|
-
const
|
|
2751
|
-
const
|
|
2752
|
-
function fields(record, teamId) {
|
|
2753
|
-
return {
|
|
2754
|
-
creator: sql`${teamId} || ':' || (${record}->'createdBy'->>'slackUserId')`.as("creator"),
|
|
2755
|
-
creatorLabel: sql`coalesce(nullif(trim(${record}->'createdBy'->>'fullName'), ''), nullif(trim(${record}->'createdBy'->>'userName'), ''), ${record}->'createdBy'->>'slackUserId')`.as("creator_label"),
|
|
2756
|
-
destination: sql`${teamId} || ':' || (${record}->'destination'->>'channelId')`.as("destination"),
|
|
2757
|
-
destinationLabel: sql`coalesce(nullif(${destination.displayName}, ''), ${record}->'destination'->>'channelId')`.as("destination_label"),
|
|
2758
|
-
isPublic: publicDestination.as("is_public"),
|
|
2759
|
-
instruction: sql`${record}->'task'->>'text'`.as("instruction")
|
|
2760
|
-
};
|
|
2761
|
-
}
|
|
2762
|
-
function destinationJoin(record, teamId) {
|
|
2763
|
-
return and(eq(destination.provider, "slack"), sql`${destination.providerTenantId} = ${teamId}`, sql`${destination.providerDestinationId} = ${record}->'destination'->>'channelId'`);
|
|
2764
|
-
}
|
|
2765
|
-
const available = or(...Object.entries(automationEventCatalog(getEventCatalog())).map(([namespace, registration]) => {
|
|
2748
|
+
const publicToViewer = and(inArray(automation.teamId, teamIds), publicDestination, ne(automation.status, "completed"));
|
|
2749
|
+
const available = or(isScheduled, ...Object.entries(automationEventCatalog(getEventCatalog())).map(([namespace, registration]) => {
|
|
2766
2750
|
const events = registration.resourceTypes.flatMap((resource) => resource.supportedEvents);
|
|
2767
|
-
return and(eq(
|
|
2751
|
+
return and(eq(automation.namespace, namespace), sql`${automation.record}->'trigger'->'events' <@ ${JSON.stringify(events)}::jsonb`);
|
|
2768
2752
|
})) ?? sql`false`;
|
|
2769
2753
|
const executions = juniorAutomationExecutions;
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
where ${executions.kind} = ${kind} and ${executions.namespace} = 'junior' and ${executions.automationId} = ${id}
|
|
2754
|
+
const lastRunNeedsAttention = sql`coalesce((select ${executions.status} in ('failed', 'blocked') from ${executions}
|
|
2755
|
+
where ${executions.kind} = ${automation.kind} and ${executions.namespace} = 'junior' and ${executions.automationId} = ${automation.id}
|
|
2773
2756
|
order by ${executions.executedAtMs} desc, ${executions.executionId} desc limit 1), false)`;
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
state: sql`${scheduled.status}`.as("state"),
|
|
2781
|
-
unavailable: sql`false`.as("unavailable"),
|
|
2782
|
-
attention: sql`${scheduled.status} not in ('paused', 'completed') and (${scheduled.status} = 'blocked' or ${lastRunNeedsAttention("scheduled", scheduled.id)})`.as("attention"),
|
|
2783
|
-
owned: sql`${scheduledOwned}`.as("owned"),
|
|
2784
|
-
resource: sql`''`.as("resource"),
|
|
2785
|
-
...fields(scheduled.record, scheduled.teamId)
|
|
2786
|
-
}).from(scheduled).leftJoin(destination, destinationJoin(scheduled.record, scheduled.teamId)).where(and(inArray(scheduled.status, [
|
|
2787
|
-
"active",
|
|
2788
|
-
"blocked",
|
|
2789
|
-
"paused",
|
|
2790
|
-
"completed"
|
|
2791
|
-
]), or(scheduledOwned, scheduledPublic))), db.select({
|
|
2792
|
-
kind: sql`'event'`.as("kind"),
|
|
2793
|
-
id: event.id,
|
|
2794
|
-
title: sql`${event.title}`.as("title"),
|
|
2795
|
-
createdAtMs: event.createdAtMs,
|
|
2796
|
-
state: sql`${event.status}`.as("state"),
|
|
2757
|
+
return db.select({
|
|
2758
|
+
kind: automation.kind,
|
|
2759
|
+
id: automation.id,
|
|
2760
|
+
title: automation.title,
|
|
2761
|
+
createdAtMs: automation.createdAtMs,
|
|
2762
|
+
state: sql`${automation.status}`.as("state"),
|
|
2797
2763
|
unavailable: sql`not (${available})`.as("unavailable"),
|
|
2798
|
-
attention: sql`${
|
|
2799
|
-
owned: sql`${
|
|
2800
|
-
resource: sql`concat_ws(' ', ${
|
|
2801
|
-
|
|
2802
|
-
|
|
2764
|
+
attention: sql`${automation.status} not in ('paused', 'completed') and (${automation.status} = 'blocked' or not (${available}) or ${lastRunNeedsAttention})`.as("attention"),
|
|
2765
|
+
owned: sql`${owned}`.as("owned"),
|
|
2766
|
+
resource: sql`case when ${isScheduled} then '' else concat_ws(' ', ${automation.identifier}, ${automation.record}->'trigger'->>'label', ${automation.namespace}) end`.as("resource"),
|
|
2767
|
+
creator: sql`${automation.teamId} || ':' || ${automation.creatorSlackUserId}`.as("creator"),
|
|
2768
|
+
creatorLabel: sql`coalesce(nullif(trim(${automation.record}->'createdBy'->>'fullName'), ''), nullif(trim(${automation.record}->'createdBy'->>'userName'), ''), ${automation.creatorSlackUserId})`.as("creator_label"),
|
|
2769
|
+
destination: sql`${automation.teamId} || ':' || ${automation.channelId}`.as("destination"),
|
|
2770
|
+
destinationLabel: sql`coalesce(nullif(${destination.displayName}, ''), ${automation.channelId})`.as("destination_label"),
|
|
2771
|
+
isPublic: publicDestination.as("is_public"),
|
|
2772
|
+
instruction: automation.instruction
|
|
2773
|
+
}).from(automation).leftJoin(destination, and(eq(destination.provider, "slack"), eq(destination.providerTenantId, automation.teamId), eq(destination.providerDestinationId, automation.channelId))).where(and(ne(automation.status, "deleted"), or(owned, publicToViewer))).as("accessible_automations");
|
|
2803
2774
|
}
|
|
2804
2775
|
/** Read an SQL page and complete, access-scoped counts and filter options. */
|
|
2805
2776
|
async function readAutomationCollection(user, input) {
|
|
@@ -3085,27 +3056,28 @@ async function readViewerAutomations(user, input = automationListQuerySchema.par
|
|
|
3085
3056
|
const { rows, ...page } = await readAutomationCollection(user, input);
|
|
3086
3057
|
const db = getDb();
|
|
3087
3058
|
const ids = rows.map((row) => row.id);
|
|
3088
|
-
const
|
|
3059
|
+
const stored = ids.length ? await db.select().from(juniorAutomations).where(inArray(juniorAutomations.id, ids)) : [];
|
|
3089
3060
|
const identityIds = new Set(user.identities.map((identity) => identity.id));
|
|
3090
3061
|
const candidates = /* @__PURE__ */ new Map();
|
|
3091
|
-
for (const row of
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3062
|
+
for (const row of stored) {
|
|
3063
|
+
if (row.kind === "scheduled") {
|
|
3064
|
+
const task = parseScheduledAutomationRow(row);
|
|
3065
|
+
if (task && task.status !== "deleted") candidates.set(task.id, {
|
|
3066
|
+
kind: "scheduled",
|
|
3067
|
+
task,
|
|
3068
|
+
ownedByViewer: identityIds.has(task.creatorIdentityId)
|
|
3069
|
+
});
|
|
3070
|
+
continue;
|
|
3071
|
+
}
|
|
3100
3072
|
const task = parseEventAutomationRow(row);
|
|
3101
|
-
if (task.status !== "deleted") candidates.set(
|
|
3073
|
+
if (task.status !== "deleted") candidates.set(task.id, {
|
|
3102
3074
|
kind: "event",
|
|
3103
3075
|
task,
|
|
3104
3076
|
ownedByViewer: eventAutomationBelongsToUser(task, user)
|
|
3105
3077
|
});
|
|
3106
3078
|
}
|
|
3107
3079
|
const selected = rows.flatMap((row) => {
|
|
3108
|
-
const candidate = candidates.get(
|
|
3080
|
+
const candidate = candidates.get(row.id);
|
|
3109
3081
|
return candidate ? [candidate] : [];
|
|
3110
3082
|
});
|
|
3111
3083
|
const [destinations, creators] = await Promise.all([destinationDetails(selected.map(({ task }) => task.destination)), creatorProfiles(selected)]);
|
|
@@ -3139,12 +3111,7 @@ async function readViewerAutomations(user, input = automationListQuerySchema.par
|
|
|
3139
3111
|
async function readDeletedOwnedScheduledAutomations(user) {
|
|
3140
3112
|
const identityIds = user.identities.map((identity) => identity.id);
|
|
3141
3113
|
if (identityIds.length === 0) return [];
|
|
3142
|
-
return (await getDb().select(
|
|
3143
|
-
creatorIdentityId: juniorSchedulerTasks.creatorIdentityId,
|
|
3144
|
-
id: juniorSchedulerTasks.id,
|
|
3145
|
-
record: juniorSchedulerTasks.record,
|
|
3146
|
-
title: juniorSchedulerTasks.title
|
|
3147
|
-
}).from(juniorSchedulerTasks).where(and(eq(juniorSchedulerTasks.status, "deleted"), inArray(juniorSchedulerTasks.creatorIdentityId, identityIds))).orderBy(desc(juniorSchedulerTasks.createdAtMs), desc(juniorSchedulerTasks.id)).limit(TASK_EXECUTION_LIST_LIMIT)).map(parseScheduledAutomationRow).filter((task) => task?.status === "deleted");
|
|
3114
|
+
return (await getDb().select().from(juniorAutomations).where(and(eq(juniorAutomations.kind, "scheduled"), eq(juniorAutomations.status, "deleted"), inArray(juniorAutomations.creatorIdentityId, identityIds))).orderBy(desc(juniorAutomations.createdAtMs), desc(juniorAutomations.id)).limit(TASK_EXECUTION_LIST_LIMIT)).map(parseScheduledAutomationRow).filter((task) => task?.status === "deleted");
|
|
3148
3115
|
}
|
|
3149
3116
|
/** Load deleted event automations the viewer still owns, newest first. */
|
|
3150
3117
|
async function readDeletedOwnedEventAutomations(user) {
|
|
@@ -3249,7 +3216,7 @@ async function readViewerAutomationExecutions(user, kind, id) {
|
|
|
3249
3216
|
async function readViewerAutomationVersions(user, kind, id) {
|
|
3250
3217
|
const candidate = await resolveViewerTaskCandidate(user, kind, id);
|
|
3251
3218
|
if (!candidate) throw new ViewerTaskNotFoundError();
|
|
3252
|
-
const versions = await listAutomationVersions(getDb(),
|
|
3219
|
+
const versions = await listAutomationVersions(getDb(), id, 101);
|
|
3253
3220
|
const current = automationDefinition(candidate.task);
|
|
3254
3221
|
const listed = versions.slice(0, AUTOMATION_VERSION_LIST_LIMIT);
|
|
3255
3222
|
return {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { $ as getAgentInvocation, G as recordSubagentStarted, H as stopChildAgentsOf, J as createAgentInvocation, Q as getActiveAgentInvocationForConversation, Rt as buildSteeringPiMessage, Ut as AuthorizationFlowDisabledError, W as recordSubagentEnded, Wt as readBlockedReport, at as getAgentInvocationTurnId, ct as isTerminalAgentInvocation, dt as markAgentInvocationMailboxAppended, gt as reportReplacedAgentInvocation, ht as markAgentInvocationSteered, m as PluginCredentialFailureError, mt as markAgentInvocationRunning, pt as markAgentInvocationPaused, q as completeAgentInvocation, rt as getAgentInvocationMessageId, st as getLatestAgentInvocationForConversation, zt as withoutSavedSteeringMessages } from "./agent-runner-
|
|
3
|
-
import { n as botConfig } from "./config-
|
|
4
|
-
import { c as getConversationEventStore, u as getConversationStore } from "./viewer-
|
|
2
|
+
import { $ as getAgentInvocation, G as recordSubagentStarted, H as stopChildAgentsOf, J as createAgentInvocation, Q as getActiveAgentInvocationForConversation, Rt as buildSteeringPiMessage, Ut as AuthorizationFlowDisabledError, W as recordSubagentEnded, Wt as readBlockedReport, at as getAgentInvocationTurnId, ct as isTerminalAgentInvocation, dt as markAgentInvocationMailboxAppended, gt as reportReplacedAgentInvocation, ht as markAgentInvocationSteered, m as PluginCredentialFailureError, mt as markAgentInvocationRunning, pt as markAgentInvocationPaused, q as completeAgentInvocation, rt as getAgentInvocationMessageId, st as getLatestAgentInvocationForConversation, zt as withoutSavedSteeringMessages } from "./agent-runner-B-7S_DCS.js";
|
|
3
|
+
import { n as botConfig } from "./config-DNNkxfGS.js";
|
|
4
|
+
import { c as getConversationEventStore, u as getConversationStore } from "./viewer-D96vo_42.js";
|
|
5
5
|
import { m as sameActorIdentity, u as agentInstructionProvenance } from "./history-9pO1Zd4Y.js";
|
|
6
|
-
import { J as saveTurnCheckpoint, Nt as openConversationProjection, Q as getTurnRecord, Y as abandonTurnRecord, Z as failTurnRecord, ct as isTurnExecutionLimitExceededError, dt as getTerminalAssistantMessages } from "./tasks-
|
|
6
|
+
import { J as saveTurnCheckpoint, Nt as openConversationProjection, Q as getTurnRecord, Y as abandonTurnRecord, Z as failTurnRecord, ct as isTurnExecutionLimitExceededError, dt as getTerminalAssistantMessages } from "./tasks-DwGlFX9i.js";
|
|
7
7
|
import { c as isTurnInputCommitLostError, i as TurnInputCommitLostError, o as getConversationTurnBoundaryError } from "./oauth-authorization-BA4Dt6a7.js";
|
|
8
|
-
import { n as getAssistantReplyText } from "./assistant-reply-
|
|
9
|
-
import { A as recordFinishedTurnForAutomatedLimit, j as resetAutomatedTurnLimit, k as maybePostAutomatedTurnLimitNotice } from "./session-stop-
|
|
10
|
-
import { r as appendAndEnqueueInboundMessage } from "./store-
|
|
11
|
-
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-
|
|
12
|
-
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-
|
|
8
|
+
import { n as getAssistantReplyText } from "./assistant-reply-DbPLvsnL.js";
|
|
9
|
+
import { A as recordFinishedTurnForAutomatedLimit, j as resetAutomatedTurnLimit, k as maybePostAutomatedTurnLimitNotice } from "./session-stop-DlRDisF5.js";
|
|
10
|
+
import { r as appendAndEnqueueInboundMessage } from "./store-Dx1U69mm.js";
|
|
11
|
+
import { t as ConversationTurnLifecycleService } from "./turn-lifecycle-B1VV58Yo.js";
|
|
12
|
+
import { n as getPersistedSandboxState, o as persistThreadStateById, r as getPersistedThreadState } from "./thread-state-Ces6tXmB.js";
|
|
13
13
|
import { isDeepStrictEqual } from "node:util";
|
|
14
14
|
import { z } from "zod";
|
|
15
15
|
//#region src/chat/runtime/turn-execution.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { v as isProviderRetryError } from "./client-
|
|
3
|
-
import { C as withLogContext, d as logException, f as logInfo, p as logWarn } from "./logging-
|
|
4
|
-
import { i as getChatConfig } from "./config-
|
|
5
|
-
import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-
|
|
6
|
-
import { C as requestAnotherSlice, M as isInvalidConversationRecordError, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, j as isFinalAttempt, k as hasConversationStop, l as completeConversationStop, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, s as clearConsumedConversationWake, t as ackMessages, u as completeConversationWork, x as releaseConversationWork, y as recordAttemptFailure } from "./store-
|
|
2
|
+
import { v as isProviderRetryError } from "./client-ROZeVjq0.js";
|
|
3
|
+
import { C as withLogContext, d as logException, f as logInfo, p as logWarn } from "./logging-COUsTFIL.js";
|
|
4
|
+
import { i as getChatConfig } from "./config-DNNkxfGS.js";
|
|
5
|
+
import { f as getTurnRequestDeadline, m as ConversationQueueMessageRejectedError } from "./job-queue-DSQx1qFY.js";
|
|
6
|
+
import { C as requestAnotherSlice, M as isInvalidConversationRecordError, T as startConversationWork, b as recordConversationRetry, d as countPendingConversationMessages, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, j as isFinalAttempt, k as hasConversationStop, l as completeConversationStop, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, s as clearConsumedConversationWake, t as ackMessages, u as completeConversationWork, x as releaseConversationWork, y as recordAttemptFailure } from "./store-Dx1U69mm.js";
|
|
7
7
|
//#region src/chat/task-execution/worker.ts
|
|
8
8
|
var worker_exports = /* @__PURE__ */ __exportAll({
|
|
9
9
|
CONVERSATION_WORK_DEFER_DELAY_MS: () => CONVERSATION_WORK_DEFER_DELAY_MS,
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
CREATE TABLE "junior_automations" (
|
|
2
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
3
|
+
"kind" text NOT NULL,
|
|
4
|
+
"team_id" text NOT NULL,
|
|
5
|
+
"channel_id" text NOT NULL,
|
|
6
|
+
"creator_slack_user_id" text NOT NULL,
|
|
7
|
+
"creator_identity_id" text,
|
|
8
|
+
"status" text NOT NULL,
|
|
9
|
+
"status_reason" text,
|
|
10
|
+
"title" text,
|
|
11
|
+
"instruction" text NOT NULL,
|
|
12
|
+
"created_at_ms" bigint NOT NULL,
|
|
13
|
+
"next_run_at_ms" bigint,
|
|
14
|
+
"run_now_at_ms" bigint,
|
|
15
|
+
"namespace" text,
|
|
16
|
+
"identifier" text,
|
|
17
|
+
"record" jsonb NOT NULL,
|
|
18
|
+
CONSTRAINT "junior_automations_kind_check" CHECK ("junior_automations"."kind" in ('scheduled', 'event')),
|
|
19
|
+
CONSTRAINT "junior_automations_status_check" CHECK ("junior_automations"."status" in ('active', 'blocked', 'paused', 'completed', 'deleted')),
|
|
20
|
+
CONSTRAINT "junior_automations_record_check" CHECK (jsonb_typeof("junior_automations"."record") = 'object'),
|
|
21
|
+
CONSTRAINT "junior_automations_trigger_check" CHECK (("junior_automations"."kind" = 'scheduled' and "junior_automations"."namespace" is null and "junior_automations"."identifier" is null) or ("junior_automations"."kind" = 'event' and "junior_automations"."namespace" is not null and "junior_automations"."identifier" is not null and "junior_automations"."next_run_at_ms" is null and "junior_automations"."run_now_at_ms" is null and "junior_automations"."status" <> 'completed'))
|
|
22
|
+
);
|
|
23
|
+
--> statement-breakpoint
|
|
24
|
+
-- Stop before the copy if a Scheduled automation and an event automation
|
|
25
|
+
-- have the same id.
|
|
26
|
+
DO $$
|
|
27
|
+
BEGIN
|
|
28
|
+
IF EXISTS (
|
|
29
|
+
SELECT 1
|
|
30
|
+
FROM "junior_scheduler_tasks" AS "scheduled"
|
|
31
|
+
JOIN "junior_event_tasks" AS "event" ON "event"."id" = "scheduled"."id"
|
|
32
|
+
) THEN
|
|
33
|
+
RAISE EXCEPTION 'junior_scheduler_tasks and junior_event_tasks share an Automation id';
|
|
34
|
+
END IF;
|
|
35
|
+
END
|
|
36
|
+
$$;
|
|
37
|
+
--> statement-breakpoint
|
|
38
|
+
-- Copy both old tables. Old workers still use them during the deploy, so they
|
|
39
|
+
-- stay. The copy keeps what the old readers read:
|
|
40
|
+
-- - A Scheduled automation takes its status and status reason from its JSON.
|
|
41
|
+
-- - A title and a creator identity come from the column, or else from the
|
|
42
|
+
-- legacy JSON key.
|
|
43
|
+
-- - A status that the new check does not allow becomes "deleted".
|
|
44
|
+
-- JSON keys that now have a column are removed from the record.
|
|
45
|
+
INSERT INTO "junior_automations" (
|
|
46
|
+
"id", "kind", "team_id", "channel_id", "creator_slack_user_id",
|
|
47
|
+
"creator_identity_id", "status", "status_reason", "title", "instruction",
|
|
48
|
+
"created_at_ms", "next_run_at_ms", "run_now_at_ms", "namespace",
|
|
49
|
+
"identifier", "record"
|
|
50
|
+
)
|
|
51
|
+
SELECT
|
|
52
|
+
"id",
|
|
53
|
+
"kind",
|
|
54
|
+
"team_id",
|
|
55
|
+
coalesce("record"->'destination'->>'channelId', ''),
|
|
56
|
+
coalesce("record"->'createdBy'->>'slackUserId', ''),
|
|
57
|
+
"creator_identity_id",
|
|
58
|
+
CASE
|
|
59
|
+
WHEN "status" IN ('active', 'blocked', 'paused', 'completed', 'deleted') THEN "status"
|
|
60
|
+
ELSE 'deleted'
|
|
61
|
+
END,
|
|
62
|
+
"status_reason",
|
|
63
|
+
nullif(btrim(coalesce("title", "record"->>'title')), ''),
|
|
64
|
+
coalesce("record"->'task'->>'text', ''),
|
|
65
|
+
"created_at_ms",
|
|
66
|
+
"next_run_at_ms",
|
|
67
|
+
"run_now_at_ms",
|
|
68
|
+
"namespace",
|
|
69
|
+
"identifier",
|
|
70
|
+
"record" - ARRAY['createdAtMs', 'creatorIdentityId', 'id', 'nextRunAtMs', 'runNowAtMs', 'status', 'statusReason', 'title', 'version']
|
|
71
|
+
FROM (
|
|
72
|
+
SELECT
|
|
73
|
+
'scheduled' AS "kind",
|
|
74
|
+
"id",
|
|
75
|
+
"team_id",
|
|
76
|
+
coalesce("creator_identity_id", "record"->>'creatorIdentityId') AS "creator_identity_id",
|
|
77
|
+
"record"->>'status' AS "status",
|
|
78
|
+
"record"->>'statusReason' AS "status_reason",
|
|
79
|
+
"title",
|
|
80
|
+
"created_at_ms",
|
|
81
|
+
"next_run_at_ms",
|
|
82
|
+
"run_now_at_ms",
|
|
83
|
+
NULL AS "namespace",
|
|
84
|
+
NULL AS "identifier",
|
|
85
|
+
"record"
|
|
86
|
+
FROM "junior_scheduler_tasks"
|
|
87
|
+
UNION ALL
|
|
88
|
+
SELECT
|
|
89
|
+
'event',
|
|
90
|
+
"id",
|
|
91
|
+
"team_id",
|
|
92
|
+
NULL,
|
|
93
|
+
"status",
|
|
94
|
+
"status_reason",
|
|
95
|
+
"title",
|
|
96
|
+
"created_at_ms",
|
|
97
|
+
NULL,
|
|
98
|
+
NULL,
|
|
99
|
+
"namespace",
|
|
100
|
+
"identifier",
|
|
101
|
+
"task_json"
|
|
102
|
+
FROM "junior_event_tasks"
|
|
103
|
+
) AS "source";
|
|
104
|
+
--> statement-breakpoint
|
|
105
|
+
CREATE INDEX "junior_automations_team_idx" ON "junior_automations" USING btree ("team_id","created_at_ms","id") WHERE "junior_automations"."status" <> 'deleted';
|
|
106
|
+
--> statement-breakpoint
|
|
107
|
+
CREATE INDEX "junior_automations_creator_idx" ON "junior_automations" USING btree ("team_id","creator_slack_user_id","created_at_ms","id");
|
|
108
|
+
--> statement-breakpoint
|
|
109
|
+
CREATE INDEX "junior_automations_creator_identity_idx" ON "junior_automations" USING btree ("creator_identity_id","created_at_ms","id") WHERE "junior_automations"."creator_identity_id" IS NOT NULL;
|
|
110
|
+
--> statement-breakpoint
|
|
111
|
+
CREATE INDEX "junior_automations_run_now_due_idx" ON "junior_automations" USING btree ("run_now_at_ms","created_at_ms","id") WHERE "junior_automations"."status" = 'active' AND "junior_automations"."run_now_at_ms" IS NOT NULL;
|
|
112
|
+
--> statement-breakpoint
|
|
113
|
+
CREATE INDEX "junior_automations_next_run_due_idx" ON "junior_automations" USING btree ("next_run_at_ms","created_at_ms","id") WHERE "junior_automations"."status" = 'active' AND "junior_automations"."next_run_at_ms" IS NOT NULL;
|
|
114
|
+
--> statement-breakpoint
|
|
115
|
+
CREATE INDEX "junior_automations_match_idx" ON "junior_automations" USING btree ("namespace","identifier","created_at_ms","id") WHERE "junior_automations"."status" <> 'deleted';
|
|
116
|
+
--> statement-breakpoint
|
|
117
|
+
-- Versions now key on the Automation id. Old workers still write kind during
|
|
118
|
+
-- the deploy, so kind stays as a nullable column until PR 3 of #2176.
|
|
119
|
+
ALTER TABLE "junior_automation_versions" DROP CONSTRAINT "junior_automation_versions_pk";
|
|
120
|
+
--> statement-breakpoint
|
|
121
|
+
ALTER TABLE "junior_automation_versions" ADD CONSTRAINT "junior_automation_versions_pk" PRIMARY KEY("automation_id","version");
|
|
122
|
+
--> statement-breakpoint
|
|
123
|
+
ALTER TABLE "junior_automation_versions" ALTER COLUMN "kind" DROP NOT NULL;
|
|
124
|
+
--> statement-breakpoint
|
|
125
|
+
ALTER TABLE "junior_automation_versions" ADD CONSTRAINT "junior_automation_versions_automation_id_fk" FOREIGN KEY ("automation_id") REFERENCES "public"."junior_automations"("id") ON DELETE cascade ON UPDATE no action;
|