@sentry/junior 0.311.0 → 0.312.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-context-G2M0y6rP.js → adapter-context-BRjEWRy1.js} +2 -2
- package/dist/{adapter-B1wujchl.js → adapter-iIq7ihf7.js} +1 -1
- package/dist/{admin-DCiBhUT1.js → admin-DhInw5K9.js} +1 -1
- package/dist/{agent-runner-BVHPUIc8.js → agent-runner-C9iDurwX.js} +3423 -3477
- package/dist/api/schema.d.ts +2 -2
- package/dist/api/schema.js +6 -6
- package/dist/api.d.ts +2 -2
- package/dist/api.js +289 -306
- package/dist/{app-Cw5Vy6H6.d.ts → app-DRFrC8Mw.d.ts} +2 -9
- package/dist/app.d.ts +1 -1
- package/dist/app.js +338 -604
- package/dist/{background-compaction-queue-CJDnWVOJ.js → background-compaction-queue-DrKi7w3d.js} +10 -85
- package/dist/callback-mFlTUWWx.js +75 -0
- package/dist/{catalog-runtime-DMY3VV-D.js → catalog-runtime-D7xapBAX.js} +1 -1
- package/dist/channel-access-CJGfNTdn.js +221 -0
- package/dist/child-message-DcsritGf.js +179 -0
- package/dist/cli/chat.js +18 -19
- package/dist/cli/check.js +3 -3
- package/dist/cli/init.js +0 -1
- package/dist/cli/main.js +3 -7
- package/dist/cli/plugins.js +4 -4
- package/dist/cli/run.d.ts +1 -2
- package/dist/cli/run.js +1 -2
- package/dist/cli/snapshot-create.js +5 -5
- package/dist/cli/upgrade.d.ts +1 -1
- package/dist/cli/upgrade.js +3 -3
- package/dist/{config-BrXDQefC.js → config-kXB2Y5tl.js} +59 -27
- package/dist/{continue-in-slack-DNXSC9So.js → continue-in-slack-O6pV5004.js} +7 -8
- package/dist/{conversation-feed-DkinDu5o.js → conversation-feed-uNOv_x68.js} +74 -20
- package/dist/{conversation-privacy-DxttrKb9.js → conversation-privacy-L4ja1_W6.js} +1 -1
- package/dist/{conversation-turn-DWw7Xhdr.js → conversation-turn-CeLbHqdw.js} +31 -27
- package/dist/{credential-sync-Bk8wGb8Y.js → credential-sync-I8VBGk05.js} +16 -15
- package/dist/{projection-Cns7XwWa.js → credentialed-Cb6E2phL.js} +16308 -20732
- package/dist/{db-7ETESH44.d.ts → db-BbC5stfa.d.ts} +11 -6
- package/dist/{db-DTxzH7u5.js → db-LAyyX8tk.js} +174 -91
- package/dist/{executor-DqTiYj9S.js → executor-SCub-fAq.js} +117 -97
- package/dist/{html-B9Sl4Axb.js → html-BCZ3Xtb_.js} +6 -6
- package/dist/ingest-BDf3D50j.js +3836 -0
- package/dist/{install-Sg4ePfLl.js → install-DCFJFkC0.js} +2 -2
- package/dist/instrumentation.js +3 -3
- package/dist/{lineage-BHAMpNKr.js → lineage-B_m-4TJw.js} +2 -2
- package/dist/{stop-CYsfc0Ed.js → list-CN2QA2R9.js} +663 -442
- package/dist/{logging-FjclQsXu.js → logging-dQ9ZRGQ8.js} +1 -1
- package/dist/{schedule-BLJ476XQ.js → media-CYm1QD8T.js} +1055 -11
- package/dist/{message-CJ7_RL50.js → message-DSXGj1hM.js} +19 -26
- package/dist/{model-input-CMLh4Cwq.js → model-input--TrP9hYV.js} +3 -3
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +4 -3
- package/dist/{oauth-callback-server-RVcbiDjL.js → oauth-callback-server-DHCZC6B4.js} +2 -2
- package/dist/{oauth-relay-Bu9kkaQu.js → oauth-relay-pPMGnDZt.js} +1 -1
- package/dist/{registry-BPwuOP2O.js → registry-CZOzddwu.js} +1 -1
- package/dist/{resolve-BK29bBry.js → resolve-cKOQ14Dh.js} +3 -3
- package/dist/result-DcvEOe1r.js +574 -0
- package/dist/result-event-type-BdIJuZxg.js +48 -0
- package/dist/{runner-BcAE-cJm.js → runner-DBfUW44l.js} +14 -16
- package/dist/{sandbox-egress-signals-C-q0go5b.js → sandbox-egress-signals-BVF_xAm1.js} +1 -1
- package/dist/{schema-DYcJeV7d.d.ts → schema-BEHKxr4I.d.ts} +166 -242
- package/dist/{schema-BLgSZXcL.js → schema-Bk9Nm2E8.js} +106 -121
- package/dist/{service-account-iJoCtkHR.js → service-account-CVYsFjty.js} +3 -3
- package/dist/{service-account-gN0zqf0S.js → service-account-Ts4ulcrV.js} +5 -5
- package/dist/{skills-BoZ80epJ.js → skills-VTnhAJWm.js} +2 -2
- package/dist/{slack-conversation-unfurl-CogYrITA.js → slack-conversation-unfurl-fuLnF1jE.js} +9 -9
- package/dist/{spawn-Dk92r7mX.js → spawn-vxAarlX5.js} +6 -5
- package/dist/start-conversation-CEn2KH1A.js +941 -0
- package/dist/{state-DH3Cmgp3.js → state-C1P3_Ywk.js} +4 -4
- package/dist/statuses-_cRJHXK7.js +150 -0
- package/dist/store-DFZaN-Ix.js +492 -0
- package/dist/task-queue-Cx4Lmjyk.js +90 -0
- package/dist/task-runner-CbTwFA6k.js +1432 -0
- package/dist/{thread-context-BW2BsQbH.js → thread-context-BkAZDTX2.js} +7 -7
- package/dist/thread-state-DhPndWi1.js +5625 -0
- package/dist/{validation-DrJd0nnq.js → validation-nIzMtAVJ.js} +1 -1
- package/dist/{task-queue-C_zldF5J.js → vercel-queue-hW90XzbG.js} +93 -172
- package/dist/{version-CNKZ8owc.js → version-Brbtz4Qf.js} +1 -1
- package/dist/version.js +1 -1
- package/dist/{warmup-BWdHew2H.js → warmup-BDA5myRK.js} +6463 -12290
- package/dist/web-message-id-C6P83ans.js +10 -0
- package/dist/{worker-t9qpu_Zx.js → worker-D63RcaVD.js} +20 -7
- package/migrations/0143_todos.sql +14 -0
- package/migrations/0144_inbox_items.sql +32 -0
- package/migrations/0145_todo_changed_by_agent.sql +1 -0
- package/migrations/0146_inbox_item_subject_title_parts.sql +1 -0
- package/migrations/0147_inbox_snooze_wake_reason.sql +1 -0
- package/migrations/0148_authorization_request_index.sql +1 -0
- package/migrations/0149_conversation_metadata.sql +10 -0
- package/migrations/0150_conversation_metadata_fill.sql +39 -0
- package/migrations/0151_conversation_search_index.sql +1 -0
- package/migrations/0152_inbox_item_legacy_automation_keys.sql +21 -0
- package/migrations/0153_artifact_expiry.sql +1 -0
- package/migrations/0154_artifact_permanent_sha_index.sql +1 -0
- package/migrations/0155_artifact_drop_public_sha_index.sql +3 -0
- package/migrations/0156_conversation_kind_lead.sql +6 -0
- package/migrations/0157_conversation_lead_actor_index.sql +1 -0
- package/migrations/meta/0143_snapshot.json +6434 -0
- package/migrations/meta/0144_snapshot.json +6434 -0
- package/migrations/meta/0145_snapshot.json +6440 -0
- package/migrations/meta/0146_snapshot.json +6446 -0
- package/migrations/meta/0147_snapshot.json +6452 -0
- package/migrations/meta/0148_snapshot.json +6474 -0
- package/migrations/meta/0149_snapshot.json +6490 -0
- package/migrations/meta/0150_snapshot.json +6490 -0
- package/migrations/meta/0151_snapshot.json +6505 -0
- package/migrations/meta/0152_snapshot.json +6505 -0
- package/migrations/meta/0153_snapshot.json +6511 -0
- package/migrations/meta/0154_snapshot.json +6533 -0
- package/migrations/meta/0155_snapshot.json +6511 -0
- package/migrations/meta/0156_snapshot.json +6511 -0
- package/migrations/meta/0157_snapshot.json +6527 -0
- package/migrations/meta/_journal.json +106 -1
- package/package.json +6 -6
- package/skills/design-automation-skill/SKILL.md +108 -0
- package/dist/briefs-BDjnug6Y.js +0 -395
- package/dist/conversation-ca__NDQW.js +0 -1063
- package/dist/prompt-CDqcsDYC.js +0 -910
- package/dist/store-DmmMIrQi.js +0 -335
- package/dist/task-runner-C7oCJQIx.js +0 -294
- package/dist/turn-session-routing-Xh_2nSQe.js +0 -261
- package/dist/web-message-id-Ch5dPq-a.js +0 -306
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/chat/conversations/web-message-id.ts
|
|
2
|
+
/**
|
|
3
|
+
* Build the retry-stable Message id shared by web ingress and browser sends.
|
|
4
|
+
* Keep the existing hash and prefix so retries still address stored Messages.
|
|
5
|
+
*/
|
|
6
|
+
async function webMessageId(args) {
|
|
7
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(`${args.conversationId}\u0000${args.idempotencyKey}`));
|
|
8
|
+
return `api-msg:${Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("").slice(0, 24)}`;
|
|
9
|
+
}
|
|
10
|
+
export { webMessageId as t };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BKpuH2hG.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { _ as
|
|
8
|
-
import { C as requestAnotherSlice, S as releaseConversationWork, T as startConversationWork, _ as getConversationWorkState, b as recordAttemptFailure, c as clearConsumedConversationWake, d as completeConversationWork, f as deadLetterAttempt, h as ensureConversationWake, i as beginConversationResume, o as checkInConversationWork, p as drainConversationMailbox, t as ackMessages, u as completeConversationStop, x as recordConversationRetry } from "./store-DmmMIrQi.js";
|
|
2
|
+
import { ft as isProviderRetryError, r as getChatConfig } from "./config-kXB2Y5tl.js";
|
|
3
|
+
import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-dQ9ZRGQ8.js";
|
|
4
|
+
import { A as saveHeldInput, D as getConversationStoppedAtMs } from "./ingest-BDf3D50j.js";
|
|
5
|
+
import { n as getTurnRequestDeadline } from "./callback-mFlTUWWx.js";
|
|
6
|
+
import { i as ConversationQueueMessageRejectedError, s as nudgeIdempotencyKey } from "./vercel-queue-hW90XzbG.js";
|
|
7
|
+
import { A as requestAnotherSlice, D as recordAttemptFailure, M as startConversationWork, O as recordConversationRetry, S as ensureConversationWake, _ as completeConversationStop, an as isInvalidConversationRecordError, b as drainConversationMailbox, en as countPendingConversationMessages, f as checkInConversationWork, h as clearConsumedConversationWake, in as isFinalAttempt, k as releaseConversationWork, mn as selectAttemptMessages, nn as hasConversationStop, p as claimConversationAttempt, pn as isAttemptInterrupt, s as ackMessages, u as beginConversationResume, v as completeConversationWork, w as getConversationWorkState, y as deadLetterAttempt } from "./thread-state-DhPndWi1.js";
|
|
9
8
|
// src/chat/task-execution/lost-lease.ts
|
|
10
9
|
/**
|
|
11
10
|
* Count a slice that lost its Conversation Lease as a failed attempt, then
|
|
@@ -366,6 +365,20 @@ async function processConversationWorkInContext(message, options) {
|
|
|
366
365
|
}
|
|
367
366
|
}
|
|
368
367
|
attemptMessageIds = attemptMessages.map((message) => message.inboundMessageId);
|
|
368
|
+
if (attemptMessageIds.length > 0) {
|
|
369
|
+
const claim = await claimConversationAttempt({
|
|
370
|
+
conversationId,
|
|
371
|
+
inboundMessageIds: attemptMessageIds,
|
|
372
|
+
leaseToken: lease.leaseToken,
|
|
373
|
+
nowMs: now(options),
|
|
374
|
+
state: options.state
|
|
375
|
+
});
|
|
376
|
+
if (claim.status === "held") {
|
|
377
|
+
await saveHeldInput(conversationId, claim.messages);
|
|
378
|
+
if (claim.pendingCount === 0 && !resumePending) break;
|
|
379
|
+
}
|
|
380
|
+
if (claim.status !== "claimed") continue;
|
|
381
|
+
}
|
|
369
382
|
attemptSelectedMessageIds = new Set(attemptMessageIds);
|
|
370
383
|
const ack = async () => {
|
|
371
384
|
if (!await ackMessages({
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
ALTER SEQUENCE "public"."junior_plan_item_version_seq" RENAME TO "junior_todo_version_seq";--> statement-breakpoint
|
|
2
|
+
ALTER TABLE "junior_plan_items" RENAME TO "junior_todos";--> statement-breakpoint
|
|
3
|
+
DROP INDEX "junior_plan_items_in_progress_uidx";--> statement-breakpoint
|
|
4
|
+
ALTER TABLE "junior_todos" DROP CONSTRAINT "junior_plan_items_status_check";--> statement-breakpoint
|
|
5
|
+
-- junior:bounded-backfill: Each Conversation has only a few To-dos.
|
|
6
|
+
UPDATE "junior_todos" SET "status" = CASE "status" WHEN 'in_progress' THEN 'in_progress' WHEN 'done' THEN 'done' WHEN 'cancelled' THEN 'dropped' ELSE 'open' END;--> statement-breakpoint
|
|
7
|
+
-- The update above maps every existing row. NOT VALID skips the scan under
|
|
8
|
+
-- lock and still checks every new write.
|
|
9
|
+
ALTER TABLE "junior_todos" ADD CONSTRAINT "junior_todos_status_check" CHECK ("junior_todos"."status" in ('open', 'in_progress', 'done', 'dropped')) NOT VALID;--> statement-breakpoint
|
|
10
|
+
ALTER TABLE "junior_todos" RENAME CONSTRAINT "junior_plan_items_assignee_check" TO "junior_todos_assignee_check";--> statement-breakpoint
|
|
11
|
+
ALTER TABLE "junior_todos" RENAME CONSTRAINT "junior_plan_items_pk" TO "junior_todos_pk";--> statement-breakpoint
|
|
12
|
+
ALTER TABLE "junior_todos" RENAME CONSTRAINT "junior_plan_items_assignee_user_id_junior_users_id_fk" TO "junior_todos_assignee_user_id_junior_users_id_fk";--> statement-breakpoint
|
|
13
|
+
ALTER TABLE "junior_todos" RENAME CONSTRAINT "junior_plan_items_changed_by_user_id_junior_users_id_fk" TO "junior_todos_changed_by_user_id_junior_users_id_fk";--> statement-breakpoint
|
|
14
|
+
ALTER TABLE "junior_todos" RENAME CONSTRAINT "junior_plan_items_conversation_id_fk" TO "junior_todos_conversation_id_fk";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
ALTER TABLE "junior_review_items" RENAME TO "junior_inbox_items";--> statement-breakpoint
|
|
2
|
+
ALTER TABLE "junior_review_item_assignees" RENAME TO "junior_inbox_item_assignees";--> statement-breakpoint
|
|
3
|
+
ALTER TABLE "junior_review_item_conversations" RENAME TO "junior_inbox_item_conversations";--> statement-breakpoint
|
|
4
|
+
ALTER TABLE "junior_review_item_slack_cards" RENAME TO "junior_inbox_item_slack_cards";--> statement-breakpoint
|
|
5
|
+
ALTER TABLE "junior_inbox_snoozes" RENAME COLUMN "review_item_id" TO "inbox_item_id";--> statement-breakpoint
|
|
6
|
+
ALTER INDEX "junior_inbox_snoozes_review_item_idx" RENAME TO "junior_inbox_snoozes_inbox_item_idx";--> statement-breakpoint
|
|
7
|
+
ALTER TABLE "junior_inbox_snoozes" RENAME CONSTRAINT "junior_inbox_snoozes_review_item_id_junior_review_items_id_fk" TO "junior_inbox_snoozes_inbox_item_id_junior_inbox_items_id_fk";--> statement-breakpoint
|
|
8
|
+
ALTER INDEX "junior_review_item_assignees_user_idx" RENAME TO "junior_inbox_item_assignees_user_idx";--> statement-breakpoint
|
|
9
|
+
ALTER TABLE "junior_inbox_item_assignees" RENAME CONSTRAINT "junior_review_item_assignees_item_id_junior_review_items_id_fk" TO "junior_inbox_item_assignees_item_id_junior_inbox_items_id_fk";--> statement-breakpoint
|
|
10
|
+
ALTER TABLE "junior_inbox_item_assignees" RENAME CONSTRAINT "junior_review_item_assignees_user_id_junior_users_id_fk" TO "junior_inbox_item_assignees_user_id_junior_users_id_fk";--> statement-breakpoint
|
|
11
|
+
ALTER TABLE "junior_inbox_item_assignees" RENAME CONSTRAINT "junior_review_item_assignees_item_id_user_id_pk" TO "junior_inbox_item_assignees_item_id_user_id_pk";--> statement-breakpoint
|
|
12
|
+
ALTER INDEX "junior_review_item_conversations_conversation_idx" RENAME TO "junior_inbox_item_conversations_conversation_idx";--> statement-breakpoint
|
|
13
|
+
ALTER TABLE "junior_inbox_item_conversations" RENAME CONSTRAINT "junior_review_item_conversations_item_id_junior_review_items_id_fk" TO "junior_inbox_item_conversations_item_id_junior_inbox_items_id_fk";--> statement-breakpoint
|
|
14
|
+
ALTER TABLE "junior_inbox_item_conversations" RENAME CONSTRAINT "junior_review_item_conversations_conversation_id_junior_conversations_conversation_id_fk" TO "junior_inbox_item_conversations_conversation_id_junior_conversations_conversation_id_fk";--> statement-breakpoint
|
|
15
|
+
ALTER TABLE "junior_inbox_item_conversations" RENAME CONSTRAINT "junior_review_item_conversations_item_id_conversation_id_pk" TO "junior_inbox_item_conversations_item_id_conversation_id_pk";--> statement-breakpoint
|
|
16
|
+
ALTER TABLE "junior_inbox_item_slack_cards" RENAME CONSTRAINT "junior_review_item_slack_cards_item_id_junior_review_items_id_fk" TO "junior_inbox_item_slack_cards_item_id_junior_inbox_items_id_fk";--> statement-breakpoint
|
|
17
|
+
ALTER TABLE "junior_inbox_item_slack_cards" RENAME CONSTRAINT "junior_review_item_slack_cards_conversation_id_junior_conversations_conversation_id_fk" TO "junior_inbox_item_slack_cards_conversation_id_junior_conversations_conversation_id_fk";--> statement-breakpoint
|
|
18
|
+
ALTER TABLE "junior_inbox_item_slack_cards" RENAME CONSTRAINT "junior_review_item_slack_cards_item_id_conversation_id_pk" TO "junior_inbox_item_slack_cards_item_id_conversation_id_pk";--> statement-breakpoint
|
|
19
|
+
ALTER INDEX "junior_review_items_open_dedupe_uidx" RENAME TO "junior_inbox_items_open_dedupe_uidx";--> statement-breakpoint
|
|
20
|
+
ALTER INDEX "junior_review_items_status_idx" RENAME TO "junior_inbox_items_status_idx";--> statement-breakpoint
|
|
21
|
+
ALTER INDEX "junior_review_items_subject_idx" RENAME TO "junior_inbox_items_subject_idx";--> statement-breakpoint
|
|
22
|
+
ALTER INDEX "junior_review_items_owner_idx" RENAME TO "junior_inbox_items_owner_idx";--> statement-breakpoint
|
|
23
|
+
ALTER INDEX "junior_review_items_open_action_owner_idx" RENAME TO "junior_inbox_items_open_action_owner_idx";--> statement-breakpoint
|
|
24
|
+
ALTER INDEX "junior_review_items_automation_idx" RENAME TO "junior_inbox_items_automation_idx";--> statement-breakpoint
|
|
25
|
+
ALTER INDEX "junior_review_items_answered_idx" RENAME TO "junior_inbox_items_answered_idx";--> statement-breakpoint
|
|
26
|
+
ALTER TABLE "junior_inbox_items" RENAME CONSTRAINT "junior_review_items_kind_check" TO "junior_inbox_items_kind_check";--> statement-breakpoint
|
|
27
|
+
ALTER TABLE "junior_inbox_items" RENAME CONSTRAINT "junior_review_items_owner_check" TO "junior_inbox_items_owner_check";--> statement-breakpoint
|
|
28
|
+
ALTER TABLE "junior_inbox_items" RENAME CONSTRAINT "junior_review_items_status_check" TO "junior_inbox_items_status_check";--> statement-breakpoint
|
|
29
|
+
ALTER TABLE "junior_inbox_items" RENAME CONSTRAINT "junior_review_items_tenant_check" TO "junior_inbox_items_tenant_check";--> statement-breakpoint
|
|
30
|
+
ALTER TABLE "junior_inbox_items" RENAME CONSTRAINT "junior_review_items_visibility_check" TO "junior_inbox_items_visibility_check";--> statement-breakpoint
|
|
31
|
+
ALTER TABLE "junior_inbox_items" RENAME CONSTRAINT "junior_review_items_automation_id_junior_automations_id_fk" TO "junior_inbox_items_automation_id_junior_automations_id_fk";--> statement-breakpoint
|
|
32
|
+
ALTER TABLE "junior_inbox_items" RENAME CONSTRAINT "junior_review_items_closed_by_user_id_junior_users_id_fk" TO "junior_inbox_items_closed_by_user_id_junior_users_id_fk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "junior_todos" ADD COLUMN "changed_by_conversation_id" text;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "junior_inbox_items" ADD COLUMN "subject_title_parts" jsonb;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "junior_inbox_snoozes" ADD COLUMN "wake_reason" jsonb;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_conversation_events_authorization_request_idx" ON "junior_conversation_events" USING btree ("conversation_id","created_at") WHERE "junior_conversation_events"."type" = 'authorization_requested';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
ALTER TABLE "junior_conversation_embeddings" DROP CONSTRAINT "junior_conversation_embeddings_brief_fk";
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
ALTER TABLE "junior_conversation_embeddings" ALTER COLUMN "brief_version" DROP NOT NULL;--> statement-breakpoint
|
|
4
|
+
ALTER TABLE "junior_conversation_embeddings" ADD COLUMN "through_seq" integer;--> statement-breakpoint
|
|
5
|
+
ALTER TABLE "junior_conversations" ADD COLUMN "summary" text;--> statement-breakpoint
|
|
6
|
+
ALTER TABLE "junior_conversations" ADD COLUMN "metadata_through_seq" integer;--> statement-breakpoint
|
|
7
|
+
-- Every embedding belonged to a Brief of an existing Conversation, so every
|
|
8
|
+
-- row passes. NOT VALID skips the scan under lock and still checks every new
|
|
9
|
+
-- write.
|
|
10
|
+
ALTER TABLE "junior_conversation_embeddings" ADD CONSTRAINT "junior_conversation_embeddings_conversation_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."junior_conversations"("conversation_id") ON DELETE cascade ON UPDATE no action NOT VALID;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
-- Copy the latest Brief of each Conversation into its Conversation metadata,
|
|
2
|
+
-- and point the Conversation embedding of that Brief at the copied metadata.
|
|
3
|
+
-- Purge already deleted the Briefs of purged private Conversations. A Brief
|
|
4
|
+
-- that an older worker stores during the rollout is not copied; the next
|
|
5
|
+
-- Turn of that Conversation writes its metadata.
|
|
6
|
+
-- junior:bounded-backfill: runs once and changes each Conversation that has a Brief once. Most of these Conversations are idle, and the update sets only new columns.
|
|
7
|
+
WITH "latest" AS (
|
|
8
|
+
SELECT DISTINCT ON ("conversation_id")
|
|
9
|
+
"conversation_id",
|
|
10
|
+
"version",
|
|
11
|
+
"through_seq",
|
|
12
|
+
"content"
|
|
13
|
+
FROM "junior_conversation_briefs"
|
|
14
|
+
ORDER BY "conversation_id", "version" DESC
|
|
15
|
+
)
|
|
16
|
+
UPDATE "junior_conversations" AS "conversations"
|
|
17
|
+
SET
|
|
18
|
+
"summary" = "latest"."content"->>'summary',
|
|
19
|
+
"metadata_through_seq" = "latest"."through_seq",
|
|
20
|
+
"detail_version" = "conversations"."detail_version" + 1
|
|
21
|
+
FROM "latest"
|
|
22
|
+
WHERE "latest"."conversation_id" = "conversations"."conversation_id"
|
|
23
|
+
AND "conversations"."metadata_through_seq" IS NULL;
|
|
24
|
+
--> statement-breakpoint
|
|
25
|
+
-- junior:bounded-backfill: only the metadata task writes Conversation embeddings, and the update sets only a new column.
|
|
26
|
+
WITH "latest" AS (
|
|
27
|
+
SELECT DISTINCT ON ("conversation_id")
|
|
28
|
+
"conversation_id",
|
|
29
|
+
"version",
|
|
30
|
+
"through_seq"
|
|
31
|
+
FROM "junior_conversation_briefs"
|
|
32
|
+
ORDER BY "conversation_id", "version" DESC
|
|
33
|
+
)
|
|
34
|
+
UPDATE "junior_conversation_embeddings" AS "embeddings"
|
|
35
|
+
SET "through_seq" = "latest"."through_seq"
|
|
36
|
+
FROM "latest"
|
|
37
|
+
WHERE "latest"."conversation_id" = "embeddings"."conversation_id"
|
|
38
|
+
AND "latest"."version" = "embeddings"."brief_version"
|
|
39
|
+
AND "embeddings"."through_seq" IS NULL;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE INDEX CONCURRENTLY IF NOT EXISTS "junior_conversations_search_idx" ON "junior_conversations" USING gin (to_tsvector('english', coalesce("title", '') || ' ' || coalesce("summary", '')));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
-- Before 0139 reserved the `automation:` dedupe key prefix for Automation
|
|
2
|
+
-- alerts, agents used it for their own items, such as
|
|
3
|
+
-- `automation:<id>:rewrite` for a question about an Automation. 0139 added
|
|
4
|
+
-- the owner check as NOT VALID because it assumed that no such row existed.
|
|
5
|
+
-- These rows are Conversation items with an `automation:` key, so they break
|
|
6
|
+
-- the check, and each update to them fails: a person cannot dismiss, answer,
|
|
7
|
+
-- or take them. The runtime also reads the prefix as an Automation alert, so
|
|
8
|
+
-- an answer goes to core and not to the agent that asked.
|
|
9
|
+
-- The new key holds the item id, which is unique, so it matches no other
|
|
10
|
+
-- open item. Since 0139, agents cannot use the old keys, so no add looks for
|
|
11
|
+
-- them.
|
|
12
|
+
-- junior:bounded-backfill: only Conversation items that agents added with an `automation:` key before 0139 reserved the prefix, about a dozen rows.
|
|
13
|
+
UPDATE "junior_inbox_items"
|
|
14
|
+
SET
|
|
15
|
+
"dedupe_key" = 'ask:' || "id",
|
|
16
|
+
"updated_at" = now()
|
|
17
|
+
WHERE "owner_kind" = 'conversation'
|
|
18
|
+
AND "dedupe_key" LIKE 'automation:%';--> statement-breakpoint
|
|
19
|
+
-- Now every row meets the check. VALIDATE proves it, so no row that breaks
|
|
20
|
+
-- the check stays until a person's click finds it.
|
|
21
|
+
ALTER TABLE "junior_inbox_items" VALIDATE CONSTRAINT "junior_inbox_items_owner_check";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "junior_artifacts" ADD COLUMN "expires_at" timestamp with time zone;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "junior_artifacts_permanent_sha_uidx" ON "junior_artifacts" USING btree ("conversation_id","sha256") WHERE "junior_artifacts"."visibility" = 'public' and "junior_artifacts"."expires_at" is 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', 'lead', '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', 'lead')) = ("junior_conversations"."parent_conversation_id" is null))) NOT VALID;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "junior_conversations_lead_actor_idx" ON "junior_conversations" USING btree ("actor_identity_id") WHERE "junior_conversations"."kind" = 'lead';
|