@sentry/junior 0.108.0 → 0.110.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 (109) hide show
  1. package/dist/{agent-hooks-NU5HK3PS.js → agent-hooks-ELT4ODFF.js} +12 -13
  2. package/dist/api/conversations/access.d.ts +9 -0
  3. package/dist/api/conversations/aggregate.d.ts +12 -1
  4. package/dist/api/conversations/archive.d.ts +3 -5
  5. package/dist/api/conversations/detail.d.ts +156 -7
  6. package/dist/api/conversations/events.d.ts +2 -2
  7. package/dist/api/conversations/list.d.ts +57 -6
  8. package/dist/api/conversations/projection.d.ts +6 -7
  9. package/dist/api/conversations/reporting.d.ts +10 -4
  10. package/dist/api/conversations/routes.d.ts +2 -1
  11. package/dist/api/conversations/shared.d.ts +1 -1
  12. package/dist/api/conversations/stats.d.ts +37 -6
  13. package/dist/api/conversations/stats.query.d.ts +1 -1
  14. package/dist/api/conversations/usage.d.ts +9 -0
  15. package/dist/api/http.d.ts +7 -0
  16. package/dist/api/locations/detail.d.ts +102 -6
  17. package/dist/api/locations/list.d.ts +43 -5
  18. package/dist/api/locations/query.d.ts +4 -2
  19. package/dist/api/locations/routes.d.ts +2 -1
  20. package/dist/api/people/list.d.ts +28 -6
  21. package/dist/api/people/list.query.d.ts +1 -1
  22. package/dist/api/people/profile.d.ts +96 -7
  23. package/dist/api/people/profile.query.d.ts +4 -2
  24. package/dist/api/people/routes.d.ts +2 -1
  25. package/dist/api/people/shared.d.ts +1219 -2
  26. package/dist/api/route.d.ts +18 -4
  27. package/dist/api/schema/common.d.ts +6 -0
  28. package/dist/api/{conversations/schema.d.ts → schema/conversation.d.ts} +88 -9
  29. package/dist/api/{locations/schema.d.ts → schema/location.d.ts} +5 -0
  30. package/dist/api/{people/schema.d.ts → schema/person.d.ts} +37 -45
  31. package/dist/api/schema.d.ts +8 -22
  32. package/dist/api/schema.js +10 -2
  33. package/dist/api.d.ts +5 -1
  34. package/dist/api.js +838 -369
  35. package/dist/app.d.ts +1 -0
  36. package/dist/app.js +1564 -486
  37. package/dist/catalog-runtime-4GI22PXK.js +16 -0
  38. package/dist/chat/agent/resume.d.ts +11 -12
  39. package/dist/chat/conversations/history.d.ts +3 -0
  40. package/dist/chat/conversations/sql/privacy.d.ts +3 -15
  41. package/dist/chat/conversations/sql/store.d.ts +0 -7
  42. package/dist/chat/log-context.d.ts +40 -0
  43. package/dist/chat/logging.d.ts +3 -26
  44. package/dist/chat/pi/messages.d.ts +2 -2
  45. package/dist/chat/pi/sql-model-usage.d.ts +4 -1
  46. package/dist/chat/runtime/slack-resume.d.ts +2 -2
  47. package/dist/chat/services/auth-pause.d.ts +4 -0
  48. package/dist/chat/services/context-compaction.d.ts +1 -0
  49. package/dist/chat/services/turn-session-record.d.ts +0 -2
  50. package/dist/chat/slack/reply.d.ts +7 -19
  51. package/dist/chat/state/conversation.d.ts +1 -0
  52. package/dist/chat/task-execution/queue-signing.d.ts +10 -8
  53. package/dist/chat/task-execution/queue.d.ts +9 -7
  54. package/dist/chat/task-execution/slack-work.d.ts +6 -6
  55. package/dist/{chunk-UD6THJ2I.js → chunk-2T7TIEXI.js} +197 -12
  56. package/dist/{chunk-CEA3A3UA.js → chunk-2ZTTXTSZ.js} +24 -1
  57. package/dist/{chunk-XKB7LGIW.js → chunk-3S7YYHBI.js} +3 -139
  58. package/dist/chunk-3TV7OEHL.js +10 -0
  59. package/dist/{chunk-A5CO2EHL.js → chunk-3UBQI73J.js} +11 -15
  60. package/dist/{chunk-7FBGKXPE.js → chunk-42WRQLJ6.js} +10 -33
  61. package/dist/{chunk-TE4QHJH4.js → chunk-4QU44P7Q.js} +135 -595
  62. package/dist/{chunk-RT5BUHR5.js → chunk-6Y5L4BOM.js} +3 -5
  63. package/dist/{chunk-VIXFG2VC.js → chunk-C4MZ3GP5.js} +1 -2
  64. package/dist/{chunk-3RGQLX2F.js → chunk-C5XAFTHY.js} +1011 -29
  65. package/dist/{chunk-PUAMO4PI.js → chunk-FPK7XY3F.js} +139 -99
  66. package/dist/{chunk-H3QYZL7K.js → chunk-GK47NBDE.js} +28 -3
  67. package/dist/{chunk-O24R4DCK.js → chunk-IYKPU7H6.js} +94 -56
  68. package/dist/chunk-JQFJO5WH.js +477 -0
  69. package/dist/{chunk-VH6KWKG2.js → chunk-L5XQPJ7T.js} +3 -3
  70. package/dist/{chunk-2XXEKR44.js → chunk-MIAKQNYX.js} +43 -31
  71. package/dist/{chunk-KPMPQ6AA.js → chunk-RHHRKSPI.js} +249 -223
  72. package/dist/{chunk-YT72TOEK.js → chunk-SBOBTS27.js} +2 -2
  73. package/dist/{chunk-B5I5LMSP.js → chunk-W6RJZG7F.js} +5 -7
  74. package/dist/chunk-W75ZPAGG.js +44 -0
  75. package/dist/{chunk-SS67LUOK.js → chunk-WNOVRQ67.js} +6 -7
  76. package/dist/{chunk-YIPD3L6L.js → chunk-Y3H2DN6F.js} +8 -10
  77. package/dist/{chunk-DY7TRYB5.js → chunk-Y5FK3CNG.js} +1 -1
  78. package/dist/chunk-ZKIOWEFL.js +125 -0
  79. package/dist/cli/chat.js +23 -24
  80. package/dist/cli/check.js +9 -7
  81. package/dist/cli/plugins.js +16 -17
  82. package/dist/cli/snapshot-warmup.js +11 -10
  83. package/dist/cli/upgrade.js +314 -3505
  84. package/dist/db/db.d.ts +1 -1
  85. package/dist/db/schema/conversations.d.ts +17 -0
  86. package/dist/db/schema.d.ts +17 -0
  87. package/dist/{db-AMRBAT5D.js → db-Y6W6CWWW.js} +8 -7
  88. package/dist/instrumentation.js +4 -3
  89. package/dist/nitro.js +4 -4
  90. package/dist/reporting-schema.d.ts +46 -0
  91. package/dist/{runner-TQH5GAJ4.js → runner-BBFV5GLR.js} +17 -21
  92. package/dist/{skills-ITNHBARB.js → skills-AR4AF32L.js} +8 -6
  93. package/dist/{validation-AGQ46ZGV.js → validation-FBIEPTC2.js} +8 -6
  94. package/dist/version.d.ts +2 -0
  95. package/dist/version.js +7 -0
  96. package/migrations/0006_drop_legacy_conversation_messages.sql +1 -0
  97. package/migrations/0007_thick_sugar_man.sql +23 -0
  98. package/migrations/README.md +12 -9
  99. package/migrations/meta/0006_snapshot.json +948 -0
  100. package/migrations/meta/0007_snapshot.json +1013 -0
  101. package/migrations/meta/_journal.json +14 -0
  102. package/package.json +9 -5
  103. package/dist/catalog-runtime-FOFNPR3P.js +0 -14
  104. package/dist/chunk-AHJR2IFF.js +0 -115
  105. package/dist/chunk-B7PUBQQM.js +0 -53
  106. package/dist/chunk-G3E7SCME.js +0 -28
  107. package/dist/chunk-J3B3FPP2.js +0 -1061
  108. package/dist/chunk-OB42YVAE.js +0 -16
  109. package/dist/chunk-TWINAEZQ.js +0 -1283
package/dist/db/db.d.ts CHANGED
@@ -19,7 +19,7 @@ export interface JuniorSqlMigrationExecutor extends JuniorSqlDatabase {
19
19
  execute(statement: string, params?: readonly unknown[]): Promise<void>;
20
20
  migrate(config: MigrationConfig): Promise<void>;
21
21
  query<T = unknown>(statement: string, params?: readonly unknown[]): Promise<T[]>;
22
- /** Serialize adoption and migration for one Drizzle journal. */
22
+ /** Serialize writes to one Drizzle migration journal. */
23
23
  withMigrationLock<T>(migrationTable: string, callback: () => Promise<T>): Promise<T>;
24
24
  }
25
25
  export interface JuniorSqlExecutor extends JuniorSqlMigrationExecutor {
@@ -430,6 +430,23 @@ export declare const juniorConversations: import("drizzle-orm/pg-core").PgTableW
430
430
  identity: undefined;
431
431
  generated: undefined;
432
432
  }, {}, {}>;
433
+ rootConversationId: import("drizzle-orm/pg-core").PgColumn<{
434
+ name: "root_conversation_id";
435
+ tableName: "junior_conversations";
436
+ dataType: "string";
437
+ columnType: "PgText";
438
+ data: string;
439
+ driverParam: string;
440
+ notNull: false;
441
+ hasDefault: false;
442
+ isPrimaryKey: false;
443
+ isAutoincrement: false;
444
+ hasRuntimeDefault: false;
445
+ enumValues: [string, ...string[]];
446
+ baseColumn: never;
447
+ identity: undefined;
448
+ generated: undefined;
449
+ }, {}, {}>;
433
450
  transcriptPurgedAt: import("drizzle-orm/pg-core").PgColumn<{
434
451
  name: string;
435
452
  tableName: "junior_conversations";
@@ -581,6 +581,23 @@ export declare const juniorSqlSchema: {
581
581
  identity: undefined;
582
582
  generated: undefined;
583
583
  }, {}, {}>;
584
+ rootConversationId: import("drizzle-orm/pg-core").PgColumn<{
585
+ name: "root_conversation_id";
586
+ tableName: "junior_conversations";
587
+ dataType: "string";
588
+ columnType: "PgText";
589
+ data: string;
590
+ driverParam: string;
591
+ notNull: false;
592
+ hasDefault: false;
593
+ isPrimaryKey: false;
594
+ isAutoincrement: false;
595
+ hasRuntimeDefault: false;
596
+ enumValues: [string, ...string[]];
597
+ baseColumn: never;
598
+ identity: undefined;
599
+ generated: undefined;
600
+ }, {}, {}>;
584
601
  transcriptPurgedAt: import("drizzle-orm/pg-core").PgColumn<{
585
602
  name: string;
586
603
  tableName: "junior_conversations";
@@ -5,15 +5,16 @@ import {
5
5
  getConversationStore,
6
6
  getDb,
7
7
  getSqlExecutor
8
- } from "./chunk-TE4QHJH4.js";
9
- import "./chunk-SS67LUOK.js";
8
+ } from "./chunk-4QU44P7Q.js";
9
+ import "./chunk-JQFJO5WH.js";
10
+ import "./chunk-WNOVRQ67.js";
10
11
  import "./chunk-VFUK3X5B.js";
11
- import "./chunk-RT5BUHR5.js";
12
- import "./chunk-B7PUBQQM.js";
13
- import "./chunk-O24R4DCK.js";
14
- import "./chunk-OB42YVAE.js";
12
+ import "./chunk-6Y5L4BOM.js";
13
+ import "./chunk-IYKPU7H6.js";
14
+ import "./chunk-42WRQLJ6.js";
15
15
  import "./chunk-6GWA276C.js";
16
- import "./chunk-7FBGKXPE.js";
16
+ import "./chunk-W75ZPAGG.js";
17
+ import "./chunk-ZKIOWEFL.js";
17
18
  import "./chunk-MLKGABMK.js";
18
19
  export {
19
20
  closeDb,
@@ -3,8 +3,8 @@ import {
3
3
  } from "./chunk-UIE3R5XU.js";
4
4
  import {
5
5
  getCurrentConversationPrivacy
6
- } from "./chunk-RT5BUHR5.js";
7
- import "./chunk-OB42YVAE.js";
6
+ } from "./chunk-6Y5L4BOM.js";
7
+ import "./chunk-42WRQLJ6.js";
8
8
  import {
9
9
  getClient,
10
10
  getGlobalScope,
@@ -15,7 +15,8 @@ import {
15
15
  import {
16
16
  getDeploymentServiceVersion,
17
17
  getDeploymentTelemetryAttributes
18
- } from "./chunk-7FBGKXPE.js";
18
+ } from "./chunk-W75ZPAGG.js";
19
+ import "./chunk-ZKIOWEFL.js";
19
20
  import "./chunk-MLKGABMK.js";
20
21
 
21
22
  // src/chat/sentry-payload-filter.ts
package/dist/nitro.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveConversationWorkQueueTopic
3
- } from "./chunk-2XXEKR44.js";
3
+ } from "./chunk-MIAKQNYX.js";
4
4
  import {
5
5
  PLUGIN_TASK_QUEUE_TOPIC
6
6
  } from "./chunk-KNFROR7R.js";
@@ -12,12 +12,12 @@ import {
12
12
  loadPluginSetFromModule,
13
13
  resolvePluginModule
14
14
  } from "./chunk-Y2CM7HXH.js";
15
- import "./chunk-B7PUBQQM.js";
16
15
  import {
17
16
  discoverInstalledPluginPackageContent,
18
17
  isValidPackageName,
19
18
  resolvePackageDir
20
19
  } from "./chunk-B3IT5END.js";
20
+ import "./chunk-3V7OFJZC.js";
21
21
  import {
22
22
  JUNIOR_CONVERSATION_WORK_CALLBACK_ROUTE,
23
23
  JUNIOR_HEARTBEAT_CRON_SCHEDULE,
@@ -25,8 +25,8 @@ import {
25
25
  JUNIOR_PLUGIN_TASK_CALLBACK_ROUTE,
26
26
  JUNIOR_RETENTION_CRON_SCHEDULE,
27
27
  JUNIOR_RETENTION_ROUTE
28
- } from "./chunk-7FBGKXPE.js";
29
- import "./chunk-3V7OFJZC.js";
28
+ } from "./chunk-W75ZPAGG.js";
29
+ import "./chunk-ZKIOWEFL.js";
30
30
  import "./chunk-MLKGABMK.js";
31
31
 
32
32
  // src/nitro.ts
@@ -90,6 +90,29 @@ export declare const pluginOperationalReportSchema: z.ZodObject<{
90
90
  }, z.core.$strict>>>;
91
91
  title: z.ZodOptional<z.ZodString>;
92
92
  pluginName: z.ZodString;
93
+ widgets: z.ZodOptional<z.ZodArray<z.ZodObject<{
94
+ categories: z.ZodArray<z.ZodObject<{
95
+ id: z.ZodString;
96
+ label: z.ZodString;
97
+ values: z.ZodRecord<z.ZodString, z.ZodNumber>;
98
+ }, z.core.$strict>>;
99
+ description: z.ZodOptional<z.ZodString>;
100
+ emptyText: z.ZodOptional<z.ZodString>;
101
+ id: z.ZodString;
102
+ series: z.ZodArray<z.ZodObject<{
103
+ key: z.ZodString;
104
+ label: z.ZodString;
105
+ tone: z.ZodOptional<z.ZodEnum<{
106
+ warning: "warning";
107
+ danger: "danger";
108
+ good: "good";
109
+ neutral: "neutral";
110
+ }>>;
111
+ }, z.core.$strict>>;
112
+ timeRangeDays: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<7>, z.ZodLiteral<30>, z.ZodLiteral<90>]>>>;
113
+ title: z.ZodString;
114
+ type: z.ZodLiteral<"bar_chart">;
115
+ }, z.core.$strict>>>;
93
116
  }, z.core.$strict>;
94
117
  export declare const pluginOperationalReportFeedSchema: z.ZodObject<{
95
118
  generatedAt: z.ZodString;
@@ -125,6 +148,29 @@ export declare const pluginOperationalReportFeedSchema: z.ZodObject<{
125
148
  }, z.core.$strict>>>;
126
149
  title: z.ZodOptional<z.ZodString>;
127
150
  pluginName: z.ZodString;
151
+ widgets: z.ZodOptional<z.ZodArray<z.ZodObject<{
152
+ categories: z.ZodArray<z.ZodObject<{
153
+ id: z.ZodString;
154
+ label: z.ZodString;
155
+ values: z.ZodRecord<z.ZodString, z.ZodNumber>;
156
+ }, z.core.$strict>>;
157
+ description: z.ZodOptional<z.ZodString>;
158
+ emptyText: z.ZodOptional<z.ZodString>;
159
+ id: z.ZodString;
160
+ series: z.ZodArray<z.ZodObject<{
161
+ key: z.ZodString;
162
+ label: z.ZodString;
163
+ tone: z.ZodOptional<z.ZodEnum<{
164
+ warning: "warning";
165
+ danger: "danger";
166
+ good: "good";
167
+ neutral: "neutral";
168
+ }>>;
169
+ }, z.core.$strict>>;
170
+ timeRangeDays: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<7>, z.ZodLiteral<30>, z.ZodLiteral<90>]>>>;
171
+ title: z.ZodString;
172
+ type: z.ZodLiteral<"bar_chart">;
173
+ }, z.core.$strict>>>;
128
174
  }, z.core.$strict>>;
129
175
  source: z.ZodLiteral<"plugins">;
130
176
  }, z.core.$strict>;
@@ -4,15 +4,17 @@ import {
4
4
  finalizeFailedTurnReplyWithEvent,
5
5
  processPluginTask,
6
6
  scheduleSessionCompletedPluginTasks
7
- } from "./chunk-A5CO2EHL.js";
7
+ } from "./chunk-3UBQI73J.js";
8
8
  import "./chunk-KNFROR7R.js";
9
9
  import {
10
10
  buildConversationContext,
11
11
  coerceThreadArtifactsState,
12
+ coerceThreadConversationState,
12
13
  completeDeliveredTurn,
13
14
  getPersistedSandboxState,
14
15
  getPersistedThreadState,
15
16
  hydrateConversationMessages,
17
+ loadProjection,
16
18
  markConversationMessage,
17
19
  markTurnFailed,
18
20
  normalizeConversationText,
@@ -23,36 +25,31 @@ import {
23
25
  startActiveTurn,
24
26
  updateConversationStats,
25
27
  upsertConversationMessage
26
- } from "./chunk-3RGQLX2F.js";
27
- import {
28
- coerceThreadConversationState,
29
- loadProjection
30
- } from "./chunk-J3B3FPP2.js";
28
+ } from "./chunk-C5XAFTHY.js";
31
29
  import "./chunk-MU6HHZEN.js";
32
30
  import "./chunk-PDO5BLNM.js";
33
- import "./chunk-UD6THJ2I.js";
34
- import "./chunk-AHJR2IFF.js";
35
- import "./chunk-G3E7SCME.js";
36
- import "./chunk-H3QYZL7K.js";
37
- import "./chunk-VH6KWKG2.js";
31
+ import "./chunk-2T7TIEXI.js";
32
+ import "./chunk-GK47NBDE.js";
33
+ import "./chunk-L5XQPJ7T.js";
38
34
  import {
39
35
  getConversationEventStore
40
- } from "./chunk-TE4QHJH4.js";
36
+ } from "./chunk-4QU44P7Q.js";
37
+ import "./chunk-JQFJO5WH.js";
41
38
  import "./chunk-4ZNGQH7C.js";
42
39
  import {
43
40
  stripRuntimeTurnContext,
44
41
  trimTrailingAssistantMessages
45
- } from "./chunk-SS67LUOK.js";
42
+ } from "./chunk-WNOVRQ67.js";
46
43
  import "./chunk-VFUK3X5B.js";
47
- import "./chunk-RT5BUHR5.js";
48
- import "./chunk-B7PUBQQM.js";
49
- import "./chunk-VIXFG2VC.js";
44
+ import "./chunk-6Y5L4BOM.js";
45
+ import "./chunk-C4MZ3GP5.js";
50
46
  import {
51
47
  logException
52
- } from "./chunk-O24R4DCK.js";
53
- import "./chunk-OB42YVAE.js";
48
+ } from "./chunk-IYKPU7H6.js";
49
+ import "./chunk-42WRQLJ6.js";
54
50
  import "./chunk-6GWA276C.js";
55
- import "./chunk-7FBGKXPE.js";
51
+ import "./chunk-W75ZPAGG.js";
52
+ import "./chunk-ZKIOWEFL.js";
56
53
  import "./chunk-MLKGABMK.js";
57
54
 
58
55
  // src/chat/local/runner.ts
@@ -366,8 +363,7 @@ async function runLocalAgentTurn(input, deps) {
366
363
  destination,
367
364
  source,
368
365
  actor: localActor,
369
- surface: "internal",
370
- logContext: {}
366
+ surface: "internal"
371
367
  });
372
368
  }
373
369
  } catch (error) {
@@ -6,15 +6,17 @@ import {
6
6
  parseSkillInvocation,
7
7
  resetSkillDiscoveryCache,
8
8
  stripFrontmatter
9
- } from "./chunk-YT72TOEK.js";
10
- import "./chunk-YIPD3L6L.js";
11
- import "./chunk-VIXFG2VC.js";
12
- import "./chunk-O24R4DCK.js";
13
- import "./chunk-OB42YVAE.js";
9
+ } from "./chunk-SBOBTS27.js";
10
+ import "./chunk-3TV7OEHL.js";
11
+ import "./chunk-Y3H2DN6F.js";
12
+ import "./chunk-C4MZ3GP5.js";
13
+ import "./chunk-IYKPU7H6.js";
14
+ import "./chunk-42WRQLJ6.js";
14
15
  import "./chunk-6GWA276C.js";
15
16
  import "./chunk-B3IT5END.js";
16
- import "./chunk-7FBGKXPE.js";
17
17
  import "./chunk-3V7OFJZC.js";
18
+ import "./chunk-W75ZPAGG.js";
19
+ import "./chunk-ZKIOWEFL.js";
18
20
  import "./chunk-MLKGABMK.js";
19
21
  export {
20
22
  discoverSkills,
@@ -1,15 +1,17 @@
1
1
  import {
2
2
  validatePluginEgressCredentialHooks,
3
3
  validatePluginRegistrations
4
- } from "./chunk-DY7TRYB5.js";
5
- import "./chunk-YIPD3L6L.js";
6
- import "./chunk-VIXFG2VC.js";
7
- import "./chunk-O24R4DCK.js";
8
- import "./chunk-OB42YVAE.js";
4
+ } from "./chunk-Y5FK3CNG.js";
5
+ import "./chunk-3TV7OEHL.js";
6
+ import "./chunk-Y3H2DN6F.js";
7
+ import "./chunk-C4MZ3GP5.js";
8
+ import "./chunk-IYKPU7H6.js";
9
+ import "./chunk-42WRQLJ6.js";
9
10
  import "./chunk-6GWA276C.js";
10
11
  import "./chunk-B3IT5END.js";
11
- import "./chunk-7FBGKXPE.js";
12
12
  import "./chunk-3V7OFJZC.js";
13
+ import "./chunk-W75ZPAGG.js";
14
+ import "./chunk-ZKIOWEFL.js";
13
15
  import "./chunk-MLKGABMK.js";
14
16
  export {
15
17
  validatePluginEgressCredentialHooks,
@@ -0,0 +1,2 @@
1
+ /** Installed Junior package version, or `unknown` when package metadata is unavailable. */
2
+ export declare const JUNIOR_VERSION: string;
@@ -0,0 +1,7 @@
1
+ import {
2
+ JUNIOR_VERSION
3
+ } from "./chunk-ZKIOWEFL.js";
4
+ import "./chunk-MLKGABMK.js";
5
+ export {
6
+ JUNIOR_VERSION
7
+ };
@@ -0,0 +1 @@
1
+ DROP TABLE "junior_conversation_messages";
@@ -0,0 +1,23 @@
1
+ ALTER TABLE "junior_conversations" ADD COLUMN "root_conversation_id" text;--> statement-breakpoint
2
+ WITH RECURSIVE "conversation_roots" AS (
3
+ SELECT
4
+ "conversation_id",
5
+ "conversation_id" AS "root_conversation_id"
6
+ FROM "junior_conversations"
7
+ WHERE "parent_conversation_id" IS NULL
8
+
9
+ UNION ALL
10
+
11
+ SELECT
12
+ child."conversation_id",
13
+ parent."root_conversation_id"
14
+ FROM "junior_conversations" child
15
+ JOIN "conversation_roots" parent
16
+ ON child."parent_conversation_id" = parent."conversation_id"
17
+ )
18
+ UPDATE "junior_conversations" conversation
19
+ SET "root_conversation_id" = roots."root_conversation_id"
20
+ FROM "conversation_roots" roots
21
+ WHERE conversation."conversation_id" = roots."conversation_id";--> statement-breakpoint
22
+ ALTER TABLE "junior_conversations" ADD CONSTRAINT "junior_conversations_root_conversation_id_junior_conversations_conversation_id_fk" FOREIGN KEY ("root_conversation_id") REFERENCES "public"."junior_conversations"("conversation_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
23
+ CREATE INDEX "junior_conversations_root_idx" ON "junior_conversations" USING btree ("root_conversation_id");
@@ -3,10 +3,15 @@
3
3
  `src/db/schema.ts` is the Drizzle schema entrypoint. This directory is the
4
4
  append-only history used to bring an existing database to that schema.
5
5
 
6
- `junior upgrade` runs the ordered migration list in `src/cli/upgrade.ts`. Core
7
- SQL runs under a migration lock and is recorded in
8
- `drizzle.__drizzle_junior_core`, so reruns do not reapply it. Register backfills
9
- after the schema migration they require.
6
+ `junior upgrade` applies core migrations and enabled plugins' packaged Drizzle
7
+ migrations. Core SQL is recorded in `drizzle.__drizzle_junior_core`. Reruns
8
+ check that journal before taking the migration lock, so an already-current
9
+ schema returns without opening a second SQL connection.
10
+
11
+ An existing Junior schema without the core Drizzle journal cannot be upgraded
12
+ directly. Upgrade it with `@sentry/junior@0.107.1` first so that bridge release
13
+ can establish the journal, then continue to the target version. A database with
14
+ no Junior tables remains a normal fresh install.
10
15
 
11
16
  ## Add a migration
12
17
 
@@ -15,13 +20,11 @@ after the schema migration they require.
15
20
  3. Review the generated SQL and commit it with `meta/_journal.json` and its
16
21
  snapshot.
17
22
 
18
- - Prefer SQL for schema changes and deterministic transformations of rows in
19
- the same database.
20
- - Use an application data migration only for external data or work that must be
21
- decoded in application code; keep it bounded and rerunnable.
23
+ - Put deterministic row transformations in the SQL migration that requires
24
+ them.
22
25
  - Never edit, rename, reorder, or delete an applied SQL migration or its
23
26
  metadata. Add a new migration to correct it.
24
27
 
25
- Migration loading, locking, and legacy baseline adoption live in
28
+ Migration loading, locking, and the bridge-version guard live in
26
29
  `src/chat/conversations/sql/migrations.ts`. Their integration coverage lives in
27
30
  `tests/integration/conversation-sql.test.ts`.