@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
@@ -1,6 +1,6 @@
1
- import { h as logWarn, p as logException } from "./logging-FjclQsXu.js";
1
+ import { h as logWarn, p as logException } from "./logging-DNt-qOIO.js";
2
2
  import { _ as withScope } from "./sentry-CPbZjomA.js";
3
- import "./config-BrXDQefC.js";
3
+ import "./config-CWbwKj0j.js";
4
4
  import * as z from "zod";
5
5
  import { AsyncLocalStorage } from "node:async_hooks";
6
6
  import { actorSchema, sourceSchema } from "@sentry/junior-plugin-api";
@@ -33,12 +33,14 @@ const juniorArtifacts = pgTable("junior_artifacts", {
33
33
  visibility: text("visibility").$type().notNull().default("conversation"),
34
34
  createdAt: timestamptz("created_at").notNull(),
35
35
  /** Set when the artifact is unpublished or its live file is deleted. */
36
- deleteRequestedAt: timestamptz("delete_requested_at")
36
+ deleteRequestedAt: timestamptz("delete_requested_at"),
37
+ /** When a public artifact stops serving. Null serves until unpublished. */
38
+ expiresAt: timestamptz("expires_at")
37
39
  }, (table) => [
38
40
  check("junior_artifacts_visibility_check", sql`${table.visibility} in ('conversation', 'internal', 'public')`),
39
41
  check("junior_artifacts_path_visibility_check", sql`(${table.path} is null) = (${table.visibility} = 'public')`),
40
42
  uniqueIndex("junior_artifacts_conversation_path_uidx").on(table.conversationId, table.path),
41
- uniqueIndex("junior_artifacts_public_sha_uidx").on(table.conversationId, table.sha256).where(sql`${table.visibility} = 'public'`),
43
+ uniqueIndex("junior_artifacts_permanent_sha_uidx").on(table.conversationId, table.sha256).where(sql`${table.visibility} = 'public' and ${table.expiresAt} is null`),
42
44
  index("junior_artifacts_gc_idx").on(table.deleteRequestedAt, table.createdAt),
43
45
  index("junior_artifacts_conversation_idx").on(table.conversationId)
44
46
  ]);
@@ -405,6 +407,8 @@ const juniorConversations = pgTable("junior_conversations", {
405
407
  actor: jsonb("actor_json").$type(),
406
408
  channelName: text("channel_name"),
407
409
  title: text("title"),
410
+ summary: text("summary"),
411
+ metadataThroughSeq: integer("metadata_through_seq"),
408
412
  createdAt: timestamptz("created_at").notNull(),
409
413
  lastActivityAt: timestamptz("last_activity_at").notNull(),
410
414
  /**
@@ -422,7 +426,6 @@ const juniorConversations = pgTable("junior_conversations", {
422
426
  kind: text("kind").$type(),
423
427
  agentConfig: jsonb("agent_config_json").$type(),
424
428
  archivedAt: timestamptz("archived_at"),
425
- legacyChildArchivedAt: timestamptz("child_archived_at"),
426
429
  forkedFromConversationId: text("forked_from_conversation_id").references(() => juniorConversations.conversationId, { onDelete: "set null" }),
427
430
  quickQuestionAt: timestamptz("quick_question_at"),
428
431
  rootConversationId: text("root_conversation_id").references(() => juniorConversations.conversationId),
@@ -445,15 +448,17 @@ const juniorConversations = pgTable("junior_conversations", {
445
448
  metricRunId: text("metric_run_id"),
446
449
  detailVersion: integer("detail_version").notNull().default(0)
447
450
  }, (table) => [
448
- check("junior_conversations_kind_check", sql`${table.kind} in ('root', 'automation', 'thread', 'task')`),
449
- check("junior_conversations_kind_parent_check", sql`${table.kind} is null or ((${table.kind} in ('root', 'automation')) = (${table.parentConversationId} is null))`),
451
+ check("junior_conversations_kind_check", sql`${table.kind} in ('root', 'automation', 'lead', 'thread', 'task')`),
452
+ check("junior_conversations_kind_parent_check", sql`${table.kind} is null or ((${table.kind} in ('root', 'automation', 'lead')) = (${table.parentConversationId} is null))`),
450
453
  index("junior_conversations_last_activity_idx").on(table.lastActivityAt.desc(), table.conversationId),
451
454
  index("junior_conversations_active_idx").using("btree", sql`coalesce(${table.executionUpdatedAt}, ${table.updatedAt})`, table.conversationId).where(sql`${table.executionStatus} <> 'idle'`),
452
455
  index("junior_conversations_destination_activity_idx").on(table.destinationId, table.lastActivityAt.desc()),
453
456
  index("junior_conversations_actor_activity_idx").on(table.actorIdentityId, table.lastActivityAt.desc()),
454
457
  index("junior_conversations_parent_idx").on(table.parentConversationId),
455
458
  index("junior_conversations_forked_from_idx").on(table.forkedFromConversationId),
456
- index("junior_conversations_root_idx").on(table.rootConversationId)
459
+ index("junior_conversations_root_idx").on(table.rootConversationId),
460
+ uniqueIndex("junior_conversations_lead_actor_idx").on(table.actorIdentityId).where(sql`${table.kind} = 'lead'`),
461
+ index("junior_conversations_search_idx").using("gin", sql`to_tsvector('english', coalesce(${table.title}, '') || ' ' || coalesce(${table.summary}, ''))`)
457
462
  ]);
458
463
  // src/db/schema/attachments.ts
459
464
  /**
@@ -666,6 +671,7 @@ const juniorConversationEvents = pgTable("junior_conversation_events", {
666
671
  index("junior_conversation_events_type_idx").on(table.conversationId, table.type, table.seq),
667
672
  index("junior_conversation_events_plugin_report_idx").on(sql`(${table.payload}->>'namespace')`, sql`(${table.payload}->>'name')`, table.createdAt).where(sql`${table.type} = 'structured_event'`),
668
673
  index("junior_conversation_events_guardian_review_time_idx").on(table.createdAt).where(sql`${table.type} = 'guardian_action_reviewed'`),
674
+ index("junior_conversation_events_authorization_request_idx").on(table.conversationId, table.createdAt).where(sql`${table.type} = 'authorization_requested'`),
669
675
  index("junior_conversation_events_plugin_conversation_idx").on(table.conversationId, sql`(${table.payload}->>'namespace')`, sql`(${table.payload}->>'name')`, table.seq).where(sql`${table.type} = 'structured_event'`),
670
676
  index("junior_conversation_events_actor_identity_idx").on(table.actorIdentityId, table.conversationId, table.seq),
671
677
  index("junior_conversation_events_author_idx").on(table.conversationId, table.actorIdentityId, table.seq).where(sql`${table.actorIdentityId} is not null`),
@@ -715,53 +721,26 @@ const juniorConversationMetrics = pgTable("junior_conversation_metrics", {
715
721
  index("junior_conversation_metrics_occurred_at_metric_idx").on(table.occurredAt, table.metric),
716
722
  index("junior_conversation_metrics_turn_metric_occurred_at_idx").on(table.metric, table.occurredAt, table.actorIdentityId, table.conversationId, table.value).where(sql`${table.metric} IN ('duration_ms', 'total_tokens', 'cost_micro_usd')`)
717
723
  ]);
718
- // src/db/schema/conversation-briefs.ts
719
- /** Append-only Brief versions produced for completed Conversation turns. */
720
- const juniorConversationBriefs = pgTable("junior_conversation_briefs", {
721
- conversationId: text("conversation_id").notNull(),
722
- version: integer("version").notNull(),
723
- turnId: text("turn_id").notNull(),
724
- throughSeq: integer("through_seq").notNull(),
725
- content: jsonb("content").$type().notNull(),
726
- outcomeStatus: text("outcome_status").$type(),
727
- searchText: text("search_text").notNull(),
728
- modelId: text("model_id").notNull(),
729
- costMicroUsd: bigint("cost_micro_usd", { mode: "number" }),
730
- legacyCostUsd: doublePrecision("cost_usd"),
731
- createdAt: timestamptz("created_at").defaultNow().notNull()
732
- }, (table) => [
733
- primaryKey({
734
- name: "junior_conversation_briefs_conversation_id_version_pk",
735
- columns: [table.conversationId, table.version]
736
- }),
737
- foreignKey({
738
- name: "junior_conversation_briefs_conversation_id_junior_conversations_conversation_id_fk",
739
- columns: [table.conversationId],
740
- foreignColumns: [juniorConversations.conversationId]
741
- }).onDelete("cascade"),
742
- uniqueIndex("junior_conversation_briefs_conversation_turn_idx").on(table.conversationId, table.turnId),
743
- index("junior_conversation_briefs_conversation_version_idx").on(table.conversationId, table.version.desc()),
744
- index("junior_conversation_briefs_created_at_idx").on(table.createdAt, table.conversationId),
745
- index("junior_conversation_briefs_search_idx").using("gin", sql`to_tsvector('english', ${table.searchText})`)
746
- ]);
747
724
  // src/db/schema/conversation-embeddings.ts
748
725
  /**
749
- * One embedding per Conversation, for semantic search. Its text is the latest
750
- * Brief. A derived index: the next Brief replaces the row, and deleting that
751
- * Brief row deletes it.
726
+ * One embedding per Conversation, for semantic search. Its text is the
727
+ * Conversation metadata. A derived index: the next metadata update replaces
728
+ * the row.
752
729
  */
753
730
  const juniorConversationEmbeddings = pgTable("junior_conversation_embeddings", {
754
731
  conversationId: text("conversation_id").primaryKey(),
755
- briefVersion: integer("brief_version").notNull(),
732
+ legacyBriefVersion: integer("brief_version"),
733
+ /** The `metadata_through_seq` of the embedded Conversation metadata. */
734
+ throughSeq: integer("through_seq"),
756
735
  provider: text("provider").notNull(),
757
736
  model: text("model").notNull(),
758
737
  dimensions: integer("dimensions").notNull(),
759
738
  embedding: embeddingVector("embedding").notNull(),
760
739
  createdAt: timestamptz("created_at").defaultNow().notNull()
761
740
  }, (table) => [foreignKey({
762
- name: "junior_conversation_embeddings_brief_fk",
763
- columns: [table.conversationId, table.briefVersion],
764
- foreignColumns: [juniorConversationBriefs.conversationId, juniorConversationBriefs.version]
741
+ name: "junior_conversation_embeddings_conversation_fk",
742
+ columns: [table.conversationId],
743
+ foreignColumns: [juniorConversations.conversationId]
765
744
  }).onDelete("cascade"), check("junior_conversation_embeddings_dimensions_check", sql`vector_dims(${table.embedding}) = ${table.dimensions}`)]);
766
745
  // src/db/schema/conversation-event-embeddings.ts
767
746
  /**
@@ -813,6 +792,39 @@ const juniorConversationEventLexemes = pgTable("junior_conversation_event_lexeme
813
792
  }).onDelete("cascade"),
814
793
  index("junior_conversation_event_lexemes_lexemes_idx").using("gin", table.lexemes)
815
794
  ]);
795
+ // src/db/schema/conversation-briefs.ts
796
+ /**
797
+ * Legacy Brief versions. Conversation metadata replaced Briefs; only purge
798
+ * still deletes rows here.
799
+ * TODO(dcramer): Drop this table after the metadata backfill ships.
800
+ */
801
+ const juniorConversationBriefs = pgTable("junior_conversation_briefs", {
802
+ conversationId: text("conversation_id").notNull(),
803
+ version: integer("version").notNull(),
804
+ turnId: text("turn_id").notNull(),
805
+ throughSeq: integer("through_seq").notNull(),
806
+ content: jsonb("content").notNull(),
807
+ outcomeStatus: text("outcome_status"),
808
+ searchText: text("search_text").notNull(),
809
+ modelId: text("model_id").notNull(),
810
+ costMicroUsd: bigint("cost_micro_usd", { mode: "number" }),
811
+ legacyCostUsd: doublePrecision("cost_usd"),
812
+ createdAt: timestamptz("created_at").defaultNow().notNull()
813
+ }, (table) => [
814
+ primaryKey({
815
+ name: "junior_conversation_briefs_conversation_id_version_pk",
816
+ columns: [table.conversationId, table.version]
817
+ }),
818
+ foreignKey({
819
+ name: "junior_conversation_briefs_conversation_id_junior_conversations_conversation_id_fk",
820
+ columns: [table.conversationId],
821
+ foreignColumns: [juniorConversations.conversationId]
822
+ }).onDelete("cascade"),
823
+ uniqueIndex("junior_conversation_briefs_conversation_turn_idx").on(table.conversationId, table.turnId),
824
+ index("junior_conversation_briefs_conversation_version_idx").on(table.conversationId, table.version.desc()),
825
+ index("junior_conversation_briefs_created_at_idx").on(table.createdAt, table.conversationId),
826
+ index("junior_conversation_briefs_search_idx").using("gin", sql`to_tsvector('english', ${table.searchText})`)
827
+ ]);
816
828
  // src/db/schema/conversation-bindings.ts
817
829
  /** Provider conversation coordinates bound to Junior's opaque durable conversation id. */
818
830
  const juniorConversationBindings = pgTable("junior_conversation_bindings", {
@@ -843,7 +855,6 @@ const juniorConversationParticipants = pgTable("junior_conversation_participants
843
855
  userId: text("user_id").notNull().references(() => juniorUsers.id),
844
856
  rootConversationId: text("root_conversation_id").notNull().references(() => juniorConversations.conversationId),
845
857
  lastMessageAt: timestamptz("last_message_at").notNull(),
846
- legacyArchivedAt: timestamptz("archived_at"),
847
858
  pinnedAt: timestamptz("pinned_at"),
848
859
  /**
849
860
  * The viewer's place for this pin in the Pinned section, from a drag
@@ -1051,9 +1062,9 @@ const juniorAutomations = pgTable("junior_automations", {
1051
1062
  index("junior_automations_skill_idx").on(table.skill, table.createdAtMs, table.id).where(sql`${table.status} <> 'deleted' AND ${table.skill} IS NOT NULL`),
1052
1063
  index("junior_automations_match_idx").on(table.namespace, table.identifier, table.createdAtMs, table.id).where(sql`${table.status} <> 'deleted'`)
1053
1064
  ]);
1054
- // src/db/schema/review-items.ts
1065
+ // src/db/schema/inbox-items.ts
1055
1066
  /**
1056
- * One Review item: something that needs a person. An action item stores its
1067
+ * One Inbox item: something that needs a person. An action item stores its
1057
1068
  * `request`, and
1058
1069
  * its `answer` after an assignee submits it. `closed_at` is set for `done`
1059
1070
  * and `dismissed`. `closed_by_user_id` is null when an agent closed it.
@@ -1061,7 +1072,7 @@ const juniorAutomations = pgTable("junior_automations", {
1061
1072
  * item gets its visibility and tenant, and where the Inbox stacks it. The id
1062
1073
  * has no foreign key, because it can name a row of more than one table.
1063
1074
  */
1064
- const juniorReviewItems = pgTable("junior_review_items", {
1075
+ const juniorInboxItems = pgTable("junior_inbox_items", {
1065
1076
  id: text("id").primaryKey(),
1066
1077
  kind: text("kind").$type().notNull(),
1067
1078
  status: text("status").$type().notNull(),
@@ -1079,6 +1090,8 @@ const juniorReviewItems = pgTable("junior_review_items", {
1079
1090
  subjectId: text("subject_id"),
1080
1091
  subjectTitle: text("subject_title"),
1081
1092
  subjectUrl: text("subject_url"),
1093
+ /** The parsed subject title of a code change (`InboxItemSubjectTitleParts`). */
1094
+ subjectTitleParts: jsonb("subject_title_parts").$type(),
1082
1095
  ownerKind: text("owner_kind").$type().notNull().default("conversation"),
1083
1096
  ownerId: text("owner_id").notNull(),
1084
1097
  /**
@@ -1099,35 +1112,35 @@ const juniorReviewItems = pgTable("junior_review_items", {
1099
1112
  createdAt: timestamptz("created_at").notNull(),
1100
1113
  updatedAt: timestamptz("updated_at").notNull()
1101
1114
  }, (table) => [
1102
- check("junior_review_items_kind_check", sql`(${table.kind} = 'notice' and ${table.request} is null and ${table.answer} is null) or (${table.kind} = 'action' and (${table.request} is not null or ((${table.dedupeKey} like 'plugin:%' or ${table.dedupeKey} like 'automation:%') and ${table.answer} is null)))`),
1103
- check("junior_review_items_owner_check", sql`(${table.ownerKind} = 'conversation' and ${table.dedupeKey} not like 'automation:%') or (${table.ownerKind} = 'automation' and ${table.dedupeKey} like 'automation:%')`),
1104
- check("junior_review_items_status_check", sql`(${table.status} = 'open' and ${table.closedAt} is null) or (${table.status} in ('done', 'dismissed') and ${table.closedAt} is not null)`),
1105
- check("junior_review_items_tenant_check", sql`(${table.provider} is null) = (${table.providerTenantId} is null)`),
1106
- check("junior_review_items_visibility_check", sql`${table.visibility} = 'public' or not ${table.assignedToEveryone}`),
1107
- uniqueIndex("junior_review_items_open_dedupe_uidx").on(sql`coalesce(${table.provider}, '')`, sql`coalesce(${table.providerTenantId}, '')`, table.dedupeKey).where(sql`${table.status} = 'open'`),
1108
- index("junior_review_items_status_idx").on(table.status, table.updatedAt, table.id),
1109
- index("junior_review_items_subject_idx").on(table.subjectId, table.status),
1110
- index("junior_review_items_owner_idx").on(table.ownerKind, table.ownerId),
1111
- index("junior_review_items_open_action_owner_idx").on(table.ownerId).where(sql`${table.status} = 'open' and ${table.kind} = 'action'`),
1112
- index("junior_review_items_automation_idx").on(table.automationId, table.status),
1113
- index("junior_review_items_answered_idx").on(table.ownerId, table.closedByUserId, table.closedAt).where(sql`${table.answer} is not null`)
1115
+ check("junior_inbox_items_kind_check", sql`(${table.kind} = 'notice' and ${table.request} is null and ${table.answer} is null) or (${table.kind} = 'action' and (${table.request} is not null or ((${table.dedupeKey} like 'plugin:%' or ${table.dedupeKey} like 'automation:%') and ${table.answer} is null)))`),
1116
+ check("junior_inbox_items_owner_check", sql`(${table.ownerKind} = 'conversation' and ${table.dedupeKey} not like 'automation:%') or (${table.ownerKind} = 'automation' and ${table.dedupeKey} like 'automation:%')`),
1117
+ check("junior_inbox_items_status_check", sql`(${table.status} = 'open' and ${table.closedAt} is null) or (${table.status} in ('done', 'dismissed') and ${table.closedAt} is not null)`),
1118
+ check("junior_inbox_items_tenant_check", sql`(${table.provider} is null) = (${table.providerTenantId} is null)`),
1119
+ check("junior_inbox_items_visibility_check", sql`${table.visibility} = 'public' or not ${table.assignedToEveryone}`),
1120
+ uniqueIndex("junior_inbox_items_open_dedupe_uidx").on(sql`coalesce(${table.provider}, '')`, sql`coalesce(${table.providerTenantId}, '')`, table.dedupeKey).where(sql`${table.status} = 'open'`),
1121
+ index("junior_inbox_items_status_idx").on(table.status, table.updatedAt, table.id),
1122
+ index("junior_inbox_items_subject_idx").on(table.subjectId, table.status),
1123
+ index("junior_inbox_items_owner_idx").on(table.ownerKind, table.ownerId),
1124
+ index("junior_inbox_items_open_action_owner_idx").on(table.ownerId).where(sql`${table.status} = 'open' and ${table.kind} = 'action'`),
1125
+ index("junior_inbox_items_automation_idx").on(table.automationId, table.status),
1126
+ index("junior_inbox_items_answered_idx").on(table.ownerId, table.closedByUserId, table.closedAt).where(sql`${table.answer} is not null`)
1114
1127
  ]);
1115
- /** The assigned Users of a Review item. Everyone is a flag on the item. */
1116
- const juniorReviewItemAssignees = pgTable("junior_review_item_assignees", {
1117
- itemId: text("item_id").notNull().references(() => juniorReviewItems.id, { onDelete: "cascade" }),
1128
+ /** The assigned Users of an Inbox item. Everyone is a flag on the item. */
1129
+ const juniorInboxItemAssignees = pgTable("junior_inbox_item_assignees", {
1130
+ itemId: text("item_id").notNull().references(() => juniorInboxItems.id, { onDelete: "cascade" }),
1118
1131
  userId: text("user_id").notNull().references(() => juniorUsers.id, { onDelete: "cascade" })
1119
- }, (table) => [primaryKey({ columns: [table.itemId, table.userId] }), index("junior_review_item_assignees_user_idx").on(table.userId)]);
1120
- /** The Conversations linked to a Review item. */
1121
- const juniorReviewItemConversations = pgTable("junior_review_item_conversations", {
1122
- itemId: text("item_id").notNull().references(() => juniorReviewItems.id, { onDelete: "cascade" }),
1132
+ }, (table) => [primaryKey({ columns: [table.itemId, table.userId] }), index("junior_inbox_item_assignees_user_idx").on(table.userId)]);
1133
+ /** The Conversations linked to an Inbox item. */
1134
+ const juniorInboxItemConversations = pgTable("junior_inbox_item_conversations", {
1135
+ itemId: text("item_id").notNull().references(() => juniorInboxItems.id, { onDelete: "cascade" }),
1123
1136
  conversationId: text("conversation_id").notNull().references(() => juniorConversations.conversationId, { onDelete: "cascade" })
1124
- }, (table) => [primaryKey({ columns: [table.itemId, table.conversationId] }), index("junior_review_item_conversations_conversation_idx").on(table.conversationId)]);
1137
+ }, (table) => [primaryKey({ columns: [table.itemId, table.conversationId] }), index("junior_inbox_item_conversations_conversation_idx").on(table.conversationId)]);
1125
1138
  /**
1126
- * The Slack message that shows a Review item in one linked Slack thread.
1139
+ * The Slack message that shows an Inbox item in one linked Slack thread.
1127
1140
  * Junior updates it in place after each change.
1128
1141
  */
1129
- const juniorReviewItemSlackCards = pgTable("junior_review_item_slack_cards", {
1130
- itemId: text("item_id").notNull().references(() => juniorReviewItems.id, { onDelete: "cascade" }),
1142
+ const juniorInboxItemSlackCards = pgTable("junior_inbox_item_slack_cards", {
1143
+ itemId: text("item_id").notNull().references(() => juniorInboxItems.id, { onDelete: "cascade" }),
1131
1144
  conversationId: text("conversation_id").notNull().references(() => juniorConversations.conversationId, { onDelete: "cascade" }),
1132
1145
  teamId: text("team_id").notNull(),
1133
1146
  channelId: text("channel_id").notNull(),
@@ -1135,21 +1148,24 @@ const juniorReviewItemSlackCards = pgTable("junior_review_item_slack_cards", {
1135
1148
  }, (table) => [primaryKey({ columns: [table.itemId, table.conversationId] })]);
1136
1149
  // src/db/schema/inbox-snoozes.ts
1137
1150
  /**
1138
- * One person's snooze of one Review item. A `snoozed` row hides the item
1151
+ * One person's snooze of one Inbox item. A `snoozed` row hides the item
1139
1152
  * from that person's Inbox until one of its triggers fires. `woken` and
1140
1153
  * `cancelled` are final. The item's own status says whether it resolved.
1154
+ * A trigger that wakes it records why in `wake_reason`, which only that
1155
+ * person sees, until they open or act on the item.
1141
1156
  */
1142
1157
  const juniorInboxSnoozes = pgTable("junior_inbox_snoozes", {
1143
1158
  id: text("id").primaryKey(),
1144
1159
  userId: text("user_id").notNull().references(() => juniorUsers.id, { onDelete: "cascade" }),
1145
- reviewItemId: text("review_item_id").notNull().references(() => juniorReviewItems.id, { onDelete: "cascade" }),
1160
+ inboxItemId: text("inbox_item_id").notNull().references(() => juniorInboxItems.id, { onDelete: "cascade" }),
1146
1161
  state: text("state").$type().notNull(),
1162
+ wakeReason: jsonb("wake_reason").$type(),
1147
1163
  createdAt: timestamptz("created_at").notNull()
1148
1164
  }, (table) => [
1149
1165
  check("junior_inbox_snoozes_state_check", sql`${table.state} in ('snoozed', 'woken', 'cancelled')`),
1150
- uniqueIndex("junior_inbox_snoozes_snoozed_uidx").on(table.userId, table.reviewItemId).where(sql`${table.state} = 'snoozed'`),
1166
+ uniqueIndex("junior_inbox_snoozes_snoozed_uidx").on(table.userId, table.inboxItemId).where(sql`${table.state} = 'snoozed'`),
1151
1167
  index("junior_inbox_snoozes_settled_idx").on(table.createdAt).where(sql`${table.state} <> 'snoozed'`),
1152
- index("junior_inbox_snoozes_review_item_idx").on(table.reviewItemId)
1168
+ index("junior_inbox_snoozes_inbox_item_idx").on(table.inboxItemId)
1153
1169
  ]);
1154
1170
  /**
1155
1171
  * An Event that ends a snooze. `wake` brings the item back; `resolve`
@@ -1191,23 +1207,25 @@ const juniorStats = pgTable("junior_stats", {
1191
1207
  table.name
1192
1208
  ]
1193
1209
  })]);
1194
- // src/db/schema/plan-items.ts
1210
+ // src/db/schema/todos.ts
1195
1211
  /**
1196
- * Gives each Plan item its id and each change its version. One sequence
1197
- * serves every Conversation, so history that a fork copies from its parent
1198
- * never shows a version that the fork's own plan reuses.
1212
+ * Gives each To-do its id and each change its version. One sequence serves
1213
+ * every Conversation, so history that a fork copies from its parent never
1214
+ * shows a version that the fork's own To-dos reuse.
1199
1215
  */
1200
- const juniorPlanItemVersionSeq = pgSequence("junior_plan_item_version_seq");
1216
+ const juniorTodoVersionSeq = pgSequence("junior_todo_version_seq");
1201
1217
  /**
1202
- * One Plan item: work that a Conversation has not finished. At most one
1203
- * assignee: a Conversation (the plan's own agent or one of its child agents)
1204
- * or a User. An item without one belongs to the plan's own agent.
1205
- * `changed_by_user_id` is set when a person made the latest change, and null
1206
- * when the plan's own agent did. Both User keys block deleting the User, as
1207
- * Conversation participants do: setting them null would turn a person's item
1208
- * into the agent's and hide an unseen change from `<plan-delta>`.
1218
+ * One To-do: work that a Conversation has not finished. At most one
1219
+ * assignee: a Conversation (the list's own agent or one of its child agents)
1220
+ * or a User. A To-do without one belongs to the list's own agent.
1221
+ * `changed_by_user_id` is set when a person made the latest change.
1222
+ * `changed_by_conversation_id` is set when the assignee child agent closed
1223
+ * it, or core closed it on that child's result. Both are null when the
1224
+ * list's own agent made the latest change. Both User keys block deleting the User, as
1225
+ * Conversation participants do: setting them null would turn a person's
1226
+ * To-do into the agent's and hide an unseen change from `<todo-delta>`.
1209
1227
  */
1210
- const juniorPlanItems = pgTable("junior_plan_items", {
1228
+ const juniorTodos = pgTable("junior_todos", {
1211
1229
  conversationId: text("conversation_id").notNull(),
1212
1230
  id: bigint("id", { mode: "number" }).notNull(),
1213
1231
  title: text("title").notNull(),
@@ -1217,21 +1235,21 @@ const juniorPlanItems = pgTable("junior_plan_items", {
1217
1235
  assigneeUserId: text("assignee_user_id").references(() => juniorUsers.id),
1218
1236
  version: bigint("version", { mode: "number" }).notNull(),
1219
1237
  changedByUserId: text("changed_by_user_id").references(() => juniorUsers.id),
1238
+ changedByConversationId: text("changed_by_conversation_id"),
1220
1239
  createdAt: timestamptz("created_at").notNull(),
1221
1240
  updatedAt: timestamptz("updated_at").notNull()
1222
1241
  }, (table) => [
1223
1242
  primaryKey({
1224
- name: "junior_plan_items_pk",
1243
+ name: "junior_todos_pk",
1225
1244
  columns: [table.conversationId, table.id]
1226
1245
  }),
1227
1246
  foreignKey({
1228
- name: "junior_plan_items_conversation_id_fk",
1247
+ name: "junior_todos_conversation_id_fk",
1229
1248
  columns: [table.conversationId],
1230
1249
  foreignColumns: [juniorConversations.conversationId]
1231
1250
  }).onDelete("cascade"),
1232
- check("junior_plan_items_status_check", sql`${table.status} in ('pending', 'in_progress', 'blocked', 'done', 'cancelled')`),
1233
- check("junior_plan_items_assignee_check", sql`${table.assigneeConversationId} is null or ${table.assigneeUserId} is null`),
1234
- uniqueIndex("junior_plan_items_in_progress_uidx").on(table.conversationId, sql`coalesce(${table.assigneeConversationId}, ${table.assigneeUserId}, ${table.conversationId})`).where(sql`${table.status} = 'in_progress'`)
1251
+ check("junior_todos_status_check", sql`${table.status} in ('open', 'in_progress', 'done', 'dropped')`),
1252
+ check("junior_todos_assignee_check", sql`${table.assigneeConversationId} is null or ${table.assigneeUserId} is null`)
1235
1253
  ]);
1236
1254
  // src/db/schema/push-subscriptions.ts
1237
1255
  /**
@@ -1331,11 +1349,11 @@ const juniorSqlSchema = {
1331
1349
  juniorIdentities,
1332
1350
  juniorInboxSnoozes,
1333
1351
  juniorInboxSnoozeTriggers,
1334
- juniorReviewItemAssignees,
1335
- juniorReviewItemConversations,
1336
- juniorReviewItemSlackCards,
1337
- juniorReviewItems,
1338
- juniorPlanItems,
1352
+ juniorInboxItemAssignees,
1353
+ juniorInboxItemConversations,
1354
+ juniorInboxItemSlackCards,
1355
+ juniorInboxItems,
1356
+ juniorTodos,
1339
1357
  juniorPushSubscriptions,
1340
1358
  juniorSnapshots,
1341
1359
  juniorStats,
@@ -1837,4 +1855,4 @@ function createJuniorSqlExecutor(args) {
1837
1855
  statementTimeoutMs
1838
1856
  });
1839
1857
  }
1840
- export { MEMORY_SCOPES as $, juniorConversationMetrics as A, juniorAttachments as B, juniorConversationParticipants as C, juniorConversationEmbeddings as D, juniorConversationEventEmbeddings as E, codeChangeSearchDocument as F, slackPersonSearchDocument as G, juniorConversations as H, codeRepositorySearchDocument as I, juniorMemoryEmbeddings as J, juniorUsers as K, juniorCodeChanges as L, juniorConversationEvents as M, juniorApiTokens as N, juniorConversationBriefs as O, juniorConversationAnnotations as P, MEMORY_KINDS as Q, juniorCodeRepositories as R, juniorConversationReadPositions as S, juniorConversationEventLexemes as T, juniorIdentities as U, juniorMessageAttachments as V, slackPersonPredicate as W, juniorMemorySignals as X, juniorMemoryMemories as Y, MEMORY_EMBEDDING_DIMENSIONS as Z, juniorAutomationRuns as _, juniorWorkspaces as a, guardedCosineDistance as at, juniorAgentBindings as b, juniorPlanItems as c, juniorArtifacts as ct, juniorInboxSnoozes as d, MEMORY_SOURCE_PLATFORMS as et, juniorReviewItemAssignees as f, juniorAutomations as g, juniorReviewItems as h, juniorWorkspaceRepos as i, embedText as it, isUserInstruction as j, CONVERSATION_METRICS as k, juniorStats as l, juniorReviewItemSlackCards as m, isPostgresErrorCode as n, memoryRuntimeContextSchema as nt, juniorPushSubscriptions as o, parseEmbeddingBatch as ot, juniorReviewItemConversations as p, juniorDestinations as q, juniorSnapshots as r, cosineDistance as rt, juniorPlanItemVersionSeq as s, refreshEmbeddings as st, createJuniorSqlExecutor as t, MEMORY_SUBJECT_TYPES as tt, juniorInboxSnoozeTriggers as u, juniorAutomationVersions as v, juniorConversationBindings as w, juniorAgentInvocations as x, juniorLocationConfigurations as y, juniorAttachmentUploads as z };
1858
+ export { MEMORY_SCOPES as $, juniorConversationMetrics as A, juniorAttachments as B, juniorConversationParticipants as C, juniorConversationEventEmbeddings as D, juniorConversationEventLexemes as E, codeChangeSearchDocument as F, slackPersonSearchDocument as G, juniorConversations as H, codeRepositorySearchDocument as I, juniorMemoryEmbeddings as J, juniorUsers as K, juniorCodeChanges as L, juniorConversationEvents as M, juniorApiTokens as N, juniorConversationEmbeddings as O, juniorConversationAnnotations as P, MEMORY_KINDS as Q, juniorCodeRepositories as R, juniorConversationReadPositions as S, juniorConversationBriefs as T, juniorIdentities as U, juniorMessageAttachments as V, slackPersonPredicate as W, juniorMemorySignals as X, juniorMemoryMemories as Y, MEMORY_EMBEDDING_DIMENSIONS as Z, juniorAutomationRuns as _, juniorWorkspaces as a, guardedCosineDistance as at, juniorAgentBindings as b, juniorTodos as c, juniorArtifacts as ct, juniorInboxSnoozes as d, MEMORY_SOURCE_PLATFORMS as et, juniorInboxItemAssignees as f, juniorAutomations as g, juniorInboxItems as h, juniorWorkspaceRepos as i, embedText as it, isUserInstruction as j, CONVERSATION_METRICS as k, juniorStats as l, juniorInboxItemSlackCards as m, isPostgresErrorCode as n, memoryRuntimeContextSchema as nt, juniorPushSubscriptions as o, parseEmbeddingBatch as ot, juniorInboxItemConversations as p, juniorDestinations as q, juniorSnapshots as r, cosineDistance as rt, juniorTodoVersionSeq as s, refreshEmbeddings as st, createJuniorSqlExecutor as t, MEMORY_SUBJECT_TYPES as tt, juniorInboxSnoozeTriggers as u, juniorAutomationVersions as v, juniorConversationBindings as w, juniorAgentInvocations as x, juniorLocationConfigurations as y, juniorAttachmentUploads as z };
@@ -1,10 +1,10 @@
1
- import { Vi as startOAuthFlow } from "./projection-Cns7XwWa.js";
2
- import { n as botConfig } from "./config-BrXDQefC.js";
1
+ import { on as startOAuthFlow } from "./credentialed-Dyv8b-lu.js";
2
+ import { n as botConfig } from "./config-CWbwKj0j.js";
3
3
  import { t as mapBounded } from "./fan-out-Cod-yEHG.js";
4
- import { $t as deleteProviderIdentityForUser, Qt as deleteProviderIdentityForSlackUser, s as getSqlExecutor } from "./db-DTxzH7u5.js";
5
- import { d as hasRequiredOAuthScope } from "./registry-BPwuOP2O.js";
6
- import { n as pluginCatalogRuntime } from "./catalog-runtime-DMY3VV-D.js";
7
- import { h as deleteMcpStoredOAuthCredentials, m as deleteMcpServerSessionId, p as deleteMcpAuthSessionsForUserProvider } from "./service-account-gN0zqf0S.js";
4
+ import { en as deleteProviderIdentityForSlackUser, s as getSqlExecutor, tn as deleteProviderIdentityForUser } from "./db-PwSRzWWn.js";
5
+ import { d as hasRequiredOAuthScope } from "./registry-POH4bZC4.js";
6
+ import { n as pluginCatalogRuntime } from "./catalog-runtime-kkE3hvCX.js";
7
+ import { h as deleteMcpStoredOAuthCredentials, m as deleteMcpServerSessionId, p as deleteMcpAuthSessionsForUserProvider } from "./service-account-o15pZWcJ.js";
8
8
  import { randomBytes } from "node:crypto";
9
9
  // src/handlers/oauth-html.ts
10
10
  /** Build pre-escaped callback HTML with the shared response security policy. */