@sentry/junior 0.293.0 → 0.295.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{admin-uuecrKuD.js → admin-ifgjyfpF.js} +2 -2
- package/dist/{agent-runner-DHq1pjUg.js → agent-runner-DjMTPWEO.js} +192 -100
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +5 -5
- package/dist/api.d.ts +1 -1
- package/dist/api.js +73 -29
- package/dist/{app-fWzCHFIb.d.ts → app-uiTzRbvq.d.ts} +5 -3
- package/dist/app.d.ts +2 -2
- package/dist/app.js +64 -74
- package/dist/{automation-BE3z19VN.js → automation-yJX3C7i3.js} +3 -3
- package/dist/{background-compaction-queue-D7ncdEa6.js → background-compaction-queue-DUkHZjmL.js} +7 -9
- package/dist/{briefs-NpgMEFh1.js → briefs-CbNYM-q2.js} +3 -3
- package/dist/{catalog-runtime-DwbTyNRD.js → catalog-runtime-DgouZKZm.js} +1 -1
- package/dist/cli/chat.d.ts +1 -1
- package/dist/cli/chat.js +15 -15
- package/dist/cli/check.js +3 -3
- package/dist/cli/init.js +2 -0
- package/dist/cli/main.js +3 -3
- package/dist/cli/plugins.d.ts +1 -1
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/snapshot-create.js +4 -4
- package/dist/cli/upgrade.d.ts +2 -2
- package/dist/cli/upgrade.js +7 -74
- package/dist/{config-B4b-NXH5.js → config-DvnTPCfp.js} +58 -7
- package/dist/{connections-Dz_AQg5p.js → connections-CWaIVl_1.js} +6 -6
- package/dist/{conversation-CtjR1Zcx.js → conversation-CMkSmi02.js} +3 -11
- package/dist/{conversation-pending-messages-1Kad1Mif.js → conversation-feed-BVAOga0H.js} +27 -2
- package/dist/{conversation-privacy-DRsSgLGO.js → conversation-privacy-DPjv4SnA.js} +1 -1
- package/dist/{credential-sync-ClCnnGVj.js → credential-sync-BhbaZfmO.js} +16 -15
- package/dist/{db-BbpttyKH.d.ts → db-CCUqQe0E.d.ts} +13 -6
- package/dist/{db-CoA7_Xqu.js → db-Dts2XvLu.js} +144 -7
- package/dist/{executor-SWyHhit0.js → executor-Ck73J0wP.js} +64 -10
- package/dist/instrumentation.js +2 -2
- package/dist/{logging-BN5drSEZ.js → logging-9OAq-fdg.js} +2 -1
- package/dist/{message-D4qjpW1C.js → message-CtaPzC7m.js} +9 -9
- package/dist/nitro.d.ts +2 -2
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-Xi-mTLOV.js → oauth-callback-server-C_LXY1d4.js} +2 -2
- package/dist/{oauth-relay-D6xxVywK.js → oauth-relay-CsfIazeF.js} +2 -1
- package/dist/{plugins-DtmjkTza.d.ts → plugins-B_0Cr0MO.d.ts} +0 -1
- package/dist/{projection-DXl4ftyL.js → projection-BzJQncZV.js} +251 -161
- package/dist/{prompt-Dmx6IfWZ.js → prompt-Cbq5b4SO.js} +5 -6
- package/dist/{registry-DosVt9f9.js → registry-cbpOxO4M.js} +3 -13
- package/dist/{resolve-BDjWJC9s.js → resolve-t-pmRdwS.js} +3 -3
- package/dist/{result-CaAFpf4B.js → result-DhgjR3nQ.js} +8 -8
- package/dist/{runner-h96Mkss6.js → runner-CHv9X9TH.js} +8 -8
- package/dist/{sandbox-egress-signals-rK91BW7i.js → sandbox-egress-signals-Yy3fSCbg.js} +1 -1
- package/dist/{schema-C_v8wb80.js → schema-BhneuGYv.js} +39 -7
- package/dist/{schema-CHsBmXIj.d.ts → schema-TSEisVJR.d.ts} +87 -14
- package/dist/secrets-DebYU866.js +18 -0
- package/dist/{service-account-WUMVuqVL.js → service-account-C4rBP8ne.js} +3 -3
- package/dist/{service-account-BpGpScaT.js → service-account-DjPIwCMj.js} +42 -26
- package/dist/{session-stop-xYK15HUu.js → session-stop-DkxI5vc3.js} +20 -775
- package/dist/{skills-DHApyCjj.js → skills-BZE2DP8I.js} +2 -2
- package/dist/{spawn-BQQrwGNe.js → spawn-BvULxIiu.js} +5 -5
- package/dist/{adapter-CMJfmHso.js → state-CO9ETDzk.js} +132 -2
- package/dist/{stop-CBeD6_Gs.js → stop-CL-rdtQb.js} +85 -32
- package/dist/{store-xtibD98L.js → store-DgD78_NK.js} +3 -3
- package/dist/{task-runner-BYPN4BEO.js → task-runner-CKOj6xla.js} +11 -11
- package/dist/{turn-failure-response-jNVl00MD.js → turn-failure-response-BTSo6SMJ.js} +8 -8
- package/dist/{validation-DGeB_moV.js → validation-CXeYgBzq.js} +1 -1
- package/dist/{version-C6nqU3Qc.js → version-AQa7Fr2H.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{viewer-9KLQibjn.js → viewer-Bqkb678l.js} +3 -3
- package/dist/warmup-h6u1e9n0.js +1869 -0
- package/dist/{work-xwX6unUE.js → work-yN_GAuXY.js} +11 -11
- package/dist/{worker-CiCCfwd4.js → worker-Hl7N292I.js} +6 -6
- package/migrations/0062_plugin_report_index.sql +1 -20
- package/migrations/0078_plugin_conversation_index.sql +1 -20
- package/migrations/0079_conversation_event_author_index.sql +1 -20
- package/migrations/0080_conversation_event_latest_message_indexes.sql +2 -27
- package/migrations/0090_guardian_review_time_index.sql +1 -20
- package/migrations/0091_conversation_participant_unsubscribed_index.sql +1 -20
- package/migrations/0097_conversation_kind_automation.sql +6 -0
- package/migrations/0098_review_item_plugin_actions.sql +5 -0
- package/migrations/0099_conversation_last_message_at.sql +1 -0
- package/migrations/0100_automation_task_kind_repair.sql +48 -0
- package/migrations/meta/0097_snapshot.json +4490 -0
- package/migrations/meta/0098_snapshot.json +4490 -0
- package/migrations/meta/0099_snapshot.json +4720 -0
- package/migrations/meta/0100_snapshot.json +4496 -0
- package/migrations/meta/_journal.json +28 -0
- package/package.json +5 -5
- package/dist/assistant-reply-CIApSfor.js +0 -58
- package/dist/warmup-7S6z068f.js +0 -993
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as botConfig } from "./config-
|
|
3
|
-
import {
|
|
4
|
-
import { g as juniorAgentInvocations, h as juniorAgentBindings } from "./executor-
|
|
1
|
+
import { H as PluginCredentialFailureError, K as AuthorizationFlowDisabledError, Sn as renderTag, Xt as isTurnExecutionLimitExceededError, at as failTurnRecord, et as lostWorkerBeforeFirstSave, go as loadForkHistory, nt as saveTurnCheckpoint, ot as getTurnRecord, rt as abandonTurnRecord, s as openConversationProjection, tn as getTerminalAssistantMessages, tt as pauseLostWorkerTurn, v as hydrateConversationMessages, vn as escapeClosingTags } from "./projection-BzJQncZV.js";
|
|
2
|
+
import { n as botConfig } from "./config-DvnTPCfp.js";
|
|
3
|
+
import { M as SYSTEM_IDENTITY_ID, a as getConversationStore, r as getConversationEventStore, s as getSqlExecutor } from "./db-Dts2XvLu.js";
|
|
4
|
+
import { g as juniorAgentInvocations, h as juniorAgentBindings } from "./executor-Ck73J0wP.js";
|
|
5
5
|
import { h as contextProvenance, m as agentInstructionProvenance, v as sameActorIdentity } from "./media-BepyEUNm.js";
|
|
6
|
-
import { Dt as stopChildAgentsOf, Gt as finishTurn, Mt as supersedeOpenMailboxTurns, Ot as recordSubagentEnded, Ut as AgentRunError, Wt as executeTurn, an as AgentNameInUseError, kt as recordSubagentStarted, rn as AgentMessageQueueFullError, tn as AgentInvocationLimitError } from "./agent-runner-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { $ as withoutSavedSteeringMessages, B as maybePostAutomatedTurnLimitNotice, K as recordFinishedTurnForAutomatedLimit, X as buildSteeringPiMessage, Z as instructionForInputs,
|
|
11
|
-
import { r as appendAndEnqueueInboundMessage } from "./store-
|
|
12
|
-
import { ft as getPersistedSandboxState, gt as coerceThreadConversationState, ht as persistThreadStateById, pt as getPersistedThreadState } from "./task-runner-
|
|
6
|
+
import { Dt as stopChildAgentsOf, Gt as finishTurn, Mt as supersedeOpenMailboxTurns, Ot as recordSubagentEnded, Ut as AgentRunError, Wt as executeTurn, an as AgentNameInUseError, kt as recordSubagentStarted, rn as AgentMessageQueueFullError, tn as AgentInvocationLimitError } from "./agent-runner-DjMTPWEO.js";
|
|
7
|
+
import { D as getAssistantReplyText, P as readBlockedReport } from "./warmup-h6u1e9n0.js";
|
|
8
|
+
import { k as getTurnRequestDeadline } from "./background-compaction-queue-DUkHZjmL.js";
|
|
9
|
+
import { $ as getUnnamedAgentConversationId, A as markAgentInvocationPaused, C as isTerminalAgentInvocation, H as agentTypeStartsWithParentHistory, J as getAgentInvocationMessageId, L as agentBindingSchema, M as markAgentInvocationSteered, N as reportReplacedAgentInvocation, O as markAgentInvocationMailboxAppended, Q as getNamedAgentConversationId, T as listOpenAgentInvocations, V as agentTypeInstructions, W as getAgentInvocationId, X as getAgentInvocationTurnId, Z as getChildAgentLockName, _ as completeAgentInvocation, at as getConversationTurnBoundaryError, f as ConversationTurnLifecycleService, g as NON_TERMINAL_AGENT_INVOCATION_STATUSES, h as ACTIVE_AGENT_INVOCATION_STATUSES, j as markAgentInvocationRunning, rt as TurnInputCommitLostError, st as isTurnInputCommitLostError, v as getActiveAgentInvocationForConversation, w as listAgentInvocationsForConversation, x as getLatestAgentInvocationForConversation, y as getAgentInvocation, z as createAgentInvocationSchema } from "./turn-failure-response-BTSo6SMJ.js";
|
|
10
|
+
import { $ as withoutSavedSteeringMessages, B as maybePostAutomatedTurnLimitNotice, K as recordFinishedTurnForAutomatedLimit, X as buildSteeringPiMessage, Z as instructionForInputs, h as parseWebMessages, i as resumeStoppedConversationTree, p as listActiveMailboxTurns, q as resetAutomatedTurnLimit, u as getActiveConversationTurnId } from "./session-stop-DkxI5vc3.js";
|
|
11
|
+
import { r as appendAndEnqueueInboundMessage } from "./store-DgD78_NK.js";
|
|
12
|
+
import { ft as getPersistedSandboxState, gt as coerceThreadConversationState, ht as persistThreadStateById, pt as getPersistedThreadState } from "./task-runner-CKOj6xla.js";
|
|
13
13
|
import { isDeepStrictEqual } from "node:util";
|
|
14
14
|
import * as z from "zod";
|
|
15
15
|
import { and, eq } from "drizzle-orm";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { v as __exportAll } from "./sentry-BRTJqumy.js";
|
|
2
|
-
import { At as isInvalidConversationRecordError, Dt as hasConversationStop, St as countPendingConversationMessages, kt as isFinalAttempt } from "./projection-
|
|
3
|
-
import {
|
|
4
|
-
import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-
|
|
5
|
-
import { Ht as selectAttemptMessages, Vt as isAttemptInterrupt } from "./agent-runner-
|
|
6
|
-
import { k as getTurnRequestDeadline, y as ConversationQueueMessageRejectedError } from "./background-compaction-queue-
|
|
7
|
-
import { C as startConversationWork, b as releaseConversationWork, c as clearConsumedConversationWake, d as completeConversationWork, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, t as ackMessages, u as completeConversationStop, v as recordAttemptFailure, x as requestAnotherSlice, y as recordConversationRetry } from "./store-
|
|
2
|
+
import { At as isInvalidConversationRecordError, Dt as hasConversationStop, St as countPendingConversationMessages, kt as isFinalAttempt } from "./projection-BzJQncZV.js";
|
|
3
|
+
import { K as isProviderRetryError, i as getChatConfig } from "./config-DvnTPCfp.js";
|
|
4
|
+
import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-9OAq-fdg.js";
|
|
5
|
+
import { Ht as selectAttemptMessages, Vt as isAttemptInterrupt } from "./agent-runner-DjMTPWEO.js";
|
|
6
|
+
import { k as getTurnRequestDeadline, y as ConversationQueueMessageRejectedError } from "./background-compaction-queue-DUkHZjmL.js";
|
|
7
|
+
import { C as startConversationWork, b as releaseConversationWork, c as clearConsumedConversationWake, d as completeConversationWork, f as deadLetterAttempt, g as getConversationWorkState, i as beginConversationResume, m as ensureConversationWake, o as checkInConversationWork, p as drainConversationMailbox, t as ackMessages, u as completeConversationStop, v as recordAttemptFailure, x as requestAnotherSlice, y as recordConversationRetry } from "./store-DgD78_NK.js";
|
|
8
8
|
// src/chat/task-execution/worker.ts
|
|
9
9
|
var worker_exports = /* @__PURE__ */ __exportAll({
|
|
10
10
|
CONVERSATION_WORK_DEFER_DELAY_MS: () => CONVERSATION_WORK_DEFER_DELAY_MS,
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
-- CREATE INDEX CONCURRENTLY, so the build below does not block writes.
|
|
3
|
-
DO $$
|
|
4
|
-
BEGIN
|
|
5
|
-
-- Even CREATE INDEX IF NOT EXISTS takes a write-blocking table lock.
|
|
6
|
-
IF to_regclass('junior_conversation_events_plugin_report_idx') IS NULL THEN
|
|
7
|
-
-- junior:concurrent-index
|
|
8
|
-
CREATE INDEX "junior_conversation_events_plugin_report_idx" ON "junior_conversation_events" USING btree (("payload"->>'namespace'),("payload"->>'name'),"created_at") WHERE "junior_conversation_events"."type" = 'structured_event';
|
|
9
|
-
END IF;
|
|
10
|
-
|
|
11
|
-
-- A failed concurrent build can leave an index that exists but cannot be used.
|
|
12
|
-
IF NOT EXISTS (
|
|
13
|
-
SELECT 1 FROM pg_index
|
|
14
|
-
WHERE indexrelid = 'junior_conversation_events_plugin_report_idx'::regclass
|
|
15
|
-
AND indrelid = 'junior_conversation_events'::regclass
|
|
16
|
-
AND indisvalid AND indisready
|
|
17
|
-
) THEN
|
|
18
|
-
RAISE EXCEPTION 'The plugin report index is not valid and ready. Repair the concurrent build before running junior upgrade.';
|
|
19
|
-
END IF;
|
|
20
|
-
END $$;
|
|
1
|
+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_conversation_events_plugin_report_idx" ON "junior_conversation_events" USING btree (("payload"->>'namespace'),("payload"->>'name'),"created_at") WHERE "junior_conversation_events"."type" = 'structured_event';
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
-- CREATE INDEX CONCURRENTLY, so the build below does not block writes.
|
|
3
|
-
DO $$
|
|
4
|
-
BEGIN
|
|
5
|
-
-- Even CREATE INDEX IF NOT EXISTS takes a write-blocking table lock.
|
|
6
|
-
IF to_regclass('junior_conversation_events_plugin_conversation_idx') IS NULL THEN
|
|
7
|
-
-- junior:concurrent-index
|
|
8
|
-
CREATE INDEX "junior_conversation_events_plugin_conversation_idx" ON "junior_conversation_events" USING btree ("conversation_id",("payload"->>'namespace'),("payload"->>'name'),"seq") WHERE "junior_conversation_events"."type" = 'structured_event';
|
|
9
|
-
END IF;
|
|
10
|
-
|
|
11
|
-
-- A failed concurrent build can leave an index that exists but cannot be used.
|
|
12
|
-
IF NOT EXISTS (
|
|
13
|
-
SELECT 1 FROM pg_index
|
|
14
|
-
WHERE indexrelid = 'junior_conversation_events_plugin_conversation_idx'::regclass
|
|
15
|
-
AND indrelid = 'junior_conversation_events'::regclass
|
|
16
|
-
AND indisvalid AND indisready
|
|
17
|
-
) THEN
|
|
18
|
-
RAISE EXCEPTION 'The plugin conversation index is not valid and ready. Repair the concurrent build before running junior upgrade.';
|
|
19
|
-
END IF;
|
|
20
|
-
END $$;
|
|
1
|
+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_conversation_events_plugin_conversation_idx" ON "junior_conversation_events" USING btree ("conversation_id",("payload"->>'namespace'),("payload"->>'name'),"seq") WHERE "junior_conversation_events"."type" = 'structured_event';
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
-- CREATE INDEX CONCURRENTLY, so the build below does not block writes.
|
|
3
|
-
DO $$
|
|
4
|
-
BEGIN
|
|
5
|
-
-- Even CREATE INDEX IF NOT EXISTS takes a write-blocking table lock.
|
|
6
|
-
IF to_regclass('junior_conversation_events_author_idx') IS NULL THEN
|
|
7
|
-
-- junior:concurrent-index
|
|
8
|
-
CREATE INDEX "junior_conversation_events_author_idx" ON "junior_conversation_events" USING btree ("conversation_id","actor_identity_id","seq") WHERE "junior_conversation_events"."actor_identity_id" is not null;
|
|
9
|
-
END IF;
|
|
10
|
-
|
|
11
|
-
-- A failed concurrent build can leave an index that exists but cannot be used.
|
|
12
|
-
IF NOT EXISTS (
|
|
13
|
-
SELECT 1 FROM pg_index
|
|
14
|
-
WHERE indexrelid = 'junior_conversation_events_author_idx'::regclass
|
|
15
|
-
AND indrelid = 'junior_conversation_events'::regclass
|
|
16
|
-
AND indisvalid AND indisready
|
|
17
|
-
) THEN
|
|
18
|
-
RAISE EXCEPTION 'The conversation event author index is not valid and ready. Repair the concurrent build before running junior upgrade.';
|
|
19
|
-
END IF;
|
|
20
|
-
END $$;
|
|
1
|
+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_conversation_events_author_idx" ON "junior_conversation_events" USING btree ("conversation_id","actor_identity_id","seq") WHERE "junior_conversation_events"."actor_identity_id" is not null;
|
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
DO $$
|
|
4
|
-
BEGIN
|
|
5
|
-
-- Even CREATE INDEX IF NOT EXISTS takes a write-blocking table lock.
|
|
6
|
-
IF to_regclass('junior_conversation_events_message_role_idx') IS NULL THEN
|
|
7
|
-
-- junior:concurrent-index
|
|
8
|
-
CREATE INDEX "junior_conversation_events_message_role_idx" ON "junior_conversation_events" USING btree ("conversation_id",("payload"->>'role'),"created_at","seq") WHERE "junior_conversation_events"."type" = 'message';
|
|
9
|
-
END IF;
|
|
10
|
-
IF to_regclass('junior_conversation_events_user_message_time_idx') IS NULL THEN
|
|
11
|
-
-- junior:concurrent-index
|
|
12
|
-
CREATE INDEX "junior_conversation_events_user_message_time_idx" ON "junior_conversation_events" USING btree ("conversation_id","created_at","seq") WHERE "junior_conversation_events"."type" = 'user_message' and ("junior_conversation_events"."payload"->'provenance'->>'authority') = 'instruction' and ("junior_conversation_events"."payload"->'provenance'->'actor'->>'platform') in ('slack', 'local', 'web');
|
|
13
|
-
END IF;
|
|
14
|
-
|
|
15
|
-
-- A failed concurrent build can leave an index that exists but cannot be used.
|
|
16
|
-
IF (
|
|
17
|
-
SELECT count(*) FROM pg_index
|
|
18
|
-
WHERE indexrelid IN (
|
|
19
|
-
'junior_conversation_events_message_role_idx'::regclass,
|
|
20
|
-
'junior_conversation_events_user_message_time_idx'::regclass
|
|
21
|
-
)
|
|
22
|
-
AND indrelid = 'junior_conversation_events'::regclass
|
|
23
|
-
AND indisvalid AND indisready
|
|
24
|
-
) <> 2 THEN
|
|
25
|
-
RAISE EXCEPTION 'The conversation event latest message indexes are not valid and ready. Repair the concurrent builds before running junior upgrade.';
|
|
26
|
-
END IF;
|
|
27
|
-
END $$;
|
|
1
|
+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_conversation_events_message_role_idx" ON "junior_conversation_events" USING btree ("conversation_id",("payload"->>'role'),"created_at","seq") WHERE "junior_conversation_events"."type" = 'message';--> statement-breakpoint
|
|
2
|
+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_conversation_events_user_message_time_idx" ON "junior_conversation_events" USING btree ("conversation_id","created_at","seq") WHERE "junior_conversation_events"."type" = 'user_message' and ("junior_conversation_events"."payload"->'provenance'->>'authority') = 'instruction' and ("junior_conversation_events"."payload"->'provenance'->'actor'->>'platform') in ('slack', 'local', 'web');
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
-- CREATE INDEX CONCURRENTLY, so the build below does not block writes.
|
|
3
|
-
DO $$
|
|
4
|
-
BEGIN
|
|
5
|
-
-- Even CREATE INDEX IF NOT EXISTS takes a write-blocking table lock.
|
|
6
|
-
IF to_regclass('junior_conversation_events_guardian_review_time_idx') IS NULL THEN
|
|
7
|
-
-- junior:concurrent-index
|
|
8
|
-
CREATE INDEX "junior_conversation_events_guardian_review_time_idx" ON "junior_conversation_events" USING btree ("created_at") WHERE "junior_conversation_events"."type" = 'guardian_action_reviewed';
|
|
9
|
-
END IF;
|
|
10
|
-
|
|
11
|
-
-- A failed concurrent build can leave an index that exists but cannot be used.
|
|
12
|
-
IF NOT EXISTS (
|
|
13
|
-
SELECT 1 FROM pg_index
|
|
14
|
-
WHERE indexrelid = 'junior_conversation_events_guardian_review_time_idx'::regclass
|
|
15
|
-
AND indrelid = 'junior_conversation_events'::regclass
|
|
16
|
-
AND indisvalid AND indisready
|
|
17
|
-
) THEN
|
|
18
|
-
RAISE EXCEPTION 'The Guardian review time index is not valid and ready. Repair the concurrent build before running junior upgrade.';
|
|
19
|
-
END IF;
|
|
20
|
-
END $$;
|
|
1
|
+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_conversation_events_guardian_review_time_idx" ON "junior_conversation_events" USING btree ("created_at") WHERE "junior_conversation_events"."type" = 'guardian_action_reviewed';
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
-- CREATE INDEX CONCURRENTLY, so the build below does not block writes.
|
|
3
|
-
DO $$
|
|
4
|
-
BEGIN
|
|
5
|
-
-- Even CREATE INDEX IF NOT EXISTS takes a write-blocking table lock.
|
|
6
|
-
IF to_regclass('junior_conversation_participants_unsubscribed_idx') IS NULL THEN
|
|
7
|
-
-- junior:concurrent-index
|
|
8
|
-
CREATE INDEX "junior_conversation_participants_unsubscribed_idx" ON "junior_conversation_participants" USING btree ("user_id","root_conversation_id") WHERE "junior_conversation_participants"."unsubscribed_at" is not null;
|
|
9
|
-
END IF;
|
|
10
|
-
|
|
11
|
-
-- A failed concurrent build can leave an index that exists but cannot be used.
|
|
12
|
-
IF NOT EXISTS (
|
|
13
|
-
SELECT 1 FROM pg_index
|
|
14
|
-
WHERE indexrelid = 'junior_conversation_participants_unsubscribed_idx'::regclass
|
|
15
|
-
AND indrelid = 'junior_conversation_participants'::regclass
|
|
16
|
-
AND indisvalid AND indisready
|
|
17
|
-
) THEN
|
|
18
|
-
RAISE EXCEPTION 'The conversation participant unsubscribed index is not valid and ready. Repair the concurrent build before running junior upgrade.';
|
|
19
|
-
END IF;
|
|
20
|
-
END $$;
|
|
1
|
+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_conversation_participants_unsubscribed_idx" ON "junior_conversation_participants" USING btree ("user_id","root_conversation_id") WHERE "junior_conversation_participants"."unsubscribed_at" is not null;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- NOT VALID: the widened checks accept every existing row, so they skip the
|
|
2
|
+
-- scan and still hold for every new write.
|
|
3
|
+
ALTER TABLE "junior_conversations" DROP CONSTRAINT "junior_conversations_kind_check";--> statement-breakpoint
|
|
4
|
+
ALTER TABLE "junior_conversations" DROP CONSTRAINT "junior_conversations_kind_parent_check";--> statement-breakpoint
|
|
5
|
+
ALTER TABLE "junior_conversations" ADD CONSTRAINT "junior_conversations_kind_check" CHECK ("junior_conversations"."kind" in ('root', 'automation', 'thread', 'task')) NOT VALID;--> statement-breakpoint
|
|
6
|
+
ALTER TABLE "junior_conversations" ADD CONSTRAINT "junior_conversations_kind_parent_check" CHECK ("junior_conversations"."kind" is null or (("junior_conversations"."kind" in ('root', 'automation')) = ("junior_conversations"."parent_conversation_id" is null))) NOT VALID;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
ALTER TABLE "junior_review_items" DROP CONSTRAINT "junior_review_items_kind_check";--> statement-breakpoint
|
|
2
|
+
-- The new check only allows more rows than the old one, so every row passes.
|
|
3
|
+
-- NOT VALID skips the scan under lock and still checks every new write. A
|
|
4
|
+
-- later migration validates it.
|
|
5
|
+
ALTER TABLE "junior_review_items" ADD CONSTRAINT "junior_review_items_kind_check" CHECK (("junior_review_items"."kind" = 'notice' and "junior_review_items"."request" is null and "junior_review_items"."answer" is null) or ("junior_review_items"."kind" = 'action' and ("junior_review_items"."request" is not null or ("junior_review_items"."dedupe_key" like 'plugin:%' and "junior_review_items"."answer" is null)))) NOT VALID;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "junior_conversations" ADD COLUMN "last_message_at" timestamp with time zone;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
-- Repeat the `{ text }` task rewrite of 0096_automation_task_kind.
|
|
2
|
+
-- `junior upgrade` runs migrations before the new runtime takes traffic. In
|
|
3
|
+
-- that window the old runtime still created Automations, and it wrote the old
|
|
4
|
+
-- `{ text }` task and an `instruction` version definition after 0096 ran.
|
|
5
|
+
-- The new runtime cannot read those rows. Each statement changes only rows
|
|
6
|
+
-- with the old shape, so this migration is safe to run again.
|
|
7
|
+
-- junior:bounded-backfill: changes only active or paused Automations with an old, blank task, which cannot run, so few rows match.
|
|
8
|
+
UPDATE "junior_automations"
|
|
9
|
+
SET
|
|
10
|
+
"status" = 'blocked',
|
|
11
|
+
"status_reason" = 'This automation has no instruction. Write one or choose a skill, then resume it.'
|
|
12
|
+
WHERE "record"->'task' ? 'text'
|
|
13
|
+
AND btrim("record"->'task'->>'text', E' \t\r\n') = ''
|
|
14
|
+
AND "status" IN ('active', 'paused');--> statement-breakpoint
|
|
15
|
+
-- junior:bounded-backfill: changes only Automations with an old task, which the old runtime wrote during one rollout, so few rows match.
|
|
16
|
+
WITH "old" AS (
|
|
17
|
+
SELECT
|
|
18
|
+
"id",
|
|
19
|
+
coalesce(
|
|
20
|
+
nullif(btrim("record"->'task'->>'text', E' \t\r\n'), ''),
|
|
21
|
+
'No instruction was saved.'
|
|
22
|
+
) AS "instruction"
|
|
23
|
+
FROM "junior_automations"
|
|
24
|
+
WHERE "record"->'task' ? 'text'
|
|
25
|
+
)
|
|
26
|
+
UPDATE "junior_automations"
|
|
27
|
+
SET
|
|
28
|
+
"instruction" = "old"."instruction",
|
|
29
|
+
"record" = jsonb_set(
|
|
30
|
+
"record",
|
|
31
|
+
'{task}',
|
|
32
|
+
jsonb_build_object('kind', 'instruction', 'instruction', "old"."instruction")
|
|
33
|
+
)
|
|
34
|
+
FROM "old"
|
|
35
|
+
WHERE "junior_automations"."id" = "old"."id";--> statement-breakpoint
|
|
36
|
+
-- junior:bounded-backfill: changes only saved versions with an old definition, which the old runtime wrote during one rollout, so few rows match.
|
|
37
|
+
UPDATE "junior_automation_versions"
|
|
38
|
+
SET "definition" = ("definition" - 'instruction') || jsonb_build_object(
|
|
39
|
+
'task',
|
|
40
|
+
jsonb_build_object(
|
|
41
|
+
'kind', 'instruction',
|
|
42
|
+
'instruction', coalesce(
|
|
43
|
+
nullif(btrim("definition"->>'instruction', E' \t\r\n'), ''),
|
|
44
|
+
'No instruction was saved.'
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
WHERE "definition" ? 'instruction';
|