@sentry/junior 0.311.0 → 0.313.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.
Files changed (120) hide show
  1. package/dist/{adapter-B1wujchl.js → adapter-CYAvJzZS.js} +1 -1
  2. package/dist/{adapter-context-G2M0y6rP.js → adapter-context-CVsHoVSf.js} +2 -2
  3. package/dist/{admin-DCiBhUT1.js → admin-Cyhb4TwZ.js} +1 -1
  4. package/dist/{agent-runner-BVHPUIc8.js → agent-runner-B5y9MsT-.js} +3487 -3493
  5. package/dist/api/schema.d.ts +2 -2
  6. package/dist/api/schema.js +6 -6
  7. package/dist/api.d.ts +2 -2
  8. package/dist/api.js +294 -311
  9. package/dist/{app-Cw5Vy6H6.d.ts → app-DA8-hCMj.d.ts} +2 -9
  10. package/dist/app.d.ts +1 -1
  11. package/dist/app.js +336 -604
  12. package/dist/{background-compaction-queue-CJDnWVOJ.js → background-compaction-queue-iZXadLV3.js} +60 -85
  13. package/dist/{catalog-runtime-DMY3VV-D.js → catalog-runtime-kkE3hvCX.js} +1 -1
  14. package/dist/channel-access-mt7K6dPh.js +221 -0
  15. package/dist/cli/chat.js +18 -19
  16. package/dist/cli/check.js +3 -3
  17. package/dist/cli/init.js +0 -1
  18. package/dist/cli/main.js +3 -7
  19. package/dist/cli/plugins.js +4 -4
  20. package/dist/cli/run.d.ts +1 -2
  21. package/dist/cli/run.js +1 -2
  22. package/dist/cli/snapshot-create.js +5 -5
  23. package/dist/cli/upgrade.d.ts +1 -1
  24. package/dist/cli/upgrade.js +3 -3
  25. package/dist/{config-BrXDQefC.js → config-CWbwKj0j.js} +59 -27
  26. package/dist/{continue-in-slack-DNXSC9So.js → continue-in-slack-CxyFzdlF.js} +7 -8
  27. package/dist/{conversation-feed-DkinDu5o.js → conversation-feed-BEXLD3Me.js} +86 -21
  28. package/dist/{conversation-privacy-DxttrKb9.js → conversation-privacy-BrMiDN61.js} +1 -1
  29. package/dist/{conversation-turn-DWw7Xhdr.js → conversation-turn-B35eu0uz.js} +78 -56
  30. package/dist/{credential-sync-Bk8wGb8Y.js → credential-sync-DWTOEQrm.js} +15 -15
  31. package/dist/{projection-Cns7XwWa.js → credentialed-Dyv8b-lu.js} +16306 -20732
  32. package/dist/{db-7ETESH44.d.ts → db-DYGcXYl3.d.ts} +11 -6
  33. package/dist/{db-DTxzH7u5.js → db-PwSRzWWn.js} +181 -100
  34. package/dist/{executor-DqTiYj9S.js → executor-CgWyWfYz.js} +117 -99
  35. package/dist/{html-B9Sl4Axb.js → html-DidUcRhI.js} +6 -6
  36. package/dist/ingest-B0AggUEC.js +7931 -0
  37. package/dist/{install-Sg4ePfLl.js → install-2urLLXNt.js} +2 -2
  38. package/dist/instrumentation.js +3 -3
  39. package/dist/{lineage-BHAMpNKr.js → lineage-BXplQAVH.js} +2 -2
  40. package/dist/{stop-CYsfc0Ed.js → list-DyIyReSV.js} +709 -475
  41. package/dist/{logging-FjclQsXu.js → logging-DNt-qOIO.js} +1 -1
  42. package/dist/{schedule-BLJ476XQ.js → media-B0pZJ0bG.js} +1058 -11
  43. package/dist/{message-CJ7_RL50.js → message-Z5YKC-Af.js} +35 -28
  44. package/dist/{model-input-CMLh4Cwq.js → model-input-BhPJYdSV.js} +3 -3
  45. package/dist/nitro.d.ts +1 -1
  46. package/dist/nitro.js +4 -3
  47. package/dist/{oauth-callback-server-RVcbiDjL.js → oauth-callback-server-ByvDdcdY.js} +2 -2
  48. package/dist/{oauth-relay-Bu9kkaQu.js → oauth-relay-D-kK0yoN.js} +1 -1
  49. package/dist/{registry-BPwuOP2O.js → registry-POH4bZC4.js} +1 -1
  50. package/dist/reporting-window-C4dbzDiR.js +124 -0
  51. package/dist/request-deadline-BUiRYQYj.js +24 -0
  52. package/dist/{resolve-BK29bBry.js → resolve-CWtBNSKP.js} +3 -3
  53. package/dist/{runner-BcAE-cJm.js → runner-CsZ_VRxp.js} +14 -16
  54. package/dist/{sandbox-egress-signals-C-q0go5b.js → sandbox-egress-signals-FbCk1FkN.js} +1 -1
  55. package/dist/{schema-DYcJeV7d.d.ts → schema-DBf18QPS.d.ts} +2773 -3630
  56. package/dist/{schema-BLgSZXcL.js → schema-DojR2uCL.js} +106 -121
  57. package/dist/{service-account-iJoCtkHR.js → service-account-CDYb9hfX.js} +3 -3
  58. package/dist/{service-account-gN0zqf0S.js → service-account-o15pZWcJ.js} +5 -5
  59. package/dist/{skills-BoZ80epJ.js → skills-B0jP4whm.js} +2 -2
  60. package/dist/{slack-conversation-unfurl-CogYrITA.js → slack-conversation-unfurl-D26t9kBC.js} +9 -9
  61. package/dist/{spawn-Dk92r7mX.js → spawn-BjljgExZ.js} +14 -32
  62. package/dist/start-conversation-DbVujrwO.js +755 -0
  63. package/dist/{state-DH3Cmgp3.js → state-BTawTCme.js} +4 -4
  64. package/dist/statuses-BKwqCPhj.js +69 -0
  65. package/dist/store-CjXrp-Up.js +492 -0
  66. package/dist/task-queue-Cwlatjz3.js +90 -0
  67. package/dist/task-runner--Ke8KSMf.js +1432 -0
  68. package/dist/{thread-context-BW2BsQbH.js → thread-context-B8exINEe.js} +6 -7
  69. package/dist/turn-membership-DTR3SaKD.js +5859 -0
  70. package/dist/{validation-DrJd0nnq.js → validation-Ce0qbMlT.js} +1 -1
  71. package/dist/{task-queue-C_zldF5J.js → vercel-queue-q4z8w5QO.js} +93 -172
  72. package/dist/{version-CNKZ8owc.js → version-DFh4n9nr.js} +1 -1
  73. package/dist/version.js +1 -1
  74. package/dist/{warmup-BWdHew2H.js → warmup-D5hzqTcp.js} +4853 -13605
  75. package/dist/web-message-id-C6P83ans.js +10 -0
  76. package/dist/{worker-t9qpu_Zx.js → worker-CDg9Lbpg.js} +20 -7
  77. package/migrations/0143_todos.sql +14 -0
  78. package/migrations/0144_inbox_items.sql +32 -0
  79. package/migrations/0145_todo_changed_by_agent.sql +1 -0
  80. package/migrations/0146_inbox_item_subject_title_parts.sql +1 -0
  81. package/migrations/0147_inbox_snooze_wake_reason.sql +1 -0
  82. package/migrations/0148_authorization_request_index.sql +1 -0
  83. package/migrations/0149_conversation_metadata.sql +10 -0
  84. package/migrations/0150_conversation_metadata_fill.sql +39 -0
  85. package/migrations/0151_conversation_search_index.sql +1 -0
  86. package/migrations/0152_inbox_item_legacy_automation_keys.sql +21 -0
  87. package/migrations/0153_artifact_expiry.sql +1 -0
  88. package/migrations/0154_artifact_permanent_sha_index.sql +1 -0
  89. package/migrations/0155_artifact_drop_public_sha_index.sql +3 -0
  90. package/migrations/0156_conversation_kind_lead.sql +6 -0
  91. package/migrations/0157_conversation_lead_actor_index.sql +1 -0
  92. package/migrations/0158_keep_legacy_archive_columns.sql +5 -0
  93. package/migrations/0159_conversation_embeddings_fk_validate.sql +5 -0
  94. package/migrations/meta/0143_snapshot.json +6434 -0
  95. package/migrations/meta/0144_snapshot.json +6434 -0
  96. package/migrations/meta/0145_snapshot.json +6440 -0
  97. package/migrations/meta/0146_snapshot.json +6446 -0
  98. package/migrations/meta/0147_snapshot.json +6452 -0
  99. package/migrations/meta/0148_snapshot.json +6474 -0
  100. package/migrations/meta/0149_snapshot.json +6490 -0
  101. package/migrations/meta/0150_snapshot.json +6490 -0
  102. package/migrations/meta/0151_snapshot.json +6505 -0
  103. package/migrations/meta/0152_snapshot.json +6505 -0
  104. package/migrations/meta/0153_snapshot.json +6511 -0
  105. package/migrations/meta/0154_snapshot.json +6533 -0
  106. package/migrations/meta/0155_snapshot.json +6511 -0
  107. package/migrations/meta/0156_snapshot.json +6511 -0
  108. package/migrations/meta/0157_snapshot.json +6527 -0
  109. package/migrations/meta/0158_snapshot.json +6515 -0
  110. package/migrations/meta/0159_snapshot.json +6515 -0
  111. package/migrations/meta/_journal.json +120 -1
  112. package/package.json +6 -6
  113. package/skills/design-automation-skill/SKILL.md +108 -0
  114. package/dist/briefs-BDjnug6Y.js +0 -395
  115. package/dist/conversation-ca__NDQW.js +0 -1063
  116. package/dist/prompt-CDqcsDYC.js +0 -910
  117. package/dist/store-DmmMIrQi.js +0 -335
  118. package/dist/task-runner-C7oCJQIx.js +0 -294
  119. package/dist/turn-session-routing-Xh_2nSQe.js +0 -261
  120. 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 { Ct as countPendingConversationMessages, Nt as isFinalAttempt, Pt as isInvalidConversationRecordError, jt as hasConversationStop } from "./projection-Cns7XwWa.js";
3
- import { i as getChatConfig, pt as isProviderRetryError } from "./config-BrXDQefC.js";
4
- import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-FjclQsXu.js";
5
- import { Ur as getConversationStoppedAtMs, _r as isAttemptInterrupt, vr as selectAttemptMessages } from "./warmup-BWdHew2H.js";
6
- import { g as getTurnRequestDeadline } from "./task-queue-C_zldF5J.js";
7
- import { _ as ConversationQueueMessageRejectedError, b as nudgeIdempotencyKey } from "./background-compaction-queue-CJDnWVOJ.js";
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-CWbwKj0j.js";
3
+ import { T as withLogContext, b as setSpanAttributes, h as logWarn, m as logInfo, p as logException } from "./logging-DNt-qOIO.js";
4
+ import { Ft as getConversationStoppedAtMs, Lt as saveHeldInput } from "./ingest-B0AggUEC.js";
5
+ import { t as getTurnRequestDeadline } from "./request-deadline-BUiRYQYj.js";
6
+ import { i as ConversationQueueMessageRejectedError, s as nudgeIdempotencyKey } from "./vercel-queue-q4z8w5QO.js";
7
+ import { D as completeConversationWork, E as completeConversationStop, I as recordAttemptFailure, L as recordConversationRetry, N as getConversationWorkState, O as deadLetterAttempt, R as releaseConversationWork, S as claimConversationAttempt, Sn as selectAttemptMessages, V as startConversationWork, cn as countPendingConversationMessages, fn as isFinalAttempt, h as ackMessages, j as ensureConversationWake, k as drainConversationMailbox, pn as isInvalidConversationRecordError, un as hasConversationStop, w as clearConsumedConversationWake, x as checkInConversationWork, xn as isAttemptInterrupt, y as beginConversationResume, z as requestAnotherSlice } from "./turn-membership-DTR3SaKD.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,3 @@
1
+ -- 0154 built the index that replaces this one, so an artifact upsert always
2
+ -- has a unique index to match.
3
+ DROP INDEX "junior_artifacts_public_sha_uidx";
@@ -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';
@@ -0,0 +1,5 @@
1
+ -- The snapshot no longer has junior_conversation_participants.archived_at or
2
+ -- junior_conversations.child_archived_at. Runtime code stopped reading and
3
+ -- writing them in #2900. They stay in the database for one release, because
4
+ -- old workers still name them in every insert while this migration runs. The
5
+ -- next release drops them with DROP COLUMN IF EXISTS, as 0101 does.
@@ -0,0 +1,5 @@
1
+ -- 0149 added this FK as NOT VALID. VALIDATE CONSTRAINT takes only SHARE UPDATE
2
+ -- EXCLUSIVE, so reads and writes keep going during the scan. Keep it alone in
3
+ -- this migration: each migration runs in one transaction, and a stronger lock
4
+ -- in the same file would be held for the whole scan.
5
+ ALTER TABLE "junior_conversation_embeddings" VALIDATE CONSTRAINT "junior_conversation_embeddings_conversation_fk";